UNPKG

@blinkk/selective-edit

Version:
42 lines 1.46 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DateField = void 0; const field_1 = require("../field"); const lit_html_1 = require("lit-html"); const dataType_1 = require("../../utility/dataType"); const class_map_js_1 = require("lit-html/directives/class-map.js"); class DateField extends field_1.Field { constructor(types, config, globalConfig, fieldType = 'text') { super(types, config, globalConfig, fieldType); this.config = config; } /** * Cleanup the date strings. * * @param value Original value from the source. */ cleanOriginalValue(value) { value = super.cleanOriginalValue(value); // If the date string is too long, strip off extra. if (value && dataType_1.DataType.isString(value) && value.length > 10) { value = value.slice(0, 10); } return value; } 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="date" id="${this.uid}" @blur=${this.handleBlur.bind(this)} @input=${this.handleInput.bind(this)} value=${value} /> </div> ${this.templateErrors(editor, data)}`; } } exports.DateField = DateField; //# sourceMappingURL=date.js.map