@oslokommune/punkt-elements 14.3.0 → 14.4.0

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.
Files changed (53) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/{checkbox-CnhA52o_.js → checkbox-DfVUNTjH.js} +1 -1
  3. package/dist/{checkbox-C0TPnShf.cjs → checkbox-uxeHrTLH.cjs} +1 -1
  4. package/dist/{combobox-C1xwAju5.cjs → combobox-CcyHcqdW.cjs} +13 -13
  5. package/dist/{combobox-Dcp_fHcL.js → combobox-MZsqmVL-.js} +45 -45
  6. package/dist/{datepicker-COIRRau0.cjs → datepicker-BeMs_vsm.cjs} +25 -25
  7. package/dist/{datepicker-Bjb9GK1E.js → datepicker-a2LvhbRb.js} +215 -234
  8. package/dist/index.d.ts +213 -14
  9. package/dist/input-element-CARcDzQB.js +840 -0
  10. package/dist/input-element-CiaV6jln.cjs +1 -0
  11. package/dist/pkt-checkbox.cjs +1 -1
  12. package/dist/pkt-checkbox.js +1 -1
  13. package/dist/pkt-combobox.cjs +1 -1
  14. package/dist/pkt-combobox.js +1 -1
  15. package/dist/pkt-datepicker.cjs +1 -1
  16. package/dist/pkt-datepicker.js +2 -2
  17. package/dist/pkt-header.cjs +1 -1
  18. package/dist/pkt-header.js +1 -1
  19. package/dist/pkt-index.cjs +1 -1
  20. package/dist/pkt-index.js +7 -7
  21. package/dist/pkt-options-controller-DjBCEHU4.cjs +1 -0
  22. package/dist/{pkt-options-controller-CZO1nxZ8.js → pkt-options-controller-zn5cmMvL.js} +3 -3
  23. package/dist/pkt-radiobutton.cjs +1 -1
  24. package/dist/pkt-radiobutton.js +1 -1
  25. package/dist/pkt-select.cjs +1 -1
  26. package/dist/pkt-select.js +1 -1
  27. package/dist/pkt-textarea.cjs +1 -1
  28. package/dist/pkt-textarea.js +1 -1
  29. package/dist/pkt-textinput.cjs +1 -1
  30. package/dist/pkt-textinput.js +1 -1
  31. package/dist/{radiobutton-Caq8-GhM.js → radiobutton-BmgdSpYf.js} +1 -1
  32. package/dist/{radiobutton-BkqaqO5E.cjs → radiobutton-DVe09YxP.cjs} +1 -1
  33. package/dist/select-7KFOnLln.cjs +49 -0
  34. package/dist/select-CKqz-JKZ.js +228 -0
  35. package/dist/{textarea-a6T4aJJU.js → textarea-Bmrv_vve.js} +1 -1
  36. package/dist/{textarea-DyUy8u7X.cjs → textarea-VBUXPS1O.cjs} +1 -1
  37. package/dist/{textinput-IN3b0nSH.cjs → textinput-BkYKotc1.cjs} +1 -1
  38. package/dist/{textinput-DIuM70dd.js → textinput-Lp1crOmj.js} +1 -1
  39. package/package.json +2 -2
  40. package/src/components/checkbox/checkbox.ts +1 -1
  41. package/src/components/combobox/combobox.ts +2 -2
  42. package/src/components/datepicker/datepicker-utils.test.ts +0 -25
  43. package/src/components/datepicker/datepicker-utils.ts +0 -28
  44. package/src/components/datepicker/datepicker.ts +0 -6
  45. package/src/components/radiobutton/radiobutton.ts +1 -1
  46. package/src/components/select/select.ts +12 -47
  47. package/src/components/textarea/textarea.ts +1 -1
  48. package/src/components/textinput/textinput.ts +1 -1
  49. package/dist/input-element-B8M8Nppd.js +0 -708
  50. package/dist/input-element-D697OAJo.cjs +0 -1
  51. package/dist/pkt-options-controller-CiuBG6Lt.cjs +0 -1
  52. package/dist/select-3dwlk22G.cjs +0 -49
  53. package/dist/select-_C-yztI0.js +0 -173
