@mattilsynet/design 0.5.4 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/mtds/button/button.d.ts +1 -0
  2. package/mtds/button/button.js.map +1 -1
  3. package/mtds/button/button.stories.d.ts +1 -0
  4. package/mtds/card/card.stories.d.ts +3 -2
  5. package/mtds/external/@u-elements/u-datalist/dist/u-datalist.js +250 -0
  6. package/mtds/external/@u-elements/u-datalist/dist/u-datalist.js.map +1 -0
  7. package/mtds/external/@u-elements/u-tags/dist/u-tags.js +367 -0
  8. package/mtds/external/@u-elements/u-tags/dist/u-tags.js.map +1 -0
  9. package/mtds/field/field-observer.js +42 -34
  10. package/mtds/field/field-observer.js.map +1 -1
  11. package/mtds/field/field.stories.d.ts +2 -0
  12. package/mtds/helptext/helptext-observer.d.ts +1 -0
  13. package/mtds/helptext/helptext.d.ts +2 -0
  14. package/mtds/{togglegroup/togglegroup.stories.d.ts → helptext/helptext.story.d.ts} +3 -0
  15. package/mtds/index.d.ts +7 -4
  16. package/mtds/index.iife.js +5 -2
  17. package/mtds/index.iife.js.map +1 -1
  18. package/mtds/index.js.map +1 -1
  19. package/mtds/input/input.stories.d.ts +1 -0
  20. package/mtds/layout/layout-observer.js +21 -13
  21. package/mtds/layout/layout-observer.js.map +1 -1
  22. package/mtds/layout/layout.d.ts +4 -3
  23. package/mtds/layout/layout.js.map +1 -1
  24. package/mtds/logo/logo-observer.js +16 -16
  25. package/mtds/logo/logo-observer.js.map +1 -1
  26. package/mtds/logo/logo.d.ts +2 -1
  27. package/mtds/logo/logo.js.map +1 -1
  28. package/mtds/logo/logo.stories.d.ts +6 -3
  29. package/mtds/popover/popover.js +3 -3
  30. package/mtds/popover/popover.js.map +1 -1
  31. package/mtds/popover/popover.stories.d.ts +1 -0
  32. package/mtds/react.d.ts +1 -1
  33. package/mtds/react.js +1 -1
  34. package/mtds/styles.css +1 -1
  35. package/mtds/styles.json +34 -33
  36. package/mtds/styles.module.css.js +68 -66
  37. package/mtds/styles.module.css.js.map +1 -1
  38. package/mtds/{heading/heading.js → typography/typography.js} +1 -1
  39. package/mtds/typography/typography.js.map +1 -0
  40. package/mtds/{heading/heading.stories.d.ts → typography/typography.stories.d.ts} +2 -1
  41. package/mtds/utils.d.ts +2 -2
  42. package/mtds/utils.js.map +1 -1
  43. package/mtds/validation/validation.stories.d.ts +1 -0
  44. package/package.json +17 -17
  45. package/mtds/heading/heading.js.map +0 -1
  46. /package/mtds/{heading/heading.d.ts → typography/typography.d.ts} +0 -0
