@mattilsynet/design 2.3.7 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/mtds/analytics/analytics.js +16 -14
  2. package/mtds/analytics/analytics.js.map +1 -1
  3. package/mtds/app/app-observer.js +26 -26
  4. package/mtds/app/app-observer.js.map +1 -1
  5. package/mtds/atlas/atlas-element.js +3 -3
  6. package/mtds/atlas/atlas-element.js.map +1 -1
  7. package/mtds/atlas/atlas-marker.js +2 -2
  8. package/mtds/atlas/atlas-marker.js.map +1 -1
  9. package/mtds/atlas.iife.js +4 -4
  10. package/mtds/breadcrumbs/breadcrumbs.d.ts +9 -8
  11. package/mtds/breadcrumbs/breadcrumbs.js +8 -10
  12. package/mtds/breadcrumbs/breadcrumbs.js.map +1 -1
  13. package/mtds/chart/chart-element.js +41 -37
  14. package/mtds/chart/chart-element.js.map +1 -1
  15. package/mtds/chart/chart.js +45 -11
  16. package/mtds/chart/chart.js.map +1 -1
  17. package/mtds/deprecations.js +135 -0
  18. package/mtds/deprecations.js.map +1 -0
  19. package/mtds/details/details.js +18 -11
  20. package/mtds/details/details.js.map +1 -1
  21. package/mtds/errorsummary/errorsummary.d.ts +4 -2
  22. package/mtds/errorsummary/errorsummary.js +14 -18
  23. package/mtds/errorsummary/errorsummary.js.map +1 -1
  24. package/mtds/field/field.d.ts +34 -12
  25. package/mtds/field/field.js +167 -137
  26. package/mtds/field/field.js.map +1 -1
  27. package/mtds/field/field.stories.d.ts +10 -10
  28. package/mtds/fieldset/fieldset.js +2 -1
  29. package/mtds/fieldset/fieldset.js.map +1 -1
  30. package/mtds/icons/cosmetics.svg +1 -1
  31. package/mtds/icons/megaphone.svg +3 -0
  32. package/mtds/illustrations/car-logo.svg +1 -0
  33. package/mtds/illustrations/car.svg +1 -0
  34. package/mtds/illustrations/cheese.svg +1 -0
  35. package/mtds/illustrations/cloud-1.svg +1 -0
  36. package/mtds/illustrations/cloud-2.svg +1 -0
  37. package/mtds/illustrations/cloud-sun.svg +1 -0
  38. package/mtds/illustrations/cloud-sunshine.svg +1 -0
  39. package/mtds/illustrations/egg-boat.svg +1 -0
  40. package/mtds/illustrations/egg-half.svg +1 -0
  41. package/mtds/illustrations/foodtruck-logo.svg +1 -0
  42. package/mtds/illustrations/foodtruck.svg +1 -0
  43. package/mtds/illustrations/house.svg +1 -0
  44. package/mtds/illustrations/index.json +104 -11
  45. package/mtds/illustrations/paragraph.svg +1 -0
  46. package/mtds/illustrations/person-child-puppy.svg +1 -0
  47. package/mtds/illustrations/person-family-house.svg +1 -0
  48. package/mtds/illustrations/person-family.svg +1 -0
  49. package/mtds/illustrations/person-paragraph.svg +1 -0
  50. package/mtds/illustrations/plane-solo.svg +1 -0
  51. package/mtds/illustrations/sunshine.svg +1 -0
  52. package/mtds/illustrations/tractor.svg +1 -0
  53. package/mtds/illustrations/wind.svg +1 -0
  54. package/mtds/index.d.ts +4 -3
  55. package/mtds/index.iife.js +24 -22
  56. package/mtds/index.js +23 -37
  57. package/mtds/index.js.map +1 -1
  58. package/mtds/input/input.js +30 -24
  59. package/mtds/input/input.js.map +1 -1
  60. package/mtds/logo/logo-observer.js +11 -11
  61. package/mtds/logo/logo-observer.js.map +1 -1
  62. package/mtds/package.json.js +1 -1
  63. package/mtds/pagination/pagination.d.ts +19 -2
  64. package/mtds/pagination/pagination.js +19 -21
  65. package/mtds/pagination/pagination.js.map +1 -1
  66. package/mtds/popover/popover.d.ts +4 -0
  67. package/mtds/popover/popover.js +7 -6
  68. package/mtds/popover/popover.js.map +1 -1
  69. package/mtds/react-types.d.ts +1 -2
  70. package/mtds/styles.css +1 -1
  71. package/mtds/styles.json +44 -43
  72. package/mtds/styles.module.css.js +43 -43
  73. package/mtds/table/table-observer.d.ts +1 -1
  74. package/mtds/table/table-observer.js +17 -41
  75. package/mtds/table/table-observer.js.map +1 -1
  76. package/mtds/tabs/tabs.d.ts +10 -9
  77. package/mtds/tabs/tabs.js +8 -8
  78. package/mtds/tabs/tabs.js.map +1 -1
  79. package/mtds/toast/toast-observer.js +7 -7
  80. package/mtds/toast/toast-observer.js.map +1 -1
  81. package/mtds/togglegroup/togglegroup.d.ts +6 -2
  82. package/mtds/togglegroup/togglegroup.js +20 -19
  83. package/mtds/togglegroup/togglegroup.js.map +1 -1
  84. package/mtds/tooltip/tooltip-element.js +7 -0
  85. package/mtds/tooltip/tooltip-element.js.map +1 -0
  86. package/mtds/utils.d.ts +13 -32
  87. package/mtds/utils.js +47 -98
  88. package/mtds/utils.js.map +1 -1
  89. package/mtds/validation/validation-observer.js +34 -29
  90. package/mtds/validation/validation-observer.js.map +1 -1
  91. package/mtds/validation/validation.js +6 -5
  92. package/mtds/validation/validation.js.map +1 -1
  93. package/package.json +15 -14
  94. package/mtds/breadcrumbs/breadcrumbs-observer.js +0 -12
  95. package/mtds/breadcrumbs/breadcrumbs-observer.js.map +0 -1
  96. package/mtds/dialog/dialog-observer.js +0 -65
  97. package/mtds/dialog/dialog-observer.js.map +0 -1
  98. package/mtds/errorsummary/errorsummary-observer.d.ts +0 -1
  99. package/mtds/errorsummary/errorsummary-observer.js +0 -11
  100. package/mtds/errorsummary/errorsummary-observer.js.map +0 -1
  101. package/mtds/field/field-observer.d.ts +0 -1
  102. package/mtds/field/field-observer.js +0 -67
  103. package/mtds/field/field-observer.js.map +0 -1
  104. package/mtds/fieldset/fieldset-observer.d.ts +0 -1
  105. package/mtds/fieldset/fieldset-observer.js +0 -20
  106. package/mtds/fieldset/fieldset-observer.js.map +0 -1
  107. package/mtds/pagination/pagination-helper.d.ts +0 -13
  108. package/mtds/pagination/pagination-helper.js +0 -16
  109. package/mtds/pagination/pagination-helper.js.map +0 -1
  110. package/mtds/popover/popover-observer.d.ts +0 -1
  111. package/mtds/popover/popover-observer.js +0 -46
  112. package/mtds/popover/popover-observer.js.map +0 -1
  113. package/mtds/togglegroup/togglegroup-observer.d.ts +0 -1
  114. package/mtds/togglegroup/togglegroup-observer.js +0 -13
  115. package/mtds/togglegroup/togglegroup-observer.js.map +0 -1
  116. package/mtds/tooltip/tooltip-observer.d.ts +0 -1
  117. package/mtds/tooltip/tooltip-observer.js +0 -43
  118. package/mtds/tooltip/tooltip-observer.js.map +0 -1
  119. /package/mtds/{breadcrumbs/breadcrumbs-observer.d.ts → deprecations.d.ts} +0 -0
  120. /package/mtds/{dialog/dialog-observer.d.ts → tooltip/tooltip-element.d.ts} +0 -0
@@ -1,8 +1,9 @@
1
- import { JSX } from 'react';
2
- import { PolymorphicComponentPropWithRef } from '../react-types';
3
- export type BreadcrumbsProps<As extends React.ElementType = "nav"> = PolymorphicComponentPropWithRef<As, {
4
- "aria-label"?: string;
5
- }>;
6
- type BreadcrumbsComponent = <As extends React.ElementType = "nav">(props: BreadcrumbsProps<As>) => JSX.Element;
7
- export declare const Breadcrumbs: BreadcrumbsComponent;
8
- export {};
1
+ import { DSBreadcrumbsElement } from '@digdir/designsystemet-web';
2
+ import { CustomReactElementProps } from '../react-types';
3
+ export type BreadcrumbsProps = CustomReactElementProps<DSBreadcrumbsElement> & {
4
+ /**
5
+ * @deprecated `as` prop is no longer supported.
6
+ */
7
+ as?: never;
8
+ };
9
+ export declare const Breadcrumbs: import('react').ForwardRefExoticComponent<Omit<BreadcrumbsProps, "ref"> & import('react').RefAttributes<DSBreadcrumbsElement>>;
@@ -1,16 +1,14 @@
1
- import { jsx as e } from "react/jsx-runtime";
2
- import s from "clsx";
1
+ import { jsx as m } from "react/jsx-runtime";
3
2
  import { forwardRef as t } from "react";
