@mattilsynet/design 2.2.17 → 2.2.19
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 +1 -1
- package/mtds/analytics/analytics.js.map +1 -1
- package/mtds/atlas/atlas-element.d.ts +24 -0
- package/mtds/atlas/atlas-element.js +57 -0
- package/mtds/atlas/atlas-element.js.map +1 -0
- package/mtds/atlas/atlas.css.js +72 -0
- package/mtds/atlas/atlas.css.js.map +1 -0
- package/mtds/atlas/atlas.d.ts +14 -0
- package/mtds/atlas/atlas.stories.d.ts +16 -0
- package/mtds/atlas.d.ts +1 -0
- package/mtds/atlas.iife.js +745 -0
- package/mtds/atlas.js +5 -0
- package/mtds/atlas.js.map +1 -0
- package/mtds/chart/chart-element.js +1 -1
- package/mtds/chart/chart-element.js.map +1 -1
- package/mtds/chart/chart.d.ts +7 -12
- package/mtds/chart/chart.js.map +1 -1
- package/mtds/dialog/dialog-observer.js +16 -16
- package/mtds/dialog/dialog-observer.js.map +1 -1
- package/mtds/field/field-observer.js +47 -44
- package/mtds/field/field-observer.js.map +1 -1
- package/mtds/fieldset/fieldset.stories.d.ts +1 -0
- package/mtds/fileupload/fileupload.d.ts +6 -0
- package/mtds/fileupload/fileupload.js +13 -0
- package/mtds/fileupload/fileupload.js.map +1 -0
- package/mtds/{lawpicker/lawpicker.stories.d.ts → fileupload/fileupload.stories.d.ts} +1 -0
- package/mtds/illustrations/byggning-1-gronn.svg +1 -0
- package/mtds/illustrations/byggning-1-mattilsynet.svg +1 -0
- package/mtds/illustrations/byggning-2-gronn.svg +1 -0
- package/mtds/illustrations/byggning-3-gronn.svg +1 -0
- package/mtds/illustrations/byggning-4-gronn.svg +1 -0
- package/mtds/illustrations/byggning-5-gronn.svg +1 -0
- package/mtds/illustrations/byggning-6-blaa.svg +1 -0
- package/mtds/illustrations/byggning-7-blaa.svg +1 -0
- package/mtds/illustrations/byggning-8-blaa.svg +1 -0
- package/mtds/illustrations/byggningsrekke-1-gronn.svg +1 -0
- package/mtds/illustrations/byggningsrekke-1-mattilsynet.svg +1 -0
- package/mtds/illustrations/byggningsrekke-2-gronn.svg +1 -0
- package/mtds/illustrations/byggningsrekke-3-blaa.svg +1 -0
- package/mtds/illustrations/debatt.svg +1 -0
- package/mtds/illustrations/egg.svg +1 -0
- package/mtds/illustrations/flagg-aaland.svg +1 -0
- package/mtds/illustrations/flagg-danmark.svg +1 -0
- package/mtds/illustrations/flagg-faeroyene.svg +1 -0
- package/mtds/illustrations/flagg-finland.svg +1 -0
- package/mtds/illustrations/flagg-gronland.svg +1 -0
- package/mtds/illustrations/flagg-island.svg +1 -0
- package/mtds/illustrations/flagg-norge.svg +1 -0
- package/mtds/illustrations/flagg-sapmi.svg +1 -0
- package/mtds/illustrations/flagg-sverige.svg +1 -0
- package/mtds/illustrations/forstorrelsesglass.svg +1 -0
- package/mtds/illustrations/hengelas.svg +1 -0
- package/mtds/illustrations/index.json +139 -0
- package/mtds/illustrations/kompass.svg +1 -0
- package/mtds/illustrations/skinke.svg +1 -0
- package/mtds/illustrations/system-stotte.svg +1 -0
- package/mtds/illustrations/system.svg +1 -0
- package/mtds/illustrations/tre-1.svg +1 -0
- package/mtds/illustrations/tre-2.svg +1 -0
- package/mtds/illustrations/tre-3.svg +1 -0
- package/mtds/index.d.ts +3 -0
- package/mtds/index.iife.js +15 -15
- package/mtds/index.js +20 -15
- package/mtds/index.js.map +1 -1
- package/mtds/law/law-helper.d.ts +38 -0
- package/mtds/law/law-helper.js +78 -0
- package/mtds/law/law-helper.js.map +1 -0
- package/mtds/law/law.d.ts +2 -0
- package/mtds/law/law.js +10 -0
- package/mtds/law/law.js.map +1 -0
- package/mtds/law/law.stories.d.ts +16 -0
- package/mtds/law/vinforskriften-new.d.ts +1 -0
- package/mtds/law/vinforskriften-old.d.ts +1 -0
- package/mtds/logo/logo-observer.js +1 -1
- package/mtds/logo/logo-observer.js.map +1 -1
- package/mtds/package.json.js +1 -1
- package/mtds/react.d.ts +2 -0
- package/mtds/react.js +58 -54
- package/mtds/react.js.map +1 -1
- package/mtds/styles.css +1 -1
- package/mtds/styles.json +43 -41
- package/mtds/styles.module.css.js +98 -94
- package/mtds/styles.module.css.js.map +1 -1
- package/mtds/table/table.stories.d.ts +1 -0
- package/mtds/utils.js +36 -30
- package/mtds/utils.js.map +1 -1
- package/package.json +15 -16
- package/mtds/lawpicker/lawpicker-element.d.ts +0 -18
- package/mtds/map/map-element.d.ts +0 -47
- package/mtds/map/map-element.js +0 -82
- package/mtds/map/map-element.js.map +0 -1
- package/mtds/map/map.css.js +0 -46
- package/mtds/map/map.css.js.map +0 -1
- package/mtds/map/map.stories.d.ts +0 -10
- package/mtds/map.d.ts +0 -1
- package/mtds/map.iife.js +0 -722
- package/mtds/map.js +0 -8
- package/mtds/map.js.map +0 -1
|
@@ -18,7 +18,7 @@ function q(t, a = {}) {
|
|
|
18
18
|
}
|
|
19
19
|
if (window._mtdsTracking?.enabled !== !1) {
|
|
20
20
|
if (window._mtdsTracking?.enabled === "debug")
|
|
21
|
-
return console.info(`analytics
|
|
21
|
+
return console.info(`analytics ${t}:`, a);
|
|
22
22
|
if (t === "pageview") {
|
|
23
23
|
const { url: e, title: o } = a;
|
|
24
24
|
window._paq.push(["setCustomUrl", e || location.href]), window._paq.push(["setDocumentTitle", o || document.title]), window._paq.push(["trackPageView"]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analytics.js","sources":["../../designsystem/analytics/analytics.ts"],"sourcesContent":["import styles from \"../styles.module.css\";\nimport { attr, IS_BROWSER, 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 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?: never;\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 (!IS_BROWSER) 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\twindow._paq.push(args as AnalyticsActions[\"matomo\"]);\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}\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","BANNER","BANNER_URL","analytics","action","args","IS_BROWSER","consent","enabled","matomoId","matomoTagManagerId","renderBanner","src","tag","url","title","category","name","value","event","v","query","results","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,IAAS,yBACTC,IACL;AAmDM,SAASC,EACfC,GACAC,IAAO,IACN;AACD,MAAKC,GAYL;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,WAAWN,CAAM,aAAa,CAAC,IAE9D,OAAO,SACX,OAAO,OAAO,OAAO,QAAQ,CAAA,GAC7B,OAAO,KAAK,KAAK,EAAE,iBAAiB,KAAK,IAAA,GAAO,OAAO,aAAa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AAKL,EAAG,cAAc,mBAAmB,CAAC;AACvD,SAAQU,EAAK,WAAWC,CAAI,KAAKA,KAASD,EAAK,MAAM,GAAG,GAAG,EAAE,KAAA;AAC9D;AAEAE,EAAS,MAAM,CAACC,EAAG,UAAU3C,GAAQ0B,GAAsBkB,CAAW,CAAC,CAAC;"}
|
|
1
|
+
{"version":3,"file":"analytics.js","sources":["../../designsystem/analytics/analytics.ts"],"sourcesContent":["import styles from \"../styles.module.css\";\nimport { attr, IS_BROWSER, 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 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?: never;\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 (!IS_BROWSER) 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\twindow._paq.push(args as AnalyticsActions[\"matomo\"]);\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}\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","BANNER","BANNER_URL","analytics","action","args","IS_BROWSER","consent","enabled","matomoId","matomoTagManagerId","renderBanner","src","tag","url","title","category","name","value","event","v","query","results","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,IAA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D,EAAU,SAAS;AAAA,IAClB,UAAU6B,EAAKH,GAAI,yBAAyB,KAAKb;AAAA,IACjD,QAAQgB,EAAKH,GAAI,uBAAuB,KAAKzB;AAAA,IAC7C,MAAM4B,EAAKH,GAAI,qBAAqB,KAAKZ;AAAA,EAAA,CACzC;AACF;AAGA,MAAMiB,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,UAAU3C,GAAQ0B,GAAsBkB,CAAW,CAAC,CAAC;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { MTDSElement } from '../utils';
|
|
2
|
+
import * as L from "leaflet";
|
|
3
|
+
import type * as ReactTypes from "react";
|
|
4
|
+
declare global {
|
|
5
|
+
namespace React.JSX {
|
|
6
|
+
interface IntrinsicElements {
|
|
7
|
+
"mtds-atlas": ReactTypes.DetailedHTMLProps<ReactTypes.HTMLAttributes<MTDSAtlasElement>, MTDSAtlasElement> & {
|
|
8
|
+
class?: string;
|
|
9
|
+
"data-view"?: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export declare class MTDSAtlasElement extends MTDSElement {
|
|
15
|
+
map?: L.Map;
|
|
16
|
+
tiles?: L.TileLayer;
|
|
17
|
+
cluster?: L.MarkerClusterGroup;
|
|
18
|
+
leaflet: typeof L;
|
|
19
|
+
static get observedAttributes(): string[];
|
|
20
|
+
constructor();
|
|
21
|
+
connectedCallback(): void;
|
|
22
|
+
addMarker(latlng: L.LatLngExpression, options?: L.MarkerOptions): L.Marker<any>;
|
|
23
|
+
disconnectedCallback(): void;
|
|
24
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as e from "leaflet";
|
|
2
|
+
import c from "leaflet/dist/leaflet.css?raw";
|
|
3
|
+
import d from "leaflet.markercluster/dist/MarkerCluster.css?raw";
|
|
4
|
+
import "leaflet.markercluster";
|
|
5
|
+
import { IS_BROWSER as h, MTDSElement as p, tag as s, attr as a } from "../utils.js";
|
|
6
|
+
import u from "./atlas.css.js";
|
|
7
|
+
e.Marker.prototype.options.icon = e.divIcon({
|
|
8
|
+
html: '<svg class="map-pin" viewBox="0 0 256 256"><rect x="78" y="50" width="100" height="100" /><path fill="var(--mtds-)" 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>',
|
|
9
|
+
iconAnchor: [15, 30],
|
|
10
|
+
iconSize: [30, 30]
|
|
11
|
+
});
|
|
12
|
+
const f = "57.95, 4.73, 71.19, 31.44, 15", v = "https://cache.kartverket.no/v1/wmts/1.0.0/topo/default/webmercator/{z}/{y}/{x}.png", w = "https://cache.kartverket.no/v1/wmts/1.0.0/topograatone/default/webmercator/{z}/{y}/{x}.png";
|
|
13
|
+
class g extends p {
|
|
14
|
+
map;
|
|
15
|
+
tiles;
|
|
16
|
+
cluster;
|
|
17
|
+
leaflet;
|
|
18
|
+
static get observedAttributes() {
|
|
19
|
+
return ["data-view", "data-layers", "data-tiles"];
|
|
20
|
+
}
|
|
21
|
+
constructor() {
|
|
22
|
+
super(), this.leaflet = e, this.attachShadow({ mode: "open" }).append(
|
|
23
|
+
s("style", {}, `${c}
|
|
24
|
+
${d}
|
|
25
|
+
${u}`),
|
|
26
|
+
s("slot"),
|
|
27
|
+
s("div")
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
connectedCallback() {
|
|
31
|
+
const t = JSON.parse(`[${a(this, "data-view") || f}]`), o = this.shadowRoot?.lastElementChild, r = Number(a(this, "data-cluster")) || 1, i = a(this, "data-tiles") === "color" ? v : w;
|
|
32
|
+
if (this.tiles = e.tileLayer(i, { maxZoom: 18 }), this.cluster = e.markerClusterGroup({
|
|
33
|
+
showCoverageOnHover: !1,
|
|
34
|
+
disableClusteringAtZoom: r
|
|
35
|
+
}), this.map = e.map(o, {
|
|
36
|
+
layers: [this.tiles, this.cluster],
|
|
37
|
+
attributionControl: !1,
|
|
38
|
+
wheelPxPerZoomLevel: 20,
|
|
39
|
+
zoomControl: !1,
|
|
40
|
+
zoomSnap: 0
|
|
41
|
+
}), this.map.addControl(e.control.zoom({ position: "bottomright" })), t.length === 3 && this.map.setView([t[0], t[1]], t[2]), t.length >= 4) {
|
|
42
|
+
const l = [t[0], t[1]], n = [t[2], t[3]], m = [t[4] ?? 0, t[5] ?? t[4] ?? 0];
|
|
43
|
+
this.map.fitBounds([l, n], { padding: m });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
addMarker(t, o) {
|
|
47
|
+
return e.marker(t, o).addTo(this.cluster || this.map);
|
|
48
|
+
}
|
|
49
|
+
disconnectedCallback() {
|
|
50
|
+
this.map?.remove();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
h && !window.customElements.get("mtds-atlas") && window.customElements.define("mtds-atlas", g);
|
|
54
|
+
export {
|
|
55
|
+
g as MTDSAtlasElement
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=atlas-element.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atlas-element.js","sources":["../../designsystem/atlas/atlas-element.ts"],"sourcesContent":["import * as L from \"leaflet\";\nimport LeafletCSS from \"leaflet/dist/leaflet.css?raw\";\nimport LeafletClusterCSS from \"leaflet.markercluster/dist/MarkerCluster.css?raw\";\nimport type * as ReactTypes from \"react\";\nimport \"leaflet.markercluster\";\n\nimport { attr, IS_BROWSER, MTDSElement, tag } from \"../utils\";\nimport css from \"./atlas.css?raw\";\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-view\"?: string;\n\t\t\t};\n\t\t}\n\t}\n}\n\nL.Marker.prototype.options.icon = L.divIcon({\n\thtml: '<svg class=\"map-pin\" viewBox=\"0 0 256 256\"><rect x=\"78\" y=\"50\" width=\"100\" height=\"100\" /><path fill=\"var(--mtds-)\" 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\ticonAnchor: [15, 30],\n\ticonSize: [30, 30],\n});\n\n// const strToLatLng = (str?: string | null) =>\n// \t[0, 0, ...(str || \"\").split(\",\").map(parseFloat)].slice(-2) as L.LatLngTuple;\n\nconst VIEW_NORWAY = \"57.95, 4.73, 71.19, 31.44, 15\";\nconst TILES_COLOR =\n\t\"https://cache.kartverket.no/v1/wmts/1.0.0/topo/default/webmercator/{z}/{y}/{x}.png\";\nconst TILES_GRAY =\n\t\"https://cache.kartverket.no/v1/wmts/1.0.0/topograatone/default/webmercator/{z}/{y}/{x}.png\";\n\nexport class MTDSAtlasElement extends MTDSElement {\n\tmap?: L.Map;\n\ttiles?: L.TileLayer;\n\tcluster?: L.MarkerClusterGroup;\n\tleaflet: typeof L;\n\n\tstatic get observedAttributes() {\n\t\treturn [\"data-view\", \"data-layers\", \"data-tiles\"]; // Using ES2015 syntax for backwards compatibility\n\t}\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.leaflet = L;\n\t\tthis.attachShadow({ mode: \"open\" }).append(\n\t\t\ttag(\"style\", {}, `${LeafletCSS}\\n${LeafletClusterCSS}\\n${css}`),\n\t\t\ttag(\"slot\"),\n\t\t\ttag(\"div\"),\n\t\t);\n\t}\n\tconnectedCallback() {\n\t\tconst view = JSON.parse(`[${attr(this, \"data-view\") || VIEW_NORWAY}]`);\n\t\tconst div = this.shadowRoot?.lastElementChild;\n\t\tconst cluster = Number(attr(this, \"data-cluster\")) || 1;\n\t\tconst tiles =\n\t\t\tattr(this, \"data-tiles\") === \"color\" ? TILES_COLOR : TILES_GRAY;\n\n\t\tthis.tiles = L.tileLayer(tiles, { maxZoom: 18 });\n\t\tthis.cluster = L.markerClusterGroup({\n\t\t\tshowCoverageOnHover: false,\n\t\t\tdisableClusteringAtZoom: cluster,\n\t\t});\n\n\t\tthis.map = L.map(div as HTMLElement, {\n\t\t\tlayers: [this.tiles, this.cluster],\n\t\t\tattributionControl: false,\n\t\t\twheelPxPerZoomLevel: 20,\n\t\t\tzoomControl: false,\n\t\t\tzoomSnap: 0,\n\t\t});\n\t\tthis.map.addControl(L.control.zoom({ position: \"bottomright\" }));\n\n\t\t// If no view is set, use Norway as default bounding box\n\t\tif (view.length === 3) this.map.setView([view[0], view[1]], view[2]);\n\t\tif (view.length >= 4) {\n\t\t\tconst nw = [view[0], view[1]] as L.LatLngTuple;\n\t\t\tconst se = [view[2], view[3]] as L.LatLngTuple;\n\t\t\tconst padding = [view[4] ?? 0, view[5] ?? view[4] ?? 0] as L.PointTuple;\n\t\t\tthis.map.fitBounds([nw, se], { padding });\n\t\t}\n\t}\n\taddMarker(latlng: L.LatLngExpression, options?: L.MarkerOptions) {\n\t\treturn L.marker(latlng, options).addTo(this.cluster || (this.map as L.Map));\n\t}\n\tdisconnectedCallback() {\n\t\tthis.map?.remove();\n\t}\n}\n\nif (IS_BROWSER && !window.customElements.get(\"mtds-atlas\"))\n\twindow.customElements.define(\"mtds-atlas\", MTDSAtlasElement);\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// // Hent punkt for adresse fra GeoNorge\n// export async function getPunktFraAdresse(\n// \tadresseSoek: string,\n// ): Promise<Adresse[]> {\n// \ttry {\n// \t\tconst response = await fetch(\n// \t\t\t`https://ws.geonorge.no/adresser/v1/sok?sok=${adresseSoek}&fuzzy=false&utkoordsys=3857&treffPerSide=100&asciiKompatibel=true`,\n// \t\t);\n// \t\tconst jsonresponse = await response.json();\n// \t\tif (jsonresponse.adresser.length > 0) {\n// \t\t\treturn jsonresponse.adresser.map((adresse: Adresse) => ({\n// \t\t\t\tadressekode: adresse.adressekode,\n// \t\t\t\tadressetekst: adresse.adressetekst,\n// \t\t\t\tbokstav: adresse.bokstav,\n// \t\t\t\tbruksenhetsnummer: adresse.bruksenhetsnummer,\n// \t\t\t\tbruksnummer: adresse.bruksnummer,\n// \t\t\t\tfestenummer: adresse.festenummer,\n// \t\t\t\tgardsnummer: adresse.gardsnummer,\n// \t\t\t\tkommunenavn: adresse.kommunenavn,\n// \t\t\t\tkommunenummer: adresse.kommunenummer,\n// \t\t\t\tnummer: adresse.nummer,\n// \t\t\t\tobjtype: adresse.objtype,\n// \t\t\t\toppdateringsdato: adresse.oppdateringsdato,\n// \t\t\t\tpostnummer: adresse.postnummer,\n// \t\t\t\tpoststed: adresse.poststed,\n// \t\t\t\trepresentasjonspunkt: {\n// \t\t\t\t\tepsg: adresse.representasjonspunkt.epsg,\n// \t\t\t\t\tlat: adresse.representasjonspunkt.lat,\n// \t\t\t\t\tlon: adresse.representasjonspunkt.lon,\n// \t\t\t\t},\n// \t\t\t}));\n// \t\t} else {\n// \t\t\treturn [];\n// \t\t}\n// \t} catch (error) {\n// \t\tconsole.log(`Feilet i å hente adresse fra punkt: ${error}`);\n// \t\treturn [];\n// \t}\n// }\n"],"names":["L","VIEW_NORWAY","TILES_COLOR","TILES_GRAY","MTDSAtlasElement","MTDSElement","tag","LeafletCSS","LeafletClusterCSS","css","view","attr","div","cluster","tiles","nw","se","padding","latlng","options","IS_BROWSER"],"mappings":";;;;;;AAuBAA,EAAE,OAAO,UAAU,QAAQ,OAAOA,EAAE,QAAQ;AAAA,EAC3C,MAAM;AAAA,EACN,YAAY,CAAC,IAAI,EAAE;AAAA,EACnB,UAAU,CAAC,IAAI,EAAE;AAClB,CAAC;AAKD,MAAMC,IAAc,iCACdC,IACL,sFACKC,IACL;AAEM,MAAMC,UAAyBC,EAAY;AAAA,EACjD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA,WAAW,qBAAqB;AAC/B,WAAO,CAAC,aAAa,eAAe,YAAY;AAAA,EACjD;AAAA,EAEA,cAAc;AACb,UAAA,GACA,KAAK,UAAUL,GACf,KAAK,aAAa,EAAE,MAAM,OAAA,CAAQ,EAAE;AAAA,MACnCM,EAAI,SAAS,IAAI,GAAGC,CAAU;AAAA,EAAKC,CAAiB;AAAA,EAAKC,CAAG,EAAE;AAAA,MAC9DH,EAAI,MAAM;AAAA,MACVA,EAAI,KAAK;AAAA,IAAA;AAAA,EAEX;AAAA,EACA,oBAAoB;AACnB,UAAMI,IAAO,KAAK,MAAM,IAAIC,EAAK,MAAM,WAAW,KAAKV,CAAW,GAAG,GAC/DW,IAAM,KAAK,YA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|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
const t = `:host {
|
|
2
|
+
--mtdsc-atlas-background: var(--mtds-color-surface-default);
|
|
3
|
+
--mtdsc-atlas-cluster-size: var(--mtds-8);
|
|
4
|
+
|
|
5
|
+
aspect-ratio: 2; /* TODO: make possible to overwrite */
|
|
6
|
+
border-radius: var(--mtds-border-radius-md);
|
|
7
|
+
border: 1px solid var(--mtds-color-border-subtle);
|
|
8
|
+
overflow: clip;
|
|
9
|
+
position: relative;
|
|
10
|
+
user-select: none;
|
|
11
|
+
}
|
|
12
|
+
:host(:not([hidden])) {
|
|
13
|
+
display: grid;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
:host([data-cursor="pointer"]) .leaflet-grab {
|
|
17
|
+
cursor: pointer;
|
|
18
|
+
}
|
|
19
|
+
:host([data-tiles="color"]) {
|
|
20
|
+
--mtdsc-atlas-background: #e0fefe;
|
|
21
|
+
}
|
|
22
|
+
:host([data-tiles="grayscale"]) .leaflet-tile-container,
|
|
23
|
+
:host(:not([data-tiles])) .leaflet-tile-container {
|
|
24
|
+
filter: contrast(0.75) brightness(1.15);
|
|
25
|
+
}
|
|
26
|
+
slot {
|
|
27
|
+
display: grid;
|
|
28
|
+
inset: var(--mtds-3);
|
|
29
|
+
pointer-events: none; /* Ensure slot does not stop pointer from reaching leaflet */
|
|
30
|
+
position: absolute;
|
|
31
|
+
z-index: 2;
|
|
32
|
+
}
|
|
33
|
+
::slotted(*) {
|
|
34
|
+
pointer-events: all; /* But let children of slot stop pointer from reaching leaflet */
|
|
35
|
+
}
|
|
36
|
+
.leaflet-div-icon {
|
|
37
|
+
background: none;
|
|
38
|
+
border: 0;
|
|
39
|
+
}
|
|
40
|
+
.leaflet-container {
|
|
41
|
+
font: inherit;
|
|
42
|
+
background: var(--mtdsc-atlas-background);
|
|
43
|
+
outline: 0;
|
|
44
|
+
}
|
|
45
|
+
.map-pin rect {
|
|
46
|
+
fill: var(--mtds-color-base-contrast-default);
|
|
47
|
+
}
|
|
48
|
+
.map-pin path {
|
|
49
|
+
fill: var(--mtds-color-base-default);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.marker-cluster {
|
|
53
|
+
background-color: var(--mtds-color-base-default);
|
|
54
|
+
border-radius: 100%;
|
|
55
|
+
color: var(--mtds-color-base-contrast-default);
|
|
56
|
+
font-weight: 500;
|
|
57
|
+
font-size: var(--mtds-body-xs-font-size);
|
|
58
|
+
line-height: var(--mtdsc-atlas-cluster-size);
|
|
59
|
+
text-align: center;
|
|
60
|
+
|
|
61
|
+
/* biome-ignore lint/complexity/noImportantStyles: need to overwrite style attribute */
|
|
62
|
+
width: var(--mtdsc-atlas-cluster-size) !important;
|
|
63
|
+
/* biome-ignore lint/complexity/noImportantStyles: need to overwrite style attribute */
|
|
64
|
+
height: var(--mtdsc-atlas-cluster-size) !important;
|
|
65
|
+
/* biome-ignore lint/complexity/noImportantStyles: need to overwrite style attribute */
|
|
66
|
+
margin: calc(var(--mtdsc-atlas-cluster-size) / -2) !important;
|
|
67
|
+
}
|
|
68
|
+
`;
|
|
69
|
+
export {
|
|
70
|
+
t as default
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=atlas.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atlas.css.js","sources":["../../designsystem/atlas/atlas.css?raw"],"sourcesContent":["export default \":host {\\n\\t--mtdsc-atlas-background: var(--ds-color-surface-default);\\n\\t--mtdsc-atlas-cluster-size: var(--mtds-8);\\n\\n\\taspect-ratio: 2; /* TODO: make possible to overwrite */\\n\\tborder-radius: var(--ds-border-radius-md);\\n\\tborder: 1px solid var(--ds-color-border-subtle);\\n\\toverflow: clip;\\n\\tposition: relative;\\n\\tuser-select: none;\\n}\\n:host(:not([hidden])) {\\n\\tdisplay: grid;\\n}\\n\\n:host([data-cursor=\\\"pointer\\\"]) .leaflet-grab {\\n\\tcursor: pointer;\\n}\\n:host([data-tiles=\\\"color\\\"]) {\\n\\t--mtdsc-atlas-background: #e0fefe;\\n}\\n:host([data-tiles=\\\"grayscale\\\"]) .leaflet-tile-container,\\n:host(:not([data-tiles])) .leaflet-tile-container {\\n\\tfilter: contrast(0.75) brightness(1.15);\\n}\\nslot {\\n\\tdisplay: grid;\\n\\tinset: var(--mtds-3);\\n\\tpointer-events: none; /* Ensure slot does not stop pointer from reaching leaflet */\\n\\tposition: absolute;\\n\\tz-index: 2;\\n}\\n::slotted(*) {\\n\\tpointer-events: all; /* But let children of slot stop pointer from reaching leaflet */\\n}\\n.leaflet-div-icon {\\n\\tbackground: none;\\n\\tborder: 0;\\n}\\n.leaflet-container {\\n\\tfont: inherit;\\n\\tbackground: var(--mtdsc-atlas-background);\\n\\toutline: 0;\\n}\\n.map-pin rect {\\n\\tfill: var(--ds-color-base-contrast-default);\\n}\\n.map-pin path {\\n\\tfill: var(--ds-color-base-default);\\n}\\n\\n.marker-cluster {\\n\\tbackground-color: var(--mtds-color-base-default);\\n\\tborder-radius: 100%;\\n\\tcolor: var(--mtds-color-base-contrast-default);\\n\\tfont-weight: 500;\\n\\tfont-size: var(--ds-body-xs-font-size);\\n\\tline-height: var(--mtdsc-atlas-cluster-size);\\n\\ttext-align: center;\\n\\n\\t/* biome-ignore lint/complexity/noImportantStyles: need to overwrite style attribute */\\n\\twidth: var(--mtdsc-atlas-cluster-size) !important;\\n\\t/* biome-ignore lint/complexity/noImportantStyles: need to overwrite style attribute */\\n\\theight: var(--mtdsc-atlas-cluster-size) !important;\\n\\t/* biome-ignore lint/complexity/noImportantStyles: need to overwrite style attribute */\\n\\tmargin: calc(var(--mtdsc-atlas-cluster-size) / -2) !important;\\n}\\n\""],"names":["css"],"mappings":"AAAA,MAAAA,IAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MTDSAtlasElement } from './atlas-element';
|
|
2
|
+
import type * as ReactTypes from "react";
|
|
3
|
+
declare global {
|
|
4
|
+
namespace React.JSX {
|
|
5
|
+
interface IntrinsicElements {
|
|
6
|
+
"mtds-atlas": AtlasProps;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export type AtlasProps = ReactTypes.DetailedHTMLProps<ReactTypes.HTMLAttributes<MTDSAtlasElement>, MTDSAtlasElement> & {
|
|
11
|
+
class?: string;
|
|
12
|
+
"data-view"?: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const Atlas: ReactTypes.ForwardRefExoticComponent<Omit<AtlasProps, "ref"> & ReactTypes.RefAttributes<MTDSAtlasElement>>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { StoryObj } from '@storybook/react-vite';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
parameters: {
|
|
5
|
+
layout: string;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export default meta;
|
|
9
|
+
type Story = StoryObj<typeof meta>;
|
|
10
|
+
export declare const Default: Story;
|
|
11
|
+
export declare const WithView: Story;
|
|
12
|
+
export declare const WithColor: Story;
|
|
13
|
+
export declare const WithCustomSize: Story;
|
|
14
|
+
export declare const WithMarker: Story;
|
|
15
|
+
export declare const WithClickToMarker: Story;
|
|
16
|
+
export declare const WithClustering: Story;
|
package/mtds/atlas.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './atlas/atlas-element';
|