@mattilsynet/design 2.2.30 → 2.3.0
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/analytics/analytics.js +41 -41
- package/mtds/analytics/analytics.js.map +1 -1
- package/mtds/app/app-observer.js +28 -26
- package/mtds/app/app-observer.js.map +1 -1
- package/mtds/app/app.js +13 -12
- package/mtds/app/app.js.map +1 -1
- package/mtds/app/app.stories.d.ts +1 -0
- package/mtds/atlas/atlas-element.js +1 -1
- package/mtds/atlas/atlas-element.js.map +1 -1
- package/mtds/atlas/atlas.css.js +22 -12
- package/mtds/atlas/atlas.css.js.map +1 -1
- package/mtds/atlas.iife.js +25 -15
- package/mtds/button/button.d.ts +6 -1
- package/mtds/button/button.js.map +1 -1
- package/mtds/dialog/dialog-observer.js +38 -22
- package/mtds/dialog/dialog-observer.js.map +1 -1
- package/mtds/dialog/dialog.d.ts +20 -0
- package/mtds/dialog/dialog.js.map +1 -1
- package/mtds/dialog/dialog.stories.d.ts +1 -0
- package/mtds/external/leaflet/dist/leaflet-src.js +7 -7
- package/mtds/external/leaflet/dist/leaflet-src.js.map +1 -1
- package/mtds/field/field-observer.js +31 -35
- package/mtds/field/field-observer.js.map +1 -1
- package/mtds/index.d.ts +1 -0
- package/mtds/index.iife.js +165 -15
- package/mtds/index.js +31 -26
- package/mtds/index.js.map +1 -1
- package/mtds/package.json.js +1 -1
- package/mtds/print/print.css.js +155 -0
- package/mtds/print/print.css.js.map +1 -0
- package/mtds/print/print.stories.d.ts +15 -0
- package/mtds/react-types.d.ts +5 -0
- package/mtds/styles.css +1 -1
- package/mtds/styles.json +43 -43
- package/mtds/styles.module.css.js +44 -44
- package/mtds/table/table-observer.js +8 -8
- package/mtds/table/table-observer.js.map +1 -1
- package/mtds/tailwind.css +1 -2
- package/mtds/toast/toast-helper.js +13 -13
- package/mtds/toast/toast-helper.js.map +1 -1
- package/mtds/toast/toast.js +1 -1
- package/mtds/toast/toast.js.map +1 -1
- package/mtds/utils.d.ts +1 -0
- package/mtds/utils.js +38 -33
- package/mtds/utils.js.map +1 -1
- package/package.json +15 -13
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { onLoaded as w, isBrowser as g, tag as b, on as y, QUICK_EVENT as _, attr as
|
|
3
|
-
const S = `.${
|
|
4
|
-
function
|
|
1
|
+
import d from "../styles.module.css.js";
|
|
2
|
+
import { onLoaded as w, isBrowser as g, tag as b, on as y, QUICK_EVENT as _, attr as s } from "../utils.js";
|
|
3
|
+
const S = `[data-command="toggle-app-expanded"],.${d.app.split(" ")[0]} > [command="show-modal"]`, k = `.${d.breadcrumbs.split(" ")[0]}`, T = `.${d.card.split(" ")[0]}`, u = `.${d.chip.split(" ")[0]}`, v = `.${d.helptext.split(" ")[0]}`, C = `.${d.pagination.split(" ")[0]}`, x = 'summary,u-summary,a,button,[role="tab"],[role="button"]', $ = "click,toggle,submit,change", p = "mattilsynet.matomo.cloud", E = ["setCustomUrl", "setDocumentTitle", "setReferrerUrl"], i = "mtds-analytics-banner", q = "https://www.mattilsynet.no/om-mattilsynet/personvernerklaering/informasjonskapsler";
|
|
4
|
+
function A(o, a = {}) {
|
|
5
5
|
if (g()) {
|
|
6
6
|
if (window._paq || (window._paq = [], window._paq.push(["HeatmapSessionRecording::disable"]), window._paq.push(["enableLinkTracking"]), window._paq.push(["setTrackerUrl", `https://${p}/matomo.php`])), window._mtm || (window._mtm = window._mtm || [], window._mtm.push({ "mtm.startTime": Date.now(), event: "mtm.Start" })), o === "init") {
|
|
7
7
|
window._mtdsTracking = {
|
|
@@ -11,7 +11,7 @@ function E(o, a = {}) {
|
|
|
11
11
|
};
|
|
12
12
|
const { consent: e, enabled: t, matomoId: n, matomoTagManagerId: r } = window._mtdsTracking;
|
|
13
13
|
if (n && window._paq.push(["setSiteId", n]), t) {
|
|
14
|
-
e !== "custom" &&
|
|
14
|
+
e !== "custom" && I();
|
|
15
15
|
const l = r ? `https://cdn.matomo.cloud/${p}/container_${r}.js` : `https://cdn.matomo.cloud/${p}/matomo.js`;
|
|
16
16
|
document.querySelector(`script[src="${l}"]`) || document.head.append(b("script", { async: "", src: l }));
|
|
17
17
|
}
|
|
@@ -39,62 +39,62 @@ function E(o, a = {}) {
|
|
|
39
39
|
window._paq.push(["trackSiteSearch", e, t, n]);
|
|
40
40
|
} else if (o === "matomo") {
|
|
41
41
|
const e = a;
|
|
42
|
-
|
|
42
|
+
E.includes(e?.[0]) && typeof e[1] != "string" && (e[1] = `${e[1] ?? ""}`), window._paq.push(e);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
function
|
|
48
|
-
if (document.getElementById(
|
|
47
|
+
function I() {
|
|
48
|
+
if (document.getElementById(i) || window.localStorage.getItem(i)) return;
|
|
49
49
|
document.body.insertAdjacentHTML(
|
|
50
50
|
"afterbegin",
|
|
51
|
-
`<dialog id="${
|
|
52
|
-
#${
|
|
53
|
-
#${
|
|
54
|
-
#${
|
|
55
|
-
#${
|
|
56
|
-
#${
|
|
57
|
-
#${
|
|
51
|
+
`<dialog id="${i}" data-analytics="ignore"><style>
|
|
52
|
+
#${i}[open] { box-sizing: border-box; display: flex; align-items: center; background: #116e6b; border-radius: .5em; border: 0; box-shadow: 0 .25em .5em rgba(0,0,0,.3); color: #fff; font-size: .875em; inset: auto auto 1em 1em; max-width: calc(100vw - 2em); outline: 0; padding: .5em; position: fixed; z-index: 99999 }
|
|
53
|
+
#${i} button { all: unset; box-sizing: border-box; cursor: pointer; display: flex; width: 1.5em; height: 1.5em; font: 300 1.5em/1.35 sans-serif; border-radius: .25em; place-content: center; transition: .2s; transition-property: background, scale }
|
|
54
|
+
#${i} button:focus-visible { outline: 2px solid }
|
|
55
|
+
#${i} button:hover { background: #0a4e4f }
|
|
56
|
+
#${i} button:active { background: #054449; scale: .9 }
|
|
57
|
+
#${i} p { margin: 0 .25em }
|
|
58
58
|
</style>
|
|
59
59
|
<p>Vi bruker <a href="${q}" target="_blank">informasjonskapsler</a> for å forbedre brukeropplevelsen.</p>
|
|
60
60
|
<form method="dialog" data-analytics="ignore"><button type="submit" aria-label="OK">×</button></form>
|
|
61
61
|
</dialog>`
|
|
62
62
|
);
|
|
63
|
-
const a = document.getElementById(
|
|
63
|
+
const a = document.getElementById(i), e = () => window.localStorage.setItem(i, "seen");
|
|
64
64
|
a.addEventListener("close", e, { once: !0 }), a.show();
|
|
65
65
|
}
|
|
66
|
-
function
|
|
67
|
-
window._mtdsTracking?.enabled && setTimeout(
|
|
66
|
+
function M(o) {
|
|
67
|
+
window._mtdsTracking?.enabled && setTimeout(B, 0, o);
|
|
68
68
|
}
|
|
69
|
-
function
|
|
69
|
+
function B({ type: o, target: a }) {
|
|
70
70
|
const e = o === "click" ? a?.closest?.(x) : a;
|
|
71
71
|
if (!(e instanceof Element) || e.closest('[data-analytics="ignore"]'))
|
|
72
72
|
return;
|
|
73
|
-
let t = "click", n = "Button", r = f(e) ||
|
|
73
|
+
let t = "click", n = "Button", r = f(e) || U(e) || s(e, "data-tooltip") || "";
|
|
74
74
|
if (o === "submit")
|
|
75
75
|
n = "Form", t = "submit", r = r || document.title;
|
|
76
76
|
else if (o === "toggle") {
|
|
77
77
|
if (!e.matches("dialog:modal")) return;
|
|
78
78
|
n = "Dialog", t = "open";
|
|
79
79
|
} else if (o === "change") {
|
|
80
|
-
const l =
|
|
81
|
-
n = e.closest(u) ? "Chip" : "Form", t = "change", r = f(c || e) ||
|
|
82
|
-
} else if (
|
|
80
|
+
const l = s(e, "type"), c = l === "checkbox" || l === "radio" ? e.closest("fieldset") : null;
|
|
81
|
+
n = e.closest(u) ? "Chip" : "Form", t = "change", r = f(c || e) || m(c?.querySelector("legend")) || m(e?.labels?.[0]);
|
|
82
|
+
} else if (s(e, "role") === "tab")
|
|
83
83
|
n = "Tab", t = "navigate";
|
|
84
|
-
else if (
|
|
85
|
-
if (!
|
|
86
|
-
n = e.closest(
|
|
84
|
+
else if (s(e, "popovertarget")) {
|
|
85
|
+
if (!L(e)?.matches(":popover-open")) return;
|
|
86
|
+
n = e.closest(v) ? "HelpText" : "Popover", t = "open";
|
|
87
87
|
} else if (e.nodeName.endsWith("SUMMARY")) {
|
|
88
88
|
if (!e.parentElement.open) return;
|
|
89
89
|
n = "Details", t = "open";
|
|
90
|
-
} else if (
|
|
91
|
-
const l =
|
|
92
|
-
n = "Sidebar", t = l ? "expand" : "minimize", r = l &&
|
|
93
|
-
} else if (e.closest(
|
|
90
|
+
} else if (e.matches(S)) {
|
|
91
|
+
const l = N(e, "--mtds-tooltip-position") === "none";
|
|
92
|
+
n = "Sidebar", t = l ? "expand" : "minimize", r = l && s(e, "data-tooltip") || m(e);
|
|
93
|
+
} else if (e.closest(k))
|
|
94
94
|
n = "Breadcrumbs", t = "navigate";
|
|
95
|
-
else if (e.closest(
|
|
95
|
+
else if (e.closest(C))
|
|
96
96
|
n = "Pagintation", t = "navigate";
|
|
97
|
-
else if (e.closest(
|
|
97
|
+
else if (e.closest(T))
|
|
98
98
|
n = "Card", t = e instanceof HTMLAnchorElement ? "navigate" : "click";
|
|
99
99
|
else if (e.closest(u))
|
|
100
100
|
n = "Chip", t = e.hasAttribute("data-removable") ? "remove" : "click";
|
|
@@ -103,21 +103,21 @@ function M({ type: o, target: a }) {
|
|
|
103
103
|
else if (e instanceof HTMLAnchorElement)
|
|
104
104
|
n = "Link", t = e.protocol === "mailto:" ? "email" : "navigate", e.hasAttribute("download") ? t = "download" : e.hash && e.href.startsWith(location.href.split("#")[0]) && (t = "anchor");
|
|
105
105
|
else if (e.hasAttribute("aria-expanded")) {
|
|
106
|
-
if (
|
|
106
|
+
if (s(e, "aria-expanded") !== "true") return;
|
|
107
107
|
n = "Expand", t = "open";
|
|
108
108
|
} else e.nodeName.startsWith("MTDS-ATLAS-") && (n = "Map Marker", t = "open");
|
|
109
|
-
|
|
110
|
-
category:
|
|
111
|
-
action:
|
|
112
|
-
name:
|
|
109
|
+
A("event", {
|
|
110
|
+
category: s(e, "data-analytics-category") ?? n,
|
|
111
|
+
action: s(e, "data-analytics-action") ?? t,
|
|
112
|
+
name: s(e, "data-analytics-name") ?? r
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
|
-
const
|
|
116
|
-
const a =
|
|
115
|
+
const m = (o) => o?.textContent?.trim() || "", f = (o) => o && s(o, "aria-label") || "", L = (o) => document.getElementById(s(o, "popovertarget") || ""), N = (o, a) => window.getComputedStyle(o).getPropertyValue(a)?.trim(), U = (o) => {
|
|
116
|
+
const a = m(o), e = m(o.querySelector("h1,h2,h3,h4,h5,h6"));
|
|
117
117
|
return a.startsWith(e) && e || a.slice(0, 100).trim();
|
|
118
118
|
};
|
|
119
|
-
w(() => [y(document,
|
|
119
|
+
w(() => [y(document, $, M, _)]);
|
|
120
120
|
export {
|
|
121
|
-
|
|
121
|
+
A as analytics
|
|
122
122
|
};
|
|
123
123
|
//# sourceMappingURL=analytics.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analytics.js","sources":["../../designsystem/analytics/analytics.ts"],"sourcesContent":["import styles from \"../styles.module.css\";\nimport { attr, isBrowser, on, onLoaded, QUICK_EVENT, tag } from \"../utils\";\n\nconst CSS_BREADCRUMBS = `.${styles.breadcrumbs.split(\" \")[0]}`;\nconst CSS_CARD = `.${styles.card.split(\" \")[0]}`;\nconst CSS_CHIP = `.${styles.chip.split(\" \")[0]}`;\nconst CSS_HELPTEXT = `.${styles.helptext.split(\" \")[0]}`;\nconst CSS_PAGINATION = `.${styles.pagination.split(\" \")[0]}`;\nconst CLICKS = `summary,u-summary,a,button,[role=\"tab\"],[role=\"button\"]`;\nconst EVENTS = \"click,toggle,submit,change\";\nconst MATOMO = \"mattilsynet.matomo.cloud\";\nconst MATOMO_STRINGS = [\"setCustomUrl\", \"setDocumentTitle\", \"setReferrerUrl\"];\nconst BANNER = \"mtds-analytics-banner\"; // Dialog to show Matomo script loading\nconst BANNER_URL =\n\t\"https://www.mattilsynet.no/om-mattilsynet/personvernerklaering/informasjonskapsler\";\n\ntype Matomo = (\n\t| string\n\t| number\n\t| boolean\n\t| Document\n\t| Element\n\t| ((this: Record<string, <T>() => T>) => void)\n)[];\ndeclare global {\n\tinterface Window {\n\t\t_paq?: Matomo[];\n\t\t_mtm?: Record<string, string | number>[];\n\t\t_mtdsTracking?: AnalyticsActions[\"init\"];\n\t\t_mtdsUntrack?: () => void;\n\t}\n}\n\nexport type AnalyticsActions = {\n\tinit: {\n\t\tenabled?: boolean | \"debug\";\n\t\tconsent?: \"custom\" | true;\n\t} & (\n\t\t| {\n\t\t\t\tmatomoId: number | string;\n\t\t\t\tmatomoTagManagerId?: never;\n\t\t }\n\t\t| {\n\t\t\t\tmatomoId?: number | string;\n\t\t\t\tmatomoTagManagerId: string;\n\t\t }\n\t);\n\tpageview: {\n\t\turl?: string;\n\t\ttitle?: string;\n\t};\n\tevent: {\n\t\tcategory: string;\n\t\taction: string;\n\t\tname?: string;\n\t\tvalue?: number;\n\t};\n\tsearch: {\n\t\tquery: string;\n\t\tcategory?: string;\n\t\tresults?: number;\n\t};\n\tmatomo: Matomo;\n};\n\nexport function analytics<Action extends keyof AnalyticsActions>(\n\taction: Action,\n\targs = {} as AnalyticsActions[Action],\n) {\n\tif (!isBrowser()) return;\n\tif (!window._paq) {\n\t\twindow._paq = [];\n\t\twindow._paq.push([\"HeatmapSessionRecording::disable\"]); // Disable heatmaps by default as this require cookies\n\t\twindow._paq.push([\"enableLinkTracking\"]);\n\t\twindow._paq.push([\"setTrackerUrl\", `https://${MATOMO}/matomo.php`]);\n\t}\n\tif (!window._mtm) {\n\t\twindow._mtm = window._mtm || []; // Prepare Matomo Tag Manager\n\t\twindow._mtm.push({ \"mtm.startTime\": Date.now(), event: \"mtm.Start\" });\n\t}\n\n\tif (action === \"init\") {\n\t\twindow._mtdsTracking = {\n\t\t\tenabled: window.location.hostname !== \"localhost\",\n\t\t\t...window._mtdsTracking,\n\t\t\t...args,\n\t\t} as AnalyticsActions[\"init\"];\n\t\tconst { consent, enabled, matomoId, matomoTagManagerId } =\n\t\t\twindow._mtdsTracking;\n\n\t\tif (matomoId) window._paq.push([\"setSiteId\", matomoId]);\n\t\tif (enabled) {\n\t\t\tif (consent !== \"custom\") renderBanner();\n\t\t\tconst src = matomoTagManagerId\n\t\t\t\t? `https://cdn.matomo.cloud/${MATOMO}/container_${matomoTagManagerId}.js`\n\t\t\t\t: `https://cdn.matomo.cloud/${MATOMO}/matomo.js`;\n\n\t\t\tdocument.querySelector(`script[src=\"${src}\"]`) ||\n\t\t\t\tdocument.head.append(tag(\"script\", { async: \"\", src }));\n\t\t}\n\t}\n\n\tif (window._mtdsTracking?.enabled === false) return;\n\tif (window._mtdsTracking?.enabled === \"debug\")\n\t\treturn console.info(`analytics ${action}:`, args);\n\n\tif (action === \"pageview\") {\n\t\tconst { url, title } = args as AnalyticsActions[\"pageview\"];\n\t\twindow._paq.push([\"setCustomUrl\", url || location.href]);\n\t\twindow._paq.push([\"setDocumentTitle\", title || document.title]);\n\t\twindow._paq.push([\"trackPageView\"]);\n\t} else if (action === \"event\") {\n\t\tconst { category, action, name, value } = args as AnalyticsActions[\"event\"];\n\t\tconst event = [\"trackEvent\", category, action, name, value];\n\n\t\t// We do not want to track events with hash in URL as this causes hard-to-read data,\n\t\t// so temporarily remove the hash part, and add it back after the event is pushed\n\t\tlet url = location.href;\n\t\twindow._paq.push([\n\t\t\tfunction () {\n\t\t\t\turl = this.getCurrentUrl<string>();\n\t\t\t},\n\t\t]);\n\t\twindow._paq.push([\"setCustomUrl\", url.split(\"#\")[0]]); // Skip hash part of URL\n\t\twindow._paq.push(event.filter((v) => v !== undefined)); // Push event\n\t\twindow._paq.push([\"setCustomUrl\", url]); // Reverrt to original URL with hash\n\t} else if (action === \"search\") {\n\t\tconst {\n\t\t\tquery,\n\t\t\tcategory = false,\n\t\t\tresults = false,\n\t\t} = args as AnalyticsActions[\"search\"];\n\t\twindow._paq.push([\"trackSiteSearch\", query, category, results]);\n\t} else if (action === \"matomo\") {\n\t\tconst props = args as AnalyticsActions[\"matomo\"];\n\t\tconst needStr = MATOMO_STRINGS.includes(props?.[0] as string);\n\t\tif (needStr && typeof props[1] !== \"string\") props[1] = `${props[1] ?? \"\"}`; // Matomo dies if not string\n\t\twindow._paq.push(props);\n\t}\n}\n\nfunction renderBanner() {\n\tconst hasSeenBanner =\n\t\tdocument.getElementById(BANNER) || window.localStorage.getItem(BANNER);\n\n\tif (hasSeenBanner) return;\n\n\tdocument.body.insertAdjacentHTML(\n\t\t\"afterbegin\",\n\t\t`<dialog id=\"${BANNER}\" data-analytics=\"ignore\"><style>\n\t\t\t\t#${BANNER}[open] { box-sizing: border-box; display: flex; align-items: center; background: #116e6b; border-radius: .5em; border: 0; box-shadow: 0 .25em .5em rgba(0,0,0,.3); color: #fff; font-size: .875em; inset: auto auto 1em 1em; max-width: calc(100vw - 2em); outline: 0; padding: .5em; position: fixed; z-index: 99999 }\n\t\t\t\t#${BANNER} button { all: unset; box-sizing: border-box; cursor: pointer; display: flex; width: 1.5em; height: 1.5em; font: 300 1.5em/1.35 sans-serif; border-radius: .25em; place-content: center; transition: .2s; transition-property: background, scale }\n\t\t\t\t#${BANNER} button:focus-visible { outline: 2px solid }\n\t\t\t\t#${BANNER} button:hover { background: #0a4e4f }\n\t\t\t\t#${BANNER} button:active { background: #054449; scale: .9 }\n\t\t\t\t#${BANNER} p { margin: 0 .25em }\n\t\t\t</style>\n\t\t\t<p>Vi bruker <a href=\"${BANNER_URL}\" target=\"_blank\">informasjonskapsler</a> for å forbedre brukeropplevelsen.</p>\n\t\t\t<form method=\"dialog\" data-analytics=\"ignore\"><button type=\"submit\" aria-label=\"OK\">×</button></form>\n\t\t</dialog>`,\n\t);\n\tconst banner = document.getElementById(BANNER) as HTMLDialogElement;\n\tconst onClose = () => window.localStorage.setItem(BANNER, \"seen\");\n\tbanner.addEventListener(\"close\", onClose, { once: true });\n\tbanner.show();\n}\n\nfunction handleAnalyticsTrack(event: Event) {\n\tif (window._mtdsTracking?.enabled) setTimeout(processTrack, 0, event); // Let other events process first\n}\n\nfunction processTrack({ type, target }: Event) {\n\tconst el = type === \"click\" ? (target as Element)?.closest?.(CLICKS) : target;\n\tif (!(el instanceof Element) || el.closest('[data-analytics=\"ignore\"]'))\n\t\treturn;\n\n\tlet action = \"click\";\n\tlet category = \"Button\";\n\tlet name = label(el) || heading(el) || attr(el, \"data-tooltip\") || \"\";\n\n\tif (type === \"submit\") {\n\t\tcategory = \"Form\";\n\t\taction = \"submit\";\n\t\tname = name || document.title;\n\t} else if (type === \"toggle\") {\n\t\tif (!el.matches(\"dialog:modal\")) return; // Skip non-modal dialogs\n\t\tcategory = \"Dialog\";\n\t\taction = \"open\";\n\t} else if (type === \"change\") {\n\t\tconst type = attr(el, \"type\");\n\t\tconst group =\n\t\t\ttype === \"checkbox\" || type === \"radio\" ? el.closest(\"fieldset\") : null;\n\n\t\tcategory = el.closest(CSS_CHIP) ? \"Chip\" : \"Form\";\n\t\taction = \"change\";\n\t\tname =\n\t\t\tlabel(group || el) ||\n\t\t\ttext(group?.querySelector(\"legend\")) ||\n\t\t\ttext((el as HTMLInputElement)?.labels?.[0]);\n\t} else if (attr(el, \"role\") === \"tab\") {\n\t\tcategory = \"Tab\";\n\t\taction = \"navigate\";\n\t} else if (attr(el, \"popovertarget\")) {\n\t\tif (!popover(el)?.matches(\":popover-open\")) return; // Skip if not open\n\t\tcategory = el.closest(CSS_HELPTEXT) ? \"HelpText\" : \"Popover\";\n\t\taction = \"open\";\n\t} else if (el.nodeName.endsWith(\"SUMMARY\")) {\n\t\tif (!(el.parentElement as HTMLDetailsElement).open) return; // Skip if not open\n\t\tcategory = \"Details\";\n\t\taction = \"open\";\n\t} else if (attr(el, \"data-command\") === \"toggle-app-expanded\") {\n\t\tconst open = style(el, \"--mtds-tooltip-position\") === \"none\";\n\t\tcategory = \"Sidebar\";\n\t\taction = open ? \"expand\" : \"minimize\";\n\t\tname = (open && attr(el, \"data-tooltip\")) || text(el);\n\t} else if (el.closest(CSS_BREADCRUMBS)) {\n\t\tcategory = \"Breadcrumbs\";\n\t\taction = \"navigate\";\n\t} else if (el.closest(CSS_PAGINATION)) {\n\t\tcategory = \"Pagintation\";\n\t\taction = \"navigate\";\n\t} else if (el.closest(CSS_CARD)) {\n\t\tcategory = \"Card\";\n\t\taction = el instanceof HTMLAnchorElement ? \"navigate\" : \"click\";\n\t} else if (el.closest(CSS_CHIP)) {\n\t\tcategory = \"Chip\";\n\t\taction = el.hasAttribute(\"data-removable\") ? \"remove\" : \"click\";\n\t} else if (el.closest(\"th[aria-sort]\")) {\n\t\tcategory = \"Table\";\n\t\taction = \"sort\";\n\t} else if (el instanceof HTMLAnchorElement) {\n\t\tcategory = \"Link\";\n\t\taction = el.protocol === \"mailto:\" ? \"email\" : \"navigate\";\n\t\tif (el.hasAttribute(\"download\")) action = \"download\";\n\t\telse if (el.hash && el.href.startsWith(location.href.split(\"#\")[0]))\n\t\t\taction = \"anchor\"; // Only track as anchor if same page\n\t} else if (el.hasAttribute(\"aria-expanded\")) {\n\t\tif (attr(el, \"aria-expanded\") !== \"true\") return; // Skip if not open\n\t\tcategory = \"Expand\";\n\t\taction = \"open\";\n\t} else if (el.nodeName.startsWith(\"MTDS-ATLAS-\")) {\n\t\tcategory = \"Map Marker\";\n\t\taction = \"open\";\n\t}\n\n\t// Respect attributes and send\n\tanalytics(\"event\", {\n\t\tcategory: attr(el, \"data-analytics-category\") ?? category,\n\t\taction: attr(el, \"data-analytics-action\") ?? action,\n\t\tname: attr(el, \"data-analytics-name\") ?? name,\n\t});\n}\n\n// Utilities\nconst text = (el?: Element | null) => el?.textContent?.trim() || \"\";\nconst label = (el?: Element | null) => (el && attr(el, \"aria-label\")) || \"\";\nconst popover = (el: Element) =>\n\tdocument.getElementById(attr(el, \"popovertarget\") || \"\");\nconst style = (el: Element, key: string) =>\n\twindow.getComputedStyle(el).getPropertyValue(key)?.trim();\nconst heading = (el: Element) => {\n\tconst body = text(el);\n\tconst head = text(el.querySelector(\"h1,h2,h3,h4,h5,h6\")); // Note: head might be empty string ''\n\treturn (body.startsWith(head) && head) || body.slice(0, 100).trim(); // Limit to 100 characters\n};\n\nonLoaded(() => [on(document, EVENTS, handleAnalyticsTrack, QUICK_EVENT)]);\n"],"names":["CSS_BREADCRUMBS","styles","CSS_CARD","CSS_CHIP","CSS_HELPTEXT","CSS_PAGINATION","CLICKS","EVENTS","MATOMO","MATOMO_STRINGS","BANNER","BANNER_URL","analytics","action","args","isBrowser","consent","enabled","matomoId","matomoTagManagerId","renderBanner","src","tag","url","title","category","name","value","event","v","query","results","props","banner","onClose","handleAnalyticsTrack","processTrack","type","target","el","label","heading","attr","group","text","popover","open","style","key","body","head","onLoaded","on","QUICK_EVENT"],"mappings":";;AAGA,MAAMA,IAAkB,IAAIC,EAAO,YAAY,MAAM,GAAG,EAAE,CAAC,CAAC,IACtDC,IAAW,IAAID,EAAO,KAAK,MAAM,GAAG,EAAE,CAAC,CAAC,IACxCE,IAAW,IAAIF,EAAO,KAAK,MAAM,GAAG,EAAE,CAAC,CAAC,IACxCG,IAAe,IAAIH,EAAO,SAAS,MAAM,GAAG,EAAE,CAAC,CAAC,IAChDI,IAAiB,IAAIJ,EAAO,WAAW,MAAM,GAAG,EAAE,CAAC,CAAC,IACpDK,IAAS,2DACTC,IAAS,8BACTC,IAAS,4BACTC,IAAiB,CAAC,gBAAgB,oBAAoB,gBAAgB,GACtEC,IAAS,yBACTC,IACL;AAmDM,SAASC,EACfC,GACAC,IAAO,IACN;AACD,MAAKC,KAYL;AAAA,QAXK,OAAO,SACX,OAAO,OAAO,CAAA,GACd,OAAO,KAAK,KAAK,CAAC,kCAAkC,CAAC,GACrD,OAAO,KAAK,KAAK,CAAC,oBAAoB,CAAC,GACvC,OAAO,KAAK,KAAK,CAAC,iBAAiB,WAAWP,CAAM,aAAa,CAAC,IAE9D,OAAO,SACX,OAAO,OAAO,OAAO,QAAQ,CAAA,GAC7B,OAAO,KAAK,KA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AACD,MAAyBA,KAAMG,EAAKH,GAAI,YAAY,KAAM,IACnEM,IAAU,CAACN,MAChB,SAAS,eAAeG,EAAKH,GAAI,eAAe,KAAK,EAAE,GAClDQ,IAAQ,CAACR,GAAaS,MAC3B,OAAO,iBAAiBT,CAAE,EAAE,iBAAiBS,CAAG,GAAG,KAAA,GAC9CP,IAAU,CAACF,MAAgB;AAChC,QAAMU,IAAOL,EAAKL,CAAE,GACdW,IAAON,EAAKL,EAAG,cAAc,mBAAmB,CAAC;AACvD,SAAQU,EAAK,WAAWC,CAAI,KAAKA,KAASD,EAAK,MAAM,GAAG,GAAG,EAAE,KAAA;AAC9D;AAEAE,EAAS,MAAM,CAACC,EAAG,UAAU7C,GAAQ4B,GAAsBkB,CAAW,CAAC,CAAC;"}
|
|
1
|
+
{"version":3,"file":"analytics.js","sources":["../../designsystem/analytics/analytics.ts"],"sourcesContent":["import styles from \"../styles.module.css\";\nimport { attr, isBrowser, on, onLoaded, QUICK_EVENT, tag } from \"../utils\";\n\n/*\n * IMPORTANT: [data-command=\"toggle-app-expanded\"] is deprecated but kept for backward compatibility.\n * Please use [command=\"show-modal\"] instead.\n */\nconst CSS_APP_TOGGLE = `[data-command=\"toggle-app-expanded\"],.${styles.app.split(\" \")[0]} > [command=\"show-modal\"]`;\nconst CSS_BREADCRUMBS = `.${styles.breadcrumbs.split(\" \")[0]}`;\nconst CSS_CARD = `.${styles.card.split(\" \")[0]}`;\nconst CSS_CHIP = `.${styles.chip.split(\" \")[0]}`;\nconst CSS_HELPTEXT = `.${styles.helptext.split(\" \")[0]}`;\nconst CSS_PAGINATION = `.${styles.pagination.split(\" \")[0]}`;\nconst CLICKS = `summary,u-summary,a,button,[role=\"tab\"],[role=\"button\"]`;\nconst EVENTS = \"click,toggle,submit,change\";\nconst MATOMO = \"mattilsynet.matomo.cloud\";\nconst MATOMO_STRINGS = [\"setCustomUrl\", \"setDocumentTitle\", \"setReferrerUrl\"];\nconst BANNER = \"mtds-analytics-banner\"; // Dialog to show Matomo script loading\nconst BANNER_URL =\n\t\"https://www.mattilsynet.no/om-mattilsynet/personvernerklaering/informasjonskapsler\";\n\ntype Matomo = (\n\t| string\n\t| number\n\t| boolean\n\t| Document\n\t| Element\n\t| ((this: Record<string, <T>() => T>) => void)\n)[];\ndeclare global {\n\tinterface Window {\n\t\t_paq?: Matomo[];\n\t\t_mtm?: Record<string, string | number>[];\n\t\t_mtdsTracking?: AnalyticsActions[\"init\"];\n\t\t_mtdsUntrack?: () => void;\n\t}\n}\n\nexport type AnalyticsActions = {\n\tinit: {\n\t\tenabled?: boolean | \"debug\";\n\t\tconsent?: \"custom\" | true;\n\t} & (\n\t\t| {\n\t\t\t\tmatomoId: number | string;\n\t\t\t\tmatomoTagManagerId?: never;\n\t\t }\n\t\t| {\n\t\t\t\tmatomoId?: number | string;\n\t\t\t\tmatomoTagManagerId: string;\n\t\t }\n\t);\n\tpageview: {\n\t\turl?: string;\n\t\ttitle?: string;\n\t};\n\tevent: {\n\t\tcategory: string;\n\t\taction: string;\n\t\tname?: string;\n\t\tvalue?: number;\n\t};\n\tsearch: {\n\t\tquery: string;\n\t\tcategory?: string;\n\t\tresults?: number;\n\t};\n\tmatomo: Matomo;\n};\n\nexport function analytics<Action extends keyof AnalyticsActions>(\n\taction: Action,\n\targs = {} as AnalyticsActions[Action],\n) {\n\tif (!isBrowser()) return;\n\tif (!window._paq) {\n\t\twindow._paq = [];\n\t\twindow._paq.push([\"HeatmapSessionRecording::disable\"]); // Disable heatmaps by default as this require cookies\n\t\twindow._paq.push([\"enableLinkTracking\"]);\n\t\twindow._paq.push([\"setTrackerUrl\", `https://${MATOMO}/matomo.php`]);\n\t}\n\tif (!window._mtm) {\n\t\twindow._mtm = window._mtm || []; // Prepare Matomo Tag Manager\n\t\twindow._mtm.push({ \"mtm.startTime\": Date.now(), event: \"mtm.Start\" });\n\t}\n\n\tif (action === \"init\") {\n\t\twindow._mtdsTracking = {\n\t\t\tenabled: window.location.hostname !== \"localhost\",\n\t\t\t...window._mtdsTracking,\n\t\t\t...args,\n\t\t} as AnalyticsActions[\"init\"];\n\t\tconst { consent, enabled, matomoId, matomoTagManagerId } =\n\t\t\twindow._mtdsTracking;\n\n\t\tif (matomoId) window._paq.push([\"setSiteId\", matomoId]);\n\t\tif (enabled) {\n\t\t\tif (consent !== \"custom\") renderBanner();\n\t\t\tconst src = matomoTagManagerId\n\t\t\t\t? `https://cdn.matomo.cloud/${MATOMO}/container_${matomoTagManagerId}.js`\n\t\t\t\t: `https://cdn.matomo.cloud/${MATOMO}/matomo.js`;\n\n\t\t\tdocument.querySelector(`script[src=\"${src}\"]`) ||\n\t\t\t\tdocument.head.append(tag(\"script\", { async: \"\", src }));\n\t\t}\n\t}\n\n\tif (window._mtdsTracking?.enabled === false) return;\n\tif (window._mtdsTracking?.enabled === \"debug\")\n\t\treturn console.info(`analytics ${action}:`, args);\n\n\tif (action === \"pageview\") {\n\t\tconst { url, title } = args as AnalyticsActions[\"pageview\"];\n\t\twindow._paq.push([\"setCustomUrl\", url || location.href]);\n\t\twindow._paq.push([\"setDocumentTitle\", title || document.title]);\n\t\twindow._paq.push([\"trackPageView\"]);\n\t} else if (action === \"event\") {\n\t\tconst { category, action, name, value } = args as AnalyticsActions[\"event\"];\n\t\tconst event = [\"trackEvent\", category, action, name, value];\n\n\t\t// We do not want to track events with hash in URL as this causes hard-to-read data,\n\t\t// so temporarily remove the hash part, and add it back after the event is pushed\n\t\tlet url = location.href;\n\t\twindow._paq.push([\n\t\t\tfunction () {\n\t\t\t\turl = this.getCurrentUrl<string>();\n\t\t\t},\n\t\t]);\n\t\twindow._paq.push([\"setCustomUrl\", url.split(\"#\")[0]]); // Skip hash part of URL\n\t\twindow._paq.push(event.filter((v) => v !== undefined)); // Push event\n\t\twindow._paq.push([\"setCustomUrl\", url]); // Reverrt to original URL with hash\n\t} else if (action === \"search\") {\n\t\tconst {\n\t\t\tquery,\n\t\t\tcategory = false,\n\t\t\tresults = false,\n\t\t} = args as AnalyticsActions[\"search\"];\n\t\twindow._paq.push([\"trackSiteSearch\", query, category, results]);\n\t} else if (action === \"matomo\") {\n\t\tconst props = args as AnalyticsActions[\"matomo\"];\n\t\tconst needStr = MATOMO_STRINGS.includes(props?.[0] as string);\n\t\tif (needStr && typeof props[1] !== \"string\") props[1] = `${props[1] ?? \"\"}`; // Matomo dies if not string\n\t\twindow._paq.push(props);\n\t}\n}\n\nfunction renderBanner() {\n\tconst hasSeenBanner =\n\t\tdocument.getElementById(BANNER) || window.localStorage.getItem(BANNER);\n\n\tif (hasSeenBanner) return;\n\n\tdocument.body.insertAdjacentHTML(\n\t\t\"afterbegin\",\n\t\t`<dialog id=\"${BANNER}\" data-analytics=\"ignore\"><style>\n\t\t\t\t#${BANNER}[open] { box-sizing: border-box; display: flex; align-items: center; background: #116e6b; border-radius: .5em; border: 0; box-shadow: 0 .25em .5em rgba(0,0,0,.3); color: #fff; font-size: .875em; inset: auto auto 1em 1em; max-width: calc(100vw - 2em); outline: 0; padding: .5em; position: fixed; z-index: 99999 }\n\t\t\t\t#${BANNER} button { all: unset; box-sizing: border-box; cursor: pointer; display: flex; width: 1.5em; height: 1.5em; font: 300 1.5em/1.35 sans-serif; border-radius: .25em; place-content: center; transition: .2s; transition-property: background, scale }\n\t\t\t\t#${BANNER} button:focus-visible { outline: 2px solid }\n\t\t\t\t#${BANNER} button:hover { background: #0a4e4f }\n\t\t\t\t#${BANNER} button:active { background: #054449; scale: .9 }\n\t\t\t\t#${BANNER} p { margin: 0 .25em }\n\t\t\t</style>\n\t\t\t<p>Vi bruker <a href=\"${BANNER_URL}\" target=\"_blank\">informasjonskapsler</a> for å forbedre brukeropplevelsen.</p>\n\t\t\t<form method=\"dialog\" data-analytics=\"ignore\"><button type=\"submit\" aria-label=\"OK\">×</button></form>\n\t\t</dialog>`,\n\t);\n\tconst banner = document.getElementById(BANNER) as HTMLDialogElement;\n\tconst onClose = () => window.localStorage.setItem(BANNER, \"seen\");\n\tbanner.addEventListener(\"close\", onClose, { once: true });\n\tbanner.show();\n}\n\nfunction handleAnalyticsTrack(event: Event) {\n\tif (window._mtdsTracking?.enabled) setTimeout(processTrack, 0, event); // Let other events process first\n}\n\nfunction processTrack({ type, target }: Event) {\n\tconst el = type === \"click\" ? (target as Element)?.closest?.(CLICKS) : target;\n\tif (!(el instanceof Element) || el.closest('[data-analytics=\"ignore\"]'))\n\t\treturn;\n\n\tlet action = \"click\";\n\tlet category = \"Button\";\n\tlet name = label(el) || heading(el) || attr(el, \"data-tooltip\") || \"\";\n\n\tif (type === \"submit\") {\n\t\tcategory = \"Form\";\n\t\taction = \"submit\";\n\t\tname = name || document.title;\n\t} else if (type === \"toggle\") {\n\t\tif (!el.matches(\"dialog:modal\")) return; // Skip non-modal dialogs\n\t\tcategory = \"Dialog\";\n\t\taction = \"open\";\n\t} else if (type === \"change\") {\n\t\tconst type = attr(el, \"type\");\n\t\tconst group =\n\t\t\ttype === \"checkbox\" || type === \"radio\" ? el.closest(\"fieldset\") : null;\n\n\t\tcategory = el.closest(CSS_CHIP) ? \"Chip\" : \"Form\";\n\t\taction = \"change\";\n\t\tname =\n\t\t\tlabel(group || el) ||\n\t\t\ttext(group?.querySelector(\"legend\")) ||\n\t\t\ttext((el as HTMLInputElement)?.labels?.[0]);\n\t} else if (attr(el, \"role\") === \"tab\") {\n\t\tcategory = \"Tab\";\n\t\taction = \"navigate\";\n\t} else if (attr(el, \"popovertarget\")) {\n\t\tif (!popover(el)?.matches(\":popover-open\")) return; // Skip if not open\n\t\tcategory = el.closest(CSS_HELPTEXT) ? \"HelpText\" : \"Popover\";\n\t\taction = \"open\";\n\t} else if (el.nodeName.endsWith(\"SUMMARY\")) {\n\t\tif (!(el.parentElement as HTMLDetailsElement).open) return; // Skip if not open\n\t\tcategory = \"Details\";\n\t\taction = \"open\";\n\t} else if (el.matches(CSS_APP_TOGGLE)) {\n\t\tconst open = style(el, \"--mtds-tooltip-position\") === \"none\";\n\t\tcategory = \"Sidebar\";\n\t\taction = open ? \"expand\" : \"minimize\";\n\t\tname = (open && attr(el, \"data-tooltip\")) || text(el);\n\t} else if (el.closest(CSS_BREADCRUMBS)) {\n\t\tcategory = \"Breadcrumbs\";\n\t\taction = \"navigate\";\n\t} else if (el.closest(CSS_PAGINATION)) {\n\t\tcategory = \"Pagintation\";\n\t\taction = \"navigate\";\n\t} else if (el.closest(CSS_CARD)) {\n\t\tcategory = \"Card\";\n\t\taction = el instanceof HTMLAnchorElement ? \"navigate\" : \"click\";\n\t} else if (el.closest(CSS_CHIP)) {\n\t\tcategory = \"Chip\";\n\t\taction = el.hasAttribute(\"data-removable\") ? \"remove\" : \"click\";\n\t} else if (el.closest(\"th[aria-sort]\")) {\n\t\tcategory = \"Table\";\n\t\taction = \"sort\";\n\t} else if (el instanceof HTMLAnchorElement) {\n\t\tcategory = \"Link\";\n\t\taction = el.protocol === \"mailto:\" ? \"email\" : \"navigate\";\n\t\tif (el.hasAttribute(\"download\")) action = \"download\";\n\t\telse if (el.hash && el.href.startsWith(location.href.split(\"#\")[0]))\n\t\t\taction = \"anchor\"; // Only track as anchor if same page\n\t} else if (el.hasAttribute(\"aria-expanded\")) {\n\t\tif (attr(el, \"aria-expanded\") !== \"true\") return; // Skip if not open\n\t\tcategory = \"Expand\";\n\t\taction = \"open\";\n\t} else if (el.nodeName.startsWith(\"MTDS-ATLAS-\")) {\n\t\tcategory = \"Map Marker\";\n\t\taction = \"open\";\n\t}\n\n\t// Respect attributes and send\n\tanalytics(\"event\", {\n\t\tcategory: attr(el, \"data-analytics-category\") ?? category,\n\t\taction: attr(el, \"data-analytics-action\") ?? action,\n\t\tname: attr(el, \"data-analytics-name\") ?? name,\n\t});\n}\n\n// Utilities\nconst text = (el?: Element | null) => el?.textContent?.trim() || \"\";\nconst label = (el?: Element | null) => (el && attr(el, \"aria-label\")) || \"\";\nconst popover = (el: Element) =>\n\tdocument.getElementById(attr(el, \"popovertarget\") || \"\");\nconst style = (el: Element, key: string) =>\n\twindow.getComputedStyle(el).getPropertyValue(key)?.trim();\nconst heading = (el: Element) => {\n\tconst body = text(el);\n\tconst head = text(el.querySelector(\"h1,h2,h3,h4,h5,h6\")); // Note: head might be empty string ''\n\treturn (body.startsWith(head) && head) || body.slice(0, 100).trim(); // Limit to 100 characters\n};\n\nonLoaded(() => [on(document, EVENTS, handleAnalyticsTrack, QUICK_EVENT)]);\n"],"names":["CSS_APP_TOGGLE","styles","CSS_BREADCRUMBS","CSS_CARD","CSS_CHIP","CSS_HELPTEXT","CSS_PAGINATION","CLICKS","EVENTS","MATOMO","MATOMO_STRINGS","BANNER","BANNER_URL","analytics","action","args","isBrowser","consent","enabled","matomoId","matomoTagManagerId","renderBanner","src","tag","url","title","category","name","value","event","v","query","results","props","banner","onClose","handleAnalyticsTrack","processTrack","type","target","el","label","heading","attr","group","text","popover","open","style","key","body","head","onLoaded","on","QUICK_EVENT"],"mappings":";;AAOA,MAAMA,IAAiB,yCAAyCC,EAAO,IAAI,MAAM,GAAG,EAAE,CAAC,CAAC,6BAClFC,IAAkB,IAAID,EAAO,YAAY,MAAM,GAAG,EAAE,CAAC,CAAC,IACtDE,IAAW,IAAIF,EAAO,KAAK,MAAM,GAAG,EAAE,CAAC,CAAC,IACxCG,IAAW,IAAIH,EAAO,KAAK,MAAM,GAAG,EAAE,CAAC,CAAC,IACxCI,IAAe,IAAIJ,EAAO,SAAS,MAAM,GAAG,EAAE,CAAC,CAAC,IAChDK,IAAiB,IAAIL,EAAO,WAAW,MAAM,GAAG,EAAE,CAAC,CAAC,IACpDM,IAAS,2DACTC,IAAS,8BACTC,IAAS,4BACTC,IAAiB,CAAC,gBAAgB,oBAAoB,gBAAgB,GACtEC,IAAS,yBACTC,IACL;AAmDM,SAASC,EACfC,GACAC,IAAO,IACN;AACD,MAAKC,KAYL;AAAA,QAXK,OAAO,SACX,OAAO,OAAO,CAAA,GACd,OAAO,KAAK,KAAK,CAAC,kCAAkC,CAAC,GACrD,OAAO,KAAK,KAAK,CAAC,oBAAoB,CAAC,GACvC,OA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AKH,GAAI,qBAAqB,KAAKb;AAAA,EAAA,CACzC;AACF;AAGA,MAAMkB,IAAO,CAACL,MAAwBA,GAAI,aAAa,UAAU,IAC3DC,IAAQ,CAACD,MAAyBA,KAAMG,EAAKH,GAAI,YAAY,KAAM,IACnEM,IAAU,CAACN,MAChB,SAAS,eAAeG,EAAKH,GAAI,eAAe,KAAK,EAAE,GAClDQ,IAAQ,CAACR,GAAaS,MAC3B,OAAO,iBAAiBT,CAAE,EAAE,iBAAiBS,CAAG,GAAG,KAAA,GAC9CP,IAAU,CAACF,MAAgB;AAChC,QAAMU,IAAOL,EAAKL,CAAE,GACdW,IAAON,EAAKL,EAAG,cAAc,mBAAmB,CAAC;AACvD,SAAQU,EAAK,WAAWC,CAAI,KAAKA,KAASD,EAAK,MAAM,GAAG,GAAG,EAAE,KAAA;AAC9D;AAEAE,EAAS,MAAM,CAACC,EAAG,UAAU7C,GAAQ4B,GAAsBkB,CAAW,CAAC,CAAC;"}
|
package/mtds/app/app-observer.js
CHANGED
|
@@ -1,38 +1,40 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { isBrowser as
|
|
1
|
+
import w from "../styles.module.css.js";
|
|
2
|
+
import { isBrowser as _, onLoaded as E, on as r, QUICK_EVENT as g, debounce as h } from "../utils.js";
|
|
3
3
|
import "./app-toggle2.js";
|
|
4
|
-
const
|
|
5
|
-
document.startViewTransition ? document.startViewTransition(
|
|
6
|
-
},
|
|
4
|
+
const y = w.app.split(" ")[0], I = w.sticky.split(" ")[0], x = `[data-command="toggle-app-expanded"],.${y} > [command="show-modal"]`, m = `.${y} > dialog,.${y} dialog ~ main`, S = _() ? document.getElementsByClassName(I) : [], C = (e) => {
|
|
5
|
+
document.startViewTransition ? document.startViewTransition(e) : e();
|
|
6
|
+
}, k = (e) => (
|
|
7
7
|
// @ts-expect-error window.mtdsAppToggle comes from app-toggle.js
|
|
8
|
-
C(() => window.mtdsToggleAppExpanded?.(
|
|
8
|
+
C(() => window.mtdsToggleAppExpanded?.(e))
|
|
9
9
|
);
|
|
10
|
-
function
|
|
11
|
-
const
|
|
12
|
-
if (
|
|
13
|
-
return
|
|
14
|
-
if (i || !(
|
|
10
|
+
function A(e) {
|
|
11
|
+
const { target: o, defaultPrevented: i } = e, u = o?.closest?.("a");
|
|
12
|
+
if (u?.closest("dialog") && u?.closest(m))
|
|
13
|
+
return T();
|
|
14
|
+
if (i || !(o instanceof HTMLButtonElement) || !o.matches(x))
|
|
15
15
|
return;
|
|
16
|
-
getComputedStyle(
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
const P = getComputedStyle(o).position === "sticky";
|
|
17
|
+
e.preventDefault(), P ? k() : C(() => {
|
|
18
|
+
const f = document.querySelector(m);
|
|
19
|
+
f?.setAttribute("closedby", "any"), f?.showModal();
|
|
19
20
|
});
|
|
20
21
|
}
|
|
21
|
-
function
|
|
22
|
-
document.querySelector(
|
|
22
|
+
function T() {
|
|
23
|
+
document.querySelector(m)?.close();
|
|
23
24
|
}
|
|
24
|
-
let
|
|
25
|
-
function
|
|
26
|
-
if (!
|
|
27
|
-
const
|
|
28
|
-
|
|
25
|
+
let p = 0, n, t = 0, c = 0, l = 0, d = !1, a = 0, s = 0;
|
|
26
|
+
function H() {
|
|
27
|
+
if (!S?.length) return;
|
|
28
|
+
const e = S[0], o = window.scrollY, i = o < s;
|
|
29
|
+
s = o, i !== n && (p = (e.parentElement?.getBoundingClientRect().top || 0) + s, n = i, c = e.offsetHeight, l = e.getBoundingClientRect().top + s, d = e.offsetHeight <= window.innerHeight, a = window.innerHeight), !(t === -1 && d) && (t !== -1 && (d || n && s <= l) ? (e.style.setProperty("--pos", "sticky"), e.style.setProperty("--top", "0px"), t = -1) : t === -1 && !n ? (e.style.setProperty("--pos", "relative"), e.style.setProperty("--top", `${Math.max(0, s - p)}px`), t = 0) : t !== 1 && !n && s + a >= l + c ? (e.style.setProperty("--pos", "sticky"), e.style.setProperty("--top", `${a - c}px`), t = 1) : t === 1 && n && (e.style.setProperty("--pos", "relative"), e.style.setProperty("--top", `${l - p}px`), t = 0));
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
-
r(document, "click",
|
|
32
|
-
|
|
33
|
-
r(window, "
|
|
31
|
+
E(() => [
|
|
32
|
+
r(document, "click", A, !0),
|
|
33
|
+
// Use capture to run before other click handlers
|
|
34
|
+
r(window, "resize", h(T, 100), g),
|
|
35
|
+
r(window, "scroll", H, g)
|
|
34
36
|
]);
|
|
35
37
|
export {
|
|
36
|
-
|
|
38
|
+
k as toggleAppExpanded
|
|
37
39
|
};
|
|
38
40
|
//# sourceMappingURL=app-observer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-observer.js","sources":["../../designsystem/app/app-observer.ts"],"sourcesContent":["import styles from \"../styles.module.css\";\nimport { debounce, isBrowser, on, onLoaded, QUICK_EVENT } from \"../utils\";\nimport \"./app-toggle\";\n\nconst CSS_APP = styles.app.split(\" \")[0];\nconst CSS_STICKY = styles.sticky.split(\" \")[0];\nconst CSS_TOGGLE =
|
|
1
|
+
{"version":3,"file":"app-observer.js","sources":["../../designsystem/app/app-observer.ts"],"sourcesContent":["import styles from \"../styles.module.css\";\nimport { debounce, isBrowser, on, onLoaded, QUICK_EVENT } from \"../utils\";\nimport \"./app-toggle\";\n\nconst CSS_APP = styles.app.split(\" \")[0];\nconst CSS_STICKY = styles.sticky.split(\" \")[0];\nconst CSS_TOGGLE = `[data-command=\"toggle-app-expanded\"],.${CSS_APP} > [command=\"show-modal\"]`;\nconst CSS_SIDEBAR = `.${CSS_APP} > dialog,.${CSS_APP} dialog ~ main`;\nconst STICKIES = isBrowser() ? document.getElementsByClassName(CSS_STICKY) : [];\n\nconst useTransition = (callback: () => void) => {\n\tif (!document.startViewTransition) callback();\n\telse document.startViewTransition(callback);\n};\n\nexport const toggleAppExpanded = (force?: boolean) =>\n\t// @ts-expect-error window.mtdsAppToggle comes from app-toggle.js\n\tuseTransition(() => window.mtdsToggleAppExpanded?.(force));\n\nfunction handleAppToggleClick(event: Event) {\n\tconst { target: el, defaultPrevented: stop } = event;\n\tconst link = (el as Element)?.closest?.(\"a\");\n\tif (link?.closest(\"dialog\") && link?.closest(CSS_SIDEBAR))\n\t\treturn closeSidebar(); // Close sidebar if link is clicked inside sidebar\n\n\tif (stop || !(el instanceof HTMLButtonElement) || !el.matches(CSS_TOGGLE))\n\t\treturn;\n\tconst isDesktop = getComputedStyle(el).position === \"sticky\";\n\tevent.preventDefault(); // Prevent default Invoker Command action so we can animate\n\n\tif (isDesktop) toggleAppExpanded();\n\telse\n\t\tuseTransition(() => {\n\t\t\tconst sidebar = document.querySelector<HTMLDialogElement>(CSS_SIDEBAR);\n\t\t\tsidebar?.setAttribute(\"closedby\", \"any\"); // Allow closing by clicking outside\n\t\t\tsidebar?.showModal();\n\t\t});\n}\n\nfunction closeSidebar() {\n\tdocument.querySelector<HTMLDialogElement>(CSS_SIDEBAR)?.close();\n}\n\n// Scroll state\nlet MIN_Y = 0; // Offset to avoid scroll jump when sticky is set to relative\nlet SCROLL_UP: boolean;\nlet STICK = 0; // -1 = stick top, 0 = relative, 1 = stick bottom\nlet STICK_H = 0;\nlet STICK_Y = 0;\nlet STUCK = false; // Used to figure if nav is larger than viewport\nlet WIN_H = 0;\nlet WIN_Y = 0;\n\nfunction handleAppScroll() {\n\tif (!STICKIES?.length) return;\n\tconst el = STICKIES[0] as HTMLElement;\n\tconst NEXT_Y = window.scrollY;\n\tconst NEXT_UP = NEXT_Y < WIN_Y;\n\tWIN_Y = NEXT_Y;\n\n\t// Only calculate if scroll direction has changed\n\tif (NEXT_UP !== SCROLL_UP) {\n\t\tMIN_Y = (el.parentElement?.getBoundingClientRect().top || 0) + WIN_Y;\n\t\tSCROLL_UP = NEXT_UP;\n\t\tSTICK_H = el.offsetHeight;\n\t\tSTICK_Y = el.getBoundingClientRect().top + WIN_Y;\n\t\tSTUCK = el.offsetHeight <= window.innerHeight;\n\t\tWIN_H = window.innerHeight;\n\t}\n\n\tif (STICK === -1 && STUCK) return; // Allways sticky when sidebar is smaller than viewport\n\tif (STICK !== -1 && (STUCK || (SCROLL_UP && WIN_Y <= STICK_Y))) {\n\t\tel.style.setProperty(\"--pos\", \"sticky\");\n\t\tel.style.setProperty(\"--top\", \"0px\");\n\t\tSTICK = -1; // Not sticking to top and sidebar is smaller than viewport or scrolling up\n\t} else if (STICK === -1 && !SCROLL_UP) {\n\t\tel.style.setProperty(\"--pos\", \"relative\");\n\t\tel.style.setProperty(\"--top\", `${Math.max(0, WIN_Y - MIN_Y)}px`);\n\t\tSTICK = 0; // Sticking to top and scrolling down\n\t} else if (STICK !== 1 && !SCROLL_UP && WIN_Y + WIN_H >= STICK_Y + STICK_H) {\n\t\tel.style.setProperty(\"--pos\", \"sticky\");\n\t\tel.style.setProperty(\"--top\", `${WIN_H - STICK_H}px`);\n\t\tSTICK = 1; // Not sticking to bottom and scrolling down\n\t} else if (STICK === 1 && SCROLL_UP) {\n\t\tel.style.setProperty(\"--pos\", \"relative\");\n\t\tel.style.setProperty(\"--top\", `${STICK_Y - MIN_Y}px`);\n\t\tSTICK = 0; // Sticking to bottom and scrolling up\n\t}\n}\n\nonLoaded(() => [\n\ton(document, \"click\", handleAppToggleClick, true), // Use capture to run before other click handlers\n\ton(window, \"resize\", debounce(closeSidebar, 100), QUICK_EVENT),\n\ton(window, \"scroll\", handleAppScroll, QUICK_EVENT),\n]);\n"],"names":["CSS_APP","styles","CSS_STICKY","CSS_TOGGLE","CSS_SIDEBAR","STICKIES","isBrowser","useTransition","callback","toggleAppExpanded","force","handleAppToggleClick","event","el","stop","link","closeSidebar","isDesktop","sidebar","MIN_Y","SCROLL_UP","STICK","STICK_H","STICK_Y","STUCK","WIN_H","WIN_Y","handleAppScroll","NEXT_Y","NEXT_UP","onLoaded","on","debounce","QUICK_EVENT"],"mappings":";;;AAIA,MAAMA,IAAUC,EAAO,IAAI,MAAM,GAAG,EAAE,CAAC,GACjCC,IAAaD,EAAO,OAAO,MAAM,GAAG,EAAE,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cACbU,IAAUV,EAAG,sBAAA,EAAwB,MAAMa,GAC3CF,IAAQX,EAAG,gBAAgB,OAAO,aAClCY,IAAQ,OAAO,cAGZ,EAAAJ,MAAU,MAAMG,OAChBH,MAAU,OAAOG,KAAUJ,KAAaM,KAASH,MACpDV,EAAG,MAAM,YAAY,SAAS,QAAQ,GACtCA,EAAG,MAAM,YAAY,SAAS,KAAK,GACnCQ,IAAQ,MACEA,MAAU,MAAM,CAACD,KAC3BP,EAAG,MAAM,YAAY,SAAS,UAAU,GACxCA,EAAG,MAAM,YAAY,SAAS,GAAG,KAAK,IAAI,GAAGa,IAAQP,CAAK,CAAC,IAAI,GAC/DE,IAAQ,KACEA,MAAU,KAAK,CAACD,KAAaM,IAAQD,KAASF,IAAUD,KAClET,EAAG,MAAM,YAAY,SAAS,QAAQ,GACtCA,EAAG,MAAM,YAAY,SAAS,GAAGY,IAAQH,CAAO,IAAI,GACpDD,IAAQ,KACEA,MAAU,KAAKD,MACzBP,EAAG,MAAM,YAAY,SAAS,UAAU,GACxCA,EAAG,MAAM,YAAY,SAAS,GAAGU,IAAUJ,CAAK,IAAI,GACpDE,IAAQ;AAEV;AAEAS,EAAS,MAAM;AAAA,EACdC,EAAG,UAAU,SAASpB,GAAsB,EAAI;AAAA;AAAA,EAChDoB,EAAG,QAAQ,UAAUC,EAAShB,GAAc,GAAG,GAAGiB,CAAW;AAAA,EAC7DF,EAAG,QAAQ,UAAUJ,GAAiBM,CAAW;AAClD,CAAC;"}
|
package/mtds/app/app.js
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
import { jsx as o } from "react/jsx-runtime";
|
|
2
2
|
import a from "clsx";
|
|
3
|
-
import { forwardRef as
|
|
3
|
+
import { forwardRef as n } from "react";
|
|
4
4
|
import { Button as s } from "../button/button.js";
|
|
5
5
|
import c from "../styles.module.css.js";
|
|
6
6
|
import d from "./app-toggle.js";
|
|
7
|
-
const f =
|
|
7
|
+
const f = n(function({ as: t, className: r, ...i }, e) {
|
|
8
8
|
return /* @__PURE__ */ o(t || "div", { className: a(c.app, r), ref: e, ...i });
|
|
9
|
-
}), u =
|
|
9
|
+
}), u = n(function({ as: t, className: r, ...i }, e) {
|
|
10
10
|
return /* @__PURE__ */ o(t || "div", { className: a(c.sticky, r), ref: e, ...i });
|
|
11
|
-
}),
|
|
12
|
-
Header:
|
|
11
|
+
}), b = Object.assign(f, {
|
|
12
|
+
Header: n(
|
|
13
13
|
function(t, r) {
|
|
14
14
|
return /* @__PURE__ */ o("header", { ref: r, ...t });
|
|
15
15
|
}
|
|
16
16
|
),
|
|
17
|
-
Sidebar:
|
|
17
|
+
Sidebar: n(
|
|
18
18
|
function(t, r) {
|
|
19
|
-
return /* @__PURE__ */ o("dialog", { role: "navigation", ref: r, ...t });
|
|
19
|
+
return /* @__PURE__ */ o("dialog", { role: "navigation", id: "mtds-sidebar", ref: r, ...t });
|
|
20
20
|
}
|
|
21
21
|
),
|
|
22
22
|
Sticky: u,
|
|
23
|
-
Toggle:
|
|
23
|
+
Toggle: n(
|
|
24
24
|
function({ children: t, ...r }, i) {
|
|
25
25
|
return /* @__PURE__ */ o(
|
|
26
26
|
s,
|
|
27
27
|
{
|
|
28
|
-
|
|
28
|
+
command: "toggle-app-expanded",
|
|
29
|
+
commandfor: "mtds-sidebar",
|
|
29
30
|
"data-tooltip": "Vis meny",
|
|
30
31
|
ref: i,
|
|
31
32
|
...r,
|
|
@@ -34,10 +35,10 @@ const f = p(function({ as: t, className: r, ...i }, e) {
|
|
|
34
35
|
);
|
|
35
36
|
}
|
|
36
37
|
),
|
|
37
|
-
Main:
|
|
38
|
+
Main: n(function(t, r) {
|
|
38
39
|
return /* @__PURE__ */ o("main", { ref: r, ...t });
|
|
39
40
|
}),
|
|
40
|
-
Footer:
|
|
41
|
+
Footer: n(
|
|
41
42
|
function(t, r) {
|
|
42
43
|
return /* @__PURE__ */ o("footer", { ref: r, ...t });
|
|
43
44
|
}
|
|
@@ -46,6 +47,6 @@ const f = p(function({ as: t, className: r, ...i }, e) {
|
|
|
46
47
|
Script: () => /* @__PURE__ */ o("script", { id: "mtds-app-script", children: d })
|
|
47
48
|
});
|
|
48
49
|
export {
|
|
49
|
-
|
|
50
|
+
b as App
|
|
50
51
|
};
|
|
51
52
|
//# 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\
|
|
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\" id=\"mtds-sidebar\" 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\tcommand=\"toggle-app-expanded\"\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"],"names":["AppComp","forwardRef","as","className","rest","ref","jsx","clsx","styles","AppS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GD,EAAA,CAAM;AAAA,EAClC,CAAC;AAAA,EACD,QAAQH;AAAA,IACP,SAAmBG,GAAMC,GAAK;AAC7B,aAAO,gBAAAC,EAAC,UAAA,EAAO,KAAAD,GAAW,GAAGD,EAAA,CAAM;AAAA,IACpC;AAAA,EAAA;AAAA;AAAA,EAGD,QAAQ,MAAM,gBAAAE,EAAC,UAAA,EAAO,IAAG,mBAAmB,UAAAO,EAAA,CAAO;AACpD,CAAC;"}
|
|
@@ -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\tattr,\n\tdefineElement,\n\tisBrowser,\n\tMTDSElement,\n\toff,\n\ton,\n\ttag,\n} from \"../utils\";\nimport css from \"./atlas.css?raw\";\nexport { L };\nexport { MTDSAtlasMarkerElement } from \"./atlas-marker\";\nexport { MTDSAtlasMatgeoElement } from \"./atlas-matgeo\";\nexport { MTDSAtlasWMSElement } from \"./atlas-wms\";\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\nif (isBrowser() && !window._matgeoCollections)\n\twindow._matgeoCollections = fetch(MATGEO_URL)\n\t\t.then((res) => res.json())\n\t\t.then((d) => d.collections.map((c: MTDSAtlasCollection) => [c.id, c]))\n\t\t.then(Object.fromEntries);\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\tnull,\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\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: [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\tasync getCollections() {\n\t\treturn (\n\t\t\twindow._matgeoCollections || Promise.resolve({} as MTDSAtlasCollections)\n\t\t);\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","isBrowser","res","d","c","MTDSAtlasElement","MTDSElement","tag","LeafletCSS","css","container","cluster","attr","tiles","L","on","#skipClick","#handlePopup","name","_prev","next","view","opts","p","b","x","y","off","type","popup","open","cont","slot","id","el","event","defineElement"],"mappings":";;;;;;;;AA+CA,IAAIA,IAAsC;AAC1C,MAAMC,IAAsB,IACtBC,IACL,sFACYC,IACZ,qFACKC,IAAuC;AAAA,EAC5C,CAAC,MAAM,IAAI;AAAA,EACX,CAAC,MAAM,KAAK;AACb;AAEIC,EAAA,KAAe,CAAC,OAAO,uBAC1B,OAAO,qBAAqB,MAAMF,CAAU,EAC1C,KAAK,CAACG,MAAQA,EAAI,MAAM,EACxB,KAAK,CAACC,MAAMA,EAAE,YAAY,IAAI,CAACC,MAA2B,CAACA,EAAE,IAAIA,CAAC,CAAC,CAAC,EACpE,KAAK,OAAO,WAAW;AAEnB,MAAMC,UAAyBC,EAAY;AAAA,EACjD;AAAA,EACA;AAAA,EAEA,WAAW,qBAAqB;AAC/B,WAAO,CAAC,aAAa,iBAAiB;AAAA,EACvC;AAAA,EACA,cAAc;AACb,UAAA,GACA,KAAK,aAAa,EAAE,MAAM,OAAA,CAAQ,EAAE;AAAA,MACnCC;AAAA,QACC;AAAA,QACA;AAAA,QACA,kBAAkBC,CAAU;AAAA,0BAA0BC,CAAA;AAAA,MAAA;AAAA,MAEvDF,EAAI,QAAQ;AAAA,IAAA;AAAA,EAEd;AAAA,EACA,oBAAoB;AACnB,UAAMG,IAAY,KAAK,YAAY,kBAC7BC,IAAUC,EAAK,MAAM,cAAc,KAAK,SACxCC,IAAQ,IAAIC,EAAE,UAAUhB,GAAsB;AAAA,MACnD,aAAa;AAAA,MACb,WAAW;AAAA,MACX,SAASD;AAAA,IAAA,CACT;AAED,SAAK,MAAM,IAAIiB,EAAE,I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1DtB,EAAKsB,GAAI,QAAQJ,IAAOI,EAAG,KAAK,IAAI,GAChCJ,KAAMD,EAAM,WAAWtB,EAAI,QAAQ,EAAE,MAAM2B,EAAG,GAAA,CAAI,CAAC;AAAA,EACxD;AAAA,EACAlB,GAAWmB,GAA4B;AACtC,IAAIA,EAAM,SAAS,UAASvC,KAAcuC,EAAM,kBAAA,IACvC,SAAS,KAAK,UAAU,SAAS,kBAAkB,MAC3DvC,IAAa,WAAW,MAAM;AAC7B,MAAAA,IAAa;AAAA,IACd,GAAG,EAAE;AAAA,EACP;AACD;AAEAwC,EAAc,cAAc/B,CAAgB;AAExCJ,EAAA,MACHa,EAAE,OAAO,UAAU,QAAQ,OAAO,IAAIA,EAAE,QAAQ;AAAA,EAC/C,MAAM;AAAA,EACN,UAAU,CAAC,GAAG,CAAC;AAAA,CACf;"}
|
|
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\tattr,\n\tdefineElement,\n\tisBrowser,\n\tMTDSElement,\n\toff,\n\ton,\n\ttag,\n} from \"../utils\";\nimport css from \"./atlas.css?raw\";\nexport { L };\nexport { MTDSAtlasMarkerElement } from \"./atlas-marker\";\nexport { MTDSAtlasMatgeoElement } from \"./atlas-matgeo\";\nexport { MTDSAtlasWMSElement } from \"./atlas-wms\";\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\nif (isBrowser() && !window._matgeoCollections)\n\twindow._matgeoCollections = fetch(MATGEO_URL)\n\t\t.then((res) => res.json())\n\t\t.then((d) => d.collections.map((c: MTDSAtlasCollection) => [c.id, c]))\n\t\t.then(Object.fromEntries);\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\tnull,\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\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: [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\tasync getCollections() {\n\t\treturn (\n\t\t\twindow._matgeoCollections || Promise.resolve({} as MTDSAtlasCollections)\n\t\t);\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","isBrowser","res","d","c","MTDSAtlasElement","MTDSElement","tag","LeafletCSS","css","container","cluster","attr","tiles","L","on","#skipClick","#handlePopup","name","_prev","next","view","opts","p","b","x","y","off","type","popup","open","cont","slot","id","el","event","defineElement"],"mappings":";;;;;;;;AA+CA,IAAIA,IAAsC;AAC1C,MAAMC,IAAsB,IACtBC,IACL,sFACYC,IACZ,qFACKC,IAAuC;AAAA,EAC5C,CAAC,MAAM,IAAI;AAAA,EACX,CAAC,MAAM,KAAK;AACb;AAEIC,EAAA,KAAe,CAAC,OAAO,uBAC1B,OAAO,qBAAqB,MAAMF,CAAU,EAC1C,KAAK,CAACG,MAAQA,EAAI,MAAM,EACxB,KAAK,CAACC,MAAMA,EAAE,YAAY,IAAI,CAACC,MAA2B,CAACA,EAAE,IAAIA,CAAC,CAAC,CAAC,EACpE,KAAK,OAAO,WAAW;AAEnB,MAAMC,UAAyBC,EAAY;AAAA,EACjD;AAAA,EACA;AAAA,EAEA,WAAW,qBAAqB;AAC/B,WAAO,CAAC,aAAa,iBAAiB;AAAA,EACvC;AAAA,EACA,cAAc;AACb,UAAA,GACA,KAAK,aAAa,EAAE,MAAM,OAAA,CAAQ,EAAE;AAAA,MACnCC;AAAA,QACC;AAAA,QACA;AAAA,QACA,kBAAkBC,CAAU;AAAA,yBAA0BC,CAAA;AAAA,MAAA;AAAA,MAEvDF,EAAI,QAAQ;AAAA,IAAA;AAAA,EAEd;AAAA,EACA,oBAAoB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C,IAAAf,EAAE,KAAK,WAAWe,GAAO,EAAE,UAAU,KAAK,cAAc,IAAI,GAC5DjB,EAAKsB,GAAI,gBAAgBJ,IAAOlB,EAAKsB,GAAI,SAAS,IAAI,IAAI,GAC1DtB,EAAKsB,GAAI,WAAWJ,IAAO,OAAOlB,EAAKsB,GAAI,cAAc,CAAC,GAC1DtB,EAAKsB,GAAI,QAAQJ,IAAOI,EAAG,KAAK,IAAI,GAChCJ,KAAMD,EAAM,WAAWtB,EAAI,QAAQ,EAAE,MAAM2B,EAAG,GAAA,CAAI,CAAC;AAAA,EACxD;AAAA,EACAlB,GAAWmB,GAA4B;AACtC,IAAIA,EAAM,SAAS,UAASvC,KAAcuC,EAAM,kBAAA,IACvC,SAAS,KAAK,UAAU,SAAS,kBAAkB,MAC3DvC,IAAa,WAAW,MAAM;AAC7B,MAAAA,IAAa;AAAA,IACd,GAAG,EAAE;AAAA,EACP;AACD;AAEAwC,EAAc,cAAc/B,CAAgB;AAExCJ,EAAA,MACHa,EAAE,OAAO,UAAU,QAAQ,OAAO,IAAIA,EAAE,QAAQ;AAAA,EAC/C,MAAM;AAAA,EACN,UAAU,CAAC,GAAG,CAAC;AAAA,CACf;"}
|
package/mtds/atlas/atlas.css.js
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
|
-
const t =
|
|
1
|
+
const t = `/**
|
|
2
|
+
* NOTE:
|
|
3
|
+
* - Dark mode styles are in styles.module.css to leverage data-color-scheme attribute
|
|
4
|
+
* - This file is using --mtds- not --mtds- since we're inside shadow dom
|
|
5
|
+
*/
|
|
6
|
+
|
|
2
7
|
:host {
|
|
3
8
|
--mtdsc-atlas-border: 1px solid var(--mtds-color-border-subtle);
|
|
4
9
|
--mtdsc-atlas-cluster-border: 1px solid;
|
|
5
|
-
--mtdsc-atlas-marker-background:
|
|
6
|
-
--mtdsc-atlas-
|
|
7
|
-
--mtdsc-atlas-
|
|
10
|
+
--mtdsc-atlas-marker-background: #116e6b;
|
|
11
|
+
--mtdsc-atlas-cluster-background: var(--mtdsc-atlas-marker-background);
|
|
12
|
+
--mtdsc-atlas-cluster-color: var(--mtdsc-atlas-marker-color);
|
|
13
|
+
--mtdsc-atlas-marker-border: none;
|
|
14
|
+
--mtdsc-atlas-marker-color: #fff;
|
|
8
15
|
--mtdsc-atlas-marker-inset: 3px;
|
|
9
|
-
--mtdsc-atlas-marker-shadow:
|
|
16
|
+
--mtdsc-atlas-marker-shadow-blur: 4px;
|
|
17
|
+
--mtdsc-atlas-marker-shadow-color: rgba(0 0 0 / 0.5);
|
|
18
|
+
--mtdsc-atlas-marker-shadow-offset: 2px;
|
|
10
19
|
--mtdsc-atlas-marker-size: var(--mtds-6);
|
|
11
|
-
--mtdsc-atlas-tile-background: #
|
|
12
|
-
--mtdsc-atlas-tile-filter: grayscale(
|
|
20
|
+
--mtdsc-atlas-tile-background: #f7fcfc;
|
|
21
|
+
--mtdsc-atlas-tile-filter: grayscale(.8) contrast(0.75) brightness(1.15); /* Also in styles.module.css */
|
|
13
22
|
|
|
14
23
|
border-radius: var(--mtds-border-radius-md);
|
|
15
24
|
aspect-ratio: 2;
|
|
@@ -77,7 +86,7 @@ const t = `/* NOTE: Using --mtds- not --mtds- since we're inside shadow dom */
|
|
|
77
86
|
}
|
|
78
87
|
.leaflet-marker-generated-icon::after,
|
|
79
88
|
::slotted(mtds-atlas-marker)::after {
|
|
80
|
-
box-shadow:
|
|
89
|
+
box-shadow: var(--mtdsc-atlas-marker-shadow-offset) var(--mtdsc-atlas-marker-shadow-offset) var(--mtdsc-atlas-marker-shadow-blur) var(--mtdsc-atlas-marker-shadow-color);
|
|
81
90
|
aspect-ratio: 1;
|
|
82
91
|
background: var(--mtdsc-atlas-marker-color);
|
|
83
92
|
color: var(--mtdsc-atlas-marker-background);
|
|
@@ -102,13 +111,13 @@ const t = `/* NOTE: Using --mtds- not --mtds- since we're inside shadow dom */
|
|
|
102
111
|
.leaflet-marker-icon slot { display: block; position: absolute; left: 0; top: 0; translate: -50% -100% }
|
|
103
112
|
.leaflet-marker-icon { background: none; border: 0 }
|
|
104
113
|
.leaflet-cluster-icon {
|
|
105
|
-
box-shadow: 0
|
|
106
|
-
background-color: var(--
|
|
114
|
+
box-shadow: 0 var(--mtdsc-atlas-marker-shadow-offset) var(--mtdsc-atlas-marker-shadow-blur) var(--mtdsc-atlas-marker-shadow-color);
|
|
115
|
+
background-color: var(--mtdsc-atlas-cluster-background);
|
|
107
116
|
border-radius: 100%;
|
|
108
117
|
border: var(--mtdsc-atlas-cluster-border);
|
|
109
118
|
box-sizing: border-box;
|
|
110
|
-
outline: 1px solid var(--
|
|
111
|
-
color: var(--
|
|
119
|
+
outline: 1px solid var(--mtdsc-atlas-cluster-background);
|
|
120
|
+
color: var(--mtdsc-atlas-cluster-color);
|
|
112
121
|
display: flex;
|
|
113
122
|
font-size: var(--mtds-body-xs-font-size);
|
|
114
123
|
font-weight: var(--mtds-font-weight-bold);
|
|
@@ -121,6 +130,7 @@ const t = `/* NOTE: Using --mtds- not --mtds- since we're inside shadow dom */
|
|
|
121
130
|
.leaflet-popup:has(slot) .leaflet-popup-close-button { display: none } /* Popup closes on clicking marker anyway */
|
|
122
131
|
.leaflet-popup:has(slot) .leaflet-popup-content-wrapper { display: contents } /* No need for styling this element */
|
|
123
132
|
.leaflet-popup:has(slot) .leaflet-popup-content { margin: 0; font: inherit }
|
|
133
|
+
|
|
124
134
|
`;
|
|
125
135
|
export {
|
|
126
136
|
t as default
|