@mattilsynet/design 2.2.23 → 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/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { UHTMLComboboxElement
|
|
2
|
-
import { UHTMLTabElement
|
|
3
|
-
import { version
|
|
4
|
-
import { analytics
|
|
5
|
-
import { toggleAppExpanded
|
|
6
|
-
import { fixLawHtml
|
|
7
|
-
import { pagination
|
|
8
|
-
import * as
|
|
9
|
-
import { toast
|
|
1
|
+
import { UHTMLComboboxElement } from "@u-elements/u-combobox";
|
|
2
|
+
import { UHTMLTabElement, UHTMLTabListElement, UHTMLTabPanelElement, UHTMLTabsElement } from "@u-elements/u-tabs";
|
|
3
|
+
import { version } from "./package.json.js";
|
|
4
|
+
import { analytics } from "./analytics/analytics.js";
|
|
5
|
+
import { toggleAppExpanded } from "./app/app-observer.js";
|
|
6
|
+
import { fixLawHtml, getLawChecked, parseLawIds, parseLawMeta, setLawChecked, toggleLawChecked } from "./law/law-helper.js";
|
|
7
|
+
import { pagination } from "./pagination/pagination-helper.js";
|
|
8
|
+
import * as styles_module from "./styles.module.css.js";
|
|
9
|
+
import { toast } from "./toast/toast-helper.js";
|
|
10
10
|
import "./breadcrumbs/breadcrumbs-observer.js";
|
|
11
11
|
import "./chart/chart-element.js";
|
|
12
12
|
import "./dialog/dialog-observer.js";
|
|
@@ -23,20 +23,22 @@ import "@u-elements/u-datalist";
|
|
|
23
23
|
import "@u-elements/u-details";
|
|
24
24
|
import "@u-elements/u-progress";
|
|
25
25
|
export {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
26
|
+
UHTMLComboboxElement,
|
|
27
|
+
UHTMLTabElement,
|
|
28
|
+
UHTMLTabListElement,
|
|
29
|
+
UHTMLTabPanelElement,
|
|
30
|
+
UHTMLTabsElement,
|
|
31
|
+
analytics,
|
|
32
|
+
fixLawHtml,
|
|
33
|
+
getLawChecked,
|
|
34
|
+
pagination,
|
|
35
|
+
parseLawIds,
|
|
36
|
+
parseLawMeta,
|
|
37
|
+
setLawChecked,
|
|
38
|
+
styles_module as styles,
|
|
39
|
+
toast,
|
|
40
|
+
toggleAppExpanded,
|
|
41
|
+
toggleLawChecked,
|
|
42
|
+
version
|
|
41
43
|
};
|
|
42
44
|
//# sourceMappingURL=index.js.map
|
package/mtds/input/input.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type InputProps = React.ComponentPropsWithoutRef<"input">;
|
|
2
|
-
export declare const Input:
|
|
2
|
+
export declare const Input: import('react').ForwardRefExoticComponent<Omit<import('react').DetailedHTMLProps<import('react').InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref"> & import('react').RefAttributes<HTMLInputElement>>;
|
|
3
3
|
export type SelectProps = React.ComponentPropsWithoutRef<"select">;
|
|
4
|
-
export declare const Select:
|
|
4
|
+
export declare const Select: import('react').ForwardRefExoticComponent<Omit<import('react').DetailedHTMLProps<import('react').SelectHTMLAttributes<HTMLSelectElement>, HTMLSelectElement>, "ref"> & import('react').RefAttributes<HTMLSelectElement>>;
|
|
5
5
|
export type TextareaProps = React.ComponentPropsWithoutRef<"textarea">;
|
|
6
|
-
export declare const Textarea:
|
|
6
|
+
export declare const Textarea: import('react').ForwardRefExoticComponent<Omit<import('react').DetailedHTMLProps<import('react').TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, "ref"> & import('react').RefAttributes<HTMLTextAreaElement>>;
|
package/mtds/input/input.js
CHANGED
|
@@ -1,30 +1,32 @@
|
|
|
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 Input = forwardRef(function Input2({ className, type = "text", ...rest }, ref) {
|
|
6
|
+
return /* @__PURE__ */ jsx(
|
|
7
7
|
"input",
|
|
8
8
|
{
|
|
9
|
-
suppressHydrationWarning:
|
|
10
|
-
className:
|
|
11
|
-
type
|
|
12
|
-
ref
|
|
13
|
-
...
|
|
9
|
+
suppressHydrationWarning: true,
|
|
10
|
+
className: clsx(styles.input, className),
|
|
11
|
+
type,
|
|
12
|
+
ref,
|
|
13
|
+
...rest
|
|
14
14
|
}
|
|
15
15
|
);
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
});
|
|
17
|
+
const Select = forwardRef(
|
|
18
|
+
function Select2({ className, ...rest }, ref) {
|
|
19
|
+
return /* @__PURE__ */ jsx("select", { className: clsx(styles.input, className), ref, ...rest });
|
|
19
20
|
}
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
);
|
|
22
|
+
const Textarea = forwardRef(
|
|
23
|
+
function Textarea2({ className, ...rest }, ref) {
|
|
24
|
+
return /* @__PURE__ */ jsx("textarea", { className: clsx(styles.input, className), ref, ...rest });
|
|
23
25
|
}
|
|
24
26
|
);
|
|
25
27
|
export {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
Input,
|
|
29
|
+
Select,
|
|
30
|
+
Textarea
|
|
29
31
|
};
|
|
30
32
|
//# sourceMappingURL=input.js.map
|
package/mtds/input/input.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.js","sources":["../../designsystem/input/input.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { forwardRef } from \"react\";\nimport styles from \"../styles.module.css\";\n\nexport type InputProps = React.ComponentPropsWithoutRef<\"input\">;\nexport const Input = forwardRef<HTMLInputElement, InputProps>(function Input(\n\t{ className, type = \"text\", ...rest },\n\tref,\n) {\n\treturn (\n\t\t<input\n\t\t\tsuppressHydrationWarning // Prevent hydration mismatch for SSR due to field-observer.ts\n\t\t\tclassName={clsx(styles.input, className)}\n\t\t\ttype={type}\n\t\t\tref={ref}\n\t\t\t{...rest}\n\t\t/>\n\t);\n});\n\nexport type SelectProps = React.ComponentPropsWithoutRef<\"select\">;\nexport const Select = forwardRef<HTMLSelectElement, SelectProps>(\n\tfunction Select({ className, ...rest }, ref) {\n\t\treturn (\n\t\t\t<select className={clsx(styles.input, className)} ref={ref} {...rest} />\n\t\t);\n\t},\n);\n\nexport type TextareaProps = React.ComponentPropsWithoutRef<\"textarea\">;\nexport const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(\n\tfunction Textarea({ className, ...rest }, ref) {\n\t\treturn (\n\t\t\t<textarea className={clsx(styles.input, className)} ref={ref} {...rest} />\n\t\t);\n\t},\n);\n"],"names":["Input","
|
|
1
|
+
{"version":3,"file":"input.js","sources":["../../designsystem/input/input.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { forwardRef } from \"react\";\nimport styles from \"../styles.module.css\";\n\nexport type InputProps = React.ComponentPropsWithoutRef<\"input\">;\nexport const Input = forwardRef<HTMLInputElement, InputProps>(function Input(\n\t{ className, type = \"text\", ...rest },\n\tref,\n) {\n\treturn (\n\t\t<input\n\t\t\tsuppressHydrationWarning // Prevent hydration mismatch for SSR due to field-observer.ts\n\t\t\tclassName={clsx(styles.input, className)}\n\t\t\ttype={type}\n\t\t\tref={ref}\n\t\t\t{...rest}\n\t\t/>\n\t);\n});\n\nexport type SelectProps = React.ComponentPropsWithoutRef<\"select\">;\nexport const Select = forwardRef<HTMLSelectElement, SelectProps>(\n\tfunction Select({ className, ...rest }, ref) {\n\t\treturn (\n\t\t\t<select className={clsx(styles.input, className)} ref={ref} {...rest} />\n\t\t);\n\t},\n);\n\nexport type TextareaProps = React.ComponentPropsWithoutRef<\"textarea\">;\nexport const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(\n\tfunction Textarea({ className, ...rest }, ref) {\n\t\treturn (\n\t\t\t<textarea className={clsx(styles.input, className)} ref={ref} {...rest} />\n\t\t);\n\t},\n);\n"],"names":["Input","Select","Textarea"],"mappings":";;;;AAKO,MAAM,QAAQ,WAAyC,SAASA,OACtE,EAAE,WAAW,OAAO,QAAQ,GAAG,KAAA,GAC/B,KACC;AACD,SACC;AAAA,IAAC;AAAA,IAAA;AAAA,MACA,0BAAwB;AAAA,MACxB,WAAW,KAAK,OAAO,OAAO,SAAS;AAAA,MACvC;AAAA,MACA;AAAA,MACC,GAAG;AAAA,IAAA;AAAA,EAAA;AAGP,CAAC;AAGM,MAAM,SAAS;AAAA,EACrB,SAASC,QAAO,EAAE,WAAW,GAAG,KAAA,GAAQ,KAAK;AAC5C,WACC,oBAAC,UAAA,EAAO,WAAW,KAAK,OAAO,OAAO,SAAS,GAAG,KAAW,GAAG,KAAA,CAAM;AAAA,EAExE;AACD;AAGO,MAAM,WAAW;AAAA,EACvB,SAASC,UAAS,EAAE,WAAW,GAAG,KAAA,GAAQ,KAAK;AAC9C,WACC,oBAAC,YAAA,EAAS,WAAW,KAAK,OAAO,OAAO,SAAS,GAAG,KAAW,GAAG,KAAA,CAAM;AAAA,EAE1E;AACD;"}
|
package/mtds/law/law-helper.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const
|
|
1
|
+
type Ids = string | string[] | HTMLButtonElement | HTMLButtonElement[];
|
|
2
|
+
export declare const getLawChecked: (lawElement?: HTMLElement | null) => string[];
|
|
3
|
+
export declare const toggleLawChecked: (ids: Ids, lawElement?: HTMLElement | null) => void;
|
|
4
|
+
export declare const setLawChecked: (ids: Ids, lawElement?: HTMLElement | null) => void;
|
|
5
|
+
export declare const parseLawIds: (ids: string | string[], lawHtml: string) => {
|
|
3
6
|
path: {
|
|
4
7
|
id: string;
|
|
5
8
|
className: string;
|
|
@@ -36,3 +39,4 @@ export declare const parseLawMeta: (lawHtml: string) => {
|
|
|
36
39
|
};
|
|
37
40
|
};
|
|
38
41
|
export declare const fixLawHtml: (lawHtml: string) => string;
|
|
42
|
+
export {};
|
package/mtds/law/law-helper.js
CHANGED
|
@@ -1,78 +1,160 @@
|
|
|
1
|
-
import { attr
|
|
2
|
-
const
|
|
1
|
+
import { attr } from "../utils.js";
|
|
2
|
+
const REGEX_ID = /<[^>]+\bid="([^"]+)[^>]+>/gi;
|
|
3
|
+
const REGEX_FORORDNING = /\([^)]{1,4}\).{1,9}\d+\/\d+/i;
|
|
4
|
+
const REGEX_HEADING = /<(h\d|[^>]+role="heading")[^>]*>(.*?)<\/?(h\d|br|div)/i;
|
|
5
|
+
const REGEX_KAPITTEL_LEDD = /kapittel-\d+-ledd-\d+/;
|
|
6
|
+
const REGEX_STRIP_BUTTONS = /<button[^>]+>.*?<\/button>/g;
|
|
7
|
+
const REGEX_STRIP_POINTER = /►m\d+/i;
|
|
8
|
+
const REGEX_STRIP_TAGS = /<[^>]+>/g;
|
|
9
|
+
const REGEX_META = /<dt([^>]*class="([^"]+)")?[^>]*>(.*?)<\/dt><dd[^>]*>(.*?)<\/dd>/gis;
|
|
10
|
+
const REGEX_FIX_TAGS = /<(\/?)(article|footer|section)/gi;
|
|
11
|
+
const REGEX_FIX_BASEURL = /(src|href)="([^"]+)"/gi;
|
|
12
|
+
const REGEX_FIX_LISTS = /(<li[^>]*)>\s*<div([^>]*>)|<\/div>(<\/li>)/gi;
|
|
13
|
+
const REGEX_FIX_SPAN_ID = /(<li[^>]+data-name="([^"]+)[^>]+>)(\s*<(ul|ol|div)[^>]+>)/gis;
|
|
14
|
+
const REGEX_FIX_NUMBEREDLEGALP = /(<[^>]+class="[^"]*\bnumberedLegalP\b[^>]+>\s*)(\d+\.)(.*?)(?=<\/?(ul|ol|div)|$)/gis;
|
|
15
|
+
const BASE_URL = "https://lovdata.no/";
|
|
16
|
+
const META_DEFAULT = {
|
|
3
17
|
legacyid: { label: "Datokode", value: "" },
|
|
4
18
|
titleshort: { label: "Korttittel", value: "" },
|
|
5
19
|
title: { label: "Tittel", value: "" },
|
|
6
20
|
url: { label: "Url", value: "" }
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
21
|
+
};
|
|
22
|
+
const toIdArray = (ids) => Array.from(
|
|
23
|
+
Array.isArray(ids) ? ids : [ids],
|
|
24
|
+
(id) => id instanceof HTMLButtonElement ? id.value : id
|
|
25
|
+
);
|
|
26
|
+
const getLawChecked = (lawElement) => Array.from(
|
|
27
|
+
lawElement?.querySelectorAll(`button[aria-checked="true"]`) || [],
|
|
28
|
+
(btn) => btn.value
|
|
29
|
+
);
|
|
30
|
+
const toggleLawChecked = (ids, lawElement) => {
|
|
31
|
+
const idArray = toIdArray(ids);
|
|
32
|
+
lawElement?.querySelectorAll(`button`).forEach((btn) => {
|
|
33
|
+
if (idArray.includes(btn.value))
|
|
34
|
+
attr(btn, "aria-checked", `${attr(btn, "aria-checked") !== "true"}`);
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
const setLawChecked = (ids, lawElement) => {
|
|
38
|
+
const idArray = toIdArray(ids);
|
|
39
|
+
lawElement?.querySelectorAll("button").forEach((btn) => {
|
|
40
|
+
attr(btn, "aria-checked", `${idArray.includes(btn.value) || false}`);
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
const parseLawIds = (ids, lawHtml) => {
|
|
44
|
+
const html = fixLawHtml(lawHtml);
|
|
45
|
+
return toIdArray(ids).map((id) => parseLawId(id, html)).filter((unit) => !!unit);
|
|
46
|
+
};
|
|
47
|
+
const parseLawMeta = (lawHtml) => {
|
|
48
|
+
const html = lawHtml.slice(0, lawHtml.indexOf("</dl>"));
|
|
49
|
+
const meta = { ...META_DEFAULT };
|
|
50
|
+
for (const m of html.matchAll(REGEX_META)) {
|
|
51
|
+
const key = m[2].replace(/-/g, "").toLowerCase();
|
|
52
|
+
meta[key] = { label: m[3], value: m[4] };
|
|
17
53
|
}
|
|
18
|
-
return
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
54
|
+
return meta;
|
|
55
|
+
};
|
|
56
|
+
const fixLawHtml = (lawHtml) => {
|
|
57
|
+
if (!lawHtml.includes("<main")) return lawHtml;
|
|
58
|
+
return (lawHtml.split(/<\/?main[^>]*>/)[1] || "").replace(REGEX_FIX_TAGS, "<$1div").replace(REGEX_FIX_LISTS, "$1$2$3").replace(REGEX_FIX_BASEURL, (_, attr2, url) => {
|
|
59
|
+
return `${attr2}="${url.includes(":") ? "" : BASE_URL}${url}" ${attr2 === "href" ? 'rel="noopener noreferrer" target="_blank"' : ""}`;
|
|
60
|
+
}).replace(REGEX_FIX_NUMBEREDLEGALP, (_, tag, id, ledd) => {
|
|
61
|
+
return `${tag}<span class="data-originalId">${id}</span><div class="legalP" id="${getAttr("id", tag)}-ledd-0">${ledd}</div>`;
|
|
62
|
+
}).replace(REGEX_FIX_SPAN_ID, (_, tag, id, child) => {
|
|
63
|
+
return `${tag}<span class="data-originalId">${id}</span>${child}`;
|
|
64
|
+
}).replace(REGEX_ID, (tag, id, idx, html) => {
|
|
65
|
+
const label = getLabel(tag, id, idx, html);
|
|
66
|
+
return `${tag}${label ? `<button type="button" role="checkbox" aria-label="${label}" value="${id}"></button>` : ""}`;
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
const parseLawId = (id, html) => {
|
|
70
|
+
const isKapitellLedd = REGEX_KAPITTEL_LEDD.test(id);
|
|
71
|
+
const path = id.split("-").map(
|
|
72
|
+
(_, i, all) => i % 2 ? parseLawItem(all.slice(0, i + 1).join("-"), html, isKapitellLedd) : null
|
|
73
|
+
).filter((unit) => !!unit);
|
|
74
|
+
if (!path.length) return null;
|
|
75
|
+
const url = path.filter(({ url: url2 }) => url2).pop()?.url || "";
|
|
76
|
+
const forordninger = path.filter(
|
|
77
|
+
(u) => u.className === "section" && REGEX_FORORDNING.test(u.label)
|
|
78
|
+
);
|
|
79
|
+
const label = path.slice(path.indexOf(forordninger.pop() || path[0])).map((u) => u.label).join(", ");
|
|
80
|
+
return { ...path.slice(-1)[0], path, label, url };
|
|
81
|
+
};
|
|
82
|
+
const parseLawItem = (id, html, isKapitellLedd) => {
|
|
83
|
+
const idx = html.lastIndexOf("<", html.indexOf(` id="${id}"`));
|
|
84
|
+
const tag = html.slice(idx, html.indexOf(">", idx) + 1);
|
|
85
|
+
const className = getAttr("class", tag);
|
|
86
|
+
const url = getAttr("data-lovdata-url", tag);
|
|
87
|
+
const label = getLabel(tag, id, idx, html);
|
|
33
88
|
return {
|
|
34
|
-
id
|
|
35
|
-
className
|
|
36
|
-
html:
|
|
37
|
-
url:
|
|
38
|
-
label: !
|
|
89
|
+
id,
|
|
90
|
+
className,
|
|
91
|
+
html: getOuterHTML(id, html),
|
|
92
|
+
url: url ? `${BASE_URL}${url}` : "",
|
|
93
|
+
label: !isKapitellLedd && className === "section" && label?.match(REGEX_FORORDNING)?.[0] || label
|
|
39
94
|
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
95
|
+
};
|
|
96
|
+
const getAttr = (attr2, html) => {
|
|
97
|
+
const query = ` ${attr2.toLowerCase()}="`;
|
|
98
|
+
const idx = html.toLowerCase().indexOf(query);
|
|
99
|
+
const start = idx + query.length;
|
|
100
|
+
return idx === -1 ? "" : html.slice(start, html.indexOf('"', start));
|
|
101
|
+
};
|
|
102
|
+
const getOuterHTML = (id, html) => {
|
|
103
|
+
const idx = html.lastIndexOf("<", html.indexOf(` id="${id}"`));
|
|
104
|
+
const max = html.length;
|
|
105
|
+
let i = idx + 1;
|
|
106
|
+
let depth = 0;
|
|
107
|
+
while (i && i < max) {
|
|
108
|
+
i = html.indexOf("<", i) + 1;
|
|
109
|
+
if (html[i] !== "/") depth++;
|
|
110
|
+
else if (--depth < 0) break;
|
|
111
|
+
}
|
|
112
|
+
const end = html.indexOf(">", i) + 1;
|
|
113
|
+
return i ? html.slice(idx, end).replace(REGEX_STRIP_BUTTONS, "") : "";
|
|
114
|
+
};
|
|
115
|
+
const getLabel = (tag, id, idx, html) => LABELS[getAttr("class", tag)]?.(tag, id, idx, html) || "";
|
|
116
|
+
const LABELS = {
|
|
117
|
+
numberedLegalP: (tag) => `nr. ${getAttr("data-numerator", tag)}.`,
|
|
118
|
+
section: (_tag, _id, idx, html) => {
|
|
119
|
+
const head = html.slice(idx).match(REGEX_HEADING)?.[2];
|
|
120
|
+
const clean = head?.replace(REGEX_STRIP_TAGS, "");
|
|
121
|
+
return clean?.replace(REGEX_STRIP_POINTER, "").trim() || "";
|
|
122
|
+
},
|
|
123
|
+
legalArticle: (_tag, _id, idx, html) => {
|
|
124
|
+
const at = html.indexOf(">", html.indexOf("legalArticleValue", idx));
|
|
125
|
+
const id = html.slice(at + 1, html.indexOf("</span>", at));
|
|
126
|
+
return id.replace(REGEX_STRIP_TAGS, "").replace("Artikkel", "artikkel");
|
|
57
127
|
},
|
|
58
|
-
legalP: (
|
|
59
|
-
const [
|
|
60
|
-
|
|
128
|
+
legalP: (_tag, id) => {
|
|
129
|
+
const [idx, type, _, parent] = id.split("-").reverse();
|
|
130
|
+
const count = type === "nummer" ? 1 : Number(idx);
|
|
131
|
+
return `avsnitt ${count + (parent === "nummer" ? 1 : 0)}`;
|
|
61
132
|
},
|
|
62
|
-
listArticle: (
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
133
|
+
listArticle: (tag, id, idx, html) => {
|
|
134
|
+
const path = id.split("-");
|
|
135
|
+
const parentTag = ` id="${path.slice(0, -2).join("-")}"`;
|
|
136
|
+
const parentIdx = html.lastIndexOf(parentTag, idx);
|
|
137
|
+
const list = html.slice(html.indexOf("<ol", parentIdx), idx);
|
|
138
|
+
const name = getAttr("data-name", tag) || "-";
|
|
139
|
+
const type = getAttr("type", list) || "-";
|
|
140
|
+
let unit = "punkt";
|
|
141
|
+
if (type === "1") unit = "tall";
|
|
142
|
+
if (type === "a") unit = "bokstav";
|
|
143
|
+
if (type === "i") unit = "romtertall";
|
|
144
|
+
return `${unit} ${name === "-" ? path.pop() : name.replace(REGEX_STRIP_TAGS, "")}`;
|
|
66
145
|
},
|
|
67
|
-
marginIdArticle: (
|
|
68
|
-
const
|
|
69
|
-
|
|
146
|
+
marginIdArticle: (_tag, _id, idx, html) => {
|
|
147
|
+
const at = html.indexOf(">", html.indexOf("data-marginOriginalId", idx));
|
|
148
|
+
const id = html.slice(at + 1, html.indexOf("</span>", at));
|
|
149
|
+
return `nr. ${id.replace(REGEX_STRIP_TAGS, "")}`;
|
|
70
150
|
}
|
|
71
151
|
};
|
|
72
152
|
export {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
153
|
+
fixLawHtml,
|
|
154
|
+
getLawChecked,
|
|
155
|
+
parseLawIds,
|
|
156
|
+
parseLawMeta,
|
|
157
|
+
setLawChecked,
|
|
158
|
+
toggleLawChecked
|
|
77
159
|
};
|
|
78
160
|
//# sourceMappingURL=law-helper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"law-helper.js","sources":["../../designsystem/law/law-helper.ts"],"sourcesContent":["import { attr } from \"../utils\";\n\n// NOTE: The law format is documentet in https://api.lovdata.no/xmldocs\nconst REGEX_ID = /<[^>]+id=\"([^\"]+)[^>]+>/gi;\nconst REGEX_FORORDNING = /\\([^)]{1,4}\\).{1,9}\\d+\\/\\d+/i; // Match (EU) 2016/2031, (EF) nr. 2020/1054, (EFF) ..., etc.\nconst REGEX_HEADING = /<(h\\d|[^>]+role=\"heading\")[^>]*>(.*?)<\\/?(h\\d|br|div)/i; // Can be both <h1>-<h6> and or <div> with role=\"heading\" if level 7+\nconst REGEX_KAPITTEL_LEDD = /kapittel-\\d+-ledd-\\d+/;\nconst REGEX_STRIP_BUTTONS = /<button[^>]+>.*?<\\/button>/g;\nconst REGEX_STRIP_POINTER = /►m\\d+/i;\nconst REGEX_STRIP_TAGS = /<[^>]+>/g;\nconst REGEX_META =\n\t/<dt([^>]*class=\"([^\"]+)\")?[^>]*>(.*?)<\\/dt><dd[^>]*>(.*?)<\\/dd>/gis;\n\nconst REGEX_FIX_TAGS = /<(\\/?)(article|footer|section)/gi;\nconst REGEX_FIX_BASEURL = /(src|href)=\"([^\"]+)\"/gi;\nconst REGEX_FIX_LISTS = /(<li[^>]*)>\\s*<div([^>]*>)|<\\/div>(<\\/li>)/gi;\nconst REGEX_FIX_SPAN_ID =\n\t/(<li[^>]+data-name=\"([^\"]+)[^>]+>)(\\s*<(ul|ol|div)[^>]+>)/gis; // Only create span if no span exists\nconst REGEX_FIX_NUMBEREDLEGALP =\n\t/(<[^>]+class=\"[^\"]*\\bnumberedLegalP\\b[^>]+>\\s*)(\\d+\\.)(.*?)(?=<\\/?(ul|ol|div)|$)/gis;\n\nconst BASE_URL = \"https://lovdata.no/\";\nconst META_DEFAULT: Record<\n\t\"legacyid\" | \"title\" | \"titleshort\" | \"url\" | (string & {}), // Ensure title and titleShort are always present\n\t{ label: string; value: string }\n> = {\n\tlegacyid: { label: \"Datokode\", value: \"\" },\n\ttitleshort: { label: \"Korttittel\", value: \"\" },\n\ttitle: { label: \"Tittel\", value: \"\" },\n\turl: { label: \"Url\", value: \"\" },\n};\n\nexport const setLawChecked = (\n\tchecked: string[],\n\tlawElement?: HTMLElement | null,\n) =>\n\tlawElement?.querySelectorAll(\"button\").forEach((btn) => {\n\t\tattr(btn, \"aria-checked\", `${checked.includes(btn.value) || false}`);\n\t});\n\nexport const parseLawIds = (ids: string[], lawHtml: string) => {\n\tconst html = fixLawHtml(lawHtml);\n\treturn ids.map((id) => parseLawId(id, html)).filter((unit) => !!unit);\n};\n\nexport const parseLawMeta = (lawHtml: string) => {\n\tconst html = lawHtml.slice(0, lawHtml.indexOf(\"</dl>\"));\n\tconst meta = { ...META_DEFAULT };\n\tfor (const m of html.matchAll(REGEX_META)) {\n\t\tconst key = m[2].replace(/-/g, \"\").toLowerCase();\n\t\tmeta[key] = { label: m[3], value: m[4] };\n\t}\n\treturn meta;\n};\n\nexport const fixLawHtml = (lawHtml: string) => {\n\tif (!lawHtml.includes(\"<main\")) return lawHtml; // Already rendered\n\treturn (lawHtml.split(/<\\/?main[^>]*>/)[1] || \"\") // Only need content in <main>\n\t\t.replace(REGEX_FIX_TAGS, \"<$1div\") // Better for accessibility, must run before other REGEX_FIX\n\t\t.replace(REGEX_FIX_LISTS, \"$1$2$3\") // Merge <li> with inner <div> to reduce unnecessary elements\n\t\t.replace(REGEX_FIX_BASEURL, (_, attr, url) => {\n\t\t\treturn `${attr}=\"${url.includes(\":\") ? \"\" : BASE_URL}${url}\" ${attr === \"href\" ? 'rel=\"noopener noreferrer\" target=\"_blank\"' : \"\"}`;\n\t\t})\n\t\t.replace(REGEX_FIX_NUMBEREDLEGALP, (_, tag, id, ledd) => {\n\t\t\treturn `${tag}<span class=\"data-originalId\">${id}</span><div class=\"legalP\" id=\"${getAttr(\"id\", tag)}-ledd-0\">${ledd}</div>`;\n\t\t})\n\t\t.replace(REGEX_FIX_SPAN_ID, (_, tag, id, child) => {\n\t\t\treturn `${tag}<span class=\"data-originalId\">${id}</span>${child}`;\n\t\t})\n\t\t.replace(REGEX_ID, (tag, id, idx, html) => {\n\t\t\tconst label = getLabel(tag, id, idx, html);\n\t\t\treturn `${tag}${label ? `<button type=\"button\" role=\"checkbox\" aria-label=\"${label}\" value=\"${id}\"></button>` : \"\"}`;\n\t\t});\n};\n\nconst parseLawId = (id: string, html: string) => {\n\tconst isKapitellLedd = REGEX_KAPITTEL_LEDD.test(id);\n\tconst path = id\n\t\t.split(\"-\")\n\t\t.map((_, i, all) =>\n\t\t\ti % 2\n\t\t\t\t? parseLawItem(all.slice(0, i + 1).join(\"-\"), html, isKapitellLedd)\n\t\t\t\t: null,\n\t\t)\n\t\t.filter((unit) => !!unit);\n\n\tif (!path.length) return null;\n\tconst url = path.filter(({ url }) => url).pop()?.url || \"\"; // The closest units item might not have an URL, so we provide the last found URL\n\tconst forordninger = path.filter(\n\t\t(u) => u.className === \"section\" && REGEX_FORORDNING.test(u.label),\n\t);\n\tconst label = path\n\t\t.slice(path.indexOf(forordninger.pop() || path[0]))\n\t\t.map((u) => u.label)\n\t\t.join(\", \");\n\n\treturn { ...path.slice(-1)[0], path, label, url };\n};\n\nconst parseLawItem = (id: string, html: string, isKapitellLedd: boolean) => {\n\tconst idx = html.lastIndexOf(\"<\", html.indexOf(` id=\"${id}\"`));\n\tconst tag = html.slice(idx, html.indexOf(\">\", idx) + 1);\n\tconst className = getAttr(\"class\", tag);\n\tconst url = getAttr(\"data-lovdata-url\", tag);\n\tconst label = getLabel(tag, id, idx, html);\n\n\treturn {\n\t\tid,\n\t\tclassName,\n\t\thtml: getOuterHTML(id, html),\n\t\turl: url ? `${BASE_URL}${url}` : \"\",\n\t\tlabel:\n\t\t\t(!isKapitellLedd &&\n\t\t\t\tclassName === \"section\" &&\n\t\t\t\tlabel?.match(REGEX_FORORDNING)?.[0]) ||\n\t\t\tlabel,\n\t};\n};\n\nconst getAttr = (attr: string, html: string) => {\n\tconst query = ` ${attr.toLowerCase()}=\"`;\n\tconst idx = html.toLowerCase().indexOf(query); // Need to lowercase to sanitize html variations\n\tconst start = idx + query.length;\n\treturn idx === -1 ? \"\" : html.slice(start, html.indexOf('\"', start)); // Using slice for performance\n};\n\nconst getOuterHTML = (id: string, html: string) => {\n\tconst idx = html.lastIndexOf(\"<\", html.indexOf(` id=\"${id}\"`));\n\tconst max = html.length;\n\tlet i = idx + 1; // Using + 1 to get 0 if not found, and to ensure we start searching inside element\n\tlet depth = 0;\n\n\twhile (i && i < max) {\n\t\ti = html.indexOf(\"<\", i) + 1;\n\t\tif (html[i] !== \"/\") depth++;\n\t\telse if (--depth < 0) break;\n\t}\n\tconst end = html.indexOf(\">\", i) + 1;\n\treturn i ? html.slice(idx, end).replace(REGEX_STRIP_BUTTONS, \"\") : \"\";\n};\n\nconst getLabel = (tag: string, id: string, idx: number, html: string): string =>\n\tLABELS[getAttr(\"class\", tag)]?.(tag, id, idx, html) || \"\";\n\nconst LABELS: Record<string, typeof getLabel> = {\n\tnumberedLegalP: (tag) => `nr. ${getAttr(\"data-numerator\", tag)}.`,\n\tsection: (_tag, _id, idx, html) => {\n\t\tconst head = html.slice(idx).match(REGEX_HEADING)?.[2];\n\t\tconst clean = head?.replace(REGEX_STRIP_TAGS, \"\");\n\t\treturn clean?.replace(REGEX_STRIP_POINTER, \"\").trim() || \"\";\n\t},\n\tlegalArticle: (_tag, _id, idx, html) => {\n\t\tconst at = html.indexOf(\">\", html.indexOf(\"legalArticleValue\", idx));\n\t\tconst id = html.slice(at + 1, html.indexOf(\"</span>\", at)); // .legalArticleValue is always a <span>\n\t\treturn id.replace(REGEX_STRIP_TAGS, \"\").replace(\"Artikkel\", \"artikkel\");\n\t},\n\tlegalP: (_tag, id) => {\n\t\tconst [parent, _, type, idx] = id.split(\"-\").slice(-4); // If placed inside numberedLegalP, parent is \"nummer\"\n\t\tconst count = type === \"nummer\" ? 1 : Number(idx); // If \"fake\" ledd 1 created by fixNumberedLegalP, type is \"number\"\n\t\treturn `avsnitt ${count + (parent === \"nummer\" ? 1 : 0)}`; // Adjust for numberedLegalP creating fake legalP starting at 1\n\t},\n\tlistArticle: (tag, id, idx, html) => {\n\t\tconst path = id.split(\"-\");\n\t\tconst parentTag = ` id=\"${path.slice(0, -2).join(\"-\")}\"`; // Since lists can be nested, we need to find parent law unit to get correct list\n\t\tconst parentIdx = html.lastIndexOf(parentTag, idx);\n\t\tconst list = html.slice(html.indexOf(\"<ol\", parentIdx), idx); // Find first <ol> after parent element opening tag\n\t\tconst name = getAttr(\"data-name\", tag) || \"-\"; // Name can be empty or dash so allways fallback to dash\n\t\tconst type = getAttr(\"type\", list) || \"-\";\n\n\t\tlet unit = \"punkt\";\n\t\tif (type === \"1\") unit = \"tall\";\n\t\tif (type === \"a\") unit = \"bokstav\";\n\t\tif (type === \"i\") unit = \"romtertall\";\n\t\treturn `${unit} ${name === \"-\" ? path.pop() : name.replace(REGEX_STRIP_TAGS, \"\")}`;\n\t},\n\tmarginIdArticle: (_tag, _id, idx, html) => {\n\t\tconst at = html.indexOf(\">\", html.indexOf(\"data-marginOriginalId\", idx));\n\t\tconst id = html.slice(at + 1, html.indexOf(\"</span>\", at));\n\t\treturn `nr. ${id.replace(REGEX_STRIP_TAGS, \"\")}`;\n\t},\n};\n"],"names":["REGEX_ID","REGEX_FORORDNING","REGEX_HEADING","REGEX_KAPITTEL_LEDD","REGEX_STRIP_BUTTONS","REGEX_STRIP_POINTER","REGEX_STRIP_TAGS","REGEX_META","REGEX_FIX_TAGS","REGEX_FIX_BASEURL","REGEX_FIX_LISTS","REGEX_FIX_SPAN_ID","REGEX_FIX_NUMBEREDLEGALP","BASE_URL","META_DEFAULT","setLawChecked","checked","lawElement","btn","attr","parseLawIds","ids","lawHtml","html","fixLawHtml","id","parseLawId","unit","parseLawMeta","meta","m","key","_","url","tag","ledd","getAttr","child","idx","label","getLabel","isKapitellLedd","path","i","all","parseLawItem","forordninger","u","className","getOuterHTML","query","start","max","depth","end","LABELS","_tag","_id","at","parent","type","parentTag","parentIdx","list","name"],"mappings":";AAGA,MAAMA,IAAW,6BACXC,IAAmB,gCACnBC,IAAgB,0DAChBC,IAAsB,yBACtBC,IAAsB,+BACtBC,IAAsB,UACtBC,IAAmB,YACnBC,IACL,sEAEKC,IAAiB,oCACjBC,IAAoB,0BACpBC,IAAkB,gDAClBC,IACL,gEACKC,IACL,uFAEKC,IAAW,uBACXC,IAGF;AAAA,EACH,UAAU,EAAE,OAAO,YAAY,OAAO,GAAA;AAAA,EACtC,YAAY,EAAE,OAAO,cAAc,OAAO,GAAA;AAAA,EAC1C,OAAO,EAAE,OAAO,UAAU,OAAO,GAAA;AAAA,EACjC,KAAK,EAAE,OAAO,OAAO,OAAO,GAAA;AAC7B,GAEaC,IAAgB,CAC5BC,GACAC,MAEAA,GAAY,iBAAiB,QAAQ,EAAE,QAAQ,CAACC,MAAQ;AACvD,EAAAC,EAAKD,GAAK,gBAAgB,GAAGF,EAAQ,SAASE,EAAI,KAAK,KAAK,EAAK,EAAE;AACpE,CAAC,GAEWE,IAAc,CAACC,GAAeC,MAAoB;AAC9D,QAAMC,IAAOC,EAAWF,CAAO;AAC/B,SAAOD,EAAI,IAAI,CAACI,MAAOC,EAAWD,GAAIF,CAAI,CAAC,EAAE,OAAO,CAACI,MAAS,CAAC,CAACA,CAAI;AACrE,GAEaC,IAAe,CAACN,MAAoB;AAChD,QAAMC,IAAOD,EAAQ,MAAM,GAAGA,EAAQ,QAAQ,OAAO,CAAC,GAChDO,IAAO,EAAE,GAAGf,EAAA;AAClB,aAAWgB,KAAKP,EAAK,SAAShB,CAAU,GAAG;AAC1C,UAAMwB,IAAMD,EAAE,CAAC,EAAE,QAAQ,MAAM,EAAE,EAAE,YAAA;AACnC,IAAAD,EAAKE,CAAG,IAAI,EAAE,OAAOD,EAAE,CAAC,GAAG,OAAOA,EAAE,CAAC,EAAA;AAAA,EACtC;AACA,SAAOD;AACR,GAEaL,IA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WAAW,IAAI,OAAOtB,CAAG,MACrBqB,MAAW,WAAW,IAAI,EAAE;AAAA,EACxD;AAAA,EACA,aAAa,CAACzB,GAAKT,GAAIa,GAAKf,MAAS;AACpC,UAAMmB,IAAOjB,EAAG,MAAM,GAAG,GACnBoC,IAAY,QAAQnB,EAAK,MAAM,GAAG,EAAE,EAAE,KAAK,GAAG,CAAC,KAC/CoB,IAAYvC,EAAK,YAAYsC,GAAWvB,CAAG,GAC3CyB,IAAOxC,EAAK,MAAMA,EAAK,QAAQ,OAAOuC,CAAS,GAAGxB,CAAG,GACrD0B,IAAO5B,EAAQ,aAAaF,CAAG,KAAK,KACpC0B,IAAOxB,EAAQ,QAAQ2B,CAAI,KAAK;AAEtC,QAAIpC,IAAO;AACX,WAAIiC,MAAS,QAAKjC,IAAO,SACrBiC,MAAS,QAAKjC,IAAO,YACrBiC,MAAS,QAAKjC,IAAO,eAClB,GAAGA,CAAI,IAAIqC,MAAS,MAAMtB,EAAK,IAAA,IAAQsB,EAAK,QAAQ1D,GAAkB,EAAE,CAAC;AAAA,EACjF;AAAA,EACA,iBAAiB,CAACkD,GAAMC,GAAKnB,GAAKf,MAAS;AAC1C,UAAMmC,IAAKnC,EAAK,QAAQ,KAAKA,EAAK,QAAQ,yBAAyBe,CAAG,CAAC;AAEvE,WAAO,OADIf,EAAK,MAAMmC,IAAK,GAAGnC,EAAK,QAAQ,WAAWmC,CAAE,CAAC,EACxC,QAAQpD,GAAkB,EAAE,CAAC;AAAA,EAC/C;AACD;"}
|
|
1
|
+
{"version":3,"file":"law-helper.js","sources":["../../designsystem/law/law-helper.ts"],"sourcesContent":["import { attr } from \"../utils\";\n\n// NOTE: The law format is documentet in https://api.lovdata.no/xmldocs\nconst REGEX_ID = /<[^>]+\\bid=\"([^\"]+)[^>]+>/gi;\nconst REGEX_FORORDNING = /\\([^)]{1,4}\\).{1,9}\\d+\\/\\d+/i; // Match (EU) 2016/2031, (EF) nr. 2020/1054, (EFF) ..., etc.\nconst REGEX_HEADING = /<(h\\d|[^>]+role=\"heading\")[^>]*>(.*?)<\\/?(h\\d|br|div)/i; // Can be both <h1>-<h6> and or <div> with role=\"heading\" if level 7+\nconst REGEX_KAPITTEL_LEDD = /kapittel-\\d+-ledd-\\d+/;\nconst REGEX_STRIP_BUTTONS = /<button[^>]+>.*?<\\/button>/g;\nconst REGEX_STRIP_POINTER = /►m\\d+/i;\nconst REGEX_STRIP_TAGS = /<[^>]+>/g;\nconst REGEX_META =\n\t/<dt([^>]*class=\"([^\"]+)\")?[^>]*>(.*?)<\\/dt><dd[^>]*>(.*?)<\\/dd>/gis;\n\nconst REGEX_FIX_TAGS = /<(\\/?)(article|footer|section)/gi;\nconst REGEX_FIX_BASEURL = /(src|href)=\"([^\"]+)\"/gi;\nconst REGEX_FIX_LISTS = /(<li[^>]*)>\\s*<div([^>]*>)|<\\/div>(<\\/li>)/gi;\nconst REGEX_FIX_SPAN_ID =\n\t/(<li[^>]+data-name=\"([^\"]+)[^>]+>)(\\s*<(ul|ol|div)[^>]+>)/gis; // Only create span if no span exists\nconst REGEX_FIX_NUMBEREDLEGALP =\n\t/(<[^>]+class=\"[^\"]*\\bnumberedLegalP\\b[^>]+>\\s*)(\\d+\\.)(.*?)(?=<\\/?(ul|ol|div)|$)/gis;\n\nconst BASE_URL = \"https://lovdata.no/\";\nconst META_DEFAULT: Record<\n\t\"legacyid\" | \"title\" | \"titleshort\" | \"url\" | (string & {}), // Ensure title and titleShort are always present\n\t{ label: string; value: string }\n> = {\n\tlegacyid: { label: \"Datokode\", value: \"\" },\n\ttitleshort: { label: \"Korttittel\", value: \"\" },\n\ttitle: { label: \"Tittel\", value: \"\" },\n\turl: { label: \"Url\", value: \"\" },\n};\n\ntype Ids = string | string[] | HTMLButtonElement | HTMLButtonElement[];\nconst toIdArray = (ids: Ids): string[] =>\n\tArray.from(Array.isArray(ids) ? ids : [ids], (id) =>\n\t\tid instanceof HTMLButtonElement ? id.value : id,\n\t);\n\nexport const getLawChecked = (lawElement?: HTMLElement | null) =>\n\tArray.from(\n\t\tlawElement?.querySelectorAll(`button[aria-checked=\"true\"]`) || [],\n\t\t(btn) => (btn as HTMLButtonElement).value,\n\t);\n\nexport const toggleLawChecked = (ids: Ids, lawElement?: HTMLElement | null) => {\n\tconst idArray = toIdArray(ids);\n\tlawElement?.querySelectorAll(`button`).forEach((btn) => {\n\t\tif (idArray.includes(btn.value))\n\t\t\tattr(btn, \"aria-checked\", `${attr(btn, \"aria-checked\") !== \"true\"}`);\n\t});\n};\n\nexport const setLawChecked = (ids: Ids, lawElement?: HTMLElement | null) => {\n\tconst idArray = toIdArray(ids);\n\tlawElement?.querySelectorAll(\"button\").forEach((btn) => {\n\t\tattr(btn, \"aria-checked\", `${idArray.includes(btn.value) || false}`);\n\t});\n};\n\nexport const parseLawIds = (ids: string | string[], lawHtml: string) => {\n\tconst html = fixLawHtml(lawHtml);\n\treturn toIdArray(ids)\n\t\t.map((id) => parseLawId(id, html))\n\t\t.filter((unit) => !!unit);\n};\n\nexport const parseLawMeta = (lawHtml: string) => {\n\tconst html = lawHtml.slice(0, lawHtml.indexOf(\"</dl>\"));\n\tconst meta = { ...META_DEFAULT };\n\tfor (const m of html.matchAll(REGEX_META)) {\n\t\tconst key = m[2].replace(/-/g, \"\").toLowerCase();\n\t\tmeta[key] = { label: m[3], value: m[4] };\n\t}\n\treturn meta;\n};\n\nexport const fixLawHtml = (lawHtml: string) => {\n\tif (!lawHtml.includes(\"<main\")) return lawHtml; // Already rendered\n\treturn (lawHtml.split(/<\\/?main[^>]*>/)[1] || \"\") // Only need content in <main>\n\t\t.replace(REGEX_FIX_TAGS, \"<$1div\") // Better for accessibility, must run before other REGEX_FIX\n\t\t.replace(REGEX_FIX_LISTS, \"$1$2$3\") // Merge <li> with inner <div> to reduce unnecessary elements\n\t\t.replace(REGEX_FIX_BASEURL, (_, attr, url) => {\n\t\t\treturn `${attr}=\"${url.includes(\":\") ? \"\" : BASE_URL}${url}\" ${attr === \"href\" ? 'rel=\"noopener noreferrer\" target=\"_blank\"' : \"\"}`;\n\t\t})\n\t\t.replace(REGEX_FIX_NUMBEREDLEGALP, (_, tag, id, ledd) => {\n\t\t\treturn `${tag}<span class=\"data-originalId\">${id}</span><div class=\"legalP\" id=\"${getAttr(\"id\", tag)}-ledd-0\">${ledd}</div>`;\n\t\t})\n\t\t.replace(REGEX_FIX_SPAN_ID, (_, tag, id, child) => {\n\t\t\treturn `${tag}<span class=\"data-originalId\">${id}</span>${child}`;\n\t\t})\n\t\t.replace(REGEX_ID, (tag, id, idx, html) => {\n\t\t\tconst label = getLabel(tag, id, idx, html);\n\t\t\treturn `${tag}${label ? `<button type=\"button\" role=\"checkbox\" aria-label=\"${label}\" value=\"${id}\"></button>` : \"\"}`;\n\t\t});\n};\n\nconst parseLawId = (id: string, html: string) => {\n\tconst isKapitellLedd = REGEX_KAPITTEL_LEDD.test(id);\n\tconst path = id\n\t\t.split(\"-\")\n\t\t.map((_, i, all) =>\n\t\t\ti % 2\n\t\t\t\t? parseLawItem(all.slice(0, i + 1).join(\"-\"), html, isKapitellLedd)\n\t\t\t\t: null,\n\t\t)\n\t\t.filter((unit) => !!unit);\n\n\tif (!path.length) return null;\n\tconst url = path.filter(({ url }) => url).pop()?.url || \"\"; // The closest units item might not have an URL, so we provide the last found URL\n\tconst forordninger = path.filter(\n\t\t(u) => u.className === \"section\" && REGEX_FORORDNING.test(u.label),\n\t);\n\tconst label = path\n\t\t.slice(path.indexOf(forordninger.pop() || path[0]))\n\t\t.map((u) => u.label)\n\t\t.join(\", \");\n\n\treturn { ...path.slice(-1)[0], path, label, url };\n};\n\nconst parseLawItem = (id: string, html: string, isKapitellLedd: boolean) => {\n\tconst idx = html.lastIndexOf(\"<\", html.indexOf(` id=\"${id}\"`));\n\tconst tag = html.slice(idx, html.indexOf(\">\", idx) + 1);\n\tconst className = getAttr(\"class\", tag);\n\tconst url = getAttr(\"data-lovdata-url\", tag);\n\tconst label = getLabel(tag, id, idx, html);\n\n\treturn {\n\t\tid,\n\t\tclassName,\n\t\thtml: getOuterHTML(id, html),\n\t\turl: url ? `${BASE_URL}${url}` : \"\",\n\t\tlabel:\n\t\t\t(!isKapitellLedd &&\n\t\t\t\tclassName === \"section\" &&\n\t\t\t\tlabel?.match(REGEX_FORORDNING)?.[0]) ||\n\t\t\tlabel,\n\t};\n};\n\nconst getAttr = (attr: string, html: string) => {\n\tconst query = ` ${attr.toLowerCase()}=\"`;\n\tconst idx = html.toLowerCase().indexOf(query); // Need to lowercase to sanitize html variations\n\tconst start = idx + query.length;\n\treturn idx === -1 ? \"\" : html.slice(start, html.indexOf('\"', start)); // Using slice for performance\n};\n\nconst getOuterHTML = (id: string, html: string) => {\n\tconst idx = html.lastIndexOf(\"<\", html.indexOf(` id=\"${id}\"`));\n\tconst max = html.length;\n\tlet i = idx + 1; // Using + 1 to get 0 if not found, and to ensure we start searching inside element\n\tlet depth = 0;\n\n\twhile (i && i < max) {\n\t\ti = html.indexOf(\"<\", i) + 1;\n\t\tif (html[i] !== \"/\") depth++;\n\t\telse if (--depth < 0) break;\n\t}\n\tconst end = html.indexOf(\">\", i) + 1;\n\treturn i ? html.slice(idx, end).replace(REGEX_STRIP_BUTTONS, \"\") : \"\";\n};\n\nconst getLabel = (tag: string, id: string, idx: number, html: string): string =>\n\tLABELS[getAttr(\"class\", tag)]?.(tag, id, idx, html) || \"\";\n\nconst LABELS: Record<string, typeof getLabel> = {\n\tnumberedLegalP: (tag) => `nr. ${getAttr(\"data-numerator\", tag)}.`,\n\tsection: (_tag, _id, idx, html) => {\n\t\tconst head = html.slice(idx).match(REGEX_HEADING)?.[2];\n\t\tconst clean = head?.replace(REGEX_STRIP_TAGS, \"\");\n\t\treturn clean?.replace(REGEX_STRIP_POINTER, \"\").trim() || \"\";\n\t},\n\tlegalArticle: (_tag, _id, idx, html) => {\n\t\tconst at = html.indexOf(\">\", html.indexOf(\"legalArticleValue\", idx));\n\t\tconst id = html.slice(at + 1, html.indexOf(\"</span>\", at)); // .legalArticleValue is always a <span>\n\t\treturn id.replace(REGEX_STRIP_TAGS, \"\").replace(\"Artikkel\", \"artikkel\");\n\t},\n\tlegalP: (_tag, id) => {\n\t\tconst [idx, type, _, parent] = id.split(\"-\").reverse(); // If placed inside numberedLegalP, parent is \"nummer\"\n\t\tconst count = type === \"nummer\" ? 1 : Number(idx); // If \"fake\" ledd 1 created by fixNumberedLegalP, type is \"number\"\n\t\treturn `avsnitt ${count + (parent === \"nummer\" ? 1 : 0)}`; // Adjust for numberedLegalP creating fake legalP starting at 1\n\t},\n\tlistArticle: (tag, id, idx, html) => {\n\t\tconst path = id.split(\"-\");\n\t\tconst parentTag = ` id=\"${path.slice(0, -2).join(\"-\")}\"`; // Since lists can be nested, we need to find parent law unit to get correct list\n\t\tconst parentIdx = html.lastIndexOf(parentTag, idx);\n\t\tconst list = html.slice(html.indexOf(\"<ol\", parentIdx), idx); // Find first <ol> after parent element opening tag\n\t\tconst name = getAttr(\"data-name\", tag) || \"-\"; // Name can be empty or dash so allways fallback to dash\n\t\tconst type = getAttr(\"type\", list) || \"-\";\n\n\t\tlet unit = \"punkt\";\n\t\tif (type === \"1\") unit = \"tall\";\n\t\tif (type === \"a\") unit = \"bokstav\";\n\t\tif (type === \"i\") unit = \"romtertall\";\n\t\treturn `${unit} ${name === \"-\" ? path.pop() : name.replace(REGEX_STRIP_TAGS, \"\")}`;\n\t},\n\tmarginIdArticle: (_tag, _id, idx, html) => {\n\t\tconst at = html.indexOf(\">\", html.indexOf(\"data-marginOriginalId\", idx));\n\t\tconst id = html.slice(at + 1, html.indexOf(\"</span>\", at));\n\t\treturn `nr. ${id.replace(REGEX_STRIP_TAGS, \"\")}`;\n\t},\n};\n"],"names":["attr","url"],"mappings":";AAGA,MAAM,WAAW;AACjB,MAAM,mBAAmB;AACzB,MAAM,gBAAgB;AACtB,MAAM,sBAAsB;AAC5B,MAAM,sBAAsB;AAC5B,MAAM,sBAAsB;AAC5B,MAAM,mBAAmB;AACzB,MAAM,aACL;AAED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Q,WAAW,EAAE,CAAC;AACzD,WAAO,OAAO,GAAG,QAAQ,kBAAkB,EAAE,CAAC;AAAA,EAC/C;AACD;"}
|
package/mtds/law/law.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
export type LawProps = React.ComponentPropsWithoutRef<"div"
|
|
2
|
-
|
|
1
|
+
export type LawProps = React.ComponentPropsWithoutRef<"div"> & {
|
|
2
|
+
"data-variant"?: "view" | "readonly";
|
|
3
|
+
};
|
|
4
|
+
export declare const Law: import('react').ForwardRefExoticComponent<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
5
|
+
"data-variant"?: "view" | "readonly";
|
|
6
|
+
} & import('react').RefAttributes<HTMLDivElement>>;
|
package/mtds/law/law.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
import { forwardRef
|
|
3
|
-
import
|
|
4
|
-
const
|
|
5
|
-
return /* @__PURE__ */
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import styles from "../styles.module.css.js";
|
|
4
|
+
const Law = forwardRef(function Law2({ className, ...rest }, ref) {
|
|
5
|
+
return /* @__PURE__ */ jsx("div", { className: styles.law, ref, ...rest });
|
|
6
6
|
});
|
|
7
7
|
export {
|
|
8
|
-
|
|
8
|
+
Law
|
|
9
9
|
};
|
|
10
10
|
//# sourceMappingURL=law.js.map
|
package/mtds/law/law.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"law.js","sources":["../../designsystem/law/law.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport styles from \"../styles.module.css\";\n\nexport type LawProps = React.ComponentPropsWithoutRef<\"div\"
|
|
1
|
+
{"version":3,"file":"law.js","sources":["../../designsystem/law/law.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport styles from \"../styles.module.css\";\n\nexport type LawProps = React.ComponentPropsWithoutRef<\"div\"> & {\n\t\"data-variant\"?: \"view\" | \"readonly\";\n};\n\nexport const Law = forwardRef<HTMLDivElement, LawProps>(function Law(\n\t{ className, ...rest },\n\tref,\n) {\n\treturn <div className={styles.law} ref={ref} {...rest} />;\n});\n"],"names":["Law"],"mappings":";;;AAOO,MAAM,MAAM,WAAqC,SAASA,KAChE,EAAE,WAAW,GAAG,KAAA,GAChB,KACC;AACD,6BAAQ,OAAA,EAAI,WAAW,OAAO,KAAK,KAAW,GAAG,MAAM;AACxD,CAAC;"}
|
package/mtds/layout/layout.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
import
|
|
3
|
-
import { forwardRef
|
|
4
|
-
import
|
|
5
|
-
const
|
|
6
|
-
|
|
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 Flex = forwardRef(function Flex2({ as, className, ...rest }, ref) {
|
|
6
|
+
const Tag = as || "div";
|
|
7
|
+
return /* @__PURE__ */ jsx(Tag, { className: clsx(styles.flex, className), ref, ...rest });
|
|
8
|
+
});
|
|
9
|
+
const Grid = forwardRef(function Grid2({ as, className, ...rest }, ref) {
|
|
10
|
+
const Tag = as || "div";
|
|
11
|
+
return /* @__PURE__ */ jsx(Tag, { className: clsx(styles.grid, className), ref, ...rest });
|
|
9
12
|
});
|
|
10
13
|
export {
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
Flex,
|
|
15
|
+
Grid
|
|
13
16
|
};
|
|
14
17
|
//# sourceMappingURL=layout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.js","sources":["../../designsystem/layout/layout.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 GapOld = \"none\" | \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\";\n\ntype SharedProps = {\n\t\"data-align\"?: \"normal\" | \"stretch\" | \"start\" | \"center\" | \"end\";\n\t\"data-align-content\"?:\n\t\t| \"start\"\n\t\t| \"center\"\n\t\t| \"end\"\n\t\t| \"space-between\"\n\t\t| \"space-around\"\n\t\t| \"space-evenly\";\n\t\"data-center\"?: \"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\";\n\t\"data-gap\"?: Sizes | GapOld;\n\t\"data-row-gap\"?: Sizes;\n\t\"data-column-gap\"?: Sizes;\n\t\"data-nowrap\"?: boolean;\n\t\"data-justify\"?:\n\t\t| \"start\"\n\t\t| \"center\"\n\t\t| \"end\"\n\t\t| \"space-between\"\n\t\t| \"space-around\"\n\t\t| \"space-evenly\";\n\t\"data-fixed\"?: boolean;\n\t\"data-items\"?:\n\t\t| \"auto\"\n\t\t| \"full\"\n\t\t| \"50\"\n\t\t| \"100\"\n\t\t| \"150\"\n\t\t| \"200\"\n\t\t| \"250\"\n\t\t| \"300\"\n\t\t| \"350\"\n\t\t| \"400\"\n\t\t| \"450\"\n\t\t| \"500\"\n\t\t| 50\n\t\t| 100\n\t\t| 150\n\t\t| 200\n\t\t| 250\n\t\t| 300\n\t\t| 350\n\t\t| 400\n\t\t| 450\n\t\t| 500;\n};\n\n/**\n * Flex\n */\nexport type FlexProps<As extends React.ElementType = \"div\"> =\n\tPolymorphicComponentPropWithRef<As, SharedProps>;\n\ntype FlexComponent = <As extends React.ElementType = \"div\">(\n\tprops: FlexProps<As>,\n) => JSX.Element;\n\nexport const Flex: FlexComponent = forwardRef<null>(function Flex<\n\tAs extends React.ElementType = \"div\",\n>({ as, className, ...rest }: FlexProps<As>, ref?: PolymorphicRef<As>) {\n\tconst Tag = as || \"div\";\n\n\treturn <Tag className={clsx(styles.flex, className)} ref={ref} {...rest} />;\n}) as FlexComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n\n/**\n * Grid\n */\nexport type GridProps<As extends React.ElementType = \"div\"> =\n\tPolymorphicComponentPropWithRef<As, SharedProps>;\n\ntype GridComponent = <As extends React.ElementType = \"div\">(\n\tprops: GridProps<As>,\n) => JSX.Element;\n\nexport const Grid: GridComponent = forwardRef<null>(function Grid<\n\tAs extends React.ElementType = \"div\",\n>({ as, className, ...rest }: GridProps<As>, ref?: PolymorphicRef<As>) {\n\tconst Tag = as || \"div\";\n\n\treturn <Tag className={clsx(styles.grid, className)} ref={ref} {...rest} />;\n}) as GridComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n"],"names":["Flex","
|
|
1
|
+
{"version":3,"file":"layout.js","sources":["../../designsystem/layout/layout.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 GapOld = \"none\" | \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\";\n\ntype SharedProps = {\n\t\"data-align\"?: \"normal\" | \"stretch\" | \"start\" | \"center\" | \"end\";\n\t\"data-align-content\"?:\n\t\t| \"start\"\n\t\t| \"center\"\n\t\t| \"end\"\n\t\t| \"space-between\"\n\t\t| \"space-around\"\n\t\t| \"space-evenly\";\n\t\"data-center\"?: \"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\";\n\t\"data-gap\"?: Sizes | GapOld;\n\t\"data-row-gap\"?: Sizes;\n\t\"data-column-gap\"?: Sizes;\n\t\"data-nowrap\"?: boolean;\n\t\"data-justify\"?:\n\t\t| \"start\"\n\t\t| \"center\"\n\t\t| \"end\"\n\t\t| \"space-between\"\n\t\t| \"space-around\"\n\t\t| \"space-evenly\";\n\t\"data-fixed\"?: boolean;\n\t\"data-items\"?:\n\t\t| \"auto\"\n\t\t| \"full\"\n\t\t| \"50\"\n\t\t| \"100\"\n\t\t| \"150\"\n\t\t| \"200\"\n\t\t| \"250\"\n\t\t| \"300\"\n\t\t| \"350\"\n\t\t| \"400\"\n\t\t| \"450\"\n\t\t| \"500\"\n\t\t| 50\n\t\t| 100\n\t\t| 150\n\t\t| 200\n\t\t| 250\n\t\t| 300\n\t\t| 350\n\t\t| 400\n\t\t| 450\n\t\t| 500;\n};\n\n/**\n * Flex\n */\nexport type FlexProps<As extends React.ElementType = \"div\"> =\n\tPolymorphicComponentPropWithRef<As, SharedProps>;\n\ntype FlexComponent = <As extends React.ElementType = \"div\">(\n\tprops: FlexProps<As>,\n) => JSX.Element;\n\nexport const Flex: FlexComponent = forwardRef<null>(function Flex<\n\tAs extends React.ElementType = \"div\",\n>({ as, className, ...rest }: FlexProps<As>, ref?: PolymorphicRef<As>) {\n\tconst Tag = as || \"div\";\n\n\treturn <Tag className={clsx(styles.flex, className)} ref={ref} {...rest} />;\n}) as FlexComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n\n/**\n * Grid\n */\nexport type GridProps<As extends React.ElementType = \"div\"> =\n\tPolymorphicComponentPropWithRef<As, SharedProps>;\n\ntype GridComponent = <As extends React.ElementType = \"div\">(\n\tprops: GridProps<As>,\n) => JSX.Element;\n\nexport const Grid: GridComponent = forwardRef<null>(function Grid<\n\tAs extends React.ElementType = \"div\",\n>({ as, className, ...rest }: GridProps<As>, ref?: PolymorphicRef<As>) {\n\tconst Tag = as || \"div\";\n\n\treturn <Tag className={clsx(styles.grid, className)} ref={ref} {...rest} />;\n}) as GridComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n"],"names":["Flex","Grid"],"mappings":";;;;AAoEO,MAAM,OAAsB,WAAiB,SAASA,MAE3D,EAAE,IAAI,WAAW,GAAG,KAAA,GAAuB,KAA0B;AACtE,QAAM,MAAM,MAAM;AAElB,SAAO,oBAAC,KAAA,EAAI,WAAW,KAAK,OAAO,MAAM,SAAS,GAAG,KAAW,GAAG,KAAA,CAAM;AAC1E,CAAC;AAYM,MAAM,OAAsB,WAAiB,SAASC,MAE3D,EAAE,IAAI,WAAW,GAAG,KAAA,GAAuB,KAA0B;AACtE,QAAM,MAAM,MAAM;AAElB,SAAO,oBAAC,KAAA,EAAI,WAAW,KAAK,OAAO,MAAM,SAAS,GAAG,KAAW,GAAG,KAAA,CAAM;AAC1E,CAAC;"}
|
package/mtds/link/link.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
import
|
|
3
|
-
import { forwardRef
|
|
4
|
-
import
|
|
5
|
-
const
|
|
6
|
-
|
|
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 Link = forwardRef(function Link2({ as, className, ...rest }, ref) {
|
|
6
|
+
const Tag = as || "a";
|
|
7
|
+
return /* @__PURE__ */ jsx(Tag, { className: clsx(styles.link, className), ...rest, ref });
|
|
7
8
|
});
|
|
8
9
|
export {
|
|
9
|
-
|
|
10
|
+
Link
|
|
10
11
|
};
|
|
11
12
|
//# sourceMappingURL=link.js.map
|
package/mtds/link/link.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.js","sources":["../../designsystem/link/link.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { forwardRef } from \"react\";\nimport type {\n\tPolymorphicComponentPropWithRef,\n\tPolymorphicRef,\n} from \"../react-types\";\nimport styles from \"../styles.module.css\";\n\nexport type LinkProps<As extends React.ElementType = \"a\"> =\n\tPolymorphicComponentPropWithRef<As>;\n\ntype LinkComponent = <As extends React.ElementType = \"a\">(\n\tprops: LinkProps<As>,\n) => React.ReactElement | null;\n\nexport const Link: LinkComponent = forwardRef<null>(function Link<\n\tAs extends React.ElementType = \"a\",\n>({ as, className, ...rest }: LinkProps<As>, ref?: PolymorphicRef<As>) {\n\tconst Tag = as || \"a\";\n\treturn <Tag className={clsx(styles.link, className)} {...rest} ref={ref} />;\n}) as LinkComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n"],"names":["Link"
|
|
1
|
+
{"version":3,"file":"link.js","sources":["../../designsystem/link/link.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { forwardRef } from \"react\";\nimport type {\n\tPolymorphicComponentPropWithRef,\n\tPolymorphicRef,\n} from \"../react-types\";\nimport styles from \"../styles.module.css\";\n\nexport type LinkProps<As extends React.ElementType = \"a\"> =\n\tPolymorphicComponentPropWithRef<As>;\n\ntype LinkComponent = <As extends React.ElementType = \"a\">(\n\tprops: LinkProps<As>,\n) => React.ReactElement | null;\n\nexport const Link: LinkComponent = forwardRef<null>(function Link<\n\tAs extends React.ElementType = \"a\",\n>({ as, className, ...rest }: LinkProps<As>, ref?: PolymorphicRef<As>) {\n\tconst Tag = as || \"a\";\n\treturn <Tag className={clsx(styles.link, className)} {...rest} ref={ref} />;\n}) as LinkComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n"],"names":["Link"],"mappings":";;;;AAeO,MAAM,OAAsB,WAAiB,SAASA,MAE3D,EAAE,IAAI,WAAW,GAAG,KAAA,GAAuB,KAA0B;AACtE,QAAM,MAAM,MAAM;AAClB,SAAO,oBAAC,KAAA,EAAI,WAAW,KAAK,OAAO,MAAM,SAAS,GAAI,GAAG,MAAM,IAAA,CAAU;AAC1E,CAAC;"}
|