@mattilsynet/design 3.3.4 → 3.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,15 @@
1
1
  import { CodeIcon, PrinterIcon } from "@phosphor-icons/react";
2
2
  import type { Meta, StoryObj } from "@storybook/react-vite";
3
- import { Button, Grid, Heading, Print, Prose, Table } from "../react";
3
+ import {
4
+ Button,
5
+ Grid,
6
+ Heading,
7
+ Ingress,
8
+ Muted,
9
+ Print,
10
+ Prose,
11
+ Table,
12
+ } from "../react";
4
13
  import styles from "../styles.module.css";
5
14
  import css from "../styles.module.css?inline";
6
15
 
@@ -837,3 +846,38 @@ export const Vedtak: Story = {
837
846
  </div>
838
847
  ),
839
848
  };
849
+
850
+ export const Overskrifter: Story = {
851
+ render: () => (
852
+ <div id="my-print">
853
+ <style>
854
+ {`${css}:root {
855
+ --mtdsc-print-office: 'hovedkontoret';
856
+ --mtdsc-print-department: 'avdeling brukerdialog og kommunikasjon';
857
+ }`}
858
+ </style>
859
+ <Print as={Prose}>
860
+ <Heading data-size="2xl">Heading data-size="2xl"</Heading>
861
+ <p>Text</p>
862
+ <Heading data-size="xl">Heading data-size="xl"</Heading>
863
+ <p>Text</p>
864
+ <Heading data-size="lg">Heading data-size="lg"</Heading>
865
+ <p>Text</p>
866
+ <Heading data-size="md">Heading data-size="md"</Heading>
867
+ <p>Text</p>
868
+ <Heading data-size="sm">Heading data-size="sm"</Heading>
869
+ <p>Text</p>
870
+ <Heading data-size="xs">Heading data-size="xs"</Heading>
871
+ <p>Text</p>
872
+ <Heading data-size="2xs">Heading data-size="2xs"</Heading>
873
+ <p>Text</p>
874
+ <p>
875
+ <Ingress>Ingress</Ingress>
876
+ </p>
877
+ <p>
878
+ <Muted>Muted</Muted>
879
+ </p>
880
+ </Print>
881
+ </div>
882
+ ),
883
+ };
@@ -1,6 +1,6 @@
1
1
  import P from "../styles.module.css.js";
2
2
  import { getByCSSModule as _, onHotReload as h, on as r, QUICK_EVENT as m, debounce as E } from "../utils.js";