package/mtds/styles.json CHANGED
@@ -1,35 +1,36 @@
1
1
  {
2
- "alert": "_alert_1p6jx_1 _ds-alert_194o1_1",
3
- "avatar": "_avatar_1p6jx_1 _ds-avatar_194o1_1",
4
- "badge": "_badge_1p6jx_1",
5
- "breadcrumbs": "_breadcrumbs_1p6jx_1 _ds-breadcrumbs_194o1_1",
6
- "button": "_button_1p6jx_1 _ds-button_194o1_1",
7
- "card": "_card_1p6jx_1",
8
- "group": "_group_1p6jx_1",
9
- "chip": "_chip_1p6jx_1 _ds-chip_194o1_1",
10
- "details": "_details_1p6jx_1 _ds-details_194o1_1",
11
- "dialog": "_dialog_1p6jx_1 _ds-dialog_194o1_1",
12
- "divider": "_divider_1p6jx_1",
13
- "errorsummary": "_errorsummary_1p6jx_1 _ds-error-summary_194o1_1",
14
- "field": "_field_1p6jx_1 _ds-field_194o1_1",
15
- "affixes": "_affixes_1p6jx_1 _ds-field-affixes_194o1_1",
16
- "count": "_count_1p6jx_1",
17
- "fieldset": "_fieldset_1p6jx_1 _ds-fieldset_194o1_1",
18
- "heading": "_heading_1p6jx_1 _ds-heading_194o1_1",
19
- "typostack": "_typostack_1p6jx_1",
20
- "input": "_input_1p6jx_1 _ds-input_194o1_1",
21
- "grid": "_grid_1p6jx_1",
22
- "flex": "_flex_1p6jx_1",
23
- "app": "_app_1p6jx_1",
24
- "link": "_link_1p6jx_1",
25
- "logo": "_logo_1p6jx_1",
26
- "pagination": "_pagination_1p6jx_1 _ds-pagination_194o1_1",
27
- "popover": "_popover_1p6jx_1",
28
- "skeleton": "_skeleton_1p6jx_1 _ds-skeleton_194o1_1",
29
- "spinner": "_spinner_1p6jx_1",
30
- "table": "_table_1p6jx_1 _ds-table_194o1_1",
31
- "tabs": "_tabs_1p6jx_1 _ds-tabs_194o1_1",
32
- "tag": "_tag_1p6jx_1 _ds-tag_194o1_1",
33
- "validation": "_validation_1p6jx_1 _ds-validation-message_194o1_1",
34
- "body": "_body_1p6jx_141"
2
+ "alert": "_alert_1u2zm_1 _ds-alert_z5gp5_1",
3
+ "avatar": "_avatar_1u2zm_1 _ds-avatar_z5gp5_1",
4
+ "badge": "_badge_1u2zm_1",
5
+ "breadcrumbs": "_breadcrumbs_1u2zm_1 _ds-breadcrumbs_z5gp5_1",
6
+ "button": "_button_1u2zm_1 _ds-button_z5gp5_1",
7
+ "card": "_card_1u2zm_1",
8
+ "info": "_info_1u2zm_1",
9
+ "group": "_group_1u2zm_1",
10
+ "chip": "_chip_1u2zm_1 _ds-chip_z5gp5_1",
11
+ "details": "_details_1u2zm_1 _ds-details_z5gp5_1",
12
+ "dialog": "_dialog_1u2zm_1 _ds-dialog_z5gp5_1",
13
+ "divider": "_divider_1u2zm_1",
14
+ "errorsummary": "_errorsummary_1u2zm_1 _ds-error-summary_z5gp5_1",
15
+ "field": "_field_1u2zm_1 _ds-field_z5gp5_1",
16
+ "affixes": "_affixes_1u2zm_1 _ds-field-affixes_z5gp5_1",
17
+ "fieldset": "_fieldset_1u2zm_1 _ds-fieldset_z5gp5_1",
18
+ "helptext": "_helptext_1u2zm_1 _ds-focus_z5gp5_1",
19
+ "input": "_input_1u2zm_1 _ds-input_z5gp5_1",
20
+ "app": "_app_1u2zm_1",
21
+ "grid": "_grid_1u2zm_1",
22
+ "flex": "_flex_1u2zm_1",
23
+ "link": "_link_1u2zm_1",
24
+ "logo": "_logo_1u2zm_1",
25
+ "pagination": "_pagination_1u2zm_1 _ds-pagination_z5gp5_1",
26
+ "popover": "_popover_1u2zm_1",
27
+ "skeleton": "_skeleton_1u2zm_1 _ds-skeleton_z5gp5_1",
28
+ "spinner": "_spinner_1u2zm_1",
29
+ "table": "_table_1u2zm_1 _ds-table_z5gp5_1",
30
+ "tabs": "_tabs_1u2zm_1 _ds-tabs_z5gp5_1",
31
+ "tag": "_tag_1u2zm_1 _ds-tag_z5gp5_1",
32
+ "heading": "_heading_1u2zm_1 _ds-heading_z5gp5_1",
33
+ "prose": "_prose_1u2zm_1",
34
+ "validation": "_validation_1u2zm_1 _ds-validation-message_z5gp5_1",
35
+ "body": "_body_1u2zm_106"
35
36
  }
