@mattilsynet/design 2.2.9 → 2.2.12
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/app/app-observer.js +22 -23
- package/mtds/app/app-observer.js.map +1 -1
- package/mtds/breadcrumbs/breadcrumbs-observer.js +10 -15
- package/mtds/breadcrumbs/breadcrumbs-observer.js.map +1 -1
- package/mtds/button/button.js +9 -8
- package/mtds/button/button.js.map +1 -1
- package/mtds/card/card.stories.d.ts +1 -0
- package/mtds/chart/chart-axis.d.ts +2 -1
- package/mtds/chart/chart-axis.js +16 -16
- package/mtds/chart/chart-axis.js.map +1 -1
- package/mtds/chart/chart-element.d.ts +2 -0
- package/mtds/chart/chart-element.js +55 -41
- package/mtds/chart/chart-element.js.map +1 -1
- package/mtds/chart/chart-lines.d.ts +1 -1
- package/mtds/chart/chart-lines.js +30 -30
- package/mtds/chart/chart-lines.js.map +1 -1
- package/mtds/chart/chart-pies.d.ts +5 -2
- package/mtds/chart/chart-pies.js +10 -10
- package/mtds/chart/chart-pies.js.map +1 -1
- package/mtds/chart/chart.css.js +105 -38
- package/mtds/chart/chart.css.js.map +1 -1
- package/mtds/chart/chart.d.ts +4 -0
- package/mtds/chart/chart.js +9 -9
- package/mtds/chart/chart.js.map +1 -1
- package/mtds/chart/chart.stories.d.ts +5 -3
- package/mtds/dialog/dialog-observer.js +25 -28
- package/mtds/dialog/dialog-observer.js.map +1 -1
- package/mtds/errorsummary/errorsummary-observer.js +3 -3
- package/mtds/errorsummary/errorsummary-observer.js.map +1 -1
- package/mtds/field/field-observer.js +49 -44
- package/mtds/field/field-observer.js.map +1 -1
- package/mtds/fieldset/fieldset-observer.js +14 -16
- package/mtds/fieldset/fieldset-observer.js.map +1 -1
- package/mtds/index.iife.js +114 -47
- package/mtds/lawpicker/lawpicker-element.d.ts +18 -0
- package/mtds/lawpicker/lawpicker.stories.d.ts +10 -0
- package/mtds/logo/logo-observer.js +11 -12
- package/mtds/logo/logo-observer.js.map +1 -1
- package/mtds/map/map-element.d.ts +1 -1
- package/mtds/map/map-element.js +53 -47
- package/mtds/map/map-element.js.map +1 -1
- package/mtds/map/map.css.js +1 -1
- package/mtds/map/map.css.js.map +1 -1
- package/mtds/map.iife.js +6 -6
- package/mtds/package.json.js +1 -1
- package/mtds/popover/popover-observer.js +25 -19
- package/mtds/popover/popover-observer.js.map +1 -1
- package/mtds/styles.css +1 -1
- package/mtds/styles.json +20 -20
- package/mtds/styles.module.css.js +31 -31
- package/mtds/table/table-observer.js +18 -17
- package/mtds/table/table-observer.js.map +1 -1
- package/mtds/toast/toast-observer.js +4 -3
- package/mtds/toast/toast-observer.js.map +1 -1
- package/mtds/togglegroup/togglegroup-observer.js +1 -1
- package/mtds/togglegroup/togglegroup-observer.js.map +1 -1
- package/mtds/tooltip/tooltip-observer.js +36 -28
- package/mtds/tooltip/tooltip-observer.js.map +1 -1
- package/mtds/utils.d.ts +9 -5
- package/mtds/utils.js +55 -69
- package/mtds/utils.js.map +1 -1
- package/package.json +23 -17
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { MTDSElement } from '../utils';
|
|
2
|
+
import type * as ReactTypes from "react";
|
|
3
|
+
type JSXMapAttrs = ReactTypes.HTMLAttributes<MTDLovvelgerElement>;
|
|
4
|
+
type JSXMapProps = ReactTypes.DetailedHTMLProps<JSXMapAttrs, MTDLovvelgerElement>;
|
|
5
|
+
declare global {
|
|
6
|
+
namespace React.JSX {
|
|
7
|
+
interface IntrinsicElements {
|
|
8
|
+
"mtds-lovvelger": JSXMapProps & {
|
|
9
|
+
class?: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export declare class MTDLovvelgerElement extends MTDSElement {
|
|
15
|
+
constructor();
|
|
16
|
+
connectedCallback(): void;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import a from "../styles.module.css.js";
|
|
2
|
-
import {
|
|
3
|
-
const
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
import { IS_BROWSER as c, onLoaded as d, onMutation as g, tag as h } from "../utils.js";
|
|
3
|
+
const m = a.logo.split(" ")[0], p = c ? document.getElementsByClassName(m) : [];
|
|
4
|
+
function u() {
|
|
5
|
+
const e = p[0], t = e?.firstElementChild;
|
|
6
|
+
if (t instanceof SVGSVGElement) {
|
|
7
|
+
for (const i of document.head.querySelectorAll("link[rel~='icon']"))
|
|
8
|
+
i.setAttribute("rel", "disabled");
|
|
9
|
+
const o = e?.hasAttribute("data-env"), n = window.getComputedStyle(t), s = n.getPropertyValue("color"), l = n.getPropertyValue("--mtds-logo-color"), r = t.outerHTML.replace(/\n+/g, " ").replace(/(fill|width|height|xmlns)="[^"]+"/gi, "").replace("<svg", `<svg width="40" height="40" fill="${s}"`);
|
|
9
10
|
document.head.appendChild(
|
|
10
|
-
|
|
11
|
-
href: `data:image/svg+xml,${encodeURIComponent(`<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 55 55'><rect fill='${o ? "none" :
|
|
11
|
+
h("link", {
|
|
12
|
+
href: `data:image/svg+xml,${encodeURIComponent(`<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 55 55'><rect fill='${o ? "none" : l}' width='51' height='51' x='2' y='2' stroke='${s}' stroke-dasharray='0.09 6.38' stroke-linecap='round' stroke-opacity='${o ? 0.6 : 0}' stroke-width='2.3' rx='25.5'/><g transform="translate(7.5 7.5)">${r}</g></svg>`)}`,
|
|
12
13
|
rel: "icon"
|
|
13
14
|
})
|
|
14
15
|
);
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
-
() => d(document.documentElement, h, m)
|
|
19
|
-
);
|
|
18
|
+
d(() => [g(u, "class")]);
|
|
20
19
|
//# sourceMappingURL=logo-observer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logo-observer.js","sources":["../../designsystem/logo/logo-observer.ts"],"sourcesContent":["import styles from \"../styles.module.css\";\nimport { onLoaded, onMutation, tag } from \"../utils\";\n\nconst CSS_LOGO = styles.logo.split(\" \")[0];\n\nfunction handleLogoMutation(
|
|
1
|
+
{"version":3,"file":"logo-observer.js","sources":["../../designsystem/logo/logo-observer.ts"],"sourcesContent":["import styles from \"../styles.module.css\";\nimport { IS_BROWSER, onLoaded, onMutation, tag } from \"../utils\";\n\nconst CSS_LOGO = styles.logo.split(\" \")[0];\nconst LOGOS = IS_BROWSER ? document.getElementsByClassName(CSS_LOGO) : [];\n\nfunction handleLogoMutation() {\n\tconst logo = LOGOS[0];\n\tconst svg = logo?.firstElementChild;\n\n\tif (svg instanceof SVGSVGElement) {\n\t\tfor (const icon of document.head.querySelectorAll(\"link[rel~='icon']\"))\n\t\t\ticon.setAttribute(\"rel\", \"disabled\"); // Disable previous icon (but not remove is as this makes Next.js sad)\n\n\t\tconst isDot = logo?.hasAttribute(\"data-env\");\n\t\tconst style = window.getComputedStyle(svg);\n\t\tconst text = style.getPropertyValue(\"color\");\n\t\tconst back = style.getPropertyValue(\"--mtds-logo-color\");\n\t\tconst icon = svg.outerHTML\n\t\t\t.replace(/\\n+/g, \" \") // Prevent line breaks\n\t\t\t.replace(/(fill|width|height|xmlns)=\"[^\"]+\"/gi, \"\")\n\t\t\t.replace(\"<svg\", `<svg width=\"40\" height=\"40\" fill=\"${text}\"`);\n\n\t\tdocument.head.appendChild(\n\t\t\ttag(\"link\", {\n\t\t\t\thref: `data:image/svg+xml,${encodeURIComponent(`<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 55 55'><rect fill='${isDot ? \"none\" : back}' width='51' height='51' x='2' y='2' stroke='${text}' stroke-dasharray='0.09 6.38' stroke-linecap='round' stroke-opacity='${isDot ? 0.6 : 0}' stroke-width='2.3' rx='25.5'/><g transform=\"translate(7.5 7.5)\">${icon}</g></svg>`)}`,\n\t\t\t\trel: \"icon\",\n\t\t\t}),\n\t\t);\n\t}\n}\n\nonLoaded(() => [onMutation(handleLogoMutation, \"class\")]);\n"],"names":["CSS_LOGO","styles","LOGOS","IS_BROWSER","handleLogoMutation","logo","svg","icon","isDot","style","text","back","tag","onLoaded","onMutation"],"mappings":";;AAGA,MAAMA,IAAWC,EAAO,KAAK,MAAM,GAAG,EAAE,CAAC,GACnCC,IAAQC,IAAa,SAAS,uBAAuBH,CAAQ,IAAI,CAAA;AAEvE,SAASI,IAAqB;AAC7B,QAAMC,IAAOH,EAAM,CAAC,GACdI,IAAMD,GAAM;AAElB,MAAIC,aAAe,eAAe;AACjC,eAAWC,KAAQ,SAAS,KAAK,iBAAiB,mBAAmB;AACpEA,MAAAA,EAAK,aAAa,OAAO,UAAU;AAEpC,UAAMC,IAAQH,GAAM,aAAa,UAAU,GACrCI,IAAQ,OAAO,iBAAiBH,CAAG,GACnCI,IAAOD,EAAM,iBAAiB,OAAO,GACrCE,IAAOF,EAAM,iBAAiB,mBAAmB,GACjDF,IAAOD,EAAI,UACf,QAAQ,QAAQ,GAAG,EACnB,QAAQ,uCAAuC,EAAE,EACjD,QAAQ,QAAQ,qCAAqCI,CAAI,GAAG;AAE9D,aAAS,KAAK;AAAA,MACbE,EAAI,QAAQ;AAAA,QACX,MAAM,sBAAsB,mBAAmB,2EAA2EJ,IAAQ,SAASG,CAAI,gDAAgDD,CAAI,yEAAyEF,IAAQ,MAAM,CAAC,qEAAqED,CAAI,YAAY,CAAC;AAAA,QACjX,KAAK;AAAA,MAAA,CACL;AAAA,IAAA;AAAA,EAEH;AACD;AAEAM,EAAS,MAAM,CAACC,EAAWV,GAAoB,OAAO,CAAC,CAAC;"}
|
|
@@ -18,7 +18,7 @@ export declare class MTDSMapElement extends MTDSElement {
|
|
|
18
18
|
cluster: L.MarkerClusterGroup;
|
|
19
19
|
constructor();
|
|
20
20
|
connectedCallback(): void;
|
|
21
|
-
addMarker(
|
|
21
|
+
addMarker(latlng: L.LatLngExpression, options: L.MarkerOptions): L.Marker<any>;
|
|
22
22
|
disconnectedCallback(): void;
|
|
23
23
|
}
|
|
24
24
|
export type Adresse = {
|
package/mtds/map/map-element.js
CHANGED
|
@@ -1,76 +1,82 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import * as n from "leaflet";
|
|
2
|
+
import p from "leaflet/dist/leaflet.css?raw";
|
|
3
|
+
import i from "leaflet.markercluster/dist/MarkerCluster.css?raw";
|
|
4
4
|
import "leaflet.markercluster";
|
|
5
|
-
import { IS_BROWSER as
|
|
6
|
-
import
|
|
7
|
-
|
|
5
|
+
import { IS_BROWSER as l, MTDSElement as u, tag as r, attr as c } from "../utils.js";
|
|
6
|
+
import h from "./map.css.js";
|
|
7
|
+
n.Marker.prototype.options.icon = n.divIcon({
|
|
8
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
9
|
iconAnchor: [15, 30],
|
|
10
10
|
iconSize: [30, 30]
|
|
11
11
|
});
|
|
12
|
-
const
|
|
13
|
-
class
|
|
12
|
+
const d = "https://cache.kartverket.no/v1/wmts/1.0.0/topograatone/default/webmercator/{z}/{y}/{x}.png";
|
|
13
|
+
class k extends u {
|
|
14
14
|
map;
|
|
15
15
|
cluster;
|
|
16
16
|
constructor() {
|
|
17
17
|
super();
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
${
|
|
21
|
-
${
|
|
22
|
-
showCoverageOnHover: !1
|
|
18
|
+
const o = new CSSStyleSheet();
|
|
19
|
+
o.replaceSync(`${p}
|
|
20
|
+
${i}
|
|
21
|
+
${h}`), this.attachShadow({ mode: "open" }).adoptedStyleSheets = [o], this.shadowRoot?.append(r("slot"), r("div")), this.cluster = n.markerClusterGroup({
|
|
22
|
+
showCoverageOnHover: !1,
|
|
23
|
+
disableClusteringAtZoom: 1
|
|
23
24
|
});
|
|
24
25
|
}
|
|
25
26
|
connectedCallback() {
|
|
26
|
-
|
|
27
|
+
const o = `[${c(this, "data-view") || "57.95, 4.73, 71.19, 31.44, 15"}]`, e = JSON.parse(o);
|
|
28
|
+
if (this.map = n.map(this.shadowRoot?.lastElementChild, {
|
|
29
|
+
layers: [n.tileLayer(d, { maxZoom: 18 }), this.cluster],
|
|
27
30
|
attributionControl: !1,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
})
|
|
31
|
+
wheelPxPerZoomLevel: 10,
|
|
32
|
+
zoomControl: !1,
|
|
33
|
+
zoomSnap: 0
|
|
34
|
+
}), this.map.addControl(n.control.zoom({ position: "bottomright" })), e.length === 3 && this.map.setView([e[0], e[1]], e[2]), e.length >= 4) {
|
|
35
|
+
const t = [e[0], e[1]], m = [e[2], e[3]], a = [e[4] ?? 0, e[5] ?? e[4] ?? 0];
|
|
36
|
+
this.map.fitBounds([t, m], { padding: a });
|
|
37
|
+
}
|
|
32
38
|
}
|
|
33
|
-
addMarker(
|
|
34
|
-
return
|
|
39
|
+
addMarker(o, e) {
|
|
40
|
+
return n.marker(o, e).addTo(this.cluster);
|
|
35
41
|
}
|
|
36
42
|
disconnectedCallback() {
|
|
37
43
|
this.map?.remove();
|
|
38
44
|
}
|
|
39
45
|
}
|
|
40
|
-
|
|
41
|
-
async function
|
|
46
|
+
l && !window.customElements.get("mtds-map") && window.customElements.define("mtds-map", k);
|
|
47
|
+
async function b(s) {
|
|
42
48
|
try {
|
|
43
|
-
const
|
|
44
|
-
`https://ws.geonorge.no/adresser/v1/sok?sok=${
|
|
49
|
+
const e = await (await fetch(
|
|
50
|
+
`https://ws.geonorge.no/adresser/v1/sok?sok=${s}&fuzzy=false&utkoordsys=3857&treffPerSide=100&asciiKompatibel=true`
|
|
45
51
|
)).json();
|
|
46
|
-
return
|
|
47
|
-
adressekode:
|
|
48
|
-
adressetekst:
|
|
49
|
-
bokstav:
|
|
50
|
-
bruksenhetsnummer:
|
|
51
|
-
bruksnummer:
|
|
52
|
-
festenummer:
|
|
53
|
-
gardsnummer:
|
|
54
|
-
kommunenavn:
|
|
55
|
-
kommunenummer:
|
|
56
|
-
nummer:
|
|
57
|
-
objtype:
|
|
58
|
-
oppdateringsdato:
|
|
59
|
-
postnummer:
|
|
60
|
-
poststed:
|
|
52
|
+
return e.adresser.length > 0 ? e.adresser.map((t) => ({
|
|
53
|
+
adressekode: t.adressekode,
|
|
54
|
+
adressetekst: t.adressetekst,
|
|
55
|
+
bokstav: t.bokstav,
|
|
56
|
+
bruksenhetsnummer: t.bruksenhetsnummer,
|
|
57
|
+
bruksnummer: t.bruksnummer,
|
|
58
|
+
festenummer: t.festenummer,
|
|
59
|
+
gardsnummer: t.gardsnummer,
|
|
60
|
+
kommunenavn: t.kommunenavn,
|
|
61
|
+
kommunenummer: t.kommunenummer,
|
|
62
|
+
nummer: t.nummer,
|
|
63
|
+
objtype: t.objtype,
|
|
64
|
+
oppdateringsdato: t.oppdateringsdato,
|
|
65
|
+
postnummer: t.postnummer,
|
|
66
|
+
poststed: t.poststed,
|
|
61
67
|
representasjonspunkt: {
|
|
62
|
-
epsg:
|
|
63
|
-
lat:
|
|
64
|
-
lon:
|
|
68
|
+
epsg: t.representasjonspunkt.epsg,
|
|
69
|
+
lat: t.representasjonspunkt.lat,
|
|
70
|
+
lon: t.representasjonspunkt.lon
|
|
65
71
|
}
|
|
66
72
|
})) : [];
|
|
67
|
-
} catch (
|
|
68
|
-
return console.log(`Feilet i å hente adresse fra punkt: ${
|
|
73
|
+
} catch (o) {
|
|
74
|
+
return console.log(`Feilet i å hente adresse fra punkt: ${o}`), [];
|
|
69
75
|
}
|
|
70
76
|
}
|
|
71
77
|
export {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
78
|
+
n as L,
|
|
79
|
+
k as MTDSMapElement,
|
|
80
|
+
b as getPunktFraAdresse
|
|
75
81
|
};
|
|
76
82
|
//# sourceMappingURL=map-element.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map-element.js","sources":["../../designsystem/map/map-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 \"leaflet.markercluster\";\nimport type * as ReactTypes from \"react\";\nimport { IS_BROWSER, MTDSElement, tag } from \"../utils\";\nimport MapCss from \"./map.css?raw\";\n\ntype JSXMapAttrs = ReactTypes.HTMLAttributes<MTDSMapElement>;\ntype JSXMapProps = ReactTypes.DetailedHTMLProps<JSXMapAttrs, MTDSMapElement>;\ndeclare global {\n\tnamespace React.JSX {\n\t\tinterface IntrinsicElements {\n\t\t\t\"mtds-map\": JSXMapProps & { class?: string };\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\nconst KARTVERKET_GRAY =\n\t\"https://cache.kartverket.no/v1/wmts/1.0.0/topograatone/default/webmercator/{z}/{y}/{x}.png\";\n\nexport { L };\nexport class MTDSMapElement extends MTDSElement {\n\tmap?: L.Map;\n\tcluster: L.MarkerClusterGroup;\n\n\tconstructor() {\n\t\tsuper();\n\t\tconst sheet = new CSSStyleSheet();\n\t\tsheet.replaceSync(`${LeafletCSS}\\n${LeafletClusterCSS}\\n${MapCss}`);\n\t\tthis.attachShadow({ mode: \"open\" }).adoptedStyleSheets = [sheet];\n\t\tthis.shadowRoot?.append(tag(\"slot\"), tag(\"div\"));\n\t\tthis.cluster = L.markerClusterGroup({\n\t\t\tshowCoverageOnHover: false,\n\t\t});\n\t}\n\tconnectedCallback() {\n\t\tthis.map = L.map(this.shadowRoot?.lastElementChild as HTMLElement, {\n\t\t\tattributionControl: false,\n\t\t\
|
|
1
|
+
{"version":3,"file":"map-element.js","sources":["../../designsystem/map/map-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 \"leaflet.markercluster\";\nimport type * as ReactTypes from \"react\";\nimport { attr, IS_BROWSER, MTDSElement, tag } from \"../utils\";\nimport MapCss from \"./map.css?raw\";\n\ntype JSXMapAttrs = ReactTypes.HTMLAttributes<MTDSMapElement>;\ntype JSXMapProps = ReactTypes.DetailedHTMLProps<JSXMapAttrs, MTDSMapElement>;\ndeclare global {\n\tnamespace React.JSX {\n\t\tinterface IntrinsicElements {\n\t\t\t\"mtds-map\": JSXMapProps & { class?: string };\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 KARTVERKET_GRAY =\n\t\"https://cache.kartverket.no/v1/wmts/1.0.0/topograatone/default/webmercator/{z}/{y}/{x}.png\";\n\nexport { L };\nexport class MTDSMapElement extends MTDSElement {\n\tmap?: L.Map;\n\tcluster: L.MarkerClusterGroup;\n\n\tconstructor() {\n\t\tsuper();\n\t\tconst sheet = new CSSStyleSheet();\n\t\tsheet.replaceSync(`${LeafletCSS}\\n${LeafletClusterCSS}\\n${MapCss}`);\n\t\tthis.attachShadow({ mode: \"open\" }).adoptedStyleSheets = [sheet];\n\t\tthis.shadowRoot?.append(tag(\"slot\"), tag(\"div\"));\n\t\tthis.cluster = L.markerClusterGroup({\n\t\t\tshowCoverageOnHover: false,\n\t\t\tdisableClusteringAtZoom: 1,\n\t\t});\n\t}\n\tconnectedCallback() {\n\t\tconst json = `[${attr(this, \"data-view\") || \"57.95, 4.73, 71.19, 31.44, 15\"}]`;\n\t\tconst view = JSON.parse(json);\n\n\t\tthis.map = L.map(this.shadowRoot?.lastElementChild as HTMLElement, {\n\t\t\tlayers: [L.tileLayer(KARTVERKET_GRAY, { maxZoom: 18 }), this.cluster],\n\t\t\tattributionControl: false,\n\t\t\twheelPxPerZoomLevel: 10,\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);\n\t}\n\tdisconnectedCallback() {\n\t\tthis.map?.remove();\n\t}\n}\n\nif (IS_BROWSER && !window.customElements.get(\"mtds-map\"))\n\twindow.customElements.define(\"mtds-map\", MTDSMapElement);\n\nexport 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\nexport 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","KARTVERKET_GRAY","MTDSMapElement","MTDSElement","sheet","LeafletCSS","LeafletClusterCSS","MapCss","tag","json","attr","view","nw","se","padding","latlng","options","IS_BROWSER","getPunktFraAdresse","adresseSoek","jsonresponse","adresse","error"],"mappings":"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"}
|
package/mtds/map/map.css.js
CHANGED
package/mtds/map/map.css.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map.css.js","sources":["../../designsystem/map/map.css?raw"],"sourcesContent":["export default \":host {\\n\\taspect-ratio: 2
|
|
1
|
+
{"version":3,"file":"map.css.js","sources":["../../designsystem/map/map.css?raw"],"sourcesContent":["export default \":host {\\n\\taspect-ratio: 2; /* TODO: make possible to overwrite */\\n\\tbackground: var(--ds-color-neutral-surface-tinted);\\n\\tborder-radius: var(--ds-border-radius-md);\\n\\toverflow: clip;\\n\\tposition: relative;\\n\\tuser-select: none;\\n}\\n:host(:not([hidden])) {\\n\\tdisplay: grid;\\n}\\nslot {\\n\\tdisplay: grid;\\n\\tinset: var(--mtds-3);\\n\\tpointer-events: none;\\n\\tposition: absolute;\\n\\tz-index: 2;\\n}\\n::slotted(*) {\\n\\tpointer-events: all;\\n}\\n.leaflet-div-icon {\\n\\tbackground: none;\\n\\tborder: 0;\\n}\\n.leaflet-container {\\n\\tbackground: var(--ds-color-neutral-surface-tinted);\\n}\\n.leaflet-container {\\n\\toutline: 0;\\n}\\n.leaflet-tile-container {\\n\\tfilter: contrast(0.75) brightness(1.15);\\n}\\n\\n.map-pin rect {\\n\\tfill: var(--ds-color-surface-default);\\n}\\n.map-pin path {\\n\\tfill: var(--ds-color-text-default);\\n}\\n\""],"names":["MapCss"],"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;"}
|