@mattilsynet/design 3.3.9 → 3.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/mtds/_virtual/_rolldown/runtime.js +17 -0
- package/mtds/ai/card.stories.tsx +54 -77
- package/mtds/ai/layout.mdx +37 -1
- package/mtds/ai/layout.stories.tsx +126 -1
- package/mtds/ai/print.mdx +1 -1
- package/mtds/ai/print.stories.tsx +1 -2
- package/mtds/alert/alert.js +16 -11
- package/mtds/alert/alert.js.map +1 -1
- package/mtds/analytics/analytics.js +118 -118
- package/mtds/analytics/analytics.js.map +1 -1
- package/mtds/app/app-observer.js +31 -36
- package/mtds/app/app-observer.js.map +1 -1
- package/mtds/app/app-toggle.js +12 -26
- package/mtds/app/app-toggle.js.map +1 -1
- package/mtds/app/app-toggle2.js +6 -11
- package/mtds/app/app-toggle2.js.map +1 -1
- package/mtds/app/app.js +66 -60
- package/mtds/app/app.js.map +1 -1
- package/mtds/atlas/atlas-element.js +83 -93
- package/mtds/atlas/atlas-element.js.map +1 -1
- package/mtds/atlas/atlas-marker.js +63 -52
- package/mtds/atlas/atlas-marker.js.map +1 -1
- package/mtds/atlas/atlas-matgeo.js +67 -61
- package/mtds/atlas/atlas-matgeo.js.map +1 -1
- package/mtds/atlas/atlas-wms.js +33 -28
- package/mtds/atlas/atlas-wms.js.map +1 -1
- package/mtds/atlas/atlas.js +6 -38
- package/mtds/atlas/atlas.js.map +1 -1
- package/mtds/atlas/atlas2.js +39 -0
- package/mtds/atlas/atlas2.js.map +1 -0
- package/mtds/atlas/cluster.js +759 -1149
- package/mtds/atlas/cluster.js.map +1 -1
- package/mtds/atlas.iife.js +3 -4
- package/mtds/atlas.js +6 -14
- package/mtds/avatar/avatar.js +14 -10
- package/mtds/avatar/avatar.js.map +1 -1
- package/mtds/badge/badge.js +15 -10
- package/mtds/badge/badge.js.map +1 -1
- package/mtds/breadcrumbs/breadcrumbs.js +15 -19
- package/mtds/breadcrumbs/breadcrumbs.js.map +1 -1
- package/mtds/button/button.js +18 -20
- package/mtds/button/button.js.map +1 -1
- package/mtds/card/card.js +22 -15
- package/mtds/card/card.js.map +1 -1
- package/mtds/chart/chart-axis.js +33 -21
- package/mtds/chart/chart-axis.js.map +1 -1
- package/mtds/chart/chart-bars.js +23 -21
- package/mtds/chart/chart-bars.js.map +1 -1
- package/mtds/chart/chart-element.js +94 -88
- package/mtds/chart/chart-element.js.map +1 -1
- package/mtds/chart/chart-lines.js +35 -37
- package/mtds/chart/chart-lines.js.map +1 -1
- package/mtds/chart/chart-pies.js +17 -17
- package/mtds/chart/chart-pies.js.map +1 -1
- package/mtds/chart/chart.js +6 -52
- package/mtds/chart/chart.js.map +1 -1
- package/mtds/chart/chart2.js +21 -0
- package/mtds/chart/chart2.js.map +1 -0
- package/mtds/chip/chip.js +15 -11
- package/mtds/chip/chip.js.map +1 -1
- package/mtds/deprecations.js +76 -158
- package/mtds/deprecations.js.map +1 -1
- package/mtds/details/details.js +21 -24
- package/mtds/details/details.js.map +1 -1
- package/mtds/dialog/dialog.js +17 -21
- package/mtds/dialog/dialog.js.map +1 -1
- package/mtds/divider/divider.js +15 -20
- package/mtds/divider/divider.js.map +1 -1
- package/mtds/errorsummary/errorsummary.js +14 -16
- package/mtds/errorsummary/errorsummary.js.map +1 -1
- package/mtds/external/@turf/boolean-point-in-polygon/dist/esm/index.js +22 -25
- package/mtds/external/@turf/boolean-point-in-polygon/dist/esm/index.js.map +1 -1
- package/mtds/external/@turf/helpers/dist/esm/index.js +21 -24
- package/mtds/external/@turf/helpers/dist/esm/index.js.map +1 -1
- package/mtds/external/@turf/invariant/dist/esm/index.js +15 -19
- package/mtds/external/@turf/invariant/dist/esm/index.js.map +1 -1
- package/mtds/external/@u-elements/u-combobox/dist/u-combobox.js +270 -297
- package/mtds/external/@u-elements/u-combobox/dist/u-combobox.js.map +1 -1
- package/mtds/external/@u-elements/u-details/dist/u-details.js +75 -101
- package/mtds/external/@u-elements/u-details/dist/u-details.js.map +1 -1
- package/mtds/external/leaflet/dist/leaflet-src.js +4257 -6151
- package/mtds/external/leaflet/dist/leaflet-src.js.map +1 -1
- package/mtds/external/leaflet/dist/leaflet.css.js +5 -606
- package/mtds/external/leaflet/dist/leaflet.css.js.map +1 -1
- package/mtds/external/point-in-polygon-hao/dist/esm/index.js +24 -25
- package/mtds/external/point-in-polygon-hao/dist/esm/index.js.map +1 -1
- package/mtds/external/robust-predicates/esm/incircle.js +5 -0
- package/mtds/external/robust-predicates/esm/incircle.js.map +1 -0
- package/mtds/external/robust-predicates/esm/insphere.js +5 -0
- package/mtds/external/robust-predicates/esm/insphere.js.map +1 -0
- package/mtds/external/robust-predicates/esm/orient2d.js +20 -22
- package/mtds/external/robust-predicates/esm/orient2d.js.map +1 -1
- package/mtds/external/robust-predicates/esm/orient3d.js +5 -0
- package/mtds/external/robust-predicates/esm/orient3d.js.map +1 -0
- package/mtds/external/robust-predicates/esm/util.js +20 -28
- package/mtds/external/robust-predicates/esm/util.js.map +1 -1
- package/mtds/external/robust-predicates/index.js +5 -0
- package/mtds/field/field.js +167 -214
- package/mtds/field/field.js.map +1 -1
- package/mtds/fieldset/fieldset.js +32 -30
- package/mtds/fieldset/fieldset.js.map +1 -1
- package/mtds/fileupload/fileupload.js +16 -13
- package/mtds/fileupload/fileupload.js.map +1 -1
- package/mtds/helptext/helptext.js +25 -27
- package/mtds/helptext/helptext.js.map +1 -1
- package/mtds/identitet/illustrasjons-generator/illustrasjons-generator.d.ts +1 -0
- package/mtds/identitet/illustrasjons-generator/index-old-1.d.ts +1 -0
- package/mtds/identitet/infografikk-generator/infografikk-generator.d.ts +1 -0
- package/mtds/illustrations/index.json +1 -1
- package/mtds/index.iife.js +21 -21
- package/mtds/index.js +38 -31
- package/mtds/index.js.map +1 -1
- package/mtds/input/input.js +33 -47
- package/mtds/input/input.js.map +1 -1
- package/mtds/law/law-helper.js +106 -95
- package/mtds/law/law-helper.js.map +1 -1
- package/mtds/law/law.js +15 -10
- package/mtds/law/law.js.map +1 -1
- package/mtds/layout/layout.js +21 -13
- package/mtds/layout/layout.js.map +1 -1
- package/mtds/layout/layout.stories.d.ts +1 -0
- package/mtds/link/link.js +15 -10
- package/mtds/link/link.js.map +1 -1
- package/mtds/logo/logo-observer.js +18 -18
- package/mtds/logo/logo-observer.js.map +1 -1
- package/mtds/logo/logo.js +18 -18
- package/mtds/logo/logo.js.map +1 -1
- package/mtds/package.js +6 -0
- package/mtds/package.js.map +1 -0
- package/mtds/package.json.d.ts +112 -0
- package/mtds/pagination/pagination.js +46 -60
- package/mtds/pagination/pagination.js.map +1 -1
- package/mtds/popover/popover-observer.js +15 -15
- package/mtds/popover/popover-observer.js.map +1 -1
- package/mtds/popover/popover.js +18 -20
- package/mtds/popover/popover.js.map +1 -1
- package/mtds/print/print.js +15 -10
- package/mtds/print/print.js.map +1 -1
- package/mtds/print/print.stories.d.ts +0 -1
- package/mtds/profilering/epost.d.ts +1 -0
- package/mtds/progress/progress.js +15 -13
- package/mtds/progress/progress.js.map +1 -1
- package/mtds/react-atlas.js +7 -16
- package/mtds/react.js +36 -84
- package/mtds/skeleton/skeleton.js +15 -11
- package/mtds/skeleton/skeleton.js.map +1 -1
- package/mtds/spinner/spinner.js +16 -13
- package/mtds/spinner/spinner.js.map +1 -1
- package/mtds/steps/steps.js +15 -10
- package/mtds/steps/steps.js.map +1 -1
- package/mtds/styles.css +2 -1
- package/mtds/styles.module.js +122 -0
- package/mtds/styles.module.js.map +1 -0
- package/mtds/table/table-observer.js +23 -28
- package/mtds/table/table-observer.js.map +1 -1
- package/mtds/table/table.js +88 -60
- package/mtds/table/table.js.map +1 -1
- package/mtds/tabs/tabs.js +32 -27
- package/mtds/tabs/tabs.js.map +1 -1
- package/mtds/tag/tag.js +16 -19
- package/mtds/tag/tag.js.map +1 -1
- package/mtds/tailwind.css +0 -4
- package/mtds/toast/toast-helper.js +45 -25
- package/mtds/toast/toast-helper.js.map +1 -1
- package/mtds/toast/toast-observer.js +18 -18
- package/mtds/toast/toast-observer.js.map +1 -1
- package/mtds/toast/toast.js +67 -54
- package/mtds/toast/toast.js.map +1 -1
- package/mtds/togglegroup/togglegroup.js +31 -40
- package/mtds/togglegroup/togglegroup.js.map +1 -1
- package/mtds/tooltip/tooltip-element.js +12 -25
- package/mtds/tooltip/tooltip-element.js.map +1 -1
- package/mtds/typography/typography.js +38 -21
- package/mtds/typography/typography.js.map +1 -1
- package/mtds/utils.js +53 -70
- package/mtds/utils.js.map +1 -1
- package/mtds/validation/validation-observer.js +40 -47
- package/mtds/validation/validation-observer.js.map +1 -1
- package/mtds/validation/validation.js +17 -21
- package/mtds/validation/validation.js.map +1 -1
- package/package.json +9 -9
- package/mtds/atlas/atlas.css.js +0 -138
- package/mtds/atlas/atlas.css.js.map +0 -1
- package/mtds/atlas.js.map +0 -1
- package/mtds/chart/chart.css.js +0 -187
- package/mtds/chart/chart.css.js.map +0 -1
- package/mtds/package.json.js +0 -5
- package/mtds/package.json.js.map +0 -1
- package/mtds/react-atlas.js.map +0 -1
- package/mtds/react.js.map +0 -1
- package/mtds/styles.module.css.js +0 -118
- package/mtds/styles.module.css.js.map +0 -1
package/mtds/app/app.js
CHANGED
|
@@ -1,61 +1,67 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
1
|
+
import e from "../styles.module.js";
|
|
2
|
+
import { Button as t } from "../button/button.js";
|
|
3
|
+
import n from "./app-toggle2.js";
|
|
4
|
+
import r from "clsx";
|
|
5
|
+
import { forwardRef as i } from "react";
|
|
6
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
7
|
+
//#region designsystem/app/app.tsx
|
|
8
|
+
var o = i(function({ as: t, className: n, ...i }, o) {
|
|
9
|
+
return /* @__PURE__ */ a(t || "div", {
|
|
10
|
+
className: r(e.app, n),
|
|
11
|
+
ref: o,
|
|
12
|
+
...i
|
|
13
|
+
});
|
|
14
|
+
}), s = i(function({ as: t, className: n, ...i }, o) {
|
|
15
|
+
return /* @__PURE__ */ a(t || "div", {
|
|
16
|
+
className: r(e.sticky, n),
|
|
17
|
+
ref: o,
|
|
18
|
+
...i
|
|
19
|
+
});
|
|
20
|
+
}), c = Object.assign(o, {
|
|
21
|
+
Header: i(function(e, t) {
|
|
22
|
+
return /* @__PURE__ */ a("header", {
|
|
23
|
+
ref: t,
|
|
24
|
+
...e
|
|
25
|
+
});
|
|
26
|
+
}),
|
|
27
|
+
Sidebar: i(function(e, t) {
|
|
28
|
+
return /* @__PURE__ */ a("dialog", {
|
|
29
|
+
role: "navigation",
|
|
30
|
+
id: "mtds-sidebar",
|
|
31
|
+
suppressHydrationWarning: !0,
|
|
32
|
+
ref: t,
|
|
33
|
+
...e
|
|
34
|
+
});
|
|
35
|
+
}),
|
|
36
|
+
Sticky: s,
|
|
37
|
+
Toggle: i(function({ children: e, ...n }, r) {
|
|
38
|
+
return /* @__PURE__ */ a(t, {
|
|
39
|
+
command: "show-modal",
|
|
40
|
+
commandfor: "mtds-sidebar",
|
|
41
|
+
"data-tooltip": "Vis meny",
|
|
42
|
+
ref: r,
|
|
43
|
+
...n,
|
|
44
|
+
children: e ?? "Skjul meny"
|
|
45
|
+
});
|
|
46
|
+
}),
|
|
47
|
+
Main: i(function(e, t) {
|
|
48
|
+
return /* @__PURE__ */ a("main", {
|
|
49
|
+
ref: t,
|
|
50
|
+
...e
|
|
51
|
+
});
|
|
52
|
+
}),
|
|
53
|
+
Footer: i(function(e, t) {
|
|
54
|
+
return /* @__PURE__ */ a("footer", {
|
|
55
|
+
ref: t,
|
|
56
|
+
...e
|
|
57
|
+
});
|
|
58
|
+
}),
|
|
59
|
+
Script: () => /* @__PURE__ */ a("script", {
|
|
60
|
+
id: "mtds-app-script",
|
|
61
|
+
children: n
|
|
62
|
+
})
|
|
57
63
|
});
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
//# sourceMappingURL=app.js.map
|
|
64
|
+
//#endregion
|
|
65
|
+
export { c as App };
|
|
66
|
+
|
|
67
|
+
//# sourceMappingURL=app.js.map
|
package/mtds/app/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sources":["../../designsystem/app/app.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { forwardRef, type JSX } from \"react\";\nimport { Button, type ButtonProps } from \"../button/button\";\nimport type {\n\tPolymorphicComponentPropWithRef,\n\tPolymorphicRef,\n} from \"../react-types\";\nimport styles from \"../styles.module.css\";\nimport script from \"./app-toggle.js?raw\";\n\nexport type AppHeaderProps = React.ComponentPropsWithoutRef<\"header\">;\nexport type AppSidebarProps = React.ComponentPropsWithoutRef<\"dialog\">;\nexport type AppStickyProps = React.ComponentPropsWithoutRef<\"div\">;\nexport type AppMainProps = React.ComponentPropsWithoutRef<\"main\">;\nexport type AppFooterProps = React.ComponentPropsWithoutRef<\"footer\">;\nexport type AppProps<As extends React.ElementType = \"div\"> =\n\tPolymorphicComponentPropWithRef<\n\t\tAs,\n\t\t{\n\t\t\t\"data-variant\"?: \"mobilebar\";\n\t\t}\n\t>;\n\ntype AppComponent = <As extends React.ElementType = \"div\">(\n\tprops: AppProps<As>,\n) => JSX.Element;\n\nconst AppComp = forwardRef<null>(function App<\n\tAs extends React.ElementType = \"div\",\n>({ as, className, ...rest }: AppProps<As>, ref?: PolymorphicRef<As>) {\n\tconst Tag = as || \"div\";\n\n\treturn <Tag className={clsx(styles.app, className)} ref={ref} {...rest} />;\n}) as AppComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n\nconst AppSticky = forwardRef<null>(function App<\n\tAs extends React.ElementType = \"div\",\n>({ as, className, ...rest }: AppProps<As>, ref?: PolymorphicRef<As>) {\n\tconst Tag = as || \"div\";\n\n\treturn <Tag className={clsx(styles.sticky, className)} ref={ref} {...rest} />;\n}) as AppComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n\nexport const App = Object.assign(AppComp, {\n\tHeader: forwardRef<HTMLElement, AppHeaderProps>(\n\t\tfunction AppHeader(rest, ref) {\n\t\t\treturn <header ref={ref} {...rest} />;\n\t\t},\n\t),\n\tSidebar: forwardRef<HTMLDialogElement, AppSidebarProps>(\n\t\tfunction AppSidebar(rest, ref) {\n\t\t\treturn (\n\t\t\t\t<dialog\n\t\t\t\t\trole=\"navigation\"\n\t\t\t\t\tid=\"mtds-sidebar\"\n\t\t\t\t\tsuppressHydrationWarning // Needed due to closedby polyfill\n\t\t\t\t\tref={ref}\n\t\t\t\t\t{...rest}\n\t\t\t\t/>\n\t\t\t);\n\t\t},\n\t),\n\tSticky: AppSticky,\n\tToggle: forwardRef<HTMLButtonElement, ButtonProps<\"button\">>(\n\t\tfunction AppToggle({ children, ...rest }: ButtonProps<\"button\">, ref) {\n\t\t\treturn (\n\t\t\t\t<Button\n\t\t\t\t\tcommand=\"show-modal\"\n\t\t\t\t\tcommandfor=\"mtds-sidebar\"\n\t\t\t\t\tdata-tooltip=\"Vis meny\"\n\t\t\t\t\tref={ref as React.Ref<HTMLAnchorElement>}\n\t\t\t\t\t{...rest}\n\t\t\t\t>\n\t\t\t\t\t{children ?? \"Skjul meny\"}\n\t\t\t\t</Button>\n\t\t\t);\n\t\t},\n\t),\n\tMain: forwardRef<HTMLElement, AppMainProps>(function AppMain(rest, ref) {\n\t\treturn <main ref={ref} {...rest} />;\n\t}),\n\tFooter: forwardRef<HTMLElement, AppFooterProps>(\n\t\tfunction AppFooter(rest, ref) {\n\t\t\treturn <footer ref={ref} {...rest} />;\n\t\t},\n\t),\n\t// Needed to avoid flash of unstyled content and still be Next.js hydration compatible\n\tScript: () => <script id=\"mtds-app-script\">{script}</script>,\n});\n"],"
|
|
1
|
+
{"version":3,"file":"app.js","names":[],"sources":["../../designsystem/app/app.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { forwardRef, type JSX } from \"react\";\nimport { Button, type ButtonProps } from \"../button/button\";\nimport type {\n\tPolymorphicComponentPropWithRef,\n\tPolymorphicRef,\n} from \"../react-types\";\nimport styles from \"../styles.module.css\";\nimport script from \"./app-toggle.js?raw\";\n\nexport type AppHeaderProps = React.ComponentPropsWithoutRef<\"header\">;\nexport type AppSidebarProps = React.ComponentPropsWithoutRef<\"dialog\">;\nexport type AppStickyProps = React.ComponentPropsWithoutRef<\"div\">;\nexport type AppMainProps = React.ComponentPropsWithoutRef<\"main\">;\nexport type AppFooterProps = React.ComponentPropsWithoutRef<\"footer\">;\nexport type AppProps<As extends React.ElementType = \"div\"> =\n\tPolymorphicComponentPropWithRef<\n\t\tAs,\n\t\t{\n\t\t\t\"data-variant\"?: \"mobilebar\";\n\t\t}\n\t>;\n\ntype AppComponent = <As extends React.ElementType = \"div\">(\n\tprops: AppProps<As>,\n) => JSX.Element;\n\nconst AppComp = forwardRef<null>(function App<\n\tAs extends React.ElementType = \"div\",\n>({ as, className, ...rest }: AppProps<As>, ref?: PolymorphicRef<As>) {\n\tconst Tag = as || \"div\";\n\n\treturn <Tag className={clsx(styles.app, className)} ref={ref} {...rest} />;\n}) as AppComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n\nconst AppSticky = forwardRef<null>(function App<\n\tAs extends React.ElementType = \"div\",\n>({ as, className, ...rest }: AppProps<As>, ref?: PolymorphicRef<As>) {\n\tconst Tag = as || \"div\";\n\n\treturn <Tag className={clsx(styles.sticky, className)} ref={ref} {...rest} />;\n}) as AppComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n\nexport const App = Object.assign(AppComp, {\n\tHeader: forwardRef<HTMLElement, AppHeaderProps>(\n\t\tfunction AppHeader(rest, ref) {\n\t\t\treturn <header ref={ref} {...rest} />;\n\t\t},\n\t),\n\tSidebar: forwardRef<HTMLDialogElement, AppSidebarProps>(\n\t\tfunction AppSidebar(rest, ref) {\n\t\t\treturn (\n\t\t\t\t<dialog\n\t\t\t\t\trole=\"navigation\"\n\t\t\t\t\tid=\"mtds-sidebar\"\n\t\t\t\t\tsuppressHydrationWarning // Needed due to closedby polyfill\n\t\t\t\t\tref={ref}\n\t\t\t\t\t{...rest}\n\t\t\t\t/>\n\t\t\t);\n\t\t},\n\t),\n\tSticky: AppSticky,\n\tToggle: forwardRef<HTMLButtonElement, ButtonProps<\"button\">>(\n\t\tfunction AppToggle({ children, ...rest }: ButtonProps<\"button\">, ref) {\n\t\t\treturn (\n\t\t\t\t<Button\n\t\t\t\t\tcommand=\"show-modal\"\n\t\t\t\t\tcommandfor=\"mtds-sidebar\"\n\t\t\t\t\tdata-tooltip=\"Vis meny\"\n\t\t\t\t\tref={ref as React.Ref<HTMLAnchorElement>}\n\t\t\t\t\t{...rest}\n\t\t\t\t>\n\t\t\t\t\t{children ?? \"Skjul meny\"}\n\t\t\t\t</Button>\n\t\t\t);\n\t\t},\n\t),\n\tMain: forwardRef<HTMLElement, AppMainProps>(function AppMain(rest, ref) {\n\t\treturn <main ref={ref} {...rest} />;\n\t}),\n\tFooter: forwardRef<HTMLElement, AppFooterProps>(\n\t\tfunction AppFooter(rest, ref) {\n\t\t\treturn <footer ref={ref} {...rest} />;\n\t\t},\n\t),\n\t// Needed to avoid flash of unstyled content and still be Next.js hydration compatible\n\tScript: () => <script id=\"mtds-app-script\">{script}</script>,\n});\n"],"mappings":";;;;;;;AA2BA,IAAM,IAAU,EAAiB,SAE/B,EAAE,OAAI,cAAW,GAAG,KAAsB,GAA0B;CAGrE,OAAO,kBAFK,KAAM,OAEX;EAAK,WAAW,EAAK,EAAO,KAAK,CAAS;EAAQ;EAAK,GAAI;CAAO,CAAA;AAC1E,CAAC,GAEK,IAAY,EAAiB,SAEjC,EAAE,OAAI,cAAW,GAAG,KAAsB,GAA0B;CAGrE,OAAO,kBAFK,KAAM,OAEX;EAAK,WAAW,EAAK,EAAO,QAAQ,CAAS;EAAQ;EAAK,GAAI;CAAO,CAAA;AAC7E,CAAC,GAEY,IAAM,OAAO,OAAO,GAAS;CACzC,QAAQ,EACP,SAAmB,GAAM,GAAK;EAC7B,OAAO,kBAAC,UAAD;GAAa;GAAK,GAAI;EAAO,CAAA;CACrC,CACD;CACA,SAAS,EACR,SAAoB,GAAM,GAAK;EAC9B,OACC,kBAAC,UAAD;GACC,MAAK;GACL,IAAG;GACH,0BAAA;GACK;GACL,GAAI;EACJ,CAAA;CAEH,CACD;CACA,QAAQ;CACR,QAAQ,EACP,SAAmB,EAAE,aAAU,GAAG,KAA+B,GAAK;EACrE,OACC,kBAAC,GAAD;GACC,SAAQ;GACR,YAAW;GACX,gBAAa;GACR;GACL,GAAI;aAEH,KAAY;EACN,CAAA;CAEV,CACD;CACA,MAAM,EAAsC,SAAiB,GAAM,GAAK;EACvE,OAAO,kBAAC,QAAD;GAAW;GAAK,GAAI;EAAO,CAAA;CACnC,CAAC;CACD,QAAQ,EACP,SAAmB,GAAM,GAAK;EAC7B,OAAO,kBAAC,UAAD;GAAa;GAAK,GAAI;EAAO,CAAA;CACrC,CACD;CAEA,cAAc,kBAAC,UAAD;EAAQ,IAAG;YAAmB;CAAe,CAAA;AAC5D,CAAC"}
|
|
@@ -1,95 +1,85 @@
|
|
|
1
|
-
import i from "../
|
|
2
|
-
import
|
|
1
|
+
import { MTDSElement as e, attachStyle as t, attr as n, defineElement as r, isBrowser as i, off as a, on as o, tag as s } from "../utils.js";
|
|
2
|
+
import c from "../external/leaflet/dist/leaflet-src.js";
|
|
3
|
+
import l from "../external/leaflet/dist/leaflet.css.js";
|
|
3
4
|
import "./cluster.js";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
];
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
#t(t) {
|
|
77
|
-
t.type === "click" ? l && t.stopPropagation?.() : document.body.classList.contains("leaflet-dragging") && (l = setTimeout(() => {
|
|
78
|
-
l = 0;
|
|
79
|
-
}, 50));
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
u("mtds-atlas", r);
|
|
83
|
-
f() && (i.Marker.prototype.options.icon = new i.DivIcon({
|
|
84
|
-
html: '<div class="leaflet-marker-generated-slot"><div class="leaflet-marker-generated-icon"></div></div>',
|
|
85
|
-
iconSize: [0, 0]
|
|
86
|
-
}));
|
|
87
|
-
export {
|
|
88
|
-
i as L,
|
|
89
|
-
S as MATGEO_URL,
|
|
90
|
-
r as MTDSAtlasElement,
|
|
91
|
-
O as MTDSAtlasMarkerElement,
|
|
92
|
-
R as MTDSAtlasMatgeoElement,
|
|
93
|
-
D as MTDSAtlasWMSElement
|
|
5
|
+
import u from "./atlas.js";
|
|
6
|
+
import { MTDSAtlasMarkerElement as d } from "./atlas-marker.js";
|
|
7
|
+
import { MTDSAtlasMatgeoElement as f } from "./atlas-matgeo.js";
|
|
8
|
+
import { MTDSAtlasWMSElement as p } from "./atlas-wms.js";
|
|
9
|
+
//#region designsystem/atlas/atlas-element.ts
|
|
10
|
+
var m = 0, h = 18, g = "https://cache.kartverket.no/v1/wmts/1.0.0/topo/default/webmercator/{z}/{y}/{x}.png", _ = "https://matgeoservice-256616427209.europe-north1.run.app/ogc/features/collections", v = [[57.5, 4.73], [71.5, 31.44]], y = class r extends e {
|
|
11
|
+
cluster;
|
|
12
|
+
map;
|
|
13
|
+
static get observedAttributes() {
|
|
14
|
+
return ["data-view", "data-scrollzoom"];
|
|
15
|
+
}
|
|
16
|
+
constructor() {
|
|
17
|
+
super(), this.attachShadow({ mode: "open" }).append(s("figure")), t(this, `@layer leaflet{${l}}\n@layer mt.v3-4-1design{${u}`);
|
|
18
|
+
}
|
|
19
|
+
connectedCallback() {
|
|
20
|
+
let e = this.shadowRoot?.lastElementChild, t = n(this, "data-cluster") ?? "false", i = new c.TileLayer(g, {
|
|
21
|
+
attribution: "© Kartverket",
|
|
22
|
+
className: "leaflet-kartverket-tiles",
|
|
23
|
+
maxZoom: h
|
|
24
|
+
});
|
|
25
|
+
this.map = new c.Map(e, {
|
|
26
|
+
attributionControl: !1,
|
|
27
|
+
fadeAnimation: !1,
|
|
28
|
+
layers: [i],
|
|
29
|
+
zoomControl: !1,
|
|
30
|
+
zoomSnap: .2
|
|
31
|
+
}), o(this, "pointerup click", this.#t), this.map.addControl(new c.Control.Attribution({ prefix: "" })), this.map.addControl(new c.Control.Zoom({ position: "bottomright" })), this.map.on("popupopen popupclose", this.#e, this), this.cluster = new c.MarkerClusterGroup({
|
|
32
|
+
zoomToBoundsOnClick: !0,
|
|
33
|
+
showCoverageOnHover: !1,
|
|
34
|
+
disableClusteringAtZoom: t === "false" ? 1 : Number(t) || 19,
|
|
35
|
+
iconCreateFunction: (e) => new c.DivIcon({
|
|
36
|
+
html: `${e.getChildCount()}`,
|
|
37
|
+
className: "leaflet-cluster-icon",
|
|
38
|
+
iconSize: [40, 40]
|
|
39
|
+
})
|
|
40
|
+
}).addTo(this.map);
|
|
41
|
+
for (let e of r.observedAttributes) this.attributeChangedCallback(e, null, n(this, e));
|
|
42
|
+
}
|
|
43
|
+
attributeChangedCallback(e, t, n) {
|
|
44
|
+
e === "data-view" && this.setView(n || ""), e === "data-scrollzoom" && this.map?.scrollWheelZoom[n === "false" ? "disable" : "enable"]();
|
|
45
|
+
}
|
|
46
|
+
setView(e, t) {
|
|
47
|
+
let n = `${e}`.split(",").map(parseFloat).filter(Number.isFinite), r = this.cluster?.getBounds();
|
|
48
|
+
if (n.length === 3) return this.map?.setView([n[0], n[1]], n[2], t);
|
|
49
|
+
if (e !== "fit") return this.map?.fitBounds(v, t);
|
|
50
|
+
if (r?.isValid()) return this.map?.fitBounds(r.pad(.1), t);
|
|
51
|
+
this.cluster?.once("layeradd", () => {
|
|
52
|
+
setTimeout(() => this.setView("fit"), 50);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
latLngFromPoint(e, t) {
|
|
56
|
+
return this.map?.pointerEventToLatLng({
|
|
57
|
+
clientX: e,
|
|
58
|
+
clientY: t
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
disconnectedCallback() {
|
|
62
|
+
a(this, "pointerup click", this.#t), this.map?.remove(), this.map = this.cluster = void 0;
|
|
63
|
+
}
|
|
64
|
+
async getCollections() {
|
|
65
|
+
return window._matgeoCollections || (window._matgeoCollections = fetch(_).then((e) => e.json()).then((e) => e.collections.map((e) => [e.id, e])).then(Object.fromEntries)), window._matgeoCollections;
|
|
66
|
+
}
|
|
67
|
+
#e({ type: e, popup: t }) {
|
|
68
|
+
let r = e === "popupopen", i = t.getElement()?.querySelector(".leaflet-popup-content"), a = i?.querySelector(":scope > slot"), o = i?.textContent?.match(/^#(\S+)/)?.[1] || "", l = document.getElementById(a?.name || o);
|
|
69
|
+
if (!l) return r && o && t.close();
|
|
70
|
+
c.Util.setOptions(t, { maxWidth: this.offsetWidth - 40 }), n(l, "data-popover", r ? n(l, "popover") : null), n(l, "popover", r ? null : n(l, "data-popover")), n(l, "slot", r ? l.id : null), r && t.setContent(s("slot", { name: l.id }));
|
|
71
|
+
}
|
|
72
|
+
#t(e) {
|
|
73
|
+
e.type === "click" ? m && e.stopPropagation?.() : document.body.classList.contains("leaflet-dragging") && (m = setTimeout(() => {
|
|
74
|
+
m = 0;
|
|
75
|
+
}, 50));
|
|
76
|
+
}
|
|
94
77
|
};
|
|
95
|
-
|
|
78
|
+
r("mtds-atlas", y), i() && (c.Marker.prototype.options.icon = new c.DivIcon({
|
|
79
|
+
html: "<div class=\"leaflet-marker-generated-slot\"><div class=\"leaflet-marker-generated-icon\"></div></div>",
|
|
80
|
+
iconSize: [0, 0]
|
|
81
|
+
}));
|
|
82
|
+
//#endregion
|
|
83
|
+
export { c as L, _ as MATGEO_URL, y as MTDSAtlasElement, d as MTDSAtlasMarkerElement, f as MTDSAtlasMatgeoElement, p as MTDSAtlasWMSElement };
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=atlas-element.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"atlas-element.js","sources":["../../designsystem/atlas/atlas-element.ts"],"sourcesContent":["import L from \"leaflet\";\nimport LeafletCSS from \"leaflet/dist/leaflet.css?raw\";\nimport type {} from \"leaflet.markercluster\"; // Extend L namespace\nimport \"./cluster.js\";\nimport {\n\tattachStyle,\n\tattr,\n\tdefineElement,\n\tisBrowser,\n\tMTDSElement,\n\toff,\n\ton,\n\ttag,\n} from \"../utils\";\nimport css from \"./atlas.css?raw\";\n\nexport { MTDSAtlasMarkerElement } from \"./atlas-marker\";\nexport { MTDSAtlasMatgeoElement } from \"./atlas-matgeo\";\nexport { MTDSAtlasWMSElement } from \"./atlas-wms\";\nexport { L };\n\n// TODO: Add minimum zoom level for adding markers (minimum 17 som standard?)\n// TODO: Add search helper (https://ws.geonorge.no/adresser/v1/openapi.json + https://ws.geonorge.no/adresser/v1/#/default/get_sok)\n// TODO: matgeo-autoload popover info\n\ntype Link = { href: string; rel: string; type: string; title: string };\ntype BBox = [number, number, number, number];\nexport type MTDSAtlasCollections = Record<string, MTDSAtlasCollection>;\nexport type MTDSAtlasCollection = {\n\tcrs: string[];\n\tdescription: string;\n\textent: { spatial: { bbox: BBox[] } };\n\tgeometry: string;\n\tid: string;\n\titemType: string;\n\tlinks: Link[];\n\ttitle: string;\n};\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t\"mtds-atlas\": MTDSAtlasElement;\n\t}\n\n\tinterface Window {\n\t\t_matgeoCollections?: Promise<MTDSAtlasCollections>;\n\t}\n}\n\nlet SKIP_CLICK: number | NodeJS.Timeout = 0;\nconst KARTVERKET_MAX_ZOOM = 18; // Kartverket does not support more than zoom level 18\nconst KARTVERKET_TILES_URL =\n\t\"https://cache.kartverket.no/v1/wmts/1.0.0/topo/default/webmercator/{z}/{y}/{x}.png\";\nexport const MATGEO_URL =\n\t\"https://matgeoservice-256616427209.europe-north1.run.app/ogc/features/collections\";\nconst BOUNDS_NORWAY: L.LatLngBoundsLiteral = [\n\t[57.5, 4.73],\n\t[71.5, 31.44],\n];\n\nexport class MTDSAtlasElement extends MTDSElement {\n\tcluster?: L.MarkerClusterGroup;\n\tmap?: L.Map;\n\n\tstatic get observedAttributes() {\n\t\treturn [\"data-view\", \"data-scrollzoom\"]; // Using ES2015 syntax for backwards compatibility\n\t}\n\tconstructor() {\n\t\tsuper();\n\t\tthis.attachShadow({ mode: \"open\" }).append(tag(\"figure\"));\n\t\tattachStyle(this, `@layer leaflet{${LeafletCSS}}\\n@layer mt.design{${css}`);\n\t}\n\tconnectedCallback() {\n\t\tconst container = this.shadowRoot?.lastElementChild as HTMLElement;\n\t\tconst cluster = attr(this, \"data-cluster\") ?? \"false\";\n\t\tconst tiles = new L.TileLayer(KARTVERKET_TILES_URL, {\n\t\t\tattribution: \"© Kartverket\",\n\t\t\tclassName: \"leaflet-kartverket-tiles\",\n\t\t\tmaxZoom: KARTVERKET_MAX_ZOOM,\n\t\t});\n\n\t\tthis.map = new L.Map(container, {\n\t\t\tattributionControl: false,\n\t\t\tfadeAnimation: false, // Prevent popup fades\n\t\t\tlayers: [tiles],\n\t\t\tzoomControl: false,\n\t\t\tzoomSnap: 0.2,\n\t\t});\n\n\t\ton(this, \"pointerup click\", this.#skipClick); // Prevent clicks from bubbling up unless sent from Leaflet\n\t\tthis.map.addControl(new L.Control.Attribution({ prefix: \"\" }));\n\t\tthis.map.addControl(new L.Control.Zoom({ position: \"bottomright\" }));\n\t\tthis.map.on(\"popupopen popupclose\", this.#handlePopup, this);\n\t\tthis.cluster = new L.MarkerClusterGroup({\n\t\t\tzoomToBoundsOnClick: true,\n\t\t\tshowCoverageOnHover: false,\n\t\t\tdisableClusteringAtZoom:\n\t\t\t\tcluster === \"false\" ? 1 : Number(cluster) || KARTVERKET_MAX_ZOOM + 1,\n\t\t\ticonCreateFunction: (cluster: L.MarkerCluster) =>\n\t\t\t\tnew L.DivIcon({\n\t\t\t\t\thtml: `${cluster.getChildCount()}`,\n\t\t\t\t\tclassName: \"leaflet-cluster-icon\",\n\t\t\t\t\ticonSize: [40, 40],\n\t\t\t\t}),\n\t\t}).addTo(this.map);\n\n\t\t// Initial setup attributes\n\t\tfor (const name of MTDSAtlasElement.observedAttributes)\n\t\t\tthis.attributeChangedCallback(name, null, attr(this, name));\n\t}\n\tattributeChangedCallback(name: string, _prev?: null, next?: string | null) {\n\t\tif (name === \"data-view\") this.setView(next || \"\");\n\t\tif (name === \"data-scrollzoom\")\n\t\t\tthis.map?.scrollWheelZoom[next === \"false\" ? \"disable\" : \"enable\"]();\n\t}\n\tsetView(view: string | number[], opts?: L.FitBoundsOptions) {\n\t\tconst p = `${view}`.split(\",\").map(parseFloat).filter(Number.isFinite);\n\t\tconst b = this.cluster?.getBounds();\n\n\t\tif (p.length === 3) return this.map?.setView([p[0], p[1]], p[2], opts);\n\t\tif (view !== \"fit\") return this.map?.fitBounds(BOUNDS_NORWAY, opts);\n\t\tif (b?.isValid()) return this.map?.fitBounds(b.pad(0.1), opts);\n\t\tthis.cluster?.once(\"layeradd\", () => {\n\t\t\tsetTimeout(() => this.setView(\"fit\"), 50); // Add all markers before fitting\n\t\t});\n\t}\n\tlatLngFromPoint(x: number, y: number) {\n\t\t// @ts-expect-error -- Missing from Leaflet@2.0.0-alpha.1 types\n\t\treturn this.map?.pointerEventToLatLng({ clientX: x, clientY: y });\n\t}\n\tdisconnectedCallback() {\n\t\toff(this, \"pointerup click\", this.#skipClick);\n\t\tthis.map?.remove();\n\t\tthis.map = this.cluster = undefined;\n\t}\n\tasync getCollections() {\n\t\tif (!window._matgeoCollections)\n\t\t\twindow._matgeoCollections = fetch(MATGEO_URL)\n\t\t\t\t.then((res) => res.json())\n\t\t\t\t.then((d) => d.collections.map((c: MTDSAtlasCollection) => [c.id, c]))\n\t\t\t\t.then(Object.fromEntries);\n\t\treturn window._matgeoCollections;\n\t}\n\t#handlePopup({ type, popup }: { type: string; popup: L.Popup }) {\n\t\tconst open = type === \"popupopen\";\n\t\tconst cont = popup.getElement()?.querySelector(\".leaflet-popup-content\");\n\t\tconst slot = cont?.querySelector<HTMLSlotElement>(\":scope > slot\");\n\t\tconst id = cont?.textContent?.match(/^#(\\S+)/)?.[1] || \"\";\n\t\tconst el = document.getElementById(slot?.name || id); // If content of popup is #id, replace with <slot>\n\n\t\tif (!el) return open && id && popup.close(); // Close popup if target element not found\n\t\tL.Util.setOptions(popup, { maxWidth: this.offsetWidth - 40 });\n\t\tattr(el, \"data-popover\", open ? attr(el, \"popover\") : null); // Store previous popover mode\n\t\tattr(el, \"popover\", open ? null : attr(el, \"data-popover\")); // But temporarily remove it so popover renders\n\t\tattr(el, \"slot\", open ? el.id : null); // Render popover in slot\n\t\tif (open) popup.setContent(tag(\"slot\", { name: el.id }));\n\t}\n\t#skipClick(event: Partial<MouseEvent>) {\n\t\tif (event.type === \"click\") SKIP_CLICK && event.stopPropagation?.();\n\t\telse if (document.body.classList.contains(\"leaflet-dragging\"))\n\t\t\tSKIP_CLICK = setTimeout(() => {\n\t\t\t\tSKIP_CLICK = 0;\n\t\t\t}, 50); // Was dragging, so skip succeeding click\n\t}\n}\n\ndefineElement(\"mtds-atlas\", MTDSAtlasElement);\n\nif (isBrowser())\n\tL.Marker.prototype.options.icon = new L.DivIcon({\n\t\thtml: '<div class=\"leaflet-marker-generated-slot\"><div class=\"leaflet-marker-generated-icon\"></div></div>',\n\t\ticonSize: [0, 0],\n\t});\n"],"names":["SKIP_CLICK","KARTVERKET_MAX_ZOOM","KARTVERKET_TILES_URL","MATGEO_URL","BOUNDS_NORWAY","MTDSAtlasElement","MTDSElement","tag","attachStyle","LeafletCSS","css","container","cluster","attr","tiles","L","on","#skipClick","#handlePopup","name","_prev","next","view","opts","p","b","x","y","off","res","d","c","type","popup","open","cont","slot","id","el","event","defineElement","isBrowser"],"mappings":";;;;;;;;AAiDA,IAAIA,IAAsC;AAC1C,MAAMC,IAAsB,IACtBC,IACL,sFACYC,IACZ,qFACKC,IAAuC;AAAA,EAC5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AM;AAAA,EACN,UAAU,CAAC,GAAG,CAAC;AAAA,CACf;"}
|
|
1
|
+
{"version":3,"file":"atlas-element.js","names":["#skipClick","#handlePopup"],"sources":["../../designsystem/atlas/atlas-element.ts"],"sourcesContent":["import L from \"leaflet\";\nimport LeafletCSS from \"leaflet/dist/leaflet.css?raw\";\nimport type {} from \"leaflet.markercluster\"; // Extend L namespace\nimport \"./cluster.js\";\nimport {\n\tattachStyle,\n\tattr,\n\tdefineElement,\n\tisBrowser,\n\tMTDSElement,\n\toff,\n\ton,\n\ttag,\n} from \"../utils\";\nimport css from \"./atlas.css?raw\";\n\nexport { MTDSAtlasMarkerElement } from \"./atlas-marker\";\nexport { MTDSAtlasMatgeoElement } from \"./atlas-matgeo\";\nexport { MTDSAtlasWMSElement } from \"./atlas-wms\";\nexport { L };\n\n// TODO: Add minimum zoom level for adding markers (minimum 17 som standard?)\n// TODO: Add search helper (https://ws.geonorge.no/adresser/v1/openapi.json + https://ws.geonorge.no/adresser/v1/#/default/get_sok)\n// TODO: matgeo-autoload popover info\n\ntype Link = { href: string; rel: string; type: string; title: string };\ntype BBox = [number, number, number, number];\nexport type MTDSAtlasCollections = Record<string, MTDSAtlasCollection>;\nexport type MTDSAtlasCollection = {\n\tcrs: string[];\n\tdescription: string;\n\textent: { spatial: { bbox: BBox[] } };\n\tgeometry: string;\n\tid: string;\n\titemType: string;\n\tlinks: Link[];\n\ttitle: string;\n};\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t\"mtds-atlas\": MTDSAtlasElement;\n\t}\n\n\tinterface Window {\n\t\t_matgeoCollections?: Promise<MTDSAtlasCollections>;\n\t}\n}\n\nlet SKIP_CLICK: number | NodeJS.Timeout = 0;\nconst KARTVERKET_MAX_ZOOM = 18; // Kartverket does not support more than zoom level 18\nconst KARTVERKET_TILES_URL =\n\t\"https://cache.kartverket.no/v1/wmts/1.0.0/topo/default/webmercator/{z}/{y}/{x}.png\";\nexport const MATGEO_URL =\n\t\"https://matgeoservice-256616427209.europe-north1.run.app/ogc/features/collections\";\nconst BOUNDS_NORWAY: L.LatLngBoundsLiteral = [\n\t[57.5, 4.73],\n\t[71.5, 31.44],\n];\n\nexport class MTDSAtlasElement extends MTDSElement {\n\tcluster?: L.MarkerClusterGroup;\n\tmap?: L.Map;\n\n\tstatic get observedAttributes() {\n\t\treturn [\"data-view\", \"data-scrollzoom\"]; // Using ES2015 syntax for backwards compatibility\n\t}\n\tconstructor() {\n\t\tsuper();\n\t\tthis.attachShadow({ mode: \"open\" }).append(tag(\"figure\"));\n\t\tattachStyle(this, `@layer leaflet{${LeafletCSS}}\\n@layer mt.design{${css}`);\n\t}\n\tconnectedCallback() {\n\t\tconst container = this.shadowRoot?.lastElementChild as HTMLElement;\n\t\tconst cluster = attr(this, \"data-cluster\") ?? \"false\";\n\t\tconst tiles = new L.TileLayer(KARTVERKET_TILES_URL, {\n\t\t\tattribution: \"© Kartverket\",\n\t\t\tclassName: \"leaflet-kartverket-tiles\",\n\t\t\tmaxZoom: KARTVERKET_MAX_ZOOM,\n\t\t});\n\n\t\tthis.map = new L.Map(container, {\n\t\t\tattributionControl: false,\n\t\t\tfadeAnimation: false, // Prevent popup fades\n\t\t\tlayers: [tiles],\n\t\t\tzoomControl: false,\n\t\t\tzoomSnap: 0.2,\n\t\t});\n\n\t\ton(this, \"pointerup click\", this.#skipClick); // Prevent clicks from bubbling up unless sent from Leaflet\n\t\tthis.map.addControl(new L.Control.Attribution({ prefix: \"\" }));\n\t\tthis.map.addControl(new L.Control.Zoom({ position: \"bottomright\" }));\n\t\tthis.map.on(\"popupopen popupclose\", this.#handlePopup, this);\n\t\tthis.cluster = new L.MarkerClusterGroup({\n\t\t\tzoomToBoundsOnClick: true,\n\t\t\tshowCoverageOnHover: false,\n\t\t\tdisableClusteringAtZoom:\n\t\t\t\tcluster === \"false\" ? 1 : Number(cluster) || KARTVERKET_MAX_ZOOM + 1,\n\t\t\ticonCreateFunction: (cluster: L.MarkerCluster) =>\n\t\t\t\tnew L.DivIcon({\n\t\t\t\t\thtml: `${cluster.getChildCount()}`,\n\t\t\t\t\tclassName: \"leaflet-cluster-icon\",\n\t\t\t\t\ticonSize: [40, 40],\n\t\t\t\t}),\n\t\t}).addTo(this.map);\n\n\t\t// Initial setup attributes\n\t\tfor (const name of MTDSAtlasElement.observedAttributes)\n\t\t\tthis.attributeChangedCallback(name, null, attr(this, name));\n\t}\n\tattributeChangedCallback(name: string, _prev?: null, next?: string | null) {\n\t\tif (name === \"data-view\") this.setView(next || \"\");\n\t\tif (name === \"data-scrollzoom\")\n\t\t\tthis.map?.scrollWheelZoom[next === \"false\" ? \"disable\" : \"enable\"]();\n\t}\n\tsetView(view: string | number[], opts?: L.FitBoundsOptions) {\n\t\tconst p = `${view}`.split(\",\").map(parseFloat).filter(Number.isFinite);\n\t\tconst b = this.cluster?.getBounds();\n\n\t\tif (p.length === 3) return this.map?.setView([p[0], p[1]], p[2], opts);\n\t\tif (view !== \"fit\") return this.map?.fitBounds(BOUNDS_NORWAY, opts);\n\t\tif (b?.isValid()) return this.map?.fitBounds(b.pad(0.1), opts);\n\t\tthis.cluster?.once(\"layeradd\", () => {\n\t\t\tsetTimeout(() => this.setView(\"fit\"), 50); // Add all markers before fitting\n\t\t});\n\t}\n\tlatLngFromPoint(x: number, y: number) {\n\t\t// @ts-expect-error -- Missing from Leaflet@2.0.0-alpha.1 types\n\t\treturn this.map?.pointerEventToLatLng({ clientX: x, clientY: y });\n\t}\n\tdisconnectedCallback() {\n\t\toff(this, \"pointerup click\", this.#skipClick);\n\t\tthis.map?.remove();\n\t\tthis.map = this.cluster = undefined;\n\t}\n\tasync getCollections() {\n\t\tif (!window._matgeoCollections)\n\t\t\twindow._matgeoCollections = fetch(MATGEO_URL)\n\t\t\t\t.then((res) => res.json())\n\t\t\t\t.then((d) => d.collections.map((c: MTDSAtlasCollection) => [c.id, c]))\n\t\t\t\t.then(Object.fromEntries);\n\t\treturn window._matgeoCollections;\n\t}\n\t#handlePopup({ type, popup }: { type: string; popup: L.Popup }) {\n\t\tconst open = type === \"popupopen\";\n\t\tconst cont = popup.getElement()?.querySelector(\".leaflet-popup-content\");\n\t\tconst slot = cont?.querySelector<HTMLSlotElement>(\":scope > slot\");\n\t\tconst id = cont?.textContent?.match(/^#(\\S+)/)?.[1] || \"\";\n\t\tconst el = document.getElementById(slot?.name || id); // If content of popup is #id, replace with <slot>\n\n\t\tif (!el) return open && id && popup.close(); // Close popup if target element not found\n\t\tL.Util.setOptions(popup, { maxWidth: this.offsetWidth - 40 });\n\t\tattr(el, \"data-popover\", open ? attr(el, \"popover\") : null); // Store previous popover mode\n\t\tattr(el, \"popover\", open ? null : attr(el, \"data-popover\")); // But temporarily remove it so popover renders\n\t\tattr(el, \"slot\", open ? el.id : null); // Render popover in slot\n\t\tif (open) popup.setContent(tag(\"slot\", { name: el.id }));\n\t}\n\t#skipClick(event: Partial<MouseEvent>) {\n\t\tif (event.type === \"click\") SKIP_CLICK && event.stopPropagation?.();\n\t\telse if (document.body.classList.contains(\"leaflet-dragging\"))\n\t\t\tSKIP_CLICK = setTimeout(() => {\n\t\t\t\tSKIP_CLICK = 0;\n\t\t\t}, 50); // Was dragging, so skip succeeding click\n\t}\n}\n\ndefineElement(\"mtds-atlas\", MTDSAtlasElement);\n\nif (isBrowser())\n\tL.Marker.prototype.options.icon = new L.DivIcon({\n\t\thtml: '<div class=\"leaflet-marker-generated-slot\"><div class=\"leaflet-marker-generated-icon\"></div></div>',\n\t\ticonSize: [0, 0],\n\t});\n"],"mappings":";;;;;;;;;AAiDA,IAAI,IAAsC,GACpC,IAAsB,IACtB,IACL,sFACY,IACZ,qFACK,IAAuC,CAC5C,CAAC,MAAM,IAAI,GACX,CAAC,MAAM,KAAK,CACb,GAEa,IAAb,MAAa,UAAyB,EAAY;CACjD;CACA;CAEA,WAAW,qBAAqB;EAC/B,OAAO,CAAC,aAAa,iBAAiB;CACvC;CACA,cAAc;EAGb,AAFA,MAAM,GACN,KAAK,aAAa,EAAE,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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
1
|
+
import { MTDSElement as e, attr as t, defineElement as n, off as r, on as i, tag as a } from "../utils.js";
|
|
2
|
+
import o from "../external/leaflet/dist/leaflet-src.js";
|
|
3
|
+
//#region designsystem/atlas/atlas-marker.ts
|
|
4
|
+
var s = 0, c = class extends e {
|
|
5
|
+
atlas;
|
|
6
|
+
marker;
|
|
7
|
+
static get observedAttributes() {
|
|
8
|
+
return [
|
|
9
|
+
"hidden",
|
|
10
|
+
"draggable",
|
|
11
|
+
"data-latlng",
|
|
12
|
+
"popovertarget"
|
|
13
|
+
];
|
|
14
|
+
}
|
|
15
|
+
connectedCallback() {
|
|
16
|
+
queueMicrotask(() => {
|
|
17
|
+
let e = a("slot", { name: `${++s}` }), n = new o.DivIcon({
|
|
18
|
+
html: e,
|
|
19
|
+
iconSize: [0, 0]
|
|
20
|
+
});
|
|
21
|
+
this.atlas = this.closest("mtds-atlas") || void 0, this.marker = new o.Marker(this.#e(), {
|
|
22
|
+
draggable: this.draggable,
|
|
23
|
+
keyboard: !1,
|
|
24
|
+
icon: n
|
|
25
|
+
}), this.marker.bindPopup(() => `#${t(this, "popovertarget")}`), this.marker.on("dragend", this.#t), i(this, "click keydown", this), t(this, "slot", `${s}`), t(this, "role", "button"), t(this, "tabindex", "0"), this.attributeChangedCallback("hidden");
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
attributeChangedCallback(e) {
|
|
29
|
+
let t = this.marker, n = this.atlas?.cluster;
|
|
30
|
+
if (e === "popovertarget" && t?.getPopup()?.update(), e === "data-latlng") {
|
|
31
|
+
let e = this.#e();
|
|
32
|
+
t?.getLatLng().equals(e) || t?.setLatLng(e);
|
|
33
|
+
}
|
|
34
|
+
e === "draggable" && t?.dragging?.[this.draggable ? "enable" : "disable"](), e === "hidden" && t && n && n[this.hidden ? "removeLayer" : "addLayer"](t);
|
|
35
|
+
}
|
|
36
|
+
disconnectedCallback() {
|
|
37
|
+
r(this, "click keydown", this), this.marker?.unbindPopup().off("dragend", this.#t).remove(), this.marker = this.atlas = void 0;
|
|
38
|
+
}
|
|
39
|
+
handleEvent(e) {
|
|
40
|
+
if (e.type === "click") return this.marker?.fire("click");
|
|
41
|
+
e.key === " " && e.preventDefault(), (e.key === " " || e.key === "Enter") && this.click();
|
|
42
|
+
}
|
|
43
|
+
get latlng() {
|
|
44
|
+
return t(this, "data-latlng") || "";
|
|
45
|
+
}
|
|
46
|
+
set latlng(e) {
|
|
47
|
+
t(this, "data-latlng", e);
|
|
48
|
+
}
|
|
49
|
+
#e() {
|
|
50
|
+
return this.latlng?.split(",").map(parseFloat);
|
|
51
|
+
}
|
|
52
|
+
#t(e) {
|
|
53
|
+
let t = (e.target._icon?.firstElementChild)?.assignedElements?.()?.[0], { lat: n, lng: r } = e.target.getLatLng();
|
|
54
|
+
t && (t.latlng = `${n},${r}`), t?.dispatchEvent(new CustomEvent("dragend", {
|
|
55
|
+
detail: e,
|
|
56
|
+
bubbles: !0
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
52
59
|
};
|
|
53
|
-
|
|
60
|
+
n("mtds-atlas-marker", c);
|
|
61
|
+
//#endregion
|
|
62
|
+
export { c as MTDSAtlasMarkerElement };
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=atlas-marker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"atlas-marker.js","sources":["../../designsystem/atlas/atlas-marker.ts"],"sourcesContent":["import L from \"leaflet\";\nimport { attr, defineElement, MTDSElement, off, on, tag } from \"../utils\";\nimport type { MTDSAtlasElement } from \"./atlas-element\";\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t\"mtds-atlas-marker\": MTDSAtlasMarkerElement;\n\t}\n}\n\nlet SLOT = 0;\nexport class MTDSAtlasMarkerElement extends MTDSElement {\n\tatlas?: MTDSAtlasElement;\n\tmarker?: L.Marker;\n\n\tstatic get observedAttributes() {\n\t\treturn [\"hidden\", \"draggable\", \"data-latlng\", \"popovertarget\"]; // Using ES2015 syntax for backwards compatibility\n\t}\n\tconnectedCallback() {\n\t\tqueueMicrotask(() => {\n\t\t\tconst html = tag(\"slot\", { name: `${++SLOT}` });\n\t\t\tconst icon = new L.DivIcon({ html, iconSize: [0, 0] });\n\t\t\tthis.atlas = this.closest<MTDSAtlasElement>(\"mtds-atlas\") || undefined;\n\t\t\tthis.marker = new L.Marker(this.#parseLatLng(), {\n\t\t\t\tdraggable: this.draggable,\n\t\t\t\tkeyboard: false,\n\t\t\t\ticon,\n\t\t\t});\n\t\t\tthis.marker.bindPopup(() => `#${attr(this, \"popovertarget\")}`);\n\t\t\tthis.marker.on(\"dragend\", this.#handleDragEnd);\n\n\t\t\ton(this, \"click keydown\", this); // Listen for clicks to toggle popup\n\t\t\tattr(this, \"slot\", `${SLOT}`); // Link slot to marker icon\n\t\t\tattr(this, \"role\", \"button\");\n\t\t\tattr(this, \"tabindex\", \"0\");\n\t\t\tthis.attributeChangedCallback(\"hidden\"); // Maybe add to map\n\t\t}); // Let the atlas parent initialize first\n\t}\n\tattributeChangedCallback(name: string) {\n\t\tconst mark = this.marker;\n\t\tconst cluster = this.atlas?.cluster;\n\t\tif (name === \"popovertarget\") mark?.getPopup()?.update();\n\t\tif (name === \"data-latlng\") {\n\t\t\tconst latlng = this.#parseLatLng();\n\t\t\tmark?.getLatLng().equals(latlng) || mark?.setLatLng(latlng);\n\t\t}\n\t\tif (name === \"draggable\")\n\t\t\tmark?.dragging?.[this.draggable ? \"enable\" : \"disable\"]();\n\t\tif (name === \"hidden\" && mark && cluster)\n\t\t\tcluster[this.hidden ? \"removeLayer\" : \"addLayer\"](mark);\n\t}\n\tdisconnectedCallback() {\n\t\toff(this, \"click keydown\", this);\n\t\tthis.marker?.unbindPopup().off(\"dragend\", this.#handleDragEnd).remove();\n\t\tthis.marker = this.atlas = undefined;\n\t}\n\thandleEvent(event: KeyboardEvent) {\n\t\tif (event.type === \"click\") return this.marker?.fire(\"click\"); //this.atlas?.togglePopup(this.marker, this);\n\t\tif (event.key === \" \") event.preventDefault(); // Prevent page scroll on space key\n\t\tif (event.key === \" \" || event.key === \"Enter\") this.click(); // Forward keyvoard to click for accessibility\n\t}\n\tget latlng() {\n\t\treturn attr(this, \"data-latlng\") || \"\";\n\t}\n\tset latlng(latlng: string) {\n\t\tattr(this, \"data-latlng\", latlng);\n\t}\n\t#parseLatLng() {\n\t\treturn this.latlng?.split(\",\").map(parseFloat) as L.LatLngTuple;\n\t}\n\t#handleDragEnd(detail: L.LeafletEvent) {\n\t\tconst slot = detail.target._icon\n\t\t\t?.firstElementChild as HTMLSlotElement | null;\n\t\tconst self =\n\t\t\tslot?.assignedElements?.()?.[0] as MTDSAtlasMarkerElement | null;\n\t\tconst { lat, lng } = detail.target.getLatLng(); // Using L.Marker.getLatLng() to get position also when in spiderified cluster\n\t\tif (self) self.latlng = `${lat},${lng}`;\n\t\tself?.dispatchEvent(new CustomEvent(\"dragend\", { detail, bubbles: true }));\n\t}\n}\n\ndefineElement(\"mtds-atlas-marker\", MTDSAtlasMarkerElement);\n"],"
|
|
1
|
+
{"version":3,"file":"atlas-marker.js","names":["#parseLatLng","#handleDragEnd"],"sources":["../../designsystem/atlas/atlas-marker.ts"],"sourcesContent":["import L from \"leaflet\";\nimport { attr, defineElement, MTDSElement, off, on, tag } from \"../utils\";\nimport type { MTDSAtlasElement } from \"./atlas-element\";\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t\"mtds-atlas-marker\": MTDSAtlasMarkerElement;\n\t}\n}\n\nlet SLOT = 0;\nexport class MTDSAtlasMarkerElement extends MTDSElement {\n\tatlas?: MTDSAtlasElement;\n\tmarker?: L.Marker;\n\n\tstatic get observedAttributes() {\n\t\treturn [\"hidden\", \"draggable\", \"data-latlng\", \"popovertarget\"]; // Using ES2015 syntax for backwards compatibility\n\t}\n\tconnectedCallback() {\n\t\tqueueMicrotask(() => {\n\t\t\tconst html = tag(\"slot\", { name: `${++SLOT}` });\n\t\t\tconst icon = new L.DivIcon({ html, iconSize: [0, 0] });\n\t\t\tthis.atlas = this.closest<MTDSAtlasElement>(\"mtds-atlas\") || undefined;\n\t\t\tthis.marker = new L.Marker(this.#parseLatLng(), {\n\t\t\t\tdraggable: this.draggable,\n\t\t\t\tkeyboard: false,\n\t\t\t\ticon,\n\t\t\t});\n\t\t\tthis.marker.bindPopup(() => `#${attr(this, \"popovertarget\")}`);\n\t\t\tthis.marker.on(\"dragend\", this.#handleDragEnd);\n\n\t\t\ton(this, \"click keydown\", this); // Listen for clicks to toggle popup\n\t\t\tattr(this, \"slot\", `${SLOT}`); // Link slot to marker icon\n\t\t\tattr(this, \"role\", \"button\");\n\t\t\tattr(this, \"tabindex\", \"0\");\n\t\t\tthis.attributeChangedCallback(\"hidden\"); // Maybe add to map\n\t\t}); // Let the atlas parent initialize first\n\t}\n\tattributeChangedCallback(name: string) {\n\t\tconst mark = this.marker;\n\t\tconst cluster = this.atlas?.cluster;\n\t\tif (name === \"popovertarget\") mark?.getPopup()?.update();\n\t\tif (name === \"data-latlng\") {\n\t\t\tconst latlng = this.#parseLatLng();\n\t\t\tmark?.getLatLng().equals(latlng) || mark?.setLatLng(latlng);\n\t\t}\n\t\tif (name === \"draggable\")\n\t\t\tmark?.dragging?.[this.draggable ? \"enable\" : \"disable\"]();\n\t\tif (name === \"hidden\" && mark && cluster)\n\t\t\tcluster[this.hidden ? \"removeLayer\" : \"addLayer\"](mark);\n\t}\n\tdisconnectedCallback() {\n\t\toff(this, \"click keydown\", this);\n\t\tthis.marker?.unbindPopup().off(\"dragend\", this.#handleDragEnd).remove();\n\t\tthis.marker = this.atlas = undefined;\n\t}\n\thandleEvent(event: KeyboardEvent) {\n\t\tif (event.type === \"click\") return this.marker?.fire(\"click\"); //this.atlas?.togglePopup(this.marker, this);\n\t\tif (event.key === \" \") event.preventDefault(); // Prevent page scroll on space key\n\t\tif (event.key === \" \" || event.key === \"Enter\") this.click(); // Forward keyvoard to click for accessibility\n\t}\n\tget latlng() {\n\t\treturn attr(this, \"data-latlng\") || \"\";\n\t}\n\tset latlng(latlng: string) {\n\t\tattr(this, \"data-latlng\", latlng);\n\t}\n\t#parseLatLng() {\n\t\treturn this.latlng?.split(\",\").map(parseFloat) as L.LatLngTuple;\n\t}\n\t#handleDragEnd(detail: L.LeafletEvent) {\n\t\tconst slot = detail.target._icon\n\t\t\t?.firstElementChild as HTMLSlotElement | null;\n\t\tconst self =\n\t\t\tslot?.assignedElements?.()?.[0] as MTDSAtlasMarkerElement | null;\n\t\tconst { lat, lng } = detail.target.getLatLng(); // Using L.Marker.getLatLng() to get position also when in spiderified cluster\n\t\tif (self) self.latlng = `${lat},${lng}`;\n\t\tself?.dispatchEvent(new CustomEvent(\"dragend\", { detail, bubbles: true }));\n\t}\n}\n\ndefineElement(\"mtds-atlas-marker\", MTDSAtlasMarkerElement);\n"],"mappings":";;;AAUA,IAAI,IAAO,GACE,IAAb,cAA4C,EAAY;CACvD;CACA;CAEA,WAAW,qBAAqB;EAC/B,OAAO;GAAC;GAAU;GAAa;GAAe;EAAe;CAC9D;CACA,oBAAoB;EACnB,qBAAqB;GACpB,IAAM,IAAO,EAAI,QAAQ,EAAE,MAAM,GAAG,EAAE,IAAO,CAAC,GACxC,IAAO,IAAI,EAAE,QAAQ;IAAE;IAAM,UAAU,CAAC,GAAG,CAAC;GAAE,CAAC;GAcrD,AAbA,KAAK,QAAQ,KAAK,QAA0B,YAAY,KAAK,KAAA,GAC7D,KAAK,SAAS,IAAI,EAAE,OAAO,KAAKA,GAAa,GAAG;IAC/C,WAAW,KAAK;IAChB,UAAU;IACV;GACD,CAAC,GACD,KAAK,OAAO,gBAAgB,IAAI,EAAK,MAAM,eAAe,GAAG,GAC7D,KAAK,OAAO,GAAG,WAAW,KAAKC,EAAc,GAE7C,EAAG,MAAM,iBAAiB,IAAI,GAC9B,EAAK,MAAM,QAAQ,GAAG,GAAM,GAC5B,EAA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