@nysds/nys-textinput 1.11.1 → 1.11.3

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.
@@ -1,780 +1,15 @@
1
- import { css as ot, LitElement as at, html as j } from "lit";
2
- /*!
3
- * ▒█▄░▒█ ▒█░░▒█ ▒█▀▀▀█ ▒█▀▀▄ ▒█▀▀▀█
4
- * ▒█▒█▒█ ▒█▄▄▄█ ░▀▀▀▄▄ ▒█░▒█ ░▀▀▀▄▄
5
- * ▒█░░▀█ ░░▒█░░ ▒█▄▄▄█ ▒█▄▄▀ ▒█▄▄▄█
6
- *
7
- * TextInput Component
8
- * Part of the New York State Design System
9
- * Repository: https://github.com/its-hcd/nysds
10
- * License: MIT
11
- */
12
- /**
13
- * @license
14
- * Copyright 2019 Google LLC
15
- * SPDX-License-Identifier: BSD-3-Clause
16
- */
17
- const O = globalThis, L = O.ShadowRoot && (O.ShadyCSS === void 0 || O.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, et = Symbol(), W = /* @__PURE__ */ new WeakMap();
18
- let lt = class {
19
- constructor(t, e, s) {
20
- if (this._$cssResult$ = !0, s !== et) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
21
- this.cssText = t, this.t = e;
22
- }
23
- get styleSheet() {
24
- let t = this.o;
25
- const e = this.t;
26
- if (L && t === void 0) {
27
- const s = e !== void 0 && e.length === 1;
28
- s && (t = W.get(e)), t === void 0 && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), s && W.set(e, t));
29
- }
30
- return t;
31
- }
32
- toString() {
33
- return this.cssText;
34
- }
1
+ import { LitElement as y, unsafeCSS as c, html as h } from "lit";
2
+ import { property as o, state as _ } from "lit/decorators.js";
3
+ import { ifDefined as d } from "lit/directives/if-defined.js";
4
+ const v = ':host{--_nys-textinput-width: 100%;--_nys-textinput-height: var(--nys-size-500, 40px);--_nys-textinput-border-radius: var(--nys-radius-md, 4px);--_nys-textinput-border-width: var(--nys-border-width-sm, 1px);--_nys-textinput-border-color: var(--nys-color-neutral-400, #909395);--_nys-textinput-color: var( --nys-color-text, var(--nys-color-neutral-900, #1b1b1b) );--_nys-textinput-color--placeholder: var( --nys-color-text-weaker, var(--nys-color-neutral-500, #797c7f) );--_nys-textinput-padding: var(--nys-space-100, 8px);--_nys-textinput-gap: var(--nys-space-50, 4px);--_nys-textinput-background-color: var( --nys-color-ink-reverse, var(--nys-color-white, #ffffff) );--_nys-textinput-color: var( --nys-color-ink, var(--nys-color-neutral-900, #1b1b1b) );--_nys-textinput-outline-color--hover: var( --nys-color-neutral-900, #1b1b1b );--_nys-textinput-outline-width: var(--nys-border-width-sm, 1px);--_nys-textinput-outline-color--focus: var(--nys-color-focus, #004dd1);--_nys-textinput-background-color--disabled: var( --nys-color-neutral-10, #f6f6f6 );--_nys-textinput-border-color--disabled: var( --nys-color-neutral-200, #bec0c1 );--_nys-textinput-color--disabled: var( --nys-color-text-disabled, var(--nys-color-neutral-200, #bec0c1) );--_nys-textinput-font-family: var( --nys-font-family-ui, var( --nys-font-family-sans, "Proxima Nova", "Helvetica Neue", "Helvetica", "Arial", sans-serif ) );--_nys-textinput-font-size: var(--nys-font-size-ui-md, 16px);--_nys-textinput-font-weight: var(--nys-font-weight-regular, 400);--_nys-textinput-line-height: var(--nys-font-lineheight-ui-md, 24px);--_nys-textinput-letter-spacing: var( --nys-font-letterspacing-ui-md, var(--nys-font-letterspacing-400, .044px) )}:host([width=sm]){--_nys-textinput-width: var(--nys-form-width-sm, 88px)}:host([width=md]){--_nys-textinput-width: var(--nys-form-width-md, 200px)}:host([width=lg]){--_nys-textinput-width: var(--nys-form-width-lg, 384px)}:host([width=full]){--_nys-textinput-width: 100%;flex:1}:host([showError]){--_nys-textinput-border-color: var(--nys-color-danger, #b52c2c)}.nys-textinput{font-weight:var(--_nys-textinput-font-weight);font-family:var(--_nys-textinput-font-family);font-size:var(--_nys-textinput-font-size);line-height:var(--_nys-textinput-line-height);letter-spacing:var(--_nys-textinput-letter-spacing);color:var(--_nys-textinput-color);gap:var(--_nys-textinput-gap);display:flex;flex-direction:column}.nys-textinput__mask-overlay{position:absolute;margin:calc(var(--_nys-textinput-padding) + var(--_nys-textinput-border-width));color:var(--nys-color-text-weaker, #797c7f);display:inline;overflow:hidden;white-space:nowrap;font:inherit;letter-spacing:normal}.nys-textinput__input{color:var(--_nys-textinput-color);border-radius:var(--_nys-textinput-border-radius);border:solid var(--_nys-textinput-border-color) var(--_nys-textinput-border-width);outline-color:transparent;outline-width:var(--_nys-textinput-outline-width);outline-style:solid;padding:var(--_nys-textinput-padding);width:100%;height:var(--_nys-textinput-height);box-sizing:border-box;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;background-color:transparent;position:relative;font:inherit}.nys-textinput__input::placeholder{color:var(--_nys-textinput-color--placeholder)}.nys-textinput__buttoncontainer{width:var(--_nys-textinput-width);max-width:100%;display:flex}.nys-textinput__buttoncontainer.has-end-button .nys-textinput__input{border-start-end-radius:0;border-end-end-radius:0;border-inline-end:none}.nys-textinput__buttoncontainer.has-start-button .nys-textinput__input{border-start-start-radius:0;border-end-start-radius:0;border-inline-start:none}.nys-textinput__container{position:relative;display:flex;align-items:center;width:100%;background-color:var(--_nys-textinput-background-color);border-radius:var(--_nys-textinput-border-radius)}::slotted(nys-button){--_nys-button-height: var(--_nys-textinput-height);--_nys-button-border-radius--start: var(--_nys-textinput-border-radius);--_nys-button-border-radius--end: var(--_nys-textinput-border-radius);--_nys-button-background-color--disabled: var( --_nys-textinput-background-color--disabled );--_nys-button-border-color--disabled: var(--_nys-textinput-color--disabled);--_nys-button-color--disabled: var(--_nys-textinput-color--disabled);--_nys-button-border-width: var(--_nys-textinput-border-width);z-index:1}.nys-textinput__buttoncontainer.has-start-button ::slotted(nys-button){--_nys-button-border-radius--end: 0}.nys-textinput__buttoncontainer.has-end-button ::slotted(nys-button){--_nys-button-border-radius--start: 0}.eye-icon{position:absolute;right:var(--nys-space-50, 4px);top:50%;transform:translateY(-50%);cursor:pointer;color:var(--_nys-textinput-color--icon);--nys-button-background-color: var(--_nys-textinput-background-color);--nys-button-background-color--hover: var( --_nys-textinput-background-color );--nys-button-background-color--active: var( --_nys-textinput-background-color );--_nys-button-outline-focus: calc( var(--_nys-button-outline-width) * -1 );--_nys-button-padding--y: var(--nys-space-50, 4px);--_nys-button-padding--x: var(--nys-space-50, 4px);--_nys-button-height: var(--nys-size-300, 32px);--_nys-button-width: var(--nys-size-400, 32px)}.nys-textinput__input:hover:not(:disabled):not(:focus){outline-color:var(--_nys-textinput-outline-color--hover);border-color:var(--_nys-textinput-outline-color--hover)}.nys-textinput__input:focus{outline-color:var(--_nys-textinput-outline-color--focus);border-color:var(--_nys-textinput-outline-color--focus);caret-color:var(--_nys-textinput-outline-color--focus)}.nys-textinput__input:disabled,.nys-textinput__input:disabled::placeholder,.nys-textinput__input:disabled+.eye-icon{background-color:var(--_nys-textinput-background-color--disabled);border-color:var(--_nys-textinput-border-color--disabled);color:var(--_nys-textinput-color--disabled);cursor:not-allowed}';
5
+ var b = Object.defineProperty, f = Object.getOwnPropertyDescriptor, r = (p, e, s, t) => {
6
+ for (var i = t > 1 ? void 0 : t ? f(e, s) : e, l = p.length - 1, a; l >= 0; l--)
7
+ (a = p[l]) && (i = (t ? a(e, s, i) : a(i)) || i);
8
+ return t && i && b(e, s, i), i;
35
9
  };
