@mattilsynet/design 0.3.6 → 0.3.8

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 (62) hide show
  1. package/mtds/alert/alert.d.ts +6 -0
  2. package/mtds/alert/alert.stories.d.ts +1 -0
  3. package/mtds/avatar/avatar.d.ts +9 -0
  4. package/mtds/avatar/avatar.stories.d.ts +1 -0
  5. package/mtds/badge/badge.d.ts +6 -0
  6. package/mtds/badge/badge.stories.d.ts +1 -0
  7. package/mtds/breadcrumbs/breadcrumbs.d.ts +8 -0
  8. package/mtds/breadcrumbs/breadcrumbs.stories.d.ts +1 -0
  9. package/mtds/button/button.d.ts +9 -0
  10. package/mtds/card/card.d.ts +9 -0
  11. package/mtds/chip/chip.d.ts +2 -0
  12. package/mtds/details/details.d.ts +4 -0
  13. package/mtds/details/details.stories.d.ts +1 -0
  14. package/mtds/dialog/{dialog.js → dialog-observer.js} +1 -1
  15. package/mtds/dialog/dialog-observer.js.map +1 -0
  16. package/mtds/dialog/dialog.d.ts +6 -2
  17. package/mtds/dialog/dialog.stories.d.ts +1 -0
  18. package/mtds/divider/divider.d.ts +2 -0
  19. package/mtds/divider/divider.stories.d.ts +1 -0
  20. package/mtds/errorsummary/errorsummary.d.ts +2 -0
  21. package/mtds/errorsummary/errorsummary.stories.d.ts +1 -0
  22. package/mtds/field/field-observer.js +45 -0
  23. package/mtds/field/field-observer.js.map +1 -0
  24. package/mtds/field/field.stories.d.ts +1 -1
  25. package/mtds/fieldset/{fieldset.js → fieldset-observer.js} +1 -1
  26. package/mtds/fieldset/fieldset-observer.js.map +1 -0
  27. package/mtds/fieldset/fieldset.d.ts +2 -2
  28. package/mtds/heading/heading.d.ts +6 -0
  29. package/mtds/index.iife.js +1 -1
  30. package/mtds/index.iife.js.map +1 -1
  31. package/mtds/index.js +7 -7
  32. package/mtds/index.js.map +1 -1
  33. package/mtds/layout/layout-observer.d.ts +2 -0
  34. package/mtds/layout/{layout.js → layout-observer.js} +1 -1
  35. package/mtds/layout/layout-observer.js.map +1 -0
  36. package/mtds/link/link.d.ts +5 -0
  37. package/mtds/popover/{popover.js → popover-observer.js} +1 -1
  38. package/mtds/popover/popover-observer.js.map +1 -0
  39. package/mtds/react-types.d.ts +10 -0
  40. package/mtds/react.d.ts +13 -0
  41. package/mtds/styles.css +1 -1
  42. package/mtds/styles.json +31 -31
  43. package/mtds/styles.module.css.js +41 -41
  44. package/mtds/table/table-observer.d.ts +2 -0
  45. package/mtds/table/{table.js → table-observer.js} +1 -1
  46. package/mtds/table/table-observer.js.map +1 -0
  47. package/mtds/tooltip/{tooltip.js → tooltip-observer.js} +1 -1
  48. package/mtds/tooltip/tooltip-observer.js.map +1 -0
  49. package/package.json +5 -5
  50. package/mtds/dialog/dialog.js.map +0 -1
  51. package/mtds/field/field.js +0 -44
  52. package/mtds/field/field.js.map +0 -1
  53. package/mtds/fieldset/fieldset.js.map +0 -1
  54. package/mtds/layout/layout.js.map +0 -1
  55. package/mtds/popover/popover.js.map +0 -1
  56. package/mtds/table/table.js.map +0 -1
  57. package/mtds/tooltip/tooltip.js.map +0 -1
  58. /package/mtds/{field/field.d.ts → dialog/dialog-observer.d.ts} +0 -0
  59. /package/mtds/{layout/layout.d.ts → field/field-observer.d.ts} +0 -0
  60. /package/mtds/{table/table.d.ts → fieldset/fieldset-observer.d.ts} +0 -0
  61. /package/mtds/popover/{popover.d.ts → popover-observer.d.ts} +0 -0
  62. /package/mtds/tooltip/{tooltip.d.ts → tooltip-observer.d.ts} +0 -0
