@blinkk/selective-edit
Version:
Selective structured text editor.
42 lines • 1.46 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TimeField = 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 TimeField extends field_1.Field {
constructor(types, config, globalConfig, fieldType = 'text') {
super(types, config, globalConfig, fieldType);
this.config = config;
}
/**
* Cleanup the time strings.
*
* @param value Original value from the source.
*/
cleanOriginalValue(value) {
value = super.cleanOriginalValue(value);
// If the time string is too long, strip off extra.
if (value && dataType_1.DataType.isString(value) && value.length > 5) {
value = value.slice(0, 5);
}
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="time"
id="${this.uid}"
@blur=${this.handleBlur.bind(this)}
@input=${this.handleInput.bind(this)}
value=${value}
/>
</div>
${this.templateErrors(editor, data)}`;
}
}
exports.TimeField = TimeField;
//# sourceMappingURL=time.js.map