@@ -0,0 +1,840 @@
1
+ import { P as Ft, t as g, n as c } from "./element-CRDRygXu.js";
2
+ import { r as Tt } from "./state-DS_kr2Fy.js";
3
+ import { u as xt } from "./utils-DznhwRXm.js";
4
+ import { b as It } from "./booleanish-C9R0tdXH.js";
5
+ import { s as Rt } from "./input-wrapper-CDgenrYA.js";
6
+ var ct = {}, dt;
7
+ function Lt() {
8
+ return dt || (dt = 1, (function() {
9
+ (function(p) {
10
+ const a = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), f = /* @__PURE__ */ new WeakMap(), u = /* @__PURE__ */ new WeakMap(), w = /* @__PURE__ */ new WeakMap(), V = /* @__PURE__ */ new WeakMap(), A = /* @__PURE__ */ new WeakMap(), v = /* @__PURE__ */ new WeakMap(), S = /* @__PURE__ */ new WeakMap(), C = /* @__PURE__ */ new WeakMap(), F = /* @__PURE__ */ new WeakMap(), T = /* @__PURE__ */ new WeakMap(), K = /* @__PURE__ */ new WeakMap(), j = /* @__PURE__ */ new WeakMap(), I = /* @__PURE__ */ new WeakMap(), R = {
11
+ ariaAtomic: "aria-atomic",
12
+ ariaAutoComplete: "aria-autocomplete",
13
+ ariaBusy: "aria-busy",
14
+ ariaChecked: "aria-checked",
15
+ ariaColCount: "aria-colcount",
16
+ ariaColIndex: "aria-colindex",
17
+ ariaColIndexText: "aria-colindextext",
18
+ ariaColSpan: "aria-colspan",
19
+ ariaCurrent: "aria-current",
20
+ ariaDescription: "aria-description",
21
+ ariaDisabled: "aria-disabled",
22
+ ariaExpanded: "aria-expanded",
23
+ ariaHasPopup: "aria-haspopup",
24
+ ariaHidden: "aria-hidden",
25
+ ariaInvalid: "aria-invalid",
26
+ ariaKeyShortcuts: "aria-keyshortcuts",
27
+ ariaLabel: "aria-label",
28
+ ariaLevel: "aria-level",
29
+ ariaLive: "aria-live",
30
+ ariaModal: "aria-modal",
31
+ ariaMultiLine: "aria-multiline",
32
+ ariaMultiSelectable: "aria-multiselectable",
33
+ ariaOrientation: "aria-orientation",
34
+ ariaPlaceholder: "aria-placeholder",
35
+ ariaPosInSet: "aria-posinset",
36
+ ariaPressed: "aria-pressed",
37
+ ariaReadOnly: "aria-readonly",
38
+ ariaRelevant: "aria-relevant",
39
+ ariaRequired: "aria-required",
40
+ ariaRoleDescription: "aria-roledescription",
41
+ ariaRowCount: "aria-rowcount",
42
+ ariaRowIndex: "aria-rowindex",
43
+ ariaRowIndexText: "aria-rowindextext",
44
+ ariaRowSpan: "aria-rowspan",
45
+ ariaSelected: "aria-selected",
46
+ ariaSetSize: "aria-setsize",
47
+ ariaSort: "aria-sort",
48
+ ariaValueMax: "aria-valuemax",
49
+ ariaValueMin: "aria-valuemin",
50
+ ariaValueNow: "aria-valuenow",
51
+ ariaValueText: "aria-valuetext",
52
+ role: "role"
53
+ }, ut = (e, t) => {
54
+ for (let i in R) {
55
+ t[i] = null;
56
+ let s = null;
57
+ const n = R[i];
58
+ Object.defineProperty(t, i, {
59
+ get() {
60
+ return s;
61
+ },
62
+ set(d) {
63
+ s = d, e.isConnected ? k(e, n, d) : C.set(e, t);
64
+ }
65
+ });
66
+ }
67
+ };
68
+ function G(e) {
69
+ const t = u.get(e), { form: i } = t;
70
+ tt(e, i, t), Z(e, t.labels);
71
+ }
72
+ const J = (e, t = !1) => {
73
+ const i = document.createTreeWalker(e, NodeFilter.SHOW_ELEMENT, {
74
+ acceptNode(d) {
75
+ return u.has(d) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
76
+ }
77
+ });
78
+ let s = i.nextNode();
79
+ const n = !t || e.disabled;
80
+ for (; s; )
81
+ s.formDisabledCallback && n && H(s, e.disabled), s = i.nextNode();
82
+ }, Q = { attributes: !0, attributeFilter: ["disabled", "name"] }, L = D() ? new MutationObserver((e) => {
83
+ for (const t of e) {
84
+ const i = t.target;
85
+ if (t.attributeName === "disabled" && (i.constructor.formAssociated ? H(i, i.hasAttribute("disabled")) : i.localName === "fieldset" && J(i)), t.attributeName === "name" && i.constructor.formAssociated) {
86
+ const s = u.get(i), n = S.get(i);
87
+ s.setFormValue(n);
88
+ }
89
+ }
90
+ }) : {};
91
+ function B(e) {
92
+ e.forEach((t) => {
93
+ const { addedNodes: i, removedNodes: s } = t, n = Array.from(i), d = Array.from(s);
94
+ n.forEach((h) => {
95
+ var y;
96
+ if (u.has(h) && h.constructor.formAssociated && G(h), C.has(h)) {
97
+ const m = C.get(h);
98
+ Object.keys(R).filter((b) => m[b] !== null).forEach((b) => {
99
+ k(h, R[b], m[b]);
100
+ }), C.delete(h);
101
+ }
102
+ if (I.has(h)) {
103
+ const m = I.get(h);
104
+ k(h, "internals-valid", m.validity.valid.toString()), k(h, "internals-invalid", (!m.validity.valid).toString()), k(h, "aria-invalid", (!m.validity.valid).toString()), I.delete(h);
105
+ }
106
+ if (h.localName === "form") {
107
+ const m = v.get(h), M = document.createTreeWalker(h, NodeFilter.SHOW_ELEMENT, {
108
+ acceptNode(U) {
109
+ return u.has(U) && U.constructor.formAssociated && !(m && m.has(U)) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
110
+ }
111
+ });
112
+ let b = M.nextNode();
113
+ for (; b; )
114
+ G(b), b = M.nextNode();
115
+ }
116
+ h.localName === "fieldset" && ((y = L.observe) === null || y === void 0 || y.call(L, h, Q), J(h, !0));
117
+ }), d.forEach((h) => {
118
+ const y = u.get(h);
119
+ y && f.get(y) && X(y), A.has(h) && A.get(h).disconnect();
120
+ });
121
+ });
122
+ }
123
+ function ft(e) {
124
+ e.forEach((t) => {
125
+ const { removedNodes: i } = t;
126
+ i.forEach((s) => {
127
+ const n = K.get(t.target);
128
+ u.has(s) && it(s), n.disconnect();
129
+ });
130
+ });
131
+ }
132
+ const pt = (e) => {
133
+ var t, i;
134
+ const s = new MutationObserver(ft);
135
+ !((t = window == null ? void 0 : window.ShadyDOM) === null || t === void 0) && t.inUse && e.mode && e.host && (e = e.host), (i = s.observe) === null || i === void 0 || i.call(s, e, { childList: !0 }), K.set(e, s);
136
+ };
137
+ D() && new MutationObserver(B);
138
+ const _ = {
139
+ childList: !0,
140
+ subtree: !0
141
+ }, k = (e, t, i) => {
142
+ e.getAttribute(t) !== i && e.setAttribute(t, i);
143
+ }, H = (e, t) => {
144
+ e.toggleAttribute("internals-disabled", t), t ? k(e, "aria-disabled", "true") : e.removeAttribute("aria-disabled"), e.formDisabledCallback && e.formDisabledCallback.apply(e, [t]);
145
+ }, X = (e) => {
146
+ f.get(e).forEach((i) => {
147
+ i.remove();
148
+ }), f.set(e, []);
149
+ }, Y = (e, t) => {
150
+ const i = document.createElement("input");
151
+ return i.type = "hidden", i.name = e.getAttribute("name"), e.after(i), f.get(t).push(i), i;
152
+ }, mt = (e, t) => {
153
+ var i;
154
+ f.set(t, []), (i = L.observe) === null || i === void 0 || i.call(L, e, Q);
155
+ }, Z = (e, t) => {
156
+ if (t.length) {
157
+ Array.from(t).forEach((s) => s.addEventListener("click", e.click.bind(e)));
158
+ let i = t[0].id;
159
+ t[0].id || (i = `${t[0].htmlFor}_Label`, t[0].id = i), k(e, "aria-labelledby", i);
160
+ }
161
+ }, N = (e) => {
162
+ const t = Array.from(e.elements).filter((d) => !d.tagName.includes("-") && d.validity).map((d) => d.validity.valid), i = v.get(e) || [], s = Array.from(i).filter((d) => d.isConnected).map((d) => u.get(d).validity.valid), n = [...t, ...s].includes(!1);
163
+ e.toggleAttribute("internals-invalid", n), e.toggleAttribute("internals-valid", !n);
164
+ }, yt = (e) => {
165
+ N(O(e.target));
166
+ }, gt = (e) => {
167
+ N(O(e.target));
168
+ }, vt = (e) => {
169
+ const t = ["button[type=submit]", "input[type=submit]", "button:not([type])"].map((i) => `${i}:not([disabled])`).map((i) => `${i}:not([form])${e.id ? `,${i}[form='${e.id}']` : ""}`).join(",");
170
+ e.addEventListener("click", (i) => {
171
+ if (i.target.closest(t)) {
172
+ const n = v.get(e);
173
+ if (e.noValidate)
174
+ return;
175
+ n.size && Array.from(n).reverse().map((y) => u.get(y).reportValidity()).includes(!1) && i.preventDefault();
176
+ }
177
+ });
178
+ }, bt = (e) => {
179
+ const t = v.get(e.target);
180
+ t && t.size && t.forEach((i) => {
181
+ i.constructor.formAssociated && i.formResetCallback && i.formResetCallback.apply(i);
182
+ });
183
+ }, tt = (e, t, i) => {
184
+ if (t) {
185
+ const s = v.get(t);
186
+ if (s)
187
+ s.add(e);
188
+ else {
189
+ const n = /* @__PURE__ */ new Set();
190
+ n.add(e), v.set(t, n), vt(t), t.addEventListener("reset", bt), t.addEventListener("input", yt), t.addEventListener("change", gt);
191
+ }
192
+ V.set(t, { ref: e, internals: i }), e.constructor.formAssociated && e.formAssociatedCallback && setTimeout(() => {
193
+ e.formAssociatedCallback.apply(e, [t]);
194
+ }, 0), N(t);
195
+ }
196
+ }, O = (e) => {
197
+ let t = e.parentNode;
198
+ return t && t.tagName !== "FORM" && (t = O(t)), t;
199
+ }, E = (e, t, i = DOMException) => {
200
+ if (!e.constructor.formAssociated)
201
+ throw new i(t);
202
+ }, et = (e, t, i) => {
203
+ const s = v.get(e);
204
+ return s && s.size && s.forEach((n) => {
205
+ u.get(n)[i]() || (t = !1);
206
+ }), t;
207
+ }, it = (e) => {
208
+ if (e.constructor.formAssociated) {
209
+ const t = u.get(e), { labels: i, form: s } = t;
210
+ Z(e, i), tt(e, s, t);
211
+ }
212
+ };
213
+ function D() {
214
+ return typeof MutationObserver < "u";
215
+ }
216
+ class wt {
217
+ constructor() {
218
+ this.badInput = !1, this.customError = !1, this.patternMismatch = !1, this.rangeOverflow = !1, this.rangeUnderflow = !1, this.stepMismatch = !1, this.tooLong = !1, this.tooShort = !1, this.typeMismatch = !1, this.valid = !0, this.valueMissing = !1, Object.seal(this);
219
+ }
220
+ }
221
+ const Et = (e) => (e.badInput = !1, e.customError = !1, e.patternMismatch = !1, e.rangeOverflow = !1, e.rangeUnderflow = !1, e.stepMismatch = !1, e.tooLong = !1, e.tooShort = !1, e.typeMismatch = !1, e.valid = !0, e.valueMissing = !1, e), Mt = (e, t, i) => (e.valid = kt(t), Object.keys(t).forEach((s) => e[s] = t[s]), i && N(i), e), kt = (e) => {
222
+ let t = !0;
223
+ for (let i in e)
224
+ i !== "valid" && e[i] !== !1 && (t = !1);
225
+ return t;
226
+ }, W = /* @__PURE__ */ new WeakMap();
227
+ function at(e, t) {
228
+ e.toggleAttribute(t, !0), e.part && e.part.add(t);
229
+ }
230
+ class q extends Set {
231
+ static get isPolyfilled() {
232
+ return !0;
233
+ }
234
+ constructor(t) {
235
+ if (super(), !t || !t.tagName || t.tagName.indexOf("-") === -1)
236
+ throw new TypeError("Illegal constructor");
237
+ W.set(this, t);
238
+ }
239
+ add(t) {
240
+ if (!/^--/.test(t) || typeof t != "string")
241
+ throw new DOMException(`Failed to execute 'add' on 'CustomStateSet': The specified value ${t} must start with '--'.`);
242
+ const i = super.add(t), s = W.get(this), n = `state${t}`;
243
+ return s.isConnected ? at(s, n) : setTimeout(() => {
244
+ at(s, n);
245
+ }), i;
246
+ }
247
+ clear() {
248
+ for (let [t] of this.entries())
249
+ this.delete(t);
250
+ super.clear();
251
+ }
252
+ delete(t) {
253
+ const i = super.delete(t), s = W.get(this);
254
+ return s.isConnected ? (s.toggleAttribute(`state${t}`, !1), s.part && s.part.remove(`state${t}`)) : setTimeout(() => {
255
+ s.toggleAttribute(`state${t}`, !1), s.part && s.part.remove(`state${t}`);
256
+ }), i;
257
+ }
258
+ }
259
+ function st(e, t, i, s) {
260
+ if (typeof t == "function" ? e !== t || !s : !t.has(e)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
261
+ return i === "m" ? s : i === "a" ? s.call(e) : s ? s.value : t.get(e);
262
+ }
263
+ function Vt(e, t, i, s, n) {
264
+ if (typeof t == "function" ? e !== t || !0 : !t.has(e)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
265
+ return t.set(e, i), i;
266
+ }
267
+ var x;
268
+ class Ct {
269
+ constructor(t) {
270
+ x.set(this, void 0), Vt(this, x, t);
271
+ for (let i = 0; i < t.length; i++) {
272
+ let s = t[i];
273
+ this[i] = s, s.hasAttribute("name") && (this[s.getAttribute("name")] = s);
274
+ }
275
+ Object.freeze(this);
276
+ }
277
+ get length() {
278
+ return st(this, x, "f").length;
279
+ }
280
+ [(x = /* @__PURE__ */ new WeakMap(), Symbol.iterator)]() {
281
+ return st(this, x, "f")[Symbol.iterator]();
282
+ }
283
+ item(t) {
284
+ return this[t] == null ? null : this[t];
285
+ }
286
+ namedItem(t) {
287
+ return this[t] == null ? null : this[t];
288
+ }
289
+ }
290
+ function At() {
291
+ const e = HTMLFormElement.prototype.checkValidity;
292
+ HTMLFormElement.prototype.checkValidity = i;
293
+ const t = HTMLFormElement.prototype.reportValidity;
294
+ HTMLFormElement.prototype.reportValidity = s;
295
+ function i(...d) {
296
+ let h = e.apply(this, d);
297
+ return et(this, h, "checkValidity");
298
+ }
299
+ function s(...d) {
300
+ let h = t.apply(this, d);
301
+ return et(this, h, "reportValidity");
302
+ }
303
+ const { get: n } = Object.getOwnPropertyDescriptor(HTMLFormElement.prototype, "elements");
304
+ Object.defineProperty(HTMLFormElement.prototype, "elements", {
305
+ get(...d) {
306
+ const h = n.call(this, ...d), y = Array.from(v.get(this) || []);
307
+ if (y.length === 0)
308
+ return h;
309
+ const m = Array.from(h).concat(y).sort((M, b) => M.compareDocumentPosition ? M.compareDocumentPosition(b) & 2 ? 1 : -1 : 0);
310
+ return new Ct(m);
311
+ }
312
+ });
313
+ }
314
+ class rt {
315
+ static get isPolyfilled() {
316
+ return !0;
317
+ }
318
+ constructor(t) {
319
+ if (!t || !t.tagName || t.tagName.indexOf("-") === -1)
320
+ throw new TypeError("Illegal constructor");
321
+ const i = t.getRootNode(), s = new wt();
322
+ this.states = new q(t), a.set(this, t), r.set(this, s), u.set(t, this), ut(t, this), mt(t, this), Object.seal(this), i instanceof DocumentFragment && pt(i);
323
+ }
324
+ checkValidity() {
325
+ const t = a.get(this);
326
+ if (E(t, "Failed to execute 'checkValidity' on 'ElementInternals': The target element is not a form-associated custom element."), !this.willValidate)
327
+ return !0;
328
+ const i = r.get(this);
329
+ if (!i.valid) {
330
+ const s = new Event("invalid", {
331
+ bubbles: !1,
332
+ cancelable: !0,
333
+ composed: !1
334
+ });
335
+ t.dispatchEvent(s);
336
+ }
337
+ return i.valid;
338
+ }
339
+ get form() {
340
+ const t = a.get(this);
341
+ E(t, "Failed to read the 'form' property from 'ElementInternals': The target element is not a form-associated custom element.");
342
+ let i;
343
+ return t.constructor.formAssociated === !0 && (i = O(t)), i;
344
+ }
345
+ get labels() {
346
+ const t = a.get(this);
347
+ E(t, "Failed to read the 'labels' property from 'ElementInternals': The target element is not a form-associated custom element.");
348
+ const i = t.getAttribute("id"), s = t.getRootNode();
349
+ return s && i ? s.querySelectorAll(`[for="${i}"]`) : [];
350
+ }
351
+ reportValidity() {
352
+ const t = a.get(this);
353
+ if (E(t, "Failed to execute 'reportValidity' on 'ElementInternals': The target element is not a form-associated custom element."), !this.willValidate)
354
+ return !0;
355
+ const i = this.checkValidity(), s = T.get(this);
356
+ if (s && !t.constructor.formAssociated)
357
+ throw new DOMException("Failed to execute 'reportValidity' on 'ElementInternals': The target element is not a form-associated custom element.");
358
+ return !i && s && (t.focus(), s.focus()), i;
359
+ }
360
+ setFormValue(t) {
361
+ const i = a.get(this);
362
+ if (E(i, "Failed to execute 'setFormValue' on 'ElementInternals': The target element is not a form-associated custom element."), X(this), t != null && !(t instanceof FormData)) {
363
+ if (i.getAttribute("name")) {
364
+ const s = Y(i, this);
365
+ s.value = t;
366
+ }
367
+ } else t != null && t instanceof FormData && Array.from(t).reverse().forEach(([s, n]) => {
368
+ if (typeof n == "string") {
369
+ const d = Y(i, this);
370
+ d.name = s, d.value = n;
371
+ }
372
+ });
373
+ S.set(i, t);
374
+ }
375
+ setValidity(t, i, s) {
376
+ const n = a.get(this);
377
+ if (E(n, "Failed to execute 'setValidity' on 'ElementInternals': The target element is not a form-associated custom element."), !t)
378
+ throw new TypeError("Failed to execute 'setValidity' on 'ElementInternals': 1 argument required, but only 0 present.");
379
+ T.set(this, s);
380
+ const d = r.get(this), h = {};
381
+ for (const M in t)
382
+ h[M] = t[M];
383
+ Object.keys(h).length === 0 && Et(d);
384
+ const y = Object.assign(Object.assign({}, d), h);
385
+ delete y.valid;
386
+ const { valid: m } = Mt(d, y, this.form);
387
+ if (!m && !i)
388
+ throw new DOMException("Failed to execute 'setValidity' on 'ElementInternals': The second argument should not be empty if one or more flags in the first argument are true.");
389
+ w.set(this, m ? "" : i), n.isConnected ? (n.toggleAttribute("internals-invalid", !m), n.toggleAttribute("internals-valid", m), k(n, "aria-invalid", `${!m}`)) : I.set(n, this);
390
+ }
391
+ get shadowRoot() {
392
+ const t = a.get(this), i = F.get(t);
393
+ return i || null;
394
+ }
395
+ get validationMessage() {
396
+ const t = a.get(this);
397
+ return E(t, "Failed to read the 'validationMessage' property from 'ElementInternals': The target element is not a form-associated custom element."), w.get(this);
398
+ }
399
+ get validity() {
400
+ const t = a.get(this);
401
+ return E(t, "Failed to read the 'validity' property from 'ElementInternals': The target element is not a form-associated custom element."), r.get(this);
402
+ }
403
+ get willValidate() {
404
+ const t = a.get(this);
405
+ return E(t, "Failed to read the 'willValidate' property from 'ElementInternals': The target element is not a form-associated custom element."), !(t.disabled || t.hasAttribute("disabled") || t.hasAttribute("readonly"));
406
+ }
407
+ }
408
+ function St() {
409
+ if (typeof window > "u" || !window.ElementInternals || !HTMLElement.prototype.attachInternals)
410
+ return !1;
411
+ class e extends HTMLElement {
412
+ constructor() {
413
+ super(), this.internals = this.attachInternals();
414
+ }
415
+ }
416
+ const t = `element-internals-feature-detection-${Math.random().toString(36).replace(/[^a-z]+/g, "")}`;
417
+ customElements.define(t, e);
418
+ const i = new e();
419
+ return [
420
+ "shadowRoot",
421
+ "form",
422
+ "willValidate",
423
+ "validity",
424
+ "validationMessage",
425
+ "labels",
426
+ "setFormValue",
427
+ "setValidity",
428
+ "checkValidity",
429
+ "reportValidity"
430
+ ].every((s) => s in i.internals);
431
+ }
432
+ let nt = !1, ot = !1;
433
+ function $(e) {
434
+ ot || (ot = !0, window.CustomStateSet = q, e && (HTMLElement.prototype.attachInternals = function(...t) {
435
+ const i = e.call(this, t);
436
+ return i.states = new q(this), i;
437
+ }));
438
+ }
439
+ function lt(e = !0) {
440
+ if (!nt) {
441
+ if (nt = !0, typeof window < "u" && (window.ElementInternals = rt), typeof CustomElementRegistry < "u") {
442
+ const t = CustomElementRegistry.prototype.define;
443
+ CustomElementRegistry.prototype.define = function(i, s, n) {
444
+ if (s.formAssociated) {
445
+ const d = s.prototype.connectedCallback;
446
+ s.prototype.connectedCallback = function() {
447
+ j.has(this) || (j.set(this, !0), this.hasAttribute("disabled") && H(this, !0)), d != null && d.apply(this), it(this);
448
+ };
449
+ }
450
+ t.call(this, i, s, n);
451
+ };
452
+ }
453
+ if (typeof HTMLElement < "u" && (HTMLElement.prototype.attachInternals = function() {
454
+ if (this.tagName) {
455
+ if (this.tagName.indexOf("-") === -1)
456
+ throw new Error("Failed to execute 'attachInternals' on 'HTMLElement': Unable to attach ElementInternals to non-custom elements.");
457
+ } else return {};
458
+ if (u.has(this))
459
+ throw new DOMException("DOMException: Failed to execute 'attachInternals' on 'HTMLElement': ElementInternals for the specified element was already attached.");
460
+ return new rt(this);
461
+ }), typeof Element < "u") {
462
+ let t = function(...s) {
463
+ const n = i.apply(this, s);
464
+ if (F.set(this, n), D()) {
465
+ const d = new MutationObserver(B);
466
+ window.ShadyDOM ? d.observe(this, _) : d.observe(n, _), A.set(this, d);
467
+ }
468
+ return n;
469
+ };
470
+ const i = Element.prototype.attachShadow;
471
+ Element.prototype.attachShadow = t;
472
+ }
473
+ D() && typeof document < "u" && new MutationObserver(B).observe(document.documentElement, _), typeof HTMLFormElement < "u" && At(), (e || typeof window < "u" && !window.CustomStateSet) && $();
474
+ }
475
+ }
476
+ return !!customElements.polyfillWrapFlushCallback || (St() ? typeof window < "u" && !window.CustomStateSet && $(HTMLElement.prototype.attachInternals) : lt(!1)), p.forceCustomStateSetPolyfill = $, p.forceElementInternalsPolyfill = lt, Object.defineProperty(p, "__esModule", { value: !0 }), p;
477
+ })({});
478
+ })()), ct;
479
+ }
480
+ Lt();
481
+ var Nt = Object.defineProperty, o = (p, a, r, f) => {
482
+ for (var u = void 0, w = p.length - 1, V; w >= 0; w--)
483
+ (V = p[w]) && (u = V(a, r, u) || u);
484
+ return u && Nt(a, r, u), u;
485
+ };
486
+ const ht = "on", z = "--checked", P = ",";
487
+ class l extends Ft {
488
+ constructor() {
489
+ super(), this.defaultValue = null, this.disabled = !1, this.readonly = !1, this.required = !1, this.max = null, this.maxlength = null, this.min = null, this.minlength = null, this.step = null, this.ariaDescribedBy = null, this.ariaLabelledby = null, this.name = "", this.pattern = null, this.placeholder = null, this.id = xt(), this.counter = !1, this.hasError = !1, this.inline = !1, this.hasFieldset = !1, this.optionalTag = !1, this.requiredTag = !1, this.skipForwardTestid = !1, this.useWrapper = !0, this.fullwidth = !1, this.counterMaxLength = 0, this.errorMessage = "", this.helptext = "", this.helptextDropdown = "", this.helptextDropdownButton = Rt.props.helptextDropdownButton.default, this.label = null, this.optionalText = g.forms.labels.optional, this.requiredText = g.forms.labels.required, this.tagText = null, this.dataTestid = "", this.touched = !1, this.internals = this.attachInternals();
490
+ }
491
+ static get formAssociated() {
492
+ return !0;
493
+ }
494
+ /**
495
+ * Manages form validation state based on input validity
496
+ * Called automatically by onChange, but can be called manually if needed
497
+ *
498
+ * @param input - The input element to validate (optional)
499
+ * @protected
500
+ */
501
+ manageValidity(a) {
502
+ var r, f, u, w, V, A, v, S, C, F, T;
503
+ if (!a) {
504
+ console.warn("manageValidity called without valid input element");
505
+ return;
506
+ }
507
+ this.required && !this.value ? this.internals.setValidity({ valueMissing: !0 }, g.forms.messages.required, a) : (r = a.validity) != null && r.typeMismatch || (f = a.validity) != null && f.badInput ? this.internals.setValidity({ typeMismatch: !0 }, g.forms.messages.invalid, a) : (u = a.validity) != null && u.patternMismatch ? this.internals.setValidity(
508
+ { patternMismatch: !0 },
509
+ g.forms.messages.invalidPattern,
510
+ a
511
+ ) : (w = a.validity) != null && w.tooShort || this.minlength && this.minlength > 0 && this.value.length < this.minlength ? this.internals.setValidity({ tooShort: !0 }, g.forms.messages.tooShort, a) : (V = a.validity) != null && V.tooLong || this.maxlength && this.maxlength > 0 && this.value.length > this.maxlength ? this.internals.setValidity({ tooLong: !0 }, g.forms.messages.tooLong, a) : (A = a.validity) != null && A.rangeUnderflow ? this.internals.setValidity(
512
+ { rangeUnderflow: !0 },
513
+ this.min ? g.forms.messages.rangeUnderflowMin.replace("{min}", (v = this.min) == null ? void 0 : v.toString()) : g.forms.messages.rangeUnderflow,
514
+ a
515
+ ) : (S = a.validity) != null && S.stepMismatch ? this.internals.setValidity({ stepMismatch: !0 }, g.forms.messages.invalid, a) : (C = a.validity) != null && C.rangeOverflow ? this.internals.setValidity(
516
+ { rangeOverflow: !0 },
517
+ this.max ? g.forms.messages.rangeOverflowMax.replace("{max}", (F = this.max) == null ? void 0 : F.toString()) : g.forms.messages.rangeOverflow,
518
+ a
519
+ ) : (T = a.validity) != null && T.customError ? this.internals.setValidity({ customError: !0 }, a.validationMessage, a) : this.internals.setValidity({});
520
+ }
521
+ /**
522
+ * Updates the form value for this input
523
+ * Handles both single values and arrays (for multi-select)
524
+ *
525
+ * @param value - The value(s) to set in the form
526
+ * @protected
527
+ */
528
+ setFormValue(a) {
529
+ if (this.internals)
530
+ if (Array.isArray(a)) {
531
+ const r = new FormData();
532
+ a.forEach((f) => {
533
+ r.append(this.name, f);
534
+ }), this.internals.setFormValue(r);
535
+ } else
536
+ this.internals.setFormValue(a);
537
+ }
538
+ /**
539
+ * Coordinates radio button group by unchecking other radios with the same name
540
+ * Only affects radio inputs within the same form
541
+ *
542
+ * @protected
543
+ */
544
+ coordinateRadioGroup() {
545
+ if (!this.form || !this.name || this.type !== "radio") return;
546
+ const a = `pkt-radiobutton[name="${this.name}"], input[type=radio][name="${this.name}"]`;
547
+ this.form.querySelectorAll(a).forEach((r) => {
548
+ var f;
549
+ if (r !== this && r.getAttribute("name") === this.name && r.getAttribute("value") !== this.value) {
550
+ const u = r;
551
+ u.checked && (u.checked = !1, u.internals && (u.internals.setFormValue(null), (f = u.internals.states) == null || f.delete(z)));
552
+ }
553
+ });
554
+ }
555
+ /**
556
+ * Updates checked state and form value for checkbox and radio inputs
557
+ * Triggers this when you want to set the value of the radio or checkbox input to the form
558
+ * Do not use valueChanged or onChange for radios and checkboxes!
559
+ *
560
+ * @param value - The checked state (string 'true'/'false', or boolean)
561
+ * @protected
562
+ */
563
+ valueChecked(a) {
564
+ if (!this.touched) return;
565
+ const r = this.internals.form || this.closest("form"), f = r ? new FormData(r) : null;
566
+ if (this.type === "radio" && this.coordinateRadioGroup(), typeof a == "string" ? (this.checked = a === "true", this.internals.ariaChecked = String(a === "true")) : typeof a == "boolean" && (this.checked = a, this.internals.ariaChecked = String(a)), this.checked) {
567
+ const u = (typeof this.value == "string" ? this.value : "") || ht;
568
+ this.internals.setFormValue(u), f && f.append(this.name, u), this.internals.states.add(z);
569
+ } else
570
+ this.internals.setFormValue(null), f && f.delete(this.name), this.internals.states.delete(z);
571
+ this.dispatchChangeEvents(this.checked), this.internals.reportValidity();
572
+ }
573
+ /**
574
+ * Called when value changes (text inputs, select, etc.)
575
+ * Subclasses can override to add custom value transformation logic
576
+ *
577
+ * @param value - The new value
578
+ * @param _old - The previous value
579
+ * @protected
580
+ * @example
581
+ * ```typescript
582
+ * protected valueChanged(value: string, old: string): void {
583
+ * const transformed = this.transformValue(value)
584
+ * super.valueChanged(transformed, old)
585
+ * }
586
+ * ```
587
+ */
588
+ valueChanged(a, r) {
589
+ (r !== this.value || r !== this._value) && (typeof a == "string" ? ((this.multiple || this.range) && a.includes(P) && (a = a.split(P)), this.value = a, this._value = Array.isArray(a) ? a : [a]) : Array.isArray(a) ? (this.value = this.multiple || this.range ? a : a[0], this._value = a) : (this.value = "", this._value = []), (!this.value || this.value.length === 0) && r && r.length !== 0 ? this.clearInputValue() : this.value && this.value.toString() !== (r == null ? void 0 : r.toString()) && this.onChange(this.value), this.updateComplete.then(() => this.requestUpdate()));
590
+ }
591
+ /**
592
+ * Dispatches change and value-change events
593
+ *
594
+ * @param value - The value to include in the event detail
595
+ * @protected
596
+ */
597
+ dispatchChangeEvents(a) {
598
+ this.dispatchEvent(new Event("change", { bubbles: !0, composed: !0 })), this.dispatchEvent(
599
+ new CustomEvent("value-change", {
600
+ detail: a,
601
+ bubbles: !0,
602
+ composed: !0
603
+ })
604
+ );
605
+ }
606
+ /**
607
+ * When input goes from content to no content
608
+ * @protected
609
+ */
610
+ clearInputValue() {
611
+ const a = this.multiple || this.range ? [] : "";
612
+ this.value = a, this.setFormValue(a), this.dispatchChangeEvents(a);
613
+ }
614
+ /**
615
+ * When user enters the input, dispatch focus event
616
+ * @protected
617
+ */
618
+ onFocus() {
619
+ this.dispatchEvent(new FocusEvent("focus", { bubbles: !0, composed: !0 }));
620
+ }
621
+ /**
622
+ * When user leaves the input, dispatch blur event
623
+ * @protected
624
+ */
625
+ onBlur() {
626
+ this.dispatchEvent(new FocusEvent("blur", { bubbles: !0, composed: !0 }));
627
+ }
628
+ /**
629
+ * Trigger this when user types in the input
630
+ * @protected
631
+ */
632
+ onInput() {
633
+ this.dispatchEvent(new InputEvent("input", { bubbles: !0, composed: !0 }));
634
+ }
635
+ /**
636
+ * Normalizes value format based on multiple/range settings
637
+ *
638
+ * @param value - The value to normalize
639
+ * @returns Normalized value (array if multiple/range, string otherwise)
640
+ * @private
641
+ */
642
+ normalizeValue(a) {
643
+ return (this.range || this.multiple) && typeof a == "string" && a.includes(P) ? a.split(P) : !this.multiple && !this.range && Array.isArray(a) ? a[0] || "" : a;
644
+ }
645
+ /**
646
+ * Validates the input element(s)
647
+ * @private
648
+ */
649
+ validate() {
650
+ var a, r;
651
+ (a = this.inputRef) != null && a.value && this.manageValidity(this.inputRef.value), (r = this.inputRefTo) != null && r.value && this.manageValidity(this.inputRefTo.value);
652
+ }
653
+ /**
654
+ * Trigger this when you want to set the value of the input out to the form
655
+ * Handles value normalization, form updates, validation, and event dispatching
656
+ *
657
+ * @param value - The value to set
658
+ * @protected
659
+ */
660
+ onChange(a) {
661
+ if (!this.touched) {
662
+ this.touched = !0, a && this.setFormValue(a);
663
+ return;
664
+ }
665
+ if (typeof a != "string" && !Array.isArray(a))
666
+ return;
667
+ const r = this.normalizeValue(a);
668
+ this.setFormValue(r), this.validate(), this.dispatchChangeEvents(r);
669
+ }
670
+ /**
671
+ * Called when the form is reset
672
+ * Resets the input to its default state
673
+ * @protected
674
+ */
675
+ formResetCallback() {
676
+ var a;
677
+ if (this.touched = !1, this._options && this._options.length && this._options.forEach((r) => {
678
+ "selected" in r && (r.selected = !1);
679
+ }), this.checked !== void 0)
680
+ this.checked = !1, this.internals.ariaChecked = "false", this.internals.setFormValue(""), (a = this.inputRef) != null && a.value && "checked" in this.inputRef.value && (this.inputRef.value.checked = !1), this.valueChecked(this.checked);
681
+ else {
682
+ this.internals.setFormValue("");
683
+ const r = this.defaultValue || (this.multiple || this.range ? [] : "");
684
+ this.value = r, this._value = Array.isArray(r) ? r : [r], this.valueChanged(this.value, null);
685
+ }
686
+ this.internals.ariaInvalid = "false";
687
+ }
688
+ updated(a) {
689
+ super.updated(a), a.has("dataTestid") && this.dataTestid && this.inputRef.value && (this.skipForwardTestid ? this.hasAttribute("data-testid") || this.setAttribute("data-testid", this.dataTestid) : (this.inputRef.value.dataset.testid = this.dataTestid, this.removeAttribute("data-testid")));
690
+ }
691
+ firstUpdated(a) {
692
+ if (super.firstUpdated(a), !this.form) {
693
+ const r = this.internals.form || this.closest("form");
694
+ this.form = r;
695
+ }
696
+ if (this.value && this.defaultValue !== null && (this.defaultValue = this.value), this.defaultValue !== null && !this.value && this.valueChanged(this.defaultValue, null), this.defaultChecked && (this.internals.ariaChecked = "true", this.checked = !0), this.required && (this.internals.ariaRequired = "true"), this.disabled && (this.internals.ariaDisabled = "true"), this.id && !this.name && (this.name = this.id), this.checked !== void 0) {
697
+ const r = this.checked === "" || this.checked === "true" || this.checked === !0;
698
+ this.internals.ariaChecked = String(r);
699
+ const f = r ? (typeof this.value == "string" ? this.value : "") || ht : null;
700
+ this.internals.setFormValue(f);
701
+ } else
702
+ this.setFormValue(this.value);
703
+ this.inputRef && this.inputRef.value && (this.inputRef.value.setAttribute("form", ""), this.manageValidity(this.inputRef.value)), this.inputRefTo && this.inputRefTo.value && (this.inputRefTo.value.setAttribute("form", ""), this.manageValidity(this.inputRefTo.value));
704
+ }
705
+ }
706
+ o([
707
+ c({ type: Boolean, reflect: !0 })
708
+ ], l.prototype, "checked");
709
+ o([
710
+ c({ type: Boolean })
711
+ ], l.prototype, "defaultChecked");
712
+ o([
713
+ c({ type: Boolean })
714
+ ], l.prototype, "multiple");
715
+ o([
716
+ c({ type: Boolean })
717
+ ], l.prototype, "range");
718
+ o([
719
+ c({ type: String, reflect: !0 })
720
+ ], l.prototype, "type");
721
+ o([
722
+ c()
723
+ ], l.prototype, "defaultValue");
724
+ o([
725
+ c({ type: Boolean, reflect: !0 })
726
+ ], l.prototype, "disabled");
727
+ o([
728
+ c({ type: Boolean, reflect: !0 })
729
+ ], l.prototype, "readonly");
730
+ o([
731
+ c({ type: Boolean, reflect: !0 })
732
+ ], l.prototype, "required");
733
+ o([
734
+ c({
735
+ reflect: !0,
736
+ converter: {
737
+ fromAttribute: (p) => p,
738
+ toAttribute: (p) => (p == null ? void 0 : p.toString()) ?? null
739
+ }
740
+ })
741
+ ], l.prototype, "max");
742
+ o([
743
+ c({ type: Number, reflect: !0 })
744
+ ], l.prototype, "maxlength");
745
+ o([
746
+ c({
747
+ reflect: !0,
748
+ converter: {
749
+ fromAttribute: (p) => p,
750
+ toAttribute: (p) => (p == null ? void 0 : p.toString()) ?? null
751
+ }
752
+ })
753
+ ], l.prototype, "min");
754
+ o([
755
+ c({ type: Number, reflect: !0 })
756
+ ], l.prototype, "minlength");
757
+ o([
758
+ c({ type: Number, reflect: !0 })
759
+ ], l.prototype, "step");
760
+ o([
761
+ c({ type: String })
762
+ ], l.prototype, "ariaDescribedBy");
763
+ o([
764
+ c({ type: String })
765
+ ], l.prototype, "ariaLabelledby");
766
+ o([
767
+ c({ type: String, reflect: !0 })
768
+ ], l.prototype, "name");
769
+ o([
770
+ c({ type: String, reflect: !0 })
771
+ ], l.prototype, "pattern");
772
+ o([
773
+ c({ type: String, reflect: !0 })
774
+ ], l.prototype, "placeholder");
775
+ o([
776
+ c({ type: String, reflect: !0 })
777
+ ], l.prototype, "id");
778
+ o([
779
+ c({ type: Boolean })
780
+ ], l.prototype, "counter");
781
+ o([
782
+ c({ type: Boolean })
783
+ ], l.prototype, "hasError");
784
+ o([
785
+ c({ type: Boolean })
786
+ ], l.prototype, "inline");
787
+ o([
788
+ c({ type: Boolean })
789
+ ], l.prototype, "hasFieldset");
790
+ o([
791
+ c({ type: Boolean })
792
+ ], l.prototype, "optionalTag");
793
+ o([
794
+ c({ type: Boolean })
795
+ ], l.prototype, "requiredTag");
796
+ o([
797
+ c({ type: Boolean })
798
+ ], l.prototype, "skipForwardTestid");
799
+ o([
800
+ c({ type: Boolean, reflect: !0, converter: It })
801
+ ], l.prototype, "useWrapper");
802
+ o([
803
+ c({ type: Boolean, reflect: !0 })
804
+ ], l.prototype, "fullwidth");
805
+ o([
806
+ c({ type: Number })
807
+ ], l.prototype, "counterMaxLength");
808
+ o([
809
+ c({ type: String })
810
+ ], l.prototype, "errorMessage");
811
+ o([
812
+ c({ type: String })
813
+ ], l.prototype, "helptext");
814
+ o([
815
+ c({ type: String })
816
+ ], l.prototype, "helptextDropdown");
817
+ o([
818
+ c({ type: String, reflect: !1 })
819
+ ], l.prototype, "helptextDropdownButton");
820
+ o([
821
+ c({ type: String })
822
+ ], l.prototype, "label");
823
+ o([
824
+ c({ type: String, reflect: !1 })
825
+ ], l.prototype, "optionalText");
826
+ o([
827
+ c({ type: String, reflect: !1 })
828
+ ], l.prototype, "requiredText");
829
+ o([
830
+ c({ type: String, reflect: !1 })
831
+ ], l.prototype, "tagText");
832
+ o([
833
+ c({ type: String, attribute: "data-testid" })
834
+ ], l.prototype, "dataTestid");
835
+ o([
836
+ Tt()
837
+ ], l.prototype, "touched");
838
+ export {
839
+ l as P
840
+ };