@@ -0,0 +1,6 @@
1
+ import { JSX } from 'react';
2
+ import { PolymorphicComponentPropWithRef } from '../react-types';
3
+ export type AlertProps<As extends React.ElementType = "output"> = PolymorphicComponentPropWithRef<As>;
4
+ type AlertComponent = <As extends React.ElementType = "output">(props: AlertProps<As>) => JSX.Element;
5
+ export declare const Alert: AlertComponent;
6
+ export {};
@@ -8,6 +8,7 @@ declare const meta: {
8
8
  export default meta;
9
9
  type Story = StoryObj<typeof meta>;
10
10
  export declare const Default: Story;
11
+ export declare const React: Story;
11
12
  export declare const Colors: Story;
12
13
  export declare const Sizes: Story;
13
14
  export declare const WithTitle: Story;
@@ -0,0 +1,9 @@
1
+ import { JSX } from 'react';
2
+ import { PolymorphicComponentPropWithRef } from '../react-types';
3
+ type AvatarBaseProps<Href> = {
4
+ href?: Href;
5
+ };
6
+ export type AvatarProps<Href, As extends React.ElementType = Href extends string ? "a" : "span"> = PolymorphicComponentPropWithRef<As, AvatarBaseProps<Href>>;
7
+ type AvatarComponent = <Href, As extends React.ElementType = Href extends string ? "a" : "span">(props: AvatarProps<As>) => JSX.Element;
8
+ export declare const Avatar: AvatarComponent;
9
+ export {};
@@ -8,4 +8,5 @@ declare const meta: {
8
8
  export default meta;
9
9
  type Story = StoryObj<typeof meta>;
10
10
  export declare const Default: Story;
11
+ export declare const React: Story;
11
12
  export declare const Sizes: Story;
@@ -0,0 +1,6 @@
1
+ import { JSX } from 'react';
2
+ import { PolymorphicComponentPropWithRef } from '../react-types';
3
+ export type BadgeProps<As extends React.ElementType = "span"> = PolymorphicComponentPropWithRef<As>;
4
+ type BadgeComponent = <As extends React.ElementType = "span">(props: BadgeProps<As>) => JSX.Element;
5
+ export declare const Badge: BadgeComponent;
6
+ export {};
@@ -8,6 +8,7 @@ declare const meta: {
8
8
  export default meta;
9
9
  type Story = StoryObj<typeof meta>;
10
10
  export declare const Default: Story;
11
+ export declare const React: Story;
11
12
  export declare const Color: Story;
12
13
  export declare const InElement: Story;
13
14
  export declare const WithPosition: Story;
@@ -0,0 +1,8 @@
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 {};
@@ -8,6 +8,7 @@ declare const meta: {
8
8
  export default meta;
9
9
  type Story = StoryObj<typeof meta>;
10
10
  export declare const Default: Story;
11
+ export declare const React: Story;
11
12
  export declare const WithBackbutton: Story;
12
13
  export declare const Sizes: Story;
13
14
  export declare const WithoutLinks: Story;
@@ -0,0 +1,9 @@
1
+ import { JSX } from 'react';
2
+ import { PolymorphicComponentPropWithRef } from '../react-types';
3
+ type ButtonBaseProps<Href> = {
4
+ href?: Href;
5
+ };
6
+ export type ButtonProps<Href, As extends React.ElementType = Href extends string ? "a" : "button"> = PolymorphicComponentPropWithRef<As, ButtonBaseProps<Href>>;
7
+ type ButtonComponent = <Href, As extends React.ElementType = Href extends string ? "a" : "button">(props: ButtonProps<As>) => JSX.Element;
8
+ export declare const Button: ButtonComponent;
9
+ export {};
@@ -0,0 +1,9 @@
1
+ import { JSX } from 'react';
2
+ import { PolymorphicComponentPropWithRef } from '../react-types';
3
+ type CardBaseProps<Href> = {
4
+ href?: Href;
5
+ };
6
+ export type CardProps<Href, As extends React.ElementType = Href extends string ? "a" : "div"> = PolymorphicComponentPropWithRef<As, CardBaseProps<Href>>;
7
+ type CardComponent = <Href, As extends React.ElementType = Href extends string ? "a" : "div">(props: CardProps<As>) => JSX.Element;
8
+ export declare const Card: CardComponent;
9
+ export {};
@@ -0,0 +1,2 @@
1
+ export type ChipProps = React.ComponentPropsWithoutRef<"label">;
2
+ export declare const Chip: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "ref"> & React.RefAttributes<HTMLLabelElement>>;
@@ -0,0 +1,4 @@
1
+ export type DetailsProps = React.ComponentPropsWithoutRef<"details">;
2
+ export declare const Details: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.DetailsHTMLAttributes<HTMLDetailsElement>, HTMLDetailsElement>, "ref"> & React.RefAttributes<HTMLDetailsElement>>;
3
+ export type SummaryProps = React.ComponentPropsWithoutRef<"summary">;
4
+ export declare const Summary: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, "ref"> & React.RefAttributes<HTMLElement>>;
@@ -8,4 +8,5 @@ declare const meta: {
8
8
  export default meta;
9
9
  type Story = StoryObj<typeof meta>;
10
10
  export declare const Default: Story;
11
+ export declare const React: Story;
11
12
  export declare const DefaultOpen: Story;
@@ -16,4 +16,4 @@ export {
16
16
  u as observe,
17
17
  E as unobserve
18
18
  };
19
- //# sourceMappingURL=dialog.js.map
19
+ //# sourceMappingURL=dialog-observer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dialog-observer.js","sources":["../../designsystem/dialog/dialog-observer.ts"],"sourcesContent":["import { QUICK_EVENT, attr, off, on } from '../utils';\n\nconst handleClick = ({ clientX: x, clientY: y, target: el }: MouseEvent) => {\n if (el instanceof HTMLDialogElement && attr(el, 'data-closedby') === 'any') {\n const { top, right, bottom, left } = el.getBoundingClientRect();\n const isInside = top <= y && y <= bottom && left <= x && x <= right;\n \n if (!isInside) el.close();\n } else if (el instanceof Element && el.closest('button[data-command=\"close\"]')) {\n el?.closest('dialog')?.close();\n }\n};\n\nexport function observe(el: Element) {\n on(el, 'click', handleClick as EventListener, QUICK_EVENT);\n}\n\nexport function unobserve(el: Element) {\n off(el, 'click', handleClick as EventListener, QUICK_EVENT);\n}"],"names":["handleClick","x","y","el","attr","top","right","bottom","left","_a","observe","on","QUICK_EVENT","unobserve","off"],"mappings":";AAEA,MAAMA,IAAc,CAAC,EAAE,SAASC,GAAG,SAASC,GAAG,QAAQC,QAAqB;;AAC1E,MAAIA,aAAc,qBAAqBC,EAAKD,GAAI,eAAe,MAAM,OAAO;AAC1E,UAAM,EAAE,KAAAE,GAAK,OAAAC,GAAO,QAAAC,GAAQ,MAAAC,EAAK,IAAIL,EAAG,sBAAsB;AAG1D,IAFaE,KAAOH,KAAKA,KAAKK,KAAUC,KAAQP,KAAKA,KAAKK,KAE/CH,EAAG,MAAM;AAAA,EAAA,OACfA,aAAc,WAAWA,EAAG,QAAQ,8BAA8B,OACvEM,IAAAN,KAAA,gBAAAA,EAAA,QAAQ,cAAR,QAAAM,EAAmB;AAE3B;AAEO,SAASC,EAAQP,GAAa;AAChC,EAAAQ,EAAAR,GAAI,SAASH,GAA8BY,CAAW;AAC3D;AAEO,SAASC,EAAUV,GAAa;AACjC,EAAAW,EAAAX,GAAI,SAASH,GAA8BY,CAAW;AAC5D;"}
@@ -1,2 +1,6 @@
1
- export declare function observe(el: Element): void;
2
- export declare function unobserve(el: Element): void;
1
+ export type DialogProps = React.ComponentPropsWithoutRef<"dialog"> & {
2
+ modal: boolean;
3
+ };
4
+ export declare const Dialog: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement>, "ref"> & {
5
+ modal: boolean;
6
+ } & React.RefAttributes<HTMLDialogElement>>;
@@ -5,5 +5,6 @@ declare const meta: {
5
5
  export default meta;
6
6
  type Story = StoryObj<typeof meta>;
7
7
  export declare const Default: Story;
8
+ export declare const React: Story;
8
9
  export declare const WithClose: Story;
9
10
  export declare const WithBackdropClose: Story;
@@ -0,0 +1,2 @@
1
+ export type DividerProps = React.ComponentPropsWithoutRef<"hr">;
2
+ export declare const Divider: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLHRElement>, HTMLHRElement>, "ref"> & React.RefAttributes<HTMLHRElement>>;
@@ -8,4 +8,5 @@ declare const meta: {
8
8
  export default meta;
9
9
  type Story = StoryObj<typeof meta>;
10
10
  export declare const Default: Story;
11
+ export declare const React: Story;
11
12
  export declare const Gap: Story;
@@ -0,0 +1,2 @@
1
+ export type ErrorsummaryProps = React.ComponentPropsWithoutRef<"div">;
2
+ export declare const Errorsummary: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
@@ -8,4 +8,5 @@ declare const meta: {
8
8
  export default meta;
9
9
  type Story = StoryObj<typeof meta>;
10
10
  export declare const Default: Story;
11
+ export declare const React: Story;
11
12
  export declare const WithForm: Story;
@@ -0,0 +1,45 @@
1
+ import m from "../styles.module.css.js";
2
+ import { onMutation as v, on as u, QUICK_EVENT as p, isInputLike as b, attr as r, off as d, useId as a } from "../utils.js";
3
+ const c = m.field.split(" ")[0], T = "--mtds-text-count-over", _ = "--mtds-text-count-under", g = m.validation.split(" "), y = g[0];
4
+ function P(t) {
5
+ for (const e of t) {
6
+ const i = [], s = [];
7
+ let o = null, l = !0;
8
+ for (const n of e.getElementsByTagName("*"))
9
+ n instanceof HTMLLabelElement ? i.push(n) : b(n) ? o = n : n.classList.contains(y) ? (l = n.getAttribute("data-color") === "success", s.unshift(a(n))) : n instanceof HTMLParagraphElement && s.push(a(n));
10
+ if (o) {
11
+ for (const n of i) n.htmlFor = a(o);
12
+ I(o), r(o, "aria-describedby", s.join(" ")), r(o, "aria-invalid", `${!l}`);
13
+ }
14
+ }
15
+ }
16
+ function S({ target: t }) {
17
+ b(t) && I(t);
18
+ }
19
+ function I(t) {
20
+ var s, o;
21
+ const e = t == null ? void 0 : t.nextElementSibling, i = e == null ? void 0 : e.getAttribute("data-count");
22
+ if (e && i) {
23
+ const l = Number(i) - t.value.length, n = l < 0, h = e.getAttribute("aria-live") === "polite", f = window.getComputedStyle(e || t), C = ((s = f.getPropertyValue(T)) == null ? void 0 : s.slice(1, -1)) || "", L = ((o = f.getPropertyValue(_)) == null ? void 0 : o.slice(1, -1)) || "";
24
+ if (h !== n) {
25
+ r(e, "aria-live", n ? "polite" : "off");
26
+ for (const A of g) e.classList.toggle(A, n);
27
+ }
28
+ e.textContent = (n ? C : L).replace("%d", `${Math.abs(l)}`);
29
+ }
30
+ }
31
+ function E(t) {
32
+ var e, i;
33
+ (i = (e = t.target) == null ? void 0 : e.closest) != null && i.call(e, `.${c}`) && t.preventDefault();
34
+ }
35
+ function R(t) {
36
+ v(t, c, P), u(t, "input", S, p), u(t, "invalid", E, !0);
37
+ }
38
+ function V(t) {
39
+ v(t, c, !1), d(t, "input", S, p), d(t, "invalid", E, !0);
40
+ }
41
+ export {
42
+ R as observe,
43
+ V as unobserve
44
+ };
45
+ //# sourceMappingURL=field-observer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-observer.js","sources":["../../designsystem/field/field-observer.ts"],"sourcesContent":["import styles from '../styles.module.css';\nimport { QUICK_EVENT, attr, isInputLike, off, on, onMutation, useId } from '../utils';\n\nconst CSS_FIELD = styles.field.split(' ')[0];\nconst CSS_PROPERTY_OVER = '--mtds-text-count-over';\nconst CSS_PROPERTY_UNDER = '--mtds-text-count-under';\nconst CSS_VALIDATIONS = styles.validation.split(' ');\nconst CSS_VALIDATION = CSS_VALIDATIONS[0];\n\nfunction renderAria(fields: HTMLCollectionOf<Element>) {\n for(const field of fields) {\n const labels: HTMLLabelElement[] = [];\n const descs: string[] = [];\n let input: HTMLInputElement | null = null;\n let valid = true;\n\n for (const el of field.getElementsByTagName('*')) {\n if (el instanceof HTMLLabelElement) labels.push(el);\n else if (isInputLike(el)) input = el;\n else if (el.classList.contains(CSS_VALIDATION)) { // Must be before instanceof HTMLParagraphElement since validation can also be a <p>\n valid = el.getAttribute('data-color') === 'success';\n descs.unshift(useId(el));\n } else if (el instanceof HTMLParagraphElement) descs.push(useId(el));\n }\n\n if (input) {\n for (const label of labels) label.htmlFor = useId(input);\n renderCounter(input);\n attr(input, 'aria-describedby', descs.join(' '));\n attr(input, 'aria-invalid', `${!valid}`);\n }\n }\n}\nfunction handleInput({ target }: Event) {\n if (isInputLike(target)) renderCounter(target);\n}\n\nfunction renderCounter(input: HTMLInputElement) {\n const el = input?.nextElementSibling;\n const limit = el?.getAttribute('data-count');\n \n if (el && limit) {\n const remainder = Number(limit) - input.value.length;\n const nextInvalid = remainder < 0;\n const prevInvalid = el.getAttribute('aria-live') === 'polite';\n const style = window.getComputedStyle(el || input);\n const over = style.getPropertyValue(CSS_PROPERTY_OVER)?.slice(1, -1) || ''; // slice to trim quotes\n const under = style.getPropertyValue(CSS_PROPERTY_UNDER)?.slice(1, -1) || ''; // slice to trim quotes\n\n if (prevInvalid !== nextInvalid) {\n attr(el, 'aria-live', nextInvalid ? 'polite' : 'off');\n for (const css of CSS_VALIDATIONS) el.classList.toggle(css, nextInvalid);\n }\n el.textContent = (nextInvalid ? over : under).replace('%d', `${Math.abs(remainder)}`);\n }\n}\n\n// Prevent browsers from showing default validation bubbles\nfunction handleInvalid(event: Event) {\n if ((event.target as Element)?.closest?.(`.${CSS_FIELD}`)) event.preventDefault();\n}\n\nexport function observe (el: Element) {\n onMutation(el, CSS_FIELD, renderAria);\n on(el, 'input', handleInput, QUICK_EVENT);\n on(el, 'invalid', handleInvalid, true); // Use capture as invalid does noe buttle\n}\n\nexport function unobserve (el: Element) {\n onMutation(el, CSS_FIELD, false);\n off(el, 'input', handleInput, QUICK_EVENT);\n off(el, 'invalid', handleInvalid, true);\n}\n"],"names":["CSS_FIELD","styles","CSS_PROPERTY_OVER","CSS_PROPERTY_UNDER","CSS_VALIDATIONS","CSS_VALIDATION","renderAria","fields","field","labels","descs","input","valid","el","isInputLike","useId","label","renderCounter","attr","handleInput","target","limit","remainder","nextInvalid","prevInvalid","style","over","_a","under","_b","css","handleInvalid","event","observe","onMutation","on","QUICK_EVENT","unobserve","off"],"mappings":";;AAGA,MAAMA,IAAYC,EAAO,MAAM,MAAM,GAAG,EAAE,CAAC,GACrCC,IAAoB,0BACpBC,IAAqB,2BACrBC,IAAkBH,EAAO,WAAW,MAAM,GAAG,GAC7CI,IAAiBD,EAAgB,CAAC;AAExC,SAASE,EAAWC,GAAmC;AACrD,aAAUC,KAASD,GAAQ;AACzB,UAAME,IAA6B,CAAC,GAC9BC,IAAkB,CAAC;AACzB,QAAIC,IAAiC,MACjCC,IAAQ;AAEZ,eAAWC,KAAML,EAAM,qBAAqB,GAAG;AAC7C,MAAI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eU,IAAcG,IAAOE,GAAO,QAAQ,MAAM,GAAG,KAAK,IAAIN,CAAS,CAAC,EAAE;AAAA,EAAA;AAExF;AAGA,SAASS,EAAcC,GAAc;;AAC9B,GAAAH,KAAAF,IAAAK,EAAM,WAAN,gBAAAL,EAA0B,YAA1B,QAAAE,EAAA,KAAAF,GAAoC,IAAI3B,CAAS,SAAW,eAAe;AAClF;AAEO,SAASiC,EAASpB,GAAa;AACzB,EAAAqB,EAAArB,GAAIb,GAAWM,CAAU,GACjC6B,EAAAtB,GAAI,SAASM,GAAaiB,CAAW,GACrCD,EAAAtB,GAAI,WAAWkB,GAAe,EAAI;AACvC;AAEO,SAASM,EAAWxB,GAAa;AAC3B,EAAAqB,EAAArB,GAAIb,GAAW,EAAK,GAC3BsC,EAAAzB,GAAI,SAASM,GAAaiB,CAAW,GACrCE,EAAAzB,GAAI,WAAWkB,GAAe,EAAI;AACxC;"}
@@ -12,4 +12,4 @@ export declare const Required: Story;
12
12
  export declare const Toggles: Story;
13
13
  export declare const WithValidation: Story;
14
14
  export declare const WithAffixes: Story;
15
- export declare const WithCount: Story;
15
+ export declare const WithCharacterCount: Story;
@@ -17,4 +17,4 @@ export {
17
17
  I as observe,
18
18
  v as unobserve
19
19
  };
20
- //# sourceMappingURL=fieldset.js.map
20
+ //# sourceMappingURL=fieldset-observer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fieldset-observer.js","sources":["../../designsystem/fieldset/fieldset-observer.ts"],"sourcesContent":["import styles from '../styles.module.css';\nimport { attr, isInputLike, onMutation, useId } from '../utils';\nconst CSS_FIELDSET = styles.fieldset.split(' ')[0];\nconst CSS_VALIDATION = styles.validation.split(' ')[0];\n\nfunction process(fieldsets: HTMLCollectionOf<Element>) {\n for(const fieldset of fieldsets) {\n const inputs: HTMLInputElement[] = [];\n let validationId = '';\n\n for (const el of fieldset.getElementsByTagName('*')) {\n if (el.classList.contains(CSS_VALIDATION)) validationId = useId(el);\n else if (isInputLike(el)) inputs.push(el);\n }\n\n if (validationId) \n for(const input of inputs) {\n attr(input, 'aria-describedby', validationId);\n attr(input, 'aria-invalid', 'true');\n }\n }\n}\n\nexport const observe = (el: Element) => onMutation(el, CSS_FIELDSET, process);\nexport const unobserve = (el: Element) => onMutation(el, CSS_FIELDSET, false);\n"],"names":["CSS_FIELDSET","styles","CSS_VALIDATION","process","fieldsets","fieldset","inputs","validationId","el","useId","isInputLike","input","attr","observe","onMutation","unobserve"],"mappings":";;AAEA,MAAMA,IAAeC,EAAO,SAAS,MAAM,GAAG,EAAE,CAAC,GAC3CC,IAAiBD,EAAO,WAAW,MAAM,GAAG,EAAE,CAAC;AAErD,SAASE,EAAQC,GAAsC;AACrD,aAAUC,KAAYD,GAAW;AAC/B,UAAME,IAA6B,CAAC;AACpC,QAAIC,IAAe;AAEnB,eAAWC,KAAMH,EAAS,qBAAqB,GAAG;AAChD,MAAIG,EAAG,UAAU,SAASN,CAAc,IAAGK,IAAeE,EAAMD,CAAE,IACzDE,EAAYF,CAAE,KAAGF,EAAO,KAAKE,CAAE;AAGtC,QAAAD;AACF,iBAAUI,KAASL;AACZ,QAAAM,EAAAD,GAAO,oBAAoBJ,CAAY,GACvCK,EAAAD,GAAO,gBAAgB,MAAM;AAAA,EACpC;AAEN;AAEO,MAAME,IAAU,CAACL,MAAgBM,EAAWN,GAAIR,GAAcG,CAAO,GAC/DY,IAAY,CAACP,MAAgBM,EAAWN,GAAIR,GAAc,EAAK;"}
@@ -1,2 +1,2 @@
1
- export declare const observe: (el: Element) => void;
2
- export declare const unobserve: (el: Element) => void;
1
+ export type FieldsetProps = React.ComponentPropsWithoutRef<"fieldset">;
2
+ export declare const Fieldset: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.FieldsetHTMLAttributes<HTMLFieldSetElement>, HTMLFieldSetElement>, "ref"> & React.RefAttributes<HTMLFieldSetElement>>;
@@ -0,0 +1,6 @@
1
+ import { JSX } from 'react';
2
+ import { PolymorphicComponentPropWithRef } from '../react-types';
3
+ export type HeadingProps<As extends React.ElementType = "h2"> = PolymorphicComponentPropWithRef<As>;
4
+ type HeadingComponent = <As extends React.ElementType = "h2">(props: HeadingProps<As>) => JSX.Element;
5
+ export declare const Heading: HeadingComponent;
6
+ export {};
@@ -1,2 +1,2 @@
1
- var mtds=function(b){"use strict";const y=typeof window<"u"&&typeof document<"u",c={capture:!0,passive:!0};function d(t,e,o){return o===void 0?t.getAttribute(e)??null:(o===null?t.removeAttribute(e):t.getAttribute(e)!==o&&t.setAttribute(e,o),null)}let kt=0;const Pt=`${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`;function S(t){return t.id||(t.id=`${Pt}${++kt}`),t.id}const k=(t,e,o)=>{for(const n of o[0].split(","))o[0]=n,e[`${t}EventListener`](...o)},l=(t,...e)=>k("add",t,e),m=(t,...e)=>k("remove",t,e),M=new Map,_=y?document.createElement("div"):null;_&&d(_,"style","position:absolute;padding:1px;top:0;left:0px"),y&&l(window,"load,resize,scroll",()=>{for(const[t,e]of M)e()},c);const g={top:0,right:1,bottom:2,left:3};function w(t,e,o){var Ot;if(!e||!e.isConnected||!t.isConnected)return M.delete(t);if(_!=null&&_.isConnected||document.body.append(_||""),!M.has(t)){const ve=g[o]??g.bottom;return(Ot=M.set(t,()=>w(t,e,ve)).get(t))==null?void 0:Ot()}const{offsetWidth:n,offsetHeight:s}=t,{offsetWidth:a,offsetHeight:i}=e,{width:p,height:A,left:de,top:le}=e.getBoundingClientRect(),T=Math.round(de-(a-p)/2),h=Math.round(le-(i-A)/2),re=T-n>0,_e=a+a+n<window.innerWidth,fe=h-s>0,ue=h+i+s<window.innerHeight,pe=o===g.bottom&&_e||!re,be=o===g.bottom&&ue||!fe,me=Math.min(Math.max(10,T-(n-a)/2),window.innerWidth-n-10),ge=Math.min(Math.max(10,h-(s-i)/2),window.innerHeight-s-10),Ct=o===g.top||o===g.bottom;t.style.left=`${Math.round(Ct?me:pe?T+a:T-n)}px`,t.style.top=`${Math.round(Ct?be?h+i:h-s:ge)}px`,_==null||_.style.setProperty("translate",`${Math.round(window.scrollX+T+a+n+30)} ${Math.round(window.scrollY+h+i+s+30)}px`)}function xt(t){let e=0;const o=()=>setTimeout(n,200),n=()=>{t([],s),e=0},s=new MutationObserver(()=>{e||(e=requestAnimationFrame(o))});return s}const L=new WeakMap,Bt=t=>{var o;const e=L.get(t);if(!e||!t.isConnected)(o=e==null?void 0:e.observer)==null||o.disconnect(),L.delete(t);else for(const[,n]of e.collections)n()},v=(t,e,o)=>{const n=t.getElementsByClassName(e);let s=L.get(t);s||(s={collections:new Map,observer:xt(()=>Bt(t))},s.observer.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class"]}),L.set(t,s)),o?s.collections.set(e,()=>o(n)):s.collections.delete(e)},$=t=>t instanceof HTMLElement&&"validity"in t&&!(t instanceof HTMLButtonElement),P=({clientX:t,clientY:e,target:o})=>{var n;if(o instanceof HTMLDialogElement&&d(o,"data-closedby")==="any"){const{top:s,right:a,bottom:i,left:p}=o.getBoundingClientRect();s<=e&&e<=i&&p<=t&&t<=a||o.close()}else o instanceof Element&&o.closest('button[data-command="close"]')&&((n=o==null?void 0:o.closest("dialog"))==null||n.close())};function Dt(t){l(t,"click",P,c)}function Ht(t){m(t,"click",P,c)}const x="_alert_1aace_1 _ds-alert_1w6ss_1",B="_avatar_1aace_1 _ds-avatar_1w6ss_1",D="_badge_1aace_1",H="_breadcrumbs_1aace_1 _ds-breadcrumbs_1w6ss_1",N="_button_1aace_1 _ds-button_1w6ss_1",V="_card_1aace_1",Y="_chip_1aace_1 _ds-chip_1w6ss_1",R="_details_1aace_1 _ds-details_1w6ss_1",U="_dialog_1aace_1 _ds-modal_1w6ss_1",W="__fadein_1aace_1",F="_divider_1aace_1",j="_errorsummary_1aace_1 _ds-error-summary_1w6ss_1",G="_field_1aace_1 _ds-field_1w6ss_1",X="_affixes_1aace_1 _ds-field-affixes_1w6ss_1",q="_count_1aace_1",z="_fieldset_1aace_1 _ds-fieldset_1w6ss_1",K="_heading_1aace_1 _ds-heading_1w6ss_1",Q="_input_1aace_1 _ds-input_1w6ss_1",J="_grid_1aace_1",Z="_flex_1aace_1",tt="_app_1aace_1",et="_link_1aace_1",ot="_logo_1aace_1 _ds-focus_1w6ss_1",nt="_pagination_1aace_1 _ds-pagination_1w6ss_1",st="_popover_1aace_1",it="_skeleton_1aace_1 _ds-skeleton_1w6ss_1",at="_spinner_1aace_1",ct="_table_1aace_1 _ds-table_1w6ss_1",dt="__scrollShadow_1aace_1",lt="_tabs_1aace_1 _ds-tabs_1w6ss_1",rt="_tag_1aace_1 _ds-tag_1w6ss_1",_t="__tooltip_1aace_1",ft="_validation_1aace_1 _ds-validation-message_1w6ss_1",ut="_body_1aace_139",f={alert:x,avatar:B,badge:D,breadcrumbs:H,button:N,card:V,chip:Y,details:R,dialog:U,_fadein:W,divider:F,errorsummary:j,field:G,affixes:X,count:q,fieldset:z,heading:K,input:Q,grid:J,flex:Z,app:tt,link:et,logo:ot,pagination:nt,popover:st,skeleton:it,spinner:at,table:ct,_scrollShadow:dt,tabs:lt,tag:rt,_tooltip:_t,validation:ft,body:ut},Nt=Object.freeze(Object.defineProperty({__proto__:null,_fadein:W,_scrollShadow:dt,_tooltip:_t,affixes:X,alert:x,app:tt,avatar:B,badge:D,body:ut,breadcrumbs:H,button:N,card:V,chip:Y,count:q,default:f,details:R,dialog:U,divider:F,errorsummary:j,field:G,fieldset:z,flex:Z,grid:J,heading:K,input:Q,link:et,logo:ot,pagination:nt,popover:st,skeleton:it,spinner:at,table:ct,tabs:lt,tag:rt,validation:ft},Symbol.toStringTag,{value:"Module"})),C=f.field.split(" ")[0],pt=f.validation.split(" "),Vt=pt[0];function Yt(t){for(const e of t){const o=[],n=[];let s=null,a=!0;for(const i of e.getElementsByTagName("*"))i instanceof HTMLLabelElement?o.push(i):$(i)?s=i:i.classList.contains(Vt)?(a=i.getAttribute("data-color")==="success",n.unshift(S(i))):i instanceof HTMLParagraphElement&&n.push(S(i));if(s){for(const i of o)i.htmlFor=S(s);mt(s),d(s,"aria-describedby",n.join(" ")),d(s,"aria-invalid",`${!a}`)}}}function bt({target:t}){$(t)&&mt(t)}function mt(t){const e=t==null?void 0:t.nextElementSibling,o=e==null?void 0:e.getAttribute("data-count");if(e&&o){const n=Number(o)-t.value.length,s=n<0;if(e.getAttribute("aria-live")==="polite"!==s){d(e,"aria-live",s?"polite":"off");for(const i of pt)e.classList.toggle(i,s)}e.textContent=`${Math.abs(n)} tegn ${s?"for mye":"igjen"}`}}function gt(t){var e,o;(o=(e=t.target)==null?void 0:e.closest)!=null&&o.call(e,`.${C}`)&&t.preventDefault()}function Rt(t){v(t,C,Yt),l(t,"input",bt,c),l(t,"invalid",gt,!0)}function Ut(t){v(t,C,!1),m(t,"input",bt,c),m(t,"invalid",gt,!0)}const vt=f.fieldset.split(" ")[0],Wt=f.validation.split(" ")[0];function Ft(t){for(const e of t){const o=[];let n="";for(const s of e.getElementsByTagName("*"))s.classList.contains(Wt)?n=S(s):$(s)&&o.push(s);if(n)for(const s of o)d(s,"aria-describedby",n),d(s,"aria-invalid","true")}}const jt=t=>v(t,vt,Ft),Gt=t=>v(t,vt,!1),ht=f.app.split(" ")[0],Xt=`.${ht} > header + :not(main) > button:empty:first-child`,wt=({target:t})=>{const e=(t==null?void 0:t.nodeName)==="BUTTON"&&(t==null?void 0:t.closest(Xt));if(!e)return;const o=e.closest(`.${ht} > *`),n=()=>o==null?void 0:o.setAttribute("data-expanded",`${(o==null?void 0:o.getAttribute("data-expanded"))==="false"}`);document.startViewTransition?document.startViewTransition(()=>n()):n()};function qt(t){l(t,"click",wt,c)}function zt(t){m(t,"click",wt,c)}function Kt(t){l(t,"toggle",yt,c),l(t,"click",St)}function Qt(t){m(t,"toggle",yt,c),m(t,"click",St)}const Tt=f.popover.split(" ")[0];function yt({target:t,newState:e}){var o;if(t instanceof HTMLElement&&t.classList.contains(Tt)){const n=(o=t.getRootNode())==null?void 0:o.querySelector(`[popovertarget="${t.id}"]`);e==="closed"?w(t,!1):n&&w(t,n,t.getAttribute("data-position")||"bottom")}}function St({target:t}){var o,n;const e=(o=t==null?void 0:t.closest)==null?void 0:o.call(t,"a");if(e){const s=e.getRootNode(),a=((n=s.getElementById)==null?void 0:n.call(s,d(e,"popovertarget")||""))||e.closest(`.${Tt}`),i=d(e,"popovertargetaction")||"toggle";a==null||a.togglePopover(i==="show"||(i==="hide"?!1:void 0))}}const Mt=f.table.split(" ")[0];function Jt(t){var e,o;for(const n of t)if(n instanceof HTMLTableElement){const s=Array.from(((o=(e=n.tHead)==null?void 0:e.rows[0])==null?void 0:o.cells)||[],a=>{var i;return(i=a.innerText)==null?void 0:i.trim()});for(const a of n.tBodies)for(const i of a.rows)for(const p of i.cells)d(p,"data-th",s[p.cellIndex]||":empty")}}const Zt=t=>v(t,Mt,Jt),te=t=>v(t,Mt,!1),ee=f._tooltip.split(" "),Lt="aria-describedby",Et="Escape",E="aria-labelledby",oe="--mtds-tooltip-position",ne=100,I="mtds-tooltip";let u=null,It=Number.NEGATIVE_INFINITY,At=0,r=null;function O({target:t,type:e,key:o}){if(e==="keydown"&&o!==Et)return;const n=It+ne-Date.now();clearTimeout(At),At=setTimeout(se,Math.max(n,0),o===Et?null:t)}function se(t){var a;if(It=Date.now(),!r||t===r)return;let e=((a=t==null?void 0:t.closest)==null?void 0:a.call(t,"[data-tooltip]"))||null;if(e===u)return;const o=(e==null?void 0:e.getAttribute("data-tooltip"))||"",n=(e==null?void 0:e.getAttribute("data-tooltip-position"))||window.getComputedStyle(e||document.body).getPropertyValue(oe)||"top",s=!!(e!=null&&e.innerText.trim())||(e==null?void 0:e.hasAttribute(E))||(e==null?void 0:e.hasAttribute("aria-label"));(!o||o==="false"||o==="true"||n==="none")&&(e=null),e&&(r.textContent=o),u==null||u.removeAttribute(u.getAttribute(E)===I?E:Lt),w(r,!1),u=e,u==null||u.setAttribute(s?Lt:E,I),r.togglePopover(!!e),w(r,e,n)}y&&!document.getElementById(I)&&(r=document.body.appendChild(document.createElement("div")),r.classList.add(...ee),r.id=I,d(r,"popover","manual"),l(document,"blur,focus,mouseout,mouseover",O,c),l(window,"keydown",O,c),l(window,"blur",O,c));const ie=(t,e,o)=>{const n=(o-1)/2,s=Math.max(Math.min(t-Math.floor(n),e-o+1),1),a=Math.min(Math.max(t+Math.ceil(n),o),e),i=Array.from({length:a+1-s},(p,A)=>A+s);return o>4&&s>1&&i.splice(0,2,1,0),o>3&&a<e&&i.splice(-2,2,0,e),i},ae=({current:t=1,total:e=10,show:o=7})=>({prev:t>1?t-1:0,next:t<e?t+1:0,pages:ie(t,e,o).map((n,s)=>({current:n===t&&"page",key:`key-${n}-${s}`,page:n}))});if(y){const t=document.readyState==="loading",e=()=>$t(document.body);t?document.addEventListener("DOMContentLoaded",e):e()}function $t(t){Dt(t),Rt(t),jt(t),qt(t),Kt(t),Zt(t)}function ce(t){Ht(t),Ut(t),Gt(t),zt(t),Qt(t),te(t)}return b.observe=$t,b.pagination=ae,b.styles=Nt,b.unobserve=ce,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"}),b}({});
1
+ var mtds=function(y){"use strict";const S=typeof window<"u"&&typeof document<"u",d={capture:!0,passive:!0};function a(t,o,e){return e===void 0?t.getAttribute(o)??null:(e===null?t.removeAttribute(o):t.getAttribute(o)!==e&&t.setAttribute(o,e),null)}let xt=0;const Bt=`${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`;function E(t){return t.id||(t.id=`${Bt}${++xt}`),t.id}const x=(t,o,e)=>{for(const n of e[0].split(","))e[0]=n,o[`${t}EventListener`](...e)},r=(t,...o)=>x("add",t,o),g=(t,...o)=>x("remove",t,o),M=new Map,_=S?document.createElement("div"):null;_&&a(_,"style","position:absolute;padding:1px;top:0;left:0px"),S&&r(window,"load,resize,scroll",()=>{for(const[t,o]of M)o()},d);const v={top:0,right:1,bottom:2,left:3};function T(t,o,e){var kt;if(!o||!o.isConnected||!t.isConnected)return M.delete(t);if(_!=null&&_.isConnected||document.body.append(_||""),!M.has(t)){const wo=v[e]??v.bottom;return(kt=M.set(t,()=>T(t,o,wo)).get(t))==null?void 0:kt()}const{offsetWidth:n,offsetHeight:s}=t,{offsetWidth:c,offsetHeight:i}=o,{width:b,height:p,left:P,top:k}=o.getBoundingClientRect(),m=Math.round(P-(c-b)/2),w=Math.round(k-(i-p)/2),uo=m-n>0,bo=c+c+n<window.innerWidth,po=w-s>0,mo=w+i+s<window.innerHeight,yo=e===v.bottom&&bo||!uo,go=e===v.bottom&&mo||!po,vo=Math.min(Math.max(10,m-(n-c)/2),window.innerWidth-n-10),ho=Math.min(Math.max(10,w-(s-i)/2),window.innerHeight-s-10),Pt=e===v.top||e===v.bottom;t.style.left=`${Math.round(Pt?vo:yo?m+c:m-n)}px`,t.style.top=`${Math.round(Pt?go?w+i:w-s:ho)}px`,_==null||_.style.setProperty("translate",`${Math.round(window.scrollX+m+c+n+30)} ${Math.round(window.scrollY+w+i+s+30)}px`)}function Dt(t){let o=0;const e=()=>setTimeout(n,200),n=()=>{t([],s),o=0},s=new MutationObserver(()=>{o||(o=requestAnimationFrame(e))});return s}const L=new WeakMap,Nt=t=>{var e;const o=L.get(t);if(!o||!t.isConnected)(e=o==null?void 0:o.observer)==null||e.disconnect(),L.delete(t);else for(const[,n]of o.collections)n()},h=(t,o,e)=>{const n=t.getElementsByClassName(o);let s=L.get(t);s||(s={collections:new Map,observer:Dt(()=>Nt(t))},s.observer.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class"]}),L.set(t,s)),e?s.collections.set(o,()=>e(n)):s.collections.delete(o)},$=t=>t instanceof HTMLElement&&"validity"in t&&!(t instanceof HTMLButtonElement),B=({clientX:t,clientY:o,target:e})=>{var n;if(e instanceof HTMLDialogElement&&a(e,"data-closedby")==="any"){const{top:s,right:c,bottom:i,left:b}=e.getBoundingClientRect();s<=o&&o<=i&&b<=t&&t<=c||e.close()}else e instanceof Element&&e.closest('button[data-command="close"]')&&((n=e==null?void 0:e.closest("dialog"))==null||n.close())};function Rt(t){r(t,"click",B,d)}function Ht(t){g(t,"click",B,d)}const D="_alert_1drby_1 _ds-alert_1w6ss_1",N="_avatar_1drby_1 _ds-avatar_1w6ss_1",R="_badge_1drby_1",H="_breadcrumbs_1drby_1 _ds-breadcrumbs_1w6ss_1",V="_button_1drby_1 _ds-button_1w6ss_1",Y="_card_1drby_1",U="_chip_1drby_1 _ds-chip_1w6ss_1",W="_details_1drby_1 _ds-details_1w6ss_1",F="_dialog_1drby_1 _ds-modal_1w6ss_1",j="__fadein_1drby_1",G="_divider_1drby_1",X="_errorsummary_1drby_1 _ds-error-summary_1w6ss_1",q="_field_1drby_1 _ds-field_1w6ss_1",z="_affixes_1drby_1 _ds-field-affixes_1w6ss_1",K="_count_1drby_1",Q="_fieldset_1drby_1 _ds-fieldset_1w6ss_1",J="_heading_1drby_1 _ds-heading_1w6ss_1",Z="_input_1drby_1 _ds-input_1w6ss_1",tt="_grid_1drby_1",ot="_flex_1drby_1",et="_app_1drby_1",nt="_link_1drby_1",st="_logo_1drby_1 _ds-focus_1w6ss_1",it="_pagination_1drby_1 _ds-pagination_1w6ss_1",ct="_popover_1drby_1",dt="_skeleton_1drby_1 _ds-skeleton_1w6ss_1",at="_spinner_1drby_1",rt="_table_1drby_1 _ds-table_1w6ss_1",lt="__scrollShadow_1drby_1",_t="_tabs_1drby_1 _ds-tabs_1w6ss_1",ft="_tag_1drby_1 _ds-tag_1w6ss_1",ut="__tooltip_1drby_1",bt="_validation_1drby_1 _ds-validation-message_1w6ss_1",pt="_body_1drby_143",f={alert:D,avatar:N,badge:R,breadcrumbs:H,button:V,card:Y,chip:U,details:W,dialog:F,_fadein:j,divider:G,errorsummary:X,field:q,affixes:z,count:K,fieldset:Q,heading:J,input:Z,grid:tt,flex:ot,app:et,link:nt,logo:st,pagination:it,popover:ct,skeleton:dt,spinner:at,table:rt,_scrollShadow:lt,tabs:_t,tag:ft,_tooltip:ut,validation:bt,body:pt},Vt=Object.freeze(Object.defineProperty({__proto__:null,_fadein:j,_scrollShadow:lt,_tooltip:ut,affixes:z,alert:D,app:et,avatar:N,badge:R,body:pt,breadcrumbs:H,button:V,card:Y,chip:U,count:K,default:f,details:W,dialog:F,divider:G,errorsummary:X,field:q,fieldset:Q,flex:ot,grid:tt,heading:J,input:Z,link:nt,logo:st,pagination:it,popover:ct,skeleton:dt,spinner:at,table:rt,tabs:_t,tag:ft,validation:bt},Symbol.toStringTag,{value:"Module"})),C=f.field.split(" ")[0],Yt="--mtds-text-count-over",Ut="--mtds-text-count-under",mt=f.validation.split(" "),Wt=mt[0];function Ft(t){for(const o of t){const e=[],n=[];let s=null,c=!0;for(const i of o.getElementsByTagName("*"))i instanceof HTMLLabelElement?e.push(i):$(i)?s=i:i.classList.contains(Wt)?(c=i.getAttribute("data-color")==="success",n.unshift(E(i))):i instanceof HTMLParagraphElement&&n.push(E(i));if(s){for(const i of e)i.htmlFor=E(s);gt(s),a(s,"aria-describedby",n.join(" ")),a(s,"aria-invalid",`${!c}`)}}}function yt({target:t}){$(t)&&gt(t)}function gt(t){var n,s;const o=t==null?void 0:t.nextElementSibling,e=o==null?void 0:o.getAttribute("data-count");if(o&&e){const c=Number(e)-t.value.length,i=c<0,b=o.getAttribute("aria-live")==="polite",p=window.getComputedStyle(o||t),P=((n=p.getPropertyValue(Yt))==null?void 0:n.slice(1,-1))||"",k=((s=p.getPropertyValue(Ut))==null?void 0:s.slice(1,-1))||"";if(b!==i){a(o,"aria-live",i?"polite":"off");for(const m of mt)o.classList.toggle(m,i)}o.textContent=(i?P:k).replace("%d",`${Math.abs(c)}`)}}function vt(t){var o,e;(e=(o=t.target)==null?void 0:o.closest)!=null&&e.call(o,`.${C}`)&&t.preventDefault()}function jt(t){h(t,C,Ft),r(t,"input",yt,d),r(t,"invalid",vt,!0)}function Gt(t){h(t,C,!1),g(t,"input",yt,d),g(t,"invalid",vt,!0)}const ht=f.fieldset.split(" ")[0],Xt=f.validation.split(" ")[0];function qt(t){for(const o of t){const e=[];let n="";for(const s of o.getElementsByTagName("*"))s.classList.contains(Xt)?n=E(s):$(s)&&e.push(s);if(n)for(const s of e)a(s,"aria-describedby",n),a(s,"aria-invalid","true")}}const zt=t=>h(t,ht,qt),Kt=t=>h(t,ht,!1),wt=f.app.split(" ")[0],Qt=`.${wt} > header + :not(main) > button:empty:first-child`,Tt=({target:t})=>{const o=(t==null?void 0:t.nodeName)==="BUTTON"&&(t==null?void 0:t.closest(Qt));if(!o)return;const e=o.closest(`.${wt} > *`),n=()=>e==null?void 0:e.setAttribute("data-expanded",`${(e==null?void 0:e.getAttribute("data-expanded"))==="false"}`);document.startViewTransition?document.startViewTransition(()=>n()):n()};function Jt(t){r(t,"click",Tt,d)}function Zt(t){g(t,"click",Tt,d)}function to(t){r(t,"toggle",Et,d),r(t,"click",Mt)}function oo(t){g(t,"toggle",Et,d),g(t,"click",Mt)}const St=f.popover.split(" ")[0];function Et({target:t,newState:o}){var e;if(t instanceof HTMLElement&&t.classList.contains(St)){const n=(e=t.getRootNode())==null?void 0:e.querySelector(`[popovertarget="${t.id}"]`);o==="closed"?T(t,!1):n&&T(t,n,t.getAttribute("data-position")||"bottom")}}function Mt({target:t}){var e,n;const o=(e=t==null?void 0:t.closest)==null?void 0:e.call(t,"a");if(o){const s=o.getRootNode(),c=((n=s.getElementById)==null?void 0:n.call(s,a(o,"popovertarget")||""))||o.closest(`.${St}`),i=a(o,"popovertargetaction")||"toggle";c==null||c.togglePopover(i==="show"||(i==="hide"?!1:void 0))}}const Lt=f.table.split(" ")[0];function eo(t){var o,e;for(const n of t)if(n instanceof HTMLTableElement){const s=Array.from(((e=(o=n.tHead)==null?void 0:o.rows[0])==null?void 0:e.cells)||[],c=>{var i;return(i=c.innerText)==null?void 0:i.trim()});for(const c of n.tBodies)for(const i of c.rows)for(const b of i.cells)a(b,"data-th",s[b.cellIndex]||":empty")}}const no=t=>h(t,Lt,eo),so=t=>h(t,Lt,!1),io=f._tooltip.split(" "),At="aria-describedby",It="Escape",A="aria-labelledby",co="--mtds-tooltip-position",ao=100,I="mtds-tooltip";let u=null,$t=Number.NEGATIVE_INFINITY,Ct=0,l=null;function O({target:t,type:o,key:e}){if(o==="keydown"&&e!==It)return;const n=$t+ao-Date.now();clearTimeout(Ct),Ct=setTimeout(ro,Math.max(n,0),e===It?null:t)}function ro(t){var c;if($t=Date.now(),!l||t===l)return;let o=((c=t==null?void 0:t.closest)==null?void 0:c.call(t,"[data-tooltip]"))||null;if(o===u)return;const e=(o==null?void 0:o.getAttribute("data-tooltip"))||"",n=(o==null?void 0:o.getAttribute("data-tooltip-position"))||window.getComputedStyle(o||document.body).getPropertyValue(co)||"top",s=!!(o!=null&&o.innerText.trim())||(o==null?void 0:o.hasAttribute(A))||(o==null?void 0:o.hasAttribute("aria-label"));(!e||e==="false"||e==="true"||n==="none")&&(o=null),o&&(l.textContent=e),u==null||u.removeAttribute(u.getAttribute(A)===I?A:At),T(l,!1),u=o,u==null||u.setAttribute(s?At:A,I),l.togglePopover(!!o),T(l,o,n)}S&&!document.getElementById(I)&&(l=document.body.appendChild(document.createElement("div")),l.classList.add(...io),l.id=I,a(l,"popover","manual"),r(document,"blur,focus,mouseout,mouseover",O,d),r(window,"keydown",O,d),r(window,"blur",O,d));const lo=(t,o,e)=>{const n=(e-1)/2,s=Math.max(Math.min(t-Math.floor(n),o-e+1),1),c=Math.min(Math.max(t+Math.ceil(n),e),o),i=Array.from({length:c+1-s},(b,p)=>p+s);return e>4&&s>1&&i.splice(0,2,1,0),e>3&&c<o&&i.splice(-2,2,0,o),i},_o=({current:t=1,total:o=10,show:e=7})=>({prev:t>1?t-1:0,next:t<o?t+1:0,pages:lo(t,o,e).map((n,s)=>({current:n===t&&"page",key:`key-${n}-${s}`,page:n}))});if(S){const t=document.readyState==="loading",o=()=>Ot(document.body);t?document.addEventListener("DOMContentLoaded",o):o()}function Ot(t){Rt(t),jt(t),zt(t),Jt(t),to(t),no(t)}function fo(t){Ht(t),Gt(t),Kt(t),Zt(t),oo(t),so(t)}return y.observe=Ot,y.pagination=_o,y.styles=Vt,y.unobserve=fo,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"}),y}({});
2
2
  //# sourceMappingURL=index.iife.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.iife.js","sources":["../designsystem/utils.ts","../designsystem/dialog/dialog.ts","../designsystem/field/field.ts","../designsystem/fieldset/fieldset.ts","../designsystem/layout/layout.ts","../designsystem/popover/popover.ts","../designsystem/table/table.ts","../designsystem/tooltip/tooltip.ts","../designsystem/pagination/pagination.ts","../designsystem/index.ts"],"sourcesContent":["export const IS_BROWSER = typeof window !== 'undefined' && typeof document !== 'undefined';\nexport const QUICK_EVENT = { capture: true, passive: true };\n\n/**\n * attr\n * @description Utility to quickly get, set and remove attributes\n * @param el The Element to use as EventTarget\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 function 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 * useId\n * @return A generated unique ID\n */\nlet id = 0;\nconst UUID = `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 5)}`;\nexport function useId (el: Element) {\n if (!el.id) el.id = `${UUID}${++id}`;\n\treturn el.id;\n};\n\n// Internal helper for on / off\nconst events = (\n\taction: \"add\" | \"remove\",\n\telement: Node | Window,\n\trest: Parameters<typeof Element.prototype.addEventListener>,\n): void => {\n\tfor (const type of rest[0].split(\",\")) {\n\t\trest[0] = type;\n\t\telement[`${action}EventListener`](...rest);\n\t}\n};\n\n/**\n * on\n * @param element The Element to use as EventTarget\n * @param types A comma separated string of event types\n * @param listener An event listener function or listener object\n */\nexport const on = (\n\telement: Node | Window,\n\t...rest: Parameters<typeof Element.prototype.addEventListener>\n): void => events(\"add\", element, rest);\n\n/**\n * off\n * @param element The Element to use as EventTarget\n * @param types A comma separated string of event types\n * @param listener An event listener function or listener object\n */\nexport const off = (\n\telement: Node | Window,\n\t...rest: Parameters<typeof Element.prototype.removeEventListener>\n): void => events(\"remove\", element, rest);\n\n\nconst TARGETS = new Map<Element, () => void>(); // Store current open poppers and their update functions\nconst SCROLLER = IS_BROWSER ? document.createElement('div') : null // Used to ensure we have scrollability under\nif (SCROLLER) attr(SCROLLER, 'style', 'position:absolute;padding:1px;top:0;left:0px');\n\nif (IS_BROWSER){\n\ton(window, 'load,resize,scroll', () => {\n\t\tfor (const [_, update] of TARGETS) update();\n\t}, QUICK_EVENT);}\n\t\n/**\n * anchorPosition\n * @param target The Element to position\n * @param anchor The Element to use as anchor\n */\nconst POSITION = { top: 0, right: 1, bottom: 2, left: 3 }; // Speed up by using a const map\n\nexport function anchorPosition (target: HTMLElement, anchor: HTMLElement | null | false, position?: string | number) {\n\tif (!anchor || !anchor.isConnected || !target.isConnected) return TARGETS.delete(target); // Stop watchning if anchor is removed from DOM\n\tif (!SCROLLER?.isConnected) document.body.append(SCROLLER || ''); // Ensure we have t´he scroller\n\tif (!TARGETS.has(target)) { // Setup new target or update position\n\t\tconst place = POSITION[position as keyof typeof POSITION] ?? POSITION.bottom; // Use CSS property to store position for more flexibility\n\t\treturn TARGETS.set(target, () => anchorPosition(target, anchor, place)).get(target)?.(); // Start watching if not already watching\n\t}\n\n const { offsetWidth: targetW, offsetHeight: targetH } = target;\n const { offsetWidth: anchorW, offsetHeight: anchorH } = anchor;\n const { width, height, left, top } = anchor.getBoundingClientRect();\n\tconst anchorX = Math.round(left - (anchorW - width) / 2); // Correct for CSS transform scale\n const anchorY = Math.round(top - (anchorH - height) / 2); // Correct for CSS transform scale\n\n\tconst hasSpaceLeft = anchorX - targetW > 0\n\tconst hasSpaceRight = anchorW + anchorW + targetW < window.innerWidth;\n\tconst hasSpaceOver = anchorY - targetH > 0\n\tconst hasSpaceUnder = anchorY + anchorH + targetH < window.innerHeight;\n\tconst positionRight = (position === POSITION.bottom && hasSpaceRight) || !hasSpaceLeft // Always position right when no hasSpaceLeft, as no OS scrolls further up than 0\n\tconst positionUnder = (position === POSITION.bottom && hasSpaceUnder) || !hasSpaceOver // Always position under when no hasSpaceOver, as no OS scrolls further up than 0\n\tconst centerX = Math.min(Math.max(10, anchorX - (targetW - anchorW) / 2), window.innerWidth - targetW - 10);\n\tconst centerY = Math.min(Math.max(10, anchorY - (targetH - anchorH) / 2), window.innerHeight - targetH - 10);\n\tconst isVertical = position === POSITION.top || position === POSITION.bottom;\n\n\ttarget.style.left = `${Math.round(isVertical ? centerX : (positionRight ? anchorX + anchorW : anchorX - targetW))}px`\n target.style.top = `${Math.round(isVertical ? (positionUnder ? anchorY + anchorH : anchorY - targetH) : centerY)}px`\n SCROLLER?.style.setProperty('translate', `${Math.round(window.scrollX + anchorX + anchorW + targetW + 30)} ${Math.round(window.scrollY + anchorY + anchorH + targetH + 30)}px`);\n}\n\n/**\n * Speed up MutationObserver by debouncing and only running when page is visible\n * @return new MutaionObserver\n */\nexport function createOptimizedMutationObserver(callback: MutationCallback) {\n let queue = 0;\n\n\tconst onFrame = () => setTimeout(onTimer, 200); // Use both requestAnimationFrame and setTimeout to debounce and only run when visible\n\tconst onTimer = () => {\n\t\tcallback([], observer);\n\t\tqueue = 0;\n\t};\n const observer = new MutationObserver(() => {\n if (!queue) queue = requestAnimationFrame(onFrame);\n });\n\n return observer;\n}\n\ntype Mutator = { observer: MutationObserver, collections: Map<string, () => void> };\nconst MUTATORS = new WeakMap<Element, Mutator>();\nconst MUTATORS_CALLBACK = (element: Element) => {\n\tconst mutator = MUTATORS.get(element);\n\n\tif (!mutator || !element.isConnected) {\n\t\tmutator?.observer?.disconnect();\n\t\tMUTATORS.delete(element);\n\t} else for(const [, callback] of mutator.collections) callback();\n};\n\n/**\n * onMutation\n * @description Utility to quickly observe mutations on a specific class name\n * @param element The Element to use as EventTarget\n * @param className The class name to observe\n * @param callback The callback to run when mutations are detected or false to stop observing\n */\nexport const onMutation = (\n\telement: Element,\n\tclassName: string,\n\tcallback: ((collection: HTMLCollection) => void) | false\n) => {\n\tconst collection = element.getElementsByClassName(className);\n\tlet mutator = MUTATORS.get(element);\n\n\tif (!mutator) {\n\t\tmutator = { collections: new Map(), observer: createOptimizedMutationObserver(() => MUTATORS_CALLBACK(element)) };\n\t\tmutator.observer.observe(element, { childList: true, subtree: true, attributes: true, attributeFilter: ['class'] });\n\t\tMUTATORS.set(element, mutator);\n\t}\n\tif (callback) mutator.collections.set(className, () => callback(collection));\n\telse mutator.collections.delete(className);\n}\n\nexport const isInputLike = (el: unknown): el is HTMLInputElement =>\n\tel instanceof HTMLElement && 'validity' in el && !(el instanceof HTMLButtonElement);\n\n// Make React support popover=\"\"target attribute\n// https://github.com/facebook/react/issues/27479\ntype Popover = \"\" | \"auto\" | \"manual\" | undefined;\ndeclare global {\n\tnamespace React.JSX {\n\t\tinterface IntrinsicAttributes {\n\t\t\tpopovertargetaction?: string;\n\t\t\tpopovertarget?: string;\n\t\t\tpopover?: Popover;\n\t\t}\n\t}\n\tnamespace React {\n\t\tinterface HTMLAttributes<T> {\n\t\t\tpopovertargetaction?: string;\n\t\t\tpopovertarget?: string;\n\t\t\tpopover?: Popover;\n\t\t}\n\t}\n}","import { QUICK_EVENT, attr, off, on } from '../utils';\n\nconst handleClick = ({ clientX: x, clientY: y, target: el }: MouseEvent) => {\n if (el instanceof HTMLDialogElement && attr(el, 'data-closedby') === 'any') {\n const { top, right, bottom, left } = el.getBoundingClientRect();\n const isInside = top <= y && y <= bottom && left <= x && x <= right;\n \n if (!isInside) el.close();\n } else if (el instanceof Element && el.closest('button[data-command=\"close\"]')) {\n el?.closest('dialog')?.close();\n }\n};\n\nexport function observe(el: Element) {\n on(el, 'click', handleClick as EventListener, QUICK_EVENT);\n}\n\nexport function unobserve(el: Element) {\n off(el, 'click', handleClick as EventListener, QUICK_EVENT);\n}","import styles from '../styles.module.css';\nimport { QUICK_EVENT, attr, isInputLike, off, on, onMutation, useId } from '../utils';\n\nconst CSS_FIELD = styles.field.split(' ')[0];\nconst CSS_VALIDATIONS = styles.validation.split(' ');\nconst CSS_VALIDATION = CSS_VALIDATIONS[0];\n\nfunction renderAria(fields: HTMLCollectionOf<Element>) {\n for(const field of fields) {\n const labels: HTMLLabelElement[] = [];\n const descs: string[] = [];\n let input: HTMLInputElement | null = null;\n let valid = true;\n\n for (const el of field.getElementsByTagName('*')) {\n if (el instanceof HTMLLabelElement) labels.push(el);\n else if (isInputLike(el)) input = el;\n else if (el.classList.contains(CSS_VALIDATION)) { // Must be before instanceof HTMLParagraphElement since validation can also be a <p>\n valid = el.getAttribute('data-color') === 'success';\n descs.unshift(useId(el));\n } else if (el instanceof HTMLParagraphElement) descs.push(useId(el));\n }\n\n if (input) {\n for (const label of labels) label.htmlFor = useId(input);\n renderCounter(input);\n attr(input, 'aria-describedby', descs.join(' '));\n attr(input, 'aria-invalid', `${!valid}`);\n }\n }\n}\nfunction handleInput({ target }: Event) {\n if (isInputLike(target)) renderCounter(target);\n}\n\nfunction renderCounter(input: HTMLInputElement) {\n const el = input?.nextElementSibling;\n const limit = el?.getAttribute('data-count');\n\n if (el && limit) {\n const remainder = Number(limit) - input.value.length;\n const nextInvalid = remainder < 0;\n const prevInvalid = el.getAttribute('aria-live') === 'polite';\n\n if (prevInvalid !== nextInvalid) {\n attr(el, 'aria-live', nextInvalid ? 'polite' : 'off');\n for (const css of CSS_VALIDATIONS) el.classList.toggle(css, nextInvalid);\n }\n el.textContent = `${Math.abs(remainder)} tegn ${nextInvalid ? 'for mye' : 'igjen'}`;\n }\n}\n\n// Prevent browsers from showing default validation bubbles\nfunction handleInvalid(event: Event) {\n if ((event.target as Element)?.closest?.(`.${CSS_FIELD}`)) event.preventDefault();\n}\n\nexport function observe (el: Element) {\n onMutation(el, CSS_FIELD, renderAria);\n on(el, 'input', handleInput, QUICK_EVENT);\n on(el, 'invalid', handleInvalid, true); // Use capture as invalid does noe buttle\n}\n\nexport function unobserve (el: Element) {\n onMutation(el, CSS_FIELD, false);\n off(el, 'input', handleInput, QUICK_EVENT);\n off(el, 'invalid', handleInvalid, true);\n}\n","import styles from '../styles.module.css';\nimport { attr, isInputLike, onMutation, useId } from '../utils';\nconst CSS_FIELDSET = styles.fieldset.split(' ')[0];\nconst CSS_VALIDATION = styles.validation.split(' ')[0];\n\nfunction process(fieldsets: HTMLCollectionOf<Element>) {\n for(const fieldset of fieldsets) {\n const inputs: HTMLInputElement[] = [];\n let validationId = '';\n\n for (const el of fieldset.getElementsByTagName('*')) {\n if (el.classList.contains(CSS_VALIDATION)) validationId = useId(el);\n else if (isInputLike(el)) inputs.push(el);\n }\n\n if (validationId) \n for(const input of inputs) {\n attr(input, 'aria-describedby', validationId);\n attr(input, 'aria-invalid', 'true');\n }\n }\n}\n\nexport const observe = (el: Element) => onMutation(el, CSS_FIELDSET, process);\nexport const unobserve = (el: Element) => onMutation(el, CSS_FIELDSET, false);\n","import styles from '../styles.module.css';\nimport { QUICK_EVENT, off, on } from '../utils';\n\nconst CSS_APP = styles.app.split(' ')[0];\nconst CSS_TOGGLE = `.${CSS_APP} > header + :not(main) > button:empty:first-child`;\n\nconst handleToggleClick = ({ target: el }: Event) => {\n const btn = (el as Element)?.nodeName === 'BUTTON' && (el as Element)?.closest(CSS_TOGGLE);\n\n if (!btn) return;\n\n const nav = btn.closest(`.${CSS_APP} > *`);\n const toggle = () =>\n nav?.setAttribute(\n \"data-expanded\",\n `${nav?.getAttribute(\"data-expanded\") === \"false\"}`,\n );\n\n if (!document.startViewTransition) toggle();\n else document.startViewTransition(() => toggle());\n};\n\nexport function observe(el: Element) {\n on(el, 'click', handleToggleClick, QUICK_EVENT);\n}\n\nexport function unobserve(el: Element) {\n off(el, 'click', handleToggleClick, QUICK_EVENT);\n}\n","import styles from '../styles.module.css';\nimport { QUICK_EVENT, anchorPosition, attr, off, on } from '../utils';\n\nexport function observe(el: Node) {\n on(el, 'toggle', handleToggle, QUICK_EVENT); // Use capture since toggle does not bubble\n on(el, 'click', handleLinkClick); // Allow `<a>` to use `popovertarget` as well\n}\nexport function unobserve(el: Node) {\n off(el, 'toggle', handleToggle, QUICK_EVENT); // Use capture since toggle does not bubble\n off(el, 'click', handleLinkClick);\n}\n\nconst CSS_POPOVER = styles.popover.split(' ')[0];\n\nfunction handleToggle ({ target: el, newState }: Event & { newState?: string }){\n if (el instanceof HTMLElement && el.classList.contains(CSS_POPOVER)) {\n const anchor = (el.getRootNode() as ShadowRoot)?.querySelector<HTMLElement>(`[popovertarget=\"${el.id}\"]`);\n \n if (newState === 'closed') anchorPosition(el, false);\n else if (anchor) anchorPosition(el, anchor, el.getAttribute('data-position') || 'bottom');\n }\n}\n\n// Polyfill popovertarget for <a> (not supported by native)\n// and automatically assume popovertarget is the closest parent popover\n// but respect the popovertarget and popovertargetaction attribute\nfunction handleLinkClick ({ target }: Event){\n const link = (target as Element )?.closest?.('a');\n if (link) {\n const root = link.getRootNode() as ShadowRoot;\n const target = root.getElementById?.(attr(link, 'popovertarget') || '') || link.closest(`.${CSS_POPOVER}`);\n const action = attr(link, 'popovertargetaction') || 'toggle';\n\n target?.togglePopover(action === 'show' || (action === 'hide' ? false : undefined));\n }\n}","import styles from '../styles.module.css';\nimport { attr, onMutation } from '../utils';\nconst CSS_TABLE = styles.table.split(' ')[0];\n\nfunction process(tables: HTMLCollectionOf<Element>) {\n for(const table of tables) if (table instanceof HTMLTableElement) {\n const ths = Array.from(table.tHead?.rows[0]?.cells || [], (el) => el.innerText?.trim()); // Using innerText to only include visible text\n for (const tbody of table.tBodies) {\n for (const row of tbody.rows) {\n for (const cell of row.cells) {\n attr(cell, 'data-th', ths[cell.cellIndex] || ':empty');\n }\n }\n }\n }\n}\n\nexport const observe = (el: Element) => onMutation(el, CSS_TABLE, process);\nexport const unobserve = (el: Element) => onMutation(el, CSS_TABLE, false);\n","import styles from '../styles.module.css';\nimport { IS_BROWSER, QUICK_EVENT, anchorPosition, attr, on } from \"../utils\";\n\nconst CSS_TOOLTIP = styles._tooltip.split(' ');\nconst DESCRIBEDBY = 'aria-describedby';\nconst ESC = 'Escape';\nconst LABELLEDBY = 'aria-labelledby';\nconst POSITION_CSS_PROPERTY = '--mtds-tooltip-position';\nconst THROTTLE_DELAY = 100;\nconst TOOLTIP_ID = 'mtds-tooltip';\n\nlet ANCHOR: HTMLElement | null = null;\nlet LAST_CALL = Number.NEGATIVE_INFINITY;\nlet THROTTLE: number | ReturnType<typeof setTimeout> = 0;\nlet TOOLTIP: HTMLElement | null = null;\n\nfunction handleMove({ target, type, key }: Event & { key?: string }) {\n if (type === 'keydown' && key !== ESC) return; // Allow ESC dismiss to follow https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/\n const wait = LAST_CALL + THROTTLE_DELAY - Date.now();\n clearTimeout(THROTTLE);\n THROTTLE = setTimeout(handleMoveThrottled, Math.max(wait, 0), key === ESC ? null : target);\n}\n\n// Using a throttled function to avoid performance issues\nfunction handleMoveThrottled(target: Element | null) {\n LAST_CALL = Date.now();\n\n if (!TOOLTIP || target === TOOLTIP) return; // Allow tooltip to be hovered, following https://www.w3.org/TR/WCAG21/#content-on-hover-or-focus\n let anchor = target?.closest?.<HTMLElement>('[data-tooltip]') || null;\n \n // No need to update\n if (anchor === ANCHOR) return;\n\n const content = anchor?.getAttribute('data-tooltip') || '';\n const position = anchor?.getAttribute('data-tooltip-position') || window.getComputedStyle(anchor || document.body).getPropertyValue(POSITION_CSS_PROPERTY) || 'top';\n const hasLabel = Boolean(anchor?.innerText.trim()) || anchor?.hasAttribute(LABELLEDBY) || anchor?.hasAttribute('aria-label');\n\n if (!content || content === 'false' || content === 'true' || position === 'none') anchor = null; // Do not show tooltip if boolish value\n if (anchor) TOOLTIP.textContent = content; // Only update content if new anchor\n\n ANCHOR?.removeAttribute(ANCHOR.getAttribute(LABELLEDBY) === TOOLTIP_ID ? LABELLEDBY : DESCRIBEDBY); // Unlink previous anchor\n anchorPosition(TOOLTIP, false); // Reset anchor position\n\n ANCHOR = anchor; // Store new anchor - might be null if no new anchor\n ANCHOR?.setAttribute(hasLabel ? DESCRIBEDBY : LABELLEDBY, TOOLTIP_ID); // Use tooltip as description if allready has label\n TOOLTIP.togglePopover(!!anchor);\n anchorPosition(TOOLTIP, anchor, position);\n}\n\n// Initialize if in browser and not already initialized\nif (IS_BROWSER && !document.getElementById(TOOLTIP_ID)) {\n TOOLTIP = document.body.appendChild(document.createElement('div'));\n TOOLTIP.classList.add(...CSS_TOOLTIP);\n TOOLTIP.id = TOOLTIP_ID;\n attr(TOOLTIP, 'popover', 'manual');\n on(document, 'blur,focus,mouseout,mouseover', handleMove, QUICK_EVENT);\n on(window, 'keydown', handleMove, QUICK_EVENT);\n on(window, 'blur', handleMove, QUICK_EVENT);\n}","const getSteps = (now: number, max: number, show: number) => {\n const offset = (show - 1) / 2;\n const start = Math.max(Math.min(now - Math.floor(offset), max - show + 1), 1);\n const end = Math.min(Math.max(now + Math.ceil(offset), show), max);\n const pages = Array.from({ length: end + 1 - start }, (_, i) => i + start);\n\n if (show > 4 && start > 1) pages.splice(0, 2, 1, 0);\n if (show > 3 && end < max) pages.splice(-2, 2, 0, max);\n return pages;\n};\n\nexport const pagination = ({\n current = 1,\n total = 10,\n show = 7,\n}) => ({\n prev: current > 1 ? current - 1 : 0,\n next: current < total ? current + 1 : 0,\n pages: getSteps(current, total, show).map((page, index) => ({\n current: page === current && 'page' as const,\n key: `key-${page}-${index}`,\n page,\n })),\n});\n","import * as dialog from './dialog/dialog';\nimport * as field from './field/field';\nimport * as fieldset from './fieldset/fieldset';\nimport * as layout from './layout/layout';\nimport * as popover from './popover/popover';\nimport * as table from './table/table';\nimport './tooltip/tooltip'; // Load data-tooltip behaviour\nimport { IS_BROWSER } from './utils';\nexport { pagination } from './pagination/pagination';\nexport * as styles from './styles.module.css';\n\n// Automatic observe on browser\nif (IS_BROWSER) {\n const isLoading = document.readyState === \"loading\"; // Check if the page is still loading - might happen if the script is in <head>\n const onLoaded = () => observe(document.body);\n \n if (isLoading) document.addEventListener(\"DOMContentLoaded\", onLoaded);\n else onLoaded();\n}\n\nexport function observe(el: Element) {\n dialog.observe(el);\n field.observe(el);\n fieldset.observe(el);\n layout.observe(el);\n popover.observe(el);\n table.observe(el);\n}\n\nexport function unobserve(el: Element) {\n dialog.unobserve(el);\n field.unobserve(el);\n fieldset.unobserve(el);\n layout.unobserve(el);\n popover.unobserve(el);\n table.unobserve(el);\n}"],"names":["IS_BROWSER","QUICK_EVENT","attr","el","name","value","id","UUID","useId","events","action","element","rest","type","on","off","TARGETS","SCROLLER","_","update","POSITION","anchorPosition","target","anchor","position","place","_a","targetW","targetH","anchorW","anchorH","width","height","left","top","anchorX","anchorY","hasSpaceLeft","hasSpaceRight","hasSpaceOver","hasSpaceUnder","positionRight","positionUnder","centerX","centerY","isVertical","createOptimizedMutationObserver","callback","queue","onFrame","onTimer","observer","MUTATORS","MUTATORS_CALLBACK","mutator","onMutation","className","collection","isInputLike","handleClick","x","y","right","bottom","observe","unobserve","CSS_FIELD","styles","CSS_VALIDATIONS","CSS_VALIDATION","renderAria","fields","field","labels","descs","input","valid","label","renderCounter","handleInput","limit","remainder","nextInvalid","css","handleInvalid","event","_b","CSS_FIELDSET","process","fieldsets","fieldset","inputs","validationId","CSS_APP","CSS_TOGGLE","handleToggleClick","btn","nav","toggle","handleToggle","handleLinkClick","CSS_POPOVER","newState","link","root","CSS_TABLE","tables","table","ths","tbody","row","cell","CSS_TOOLTIP","DESCRIBEDBY","ESC","LABELLEDBY","POSITION_CSS_PROPERTY","THROTTLE_DELAY","TOOLTIP_ID","ANCHOR","LAST_CALL","THROTTLE","TOOLTIP","handleMove","key","wait","handleMoveThrottled","content","hasLabel","getSteps","now","max","show","offset","start","end","pages","i","pagination","current","total","page","index","isLoading","onLoaded","dialog.observe","field.observe","fieldset.observe","layout.observe","popover.observe","table.observe","dialog.unobserve","field.unobserve","fieldset.unobserve","layout.unobserve","popover.unobserve","table.unobserve"],"mappings":"kCAAO,M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CAACpH,EAAGuH,IAAMA,EAAIH,CAAK,EAErE,OAAAF,EAAO,GAAKE,EAAQ,KAAS,OAAO,EAAG,EAAG,EAAG,CAAC,EAC9CF,EAAO,GAAKG,EAAMJ,KAAW,OAAO,GAAI,EAAG,EAAGA,CAAG,EAC9CK,CACT,EAEaE,GAAa,CAAC,CACzB,QAAAC,EAAU,EACV,MAAAC,EAAQ,GACR,KAAAR,EAAO,CACT,KAAO,CACL,KAAMO,EAAU,EAAIA,EAAU,EAAI,EAClC,KAAMA,EAAUC,EAAQD,EAAU,EAAI,EACtC,MAAOV,GAASU,EAASC,EAAOR,CAAI,EAAE,IAAI,CAACS,EAAMC,KAAW,CAC1D,QAASD,IAASF,GAAW,OAC7B,IAAK,OAAOE,CAAI,IAAIC,CAAK,GACzB,KAAAD,CAAA,EACA,CACJ,GCXA,GAAI7I,EAAY,CACR,MAAA+I,EAAY,SAAS,aAAe,UACpCC,EAAW,IAAMhF,GAAQ,SAAS,IAAI,EAExC+E,EAAW,SAAS,iBAAiB,mBAAoBC,CAAQ,EACvDA,EAAA,CAChB,CAEO,SAAShF,GAAQ7D,EAAa,CACnC8I,GAAe9I,CAAE,EACjB+I,GAAc/I,CAAE,EAChBgJ,GAAiBhJ,CAAE,EACnBiJ,GAAejJ,CAAE,EACjBkJ,GAAgBlJ,CAAE,EAClBmJ,GAAcnJ,CAAE,CAClB,CAEO,SAAS8D,GAAU9D,EAAa,CACrCoJ,GAAiBpJ,CAAE,EACnBqJ,GAAgBrJ,CAAE,EAClBsJ,GAAmBtJ,CAAE,EACrBuJ,GAAiBvJ,CAAE,EACnBwJ,GAAkBxJ,CAAE,EACpByJ,GAAgBzJ,CAAE,CACpB"}
1
+ {"version":3,"file":"index.iife.js","sources":["../designsystem/utils.ts","../designsystem/dialog/dialog-observer.ts","../designsystem/field/field-observer.ts","../designsystem/fieldset/fieldset-observer.ts","../designsystem/layout/layout-observer.ts","../designsystem/popover/popover-observer.ts","../designsystem/table/table-observer.ts","../designsystem/tooltip/tooltip-observer.ts","../designsystem/pagination/pagination.ts","../designsystem/index.ts"],"sourcesContent":["export const IS_BROWSER = typeof window !== 'undefined' && typeof document !== 'undefined';\nexport const QUICK_EVENT = { capture: true, passive: true };\n\n/**\n * attr\n * @description Utility to quickly get, set and remove attributes\n * @param el The Element to use as EventTarget\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 function 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 * useId\n * @return A generated unique ID\n */\nlet id = 0;\nconst UUID = `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 5)}`;\nexport function useId (el: Element) {\n if (!el.id) el.id = `${UUID}${++id}`;\n\treturn el.id;\n};\n\n// Internal helper for on / off\nconst events = (\n\taction: \"add\" | \"remove\",\n\telement: Node | Window,\n\trest: Parameters<typeof Element.prototype.addEventListener>,\n): void => {\n\tfor (const type of rest[0].split(\",\")) {\n\t\trest[0] = type;\n\t\telement[`${action}EventListener`](...rest);\n\t}\n};\n\n/**\n * on\n * @param element The Element to use as EventTarget\n * @param types A comma separated string of event types\n * @param listener An event listener function or listener object\n */\nexport const on = (\n\telement: Node | Window,\n\t...rest: Parameters<typeof Element.prototype.addEventListener>\n): void => events(\"add\", element, rest);\n\n/**\n * off\n * @param element The Element to use as EventTarget\n * @param types A comma separated string of event types\n * @param listener An event listener function or listener object\n */\nexport const off = (\n\telement: Node | Window,\n\t...rest: Parameters<typeof Element.prototype.removeEventListener>\n): void => events(\"remove\", element, rest);\n\n\nconst TARGETS = new Map<Element, () => void>(); // Store current open poppers and their update functions\nconst SCROLLER = IS_BROWSER ? document.createElement('div') : null // Used to ensure we have scrollability under\nif (SCROLLER) attr(SCROLLER, 'style', 'position:absolute;padding:1px;top:0;left:0px');\n\nif (IS_BROWSER){\n\ton(window, 'load,resize,scroll', () => {\n\t\tfor (const [_, update] of TARGETS) update();\n\t}, QUICK_EVENT);}\n\t\n/**\n * anchorPosition\n * @param target The Element to position\n * @param anchor The Element to use as anchor\n */\nconst POSITION = { top: 0, right: 1, bottom: 2, left: 3 }; // Speed up by using a const map\n\nexport function anchorPosition (target: HTMLElement, anchor: HTMLElement | null | false, position?: string | number) {\n\tif (!anchor || !anchor.isConnected || !target.isConnected) return TARGETS.delete(target); // Stop watchning if anchor is removed from DOM\n\tif (!SCROLLER?.isConnected) document.body.append(SCROLLER || ''); // Ensure we have t´he scroller\n\tif (!TARGETS.has(target)) { // Setup new target or update position\n\t\tconst place = POSITION[position as keyof typeof POSITION] ?? POSITION.bottom; // Use CSS property to store position for more flexibility\n\t\treturn TARGETS.set(target, () => anchorPosition(target, anchor, place)).get(target)?.(); // Start watching if not already watching\n\t}\n\n const { offsetWidth: targetW, offsetHeight: targetH } = target;\n const { offsetWidth: anchorW, offsetHeight: anchorH } = anchor;\n const { width, height, left, top } = anchor.getBoundingClientRect();\n\tconst anchorX = Math.round(left - (anchorW - width) / 2); // Correct for CSS transform scale\n const anchorY = Math.round(top - (anchorH - height) / 2); // Correct for CSS transform scale\n\n\tconst hasSpaceLeft = anchorX - targetW > 0\n\tconst hasSpaceRight = anchorW + anchorW + targetW < window.innerWidth;\n\tconst hasSpaceOver = anchorY - targetH > 0\n\tconst hasSpaceUnder = anchorY + anchorH + targetH < window.innerHeight;\n\tconst positionRight = (position === POSITION.bottom && hasSpaceRight) || !hasSpaceLeft // Always position right when no hasSpaceLeft, as no OS scrolls further up than 0\n\tconst positionUnder = (position === POSITION.bottom && hasSpaceUnder) || !hasSpaceOver // Always position under when no hasSpaceOver, as no OS scrolls further up than 0\n\tconst centerX = Math.min(Math.max(10, anchorX - (targetW - anchorW) / 2), window.innerWidth - targetW - 10);\n\tconst centerY = Math.min(Math.max(10, anchorY - (targetH - anchorH) / 2), window.innerHeight - targetH - 10);\n\tconst isVertical = position === POSITION.top || position === POSITION.bottom;\n\n\ttarget.style.left = `${Math.round(isVertical ? centerX : (positionRight ? anchorX + anchorW : anchorX - targetW))}px`\n target.style.top = `${Math.round(isVertical ? (positionUnder ? anchorY + anchorH : anchorY - targetH) : centerY)}px`\n SCROLLER?.style.setProperty('translate', `${Math.round(window.scrollX + anchorX + anchorW + targetW + 30)} ${Math.round(window.scrollY + anchorY + anchorH + targetH + 30)}px`);\n}\n\n/**\n * Speed up MutationObserver by debouncing and only running when page is visible\n * @return new MutaionObserver\n */\nexport function createOptimizedMutationObserver(callback: MutationCallback) {\n let queue = 0;\n\n\tconst onFrame = () => setTimeout(onTimer, 200); // Use both requestAnimationFrame and setTimeout to debounce and only run when visible\n\tconst onTimer = () => {\n\t\tcallback([], observer);\n\t\tqueue = 0;\n\t};\n const observer = new MutationObserver(() => {\n if (!queue) queue = requestAnimationFrame(onFrame);\n });\n\n return observer;\n}\n\ntype Mutator = { observer: MutationObserver, collections: Map<string, () => void> };\nconst MUTATORS = new WeakMap<Element, Mutator>();\nconst MUTATORS_CALLBACK = (element: Element) => {\n\tconst mutator = MUTATORS.get(element);\n\n\tif (!mutator || !element.isConnected) {\n\t\tmutator?.observer?.disconnect();\n\t\tMUTATORS.delete(element);\n\t} else for(const [, callback] of mutator.collections) callback();\n};\n\n/**\n * onMutation\n * @description Utility to quickly observe mutations on a specific class name\n * @param element The Element to use as EventTarget\n * @param className The class name to observe\n * @param callback The callback to run when mutations are detected or false to stop observing\n */\nexport const onMutation = (\n\telement: Element,\n\tclassName: string,\n\tcallback: ((collection: HTMLCollection) => void) | false\n) => {\n\tconst collection = element.getElementsByClassName(className);\n\tlet mutator = MUTATORS.get(element);\n\n\tif (!mutator) {\n\t\tmutator = { collections: new Map(), observer: createOptimizedMutationObserver(() => MUTATORS_CALLBACK(element)) };\n\t\tmutator.observer.observe(element, { childList: true, subtree: true, attributes: true, attributeFilter: ['class'] });\n\t\tMUTATORS.set(element, mutator);\n\t}\n\tif (callback) mutator.collections.set(className, () => callback(collection));\n\telse mutator.collections.delete(className);\n}\n\nexport const isInputLike = (el: unknown): el is HTMLInputElement =>\n\tel instanceof HTMLElement && 'validity' in el && !(el instanceof HTMLButtonElement);\n\n// Make React support popover=\"\"target attribute\n// https://github.com/facebook/react/issues/27479\ntype Popover = \"\" | \"auto\" | \"manual\" | undefined;\ndeclare global {\n\tnamespace React.JSX {\n\t\tinterface IntrinsicAttributes {\n\t\t\tpopovertargetaction?: string;\n\t\t\tpopovertarget?: string;\n\t\t\tpopover?: Popover;\n\t\t}\n\t}\n\tnamespace React {\n\t\tinterface HTMLAttributes<T> {\n\t\t\tpopovertargetaction?: string;\n\t\t\tpopovertarget?: string;\n\t\t\tpopover?: Popover;\n\t\t}\n\t}\n}","import { QUICK_EVENT, attr, off, on } from '../utils';\n\nconst handleClick = ({ clientX: x, clientY: y, target: el }: MouseEvent) => {\n if (el instanceof HTMLDialogElement && attr(el, 'data-closedby') === 'any') {\n const { top, right, bottom, left } = el.getBoundingClientRect();\n const isInside = top <= y && y <= bottom && left <= x && x <= right;\n \n if (!isInside) el.close();\n } else if (el instanceof Element && el.closest('button[data-command=\"close\"]')) {\n el?.closest('dialog')?.close();\n }\n};\n\nexport function observe(el: Element) {\n on(el, 'click', handleClick as EventListener, QUICK_EVENT);\n}\n\nexport function unobserve(el: Element) {\n off(el, 'click', handleClick as EventListener, QUICK_EVENT);\n}","import styles from '../styles.module.css';\nimport { QUICK_EVENT, attr, isInputLike, off, on, onMutation, useId } from '../utils';\n\nconst CSS_FIELD = styles.field.split(' ')[0];\nconst CSS_PROPERTY_OVER = '--mtds-text-count-over';\nconst CSS_PROPERTY_UNDER = '--mtds-text-count-under';\nconst CSS_VALIDATIONS = styles.validation.split(' ');\nconst CSS_VALIDATION = CSS_VALIDATIONS[0];\n\nfunction renderAria(fields: HTMLCollectionOf<Element>) {\n for(const field of fields) {\n const labels: HTMLLabelElement[] = [];\n const descs: string[] = [];\n let input: HTMLInputElement | null = null;\n let valid = true;\n\n for (const el of field.getElementsByTagName('*')) {\n if (el instanceof HTMLLabelElement) labels.push(el);\n else if (isInputLike(el)) input = el;\n else if (el.classList.contains(CSS_VALIDATION)) { // Must be before instanceof HTMLParagraphElement since validation can also be a <p>\n valid = el.getAttribute('data-color') === 'success';\n descs.unshift(useId(el));\n } else if (el instanceof HTMLParagraphElement) descs.push(useId(el));\n }\n\n if (input) {\n for (const label of labels) label.htmlFor = useId(input);\n renderCounter(input);\n attr(input, 'aria-describedby', descs.join(' '));\n attr(input, 'aria-invalid', `${!valid}`);\n }\n }\n}\nfunction handleInput({ target }: Event) {\n if (isInputLike(target)) renderCounter(target);\n}\n\nfunction renderCounter(input: HTMLInputElement) {\n const el = input?.nextElementSibling;\n const limit = el?.getAttribute('data-count');\n \n if (el && limit) {\n const remainder = Number(limit) - input.value.length;\n const nextInvalid = remainder < 0;\n const prevInvalid = el.getAttribute('aria-live') === 'polite';\n const style = window.getComputedStyle(el || input);\n const over = style.getPropertyValue(CSS_PROPERTY_OVER)?.slice(1, -1) || ''; // slice to trim quotes\n const under = style.getPropertyValue(CSS_PROPERTY_UNDER)?.slice(1, -1) || ''; // slice to trim quotes\n\n if (prevInvalid !== nextInvalid) {\n attr(el, 'aria-live', nextInvalid ? 'polite' : 'off');\n for (const css of CSS_VALIDATIONS) el.classList.toggle(css, nextInvalid);\n }\n el.textContent = (nextInvalid ? over : under).replace('%d', `${Math.abs(remainder)}`);\n }\n}\n\n// Prevent browsers from showing default validation bubbles\nfunction handleInvalid(event: Event) {\n if ((event.target as Element)?.closest?.(`.${CSS_FIELD}`)) event.preventDefault();\n}\n\nexport function observe (el: Element) {\n onMutation(el, CSS_FIELD, renderAria);\n on(el, 'input', handleInput, QUICK_EVENT);\n on(el, 'invalid', handleInvalid, true); // Use capture as invalid does noe buttle\n}\n\nexport function unobserve (el: Element) {\n onMutation(el, CSS_FIELD, false);\n off(el, 'input', handleInput, QUICK_EVENT);\n off(el, 'invalid', handleInvalid, true);\n}\n","import styles from '../styles.module.css';\nimport { attr, isInputLike, onMutation, useId } from '../utils';\nconst CSS_FIELDSET = styles.fieldset.split(' ')[0];\nconst CSS_VALIDATION = styles.validation.split(' ')[0];\n\nfunction process(fieldsets: HTMLCollectionOf<Element>) {\n for(const fieldset of fieldsets) {\n const inputs: HTMLInputElement[] = [];\n let validationId = '';\n\n for (const el of fieldset.getElementsByTagName('*')) {\n if (el.classList.contains(CSS_VALIDATION)) validationId = useId(el);\n else if (isInputLike(el)) inputs.push(el);\n }\n\n if (validationId) \n for(const input of inputs) {\n attr(input, 'aria-describedby', validationId);\n attr(input, 'aria-invalid', 'true');\n }\n }\n}\n\nexport const observe = (el: Element) => onMutation(el, CSS_FIELDSET, process);\nexport const unobserve = (el: Element) => onMutation(el, CSS_FIELDSET, false);\n","import styles from '../styles.module.css';\nimport { QUICK_EVENT, off, on } from '../utils';\n\nconst CSS_APP = styles.app.split(' ')[0];\nconst CSS_TOGGLE = `.${CSS_APP} > header + :not(main) > button:empty:first-child`;\n\nconst handleToggleClick = ({ target: el }: Event) => {\n const btn = (el as Element)?.nodeName === 'BUTTON' && (el as Element)?.closest(CSS_TOGGLE);\n\n if (!btn) return;\n\n const nav = btn.closest(`.${CSS_APP} > *`);\n const toggle = () =>\n nav?.setAttribute(\n \"data-expanded\",\n `${nav?.getAttribute(\"data-expanded\") === \"false\"}`,\n );\n\n if (!document.startViewTransition) toggle();\n else document.startViewTransition(() => toggle());\n};\n\nexport function observe(el: Element) {\n on(el, 'click', handleToggleClick, QUICK_EVENT);\n}\n\nexport function unobserve(el: Element) {\n off(el, 'click', handleToggleClick, QUICK_EVENT);\n}\n","import styles from '../styles.module.css';\nimport { QUICK_EVENT, anchorPosition, attr, off, on } from '../utils';\n\nexport function observe(el: Node) {\n on(el, 'toggle', handleToggle, QUICK_EVENT); // Use capture since toggle does not bubble\n on(el, 'click', handleLinkClick); // Allow `<a>` to use `popovertarget` as well\n}\nexport function unobserve(el: Node) {\n off(el, 'toggle', handleToggle, QUICK_EVENT); // Use capture since toggle does not bubble\n off(el, 'click', handleLinkClick);\n}\n\nconst CSS_POPOVER = styles.popover.split(' ')[0];\n\nfunction handleToggle ({ target: el, newState }: Event & { newState?: string }){\n if (el instanceof HTMLElement && el.classList.contains(CSS_POPOVER)) {\n const anchor = (el.getRootNode() as ShadowRoot)?.querySelector<HTMLElement>(`[popovertarget=\"${el.id}\"]`);\n \n if (newState === 'closed') anchorPosition(el, false);\n else if (anchor) anchorPosition(el, anchor, el.getAttribute('data-position') || 'bottom');\n }\n}\n\n// Polyfill popovertarget for <a> (not supported by native)\n// and automatically assume popovertarget is the closest parent popover\n// but respect the popovertarget and popovertargetaction attribute\nfunction handleLinkClick ({ target }: Event){\n const link = (target as Element )?.closest?.('a');\n if (link) {\n const root = link.getRootNode() as ShadowRoot;\n const target = root.getElementById?.(attr(link, 'popovertarget') || '') || link.closest(`.${CSS_POPOVER}`);\n const action = attr(link, 'popovertargetaction') || 'toggle';\n\n target?.togglePopover(action === 'show' || (action === 'hide' ? false : undefined));\n }\n}","import styles from '../styles.module.css';\nimport { attr, onMutation } from '../utils';\nconst CSS_TABLE = styles.table.split(' ')[0];\n\nfunction process(tables: HTMLCollectionOf<Element>) {\n for(const table of tables) if (table instanceof HTMLTableElement) {\n const ths = Array.from(table.tHead?.rows[0]?.cells || [], (el) => el.innerText?.trim()); // Using innerText to only include visible text\n for (const tbody of table.tBodies) {\n for (const row of tbody.rows) {\n for (const cell of row.cells) {\n attr(cell, 'data-th', ths[cell.cellIndex] || ':empty');\n }\n }\n }\n }\n}\n\nexport const observe = (el: Element) => onMutation(el, CSS_TABLE, process);\nexport const unobserve = (el: Element) => onMutation(el, CSS_TABLE, false);\n","import styles from '../styles.module.css';\nimport { IS_BROWSER, QUICK_EVENT, anchorPosition, attr, on } from \"../utils\";\n\nconst CSS_TOOLTIP = styles._tooltip.split(' ');\nconst DESCRIBEDBY = 'aria-describedby';\nconst ESC = 'Escape';\nconst LABELLEDBY = 'aria-labelledby';\nconst POSITION_CSS_PROPERTY = '--mtds-tooltip-position';\nconst THROTTLE_DELAY = 100;\nconst TOOLTIP_ID = 'mtds-tooltip';\n\nlet ANCHOR: HTMLElement | null = null;\nlet LAST_CALL = Number.NEGATIVE_INFINITY;\nlet THROTTLE: number | ReturnType<typeof setTimeout> = 0;\nlet TOOLTIP: HTMLElement | null = null;\n\nfunction handleMove({ target, type, key }: Event & { key?: string }) {\n if (type === 'keydown' && key !== ESC) return; // Allow ESC dismiss to follow https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/\n const wait = LAST_CALL + THROTTLE_DELAY - Date.now();\n clearTimeout(THROTTLE);\n THROTTLE = setTimeout(handleMoveThrottled, Math.max(wait, 0), key === ESC ? null : target);\n}\n\n// Using a throttled function to avoid performance issues\nfunction handleMoveThrottled(target: Element | null) {\n LAST_CALL = Date.now();\n\n if (!TOOLTIP || target === TOOLTIP) return; // Allow tooltip to be hovered, following https://www.w3.org/TR/WCAG21/#content-on-hover-or-focus\n let anchor = target?.closest?.<HTMLElement>('[data-tooltip]') || null;\n \n // No need to update\n if (anchor === ANCHOR) return;\n\n const content = anchor?.getAttribute('data-tooltip') || '';\n const position = anchor?.getAttribute('data-tooltip-position') || window.getComputedStyle(anchor || document.body).getPropertyValue(POSITION_CSS_PROPERTY) || 'top';\n const hasLabel = Boolean(anchor?.innerText.trim()) || anchor?.hasAttribute(LABELLEDBY) || anchor?.hasAttribute('aria-label');\n\n if (!content || content === 'false' || content === 'true' || position === 'none') anchor = null; // Do not show tooltip if boolish value\n if (anchor) TOOLTIP.textContent = content; // Only update content if new anchor\n\n ANCHOR?.removeAttribute(ANCHOR.getAttribute(LABELLEDBY) === TOOLTIP_ID ? LABELLEDBY : DESCRIBEDBY); // Unlink previous anchor\n anchorPosition(TOOLTIP, false); // Reset anchor position\n\n ANCHOR = anchor; // Store new anchor - might be null if no new anchor\n ANCHOR?.setAttribute(hasLabel ? DESCRIBEDBY : LABELLEDBY, TOOLTIP_ID); // Use tooltip as description if allready has label\n TOOLTIP.togglePopover(!!anchor);\n anchorPosition(TOOLTIP, anchor, position);\n}\n\n// Initialize if in browser and not already initialized\nif (IS_BROWSER && !document.getElementById(TOOLTIP_ID)) {\n TOOLTIP = document.body.appendChild(document.createElement('div'));\n TOOLTIP.classList.add(...CSS_TOOLTIP);\n TOOLTIP.id = TOOLTIP_ID;\n attr(TOOLTIP, 'popover', 'manual');\n on(document, 'blur,focus,mouseout,mouseover', handleMove, QUICK_EVENT);\n on(window, 'keydown', handleMove, QUICK_EVENT);\n on(window, 'blur', handleMove, QUICK_EVENT);\n}","const getSteps = (now: number, max: number, show: number) => {\n const offset = (show - 1) / 2;\n const start = Math.max(Math.min(now - Math.floor(offset), max - show + 1), 1);\n const end = Math.min(Math.max(now + Math.ceil(offset), show), max);\n const pages = Array.from({ length: end + 1 - start }, (_, i) => i + start);\n\n if (show > 4 && start > 1) pages.splice(0, 2, 1, 0);\n if (show > 3 && end < max) pages.splice(-2, 2, 0, max);\n return pages;\n};\n\nexport const pagination = ({\n current = 1,\n total = 10,\n show = 7,\n}) => ({\n prev: current > 1 ? current - 1 : 0,\n next: current < total ? current + 1 : 0,\n pages: getSteps(current, total, show).map((page, index) => ({\n current: page === current && 'page' as const,\n key: `key-${page}-${index}`,\n page,\n })),\n});\n","import * as dialog from \"./dialog/dialog-observer\";\nimport * as field from \"./field/field-observer\";\nimport * as fieldset from \"./fieldset/fieldset-observer\";\nimport * as layout from \"./layout/layout-observer\";\nimport * as popover from \"./popover/popover-observer\";\nimport * as table from \"./table/table-observer\";\nimport \"./tooltip/tooltip-observer\"; // Load data-tooltip behaviour\nimport { IS_BROWSER } from \"./utils\";\nexport { pagination } from \"./pagination/pagination\";\nexport * as styles from \"./styles.module.css\";\n\n// Automatic observe on browser\nif (IS_BROWSER) {\n const isLoading = document.readyState === \"loading\"; // Check if the page is still loading - might happen if the script is in <head>\n const onLoaded = () => observe(document.body);\n\n if (isLoading) document.addEventListener(\"DOMContentLoaded\", onLoaded);\n else onLoaded();\n}\n\nexport function observe(el: Element) {\n dialog.observe(el);\n field.observe(el);\n fieldset.observe(el);\n layout.observe(el);\n popover.observe(el);\n table.observe(el);\n}\n\nexport function unobserve(el: Element) {\n dialog.unobserve(el);\n field.unobserve(el);\n fieldset.unobserve(el);\n layout.unobserve(el);\n popover.unobserve(el);\n table.unobserve(el);\n}\n"],"names":["IS_BROWSER","QUICK_EVENT","attr","el","name","value","id","UUID","useId","events","action","element","rest","type","on","off","TARGETS","SCROLLER","_","update","POSITION","anchorPosition","target","anchor","position","place","_a","targetW","targetH","anchorW","anchorH","width","height","left","top","anchorX","anchorY","hasSpaceLeft","hasSpaceRight","hasSpaceOver","hasSpaceUnder","positionRight","positionUnder","centerX","centerY","isVertical","createOptimizedMutationObserver","callback","queue","onFrame","onTimer","observer","MUTATORS","MUTATORS_CALLBACK","mutator","onMutation","className","collection","isInputLike","handleClick","x","y","right","bottom","observe","unobserve","CSS_FIELD","styles","CSS_PROPERTY_OVER","CSS_PROPERTY_UNDER","CSS_VALIDATIONS","CSS_VALIDATION","renderAria","fields","field","labels","descs","input","valid","label","renderCounter","handleInput","limit","remainder","nextInvalid","prevInvalid","style","over","under","_b","css","handleInvalid","event","CSS_FIELDSET","process","fieldsets","fieldset","inputs","validationId","CSS_APP","CSS_TOGGLE","handleToggleClick","btn","nav","toggle","handleToggle","handleLinkClick","CSS_POPOVER","newState","link","root","CSS_TABLE","tables","table","ths","tbody","row","cell","CSS_TOOLTIP","DESCRIBEDBY","ESC","LABELLEDBY","POSITION_CSS_PROPERTY","THROTTLE_DELAY","TOOLTIP_ID","ANCHOR","LAST_CALL","THROTTLE","TOOLTIP","handleMove","key","wait","handleMoveThrottled","content","hasLabel","getSteps","now","max","show","offset","start","end","pages","i","pagination","current","total","page","index","isLoading","onLoaded","dialog.observe","field.observe","fieldset.observe","layout.observe","popover.observe","table.observe","dialog.unobserve","field.unobserve","fieldset.unobserve","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GAAiB1J,CAAE,EACnB2J,GAAgB3J,CAAE,EAClB4J,GAAmB5J,CAAE,EACrB6J,GAAiB7J,CAAE,EACnB8J,GAAkB9J,CAAE,EACpB+J,GAAgB/J,CAAE,CACpB"}
package/mtds/index.js CHANGED
@@ -1,10 +1,10 @@
1
- import { observe as r, unobserve as s } from "./dialog/dialog.js";
2
- import { observe as n, unobserve as t } from "./field/field.js";
3
- import { observe as b, unobserve as v } from "./fieldset/fieldset.js";
4
- import { observe as a, unobserve as m } from "./layout/layout.js";
5
- import { observe as i, unobserve as u } from "./popover/popover.js";
6
- import { observe as d, unobserve as f } from "./table/table.js";
7
- import "./tooltip/tooltip.js";
1
+ import { observe as r, unobserve as s } from "./dialog/dialog-observer.js";
2
+ import { observe as n, unobserve as t } from "./field/field-observer.js";
3
+ import { observe as b, unobserve as v } from "./fieldset/fieldset-observer.js";
4
+ import { observe as a, unobserve as m } from "./layout/layout-observer.js";
5
+ import { observe as i, unobserve as u } from "./popover/popover-observer.js";
6
+ import { observe as d, unobserve as f } from "./table/table-observer.js";
7
+ import "./tooltip/tooltip-observer.js";
8
8
  import { IS_BROWSER as p } from "./utils.js";
9
9
  import { pagination as D } from "./pagination/pagination.js";
10
10
  import * as R from "./styles.module.css.js";
package/mtds/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../designsystem/index.ts"],"sourcesContent":["import * as dialog from './dialog/dialog';\nimport * as field from './field/field';\nimport * as fieldset from './fieldset/fieldset';\nimport * as layout from './layout/layout';\nimport * as popover from './popover/popover';\nimport * as table from './table/table';\nimport './tooltip/tooltip'; // Load data-tooltip behaviour\nimport { IS_BROWSER } from './utils';\nexport { pagination } from './pagination/pagination';\nexport * as styles from './styles.module.css';\n\n// Automatic observe on browser\nif (IS_BROWSER) {\n const isLoading = document.readyState === \"loading\"; // Check if the page is still loading - might happen if the script is in <head>\n const onLoaded = () => observe(document.body);\n \n if (isLoading) document.addEventListener(\"DOMContentLoaded\", onLoaded);\n else onLoaded();\n}\n\nexport function observe(el: Element) {\n dialog.observe(el);\n field.observe(el);\n fieldset.observe(el);\n layout.observe(el);\n popover.observe(el);\n table.observe(el);\n}\n\nexport function unobserve(el: Element) {\n dialog.unobserve(el);\n field.unobserve(el);\n fieldset.unobserve(el);\n layout.unobserve(el);\n popover.unobserve(el);\n table.unobserve(el);\n}"],"names":["IS_BROWSER","isLoading","onLoaded","observe","el","dialog.observe","field.observe","fieldset.observe","layout.observe","popover.observe","table.observe","unobserve","dialog.unobserve","field.unobserve","fieldset.unobserve","layout.unobserve","popover.unobserve","table.unobserve"],"mappings":";;;;;;;;;;AAYA,IAAIA,GAAY;AACR,QAAAC,IAAY,SAAS,eAAe,WACpCC,IAAW,MAAMC,EAAQ,SAAS,IAAI;AAE5C,EAAIF,IAAW,SAAS,iBAAiB,oBAAoBC,CAAQ,IACvDA,EAAA;AAChB;AAEO,SAASC,EAAQC,GAAa;AACnCC,EAAAA,EAAeD,CAAE,GACjBE,EAAcF,CAAE,GAChBG,EAAiBH,CAAE,GACnBI,EAAeJ,CAAE,GACjBK,EAAgBL,CAAE,GAClBM,EAAcN,CAAE;AAClB;AAEO,SAASO,EAAUP,GAAa;AACrCQ,EAAAA,EAAiBR,CAAE,GACnBS,EAAgBT,CAAE,GAClBU,EAAmBV,CAAE,GACrBW,EAAiBX,CAAE,GACnBY,EAAkBZ,CAAE,GACpBa,EAAgBb,CAAE;AACpB;"}
1
+ {"version":3,"file":"index.js","sources":["../designsystem/index.ts"],"sourcesContent":["import * as dialog from \"./dialog/dialog-observer\";\nimport * as field from \"./field/field-observer\";\nimport * as fieldset from \"./fieldset/fieldset-observer\";\nimport * as layout from \"./layout/layout-observer\";\nimport * as popover from \"./popover/popover-observer\";\nimport * as table from \"./table/table-observer\";\nimport \"./tooltip/tooltip-observer\"; // Load data-tooltip behaviour\nimport { IS_BROWSER } from \"./utils\";\nexport { pagination } from \"./pagination/pagination\";\nexport * as styles from \"./styles.module.css\";\n\n// Automatic observe on browser\nif (IS_BROWSER) {\n const isLoading = document.readyState === \"loading\"; // Check if the page is still loading - might happen if the script is in <head>\n const onLoaded = () => observe(document.body);\n\n if (isLoading) document.addEventListener(\"DOMContentLoaded\", onLoaded);\n else onLoaded();\n}\n\nexport function observe(el: Element) {\n dialog.observe(el);\n field.observe(el);\n fieldset.observe(el);\n layout.observe(el);\n popover.observe(el);\n table.observe(el);\n}\n\nexport function unobserve(el: Element) {\n dialog.unobserve(el);\n field.unobserve(el);\n fieldset.unobserve(el);\n layout.unobserve(el);\n popover.unobserve(el);\n table.unobserve(el);\n}\n"],"names":["IS_BROWSER","isLoading","onLoaded","observe","el","dialog.observe","field.observe","fieldset.observe","layout.observe","popover.observe","table.observe","unobserve","dialog.unobserve","field.unobserve","fieldset.unobserve","layout.unobserve","popover.unobserve","table.unobserve"],"mappings":";;;;;;;;;;AAYA,IAAIA,GAAY;AACR,QAAAC,IAAY,SAAS,eAAe,WACpCC,IAAW,MAAMC,EAAQ,SAAS,IAAI;AAE5C,EAAIF,IAAW,SAAS,iBAAiB,oBAAoBC,CAAQ,IACvDA,EAAA;AAChB;AAEO,SAASC,EAAQC,GAAa;AACnCC,EAAAA,EAAeD,CAAE,GACjBE,EAAcF,CAAE,GAChBG,EAAiBH,CAAE,GACnBI,EAAeJ,CAAE,GACjBK,EAAgBL,CAAE,GAClBM,EAAcN,CAAE;AAClB;AAEO,SAASO,EAAUP,GAAa;AACrCQ,EAAAA,EAAiBR,CAAE,GACnBS,EAAgBT,CAAE,GAClBU,EAAmBV,CAAE,GACrBW,EAAiBX,CAAE,GACnBY,EAAkBZ,CAAE,GACpBa,EAAgBb,CAAE;AACpB;"}
@@ -0,0 +1,2 @@
1
+ export declare function observe(el: Element): void;
2
+ export declare function unobserve(el: Element): void;
@@ -19,4 +19,4 @@ export {
19
19
  u as observe,
20
20
  T as unobserve
21
21
  };
22
- //# sourceMappingURL=layout.js.map
22
+ //# sourceMappingURL=layout-observer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout-observer.js","sources":["../../designsystem/layout/layout-observer.ts"],"sourcesContent":["import styles from '../styles.module.css';\nimport { QUICK_EVENT, off, on } from '../utils';\n\nconst CSS_APP = styles.app.split(' ')[0];\nconst CSS_TOGGLE = `.${CSS_APP} > header + :not(main) > button:empty:first-child`;\n\nconst handleToggleClick = ({ target: el }: Event) => {\n const btn = (el as Element)?.nodeName === 'BUTTON' && (el as Element)?.closest(CSS_TOGGLE);\n\n if (!btn) return;\n\n const nav = btn.closest(`.${CSS_APP} > *`);\n const toggle = () =>\n nav?.setAttribute(\n \"data-expanded\",\n `${nav?.getAttribute(\"data-expanded\") === \"false\"}`,\n );\n\n if (!document.startViewTransition) toggle();\n else document.startViewTransition(() => toggle());\n};\n\nexport function observe(el: Element) {\n on(el, 'click', handleToggleClick, QUICK_EVENT);\n}\n\nexport function unobserve(el: Element) {\n off(el, 'click', handleToggleClick, QUICK_EVENT);\n}\n"],"names":["CSS_APP","styles","CSS_TOGGLE","handleToggleClick","el","btn","nav","toggle","observe","on","QUICK_EVENT","unobserve","off"],"mappings":";;AAGA,MAAMA,IAAUC,EAAO,IAAI,MAAM,GAAG,EAAE,CAAC,GACjCC,IAAa,IAAIF,CAAO,qDAExBG,IAAoB,CAAC,EAAE,QAAQC,QAAgB;AACnD,QAAMC,KAAOD,KAAA,gBAAAA,EAAgB,cAAa,aAAaA,KAAA,gBAAAA,EAAgB,QAAQF;AAE/E,MAAI,CAACG,EAAK;AAEV,QAAMC,IAAMD,EAAI,QAAQ,IAAIL,CAAO,MAAM,GACnCO,IAAS,MACbD,KAAA,gBAAAA,EAAK;AAAA,IACH;AAAA,IACA,IAAGA,KAAA,gBAAAA,EAAK,aAAa,sBAAqB,OAAO;AAAA;AAGjD,EAAC,SAAS,sBACA,SAAA,oBAAoB,MAAMC,GAAQ,IADNA,EAAA;AAE5C;AAEO,SAASC,EAAQJ,GAAa;AAChC,EAAAK,EAAAL,GAAI,SAASD,GAAmBO,CAAW;AAChD;AAEO,SAASC,EAAUP,GAAa;AACjC,EAAAQ,EAAAR,GAAI,SAASD,GAAmBO,CAAW;AACjD;"}
@@ -0,0 +1,5 @@
1
+ import { PolymorphicComponentPropWithRef } from '../react-types';
2
+ export type LinkProps<As extends React.ElementType = "a"> = PolymorphicComponentPropWithRef<As>;
3
+ type LinkComponent = <As extends React.ElementType = "a">(props: LinkProps<As>) => React.ReactElement | null;
4
+ export declare const Link: LinkComponent;
5
+ export {};
@@ -26,4 +26,4 @@ export {
26
26
  k as observe,
27
27
  E as unobserve
28
28
  };
29
- //# sourceMappingURL=popover.js.map
29
+ //# sourceMappingURL=popover-observer.js.map