@mattilsynet/design 2.3.6 → 2.3.7

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.
@@ -24,7 +24,7 @@ class m extends C {
24
24
  "style",
25
25
  null,
26
26
  `@layer leaflet{${f}}
27
- @layer mt.v2-3-6design{${b}`
27
+ @layer mt.v2-3-7design{${b}`
28
28
  ),
29
29
  r("figure")
30
30
  );
@@ -1,16 +1,16 @@
1
1
  import { booleanPointInPolygon as c } from "../external/@turf/boolean-point-in-polygon/dist/esm/index.js";
2
2
  import { point as d } from "../external/@turf/helpers/dist/esm/index.js";
3
3
  import r from "../external/leaflet/dist/leaflet-src.js";
4
- import { defineElement as g, MTDSElement as m, debounce as p, attr as n } from "../utils.js";
4
+ import { defineElement as g, MTDSElement as p, debounce as m, attr as n } from "../utils.js";
5
5
  const h = "moveend zoomend refresh";
6
- class u extends m {
6
+ class u extends p {
7
7
  atlas;
8
8
  geojson;
9
9
  static get observedAttributes() {
10
10
  return ["hidden", "data-collection", "data-color", "popovertarget"];
11
11
  }
12
12
  constructor() {
13
- super(), this.refresh = p(this.refresh, 300);
13
+ super(), this.refresh = m(this.refresh, 300);
14
14
  }
15
15
  connectedCallback() {
16
16
  queueMicrotask(() => {
@@ -31,7 +31,7 @@ class u extends m {
31
31
  !this.geojson || !this.atlas?.map?.hasLayer(this.geojson) || this.getCollection().then((s) => {
32
32
  const o = s?.links.find(({ rel: e }) => e === "items"), a = t === !0 ? `&nocache=${Date.now()}` : "", i = this.atlas?.map?.getBounds().toBBoxString();
33
33
  s ? fetch(`${o?.href}?bbox=${i}${a}`).then((e) => e.json()).then((e) => this.geojson?.clearLayers().addData(e)) : this.atlas?.getCollections().then((e) => {
34
- const l = `mtds-atlas-matgeo: Please set a vaild \x1B[103mdata-collection="${Object.keys(e).join(" | ")}"\x1B[m`;
34
+ const l = `mtds-atlas-matgeo: Please set a vaild data-collection="${Object.keys(e).join(" | ")}"`;
35
35
  console.warn(l);
36
36
  });
37
37
  });
@@ -1 +1 @@
1
- {"version":3,"file":"atlas-matgeo.js","sources":["../../designsystem/atlas/atlas-matgeo.ts"],"sourcesContent":["import { booleanPointInPolygon as inGeo } from \"@turf/boolean-point-in-polygon\";\nimport { point as turfPoint } from \"@turf/helpers\";\n\nimport L from \"leaflet\";\nimport { attr, debounce, defineElement, MTDSElement } from \"../utils\";\nimport type { MTDSAtlasCollection, MTDSAtlasElement } from \"./atlas-element\";\n\ntype Feature = L.Polygon[\"feature\"];\ntype LayerWithFeature = L.Layer & { feature?: Feature };\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t\"mtds-atlas-matgeo\": MTDSAtlasMatgeoElement;\n\t}\n\tinterface GlobalEventHandlersEventMap {\n\t\tatlasfeatureclick: CustomEvent<\n\t\t\tOmit<L.LeafletMouseEvent, \"target\"> & {\n\t\t\t\ttargets: LayerWithFeature[];\n\t\t\t\tcollections: MTDSAtlasCollection[];\n\t\t\t}\n\t\t>;\n\t}\n}\n\nconst EVENTS = \"moveend zoomend refresh\";\n\nexport class MTDSAtlasMatgeoElement extends MTDSElement {\n\tatlas?: MTDSAtlasElement;\n\tgeojson?: L.GeoJSON;\n\n\tstatic get observedAttributes() {\n\t\treturn [\"hidden\", \"data-collection\", \"data-color\", \"popovertarget\"]; // Using ES2015 syntax for backwards compatibility\n\t}\n\tconstructor() {\n\t\tsuper();\n\t\tthis.refresh = debounce(this.refresh, 300); // Debounce to avoid too many requests\n\t}\n\tconnectedCallback() {\n\t\tqueueMicrotask(() => {\n\t\t\tthis.atlas = this.closest<MTDSAtlasElement>(\"mtds-atlas\") || undefined;\n\t\t\tthis.atlas?.map?.on(EVENTS, this.refresh, this);\n\t\t\tthis.geojson = new L.GeoJSON(null, {\n\t\t\t\tstyle: this.#getStyle(),\n\t\t\t\tonEachFeature: (_, layer) => layer.on(\"click\", this.handleEvent, this),\n\t\t\t}).bindPopup(() => `#${attr(this, \"popovertarget\")}`);\n\t\t\tthis.refresh();\n\t\t\tthis.attributeChangedCallback(\"hidden\"); // Maybe add to map\n\t\t}); // Let the atlas parent initialize first\n\t}\n\tattributeChangedCallback(name?: string) {\n\t\tconst geojson = this.geojson;\n\t\tconst map = this.atlas?.map;\n\t\tif (name === \"popovertarget\") geojson?.getPopup()?.update();\n\t\tif (name === \"data-color\") geojson?.setStyle(this.#getStyle());\n\t\tif (name === \"data-collection\") this.refresh();\n\t\tif (name === \"hidden\" && geojson && map)\n\t\t\tmap[this.hidden ? \"removeLayer\" : \"addLayer\"](geojson);\n\t}\n\tdisconnectedCallback() {\n\t\tthis.atlas?.map?.off(EVENTS, this.refresh, this);\n\t\tthis.geojson?.unbindPopup().remove();\n\t\tthis.geojson = this.atlas = undefined;\n\t}\n\trefresh(nocache?: boolean | L.LeafletEvent) {\n\t\tif (!this.geojson || !this.atlas?.map?.hasLayer(this.geojson)) return;\n\t\tthis.getCollection().then((collection) => {\n\t\t\tconst items = collection?.links.find(({ rel }) => rel === \"items\");\n\t\t\tconst cache = nocache === true ? `&nocache=${Date.now()}` : \"\";\n\t\t\tconst bbox = this.atlas?.map?.getBounds().toBBoxString();\n\n\t\t\tif (!collection)\n\t\t\t\tthis.atlas?.getCollections().then((collections) => {\n\t\t\t\t\tconst message = `mtds-atlas-matgeo: Please set a vaild \\x1B[103mdata-collection=\"${Object.keys(collections).join(\" | \")}\"\\x1B[m`;\n\t\t\t\t\tconsole.warn(message);\n\t\t\t\t});\n\t\t\telse\n\t\t\t\tfetch(`${items?.href}?bbox=${bbox}${cache}`)\n\t\t\t\t\t.then((res) => res.json())\n\t\t\t\t\t.then((data) => this.geojson?.clearLayers().addData(data));\n\t\t});\n\t}\n\thandleEvent(event: L.LeafletMouseEvent) {\n\t\tevent.originalEvent.stopPropagation(); // Prevent clicks from bubbling from ShadowDOM\n\t\tthis.atlas?.getCollections().then((collections) => {\n\t\t\tconst targets: LayerWithFeature[] = [event.target]; // Leaflet does not list all clicked layers, so we find them manually\n\t\t\tconst detail = { ...event, targets, collections };\n\t\t\tconst point = turfPoint([event.latlng.lng, event.latlng.lat]);\n\n\t\t\tthis.atlas?.map?.eachLayer((layer: LayerWithFeature) => {\n\t\t\t\tif (layer === event.target) return; // Already added\n\t\t\t\tconst inside =\n\t\t\t\t\t(layer.feature?.geometry && inGeo(point, layer.feature.geometry)) ||\n\t\t\t\t\t(layer instanceof L.Marker && layer.getLatLng().equals(event.latlng));\n\t\t\t\tif (inside) targets.push(layer);\n\t\t\t});\n\n\t\t\tthis.dispatchEvent(new MouseEvent(\"click\", event.originalEvent)); // Forward click, but from <mtds-atlas-matgeo> element\n\t\t\tthis.dispatchEvent(\n\t\t\t\tnew CustomEvent(\"atlasfeatureclick\", { detail, bubbles: true }),\n\t\t\t);\n\t\t});\n\t}\n\tasync getCollection() {\n\t\treturn this.atlas\n\t\t\t?.getCollections()\n\t\t\t.then((cols) => cols?.[attr(this, \"data-collection\") || \"\"]);\n\t}\n\t#getStyle() {\n\t\treturn {\n\t\t\tcolor: `var(--mtds-color-${attr(this, \"data-color\") || \"main\"}-base-default)`,\n\t\t};\n\t}\n}\n\ndefineElement(\"mtds-atlas-matgeo\", MTDSAtlasMatgeoElement);\n"],"names":["EVENTS","MTDSAtlasMatgeoElement","MTDSElement","debounce","L","#getStyle","_","layer","attr","name","geojson","map","nocache","collection","items","rel","cache","bbox","res","data","collections","message","event","targets","detail","point","turfPoint","inGeo","cols","defineElement"],"mappings":";;;;AAuBA,MAAMA,IAAS;AAER,MAAMC,UAA+BC,EAAY;AAAA,EACvD;AAAA,EACA;AAAA,EAEA,WAAW,qBAAqB;AAC/B,WAAO,CAAC,UAAU,mBAAmB,cAAc,eAAe;AAAA,EACnE;AAAA,EACA,cAAc;AACb,UAAA,GACA,KAAK,UAAUC,EAAS,KAAK,SAAS,GAAG;AAAA,EAC1C;AAAA,EACA,oBAAoB;AACnB,mBAAe,MAAM;AACpB,WAAK,QAAQ,KAAK,QAA0B,YAAY,KAAK,QAC7D,KAAK,OAAO,KAAK,GA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AACD;AAEAqB,EAAc,qBAAqB5B,CAAsB;"}
1
+ {"version":3,"file":"atlas-matgeo.js","sources":["../../designsystem/atlas/atlas-matgeo.ts"],"sourcesContent":["import { booleanPointInPolygon as inGeo } from \"@turf/boolean-point-in-polygon\";\nimport { point as turfPoint } from \"@turf/helpers\";\n\nimport L from \"leaflet\";\nimport { attr, debounce, defineElement, MTDSElement } from \"../utils\";\nimport type { MTDSAtlasCollection, MTDSAtlasElement } from \"./atlas-element\";\n\ntype Feature = L.Polygon[\"feature\"];\ntype LayerWithFeature = L.Layer & { feature?: Feature };\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t\"mtds-atlas-matgeo\": MTDSAtlasMatgeoElement;\n\t}\n\tinterface GlobalEventHandlersEventMap {\n\t\tatlasfeatureclick: CustomEvent<\n\t\t\tOmit<L.LeafletMouseEvent, \"target\"> & {\n\t\t\t\ttargets: LayerWithFeature[];\n\t\t\t\tcollections: MTDSAtlasCollection[];\n\t\t\t}\n\t\t>;\n\t}\n}\n\nconst EVENTS = \"moveend zoomend refresh\";\n\nexport class MTDSAtlasMatgeoElement extends MTDSElement {\n\tatlas?: MTDSAtlasElement;\n\tgeojson?: L.GeoJSON;\n\n\tstatic get observedAttributes() {\n\t\treturn [\"hidden\", \"data-collection\", \"data-color\", \"popovertarget\"]; // Using ES2015 syntax for backwards compatibility\n\t}\n\tconstructor() {\n\t\tsuper();\n\t\tthis.refresh = debounce(this.refresh, 300); // Debounce to avoid too many requests\n\t}\n\tconnectedCallback() {\n\t\tqueueMicrotask(() => {\n\t\t\tthis.atlas = this.closest<MTDSAtlasElement>(\"mtds-atlas\") || undefined;\n\t\t\tthis.atlas?.map?.on(EVENTS, this.refresh, this);\n\t\t\tthis.geojson = new L.GeoJSON(null, {\n\t\t\t\tstyle: this.#getStyle(),\n\t\t\t\tonEachFeature: (_, layer) => layer.on(\"click\", this.handleEvent, this),\n\t\t\t}).bindPopup(() => `#${attr(this, \"popovertarget\")}`);\n\t\t\tthis.refresh();\n\t\t\tthis.attributeChangedCallback(\"hidden\"); // Maybe add to map\n\t\t}); // Let the atlas parent initialize first\n\t}\n\tattributeChangedCallback(name?: string) {\n\t\tconst geojson = this.geojson;\n\t\tconst map = this.atlas?.map;\n\t\tif (name === \"popovertarget\") geojson?.getPopup()?.update();\n\t\tif (name === \"data-color\") geojson?.setStyle(this.#getStyle());\n\t\tif (name === \"data-collection\") this.refresh();\n\t\tif (name === \"hidden\" && geojson && map)\n\t\t\tmap[this.hidden ? \"removeLayer\" : \"addLayer\"](geojson);\n\t}\n\tdisconnectedCallback() {\n\t\tthis.atlas?.map?.off(EVENTS, this.refresh, this);\n\t\tthis.geojson?.unbindPopup().remove();\n\t\tthis.geojson = this.atlas = undefined;\n\t}\n\trefresh(nocache?: boolean | L.LeafletEvent) {\n\t\tif (!this.geojson || !this.atlas?.map?.hasLayer(this.geojson)) return;\n\t\tthis.getCollection().then((collection) => {\n\t\t\tconst items = collection?.links.find(({ rel }) => rel === \"items\");\n\t\t\tconst cache = nocache === true ? `&nocache=${Date.now()}` : \"\";\n\t\t\tconst bbox = this.atlas?.map?.getBounds().toBBoxString();\n\n\t\t\tif (!collection)\n\t\t\t\tthis.atlas?.getCollections().then((collections) => {\n\t\t\t\t\tconst message = `mtds-atlas-matgeo: Please set a vaild data-collection=\"${Object.keys(collections).join(\" | \")}\"`;\n\t\t\t\t\tconsole.warn(message);\n\t\t\t\t});\n\t\t\telse\n\t\t\t\tfetch(`${items?.href}?bbox=${bbox}${cache}`)\n\t\t\t\t\t.then((res) => res.json())\n\t\t\t\t\t.then((data) => this.geojson?.clearLayers().addData(data));\n\t\t});\n\t}\n\thandleEvent(event: L.LeafletMouseEvent) {\n\t\tevent.originalEvent.stopPropagation(); // Prevent clicks from bubbling from ShadowDOM\n\t\tthis.atlas?.getCollections().then((collections) => {\n\t\t\tconst targets: LayerWithFeature[] = [event.target]; // Leaflet does not list all clicked layers, so we find them manually\n\t\t\tconst detail = { ...event, targets, collections };\n\t\t\tconst point = turfPoint([event.latlng.lng, event.latlng.lat]);\n\n\t\t\tthis.atlas?.map?.eachLayer((layer: LayerWithFeature) => {\n\t\t\t\tif (layer === event.target) return; // Already added\n\t\t\t\tconst inside =\n\t\t\t\t\t(layer.feature?.geometry && inGeo(point, layer.feature.geometry)) ||\n\t\t\t\t\t(layer instanceof L.Marker && layer.getLatLng().equals(event.latlng));\n\t\t\t\tif (inside) targets.push(layer);\n\t\t\t});\n\n\t\t\tthis.dispatchEvent(new MouseEvent(\"click\", event.originalEvent)); // Forward click, but from <mtds-atlas-matgeo> element\n\t\t\tthis.dispatchEvent(\n\t\t\t\tnew CustomEvent(\"atlasfeatureclick\", { detail, bubbles: true }),\n\t\t\t);\n\t\t});\n\t}\n\tasync getCollection() {\n\t\treturn this.atlas\n\t\t\t?.getCollections()\n\t\t\t.then((cols) => cols?.[attr(this, \"data-collection\") || \"\"]);\n\t}\n\t#getStyle() {\n\t\treturn {\n\t\t\tcolor: `var(--mtds-color-${attr(this, \"data-color\") || \"main\"}-base-default)`,\n\t\t};\n\t}\n}\n\ndefineElement(\"mtds-atlas-matgeo\", MTDSAtlasMatgeoElement);\n"],"names":["EVENTS","MTDSAtlasMatgeoElement","MTDSElement","debounce","L","#getStyle","_","layer","attr","name","geojson","map","nocache","collection","items","rel","cache","bbox","res","data","collections","message","event","targets","detail","point","turfPoint","inGeo","cols","defineElement"],"mappings":";;;;AAuBA,MAAMA,IAAS;AAER,MAAMC,UAA+BC,EAAY;AAAA,EACvD;AAAA,EACA;AAAA,EAEA,WAAW,qBAAqB;AAC/B,WAAO,CAAC,UAAU,mBAAmB,cAAc,eAAe;AAAA,EACnE;AAAA,EACA,cAAc;AACb,UAAA,GACA,KAAK,UAAUC,EAAS,KAAK,SAAS,GAAG;AAAA,EAC1C;AAAA,EACA,oBAAoB;AACnB,mBAAe,MAAM;AACpB,WAAK,QAAQ,KAAK,QAA0B,YAAY,KAAK,QAC7D,KAAK,OAAO,KAAK,GAAGH,GAAQ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qB,EAAc,qBAAqB5B,CAAsB;"}
@@ -733,5 +733,5 @@ path.leaflet-interactive:focus:not(:focus-visible) {
733
733
  .leaflet-popup:has(slot) .leaflet-popup-content-wrapper { display: contents } /* No need for styling this element */
734
734
  .leaflet-popup:has(slot) .leaflet-popup-content { margin: 0; font: inherit }
735
735
 
736
- `;let sn=0;class on extends ue{atlas;marker;static get observedAttributes(){return["hidden","draggable","data-latlng","popovertarget"]}connectedCallback(){queueMicrotask(()=>{const t=ce("slot",{name:`${++sn}`}),e=new _.DivIcon({html:t,iconSize:[0,0]});this.atlas=this.closest("mtds-atlas")||void 0,this.marker=new _.Marker(this.#t(),{draggable:this.draggable,keyboard:!1,icon:e}),this.marker.bindPopup(()=>`#${A(this,"popovertarget")}`),this.marker.on("dragend",this.#e),nn(this,"click,keydown",this),A(this,"slot",`${sn}`),A(this,"role","button"),A(this,"tabindex","0"),this.attributeChangedCallback("hidden")})}attributeChangedCallback(t){const e=this.marker,i=this.atlas?.cluster;if(t==="popovertarget"&&e?.getPopup()?.update(),t==="data-latlng"){const s=this.#t();e?.getLatLng().equals(s)||e?.setLatLng(s)}t==="draggable"&&e?.dragging?.[this.draggable?"enable":"disable"](),t==="hidden"&&e&&i&&i[this.hidden?"removeLayer":"addLayer"](e)}disconnectedCallback(){Ke(this,"click,keydown",this),this.marker?.unbindPopup().off("dragend",this.#e).remove(),this.marker=this.atlas=void 0}handleEvent(t){if(t.type==="click")return this.marker?.fire("click");t.key===" "&&t.preventDefault(),(t.key===" "||t.key==="Enter")&&this.click()}get latlng(){return A(this,"data-latlng")||""}set latlng(t){A(this,"data-latlng",t)}#t(){return this.latlng?.split(",").map(parseFloat)}#e(t){const i=t.target._icon?.firstElementChild?.assignedElements?.()?.[0],{lat:s,lng:o}=t.target.getLatLng();i&&(i.latlng=`${s},${o}`),i?.dispatchEvent(new CustomEvent("dragend",{detail:t,bubbles:!0}))}}pe("mtds-atlas-marker",on);const lt=11102230246251565e-32,R=134217729,ts=(3+8*lt)*lt;function Ye(n,t,e,i,s){let o,r,a,l,h=t[0],d=i[0],c=0,u=0;d>h==d>-h?(o=h,h=t[++c]):(o=d,d=i[++u]);let p=0;if(c<n&&u<e)for(d>h==d>-h?(r=h+o,a=o-(r-h),h=t[++c]):(r=d+o,a=o-(r-d),d=i[++u]),o=r,a!==0&&(s[p++]=a);c<n&&u<e;)d>h==d>-h?(r=o+h,l=r-o,a=o-(r-l)+(h-l),h=t[++c]):(r=o+d,l=r-o,a=o-(r-l)+(d-l),d=i[++u]),o=r,a!==0&&(s[p++]=a);for(;c<n;)r=o+h,l=r-o,a=o-(r-l)+(h-l),h=t[++c],o=r,a!==0&&(s[p++]=a);for(;u<e;)r=o+d,l=r-o,a=o-(r-l)+(d-l),d=i[++u],o=r,a!==0&&(s[p++]=a);return(o!==0||p===0)&&(s[p++]=o),p}function es(n,t){let e=t[0];for(let i=1;i<n;i++)e+=t[i];return e}function Wt(n){return new Float64Array(n)}const is=(3+16*lt)*lt,ns=(2+12*lt)*lt,ss=(9+64*lt)*lt*lt,Mt=Wt(4),rn=Wt(8),an=Wt(12),ln=Wt(16),j=Wt(4);function os(n,t,e,i,s,o,r){let a,l,h,d,c,u,p,y,g,x,v,M,B,O,I,Z,$,E;const T=n-s,N=e-s,U=t-o,q=i-o;O=T*q,u=R*T,p=u-(u-T),y=T-p,u=R*q,g=u-(u-q),x=q-g,I=y*x-(O-p*g-y*g-p*x),Z=U*N,u=R*U,p=u-(u-U),y=U-p,u=R*N,g=u-(u-N),x=N-g,$=y*x-(Z-p*g-y*g-p*x),v=I-$,c=I-v,Mt[0]=I-(v+c)+(c-$),M=O+v,c=M-O,B=O-(M-c)+(v-c),v=B-Z,c=B-v,Mt[1]=B-(v+c)+(c-Z),E=M+v,c=E-M,Mt[2]=M-(E-c)+(v-c),Mt[3]=E;let Q=es(4,Mt),ht=ns*r;if(Q>=ht||-Q>=ht||(c=n-T,a=n-(T+c)+(c-s),c=e-N,h=e-(N+c)+(c-s),c=t-U,l=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),l=r-a,h=Math.abs(r+a);return Math.abs(l)>=is*h?l:-os(n,t,e,i,s,o,h)}function as(n,t){var e,i,s=0,o,r,a,l,h,d,c,u=n[0],p=n[1],y=t.length;for(e=0;e<y;e++){i=0;var g=t[e],x=g.length-1;if(d=g[0],d[0]!==g[x][0]&&d[1]!==g[x][1])throw new Error("First and last coordinates in a ring must be the same");for(r=d[0]-u,a=d[1]-p,i;i<x;i++){if(c=g[i+1],l=c[0]-u,h=c[1]-p,a===0&&h===0){if(l<=0&&r>=0||r<=0&&l>=0)return 0}else if(h>=0&&a<=0||h<=0&&a>=0){if(o=rs(r,l,a,h,0,0),o===0)return 0;(o>0&&h>0&&a<=0||o<0&&h<=0&&a>0)&&s++}d=c,a=h,r=l}}return s%2!==0}function ls(n,t,e={}){const i={type:"Feature"};return(e.id===0||e.id)&&(i.id=e.id),e.bbox&&(i.bbox=e.bbox),i.properties={},i.geometry=n,i}function hs(n,t,e={}){if(!n)throw new Error("coordinates is required");if(!Array.isArray(n))throw new Error("coordinates must be an Array");if(n.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!hn(n[0])||!hn(n[1]))throw new Error("coordinates must contain numbers");return ls({type:"Point",coordinates:n},t,e)}function hn(n){return!isNaN(n)&&n!==null&&!Array.isArray(n)}function ds(n){if(!n)throw new Error("coord is required");if(!Array.isArray(n)){if(n.type==="Feature"&&n.geometry!==null&&n.geometry.type==="Point")return[...n.geometry.coordinates];if(n.type==="Point")return[...n.coordinates]}if(Array.isArray(n)&&n.length>=2&&!Array.isArray(n[0])&&!Array.isArray(n[1]))return[...n];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function cs(n){return n.type==="Feature"?n.geometry:n}function us(n,t,e={}){if(!n)throw new Error("point is required");if(!t)throw new Error("polygon is required");const i=ds(n),s=cs(t),o=s.type,r=t.bbox;let a=s.coordinates;if(r&&ps(i,r)===!1)return!1;o==="Polygon"&&(a=[a]);let l=!1;for(var h=0;h<a.length;++h){const d=as(i,a[h]);if(d===0)return!e.ignoreBoundary;d&&(l=!0)}return l}function ps(n,t){return t[0]<=n[0]&&t[1]<=n[1]&&t[2]>=n[0]&&t[3]>=n[1]}const dn="moveend zoomend refresh";class cn extends ue{atlas;geojson;static get observedAttributes(){return["hidden","data-collection","data-color","popovertarget"]}constructor(){super(),this.refresh=Jn(this.refresh,300)}connectedCallback(){queueMicrotask(()=>{this.atlas=this.closest("mtds-atlas")||void 0,this.atlas?.map?.on(dn,this.refresh,this),this.geojson=new _.GeoJSON(null,{style:this.#t(),onEachFeature:(t,e)=>e.on("click",this.handleEvent,this)}).bindPopup(()=>`#${A(this,"popovertarget")}`),this.refresh(),this.attributeChangedCallback("hidden")})}attributeChangedCallback(t){const e=this.geojson,i=this.atlas?.map;t==="popovertarget"&&e?.getPopup()?.update(),t==="data-color"&&e?.setStyle(this.#t()),t==="data-collection"&&this.refresh(),t==="hidden"&&e&&i&&i[this.hidden?"removeLayer":"addLayer"](e)}disconnectedCallback(){this.atlas?.map?.off(dn,this.refresh,this),this.geojson?.unbindPopup().remove(),this.geojson=this.atlas=void 0}refresh(t){!this.geojson||!this.atlas?.map?.hasLayer(this.geojson)||this.getCollection().then(e=>{const i=e?.links.find(({rel:r})=>r==="items"),s=t===!0?`&nocache=${Date.now()}`:"",o=this.atlas?.map?.getBounds().toBBoxString();e?fetch(`${i?.href}?bbox=${o}${s}`).then(r=>r.json()).then(r=>this.geojson?.clearLayers().addData(r)):this.atlas?.getCollections().then(r=>{const a=`mtds-atlas-matgeo: Please set a vaild \x1B[103mdata-collection="${Object.keys(r).join(" | ")}"\x1B[m`;console.warn(a)})})}handleEvent(t){t.originalEvent.stopPropagation(),this.atlas?.getCollections().then(e=>{const i=[t.target],s={...t,targets:i,collections:e},o=hs([t.latlng.lng,t.latlng.lat]);this.atlas?.map?.eachLayer(r=>{if(r===t.target)return;(r.feature?.geometry&&us(o,r.feature.geometry)||r instanceof _.Marker&&r.getLatLng().equals(t.latlng))&&i.push(r)}),this.dispatchEvent(new MouseEvent("click",t.originalEvent)),this.dispatchEvent(new CustomEvent("atlasfeatureclick",{detail:s,bubbles:!0}))})}async getCollection(){return this.atlas?.getCollections().then(t=>t?.[A(this,"data-collection")||""])}#t(){return{color:`var(--mtds-color-${A(this,"data-color")||"main"}-base-default)`}}}pe("mtds-atlas-matgeo",cn);class un extends ue{atlas;wms;static get observedAttributes(){return["hidden","data-url","popovertarget"]}connectedCallback(){queueMicrotask(()=>{this.atlas=this.closest("mtds-atlas")||void 0,this.refresh()})}attributeChangedCallback(t){t==="data-url"&&this.refresh(),t==="popovertarget"&&this.wms?.getPopup()?.update(),t==="hidden"&&this.wms&&(this.atlas?.map?.[this.hidden?"removeLayer":"addLayer"](this.wms),this.wms.bringToFront())}refresh(){const t=new URL(A(this,"data-url")||""),e=Object.fromEntries(t.searchParams.entries());this.wms?.unbindPopup().remove(),this.wms=new _.TileLayer.WMS(`${t.origin}${t.pathname}`,e),this.attributeChangedCallback("hidden")}disconnectedCallback(){this.wms?.unbindPopup().remove(),this.wms=this.atlas=void 0}}pe("mtds-atlas-wms",un);let Xe=0;const pn=18,_s="https://cache.kartverket.no/v1/wmts/1.0.0/topo/default/webmercator/{z}/{y}/{x}.png",_n="https://matgeoservice-256616427209.europe-north1.run.app/ogc/features/collections",fs=[[57.5,4.73],[71.5,31.44]];Ve()&&!window._matgeoCollections&&(window._matgeoCollections=fetch(_n).then(n=>n.json()).then(n=>n.collections.map(t=>[t.id,t])).then(Object.fromEntries));class _e extends ue{cluster;map;static get observedAttributes(){return["data-view","data-scrollzoom"]}constructor(){super(),this.attachShadow({mode:"open"}).append(ce("style",null,`@layer leaflet{${Yn}}
736
+ `;let sn=0;class on extends ue{atlas;marker;static get observedAttributes(){return["hidden","draggable","data-latlng","popovertarget"]}connectedCallback(){queueMicrotask(()=>{const t=ce("slot",{name:`${++sn}`}),e=new _.DivIcon({html:t,iconSize:[0,0]});this.atlas=this.closest("mtds-atlas")||void 0,this.marker=new _.Marker(this.#t(),{draggable:this.draggable,keyboard:!1,icon:e}),this.marker.bindPopup(()=>`#${A(this,"popovertarget")}`),this.marker.on("dragend",this.#e),nn(this,"click,keydown",this),A(this,"slot",`${sn}`),A(this,"role","button"),A(this,"tabindex","0"),this.attributeChangedCallback("hidden")})}attributeChangedCallback(t){const e=this.marker,i=this.atlas?.cluster;if(t==="popovertarget"&&e?.getPopup()?.update(),t==="data-latlng"){const s=this.#t();e?.getLatLng().equals(s)||e?.setLatLng(s)}t==="draggable"&&e?.dragging?.[this.draggable?"enable":"disable"](),t==="hidden"&&e&&i&&i[this.hidden?"removeLayer":"addLayer"](e)}disconnectedCallback(){Ke(this,"click,keydown",this),this.marker?.unbindPopup().off("dragend",this.#e).remove(),this.marker=this.atlas=void 0}handleEvent(t){if(t.type==="click")return this.marker?.fire("click");t.key===" "&&t.preventDefault(),(t.key===" "||t.key==="Enter")&&this.click()}get latlng(){return A(this,"data-latlng")||""}set latlng(t){A(this,"data-latlng",t)}#t(){return this.latlng?.split(",").map(parseFloat)}#e(t){const i=t.target._icon?.firstElementChild?.assignedElements?.()?.[0],{lat:s,lng:o}=t.target.getLatLng();i&&(i.latlng=`${s},${o}`),i?.dispatchEvent(new CustomEvent("dragend",{detail:t,bubbles:!0}))}}pe("mtds-atlas-marker",on);const lt=11102230246251565e-32,R=134217729,ts=(3+8*lt)*lt;function Ye(n,t,e,i,s){let o,r,a,l,h=t[0],d=i[0],c=0,u=0;d>h==d>-h?(o=h,h=t[++c]):(o=d,d=i[++u]);let p=0;if(c<n&&u<e)for(d>h==d>-h?(r=h+o,a=o-(r-h),h=t[++c]):(r=d+o,a=o-(r-d),d=i[++u]),o=r,a!==0&&(s[p++]=a);c<n&&u<e;)d>h==d>-h?(r=o+h,l=r-o,a=o-(r-l)+(h-l),h=t[++c]):(r=o+d,l=r-o,a=o-(r-l)+(d-l),d=i[++u]),o=r,a!==0&&(s[p++]=a);for(;c<n;)r=o+h,l=r-o,a=o-(r-l)+(h-l),h=t[++c],o=r,a!==0&&(s[p++]=a);for(;u<e;)r=o+d,l=r-o,a=o-(r-l)+(d-l),d=i[++u],o=r,a!==0&&(s[p++]=a);return(o!==0||p===0)&&(s[p++]=o),p}function es(n,t){let e=t[0];for(let i=1;i<n;i++)e+=t[i];return e}function Wt(n){return new Float64Array(n)}const is=(3+16*lt)*lt,ns=(2+12*lt)*lt,ss=(9+64*lt)*lt*lt,Mt=Wt(4),rn=Wt(8),an=Wt(12),ln=Wt(16),j=Wt(4);function os(n,t,e,i,s,o,r){let a,l,h,d,c,u,p,y,g,x,v,M,B,O,I,Z,$,E;const T=n-s,N=e-s,U=t-o,q=i-o;O=T*q,u=R*T,p=u-(u-T),y=T-p,u=R*q,g=u-(u-q),x=q-g,I=y*x-(O-p*g-y*g-p*x),Z=U*N,u=R*U,p=u-(u-U),y=U-p,u=R*N,g=u-(u-N),x=N-g,$=y*x-(Z-p*g-y*g-p*x),v=I-$,c=I-v,Mt[0]=I-(v+c)+(c-$),M=O+v,c=M-O,B=O-(M-c)+(v-c),v=B-Z,c=B-v,Mt[1]=B-(v+c)+(c-Z),E=M+v,c=E-M,Mt[2]=M-(E-c)+(v-c),Mt[3]=E;let Q=es(4,Mt),ht=ns*r;if(Q>=ht||-Q>=ht||(c=n-T,a=n-(T+c)+(c-s),c=e-N,h=e-(N+c)+(c-s),c=t-U,l=t-(U+c)+(c-o),c=i-q,d=i-(q+c)+(c-o),a===0&&l===0&&h===0&&d===0)||(ht=ss*r+ts*Math.abs(Q),Q+=T*d+q*a-(U*h+N*l),Q>=ht||-Q>=ht))return Q;O=a*q,u=R*a,p=u-(u-a),y=a-p,u=R*q,g=u-(u-q),x=q-g,I=y*x-(O-p*g-y*g-p*x),Z=l*N,u=R*l,p=u-(u-l),y=l-p,u=R*N,g=u-(u-N),x=N-g,$=y*x-(Z-p*g-y*g-p*x),v=I-$,c=I-v,j[0]=I-(v+c)+(c-$),M=O+v,c=M-O,B=O-(M-c)+(v-c),v=B-Z,c=B-v,j[1]=B-(v+c)+(c-Z),E=M+v,c=E-M,j[2]=M-(E-c)+(v-c),j[3]=E;const me=Ye(4,Mt,4,j,rn);O=T*d,u=R*T,p=u-(u-T),y=T-p,u=R*d,g=u-(u-d),x=d-g,I=y*x-(O-p*g-y*g-p*x),Z=U*h,u=R*U,p=u-(u-U),y=U-p,u=R*h,g=u-(u-h),x=h-g,$=y*x-(Z-p*g-y*g-p*x),v=I-$,c=I-v,j[0]=I-(v+c)+(c-$),M=O+v,c=M-O,B=O-(M-c)+(v-c),v=B-Z,c=B-v,j[1]=B-(v+c)+(c-Z),E=M+v,c=E-M,j[2]=M-(E-c)+(v-c),j[3]=E;const fn=Ye(me,rn,4,j,an);O=a*d,u=R*a,p=u-(u-a),y=a-p,u=R*d,g=u-(u-d),x=d-g,I=y*x-(O-p*g-y*g-p*x),Z=l*h,u=R*l,p=u-(u-l),y=l-p,u=R*h,g=u-(u-h),x=h-g,$=y*x-(Z-p*g-y*g-p*x),v=I-$,c=I-v,j[0]=I-(v+c)+(c-$),M=O+v,c=M-O,B=O-(M-c)+(v-c),v=B-Z,c=B-v,j[1]=B-(v+c)+(c-Z),E=M+v,c=E-M,j[2]=M-(E-c)+(v-c),j[3]=E;const ms=Ye(fn,an,4,j,ln);return ln[ms-1]}function rs(n,t,e,i,s,o){const r=(t-o)*(e-s),a=(n-s)*(i-o),l=r-a,h=Math.abs(r+a);return Math.abs(l)>=is*h?l:-os(n,t,e,i,s,o,h)}function as(n,t){var e,i,s=0,o,r,a,l,h,d,c,u=n[0],p=n[1],y=t.length;for(e=0;e<y;e++){i=0;var g=t[e],x=g.length-1;if(d=g[0],d[0]!==g[x][0]&&d[1]!==g[x][1])throw new Error("First and last coordinates in a ring must be the same");for(r=d[0]-u,a=d[1]-p,i;i<x;i++){if(c=g[i+1],l=c[0]-u,h=c[1]-p,a===0&&h===0){if(l<=0&&r>=0||r<=0&&l>=0)return 0}else if(h>=0&&a<=0||h<=0&&a>=0){if(o=rs(r,l,a,h,0,0),o===0)return 0;(o>0&&h>0&&a<=0||o<0&&h<=0&&a>0)&&s++}d=c,a=h,r=l}}return s%2!==0}function ls(n,t,e={}){const i={type:"Feature"};return(e.id===0||e.id)&&(i.id=e.id),e.bbox&&(i.bbox=e.bbox),i.properties={},i.geometry=n,i}function hs(n,t,e={}){if(!n)throw new Error("coordinates is required");if(!Array.isArray(n))throw new Error("coordinates must be an Array");if(n.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!hn(n[0])||!hn(n[1]))throw new Error("coordinates must contain numbers");return ls({type:"Point",coordinates:n},t,e)}function hn(n){return!isNaN(n)&&n!==null&&!Array.isArray(n)}function ds(n){if(!n)throw new Error("coord is required");if(!Array.isArray(n)){if(n.type==="Feature"&&n.geometry!==null&&n.geometry.type==="Point")return[...n.geometry.coordinates];if(n.type==="Point")return[...n.coordinates]}if(Array.isArray(n)&&n.length>=2&&!Array.isArray(n[0])&&!Array.isArray(n[1]))return[...n];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function cs(n){return n.type==="Feature"?n.geometry:n}function us(n,t,e={}){if(!n)throw new Error("point is required");if(!t)throw new Error("polygon is required");const i=ds(n),s=cs(t),o=s.type,r=t.bbox;let a=s.coordinates;if(r&&ps(i,r)===!1)return!1;o==="Polygon"&&(a=[a]);let l=!1;for(var h=0;h<a.length;++h){const d=as(i,a[h]);if(d===0)return!e.ignoreBoundary;d&&(l=!0)}return l}function ps(n,t){return t[0]<=n[0]&&t[1]<=n[1]&&t[2]>=n[0]&&t[3]>=n[1]}const dn="moveend zoomend refresh";class cn extends ue{atlas;geojson;static get observedAttributes(){return["hidden","data-collection","data-color","popovertarget"]}constructor(){super(),this.refresh=Jn(this.refresh,300)}connectedCallback(){queueMicrotask(()=>{this.atlas=this.closest("mtds-atlas")||void 0,this.atlas?.map?.on(dn,this.refresh,this),this.geojson=new _.GeoJSON(null,{style:this.#t(),onEachFeature:(t,e)=>e.on("click",this.handleEvent,this)}).bindPopup(()=>`#${A(this,"popovertarget")}`),this.refresh(),this.attributeChangedCallback("hidden")})}attributeChangedCallback(t){const e=this.geojson,i=this.atlas?.map;t==="popovertarget"&&e?.getPopup()?.update(),t==="data-color"&&e?.setStyle(this.#t()),t==="data-collection"&&this.refresh(),t==="hidden"&&e&&i&&i[this.hidden?"removeLayer":"addLayer"](e)}disconnectedCallback(){this.atlas?.map?.off(dn,this.refresh,this),this.geojson?.unbindPopup().remove(),this.geojson=this.atlas=void 0}refresh(t){!this.geojson||!this.atlas?.map?.hasLayer(this.geojson)||this.getCollection().then(e=>{const i=e?.links.find(({rel:r})=>r==="items"),s=t===!0?`&nocache=${Date.now()}`:"",o=this.atlas?.map?.getBounds().toBBoxString();e?fetch(`${i?.href}?bbox=${o}${s}`).then(r=>r.json()).then(r=>this.geojson?.clearLayers().addData(r)):this.atlas?.getCollections().then(r=>{const a=`mtds-atlas-matgeo: Please set a vaild data-collection="${Object.keys(r).join(" | ")}"`;console.warn(a)})})}handleEvent(t){t.originalEvent.stopPropagation(),this.atlas?.getCollections().then(e=>{const i=[t.target],s={...t,targets:i,collections:e},o=hs([t.latlng.lng,t.latlng.lat]);this.atlas?.map?.eachLayer(r=>{if(r===t.target)return;(r.feature?.geometry&&us(o,r.feature.geometry)||r instanceof _.Marker&&r.getLatLng().equals(t.latlng))&&i.push(r)}),this.dispatchEvent(new MouseEvent("click",t.originalEvent)),this.dispatchEvent(new CustomEvent("atlasfeatureclick",{detail:s,bubbles:!0}))})}async getCollection(){return this.atlas?.getCollections().then(t=>t?.[A(this,"data-collection")||""])}#t(){return{color:`var(--mtds-color-${A(this,"data-color")||"main"}-base-default)`}}}pe("mtds-atlas-matgeo",cn);class un extends ue{atlas;wms;static get observedAttributes(){return["hidden","data-url","popovertarget"]}connectedCallback(){queueMicrotask(()=>{this.atlas=this.closest("mtds-atlas")||void 0,this.refresh()})}attributeChangedCallback(t){t==="data-url"&&this.refresh(),t==="popovertarget"&&this.wms?.getPopup()?.update(),t==="hidden"&&this.wms&&(this.atlas?.map?.[this.hidden?"removeLayer":"addLayer"](this.wms),this.wms.bringToFront())}refresh(){const t=new URL(A(this,"data-url")||""),e=Object.fromEntries(t.searchParams.entries());this.wms?.unbindPopup().remove(),this.wms=new _.TileLayer.WMS(`${t.origin}${t.pathname}`,e),this.attributeChangedCallback("hidden")}disconnectedCallback(){this.wms?.unbindPopup().remove(),this.wms=this.atlas=void 0}}pe("mtds-atlas-wms",un);let Xe=0;const pn=18,_s="https://cache.kartverket.no/v1/wmts/1.0.0/topo/default/webmercator/{z}/{y}/{x}.png",_n="https://matgeoservice-256616427209.europe-north1.run.app/ogc/features/collections",fs=[[57.5,4.73],[71.5,31.44]];Ve()&&!window._matgeoCollections&&(window._matgeoCollections=fetch(_n).then(n=>n.json()).then(n=>n.collections.map(t=>[t.id,t])).then(Object.fromEntries));class _e extends ue{cluster;map;static get observedAttributes(){return["data-view","data-scrollzoom"]}constructor(){super(),this.attachShadow({mode:"open"}).append(ce("style",null,`@layer leaflet{${Yn}}
737
737
  @layer mt.design{${Qn}`),ce("figure"))}connectedCallback(){const t=this.shadowRoot?.lastElementChild,e=A(this,"data-cluster")??"false",i=new _.TileLayer(_s,{attribution:"&copy; Kartverket",className:"leaflet-kartverket-tiles",maxZoom:pn});this.map=new _.Map(t,{attributionControl:!1,fadeAnimation:!1,layers:[i],zoomControl:!1,zoomSnap:.2}),nn(this,"pointerup,click",this.#e),this.map.addControl(new _.Control.Attribution({prefix:""})),this.map.addControl(new _.Control.Zoom({position:"bottomright"})),this.map.on("popupopen popupclose",this.#t,this),this.cluster=new _.MarkerClusterGroup({zoomToBoundsOnClick:!0,showCoverageOnHover:!1,disableClusteringAtZoom:e==="false"?1:Number(e)||pn+1,iconCreateFunction:s=>new _.DivIcon({html:`${s.getChildCount()}`,className:"leaflet-cluster-icon",iconSize:[30,30]})}).addTo(this.map);for(const s of _e.observedAttributes)this.attributeChangedCallback(s,null,A(this,s))}attributeChangedCallback(t,e,i){t==="data-view"&&this.setView(i||""),t==="data-scrollzoom"&&this.map?.scrollWheelZoom[i==="false"?"disable":"enable"]()}setView(t,e){const i=`${t}`.split(",").map(parseFloat).filter(Number.isFinite),s=this.cluster?.getBounds();if(i.length===3)return this.map?.setView([i[0],i[1]],i[2],e);if(t!=="fit")return this.map?.fitBounds(fs,e);if(s?.isValid())return this.map?.fitBounds(s.pad(.1),e);this.cluster?.once("layeradd",()=>{setTimeout(()=>this.setView("fit"),50)})}latLngFromPoint(t,e){return this.map?.pointerEventToLatLng({clientX:t,clientY:e})}disconnectedCallback(){Ke(this,"pointerup,click",this.#e),this.map?.remove(),this.map=this.cluster=void 0}async getCollections(){return window._matgeoCollections||Promise.resolve({})}#t({type:t,popup:e}){const i=t==="popupopen",s=e.getElement()?.querySelector(".leaflet-popup-content"),o=s?.querySelector(":scope > slot"),r=s?.textContent?.match(/^#(\S+)/)?.[1]||"",a=document.getElementById(o?.name||r);if(!a)return i&&r&&e.close();_.Util.setOptions(e,{maxWidth:this.offsetWidth-40}),A(a,"data-popover",i?A(a,"popover"):null),A(a,"popover",i?null:A(a,"data-popover")),A(a,"slot",i?a.id:null),i&&e.setContent(ce("slot",{name:a.id}))}#e(t){t.type==="click"?Xe&&t.stopPropagation?.():document.body.classList.contains("leaflet-dragging")&&(Xe=setTimeout(()=>{Xe=0},50))}}return pe("mtds-atlas",_e),Ve()&&(_.Marker.prototype.options.icon=new _.DivIcon({html:'<div class="leaflet-marker-generated-slot"><div class="leaflet-marker-generated-icon"></div></div>',iconSize:[0,0]})),H.L=_,H.MATGEO_URL=_n,H.MTDSAtlasElement=_e,H.MTDSAtlasMarkerElement=on,H.MTDSAtlasMatgeoElement=cn,H.MTDSAtlasWMSElement=un,Object.defineProperty(H,Symbol.toStringTag,{value:"Module"}),H})({});
@@ -1,49 +1,65 @@
1
- import l from "../styles.module.css.js";
2
- import { isBrowser as m, onLoaded as s, on as i, onMutation as d, QUICK_EVENT as r, deprecate as e, attr as t } from "../utils.js";
3
- const f = l.dialog.split(" ")[0], c = m() ? document.getElementsByClassName(
4
- f
1
+ import p from "../styles.module.css.js";
2
+ import { isBrowser as u, onLoaded as h, on as l, onMutation as m, QUICK_EVENT as r, attr as e, deprecate as n } from "../utils.js";
3
+ const b = p.dialog.split(" ")[0], g = u() ? document.getElementsByClassName(
4
+ b
5
5
  ) : [];
6
- function p() {
7
- for (const o of c)
8
- if (o.getAttribute("data-variant") === "drawer" && e(
6
+ function w() {
7
+ for (const o of g)
8
+ if (o.getAttribute("data-variant") === "drawer" && n(
9
9
  '<dialog data-variant="drawer">',
10
10
  '<dialog data-placement="center|left|right|top|bottom">',
11
11
  o
12
12
  ), o.isConnected && o.showModal && o.close) {
13
- const a = t(o, "data-closedby");
14
- a && (t(o, "closedby", a), e(
13
+ const a = e(o, "data-closedby");
14
+ a && (e(o, "closedby", a), n(
15
15
  `<dialog data-closedby="${a}">`,
16
16
  `<dialog closedby="${a}">`,
17
17
  o
18
- )), o.matches('[open]:not([data-modal="false"]):not(:modal)') ? (e(
18
+ )), o.matches('[open]:not([data-modal="false"]):not(:modal)') ? (n(
19
19
  '<dialog data-modal="true">',
20
20
  '.showModal() or <button command="show-modal" commandfor="DIALOG-ID"></button>'
21
- ), t(o, "open", null), o.showModal()) : o.matches(":modal:not([open])") && (t(o, "open", ""), o.close());
21
+ ), e(o, "open", null), o.showModal()) : o.matches(":modal:not([open])") && (e(o, "open", ""), o.close());
22
22
  }
23
23
  }
24
- function g({ target: o }) {
25
- for (const a of c)
24
+ function D({ target: o }) {
25
+ for (const a of g)
26
26
  a.open && a.contains(o) && o?.closest?.('[data-command="close"]') && a.close();
27
27
  }
28
- const n = /* @__PURE__ */ new WeakSet();
29
- function u() {
28
+ const f = /* @__PURE__ */ new WeakSet();
29
+ function y() {
30
30
  document.querySelectorAll("[data-command]").forEach((o) => {
31
- if (n.has(o)) return;
32
- const a = t(o, "data-command");
33
- n.add(o), a === "row" ? e(
31
+ if (f.has(o)) return;
32
+ const a = e(o, "data-command");
33
+ f.add(o), a === "row" ? n(
34
34
  `<${o.nodeName.toLowerCase()} data-command="${a}">`,
35
35
  `<tr data-clickdelegatefor="${o.nodeName}-ID">`,
36
36
  o
37
- ) : e(
37
+ ) : n(
38
38
  `<button data-command="${a}">`,
39
39
  `<button command="${a?.replace("toggle-app-expanded", "show-modal")}" commandfor="TARGET-ID">`,
40
40
  o
41
41
  );
42
42
  });
43
43
  }
44
- s(() => [
45
- i(document, "click", g, r),
46
- d(p, ["open", "data-drawer"]),
47
- d(u, "data-command")
44
+ let d = !1;
45
+ function C({
46
+ type: o,
47
+ target: a,
48
+ clientX: s = 0,
49
+ clientY: c = 0
50
+ }) {
51
+ if (o === "pointerdown") {
52
+ const t = a?.closest?.("dialog")?.getBoundingClientRect();
53
+ d = !!(t && t.top <= c && c <= t.bottom && t.left <= s && s <= t.right);
54
+ } else {
55
+ const i = a instanceof HTMLDialogElement && !d && e(a, "closedby") === "any";
56
+ d = !1, i && requestAnimationFrame(() => a.open && a.close());
57
+ }
58
+ }
59
+ h(() => [
60
+ l(document, "click", D, r),
61
+ l(document, "pointerdown,pointerup", C, r),
62
+ m(w, ["open", "data-drawer"]),
63
+ m(y, "data-command")
48
64
  ]);
49
65
  //# sourceMappingURL=dialog-observer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dialog-observer.js","sources":["../../designsystem/dialog/dialog-observer.ts"],"sourcesContent":["import styles from \"../styles.module.css\";\nimport {\n\tattr,\n\tdeprecate,\n\tisBrowser,\n\ton,\n\tonLoaded,\n\tonMutation,\n\tQUICK_EVENT,\n} from \"../utils\";\n\nconst CSS_DIALOG = styles.dialog.split(\" \")[0];\nconst DIALOGS = isBrowser()\n\t? (document.getElementsByClassName(\n\t\t\tCSS_DIALOG,\n\t\t) as HTMLCollectionOf<HTMLDialogElement>)\n\t: [];\n\nfunction handleDialogModal() {\n\tfor (const dialog of DIALOGS) {\n\t\tif (dialog.getAttribute(\"data-variant\") === \"drawer\")\n\t\t\tdeprecate(\n\t\t\t\t'<dialog data-variant=\"drawer\">',\n\t\t\t\t'<dialog data-placement=\"center|left|right|top|bottom\">',\n\t\t\t\tdialog,\n\t\t\t);\n\t\tif (dialog.isConnected && dialog.showModal && dialog.close) {\n\t\t\tconst closedby = attr(dialog, \"data-closedby\");\n\t\t\tif (closedby) {\n\t\t\t\tattr(dialog, \"closedby\", closedby);\n\t\t\t\tdeprecate(\n\t\t\t\t\t`<dialog data-closedby=\"${closedby}\">`,\n\t\t\t\t\t`<dialog closedby=\"${closedby}\">`,\n\t\t\t\t\tdialog,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (dialog.matches('[open]:not([data-modal=\"false\"]):not(:modal)')) {\n\t\t\t\tdeprecate(\n\t\t\t\t\t'<dialog data-modal=\"true\">',\n\t\t\t\t\t'.showModal() or <button command=\"show-modal\" commandfor=\"DIALOG-ID\"></button>',\n\t\t\t\t);\n\t\t\t\tattr(dialog, \"open\", null); // Using attribute instead of .close to avoid `close` event\n\t\t\t\tdialog.showModal();\n\t\t\t} else if (dialog.matches(\":modal:not([open])\")) {\n\t\t\t\tattr(dialog, \"open\", \"\"); // Set as open\n\t\t\t\tdialog.close(); // So we correctly can call .close, removing <dialog> from #top-layer\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction handleDialogCloseClick({ target: el }: Event) {\n\tfor (const dialog of DIALOGS)\n\t\tif (dialog.open && dialog.contains(el as Node)) {\n\t\t\tif ((el as Element)?.closest?.('[data-command=\"close\"]')) dialog.close();\n\t\t}\n}\n\nconst deprecations = new WeakSet();\nfunction handleCommandDepreactions() {\n\tdocument.querySelectorAll(\"[data-command]\").forEach((el) => {\n\t\tif (deprecations.has(el)) return;\n\t\tconst command = attr(el, \"data-command\");\n\t\tdeprecations.add(el);\n\n\t\tif (command === \"row\")\n\t\t\tdeprecate(\n\t\t\t\t`<${el.nodeName.toLowerCase()} data-command=\"${command}\">`,\n\t\t\t\t`<tr data-clickdelegatefor=\"${el.nodeName}-ID\">`,\n\t\t\t\tel,\n\t\t\t);\n\t\telse\n\t\t\tdeprecate(\n\t\t\t\t`<button data-command=\"${command}\">`,\n\t\t\t\t`<button command=\"${command?.replace(\"toggle-app-expanded\", \"show-modal\")}\" commandfor=\"TARGET-ID\">`,\n\t\t\t\tel,\n\t\t\t);\n\t});\n}\n\nonLoaded(() => [\n\ton(document, \"click\", handleDialogCloseClick, QUICK_EVENT),\n\tonMutation(handleDialogModal, [\"open\", \"data-drawer\"]),\n\tonMutation(handleCommandDepreactions, \"data-command\"),\n]);\n"],"names":["CSS_DIALOG","styles","DIALOGS","isBrowser","handleDialogModal","dialog","deprecate","closedby","attr","handleDialogCloseClick","el","deprecations","handleCommandDepreactions","command","onLoaded","on","QUICK_EVENT","onMutation"],"mappings":";;AAWA,MAAMA,IAAaC,EAAO,OAAO,MAAM,GAAG,EAAE,CAAC,GACvCC,IAAUC,MACZ,SAAS;AAAA,EACVH;AACD,IACC,CAAA;AAEH,SAASI,IAAoB;AAC5B,aAAWC,KAAUH;AAOpB,QANIG,EAAO,aAAa,cAAc,MAAM,YAC3CC;AAAA,MACC;AAAA,MACA;AAAA,MACAD;AAAA,IAAA,GAEEA,EAAO,eAAeA,EAAO,aAAaA,EAAO,OAAO;AAC3D,YAAME,IAAWC,EAAKH,GAAQ,eAAe;AAC7C,MAAIE,MACHC,EAAKH,GAAQ,YAAYE,CAAQ,GACjCD;AAAA,QACC,0BAA0BC,CAAQ;AAAA,QAClC,qBAAqBA,CAAQ;AAAA,QAC7BF;AAAA,MAAA,IAGEA,EAAO,QAAQ,8CAA8C,KAChEC;AAAA,QACC;AAAA,QACA;AAAA,MAAA,GAEDE,EAAKH,GAAQ,QAAQ,IAAI,GACzBA,EAAO,UAAA,KACGA,EAAO,QAAQ,oBAAoB,MAC7CG,EAAKH,GAAQ,QAAQ,EAAE,GACvBA,EAAO,MAAA;AAAA,IAET;AAEF;AAEA,SAASI,EAAuB,EAAE,QAAQC,KAAa;AACtD,aAAWL,KAAUH;AACpB,IAAIG,EAAO,QAAQA,EAAO,SAASK,CAAU,KACvCA,GAAgB,UAAU,wBAAwB,OAAU,MAAA;AAEpE;AAEA,MAAMC,wBAAmB,QAAA;AACzB,SAASC,IAA4B;AACpC,WAAS,iBAAiB,gBAAgB,EAAE,QAAQ,CAACF,MAAO;AAC3D,QAAIC,EAAa,IAAID,CAAE,EAAG;AAC1B,UAAMG,IAAUL,EAAKE,GAAI,cAAc;AACvC,IAAAC,EAAa,IAAID,CAAE,GAEfG,MAAY,QACfP;AAAA,MACC,IAAII,EAAG,SAAS,YAAA,CAAa,kBAAkBG,CAAO;AAAA,MACtD,8BAA8BH,EAAG,QAAQ;AAAA,MACzCA;AAAA,IAAA,IAGDJ;AAAA,MACC,yBAAyBO,CAAO;AAAA,MAChC,oBAAoBA,GAAS,QAAQ,uBAAuB,YAAY,CAAC;AAAA,MACzEH;AAAA,IAAA;AAAA,EAEH,CAAC;AACF;AAEAI,EAAS,MAAM;AAAA,EACdC,EAAG,UAAU,SAASN,GAAwBO,CAAW;AAAA,EACzDC,EAAWb,GAAmB,CAAC,QAAQ,aAAa,CAAC;AAAA,EACrDa,EAAWL,GAA2B,cAAc;AACrD,CAAC;"}
1
+ {"version":3,"file":"dialog-observer.js","sources":["../../designsystem/dialog/dialog-observer.ts"],"sourcesContent":["import styles from \"../styles.module.css\";\nimport {\n\tattr,\n\tdeprecate,\n\tisBrowser,\n\ton,\n\tonLoaded,\n\tonMutation,\n\tQUICK_EVENT,\n} from \"../utils\";\n\nconst CSS_DIALOG = styles.dialog.split(\" \")[0];\nconst DIALOGS = isBrowser()\n\t? (document.getElementsByClassName(\n\t\t\tCSS_DIALOG,\n\t\t) as HTMLCollectionOf<HTMLDialogElement>)\n\t: [];\n\nfunction handleDialogModal() {\n\tfor (const dialog of DIALOGS) {\n\t\tif (dialog.getAttribute(\"data-variant\") === \"drawer\")\n\t\t\tdeprecate(\n\t\t\t\t'<dialog data-variant=\"drawer\">',\n\t\t\t\t'<dialog data-placement=\"center|left|right|top|bottom\">',\n\t\t\t\tdialog,\n\t\t\t);\n\t\tif (dialog.isConnected && dialog.showModal && dialog.close) {\n\t\t\tconst closedby = attr(dialog, \"data-closedby\");\n\t\t\tif (closedby) {\n\t\t\t\tattr(dialog, \"closedby\", closedby);\n\t\t\t\tdeprecate(\n\t\t\t\t\t`<dialog data-closedby=\"${closedby}\">`,\n\t\t\t\t\t`<dialog closedby=\"${closedby}\">`,\n\t\t\t\t\tdialog,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (dialog.matches('[open]:not([data-modal=\"false\"]):not(:modal)')) {\n\t\t\t\tdeprecate(\n\t\t\t\t\t'<dialog data-modal=\"true\">',\n\t\t\t\t\t'.showModal() or <button command=\"show-modal\" commandfor=\"DIALOG-ID\"></button>',\n\t\t\t\t);\n\t\t\t\tattr(dialog, \"open\", null); // Using attribute instead of .close to avoid `close` event\n\t\t\t\tdialog.showModal();\n\t\t\t} else if (dialog.matches(\":modal:not([open])\")) {\n\t\t\t\tattr(dialog, \"open\", \"\"); // Set as open\n\t\t\t\tdialog.close(); // So we correctly can call .close, removing <dialog> from #top-layer\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction handleDialogCloseClick({ target: el }: Event) {\n\tfor (const dialog of DIALOGS)\n\t\tif (dialog.open && dialog.contains(el as Node)) {\n\t\t\tif ((el as Element)?.closest?.('[data-command=\"close\"]')) dialog.close();\n\t\t}\n}\n\nconst deprecations = new WeakSet();\nfunction handleCommandDepreactions() {\n\tdocument.querySelectorAll(\"[data-command]\").forEach((el) => {\n\t\tif (deprecations.has(el)) return;\n\t\tconst command = attr(el, \"data-command\");\n\t\tdeprecations.add(el);\n\n\t\tif (command === \"row\")\n\t\t\tdeprecate(\n\t\t\t\t`<${el.nodeName.toLowerCase()} data-command=\"${command}\">`,\n\t\t\t\t`<tr data-clickdelegatefor=\"${el.nodeName}-ID\">`,\n\t\t\t\tel,\n\t\t\t);\n\t\telse\n\t\t\tdeprecate(\n\t\t\t\t`<button data-command=\"${command}\">`,\n\t\t\t\t`<button command=\"${command?.replace(\"toggle-app-expanded\", \"show-modal\")}\" commandfor=\"TARGET-ID\">`,\n\t\t\t\tel,\n\t\t\t);\n\t});\n}\n\n// Polyfill closedby in Safari functionaliy in Safari\n// Also in Safari 26.2 where `closedBy` property is supported natively,\n// but no corresponding functionality/behavior is implemented.\nlet DOWN_INSIDE = false; // Prevent close if selecting text inside dialog\nfunction handleClosedbyAny({\n\ttype,\n\ttarget: el,\n\tclientX: x = 0,\n\tclientY: y = 0,\n}: Partial<MouseEvent>) {\n\tif (type === \"pointerdown\") {\n\t\tconst r = (el as Element)?.closest?.(\"dialog\")?.getBoundingClientRect();\n\t\tconst isInside =\n\t\t\tr && r.top <= y && y <= r.bottom && r.left <= x && x <= r.right;\n\n\t\tDOWN_INSIDE = !!isInside;\n\t} else {\n\t\tconst isDialog = el instanceof HTMLDialogElement;\n\t\tconst isClose = isDialog && !DOWN_INSIDE && attr(el, \"closedby\") === \"any\";\n\n\t\tDOWN_INSIDE = false; // Reset on every pointerup\n\t\tif (isClose) requestAnimationFrame(() => el.open && el.close()); // Close if browser did not do it\n\t}\n}\n\nonLoaded(() => [\n\ton(document, \"click\", handleDialogCloseClick, QUICK_EVENT),\n\ton(document, \"pointerdown,pointerup\", handleClosedbyAny, QUICK_EVENT),\n\tonMutation(handleDialogModal, [\"open\", \"data-drawer\"]),\n\tonMutation(handleCommandDepreactions, \"data-command\"),\n]);\n"],"names":["CSS_DIALOG","styles","DIALOGS","isBrowser","handleDialogModal","dialog","deprecate","closedby","attr","handleDialogCloseClick","el","deprecations","handleCommandDepreactions","command","DOWN_INSIDE","handleClosedbyAny","type","x","y","r","isClose","onLoaded","on","QUICK_EVENT","onMutation"],"mappings":";;AAWA,MAAMA,IAAaC,EAAO,OAAO,MAAM,GAAG,EAAE,CAAC,GACvCC,IAAUC,MACZ,SAAS;AAAA,EACVH;AACD,IACC,CAAA;AAEH,SAASI,IAAoB;AAC5B,aAAWC,KAAUH;AAOpB,QANIG,EAAO,aAAa,cAAc,MAAM,YAC3CC;AAAA,MACC;AA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ASC,IAAI;AACd,GAAwB;AACvB,MAAIF,MAAS,eAAe;AAC3B,UAAMG,IAAKT,GAAgB,UAAU,QAAQ,GAAG,sBAAA;AAIhD,IAAAI,IAAc,CAAC,EAFdK,KAAKA,EAAE,OAAOD,KAAKA,KAAKC,EAAE,UAAUA,EAAE,QAAQF,KAAKA,KAAKE,EAAE;AAAA,EAG5D,OAAO;AAEN,UAAMC,IADWV,aAAc,qBACH,CAACI,KAAeN,EAAKE,GAAI,UAAU,MAAM;AAErE,IAAAI,IAAc,IACVM,KAAS,sBAAsB,MAAMV,EAAG,QAAQA,EAAG,OAAO;AAAA,EAC/D;AACD;AAEAW,EAAS,MAAM;AAAA,EACdC,EAAG,UAAU,SAASb,GAAwBc,CAAW;AAAA,EACzDD,EAAG,UAAU,yBAAyBP,GAAmBQ,CAAW;AAAA,EACpEC,EAAWpB,GAAmB,CAAC,QAAQ,aAAa,CAAC;AAAA,EACrDoB,EAAWZ,GAA2B,cAAc;AACrD,CAAC;"}
@@ -1,15 +1,15 @@
1
1
  'use client';
2
- import { jsx as e, Fragment as P, jsxs as W } from "react/jsx-runtime";
3
- import S from "clsx";
4
- import { forwardRef as s, useRef as k, useImperativeHandle as Y, useEffect as Z } from "react";
5
- import { HelpText as _ } from "../helptext/helptext.js";
6
- import { Input as $ } from "../input/input.js";
2
+ import { jsx as e, Fragment as S, jsxs as W } from "react/jsx-runtime";
3
+ import T from "clsx";
4
+ import { forwardRef as s, useRef as w, useImperativeHandle as Z, useEffect as _ } from "react";
5
+ import { HelpText as $ } from "../helptext/helptext.js";
6
+ import { Input as ee } from "../input/input.js";
7
7
  import D from "../styles.module.css.js";
8
- import { toCustomElementProps as q } from "../utils.js";
9
- import { Validation as ee } from "../validation/validation.js";
10
- const T = (i) => typeof i == "string" ? { label: i, value: i } : i, ne = s(function({
11
- "data-size": n,
12
- "data-validation": t,
8
+ import { toCustomElementProps as z, deprecate as P } from "../utils.js";
9
+ import { Validation as te } from "../validation/validation.js";
10
+ const V = (i) => typeof i == "string" ? { label: i, value: i } : i, ne = s(function({
11
+ "data-size": t,
12
+ "data-validation": n,
13
13
  as: o,
14
14
  className: u,
15
15
  count: f,
@@ -23,68 +23,68 @@ const T = (i) => typeof i == "string" ? { label: i, value: i } : i, ne = s(funct
23
23
  suffix: F,
24
24
  validation: j,
25
25
  ...r
26
- }, l) {
27
- const C = o || "div", L = !!F || !!h, c = j || v, y = {
28
- "data-size": n,
29
- "data-validation": t,
30
- className: S(D.field, u),
26
+ }, d) {
27
+ const y = o || "div", L = !!F || !!h, c = j || v, C = {
28
+ "data-size": t,
29
+ "data-validation": n,
30
+ className: T(D.field, u),
31
31
  style: O
32
32
  };
33
33
  return o === "select" && !r.children && Object.assign(r, {
34
34
  options: void 0,
35
35
  // Ensure options is not passed to DOM
36
- children: /* @__PURE__ */ e(P, { children: r.options?.map(T).map(({ label: E, value: H }) => /* @__PURE__ */ e("option", { value: H, children: E }, H)) })
37
- }), o ? /* @__PURE__ */ W("div", { ...y, children: [
38
- !!b && /* @__PURE__ */ e(J, { children: b }),
39
- !!x && /* @__PURE__ */ e(_, { "aria-label": g, children: x }),
40
- !!m && /* @__PURE__ */ e(K, { children: m }),
41
- L ? /* @__PURE__ */ W(V, { children: [
36
+ children: /* @__PURE__ */ e(S, { children: r.options?.map(V).map(({ label: E, value: H }) => /* @__PURE__ */ e("option", { value: H, children: E }, H)) })
37
+ }), o ? /* @__PURE__ */ W("div", { ...C, children: [
38
+ !!b && /* @__PURE__ */ e(K, { children: b }),
39
+ !!x && /* @__PURE__ */ e($, { "aria-label": g, children: x }),
40
+ !!m && /* @__PURE__ */ e(M, { children: m }),
41
+ L ? /* @__PURE__ */ W(B, { children: [
42
42
  !!h && /* @__PURE__ */ e("span", { children: h }),
43
43
  /* @__PURE__ */ e(
44
- C,
44
+ y,
45
45
  {
46
46
  className: D.input,
47
47
  suppressHydrationWarning: !0,
48
- ref: l,
48
+ ref: d,
49
49
  ...r
50
50
  }
51
51
  ),
52
52
  !!F && /* @__PURE__ */ e("span", { children: F })
53
53
  ] }) : /* @__PURE__ */ e(
54
- C,
54
+ y,
55
55
  {
56
56
  className: typeof o == "string" ? D.input : void 0,
57
57
  suppressHydrationWarning: !0,
58
- ref: l,
58
+ ref: d,
59
59
  ...r
60
60
  }
61
61
  ),
62
- !!c && /* @__PURE__ */ e(ee, { children: c }),
63
- !!f && /* @__PURE__ */ e(M, { "data-count": f })
64
- ] }) : /* @__PURE__ */ e("div", { ref: l, ...y, ...r });
65
- }), V = s(
66
- function({ className: n, ...t }, o) {
67
- return /* @__PURE__ */ e("div", { className: S(D.affixes, n), ref: o, ...t });
62
+ !!c && /* @__PURE__ */ e(te, { children: c }),
63
+ !!f && /* @__PURE__ */ e(Q, { "data-count": f })
64
+ ] }) : /* @__PURE__ */ e("div", { ref: d, ...C, ...r });
65
+ }), B = s(
66
+ function({ className: t, ...n }, o) {
67
+ return /* @__PURE__ */ e("div", { className: T(D.affixes, t), ref: o, ...n });
68
68
  }
69
- ), B = s(
70
- function({ "data-nofilter": n, ...t }, o) {
69
+ ), G = s(
70
+ function({ "data-nofilter": t, ...n }, o) {
71
71
  return /* @__PURE__ */ e(
72
72
  "u-datalist",
73
73
  {
74
- "data-nofilter": !!n || void 0,
74
+ "data-nofilter": !!t || void 0,
75
75
  ref: o,
76
- ...q(t)
76
+ ...z(n)
77
77
  }
78
78
  );
79
79
  }
80
- ), G = s(
81
- function(n, t) {
82
- return /* @__PURE__ */ e("u-option", { ref: t, ...q(n) });
80
+ ), J = s(
81
+ function(t, n) {
82
+ return /* @__PURE__ */ e("u-option", { ref: n, ...z(t) });
83
83
  }
84
- ), te = s(
84
+ ), ie = s(
85
85
  function({
86
- "aria-required": n,
87
- "data-position": t,
86
+ "aria-required": t,
87
+ "data-position": n,
88
88
  "data-nofilter": o,
89
89
  "data-multiple": u,
90
90
  onAfterChange: f,
@@ -98,32 +98,28 @@ const T = (i) => typeof i == "string" ? { label: i, value: i } : i, ne = s(funct
98
98
  children: F,
99
99
  disabled: j,
100
100
  name: r,
101
- options: l,
102
- placeholder: C,
101
+ options: d,
102
+ placeholder: y,
103
103
  readOnly: L,
104
104
  selected: c,
105
- type: y,
105
+ type: C,
106
106
  ...E
107
107
  }, H) {
108
- const N = k(null), w = k(b);
109
- return w.current = b, f && (m = f, console.warn(
110
- "Combobox onAfterChange is deprecated, use onAfterSelect instead."
111
- )), v && (g = v, console.warn(
112
- "Combobox onBeforeChange is deprecated, use onBeforeSelect instead."
113
- )), Y(H, () => N.current), Z(() => {
114
- const p = N.current, d = (a) => {
115
- const A = w.current;
116
- if (!w) return;
108
+ const N = w(null), A = w(b);
109
+ return A.current = b, f && (m = f, P("onAfterChange", "onAfterSelect")), v && (g = v, P("onBeforeChange", "onBeforeSelect")), Z(H, () => N.current), _(() => {
110
+ const p = N.current, l = (a) => {
111
+ const R = A.current;
112
+ if (!A) return;
117
113
  a.preventDefault();
118
- const { isConnected: Q, textContent: U, value: R } = a.detail, z = U?.trim() || "", I = c || [];
119
- A?.(Q ? I.filter((X) => X.value !== R) : u ? [...I, { value: R, label: z }] : [{ value: R, label: z }]);
114
+ const { isConnected: U, textContent: X, value: q } = a.detail, I = X?.trim() || "", k = c || [];
115
+ R?.(U ? k.filter((Y) => Y.value !== q) : u ? [...k, { value: q, label: I }] : [{ value: q, label: I }]);
120
116
  };
121
- return p?.addEventListener("comboboxbeforeselect", d), () => p?.removeEventListener("comboboxbeforeselect", d);
117
+ return p?.addEventListener("comboboxbeforeselect", l), () => p?.removeEventListener("comboboxbeforeselect", l);
122
118
  }, [u, c]), /* @__PURE__ */ W(
123
119
  "u-combobox",
124
120
  {
125
121
  "data-multiple": u || void 0,
126
- ...q({
122
+ ...z({
127
123
  oncomboboxbeforeselect: g,
128
124
  oncomboboxbeforematch: x,
129
125
  oncomboboxafterselect: m,
@@ -131,49 +127,49 @@ const T = (i) => typeof i == "string" ? { label: i, value: i } : i, ne = s(funct
131
127
  ...E
132
128
  }),
133
129
  children: [
134
- c?.map(({ children: p, label: d, value: a }) => /* @__PURE__ */ e("data", { value: a, suppressHydrationWarning: !0, children: p ?? d }, a)),
135
- F || /* @__PURE__ */ W(P, { children: [
130
+ c?.map(({ children: p, label: l, value: a }) => /* @__PURE__ */ e("data", { value: a, suppressHydrationWarning: !0, children: p ?? l }, a)),
131
+ F || /* @__PURE__ */ W(S, { children: [
136
132
  /* @__PURE__ */ e(
137
- $,
133
+ ee,
138
134
  {
139
- "aria-required": n,
135
+ "aria-required": t,
140
136
  disabled: j,
141
137
  name: r,
142
138
  onInput: h,
143
139
  onChange: O,
144
- placeholder: C,
140
+ placeholder: y,
145
141
  readOnly: L,
146
- type: y
142
+ type: C
147
143
  }
148
144
  ),
149
145
  /* @__PURE__ */ e("del", { "aria-label": "Fjern tekst", suppressHydrationWarning: !0 })
150
146
  ] }),
151
- !!l && /* @__PURE__ */ e(B, { "data-nofilter": o, "data-position": t, children: l.map(T).map(({ children: p, label: d, value: a }) => /* @__PURE__ */ e(G, { value: a, label: d, children: p ?? d }, a)) })
147
+ !!d && /* @__PURE__ */ e(G, { "data-nofilter": o, "data-position": n, children: d.map(V).map(({ children: p, label: l, value: a }) => /* @__PURE__ */ e(J, { value: a, label: l, children: p ?? l }, a)) })
152
148
  ]
153
149
  }
154
150
  );
155
151
  }
156
- ), J = s(
157
- function(n, t) {
158
- return /* @__PURE__ */ e("label", { suppressHydrationWarning: !0, ref: t, ...n });
152
+ ), K = s(
153
+ function(t, n) {
154
+ return /* @__PURE__ */ e("label", { suppressHydrationWarning: !0, ref: n, ...t });
159
155
  }
160
- ), K = s(function(n, t) {
161
- return /* @__PURE__ */ e("p", { suppressHydrationWarning: !0, ref: t, ...n });
162
- }), M = s(
163
- function(n, t) {
164
- return /* @__PURE__ */ e("p", { suppressHydrationWarning: !0, ref: t, ...n });
156
+ ), M = s(function(t, n) {
157
+ return /* @__PURE__ */ e("p", { suppressHydrationWarning: !0, ref: n, ...t });
158
+ }), Q = s(
159
+ function(t, n) {
160
+ return /* @__PURE__ */ e("p", { suppressHydrationWarning: !0, ref: n, ...t });
165
161
  }
166
- ), pe = Object.assign(ne, {
167
- Affixes: V,
168
- Combobox: te,
169
- Datalist: B,
170
- Option: G,
171
- Description: K,
172
- Label: J,
173
- Count: M
162
+ ), ue = Object.assign(ne, {
163
+ Affixes: B,
164
+ Combobox: ie,
165
+ Datalist: G,
166
+ Option: J,
167
+ Description: M,
168
+ Label: K,
169
+ Count: Q
174
170
  });
175
171
  export {
176
- pe as Field,
172
+ ue as Field,
177
173
  ne as FieldComp
178
174
  };
179
175
  //# sourceMappingURL=field.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"field.js","sources":["../../designsystem/field/field.tsx"],"sourcesContent":["\"use client\";\nimport type { Placement } from \"@floating-ui/dom\";\nimport type {\n\tReactUcombobox,\n\tUHTMLComboboxElement,\n} from \"@u-elements/u-combobox\";\nimport clsx from \"clsx\";\nimport type { JSX } from \"react\";\nimport { forwardRef, useEffect, useImperativeHandle, useRef } from \"react\";\nimport { HelpText } from \"../helptext/helptext\";\nimport { Input, type InputProps } from \"../input/input\";\nimport type {\n\tPolymorphicComponentPropWithRef,\n\tPolymorphicRef,\n} from \"../react-types\";\nimport styles from \"../styles.module.css\";\nimport { toCustomElementProps } from \"../utils\";\nimport { Validation } from \"../validation/validation\";\n\ntype FieldBaseProps = {\n\tcount?: number;\n\tdescription?: React.ReactNode;\n\terror?: React.ReactNode; // Kept for backwards compatibility\n\thelpText?: React.ReactNode;\n\thelpTextLabel?: string;\n\tlabel?: React.ReactNode;\n\toptions?: string[] | FieldComboboxSelected;\n\tprefix?: string;\n\treadOnly?: boolean; // Allow readoOnly also on <select>\n\tsuffix?: string;\n\tvalidation?: React.ReactNode;\n};\n\nexport type FieldProps<As extends React.ElementType = \"div\"> =\n\tPolymorphicComponentPropWithRef<As, FieldBaseProps>;\n\ntype FieldComponent = <As extends React.ElementType = \"div\">(\n\tprops: FieldProps<As>,\n) => JSX.Element;\n\nconst toOption = (\n\to: FieldComboboxSelected[number] | string,\n): FieldComboboxSelected[number] =>\n\ttypeof o === \"string\" ? { label: o, value: o } : o;\n\nexport const FieldComp: FieldComponent = forwardRef<null>(function Field<\n\tAs extends React.ElementType = \"div\",\n>(\n\t{\n\t\t\"data-size\": size,\n\t\t\"data-validation\": dataValidation,\n\t\tas,\n\t\tclassName,\n\t\tcount,\n\t\tdescription,\n\t\terror,\n\t\thelpText,\n\t\thelpTextLabel,\n\t\tlabel,\n\t\tprefix,\n\t\tstyle,\n\t\tsuffix,\n\t\tvalidation: validationContent,\n\t\t...rest\n\t}: FieldProps<As>,\n\tref?: PolymorphicRef<As>,\n) {\n\tconst Tag = as || \"div\";\n\tconst affixes = !!suffix || !!prefix;\n\tconst validation = validationContent || error; // error kept for backwards compatibility\n\tconst shared = {\n\t\t\"data-size\": size,\n\t\t\"data-validation\": dataValidation,\n\t\tclassName: clsx(styles.field, className),\n\t\tstyle,\n\t};\n\n\t// Render options if select\n\tif (as === \"select\" && !rest.children)\n\t\tObject.assign(rest, {\n\t\t\toptions: undefined, // Ensure options is not passed to DOM\n\t\t\tchildren: (\n\t\t\t\t<>\n\t\t\t\t\t{(rest.options as FieldBaseProps[\"options\"])\n\t\t\t\t\t\t?.map(toOption)\n\t\t\t\t\t\t.map(({ label, value }) => (\n\t\t\t\t\t\t\t<option key={value} value={value}>\n\t\t\t\t\t\t\t\t{label}\n\t\t\t\t\t\t\t</option>\n\t\t\t\t\t\t))}\n\t\t\t\t</>\n\t\t\t),\n\t\t});\n\n\t// Using suppressHydrationWarning to avoid Next.js vs field-observer.ts hydration conflict\n\treturn as ? (\n\t\t<div {...shared}>\n\t\t\t{!!label && <FieldLabel>{label}</FieldLabel>}\n\t\t\t{!!helpText && <HelpText aria-label={helpTextLabel}>{helpText}</HelpText>}\n\t\t\t{!!description && <FieldDescription>{description}</FieldDescription>}\n\t\t\t{affixes ? (\n\t\t\t\t<FieldAffixes>\n\t\t\t\t\t{!!prefix && <span>{prefix}</span>}\n\t\t\t\t\t<Tag\n\t\t\t\t\t\tclassName={styles.input}\n\t\t\t\t\t\tsuppressHydrationWarning\n\t\t\t\t\t\tref={ref}\n\t\t\t\t\t\t{...rest}\n\t\t\t\t\t/>\n\t\t\t\t\t{!!suffix && <span>{suffix}</span>}\n\t\t\t\t</FieldAffixes>\n\t\t\t) : (\n\t\t\t\t<Tag\n\t\t\t\t\tclassName={typeof as === \"string\" ? styles.input : undefined}\n\t\t\t\t\tsuppressHydrationWarning\n\t\t\t\t\tref={ref}\n\t\t\t\t\t{...rest}\n\t\t\t\t/>\n\t\t\t)}\n\t\t\t{!!validation && <Validation>{validation}</Validation>}\n\t\t\t{!!count && <FieldCount data-count={count} />}\n\t\t</div>\n\t) : (\n\t\t<div ref={ref} {...shared} {...rest} />\n\t);\n}) as FieldComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n\nexport type FieldAffixProps = React.ComponentPropsWithoutRef<\"div\">;\nconst FieldAffixes = forwardRef<HTMLDivElement, FieldAffixProps>(\n\tfunction FieldAffixes({ className, ...rest }, ref) {\n\t\treturn (\n\t\t\t<div className={clsx(styles.affixes, className)} ref={ref} {...rest} />\n\t\t);\n\t},\n);\n\nexport type FieldDatalistProps = React.ComponentPropsWithoutRef<\"datalist\"> & {\n\t\"data-nofilter\"?: boolean;\n\t\"data-position\"?: Placement;\n};\n\nconst FieldDatalist = forwardRef<HTMLDataListElement, FieldDatalistProps>(\n\tfunction FieldDatalist({ \"data-nofilter\": filter, ...rest }, ref) {\n\t\treturn (\n\t\t\t<u-datalist\n\t\t\t\tdata-nofilter={!!filter || undefined} // Ensure data-nofilter is set correctly\n\t\t\t\tref={ref}\n\t\t\t\t{...toCustomElementProps(rest)}\n\t\t\t/>\n\t\t);\n\t},\n);\n\nexport type FieldOptionProps = React.ComponentPropsWithoutRef<\"option\">;\nconst FieldOption = forwardRef<HTMLOptionElement, FieldOptionProps>(\n\tfunction FieldOption(props, ref) {\n\t\treturn <u-option ref={ref} {...toCustomElementProps(props)} />;\n\t},\n);\n\nexport type FieldComboboxSelected = {\n\tlabel: string;\n\tvalue: string;\n\tchildren?: React.ReactNode;\n}[];\nexport type FieldComboboxProps = Omit<\n\tReactUcombobox,\n\t\"onChange\" | \"onInput\"\n> & {\n\t\"data-creatable\"?: boolean;\n\t\"data-multiple\"?: boolean;\n\tonAfterChange?: (e: CustomEvent<HTMLDataElement>) => void; // deprecated\n\tonAfterSelect?: (e: CustomEvent<HTMLDataElement>) => void; // Custom event to handle before change\n\tonBeforeChange?: (e: CustomEvent<HTMLDataElement>) => void; // deprecated\n\tonBeforeMatch?: (e: CustomEvent<HTMLOptionElement>) => void; // Custom event to handle before change\n\tonBeforeSelect?: (e: CustomEvent<HTMLDataElement>) => void; // Custom event to handle before change\n\tonSelectedChange?: (selected: FieldComboboxSelected) => void; // Allow onChange to be a function that returns void\n\toptions?: FieldComboboxSelected;\n\tselected?: FieldComboboxSelected; // Allow value to be a string or an array of strings for multiple select\n} & Pick<\n\t\tInputProps,\n\t\t| \"disabled\"\n\t\t| \"name\"\n\t\t| \"onChange\"\n\t\t| \"onInput\"\n\t\t| \"placeholder\"\n\t\t| \"readOnly\"\n\t\t| \"type\"\n\t\t| \"value\"\n\t> & // Allow input props to be passed down\n\tPick<FieldDatalistProps, \"data-position\" | \"data-nofilter\">; // Allow datalist props to be passed down\n\nconst FieldCombobox = forwardRef<UHTMLComboboxElement, FieldComboboxProps>(\n\tfunction FieldCombobox(\n\t\t{\n\t\t\t\"aria-required\": required,\n\t\t\t\"data-position\": position,\n\t\t\t\"data-nofilter\": nofilter,\n\t\t\t\"data-multiple\": multiple,\n\t\t\tonAfterChange,\n\t\t\tonAfterSelect,\n\t\t\tonBeforeChange,\n\t\t\tonBeforeMatch,\n\t\t\tonBeforeSelect,\n\t\t\tonSelectedChange,\n\t\t\tonInput,\n\t\t\tonChange,\n\t\t\tchildren,\n\t\t\tdisabled,\n\t\t\tname,\n\t\t\toptions,\n\t\t\tplaceholder,\n\t\t\treadOnly,\n\t\t\tselected,\n\t\t\ttype,\n\t\t\t...props\n\t\t},\n\t\tref,\n\t) {\n\t\tconst innerRef = useRef<UHTMLComboboxElement>(null);\n\t\tconst onSelected = useRef(onSelectedChange);\n\t\tonSelected.current = onSelectedChange; // Sync the latest onSelectedChange function\n\n\t\t// Deprecated props\n\t\tif (onAfterChange) {\n\t\t\tonAfterSelect = onAfterChange;\n\t\t\tconsole.warn(\n\t\t\t\t`Combobox onAfterChange is deprecated, use onAfterSelect instead.`,\n\t\t\t);\n\t\t}\n\t\tif (onBeforeChange) {\n\t\t\tonBeforeSelect = onBeforeChange;\n\t\t\tconsole.warn(\n\t\t\t\t`Combobox onBeforeChange is deprecated, use onBeforeSelect instead.`,\n\t\t\t);\n\t\t}\n\n\t\t// Using useEffect for React 18 and lower compatibility\n\t\tuseImperativeHandle(ref, () => innerRef.current as UHTMLComboboxElement); // Forward innerRef\n\t\tuseEffect(() => {\n\t\t\tconst self = innerRef.current;\n\t\t\tconst handleChange = (event: CustomEvent<HTMLDataElement>) => {\n\t\t\t\tconst handleSelected = onSelected.current;\n\t\t\t\tif (!onSelected) return; // No onSelectedChange function provided, let u-combobox handle it\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst { isConnected: remove, textContent, value } = event.detail;\n\t\t\t\tconst label = textContent?.trim() || \"\";\n\t\t\t\tconst prev = selected || [];\n\n\t\t\t\tif (remove) handleSelected?.(prev.filter((i) => i.value !== value));\n\t\t\t\telse if (multiple) handleSelected?.([...prev, { value, label }]);\n\t\t\t\telse handleSelected?.([{ value, label }]);\n\t\t\t};\n\n\t\t\tself?.addEventListener(\"comboboxbeforeselect\", handleChange);\n\t\t\treturn () =>\n\t\t\t\tself?.removeEventListener(\"comboboxbeforeselect\", handleChange);\n\t\t}, [multiple, selected]);\n\n\t\treturn (\n\t\t\t<u-combobox\n\t\t\t\tdata-multiple={multiple || undefined}\n\t\t\t\t{...toCustomElementProps({\n\t\t\t\t\toncomboboxbeforeselect: onBeforeSelect,\n\t\t\t\t\toncomboboxbeforematch: onBeforeMatch,\n\t\t\t\t\toncomboboxafterselect: onAfterSelect,\n\t\t\t\t\tref: innerRef,\n\t\t\t\t\t...props,\n\t\t\t\t})}\n\t\t\t>\n\t\t\t\t{selected?.map(({ children, label, value }) => (\n\t\t\t\t\t<data key={value} value={value} suppressHydrationWarning>\n\t\t\t\t\t\t{children ?? label}\n\t\t\t\t\t</data>\n\t\t\t\t))}\n\t\t\t\t{children || (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<Input\n\t\t\t\t\t\t\taria-required={required}\n\t\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\t\tname={name}\n\t\t\t\t\t\t\tonInput={onInput}\n\t\t\t\t\t\t\tonChange={onChange}\n\t\t\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t\t\t\treadOnly={readOnly}\n\t\t\t\t\t\t\ttype={type}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<del aria-label=\"Fjern tekst\" suppressHydrationWarning />\n\t\t\t\t\t</>\n\t\t\t\t)}\n\t\t\t\t{!!options && (\n\t\t\t\t\t<FieldDatalist data-nofilter={nofilter} data-position={position}>\n\t\t\t\t\t\t{options.map(toOption).map(({ children, label, value }) => (\n\t\t\t\t\t\t\t<FieldOption key={value} value={value} label={label}>\n\t\t\t\t\t\t\t\t{children ?? label}\n\t\t\t\t\t\t\t</FieldOption>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</FieldDatalist>\n\t\t\t\t)}\n\t\t\t</u-combobox>\n\t\t);\n\t},\n);\n\nexport type FieldLabelProps = React.ComponentPropsWithoutRef<\"label\">;\nconst FieldLabel = forwardRef<HTMLLabelElement, FieldLabelProps>(\n\tfunction FieldLabel(rest, ref) {\n\t\treturn <label suppressHydrationWarning ref={ref} {...rest} />;\n\t},\n);\n\nexport type FieldDescriptionProps = React.ComponentPropsWithoutRef<\"p\">;\nconst FieldDescription = forwardRef<\n\tHTMLParagraphElement,\n\tFieldDescriptionProps\n>(function FieldDescription(rest, ref) {\n\treturn <p suppressHydrationWarning ref={ref} {...rest} />;\n});\n\nexport type FieldCountProps = React.ComponentPropsWithoutRef<\"p\"> & {\n\t\"data-count\": number;\n};\nconst FieldCount = forwardRef<HTMLParagraphElement, FieldCountProps>(\n\tfunction FieldCount(rest, ref) {\n\t\treturn <p suppressHydrationWarning ref={ref} {...rest} />;\n\t},\n);\n\nexport const Field = Object.assign(FieldComp, {\n\tAffixes: FieldAffixes,\n\tCombobox: FieldCombobox,\n\tDatalist: FieldDatalist,\n\tOption: FieldOption,\n\tDescription: FieldDescription,\n\tLabel: FieldLabel,\n\tCount: FieldCount,\n});\n"],"names":["toOption","o","FieldComp","forwardRef","size","dataValidation","as","className","count","description","error","helpText","helpTextLabel","label","prefix","style","suffix","validationContent","rest","ref","Tag","affixes","validation","shared","clsx","styles","value","jsx","jsxs","FieldLabel","HelpText","FieldDescription","FieldAffixes","Validation","FieldCount","FieldDatalist","filter","toCustomElementProps","FieldOption","props","FieldCombobox","required","position","nofilter","multiple","onAfterChange","onAfterSelect","onBeforeChange","onBeforeMatch","onBeforeSelect","onSelectedChange","onInput","onChange","children","disabled","name","options","placeholder","readOnly","selected","type","innerRef","useRef","onSelected","useImperativeHandle","useEffect","self","handleChange","event","handleSelected","remove","textContent","prev","i","Fragment","Input","Field"],"mappings":";;;;;;;;AAwCA,MAAMA,IAAW,CAChBC,MAEA,OAAOA,KAAM,WAAW,EAAE,OAAOA,GAAG,OAAOA,EAAA,IAAMA,GAErCC,KAA4BC,EAAiB,SAGzD;AAAA,EACC,aAAaC;AAAA,EACb,mBAAmBC;AAAA,EACnB,IAAAC;AAAA,EACA,WAAAC;AAAA,EACA,OAAAC;AAAA,EACA,aAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,eAAAC;AAAA,EACA,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,YAAYC;AAAA,EACZ,GAAGC;AACJ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AACxD,CAAC,GAKKgB,IAAa/B;AAAA,EAClB,SAAoBe,GAAMC,GAAK;AAC9B,6BAAQ,KAAA,EAAE,0BAAwB,IAAC,KAAAA,GAAW,GAAGD,GAAM;AAAA,EACxD;AACD,GAEa0D,KAAQ,OAAO,OAAO1E,IAAW;AAAA,EAC7C,SAAS8B;AAAA,EACT,UAAUQ;AAAA,EACV,UAAUL;AAAA,EACV,QAAQG;AAAA,EACR,aAAaP;AAAA,EACb,OAAOF;AAAA,EACP,OAAOK;AACR,CAAC;"}
1
+ {"version":3,"file":"field.js","sources":["../../designsystem/field/field.tsx"],"sourcesContent":["\"use client\";\nimport type { Placement } from \"@floating-ui/dom\";\nimport type {\n\tReactUcombobox,\n\tUHTMLComboboxElement,\n} from \"@u-elements/u-combobox\";\nimport clsx from \"clsx\";\nimport type { JSX } from \"react\";\nimport { forwardRef, useEffect, useImperativeHandle, useRef } from \"react\";\nimport { HelpText } from \"../helptext/helptext\";\nimport { Input, type InputProps } from \"../input/input\";\nimport type {\n\tPolymorphicComponentPropWithRef,\n\tPolymorphicRef,\n} from \"../react-types\";\nimport styles from \"../styles.module.css\";\nimport { deprecate, toCustomElementProps } from \"../utils\";\nimport { Validation } from \"../validation/validation\";\n\ntype FieldBaseProps = {\n\tcount?: number;\n\tdescription?: React.ReactNode;\n\terror?: React.ReactNode; // Kept for backwards compatibility\n\thelpText?: React.ReactNode;\n\thelpTextLabel?: string;\n\tlabel?: React.ReactNode;\n\toptions?: string[] | FieldComboboxSelected;\n\tprefix?: string;\n\treadOnly?: boolean; // Allow readoOnly also on <select>\n\tsuffix?: string;\n\tvalidation?: React.ReactNode;\n};\n\nexport type FieldProps<As extends React.ElementType = \"div\"> =\n\tPolymorphicComponentPropWithRef<As, FieldBaseProps>;\n\ntype FieldComponent = <As extends React.ElementType = \"div\">(\n\tprops: FieldProps<As>,\n) => JSX.Element;\n\nconst toOption = (\n\to: FieldComboboxSelected[number] | string,\n): FieldComboboxSelected[number] =>\n\ttypeof o === \"string\" ? { label: o, value: o } : o;\n\nexport const FieldComp: FieldComponent = forwardRef<null>(function Field<\n\tAs extends React.ElementType = \"div\",\n>(\n\t{\n\t\t\"data-size\": size,\n\t\t\"data-validation\": dataValidation,\n\t\tas,\n\t\tclassName,\n\t\tcount,\n\t\tdescription,\n\t\terror,\n\t\thelpText,\n\t\thelpTextLabel,\n\t\tlabel,\n\t\tprefix,\n\t\tstyle,\n\t\tsuffix,\n\t\tvalidation: validationContent,\n\t\t...rest\n\t}: FieldProps<As>,\n\tref?: PolymorphicRef<As>,\n) {\n\tconst Tag = as || \"div\";\n\tconst affixes = !!suffix || !!prefix;\n\tconst validation = validationContent || error; // error kept for backwards compatibility\n\tconst shared = {\n\t\t\"data-size\": size,\n\t\t\"data-validation\": dataValidation,\n\t\tclassName: clsx(styles.field, className),\n\t\tstyle,\n\t};\n\n\t// Render options if select\n\tif (as === \"select\" && !rest.children)\n\t\tObject.assign(rest, {\n\t\t\toptions: undefined, // Ensure options is not passed to DOM\n\t\t\tchildren: (\n\t\t\t\t<>\n\t\t\t\t\t{(rest.options as FieldBaseProps[\"options\"])\n\t\t\t\t\t\t?.map(toOption)\n\t\t\t\t\t\t.map(({ label, value }) => (\n\t\t\t\t\t\t\t<option key={value} value={value}>\n\t\t\t\t\t\t\t\t{label}\n\t\t\t\t\t\t\t</option>\n\t\t\t\t\t\t))}\n\t\t\t\t</>\n\t\t\t),\n\t\t});\n\n\t// Using suppressHydrationWarning to avoid Next.js vs field-observer.ts hydration conflict\n\treturn as ? (\n\t\t<div {...shared}>\n\t\t\t{!!label && <FieldLabel>{label}</FieldLabel>}\n\t\t\t{!!helpText && <HelpText aria-label={helpTextLabel}>{helpText}</HelpText>}\n\t\t\t{!!description && <FieldDescription>{description}</FieldDescription>}\n\t\t\t{affixes ? (\n\t\t\t\t<FieldAffixes>\n\t\t\t\t\t{!!prefix && <span>{prefix}</span>}\n\t\t\t\t\t<Tag\n\t\t\t\t\t\tclassName={styles.input}\n\t\t\t\t\t\tsuppressHydrationWarning\n\t\t\t\t\t\tref={ref}\n\t\t\t\t\t\t{...rest}\n\t\t\t\t\t/>\n\t\t\t\t\t{!!suffix && <span>{suffix}</span>}\n\t\t\t\t</FieldAffixes>\n\t\t\t) : (\n\t\t\t\t<Tag\n\t\t\t\t\tclassName={typeof as === \"string\" ? styles.input : undefined}\n\t\t\t\t\tsuppressHydrationWarning\n\t\t\t\t\tref={ref}\n\t\t\t\t\t{...rest}\n\t\t\t\t/>\n\t\t\t)}\n\t\t\t{!!validation && <Validation>{validation}</Validation>}\n\t\t\t{!!count && <FieldCount data-count={count} />}\n\t\t</div>\n\t) : (\n\t\t<div ref={ref} {...shared} {...rest} />\n\t);\n}) as FieldComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n\nexport type FieldAffixProps = React.ComponentPropsWithoutRef<\"div\">;\nconst FieldAffixes = forwardRef<HTMLDivElement, FieldAffixProps>(\n\tfunction FieldAffixes({ className, ...rest }, ref) {\n\t\treturn (\n\t\t\t<div className={clsx(styles.affixes, className)} ref={ref} {...rest} />\n\t\t);\n\t},\n);\n\nexport type FieldDatalistProps = React.ComponentPropsWithoutRef<\"datalist\"> & {\n\t\"data-nofilter\"?: boolean;\n\t\"data-position\"?: Placement;\n};\n\nconst FieldDatalist = forwardRef<HTMLDataListElement, FieldDatalistProps>(\n\tfunction FieldDatalist({ \"data-nofilter\": filter, ...rest }, ref) {\n\t\treturn (\n\t\t\t<u-datalist\n\t\t\t\tdata-nofilter={!!filter || undefined} // Ensure data-nofilter is set correctly\n\t\t\t\tref={ref}\n\t\t\t\t{...toCustomElementProps(rest)}\n\t\t\t/>\n\t\t);\n\t},\n);\n\nexport type FieldOptionProps = React.ComponentPropsWithoutRef<\"option\">;\nconst FieldOption = forwardRef<HTMLOptionElement, FieldOptionProps>(\n\tfunction FieldOption(props, ref) {\n\t\treturn <u-option ref={ref} {...toCustomElementProps(props)} />;\n\t},\n);\n\nexport type FieldComboboxSelected = {\n\tlabel: string;\n\tvalue: string;\n\tchildren?: React.ReactNode;\n}[];\nexport type FieldComboboxProps = Omit<\n\tReactUcombobox,\n\t\"onChange\" | \"onInput\"\n> & {\n\t\"data-creatable\"?: boolean;\n\t\"data-multiple\"?: boolean;\n\tonAfterChange?: (e: CustomEvent<HTMLDataElement>) => void; // deprecated\n\tonAfterSelect?: (e: CustomEvent<HTMLDataElement>) => void; // Custom event to handle before change\n\tonBeforeChange?: (e: CustomEvent<HTMLDataElement>) => void; // deprecated\n\tonBeforeMatch?: (e: CustomEvent<HTMLOptionElement>) => void; // Custom event to handle before change\n\tonBeforeSelect?: (e: CustomEvent<HTMLDataElement>) => void; // Custom event to handle before change\n\tonSelectedChange?: (selected: FieldComboboxSelected) => void; // Allow onChange to be a function that returns void\n\toptions?: FieldComboboxSelected;\n\tselected?: FieldComboboxSelected; // Allow value to be a string or an array of strings for multiple select\n} & Pick<\n\t\tInputProps,\n\t\t| \"disabled\"\n\t\t| \"name\"\n\t\t| \"onChange\"\n\t\t| \"onInput\"\n\t\t| \"placeholder\"\n\t\t| \"readOnly\"\n\t\t| \"type\"\n\t\t| \"value\"\n\t> & // Allow input props to be passed down\n\tPick<FieldDatalistProps, \"data-position\" | \"data-nofilter\">; // Allow datalist props to be passed down\n\nconst FieldCombobox = forwardRef<UHTMLComboboxElement, FieldComboboxProps>(\n\tfunction FieldCombobox(\n\t\t{\n\t\t\t\"aria-required\": required,\n\t\t\t\"data-position\": position,\n\t\t\t\"data-nofilter\": nofilter,\n\t\t\t\"data-multiple\": multiple,\n\t\t\tonAfterChange,\n\t\t\tonAfterSelect,\n\t\t\tonBeforeChange,\n\t\t\tonBeforeMatch,\n\t\t\tonBeforeSelect,\n\t\t\tonSelectedChange,\n\t\t\tonInput,\n\t\t\tonChange,\n\t\t\tchildren,\n\t\t\tdisabled,\n\t\t\tname,\n\t\t\toptions,\n\t\t\tplaceholder,\n\t\t\treadOnly,\n\t\t\tselected,\n\t\t\ttype,\n\t\t\t...props\n\t\t},\n\t\tref,\n\t) {\n\t\tconst innerRef = useRef<UHTMLComboboxElement>(null);\n\t\tconst onSelected = useRef(onSelectedChange);\n\t\tonSelected.current = onSelectedChange; // Sync the latest onSelectedChange function\n\n\t\t// Deprecated props\n\t\tif (onAfterChange) {\n\t\t\tonAfterSelect = onAfterChange;\n\t\t\tdeprecate(\"onAfterChange\", \"onAfterSelect\");\n\t\t}\n\t\tif (onBeforeChange) {\n\t\t\tonBeforeSelect = onBeforeChange;\n\t\t\tdeprecate(\"onBeforeChange\", \"onBeforeSelect\");\n\t\t}\n\n\t\t// Using useEffect for React 18 and lower compatibility\n\t\tuseImperativeHandle(ref, () => innerRef.current as UHTMLComboboxElement); // Forward innerRef\n\t\tuseEffect(() => {\n\t\t\tconst self = innerRef.current;\n\t\t\tconst handleChange = (event: CustomEvent<HTMLDataElement>) => {\n\t\t\t\tconst handleSelected = onSelected.current;\n\t\t\t\tif (!onSelected) return; // No onSelectedChange function provided, let u-combobox handle it\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst { isConnected: remove, textContent, value } = event.detail;\n\t\t\t\tconst label = textContent?.trim() || \"\";\n\t\t\t\tconst prev = selected || [];\n\n\t\t\t\tif (remove) handleSelected?.(prev.filter((i) => i.value !== value));\n\t\t\t\telse if (multiple) handleSelected?.([...prev, { value, label }]);\n\t\t\t\telse handleSelected?.([{ value, label }]);\n\t\t\t};\n\n\t\t\tself?.addEventListener(\"comboboxbeforeselect\", handleChange);\n\t\t\treturn () =>\n\t\t\t\tself?.removeEventListener(\"comboboxbeforeselect\", handleChange);\n\t\t}, [multiple, selected]);\n\n\t\treturn (\n\t\t\t<u-combobox\n\t\t\t\tdata-multiple={multiple || undefined}\n\t\t\t\t{...toCustomElementProps({\n\t\t\t\t\toncomboboxbeforeselect: onBeforeSelect,\n\t\t\t\t\toncomboboxbeforematch: onBeforeMatch,\n\t\t\t\t\toncomboboxafterselect: onAfterSelect,\n\t\t\t\t\tref: innerRef,\n\t\t\t\t\t...props,\n\t\t\t\t})}\n\t\t\t>\n\t\t\t\t{selected?.map(({ children, label, value }) => (\n\t\t\t\t\t<data key={value} value={value} suppressHydrationWarning>\n\t\t\t\t\t\t{children ?? label}\n\t\t\t\t\t</data>\n\t\t\t\t))}\n\t\t\t\t{children || (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<Input\n\t\t\t\t\t\t\taria-required={required}\n\t\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\t\tname={name}\n\t\t\t\t\t\t\tonInput={onInput}\n\t\t\t\t\t\t\tonChange={onChange}\n\t\t\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t\t\t\treadOnly={readOnly}\n\t\t\t\t\t\t\ttype={type}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<del aria-label=\"Fjern tekst\" suppressHydrationWarning />\n\t\t\t\t\t</>\n\t\t\t\t)}\n\t\t\t\t{!!options && (\n\t\t\t\t\t<FieldDatalist data-nofilter={nofilter} data-position={position}>\n\t\t\t\t\t\t{options.map(toOption).map(({ children, label, value }) => (\n\t\t\t\t\t\t\t<FieldOption key={value} value={value} label={label}>\n\t\t\t\t\t\t\t\t{children ?? label}\n\t\t\t\t\t\t\t</FieldOption>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</FieldDatalist>\n\t\t\t\t)}\n\t\t\t</u-combobox>\n\t\t);\n\t},\n);\n\nexport type FieldLabelProps = React.ComponentPropsWithoutRef<\"label\">;\nconst FieldLabel = forwardRef<HTMLLabelElement, FieldLabelProps>(\n\tfunction FieldLabel(rest, ref) {\n\t\treturn <label suppressHydrationWarning ref={ref} {...rest} />;\n\t},\n);\n\nexport type FieldDescriptionProps = React.ComponentPropsWithoutRef<\"p\">;\nconst FieldDescription = forwardRef<\n\tHTMLParagraphElement,\n\tFieldDescriptionProps\n>(function FieldDescription(rest, ref) {\n\treturn <p suppressHydrationWarning ref={ref} {...rest} />;\n});\n\nexport type FieldCountProps = React.ComponentPropsWithoutRef<\"p\"> & {\n\t\"data-count\": number;\n};\nconst FieldCount = forwardRef<HTMLParagraphElement, FieldCountProps>(\n\tfunction FieldCount(rest, ref) {\n\t\treturn <p suppressHydrationWarning ref={ref} {...rest} />;\n\t},\n);\n\nexport const Field = Object.assign(FieldComp, {\n\tAffixes: FieldAffixes,\n\tCombobox: FieldCombobox,\n\tDatalist: FieldDatalist,\n\tOption: FieldOption,\n\tDescription: FieldDescription,\n\tLabel: FieldLabel,\n\tCount: FieldCount,\n});\n"],"names":["toOption","o","FieldComp","forwardRef","size","dataValidation","as","className","count","description","error","helpText","helpTextLabel","label","prefix","style","suffix","validationContent","rest","ref","Tag","affixes","validation","shared","clsx","styles","value","jsx","jsxs","FieldLabel","HelpText","FieldDescription","FieldAffixes","Validation","FieldCount","FieldDatalist","filter","toCustomElementProps","FieldOption","props","FieldCombobox","required","position","nofilter","multiple","onAfterChange","onAfterSelect","onBeforeChange","onBeforeMatch","onBeforeSelect","onSelectedChange","onInput","onChange","children","disabled","name","options","placeholder","readOnly","selected","type","innerRef","useRef","onSelected","deprecate","useImperativeHandle","useEffect","self","handleChange","event","handleSelected","remove","textContent","prev","i","Fragment","Input","Field"],"mappings":";;;;;;;;AAwCA,MAAMA,IAAW,CAChBC,MAEA,OAAOA,KAAM,WAAW,EAAE,OAAOA,GAAG,OAAOA,EAAA,IAAMA,GAErCC,KAA4BC,EAAiB,SAGzD;AAAA,EACC,aAAaC;AAAA,EACb,mBAAmBC;AAAA,EACnB,IAAAC;AAAA,EACA,WAAAC;AAAA,EACA,OAAAC;AAAA,EACA,aAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,eAAAC;AAAA,EACA,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,YAAYC;AAAA,EACZ,GAAGC;AACJ,GACAC,GACC;AACD,QAAMC,IAAMd,KAAM,OACZe,IAAU,CAAC,CAACL,KAAU,CAAC,CAACF,GACxBQ,IAAaL,KAAqBP,GAClC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