@mattilsynet/design 3.3.9 → 3.4.1

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 (192) hide show
  1. package/mtds/_virtual/_rolldown/runtime.js +17 -0
  2. package/mtds/ai/card.stories.tsx +54 -77
  3. package/mtds/ai/layout.mdx +37 -1
  4. package/mtds/ai/layout.stories.tsx +126 -1
  5. package/mtds/ai/print.mdx +1 -1
  6. package/mtds/ai/print.stories.tsx +1 -2
  7. package/mtds/alert/alert.js +16 -11
  8. package/mtds/alert/alert.js.map +1 -1
  9. package/mtds/analytics/analytics.js +118 -118
  10. package/mtds/analytics/analytics.js.map +1 -1
  11. package/mtds/app/app-observer.js +31 -36
  12. package/mtds/app/app-observer.js.map +1 -1
  13. package/mtds/app/app-toggle.js +12 -26
  14. package/mtds/app/app-toggle.js.map +1 -1
  15. package/mtds/app/app-toggle2.js +6 -11
  16. package/mtds/app/app-toggle2.js.map +1 -1
  17. package/mtds/app/app.js +66 -60
  18. package/mtds/app/app.js.map +1 -1
  19. package/mtds/atlas/atlas-element.js +83 -93
  20. package/mtds/atlas/atlas-element.js.map +1 -1
  21. package/mtds/atlas/atlas-marker.js +63 -52
  22. package/mtds/atlas/atlas-marker.js.map +1 -1
  23. package/mtds/atlas/atlas-matgeo.js +67 -61
  24. package/mtds/atlas/atlas-matgeo.js.map +1 -1
  25. package/mtds/atlas/atlas-wms.js +33 -28
  26. package/mtds/atlas/atlas-wms.js.map +1 -1
  27. package/mtds/atlas/atlas.js +6 -38
  28. package/mtds/atlas/atlas.js.map +1 -1
  29. package/mtds/atlas/atlas2.js +39 -0
  30. package/mtds/atlas/atlas2.js.map +1 -0
  31. package/mtds/atlas/cluster.js +759 -1149
  32. package/mtds/atlas/cluster.js.map +1 -1
  33. package/mtds/atlas.iife.js +3 -4
  34. package/mtds/atlas.js +6 -14
  35. package/mtds/avatar/avatar.js +14 -10
  36. package/mtds/avatar/avatar.js.map +1 -1
  37. package/mtds/badge/badge.js +15 -10
  38. package/mtds/badge/badge.js.map +1 -1
  39. package/mtds/breadcrumbs/breadcrumbs.js +15 -19
  40. package/mtds/breadcrumbs/breadcrumbs.js.map +1 -1
  41. package/mtds/button/button.js +18 -20
  42. package/mtds/button/button.js.map +1 -1
  43. package/mtds/card/card.js +22 -15
  44. package/mtds/card/card.js.map +1 -1
  45. package/mtds/chart/chart-axis.js +33 -21
  46. package/mtds/chart/chart-axis.js.map +1 -1
  47. package/mtds/chart/chart-bars.js +23 -21
  48. package/mtds/chart/chart-bars.js.map +1 -1
  49. package/mtds/chart/chart-element.js +94 -88
  50. package/mtds/chart/chart-element.js.map +1 -1
  51. package/mtds/chart/chart-lines.js +35 -37
  52. package/mtds/chart/chart-lines.js.map +1 -1
  53. package/mtds/chart/chart-pies.js +17 -17
  54. package/mtds/chart/chart-pies.js.map +1 -1
  55. package/mtds/chart/chart.js +6 -52
  56. package/mtds/chart/chart.js.map +1 -1
  57. package/mtds/chart/chart2.js +21 -0
  58. package/mtds/chart/chart2.js.map +1 -0
  59. package/mtds/chip/chip.js +15 -11
  60. package/mtds/chip/chip.js.map +1 -1
  61. package/mtds/deprecations.js +76 -158
  62. package/mtds/deprecations.js.map +1 -1
  63. package/mtds/details/details.js +21 -24
  64. package/mtds/details/details.js.map +1 -1
  65. package/mtds/dialog/dialog.js +17 -21
  66. package/mtds/dialog/dialog.js.map +1 -1
  67. package/mtds/divider/divider.js +15 -20
  68. package/mtds/divider/divider.js.map +1 -1
  69. package/mtds/errorsummary/errorsummary.js +14 -16
  70. package/mtds/errorsummary/errorsummary.js.map +1 -1
  71. package/mtds/external/@turf/boolean-point-in-polygon/dist/esm/index.js +22 -25
  72. package/mtds/external/@turf/boolean-point-in-polygon/dist/esm/index.js.map +1 -1
  73. package/mtds/external/@turf/helpers/dist/esm/index.js +21 -24
  74. package/mtds/external/@turf/helpers/dist/esm/index.js.map +1 -1
  75. package/mtds/external/@turf/invariant/dist/esm/index.js +15 -19
  76. package/mtds/external/@turf/invariant/dist/esm/index.js.map +1 -1
  77. package/mtds/external/@u-elements/u-combobox/dist/u-combobox.js +270 -297
  78. package/mtds/external/@u-elements/u-combobox/dist/u-combobox.js.map +1 -1
  79. package/mtds/external/@u-elements/u-details/dist/u-details.js +75 -101
  80. package/mtds/external/@u-elements/u-details/dist/u-details.js.map +1 -1
  81. package/mtds/external/leaflet/dist/leaflet-src.js +4257 -6151
  82. package/mtds/external/leaflet/dist/leaflet-src.js.map +1 -1
  83. package/mtds/external/leaflet/dist/leaflet.css.js +5 -606
  84. package/mtds/external/leaflet/dist/leaflet.css.js.map +1 -1
  85. package/mtds/external/point-in-polygon-hao/dist/esm/index.js +24 -25
  86. package/mtds/external/point-in-polygon-hao/dist/esm/index.js.map +1 -1
  87. package/mtds/external/robust-predicates/esm/incircle.js +5 -0
  88. package/mtds/external/robust-predicates/esm/incircle.js.map +1 -0
  89. package/mtds/external/robust-predicates/esm/insphere.js +5 -0
  90. package/mtds/external/robust-predicates/esm/insphere.js.map +1 -0
  91. package/mtds/external/robust-predicates/esm/orient2d.js +20 -22
  92. package/mtds/external/robust-predicates/esm/orient2d.js.map +1 -1
  93. package/mtds/external/robust-predicates/esm/orient3d.js +5 -0
  94. package/mtds/external/robust-predicates/esm/orient3d.js.map +1 -0
  95. package/mtds/external/robust-predicates/esm/util.js +20 -28
  96. package/mtds/external/robust-predicates/esm/util.js.map +1 -1
  97. package/mtds/external/robust-predicates/index.js +5 -0
  98. package/mtds/field/field.js +167 -214
  99. package/mtds/field/field.js.map +1 -1
  100. package/mtds/fieldset/fieldset.js +32 -30
  101. package/mtds/fieldset/fieldset.js.map +1 -1
  102. package/mtds/fileupload/fileupload.js +16 -13
  103. package/mtds/fileupload/fileupload.js.map +1 -1
  104. package/mtds/helptext/helptext.js +25 -27
  105. package/mtds/helptext/helptext.js.map +1 -1
  106. package/mtds/identitet/illustrasjons-generator/illustrasjons-generator.d.ts +1 -0
  107. package/mtds/identitet/illustrasjons-generator/index-old-1.d.ts +1 -0
  108. package/mtds/identitet/infografikk-generator/infografikk-generator.d.ts +1 -0
  109. package/mtds/illustrations/index.json +1 -1
  110. package/mtds/index.iife.js +21 -21
  111. package/mtds/index.js +38 -31
  112. package/mtds/index.js.map +1 -1
  113. package/mtds/input/input.js +33 -47
  114. package/mtds/input/input.js.map +1 -1
  115. package/mtds/law/law-helper.js +106 -95
  116. package/mtds/law/law-helper.js.map +1 -1
  117. package/mtds/law/law.js +15 -10
  118. package/mtds/law/law.js.map +1 -1
  119. package/mtds/layout/layout.js +21 -13
  120. package/mtds/layout/layout.js.map +1 -1
  121. package/mtds/layout/layout.stories.d.ts +1 -0
  122. package/mtds/link/link.js +15 -10
  123. package/mtds/link/link.js.map +1 -1
  124. package/mtds/logo/logo-observer.js +18 -18
  125. package/mtds/logo/logo-observer.js.map +1 -1
  126. package/mtds/logo/logo.js +18 -18
  127. package/mtds/logo/logo.js.map +1 -1
  128. package/mtds/package.js +6 -0
  129. package/mtds/package.js.map +1 -0
  130. package/mtds/package.json.d.ts +112 -0
  131. package/mtds/pagination/pagination.js +46 -60
  132. package/mtds/pagination/pagination.js.map +1 -1
  133. package/mtds/popover/popover-observer.js +15 -15
  134. package/mtds/popover/popover-observer.js.map +1 -1
  135. package/mtds/popover/popover.js +18 -20
  136. package/mtds/popover/popover.js.map +1 -1
  137. package/mtds/print/print.js +15 -10
  138. package/mtds/print/print.js.map +1 -1
  139. package/mtds/print/print.stories.d.ts +0 -1
  140. package/mtds/profilering/epost.d.ts +1 -0
  141. package/mtds/progress/progress.js +15 -13
  142. package/mtds/progress/progress.js.map +1 -1
  143. package/mtds/react-atlas.js +7 -16
  144. package/mtds/react.js +36 -84
  145. package/mtds/skeleton/skeleton.js +15 -11
  146. package/mtds/skeleton/skeleton.js.map +1 -1
  147. package/mtds/spinner/spinner.js +16 -13
  148. package/mtds/spinner/spinner.js.map +1 -1
  149. package/mtds/steps/steps.js +15 -10
  150. package/mtds/steps/steps.js.map +1 -1
  151. package/mtds/styles.css +2 -1
  152. package/mtds/styles.module.js +122 -0
  153. package/mtds/styles.module.js.map +1 -0
  154. package/mtds/table/table-observer.js +23 -28
  155. package/mtds/table/table-observer.js.map +1 -1
  156. package/mtds/table/table.js +88 -60
  157. package/mtds/table/table.js.map +1 -1
  158. package/mtds/tabs/tabs.js +32 -27
  159. package/mtds/tabs/tabs.js.map +1 -1
  160. package/mtds/tag/tag.js +16 -19
  161. package/mtds/tag/tag.js.map +1 -1
  162. package/mtds/tailwind.css +0 -4
  163. package/mtds/toast/toast-helper.js +45 -25
  164. package/mtds/toast/toast-helper.js.map +1 -1
  165. package/mtds/toast/toast-observer.js +18 -18
  166. package/mtds/toast/toast-observer.js.map +1 -1
  167. package/mtds/toast/toast.js +67 -54
  168. package/mtds/toast/toast.js.map +1 -1
  169. package/mtds/togglegroup/togglegroup.js +31 -40
  170. package/mtds/togglegroup/togglegroup.js.map +1 -1
  171. package/mtds/tooltip/tooltip-element.js +12 -25
  172. package/mtds/tooltip/tooltip-element.js.map +1 -1
  173. package/mtds/typography/typography.js +38 -21
  174. package/mtds/typography/typography.js.map +1 -1
  175. package/mtds/utils.js +53 -70
  176. package/mtds/utils.js.map +1 -1
  177. package/mtds/validation/validation-observer.js +40 -47
  178. package/mtds/validation/validation-observer.js.map +1 -1
  179. package/mtds/validation/validation.js +17 -21
  180. package/mtds/validation/validation.js.map +1 -1
  181. package/package.json +9 -9
  182. package/mtds/atlas/atlas.css.js +0 -138
  183. package/mtds/atlas/atlas.css.js.map +0 -1
  184. package/mtds/atlas.js.map +0 -1
  185. package/mtds/chart/chart.css.js +0 -187
  186. package/mtds/chart/chart.css.js.map +0 -1
  187. package/mtds/package.json.js +0 -5
  188. package/mtds/package.json.js.map +0 -1
  189. package/mtds/react-atlas.js.map +0 -1
  190. package/mtds/react.js.map +0 -1
  191. package/mtds/styles.module.css.js +0 -118
  192. package/mtds/styles.module.css.js.map +0 -1
