@mattilsynet/design 2.2.24 → 2.2.26
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.
- package/mtds/alert/alert.js +9 -8
- package/mtds/alert/alert.js.map +1 -1
- package/mtds/analytics/analytics.d.ts +1 -1
- package/mtds/analytics/analytics.js +165 -101
- package/mtds/analytics/analytics.js.map +1 -1
- package/mtds/app/app-observer.js +73 -27
- package/mtds/app/app-observer.js.map +1 -1
- package/mtds/app/app-toggle.js +2 -24
- package/mtds/app/app-toggle.js.map +1 -1
- package/mtds/app/app-toggle2.js +16 -10
- package/mtds/app/app-toggle2.js.map +1 -1
- package/mtds/app/app.d.ts +5 -5
- package/mtds/app/app.js +36 -32
- package/mtds/app/app.js.map +1 -1
- package/mtds/atlas/atlas-element.d.ts +9 -14
- package/mtds/atlas/atlas-element.js +98 -76
- package/mtds/atlas/atlas-element.js.map +1 -1
- package/mtds/atlas/atlas-marker.d.ts +20 -0
- package/mtds/atlas/atlas-marker.js +73 -0
- package/mtds/atlas/atlas-marker.js.map +1 -0
- package/mtds/atlas/atlas-matgeo.d.ts +37 -0
- package/mtds/atlas/atlas-matgeo.js +93 -0
- package/mtds/atlas/atlas-matgeo.js.map +1 -0
- package/mtds/atlas/atlas-wms.d.ts +17 -0
- package/mtds/atlas/atlas-wms.js +39 -0
- package/mtds/atlas/atlas-wms.js.map +1 -0
- package/mtds/atlas/atlas.css.js +80 -94
- package/mtds/atlas/atlas.css.js.map +1 -1
- package/mtds/atlas/atlas.d.ts +51 -0
- package/mtds/atlas/atlas.js +38 -0
- package/mtds/atlas/atlas.js.map +1 -0
- package/mtds/atlas/atlas.stories.d.ts +6 -1
- package/mtds/atlas/cluster.js +1576 -697
- package/mtds/atlas/cluster.js.map +1 -1
- package/mtds/atlas.iife.js +84 -98
- package/mtds/atlas.js +10 -4
- package/mtds/atlas.js.map +1 -1
- package/mtds/avatar/avatar.js +8 -8
- package/mtds/avatar/avatar.js.map +1 -1
- package/mtds/badge/badge.d.ts +2 -2
- package/mtds/badge/badge.js +7 -7
- package/mtds/badge/badge.js.map +1 -1
- package/mtds/breadcrumbs/breadcrumbs-observer.js +10 -9
- package/mtds/breadcrumbs/breadcrumbs-observer.js.map +1 -1
- package/mtds/breadcrumbs/breadcrumbs.js +14 -13
- package/mtds/breadcrumbs/breadcrumbs.js.map +1 -1
- package/mtds/button/button.js +16 -14
- package/mtds/button/button.js.map +1 -1
- package/mtds/card/card.js +14 -12
- package/mtds/card/card.js.map +1 -1
- package/mtds/chart/chart-axis.js +27 -15
- package/mtds/chart/chart-axis.js.map +1 -1
- package/mtds/chart/chart-bars.js +15 -13
- package/mtds/chart/chart-bars.js.map +1 -1
- package/mtds/chart/chart-element.d.ts +5 -0
- package/mtds/chart/chart-element.js +83 -48
- package/mtds/chart/chart-element.js.map +1 -1
- package/mtds/chart/chart-lines.js +54 -32
- package/mtds/chart/chart-lines.js.map +1 -1
- package/mtds/chart/chart-pies.js +34 -14
- package/mtds/chart/chart-pies.js.map +1 -1
- package/mtds/chart/chart.css.js +2 -2
- package/mtds/chart/chart.css.js.map +1 -1
- package/mtds/chart/chart.d.ts +3 -4
- package/mtds/chart/chart.js +12 -12
- package/mtds/chart/chart.js.map +1 -1
- package/mtds/chip/chip.js +8 -8
- package/mtds/chip/chip.js.map +1 -1
- package/mtds/details/details.d.ts +3 -3
- package/mtds/details/details.js +14 -12
- package/mtds/details/details.js.map +1 -1
- package/mtds/dialog/dialog-observer.js +35 -22
- package/mtds/dialog/dialog-observer.js.map +1 -1
- package/mtds/dialog/dialog.d.ts +2 -2
- package/mtds/dialog/dialog.js +12 -12
- package/mtds/dialog/dialog.js.map +1 -1
- package/mtds/divider/divider.d.ts +2 -2
- package/mtds/divider/divider.js +10 -10
- package/mtds/divider/divider.js.map +1 -1
- package/mtds/errorsummary/errorsummary-observer.js +11 -8
- package/mtds/errorsummary/errorsummary-observer.js.map +1 -1
- package/mtds/errorsummary/errorsummary.d.ts +1 -1
- package/mtds/errorsummary/errorsummary.js +11 -11
- package/mtds/errorsummary/errorsummary.js.map +1 -1
- package/mtds/external/@turf/boolean-point-in-polygon/dist/esm/index.js +35 -0
- package/mtds/external/@turf/boolean-point-in-polygon/dist/esm/index.js.map +1 -0
- package/mtds/external/@turf/helpers/dist/esm/index.js +40 -0
- package/mtds/external/@turf/helpers/dist/esm/index.js.map +1 -0
- package/mtds/external/@turf/invariant/dist/esm/index.js +28 -0
- package/mtds/external/@turf/invariant/dist/esm/index.js.map +1 -0
- package/mtds/external/leaflet/dist/leaflet-src.js +6006 -3098
- package/mtds/external/leaflet/dist/leaflet-src.js.map +1 -1
- package/mtds/external/leaflet/dist/leaflet.css.js +2 -2
- package/mtds/external/leaflet/dist/leaflet.css.js.map +1 -1
- package/mtds/external/point-in-polygon-hao/dist/esm/index.js +56 -0
- package/mtds/external/point-in-polygon-hao/dist/esm/index.js.map +1 -0
- package/mtds/external/robust-predicates/esm/orient2d.js +168 -0
- package/mtds/external/robust-predicates/esm/orient2d.js.map +1 -0
- package/mtds/external/robust-predicates/esm/util.js +91 -0
- package/mtds/external/robust-predicates/esm/util.js.map +1 -0
- package/mtds/field/field-observer.js +114 -62
- package/mtds/field/field-observer.js.map +1 -1
- package/mtds/field/field.d.ts +6 -6
- package/mtds/field/field.js +166 -133
- package/mtds/field/field.js.map +1 -1
- package/mtds/field/field.stories.d.ts +2 -0
- package/mtds/fieldset/fieldset-observer.js +24 -14
- package/mtds/fieldset/fieldset-observer.js.map +1 -1
- package/mtds/fieldset/fieldset.d.ts +1 -1
- package/mtds/fieldset/fieldset.js +11 -11
- package/mtds/fieldset/fieldset.js.map +1 -1
- package/mtds/fileupload/fileupload.js +9 -8
- package/mtds/fileupload/fileupload.js.map +1 -1
- package/mtds/helptext/helptext.d.ts +1 -1
- package/mtds/helptext/helptext.js +15 -15
- package/mtds/helptext/helptext.js.map +1 -1
- package/mtds/index.iife.js +9 -9
- package/mtds/index.js +26 -24
- package/mtds/input/input.d.ts +3 -3
- package/mtds/input/input.js +22 -20
- package/mtds/input/input.js.map +1 -1
- package/mtds/law/law-helper.d.ts +6 -2
- package/mtds/law/law-helper.js +145 -63
- package/mtds/law/law-helper.js.map +1 -1
- package/mtds/law/law.d.ts +6 -2
- package/mtds/law/law.js +6 -6
- package/mtds/law/law.js.map +1 -1
- package/mtds/law/law.stories.d.ts +1 -0
- package/mtds/layout/layout.js +13 -10
- package/mtds/layout/layout.js.map +1 -1
- package/mtds/link/link.js +8 -7
- package/mtds/link/link.js.map +1 -1
- package/mtds/logo/logo-observer.js +18 -12
- package/mtds/logo/logo-observer.js.map +1 -1
- package/mtds/logo/logo.js +8 -8
- package/mtds/logo/logo.js.map +1 -1
- package/mtds/package.json.js +2 -2
- package/mtds/pagination/pagination-helper.js +17 -11
- package/mtds/pagination/pagination-helper.js.map +1 -1
- package/mtds/pagination/pagination.d.ts +1 -1
- package/mtds/pagination/pagination.js +30 -30
- package/mtds/pagination/pagination.js.map +1 -1
- package/mtds/popover/popover-observer.js +47 -28
- package/mtds/popover/popover-observer.js.map +1 -1
- package/mtds/popover/popover.js +13 -11
- package/mtds/popover/popover.js.map +1 -1
- package/mtds/progress/progress.d.ts +1 -1
- package/mtds/progress/progress.js +8 -8
- package/mtds/progress/progress.js.map +1 -1
- package/mtds/react-atlas.d.ts +1 -0
- package/mtds/react-atlas.js +15 -0
- package/mtds/react-atlas.js.map +1 -0
- package/mtds/react-types.d.ts +3 -0
- package/mtds/react.js +79 -79
- package/mtds/skeleton/skeleton.js +8 -8
- package/mtds/skeleton/skeleton.js.map +1 -1
- package/mtds/spinner/spinner.d.ts +2 -2
- package/mtds/spinner/spinner.js +8 -8
- package/mtds/spinner/spinner.js.map +1 -1
- package/mtds/steps/steps.d.ts +2 -2
- package/mtds/steps/steps.js +7 -7
- package/mtds/steps/steps.js.map +1 -1
- package/mtds/styles.css +4586 -1
- package/mtds/styles.module.css.js +167 -112
- package/mtds/styles.module.css.js.map +1 -1
- package/mtds/table/table-observer.js +22 -19
- package/mtds/table/table-observer.js.map +1 -1
- package/mtds/table/table.d.ts +4 -4
- package/mtds/table/table.js +18 -16
- package/mtds/table/table.js.map +1 -1
- package/mtds/tabs/tabs.d.ts +4 -4
- package/mtds/tabs/tabs.js +25 -21
- package/mtds/tabs/tabs.js.map +1 -1
- package/mtds/tag/tag.js +8 -8
- package/mtds/tag/tag.js.map +1 -1
- package/mtds/tailwind.css +24 -6
- package/mtds/toast/toast-helper.js +35 -20
- package/mtds/toast/toast-helper.js.map +1 -1
- package/mtds/toast/toast-observer.js +30 -15
- package/mtds/toast/toast-observer.js.map +1 -1
- package/mtds/toast/toast.js +45 -37
- package/mtds/toast/toast.js.map +1 -1
- package/mtds/togglegroup/togglegroup-observer.js +15 -10
- package/mtds/togglegroup/togglegroup-observer.js.map +1 -1
- package/mtds/togglegroup/togglegroup.d.ts +3 -3
- package/mtds/togglegroup/togglegroup.js +20 -18
- package/mtds/togglegroup/togglegroup.js.map +1 -1
- package/mtds/tooltip/tooltip-observer.js +48 -32
- package/mtds/tooltip/tooltip-observer.js.map +1 -1
- package/mtds/typography/typography.js +28 -19
- package/mtds/typography/typography.js.map +1 -1
- package/mtds/utils.d.ts +12 -3
- package/mtds/utils.js +133 -81
- package/mtds/utils.js.map +1 -1
- package/mtds/validation/validation.d.ts +1 -1
- package/mtds/validation/validation.js +12 -12
- package/mtds/validation/validation.js.map +1 -1
- package/package.json +16 -10
|
@@ -1,23 +1,32 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
import
|
|
3
|
-
import { forwardRef
|
|
4
|
-
import
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import styles from "../styles.module.css.js";
|
|
5
|
+
const Heading = forwardRef(function Heading2({ as, className, ...rest }, ref) {
|
|
6
|
+
const Tag = as || "h2";
|
|
7
|
+
return /* @__PURE__ */ jsx(Tag, { className: clsx(styles.heading, className), ref, ...rest });
|
|
8
|
+
});
|
|
9
|
+
const Muted = forwardRef(function Muted2({ as, className, ...rest }, ref) {
|
|
10
|
+
const Tag = as || "small";
|
|
11
|
+
return /* @__PURE__ */ jsx(Tag, { className: clsx(styles.muted, className), ref, ...rest });
|
|
12
|
+
});
|
|
13
|
+
const Ingress = forwardRef(function Ingress2({ as, className, ...rest }, ref) {
|
|
14
|
+
const Tag = as || "span";
|
|
15
|
+
return /* @__PURE__ */ jsx(Tag, { className: clsx(styles.ingress, className), ref, ...rest });
|
|
16
|
+
});
|
|
17
|
+
const Info = forwardRef(function Info2({ as, className, ...rest }, ref) {
|
|
18
|
+
const Tag = as || "div";
|
|
19
|
+
return /* @__PURE__ */ jsx(Tag, { className: clsx(styles.info, className), ref, ...rest });
|
|
20
|
+
});
|
|
21
|
+
const Prose = forwardRef(function Prose2({ as, className, ...rest }, ref) {
|
|
22
|
+
const Tag = as || "div";
|
|
23
|
+
return /* @__PURE__ */ jsx(Tag, { className: clsx(styles.prose, className), ref, ...rest });
|
|
15
24
|
});
|
|
16
25
|
export {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
26
|
+
Heading,
|
|
27
|
+
Info,
|
|
28
|
+
Ingress,
|
|
29
|
+
Muted,
|
|
30
|
+
Prose
|
|
22
31
|
};
|
|
23
32
|
//# sourceMappingURL=typography.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typography.js","sources":["../../designsystem/typography/typography.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { forwardRef, type JSX } from \"react\";\nimport type {\n\tPolymorphicComponentPropWithRef,\n\tPolymorphicRef,\n} from \"../react-types\";\nimport styles from \"../styles.module.css\";\n\nexport type HeadingSizes = \"2xs\" | \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\";\nexport type HeadingProps<As extends React.ElementType = \"h2\"> =\n\tPolymorphicComponentPropWithRef<\n\t\tAs,\n\t\t{\n\t\t\t\"data-size\"?: HeadingSizes;\n\t\t\t\"data-justify\"?: \"start\" | \"center\";\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\nexport type MutedProps<As extends React.ElementType = \"small\"> =\n\tPolymorphicComponentPropWithRef<As>;\n\ntype MutedComponent = <As extends React.ElementType = \"small\">(\n\tprops: MutedProps<As>,\n) => JSX.Element;\n\nexport const Muted: MutedComponent = forwardRef<null>(function Muted<\n\tAs extends React.ElementType = \"small\",\n>({ as, className, ...rest }: MutedProps<As>, ref?: PolymorphicRef<As>) {\n\tconst Tag = as || \"small\";\n\treturn <Tag className={clsx(styles.muted, className)} ref={ref} {...rest} />;\n}) as MutedComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n\nexport type IngressProps<As extends React.ElementType = \"span\"> =\n\tPolymorphicComponentPropWithRef<As>;\n\ntype IngressComponent = <As extends React.ElementType = \"span\">(\n\tprops: MutedProps<As>,\n) => JSX.Element;\n\nexport const Ingress: IngressComponent = forwardRef<null>(function Ingress<\n\tAs extends React.ElementType = \"span\",\n>({ as, className, ...rest }: IngressProps<As>, ref?: PolymorphicRef<As>) {\n\tconst Tag = as || \"span\";\n\treturn (\n\t\t<Tag className={clsx(styles.ingress, className)} ref={ref} {...rest} />\n\t);\n}) as IngressComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n\nexport type InfoProps<As extends React.ElementType = \"div\"> =\n\tPolymorphicComponentPropWithRef<\n\t\tAs,\n\t\t{ \"data-variant\"?: \"regular\" | \"circle\" }\n\t>;\n\ntype InfoComponent = <As extends React.ElementType = \"div\">(\n\tprops: MutedProps<As>,\n) => JSX.Element;\n\nexport const Info: InfoComponent = forwardRef<null>(function Info<\n\tAs extends React.ElementType = \"div\",\n>({ as, className, ...rest }: InfoProps<As>, ref?: PolymorphicRef<As>) {\n\tconst Tag = as || \"div\";\n\treturn <Tag className={clsx(styles.info, className)} ref={ref} {...rest} />;\n}) as InfoComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n\n/**\n * Prose\n */\nexport type ProseProps<As extends React.ElementType = \"div\"> =\n\tPolymorphicComponentPropWithRef<\n\t\tAs,\n\t\t{ \"data-justify\"?: \"start\" | \"center\" | \"end\" }\n\t>;\n\ntype ProseComponent = <As extends React.ElementType = \"div\">(\n\tprops: ProseProps<As>,\n) => JSX.Element;\n\nexport const Prose: ProseComponent = forwardRef<null>(function Prose<\n\tAs extends React.ElementType = \"div\",\n>({ as, className, ...rest }: ProseProps<As>, ref?: PolymorphicRef<As>) {\n\tconst Tag = as || \"div\";\n\n\treturn <Tag className={clsx(styles.prose, className)} ref={ref} {...rest} />;\n}) as ProseComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n"],"names":["Heading","
|
|
1
|
+
{"version":3,"file":"typography.js","sources":["../../designsystem/typography/typography.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { forwardRef, type JSX } from \"react\";\nimport type {\n\tPolymorphicComponentPropWithRef,\n\tPolymorphicRef,\n} from \"../react-types\";\nimport styles from \"../styles.module.css\";\n\nexport type HeadingSizes = \"2xs\" | \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\";\nexport type HeadingProps<As extends React.ElementType = \"h2\"> =\n\tPolymorphicComponentPropWithRef<\n\t\tAs,\n\t\t{\n\t\t\t\"data-size\"?: HeadingSizes;\n\t\t\t\"data-justify\"?: \"start\" | \"center\";\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\nexport type MutedProps<As extends React.ElementType = \"small\"> =\n\tPolymorphicComponentPropWithRef<As>;\n\ntype MutedComponent = <As extends React.ElementType = \"small\">(\n\tprops: MutedProps<As>,\n) => JSX.Element;\n\nexport const Muted: MutedComponent = forwardRef<null>(function Muted<\n\tAs extends React.ElementType = \"small\",\n>({ as, className, ...rest }: MutedProps<As>, ref?: PolymorphicRef<As>) {\n\tconst Tag = as || \"small\";\n\treturn <Tag className={clsx(styles.muted, className)} ref={ref} {...rest} />;\n}) as MutedComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n\nexport type IngressProps<As extends React.ElementType = \"span\"> =\n\tPolymorphicComponentPropWithRef<As>;\n\ntype IngressComponent = <As extends React.ElementType = \"span\">(\n\tprops: MutedProps<As>,\n) => JSX.Element;\n\nexport const Ingress: IngressComponent = forwardRef<null>(function Ingress<\n\tAs extends React.ElementType = \"span\",\n>({ as, className, ...rest }: IngressProps<As>, ref?: PolymorphicRef<As>) {\n\tconst Tag = as || \"span\";\n\treturn (\n\t\t<Tag className={clsx(styles.ingress, className)} ref={ref} {...rest} />\n\t);\n}) as IngressComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n\nexport type InfoProps<As extends React.ElementType = \"div\"> =\n\tPolymorphicComponentPropWithRef<\n\t\tAs,\n\t\t{ \"data-variant\"?: \"regular\" | \"circle\" }\n\t>;\n\ntype InfoComponent = <As extends React.ElementType = \"div\">(\n\tprops: MutedProps<As>,\n) => JSX.Element;\n\nexport const Info: InfoComponent = forwardRef<null>(function Info<\n\tAs extends React.ElementType = \"div\",\n>({ as, className, ...rest }: InfoProps<As>, ref?: PolymorphicRef<As>) {\n\tconst Tag = as || \"div\";\n\treturn <Tag className={clsx(styles.info, className)} ref={ref} {...rest} />;\n}) as InfoComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n\n/**\n * Prose\n */\nexport type ProseProps<As extends React.ElementType = \"div\"> =\n\tPolymorphicComponentPropWithRef<\n\t\tAs,\n\t\t{ \"data-justify\"?: \"start\" | \"center\" | \"end\" }\n\t>;\n\ntype ProseComponent = <As extends React.ElementType = \"div\">(\n\tprops: ProseProps<As>,\n) => JSX.Element;\n\nexport const Prose: ProseComponent = forwardRef<null>(function Prose<\n\tAs extends React.ElementType = \"div\",\n>({ as, className, ...rest }: ProseProps<As>, ref?: PolymorphicRef<As>) {\n\tconst Tag = as || \"div\";\n\n\treturn <Tag className={clsx(styles.prose, className)} ref={ref} {...rest} />;\n}) as ProseComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n"],"names":["Heading","Muted","Ingress","Info","Prose"],"mappings":";;;;AAsBO,MAAM,UAA4B,WAAiB,SAASA,SAEjE,EAAE,IAAI,WAAW,GAAG,KAAA,GAA0B,KAA0B;AACzE,QAAM,MAAM,MAAM;AAElB,SACC,oBAAC,KAAA,EAAI,WAAW,KAAK,OAAO,SAAS,SAAS,GAAG,KAAW,GAAG,KAAA,CAAM;AAEvE,CAAC;AASM,MAAM,QAAwB,WAAiB,SAASC,OAE7D,EAAE,IAAI,WAAW,GAAG,KAAA,GAAwB,KAA0B;AACvE,QAAM,MAAM,MAAM;AAClB,SAAO,oBAAC,KAAA,EAAI,WAAW,KAAK,OAAO,OAAO,SAAS,GAAG,KAAW,GAAG,KAAA,CAAM;AAC3E,CAAC;AASM,MAAM,UAA4B,WAAiB,SAASC,SAEjE,EAAE,IAAI,WAAW,GAAG,KAAA,GAA0B,KAA0B;AACzE,QAAM,MAAM,MAAM;AAClB,SACC,oBAAC,KAAA,EAAI,WAAW,KAAK,OAAO,SAAS,SAAS,GAAG,KAAW,GAAG,KAAA,CAAM;AAEvE,CAAC;AAYM,MAAM,OAAsB,WAAiB,SAASC,MAE3D,EAAE,IAAI,WAAW,GAAG,KAAA,GAAuB,KAA0B;AACtE,QAAM,MAAM,MAAM;AAClB,SAAO,oBAAC,KAAA,EAAI,WAAW,KAAK,OAAO,MAAM,SAAS,GAAG,KAAW,GAAG,KAAA,CAAM;AAC1E,CAAC;AAeM,MAAM,QAAwB,WAAiB,SAASC,OAE7D,EAAE,IAAI,WAAW,GAAG,KAAA,GAAwB,KAA0B;AACvE,QAAM,MAAM,MAAM;AAElB,SAAO,oBAAC,KAAA,EAAI,WAAW,KAAK,OAAO,OAAO,SAAS,GAAG,KAAW,GAAG,KAAA,CAAM;AAC3E,CAAC;"}
|
package/mtds/utils.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export declare const QUICK_EVENT: {
|
|
|
3
3
|
capture: boolean;
|
|
4
4
|
passive: boolean;
|
|
5
5
|
};
|
|
6
|
-
export declare const
|
|
6
|
+
export declare const isBrowser: () => boolean;
|
|
7
7
|
export declare function debounce<T extends unknown[]>(callback: (...args: T) => void, delay: number): (this: unknown, ...args: T) => void;
|
|
8
8
|
/**
|
|
9
9
|
* attr
|
|
@@ -61,8 +61,12 @@ export declare function onResize(callback: ResizeObserverCallback, element: Elem
|
|
|
61
61
|
* @returns True if the element is an input like element
|
|
62
62
|
*/
|
|
63
63
|
export declare const isInputLike: (el: unknown) => el is HTMLInputElement;
|
|
64
|
-
export declare const toCustomElementProps:
|
|
65
|
-
|
|
64
|
+
export declare const toCustomElementProps: <T extends Record<string, unknown>>(rest: T, klass?: string) => T & {
|
|
65
|
+
suppressHydrationWarning: boolean;
|
|
66
|
+
"aria-selected": boolean | undefined;
|
|
67
|
+
class: string;
|
|
68
|
+
hidden: boolean;
|
|
69
|
+
open: boolean;
|
|
66
70
|
};
|
|
67
71
|
/**
|
|
68
72
|
* tag
|
|
@@ -77,4 +81,9 @@ export declare const MTDSElement: {
|
|
|
77
81
|
new (): HTMLElement;
|
|
78
82
|
prototype: HTMLElement;
|
|
79
83
|
};
|
|
84
|
+
/**
|
|
85
|
+
* defineElement
|
|
86
|
+
* @description Defines a customElement if running in browser and if not already registered
|
|
87
|
+
*/
|
|
88
|
+
export declare const defineElement: (name: string, instance: CustomElementConstructor) => true | void | CustomElementConstructor;
|
|
80
89
|
export {};
|
package/mtds/utils.js
CHANGED
|
@@ -1,102 +1,154 @@
|
|
|
1
|
-
import { autoUpdate
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { autoUpdate, computePosition, flip, shift, size } from "@floating-ui/dom";
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
import styles from "./styles.module.css.js";
|
|
4
|
+
const QUICK_EVENT = { capture: true, passive: true };
|
|
5
|
+
const isBrowser = () => typeof window !== "undefined" && typeof document !== "undefined";
|
|
6
|
+
function debounce(callback, delay) {
|
|
7
|
+
let timer;
|
|
8
|
+
return function(...args) {
|
|
9
|
+
clearTimeout(timer);
|
|
10
|
+
timer = setTimeout(() => callback.apply(this, args), delay);
|
|
9
11
|
};
|
|
10
12
|
}
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
+
function attr(el, name, value) {
|
|
14
|
+
if (value === void 0) return el.getAttribute(name) ?? null;
|
|
15
|
+
if (value === null) el.removeAttribute(name);
|
|
16
|
+
else if (el.getAttribute(name) !== value) el.setAttribute(name, value);
|
|
17
|
+
return null;
|
|
13
18
|
}
|
|
14
|
-
let
|
|
15
|
-
const
|
|
16
|
-
function
|
|
17
|
-
|
|
19
|
+
let id = 0;
|
|
20
|
+
const UUID = `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 5)}`;
|
|
21
|
+
function useId(el) {
|
|
22
|
+
if (!el.id) el.id = `${UUID}${++id}`;
|
|
23
|
+
return el.id;
|
|
18
24
|
}
|
|
19
|
-
const
|
|
20
|
-
for (const
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
const events = (action, element, [...rest]) => {
|
|
26
|
+
for (const type of rest[0].split(",")) {
|
|
27
|
+
rest[0] = type;
|
|
28
|
+
element[`${action}EventListener`](...rest);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const on = (element, ...rest) => {
|
|
32
|
+
events("add", element, rest);
|
|
33
|
+
return () => off(element, ...rest);
|
|
34
|
+
};
|
|
35
|
+
const off = (element, ...rest) => events("remove", element, rest);
|
|
36
|
+
const onLoaded = (setup) => {
|
|
37
|
+
if (!isBrowser() || !window.requestAnimationFrame) return;
|
|
38
|
+
if (!window._mtdsCleanups) window._mtdsCleanups = /* @__PURE__ */ new Map();
|
|
39
|
+
const run = () => requestAnimationFrame(() => {
|
|
40
|
+
const key = String(setup).replace(/(\n|\s)/g, "");
|
|
41
|
+
window._mtdsCleanups?.get(key)?.map((cleanup) => cleanup());
|
|
42
|
+
window._mtdsCleanups?.set(key, setup());
|
|
28
43
|
});
|
|
29
|
-
document.readyState === "complete"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
44
|
+
if (document.readyState === "complete") run();
|
|
45
|
+
else on(window, "load", run);
|
|
46
|
+
};
|
|
47
|
+
const ANCHORED = /* @__PURE__ */ new WeakMap();
|
|
48
|
+
const DIALOG = `.${styles.dialog.split(" ")[0]}`;
|
|
49
|
+
function anchorPosition(target, anchor, { contain, middleware, placement, ...options } = {}) {
|
|
50
|
+
ANCHORED.get(target)?.();
|
|
51
|
+
ANCHORED.delete(target);
|
|
52
|
+
if (anchor) {
|
|
53
|
+
const footer = target.closest(DIALOG)?.querySelector(":scope > footer");
|
|
54
|
+
const inset = Number(attr(target, "data-inset")) || 20;
|
|
55
|
+
const bottom = (footer?.clientHeight || 0) + inset;
|
|
56
|
+
const padding = { bottom, left: inset, right: inset, top: inset };
|
|
57
|
+
const position = attr(target, "data-position") ?? "bottom";
|
|
58
|
+
ANCHORED.set(
|
|
59
|
+
target,
|
|
60
|
+
autoUpdate(anchor, target, () => {
|
|
61
|
+
if (!target.isConnected || !anchor.isConnected || target.hidden)
|
|
62
|
+
return anchorPosition(target, false);
|
|
63
|
+
computePosition(anchor, target, {
|
|
64
|
+
...options,
|
|
65
|
+
placement: placement || position,
|
|
42
66
|
middleware: [
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
...
|
|
46
|
-
...
|
|
67
|
+
flip({ padding }),
|
|
68
|
+
shift(),
|
|
69
|
+
...contain ? [size({ padding, apply: contain })] : [],
|
|
70
|
+
...middleware || []
|
|
47
71
|
]
|
|
48
|
-
}).then(({ x
|
|
49
|
-
|
|
72
|
+
}).then(({ x, y }) => {
|
|
73
|
+
target.style.left = `${x}px`;
|
|
74
|
+
target.style.top = `${y}px`;
|
|
50
75
|
});
|
|
51
76
|
})
|
|
52
77
|
);
|
|
53
78
|
}
|
|
54
79
|
}
|
|
55
|
-
function
|
|
56
|
-
let
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
80
|
+
function onMutation(callback, attr2) {
|
|
81
|
+
let queue = 0;
|
|
82
|
+
const opt = Array.isArray(attr2) || typeof attr2 === "string" ? { attr: attr2 } : attr2;
|
|
83
|
+
const onFrame = () => setTimeout(onTimer, opt?.delay ?? 200);
|
|
84
|
+
const onTimer = () => {
|
|
85
|
+
if (!isBrowser()) return cleanup();
|
|
86
|
+
callback(observer);
|
|
87
|
+
observer.takeRecords();
|
|
88
|
+
queue = 0;
|
|
89
|
+
};
|
|
90
|
+
const observer = new MutationObserver(() => {
|
|
91
|
+
if (!queue) queue = requestAnimationFrame(onFrame);
|
|
92
|
+
});
|
|
93
|
+
const cleanup = () => {
|
|
63
94
|
try {
|
|
64
|
-
|
|
65
|
-
} catch {
|
|
95
|
+
observer.disconnect();
|
|
96
|
+
} catch (_) {
|
|
66
97
|
}
|
|
67
98
|
};
|
|
68
|
-
|
|
69
|
-
attributeFilter: [].concat(
|
|
70
|
-
attributes:
|
|
71
|
-
childList:
|
|
72
|
-
subtree:
|
|
73
|
-
})
|
|
99
|
+
observer.observe(opt?.root || document.documentElement, {
|
|
100
|
+
attributeFilter: [].concat(opt.attr),
|
|
101
|
+
attributes: true,
|
|
102
|
+
childList: true,
|
|
103
|
+
subtree: true
|
|
104
|
+
});
|
|
105
|
+
callback(observer);
|
|
106
|
+
return cleanup;
|
|
74
107
|
}
|
|
75
|
-
function
|
|
76
|
-
const
|
|
77
|
-
|
|
108
|
+
function onResize(callback, element) {
|
|
109
|
+
const resize = new ResizeObserver(callback);
|
|
110
|
+
resize.observe(element);
|
|
111
|
+
return () => resize.disconnect();
|
|
78
112
|
}
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
113
|
+
const isInputLike = (el) => el instanceof HTMLElement && "validity" in el && !(el instanceof HTMLButtonElement);
|
|
114
|
+
const SELECTED = "aria-selected";
|
|
115
|
+
const toCustomElementProps = (rest, klass) => Object.assign({}, rest, {
|
|
116
|
+
suppressHydrationWarning: true,
|
|
117
|
+
// Make Next.js happy
|
|
118
|
+
[SELECTED]: rest[SELECTED] === void 0 ? void 0 : `${(rest[SELECTED] || "false") !== "false"}`,
|
|
119
|
+
// Ensure aria-selected boolean is string
|
|
120
|
+
class: clsx(klass, rest.className),
|
|
121
|
+
// Use class instead of className
|
|
122
|
+
hidden: !!rest.hidden,
|
|
123
|
+
// Ensure boolean prop behaviour
|
|
124
|
+
open: !!rest.open
|
|
125
|
+
// Ensure boolean prop behaviour
|
|
126
|
+
});
|
|
127
|
+
const tag = (tagName, attrs, text) => {
|
|
128
|
+
const el = document.createElement(tagName);
|
|
129
|
+
if (text) el.textContent = text;
|
|
130
|
+
if (attrs) for (const [key, val] of Object.entries(attrs)) attr(el, key, val);
|
|
131
|
+
return el;
|
|
132
|
+
};
|
|
133
|
+
const MTDSElement = typeof HTMLElement === "undefined" ? class {
|
|
84
134
|
} : HTMLElement;
|
|
135
|
+
const defineElement = (name, instance) => !isBrowser() || window.customElements.get(name) || window.customElements.define(name, instance);
|
|
85
136
|
export {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
137
|
+
MTDSElement,
|
|
138
|
+
QUICK_EVENT,
|
|
139
|
+
anchorPosition,
|
|
140
|
+
attr,
|
|
141
|
+
debounce,
|
|
142
|
+
defineElement,
|
|
143
|
+
isBrowser,
|
|
144
|
+
isInputLike,
|
|
145
|
+
off,
|
|
146
|
+
on,
|
|
147
|
+
onLoaded,
|
|
148
|
+
onMutation,
|
|
149
|
+
onResize,
|
|
150
|
+
tag,
|
|
151
|
+
toCustomElementProps,
|
|
152
|
+
useId
|
|
101
153
|
};
|
|
102
154
|
//# sourceMappingURL=utils.js.map
|
package/mtds/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../designsystem/utils.ts"],"sourcesContent":["import type { Placement, SizeOptions } from \"@floating-ui/dom\";\nimport {\n\tautoUpdate,\n\tcomputePosition,\n\tflip,\n\tshift,\n\tsize,\n} from \"@floating-ui/dom\";\nimport clsx from \"clsx\";\nimport styles from \"./styles.module.css\";\n\nexport const QUICK_EVENT = { capture: true, passive: true };\nexport const IS_BROWSER =\n\ttypeof window !== \"undefined\" && typeof document !== \"undefined\";\n\nexport function debounce<T extends unknown[]>(\n\tcallback: (...args: T) => void,\n\tdelay: number,\n) {\n\tlet timer: ReturnType<typeof setTimeout>;\n\n\treturn function (this: unknown, ...args: T) {\n\t\tclearTimeout(timer);\n\t\ttimer = setTimeout(() => callback.apply(this, args), delay);\n\t};\n}\n\n/**\n * attr\n * @description Utility to quickly get, set and remove attributes\n * @param el The Element to 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\tif (!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 | ShadowRoot,\n\t[...rest]: Parameters<typeof Element.prototype.addEventListener>, // Spreat to make a copy of the array\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 | ShadowRoot,\n\t...rest: Parameters<typeof Element.prototype.addEventListener>\n): (() => void) => {\n\tevents(\"add\", element, rest);\n\treturn () => off(element, ...rest);\n};\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 | ShadowRoot,\n\t...rest: Parameters<typeof Element.prototype.removeEventListener>\n): void => events(\"remove\", element, rest);\n\ndeclare global {\n\tinterface Window {\n\t\t_mtdsCleanups?: Map<string, Array<() => void>>;\n\t}\n}\n\n/**\n * onLoaded\n * @description Runs a callback when window is loaded in browser, and ensures events are unbound if hot reloading\n * @param callback The callback to run when the page is ready\n */\nexport const onLoaded = (setup: () => Array<() => void>) => {\n\tif (!IS_BROWSER || !window.requestAnimationFrame) return; // Skip if not in browser environment\n\tif (!window._mtdsCleanups) window._mtdsCleanups = new Map();\n\n\tconst run = () =>\n\t\trequestAnimationFrame(() => {\n\t\t\tconst key = String(setup).replace(/(\\n|\\s)/g, \"\"); // Create a key based on setup function body\n\t\t\twindow._mtdsCleanups?.get(key)?.map((cleanup) => cleanup()); // Run cleanups\n\t\t\twindow._mtdsCleanups?.set(key, setup()); // Rum setup and store cleanups\n\t\t});\n\n\tif (document.readyState === \"complete\") run();\n\telse on(window, \"load\", run);\n};\n\ntype AnchorOptions = Parameters<typeof computePosition>[2] & {\n\tcontain?: SizeOptions[\"apply\"] | false;\n};\nconst ANCHORED = new WeakMap<Element, ReturnType<typeof autoUpdate>>();\nconst DIALOG = `.${styles.dialog.split(\" \")[0]}`;\nexport function anchorPosition(\n\ttarget: HTMLElement,\n\tanchor: false | Element,\n\t{ contain, middleware, placement, ...options }: AnchorOptions = {},\n) {\n\tANCHORED.get(target)?.(); // Unbind previous anchor position\n\tANCHORED.delete(target);\n\n\t// TODO aria-label på app\n\tif (anchor) {\n\t\tconst footer = target.closest(DIALOG)?.querySelector(\":scope > footer\");\n\t\tconst inset = Number(attr(target, \"data-inset\")) || 20;\n\t\tconst bottom = (footer?.clientHeight || 0) + inset;\n\t\tconst padding = { bottom, left: inset, right: inset, top: inset };\n\t\tconst position = (attr(target, \"data-position\") ?? \"bottom\") as Placement;\n\n\t\tANCHORED.set(\n\t\t\ttarget,\n\t\t\tautoUpdate(anchor, target, () => {\n\t\t\t\tif (!target.isConnected || !anchor.isConnected || target.hidden)\n\t\t\t\t\treturn anchorPosition(target, false);\n\t\t\t\tcomputePosition(anchor, target, {\n\t\t\t\t\t...options,\n\t\t\t\t\tplacement: placement || position,\n\t\t\t\t\tmiddleware: [\n\t\t\t\t\t\tflip({ padding }),\n\t\t\t\t\t\tshift(),\n\t\t\t\t\t\t...(contain ? [size({ padding, apply: contain })] : []),\n\t\t\t\t\t\t...(middleware || []),\n\t\t\t\t\t],\n\t\t\t\t}).then(({ x, y }) => {\n\t\t\t\t\ttarget.style.left = `${x}px`;\n\t\t\t\t\ttarget.style.top = `${y}px`;\n\t\t\t\t});\n\t\t\t}),\n\t\t);\n\t}\n}\n\n/**\n * Speed up MutationObserver by debouncing and only running when page is visible\n * @return new MutaionObserver\n */\ntype Attr = string | string[];\nexport function onMutation(\n\tcallback: (observer: MutationObserver) => void,\n\tattr: Attr | { attr: Attr; root?: HTMLElement; delay?: number },\n) {\n\tlet queue = 0;\n\tconst opt = Array.isArray(attr) || typeof attr === \"string\" ? { attr } : attr;\n\tconst onFrame = () => setTimeout(onTimer, opt?.delay ?? 200); // Use both requestAnimationFrame and setTimeout to debounce and only run when visible\n\tconst onTimer = () => {\n\t\tif (!IS_BROWSER) return cleanup(); // If using JSDOM, the document might have been removed\n\t\tcallback(observer);\n\t\tobserver.takeRecords(); // Clear records to avoid running callback multiple times\n\t\tqueue = 0;\n\t};\n\tconst observer = new MutationObserver(() => {\n\t\tif (!queue) queue = requestAnimationFrame(onFrame);\n\t});\n\tconst cleanup = () => {\n\t\ttry {\n\t\t\tobserver.disconnect();\n\t\t} catch (_) {\n\t\t\t// No more observer\n\t\t}\n\t};\n\n\tobserver.observe(opt?.root || document.documentElement, {\n\t\tattributeFilter: ([] as string[]).concat(opt.attr),\n\t\tattributes: true,\n\t\tchildList: true,\n\t\tsubtree: true,\n\t});\n\n\tcallback(observer); // Initial run\n\treturn cleanup;\n}\n\nexport function onResize(callback: ResizeObserverCallback, element: Element) {\n\tconst resize = new ResizeObserver(callback);\n\tresize.observe(element);\n\treturn () => resize.disconnect();\n}\n\n/**\n * isInputLike\n * @description Check if element is an input like element\n * @param el The element to check\n * @returns True if the element is an input like element\n */\nexport const isInputLike = (el: unknown): el is HTMLInputElement =>\n\tel instanceof HTMLElement &&\n\t\"validity\" in el &&\n\t!(el instanceof HTMLButtonElement);\n\n/**\n * toCustomElementProps\n * @description Utility to quickly convert props to custom element attributes\n * @param props The props to convert\n * @returns The converted props\n */\nconst SELECTED = \"aria-selected\";\nexport const toCustomElementProps = (\n\t{ className, hidden, open, ...rest }: Record<string, unknown>,\n\tklass?: string,\n) => {\n\trest.suppressHydrationWarning = true; // Make Next.js happy\n\tif (rest[SELECTED] !== undefined)\n\t\trest[SELECTED] = `${(rest[SELECTED] || \"false\") !== \"false\"}`; // Ensure aria-selected boolean is string\n\tif (className || klass) rest.class = clsx(klass, className as string); // Use class instead of className\n\tif (hidden) rest.hidden = true; // Ensure boolean prop behaviour\n\tif (open) rest.open = true; // Ensure boolean prop behaviour\n\treturn rest;\n};\n\n/**\n * tag\n * @description creates element and assigns properties\n * @param tagName The tagname of element to create\n * @param attrs Optional attributes to add to the element\n * @param text Optional text content to add to the element\n * @return HTMLElement with props\n */\nexport const tag = <TagName extends keyof HTMLElementTagNameMap>(\n\ttagName: TagName,\n\tattrs?: Record<string, string | null> | null,\n\ttext?: string | null,\n): HTMLElementTagNameMap[TagName] => {\n\tconst el = document.createElement(tagName);\n\tif (text) el.textContent = text;\n\tif (attrs) for (const [key, val] of Object.entries(attrs)) attr(el, key, val);\n\treturn el;\n};\n\n// Make sure we have a HTMLElement to extend (for server side rendering)\nexport const MTDSElement =\n\ttypeof HTMLElement === \"undefined\"\n\t\t? (class {} as typeof HTMLElement)\n\t\t: HTMLElement;\n"],"names":["QUICK_EVENT","IS_BROWSER","debounce","callback","delay","timer","args","attr","el","name","value","id","UUID","useId","events","action","element","type","rest","on","off","onLoaded","setup","run","key","cleanup","ANCHORED","DIALOG","styles","anchorPosition","target","anchor","contain","middleware","placement","options","footer","inset","padding","position","autoUpdate","computePosition","flip","shift","size","x","y","onMutation","queue","opt","onFrame","onTimer","observer","onResize","resize","isInputLike","SELECTED","toCustomElementProps","className","hidden","open","klass","clsx","tag","tagName","attrs","text","val","MTDSElement"],"mappings":";;;AAWO,MAAMA,IAAc,EAAE,SAAS,IAAM,SAAS,GAAA,GACxCC,IACZ,OAAO,SAAW,OAAe,OAAO,WAAa;AAE/C,SAASC,EACfC,GACAC,GACC;AACD,MAAIC;AAEJ,SAAO,YAA4BC,GAAS;AAC3C,iBAAaD,CAAK,GAClBA,IAAQ,WAAW,MAAMF,EAAS,MAAM,MAAMG,CAAI,GAAGF,CAAK;AAAA,EAC3D;AACD;AASO,SAASG,EACfC,GACAC,GACAC,GACgB;AAChB,SAAIA,MAAU,SAAkBF,EAAG,aAAaC,CAAI,KAAK,QACrDC,MAAU,OAAMF,EAAG,gBAAgBC,CAAI,IAClCD,EAAG,aAAaC,CAAI,MAAMC,KAAOF,EAAG,aAAaC,GAAMC,CAAK,GAC9D;AACR;AAMA,IAAIC,IAAK;AACT,MAAMC,IAAO,GAAG,KAAK,MAAM,SAAS,EAAE,CAAC,GAAG,KAAK,OAAA,EAAS,SAAS,EAAE,EAAE,MAAM,GAAG,CAAC,CAAC;AACzE,SAASC,EAAML,GAAa;AAClC,SAAKA,EAAG,OAAIA,EAAG,KAAK,GAAGI,CAAI,GAAG,EAAED,CAAE,KAC3BH,EAAG;AACX;AAGA,MAAMM,IAAS,CACdC,GACAC,GACA,KAAQ,MACE;AACV,aAAWC,KAAQC,EAAK,CAAC,EAAE,MAAM,GAAG;AACnC,IAAAA,EAAK,CAAC,IAAID,GACVD,EAAQ,GAAGD,CAAM,eAAe,EAAE,GAAGG,CAAI;AAE3C,GAQaC,IAAK,CACjBH,MACGE,OAEHJ,EAAO,OAAOE,GAASE,CAAI,GACpB,MAAME,EAAIJ,GAAS,GAAGE,CAAI,IASrBE,IAAM,CAClBJ,MACGE,MACOJ,E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mD,EAAO,QAAQtC,CAAO,GACf,MAAMsC,EAAO,WAAA;AACrB;AAQO,MAAMC,IAAc,CAAC/C,MAC3BA,aAAc,eACd,cAAcA,KACd,EAAEA,aAAc,oBAQXgD,IAAW,iBACJC,IAAuB,CACnC,EAAE,WAAAC,GAAW,QAAAC,GAAQ,MAAAC,GAAM,GAAG1C,EAAA,GAC9B2C,OAEA3C,EAAK,2BAA2B,IAC5BA,EAAKsC,CAAQ,MAAM,WACtBtC,EAAKsC,CAAQ,IAAI,IAAItC,EAAKsC,CAAQ,KAAK,aAAa,OAAO,MACxDE,KAAaG,OAAO3C,EAAK,QAAQ4C,EAAKD,GAAOH,CAAmB,IAChEC,QAAa,SAAS,KACtBC,QAAW,OAAO,KACf1C,IAWK6C,IAAM,CAClBC,GACAC,GACAC,MACoC;AACpC,QAAM1D,IAAK,SAAS,cAAcwD,CAAO;AAEzC,MADIE,QAAS,cAAcA,IACvBD,EAAO,YAAW,CAACzC,GAAK2C,CAAG,KAAK,OAAO,QAAQF,CAAK,EAAG,CAAA1D,EAAKC,GAAIgB,GAAK2C,CAAG;AAC5E,SAAO3D;AACR,GAGa4D,IACZ,OAAO,cAAgB,MACnB,MAAM;AAAC,IACR;"}
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../designsystem/utils.ts"],"sourcesContent":["import type { Placement, SizeOptions } from \"@floating-ui/dom\";\nimport {\n\tautoUpdate,\n\tcomputePosition,\n\tflip,\n\tshift,\n\tsize,\n} from \"@floating-ui/dom\";\nimport clsx from \"clsx\";\nimport styles from \"./styles.module.css\";\n\nexport const QUICK_EVENT = { capture: true, passive: true };\nexport const isBrowser = () =>\n\ttypeof window !== \"undefined\" && typeof document !== \"undefined\"; // Using function to play nice with Vitest where DOM can come and go\n\nexport function debounce<T extends unknown[]>(\n\tcallback: (...args: T) => void,\n\tdelay: number,\n) {\n\tlet timer: ReturnType<typeof setTimeout>;\n\n\treturn function (this: unknown, ...args: T) {\n\t\tclearTimeout(timer);\n\t\ttimer = setTimeout(() => callback.apply(this, args), delay);\n\t};\n}\n\n/**\n * attr\n * @description Utility to quickly get, set and remove attributes\n * @param el The Element to 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\tif (!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 | ShadowRoot,\n\t[...rest]: Parameters<typeof Element.prototype.addEventListener>, // Spreat to make a copy of the array\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 | ShadowRoot,\n\t...rest: Parameters<typeof Element.prototype.addEventListener>\n): (() => void) => {\n\tevents(\"add\", element, rest);\n\treturn () => off(element, ...rest);\n};\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 | ShadowRoot,\n\t...rest: Parameters<typeof Element.prototype.removeEventListener>\n): void => events(\"remove\", element, rest);\n\ndeclare global {\n\tinterface Window {\n\t\t_mtdsCleanups?: Map<string, Array<() => void>>;\n\t}\n}\n\n/**\n * onLoaded\n * @description Runs a callback when window is loaded in browser, and ensures events are unbound if hot reloading\n * @param callback The callback to run when the page is ready\n */\nexport const onLoaded = (setup: () => Array<() => void>) => {\n\tif (!isBrowser() || !window.requestAnimationFrame) return; // Skip if not in browser environment\n\tif (!window._mtdsCleanups) window._mtdsCleanups = new Map();\n\n\tconst run = () =>\n\t\trequestAnimationFrame(() => {\n\t\t\tconst key = String(setup).replace(/(\\n|\\s)/g, \"\"); // Create a key based on setup function body\n\t\t\twindow._mtdsCleanups?.get(key)?.map((cleanup) => cleanup()); // Run cleanups\n\t\t\twindow._mtdsCleanups?.set(key, setup()); // Rum setup and store cleanups\n\t\t});\n\n\tif (document.readyState === \"complete\") run();\n\telse on(window, \"load\", run);\n};\n\ntype AnchorOptions = Parameters<typeof computePosition>[2] & {\n\tcontain?: SizeOptions[\"apply\"] | false;\n};\nconst ANCHORED = new WeakMap<Element, ReturnType<typeof autoUpdate>>();\nconst DIALOG = `.${styles.dialog.split(\" \")[0]}`;\nexport function anchorPosition(\n\ttarget: HTMLElement,\n\tanchor: false | Element,\n\t{ contain, middleware, placement, ...options }: AnchorOptions = {},\n) {\n\tANCHORED.get(target)?.(); // Unbind previous anchor position\n\tANCHORED.delete(target);\n\n\tif (anchor) {\n\t\tconst footer = target.closest(DIALOG)?.querySelector(\":scope > footer\");\n\t\tconst inset = Number(attr(target, \"data-inset\")) || 20;\n\t\tconst bottom = (footer?.clientHeight || 0) + inset;\n\t\tconst padding = { bottom, left: inset, right: inset, top: inset };\n\t\tconst position = (attr(target, \"data-position\") ?? \"bottom\") as Placement;\n\n\t\tANCHORED.set(\n\t\t\ttarget,\n\t\t\tautoUpdate(anchor, target, () => {\n\t\t\t\tif (!target.isConnected || !anchor.isConnected || target.hidden)\n\t\t\t\t\treturn anchorPosition(target, false);\n\t\t\t\tcomputePosition(anchor, target, {\n\t\t\t\t\t...options,\n\t\t\t\t\tplacement: placement || position,\n\t\t\t\t\tmiddleware: [\n\t\t\t\t\t\tflip({ padding }),\n\t\t\t\t\t\tshift(),\n\t\t\t\t\t\t...(contain ? [size({ padding, apply: contain })] : []),\n\t\t\t\t\t\t...(middleware || []),\n\t\t\t\t\t],\n\t\t\t\t}).then(({ x, y }) => {\n\t\t\t\t\ttarget.style.left = `${x}px`;\n\t\t\t\t\ttarget.style.top = `${y}px`;\n\t\t\t\t});\n\t\t\t}),\n\t\t);\n\t}\n}\n\n/**\n * Speed up MutationObserver by debouncing and only running when page is visible\n * @return new MutaionObserver\n */\ntype Attr = string | string[];\nexport function onMutation(\n\tcallback: (observer: MutationObserver) => void,\n\tattr: Attr | { attr: Attr; root?: HTMLElement; delay?: number },\n) {\n\tlet queue = 0;\n\tconst opt = Array.isArray(attr) || typeof attr === \"string\" ? { attr } : attr;\n\tconst onFrame = () => setTimeout(onTimer, opt?.delay ?? 200); // Use both requestAnimationFrame and setTimeout to debounce and only run when visible\n\tconst onTimer = () => {\n\t\tif (!isBrowser()) return cleanup(); // If using JSDOM, the document might have been removed\n\t\tcallback(observer);\n\t\tobserver.takeRecords(); // Clear records to avoid running callback multiple times\n\t\tqueue = 0;\n\t};\n\tconst observer = new MutationObserver(() => {\n\t\tif (!queue) queue = requestAnimationFrame(onFrame);\n\t});\n\tconst cleanup = () => {\n\t\ttry {\n\t\t\tobserver.disconnect();\n\t\t} catch (_) {\n\t\t\t// No more observer\n\t\t}\n\t};\n\n\tobserver.observe(opt?.root || document.documentElement, {\n\t\tattributeFilter: ([] as string[]).concat(opt.attr),\n\t\tattributes: true,\n\t\tchildList: true,\n\t\tsubtree: true,\n\t});\n\n\tcallback(observer); // Initial run\n\treturn cleanup;\n}\n\nexport function onResize(callback: ResizeObserverCallback, element: Element) {\n\tconst resize = new ResizeObserver(callback);\n\tresize.observe(element);\n\treturn () => resize.disconnect();\n}\n\n/**\n * isInputLike\n * @description Check if element is an input like element\n * @param el The element to check\n * @returns True if the element is an input like element\n */\nexport const isInputLike = (el: unknown): el is HTMLInputElement =>\n\tel instanceof HTMLElement &&\n\t\"validity\" in el &&\n\t!(el instanceof HTMLButtonElement);\n\n/**\n * toCustomElementProps\n * @description Utility to quickly convert props to custom element attributes\n * @param props The props to convert\n * @returns The converted props\n */\nconst SELECTED = \"aria-selected\";\nexport const toCustomElementProps = <T extends Record<string, unknown>>(\n\trest: T,\n\tklass?: string,\n) =>\n\tObject.assign({}, rest, {\n\t\tsuppressHydrationWarning: true, // Make Next.js happy\n\t\t[SELECTED]:\n\t\t\trest[SELECTED] === undefined\n\t\t\t\t? undefined\n\t\t\t\t: (`${(rest[SELECTED] || \"false\") !== \"false\"}` as unknown as boolean), // Ensure aria-selected boolean is string\n\t\tclass: clsx(klass, rest.className as string), // Use class instead of className\n\t\thidden: !!rest.hidden, // Ensure boolean prop behaviour\n\t\topen: !!rest.open, // Ensure boolean prop behaviour\n\t});\n\n/**\n * tag\n * @description creates element and assigns properties\n * @param tagName The tagname of element to create\n * @param attrs Optional attributes to add to the element\n * @param text Optional text content to add to the element\n * @return HTMLElement with props\n */\nexport const tag = <TagName extends keyof HTMLElementTagNameMap>(\n\ttagName: TagName,\n\tattrs?: Record<string, string | null> | null,\n\ttext?: string | null,\n): HTMLElementTagNameMap[TagName] => {\n\tconst el = document.createElement(tagName);\n\tif (text) el.textContent = text;\n\tif (attrs) for (const [key, val] of Object.entries(attrs)) attr(el, key, val);\n\treturn el;\n};\n\n// Make sure we have a HTMLElement to extend (for server side rendering)\nexport const MTDSElement =\n\ttypeof HTMLElement === \"undefined\"\n\t\t? (class {} as typeof HTMLElement)\n\t\t: HTMLElement;\n\n/**\n * defineElement\n * @description Defines a customElement if running in browser and if not already registered\n */\nexport const defineElement = (\n\tname: string,\n\tinstance: CustomElementConstructor,\n) =>\n\t!isBrowser() ||\n\twindow.customElements.get(name) ||\n\twindow.customElements.define(name, instance);\n"],"names":["attr"],"mappings":";;;AAWO,MAAM,cAAc,EAAE,SAAS,MAAM,SAAS,KAAA;AAC9C,MAAM,YAAY,MACxB,OAAO,WAAW,eAAe,OAAO,aAAa;AAE/C,SAAS,SACf,UACA,OACC;AACD,MAAI;AAEJ,SAAO,YAA4B,MAAS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AAAA,EACf,MAAM,CAAC,CAAC,KAAK;AAAA;AACd,CAAC;AAUK,MAAM,MAAM,CAClB,SACA,OACA,SACoC;AACpC,QAAM,KAAK,SAAS,cAAc,OAAO;AACzC,MAAI,SAAS,cAAc;AAC3B,MAAI,MAAO,YAAW,CAAC,KAAK,GAAG,KAAK,OAAO,QAAQ,KAAK,EAAG,MAAK,IAAI,KAAK,GAAG;AAC5E,SAAO;AACR;AAGO,MAAM,cACZ,OAAO,gBAAgB,cACnB,MAAM;AAAC,IACR;AAMG,MAAM,gBAAgB,CAC5B,MACA,aAEA,CAAC,eACD,OAAO,eAAe,IAAI,IAAI,KAC9B,OAAO,eAAe,OAAO,MAAM,QAAQ;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export type ValidationProps = React.ComponentPropsWithoutRef<"div">;
|
|
2
|
-
export declare const Validation:
|
|
2
|
+
export declare const Validation: import('react').ForwardRefExoticComponent<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
import
|
|
3
|
-
import { forwardRef
|
|
4
|
-
import
|
|
5
|
-
const
|
|
6
|
-
function({ className
|
|
7
|
-
return /* @__PURE__ */
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import styles from "../styles.module.css.js";
|
|
5
|
+
const Validation = forwardRef(
|
|
6
|
+
function Validation2({ className, ...rest }, ref) {
|
|
7
|
+
return /* @__PURE__ */ jsx(
|
|
8
8
|
"div",
|
|
9
9
|
{
|
|
10
|
-
suppressHydrationWarning:
|
|
11
|
-
className:
|
|
12
|
-
ref
|
|
13
|
-
...
|
|
10
|
+
suppressHydrationWarning: true,
|
|
11
|
+
className: clsx(styles.validation, className),
|
|
12
|
+
ref,
|
|
13
|
+
...rest
|
|
14
14
|
}
|
|
15
15
|
);
|
|
16
16
|
}
|
|
17
17
|
);
|
|
18
18
|
export {
|
|
19
|
-
|
|
19
|
+
Validation
|
|
20
20
|
};
|
|
21
21
|
//# sourceMappingURL=validation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sources":["../../designsystem/validation/validation.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { forwardRef } from \"react\";\nimport styles from \"../styles.module.css\";\n\nexport type ValidationProps = React.ComponentPropsWithoutRef<\"div\">;\n\nexport const Validation = forwardRef<HTMLDivElement, ValidationProps>(\n\tfunction Validation({ className, ...rest }, ref) {\n\t\treturn (\n\t\t\t<div\n\t\t\t\tsuppressHydrationWarning // Prevent hydration mismatch for SSR due to field-observer.ts\n\t\t\t\tclassName={clsx(styles.validation, className)}\n\t\t\t\tref={ref}\n\t\t\t\t{...rest}\n\t\t\t/>\n\t\t);\n\t},\n);\n"],"names":["Validation"
|
|
1
|
+
{"version":3,"file":"validation.js","sources":["../../designsystem/validation/validation.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { forwardRef } from \"react\";\nimport styles from \"../styles.module.css\";\n\nexport type ValidationProps = React.ComponentPropsWithoutRef<\"div\">;\n\nexport const Validation = forwardRef<HTMLDivElement, ValidationProps>(\n\tfunction Validation({ className, ...rest }, ref) {\n\t\treturn (\n\t\t\t<div\n\t\t\t\tsuppressHydrationWarning // Prevent hydration mismatch for SSR due to field-observer.ts\n\t\t\t\tclassName={clsx(styles.validation, className)}\n\t\t\t\tref={ref}\n\t\t\t\t{...rest}\n\t\t\t/>\n\t\t);\n\t},\n);\n"],"names":["Validation"],"mappings":";;;;AAMO,MAAM,aAAa;AAAA,EACzB,SAASA,YAAW,EAAE,WAAW,GAAG,KAAA,GAAQ,KAAK;AAChD,WACC;AAAA,MAAC;AAAA,MAAA;AAAA,QACA,0BAAwB;AAAA,QACxB,WAAW,KAAK,OAAO,YAAY,SAAS;AAAA,QAC5C;AAAA,QACC,GAAG;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AACD;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mattilsynet/design",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.26",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,6 +28,10 @@
|
|
|
28
28
|
"import": "./mtds/atlas.js",
|
|
29
29
|
"types": "./mtds/atlas.d.ts"
|
|
30
30
|
},
|
|
31
|
+
"./atlas/react": {
|
|
32
|
+
"import": "./mtds/react-atlas.js",
|
|
33
|
+
"types": "./mtds/react-atlas.d.ts"
|
|
34
|
+
},
|
|
31
35
|
"./*.svg": "./mtds/*.svg",
|
|
32
36
|
"./*.ico": "./mtds/*.ico",
|
|
33
37
|
"./icons/*": "./mtds/icons/*",
|
|
@@ -50,31 +54,33 @@
|
|
|
50
54
|
"storybook:build": "npm run build && storybook build"
|
|
51
55
|
},
|
|
52
56
|
"devDependencies": {
|
|
53
|
-
"@biomejs/biome": "2.3.
|
|
57
|
+
"@biomejs/biome": "2.3.8",
|
|
54
58
|
"@digdir/designsystemet-css": "^1.7.3",
|
|
55
|
-
"@handsontable/react-wrapper": "^16.
|
|
59
|
+
"@handsontable/react-wrapper": "^16.2.0",
|
|
56
60
|
"@phosphor-icons/core": "^2.1.1",
|
|
57
61
|
"@phosphor-icons/react": "^2.1.10",
|
|
58
|
-
"@storybook/addon-docs": "^10.
|
|
59
|
-
"@storybook/addon-themes": "^10.
|
|
60
|
-
"@storybook/react-vite": "^10.
|
|
62
|
+
"@storybook/addon-docs": "^10.1.2",
|
|
63
|
+
"@storybook/addon-themes": "^10.1.2",
|
|
64
|
+
"@storybook/react-vite": "^10.1.2",
|
|
61
65
|
"@tanstack/react-table": "^8.21.3",
|
|
66
|
+
"@turf/boolean-point-in-polygon": "^7.3.1",
|
|
67
|
+
"@turf/helpers": "^7.3.1",
|
|
62
68
|
"@types/leaflet": "^1.9.21",
|
|
63
69
|
"@types/leaflet.markercluster": "^1.5.6",
|
|
64
70
|
"@types/node": "^24.10.1",
|
|
65
|
-
"@types/react": "^19.2.
|
|
71
|
+
"@types/react": "^19.2.7",
|
|
66
72
|
"@types/react-dom": "^19.2.3",
|
|
67
73
|
"@vitejs/plugin-react": "^5.1.1",
|
|
68
74
|
"fast-glob": "^3.3.3",
|
|
69
|
-
"handsontable": "^16.
|
|
75
|
+
"handsontable": "^16.2.0",
|
|
70
76
|
"leaflet": "^2.0.0-alpha.1",
|
|
71
77
|
"postcss": "^8.5.6",
|
|
72
78
|
"postcss-nesting": "^13.0.2",
|
|
73
79
|
"react": "^19.2.0",
|
|
74
80
|
"react-dom": "^19.2.0",
|
|
75
|
-
"storybook": "^10.
|
|
81
|
+
"storybook": "^10.1.2",
|
|
76
82
|
"typescript": "^5.9.3",
|
|
77
|
-
"vite": "^7.2.
|
|
83
|
+
"vite": "^7.2.6",
|
|
78
84
|
"vite-plugin-dts": "^4.5.4"
|
|
79
85
|
},
|
|
80
86
|
"dependencies": {
|