@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
@@ -1,708 +0,0 @@
1
- import { P as Ce, t as g, n as d } from "./element-CRDRygXu.js";
2
- import { r as Fe } from "./state-DS_kr2Fy.js";
3
- import { u as Te } from "./utils-DznhwRXm.js";
4
- import { b as Se } from "./booleanish-C9R0tdXH.js";
5
- import { s as Ae } from "./input-wrapper-CDgenrYA.js";
6
- var oe = {}, le;
7
- function xe() {
8
- return le || (le = 1, (function() {
9
- (function(M) {
10
- const s = /* @__PURE__ */ new WeakMap(), h = /* @__PURE__ */ new WeakMap(), p = /* @__PURE__ */ new WeakMap(), u = /* @__PURE__ */ new WeakMap(), y = /* @__PURE__ */ new WeakMap(), V = /* @__PURE__ */ new WeakMap(), F = /* @__PURE__ */ new WeakMap(), b = /* @__PURE__ */ new WeakMap(), T = /* @__PURE__ */ new WeakMap(), C = /* @__PURE__ */ new WeakMap(), S = /* @__PURE__ */ new WeakMap(), A = /* @__PURE__ */ new WeakMap(), U = /* @__PURE__ */ new WeakMap(), z = /* @__PURE__ */ new WeakMap(), I = /* @__PURE__ */ new WeakMap(), L = {
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
- }, ce = (t, e) => {
54
- for (let i in L) {
55
- e[i] = null;
56
- let a = null;
57
- const r = L[i];
58
- Object.defineProperty(e, i, {
59
- get() {
60
- return a;
61
- },
62
- set(n) {
63
- a = n, t.isConnected ? k(t, r, n) : C.set(t, e);
64
- }
65
- });
66
- }
67
- };
68
- function K(t) {
69
- const e = u.get(t), { form: i } = e;
70
- Y(t, i, e), X(t, e.labels);
71
- }
72
- const j = (t, e = !1) => {
73
- const i = document.createTreeWalker(t, NodeFilter.SHOW_ELEMENT, {
74
- acceptNode(n) {
75
- return u.has(n) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
76
- }
77
- });
78
- let a = i.nextNode();
79
- const r = !e || t.disabled;
80
- for (; a; )
81
- a.formDisabledCallback && r && W(a, t.disabled), a = i.nextNode();
82
- }, G = { attributes: !0, attributeFilter: ["disabled", "name"] }, N = D() ? new MutationObserver((t) => {
83
- for (const e of t) {
84
- const i = e.target;
85
- if (e.attributeName === "disabled" && (i.constructor.formAssociated ? W(i, i.hasAttribute("disabled")) : i.localName === "fieldset" && j(i)), e.attributeName === "name" && i.constructor.formAssociated) {
86
- const a = u.get(i), r = T.get(i);
87
- a.setFormValue(r);
88
- }
89
- }
90
- }) : {};
91
- function P(t) {
92
- t.forEach((e) => {
93
- const { addedNodes: i, removedNodes: a } = e, r = Array.from(i), n = Array.from(a);
94
- r.forEach((o) => {
95
- var m;
96
- if (u.has(o) && o.constructor.formAssociated && K(o), C.has(o)) {
97
- const f = C.get(o);
98
- Object.keys(L).filter((v) => f[v] !== null).forEach((v) => {
99
- k(o, L[v], f[v]);
100
- }), C.delete(o);
101
- }
102
- if (I.has(o)) {
103
- const f = I.get(o);
104
- k(o, "internals-valid", f.validity.valid.toString()), k(o, "internals-invalid", (!f.validity.valid).toString()), k(o, "aria-invalid", (!f.validity.valid).toString()), I.delete(o);
105
- }
106
- if (o.localName === "form") {
107
- const f = b.get(o), E = document.createTreeWalker(o, NodeFilter.SHOW_ELEMENT, {
108
- acceptNode($) {
109
- return u.has($) && $.constructor.formAssociated && !(f && f.has($)) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
110
- }
111
- });
112
- let v = E.nextNode();
113
- for (; v; )
114
- K(v), v = E.nextNode();
115
- }
116
- o.localName === "fieldset" && ((m = N.observe) === null || m === void 0 || m.call(N, o, G), j(o, !0));
117
- }), n.forEach((o) => {
118
- const m = u.get(o);
119
- m && p.get(m) && J(m), F.has(o) && F.get(o).disconnect();
120
- });
121
- });
122
- }
123
- function de(t) {
124
- t.forEach((e) => {
125
- const { removedNodes: i } = e;
126
- i.forEach((a) => {
127
- const r = U.get(e.target);
128
- u.has(a) && ee(a), r.disconnect();
129
- });
130
- });
131
- }
132
- const he = (t) => {
133
- var e, i;
134
- const a = new MutationObserver(de);
135
- !((e = window == null ? void 0 : window.ShadyDOM) === null || e === void 0) && e.inUse && t.mode && t.host && (t = t.host), (i = a.observe) === null || i === void 0 || i.call(a, t, { childList: !0 }), U.set(t, a);
136
- };
137
- D() && new MutationObserver(P);
138
- const H = {
139
- childList: !0,
140
- subtree: !0
141
- }, k = (t, e, i) => {
142
- t.getAttribute(e) !== i && t.setAttribute(e, i);
143
- }, W = (t, e) => {
144
- t.toggleAttribute("internals-disabled", e), e ? k(t, "aria-disabled", "true") : t.removeAttribute("aria-disabled"), t.formDisabledCallback && t.formDisabledCallback.apply(t, [e]);
145
- }, J = (t) => {
146
- p.get(t).forEach((i) => {
147
- i.remove();
148
- }), p.set(t, []);
149
- }, Q = (t, e) => {
150
- const i = document.createElement("input");
151
- return i.type = "hidden", i.name = t.getAttribute("name"), t.after(i), p.get(e).push(i), i;
152
- }, ue = (t, e) => {
153
- var i;
154
- p.set(e, []), (i = N.observe) === null || i === void 0 || i.call(N, t, G);
155
- }, X = (t, e) => {
156
- if (e.length) {
157
- Array.from(e).forEach((a) => a.addEventListener("click", t.click.bind(t)));
158
- let i = e[0].id;
159
- e[0].id || (i = `${e[0].htmlFor}_Label`, e[0].id = i), k(t, "aria-labelledby", i);
160
- }
161
- }, R = (t) => {
162
- const e = Array.from(t.elements).filter((n) => !n.tagName.includes("-") && n.validity).map((n) => n.validity.valid), i = b.get(t) || [], a = Array.from(i).filter((n) => n.isConnected).map((n) => u.get(n).validity.valid), r = [...e, ...a].includes(!1);
163
- t.toggleAttribute("internals-invalid", r), t.toggleAttribute("internals-valid", !r);
164
- }, fe = (t) => {
165
- R(O(t.target));
166
- }, pe = (t) => {
167
- R(O(t.target));
168
- }, me = (t) => {
169
- const e = ["button[type=submit]", "input[type=submit]", "button:not([type])"].map((i) => `${i}:not([disabled])`).map((i) => `${i}:not([form])${t.id ? `,${i}[form='${t.id}']` : ""}`).join(",");
170
- t.addEventListener("click", (i) => {
171
- if (i.target.closest(e)) {
172
- const r = b.get(t);
173
- if (t.noValidate)
174
- return;
175
- r.size && Array.from(r).reverse().map((m) => u.get(m).reportValidity()).includes(!1) && i.preventDefault();
176
- }
177
- });
178
- }, ye = (t) => {
179
- const e = b.get(t.target);
180
- e && e.size && e.forEach((i) => {
181
- i.constructor.formAssociated && i.formResetCallback && i.formResetCallback.apply(i);
182
- });
183
- }, Y = (t, e, i) => {
184
- if (e) {
185
- const a = b.get(e);
186
- if (a)
187
- a.add(t);
188
- else {
189
- const r = /* @__PURE__ */ new Set();
190
- r.add(t), b.set(e, r), me(e), e.addEventListener("reset", ye), e.addEventListener("input", fe), e.addEventListener("change", pe);
191
- }
192
- V.set(e, { ref: t, internals: i }), t.constructor.formAssociated && t.formAssociatedCallback && setTimeout(() => {
193
- t.formAssociatedCallback.apply(t, [e]);
194
- }, 0), R(e);
195
- }
196
- }, O = (t) => {
197
- let e = t.parentNode;
198
- return e && e.tagName !== "FORM" && (e = O(e)), e;
199
- }, w = (t, e, i = DOMException) => {
200
- if (!t.constructor.formAssociated)
201
- throw new i(e);
202
- }, Z = (t, e, i) => {
203
- const a = b.get(t);
204
- return a && a.size && a.forEach((r) => {
205
- u.get(r)[i]() || (e = !1);
206
- }), e;
207
- }, ee = (t) => {
208
- if (t.constructor.formAssociated) {
209
- const e = u.get(t), { labels: i, form: a } = e;
210
- X(t, i), Y(t, a, e);
211
- }
212
- };
213
- function D() {
214
- return typeof MutationObserver < "u";
215
- }
216
- class ge {
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 be = (t) => (t.badInput = !1, t.customError = !1, t.patternMismatch = !1, t.rangeOverflow = !1, t.rangeUnderflow = !1, t.stepMismatch = !1, t.tooLong = !1, t.tooShort = !1, t.typeMismatch = !1, t.valid = !0, t.valueMissing = !1, t), ve = (t, e, i) => (t.valid = we(e), Object.keys(e).forEach((a) => t[a] = e[a]), i && R(i), t), we = (t) => {
222
- let e = !0;
223
- for (let i in t)
224
- i !== "valid" && t[i] !== !1 && (e = !1);
225
- return e;
226
- }, B = /* @__PURE__ */ new WeakMap();
227
- function te(t, e) {
228
- t.toggleAttribute(e, !0), t.part && t.part.add(e);
229
- }
230
- class _ extends Set {
231
- static get isPolyfilled() {
232
- return !0;
233
- }
234
- constructor(e) {
235
- if (super(), !e || !e.tagName || e.tagName.indexOf("-") === -1)
236
- throw new TypeError("Illegal constructor");
237
- B.set(this, e);
238
- }
239
- add(e) {
240
- if (!/^--/.test(e) || typeof e != "string")
241
- throw new DOMException(`Failed to execute 'add' on 'CustomStateSet': The specified value ${e} must start with '--'.`);
242
- const i = super.add(e), a = B.get(this), r = `state${e}`;
243
- return a.isConnected ? te(a, r) : setTimeout(() => {
244
- te(a, r);
245
- }), i;
246
- }
247
- clear() {
248
- for (let [e] of this.entries())
249
- this.delete(e);
250
- super.clear();
251
- }
252
- delete(e) {
253
- const i = super.delete(e), a = B.get(this);
254
- return a.isConnected ? (a.toggleAttribute(`state${e}`, !1), a.part && a.part.remove(`state${e}`)) : setTimeout(() => {
255
- a.toggleAttribute(`state${e}`, !1), a.part && a.part.remove(`state${e}`);
256
- }), i;
257
- }
258
- }
259
- function ie(t, e, i, a) {
260
- if (typeof e == "function" ? t !== e || !a : !e.has(t)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
261
- return i === "m" ? a : i === "a" ? a.call(t) : a ? a.value : e.get(t);
262
- }
263
- function Ee(t, e, i, a, r) {
264
- if (typeof e == "function" ? t !== e || !0 : !e.has(t)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
265
- return e.set(t, i), i;
266
- }
267
- var x;
268
- class Me {
269
- constructor(e) {
270
- x.set(this, void 0), Ee(this, x, e);
271
- for (let i = 0; i < e.length; i++) {
272
- let a = e[i];
273
- this[i] = a, a.hasAttribute("name") && (this[a.getAttribute("name")] = a);
274
- }
275
- Object.freeze(this);
276
- }
277
- get length() {
278
- return ie(this, x, "f").length;
279
- }
280
- [(x = /* @__PURE__ */ new WeakMap(), Symbol.iterator)]() {
281
- return ie(this, x, "f")[Symbol.iterator]();
282
- }
283
- item(e) {
284
- return this[e] == null ? null : this[e];
285
- }
286
- namedItem(e) {
287
- return this[e] == null ? null : this[e];
288
- }
289
- }
290
- function ke() {
291
- const t = HTMLFormElement.prototype.checkValidity;
292
- HTMLFormElement.prototype.checkValidity = i;
293
- const e = HTMLFormElement.prototype.reportValidity;
294
- HTMLFormElement.prototype.reportValidity = a;
295
- function i(...n) {
296
- let o = t.apply(this, n);
297
- return Z(this, o, "checkValidity");
298
- }
299
- function a(...n) {
300
- let o = e.apply(this, n);
301
- return Z(this, o, "reportValidity");
302
- }
303
- const { get: r } = Object.getOwnPropertyDescriptor(HTMLFormElement.prototype, "elements");
304
- Object.defineProperty(HTMLFormElement.prototype, "elements", {
305
- get(...n) {
306
- const o = r.call(this, ...n), m = Array.from(b.get(this) || []);
307
- if (m.length === 0)
308
- return o;
309
- const f = Array.from(o).concat(m).sort((E, v) => E.compareDocumentPosition ? E.compareDocumentPosition(v) & 2 ? 1 : -1 : 0);
310
- return new Me(f);
311
- }
312
- });
313
- }
314
- class ae {
315
- static get isPolyfilled() {
316
- return !0;
317
- }
318
- constructor(e) {
319
- if (!e || !e.tagName || e.tagName.indexOf("-") === -1)
320
- throw new TypeError("Illegal constructor");
321
- const i = e.getRootNode(), a = new ge();
322
- this.states = new _(e), s.set(this, e), h.set(this, a), u.set(e, this), ce(e, this), ue(e, this), Object.seal(this), i instanceof DocumentFragment && he(i);
323
- }
324
- checkValidity() {
325
- const e = s.get(this);
326
- if (w(e, "Failed to execute 'checkValidity' on 'ElementInternals': The target element is not a form-associated custom element."), !this.willValidate)
327
- return !0;
328
- const i = h.get(this);
329
- if (!i.valid) {
330
- const a = new Event("invalid", {
331
- bubbles: !1,
332
- cancelable: !0,
333
- composed: !1
334
- });
335
- e.dispatchEvent(a);
336
- }
337
- return i.valid;
338
- }
339
- get form() {
340
- const e = s.get(this);
341
- w(e, "Failed to read the 'form' property from 'ElementInternals': The target element is not a form-associated custom element.");
342
- let i;
343
- return e.constructor.formAssociated === !0 && (i = O(e)), i;
344
- }
345
- get labels() {
346
- const e = s.get(this);
347
- w(e, "Failed to read the 'labels' property from 'ElementInternals': The target element is not a form-associated custom element.");
348
- const i = e.getAttribute("id"), a = e.getRootNode();
349
- return a && i ? a.querySelectorAll(`[for="${i}"]`) : [];
350
- }
351
- reportValidity() {
352
- const e = s.get(this);
353
- if (w(e, "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(), a = A.get(this);
356
- if (a && !e.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 && a && (e.focus(), a.focus()), i;
359
- }
360
- setFormValue(e) {
361
- const i = s.get(this);
362
- if (w(i, "Failed to execute 'setFormValue' on 'ElementInternals': The target element is not a form-associated custom element."), J(this), e != null && !(e instanceof FormData)) {
363
- if (i.getAttribute("name")) {
364
- const a = Q(i, this);
365
- a.value = e;
366
- }
367
- } else e != null && e instanceof FormData && Array.from(e).reverse().forEach(([a, r]) => {
368
- if (typeof r == "string") {
369
- const n = Q(i, this);
370
- n.name = a, n.value = r;
371
- }
372
- });
373
- T.set(i, e);
374
- }
375
- setValidity(e, i, a) {
376
- const r = s.get(this);
377
- if (w(r, "Failed to execute 'setValidity' on 'ElementInternals': The target element is not a form-associated custom element."), !e)
378
- throw new TypeError("Failed to execute 'setValidity' on 'ElementInternals': 1 argument required, but only 0 present.");
379
- A.set(this, a);
380
- const n = h.get(this), o = {};
381
- for (const E in e)
382
- o[E] = e[E];
383
- Object.keys(o).length === 0 && be(n);
384
- const m = Object.assign(Object.assign({}, n), o);
385
- delete m.valid;
386
- const { valid: f } = ve(n, m, this.form);
387
- if (!f && !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
- y.set(this, f ? "" : i), r.isConnected ? (r.toggleAttribute("internals-invalid", !f), r.toggleAttribute("internals-valid", f), k(r, "aria-invalid", `${!f}`)) : I.set(r, this);
390
- }
391
- get shadowRoot() {
392
- const e = s.get(this), i = S.get(e);
393
- return i || null;
394
- }
395
- get validationMessage() {
396
- const e = s.get(this);
397
- return w(e, "Failed to read the 'validationMessage' property from 'ElementInternals': The target element is not a form-associated custom element."), y.get(this);
398
- }
399
- get validity() {
400
- const e = s.get(this);
401
- return w(e, "Failed to read the 'validity' property from 'ElementInternals': The target element is not a form-associated custom element."), h.get(this);
402
- }
403
- get willValidate() {
404
- const e = s.get(this);
405
- return w(e, "Failed to read the 'willValidate' property from 'ElementInternals': The target element is not a form-associated custom element."), !(e.disabled || e.hasAttribute("disabled") || e.hasAttribute("readonly"));
406
- }
407
- }
408
- function Ve() {
409
- if (typeof window > "u" || !window.ElementInternals || !HTMLElement.prototype.attachInternals)
410
- return !1;
411
- class t extends HTMLElement {
412
- constructor() {
413
- super(), this.internals = this.attachInternals();
414
- }
415
- }
416
- const e = `element-internals-feature-detection-${Math.random().toString(36).replace(/[^a-z]+/g, "")}`;
417
- customElements.define(e, t);
418
- const i = new t();
419
- return [
420
- "shadowRoot",
421
- "form",
422
- "willValidate",
423
- "validity",
424
- "validationMessage",
425
- "labels",
426
- "setFormValue",
427
- "setValidity",
428
- "checkValidity",
429
- "reportValidity"
430
- ].every((a) => a in i.internals);
431
- }
432
- let se = !1, re = !1;
433
- function q(t) {
434
- re || (re = !0, window.CustomStateSet = _, t && (HTMLElement.prototype.attachInternals = function(...e) {
435
- const i = t.call(this, e);
436
- return i.states = new _(this), i;
437
- }));
438
- }
439
- function ne(t = !0) {
440
- if (!se) {
441
- if (se = !0, typeof window < "u" && (window.ElementInternals = ae), typeof CustomElementRegistry < "u") {
442
- const e = CustomElementRegistry.prototype.define;
443
- CustomElementRegistry.prototype.define = function(i, a, r) {
444
- if (a.formAssociated) {
445
- const n = a.prototype.connectedCallback;
446
- a.prototype.connectedCallback = function() {
447
- z.has(this) || (z.set(this, !0), this.hasAttribute("disabled") && W(this, !0)), n != null && n.apply(this), ee(this);
448
- };
449
- }
450
- e.call(this, i, a, r);
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 ae(this);
461
- }), typeof Element < "u") {
462
- let e = function(...a) {
463
- const r = i.apply(this, a);
464
- if (S.set(this, r), D()) {
465
- const n = new MutationObserver(P);
466
- window.ShadyDOM ? n.observe(this, H) : n.observe(r, H), F.set(this, n);
467
- }
468
- return r;
469
- };
470
- const i = Element.prototype.attachShadow;
471
- Element.prototype.attachShadow = e;
472
- }
473
- D() && typeof document < "u" && new MutationObserver(P).observe(document.documentElement, H), typeof HTMLFormElement < "u" && ke(), (t || typeof window < "u" && !window.CustomStateSet) && q();
474
- }
475
- }
476
- return !!customElements.polyfillWrapFlushCallback || (Ve() ? typeof window < "u" && !window.CustomStateSet && q(HTMLElement.prototype.attachInternals) : ne(!1)), M.forceCustomStateSetPolyfill = q, M.forceElementInternalsPolyfill = ne, Object.defineProperty(M, "__esModule", { value: !0 }), M;
477
- })({});
478
- })()), oe;
479
- }
480
- xe();
481
- var Ie = Object.defineProperty, l = (M, s, h, p) => {
482
- for (var u = void 0, y = M.length - 1, V; y >= 0; y--)
483
- (V = M[y]) && (u = V(s, h, u) || u);
484
- return u && Ie(s, h, u), u;
485
- };
486
- class c extends Ce {
487
- constructor() {
488
- 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 = Te(), 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 = Ae.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();
489
- }
490
- static get formAssociated() {
491
- return !0;
492
- }
493
- manageValidity(s) {
494
- var h, p, u, y, V, F, b, T, C, S, A;
495
- s && (this.required && !this.value ? this.internals.setValidity({ valueMissing: !0 }, g.forms.messages.required, s) : (h = s.validity) != null && h.typeMismatch || (p = s.validity) != null && p.badInput ? this.internals.setValidity({ typeMismatch: !0 }, g.forms.messages.invalid, s) : (u = s.validity) != null && u.patternMismatch ? this.internals.setValidity(
496
- { patternMismatch: !0 },
497
- g.forms.messages.invalidPattern,
498
- s
499
- ) : (y = s.validity) != null && y.tooShort || this.minlength && this.minlength > 0 && this.value.length < this.minlength ? this.internals.setValidity({ tooShort: !0 }, g.forms.messages.tooShort, s) : (V = s.validity) != null && V.tooLong || this.maxlength && this.maxlength > 0 && this.value.length > this.maxlength ? this.internals.setValidity({ tooLong: !0 }, g.forms.messages.tooLong, s) : (F = s.validity) != null && F.rangeUnderflow ? this.internals.setValidity(
500
- { rangeUnderflow: !0 },
501
- this.min ? g.forms.messages.rangeUnderflowMin.replace("{min}", (b = this.min) == null ? void 0 : b.toString()) : g.forms.messages.rangeUnderflow,
502
- s
503
- ) : (T = s.validity) != null && T.stepMismatch ? this.internals.setValidity({ stepMismatch: !0 }, g.forms.messages.invalid, s) : (C = s.validity) != null && C.rangeOverflow ? this.internals.setValidity(
504
- { rangeOverflow: !0 },
505
- this.max ? g.forms.messages.rangeOverflowMax.replace("{max}", (S = this.max) == null ? void 0 : S.toString()) : g.forms.messages.rangeOverflow,
506
- s
507
- ) : (A = s.validity) != null && A.customError ? this.internals.setValidity({ customError: !0 }, s.validationMessage, s) : this.internals.setValidity({}));
508
- }
509
- setFormValue(s) {
510
- if (this.internals)
511
- if (Array.isArray(s)) {
512
- const h = new FormData();
513
- s.forEach((p) => {
514
- h.append(this.name, p);
515
- }), this.internals.setFormValue(h);
516
- } else
517
- this.internals.setFormValue(s);
518
- }
519
- // Trigger this when you want to set the value of the *radio or checkbox* input out to the form
520
- // Do not use valueChanged or onChange for radios and checkboxes!
521
- valueChecked(s) {
522
- if (!this.touched) return;
523
- const h = this.internals.form || this.closest("form"), p = h ? new FormData(h) : null;
524
- h && h.querySelectorAll(
525
- `pkt-radiobutton[name="${this.name}"], input[type=radio][name="${this.name}"]`
526
- ).forEach((u) => {
527
- const y = u;
528
- y.name === this.name && y.value !== this.value && y.checked && (y.checked = !1);
529
- }), typeof s == "string" ? (this.checked = s === "true", this.internals.ariaChecked = s === "true") : typeof s == "boolean" && (this.checked = s, this.internals.ariaChecked = s), this.checked ? (this.internals.setFormValue(this.value || "on", this.value || "on"), p && p.append(this.name, this.value || "on"), this.internals.states.add("--checked")) : (this.internals.setFormValue(null, null), p && p.delete(this.name), this.internals.states.delete("--checked")), this.dispatchEvent(new Event("change", { bubbles: !0, composed: !0 })), this.dispatchEvent(
530
- new CustomEvent("value-change", {
531
- detail: this.checked,
532
- bubbles: !0,
533
- composed: !0
534
- })
535
- ), this.internals.reportValidity();
536
- }
537
- valueChanged(s, h) {
538
- (h !== this.value || h !== this._value) && (typeof s == "string" ? ((this.multiple || this.range) && s.includes(",") && (s = s.split(",")), this.value = s, this._value = Array.isArray(s) ? s : [s]) : Array.isArray(s) ? (this.value = this.multiple || this.range ? s : s[0], this._value = s) : (this.value = "", this._value = []), (!this.value || this.value.length === 0) && h && h.length !== 0 ? this.clearInputValue() : this.value && this.value.toString() !== (h == null ? void 0 : h.toString()) && this.onChange(this.value), this.updateComplete.then(() => this.requestUpdate()));
539
- }
540
- // When input goes from content to no content
541
- clearInputValue() {
542
- const s = this.multiple || this.range ? [] : "";
543
- this.value = s, this.internals.setFormValue(s), this.dispatchEvent(new Event("change", { bubbles: !0, composed: !0 })), this.dispatchEvent(
544
- new CustomEvent("value-change", {
545
- detail: s,
546
- bubbles: !0,
547
- composed: !0
548
- })
549
- );
550
- }
551
- // When user enters the input, we need to push that event out to the form
552
- onFocus() {
553
- this.dispatchEvent(new FocusEvent("focus", { bubbles: !0, composed: !0 }));
554
- }
555
- // And also when the user leaves the input...
556
- onBlur() {
557
- this.dispatchEvent(new FocusEvent("blur", { bubbles: !0, composed: !0 }));
558
- }
559
- // Trigger this when user types in the input
560
- onInput() {
561
- this.dispatchEvent(new InputEvent("input", { bubbles: !0, composed: !0 }));
562
- }
563
- // Trigger this when you want to set the value of the input out to the form
564
- onChange(s) {
565
- if (!this.touched) {
566
- this.touched = !0, s && this.setFormValue(s);
567
- return;
568
- }
569
- typeof s != "string" && !Array.isArray(s) || ((this.range || this.multiple) && !Array.isArray(s) && s.includes(",") && (s = s.split(",")), !this.multiple && !this.range && Array.isArray(s) && (s = s[0]), this.setFormValue(s), this.manageValidity(this.inputRef.value), this.inputRefTo && this.manageValidity(this.inputRefTo.value), this.dispatchEvent(new Event("change", { bubbles: !0, composed: !0 })), this.dispatchEvent(
570
- new CustomEvent("value-change", {
571
- detail: s,
572
- bubbles: !0,
573
- composed: !0
574
- })
575
- ));
576
- }
577
- formResetCallback() {
578
- this.touched = !1, this._options && this._options.length && this._options.forEach((s) => {
579
- "selected" in s && (s.selected = !1);
580
- }), this.checked !== void 0 ? (this.checked = !1, this.internals.ariaChecked = !1, this.internals.setFormValue("", ""), this.inputRef.value.checked = !1, this.valueChecked(this.checked)) : (this.internals.setFormValue(""), this.value = this.defaultValue || (this.multiple || this.range ? [] : ""), this._value = this.value, this.valueChanged(this.value, null)), this.internals.ariaInvalid = !1;
581
- }
582
- updated(s) {
583
- super.updated(s), s.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")));
584
- }
585
- firstUpdated(s) {
586
- if (super.firstUpdated(s), !this.form) {
587
- const h = this.internals.form || this.closest("form");
588
- this.form = h;
589
- }
590
- 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 = !0, this.checked = !0), this.required && (this.internals.ariaRequired = !0), this.disabled && (this.internals.ariaDisabled = !0), this.id && !this.name && (this.name = this.id), this.checked !== void 0) {
591
- const h = this.checked === "" || this.checked === "true" || this.checked === !0;
592
- this.internals.ariaChecked = h, this.internals.setFormValue(
593
- h ? this.value || "on" : "",
594
- h ? this.value || "on" : ""
595
- );
596
- } else
597
- this.internals.setFormValue(this.value);
598
- 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));
599
- }
600
- }
601
- l([
602
- d()
603
- ], c.prototype, "defaultValue");
604
- l([
605
- d({ type: Boolean, reflect: !0 })
606
- ], c.prototype, "disabled");
607
- l([
608
- d({ type: Boolean, reflect: !0 })
609
- ], c.prototype, "readonly");
610
- l([
611
- d({ type: Boolean, reflect: !0 })
612
- ], c.prototype, "required");
613
- l([
614
- d({ type: Number, reflect: !0 })
615
- ], c.prototype, "max");
616
- l([
617
- d({ type: Number, reflect: !0 })
618
- ], c.prototype, "maxlength");
619
- l([
620
- d({ type: Number, reflect: !0 })
621
- ], c.prototype, "min");
622
- l([
623
- d({ type: Number, reflect: !0 })
624
- ], c.prototype, "minlength");
625
- l([
626
- d({ type: Number, reflect: !0 })
627
- ], c.prototype, "step");
628
- l([
629
- d({ type: String })
630
- ], c.prototype, "ariaDescribedBy");
631
- l([
632
- d({ type: String })
633
- ], c.prototype, "ariaLabelledby");
634
- l([
635
- d({ type: String, reflect: !0 })
636
- ], c.prototype, "name");
637
- l([
638
- d({ type: String, reflect: !0 })
639
- ], c.prototype, "pattern");
640
- l([
641
- d({ type: String, reflect: !0 })
642
- ], c.prototype, "placeholder");
643
- l([
644
- d({ type: String, reflect: !0 })
645
- ], c.prototype, "id");
646
- l([
647
- d({ type: Boolean })
648
- ], c.prototype, "counter");
649
- l([
650
- d({ type: Boolean })
651
- ], c.prototype, "hasError");
652
- l([
653
- d({ type: Boolean })
654
- ], c.prototype, "inline");
655
- l([
656
- d({ type: Boolean })
657
- ], c.prototype, "hasFieldset");
658
- l([
659
- d({ type: Boolean })
660
- ], c.prototype, "optionalTag");
661
- l([
662
- d({ type: Boolean })
663
- ], c.prototype, "requiredTag");
664
- l([
665
- d({ type: Boolean })
666
- ], c.prototype, "skipForwardTestid");
667
- l([
668
- d({ type: Boolean, reflect: !0, converter: Se })
669
- ], c.prototype, "useWrapper");
670
- l([
671
- d({ type: Boolean, reflect: !0 })
672
- ], c.prototype, "fullwidth");
673
- l([
674
- d({ type: Number })
675
- ], c.prototype, "counterMaxLength");
676
- l([
677
- d({ type: String })
678
- ], c.prototype, "errorMessage");
679
- l([
680
- d({ type: String })
681
- ], c.prototype, "helptext");
682
- l([
683
- d({ type: String })
684
- ], c.prototype, "helptextDropdown");
685
- l([
686
- d({ type: String, reflect: !1 })
687
- ], c.prototype, "helptextDropdownButton");
688
- l([
689
- d({ type: String })
690
- ], c.prototype, "label");
691
- l([
692
- d({ type: String, reflect: !1 })
693
- ], c.prototype, "optionalText");
694
- l([
695
- d({ type: String, reflect: !1 })
696
- ], c.prototype, "requiredText");
697
- l([
698
- d({ type: String, reflect: !1 })
699
- ], c.prototype, "tagText");
700
- l([
701
- d({ type: String, attribute: "data-testid" })
702
- ], c.prototype, "dataTestid");
703
- l([
704
- Fe()
705
- ], c.prototype, "touched");
706
- export {
707
- c as P
708
- };