package/mtds/utils.js CHANGED
@@ -1,72 +1,55 @@
1
- import u from "clsx";
2
- import a from "./styles.module.css.js";
3
- const E = { capture: !0, passive: !0 }, r = () => typeof window < "u" && typeof document < "u", C = (e) => r() ? document.getElementsByClassName(a[e].split(" ")[0]) : [];
4
- function h(e, t) {
5
- let o;
6
- return function(...n) {
7
- clearTimeout(o), o = setTimeout(() => e.apply(this, n), t);
8
- };
1
+ import e from "./styles.module.js";
2
+ import t from "clsx";
3
+ //#region designsystem/utils.ts
4
+ var n = {
5
+ capture: !0,
6
+ passive: !0
7
+ }, r = () => typeof window < "u" && typeof document < "u", i = (t) => r() ? document.getElementsByClassName(e[t].split(" ")[0]) : [];
8
+ function a(e, t) {
9
+ let n;
10
+ return function(...r) {
11
+ clearTimeout(n), n = setTimeout(() => e.apply(this, r), t);
12
+ };
9
13
  }
10
- const l = (e, t, o) => o === void 0 ? e.getAttribute(t) ?? null : (o === null ? e.removeAttribute(t) : e.getAttribute(t) !== o && e.setAttribute(t, o), null), p = (e, ...t) => {
11
- const [o, ...n] = t;
12
- for (const s of o.split(" ")) e.addEventListener(s, ...n);
13
- return () => f(e, ...t);
14
- }, f = (e, ...t) => {
15
- const [o, ...n] = t;
16
- for (const s of o.split(" ")) e.removeEventListener(s, ...n);
17
- }, T = (e, t) => {
18
- if (!r()) return;
19
- window._mtdsHotReloadCleanup || (window._mtdsHotReloadCleanup = /* @__PURE__ */ new Map());
20
- const o = () => {
21
- window._mtdsHotReloadCleanup?.get(e)?.map((n) => n()), window._mtdsHotReloadCleanup?.set(e, t());
22
- };
23
- document.readyState !== "complete" ? p(window, "load", o) : document.fonts?.ready?.then(o) || setTimeout(o, 0);
24
- }, b = (e, t, o) => {
25
- let n = 0;
26
- const s = () => {
27
- if (!e.isConnected) return i();
28
- t(d), d.takeRecords(), n = 0;
29
- }, i = () => d?.disconnect?.(), d = new MutationObserver(() => {
30
- n || (n = requestAnimationFrame(s));
31
- });
32
- return d.observe(e, o), s(), i;
33
- }, c = "aria-selected", v = (e, t) => Object.assign({}, e, {
34
- suppressHydrationWarning: !0,
35
- // Make Next.js happy
36
- [c]: e[c] === void 0 ? void 0 : `${(e[c] || "false") !== "false"}`,
37
- // Ensure aria-selected boolean is string
38
- class: u(t, e.className) || void 0,
39
- // Use class instead of className
40
- hidden: !!e.hidden,
41
- // Ensure boolean prop behaviour
42
- open: !!e.open
43
- // Ensure boolean prop behaviour
44
- }), m = (e, t, o) => {
45
- const n = document.createElement(e);
46
- if (o && (n.textContent = o), t) for (const [s, i] of Object.entries(t)) l(n, s, i);
47
- return n;
48
- }, R = typeof HTMLElement > "u" ? class {
49
- } : HTMLElement, g = (e, t) => !r() || window.customElements.get(e) || window.customElements.define(e, t), w = typeof window < "u" && window.CSSStyleSheet && document.adoptedStyleSheets, H = (e, t) => {
50
- if (!w) return;
51
- e.shadowRoot || e.attachShadow({ mode: "open" }).append(m("slot"));
52
- const o = new CSSStyleSheet();
53
- o.replaceSync(t), e.shadowRoot.adoptedStyleSheets = [o];
14
+ var o = (e, t, n) => n === void 0 ? e.getAttribute(t) ?? null : (n === null ? e.removeAttribute(t) : e.getAttribute(t) !== n && e.setAttribute(t, n), null), s = (e, ...t) => {
15
+ let [n, ...r] = t;
16
+ for (let t of n.split(" ")) e.addEventListener(t, ...r);
17
+ return () => c(e, ...t);
18
+ }, c = (e, ...t) => {
19
+ let [n, ...r] = t;
20
+ for (let t of n.split(" ")) e.removeEventListener(t, ...r);
21
+ }, l = (e, t) => {
22
+ if (!r()) return;
23
+ window._mtdsHotReloadCleanup || (window._mtdsHotReloadCleanup = /* @__PURE__ */ new Map());
24
+ let n = () => {
25
+ window._mtdsHotReloadCleanup?.get(e)?.map((e) => e()), window._mtdsHotReloadCleanup?.set(e, t());
26
+ };
27
+ document.readyState === "complete" ? document.fonts?.ready?.then(n) || setTimeout(n, 0) : s(window, "load", n);
28
+ }, u = (e, t, n) => {
29
+ let r = 0, i = () => {
30
+ if (!e.isConnected) return a();
31
+ t(o), o.takeRecords(), r = 0;
32
+ }, a = () => o?.disconnect?.(), o = new MutationObserver(() => {
33
+ r ||= requestAnimationFrame(i);
34
+ });
35
+ return o.observe(e, n), i(), a;
36
+ }, d = "aria-selected", f = (e, n) => Object.assign({}, e, {
37
+ suppressHydrationWarning: !0,
38
+ [d]: e[d] === void 0 ? void 0 : `${(e[d] || "false") !== "false"}`,
39
+ class: t(n, e.className) || void 0,
40
+ hidden: !!e.hidden,
41
+ open: !!e.open
42
+ }), p = (e, t, n) => {
43
+ let r = document.createElement(e);
44
+ if (n && (r.textContent = n), t) for (let [e, n] of Object.entries(t)) o(r, e, n);
45
+ return r;
46
+ }, m = typeof HTMLElement > "u" ? class {} : HTMLElement, h = (e, t) => !r() || window.customElements.get(e) || window.customElements.define(e, t), g = typeof window < "u" && window.CSSStyleSheet && document.adoptedStyleSheets, _ = (e, t) => {
47
+ if (!g) return;
48
+ e.shadowRoot || e.attachShadow({ mode: "open" }).append(p("slot"));
49
+ let n = new CSSStyleSheet();
50
+ n.replaceSync(t), e.shadowRoot.adoptedStyleSheets = [n];
54
51
  };
55
- export {
56
- R as MTDSElement,
57
- E as QUICK_EVENT,
58
- w as SUPPORTS_CONSTRUCTED_CSS,
59
- H as attachStyle,
60
- l as attr,
61
- h as debounce,
62
- g as defineElement,
63
- C as getByCSSModule,
64
- r as isBrowser,
65
- f as off,
66
- p as on,
67
- T as onHotReload,
68
- b as onMutation,
69
- m as tag,
70
- v as toCustomElementProps
71
- };
72
- //# sourceMappingURL=utils.js.map
52
+ //#endregion
53
+ export { m as MTDSElement, n as QUICK_EVENT, g as SUPPORTS_CONSTRUCTED_CSS, _ as attachStyle, o as attr, a as debounce, h as defineElement, i as getByCSSModule, r as isBrowser, c as off, s as on, l as onHotReload, u as onMutation, p as tag, f as toCustomElementProps };
54
+
55
+ //# sourceMappingURL=utils.js.map
package/mtds/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../designsystem/utils.ts"],"sourcesContent":["import clsx from \"clsx\";\nimport styles from \"./styles.module.css\";\n\nexport const QUICK_EVENT = { capture: true, passive: true };\nexport const isBrowser = () =>\n\ttypeof window !== \"undefined\" && typeof document !== \"undefined\"; // Using function to play nice with Vitest where DOM can come and go\n\nexport const getByCSSModule = (key: string) =>\n\tisBrowser() ? document.getElementsByClassName(styles[key].split(\" \")[0]) : [];\n\nexport function debounce<T extends unknown[]>(\n\tcallback: (...args: T) => void,\n\tdelay: number,\n) {\n\tlet timer: ReturnType<typeof setTimeout>;\n\n\treturn function (this: unknown, ...args: T) {\n\t\tclearTimeout(timer);\n\t\ttimer = setTimeout(() => callback.apply(this, args), delay);\n\t};\n}\n\n/**\n * attr\n * @description Utility to quickly get, set and remove attributes\n * @param el The Element to read/write attributes from\n * @param name The attribute name to get, set or remove, or a object to set multiple attributes\n * @param value A valid attribute value or null to remove attribute\n */\nexport const attr = (\n\tel: Element,\n\tname: string,\n\tvalue?: string | null,\n): string | null => {\n\tif (value === undefined) return el.getAttribute(name) ?? null; // Fallback to null only if el is undefined\n\tif (value === null) el.removeAttribute(name);\n\telse if (el.getAttribute(name) !== value) el.setAttribute(name, value);\n\treturn null;\n};\n\n/**\n * on\n * @param el The Element to use as EventTarget\n * @param types A space separated string of event types\n * @param listener An event listener function or listener object\n */\nexport const on = (\n\tel: Node | Window | ShadowRoot,\n\t...rest: Parameters<typeof Element.prototype.addEventListener>\n): (() => void) => {\n\tconst [types, ...options] = rest;\n\tfor (const type of types.split(\" \")) el.addEventListener(type, ...options);\n\treturn () => off(el, ...rest);\n};\n\n/**\n * off\n * @param el The Element to use as EventTarget\n * @param types A space separated string of event types\n * @param listener An event listener function or listener object\n */\nexport const off = (\n\tel: Node | Window | ShadowRoot,\n\t...rest: Parameters<typeof Element.prototype.removeEventListener>\n): void => {\n\tconst [types, ...options] = rest;\n\tfor (const type of types.split(\" \")) el.removeEventListener(type, ...options);\n};\n\ndeclare global {\n\tinterface Window {\n\t\t_mtdsHotReloadCleanup?: Map<string, Array<() => void>>;\n\t}\n}\n\n/**\n * onHotReload\n * @description Runs a callback when window is loaded in browser, and ensures cleanup when hot-reloading\n * @param key The key to identify setup and corresponding cleanup\n * @param callback The callback to run when the page is ready\n */\nexport const onHotReload = (key: string, setup: () => Array<() => void>) => {\n\tif (!isBrowser()) return; // Skip if not in modern browser environment, but on each call as Vitest might have unloaded jsdom between tests\n\tif (!window._mtdsHotReloadCleanup) window._mtdsHotReloadCleanup = new Map(); // Hot reload cleanup support supporting all build tools\n\n\tconst run = () => {\n\t\twindow._mtdsHotReloadCleanup?.get(key)?.map((cleanup) => cleanup()); // Run previous cleanup\n\t\twindow._mtdsHotReloadCleanup?.set(key, setup()); // Store new cleanup\n\t};\n\n\tif (document.readyState !== \"complete\") on(window, \"load\", run);\n\telse document.fonts?.ready?.then(run) || setTimeout(run, 0); // Prefer fonts ready promise if available, but fallback to setTimeout\n};\n\n/**\n * Speed up MutationObserver by debouncing and only running when page is visible\n * @return new MutaionObserver\n */\nexport const onMutation = (\n\tel: Node,\n\tcallback: (observer: MutationObserver) => void,\n\toptions: MutationObserverInit,\n) => {\n\tlet queue = 0;\n\tconst onFrame = () => {\n\t\tif (!el.isConnected) return cleanup(); // Disconnect if element is removed from DOM\n\t\tcallback(observer);\n\t\tobserver.takeRecords(); // Clear records to avoid multiple triggers\n\t\tqueue = 0;\n\t};\n\tconst cleanup = () => observer?.disconnect?.();\n\tconst observer = new MutationObserver(() => {\n\t\tif (!queue) queue = requestAnimationFrame(onFrame); // requestAnimationFrame only runs when page is visible\n\t});\n\n\tobserver.observe(el, options);\n\tonFrame(); // Initial run\n\treturn cleanup;\n};\n\n/**\n * toCustomElementProps\n * @description Utility to quickly convert props to custom element attributes\n * @param props The props to convert\n * @returns The converted props\n */\nconst SELECTED = \"aria-selected\";\nexport const toCustomElementProps = <T extends Record<string, unknown>>(\n\trest: T,\n\tklass?: string,\n) =>\n\tObject.assign({}, rest, {\n\t\tsuppressHydrationWarning: true, // Make Next.js happy\n\t\t[SELECTED]:\n\t\t\trest[SELECTED] === undefined\n\t\t\t\t? undefined\n\t\t\t\t: (`${(rest[SELECTED] || \"false\") !== \"false\"}` as unknown as boolean), // Ensure aria-selected boolean is string\n\t\tclass: clsx(klass, rest.className as string) || undefined, // Use class instead of className\n\t\thidden: !!rest.hidden, // Ensure boolean prop behaviour\n\t\topen: !!rest.open, // Ensure boolean prop behaviour\n\t});\n\n/**\n * tag\n * @description creates element and assigns properties\n * @param tagName The tagname of element to create\n * @param attrs Optional attributes to add to the element\n * @param text Optional text content to add to the element\n * @return HTMLElement with props\n */\nexport const tag = <TagName extends keyof HTMLElementTagNameMap>(\n\ttagName: TagName,\n\tattrs?: Record<string, string | null> | null,\n\ttext?: string | null,\n): HTMLElementTagNameMap[TagName] => {\n\tconst el = document.createElement(tagName);\n\tif (text) el.textContent = text;\n\tif (attrs) for (const [key, val] of Object.entries(attrs)) attr(el, key, val);\n\treturn el;\n};\n\n// Make sure we have a HTMLElement to extend (for server side rendering)\nexport const MTDSElement =\n\ttypeof HTMLElement === \"undefined\"\n\t\t? (class {} as typeof HTMLElement)\n\t\t: HTMLElement;\n\n/**\n * defineElement\n * @description Defines a customElement if running in browser and if not already registered\n */\nexport const defineElement = (\n\tname: string,\n\tinstance: CustomElementConstructor,\n) =>\n\t!isBrowser() ||\n\twindow.customElements.get(name) ||\n\twindow.customElements.define(name, instance);\n\n/**\n * attachStyle\n * @param el The Element to scope styles for\n * @param css The css to inject\n */\nexport const SUPPORTS_CONSTRUCTED_CSS =\n\ttypeof window !== \"undefined\" &&\n\twindow.CSSStyleSheet &&\n\tdocument.adoptedStyleSheets;\n\nexport const attachStyle = (el: Element, css: string) => {\n\tif (!SUPPORTS_CONSTRUCTED_CSS) return;\n\tif (!el.shadowRoot) el.attachShadow({ mode: \"open\" }).append(tag(\"slot\"));\n\n\tconst sheet = new CSSStyleSheet();\n\tsheet.replaceSync(css);\n\t(el.shadowRoot as ShadowRoot).adoptedStyleSheets = [sheet];\n};\n"],"names":["QUICK_EVENT","isBrowser","getByCSSModule","key","styles","debounce","callback","delay","timer","args","attr","el","name","value","on","rest","types","options","type","off","onHotReload","setup","run","cleanup","onMutation","queue","onFrame","observer","SELECTED","toCustomElementProps","klass","clsx","tag","tagName","attrs","text","val","MTDSElement","defineElement","instance","SUPPORTS_CONSTRUCTED_CSS","attachStyle","css","sheet"],"mappings":";;AAGO,MAAMA,IAAc,EAAE,SAAS,IAAM,SAAS,GAAA,GACxCC,IAAY,MACxB,OAAO,SAAW,OAAe,OAAO,WAAa,KAEzCC,IAAiB,CAACC,MAC9BF,EAAA,IAAc,SAAS,uBAAuBG,EAAOD,CAAG,EAAE,MAAM,GAAG,EAAE,CAAC,CAAC,IAAI,CAAA;AAErE,SAASE,EACfC,GACAC,GACC;AACD,MAAIC;AAEJ,SAAO,YAA4BC,GAAS;AAC3C,iBAAaD,CAAK,GAClBA,IAAQ,WAAW,MAAMF,EAAS,MAAM,MAAMG,CAAI,GAAGF,CAAK;AAAA,EAC3D;AACD;AASO,MAAMG,IAAO,CACnBC,GACAC,GACAC,MAEIA,MAAU,SAAkBF,EAAG,aAAaC,CAAI,KAAK,QACrDC,MAAU,OAAMF,EAAG,gBAAgBC,CAAI,IAClCD,EAAG,aAAaC,CAAI,MAAMC,KAAOF,EAAG,aAAaC,GAAMC,CAAK,GAC9D,OASKC,IAAK,CACjBH,MACGI,MACe;AAClB,QAAM,CAACC,GAAO,GAAGC,CAAO,IAAIF;AAC5B,aAAWG,KAAQF,EAAM,MAAM,GAAG,EAAG,CAAAL,EAAG,iBAAiBO,GAAM,GAAGD,CAAO;AACzE,SAAO,MAAME,EAAIR,GAAI,GAAGI,CAAI;AAC7B,GAQaI,IAAM,CAClBR,MACGI,MACO;AACV,QAAM,CAACC,GAAO,GAAGC,CAAO,IAAIF;AAC5B,aAAWG,KAAQF,EAAM,MAAM,GAAG,EAAG,CAAAL,EAAG,oBAAoBO,GAAM,GAAGD,CAAO;AAC7E,GAcaG,IAAc,CAACjB,GAAakB,MAAmC;AAC3E,MAAI,CAACpB,IAAa;AACl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iC,CAAG,KAAK,OAAO,QAAQF,CAAK,EAAG,CAAAxB,EAAKC,GAAIR,GAAKiC,CAAG;AAC5E,SAAOzB;AACR,GAGa0B,IACZ,OAAO,cAAgB,MACnB,MAAM;AAAC,IACR,aAMSC,IAAgB,CAC5B1B,GACA2B,MAEA,CAACtC,OACD,OAAO,eAAe,IAAIW,CAAI,KAC9B,OAAO,eAAe,OAAOA,GAAM2B,CAAQ,GAO/BC,IACZ,OAAO,SAAW,OAClB,OAAO,iBACP,SAAS,oBAEGC,IAAc,CAAC9B,GAAa+B,MAAgB;AACxD,MAAI,CAACF,EAA0B;AAC/B,EAAK7B,EAAG,cAAYA,EAAG,aAAa,EAAE,MAAM,OAAA,CAAQ,EAAE,OAAOqB,EAAI,MAAM,CAAC;AAExE,QAAMW,IAAQ,IAAI,cAAA;AAClB,EAAAA,EAAM,YAAYD,CAAG,GACpB/B,EAAG,WAA0B,qBAAqB,CAACgC,CAAK;AAC1D;"}
1
+ {"version":3,"file":"utils.js","names":[],"sources":["../designsystem/utils.ts"],"sourcesContent":["import clsx from \"clsx\";\nimport styles from \"./styles.module.css\";\n\nexport const QUICK_EVENT = { capture: true, passive: true };\nexport const isBrowser = () =>\n\ttypeof window !== \"undefined\" && typeof document !== \"undefined\"; // Using function to play nice with Vitest where DOM can come and go\n\nexport const getByCSSModule = (key: string) =>\n\tisBrowser() ? document.getElementsByClassName(styles[key].split(\" \")[0]) : [];\n\nexport function debounce<T extends unknown[]>(\n\tcallback: (...args: T) => void,\n\tdelay: number,\n) {\n\tlet timer: ReturnType<typeof setTimeout>;\n\n\treturn function (this: unknown, ...args: T) {\n\t\tclearTimeout(timer);\n\t\ttimer = setTimeout(() => callback.apply(this, args), delay);\n\t};\n}\n\n/**\n * attr\n * @description Utility to quickly get, set and remove attributes\n * @param el The Element to read/write attributes from\n * @param name The attribute name to get, set or remove, or a object to set multiple attributes\n * @param value A valid attribute value or null to remove attribute\n */\nexport const attr = (\n\tel: Element,\n\tname: string,\n\tvalue?: string | null,\n): string | null => {\n\tif (value === undefined) return el.getAttribute(name) ?? null; // Fallback to null only if el is undefined\n\tif (value === null) el.removeAttribute(name);\n\telse if (el.getAttribute(name) !== value) el.setAttribute(name, value);\n\treturn null;\n};\n\n/**\n * on\n * @param el The Element to use as EventTarget\n * @param types A space separated string of event types\n * @param listener An event listener function or listener object\n */\nexport const on = (\n\tel: Node | Window | ShadowRoot,\n\t...rest: Parameters<typeof Element.prototype.addEventListener>\n): (() => void) => {\n\tconst [types, ...options] = rest;\n\tfor (const type of types.split(\" \")) el.addEventListener(type, ...options);\n\treturn () => off(el, ...rest);\n};\n\n/**\n * off\n * @param el The Element to use as EventTarget\n * @param types A space separated string of event types\n * @param listener An event listener function or listener object\n */\nexport const off = (\n\tel: Node | Window | ShadowRoot,\n\t...rest: Parameters<typeof Element.prototype.removeEventListener>\n): void => {\n\tconst [types, ...options] = rest;\n\tfor (const type of types.split(\" \")) el.removeEventListener(type, ...options);\n};\n\ndeclare global {\n\tinterface Window {\n\t\t_mtdsHotReloadCleanup?: Map<string, Array<() => void>>;\n\t}\n}\n\n/**\n * onHotReload\n * @description Runs a callback when window is loaded in browser, and ensures cleanup when hot-reloading\n * @param key The key to identify setup and corresponding cleanup\n * @param callback The callback to run when the page is ready\n */\nexport const onHotReload = (key: string, setup: () => Array<() => void>) => {\n\tif (!isBrowser()) return; // Skip if not in modern browser environment, but on each call as Vitest might have unloaded jsdom between tests\n\tif (!window._mtdsHotReloadCleanup) window._mtdsHotReloadCleanup = new Map(); // Hot reload cleanup support supporting all build tools\n\n\tconst run = () => {\n\t\twindow._mtdsHotReloadCleanup?.get(key)?.map((cleanup) => cleanup()); // Run previous cleanup\n\t\twindow._mtdsHotReloadCleanup?.set(key, setup()); // Store new cleanup\n\t};\n\n\tif (document.readyState !== \"complete\") on(window, \"load\", run);\n\telse document.fonts?.ready?.then(run) || setTimeout(run, 0); // Prefer fonts ready promise if available, but fallback to setTimeout\n};\n\n/**\n * Speed up MutationObserver by debouncing and only running when page is visible\n * @return new MutaionObserver\n */\nexport const onMutation = (\n\tel: Node,\n\tcallback: (observer: MutationObserver) => void,\n\toptions: MutationObserverInit,\n) => {\n\tlet queue = 0;\n\tconst onFrame = () => {\n\t\tif (!el.isConnected) return cleanup(); // Disconnect if element is removed from DOM\n\t\tcallback(observer);\n\t\tobserver.takeRecords(); // Clear records to avoid multiple triggers\n\t\tqueue = 0;\n\t};\n\tconst cleanup = () => observer?.disconnect?.();\n\tconst observer = new MutationObserver(() => {\n\t\tif (!queue) queue = requestAnimationFrame(onFrame); // requestAnimationFrame only runs when page is visible\n\t});\n\n\tobserver.observe(el, options);\n\tonFrame(); // Initial run\n\treturn cleanup;\n};\n\n/**\n * toCustomElementProps\n * @description Utility to quickly convert props to custom element attributes\n * @param props The props to convert\n * @returns The converted props\n */\nconst SELECTED = \"aria-selected\";\nexport const toCustomElementProps = <T extends Record<string, unknown>>(\n\trest: T,\n\tklass?: string,\n) =>\n\tObject.assign({}, rest, {\n\t\tsuppressHydrationWarning: true, // Make Next.js happy\n\t\t[SELECTED]:\n\t\t\trest[SELECTED] === undefined\n\t\t\t\t? undefined\n\t\t\t\t: (`${(rest[SELECTED] || \"false\") !== \"false\"}` as unknown as boolean), // Ensure aria-selected boolean is string\n\t\tclass: clsx(klass, rest.className as string) || undefined, // Use class instead of className\n\t\thidden: !!rest.hidden, // Ensure boolean prop behaviour\n\t\topen: !!rest.open, // Ensure boolean prop behaviour\n\t});\n\n/**\n * tag\n * @description creates element and assigns properties\n * @param tagName The tagname of element to create\n * @param attrs Optional attributes to add to the element\n * @param text Optional text content to add to the element\n * @return HTMLElement with props\n */\nexport const tag = <TagName extends keyof HTMLElementTagNameMap>(\n\ttagName: TagName,\n\tattrs?: Record<string, string | null> | null,\n\ttext?: string | null,\n): HTMLElementTagNameMap[TagName] => {\n\tconst el = document.createElement(tagName);\n\tif (text) el.textContent = text;\n\tif (attrs) for (const [key, val] of Object.entries(attrs)) attr(el, key, val);\n\treturn el;\n};\n\n// Make sure we have a HTMLElement to extend (for server side rendering)\nexport const MTDSElement =\n\ttypeof HTMLElement === \"undefined\"\n\t\t? (class {} as typeof HTMLElement)\n\t\t: HTMLElement;\n\n/**\n * defineElement\n * @description Defines a customElement if running in browser and if not already registered\n */\nexport const defineElement = (\n\tname: string,\n\tinstance: CustomElementConstructor,\n) =>\n\t!isBrowser() ||\n\twindow.customElements.get(name) ||\n\twindow.customElements.define(name, instance);\n\n/**\n * attachStyle\n * @param el The Element to scope styles for\n * @param css The css to inject\n */\nexport const SUPPORTS_CONSTRUCTED_CSS =\n\ttypeof window !== \"undefined\" &&\n\twindow.CSSStyleSheet &&\n\tdocument.adoptedStyleSheets;\n\nexport const attachStyle = (el: Element, css: string) => {\n\tif (!SUPPORTS_CONSTRUCTED_CSS) return;\n\tif (!el.shadowRoot) el.attachShadow({ mode: \"open\" }).append(tag(\"slot\"));\n\n\tconst sheet = new CSSStyleSheet();\n\tsheet.replaceSync(css);\n\t(el.shadowRoot as ShadowRoot).adoptedStyleSheets = [sheet];\n};\n"],"mappings":";;;AAGA,IAAa,IAAc;CAAE,SAAS;CAAM,SAAS;AAAK,GAC7C,UACZ,OAAO,SAAW,OAAe,OAAO,WAAa,KAEzC,KAAkB,MAC9B,EAAU,IAAI,SAAS,uBAAuB,EAAO,EAAI,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC;AAE7E,SAAgB,EACf,GACA,GACC;CACD,IAAI;CAEJ,OAAO,SAAyB,GAAG,GAAS;EAE3C,AADA,aAAa,CAAK,GAClB,IAAQ,iBAAiB,EAAS,MAAM,MAAM,CAAI,GAAG,CAAK;CAC3D;AACD;AASA,IAAa,KACZ,GACA,GACA,MAEI,MAAU,KAAA,IAAkB,EAAG,aAAa,CAAI,KAAK,QACrD,MAAU,OAAM,EAAG,gBAAgB,CAAI,IAClC,EAAG,aAAa,CAAI,MAAM,KAAO,EAAG,aAAa,GAAM,CAAK,GAC9D,OASK,KACZ,GACA,GAA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Q,CAAC,CAAC,EAAK;CACf,MAAM,CAAC,CAAC,EAAK;AACd,CAAC,GAUW,KACZ,GACA,GACA,MACoC;CACpC,IAAM,IAAK,SAAS,cAAc,CAAO;CAEzC,IADI,MAAM,EAAG,cAAc,IACvB,GAAO,KAAK,IAAM,CAAC,GAAK,MAAQ,OAAO,QAAQ,CAAK,GAAG,EAAK,GAAI,GAAK,CAAG;CAC5E,OAAO;AACR,GAGa,IACZ,OAAO,cAAgB,MACnB,MAAM,CAAC,IACR,aAMS,KACZ,GACA,MAEA,CAAC,EAAU,KACX,OAAO,eAAe,IAAI,CAAI,KAC9B,OAAO,eAAe,OAAO,GAAM,CAAQ,GAO/B,IACZ,OAAO,SAAW,OAClB,OAAO,iBACP,SAAS,oBAEG,KAAe,GAAa,MAAgB;CACxD,IAAI,CAAC,GAA0B;CAC/B,AAAK,EAAG,cAAY,EAAG,aAAa,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,OAAO,EAAI,MAAM,CAAC;CAExE,IAAM,IAAQ,IAAI,cAAc;CAEhC,AADA,EAAM,YAAY,CAAG,GACrB,EAAI,WAA0B,qBAAqB,CAAC,CAAK;AAC1D"}
@@ -1,49 +1,42 @@
1
- import g from "../styles.module.css.js";
2
- import { isBrowser as v, onHotReload as I, on as a, QUICK_EVENT as h, debounce as b, onMutation as y, attr as n } from "../utils.js";
3
- const f = `.${g.field.split(" ")[0]}`, A = `${f} :is(input,textarea,select)`, C = "ds-suggestion,u-combobox", V = g.validation.split(" ")[0], d = (t) => t instanceof HTMLFormElement && n(t, "data-validation") === "form", u = (t) => t.closest(f), c = (t) => t?.querySelectorAll(A) || [], r = (t) => t?.getElementsByClassName(V) || [], m = (t) => {
4
- const e = !t.clientHeight || t.disabled || t.readOnly || n(t, "aria-readonly") === "true" || n(t, "aria-disabled") === "true", o = t.closest(C)?.items, s = n(t, "aria-required") !== "true" || !!o?.length;
5
- return o && t.setCustomValidity(e || s ? "" : "Required"), e ? !1 : t.matches(":user-invalid");
6
- }, S = (t) => {
7
- const e = t.target?.form || t.target;
8
- let o;
9
- if (d(e)) {
10
- for (const s of e.querySelectorAll(f)) {
11
- const i = [...c(s)].find(m);
12
- !o && i && (o = i);
13
- for (const l of r(s))
14
- n(l, "hidden", i ? null : "");
15
- }
16
- for (const s of e.querySelectorAll("fieldset")) {
17
- const i = [...c(s)].some(m);
18
- for (const l of r(s))
19
- u(l) || n(l, "hidden", i ? null : "");
20
- }
21
- o && (t.preventDefault(), o.focus());
22
- }
23
- }, E = ({ target: t }) => {
24
- const e = t;
25
- if (d(e.form))
26
- for (const o of r(e.closest("fieldset") || u(e)))
27
- n(o, "hidden", "");
28
- }, N = (t) => d(t.target.form) && t?.preventDefault(), T = v() ? r(document) : [], p = () => {
29
- for (const t of T)
30
- if (!t.hasAttribute("data-validation")) {
31
- const e = c(u(t))[0];
32
- n(t, "data-validation", "form"), d(e?.form) && n(t, "hidden", "");
33
- }
1
+ import e from "../styles.module.js";
2
+ import { QUICK_EVENT as t, attr as n, debounce as r, isBrowser as i, on as a, onHotReload as o, onMutation as s } from "../utils.js";
3
+ //#region designsystem/validation/validation-observer.ts
4
+ var c = `.${e.field.split(" ")[0]}`, l = `${c} :is(input,textarea,select)`, u = "ds-suggestion,u-combobox", d = e.validation.split(" ")[0], f = (e) => e instanceof HTMLFormElement && n(e, "data-validation") === "form", p = (e) => e.closest(c), m = (e) => e?.querySelectorAll(l) || [], h = (e) => e?.getElementsByClassName(d) || [], g = (e) => {
5
+ let t = !e.clientHeight || e.disabled || e.readOnly || n(e, "aria-readonly") === "true" || n(e, "aria-disabled") === "true", r = e.closest(u)?.items, i = n(e, "aria-required") !== "true" || !!r?.length;
6
+ return r && e.setCustomValidity(t || i ? "" : "Required"), t ? !1 : e.matches(":user-invalid");
7
+ }, _ = (e) => {
8
+ let t = e.target?.form || e.target, r;
9
+ if (f(t)) {
10
+ for (let e of t.querySelectorAll(c)) {
11
+ let t = [...m(e)].find(g);
12
+ !r && t && (r = t);
13
+ for (let r of h(e)) n(r, "hidden", t ? null : "");
14
+ }
15
+ for (let e of t.querySelectorAll("fieldset")) {
16
+ let t = [...m(e)].some(g);
17
+ for (let r of h(e)) p(r) || n(r, "hidden", t ? null : "");
18
+ }
19
+ r && (e.preventDefault(), r.focus());
20
+ }
21
+ }, v = ({ target: e }) => {
22
+ let t = e;
23
+ if (f(t.form)) for (let e of h(t.closest("fieldset") || p(t))) n(e, "hidden", "");
24
+ }, y = (e) => f(e.target.form) && e?.preventDefault(), b = i() ? h(document) : [], x = () => {
25
+ for (let e of b) if (!e.hasAttribute("data-validation")) {
26
+ let t = m(p(e))[0];
27
+ n(e, "data-validation", "form"), f(t?.form) && n(e, "hidden", "");
28
+ }
34
29
  };
35
- I("validations", () => [
36
- a(document, "input comboboxbeforeselect", E, !0),
37
- // Hide validation when typing
38
- a(document, "invalid", N, !0),
39
- // Prevent default browser invalid popup
40
- a(document, "invalid", b(S, 10), h),
41
- // Debounced to group invalid events
42
- a(document, "submit", S, !0),
43
- // Use capture as submit does not bubble
44
- y(document, p, {
45
- childList: !0,
46
- subtree: !0
47
- })
30
+ o("validations", () => [
31
+ a(document, "input comboboxbeforeselect", v, !0),
32
+ a(document, "invalid", y, !0),
33
+ a(document, "invalid", r(_, 10), t),
34
+ a(document, "submit", _, !0),
35
+ s(document, x, {
36
+ childList: !0,
37
+ subtree: !0
38
+ })
48
39
  ]);
49
- //# sourceMappingURL=validation-observer.js.map
40
+ //#endregion
41
+
42
+ //# sourceMappingURL=validation-observer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validation-observer.js","sources":["../../designsystem/validation/validation-observer.ts"],"sourcesContent":["import styles from \"../styles.module.css\";\nimport {\n\tattr,\n\tdebounce,\n\tisBrowser,\n\ton,\n\tonHotReload,\n\tonMutation,\n\tQUICK_EVENT,\n} from \"../utils\";\n\nconst CSS_FIELD = `.${styles.field.split(\" \")[0]}`;\nconst CSS_INPUTS = `${CSS_FIELD} :is(input,textarea,select)` as \"input\";\nconst CSS_SUGGESTION = \"ds-suggestion,u-combobox\" as \"ds-suggestion\"; // u-combobox kept for backward compatibility\nconst CSS_VALIDATION = styles.validation.split(\" \")[0];\n\nconst isValidationForm = (form: unknown): form is HTMLFormElement =>\n\tform instanceof HTMLFormElement && attr(form, \"data-validation\") === \"form\";\n\nconst getField = (el: Element) => el.closest(CSS_FIELD);\nconst getInputs = (el?: Element | Document | null) =>\n\tel?.querySelectorAll(CSS_INPUTS) || [];\n\nconst getValidations = (el?: Element | Document | null) =>\n\tel?.getElementsByClassName(CSS_VALIDATION) || [];\n\nconst getInvalid = (input: HTMLInputElement) => {\n\tconst skip =\n\t\t!input.clientHeight ||\n\t\tinput.disabled ||\n\t\tinput.readOnly ||\n\t\tattr(input, \"aria-readonly\") === \"true\" ||\n\t\tattr(input, \"aria-disabled\") === \"true\";\n\tconst suggestion = input.closest(CSS_SUGGESTION)?.items;\n\tconst ok = attr(input, \"aria-required\") !== \"true\" || !!suggestion?.length;\n\tif (suggestion) input.setCustomValidity(skip || ok ? \"\" : \"Required\"); // \"Fake\" native validity for suggestions\n\treturn skip ? false : input.matches(\":user-invalid\");\n};\n\n// Hide or show validations on submit or invalid event\nconst handleValidations = (event: Event) => {\n\tconst form = (event.target as HTMLInputElement)?.form || event.target;\n\tlet invalid: HTMLInputElement | undefined;\n\tif (!isValidationForm(form)) return;\n\n\t// Toggle validitiy of fields\n\tfor (const field of form.querySelectorAll(CSS_FIELD)) {\n\t\tconst isInvalid = [...getInputs(field)].find(getInvalid);\n\n\t\tif (!invalid && isInvalid) invalid = isInvalid;\n\t\tfor (const el of getValidations(field))\n\t\t\tattr(el, \"hidden\", isInvalid ? null : \"\");\n\t}\n\n\t// Toggle validitiy of fieldset\n\tfor (const fieldset of form.querySelectorAll(\"fieldset\")) {\n\t\tconst isInvalid = [...getInputs(fieldset)].some(getInvalid);\n\t\tfor (const el of getValidations(fieldset))\n\t\t\tif (!getField(el)) attr(el, \"hidden\", isInvalid ? null : \"\"); // Only toggle fieldset validations if they are not also in a field\n\t}\n\n\tif (!invalid) return;\n\tevent.preventDefault(); // Prevent submit if focusable invalid element found\n\tinvalid.focus(); // Only move focus to first invalid field if validate was true\n};\n\n// Hide related validations again when typing\nconst handleInput = ({ target }: Event) => {\n\tconst input = target as HTMLInputElement;\n\tif (!isValidationForm(input.form)) return; // Skip if not in a validation form\n\tfor (const el of getValidations(input.closest(\"fieldset\") || getField(input)))\n\t\tattr(el, \"hidden\", \"\");\n};\n\n// Hide native browser validation popup\nconst handleInvalid = (e: Event) =>\n\tisValidationForm((e.target as HTMLInputElement).form) && e?.preventDefault();\n\n// Hide validations when added to the DOM\nconst VALIDATIONS = isBrowser() ? getValidations(document) : [];\nconst handleMutation = () => {\n\tfor (const valid of VALIDATIONS)\n\t\tif (!valid.hasAttribute(\"data-validation\")) {\n\t\t\tconst input = getInputs(getField(valid))[0];\n\t\t\tattr(valid, \"data-validation\", \"form\"); // Mark as handled to avoid hiding again if moved in the DOM\n\t\t\tif (isValidationForm(input?.form)) attr(valid, \"hidden\", \"\");\n\t\t}\n};\n\nonHotReload(\"validations\", () => [\n\ton(document, \"input comboboxbeforeselect\", handleInput, true), // Hide validation when typing\n\ton(document, \"invalid\", handleInvalid, true), // Prevent default browser invalid popup\n\ton(document, \"invalid\", debounce(handleValidations, 10), QUICK_EVENT), // Debounced to group invalid events\n\ton(document, \"submit\", handleValidations, true), // Use capture as submit does not bubble\n\tonMutation(document, handleMutation, {\n\t\tchildList: true,\n\t\tsubtree: true,\n\t}),\n]);\n"],"names":["CSS_FIELD","styles","CSS_INPUTS","CSS_SUGGESTION","CSS_VALIDATION","isValidationForm","form","attr","getField","el","getInputs","getValidations","getInvalid","input","skip","suggestion","ok","handleValidations","event","invalid","field","isInvalid","fieldset","handleInput","target","handleInvalid","e","VALIDATIONS","isBrowser","handleMutation","valid","onHotReload","on","debounce","QUICK_EVENT","onMutation"],"mappings":";;AAWA,MAAMA,IAAY,IAAIC,EAAO,MAAM,MAAM,GAAG,EAA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,iBAAWH,KAAME,EAAeW,CAAQ;AACvC,QAAKd,EAASC,CAAE,OAAQA,GAAI,UAAUY,IAAY,OAAO,EAAE;AAAA,IAC7D;AAEA,IAAKF,MACLD,EAAM,eAAA,GACNC,EAAQ,MAAA;AAAA;AACT,GAGMI,IAAc,CAAC,EAAE,QAAAC,QAAoB;AAC1C,QAAMX,IAAQW;AACd,MAAKnB,EAAiBQ,EAAM,IAAI;AAChC,eAAWJ,KAAME,EAAeE,EAAM,QAAQ,UAAU,KAAKL,EAASK,CAAK,CAAC;AAC3E,MAAAN,EAAKE,GAAI,UAAU,EAAE;AACvB,GAGMgB,IAAgB,CAACC,MACtBrB,EAAkBqB,EAAE,OAA4B,IAAI,KAAKA,GAAG,eAAA,GAGvDC,IAAcC,EAAA,IAAcjB,EAAe,QAAQ,IAAI,CAAA,GACvDkB,IAAiB,MAAM;AAC5B,aAAWC,KAASH;AACnB,QAAI,CAACG,EAAM,aAAa,iBAAiB,GAAG;AAC3C,YAAMjB,IAAQH,EAAUF,EAASsB,CAAK,CAAC,EAAE,CAAC;AAC1C,MAAAvB,EAAKuB,GAAO,mBAAmB,MAAM,GACjCzB,EAAiBQ,GAAO,IAAI,KAAGN,EAAKuB,GAAO,UAAU,EAAE;AAAA,IAC5D;AACF;AAEAC,EAAY,eAAe,MAAM;AAAA,EAChCC,EAAG,UAAU,8BAA8BT,GAAa,EAAI;AAAA;AAAA,EAC5DS,EAAG,UAAU,WAAWP,GAAe,EAAI;AAAA;AAAA,EAC3CO,EAAG,UAAU,WAAWC,EAAShB,GAAmB,EAAE,GAAGiB,CAAW;AAAA;AAAA,EACpEF,EAAG,UAAU,UAAUf,GAAmB,EAAI;AAAA;AAAA,EAC9CkB,EAAW,UAAUN,GAAgB;AAAA,IACpC,WAAW;AAAA,IACX,SAAS;AAAA,EAAA,CACT;AACF,CAAC;"}
1
+ {"version":3,"file":"validation-observer.js","names":[],"sources":["../../designsystem/validation/validation-observer.ts"],"sourcesContent":["import styles from \"../styles.module.css\";\nimport {\n\tattr,\n\tdebounce,\n\tisBrowser,\n\ton,\n\tonHotReload,\n\tonMutation,\n\tQUICK_EVENT,\n} from \"../utils\";\n\nconst CSS_FIELD = `.${styles.field.split(\" \")[0]}`;\nconst CSS_INPUTS = `${CSS_FIELD} :is(input,textarea,select)` as \"input\";\nconst CSS_SUGGESTION = \"ds-suggestion,u-combobox\" as \"ds-suggestion\"; // u-combobox kept for backward compatibility\nconst CSS_VALIDATION = styles.validation.split(\" \")[0];\n\nconst isValidationForm = (form: unknown): form is HTMLFormElement =>\n\tform instanceof HTMLFormElement && attr(form, \"data-validation\") === \"form\";\n\nconst getField = (el: Element) => el.closest(CSS_FIELD);\nconst getInputs = (el?: Element | Document | null) =>\n\tel?.querySelectorAll(CSS_INPUTS) || [];\n\nconst getValidations = (el?: Element | Document | null) =>\n\tel?.getElementsByClassName(CSS_VALIDATION) || [];\n\nconst getInvalid = (input: HTMLInputElement) => {\n\tconst skip =\n\t\t!input.clientHeight ||\n\t\tinput.disabled ||\n\t\tinput.readOnly ||\n\t\tattr(input, \"aria-readonly\") === \"true\" ||\n\t\tattr(input, \"aria-disabled\") === \"true\";\n\tconst suggestion = input.closest(CSS_SUGGESTION)?.items;\n\tconst ok = attr(input, \"aria-required\") !== \"true\" || !!suggestion?.length;\n\tif (suggestion) input.setCustomValidity(skip || ok ? \"\" : \"Required\"); // \"Fake\" native validity for suggestions\n\treturn skip ? false : input.matches(\":user-invalid\");\n};\n\n// Hide or show validations on submit or invalid event\nconst handleValidations = (event: Event) => {\n\tconst form = (event.target as HTMLInputElement)?.form || event.target;\n\tlet invalid: HTMLInputElement | undefined;\n\tif (!isValidationForm(form)) return;\n\n\t// Toggle validitiy of fields\n\tfor (const field of form.querySelectorAll(CSS_FIELD)) {\n\t\tconst isInvalid = [...getInputs(field)].find(getInvalid);\n\n\t\tif (!invalid && isInvalid) invalid = isInvalid;\n\t\tfor (const el of getValidations(field))\n\t\t\tattr(el, \"hidden\", isInvalid ? null : \"\");\n\t}\n\n\t// Toggle validitiy of fieldset\n\tfor (const fieldset of form.querySelectorAll(\"fieldset\")) {\n\t\tconst isInvalid = [...getInputs(fieldset)].some(getInvalid);\n\t\tfor (const el of getValidations(fieldset))\n\t\t\tif (!getField(el)) attr(el, \"hidden\", isInvalid ? null : \"\"); // Only toggle fieldset validations if they are not also in a field\n\t}\n\n\tif (!invalid) return;\n\tevent.preventDefault(); // Prevent submit if focusable invalid element found\n\tinvalid.focus(); // Only move focus to first invalid field if validate was true\n};\n\n// Hide related validations again when typing\nconst handleInput = ({ target }: Event) => {\n\tconst input = target as HTMLInputElement;\n\tif (!isValidationForm(input.form)) return; // Skip if not in a validation form\n\tfor (const el of getValidations(input.closest(\"fieldset\") || getField(input)))\n\t\tattr(el, \"hidden\", \"\");\n};\n\n// Hide native browser validation popup\nconst handleInvalid = (e: Event) =>\n\tisValidationForm((e.target as HTMLInputElement).form) && e?.preventDefault();\n\n// Hide validations when added to the DOM\nconst VALIDATIONS = isBrowser() ? getValidations(document) : [];\nconst handleMutation = () => {\n\tfor (const valid of VALIDATIONS)\n\t\tif (!valid.hasAttribute(\"data-validation\")) {\n\t\t\tconst input = getInputs(getField(valid))[0];\n\t\t\tattr(valid, \"data-validation\", \"form\"); // Mark as handled to avoid hiding again if moved in the DOM\n\t\t\tif (isValidationForm(input?.form)) attr(valid, \"hidden\", \"\");\n\t\t}\n};\n\nonHotReload(\"validations\", () => [\n\ton(document, \"input comboboxbeforeselect\", handleInput, true), // Hide validation when typing\n\ton(document, \"invalid\", handleInvalid, true), // Prevent default browser invalid popup\n\ton(document, \"invalid\", debounce(handleValidations, 10), QUICK_EVENT), // Debounced to group invalid events\n\ton(document, \"submit\", handleValidations, true), // Use capture as submit does not bubble\n\tonMutation(document, handleMutation, {\n\t\tchildList: true,\n\t\tsubtree: true,\n\t}),\n]);\n"],"mappings":";;;AAWA,IAAM,IAAY,IAAI,EAAO,MAAM,MAAM,GAAG,CAAC,CAAC,MACxC,IAAa,GA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,MAAM;CAXd;AAYD,GAGM,KAAe,EAAE,gBAAoB;CAC1C,IAAM,IAAQ;CACT,MAAiB,EAAM,IAAI,GAChC,KAAK,IAAM,KAAM,EAAe,EAAM,QAAQ,UAAU,KAAK,EAAS,CAAK,CAAC,GAC3E,EAAK,GAAI,UAAU,EAAE;AACvB,GAGM,KAAiB,MACtB,EAAkB,EAAE,OAA4B,IAAI,KAAK,GAAG,eAAe,GAGtE,IAAc,EAAU,IAAI,EAAe,QAAQ,IAAI,CAAC,GACxD,UAAuB;CAC5B,KAAK,IAAM,KAAS,GACnB,IAAI,CAAC,EAAM,aAAa,iBAAiB,GAAG;EAC3C,IAAM,IAAQ,EAAU,EAAS,CAAK,CAAC,CAAC,CAAC;EAEzC,AADA,EAAK,GAAO,mBAAmB,MAAM,GACjC,EAAiB,GAAO,IAAI,KAAG,EAAK,GAAO,UAAU,EAAE;CAC5D;AACF;AAEA,EAAY,qBAAqB;CAChC,EAAG,UAAU,8BAA8B,GAAa,EAAI;CAC5D,EAAG,UAAU,WAAW,GAAe,EAAI;CAC3C,EAAG,UAAU,WAAW,EAAS,GAAmB,EAAE,GAAG,CAAW;CACpE,EAAG,UAAU,UAAU,GAAmB,EAAI;CAC9C,EAAW,UAAU,GAAgB;EACpC,WAAW;EACX,SAAS;CACV,CAAC;AACF,CAAC"}
@@ -1,22 +1,18 @@
1
- import { jsx as t } from "react/jsx-runtime";
2
- import a from "clsx";
1
+ import e from "../styles.module.js";
2
+ import t from "clsx";
3
3
  import { forwardRef as n } from "react";
4
- import s from "../styles.module.css.js";
5
- const p = n(
6
- function({ className: i, ...o }, r) {
7
- return /* @__PURE__ */ t(
8
- "div",
9
- {
10
- suppressHydrationWarning: !0,
11
- className: a(s.validation, i),
12
- "data-field": "validation",
13
- ref: r,
14
- ...o
15
- }
16
- );
17
- }
18
- );
19
- export {
20
- p as Validation
21
- };
22
- //# sourceMappingURL=validation.js.map
4
+ import { jsx as r } from "react/jsx-runtime";
5
+ //#region designsystem/validation/validation.tsx
6
+ var i = n(function({ className: n, ...i }, a) {
7
+ return /* @__PURE__ */ r("div", {
8
+ suppressHydrationWarning: !0,
9
+ className: t(e.validation, n),
10
+ "data-field": "validation",
11
+ ref: a,
12
+ ...i
13
+ });
14
+ });
15
+ //#endregion
16
+ export { i as Validation };
17
+
18
+ //# sourceMappingURL=validation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validation.js","sources":["../../designsystem/validation/validation.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { forwardRef } from \"react\";\nimport styles from \"../styles.module.css\";\n\nexport type ValidationProps = React.ComponentPropsWithoutRef<\"div\">;\n\nexport const Validation = forwardRef<HTMLDivElement, ValidationProps>(\n\tfunction Validation({ className, ...rest }, ref) {\n\t\treturn (\n\t\t\t<div\n\t\t\t\tsuppressHydrationWarning // Prevent hydration mismatch for SSR due to field-observer.ts\n\t\t\t\tclassName={clsx(styles.validation, className)}\n\t\t\t\tdata-field=\"validation\"\n\t\t\t\tref={ref}\n\t\t\t\t{...rest}\n\t\t\t/>\n\t\t);\n\t},\n);\n"],"names":["Validation","forwardRef","className","rest","ref","jsx","clsx","styles"],"mappings":";;;;AAMO,MAAMA,IAAaC;AAAA,EACzB,SAAoB,EAAE,WAAAC,GAAW,GAAGC,EAAA,GAAQC,GAAK;AAChD,WACC,gBAAAC;AAAA,MAAC;AAAA,MAAA;AAAA,QACA,0BAAwB;AAAA,QACxB,WAAWC,EAAKC,EAAO,YAAYL,CAAS;AAAA,QAC5C,cAAW;AAAA,QACX,KAAAE;AAAA,QACC,GAAGD;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AACD;"}
1
+ {"version":3,"file":"validation.js","names":[],"sources":["../../designsystem/validation/validation.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { forwardRef } from \"react\";\nimport styles from \"../styles.module.css\";\n\nexport type ValidationProps = React.ComponentPropsWithoutRef<\"div\">;\n\nexport const Validation = forwardRef<HTMLDivElement, ValidationProps>(\n\tfunction Validation({ className, ...rest }, ref) {\n\t\treturn (\n\t\t\t<div\n\t\t\t\tsuppressHydrationWarning // Prevent hydration mismatch for SSR due to field-observer.ts\n\t\t\t\tclassName={clsx(styles.validation, className)}\n\t\t\t\tdata-field=\"validation\"\n\t\t\t\tref={ref}\n\t\t\t\t{...rest}\n\t\t\t/>\n\t\t);\n\t},\n);\n"],"mappings":";;;;;AAMA,IAAa,IAAa,EACzB,SAAoB,EAAE,cAAW,GAAG,KAAQ,GAAK;CAChD,OACC,kBAAC,OAAD;EACC,0BAAA;EACA,WAAW,EAAK,EAAO,YAAY,CAAS;EAC5C,cAAW;EACN;EACL,GAAI;CACJ,CAAA;AAEH,CACD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mattilsynet/design",
3
- "version": "3.3.9",
3
+ "version": "3.4.1",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -55,10 +55,10 @@
55
55
  "storybook:build": "npm run build && storybook build"
56
56
  },
57
57
  "devDependencies": {
58
- "@biomejs/biome": "2.5.1",
58
+ "@biomejs/biome": "2.5.3",
59
59
  "@digdir/designsystemet-css": "^1.18.0",
60
60
  "@digdir/designsystemet-types": "^1.18.0",
61
- "@handsontable/react-wrapper": "17.1.0",
61
+ "@handsontable/react-wrapper": "18.0.0",
62
62
  "@phosphor-icons/core": "^2.1.1",
63
63
  "@phosphor-icons/react": "^2.1.10",
64
64
  "@storybook/addon-docs": "^10.4.6",
@@ -69,22 +69,22 @@
69
69
  "@turf/helpers": "^7.3.5",
70
70
  "@types/leaflet": "^1.9.21",
71
71
  "@types/leaflet.markercluster": "^1.5.6",
72
- "@types/node": "^26.0.1",
72
+ "@types/node": "^26.1.1",
73
73
  "@types/react": "^19.2.17",
74
74
  "@types/react-dom": "^19.2.3",
75
- "@vitejs/plugin-react": "^5.2.0",
75
+ "@vitejs/plugin-react": "^6.0.3",
76
76
  "fast-glob": "^3.3.3",
77
- "handsontable": "17.1.0",
77
+ "handsontable": "18.0.0",
78
78
  "leaflet": "^2.0.0-alpha.1",
79
- "postcss": "^8.5.15",
79
+ "postcss": "^8.5.16",
80
80
  "postcss-nesting": "^14.0.0",
81
81
  "react": "^19.2.7",
82
82
  "react-dom": "^19.2.7",
83
83
  "react-moveable": "^0.56.0",
84
84
  "storybook": "^10.4.6",
85
85
  "typescript": "^6.0.3",
86
- "vite": "^7.3.2",
87
- "vite-plugin-dts": "^4.5.4",
86
+ "unplugin-dts": "^1.0.3",
87
+ "vite": "^8.1.3",
88
88
  "vite-plugin-static-copy": "^4.1.1"
89
89
  },
90
90
  "dependencies": {
@@ -1,138 +0,0 @@
1
- const t = `/**
2
- * NOTE:
3
- * - Dark mode styles are in styles.module.css to leverage data-color-scheme attribute
4
- * - This file is using --mtds- not --mtds- since we're inside shadow dom
5
- */
6
-
7
- ::slotted([data-color]), /* Ensure data-color is respected */
8
- :host {
9
- --mtdsc-atlas-border: 1px solid var(--mtds-color-border-subtle);
10
- --mtdsc-atlas-cluster-border: 1px solid;
11
- --mtdsc-atlas-marker-background: var(--mtds-color-base-default);
12
- --mtdsc-atlas-marker-background-outer: #fff;
13
- --mtdsc-atlas-cluster-background: var(--mtdsc-atlas-marker-background);
14
- --mtdsc-atlas-cluster-color: var(--mtdsc-atlas-marker-color);
15
- --mtdsc-atlas-marker-border: none;
16
- --mtdsc-atlas-marker-color: var(--mtds-color-base-contrast-default);
17
- --mtdsc-atlas-marker-inset: 3px;
18
- --mtdsc-atlas-marker-shadow-blur: 4px;
19
- --mtdsc-atlas-marker-shadow-color: rgba(0 0 0 / 0.5);
20
- --mtdsc-atlas-marker-shadow-offset: 2px;
21
- --mtdsc-atlas-marker-size: var(--mtds-6);
22
- --mtdsc-atlas-tile-background: #f7fcfc;
23
- --mtdsc-atlas-tile-filter: grayscale(.8) contrast(0.75) brightness(1.15); /* Also in styles.module.css */
24
- }
25
- :host {
26
- border-radius: var(--mtds-border-radius-md);
27
- aspect-ratio: 2;
28
- overflow: clip;
29
- position: relative;
30
- }
31
- :host(:not([hidden])) { display: block }
32
- :host([data-cursor="pointer"]) .leaflet-grab { cursor: pointer }
33
-
34
- /* Focus */
35
- .leaflet-control-zoom a:focus-visible,
36
- :host:has(.leaflet-container:focus-visible),
37
- ::slotted(mtds-atlas-marker:focus-visible) {
38
- box-shadow: var(--mtdsc-focus-boxShadow);
39
- outline: var(--mtdsc-focus-outline);
40
- outline-offset: var(--mtds-border-width-focus);
41
- }
42
-
43
- /* Tiles */
44
- .leaflet-kartverket-tiles { filter: var(--mtdsc-atlas-tile-filter); transition: filter 0.5s }
45
- .leaflet-container {
46
- background: var(--mtdsc-atlas-tile-background);
47
- border-radius: inherit;
48
- border: var(--mtdsc-atlas-border);
49
- box-sizing: border-box;
50
- font: inherit;
51
- height: 100%;
52
- margin: 0;
53
- outline: 0;
54
- position: relative;
55
- z-index: 1; /* Ensure <slot> is always on top */
56
- }
57
- :host([data-tiles="color"]) {
58
- --mtdsc-atlas-tile-background: #e5fcfd;
59
- --mtdsc-atlas-tile-filter: grayscale(0.2);
60
- }
61
-
62
- /* Controls */
63
- .leaflet-control-attribution { font-size: 12px; border-top-left-radius: var(--mtds-border-radius-md) }
64
- .leaflet-control-zoom { border-radius: var(--mtds-border-radius-md); border: 1px solid var(--mtds-color-border-default) }
65
- .leaflet-control-zoom a { background: var(--mtds-color-surface-default); border-color: inherit; color: var(--mtds-color-text-default); height: var(--mtds-10); line-height: var(--mtds-10); transition: 0.2s; width: var(--mtds-10) }
66
- .leaflet-control-zoom a:first-child { border-top-left-radius: inherit; border-top-right-radius: inherit }
67
- .leaflet-control-zoom a:last-child { border-bottom-left-radius: inherit; border-bottom-right-radius: inherit }
68
- .leaflet-control-zoom a:hover { background: var(--mtds-color-surface-hover) }
69
- .leaflet-control-zoom a:active { background: var(--mtds-color-surface-active) }
70
-
71
- /* Markers */
72
- .leaflet-marker-generated-icon,
73
- ::slotted(mtds-atlas-marker) {
74
- all: unset;
75
- color: var(--mtdsc-atlas-marker-color);
76
- background: var(--mtdsc-atlas-marker-background);
77
- border-radius: 100%;
78
- box-sizing: border-box;
79
- cursor: pointer;
80
- display: grid;
81
- place-items: center;
82
- place-content: center;
83
- font-size: var(--mtds-body-sm-font-size);
84
- font-weight: var(--mtds-font-weight-bold);
85
- height: var(--mtdsc-atlas-marker-size);
86
- /* biome-ignore lint/complexity/noImportantStyles: Overwrite Tailwind */
87
- margin-bottom: calc(var(--mtdsc-atlas-marker-size) * .25 + var(--mtdsc-atlas-marker-inset))!important;
88
- width: var(--mtdsc-atlas-marker-size);
89
- }
90
- .leaflet-marker-generated-icon::after,
91
- ::slotted(mtds-atlas-marker)::after {
92
- box-shadow: var(--mtdsc-atlas-marker-shadow-offset) var(--mtdsc-atlas-marker-shadow-offset) var(--mtdsc-atlas-marker-shadow-blur) var(--mtdsc-atlas-marker-shadow-color);
93
- aspect-ratio: 1;
94
- background: var(--mtdsc-atlas-marker-background-outer);
95
- color: var(--mtdsc-atlas-marker-background);
96
- border-radius: 50% 50% 0 50%;
97
- /* biome-ignore lint/complexity/noImportantStyles: Overwrite Tailwind */
98
- border: var(--mtdsc-atlas-marker-border)!important;
99
- content: "";
100
- rotate: 45deg;
101
- position: absolute;
102
- inset: calc(var(--mtdsc-atlas-marker-inset) * -1);
103
- z-index: -1;
104
- }
105
-
106
- ::slotted(mtds-atlas-marker.leaflet-drag-target) {
107
- cursor: grabbing;
108
- }
109
-
110
- .leaflet-marker-generated-slot,
111
- .leaflet-marker-icon slot { display: block; position: absolute; left: 0; top: 0; translate: -50% -100% }
112
- .leaflet-marker-icon { background: none; border: 0 }
113
- .leaflet-cluster-icon {
114
- box-shadow: 0 var(--mtdsc-atlas-marker-shadow-offset) var(--mtdsc-atlas-marker-shadow-blur) var(--mtdsc-atlas-marker-shadow-color);
115
- background-color: var(--mtdsc-atlas-cluster-background);
116
- border-radius: 100%;
117
- border: var(--mtdsc-atlas-cluster-border);
118
- box-sizing: border-box;
119
- outline: 2px solid var(--mtdsc-atlas-cluster-background);
120
- color: var(--mtdsc-atlas-cluster-color);
121
- display: flex;
122
- font-size: var(--mtds-body-xs-font-size);
123
- font-weight: var(--mtds-font-weight-bold);
124
- place-content: center;
125
- place-items: center;
126
- }
127
-
128
- /* Popover */
129
- .leaflet-popup:has(slot) .leaflet-popup-tip { background: var(--mtds-color-surface-default) }
130
- .leaflet-popup:has(slot) .leaflet-popup-close-button { display: none } /* Popup closes on clicking marker anyway */
131
- .leaflet-popup:has(slot) .leaflet-popup-content-wrapper { display: contents } /* No need for styling this element */
132
- .leaflet-popup:has(slot) .leaflet-popup-content { margin: 0; font: inherit }
133
-
134
- `;
135
- export {
136
- t as default
137
- };
138
- //# sourceMappingURL=atlas.css.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"atlas.css.js","sources":["../../designsystem/atlas/atlas.css?raw"],"sourcesContent":["export default \"/**\\n * NOTE:\\n * - Dark mode styles are in styles.module.css to leverage data-color-scheme attribute\\n * - This file is using --mtds- not --mtds- since we're inside shadow dom\\n */\\t\\n \\n::slotted([data-color]), /* Ensure data-color is respected */\\n:host {\\n\\t--mtdsc-atlas-border: 1px solid var(--mtds-color-border-subtle);\\n\\t--mtdsc-atlas-cluster-border: 1px solid;\\n\\t--mtdsc-atlas-marker-background: var(--mtds-color-base-default);\\n\\t--mtdsc-atlas-marker-background-outer: #fff;\\n\\t--mtdsc-atlas-cluster-background: var(--mtdsc-atlas-marker-background);\\n\\t--mtdsc-atlas-cluster-color: var(--mtdsc-atlas-marker-color);\\n\\t--mtdsc-atlas-marker-border: none;\\n\\t--mtdsc-atlas-marker-color: var(--mtds-color-base-contrast-default);\\n\\t--mtdsc-atlas-marker-inset: 3px;\\n\\t--mtdsc-atlas-marker-shadow-blur: 4px;\\n\\t--mtdsc-atlas-marker-shadow-color: rgba(0 0 0 / 0.5);\\n\\t--mtdsc-atlas-marker-shadow-offset: 2px;\\n\\t--mtdsc-atlas-marker-size: var(--mtds-6);\\n\\t--mtdsc-atlas-tile-background: #f7fcfc;\\n\\t--mtdsc-atlas-tile-filter: grayscale(.8) contrast(0.75) brightness(1.15); /* Also in styles.module.css */\\n}\\n:host {\\n\\tborder-radius: var(--mtds-border-radius-md);\\n\\taspect-ratio: 2;\\n\\toverflow: clip;\\n\\tposition: relative;\\n}\\n:host(:not([hidden])) { display: block }\\n:host([data-cursor=\\\"pointer\\\"]) .leaflet-grab { cursor: pointer }\\n\\n/* Focus */\\n.leaflet-control-zoom a:focus-visible,\\n:host:has(.leaflet-container:focus-visible),\\n::slotted(mtds-atlas-marker:focus-visible) {\\n\\tbox-shadow: var(--mtdsc-focus-boxShadow);\\n\\toutline: var(--mtdsc-focus-outline);\\n\\toutline-offset: var(--mtds-border-width-focus);\\n}\\n\\n/* Tiles */\\n.leaflet-kartverket-tiles { filter: var(--mtdsc-atlas-tile-filter); transition: filter 0.5s }\\n.leaflet-container {\\n\\tbackground: var(--mtdsc-atlas-tile-background);\\n\\tborder-radius: inherit;\\n\\tborder: var(--mtdsc-atlas-border);\\n\\tbox-sizing: border-box;\\n\\tfont: inherit;\\n\\theight: 100%;\\n\\tmargin: 0;\\n\\toutline: 0;\\n\\tposition: relative;\\n\\tz-index: 1; /* Ensure <slot> is always on top */\\n}\\n:host([data-tiles=\\\"color\\\"]) {\\n\\t--mtdsc-atlas-tile-background: #e5fcfd;\\n\\t--mtdsc-atlas-tile-filter: grayscale(0.2);\\n}\\n\\n/* Controls */\\n.leaflet-control-attribution { font-size: 12px; border-top-left-radius: var(--mtds-border-radius-md) }\\n.leaflet-control-zoom { border-radius: var(--mtds-border-radius-md); border: 1px solid var(--mtds-color-border-default) }\\n.leaflet-control-zoom a { background: var(--mtds-color-surface-default); border-color: inherit; color: var(--mtds-color-text-default); height: var(--mtds-10); line-height: var(--mtds-10); transition: 0.2s; width: var(--mtds-10) }\\n.leaflet-control-zoom a:first-child { border-top-left-radius: inherit; border-top-right-radius: inherit }\\n.leaflet-control-zoom a:last-child { border-bottom-left-radius: inherit; border-bottom-right-radius: inherit }\\n.leaflet-control-zoom a:hover { background: var(--mtds-color-surface-hover) }\\n.leaflet-control-zoom a:active { background: var(--mtds-color-surface-active) }\\n\\n/* Markers */\\n.leaflet-marker-generated-icon,\\n::slotted(mtds-atlas-marker) {\\n\\tall: unset;\\n\\tcolor: var(--mtdsc-atlas-marker-color);\\n\\tbackground: var(--mtdsc-atlas-marker-background);\\n\\tborder-radius: 100%;\\n\\tbox-sizing: border-box;\\n\\tcursor: pointer;\\n\\tdisplay: grid;\\n\\tplace-items: center;\\n\\tplace-content: center;\\n\\tfont-size: var(--mtds-body-sm-font-size);\\n\\tfont-weight: var(--mtds-font-weight-bold);\\n\\theight: var(--mtdsc-atlas-marker-size);\\n\\t/* biome-ignore lint/complexity/noImportantStyles: Overwrite Tailwind */\\n\\tmargin-bottom: calc(var(--mtdsc-atlas-marker-size) * .25 + var(--mtdsc-atlas-marker-inset))!important;\\n\\twidth: var(--mtdsc-atlas-marker-size);\\n}\\n.leaflet-marker-generated-icon::after,\\n::slotted(mtds-atlas-marker)::after {\\n\\tbox-shadow: var(--mtdsc-atlas-marker-shadow-offset) var(--mtdsc-atlas-marker-shadow-offset) var(--mtdsc-atlas-marker-shadow-blur) var(--mtdsc-atlas-marker-shadow-color);\\n\\taspect-ratio: 1;\\n\\tbackground: var(--mtdsc-atlas-marker-background-outer);\\n\\tcolor: var(--mtdsc-atlas-marker-background);\\n\\tborder-radius: 50% 50% 0 50%;\\n\\t/* biome-ignore lint/complexity/noImportantStyles: Overwrite Tailwind */\\n\\tborder: var(--mtdsc-atlas-marker-border)!important;\\n\\tcontent: \\\"\\\";\\n\\trotate: 45deg;\\n\\tposition: absolute;\\n\\tinset: calc(var(--mtdsc-atlas-marker-inset) * -1);\\n\\tz-index: -1;\\n}\\n\\n::slotted(mtds-atlas-marker.leaflet-drag-target) {\\n\\tcursor: grabbing;\\n}\\n\\n.leaflet-marker-generated-slot,\\n.leaflet-marker-icon slot { display: block; position: absolute; left: 0; top: 0; translate: -50% -100% }\\n.leaflet-marker-icon { background: none; border: 0 }\\n.leaflet-cluster-icon {\\n\\tbox-shadow: 0 var(--mtdsc-atlas-marker-shadow-offset) var(--mtdsc-atlas-marker-shadow-blur) var(--mtdsc-atlas-marker-shadow-color);\\n\\tbackground-color: var(--mtdsc-atlas-cluster-background);\\n\\tborder-radius: 100%;\\n\\tborder: var(--mtdsc-atlas-cluster-border);\\n\\tbox-sizing: border-box;\\n\\toutline: 2px solid var(--mtdsc-atlas-cluster-background);\\n\\tcolor: var(--mtdsc-atlas-cluster-color);\\n\\tdisplay: flex;\\n\\tfont-size: var(--mtds-body-xs-font-size);\\n\\tfont-weight: var(--mtds-font-weight-bold);\\n\\tplace-content: center;\\n\\tplace-items: center;\\n}\\n\\n/* Popover */\\n.leaflet-popup:has(slot) .leaflet-popup-tip { background: var(--mtds-color-surface-default) }\\n.leaflet-popup:has(slot) .leaflet-popup-close-button { display: none } /* Popup closes on clicking marker anyway */\\n.leaflet-popup:has(slot) .leaflet-popup-content-wrapper { display: contents } /* No need for styling this element */\\n.leaflet-popup:has(slot) .leaflet-popup-content { margin: 0; font: inherit }\\n\\n\""],"names":["css"],"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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;"}
package/mtds/atlas.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"atlas.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}