@mattilsynet/design 2.2.20 → 2.2.22

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.
@@ -7,6 +7,9 @@ declare global {
7
7
  interface IntrinsicElements {
8
8
  "mtds-atlas": ReactTypes.DetailedHTMLProps<ReactTypes.HTMLAttributes<MTDSAtlasElement>, MTDSAtlasElement> & {
9
9
  class?: string;
10
+ "data-cluster"?: number | `${number}` | boolean | "true" | "false";
11
+ "data-scrollzoom"?: boolean | "true" | "false";
12
+ "data-tiles"?: "color" | "gray";
10
13
  "data-view"?: string | number[];
11
14
  };
12
15
  }
@@ -15,7 +18,6 @@ declare global {
15
18
  export declare class MTDSAtlasElement extends MTDSElement {
16
19
  cluster?: L.MarkerClusterGroup;
17
20
  map?: L.Map;
18
- _popup?: [HTMLElement, L.Popup];
19
21
  static get observedAttributes(): string[];
20
22
  constructor();
21
23
  connectedCallback(): void;
@@ -1,74 +1,102 @@
1
1
  import s from "../external/leaflet/dist/leaflet-src.js";
2
- import d from "../external/leaflet/dist/leaflet.css.js";
3
- import { IS_BROWSER as c, MTDSElement as m, tag as a, attr as l, debounce as h } from "../utils.js";
4
- import p from "./atlas.css.js";
2
+ import k from "../external/leaflet/dist/leaflet.css.js";
3
+ import A from "./atlas.css.js";
5
4
  import "./cluster.js";
6
- const u = [
5
+ import { IS_BROWSER as E, attr as i, MTDSElement as M, tag as d, debounce as S, onResize as z, on as x } from "../utils.js";
6
+ const c = [30, 30], m = 18, O = [
7
7
  [57.5, 4.73],
8
8
  [71.5, 31.44]
9
- ], f = "https://cache.kartverket.no/v1/wmts/1.0.0/topo/default/webmercator/{z}/{y}/{x}.png";
10
- class r extends m {
9
+ ], L = "https://cache.kartverket.no/v1/wmts/1.0.0/topo/default/webmercator/{z}/{y}/{x}.png";
10
+ class p extends M {
11
11
  cluster;
12
12
  map;
13
- // Private properties
14
- _popup;
15
13
  static get observedAttributes() {
16
14
  return ["data-view", "data-scrollzoom"];
17
15
  }
18
16
  constructor() {
19
17
  super(), this.attachShadow({ mode: "open" }).append(
20
- a("style", {}, `${d}
21
- ${p}`),
22
- a("slot"),
23
- a("div")
18
+ d("style", {}, `@layer leaflet{${k}}
19
+ ${A}`),
20
+ d("slot"),
21
+ d("div")
24
22
  );
25
23
  }
26
24
  connectedCallback() {
27
- const t = this.shadowRoot?.lastElementChild, o = Number(l(this, "data-cluster")) || 1, e = new s.TileLayer(f, {
25
+ const e = this.shadowRoot?.lastElementChild, o = i(this, "data-cluster") ?? "false", t = new s.TileLayer(L, {
28
26
  attribution: "&copy; Kartverket",
29
- maxZoom: 18
27
+ maxZoom: m
30
28
  });
31
- this.map = new s.Map(t, {
29
+ this.map = new s.Map(e, {
32
30
  attributionControl: !1,
33
31
  wheelPxPerZoomLevel: 20,
34
32
  zoomControl: !1,
35
33
  zoomSnap: 0,
36
- layers: [e]
34
+ layers: [t]
37
35
  }), this.cluster = new s.MarkerClusterGroup({
38
- disableClusteringAtZoom: o,
36
+ zoomToBoundsOnClick: !0,
39
37
  showCoverageOnHover: !1,
40
- zoomToBoundsOnClick: !0
41
- }).addTo(this.map), this.map.addControl(new s.Control.Attribution({ prefix: "" })), this.map.addControl(new s.Control.Zoom({ position: "bottomright" })), r.observedAttributes.forEach((i) => {
42
- this.attributeChangedCallback(i, null, l(this, i));
38
+ disableClusteringAtZoom: o === "false" ? 1 : Number(o) || m,
39
+ iconCreateFunction: (n) => new s.DivIcon({
40
+ className: "leaflet-cluster-icon",
41
+ html: `${n.getAllChildMarkers().length}`,
42
+ iconSize: c
43
+ })
44
+ }).addTo(this.map), this.map.addControl(new s.Control.Attribution({ prefix: "" })), this.map.addControl(new s.Control.Zoom({ position: "bottomright" })), this.map.on("popupopen", f), p.observedAttributes.forEach((n) => {
45
+ this.attributeChangedCallback(n, null, i(this, n));
43
46
  });
44
47
  }
45
- attributeChangedCallback(t, o = null, e = null) {
46
- this.map && (t === "data-view" && this.setView(e || ""), t === "data-scrollzoom" && this.map.scrollWheelZoom[e === "false" ? "disable" : "enable"]());
48
+ attributeChangedCallback(e, o = null, t = null) {
49
+ this.map && (e === "data-view" && this.setView(t || ""), e === "data-scrollzoom" && this.map.scrollWheelZoom[t === "false" ? "disable" : "enable"]());
47
50
  }
48
- setView(t, o) {
49
- const e = `${t}`.split(",").map(parseFloat).filter(Number.isFinite), i = this.cluster?.getBounds();
50
- e.length === 3 ? this.map?.setView([e[0], e[1]], e[2], o) : t !== "fit" ? this.map?.fitBounds(u, o) : i?.isValid() ? this.map?.fitBounds(i, o || { padding: [40, 40] }) : this.cluster?.on("layeradd", n, this);
51
+ setView(e, o) {
52
+ const t = `${e}`.split(",").map(parseFloat).filter(Number.isFinite), n = this.cluster?.getBounds();
53
+ t.length === 3 ? this.map?.setView([t[0], t[1]], t[2], o) : e !== "fit" ? this.map?.fitBounds(O, o) : n?.isValid() ? this.map?.fitBounds(n, o || { padding: c }) : this.cluster?.on("layeradd", g, this);
51
54
  }
52
- addMarker(t, o) {
53
- return new s.Marker(t, o).addTo(
55
+ addMarker(e, o) {
56
+ return new s.Marker(e, o).addTo(
54
57
  this.cluster
55
58
  );
56
59
  }
57
60
  disconnectedCallback() {
58
- this.map?.remove();
61
+ this.map?.off("popupopen", f), this.map?.remove();
59
62
  }
60
63
  }
61
- c && !window.customElements.get("mtds-atlas") && (s.Marker.prototype.options.icon = new s.DivIcon({
62
- 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>',
63
- iconSize: [30, 30],
64
- iconAnchor: [15, 30],
65
- popupAnchor: [0, -15]
66
- }), window.customElements.define("mtds-atlas", r));
67
- const n = h(function() {
68
- this.cluster?.off("layeradd", n), this.cluster?.getBounds().isValid() && this.setView("fit");
69
- }, 100);
64
+ if (E && !window.customElements.get("mtds-atlas")) {
65
+ const l = s.Marker.prototype.onAdd;
66
+ s.Marker.prototype.onAdd = function(...e) {
67
+ l.apply(this, e);
68
+ const o = this.getElement();
69
+ return o && i(o, "aria-label", this.options.title || null), o && i(o, "title", null), this;
70
+ }, s.Tooltip.prototype.options.direction = "top", s.Marker.prototype.options.icon = new s.DivIcon({
71
+ html: '<svg viewBox="0 0 256 256"><rect x="78" y="50" width="100" height="100" /><path d="M128,16a88.1,88.1,0,0,0-88,88c0,75.3,80,132.17,83.41,134.55a8,8,0,0,0,9.18,0C136,236.17,216,179.3,216,104A88.1,88.1,0,0,0,128,16Zm0,56a32,32,0,1,1-32,32A32,32,0,0,1,128,72Z"/></svg>',
72
+ iconSize: c,
73
+ iconAnchor: [15, 30],
74
+ popupAnchor: [0, -15],
75
+ tooltipAnchor: [0, -30]
76
+ }), window.customElements.define("mtds-atlas", p);
77
+ }
78
+ const g = S(function() {
79
+ this.cluster?.off("layeradd", g, this), this.cluster?.getBounds().isValid() && this.setView("fit");
80
+ }, 100), u = "popupclose move resize zoom viewreset", f = ({ target: l, popup: e }) => {
81
+ const o = e.getContent(), t = String(o)[0] === "#" && document.getElementById(o.slice(1));
82
+ if (t && t.closest("mtds-atlas")) {
83
+ const n = e.getLatLng(), w = i(t, "popover");
84
+ i(e.getElement(), "hidden", ""), i(t, "popover", null);
85
+ const a = (r) => {
86
+ if (r?.type === "popupclose" && r?.popup === e)
87
+ l.off(u, a), i(e.getElement(), "hidden", null), i(t, "data-popover", null), i(t, "popover", w), v(), C();
88
+ else {
89
+ const h = l.latLngToContainerPoint(n), b = h.x - t.offsetWidth / 2, y = h.y - t.offsetHeight - c[1];
90
+ t.style.translate = `${b}px ${y}px`;
91
+ }
92
+ }, v = z(() => a(), t), C = x(t, "click", (r) => {
93
+ r.target?.closest?.('[popovertargetaction="hide"]') && e.close();
94
+ });
95
+ l.on(u, a), a();
96
+ }
97
+ };
70
98
  export {
71
99
  s as L,
72
- r as MTDSAtlasElement
100
+ p as MTDSAtlasElement
73
101
  };
74
102
  //# sourceMappingURL=atlas-element.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"atlas-element.js","sources":["../../designsystem/atlas/atlas-element.ts"],"sourcesContent":["import L from \"leaflet\";\nimport LeafletCSS from \"leaflet/dist/leaflet.css?raw\";\nimport type {} from \"leaflet.markercluster\";\nimport type * as ReactTypes from \"react\";\nimport { attr, debounce, IS_BROWSER, MTDSElement, tag } from \"../utils\";\nimport css from \"./atlas.css?raw\";\nimport \"./cluster.js\";\nexport { L };\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 | number[];\n\t\t\t};\n\t\t}\n\t}\n}\n\n// const EVENTS = \"popupopen popupclose move zoom resize\";\nconst BOUNDS_NORWAY: L.LatLngBoundsLiteral = [\n\t[57.5, 4.73],\n\t[71.5, 31.44],\n];\n\n// Turns out Kartverket's color tiles are better in grayscale than their grayscale tiles\n// const TILES_GRAY = \"https://cache.kartverket.no/v1/wmts/1.0.0/topograatone/default/webmercator/{z}/{y}/{x}.png\";\nconst TILES_COLOR =\n\t\"https://cache.kartverket.no/v1/wmts/1.0.0/topo/default/webmercator/{z}/{y}/{x}.png\";\n\nexport class MTDSAtlasElement extends MTDSElement {\n\tcluster?: L.MarkerClusterGroup;\n\tmap?: L.Map;\n\n\t// Private properties\n\t_popup?: [HTMLElement, L.Popup];\n\n\tstatic get observedAttributes() {\n\t\treturn [\"data-view\", \"data-scrollzoom\"]; //TODO: \"data-layers\" // Using ES2015 syntax for backwards compatibility\n\t}\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.attachShadow({ mode: \"open\" }).append(\n\t\t\ttag(\"style\", {}, `${LeafletCSS}\\n${css}`),\n\t\t\ttag(\"slot\"),\n\t\t\ttag(\"div\"),\n\t\t);\n\t}\n\tconnectedCallback() {\n\t\tconst div = this.shadowRoot?.lastElementChild;\n\t\tconst cluster = Number(attr(this, \"data-cluster\")) || 1;\n\t\tconst tiles = new L.TileLayer(TILES_COLOR, {\n\t\t\tattribution: \"&copy; Kartverket\",\n\t\t\tmaxZoom: 18,\n\t\t});\n\n\t\tthis.map = new L.Map(div as HTMLElement, {\n\t\t\tattributionControl: false,\n\t\t\twheelPxPerZoomLevel: 20,\n\t\t\tzoomControl: false,\n\t\t\tzoomSnap: 0,\n\t\t\tlayers: [tiles],\n\t\t});\n\n\t\tthis.cluster = new L.MarkerClusterGroup({\n\t\t\tdisableClusteringAtZoom: cluster,\n\t\t\tshowCoverageOnHover: false,\n\t\t\tzoomToBoundsOnClick: true,\n\t\t}).addTo(this.map);\n\n\t\tthis.map.addControl(new L.Control.Attribution({ prefix: \"\" }));\n\t\tthis.map.addControl(new L.Control.Zoom({ position: \"bottomright\" }));\n\t\t// this.map.on(EVENTS, handleEvents);\n\n\t\t// Initial setup when map is connected\n\t\tMTDSAtlasElement.observedAttributes.forEach((name) => {\n\t\t\tthis.attributeChangedCallback(name, null, attr(this, name));\n\t\t});\n\t}\n\tattributeChangedCallback(\n\t\tname: string,\n\t\t_prev: string | null = null,\n\t\tnext: string | null = null,\n\t) {\n\t\tif (!this.map) return; // No map yet\n\t\tif (name === \"data-view\") this.setView(next || \"\");\n\t\tif (name === \"data-scrollzoom\")\n\t\t\tthis.map.scrollWheelZoom[next === \"false\" ? \"disable\" : \"enable\"]();\n\t}\n\tsetView(view: string | number[], options?: L.ZoomPanOptions) {\n\t\tconst pos = `${view}`.split(\",\").map(parseFloat).filter(Number.isFinite);\n\t\tconst bounds = this.cluster?.getBounds();\n\n\t\tif (pos.length === 3) this.map?.setView([pos[0], pos[1]], pos[2], options);\n\t\telse if (view !== \"fit\") this.map?.fitBounds(BOUNDS_NORWAY, options);\n\t\telse if (!bounds?.isValid())\n\t\t\tthis.cluster?.on(\"layeradd\", fitWhenMarkers, this);\n\t\telse this.map?.fitBounds(bounds, options || { padding: [40, 40] });\n\t}\n\taddMarker(latlng: L.LatLngExpression, options?: L.MarkerOptions) {\n\t\treturn new L.Marker(latlng, options).addTo(\n\t\t\tthis.cluster as L.MarkerClusterGroup,\n\t\t);\n\t}\n\tdisconnectedCallback() {\n\t\tthis.map?.remove();\n\t\t// this.map?.off(EVENTS, handleEvents);\n\t}\n}\n\n// Set default marker icon and define custom element\nif (IS_BROWSER && !window.customElements.get(\"mtds-atlas\")) {\n\tL.Marker.prototype.options.icon = new L.DivIcon({\n\t\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\t\ticonSize: [30, 30],\n\t\ticonAnchor: [15, 30],\n\t\tpopupAnchor: [0, -15],\n\t});\n\twindow.customElements.define(\"mtds-atlas\", MTDSAtlasElement);\n}\n\nconst fitWhenMarkers = debounce(function (this: MTDSAtlasElement) {\n\tthis.cluster?.off(\"layeradd\", fitWhenMarkers);\n\tif (this.cluster?.getBounds().isValid()) this.setView(\"fit\");\n}, 100);\n\n// const handleEvents: L.LeafletEventHandlerFn = ({ type, target, popup }) => {\n// \tconst self = target.getContainer();\n\n// \tif (type === \"popupopen\" || type === \"popupclose\") {\n// \t\tif (self._popup) {\n// \t\t\tconst [el] = self._popup;\n// \t\t\tself._popup = el.hidePopover();\n// \t\t\tself._popup = undefined;\n// \t\t}\n// \t\tconst id = type === \"popupopen\" && popup.getContent();\n// \t\tconst el = String(id)[0] === \"#\" && document.getElementById(id.slice(1));\n\n// \t\tif (el) {\n// \t\t\tattr(el, \"popover\", \"manual\");\n// \t\t\tattr(popup.getElement(), \"data-atlas-popup\", id);\n// \t\t\tel.showPopover();\n// \t\t\tself._popup = [el, popup];\n// \t\t\tanchorPopover(target, popup, el);\n// \t\t}\n// \t} else if (self._popup) {\n// \t\tanchorPopover(target, self._popup[1], self._popup[0]);\n// \t}\n// };\n\n// const anchorPopover = (map: L.Map, popup: L.Popup, popover: HTMLElement) => {\n// \tconst point = map.latLngToContainerPoint(popup.getLatLng() as L.LatLng);\n// \tconst rect = map.getContainer().getBoundingClientRect();\n// \tpopover.style.translate = `${rect.x + point.x + window.scrollX}px ${rect.y + point.y + window.scrollY}px`;\n// };\n\n// .on(\"click\", ({ target: marker, originalEvent: event }) => {\n// \tconst id = (marker.options as Record<string, string>)?.popoverTarget;\n// \tconst el = document.getElementById(id || \"\");\n\n// \tif (el) {\n// \t\tconsole.log(el, this);\n// \t\tevent.stopPropagation();\n// \t\tel.showPopover();\n// \t\tthis.popup = el;\n// \t\tthis.map?.fire(\"move\"); // Trigger position update\n\n// \t\t// \tconst updatePosition = () => {\n// \t\t// \t\tconst point = this.map?.latLngToContainerPoint(marker.getLatLng());\n// \t\t// \t\tconst rect = this.getBoundingClientRect();\n// \t\t// \t\tconsole.dir(rect);\n// \t\t// \t\t// console.log(point, this.map?.getBounds().getCenter().lat);\n// \t\t// \t\tif (point)\n// \t\t// \t\t\tel.style.translate = `${rect.x + point.x + window.scrollX}px ${rect.y + point.y + window.scrollY}px`;\n// \t\t// \t};\n\n// \t\t// \tupdatePosition();\n// \t}\n// })\n\n// export type Adresse = {\n// \tadressekode: number;\n// \tadressetekst: string;\n// \tbokstav: string;\n// \tbruksenhetsnummer: string[];\n// \tbruksnummer: number;\n// \tfestenummer: number;\n// \tgardsnummer: number;\n// \tkommunenavn: string;\n// \tkommunenummer: string;\n// \tnummer: number;\n// \tobjtype: string;\n// \toppdateringsdato: string;\n// \tpostnummer: string;\n// \tpoststed: string;\n// \trepresentasjonspunkt: {\n// \t\tepsg: string;\n// \t\tlat: number;\n// \t\tlon: number;\n// \t};\n// \tstedfestingverifisert: boolean;\n// \tundernummer: string | null;\n// };\n\n// // 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":["BOUNDS_NORWAY","TILES_COLOR","MTDSAtlasElement","MTDSElement","tag","LeafletCSS","css","div","cluster","attr","tiles","L","name","_prev","next","view","options","pos","bounds","fitWhenMarkers","latlng","IS_BROWSER","debounce"],"mappings":";;;;;AAuBA,MAAMA,IAAuC;AAAA,EAC5C,CAAC,MAAM,IAAI;AAAA,EACX,CAAC,MAAM,KAAK;AACb,GAIMC,IACL;AAEM,MAAMC,UAAyBC,EAAY;AAAA,EACjD;AAAA,EACA;AAAA;AAAA,EAGA;AAAA,EAEA,WAAW,qBAAqB;AAC/B,WAAO,CAAC,aAAa,iBAAiB;AAAA,EACvC;AAAA,EAEA,cAAc;AACb,UAAA,GACA,KAAK,aAAa,EAAE,MAAM,OAAA,CAAQ,EAAE;AAAA,MACnCC,EAAI,SAAS,IAAI,GAAGC,CAAU;AAAA,EAAKC,CAAG,EAAE;AAAA,MACxCF,EAAI,MAAM;AAAA,MACVA,EAAI,KAAK;AAAA,IAAA;AAAA,EAEX;AAAA,EACA,oBAAoB;AACnB,UAAMG,IAAM,KAAK,YAAY,kBACvBC,IAAU,OAAOC,EAAK,MAAM,cAAc,CAAC,KAAK,GAChDC,IAAQ,IAAIC,EAAE,UAAUV,GAAa;AAAA,MAC1C,aAAa;AAAA,MACb,SAAS;AAAA,IAAA,CACT;AAED,SAAK,MAAM,IAAIU,EAAE,IAAIJ,GAAoB;AAAA,MACxC,oBAAoB;AAAA,MACpB,qBAAqB;AAAA,MACrB,aAAa;AAAA,MACb,UAAU;AAAA,MACV,QAAQ,CAACG,CAAK;AAAA,IAAA,CACd,GAED,KAAK,UAAU,IAAIC,EAAE,mBAAmB;AAAA,MACvC,yBAAyBH;AAAA,MACzB,qBAAqB;AAAA,MACrB,qBAAqB;AAAA,IAAA,CACrB,EAAE,MAAM,KAAK,GAAG,GAEjB,KAAK,IAAI,WAAW,IAAIG,EAAE,QAAQ,YAAY,EAAE,QAAQ,GAAA,CAAI,CAAC,GAC7D,KAAK,IAAI,WAAW,IAAIA,EAAE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AC,IAAI,EAAE;AAAA,EACnB,aAAa,CAAC,GAAG,GAAG;AAAA,CACpB,GACD,OAAO,eAAe,OAAO,cAAcT,CAAgB;AAG5D,MAAMiB,IAAiBG,EAAS,WAAkC;AACjE,OAAK,SAAS,IAAI,YAAYH,CAAc,GACxC,KAAK,SAAS,UAAA,EAAY,aAAW,KAAK,QAAQ,KAAK;AAC5D,GAAG,GAAG;"}
1
+ {"version":3,"file":"atlas-element.js","sources":["../../designsystem/atlas/atlas-element.ts"],"sourcesContent":["import L from \"leaflet\";\nimport LeafletCSS from \"leaflet/dist/leaflet.css?raw\";\nimport type {} from \"leaflet.markercluster\";\nimport type * as ReactTypes from \"react\";\nimport css from \"./atlas.css?raw\";\nimport \"./cluster.js\";\nimport {\n\tattr,\n\tdebounce,\n\tIS_BROWSER,\n\tMTDSElement,\n\ton,\n\tonResize,\n\ttag,\n} from \"../utils\";\nexport { L };\n\ndeclare global {\n\tnamespace React.JSX {\n\t\tinterface IntrinsicElements {\n\t\t\t\"mtds-atlas\": ReactTypes.DetailedHTMLProps<\n\t\t\t\tReactTypes.HTMLAttributes<MTDSAtlasElement>,\n\t\t\t\tMTDSAtlasElement\n\t\t\t> & {\n\t\t\t\tclass?: string;\n\t\t\t\t\"data-cluster\"?: number | `${number}` | boolean | \"true\" | \"false\";\n\t\t\t\t\"data-scrollzoom\"?: boolean | \"true\" | \"false\";\n\t\t\t\t\"data-tiles\"?: \"color\" | \"gray\";\n\t\t\t\t\"data-view\"?: string | number[];\n\t\t\t};\n\t\t}\n\t}\n}\n\nconst ICON_SIZE = [30, 30] as L.PointTuple;\nconst MAX_ZOOM = 18; // Kartverket does not support more than zoom level 18\nconst NORWAY: L.LatLngBoundsLiteral = [\n\t[57.5, 4.73],\n\t[71.5, 31.44],\n];\n\n// Turns out Kartverket's color tiles are better in grayscale than their grayscale tiles\nconst TILES_COLOR =\n\t\"https://cache.kartverket.no/v1/wmts/1.0.0/topo/default/webmercator/{z}/{y}/{x}.png\";\n\nexport class MTDSAtlasElement extends MTDSElement {\n\tcluster?: L.MarkerClusterGroup;\n\tmap?: L.Map;\n\n\tstatic get observedAttributes() {\n\t\treturn [\"data-view\", \"data-scrollzoom\"]; //TODO: \"data-layers\" // Using ES2015 syntax for backwards compatibility\n\t}\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.attachShadow({ mode: \"open\" }).append(\n\t\t\ttag(\"style\", {}, `@layer leaflet{${LeafletCSS}}\\n${css}`),\n\t\t\ttag(\"slot\"),\n\t\t\ttag(\"div\"),\n\t\t);\n\t}\n\tconnectedCallback() {\n\t\tconst div = this.shadowRoot?.lastElementChild;\n\t\tconst cluster = attr(this, \"data-cluster\") ?? \"false\";\n\t\tconst tiles = new L.TileLayer(TILES_COLOR, {\n\t\t\tattribution: \"&copy; Kartverket\",\n\t\t\tmaxZoom: MAX_ZOOM,\n\t\t});\n\n\t\tthis.map = new L.Map(div as HTMLElement, {\n\t\t\tattributionControl: false,\n\t\t\twheelPxPerZoomLevel: 20,\n\t\t\tzoomControl: false,\n\t\t\tzoomSnap: 0,\n\t\t\tlayers: [tiles],\n\t\t});\n\n\t\tthis.cluster = new L.MarkerClusterGroup({\n\t\t\tzoomToBoundsOnClick: true,\n\t\t\tshowCoverageOnHover: false,\n\t\t\tdisableClusteringAtZoom:\n\t\t\t\tcluster === \"false\" ? 1 : Number(cluster) || MAX_ZOOM,\n\t\t\ticonCreateFunction: (cluster) =>\n\t\t\t\tnew L.DivIcon({\n\t\t\t\t\tclassName: \"leaflet-cluster-icon\",\n\t\t\t\t\thtml: `${cluster.getAllChildMarkers().length}`,\n\t\t\t\t\ticonSize: ICON_SIZE,\n\t\t\t\t}),\n\t\t}).addTo(this.map);\n\n\t\tthis.map.addControl(new L.Control.Attribution({ prefix: \"\" }));\n\t\tthis.map.addControl(new L.Control.Zoom({ position: \"bottomright\" }));\n\t\tthis.map.on(\"popupopen\", handlePopupById);\n\n\t\t// Initial setup when map is connected\n\t\tMTDSAtlasElement.observedAttributes.forEach((name) => {\n\t\t\tthis.attributeChangedCallback(name, null, attr(this, name));\n\t\t});\n\t}\n\tattributeChangedCallback(\n\t\tname: string,\n\t\t_prev: string | null = null,\n\t\tnext: string | null = null,\n\t) {\n\t\tif (!this.map) return; // No map yet\n\t\tif (name === \"data-view\") this.setView(next || \"\");\n\t\tif (name === \"data-scrollzoom\")\n\t\t\tthis.map.scrollWheelZoom[next === \"false\" ? \"disable\" : \"enable\"]();\n\t}\n\tsetView(view: string | number[], options?: L.ZoomPanOptions) {\n\t\tconst pos = `${view}`.split(\",\").map(parseFloat).filter(Number.isFinite);\n\t\tconst bounds = this.cluster?.getBounds();\n\n\t\tif (pos.length === 3) this.map?.setView([pos[0], pos[1]], pos[2], options);\n\t\telse if (view !== \"fit\") this.map?.fitBounds(NORWAY, options);\n\t\telse if (!bounds?.isValid())\n\t\t\tthis.cluster?.on(\"layeradd\", fitWhenMarkers, this);\n\t\telse this.map?.fitBounds(bounds, options || { padding: ICON_SIZE });\n\t}\n\taddMarker(latlng: L.LatLngExpression, options?: L.MarkerOptions) {\n\t\treturn new L.Marker(latlng, options).addTo(\n\t\t\tthis.cluster as L.MarkerClusterGroup,\n\t\t);\n\t}\n\tdisconnectedCallback() {\n\t\tthis.map?.off(\"popupopen\", handlePopupById);\n\t\tthis.map?.remove();\n\t}\n}\n\nif (IS_BROWSER && !window.customElements.get(\"mtds-atlas\")) {\n\t// Fix accessibility\n\tconst onAddOriginal = L.Marker.prototype.onAdd;\n\tL.Marker.prototype.onAdd = function (...args) {\n\t\tonAddOriginal.apply(this, args);\n\t\tconst el = this.getElement();\n\t\tif (el) attr(el, \"aria-label\", this.options.title || null);\n\t\tif (el) attr(el, \"title\", null);\n\t\treturn this;\n\t};\n\n\t// Set defaults\n\tL.Tooltip.prototype.options.direction = \"top\";\n\tL.Marker.prototype.options.icon = new L.DivIcon({\n\t\thtml: '<svg viewBox=\"0 0 256 256\"><rect x=\"78\" y=\"50\" width=\"100\" height=\"100\" /><path d=\"M128,16a88.1,88.1,0,0,0-88,88c0,75.3,80,132.17,83.41,134.55a8,8,0,0,0,9.18,0C136,236.17,216,179.3,216,104A88.1,88.1,0,0,0,128,16Zm0,56a32,32,0,1,1-32,32A32,32,0,0,1,128,72Z\"/></svg>',\n\t\ticonSize: ICON_SIZE,\n\t\ticonAnchor: [15, 30],\n\t\tpopupAnchor: [0, -15],\n\t\ttooltipAnchor: [0, -30],\n\t});\n\n\t// Define custom element\n\twindow.customElements.define(\"mtds-atlas\", MTDSAtlasElement);\n}\n\n// TODO: Style markers\n// TODO: Synlig label til marker\n// TODO: Add minimum zoom level for adding markers (minimum 17 som standard?)\n// TODO: data-layers: https://matgeoservice-256616427209.europe-north1.run.app/ogc/features/collections\n\nconst fitWhenMarkers = debounce(function (this: MTDSAtlasElement) {\n\tthis.cluster?.off(\"layeradd\", fitWhenMarkers, this);\n\tif (this.cluster?.getBounds().isValid()) this.setView(\"fit\");\n}, 100);\n\nconst HANDLE_POPUP_EVENTS = \"popupclose move resize zoom viewreset\";\nconst handlePopupById = ({ target: map, popup }: L.LeafletEvent) => {\n\tconst id = popup.getContent();\n\tconst popover = String(id)[0] === \"#\" && document.getElementById(id.slice(1));\n\n\tif (!!popover && popover.closest(\"mtds-atlas\")) {\n\t\tconst latlng = popup.getLatLng();\n\t\tconst mode = attr(popover, \"popover\"); // Save current popover mode\n\t\tattr(popup.getElement(), \"hidden\", \"\"); // Hide Leaflet popup element\n\t\tattr(popover, \"popover\", null); // Disable Popover API to show and ensure overflow: clip on mtds-atlas works\n\n\t\tconst update = (event?: L.LeafletEvent) => {\n\t\t\tif (event?.type === \"popupclose\" && event?.popup === popup) {\n\t\t\t\tmap.off(HANDLE_POPUP_EVENTS, update);\n\t\t\t\tattr(popup.getElement(), \"hidden\", null); // Un-hide Leaflet popup element\n\t\t\t\tattr(popover, \"data-popover\", null); // Hide popover\n\t\t\t\tattr(popover, \"popover\", mode); // Re-enable Popover API\n\t\t\t\tunresize();\n\t\t\t\tunclick();\n\t\t\t} else {\n\t\t\t\tconst point = map.latLngToContainerPoint(latlng);\n\t\t\t\tconst x = point.x - popover.offsetWidth / 2;\n\t\t\t\tconst y = point.y - popover.offsetHeight - ICON_SIZE[1];\n\t\t\t\tpopover.style.translate = `${x}px ${y}px`;\n\t\t\t}\n\t\t};\n\n\t\tconst unresize = onResize(() => update(), popover);\n\t\tconst unclick = on(popover, \"click\", (e: Event) => {\n\t\t\tif ((e.target as Element)?.closest?.('[popovertargetaction=\"hide\"]'))\n\t\t\t\tpopup.close(); // Listen for close actions inside popover since we are not using actual Popover API\n\t\t});\n\n\t\tmap.on(HANDLE_POPUP_EVENTS, update);\n\t\tupdate(); // Initial position\n\t}\n};\n\n// export type Adresse = {\n// \tadressekode: number;\n// \tadressetekst: string;\n// \tbokstav: string;\n// \tbruksenhetsnummer: string[];\n// \tbruksnummer: number;\n// \tfestenummer: number;\n// \tgardsnummer: number;\n// \tkommunenavn: string;\n// \tkommunenummer: string;\n// \tnummer: number;\n// \tobjtype: string;\n// \toppdateringsdato: string;\n// \tpostnummer: string;\n// \tpoststed: string;\n// \trepresentasjonspunkt: {\n// \t\tepsg: string;\n// \t\tlat: number;\n// \t\tlon: number;\n// \t};\n// \tstedfestingverifisert: boolean;\n// \tundernummer: string | null;\n// };\n\n// type GeoNorgeAdresser = {\n// \tmetadata: {\n// \t\tside: number;\n// \t\tviserFra: number;\n// \t\ttotaltAntallTreff: number;\n// \t\tasciiKompatibel: boolean;\n// \t\ttreffPerSide: number;\n// \t\tviserTil: number;\n// \t\tsokeStreng: string;\n// \t};\n// \tadresser: {\n// \t\tadressenavn: string;\n// \t\tadressetekst: string;\n// \t\tadressetilleggsnavn: string | null;\n// \t\tadressekode: number;\n// \t\tnummer: number;\n// \t\tbokstav: string;\n// \t\tkommunenummer: string;\n// \t\tkommunenavn: string;\n// \t\tgardsnummer: number;\n// \t\tbruksnummer: number;\n// \t\tfestenummer: number;\n// \t\tundernummer: string | null;\n// \t\tbruksenhetsnummer: (string | null)[];\n// \t\tobjtype: string;\n// \t\tpoststed: string;\n// \t\tpostnummer: string;\n// \t\tadressetekstutenadressetilleggsnavn: string;\n// \t\tstedfestingverifisert: boolean;\n// \t\toppdateringsdato: string;\n// \t\trepresentasjonspunkt: {\n// \t\t\tepsg: string;\n// \t\t\tlat: number;\n// \t\t\tlon: number;\n// \t\t};\n// \t}[];\n// };\n\n// // Hent punkt for adresse fra GeoNorge\n// const toUrlQuery = (obj: Record<string, unknown>) =>\n// \tnew URLSearchParams(\n// \t\tObject.fromEntries(Object.entries(obj).map(([k, v]) => [k, `${v}`])),\n// \t).toString();\n\n// export const getGeoNorgeAdresser = async (params: {\n// \tadressekode?: number;\n// \tadressenavn?: string;\n// \tadressetekst?: string;\n// \tadressetilleggsnavn?: string;\n// \tasciiKompatibel?: boolean;\n// \tbokstav?: string;\n// \tbruksenhetsnummer?: string;\n// \tbruksnummer?: number;\n// \tfestenummer?: number;\n// \tfiltrer?: string;\n// \tfuzzy?: boolean;\n// \tgardsnummer?: number;\n// \tkommunenavn?: string;\n// \tkommunenummer?: number;\n// \tnummer?: number;\n// \tobjtype?: \"Vegadresse\" | \"Matrikkeladresse\";\n// \tpostnummer?: string;\n// \tpoststed?: string;\n// \tside?: number;\n// \tsok?: string;\n// \tsokemodus?: \"AND\" | \"OR\";\n// \ttreffPerSide?: number;\n// \tundernummer?: string;\n// \tutkoordsys?: number;\n// }): Promise<GeoNorgeAdresser | undefined> =>\n// \tfetch(\n// \t\t`https://ws.geonorge.no/adresser/v1/sok?${toUrlQuery({\n// \t\t\tasciiKompatibel: true,\n// \t\t\tfuzzy: true,\n// \t\t\tside: 0,\n// \t\t\ttreffPerSide: 10,\n// \t\t\tutkoordsys: 4326,\n// \t\t\t...params,\n// \t\t})}`,\n// \t)\n// \t\t.then((res) => res.json())\n// \t\t.catch((error) =>\n// \t\t\tconsole.log(`Feilet i å hente adresse fra punkt: ${error}`),\n// \t\t);\n"],"names":["ICON_SIZE","MAX_ZOOM","NORWAY","TILES_COLOR","MTDSAtlasElement","MTDSElement","tag","LeafletCSS","css","div","cluster","attr","tiles","L","handlePopupById","name","_prev","next","view","options","pos","bounds","fitWhenMarkers","latlng","IS_BROWSER","onAddOriginal","args","el","debounce","HANDLE_POPUP_EVENTS","map","popup","id","popover","mode","update","event","unresize","unclick","point","x","onResize","on","e"],"mappings":";;;;;AAkCA,MAAMA,IAAY,CAAC,IAAI,EAAE,GACnBC,IAAW,IACXC,IAAgC;AAAA,EACrC,CAAC,MAAM,IAAI;AAAA,EACX,CAAC,MAAM,KAAK;AACb,GAGMC,IACL;AAEM,MAAMC,UAAyBC,EAAY;AAAA,EACjD;AAAA,EACA;AAAA,EAEA,WAAW,qBAAqB;AAC/B,WAAO,CAAC,aAAa,iBAAiB;AAAA,EACvC;AAAA,EAEA,cAAc;AACb,UAAA,GACA,KAAK,aAAa,EAAE,MAAM,OAAA,CAAQ,EAAE;AAAA,MACnCC,EAAI,SAAS,CAAA,GAAI,kBAAkBC,CAAU;AAAA,EAAMC,CAAG,EAAE;AAAA,MACxDF,EAAI,MAAM;AAAA,MACVA,EAAI,KAAK;AAAA,IAAA;AAAA,EAEX;AAAA,EACA,oBAAoB;AACnB,UAAMG,IAAM,KAAK,YAAY,kBACvBC,IAAUC,EAAK,MAAM,cAAc,KAAK,SACxCC,IAAQ,IAAIC,EAAE,UAAUV,GAAa;AAAA,MAC1C,aAAa;AAAA,MACb,SAASF;AAAA,IAAA,CACT;AAED,SAAK,MAAM,IAAIY,EAAE,IAAIJ,GAAoB;AAAA,MACxC,oBAAoB;AAAA,MACpB,qBAAqB;AAAA,MACrB,aAAa;AAAA,MACb,UAAU;AAAA,MACV,QAAQ,CAACG,CAAK;AAAA,IAAA,CACd,GAED,KAAK,UAAU,IAAIC,EAAE,mBAAmB;AAAA,MACvC,qBAAqB;AAAA,MACrB,qBAAqB;AAAA,MACrB,yBACCH,MAAY,UAAU,IAAI,OAAOA,CAAO,KAAKT;AAAA,MAC9C,oBAAoB,CAACS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AAC/C,UAAMV,IAASQ,EAAM,UAAA,GACfG,IAAOvB,EAAKsB,GAAS,SAAS;AACpC,IAAAtB,EAAKoB,EAAM,cAAc,UAAU,EAAE,GACrCpB,EAAKsB,GAAS,WAAW,IAAI;AAE7B,UAAME,IAAS,CAACC,MAA2B;AAC1C,UAAIA,GAAO,SAAS,gBAAgBA,GAAO,UAAUL;AACpD,QAAAD,EAAI,IAAID,GAAqBM,CAAM,GACnCxB,EAAKoB,EAAM,cAAc,UAAU,IAAI,GACvCpB,EAAKsB,GAAS,gBAAgB,IAAI,GAClCtB,EAAKsB,GAAS,WAAWC,CAAI,GAC7BG,EAAA,GACAC,EAAA;AAAA,WACM;AACN,cAAMC,IAAQT,EAAI,uBAAuBP,CAAM,GACzCiB,IAAID,EAAM,IAAIN,EAAQ,cAAc,GACpC,IAAIM,EAAM,IAAIN,EAAQ,eAAejC,EAAU,CAAC;AACtD,QAAAiC,EAAQ,MAAM,YAAY,GAAGO,CAAC,MAAM,CAAC;AAAA,MACtC;AAAA,IACD,GAEMH,IAAWI,EAAS,MAAMN,EAAA,GAAUF,CAAO,GAC3CK,IAAUI,EAAGT,GAAS,SAAS,CAACU,MAAa;AAClD,MAAKA,EAAE,QAAoB,UAAU,8BAA8B,KAClEZ,EAAM,MAAA;AAAA,IACR,CAAC;AAED,IAAAD,EAAI,GAAGD,GAAqBM,CAAM,GAClCA,EAAA;AAAA,EACD;AACD;"}
@@ -1,39 +1,23 @@
1
- const t = `:host {
2
- --mtdsc-atlas-cluster-size: var(--mtds-8);
1
+ const t = `/* NOTE: Using --mtds- not --mtds- since we're inside shadow dom */
2
+ :host {
3
3
  --mtdsc-atlas-background: #fbfbfb;
4
- --mtdsc-atlas-border-color: var(--mtds-color-border-subtle);
5
4
  --mtdsc-atlas-border: var(--mtds-border-width-default) solid
6
- var(--mtdsc-atlas-border-color);
5
+ var(--mtds-color-border-subtle);
7
6
 
8
7
  border-radius: var(--mtds-border-radius-md);
9
8
  aspect-ratio: 2;
10
9
  overflow: clip;
11
10
  position: relative;
12
- user-select: none;
13
11
  }
14
12
  :host(:not([hidden])) {
15
- display: grid;
13
+ display: block;
16
14
  }
17
15
  :host([data-cursor="pointer"]) .leaflet-grab {
18
16
  cursor: pointer;
19
17
  }
20
- .leaflet-tile-container {
21
- filter: grayscale(1) contrast(0.75) brightness(1.15);
22
- }
23
- :host([data-tiles="color"]) .leaflet-tile-container {
24
- filter: grayscale(0.2);
25
- }
26
- :host([data-tiles="color"]) {
27
- --mtdsc-atlas-background: #e5fcfd;
28
- }
29
- :host:has(.leaflet-container:focus-visible) {
30
- box-shadow: var(--mtdsc-focus-boxShadow);
31
- outline: var(--mtdsc-focus-outline);
32
- outline-offset: var(--mtds-border-width-focus);
33
- }
34
18
  slot {
35
- display: grid;
36
- inset: var(--mtds-3);
19
+ display: block;
20
+ inset: 0;
37
21
  pointer-events: none; /* Ensure slot does not stop pointer from reaching leaflet */
38
22
  position: absolute;
39
23
  z-index: 2;
@@ -41,46 +25,116 @@ slot {
41
25
  ::slotted(*) {
42
26
  pointer-events: all; /* But let children of slot stop pointer from reaching leaflet */
43
27
  }
44
- .leaflet-div-icon {
45
- background: none;
46
- border: 0;
28
+
29
+ /* Focus */
30
+ .leaflet-control-zoom a:focus-visible,
31
+ :host:has(.leaflet-container:focus-visible) {
32
+ box-shadow: var(--mtdsc-focus-boxShadow);
33
+ outline: var(--mtdsc-focus-outline);
34
+ outline-offset: var(--mtds-border-width-focus);
47
35
  }
36
+
37
+ /* Map and tiles */
48
38
  .leaflet-container {
49
39
  background: var(--mtdsc-atlas-background);
50
40
  border-radius: inherit;
51
41
  border: var(--mtdsc-atlas-border);
52
42
  box-sizing: border-box;
53
43
  font: inherit;
44
+ height: 100%;
54
45
  outline: 0;
46
+ position: relative;
47
+ z-index: 1; /* Ensure <slot> is always on top */
48
+ }
49
+ .leaflet-tile-container {
50
+ filter: grayscale(1) contrast(0.75) brightness(1.15);
51
+ transition: filter 0.5s;
55
52
  }
53
+ :host([data-tiles="color"]) {
54
+ --mtdsc-atlas-background: #e5fcfd;
55
+ }
56
+ :host([data-tiles="color"]) .leaflet-tile-container {
57
+ filter: grayscale(0.2);
58
+ }
59
+
60
+ /* Controls */
56
61
  .leaflet-control-attribution {
57
62
  font-size: 12px;
58
63
  border-top-left-radius: var(--mtds-border-radius-md);
59
64
  }
65
+ .leaflet-control-zoom {
66
+ border-radius: var(--mtds-border-radius-md);
67
+ border: 1px solid var(--mtds-color-border-default);
68
+ }
69
+ .leaflet-control-zoom a {
70
+ border-color: inherit;
71
+ background: var(--mtds-color-surface-default);
72
+ color: var(--mtds-color-text-default);
73
+ display: flex;
74
+ height: var(--mtds-10);
75
+ outline: 0;
76
+ place-content: center;
77
+ place-items: center;
78
+ transition: 0.2s;
79
+ width: var(--mtds-10);
80
+ }
81
+ .leaflet-control-zoom a:first-child {
82
+ border-top-left-radius: inherit;
83
+ border-top-right-radius: inherit;
84
+ }
85
+ .leaflet-control-zoom a:last-child {
86
+ border-bottom-left-radius: inherit;
87
+ border-bottom-right-radius: inherit;
88
+ }
89
+ .leaflet-control-zoom a:hover {
90
+ background: var(--mtds-color-surface-hover);
91
+ }
92
+ .leaflet-control-zoom a:active {
93
+ background: var(--mtds-color-surface-active);
94
+ }
60
95
 
61
- .map-pin rect {
96
+ /* Markers */
97
+ .leaflet-tooltip {
98
+ background: var(--mtds-color-surface-default);
99
+ border-radius: var(--mtds-border-radius-md);
100
+ box-shadow: var(--mtds-box-shadow-sm);
101
+ color: var(--mtds-color-text-default);
102
+ padding: var(--mtds-1) var(--mtds-2);
103
+ }
104
+ .leaflet-marker-icon {
105
+ background: none;
106
+ border: 0;
107
+ }
108
+ .leaflet-marker-icon rect {
62
109
  fill: var(--mtds-color-base-contrast-default);
63
110
  }
64
- .map-pin path {
111
+ .leaflet-marker-icon path {
65
112
  fill: var(--mtds-color-base-default);
113
+ stroke: var(--mtds-color-base-contrast-default);
114
+ vector-effect: non-scaling-stroke;
66
115
  }
67
-
68
- .marker-cluster {
116
+ .leaflet-cluster-icon {
69
117
  background-color: var(--mtds-color-base-default);
70
118
  border-radius: 100%;
119
+ border: 1px solid;
120
+ box-sizing: border-box;
71
121
  color: var(--mtds-color-base-contrast-default);
72
- font-weight: 500;
122
+ display: flex;
73
123
  font-size: var(--mtds-body-xs-font-size);
74
- line-height: var(--mtdsc-atlas-cluster-size);
75
- text-align: center;
76
-
77
- /* biome-ignore lint/complexity/noImportantStyles: need to overwrite style attribute */
78
- width: var(--mtdsc-atlas-cluster-size) !important;
79
- /* biome-ignore lint/complexity/noImportantStyles: need to overwrite style attribute */
80
- height: var(--mtdsc-atlas-cluster-size) !important;
81
- /* biome-ignore lint/complexity/noImportantStyles: need to overwrite style attribute */
82
- margin: calc(var(--mtdsc-atlas-cluster-size) / -2) !important;
124
+ font-weight: 500;
125
+ place-content: center;
126
+ place-items: center;
83
127
  }
128
+ /* .leaflet-marker-icon::after {
129
+ aspect-ratio: 1;
130
+ background: #fff;
131
+ border-radius: 50% 50% 0 50%;
132
+ border: 1px solid red;
133
+ content: "";
134
+ inset: 0 0 auto;
135
+ position: absolute;
136
+ rotate: 45deg;
137
+ } */
84
138
  `;
85
139
  export {
86
140
  t as default
@@ -1 +1 @@
1
- {"version":3,"file":"atlas.css.js","sources":["../../designsystem/atlas/atlas.css?raw"],"sourcesContent":["export default \":host {\\n\\t--mtdsc-atlas-cluster-size: var(--mtds-8);\\n\\t--mtdsc-atlas-background: #fbfbfb;\\n\\t--mtdsc-atlas-border-color: var(--ds-color-border-subtle);\\n\\t--mtdsc-atlas-border: var(--ds-border-width-default) solid\\n\\t\\tvar(--mtdsc-atlas-border-color);\\n\\n\\tborder-radius: var(--ds-border-radius-md);\\n\\taspect-ratio: 2;\\n\\toverflow: clip;\\n\\tposition: relative;\\n\\tuser-select: none;\\n}\\n:host(:not([hidden])) {\\n\\tdisplay: grid;\\n}\\n:host([data-cursor=\\\"pointer\\\"]) .leaflet-grab {\\n\\tcursor: pointer;\\n}\\n.leaflet-tile-container {\\n\\tfilter: grayscale(1) contrast(0.75) brightness(1.15);\\n}\\n:host([data-tiles=\\\"color\\\"]) .leaflet-tile-container {\\n\\tfilter: grayscale(0.2);\\n}\\n:host([data-tiles=\\\"color\\\"]) {\\n\\t--mtdsc-atlas-background: #e5fcfd;\\n}\\n:host:has(.leaflet-container:focus-visible) {\\n\\tbox-shadow: var(--dsc-focus-boxShadow);\\n\\toutline: var(--dsc-focus-outline);\\n\\toutline-offset: var(--ds-border-width-focus);\\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\\tbackground: var(--mtdsc-atlas-background);\\n\\tborder-radius: inherit;\\n\\tborder: var(--mtdsc-atlas-border);\\n\\tbox-sizing: border-box;\\n\\tfont: inherit;\\n\\toutline: 0;\\n}\\n.leaflet-control-attribution {\\n\\tfont-size: 12px;\\n\\tborder-top-left-radius: var(--ds-border-radius-md);\\n}\\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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;"}
1
+ {"version":3,"file":"atlas.css.js","sources":["../../designsystem/atlas/atlas.css?raw"],"sourcesContent":["export default \"/* NOTE: Using --mtds- not --mtds- since we're inside shadow dom */\\n:host {\\n\\t--mtdsc-atlas-background: #fbfbfb;\\n\\t--mtdsc-atlas-border: var(--mtds-border-width-default) solid\\n\\t\\tvar(--mtds-color-border-subtle);\\n\\n\\tborder-radius: var(--mtds-border-radius-md);\\n\\taspect-ratio: 2;\\n\\toverflow: clip;\\n\\tposition: relative;\\n}\\n:host(:not([hidden])) {\\n\\tdisplay: block;\\n}\\n:host([data-cursor=\\\"pointer\\\"]) .leaflet-grab {\\n\\tcursor: pointer;\\n}\\nslot {\\n\\tdisplay: block;\\n\\tinset: 0;\\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\\n/* Focus */\\n.leaflet-control-zoom a:focus-visible,\\n:host:has(.leaflet-container:focus-visible) {\\n\\tbox-shadow: var(--dsc-focus-boxShadow);\\n\\toutline: var(--dsc-focus-outline);\\n\\toutline-offset: var(--mtds-border-width-focus);\\n}\\n\\n/* Map and tiles */\\n.leaflet-container {\\n\\tbackground: var(--mtdsc-atlas-background);\\n\\tborder-radius: inherit;\\n\\tborder: var(--mtdsc-atlas-border);\\n\\tbox-sizing: border-box;\\n\\tfont: inherit;\\n\\theight: 100%;\\n\\toutline: 0;\\n\\tposition: relative;\\n\\tz-index: 1; /* Ensure <slot> is always on top */\\n}\\n.leaflet-tile-container {\\n\\tfilter: grayscale(1) contrast(0.75) brightness(1.15);\\n\\ttransition: filter 0.5s;\\n}\\n:host([data-tiles=\\\"color\\\"]) {\\n\\t--mtdsc-atlas-background: #e5fcfd;\\n}\\n:host([data-tiles=\\\"color\\\"]) .leaflet-tile-container {\\n\\tfilter: grayscale(0.2);\\n}\\n\\n/* Controls */\\n.leaflet-control-attribution {\\n\\tfont-size: 12px;\\n\\tborder-top-left-radius: var(--mtds-border-radius-md);\\n}\\n.leaflet-control-zoom {\\n\\tborder-radius: var(--mtds-border-radius-md);\\n\\tborder: 1px solid var(--mtds-color-border-default);\\n}\\n.leaflet-control-zoom a {\\n\\tborder-color: inherit;\\n\\tbackground: var(--mtds-color-surface-default);\\n\\tcolor: var(--mtds-color-text-default);\\n\\tdisplay: flex;\\n\\theight: var(--mtds-10);\\n\\toutline: 0;\\n\\tplace-content: center;\\n\\tplace-items: center;\\n\\ttransition: 0.2s;\\n\\twidth: var(--mtds-10);\\n}\\n.leaflet-control-zoom a:first-child {\\n\\tborder-top-left-radius: inherit;\\n\\tborder-top-right-radius: inherit;\\n}\\n.leaflet-control-zoom a:last-child {\\n\\tborder-bottom-left-radius: inherit;\\n\\tborder-bottom-right-radius: inherit;\\n}\\n.leaflet-control-zoom a:hover {\\n\\tbackground: var(--mtds-color-surface-hover);\\n}\\n.leaflet-control-zoom a:active {\\n\\tbackground: var(--mtds-color-surface-active);\\n}\\n\\n/* Markers */\\n.leaflet-tooltip {\\n\\tbackground: var(--mtds-color-surface-default);\\n\\tborder-radius: var(--mtds-border-radius-md);\\n\\tbox-shadow: var(--mtds-box-shadow-sm);\\n\\tcolor: var(--mtds-color-text-default);\\n\\tpadding: var(--mtds-1) var(--mtds-2);\\n}\\n.leaflet-marker-icon {\\n\\tbackground: none;\\n\\tborder: 0;\\n}\\n.leaflet-marker-icon rect {\\n\\tfill: var(--mtds-color-base-contrast-default);\\n}\\n.leaflet-marker-icon path {\\n\\tfill: var(--mtds-color-base-default);\\n\\tstroke: var(--mtds-color-base-contrast-default);\\n\\tvector-effect: non-scaling-stroke;\\n}\\n.leaflet-cluster-icon {\\n\\tbackground-color: var(--mtds-color-base-default);\\n\\tborder-radius: 100%;\\n\\tborder: 1px solid;\\n\\tbox-sizing: border-box;\\n\\tcolor: var(--mtds-color-base-contrast-default);\\n\\tdisplay: flex;\\n\\tfont-size: var(--mtds-body-xs-font-size);\\n\\tfont-weight: 500;\\n\\tplace-content: center;\\n\\tplace-items: center;\\n}\\n/* .leaflet-marker-icon::after {\\n\\taspect-ratio: 1;\\n\\tbackground: #fff;\\n\\tborder-radius: 50% 50% 0 50%;\\n\\tborder: 1px solid red;\\n\\tcontent: \\\"\\\";\\n\\tinset: 0 0 auto;\\n\\tposition: absolute;\\n\\trotate: 45deg;\\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;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;AAAA;AAAA;AAAA;"}
@@ -15,4 +15,6 @@ export declare const WithCustomSize: Story;
15
15
  export declare const WithMarker: Story;
16
16
  export declare const WithClickToAddMarker: Story;
17
17
  export declare const WithClustering: Story;
18
+ export declare const WithPopover: Story;
19
+ export declare const WithTooltip: Story;
18
20
  export declare const WithoutScrollZoom: Story;
@@ -52,7 +52,7 @@ u.MarkerClusterGroup = u.FeatureGroup.extend({
52
52
  return this._needsClustering.push(t), this.fire("layeradd", { layer: t, propagatedFrom: t }), this;
53
53
  if (this.hasLayer(t))
54
54
  return this;
55
- this._unspiderfy && this._unspiderfy(), this._addLayer(t, this._maxZoom), this.fire("layeradd", { layer: t }), this._topClusterLevel._recalculateBounds(), this._refreshClustersIcons();
55
+ this._unspiderfy && this._unspiderfy(), this._addLayer(t, this._maxZoom), this.fire("layeradd", { layer: t, propagatedFrom: t }), this._topClusterLevel._recalculateBounds(), this._refreshClustersIcons();
56
56
  var e = t, i = this._zoom;
57
57
  if (t.__parent)
58
58
  for (; e.__parent._zoom >= i; )