@mattilsynet/design 2.2.24 → 2.2.25
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 +163 -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 +8 -14
- package/mtds/atlas/atlas-element.js +90 -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 +69 -0
- package/mtds/atlas/atlas-marker.js.map +1 -0
- package/mtds/atlas/atlas-matgeo.d.ts +29 -0
- package/mtds/atlas/atlas-matgeo.js +71 -0
- package/mtds/atlas/atlas-matgeo.js.map +1 -0
- package/mtds/atlas/atlas.css.js +76 -96
- package/mtds/atlas/atlas.css.js.map +1 -1
- package/mtds/atlas/atlas.d.ts +42 -0
- package/mtds/atlas/atlas.js +33 -0
- package/mtds/atlas/atlas.js.map +1 -0
- package/mtds/atlas/atlas.stories.d.ts +5 -1
- package/mtds/atlas/cluster.js +1576 -697
- package/mtds/atlas/cluster.js.map +1 -1
- package/mtds/atlas.iife.js +80 -100
- package/mtds/atlas.js +8 -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/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/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 +37 -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 +13 -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 +14 -10
package/mtds/atlas.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import { MTDSAtlasElement
|
|
2
|
-
import {
|
|
1
|
+
import { MTDSAtlasElement } from "./atlas/atlas-element.js";
|
|
2
|
+
import { MTDSAtlasMarkerElement } from "./atlas/atlas-marker.js";
|
|
3
|
+
import { MTDSAtlasMatgeoElement } from "./atlas/atlas-matgeo.js";
|
|
4
|
+
import { default as default2 } from "./external/leaflet/dist/leaflet-src.js";
|
|
3
5
|
export {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
default2 as L,
|
|
7
|
+
MTDSAtlasElement,
|
|
8
|
+
MTDSAtlasMarkerElement,
|
|
9
|
+
MTDSAtlasMatgeoElement
|
|
6
10
|
};
|
|
7
11
|
//# sourceMappingURL=atlas.js.map
|
package/mtds/atlas.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"atlas.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"atlas.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
package/mtds/avatar/avatar.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
import
|
|
3
|
-
import { forwardRef
|
|
4
|
-
import
|
|
5
|
-
const
|
|
6
|
-
const
|
|
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 Avatar = forwardRef(function Avatar2({ as, className, ...rest }, ref) {
|
|
6
|
+
const Tag = as || (rest.href ? "a" : "span");
|
|
7
|
+
return /* @__PURE__ */ jsx(Tag, { className: clsx(styles.avatar, className), ref, ...rest });
|
|
8
8
|
});
|
|
9
9
|
export {
|
|
10
|
-
|
|
10
|
+
Avatar
|
|
11
11
|
};
|
|
12
12
|
//# sourceMappingURL=avatar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avatar.js","sources":["../../designsystem/avatar/avatar.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\ntype AvatarBaseProps<Href> = {\n\thref?: Href;\n};\n\nexport type AvatarProps<\n\tHref,\n\tAs extends React.ElementType = Href extends string ? \"a\" : \"span\",\n> = PolymorphicComponentPropWithRef<As, AvatarBaseProps<Href>>;\n\ntype AvatarComponent = <\n\tHref,\n\tAs extends React.ElementType = Href extends string ? \"a\" : \"span\",\n>(\n\tprops: AvatarProps<Href, As>,\n) => JSX.Element;\n\nexport const Avatar: AvatarComponent = forwardRef<null>(function Avatar<\n\tHref,\n\tAs extends React.ElementType = Href extends string ? \"a\" : \"span\",\n>({ as, className, ...rest }: AvatarProps<Href, As>, ref?: PolymorphicRef<As>) {\n\tconst Tag = as || (rest.href ? \"a\" : \"span\");\n\n\treturn <Tag className={clsx(styles.avatar, className)} ref={ref} {...rest} />;\n}) as AvatarComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n"],"names":["Avatar"
|
|
1
|
+
{"version":3,"file":"avatar.js","sources":["../../designsystem/avatar/avatar.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\ntype AvatarBaseProps<Href> = {\n\thref?: Href;\n};\n\nexport type AvatarProps<\n\tHref,\n\tAs extends React.ElementType = Href extends string ? \"a\" : \"span\",\n> = PolymorphicComponentPropWithRef<As, AvatarBaseProps<Href>>;\n\ntype AvatarComponent = <\n\tHref,\n\tAs extends React.ElementType = Href extends string ? \"a\" : \"span\",\n>(\n\tprops: AvatarProps<Href, As>,\n) => JSX.Element;\n\nexport const Avatar: AvatarComponent = forwardRef<null>(function Avatar<\n\tHref,\n\tAs extends React.ElementType = Href extends string ? \"a\" : \"span\",\n>({ as, className, ...rest }: AvatarProps<Href, As>, ref?: PolymorphicRef<As>) {\n\tconst Tag = as || (rest.href ? \"a\" : \"span\");\n\n\treturn <Tag className={clsx(styles.avatar, className)} ref={ref} {...rest} />;\n}) as AvatarComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n"],"names":["Avatar"],"mappings":";;;;AAwBO,MAAM,SAA0B,WAAiB,SAASA,QAG/D,EAAE,IAAI,WAAW,GAAG,KAAA,GAA+B,KAA0B;AAC9E,QAAM,MAAM,OAAO,KAAK,OAAO,MAAM;AAErC,SAAO,oBAAC,KAAA,EAAI,WAAW,KAAK,OAAO,QAAQ,SAAS,GAAG,KAAW,GAAG,KAAA,CAAM;AAC5E,CAAC;"}
|
package/mtds/badge/badge.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type BadgeProps = React.ComponentPropsWithoutRef<"span"> & {
|
|
2
2
|
"data-badge"?: string | number | boolean;
|
|
3
3
|
};
|
|
4
|
-
export declare const Badge:
|
|
4
|
+
export declare const Badge: import('react').ForwardRefExoticComponent<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
|
|
5
5
|
"data-badge"?: string | number | boolean;
|
|
6
|
-
} &
|
|
6
|
+
} & import('react').RefAttributes<HTMLSpanElement>>;
|
package/mtds/badge/badge.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
import
|
|
3
|
-
import { forwardRef
|
|
4
|
-
import
|
|
5
|
-
const
|
|
6
|
-
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 Badge = forwardRef(function Badge2({ className, ...rest }, ref) {
|
|
6
|
+
return /* @__PURE__ */ jsx("span", { className: clsx(styles.badge, className), ref, ...rest });
|
|
7
7
|
});
|
|
8
8
|
export {
|
|
9
|
-
|
|
9
|
+
Badge
|
|
10
10
|
};
|
|
11
11
|
//# sourceMappingURL=badge.js.map
|
package/mtds/badge/badge.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"badge.js","sources":["../../designsystem/badge/badge.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { forwardRef } from \"react\";\nimport styles from \"../styles.module.css\";\n\nexport type BadgeProps = React.ComponentPropsWithoutRef<\"span\"> & {\n\t\"data-badge\"?: string | number | boolean;\n};\n\nexport const Badge = forwardRef<HTMLSpanElement, BadgeProps>(function Badge(\n\t{ className, ...rest },\n\tref,\n) {\n\treturn <span className={clsx(styles.badge, className)} ref={ref} {...rest} />;\n});\n"],"names":["Badge"
|
|
1
|
+
{"version":3,"file":"badge.js","sources":["../../designsystem/badge/badge.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { forwardRef } from \"react\";\nimport styles from \"../styles.module.css\";\n\nexport type BadgeProps = React.ComponentPropsWithoutRef<\"span\"> & {\n\t\"data-badge\"?: string | number | boolean;\n};\n\nexport const Badge = forwardRef<HTMLSpanElement, BadgeProps>(function Badge(\n\t{ className, ...rest },\n\tref,\n) {\n\treturn <span className={clsx(styles.badge, className)} ref={ref} {...rest} />;\n});\n"],"names":["Badge"],"mappings":";;;;AAQO,MAAM,QAAQ,WAAwC,SAASA,OACrE,EAAE,WAAW,GAAG,KAAA,GAChB,KACC;AACD,SAAO,oBAAC,QAAA,EAAK,WAAW,KAAK,OAAO,OAAO,SAAS,GAAG,KAAW,GAAG,KAAA,CAAM;AAC5E,CAAC;"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import styles from "../styles.module.css.js";
|
|
2
|
+
import { isBrowser, onLoaded, onMutation, attr } from "../utils.js";
|
|
3
|
+
const CSS_BREADCRUMBS = styles.breadcrumbs.split(" ")[0];
|
|
4
|
+
const BREADCRUMBS = isBrowser() ? document.getElementsByClassName(CSS_BREADCRUMBS) : [];
|
|
5
|
+
function handleBreadcrumbsMutation() {
|
|
6
|
+
if (BREADCRUMBS)
|
|
7
|
+
for (const breadcumbs of BREADCRUMBS)
|
|
8
|
+
breadcumbs.querySelectorAll("a").forEach((crumb, index, { length }) => {
|
|
9
|
+
attr(crumb, "aria-current", index === length - 1 ? "page" : null);
|
|
9
10
|
});
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
+
onLoaded(() => [onMutation(handleBreadcrumbsMutation, "class")]);
|
|
12
13
|
//# sourceMappingURL=breadcrumbs-observer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"breadcrumbs-observer.js","sources":["../../designsystem/breadcrumbs/breadcrumbs-observer.ts"],"sourcesContent":["import styles from \"../styles.module.css\";\nimport { attr,
|
|
1
|
+
{"version":3,"file":"breadcrumbs-observer.js","sources":["../../designsystem/breadcrumbs/breadcrumbs-observer.ts"],"sourcesContent":["import styles from \"../styles.module.css\";\nimport { attr, isBrowser, onLoaded, onMutation } from \"../utils\";\n\nconst CSS_BREADCRUMBS = styles.breadcrumbs.split(\" \")[0];\nconst BREADCRUMBS = isBrowser()\n\t? document.getElementsByClassName(CSS_BREADCRUMBS)\n\t: [];\n\nfunction handleBreadcrumbsMutation() {\n\tif (BREADCRUMBS)\n\t\tfor (const breadcumbs of BREADCRUMBS)\n\t\t\tbreadcumbs.querySelectorAll(\"a\").forEach((crumb, index, { length }) => {\n\t\t\t\tattr(crumb, \"aria-current\", index === length - 1 ? \"page\" : null);\n\t\t\t});\n}\n\nonLoaded(() => [onMutation(handleBreadcrumbsMutation, \"class\")]);\n"],"names":[],"mappings":";;AAGA,MAAM,kBAAkB,OAAO,YAAY,MAAM,GAAG,EAAE,CAAC;AACvD,MAAM,cAAc,UAAA,IACjB,SAAS,uBAAuB,eAAe,IAC/C,CAAA;AAEH,SAAS,4BAA4B;AACpC,MAAI;AACH,eAAW,cAAc;AACxB,iBAAW,iBAAiB,GAAG,EAAE,QAAQ,CAAC,OAAO,OAAO,EAAE,aAAa;AACtE,aAAK,OAAO,gBAAgB,UAAU,SAAS,IAAI,SAAS,IAAI;AAAA,MACjE,CAAC;AACJ;AAEA,SAAS,MAAM,CAAC,WAAW,2BAA2B,OAAO,CAAC,CAAC;"}
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
import
|
|
3
|
-
import { forwardRef
|
|
4
|
-
import
|
|
5
|
-
const
|
|
6
|
-
function({ as
|
|
7
|
-
|
|
8
|
-
|
|
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 Breadcrumbs = forwardRef(
|
|
6
|
+
function Breadcrumbs2({ as, className, ...rest }, ref) {
|
|
7
|
+
const Tag = as || "nav";
|
|
8
|
+
return /* @__PURE__ */ jsx(
|
|
9
|
+
Tag,
|
|
9
10
|
{
|
|
10
|
-
"aria-label":
|
|
11
|
-
className:
|
|
12
|
-
ref
|
|
13
|
-
...
|
|
11
|
+
"aria-label": rest["aria-label"] || "Du er her:",
|
|
12
|
+
className: clsx(styles.breadcrumbs, className),
|
|
13
|
+
ref,
|
|
14
|
+
...rest
|
|
14
15
|
}
|
|
15
16
|
);
|
|
16
17
|
}
|
|
17
18
|
);
|
|
18
19
|
export {
|
|
19
|
-
|
|
20
|
+
Breadcrumbs
|
|
20
21
|
};
|
|
21
22
|
//# sourceMappingURL=breadcrumbs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"breadcrumbs.js","sources":["../../designsystem/breadcrumbs/breadcrumbs.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { forwardRef, type JSX } from \"react\";\nimport type {\n\tPolymorphicComponentPropWithRef,\n\tPolymorphicRef,\n} from \"../react-types\";\nimport styles from \"../styles.module.css\";\n\nexport type BreadcrumbsProps<As extends React.ElementType = \"nav\"> =\n\tPolymorphicComponentPropWithRef<As, { \"aria-label\"?: string }>;\n\ntype BreadcrumbsComponent = <As extends React.ElementType = \"nav\">(\n\tprops: BreadcrumbsProps<As>,\n) => JSX.Element;\n\nexport const Breadcrumbs: BreadcrumbsComponent = forwardRef<null>(\n\tfunction Breadcrumbs<As extends React.ElementType = \"nav\">(\n\t\t{ as, className, ...rest }: BreadcrumbsProps<As>,\n\t\tref?: PolymorphicRef<As>,\n\t) {\n\t\tconst Tag = as || \"nav\";\n\n\t\treturn (\n\t\t\t<Tag\n\t\t\t\taria-label={rest[\"aria-label\"] || \"Du er her:\"}\n\t\t\t\tclassName={clsx(styles.breadcrumbs, className)}\n\t\t\t\tref={ref}\n\t\t\t\t{...rest}\n\t\t\t/>\n\t\t);\n\t},\n) as BreadcrumbsComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n"],"names":["Breadcrumbs"
|
|
1
|
+
{"version":3,"file":"breadcrumbs.js","sources":["../../designsystem/breadcrumbs/breadcrumbs.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { forwardRef, type JSX } from \"react\";\nimport type {\n\tPolymorphicComponentPropWithRef,\n\tPolymorphicRef,\n} from \"../react-types\";\nimport styles from \"../styles.module.css\";\n\nexport type BreadcrumbsProps<As extends React.ElementType = \"nav\"> =\n\tPolymorphicComponentPropWithRef<As, { \"aria-label\"?: string }>;\n\ntype BreadcrumbsComponent = <As extends React.ElementType = \"nav\">(\n\tprops: BreadcrumbsProps<As>,\n) => JSX.Element;\n\nexport const Breadcrumbs: BreadcrumbsComponent = forwardRef<null>(\n\tfunction Breadcrumbs<As extends React.ElementType = \"nav\">(\n\t\t{ as, className, ...rest }: BreadcrumbsProps<As>,\n\t\tref?: PolymorphicRef<As>,\n\t) {\n\t\tconst Tag = as || \"nav\";\n\n\t\treturn (\n\t\t\t<Tag\n\t\t\t\taria-label={rest[\"aria-label\"] || \"Du er her:\"}\n\t\t\t\tclassName={clsx(styles.breadcrumbs, className)}\n\t\t\t\tref={ref}\n\t\t\t\t{...rest}\n\t\t\t/>\n\t\t);\n\t},\n) as BreadcrumbsComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n"],"names":["Breadcrumbs"],"mappings":";;;;AAeO,MAAM,cAAoC;AAAA,EAChD,SAASA,aACR,EAAE,IAAI,WAAW,GAAG,KAAA,GACpB,KACC;AACD,UAAM,MAAM,MAAM;AAElB,WACC;AAAA,MAAC;AAAA,MAAA;AAAA,QACA,cAAY,KAAK,YAAY,KAAK;AAAA,QAClC,WAAW,KAAK,OAAO,aAAa,SAAS;AAAA,QAC7C;AAAA,QACC,GAAG;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AACD;"}
|
package/mtds/button/button.js
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
import
|
|
3
|
-
import { forwardRef
|
|
4
|
-
import
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
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 Button = forwardRef(function Button2({ as, className, type, ...rest }, ref) {
|
|
6
|
+
const Tag = as || (rest.href ? "a" : "button");
|
|
7
|
+
if (Tag === "button" && rest["aria-busy"])
|
|
8
|
+
rest.disabled = true;
|
|
9
|
+
return /* @__PURE__ */ jsx(
|
|
10
|
+
Tag,
|
|
9
11
|
{
|
|
10
|
-
suppressHydrationWarning:
|
|
11
|
-
className:
|
|
12
|
-
type:
|
|
13
|
-
ref
|
|
14
|
-
...
|
|
12
|
+
suppressHydrationWarning: true,
|
|
13
|
+
className: clsx(styles.button, className),
|
|
14
|
+
type: type ?? (Tag === "button" ? Tag : void 0),
|
|
15
|
+
ref,
|
|
16
|
+
...rest
|
|
15
17
|
}
|
|
16
18
|
);
|
|
17
19
|
});
|
|
18
20
|
export {
|
|
19
|
-
|
|
21
|
+
Button
|
|
20
22
|
};
|
|
21
23
|
//# sourceMappingURL=button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.js","sources":["../../designsystem/button/button.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\ntype ButtonBaseProps<Href> = {\n\t\"data-arrow\"?: \"left\" | \"right\" | true;\n\t\"data-justify\"?: \"start\" | \"center\" | \"end\" | \"right\" | \"left\";\n\t\"data-nowrap\"?: boolean;\n\t\"data-variant\"?: \"primary\" | \"secondary\" | \"tertiary\";\n\t\"data-command\"?: string;\n\thref?: Href;\n\tpopovertarget?: string;\n\tpopovertargetaction?: string;\n};\n\nexport type ButtonProps<\n\tHref,\n\tAs extends React.ElementType = Href extends string ? \"a\" : \"button\",\n> = PolymorphicComponentPropWithRef<As, ButtonBaseProps<Href>>;\n\ntype ButtonElement = ButtonProps<null, \"button\">;\ntype ButtonComponent = <\n\tHref,\n\tAs extends React.ElementType = Href extends string ? \"a\" : \"button\",\n>(\n\tprops: ButtonProps<Href, As>,\n) => JSX.Element;\n\nexport const Button: ButtonComponent = forwardRef<null>(function Button<\n\tHref,\n\tAs extends React.ElementType = Href extends string ? \"a\" : \"button\",\n>(\n\t{ as, className, type, ...rest }: ButtonProps<Href, As>,\n\tref?: PolymorphicRef<As>,\n) {\n\tconst Tag = as || (rest.href ? \"a\" : \"button\");\n\n\tif (Tag === \"button\" && (rest as ButtonElement)[\"aria-busy\"])\n\t\t(rest as ButtonElement).disabled = true; // Automatically disable button if aria-busy is set\n\n\treturn (\n\t\t<Tag\n\t\t\tsuppressHydrationWarning // aria-label might change on client when using data-tooltip\n\t\t\tclassName={clsx(styles.button, className)}\n\t\t\ttype={type ?? (Tag === \"button\" ? Tag : undefined)} // Default to type=\"button\" if not set and tag is button\n\t\t\tref={ref}\n\t\t\t{...rest}\n\t\t/>\n\t);\n}) as ButtonComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n"],"names":["Button"
|
|
1
|
+
{"version":3,"file":"button.js","sources":["../../designsystem/button/button.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\ntype ButtonBaseProps<Href> = {\n\t\"data-arrow\"?: \"left\" | \"right\" | true;\n\t\"data-justify\"?: \"start\" | \"center\" | \"end\" | \"right\" | \"left\";\n\t\"data-nowrap\"?: boolean;\n\t\"data-variant\"?: \"primary\" | \"secondary\" | \"tertiary\";\n\t\"data-command\"?: string;\n\thref?: Href;\n\tpopovertarget?: string;\n\tpopovertargetaction?: string;\n};\n\nexport type ButtonProps<\n\tHref,\n\tAs extends React.ElementType = Href extends string ? \"a\" : \"button\",\n> = PolymorphicComponentPropWithRef<As, ButtonBaseProps<Href>>;\n\ntype ButtonElement = ButtonProps<null, \"button\">;\ntype ButtonComponent = <\n\tHref,\n\tAs extends React.ElementType = Href extends string ? \"a\" : \"button\",\n>(\n\tprops: ButtonProps<Href, As>,\n) => JSX.Element;\n\nexport const Button: ButtonComponent = forwardRef<null>(function Button<\n\tHref,\n\tAs extends React.ElementType = Href extends string ? \"a\" : \"button\",\n>(\n\t{ as, className, type, ...rest }: ButtonProps<Href, As>,\n\tref?: PolymorphicRef<As>,\n) {\n\tconst Tag = as || (rest.href ? \"a\" : \"button\");\n\n\tif (Tag === \"button\" && (rest as ButtonElement)[\"aria-busy\"])\n\t\t(rest as ButtonElement).disabled = true; // Automatically disable button if aria-busy is set\n\n\treturn (\n\t\t<Tag\n\t\t\tsuppressHydrationWarning // aria-label might change on client when using data-tooltip\n\t\t\tclassName={clsx(styles.button, className)}\n\t\t\ttype={type ?? (Tag === \"button\" ? Tag : undefined)} // Default to type=\"button\" if not set and tag is button\n\t\t\tref={ref}\n\t\t\t{...rest}\n\t\t/>\n\t);\n}) as ButtonComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n"],"names":["Button"],"mappings":";;;;AAgCO,MAAM,SAA0B,WAAiB,SAASA,QAIhE,EAAE,IAAI,WAAW,MAAM,GAAG,KAAA,GAC1B,KACC;AACD,QAAM,MAAM,OAAO,KAAK,OAAO,MAAM;AAErC,MAAI,QAAQ,YAAa,KAAuB,WAAW;AACzD,SAAuB,WAAW;AAEpC,SACC;AAAA,IAAC;AAAA,IAAA;AAAA,MACA,0BAAwB;AAAA,MACxB,WAAW,KAAK,OAAO,QAAQ,SAAS;AAAA,MACxC,MAAM,SAAS,QAAQ,WAAW,MAAM;AAAA,MACxC;AAAA,MACC,GAAG;AAAA,IAAA;AAAA,EAAA;AAGP,CAAC;"}
|
package/mtds/card/card.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
import
|
|
3
|
-
import { forwardRef
|
|
4
|
-
import
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
return /* @__PURE__ */
|
|
8
|
-
})
|
|
9
|
-
|
|
10
|
-
|
|
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 Card = forwardRef(function Card2({ as, className, ...rest }, ref) {
|
|
6
|
+
const Tag = as || (rest.href ? "a" : "div");
|
|
7
|
+
return /* @__PURE__ */ jsx(Tag, { className: clsx(styles.card, className), ref, ...rest });
|
|
8
|
+
});
|
|
9
|
+
const Group = forwardRef(function Group2({ as, className, ...rest }, ref) {
|
|
10
|
+
const Tag = as || "div";
|
|
11
|
+
if (Tag === "button" && !rest.type) Object.assign(rest, { type: "button" });
|
|
12
|
+
return /* @__PURE__ */ jsx(Tag, { className: clsx(styles.group, className), ref, ...rest });
|
|
11
13
|
});
|
|
12
14
|
export {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
Card,
|
|
16
|
+
Group
|
|
15
17
|
};
|
|
16
18
|
//# sourceMappingURL=card.js.map
|
package/mtds/card/card.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card.js","sources":["../../designsystem/card/card.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { forwardRef, type JSX } from \"react\";\nimport type {\n\tPolymorphicComponentPropWithRef,\n\tPolymorphicRef,\n\tSizes,\n} from \"../react-types\";\nimport styles from \"../styles.module.css\";\n\ntype CardBaseProps<Href> = {\n\t\"data-pad\"?: Sizes;\n\thref?: Href;\n};\n\nexport type CardProps<\n\tHref,\n\tAs extends React.ElementType = Href extends string ? \"a\" : \"div\",\n> = PolymorphicComponentPropWithRef<As, CardBaseProps<Href>>;\n\ntype CardComponent = <\n\tHref,\n\tAs extends React.ElementType = Href extends string ? \"a\" : \"div\",\n>(\n\tprops: CardProps<Href, As>,\n) => JSX.Element;\n\nexport const Card: CardComponent = forwardRef<null>(function Card<\n\tHref,\n\tAs extends React.ElementType = Href extends string ? \"a\" : \"div\",\n>({ as, className, ...rest }: CardProps<Href, As>, ref?: PolymorphicRef<As>) {\n\tconst Tag = as || (rest.href ? \"a\" : \"div\");\n\n\treturn <Tag className={clsx(styles.card, className)} ref={ref} {...rest} />;\n}) as CardComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n\nexport type GroupProps<As extends React.ElementType = \"div\"> =\n\tPolymorphicComponentPropWithRef<As, { \"data-pad\"?: Sizes }>;\n\ntype GroupComponent = <As extends React.ElementType = \"div\">(\n\tprops: GroupProps<As>,\n) => JSX.Element;\n\nexport const Group: GroupComponent = forwardRef<null>(function Group<\n\tAs extends React.ElementType = \"div\",\n>({ as, className, ...rest }: GroupProps<As>, ref?: PolymorphicRef<As>) {\n\tconst Tag = as || \"div\";\n\tif (Tag === \"button\" && !rest.type) Object.assign(rest, { type: \"button\" }); // Default type for button to avoid accidental submits\n\treturn <Tag className={clsx(styles.group, className)} ref={ref} {...rest} />;\n}) as GroupComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n"],"names":["Card","
|
|
1
|
+
{"version":3,"file":"card.js","sources":["../../designsystem/card/card.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { forwardRef, type JSX } from \"react\";\nimport type {\n\tPolymorphicComponentPropWithRef,\n\tPolymorphicRef,\n\tSizes,\n} from \"../react-types\";\nimport styles from \"../styles.module.css\";\n\ntype CardBaseProps<Href> = {\n\t\"data-pad\"?: Sizes;\n\thref?: Href;\n};\n\nexport type CardProps<\n\tHref,\n\tAs extends React.ElementType = Href extends string ? \"a\" : \"div\",\n> = PolymorphicComponentPropWithRef<As, CardBaseProps<Href>>;\n\ntype CardComponent = <\n\tHref,\n\tAs extends React.ElementType = Href extends string ? \"a\" : \"div\",\n>(\n\tprops: CardProps<Href, As>,\n) => JSX.Element;\n\nexport const Card: CardComponent = forwardRef<null>(function Card<\n\tHref,\n\tAs extends React.ElementType = Href extends string ? \"a\" : \"div\",\n>({ as, className, ...rest }: CardProps<Href, As>, ref?: PolymorphicRef<As>) {\n\tconst Tag = as || (rest.href ? \"a\" : \"div\");\n\n\treturn <Tag className={clsx(styles.card, className)} ref={ref} {...rest} />;\n}) as CardComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n\nexport type GroupProps<As extends React.ElementType = \"div\"> =\n\tPolymorphicComponentPropWithRef<As, { \"data-pad\"?: Sizes }>;\n\ntype GroupComponent = <As extends React.ElementType = \"div\">(\n\tprops: GroupProps<As>,\n) => JSX.Element;\n\nexport const Group: GroupComponent = forwardRef<null>(function Group<\n\tAs extends React.ElementType = \"div\",\n>({ as, className, ...rest }: GroupProps<As>, ref?: PolymorphicRef<As>) {\n\tconst Tag = as || \"div\";\n\tif (Tag === \"button\" && !rest.type) Object.assign(rest, { type: \"button\" }); // Default type for button to avoid accidental submits\n\treturn <Tag className={clsx(styles.group, className)} ref={ref} {...rest} />;\n}) as GroupComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n"],"names":["Card","Group"],"mappings":";;;;AA0BO,MAAM,OAAsB,WAAiB,SAASA,MAG3D,EAAE,IAAI,WAAW,GAAG,KAAA,GAA6B,KAA0B;AAC5E,QAAM,MAAM,OAAO,KAAK,OAAO,MAAM;AAErC,SAAO,oBAAC,KAAA,EAAI,WAAW,KAAK,OAAO,MAAM,SAAS,GAAG,KAAW,GAAG,KAAA,CAAM;AAC1E,CAAC;AASM,MAAM,QAAwB,WAAiB,SAASC,OAE7D,EAAE,IAAI,WAAW,GAAG,KAAA,GAAwB,KAA0B;AACvE,QAAM,MAAM,MAAM;AAClB,MAAI,QAAQ,YAAY,CAAC,KAAK,KAAM,QAAO,OAAO,MAAM,EAAE,MAAM,SAAA,CAAU;AAC1E,SAAO,oBAAC,KAAA,EAAI,WAAW,KAAK,OAAO,OAAO,SAAS,GAAG,KAAW,GAAG,KAAA,CAAM;AAC3E,CAAC;"}
|
package/mtds/chart/chart-axis.js
CHANGED
|
@@ -1,21 +1,33 @@
|
|
|
1
|
-
import { tag
|
|
2
|
-
const
|
|
3
|
-
function
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { tag } from "../utils.js";
|
|
2
|
+
const STEPS = [0.1, 0.2, 0.25, 0.5, 1];
|
|
3
|
+
function toAxis(data, { aspect, type }) {
|
|
4
|
+
const totalTicks = 10;
|
|
5
|
+
const isStacked = type === "stacked";
|
|
6
|
+
const max = data[0].reduce((acc, _, index) => {
|
|
7
|
+
const all = data.map((row) => row[index].number);
|
|
8
|
+
const sum = all.reduce((acc2, num) => acc2 + num, 0);
|
|
9
|
+
return Math.max(acc, ...isStacked ? [sum] : all);
|
|
10
|
+
}, 0);
|
|
11
|
+
const tickRange = max / totalTicks;
|
|
12
|
+
const tickDigits = 10 ** `${Math.round(tickRange)}`.length;
|
|
13
|
+
const tickSize = tickRange / tickDigits;
|
|
14
|
+
const step = (STEPS.find((current) => current > tickSize) || 1) * tickDigits;
|
|
15
|
+
const total = Math.ceil(max / step) * step;
|
|
16
|
+
const axis = tag("div", {
|
|
17
|
+
"aria-label": data[0][0].value || null,
|
|
9
18
|
class: "axis",
|
|
10
19
|
role: "figure",
|
|
11
|
-
style: `${
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
20
|
+
style: `${aspect ? `--mtdsc-chart-aspect: ${aspect};` : ""} --bars: ${data[0]?.length - 1}; --groups: ${data.length - 1}; --total: ${total}`
|
|
21
|
+
});
|
|
22
|
+
const steps = axis.appendChild(tag("div", { class: "axisSteps" }));
|
|
23
|
+
const groups = axis.appendChild(tag("div", { class: "axisGroups" }));
|
|
24
|
+
Array.from({ length: total / step + 1 }, (_, i) => getNum(step * i)).reverse().map(
|
|
25
|
+
(num) => steps.append(tag("div", { class: "axisStep", "data-label": num }))
|
|
26
|
+
);
|
|
27
|
+
return { total, groups, axis };
|
|
16
28
|
}
|
|
17
|
-
const
|
|
29
|
+
const getNum = new Intl.NumberFormat().format;
|
|
18
30
|
export {
|
|
19
|
-
|
|
31
|
+
toAxis
|
|
20
32
|
};
|
|
21
33
|
//# sourceMappingURL=chart-axis.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart-axis.js","sources":["../../designsystem/chart/chart-axis.ts"],"sourcesContent":["import { tag } from \"../utils\";\nimport type { ChartData } from \"./chart-element\";\n\ntype Config = { type: string; aspect?: string };\n\nconst STEPS = [0.1, 0.2, 0.25, 0.5, 1];\n\nexport function toAxis(data: ChartData, { aspect, type }: Config) {\n\tconst totalTicks = 10;\n\tconst isStacked = type === \"stacked\";\n\tconst max = data[0].reduce((acc, _, index) => {\n\t\tconst all = data.map((row) => row[index].number);\n\t\tconst sum = all.reduce((acc, num) => acc + num, 0);\n\t\treturn Math.max(acc, ...(isStacked ? [sum] : all));\n\t}, 0);\n\n\tconst tickRange = max / totalTicks;\n\tconst tickDigits = 10 ** `${Math.round(tickRange)}`.length; // Get amount of digits in total number and use as exponent for 10x\n\tconst tickSize = tickRange / tickDigits; // Get amount of digits in total number and use as exponent for 10\n\tconst step = (STEPS.find((current) => current > tickSize) || 1) * tickDigits; // Find closest step larger than tick\n\tconst total = Math.ceil(max / step) * step;\n\tconst axis = tag(\"div\", {\n\t\t\"aria-label\": data[0][0].value || null,\n\t\tclass: \"axis\",\n\t\trole: \"figure\",\n\t\tstyle: `${aspect ? `--mtdsc-chart-aspect: ${aspect};` : \"\"} --bars: ${data[0]?.length - 1}; --groups: ${data.length - 1}; --total: ${total}`,\n\t});\n\tconst steps = axis.appendChild(tag(\"div\", { class: \"axisSteps\" }));\n\tconst groups = axis.appendChild(tag(\"div\", { class: \"axisGroups\" }));\n\n\tArray.from({ length: total / step + 1 }, (_, i) => getNum(step * i))\n\t\t.reverse()\n\t\t.map((num) =>\n\t\t\tsteps.append(tag(\"div\", { class: \"axisStep\", \"data-label\": num })),\n\t\t);\n\n\treturn { total, groups, axis };\n}\n\nconst getNum = new Intl.NumberFormat().format;\n"],"names":["
|
|
1
|
+
{"version":3,"file":"chart-axis.js","sources":["../../designsystem/chart/chart-axis.ts"],"sourcesContent":["import { tag } from \"../utils\";\nimport type { ChartData } from \"./chart-element\";\n\ntype Config = { type: string; aspect?: string };\n\nconst STEPS = [0.1, 0.2, 0.25, 0.5, 1];\n\nexport function toAxis(data: ChartData, { aspect, type }: Config) {\n\tconst totalTicks = 10;\n\tconst isStacked = type === \"stacked\";\n\tconst max = data[0].reduce((acc, _, index) => {\n\t\tconst all = data.map((row) => row[index].number);\n\t\tconst sum = all.reduce((acc, num) => acc + num, 0);\n\t\treturn Math.max(acc, ...(isStacked ? [sum] : all));\n\t}, 0);\n\n\tconst tickRange = max / totalTicks;\n\tconst tickDigits = 10 ** `${Math.round(tickRange)}`.length; // Get amount of digits in total number and use as exponent for 10x\n\tconst tickSize = tickRange / tickDigits; // Get amount of digits in total number and use as exponent for 10\n\tconst step = (STEPS.find((current) => current > tickSize) || 1) * tickDigits; // Find closest step larger than tick\n\tconst total = Math.ceil(max / step) * step;\n\tconst axis = tag(\"div\", {\n\t\t\"aria-label\": data[0][0].value || null,\n\t\tclass: \"axis\",\n\t\trole: \"figure\",\n\t\tstyle: `${aspect ? `--mtdsc-chart-aspect: ${aspect};` : \"\"} --bars: ${data[0]?.length - 1}; --groups: ${data.length - 1}; --total: ${total}`,\n\t});\n\tconst steps = axis.appendChild(tag(\"div\", { class: \"axisSteps\" }));\n\tconst groups = axis.appendChild(tag(\"div\", { class: \"axisGroups\" }));\n\n\tArray.from({ length: total / step + 1 }, (_, i) => getNum(step * i))\n\t\t.reverse()\n\t\t.map((num) =>\n\t\t\tsteps.append(tag(\"div\", { class: \"axisStep\", \"data-label\": num })),\n\t\t);\n\n\treturn { total, groups, axis };\n}\n\nconst getNum = new Intl.NumberFormat().format;\n"],"names":["acc"],"mappings":";AAKA,MAAM,QAAQ,CAAC,KAAK,KAAK,MAAM,KAAK,CAAC;AAE9B,SAAS,OAAO,MAAiB,EAAE,QAAQ,QAAgB;AACjE,QAAM,aAAa;AACnB,QAAM,YAAY,SAAS;AAC3B,QAAM,MAAM,KAAK,CAAC,EAAE,OAAO,CAAC,KAAK,GAAG,UAAU;AAC7C,UAAM,MAAM,KAAK,IAAI,CAAC,QAAQ,IAAI,KAAK,EAAE,MAAM;AAC/C,UAAM,MAAM,IAAI,OAAO,CAACA,MAAK,QAAQA,OAAM,KAAK,CAAC;AACjD,WAAO,KAAK,IAAI,KAAK,GAAI,YAAY,CAAC,GAAG,IAAI,GAAI;AAAA,EAClD,GAAG,CAAC;AAEJ,QAAM,YAAY,MAAM;AACxB,QAAM,aAAa,MAAM,GAAG,KAAK,MAAM,SAAS,CAAC,GAAG;AACpD,QAAM,WAAW,YAAY;AAC7B,QAAM,QAAQ,MAAM,KAAK,CAAC,YAAY,UAAU,QAAQ,KAAK,KAAK;AAClE,QAAM,QAAQ,KAAK,KAAK,MAAM,IAAI,IAAI;AACtC,QAAM,OAAO,IAAI,OAAO;AAAA,IACvB,cAAc,KAAK,CAAC,EAAE,CAAC,EAAE,SAAS;AAAA,IAClC,OAAO;AAAA,IACP,MAAM;AAAA,IACN,OAAO,GAAG,SAAS,yBAAyB,MAAM,MAAM,EAAE,YAAY,KAAK,CAAC,GAAG,SAAS,CAAC,eAAe,KAAK,SAAS,CAAC,cAAc,KAAK;AAAA,EAAA,CAC1I;AACD,QAAM,QAAQ,KAAK,YAAY,IAAI,OAAO,EAAE,OAAO,YAAA,CAAa,CAAC;AACjE,QAAM,SAAS,KAAK,YAAY,IAAI,OAAO,EAAE,OAAO,aAAA,CAAc,CAAC;AAEnE,QAAM,KAAK,EAAE,QAAQ,QAAQ,OAAO,KAAK,CAAC,GAAG,MAAM,OAAO,OAAO,CAAC,CAAC,EACjE,UACA;AAAA,IAAI,CAAC,QACL,MAAM,OAAO,IAAI,OAAO,EAAE,OAAO,YAAY,cAAc,KAAK,CAAC;AAAA,EAAA;AAGnE,SAAO,EAAE,OAAO,QAAQ,KAAA;AACzB;AAEA,MAAM,SAAS,IAAI,KAAK,aAAA,EAAe;"}
|
package/mtds/chart/chart-bars.js
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
import { tag
|
|
2
|
-
function
|
|
3
|
-
return
|
|
4
|
-
const
|
|
5
|
-
|
|
1
|
+
import { tag } from "../utils.js";
|
|
2
|
+
function toBars(data) {
|
|
3
|
+
return data[0].slice(1).map(({ value, event }, index) => {
|
|
4
|
+
const group = tag("div", { class: "axisGroup", "data-label": value });
|
|
5
|
+
const content = group.appendChild(
|
|
6
|
+
tag("div", { class: "axisGroupContent" })
|
|
6
7
|
);
|
|
7
|
-
|
|
8
|
-
({ tooltip
|
|
9
|
-
|
|
10
|
-
"aria-label":
|
|
11
|
-
"data-event":
|
|
8
|
+
data.slice(1).map((values) => values[index + 1]).map(
|
|
9
|
+
({ tooltip, style, number }) => content.appendChild(
|
|
10
|
+
tag("div", {
|
|
11
|
+
"aria-label": tooltip,
|
|
12
|
+
"data-event": event,
|
|
12
13
|
class: "bar",
|
|
13
14
|
role: "img",
|
|
14
|
-
style: `${
|
|
15
|
+
style: `${style}; --value: ${number}`,
|
|
15
16
|
tabindex: "0"
|
|
16
17
|
})
|
|
17
18
|
)
|
|
18
|
-
)
|
|
19
|
+
);
|
|
20
|
+
return group;
|
|
19
21
|
});
|
|
20
22
|
}
|
|
21
23
|
export {
|
|
22
|
-
|
|
24
|
+
toBars
|
|
23
25
|
};
|
|
24
26
|
//# sourceMappingURL=chart-bars.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart-bars.js","sources":["../../designsystem/chart/chart-bars.ts"],"sourcesContent":["import { tag } from \"../utils\";\nimport type { ChartData } from \"./chart-element\";\n\nexport function toBars(data: ChartData) {\n\treturn data[0].slice(1).map(({ value, event }, index) => {\n\t\tconst group = tag(\"div\", { class: \"axisGroup\", \"data-label\": value });\n\t\tconst content = group.appendChild(\n\t\t\ttag(\"div\", { class: \"axisGroupContent\" }),\n\t\t);\n\n\t\tdata\n\t\t\t.slice(1)\n\t\t\t.map((values) => values[index + 1])\n\t\t\t.map(({ tooltip, style, number }) =>\n\t\t\t\tcontent.appendChild(\n\t\t\t\t\ttag(\"div\", {\n\t\t\t\t\t\t\"aria-label\": tooltip,\n\t\t\t\t\t\t\"data-event\": event,\n\t\t\t\t\t\tclass: \"bar\",\n\t\t\t\t\t\trole: \"img\",\n\t\t\t\t\t\tstyle: `${style}; --value: ${number}`,\n\t\t\t\t\t\ttabindex: \"0\",\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t);\n\t\treturn group;\n\t});\n}\n"],"names":[
|
|
1
|
+
{"version":3,"file":"chart-bars.js","sources":["../../designsystem/chart/chart-bars.ts"],"sourcesContent":["import { tag } from \"../utils\";\nimport type { ChartData } from \"./chart-element\";\n\nexport function toBars(data: ChartData) {\n\treturn data[0].slice(1).map(({ value, event }, index) => {\n\t\tconst group = tag(\"div\", { class: \"axisGroup\", \"data-label\": value });\n\t\tconst content = group.appendChild(\n\t\t\ttag(\"div\", { class: \"axisGroupContent\" }),\n\t\t);\n\n\t\tdata\n\t\t\t.slice(1)\n\t\t\t.map((values) => values[index + 1])\n\t\t\t.map(({ tooltip, style, number }) =>\n\t\t\t\tcontent.appendChild(\n\t\t\t\t\ttag(\"div\", {\n\t\t\t\t\t\t\"aria-label\": tooltip,\n\t\t\t\t\t\t\"data-event\": event,\n\t\t\t\t\t\tclass: \"bar\",\n\t\t\t\t\t\trole: \"img\",\n\t\t\t\t\t\tstyle: `${style}; --value: ${number}`,\n\t\t\t\t\t\ttabindex: \"0\",\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t);\n\t\treturn group;\n\t});\n}\n"],"names":[],"mappings":";AAGO,SAAS,OAAO,MAAiB;AACvC,SAAO,KAAK,CAAC,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC,EAAE,OAAO,MAAA,GAAS,UAAU;AACxD,UAAM,QAAQ,IAAI,OAAO,EAAE,OAAO,aAAa,cAAc,OAAO;AACpE,UAAM,UAAU,MAAM;AAAA,MACrB,IAAI,OAAO,EAAE,OAAO,oBAAoB;AAAA,IAAA;AAGzC,SACE,MAAM,CAAC,EACP,IAAI,CAAC,WAAW,OAAO,QAAQ,CAAC,CAAC,EACjC;AAAA,MAAI,CAAC,EAAE,SAAS,OAAO,OAAA,MACvB,QAAQ;AAAA,QACP,IAAI,OAAO;AAAA,UACV,cAAc;AAAA,UACd,cAAc;AAAA,UACd,OAAO;AAAA,UACP,MAAM;AAAA,UACN,OAAO,GAAG,KAAK,cAAc,MAAM;AAAA,UACnC,UAAU;AAAA,QAAA,CACV;AAAA,MAAA;AAAA,IACF;AAEF,WAAO;AAAA,EACR,CAAC;AACF;"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { MTDSElement } from '../utils';
|
|
2
2
|
export type ChartData = ReturnType<typeof toData>;
|
|
3
|
+
declare global {
|
|
4
|
+
interface HTMLElementTagNameMap {
|
|
5
|
+
"mtds-chart": MTDSChartElement;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
3
8
|
export declare class MTDSChartElement extends MTDSElement {
|
|
4
9
|
#private;
|
|
5
10
|
static get observedAttributes(): string[];
|
|
@@ -1,84 +1,119 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import { toAxis
|
|
5
|
-
import { toBars
|
|
6
|
-
import { toLines
|
|
7
|
-
import { toPies
|
|
8
|
-
const
|
|
1
|
+
import styles from "../styles.module.css.js";
|
|
2
|
+
import { isBrowser, tag, defineElement, MTDSElement, onResize, onMutation, on, off, attr } from "../utils.js";
|
|
3
|
+
import css from "./chart.css.js";
|
|
4
|
+
import { toAxis } from "./chart-axis.js";
|
|
5
|
+
import { toBars } from "./chart-bars.js";
|
|
6
|
+
import { toLines } from "./chart-lines.js";
|
|
7
|
+
import { toPies } from "./chart-pies.js";
|
|
8
|
+
const EVENTS = "click,keydown,mousemove,mouseout";
|
|
9
|
+
const TOOLTIP_ID = "mtds-chart-tooltip";
|
|
10
|
+
const TOOLTIP = isBrowser() ? document.getElementById(TOOLTIP_ID) || tag("div", {
|
|
9
11
|
"aria-hidden": "true",
|
|
10
|
-
class:
|
|
12
|
+
class: styles._tooltip,
|
|
11
13
|
hidden: "",
|
|
12
|
-
id:
|
|
14
|
+
id: TOOLTIP_ID
|
|
13
15
|
}) : null;
|
|
14
|
-
class
|
|
15
|
-
#
|
|
16
|
-
#
|
|
16
|
+
class MTDSChartElement extends MTDSElement {
|
|
17
|
+
#unmutate;
|
|
18
|
+
#unresize;
|
|
17
19
|
static get observedAttributes() {
|
|
18
20
|
return ["data-variant", "data-aspect"];
|
|
19
21
|
}
|
|
20
22
|
constructor() {
|
|
21
|
-
super()
|
|
23
|
+
super();
|
|
24
|
+
this.attachShadow({ mode: "open" });
|
|
22
25
|
}
|
|
23
26
|
connectedCallback() {
|
|
24
|
-
this.#
|
|
27
|
+
this.#unresize = onResize(() => this.handleResize(), this);
|
|
28
|
+
this.#unmutate = onMutation(() => this.attributeChangedCallback(), {
|
|
25
29
|
attr: "data-tooltip",
|
|
26
30
|
root: this
|
|
27
|
-
})
|
|
31
|
+
});
|
|
32
|
+
this.attributeChangedCallback();
|
|
33
|
+
on(this, EVENTS, this);
|
|
28
34
|
}
|
|
29
35
|
disconnectedCallback() {
|
|
30
|
-
|
|
36
|
+
if (TOOLTIP) TOOLTIP.hidden = true;
|
|
37
|
+
off(this, EVENTS, this);
|
|
38
|
+
this.#unresize?.();
|
|
39
|
+
this.#unmutate?.();
|
|
40
|
+
this.#unmutate = this.#unresize = void 0;
|
|
31
41
|
}
|
|
32
42
|
attributeChangedCallback() {
|
|
33
|
-
Array.from(this.shadowRoot?.children || []).map((
|
|
34
|
-
const [
|
|
43
|
+
Array.from(this.shadowRoot?.children || []).map((el) => el.remove());
|
|
44
|
+
const [variant, type] = (attr(this, "data-variant") || "column").split("-");
|
|
45
|
+
const aspect = attr(this, "data-aspect") || void 0;
|
|
46
|
+
const data = toData(this.querySelector("table"));
|
|
47
|
+
const style = tag("style", {}, css);
|
|
48
|
+
const legend = tag("div", {
|
|
35
49
|
"aria-hidden": "hidden",
|
|
36
50
|
class: "legends",
|
|
37
51
|
role: "group"
|
|
38
52
|
});
|
|
39
|
-
|
|
40
|
-
|
|
53
|
+
data.slice(1).forEach(([{ value, style: style2 }]) => {
|
|
54
|
+
legend.appendChild(tag("div", { class: "legend", style: style2 }, value));
|
|
41
55
|
});
|
|
42
|
-
const { axis
|
|
43
|
-
(
|
|
56
|
+
const { axis, groups, total } = toAxis(data, { aspect, type });
|
|
57
|
+
if (variant === "column" || variant === "bar")
|
|
58
|
+
groups.append(...toBars(data));
|
|
59
|
+
if (variant === "line" || variant === "area")
|
|
60
|
+
groups.append(toLines(data, { total, variant, type }));
|
|
61
|
+
if (variant === "doughnut" || variant === "pie")
|
|
62
|
+
this.shadowRoot?.append(toPies(data, { aspect, variant }));
|
|
63
|
+
this.shadowRoot?.append(axis, legend, style);
|
|
44
64
|
}
|
|
45
|
-
handleEvent(
|
|
46
|
-
|
|
65
|
+
handleEvent(e) {
|
|
66
|
+
if (e.type === "click" || e.type === "keydown") onClick(e, this);
|
|
67
|
+
else onMoveTooltip(e);
|
|
47
68
|
}
|
|
48
69
|
handleResize() {
|
|
49
|
-
const
|
|
50
|
-
|
|
70
|
+
const axis = this.shadowRoot?.firstElementChild;
|
|
71
|
+
const steps = axis?.firstElementChild;
|
|
72
|
+
axis?.classList.toggle("axisStepsYHalf", (steps?.offsetHeight || 0) < 400);
|
|
73
|
+
axis?.classList.toggle("axisStepsXHalf", (steps?.offsetWidth || 0) < 500);
|
|
51
74
|
}
|
|
52
75
|
}
|
|
53
|
-
function
|
|
54
|
-
if (
|
|
55
|
-
const
|
|
56
|
-
|
|
76
|
+
function onClick(event, self) {
|
|
77
|
+
if (event instanceof KeyboardEvent && event.key !== "Enter") return;
|
|
78
|
+
const el = event.composedPath()[0];
|
|
79
|
+
const table = self.querySelector("table");
|
|
80
|
+
const [tr, td] = el instanceof Element && attr(el, "data-event")?.split("-").map(Number) || [];
|
|
81
|
+
table?.rows[tr]?.cells[td]?.querySelector("a,button")?.click?.();
|
|
57
82
|
}
|
|
58
|
-
let
|
|
59
|
-
function
|
|
60
|
-
if (!
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
|
|
83
|
+
let TOOLTIP_TEXT = "";
|
|
84
|
+
function onMoveTooltip(event) {
|
|
85
|
+
if (!TOOLTIP) return;
|
|
86
|
+
if (!TOOLTIP?.isConnected) document.body.append(TOOLTIP);
|
|
87
|
+
const el = event.composedPath()[0];
|
|
88
|
+
const tip = el instanceof Element && el.getAttribute("aria-label") || "";
|
|
89
|
+
if (tip)
|
|
90
|
+
TOOLTIP.style.transform = `translate(${event.pageX}px, ${event.pageY}px)`;
|
|
91
|
+
if (tip !== TOOLTIP_TEXT) {
|
|
92
|
+
if (tip) TOOLTIP.textContent = tip;
|
|
93
|
+
TOOLTIP_TEXT = tip;
|
|
94
|
+
TOOLTIP.hidden = !tip;
|
|
95
|
+
}
|
|
64
96
|
}
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
97
|
+
const text = (el) => el?.textContent?.trim() || "";
|
|
98
|
+
const toData = (table) => Array.from(
|
|
99
|
+
table?.rows || [],
|
|
100
|
+
(row, rowIndex) => Array.from(row.cells, (cell, cellIndex) => {
|
|
101
|
+
const rowHeading = text(row.cells[0]);
|
|
102
|
+
const colHeading = text(table?.rows[0].cells[cellIndex]);
|
|
103
|
+
const tooltip = `${rowHeading}: ${text(cell)}${colHeading ? ` (${colHeading})` : ""}`;
|
|
69
104
|
return {
|
|
70
|
-
number:
|
|
105
|
+
number: cellIndex && rowIndex && Number.parseFloat(text(cell)) || 0,
|
|
71
106
|
// First row and column is not a number
|
|
72
|
-
event:
|
|
107
|
+
event: cell.querySelector("a,button") && `${rowIndex}-${cellIndex}`,
|
|
73
108
|
// Reference to proxy events
|
|
74
|
-
style: `--color: var(--mtdsc-chart-color-${
|
|
75
|
-
value:
|
|
76
|
-
tooltip:
|
|
109
|
+
style: `--color: var(--mtdsc-chart-color-${rowIndex}, var(--mtdsc-chart-color-base))`,
|
|
110
|
+
value: text(cell),
|
|
111
|
+
tooltip: attr(cell, "data-tooltip") || tooltip
|
|
77
112
|
};
|
|
78
113
|
})
|
|
79
114
|
);
|
|
80
|
-
|
|
115
|
+
defineElement("mtds-chart", MTDSChartElement);
|
|
81
116
|
export {
|
|
82
|
-
|
|
117
|
+
MTDSChartElement
|
|
83
118
|
};
|
|
84
119
|
//# sourceMappingURL=chart-element.js.map
|