@mattilsynet/design 2.2.7 → 2.2.9
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/card/card.js +9 -8
- package/mtds/card/card.js.map +1 -1
- package/mtds/chart/chart-element.js +34 -31
- package/mtds/chart/chart-element.js.map +1 -1
- package/mtds/chart/chart-pies.js +10 -9
- package/mtds/chart/chart-pies.js.map +1 -1
- package/mtds/chart/chart.js +10 -5
- package/mtds/chart/chart.js.map +1 -1
- package/mtds/dialog/dialog-observer.js +20 -19
- package/mtds/dialog/dialog-observer.js.map +1 -1
- package/mtds/dialog/dialog.stories.d.ts +3 -1
- package/mtds/field/field-observer.js +43 -52
- package/mtds/field/field-observer.js.map +1 -1
- package/mtds/index.d.ts +0 -1
- package/mtds/index.iife.js +15 -15
- package/mtds/map/map-element.d.ts +7 -3
- package/mtds/map/map-element.js +55 -45
- package/mtds/map/map-element.js.map +1 -1
- package/mtds/map/map.css.js +30 -6
- package/mtds/map/map.css.js.map +1 -1
- package/mtds/map.iife.js +47 -8
- package/mtds/map.js +5 -3
- package/mtds/map.js.map +1 -1
- package/mtds/package.json.js +1 -1
- package/mtds/popover/popover-observer.js +25 -31
- package/mtds/popover/popover-observer.js.map +1 -1
- package/mtds/styles.css +1 -1
- package/mtds/styles.json +41 -42
- package/mtds/styles.module.css.js +72 -74
- package/mtds/styles.module.css.js.map +1 -1
- package/mtds/toast/toast.stories.d.ts +2 -2
- package/mtds/utils.d.ts +6 -2
- package/mtds/utils.js +68 -55
- package/mtds/utils.js.map +1 -1
- package/package.json +5 -3
package/mtds/map/map-element.js
CHANGED
|
@@ -1,66 +1,76 @@
|
|
|
1
|
-
import o from "leaflet";
|
|
2
|
-
import m from "leaflet/dist/
|
|
3
|
-
import a from "leaflet/dist/
|
|
4
|
-
import
|
|
5
|
-
import { IS_BROWSER as
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
class
|
|
1
|
+
import * as o from "leaflet";
|
|
2
|
+
import m from "leaflet/dist/leaflet.css?raw";
|
|
3
|
+
import a from "leaflet.markercluster/dist/MarkerCluster.css?raw";
|
|
4
|
+
import "leaflet.markercluster";
|
|
5
|
+
import { IS_BROWSER as p, MTDSElement as u, tag as s } from "../utils.js";
|
|
6
|
+
import i from "./map.css.js";
|
|
7
|
+
o.Marker.prototype.options.icon = o.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 l = "https://cache.kartverket.no/v1/wmts/1.0.0/topograatone/default/webmercator/{z}/{y}/{x}.png";
|
|
13
|
+
class c extends u {
|
|
9
14
|
map;
|
|
15
|
+
cluster;
|
|
10
16
|
constructor() {
|
|
11
17
|
super();
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
${
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
shadowUrl: a
|
|
18
|
+
const t = new CSSStyleSheet();
|
|
19
|
+
t.replaceSync(`${m}
|
|
20
|
+
${a}
|
|
21
|
+
${i}`), this.attachShadow({ mode: "open" }).adoptedStyleSheets = [t], this.shadowRoot?.append(s("slot"), s("div")), this.cluster = o.markerClusterGroup({
|
|
22
|
+
showCoverageOnHover: !1
|
|
18
23
|
});
|
|
19
24
|
}
|
|
20
25
|
connectedCallback() {
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
this.map = o.map(this.shadowRoot?.lastElementChild, {
|
|
27
|
+
attributionControl: !1,
|
|
28
|
+
center: [63.43067801397488, 10.402166438219403],
|
|
29
|
+
zoom: 13,
|
|
30
|
+
layers: [o.tileLayer(l, { maxZoom: 18 }), this.cluster]
|
|
31
|
+
});
|
|
23
32
|
}
|
|
24
|
-
|
|
25
|
-
|
|
33
|
+
addMarker(t) {
|
|
34
|
+
return o.marker(t).addTo(this.cluster);
|
|
26
35
|
}
|
|
27
36
|
disconnectedCallback() {
|
|
28
|
-
|
|
37
|
+
this.map?.remove();
|
|
29
38
|
}
|
|
30
39
|
}
|
|
31
|
-
|
|
32
|
-
async function
|
|
40
|
+
p && !window.customElements.get("mtds-map") && window.customElements.define("mtds-map", c);
|
|
41
|
+
async function S(r) {
|
|
33
42
|
try {
|
|
34
|
-
const
|
|
35
|
-
`https://ws.geonorge.no/adresser/v1/sok?sok=${
|
|
43
|
+
const n = await (await fetch(
|
|
44
|
+
`https://ws.geonorge.no/adresser/v1/sok?sok=${r}&fuzzy=false&utkoordsys=3857&treffPerSide=100&asciiKompatibel=true`
|
|
36
45
|
)).json();
|
|
37
|
-
return
|
|
38
|
-
adressekode:
|
|
39
|
-
adressetekst:
|
|
40
|
-
bokstav:
|
|
41
|
-
bruksenhetsnummer:
|
|
42
|
-
bruksnummer:
|
|
43
|
-
festenummer:
|
|
44
|
-
gardsnummer:
|
|
45
|
-
kommunenavn:
|
|
46
|
-
kommunenummer:
|
|
47
|
-
nummer:
|
|
48
|
-
objtype:
|
|
49
|
-
oppdateringsdato:
|
|
50
|
-
postnummer:
|
|
51
|
-
poststed:
|
|
46
|
+
return n.adresser.length > 0 ? n.adresser.map((e) => ({
|
|
47
|
+
adressekode: e.adressekode,
|
|
48
|
+
adressetekst: e.adressetekst,
|
|
49
|
+
bokstav: e.bokstav,
|
|
50
|
+
bruksenhetsnummer: e.bruksenhetsnummer,
|
|
51
|
+
bruksnummer: e.bruksnummer,
|
|
52
|
+
festenummer: e.festenummer,
|
|
53
|
+
gardsnummer: e.gardsnummer,
|
|
54
|
+
kommunenavn: e.kommunenavn,
|
|
55
|
+
kommunenummer: e.kommunenummer,
|
|
56
|
+
nummer: e.nummer,
|
|
57
|
+
objtype: e.objtype,
|
|
58
|
+
oppdateringsdato: e.oppdateringsdato,
|
|
59
|
+
postnummer: e.postnummer,
|
|
60
|
+
poststed: e.poststed,
|
|
52
61
|
representasjonspunkt: {
|
|
53
|
-
epsg:
|
|
54
|
-
lat:
|
|
55
|
-
lon:
|
|
62
|
+
epsg: e.representasjonspunkt.epsg,
|
|
63
|
+
lat: e.representasjonspunkt.lat,
|
|
64
|
+
lon: e.representasjonspunkt.lon
|
|
56
65
|
}
|
|
57
66
|
})) : [];
|
|
58
|
-
} catch (
|
|
59
|
-
return console.log(`Feilet i å hente adresse fra punkt: ${
|
|
67
|
+
} catch (t) {
|
|
68
|
+
return console.log(`Feilet i å hente adresse fra punkt: ${t}`), [];
|
|
60
69
|
}
|
|
61
70
|
}
|
|
62
71
|
export {
|
|
63
|
-
|
|
64
|
-
|
|
72
|
+
o as L,
|
|
73
|
+
c as MTDSMapElement,
|
|
74
|
+
S as getPunktFraAdresse
|
|
65
75
|
};
|
|
66
76
|
//# sourceMappingURL=map-element.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map-element.js","sources":["../../designsystem/map/map-element.ts"],"sourcesContent":["import
|
|
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\tcenter: [63.43067801397488, 10.402166438219403],\n\t\t\tzoom: 13,\n\t\t\tlayers: [L.tileLayer(KARTVERKET_GRAY, { maxZoom: 18 }), this.cluster],\n\t\t});\n\t}\n\taddMarker(point: L.LatLngExpression) {\n\t\treturn L.marker(point).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","point","IS_BROWSER","getPunktFraAdresse","adresseSoek","jsonresponse","adresse","error"],"mappings":";;;;;;AAkBAA,EAAE,OAAO,UAAU,QAAQ,OAAOA,EAAE,QAAQ;AAAA,EAC3C,MAAM;AAAA,EACN,YAAY,CAAC,IAAI,EAAE;AAAA,EACnB,UAAU,CAAC,IAAI,EAAE;AAClB,CAAC;AAED,MAAMC,IACL;AAGM,MAAMC,UAAuBC,EAAY;AAAA,EAC/C;AAAA,EACA;AAAA,EAEA,cAAc;AACb,UAAA;AACA,UAAMC,IAAQ,IAAI,cAAA;AAClB,IAAAA,EAAM,YAAY,GAAGC,CAAU;AAAA,EAAKC,CAAiB;AAAA,EAAKC,CAAM,EAAE,GAClE,KAAK,aAAa,EAAE,MAAM,OAAA,CAAQ,EAAE,qBAAqB,CAACH,CAAK,GAC/D,KAAK,YAAY,OAAOI,EAAI,MAAM,GAAGA,EAAI,KAAK,CAAC,GAC/C,KAAK,UAAUR,EAAE,mBAAmB;AAAA,MACnC,qBAAqB;AAAA,IAAA,CACrB;AAAA,EACF;AAAA,EACA,oBAAoB;AACnB,SAAK,MAAMA,EAAE,IAAI,KAAK,YAAY,kBAAiC;AAAA,MAClE,oBAAoB;AAAA,MACpB,QAAQ,CAAC,mBAAmB,kBAAkB;AAAA,MAC9C,MAAM;AAAA,MACN,QAAQ,CAACA,EAAE,UAAUC,GAAiB,EAAE,SAAS,GAAA,CAAI,GAAG,KAAK,OAAO;AAAA,IAAA,CACpE;AAAA,EACF;AAAA,EACA,UAAUQ,GAA2B;AACpC,WAAOT,EAAE,OAAOS,CAAK,EAAE,MAAM,KAAK,OAAO;AAAA,EAC1C;AAAA,EACA,uBAAuB;AACtB,SAAK,KAAK,OAAA;AAAA,EACX;AACD;AAEIC,KAAc,CAAC,OAAO,eAAe,IAAI,UAAU,KACtD,OAAO,eAAe,OAAO,YAAYR,CAAc;AA2BxD,eAAsBS,EACrBC,GACqB;AACrB,MAAI;AAIH,UAAMC,IAAe,OAHJ,MAAM;AAAA,MACtB,8CAA8CD,CAAW;AAAA,IAAA,GAEtB,KAAA;AACpC,WAAIC,EAAa,SAAS,SAAS,IAC3BA,EAAa,SAAS,IAAI,CAACC,OAAsB;AAAA,MACvD,aAAaA,EAAQ;AAAA,MACrB,cAAcA,EAAQ;AAAA,MACtB,SAASA,EAAQ;AAAA,MACjB,mBAAmBA,EAAQ;AAAA,MAC3B,aAAaA,EAAQ;AAAA,MACrB,aAAaA,EAAQ;AAAA,MACrB,aAAaA,EAAQ;AAAA,MACrB,aAAaA,EAAQ;AAAA,MACrB,eAAeA,EAAQ;AAAA,MACvB,QAAQA,EAAQ;AAAA,MAChB,SAASA,EAAQ;AAAA,MACjB,kBAAkBA,EAAQ;AAAA,MAC1B,YAAYA,EAAQ;AAAA,MACpB,UAAUA,EAAQ;AAAA,MAClB,sBAAsB;AAAA,QACrB,MAAMA,EAAQ,qBAAqB;AAAA,QACnC,KAAKA,EAAQ,qBAAqB;AAAA,QAClC,KAAKA,EAAQ,qBAAqB;AAAA,MAAA;AAAA,IACnC,EACC,IAEK,CAAA;AAAA,EAET,SAASC,GAAO;AACf,mBAAQ,IAAI,uCAAuCA,CAAK,EAAE,GACnD,CAAA;AAAA,EACR;AACD;"}
|
package/mtds/map/map.css.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
const
|
|
1
|
+
const n = `:host {
|
|
2
|
+
aspect-ratio: 2;
|
|
2
3
|
background: var(--mtds-color-neutral-surface-tinted);
|
|
3
|
-
|
|
4
|
+
border-radius: var(--mtds-border-radius-md);
|
|
5
|
+
overflow: clip;
|
|
4
6
|
position: relative;
|
|
7
|
+
user-select: none;
|
|
8
|
+
}
|
|
9
|
+
:host(:not([hidden])) {
|
|
10
|
+
display: grid;
|
|
5
11
|
}
|
|
6
|
-
|
|
12
|
+
slot {
|
|
7
13
|
display: grid;
|
|
8
14
|
inset: var(--mtds-3);
|
|
9
15
|
pointer-events: none;
|
|
@@ -13,10 +19,28 @@ const t = `:host {
|
|
|
13
19
|
::slotted(*) {
|
|
14
20
|
pointer-events: all;
|
|
15
21
|
}
|
|
16
|
-
|
|
22
|
+
.leaflet-div-icon {
|
|
23
|
+
background: none;
|
|
24
|
+
border: 0;
|
|
25
|
+
}
|
|
26
|
+
.leaflet-container {
|
|
27
|
+
background: var(--mtds-color-neutral-surface-tinted);
|
|
28
|
+
}
|
|
29
|
+
.leaflet-container {
|
|
17
30
|
outline: 0;
|
|
18
|
-
}
|
|
31
|
+
}
|
|
32
|
+
.leaflet-tile-container {
|
|
33
|
+
filter: contrast(0.75) brightness(1.15);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.map-pin rect {
|
|
37
|
+
fill: var(--mtds-color-surface-default);
|
|
38
|
+
}
|
|
39
|
+
.map-pin path {
|
|
40
|
+
fill: var(--mtds-color-text-default);
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
19
43
|
export {
|
|
20
|
-
|
|
44
|
+
n as default
|
|
21
45
|
};
|
|
22
46
|
//# sourceMappingURL=map.css.js.map
|
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\\tbackground: var(--ds-color-neutral-surface-tinted);\\n\\
|
|
1
|
+
{"version":3,"file":"map.css.js","sources":["../../designsystem/map/map.css?raw"],"sourcesContent":["export default \":host {\\n\\taspect-ratio: 2;\\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;"}
|