@mattilsynet/design 2.2.24 → 2.2.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/mtds/alert/alert.js +9 -8
- package/mtds/alert/alert.js.map +1 -1
- package/mtds/analytics/analytics.d.ts +1 -1
- package/mtds/analytics/analytics.js +163 -101
- package/mtds/analytics/analytics.js.map +1 -1
- package/mtds/app/app-observer.js +73 -27
- package/mtds/app/app-observer.js.map +1 -1
- package/mtds/app/app-toggle.js +2 -24
- package/mtds/app/app-toggle.js.map +1 -1
- package/mtds/app/app-toggle2.js +16 -10
- package/mtds/app/app-toggle2.js.map +1 -1
- package/mtds/app/app.d.ts +5 -5
- package/mtds/app/app.js +36 -32
- package/mtds/app/app.js.map +1 -1
- package/mtds/atlas/atlas-element.d.ts +8 -14
- package/mtds/atlas/atlas-element.js +90 -76
- package/mtds/atlas/atlas-element.js.map +1 -1
- package/mtds/atlas/atlas-marker.d.ts +20 -0
- package/mtds/atlas/atlas-marker.js +69 -0
- package/mtds/atlas/atlas-marker.js.map +1 -0
- package/mtds/atlas/atlas-matgeo.d.ts +29 -0
- package/mtds/atlas/atlas-matgeo.js +71 -0
- package/mtds/atlas/atlas-matgeo.js.map +1 -0
- package/mtds/atlas/atlas.css.js +76 -96
- package/mtds/atlas/atlas.css.js.map +1 -1
- package/mtds/atlas/atlas.d.ts +42 -0
- package/mtds/atlas/atlas.js +33 -0
- package/mtds/atlas/atlas.js.map +1 -0
- package/mtds/atlas/atlas.stories.d.ts +5 -1
- package/mtds/atlas/cluster.js +1576 -697
- package/mtds/atlas/cluster.js.map +1 -1
- package/mtds/atlas.iife.js +80 -100
- package/mtds/atlas.js +8 -4
- package/mtds/atlas.js.map +1 -1
- package/mtds/avatar/avatar.js +8 -8
- package/mtds/avatar/avatar.js.map +1 -1
- package/mtds/badge/badge.d.ts +2 -2
- package/mtds/badge/badge.js +7 -7
- package/mtds/badge/badge.js.map +1 -1
- package/mtds/breadcrumbs/breadcrumbs-observer.js +10 -9
- package/mtds/breadcrumbs/breadcrumbs-observer.js.map +1 -1
- package/mtds/breadcrumbs/breadcrumbs.js +14 -13
- package/mtds/breadcrumbs/breadcrumbs.js.map +1 -1
- package/mtds/button/button.js +16 -14
- package/mtds/button/button.js.map +1 -1
- package/mtds/card/card.js +14 -12
- package/mtds/card/card.js.map +1 -1
- package/mtds/chart/chart-axis.js +27 -15
- package/mtds/chart/chart-axis.js.map +1 -1
- package/mtds/chart/chart-bars.js +15 -13
- package/mtds/chart/chart-bars.js.map +1 -1
- package/mtds/chart/chart-element.d.ts +5 -0
- package/mtds/chart/chart-element.js +83 -48
- package/mtds/chart/chart-element.js.map +1 -1
- package/mtds/chart/chart-lines.js +54 -32
- package/mtds/chart/chart-lines.js.map +1 -1
- package/mtds/chart/chart-pies.js +34 -14
- package/mtds/chart/chart-pies.js.map +1 -1
- package/mtds/chart/chart.css.js +2 -2
- package/mtds/chart/chart.css.js.map +1 -1
- package/mtds/chart/chart.d.ts +3 -4
- package/mtds/chart/chart.js +12 -12
- package/mtds/chart/chart.js.map +1 -1
- package/mtds/chip/chip.js +8 -8
- package/mtds/chip/chip.js.map +1 -1
- package/mtds/details/details.d.ts +3 -3
- package/mtds/details/details.js +14 -12
- package/mtds/details/details.js.map +1 -1
- package/mtds/dialog/dialog-observer.js +35 -22
- package/mtds/dialog/dialog-observer.js.map +1 -1
- package/mtds/dialog/dialog.d.ts +2 -2
- package/mtds/dialog/dialog.js +12 -12
- package/mtds/dialog/dialog.js.map +1 -1
- package/mtds/divider/divider.d.ts +2 -2
- package/mtds/divider/divider.js +10 -10
- package/mtds/divider/divider.js.map +1 -1
- package/mtds/errorsummary/errorsummary-observer.js +11 -8
- package/mtds/errorsummary/errorsummary-observer.js.map +1 -1
- package/mtds/errorsummary/errorsummary.d.ts +1 -1
- package/mtds/errorsummary/errorsummary.js +11 -11
- package/mtds/errorsummary/errorsummary.js.map +1 -1
- package/mtds/external/leaflet/dist/leaflet-src.js +6006 -3098
- package/mtds/external/leaflet/dist/leaflet-src.js.map +1 -1
- package/mtds/external/leaflet/dist/leaflet.css.js +2 -2
- package/mtds/external/leaflet/dist/leaflet.css.js.map +1 -1
- package/mtds/field/field-observer.js +114 -62
- package/mtds/field/field-observer.js.map +1 -1
- package/mtds/field/field.d.ts +6 -6
- package/mtds/field/field.js +166 -133
- package/mtds/field/field.js.map +1 -1
- package/mtds/field/field.stories.d.ts +2 -0
- package/mtds/fieldset/fieldset-observer.js +24 -14
- package/mtds/fieldset/fieldset-observer.js.map +1 -1
- package/mtds/fieldset/fieldset.d.ts +1 -1
- package/mtds/fieldset/fieldset.js +11 -11
- package/mtds/fieldset/fieldset.js.map +1 -1
- package/mtds/fileupload/fileupload.js +9 -8
- package/mtds/fileupload/fileupload.js.map +1 -1
- package/mtds/helptext/helptext.d.ts +1 -1
- package/mtds/helptext/helptext.js +15 -15
- package/mtds/helptext/helptext.js.map +1 -1
- package/mtds/index.iife.js +9 -9
- package/mtds/index.js +26 -24
- package/mtds/input/input.d.ts +3 -3
- package/mtds/input/input.js +22 -20
- package/mtds/input/input.js.map +1 -1
- package/mtds/law/law-helper.d.ts +6 -2
- package/mtds/law/law-helper.js +145 -63
- package/mtds/law/law-helper.js.map +1 -1
- package/mtds/law/law.d.ts +6 -2
- package/mtds/law/law.js +6 -6
- package/mtds/law/law.js.map +1 -1
- package/mtds/law/law.stories.d.ts +1 -0
- package/mtds/layout/layout.js +13 -10
- package/mtds/layout/layout.js.map +1 -1
- package/mtds/link/link.js +8 -7
- package/mtds/link/link.js.map +1 -1
- package/mtds/logo/logo-observer.js +18 -12
- package/mtds/logo/logo-observer.js.map +1 -1
- package/mtds/logo/logo.js +8 -8
- package/mtds/logo/logo.js.map +1 -1
- package/mtds/package.json.js +2 -2
- package/mtds/pagination/pagination-helper.js +17 -11
- package/mtds/pagination/pagination-helper.js.map +1 -1
- package/mtds/pagination/pagination.d.ts +1 -1
- package/mtds/pagination/pagination.js +30 -30
- package/mtds/pagination/pagination.js.map +1 -1
- package/mtds/popover/popover-observer.js +37 -28
- package/mtds/popover/popover-observer.js.map +1 -1
- package/mtds/popover/popover.js +13 -11
- package/mtds/popover/popover.js.map +1 -1
- package/mtds/progress/progress.d.ts +1 -1
- package/mtds/progress/progress.js +8 -8
- package/mtds/progress/progress.js.map +1 -1
- package/mtds/react-atlas.d.ts +1 -0
- package/mtds/react-atlas.js +13 -0
- package/mtds/react-atlas.js.map +1 -0
- package/mtds/react-types.d.ts +3 -0
- package/mtds/react.js +79 -79
- package/mtds/skeleton/skeleton.js +8 -8
- package/mtds/skeleton/skeleton.js.map +1 -1
- package/mtds/spinner/spinner.d.ts +2 -2
- package/mtds/spinner/spinner.js +8 -8
- package/mtds/spinner/spinner.js.map +1 -1
- package/mtds/steps/steps.d.ts +2 -2
- package/mtds/steps/steps.js +7 -7
- package/mtds/steps/steps.js.map +1 -1
- package/mtds/styles.css +4586 -1
- package/mtds/styles.module.css.js +167 -112
- package/mtds/styles.module.css.js.map +1 -1
- package/mtds/table/table-observer.js +22 -19
- package/mtds/table/table-observer.js.map +1 -1
- package/mtds/table/table.d.ts +4 -4
- package/mtds/table/table.js +18 -16
- package/mtds/table/table.js.map +1 -1
- package/mtds/tabs/tabs.d.ts +4 -4
- package/mtds/tabs/tabs.js +25 -21
- package/mtds/tabs/tabs.js.map +1 -1
- package/mtds/tag/tag.js +8 -8
- package/mtds/tag/tag.js.map +1 -1
- package/mtds/tailwind.css +24 -6
- package/mtds/toast/toast-helper.js +35 -20
- package/mtds/toast/toast-helper.js.map +1 -1
- package/mtds/toast/toast-observer.js +30 -15
- package/mtds/toast/toast-observer.js.map +1 -1
- package/mtds/toast/toast.js +45 -37
- package/mtds/toast/toast.js.map +1 -1
- package/mtds/togglegroup/togglegroup-observer.js +15 -10
- package/mtds/togglegroup/togglegroup-observer.js.map +1 -1
- package/mtds/togglegroup/togglegroup.d.ts +3 -3
- package/mtds/togglegroup/togglegroup.js +20 -18
- package/mtds/togglegroup/togglegroup.js.map +1 -1
- package/mtds/tooltip/tooltip-observer.js +48 -32
- package/mtds/tooltip/tooltip-observer.js.map +1 -1
- package/mtds/typography/typography.js +28 -19
- package/mtds/typography/typography.js.map +1 -1
- package/mtds/utils.d.ts +12 -3
- package/mtds/utils.js +133 -81
- package/mtds/utils.js.map +1 -1
- package/mtds/validation/validation.d.ts +1 -1
- package/mtds/validation/validation.js +12 -12
- package/mtds/validation/validation.js.map +1 -1
- package/package.json +14 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-toggle.js","sources":["../../designsystem/app/app-toggle.js?raw"],"sourcesContent":["export default \"if (\\n\\ttypeof window !== \\\"undefined\\\" &&\\n\\twindow.CSSStyleSheet &&\\n\\tdocument.adoptedStyleSheets\\n)\\n\\t(() => {\\n\\t\\tconst key = \\\"--mtds-app-expanded\\\";\\n\\t\\tconst sheet = new CSSStyleSheet();\\n\\t\\tconst prev = () => !window.localStorage.getItem(key)?.includes(\\\"false\\\");\\n\\n\\t\\tdocument.adoptedStyleSheets.push(sheet);\\n\\t\\twindow.mtdsToggleAppExpanded = (force) => {\\n\\t\\t\\ttry {\\n\\t\\t\\t\\tconst next = force ?? !prev();\\n\\t\\t\\t\\tsheet.replaceSync?.(`:root { ${key}: var(${key}--${next})}`);\\n\\t\\t\\t\\twindow.localStorage.setItem(key, next);\\n\\t\\t\\t} catch (_err) {} // localStorage is full or replaceSync is not supported\\n\\t\\t};\\n\\n\\t\\t// Set and store initial state\\n\\t\\twindow.mtdsToggleAppExpanded(prev());\\n\\t})();\\n\""],"names":[
|
|
1
|
+
{"version":3,"file":"app-toggle.js","sources":["../../designsystem/app/app-toggle.js?raw"],"sourcesContent":["export default \"if (\\n\\ttypeof window !== \\\"undefined\\\" &&\\n\\twindow.CSSStyleSheet &&\\n\\tdocument.adoptedStyleSheets\\n)\\n\\t(() => {\\n\\t\\tconst key = \\\"--mtds-app-expanded\\\";\\n\\t\\tconst sheet = new CSSStyleSheet();\\n\\t\\tconst prev = () => !window.localStorage.getItem(key)?.includes(\\\"false\\\");\\n\\n\\t\\tdocument.adoptedStyleSheets.push(sheet);\\n\\t\\twindow.mtdsToggleAppExpanded = (force) => {\\n\\t\\t\\ttry {\\n\\t\\t\\t\\tconst next = force ?? !prev();\\n\\t\\t\\t\\tsheet.replaceSync?.(`:root { ${key}: var(${key}--${next})}`);\\n\\t\\t\\t\\twindow.localStorage.setItem(key, next);\\n\\t\\t\\t} catch (_err) {} // localStorage is full or replaceSync is not supported\\n\\t\\t};\\n\\n\\t\\t// Set and store initial state\\n\\t\\twindow.mtdsToggleAppExpanded(prev());\\n\\t})();\\n\""],"names":[],"mappings":"AAAA,MAAA,SAAe;"}
|
package/mtds/app/app-toggle2.js
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
typeof window
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
1
|
+
if (typeof window !== "undefined" && window.CSSStyleSheet && document.adoptedStyleSheets)
|
|
2
|
+
(() => {
|
|
3
|
+
const key = "--mtds-app-expanded";
|
|
4
|
+
const sheet = new CSSStyleSheet();
|
|
5
|
+
const prev = () => !window.localStorage.getItem(key)?.includes("false");
|
|
6
|
+
document.adoptedStyleSheets.push(sheet);
|
|
7
|
+
window.mtdsToggleAppExpanded = (force) => {
|
|
8
|
+
try {
|
|
9
|
+
const next = force ?? !prev();
|
|
10
|
+
sheet.replaceSync?.(`:root { ${key}: var(${key}--${next})}`);
|
|
11
|
+
window.localStorage.setItem(key, next);
|
|
12
|
+
} catch (_err) {
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
window.mtdsToggleAppExpanded(prev());
|
|
16
|
+
})();
|
|
11
17
|
//# sourceMappingURL=app-toggle2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-toggle2.js","sources":["../../designsystem/app/app-toggle.js"],"sourcesContent":["if (\n\ttypeof window !== \"undefined\" &&\n\twindow.CSSStyleSheet &&\n\tdocument.adoptedStyleSheets\n)\n\t(() => {\n\t\tconst key = \"--mtds-app-expanded\";\n\t\tconst sheet = new CSSStyleSheet();\n\t\tconst prev = () => !window.localStorage.getItem(key)?.includes(\"false\");\n\n\t\tdocument.adoptedStyleSheets.push(sheet);\n\t\twindow.mtdsToggleAppExpanded = (force) => {\n\t\t\ttry {\n\t\t\t\tconst next = force ?? !prev();\n\t\t\t\tsheet.replaceSync?.(`:root { ${key}: var(${key}--${next})}`);\n\t\t\t\twindow.localStorage.setItem(key, next);\n\t\t\t} catch (_err) {} // localStorage is full or replaceSync is not supported\n\t\t};\n\n\t\t// Set and store initial state\n\t\twindow.mtdsToggleAppExpanded(prev());\n\t})();\n"],"names":[
|
|
1
|
+
{"version":3,"file":"app-toggle2.js","sources":["../../designsystem/app/app-toggle.js"],"sourcesContent":["if (\n\ttypeof window !== \"undefined\" &&\n\twindow.CSSStyleSheet &&\n\tdocument.adoptedStyleSheets\n)\n\t(() => {\n\t\tconst key = \"--mtds-app-expanded\";\n\t\tconst sheet = new CSSStyleSheet();\n\t\tconst prev = () => !window.localStorage.getItem(key)?.includes(\"false\");\n\n\t\tdocument.adoptedStyleSheets.push(sheet);\n\t\twindow.mtdsToggleAppExpanded = (force) => {\n\t\t\ttry {\n\t\t\t\tconst next = force ?? !prev();\n\t\t\t\tsheet.replaceSync?.(`:root { ${key}: var(${key}--${next})}`);\n\t\t\t\twindow.localStorage.setItem(key, next);\n\t\t\t} catch (_err) {} // localStorage is full or replaceSync is not supported\n\t\t};\n\n\t\t// Set and store initial state\n\t\twindow.mtdsToggleAppExpanded(prev());\n\t})();\n"],"names":[],"mappings":"AAAA,IACC,OAAO,WAAW,eAClB,OAAO,iBACP,SAAS;AAET,GAAC,MAAM;AACN,UAAM,MAAM;AACZ,UAAM,QAAQ,IAAI,cAAa;AAC/B,UAAM,OAAO,MAAM,CAAC,OAAO,aAAa,QAAQ,GAAG,GAAG,SAAS,OAAO;AAEtE,aAAS,mBAAmB,KAAK,KAAK;AACtC,WAAO,wBAAwB,CAAC,UAAU;AACzC,UAAI;AACH,cAAM,OAAO,SAAS,CAAC,KAAI;AAC3B,cAAM,cAAc,WAAW,GAAG,SAAS,GAAG,KAAK,IAAI,IAAI;AAC3D,eAAO,aAAa,QAAQ,KAAK,IAAI;AAAA,MACtC,SAAS,MAAM;AAAA,MAAC;AAAA,IACjB;AAGA,WAAO,sBAAsB,MAAM;AAAA,EACpC,GAAC;"}
|
package/mtds/app/app.d.ts
CHANGED
|
@@ -9,12 +9,12 @@ export type AppFooterProps = React.ComponentPropsWithoutRef<"footer">;
|
|
|
9
9
|
export type AppProps<As extends React.ElementType = "div"> = PolymorphicComponentPropWithRef<As>;
|
|
10
10
|
type AppComponent = <As extends React.ElementType = "div">(props: AppProps<As>) => JSX.Element;
|
|
11
11
|
export declare const App: AppComponent & {
|
|
12
|
-
Header:
|
|
13
|
-
Sidebar:
|
|
12
|
+
Header: import('react').ForwardRefExoticComponent<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLElement>, HTMLElement>, "ref"> & import('react').RefAttributes<HTMLElement>>;
|
|
13
|
+
Sidebar: import('react').ForwardRefExoticComponent<Omit<import('react').DetailedHTMLProps<import('react').DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement>, "ref"> & import('react').RefAttributes<HTMLDialogElement>>;
|
|
14
14
|
Sticky: AppComponent;
|
|
15
|
-
Toggle:
|
|
16
|
-
Main:
|
|
17
|
-
Footer:
|
|
15
|
+
Toggle: import('react').ForwardRefExoticComponent<Omit<ButtonProps<"button">, "ref"> & import('react').RefAttributes<HTMLButtonElement>>;
|
|
16
|
+
Main: import('react').ForwardRefExoticComponent<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLElement>, HTMLElement>, "ref"> & import('react').RefAttributes<HTMLElement>>;
|
|
17
|
+
Footer: import('react').ForwardRefExoticComponent<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLElement>, HTMLElement>, "ref"> & import('react').RefAttributes<HTMLElement>>;
|
|
18
18
|
Script: () => import("react/jsx-runtime").JSX.Element;
|
|
19
19
|
};
|
|
20
20
|
export {};
|
package/mtds/app/app.js
CHANGED
|
@@ -1,51 +1,55 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
import
|
|
3
|
-
import { forwardRef
|
|
4
|
-
import { Button
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import { Button } from "../button/button.js";
|
|
5
|
+
import styles from "../styles.module.css.js";
|
|
6
|
+
import script from "./app-toggle.js";
|
|
7
|
+
const AppComp = forwardRef(function App2({ as, className, ...rest }, ref) {
|
|
8
|
+
const Tag = as || "div";
|
|
9
|
+
return /* @__PURE__ */ jsx(Tag, { className: clsx(styles.app, className), ref, ...rest });
|
|
10
|
+
});
|
|
11
|
+
const AppSticky = forwardRef(function App3({ as, className, ...rest }, ref) {
|
|
12
|
+
const Tag = as || "div";
|
|
13
|
+
return /* @__PURE__ */ jsx(Tag, { className: clsx(styles.sticky, className), ref, ...rest });
|
|
14
|
+
});
|
|
15
|
+
const App = Object.assign(AppComp, {
|
|
16
|
+
Header: forwardRef(
|
|
17
|
+
function AppHeader(rest, ref) {
|
|
18
|
+
return /* @__PURE__ */ jsx("header", { ref, ...rest });
|
|
15
19
|
}
|
|
16
20
|
),
|
|
17
|
-
Sidebar:
|
|
18
|
-
function(
|
|
19
|
-
return /* @__PURE__ */
|
|
21
|
+
Sidebar: forwardRef(
|
|
22
|
+
function AppSidebar(rest, ref) {
|
|
23
|
+
return /* @__PURE__ */ jsx("dialog", { role: "navigation", ref, ...rest });
|
|
20
24
|
}
|
|
21
25
|
),
|
|
22
|
-
Sticky:
|
|
23
|
-
Toggle:
|
|
24
|
-
function({ children
|
|
25
|
-
return /* @__PURE__ */
|
|
26
|
-
|
|
26
|
+
Sticky: AppSticky,
|
|
27
|
+
Toggle: forwardRef(
|
|
28
|
+
function AppToggle({ children, ...rest }, ref) {
|
|
29
|
+
return /* @__PURE__ */ jsx(
|
|
30
|
+
Button,
|
|
27
31
|
{
|
|
28
32
|
"data-command": "toggle-app-expanded",
|
|
29
33
|
"data-tooltip": "Vis meny",
|
|
30
|
-
ref
|
|
31
|
-
...
|
|
32
|
-
children:
|
|
34
|
+
ref,
|
|
35
|
+
...rest,
|
|
36
|
+
children: children ?? "Skjul meny"
|
|
33
37
|
}
|
|
34
38
|
);
|
|
35
39
|
}
|
|
36
40
|
),
|
|
37
|
-
Main:
|
|
38
|
-
return /* @__PURE__ */
|
|
41
|
+
Main: forwardRef(function AppMain(rest, ref) {
|
|
42
|
+
return /* @__PURE__ */ jsx("main", { ref, ...rest });
|
|
39
43
|
}),
|
|
40
|
-
Footer:
|
|
41
|
-
function(
|
|
42
|
-
return /* @__PURE__ */
|
|
44
|
+
Footer: forwardRef(
|
|
45
|
+
function AppFooter(rest, ref) {
|
|
46
|
+
return /* @__PURE__ */ jsx("footer", { ref, ...rest });
|
|
43
47
|
}
|
|
44
48
|
),
|
|
45
49
|
// Needed to avoid flash of unstyled content and still be Next.js hydration compatible
|
|
46
|
-
Script: () => /* @__PURE__ */
|
|
50
|
+
Script: () => /* @__PURE__ */ jsx("script", { id: "mtds-app-script", children: script })
|
|
47
51
|
});
|
|
48
52
|
export {
|
|
49
|
-
|
|
53
|
+
App
|
|
50
54
|
};
|
|
51
55
|
//# 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<As>;\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 <dialog role=\"navigation\" ref={ref} {...rest} />;\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\tdata-command=\"toggle-app-expanded\"\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"],"names":["
|
|
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<As>;\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 <dialog role=\"navigation\" ref={ref} {...rest} />;\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\tdata-command=\"toggle-app-expanded\"\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"],"names":["App"],"mappings":";;;;;;AAsBA,MAAM,UAAU,WAAiB,SAASA,KAExC,EAAE,IAAI,WAAW,GAAG,KAAA,GAAsB,KAA0B;AACrE,QAAM,MAAM,MAAM;AAElB,SAAO,oBAAC,KAAA,EAAI,WAAW,KAAK,OAAO,KAAK,SAAS,GAAG,KAAW,GAAG,KAAA,CAAM;AACzE,CAAC;AAED,MAAM,YAAY,WAAiB,SAASA,KAE1C,EAAE,IAAI,WAAW,GAAG,KAAA,GAAsB,KAA0B;AACrE,QAAM,MAAM,MAAM;AAElB,SAAO,oBAAC,KAAA,EAAI,WAAW,KAAK,OAAO,QAAQ,SAAS,GAAG,KAAW,GAAG,KAAA,CAAM;AAC5E,CAAC;AAEM,MAAM,MAAM,OAAO,OAAO,SAAS;AAAA,EACzC,QAAQ;AAAA,IACP,SAAS,UAAU,MAAM,KAAK;AAC7B,aAAO,oBAAC,UAAA,EAAO,KAAW,GAAG,KAAA,CAAM;AAAA,IACpC;AAAA,EAAA;AAAA,EAED,SAAS;AAAA,IACR,SAAS,WAAW,MAAM,KAAK;AAC9B,iCAAQ,UAAA,EAAO,MAAK,cAAa,KAAW,GAAG,MAAM;AAAA,IACtD;AAAA,EAAA;AAAA,EAED,QAAQ;AAAA,EACR,QAAQ;AAAA,IACP,SAAS,UAAU,EAAE,UAAU,GAAG,KAAA,GAA+B,KAAK;AACrE,aACC;AAAA,QAAC;AAAA,QAAA;AAAA,UACA,gBAAa;AAAA,UACb,gBAAa;AAAA,UACb;AAAA,UACC,GAAG;AAAA,UAEH,UAAA,YAAY;AAAA,QAAA;AAAA,MAAA;AAAA,IAGhB;AAAA,EAAA;AAAA,EAED,MAAM,WAAsC,SAAS,QAAQ,MAAM,KAAK;AACvE,WAAO,oBAAC,QAAA,EAAK,KAAW,GAAG,KAAA,CAAM;AAAA,EAClC,CAAC;AAAA,EACD,QAAQ;AAAA,IACP,SAAS,UAAU,MAAM,KAAK;AAC7B,aAAO,oBAAC,UAAA,EAAO,KAAW,GAAG,KAAA,CAAM;AAAA,IACpC;AAAA,EAAA;AAAA;AAAA,EAGD,QAAQ,MAAM,oBAAC,UAAA,EAAO,IAAG,mBAAmB,UAAA,OAAA,CAAO;AACpD,CAAC;"}
|
|
@@ -1,28 +1,22 @@
|
|
|
1
1
|
import { default as L } from 'leaflet';
|
|
2
2
|
import { MTDSElement } from '../utils';
|
|
3
|
-
import type * as ReactTypes from "react";
|
|
4
3
|
export { L };
|
|
4
|
+
export { MTDSAtlasMarkerElement } from './atlas-marker';
|
|
5
|
+
export { MTDSAtlasMatgeoElement } from './atlas-matgeo';
|
|
5
6
|
declare global {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"mtds-atlas": ReactTypes.DetailedHTMLProps<ReactTypes.HTMLAttributes<MTDSAtlasElement>, MTDSAtlasElement> & {
|
|
9
|
-
class?: string;
|
|
10
|
-
"data-cluster"?: number | `${number}` | boolean | "true" | "false";
|
|
11
|
-
"data-scrollzoom"?: boolean | "true" | "false";
|
|
12
|
-
"data-tiles"?: "color" | "gray";
|
|
13
|
-
"data-view"?: string | number[];
|
|
14
|
-
};
|
|
15
|
-
}
|
|
7
|
+
interface HTMLElementTagNameMap {
|
|
8
|
+
"mtds-atlas": MTDSAtlasElement;
|
|
16
9
|
}
|
|
17
10
|
}
|
|
18
11
|
export declare class MTDSAtlasElement extends MTDSElement {
|
|
12
|
+
#private;
|
|
19
13
|
cluster?: L.MarkerClusterGroup;
|
|
20
14
|
map?: L.Map;
|
|
21
15
|
static get observedAttributes(): string[];
|
|
22
16
|
constructor();
|
|
23
17
|
connectedCallback(): void;
|
|
24
|
-
attributeChangedCallback(name: string, _prev?:
|
|
25
|
-
setView(view: string | number[],
|
|
26
|
-
|
|
18
|
+
attributeChangedCallback(name: string, _prev?: null, next?: string | null): void;
|
|
19
|
+
setView(view: string | number[], opts?: L.FitBoundsOptions): L.Map | undefined;
|
|
20
|
+
latLngFromPoint(x: number, y: number): any;
|
|
27
21
|
disconnectedCallback(): void;
|
|
28
22
|
}
|
|
@@ -1,102 +1,116 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import A from "./atlas.css.js";
|
|
1
|
+
import L from "../external/leaflet/dist/leaflet-src.js";
|
|
2
|
+
import LeafletCSS from "../external/leaflet/dist/leaflet.css.js";
|
|
4
3
|
import "./cluster.js";
|
|
5
|
-
import {
|
|
6
|
-
|
|
4
|
+
import { defineElement, MTDSElement, tag, attr, on, off } from "../utils.js";
|
|
5
|
+
import css from "./atlas.css.js";
|
|
6
|
+
import { MTDSAtlasMarkerElement } from "./atlas-marker.js";
|
|
7
|
+
import { MTDSAtlasMatgeoElement } from "./atlas-matgeo.js";
|
|
8
|
+
let SKIP_CLICK = 0;
|
|
9
|
+
const KARTVERKET_MAX_ZOOM = 18;
|
|
10
|
+
const KARTVERKET_TILES_URL = "https://cache.kartverket.no/v1/wmts/1.0.0/topo/default/webmercator/{z}/{y}/{x}.png";
|
|
11
|
+
const BOUNDS_NORWAY = [
|
|
7
12
|
[57.5, 4.73],
|
|
8
13
|
[71.5, 31.44]
|
|
9
|
-
]
|
|
10
|
-
class
|
|
14
|
+
];
|
|
15
|
+
class MTDSAtlasElement extends MTDSElement {
|
|
11
16
|
cluster;
|
|
12
17
|
map;
|
|
13
18
|
static get observedAttributes() {
|
|
14
19
|
return ["data-view", "data-scrollzoom"];
|
|
15
20
|
}
|
|
16
21
|
constructor() {
|
|
17
|
-
super()
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
super();
|
|
23
|
+
this.attachShadow({ mode: "open" }).append(
|
|
24
|
+
tag(
|
|
25
|
+
"style",
|
|
26
|
+
{},
|
|
27
|
+
`@layer leaflet{${LeafletCSS}}
|
|
28
|
+
@layer mt.v2-2-25design{${css}`
|
|
29
|
+
),
|
|
30
|
+
tag("figure")
|
|
22
31
|
);
|
|
23
32
|
}
|
|
24
33
|
connectedCallback() {
|
|
25
|
-
const
|
|
34
|
+
const container = this.shadowRoot?.lastElementChild;
|
|
35
|
+
const cluster = attr(this, "data-cluster") ?? "false";
|
|
36
|
+
const tiles = new L.TileLayer(KARTVERKET_TILES_URL, {
|
|
26
37
|
attribution: "© Kartverket",
|
|
27
|
-
maxZoom:
|
|
38
|
+
maxZoom: KARTVERKET_MAX_ZOOM
|
|
28
39
|
});
|
|
29
|
-
this.map = new
|
|
30
|
-
attributionControl:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
this.map = new L.Map(container, {
|
|
41
|
+
attributionControl: false,
|
|
42
|
+
fadeAnimation: false,
|
|
43
|
+
// Prevent popup fades
|
|
44
|
+
layers: [tiles],
|
|
45
|
+
zoomControl: false,
|
|
46
|
+
zoomSnap: 0.2
|
|
47
|
+
});
|
|
48
|
+
on(this, "pointerup,click", this.#skipClick);
|
|
49
|
+
this.map.addControl(new L.Control.Attribution({ prefix: "" }));
|
|
50
|
+
this.map.addControl(new L.Control.Zoom({ position: "bottomright" }));
|
|
51
|
+
this.map.on("popupopen popupclose", this.#handlePopup, this);
|
|
52
|
+
this.cluster = new L.MarkerClusterGroup({
|
|
53
|
+
zoomToBoundsOnClick: true,
|
|
54
|
+
showCoverageOnHover: false,
|
|
55
|
+
disableClusteringAtZoom: cluster === "false" ? 1 : Number(cluster) || KARTVERKET_MAX_ZOOM + 1,
|
|
56
|
+
iconCreateFunction: (cluster2) => new L.DivIcon({
|
|
57
|
+
html: `${cluster2.getChildCount()}`,
|
|
40
58
|
className: "leaflet-cluster-icon",
|
|
41
|
-
|
|
42
|
-
iconSize: c
|
|
59
|
+
iconSize: [30, 30]
|
|
43
60
|
})
|
|
44
|
-
}).addTo(this.map)
|
|
45
|
-
|
|
46
|
-
|
|
61
|
+
}).addTo(this.map);
|
|
62
|
+
for (const name of MTDSAtlasElement.observedAttributes)
|
|
63
|
+
this.attributeChangedCallback(name, null, attr(this, name));
|
|
47
64
|
}
|
|
48
|
-
attributeChangedCallback(
|
|
49
|
-
|
|
65
|
+
attributeChangedCallback(name, _prev, next) {
|
|
66
|
+
if (name === "data-view") this.setView(next || "");
|
|
67
|
+
if (name === "data-scrollzoom")
|
|
68
|
+
this.map?.scrollWheelZoom[next === "false" ? "disable" : "enable"]();
|
|
50
69
|
}
|
|
51
|
-
setView(
|
|
52
|
-
const
|
|
53
|
-
|
|
70
|
+
setView(view, opts) {
|
|
71
|
+
const p = `${view}`.split(",").map(parseFloat).filter(Number.isFinite);
|
|
72
|
+
const b = this.cluster?.getBounds();
|
|
73
|
+
if (p.length === 3) return this.map?.setView([p[0], p[1]], p[2], opts);
|
|
74
|
+
if (view !== "fit") return this.map?.fitBounds(BOUNDS_NORWAY, opts);
|
|
75
|
+
if (b?.isValid()) return this.map?.fitBounds(b.pad(0.1), opts);
|
|
76
|
+
this.cluster?.once("layeradd", () => {
|
|
77
|
+
setTimeout(() => this.setView("fit"), 50);
|
|
78
|
+
});
|
|
54
79
|
}
|
|
55
|
-
|
|
56
|
-
return
|
|
57
|
-
this.cluster
|
|
58
|
-
);
|
|
80
|
+
latLngFromPoint(x, y) {
|
|
81
|
+
return this.map?.pointerEventToLatLng({ clientX: x, clientY: y });
|
|
59
82
|
}
|
|
60
83
|
disconnectedCallback() {
|
|
61
|
-
|
|
84
|
+
off(this, "pointerup,click", this.#skipClick);
|
|
85
|
+
this.map?.remove();
|
|
86
|
+
this.map = this.cluster = void 0;
|
|
62
87
|
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
tooltipAnchor: [0, -30]
|
|
76
|
-
}), window.customElements.define("mtds-atlas", p);
|
|
77
|
-
}
|
|
78
|
-
const g = S(function() {
|
|
79
|
-
this.cluster?.off("layeradd", g, this), this.cluster?.getBounds().isValid() && this.setView("fit");
|
|
80
|
-
}, 100), u = "popupclose move resize zoom viewreset", f = ({ target: l, popup: e }) => {
|
|
81
|
-
const o = e.getContent(), t = String(o)[0] === "#" && document.getElementById(o.slice(1));
|
|
82
|
-
if (t && t.closest("mtds-atlas")) {
|
|
83
|
-
const n = e.getLatLng(), w = i(t, "popover");
|
|
84
|
-
i(e.getElement(), "hidden", ""), i(t, "popover", null);
|
|
85
|
-
const a = (r) => {
|
|
86
|
-
if (r?.type === "popupclose" && r?.popup === e)
|
|
87
|
-
l.off(u, a), i(e.getElement(), "hidden", null), i(t, "data-popover", null), i(t, "popover", w), v(), C();
|
|
88
|
-
else {
|
|
89
|
-
const h = l.latLngToContainerPoint(n), b = h.x - t.offsetWidth / 2, y = h.y - t.offsetHeight - c[1];
|
|
90
|
-
t.style.translate = `${b}px ${y}px`;
|
|
91
|
-
}
|
|
92
|
-
}, v = z(() => a(), t), C = x(t, "click", (r) => {
|
|
93
|
-
r.target?.closest?.('[popovertargetaction="hide"]') && e.close();
|
|
94
|
-
});
|
|
95
|
-
l.on(u, a), a();
|
|
88
|
+
#handlePopup({ type, popup }) {
|
|
89
|
+
const open = type === "popupopen";
|
|
90
|
+
const cont = popup.getElement()?.querySelector(".leaflet-popup-content");
|
|
91
|
+
const slot = cont?.querySelector(":scope > slot");
|
|
92
|
+
const id = cont?.textContent?.match(/^#(\S+)/)?.[1] || "";
|
|
93
|
+
const el = document.getElementById(slot?.name || id);
|
|
94
|
+
if (!el) return open && id && popup.close();
|
|
95
|
+
L.Util.setOptions(popup, { maxWidth: 9999 });
|
|
96
|
+
attr(el, "data-popover", open ? attr(el, "popover") : null);
|
|
97
|
+
attr(el, "popover", open ? null : attr(el, "data-popover"));
|
|
98
|
+
attr(el, "slot", open ? el.id : null);
|
|
99
|
+
if (open) popup.setContent(tag("slot", { name: el.id }));
|
|
96
100
|
}
|
|
97
|
-
|
|
101
|
+
#skipClick(event) {
|
|
102
|
+
if (event.type === "click") SKIP_CLICK && event.stopPropagation?.();
|
|
103
|
+
else if (document.body.classList.contains("leaflet-dragging"))
|
|
104
|
+
SKIP_CLICK = setTimeout(() => {
|
|
105
|
+
SKIP_CLICK = 0;
|
|
106
|
+
}, 50);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
defineElement("mtds-atlas", MTDSAtlasElement);
|
|
98
110
|
export {
|
|
99
|
-
|
|
100
|
-
|
|
111
|
+
L,
|
|
112
|
+
MTDSAtlasElement,
|
|
113
|
+
MTDSAtlasMarkerElement,
|
|
114
|
+
MTDSAtlasMatgeoElement
|
|
101
115
|
};
|
|
102
116
|
//# 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\";\nimport type * as ReactTypes from \"react\";\nimport css from \"./atlas.css?raw\";\nimport \"./cluster.js\";\nimport {\n\tattr,\n\tdebounce,\n\tIS_BROWSER,\n\tMTDSElement,\n\ton,\n\tonResize,\n\ttag,\n} from \"../utils\";\nexport { L };\n\ndeclare global {\n\tnamespace React.JSX {\n\t\tinterface IntrinsicElements {\n\t\t\t\"mtds-atlas\": ReactTypes.DetailedHTMLProps<\n\t\t\t\tReactTypes.HTMLAttributes<MTDSAtlasElement>,\n\t\t\t\tMTDSAtlasElement\n\t\t\t> & {\n\t\t\t\tclass?: string;\n\t\t\t\t\"data-cluster\"?: number | `${number}` | boolean | \"true\" | \"false\";\n\t\t\t\t\"data-scrollzoom\"?: boolean | \"true\" | \"false\";\n\t\t\t\t\"data-tiles\"?: \"color\" | \"gray\";\n\t\t\t\t\"data-view\"?: string | number[];\n\t\t\t};\n\t\t}\n\t}\n}\n\nconst ICON_SIZE = [30, 30] as L.PointTuple;\nconst MAX_ZOOM = 18; // Kartverket does not support more than zoom level 18\nconst NORWAY: L.LatLngBoundsLiteral = [\n\t[57.5, 4.73],\n\t[71.5, 31.44],\n];\n\n// Turns out Kartverket's color tiles are better in grayscale than their grayscale tiles\nconst TILES_COLOR =\n\t\"https://cache.kartverket.no/v1/wmts/1.0.0/topo/default/webmercator/{z}/{y}/{x}.png\";\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\"]; //TODO: \"data-layers\" // Using ES2015 syntax for backwards compatibility\n\t}\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.attachShadow({ mode: \"open\" }).append(\n\t\t\ttag(\"style\", {}, `@layer leaflet{${LeafletCSS}}\\n${css}`),\n\t\t\ttag(\"slot\"),\n\t\t\ttag(\"div\"),\n\t\t);\n\t}\n\tconnectedCallback() {\n\t\tconst div = this.shadowRoot?.lastElementChild;\n\t\tconst cluster = attr(this, \"data-cluster\") ?? \"false\";\n\t\tconst tiles = new L.TileLayer(TILES_COLOR, {\n\t\t\tattribution: \"© Kartverket\",\n\t\t\tmaxZoom: MAX_ZOOM,\n\t\t});\n\n\t\tthis.map = new L.Map(div as HTMLElement, {\n\t\t\tattributionControl: false,\n\t\t\twheelPxPerZoomLevel: 20,\n\t\t\tzoomControl: false,\n\t\t\tzoomSnap: 0,\n\t\t\tlayers: [tiles],\n\t\t});\n\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) || MAX_ZOOM,\n\t\t\ticonCreateFunction: (cluster) =>\n\t\t\t\tnew L.DivIcon({\n\t\t\t\t\tclassName: \"leaflet-cluster-icon\",\n\t\t\t\t\thtml: `${cluster.getAllChildMarkers().length}`,\n\t\t\t\t\ticonSize: ICON_SIZE,\n\t\t\t\t}),\n\t\t}).addTo(this.map);\n\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\", handlePopupById);\n\n\t\t// Initial setup when map is connected\n\t\tMTDSAtlasElement.observedAttributes.forEach((name) => {\n\t\t\tthis.attributeChangedCallback(name, null, attr(this, name));\n\t\t});\n\t}\n\tattributeChangedCallback(\n\t\tname: string,\n\t\t_prev: string | null = null,\n\t\tnext: string | null = null,\n\t) {\n\t\tif (!this.map) return; // No map yet\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[], options?: L.ZoomPanOptions) {\n\t\tconst pos = `${view}`.split(\",\").map(parseFloat).filter(Number.isFinite);\n\t\tconst bounds = this.cluster?.getBounds();\n\n\t\tif (pos.length === 3) this.map?.setView([pos[0], pos[1]], pos[2], options);\n\t\telse if (view !== \"fit\") this.map?.fitBounds(NORWAY, options);\n\t\telse if (!bounds?.isValid())\n\t\t\tthis.cluster?.on(\"layeradd\", fitWhenMarkers, this);\n\t\telse this.map?.fitBounds(bounds, options || { padding: ICON_SIZE });\n\t}\n\taddMarker(latlng: L.LatLngExpression, options?: L.MarkerOptions) {\n\t\treturn new L.Marker(latlng, options).addTo(\n\t\t\tthis.cluster as L.MarkerClusterGroup,\n\t\t);\n\t}\n\tdisconnectedCallback() {\n\t\tthis.map?.off(\"popupopen\", handlePopupById);\n\t\tthis.map?.remove();\n\t}\n}\n\nif (IS_BROWSER && !window.customElements.get(\"mtds-atlas\")) {\n\t// Fix accessibility\n\tconst onAddOriginal = L.Marker.prototype.onAdd;\n\tL.Marker.prototype.onAdd = function (...args) {\n\t\tonAddOriginal.apply(this, args);\n\t\tconst el = this.getElement();\n\t\tif (el) attr(el, \"aria-label\", this.options.title || null);\n\t\tif (el) attr(el, \"title\", null);\n\t\treturn this;\n\t};\n\n\t// Set defaults\n\tL.Tooltip.prototype.options.direction = \"top\";\n\tL.Marker.prototype.options.icon = new L.DivIcon({\n\t\thtml: '<svg viewBox=\"0 0 256 256\"><rect x=\"78\" y=\"50\" width=\"100\" height=\"100\" /><path d=\"M128,16a88.1,88.1,0,0,0-88,88c0,75.3,80,132.17,83.41,134.55a8,8,0,0,0,9.18,0C136,236.17,216,179.3,216,104A88.1,88.1,0,0,0,128,16Zm0,56a32,32,0,1,1-32,32A32,32,0,0,1,128,72Z\"/></svg>',\n\t\ticonSize: ICON_SIZE,\n\t\ticonAnchor: [15, 30],\n\t\tpopupAnchor: [0, -15],\n\t\ttooltipAnchor: [0, -30],\n\t});\n\n\t// Define custom element\n\twindow.customElements.define(\"mtds-atlas\", MTDSAtlasElement);\n}\n\n// TODO: Style markers\n// TODO: Synlig label til marker\n// TODO: Add minimum zoom level for adding markers (minimum 17 som standard?)\n// TODO: data-layers: https://matgeoservice-256616427209.europe-north1.run.app/ogc/features/collections\n\nconst fitWhenMarkers = debounce(function (this: MTDSAtlasElement) {\n\tthis.cluster?.off(\"layeradd\", fitWhenMarkers, this);\n\tif (this.cluster?.getBounds().isValid()) this.setView(\"fit\");\n}, 100);\n\nconst HANDLE_POPUP_EVENTS = \"popupclose move resize zoom viewreset\";\nconst handlePopupById = ({ target: map, popup }: L.LeafletEvent) => {\n\tconst id = popup.getContent();\n\tconst popover = String(id)[0] === \"#\" && document.getElementById(id.slice(1));\n\n\tif (!!popover && popover.closest(\"mtds-atlas\")) {\n\t\tconst latlng = popup.getLatLng();\n\t\tconst mode = attr(popover, \"popover\"); // Save current popover mode\n\t\tattr(popup.getElement(), \"hidden\", \"\"); // Hide Leaflet popup element\n\t\tattr(popover, \"popover\", null); // Disable Popover API to show and ensure overflow: clip on mtds-atlas works\n\n\t\tconst update = (event?: L.LeafletEvent) => {\n\t\t\tif (event?.type === \"popupclose\" && event?.popup === popup) {\n\t\t\t\tmap.off(HANDLE_POPUP_EVENTS, update);\n\t\t\t\tattr(popup.getElement(), \"hidden\", null); // Un-hide Leaflet popup element\n\t\t\t\tattr(popover, \"data-popover\", null); // Hide popover\n\t\t\t\tattr(popover, \"popover\", mode); // Re-enable Popover API\n\t\t\t\tunresize();\n\t\t\t\tunclick();\n\t\t\t} else {\n\t\t\t\tconst point = map.latLngToContainerPoint(latlng);\n\t\t\t\tconst x = point.x - popover.offsetWidth / 2;\n\t\t\t\tconst y = point.y - popover.offsetHeight - ICON_SIZE[1];\n\t\t\t\tpopover.style.translate = `${x}px ${y}px`;\n\t\t\t}\n\t\t};\n\n\t\tconst unresize = onResize(() => update(), popover);\n\t\tconst unclick = on(popover, \"click\", (e: Event) => {\n\t\t\tif ((e.target as Element)?.closest?.('[popovertargetaction=\"hide\"]'))\n\t\t\t\tpopup.close(); // Listen for close actions inside popover since we are not using actual Popover API\n\t\t});\n\n\t\tmap.on(HANDLE_POPUP_EVENTS, update);\n\t\tupdate(); // Initial position\n\t}\n};\n\n// export type Adresse = {\n// \tadressekode: number;\n// \tadressetekst: string;\n// \tbokstav: string;\n// \tbruksenhetsnummer: string[];\n// \tbruksnummer: number;\n// \tfestenummer: number;\n// \tgardsnummer: number;\n// \tkommunenavn: string;\n// \tkommunenummer: string;\n// \tnummer: number;\n// \tobjtype: string;\n// \toppdateringsdato: string;\n// \tpostnummer: string;\n// \tpoststed: string;\n// \trepresentasjonspunkt: {\n// \t\tepsg: string;\n// \t\tlat: number;\n// \t\tlon: number;\n// \t};\n// \tstedfestingverifisert: boolean;\n// \tundernummer: string | null;\n// };\n\n// type GeoNorgeAdresser = {\n// \tmetadata: {\n// \t\tside: number;\n// \t\tviserFra: number;\n// \t\ttotaltAntallTreff: number;\n// \t\tasciiKompatibel: boolean;\n// \t\ttreffPerSide: number;\n// \t\tviserTil: number;\n// \t\tsokeStreng: string;\n// \t};\n// \tadresser: {\n// \t\tadressenavn: string;\n// \t\tadressetekst: string;\n// \t\tadressetilleggsnavn: string | null;\n// \t\tadressekode: number;\n// \t\tnummer: number;\n// \t\tbokstav: string;\n// \t\tkommunenummer: string;\n// \t\tkommunenavn: string;\n// \t\tgardsnummer: number;\n// \t\tbruksnummer: number;\n// \t\tfestenummer: number;\n// \t\tundernummer: string | null;\n// \t\tbruksenhetsnummer: (string | null)[];\n// \t\tobjtype: string;\n// \t\tpoststed: string;\n// \t\tpostnummer: string;\n// \t\tadressetekstutenadressetilleggsnavn: string;\n// \t\tstedfestingverifisert: boolean;\n// \t\toppdateringsdato: string;\n// \t\trepresentasjonspunkt: {\n// \t\t\tepsg: string;\n// \t\t\tlat: number;\n// \t\t\tlon: number;\n// \t\t};\n// \t}[];\n// };\n\n// // Hent punkt for adresse fra GeoNorge\n// const toUrlQuery = (obj: Record<string, unknown>) =>\n// \tnew URLSearchParams(\n// \t\tObject.fromEntries(Object.entries(obj).map(([k, v]) => [k, `${v}`])),\n// \t).toString();\n\n// export const getGeoNorgeAdresser = async (params: {\n// \tadressekode?: number;\n// \tadressenavn?: string;\n// \tadressetekst?: string;\n// \tadressetilleggsnavn?: string;\n// \tasciiKompatibel?: boolean;\n// \tbokstav?: string;\n// \tbruksenhetsnummer?: string;\n// \tbruksnummer?: number;\n// \tfestenummer?: number;\n// \tfiltrer?: string;\n// \tfuzzy?: boolean;\n// \tgardsnummer?: number;\n// \tkommunenavn?: string;\n// \tkommunenummer?: number;\n// \tnummer?: number;\n// \tobjtype?: \"Vegadresse\" | \"Matrikkeladresse\";\n// \tpostnummer?: string;\n// \tpoststed?: string;\n// \tside?: number;\n// \tsok?: string;\n// \tsokemodus?: \"AND\" | \"OR\";\n// \ttreffPerSide?: number;\n// \tundernummer?: string;\n// \tutkoordsys?: number;\n// }): Promise<GeoNorgeAdresser | undefined> =>\n// \tfetch(\n// \t\t`https://ws.geonorge.no/adresser/v1/sok?${toUrlQuery({\n// \t\t\tasciiKompatibel: true,\n// \t\t\tfuzzy: true,\n// \t\t\tside: 0,\n// \t\t\ttreffPerSide: 10,\n// \t\t\tutkoordsys: 4326,\n// \t\t\t...params,\n// \t\t})}`,\n// \t)\n// \t\t.then((res) => res.json())\n// \t\t.catch((error) =>\n// \t\t\tconsole.log(`Feilet i å hente adresse fra punkt: ${error}`),\n// \t\t);\n"],"names":["ICON_SIZE","MAX_ZOOM","NORWAY","TILES_COLOR","MTDSAtlasElement","MTDSElement","tag","LeafletCSS","css","div","cluster","attr","tiles","L","handlePopupById","name","_prev","next","view","options","pos","bounds","fitWhenMarkers","latlng","IS_BROWSER","onAddOriginal","args","el","debounce","HANDLE_POPUP_EVENTS","map","popup","id","popover","mode","update","event","unresize","unclick","point","x","onResize","on","e"],"mappings":";;;;;AAkCA,MAAMA,IAAY,CAAC,IAAI,EAAE,GACnBC,IAAW,IACXC,IAAgC;AAAA,EACrC,CAAC,MAAM,IAAI;AAAA,EACX,CAAC,MAAM,KAAK;AACb,GAGMC,IACL;AAEM,MAAMC,UAAyBC,EAAY;AAAA,EACjD;AAAA,EACA;AAAA,EAEA,WAAW,qBAAqB;AAC/B,WAAO,CAAC,aAAa,iBAAiB;AAAA,EACvC;AAAA,EAEA,cAAc;AACb,UAAA,GACA,KAAK,aAAa,EAAE,MAAM,OAAA,CAAQ,EAAE;AAAA,MACnCC,EAAI,SAAS,CAAA,GAAI,kBAAkBC,CAAU;AAAA,EAAMC,CAAG,EAAE;AAAA,MACxDF,EAAI,MAAM;AAAA,MACVA,EAAI,KAAK;AAAA,IAAA;AAAA,EAEX;AAAA,EACA,oBAAoB;AACnB,UAAMG,IAAM,KAAK,YAAY,kBACvBC,IAAUC,EAAK,MAAM,cAAc,KAAK,SACxCC,IAAQ,IAAIC,EAAE,UAAUV,GAAa;AAAA,MAC1C,aAAa;AAAA,MACb,SAASF;AAAA,IAAA,CACT;AAED,SAAK,MAAM,IAAIY,EAAE,IAAIJ,GAAoB;AAAA,MACxC,oBAAoB;AAAA,MACpB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C5D,GAAG,GAAG,GAEAO,IAAsB,yCACtBf,IAAkB,CAAC,EAAE,QAAQgB,GAAK,OAAAC,QAA4B;AACnE,QAAMC,IAAKD,EAAM,WAAA,GACXE,IAAU,OAAOD,CAAE,EAAE,CAAC,MAAM,OAAO,SAAS,eAAeA,EAAG,MAAM,CAAC,CAAC;AAE5E,MAAMC,KAAWA,EAAQ,QAAQ,YAAY,GAAG;AAC/C,UAAMV,IAASQ,EAAM,UAAA,GACfG,IAAOvB,EAAKsB,GAAS,SAAS;AACpC,IAAAtB,EAAKoB,EAAM,cAAc,UAAU,EAAE,GACrCpB,EAAKsB,GAAS,WAAW,IAAI;AAE7B,UAAME,IAAS,CAACC,MAA2B;AAC1C,UAAIA,GAAO,SAAS,gBAAgBA,GAAO,UAAUL;AACpD,QAAAD,EAAI,IAAID,GAAqBM,CAAM,GACnCxB,EAAKoB,EAAM,cAAc,UAAU,IAAI,GACvCpB,EAAKsB,GAAS,gBAAgB,IAAI,GAClCtB,EAAKsB,GAAS,WAAWC,CAAI,GAC7BG,EAAA,GACAC,EAAA;AAAA,WACM;AACN,cAAMC,IAAQT,EAAI,uBAAuBP,CAAM,GACzCiB,IAAID,EAAM,IAAIN,EAAQ,cAAc,GACpC,IAAIM,EAAM,IAAIN,EAAQ,eAAejC,EAAU,CAAC;AACtD,QAAAiC,EAAQ,MAAM,YAAY,GAAGO,CAAC,MAAM,CAAC;AAAA,MACtC;AAAA,IACD,GAEMH,IAAWI,EAAS,MAAMN,EAAA,GAAUF,CAAO,GAC3CK,IAAUI,EAAGT,GAAS,SAAS,CAACU,MAAa;AAClD,MAAKA,EAAE,QAAoB,UAAU,8BAA8B,KAClEZ,EAAM,MAAA;AAAA,IACR,CAAC;AAED,IAAAD,EAAI,GAAGD,GAAqBM,CAAM,GAClCA,EAAA;AAAA,EACD;AACD;"}
|
|
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 { attr, defineElement, MTDSElement, off, on, tag } from \"../utils\";\nimport css from \"./atlas.css?raw\";\nexport { L };\nexport { MTDSAtlasMarkerElement } from \"./atlas-marker\";\nexport { MTDSAtlasMatgeoElement } from \"./atlas-matgeo\";\n\n// TODO: Add minimum zoom level for adding markers (minimum 17 som standard?)\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t\"mtds-atlas\": MTDSAtlasElement;\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\";\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(\n\t\t\ttag(\n\t\t\t\t\"style\",\n\t\t\t\t{},\n\t\t\t\t`@layer leaflet{${LeafletCSS}}\\n@layer mt.design{${css}`,\n\t\t\t),\n\t\t\ttag(\"figure\"),\n\t\t);\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\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: [30, 30],\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\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: 9999 });\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"],"names":["cluster"],"mappings":";;;;;;;AAkBA,IAAI,aAAsC;AAC1C,MAAM,sBAAsB;AAC5B,MAAM,uBACL;AACD,MAAM,gBAAuC;AAAA,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AAS;AACtB,UAAM,OAAO,MAAM,WAAA,GAAc,cAAc,wBAAwB;AACvE,UAAM,OAAO,MAAM,cAA+B,eAAe;AACjE,UAAM,KAAK,MAAM,aAAa,MAAM,SAAS,IAAI,CAAC,KAAK;AACvD,UAAM,KAAK,SAAS,eAAe,MAAM,QAAQ,EAAE;AAEnD,QAAI,CAAC,GAAI,QAAO,QAAQ,MAAM,MAAM,MAAA;AACpC,MAAE,KAAK,WAAW,OAAO,EAAE,UAAU,MAAM;AAC3C,SAAK,IAAI,gBAAgB,OAAO,KAAK,IAAI,SAAS,IAAI,IAAI;AAC1D,SAAK,IAAI,WAAW,OAAO,OAAO,KAAK,IAAI,cAAc,CAAC;AAC1D,SAAK,IAAI,QAAQ,OAAO,GAAG,KAAK,IAAI;AACpC,QAAI,KAAM,OAAM,WAAW,IAAI,QAAQ,EAAE,MAAM,GAAG,GAAA,CAAI,CAAC;AAAA,EACxD;AAAA,EACA,WAAW,OAA4B;AACtC,QAAI,MAAM,SAAS,QAAS,eAAc,MAAM,kBAAA;AAAA,aACvC,SAAS,KAAK,UAAU,SAAS,kBAAkB;AAC3D,mBAAa,WAAW,MAAM;AAC7B,qBAAa;AAAA,MACd,GAAG,EAAE;AAAA,EACP;AACD;AAEA,cAAc,cAAc,gBAAgB;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { default as L } from 'leaflet';
|
|
2
|
+
import { MTDSElement } from '../utils';
|
|
3
|
+
import { MTDSAtlasElement } from './atlas-element';
|
|
4
|
+
declare global {
|
|
5
|
+
interface HTMLElementTagNameMap {
|
|
6
|
+
"mtds-atlas-marker": MTDSAtlasMarkerElement;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export declare class MTDSAtlasMarkerElement extends MTDSElement {
|
|
10
|
+
#private;
|
|
11
|
+
atlas?: MTDSAtlasElement;
|
|
12
|
+
marker?: L.Marker;
|
|
13
|
+
static get observedAttributes(): string[];
|
|
14
|
+
connectedCallback(): void;
|
|
15
|
+
attributeChangedCallback(name: string): void;
|
|
16
|
+
disconnectedCallback(): void;
|
|
17
|
+
handleEvent(event: KeyboardEvent): L.Marker<any> | undefined;
|
|
18
|
+
get latlng(): string;
|
|
19
|
+
set latlng(latlng: string);
|
|
20
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import L from "../external/leaflet/dist/leaflet-src.js";
|
|
2
|
+
import { defineElement, MTDSElement, tag, attr, on, off } from "../utils.js";
|
|
3
|
+
let SLOT = 0;
|
|
4
|
+
class MTDSAtlasMarkerElement extends MTDSElement {
|
|
5
|
+
atlas;
|
|
6
|
+
marker;
|
|
7
|
+
static get observedAttributes() {
|
|
8
|
+
return ["draggable", "data-latlng", "popovertarget"];
|
|
9
|
+
}
|
|
10
|
+
connectedCallback() {
|
|
11
|
+
queueMicrotask(() => {
|
|
12
|
+
const html = tag("slot", { name: `${++SLOT}` });
|
|
13
|
+
const icon = new L.DivIcon({ html, iconSize: [0, 0] });
|
|
14
|
+
this.atlas = this.closest("mtds-atlas") || void 0;
|
|
15
|
+
this.marker = new L.Marker(this.#parseLatLng(), {
|
|
16
|
+
draggable: this.draggable,
|
|
17
|
+
keyboard: false,
|
|
18
|
+
icon
|
|
19
|
+
});
|
|
20
|
+
this.marker.bindPopup(() => `#${attr(this, "popovertarget")}`);
|
|
21
|
+
this.marker.on("dragend", this.#handleDragEnd);
|
|
22
|
+
on(this, "click,keydown", this);
|
|
23
|
+
attr(this, "slot", `${SLOT}`);
|
|
24
|
+
attr(this, "role", "button");
|
|
25
|
+
attr(this, "tabindex", "0");
|
|
26
|
+
this.atlas?.cluster?.addLayer(this.marker);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
attributeChangedCallback(name) {
|
|
30
|
+
if (name === "popovertarget") this.marker?.getPopup()?.update();
|
|
31
|
+
if (name === "data-latlng") {
|
|
32
|
+
const latlng = this.#parseLatLng();
|
|
33
|
+
this.marker?.getLatLng().equals(latlng) || this.marker?.setLatLng(latlng);
|
|
34
|
+
}
|
|
35
|
+
if (name === "draggable")
|
|
36
|
+
this.marker?.dragging?.[this.draggable ? "enable" : "disable"]();
|
|
37
|
+
}
|
|
38
|
+
disconnectedCallback() {
|
|
39
|
+
off(this, "click,keydown", this);
|
|
40
|
+
this.marker?.unbindPopup().off("dragend", this.#handleDragEnd).remove();
|
|
41
|
+
this.marker = this.atlas = void 0;
|
|
42
|
+
}
|
|
43
|
+
handleEvent(event) {
|
|
44
|
+
if (event.type === "click") return this.marker?.fire("click");
|
|
45
|
+
if (event.key === " ") event.preventDefault();
|
|
46
|
+
if (event.key === " " || event.key === "Enter") this.click();
|
|
47
|
+
}
|
|
48
|
+
get latlng() {
|
|
49
|
+
return attr(this, "data-latlng") || "";
|
|
50
|
+
}
|
|
51
|
+
set latlng(latlng) {
|
|
52
|
+
attr(this, "data-latlng", latlng);
|
|
53
|
+
}
|
|
54
|
+
#parseLatLng() {
|
|
55
|
+
return this.latlng?.split(",").map(parseFloat);
|
|
56
|
+
}
|
|
57
|
+
#handleDragEnd(detail) {
|
|
58
|
+
const slot = detail.target._icon?.firstElementChild;
|
|
59
|
+
const self = slot?.assignedElements?.()?.[0];
|
|
60
|
+
const { lat, lng } = detail.target.getLatLng();
|
|
61
|
+
if (self) self.latlng = `${lat},${lng}`;
|
|
62
|
+
self?.dispatchEvent(new CustomEvent("dragend", { detail, bubbles: true }));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
defineElement("mtds-atlas-marker", MTDSAtlasMarkerElement);
|
|
66
|
+
export {
|
|
67
|
+
MTDSAtlasMarkerElement
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=atlas-marker.js.map
|
|
@@ -0,0 +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 [\"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.atlas?.cluster?.addLayer(this.marker);\n\t\t}); // Let the atlas parent initialize first\n\t}\n\tattributeChangedCallback(name: string) {\n\t\tif (name === \"popovertarget\") this.marker?.getPopup()?.update();\n\t\tif (name === \"data-latlng\") {\n\t\t\tconst latlng = this.#parseLatLng();\n\t\t\tthis.marker?.getLatLng().equals(latlng) || this.marker?.setLatLng(latlng);\n\t\t}\n\t\tif (name === \"draggable\")\n\t\t\tthis.marker?.dragging?.[this.draggable ? \"enable\" : \"disable\"]();\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"],"names":[],"mappings":";;AAUA,IAAI,OAAO;AACJ,MAAM,+BAA+B,YAAY;AAAA,EACvD;AAAA,EACA;AAAA,EAEA,WAAW,qBAAqB;AAC/B,WAAO,CAAC,aAAa,eAAe,eAAe;AAAA,EACpD;AAAA,EACA,oBAAoB;AACnB,mBAAe,MAAM;AACpB,YAAM,OAAO,IAAI,QAAQ,EAAE,MAAM,GAAG,EAAE,IAAI,IAAI;AAC9C,YAAM,OAAO,IAAI,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC,GAAG,CAAC,GAAG;AACrD,WAAK,QAAQ,KAAK,QAA0B,YAAY,KAAK;AAC7D,WAAK,SAAS,IAAI,EAAE,OAAO,KAAK,gBAAgB;AAAA,QAC/C,WAAW,KAAK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AE,IAAI,UAAU;AAAA,EAC9C;AAAA,EACA,eAAe,QAAwB;AACtC,UAAM,OAAO,OAAO,OAAO,OACxB;AACH,UAAM,OACL,MAAM,mBAAA,IAAuB,CAAC;AAC/B,UAAM,EAAE,KAAK,IAAA,IAAQ,OAAO,OAAO,UAAA;AACnC,QAAI,KAAM,MAAK,SAAS,GAAG,GAAG,IAAI,GAAG;AACrC,UAAM,cAAc,IAAI,YAAY,WAAW,EAAE,QAAQ,SAAS,KAAA,CAAM,CAAC;AAAA,EAC1E;AACD;AAEA,cAAc,qBAAqB,sBAAsB;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { default as L } from 'leaflet';
|
|
2
|
+
import { MTDSElement } from '../utils';
|
|
3
|
+
import { MTDSAtlasElement } from './atlas-element';
|
|
4
|
+
declare global {
|
|
5
|
+
interface HTMLElementTagNameMap {
|
|
6
|
+
"mtds-atlas-matgeo": MTDSAtlasMatgeoElement;
|
|
7
|
+
}
|
|
8
|
+
interface GlobalEventHandlersEventMap {
|
|
9
|
+
atlasfeatureclick: CustomEvent<Omit<L.LeafletMouseEvent, "target"> & {
|
|
10
|
+
feature: L.Polygon["feature"];
|
|
11
|
+
target: L.Layer;
|
|
12
|
+
}>;
|
|
13
|
+
}
|
|
14
|
+
interface Window {
|
|
15
|
+
_matgeoCollections?: Promise<string[]>;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export declare class MTDSAtlasMatgeoElement extends MTDSElement {
|
|
19
|
+
#private;
|
|
20
|
+
atlas?: MTDSAtlasElement;
|
|
21
|
+
geojson?: L.GeoJSON;
|
|
22
|
+
static get observedAttributes(): string[];
|
|
23
|
+
constructor();
|
|
24
|
+
connectedCallback(): void;
|
|
25
|
+
attributeChangedCallback(name?: string): void;
|
|
26
|
+
disconnectedCallback(): void;
|
|
27
|
+
refresh(nocache?: boolean | L.LeafletEvent): void;
|
|
28
|
+
handleEvent(event: L.LeafletMouseEvent): void;
|
|
29
|
+
}
|