Sha256: ecef32bb11a02710fa8b7449b45bade09ff149a28be5a6e2f065e21791f27a5c
Contents?: true
Size: 1.44 KB
Versions: 1
Compression:
Stored size: 1.44 KB
Contents
import { Controller } from "@hotwired/stimulus" import Inputmask from "https://cdn.jsdelivr.net/npm/inputmask@5.0.9/+esm" export default class extends Controller { static values = { mask: String, alias: String, groupSeparator: { type: String, default: "" }, radixPoint: { type: String, default: "." }, digits: { type: String, default: "*" }, digitsOptional: { type: Boolean, default: true }, inputFormat: { type: String, default: "mm/dd/yyyy HH:MM" }, outputFormat: { type: String, default: "yyyy-mm-dd HH:MM" } } connect() { if (this.hasMaskValue) { Inputmask({ mask: this.maskValue }).mask(this.element) } else if (this.aliasValue == "numeric") { Inputmask(this.#numericOptions).mask(this.element) } else if (this.aliasValue == "datetime") { Inputmask(this.#datetimeOptions).mask(this.element) } } disconnect() { Inputmask.remove(this.element) } get #numericOptions() { return { alias: "numeric", unmaskAsNumber: true, removeMaskOnSubmit: true, groupSeparator: this.groupSeparatorValue, radixPoint: this.radixPointValue, digits: this.digitsValue, digitsOptional: this.digitsOptionalValue } } get #datetimeOptions() { return { alias: "datetime", removeMaskOnSubmit: true, inputFormat: this.inputFormatValue, outputFormat: this.outputFormatValue } } }
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
css-zero-0.0.87 | lib/generators/css_zero/add/templates/app/javascript/controllers/inputmask_controller.js |