@@ -1,76 +1,78 @@
1
- const _ = "_alert_1p6jx_1 _ds-alert_194o1_1", o = "_avatar_1p6jx_1 _ds-avatar_194o1_1", t = "_badge_1p6jx_1", s = "_breadcrumbs_1p6jx_1 _ds-breadcrumbs_194o1_1", a = "_button_1p6jx_1 _ds-button_194o1_1", n = "_card_1p6jx_1", p = "_group_1p6jx_1", d = "_chip_1p6jx_1 _ds-chip_194o1_1", e = "_details_1p6jx_1 _ds-details_194o1_1", i = "_dialog_1p6jx_1 _ds-dialog_194o1_1", c = "_divider_1p6jx_1", r = "_errorsummary_1p6jx_1 _ds-error-summary_194o1_1", l = "_field_1p6jx_1 _ds-field_194o1_1", x = "_affixes_1p6jx_1 _ds-field-affixes_194o1_1", j = "_count_1p6jx_1", g = "_fieldset_1p6jx_1 _ds-fieldset_194o1_1", b = "_heading_1p6jx_1 _ds-heading_194o1_1", u = "_typostack_1p6jx_1", f = "_input_1p6jx_1 _ds-input_194o1_1", v = "_grid_1p6jx_1", m = "_flex_1p6jx_1", h = "_app_1p6jx_1", y = "_link_1p6jx_1", k = "_logo_1p6jx_1", w = "_pagination_1p6jx_1 _ds-pagination_194o1_1", S = "_popover_1p6jx_1", q = "_skeleton_1p6jx_1 _ds-skeleton_194o1_1", z = "_spinner_1p6jx_1", A = "_table_1p6jx_1 _ds-table_194o1_1", B = "__scrollShadow_1p6jx_1", C = "_tabs_1p6jx_1 _ds-tabs_194o1_1", D = "_tag_1p6jx_1 _ds-tag_194o1_1", E = "__tooltip_1p6jx_1", F = "_validation_1p6jx_1 _ds-validation-message_194o1_1", G = "_body_1p6jx_141", H = {
1
+ const _ = "_alert_1u2zm_1 _ds-alert_z5gp5_1", t = "_avatar_1u2zm_1 _ds-avatar_z5gp5_1", s = "_badge_1u2zm_1", o = "_breadcrumbs_1u2zm_1 _ds-breadcrumbs_z5gp5_1", a = "_button_1u2zm_1 _ds-button_z5gp5_1", e = "_card_1u2zm_1", n = "_info_1u2zm_1", d = "_group_1u2zm_1", i = "_chip_1u2zm_1 _ds-chip_z5gp5_1", p = "_details_1u2zm_1 _ds-details_z5gp5_1", r = "_dialog_1u2zm_1 _ds-dialog_z5gp5_1", u = "_divider_1u2zm_1", l = "_errorsummary_1u2zm_1 _ds-error-summary_z5gp5_1", z = "_field_1u2zm_1 _ds-field_z5gp5_1", c = "_affixes_1u2zm_1 _ds-field-affixes_z5gp5_1", g = "_fieldset_1u2zm_1 _ds-fieldset_z5gp5_1", m = "_helptext_1u2zm_1 _ds-focus_z5gp5_1", b = "_input_1u2zm_1 _ds-input_z5gp5_1", f = "_app_1u2zm_1", h = "_grid_1u2zm_1", v = "_flex_1u2zm_1", x = "_link_1u2zm_1", y = "_logo_1u2zm_1", k = "_pagination_1u2zm_1 _ds-pagination_z5gp5_1", w = "_popover_1u2zm_1", S = "_skeleton_1u2zm_1 _ds-skeleton_z5gp5_1", j = "_spinner_1u2zm_1", q = "_table_1u2zm_1 _ds-table_z5gp5_1", A = "__scrollShadow_1u2zm_1", B = "_tabs_1u2zm_1 _ds-tabs_z5gp5_1", C = "_tag_1u2zm_1 _ds-tag_z5gp5_1", D = "__tooltip_1u2zm_1", E = "_heading_1u2zm_1 _ds-heading_z5gp5_1", F = "_prose_1u2zm_1", G = "_validation_1u2zm_1 _ds-validation-message_z5gp5_1", H = "_body_1u2zm_106", I = {
2
2
  alert: _,
3
- avatar: o,
4
- badge: t,
5
- breadcrumbs: s,
3
+ avatar: t,
4
+ badge: s,
5
+ breadcrumbs: o,
6
6
  button: a,
7
- card: n,
8
- group: p,
9
- chip: d,
10
- details: e,
11
- dialog: i,
12
- divider: c,
13
- errorsummary: r,
14
- field: l,
15
- affixes: x,
16
- count: j,
7
+ card: e,
8
+ info: n,
9
+ group: d,
10
+ chip: i,
11
+ details: p,
12
+ dialog: r,
13
+ divider: u,
14
+ errorsummary: l,
15
+ field: z,
16
+ affixes: c,
17
17
  fieldset: g,
18
- heading: b,
19
- typostack: u,
20
- input: f,
21
- grid: v,
22
- flex: m,
23
- app: h,
24
- link: y,
25
- logo: k,
26
- pagination: w,
27
- popover: S,
28
- skeleton: q,
29
- spinner: z,
30
- table: A,
31
- _scrollShadow: B,
32
- tabs: C,
33
- tag: D,
34
- _tooltip: E,
35
- validation: F,
36
- body: G
18
+ helptext: m,
19
+ input: b,
20
+ app: f,
21
+ grid: h,
22
+ flex: v,
23
+ link: x,
24
+ logo: y,
25
+ pagination: k,
26
+ popover: w,
27
+ skeleton: S,
28
+ spinner: j,
29
+ table: q,
30
+ _scrollShadow: A,
31
+ tabs: B,
32
+ tag: C,
33
+ _tooltip: D,
34
+ heading: E,
35
+ prose: F,
36
+ validation: G,
37
+ body: H
37
38
  };
38
39
  export {
39
- B as _scrollShadow,
40
- E as _tooltip,
41
- x as affixes,
40
+ A as _scrollShadow,
41
+ D as _tooltip,
42
+ c as affixes,
42
43
  _ as alert,
43
- h as app,
44
- o as avatar,
45
- t as badge,
46
- G as body,
47
- s as breadcrumbs,
44
+ f as app,
45
+ t as avatar,
46
+ s as badge,
47
+ H as body,
48
+ o as breadcrumbs,
48
49
  a as button,
49
- n as card,
50
- d as chip,
51
- j as count,
52
- H as default,
53
- e as details,
54
- i as dialog,
55
- c as divider,
56
- r as errorsummary,
57
- l as field,
50
+ e as card,
51
+ i as chip,
52
+ I as default,
53
+ p as details,
54
+ r as dialog,
55
+ u as divider,
56
+ l as errorsummary,
57
+ z as field,
58
58
  g as fieldset,
59
- m as flex,
60
- v as grid,
61
- p as group,
62
- b as heading,
63
- f as input,
64
- y as link,
65
- k as logo,
66
- w as pagination,
67
- S as popover,
68
- q as skeleton,
69
- z as spinner,
70
- A as table,
71
- C as tabs,
72
- D as tag,
73
- u as typostack,
74
- F as validation
59
+ v as flex,
60
+ h as grid,
61
+ d as group,
62
+ E as heading,
63
+ m as helptext,
64
+ n as info,
65
+ b as input,
66
+ x as link,
67
+ y as logo,
68
+ k as pagination,
69
+ w as popover,
70
+ F as prose,
71
+ S as skeleton,
72
+ j as spinner,
73
+ q as table,
74
+ B as tabs,
75
+ C as tag,
76
+ G as validation
75
77
  };
76
78
  //# sourceMappingURL=styles.module.css.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"styles.module.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"styles.module.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -8,4 +8,4 @@ const l = i(function({ as: o, className: r, ...t }, m) {
8
8
  export {
9
9
  l as Heading
10
10
  };
11
- //# sourceMappingURL=heading.js.map
11
+ //# sourceMappingURL=typography.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typography.js","sources":["../../designsystem/typography/typography.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { type JSX, forwardRef } from \"react\";\nimport type {\n\tPolymorphicComponentPropWithRef,\n\tPolymorphicRef,\n} from \"../react-types\";\nimport styles from \"../styles.module.css\";\n\nexport type HeadingProps<As extends React.ElementType = \"h2\"> =\n\tPolymorphicComponentPropWithRef<\n\t\tAs,\n\t\t{\n\t\t\t\"data-size\"?: \"2xs\" | \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\";\n\t\t}\n\t>;\n\ntype HeadingComponent = <As extends React.ElementType = \"h2\">(\n\tprops: HeadingProps<As>,\n) => JSX.Element;\n\nexport const Heading: HeadingComponent = forwardRef<null>(function Heading<\n\tAs extends React.ElementType = \"h2\",\n>({ as, className, ...rest }: HeadingProps<As>, ref?: PolymorphicRef<As>) {\n\tconst Tag = as || \"h2\";\n\n\treturn (\n\t\t<Tag className={clsx(styles.heading, className)} ref={ref} {...rest} />\n\t);\n}) as HeadingComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n"],"names":["Heading","forwardRef","as","className","rest","ref","jsx","clsx","styles"],"mappings":";;;;AAoBa,MAAAA,IAA4BC,EAAiB,SAExD,EAAE,IAAAC,GAAI,WAAAC,GAAW,GAAGC,EAAK,GAAqBC,GAA0B;AAIxE,SAAA,gBAAAC,EAHWJ,KAAM,MAGZ,EAAA,WAAWK,EAAKC,EAAO,SAASL,CAAS,GAAG,KAAAE,GAAW,GAAGD,EAAM,CAAA;AAEvE,CAAC;"}
@@ -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 Sizes: Story;
11
12
  export declare const React: Story;
12
13
  export declare const Center: Story;
13
- export declare const Stack: Story;
14
+ export declare const Prose: Story;
package/mtds/utils.d.ts CHANGED
@@ -18,14 +18,14 @@ export declare function useId(el: Element): string;
18
18
  * @param types A comma separated string of event types
19
19
  * @param listener An event listener function or listener object
20
20
  */
21
- export declare const on: (element: Node | Window, type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions | undefined) => void;
21
+ export declare const on: (element: Node | Window, ...rest: Parameters<typeof Element.prototype.addEventListener>) => void;
22
22
  /**
23
23
  * off
24
24
  * @param element The Element to use as EventTarget
25
25
  * @param types A comma separated string of event types
26
26
  * @param listener An event listener function or listener object
27
27
  */
28
- export declare const off: (element: Node | Window, type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions | undefined) => void;
28
+ export declare const off: (element: Node | Window, ...rest: Parameters<typeof Element.prototype.removeEventListener>) => void;
29
29
  export declare function anchorPosition(target: HTMLElement, anchor: HTMLElement | null | false, position?: string | number): boolean | void;
30
30
  /**
31
31
  * Speed up MutationObserver by debouncing and only running when page is visible
package/mtds/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../designsystem/utils.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}"],"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","_a","place","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"],"mappings":"AAAO,MAAMA,IAAa,OAAO,SAAW,OAAe,OAAO,WAAa,KAClEC,IAAc,EAAE,SAAS,IAAM,SAAS,GAAK;AAS1C,SAAAC,EACfC,GACAC,GACAC,GACgB;AAChB,SAAIA,MAAU,SAAkBF,EAAG,aAAaC,CAAI,KAAK,QACrDC,MAAU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,CAACvD,MAC3BA,aAAc,eAAe,cAAcA,KAAM,EAAEA,aAAc;"}
1
+ {"version":3,"file":"utils.js","sources":["../designsystem/utils.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 attributes\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}"],"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","_a","place","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"],"mappings":"AAAO,MAAMA,IAAa,OAAO,SAAW,OAAe,OAAO,WAAa,KAClEC,IAAc,EAAE,SAAS,IAAM,SAAS,GAAK;AAS1C,SAAAC,EACfC,GACAC,GACAC,GACgB;AAChB,SAAIA,MAAU,SAAkBF,EAAG,aAAaC,CAAI,KAAK,QACrDC,MAAU,OAASF,EAAA,gBAAgBC,CAAI,IAClCD,EAAG,aAAaC,CAAI,MAAMC,KAAUF,EAAA,aAAaC,GAAMC,CAAK,GAC9D;AACR;AAMA,IAAIC,IAAK;AACT,MAAMC,IAAO,GAAG,KA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CC,GAA4B;AAC1E,MAAIC,IAAQ;AAEb,QAAMC,IAAU,MAAM,WAAWC,GAAS,GAAG,GACvCA,IAAU,MAAM;AACZ,IAAAH,EAAA,IAAII,CAAQ,GACbH,IAAA;AAAA,EACT,GACOG,IAAW,IAAI,iBAAiB,MAAM;AAC1C,IAAKH,MAAeA,IAAA,sBAAsBC,CAAO;AAAA,EAAA,CAClD;AAEM,SAAAE;AACT;AAGA,MAAMC,wBAAe,QAA0B,GACzCC,IAAoB,CAAC1C,MAAqB;AArIzC,MAAAc;AAsIA,QAAA6B,IAAUF,EAAS,IAAIzC,CAAO;AAEpC,MAAI,CAAC2C,KAAW,CAAC3C,EAAQ;AACxB,KAAAc,IAAA6B,KAAA,gBAAAA,EAAS,aAAT,QAAA7B,EAAmB,cACnB2B,EAAS,OAAOzC,CAAO;AAAA,kBACP,CAAA,EAAGoC,CAAQ,KAAKO,EAAQ,YAAsB,CAAAP,EAAA;AAChE,GASaQ,IAAa,CACzB5C,GACA6C,GACAT,MACI;AACE,QAAAU,IAAa9C,EAAQ,uBAAuB6C,CAAS;AACvD,MAAAF,IAAUF,EAAS,IAAIzC,CAAO;AAElC,EAAK2C,MACMA,IAAA,EAAE,aAAa,oBAAI,IAAI,GAAG,UAAUR,EAAgC,MAAMO,EAAkB1C,CAAO,CAAC,EAAE,GAChH2C,EAAQ,SAAS,QAAQ3C,GAAS,EAAE,WAAW,IAAM,SAAS,IAAM,YAAY,IAAM,iBAAiB,CAAC,OAAO,GAAG,GACzGyC,EAAA,IAAIzC,GAAS2C,CAAO,IAE1BP,MAAkB,YAAY,IAAIS,GAAW,MAAMT,EAASU,CAAU,CAAC,IACtEH,EAAQ,YAAY,OAAOE,CAAS;AAC1C,GAEaE,IAAc,CAACvD,MAC3BA,aAAc,eAAe,cAAcA,KAAM,EAAEA,aAAc;"}
@@ -6,3 +6,4 @@ export default meta;
6
6
  type Story = StoryObj<typeof meta>;
7
7
  export declare const Default: Story;
8
8
  export declare const React: Story;
9
+ export declare const Colors: Story;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mattilsynet/design",
3
- "version": "0.5.4",
3
+ "version": "1.0.1",
4
4
  "type": "module",
5
5
  "main": "./mtds/index.js",
6
6
  "types": "./mtds/index.d.ts",
@@ -38,19 +38,18 @@
38
38
  },
39
39
  "devDependencies": {
40
40
  "@biomejs/biome": "^1.9.4",
41
- "@digdir/designsystemet-css": "^1.0.0-next.49",
42
- "@digdir/designsystemet-theme": "^1.0.0-next.49",
41
+ "@digdir/designsystemet-css": "^1.0.2",
43
42
  "@phosphor-icons/react": "^2.1.7",
44
- "@storybook/addon-essentials": "^8.6.0",
45
- "@storybook/addon-mdx-gfm": "^8.6.0",
46
- "@storybook/addon-storysource": "^8.6.0",
47
- "@storybook/blocks": "^8.6.0",
48
- "@storybook/manager-api": "^8.6.0",
49
- "@storybook/react": "^8.6.0",
50
- "@storybook/react-vite": "^8.6.0",
51
- "@storybook/theming": "^8.6.0",
43
+ "@storybook/addon-essentials": "^8.6.4",
44
+ "@storybook/addon-mdx-gfm": "^8.6.4",
45
+ "@storybook/addon-storysource": "^8.6.4",
46
+ "@storybook/blocks": "^8.6.4",
47
+ "@storybook/manager-api": "^8.6.4",
48
+ "@storybook/react": "^8.6.4",
49
+ "@storybook/react-vite": "^8.6.4",
50
+ "@storybook/theming": "^8.6.4",
52
51
  "@tanstack/react-table": "^8.21.2",
53
- "@types/node": "^22.13.5",
52
+ "@types/node": "^22.13.10",
54
53
  "@types/react": "^19.0.10",
55
54
  "@types/react-dom": "^19.0.4",
56
55
  "@vitejs/plugin-react": "^4.3.4",
@@ -59,15 +58,16 @@
59
58
  "postcss-nesting": "^13.0.1",
60
59
  "react": "^19.0.0",
61
60
  "react-dom": "^19.0.0",
62
- "storybook": "^8.6.0",
63
- "typescript": "^5.7.3",
64
- "vite": "^6.2.0",
65
- "vite-plugin-dts": "^4.5.0"
61
+ "storybook": "^8.6.4",
62
+ "typescript": "^5.8.2",
63
+ "vite": "^6.2.1",
64
+ "vite-plugin-dts": "^4.5.3"
66
65
  },
67
66
  "dependencies": {
68
- "@u-elements/u-datalist": "0.1.3",
67
+ "@u-elements/u-datalist": "^0.1.3",
69
68
  "@u-elements/u-details": "^0.1.0",
70
69
  "@u-elements/u-tabs": "^0.0.8",
70
+ "@u-elements/u-tags": "^0.1.3",
71
71
  "clsx": "^2.1.1"
72
72
  }
73
73
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"heading.js","sources":["../../designsystem/heading/heading.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { type JSX, forwardRef } from \"react\";\nimport type {\n\tPolymorphicComponentPropWithRef,\n\tPolymorphicRef,\n} from \"../react-types\";\nimport styles from \"../styles.module.css\";\n\nexport type HeadingProps<As extends React.ElementType = \"h2\"> =\n\tPolymorphicComponentPropWithRef<\n\t\tAs,\n\t\t{\n\t\t\t\"data-size\"?: \"2xs\" | \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\";\n\t\t}\n\t>;\n\ntype HeadingComponent = <As extends React.ElementType = \"h2\">(\n\tprops: HeadingProps<As>,\n) => JSX.Element;\n\nexport const Heading: HeadingComponent = forwardRef<null>(function Heading<\n\tAs extends React.ElementType = \"h2\",\n>({ as, className, ...rest }: HeadingProps<As>, ref?: PolymorphicRef<As>) {\n\tconst Tag = as || \"h2\";\n\n\treturn (\n\t\t<Tag className={clsx(styles.heading, className)} ref={ref} {...rest} />\n\t);\n}) as HeadingComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n"],"names":["Heading","forwardRef","as","className","rest","ref","jsx","clsx","styles"],"mappings":";;;;AAoBa,MAAAA,IAA4BC,EAAiB,SAExD,EAAE,IAAAC,GAAI,WAAAC,GAAW,GAAGC,EAAK,GAAqBC,GAA0B;AAIxE,SAAA,gBAAAC,EAHWJ,KAAM,MAGZ,EAAA,WAAWK,EAAKC,EAAO,SAASL,CAAS,GAAG,KAAAE,GAAW,GAAGD,EAAM,CAAA;AAEvE,CAAC;"}