UNPKG

@blinkk/selective-edit

Version:
42 lines 1.52 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.NumberField = void 0; const field_1 = require("../field"); const lit_html_1 = require("lit-html"); const class_map_js_1 = require("lit-html/directives/class-map.js"); class NumberField extends field_1.Field { constructor(types, config, globalConfig, fieldType = 'text') { super(types, config, globalConfig, fieldType); this.config = config; } /** * Handle when the input changes value. * * @param evt Input event from changing value. */ handleInput(evt) { const target = evt.target; this.currentValue = parseFloat(target.value) || undefined; this.render(); } templateInput(editor, data) { const value = this.currentValue || ''; return (0, lit_html_1.html) `${this.templateHelp(editor, data)} <div class=${(0, class_map_js_1.classMap)(this.classesForInput())}> <input type="number" id="${this.uid}" placeholder=${this.config.placeholder || ''} @blur=${this.handleBlur.bind(this)} @input=${this.handleInput.bind(this)} max=${this.config.max === undefined ? '' : this.config.max} min=${this.config.min === undefined ? '' : this.config.min} step=${this.config.step || 1} value=${value} /> </div> ${this.templateErrors(editor, data)}`; } } exports.NumberField = NumberField; //# sourceMappingURL=number.js.map