@cas-smartdesign/lit-input 7.3.1 → 7.4.1
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/docs/doc.css +1 -1
- package/dist/docs/doc.mjs +86 -65
- package/dist/docs/form-validation.js +1 -0
- package/dist/docs/misc-examples.js +1 -1
- package/dist/docs/validation.js +1 -1
- package/dist/input-with-externals.js +28 -46
- package/dist/input-with-externals.js.map +4 -4
- package/dist/input.mjs +118 -122
- package/dist/input.mjs.map +1 -1
- package/npm-third-party-licenses.json +52 -47
- package/package.json +6 -6
package/dist/input.mjs
CHANGED
|
@@ -1,42 +1,41 @@
|
|
|
1
|
-
import { LitElement as f,
|
|
2
|
-
import { property as
|
|
3
|
-
import { ifDefined as
|
|
1
|
+
import { LitElement as f, unsafeCSS as m, css as b, html as d, nothing as y } from "lit";
|
|
2
|
+
import { property as i } from "lit/decorators/property.js";
|
|
3
|
+
import { ifDefined as l } from "lit/directives/if-defined.js";
|
|
4
4
|
import { ValidationLevel as g } from "@cas-smartdesign/field-validation-message";
|
|
5
|
-
const x = ":host{display:inline-flex;position:relative;cursor:text;font-family:Segoe UI,Lucida Sans,Arial,sans-serif;font-size:16px;color:#111;contain:layout style;flex-direction:column}:host([hidden]),:host([type=hidden]){display:none!important}:host([effective-disabled]){opacity:.6;cursor:default;filter:grayscale(100%)}:host([effective-disabled]) .unfocused-line,:host([effective-disabled]) .focused-line{border-bottom-style:dashed}:host(:not([effective-disabled]):focus) .focused-line,:host(:not([effective-disabled])[focused]) .focused-line{transform:none;transition:transform .25s}:host(:not([effective-disabled]):focus) .label.float,:host(:not([effective-disabled])[focused]) .label.float{color:var(--sd-input-focused-color, #1467ba)}:host([inactive]) .input{pointer-events:none}:host([effective-disabled]:focus),:host([effective-disabled][focused]){box-shadow:0 0 0 1px #111}:host(:not([effective-disabled])[validationlevel]) .focused-line,:host(:not([effective-disabled]):invalid) .focused-line{transform:none;transition:transform .25s}:host([validationlevel=warn i]) .focused-line{border-bottom-color:var(--sd-input-validation-color, #555555)}:host([validationlevel=warn i]) .label,:host([validationlevel=warn i]) .validation-message{color:var(--sd-input-validation-color, #555555)!important}:host([validationlevel=suggest i]) .focused-line{border-bottom-color:var(--sd-input-validation-color, #bf8800)}:host([validationlevel=suggest i]) .label,:host([validationlevel=suggest i]) .validation-message{color:var(--sd-input-validation-color, #bf8800)!important}:host([validationlevel=error i]) .focused-line,:host(:not([validationlevel]):invalid) .focused-line{border-bottom-color:var(--sd-input-validation-color, #cc0017)}:host([validationlevel=error i]) .label,:host([validationlevel=error i]) .validation-message,:host(:not([validationlevel]):invalid) .label,:host(:not([validationlevel]):invalid) .validation-message{color:var(--sd-input-validation-color, #cc0017)!important}.validation-message-wrapper{min-height:var(--sd-input-validation-message-minheight, 0px);position:relative;font-size:0}.validation-message{position:relative;position:var(--sd-input-validation-message-minheight, absolute);left:0;right:0}.label.float{transform:translateY(-75%) scale(.75);width:133%}.label:not(.float){max-width:100%}.floated-label-placeholder{height:20px;width:100%}.label{position:absolute;top:0;left:0;line-height:24px;pointer-events:none;color:var(--sd-input-color, #767676);transition:transform .25s,width .25s;transform-origin:left top}.input-wrapper{position:relative;display:flex;flex-direction:row;align-items:center;background-color:var(--input-wrapper-background-color)}:host([extended-prefix]:focus-within:not([effective-disabled])) .input-wrapper{flex-direction:column;align-items:baseline}:host([extended-prefix]:focus-within:not([effective-disabled])) .input-container{width:100%}:host([extended-prefix]:not(:focus-within)) .input-container,:host([extended-prefix][effective-disabled]) .input-container{width:0px}.input-container{line-height:var(--sd-input-line-height, 24px);flex:1 1 auto}.input{width:100%;background:var(--sd-input-background, transparent);font-family:inherit;font-size:inherit;text-align:inherit;color:inherit;border:none;outline:none;resize:none;padding-left:0;padding-right:0}.input:-webkit-autofill{animation-name:onautofillstart}.input:not(:-webkit-autofill){animation-name:onautofillcancel}@keyframes onautofillstart{0%{outline:none}}@keyframes onautofillcancel{0%{outline:none}}.label,input.input{text-overflow:ellipsis;overflow-x:hidden;white-space:nowrap}.validation-message{text-overflow:ellipsis;overflow-x:hidden;white-space:normal;white-space:var(--sd-input-validation-message-minheight, nowrap)}.input::placeholder{color:var(--sd-input-color, #767676)}.underline{height:2px;width:100%;position:relative}.unfocused-line,.focused-line{position:absolute;
|
|
6
|
-
var w = Object.defineProperty,
|
|
7
|
-
for (var
|
|
8
|
-
(
|
|
9
|
-
return
|
|
5
|
+
const x = ":host{display:inline-flex;position:relative;cursor:text;font-family:Segoe UI,Lucida Sans,Arial,sans-serif;font-size:16px;color:#111;contain:layout style;flex-direction:column}:host([hidden]),:host([type=hidden]){display:none!important}:host([effective-disabled]){opacity:.6;cursor:default;filter:grayscale(100%)}:host([effective-disabled]) .unfocused-line,:host([effective-disabled]) .focused-line{border-bottom-style:dashed}:host(:not([effective-disabled]):focus) .focused-line,:host(:not([effective-disabled])[focused]) .focused-line{transform:none;transition:transform .25s}:host(:not([effective-disabled]):focus) .label.float,:host(:not([effective-disabled])[focused]) .label.float{color:var(--sd-input-focused-color, #1467ba)}:host([inactive]) .input{pointer-events:none}:host([effective-disabled]:focus),:host([effective-disabled][focused]){box-shadow:0 0 0 1px #111}:host(:not([effective-disabled])[validationlevel]) .focused-line,:host(:not([effective-disabled]):invalid) .focused-line{transform:none;transition:transform .25s}:host([validationlevel=warn i]) .focused-line{border-bottom-color:var(--sd-input-validation-color, #555555)}:host([validationlevel=warn i]) .label,:host([validationlevel=warn i]) .validation-message{color:var(--sd-input-validation-color, #555555)!important}:host([validationlevel=suggest i]) .focused-line{border-bottom-color:var(--sd-input-validation-color, #bf8800)}:host([validationlevel=suggest i]) .label,:host([validationlevel=suggest i]) .validation-message{color:var(--sd-input-validation-color, #bf8800)!important}:host([validationlevel=error i]) .focused-line,:host(:not([validationlevel]):invalid) .focused-line{border-bottom-color:var(--sd-input-validation-color, #cc0017)}:host([validationlevel=error i]) .label,:host([validationlevel=error i]) .validation-message,:host(:not([validationlevel]):invalid) .label,:host(:not([validationlevel]):invalid) .validation-message{color:var(--sd-input-validation-color, #cc0017)!important}.validation-message-wrapper{min-height:var(--sd-input-validation-message-minheight, 0px);position:relative;font-size:0}.validation-message{position:relative;position:var(--sd-input-validation-message-minheight, absolute);left:0;right:0}.label.float{transform:translateY(-75%) scale(.75);width:133%}.label:not(.float){max-width:100%}.floated-label-placeholder{height:20px;width:100%}.label{position:absolute;top:0;left:0;line-height:24px;pointer-events:none;color:var(--sd-input-color, #767676);transition:transform .25s,width .25s;transform-origin:left top}.input-wrapper{position:relative;display:flex;flex-direction:row;align-items:center;background-color:var(--input-wrapper-background-color)}:host([extended-prefix]:focus-within:not([effective-disabled])) .input-wrapper{flex-direction:column;align-items:baseline}:host([extended-prefix]:focus-within:not([effective-disabled])) .input-container{width:100%}:host([extended-prefix]:not(:focus-within)) .input-container,:host([extended-prefix][effective-disabled]) .input-container{width:0px}.input-container{line-height:var(--sd-input-line-height, 24px);flex:1 1 auto}.input{width:100%;background:var(--sd-input-background, transparent);font-family:inherit;font-size:inherit;text-align:inherit;color:inherit;border:none;outline:none;resize:none;padding-left:0;padding-right:0}.input:-webkit-autofill{animation-name:onautofillstart}.input:not(:-webkit-autofill){animation-name:onautofillcancel}@keyframes onautofillstart{0%{outline:none}}@keyframes onautofillcancel{0%{outline:none}}.label,input.input{text-overflow:ellipsis;overflow-x:hidden;white-space:nowrap}.validation-message{text-overflow:ellipsis;overflow-x:hidden;white-space:normal;white-space:var(--sd-input-validation-message-minheight, nowrap)}.input::placeholder{color:var(--sd-input-color, #767676)}.underline{height:2px;width:100%;position:relative}.unfocused-line,.focused-line{position:absolute;inset:0}.unfocused-line{border-bottom:1px solid var(--sd-input-underline-color, #959595)}.focused-line{border-bottom:2px solid var(--sd-input-focused-color, #1467ba);transform-origin:center center;transform:scale3d(0,1,1)}.prefix,.suffix{display:flex;flex-wrap:nowrap;max-width:100%}.prefix ::slotted(*),.suffix ::slotted(*){display:flex}";
|
|
6
|
+
var w = Object.defineProperty, a = (u, t, s, n) => {
|
|
7
|
+
for (var r = void 0, h = u.length - 1, c; h >= 0; h--)
|
|
8
|
+
(c = u[h]) && (r = c(t, s, r) || r);
|
|
9
|
+
return r && w(t, s, r), r;
|
|
10
10
|
};
|
|
11
|
-
const
|
|
12
|
-
let
|
|
13
|
-
var
|
|
14
|
-
const
|
|
11
|
+
const E = "sd-lit-input", v = "delegatesFocus" in window.ShadowRoot.prototype;
|
|
12
|
+
let $ = 0;
|
|
13
|
+
var o;
|
|
14
|
+
const e = (o = class extends f {
|
|
15
15
|
constructor() {
|
|
16
16
|
super(), this.rows = 1, this.effectiveDisabled = !1, this.type = "text", this.autocomplete = "off";
|
|
17
|
-
const t =
|
|
18
|
-
this._validationMessageId =
|
|
17
|
+
const t = $++;
|
|
18
|
+
this._validationMessageId = o.ID + "_message_" + t, this._inputId = o.ID + "_input_" + t, this.attachInternals && !this.activeShadyDOM && (this._internals = this.attachInternals());
|
|
19
19
|
}
|
|
20
20
|
connectedCallback() {
|
|
21
21
|
super.connectedCallback(), this.hasAttribute("tabIndex") || (this.tabIndex = 0);
|
|
22
22
|
}
|
|
23
23
|
firstUpdated(t) {
|
|
24
|
-
super.firstUpdated(t), this.initAutocompleted(this.inputElement), this.updateInitialValue(), this.updateFormValidity(), this.hasAttribute("disabled") && (this.disabled = !0), this.inputElement.oninput = (
|
|
25
|
-
this.autocompleted =
|
|
26
|
-
}, this.inputElement.onchange = () => this.fireValueChange(), v || (this.inputElement.onfocus = () => this.setAttribute("focused", ""), this.inputElement.onblur = () => this.removeAttribute("focused"), this.addEventListener("focus", (
|
|
27
|
-
|
|
24
|
+
super.firstUpdated(t), this.initAutocompleted(this.inputElement), this.updateInitialValue(), this.updateFormValidity(), this.hasAttribute("disabled") && (this.disabled = !0), this.inputElement.oninput = (s) => {
|
|
25
|
+
this.autocompleted = s.inputType === "insertReplacementText" || !("data" in s), this.currentText = this.inputElement.value, this.fireValueChange(!0);
|
|
26
|
+
}, this.inputElement.onchange = () => this.fireValueChange(), v || (this.inputElement.onfocus = () => this.setAttribute("focused", ""), this.inputElement.onblur = () => this.removeAttribute("focused"), this.addEventListener("focus", (s) => {
|
|
27
|
+
s.target === this && this.inputElement.focus();
|
|
28
28
|
})), this.inputElement.addEventListener("keyup", () => {
|
|
29
29
|
this.updateFormValidity();
|
|
30
|
-
}), this.addEventListener("keydown", (
|
|
31
|
-
|
|
32
|
-
e.key == "Enter" && ((l = (o = this._internals) == null ? void 0 : o.form) == null || l.requestSubmit());
|
|
30
|
+
}), this.addEventListener("keydown", (s) => {
|
|
31
|
+
s.key == "Enter" && this._internals?.form?.requestSubmit();
|
|
33
32
|
}), this._initialized = !0;
|
|
34
33
|
}
|
|
35
34
|
initAutocompleted(t) {
|
|
36
|
-
const
|
|
37
|
-
/^onautofillstart(-sd-lit-input-\d+|\s?)$/.test(
|
|
35
|
+
const s = (n) => {
|
|
36
|
+
/^onautofillstart(-sd-lit-input-\d+|\s?)$/.test(n.animationName) ? this.autocompleted = !0 : /^onautofillcancel(-sd-lit-input-\d+|\s?)$/.test(n.animationName) && (this.autocompleted = !1);
|
|
38
37
|
};
|
|
39
|
-
this.activeShadyDOM ? (this._needsAutocompletedCheck = !0, this.activeShadyDOM.nativeMethods.addEventListener.call(t, "animationstart",
|
|
38
|
+
this.activeShadyDOM ? (this._needsAutocompletedCheck = !0, this.activeShadyDOM.nativeMethods.addEventListener.call(t, "animationstart", s)) : t.addEventListener("animationstart", s);
|
|
40
39
|
}
|
|
41
40
|
get activeShadyDOM() {
|
|
42
41
|
const t = window.ShadyDOM;
|
|
@@ -70,58 +69,57 @@ const i = (n = class extends f {
|
|
|
70
69
|
select() {
|
|
71
70
|
this.inputElement && this.inputElement.select();
|
|
72
71
|
}
|
|
73
|
-
setSelectionRange(t,
|
|
72
|
+
setSelectionRange(t, s) {
|
|
74
73
|
this.updateComplete.then(() => {
|
|
75
|
-
this.inputElement && this.inputElement.setSelectionRange(t,
|
|
74
|
+
this.inputElement && this.inputElement.setSelectionRange(t, s);
|
|
76
75
|
});
|
|
77
76
|
}
|
|
78
77
|
static get styles() {
|
|
79
78
|
return [
|
|
80
|
-
|
|
81
|
-
${
|
|
79
|
+
b`
|
|
80
|
+
${m(x)}
|
|
82
81
|
`
|
|
83
82
|
];
|
|
84
83
|
}
|
|
85
84
|
render() {
|
|
86
|
-
var l;
|
|
87
85
|
let t;
|
|
88
|
-
const
|
|
86
|
+
const s = this.validationMessage || this.inputElement?.validationMessage, n = s || this.validationLevel != null;
|
|
89
87
|
return this.rows === 1 ? t = d`
|
|
90
88
|
<input
|
|
91
89
|
id=${this._inputId}
|
|
92
90
|
class="input"
|
|
93
91
|
.type=${this.type}
|
|
94
|
-
placeholder=${
|
|
95
|
-
name=${
|
|
92
|
+
placeholder=${l(this.placeholder || void 0)}
|
|
93
|
+
name=${l(this.name || void 0)}
|
|
96
94
|
aria-disabled=${this.effectiveDisabled}
|
|
97
95
|
autocomplete=${this.autocomplete}
|
|
98
96
|
?disabled=${this.inactive}
|
|
99
97
|
?readonly=${this.readonly || this.effectiveDisabled}
|
|
100
98
|
?required=${this.required}
|
|
101
|
-
maxlength=${this.maxlength > 0 ? this.maxlength :
|
|
99
|
+
maxlength=${this.maxlength > 0 ? this.maxlength : o.DEFAULT_MAX_LENGTH}
|
|
102
100
|
aria-describedby=${this._validationMessageId}
|
|
103
|
-
aria-invalid=${
|
|
104
|
-
aria-label=${
|
|
105
|
-
min=${
|
|
106
|
-
max=${
|
|
107
|
-
pattern=${
|
|
101
|
+
aria-invalid=${l(n)}
|
|
102
|
+
aria-label=${l(this.sdAriaLabel || void 0)}
|
|
103
|
+
min=${l(this.min || void 0)}
|
|
104
|
+
max=${l(this.max || void 0)}
|
|
105
|
+
pattern=${l(this.pattern || void 0)}
|
|
108
106
|
/>
|
|
109
107
|
` : t = d`
|
|
110
108
|
<textarea
|
|
111
109
|
id=${this._inputId}
|
|
112
110
|
class="input"
|
|
113
|
-
placeholder=${
|
|
114
|
-
name=${
|
|
111
|
+
placeholder=${l(this.placeholder || void 0)}
|
|
112
|
+
name=${l(this.name || void 0)}
|
|
115
113
|
aria-disabled=${this.effectiveDisabled}
|
|
116
114
|
autocomplete=${this.autocomplete}
|
|
117
115
|
?disabled=${this.inactive}
|
|
118
116
|
?readonly=${this.readonly || this.effectiveDisabled}
|
|
119
117
|
?required=${this.required}
|
|
120
|
-
maxlength=${this.maxlength > 0 ? this.maxlength :
|
|
118
|
+
maxlength=${this.maxlength > 0 ? this.maxlength : o.DEFAULT_MAX_LENGTH}
|
|
121
119
|
rows=${this.rows}
|
|
122
120
|
aria-describedby=${this._validationMessageId}
|
|
123
|
-
aria-invalid=${
|
|
124
|
-
aria-label=${
|
|
121
|
+
aria-invalid=${l(n)}
|
|
122
|
+
aria-label=${l(this.sdAriaLabel || void 0)}
|
|
125
123
|
></textarea>
|
|
126
124
|
`, d`
|
|
127
125
|
${this.label ? d` <div class="floated-label-placeholder" aria-hidden="true"> </div> ` : y}
|
|
@@ -142,11 +140,11 @@ const i = (n = class extends f {
|
|
|
142
140
|
<div class="focused-line"></div>
|
|
143
141
|
</div>
|
|
144
142
|
<div class="validation-message-wrapper" aria-hidden="true">
|
|
145
|
-
${(
|
|
143
|
+
${(s || this.validationIconSrc) && d`
|
|
146
144
|
<sd-field-validation-message
|
|
147
145
|
id=${this._validationMessageId}
|
|
148
146
|
class="validation-message"
|
|
149
|
-
.message=${
|
|
147
|
+
.message=${s}
|
|
150
148
|
.icon=${this.validationIconSrc}
|
|
151
149
|
.level=${this.validationLevel}
|
|
152
150
|
>
|
|
@@ -164,8 +162,7 @@ const i = (n = class extends f {
|
|
|
164
162
|
}, 0), this.rows > 1 && ((t.has("min") || t.has("max") || t.has("pattern")) && console.warn("min, max & pattern attributes are not supported with multiple rows configuration."), this.type != "text" && console.warn(`type: ${this.type} is not supported with multiple rows configuration.`));
|
|
165
163
|
}
|
|
166
164
|
update(t) {
|
|
167
|
-
|
|
168
|
-
if (super.update(t), t.has("validationMessage") && (this.validationMessage ? (e = this._internals) == null || e.setValidity({ customError: !0 }, this.validationMessage) : (o = this._internals) == null || o.setValidity(this.inputElement.validity, this.inputElement.validationMessage)), this._initialized && t.has("rows"))
|
|
165
|
+
if (super.update(t), t.has("validationMessage") && (this.validationMessage ? this._internals?.setValidity({ customError: !0 }, this.validationMessage) : this._internals?.setValidity(this.inputElement.validity, this.inputElement.validationMessage)), this._initialized && t.has("rows"))
|
|
169
166
|
throw Error("rows attribute cannot be changed after the input is attached to the DOM");
|
|
170
167
|
}
|
|
171
168
|
fireValueChange(t) {
|
|
@@ -173,7 +170,7 @@ const i = (n = class extends f {
|
|
|
173
170
|
new CustomEvent(`${t ? "immediate-" : ""}value-change`, {
|
|
174
171
|
detail: { value: this.value }
|
|
175
172
|
})
|
|
176
|
-
), this.setFormValue(this.value)
|
|
173
|
+
), this.setFormValue(this.value);
|
|
177
174
|
}
|
|
178
175
|
updateFormValidity() {
|
|
179
176
|
if (this.validationMessage == null) {
|
|
@@ -186,8 +183,7 @@ const i = (n = class extends f {
|
|
|
186
183
|
return this.alwaysFloatLabel || this.currentText || this.placeholder || this.autocompleted || this.type === "date";
|
|
187
184
|
}
|
|
188
185
|
setFormValue(t) {
|
|
189
|
-
|
|
190
|
-
(e = this._internals) == null || e.setFormValue(t);
|
|
186
|
+
this._internals?.setFormValue(t), this.updateFormValidity();
|
|
191
187
|
}
|
|
192
188
|
formResetCallback() {
|
|
193
189
|
this.value = this._initialValue;
|
|
@@ -198,87 +194,87 @@ const i = (n = class extends f {
|
|
|
198
194
|
formAssociatedCallback(t) {
|
|
199
195
|
this._needsAutocompletedCheck = !0;
|
|
200
196
|
}
|
|
201
|
-
formStateRestoreCallback(t,
|
|
197
|
+
formStateRestoreCallback(t, s) {
|
|
202
198
|
typeof t == "string" && (this.value = t);
|
|
203
199
|
}
|
|
204
|
-
},
|
|
200
|
+
}, o.ID = E, o.DEFAULT_MAX_LENGTH = 524288, o.formAssociated = !0, o.shadowRootOptions = {
|
|
205
201
|
...f.shadowRootOptions,
|
|
206
202
|
delegatesFocus: v
|
|
207
|
-
},
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
],
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
],
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
],
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
],
|
|
220
|
-
|
|
221
|
-
|
|
203
|
+
}, o);
|
|
204
|
+
a([
|
|
205
|
+
i({ type: String, reflect: !0 })
|
|
206
|
+
], e.prototype, "label");
|
|
207
|
+
a([
|
|
208
|
+
i({ type: String, attribute: !0 })
|
|
209
|
+
], e.prototype, "validationMessage");
|
|
210
|
+
a([
|
|
211
|
+
i({ type: String, attribute: !0 })
|
|
212
|
+
], e.prototype, "validationIconSrc");
|
|
213
|
+
a([
|
|
214
|
+
i({ type: g, attribute: !0, reflect: !0 })
|
|
215
|
+
], e.prototype, "validationLevel");
|
|
216
|
+
a([
|
|
217
|
+
i({
|
|
222
218
|
type: String,
|
|
223
219
|
hasChanged(u, t) {
|
|
224
220
|
return t != null && t != u;
|
|
225
221
|
}
|
|
226
222
|
})
|
|
227
|
-
],
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
],
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
],
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
],
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
],
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
],
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
],
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
],
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
],
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
],
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
],
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
],
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
],
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
],
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
],
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
],
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
],
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
],
|
|
279
|
-
let
|
|
280
|
-
customElements.get(
|
|
223
|
+
], e.prototype, "currentText");
|
|
224
|
+
a([
|
|
225
|
+
i({ type: Boolean, attribute: !0 })
|
|
226
|
+
], e.prototype, "alwaysFloatLabel");
|
|
227
|
+
a([
|
|
228
|
+
i({ type: Boolean, attribute: !0 })
|
|
229
|
+
], e.prototype, "autocompleted");
|
|
230
|
+
a([
|
|
231
|
+
i({ type: Number, attribute: !0 })
|
|
232
|
+
], e.prototype, "rows");
|
|
233
|
+
a([
|
|
234
|
+
i({ type: Boolean, reflect: !0, attribute: "effective-disabled" })
|
|
235
|
+
], e.prototype, "effectiveDisabled");
|
|
236
|
+
a([
|
|
237
|
+
i({ type: Boolean, reflect: !0, attribute: "extended-prefix" })
|
|
238
|
+
], e.prototype, "extendedPrefix");
|
|
239
|
+
a([
|
|
240
|
+
i({ type: String, reflect: !0 })
|
|
241
|
+
], e.prototype, "type");
|
|
242
|
+
a([
|
|
243
|
+
i({ type: String, reflect: !0 })
|
|
244
|
+
], e.prototype, "placeholder");
|
|
245
|
+
a([
|
|
246
|
+
i({ type: String, reflect: !0 })
|
|
247
|
+
], e.prototype, "sdAriaLabel");
|
|
248
|
+
a([
|
|
249
|
+
i({ type: Number, reflect: !0 })
|
|
250
|
+
], e.prototype, "maxlength");
|
|
251
|
+
a([
|
|
252
|
+
i({ type: Boolean, reflect: !0 })
|
|
253
|
+
], e.prototype, "readonly");
|
|
254
|
+
a([
|
|
255
|
+
i({ type: Boolean, reflect: !0 })
|
|
256
|
+
], e.prototype, "required");
|
|
257
|
+
a([
|
|
258
|
+
i({ type: String, reflect: !0 })
|
|
259
|
+
], e.prototype, "name");
|
|
260
|
+
a([
|
|
261
|
+
i({ type: Boolean, reflect: !0 })
|
|
262
|
+
], e.prototype, "inactive");
|
|
263
|
+
a([
|
|
264
|
+
i({ type: String, attribute: !0 })
|
|
265
|
+
], e.prototype, "autocomplete");
|
|
266
|
+
a([
|
|
267
|
+
i({ type: String, attribute: !0 })
|
|
268
|
+
], e.prototype, "min");
|
|
269
|
+
a([
|
|
270
|
+
i({ type: String, attribute: !0 })
|
|
271
|
+
], e.prototype, "max");
|
|
272
|
+
a([
|
|
273
|
+
i({ type: String, attribute: !0 })
|
|
274
|
+
], e.prototype, "pattern");
|
|
275
|
+
let p = e;
|
|
276
|
+
customElements.get(p.ID) || customElements.define(p.ID, p);
|
|
281
277
|
export {
|
|
282
|
-
|
|
278
|
+
p as default
|
|
283
279
|
};
|
|
284
280
|
//# sourceMappingURL=input.mjs.map
|
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","_b","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;AACJ,aA9CV,KAAO,OAAO,GAEd,KAAO,oBAA6B,IAMpC,KAAO,OAAO,QAgBd,KAAO,eAAyB;AAuB5B,UAAMC,IAAeJ;AAChB,SAAA,uBAAuBE,EAAQ,KAAK,cAAcE,GAClD,KAAA,WAAWF,EAAQ,KAAK,YAAYE,GACrC,KAAK,mBAAmB,CAAC,KAAK,mBACzB,KAAA,aAAa,KAAK;EAE/B;AAA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EADNC,EAAS,EAAE,MAAM,QAAQ,WAAW,IAAM;AAAA,GApD1B9B,EAqDV,WAAA,OAAA,CAAA;AAEA6B,EAAA;AAAA,EADNC,EAAS,EAAE,MAAM,QAAQ,WAAW,IAAM;AAAA,GAtD1B9B,EAuDV,WAAA,WAAA,CAAA;AAvDX,IAAqBiC,IAArBjC;AA2YK,eAAe,IAAIiC,EAAQ,EAAE,KACf,eAAA,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) {\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,KAAK,mBAC9B,KAAK,aAAa,KAAK,gBAAA;AAAA,EAE/B;AAAA,EAEA,oBAA0B;AACtB,UAAM,kBAAA,GACD,KAAK,aAAa,UAAU,MAC7B,KAAK,WAAW;AAAA,EAExB;AAAA,EAEU,aAAaC,GAAyC;AAC5D,UAAM,aAAaA,CAAiB,GACpC,KAAK,kBAAkB,KAAK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