@mattilsynet/design 1.2.2 → 1.3.0
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.d.ts +30 -0
- package/mtds/analytics/analytics.js +36 -0
- package/mtds/analytics/analytics.js.map +1 -0
- package/mtds/app/app-observer.js +1 -1
- package/mtds/app/app-toggle.js +14 -26
- package/mtds/app/app-toggle.js.map +1 -1
- package/mtds/app/app-toggle2.js +26 -14
- 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 +107 -102
- 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 +65 -64
- package/mtds/external/@u-elements/u-datalist/dist/u-datalist.js.map +1 -1
- package/mtds/field/field-observer.js +44 -37
- package/mtds/field/field-observer.js.map +1 -1
- package/mtds/field/field.d.ts +5 -2
- package/mtds/field/field.js.map +1 -1
- package/mtds/field/field.stories.d.ts +4 -3
- package/mtds/index.d.ts +1 -0
- package/mtds/index.iife.js +7 -7
- package/mtds/index.js +8 -6
- package/mtds/index.js.map +1 -1
- package/mtds/layout/layout.d.ts +5 -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 +39 -39
- package/mtds/styles.module.css.js +23 -23
- package/mtds/tailwind.css +20 -0
- package/package.json +4 -3
- package/mtds/matomo.d.ts +0 -6
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
type Matomo = (string | number | boolean)[];
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
_paq?: Matomo[];
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export type AnalyticsActions = {
|
|
8
|
+
init: {
|
|
9
|
+
matomoId: number | string;
|
|
10
|
+
enabled?: boolean | "debug";
|
|
11
|
+
};
|
|
12
|
+
pageview: {
|
|
13
|
+
url?: string;
|
|
14
|
+
title?: string;
|
|
15
|
+
};
|
|
16
|
+
event: {
|
|
17
|
+
category: string;
|
|
18
|
+
action: string;
|
|
19
|
+
name?: string;
|
|
20
|
+
value?: number;
|
|
21
|
+
};
|
|
22
|
+
search: {
|
|
23
|
+
query: string;
|
|
24
|
+
category?: string;
|
|
25
|
+
results?: number;
|
|
26
|
+
};
|
|
27
|
+
matomo: Matomo;
|
|
28
|
+
};
|
|
29
|
+
export declare function analytics<Action extends keyof AnalyticsActions>(action: Action, args?: AnalyticsActions[Action]): void;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { IS_BROWSER as r } from "../utils.js";
|
|
2
|
+
const a = "mattilsynet.matomo.cloud";
|
|
3
|
+
let s = !0;
|
|
4
|
+
function d(o, n = {}) {
|
|
5
|
+
if (r) {
|
|
6
|
+
if (window._paq || (window._paq = [], window._paq.push(["HeatmapSessionRecording::disable"]), window._paq.push(["enableLinkTracking"]), window._paq.push(["setTrackerUrl", `https://${a}/matomo.php`]), document.querySelector('script[src*="matomo.js"]') || document.documentElement.append(
|
|
7
|
+
Object.assign(document.createElement("script"), {
|
|
8
|
+
async: !0,
|
|
9
|
+
src: `https://cdn.matomo.cloud/${a}/matomo.js`
|
|
10
|
+
})
|
|
11
|
+
)), o === "init") {
|
|
12
|
+
const { matomoId: e, enabled: t = !0 } = n;
|
|
13
|
+
s = t, window._paq.push(["setSiteId", e]);
|
|
14
|
+
}
|
|
15
|
+
if (s === "debug") return console.info(`Analytics: "${o}"`, n);
|
|
16
|
+
if (!(s === !1 || window.location.hostname === "localhost"))
|
|
17
|
+
if (o === "pageview") {
|
|
18
|
+
const { url: e, title: t } = n;
|
|
19
|
+
window._paq.push(["setCustomUrl", e || location.href]), window._paq.push(["setDocumentTitle", t || document.title]), window._paq.push(["trackPageView"]);
|
|
20
|
+
} else if (o === "event") {
|
|
21
|
+
const { category: e, action: t, name: i, value: c } = n, p = ["trackEvent", e, t, i, c];
|
|
22
|
+
window._paq.push(p.filter((l) => l !== void 0));
|
|
23
|
+
} else if (o === "search") {
|
|
24
|
+
const {
|
|
25
|
+
query: e,
|
|
26
|
+
category: t = !1,
|
|
27
|
+
results: i = !1
|
|
28
|
+
} = n;
|
|
29
|
+
window._paq.push(["trackSiteSearch", e, t, i]);
|
|
30
|
+
} else o === "matomo" && window._paq.push(n);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
d as analytics
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=analytics.js.map
|
|
@@ -0,0 +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}\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.documentElement.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 = true } = args as AnalyticsActions[\"init\"];\n\t\tENABLED = enabled;\n\t\twindow._paq.push([\"setSiteId\", matomoId]);\n\t}\n\n\tif (ENABLED === \"debug\") return console.info(`Analytics: \"${action}\"`, args);\n\tif (ENABLED === false || window.location.hostname === \"localhost\") 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;AAgC5C,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,gBAAgB;AAAA,MACxB,OAAO,OAAO,SAAS,cAAc,QAAQ,GAAG;AAAA,QAC/C,OAAO;AAAA,QACP,KAAK,4BAA4BA,CAAM;AAAA,MACvC,CAAA;AAAA,IACF,IAEEG,MAAW,QAAQ;AACtB,YAAM,EAAE,UAAAG,GAAU,SAAAC,IAAU,GAAS,IAAAH;AAC3B,MAAAH,IAAAM,GACV,OAAO,KAAK,KAAK,CAAC,aAAaD,CAAQ,CAAC;AAAA,IAAA;AAGrC,QAAAL,MAAY,QAAgB,QAAA,QAAQ,KAAK,eAAeE,CAAM,KAAKC,CAAI;AAC3E,QAAI,EAAAH,MAAY,MAAS,OAAO,SAAS,aAAa;AAEtD,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 C, onMutation as T, on as r, QUICK_EVENT as p, debounce as P } from "../utils.js";
|
|
3
|
-
import "./app-
|
|
3
|
+
import "./app-toggle.js";
|
|
4
4
|
const f = m.app.split(" ")[0], _ = m.sticky.split(" ")[0], h = '[data-command="toggle-app-expanded"]', g = `.${f} > dialog,.${f} dialog ~ main`, S = (t) => {
|
|
5
5
|
document.startViewTransition ? document.startViewTransition(t) : t();
|
|
6
6
|
}, E = (t) => (
|
package/mtds/app/app-toggle.js
CHANGED
|
@@ -1,27 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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", t = new CSSStyleSheet(), n = () => {
|
|
3
|
+
var d;
|
|
4
|
+
return !((d = window.localStorage.getItem(e)) != null && d.includes("false"));
|
|
5
|
+
};
|
|
6
|
+
document.adoptedStyleSheets.push(t), window.mtdsToggleAppExpanded = (d) => {
|
|
7
|
+
var p;
|
|
8
|
+
try {
|
|
9
|
+
const o = d ?? !n();
|
|
10
|
+
(p = t.replaceSync) == null || p.call(t, `:root { ${e}: var(${e}--${o})}`), window.localStorage.setItem(e, o);
|
|
11
|
+
} catch {
|
|
12
|
+
}
|
|
13
|
+
}, window.mtdsToggleAppExpanded(n());
|
|
14
|
+
})();
|
|
27
15
|
//# sourceMappingURL=app-toggle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-toggle.js","sources":["../../designsystem/app/app-toggle.js
|
|
1
|
+
{"version":3,"file":"app-toggle.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","_a","force","next"],"mappings":"AACC,OAAO,SAAW,OAClB,OAAO,iBACP,SAAS,uBAER,MAAM;AACN,QAAMA,IAAM,uBACNC,IAAQ,IAAI,cAAe,GAC3BC,IAAO,MAAM;AARrB,QAAAC;AAQqB,cAACA,IAAA,OAAO,aAAa,QAAQH,CAAG,MAA/B,QAAAG,EAAkC,SAAS;AAAA;AAE/D,WAAS,mBAAmB,KAAKF,CAAK,GACtC,OAAO,wBAAwB,CAACG,MAAU;AAX5C,QAAAD;AAYG,QAAI;AACH,YAAME,IAAOD,KAAS,CAACF,EAAM;AAC7B,OAAAC,IAAAF,EAAM,gBAAN,QAAAE,EAAA,KAAAF,GAAoB,WAAWD,CAAG,SAASA,CAAG,KAAKK,CAAI,OACvD,OAAO,aAAa,QAAQL,GAAKK,CAAI;AAAA,IACzC,QAAiB;AAAA,IAAE;AAAA,EAChB,GAGD,OAAO,sBAAsBH,GAAM;AACrC,GAAK;"}
|
package/mtds/app/app-toggle2.js
CHANGED
|
@@ -1,15 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
+
};
|
|
15
27
|
//# sourceMappingURL=app-toggle2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-toggle2.js","sources":["../../designsystem/app/app-toggle.js"],"sourcesContent":["if (
|
|
1
|
+
{"version":3,"file":"app-toggle2.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.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx as o } from "react/jsx-runtime";
|
|
|
2
2
|
import { clsx as a } from "../external/clsx/dist/clsx.js";
|
|
3
3
|
import { forwardRef as p } from "react";
|
|
4
4
|
import c from "../styles.module.css.js";
|
|
5
|
-
import m from "./app-
|
|
5
|
+
import m from "./app-toggle2.js";
|
|
6
6
|
const f = p(function({ as: r, className: t, ...n }, e) {
|
|
7
7
|
return /* @__PURE__ */ o(r || "div", { className: a(c.app, t), ref: e, ...n });
|
|
8
8
|
}), d = p(function({ as: r, className: t, ...n }, e) {
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
var J = Object.defineProperty,
|
|
1
|
+
var J = Object.defineProperty, F = Object.getOwnPropertySymbols, Q = Object.prototype.hasOwnProperty, Z = Object.prototype.propertyIsEnumerable, H = (t, e, o) => e in t ? J(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o, tt = (t, e) => {
|
|
2
2
|
for (var o in e || (e = {}))
|
|
3
|
-
Q.call(e, o) &&
|
|
4
|
-
if (
|
|
5
|
-
for (var o of
|
|
6
|
-
Z.call(e, o) &&
|
|
3
|
+
Q.call(e, o) && H(t, o, e[o]);
|
|
4
|
+
if (F)
|
|
5
|
+
for (var o of F(e))
|
|
6
|
+
Z.call(e, o) && H(t, o, e[o]);
|
|
7
7
|
return t;
|
|
8
|
-
}, T = typeof window < "u" && typeof window.document < "u" && typeof window.navigator < "u",
|
|
8
|
+
}, T = typeof window < "u" && typeof window.document < "u" && typeof window.navigator < "u", j = T && /android/i.test(navigator.userAgent), et = T && /firefox/i.test(navigator.userAgent), ot = T && /iPad|iPhone|iPod/.test(navigator.userAgent), q;
|
|
9
9
|
T && // @ts-expect-error Typescript has not implemented userAgentData yet https://stackoverflow.com/a/71392474
|
|
10
|
-
/^Mac/i.test(((
|
|
10
|
+
/^Mac/i.test(((q = navigator.userAgentData) == null ? void 0 : q.platform) || navigator.platform);
|
|
11
11
|
var it = "outline: 1px dotted; outline: 5px auto Highlight; outline: 5px auto -webkit-focus-ring-color", nt = typeof HTMLElement > "u" ? class {
|
|
12
12
|
} : HTMLElement;
|
|
13
13
|
function l(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
|
-
var
|
|
17
|
-
for (const
|
|
18
|
-
o[0] =
|
|
19
|
-
}, R = (t, ...e) =>
|
|
20
|
-
if (e === void 0) return
|
|
16
|
+
var K = (t, e, o) => {
|
|
17
|
+
for (const r of o[0].split(","))
|
|
18
|
+
o[0] = r, Element.prototype[`${t}EventListener`].apply(e, o);
|
|
19
|
+
}, R = (t, ...e) => K("add", t, e), rt = (t, ...e) => K("remove", t, e), S = /* @__PURE__ */ new WeakMap(), M = (t, e) => {
|
|
20
|
+
if (e === void 0) return S.get(t);
|
|
21
21
|
try {
|
|
22
|
-
|
|
22
|
+
S.get(t).disconnect(), S.delete(t);
|
|
23
23
|
} catch {
|
|
24
24
|
}
|
|
25
25
|
if (e) {
|
|
26
26
|
const o = new MutationObserver(
|
|
27
|
-
(
|
|
27
|
+
(r) => t.handleEvent({ type: "mutation", detail: r })
|
|
28
28
|
);
|
|
29
|
-
o.observe(t, e),
|
|
29
|
+
o.observe(t, e), S.set(t, o);
|
|
30
30
|
}
|
|
31
31
|
}, at = (t) => {
|
|
32
32
|
const e = "key" in t && (t.key === " " || t.key === "Enter");
|
|
@@ -35,20 +35,20 @@ var j = (t, e, o) => {
|
|
|
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
|
+
}, st = 0, ut = (t) => t ? (t.id || (t.id = `:${t.nodeName.toLowerCase()}${(++st).toString(32)}`), t.id) : "", C = (t, e, o) => {
|
|
39
|
+
const r = document.createElement(t);
|
|
40
|
+
if (e && (r.textContent = e), o) for (const [i, a] of Object.entries(o)) l(r, i, a);
|
|
41
|
+
return r;
|
|
42
42
|
}, dt = {
|
|
43
43
|
define: (t, e) => !T || window.customElements.get(t) || window.customElements.define(t, e)
|
|
44
44
|
}, ct = (t) => {
|
|
45
45
|
const e = C("div");
|
|
46
46
|
return e.style.cssText = "position:fixed;overflow:hidden;width:1px;white-space:nowrap", l(e, "aria-live", t), e;
|
|
47
|
-
},
|
|
48
|
-
var
|
|
47
|
+
}, U = (t, e, o = "") => {
|
|
48
|
+
var r, i;
|
|
49
49
|
const a = { bubbles: !0, composed: !0, data: e, inputType: o }, s = HTMLInputElement.prototype;
|
|
50
|
-
t.dispatchEvent(new InputEvent("beforeinput", a)), (
|
|
51
|
-
},
|
|
50
|
+
t.dispatchEvent(new InputEvent("beforeinput", a)), (i = (r = Object.getOwnPropertyDescriptor(s, "value")) == null ? void 0 : r.set) == null || i.call(t, e), t.dispatchEvent(new InputEvent("input", a)), t.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
51
|
+
}, y, vt = 0, N = !1, V = "beforeinput,blur,focus,click,input,keydown,mousedown,mouseup", X = { once: !0, passive: !0 }, pt = et && !j, ft = j || ot, A = "false", mt = "insertReplacementText", O = {
|
|
52
52
|
added: "Added",
|
|
53
53
|
empty: "No selected",
|
|
54
54
|
found: "Navigate left to find %d selected",
|
|
@@ -80,18 +80,18 @@ var j = (t, e, o) => {
|
|
|
80
80
|
return Object.keys(O).map((t) => `data-sr-${t}`);
|
|
81
81
|
}
|
|
82
82
|
connectedCallback() {
|
|
83
|
-
this._root = lt(this), R(this,
|
|
83
|
+
this._root = lt(this), R(this, V, this, !0), M(this, { childList: !0 }), setTimeout(w, 0, this), setTimeout($, 0, this);
|
|
84
84
|
}
|
|
85
85
|
attributeChangedCallback(t, e, o) {
|
|
86
|
-
const
|
|
87
|
-
O[
|
|
86
|
+
const r = t.split("data-sr-")[1];
|
|
87
|
+
O[r] && (this._texts[r] = o || O[r]);
|
|
88
88
|
}
|
|
89
89
|
disconnectedCallback() {
|
|
90
|
-
|
|
90
|
+
W(this), M(this, !1), rt(this, V, this, !0), this._root = void 0;
|
|
91
91
|
}
|
|
92
92
|
handleEvent(t) {
|
|
93
93
|
const e = t.target;
|
|
94
|
-
t.type === "beforeinput" && (this._value = (e == null ? void 0 : e.value) || ""), t.type === "blur" && _t(this), t.type === "click" &&
|
|
94
|
+
t.type === "beforeinput" && (this._value = (e == null ? void 0 : e.value) || ""), t.type === "blur" && _t(this), t.type === "click" && gt(this, t), t.type === "focus" && bt(this, t), t.type === "input" && Et(this, t), t.type === "keydown" && wt(this, t), t.type === "mousedown" && (N = this.contains(e)), t.type === "mouseup" && (N = !1), t.type === "mutation" && w(this, t);
|
|
95
95
|
}
|
|
96
96
|
get multiple() {
|
|
97
97
|
var t;
|
|
@@ -135,100 +135,105 @@ var j = (t, e, o) => {
|
|
|
135
135
|
return ((e = t == null ? void 0 : t.textContent) == null ? void 0 : e.trim()) || "";
|
|
136
136
|
}, P = (t) => typeof t == "string" ? C("data", t, { value: t }) : t instanceof HTMLDataElement ? t : C("data", t.label || t.value, {
|
|
137
137
|
value: t.value || t.label || ""
|
|
138
|
-
}),
|
|
138
|
+
}), W = (t) => {
|
|
139
139
|
t._focus = t._control = t._items = t._list = t._options = void 0;
|
|
140
140
|
}, w = (t, e) => {
|
|
141
|
-
var o,
|
|
142
|
-
let { _focus: a, _speak: s, _texts: u, items:
|
|
143
|
-
const { addedNodes: f, removedNodes: m } = (e == null ? void 0 : e.detail[0]) || {}, b = (e == null ? void 0 : e.detail[1]) || (f == null ? void 0 : f[1]) || (f == null ? void 0 : f[1]) ? null : (f == null ? void 0 : f[0]) || (m == null ? void 0 : m[0]), L =
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
141
|
+
var o, r, i;
|
|
142
|
+
let { _focus: a, _speak: s, _texts: u, items: d, control: n, list: c, multiple: v } = t;
|
|
143
|
+
const { addedNodes: f, removedNodes: m } = (e == null ? void 0 : e.detail[0]) || {}, b = (e == null ? void 0 : e.detail[1]) || (f == null ? void 0 : f[1]) || (f == null ? void 0 : f[1]) ? null : (f == null ? void 0 : f[0]) || (m == null ? void 0 : m[0]), L = v ? d.length : 1, D = [];
|
|
144
|
+
let B = `${s}${_((o = n == null ? void 0 : n.labels) == null ? void 0 : o[0])}, ${v ? L ? u.found.replace("%d", `${L}`) : u.empty : ""}`;
|
|
145
|
+
if (n && (b == null ? void 0 : b.nodeName) === "DATA" && // Announce if only one item has changed...
|
|
146
|
+
(v ? a : b === a)) {
|
|
147
|
+
const p = l(n, "inputmode"), h = (a == null ? void 0 : a.nodeName) === "DATA" ? n : a;
|
|
148
|
+
s = `${u[b.isConnected ? "added" : "removed"]} ${_(b)}, `, (ft || a === n) && (y.textContent = s), n !== h && (l(n, "aria-expanded", null), l(n, "inputmode", "none"), B = " ", n.focus()), setTimeout(() => {
|
|
147
149
|
var x;
|
|
148
|
-
|
|
150
|
+
l(n, "aria-expanded", "true"), l(n, "inputmode", p), (x = h == null ? void 0 : h.focus) == null || x.call(h), t._speak = "", pt ? R(t, "blur", () => w(t), X) : setTimeout(w, 100, t);
|
|
149
151
|
}, 100);
|
|
150
152
|
}
|
|
151
|
-
const
|
|
152
|
-
Array.from(
|
|
153
|
-
if (!
|
|
154
|
-
const h = _(
|
|
155
|
-
l(
|
|
153
|
+
const z = b != null && b.isConnected ? b : d[0];
|
|
154
|
+
Array.from(d, (p) => {
|
|
155
|
+
if (!v && p !== z) return p.remove();
|
|
156
|
+
const h = _(p), x = p.value || h, G = `${s}${h}, ${u.remove}, ${D.push(x)} ${u.of} ${L}`;
|
|
157
|
+
l(p, "role", "button"), l(p, "value", x), l(p, "tabindex", "-1"), l(p, "aria-label", G);
|
|
156
158
|
});
|
|
157
|
-
for (const
|
|
158
|
-
const h = (
|
|
159
|
-
l(
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
y && (y.multiple = c), y && (y.textContent = ""), y == null || y.append(...M.map((v) => new Option("", v, !0, !0))), (r = D(t)) == null || r.takeRecords();
|
|
159
|
+
for (const p of t.options || []) {
|
|
160
|
+
const h = (r = l(p, "value")) != null ? r : _(p);
|
|
161
|
+
l(p, "aria-label", s ? `${s}${_(p)}` : null), l(p, "selected", D.includes(h) ? "" : null);
|
|
162
|
+
}
|
|
163
|
+
c && l(c, "aria-multiselectable", `${v}`), n && l(n, "list", ut(c)), n && l(n, "aria-label", B), t._value = (n == null ? void 0 : n.value) || "";
|
|
164
|
+
const k = t.querySelector("del");
|
|
165
|
+
k && l(k, "role", "button"), k && (k.hidden = !(n != null && n.value));
|
|
166
|
+
const g = t.querySelector("select");
|
|
167
|
+
g && (g.multiple = v), g && (g.textContent = ""), g == null || g.append(...D.map((p) => new Option("", p, !0, !0))), (i = M(t)) == null || i.takeRecords();
|
|
167
168
|
}, $ = (t, e) => {
|
|
168
|
-
const { multiple: o, control:
|
|
169
|
-
if (!(o || !
|
|
170
|
-
if (e) return
|
|
171
|
-
|
|
169
|
+
const { multiple: o, control: r, items: i } = t;
|
|
170
|
+
if (!(o || !r || !i[0])) {
|
|
171
|
+
if (e) return U(r, _(t.items[0]), "insertText");
|
|
172
|
+
r.value = _(t.items[0]);
|
|
172
173
|
}
|
|
173
|
-
},
|
|
174
|
+
}, Y = (t) => {
|
|
174
175
|
var e;
|
|
175
|
-
const { options: o = [], creatable:
|
|
176
|
-
let
|
|
177
|
-
const
|
|
178
|
-
if (t.dispatchEvent(new CustomEvent("beforematch",
|
|
179
|
-
for (const
|
|
180
|
-
if (
|
|
176
|
+
const { options: o = [], creatable: r, control: i, items: a, multiple: s } = t, u = ((e = i == null ? void 0 : i.value) == null ? void 0 : e.trim()) || "", d = u.toLowerCase() || null;
|
|
177
|
+
let n = [...o].find((v) => v.label.trim().toLowerCase() === d);
|
|
178
|
+
const c = { bubbles: !0, cancelable: !0, detail: n };
|
|
179
|
+
if (t.dispatchEvent(new CustomEvent("beforematch", c)))
|
|
180
|
+
for (const v of o) v.selected = v === n;
|
|
181
|
+
if (n = [...o].find((v) => v.selected), !n && r && u)
|
|
181
182
|
return E(t, P(u), !1);
|
|
182
|
-
if (!
|
|
183
|
-
if (!
|
|
184
|
-
E(t,
|
|
183
|
+
if (!n && !s && a[0]) return E(t, a[0]);
|
|
184
|
+
if (!n || t.values.includes(n.value)) return w(t);
|
|
185
|
+
E(t, n, !1);
|
|
185
186
|
}, E = (t, e, o = !0) => {
|
|
186
|
-
const
|
|
187
|
-
if (!(
|
|
187
|
+
const r = P(e), i = [...t.items].find((s) => s.value === e.value), a = { bubbles: !0, cancelable: !0, detail: i || r };
|
|
188
|
+
if (!(i && !o)) {
|
|
188
189
|
if (!t.dispatchEvent(new CustomEvent("beforechange", a)))
|
|
189
190
|
return w(t);
|
|
190
|
-
|
|
191
|
+
i ? i.remove() : t.add(r), t.dispatchEvent(new CustomEvent("afterchange", a));
|
|
191
192
|
}
|
|
192
193
|
}, bt = (t, { target: e }) => {
|
|
193
|
-
|
|
194
|
-
}, _t = (t) => N || setTimeout(
|
|
194
|
+
y || (y = ct("assertive")), y.isConnected || document.body.appendChild(y), e instanceof HTMLElement && (t._focus = e), t._items || (t._control = t.control || void 0, t._items = t.items, t._list = t.list || void 0, t._options = t.options || void 0);
|
|
195
|
+
}, _t = (t) => N || setTimeout(yt, 0, t), yt = (t) => {
|
|
195
196
|
var e;
|
|
196
|
-
!t._focus || t.contains((e = t._root) == null ? void 0 : e.activeElement) || ($(t, !0),
|
|
197
|
-
},
|
|
198
|
-
var o,
|
|
199
|
-
const
|
|
200
|
-
if (
|
|
201
|
-
return e.preventDefault(),
|
|
202
|
-
for (const
|
|
203
|
-
const { top:
|
|
204
|
-
if (
|
|
205
|
-
if (s >=
|
|
206
|
-
}
|
|
207
|
-
u === t && (
|
|
197
|
+
!t._focus || t.contains((e = t._root) == null ? void 0 : e.activeElement) || ($(t, !0), W(t));
|
|
198
|
+
}, gt = (t, e) => {
|
|
199
|
+
var o, r;
|
|
200
|
+
const i = (r = (o = e.target) == null ? void 0 : o.closest) == null ? void 0 : r.call(o, "del"), { clientX: a, clientY: s, target: u } = e, { control: d, items: n } = t;
|
|
201
|
+
if (i && d)
|
|
202
|
+
return e.preventDefault(), U(d, "", "deleteContentBackward"), d.focus();
|
|
203
|
+
for (const c of n) {
|
|
204
|
+
const { top: v, right: f, bottom: m, left: I } = c.getBoundingClientRect();
|
|
205
|
+
if (c.contains(u)) return E(t, c);
|
|
206
|
+
if (s >= v && s <= m && a >= I && a <= f) return c.focus();
|
|
207
|
+
}
|
|
208
|
+
u === t && (d == null || d.focus());
|
|
208
209
|
}, Et = (t, e) => {
|
|
209
|
-
var o
|
|
210
|
-
const { options: r = [], control:
|
|
211
|
-
if (
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
210
|
+
var o;
|
|
211
|
+
const { options: r = [], control: i, multiple: a } = t, s = ((o = i == null ? void 0 : i.value) == null ? void 0 : o.trim()) || "";
|
|
212
|
+
if (e instanceof InputEvent ? !e.inputType || e.inputType === mt : !!s) {
|
|
213
|
+
e.stopImmediatePropagation(), i && (i.value = t._value);
|
|
214
|
+
for (const d of r)
|
|
215
|
+
if (d.value && d.value === s)
|
|
216
|
+
return E(t, d, a), setTimeout($, 0, t, !0);
|
|
217
|
+
} else {
|
|
218
|
+
const d = t.querySelector("del");
|
|
219
|
+
return d && (d.hidden = !s), a || Y(t);
|
|
220
|
+
}
|
|
216
221
|
}, wt = (t, e) => {
|
|
217
222
|
var o;
|
|
218
223
|
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) return;
|
|
219
|
-
const { _texts:
|
|
220
|
-
let m =
|
|
221
|
-
if (f && !f.hidden && (e.preventDefault(), f.tabIndex = -1, f.focus(), R(f, "blur", () => l(f, "tabindex", null),
|
|
222
|
-
if (u === "ArrowRight" && !
|
|
223
|
-
else if (u === "ArrowLeft" && !
|
|
224
|
-
else if (u === "Enter" &&
|
|
225
|
-
const I = l(
|
|
226
|
-
return l(
|
|
227
|
-
} else if ((u === "Backspace" || u === "Delete") && !
|
|
228
|
-
if (e.preventDefault(), !
|
|
229
|
-
|
|
230
|
-
} else return
|
|
231
|
-
e.preventDefault(), (o = a[Math.max(0, m)] ||
|
|
224
|
+
const { _texts: r, control: i, items: a, multiple: s } = t, { key: u, repeat: d, target: n } = e, c = i && i === n, v = c && (i == null ? void 0 : i.selectionEnd), f = c && u === "Tab" && t.querySelector("del");
|
|
225
|
+
let m = c ? a.length : [...a].indexOf(n);
|
|
226
|
+
if (f && !f.hidden && (e.preventDefault(), f.tabIndex = -1, f.focus(), R(f, "blur", () => l(f, "tabindex", null), X)), !(!c && at(e) || m === -1)) {
|
|
227
|
+
if (u === "ArrowRight" && !c) m += 1;
|
|
228
|
+
else if (u === "ArrowLeft" && !v) m -= 1;
|
|
229
|
+
else if (u === "Enter" && c) {
|
|
230
|
+
const I = l(i, "form");
|
|
231
|
+
return l(i, "form", "#"), requestAnimationFrame(() => l(i, "form", I)), s ? Y(t) : !t.items[0] && y && (y.textContent = `${r.invalid}${++vt % 2 ? " " : ""}`), $(t, !0);
|
|
232
|
+
} else if ((u === "Backspace" || u === "Delete") && !v) {
|
|
233
|
+
if (e.preventDefault(), !d && a[m]) return E(t, a[m]);
|
|
234
|
+
c && (m -= 1);
|
|
235
|
+
} else return c || (i == null ? void 0 : i.focus());
|
|
236
|
+
e.preventDefault(), (o = a[Math.max(0, m)] || i) == null || o.focus();
|
|
232
237
|
}
|
|
233
238
|
};
|
|
234
239
|
dt.define("u-combobox", ht);
|