@mattilsynet/design 1.3.9 → 1.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/mtds/analytics/analytics.js +6 -6
- package/mtds/analytics/analytics.js.map +1 -1
- package/mtds/app/app-observer.js +1 -1
- package/mtds/app/app-toggle.js +26 -10
- package/mtds/app/app-toggle.js.map +1 -1
- package/mtds/app/app-toggle2.js +10 -26
- package/mtds/app/app-toggle2.js.map +1 -1
- package/mtds/app/app.js +1 -1
- package/mtds/external/@u-elements/u-combobox/dist/u-combobox.js +95 -98
- package/mtds/external/@u-elements/u-combobox/dist/u-combobox.js.map +1 -1
- package/mtds/external/@u-elements/u-datalist/dist/u-datalist.js +42 -40
- package/mtds/external/@u-elements/u-datalist/dist/u-datalist.js.map +1 -1
- package/mtds/field/field.d.ts +47 -7
- package/mtds/field/field.js +94 -69
- package/mtds/field/field.js.map +1 -1
- package/mtds/field/field.stories.d.ts +35 -2
- package/mtds/index.iife.js +7 -7
- package/mtds/layout/layout.d.ts +2 -1
- package/mtds/layout/layout.js.map +1 -1
- package/mtds/package.json.js +1 -1
- package/mtds/styles.css +1 -1
- package/mtds/styles.json +40 -40
- package/mtds/styles.module.css.js +41 -41
- package/mtds/utils.js +33 -33
- package/mtds/utils.js.map +1 -1
- package/package.json +13 -13
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { IS_BROWSER as
|
|
1
|
+
import { IS_BROWSER as r } from "../utils.js";
|
|
2
2
|
const s = "mattilsynet.matomo.cloud";
|
|
3
3
|
let a = !0;
|
|
4
4
|
function d(o, n = {}) {
|
|
5
|
-
if (
|
|
5
|
+
if (r) {
|
|
6
6
|
if (window._paq || (window._paq = [], window._paq.push(["HeatmapSessionRecording::disable"]), window._paq.push(["enableLinkTracking"]), window._paq.push(["setTrackerUrl", `https://${s}/matomo.php`]), document.querySelector('script[src*="matomo.js"]') || document.head.append(
|
|
7
7
|
Object.assign(document.createElement("script"), {
|
|
8
8
|
async: !0,
|
|
9
9
|
src: `https://cdn.matomo.cloud/${s}/matomo.js`
|
|
10
10
|
})
|
|
11
11
|
)), o === "init") {
|
|
12
|
-
const { matomoId: e, enabled: t
|
|
13
|
-
a = t, window._paq.push(["setSiteId", e]);
|
|
12
|
+
const { matomoId: e, enabled: t } = n;
|
|
13
|
+
a = t ?? window.location.hostname === "localhost", window._paq.push(["setSiteId", e]);
|
|
14
14
|
}
|
|
15
15
|
if (a === "debug") return console.info(`Analytics: "${o}"`, n);
|
|
16
|
-
if (
|
|
16
|
+
if (a !== !1)
|
|
17
17
|
if (o === "pageview") {
|
|
18
18
|
const { url: e, title: t } = n;
|
|
19
19
|
window._paq.push(["setCustomUrl", e || location.href]), window._paq.push(["setDocumentTitle", t || document.title]), window._paq.push(["trackPageView"]);
|
|
20
20
|
} else if (o === "event") {
|
|
21
21
|
const { category: e, action: t, name: i, value: c } = n, p = ["trackEvent", e, t, i, c];
|
|
22
|
-
window._paq.push(p.filter((
|
|
22
|
+
window._paq.push(p.filter((l) => l !== void 0));
|
|
23
23
|
} else if (o === "search") {
|
|
24
24
|
const {
|
|
25
25
|
query: e,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analytics.js","sources":["../../designsystem/analytics/analytics.ts"],"sourcesContent":["import { IS_BROWSER } from \"../utils\";\n\nconst MATOMO = \"mattilsynet.matomo.cloud\";\nlet ENABLED: AnalyticsActions[\"init\"][\"enabled\"] = true;\n\ntype Matomo = (string | number | boolean)[];\ndeclare global {\n\tinterface Window {\n\t\t_paq?: Matomo[];\n\t\t_mtm?: Record<string, string | number>[];\n\t}\n}\n\n// window._paq = window._paq || [];\n// window._mtm = window._mtm || [];\n\n// window._paq.push([\"setCustomUrl\", `${document.location.href}&eirik`]);\n// window._paq.push([\"setDocumentTitle\", \"Eirik 3\"]);\n// window._mtm.push({\n// \tevent: \"mtm.Start\",\n// \t\"mtm.startTime\": new Date().getTime(),\n// \tcustomTitle: \"Eirik 1\",\n// \tcustomUrl: `${document.location.href}&eirik`,\n// });\n\n// window._mtm.push({\n// \tevent: \"mtm.PageView\",\n// \tcustomTitle: \"Eirik 2\",\n// \tcustomUrl: `${document.location.href}&eirik`,\n// });\n\n// const containerId = \"A9utKk3O\";\n\n// document.head.append(\n// \tObject.assign(document.createElement(\"script\"), {\n// \t\tsrc: `https://cdn.matomo.cloud/mattilsynet.matomo.cloud/container_${containerId}.js`,\n// \t\tasync: true,\n// \t\tonload: () => console.log(window._paq),\n// \t}),\n// );\n\nexport type AnalyticsActions = {\n\tinit: {\n\t\tmatomoId: number | string;\n\t\tenabled?: boolean | \"debug\";\n\t};\n\tpageview: {\n\t\turl?: string;\n\t\ttitle?: string;\n\t};\n\tevent: {\n\t\tcategory: string;\n\t\taction: string;\n\t\tname?: string;\n\t\tvalue?: number;\n\t};\n\tsearch: {\n\t\tquery: string;\n\t\tcategory?: string;\n\t\tresults?: number;\n\t};\n\tmatomo: Matomo;\n};\n\nexport function analytics<Action extends keyof AnalyticsActions>(\n\taction: Action,\n\targs = {} as AnalyticsActions[Action],\n) {\n\tif (!IS_BROWSER) return;\n\tif (!window._paq) {\n\t\twindow._paq = [];\n\t\twindow._paq.push([\"HeatmapSessionRecording::disable\"]); // Disable heatmaps by default as this require cookies\n\t\twindow._paq.push([\"enableLinkTracking\"]);\n\t\twindow._paq.push([\"setTrackerUrl\", `https://${MATOMO}/matomo.php`]);\n\t\tdocument.querySelector('script[src*=\"matomo.js\"]') ||\n\t\t\tdocument.head.append(\n\t\t\t\tObject.assign(document.createElement(\"script\"), {\n\t\t\t\t\tasync: true,\n\t\t\t\t\tsrc: `https://cdn.matomo.cloud/${MATOMO}/matomo.js`,\n\t\t\t\t}),\n\t\t\t);\n\t}\n\tif (action === \"init\") {\n\t\tconst { matomoId, enabled
|
|
1
|
+
{"version":3,"file":"analytics.js","sources":["../../designsystem/analytics/analytics.ts"],"sourcesContent":["import { IS_BROWSER } from \"../utils\";\n\nconst MATOMO = \"mattilsynet.matomo.cloud\";\nlet ENABLED: AnalyticsActions[\"init\"][\"enabled\"] = true;\n\ntype Matomo = (string | number | boolean)[];\ndeclare global {\n\tinterface Window {\n\t\t_paq?: Matomo[];\n\t\t_mtm?: Record<string, string | number>[];\n\t}\n}\n\n// window._paq = window._paq || [];\n// window._mtm = window._mtm || [];\n\n// window._paq.push([\"setCustomUrl\", `${document.location.href}&eirik`]);\n// window._paq.push([\"setDocumentTitle\", \"Eirik 3\"]);\n// window._mtm.push({\n// \tevent: \"mtm.Start\",\n// \t\"mtm.startTime\": new Date().getTime(),\n// \tcustomTitle: \"Eirik 1\",\n// \tcustomUrl: `${document.location.href}&eirik`,\n// });\n\n// window._mtm.push({\n// \tevent: \"mtm.PageView\",\n// \tcustomTitle: \"Eirik 2\",\n// \tcustomUrl: `${document.location.href}&eirik`,\n// });\n\n// const containerId = \"A9utKk3O\";\n\n// document.head.append(\n// \tObject.assign(document.createElement(\"script\"), {\n// \t\tsrc: `https://cdn.matomo.cloud/mattilsynet.matomo.cloud/container_${containerId}.js`,\n// \t\tasync: true,\n// \t\tonload: () => console.log(window._paq),\n// \t}),\n// );\n\nexport type AnalyticsActions = {\n\tinit: {\n\t\tmatomoId: number | string;\n\t\tenabled?: boolean | \"debug\";\n\t};\n\tpageview: {\n\t\turl?: string;\n\t\ttitle?: string;\n\t};\n\tevent: {\n\t\tcategory: string;\n\t\taction: string;\n\t\tname?: string;\n\t\tvalue?: number;\n\t};\n\tsearch: {\n\t\tquery: string;\n\t\tcategory?: string;\n\t\tresults?: number;\n\t};\n\tmatomo: Matomo;\n};\n\nexport function analytics<Action extends keyof AnalyticsActions>(\n\taction: Action,\n\targs = {} as AnalyticsActions[Action],\n) {\n\tif (!IS_BROWSER) return;\n\tif (!window._paq) {\n\t\twindow._paq = [];\n\t\twindow._paq.push([\"HeatmapSessionRecording::disable\"]); // Disable heatmaps by default as this require cookies\n\t\twindow._paq.push([\"enableLinkTracking\"]);\n\t\twindow._paq.push([\"setTrackerUrl\", `https://${MATOMO}/matomo.php`]);\n\t\tdocument.querySelector('script[src*=\"matomo.js\"]') ||\n\t\t\tdocument.head.append(\n\t\t\t\tObject.assign(document.createElement(\"script\"), {\n\t\t\t\t\tasync: true,\n\t\t\t\t\tsrc: `https://cdn.matomo.cloud/${MATOMO}/matomo.js`,\n\t\t\t\t}),\n\t\t\t);\n\t}\n\tif (action === \"init\") {\n\t\tconst { matomoId, enabled } = args as AnalyticsActions[\"init\"];\n\t\tENABLED = enabled ?? window.location.hostname === \"localhost\";\n\t\twindow._paq.push([\"setSiteId\", matomoId]);\n\t}\n\n\tif (ENABLED === \"debug\") return console.info(`Analytics: \"${action}\"`, args);\n\tif (ENABLED === false) return;\n\n\tif (action === \"pageview\") {\n\t\tconst { url, title } = args as AnalyticsActions[\"pageview\"];\n\t\twindow._paq.push([\"setCustomUrl\", url || location.href]);\n\t\twindow._paq.push([\"setDocumentTitle\", title || document.title]);\n\t\twindow._paq.push([\"trackPageView\"]);\n\t} else if (action === \"event\") {\n\t\tconst { category, action, name, value } = args as AnalyticsActions[\"event\"];\n\t\tconst event = [\"trackEvent\", category, action, name, value];\n\t\twindow._paq.push(event.filter((v) => v !== undefined));\n\t} else if (action === \"search\") {\n\t\tconst {\n\t\t\tquery,\n\t\t\tcategory = false,\n\t\t\tresults = false,\n\t\t} = args as AnalyticsActions[\"search\"];\n\t\twindow._paq.push([\"trackSiteSearch\", query, category, results]);\n\t} else if (action === \"matomo\") {\n\t\twindow._paq.push(args as AnalyticsActions[\"matomo\"]);\n\t}\n}\n"],"names":["MATOMO","ENABLED","analytics","action","args","IS_BROWSER","matomoId","enabled","url","title","category","name","value","event","v","query","results"],"mappings":";AAEA,MAAMA,IAAS;AACf,IAAIC,IAA+C;AA6D5C,SAASC,EACfC,GACAC,IAAO,IACN;AACD,MAAKC,GAcL;AAAA,QAbK,OAAO,SACX,OAAO,OAAO,CAAC,GACf,OAAO,KAAK,KAAK,CAAC,kCAAkC,CAAC,GACrD,OAAO,KAAK,KAAK,CAAC,oBAAoB,CAAC,GACvC,OAAO,KAAK,KAAK,CAAC,iBAAiB,WAAWL,CAAM,aAAa,CAAC,GAClE,SAAS,cAAc,0BAA0B,KAChD,SAAS,KAAK;AAAA,MACb,OAAO,OAAO,SAAS,cAAc,QAAQ,GAAG;AAAA,QAC/C,OAAO;AAAA,QACP,KAAK,4BAA4BA,CAAM;AAAA,MACvC,CAAA;AAAA,IACF,IAEEG,MAAW,QAAQ;AAChB,YAAA,EAAE,UAAAG,GAAU,SAAAC,EAAA,IAAYH;AACpB,MAAAH,IAAAM,KAAW,OAAO,SAAS,aAAa,aAClD,OAAO,KAAK,KAAK,CAAC,aAAaD,CAAQ,CAAC;AAAA,IAAA;AAGrC,QAAAL,MAAY,QAAgB,QAAA,QAAQ,KAAK,eAAeE,CAAM,KAAKC,CAAI;AAC3E,QAAIH,MAAY;AAEhB,UAAIE,MAAW,YAAY;AACpB,cAAA,EAAE,KAAAK,GAAK,OAAAC,EAAA,IAAUL;AACvB,eAAO,KAAK,KAAK,CAAC,gBAAgBI,KAAO,SAAS,IAAI,CAAC,GACvD,OAAO,KAAK,KAAK,CAAC,oBAAoBC,KAAS,SAAS,KAAK,CAAC,GAC9D,OAAO,KAAK,KAAK,CAAC,eAAe,CAAC;AAAA,MAAA,WACxBN,MAAW,SAAS;AAC9B,cAAM,EAAE,UAAAO,GAAU,QAAAP,GAAQ,MAAAQ,GAAM,OAAAC,MAAUR,GACpCS,IAAQ,CAAC,cAAcH,GAAUP,GAAQQ,GAAMC,CAAK;AACnD,eAAA,KAAK,KAAKC,EAAM,OAAO,CAACC,MAAMA,MAAM,MAAS,CAAC;AAAA,MAAA,WAC3CX,MAAW,UAAU;AACzB,cAAA;AAAA,UACL,OAAAY;AAAA,UACA,UAAAL,IAAW;AAAA,UACX,SAAAM,IAAU;AAAA,QAAA,IACPZ;AACJ,eAAO,KAAK,KAAK,CAAC,mBAAmBW,GAAOL,GAAUM,CAAO,CAAC;AAAA,MAAA,MAC/D,CAAWb,MAAW,YACd,OAAA,KAAK,KAAKC,CAAkC;AAAA;AAErD;"}
|
package/mtds/app/app-observer.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import m from "../styles.module.css.js";
|
|
2
2
|
import { onLoaded as T, onMutation as w, on as r, QUICK_EVENT as p, debounce as _ } from "../utils.js";
|
|
3
|
-
import "./app-
|
|
3
|
+
import "./app-toggle2.js";
|
|
4
4
|
const f = m.app.split(" ")[0], P = m.sticky.split(" ")[0], E = '[data-command="toggle-app-expanded"]', g = `.${f} > dialog,.${f} dialog ~ main`, S = (e) => {
|
|
5
5
|
document.startViewTransition ? document.startViewTransition(e) : e();
|
|
6
6
|
}, h = (e) => (
|
package/mtds/app/app-toggle.js
CHANGED
|
@@ -1,11 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
const t = `if (
|
|
2
|
+
typeof window !== "undefined" &&
|
|
3
|
+
window.CSSStyleSheet &&
|
|
4
|
+
document.adoptedStyleSheets
|
|
5
|
+
)
|
|
6
|
+
(() => {
|
|
7
|
+
const key = "--mtds-app-expanded";
|
|
8
|
+
const sheet = new CSSStyleSheet();
|
|
9
|
+
const prev = () => !window.localStorage.getItem(key)?.includes("false");
|
|
10
|
+
|
|
11
|
+
document.adoptedStyleSheets.push(sheet);
|
|
12
|
+
window.mtdsToggleAppExpanded = (force) => {
|
|
13
|
+
try {
|
|
14
|
+
const next = force ?? !prev();
|
|
15
|
+
sheet.replaceSync?.(\`:root { \${key}: var(\${key}--\${next})}\`);
|
|
16
|
+
window.localStorage.setItem(key, next);
|
|
17
|
+
} catch (_err) {} // localStorage is full or replaceSync is not supported
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// Set and store initial state
|
|
21
|
+
window.mtdsToggleAppExpanded(prev());
|
|
22
|
+
})();
|
|
23
|
+
`;
|
|
24
|
+
export {
|
|
25
|
+
t as default
|
|
26
|
+
};
|
|
11
27
|
//# sourceMappingURL=app-toggle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-toggle.js","sources":["../../designsystem/app/app-toggle.js"],"sourcesContent":["if (
|
|
1
|
+
{"version":3,"file":"app-toggle.js","sources":["../../designsystem/app/app-toggle.js?raw"],"sourcesContent":["export default \"if (\\n\\ttypeof window !== \\\"undefined\\\" &&\\n\\twindow.CSSStyleSheet &&\\n\\tdocument.adoptedStyleSheets\\n)\\n\\t(() => {\\n\\t\\tconst key = \\\"--mtds-app-expanded\\\";\\n\\t\\tconst sheet = new CSSStyleSheet();\\n\\t\\tconst prev = () => !window.localStorage.getItem(key)?.includes(\\\"false\\\");\\n\\n\\t\\tdocument.adoptedStyleSheets.push(sheet);\\n\\t\\twindow.mtdsToggleAppExpanded = (force) => {\\n\\t\\t\\ttry {\\n\\t\\t\\t\\tconst next = force ?? !prev();\\n\\t\\t\\t\\tsheet.replaceSync?.(`:root { ${key}: var(${key}--${next})}`);\\n\\t\\t\\t\\twindow.localStorage.setItem(key, next);\\n\\t\\t\\t} catch (_err) {} // localStorage is full or replaceSync is not supported\\n\\t\\t};\\n\\n\\t\\t// Set and store initial state\\n\\t\\twindow.mtdsToggleAppExpanded(prev());\\n\\t})();\\n\""],"names":["script"],"mappings":"AAAA,MAAeA,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;"}
|
package/mtds/app/app-toggle2.js
CHANGED
|
@@ -1,27 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
)
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
document.adoptedStyleSheets.push(sheet);
|
|
12
|
-
window.mtdsToggleAppExpanded = (force) => {
|
|
13
|
-
try {
|
|
14
|
-
const next = force ?? !prev();
|
|
15
|
-
sheet.replaceSync?.(\`:root { \${key}: var(\${key}--\${next})}\`);
|
|
16
|
-
window.localStorage.setItem(key, next);
|
|
17
|
-
} catch (_err) {} // localStorage is full or replaceSync is not supported
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
// Set and store initial state
|
|
21
|
-
window.mtdsToggleAppExpanded(prev());
|
|
22
|
-
})();
|
|
23
|
-
`;
|
|
24
|
-
export {
|
|
25
|
-
t as default
|
|
26
|
-
};
|
|
1
|
+
typeof window < "u" && window.CSSStyleSheet && document.adoptedStyleSheets && (() => {
|
|
2
|
+
const e = "--mtds-app-expanded", d = new CSSStyleSheet(), o = () => !window.localStorage.getItem(e)?.includes("false");
|
|
3
|
+
document.adoptedStyleSheets.push(d), window.mtdsToggleAppExpanded = (n) => {
|
|
4
|
+
try {
|
|
5
|
+
const t = n ?? !o();
|
|
6
|
+
d.replaceSync?.(`:root { ${e}: var(${e}--${t})}`), window.localStorage.setItem(e, t);
|
|
7
|
+
} catch {
|
|
8
|
+
}
|
|
9
|
+
}, window.mtdsToggleAppExpanded(o());
|
|
10
|
+
})();
|
|
27
11
|
//# sourceMappingURL=app-toggle2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-toggle2.js","sources":["../../designsystem/app/app-toggle.js
|
|
1
|
+
{"version":3,"file":"app-toggle2.js","sources":["../../designsystem/app/app-toggle.js"],"sourcesContent":["if (\n\ttypeof window !== \"undefined\" &&\n\twindow.CSSStyleSheet &&\n\tdocument.adoptedStyleSheets\n)\n\t(() => {\n\t\tconst key = \"--mtds-app-expanded\";\n\t\tconst sheet = new CSSStyleSheet();\n\t\tconst prev = () => !window.localStorage.getItem(key)?.includes(\"false\");\n\n\t\tdocument.adoptedStyleSheets.push(sheet);\n\t\twindow.mtdsToggleAppExpanded = (force) => {\n\t\t\ttry {\n\t\t\t\tconst next = force ?? !prev();\n\t\t\t\tsheet.replaceSync?.(`:root { ${key}: var(${key}--${next})}`);\n\t\t\t\twindow.localStorage.setItem(key, next);\n\t\t\t} catch (_err) {} // localStorage is full or replaceSync is not supported\n\t\t};\n\n\t\t// Set and store initial state\n\t\twindow.mtdsToggleAppExpanded(prev());\n\t})();\n"],"names":["key","sheet","prev","force","next"],"mappings":"AACC,OAAO,SAAW,OAClB,OAAO,iBACP,SAAS,uBAER,MAAM;AACN,QAAMA,IAAM,uBACNC,IAAQ,IAAI,cAAe,GAC3BC,IAAO,MAAM,CAAC,OAAO,aAAa,QAAQF,CAAG,GAAG,SAAS,OAAO;AAEtE,WAAS,mBAAmB,KAAKC,CAAK,GACtC,OAAO,wBAAwB,CAACE,MAAU;AACzC,QAAI;AACH,YAAMC,IAAOD,KAAS,CAACD,EAAM;AAC7B,MAAAD,EAAM,cAAc,WAAWD,CAAG,SAASA,CAAG,KAAKI,CAAI,IAAI,GAC3D,OAAO,aAAa,QAAQJ,GAAKI,CAAI;AAAA,IACzC,QAAkB;AAAA,IAAE;AAAA,EACjB,GAGD,OAAO,sBAAsBF,GAAM;AACrC,GAAK;"}
|
package/mtds/app/app.js
CHANGED
|
@@ -32,7 +32,7 @@ import "../togglegroup/togglegroup.js";
|
|
|
32
32
|
import "../typography/typography.js";
|
|
33
33
|
import "../validation/validation.js";
|
|
34
34
|
import a from "../styles.module.css.js";
|
|
35
|
-
import d from "./app-
|
|
35
|
+
import d from "./app-toggle.js";
|
|
36
36
|
const f = p(function({ as: t, className: r, ...m }, n) {
|
|
37
37
|
return /* @__PURE__ */ o(t || "div", { className: e(a.app, r), ref: n, ...m });
|
|
38
38
|
}), u = p(function({ as: t, className: r, ...m }, n) {
|
|
@@ -14,8 +14,8 @@ function s(t, e, o) {
|
|
|
14
14
|
return o === void 0 ? t.getAttribute(e) : (o === null ? t.removeAttribute(e) : t.getAttribute(e) !== o && t.setAttribute(e, o), null);
|
|
15
15
|
}
|
|
16
16
|
var q = (t, e, o) => {
|
|
17
|
-
for (const
|
|
18
|
-
o[0] =
|
|
17
|
+
for (const n of o[0].split(","))
|
|
18
|
+
o[0] = n, Element.prototype[`${t}EventListener`].apply(e, o);
|
|
19
19
|
}, O = (t, ...e) => q("add", t, e), it = (t, ...e) => q("remove", t, e), x = /* @__PURE__ */ new WeakMap(), L = (t, e) => {
|
|
20
20
|
if (e === void 0) return x.get(t);
|
|
21
21
|
try {
|
|
@@ -24,30 +24,30 @@ var q = (t, e, o) => {
|
|
|
24
24
|
}
|
|
25
25
|
if (e) {
|
|
26
26
|
const o = new MutationObserver(
|
|
27
|
-
(
|
|
27
|
+
(n) => t.handleEvent({ type: "mutation", detail: n })
|
|
28
28
|
);
|
|
29
29
|
o.observe(t, e), x.set(t, o);
|
|
30
30
|
}
|
|
31
31
|
}, nt = (t) => {
|
|
32
32
|
const e = "key" in t && (t.key === " " || t.key === "Enter");
|
|
33
33
|
return e && t.preventDefault(), e && t.target instanceof HTMLElement && t.target.click(), e;
|
|
34
|
-
},
|
|
34
|
+
}, at = (t) => {
|
|
35
35
|
var e;
|
|
36
36
|
const o = ((e = t.getRootNode) == null ? void 0 : e.call(t)) || t.ownerDocument;
|
|
37
37
|
return o instanceof Document || o instanceof ShadowRoot ? o : document;
|
|
38
|
-
},
|
|
39
|
-
const
|
|
40
|
-
if (e && (
|
|
41
|
-
return
|
|
38
|
+
}, rt = 0, lt = (t) => t ? (t.id || (t.id = `:${t.nodeName.toLowerCase()}${(++rt).toString(32)}`), t.id) : "", I = (t, e, o) => {
|
|
39
|
+
const n = document.createElement(t);
|
|
40
|
+
if (e && (n.textContent = e), o) for (const [i, a] of Object.entries(o)) s(n, i, a);
|
|
41
|
+
return n;
|
|
42
42
|
}, st = {
|
|
43
43
|
define: (t, e) => !w || window.customElements.get(t) || window.customElements.define(t, e)
|
|
44
44
|
}, y, ut = 0, M = (t) => {
|
|
45
|
-
y || (y =
|
|
45
|
+
y || (y = I("div"), y.style.cssText = "position:fixed;overflow:hidden;width:1px;white-space:nowrap", s(y, "aria-live", "assertive")), y.isConnected || document.body.append(y), t && (y.textContent = `${t}${ut++ % 2 ? " " : ""}`);
|
|
46
46
|
}, K = (t, e, o = "") => {
|
|
47
|
-
var
|
|
48
|
-
const
|
|
49
|
-
t.dispatchEvent(new InputEvent("beforeinput",
|
|
50
|
-
}, A = !1, N = (t) => (t?.type === "mouseup" && (A = !1), t?.type === "mousedown" && (A = !0, O(document, "mouseup", N, { once: !0 })), A), j = "beforeinput,blur,focus,click,input,keydown,mousedown", U = { once: !0, passive: !0 }, ct = Z && !V, dt = V || tt, k = "false",
|
|
47
|
+
var n, i;
|
|
48
|
+
const a = { bubbles: !0, composed: !0, data: e, inputType: o }, r = HTMLInputElement.prototype;
|
|
49
|
+
t.dispatchEvent(new InputEvent("beforeinput", a)), (i = (n = Object.getOwnPropertyDescriptor(r, "value")) == null ? void 0 : n.set) == null || i.call(t, e), t.dispatchEvent(new InputEvent("input", a)), t.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
50
|
+
}, A = !1, N = (t) => (t?.type === "mouseup" && (A = !1), t?.type === "mousedown" && (A = !0, O(document, "mouseup", N, { once: !0 })), A), j = "beforeinput,blur,focus,click,input,keydown,mousedown", U = { once: !0, passive: !0 }, ct = Z && !V, dt = V || tt, k = "false", C = {
|
|
51
51
|
added: "Added",
|
|
52
52
|
empty: "No selected",
|
|
53
53
|
found: "Navigate left to find %d selected",
|
|
@@ -55,12 +55,12 @@ var q = (t, e, o) => {
|
|
|
55
55
|
of: "of",
|
|
56
56
|
remove: "Press to remove",
|
|
57
57
|
removed: "Removed"
|
|
58
|
-
},
|
|
58
|
+
}, pt = class extends ot {
|
|
59
59
|
constructor() {
|
|
60
|
-
super(), this.
|
|
61
|
-
|
|
60
|
+
super(), this._item = "", this._speak = "", this._texts = Q({}, C), this._value = "", this.attachShadow({ mode: "open" }).append(
|
|
61
|
+
I("slot"),
|
|
62
62
|
// Content slot
|
|
63
|
-
|
|
63
|
+
I(
|
|
64
64
|
"style",
|
|
65
65
|
`:host(:not([hidden])) { display: block; cursor: pointer; -webkit-tap-highlight-color: rgba(0, 0, 0, 0) } /* Must be display block in Safari to allow focus inside */
|
|
66
66
|
:host(:not([data-multiple])) ::slotted(data),
|
|
@@ -76,29 +76,29 @@ var q = (t, e, o) => {
|
|
|
76
76
|
// Locally store value to store value before input-click
|
|
77
77
|
// Using ES2015 syntax for backwards compatibility
|
|
78
78
|
static get observedAttributes() {
|
|
79
|
-
return Object.keys(
|
|
79
|
+
return Object.keys(C).map((t) => `data-sr-${t}`);
|
|
80
80
|
}
|
|
81
81
|
connectedCallback() {
|
|
82
|
-
this._root =
|
|
83
|
-
attributeFilter: ["value"],
|
|
84
|
-
// Respond to changes in <data> value
|
|
82
|
+
this._root = at(this), O(this, j, this, !0), L(this, {
|
|
83
|
+
attributeFilter: ["value", "id"],
|
|
84
|
+
// Respond to changes in <data> value or change of id for <datalist> to reconnect with input
|
|
85
85
|
attributes: !0,
|
|
86
86
|
characterData: !0,
|
|
87
87
|
// Respond to changes in <data> textContent
|
|
88
88
|
childList: !0,
|
|
89
89
|
subtree: !0
|
|
90
|
-
}), setTimeout(
|
|
90
|
+
}), setTimeout(T, 0, this), setTimeout(S, 0, this);
|
|
91
91
|
}
|
|
92
92
|
attributeChangedCallback(t, e, o) {
|
|
93
|
-
const
|
|
94
|
-
|
|
93
|
+
const n = t.split("data-sr-")[1];
|
|
94
|
+
C[n] && (this._texts[n] = o || C[n]);
|
|
95
95
|
}
|
|
96
96
|
disconnectedCallback() {
|
|
97
97
|
L(this, !1), it(this, j, this, !0), this._items = this._clear = this._focus = this._control = void 0, this._list = this._options = this._root = void 0;
|
|
98
98
|
}
|
|
99
99
|
handleEvent(t) {
|
|
100
100
|
const e = t.target;
|
|
101
|
-
t.type === "beforeinput" && (this._value = e?.value || ""), t.type === "blur" && ft(this), t.type === "click" && ht(this, t), t.type === "focus" &&
|
|
101
|
+
t.type === "beforeinput" && (this._value = e?.value || ""), t.type === "blur" && ft(this), t.type === "click" && ht(this, t), t.type === "focus" && vt(this, t), t.type === "input" && _t(this, t), t.type === "keydown" && bt(this, t), t.type === "mousedown" && N(t), t.type === "mutation" && T(this, t);
|
|
102
102
|
}
|
|
103
103
|
get multiple() {
|
|
104
104
|
var t;
|
|
@@ -143,114 +143,111 @@ var q = (t, e, o) => {
|
|
|
143
143
|
}, b = (t) => {
|
|
144
144
|
var e;
|
|
145
145
|
return ((e = t?.textContent) == null ? void 0 : e.trim()) || "";
|
|
146
|
-
}, D = (t) => t instanceof HTMLDataElement,
|
|
147
|
-
var o,
|
|
148
|
-
const { _focus:
|
|
149
|
-
let
|
|
150
|
-
const
|
|
146
|
+
}, D = (t) => t instanceof HTMLDataElement, T = (t, e) => {
|
|
147
|
+
var o, n;
|
|
148
|
+
const { _focus: i, _texts: a, items: r, control: l, list: d, multiple: u } = t;
|
|
149
|
+
let p = `${b((o = l?.labels) == null ? void 0 : o[0])}, ${u ? r.length ? a.found.replace("%d", `${r.length}`) : a.empty : ""}`;
|
|
150
|
+
const c = [];
|
|
151
151
|
for (const { addedNodes: m, removedNodes: h } of e?.detail || []) {
|
|
152
|
-
for (const
|
|
153
|
-
for (const
|
|
154
|
-
}
|
|
155
|
-
const g =
|
|
156
|
-
if (
|
|
157
|
-
const m = s(l, "inputmode"), h = D(
|
|
158
|
-
t._speak = `${
|
|
159
|
-
var
|
|
160
|
-
s(l, "aria-expanded", "true"), s(l, "inputmode", m), (
|
|
152
|
+
for (const v of m) D(v) && c.unshift(v);
|
|
153
|
+
for (const v of h) D(v) && c.push(v);
|
|
154
|
+
}
|
|
155
|
+
const g = u ? c.length === 1 : c[0] === i;
|
|
156
|
+
if (i && l && g) {
|
|
157
|
+
const m = s(l, "inputmode"), h = D(i) ? l : i;
|
|
158
|
+
t._speak = `${a[c[0].isConnected ? "added" : "removed"]} ${b(c[0])}, `, (dt || i === l) && M(t._speak), l !== h && (s(l, "aria-expanded", null), s(l, "inputmode", "none"), p = " ", l.focus()), setTimeout(() => {
|
|
159
|
+
var v;
|
|
160
|
+
s(l, "aria-expanded", "true"), s(l, "inputmode", m), (v = h?.focus) == null || v.call(h), t._speak = "", ct ? O(t, "blur", () => T(t), U) : setTimeout(T, 100, t);
|
|
161
161
|
}, 100);
|
|
162
162
|
}
|
|
163
163
|
let f = 0;
|
|
164
164
|
const _ = t.querySelector("select");
|
|
165
|
-
for (const m of
|
|
166
|
-
const h = _?.options[f],
|
|
167
|
-
s(m, "role", "button"), s(m, "value", $), s(m, "tabindex", "-1"), s(m, "aria-label", Y), h ? Object.assign(h, { textContent:
|
|
165
|
+
for (const m of r) {
|
|
166
|
+
const h = _?.options[f], v = b(m), $ = m.value || v, Y = `${t._speak}${v}, ${a.remove}, ${++f} ${a.of} ${r.length}`;
|
|
167
|
+
s(m, "role", "button"), s(m, "value", $), s(m, "tabindex", "-1"), s(m, "aria-label", Y), h ? Object.assign(h, { textContent: v, value: $ }) : _?.appendChild(new Option(v, $, !0, !0));
|
|
168
168
|
}
|
|
169
|
-
_ && s(_, "multiple",
|
|
169
|
+
_ && s(_, "multiple", u ? "" : null);
|
|
170
170
|
for (const m of [..._?.options || []].slice(f)) m.remove();
|
|
171
|
-
!
|
|
172
|
-
const R = b(
|
|
173
|
-
R !== t.
|
|
171
|
+
!u && f > 1 && console.warn("u-combobox: Multiple <data> found in single mode."), d && s(d, "aria-multiselectable", `${u}`), l && s(l, "list", lt(d)), l && s(l, "aria-label", `${t._speak}${p}`);
|
|
172
|
+
const R = b(r[0]);
|
|
173
|
+
R !== t._item && S(t), t._item = R, X(t), W(t), (n = L(t)) == null || n.takeRecords();
|
|
174
174
|
}, X = (t) => {
|
|
175
175
|
var e;
|
|
176
176
|
t.clear && s(t.clear, "role", "button"), t.clear && (t.clear.hidden = !((e = t.control) != null && e.value));
|
|
177
177
|
}, W = (t) => {
|
|
178
178
|
var e;
|
|
179
|
-
const { _speak: o, options:
|
|
180
|
-
for (const
|
|
181
|
-
const
|
|
182
|
-
s(
|
|
183
|
-
}
|
|
184
|
-
}, S = (t
|
|
185
|
-
const { multiple:
|
|
186
|
-
|
|
187
|
-
if (e) return K(i, r, "insertText");
|
|
188
|
-
i.value = r;
|
|
189
|
-
}
|
|
179
|
+
const { _speak: o, options: n = [], values: i } = t;
|
|
180
|
+
for (const a of n) {
|
|
181
|
+
const r = (e = s(a, "value")) != null ? e : b(a);
|
|
182
|
+
s(a, "aria-label", o ? `${o}${b(a)}` : null), s(a, "selected", i.includes(r) ? "" : null);
|
|
183
|
+
}
|
|
184
|
+
}, S = (t) => {
|
|
185
|
+
const { multiple: e, control: o, items: n } = t, i = b(n[0]);
|
|
186
|
+
!e && o && i !== o.value && K(o, i, i ? "insertText" : "deleteContent");
|
|
190
187
|
}, P = (t, e = !0) => {
|
|
191
188
|
var o;
|
|
192
|
-
const { _texts:
|
|
193
|
-
let
|
|
194
|
-
(f) => (s(f, "label") || b(f)).trim().toLowerCase() ===
|
|
189
|
+
const { _texts: n, options: i = [], creatable: a, control: r, items: l, multiple: d } = t, u = ((o = r?.value) == null ? void 0 : o.trim()) || "", p = u.toLowerCase() || null;
|
|
190
|
+
let c = [...i].find(
|
|
191
|
+
(f) => (s(f, "label") || b(f)).trim().toLowerCase() === p
|
|
195
192
|
);
|
|
196
|
-
const g = { bubbles: !0, cancelable: !0, detail:
|
|
197
|
-
if (t.dispatchEvent(new CustomEvent("beforematch", g)) || (
|
|
198
|
-
return W(t),
|
|
199
|
-
for (const f of
|
|
193
|
+
const g = { bubbles: !0, cancelable: !0, detail: c };
|
|
194
|
+
if (t.dispatchEvent(new CustomEvent("beforematch", g)) || (c = [...i].find((f) => f.selected)), e)
|
|
195
|
+
return W(t), c ? E(t, c, !1) : a && u ? E(t, { value: u }, !1) : (!d && !u && l[0] ? E(t, l[0]) : S(t), M(n.invalid));
|
|
196
|
+
for (const f of i) f.selected = f === c;
|
|
200
197
|
}, E = (t, e, o = !0) => {
|
|
201
|
-
const { control:
|
|
198
|
+
const { control: n, items: i, multiple: a } = t, r = I("data", e.label || e.value, {
|
|
202
199
|
value: e.value
|
|
203
|
-
}), l = [...
|
|
200
|
+
}), l = [...i].find((p) => p.value === e.value), d = { bubbles: !0, cancelable: !0, detail: l || r };
|
|
204
201
|
if (l && !o) return S(t);
|
|
205
202
|
if (t.dispatchEvent(new CustomEvent("beforechange", d))) {
|
|
206
|
-
if (!
|
|
207
|
-
l ? l.remove() :
|
|
203
|
+
if (!a) for (const p of [...i]) p.remove();
|
|
204
|
+
l ? l.remove() : n?.insertAdjacentElement("beforebegin", r), t.dispatchEvent(new CustomEvent("afterchange", d));
|
|
208
205
|
}
|
|
209
|
-
},
|
|
206
|
+
}, vt = (t, { target: e }) => {
|
|
210
207
|
e instanceof HTMLElement && (t._focus = e), M();
|
|
211
208
|
}, ft = (t) => N() || setTimeout(mt, 0, t), mt = (t) => {
|
|
212
209
|
var e;
|
|
213
210
|
!t._focus || t.contains((e = t._root) == null ? void 0 : e.activeElement) || (t.multiple || P(t), t._focus = void 0);
|
|
214
211
|
}, ht = (t, e) => {
|
|
215
|
-
const { clientX: o, clientY:
|
|
216
|
-
if (
|
|
217
|
-
return
|
|
212
|
+
const { clientX: o, clientY: n, target: i } = e, { clear: a, control: r, items: l } = t;
|
|
213
|
+
if (a?.contains(i))
|
|
214
|
+
return r && K(r, "", "deleteContentBackward"), r?.focus();
|
|
218
215
|
for (const d of l) {
|
|
219
|
-
const { top:
|
|
220
|
-
if (d.contains(
|
|
221
|
-
if (
|
|
216
|
+
const { top: u, right: p, bottom: c, left: g } = d.getBoundingClientRect();
|
|
217
|
+
if (d.contains(i)) return E(t, d);
|
|
218
|
+
if (n >= u && n <= c && o >= g && o <= p) return d.focus();
|
|
222
219
|
}
|
|
223
|
-
|
|
220
|
+
i === t && r?.focus();
|
|
224
221
|
}, _t = (t, e) => {
|
|
225
222
|
var o;
|
|
226
|
-
const { options:
|
|
227
|
-
if (e instanceof InputEvent ? !e.inputType || e.inputType === "insertReplacementText" : !!
|
|
228
|
-
e.stopImmediatePropagation(),
|
|
229
|
-
for (const d of
|
|
230
|
-
if (d.value && d.value ===
|
|
231
|
-
return E(t, d,
|
|
232
|
-
} else
|
|
223
|
+
const { options: n = [], control: i, multiple: a } = t, r = ((o = i?.value) == null ? void 0 : o.trim()) || "";
|
|
224
|
+
if (e instanceof InputEvent ? !e.inputType || e.inputType === "insertReplacementText" : !!r) {
|
|
225
|
+
e.stopImmediatePropagation(), i && (i.value = t._value);
|
|
226
|
+
for (const d of n)
|
|
227
|
+
if (d.value && d.value === r)
|
|
228
|
+
return E(t, d, a);
|
|
229
|
+
} else a || P(t, !1);
|
|
233
230
|
X(t);
|
|
234
231
|
}, bt = (t, e) => {
|
|
235
232
|
var o;
|
|
236
233
|
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) return;
|
|
237
|
-
const { clear:
|
|
238
|
-
let
|
|
239
|
-
if (
|
|
240
|
-
if (
|
|
241
|
-
else if (
|
|
242
|
-
else if (
|
|
243
|
-
const g = s(
|
|
244
|
-
return s(
|
|
245
|
-
} else if ((
|
|
246
|
-
if (e.preventDefault(), !l &&
|
|
247
|
-
|
|
248
|
-
} else return
|
|
249
|
-
e.preventDefault(), (o =
|
|
234
|
+
const { clear: n, control: i, items: a } = t, { key: r, repeat: l, target: d } = e, u = i && i === d, p = u && i?.selectionEnd;
|
|
235
|
+
let c = u ? a.length : [...a].indexOf(d);
|
|
236
|
+
if (u && r === "Tab" && n && !n.hidden && (e.preventDefault(), n.tabIndex = -1, n.focus(), O(n, "blur", () => s(n, "tabindex", null), U)), !(!u && nt(e) || c === -1)) {
|
|
237
|
+
if (r === "ArrowRight" && !u) c += 1;
|
|
238
|
+
else if (r === "ArrowLeft" && !p) c -= 1;
|
|
239
|
+
else if (r === "Enter" && u) {
|
|
240
|
+
const g = s(i, "form");
|
|
241
|
+
return s(i, "form", "#"), requestAnimationFrame(() => s(i, "form", g)), P(t);
|
|
242
|
+
} else if ((r === "Backspace" || r === "Delete") && !p) {
|
|
243
|
+
if (e.preventDefault(), !l && a[c]) return E(t, a[c]);
|
|
244
|
+
u && (c -= 1);
|
|
245
|
+
} else return u || i?.focus();
|
|
246
|
+
e.preventDefault(), (o = a[Math.max(0, c)] || i) == null || o.focus();
|
|
250
247
|
}
|
|
251
248
|
};
|
|
252
|
-
st.define("u-combobox",
|
|
249
|
+
st.define("u-combobox", pt);
|
|
253
250
|
export {
|
|
254
|
-
|
|
251
|
+
pt as UHTMLComboboxElement
|
|
255
252
|
};
|
|
256
253
|
//# sourceMappingURL=u-combobox.js.map
|