3
- import "./app-toggle2.js";
3
+ import "./app-toggle.js";
4
4
  const y = P.app.split(" ")[0], I = `[data-command="toggle-app-expanded"],.${y} > [command="show-modal"]`, u = `.${y} > dialog,.${y} dialog ~ main`, S = _("sticky"), w = (t) => {
5
5
  document.startViewTransition ? document.startViewTransition(t) : t();
6
6
  }, x = (t) => (
@@ -1,27 +1,11 @@
1
- const t = `if (
2
- typeof window !== "undefined" &&
3
- window.CSSStyleSheet &&
4
- document.adoptedStyleSheets
5
- )
6
- (() => {
7
- const key = "--mtds-app-expanded";
8
- const sheet = new CSSStyleSheet();
9
- const prev = () => !window.localStorage.getItem(key)?.includes("false");
10
-
11
- document.adoptedStyleSheets.push(sheet);
12
- window.mtdsToggleAppExpanded = (force) => {
13
- try {
14
- const next = force ?? !prev();
15
- sheet.replaceSync?.(\`:root { \${key}: var(\${key}--\${next})}\`);
16
- window.localStorage.setItem(key, next);
17
- } catch (_err) {} // localStorage is full or replaceSync is not supported
18
- };
19
-
20
- // Set and store initial state
21
- window.mtdsToggleAppExpanded(prev());
22
- })();
23
- `;
24
- export {
25
- t as default
26
- };
1
+ typeof window < "u" && window.CSSStyleSheet && document.adoptedStyleSheets && (() => {
2
+ const e = "--mtds-app-expanded", d = new CSSStyleSheet(), o = () => !window.localStorage.getItem(e)?.includes("false");
3
+ document.adoptedStyleSheets.push(d), window.mtdsToggleAppExpanded = (n) => {
4
+ try {
5
+ const t = n ?? !o();
6
+ d.replaceSync?.(`:root { ${e}: var(${e}--${t})}`), window.localStorage.setItem(e, t);
7
+ } catch {
8
+ }
9
+ }, window.mtdsToggleAppExpanded(o());
10
+ })();
27
11
  //# sourceMappingURL=app-toggle.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"app-toggle.js","sources":["../../designsystem/app/app-toggle.js?raw"],"sourcesContent":["export default \"if (\\n\\ttypeof window !== \\\"undefined\\\" &&\\n\\twindow.CSSStyleSheet &&\\n\\tdocument.adoptedStyleSheets\\n)\\n\\t(() => {\\n\\t\\tconst key = \\\"--mtds-app-expanded\\\";\\n\\t\\tconst sheet = new CSSStyleSheet();\\n\\t\\tconst prev = () => !window.localStorage.getItem(key)?.includes(\\\"false\\\");\\n\\n\\t\\tdocument.adoptedStyleSheets.push(sheet);\\n\\t\\twindow.mtdsToggleAppExpanded = (force) => {\\n\\t\\t\\ttry {\\n\\t\\t\\t\\tconst next = force ?? !prev();\\n\\t\\t\\t\\tsheet.replaceSync?.(`:root { ${key}: var(${key}--${next})}`);\\n\\t\\t\\t\\twindow.localStorage.setItem(key, next);\\n\\t\\t\\t} catch (_err) {} // localStorage is full or replaceSync is not supported\\n\\t\\t};\\n\\n\\t\\t// Set and store initial state\\n\\t\\twindow.mtdsToggleAppExpanded(prev());\\n\\t})();\\n\""],"names":["script"],"mappings":"AAAA,MAAAA,IAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;"}
1
+ {"version":3,"file":"app-toggle.js","sources":["../../designsystem/app/app-toggle.js"],"sourcesContent":["if (\n\ttypeof window !== \"undefined\" &&\n\twindow.CSSStyleSheet &&\n\tdocument.adoptedStyleSheets\n)\n\t(() => {\n\t\tconst key = \"--mtds-app-expanded\";\n\t\tconst sheet = new CSSStyleSheet();\n\t\tconst prev = () => !window.localStorage.getItem(key)?.includes(\"false\");\n\n\t\tdocument.adoptedStyleSheets.push(sheet);\n\t\twindow.mtdsToggleAppExpanded = (force) => {\n\t\t\ttry {\n\t\t\t\tconst next = force ?? !prev();\n\t\t\t\tsheet.replaceSync?.(`:root { ${key}: var(${key}--${next})}`);\n\t\t\t\twindow.localStorage.setItem(key, next);\n\t\t\t} catch (_err) {} // localStorage is full or replaceSync is not supported\n\t\t};\n\n\t\t// Set and store initial state\n\t\twindow.mtdsToggleAppExpanded(prev());\n\t})();\n"],"names":["key","sheet","prev","force","next"],"mappings":"AACC,OAAO,SAAW,OAClB,OAAO,iBACP,SAAS,uBAER,MAAM;AACN,QAAMA,IAAM,uBACNC,IAAQ,IAAI,cAAa,GACzBC,IAAO,MAAM,CAAC,OAAO,aAAa,QAAQF,CAAG,GAAG,SAAS,OAAO;AAEtE,WAAS,mBAAmB,KAAKC,CAAK,GACtC,OAAO,wBAAwB,CAACE,MAAU;AACzC,QAAI;AACH,YAAMC,IAAOD,KAAS,CAACD,EAAI;AAC3B,MAAAD,EAAM,cAAc,WAAWD,CAAG,SAASA,CAAG,KAAKI,CAAI,IAAI,GAC3D,OAAO,aAAa,QAAQJ,GAAKI,CAAI;AAAA,IACtC,QAAe;AAAA,IAAC;AAAA,EACjB,GAGA,OAAO,sBAAsBF,GAAM;AACpC,GAAC;"}
@@ -1,11 +1,27 @@
1
- typeof window < "u" && window.CSSStyleSheet && document.adoptedStyleSheets && (() => {
2
- const e = "--mtds-app-expanded", d = new CSSStyleSheet(), o = () => !window.localStorage.getItem(e)?.includes("false");
3
- document.adoptedStyleSheets.push(d), window.mtdsToggleAppExpanded = (n) => {
4
- try {
5
- const t = n ?? !o();
6
- d.replaceSync?.(`:root { ${e}: var(${e}--${t})}`), window.localStorage.setItem(e, t);
7
- } catch {
8
- }
9
- }, window.mtdsToggleAppExpanded(o());
10
- })();
1
+ const t = `if (
2
+ typeof window !== "undefined" &&
3
+ window.CSSStyleSheet &&
4
+ document.adoptedStyleSheets
5
+ )
6
+ (() => {
7
+ const key = "--mtds-app-expanded";
8
+ const sheet = new CSSStyleSheet();
9
+ const prev = () => !window.localStorage.getItem(key)?.includes("false");
10
+
11
+ document.adoptedStyleSheets.push(sheet);
12
+ window.mtdsToggleAppExpanded = (force) => {
13
+ try {
14
+ const next = force ?? !prev();
15
+ sheet.replaceSync?.(\`:root { \${key}: var(\${key}--\${next})}\`);
16
+ window.localStorage.setItem(key, next);
17
+ } catch (_err) {} // localStorage is full or replaceSync is not supported
18
+ };
19
+
20
+ // Set and store initial state
21
+ window.mtdsToggleAppExpanded(prev());
22
+ })();
23
+ `;
24
+ export {
25
+ t as default
26
+ };
11
27
  //# sourceMappingURL=app-toggle2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"app-toggle2.js","sources":["../../designsystem/app/app-toggle.js"],"sourcesContent":["if (\n\ttypeof window !== \"undefined\" &&\n\twindow.CSSStyleSheet &&\n\tdocument.adoptedStyleSheets\n)\n\t(() => {\n\t\tconst key = \"--mtds-app-expanded\";\n\t\tconst sheet = new CSSStyleSheet();\n\t\tconst prev = () => !window.localStorage.getItem(key)?.includes(\"false\");\n\n\t\tdocument.adoptedStyleSheets.push(sheet);\n\t\twindow.mtdsToggleAppExpanded = (force) => {\n\t\t\ttry {\n\t\t\t\tconst next = force ?? !prev();\n\t\t\t\tsheet.replaceSync?.(`:root { ${key}: var(${key}--${next})}`);\n\t\t\t\twindow.localStorage.setItem(key, next);\n\t\t\t} catch (_err) {} // localStorage is full or replaceSync is not supported\n\t\t};\n\n\t\t// Set and store initial state\n\t\twindow.mtdsToggleAppExpanded(prev());\n\t})();\n"],"names":["key","sheet","prev","force","next"],"mappings":"AACC,OAAO,SAAW,OAClB,OAAO,iBACP,SAAS,uBAER,MAAM;AACN,QAAMA,IAAM,uBACNC,IAAQ,IAAI,cAAa,GACzBC,IAAO,MAAM,CAAC,OAAO,aAAa,QAAQF,CAAG,GAAG,SAAS,OAAO;AAEtE,WAAS,mBAAmB,KAAKC,CAAK,GACtC,OAAO,wBAAwB,CAACE,MAAU;AACzC,QAAI;AACH,YAAMC,IAAOD,KAAS,CAACD,EAAI;AAC3B,MAAAD,EAAM,cAAc,WAAWD,CAAG,SAASA,CAAG,KAAKI,CAAI,IAAI,GAC3D,OAAO,aAAa,QAAQJ,GAAKI,CAAI;AAAA,IACtC,QAAe;AAAA,IAAC;AAAA,EACjB,GAGA,OAAO,sBAAsBF,GAAM;AACpC,GAAC;"}
1
+ {"version":3,"file":"app-toggle2.js","sources":["../../designsystem/app/app-toggle.js?raw"],"sourcesContent":["export default \"if (\\n\\ttypeof window !== \\\"undefined\\\" &&\\n\\twindow.CSSStyleSheet &&\\n\\tdocument.adoptedStyleSheets\\n)\\n\\t(() => {\\n\\t\\tconst key = \\\"--mtds-app-expanded\\\";\\n\\t\\tconst sheet = new CSSStyleSheet();\\n\\t\\tconst prev = () => !window.localStorage.getItem(key)?.includes(\\\"false\\\");\\n\\n\\t\\tdocument.adoptedStyleSheets.push(sheet);\\n\\t\\twindow.mtdsToggleAppExpanded = (force) => {\\n\\t\\t\\ttry {\\n\\t\\t\\t\\tconst next = force ?? !prev();\\n\\t\\t\\t\\tsheet.replaceSync?.(`:root { ${key}: var(${key}--${next})}`);\\n\\t\\t\\t\\twindow.localStorage.setItem(key, next);\\n\\t\\t\\t} catch (_err) {} // localStorage is full or replaceSync is not supported\\n\\t\\t};\\n\\n\\t\\t// Set and store initial state\\n\\t\\twindow.mtdsToggleAppExpanded(prev());\\n\\t})();\\n\""],"names":["script"],"mappings":"AAAA,MAAAA,IAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;"}
package/mtds/app/app.js CHANGED
@@ -3,7 +3,7 @@ import a from "clsx";
3
3
  import { forwardRef as n } from "react";
4
4
  import { Button as m } from "../button/button.js";
5
5
  import s from "../styles.module.css.js";
6
- import d from "./app-toggle.js";
6
+ import d from "./app-toggle2.js";
7
7
  const u = n(function({ as: r, className: t, ...p }, e) {
8
8
  return /* @__PURE__ */ o(r || "div", { className: a(s.app, t), ref: e, ...p });
9
9
  }), f = n(function({ as: r, className: t, ...p }, e) {
@@ -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-3-4design{${b}`);
22
+ @layer mt.v3-3-6design{${b}`);
23
23
  }
24
24
  connectedCallback() {
25
25
  const t = this.shadowRoot?.lastElementChild, e = a(this, "data-cluster") ?? "false", o = new i.TileLayer(k, {
@@ -1,11 +1,23 @@
1
- import "./index.js";
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";
1
+ import "@u-elements/u-progress";
4
2
  import { DSFieldElement as g } from "@digdir/designsystemet-web";
3
+ import "./external/@u-elements/u-combobox/dist/u-combobox.js";
4
+ import "./external/@u-elements/u-details/dist/u-details.js";
5
+ import "./analytics/analytics.js";
6
+ import "./app/app-observer.js";
7
+ import { getByCSSModule as l, isBrowser as n, onHotReload as y, on as u, QUICK_EVENT as S, onMutation as E, attr as s, debounce as D } from "./utils.js";
8
+ import c from "./styles.module.css.js";
9
+ import "./toast/toast-helper.js";
10
+ import "./chart/chart-element.js";
11
+ import "./logo/logo-observer.js";
12
+ import "./popover/popover-observer.js";
13
+ import "./table/table-observer.js";
14
+ import "./toast/toast-observer.js";
15
+ import "./tooltip/tooltip-element.js";
16
+ import "./validation/validation-observer.js";
5
17
  const f = /* @__PURE__ */ new WeakSet(), a = (t) => !f.has(t) && f.add(t), o = (t, e, r) => window.dsWarnings === !1 || console.warn(
6
18
  `\x1B[1m@mattilsynet/design:\x1B[m ${t} is deprecated, please use ${e}:`,
7
19
  r
8
- ), A = n("togglegroup"), p = l.button.split(" "), L = () => {
20
+ ), A = l("togglegroup"), p = c.button.split(" "), L = () => {
9
21
  for (const t of A) {
10
22
  a(t) && !t.hasAttribute("data-toggle-group") && (s(t, "data-toggle-group", "Valgknapper"), o(
11
23
  'Only setting class="styles.togglegroup"',
@@ -19,22 +31,22 @@ const f = /* @__PURE__ */ new WeakSet(), a = (t) => !f.has(t) && f.add(t), o = (
19
31
  e
20
32
  ));
21
33
  }
22
- }, O = n("breadcrumbs"), C = () => {
23
- for (const t of O)
24
- a(t) && t.nodeName !== "DS-BREADCRUMBS" && (t.classList.add(...l.breadcrumbs.split(" ")), o(
34
+ }, N = l("breadcrumbs"), O = () => {
35
+ for (const t of N)
36
+ a(t) && t.nodeName !== "DS-BREADCRUMBS" && (t.classList.add(...c.breadcrumbs.split(" ")), o(
25
37
  'Only setting class="styles.breadcrumbs"',
26
38
  '<ds-breadcrumbs class="styles.breadcrumbs">',
27
39
  t
28
40
  ));
29
- }, N = n("errorsummary"), R = () => {
30
- for (const t of N)
41
+ }, T = l("errorsummary"), B = () => {
42
+ for (const t of T)
31
43
  a(t) && t.nodeName !== "DS-ERROR-SUMMARY" && o(
32
44
  'Only setting class="styles.errorsummary"',
33
45
  '<ds-error-summary class="styles.errorsummary">',
34
46
  t
35
47
  );
36
- }, w = n("dialog"), b = () => {
37
- for (const t of w) {
48
+ }, C = l("dialog"), b = () => {
49
+ for (const t of C) {
38
50
  if (a(t)) {
39
51
  const e = s(t, "data-closedby");
40
52
  e && (s(t, "closedby", e), o(
@@ -53,17 +65,17 @@ const f = /* @__PURE__ */ new WeakSet(), a = (t) => !f.has(t) && f.add(t), o = (
53
65
  t
54
66
  ), s(t, "open", null), t.showModal()) : t.matches(":modal:not([open])") && (s(t, "open", ""), t.close()));
55
67
  }
56
- }, B = () => {
68
+ }, R = () => {
57
69
  for (const t of document.querySelectorAll("[data-count]"))
58
70
  if (a(t)) {
59
71
  const e = s(t, "data-count");
60
- t.classList.add(...l.validation.split(" ")), s(t, "data-limit", e), o(
72
+ t.classList.add(...c.validation.split(" ")), s(t, "data-limit", e), o(
61
73
  `data-count="${e}"`,
62
74
  `class="styles.validation" data-field="counter" data-limit="${e}"`,
63
75
  t
64
76
  );
65
77
  }
66
- }, T = () => {
78
+ }, w = () => {
67
79
  for (const t of document.querySelectorAll("[data-command]"))
68
80
  if (a(t)) {
69
81
  const e = s(t, "data-command");
@@ -77,59 +89,61 @@ const f = /* @__PURE__ */ new WeakSet(), a = (t) => !f.has(t) && f.add(t), o = (
77
89
  t
78
90
  );
79
91
  }
80
- }, h = d() ? document.getElementsByTagName("u-tabs") : [], I = () => {
81
- for (const t of h) a(t) && o("u-tabs", "ds-tabs", t);
82
- }, i = l.suggestion.split(" "), v = d() ? document.getElementsByTagName("u-combobox") : [], $ = d() ? document.getElementsByTagName("ds-suggestion") : [], M = () => {
83
- for (const t of v)
84
- a(t) && (t.classList.add(...i), o("<u-combobox>", '<ds-suggestion class="styles.suggestion">', t));
92
+ }, I = n() ? document.getElementsByTagName("u-tabs") : [], h = () => {
93
+ for (const t of I) a(t) && o("u-tabs", "ds-tabs", t);
94
+ }, v = n() ? document.getElementsByTagName("u-details") : [], U = () => {
95
+ for (const t of v) a(t) && o("u-details", "details", t);
96
+ }, i = c.suggestion.split(" "), $ = n() ? document.getElementsByTagName("u-combobox") : [], M = n() ? document.getElementsByTagName("ds-suggestion") : [], k = () => {
85
97
  for (const t of $)
98
+ a(t) && (t.classList.add(...i), o("<u-combobox>", '<ds-suggestion class="styles.suggestion">', t));
99
+ for (const t of M)
86
100
  a(t) && !t.classList.contains(i[0]) && (t.classList.add(...i), o(
87
101
  "Only using <ds-suggestion>",
88
102
  '<ds-suggestion class="styles.suggestion">',
89
103
  t
90
104
  ));
91
- }, U = ({ target: t }) => {
105
+ }, F = ({ target: t }) => {
92
106
  if (!(t instanceof Element)) return;
93
107
  const e = t?.closest("tr")?.querySelector('[data-command="row"]');
94
108
  e && !t?.closest('a,button,label,input,select,textarea,[role="button"]') && e.click();
95
109
  const m = t?.closest("dialog");
96
110
  m && t?.closest('[data-command="close"]') && m.close();
97
- }, k = n("field"), c = /* @__PURE__ */ new Set(), F = () => {
98
- for (const t of k)
111
+ }, G = l("field"), d = /* @__PURE__ */ new Set(), x = () => {
112
+ for (const t of G)
99
113
  t.nodeName !== "DS-FIELD" && (a(t) || o(
100
114
  'Only setting class="styles.field"',
101
115
  '<ds-field class="styles.field">',
102
116
  t
103
- ), !c.has(t) && c.add(t) && g.prototype.connectedCallback.call(t));
104
- }, G = () => {
105
- for (const t of c)
106
- g.prototype.disconnectedCallback.call(t), c.delete(t);
107
- }, x = `[data-description], .${l.field.split(" ")[0]} label + p`, q = () => {
108
- for (const t of document.querySelectorAll(x))
117
+ ), !d.has(t) && d.add(t) && g.prototype.connectedCallback.call(t));
118
+ }, q = () => {
119
+ for (const t of d)
120
+ g.prototype.disconnectedCallback.call(t), d.delete(t);
121
+ }, P = `[data-description], .${c.field.split(" ")[0]} label + p`, _ = () => {
122
+ for (const t of document.querySelectorAll(P))
109
123
  a(t) && t.getAttribute("data-field") !== "description" && (s(t, "data-field", "description"), o(
110
124
  "Descriptions created by data-description of <p> only",
111
125
  'data-field="data-description"',
112
126
  t
113
127
  ));
114
- }, P = n("validation"), _ = () => {
115
- for (const t of P)
128
+ }, V = l("validation"), W = () => {
129
+ for (const t of V)
116
130
  a(t) && !t.hasAttribute("data-field") && (s(t, "data-field", "validation"), o(
117
131
  'Only setting class="styles.validation"',
118
132
  'class="styles.validation" data-field="validation"',
119
133
  t
120
134
  ));
121
- }, V = () => {
135
+ }, H = () => {
122
136
  for (const t of document.querySelectorAll("[popover][data-position]"))
123
137
  a(t) && (s(t, "data-placement", s(t, "data-position")), o("data-position", "data-placement", t));
124
- }, W = D(() => {
125
- d() && (B(), T(), C(), b(), R(), q(), _(), V(), F(), L(), M(), I());
138
+ }, Y = D(() => {
139
+ n() && (R(), w(), O(), b(), B(), _(), W(), H(), x(), L(), k(), h(), U());
126
140
  }, 200);
127
141
  y("deprecations", () => [
128
- G,
142
+ q,
129
143
  // Return as cleanup function
130
- u(document, "click", U, S),
144
+ u(document, "click", F, S),
131
145
  u(document, "toggle", b, !0),
132
- E(document, W, {
146
+ E(document, Y, {
133
147
  attributeFilter: [
134
148
  "class",
135
149
  "data-command",
@@ -1 +1 @@
1
- {"version":3,"file":"deprecations.js","sources":["../designsystem/deprecations.ts"],"sourcesContent":["import { DSFieldElement } from \".\";\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,E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CC;AAAA,MACC;AAAA,MACA;AAAA,MACAD;AAAA,IAAA;AAGJ,GAGMuC,IAAclC,EAAe,YAAY,GACzCmC,IAA2B,MAAM;AACtC,aAAWxC,KAAMuC;AAChB,IAAIxC,EAAUC,CAAE,KAAK,CAACA,EAAG,aAAa,YAAY,MACjDS,EAAKT,GAAI,cAAc,YAAY,GACnCC;AAAA,MACC;AAAA,MACA;AAAA,MACAD;AAAA,IAAA;AAGJ,GAEMyC,IAA2B,MAAM;AACtC,aAAWzC,KAAM,SAAS,iBAAiB,0BAA0B;AACpE,IAAID,EAAUC,CAAE,MACfS,EAAKT,GAAI,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;"}
1
+ {"version":3,"file":"deprecations.js","sources":["../designsystem/deprecations.ts"],"sourcesContent":["import { DSFieldElement } from \".\";\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-details\nconst DETAILS = isBrowser() ? document.getElementsByTagName(\"u-details\") : [];\nconst deprecateUDetails = () => {\n\tfor (const el of DETAILS) if (deprecate(el)) warn(\"u-details\", \"details\", 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\tdeprecateUDetails();\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","DETAILS","deprecateUDetails","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,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AA,MACA;AAAA,IAAA;AAAA,IAED,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,SAAS;AAAA,EAAA,CACT;AACF,CAAC;"}
@@ -0,0 +1,105 @@
1
+ var h = () => typeof window < "u" && typeof window.document < "u" && typeof window.navigator < "u", m = h(), c;
2
+ m && // @ts-expect-error Typescript has not implemented userAgentData yet https://stackoverflow.com/a/71392474
3
+ /^Mac/i.test(((c = navigator.userAgentData) == null ? void 0 : c.platform) || navigator.platform);
4
+ var b = m && window.CSSStyleSheet && document.adoptedStyleSheets, v = ":host(:not([hidden])) { display: block }", p = typeof HTMLElement > "u" ? class {
5
+ } : HTMLElement, i = (t, e, o) => o === void 0 ? t.getAttribute(e) : (o === null ? t.removeAttribute(e) : t.getAttribute(e) !== o && t.setAttribute(e, o), null), u = (t, ...e) => {
6
+ const [o, ...n] = e;
7
+ for (const s of o.split(" ")) t.addEventListener(s, ...n);
8
+ return () => l(t, ...e);
9
+ }, l = (t, ...e) => {
10
+ const [o, ...n] = e;
11
+ for (const s of o.split(" ")) t.removeEventListener(s, ...n);
12
+ }, S = (t, e) => {
13
+ const o = t.shadowRoot || t.attachShadow({ mode: "open" });
14
+ if (o.querySelector("slot") || o.append(r("slot")), !o.querySelector("style"))
15
+ if (!b) o.append(r("style", null, e));
16
+ else {
17
+ const n = new CSSStyleSheet();
18
+ n.replaceSync(e), o.adoptedStyleSheets = [n];
19
+ }
20
+ return o;
21
+ }, w = (t) => {
22
+ var e;
23
+ const o = ((e = t.getRootNode) == null ? void 0 : e.call(t)) || t.ownerDocument;
24
+ return o instanceof Document || o instanceof ShadowRoot ? o : document;
25
+ }, r = (t, e, o) => {
26
+ const n = document.createElement(t);
27
+ if (o && (n.textContent = o), e) for (const [s, a] of Object.entries(e)) i(n, s, a);
28
+ return n;
29
+ }, f = {
30
+ define: (t, e) => !h() || window.customElements.get(t) || window.customElements.define(t, e)
31
+ }, g = (t, e = "<slot></slot>") => `<template shadowrootmode="open">${e}<style>${t}</style></template>`, y = `${v}
32
+ ::slotted([slot="summary"]) { cursor: pointer; display: block }
33
+ ::slotted([slot="summary"])::before { content: ''; display: inline-block; vertical-align: middle; margin-inline: .05em .3125em; border-block: .3125em solid transparent; border-inline-start: .5em solid }
34
+ ::slotted([slot="summary"][aria-expanded="true"])::before { rotate: 90deg }
35
+ :host > [part="details-content"]:not([hidden=""]) { display: block }`, _ = g(
36
+ y,
37
+ '<slot name="summary"></slot><slot part="details-content" hidden="until-found"></slot>'
38
+ ), k = class extends p {
39
+ // Using underscore instead of private fields for backwards compatibility
40
+ // Using ES2015 syntax for backwards compatibility
41
+ static get observedAttributes() {
42
+ return ["open"];
43
+ }
44
+ constructor() {
45
+ var t;
46
+ super(), S(this, y), (t = this.shadowRoot) == null || t.prepend(
47
+ r("slot", { name: "summary" }),
48
+ r("slot", { part: "details-content" })
49
+ ), console.warn(
50
+ `\x1B[1m<u-details> is deprecated as <details> now has sufficient screen reader support 🎉\x1B[0m
51
+ Please use <details> and <summary>, but import '@u-elements/u-details/polyfill' to polyfill support for Talkback screen reader when used with Firefox on Android.`,
52
+ this
53
+ );
54
+ }
55
+ connectedCallback() {
56
+ var t;
57
+ this._content = (t = this.shadowRoot) == null ? void 0 : t.children[1], i(this, "role", "group"), u(this._content, "beforematch", this), u(this, "click keydown", this), this.attributeChangedCallback();
58
+ }
59
+ disconnectedCallback() {
60
+ this._content && l(this._content, "beforematch", this), l(this, "click keydown", this), this._content = void 0;
61
+ }
62
+ attributeChangedCallback(t, e, o) {
63
+ const n = "onbeforematch" in this ? "until-found" : !0, s = this.open;
64
+ for (const a of this.children)
65
+ a.nodeName === "U-SUMMARY" && i(a, "aria-expanded", `${s}`);
66
+ if (this._content && (i(this._content, "aria-hidden", `${!s}`), i(this._content, "tabindex", s ? null : "-1"), this._content.hidden = s ? !1 : n), s && this.name) {
67
+ const a = w(this).querySelectorAll(
68
+ `${this.nodeName}[name="${this.name}"]`
69
+ );
70
+ for (const d of a)
71
+ d !== this && (d.open = !1);
72
+ }
73
+ t === "open" && e === null != (o === null) && this.dispatchEvent(new Event("toggle"));
74
+ }
75
+ handleEvent(t) {
76
+ var e, o;
77
+ const n = t.key === " " || t.key === "Enter", s = t.target instanceof Element && ((e = t.target.closest('[slot="summary"]')) == null ? void 0 : e.parentElement) === this;
78
+ t.defaultPrevented || (t.type === "beforematch" && (this.open = !0), s && t.type === "click" && (this.open = !this.open), s && t.type === "keydown" && n && ((o = t.preventDefault) == null || o.call(t), t.target.dispatchEvent(new MouseEvent("click", t))));
79
+ }
80
+ get open() {
81
+ return this.hasAttribute("open");
82
+ }
83
+ set open(t) {
84
+ i(this, "open", t ? "" : null);
85
+ }
86
+ get name() {
87
+ return i(this, "name") || "";
88
+ }
89
+ set name(t) {
90
+ i(this, "name", t);
91
+ }
92
+ }, E = class extends p {
93
+ connectedCallback() {
94
+ i(this, "role", "button"), this.slot = "summary", this.tabIndex = 0;
95
+ }
96
+ };
97
+ f.define("u-details", k);
98
+ f.define("u-summary", E);
99
+ export {
100
+ k as UHTMLDetailsElement,
101
+ _ as UHTMLDetailsShadowRoot,
102
+ y as UHTMLDetailsStyle,
103
+ E as UHTMLSummaryElement
104
+ };
105
+ //# sourceMappingURL=u-details.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"u-details.js","sources":["../../../../../node_modules/@u-elements/u-details/dist/u-details.js"],"sourcesContent":["// ../utils.ts\nvar isBrowser = () => typeof window !== \"undefined\" && typeof window.document !== \"undefined\" && typeof window.navigator !== \"undefined\";\nvar IS_BROWSER = isBrowser();\nvar _a;\nIS_BROWSER && // @ts-expect-error Typescript has not implemented userAgentData yet https://stackoverflow.com/a/71392474\n/^Mac/i.test(((_a = navigator.userAgentData) == null ? void 0 : _a.platform) || navigator.platform);\nvar SUPPORTS_CONSTRUCTED_CSS = IS_BROWSER && window.CSSStyleSheet && document.adoptedStyleSheets;\nvar DISPLAY_BLOCK = \":host(:not([hidden])) { display: block }\";\nvar UHTMLElement = typeof HTMLElement === \"undefined\" ? class {\n} : HTMLElement;\nvar attr = (el, name, value) => {\n if (value === void 0) return el.getAttribute(name);\n if (value === null) el.removeAttribute(name);\n else if (el.getAttribute(name) !== value) el.setAttribute(name, value);\n return null;\n};\nvar on = (el, ...rest) => {\n const [types, ...options] = rest;\n for (const type of types.split(\" \")) el.addEventListener(type, ...options);\n return () => off(el, ...rest);\n};\nvar off = (el, ...rest) => {\n const [types, ...options] = rest;\n for (const type of types.split(\" \")) el.removeEventListener(type, ...options);\n};\nvar attachStyle = (el, css) => {\n const root = el.shadowRoot || el.attachShadow({ mode: \"open\" });\n if (!root.querySelector(\"slot\")) root.append(tag(\"slot\"));\n if (!root.querySelector(\"style\")) {\n if (!SUPPORTS_CONSTRUCTED_CSS) root.append(tag(\"style\", null, css));\n else {\n const sheet = new CSSStyleSheet();\n sheet.replaceSync(css);\n root.adoptedStyleSheets = [sheet];\n }\n }\n return root;\n};\nvar getRoot = (node) => {\n var _a2;\n const root = ((_a2 = node.getRootNode) == null ? void 0 : _a2.call(node)) || node.ownerDocument;\n return root instanceof Document || root instanceof ShadowRoot ? root : document;\n};\nvar tag = (tagName, attrs, content) => {\n const el = document.createElement(tagName);\n if (content) el.textContent = content;\n if (attrs) for (const [key, val] of Object.entries(attrs)) attr(el, key, val);\n return el;\n};\nvar customElements = {\n define: (name, instance) => !isBrowser() || window.customElements.get(name) || window.customElements.define(name, instance)\n};\nvar declarativeShadowRoot = (style, slot = \"<slot></slot>\") => `<template shadowrootmode=\"open\">${slot}<style>${style}</style></template>`;\n\n// u-details.ts\nvar UHTMLDetailsStyle = `${DISPLAY_BLOCK}\n::slotted([slot=\"summary\"]) { cursor: pointer; display: block }\n::slotted([slot=\"summary\"])::before { content: ''; display: inline-block; vertical-align: middle; margin-inline: .05em .3125em; border-block: .3125em solid transparent; border-inline-start: .5em solid }\n::slotted([slot=\"summary\"][aria-expanded=\"true\"])::before { rotate: 90deg }\n:host > [part=\"details-content\"]:not([hidden=\"\"]) { display: block }`;\nvar UHTMLDetailsShadowRoot = declarativeShadowRoot(\n UHTMLDetailsStyle,\n '<slot name=\"summary\"></slot><slot part=\"details-content\" hidden=\"until-found\"></slot>'\n);\nvar UHTMLDetailsElement = class extends UHTMLElement {\n // Using underscore instead of private fields for backwards compatibility\n // Using ES2015 syntax for backwards compatibility\n static get observedAttributes() {\n return [\"open\"];\n }\n constructor() {\n var _a2;\n super();\n attachStyle(this, UHTMLDetailsStyle);\n (_a2 = this.shadowRoot) == null ? void 0 : _a2.prepend(\n tag(\"slot\", { name: \"summary\" }),\n tag(\"slot\", { part: \"details-content\" })\n );\n console.warn(\n \"\\x1B[1m<u-details> is deprecated as <details> now has sufficient screen reader support \\u{1F389}\\x1B[0m\\nPlease use <details> and <summary>, but import '@u-elements/u-details/polyfill' to polyfill support for Talkback screen reader when used with Firefox on Android.\",\n this\n );\n }\n connectedCallback() {\n var _a2;\n this._content = (_a2 = this.shadowRoot) == null ? void 0 : _a2.children[1];\n attr(this, \"role\", \"group\");\n on(this._content, \"beforematch\", this);\n on(this, \"click keydown\", this);\n this.attributeChangedCallback();\n }\n disconnectedCallback() {\n if (this._content) off(this._content, \"beforematch\", this);\n off(this, \"click keydown\", this);\n this._content = void 0;\n }\n attributeChangedCallback(prop, prev, next) {\n const hide = \"onbeforematch\" in this ? \"until-found\" : true;\n const open = this.open;\n for (const el of this.children)\n if (el.nodeName === \"U-SUMMARY\") attr(el, \"aria-expanded\", `${open}`);\n if (this._content) {\n attr(this._content, \"aria-hidden\", `${!open}`);\n attr(this._content, \"tabindex\", open ? null : \"-1\");\n this._content.hidden = open ? false : hide;\n }\n if (open && this.name) {\n const uDetailsList = getRoot(this).querySelectorAll(\n `${this.nodeName}[name=\"${this.name}\"]`\n );\n for (const uDetails of uDetailsList)\n if (uDetails !== this) uDetails.open = false;\n }\n if (prop === \"open\" && prev === null !== (next === null))\n this.dispatchEvent(new Event(\"toggle\"));\n }\n handleEvent(event) {\n var _a2, _b;\n const isKeyClick = event.key === \" \" || event.key === \"Enter\";\n const isSummary = event.target instanceof Element && ((_a2 = event.target.closest('[slot=\"summary\"]')) == null ? void 0 : _a2.parentElement) === this;\n if (event.defaultPrevented) return;\n if (event.type === \"beforematch\") this.open = true;\n if (isSummary && event.type === \"click\") this.open = !this.open;\n if (isSummary && event.type === \"keydown\" && isKeyClick) {\n (_b = event.preventDefault) == null ? void 0 : _b.call(event);\n event.target.dispatchEvent(new MouseEvent(\"click\", event));\n }\n }\n get open() {\n return this.hasAttribute(\"open\");\n }\n set open(value) {\n attr(this, \"open\", value ? \"\" : null);\n }\n get name() {\n return attr(this, \"name\") || \"\";\n }\n set name(value) {\n attr(this, \"name\", value);\n }\n};\nvar UHTMLSummaryElement = class extends UHTMLElement {\n connectedCallback() {\n attr(this, \"role\", \"button\");\n this.slot = \"summary\";\n this.tabIndex = 0;\n }\n};\ncustomElements.define(\"u-details\", UHTMLDetailsElement);\ncustomElements.define(\"u-summary\", UHTMLSummaryElement);\n\nexport { UHTMLDetailsElement, UHTMLDetailsShadowRoot, UHTMLDetailsStyle, UHTMLSummaryElement };\n"],"names":["isBrowser","IS_BROWSER","_a","SUPPORTS_CONSTRUCTED_CSS","DISPLAY_BLOCK","UHTMLElement","attr","el","name","value","on","rest","types","options","type","off","attachStyle","css","root","tag","sheet","getRoot","node","_a2","tagName","attrs","content","key","val","customElements","instance","declarativeShadowRoot","style","slot","UHTMLDetailsStyle","UHTMLDetailsShadowRoot","UHTMLDetailsElement","prop","prev","next","hide","open","uDetailsList","uDetails","event","_b","isKeyClick","isSummary","UHTMLSummaryElement"],"mappings":"AACA,IAAIA,IAAY,MAAM,OAAO,SAAW,OAAe,OAAO,OAAO,WAAa,OAAe,OAAO,OAAO,YAAc,KACzHC,IAAaD,EAAS,GACtBE;AACJD;AACA,QAAQ,OAAOC,IAAK,UAAU,kBAAkB,OAAO,SAASA,EAAG,aAAa,UAAU,QAAQ;AAClG,IAAIC,IAA2BF,KAAc,OAAO,iBAAiB,SAAS,oBAC1EG,IAAgB,4CAChB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