@mattilsynet/design 3.2.3 → 3.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/mtds/atlas/atlas-element.js +1 -1
- package/mtds/deprecations.js +39 -37
- package/mtds/deprecations.js.map +1 -1
- package/mtds/external/@u-elements/u-combobox/dist/u-combobox.js +288 -0
- package/mtds/external/@u-elements/u-combobox/dist/u-combobox.js.map +1 -0
- package/mtds/external/@u-elements/u-datalist/dist/u-datalist.js +238 -0
- package/mtds/external/@u-elements/u-datalist/dist/u-datalist.js.map +1 -0
- package/mtds/external/@u-elements/u-details/dist/u-details.js +101 -0
- package/mtds/external/@u-elements/u-details/dist/u-details.js.map +1 -0
- package/mtds/external/@u-elements/u-tabs/dist/u-tabs.js +235 -0
- package/mtds/external/@u-elements/u-tabs/dist/u-tabs.js.map +1 -0
- package/mtds/index.iife.js +17 -30
- package/mtds/index.js +36 -21
- package/mtds/layout/layout.d.ts +1 -1
- package/mtds/layout/layout.js.map +1 -1
- package/mtds/package.json.js +1 -1
- package/mtds/styles.css +1 -1
- package/mtds/styles.json +23 -23
- package/mtds/styles.module.css.js +44 -44
- package/mtds/tabs/tabs.d.ts +9 -9
- package/mtds/tabs/tabs.js +8 -8
- package/mtds/tabs/tabs.js.map +1 -1
- package/package.json +9 -13
|
@@ -19,7 +19,7 @@ class r extends g {
|
|
|
19
19
|
}
|
|
20
20
|
constructor() {
|
|
21
21
|
super(), this.attachShadow({ mode: "open" }).append(m("figure")), C(this, `@layer leaflet{${h}}
|
|
22
|
-
@layer mt.v3-2-
|
|
22
|
+
@layer mt.v3-2-5design{${b}`);
|
|
23
23
|
}
|
|
24
24
|
connectedCallback() {
|
|
25
25
|
const t = this.shadowRoot?.lastElementChild, e = a(this, "data-cluster") ?? "false", o = new i.TileLayer(k, {
|
package/mtds/deprecations.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { DSFieldElement as p } from "@digdir/designsystemet-web";
|
|
2
|
-
import
|
|
3
|
-
import { getByCSSModule as
|
|
4
|
-
const
|
|
2
|
+
import l from "./styles.module.css.js";
|
|
3
|
+
import { getByCSSModule as n, isBrowser as d, onHotReload as y, on as u, QUICK_EVENT as S, onMutation as E, attr as s, debounce as D } from "./utils.js";
|
|
4
|
+
const f = /* @__PURE__ */ new WeakSet(), a = (t) => !f.has(t) && f.add(t), o = (t, e, r) => window.dsWarnings === !1 || console.warn(
|
|
5
5
|
`\x1B[1m@mattilsynet/design:\x1B[m ${t} is deprecated, please use ${e}:`,
|
|
6
|
-
|
|
7
|
-
), A =
|
|
6
|
+
r
|
|
7
|
+
), A = n("togglegroup"), g = l.button.split(" "), L = () => {
|
|
8
8
|
for (const t of A) {
|
|
9
9
|
a(t) && !t.hasAttribute("data-toggle-group") && (s(t, "data-toggle-group", "Valgknapper"), o(
|
|
10
10
|
'Only setting class="styles.togglegroup"',
|
|
@@ -12,28 +12,28 @@ const u = /* @__PURE__ */ new WeakSet(), a = (t) => !u.has(t) && u.add(t), o = (
|
|
|
12
12
|
t
|
|
13
13
|
));
|
|
14
14
|
for (const e of t.getElementsByTagName("label"))
|
|
15
|
-
a(e) && !e.classList.contains(
|
|
15
|
+
a(e) && !e.classList.contains(g[0]) && (e.classList.add(...g), o(
|
|
16
16
|
'Only setting class="styles.button"',
|
|
17
17
|
'<label class="styles.button">',
|
|
18
18
|
e
|
|
19
19
|
));
|
|
20
20
|
}
|
|
21
|
-
}, O =
|
|
21
|
+
}, O = n("breadcrumbs"), C = () => {
|
|
22
22
|
for (const t of O)
|
|
23
|
-
a(t) && t.nodeName !== "DS-BREADCRUMBS" && (t.classList.add(...
|
|
23
|
+
a(t) && t.nodeName !== "DS-BREADCRUMBS" && (t.classList.add(...l.breadcrumbs.split(" ")), o(
|
|
24
24
|
'Only setting class="styles.breadcrumbs"',
|
|
25
25
|
'<ds-breadcrumbs class="styles.breadcrumbs">',
|
|
26
26
|
t
|
|
27
27
|
));
|
|
28
|
-
},
|
|
29
|
-
for (const t of
|
|
28
|
+
}, N = n("errorsummary"), R = () => {
|
|
29
|
+
for (const t of N)
|
|
30
30
|
a(t) && t.nodeName !== "DS-ERROR-SUMMARY" && o(
|
|
31
31
|
'Only setting class="styles.errorsummary"',
|
|
32
32
|
'<ds-error-summary class="styles.errorsummary">',
|
|
33
33
|
t
|
|
34
34
|
);
|
|
35
|
-
},
|
|
36
|
-
for (const t of
|
|
35
|
+
}, w = n("dialog"), b = () => {
|
|
36
|
+
for (const t of w) {
|
|
37
37
|
if (a(t)) {
|
|
38
38
|
const e = s(t, "data-closedby");
|
|
39
39
|
e && (s(t, "closedby", e), o(
|
|
@@ -52,17 +52,17 @@ const u = /* @__PURE__ */ new WeakSet(), a = (t) => !u.has(t) && u.add(t), o = (
|
|
|
52
52
|
t
|
|
53
53
|
), s(t, "open", null), t.showModal()) : t.matches(":modal:not([open])") && (s(t, "open", ""), t.close()));
|
|
54
54
|
}
|
|
55
|
-
},
|
|
55
|
+
}, B = () => {
|
|
56
56
|
for (const t of document.querySelectorAll("[data-count]"))
|
|
57
57
|
if (a(t)) {
|
|
58
58
|
const e = s(t, "data-count");
|
|
59
|
-
t.classList.add(...
|
|
59
|
+
t.classList.add(...l.validation.split(" ")), s(t, "data-limit", e), o(
|
|
60
60
|
`data-count="${e}"`,
|
|
61
61
|
`class="styles.validation" data-field="counter" data-limit="${e}"`,
|
|
62
62
|
t
|
|
63
63
|
);
|
|
64
64
|
}
|
|
65
|
-
},
|
|
65
|
+
}, T = () => {
|
|
66
66
|
for (const t of document.querySelectorAll("[data-command]"))
|
|
67
67
|
if (a(t)) {
|
|
68
68
|
const e = s(t, "data-command");
|
|
@@ -76,57 +76,59 @@ const u = /* @__PURE__ */ new WeakSet(), a = (t) => !u.has(t) && u.add(t), o = (
|
|
|
76
76
|
t
|
|
77
77
|
);
|
|
78
78
|
}
|
|
79
|
-
},
|
|
80
|
-
for (const t of
|
|
81
|
-
|
|
82
|
-
for (const t of
|
|
83
|
-
a(t) &&
|
|
79
|
+
}, h = d() ? document.getElementsByTagName("u-tabs") : [], I = () => {
|
|
80
|
+
for (const t of h) a(t) && o("u-tabs", "ds-tabs", t);
|
|
81
|
+
}, i = l.suggestion.split(" "), v = d() ? document.getElementsByTagName("u-combobox") : [], $ = d() ? document.getElementsByTagName("ds-suggestion") : [], M = () => {
|
|
82
|
+
for (const t of v)
|
|
83
|
+
a(t) && (t.classList.add(...i), o("<u-combobox>", '<ds-suggestion class="styles.suggestion">', t));
|
|
84
|
+
for (const t of $)
|
|
85
|
+
a(t) && !t.classList.contains(i[0]) && (t.classList.add(...i), o(
|
|
84
86
|
"Only using <ds-suggestion>",
|
|
85
87
|
'<ds-suggestion class="styles.suggestion">',
|
|
86
88
|
t
|
|
87
89
|
));
|
|
88
|
-
},
|
|
90
|
+
}, U = ({ target: t }) => {
|
|
89
91
|
if (!(t instanceof Element)) return;
|
|
90
92
|
const e = t?.closest("tr")?.querySelector('[data-command="row"]');
|
|
91
93
|
e && !t?.closest('a,button,label,input,select,textarea,[role="button"]') && e.click();
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
},
|
|
95
|
-
for (const t of
|
|
94
|
+
const m = t?.closest("dialog");
|
|
95
|
+
m && t?.closest('[data-command="close"]') && m.close();
|
|
96
|
+
}, k = n("field"), c = /* @__PURE__ */ new Set(), F = () => {
|
|
97
|
+
for (const t of k)
|
|
96
98
|
t.nodeName !== "DS-FIELD" && (a(t) || o(
|
|
97
99
|
'Only setting class="styles.field"',
|
|
98
100
|
'<ds-field class="styles.field">',
|
|
99
101
|
t
|
|
100
102
|
), !c.has(t) && c.add(t) && p.prototype.connectedCallback.call(t));
|
|
101
|
-
},
|
|
103
|
+
}, G = () => {
|
|
102
104
|
for (const t of c)
|
|
103
105
|
p.prototype.disconnectedCallback.call(t), c.delete(t);
|
|
104
|
-
},
|
|
105
|
-
for (const t of document.querySelectorAll(
|
|
106
|
+
}, x = `[data-description], .${l.field.split(" ")[0]} label + p`, q = () => {
|
|
107
|
+
for (const t of document.querySelectorAll(x))
|
|
106
108
|
a(t) && t.getAttribute("data-field") !== "description" && (s(t, "data-field", "description"), o(
|
|
107
109
|
"Descriptions created by data-description of <p> only",
|
|
108
110
|
'data-field="data-description"',
|
|
109
111
|
t
|
|
110
112
|
));
|
|
111
|
-
},
|
|
112
|
-
for (const t of
|
|
113
|
+
}, P = n("validation"), _ = () => {
|
|
114
|
+
for (const t of P)
|
|
113
115
|
a(t) && !t.hasAttribute("data-field") && (s(t, "data-field", "validation"), o(
|
|
114
116
|
'Only setting class="styles.validation"',
|
|
115
117
|
'class="styles.validation" data-field="validation"',
|
|
116
118
|
t
|
|
117
119
|
));
|
|
118
|
-
},
|
|
120
|
+
}, V = () => {
|
|
119
121
|
for (const t of document.querySelectorAll("[popover][data-position]"))
|
|
120
122
|
a(t) && (s(t, "data-placement", s(t, "data-position")), o("data-position", "data-placement", t));
|
|
121
|
-
},
|
|
122
|
-
|
|
123
|
+
}, W = D(() => {
|
|
124
|
+
d() && (B(), T(), C(), b(), R(), q(), _(), V(), F(), L(), M(), I());
|
|
123
125
|
}, 200);
|
|
124
126
|
y("deprecations", () => [
|
|
125
|
-
|
|
127
|
+
G,
|
|
126
128
|
// Return as cleanup function
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
E(document,
|
|
129
|
+
u(document, "click", U, S),
|
|
130
|
+
u(document, "toggle", b, !0),
|
|
131
|
+
E(document, W, {
|
|
130
132
|
attributeFilter: [
|
|
131
133
|
"class",
|
|
132
134
|
"data-command",
|
package/mtds/deprecations.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deprecations.js","sources":["../designsystem/deprecations.ts"],"sourcesContent":["import { DSFieldElement } from \"@digdir/designsystemet-web\";\nimport styles from \"./styles.module.css\";\nimport {\n\tattr,\n\tdebounce,\n\tgetByCSSModule,\n\tisBrowser,\n\ton,\n\tonHotReload,\n\tonMutation,\n\tQUICK_EVENT,\n} from \"./utils\";\n\nconst DEPRECATIONS = new WeakSet<Element>();\nconst deprecate = (el: Element) =>\n\t!DEPRECATIONS.has(el) && DEPRECATIONS.add(el);\n\nconst warn = (from: string, to: string, el: Element) =>\n\twindow.dsWarnings === false ||\n\tconsole.warn(\n\t\t`\\x1B[1m@mattilsynet/design:\\x1B[m ${from} is deprecated, please use ${to}:`,\n\t\tel,\n\t);\n\n// Deprecate togglegroup without data-toggle-group attribute\nconst TOGGLEGROUPS = getByCSSModule(\"togglegroup\");\nconst CSS_BUTTON = styles.button.split(\" \");\nconst deprecateToggleGroup = () => {\n\tfor (const el of TOGGLEGROUPS) {\n\t\tif (deprecate(el) && !el.hasAttribute(\"data-toggle-group\")) {\n\t\t\tattr(el, \"data-toggle-group\", \"Valgknapper\");\n\t\t\twarn(\n\t\t\t\t'Only setting class=\"styles.togglegroup\"',\n\t\t\t\t'data-toggle-group=\"LABEL-HERE\" attribute also for better accessibility',\n\t\t\t\tel,\n\t\t\t);\n\t\t}\n\t\tfor (const label of el.getElementsByTagName(\"label\")) {\n\t\t\tif (deprecate(label) && !label.classList.contains(CSS_BUTTON[0])) {\n\t\t\t\tlabel.classList.add(...CSS_BUTTON);\n\t\t\t\twarn(\n\t\t\t\t\t'Only setting class=\"styles.button\"',\n\t\t\t\t\t`<label class=\"styles.button\">`,\n\t\t\t\t\tlabel,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n};\n\n// Deprecate errorsummary without ds-error-summary element\nconst BREADCRUMBS = getByCSSModule(\"breadcrumbs\");\nconst deprecateBreadcrumbs = () => {\n\tfor (const el of BREADCRUMBS)\n\t\tif (deprecate(el) && el.nodeName !== \"DS-BREADCRUMBS\") {\n\t\t\tel.classList.add(...styles.breadcrumbs.split(\" \"));\n\t\t\twarn(\n\t\t\t\t'Only setting class=\"styles.breadcrumbs\"',\n\t\t\t\t'<ds-breadcrumbs class=\"styles.breadcrumbs\">',\n\t\t\t\tel,\n\t\t\t);\n\t\t}\n};\n\n// Deprecate errorsummary without ds-error-summary element\nconst ERRORSUMMARYS = getByCSSModule(\"errorsummary\");\nconst deprecateErrorSummary = () => {\n\tfor (const el of ERRORSUMMARYS)\n\t\tif (deprecate(el) && el.nodeName !== \"DS-ERROR-SUMMARY\") {\n\t\t\twarn(\n\t\t\t\t'Only setting class=\"styles.errorsummary\"',\n\t\t\t\t'<ds-error-summary class=\"styles.errorsummary\">',\n\t\t\t\tel,\n\t\t\t);\n\t\t}\n};\n\n// Deprecate data-variant and data-modal and data-closedby on dialogs\nconst DIALOGS = getByCSSModule(\"dialog\") as HTMLCollectionOf<HTMLDialogElement>;\nconst deprecateDialog = () => {\n\tfor (const el of DIALOGS) {\n\t\tif (deprecate(el)) {\n\t\t\tconst closedby = attr(el, \"data-closedby\");\n\t\t\tif (closedby) {\n\t\t\t\tattr(el, \"closedby\", closedby);\n\t\t\t\twarn(\n\t\t\t\t\t`<dialog data-closedby=\"${closedby}\">`,\n\t\t\t\t\t`<dialog closedby=\"${closedby}\">`,\n\t\t\t\t\tel,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (el.hasAttribute(\"data-variant\")) {\n\t\t\t\twarn(\n\t\t\t\t\t'<dialog data-variant=\"drawer\">',\n\t\t\t\t\t'<dialog data-placement=\"center|left|right|top|bottom\">',\n\t\t\t\t\tel,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tif (el.isConnected && el.showModal && el.close) {\n\t\t\tif (\n\t\t\t\tel.matches('[open][data-modal]:not([data-modal=\"false\"]):not(:modal)')\n\t\t\t) {\n\t\t\t\twarn(\n\t\t\t\t\t'<dialog data-modal=\"true\">',\n\t\t\t\t\t'.showModal() or <button command=\"show-modal\" commandfor=\"DIALOG-ID\"></button>',\n\t\t\t\t\tel,\n\t\t\t\t);\n\t\t\t\tattr(el, \"open\", null); // Using attribute instead of .close to avoid `close` event\n\t\t\t\tel.showModal();\n\t\t\t} else if (el.matches(\":modal:not([open])\")) {\n\t\t\t\tattr(el, \"open\", \"\"); // Set as open\n\t\t\t\tel.close(); // So we correctly can call .close, removing <dialog> from #top-layer\n\t\t\t}\n\t\t}\n\t}\n};\n\n// Deprecate data-count in favor of data-limit\nconst deprecateCounter = () => {\n\tfor (const el of document.querySelectorAll(\"[data-count]\"))\n\t\tif (deprecate(el)) {\n\t\t\tconst count = attr(el, \"data-count\");\n\t\t\tel.classList.add(...styles.validation.split(\" \"));\n\t\t\tattr(el, \"data-limit\", count);\n\t\t\twarn(\n\t\t\t\t`data-count=\"${count}\"`,\n\t\t\t\t`class=\"styles.validation\" data-field=\"counter\" data-limit=\"${count}\"`,\n\t\t\t\tel,\n\t\t\t);\n\t\t}\n};\n\n// Deprecate data-command on buttons and other elements\nconst deprecateDataCommand = () => {\n\tfor (const el of document.querySelectorAll(\"[data-command]\"))\n\t\tif (deprecate(el)) {\n\t\t\tconst command = attr(el, \"data-command\");\n\n\t\t\tif (command === \"row\")\n\t\t\t\twarn(\n\t\t\t\t\t`<${el.nodeName.toLowerCase()} data-command=\"${command}\">`,\n\t\t\t\t\t`<tr data-clickdelegatefor=\"${el.nodeName}-ID\">`,\n\t\t\t\t\tel,\n\t\t\t\t);\n\t\t\telse\n\t\t\t\twarn(\n\t\t\t\t\t`<button data-command=\"${command}\">`,\n\t\t\t\t\t`<button command=\"${command?.replace(\"toggle-app-expanded\", \"show-modal\")}\" commandfor=\"TARGET-ID\">`,\n\t\t\t\t\tel,\n\t\t\t\t);\n\t\t}\n};\n\n// Deprecate u-tabs\n// const TABS = isBrowser() ? document.getElementsByTagName(\"u-tabs\") : [];\n// const deprecateUTabs = () => {\n// \tfor (const el of TABS) if (deprecate(el)) warn(\"u-tabs\", \"ds-tabs\", el);\n// };\n\n// Deprecate u-combobox and add class to ds-suggestion\nconst CSS_SUGGESTION = styles.suggestion.split(\" \");\nconst OLD = isBrowser() ? document.getElementsByTagName(\"u-combobox\") : [];\nconst NEW = isBrowser() ? document.getElementsByTagName(\"ds-suggestion\") : [];\nconst deprecateUCombobox = () => {\n\tfor (const el of OLD)\n\t\tif (deprecate(el)) {\n\t\t\tel.classList.add(...CSS_SUGGESTION);\n\t\t\twarn(\"<u-combobox>\", `<ds-suggestion class=\"styles.suggestion\">`, el);\n\t\t}\n\tfor (const el of NEW)\n\t\tif (deprecate(el) && !el.classList.contains(CSS_SUGGESTION[0])) {\n\t\t\tel.classList.add(...CSS_SUGGESTION);\n\t\t\twarn(\n\t\t\t\t\"Only using <ds-suggestion>\",\n\t\t\t\t`<ds-suggestion class=\"styles.suggestion\">`,\n\t\t\t\tel,\n\t\t\t);\n\t\t}\n};\n\nconst handleCommandClick = ({ target: el }: Event) => {\n\tif (el instanceof Element === false) return;\n\tconst row = el?.closest(\"tr\")?.querySelector('[data-command=\"row\"]');\n\tconst click =\n\t\trow && !el?.closest('a,button,label,input,select,textarea,[role=\"button\"]');\n\tif (click) (row as HTMLElement).click(); // Forward click to data-command=\"row\" element\n\n\tconst dialog = el?.closest(\"dialog\");\n\tconst close = dialog && el?.closest('[data-command=\"close\"]');\n\tif (close) dialog.close();\n};\n\n// Deprecate fields without ds-field element\nconst FIELDS = getByCSSModule(\"field\");\nconst FIELD_UNBIND = new Set<Element>();\nconst deprecateField = () => {\n\tfor (const el of FIELDS)\n\t\tif (el.nodeName !== \"DS-FIELD\") {\n\t\t\tif (!deprecate(el))\n\t\t\t\twarn(\n\t\t\t\t\t'Only setting class=\"styles.field\"',\n\t\t\t\t\t'<ds-field class=\"styles.field\">',\n\t\t\t\t\tel,\n\t\t\t\t);\n\t\t\tif (!FIELD_UNBIND.has(el) && FIELD_UNBIND.add(el)) {\n\t\t\t\tDSFieldElement.prototype.connectedCallback.call(el as DSFieldElement);\n\t\t\t}\n\t\t}\n};\nconst unbindFields = () => {\n\tfor (const el of FIELD_UNBIND) {\n\t\tDSFieldElement.prototype.disconnectedCallback.call(el as DSFieldElement);\n\t\tFIELD_UNBIND.delete(el);\n\t}\n};\n\n// Deprecate validation without data-field=\"validation\"\nconst CSS_DESCRIPTIONS = `[data-description], .${styles.field.split(\" \")[0]} label + p`;\nconst deprecateFeildDescription = () => {\n\tfor (const el of document.querySelectorAll(CSS_DESCRIPTIONS))\n\t\tif (deprecate(el) && el.getAttribute(\"data-field\") !== \"description\") {\n\t\t\tattr(el, \"data-field\", \"description\");\n\t\t\twarn(\n\t\t\t\t\"Descriptions created by data-description of <p> only\",\n\t\t\t\t'data-field=\"data-description\"',\n\t\t\t\tel,\n\t\t\t);\n\t\t}\n};\n\n// Deprecate validation without data-field=\"validation\"\nconst VALIDATIONS = getByCSSModule(\"validation\");\nconst deprecateFieldValidation = () => {\n\tfor (const el of VALIDATIONS)\n\t\tif (deprecate(el) && !el.hasAttribute(\"data-field\")) {\n\t\t\tattr(el, \"data-field\", \"validation\");\n\t\t\twarn(\n\t\t\t\t'Only setting class=\"styles.validation\"',\n\t\t\t\t'class=\"styles.validation\" data-field=\"validation\"',\n\t\t\t\tel,\n\t\t\t);\n\t\t}\n};\n\nconst deprecatePopoverPosition = () => {\n\tfor (const el of document.querySelectorAll(\"[popover][data-position]\"))\n\t\tif (deprecate(el)) {\n\t\t\tattr(el, \"data-placement\", attr(el, \"data-position\"));\n\t\t\twarn(\"data-position\", \"data-placement\", el);\n\t\t}\n};\n\nconst handleDeprecations = debounce(() => {\n\tdeprecateCounter();\n\tdeprecateDataCommand();\n\tdeprecateBreadcrumbs();\n\tdeprecateDialog();\n\tdeprecateErrorSummary();\n\tdeprecateFeildDescription();\n\tdeprecateFieldValidation();\n\tdeprecatePopoverPosition();\n\tdeprecateField(); // Should run after other field deprecations to access correct data-attributes\n\tdeprecateToggleGroup();\n\tdeprecateUCombobox();\n\t// deprecateUTabs();\n}, 200);\n\nonHotReload(\"deprecations\", () => [\n\tunbindFields, // Return as cleanup function\n\ton(document, \"click\", handleCommandClick, QUICK_EVENT),\n\ton(document, \"toggle\", deprecateDialog, true),\n\tonMutation(document, handleDeprecations, {\n\t\tattributeFilter: [\n\t\t\t\"class\",\n\t\t\t\"data-command\",\n\t\t\t\"data-count\",\n\t\t\t\"data-description\",\n\t\t\t\"data-variant\",\n\t\t\t\"open\",\n\t\t],\n\t\tattributes: true,\n\t\tchildList: true,\n\t\tsubtree: true,\n\t}),\n]);\n"],"names":["DEPRECATIONS","deprecate","el","warn","from","to","TOGGLEGROUPS","getByCSSModule","CSS_BUTTON","styles","deprecateToggleGroup","attr","label","BREADCRUMBS","deprecateBreadcrumbs","ERRORSUMMARYS","deprecateErrorSummary","DIALOGS","deprecateDialog","closedby","deprecateCounter","count","deprecateDataCommand","command","CSS_SUGGESTION","OLD","isBrowser","NEW","deprecateUCombobox","handleCommandClick","row","dialog","FIELDS","FIELD_UNBIND","deprecateField","DSFieldElement","unbindFields","CSS_DESCRIPTIONS","deprecateFeildDescription","VALIDATIONS","deprecateFieldValidation","deprecatePopoverPosition","handleDeprecations","debounce","onHotReload","on","QUICK_EVENT","onMutation"],"mappings":";;;AAaA,MAAMA,wBAAmB,QAAA,GACnBC,IAAY,CAACC,MAClB,CAACF,EAAa,IAAIE,CAAE,KAAKF,EAAa,IAAIE,CAAE,GAEvCC,IAAO,CAACC,GAAcC,GAAYH,MACvC,OAAO,eAAe,MACtB,QAAQ;AAAA,EACP,qCAAqCE,CAAI,8BAA8BC,CAAE;AAAA,EACzEH;AACD,GAGKI,IAAeC,EAAe,aAAa,GAC3CC,IAAaC,EAAO,OAAO,MAAM,GAAG,GACpCC,IAAuB,MAAM;AAClC,aAAWR,KAAMI,GAAc;AAC9B,IAAIL,EAAUC,CAAE,KAAK,CAACA,EAAG,aAAa,mBAAmB,MACxDS,EAAKT,GAAI,qBAAqB,aAAa,GAC3CC;AAAA,MACC;AAAA,MACA;AAAA,MACAD;AAAA,IAAA;AAGF,eAAWU,KAASV,EAAG,qBAAqB,OAAO;AAClD,MAAID,EAAUW,CAAK,KAAK,CAACA,EAAM,UAAU,SAASJ,EAAW,CAAC,CAAC,MAC9DI,EAAM,UAAU,IAAI,GAAGJ,CAAU,GACjCL;AAAA,QACC;AAAA,QACA;AAAA,QACAS;AAA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AS,iBAAiB,0BAA0B;AACpE,IAAID,EAAUC,CAAE,MACfS,EAAKT,GAAI,kBAAkBS,EAAKT,GAAI,eAAe,CAAC,GACpDC,EAAK,iBAAiB,kBAAkBD,CAAE;AAE7C,GAEMwC,IAAqBC,EAAS,MAAM;AACzC,EAAAvB,EAAA,GACAE,EAAA,GACAR,EAAA,GACAI,EAAA,GACAF,EAAA,GACAsB,EAAA,GACAE,EAAA,GACAC,EAAA,GACAP,EAAA,GACAxB,EAAA,GACAkB,EAAA;AAED,GAAG,GAAG;AAENgB,EAAY,gBAAgB,MAAM;AAAA,EACjCR;AAAA;AAAA,EACAS,EAAG,UAAU,SAAShB,GAAoBiB,CAAW;AAAA,EACrDD,EAAG,UAAU,UAAU3B,GAAiB,EAAI;AAAA,EAC5C6B,EAAW,UAAUL,GAAoB;AAAA,IACxC,iBAAiB;AAAA,MAChB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,IAED,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,SAAS;AAAA,EAAA,CACT;AACF,CAAC;"}
|
|
1
|
+
{"version":3,"file":"deprecations.js","sources":["../designsystem/deprecations.ts"],"sourcesContent":["import { DSFieldElement } from \"@digdir/designsystemet-web\";\nimport styles from \"./styles.module.css\";\nimport {\n\tattr,\n\tdebounce,\n\tgetByCSSModule,\n\tisBrowser,\n\ton,\n\tonHotReload,\n\tonMutation,\n\tQUICK_EVENT,\n} from \"./utils\";\n\nconst DEPRECATIONS = new WeakSet<Element>();\nconst deprecate = (el: Element) =>\n\t!DEPRECATIONS.has(el) && DEPRECATIONS.add(el);\n\nconst warn = (from: string, to: string, el: Element) =>\n\twindow.dsWarnings === false ||\n\tconsole.warn(\n\t\t`\\x1B[1m@mattilsynet/design:\\x1B[m ${from} is deprecated, please use ${to}:`,\n\t\tel,\n\t);\n\n// Deprecate togglegroup without data-toggle-group attribute\nconst TOGGLEGROUPS = getByCSSModule(\"togglegroup\");\nconst CSS_BUTTON = styles.button.split(\" \");\nconst deprecateToggleGroup = () => {\n\tfor (const el of TOGGLEGROUPS) {\n\t\tif (deprecate(el) && !el.hasAttribute(\"data-toggle-group\")) {\n\t\t\tattr(el, \"data-toggle-group\", \"Valgknapper\");\n\t\t\twarn(\n\t\t\t\t'Only setting class=\"styles.togglegroup\"',\n\t\t\t\t'data-toggle-group=\"LABEL-HERE\" attribute also for better accessibility',\n\t\t\t\tel,\n\t\t\t);\n\t\t}\n\t\tfor (const label of el.getElementsByTagName(\"label\")) {\n\t\t\tif (deprecate(label) && !label.classList.contains(CSS_BUTTON[0])) {\n\t\t\t\tlabel.classList.add(...CSS_BUTTON);\n\t\t\t\twarn(\n\t\t\t\t\t'Only setting class=\"styles.button\"',\n\t\t\t\t\t`<label class=\"styles.button\">`,\n\t\t\t\t\tlabel,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n};\n\n// Deprecate errorsummary without ds-error-summary element\nconst BREADCRUMBS = getByCSSModule(\"breadcrumbs\");\nconst deprecateBreadcrumbs = () => {\n\tfor (const el of BREADCRUMBS)\n\t\tif (deprecate(el) && el.nodeName !== \"DS-BREADCRUMBS\") {\n\t\t\tel.classList.add(...styles.breadcrumbs.split(\" \"));\n\t\t\twarn(\n\t\t\t\t'Only setting class=\"styles.breadcrumbs\"',\n\t\t\t\t'<ds-breadcrumbs class=\"styles.breadcrumbs\">',\n\t\t\t\tel,\n\t\t\t);\n\t\t}\n};\n\n// Deprecate errorsummary without ds-error-summary element\nconst ERRORSUMMARYS = getByCSSModule(\"errorsummary\");\nconst deprecateErrorSummary = () => {\n\tfor (const el of ERRORSUMMARYS)\n\t\tif (deprecate(el) && el.nodeName !== \"DS-ERROR-SUMMARY\") {\n\t\t\twarn(\n\t\t\t\t'Only setting class=\"styles.errorsummary\"',\n\t\t\t\t'<ds-error-summary class=\"styles.errorsummary\">',\n\t\t\t\tel,\n\t\t\t);\n\t\t}\n};\n\n// Deprecate data-variant and data-modal and data-closedby on dialogs\nconst DIALOGS = getByCSSModule(\"dialog\") as HTMLCollectionOf<HTMLDialogElement>;\nconst deprecateDialog = () => {\n\tfor (const el of DIALOGS) {\n\t\tif (deprecate(el)) {\n\t\t\tconst closedby = attr(el, \"data-closedby\");\n\t\t\tif (closedby) {\n\t\t\t\tattr(el, \"closedby\", closedby);\n\t\t\t\twarn(\n\t\t\t\t\t`<dialog data-closedby=\"${closedby}\">`,\n\t\t\t\t\t`<dialog closedby=\"${closedby}\">`,\n\t\t\t\t\tel,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (el.hasAttribute(\"data-variant\")) {\n\t\t\t\twarn(\n\t\t\t\t\t'<dialog data-variant=\"drawer\">',\n\t\t\t\t\t'<dialog data-placement=\"center|left|right|top|bottom\">',\n\t\t\t\t\tel,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tif (el.isConnected && el.showModal && el.close) {\n\t\t\tif (\n\t\t\t\tel.matches('[open][data-modal]:not([data-modal=\"false\"]):not(:modal)')\n\t\t\t) {\n\t\t\t\twarn(\n\t\t\t\t\t'<dialog data-modal=\"true\">',\n\t\t\t\t\t'.showModal() or <button command=\"show-modal\" commandfor=\"DIALOG-ID\"></button>',\n\t\t\t\t\tel,\n\t\t\t\t);\n\t\t\t\tattr(el, \"open\", null); // Using attribute instead of .close to avoid `close` event\n\t\t\t\tel.showModal();\n\t\t\t} else if (el.matches(\":modal:not([open])\")) {\n\t\t\t\tattr(el, \"open\", \"\"); // Set as open\n\t\t\t\tel.close(); // So we correctly can call .close, removing <dialog> from #top-layer\n\t\t\t}\n\t\t}\n\t}\n};\n\n// Deprecate data-count in favor of data-limit\nconst deprecateCounter = () => {\n\tfor (const el of document.querySelectorAll(\"[data-count]\"))\n\t\tif (deprecate(el)) {\n\t\t\tconst count = attr(el, \"data-count\");\n\t\t\tel.classList.add(...styles.validation.split(\" \"));\n\t\t\tattr(el, \"data-limit\", count);\n\t\t\twarn(\n\t\t\t\t`data-count=\"${count}\"`,\n\t\t\t\t`class=\"styles.validation\" data-field=\"counter\" data-limit=\"${count}\"`,\n\t\t\t\tel,\n\t\t\t);\n\t\t}\n};\n\n// Deprecate data-command on buttons and other elements\nconst deprecateDataCommand = () => {\n\tfor (const el of document.querySelectorAll(\"[data-command]\"))\n\t\tif (deprecate(el)) {\n\t\t\tconst command = attr(el, \"data-command\");\n\n\t\t\tif (command === \"row\")\n\t\t\t\twarn(\n\t\t\t\t\t`<${el.nodeName.toLowerCase()} data-command=\"${command}\">`,\n\t\t\t\t\t`<tr data-clickdelegatefor=\"${el.nodeName}-ID\">`,\n\t\t\t\t\tel,\n\t\t\t\t);\n\t\t\telse\n\t\t\t\twarn(\n\t\t\t\t\t`<button data-command=\"${command}\">`,\n\t\t\t\t\t`<button command=\"${command?.replace(\"toggle-app-expanded\", \"show-modal\")}\" commandfor=\"TARGET-ID\">`,\n\t\t\t\t\tel,\n\t\t\t\t);\n\t\t}\n};\n\n// Deprecate u-tabs\nconst TABS = isBrowser() ? document.getElementsByTagName(\"u-tabs\") : [];\nconst deprecateUTabs = () => {\n\tfor (const el of TABS) if (deprecate(el)) warn(\"u-tabs\", \"ds-tabs\", el);\n};\n\n// Deprecate u-combobox and add class to ds-suggestion\nconst CSS_SUGGESTION = styles.suggestion.split(\" \");\nconst OLD = isBrowser() ? document.getElementsByTagName(\"u-combobox\") : [];\nconst NEW = isBrowser() ? document.getElementsByTagName(\"ds-suggestion\") : [];\nconst deprecateUCombobox = () => {\n\tfor (const el of OLD)\n\t\tif (deprecate(el)) {\n\t\t\tel.classList.add(...CSS_SUGGESTION);\n\t\t\twarn(\"<u-combobox>\", `<ds-suggestion class=\"styles.suggestion\">`, el);\n\t\t}\n\tfor (const el of NEW)\n\t\tif (deprecate(el) && !el.classList.contains(CSS_SUGGESTION[0])) {\n\t\t\tel.classList.add(...CSS_SUGGESTION);\n\t\t\twarn(\n\t\t\t\t\"Only using <ds-suggestion>\",\n\t\t\t\t`<ds-suggestion class=\"styles.suggestion\">`,\n\t\t\t\tel,\n\t\t\t);\n\t\t}\n};\n\nconst handleCommandClick = ({ target: el }: Event) => {\n\tif (el instanceof Element === false) return;\n\tconst row = el?.closest(\"tr\")?.querySelector('[data-command=\"row\"]');\n\tconst click =\n\t\trow && !el?.closest('a,button,label,input,select,textarea,[role=\"button\"]');\n\tif (click) (row as HTMLElement).click(); // Forward click to data-command=\"row\" element\n\n\tconst dialog = el?.closest(\"dialog\");\n\tconst close = dialog && el?.closest('[data-command=\"close\"]');\n\tif (close) dialog.close();\n};\n\n// Deprecate fields without ds-field element\nconst FIELDS = getByCSSModule(\"field\");\nconst FIELD_UNBIND = new Set<Element>();\nconst deprecateField = () => {\n\tfor (const el of FIELDS)\n\t\tif (el.nodeName !== \"DS-FIELD\") {\n\t\t\tif (!deprecate(el))\n\t\t\t\twarn(\n\t\t\t\t\t'Only setting class=\"styles.field\"',\n\t\t\t\t\t'<ds-field class=\"styles.field\">',\n\t\t\t\t\tel,\n\t\t\t\t);\n\t\t\tif (!FIELD_UNBIND.has(el) && FIELD_UNBIND.add(el)) {\n\t\t\t\tDSFieldElement.prototype.connectedCallback.call(el as DSFieldElement);\n\t\t\t}\n\t\t}\n};\nconst unbindFields = () => {\n\tfor (const el of FIELD_UNBIND) {\n\t\tDSFieldElement.prototype.disconnectedCallback.call(el as DSFieldElement);\n\t\tFIELD_UNBIND.delete(el);\n\t}\n};\n\n// Deprecate validation without data-field=\"validation\"\nconst CSS_DESCRIPTIONS = `[data-description], .${styles.field.split(\" \")[0]} label + p`;\nconst deprecateFeildDescription = () => {\n\tfor (const el of document.querySelectorAll(CSS_DESCRIPTIONS))\n\t\tif (deprecate(el) && el.getAttribute(\"data-field\") !== \"description\") {\n\t\t\tattr(el, \"data-field\", \"description\");\n\t\t\twarn(\n\t\t\t\t\"Descriptions created by data-description of <p> only\",\n\t\t\t\t'data-field=\"data-description\"',\n\t\t\t\tel,\n\t\t\t);\n\t\t}\n};\n\n// Deprecate validation without data-field=\"validation\"\nconst VALIDATIONS = getByCSSModule(\"validation\");\nconst deprecateFieldValidation = () => {\n\tfor (const el of VALIDATIONS)\n\t\tif (deprecate(el) && !el.hasAttribute(\"data-field\")) {\n\t\t\tattr(el, \"data-field\", \"validation\");\n\t\t\twarn(\n\t\t\t\t'Only setting class=\"styles.validation\"',\n\t\t\t\t'class=\"styles.validation\" data-field=\"validation\"',\n\t\t\t\tel,\n\t\t\t);\n\t\t}\n};\n\nconst deprecatePopoverPosition = () => {\n\tfor (const el of document.querySelectorAll(\"[popover][data-position]\"))\n\t\tif (deprecate(el)) {\n\t\t\tattr(el, \"data-placement\", attr(el, \"data-position\"));\n\t\t\twarn(\"data-position\", \"data-placement\", el);\n\t\t}\n};\n\nconst handleDeprecations = debounce(() => {\n\tif (!isBrowser()) return; // Check if document is still available, since this can run in test environments after document is destroyed\n\tdeprecateCounter();\n\tdeprecateDataCommand();\n\tdeprecateBreadcrumbs();\n\tdeprecateDialog();\n\tdeprecateErrorSummary();\n\tdeprecateFeildDescription();\n\tdeprecateFieldValidation();\n\tdeprecatePopoverPosition();\n\tdeprecateField(); // Should run after other field deprecations to access correct data-attributes\n\tdeprecateToggleGroup();\n\tdeprecateUCombobox();\n\tdeprecateUTabs();\n}, 200);\n\nonHotReload(\"deprecations\", () => [\n\tunbindFields, // Return as cleanup function\n\ton(document, \"click\", handleCommandClick, QUICK_EVENT),\n\ton(document, \"toggle\", deprecateDialog, true),\n\tonMutation(document, handleDeprecations, {\n\t\tattributeFilter: [\n\t\t\t\"class\",\n\t\t\t\"data-command\",\n\t\t\t\"data-count\",\n\t\t\t\"data-description\",\n\t\t\t\"data-variant\",\n\t\t\t\"open\",\n\t\t],\n\t\tattributes: true,\n\t\tchildList: true,\n\t\tsubtree: true,\n\t}),\n]);\n"],"names":["DEPRECATIONS","deprecate","el","warn","from","to","TOGGLEGROUPS","getByCSSModule","CSS_BUTTON","styles","deprecateToggleGroup","attr","label","BREADCRUMBS","deprecateBreadcrumbs","ERRORSUMMARYS","deprecateErrorSummary","DIALOGS","deprecateDialog","closedby","deprecateCounter","count","deprecateDataCommand","command","TABS","isBrowser","deprecateUTabs","CSS_SUGGESTION","OLD","NEW","deprecateUCombobox","handleCommandClick","row","dialog","FIELDS","FIELD_UNBIND","deprecateField","DSFieldElement","unbindFields","CSS_DESCRIPTIONS","deprecateFeildDescription","VALIDATIONS","deprecateFieldValidation","deprecatePopoverPosition","handleDeprecations","debounce","onHotReload","on","QUICK_EVENT","onMutation"],"mappings":";;;AAaA,MAAMA,wBAAmB,QAAA,GACnBC,IAAY,CAACC,MAClB,CAACF,EAAa,IAAIE,CAAE,KAAKF,EAAa,IAAIE,CAAE,GAEvCC,IAAO,CAACC,GAAcC,GAAYH,MACvC,OAAO,eAAe,MACtB,QAAQ;AAAA,EACP,qCAAqCE,CAAI,8BAA8BC,CAAE;AAAA,EACzEH;AACD,GAGKI,IAAeC,EAAe,aAAa,GAC3CC,IAAaC,EAAO,OAAO,MAAM,GAAG,GACpCC,IAAuB,MAAM;AAClC,aAAWR,KAAMI,GAAc;AAC9B,IAAIL,EAAUC,CAAE,KAAK,CAACA,EAAG,aAAa,mBAAmB,MACxDS,EAAKT,GAAI,qBAAqB,aAAa,GAC3CC;AAAA,MACC;AAAA,MACA;AAAA,MACAD;AAAA,IAAA;AAGF,eAAWU,KAASV,EAAG,qBAAqB,OAAO;AAClD,MAAID,EAAUW,CAAK,KAAK,CAACA,EAAM,UAAU,SAASJ,EAAW,CAAC,CAAC,MAC9DI,EAAM,UAAU,IAAI,GAAGJ,CAAU,GACjCL;AAAA,QACC;AAAA,QACA;AAAA,QACAS;AAAA,MAAA;AAAA,EAIJ;AACD,GAGMC,IAAcN,EAAe,aAAa,GAC1CO,IAAuB,MAAM;AAClC,aAAWZ,KAAMW;AAChB,IAAIZ,EAAUC,CAAE,KAAKA,EAAG,aAAa,qBACpCA,EAAG,UAAU,IAAI,GAAGO,EAAO,YAAY,MAAM,GAAG,CAAC,GACjDN;AAAA,MACC;AAAA,MACA;AAAA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,kBAAkBS,EAAKT,GAAI,eAAe,CAAC,GACpDC,EAAK,iBAAiB,kBAAkBD,CAAE;AAE7C,GAEM0C,IAAqBC,EAAS,MAAM;AACzC,EAAKpB,QACLL,EAAA,GACAE,EAAA,GACAR,EAAA,GACAI,EAAA,GACAF,EAAA,GACAwB,EAAA,GACAE,EAAA,GACAC,EAAA,GACAP,EAAA,GACA1B,EAAA,GACAoB,EAAA,GACAJ,EAAA;AACD,GAAG,GAAG;AAENoB,EAAY,gBAAgB,MAAM;AAAA,EACjCR;AAAA;AAAA,EACAS,EAAG,UAAU,SAAShB,GAAoBiB,CAAW;AAAA,EACrDD,EAAG,UAAU,UAAU7B,GAAiB,EAAI;AAAA,EAC5C+B,EAAW,UAAUL,GAAoB;AAAA,IACxC,iBAAiB;AAAA,MAChB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,IAED,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,SAAS;AAAA,EAAA,CACT;AACF,CAAC;"}
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
var Y = Object.defineProperty, R = Object.getOwnPropertySymbols, z = Object.prototype.hasOwnProperty, G = Object.prototype.propertyIsEnumerable, $ = (t, e, o) => e in t ? Y(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o, J = (t, e) => {
|
|
2
|
+
for (var o in e || (e = {}))
|
|
3
|
+
z.call(e, o) && $(t, o, e[o]);
|
|
4
|
+
if (R)
|
|
5
|
+
for (var o of R(e))
|
|
6
|
+
G.call(e, o) && $(t, o, e[o]);
|
|
7
|
+
return t;
|
|
8
|
+
}, T = () => typeof window < "u" && typeof window.document < "u" && typeof window.navigator < "u", g = T(), k = g ? navigator.userAgent : "", P = /android/i.test(k), Q = /firefox/i.test(k), B = /iPad|iPhone|iPod/.test(k), D, Z = g && // @ts-expect-error Typescript has not implemented userAgentData yet https://stackoverflow.com/a/71392474
|
|
9
|
+
/^Mac/i.test(((D = navigator.userAgentData) == null ? void 0 : D.platform) || navigator.platform), tt = g && window.CSSStyleSheet && document.adoptedStyleSheets, H = { once: !0, capture: !0, passive: !0 }, et = ":host(:not([hidden])) { display: block }", ot = "outline: 1px dotted; outline: 5px auto Highlight; outline: 5px auto -webkit-focus-ring-color", nt = `${P ? "data" : "aria"}-multiselectable`, it = typeof HTMLElement > "u" ? class {
|
|
10
|
+
} : HTMLElement, s = (t, e, o) => o === void 0 ? t.getAttribute(e) : (o === null ? t.removeAttribute(e) : t.getAttribute(e) !== o && t.setAttribute(e, o), null), L = (t, ...e) => {
|
|
11
|
+
const [o, ...n] = e;
|
|
12
|
+
for (const i of o.split(" ")) t.addEventListener(i, ...n);
|
|
13
|
+
return () => K(t, ...e);
|
|
14
|
+
}, K = (t, ...e) => {
|
|
15
|
+
const [o, ...n] = e;
|
|
16
|
+
for (const i of o.split(" ")) t.removeEventListener(i, ...n);
|
|
17
|
+
}, rt = (t, e) => {
|
|
18
|
+
const o = t.shadowRoot || t.attachShadow({ mode: "open" });
|
|
19
|
+
if (o.querySelector("slot") || o.append(y("slot")), !o.querySelector("style"))
|
|
20
|
+
if (!tt) o.append(y("style", null, e));
|
|
21
|
+
else {
|
|
22
|
+
const n = new CSSStyleSheet();
|
|
23
|
+
n.replaceSync(e), o.adoptedStyleSheets = [n];
|
|
24
|
+
}
|
|
25
|
+
return o;
|
|
26
|
+
}, at = (t, e, o) => {
|
|
27
|
+
const n = new MutationObserver((r) => {
|
|
28
|
+
if (!T() || !t.isConnected) return i();
|
|
29
|
+
e(t, r);
|
|
30
|
+
}), i = Object.assign(() => n.disconnect(), {
|
|
31
|
+
takeRecords: () => n.takeRecords()
|
|
32
|
+
// Expose takeRecords - useful if mutating a attribute that is observed
|
|
33
|
+
});
|
|
34
|
+
return e(t), n.observe(t, o), i;
|
|
35
|
+
}, lt = (t) => {
|
|
36
|
+
var e;
|
|
37
|
+
const o = ((e = t.getRootNode) == null ? void 0 : e.call(t)) || t.ownerDocument;
|
|
38
|
+
return o instanceof Document || o instanceof ShadowRoot ? o : document;
|
|
39
|
+
}, O = (t) => lt(t).activeElement, st = (t) => {
|
|
40
|
+
var e;
|
|
41
|
+
const o = s(t, "aria-label") || "";
|
|
42
|
+
return [
|
|
43
|
+
...(((e = s(t, "aria-labelledby")) == null ? void 0 : e.split(" ")) || []).map((i) => document.getElementById(i.trim() || "-")),
|
|
44
|
+
// Get all labelledby elements
|
|
45
|
+
...Array.from(t.labels || [])
|
|
46
|
+
// Get all <label> elements
|
|
47
|
+
].reduce((i, r) => {
|
|
48
|
+
var l;
|
|
49
|
+
return i || ((l = r?.innerText) == null ? void 0 : l.trim()) || "";
|
|
50
|
+
}, o).trim();
|
|
51
|
+
}, ut = (t) => {
|
|
52
|
+
if (!t || !g) return null;
|
|
53
|
+
if (window.uElementsId || (window.uElementsId = {}), !t.id) {
|
|
54
|
+
const e = t.nodeName.toLowerCase();
|
|
55
|
+
window.uElementsId[e] || (window.uElementsId[e] = 1), t.id = `:${e}${window.uElementsId[e]++}`;
|
|
56
|
+
}
|
|
57
|
+
return t.id;
|
|
58
|
+
}, y = (t, e, o) => {
|
|
59
|
+
const n = document.createElement(t);
|
|
60
|
+
if (o && (n.textContent = o), e) for (const [i, r] of Object.entries(e)) s(n, i, r);
|
|
61
|
+
return n;
|
|
62
|
+
}, ct = {
|
|
63
|
+
define: (t, e) => !T() || window.customElements.get(t) || window.customElements.define(t, e)
|
|
64
|
+
}, V = (t, e, o = "") => {
|
|
65
|
+
var n, i;
|
|
66
|
+
const r = { bubbles: !0, composed: !0, data: e, inputType: o }, l = HTMLInputElement.prototype;
|
|
67
|
+
t.dispatchEvent(new InputEvent("beforeinput", r)), (i = (n = Object.getOwnPropertyDescriptor(l, "value")) == null ? void 0 : n.set) == null || i.call(t, e), t.dispatchEvent(new InputEvent("input", r)), t.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
68
|
+
}, I = /* @__PURE__ */ new WeakSet(), q = (t, e) => (e?.type === "pointerdown" && (I.add(t), L(document, "pointerup", () => I.delete(t), H)), I.has(t)), dt = (t, e = "<slot></slot>") => `<template shadowrootmode="open">${e}<style>${t}</style></template>`, vt = (t) => {
|
|
69
|
+
const e = s(t, "form");
|
|
70
|
+
s(t, "form", "#"), setTimeout(pt, 0, t, e);
|
|
71
|
+
}, pt = (t, e) => s(t, "form", e), _ = (t) => {
|
|
72
|
+
var e;
|
|
73
|
+
return ((e = t?.textContent) == null ? void 0 : e.trim()) || "";
|
|
74
|
+
}, m, mt = 0, M = 0, x = (t) => {
|
|
75
|
+
clearTimeout(M), m || (m = y("div", { "aria-live": "assertive" }), m.style.overflow = "hidden", m.style.position = "fixed", m.style.whiteSpace = "nowrap", m.style.width = "1px"), m.isConnected || document.body.append(m), t === "" && (m.textContent = ""), t && (m.textContent = `${t}${mt++ % 2 ? " " : ""}`, M = setTimeout(x, !Z && Q ? 2e3 : 300, ""));
|
|
76
|
+
}, U = `${et}
|
|
77
|
+
:is(:host(:not([data-multiple])), :host([data-multiple="false"])) [part="items"] { display: none }
|
|
78
|
+
[role="listbox"] { display: contents }
|
|
79
|
+
::slotted(button[type="reset"]),::slotted(del) { font: inherit; border: 0; padding: 0; background: none; color: inherit; cursor: pointer; text-decoration: none }
|
|
80
|
+
::slotted(data) { cursor: pointer; pointer-events: none }
|
|
81
|
+
::slotted(data)::after { padding-inline: .5ch; pointer-events: auto }
|
|
82
|
+
::slotted(data)::after,::slotted(button[type="reset"]:empty)::before,::slotted(del:empty)::before { content: '\\00D7'; content: '\\00D7' / '' }
|
|
83
|
+
::slotted(data:focus),::slotted(del:focus),::slotted(button[type="reset"]:focus) { ${ot} }`, Lt = dt(U), f = "aria-label", ft = 'button[type="reset"],del', ht = 'datalist,[role="listbox"]', _t = 'option,[role="option"]', N = "blur focus click input keydown pointerdown", S = "false", w = {
|
|
84
|
+
added: "Added",
|
|
85
|
+
clear: "Clear input",
|
|
86
|
+
empty: "No selected",
|
|
87
|
+
found: "Navigate left to find %d selected",
|
|
88
|
+
invalid: "Invalid value",
|
|
89
|
+
items: "Selected",
|
|
90
|
+
// Note: Not announced by NVDA
|
|
91
|
+
of: "of",
|
|
92
|
+
remove: "Press to remove",
|
|
93
|
+
removed: "Removed"
|
|
94
|
+
}, bt = class extends it {
|
|
95
|
+
constructor() {
|
|
96
|
+
super(), this._focusMoved = !1, this._itemSingleVale = "", this._speak = "", this._texts = J({}, w), this._value = "";
|
|
97
|
+
const t = rt(this, U);
|
|
98
|
+
this._listbox = t.querySelector('[role="listbox"]') || y("div"), this._listbox.innerHTML = '<slot name="items"></slot>', s(this._listbox, "aria-orientation", "horizontal"), s(this._listbox, "role", "listbox"), s(this._listbox, "part", "items"), s(this._listbox, "tabindex", "-1"), t.prepend(this._listbox);
|
|
99
|
+
}
|
|
100
|
+
// Locally store value to store value before input-click
|
|
101
|
+
static get observedAttributes() {
|
|
102
|
+
return Object.keys(w).map((t) => `data-sr-${t}`);
|
|
103
|
+
}
|
|
104
|
+
connectedCallback() {
|
|
105
|
+
L(this, N, this, !0), this._umutate = at(this, It, {
|
|
106
|
+
attributeFilter: ["id", "value", "role"],
|
|
107
|
+
// Respond to changes in <data> value or id or role of <datalist>
|
|
108
|
+
attributes: !0,
|
|
109
|
+
characterData: !0,
|
|
110
|
+
// Respond to changes in <data> textContent
|
|
111
|
+
childList: !0,
|
|
112
|
+
subtree: !0
|
|
113
|
+
}), E(this), A(this);
|
|
114
|
+
}
|
|
115
|
+
attributeChangedCallback(t, e, o) {
|
|
116
|
+
const n = t.split("data-sr-")[1];
|
|
117
|
+
w[n] && (this._texts[n] = o || w[n]), n === "clear" && this.clear && s(this.clear, f, this._texts.clear);
|
|
118
|
+
}
|
|
119
|
+
disconnectedCallback() {
|
|
120
|
+
var t;
|
|
121
|
+
K(this, N, this, !0), (t = this._umutate) == null || t.call(this), this._umutate = this._list = this._options = this._match = void 0, this._items = this._clear = this._control = this._select = void 0;
|
|
122
|
+
}
|
|
123
|
+
handleEvent(t) {
|
|
124
|
+
var e, o;
|
|
125
|
+
(e = this.control) != null && e.disabled || (o = this.control) != null && o.readOnly || (t.type === "blur" && yt(this), t.type === "click" && wt(this, t), t.type === "focus" && x(), t.type === "input" && Et(this, t), t.type === "keydown" && gt(this, t), t.type === "pointerdown" && q(this, t));
|
|
126
|
+
}
|
|
127
|
+
get multiple() {
|
|
128
|
+
var t;
|
|
129
|
+
return ((t = s(this, "data-multiple")) != null ? t : S) !== S;
|
|
130
|
+
}
|
|
131
|
+
set multiple(t) {
|
|
132
|
+
s(this, "data-multiple", t ? "" : null);
|
|
133
|
+
}
|
|
134
|
+
get creatable() {
|
|
135
|
+
var t;
|
|
136
|
+
return ((t = s(this, "data-creatable")) != null ? t : S) !== S;
|
|
137
|
+
}
|
|
138
|
+
set creatable(t) {
|
|
139
|
+
s(this, "data-creatable", t ? "" : null);
|
|
140
|
+
}
|
|
141
|
+
get control() {
|
|
142
|
+
var t;
|
|
143
|
+
return (t = this._control) != null && t.isConnected || (this._control = this.querySelector("input")), this._control;
|
|
144
|
+
}
|
|
145
|
+
get list() {
|
|
146
|
+
var t;
|
|
147
|
+
return (t = this._list) != null && t.isConnected || (this._list = this.querySelector(ht), this._options = void 0), this._list;
|
|
148
|
+
}
|
|
149
|
+
get clear() {
|
|
150
|
+
var t;
|
|
151
|
+
return (t = this._clear) != null && t.isConnected || (this._clear = this.querySelector(ft)), this._clear;
|
|
152
|
+
}
|
|
153
|
+
get items() {
|
|
154
|
+
return this._items || (this._items = this.getElementsByTagName("data")), this._items;
|
|
155
|
+
}
|
|
156
|
+
get options() {
|
|
157
|
+
var t, e, o;
|
|
158
|
+
const n = !this._options && ((e = (t = this.list) == null ? void 0 : t.querySelector(_t)) == null ? void 0 : e.nodeName);
|
|
159
|
+
return n && (this._options = (o = this.list) == null ? void 0 : o.getElementsByTagName(n)), this._options || this.getElementsByTagName("-");
|
|
160
|
+
}
|
|
161
|
+
get values() {
|
|
162
|
+
return Array.from(this.items, ({ value: t }) => t);
|
|
163
|
+
}
|
|
164
|
+
}, j = (t) => {
|
|
165
|
+
var e;
|
|
166
|
+
const { creatable: o, control: n, options: i, multiple: r } = t, l = ((e = n?.value) == null ? void 0 : e.trim()) || "", u = l.toLowerCase() || null;
|
|
167
|
+
let a = [...i].find((c) => c.label.trim().toLowerCase() === u);
|
|
168
|
+
const d = { bubbles: !0, cancelable: !0, detail: a };
|
|
169
|
+
if (t.dispatchEvent(new CustomEvent("comboboxbeforematch", d)) || (a = [...i].find((c) => c.selected)), r) W(t);
|
|
170
|
+
else for (const c of i) c.selected = c === a;
|
|
171
|
+
return !a && o && l ? { value: l, label: l } : a && { value: a.value, label: a.label };
|
|
172
|
+
}, b = (t, e, o = !0) => {
|
|
173
|
+
const { _texts: n, control: i, items: r, multiple: l } = t;
|
|
174
|
+
if (!e)
|
|
175
|
+
return l ? x(n.invalid) : !i?.value && r[0] ? b(t, r[0]) : E(t);
|
|
176
|
+
const u = [...r].findIndex((p) => p.value === e.value), a = r[u], d = a === O(t) && (l && (r[u - 1] || r[u + 1]) || i);
|
|
177
|
+
if (a && !o) return E(t);
|
|
178
|
+
d && d.focus(), t._focusMoved = !!d;
|
|
179
|
+
const c = y("data", { value: e.value }, e.label || e.value), v = { bubbles: !0, cancelable: !0, detail: a || c };
|
|
180
|
+
if (t.dispatchEvent(new CustomEvent("comboboxbeforeselect", v))) {
|
|
181
|
+
if (!l) for (const p of [...r]) p.remove();
|
|
182
|
+
a ? a.remove() : i?.insertAdjacentElement("beforebegin", c), t.dispatchEvent(new CustomEvent("comboboxafterselect", v));
|
|
183
|
+
}
|
|
184
|
+
}, yt = (t) => q(t) || setTimeout(St, 0, t), St = (t) => t.multiple || t.contains(O(t)) || b(t, t._match, !1), wt = (t, e) => {
|
|
185
|
+
const { clientX: o, clientY: n, target: i } = e, { clear: r, control: l, items: u } = t;
|
|
186
|
+
if (l && r?.contains(i))
|
|
187
|
+
return e.preventDefault(), V(l, "", "deleteContentBackward"), l.focus();
|
|
188
|
+
for (const a of u) {
|
|
189
|
+
if (a.contains(i)) return b(t, a);
|
|
190
|
+
const d = a.getBoundingClientRect(), { top: c, right: v, bottom: p, left: C, width: h, height: X } = d;
|
|
191
|
+
if (h && X && n >= c && n <= p && o >= C && o <= v) return a.focus();
|
|
192
|
+
}
|
|
193
|
+
i === t && l?.focus();
|
|
194
|
+
}, Et = (t, e) => {
|
|
195
|
+
var o;
|
|
196
|
+
const { control: n, options: i, multiple: r } = t, l = n?.value || null, u = e instanceof InputEvent ? !e.inputType || e.inputType === "insertReplacementText" : !!n?.value;
|
|
197
|
+
if (u || (t._value = n?.value || ""), u) {
|
|
198
|
+
(o = e.stopImmediatePropagation) == null || o.call(e);
|
|
199
|
+
const a = [...i].find((d) => d.value === l);
|
|
200
|
+
if (n && (n.value = t._value), a) return b(t, a, r);
|
|
201
|
+
} else r || (t._match = j(t));
|
|
202
|
+
A(t);
|
|
203
|
+
}, gt = (t, e) => {
|
|
204
|
+
e.ctrlKey || e.metaKey || e.shiftKey || e.key === "Alt" || (t.control === e.target ? xt(t, e) : Ct(t, e));
|
|
205
|
+
}, xt = (t, e) => {
|
|
206
|
+
var o;
|
|
207
|
+
const { _match: n, clear: i, control: r, items: l, multiple: u } = t;
|
|
208
|
+
(e.key === "ArrowLeft" || e.key === "Backspace") && !r?.selectionEnd && ((o = l[l.length - 1]) == null || o.focus()), e.key === "Enter" && r && (vt(r), b(t, u ? j(t) : n, u)), e.key === "Tab" && !e.shiftKey && i && !i.hidden && (e.preventDefault(), s(i, "aria-hidden", "false"), s(i, "tabindex", "0"), i.focus(), L(i, "blur", () => A(t), H));
|
|
209
|
+
}, Ct = (t, e) => {
|
|
210
|
+
var o, n, i;
|
|
211
|
+
const { clear: r, control: l, items: u } = t, { key: a, repeat: d, target: c } = e, v = [...u].indexOf(c);
|
|
212
|
+
if ((a === " " || a === "Enter") && (u[v] || c === r))
|
|
213
|
+
return (o = u[v] || r) == null || o.click(), e.preventDefault();
|
|
214
|
+
if (u[v]) {
|
|
215
|
+
if (a === "ArrowLeft") return (n = u[v - 1]) == null ? void 0 : n.focus();
|
|
216
|
+
if (a === "ArrowRight") return (i = u[v + 1] || l) == null ? void 0 : i.focus();
|
|
217
|
+
if (a === "Backspace")
|
|
218
|
+
return e.preventDefault(), d || b(t, u[v]);
|
|
219
|
+
l?.focus();
|
|
220
|
+
}
|
|
221
|
+
}, It = (t, e) => {
|
|
222
|
+
var o;
|
|
223
|
+
if (!t.control) return;
|
|
224
|
+
const { _texts: n, control: i, items: r, list: l, multiple: u } = t, a = [];
|
|
225
|
+
for (const { addedNodes: p, removedNodes: C } of e || []) {
|
|
226
|
+
for (const h of p) h instanceof HTMLDataElement && a.unshift(h);
|
|
227
|
+
for (const h of C) h instanceof HTMLDataElement && a.push(h);
|
|
228
|
+
}
|
|
229
|
+
const d = O(t);
|
|
230
|
+
if ((u ? a.length === 1 : a[0] === d) && t.contains(d)) {
|
|
231
|
+
const p = i ? s(i, f) : null;
|
|
232
|
+
t._speak = `${n[a[0].isConnected ? "added" : "removed"]} ${_(a[0])}, `, s(i, f, `${t._speak}${st(i)}`), t._focusMoved || setTimeout(() => x(t._speak.slice(0, -2))), setTimeout(Tt, 300, t, p);
|
|
233
|
+
}
|
|
234
|
+
if (!u) {
|
|
235
|
+
const p = _(r[0]);
|
|
236
|
+
p !== t._itemSingleVale && E(t), t._itemSingleVale = p;
|
|
237
|
+
}
|
|
238
|
+
F(t), W(t), kt(t);
|
|
239
|
+
const v = `${r.length ? n.found.replace("%d", `${r.length}`) : n.empty}`;
|
|
240
|
+
s(i, "aria-description", u ? v : null), s(i, "list", ut(l)), s(t._listbox, f, n.items), (o = t._umutate) == null || o.takeRecords();
|
|
241
|
+
}, Tt = (t, e) => {
|
|
242
|
+
t._speak = "", t.control && s(t.control, f, e), F(t);
|
|
243
|
+
}, F = (t) => {
|
|
244
|
+
const { _texts: e, _speak: o, items: n } = t;
|
|
245
|
+
let i = 0;
|
|
246
|
+
for (const r of n) {
|
|
247
|
+
const l = `${o}${_(r)}, ${e.remove}${B ? `, ${++i} ${e.of} ${n.length}` : ""}`;
|
|
248
|
+
s(r, f, l), s(r, "role", "option"), s(r, "slot", "items"), s(r, "tabindex", "-1"), s(r, "value", r.value || _(r));
|
|
249
|
+
}
|
|
250
|
+
}, kt = (t) => {
|
|
251
|
+
var e, o;
|
|
252
|
+
if ((e = t._select) != null && e.isConnected || (t._select = t.querySelector("select")), !t._select) return;
|
|
253
|
+
const { _select: n, items: i, multiple: r } = t, l = [];
|
|
254
|
+
let u = 0;
|
|
255
|
+
s(n, "multiple", r ? "" : null);
|
|
256
|
+
for (const a of i) {
|
|
257
|
+
const d = n?.options[u++], c = _(a), v = a?.value;
|
|
258
|
+
d ? Object.assign(d, {
|
|
259
|
+
defaultSelected: !0,
|
|
260
|
+
selected: !0,
|
|
261
|
+
text: c,
|
|
262
|
+
value: v
|
|
263
|
+
}) : l.push(new Option(c, v, !0, !0));
|
|
264
|
+
}
|
|
265
|
+
if (l.length) n.append(...l);
|
|
266
|
+
else for (const a of [...n.options].slice(u)) a.remove();
|
|
267
|
+
(o = t._umutate) == null || o.takeRecords();
|
|
268
|
+
}, A = (t) => {
|
|
269
|
+
if (!t.clear) return;
|
|
270
|
+
const { clear: e, control: o } = t, n = !o?.value || o?.disabled || o?.readOnly;
|
|
271
|
+
e.nodeName === "DEL" && s(e, "role", "button"), s(e, f) || s(e, f, t._texts.clear), s(e, "aria-hidden", `${B || P}`), s(e, "hidden", n ? "" : null), s(e, "tabindex", "-1");
|
|
272
|
+
}, W = (t) => {
|
|
273
|
+
if (!t.list) return;
|
|
274
|
+
const { _texts: e, list: o, multiple: n, options: i, values: r } = t;
|
|
275
|
+
s(o, "data-sr-of", e.of), s(o, nt, `${n}`);
|
|
276
|
+
for (const l of i) l.selected = r.includes(l.value);
|
|
277
|
+
}, E = (t) => {
|
|
278
|
+
if (!t.control || t.multiple) return;
|
|
279
|
+
const { control: e, items: o } = t, n = _(o[0]), i = n ? "insertText" : "deleteContentBackward";
|
|
280
|
+
n !== e.value && V(e, n, i);
|
|
281
|
+
};
|
|
282
|
+
ct.define("u-combobox", bt);
|
|
283
|
+
export {
|
|
284
|
+
bt as UHTMLComboboxElement,
|
|
285
|
+
Lt as UHTMLComboboxShadowRoot,
|
|
286
|
+
U as UHTMLComboboxStyle
|
|
287
|
+
};
|
|
288
|
+
//# sourceMappingURL=u-combobox.js.map
|