@mattilsynet/design 3.3.8 → 3.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/mtds/ai/avatar.stories.tsx +3 -0
- package/mtds/ai/field.stories.tsx +1 -1
- package/mtds/ai/typography.stories.tsx +1 -3
- package/mtds/atlas/atlas-element.js +1 -1
- package/mtds/atlas/atlas-element.js.map +1 -1
- package/mtds/external/@u-elements/u-combobox/dist/u-combobox.js +153 -132
- package/mtds/external/@u-elements/u-combobox/dist/u-combobox.js.map +1 -1
- package/mtds/illustrations/books.svg +1 -0
- package/mtds/illustrations/carrot.svg +1 -0
- package/mtds/illustrations/collaboration-and-culture.svg +1 -0
- package/mtds/illustrations/emergency-vehicle.svg +1 -0
- package/mtds/illustrations/eu-flags.svg +1 -0
- package/mtds/illustrations/eu-work-1.svg +1 -0
- package/mtds/illustrations/eu-work-2.svg +1 -0
- package/mtds/illustrations/fishing-boat-and-fish-health-biologist.svg +1 -0
- package/mtds/illustrations/fishing-boat.svg +1 -0
- package/mtds/illustrations/index.json +143 -7
- package/mtds/illustrations/it-and-security.svg +1 -0
- package/mtds/illustrations/kompass.svg +1 -1
- package/mtds/illustrations/lab-work.svg +1 -0
- package/mtds/illustrations/law-books.svg +1 -0
- package/mtds/illustrations/law.svg +1 -0
- package/mtds/illustrations/letter-in-mailbox.svg +1 -0
- package/mtds/illustrations/man-with-magnifying-glass.svg +1 -0
- package/mtds/illustrations/milk-carton.svg +1 -0
- package/mtds/illustrations/norwegian-parliament.svg +1 -0
- package/mtds/illustrations/pen.svg +1 -0
- package/mtds/illustrations/pencil.svg +1 -0
- package/mtds/illustrations/person-and-infographic.svg +1 -0
- package/mtds/illustrations/person-with-tie.svg +1 -0
- package/mtds/illustrations/screen-with-content.svg +1 -0
- package/mtds/illustrations/shopping-cart-large.svg +1 -0
- package/mtds/illustrations/study.svg +1 -0
- package/mtds/illustrations/telescope.svg +1 -0
- package/mtds/illustrations/trailer.svg +1 -0
- package/mtds/illustrations/user-dialogue.svg +1 -0
- package/mtds/illustrations/user-interface.svg +1 -0
- package/mtds/illustrations/waterworks.svg +1 -0
- package/mtds/index.iife.js +89 -21
- package/mtds/package.json.js +1 -1
- package/mtds/styles.css +1 -1
- package/mtds/styles.json +23 -23
- package/mtds/styles.module.css.js +40 -40
- package/package.json +5 -5
|
@@ -550,7 +550,7 @@ export const WithSuggestionAPI: Story = {
|
|
|
550
550
|
|
|
551
551
|
const getCountries = async (value: string) => {
|
|
552
552
|
if (!value) return setOptions("Name a country");
|
|
553
|
-
const api = `https://dummyjson.com/recipes/search?q=${value}`;
|
|
553
|
+
const api = `https://dummyjson.com/recipes/search?q=${value}`; // TODO FIX
|
|
554
554
|
const data = await (await fetch(api)).json();
|
|
555
555
|
|
|
556
556
|
setOptions(
|
|
@@ -182,11 +182,9 @@ const proseDecorator: Story["decorators"] = (Story) => {
|
|
|
182
182
|
body:has(input[role="switch"]:checked) { --checked: "" }
|
|
183
183
|
body:has(input[role="switch"]:checked) .${CSS_PROSE} > :hover { --background: #88bbff4d }
|
|
184
184
|
body:not(:has(.sbdocs-content)) {
|
|
185
|
-
.${CSS_PROSE} { overflow: clip }
|
|
186
185
|
.${CSS_PROSE} > * {
|
|
187
186
|
position: relative;
|
|
188
|
-
background: var(--background, transparent);
|
|
189
|
-
box-shadow: 100px 0 var(--background, transparent), -100px 0 var(--background, transparent);
|
|
187
|
+
background: linear-gradient(to right, var(--background, transparent), transparent);
|
|
190
188
|
}
|
|
191
189
|
.${CSS_PROSE} > [data-before]::before,
|
|
192
190
|
.${CSS_PROSE} > [data-after]::after {
|
|
@@ -19,7 +19,7 @@ class r extends g {
|
|
|
19
19
|
}
|
|
20
20
|
constructor() {
|
|
21
21
|
super(), this.attachShadow({ mode: "open" }).append(m("figure")), C(this, `@layer leaflet{${h}}
|
|
22
|
-
@layer mt.v3-3-
|
|
22
|
+
@layer mt.v3-3-10design{${b}`);
|
|
23
23
|
}
|
|
24
24
|
connectedCallback() {
|
|
25
25
|
const t = this.shadowRoot?.lastElementChild, e = a(this, "data-cluster") ?? "false", o = new i.TileLayer(k, {
|
|
@@ -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\"; // Extend L namespace\nimport \"./cluster.js\";\nimport {\n\tattachStyle,\n\tattr,\n\tdefineElement,\n\tisBrowser,\n\tMTDSElement,\n\toff,\n\ton,\n\ttag,\n} from \"../utils\";\nimport css from \"./atlas.css?raw\";\n\nexport { MTDSAtlasMarkerElement } from \"./atlas-marker\";\nexport { MTDSAtlasMatgeoElement } from \"./atlas-matgeo\";\nexport { MTDSAtlasWMSElement } from \"./atlas-wms\";\nexport { L };\n\n// TODO: Add minimum zoom level for adding markers (minimum 17 som standard?)\n// TODO: Add search helper (https://ws.geonorge.no/adresser/v1/openapi.json + https://ws.geonorge.no/adresser/v1/#/default/get_sok)\n// TODO: matgeo-autoload popover info\n\ntype Link = { href: string; rel: string; type: string; title: string };\ntype BBox = [number, number, number, number];\nexport type MTDSAtlasCollections = Record<string, MTDSAtlasCollection>;\nexport type MTDSAtlasCollection = {\n\tcrs: string[];\n\tdescription: string;\n\textent: { spatial: { bbox: BBox[] } };\n\tgeometry: string;\n\tid: string;\n\titemType: string;\n\tlinks: Link[];\n\ttitle: string;\n};\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t\"mtds-atlas\": MTDSAtlasElement;\n\t}\n\n\tinterface Window {\n\t\t_matgeoCollections?: Promise<MTDSAtlasCollections>;\n\t}\n}\n\nlet SKIP_CLICK: number | NodeJS.Timeout = 0;\nconst KARTVERKET_MAX_ZOOM = 18; // Kartverket does not support more than zoom level 18\nconst KARTVERKET_TILES_URL =\n\t\"https://cache.kartverket.no/v1/wmts/1.0.0/topo/default/webmercator/{z}/{y}/{x}.png\";\nexport const MATGEO_URL =\n\t\"https://matgeoservice-256616427209.europe-north1.run.app/ogc/features/collections\";\nconst BOUNDS_NORWAY: L.LatLngBoundsLiteral = [\n\t[57.5, 4.73],\n\t[71.5, 31.44],\n];\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\"]; // Using ES2015 syntax for backwards compatibility\n\t}\n\tconstructor() {\n\t\tsuper();\n\t\tthis.attachShadow({ mode: \"open\" }).append(tag(\"figure\"));\n\t\tattachStyle(this, `@layer leaflet{${LeafletCSS}}\\n@layer mt.design{${css}`);\n\t}\n\tconnectedCallback() {\n\t\tconst container = this.shadowRoot?.lastElementChild as HTMLElement;\n\t\tconst cluster = attr(this, \"data-cluster\") ?? \"false\";\n\t\tconst tiles = new L.TileLayer(KARTVERKET_TILES_URL, {\n\t\t\tattribution: \"© Kartverket\",\n\t\t\tclassName: \"leaflet-kartverket-tiles\",\n\t\t\tmaxZoom: KARTVERKET_MAX_ZOOM,\n\t\t});\n\n\t\tthis.map = new L.Map(container, {\n\t\t\tattributionControl: false,\n\t\t\tfadeAnimation: false, // Prevent popup fades\n\t\t\tlayers: [tiles],\n\t\t\tzoomControl: false,\n\t\t\tzoomSnap: 0.2,\n\t\t});\n\n\t\ton(this, \"pointerup click\", this.#skipClick); // Prevent clicks from bubbling up unless sent from Leaflet\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 popupclose\", this.#handlePopup, this);\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) || KARTVERKET_MAX_ZOOM + 1,\n\t\t\ticonCreateFunction: (cluster: L.MarkerCluster) =>\n\t\t\t\tnew L.DivIcon({\n\t\t\t\t\thtml: `${cluster.getChildCount()}`,\n\t\t\t\t\tclassName: \"leaflet-cluster-icon\",\n\t\t\t\t\ticonSize: [40, 40],\n\t\t\t\t}),\n\t\t}).addTo(this.map);\n\n\t\t// Initial setup attributes\n\t\tfor (const name of MTDSAtlasElement.observedAttributes)\n\t\t\tthis.attributeChangedCallback(name, null, attr(this, name));\n\t}\n\tattributeChangedCallback(name: string, _prev?: null, next?: string | null) {\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[], opts?: L.FitBoundsOptions) {\n\t\tconst p = `${view}`.split(\",\").map(parseFloat).filter(Number.isFinite);\n\t\tconst b = this.cluster?.getBounds();\n\n\t\tif (p.length === 3) return this.map?.setView([p[0], p[1]], p[2], opts);\n\t\tif (view !== \"fit\") return this.map?.fitBounds(BOUNDS_NORWAY, opts);\n\t\tif (b?.isValid()) return this.map?.fitBounds(b.pad(0.1), opts);\n\t\tthis.cluster?.once(\"layeradd\", () => {\n\t\t\tsetTimeout(() => this.setView(\"fit\"), 50); // Add all markers before fitting\n\t\t});\n\t}\n\tlatLngFromPoint(x: number, y: number) {\n\t\t// @ts-expect-error -- Missing from Leaflet@2.0.0-alpha.1 types\n\t\treturn this.map?.pointerEventToLatLng({ clientX: x, clientY: y });\n\t}\n\tdisconnectedCallback() {\n\t\toff(this, \"pointerup click\", this.#skipClick);\n\t\tthis.map?.remove();\n\t\tthis.map = this.cluster = undefined;\n\t}\n\tasync getCollections() {\n\t\tif (!window._matgeoCollections)\n\t\t\twindow._matgeoCollections = fetch(MATGEO_URL)\n\t\t\t\t.then((res) => res.json())\n\t\t\t\t.then((d) => d.collections.map((c: MTDSAtlasCollection) => [c.id, c]))\n\t\t\t\t.then(Object.fromEntries);\n\t\treturn window._matgeoCollections;\n\t}\n\t#handlePopup({ type, popup }: { type: string; popup: L.Popup }) {\n\t\tconst open = type === \"popupopen\";\n\t\tconst cont = popup.getElement()?.querySelector(\".leaflet-popup-content\");\n\t\tconst slot = cont?.querySelector<HTMLSlotElement>(\":scope > slot\");\n\t\tconst id = cont?.textContent?.match(/^#(\\S+)/)?.[1] || \"\";\n\t\tconst el = document.getElementById(slot?.name || id); // If content of popup is #id, replace with <slot>\n\n\t\tif (!el) return open && id && popup.close(); // Close popup if target element not found\n\t\tL.Util.setOptions(popup, { maxWidth: this.offsetWidth - 40 });\n\t\tattr(el, \"data-popover\", open ? attr(el, \"popover\") : null); // Store previous popover mode\n\t\tattr(el, \"popover\", open ? null : attr(el, \"data-popover\")); // But temporarily remove it so popover renders\n\t\tattr(el, \"slot\", open ? el.id : null); // Render popover in slot\n\t\tif (open) popup.setContent(tag(\"slot\", { name: el.id }));\n\t}\n\t#skipClick(event: Partial<MouseEvent>) {\n\t\tif (event.type === \"click\") SKIP_CLICK && event.stopPropagation?.();\n\t\telse if (document.body.classList.contains(\"leaflet-dragging\"))\n\t\t\tSKIP_CLICK = setTimeout(() => {\n\t\t\t\tSKIP_CLICK = 0;\n\t\t\t}, 50); // Was dragging, so skip succeeding click\n\t}\n}\n\ndefineElement(\"mtds-atlas\", MTDSAtlasElement);\n\nif (isBrowser())\n\tL.Marker.prototype.options.icon = new L.DivIcon({\n\t\thtml: '<div class=\"leaflet-marker-generated-slot\"><div class=\"leaflet-marker-generated-icon\"></div></div>',\n\t\ticonSize: [0, 0],\n\t});\n"],"names":["SKIP_CLICK","KARTVERKET_MAX_ZOOM","KARTVERKET_TILES_URL","MATGEO_URL","BOUNDS_NORWAY","MTDSAtlasElement","MTDSElement","tag","attachStyle","LeafletCSS","css","container","cluster","attr","tiles","L","on","#skipClick","#handlePopup","name","_prev","next","view","opts","p","b","x","y","off","res","d","c","type","popup","open","cont","slot","id","el","event","defineElement","isBrowser"],"mappings":";;;;;;;;AAiDA,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ExCoC,EAAA,MACH1B,EAAE,OAAO,UAAU,QAAQ,OAAO,IAAIA,EAAE,QAAQ;AAAA,EAC/C,MAAM;AAAA,EACN,UAAU,CAAC,GAAG,CAAC;AAAA,CACf;"}
|
|
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\"; // Extend L namespace\nimport \"./cluster.js\";\nimport {\n\tattachStyle,\n\tattr,\n\tdefineElement,\n\tisBrowser,\n\tMTDSElement,\n\toff,\n\ton,\n\ttag,\n} from \"../utils\";\nimport css from \"./atlas.css?raw\";\n\nexport { MTDSAtlasMarkerElement } from \"./atlas-marker\";\nexport { MTDSAtlasMatgeoElement } from \"./atlas-matgeo\";\nexport { MTDSAtlasWMSElement } from \"./atlas-wms\";\nexport { L };\n\n// TODO: Add minimum zoom level for adding markers (minimum 17 som standard?)\n// TODO: Add search helper (https://ws.geonorge.no/adresser/v1/openapi.json + https://ws.geonorge.no/adresser/v1/#/default/get_sok)\n// TODO: matgeo-autoload popover info\n\ntype Link = { href: string; rel: string; type: string; title: string };\ntype BBox = [number, number, number, number];\nexport type MTDSAtlasCollections = Record<string, MTDSAtlasCollection>;\nexport type MTDSAtlasCollection = {\n\tcrs: string[];\n\tdescription: string;\n\textent: { spatial: { bbox: BBox[] } };\n\tgeometry: string;\n\tid: string;\n\titemType: string;\n\tlinks: Link[];\n\ttitle: string;\n};\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t\"mtds-atlas\": MTDSAtlasElement;\n\t}\n\n\tinterface Window {\n\t\t_matgeoCollections?: Promise<MTDSAtlasCollections>;\n\t}\n}\n\nlet SKIP_CLICK: number | NodeJS.Timeout = 0;\nconst KARTVERKET_MAX_ZOOM = 18; // Kartverket does not support more than zoom level 18\nconst KARTVERKET_TILES_URL =\n\t\"https://cache.kartverket.no/v1/wmts/1.0.0/topo/default/webmercator/{z}/{y}/{x}.png\";\nexport const MATGEO_URL =\n\t\"https://matgeoservice-256616427209.europe-north1.run.app/ogc/features/collections\";\nconst BOUNDS_NORWAY: L.LatLngBoundsLiteral = [\n\t[57.5, 4.73],\n\t[71.5, 31.44],\n];\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\"]; // Using ES2015 syntax for backwards compatibility\n\t}\n\tconstructor() {\n\t\tsuper();\n\t\tthis.attachShadow({ mode: \"open\" }).append(tag(\"figure\"));\n\t\tattachStyle(this, `@layer leaflet{${LeafletCSS}}\\n@layer mt.design{${css}`);\n\t}\n\tconnectedCallback() {\n\t\tconst container = this.shadowRoot?.lastElementChild as HTMLElement;\n\t\tconst cluster = attr(this, \"data-cluster\") ?? \"false\";\n\t\tconst tiles = new L.TileLayer(KARTVERKET_TILES_URL, {\n\t\t\tattribution: \"© Kartverket\",\n\t\t\tclassName: \"leaflet-kartverket-tiles\",\n\t\t\tmaxZoom: KARTVERKET_MAX_ZOOM,\n\t\t});\n\n\t\tthis.map = new L.Map(container, {\n\t\t\tattributionControl: false,\n\t\t\tfadeAnimation: false, // Prevent popup fades\n\t\t\tlayers: [tiles],\n\t\t\tzoomControl: false,\n\t\t\tzoomSnap: 0.2,\n\t\t});\n\n\t\ton(this, \"pointerup click\", this.#skipClick); // Prevent clicks from bubbling up unless sent from Leaflet\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 popupclose\", this.#handlePopup, this);\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) || KARTVERKET_MAX_ZOOM + 1,\n\t\t\ticonCreateFunction: (cluster: L.MarkerCluster) =>\n\t\t\t\tnew L.DivIcon({\n\t\t\t\t\thtml: `${cluster.getChildCount()}`,\n\t\t\t\t\tclassName: \"leaflet-cluster-icon\",\n\t\t\t\t\ticonSize: [40, 40],\n\t\t\t\t}),\n\t\t}).addTo(this.map);\n\n\t\t// Initial setup attributes\n\t\tfor (const name of MTDSAtlasElement.observedAttributes)\n\t\t\tthis.attributeChangedCallback(name, null, attr(this, name));\n\t}\n\tattributeChangedCallback(name: string, _prev?: null, next?: string | null) {\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[], opts?: L.FitBoundsOptions) {\n\t\tconst p = `${view}`.split(\",\").map(parseFloat).filter(Number.isFinite);\n\t\tconst b = this.cluster?.getBounds();\n\n\t\tif (p.length === 3) return this.map?.setView([p[0], p[1]], p[2], opts);\n\t\tif (view !== \"fit\") return this.map?.fitBounds(BOUNDS_NORWAY, opts);\n\t\tif (b?.isValid()) return this.map?.fitBounds(b.pad(0.1), opts);\n\t\tthis.cluster?.once(\"layeradd\", () => {\n\t\t\tsetTimeout(() => this.setView(\"fit\"), 50); // Add all markers before fitting\n\t\t});\n\t}\n\tlatLngFromPoint(x: number, y: number) {\n\t\t// @ts-expect-error -- Missing from Leaflet@2.0.0-alpha.1 types\n\t\treturn this.map?.pointerEventToLatLng({ clientX: x, clientY: y });\n\t}\n\tdisconnectedCallback() {\n\t\toff(this, \"pointerup click\", this.#skipClick);\n\t\tthis.map?.remove();\n\t\tthis.map = this.cluster = undefined;\n\t}\n\tasync getCollections() {\n\t\tif (!window._matgeoCollections)\n\t\t\twindow._matgeoCollections = fetch(MATGEO_URL)\n\t\t\t\t.then((res) => res.json())\n\t\t\t\t.then((d) => d.collections.map((c: MTDSAtlasCollection) => [c.id, c]))\n\t\t\t\t.then(Object.fromEntries);\n\t\treturn window._matgeoCollections;\n\t}\n\t#handlePopup({ type, popup }: { type: string; popup: L.Popup }) {\n\t\tconst open = type === \"popupopen\";\n\t\tconst cont = popup.getElement()?.querySelector(\".leaflet-popup-content\");\n\t\tconst slot = cont?.querySelector<HTMLSlotElement>(\":scope > slot\");\n\t\tconst id = cont?.textContent?.match(/^#(\\S+)/)?.[1] || \"\";\n\t\tconst el = document.getElementById(slot?.name || id); // If content of popup is #id, replace with <slot>\n\n\t\tif (!el) return open && id && popup.close(); // Close popup if target element not found\n\t\tL.Util.setOptions(popup, { maxWidth: this.offsetWidth - 40 });\n\t\tattr(el, \"data-popover\", open ? attr(el, \"popover\") : null); // Store previous popover mode\n\t\tattr(el, \"popover\", open ? null : attr(el, \"data-popover\")); // But temporarily remove it so popover renders\n\t\tattr(el, \"slot\", open ? el.id : null); // Render popover in slot\n\t\tif (open) popup.setContent(tag(\"slot\", { name: el.id }));\n\t}\n\t#skipClick(event: Partial<MouseEvent>) {\n\t\tif (event.type === \"click\") SKIP_CLICK && event.stopPropagation?.();\n\t\telse if (document.body.classList.contains(\"leaflet-dragging\"))\n\t\t\tSKIP_CLICK = setTimeout(() => {\n\t\t\t\tSKIP_CLICK = 0;\n\t\t\t}, 50); // Was dragging, so skip succeeding click\n\t}\n}\n\ndefineElement(\"mtds-atlas\", MTDSAtlasElement);\n\nif (isBrowser())\n\tL.Marker.prototype.options.icon = new L.DivIcon({\n\t\thtml: '<div class=\"leaflet-marker-generated-slot\"><div class=\"leaflet-marker-generated-icon\"></div></div>',\n\t\ticonSize: [0, 0],\n\t});\n"],"names":["SKIP_CLICK","KARTVERKET_MAX_ZOOM","KARTVERKET_TILES_URL","MATGEO_URL","BOUNDS_NORWAY","MTDSAtlasElement","MTDSElement","tag","attachStyle","LeafletCSS","css","container","cluster","attr","tiles","L","on","#skipClick","#handlePopup","name","_prev","next","view","opts","p","b","x","y","off","res","d","c","type","popup","open","cont","slot","id","el","event","defineElement","is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EAwC,EAAc,cAAcnC,CAAgB;AAExCoC,EAAA,MACH1B,EAAE,OAAO,UAAU,QAAQ,OAAO,IAAIA,EAAE,QAAQ;AAAA,EAC/C,MAAM;AAAA,EACN,UAAU,CAAC,GAAG,CAAC;AAAA,CACf;"}
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Z = Object.defineProperty, N = Object.getOwnPropertySymbols, tt = Object.prototype.hasOwnProperty, et = Object.prototype.propertyIsEnumerable, P = (t, e, o) => e in t ? Z(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o, ot = (t, e) => {
|
|
2
2
|
for (var o in e || (e = {}))
|
|
3
|
-
|
|
4
|
-
if (
|
|
5
|
-
for (var o of
|
|
6
|
-
|
|
3
|
+
tt.call(e, o) && P(t, o, e[o]);
|
|
4
|
+
if (N)
|
|
5
|
+
for (var o of N(e))
|
|
6
|
+
et.call(e, o) && P(t, o, e[o]);
|
|
7
7
|
return t;
|
|
8
|
-
},
|
|
9
|
-
/^Mac/i.test(((
|
|
10
|
-
} : HTMLElement,
|
|
8
|
+
}, D = () => typeof window < "u" && typeof window.document < "u" && typeof window.navigator < "u", C = D(), $ = C ? navigator.userAgent : "", L = /android/i.test($), nt = /firefox/i.test($), O = /iPad|iPhone|iPod/.test($), H, it = C && // @ts-expect-error Typescript has not implemented userAgentData yet https://stackoverflow.com/a/71392474
|
|
9
|
+
/^Mac/i.test(((H = navigator.userAgentData) == null ? void 0 : H.platform) || navigator.platform), rt = C && window.CSSStyleSheet && document.adoptedStyleSheets, U = { once: !0, capture: !0, passive: !0 }, at = ":host(:not([hidden])) { display: block }", lt = "outline: 1px dotted; outline: 5px auto Highlight; outline: 5px auto -webkit-focus-ring-color", st = `${L ? "data" : "aria"}-multiselectable`, ut = typeof HTMLElement > "u" ? class {
|
|
10
|
+
} : HTMLElement, a = (t, e, o) => o === void 0 ? t.getAttribute(e) : (o === null ? t.removeAttribute(e) : t.getAttribute(e) !== o && t.setAttribute(e, o), null), R = (t, ...e) => {
|
|
11
11
|
const [o, ...n] = e;
|
|
12
12
|
for (const i of o.split(" ")) t.addEventListener(i, ...n);
|
|
13
|
-
return () =>
|
|
14
|
-
},
|
|
13
|
+
return () => j(t, ...e);
|
|
14
|
+
}, j = (t, ...e) => {
|
|
15
15
|
const [o, ...n] = e;
|
|
16
16
|
for (const i of o.split(" ")) t.removeEventListener(i, ...n);
|
|
17
|
-
},
|
|
17
|
+
}, dt = (t, e) => {
|
|
18
18
|
const o = t.shadowRoot || t.attachShadow({ mode: "open" });
|
|
19
|
-
if (o.querySelector("slot") || o.append(
|
|
20
|
-
if (!
|
|
19
|
+
if (o.querySelector("slot") || o.append(g("slot")), !o.querySelector("style"))
|
|
20
|
+
if (!rt) o.append(g("style", null, e));
|
|
21
21
|
else {
|
|
22
22
|
const n = new CSSStyleSheet();
|
|
23
23
|
n.replaceSync(e), o.adoptedStyleSheets = [n];
|
|
24
24
|
}
|
|
25
25
|
return o;
|
|
26
|
-
},
|
|
26
|
+
}, ct = (t, e, o) => {
|
|
27
27
|
const n = new MutationObserver((r) => {
|
|
28
|
-
if (!
|
|
28
|
+
if (!D() || !t.isConnected) return i();
|
|
29
29
|
e(t, r);
|
|
30
30
|
}), i = Object.assign(() => n.disconnect(), {
|
|
31
31
|
takeRecords: () => n.takeRecords()
|
|
32
32
|
// Expose takeRecords - useful if mutating a attribute that is observed
|
|
33
33
|
});
|
|
34
34
|
return e(t), n.observe(t, o), i;
|
|
35
|
-
},
|
|
35
|
+
}, vt = (t) => {
|
|
36
36
|
var e;
|
|
37
37
|
const o = ((e = t.getRootNode) == null ? void 0 : e.call(t)) || t.ownerDocument;
|
|
38
38
|
return o instanceof Document || o instanceof ShadowRoot ? o : document;
|
|
39
|
-
},
|
|
39
|
+
}, B = (t) => vt(t).activeElement, pt = (t) => {
|
|
40
40
|
var e;
|
|
41
|
-
const o =
|
|
41
|
+
const o = a(t, "aria-label") || "";
|
|
42
42
|
return [
|
|
43
|
-
...(((e =
|
|
43
|
+
...(((e = a(t, "aria-labelledby")) == null ? void 0 : e.split(" ")) || []).map((i) => document.getElementById(i.trim() || "-")),
|
|
44
44
|
// Get all labelledby elements
|
|
45
45
|
...Array.from(t.labels || [])
|
|
46
46
|
// Get all <label> elements
|
|
@@ -48,39 +48,45 @@ var Y = Object.defineProperty, R = Object.getOwnPropertySymbols, z = Object.prot
|
|
|
48
48
|
var l;
|
|
49
49
|
return i || ((l = r?.innerText) == null ? void 0 : l.trim()) || "";
|
|
50
50
|
}, o).trim();
|
|
51
|
-
},
|
|
52
|
-
if (!t || !
|
|
51
|
+
}, mt = (t) => {
|
|
52
|
+
if (!t || !C) return null;
|
|
53
53
|
if (window.uElementsId || (window.uElementsId = {}), !t.id) {
|
|
54
54
|
const e = t.nodeName.toLowerCase();
|
|
55
55
|
window.uElementsId[e] || (window.uElementsId[e] = 1), t.id = `:${e}${window.uElementsId[e]++}`;
|
|
56
56
|
}
|
|
57
57
|
return t.id;
|
|
58
|
-
},
|
|
58
|
+
}, g = (t, e, o) => {
|
|
59
59
|
const n = document.createElement(t);
|
|
60
|
-
if (o && (n.textContent = o), e) for (const [i, r] of Object.entries(e))
|
|
60
|
+
if (o && (n.textContent = o), e) for (const [i, r] of Object.entries(e)) a(n, i, r);
|
|
61
61
|
return n;
|
|
62
|
-
},
|
|
63
|
-
define: (t, e) => !
|
|
64
|
-
},
|
|
62
|
+
}, ft = {
|
|
63
|
+
define: (t, e) => !D() || window.customElements.get(t) || window.customElements.define(t, e)
|
|
64
|
+
}, F = (t, e, o = "") => {
|
|
65
65
|
var n, i;
|
|
66
66
|
const r = { bubbles: !0, composed: !0, data: e, inputType: o }, l = HTMLInputElement.prototype;
|
|
67
67
|
t.dispatchEvent(new InputEvent("beforeinput", r)), (i = (n = Object.getOwnPropertyDescriptor(l, "value")) == null ? void 0 : n.set) == null || i.call(t, e), t.dispatchEvent(new InputEvent("input", r)), t.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
68
|
-
},
|
|
69
|
-
const e =
|
|
70
|
-
|
|
71
|
-
},
|
|
68
|
+
}, k = /* @__PURE__ */ new WeakSet(), W = (t, e) => (e?.type === "pointerdown" && (k.add(t), R(document, "pointerup", () => k.delete(t), U)), k.has(t)), ht = (t, e = "<slot></slot>") => `<template shadowrootmode="open">${e}<style>${t}</style></template>`, _t = (t) => {
|
|
69
|
+
const e = a(t, "form");
|
|
70
|
+
a(t, "form", "#"), setTimeout(bt, 0, t, e);
|
|
71
|
+
}, bt = (t, e) => a(t, "form", e), b = (t) => {
|
|
72
72
|
var e;
|
|
73
73
|
return ((e = t?.textContent) == null ? void 0 : e.trim()) || "";
|
|
74
|
-
},
|
|
75
|
-
clearTimeout(
|
|
76
|
-
},
|
|
74
|
+
}, p, yt = 0, V = 0, I = (t) => {
|
|
75
|
+
clearTimeout(V), p || (p = g("div", { "aria-live": "assertive" }), p.style.overflow = "hidden", p.style.position = "fixed", p.style.whiteSpace = "nowrap", p.style.width = "1px"), p.isConnected || document.body.append(p), t === "" && (p.textContent = ""), t && (p.textContent = `${t}${yt++ % 2 ? " " : ""}`, V = setTimeout(I, !it && nt ? 2e3 : 300, ""));
|
|
76
|
+
}, X = `${at}
|
|
77
77
|
:is(:host(:not([data-multiple])), :host([data-multiple="false"])) [part="items"] { display: none }
|
|
78
|
-
[role="listbox"] { display: contents
|
|
79
|
-
::slotted(button[type="reset"])
|
|
78
|
+
[role="listbox"] { display: inline-flex } /* Can not be "contents" as this confuses VoiceOver */
|
|
79
|
+
::slotted(button[type="reset"]),
|
|
80
|
+
::slotted(button[aria-expanded]),
|
|
81
|
+
::slotted(del) { font: inherit; border: 0; padding: 0; background: none; color: inherit; cursor: pointer; text-decoration: none }
|
|
80
82
|
::slotted(data) { cursor: pointer; pointer-events: none }
|
|
81
83
|
::slotted(data)::after { padding-inline: .5ch; pointer-events: auto }
|
|
82
|
-
::slotted(data)::after
|
|
83
|
-
::slotted(
|
|
84
|
+
::slotted(data)::after,
|
|
85
|
+
::slotted(del:empty)::before,
|
|
86
|
+
::slotted(button[type="reset"]:empty)::before { content: '\\00D7'; content: '\\00D7' / '' }
|
|
87
|
+
::slotted(button[aria-expanded="false"]:empty)::before { content: '\\25BC'; content: '\\25BC' / '' }
|
|
88
|
+
::slotted(button[aria-expanded="true"]:empty)::before { content: '\\25B2'; content: '\\25B2' / '' }
|
|
89
|
+
::slotted(data:focus),::slotted(del:focus),::slotted(button[type="reset"]:focus) { ${lt} }`, Mt = ht(X), A = !1, m = "aria-label", gt = 'button[type="reset"],del', St = "button[aria-expanded]", wt = 'datalist,u-datalist,[role="listbox"]', Et = 'option,u-option,[role="option"]', q = "blur focus click input keydown pointerdown", w = "false", E = {
|
|
84
90
|
added: "Added",
|
|
85
91
|
clear: "Clear input",
|
|
86
92
|
empty: "No selected",
|
|
@@ -90,53 +96,54 @@ var Y = Object.defineProperty, R = Object.getOwnPropertySymbols, z = Object.prot
|
|
|
90
96
|
// Note: Not announced by NVDA
|
|
91
97
|
of: "of",
|
|
92
98
|
remove: "Press to remove",
|
|
93
|
-
removed: "Removed"
|
|
94
|
-
|
|
99
|
+
removed: "Removed",
|
|
100
|
+
toggle: "Options"
|
|
101
|
+
}, xt = class extends ut {
|
|
95
102
|
constructor() {
|
|
96
|
-
super(), this._focusMoved = !1, this._itemSingleVale = "", this._speak = "", this._texts =
|
|
97
|
-
const t =
|
|
98
|
-
this._listbox = t.querySelector('[role="listbox"]') ||
|
|
103
|
+
super(), this._focusMoved = !1, this._itemSingleVale = "", this._speak = "", this._texts = ot({}, E), this._value = "";
|
|
104
|
+
const t = dt(this, X);
|
|
105
|
+
this._listbox = t.querySelector('[role="listbox"]') || g("div"), this._listbox.innerHTML = '<slot name="items"></slot>', a(this._listbox, "aria-orientation", "horizontal"), a(this._listbox, "role", "listbox"), a(this._listbox, "part", "items"), a(this._listbox, "tabindex", "-1"), t.prepend(this._listbox);
|
|
99
106
|
}
|
|
100
107
|
// Locally store value to store value before input-click
|
|
101
108
|
static get observedAttributes() {
|
|
102
|
-
return Object.keys(
|
|
109
|
+
return Object.keys(E).map((t) => `data-sr-${t}`);
|
|
103
110
|
}
|
|
104
111
|
connectedCallback() {
|
|
105
|
-
|
|
106
|
-
attributeFilter: ["id", "value", "role"],
|
|
112
|
+
R(this, q, this, !0), this._umutate = ct(this, Dt, {
|
|
113
|
+
attributeFilter: ["id", "value", "role", "aria-expanded"],
|
|
107
114
|
// Respond to changes in <data> value or id or role of <datalist>
|
|
108
115
|
attributes: !0,
|
|
109
116
|
characterData: !0,
|
|
110
117
|
// Respond to changes in <data> textContent
|
|
111
118
|
childList: !0,
|
|
112
119
|
subtree: !0
|
|
113
|
-
}),
|
|
120
|
+
}), x(this), M(this);
|
|
114
121
|
}
|
|
115
122
|
attributeChangedCallback(t, e, o) {
|
|
116
123
|
const n = t.split("data-sr-")[1];
|
|
117
|
-
|
|
124
|
+
E[n] && (this._texts[n] = o || E[n]), n === "clear" && this.clear && a(this.clear, m, this._texts.clear);
|
|
118
125
|
}
|
|
119
126
|
disconnectedCallback() {
|
|
120
127
|
var t;
|
|
121
|
-
|
|
128
|
+
j(this, q, this, !0), (t = this._umutate) == null || t.call(this), this._umutate = this._clear = this._toggle = void 0, this._control = this._match = this._select = void 0, this._options = this._items = this._list = void 0;
|
|
122
129
|
}
|
|
123
130
|
handleEvent(t) {
|
|
124
|
-
var e, o;
|
|
125
|
-
(e = this.control) != null && e.disabled || (o = this.control) != null && o.readOnly || (t.type === "blur" &&
|
|
131
|
+
var e, o, n;
|
|
132
|
+
(e = this.control) != null && e.disabled || (o = this.control) != null && o.readOnly || (t.type === "blur" && Ct(this), t.type === "click" && Tt(this, t), t.type === "focus" && I(), t.type === "input" && kt(this, t), t.type === "keydown" && Lt(this, t), t.type === "pointerdown" && (A = !!((n = this.list) != null && n.hidden), W(this, t)));
|
|
126
133
|
}
|
|
127
134
|
get multiple() {
|
|
128
135
|
var t;
|
|
129
|
-
return ((t =
|
|
136
|
+
return ((t = a(this, "data-multiple")) != null ? t : w) !== w;
|
|
130
137
|
}
|
|
131
138
|
set multiple(t) {
|
|
132
|
-
|
|
139
|
+
a(this, "data-multiple", t ? "" : null);
|
|
133
140
|
}
|
|
134
141
|
get creatable() {
|
|
135
142
|
var t;
|
|
136
|
-
return ((t =
|
|
143
|
+
return ((t = a(this, "data-creatable")) != null ? t : w) !== w;
|
|
137
144
|
}
|
|
138
145
|
set creatable(t) {
|
|
139
|
-
|
|
146
|
+
a(this, "data-creatable", t ? "" : null);
|
|
140
147
|
}
|
|
141
148
|
get control() {
|
|
142
149
|
var t;
|
|
@@ -144,117 +151,123 @@ var Y = Object.defineProperty, R = Object.getOwnPropertySymbols, z = Object.prot
|
|
|
144
151
|
}
|
|
145
152
|
get list() {
|
|
146
153
|
var t;
|
|
147
|
-
return (t = this._list) != null && t.isConnected || (this._list = this.querySelector(
|
|
154
|
+
return (t = this._list) != null && t.isConnected || (this._list = this.querySelector(wt), this._options = void 0), this._list;
|
|
148
155
|
}
|
|
149
156
|
get clear() {
|
|
150
157
|
var t;
|
|
151
|
-
return (t = this._clear) != null && t.isConnected || (this._clear = this.querySelector(
|
|
158
|
+
return (t = this._clear) != null && t.isConnected || (this._clear = this.querySelector(gt)), this._clear;
|
|
159
|
+
}
|
|
160
|
+
get toggle() {
|
|
161
|
+
var t;
|
|
162
|
+
return (t = this._toggle) != null && t.isConnected || (this._toggle = this.querySelector(St)), this._toggle;
|
|
152
163
|
}
|
|
153
164
|
get items() {
|
|
154
165
|
return this._items || (this._items = this.getElementsByTagName("data")), this._items;
|
|
155
166
|
}
|
|
156
167
|
get options() {
|
|
157
168
|
var t, e, o;
|
|
158
|
-
const n = !this._options && ((e = (t = this.list) == null ? void 0 : t.querySelector(
|
|
169
|
+
const n = !this._options && ((e = (t = this.list) == null ? void 0 : t.querySelector(Et)) == null ? void 0 : e.nodeName);
|
|
159
170
|
return n && (this._options = (o = this.list) == null ? void 0 : o.getElementsByTagName(n)), this._options || this.getElementsByTagName("-");
|
|
160
171
|
}
|
|
161
172
|
get values() {
|
|
162
173
|
return Array.from(this.items, ({ value: t }) => t);
|
|
163
174
|
}
|
|
164
|
-
},
|
|
175
|
+
}, G = (t) => {
|
|
165
176
|
var e;
|
|
166
177
|
const { creatable: o, control: n, options: i, multiple: r } = t, l = ((e = n?.value) == null ? void 0 : e.trim()) || "", u = l.toLowerCase() || null;
|
|
167
|
-
let
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
178
|
+
let s = [...i].find(
|
|
179
|
+
(c) => K(c).trim().toLowerCase() === u
|
|
180
|
+
);
|
|
181
|
+
const d = { bubbles: !0, cancelable: !0, detail: s };
|
|
182
|
+
if (t.dispatchEvent(new CustomEvent("comboboxbeforematch", d)) || (s = [...i].find(Bt)), r) z(t);
|
|
183
|
+
else for (const c of i) J(c, c === s);
|
|
184
|
+
return !s && o && l ? { value: l, label: l } : s && { value: S(s), label: K(s) };
|
|
185
|
+
}, y = (t, e, o = !0) => {
|
|
173
186
|
const { _texts: n, control: i, items: r, multiple: l } = t;
|
|
174
187
|
if (!e)
|
|
175
|
-
return l ?
|
|
176
|
-
const u = [...r].findIndex((
|
|
177
|
-
if (
|
|
188
|
+
return l ? I(n.invalid) : !i?.value && r[0] ? y(t, r[0]) : x(t);
|
|
189
|
+
const u = [...r].findIndex((f) => f.value === e.value), s = r[u], d = s === B(t) && (l && (r[u - 1] || r[u + 1]) || i);
|
|
190
|
+
if (s && !o) return x(t);
|
|
178
191
|
d && d.focus(), t._focusMoved = !!d;
|
|
179
|
-
const c =
|
|
192
|
+
const c = g("data", { value: e.value }, e.label || e.value), v = { bubbles: !0, cancelable: !0, detail: s || c };
|
|
180
193
|
if (t.dispatchEvent(new CustomEvent("comboboxbeforeselect", v))) {
|
|
181
|
-
if (!l) for (const
|
|
182
|
-
|
|
194
|
+
if (!l) for (const f of [...r]) f.remove();
|
|
195
|
+
s ? s.remove() : i?.insertAdjacentElement("beforebegin", c), t.dispatchEvent(new CustomEvent("comboboxafterselect", v));
|
|
183
196
|
}
|
|
184
|
-
},
|
|
185
|
-
const { clientX: o, clientY: n, target: i } = e, { clear: r, control: l, items: u } = t;
|
|
186
|
-
if (l && r?.contains(i))
|
|
187
|
-
return e.preventDefault(),
|
|
188
|
-
for (const
|
|
189
|
-
if (
|
|
190
|
-
const
|
|
191
|
-
if (
|
|
197
|
+
}, Ct = (t) => W(t) || setTimeout(It, 0, t), It = (t) => t.multiple || t.contains(B(t)) || y(t, t._match, !1), Tt = (t, e) => {
|
|
198
|
+
const { clientX: o, clientY: n, target: i } = e, { clear: r, control: l, items: u, toggle: s } = t;
|
|
199
|
+
if (s?.contains(i) && (l?.focus(), A && l?.click()), l && r?.contains(i))
|
|
200
|
+
return e.preventDefault(), F(l, "", "deleteContentBackward"), l.focus(), A || l.click();
|
|
201
|
+
for (const d of u) {
|
|
202
|
+
if (d.contains(i)) return y(t, d);
|
|
203
|
+
const c = d.getBoundingClientRect(), { top: v, right: f, bottom: h, left: T, width: _, height: Q } = c;
|
|
204
|
+
if (_ && Q && n >= v && n <= h && o >= T && o <= f) return d.focus();
|
|
192
205
|
}
|
|
193
206
|
i === t && l?.focus();
|
|
194
|
-
},
|
|
207
|
+
}, kt = (t, e) => {
|
|
195
208
|
var o;
|
|
196
209
|
const { control: n, options: i, multiple: r } = t, l = n?.value || null, u = e instanceof InputEvent ? !e.inputType || e.inputType === "insertReplacementText" : !!n?.value;
|
|
197
210
|
if (u || (t._value = n?.value || ""), u) {
|
|
198
211
|
(o = e.stopImmediatePropagation) == null || o.call(e);
|
|
199
|
-
const
|
|
200
|
-
if (n && (n.value = t._value),
|
|
201
|
-
} else r || (t._match =
|
|
202
|
-
|
|
203
|
-
},
|
|
204
|
-
e.ctrlKey || e.metaKey || e.shiftKey || e.key === "Alt" || (t.control === e.target ?
|
|
205
|
-
},
|
|
212
|
+
const s = [...i].find((d) => S(d) === l);
|
|
213
|
+
if (n && (n.value = t._value), s) return y(t, s, r);
|
|
214
|
+
} else r || (t._match = G(t));
|
|
215
|
+
M(t);
|
|
216
|
+
}, Lt = (t, e) => {
|
|
217
|
+
e.ctrlKey || e.metaKey || e.shiftKey || e.key === "Alt" || (t.control === e.target ? Ot(t, e) : At(t, e));
|
|
218
|
+
}, Ot = (t, e) => {
|
|
206
219
|
var o;
|
|
207
220
|
const { _match: n, clear: i, control: r, items: l, multiple: u } = t;
|
|
208
|
-
(e.key === "ArrowLeft" || e.key === "Backspace") && !r?.selectionEnd && ((o = l[l.length - 1]) == null || o.focus()), e.key === "Enter" && r && (
|
|
209
|
-
},
|
|
221
|
+
(e.key === "ArrowLeft" || e.key === "Backspace") && !r?.selectionEnd && ((o = l[l.length - 1]) == null || o.focus(), e.preventDefault()), e.key === "Enter" && r && (_t(r), y(t, u ? G(t) : n, u)), e.key === "Tab" && !e.shiftKey && i && !i.hidden && (e.preventDefault(), a(i, "aria-hidden", "false"), a(i, "tabindex", "0"), i.focus(), R(i, "blur", () => M(t), U));
|
|
222
|
+
}, At = (t, e) => {
|
|
210
223
|
var o, n, i;
|
|
211
|
-
const { clear: r, control: l, items: u } = t, { key:
|
|
212
|
-
if ((
|
|
224
|
+
const { clear: r, control: l, items: u } = t, { key: s, repeat: d, target: c } = e, v = [...u].indexOf(c);
|
|
225
|
+
if ((s === " " || s === "Enter") && (u[v] || c === r))
|
|
213
226
|
return (o = u[v] || r) == null || o.click(), e.preventDefault();
|
|
214
227
|
if (u[v]) {
|
|
215
|
-
if (
|
|
216
|
-
if (
|
|
217
|
-
if (
|
|
218
|
-
return e.preventDefault(), d ||
|
|
228
|
+
if (s.startsWith("Arrow") && e.preventDefault(), s === "ArrowLeft") return (n = u[v - 1]) == null ? void 0 : n.focus();
|
|
229
|
+
if (s === "ArrowRight") return (i = u[v + 1] || l) == null ? void 0 : i.focus();
|
|
230
|
+
if (s === "Backspace")
|
|
231
|
+
return e.preventDefault(), d || y(t, u[v]);
|
|
219
232
|
l?.focus();
|
|
220
233
|
}
|
|
221
|
-
},
|
|
234
|
+
}, Dt = (t, e) => {
|
|
222
235
|
var o;
|
|
223
236
|
if (!t.control) return;
|
|
224
|
-
const { _texts: n, control: i, items: r, list: l, multiple: u } = t,
|
|
225
|
-
for (const { addedNodes:
|
|
226
|
-
for (const
|
|
227
|
-
for (const
|
|
237
|
+
const { _texts: n, control: i, items: r, list: l, multiple: u, toggle: s } = t, d = [];
|
|
238
|
+
for (const { addedNodes: h, removedNodes: T } of e || []) {
|
|
239
|
+
for (const _ of h) _ instanceof HTMLDataElement && d.unshift(_);
|
|
240
|
+
for (const _ of T) _ instanceof HTMLDataElement && d.push(_);
|
|
228
241
|
}
|
|
229
|
-
const
|
|
230
|
-
if ((u ?
|
|
231
|
-
const
|
|
232
|
-
t._speak = `${n[
|
|
242
|
+
const c = B(t);
|
|
243
|
+
if ((u ? d.length === 1 : d[0] === c) && t.contains(c)) {
|
|
244
|
+
const h = i ? a(i, m) : null;
|
|
245
|
+
t._speak = `${n[d[0].isConnected ? "added" : "removed"]} ${b(d[0])}, `, a(i, m, `${t._speak}${pt(i)}`), t._focusMoved || setTimeout(() => I(t._speak.slice(0, -2))), setTimeout($t, 300, t, h);
|
|
233
246
|
}
|
|
234
247
|
if (!u) {
|
|
235
|
-
const
|
|
236
|
-
|
|
248
|
+
const h = b(r[0]);
|
|
249
|
+
h !== t._itemSingleVale && x(t), t._itemSingleVale = h;
|
|
237
250
|
}
|
|
238
|
-
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
},
|
|
242
|
-
t._speak = "", t.control &&
|
|
243
|
-
},
|
|
251
|
+
Y(t), z(t), Rt(t), s && a(s, "aria-expanded", `${!l?.hidden}`);
|
|
252
|
+
const f = `${r.length ? n.found.replace("%d", `${r.length}`) : n.empty}`;
|
|
253
|
+
a(i, "aria-description", u ? f : null), a(i, "list", mt(l)), a(t._listbox, m, n.items), (o = t._umutate) == null || o.takeRecords();
|
|
254
|
+
}, $t = (t, e) => {
|
|
255
|
+
t._speak = "", t.control && a(t.control, m, e), Y(t);
|
|
256
|
+
}, Y = (t) => {
|
|
244
257
|
const { _texts: e, _speak: o, items: n } = t;
|
|
245
258
|
let i = 0;
|
|
246
259
|
for (const r of n) {
|
|
247
|
-
const l = `${o}${
|
|
248
|
-
|
|
260
|
+
const l = `${o}${b(r)}, ${e.remove}${O ? `, ${++i} ${e.of} ${n.length}` : ""}`;
|
|
261
|
+
a(r, m, l), a(r, "role", "option"), a(r, "slot", "items"), a(r, "tabindex", "-1"), a(r, "value", S(r));
|
|
249
262
|
}
|
|
250
|
-
},
|
|
263
|
+
}, Rt = (t) => {
|
|
251
264
|
var e, o;
|
|
252
265
|
if ((e = t._select) != null && e.isConnected || (t._select = t.querySelector("select")), !t._select) return;
|
|
253
266
|
const { _select: n, items: i, multiple: r } = t, l = [];
|
|
254
267
|
let u = 0;
|
|
255
|
-
|
|
256
|
-
for (const
|
|
257
|
-
const d = n?.options[u++], c =
|
|
268
|
+
a(n, "multiple", r ? "" : null);
|
|
269
|
+
for (const s of i) {
|
|
270
|
+
const d = n?.options[u++], c = b(s), v = S(s);
|
|
258
271
|
d ? Object.assign(d, {
|
|
259
272
|
defaultSelected: !0,
|
|
260
273
|
selected: !0,
|
|
@@ -263,26 +276,34 @@ var Y = Object.defineProperty, R = Object.getOwnPropertySymbols, z = Object.prot
|
|
|
263
276
|
}) : l.push(new Option(c, v, !0, !0));
|
|
264
277
|
}
|
|
265
278
|
if (l.length) n.append(...l);
|
|
266
|
-
else for (const
|
|
279
|
+
else for (const s of [...n.options].slice(u)) s.remove();
|
|
267
280
|
(o = t._umutate) == null || o.takeRecords();
|
|
268
|
-
},
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
}, W = (t) => {
|
|
281
|
+
}, M = (t) => {
|
|
282
|
+
const { clear: e, control: o, toggle: n } = t, i = !o?.value || o?.disabled || o?.readOnly;
|
|
283
|
+
e?.nodeName === "DEL" && a(e, "role", "button"), e && (a(e, m) || a(e, m, t._texts.clear), a(e, "aria-hidden", `${O || L}`), a(e, "hidden", i ? "" : null), a(e, "tabindex", "-1")), n && (a(n, m) || a(n, m, t._texts.toggle), a(n, "aria-hidden", `${O || L}`), a(n, "hidden", i ? null : ""), a(n, "tabindex", "-1"), a(n, "type", "button"));
|
|
284
|
+
}, z = (t) => {
|
|
273
285
|
if (!t.list) return;
|
|
274
286
|
const { _texts: e, list: o, multiple: n, options: i, values: r } = t;
|
|
275
|
-
|
|
276
|
-
for (const l of i) l
|
|
277
|
-
},
|
|
287
|
+
a(o, "data-sr-of", e.of), a(o, st, `${n}`);
|
|
288
|
+
for (const l of i) J(l, r.includes(S(l)));
|
|
289
|
+
}, x = (t) => {
|
|
278
290
|
if (!t.control || t.multiple) return;
|
|
279
|
-
const { control: e, items: o } = t, n =
|
|
280
|
-
n !== e.value &&
|
|
291
|
+
const { control: e, items: o } = t, n = b(o[0]), i = n ? "insertText" : "deleteContentBackward";
|
|
292
|
+
n !== e.value && F(e, n, i);
|
|
293
|
+
}, K = (t) => {
|
|
294
|
+
var e;
|
|
295
|
+
return (e = a(t, "label")) != null ? e : b(t);
|
|
296
|
+
}, S = (t) => {
|
|
297
|
+
var e;
|
|
298
|
+
return (e = a(t, "value")) != null ? e : b(t);
|
|
299
|
+
}, J = (t, e) => a(t, "selected", e ? "" : null), Bt = (t) => {
|
|
300
|
+
var e;
|
|
301
|
+
return (e = t.selected) != null ? e : t.hasAttribute("selected");
|
|
281
302
|
};
|
|
282
|
-
|
|
303
|
+
ft.define("u-combobox", xt);
|
|
283
304
|
export {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
305
|
+
xt as UHTMLComboboxElement,
|
|
306
|
+
Mt as UHTMLComboboxShadowRoot,
|
|
307
|
+
X as UHTMLComboboxStyle
|
|
287
308
|
};
|
|
288
309
|
//# sourceMappingURL=u-combobox.js.map
|