-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Description
i'm trying use Cleave in my rails project with stumulus and i have this error.
how to fix this ?
My code:
import { Controller } from "@hotwired/stimulus"
import Cleave from "cleave.js"
// Connects to data-controller="cleave"
export default class extends Controller {
static values = {
delimiter: String,
uppercase: Boolean,
blocks: String,
type: String
}
connect() {
this.setOptions()
this.cleave = new Cleave(this.element, this.options)
console.log(this.cleave)
}
disconnect() {
if (this.cleave) {
this.cleave.destroy()
}
}
setOptions() {
this.options = {}
if (this.hasDelimiterValue) { this.options["delimiter"] = this.delimiterValue }
if (this.hasBlocksValue) { this.options["blocks"] = this.blocksValue.split(",").map(Number) }
if (this.hasUppercaseValue) { this.options["uppercase"] = this.uppercaseValue }
switch(this.hasTypeValue && this.typeValue) {
case "credit-card":
this.options["creditCard"] = true
break;
case "date":
this.options["date"] = true
this.options["datePattern"] = ["d", "m", "Y"]
break;
case "number":
this.options["numeral"] = true
this.options["numeralThousandsGroupStyle"] = "thousand"
break;
case "phone":
this.options["phone"] = true
this.options["phoneRegionCode"] = "BR";
this.options["prefix"] = "+55"
this.options["delimiter"] = "-"
break;
case "time":
this.options["time"] = true
this.options["timePattern"] = ["h", "m", "s"]
break;
}
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