4
- import c from "../styles.module.css.js";
3
+ import s from "../styles.module.css.js";
4
+ import { toCustomElementProps as e } from "../utils.js";
5
5
  const p = t(
6
- function({ as: a, className: o, ...r }, m) {
7
- return /* @__PURE__ */ e(
8
- a || "nav",
6
+ function(r, o) {
7
+ return /* @__PURE__ */ m(
8
+ "ds-breadcrumbs",
9
9
  {
10
- "aria-label": r["aria-label"] || "Du er her:",
11
- className: s(c.breadcrumbs, o),
12
- ref: m,
13
- ...r
10
+ ref: o,
11
+ ...e(r, s.breadcrumbs)
14
12
  }
15
13
  );
16
14
  }
@@ -1 +1 @@
1
- {"version":3,"file":"breadcrumbs.js","sources":["../../designsystem/breadcrumbs/breadcrumbs.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { forwardRef, type JSX } from \"react\";\nimport type {\n\tPolymorphicComponentPropWithRef,\n\tPolymorphicRef,\n} from \"../react-types\";\nimport styles from \"../styles.module.css\";\n\nexport type BreadcrumbsProps<As extends React.ElementType = \"nav\"> =\n\tPolymorphicComponentPropWithRef<As, { \"aria-label\"?: string }>;\n\ntype BreadcrumbsComponent = <As extends React.ElementType = \"nav\">(\n\tprops: BreadcrumbsProps<As>,\n) => JSX.Element;\n\nexport const Breadcrumbs: BreadcrumbsComponent = forwardRef<null>(\n\tfunction Breadcrumbs<As extends React.ElementType = \"nav\">(\n\t\t{ as, className, ...rest }: BreadcrumbsProps<As>,\n\t\tref?: PolymorphicRef<As>,\n\t) {\n\t\tconst Tag = as || \"nav\";\n\n\t\treturn (\n\t\t\t<Tag\n\t\t\t\taria-label={rest[\"aria-label\"] || \"Du er her:\"}\n\t\t\t\tclassName={clsx(styles.breadcrumbs, className)}\n\t\t\t\tref={ref}\n\t\t\t\t{...rest}\n\t\t\t/>\n\t\t);\n\t},\n) as BreadcrumbsComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n"],"names":["Breadcrumbs","forwardRef","as","className","rest","ref","jsx","clsx","styles"],"mappings":";;;;AAeO,MAAMA,IAAoCC;AAAA,EAChD,SACC,EAAE,IAAAC,GAAI,WAAAC,GAAW,GAAGC,EAAA,GACpBC,GACC;AAGD,WACC,gBAAAC;AAAA,MAHWJ,KAAM;AAAA,MAGhB;AAAA,QACA,cAAYE,EAAK,YAAY,KAAK;AAAA,QAClC,WAAWG,EAAKC,EAAO,aAAaL,CAAS;AAAA,QAC7C,KAAAE;AAAA,QACC,GAAGD;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AACD;"}
1
+ {"version":3,"file":"breadcrumbs.js","sources":["../../designsystem/breadcrumbs/breadcrumbs.tsx"],"sourcesContent":["import type { DSBreadcrumbsElement } from \"@digdir/designsystemet-web\";\nimport { forwardRef } from \"react\";\nimport type { CustomReactElementProps } from \"../react-types\";\nimport styles from \"../styles.module.css\";\nimport { toCustomElementProps } from \"../utils\";\n\nexport type BreadcrumbsProps = CustomReactElementProps<DSBreadcrumbsElement> & {\n\t/**\n\t * @deprecated `as` prop is no longer supported.\n\t */\n\tas?: never; // Remove `as` prop support\n};\n\nexport const Breadcrumbs = forwardRef<DSBreadcrumbsElement, BreadcrumbsProps>(\n\tfunction Breadcrumbs(rest, ref) {\n\t\treturn (\n\t\t\t<ds-breadcrumbs\n\t\t\t\tref={ref}\n\t\t\t\t{...toCustomElementProps(rest, styles.breadcrumbs)}\n\t\t\t/>\n\t\t);\n\t},\n);\n"],"names":["Breadcrumbs","forwardRef","rest","ref","jsx","toCustomElementProps","styles"],"mappings":";;;;AAaO,MAAMA,IAAcC;AAAA,EAC1B,SAAqBC,GAAMC,GAAK;AAC/B,WACC,gBAAAC;AAAA,MAAC;AAAA,MAAA;AAAA,QACA,KAAAD;AAAA,QACC,GAAGE,EAAqBH,GAAMI,EAAO,WAAW;AAAA,MAAA;AAAA,IAAA;AAAA,EAGpD;AACD;"}
@@ -1,13 +1,13 @@
1
- import C from "../styles.module.css.js";
2
- import { isBrowser as v, tag as c, defineElement as E, MTDSElement as k, onResize as T, onMutation as w, on as S, off as $, attr as d } from "../utils.js";
3
- import x from "./chart.css.js";
4
- import { toAxis as R } from "./chart-axis.js";
5
- import { toBars as A } from "./chart-bars.js";
6
- import { toLines as L } from "./chart-lines.js";
7
- import { toPies as O } from "./chart-pies.js";
8
- const u = "click,keydown,mousemove,mouseout", f = "mtds-chart-tooltip", i = v() ? document.getElementById(f) || c("div", {
1
+ import v from "../styles.module.css.js";
2
+ import { isBrowser as C, tag as d, defineElement as E, MTDSElement as k, onMutation as w, debounce as T, on as S, off as x, attr as l } from "../utils.js";
3
+ import $ from "./chart.css.js";
4
+ import { toAxis as A } from "./chart-axis.js";
5
+ import { toBars as L } from "./chart-bars.js";
6
+ import { toLines as O } from "./chart-lines.js";
7
+ import { toPies as R } from "./chart-pies.js";
8
+ const u = "click keydown mousemove mouseout", f = "mtds-chart-tooltip", a = C() ? document.getElementById(f) || d("div", {
9
9
  "aria-hidden": "true",
10
- class: C._tooltip,
10
+ class: v._tooltip,
11
11
  hidden: "",
12
12
  id: f
13
13
  }) : null;
@@ -21,61 +21,65 @@ class P extends k {
21
21
  super(), this.attachShadow({ mode: "open" });
22
22
  }
23
23
  connectedCallback() {
24
- this.#e = T(() => this.handleResize(), this), this.#t = w(() => this.attributeChangedCallback(), {
25
- attr: "data-tooltip",
26
- root: this
27
- }), this.attributeChangedCallback(), S(this, u, this);
24
+ const e = T(() => this.attributeChangedCallback(), 100), t = new ResizeObserver(() => this.handleResize());
25
+ t.observe(this), this.#e = () => t.disconnect(), this.#t = w(this, e, {
26
+ attributeFilter: ["data-tooltip"],
27
+ attributes: !0,
28
+ characterData: !0,
29
+ childList: !0,
30
+ subtree: !0
31
+ }), requestAnimationFrame(() => this.attributeChangedCallback()), S(this, u, this);
28
32
  }
29
33
  disconnectedCallback() {
30
- i && (i.hidden = !0), $(this, u, this), this.#e?.(), this.#t?.(), this.#t = this.#e = void 0;
34
+ a && (a.hidden = !0), x(this, u, this), this.#e?.(), this.#t?.(), this.#t = this.#e = void 0;
31
35
  }
32
36
  attributeChangedCallback() {
33
- const e = q(this.querySelector("table"));
37
+ const e = D(this.querySelector("table"));
34
38
  if (!e[0]) return;
35
- Array.from(this.shadowRoot?.children || []).map((p) => p.remove());
36
- const [t, s] = (d(this, "data-variant") || "column").split("-"), a = d(this, "data-aspect") || void 0, n = c("style", {}, x), r = c("div", {
39
+ Array.from(this.shadowRoot?.children || []).map((m) => m.remove());
40
+ const [t, s] = (l(this, "data-variant") || "column").split("-"), i = l(this, "data-aspect") || void 0, n = d("style", {}, $), r = d("div", {
37
41
  "aria-hidden": "hidden",
38
42
  class: "legends",
39
43
  role: "group"
40
44
  });
41
- e.slice(1).forEach(([{ value: p, style: g }]) => {
42
- r.appendChild(c("div", { class: "legend", style: g }, p));
45
+ e.slice(1).forEach(([{ value: m, style: g }]) => {
46
+ r.appendChild(d("div", { class: "legend", style: g }, m));
43
47
  });
44
- const { axis: h, groups: m, total: y } = R(e, { aspect: a, type: s });
45
- (t === "column" || t === "bar") && m.append(...A(e)), (t === "line" || t === "area") && m.append(L(e, { total: y, variant: t, type: s })), (t === "doughnut" || t === "pie") && this.shadowRoot?.append(O(e, { aspect: a, variant: t })), this.shadowRoot?.append(h, r, n);
48
+ const { axis: h, groups: p, total: y } = A(e, { aspect: i, type: s });
49
+ (t === "column" || t === "bar") && p.append(...L(e)), (t === "line" || t === "area") && p.append(O(e, { total: y, variant: t, type: s })), (t === "doughnut" || t === "pie") && this.shadowRoot?.append(R(e, { aspect: i, variant: t })), this.shadowRoot?.append(h, r, n);
46
50
  }
47
51
  handleEvent(e) {
48
- e.type === "click" || e.type === "keydown" ? H(e, this) : M(e);
52
+ e.type === "click" || e.type === "keydown" ? q(e, this) : z(e);
49
53
  }
50
54
  handleResize() {
51
55
  const e = this.shadowRoot?.firstElementChild, t = e?.firstElementChild;
52
56
  e?.classList.toggle("axisStepsYHalf", (t?.offsetHeight || 0) < 400), e?.classList.toggle("axisStepsXHalf", (t?.offsetWidth || 0) < 500);
53
57
  }
54
58
  }
55
- function H(o, e) {
59
+ function q(o, e) {
56
60
  if (o instanceof KeyboardEvent && o.key !== "Enter") return;
57
- const t = o.composedPath()[0], s = e.querySelector("table"), [a, n] = t instanceof Element && d(t, "data-event")?.split("-").map(Number) || [];
58
- s?.rows[a]?.cells[n]?.querySelector("a,button")?.click?.();
61
+ const t = o.composedPath()[0], s = e.querySelector("table"), [i, n] = t instanceof Element && l(t, "data-event")?.split("-").map(Number) || [];
62
+ s?.rows[i]?.cells[n]?.querySelector("a,button")?.click?.();
59
63
  }
60
64
  let b = "";
61
- function M(o) {
62
- if (!i) return;
63
- i?.isConnected || document.body.append(i);
65
+ function z(o) {
66
+ if (!a) return;
67
+ a?.isConnected || document.body.append(a);
64
68
  const e = o.composedPath()[0], t = e instanceof Element && e.getAttribute("aria-label") || "";
65
- t && (i.style.transform = `translate(${Math.min(o.clientX, window.innerWidth - i.clientWidth - 10)}px, ${o.clientY}px)`), t !== b && (t && (i.textContent = t), b = t, i.hidden = !t);
69
+ t && (a.style.transform = `translate(${Math.min(o.clientX, window.innerWidth)}px, ${o.clientY}px)`), t !== b && (t && (a.textContent = t), b = t, a.hidden = !t);
66
70
  }
67
- const l = (o) => o?.textContent?.trim() || "", q = (o) => Array.from(
71
+ const c = (o) => o?.textContent?.trim() || "", D = (o) => Array.from(
68
72
  o?.rows || [],
69
- (e, t) => Array.from(e.cells, (s, a) => {
70
- const n = l(e.cells[0]), r = l(o?.rows[0].cells[a]), h = `${n}: ${l(s)}${r ? ` (${r})` : ""}`;
71
- return {
72
- number: a && t && Number.parseFloat(l(s)) || 0,
73
+ (e, t) => Array.from(e.cells, (s, i) => {
74
+ const n = c(e.cells[0]), r = c(o?.rows[0].cells[i]), h = `${n}: ${c(s)}${r ? ` (${r})` : ""}`;
75
+ return l(s, "tabindex", "-1"), {
76
+ number: i && t && Number.parseFloat(c(s)) || 0,
73
77
  // First row and column is not a number
74
- event: s.querySelector("a,button") && `${t}-${a}`,
78
+ event: s.querySelector("a,button") && `${t}-${i}`,
75
79
  // Reference to proxy events
76
80
  style: `--color: var(--mtdsc-chart-color-${t}, var(--mtdsc-chart-color-base))`,
77
- value: l(s),
78
- tooltip: d(s, "data-tooltip") || h
81
+ value: c(s),
82
+ tooltip: l(s, "data-tooltip") || h
79
83
  };
80
84
  })
81
85
  );
@@ -1 +1 @@
1
- {"version":3,"file":"chart-element.js","sources":["../../designsystem/chart/chart-element.ts"],"sourcesContent":["import styles from \"../styles.module.css\";\nimport {\n\tattr,\n\tdefineElement,\n\tisBrowser,\n\tMTDSElement,\n\toff,\n\ton,\n\tonMutation,\n\tonResize,\n\ttag,\n} from \"../utils\";\nimport css from \"./chart.css?raw\";\nimport { toAxis } from \"./chart-axis\";\nimport { toBars } from \"./chart-bars\";\nimport { toLines } from \"./chart-lines\";\nimport { toPies } from \"./chart-pies\";\n\nexport type ChartData = ReturnType<typeof toData>;\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t\"mtds-chart\": MTDSChartElement;\n\t}\n}\n\nconst EVENTS = \"click,keydown,mousemove,mouseout\";\nconst TOOLTIP_ID = \"mtds-chart-tooltip\";\nconst TOOLTIP = isBrowser()\n\t? document.getElementById(TOOLTIP_ID) ||\n\t\ttag(\"div\", {\n\t\t\t\"aria-hidden\": \"true\",\n\t\t\tclass: styles._tooltip,\n\t\t\thidden: \"\",\n\t\t\tid: TOOLTIP_ID,\n\t\t})\n\t: null;\n\nexport class MTDSChartElement extends MTDSElement {\n\t#unmutate?: () => void;\n\t#unresize?: () => void;\n\n\tstatic get observedAttributes() {\n\t\treturn [\"data-variant\", \"data-aspect\"]; // Using ES2015 syntax for backwards compatibility\n\t}\n\tconstructor() {\n\t\tsuper();\n\t\tthis.attachShadow({ mode: \"open\" });\n\t}\n\tconnectedCallback() {\n\t\tthis.#unresize = onResize(() => this.handleResize(), this);\n\t\tthis.#unmutate = onMutation(() => this.attributeChangedCallback(), {\n\t\t\tattr: \"data-tooltip\",\n\t\t\troot: this,\n\t\t});\n\t\tthis.attributeChangedCallback(); // Initial setup\n\t\ton(this, EVENTS, this);\n\t}\n\tdisconnectedCallback() {\n\t\tif (TOOLTIP) TOOLTIP.hidden = true;\n\t\toff(this, EVENTS, this);\n\t\tthis.#unresize?.();\n\t\tthis.#unmutate?.();\n\t\tthis.#unmutate = this.#unresize = undefined;\n\t}\n\tattributeChangedCallback() {\n\t\tconst data = toData(this.querySelector(\"table\"));\n\t\tif (!data[0]) return; // We require at least one row\n\n\t\tArray.from(this.shadowRoot?.children || []).map((el) => el.remove()); // Clear shadowRoot\n\t\tconst [variant, type] = (attr(this, \"data-variant\") || \"column\").split(\"-\");\n\t\tconst aspect = attr(this, \"data-aspect\") || undefined;\n\t\tconst style = tag(\"style\", {}, css);\n\t\tconst legend = tag(\"div\", {\n\t\t\t\"aria-hidden\": \"hidden\",\n\t\t\tclass: \"legends\",\n\t\t\trole: \"group\",\n\t\t});\n\t\tdata.slice(1).forEach(([{ value, style }]) => {\n\t\t\tlegend.appendChild(tag(\"div\", { class: \"legend\", style }, value));\n\t\t});\n\n\t\tconst { axis, groups, total } = toAxis(data, { aspect, type });\n\t\tif (variant === \"column\" || variant === \"bar\")\n\t\t\tgroups.append(...toBars(data));\n\t\tif (variant === \"line\" || variant === \"area\")\n\t\t\tgroups.append(toLines(data, { total, variant, type }));\n\t\tif (variant === \"doughnut\" || variant === \"pie\")\n\t\t\tthis.shadowRoot?.append(toPies(data, { aspect, variant }));\n\n\t\tthis.shadowRoot?.append(axis, legend, style); // Axis must be first\n\t}\n\thandleEvent(e: Event) {\n\t\tif (e.type === \"click\" || e.type === \"keydown\") onClick(e, this);\n\t\telse onMoveTooltip(e as MouseEvent);\n\t}\n\thandleResize() {\n\t\tconst axis = this.shadowRoot?.firstElementChild as HTMLElement | null;\n\t\tconst steps = axis?.firstElementChild as HTMLElement | null;\n\t\taxis?.classList.toggle(\"axisStepsYHalf\", (steps?.offsetHeight || 0) < 400);\n\t\taxis?.classList.toggle(\"axisStepsXHalf\", (steps?.offsetWidth || 0) < 500);\n\t}\n}\n\nfunction onClick(event: Event, self: MTDSChartElement) {\n\tif (event instanceof KeyboardEvent && event.key !== \"Enter\") return; // Only handle enter key\n\tconst el = event.composedPath()[0];\n\tconst table = self.querySelector(\"table\");\n\tconst [tr, td] =\n\t\t(el instanceof Element && attr(el, \"data-event\")?.split(\"-\").map(Number)) ||\n\t\t[];\n\n\ttable?.rows[tr]?.cells[td]?.querySelector<HTMLElement>(\"a,button\")?.click?.();\n}\n\nlet TOOLTIP_TEXT = \"\";\nfunction onMoveTooltip(event: MouseEvent) {\n\tif (!TOOLTIP) return;\n\tif (!TOOLTIP?.isConnected) document.body.append(TOOLTIP); // Ensure connected\n\n\tconst el = event.composedPath()[0];\n\tconst tip = (el instanceof Element && el.getAttribute(\"aria-label\")) || \"\";\n\n\tif (tip)\n\t\tTOOLTIP.style.transform = `translate(${Math.min(event.clientX, window.innerWidth - TOOLTIP.clientWidth - 10)}px, ${event.clientY}px)`;\n\tif (tip !== TOOLTIP_TEXT) {\n\t\tif (tip) TOOLTIP.textContent = tip;\n\t\tTOOLTIP_TEXT = tip;\n\t\tTOOLTIP.hidden = !tip;\n\t}\n}\n\nconst text = (el?: Element | null) => el?.textContent?.trim() || \"\"; // Helper to get trimmed text\nconst toData = (table?: HTMLTableElement | null) =>\n\tArray.from(table?.rows || [], (row, rowIndex) =>\n\t\tArray.from(row.cells, (cell, cellIndex) => {\n\t\t\tconst rowHeading = text(row.cells[0]);\n\t\t\tconst colHeading = text(table?.rows[0].cells[cellIndex]);\n\t\t\tconst tooltip = `${rowHeading}: ${text(cell)}${colHeading ? ` (${colHeading})` : \"\"}`;\n\n\t\t\treturn {\n\t\t\t\tnumber: (cellIndex && rowIndex && Number.parseFloat(text(cell))) || 0, // First row and column is not a number\n\t\t\t\tevent: cell.querySelector(\"a,button\") && `${rowIndex}-${cellIndex}`, // Reference to proxy events\n\t\t\t\tstyle: `--color: var(--mtdsc-chart-color-${rowIndex}, var(--mtdsc-chart-color-base))`,\n\t\t\t\tvalue: text(cell),\n\t\t\t\ttooltip: attr(cell, \"data-tooltip\") || tooltip,\n\t\t\t};\n\t\t}),\n\t);\n\ndefineElement(\"mtds-chart\", MTDSChartElement);\n"],"names":["EVENTS","TOOLTIP_ID","TOOLTIP","isBrowser","tag","styles","MTDSChartElement","MTDSElement","#unmutate","#unresize","onResize","onMutation","on","off","data","toData","el","variant","type","attr","aspect","style","css","legend","value","axis","groups","total","toAxis","toBars","toLines","toPies","onClick","steps","event","self","table","tr","td","TOOLTIP_TEXT","onMoveTooltip","tip","text","row","rowIndex","cell","cellIndex","rowHeading","colHeading","tooltip","defineElement"],"mappings":";;;;;;;AA0BA,MAAMA,IAAS,oCACTC,IAAa,sBACbC,IAAUC,MACb,SAAS,eAAeF,CAAU,KACnCG,EAAI,OAAO;AAAA,EACV,eAAe;AAAA,EACf,OAAOC,EAAO;AAAA,EACd,QAAQ;AAAA,EACR,IAAIJ;AACL,CAAC,IACA;AAEI,MAAMK,UAAyBC,EAAY;AAAA,EACjDC;AAAA,EACAC;AAAA,EAEA,WAAW,qBAAqB;AAC/B,WAAO,CAAC,gBAAgB,aAAa;AAAA,EACtC;AAAA,EACA,cAAc;AACb,UAAA,GACA,KAAK,aAAa,EAAE,MAAM,OAAA,CAAQ;AAAA,EACnC;AAAA,EACA,oBAAoB;AACnB,SAAKA,KAAYC,EAAS,MAAM,KAAK,aAAA,GAAgB,IAAI,GACzD,KAAKF,KAAYG,EAAW,MAAM,KAAK,4BAA4B;AAAA,MAClE,MAAM;AAAA,MACN,MAAM;AAAA,IAAA,CACN,GACD,KAAK,yBAAA,GACLC,EAAG,MAAMZ,GAAQ,IAAI;AAAA,EACtB;AAAA,EACA,uBAAuB;AACtB,IAAIE,QAAiB,SAAS,KAC9BW,EAAI,MAAMb,GAAQ,IAAI,GACtB,KAAKS,KAAA,GACL,KAAKD,KAAA,GACL,KAAKA,KAAY,KAAKC,KAAY;AAAA,EACnC;AAAA,EACA,2BAA2B;AAC1B,UAAMK,IAAOC,EAAO,KAAK,cAAc,OAAO,CAAC;AAC/C,QAAI,CAACD,EAAK,CAAC,EAAG;AAEd,UAAM,KAAK,KAAK,YAAY,YAAY,CAAA,CAAE,EAAE,IAAI,CAACE,MAAOA,EAAG,OAAA,CAAQ;AACnE,UAAM,CAACC,GAASC,CAAI,KAAKC,EAAK,MAAM,cAAc,KAAK,UAAU,MAAM,GAAG,GACpEC,IAASD,EAAK,MAAM,aAAa,KAAK,QACtCE,I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,OAAOA,EAAK,cAAc,UAAU,KAAK,GAAGD,CAAQ,IAAIE,CAAS;AAAA;AAAA,MACjE,OAAO,oCAAoCF,CAAQ;AAAA,MACnD,OAAOF,EAAKG,CAAI;AAAA,MAChB,SAAS1B,EAAK0B,GAAM,cAAc,KAAKI;AAAA,IAAA;AAAA,EAEzC,CAAC;AACF;AAEDC,EAAc,cAAc5C,CAAgB;"}
1
+ {"version":3,"file":"chart-element.js","sources":["../../designsystem/chart/chart-element.ts"],"sourcesContent":["import styles from \"../styles.module.css\";\nimport {\n\tattr,\n\tdebounce,\n\tdefineElement,\n\tisBrowser,\n\tMTDSElement,\n\toff,\n\ton,\n\tonMutation,\n\ttag,\n} from \"../utils\";\nimport css from \"./chart.css?raw\";\nimport { toAxis } from \"./chart-axis\";\nimport { toBars } from \"./chart-bars\";\nimport { toLines } from \"./chart-lines\";\nimport { toPies } from \"./chart-pies\";\n\nexport type ChartData = ReturnType<typeof toData>;\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t\"mtds-chart\": MTDSChartElement;\n\t}\n}\n\nconst EVENTS = \"click keydown mousemove mouseout\";\nconst TOOLTIP_ID = \"mtds-chart-tooltip\";\nconst TOOLTIP = isBrowser()\n\t? document.getElementById(TOOLTIP_ID) ||\n\t\ttag(\"div\", {\n\t\t\t\"aria-hidden\": \"true\",\n\t\t\tclass: styles._tooltip,\n\t\t\thidden: \"\",\n\t\t\tid: TOOLTIP_ID,\n\t\t})\n\t: null;\n\nexport class MTDSChartElement extends MTDSElement {\n\t#unmutate?: () => void;\n\t#unresize?: () => void;\n\n\tstatic get observedAttributes() {\n\t\treturn [\"data-variant\", \"data-aspect\"]; // Using ES2015 syntax for backwards compatibility\n\t}\n\tconstructor() {\n\t\tsuper();\n\t\tthis.attachShadow({ mode: \"open\" });\n\t}\n\tconnectedCallback() {\n\t\tconst render = debounce(() => this.attributeChangedCallback(), 100);\n\t\tconst resize = new ResizeObserver(() => this.handleResize());\n\t\tresize.observe(this);\n\t\tthis.#unresize = () => resize.disconnect();\n\t\tthis.#unmutate = onMutation(this, render, {\n\t\t\tattributeFilter: [\"data-tooltip\"],\n\t\t\tattributes: true,\n\t\t\tcharacterData: true,\n\t\t\tchildList: true,\n\t\t\tsubtree: true,\n\t\t});\n\t\trequestAnimationFrame(() => this.attributeChangedCallback()); // Initial setup when children is mounted\n\t\ton(this, EVENTS, this);\n\t}\n\tdisconnectedCallback() {\n\t\tif (TOOLTIP) TOOLTIP.hidden = true;\n\t\toff(this, EVENTS, this);\n\t\tthis.#unresize?.();\n\t\tthis.#unmutate?.();\n\t\tthis.#unmutate = this.#unresize = undefined;\n\t}\n\tattributeChangedCallback() {\n\t\tconst data = toData(this.querySelector(\"table\"));\n\t\tif (!data[0]) return; // We require at least one row\n\n\t\tArray.from(this.shadowRoot?.children || []).map((el) => el.remove()); // Clear shadowRoot\n\t\tconst [variant, type] = (attr(this, \"data-variant\") || \"column\").split(\"-\");\n\t\tconst aspect = attr(this, \"data-aspect\") || undefined;\n\t\tconst style = tag(\"style\", {}, css);\n\t\tconst legend = tag(\"div\", {\n\t\t\t\"aria-hidden\": \"hidden\",\n\t\t\tclass: \"legends\",\n\t\t\trole: \"group\",\n\t\t});\n\t\tdata.slice(1).forEach(([{ value, style }]) => {\n\t\t\tlegend.appendChild(tag(\"div\", { class: \"legend\", style }, value));\n\t\t});\n\n\t\tconst { axis, groups, total } = toAxis(data, { aspect, type });\n\t\tif (variant === \"column\" || variant === \"bar\")\n\t\t\tgroups.append(...toBars(data));\n\t\tif (variant === \"line\" || variant === \"area\")\n\t\t\tgroups.append(toLines(data, { total, variant, type }));\n\t\tif (variant === \"doughnut\" || variant === \"pie\")\n\t\t\tthis.shadowRoot?.append(toPies(data, { aspect, variant }));\n\n\t\tthis.shadowRoot?.append(axis, legend, style); // Axis must be first\n\t}\n\thandleEvent(e: Event) {\n\t\tif (e.type === \"click\" || e.type === \"keydown\") onClick(e, this);\n\t\telse onMoveTooltip(e as MouseEvent);\n\t}\n\thandleResize() {\n\t\tconst axis = this.shadowRoot?.firstElementChild as HTMLElement | null;\n\t\tconst steps = axis?.firstElementChild as HTMLElement | null;\n\t\taxis?.classList.toggle(\"axisStepsYHalf\", (steps?.offsetHeight || 0) < 400);\n\t\taxis?.classList.toggle(\"axisStepsXHalf\", (steps?.offsetWidth || 0) < 500);\n\t}\n}\n\nfunction onClick(event: Event, self: MTDSChartElement) {\n\tif (event instanceof KeyboardEvent && event.key !== \"Enter\") return; // Only handle enter key\n\tconst el = event.composedPath()[0];\n\tconst table = self.querySelector(\"table\");\n\tconst [tr, td] =\n\t\t(el instanceof Element && attr(el, \"data-event\")?.split(\"-\").map(Number)) ||\n\t\t[];\n\n\ttable?.rows[tr]?.cells[td]?.querySelector<HTMLElement>(\"a,button\")?.click?.();\n}\n\nlet TOOLTIP_TEXT = \"\";\nfunction onMoveTooltip(event: MouseEvent) {\n\tif (!TOOLTIP) return;\n\tif (!TOOLTIP?.isConnected) document.body.append(TOOLTIP); // Ensure connected\n\n\tconst el = event.composedPath()[0];\n\tconst tip = (el instanceof Element && el.getAttribute(\"aria-label\")) || \"\";\n\n\tif (tip)\n\t\tTOOLTIP.style.transform = `translate(${Math.min(event.clientX, window.innerWidth)}px, ${event.clientY}px)`;\n\tif (tip !== TOOLTIP_TEXT) {\n\t\tif (tip) TOOLTIP.textContent = tip;\n\t\tTOOLTIP_TEXT = tip;\n\t\tTOOLTIP.hidden = !tip;\n\t}\n}\n\nconst text = (el?: Element | null) => el?.textContent?.trim() || \"\"; // Helper to get trimmed text\nconst toData = (table?: HTMLTableElement | null) =>\n\tArray.from(table?.rows || [], (row, rowIndex) =>\n\t\tArray.from(row.cells, (cell, cellIndex) => {\n\t\t\tconst rowHeading = text(row.cells[0]);\n\t\t\tconst colHeading = text(table?.rows[0].cells[cellIndex]);\n\t\t\tconst tooltip = `${rowHeading}: ${text(cell)}${colHeading ? ` (${colHeading})` : \"\"}`;\n\t\t\tattr(cell, \"tabindex\", \"-1\");\n\n\t\t\treturn {\n\t\t\t\tnumber: (cellIndex && rowIndex && Number.parseFloat(text(cell))) || 0, // First row and column is not a number\n\t\t\t\tevent: cell.querySelector(\"a,button\") && `${rowIndex}-${cellIndex}`, // Reference to proxy events\n\t\t\t\tstyle: `--color: var(--mtdsc-chart-color-${rowIndex}, var(--mtdsc-chart-color-base))`,\n\t\t\t\tvalue: text(cell),\n\t\t\t\ttooltip: attr(cell, \"data-tooltip\") || tooltip,\n\t\t\t};\n\t\t}),\n\t);\n\ndefineElement(\"mtds-chart\", MTDSChartElement);\n"],"names":["EVENTS","TOOLTIP_ID","TOOLTIP","isBrowser","tag","styles","MTDSChartElement","MTDSElement","#unmutate","#unresize","render","debounce","resize","onMutation","on","off","data","toData","el","variant","type","attr","aspect","style","css","legend","value","axis","groups","total","toAxis","toBars","toLines","toPies","onClick","steps","event","self","table","tr","td","TOOLTIP_TEXT","onMoveTooltip","tip","text","row","rowIndex","cell","cellIndex","rowHeading","colHeading","tooltip","defineElement"],"mappings":";;;;;;;AA0BA,MAAMA,IAAS,oCACTC,IAAa,sBACbC,IAAUC,MACb,SAAS,eAAeF,CAAU,KACnCG,EAAI,OAAO;AAAA,EACV,eAAe;AAAA,EACf,OAAOC,EAAO;AAAA,EACd,QAAQ;AAAA,EACR,IAAIJ;AACL,CAAC,IACA;AAEI,MAAMK,UAAyBC,EAAY;AAAA,EACjDC;AAAA,EACAC;AAAA,EAEA,WAAW,qBAAqB;AAC/B,WAAO,CAAC,gBAAgB,aAAa;AAAA,EACtC;AAAA,EACA,cAAc;AACb,UAAA,GACA,KAAK,aAAa,EAAE,MAAM,OAAA,CAAQ;AAAA,EACnC;AAAA,EACA,oBAAoB;AACnB,UAAMC,IAASC,EAAS,MAAM,KAAK,yBAAA,GAA4B,GAAG,GAC5DC,IAAS,IAAI,eAAe,MAAM,KAAK,cAAc;AAC3D,IAAAA,EAAO,QAAQ,IAAI,GACnB,KAAKH,KAAY,MAAMG,EAAO,WAAA,GAC9B,KAAKJ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E,EAAIyB,MACHzC,EAAQ,MAAM,YAAY,aAAa,KAAK,IAAIkC,EAAM,SAAS,OAAO,UAAU,CAAC,OAAOA,EAAM,OAAO,QAClGO,MAAQF,MACPE,QAAa,cAAcA,IAC/BF,IAAeE,GACfzC,EAAQ,SAAS,CAACyC;AAEpB;AAEA,MAAMC,IAAO,CAAC1B,MAAwBA,GAAI,aAAa,UAAU,IAC3DD,IAAS,CAACqB,MACf,MAAM;AAAA,EAAKA,GAAO,QAAQ,CAAA;AAAA,EAAI,CAACO,GAAKC,MACnC,MAAM,KAAKD,EAAI,OAAO,CAACE,GAAMC,MAAc;AAC1C,UAAMC,IAAaL,EAAKC,EAAI,MAAM,CAAC,CAAC,GAC9BK,IAAaN,EAAKN,GAAO,KAAK,CAAC,EAAE,MAAMU,CAAS,CAAC,GACjDG,IAAU,GAAGF,CAAU,KAAKL,EAAKG,CAAI,CAAC,GAAGG,IAAa,KAAKA,CAAU,MAAM,EAAE;AACnF,WAAA7B,EAAK0B,GAAM,YAAY,IAAI,GAEpB;AAAA,MACN,QAASC,KAAaF,KAAY,OAAO,WAAWF,EAAKG,CAAI,CAAC,KAAM;AAAA;AAAA,MACpE,OAAOA,EAAK,cAAc,UAAU,KAAK,GAAGD,CAAQ,IAAIE,CAAS;AAAA;AAAA,MACjE,OAAO,oCAAoCF,CAAQ;AAAA,MACnD,OAAOF,EAAKG,CAAI;AAAA,MAChB,SAAS1B,EAAK0B,GAAM,cAAc,KAAKI;AAAA,IAAA;AAAA,EAEzC,CAAC;AACF;AAEDC,EAAc,cAAc9C,CAAgB;"}
@@ -1,17 +1,51 @@
1
1
  import { jsx as r, jsxs as d } from "react/jsx-runtime";
2
- import { forwardRef as $ } from "react";
3
- import { toCustomElementProps as p } from "../utils.js";
2
+ import { forwardRef as s } from "react";
3
+ import { toCustomElementProps as $ } from "../utils.js";
4
4
  import "./chart-element.js";
5
- let t = 0;
6
- const u = $(function({ data: l, children: i, ...m }, n) {
7
- return /* @__PURE__ */ r("mtds-chart", { ref: n, ...p(m), children: l ? /* @__PURE__ */ d("table", { children: [
8
- /* @__PURE__ */ r("thead", { children: l.slice(0, 1).map((o, c) => /* @__PURE__ */ r("tr", { children: o.map((h, e) => /* @__PURE__ */ r("th", { children: h }, `${e}_${t}`)) }, `${c}_${t}`)) }),
9
- /* @__PURE__ */ r("tbody", { children: l.slice(1).map((o, c) => /* @__PURE__ */ r("tr", { children: o.map(
10
- (h, e) => e ? /* @__PURE__ */ r("td", { children: h }, `${e}_${t}`) : /* @__PURE__ */ r("th", { children: h }, `${e}_${t}`)
11
- ) }, `${c}_${t}`)) })
12
- ] }, `table_${++t}`) : i });
5
+ import "../alert/alert.js";
6
+ import "../app/app.js";
7
+ import "../avatar/avatar.js";
8
+ import "../badge/badge.js";
9
+ import "../breadcrumbs/breadcrumbs.js";
10
+ import "../button/button.js";
11
+ import "../card/card.js";
12
+ import "../chip/chip.js";
13
+ import "../details/details.js";
14
+ import "../dialog/dialog.js";
15
+ import "../divider/divider.js";
16
+ import "../errorsummary/errorsummary.js";
17
+ import "../field/field.js";
18
+ import "../fieldset/fieldset.js";
19
+ import "../fileupload/fileupload.js";
20
+ import "../helptext/helptext.js";
21
+ import "../input/input.js";
22
+ import "../law/law.js";
23
+ import "../layout/layout.js";
24
+ import "../link/link.js";
25
+ import "../logo/logo.js";
26
+ import "../pagination/pagination.js";
27
+ import "../popover/popover.js";
28
+ import "../progress/progress.js";
29
+ import "../skeleton/skeleton.js";
30
+ import "../spinner/spinner.js";
31
+ import "../steps/steps.js";
32
+ import { Table as o } from "../table/table.js";
33
+ import "../tabs/tabs.js";
34
+ import "../tag/tag.js";
35
+ import "../toast/toast.js";
36
+ import "../togglegroup/togglegroup.js";
37
+ import "../typography/typography.js";
38
+ import "../validation/validation.js";
39
+ let i = 0;
40
+ const Z = s(function({ data: p, children: h, ...l }, c) {
41
+ return /* @__PURE__ */ r("mtds-chart", { ref: c, ...$(l), children: p ? /* @__PURE__ */ d(o, { children: [
42
+ /* @__PURE__ */ r(o.Thead, { children: p.slice(0, 1).map((e, n) => /* @__PURE__ */ r(o.Tr, { children: e.map((m, t) => /* @__PURE__ */ r(o.Th, { suppressHydrationWarning: !0, children: m }, `${t}_${i}`)) }, `${n}_${i}`)) }),
43
+ /* @__PURE__ */ r(o.Tbody, { children: p.slice(1).map((e, n) => /* @__PURE__ */ r(o.Tr, { children: e.map(
44
+ (m, t) => t ? /* @__PURE__ */ r(o.Td, { children: m }, `${t}_${i}`) : /* @__PURE__ */ r(o.Th, { children: m }, `${t}_${i}`)
45
+ ) }, `${n}_${i}`)) })
46
+ ] }, `table_${++i}`) : h });
13
47
  });
14
48
  export {
15
- u as Chart
49
+ Z as Chart
16
50
  };
17
51
  //# sourceMappingURL=chart.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"chart.js","sources":["../../designsystem/chart/chart.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport { toCustomElementProps } from \"../utils\";\nimport \"./chart-element\";\nimport type { CustomReactElementProps } from \"../react-types\";\nimport type { MTDSChartElement } from \"./chart-element\";\n\ndeclare global {\n\tnamespace React.JSX {\n\t\tinterface IntrinsicElements {\n\t\t\t\"mtds-chart\": ChartProps;\n\t\t}\n\t}\n}\n\nexport type ChartProps = CustomReactElementProps<MTDSChartElement> & {\n\tdata?: (number | string)[][];\n\t\"data-legend\"?: \"none\" | \"hidden\" | \"false\" | \"true\" | boolean;\n\t\"data-axis\"?: \"none\" | \"hidden\" | \"false\" | \"true\" | boolean;\n\t\"data-variant\"?:\n\t\t| \"area\"\n\t\t| \"bar\"\n\t\t| \"bar-stacked\"\n\t\t| \"column\"\n\t\t| \"column-stacked\"\n\t\t| \"doughnut\"\n\t\t| \"line\"\n\t\t| \"pie\";\n};\n\nlet RENDER = 0; // Ensure re-render on data change\nexport const Chart = forwardRef<MTDSChartElement, ChartProps>(function Chart(\n\t{ data, children, ...rest },\n\tref,\n) {\n\treturn (\n\t\t<mtds-chart ref={ref} {...toCustomElementProps(rest)}>\n\t\t\t{data ? (\n\t\t\t\t<table key={`table_${++RENDER}`}>\n\t\t\t\t\t<thead>\n\t\t\t\t\t\t{data.slice(0, 1).map((tr, row) => (\n\t\t\t\t\t\t\t<tr key={`${row}_${RENDER}`}>\n\t\t\t\t\t\t\t\t{tr.map((td, i) => (\n\t\t\t\t\t\t\t\t\t<th key={`${i}_${RENDER}`}>{td}</th>\n\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</thead>\n\t\t\t\t\t<tbody>\n\t\t\t\t\t\t{data.slice(1).map((tr, row) => (\n\t\t\t\t\t\t\t<tr key={`${row}_${RENDER}`}>\n\t\t\t\t\t\t\t\t{tr.map((td, i) =>\n\t\t\t\t\t\t\t\t\ti ? (\n\t\t\t\t\t\t\t\t\t\t<td key={`${i}_${RENDER}`}>{td}</td>\n\t\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t\t<th key={`${i}_${RENDER}`}>{td}</th>\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</tbody>\n\t\t\t\t</table>\n\t\t\t) : (\n\t\t\t\tchildren\n\t\t\t)}\n\t\t</mtds-chart>\n\t);\n});\n"],"names":["RENDER","Chart","forwardRef","data","children","rest","ref","jsx","toCustomElementProps","jsxs","tr","row","td","i"],"mappings":";;;;AA6BA,IAAIA,IAAS;AACN,MAAMC,IAAQC,EAAyC,SAC7D,EAAE,MAAAC,GAAM,UAAAC,GAAU,GAAGC,EAAA,GACrBC,GACC;AACD,SACC,gBAAAC,EAAC,gBAAW,KAAAD,GAAW,GAAGE,EAAqBH,CAAI,GACjD,UAAAF,IACA,gBAAAM,EAAC,SAAA,EACA,UAAA;AAAA,IAAA,gBAAAF,EAAC,SAAA,EACC,UAAAJ,EAAK,MAAM,GAAG,CAAC,EAAE,IAAI,CAACO,GAAIC,MAC1B,gBAAAJ,EAAC,MAAA,EACC,UAAAG,EAAG,IAAI,CAACE,GAAIC,MACZ,gBAAAN,EAAC,MAAA,EAA2B,UAAAK,EAAA,GAAnB,GAAGC,CAAC,IAAIb,CAAM,EAAQ,CAC/B,EAAA,GAHO,GAAGW,CAAG,IAAIX,CAAM,EAIzB,CACA,GACF;AAAA,IACA,gBAAAO,EAAC,SAAA,EACC,UAAAJ,EAAK,MAAM,CAAC,EAAE,IAAI,CAACO,GAAIC,MACvB,gBAAAJ,EAAC,MAAA,EACC,UAAAG,EAAG;AAAA,MAAI,CAACE,GAAIC,MACZA,sBACE,MAAA,EAA2B,UAAAD,EAAA,GAAnB,GAAGC,CAAC,IAAIb,CAAM,EAAQ,sBAE9B,MAAA,EAA2B,UAAAY,EAAA,GAAnB,GAAGC,CAAC,IAAIb,CAAM,EAAQ;AAAA,IAAA,KALzB,GAAGW,CAAG,IAAIX,CAAM,EAQzB,CACA,EAAA,CACF;AAAA,EAAA,EAAA,GAtBW,SAAS,EAAEA,CAAM,EAuB7B,IAEAI,GAEF;AAEF,CAAC;"}
1
+ {"version":3,"file":"chart.js","sources":["../../designsystem/chart/chart.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport { toCustomElementProps } from \"../utils\";\nimport \"./chart-element\";\nimport { Table } from \"../react\";\nimport type { CustomReactElementProps } from \"../react-types\";\nimport type { MTDSChartElement } from \"./chart-element\";\n\ndeclare global {\n\tnamespace React.JSX {\n\t\tinterface IntrinsicElements {\n\t\t\t\"mtds-chart\": ChartProps;\n\t\t}\n\t}\n}\n\nexport type ChartProps = CustomReactElementProps<MTDSChartElement> & {\n\tdata?: (number | string)[][];\n\t\"data-legend\"?: \"none\" | \"hidden\" | \"false\" | \"true\" | boolean;\n\t\"data-axis\"?: \"none\" | \"hidden\" | \"false\" | \"true\" | boolean;\n\t\"data-variant\"?:\n\t\t| \"area\"\n\t\t| \"bar\"\n\t\t| \"bar-stacked\"\n\t\t| \"column\"\n\t\t| \"column-stacked\"\n\t\t| \"doughnut\"\n\t\t| \"line\"\n\t\t| \"pie\";\n};\n\nlet RENDER = 0; // Ensure re-render on data change\nexport const Chart = forwardRef<MTDSChartElement, ChartProps>(function Chart(\n\t{ data, children, ...rest },\n\tref,\n) {\n\treturn (\n\t\t<mtds-chart ref={ref} {...toCustomElementProps(rest)}>\n\t\t\t{data ? (\n\t\t\t\t<Table key={`table_${++RENDER}`}>\n\t\t\t\t\t<Table.Thead>\n\t\t\t\t\t\t{data.slice(0, 1).map((tr, row) => (\n\t\t\t\t\t\t\t<Table.Tr key={`${row}_${RENDER}`}>\n\t\t\t\t\t\t\t\t{tr.map((td, i) => (\n\t\t\t\t\t\t\t\t\t<Table.Th suppressHydrationWarning key={`${i}_${RENDER}`}>\n\t\t\t\t\t\t\t\t\t\t{td}\n\t\t\t\t\t\t\t\t\t</Table.Th>\n\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t</Table.Tr>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</Table.Thead>\n\t\t\t\t\t<Table.Tbody>\n\t\t\t\t\t\t{data.slice(1).map((tr, row) => (\n\t\t\t\t\t\t\t<Table.Tr key={`${row}_${RENDER}`}>\n\t\t\t\t\t\t\t\t{tr.map((td, i) =>\n\t\t\t\t\t\t\t\t\ti ? (\n\t\t\t\t\t\t\t\t\t\t<Table.Td key={`${i}_${RENDER}`}>{td}</Table.Td>\n\t\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t\t<Table.Th key={`${i}_${RENDER}`}>{td}</Table.Th>\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</Table.Tr>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</Table.Tbody>\n\t\t\t\t</Table>\n\t\t\t) : (\n\t\t\t\tchildren\n\t\t\t)}\n\t\t</mtds-chart>\n\t);\n});\n"],"names":["RENDER","Chart","forwardRef","data","children","rest","ref","jsx","toCustomElementProps","jsxs","Table","tr","row","td","i"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,IAAIA,IAAS;AACN,MAAMC,IAAQC,EAAyC,SAC7D,EAAE,MAAAC,GAAM,UAAAC,GAAU,GAAGC,EAAA,GACrBC,GACC;AACD,SACC,gBAAAC,EAAC,gBAAW,KAAAD,GAAW,GAAGE,EAAqBH,CAAI,GACjD,UAAAF,IACA,gBAAAM,EAACC,GAAA,EACA,UAAA;AAAA,IAAA,gBAAAH,EAACG,EAAM,OAAN,EACC,YAAK,MAAM,GAAG,CAAC,EAAE,IAAI,CAACC,GAAIC,MAC1B,gBAAAL,EAACG,EAAM,IAAN,EACC,UAAAC,EAAG,IAAI,CAACE,GAAIC,MACZ,gBAAAP,EAACG,EAAM,IAAN,EAAS,0BAAwB,IAChC,UAAAG,EAAA,GADsC,GAAGC,CAAC,IAAId,CAAM,EAEtD,CACA,KALa,GAAGY,CAAG,IAAIZ,CAAM,EAM/B,CACA,GACF;AAAA,sBACCU,EAAM,OAAN,EACC,UAAAP,EAAK,MAAM,CAAC,EAAE,IAAI,CAACQ,GAAIC,MACvB,gBAAAL,EAACG,EAAM,IAAN,EACC,UAAAC,EAAG;AAAA,MAAI,CAACE,GAAIC,MACZA,IACC,gBAAAP,EAACG,EAAM,IAAN,EAAiC,UAAAG,EAAA,GAAnB,GAAGC,CAAC,IAAId,CAAM,EAAQ,IAErC,gBAAAO,EAACG,EAAM,IAAN,EAAiC,eAAnB,GAAGI,CAAC,IAAId,CAAM,EAAQ;AAAA,IAAA,KALzB,GAAGY,CAAG,IAAIZ,CAAM,EAQ/B,CACA,EAAA,CACF;AAAA,EAAA,EAAA,GAxBW,SAAS,EAAEA,CAAM,EAyB7B,IAEAI,GAEF;AAEF,CAAC;"}
@@ -0,0 +1,135 @@
1
+ import { DSFieldElement as u } from "@digdir/designsystemet-web";
2
+ import d from "./styles.module.css.js";
3
+ import { getByCSSModule as n, isBrowser as i, onHotReload as p, on as g, onMutation as b, QUICK_EVENT as y, debounce as S, attr as s } 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
+ `\x1B[1m@mattilsynet/design:\x1B[m ${t} is deprecated, please use ${e}:`,
6
+ r
7
+ ), E = n("togglegroup"), D = () => {
8
+ for (const t of E)
9
+ a(t) && !t.hasAttribute("data-toggle-group") && (s(t, "data-toggle-group", "Valgknapper"), o(
10
+ 'Only setting class="styles.togglegroup"',
11
+ 'data-toggle-group="LABEL-HERE" attribute also for better accessibility',
12
+ t
13
+ ));
14
+ }, A = n("breadcrumbs"), R = () => {
15
+ for (const t of A)
16
+ a(t) && t.nodeName !== "DS-BREADCRUMBS" && (t.classList.add(...d.breadcrumbs.split(" ")), o(
17
+ 'Only setting class="styles.breadcrumbs"',
18
+ '<ds-breadcrumbs class="styles.breadcrumbs">',
19
+ t
20
+ ));
21
+ }, w = n("errorsummary"), C = () => {
22
+ for (const t of w)
23
+ a(t) && t.nodeName !== "DS-ERROR-SUMMARY" && o(
24
+ 'Only setting class="styles.errorsummary"',
25
+ '<ds-error-summary class="styles.errorsummary">',
26
+ t
27
+ );
28
+ }, L = n("dialog"), O = () => {
29
+ for (const t of L)
30
+ if (a(t) && (t.hasAttribute("data-variant") && o(
31
+ '<dialog data-variant="drawer">',
32
+ '<dialog data-placement="center|left|right|top|bottom">',
33
+ t
34
+ ), t.isConnected && t.showModal && t.close)) {
35
+ const e = s(t, "data-closedby");
36
+ e && (s(t, "closedby", e), o(
37
+ `<dialog data-closedby="${e}">`,
38
+ `<dialog closedby="${e}">`,
39
+ t
40
+ )), t.matches('[open]:not([data-modal="false"]):not(:modal)') ? (o(
41
+ '<dialog data-modal="true">',
42
+ '.showModal() or <button command="show-modal" commandfor="DIALOG-ID"></button>',
43
+ t
44
+ ), s(t, "open", null), t.showModal()) : t.matches(":modal:not([open])") && (s(t, "open", ""), t.close());
45
+ }
46
+ }, h = () => {
47
+ for (const t of document.querySelectorAll("[data-count]"))
48
+ if (a(t)) {
49
+ const e = s(t, "data-count");
50
+ t.classList.add(...d.validation.split(" ")), s(t, "data-limit", e), o(
51
+ `data-count="${e}"`,
52
+ `class="styles.validation" data-field="counter" data-limit="${e}"`,
53
+ t
54
+ );
55
+ }
56
+ }, I = () => {
57
+ for (const t of document.querySelectorAll("[data-command]"))
58
+ if (a(t)) {
59
+ const e = s(t, "data-command");
60
+ e === "row" ? o(
61
+ `<${t.nodeName.toLowerCase()} data-command="${e}">`,
62
+ `<tr data-clickdelegatefor="${t.nodeName}-ID">`,
63
+ t
64
+ ) : o(
65
+ `<button data-command="${e}">`,
66
+ `<button command="${e?.replace("toggle-app-expanded", "show-modal")}" commandfor="TARGET-ID">`,
67
+ t
68
+ );
69
+ }
70
+ }, N = i() ? document.getElementsByTagName("u-tabs") : [], B = () => {
71
+ for (const t of N) a(t) && o("u-tabs", "ds-tabs", t);
72
+ }, l = d.suggestion.split(" "), T = i() ? document.getElementsByTagName("u-combobox") : [], v = i() ? document.getElementsByTagName("ds-suggestion") : [], $ = () => {
73
+ for (const t of T)
74
+ a(t) && (t.classList.add(...l), o("<u-combobox>", '<ds-suggestion class="styles.suggestion">', t));
75
+ for (const t of v)
76
+ a(t) && !t.classList.contains(l[0]) && (t.classList.add(...l), o(
77
+ "Only using <ds-suggestion>",
78
+ '<ds-suggestion class="styles.suggestion">',
79
+ t
80
+ ));
81
+ }, M = ({ target: t }) => {
82
+ if (!(t instanceof Element)) return;
83
+ const e = t?.closest("tr")?.querySelector('[data-command="row"]');
84
+ e && !t?.closest('a,button,label,input,select,textarea,[role="button"]') && e.click();
85
+ const m = t?.closest("dialog");
86
+ m && t?.closest('[data-command="close"]') && m.close();
87
+ }, k = n("field"), c = /* @__PURE__ */ new Set(), U = () => {
88
+ for (const t of k)
89
+ t.nodeName !== "DS-FIELD" && (a(t) || o(
90
+ 'Only setting class="styles.field"',
91
+ '<ds-field class="styles.field">',
92
+ t
93
+ ), !c.has(t) && c.add(t) && u.prototype.connectedCallback.call(t));
94
+ }, F = () => {
95
+ for (const t of c)
96
+ u.prototype.disconnectedCallback.call(t), c.delete(t);
97
+ }, G = `[data-description], .${d.field.split(" ")[0]} label + p`, x = () => {
98
+ for (const t of document.querySelectorAll(G))
99
+ a(t) && t.getAttribute("data-field") !== "description" && (s(t, "data-field", "description"), o(
100
+ "Descriptions created by data-description of <p> only",
101
+ 'data-field="data-description"',
102
+ t
103
+ ));
104
+ }, q = n("validation"), P = () => {
105
+ for (const t of q)
106
+ a(t) && !t.hasAttribute("data-field") && (s(t, "data-field", "validation"), o(
107
+ 'Only setting class="styles.validation"',
108
+ 'class="styles.validation" data-field="validation"',
109
+ t
110
+ ));
111
+ }, V = () => {
112
+ for (const t of document.querySelectorAll("[popover][data-position]"))
113
+ a(t) && (s(t, "data-placement", s(t, "data-position")), o("data-position", "data-placement", t));
114
+ }, _ = S(() => {
115
+ h(), I(), R(), O(), C(), x(), P(), V(), U(), D(), $(), B();
116
+ }, 200);
117
+ p("deprecations", () => [
118
+ F,
119
+ // Return as cleanup function
120
+ g(document, "click", M, y),
121
+ b(document, _, {
122
+ attributeFilter: [
123
+ "class",
124
+ "data-command",
125
+ "data-count",
126
+ "data-description",
127
+ "data-variant",
128
+ "open"
129
+ ],
130
+ attributes: !0,
131
+ childList: !0,
132
+ subtree: !0
133
+ })
134
+ ]);
135
+ //# sourceMappingURL=deprecations.js.map
@@ -0,0 +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 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};\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)) continue;\n\t\tif (el.hasAttribute(\"data-variant\")) {\n\t\t\twarn(\n\t\t\t\t'<dialog data-variant=\"drawer\">',\n\t\t\t\t'<dialog data-placement=\"center|left|right|top|bottom\">',\n\t\t\t\tel,\n\t\t\t);\n\t\t}\n\t\tif (el.isConnected && el.showModal && el.close) {\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.matches('[open]:not([data-modal=\"false\"]):not(:modal)')) {\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\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\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","deprecateToggleGroup","attr","BREADCRUMBS","deprecateBreadcrumbs","styles","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,IAAuB,MAAM;AAClC,aAAWN,KAAMI;AAChB,IAAIL,EAAUC,CAAE,KAAK,CAACA,EAAG,aAAa,mBAAmB,MACxDO,EAAKP,GAAI,qBAAqB,aAAa,GAC3CC;AAAA,MACC;AAAA,MACA;AAAA,MACAD;AAAA,IAAA;AAGJ,GAGMQ,IAAcH,EAAe,aAAa,GAC1CI,IAAuB,MAAM;AAClC,aAAWT,KAAMQ;AAChB,IAAIT,EAAUC,CAAE,KAAKA,EAAG,aAAa,qBACpCA,EAAG,UAAU,IAAI,GAAGU,EAAO,YAAY,MAAM,GAAG,CAAC,GACjDT;AAAA,MACC;AAAA,MACA;AAAA,MACAD;AAAA,IAAA;AAGJ,GAGMW,IAAgBN,EAAe,cAAc,GAC7CO,IAAwB,MAAM;AACnC,aAAWZ,KAAMW;AAChB,IAAIZ,EAAUC,CAAE,KAAKA,EAAG,aAAa,sBACpCC;AAAA,MACC;AAAA,MACA;AAAA,MACAD;AAAA,IAAA;AAGJ,GAGMa,IAAUR,EAAe,QAAQ,GACjCS,IAAkB,MAAM;AAC7B,aAAWd,KAAMa;AAChB,QAAKd,EAAUC,CAAE,MACbA,EAAG,aAAa,cAAc,KACjCC;AAAA,MACC;AAAA,MACA;AAAA,MACAD;AAAA,IAAA,GAGEA,EAAG,eAAeA,EAAG,aAAaA,EAAG,QAAO;AAC/C,YAAMe,IAAWR,EAAKP,GAAI,eAAe;AACzC,MAAIe,M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A;AAAA,IAED,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,SAAS;AAAA,EAAA,CACT;AACF,CAAC;"}
@@ -1,17 +1,24 @@
1
- import { jsx as m } from "react/jsx-runtime";
2
- import { forwardRef as o } from "react";
1
+ import { jsx as s } from "react/jsx-runtime";
2
+ import e from "clsx";
3
+ import { forwardRef as m } from "react";
3
4
  import i from "../styles.module.css.js";
4
- import { toCustomElementProps as s } from "../utils.js";
5
- const a = o(
6
- function(t, r) {
7
- return /* @__PURE__ */ m("u-details", { ref: r, ...s(t, i.details) });
5
+ const n = m(
6
+ function({ className: r, ...t }, o) {
7
+ return /* @__PURE__ */ s(
8
+ "details",
9
+ {
10
+ ref: o,
11
+ className: e(i.details, r),
12
+ ...t
13
+ }
14
+ );
8
15
  }
9
- ), n = o(
10
- function(t, r) {
11
- return /* @__PURE__ */ m("u-summary", { ref: r, ...s(t) });
16
+ ), l = m(
17
+ function(r, t) {
18
+ return /* @__PURE__ */ s("summary", { ref: t, suppressHydrationWarning: !0, ...r });
12
19
  }
13
- ), c = Object.assign(a, { Summary: n });
20
+ ), y = Object.assign(n, { Summary: l });
14
21
  export {
15
- c as Details
22
+ y as Details
16
23
  };
17
24
  //# sourceMappingURL=details.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"details.js","sources":["../../designsystem/details/details.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport styles from \"../styles.module.css\";\nimport { toCustomElementProps } from \"../utils\";\n\nexport type DetailsProps = React.ComponentPropsWithoutRef<\"details\"> & {\n\t\"data-align\"?: \"start\" | \"center\";\n\t\"data-variant\"?: \"default\" | \"card\";\n};\nconst DetailsComp = forwardRef<HTMLDetailsElement, DetailsProps>(\n\tfunction Details(props, ref) {\n\t\treturn (\n\t\t\t<u-details ref={ref} {...toCustomElementProps(props, styles.details)} />\n\t\t);\n\t},\n);\n\nexport type SummaryProps = React.ComponentPropsWithoutRef<\"summary\">;\nconst DetailsSummary = forwardRef<HTMLElement, SummaryProps>(\n\tfunction DetailsSummary(props, ref) {\n\t\treturn <u-summary ref={ref} {...toCustomElementProps(props)} />;\n\t},\n);\n\nexport const Details = Object.assign(DetailsComp, { Summary: DetailsSummary });\n"],"names":["DetailsComp","forwardRef","props","ref","jsx","toCustomElementProps","styles","DetailsSummary","Details"],"mappings":";;;;AAQA,MAAMA,IAAcC;AAAA,EACnB,SAAiBC,GAAOC,GAAK;AAC5B,WACC,gBAAAC,EAAC,eAAU,KAAAD,GAAW,GAAGE,EAAqBH,GAAOI,EAAO,OAAO,GAAG;AAAA,EAExE;AACD,GAGMC,IAAiBN;AAAA,EACtB,SAAwBC,GAAOC,GAAK;AACnC,6BAAQ,aAAA,EAAU,KAAAA,GAAW,GAAGE,EAAqBH,CAAK,GAAG;AAAA,EAC9D;AACD,GAEaM,IAAU,OAAO,OAAOR,GAAa,EAAE,SAASO,GAAgB;"}
1
+ {"version":3,"file":"details.js","sources":["../../designsystem/details/details.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { forwardRef } from \"react\";\nimport styles from \"../styles.module.css\";\n\nexport type DetailsProps = React.ComponentPropsWithoutRef<\"details\"> & {\n\t\"data-align\"?: \"start\" | \"center\";\n\t\"data-variant\"?: \"default\" | \"card\";\n};\nconst DetailsComp = forwardRef<HTMLDetailsElement, DetailsProps>(\n\tfunction Details({ className, ...rest }, ref) {\n\t\treturn (\n\t\t\t<details\n\t\t\t\tref={ref}\n\t\t\t\tclassName={clsx(styles.details, className)}\n\t\t\t\t{...rest}\n\t\t\t/>\n\t\t);\n\t},\n);\n\nexport type SummaryProps = React.ComponentPropsWithoutRef<\"summary\">;\nconst DetailsSummary = forwardRef<HTMLElement, SummaryProps>(\n\tfunction DetailsSummary(rest, ref) {\n\t\treturn <summary ref={ref} suppressHydrationWarning {...rest} />;\n\t},\n);\n\nexport const Details = Object.assign(DetailsComp, { Summary: DetailsSummary });\n"],"names":["DetailsComp","forwardRef","className","rest","ref","jsx","clsx","styles","DetailsSummary","Details"],"mappings":";;;;AAQA,MAAMA,IAAcC;AAAA,EACnB,SAAiB,EAAE,WAAAC,GAAW,GAAGC,EAAA,GAAQC,GAAK;AAC7C,WACC,gBAAAC;AAAA,MAAC;AAAA,MAAA;AAAA,QACA,KAAAD;AAAA,QACA,WAAWE,EAAKC,EAAO,SAASL,CAAS;AAAA,QACxC,GAAGC;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AACD,GAGMK,IAAiBP;AAAA,EACtB,SAAwBE,GAAMC,GAAK;AAClC,6BAAQ,WAAA,EAAQ,KAAAA,GAAU,0BAAwB,IAAE,GAAGD,GAAM;AAAA,EAC9D;AACD,GAEaM,IAAU,OAAO,OAAOT,GAAa,EAAE,SAASQ,GAAgB;"}
@@ -1,2 +1,4 @@
1
- export type ErrorsummaryProps = React.ComponentPropsWithoutRef<"div">;
2
- export declare const Errorsummary: import('react').ForwardRefExoticComponent<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
1
+ import { DSErrorSummaryElement } from '@digdir/designsystemet-web';
2
+ import { CustomReactElementProps } from '../react-types';
3
+ export type ErrorsummaryProps = CustomReactElementProps<DSErrorSummaryElement>;
4
+ export declare const Errorsummary: import('react').ForwardRefExoticComponent<Omit<ErrorsummaryProps, "ref"> & import('react').RefAttributes<DSErrorSummaryElement>>;
@@ -1,21 +1,17 @@
1
- import { jsx as s } from "react/jsx-runtime";
2
- import t from "clsx";
3
- import { forwardRef as e } from "react";
4
- import a from "../styles.module.css.js";
5
- const c = e(
6
- function({ className: r, ...o }, m) {
7
- return /* @__PURE__ */ s(
8
- "div",
9
- {
10
- className: t(a.errorsummary, r),
11
- role: "alert",
12
- ref: m,
13
- ...o
14
- }
15
- );
16
- }
17
- );
1
+ import { jsx as m } from "react/jsx-runtime";
2
+ import { forwardRef as t } from "react";
3
+ import s from "../styles.module.css.js";
4
+ import { toCustomElementProps as e } from "../utils.js";
5
+ const n = t(function(r, o) {
6
+ return /* @__PURE__ */ m(
7
+ "ds-error-summary",
8
+ {
9
+ ref: o,
10
+ ...e(r, s.errorsummary)
11
+ }
12
+ );
13
+ });
18
14
  export {
19
- c as Errorsummary
15
+ n as Errorsummary
20
16
  };
21
17
  //# sourceMappingURL=errorsummary.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errorsummary.js","sources":["../../designsystem/errorsummary/errorsummary.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { forwardRef } from \"react\";\nimport styles from \"../styles.module.css\";\n\nexport type ErrorsummaryProps = React.ComponentPropsWithoutRef<\"div\">;\n\nexport const Errorsummary = forwardRef<HTMLDivElement, ErrorsummaryProps>(\n\tfunction Errorsummary({ className, ...rest }, ref) {\n\t\treturn (\n\t\t\t<div\n\t\t\t\tclassName={clsx(styles.errorsummary, className)}\n\t\t\t\trole=\"alert\"\n\t\t\t\tref={ref}\n\t\t\t\t{...rest}\n\t\t\t/>\n\t\t);\n\t},\n);\n"],"names":["Errorsummary","forwardRef","className","rest","ref","jsx","clsx","styles"],"mappings":";;;;AAMO,MAAMA,IAAeC;AAAA,EAC3B,SAAsB,EAAE,WAAAC,GAAW,GAAGC,EAAA,GAAQC,GAAK;AAClD,WACC,gBAAAC;AAAA,MAAC;AAAA,MAAA;AAAA,QACA,WAAWC,EAAKC,EAAO,cAAcL,CAAS;AAAA,QAC9C,MAAK;AAAA,QACL,KAAAE;AAAA,QACC,GAAGD;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AACD;"}
1
+ {"version":3,"file":"errorsummary.js","sources":["../../designsystem/errorsummary/errorsummary.tsx"],"sourcesContent":["import type { DSErrorSummaryElement } from \"@digdir/designsystemet-web\";\nimport { forwardRef } from \"react\";\nimport type { CustomReactElementProps } from \"../react-types\";\nimport styles from \"../styles.module.css\";\nimport { toCustomElementProps } from \"../utils\";\n\nexport type ErrorsummaryProps = CustomReactElementProps<DSErrorSummaryElement>;\n\nexport const Errorsummary = forwardRef<\n\tDSErrorSummaryElement,\n\tErrorsummaryProps\n>(function Errorsummary(rest, ref) {\n\treturn (\n\t\t<ds-error-summary\n\t\t\tref={ref}\n\t\t\t{...toCustomElementProps(rest, styles.errorsummary)}\n\t\t/>\n\t);\n});\n"],"names":["Errorsummary","forwardRef","rest","ref","jsx","toCustomElementProps","styles"],"mappings":";;;;AAQO,MAAMA,IAAeC,EAG1B,SAAsBC,GAAMC,GAAK;AAClC,SACC,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACA,KAAAD;AAAA,MACC,GAAGE,EAAqBH,GAAMI,EAAO,YAAY;AAAA,IAAA;AAAA,EAAA;AAGrD,CAAC;"}