36
- const ht = (r) => new lt(typeof r == "string" ? r : r + "", void 0, et), dt = (r, t) => {
37
- if (L) r.adoptedStyleSheets = t.map(((e) => e instanceof CSSStyleSheet ? e : e.styleSheet));
38
- else for (const e of t) {
39
- const s = document.createElement("style"), i = O.litNonce;
40
- i !== void 0 && s.setAttribute("nonce", i), s.textContent = e.cssText, r.appendChild(s);
41
- }
42
- }, F = L ? (r) => r : (r) => r instanceof CSSStyleSheet ? ((t) => {
43
- let e = "";
44
- for (const s of t.cssRules) e += s.cssText;
45
- return ht(e);
46
- })(r) : r;
47
- /**
48
- * @license
49
- * Copyright 2017 Google LLC
50
- * SPDX-License-Identifier: BSD-3-Clause
51
- */
52
- const { is: ut, defineProperty: ct, getOwnPropertyDescriptor: pt, getOwnPropertyNames: yt, getOwnPropertySymbols: _t, getPrototypeOf: ft } = Object, I = globalThis, Y = I.trustedTypes, vt = Y ? Y.emptyScript : "", bt = I.reactiveElementPolyfillSupport, P = (r, t) => r, T = { toAttribute(r, t) {
53
- switch (t) {
54
- case Boolean:
55
- r = r ? vt : null;
56
- break;
57
- case Object:
58
- case Array:
59
- r = r == null ? r : JSON.stringify(r);
60
- }
61
- return r;
62
- }, fromAttribute(r, t) {
63
- let e = r;
64
- switch (t) {
65
- case Boolean:
66
- e = r !== null;
67
- break;
68
- case Number:
69
- e = r === null ? null : Number(r);
70
- break;
71
- case Object:
72
- case Array:
73
- try {
74
- e = JSON.parse(r);
75
- } catch {
76
- e = null;
77
- }
78
- }
79
- return e;
80
- } }, V = (r, t) => !ut(r, t), G = { attribute: !0, type: String, converter: T, reflect: !1, useDefault: !1, hasChanged: V };
81
- Symbol.metadata ??= Symbol("metadata"), I.litPropertyMetadata ??= /* @__PURE__ */ new WeakMap();
82
- class E extends HTMLElement {
83
- static addInitializer(t) {
84
- this._$Ei(), (this.l ??= []).push(t);
85
- }
86
- static get observedAttributes() {
87
- return this.finalize(), this._$Eh && [...this._$Eh.keys()];
88
- }
89
- static createProperty(t, e = G) {
90
- if (e.state && (e.attribute = !1), this._$Ei(), this.prototype.hasOwnProperty(t) && ((e = Object.create(e)).wrapped = !0), this.elementProperties.set(t, e), !e.noAccessor) {
91
- const s = Symbol(), i = this.getPropertyDescriptor(t, s, e);
92
- i !== void 0 && ct(this.prototype, t, i);
93
- }
94
- }
95
- static getPropertyDescriptor(t, e, s) {
96
- const { get: i, set: n } = pt(this.prototype, t) ?? { get() {
97
- return this[e];
98
- }, set(o) {
99
- this[e] = o;
100
- } };
101
- return { get: i, set(o) {
102
- const l = i?.call(this);
103
- n?.call(this, o), this.requestUpdate(t, l, s);
104
- }, configurable: !0, enumerable: !0 };
105
- }
106
- static getPropertyOptions(t) {
107
- return this.elementProperties.get(t) ?? G;
108
- }
109
- static _$Ei() {
110
- if (this.hasOwnProperty(P("elementProperties"))) return;
111
- const t = ft(this);
112
- t.finalize(), t.l !== void 0 && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties);
113
- }
114
- static finalize() {
115
- if (this.hasOwnProperty(P("finalized"))) return;
116
- if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(P("properties"))) {
117
- const e = this.properties, s = [...yt(e), ..._t(e)];
118
- for (const i of s) this.createProperty(i, e[i]);
119
- }
120
- const t = this[Symbol.metadata];
121
- if (t !== null) {
122
- const e = litPropertyMetadata.get(t);
123
- if (e !== void 0) for (const [s, i] of e) this.elementProperties.set(s, i);
124
- }
125
- this._$Eh = /* @__PURE__ */ new Map();
126
- for (const [e, s] of this.elementProperties) {
127
- const i = this._$Eu(e, s);
128
- i !== void 0 && this._$Eh.set(i, e);
129
- }
130
- this.elementStyles = this.finalizeStyles(this.styles);
131
- }
132
- static finalizeStyles(t) {
133
- const e = [];
134
- if (Array.isArray(t)) {
135
- const s = new Set(t.flat(1 / 0).reverse());
136
- for (const i of s) e.unshift(F(i));
137
- } else t !== void 0 && e.push(F(t));
138
- return e;
139
- }
140
- static _$Eu(t, e) {
141
- const s = e.attribute;
142
- return s === !1 ? void 0 : typeof s == "string" ? s : typeof t == "string" ? t.toLowerCase() : void 0;
143
- }
144
- constructor() {
145
- super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev();
146
- }
147
- _$Ev() {
148
- this._$ES = new Promise(((t) => this.enableUpdating = t)), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), this.constructor.l?.forEach(((t) => t(this)));
149
- }
150
- addController(t) {
151
- (this._$EO ??= /* @__PURE__ */ new Set()).add(t), this.renderRoot !== void 0 && this.isConnected && t.hostConnected?.();
152
- }
153
- removeController(t) {
154
- this._$EO?.delete(t);
155
- }
156
- _$E_() {
157
- const t = /* @__PURE__ */ new Map(), e = this.constructor.elementProperties;
158
- for (const s of e.keys()) this.hasOwnProperty(s) && (t.set(s, this[s]), delete this[s]);
159
- t.size > 0 && (this._$Ep = t);
160
- }
161
- createRenderRoot() {
162
- const t = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
163
- return dt(t, this.constructor.elementStyles), t;
164
- }
165
- connectedCallback() {
166
- this.renderRoot ??= this.createRenderRoot(), this.enableUpdating(!0), this._$EO?.forEach(((t) => t.hostConnected?.()));
167
- }
168
- enableUpdating(t) {
169
- }
170
- disconnectedCallback() {
171
- this._$EO?.forEach(((t) => t.hostDisconnected?.()));
172
- }
173
- attributeChangedCallback(t, e, s) {
174
- this._$AK(t, s);
175
- }
176
- _$ET(t, e) {
177
- const s = this.constructor.elementProperties.get(t), i = this.constructor._$Eu(t, s);
178
- if (i !== void 0 && s.reflect === !0) {
179
- const n = (s.converter?.toAttribute !== void 0 ? s.converter : T).toAttribute(e, s.type);
180
- this._$Em = t, n == null ? this.removeAttribute(i) : this.setAttribute(i, n), this._$Em = null;
181
- }
182
- }
183
- _$AK(t, e) {
184
- const s = this.constructor, i = s._$Eh.get(t);
185
- if (i !== void 0 && this._$Em !== i) {
186
- const n = s.getPropertyOptions(i), o = typeof n.converter == "function" ? { fromAttribute: n.converter } : n.converter?.fromAttribute !== void 0 ? n.converter : T;
187
- this._$Em = i;
188
- const l = o.fromAttribute(e, n.type);
189
- this[i] = l ?? this._$Ej?.get(i) ?? l, this._$Em = null;
190
- }
191
- }
192
- requestUpdate(t, e, s) {
193
- if (t !== void 0) {
194
- const i = this.constructor, n = this[t];
195
- if (s ??= i.getPropertyOptions(t), !((s.hasChanged ?? V)(n, e) || s.useDefault && s.reflect && n === this._$Ej?.get(t) && !this.hasAttribute(i._$Eu(t, s)))) return;
196
- this.C(t, e, s);
197
- }
198
- this.isUpdatePending === !1 && (this._$ES = this._$EP());
199
- }
200
- C(t, e, { useDefault: s, reflect: i, wrapped: n }, o) {
201
- s && !(this._$Ej ??= /* @__PURE__ */ new Map()).has(t) && (this._$Ej.set(t, o ?? e ?? this[t]), n !== !0 || o !== void 0) || (this._$AL.has(t) || (this.hasUpdated || s || (e = void 0), this._$AL.set(t, e)), i === !0 && this._$Em !== t && (this._$Eq ??= /* @__PURE__ */ new Set()).add(t));
202
- }
203
- async _$EP() {
204
- this.isUpdatePending = !0;
205
- try {
206
- await this._$ES;
207
- } catch (e) {
208
- Promise.reject(e);
209
- }
210
- const t = this.scheduleUpdate();
211
- return t != null && await t, !this.isUpdatePending;
212
- }
213
- scheduleUpdate() {
214
- return this.performUpdate();
215
- }
216
- performUpdate() {
217
- if (!this.isUpdatePending) return;
218
- if (!this.hasUpdated) {
219
- if (this.renderRoot ??= this.createRenderRoot(), this._$Ep) {
220
- for (const [i, n] of this._$Ep) this[i] = n;
221
- this._$Ep = void 0;
222
- }
223
- const s = this.constructor.elementProperties;
224
- if (s.size > 0) for (const [i, n] of s) {
225
- const { wrapped: o } = n, l = this[i];
226
- o !== !0 || this._$AL.has(i) || l === void 0 || this.C(i, void 0, n, l);
227
- }
228
- }
229
- let t = !1;
230
- const e = this._$AL;
231
- try {
232
- t = this.shouldUpdate(e), t ? (this.willUpdate(e), this._$EO?.forEach(((s) => s.hostUpdate?.())), this.update(e)) : this._$EM();
233
- } catch (s) {
234
- throw t = !1, this._$EM(), s;
235
- }
236
- t && this._$AE(e);
237
- }
238
- willUpdate(t) {
239
- }
240
- _$AE(t) {
241
- this._$EO?.forEach(((e) => e.hostUpdated?.())), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(t)), this.updated(t);
242
- }
243
- _$EM() {
244
- this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1;
245
- }
246
- get updateComplete() {
247
- return this.getUpdateComplete();
248
- }
249
- getUpdateComplete() {
250
- return this._$ES;
251
- }
252
- shouldUpdate(t) {
253
- return !0;
254
- }
255
- update(t) {
256
- this._$Eq &&= this._$Eq.forEach(((e) => this._$ET(e, this[e]))), this._$EM();
257
- }
258
- updated(t) {
259
- }
260
- firstUpdated(t) {
261
- }
262
- }
263
- E.elementStyles = [], E.shadowRootOptions = { mode: "open" }, E[P("elementProperties")] = /* @__PURE__ */ new Map(), E[P("finalized")] = /* @__PURE__ */ new Map(), bt?.({ ReactiveElement: E }), (I.reactiveElementVersions ??= []).push("2.1.1");
264
- /**
265
- * @license
266
- * Copyright 2017 Google LLC
267
- * SPDX-License-Identifier: BSD-3-Clause
268
- */
269
- const gt = { attribute: !0, type: String, converter: T, reflect: !1, hasChanged: V }, $t = (r = gt, t, e) => {
270
- const { kind: s, metadata: i } = e;
271
- let n = globalThis.litPropertyMetadata.get(i);
272
- if (n === void 0 && globalThis.litPropertyMetadata.set(i, n = /* @__PURE__ */ new Map()), s === "setter" && ((r = Object.create(r)).wrapped = !0), n.set(e.name, r), s === "accessor") {
273
- const { name: o } = e;
274
- return { set(l) {
275
- const a = t.get.call(this);
276
- t.set.call(this, l), this.requestUpdate(o, a, r);
277
- }, init(l) {
278
- return l !== void 0 && this.C(o, void 0, r, l), l;
279
- } };
280
- }
281
- if (s === "setter") {
282
- const { name: o } = e;
283
- return function(l) {
284
- const a = this[o];
285
- t.call(this, l), this.requestUpdate(o, a, r);
286
- };
287
- }
288
- throw Error("Unsupported decorator location: " + s);
289
- };
290
- function u(r) {
291
- return (t, e) => typeof e == "object" ? $t(r, t, e) : ((s, i, n) => {
292
- const o = i.hasOwnProperty(n);
293
- return i.constructor.createProperty(n, s), o ? Object.getOwnPropertyDescriptor(i, n) : void 0;
294
- })(r, t, e);
295
- }
296
- /**
297
- * @license
298
- * Copyright 2017 Google LLC
299
- * SPDX-License-Identifier: BSD-3-Clause
300
- */
301
- function mt(r) {
302
- return u({ ...r, state: !0, attribute: !1 });
303
- }
304
- const xt = ot`
305
- :host {
306
- /* Anything that can be overridden should be defined here */
307
-
308
- /* Global Text Input Styles */
309
- --_nys-textinput-width: 100%;
310
- --_nys-textinput-height: var(--nys-size-500, 40px);
311
- --_nys-textinput-border-radius: var(--nys-radius-md, 4px);
312
- --_nys-textinput-border-width: var(--nys-border-width-sm, 1px);
313
- --_nys-textinput-border-color: var(--nys-color-neutral-400, #909395);
314
- --_nys-textinput-color: var(
315
- --nys-color-text,
316
- var(--nys-color-neutral-900, #1b1b1b)
317
- );
318
- --_nys-textinput-color--placeholder: var(
319
- --nys-color-text-weaker,
320
- var(--nys-color-neutral-500, #797c7f)
321
- );
322
- --_nys-textinput-padding: var(--nys-space-100, 8px);
323
- --_nys-textinput-gap: var(--nys-space-50, 4px);
324
- --_nys-textinput-background-color: var(
325
- --nys-color-ink-reverse,
326
- var(--nys-color-white, #ffffff)
327
- );
328
- --_nys-textinput-color: var(
329
- --nys-color-ink,
330
- var(--nys-color-neutral-900, #1b1b1b)
331
- );
332
-
333
- /* Hovered */
334
- --_nys-textinput-outline-color--hover: var(
335
- --nys-color-neutral-900,
336
- #1b1b1b
337
- );
338
- --_nys-textinput-outline-width: var(--nys-border-width-sm, 1px);
339
-
340
- /* Focused */
341
- --_nys-textinput-outline-color--focus: var(--nys-color-focus, #004dd1);
342
-
343
- /* Disabled */
344
- --_nys-textinput-background-color--disabled: var(
345
- --nys-color-neutral-10,
346
- #f6f6f6
347
- );
348
- --_nys-textinput-border-color--disabled: var(
349
- --nys-color-neutral-200,
350
- #bec0c1
351
- );
352
- --_nys-textinput-color--disabled: var(
353
- --nys-color-text-disabled,
354
- var(--nys-color-neutral-200, #bec0c1)
355
- );
356
-
357
- /* Global Font Styles */
358
- --_nys-textinput-font-family: var(
359
- --nys-font-family-ui,
360
- var(
361
- --nys-font-family-sans,
362
- "Proxima Nova",
363
- "Helvetica Neue",
364
- "Helvetica",
365
- "Arial",
366
- sans-serif
367
- )
368
- );
369
- --_nys-textinput-font-size: var(--nys-font-size-ui-md, 16px);
370
- --_nys-textinput-font-weight: var(--nys-font-weight-regular, 400);
371
- --_nys-textinput-line-height: var(--nys-font-lineheight-ui-md, 24px);
372
- --_nys-textinput-letter-spacing: var(
373
- --nys-font-letterspacing-ui-md,
374
- var(--nys-font-letterspacing-400, 0.044px)
375
- );
376
- }
377
-
378
- :host([width="sm"]) {
379
- --_nys-textinput-width: var(--nys-form-width-sm, 88px);
380
- }
381
-
382
- :host([width="md"]) {
383
- --_nys-textinput-width: var(--nys-form-width-md, 200px);
384
- }
385
-
386
- :host([width="lg"]) {
387
- --_nys-textinput-width: var(--nys-form-width-lg, 384px);
388
- }
389
-
390
- :host([width="full"]) {
391
- --_nys-textinput-width: 100%;
392
- flex: 1; /* stretches width for flex container */
393
- }
394
-
395
- :host([showError]) {
396
- --_nys-textinput-border-color: var(--nys-color-danger, #b52c2c);
397
- }
398
-
399
- .nys-textinput {
400
- font-weight: var(--_nys-textinput-font-weight);
401
- font-family: var(--_nys-textinput-font-family);
402
- font-size: var(--_nys-textinput-font-size);
403
- line-height: var(--_nys-textinput-line-height);
404
- letter-spacing: var(--_nys-textinput-letter-spacing);
405
- color: var(--_nys-textinput-color);
406
- gap: var(--_nys-textinput-gap);
407
- display: flex;
408
- flex-direction: column;
409
- }
410
-
411
- .nys-textinput__mask-overlay {
412
- position: absolute;
413
- margin: calc(
414
- var(--_nys-textinput-padding) + var(--_nys-textinput-border-width)
415
- );
416
- color: var(--nys-color-text-weaker, #797c7f);
417
- display: inline;
418
- overflow: hidden;
419
- white-space: nowrap;
420
- font: inherit;
421
- letter-spacing: normal;
422
- }
423
-
424
- .nys-textinput__input {
425
- color: var(--_nys-textinput-color);
426
- border-radius: var(--_nys-textinput-border-radius);
427
- border: solid var(--_nys-textinput-border-color)
428
- var(--_nys-textinput-border-width);
429
- outline-color: transparent;
430
- outline-width: var(--_nys-textinput-outline-width);
431
- outline-style: solid;
432
- padding: var(--_nys-textinput-padding);
433
- width: 100%;
434
- height: var(--_nys-textinput-height);
435
- box-sizing: border-box;
436
- -webkit-box-sizing: border-box;
437
- -moz-box-sizing: border-box;
438
- background-color: transparent;
439
- position: relative;
440
- font: inherit;
441
- }
442
- .nys-textinput__input::placeholder {
443
- color: var(--_nys-textinput-color--placeholder);
444
- }
445
-
446
- .nys-textinput__buttoncontainer {
447
- width: var(--_nys-textinput-width);
448
- max-width: 100%;
449
- display: flex;
450
- }
451
-
452
- .nys-textinput__buttoncontainer.has-end-button .nys-textinput__input {
453
- border-start-end-radius: 0;
454
- border-end-end-radius: 0;
455
- border-inline-end: none;
456
- }
457
-
458
- .nys-textinput__buttoncontainer.has-start-button .nys-textinput__input {
459
- border-start-start-radius: 0;
460
- border-end-start-radius: 0;
461
- border-inline-start: none;
462
- }
463
-
464
- .nys-textinput__container {
465
- position: relative;
466
- display: flex;
467
- align-items: center;
468
- width: 100%;
469
- background-color: var(--_nys-textinput-background-color);
470
- border-radius: var(--_nys-textinput-border-radius);
471
- }
472
-
473
- ::slotted(nys-button) {
474
- /* These props ARE NOT publicly overridable */
475
- --_nys-button-height: var(--_nys-textinput-height);
476
- --_nys-button-border-radius--start: var(--_nys-textinput-border-radius);
477
- --_nys-button-border-radius--end: var(--_nys-textinput-border-radius);
478
- --_nys-button-background-color--disabled: var(
479
- --_nys-textinput-background-color--disabled
480
- );
481
- --_nys-button-border-color--disabled: var(--_nys-textinput-color--disabled);
482
- --_nys-button-color--disabled: var(--_nys-textinput-color--disabled);
483
- --_nys-button-border-width: var(--_nys-textinput-border-width);
484
- z-index: 1; /* to make sure the button outline renders on top of the input */
485
- }
486
-
487
- .nys-textinput__buttoncontainer.has-start-button ::slotted(nys-button) {
488
- --_nys-button-border-radius--end: 0;
489
- }
490
-
491
- .nys-textinput__buttoncontainer.has-end-button ::slotted(nys-button) {
492
- --_nys-button-border-radius--start: 0;
493
- }
494
-
495
- .eye-icon {
496
- position: absolute;
497
- right: var(--nys-space-50, 4px);
498
- top: 50%;
499
- transform: translateY(-50%);
500
- cursor: pointer;
501
- color: var(--_nys-textinput-color--icon);
502
- /* These props ARE publicly overridable */
503
- --nys-button-background-color: var(--_nys-textinput-background-color);
504
- --nys-button-background-color--hover: var(
505
- --_nys-textinput-background-color
506
- );
507
- --nys-button-background-color--active: var(
508
- --_nys-textinput-background-color
509
- );
510
- /* These props ARE NOT publicly overridable */
511
- --_nys-button-outline-focus: calc(
512
- var(--_nys-button-outline-width) * -1
513
- ); /* Needs to be negative of the offset width */
514
- --_nys-button-padding--y: var(--nys-space-50, 4px);
515
- --_nys-button-padding--x: var(--nys-space-50, 4px);
516
- --_nys-button-height: var(--nys-size-300, 32px);
517
- --_nys-button-width: var(--nys-size-400, 32px);
518
- }
519
-
520
- /* Hovered */
521
- .nys-textinput__input:hover:not(:disabled):not(:focus) {
522
- outline-color: var(--_nys-textinput-outline-color--hover);
523
- border-color: var(--_nys-textinput-outline-color--hover);
524
- }
525
-
526
- /* Focused */
527
- .nys-textinput__input:focus {
528
- outline-color: var(--_nys-textinput-outline-color--focus);
529
- border-color: var(--_nys-textinput-outline-color--focus);
530
- caret-color: var(--_nys-textinput-outline-color--focus);
531
- }
532
-
533
- /* Disabled */
534
- .nys-textinput__input:disabled,
535
- .nys-textinput__input:disabled::placeholder,
536
- .nys-textinput__input:disabled + .eye-icon {
537
- background-color: var(--_nys-textinput-background-color--disabled);
538
- border-color: var(--_nys-textinput-border-color--disabled);
539
- color: var(--_nys-textinput-color--disabled);
540
- cursor: not-allowed;
541
- }
542
- `;
543
- /**
544
- * @license
545
- * Copyright 2017 Google LLC
546
- * SPDX-License-Identifier: BSD-3-Clause
547
- */
548
- const z = globalThis, R = z.trustedTypes, J = R ? R.createPolicy("lit-html", { createHTML: (r) => r }) : void 0, st = "$lit$", g = `lit$${Math.random().toFixed(9).slice(2)}$`, it = "?" + g, wt = `<${it}>`, w = document, H = () => w.createComment(""), M = (r) => r === null || typeof r != "object" && typeof r != "function", D = Array.isArray, At = (r) => D(r) || typeof r?.[Symbol.iterator] == "function", B = `[
549
- \f\r]`, S = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, K = /-->/g, Z = />/g, $ = RegExp(`>|${B}(?:([^\\s"'>=/]+)(${B}*=${B}*(?:[^
550
- \f\r"'\`<>=]|("|')|))|$)`, "g"), Q = /'/g, X = /"/g, nt = /^(?:script|style|textarea|title)$/i, C = Symbol.for("lit-noChange"), p = Symbol.for("lit-nothing"), tt = /* @__PURE__ */ new WeakMap(), x = w.createTreeWalker(w, 129);
551
- function rt(r, t) {
552
- if (!D(r) || !r.hasOwnProperty("raw")) throw Error("invalid template strings array");
553
- return J !== void 0 ? J.createHTML(t) : t;
554
- }
555
- const Et = (r, t) => {
556
- const e = r.length - 1, s = [];
557
- let i, n = t === 2 ? "<svg>" : t === 3 ? "<math>" : "", o = S;
558
- for (let l = 0; l < e; l++) {
559
- const a = r[l];
560
- let y, _, h = -1, v = 0;
561
- for (; v < a.length && (o.lastIndex = v, _ = o.exec(a), _ !== null); ) v = o.lastIndex, o === S ? _[1] === "!--" ? o = K : _[1] !== void 0 ? o = Z : _[2] !== void 0 ? (nt.test(_[2]) && (i = RegExp("</" + _[2], "g")), o = $) : _[3] !== void 0 && (o = $) : o === $ ? _[0] === ">" ? (o = i ?? S, h = -1) : _[1] === void 0 ? h = -2 : (h = o.lastIndex - _[2].length, y = _[1], o = _[3] === void 0 ? $ : _[3] === '"' ? X : Q) : o === X || o === Q ? o = $ : o === K || o === Z ? o = S : (o = $, i = void 0);
562
- const b = o === $ && r[l + 1].startsWith("/>") ? " " : "";
563
- n += o === S ? a + wt : h >= 0 ? (s.push(y), a.slice(0, h) + st + a.slice(h) + g + b) : a + g + (h === -2 ? l : b);
564
- }
565
- return [rt(r, n + (r[e] || "<?>") + (t === 2 ? "</svg>" : t === 3 ? "</math>" : "")), s];
566
- };
567
- class k {
568
- constructor({ strings: t, _$litType$: e }, s) {
569
- let i;
570
- this.parts = [];
571
- let n = 0, o = 0;
572
- const l = t.length - 1, a = this.parts, [y, _] = Et(t, e);
573
- if (this.el = k.createElement(y, s), x.currentNode = this.el.content, e === 2 || e === 3) {
574
- const h = this.el.content.firstChild;
575
- h.replaceWith(...h.childNodes);
576
- }
577
- for (; (i = x.nextNode()) !== null && a.length < l; ) {
578
- if (i.nodeType === 1) {
579
- if (i.hasAttributes()) for (const h of i.getAttributeNames()) if (h.endsWith(st)) {
580
- const v = _[o++], b = i.getAttribute(h).split(g), U = /([.?@])?(.*)/.exec(v);
581
- a.push({ type: 1, index: n, name: U[2], strings: b, ctor: U[1] === "." ? Pt : U[1] === "?" ? Mt : U[1] === "@" ? Ct : q }), i.removeAttribute(h);
582
- } else h.startsWith(g) && (a.push({ type: 6, index: n }), i.removeAttribute(h));
583
- if (nt.test(i.tagName)) {
584
- const h = i.textContent.split(g), v = h.length - 1;
585
- if (v > 0) {
586
- i.textContent = R ? R.emptyScript : "";
587
- for (let b = 0; b < v; b++) i.append(h[b], H()), x.nextNode(), a.push({ type: 2, index: ++n });
588
- i.append(h[v], H());
589
- }
590
- }
591
- } else if (i.nodeType === 8) if (i.data === it) a.push({ type: 2, index: n });
592
- else {
593
- let h = -1;
594
- for (; (h = i.data.indexOf(g, h + 1)) !== -1; ) a.push({ type: 7, index: n }), h += g.length - 1;
595
- }
596
- n++;
597
- }
598
- }
599
- static createElement(t, e) {
600
- const s = w.createElement("template");
601
- return s.innerHTML = t, s;
602
- }
603
- }
604
- function A(r, t, e = r, s) {
605
- if (t === C) return t;
606
- let i = s !== void 0 ? e._$Co?.[s] : e._$Cl;
607
- const n = M(t) ? void 0 : t._$litDirective$;
608
- return i?.constructor !== n && (i?._$AO?.(!1), n === void 0 ? i = void 0 : (i = new n(r), i._$AT(r, e, s)), s !== void 0 ? (e._$Co ??= [])[s] = i : e._$Cl = i), i !== void 0 && (t = A(r, i._$AS(r, t.values), i, s)), t;
609
- }
610
- class St {
611
- constructor(t, e) {
612
- this._$AV = [], this._$AN = void 0, this._$AD = t, this._$AM = e;
613
- }
614
- get parentNode() {
615
- return this._$AM.parentNode;
616
- }
617
- get _$AU() {
618
- return this._$AM._$AU;
619
- }
620
- u(t) {
621
- const { el: { content: e }, parts: s } = this._$AD, i = (t?.creationScope ?? w).importNode(e, !0);
622
- x.currentNode = i;
623
- let n = x.nextNode(), o = 0, l = 0, a = s[0];
624
- for (; a !== void 0; ) {
625
- if (o === a.index) {
626
- let y;
627
- a.type === 2 ? y = new N(n, n.nextSibling, this, t) : a.type === 1 ? y = new a.ctor(n, a.name, a.strings, this, t) : a.type === 6 && (y = new kt(n, this, t)), this._$AV.push(y), a = s[++l];
628
- }
629
- o !== a?.index && (n = x.nextNode(), o++);
630
- }
631
- return x.currentNode = w, i;
632
- }
633
- p(t) {
634
- let e = 0;
635
- for (const s of this._$AV) s !== void 0 && (s.strings !== void 0 ? (s._$AI(t, s, e), e += s.strings.length - 2) : s._$AI(t[e])), e++;
636
- }
637
- }
638
- class N {
639
- get _$AU() {
640
- return this._$AM?._$AU ?? this._$Cv;
641
- }
642
- constructor(t, e, s, i) {
643
- this.type = 2, this._$AH = p, this._$AN = void 0, this._$AA = t, this._$AB = e, this._$AM = s, this.options = i, this._$Cv = i?.isConnected ?? !0;
644
- }
645
- get parentNode() {
646
- let t = this._$AA.parentNode;
647
- const e = this._$AM;
648
- return e !== void 0 && t?.nodeType === 11 && (t = e.parentNode), t;
649
- }
650
- get startNode() {
651
- return this._$AA;
652
- }
653
- get endNode() {
654
- return this._$AB;
655
- }
656
- _$AI(t, e = this) {
657
- t = A(this, t, e), M(t) ? t === p || t == null || t === "" ? (this._$AH !== p && this._$AR(), this._$AH = p) : t !== this._$AH && t !== C && this._(t) : t._$litType$ !== void 0 ? this.$(t) : t.nodeType !== void 0 ? this.T(t) : At(t) ? this.k(t) : this._(t);
658
- }
659
- O(t) {
660
- return this._$AA.parentNode.insertBefore(t, this._$AB);
661
- }
662
- T(t) {
663
- this._$AH !== t && (this._$AR(), this._$AH = this.O(t));
664
- }
665
- _(t) {
666
- this._$AH !== p && M(this._$AH) ? this._$AA.nextSibling.data = t : this.T(w.createTextNode(t)), this._$AH = t;
667
- }
668
- $(t) {
669
- const { values: e, _$litType$: s } = t, i = typeof s == "number" ? this._$AC(t) : (s.el === void 0 && (s.el = k.createElement(rt(s.h, s.h[0]), this.options)), s);
670
- if (this._$AH?._$AD === i) this._$AH.p(e);
671
- else {
672
- const n = new St(i, this), o = n.u(this.options);
673
- n.p(e), this.T(o), this._$AH = n;
674
- }
675
- }
676
- _$AC(t) {
677
- let e = tt.get(t.strings);
678
- return e === void 0 && tt.set(t.strings, e = new k(t)), e;
679
- }
680
- k(t) {
681
- D(this._$AH) || (this._$AH = [], this._$AR());
682
- const e = this._$AH;
683
- let s, i = 0;
684
- for (const n of t) i === e.length ? e.push(s = new N(this.O(H()), this.O(H()), this, this.options)) : s = e[i], s._$AI(n), i++;
685
- i < e.length && (this._$AR(s && s._$AB.nextSibling, i), e.length = i);
686
- }
687
- _$AR(t = this._$AA.nextSibling, e) {
688
- for (this._$AP?.(!1, !0, e); t !== this._$AB; ) {
689
- const s = t.nextSibling;
690
- t.remove(), t = s;
691
- }
692
- }
693
- setConnected(t) {
694
- this._$AM === void 0 && (this._$Cv = t, this._$AP?.(t));
695
- }
696
- }
697
- class q {
698
- get tagName() {
699
- return this.element.tagName;
700
- }
701
- get _$AU() {
702
- return this._$AM._$AU;
703
- }
704
- constructor(t, e, s, i, n) {
705
- this.type = 1, this._$AH = p, this._$AN = void 0, this.element = t, this.name = e, this._$AM = i, this.options = n, s.length > 2 || s[0] !== "" || s[1] !== "" ? (this._$AH = Array(s.length - 1).fill(new String()), this.strings = s) : this._$AH = p;
706
- }
707
- _$AI(t, e = this, s, i) {
708
- const n = this.strings;
709
- let o = !1;
710
- if (n === void 0) t = A(this, t, e, 0), o = !M(t) || t !== this._$AH && t !== C, o && (this._$AH = t);
711
- else {
712
- const l = t;
713
- let a, y;
714
- for (t = n[0], a = 0; a < n.length - 1; a++) y = A(this, l[s + a], e, a), y === C && (y = this._$AH[a]), o ||= !M(y) || y !== this._$AH[a], y === p ? t = p : t !== p && (t += (y ?? "") + n[a + 1]), this._$AH[a] = y;
715
- }
716
- o && !i && this.j(t);
717
- }
718
- j(t) {
719
- t === p ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t ?? "");
720
- }
721
- }
722
- class Pt extends q {
723
- constructor() {
724
- super(...arguments), this.type = 3;
725
- }
726
- j(t) {
727
- this.element[this.name] = t === p ? void 0 : t;
728
- }
729
- }
730
- class Mt extends q {
731
- constructor() {
732
- super(...arguments), this.type = 4;
733
- }
734
- j(t) {
735
- this.element.toggleAttribute(this.name, !!t && t !== p);
736
- }
737
- }
738
- class Ct extends q {
739
- constructor(t, e, s, i, n) {
740
- super(t, e, s, i, n), this.type = 5;
741
- }
742
- _$AI(t, e = this) {
743
- if ((t = A(this, t, e, 0) ?? p) === C) return;
744
- const s = this._$AH, i = t === p && s !== p || t.capture !== s.capture || t.once !== s.once || t.passive !== s.passive, n = t !== p && (s === p || i);
745
- i && this.element.removeEventListener(this.name, this, s), n && this.element.addEventListener(this.name, this, t), this._$AH = t;
746
- }
747
- handleEvent(t) {
748
- typeof this._$AH == "function" ? this._$AH.call(this.options?.host ?? this.element, t) : this._$AH.handleEvent(t);
749
- }
750
- }
751
- class kt {
752
- constructor(t, e, s) {
753
- this.element = t, this.type = 6, this._$AN = void 0, this._$AM = e, this.options = s;
754
- }
755
- get _$AU() {
756
- return this._$AM._$AU;
757
- }
758
- _$AI(t) {
759
- A(this, t);
760
- }
761
- }
762
- const Ut = z.litHtmlPolyfillSupport;
763
- Ut?.(k, N), (z.litHtmlVersions ??= []).push("3.3.1");
764
- /**
765
- * @license
766
- * Copyright 2018 Google LLC
767
- * SPDX-License-Identifier: BSD-3-Clause
768
- */
769
- const m = (r) => r ?? p;
770
- var Ot = Object.defineProperty, Tt = Object.getOwnPropertyDescriptor, c = (r, t, e, s) => {
771
- for (var i = s > 1 ? void 0 : s ? Tt(t, e) : t, n = r.length - 1, o; n >= 0; n--)
772
- (o = r[n]) && (i = (s ? o(t, e, i) : o(i)) || i);
773
- return s && i && Ot(t, e, i), i;
774
- };
775
- let Rt = 0;
776
- var f;
777
- const d = (f = class extends at {
10
+ let x = 0;
11
+ var u;
12
+ const n = (u = class extends y {
778
13
  // allows use of elementInternals' API
779
14
  constructor() {
780
15
  super(), this.id = "", this.name = "", this._type = "text", this.label = "", this.description = "", this.placeholder = "", this.value = "", this.disabled = !1, this.readonly = !1, this.required = !1, this.optional = !1, this._tooltip = "", this.form = null, this.pattern = "", this.maxlength = null, this.width = "full", this.step = null, this.min = null, this.max = null, this.inverted = !1, this.showError = !1, this.errorMessage = "", this.showPassword = !1, this._originalErrorMessage = "", this._hasUserInteracted = !1, this._maskPatterns = {
@@ -784,14 +19,14 @@ const d = (f = class extends at {
784
19
  get type() {
785
20
  return this._type;
786
21
  }
787
- set type(t) {
788
- this._type = f.VALID_TYPES.includes(
789
- t
790
- ) ? t : "text";
22
+ set type(e) {
23
+ this._type = u.VALID_TYPES.includes(
24
+ e
25
+ ) ? e : "text";
791
26
  }
792
27
  // Generate a unique ID if one is not provided
793
28
  connectedCallback() {
794
- super.connectedCallback(), this.id || (this.id = `nys-textinput-${Date.now()}-${Rt++}`), this._originalErrorMessage = this.errorMessage ?? "", this.addEventListener("invalid", this._handleInvalid);
29
+ super.connectedCallback(), this.id || (this.id = `nys-textinput-${Date.now()}-${x++}`), this._originalErrorMessage = this.errorMessage ?? "", this.addEventListener("invalid", this._handleInvalid);
795
30
  }
796
31
  disconnectedCallback() {
797
32
  super.disconnectedCallback(), this.removeEventListener("invalid", this._handleInvalid);
@@ -800,14 +35,14 @@ const d = (f = class extends at {
800
35
  this._setValue();
801
36
  }
802
37
  // Ensure the "width" property is valid after updates
803
- async updated(t) {
804
- if (t.has("width") && (await Promise.resolve(), this.width = f.VALID_WIDTHS.includes(this.width) ? this.width : "full"), t.has("disabled") && (this._validateButtonSlot("startButton"), this._validateButtonSlot("endButton")), t.has("type")) {
805
- const e = this._maskPatterns[this.type], s = this.shadowRoot?.querySelector("input");
806
- if (s)
807
- if (e)
808
- s.maxLength = e.length, this._updateOverlay(s.value, e);
38
+ async updated(e) {
39
+ if (e.has("width") && (await Promise.resolve(), this.width = u.VALID_WIDTHS.includes(this.width) ? this.width : "full"), e.has("disabled") && (this._validateButtonSlot("startButton"), this._validateButtonSlot("endButton")), e.has("type")) {
40
+ const s = this._maskPatterns[this.type], t = this.shadowRoot?.querySelector("input");
41
+ if (t)
42
+ if (s)
43
+ t.maxLength = s.length, this._updateOverlay(t.value, s);
809
44
  else {
810
- s.removeAttribute("maxLength");
45
+ t.removeAttribute("maxLength");
811
46
  const i = this.shadowRoot?.querySelector(
812
47
  ".nys-textinput__mask-overlay"
813
48
  );
@@ -824,75 +59,75 @@ const d = (f = class extends at {
824
59
  this._internals.setFormValue(this.value), this._manageRequire();
825
60
  }
826
61
  _manageRequire() {
827
- const t = this.shadowRoot?.querySelector("input");
828
- if (!t) return;
829
- const e = this.errorMessage || "This field is required";
830
- this.required && (!this.value || this.value?.trim() === "") ? (this._internals.ariaRequired = "true", this._internals.setValidity({ valueMissing: !0 }, e, t)) : (this._internals.ariaRequired = "false", this._internals.setValidity({}), this._hasUserInteracted = !1);
831
- }
832
- _setValidityMessage(t = "") {
833
62
  const e = this.shadowRoot?.querySelector("input");
834
63
  if (!e) return;
835
- this.showError = !!t, this._originalErrorMessage?.trim() && t !== "" ? this.errorMessage = this._originalErrorMessage : this.errorMessage = t;
836
- const s = t ? { customError: !0 } : {};
837
- this._internals.setValidity(s, this.errorMessage, e);
64
+ const s = this.errorMessage || "This field is required";
65
+ this.required && (!this.value || this.value?.trim() === "") ? (this._internals.ariaRequired = "true", this._internals.setValidity({ valueMissing: !0 }, s, e)) : (this._internals.ariaRequired = "false", this._internals.setValidity({}), this._hasUserInteracted = !1);
66
+ }
67
+ _setValidityMessage(e = "") {
68
+ const s = this.shadowRoot?.querySelector("input");
69
+ if (!s) return;
70
+ this.showError = !!e, this._originalErrorMessage?.trim() && e !== "" ? this.errorMessage = this._originalErrorMessage : this.errorMessage = e;
71
+ const t = e ? { customError: !0 } : {};
72
+ this._internals.setValidity(t, this.errorMessage, s);
838
73
  }
839
74
  _validate() {
840
- const t = this.shadowRoot?.querySelector("input");
841
- if (!t) return;
842
- const e = t.validity;
843
- let s = "";
844
- e.valueMissing ? s = "This field is required" : e.typeMismatch ? s = "Invalid format for this type" : e.patternMismatch ? s = "Invalid format" : e.tooShort ? s = `Value is too short. Minimum length is ${t.minLength}` : e.tooLong ? s = `Value is too long. Maximum length is ${t.maxLength}` : e.rangeUnderflow ? s = `Value must be at least ${t.min}` : e.rangeOverflow ? s = `Value must be at most ${t.max}` : e.stepMismatch ? s = "Invalid step value" : s = t.validationMessage, this._setValidityMessage(s);
75
+ const e = this.shadowRoot?.querySelector("input");
76
+ if (!e) return;
77
+ const s = e.validity;
78
+ let t = "";
79
+ s.valueMissing ? t = "This field is required" : s.typeMismatch ? t = "Invalid format for this type" : s.patternMismatch ? t = "Invalid format" : s.tooShort ? t = `Value is too short. Minimum length is ${e.minLength}` : s.tooLong ? t = `Value is too long. Maximum length is ${e.maxLength}` : s.rangeUnderflow ? t = `Value must be at least ${e.min}` : s.rangeOverflow ? t = `Value must be at most ${e.max}` : s.stepMismatch ? t = "Invalid step value" : t = e.validationMessage, this._setValidityMessage(t);
845
80
  }
846
81
  /********************** Functions **********************/
847
82
  // This helper function is called to perform the element's native validation.
848
83
  checkValidity() {
849
- const t = this.shadowRoot?.querySelector("input");
850
- return t ? t.checkValidity() : !0;
851
- }
852
- _handleInvalid(t) {
853
- t.preventDefault(), this._hasUserInteracted = !0, this._validate();
854
84
  const e = this.shadowRoot?.querySelector("input");
855
- if (e) {
856
- const s = this._internals.form;
857
- s ? Array.from(s.elements).find(
858
- (o) => typeof o.checkValidity == "function" && !o.checkValidity()
859
- ) === this && e.focus() : e.focus();
85
+ return e ? e.checkValidity() : !0;
86
+ }
87
+ _handleInvalid(e) {
88
+ e.preventDefault(), this._hasUserInteracted = !0, this._validate();
89
+ const s = this.shadowRoot?.querySelector("input");
90
+ if (s) {
91
+ const t = this._internals.form;
92
+ t ? Array.from(t.elements).find(
93
+ (a) => typeof a.checkValidity == "function" && !a.checkValidity()
94
+ ) === this && s.focus() : s.focus();
860
95
  }
861
96
  }
862
97
  _togglePasswordVisibility() {
863
98
  this.showPassword = !this.showPassword;
864
99
  }
865
- _updateOverlay(t, e) {
866
- const s = this.shadowRoot?.querySelector(
100
+ _updateOverlay(e, s) {
101
+ const t = this.shadowRoot?.querySelector(
867
102
  ".nys-textinput__mask-overlay"
868
103
  );
869
- if (!s) return;
870
- const i = t, n = e.slice(i.length);
871
- s.textContent = i + n;
104
+ if (!t) return;
105
+ const i = e, l = s.slice(i.length);
106
+ t.textContent = i + l;
872
107
  }
873
- _applyMask(t, e) {
874
- const s = t.replace(/\D/g, "");
108
+ _applyMask(e, s) {
109
+ const t = e.replace(/\D/g, "");
875
110
  let i = "";
876
111
  if (this.type === "tel")
877
- return s.length > 0 && (i = "(" + s.substring(0, 3)), s.length >= 4 && (i += ") " + s.substring(3, 6)), s.length > 6 && (i += "-" + s.substring(6, 10)), i;
878
- let n = 0;
879
- for (let o = 0; o < e.length; o++)
880
- if (e[o] === "_" || e[o].match(/[d9]/i))
881
- if (n < s.length)
882
- i += s[n++];
112
+ return t.length > 0 && (i = "(" + t.substring(0, 3)), t.length >= 4 && (i += ") " + t.substring(3, 6)), t.length > 6 && (i += "-" + t.substring(6, 10)), i;
113
+ let l = 0;
114
+ for (let a = 0; a < s.length; a++)
115
+ if (s[a] === "_" || s[a].match(/[d9]/i))
116
+ if (l < t.length)
117
+ i += t[l++];
883
118
  else
884
119
  break;
885
120
  else
886
- i += e[o];
121
+ i += s[a];
887
122
  return i;
888
123
  }
889
124
  /******************** Event Handlers ********************/
890
125
  // Handle input event to check pattern validity
891
- _handleInput(t) {
892
- const e = t.target;
893
- let s = e.value;
126
+ _handleInput(e) {
127
+ const s = e.target;
128
+ let t = s.value;
894
129
  const i = this._maskPatterns[this.type];
895
- i && (s = this._applyMask(s, i), e.value = s, this._updateOverlay(s, i)), this.value = s, this._internals.setFormValue(this.value), this._hasUserInteracted && this._validate(), this.dispatchEvent(
130
+ i && (t = this._applyMask(t, i), s.value = t, this._updateOverlay(t, i)), this.value = t, this._internals.setFormValue(this.value), this._hasUserInteracted && this._validate(), this.dispatchEvent(
896
131
  new CustomEvent("nys-input", {
897
132
  detail: { id: this.id, value: this.value },
898
133
  bubbles: !0,
@@ -908,27 +143,27 @@ const d = (f = class extends at {
908
143
  _handleBlur() {
909
144
  this._hasUserInteracted || (this._hasUserInteracted = !0), this._validate(), this.dispatchEvent(new Event("nys-blur"));
910
145
  }
911
- _validateButtonSlot(t) {
912
- const e = this.shadowRoot?.querySelector(
913
- 'slot[name="' + t + '"]'
914
- ), s = this.shadowRoot?.querySelector(
146
+ _validateButtonSlot(e) {
147
+ const s = this.shadowRoot?.querySelector(
148
+ 'slot[name="' + e + '"]'
149
+ ), t = this.shadowRoot?.querySelector(
915
150
  ".nys-textinput__buttoncontainer"
916
151
  );
917
- if (!e || !s) return;
918
- const i = e.assignedElements();
919
- let n = !1;
920
- i.forEach((o) => {
921
- o instanceof HTMLElement && o.tagName.toLowerCase() === "nys-button" && !n ? (n = !0, o.setAttribute("size", "sm"), o.setAttribute("variant", "primary"), this.disabled ? o.setAttribute("disabled", "true") : o.removeAttribute("disabled")) : (console.warn(
922
- "The '" + t + "' slot only accepts a single <nys-button> element. Removing invalid or extra node:",
923
- o
924
- ), o.remove());
925
- }), t === "startButton" ? s.classList.toggle("has-start-button", n) : t === "endButton" && s.classList.toggle("has-end-button", n);
152
+ if (!s || !t) return;
153
+ const i = s.assignedElements();
154
+ let l = !1;
155
+ i.forEach((a) => {
156
+ a instanceof HTMLElement && a.tagName.toLowerCase() === "nys-button" && !l ? (l = !0, a.setAttribute("size", "sm"), a.setAttribute("variant", "primary"), this.disabled ? a.setAttribute("disabled", "true") : a.removeAttribute("disabled")) : (console.warn(
157
+ "The '" + e + "' slot only accepts a single <nys-button> element. Removing invalid or extra node:",
158
+ a
159
+ ), a.remove());
160
+ }), e === "startButton" ? t.classList.toggle("has-start-button", l) : e === "endButton" && t.classList.toggle("has-end-button", l);
926
161
  }
927
162
  render() {
928
- return j`
163
+ return h`
929
164
  <div class="nys-textinput">
930
165
  <nys-label
931
- for=${this.id}
166
+ for=${this.id + "--native"}
932
167
  label=${this.label}
933
168
  description=${this.description}
934
169
  flag=${this.required ? "required" : this.optional ? "optional" : ""}
@@ -948,7 +183,7 @@ const d = (f = class extends at {
948
183
  class="nys-textinput__input"
949
184
  type=${this.type === "password" ? this.showPassword ? "text" : "password" : this.type}
950
185
  name=${this.name}
951
- id=${this.id}
186
+ id=${this.id + "--native"}
952
187
  ?disabled=${this.disabled}
953
188
  ?required=${this.required}
954
189
  ?readonly=${this.readonly}
@@ -956,22 +191,22 @@ const d = (f = class extends at {
956
191
  aria-disabled="${this.disabled}"
957
192
  aria-label="${[this.label, this.description].filter(Boolean).join(" ")}"
958
193
  .value=${this.value}
959
- placeholder=${m(
194
+ placeholder=${d(
960
195
  this.placeholder ? this.placeholder : void 0
961
196
  )}
962
- pattern=${m(this.pattern ? this.pattern : void 0)}
963
- min=${m(this.min !== null ? this.min : void 0)}
964
- maxlength=${m(
197
+ pattern=${d(this.pattern ? this.pattern : void 0)}
198
+ min=${d(this.min !== null ? this.min : void 0)}
199
+ maxlength=${d(
965
200
  this.maxlength !== null ? this.maxlength : void 0
966
201
  )}
967
- step=${m(this.step !== null ? this.step : void 0)}
968
- max=${m(this.max !== null ? this.max : void 0)}
969
- form=${m(this.form || void 0)}
202
+ step=${d(this.step !== null ? this.step : void 0)}
203
+ max=${d(this.max !== null ? this.max : void 0)}
204
+ form=${d(this.form || void 0)}
970
205
  @input=${this._handleInput}
971
206
  @focus="${this._handleFocus}"
972
207
  @blur="${this._handleBlur}"
973
208
  />
974
- ${this.type === "password" ? j` <nys-button
209
+ ${this.type === "password" ? h` <nys-button
975
210
  class="eye-icon"
976
211
  id="password-toggle"
977
212
  suffixIcon="slotted"
@@ -999,7 +234,7 @@ const d = (f = class extends at {
999
234
  </div>
1000
235
  `;
1001
236
  }
1002
- }, f.VALID_TYPES = [
237
+ }, u.styles = c(v), u.VALID_TYPES = [
1003
238
  "email",
1004
239
  "number",
1005
240
  "password",
@@ -1007,79 +242,79 @@ const d = (f = class extends at {
1007
242
  "tel",
1008
243
  "text",
1009
244
  "url"
1010
- ], f.VALID_WIDTHS = ["sm", "md", "lg", "full"], f.styles = xt, f.formAssociated = !0, f);
1011
- c([
1012
- u({ type: String })
1013
- ], d.prototype, "id", 2);
1014
- c([
1015
- u({ type: String, reflect: !0 })
1016
- ], d.prototype, "name", 2);
1017
- c([
1018
- u({ reflect: !0 })
1019
- ], d.prototype, "type", 1);
1020
- c([
1021
- u({ type: String })
1022
- ], d.prototype, "label", 2);
1023
- c([
1024
- u({ type: String })
1025
- ], d.prototype, "description", 2);
1026
- c([
1027
- u({ type: String })
1028
- ], d.prototype, "placeholder", 2);
1029
- c([
1030
- u({ type: String })
1031
- ], d.prototype, "value", 2);
1032
- c([
1033
- u({ type: Boolean, reflect: !0 })
1034
- ], d.prototype, "disabled", 2);
1035
- c([
1036
- u({ type: Boolean, reflect: !0 })
1037
- ], d.prototype, "readonly", 2);
1038
- c([
1039
- u({ type: Boolean, reflect: !0 })
1040
- ], d.prototype, "required", 2);
1041
- c([
1042
- u({ type: Boolean, reflect: !0 })
1043
- ], d.prototype, "optional", 2);
1044
- c([
1045
- u({ type: String })
1046
- ], d.prototype, "_tooltip", 2);
1047
- c([
1048
- u({ type: String, reflect: !0 })
1049
- ], d.prototype, "form", 2);
1050
- c([
1051
- u({ type: String })
1052
- ], d.prototype, "pattern", 2);
1053
- c([
1054
- u({ type: Number })
1055
- ], d.prototype, "maxlength", 2);
1056
- c([
1057
- u({ reflect: !0 })
1058
- ], d.prototype, "width", 2);
1059
- c([
1060
- u({ type: Number })
1061
- ], d.prototype, "step", 2);
1062
- c([
1063
- u({ type: Number })
1064
- ], d.prototype, "min", 2);
1065
- c([
1066
- u({ type: Number })
1067
- ], d.prototype, "max", 2);
1068
- c([
1069
- u({ type: Boolean, reflect: !0 })
1070
- ], d.prototype, "inverted", 2);
1071
- c([
1072
- u({ type: Boolean, reflect: !0 })
1073
- ], d.prototype, "showError", 2);
1074
- c([
1075
- u({ type: String })
1076
- ], d.prototype, "errorMessage", 2);
1077
- c([
1078
- mt()
1079
- ], d.prototype, "showPassword", 2);
1080
- let Ht = d;
1081
- customElements.get("nys-textinput") || customElements.define("nys-textinput", Ht);
245
+ ], u.VALID_WIDTHS = ["sm", "md", "lg", "full"], u.formAssociated = !0, u);
246
+ r([
247
+ o({ type: String, reflect: !0 })
248
+ ], n.prototype, "id", 2);
249
+ r([
250
+ o({ type: String, reflect: !0 })
251
+ ], n.prototype, "name", 2);
252
+ r([
253
+ o({ reflect: !0 })
254
+ ], n.prototype, "type", 1);
255
+ r([
256
+ o({ type: String })
257
+ ], n.prototype, "label", 2);
258
+ r([
259
+ o({ type: String })
260
+ ], n.prototype, "description", 2);
261
+ r([
262
+ o({ type: String })
263
+ ], n.prototype, "placeholder", 2);
264
+ r([
265
+ o({ type: String })
266
+ ], n.prototype, "value", 2);
267
+ r([
268
+ o({ type: Boolean, reflect: !0 })
269
+ ], n.prototype, "disabled", 2);
270
+ r([
271
+ o({ type: Boolean, reflect: !0 })
272
+ ], n.prototype, "readonly", 2);
273
+ r([
274
+ o({ type: Boolean, reflect: !0 })
275
+ ], n.prototype, "required", 2);
276
+ r([
277
+ o({ type: Boolean, reflect: !0 })
278
+ ], n.prototype, "optional", 2);
279
+ r([
280
+ o({ type: String })
281
+ ], n.prototype, "_tooltip", 2);
282
+ r([
283
+ o({ type: String, reflect: !0 })
284
+ ], n.prototype, "form", 2);
285
+ r([
286
+ o({ type: String })
287
+ ], n.prototype, "pattern", 2);
288
+ r([
289
+ o({ type: Number })
290
+ ], n.prototype, "maxlength", 2);
291
+ r([
292
+ o({ reflect: !0 })
293
+ ], n.prototype, "width", 2);
294
+ r([
295
+ o({ type: Number })
296
+ ], n.prototype, "step", 2);
297
+ r([
298
+ o({ type: Number })
299
+ ], n.prototype, "min", 2);
300
+ r([
301
+ o({ type: Number })
302
+ ], n.prototype, "max", 2);
303
+ r([
304
+ o({ type: Boolean, reflect: !0 })
305
+ ], n.prototype, "inverted", 2);
306
+ r([
307
+ o({ type: Boolean, reflect: !0 })
308
+ ], n.prototype, "showError", 2);
309
+ r([
310
+ o({ type: String })
311
+ ], n.prototype, "errorMessage", 2);
312
+ r([
313
+ _()
314
+ ], n.prototype, "showPassword", 2);
315
+ let g = n;
316
+ customElements.get("nys-textinput") || customElements.define("nys-textinput", g);
1082
317
  export {
1083
- Ht as NysTextinput
318
+ g as NysTextinput
1084
319
  };
1085
320
  //# sourceMappingURL=nys-textinput.js.map