@cas-smartdesign/lit-input 7.4.0 → 7.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/input.mjs
CHANGED
|
@@ -170,10 +170,10 @@ const e = (o = class extends f {
|
|
|
170
170
|
new CustomEvent(`${t ? "immediate-" : ""}value-change`, {
|
|
171
171
|
detail: { value: this.value }
|
|
172
172
|
})
|
|
173
|
-
), this.setFormValue(this.value)
|
|
173
|
+
), this.setFormValue(this.value);
|
|
174
174
|
}
|
|
175
175
|
updateFormValidity() {
|
|
176
|
-
if (this.validationMessage == null) {
|
|
176
|
+
if (this.validationMessage == null && this.inputElement != null) {
|
|
177
177
|
this._internals.setValidity(this.inputElement.validity, this.inputElement.validationMessage);
|
|
178
178
|
const t = this.shadowRoot.querySelector("sd-field-validation-message");
|
|
179
179
|
this.requestUpdate("validationMessage", t == null ? null : t.message);
|
|
@@ -183,7 +183,7 @@ const e = (o = class extends f {
|
|
|
183
183
|
return this.alwaysFloatLabel || this.currentText || this.placeholder || this.autocompleted || this.type === "date";
|
|
184
184
|
}
|
|
185
185
|
setFormValue(t) {
|
|
186
|
-
this._internals?.setFormValue(t);
|
|
186
|
+
this._internals?.setFormValue(t), this.updateFormValidity();
|
|
187
187
|
}
|
|
188
188
|
formResetCallback() {
|
|
189
189
|
this.value = this._initialValue;
|
package/dist/input.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.mjs","sources":["../input.ts"],"sourcesContent":["import { LitElement, html, PropertyValues, unsafeCSS, TemplateResult, css, nothing } from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\nimport { ValidationLevel } from \"@cas-smartdesign/field-validation-message\";\n\nconst TAG_NAME = \"sd-lit-input\";\n\ndeclare global {\n interface HTMLElementTagNameMap {\n [TAG_NAME]: SDInput;\n }\n}\n\nimport style from \"./style.scss?inline\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst delegatesFocus = \"delegatesFocus\" in (window as any).ShadowRoot.prototype;\n\nlet idCounter = 0;\n\nexport interface IValueChangeEvent {\n value: string;\n}\n\nexport interface CustomEventMap extends HTMLElementEventMap {\n \"immediate-value-change\": CustomEvent<IValueChangeEvent>;\n \"value-change\": CustomEvent<IValueChangeEvent>;\n}\n\nexport default interface SDInput {\n addEventListener<K extends keyof CustomEventMap>(\n event: K,\n listener: ((this: this, ev: CustomEventMap[K]) => unknown) | null,\n options?: AddEventListenerOptions | boolean,\n ): void;\n addEventListener(\n type: string,\n callback: EventListenerOrEventListenerObject | null,\n options?: AddEventListenerOptions | boolean,\n ): void;\n removeEventListener<K extends keyof CustomEventMap>(\n type: K,\n listener: (this: this, ev: CustomEventMap[K]) => unknown,\n options?: boolean | EventListenerOptions,\n ): void;\n removeEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | EventListenerOptions,\n ): void;\n dispatchEvent<EventType extends CustomEventMap[keyof CustomEventMap]>(event: EventType): boolean;\n}\n\nexport default class SDInput extends LitElement {\n public static readonly ID: string = TAG_NAME;\n private static readonly DEFAULT_MAX_LENGTH: number = 524288;\n static formAssociated = true;\n\n @property({ type: String, reflect: true })\n public label: string;\n @property({ type: String, attribute: true })\n public validationMessage: string;\n @property({ type: String, attribute: true })\n public validationIconSrc: string;\n @property({ type: ValidationLevel, attribute: true, reflect: true })\n public validationLevel: ValidationLevel;\n @property({\n type: String,\n hasChanged(value, oldValue) {\n return oldValue != undefined && oldValue != value;\n },\n })\n public currentText;\n @property({ type: Boolean, attribute: true })\n public alwaysFloatLabel: boolean;\n @property({ type: Boolean, attribute: true })\n public autocompleted: boolean;\n @property({ type: Number, attribute: true })\n public rows = 1;\n @property({ type: Boolean, reflect: true, attribute: \"effective-disabled\" })\n public effectiveDisabled: boolean = false;\n @property({ type: Boolean, reflect: true, attribute: \"extended-prefix\" })\n public extendedPrefix: boolean;\n\n // delegated settings to input\n @property({ type: String, reflect: true })\n public type = \"text\";\n @property({ type: String, reflect: true })\n public placeholder: string;\n @property({ type: String, reflect: true })\n public sdAriaLabel: string;\n @property({ type: Number, reflect: true })\n public maxlength: number;\n @property({ type: Boolean, reflect: true })\n public readonly: boolean;\n @property({ type: Boolean, reflect: true })\n public required: boolean;\n @property({ type: String, reflect: true })\n public name: string;\n @property({ type: Boolean, reflect: true })\n public inactive: boolean;\n @property({ type: String, attribute: true })\n public autocomplete: AutoFill = \"off\";\n @property({ type: String, attribute: true })\n public min: string;\n @property({ type: String, attribute: true })\n public max: string;\n @property({ type: String, attribute: true })\n public pattern: string;\n\n private _inputElement: HTMLInputElement;\n private _initialized: boolean;\n private _needsAutocompletedCheck: boolean;\n private _validationMessageId: string;\n private _inputId: string;\n private _internals: ElementInternals;\n private _initialValue: string;\n\n static shadowRootOptions: ShadowRootInit = {\n ...LitElement.shadowRootOptions,\n delegatesFocus,\n };\n\n constructor() {\n super();\n const nextIdNumber = idCounter++;\n this._validationMessageId = SDInput.ID + \"_message_\" + nextIdNumber;\n this._inputId = SDInput.ID + \"_input_\" + nextIdNumber;\n if (this.attachInternals && !this.activeShadyDOM) {\n this._internals = this.attachInternals();\n }\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n if (!this.hasAttribute(\"tabIndex\")) {\n this.tabIndex = 0;\n }\n }\n\n protected firstUpdated(changedProperties: PropertyValues): void {\n super.firstUpdated(changedProperties);\n this.initAutocompleted(this.inputElement);\n this.updateInitialValue();\n this.updateFormValidity();\n\n if (this.hasAttribute(\"disabled\")) {\n this.disabled = true;\n }\n\n this.inputElement.oninput = (event: InputEvent) => {\n this.autocompleted = \"insertReplacementText\" === event.inputType || !(\"data\" in event);\n this.currentText = this.inputElement.value;\n this.fireValueChange(true);\n };\n this.inputElement.onchange = () => this.fireValueChange();\n if (!delegatesFocus) {\n // Provide a limited \"delegatesFocus\" behavior where it is not supported.\n // Note that clicking on non-focusable elements inside the shadow root\n // does not focus the first focusable element as it would have been expected.\n this.inputElement.onfocus = () => this.setAttribute(\"focused\", \"\");\n this.inputElement.onblur = () => this.removeAttribute(\"focused\");\n this.addEventListener(\"focus\", (event) => {\n if (event.target === this) {\n this.inputElement.focus();\n }\n });\n }\n // An input with 'type: date' may not dispatch change or input events in partially filled state\n this.inputElement.addEventListener(\"keyup\", () => {\n this.updateFormValidity();\n });\n this.addEventListener(\"keydown\", (event) => {\n if (event.key == \"Enter\") {\n this._internals?.form?.requestSubmit();\n }\n });\n this._initialized = true;\n }\n\n private initAutocompleted(target: HTMLElement) {\n const listener = (event) => {\n if (/^onautofillstart(-sd-lit-input-\\d+|\\s?)$/.test(event.animationName)) {\n this.autocompleted = true;\n } else if (/^onautofillcancel(-sd-lit-input-\\d+|\\s?)$/.test(event.animationName)) {\n this.autocompleted = false;\n }\n };\n if (this.activeShadyDOM) {\n this._needsAutocompletedCheck = true;\n this.activeShadyDOM.nativeMethods.addEventListener.call(target, \"animationstart\", listener);\n } else {\n target.addEventListener(\"animationstart\", listener);\n }\n }\n\n private get activeShadyDOM(): { nativeMethods } | null {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const shadyDOM = (window as any).ShadyDOM;\n return shadyDOM && shadyDOM.inUse ? shadyDOM : null;\n }\n\n private updateInitialValue(): void {\n if (typeof this.currentText !== \"undefined\") {\n this.value = this.currentText;\n } else {\n this.value = this.getAttribute(\"value\");\n }\n if (this.value) {\n this.currentText = this.inputElement.value;\n }\n this._initialValue = this.value;\n }\n\n public get disabled(): boolean {\n return this.hasAttribute(\"disabled\");\n }\n\n public set disabled(disabled: boolean) {\n if (disabled) {\n this.setAttribute(\"disabled\", \"\");\n } else {\n this.removeAttribute(\"disabled\");\n }\n if (!this._internals) {\n this.effectiveDisabled = disabled;\n }\n }\n\n // It is public as hacking around due to IE 11 is a common task to do.\n public get inputElement(): HTMLInputElement {\n if (this.shadowRoot && !this._inputElement) {\n this._inputElement = this.shadowRoot.querySelector(\".input\");\n }\n return this._inputElement;\n }\n\n public get value(): string {\n return this.inputElement && this.inputElement.value;\n }\n\n public set value(newValue: string) {\n this.currentText = newValue || \"\";\n if (this.inputElement) {\n this.inputElement.value = this.currentText;\n }\n this.setFormValue(this.currentText);\n }\n\n public get selectionStart(): number {\n return this.inputElement ? this.inputElement.selectionStart : 0;\n }\n\n public focus(): void {\n if (this.inputElement) {\n this.inputElement.focus();\n } else {\n super.focus();\n }\n }\n\n public select(): void {\n if (this.inputElement) {\n this.inputElement.select();\n }\n }\n\n public setSelectionRange(start: number, end: number): void {\n this.updateComplete.then(() => {\n if (this.inputElement) {\n this.inputElement.setSelectionRange(start, end);\n }\n });\n }\n\n static get styles() {\n return [\n css`\n ${unsafeCSS(style)}\n `,\n ];\n }\n\n public render(): TemplateResult {\n let inputPart;\n const valMessage = this.validationMessage || this.inputElement?.validationMessage;\n const isInvalid = valMessage || this.validationLevel != null;\n if (this.rows === 1) {\n inputPart = html`\n <input\n id=${this._inputId}\n class=\"input\"\n .type=${this.type}\n placeholder=${ifDefined(this.placeholder || undefined)}\n name=${ifDefined(this.name || undefined)}\n aria-disabled=${this.effectiveDisabled}\n autocomplete=${this.autocomplete}\n ?disabled=${this.inactive}\n ?readonly=${this.readonly || this.effectiveDisabled}\n ?required=${this.required}\n maxlength=${this.maxlength > 0 ? this.maxlength : SDInput.DEFAULT_MAX_LENGTH}\n aria-describedby=${this._validationMessageId}\n aria-invalid=${ifDefined(isInvalid)}\n aria-label=${ifDefined(this.sdAriaLabel || undefined)}\n min=${ifDefined(this.min || undefined)}\n max=${ifDefined(this.max || undefined)}\n pattern=${ifDefined(this.pattern || undefined)}\n />\n `;\n } else {\n inputPart = html`\n <textarea\n id=${this._inputId}\n class=\"input\"\n placeholder=${ifDefined(this.placeholder || undefined)}\n name=${ifDefined(this.name || undefined)}\n aria-disabled=${this.effectiveDisabled}\n autocomplete=${this.autocomplete}\n ?disabled=${this.inactive}\n ?readonly=${this.readonly || this.effectiveDisabled}\n ?required=${this.required}\n maxlength=${this.maxlength > 0 ? this.maxlength : SDInput.DEFAULT_MAX_LENGTH}\n rows=${this.rows}\n aria-describedby=${this._validationMessageId}\n aria-invalid=${ifDefined(isInvalid)}\n aria-label=${ifDefined(this.sdAriaLabel || undefined)}\n ></textarea>\n `;\n }\n\n return html`\n ${this.label ? html` <div class=\"floated-label-placeholder\" aria-hidden=\"true\"> </div> ` : nothing}\n <div class=\"input-wrapper\">\n <span class=\"prefix\"><slot name=\"prefix\"></slot></span>\n <div class=\"input-container\" style=\"position:${this.shouldFloat() ? \"static\" : \"relative\"};\">\n ${this.label &&\n html`\n <label for=\"${this._inputId}\" class=\"label ${this.shouldFloat() ? \"float\" : \"\"}\"\n >${this.label}</label\n >\n `}\n ${inputPart}\n </div>\n <span class=\"suffix\"><slot name=\"suffix\"></slot></span>\n </div>\n <div class=\"underline\" aria-hidden=\"true\">\n <div class=\"unfocused-line\"></div>\n <div class=\"focused-line\"></div>\n </div>\n <div class=\"validation-message-wrapper\" aria-hidden=\"true\">\n ${(valMessage || this.validationIconSrc) &&\n html`\n <sd-field-validation-message\n id=${this._validationMessageId}\n class=\"validation-message\"\n .message=${valMessage}\n .icon=${this.validationIconSrc}\n .level=${this.validationLevel}\n >\n </sd-field-validation-message>\n `}\n </div>\n `;\n }\n\n protected updated(changedProperties: PropertyValues): void {\n super.updated(changedProperties);\n if (this._needsAutocompletedCheck && !this.autocompleted) {\n setTimeout(() => {\n try {\n // In certain cases there is no animation event dispatched even if the animation itself is done (it is visible also in dev tools) when an autofill is done.\n this.autocompleted = this.autocompleted || !!this.shadowRoot.querySelector(\":-webkit-autofill\");\n } catch (ignored) {\n // the above used selector is not supported for example in Firefox\n }\n }, 0);\n }\n if (this.rows > 1) {\n if (changedProperties.has(\"min\") || changedProperties.has(\"max\") || changedProperties.has(\"pattern\")) {\n console.warn(\"min, max & pattern attributes are not supported with multiple rows configuration.\");\n }\n if (\"text\" != this.type) {\n console.warn(`type: ${this.type} is not supported with multiple rows configuration.`);\n }\n }\n }\n\n public update(changedProperties: PropertyValues): void {\n super.update(changedProperties);\n if (changedProperties.has(\"validationMessage\")) {\n if (this.validationMessage) {\n this._internals?.setValidity({ customError: true }, this.validationMessage);\n } else {\n this._internals?.setValidity(this.inputElement.validity, this.inputElement.validationMessage);\n }\n }\n if (this._initialized && changedProperties.has(\"rows\")) {\n throw Error(\"rows attribute cannot be changed after the input is attached to the DOM\");\n }\n }\n\n protected fireValueChange(immediate?: boolean): void {\n this.dispatchEvent(\n new CustomEvent<IValueChangeEvent>(`${immediate ? \"immediate-\" : \"\"}value-change`, {\n detail: { value: this.value },\n }),\n );\n this.setFormValue(this.value);\n this.updateFormValidity();\n }\n\n private updateFormValidity() {\n if (this.validationMessage == null) {\n this._internals.setValidity(this.inputElement.validity, this.inputElement.validationMessage);\n const valMessageEl = this.shadowRoot.querySelector(\"sd-field-validation-message\");\n this.requestUpdate(\"validationMessage\", valMessageEl == null ? null : valMessageEl.message);\n }\n }\n\n protected shouldFloat() {\n return (\n this.alwaysFloatLabel || this.currentText || this.placeholder || this.autocompleted || this.type === \"date\"\n );\n }\n\n protected setFormValue(value: string | File | FormData) {\n this._internals?.setFormValue(value);\n }\n\n protected formResetCallback() {\n this.value = this._initialValue;\n }\n\n protected formDisabledCallback(disabled: boolean) {\n this.effectiveDisabled = disabled || this.hasAttribute(\"disabled\");\n }\n\n protected formAssociatedCallback(_form: HTMLFormElement) {\n this._needsAutocompletedCheck = true;\n }\n\n protected formStateRestoreCallback(state: File | string | FormData | null, reason: unknown) {\n if (typeof state == \"string\") {\n this.value = state;\n }\n }\n}\n\nif (!customElements.get(SDInput.ID)) {\n customElements.define(SDInput.ID, SDInput);\n}\n"],"names":["TAG_NAME","delegatesFocus","idCounter","_SDInput","_a","LitElement","nextIdNumber","changedProperties","event","target","listener","shadyDOM","disabled","newValue","start","end","css","unsafeCSS","style","inputPart","valMessage","isInvalid","html","ifDefined","nothing","immediate","valMessageEl","value","_form","state","reason","__decorateClass","property","ValidationLevel","oldValue","SDInput"],"mappings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AAA;AAEA4B,EAAA;AAAA,EADNC,EAAS,EAAE,MAAM,QAAQ,WAAW,IAAM;AAAA,GAhD1B7B,EAiDV,WAAA,cAAA;AAEA4B,EAAA;AAAA,EADNC,EAAS,EAAE,MAAM,QAAQ,WAAW,IAAM;AAAA,GAlD1B7B,EAmDV,WAAA,KAAA;AAEA4B,EAAA;AAAA,EADNC,EAAS,EAAE,MAAM,QAAQ,WAAW,IAAM;AAAA,GApD1B7B,EAqDV,WAAA,KAAA;AAEA4B,EAAA;AAAA,EADNC,EAAS,EAAE,MAAM,QAAQ,WAAW,IAAM;AAAA,GAtD1B7B,EAuDV,WAAA,SAAA;AAvDX,IAAqBgC,IAArBhC;AA2YK,eAAe,IAAIgC,EAAQ,EAAE,KAC9B,eAAe,OAAOA,EAAQ,IAAIA,CAAO;"}
|
|
1
|
+
{"version":3,"file":"input.mjs","sources":["../input.ts"],"sourcesContent":["import { LitElement, html, PropertyValues, unsafeCSS, TemplateResult, css, nothing } from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\nimport { ValidationLevel } from \"@cas-smartdesign/field-validation-message\";\n\nconst TAG_NAME = \"sd-lit-input\";\n\ndeclare global {\n interface HTMLElementTagNameMap {\n [TAG_NAME]: SDInput;\n }\n}\n\nimport style from \"./style.scss?inline\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst delegatesFocus = \"delegatesFocus\" in (window as any).ShadowRoot.prototype;\n\nlet idCounter = 0;\n\nexport interface IValueChangeEvent {\n value: string;\n}\n\nexport interface CustomEventMap extends HTMLElementEventMap {\n \"immediate-value-change\": CustomEvent<IValueChangeEvent>;\n \"value-change\": CustomEvent<IValueChangeEvent>;\n}\n\nexport default interface SDInput {\n addEventListener<K extends keyof CustomEventMap>(\n event: K,\n listener: ((this: this, ev: CustomEventMap[K]) => unknown) | null,\n options?: AddEventListenerOptions | boolean,\n ): void;\n addEventListener(\n type: string,\n callback: EventListenerOrEventListenerObject | null,\n options?: AddEventListenerOptions | boolean,\n ): void;\n removeEventListener<K extends keyof CustomEventMap>(\n type: K,\n listener: (this: this, ev: CustomEventMap[K]) => unknown,\n options?: boolean | EventListenerOptions,\n ): void;\n removeEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | EventListenerOptions,\n ): void;\n dispatchEvent<EventType extends CustomEventMap[keyof CustomEventMap]>(event: EventType): boolean;\n}\n\nexport default class SDInput extends LitElement {\n public static readonly ID: string = TAG_NAME;\n private static readonly DEFAULT_MAX_LENGTH: number = 524288;\n static formAssociated = true;\n\n @property({ type: String, reflect: true })\n public label: string;\n @property({ type: String, attribute: true })\n public validationMessage: string;\n @property({ type: String, attribute: true })\n public validationIconSrc: string;\n @property({ type: ValidationLevel, attribute: true, reflect: true })\n public validationLevel: ValidationLevel;\n @property({\n type: String,\n hasChanged(value, oldValue) {\n return oldValue != undefined && oldValue != value;\n },\n })\n public currentText;\n @property({ type: Boolean, attribute: true })\n public alwaysFloatLabel: boolean;\n @property({ type: Boolean, attribute: true })\n public autocompleted: boolean;\n @property({ type: Number, attribute: true })\n public rows = 1;\n @property({ type: Boolean, reflect: true, attribute: \"effective-disabled\" })\n public effectiveDisabled: boolean = false;\n @property({ type: Boolean, reflect: true, attribute: \"extended-prefix\" })\n public extendedPrefix: boolean;\n\n // delegated settings to input\n @property({ type: String, reflect: true })\n public type = \"text\";\n @property({ type: String, reflect: true })\n public placeholder: string;\n @property({ type: String, reflect: true })\n public sdAriaLabel: string;\n @property({ type: Number, reflect: true })\n public maxlength: number;\n @property({ type: Boolean, reflect: true })\n public readonly: boolean;\n @property({ type: Boolean, reflect: true })\n public required: boolean;\n @property({ type: String, reflect: true })\n public name: string;\n @property({ type: Boolean, reflect: true })\n public inactive: boolean;\n @property({ type: String, attribute: true })\n public autocomplete: AutoFill = \"off\";\n @property({ type: String, attribute: true })\n public min: string;\n @property({ type: String, attribute: true })\n public max: string;\n @property({ type: String, attribute: true })\n public pattern: string;\n\n private _inputElement: HTMLInputElement;\n private _initialized: boolean;\n private _needsAutocompletedCheck: boolean;\n private _validationMessageId: string;\n private _inputId: string;\n private _internals: ElementInternals;\n private _initialValue: string;\n\n static shadowRootOptions: ShadowRootInit = {\n ...LitElement.shadowRootOptions,\n delegatesFocus,\n };\n\n constructor() {\n super();\n const nextIdNumber = idCounter++;\n this._validationMessageId = SDInput.ID + \"_message_\" + nextIdNumber;\n this._inputId = SDInput.ID + \"_input_\" + nextIdNumber;\n if (this.attachInternals && !this.activeShadyDOM) {\n this._internals = this.attachInternals();\n }\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n if (!this.hasAttribute(\"tabIndex\")) {\n this.tabIndex = 0;\n }\n }\n\n protected firstUpdated(changedProperties: PropertyValues): void {\n super.firstUpdated(changedProperties);\n this.initAutocompleted(this.inputElement);\n this.updateInitialValue();\n this.updateFormValidity();\n\n if (this.hasAttribute(\"disabled\")) {\n this.disabled = true;\n }\n\n this.inputElement.oninput = (event: InputEvent) => {\n this.autocompleted = \"insertReplacementText\" === event.inputType || !(\"data\" in event);\n this.currentText = this.inputElement.value;\n this.fireValueChange(true);\n };\n this.inputElement.onchange = () => this.fireValueChange();\n if (!delegatesFocus) {\n // Provide a limited \"delegatesFocus\" behavior where it is not supported.\n // Note that clicking on non-focusable elements inside the shadow root\n // does not focus the first focusable element as it would have been expected.\n this.inputElement.onfocus = () => this.setAttribute(\"focused\", \"\");\n this.inputElement.onblur = () => this.removeAttribute(\"focused\");\n this.addEventListener(\"focus\", (event) => {\n if (event.target === this) {\n this.inputElement.focus();\n }\n });\n }\n // An input with 'type: date' may not dispatch change or input events in partially filled state\n this.inputElement.addEventListener(\"keyup\", () => {\n this.updateFormValidity();\n });\n this.addEventListener(\"keydown\", (event) => {\n if (event.key == \"Enter\") {\n this._internals?.form?.requestSubmit();\n }\n });\n this._initialized = true;\n }\n\n private initAutocompleted(target: HTMLElement) {\n const listener = (event) => {\n if (/^onautofillstart(-sd-lit-input-\\d+|\\s?)$/.test(event.animationName)) {\n this.autocompleted = true;\n } else if (/^onautofillcancel(-sd-lit-input-\\d+|\\s?)$/.test(event.animationName)) {\n this.autocompleted = false;\n }\n };\n if (this.activeShadyDOM) {\n this._needsAutocompletedCheck = true;\n this.activeShadyDOM.nativeMethods.addEventListener.call(target, \"animationstart\", listener);\n } else {\n target.addEventListener(\"animationstart\", listener);\n }\n }\n\n private get activeShadyDOM(): { nativeMethods } | null {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const shadyDOM = (window as any).ShadyDOM;\n return shadyDOM && shadyDOM.inUse ? shadyDOM : null;\n }\n\n private updateInitialValue(): void {\n if (typeof this.currentText !== \"undefined\") {\n this.value = this.currentText;\n } else {\n this.value = this.getAttribute(\"value\");\n }\n if (this.value) {\n this.currentText = this.inputElement.value;\n }\n this._initialValue = this.value;\n }\n\n public get disabled(): boolean {\n return this.hasAttribute(\"disabled\");\n }\n\n public set disabled(disabled: boolean) {\n if (disabled) {\n this.setAttribute(\"disabled\", \"\");\n } else {\n this.removeAttribute(\"disabled\");\n }\n if (!this._internals) {\n this.effectiveDisabled = disabled;\n }\n }\n\n // It is public as hacking around due to IE 11 is a common task to do.\n public get inputElement(): HTMLInputElement {\n if (this.shadowRoot && !this._inputElement) {\n this._inputElement = this.shadowRoot.querySelector(\".input\");\n }\n return this._inputElement;\n }\n\n public get value(): string {\n return this.inputElement && this.inputElement.value;\n }\n\n public set value(newValue: string) {\n this.currentText = newValue || \"\";\n if (this.inputElement) {\n this.inputElement.value = this.currentText;\n }\n this.setFormValue(this.currentText);\n }\n\n public get selectionStart(): number {\n return this.inputElement ? this.inputElement.selectionStart : 0;\n }\n\n public focus(): void {\n if (this.inputElement) {\n this.inputElement.focus();\n } else {\n super.focus();\n }\n }\n\n public select(): void {\n if (this.inputElement) {\n this.inputElement.select();\n }\n }\n\n public setSelectionRange(start: number, end: number): void {\n this.updateComplete.then(() => {\n if (this.inputElement) {\n this.inputElement.setSelectionRange(start, end);\n }\n });\n }\n\n static get styles() {\n return [\n css`\n ${unsafeCSS(style)}\n `,\n ];\n }\n\n public render(): TemplateResult {\n let inputPart;\n const valMessage = this.validationMessage || this.inputElement?.validationMessage;\n const isInvalid = valMessage || this.validationLevel != null;\n if (this.rows === 1) {\n inputPart = html`\n <input\n id=${this._inputId}\n class=\"input\"\n .type=${this.type}\n placeholder=${ifDefined(this.placeholder || undefined)}\n name=${ifDefined(this.name || undefined)}\n aria-disabled=${this.effectiveDisabled}\n autocomplete=${this.autocomplete}\n ?disabled=${this.inactive}\n ?readonly=${this.readonly || this.effectiveDisabled}\n ?required=${this.required}\n maxlength=${this.maxlength > 0 ? this.maxlength : SDInput.DEFAULT_MAX_LENGTH}\n aria-describedby=${this._validationMessageId}\n aria-invalid=${ifDefined(isInvalid)}\n aria-label=${ifDefined(this.sdAriaLabel || undefined)}\n min=${ifDefined(this.min || undefined)}\n max=${ifDefined(this.max || undefined)}\n pattern=${ifDefined(this.pattern || undefined)}\n />\n `;\n } else {\n inputPart = html`\n <textarea\n id=${this._inputId}\n class=\"input\"\n placeholder=${ifDefined(this.placeholder || undefined)}\n name=${ifDefined(this.name || undefined)}\n aria-disabled=${this.effectiveDisabled}\n autocomplete=${this.autocomplete}\n ?disabled=${this.inactive}\n ?readonly=${this.readonly || this.effectiveDisabled}\n ?required=${this.required}\n maxlength=${this.maxlength > 0 ? this.maxlength : SDInput.DEFAULT_MAX_LENGTH}\n rows=${this.rows}\n aria-describedby=${this._validationMessageId}\n aria-invalid=${ifDefined(isInvalid)}\n aria-label=${ifDefined(this.sdAriaLabel || undefined)}\n ></textarea>\n `;\n }\n\n return html`\n ${this.label ? html` <div class=\"floated-label-placeholder\" aria-hidden=\"true\"> </div> ` : nothing}\n <div class=\"input-wrapper\">\n <span class=\"prefix\"><slot name=\"prefix\"></slot></span>\n <div class=\"input-container\" style=\"position:${this.shouldFloat() ? \"static\" : \"relative\"};\">\n ${this.label &&\n html`\n <label for=\"${this._inputId}\" class=\"label ${this.shouldFloat() ? \"float\" : \"\"}\"\n >${this.label}</label\n >\n `}\n ${inputPart}\n </div>\n <span class=\"suffix\"><slot name=\"suffix\"></slot></span>\n </div>\n <div class=\"underline\" aria-hidden=\"true\">\n <div class=\"unfocused-line\"></div>\n <div class=\"focused-line\"></div>\n </div>\n <div class=\"validation-message-wrapper\" aria-hidden=\"true\">\n ${(valMessage || this.validationIconSrc) &&\n html`\n <sd-field-validation-message\n id=${this._validationMessageId}\n class=\"validation-message\"\n .message=${valMessage}\n .icon=${this.validationIconSrc}\n .level=${this.validationLevel}\n >\n </sd-field-validation-message>\n `}\n </div>\n `;\n }\n\n protected updated(changedProperties: PropertyValues): void {\n super.updated(changedProperties);\n if (this._needsAutocompletedCheck && !this.autocompleted) {\n setTimeout(() => {\n try {\n // In certain cases there is no animation event dispatched even if the animation itself is done (it is visible also in dev tools) when an autofill is done.\n this.autocompleted = this.autocompleted || !!this.shadowRoot.querySelector(\":-webkit-autofill\");\n } catch (ignored) {\n // the above used selector is not supported for example in Firefox\n }\n }, 0);\n }\n if (this.rows > 1) {\n if (changedProperties.has(\"min\") || changedProperties.has(\"max\") || changedProperties.has(\"pattern\")) {\n console.warn(\"min, max & pattern attributes are not supported with multiple rows configuration.\");\n }\n if (\"text\" != this.type) {\n console.warn(`type: ${this.type} is not supported with multiple rows configuration.`);\n }\n }\n }\n\n public update(changedProperties: PropertyValues): void {\n super.update(changedProperties);\n if (changedProperties.has(\"validationMessage\")) {\n if (this.validationMessage) {\n this._internals?.setValidity({ customError: true }, this.validationMessage);\n } else {\n this._internals?.setValidity(this.inputElement.validity, this.inputElement.validationMessage);\n }\n }\n if (this._initialized && changedProperties.has(\"rows\")) {\n throw Error(\"rows attribute cannot be changed after the input is attached to the DOM\");\n }\n }\n\n protected fireValueChange(immediate?: boolean): void {\n this.dispatchEvent(\n new CustomEvent<IValueChangeEvent>(`${immediate ? \"immediate-\" : \"\"}value-change`, {\n detail: { value: this.value },\n }),\n );\n this.setFormValue(this.value);\n }\n\n private updateFormValidity() {\n if (this.validationMessage == null && this.inputElement != null) {\n this._internals.setValidity(this.inputElement.validity, this.inputElement.validationMessage);\n const valMessageEl = this.shadowRoot.querySelector(\"sd-field-validation-message\");\n this.requestUpdate(\"validationMessage\", valMessageEl == null ? null : valMessageEl.message);\n }\n }\n\n protected shouldFloat() {\n return (\n this.alwaysFloatLabel || this.currentText || this.placeholder || this.autocompleted || this.type === \"date\"\n );\n }\n\n protected setFormValue(value: string | File | FormData) {\n this._internals?.setFormValue(value);\n this.updateFormValidity();\n }\n\n protected formResetCallback() {\n this.value = this._initialValue;\n }\n\n protected formDisabledCallback(disabled: boolean) {\n this.effectiveDisabled = disabled || this.hasAttribute(\"disabled\");\n }\n\n protected formAssociatedCallback(_form: HTMLFormElement) {\n this._needsAutocompletedCheck = true;\n }\n\n protected formStateRestoreCallback(state: File | string | FormData | null, reason: unknown) {\n if (typeof state == \"string\") {\n this.value = state;\n }\n }\n}\n\nif (!customElements.get(SDInput.ID)) {\n customElements.define(SDInput.ID, SDInput);\n}\n"],"names":["TAG_NAME","delegatesFocus","idCounter","_SDInput","_a","LitElement","nextIdNumber","changedProperties","event","target","listener","shadyDOM","disabled","newValue","start","end","css","unsafeCSS","style","inputPart","valMessage","isInvalid","html","ifDefined","nothing","immediate","valMessageEl","value","_form","state","reason","__decorateClass","property","ValidationLevel","oldValue","SDInput"],"mappings":";;;;;;;;;;AAKA,MAAMA,IAAW,gBAWXC,IAAiB,oBAAqB,OAAe,WAAW;AAEtE,IAAIC,IAAY;;AAmChB,MAAqBC,KAArBC,IAAA,cAAqCC,EAAW;AAAA,EAsE5C,cAAc;AACV,UAAA,GA9CJ,KAAO,OAAO,GAEd,KAAO,oBAA6B,IAMpC,KAAO,OAAO,QAgBd,KAAO,eAAyB;AAuB5B,UAAMC,IAAeJ;AACrB,SAAK,uBAAuBE,EAAQ,KAAK,cAAcE,GACvD,KAAK,WAAWF,EAAQ,KAAK,YAAYE,GACrC,KAAK,mBAAmB,CAAC,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AAW,IAAM;AAAA,GAtD1B7B,EAuDV,WAAA,SAAA;AAvDX,IAAqBgC,IAArBhC;AA2YK,eAAe,IAAIgC,EAAQ,EAAE,KAC9B,eAAe,OAAOA,EAAQ,IAAIA,CAAO;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cas-smartdesign/lit-input",
|
|
3
|
-
"version": "7.4.
|
|
3
|
+
"version": "7.4.2",
|
|
4
4
|
"description": "An input element based on LitElement & material components",
|
|
5
5
|
"main": "dist/input-with-externals.js",
|
|
6
6
|
"module": "dist/input.mjs",
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"@cas-smartdesign/field-validation-message": "^5.1.0"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"@cas-smartdesign/license-generator": "^1.7.0",
|
|
15
14
|
"@cas-smartdesign/element-preview": "^0.3.0",
|
|
15
|
+
"@cas-smartdesign/license-generator": "^1.7.0",
|
|
16
16
|
"@cas-smartdesign/styles": "^3.7.0"
|
|
17
17
|
},
|
|
18
18
|
"files": [
|