screenreader-speech-capture 0.9.0 → 0.10.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/README.md +17 -0
- package/dist/cli.mjs +1 -1
- package/dist/ui/adapter-node.js +1 -1
- package/dist/ui/client/ui/_app/immutable/assets/{0.CnPCLsGJ.css → 0.DH3e8XLu.css} +1 -1
- package/dist/ui/client/ui/_app/immutable/assets/0.DH3e8XLu.css.br +0 -0
- package/dist/ui/client/ui/_app/immutable/assets/0.DH3e8XLu.css.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/assets/2.DSVNnDlO.css +1 -0
- package/dist/ui/client/ui/_app/immutable/assets/2.DSVNnDlO.css.br +3 -0
- package/dist/ui/client/ui/_app/immutable/assets/2.DSVNnDlO.css.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/assets/4.DIE1qdmp.css +1 -0
- package/dist/ui/client/ui/_app/immutable/assets/4.DIE1qdmp.css.br +0 -0
- package/dist/ui/client/ui/_app/immutable/assets/4.DIE1qdmp.css.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/assets/5.DCMlxwLh.css +1 -0
- package/dist/ui/client/ui/_app/immutable/assets/5.DCMlxwLh.css.br +0 -0
- package/dist/ui/client/ui/_app/immutable/assets/5.DCMlxwLh.css.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/assets/6.C0Nhvs_m.css +1 -0
- package/dist/ui/client/ui/_app/immutable/assets/6.C0Nhvs_m.css.br +0 -0
- package/dist/ui/client/ui/_app/immutable/assets/6.C0Nhvs_m.css.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/assets/ExternalLink.CYXazpKA.css +1 -0
- package/dist/ui/client/ui/_app/immutable/assets/ExternalLink.CYXazpKA.css.br +0 -0
- package/dist/ui/client/ui/_app/immutable/assets/ExternalLink.CYXazpKA.css.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/assets/Pane.Co7gxzxw.css +1 -0
- package/dist/ui/client/ui/_app/immutable/assets/Pane.Co7gxzxw.css.br +0 -0
- package/dist/ui/client/ui/_app/immutable/assets/Pane.Co7gxzxw.css.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/{Cba3ZwaX.js → 4R6qUa-I.js} +12 -13
- package/dist/ui/client/ui/_app/immutable/chunks/4R6qUa-I.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/4R6qUa-I.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/BC9D66S_.js +2 -0
- package/dist/ui/client/ui/_app/immutable/chunks/BC9D66S_.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/BC9D66S_.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/BCiTXg3M.js +138 -0
- package/dist/ui/client/ui/_app/immutable/chunks/BCiTXg3M.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/BCiTXg3M.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/BGgW64O2.js +1 -0
- package/dist/ui/client/ui/_app/immutable/chunks/BGgW64O2.js.br +2 -0
- package/dist/ui/client/ui/_app/immutable/chunks/BGgW64O2.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/Bvlvl8SZ.js +1 -0
- package/dist/ui/client/ui/_app/immutable/chunks/Bvlvl8SZ.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/Bvlvl8SZ.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/ByQTEKOy.js +3 -0
- package/dist/ui/client/ui/_app/immutable/chunks/ByQTEKOy.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/ByQTEKOy.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/C-UVUBR9.js +3 -0
- package/dist/ui/client/ui/_app/immutable/chunks/C-UVUBR9.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/C-UVUBR9.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/C1Z3Vlq6.js +3 -0
- package/dist/ui/client/ui/_app/immutable/chunks/C1Z3Vlq6.js.br +11 -0
- package/dist/ui/client/ui/_app/immutable/chunks/C1Z3Vlq6.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/CSj31z2g.js +1 -0
- package/dist/ui/client/ui/_app/immutable/chunks/CSj31z2g.js.br +2 -0
- package/dist/ui/client/ui/_app/immutable/chunks/CSj31z2g.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/D7Lf2nU5.js +48 -0
- package/dist/ui/client/ui/_app/immutable/chunks/D7Lf2nU5.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/D7Lf2nU5.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/D8AQra8V.js +3 -0
- package/dist/ui/client/ui/_app/immutable/chunks/D8AQra8V.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/D8AQra8V.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/DLBNPxq0.js +1 -0
- package/dist/ui/client/ui/_app/immutable/chunks/DLBNPxq0.js.br +3 -0
- package/dist/ui/client/ui/_app/immutable/chunks/DLBNPxq0.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/DMXmTTni.js +1 -0
- package/dist/ui/client/ui/_app/immutable/chunks/DMXmTTni.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/DMXmTTni.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/DVjfBgOA.js +1 -0
- package/dist/ui/client/ui/_app/immutable/chunks/DVjfBgOA.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/DVjfBgOA.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/EBfbaSFC.js +40 -0
- package/dist/ui/client/ui/_app/immutable/chunks/EBfbaSFC.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/EBfbaSFC.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/HjKxdHgL.js +4 -0
- package/dist/ui/client/ui/_app/immutable/chunks/HjKxdHgL.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/HjKxdHgL.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/y62iQtQV.js +1 -0
- package/dist/ui/client/ui/_app/immutable/chunks/y62iQtQV.js.br +1 -0
- package/dist/ui/client/ui/_app/immutable/chunks/y62iQtQV.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/entry/app.BRCyy_aP.js +2 -0
- package/dist/ui/client/ui/_app/immutable/entry/app.BRCyy_aP.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/entry/app.BRCyy_aP.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/entry/start.ujo8oI9U.js +2 -0
- package/dist/ui/client/ui/_app/immutable/entry/start.ujo8oI9U.js.br +5 -0
- package/dist/ui/client/ui/_app/immutable/entry/start.ujo8oI9U.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/0.CYE8I_uA.js +1 -0
- package/dist/ui/client/ui/_app/immutable/nodes/0.CYE8I_uA.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/0.CYE8I_uA.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/1.DTsysZRk.js +1 -0
- package/dist/ui/client/ui/_app/immutable/nodes/1.DTsysZRk.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/1.DTsysZRk.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/2.hev1nfuM.js +1 -0
- package/dist/ui/client/ui/_app/immutable/nodes/2.hev1nfuM.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/2.hev1nfuM.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/3.CApflji6.js +5 -0
- package/dist/ui/client/ui/_app/immutable/nodes/3.CApflji6.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/3.CApflji6.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/4.BkefkGQL.js +160 -0
- package/dist/ui/client/ui/_app/immutable/nodes/4.BkefkGQL.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/4.BkefkGQL.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/5.CDYh05RH.js +6 -0
- package/dist/ui/client/ui/_app/immutable/nodes/5.CDYh05RH.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/5.CDYh05RH.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/6.DwISzDQO.js +6 -0
- package/dist/ui/client/ui/_app/immutable/nodes/6.DwISzDQO.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/6.DwISzDQO.js.gz +0 -0
- package/dist/ui/client/ui/_app/version.json +1 -1
- package/dist/ui/client/ui/_app/version.json.br +0 -0
- package/dist/ui/client/ui/_app/version.json.gz +0 -0
- package/dist/ui/server/.vite/manifest.json +193 -10
- package/dist/ui/server/_app/immutable/assets/ExternalLink.CYXazpKA.css +1 -0
- package/dist/ui/server/_app/immutable/assets/Pane.Co7gxzxw.css +1 -0
- package/dist/ui/server/_app/immutable/assets/{_layout.CnPCLsGJ.css → _layout.DH3e8XLu.css} +1 -1
- package/dist/ui/server/_app/immutable/assets/_layout.DSVNnDlO.css +1 -0
- package/dist/ui/server/_app/immutable/assets/_page.C0Nhvs_m.css +1 -0
- package/dist/ui/server/_app/immutable/assets/_page.DCMlxwLh.css +1 -0
- package/dist/ui/server/_app/immutable/assets/_page.DIE1qdmp.css +1 -0
- package/dist/ui/server/chunks/ExternalLink.js +12 -0
- package/dist/ui/server/chunks/ExternalLink.js.map +1 -0
- package/dist/ui/server/chunks/Pane.js +13 -0
- package/dist/ui/server/chunks/Pane.js.map +1 -0
- package/dist/ui/server/chunks/composition.js +462 -120
- package/dist/ui/server/chunks/composition.js.map +1 -1
- package/dist/ui/server/chunks/config-state.js +21 -0
- package/dist/ui/server/chunks/config-state.js.map +1 -0
- package/dist/ui/server/chunks/dialog.js +592 -0
- package/dist/ui/server/chunks/dialog.js.map +1 -0
- package/dist/ui/server/chunks/filled-button.js +116 -0
- package/dist/ui/server/chunks/filled-button.js.map +1 -0
- package/dist/ui/server/chunks/icon-button.js +2 -46
- package/dist/ui/server/chunks/icon-button.js.map +1 -1
- package/dist/ui/server/chunks/icon.js +49 -0
- package/dist/ui/server/chunks/icon.js.map +1 -0
- package/dist/ui/server/chunks/index-server.js +5 -1
- package/dist/ui/server/chunks/index-server.js.map +1 -0
- package/dist/ui/server/chunks/instance.js +5 -5
- package/dist/ui/server/chunks/internal.js +1 -1
- package/dist/ui/server/chunks/navigation.js +9 -13
- package/dist/ui/server/chunks/navigation.js.map +1 -1
- package/dist/ui/server/chunks/navigation2.js +15 -0
- package/dist/ui/server/chunks/navigation2.js.map +1 -0
- package/dist/ui/server/chunks/outlined-text-field.js +11 -398
- package/dist/ui/server/chunks/outlined-text-field.js.map +1 -1
- package/dist/ui/server/chunks/paths.js +2 -0
- package/dist/ui/server/chunks/redispatch-event.js +91 -0
- package/dist/ui/server/chunks/redispatch-event.js.map +1 -0
- package/dist/ui/server/chunks/server2.js +11 -1
- package/dist/ui/server/chunks/server2.js.map +1 -1
- package/dist/ui/server/chunks/src.js +112 -3
- package/dist/ui/server/chunks/src.js.map +1 -1
- package/dist/ui/server/chunks/state.js +1 -1
- package/dist/ui/server/chunks/static-html.js +38 -0
- package/dist/ui/server/chunks/static-html.js.map +1 -0
- package/dist/ui/server/chunks/text-button.js +307 -0
- package/dist/ui/server/chunks/text-button.js.map +1 -0
- package/dist/ui/server/entries/endpoints/api/config/_server.ts.js +4 -17
- package/dist/ui/server/entries/endpoints/api/config/_server.ts.js.map +1 -1
- package/dist/ui/server/entries/endpoints/api/input/keys/_server.ts.js +14 -0
- package/dist/ui/server/entries/endpoints/api/input/keys/_server.ts.js.map +1 -0
- package/dist/ui/server/entries/endpoints/api/markers/_server.ts.js +1 -1
- package/dist/ui/server/entries/endpoints/api/speech/_server.ts.js +1 -1
- package/dist/ui/server/entries/fallbacks/error.svelte.js +1 -1
- package/dist/ui/server/entries/hooks.server.js +4 -1
- package/dist/ui/server/entries/hooks.server.js.map +1 -1
- package/dist/ui/server/entries/pages/_layout.svelte.js +5 -10
- package/dist/ui/server/entries/pages/_layout.svelte.js.map +1 -1
- package/dist/ui/server/entries/pages/_page.svelte.js +15 -597
- package/dist/ui/server/entries/pages/_page.svelte.js.map +1 -1
- package/dist/ui/server/entries/pages/settings/_page.server.ts.js +12 -0
- package/dist/ui/server/entries/pages/settings/_page.server.ts.js.map +1 -0
- package/dist/ui/server/entries/pages/settings/_page.svelte.js +3470 -70
- package/dist/ui/server/entries/pages/settings/_page.svelte.js.map +1 -1
- package/dist/ui/server/entries/pages/setup/_layout.svelte.js +51 -0
- package/dist/ui/server/entries/pages/setup/_layout.svelte.js.map +1 -0
- package/dist/ui/server/entries/pages/setup/_page.svelte.js +225 -3
- package/dist/ui/server/entries/pages/setup/_page.svelte.js.map +1 -1
- package/dist/ui/server/entries/pages/setup/instructions/_page.server.ts.js +12 -0
- package/dist/ui/server/entries/pages/setup/instructions/_page.server.ts.js.map +1 -0
- package/dist/ui/server/entries/pages/setup/instructions/_page.svelte.js +271 -0
- package/dist/ui/server/entries/pages/setup/instructions/_page.svelte.js.map +1 -0
- package/dist/ui/server/manifest-full.js +21 -5
- package/dist/ui/server/manifest.js +21 -5
- package/dist/ui/server/nodes/0.js +2 -2
- package/dist/ui/server/nodes/1.js +1 -1
- package/dist/ui/server/nodes/2.js +4 -6
- package/dist/ui/server/nodes/3.js +6 -4
- package/dist/ui/server/nodes/4.js +6 -4
- package/dist/ui/server/nodes/5.js +8 -0
- package/dist/ui/server/nodes/6.js +10 -0
- package/dist/ui/server/server.js +21 -5
- package/package.json +1 -1
- package/dist/ui/client/ui/_app/immutable/assets/0.CnPCLsGJ.css.br +0 -0
- package/dist/ui/client/ui/_app/immutable/assets/0.CnPCLsGJ.css.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/assets/3.CK2Biket.css +0 -1
- package/dist/ui/client/ui/_app/immutable/assets/3.CK2Biket.css.br +0 -0
- package/dist/ui/client/ui/_app/immutable/assets/3.CK2Biket.css.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/0YgL1EU2.js +0 -179
- package/dist/ui/client/ui/_app/immutable/chunks/0YgL1EU2.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/0YgL1EU2.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/BYvlzyV8.js +0 -1
- package/dist/ui/client/ui/_app/immutable/chunks/BYvlzyV8.js.br +0 -2
- package/dist/ui/client/ui/_app/immutable/chunks/BYvlzyV8.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/BfvDkxmG.js +0 -3
- package/dist/ui/client/ui/_app/immutable/chunks/BfvDkxmG.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/BfvDkxmG.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/Cba3ZwaX.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/Cba3ZwaX.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/DErxe_FC.js +0 -3
- package/dist/ui/client/ui/_app/immutable/chunks/DErxe_FC.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/DErxe_FC.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/Dqufijaz.js +0 -1
- package/dist/ui/client/ui/_app/immutable/chunks/Dqufijaz.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/Dqufijaz.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/WpCriteK.js +0 -1
- package/dist/ui/client/ui/_app/immutable/chunks/WpCriteK.js.br +0 -1
- package/dist/ui/client/ui/_app/immutable/chunks/WpCriteK.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/wbLSPbHY.js +0 -4
- package/dist/ui/client/ui/_app/immutable/chunks/wbLSPbHY.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/wbLSPbHY.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/entry/app.B6hhDf4F.js +0 -2
- package/dist/ui/client/ui/_app/immutable/entry/app.B6hhDf4F.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/entry/app.B6hhDf4F.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/entry/start.Dluk7nQO.js +0 -2
- package/dist/ui/client/ui/_app/immutable/entry/start.Dluk7nQO.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/entry/start.Dluk7nQO.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/0.D-lhv0Us.js +0 -1
- package/dist/ui/client/ui/_app/immutable/nodes/0.D-lhv0Us.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/0.D-lhv0Us.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/1.Cs4GAsCO.js +0 -1
- package/dist/ui/client/ui/_app/immutable/nodes/1.Cs4GAsCO.js.br +0 -2
- package/dist/ui/client/ui/_app/immutable/nodes/1.Cs4GAsCO.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/2.CmuzlN_T.js +0 -52
- package/dist/ui/client/ui/_app/immutable/nodes/2.CmuzlN_T.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/2.CmuzlN_T.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/3.DMXXeBbC.js +0 -5
- package/dist/ui/client/ui/_app/immutable/nodes/3.DMXXeBbC.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/3.DMXXeBbC.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/4.CMHCNMDn.js +0 -1
- package/dist/ui/client/ui/_app/immutable/nodes/4.CMHCNMDn.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/4.CMHCNMDn.js.gz +0 -0
- package/dist/ui/server/_app/immutable/assets/_page.CK2Biket.css +0 -1
- /package/dist/ui/client/ui/_app/immutable/assets/{2.ChCvyBVk.css → 3.ChCvyBVk.css} +0 -0
- /package/dist/ui/client/ui/_app/immutable/assets/{2.ChCvyBVk.css.br → 3.ChCvyBVk.css.br} +0 -0
- /package/dist/ui/client/ui/_app/immutable/assets/{2.ChCvyBVk.css.gz → 3.ChCvyBVk.css.gz} +0 -0
|
@@ -1,87 +1,3436 @@
|
|
|
1
|
-
import { a as head, i as ensure_array_like, m as
|
|
2
|
-
import "../../../chunks/index-server.js";
|
|
3
|
-
import {
|
|
4
|
-
import { i as
|
|
5
|
-
|
|
1
|
+
import { a as head, c as stringify, d as attr, h as escape_html, i as ensure_array_like, m as run, o as props_id, r as derived, t as attr_class } from "../../../chunks/server2.js";
|
|
2
|
+
import { t as tick } from "../../../chunks/index-server.js";
|
|
3
|
+
import { h as LOG_LEVELS } from "../../../chunks/src.js";
|
|
4
|
+
import { B as e$3, D as createAnimationSignal, E as EASING, G as t, H as r$1, I as T, K as __decorate, M as i, N as A, O as e$2, P as B, S as mixinElementInternals, T as mixinDelegatesAria, U as n$1, V as e$1, W as i$1, _ as THEMES, b as mixinFormAssociated, f as SettingRejected, g as pendingFields, h as parsePort, m as parsePlaywrightVersion, p as parseMaxEntries, t as appStores, y as getFormValue } from "../../../chunks/composition.js";
|
|
5
|
+
import { t as Pane } from "../../../chunks/Pane.js";
|
|
6
|
+
import "../../../chunks/filled-button.js";
|
|
7
|
+
import { r as o } from "../../../chunks/text-button.js";
|
|
8
|
+
import { a as getValidityAnchor, i as createValidator, n as mixinOnReportValidity, o as mixinConstraintValidation, r as onReportValidity, s as o$1, t as Validator } from "../../../chunks/outlined-text-field.js";
|
|
9
|
+
import { n as u, t as i$2 } from "../../../chunks/static-html.js";
|
|
10
|
+
import { t as redispatchEvent } from "../../../chunks/redispatch-event.js";
|
|
11
|
+
// ../../node_modules/.pnpm/@lit+reactive-element@2.1.2/node_modules/@lit/reactive-element/node/decorators/query-all.js
|
|
6
12
|
/**
|
|
7
13
|
* @license
|
|
8
|
-
* Copyright
|
|
14
|
+
* Copyright 2017 Google LLC
|
|
15
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
16
|
+
*/
|
|
17
|
+
var e;
|
|
18
|
+
function r(r) {
|
|
19
|
+
return (n, o) => e$1(n, o, { get() {
|
|
20
|
+
return (this.renderRoot ?? (e ??= document.createDocumentFragment())).querySelectorAll(r);
|
|
21
|
+
} });
|
|
22
|
+
}
|
|
23
|
+
// ../../node_modules/.pnpm/@lit+reactive-element@2.1.2/node_modules/@lit/reactive-element/node/decorators/query-assigned-nodes.js
|
|
24
|
+
/**
|
|
25
|
+
* @license
|
|
26
|
+
* Copyright 2017 Google LLC
|
|
27
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
28
|
+
*/ function n(n) {
|
|
29
|
+
return (o, r) => {
|
|
30
|
+
const { slot: e } = n ?? {}, s = "slot" + (e ? `[name=${e}]` : ":not([name])");
|
|
31
|
+
return e$1(o, r, { get() {
|
|
32
|
+
return (this.renderRoot?.querySelector(s))?.assignedNodes(n) ?? [];
|
|
33
|
+
} });
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
// src/lib/core/settings.ts
|
|
37
|
+
var TCP_PORT = {
|
|
38
|
+
path: "tcp.port",
|
|
39
|
+
label: "TCP port",
|
|
40
|
+
control: {
|
|
41
|
+
kind: "text",
|
|
42
|
+
inputmode: "numeric"
|
|
43
|
+
},
|
|
44
|
+
help: () => "The port the screen reader's speech voice sends to. Default 4449.",
|
|
45
|
+
format: String,
|
|
46
|
+
parse(text) {
|
|
47
|
+
const parsed = parsePort(text);
|
|
48
|
+
return parsed.ok ? {
|
|
49
|
+
ok: true,
|
|
50
|
+
value: parsed.port
|
|
51
|
+
} : parsed;
|
|
52
|
+
},
|
|
53
|
+
describe: String,
|
|
54
|
+
consequence: (saved) => [
|
|
55
|
+
`The speech voice on the VM sends to a fixed port, so also add a voice for ${saved} (`,
|
|
56
|
+
{ code: "text-to-socket-engine-add-voice" },
|
|
57
|
+
") and select it in the screen reader."
|
|
58
|
+
]
|
|
59
|
+
};
|
|
60
|
+
/** The ANSI code pages Windows has, plus UTF-8: what a speech voice on the VM can send. */
|
|
61
|
+
var ENCODINGS = [
|
|
62
|
+
["windows-874", "Thai"],
|
|
63
|
+
["windows-1250", "Central European"],
|
|
64
|
+
["windows-1251", "Cyrillic"],
|
|
65
|
+
["windows-1252", "Western European"],
|
|
66
|
+
["windows-1253", "Greek"],
|
|
67
|
+
["windows-1254", "Turkish"],
|
|
68
|
+
["windows-1255", "Hebrew"],
|
|
69
|
+
["windows-1256", "Arabic"],
|
|
70
|
+
["windows-1257", "Baltic"],
|
|
71
|
+
["windows-1258", "Vietnamese"],
|
|
72
|
+
["shift_jis", "Japanese"],
|
|
73
|
+
["gbk", "Simplified Chinese"],
|
|
74
|
+
["euc-kr", "Korean"],
|
|
75
|
+
["big5", "Traditional Chinese"],
|
|
76
|
+
["utf-8", "Unicode"]
|
|
77
|
+
].map(([value, name]) => ({
|
|
78
|
+
value,
|
|
79
|
+
label: `${value} (${name})`
|
|
80
|
+
}));
|
|
81
|
+
/**
|
|
82
|
+
* The options of a select that holds `value`. A saved value outside the list (an alias such as
|
|
83
|
+
* `cp1252`) is added, so showing it never changes it.
|
|
84
|
+
*/
|
|
85
|
+
function selectOptions(options, value) {
|
|
86
|
+
return options.some((option) => option.value === value) ? options : [...options, {
|
|
87
|
+
value,
|
|
88
|
+
label: value
|
|
89
|
+
}];
|
|
90
|
+
}
|
|
91
|
+
var TEXT_ENCODING = {
|
|
92
|
+
path: "tcp.encoding",
|
|
93
|
+
label: "Text encoding",
|
|
94
|
+
control: {
|
|
95
|
+
kind: "select",
|
|
96
|
+
options: ENCODINGS
|
|
97
|
+
},
|
|
98
|
+
help: () => "The code page the speech voice sends: the VM's ANSI code page. Default windows-1252.",
|
|
99
|
+
format: (encoding) => encoding,
|
|
100
|
+
parse: (text) => ({
|
|
101
|
+
ok: true,
|
|
102
|
+
value: text
|
|
103
|
+
}),
|
|
104
|
+
describe: (encoding) => encoding,
|
|
105
|
+
consequence: () => []
|
|
106
|
+
};
|
|
107
|
+
var BUFFER_SIZE = {
|
|
108
|
+
path: "buffer.maxEntries",
|
|
109
|
+
label: "Speech buffer size",
|
|
110
|
+
control: {
|
|
111
|
+
kind: "text",
|
|
112
|
+
inputmode: "numeric",
|
|
113
|
+
suffix: "entries"
|
|
114
|
+
},
|
|
115
|
+
help: () => "How many speech entries the bridge keeps; then the oldest are dropped. Default 10000.",
|
|
116
|
+
format: String,
|
|
117
|
+
parse(text) {
|
|
118
|
+
const parsed = parseMaxEntries(text);
|
|
119
|
+
return parsed.ok ? {
|
|
120
|
+
ok: true,
|
|
121
|
+
value: parsed.entries
|
|
122
|
+
} : parsed;
|
|
123
|
+
},
|
|
124
|
+
describe: String,
|
|
125
|
+
consequence: () => []
|
|
126
|
+
};
|
|
127
|
+
/** What every on / off setting shares. */
|
|
128
|
+
var onOff = {
|
|
129
|
+
control: { kind: "checkbox" },
|
|
130
|
+
format: String,
|
|
131
|
+
parse: (text) => ({
|
|
132
|
+
ok: true,
|
|
133
|
+
value: text === "true"
|
|
134
|
+
}),
|
|
135
|
+
describe: (on) => on ? "On" : "Off"
|
|
136
|
+
};
|
|
137
|
+
/** What to know before a restart that turns a child service on. */
|
|
138
|
+
var INSTALLS = "The first start installs what is missing, which can take a minute or two.";
|
|
139
|
+
var PLAYWRIGHT_ENABLED = {
|
|
140
|
+
...onOff,
|
|
141
|
+
path: "playwright.enabled",
|
|
142
|
+
label: "Playwright server",
|
|
143
|
+
help: () => "Tests connect to it to drive a browser on the VM.",
|
|
144
|
+
consequence: (saved) => [saved ? INSTALLS : "Tests can't connect to a browser on the VM while it is off."]
|
|
145
|
+
};
|
|
146
|
+
var bundled = ({ runningPlaywright }) => runningPlaywright === null ? "bundled version" : `bundled version (${runningPlaywright})`;
|
|
147
|
+
var PLAYWRIGHT_VERSION = {
|
|
148
|
+
path: "playwright.version",
|
|
149
|
+
label: "Playwright version",
|
|
150
|
+
control: {
|
|
151
|
+
kind: "text",
|
|
152
|
+
inputmode: "text"
|
|
153
|
+
},
|
|
154
|
+
help: (active, { runningPlaywright, playwrightOff }) => "The exact version of the Playwright server, like 1.65.0. Use the version your tests use. Leave empty for the bundled version" + (active === null && runningPlaywright !== null ? ` (${runningPlaywright}).` : ".") + (playwrightOff === true ? " Applies when the server is turned on." : ""),
|
|
155
|
+
format: (version) => version ?? "",
|
|
156
|
+
parse(text) {
|
|
157
|
+
const parsed = parsePlaywrightVersion(text);
|
|
158
|
+
return parsed.ok ? {
|
|
159
|
+
ok: true,
|
|
160
|
+
value: parsed.version
|
|
161
|
+
} : parsed;
|
|
162
|
+
},
|
|
163
|
+
describe: (version, context) => version ?? bundled(context),
|
|
164
|
+
consequence: () => ["The first start of a new version installs it, which can take a minute or two. Your test projects need the same version."]
|
|
165
|
+
};
|
|
166
|
+
/** The value of a setting in a configuration. */
|
|
167
|
+
function readSetting(config, path) {
|
|
168
|
+
const [section, key] = path.split(".");
|
|
169
|
+
return config[section][key];
|
|
170
|
+
}
|
|
171
|
+
/** The settings whose draft differs from the saved value. */
|
|
172
|
+
function changedSettings(settings, drafts, saved) {
|
|
173
|
+
return settings.filter((setting) => {
|
|
174
|
+
const draft = drafts[setting.path];
|
|
175
|
+
return draft !== void 0 && draft.trim() !== setting.format(readSetting(saved, setting.path));
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* The patch that saves the changed settings, and only those: an untouched value must not end up in
|
|
180
|
+
* the config file. One unreadable draft means nothing is saved.
|
|
181
|
+
*/
|
|
182
|
+
function buildPatch(settings, drafts, saved) {
|
|
183
|
+
const patch = {};
|
|
184
|
+
const errors = {};
|
|
185
|
+
for (const setting of changedSettings(settings, drafts, saved)) {
|
|
186
|
+
const parsed = setting.parse(drafts[setting.path]);
|
|
187
|
+
if (!parsed.ok) {
|
|
188
|
+
errors[setting.path] = parsed.message;
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
const [section, key] = setting.path.split(".");
|
|
192
|
+
(patch[section] ??= {})[key] = parsed.value;
|
|
193
|
+
}
|
|
194
|
+
return Object.keys(errors).length > 0 ? {
|
|
195
|
+
ok: false,
|
|
196
|
+
errors
|
|
197
|
+
} : {
|
|
198
|
+
ok: true,
|
|
199
|
+
patch
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
var MCP_ENABLED = {
|
|
203
|
+
...onOff,
|
|
204
|
+
path: "mcp.enabled",
|
|
205
|
+
label: "Playwright MCP",
|
|
206
|
+
help: () => "AI agents connect to it to drive a browser on the VM.",
|
|
207
|
+
consequence: (saved) => [saved ? INSTALLS : "AI agents can't connect to a browser through it while it is off."]
|
|
208
|
+
};
|
|
209
|
+
/** What each level of the bridge log holds. */
|
|
210
|
+
var LEVELS = {
|
|
211
|
+
error: "errors only",
|
|
212
|
+
warn: "errors and warnings",
|
|
213
|
+
info: "normal operation",
|
|
214
|
+
debug: "everything, with the speech"
|
|
215
|
+
};
|
|
216
|
+
var LOG_LEVEL = {
|
|
217
|
+
path: "log.level",
|
|
218
|
+
label: "Log level",
|
|
219
|
+
control: {
|
|
220
|
+
kind: "select",
|
|
221
|
+
options: LOG_LEVELS.map((value) => ({
|
|
222
|
+
value,
|
|
223
|
+
label: `${value} (${LEVELS[value]})`
|
|
224
|
+
}))
|
|
225
|
+
},
|
|
226
|
+
help: () => "How much the bridge writes to its log. At debug that includes everything the screen reader says, in the log file. Default info.",
|
|
227
|
+
format: (level) => level,
|
|
228
|
+
parse: (text) => ({
|
|
229
|
+
ok: true,
|
|
230
|
+
value: text
|
|
231
|
+
}),
|
|
232
|
+
describe: (level) => level,
|
|
233
|
+
consequence: (saved) => saved === "debug" ? ["What the screen reader says is then written to the log file."] : []
|
|
234
|
+
};
|
|
235
|
+
/** The settings with a UI element. */
|
|
236
|
+
var SETTINGS = [
|
|
237
|
+
TCP_PORT,
|
|
238
|
+
TEXT_ENCODING,
|
|
239
|
+
BUFFER_SIZE,
|
|
240
|
+
PLAYWRIGHT_ENABLED,
|
|
241
|
+
PLAYWRIGHT_VERSION,
|
|
242
|
+
MCP_ENABLED,
|
|
243
|
+
LOG_LEVEL
|
|
244
|
+
];
|
|
245
|
+
/** Whether the saved value of a setting waits for a restart. A flag or variable keeps winning. */
|
|
246
|
+
function isPending(path, active, saved, overrides) {
|
|
247
|
+
return overrides[path] === void 0 && readSetting(active, path) !== readSetting(saved, path);
|
|
248
|
+
}
|
|
249
|
+
var valueAt = (config, path) => {
|
|
250
|
+
const [section, key] = path.split(".");
|
|
251
|
+
return config[section][key];
|
|
252
|
+
};
|
|
253
|
+
/**
|
|
254
|
+
* Everything that waits for a restart, also settings saved through the API that have no field
|
|
255
|
+
* here.
|
|
256
|
+
*/
|
|
257
|
+
function waitingForRestart(active, saved, overrides, context) {
|
|
258
|
+
return pendingFields(active, saved).filter((path) => overrides[path] === void 0).map((path) => {
|
|
259
|
+
const setting = SETTINGS.find((candidate) => candidate.path === path);
|
|
260
|
+
if (setting === void 0) {
|
|
261
|
+
const text = (config) => JSON.stringify(valueAt(config, path));
|
|
262
|
+
return {
|
|
263
|
+
path,
|
|
264
|
+
label: path,
|
|
265
|
+
from: text(active),
|
|
266
|
+
to: text(saved),
|
|
267
|
+
consequence: []
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
const from = readSetting(active, setting.path);
|
|
271
|
+
const to = readSetting(saved, setting.path);
|
|
272
|
+
return {
|
|
273
|
+
path,
|
|
274
|
+
label: setting.label,
|
|
275
|
+
from: setting.describe(from, context),
|
|
276
|
+
to: setting.describe(to, {
|
|
277
|
+
...context,
|
|
278
|
+
runningPlaywright: null
|
|
279
|
+
}),
|
|
280
|
+
consequence: setting.consequence(to, from)
|
|
281
|
+
};
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Puts a failed save into the form's terms. The bridge names one setting (`details.field`) by its
|
|
286
|
+
* dotted path, which isn't always the one that was changed: two listeners on one port are reported
|
|
287
|
+
* on the later one. So the field is the named one if the form has it, else one the message names.
|
|
288
|
+
*/
|
|
289
|
+
function explainRejection(cause, settings) {
|
|
290
|
+
if (!(cause instanceof Error)) return {
|
|
291
|
+
field: null,
|
|
292
|
+
message: "The settings could not be saved."
|
|
293
|
+
};
|
|
294
|
+
if (!(cause instanceof SettingRejected) || cause.field === void 0) return {
|
|
295
|
+
field: null,
|
|
296
|
+
message: cause.message
|
|
297
|
+
};
|
|
298
|
+
const target = settings.find((setting) => setting.path === cause.field) ?? settings.find((setting) => cause.message.includes(setting.path));
|
|
299
|
+
const readable = SETTINGS.reduce((message, setting) => message.replaceAll(setting.path, setting.label), cause.message);
|
|
300
|
+
return {
|
|
301
|
+
field: target?.path ?? null,
|
|
302
|
+
message: `${readable}. Nothing was saved.`
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
// src/lib/components/RestartSummary/RestartSummary.svelte
|
|
306
|
+
function RestartSummary($$renderer, $$props) {
|
|
307
|
+
$$renderer.component(($$renderer) => {
|
|
308
|
+
/** Whether the last read of the configuration worked. */
|
|
309
|
+
/** Reads the configuration and the status again, after a restart. */
|
|
310
|
+
let { changes, reachable, onCheck } = $$props;
|
|
311
|
+
/** What the last check found; empty until someone checks. */
|
|
312
|
+
let result = "";
|
|
313
|
+
const counted = (count) => count === 1 ? "1 change waits for a restart" : `${count} changes wait for a restart`;
|
|
314
|
+
if (changes.length > 0) {
|
|
315
|
+
$$renderer.push(`<!--[0--><section aria-labelledby="restart-heading" class="svelte-1ko3bij"><h2 id="restart-heading" class="svelte-1ko3bij">${escape_html(counted(changes.length))}</h2> <ul class="svelte-1ko3bij"><!--[-->`);
|
|
316
|
+
const each_array = ensure_array_like(changes);
|
|
317
|
+
for (let $$index_1 = 0, $$length = each_array.length; $$index_1 < $$length; $$index_1++) {
|
|
318
|
+
let change = each_array[$$index_1];
|
|
319
|
+
$$renderer.push(`<li class="svelte-1ko3bij"><strong>${escape_html(change.label)}:</strong> ${escape_html(change.from)} → ${escape_html(change.to)}. <!--[-->`);
|
|
320
|
+
const each_array_1 = ensure_array_like(change.consequence);
|
|
321
|
+
for (let index = 0, $$length = each_array_1.length; index < $$length; index++) {
|
|
322
|
+
let fragment = each_array_1[index];
|
|
323
|
+
if (typeof fragment === "string") $$renderer.push(`<!--[0-->${escape_html(fragment)}`);
|
|
324
|
+
else $$renderer.push(`<!--[-1--><code class="svelte-1ko3bij">${escape_html(fragment.code)}</code>`);
|
|
325
|
+
$$renderer.push(`<!--]-->`);
|
|
326
|
+
}
|
|
327
|
+
$$renderer.push(`<!--]--></li>`);
|
|
328
|
+
}
|
|
329
|
+
$$renderer.push(`<!--]--></ul> <p class="svelte-1ko3bij">Restarting the bridge empties the recorded speech and sessions.</p> <md-outlined-button type="button" class="svelte-1ko3bij">Check again</md-outlined-button></section>`);
|
|
330
|
+
} else $$renderer.push("<!--[-1-->");
|
|
331
|
+
$$renderer.push(`<!--]--> <p role="status" tabindex="-1" class="result svelte-1ko3bij">${escape_html(result)}</p>`);
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
// ../../node_modules/.pnpm/@material+web@2.5.0/node_modules/@material/web/list/internal/list-navigation-helpers.js
|
|
335
|
+
/**
|
|
336
|
+
* @license
|
|
337
|
+
* Copyright 2023 Google LLC
|
|
338
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
339
|
+
*/
|
|
340
|
+
/**
|
|
341
|
+
* Activates the first non-disabled item of a given array of items.
|
|
342
|
+
*
|
|
343
|
+
* @param items {Array<ListItem>} The items from which to activate the
|
|
344
|
+
* first item.
|
|
345
|
+
* @param isActivatable Function to determine if an item can be activated.
|
|
346
|
+
* Defaults to non-disabled items.
|
|
347
|
+
*/
|
|
348
|
+
function activateFirstItem(items, isActivatable = isItemNotDisabled) {
|
|
349
|
+
const firstItem = getFirstActivatableItem(items, isActivatable);
|
|
350
|
+
if (firstItem) {
|
|
351
|
+
firstItem.tabIndex = 0;
|
|
352
|
+
firstItem.focus();
|
|
353
|
+
}
|
|
354
|
+
return firstItem;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Activates the last non-disabled item of a given array of items.
|
|
358
|
+
*
|
|
359
|
+
* @param items {Array<ListItem>} The items from which to activate the
|
|
360
|
+
* last item.
|
|
361
|
+
* @param isActivatable Function to determine if an item can be activated.
|
|
362
|
+
* Defaults to non-disabled items.
|
|
363
|
+
* @nocollapse
|
|
364
|
+
*/
|
|
365
|
+
function activateLastItem(items, isActivatable = isItemNotDisabled) {
|
|
366
|
+
const lastItem = getLastActivatableItem(items, isActivatable);
|
|
367
|
+
if (lastItem) {
|
|
368
|
+
lastItem.tabIndex = 0;
|
|
369
|
+
lastItem.focus();
|
|
370
|
+
}
|
|
371
|
+
return lastItem;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Retrieves the first activated item of a given array of items.
|
|
375
|
+
*
|
|
376
|
+
* @param items {Array<ListItem>} The items to search.
|
|
377
|
+
* @param isActivatable Function to determine if an item can be activated.
|
|
378
|
+
* Defaults to non-disabled items.
|
|
379
|
+
* @return A record of the first activated item including the item and the
|
|
380
|
+
* index of the item or `null` if none are activated.
|
|
381
|
+
* @nocollapse
|
|
382
|
+
*/
|
|
383
|
+
function getActiveItem(items, isActivatable = isItemNotDisabled) {
|
|
384
|
+
for (let i = 0; i < items.length; i++) {
|
|
385
|
+
const item = items[i];
|
|
386
|
+
if (item.tabIndex === 0 && isActivatable(item)) return {
|
|
387
|
+
item,
|
|
388
|
+
index: i
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
return null;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Retrieves the first non-disabled item of a given array of items. This
|
|
395
|
+
* the first item that is not disabled.
|
|
396
|
+
*
|
|
397
|
+
* @param items {Array<ListItem>} The items to search.
|
|
398
|
+
* @param isActivatable Function to determine if an item can be activated.
|
|
399
|
+
* Defaults to non-disabled items.
|
|
400
|
+
* @return The first activatable item or `null` if none are activatable.
|
|
401
|
+
* @nocollapse
|
|
402
|
+
*/
|
|
403
|
+
function getFirstActivatableItem(items, isActivatable = isItemNotDisabled) {
|
|
404
|
+
for (const item of items) if (isActivatable(item)) return item;
|
|
405
|
+
return null;
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Retrieves the last non-disabled item of a given array of items.
|
|
409
|
+
*
|
|
410
|
+
* @param items {Array<ListItem>} The items to search.
|
|
411
|
+
* @param isActivatable Function to determine if an item can be activated.
|
|
412
|
+
* Defaults to non-disabled items.
|
|
413
|
+
* @return The last activatable item or `null` if none are activatable.
|
|
414
|
+
* @nocollapse
|
|
415
|
+
*/
|
|
416
|
+
function getLastActivatableItem(items, isActivatable = isItemNotDisabled) {
|
|
417
|
+
for (let i = items.length - 1; i >= 0; i--) {
|
|
418
|
+
const item = items[i];
|
|
419
|
+
if (isActivatable(item)) return item;
|
|
420
|
+
}
|
|
421
|
+
return null;
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Retrieves the next non-disabled item of a given array of items.
|
|
425
|
+
*
|
|
426
|
+
* @param items {Array<ListItem>} The items to search.
|
|
427
|
+
* @param index {{index: number}} The index to search from.
|
|
428
|
+
* @param isActivatable Function to determine if an item can be activated.
|
|
429
|
+
* Defaults to non-disabled items.
|
|
430
|
+
* @param wrap If true, then the next item at the end of the list is the first
|
|
431
|
+
* item. Defaults to true.
|
|
432
|
+
* @return The next activatable item or `null` if none are activatable.
|
|
433
|
+
*/
|
|
434
|
+
function getNextItem(items, index, isActivatable = isItemNotDisabled, wrap = true) {
|
|
435
|
+
for (let i = 1; i < items.length; i++) {
|
|
436
|
+
const nextIndex = (i + index) % items.length;
|
|
437
|
+
if (nextIndex < index && !wrap) return null;
|
|
438
|
+
const item = items[nextIndex];
|
|
439
|
+
if (isActivatable(item)) return item;
|
|
440
|
+
}
|
|
441
|
+
return items[index] ? items[index] : null;
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Retrieves the previous non-disabled item of a given array of items.
|
|
445
|
+
*
|
|
446
|
+
* @param items {Array<ListItem>} The items to search.
|
|
447
|
+
* @param index {{index: number}} The index to search from.
|
|
448
|
+
* @param isActivatable Function to determine if an item can be activated.
|
|
449
|
+
* Defaults to non-disabled items.
|
|
450
|
+
* @param wrap If true, then the previous item at the beginning of the list is
|
|
451
|
+
* the last item. Defaults to true.
|
|
452
|
+
* @return The previous activatable item or `null` if none are activatable.
|
|
453
|
+
*/
|
|
454
|
+
function getPrevItem(items, index, isActivatable = isItemNotDisabled, wrap = true) {
|
|
455
|
+
for (let i = 1; i < items.length; i++) {
|
|
456
|
+
const prevIndex = (index - i + items.length) % items.length;
|
|
457
|
+
if (prevIndex > index && !wrap) return null;
|
|
458
|
+
const item = items[prevIndex];
|
|
459
|
+
if (isActivatable(item)) return item;
|
|
460
|
+
}
|
|
461
|
+
return items[index] ? items[index] : null;
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Activates the next item and focuses it. If nothing is currently activated,
|
|
465
|
+
* activates the first item.
|
|
466
|
+
*/
|
|
467
|
+
function activateNextItem(items, activeItemRecord, isActivatable = isItemNotDisabled, wrap = true) {
|
|
468
|
+
if (activeItemRecord) {
|
|
469
|
+
const next = getNextItem(items, activeItemRecord.index, isActivatable, wrap);
|
|
470
|
+
if (next) {
|
|
471
|
+
next.tabIndex = 0;
|
|
472
|
+
next.focus();
|
|
473
|
+
}
|
|
474
|
+
return next;
|
|
475
|
+
} else return activateFirstItem(items, isActivatable);
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Activates the previous item and focuses it. If nothing is currently
|
|
479
|
+
* activated, activates the last item.
|
|
480
|
+
*/
|
|
481
|
+
function activatePreviousItem(items, activeItemRecord, isActivatable = isItemNotDisabled, wrap = true) {
|
|
482
|
+
if (activeItemRecord) {
|
|
483
|
+
const prev = getPrevItem(items, activeItemRecord.index, isActivatable, wrap);
|
|
484
|
+
if (prev) {
|
|
485
|
+
prev.tabIndex = 0;
|
|
486
|
+
prev.focus();
|
|
487
|
+
}
|
|
488
|
+
return prev;
|
|
489
|
+
} else return activateLastItem(items, isActivatable);
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* The default `isActivatable` function, which checks if an item is not
|
|
493
|
+
* disabled.
|
|
494
|
+
*
|
|
495
|
+
* @param item The item to check.
|
|
496
|
+
* @return true if `item.disabled` is `false.
|
|
497
|
+
*/
|
|
498
|
+
function isItemNotDisabled(item) {
|
|
499
|
+
return !item.disabled;
|
|
500
|
+
}
|
|
501
|
+
// ../../node_modules/.pnpm/@material+web@2.5.0/node_modules/@material/web/list/internal/list-controller.js
|
|
502
|
+
/**
|
|
503
|
+
* @license
|
|
504
|
+
* Copyright 2023 Google LLC
|
|
505
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
506
|
+
*/
|
|
507
|
+
/**
|
|
508
|
+
* Default keys that trigger navigation.
|
|
509
|
+
*/
|
|
510
|
+
var NavigableKeys = {
|
|
511
|
+
ArrowDown: "ArrowDown",
|
|
512
|
+
ArrowLeft: "ArrowLeft",
|
|
513
|
+
ArrowUp: "ArrowUp",
|
|
514
|
+
ArrowRight: "ArrowRight",
|
|
515
|
+
Home: "Home",
|
|
516
|
+
End: "End"
|
|
517
|
+
};
|
|
518
|
+
/**
|
|
519
|
+
* A controller that handles list keyboard navigation and item management.
|
|
520
|
+
*/
|
|
521
|
+
var ListController = class {
|
|
522
|
+
constructor(config) {
|
|
523
|
+
/**
|
|
524
|
+
* Handles keyboard navigation. Should be bound to the node that will act as
|
|
525
|
+
* the List.
|
|
526
|
+
*/
|
|
527
|
+
this.handleKeydown = (event) => {
|
|
528
|
+
const key = event.key;
|
|
529
|
+
if (event.defaultPrevented || !this.isNavigableKey(key)) return;
|
|
530
|
+
const items = this.items;
|
|
531
|
+
if (!items.length) return;
|
|
532
|
+
const activeItemRecord = getActiveItem(items, this.isActivatable);
|
|
533
|
+
event.preventDefault();
|
|
534
|
+
const isRtl = this.isRtl();
|
|
535
|
+
const inlinePrevious = isRtl ? NavigableKeys.ArrowRight : NavigableKeys.ArrowLeft;
|
|
536
|
+
const inlineNext = isRtl ? NavigableKeys.ArrowLeft : NavigableKeys.ArrowRight;
|
|
537
|
+
let nextActiveItem = null;
|
|
538
|
+
switch (key) {
|
|
539
|
+
case NavigableKeys.ArrowDown:
|
|
540
|
+
case inlineNext:
|
|
541
|
+
nextActiveItem = activateNextItem(items, activeItemRecord, this.isActivatable, this.wrapNavigation());
|
|
542
|
+
break;
|
|
543
|
+
case NavigableKeys.ArrowUp:
|
|
544
|
+
case inlinePrevious:
|
|
545
|
+
nextActiveItem = activatePreviousItem(items, activeItemRecord, this.isActivatable, this.wrapNavigation());
|
|
546
|
+
break;
|
|
547
|
+
case NavigableKeys.Home:
|
|
548
|
+
nextActiveItem = activateFirstItem(items, this.isActivatable);
|
|
549
|
+
break;
|
|
550
|
+
case NavigableKeys.End: nextActiveItem = activateLastItem(items, this.isActivatable);
|
|
551
|
+
}
|
|
552
|
+
if (nextActiveItem && activeItemRecord && activeItemRecord.item !== nextActiveItem) activeItemRecord.item.tabIndex = -1;
|
|
553
|
+
};
|
|
554
|
+
/**
|
|
555
|
+
* Listener to be bound to the `deactivate-items` item event.
|
|
556
|
+
*/
|
|
557
|
+
this.onDeactivateItems = () => {
|
|
558
|
+
const items = this.items;
|
|
559
|
+
for (const item of items) this.deactivateItem(item);
|
|
560
|
+
};
|
|
561
|
+
/**
|
|
562
|
+
* Listener to be bound to the `request-activation` item event..
|
|
563
|
+
*/
|
|
564
|
+
this.onRequestActivation = (event) => {
|
|
565
|
+
this.onDeactivateItems();
|
|
566
|
+
const target = event.target;
|
|
567
|
+
this.activateItem(target);
|
|
568
|
+
target.focus();
|
|
569
|
+
};
|
|
570
|
+
/**
|
|
571
|
+
* Listener to be bound to the `slotchange` event for the slot that renders
|
|
572
|
+
* the items.
|
|
573
|
+
*/
|
|
574
|
+
this.onSlotchange = () => {
|
|
575
|
+
const items = this.items;
|
|
576
|
+
let encounteredActivated = false;
|
|
577
|
+
for (const item of items) {
|
|
578
|
+
if (!item.disabled && item.tabIndex > -1 && !encounteredActivated) {
|
|
579
|
+
encounteredActivated = true;
|
|
580
|
+
item.tabIndex = 0;
|
|
581
|
+
continue;
|
|
582
|
+
}
|
|
583
|
+
item.tabIndex = -1;
|
|
584
|
+
}
|
|
585
|
+
if (encounteredActivated) return;
|
|
586
|
+
const firstActivatableItem = getFirstActivatableItem(items, this.isActivatable);
|
|
587
|
+
if (!firstActivatableItem) return;
|
|
588
|
+
firstActivatableItem.tabIndex = 0;
|
|
589
|
+
};
|
|
590
|
+
const { isItem, getPossibleItems, isRtl, deactivateItem, activateItem, isNavigableKey, isActivatable, wrapNavigation } = config;
|
|
591
|
+
this.isItem = isItem;
|
|
592
|
+
this.getPossibleItems = getPossibleItems;
|
|
593
|
+
this.isRtl = isRtl;
|
|
594
|
+
this.deactivateItem = deactivateItem;
|
|
595
|
+
this.activateItem = activateItem;
|
|
596
|
+
this.isNavigableKey = isNavigableKey;
|
|
597
|
+
this.isActivatable = isActivatable;
|
|
598
|
+
this.wrapNavigation = wrapNavigation ?? (() => true);
|
|
599
|
+
}
|
|
600
|
+
/**
|
|
601
|
+
* The items being managed by the list. Additionally, attempts to see if the
|
|
602
|
+
* object has a sub-item in the `.item` property.
|
|
603
|
+
*/
|
|
604
|
+
get items() {
|
|
605
|
+
const maybeItems = this.getPossibleItems();
|
|
606
|
+
const items = [];
|
|
607
|
+
for (const itemOrParent of maybeItems) {
|
|
608
|
+
if (this.isItem(itemOrParent)) {
|
|
609
|
+
items.push(itemOrParent);
|
|
610
|
+
continue;
|
|
611
|
+
}
|
|
612
|
+
const subItem = itemOrParent.item;
|
|
613
|
+
if (subItem && this.isItem(subItem)) items.push(subItem);
|
|
614
|
+
}
|
|
615
|
+
return items;
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* Activates the next item in the list. If at the end of the list, the first
|
|
619
|
+
* item will be activated.
|
|
620
|
+
*
|
|
621
|
+
* @return The activated list item or `null` if there are no items.
|
|
622
|
+
*/
|
|
623
|
+
activateNextItem() {
|
|
624
|
+
const items = this.items;
|
|
625
|
+
const activeItemRecord = getActiveItem(items, this.isActivatable);
|
|
626
|
+
if (activeItemRecord) activeItemRecord.item.tabIndex = -1;
|
|
627
|
+
return activateNextItem(items, activeItemRecord, this.isActivatable, this.wrapNavigation());
|
|
628
|
+
}
|
|
629
|
+
/**
|
|
630
|
+
* Activates the previous item in the list. If at the start of the list, the
|
|
631
|
+
* last item will be activated.
|
|
632
|
+
*
|
|
633
|
+
* @return The activated list item or `null` if there are no items.
|
|
634
|
+
*/
|
|
635
|
+
activatePreviousItem() {
|
|
636
|
+
const items = this.items;
|
|
637
|
+
const activeItemRecord = getActiveItem(items, this.isActivatable);
|
|
638
|
+
if (activeItemRecord) activeItemRecord.item.tabIndex = -1;
|
|
639
|
+
return activatePreviousItem(items, activeItemRecord, this.isActivatable, this.wrapNavigation());
|
|
640
|
+
}
|
|
641
|
+
};
|
|
642
|
+
// ../../node_modules/.pnpm/@material+web@2.5.0/node_modules/@material/web/menu/internal/controllers/shared.js
|
|
643
|
+
/**
|
|
644
|
+
* @license
|
|
645
|
+
* Copyright 2023 Google LLC
|
|
646
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
647
|
+
*/
|
|
648
|
+
/**
|
|
649
|
+
* Creates an event that closes any parent menus.
|
|
650
|
+
*/
|
|
651
|
+
function createCloseMenuEvent(initiator, reason) {
|
|
652
|
+
return new CustomEvent("close-menu", {
|
|
653
|
+
bubbles: true,
|
|
654
|
+
composed: true,
|
|
655
|
+
detail: {
|
|
656
|
+
initiator,
|
|
657
|
+
reason,
|
|
658
|
+
itemPath: [initiator]
|
|
659
|
+
}
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* Creates a default close menu event used by md-menu.
|
|
664
|
+
*/
|
|
665
|
+
var createDefaultCloseMenuEvent = createCloseMenuEvent;
|
|
666
|
+
/**
|
|
667
|
+
* Keys that are used for selection in menus.
|
|
668
|
+
*/
|
|
669
|
+
var SelectionKey = {
|
|
670
|
+
SPACE: "Space",
|
|
671
|
+
ENTER: "Enter"
|
|
672
|
+
};
|
|
673
|
+
/**
|
|
674
|
+
* Default close `Reason` kind values.
|
|
675
|
+
*/
|
|
676
|
+
var CloseReason = {
|
|
677
|
+
CLICK_SELECTION: "click-selection",
|
|
678
|
+
KEYDOWN: "keydown"
|
|
679
|
+
};
|
|
680
|
+
/**
|
|
681
|
+
* Keys that can close menus.
|
|
682
|
+
*/
|
|
683
|
+
var KeydownCloseKey = {
|
|
684
|
+
ESCAPE: "Escape",
|
|
685
|
+
SPACE: SelectionKey.SPACE,
|
|
686
|
+
ENTER: SelectionKey.ENTER
|
|
687
|
+
};
|
|
688
|
+
/**
|
|
689
|
+
* Determines whether the given key code is a key code that should close the
|
|
690
|
+
* menu.
|
|
691
|
+
*
|
|
692
|
+
* @param code The KeyboardEvent code to check.
|
|
693
|
+
* @return Whether or not the key code is in the predetermined list to close the
|
|
694
|
+
* menu.
|
|
695
|
+
*/
|
|
696
|
+
function isClosableKey(code) {
|
|
697
|
+
return Object.values(KeydownCloseKey).some((value) => value === code);
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* Determines whether the given key code is a key code that should select a menu
|
|
701
|
+
* item.
|
|
702
|
+
*
|
|
703
|
+
* @param code They KeyboardEvent code to check.
|
|
704
|
+
* @return Whether or not the key code is in the predetermined list to select a
|
|
705
|
+
* menu item.
|
|
706
|
+
*/
|
|
707
|
+
function isSelectableKey(code) {
|
|
708
|
+
return Object.values(SelectionKey).some((value) => value === code);
|
|
709
|
+
}
|
|
710
|
+
/**
|
|
711
|
+
* Determines whether a target element is contained inside another element's
|
|
712
|
+
* composed tree.
|
|
713
|
+
*
|
|
714
|
+
* @param target The potential contained element.
|
|
715
|
+
* @param container The potential containing element of the target.
|
|
716
|
+
* @returns Whether the target element is contained inside the container's
|
|
717
|
+
* composed subtree
|
|
718
|
+
*/
|
|
719
|
+
function isElementInSubtree(target, container) {
|
|
720
|
+
const focusEv = new Event("md-contains", {
|
|
721
|
+
bubbles: true,
|
|
722
|
+
composed: true
|
|
723
|
+
});
|
|
724
|
+
let composedPath = [];
|
|
725
|
+
const listener = (ev) => {
|
|
726
|
+
composedPath = ev.composedPath();
|
|
727
|
+
};
|
|
728
|
+
container.addEventListener("md-contains", listener);
|
|
729
|
+
target.dispatchEvent(focusEv);
|
|
730
|
+
container.removeEventListener("md-contains", listener);
|
|
731
|
+
return composedPath.length > 0;
|
|
732
|
+
}
|
|
733
|
+
/**
|
|
734
|
+
* Element to focus on when menu is first opened.
|
|
735
|
+
*/
|
|
736
|
+
var FocusState = {
|
|
737
|
+
NONE: "none",
|
|
738
|
+
LIST_ROOT: "list-root",
|
|
739
|
+
FIRST_ITEM: "first-item",
|
|
740
|
+
LAST_ITEM: "last-item"
|
|
741
|
+
};
|
|
742
|
+
// ../../node_modules/.pnpm/@material+web@2.5.0/node_modules/@material/web/menu/internal/controllers/surfacePositionController.js
|
|
743
|
+
/**
|
|
744
|
+
* @license
|
|
745
|
+
* Copyright 2023 Google LLC
|
|
746
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
747
|
+
*/
|
|
748
|
+
/**
|
|
749
|
+
* An enum of supported Menu corners
|
|
750
|
+
*/
|
|
751
|
+
var Corner = {
|
|
752
|
+
END_START: "end-start",
|
|
753
|
+
END_END: "end-end",
|
|
754
|
+
START_START: "start-start",
|
|
755
|
+
START_END: "start-end"
|
|
756
|
+
};
|
|
757
|
+
/**
|
|
758
|
+
* Given a surface, an anchor, corners, and some options, this surface will
|
|
759
|
+
* calculate the position of a surface to align the two given corners and keep
|
|
760
|
+
* the surface inside the window viewport. It also provides a StyleInfo map that
|
|
761
|
+
* can be applied to the surface to handle visiblility and position.
|
|
762
|
+
*/
|
|
763
|
+
var SurfacePositionController = class {
|
|
764
|
+
/**
|
|
765
|
+
* @param host The host to connect the controller to.
|
|
766
|
+
* @param getProperties A function that returns the properties for the
|
|
767
|
+
* controller.
|
|
768
|
+
*/
|
|
769
|
+
constructor(host, getProperties) {
|
|
770
|
+
this.host = host;
|
|
771
|
+
this.getProperties = getProperties;
|
|
772
|
+
this.surfaceStylesInternal = { "display": "none" };
|
|
773
|
+
this.lastValues = { isOpen: false };
|
|
774
|
+
this.host.addController(this);
|
|
775
|
+
}
|
|
776
|
+
/**
|
|
777
|
+
* The StyleInfo map to apply to the surface via Lit's stylemap
|
|
778
|
+
*/
|
|
779
|
+
get surfaceStyles() {
|
|
780
|
+
return this.surfaceStylesInternal;
|
|
781
|
+
}
|
|
782
|
+
/**
|
|
783
|
+
* Calculates the surface's new position required so that the surface's
|
|
784
|
+
* `surfaceCorner` aligns to the anchor's `anchorCorner` while keeping the
|
|
785
|
+
* surface inside the window viewport. This positioning also respects RTL by
|
|
786
|
+
* checking `getComputedStyle()` on the surface element.
|
|
787
|
+
*/
|
|
788
|
+
async position() {
|
|
789
|
+
const { surfaceEl, anchorEl, anchorCorner: anchorCornerRaw, surfaceCorner: surfaceCornerRaw, positioning, xOffset, yOffset, disableBlockFlip, disableInlineFlip, repositionStrategy } = this.getProperties();
|
|
790
|
+
const anchorCorner = anchorCornerRaw.toLowerCase().trim();
|
|
791
|
+
const surfaceCorner = surfaceCornerRaw.toLowerCase().trim();
|
|
792
|
+
if (!surfaceEl || !anchorEl) return;
|
|
793
|
+
const windowInnerWidth = window.innerWidth;
|
|
794
|
+
const windowInnerHeight = window.innerHeight;
|
|
795
|
+
const div = document.createElement("div");
|
|
796
|
+
div.style.opacity = "0";
|
|
797
|
+
div.style.position = "fixed";
|
|
798
|
+
div.style.display = "block";
|
|
799
|
+
div.style.inset = "0";
|
|
800
|
+
document.body.appendChild(div);
|
|
801
|
+
const scrollbarTestRect = div.getBoundingClientRect();
|
|
802
|
+
div.remove();
|
|
803
|
+
const blockScrollbarHeight = window.innerHeight - scrollbarTestRect.bottom;
|
|
804
|
+
const inlineScrollbarWidth = window.innerWidth - scrollbarTestRect.right;
|
|
805
|
+
this.surfaceStylesInternal = {
|
|
806
|
+
"display": "block",
|
|
807
|
+
"opacity": "0"
|
|
808
|
+
};
|
|
809
|
+
this.host.requestUpdate();
|
|
810
|
+
await this.host.updateComplete;
|
|
811
|
+
if (surfaceEl.popover && surfaceEl.isConnected) surfaceEl.showPopover();
|
|
812
|
+
const surfaceRect = surfaceEl.getSurfacePositionClientRect ? surfaceEl.getSurfacePositionClientRect() : surfaceEl.getBoundingClientRect();
|
|
813
|
+
const anchorRect = anchorEl.getSurfacePositionClientRect ? anchorEl.getSurfacePositionClientRect() : anchorEl.getBoundingClientRect();
|
|
814
|
+
const [surfaceBlock, surfaceInline] = surfaceCorner.split("-");
|
|
815
|
+
const [anchorBlock, anchorInline] = anchorCorner.split("-");
|
|
816
|
+
const isLTR = getComputedStyle(surfaceEl).direction === "ltr";
|
|
817
|
+
let { blockInset, blockOutOfBoundsCorrection, surfaceBlockProperty } = this.calculateBlock({
|
|
818
|
+
surfaceRect,
|
|
819
|
+
anchorRect,
|
|
820
|
+
anchorBlock,
|
|
821
|
+
surfaceBlock,
|
|
822
|
+
yOffset,
|
|
823
|
+
positioning,
|
|
824
|
+
windowInnerHeight,
|
|
825
|
+
blockScrollbarHeight
|
|
826
|
+
});
|
|
827
|
+
if (blockOutOfBoundsCorrection && !disableBlockFlip) {
|
|
828
|
+
const flippedSurfaceBlock = surfaceBlock === "start" ? "end" : "start";
|
|
829
|
+
const flippedAnchorBlock = anchorBlock === "start" ? "end" : "start";
|
|
830
|
+
const flippedBlock = this.calculateBlock({
|
|
831
|
+
surfaceRect,
|
|
832
|
+
anchorRect,
|
|
833
|
+
anchorBlock: flippedAnchorBlock,
|
|
834
|
+
surfaceBlock: flippedSurfaceBlock,
|
|
835
|
+
yOffset,
|
|
836
|
+
positioning,
|
|
837
|
+
windowInnerHeight,
|
|
838
|
+
blockScrollbarHeight
|
|
839
|
+
});
|
|
840
|
+
if (blockOutOfBoundsCorrection > flippedBlock.blockOutOfBoundsCorrection) {
|
|
841
|
+
blockInset = flippedBlock.blockInset;
|
|
842
|
+
blockOutOfBoundsCorrection = flippedBlock.blockOutOfBoundsCorrection;
|
|
843
|
+
surfaceBlockProperty = flippedBlock.surfaceBlockProperty;
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
let { inlineInset, inlineOutOfBoundsCorrection, surfaceInlineProperty } = this.calculateInline({
|
|
847
|
+
surfaceRect,
|
|
848
|
+
anchorRect,
|
|
849
|
+
anchorInline,
|
|
850
|
+
surfaceInline,
|
|
851
|
+
xOffset,
|
|
852
|
+
positioning,
|
|
853
|
+
isLTR,
|
|
854
|
+
windowInnerWidth,
|
|
855
|
+
inlineScrollbarWidth
|
|
856
|
+
});
|
|
857
|
+
if (inlineOutOfBoundsCorrection && !disableInlineFlip) {
|
|
858
|
+
const flippedSurfaceInline = surfaceInline === "start" ? "end" : "start";
|
|
859
|
+
const flippedAnchorInline = anchorInline === "start" ? "end" : "start";
|
|
860
|
+
const flippedInline = this.calculateInline({
|
|
861
|
+
surfaceRect,
|
|
862
|
+
anchorRect,
|
|
863
|
+
anchorInline: flippedAnchorInline,
|
|
864
|
+
surfaceInline: flippedSurfaceInline,
|
|
865
|
+
xOffset,
|
|
866
|
+
positioning,
|
|
867
|
+
isLTR,
|
|
868
|
+
windowInnerWidth,
|
|
869
|
+
inlineScrollbarWidth
|
|
870
|
+
});
|
|
871
|
+
if (Math.abs(inlineOutOfBoundsCorrection) > Math.abs(flippedInline.inlineOutOfBoundsCorrection)) {
|
|
872
|
+
inlineInset = flippedInline.inlineInset;
|
|
873
|
+
inlineOutOfBoundsCorrection = flippedInline.inlineOutOfBoundsCorrection;
|
|
874
|
+
surfaceInlineProperty = flippedInline.surfaceInlineProperty;
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
if (repositionStrategy === "move") {
|
|
878
|
+
blockInset = blockInset - blockOutOfBoundsCorrection;
|
|
879
|
+
inlineInset = inlineInset - inlineOutOfBoundsCorrection;
|
|
880
|
+
}
|
|
881
|
+
this.surfaceStylesInternal = {
|
|
882
|
+
"display": "block",
|
|
883
|
+
"opacity": "1",
|
|
884
|
+
[surfaceBlockProperty]: `${blockInset}px`,
|
|
885
|
+
[surfaceInlineProperty]: `${inlineInset}px`
|
|
886
|
+
};
|
|
887
|
+
if (repositionStrategy === "resize") {
|
|
888
|
+
if (blockOutOfBoundsCorrection) this.surfaceStylesInternal["height"] = `${surfaceRect.height - blockOutOfBoundsCorrection}px`;
|
|
889
|
+
if (inlineOutOfBoundsCorrection) this.surfaceStylesInternal["width"] = `${surfaceRect.width - inlineOutOfBoundsCorrection}px`;
|
|
890
|
+
}
|
|
891
|
+
this.host.requestUpdate();
|
|
892
|
+
}
|
|
893
|
+
/**
|
|
894
|
+
* Calculates the css property, the inset, and the out of bounds correction
|
|
895
|
+
* for the surface in the block direction.
|
|
896
|
+
*/
|
|
897
|
+
calculateBlock(config) {
|
|
898
|
+
const { surfaceRect, anchorRect, anchorBlock, surfaceBlock, yOffset, positioning, windowInnerHeight, blockScrollbarHeight } = config;
|
|
899
|
+
const relativeToWindow = positioning === "fixed" || positioning === "document" ? 1 : 0;
|
|
900
|
+
const relativeToDocument = positioning === "document" ? 1 : 0;
|
|
901
|
+
const isSurfaceBlockStart = surfaceBlock === "start" ? 1 : 0;
|
|
902
|
+
const isSurfaceBlockEnd = surfaceBlock === "end" ? 1 : 0;
|
|
903
|
+
const blockAnchorOffset = (anchorBlock !== surfaceBlock ? 1 : 0) * anchorRect.height + yOffset;
|
|
904
|
+
const blockTopLayerOffset = isSurfaceBlockStart * anchorRect.top + isSurfaceBlockEnd * (windowInnerHeight - anchorRect.bottom - blockScrollbarHeight);
|
|
905
|
+
const blockDocumentOffset = isSurfaceBlockStart * window.scrollY - isSurfaceBlockEnd * window.scrollY;
|
|
906
|
+
const blockOutOfBoundsCorrection = Math.abs(Math.min(0, windowInnerHeight - blockTopLayerOffset - blockAnchorOffset - surfaceRect.height));
|
|
907
|
+
return {
|
|
908
|
+
blockInset: relativeToWindow * blockTopLayerOffset + relativeToDocument * blockDocumentOffset + blockAnchorOffset,
|
|
909
|
+
blockOutOfBoundsCorrection,
|
|
910
|
+
surfaceBlockProperty: surfaceBlock === "start" ? "inset-block-start" : "inset-block-end"
|
|
911
|
+
};
|
|
912
|
+
}
|
|
913
|
+
/**
|
|
914
|
+
* Calculates the css property, the inset, and the out of bounds correction
|
|
915
|
+
* for the surface in the inline direction.
|
|
916
|
+
*/
|
|
917
|
+
calculateInline(config) {
|
|
918
|
+
const { isLTR: isLTRBool, surfaceInline, anchorInline, anchorRect, surfaceRect, xOffset, positioning, windowInnerWidth, inlineScrollbarWidth } = config;
|
|
919
|
+
const relativeToWindow = positioning === "fixed" || positioning === "document" ? 1 : 0;
|
|
920
|
+
const relativeToDocument = positioning === "document" ? 1 : 0;
|
|
921
|
+
const isLTR = isLTRBool ? 1 : 0;
|
|
922
|
+
const isRTL = isLTRBool ? 0 : 1;
|
|
923
|
+
const isSurfaceInlineStart = surfaceInline === "start" ? 1 : 0;
|
|
924
|
+
const isSurfaceInlineEnd = surfaceInline === "end" ? 1 : 0;
|
|
925
|
+
const inlineAnchorOffset = (anchorInline !== surfaceInline ? 1 : 0) * anchorRect.width + xOffset;
|
|
926
|
+
const inlineTopLayerOffsetLTR = isSurfaceInlineStart * anchorRect.left + isSurfaceInlineEnd * (windowInnerWidth - anchorRect.right - inlineScrollbarWidth);
|
|
927
|
+
const inlineTopLayerOffsetRTL = isSurfaceInlineStart * (windowInnerWidth - anchorRect.right - inlineScrollbarWidth) + isSurfaceInlineEnd * anchorRect.left;
|
|
928
|
+
const inlineTopLayerOffset = isLTR * inlineTopLayerOffsetLTR + isRTL * inlineTopLayerOffsetRTL;
|
|
929
|
+
const inlineDocumentOffsetLTR = isSurfaceInlineStart * window.scrollX - isSurfaceInlineEnd * window.scrollX;
|
|
930
|
+
const inlineDocumentOffsetRTL = isSurfaceInlineEnd * window.scrollX - isSurfaceInlineStart * window.scrollX;
|
|
931
|
+
const inlineDocumentOffset = isLTR * inlineDocumentOffsetLTR + isRTL * inlineDocumentOffsetRTL;
|
|
932
|
+
const inlineOutOfBoundsCorrection = Math.abs(Math.min(0, windowInnerWidth - inlineTopLayerOffset - inlineAnchorOffset - surfaceRect.width));
|
|
933
|
+
const inlineInset = relativeToWindow * inlineTopLayerOffset + inlineAnchorOffset + relativeToDocument * inlineDocumentOffset;
|
|
934
|
+
let surfaceInlineProperty = surfaceInline === "start" ? "inset-inline-start" : "inset-inline-end";
|
|
935
|
+
if (positioning === "document" || positioning === "fixed") {
|
|
936
|
+
if (surfaceInline === "start" && isLTRBool || surfaceInline === "end" && !isLTRBool) surfaceInlineProperty = "left";
|
|
937
|
+
else surfaceInlineProperty = "right";
|
|
938
|
+
}
|
|
939
|
+
return {
|
|
940
|
+
inlineInset,
|
|
941
|
+
inlineOutOfBoundsCorrection,
|
|
942
|
+
surfaceInlineProperty
|
|
943
|
+
};
|
|
944
|
+
}
|
|
945
|
+
hostUpdate() {
|
|
946
|
+
this.onUpdate();
|
|
947
|
+
}
|
|
948
|
+
hostUpdated() {
|
|
949
|
+
this.onUpdate();
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* Checks whether the properties passed into the controller have changed since
|
|
953
|
+
* the last positioning. If so, it will reposition if the surface is open or
|
|
954
|
+
* close it if the surface should close.
|
|
955
|
+
*/
|
|
956
|
+
async onUpdate() {
|
|
957
|
+
const props = this.getProperties();
|
|
958
|
+
let hasChanged = false;
|
|
959
|
+
for (const [key, value] of Object.entries(props)) {
|
|
960
|
+
hasChanged = hasChanged || value !== this.lastValues[key];
|
|
961
|
+
if (hasChanged) break;
|
|
962
|
+
}
|
|
963
|
+
const openChanged = this.lastValues.isOpen !== props.isOpen;
|
|
964
|
+
const hasAnchor = !!props.anchorEl;
|
|
965
|
+
const hasSurface = !!props.surfaceEl;
|
|
966
|
+
if (hasChanged && hasAnchor && hasSurface) {
|
|
967
|
+
this.lastValues.isOpen = props.isOpen;
|
|
968
|
+
if (props.isOpen) {
|
|
969
|
+
this.lastValues = props;
|
|
970
|
+
await this.position();
|
|
971
|
+
props.onOpen();
|
|
972
|
+
} else if (openChanged) {
|
|
973
|
+
await props.beforeClose();
|
|
974
|
+
this.close();
|
|
975
|
+
props.onClose();
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
/**
|
|
980
|
+
* Hides the surface.
|
|
981
|
+
*/
|
|
982
|
+
close() {
|
|
983
|
+
this.surfaceStylesInternal = { "display": "none" };
|
|
984
|
+
this.host.requestUpdate();
|
|
985
|
+
const surfaceEl = this.getProperties().surfaceEl;
|
|
986
|
+
if (surfaceEl?.popover && surfaceEl?.isConnected) surfaceEl.hidePopover();
|
|
987
|
+
}
|
|
988
|
+
};
|
|
989
|
+
// ../../node_modules/.pnpm/@material+web@2.5.0/node_modules/@material/web/menu/internal/controllers/typeaheadController.js
|
|
990
|
+
/**
|
|
991
|
+
* @license
|
|
992
|
+
* Copyright 2023 Google LLC
|
|
993
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
994
|
+
*/
|
|
995
|
+
/**
|
|
996
|
+
* Indicies to access the TypeaheadRecord tuple type.
|
|
997
|
+
*/
|
|
998
|
+
var TYPEAHEAD_RECORD = {
|
|
999
|
+
INDEX: 0,
|
|
1000
|
+
ITEM: 1,
|
|
1001
|
+
TEXT: 2
|
|
1002
|
+
};
|
|
1003
|
+
/**
|
|
1004
|
+
* This controller listens to `keydown` events and searches the header text of
|
|
1005
|
+
* an array of `MenuItem`s with the corresponding entered keys within the buffer
|
|
1006
|
+
* time and activates the item.
|
|
1007
|
+
*
|
|
1008
|
+
* @example
|
|
1009
|
+
* ```ts
|
|
1010
|
+
* const typeaheadController = new TypeaheadController(() => ({
|
|
1011
|
+
* typeaheadBufferTime: 50,
|
|
1012
|
+
* getItems: () => Array.from(document.querySelectorAll('md-menu-item'))
|
|
1013
|
+
* }));
|
|
1014
|
+
* html`
|
|
1015
|
+
* <div
|
|
1016
|
+
* @keydown=${typeaheadController.onKeydown}
|
|
1017
|
+
* tabindex="0"
|
|
1018
|
+
* class="activeItemText">
|
|
1019
|
+
* <!-- focusable element that will receive keydown events -->
|
|
1020
|
+
* Apple
|
|
1021
|
+
* </div>
|
|
1022
|
+
* <div>
|
|
1023
|
+
* <md-menu-item active header="Apple"></md-menu-item>
|
|
1024
|
+
* <md-menu-item header="Apricot"></md-menu-item>
|
|
1025
|
+
* <md-menu-item header="Banana"></md-menu-item>
|
|
1026
|
+
* <md-menu-item header="Olive"></md-menu-item>
|
|
1027
|
+
* <md-menu-item header="Orange"></md-menu-item>
|
|
1028
|
+
* </div>
|
|
1029
|
+
* `;
|
|
1030
|
+
* ```
|
|
1031
|
+
*/
|
|
1032
|
+
var TypeaheadController = class {
|
|
1033
|
+
/**
|
|
1034
|
+
* @param getProperties A function that returns the options of the typeahead
|
|
1035
|
+
* controller:
|
|
1036
|
+
*
|
|
1037
|
+
* {
|
|
1038
|
+
* getItems: A function that returns an array of menu items to be searched.
|
|
1039
|
+
* typeaheadBufferTime: The maximum time between each keystroke to keep the
|
|
1040
|
+
* current type buffer alive.
|
|
1041
|
+
* }
|
|
1042
|
+
*/
|
|
1043
|
+
constructor(getProperties) {
|
|
1044
|
+
this.getProperties = getProperties;
|
|
1045
|
+
/**
|
|
1046
|
+
* Array of tuples that helps with indexing.
|
|
1047
|
+
*/
|
|
1048
|
+
this.typeaheadRecords = [];
|
|
1049
|
+
/**
|
|
1050
|
+
* Currently-typed text since last buffer timeout
|
|
1051
|
+
*/
|
|
1052
|
+
this.typaheadBuffer = "";
|
|
1053
|
+
/**
|
|
1054
|
+
* The timeout id from the current buffer's setTimeout
|
|
1055
|
+
*/
|
|
1056
|
+
this.cancelTypeaheadTimeout = 0;
|
|
1057
|
+
/**
|
|
1058
|
+
* If we are currently "typing"
|
|
1059
|
+
*/
|
|
1060
|
+
this.isTypingAhead = false;
|
|
1061
|
+
/**
|
|
1062
|
+
* The record of the last active item.
|
|
1063
|
+
*/
|
|
1064
|
+
this.lastActiveRecord = null;
|
|
1065
|
+
/**
|
|
1066
|
+
* Apply this listener to the element that will receive `keydown` events that
|
|
1067
|
+
* should trigger this controller.
|
|
1068
|
+
*
|
|
1069
|
+
* @param event The native browser `KeyboardEvent` from the `keydown` event.
|
|
1070
|
+
*/
|
|
1071
|
+
this.onKeydown = (event) => {
|
|
1072
|
+
if (this.isTypingAhead) this.typeahead(event);
|
|
1073
|
+
else this.beginTypeahead(event);
|
|
1074
|
+
};
|
|
1075
|
+
/**
|
|
1076
|
+
* Ends the current typeahead and clears the buffer.
|
|
1077
|
+
*/
|
|
1078
|
+
this.endTypeahead = () => {
|
|
1079
|
+
this.isTypingAhead = false;
|
|
1080
|
+
this.typaheadBuffer = "";
|
|
1081
|
+
this.typeaheadRecords = [];
|
|
1082
|
+
};
|
|
1083
|
+
}
|
|
1084
|
+
get items() {
|
|
1085
|
+
return this.getProperties().getItems();
|
|
1086
|
+
}
|
|
1087
|
+
get active() {
|
|
1088
|
+
return this.getProperties().active;
|
|
1089
|
+
}
|
|
1090
|
+
/**
|
|
1091
|
+
* Sets up typingahead
|
|
1092
|
+
*/
|
|
1093
|
+
beginTypeahead(event) {
|
|
1094
|
+
if (!this.active) return;
|
|
1095
|
+
if (event.code === "Space" || event.code === "Enter" || event.code.startsWith("Arrow") || event.code === "Escape") return;
|
|
1096
|
+
this.isTypingAhead = true;
|
|
1097
|
+
this.typeaheadRecords = this.items.map((el, index) => [
|
|
1098
|
+
index,
|
|
1099
|
+
el,
|
|
1100
|
+
el.typeaheadText.trim().toLowerCase()
|
|
1101
|
+
]);
|
|
1102
|
+
this.lastActiveRecord = this.typeaheadRecords.find((record) => record[TYPEAHEAD_RECORD.ITEM].tabIndex === 0) ?? null;
|
|
1103
|
+
if (this.lastActiveRecord) this.lastActiveRecord[TYPEAHEAD_RECORD.ITEM].tabIndex = -1;
|
|
1104
|
+
this.typeahead(event);
|
|
1105
|
+
}
|
|
1106
|
+
/**
|
|
1107
|
+
* Performs the typeahead. Based on the normalized items and the current text
|
|
1108
|
+
* buffer, finds the _next_ item with matching text and activates it.
|
|
1109
|
+
*
|
|
1110
|
+
* @example
|
|
1111
|
+
*
|
|
1112
|
+
* items: Apple, Banana, Olive, Orange, Cucumber
|
|
1113
|
+
* buffer: ''
|
|
1114
|
+
* user types: o
|
|
1115
|
+
*
|
|
1116
|
+
* activates Olive
|
|
1117
|
+
*
|
|
1118
|
+
* @example
|
|
1119
|
+
*
|
|
1120
|
+
* items: Apple, Banana, Olive (active), Orange, Cucumber
|
|
1121
|
+
* buffer: 'o'
|
|
1122
|
+
* user types: l
|
|
1123
|
+
*
|
|
1124
|
+
* activates Olive
|
|
1125
|
+
*
|
|
1126
|
+
* @example
|
|
1127
|
+
*
|
|
1128
|
+
* items: Apple, Banana, Olive (active), Orange, Cucumber
|
|
1129
|
+
* buffer: ''
|
|
1130
|
+
* user types: o
|
|
1131
|
+
*
|
|
1132
|
+
* activates Orange
|
|
1133
|
+
*
|
|
1134
|
+
* @example
|
|
1135
|
+
*
|
|
1136
|
+
* items: Apple, Banana, Olive, Orange (active), Cucumber
|
|
1137
|
+
* buffer: ''
|
|
1138
|
+
* user types: o
|
|
1139
|
+
*
|
|
1140
|
+
* activates Olive
|
|
1141
|
+
*/
|
|
1142
|
+
typeahead(event) {
|
|
1143
|
+
if (event.defaultPrevented) return;
|
|
1144
|
+
clearTimeout(this.cancelTypeaheadTimeout);
|
|
1145
|
+
if (event.code === "Enter" || event.code.startsWith("Arrow") || event.code === "Escape") {
|
|
1146
|
+
this.endTypeahead();
|
|
1147
|
+
if (this.lastActiveRecord) this.lastActiveRecord[TYPEAHEAD_RECORD.ITEM].tabIndex = -1;
|
|
1148
|
+
return;
|
|
1149
|
+
}
|
|
1150
|
+
if (event.code === "Space") event.preventDefault();
|
|
1151
|
+
this.cancelTypeaheadTimeout = setTimeout(this.endTypeahead, this.getProperties().typeaheadBufferTime);
|
|
1152
|
+
this.typaheadBuffer += event.key.toLowerCase();
|
|
1153
|
+
const lastActiveIndex = this.lastActiveRecord ? this.lastActiveRecord[TYPEAHEAD_RECORD.INDEX] : -1;
|
|
1154
|
+
const numRecords = this.typeaheadRecords.length;
|
|
1155
|
+
/**
|
|
1156
|
+
* Sorting function that will resort the items starting with the given index
|
|
1157
|
+
*
|
|
1158
|
+
* @example
|
|
1159
|
+
*
|
|
1160
|
+
* this.typeaheadRecords =
|
|
1161
|
+
* 0: [0, <reference>, 'apple']
|
|
1162
|
+
* 1: [1, <reference>, 'apricot']
|
|
1163
|
+
* 2: [2, <reference>, 'banana']
|
|
1164
|
+
* 3: [3, <reference>, 'olive'] <-- lastActiveIndex
|
|
1165
|
+
* 4: [4, <reference>, 'orange']
|
|
1166
|
+
* 5: [5, <reference>, 'strawberry']
|
|
1167
|
+
*
|
|
1168
|
+
* this.typeaheadRecords.sort((a,b) => rebaseIndexOnActive(a)
|
|
1169
|
+
* - rebaseIndexOnActive(b)) ===
|
|
1170
|
+
* 0: [3, <reference>, 'olive'] <-- lastActiveIndex
|
|
1171
|
+
* 1: [4, <reference>, 'orange']
|
|
1172
|
+
* 2: [5, <reference>, 'strawberry']
|
|
1173
|
+
* 3: [0, <reference>, 'apple']
|
|
1174
|
+
* 4: [1, <reference>, 'apricot']
|
|
1175
|
+
* 5: [2, <reference>, 'banana']
|
|
1176
|
+
*/
|
|
1177
|
+
const rebaseIndexOnActive = (record) => {
|
|
1178
|
+
return (record[TYPEAHEAD_RECORD.INDEX] + numRecords - lastActiveIndex) % numRecords;
|
|
1179
|
+
};
|
|
1180
|
+
const matchingRecords = this.typeaheadRecords.filter((record) => !record[TYPEAHEAD_RECORD.ITEM].disabled && record[TYPEAHEAD_RECORD.TEXT].startsWith(this.typaheadBuffer)).sort((a, b) => rebaseIndexOnActive(a) - rebaseIndexOnActive(b));
|
|
1181
|
+
if (matchingRecords.length === 0) {
|
|
1182
|
+
clearTimeout(this.cancelTypeaheadTimeout);
|
|
1183
|
+
if (this.lastActiveRecord) this.lastActiveRecord[TYPEAHEAD_RECORD.ITEM].tabIndex = -1;
|
|
1184
|
+
this.endTypeahead();
|
|
1185
|
+
return;
|
|
1186
|
+
}
|
|
1187
|
+
const isNewQuery = this.typaheadBuffer.length === 1;
|
|
1188
|
+
let nextRecord;
|
|
1189
|
+
if (this.lastActiveRecord === matchingRecords[0] && isNewQuery) nextRecord = matchingRecords[1] ?? matchingRecords[0];
|
|
1190
|
+
else nextRecord = matchingRecords[0];
|
|
1191
|
+
if (this.lastActiveRecord) this.lastActiveRecord[TYPEAHEAD_RECORD.ITEM].tabIndex = -1;
|
|
1192
|
+
this.lastActiveRecord = nextRecord;
|
|
1193
|
+
nextRecord[TYPEAHEAD_RECORD.ITEM].tabIndex = 0;
|
|
1194
|
+
nextRecord[TYPEAHEAD_RECORD.ITEM].focus();
|
|
1195
|
+
}
|
|
1196
|
+
};
|
|
1197
|
+
/**
|
|
1198
|
+
* @license
|
|
1199
|
+
* Copyright 2023 Google LLC
|
|
9
1200
|
* SPDX-License-Identifier: Apache-2.0
|
|
10
1201
|
*/
|
|
1202
|
+
var submenuNavKeys = /* @__PURE__ */ new Set([
|
|
1203
|
+
NavigableKeys.ArrowDown,
|
|
1204
|
+
NavigableKeys.ArrowUp,
|
|
1205
|
+
NavigableKeys.Home,
|
|
1206
|
+
NavigableKeys.End
|
|
1207
|
+
]);
|
|
1208
|
+
var menuNavKeys = /* @__PURE__ */ new Set([
|
|
1209
|
+
NavigableKeys.ArrowLeft,
|
|
1210
|
+
NavigableKeys.ArrowRight,
|
|
1211
|
+
...submenuNavKeys
|
|
1212
|
+
]);
|
|
11
1213
|
/**
|
|
12
|
-
*
|
|
1214
|
+
* Gets the currently focused element on the page.
|
|
1215
|
+
*
|
|
1216
|
+
* @param activeDoc The document or shadowroot from which to start the search.
|
|
1217
|
+
* Defaults to `window.document`
|
|
1218
|
+
* @return Returns the currently deeply focused element or `null` if none.
|
|
13
1219
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
1220
|
+
function getFocusedElement(activeDoc = document) {
|
|
1221
|
+
let activeEl = activeDoc.activeElement;
|
|
1222
|
+
while (activeEl && activeEl?.shadowRoot?.activeElement) activeEl = activeEl.shadowRoot.activeElement;
|
|
1223
|
+
return activeEl;
|
|
1224
|
+
}
|
|
1225
|
+
/**
|
|
1226
|
+
* @fires opening {Event} Fired before the opening animation begins
|
|
1227
|
+
* @fires opened {Event} Fired once the menu is open, after any animations
|
|
1228
|
+
* @fires closing {Event} Fired before the closing animation begins
|
|
1229
|
+
* @fires closed {Event} Fired once the menu is closed, after any animations
|
|
1230
|
+
*/
|
|
1231
|
+
var Menu = class extends i {
|
|
1232
|
+
/**
|
|
1233
|
+
* Whether the menu is animating upwards or downwards when opening. This is
|
|
1234
|
+
* helpful for calculating some animation calculations.
|
|
1235
|
+
*/
|
|
1236
|
+
get openDirection() {
|
|
1237
|
+
return this.menuCorner.split("-")[0] === "start" ? "DOWN" : "UP";
|
|
1238
|
+
}
|
|
1239
|
+
/**
|
|
1240
|
+
* The element which the menu should align to. If `anchor` is set to a
|
|
1241
|
+
* non-empty idref string, then `anchorEl` will resolve to the element with
|
|
1242
|
+
* the given id in the same root node. Otherwise, `null`.
|
|
1243
|
+
*/
|
|
1244
|
+
get anchorElement() {
|
|
1245
|
+
if (this.anchor) return this.getRootNode().querySelector(`#${this.anchor}`);
|
|
1246
|
+
return this.currentAnchorElement;
|
|
1247
|
+
}
|
|
1248
|
+
set anchorElement(element) {
|
|
1249
|
+
this.currentAnchorElement = element;
|
|
1250
|
+
this.requestUpdate("anchorElement");
|
|
1251
|
+
}
|
|
1252
|
+
constructor() {
|
|
1253
|
+
super();
|
|
1254
|
+
/**
|
|
1255
|
+
* The ID of the element in the same root node in which the menu should align
|
|
1256
|
+
* to. Overrides setting `anchorElement = elementReference`.
|
|
1257
|
+
*
|
|
1258
|
+
* __NOTE__: anchor or anchorElement must either be an HTMLElement or resolve
|
|
1259
|
+
* to an HTMLElement in order for menu to open.
|
|
1260
|
+
*/
|
|
1261
|
+
this.anchor = "";
|
|
1262
|
+
/**
|
|
1263
|
+
* Whether the positioning algorithm should calculate relative to the parent
|
|
1264
|
+
* of the anchor element (`absolute`), relative to the window (`fixed`), or
|
|
1265
|
+
* relative to the document (`document`). `popover` will use the popover API
|
|
1266
|
+
* to render the menu in the top-layer. If your browser does not support the
|
|
1267
|
+
* popover API, it will fall back to `fixed`.
|
|
1268
|
+
*
|
|
1269
|
+
* __Examples for `position = 'fixed'`:__
|
|
1270
|
+
*
|
|
1271
|
+
* - If there is no `position:relative` in the given parent tree and the
|
|
1272
|
+
* surface is `position:absolute`
|
|
1273
|
+
* - If the surface is `position:fixed`
|
|
1274
|
+
* - If the surface is in the "top layer"
|
|
1275
|
+
* - The anchor and the surface do not share a common `position:relative`
|
|
1276
|
+
* ancestor
|
|
1277
|
+
*
|
|
1278
|
+
* When using `positioning=fixed`, in most cases, the menu should position
|
|
1279
|
+
* itself above most other `position:absolute` or `position:fixed` elements
|
|
1280
|
+
* when placed inside of them. e.g. using a menu inside of an `md-dialog`.
|
|
1281
|
+
*
|
|
1282
|
+
* __NOTE__: Fixed menus will not scroll with the page and will be fixed to
|
|
1283
|
+
* the window instead.
|
|
1284
|
+
*
|
|
1285
|
+
* __Examples for `position = 'document'`:__
|
|
1286
|
+
*
|
|
1287
|
+
* - There is no parent that creates a relative positioning context e.g.
|
|
1288
|
+
* `position: relative`, `position: absolute`, `transform: translate(x, y)`,
|
|
1289
|
+
* etc.
|
|
1290
|
+
* - You put the effort into hoisting the menu to the top of the DOM like the
|
|
1291
|
+
* end of the `<body>` to render over everything or in a top-layer.
|
|
1292
|
+
* - You are reusing a single `md-menu` element that dynamically renders
|
|
1293
|
+
* content.
|
|
1294
|
+
*
|
|
1295
|
+
* __Examples for `position = 'popover'`:__
|
|
1296
|
+
*
|
|
1297
|
+
* - Your browser supports `popover`.
|
|
1298
|
+
* - Most cases. Once popover is in browsers, this will become the default.
|
|
1299
|
+
*/
|
|
1300
|
+
this.positioning = "absolute";
|
|
1301
|
+
/**
|
|
1302
|
+
* Skips the opening and closing animations.
|
|
1303
|
+
*/
|
|
1304
|
+
this.quick = false;
|
|
1305
|
+
/**
|
|
1306
|
+
* Displays overflow content like a submenu. Not required in most cases when
|
|
1307
|
+
* using `positioning="popover"`.
|
|
1308
|
+
*
|
|
1309
|
+
* __NOTE__: This may cause adverse effects if you set
|
|
1310
|
+
* `md-menu {max-height:...}`
|
|
1311
|
+
* and have items overflowing items in the "y" direction.
|
|
1312
|
+
*/
|
|
1313
|
+
this.hasOverflow = false;
|
|
1314
|
+
/**
|
|
1315
|
+
* Opens the menu and makes it visible. Alternative to the `.show()` and
|
|
1316
|
+
* `.close()` methods
|
|
1317
|
+
*/
|
|
1318
|
+
this.open = false;
|
|
1319
|
+
/**
|
|
1320
|
+
* Offsets the menu's inline alignment from the anchor by the given number in
|
|
1321
|
+
* pixels. This value is direction aware and will follow the LTR / RTL
|
|
1322
|
+
* direction.
|
|
1323
|
+
*
|
|
1324
|
+
* e.g. LTR: positive -> right, negative -> left
|
|
1325
|
+
* RTL: positive -> left, negative -> right
|
|
1326
|
+
*/
|
|
1327
|
+
this.xOffset = 0;
|
|
1328
|
+
/**
|
|
1329
|
+
* Offsets the menu's block alignment from the anchor by the given number in
|
|
1330
|
+
* pixels.
|
|
1331
|
+
*
|
|
1332
|
+
* e.g. positive -> down, negative -> up
|
|
1333
|
+
*/
|
|
1334
|
+
this.yOffset = 0;
|
|
1335
|
+
/**
|
|
1336
|
+
* Disable the `flip` behavior that usually happens on the horizontal axis
|
|
1337
|
+
* when the surface would render outside the viewport.
|
|
1338
|
+
*/
|
|
1339
|
+
this.noHorizontalFlip = false;
|
|
1340
|
+
/**
|
|
1341
|
+
* Disable the `flip` behavior that usually happens on the vertical axis when
|
|
1342
|
+
* the surface would render outside the viewport.
|
|
1343
|
+
*/
|
|
1344
|
+
this.noVerticalFlip = false;
|
|
1345
|
+
/**
|
|
1346
|
+
* The max time between the keystrokes of the typeahead menu behavior before
|
|
1347
|
+
* it clears the typeahead buffer.
|
|
1348
|
+
*/
|
|
1349
|
+
this.typeaheadDelay = 200;
|
|
1350
|
+
/**
|
|
1351
|
+
* The corner of the anchor which to align the menu in the standard logical
|
|
1352
|
+
* property style of <block>-<inline> e.g. `'end-start'`.
|
|
1353
|
+
*
|
|
1354
|
+
* NOTE: This value may not be respected by the menu positioning algorithm
|
|
1355
|
+
* if the menu would render outisde the viewport.
|
|
1356
|
+
* Use `no-horizontal-flip` or `no-vertical-flip` to force the usage of the value
|
|
1357
|
+
*/
|
|
1358
|
+
this.anchorCorner = Corner.END_START;
|
|
1359
|
+
/**
|
|
1360
|
+
* The corner of the menu which to align the anchor in the standard logical
|
|
1361
|
+
* property style of <block>-<inline> e.g. `'start-start'`.
|
|
1362
|
+
*
|
|
1363
|
+
* NOTE: This value may not be respected by the menu positioning algorithm
|
|
1364
|
+
* if the menu would render outisde the viewport.
|
|
1365
|
+
* Use `no-horizontal-flip` or `no-vertical-flip` to force the usage of the value
|
|
1366
|
+
*/
|
|
1367
|
+
this.menuCorner = Corner.START_START;
|
|
1368
|
+
/**
|
|
1369
|
+
* Keeps the user clicks outside the menu.
|
|
1370
|
+
*
|
|
1371
|
+
* NOTE: clicking outside may still cause focusout to close the menu so see
|
|
1372
|
+
* `stayOpenOnFocusout`.
|
|
1373
|
+
*/
|
|
1374
|
+
this.stayOpenOnOutsideClick = false;
|
|
1375
|
+
/**
|
|
1376
|
+
* Keeps the menu open when focus leaves the menu's composed subtree.
|
|
1377
|
+
*
|
|
1378
|
+
* NOTE: Focusout behavior will stop propagation of the focusout event. Set
|
|
1379
|
+
* this property to true to opt-out of menu's focusout handling altogether.
|
|
1380
|
+
*/
|
|
1381
|
+
this.stayOpenOnFocusout = false;
|
|
1382
|
+
/**
|
|
1383
|
+
* After closing, does not restore focus to the last focused element before
|
|
1384
|
+
* the menu was opened.
|
|
1385
|
+
*/
|
|
1386
|
+
this.skipRestoreFocus = false;
|
|
1387
|
+
/**
|
|
1388
|
+
* The element that should be focused by default once opened.
|
|
1389
|
+
*
|
|
1390
|
+
* NOTE: When setting default focus to 'LIST_ROOT', remember to change
|
|
1391
|
+
* `tabindex` to `0` and change md-menu's display to something other than
|
|
1392
|
+
* `display: contents` when necessary.
|
|
1393
|
+
*/
|
|
1394
|
+
this.defaultFocus = FocusState.FIRST_ITEM;
|
|
1395
|
+
/**
|
|
1396
|
+
* Turns off navigation wrapping. By default, navigating past the end of the
|
|
1397
|
+
* menu items will wrap focus back to the beginning and vice versa. Use this
|
|
1398
|
+
* for ARIA patterns that do not wrap focus, like combobox.
|
|
1399
|
+
*/
|
|
1400
|
+
this.noNavigationWrap = false;
|
|
1401
|
+
this.typeaheadActive = true;
|
|
1402
|
+
/**
|
|
1403
|
+
* Whether or not the current menu is a submenu and should not handle specific
|
|
1404
|
+
* navigation keys.
|
|
1405
|
+
*
|
|
1406
|
+
* @export
|
|
1407
|
+
*/
|
|
1408
|
+
this.isSubmenu = false;
|
|
1409
|
+
/**
|
|
1410
|
+
* The event path of the last window pointerdown event.
|
|
1411
|
+
*/
|
|
1412
|
+
this.pointerPath = [];
|
|
1413
|
+
/**
|
|
1414
|
+
* Whether or not the menu is repositoining due to window / document resize
|
|
1415
|
+
*/
|
|
1416
|
+
this.isRepositioning = false;
|
|
1417
|
+
this.openCloseAnimationSignal = createAnimationSignal();
|
|
1418
|
+
this.listController = new ListController({
|
|
1419
|
+
isItem: (maybeItem) => {
|
|
1420
|
+
return maybeItem.hasAttribute("md-menu-item");
|
|
1421
|
+
},
|
|
1422
|
+
getPossibleItems: () => this.slotItems,
|
|
1423
|
+
isRtl: () => getComputedStyle(this).direction === "rtl",
|
|
1424
|
+
deactivateItem: (item) => {
|
|
1425
|
+
item.selected = false;
|
|
1426
|
+
item.tabIndex = -1;
|
|
1427
|
+
},
|
|
1428
|
+
activateItem: (item) => {
|
|
1429
|
+
item.selected = true;
|
|
1430
|
+
item.tabIndex = 0;
|
|
1431
|
+
},
|
|
1432
|
+
isNavigableKey: (key) => {
|
|
1433
|
+
if (!this.isSubmenu) return menuNavKeys.has(key);
|
|
1434
|
+
if (key === (getComputedStyle(this).direction === "rtl" ? NavigableKeys.ArrowLeft : NavigableKeys.ArrowRight)) return true;
|
|
1435
|
+
return submenuNavKeys.has(key);
|
|
1436
|
+
},
|
|
1437
|
+
wrapNavigation: () => !this.noNavigationWrap
|
|
1438
|
+
});
|
|
1439
|
+
/**
|
|
1440
|
+
* The element that was focused before the menu opened.
|
|
1441
|
+
*/
|
|
1442
|
+
this.lastFocusedElement = null;
|
|
1443
|
+
/**
|
|
1444
|
+
* Handles typeahead navigation through the menu.
|
|
1445
|
+
*/
|
|
1446
|
+
this.typeaheadController = new TypeaheadController(() => {
|
|
1447
|
+
return {
|
|
1448
|
+
getItems: () => this.items,
|
|
1449
|
+
typeaheadBufferTime: this.typeaheadDelay,
|
|
1450
|
+
active: this.typeaheadActive
|
|
1451
|
+
};
|
|
1452
|
+
});
|
|
1453
|
+
this.currentAnchorElement = null;
|
|
1454
|
+
this.internals = this.attachInternals();
|
|
1455
|
+
/**
|
|
1456
|
+
* Handles positioning the surface and aligning it to the anchor as well as
|
|
1457
|
+
* keeping it in the viewport.
|
|
1458
|
+
*/
|
|
1459
|
+
this.menuPositionController = new SurfacePositionController(this, () => {
|
|
1460
|
+
return {
|
|
1461
|
+
anchorCorner: this.anchorCorner,
|
|
1462
|
+
surfaceCorner: this.menuCorner,
|
|
1463
|
+
surfaceEl: this.surfaceEl,
|
|
1464
|
+
anchorEl: this.anchorElement,
|
|
1465
|
+
positioning: this.positioning === "popover" ? "document" : this.positioning,
|
|
1466
|
+
isOpen: this.open,
|
|
1467
|
+
xOffset: this.xOffset,
|
|
1468
|
+
yOffset: this.yOffset,
|
|
1469
|
+
disableBlockFlip: this.noVerticalFlip,
|
|
1470
|
+
disableInlineFlip: this.noHorizontalFlip,
|
|
1471
|
+
onOpen: this.onOpened,
|
|
1472
|
+
beforeClose: this.beforeClose,
|
|
1473
|
+
onClose: this.onClosed,
|
|
1474
|
+
repositionStrategy: this.hasOverflow && this.positioning !== "popover" ? "move" : "resize"
|
|
1475
|
+
};
|
|
1476
|
+
});
|
|
1477
|
+
this.onWindowResize = () => {
|
|
1478
|
+
if (this.isRepositioning || this.positioning !== "document" && this.positioning !== "fixed" && this.positioning !== "popover") return;
|
|
1479
|
+
this.isRepositioning = true;
|
|
1480
|
+
this.reposition();
|
|
1481
|
+
this.isRepositioning = false;
|
|
1482
|
+
};
|
|
1483
|
+
this.handleFocusout = async (event) => {
|
|
1484
|
+
const anchorEl = this.anchorElement;
|
|
1485
|
+
if (this.stayOpenOnFocusout || !this.open || this.pointerPath.includes(anchorEl)) return;
|
|
1486
|
+
if (event.relatedTarget) {
|
|
1487
|
+
if (isElementInSubtree(event.relatedTarget, this) || this.pointerPath.length !== 0 && isElementInSubtree(event.relatedTarget, anchorEl)) return;
|
|
1488
|
+
} else if (this.pointerPath.includes(this)) return;
|
|
1489
|
+
const oldRestoreFocus = this.skipRestoreFocus;
|
|
1490
|
+
this.skipRestoreFocus = true;
|
|
1491
|
+
this.close();
|
|
1492
|
+
await this.updateComplete;
|
|
1493
|
+
this.skipRestoreFocus = oldRestoreFocus;
|
|
1494
|
+
};
|
|
1495
|
+
/**
|
|
1496
|
+
* Saves the last focused element focuses the new element based on
|
|
1497
|
+
* `defaultFocus`, and animates open.
|
|
1498
|
+
*/
|
|
1499
|
+
this.onOpened = async () => {
|
|
1500
|
+
this.lastFocusedElement = getFocusedElement();
|
|
1501
|
+
const items = this.items;
|
|
1502
|
+
const activeItemRecord = getActiveItem(items);
|
|
1503
|
+
if (activeItemRecord && this.defaultFocus !== FocusState.NONE) activeItemRecord.item.tabIndex = -1;
|
|
1504
|
+
let animationAborted = !this.quick;
|
|
1505
|
+
if (this.quick) this.dispatchEvent(new Event("opening"));
|
|
1506
|
+
else animationAborted = !!await this.animateOpen();
|
|
1507
|
+
switch (this.defaultFocus) {
|
|
1508
|
+
case FocusState.FIRST_ITEM:
|
|
1509
|
+
const first = getFirstActivatableItem(items);
|
|
1510
|
+
if (first) {
|
|
1511
|
+
first.tabIndex = 0;
|
|
1512
|
+
first.focus();
|
|
1513
|
+
await first.updateComplete;
|
|
1514
|
+
}
|
|
1515
|
+
break;
|
|
1516
|
+
case FocusState.LAST_ITEM:
|
|
1517
|
+
const last = getLastActivatableItem(items);
|
|
1518
|
+
if (last) {
|
|
1519
|
+
last.tabIndex = 0;
|
|
1520
|
+
last.focus();
|
|
1521
|
+
await last.updateComplete;
|
|
1522
|
+
}
|
|
1523
|
+
break;
|
|
1524
|
+
case FocusState.LIST_ROOT:
|
|
1525
|
+
this.focus();
|
|
1526
|
+
break;
|
|
1527
|
+
default:
|
|
1528
|
+
case FocusState.NONE:
|
|
1529
|
+
}
|
|
1530
|
+
if (!animationAborted) this.dispatchEvent(new Event("opened"));
|
|
1531
|
+
};
|
|
1532
|
+
/**
|
|
1533
|
+
* Animates closed.
|
|
1534
|
+
*/
|
|
1535
|
+
this.beforeClose = async () => {
|
|
1536
|
+
this.open = false;
|
|
1537
|
+
if (!this.skipRestoreFocus) this.lastFocusedElement?.focus?.();
|
|
1538
|
+
if (!this.quick) await this.animateClose();
|
|
1539
|
+
};
|
|
1540
|
+
/**
|
|
1541
|
+
* Focuses the last focused element.
|
|
1542
|
+
*/
|
|
1543
|
+
this.onClosed = () => {
|
|
1544
|
+
if (this.quick) {
|
|
1545
|
+
this.dispatchEvent(new Event("closing"));
|
|
1546
|
+
this.dispatchEvent(new Event("closed"));
|
|
1547
|
+
}
|
|
1548
|
+
};
|
|
1549
|
+
this.onWindowPointerdown = (event) => {
|
|
1550
|
+
this.pointerPath = event.composedPath();
|
|
1551
|
+
};
|
|
1552
|
+
/**
|
|
1553
|
+
* We cannot listen to window click because Safari on iOS will not bubble a
|
|
1554
|
+
* click event on window if the item clicked is not a "clickable" item such as
|
|
1555
|
+
* <body>
|
|
1556
|
+
*/
|
|
1557
|
+
this.onDocumentClick = (event) => {
|
|
1558
|
+
if (!this.open) return;
|
|
1559
|
+
const path = event.composedPath();
|
|
1560
|
+
if (!this.stayOpenOnOutsideClick && !path.includes(this) && !path.includes(this.anchorElement)) this.open = false;
|
|
1561
|
+
};
|
|
1562
|
+
}
|
|
1563
|
+
/**
|
|
1564
|
+
* The menu items associated with this menu. The items must be `MenuItem`s and
|
|
1565
|
+
* have both the `md-menu-item` and `md-list-item` attributes.
|
|
1566
|
+
*/
|
|
1567
|
+
get items() {
|
|
1568
|
+
return this.listController.items;
|
|
1569
|
+
}
|
|
1570
|
+
willUpdate(changed) {
|
|
1571
|
+
if (!changed.has("open")) return;
|
|
1572
|
+
if (this.open) {
|
|
1573
|
+
this.removeAttribute("aria-hidden");
|
|
1574
|
+
return;
|
|
1575
|
+
}
|
|
1576
|
+
this.setAttribute("aria-hidden", "true");
|
|
1577
|
+
}
|
|
1578
|
+
update(changed) {
|
|
1579
|
+
if (changed.has("open")) {
|
|
1580
|
+
if (this.open) this.setUpGlobalEventListeners();
|
|
1581
|
+
else this.cleanUpGlobalEventListeners();
|
|
1582
|
+
}
|
|
1583
|
+
if (changed.has("positioning") && this.positioning === "popover" && !this.showPopover) this.positioning = "fixed";
|
|
1584
|
+
super.update(changed);
|
|
1585
|
+
}
|
|
1586
|
+
connectedCallback() {
|
|
1587
|
+
super.connectedCallback();
|
|
1588
|
+
if (this.open) this.setUpGlobalEventListeners();
|
|
1589
|
+
}
|
|
1590
|
+
disconnectedCallback() {
|
|
1591
|
+
super.disconnectedCallback();
|
|
1592
|
+
this.cleanUpGlobalEventListeners();
|
|
1593
|
+
}
|
|
1594
|
+
getBoundingClientRect() {
|
|
1595
|
+
if (!this.surfaceEl) return super.getBoundingClientRect();
|
|
1596
|
+
return this.surfaceEl.getBoundingClientRect();
|
|
1597
|
+
}
|
|
1598
|
+
getClientRects() {
|
|
1599
|
+
if (!this.surfaceEl) return super.getClientRects();
|
|
1600
|
+
return this.surfaceEl.getClientRects();
|
|
1601
|
+
}
|
|
1602
|
+
render() {
|
|
1603
|
+
return this.renderSurface();
|
|
1604
|
+
}
|
|
1605
|
+
/**
|
|
1606
|
+
* Renders the positionable surface element and its contents.
|
|
1607
|
+
*/
|
|
1608
|
+
renderSurface() {
|
|
1609
|
+
return T`
|
|
1610
|
+
<div
|
|
1611
|
+
class="menu ${e$2(this.getSurfaceClasses())}"
|
|
1612
|
+
style=${o$1(this.menuPositionController.surfaceStyles)}
|
|
1613
|
+
popover=${this.positioning === "popover" ? "manual" : A}>
|
|
1614
|
+
${this.renderElevation()}
|
|
1615
|
+
<div class="items">
|
|
1616
|
+
<div class="item-padding"> ${this.renderMenuItems()} </div>
|
|
1617
|
+
</div>
|
|
1618
|
+
</div>
|
|
1619
|
+
`;
|
|
1620
|
+
}
|
|
1621
|
+
/**
|
|
1622
|
+
* Renders the menu items' slot
|
|
1623
|
+
*/
|
|
1624
|
+
renderMenuItems() {
|
|
1625
|
+
return T`<slot
|
|
1626
|
+
@close-menu=${this.onCloseMenu}
|
|
1627
|
+
@deactivate-items=${this.onDeactivateItems}
|
|
1628
|
+
@request-activation=${this.onRequestActivation}
|
|
1629
|
+
@deactivate-typeahead=${this.handleDeactivateTypeahead}
|
|
1630
|
+
@activate-typeahead=${this.handleActivateTypeahead}
|
|
1631
|
+
@stay-open-on-focusout=${this.handleStayOpenOnFocusout}
|
|
1632
|
+
@close-on-focusout=${this.handleCloseOnFocusout}
|
|
1633
|
+
@slotchange=${this.listController.onSlotchange}></slot>`;
|
|
1634
|
+
}
|
|
1635
|
+
/**
|
|
1636
|
+
* Renders the elevation component.
|
|
1637
|
+
*/
|
|
1638
|
+
renderElevation() {
|
|
16
1639
|
return T`<md-elevation part="elevation"></md-elevation>`;
|
|
17
1640
|
}
|
|
1641
|
+
getSurfaceClasses() {
|
|
1642
|
+
return {
|
|
1643
|
+
open: this.open,
|
|
1644
|
+
fixed: this.positioning === "fixed",
|
|
1645
|
+
"has-overflow": this.hasOverflow
|
|
1646
|
+
};
|
|
1647
|
+
}
|
|
1648
|
+
captureKeydown(event) {
|
|
1649
|
+
if (event.target === this && !event.defaultPrevented && isClosableKey(event.code)) {
|
|
1650
|
+
event.preventDefault();
|
|
1651
|
+
this.close();
|
|
1652
|
+
}
|
|
1653
|
+
this.typeaheadController.onKeydown(event);
|
|
1654
|
+
}
|
|
1655
|
+
/**
|
|
1656
|
+
* Performs the opening animation:
|
|
1657
|
+
*
|
|
1658
|
+
* https://direct.googleplex.com/#/spec/295000003+271060003
|
|
1659
|
+
*
|
|
1660
|
+
* @return A promise that resolve to `true` if the animation was aborted,
|
|
1661
|
+
* `false` if it was not aborted.
|
|
1662
|
+
*/
|
|
1663
|
+
async animateOpen() {
|
|
1664
|
+
const surfaceEl = this.surfaceEl;
|
|
1665
|
+
const slotEl = this.slotEl;
|
|
1666
|
+
if (!surfaceEl || !slotEl) return true;
|
|
1667
|
+
const openDirection = this.openDirection;
|
|
1668
|
+
this.dispatchEvent(new Event("opening"));
|
|
1669
|
+
surfaceEl.classList.toggle("animating", true);
|
|
1670
|
+
const signal = this.openCloseAnimationSignal.start();
|
|
1671
|
+
const height = surfaceEl.offsetHeight;
|
|
1672
|
+
const openingUpwards = openDirection === "UP";
|
|
1673
|
+
const children = this.items;
|
|
1674
|
+
const FULL_DURATION = 500;
|
|
1675
|
+
const SURFACE_OPACITY_DURATION = 50;
|
|
1676
|
+
const ITEM_OPACITY_DURATION = 250;
|
|
1677
|
+
const DELAY_BETWEEN_ITEMS = 250 / children.length;
|
|
1678
|
+
const surfaceHeightAnimation = surfaceEl.animate([{ height: "0px" }, { height: `${height}px` }], {
|
|
1679
|
+
duration: FULL_DURATION,
|
|
1680
|
+
easing: EASING.EMPHASIZED
|
|
1681
|
+
});
|
|
1682
|
+
const upPositionCorrectionAnimation = slotEl.animate([{ transform: openingUpwards ? `translateY(-${height}px)` : "" }, { transform: "" }], {
|
|
1683
|
+
duration: FULL_DURATION,
|
|
1684
|
+
easing: EASING.EMPHASIZED
|
|
1685
|
+
});
|
|
1686
|
+
const surfaceOpacityAnimation = surfaceEl.animate([{ opacity: 0 }, { opacity: 1 }], SURFACE_OPACITY_DURATION);
|
|
1687
|
+
const childrenAnimations = [];
|
|
1688
|
+
for (let i = 0; i < children.length; i++) {
|
|
1689
|
+
const child = children[openingUpwards ? children.length - 1 - i : i];
|
|
1690
|
+
const animation = child.animate([{ opacity: 0 }, { opacity: 1 }], {
|
|
1691
|
+
duration: ITEM_OPACITY_DURATION,
|
|
1692
|
+
delay: DELAY_BETWEEN_ITEMS * i
|
|
1693
|
+
});
|
|
1694
|
+
child.classList.toggle("md-menu-hidden", true);
|
|
1695
|
+
animation.addEventListener("finish", () => {
|
|
1696
|
+
child.classList.toggle("md-menu-hidden", false);
|
|
1697
|
+
});
|
|
1698
|
+
childrenAnimations.push([child, animation]);
|
|
1699
|
+
}
|
|
1700
|
+
let resolveAnimation = (value) => {};
|
|
1701
|
+
const animationFinished = new Promise((resolve) => {
|
|
1702
|
+
resolveAnimation = resolve;
|
|
1703
|
+
});
|
|
1704
|
+
signal.addEventListener("abort", () => {
|
|
1705
|
+
surfaceHeightAnimation.cancel();
|
|
1706
|
+
upPositionCorrectionAnimation.cancel();
|
|
1707
|
+
surfaceOpacityAnimation.cancel();
|
|
1708
|
+
childrenAnimations.forEach(([child, animation]) => {
|
|
1709
|
+
child.classList.toggle("md-menu-hidden", false);
|
|
1710
|
+
animation.cancel();
|
|
1711
|
+
});
|
|
1712
|
+
resolveAnimation(true);
|
|
1713
|
+
});
|
|
1714
|
+
surfaceHeightAnimation.addEventListener("finish", () => {
|
|
1715
|
+
surfaceEl.classList.toggle("animating", false);
|
|
1716
|
+
this.openCloseAnimationSignal.finish();
|
|
1717
|
+
resolveAnimation(false);
|
|
1718
|
+
});
|
|
1719
|
+
return await animationFinished;
|
|
1720
|
+
}
|
|
1721
|
+
/**
|
|
1722
|
+
* Performs the closing animation:
|
|
1723
|
+
*
|
|
1724
|
+
* https://direct.googleplex.com/#/spec/295000003+271060003
|
|
1725
|
+
*/
|
|
1726
|
+
animateClose() {
|
|
1727
|
+
let resolve;
|
|
1728
|
+
const animationEnded = new Promise((res) => {
|
|
1729
|
+
resolve = res;
|
|
1730
|
+
});
|
|
1731
|
+
const surfaceEl = this.surfaceEl;
|
|
1732
|
+
const slotEl = this.slotEl;
|
|
1733
|
+
if (!surfaceEl || !slotEl) {
|
|
1734
|
+
resolve(false);
|
|
1735
|
+
return animationEnded;
|
|
1736
|
+
}
|
|
1737
|
+
const closingDownwards = this.openDirection === "UP";
|
|
1738
|
+
this.dispatchEvent(new Event("closing"));
|
|
1739
|
+
surfaceEl.classList.toggle("animating", true);
|
|
1740
|
+
const signal = this.openCloseAnimationSignal.start();
|
|
1741
|
+
const height = surfaceEl.offsetHeight;
|
|
1742
|
+
const children = this.items;
|
|
1743
|
+
const FULL_DURATION = 150;
|
|
1744
|
+
const SURFACE_OPACITY_DURATION = 50;
|
|
1745
|
+
const SURFACE_OPACITY_DELAY = 100;
|
|
1746
|
+
const ITEM_OPACITY_DURATION = 50;
|
|
1747
|
+
const ITEM_OPACITY_INITIAL_DELAY = 50;
|
|
1748
|
+
const END_HEIGHT_PERCENTAGE = .35;
|
|
1749
|
+
const DELAY_BETWEEN_ITEMS = 50 / children.length;
|
|
1750
|
+
const surfaceHeightAnimation = surfaceEl.animate([{ height: `${height}px` }, { height: `${height * END_HEIGHT_PERCENTAGE}px` }], {
|
|
1751
|
+
duration: FULL_DURATION,
|
|
1752
|
+
easing: EASING.EMPHASIZED_ACCELERATE
|
|
1753
|
+
});
|
|
1754
|
+
const downPositionCorrectionAnimation = slotEl.animate([{ transform: "" }, { transform: closingDownwards ? `translateY(-${height * .65}px)` : "" }], {
|
|
1755
|
+
duration: FULL_DURATION,
|
|
1756
|
+
easing: EASING.EMPHASIZED_ACCELERATE
|
|
1757
|
+
});
|
|
1758
|
+
const surfaceOpacityAnimation = surfaceEl.animate([{ opacity: 1 }, { opacity: 0 }], {
|
|
1759
|
+
duration: SURFACE_OPACITY_DURATION,
|
|
1760
|
+
delay: SURFACE_OPACITY_DELAY
|
|
1761
|
+
});
|
|
1762
|
+
const childrenAnimations = [];
|
|
1763
|
+
for (let i = 0; i < children.length; i++) {
|
|
1764
|
+
const child = children[closingDownwards ? i : children.length - 1 - i];
|
|
1765
|
+
const animation = child.animate([{ opacity: 1 }, { opacity: 0 }], {
|
|
1766
|
+
duration: ITEM_OPACITY_DURATION,
|
|
1767
|
+
delay: ITEM_OPACITY_INITIAL_DELAY + DELAY_BETWEEN_ITEMS * i
|
|
1768
|
+
});
|
|
1769
|
+
animation.addEventListener("finish", () => {
|
|
1770
|
+
child.classList.toggle("md-menu-hidden", true);
|
|
1771
|
+
});
|
|
1772
|
+
childrenAnimations.push([child, animation]);
|
|
1773
|
+
}
|
|
1774
|
+
signal.addEventListener("abort", () => {
|
|
1775
|
+
surfaceHeightAnimation.cancel();
|
|
1776
|
+
downPositionCorrectionAnimation.cancel();
|
|
1777
|
+
surfaceOpacityAnimation.cancel();
|
|
1778
|
+
childrenAnimations.forEach(([child, animation]) => {
|
|
1779
|
+
animation.cancel();
|
|
1780
|
+
child.classList.toggle("md-menu-hidden", false);
|
|
1781
|
+
});
|
|
1782
|
+
resolve(false);
|
|
1783
|
+
});
|
|
1784
|
+
surfaceHeightAnimation.addEventListener("finish", () => {
|
|
1785
|
+
surfaceEl.classList.toggle("animating", false);
|
|
1786
|
+
childrenAnimations.forEach(([child]) => {
|
|
1787
|
+
child.classList.toggle("md-menu-hidden", false);
|
|
1788
|
+
});
|
|
1789
|
+
this.openCloseAnimationSignal.finish();
|
|
1790
|
+
this.dispatchEvent(new Event("closed"));
|
|
1791
|
+
resolve(true);
|
|
1792
|
+
});
|
|
1793
|
+
return animationEnded;
|
|
1794
|
+
}
|
|
1795
|
+
handleKeydown(event) {
|
|
1796
|
+
this.pointerPath = [];
|
|
1797
|
+
this.listController.handleKeydown(event);
|
|
1798
|
+
}
|
|
1799
|
+
setUpGlobalEventListeners() {
|
|
1800
|
+
document.addEventListener("click", this.onDocumentClick, { capture: true });
|
|
1801
|
+
window.addEventListener("pointerdown", this.onWindowPointerdown);
|
|
1802
|
+
document.addEventListener("resize", this.onWindowResize, { passive: true });
|
|
1803
|
+
window.addEventListener("resize", this.onWindowResize, { passive: true });
|
|
1804
|
+
}
|
|
1805
|
+
cleanUpGlobalEventListeners() {
|
|
1806
|
+
document.removeEventListener("click", this.onDocumentClick, { capture: true });
|
|
1807
|
+
window.removeEventListener("pointerdown", this.onWindowPointerdown);
|
|
1808
|
+
document.removeEventListener("resize", this.onWindowResize);
|
|
1809
|
+
window.removeEventListener("resize", this.onWindowResize);
|
|
1810
|
+
}
|
|
1811
|
+
onCloseMenu() {
|
|
1812
|
+
this.close();
|
|
1813
|
+
}
|
|
1814
|
+
onDeactivateItems(event) {
|
|
1815
|
+
event.stopPropagation();
|
|
1816
|
+
this.listController.onDeactivateItems();
|
|
1817
|
+
}
|
|
1818
|
+
onRequestActivation(event) {
|
|
1819
|
+
event.stopPropagation();
|
|
1820
|
+
this.listController.onRequestActivation(event);
|
|
1821
|
+
}
|
|
1822
|
+
handleDeactivateTypeahead(event) {
|
|
1823
|
+
event.stopPropagation();
|
|
1824
|
+
this.typeaheadActive = false;
|
|
1825
|
+
}
|
|
1826
|
+
handleActivateTypeahead(event) {
|
|
1827
|
+
event.stopPropagation();
|
|
1828
|
+
this.typeaheadActive = true;
|
|
1829
|
+
}
|
|
1830
|
+
handleStayOpenOnFocusout(event) {
|
|
1831
|
+
event.stopPropagation();
|
|
1832
|
+
this.stayOpenOnFocusout = true;
|
|
1833
|
+
}
|
|
1834
|
+
handleCloseOnFocusout(event) {
|
|
1835
|
+
event.stopPropagation();
|
|
1836
|
+
this.stayOpenOnFocusout = false;
|
|
1837
|
+
}
|
|
1838
|
+
close() {
|
|
1839
|
+
this.open = false;
|
|
1840
|
+
this.slotItems.forEach((item) => {
|
|
1841
|
+
item.close?.();
|
|
1842
|
+
});
|
|
1843
|
+
}
|
|
1844
|
+
show() {
|
|
1845
|
+
this.open = true;
|
|
1846
|
+
}
|
|
1847
|
+
/**
|
|
1848
|
+
* Activates the next item in the menu. If at the end of the menu, the first
|
|
1849
|
+
* item will be activated.
|
|
1850
|
+
*
|
|
1851
|
+
* @return The activated menu item or `null` if there are no items.
|
|
1852
|
+
*/
|
|
1853
|
+
activateNextItem() {
|
|
1854
|
+
return this.listController.activateNextItem() ?? null;
|
|
1855
|
+
}
|
|
1856
|
+
/**
|
|
1857
|
+
* Activates the previous item in the menu. If at the start of the menu, the
|
|
1858
|
+
* last item will be activated.
|
|
1859
|
+
*
|
|
1860
|
+
* @return The activated menu item or `null` if there are no items.
|
|
1861
|
+
*/
|
|
1862
|
+
activatePreviousItem() {
|
|
1863
|
+
return this.listController.activatePreviousItem() ?? null;
|
|
1864
|
+
}
|
|
1865
|
+
/**
|
|
1866
|
+
* Repositions the menu if it is open.
|
|
1867
|
+
*
|
|
1868
|
+
* Useful for the case where document or window-positioned menus have their
|
|
1869
|
+
* anchors moved while open.
|
|
1870
|
+
*/
|
|
1871
|
+
reposition() {
|
|
1872
|
+
if (this.open) this.menuPositionController.position();
|
|
1873
|
+
}
|
|
1874
|
+
};
|
|
1875
|
+
__decorate([e$3(".menu")], Menu.prototype, "surfaceEl", void 0);
|
|
1876
|
+
__decorate([e$3("slot")], Menu.prototype, "slotEl", void 0);
|
|
1877
|
+
__decorate([n$1()], Menu.prototype, "anchor", void 0);
|
|
1878
|
+
__decorate([n$1()], Menu.prototype, "positioning", void 0);
|
|
1879
|
+
__decorate([n$1({ type: Boolean })], Menu.prototype, "quick", void 0);
|
|
1880
|
+
__decorate([n$1({
|
|
1881
|
+
type: Boolean,
|
|
1882
|
+
attribute: "has-overflow"
|
|
1883
|
+
})], Menu.prototype, "hasOverflow", void 0);
|
|
1884
|
+
__decorate([n$1({
|
|
1885
|
+
type: Boolean,
|
|
1886
|
+
reflect: true
|
|
1887
|
+
})], Menu.prototype, "open", void 0);
|
|
1888
|
+
__decorate([n$1({
|
|
1889
|
+
type: Number,
|
|
1890
|
+
attribute: "x-offset"
|
|
1891
|
+
})], Menu.prototype, "xOffset", void 0);
|
|
1892
|
+
__decorate([n$1({
|
|
1893
|
+
type: Number,
|
|
1894
|
+
attribute: "y-offset"
|
|
1895
|
+
})], Menu.prototype, "yOffset", void 0);
|
|
1896
|
+
__decorate([n$1({
|
|
1897
|
+
type: Boolean,
|
|
1898
|
+
attribute: "no-horizontal-flip"
|
|
1899
|
+
})], Menu.prototype, "noHorizontalFlip", void 0);
|
|
1900
|
+
__decorate([n$1({
|
|
1901
|
+
type: Boolean,
|
|
1902
|
+
attribute: "no-vertical-flip"
|
|
1903
|
+
})], Menu.prototype, "noVerticalFlip", void 0);
|
|
1904
|
+
__decorate([n$1({
|
|
1905
|
+
type: Number,
|
|
1906
|
+
attribute: "typeahead-delay"
|
|
1907
|
+
})], Menu.prototype, "typeaheadDelay", void 0);
|
|
1908
|
+
__decorate([n$1({ attribute: "anchor-corner" })], Menu.prototype, "anchorCorner", void 0);
|
|
1909
|
+
__decorate([n$1({ attribute: "menu-corner" })], Menu.prototype, "menuCorner", void 0);
|
|
1910
|
+
__decorate([n$1({
|
|
1911
|
+
type: Boolean,
|
|
1912
|
+
attribute: "stay-open-on-outside-click"
|
|
1913
|
+
})], Menu.prototype, "stayOpenOnOutsideClick", void 0);
|
|
1914
|
+
__decorate([n$1({
|
|
1915
|
+
type: Boolean,
|
|
1916
|
+
attribute: "stay-open-on-focusout"
|
|
1917
|
+
})], Menu.prototype, "stayOpenOnFocusout", void 0);
|
|
1918
|
+
__decorate([n$1({
|
|
1919
|
+
type: Boolean,
|
|
1920
|
+
attribute: "skip-restore-focus"
|
|
1921
|
+
})], Menu.prototype, "skipRestoreFocus", void 0);
|
|
1922
|
+
__decorate([n$1({ attribute: "default-focus" })], Menu.prototype, "defaultFocus", void 0);
|
|
1923
|
+
__decorate([n$1({
|
|
1924
|
+
type: Boolean,
|
|
1925
|
+
attribute: "no-navigation-wrap"
|
|
1926
|
+
})], Menu.prototype, "noNavigationWrap", void 0);
|
|
1927
|
+
__decorate([o({ flatten: true })], Menu.prototype, "slotItems", void 0);
|
|
1928
|
+
__decorate([r$1()], Menu.prototype, "typeaheadActive", void 0);
|
|
1929
|
+
// ../../node_modules/.pnpm/@material+web@2.5.0/node_modules/@material/web/menu/internal/menu-styles.cssresult.js
|
|
1930
|
+
/**
|
|
1931
|
+
* @license
|
|
1932
|
+
* Copyright 2026 Google LLC
|
|
1933
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
1934
|
+
*/
|
|
1935
|
+
var styles$4 = i$1`:host{--md-elevation-level: var(--md-menu-container-elevation, 2);--md-elevation-shadow-color: var(--md-menu-container-shadow-color, var(--md-sys-color-shadow, #000));min-width:112px;color:unset;display:contents}md-focus-ring{--md-focus-ring-shape: var(--md-menu-container-shape, var(--md-sys-shape-corner-extra-small, 4px))}.menu{border-radius:var(--md-menu-container-shape, var(--md-sys-shape-corner-extra-small, 4px));display:none;inset:auto;border:none;padding:0px;overflow:visible;background-color:rgba(0,0,0,0);color:inherit;opacity:0;z-index:20;position:absolute;user-select:none;max-height:inherit;height:inherit;min-width:inherit;max-width:inherit;scrollbar-width:inherit}.menu::backdrop{display:none}.fixed{position:fixed}.items{display:block;list-style-type:none;margin:0;outline:none;box-sizing:border-box;background-color:var(--md-menu-container-color, var(--md-sys-color-surface-container, #f3edf7));height:inherit;max-height:inherit;overflow:auto;min-width:inherit;max-width:inherit;border-radius:inherit;scrollbar-width:inherit}.item-padding{padding-block:var(--md-menu-top-space, 8px) var(--md-menu-bottom-space, 8px)}.has-overflow:not([popover]) .items{overflow:visible}.has-overflow.animating .items,.animating .items{overflow:hidden}.has-overflow.animating .items{pointer-events:none}.animating ::slotted(.md-menu-hidden){opacity:0}slot{display:block;height:inherit;max-height:inherit}::slotted(:is(md-divider,[role=separator])){margin:8px 0}@media(forced-colors: active){.menu{border-style:solid;border-color:CanvasText;border-width:1px}}
|
|
1936
|
+
`;
|
|
1937
|
+
styles$4.styleSheet;
|
|
1938
|
+
// ../../node_modules/.pnpm/@material+web@2.5.0/node_modules/@material/web/menu/menu.js
|
|
1939
|
+
/**
|
|
1940
|
+
* @license
|
|
1941
|
+
* Copyright 2022 Google LLC
|
|
1942
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
1943
|
+
*/
|
|
1944
|
+
/**
|
|
1945
|
+
* @summary Menus display a list of choices on a temporary surface.
|
|
1946
|
+
*
|
|
1947
|
+
* @description
|
|
1948
|
+
* Menus appear when users interact with a button, action, or other control.
|
|
1949
|
+
*
|
|
1950
|
+
* They can be opened from a variety of elements, most commonly icon buttons,
|
|
1951
|
+
* buttons, and text fields.
|
|
1952
|
+
*
|
|
1953
|
+
* md-menu listens for the `close-menu` and `deselect-items` events.
|
|
1954
|
+
*
|
|
1955
|
+
* - `close-menu` closes the menu when dispatched from a child element.
|
|
1956
|
+
* - `deselect-items` deselects all of its immediate menu-item children.
|
|
1957
|
+
*
|
|
1958
|
+
* @example
|
|
1959
|
+
* ```html
|
|
1960
|
+
* <div style="position:relative;">
|
|
1961
|
+
* <button
|
|
1962
|
+
* id="anchor"
|
|
1963
|
+
* @click=${() => this.menuRef.value.show()}>
|
|
1964
|
+
* Click to open menu
|
|
1965
|
+
* </button>
|
|
1966
|
+
* <!--
|
|
1967
|
+
* `has-overflow` is required when using a submenu which overflows the
|
|
1968
|
+
* menu's contents.
|
|
1969
|
+
*
|
|
1970
|
+
* Additionally, `anchor` ingests an idref which do not pass through shadow
|
|
1971
|
+
* roots. You can also set `.anchorElement` to an element reference if
|
|
1972
|
+
* necessary.
|
|
1973
|
+
* -->
|
|
1974
|
+
* <md-menu anchor="anchor" has-overflow ${ref(menuRef)}>
|
|
1975
|
+
* <md-menu-item headline="This is a headline"></md-menu-item>
|
|
1976
|
+
* <md-sub-menu>
|
|
1977
|
+
* <md-menu-item
|
|
1978
|
+
* slot="item"
|
|
1979
|
+
* headline="this is a submenu item">
|
|
1980
|
+
* </md-menu-item>
|
|
1981
|
+
* <md-menu slot="menu">
|
|
1982
|
+
* <md-menu-item headline="This is an item inside a submenu">
|
|
1983
|
+
* </md-menu-item>
|
|
1984
|
+
* </md-menu>
|
|
1985
|
+
* </md-sub-menu>
|
|
1986
|
+
* </md-menu>
|
|
1987
|
+
* </div>
|
|
1988
|
+
* ```
|
|
1989
|
+
*
|
|
1990
|
+
* @final
|
|
1991
|
+
* @suppress {visibility}
|
|
1992
|
+
*/
|
|
1993
|
+
var MdMenu = class MdMenu extends Menu {};
|
|
1994
|
+
MdMenu.styles = [styles$4];
|
|
1995
|
+
MdMenu = __decorate([t("md-menu")], MdMenu);
|
|
1996
|
+
// ../../node_modules/.pnpm/@material+web@2.5.0/node_modules/@material/web/labs/behaviors/validators/select-validator.js
|
|
1997
|
+
/**
|
|
1998
|
+
* @license
|
|
1999
|
+
* Copyright 2023 Google LLC
|
|
2000
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
2001
|
+
*/
|
|
2002
|
+
/**
|
|
2003
|
+
* A validator that provides constraint validation that emulates `<select>`
|
|
2004
|
+
* validation.
|
|
2005
|
+
*/
|
|
2006
|
+
var SelectValidator = class extends Validator {
|
|
2007
|
+
computeValidity(state) {
|
|
2008
|
+
if (!this.selectControl) this.selectControl = document.createElement("select");
|
|
2009
|
+
B(T`<option value=${state.value}></option>`, this.selectControl);
|
|
2010
|
+
this.selectControl.value = state.value;
|
|
2011
|
+
this.selectControl.required = state.required;
|
|
2012
|
+
return {
|
|
2013
|
+
validity: this.selectControl.validity,
|
|
2014
|
+
validationMessage: this.selectControl.validationMessage
|
|
2015
|
+
};
|
|
2016
|
+
}
|
|
2017
|
+
equals(prev, next) {
|
|
2018
|
+
return prev.value === next.value && prev.required === next.required;
|
|
2019
|
+
}
|
|
2020
|
+
copy({ value, required }) {
|
|
2021
|
+
return {
|
|
2022
|
+
value,
|
|
2023
|
+
required
|
|
2024
|
+
};
|
|
2025
|
+
}
|
|
2026
|
+
};
|
|
2027
|
+
// ../../node_modules/.pnpm/@material+web@2.5.0/node_modules/@material/web/select/internal/shared.js
|
|
2028
|
+
/**
|
|
2029
|
+
* @license
|
|
2030
|
+
* Copyright 2023 Google LLC
|
|
2031
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
2032
|
+
*/
|
|
2033
|
+
/**
|
|
2034
|
+
* Given a list of select options, this function will return an array of
|
|
2035
|
+
* SelectOptionRecords that are selected.
|
|
2036
|
+
*
|
|
2037
|
+
* @return An array of SelectOptionRecords describing the options that are
|
|
2038
|
+
* selected.
|
|
2039
|
+
*/
|
|
2040
|
+
function getSelectedItems(items) {
|
|
2041
|
+
const selectedItemRecords = [];
|
|
2042
|
+
for (let i = 0; i < items.length; i++) {
|
|
2043
|
+
const item = items[i];
|
|
2044
|
+
if (item.selected) selectedItemRecords.push([item, i]);
|
|
2045
|
+
}
|
|
2046
|
+
return selectedItemRecords;
|
|
2047
|
+
}
|
|
2048
|
+
// ../../node_modules/.pnpm/@material+web@2.5.0/node_modules/@material/web/select/internal/select.js
|
|
2049
|
+
/**
|
|
2050
|
+
* @license
|
|
2051
|
+
* Copyright 2023 Google LLC
|
|
2052
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
2053
|
+
*/
|
|
2054
|
+
var _a;
|
|
2055
|
+
var VALUE = Symbol("value");
|
|
2056
|
+
var selectBaseClass = mixinDelegatesAria(mixinOnReportValidity(mixinConstraintValidation(mixinFormAssociated(mixinElementInternals(i)))));
|
|
2057
|
+
/**
|
|
2058
|
+
* @fires change {Event} The native `change` event on
|
|
2059
|
+
* [`<input>`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/change_event)
|
|
2060
|
+
* --bubbles
|
|
2061
|
+
* @fires input {InputEvent} The native `input` event on
|
|
2062
|
+
* [`<input>`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/input_event)
|
|
2063
|
+
* --bubbles --composed
|
|
2064
|
+
* @fires opening {Event} Fired when the select's menu is about to open.
|
|
2065
|
+
* @fires opened {Event} Fired when the select's menu has finished animations
|
|
2066
|
+
* and opened.
|
|
2067
|
+
* @fires closing {Event} Fired when the select's menu is about to close.
|
|
2068
|
+
* @fires closed {Event} Fired when the select's menu has finished animations
|
|
2069
|
+
* and closed.
|
|
2070
|
+
*/
|
|
2071
|
+
var Select = class extends selectBaseClass {
|
|
2072
|
+
/**
|
|
2073
|
+
* The value of the currently selected option.
|
|
2074
|
+
*
|
|
2075
|
+
* Note: For SSR, set `[selected]` on the requested option and `displayText`
|
|
2076
|
+
* rather than setting `value` setting `value` will incur a DOM query.
|
|
2077
|
+
*/
|
|
2078
|
+
get value() {
|
|
2079
|
+
return this[VALUE];
|
|
2080
|
+
}
|
|
2081
|
+
set value(value) {}
|
|
2082
|
+
get options() {
|
|
2083
|
+
return this.menu?.items ?? [];
|
|
2084
|
+
}
|
|
2085
|
+
/**
|
|
2086
|
+
* The index of the currently selected option.
|
|
2087
|
+
*
|
|
2088
|
+
* Note: For SSR, set `[selected]` on the requested option and `displayText`
|
|
2089
|
+
* rather than setting `selectedIndex` setting `selectedIndex` will incur a
|
|
2090
|
+
* DOM query.
|
|
2091
|
+
*/
|
|
2092
|
+
get selectedIndex() {
|
|
2093
|
+
const [_option, index] = (this.getSelectedOptions() ?? [])[0] ?? [];
|
|
2094
|
+
return index ?? -1;
|
|
2095
|
+
}
|
|
2096
|
+
set selectedIndex(index) {
|
|
2097
|
+
this.lastUserSetSelectedIndex = index;
|
|
2098
|
+
this.selectIndex(index);
|
|
2099
|
+
}
|
|
2100
|
+
/**
|
|
2101
|
+
* Returns an array of selected options.
|
|
2102
|
+
*
|
|
2103
|
+
* NOTE: md-select only supports single selection.
|
|
2104
|
+
*/
|
|
2105
|
+
get selectedOptions() {
|
|
2106
|
+
return (this.getSelectedOptions() ?? []).map(([option]) => option);
|
|
2107
|
+
}
|
|
2108
|
+
get hasError() {
|
|
2109
|
+
return this.error || this.nativeError;
|
|
2110
|
+
}
|
|
2111
|
+
constructor() {
|
|
2112
|
+
super();
|
|
2113
|
+
/**
|
|
2114
|
+
* Opens the menu synchronously with no animation.
|
|
2115
|
+
*/
|
|
2116
|
+
this.quick = false;
|
|
2117
|
+
/**
|
|
2118
|
+
* Whether or not the select is required.
|
|
2119
|
+
*/
|
|
2120
|
+
this.required = false;
|
|
2121
|
+
/**
|
|
2122
|
+
* The error message that replaces supporting text when `error` is true. If
|
|
2123
|
+
* `errorText` is an empty string, then the supporting text will continue to
|
|
2124
|
+
* show.
|
|
2125
|
+
*
|
|
2126
|
+
* This error message overrides the error message displayed by
|
|
2127
|
+
* `reportValidity()`.
|
|
2128
|
+
*/
|
|
2129
|
+
this.errorText = "";
|
|
2130
|
+
/**
|
|
2131
|
+
* The floating label for the field.
|
|
2132
|
+
*/
|
|
2133
|
+
this.label = "";
|
|
2134
|
+
/**
|
|
2135
|
+
* Disables the asterisk on the floating label, when the select is
|
|
2136
|
+
* required.
|
|
2137
|
+
*/
|
|
2138
|
+
this.noAsterisk = false;
|
|
2139
|
+
/**
|
|
2140
|
+
* Conveys additional information below the select, such as how it should
|
|
2141
|
+
* be used.
|
|
2142
|
+
*/
|
|
2143
|
+
this.supportingText = "";
|
|
2144
|
+
/**
|
|
2145
|
+
* Gets or sets whether or not the select is in a visually invalid state.
|
|
2146
|
+
*
|
|
2147
|
+
* This error state overrides the error state controlled by
|
|
2148
|
+
* `reportValidity()`.
|
|
2149
|
+
*/
|
|
2150
|
+
this.error = false;
|
|
2151
|
+
/**
|
|
2152
|
+
* Whether or not the underlying md-menu should be position: fixed to display
|
|
2153
|
+
* in a top-level manner, or position: absolute.
|
|
2154
|
+
*
|
|
2155
|
+
* position:fixed is useful for cases where select is inside of another
|
|
2156
|
+
* element with stacking context and hidden overflows such as `md-dialog`.
|
|
2157
|
+
*/
|
|
2158
|
+
this.menuPositioning = "popover";
|
|
2159
|
+
/**
|
|
2160
|
+
* Clamps the menu-width to the width of the select.
|
|
2161
|
+
*/
|
|
2162
|
+
this.clampMenuWidth = false;
|
|
2163
|
+
/**
|
|
2164
|
+
* The max time between the keystrokes of the typeahead select / menu behavior
|
|
2165
|
+
* before it clears the typeahead buffer.
|
|
2166
|
+
*/
|
|
2167
|
+
this.typeaheadDelay = 200;
|
|
2168
|
+
/**
|
|
2169
|
+
* Whether or not the text field has a leading icon. Used for SSR.
|
|
2170
|
+
*/
|
|
2171
|
+
this.hasLeadingIcon = false;
|
|
2172
|
+
/**
|
|
2173
|
+
* Text to display in the field. Only set for SSR.
|
|
2174
|
+
*/
|
|
2175
|
+
this.displayText = "";
|
|
2176
|
+
/**
|
|
2177
|
+
* Whether the menu should be aligned to the start or the end of the select's
|
|
2178
|
+
* textbox.
|
|
2179
|
+
*/
|
|
2180
|
+
this.menuAlign = "start";
|
|
2181
|
+
this[_a] = "";
|
|
2182
|
+
/**
|
|
2183
|
+
* Used for initializing select when the user sets the `value` directly.
|
|
2184
|
+
*/
|
|
2185
|
+
this.lastUserSetValue = null;
|
|
2186
|
+
/**
|
|
2187
|
+
* Used for initializing select when the user sets the `selectedIndex`
|
|
2188
|
+
* directly.
|
|
2189
|
+
*/
|
|
2190
|
+
this.lastUserSetSelectedIndex = null;
|
|
2191
|
+
/**
|
|
2192
|
+
* Used for `input` and `change` event change detection.
|
|
2193
|
+
*/
|
|
2194
|
+
this.lastSelectedOption = null;
|
|
2195
|
+
this.lastSelectedOptionRecords = [];
|
|
2196
|
+
/**
|
|
2197
|
+
* Whether or not a native error has been reported via `reportValidity()`.
|
|
2198
|
+
*/
|
|
2199
|
+
this.nativeError = false;
|
|
2200
|
+
/**
|
|
2201
|
+
* The validation message displayed from a native error via
|
|
2202
|
+
* `reportValidity()`.
|
|
2203
|
+
*/
|
|
2204
|
+
this.nativeErrorText = "";
|
|
2205
|
+
this.focused = false;
|
|
2206
|
+
this.open = false;
|
|
2207
|
+
this.defaultFocus = FocusState.NONE;
|
|
2208
|
+
this.prevOpen = this.open;
|
|
2209
|
+
this.selectWidth = 0;
|
|
2210
|
+
}
|
|
2211
|
+
/**
|
|
2212
|
+
* Selects an option given the value of the option, and updates MdSelect's
|
|
2213
|
+
* value.
|
|
2214
|
+
*/
|
|
2215
|
+
select(value) {
|
|
2216
|
+
const optionToSelect = this.options.find((option) => option.value === value);
|
|
2217
|
+
if (optionToSelect) this.selectItem(optionToSelect);
|
|
2218
|
+
}
|
|
2219
|
+
/**
|
|
2220
|
+
* Selects an option given the index of the option, and updates MdSelect's
|
|
2221
|
+
* value.
|
|
2222
|
+
*/
|
|
2223
|
+
selectIndex(index) {
|
|
2224
|
+
const optionToSelect = this.options[index];
|
|
2225
|
+
if (optionToSelect) this.selectItem(optionToSelect);
|
|
2226
|
+
}
|
|
2227
|
+
/**
|
|
2228
|
+
* Reset the select to its default value.
|
|
2229
|
+
*/
|
|
2230
|
+
reset() {
|
|
2231
|
+
for (const option of this.options) option.selected = option.hasAttribute("selected");
|
|
2232
|
+
this.updateValueAndDisplayText();
|
|
2233
|
+
this.nativeError = false;
|
|
2234
|
+
this.nativeErrorText = "";
|
|
2235
|
+
}
|
|
2236
|
+
/** Shows the picker. If it's already open, this is a no-op. */
|
|
2237
|
+
showPicker() {
|
|
2238
|
+
this.open = true;
|
|
2239
|
+
}
|
|
2240
|
+
[(_a = VALUE, onReportValidity)](invalidEvent) {
|
|
2241
|
+
invalidEvent?.preventDefault();
|
|
2242
|
+
const prevMessage = this.getErrorText();
|
|
2243
|
+
this.nativeError = !!invalidEvent;
|
|
2244
|
+
this.nativeErrorText = this.validationMessage;
|
|
2245
|
+
if (prevMessage === this.getErrorText()) this.field?.reannounceError();
|
|
2246
|
+
}
|
|
2247
|
+
update(changed) {
|
|
2248
|
+
if (!this.hasUpdated) this.initUserSelection();
|
|
2249
|
+
if (this.prevOpen !== this.open && this.open) {
|
|
2250
|
+
const selectRect = this.getBoundingClientRect();
|
|
2251
|
+
this.selectWidth = selectRect.width;
|
|
2252
|
+
}
|
|
2253
|
+
this.prevOpen = this.open;
|
|
2254
|
+
super.update(changed);
|
|
2255
|
+
}
|
|
2256
|
+
render() {
|
|
2257
|
+
return T`
|
|
2258
|
+
<span
|
|
2259
|
+
class="select ${e$2(this.getRenderClasses())}"
|
|
2260
|
+
@focusout=${this.handleFocusout}>
|
|
2261
|
+
${this.renderField()} ${this.renderMenu()}
|
|
2262
|
+
</span>
|
|
2263
|
+
`;
|
|
2264
|
+
}
|
|
2265
|
+
async firstUpdated(changed) {
|
|
2266
|
+
await this.menu?.updateComplete;
|
|
2267
|
+
if (!this.lastSelectedOptionRecords.length) this.initUserSelection();
|
|
2268
|
+
if (!this.lastSelectedOptionRecords.length && false);
|
|
2269
|
+
super.firstUpdated(changed);
|
|
2270
|
+
}
|
|
2271
|
+
getRenderClasses() {
|
|
2272
|
+
return {
|
|
2273
|
+
"disabled": this.disabled,
|
|
2274
|
+
"error": this.error,
|
|
2275
|
+
"open": this.open
|
|
2276
|
+
};
|
|
2277
|
+
}
|
|
2278
|
+
renderField() {
|
|
2279
|
+
const ariaLabel = this.ariaLabel || this.label;
|
|
2280
|
+
return u`
|
|
2281
|
+
<${this.fieldTag}
|
|
2282
|
+
aria-haspopup="listbox"
|
|
2283
|
+
role="combobox"
|
|
2284
|
+
part="field"
|
|
2285
|
+
id="field"
|
|
2286
|
+
tabindex=${this.disabled ? "-1" : "0"}
|
|
2287
|
+
aria-label=${ariaLabel || A}
|
|
2288
|
+
aria-describedby="description"
|
|
2289
|
+
aria-expanded=${this.open ? "true" : "false"}
|
|
2290
|
+
aria-controls="listbox"
|
|
2291
|
+
class="field"
|
|
2292
|
+
label=${this.label}
|
|
2293
|
+
?no-asterisk=${this.noAsterisk}
|
|
2294
|
+
.focused=${this.focused || this.open}
|
|
2295
|
+
.populated=${!!this.displayText}
|
|
2296
|
+
.disabled=${this.disabled}
|
|
2297
|
+
.required=${this.required}
|
|
2298
|
+
.error=${this.hasError}
|
|
2299
|
+
?has-start=${this.hasLeadingIcon}
|
|
2300
|
+
has-end
|
|
2301
|
+
supporting-text=${this.supportingText}
|
|
2302
|
+
error-text=${this.getErrorText()}
|
|
2303
|
+
@keydown=${this.handleKeydown}
|
|
2304
|
+
@click=${this.handleClick}>
|
|
2305
|
+
${this.renderFieldContent()}
|
|
2306
|
+
<div id="description" slot="aria-describedby"></div>
|
|
2307
|
+
</${this.fieldTag}>`;
|
|
2308
|
+
}
|
|
2309
|
+
renderFieldContent() {
|
|
2310
|
+
return [
|
|
2311
|
+
this.renderLeadingIcon(),
|
|
2312
|
+
this.renderLabel(),
|
|
2313
|
+
this.renderTrailingIcon()
|
|
2314
|
+
];
|
|
2315
|
+
}
|
|
2316
|
+
renderLeadingIcon() {
|
|
2317
|
+
return T`
|
|
2318
|
+
<span class="icon leading" slot="start">
|
|
2319
|
+
<slot name="leading-icon" @slotchange=${this.handleIconChange}></slot>
|
|
2320
|
+
</span>
|
|
2321
|
+
`;
|
|
2322
|
+
}
|
|
2323
|
+
renderTrailingIcon() {
|
|
2324
|
+
return T`
|
|
2325
|
+
<span class="icon trailing" slot="end">
|
|
2326
|
+
<slot name="trailing-icon" @slotchange=${this.handleIconChange}>
|
|
2327
|
+
<svg height="5" viewBox="7 10 10 5" focusable="false">
|
|
2328
|
+
<polygon
|
|
2329
|
+
class="down"
|
|
2330
|
+
stroke="none"
|
|
2331
|
+
fill-rule="evenodd"
|
|
2332
|
+
points="7 10 12 15 17 10"></polygon>
|
|
2333
|
+
<polygon
|
|
2334
|
+
class="up"
|
|
2335
|
+
stroke="none"
|
|
2336
|
+
fill-rule="evenodd"
|
|
2337
|
+
points="7 15 12 10 17 15"></polygon>
|
|
2338
|
+
</svg>
|
|
2339
|
+
</slot>
|
|
2340
|
+
</span>
|
|
2341
|
+
`;
|
|
2342
|
+
}
|
|
2343
|
+
renderLabel() {
|
|
2344
|
+
return T`<div id="label">${this.displayText || T` `}</div>`;
|
|
2345
|
+
}
|
|
2346
|
+
renderMenu() {
|
|
2347
|
+
const ariaLabel = this.label || this.ariaLabel;
|
|
2348
|
+
return T`<div class="menu-wrapper">
|
|
2349
|
+
<md-menu
|
|
2350
|
+
id="listbox"
|
|
2351
|
+
.defaultFocus=${this.defaultFocus}
|
|
2352
|
+
role="listbox"
|
|
2353
|
+
tabindex="-1"
|
|
2354
|
+
aria-label=${ariaLabel || A}
|
|
2355
|
+
stay-open-on-focusout
|
|
2356
|
+
part="menu"
|
|
2357
|
+
exportparts="focus-ring: menu-focus-ring"
|
|
2358
|
+
anchor="field"
|
|
2359
|
+
style=${o$1({
|
|
2360
|
+
"--__menu-min-width": `${this.selectWidth}px`,
|
|
2361
|
+
"--__menu-max-width": this.clampMenuWidth ? `${this.selectWidth}px` : void 0
|
|
2362
|
+
})}
|
|
2363
|
+
no-navigation-wrap
|
|
2364
|
+
.open=${this.open}
|
|
2365
|
+
.quick=${this.quick}
|
|
2366
|
+
.positioning=${this.menuPositioning}
|
|
2367
|
+
.typeaheadDelay=${this.typeaheadDelay}
|
|
2368
|
+
.anchorCorner=${this.menuAlign === "start" ? "end-start" : "end-end"}
|
|
2369
|
+
.menuCorner=${this.menuAlign === "start" ? "start-start" : "start-end"}
|
|
2370
|
+
@opening=${this.handleOpening}
|
|
2371
|
+
@opened=${this.redispatchEvent}
|
|
2372
|
+
@closing=${this.redispatchEvent}
|
|
2373
|
+
@closed=${this.handleClosed}
|
|
2374
|
+
@close-menu=${this.handleCloseMenu}
|
|
2375
|
+
@request-selection=${this.handleRequestSelection}
|
|
2376
|
+
@request-deselection=${this.handleRequestDeselection}>
|
|
2377
|
+
${this.renderMenuContent()}
|
|
2378
|
+
</md-menu>
|
|
2379
|
+
</div>`;
|
|
2380
|
+
}
|
|
2381
|
+
renderMenuContent() {
|
|
2382
|
+
return T`<slot></slot>`;
|
|
2383
|
+
}
|
|
2384
|
+
/**
|
|
2385
|
+
* Handles opening the select on keydown and typahead selection when the menu
|
|
2386
|
+
* is closed.
|
|
2387
|
+
*/
|
|
2388
|
+
handleKeydown(event) {
|
|
2389
|
+
if (this.open || this.disabled || !this.menu) return;
|
|
2390
|
+
const typeaheadController = this.menu.typeaheadController;
|
|
2391
|
+
const isOpenKey = event.code === "Space" || event.code === "ArrowDown" || event.code === "ArrowUp" || event.code === "End" || event.code === "Home" || event.code === "Enter";
|
|
2392
|
+
if (!typeaheadController.isTypingAhead && isOpenKey) {
|
|
2393
|
+
event.preventDefault();
|
|
2394
|
+
this.open = true;
|
|
2395
|
+
switch (event.code) {
|
|
2396
|
+
case "Space":
|
|
2397
|
+
case "ArrowDown":
|
|
2398
|
+
case "Enter":
|
|
2399
|
+
this.defaultFocus = FocusState.NONE;
|
|
2400
|
+
break;
|
|
2401
|
+
case "End":
|
|
2402
|
+
this.defaultFocus = FocusState.LAST_ITEM;
|
|
2403
|
+
break;
|
|
2404
|
+
case "ArrowUp":
|
|
2405
|
+
case "Home": this.defaultFocus = FocusState.FIRST_ITEM;
|
|
2406
|
+
}
|
|
2407
|
+
return;
|
|
2408
|
+
}
|
|
2409
|
+
if (event.key.length === 1) {
|
|
2410
|
+
typeaheadController.onKeydown(event);
|
|
2411
|
+
event.preventDefault();
|
|
2412
|
+
const { lastActiveRecord } = typeaheadController;
|
|
2413
|
+
if (!lastActiveRecord) return;
|
|
2414
|
+
this.labelEl?.setAttribute?.("aria-live", "polite");
|
|
2415
|
+
if (this.selectItem(lastActiveRecord[TYPEAHEAD_RECORD.ITEM])) this.dispatchInteractionEvents();
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
handleClick() {
|
|
2419
|
+
this.open = !this.open;
|
|
2420
|
+
}
|
|
2421
|
+
handleFocus() {
|
|
2422
|
+
this.focused = true;
|
|
2423
|
+
}
|
|
2424
|
+
handleBlur() {
|
|
2425
|
+
this.focused = false;
|
|
2426
|
+
}
|
|
2427
|
+
/**
|
|
2428
|
+
* Handles closing the menu when the focus leaves the select's subtree.
|
|
2429
|
+
*/
|
|
2430
|
+
handleFocusout(event) {
|
|
2431
|
+
if (event.relatedTarget && isElementInSubtree(event.relatedTarget, this)) return;
|
|
2432
|
+
this.open = false;
|
|
2433
|
+
}
|
|
2434
|
+
/**
|
|
2435
|
+
* Gets a list of all selected select options as a list item record array.
|
|
2436
|
+
*
|
|
2437
|
+
* @return An array of selected list option records.
|
|
2438
|
+
*/
|
|
2439
|
+
getSelectedOptions() {
|
|
2440
|
+
if (!this.menu) {
|
|
2441
|
+
this.lastSelectedOptionRecords = [];
|
|
2442
|
+
return null;
|
|
2443
|
+
}
|
|
2444
|
+
const items = this.menu.items;
|
|
2445
|
+
this.lastSelectedOptionRecords = getSelectedItems(items);
|
|
2446
|
+
return this.lastSelectedOptionRecords;
|
|
2447
|
+
}
|
|
2448
|
+
async getUpdateComplete() {
|
|
2449
|
+
await this.menu?.updateComplete;
|
|
2450
|
+
return super.getUpdateComplete();
|
|
2451
|
+
}
|
|
2452
|
+
/**
|
|
2453
|
+
* Gets the selected options from the DOM, and updates the value and display
|
|
2454
|
+
* text to the first selected option's value and headline respectively.
|
|
2455
|
+
*
|
|
2456
|
+
* @return Whether or not the selected option has changed since last update.
|
|
2457
|
+
*/
|
|
2458
|
+
updateValueAndDisplayText() {
|
|
2459
|
+
const selectedOptions = this.getSelectedOptions() ?? [];
|
|
2460
|
+
let hasSelectedOptionChanged = false;
|
|
2461
|
+
if (selectedOptions.length) {
|
|
2462
|
+
const [firstSelectedOption] = selectedOptions[0];
|
|
2463
|
+
hasSelectedOptionChanged = this.lastSelectedOption !== firstSelectedOption;
|
|
2464
|
+
this.lastSelectedOption = firstSelectedOption;
|
|
2465
|
+
this[VALUE] = firstSelectedOption.value;
|
|
2466
|
+
this.displayText = firstSelectedOption.displayText;
|
|
2467
|
+
} else {
|
|
2468
|
+
hasSelectedOptionChanged = this.lastSelectedOption !== null;
|
|
2469
|
+
this.lastSelectedOption = null;
|
|
2470
|
+
this[VALUE] = "";
|
|
2471
|
+
this.displayText = "";
|
|
2472
|
+
}
|
|
2473
|
+
return hasSelectedOptionChanged;
|
|
2474
|
+
}
|
|
2475
|
+
/**
|
|
2476
|
+
* Focuses and activates the last selected item upon opening, and resets other
|
|
2477
|
+
* active items.
|
|
2478
|
+
*/
|
|
2479
|
+
async handleOpening(e) {
|
|
2480
|
+
this.labelEl?.removeAttribute?.("aria-live");
|
|
2481
|
+
this.redispatchEvent(e);
|
|
2482
|
+
if (this.defaultFocus !== FocusState.NONE) return;
|
|
2483
|
+
const items = this.menu.items;
|
|
2484
|
+
const activeItem = getActiveItem(items)?.item;
|
|
2485
|
+
let [selectedItem] = this.lastSelectedOptionRecords[0] ?? [null];
|
|
2486
|
+
if (activeItem && activeItem !== selectedItem) activeItem.tabIndex = -1;
|
|
2487
|
+
selectedItem = selectedItem ?? items[0];
|
|
2488
|
+
if (selectedItem) {
|
|
2489
|
+
selectedItem.tabIndex = 0;
|
|
2490
|
+
selectedItem.focus();
|
|
2491
|
+
}
|
|
2492
|
+
}
|
|
2493
|
+
redispatchEvent(e) {
|
|
2494
|
+
redispatchEvent(this, e);
|
|
2495
|
+
}
|
|
2496
|
+
handleClosed(e) {
|
|
2497
|
+
this.open = false;
|
|
2498
|
+
this.redispatchEvent(e);
|
|
2499
|
+
}
|
|
2500
|
+
/**
|
|
2501
|
+
* Determines the reason for closing, and updates the UI accordingly.
|
|
2502
|
+
*/
|
|
2503
|
+
handleCloseMenu(event) {
|
|
2504
|
+
const reason = event.detail.reason;
|
|
2505
|
+
const item = event.detail.itemPath[0];
|
|
2506
|
+
this.open = false;
|
|
2507
|
+
let hasChanged = false;
|
|
2508
|
+
if (reason.kind === "click-selection") hasChanged = this.selectItem(item);
|
|
2509
|
+
else if (reason.kind === "keydown" && isSelectableKey(reason.key)) hasChanged = this.selectItem(item);
|
|
2510
|
+
else {
|
|
2511
|
+
item.tabIndex = -1;
|
|
2512
|
+
item.blur();
|
|
2513
|
+
}
|
|
2514
|
+
if (hasChanged) this.dispatchInteractionEvents();
|
|
2515
|
+
}
|
|
2516
|
+
/**
|
|
2517
|
+
* Selects a given option, deselects other options, and updates the UI.
|
|
2518
|
+
*
|
|
2519
|
+
* @return Whether the last selected option has changed.
|
|
2520
|
+
*/
|
|
2521
|
+
selectItem(item) {
|
|
2522
|
+
(this.getSelectedOptions() ?? []).forEach(([option]) => {
|
|
2523
|
+
if (item !== option) {
|
|
2524
|
+
option.selected = false;
|
|
2525
|
+
option.tabIndex = -1;
|
|
2526
|
+
}
|
|
2527
|
+
});
|
|
2528
|
+
item.selected = true;
|
|
2529
|
+
item.tabIndex = 0;
|
|
2530
|
+
return this.updateValueAndDisplayText();
|
|
2531
|
+
}
|
|
2532
|
+
/**
|
|
2533
|
+
* Handles updating selection when an option element requests selection via
|
|
2534
|
+
* property / attribute change.
|
|
2535
|
+
*/
|
|
2536
|
+
handleRequestSelection(event) {
|
|
2537
|
+
const requestingOptionEl = event.target;
|
|
2538
|
+
if (this.lastSelectedOptionRecords.some(([option]) => option === requestingOptionEl)) return;
|
|
2539
|
+
this.selectItem(requestingOptionEl);
|
|
2540
|
+
}
|
|
2541
|
+
/**
|
|
2542
|
+
* Handles updating selection when an option element requests deselection via
|
|
2543
|
+
* property / attribute change.
|
|
2544
|
+
*/
|
|
2545
|
+
handleRequestDeselection(event) {
|
|
2546
|
+
const requestingOptionEl = event.target;
|
|
2547
|
+
if (!this.lastSelectedOptionRecords.some(([option]) => option === requestingOptionEl)) return;
|
|
2548
|
+
this.updateValueAndDisplayText();
|
|
2549
|
+
}
|
|
2550
|
+
/**
|
|
2551
|
+
* Attempts to initialize the selected option from user-settable values like
|
|
2552
|
+
* SSR, setting `value`, or `selectedIndex` at startup.
|
|
2553
|
+
*/
|
|
2554
|
+
initUserSelection() {
|
|
2555
|
+
if (this.lastUserSetValue && !this.lastSelectedOptionRecords.length) this.select(this.lastUserSetValue);
|
|
2556
|
+
else if (this.lastUserSetSelectedIndex !== null && !this.lastSelectedOptionRecords.length) this.selectIndex(this.lastUserSetSelectedIndex);
|
|
2557
|
+
else this.updateValueAndDisplayText();
|
|
2558
|
+
}
|
|
2559
|
+
handleIconChange() {
|
|
2560
|
+
this.hasLeadingIcon = this.leadingIcons.length > 0;
|
|
2561
|
+
}
|
|
2562
|
+
/**
|
|
2563
|
+
* Dispatches the `input` and `change` events.
|
|
2564
|
+
*/
|
|
2565
|
+
dispatchInteractionEvents() {
|
|
2566
|
+
this.dispatchEvent(new Event("input", {
|
|
2567
|
+
bubbles: true,
|
|
2568
|
+
composed: true
|
|
2569
|
+
}));
|
|
2570
|
+
this.dispatchEvent(new Event("change", { bubbles: true }));
|
|
2571
|
+
}
|
|
2572
|
+
getErrorText() {
|
|
2573
|
+
return this.error ? this.errorText : this.nativeErrorText;
|
|
2574
|
+
}
|
|
2575
|
+
[getFormValue]() {
|
|
2576
|
+
return this.value;
|
|
2577
|
+
}
|
|
2578
|
+
formResetCallback() {
|
|
2579
|
+
this.reset();
|
|
2580
|
+
}
|
|
2581
|
+
formStateRestoreCallback(state) {
|
|
2582
|
+
this.value = state;
|
|
2583
|
+
}
|
|
2584
|
+
click() {
|
|
2585
|
+
this.field?.click();
|
|
2586
|
+
}
|
|
2587
|
+
[createValidator]() {
|
|
2588
|
+
return new SelectValidator(() => this);
|
|
2589
|
+
}
|
|
2590
|
+
[getValidityAnchor]() {
|
|
2591
|
+
return this.field;
|
|
2592
|
+
}
|
|
2593
|
+
};
|
|
2594
|
+
/** @nocollapse */
|
|
2595
|
+
Select.shadowRootOptions = {
|
|
2596
|
+
...i.shadowRootOptions,
|
|
2597
|
+
delegatesFocus: true
|
|
2598
|
+
};
|
|
2599
|
+
__decorate([n$1({ type: Boolean })], Select.prototype, "quick", void 0);
|
|
2600
|
+
__decorate([n$1({ type: Boolean })], Select.prototype, "required", void 0);
|
|
2601
|
+
__decorate([n$1({
|
|
2602
|
+
type: String,
|
|
2603
|
+
attribute: "error-text"
|
|
2604
|
+
})], Select.prototype, "errorText", void 0);
|
|
2605
|
+
__decorate([n$1()], Select.prototype, "label", void 0);
|
|
2606
|
+
__decorate([n$1({
|
|
2607
|
+
type: Boolean,
|
|
2608
|
+
attribute: "no-asterisk"
|
|
2609
|
+
})], Select.prototype, "noAsterisk", void 0);
|
|
2610
|
+
__decorate([n$1({
|
|
2611
|
+
type: String,
|
|
2612
|
+
attribute: "supporting-text"
|
|
2613
|
+
})], Select.prototype, "supportingText", void 0);
|
|
2614
|
+
__decorate([n$1({
|
|
2615
|
+
type: Boolean,
|
|
2616
|
+
reflect: true
|
|
2617
|
+
})], Select.prototype, "error", void 0);
|
|
2618
|
+
__decorate([n$1({ attribute: "menu-positioning" })], Select.prototype, "menuPositioning", void 0);
|
|
2619
|
+
__decorate([n$1({
|
|
2620
|
+
type: Boolean,
|
|
2621
|
+
attribute: "clamp-menu-width"
|
|
2622
|
+
})], Select.prototype, "clampMenuWidth", void 0);
|
|
2623
|
+
__decorate([n$1({
|
|
2624
|
+
type: Number,
|
|
2625
|
+
attribute: "typeahead-delay"
|
|
2626
|
+
})], Select.prototype, "typeaheadDelay", void 0);
|
|
2627
|
+
__decorate([n$1({
|
|
2628
|
+
type: Boolean,
|
|
2629
|
+
attribute: "has-leading-icon"
|
|
2630
|
+
})], Select.prototype, "hasLeadingIcon", void 0);
|
|
2631
|
+
__decorate([n$1({ attribute: "display-text" })], Select.prototype, "displayText", void 0);
|
|
2632
|
+
__decorate([n$1({ attribute: "menu-align" })], Select.prototype, "menuAlign", void 0);
|
|
2633
|
+
__decorate([n$1()], Select.prototype, "value", null);
|
|
2634
|
+
__decorate([n$1({
|
|
2635
|
+
type: Number,
|
|
2636
|
+
attribute: "selected-index"
|
|
2637
|
+
})], Select.prototype, "selectedIndex", null);
|
|
2638
|
+
__decorate([r$1()], Select.prototype, "nativeError", void 0);
|
|
2639
|
+
__decorate([r$1()], Select.prototype, "nativeErrorText", void 0);
|
|
2640
|
+
__decorate([r$1()], Select.prototype, "focused", void 0);
|
|
2641
|
+
__decorate([r$1()], Select.prototype, "open", void 0);
|
|
2642
|
+
__decorate([r$1()], Select.prototype, "defaultFocus", void 0);
|
|
2643
|
+
__decorate([e$3(".field")], Select.prototype, "field", void 0);
|
|
2644
|
+
__decorate([e$3("md-menu")], Select.prototype, "menu", void 0);
|
|
2645
|
+
__decorate([e$3("#label")], Select.prototype, "labelEl", void 0);
|
|
2646
|
+
__decorate([o({
|
|
2647
|
+
slot: "leading-icon",
|
|
2648
|
+
flatten: true
|
|
2649
|
+
})], Select.prototype, "leadingIcons", void 0);
|
|
2650
|
+
// ../../node_modules/.pnpm/@material+web@2.5.0/node_modules/@material/web/select/internal/outlined-select.js
|
|
2651
|
+
/**
|
|
2652
|
+
* @license
|
|
2653
|
+
* Copyright 2023 Google LLC
|
|
2654
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
2655
|
+
*/
|
|
2656
|
+
var OutlinedSelect = class extends Select {
|
|
2657
|
+
constructor() {
|
|
2658
|
+
super(...arguments);
|
|
2659
|
+
this.fieldTag = i$2`md-outlined-field`;
|
|
2660
|
+
}
|
|
2661
|
+
};
|
|
2662
|
+
// ../../node_modules/.pnpm/@material+web@2.5.0/node_modules/@material/web/select/internal/outlined-select-styles.cssresult.js
|
|
2663
|
+
/**
|
|
2664
|
+
* @license
|
|
2665
|
+
* Copyright 2026 Google LLC
|
|
2666
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
2667
|
+
*/
|
|
2668
|
+
var styles$3 = i$1`:host{--_text-field-disabled-input-text-color: var(--md-outlined-select-text-field-disabled-input-text-color, var(--md-sys-color-on-surface, #1d1b20));--_text-field-disabled-input-text-opacity: var(--md-outlined-select-text-field-disabled-input-text-opacity, 0.38);--_text-field-disabled-label-text-color: var(--md-outlined-select-text-field-disabled-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_text-field-disabled-label-text-opacity: var(--md-outlined-select-text-field-disabled-label-text-opacity, 0.38);--_text-field-disabled-leading-icon-color: var(--md-outlined-select-text-field-disabled-leading-icon-color, var(--md-sys-color-on-surface, #1d1b20));--_text-field-disabled-leading-icon-opacity: var(--md-outlined-select-text-field-disabled-leading-icon-opacity, 0.38);--_text-field-disabled-outline-color: var(--md-outlined-select-text-field-disabled-outline-color, var(--md-sys-color-on-surface, #1d1b20));--_text-field-disabled-outline-opacity: var(--md-outlined-select-text-field-disabled-outline-opacity, 0.12);--_text-field-disabled-outline-width: var(--md-outlined-select-text-field-disabled-outline-width, 1px);--_text-field-disabled-supporting-text-color: var(--md-outlined-select-text-field-disabled-supporting-text-color, var(--md-sys-color-on-surface, #1d1b20));--_text-field-disabled-supporting-text-opacity: var(--md-outlined-select-text-field-disabled-supporting-text-opacity, 0.38);--_text-field-disabled-trailing-icon-color: var(--md-outlined-select-text-field-disabled-trailing-icon-color, var(--md-sys-color-on-surface, #1d1b20));--_text-field-disabled-trailing-icon-opacity: var(--md-outlined-select-text-field-disabled-trailing-icon-opacity, 0.38);--_text-field-error-focus-input-text-color: var(--md-outlined-select-text-field-error-focus-input-text-color, var(--md-sys-color-on-surface, #1d1b20));--_text-field-error-focus-label-text-color: var(--md-outlined-select-text-field-error-focus-label-text-color, var(--md-sys-color-error, #b3261e));--_text-field-error-focus-leading-icon-color: var(--md-outlined-select-text-field-error-focus-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-error-focus-outline-color: var(--md-outlined-select-text-field-error-focus-outline-color, var(--md-sys-color-error, #b3261e));--_text-field-error-focus-supporting-text-color: var(--md-outlined-select-text-field-error-focus-supporting-text-color, var(--md-sys-color-error, #b3261e));--_text-field-error-focus-trailing-icon-color: var(--md-outlined-select-text-field-error-focus-trailing-icon-color, var(--md-sys-color-error, #b3261e));--_text-field-error-hover-input-text-color: var(--md-outlined-select-text-field-error-hover-input-text-color, var(--md-sys-color-on-surface, #1d1b20));--_text-field-error-hover-label-text-color: var(--md-outlined-select-text-field-error-hover-label-text-color, var(--md-sys-color-on-error-container, #410e0b));--_text-field-error-hover-leading-icon-color: var(--md-outlined-select-text-field-error-hover-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-error-hover-outline-color: var(--md-outlined-select-text-field-error-hover-outline-color, var(--md-sys-color-on-error-container, #410e0b));--_text-field-error-hover-supporting-text-color: var(--md-outlined-select-text-field-error-hover-supporting-text-color, var(--md-sys-color-error, #b3261e));--_text-field-error-hover-trailing-icon-color: var(--md-outlined-select-text-field-error-hover-trailing-icon-color, var(--md-sys-color-on-error-container, #410e0b));--_text-field-error-input-text-color: var(--md-outlined-select-text-field-error-input-text-color, var(--md-sys-color-on-surface, #1d1b20));--_text-field-error-label-text-color: var(--md-outlined-select-text-field-error-label-text-color, var(--md-sys-color-error, #b3261e));--_text-field-error-leading-icon-color: var(--md-outlined-select-text-field-error-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-error-outline-color: var(--md-outlined-select-text-field-error-outline-color, var(--md-sys-color-error, #b3261e));--_text-field-error-supporting-text-color: var(--md-outlined-select-text-field-error-supporting-text-color, var(--md-sys-color-error, #b3261e));--_text-field-error-trailing-icon-color: var(--md-outlined-select-text-field-error-trailing-icon-color, var(--md-sys-color-error, #b3261e));--_text-field-focus-input-text-color: var(--md-outlined-select-text-field-focus-input-text-color, var(--md-sys-color-on-surface, #1d1b20));--_text-field-focus-label-text-color: var(--md-outlined-select-text-field-focus-label-text-color, var(--md-sys-color-primary, #6750a4));--_text-field-focus-leading-icon-color: var(--md-outlined-select-text-field-focus-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-focus-outline-color: var(--md-outlined-select-text-field-focus-outline-color, var(--md-sys-color-primary, #6750a4));--_text-field-focus-outline-width: var(--md-outlined-select-text-field-focus-outline-width, 3px);--_text-field-focus-supporting-text-color: var(--md-outlined-select-text-field-focus-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-focus-trailing-icon-color: var(--md-outlined-select-text-field-focus-trailing-icon-color, var(--md-sys-color-primary, #6750a4));--_text-field-hover-input-text-color: var(--md-outlined-select-text-field-hover-input-text-color, var(--md-sys-color-on-surface, #1d1b20));--_text-field-hover-label-text-color: var(--md-outlined-select-text-field-hover-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_text-field-hover-leading-icon-color: var(--md-outlined-select-text-field-hover-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-hover-outline-color: var(--md-outlined-select-text-field-hover-outline-color, var(--md-sys-color-on-surface, #1d1b20));--_text-field-hover-outline-width: var(--md-outlined-select-text-field-hover-outline-width, 1px);--_text-field-hover-supporting-text-color: var(--md-outlined-select-text-field-hover-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-hover-trailing-icon-color: var(--md-outlined-select-text-field-hover-trailing-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-input-text-color: var(--md-outlined-select-text-field-input-text-color, var(--md-sys-color-on-surface, #1d1b20));--_text-field-input-text-font: var(--md-outlined-select-text-field-input-text-font, var(--md-sys-typescale-body-large-font, var(--md-ref-typeface-plain, Roboto)));--_text-field-input-text-line-height: var(--md-outlined-select-text-field-input-text-line-height, var(--md-sys-typescale-body-large-line-height, 1.5rem));--_text-field-input-text-size: var(--md-outlined-select-text-field-input-text-size, var(--md-sys-typescale-body-large-size, 1rem));--_text-field-input-text-weight: var(--md-outlined-select-text-field-input-text-weight, var(--md-sys-typescale-body-large-weight, var(--md-ref-typeface-weight-regular, 400)));--_text-field-label-text-color: var(--md-outlined-select-text-field-label-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-label-text-font: var(--md-outlined-select-text-field-label-text-font, var(--md-sys-typescale-body-large-font, var(--md-ref-typeface-plain, Roboto)));--_text-field-label-text-line-height: var(--md-outlined-select-text-field-label-text-line-height, var(--md-sys-typescale-body-large-line-height, 1.5rem));--_text-field-label-text-populated-line-height: var(--md-outlined-select-text-field-label-text-populated-line-height, var(--md-sys-typescale-body-small-line-height, 1rem));--_text-field-label-text-populated-size: var(--md-outlined-select-text-field-label-text-populated-size, var(--md-sys-typescale-body-small-size, 0.75rem));--_text-field-label-text-size: var(--md-outlined-select-text-field-label-text-size, var(--md-sys-typescale-body-large-size, 1rem));--_text-field-label-text-weight: var(--md-outlined-select-text-field-label-text-weight, var(--md-sys-typescale-body-large-weight, var(--md-ref-typeface-weight-regular, 400)));--_text-field-leading-icon-color: var(--md-outlined-select-text-field-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-leading-icon-size: var(--md-outlined-select-text-field-leading-icon-size, 24px);--_text-field-outline-color: var(--md-outlined-select-text-field-outline-color, var(--md-sys-color-outline, #79747e));--_text-field-outline-width: var(--md-outlined-select-text-field-outline-width, 1px);--_text-field-supporting-text-color: var(--md-outlined-select-text-field-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-supporting-text-font: var(--md-outlined-select-text-field-supporting-text-font, var(--md-sys-typescale-body-small-font, var(--md-ref-typeface-plain, Roboto)));--_text-field-supporting-text-line-height: var(--md-outlined-select-text-field-supporting-text-line-height, var(--md-sys-typescale-body-small-line-height, 1rem));--_text-field-supporting-text-size: var(--md-outlined-select-text-field-supporting-text-size, var(--md-sys-typescale-body-small-size, 0.75rem));--_text-field-supporting-text-weight: var(--md-outlined-select-text-field-supporting-text-weight, var(--md-sys-typescale-body-small-weight, var(--md-ref-typeface-weight-regular, 400)));--_text-field-trailing-icon-color: var(--md-outlined-select-text-field-trailing-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_text-field-trailing-icon-size: var(--md-outlined-select-text-field-trailing-icon-size, 24px);--_text-field-container-shape-start-start: var(--md-outlined-select-text-field-container-shape-start-start, var(--md-outlined-select-text-field-container-shape, var(--md-sys-shape-corner-extra-small, 4px)));--_text-field-container-shape-start-end: var(--md-outlined-select-text-field-container-shape-start-end, var(--md-outlined-select-text-field-container-shape, var(--md-sys-shape-corner-extra-small, 4px)));--_text-field-container-shape-end-end: var(--md-outlined-select-text-field-container-shape-end-end, var(--md-outlined-select-text-field-container-shape, var(--md-sys-shape-corner-extra-small, 4px)));--_text-field-container-shape-end-start: var(--md-outlined-select-text-field-container-shape-end-start, var(--md-outlined-select-text-field-container-shape, var(--md-sys-shape-corner-extra-small, 4px)));--md-outlined-field-container-shape-end-end: var(--_text-field-container-shape-end-end);--md-outlined-field-container-shape-end-start: var(--_text-field-container-shape-end-start);--md-outlined-field-container-shape-start-end: var(--_text-field-container-shape-start-end);--md-outlined-field-container-shape-start-start: var(--_text-field-container-shape-start-start);--md-outlined-field-content-color: var(--_text-field-input-text-color);--md-outlined-field-content-font: var(--_text-field-input-text-font);--md-outlined-field-content-line-height: var(--_text-field-input-text-line-height);--md-outlined-field-content-size: var(--_text-field-input-text-size);--md-outlined-field-content-weight: var(--_text-field-input-text-weight);--md-outlined-field-disabled-content-color: var(--_text-field-disabled-input-text-color);--md-outlined-field-disabled-content-opacity: var(--_text-field-disabled-input-text-opacity);--md-outlined-field-disabled-label-text-color: var(--_text-field-disabled-label-text-color);--md-outlined-field-disabled-label-text-opacity: var(--_text-field-disabled-label-text-opacity);--md-outlined-field-disabled-leading-content-color: var(--_text-field-disabled-leading-icon-color);--md-outlined-field-disabled-leading-content-opacity: var(--_text-field-disabled-leading-icon-opacity);--md-outlined-field-disabled-outline-color: var(--_text-field-disabled-outline-color);--md-outlined-field-disabled-outline-opacity: var(--_text-field-disabled-outline-opacity);--md-outlined-field-disabled-outline-width: var(--_text-field-disabled-outline-width);--md-outlined-field-disabled-supporting-text-color: var(--_text-field-disabled-supporting-text-color);--md-outlined-field-disabled-supporting-text-opacity: var(--_text-field-disabled-supporting-text-opacity);--md-outlined-field-disabled-trailing-content-color: var(--_text-field-disabled-trailing-icon-color);--md-outlined-field-disabled-trailing-content-opacity: var(--_text-field-disabled-trailing-icon-opacity);--md-outlined-field-error-content-color: var(--_text-field-error-input-text-color);--md-outlined-field-error-focus-content-color: var(--_text-field-error-focus-input-text-color);--md-outlined-field-error-focus-label-text-color: var(--_text-field-error-focus-label-text-color);--md-outlined-field-error-focus-leading-content-color: var(--_text-field-error-focus-leading-icon-color);--md-outlined-field-error-focus-outline-color: var(--_text-field-error-focus-outline-color);--md-outlined-field-error-focus-supporting-text-color: var(--_text-field-error-focus-supporting-text-color);--md-outlined-field-error-focus-trailing-content-color: var(--_text-field-error-focus-trailing-icon-color);--md-outlined-field-error-hover-content-color: var(--_text-field-error-hover-input-text-color);--md-outlined-field-error-hover-label-text-color: var(--_text-field-error-hover-label-text-color);--md-outlined-field-error-hover-leading-content-color: var(--_text-field-error-hover-leading-icon-color);--md-outlined-field-error-hover-outline-color: var(--_text-field-error-hover-outline-color);--md-outlined-field-error-hover-supporting-text-color: var(--_text-field-error-hover-supporting-text-color);--md-outlined-field-error-hover-trailing-content-color: var(--_text-field-error-hover-trailing-icon-color);--md-outlined-field-error-label-text-color: var(--_text-field-error-label-text-color);--md-outlined-field-error-leading-content-color: var(--_text-field-error-leading-icon-color);--md-outlined-field-error-outline-color: var(--_text-field-error-outline-color);--md-outlined-field-error-supporting-text-color: var(--_text-field-error-supporting-text-color);--md-outlined-field-error-trailing-content-color: var(--_text-field-error-trailing-icon-color);--md-outlined-field-focus-content-color: var(--_text-field-focus-input-text-color);--md-outlined-field-focus-label-text-color: var(--_text-field-focus-label-text-color);--md-outlined-field-focus-leading-content-color: var(--_text-field-focus-leading-icon-color);--md-outlined-field-focus-outline-color: var(--_text-field-focus-outline-color);--md-outlined-field-focus-outline-width: var(--_text-field-focus-outline-width);--md-outlined-field-focus-supporting-text-color: var(--_text-field-focus-supporting-text-color);--md-outlined-field-focus-trailing-content-color: var(--_text-field-focus-trailing-icon-color);--md-outlined-field-hover-content-color: var(--_text-field-hover-input-text-color);--md-outlined-field-hover-label-text-color: var(--_text-field-hover-label-text-color);--md-outlined-field-hover-leading-content-color: var(--_text-field-hover-leading-icon-color);--md-outlined-field-hover-outline-color: var(--_text-field-hover-outline-color);--md-outlined-field-hover-outline-width: var(--_text-field-hover-outline-width);--md-outlined-field-hover-supporting-text-color: var(--_text-field-hover-supporting-text-color);--md-outlined-field-hover-trailing-content-color: var(--_text-field-hover-trailing-icon-color);--md-outlined-field-label-text-color: var(--_text-field-label-text-color);--md-outlined-field-label-text-font: var(--_text-field-label-text-font);--md-outlined-field-label-text-line-height: var(--_text-field-label-text-line-height);--md-outlined-field-label-text-populated-line-height: var(--_text-field-label-text-populated-line-height);--md-outlined-field-label-text-populated-size: var(--_text-field-label-text-populated-size);--md-outlined-field-label-text-size: var(--_text-field-label-text-size);--md-outlined-field-label-text-weight: var(--_text-field-label-text-weight);--md-outlined-field-leading-content-color: var(--_text-field-leading-icon-color);--md-outlined-field-outline-color: var(--_text-field-outline-color);--md-outlined-field-outline-width: var(--_text-field-outline-width);--md-outlined-field-supporting-text-color: var(--_text-field-supporting-text-color);--md-outlined-field-supporting-text-font: var(--_text-field-supporting-text-font);--md-outlined-field-supporting-text-line-height: var(--_text-field-supporting-text-line-height);--md-outlined-field-supporting-text-size: var(--_text-field-supporting-text-size);--md-outlined-field-supporting-text-weight: var(--_text-field-supporting-text-weight);--md-outlined-field-trailing-content-color: var(--_text-field-trailing-icon-color)}[has-start] .icon.leading{font-size:var(--_text-field-leading-icon-size);height:var(--_text-field-leading-icon-size);width:var(--_text-field-leading-icon-size)}.icon.trailing{font-size:var(--_text-field-trailing-icon-size);height:var(--_text-field-trailing-icon-size);width:var(--_text-field-trailing-icon-size)}
|
|
2669
|
+
`;
|
|
2670
|
+
styles$3.styleSheet;
|
|
2671
|
+
// ../../node_modules/.pnpm/@material+web@2.5.0/node_modules/@material/web/select/internal/shared-styles.cssresult.js
|
|
2672
|
+
/**
|
|
2673
|
+
* @license
|
|
2674
|
+
* Copyright 2026 Google LLC
|
|
2675
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
2676
|
+
*/
|
|
2677
|
+
var styles$2 = i$1`:host{color:unset;min-width:210px;display:flex}.field{cursor:default;outline:none}.select{position:relative;flex-direction:column}.icon.trailing svg,.icon ::slotted(*){fill:currentColor}.icon ::slotted(*){width:inherit;height:inherit;font-size:inherit}.icon slot{display:flex;height:100%;width:100%;align-items:center;justify-content:center}.icon.trailing :is(.up,.down){opacity:0;transition:opacity 75ms linear 75ms}.select:not(.open) .down,.select.open .up{opacity:1}.field,.select,md-menu{min-width:inherit;width:inherit;max-width:inherit;display:flex}md-menu{min-width:var(--__menu-min-width);max-width:var(--__menu-max-width, inherit)}.menu-wrapper{width:0px;height:0px;max-width:inherit}md-menu ::slotted(:not[disabled]){cursor:pointer}.field,.select{width:100%}:host{display:inline-flex}:host([disabled]){pointer-events:none}
|
|
2678
|
+
`;
|
|
2679
|
+
styles$2.styleSheet;
|
|
2680
|
+
// ../../node_modules/.pnpm/@material+web@2.5.0/node_modules/@material/web/select/outlined-select.js
|
|
2681
|
+
/**
|
|
2682
|
+
* @license
|
|
2683
|
+
* Copyright 2023 Google LLC
|
|
2684
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
2685
|
+
*/
|
|
2686
|
+
/**
|
|
2687
|
+
* @summary
|
|
2688
|
+
* Select menus display a list of choices on temporary surfaces and display the
|
|
2689
|
+
* currently selected menu item above the menu.
|
|
2690
|
+
*
|
|
2691
|
+
* @description
|
|
2692
|
+
* The select component allows users to choose a value from a fixed list of
|
|
2693
|
+
* available options. Composed of an interactive anchor button and a menu, it is
|
|
2694
|
+
* analogous to the native HTML `<select>` element. This is the "outlined"
|
|
2695
|
+
* variant.
|
|
2696
|
+
*
|
|
2697
|
+
* @example
|
|
2698
|
+
* ```html
|
|
2699
|
+
* <md-outlined-select label="fruits">
|
|
2700
|
+
* <!-- An empty selected option will give select an "un-filled" state -->
|
|
2701
|
+
* <md-select-option selected></md-select-option>
|
|
2702
|
+
* <md-select-option value="apple" headline="Apple"></md-select-option>
|
|
2703
|
+
* <md-select-option value="banana" headline="Banana"></md-select-option>
|
|
2704
|
+
* <md-select-option value="kiwi" headline="Kiwi"></md-select-option>
|
|
2705
|
+
* <md-select-option value="orange" headline="Orange"></md-select-option>
|
|
2706
|
+
* <md-select-option value="tomato" headline="Tomato"></md-select-option>
|
|
2707
|
+
* </md-outlined-select>
|
|
2708
|
+
* ```
|
|
2709
|
+
*
|
|
2710
|
+
* @final
|
|
2711
|
+
* @suppress {visibility}
|
|
2712
|
+
*/
|
|
2713
|
+
var MdOutlinedSelect = class MdOutlinedSelect extends OutlinedSelect {};
|
|
2714
|
+
MdOutlinedSelect.styles = [styles$2, styles$3];
|
|
2715
|
+
MdOutlinedSelect = __decorate([t("md-outlined-select")], MdOutlinedSelect);
|
|
2716
|
+
// ../../node_modules/.pnpm/@material+web@2.5.0/node_modules/@material/web/menu/internal/menuitem/menu-item-styles.cssresult.js
|
|
2717
|
+
/**
|
|
2718
|
+
* @license
|
|
2719
|
+
* Copyright 2026 Google LLC
|
|
2720
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
2721
|
+
*/
|
|
2722
|
+
var styles$1 = i$1`:host{display:flex;gap:16px;--md-ripple-hover-color: var(--md-menu-item-hover-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--md-ripple-hover-opacity: var(--md-menu-item-hover-state-layer-opacity, 0.08);--md-ripple-pressed-color: var(--md-menu-item-pressed-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--md-ripple-pressed-opacity: var(--md-menu-item-pressed-state-layer-opacity, 0.12)}:host([disabled]){opacity:var(--md-menu-item-disabled-opacity, 0.3);pointer-events:none}md-focus-ring{z-index:1;--md-focus-ring-shape: 8px}a,button,li{background:none;border:none;padding:0;margin:0;text-align:unset;text-decoration:none}.list-item{border-radius:inherit;display:flex;flex:1;gap:inherit;max-width:inherit;min-width:inherit;outline:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}.list-item:not(.disabled){cursor:pointer}[slot=container]{pointer-events:none}md-ripple{border-radius:inherit}md-item{border-radius:inherit;flex:1;color:var(--md-menu-item-label-text-color, var(--md-sys-color-on-surface, #1d1b20));font-family:var(--md-menu-item-label-text-font, var(--md-sys-typescale-body-large-font, var(--md-ref-typeface-plain, Roboto)));font-size:var(--md-menu-item-label-text-size, var(--md-sys-typescale-body-large-size, 1rem));line-height:var(--md-menu-item-label-text-line-height, var(--md-sys-typescale-body-large-line-height, 1.5rem));font-weight:var(--md-menu-item-label-text-weight, var(--md-sys-typescale-body-large-weight, var(--md-ref-typeface-weight-regular, 400)));min-height:var(--md-menu-item-one-line-container-height, 56px);padding-top:var(--md-menu-item-top-space, 12px);padding-bottom:var(--md-menu-item-bottom-space, 12px);padding-inline-start:var(--md-menu-item-leading-space, 16px);padding-inline-end:var(--md-menu-item-trailing-space, 16px);gap:inherit}md-item[multiline]{min-height:var(--md-menu-item-two-line-container-height, 72px)}[slot=supporting-text]{color:var(--md-menu-item-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));font-family:var(--md-menu-item-supporting-text-font, var(--md-sys-typescale-body-medium-font, var(--md-ref-typeface-plain, Roboto)));font-size:var(--md-menu-item-supporting-text-size, var(--md-sys-typescale-body-medium-size, 0.875rem));line-height:var(--md-menu-item-supporting-text-line-height, var(--md-sys-typescale-body-medium-line-height, 1.25rem));font-weight:var(--md-menu-item-supporting-text-weight, var(--md-sys-typescale-body-medium-weight, var(--md-ref-typeface-weight-regular, 400)))}[slot=trailing-supporting-text]{color:var(--md-menu-item-trailing-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));font-family:var(--md-menu-item-trailing-supporting-text-font, var(--md-sys-typescale-label-small-font, var(--md-ref-typeface-plain, Roboto)));font-size:var(--md-menu-item-trailing-supporting-text-size, var(--md-sys-typescale-label-small-size, 0.6875rem));line-height:var(--md-menu-item-trailing-supporting-text-line-height, var(--md-sys-typescale-label-small-line-height, 1rem));font-weight:var(--md-menu-item-trailing-supporting-text-weight, var(--md-sys-typescale-label-small-weight, var(--md-ref-typeface-weight-medium, 500)))}:is([slot=start],[slot=end])::slotted(*){fill:currentColor}[slot=start]{color:var(--md-menu-item-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f))}[slot=end]{color:var(--md-menu-item-trailing-icon-color, var(--md-sys-color-on-surface-variant, #49454f))}.list-item{background-color:var(--md-menu-item-container-color, transparent)}.list-item.selected{background-color:var(--md-menu-item-selected-container-color, var(--md-sys-color-secondary-container, #e8def8))}.selected:not(.disabled) ::slotted(*){color:var(--md-menu-item-selected-label-text-color, var(--md-sys-color-on-secondary-container, #1d192b))}@media(forced-colors: active){:host([disabled]),:host([disabled]) slot{color:GrayText;opacity:1}.list-item{position:relative}.list-item.selected::before{content:"";position:absolute;inset:0;box-sizing:border-box;border-radius:inherit;pointer-events:none;border:3px double CanvasText}}
|
|
2723
|
+
`;
|
|
2724
|
+
styles$1.styleSheet;
|
|
2725
|
+
// ../../node_modules/.pnpm/@material+web@2.5.0/node_modules/@material/web/labs/item/internal/item.js
|
|
2726
|
+
/**
|
|
2727
|
+
* @license
|
|
2728
|
+
* Copyright 2023 Google LLC
|
|
2729
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
2730
|
+
*/
|
|
2731
|
+
/**
|
|
2732
|
+
* An item layout component.
|
|
2733
|
+
*/
|
|
2734
|
+
var Item = class extends i {
|
|
2735
|
+
constructor() {
|
|
2736
|
+
super(...arguments);
|
|
2737
|
+
/**
|
|
2738
|
+
* Only needed for SSR.
|
|
2739
|
+
*
|
|
2740
|
+
* Add this attribute when an item has two lines to avoid a Flash Of Unstyled
|
|
2741
|
+
* Content. This attribute is not needed for single line items or items with
|
|
2742
|
+
* three or more lines.
|
|
2743
|
+
*/
|
|
2744
|
+
this.multiline = false;
|
|
2745
|
+
}
|
|
2746
|
+
render() {
|
|
2747
|
+
return T`
|
|
2748
|
+
<slot name="container"></slot>
|
|
2749
|
+
<slot class="non-text" name="start"></slot>
|
|
2750
|
+
<div class="text">
|
|
2751
|
+
<slot name="overline" @slotchange=${this.handleTextSlotChange}></slot>
|
|
2752
|
+
<slot
|
|
2753
|
+
class="default-slot"
|
|
2754
|
+
@slotchange=${this.handleTextSlotChange}></slot>
|
|
2755
|
+
<slot name="headline" @slotchange=${this.handleTextSlotChange}></slot>
|
|
2756
|
+
<slot
|
|
2757
|
+
name="supporting-text"
|
|
2758
|
+
@slotchange=${this.handleTextSlotChange}></slot>
|
|
2759
|
+
</div>
|
|
2760
|
+
<slot class="non-text" name="trailing-supporting-text"></slot>
|
|
2761
|
+
<slot class="non-text" name="end"></slot>
|
|
2762
|
+
`;
|
|
2763
|
+
}
|
|
2764
|
+
handleTextSlotChange() {
|
|
2765
|
+
let isMultiline = false;
|
|
2766
|
+
let slotsWithContent = 0;
|
|
2767
|
+
for (const slot of this.textSlots) {
|
|
2768
|
+
if (slotHasContent(slot)) slotsWithContent += 1;
|
|
2769
|
+
if (slotsWithContent > 1) {
|
|
2770
|
+
isMultiline = true;
|
|
2771
|
+
break;
|
|
2772
|
+
}
|
|
2773
|
+
}
|
|
2774
|
+
this.multiline = isMultiline;
|
|
2775
|
+
}
|
|
18
2776
|
};
|
|
19
|
-
|
|
2777
|
+
__decorate([n$1({
|
|
2778
|
+
type: Boolean,
|
|
2779
|
+
reflect: true
|
|
2780
|
+
})], Item.prototype, "multiline", void 0);
|
|
2781
|
+
__decorate([r(".text slot")], Item.prototype, "textSlots", void 0);
|
|
2782
|
+
function slotHasContent(slot) {
|
|
2783
|
+
for (const node of slot.assignedNodes({ flatten: true })) {
|
|
2784
|
+
const isElement = node.nodeType === Node.ELEMENT_NODE;
|
|
2785
|
+
const isTextWithContent = node.nodeType === Node.TEXT_NODE && node.textContent?.match(/\S/);
|
|
2786
|
+
if (isElement || isTextWithContent) return true;
|
|
2787
|
+
}
|
|
2788
|
+
return false;
|
|
2789
|
+
}
|
|
2790
|
+
// ../../node_modules/.pnpm/@material+web@2.5.0/node_modules/@material/web/labs/item/internal/item-styles.cssresult.js
|
|
20
2791
|
/**
|
|
21
2792
|
* @license
|
|
22
2793
|
* Copyright 2026 Google LLC
|
|
23
2794
|
* SPDX-License-Identifier: Apache-2.0
|
|
24
2795
|
*/
|
|
25
|
-
var styles = i`:host{
|
|
2796
|
+
var styles = i$1`:host{color:var(--md-sys-color-on-surface, #1d1b20);font-family:var(--md-sys-typescale-body-large-font, var(--md-ref-typeface-plain, Roboto));font-size:var(--md-sys-typescale-body-large-size, 1rem);font-weight:var(--md-sys-typescale-body-large-weight, var(--md-ref-typeface-weight-regular, 400));line-height:var(--md-sys-typescale-body-large-line-height, 1.5rem);align-items:center;box-sizing:border-box;display:flex;gap:16px;min-height:56px;overflow:hidden;padding:12px 16px;position:relative;text-overflow:ellipsis}:host([multiline]){min-height:72px}[name=overline]{color:var(--md-sys-color-on-surface-variant, #49454f);font-family:var(--md-sys-typescale-label-small-font, var(--md-ref-typeface-plain, Roboto));font-size:var(--md-sys-typescale-label-small-size, 0.6875rem);font-weight:var(--md-sys-typescale-label-small-weight, var(--md-ref-typeface-weight-medium, 500));line-height:var(--md-sys-typescale-label-small-line-height, 1rem)}[name=supporting-text]{color:var(--md-sys-color-on-surface-variant, #49454f);font-family:var(--md-sys-typescale-body-medium-font, var(--md-ref-typeface-plain, Roboto));font-size:var(--md-sys-typescale-body-medium-size, 0.875rem);font-weight:var(--md-sys-typescale-body-medium-weight, var(--md-ref-typeface-weight-regular, 400));line-height:var(--md-sys-typescale-body-medium-line-height, 1.25rem)}[name=trailing-supporting-text]{color:var(--md-sys-color-on-surface-variant, #49454f);font-family:var(--md-sys-typescale-label-small-font, var(--md-ref-typeface-plain, Roboto));font-size:var(--md-sys-typescale-label-small-size, 0.6875rem);font-weight:var(--md-sys-typescale-label-small-weight, var(--md-ref-typeface-weight-medium, 500));line-height:var(--md-sys-typescale-label-small-line-height, 1rem)}[name=container]::slotted(*){inset:0;position:absolute}.default-slot{display:inline}.default-slot,.text ::slotted(*){overflow:hidden;text-overflow:ellipsis}.text{display:flex;flex:1;flex-direction:column;overflow:hidden}
|
|
26
2797
|
`;
|
|
27
2798
|
styles.styleSheet;
|
|
28
|
-
// ../../node_modules/.pnpm/@material+web@2.5.0/node_modules/@material/web/
|
|
2799
|
+
// ../../node_modules/.pnpm/@material+web@2.5.0/node_modules/@material/web/labs/item/item.js
|
|
29
2800
|
/**
|
|
30
2801
|
* @license
|
|
31
|
-
* Copyright
|
|
2802
|
+
* Copyright 2023 Google LLC
|
|
32
2803
|
* SPDX-License-Identifier: Apache-2.0
|
|
33
2804
|
*/
|
|
34
2805
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
2806
|
+
* An item layout component that can be used inside list items to give them
|
|
2807
|
+
* their customizable structure.
|
|
2808
|
+
*
|
|
2809
|
+
* `<md-item>` does not have any functionality, which must be added by the
|
|
2810
|
+
* component using it.
|
|
2811
|
+
*
|
|
2812
|
+
* All text will wrap unless `white-space: nowrap` is set on the item or any of
|
|
2813
|
+
* its children.
|
|
2814
|
+
*
|
|
2815
|
+
* Slots available:
|
|
2816
|
+
* - `<default>`: The headline, or custom content.
|
|
2817
|
+
* - `headline`: The first line.
|
|
2818
|
+
* - `supporting-text`: Supporting text lines underneath the headline.
|
|
2819
|
+
* - `trailing-supporting-text`: A small text snippet at the end of the item.
|
|
2820
|
+
* - `start`: Any leading content, such as icons, avatars, or checkboxes.
|
|
2821
|
+
* - `end`: Any trailing content, such as icons and buttons.
|
|
2822
|
+
* - `container`: Background container content, intended for adding additional
|
|
2823
|
+
* styles, such as ripples or focus rings.
|
|
2824
|
+
*
|
|
2825
|
+
* @example
|
|
2826
|
+
* ```html
|
|
2827
|
+
* <md-item>Single line</md-item>
|
|
2828
|
+
*
|
|
2829
|
+
* <md-item>
|
|
2830
|
+
* <div class="custom-content">...</div>
|
|
2831
|
+
* </md-item>
|
|
2832
|
+
*
|
|
2833
|
+
* <!-- Classic 1 to 3+ line list items -->
|
|
2834
|
+
* <md-item>
|
|
2835
|
+
* <md-icon slot="start">image</md-icon>
|
|
2836
|
+
* <div slot="overline">Overline</div>
|
|
2837
|
+
* <div slot="headline">Headline</div>
|
|
2838
|
+
* <div="supporting-text">Supporting text</div>
|
|
2839
|
+
* <div="trailing-supporting-text">Trailing</div>
|
|
2840
|
+
* <md-icon slot="end">image</md-icon>
|
|
2841
|
+
* </md-item>
|
|
2842
|
+
* ```
|
|
2843
|
+
*
|
|
2844
|
+
* When wrapping `<md-item>`, forward the available slots to use the same slot
|
|
2845
|
+
* structure for the wrapping component (this is what `<md-list-item>` does).
|
|
2846
|
+
*
|
|
2847
|
+
* @example
|
|
2848
|
+
* ```html
|
|
2849
|
+
* <md-item>
|
|
2850
|
+
* <slot></slot>
|
|
2851
|
+
* <slot name="overline" slot="overline"></slot>
|
|
2852
|
+
* <slot name="headline" slot="headline"></slot>
|
|
2853
|
+
* <slot name="supporting-text" slot="supporting-text"></slot>
|
|
2854
|
+
* <slot name="trailing-supporting-text"
|
|
2855
|
+
* slot="trailing-supporting-text"></slot>
|
|
2856
|
+
* <slot name="start" slot="start"></slot>
|
|
2857
|
+
* <slot name="end" slot="end"></slot>
|
|
2858
|
+
* </md-item>
|
|
2859
|
+
* ```
|
|
2860
|
+
*
|
|
2861
|
+
* @final
|
|
2862
|
+
* @suppress {visibility}
|
|
2863
|
+
*/
|
|
2864
|
+
var MdItem = class MdItem extends Item {};
|
|
2865
|
+
MdItem.styles = [styles];
|
|
2866
|
+
MdItem = __decorate([t("md-item")], MdItem);
|
|
2867
|
+
// ../../node_modules/.pnpm/@material+web@2.5.0/node_modules/@material/web/menu/internal/controllers/menuItemController.js
|
|
2868
|
+
/**
|
|
2869
|
+
* @license
|
|
2870
|
+
* Copyright 2023 Google LLC
|
|
2871
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
2872
|
+
*/
|
|
2873
|
+
/**
|
|
2874
|
+
* A controller that provides most functionality of an element that implements
|
|
2875
|
+
* the MenuItem interface.
|
|
2876
|
+
*/
|
|
2877
|
+
var MenuItemController = class {
|
|
2878
|
+
/**
|
|
2879
|
+
* @param host The MenuItem in which to attach this controller to.
|
|
2880
|
+
* @param config The object that configures this controller's behavior.
|
|
2881
|
+
*/
|
|
2882
|
+
constructor(host, config) {
|
|
2883
|
+
this.host = host;
|
|
2884
|
+
this.internalTypeaheadText = null;
|
|
2885
|
+
/**
|
|
2886
|
+
* Bind this click listener to the interactive element. Handles closing the
|
|
2887
|
+
* menu.
|
|
2888
|
+
*/
|
|
2889
|
+
this.onClick = () => {
|
|
2890
|
+
if (this.host.keepOpen) return;
|
|
2891
|
+
this.host.dispatchEvent(createDefaultCloseMenuEvent(this.host, { kind: CloseReason.CLICK_SELECTION }));
|
|
2892
|
+
};
|
|
2893
|
+
/**
|
|
2894
|
+
* Bind this click listener to the interactive element. Handles closing the
|
|
2895
|
+
* menu.
|
|
2896
|
+
*/
|
|
2897
|
+
this.onKeydown = (event) => {
|
|
2898
|
+
if (this.host.href && event.code === "Enter") {
|
|
2899
|
+
const interactiveElement = this.getInteractiveElement();
|
|
2900
|
+
if (interactiveElement instanceof HTMLAnchorElement) interactiveElement.click();
|
|
2901
|
+
}
|
|
2902
|
+
if (event.defaultPrevented) return;
|
|
2903
|
+
const keyCode = event.code;
|
|
2904
|
+
if (this.host.keepOpen && keyCode !== "Escape") return;
|
|
2905
|
+
if (isClosableKey(keyCode)) {
|
|
2906
|
+
event.preventDefault();
|
|
2907
|
+
this.host.dispatchEvent(createDefaultCloseMenuEvent(this.host, {
|
|
2908
|
+
kind: CloseReason.KEYDOWN,
|
|
2909
|
+
key: keyCode
|
|
2910
|
+
}));
|
|
2911
|
+
}
|
|
2912
|
+
};
|
|
2913
|
+
this.getHeadlineElements = config.getHeadlineElements;
|
|
2914
|
+
this.getSupportingTextElements = config.getSupportingTextElements;
|
|
2915
|
+
this.getDefaultElements = config.getDefaultElements;
|
|
2916
|
+
this.getInteractiveElement = config.getInteractiveElement;
|
|
2917
|
+
this.host.addController(this);
|
|
2918
|
+
}
|
|
2919
|
+
/**
|
|
2920
|
+
* The text that is selectable via typeahead. If not set, defaults to the
|
|
2921
|
+
* innerText of the item slotted into the `"headline"` slot, and if there are
|
|
2922
|
+
* no slotted elements into headline, then it checks the _default_ slot, and
|
|
2923
|
+
* then the `"supporting-text"` slot if nothing is in _default_.
|
|
2924
|
+
*/
|
|
2925
|
+
get typeaheadText() {
|
|
2926
|
+
if (this.internalTypeaheadText !== null) return this.internalTypeaheadText;
|
|
2927
|
+
const headlineElements = this.getHeadlineElements();
|
|
2928
|
+
const textParts = [];
|
|
2929
|
+
headlineElements.forEach((headlineElement) => {
|
|
2930
|
+
if (headlineElement.textContent && headlineElement.textContent.trim()) textParts.push(headlineElement.textContent.trim());
|
|
2931
|
+
});
|
|
2932
|
+
if (textParts.length === 0) this.getDefaultElements().forEach((defaultElement) => {
|
|
2933
|
+
if (defaultElement.textContent && defaultElement.textContent.trim()) textParts.push(defaultElement.textContent.trim());
|
|
2934
|
+
});
|
|
2935
|
+
if (textParts.length === 0) this.getSupportingTextElements().forEach((supportingTextElement) => {
|
|
2936
|
+
if (supportingTextElement.textContent && supportingTextElement.textContent.trim()) textParts.push(supportingTextElement.textContent.trim());
|
|
2937
|
+
});
|
|
2938
|
+
return textParts.join(" ");
|
|
2939
|
+
}
|
|
2940
|
+
/**
|
|
2941
|
+
* The recommended tag name to render as the list item.
|
|
2942
|
+
*/
|
|
2943
|
+
get tagName() {
|
|
2944
|
+
switch (this.host.type) {
|
|
2945
|
+
case "link": return "a";
|
|
2946
|
+
case "button": return "button";
|
|
2947
|
+
default:
|
|
2948
|
+
case "menuitem":
|
|
2949
|
+
case "option": return "li";
|
|
2950
|
+
}
|
|
2951
|
+
}
|
|
2952
|
+
/**
|
|
2953
|
+
* The recommended role of the menu item.
|
|
2954
|
+
*/
|
|
2955
|
+
get role() {
|
|
2956
|
+
return this.host.type === "option" ? "option" : "menuitem";
|
|
2957
|
+
}
|
|
2958
|
+
hostConnected() {
|
|
2959
|
+
this.host.toggleAttribute("md-menu-item", true);
|
|
2960
|
+
}
|
|
2961
|
+
hostUpdate() {
|
|
2962
|
+
if (this.host.href) this.host.type = "link";
|
|
2963
|
+
}
|
|
2964
|
+
/**
|
|
2965
|
+
* Use to set the typeaheadText when it changes.
|
|
2966
|
+
*/
|
|
2967
|
+
setTypeaheadText(text) {
|
|
2968
|
+
this.internalTypeaheadText = text;
|
|
2969
|
+
}
|
|
2970
|
+
};
|
|
2971
|
+
// ../../node_modules/.pnpm/@material+web@2.5.0/node_modules/@material/web/select/internal/selectoption/selectOptionController.js
|
|
2972
|
+
/**
|
|
2973
|
+
* @license
|
|
2974
|
+
* Copyright 2023 Google LLC
|
|
2975
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
2976
|
+
*/
|
|
2977
|
+
/**
|
|
2978
|
+
* Creates an event fired by a SelectOption to request selection from md-select.
|
|
2979
|
+
* Typically fired after `selected` changes from `false` to `true`.
|
|
2980
|
+
*/
|
|
2981
|
+
function createRequestSelectionEvent() {
|
|
2982
|
+
return new Event("request-selection", {
|
|
2983
|
+
bubbles: true,
|
|
2984
|
+
composed: true
|
|
2985
|
+
});
|
|
2986
|
+
}
|
|
2987
|
+
/**
|
|
2988
|
+
* Creates an event fired by a SelectOption to request deselection from
|
|
2989
|
+
* md-select. Typically fired after `selected` changes from `true` to `false`.
|
|
2990
|
+
*/
|
|
2991
|
+
function createRequestDeselectionEvent() {
|
|
2992
|
+
return new Event("request-deselection", {
|
|
2993
|
+
bubbles: true,
|
|
2994
|
+
composed: true
|
|
2995
|
+
});
|
|
2996
|
+
}
|
|
2997
|
+
/**
|
|
2998
|
+
* A controller that provides most functionality and md-select compatibility for
|
|
2999
|
+
* an element that implements the SelectOption interface.
|
|
3000
|
+
*/
|
|
3001
|
+
var SelectOptionController = class {
|
|
3002
|
+
/**
|
|
3003
|
+
* The recommended role of the select option.
|
|
3004
|
+
*/
|
|
3005
|
+
get role() {
|
|
3006
|
+
return this.menuItemController.role;
|
|
3007
|
+
}
|
|
3008
|
+
/**
|
|
3009
|
+
* The text that is selectable via typeahead. If not set, defaults to the
|
|
3010
|
+
* innerText of the item slotted into the `"headline"` slot, and if there are
|
|
3011
|
+
* no slotted elements into headline, then it checks the _default_ slot, and
|
|
3012
|
+
* then the `"supporting-text"` slot if nothing is in _default_.
|
|
3013
|
+
*/
|
|
3014
|
+
get typeaheadText() {
|
|
3015
|
+
return this.menuItemController.typeaheadText;
|
|
3016
|
+
}
|
|
3017
|
+
setTypeaheadText(text) {
|
|
3018
|
+
this.menuItemController.setTypeaheadText(text);
|
|
3019
|
+
}
|
|
3020
|
+
/**
|
|
3021
|
+
* The text that is displayed in the select field when selected. If not set,
|
|
3022
|
+
* defaults to the textContent of the item slotted into the `"headline"` slot,
|
|
3023
|
+
* and if there are no slotted elements into headline, then it checks the
|
|
3024
|
+
* _default_ slot, and then the `"supporting-text"` slot if nothing is in
|
|
3025
|
+
* _default_.
|
|
3026
|
+
*/
|
|
3027
|
+
get displayText() {
|
|
3028
|
+
if (this.internalDisplayText !== null) return this.internalDisplayText;
|
|
3029
|
+
return this.menuItemController.typeaheadText;
|
|
3030
|
+
}
|
|
3031
|
+
setDisplayText(text) {
|
|
3032
|
+
this.internalDisplayText = text;
|
|
3033
|
+
}
|
|
3034
|
+
/**
|
|
3035
|
+
* @param host The SelectOption in which to attach this controller to.
|
|
3036
|
+
* @param config The object that configures this controller's behavior.
|
|
3037
|
+
*/
|
|
3038
|
+
constructor(host, config) {
|
|
3039
|
+
this.host = host;
|
|
3040
|
+
this.internalDisplayText = null;
|
|
3041
|
+
this.firstUpdate = true;
|
|
3042
|
+
/**
|
|
3043
|
+
* Bind this click listener to the interactive element. Handles closing the
|
|
3044
|
+
* menu.
|
|
3045
|
+
*/
|
|
3046
|
+
this.onClick = () => {
|
|
3047
|
+
this.menuItemController.onClick();
|
|
3048
|
+
};
|
|
3049
|
+
/**
|
|
3050
|
+
* Bind this click listener to the interactive element. Handles closing the
|
|
3051
|
+
* menu.
|
|
3052
|
+
*/
|
|
3053
|
+
this.onKeydown = (e) => {
|
|
3054
|
+
this.menuItemController.onKeydown(e);
|
|
3055
|
+
};
|
|
3056
|
+
this.lastSelected = this.host.selected;
|
|
3057
|
+
this.menuItemController = new MenuItemController(host, config);
|
|
3058
|
+
host.addController(this);
|
|
3059
|
+
}
|
|
3060
|
+
hostUpdate() {
|
|
3061
|
+
if (this.lastSelected !== this.host.selected) this.host.ariaSelected = this.host.selected ? "true" : "false";
|
|
3062
|
+
}
|
|
3063
|
+
hostUpdated() {
|
|
3064
|
+
if (this.lastSelected !== this.host.selected && !this.firstUpdate) {
|
|
3065
|
+
if (this.host.selected) this.host.dispatchEvent(createRequestSelectionEvent());
|
|
3066
|
+
else this.host.dispatchEvent(createRequestDeselectionEvent());
|
|
3067
|
+
}
|
|
3068
|
+
this.lastSelected = this.host.selected;
|
|
3069
|
+
this.firstUpdate = false;
|
|
3070
|
+
}
|
|
3071
|
+
};
|
|
3072
|
+
// ../../node_modules/.pnpm/@material+web@2.5.0/node_modules/@material/web/select/internal/selectoption/select-option.js
|
|
3073
|
+
/**
|
|
3074
|
+
* @license
|
|
3075
|
+
* Copyright 2023 Google LLC
|
|
3076
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
3077
|
+
*/
|
|
3078
|
+
var selectOptionBaseClass = mixinDelegatesAria(i);
|
|
3079
|
+
/**
|
|
3080
|
+
* @fires close-menu {CustomEvent<{initiator: SelectOption, reason: Reason, itemPath: SelectOption[]}>}
|
|
3081
|
+
* Closes the encapsulating menu on closable interaction. --bubbles --composed
|
|
3082
|
+
* @fires request-selection {Event} Requests the parent md-select to select this
|
|
3083
|
+
* element (and deselect others if single-selection) when `selected` changed to
|
|
3084
|
+
* `true`. --bubbles --composed
|
|
3085
|
+
* @fires request-deselection {Event} Requests the parent md-select to deselect
|
|
3086
|
+
* this element when `selected` changed to `false`. --bubbles --composed
|
|
3087
|
+
*/
|
|
3088
|
+
var SelectOptionEl = class extends selectOptionBaseClass {
|
|
3089
|
+
constructor() {
|
|
3090
|
+
super(...arguments);
|
|
3091
|
+
/**
|
|
3092
|
+
* Disables the item and makes it non-selectable and non-interactive.
|
|
3093
|
+
*/
|
|
3094
|
+
this.disabled = false;
|
|
3095
|
+
/**
|
|
3096
|
+
* READONLY: self-identifies as a menu item and sets its identifying attribute
|
|
3097
|
+
*/
|
|
3098
|
+
this.isMenuItem = true;
|
|
3099
|
+
/**
|
|
3100
|
+
* Sets the item in the selected visual state when a submenu is opened.
|
|
3101
|
+
*/
|
|
3102
|
+
this.selected = false;
|
|
3103
|
+
/**
|
|
3104
|
+
* Form value of the option.
|
|
3105
|
+
*/
|
|
3106
|
+
this.value = "";
|
|
3107
|
+
this.type = "option";
|
|
3108
|
+
this.selectOptionController = new SelectOptionController(this, {
|
|
3109
|
+
getHeadlineElements: () => {
|
|
3110
|
+
return this.headlineElements;
|
|
3111
|
+
},
|
|
3112
|
+
getSupportingTextElements: () => {
|
|
3113
|
+
return this.supportingTextElements;
|
|
3114
|
+
},
|
|
3115
|
+
getDefaultElements: () => {
|
|
3116
|
+
return this.defaultElements;
|
|
3117
|
+
},
|
|
3118
|
+
getInteractiveElement: () => this.listItemRoot
|
|
3119
|
+
});
|
|
3120
|
+
}
|
|
3121
|
+
/**
|
|
3122
|
+
* The text that is selectable via typeahead. If not set, defaults to the
|
|
3123
|
+
* innerText of the item slotted into the `"headline"` slot.
|
|
3124
|
+
*/
|
|
3125
|
+
get typeaheadText() {
|
|
3126
|
+
return this.selectOptionController.typeaheadText;
|
|
3127
|
+
}
|
|
3128
|
+
set typeaheadText(text) {
|
|
3129
|
+
this.selectOptionController.setTypeaheadText(text);
|
|
3130
|
+
}
|
|
3131
|
+
/**
|
|
3132
|
+
* The text that is displayed in the select field when selected. If not set,
|
|
3133
|
+
* defaults to the textContent of the item slotted into the `"headline"` slot.
|
|
3134
|
+
*/
|
|
3135
|
+
get displayText() {
|
|
3136
|
+
return this.selectOptionController.displayText;
|
|
3137
|
+
}
|
|
3138
|
+
set displayText(text) {
|
|
3139
|
+
this.selectOptionController.setDisplayText(text);
|
|
3140
|
+
}
|
|
3141
|
+
render() {
|
|
3142
|
+
return this.renderListItem(T`
|
|
3143
|
+
<md-item>
|
|
3144
|
+
<div slot="container">
|
|
3145
|
+
${this.renderRipple()} ${this.renderFocusRing()}
|
|
3146
|
+
</div>
|
|
3147
|
+
<slot name="start" slot="start"></slot>
|
|
3148
|
+
<slot name="end" slot="end"></slot>
|
|
3149
|
+
${this.renderBody()}
|
|
3150
|
+
</md-item>
|
|
3151
|
+
`);
|
|
3152
|
+
}
|
|
3153
|
+
/**
|
|
3154
|
+
* Renders the root list item.
|
|
3155
|
+
*
|
|
3156
|
+
* @param content the child content of the list item.
|
|
3157
|
+
*/
|
|
3158
|
+
renderListItem(content) {
|
|
3159
|
+
return T`
|
|
3160
|
+
<li
|
|
3161
|
+
id="item"
|
|
3162
|
+
tabindex=${this.disabled ? -1 : 0}
|
|
3163
|
+
role=${this.selectOptionController.role}
|
|
3164
|
+
aria-label=${this.ariaLabel || A}
|
|
3165
|
+
aria-selected=${this.ariaSelected || A}
|
|
3166
|
+
aria-checked=${this.ariaChecked || A}
|
|
3167
|
+
aria-expanded=${this.ariaExpanded || A}
|
|
3168
|
+
aria-haspopup=${this.ariaHasPopup || A}
|
|
3169
|
+
class="list-item ${e$2(this.getRenderClasses())}"
|
|
3170
|
+
@click=${this.selectOptionController.onClick}
|
|
3171
|
+
@keydown=${this.selectOptionController.onKeydown}
|
|
3172
|
+
>${content}</li
|
|
3173
|
+
>
|
|
3174
|
+
`;
|
|
3175
|
+
}
|
|
3176
|
+
/**
|
|
3177
|
+
* Handles rendering of the ripple element.
|
|
3178
|
+
*/
|
|
3179
|
+
renderRipple() {
|
|
3180
|
+
return T` <md-ripple
|
|
3181
|
+
part="ripple"
|
|
3182
|
+
for="item"
|
|
3183
|
+
?disabled=${this.disabled}></md-ripple>`;
|
|
3184
|
+
}
|
|
3185
|
+
/**
|
|
3186
|
+
* Handles rendering of the focus ring.
|
|
3187
|
+
*/
|
|
3188
|
+
renderFocusRing() {
|
|
3189
|
+
return T` <md-focus-ring
|
|
3190
|
+
part="focus-ring"
|
|
3191
|
+
for="item"
|
|
3192
|
+
inward></md-focus-ring>`;
|
|
3193
|
+
}
|
|
3194
|
+
/**
|
|
3195
|
+
* Classes applied to the list item root.
|
|
3196
|
+
*/
|
|
3197
|
+
getRenderClasses() {
|
|
3198
|
+
return {
|
|
3199
|
+
"disabled": this.disabled,
|
|
3200
|
+
"selected": this.selected
|
|
3201
|
+
};
|
|
3202
|
+
}
|
|
3203
|
+
/**
|
|
3204
|
+
* Handles rendering the headline and supporting text.
|
|
3205
|
+
*/
|
|
3206
|
+
renderBody() {
|
|
3207
|
+
return T`
|
|
3208
|
+
<slot></slot>
|
|
3209
|
+
<slot name="overline" slot="overline"></slot>
|
|
3210
|
+
<slot name="headline" slot="headline"></slot>
|
|
3211
|
+
<slot name="supporting-text" slot="supporting-text"></slot>
|
|
3212
|
+
<slot
|
|
3213
|
+
name="trailing-supporting-text"
|
|
3214
|
+
slot="trailing-supporting-text"></slot>
|
|
3215
|
+
`;
|
|
3216
|
+
}
|
|
3217
|
+
focus() {
|
|
3218
|
+
this.listItemRoot?.focus();
|
|
3219
|
+
}
|
|
3220
|
+
};
|
|
3221
|
+
/** @nocollapse */
|
|
3222
|
+
SelectOptionEl.shadowRootOptions = {
|
|
3223
|
+
...i.shadowRootOptions,
|
|
3224
|
+
delegatesFocus: true
|
|
3225
|
+
};
|
|
3226
|
+
__decorate([n$1({
|
|
3227
|
+
type: Boolean,
|
|
3228
|
+
reflect: true
|
|
3229
|
+
})], SelectOptionEl.prototype, "disabled", void 0);
|
|
3230
|
+
__decorate([n$1({
|
|
3231
|
+
type: Boolean,
|
|
3232
|
+
attribute: "md-menu-item",
|
|
3233
|
+
reflect: true
|
|
3234
|
+
})], SelectOptionEl.prototype, "isMenuItem", void 0);
|
|
3235
|
+
__decorate([n$1({ type: Boolean })], SelectOptionEl.prototype, "selected", void 0);
|
|
3236
|
+
__decorate([n$1()], SelectOptionEl.prototype, "value", void 0);
|
|
3237
|
+
__decorate([e$3(".list-item")], SelectOptionEl.prototype, "listItemRoot", void 0);
|
|
3238
|
+
__decorate([o({ slot: "headline" })], SelectOptionEl.prototype, "headlineElements", void 0);
|
|
3239
|
+
__decorate([o({ slot: "supporting-text" })], SelectOptionEl.prototype, "supportingTextElements", void 0);
|
|
3240
|
+
__decorate([n({ slot: "" })], SelectOptionEl.prototype, "defaultElements", void 0);
|
|
3241
|
+
__decorate([n$1({ attribute: "typeahead-text" })], SelectOptionEl.prototype, "typeaheadText", null);
|
|
3242
|
+
__decorate([n$1({ attribute: "display-text" })], SelectOptionEl.prototype, "displayText", null);
|
|
3243
|
+
// ../../node_modules/.pnpm/@material+web@2.5.0/node_modules/@material/web/select/select-option.js
|
|
3244
|
+
/**
|
|
3245
|
+
* @license
|
|
3246
|
+
* Copyright 2023 Google LLC
|
|
3247
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
3248
|
+
*/
|
|
3249
|
+
/**
|
|
3250
|
+
* @summary
|
|
3251
|
+
* Select menus display a list of choices on temporary surfaces and display the
|
|
3252
|
+
* currently selected menu item above the menu.
|
|
37
3253
|
*
|
|
38
3254
|
* @description
|
|
39
|
-
*
|
|
40
|
-
*
|
|
3255
|
+
* The select component allows users to choose a value from a fixed list of
|
|
3256
|
+
* available options. Composed of an interactive anchor button and a menu, it is
|
|
3257
|
+
* analogous to the native HTML `<select>` element. This is the option that
|
|
3258
|
+
* can be placed inside of an md-select.
|
|
41
3259
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* actions in a flow.
|
|
3260
|
+
* This component is a subclass of `md-menu-item` and can accept the same slots,
|
|
3261
|
+
* properties, and events as `md-menu-item`.
|
|
45
3262
|
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* -
|
|
49
|
-
* -
|
|
3263
|
+
* @example
|
|
3264
|
+
* ```html
|
|
3265
|
+
* <md-outlined-select label="fruits">
|
|
3266
|
+
* <!-- An empty selected option will give select an "un-filled" state -->
|
|
3267
|
+
* <md-select-option selected></md-select-option>
|
|
3268
|
+
* <md-select-option value="apple" headline="Apple"></md-select-option>
|
|
3269
|
+
* <md-select-option value="banana" headline="Banana"></md-select-option>
|
|
3270
|
+
* <md-select-option value="kiwi" headline="Kiwi"></md-select-option>
|
|
3271
|
+
* <md-select-option value="orange" headline="Orange"></md-select-option>
|
|
3272
|
+
* <md-select-option value="tomato" headline="Tomato"></md-select-option>
|
|
3273
|
+
* </md-outlined-select>
|
|
3274
|
+
* ```
|
|
50
3275
|
*
|
|
51
3276
|
* @final
|
|
52
3277
|
* @suppress {visibility}
|
|
53
3278
|
*/
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
];
|
|
60
|
-
MdFilledButton = __decorate([t("md-filled-button")], MdFilledButton);
|
|
61
|
-
// src/lib/components/TcpPortSetting/TcpPortSetting.svelte
|
|
62
|
-
function TcpPortSetting($$renderer, $$props) {
|
|
3279
|
+
var MdSelectOption = class MdSelectOption extends SelectOptionEl {};
|
|
3280
|
+
MdSelectOption.styles = [styles$1];
|
|
3281
|
+
MdSelectOption = __decorate([t("md-select-option")], MdSelectOption);
|
|
3282
|
+
// src/lib/components/CheckboxField/CheckboxField.svelte
|
|
3283
|
+
function CheckboxField($$renderer, $$props) {
|
|
63
3284
|
$$renderer.component(($$renderer) => {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
let { active, saved, overriddenBy, onSave } = $$props;
|
|
69
|
-
let fieldError = "";
|
|
70
|
-
let busy = false;
|
|
71
|
-
const shown = derived(() => String(saved));
|
|
72
|
-
const changed = derived(() => false);
|
|
73
|
-
const pending = derived(() => saved !== active);
|
|
74
|
-
$$renderer.push(`<form novalidate="" class="svelte-1oos7l"><md-outlined-text-field label="TCP port" inputmode="numeric" autocomplete="off" supporting-text="The port the screen reader's speech voice sends to. Default 4449."${attr("value", shown())}${attr("disabled", overriddenBy !== null, true)}${attr("error", false)}${attr("error-text", fieldError)}></md-outlined-text-field> `);
|
|
75
|
-
if (overriddenBy !== null) $$renderer.push(`<!--[0--><p class="note svelte-1oos7l">Set by <code class="svelte-1oos7l">${escape_html(overriddenBy)}</code> when the bridge starts, so a saved port has no effect. Remove
|
|
76
|
-
it to change the port here.</p>`);
|
|
77
|
-
else $$renderer.push(`<!--[-1--><div class="actions svelte-1oos7l"><md-filled-button type="submit"${attr("disabled", !changed() || busy, true)}>Save</md-filled-button> <md-text-button type="button"${attr("disabled", !changed() || busy, true)}>Revert</md-text-button></div>`);
|
|
78
|
-
$$renderer.push(`<!--]--> <p class="note svelte-1oos7l">In use: ${escape_html(active)}</p> <div role="status" class="status">`);
|
|
79
|
-
if (pending()) $$renderer.push(`<!--[0--><div class="pending svelte-1oos7l"><strong>Restart the bridge to use port ${escape_html(saved)}.</strong> It still listens on ${escape_html(active)} until it is restarted. The speech voice on the VM sends to a fixed
|
|
80
|
-
port, so also add a voice for ${escape_html(saved)} (<code class="svelte-1oos7l">text-to-socket-engine-add-voice</code>) and
|
|
81
|
-
select it in the screen reader.</div>`);
|
|
3285
|
+
const id = props_id($$renderer);
|
|
3286
|
+
let { path, label, checked, help, error, onChange } = $$props;
|
|
3287
|
+
$$renderer.push(`<div><label class="svelte-6obkkj"><input type="checkbox"${attr("data-setting", path)}${attr("checked", checked, true)}${attr("aria-describedby", error === "" ? `${id}-help` : `${id}-error ${id}-help`)}${attr("aria-invalid", error === "" ? void 0 : true)} class="svelte-6obkkj"/> <span>${escape_html(label)}</span></label> <p class="help svelte-6obkkj"${attr("id", `${id}-help`)}>${escape_html(help)}</p> `);
|
|
3288
|
+
if (error !== "") $$renderer.push(`<!--[0--><p class="error svelte-6obkkj"${attr("id", `${id}-error`)} role="alert">${escape_html(error)}</p>`);
|
|
82
3289
|
else $$renderer.push("<!--[-1-->");
|
|
3290
|
+
$$renderer.push(`<!--]--></div>`);
|
|
3291
|
+
});
|
|
3292
|
+
}
|
|
3293
|
+
// src/lib/components/SettingField/SettingField.svelte
|
|
3294
|
+
function SettingField($$renderer, $$props) {
|
|
3295
|
+
$$renderer.component(($$renderer) => {
|
|
3296
|
+
/** What the control holds: the draft, or the saved value. */
|
|
3297
|
+
/** The saved value, as the control holds it. */
|
|
3298
|
+
/** The text under the control. */
|
|
3299
|
+
/** The value in use while the saved one waits for a restart. */
|
|
3300
|
+
/** Why the value was refused; empty if it wasn't. */
|
|
3301
|
+
/**
|
|
3302
|
+
* Set when a flag or variable sets the setting: it can't be changed here, so the field is a
|
|
3303
|
+
* read-only row with the value in use.
|
|
3304
|
+
*/
|
|
3305
|
+
/** Enter in a text field. */
|
|
3306
|
+
let { setting, value, savedValue, help, pendingValue, error, fixed, onInput, onSubmit } = $$props;
|
|
3307
|
+
const supporting = derived(() => pendingValue === void 0 ? help : `Restart pending, in use: ${pendingValue}. ${help}`);
|
|
3308
|
+
if (fixed !== void 0) $$renderer.push(`<!--[0--><dl class="svelte-rc157l"><dt class="svelte-rc157l">${escape_html(setting.label)}</dt> <dd class="value svelte-rc157l">${escape_html(fixed.value)}</dd> <dd class="note svelte-rc157l">Set by <code class="svelte-rc157l">${escape_html(fixed.by)}</code>. Change it where the bridge is started.</dd></dl>`);
|
|
3309
|
+
else {
|
|
3310
|
+
$$renderer.push(`<!--[-1--><div${attr_class("svelte-rc157l", void 0, { "pending": pendingValue !== void 0 })}>`);
|
|
3311
|
+
if (setting.control.kind === "checkbox") {
|
|
3312
|
+
$$renderer.push("<!--[0-->");
|
|
3313
|
+
CheckboxField($$renderer, {
|
|
3314
|
+
path: setting.path,
|
|
3315
|
+
label: setting.label,
|
|
3316
|
+
checked: value === "true",
|
|
3317
|
+
help: supporting(),
|
|
3318
|
+
error,
|
|
3319
|
+
onChange: (checked) => onInput(String(checked))
|
|
3320
|
+
});
|
|
3321
|
+
} else if (setting.control.kind === "select") {
|
|
3322
|
+
$$renderer.push(`<!--[1--><md-outlined-select${attr("data-setting", setting.path)}${attr("label", setting.label)}${attr("supporting-text", supporting())}${attr("value", value)}${attr("error", error !== "" ? true : void 0)}${attr("error-text", error)} class="svelte-rc157l"><!--[-->`);
|
|
3323
|
+
const each_array = ensure_array_like(selectOptions(setting.control.options, savedValue));
|
|
3324
|
+
for (let $$index = 0, $$length = each_array.length; $$index < $$length; $$index++) {
|
|
3325
|
+
let option = each_array[$$index];
|
|
3326
|
+
$$renderer.push(`<md-select-option${attr("value", option.value)}${attr("selected", option.value === value ? true : void 0, true)}><div slot="headline">${escape_html(option.label)}</div></md-select-option>`);
|
|
3327
|
+
}
|
|
3328
|
+
$$renderer.push(`<!--]--></md-outlined-select>`);
|
|
3329
|
+
} else $$renderer.push(`<!--[-1--><md-outlined-text-field${attr("data-setting", setting.path)}${attr("label", setting.label)}${attr("inputmode", setting.control.inputmode)}${attr("suffix-text", setting.control.suffix)} autocomplete="off"${attr("supporting-text", supporting())}${attr("value", value)}${attr("error", error !== "" ? true : void 0)}${attr("error-text", error)} class="svelte-rc157l"></md-outlined-text-field>`);
|
|
3330
|
+
$$renderer.push(`<!--]--></div>`);
|
|
3331
|
+
}
|
|
3332
|
+
$$renderer.push(`<!--]-->`);
|
|
3333
|
+
});
|
|
3334
|
+
}
|
|
3335
|
+
// src/lib/components/SettingsForm/SettingsForm.svelte
|
|
3336
|
+
function SettingsForm($$renderer, $$props) {
|
|
3337
|
+
$$renderer.component(($$renderer) => {
|
|
3338
|
+
/** What the form's buttons are about, for their accessible names (`speech capture`). */
|
|
3339
|
+
/** In order, one per grid cell; settings that belong together share a cell, stacked. */
|
|
3340
|
+
/** The configuration in use. */
|
|
3341
|
+
/** The configuration the next start will use. */
|
|
3342
|
+
/** What sets a setting (`--tcp-port`) when a flag or variable does: it can't be changed here. */
|
|
3343
|
+
/** Rejects with a message to show; resolves when the patch is saved. */
|
|
3344
|
+
let { name, settings, active, saved, overrides, settingContext, onSave } = $$props;
|
|
3345
|
+
/** What was typed; a field without a draft follows the saved value. */
|
|
3346
|
+
let drafts = {};
|
|
3347
|
+
let errors = {};
|
|
3348
|
+
let failure = "";
|
|
3349
|
+
let busy = false;
|
|
3350
|
+
/**
|
|
3351
|
+
* Set while the last thing that happened to this form is a save that worked: whether it left
|
|
3352
|
+
* something waiting for a restart.
|
|
3353
|
+
*/
|
|
3354
|
+
let justSaved = null;
|
|
3355
|
+
let form;
|
|
3356
|
+
const cells = derived(() => settings.map((cell) => [cell].flat()));
|
|
3357
|
+
const editable = derived(() => cells().flat().filter((setting) => overrides[setting.path] === void 0));
|
|
3358
|
+
const changed = derived(() => changedSettings(editable(), drafts, saved));
|
|
3359
|
+
const idle = derived(() => changed().length === 0 || busy);
|
|
3360
|
+
const waits = derived(() => editable().some((setting) => isPending(setting.path, active, saved, overrides)));
|
|
3361
|
+
const savedMessage = derived(() => {
|
|
3362
|
+
if (justSaved === null) return "";
|
|
3363
|
+
if (!justSaved.waited) return "Saved.";
|
|
3364
|
+
return waits() ? "Saved. Restart the bridge to apply." : "";
|
|
3365
|
+
});
|
|
3366
|
+
async function focusField(path) {
|
|
3367
|
+
await /* @__PURE__ */ tick();
|
|
3368
|
+
form.querySelector(`[data-setting="${path}"]`)?.focus();
|
|
3369
|
+
}
|
|
3370
|
+
async function save() {
|
|
3371
|
+
if (busy || changed().length === 0) return;
|
|
3372
|
+
const result = buildPatch(editable(), drafts, saved);
|
|
3373
|
+
failure = "";
|
|
3374
|
+
justSaved = null;
|
|
3375
|
+
if (!result.ok) {
|
|
3376
|
+
errors = result.errors;
|
|
3377
|
+
await focusField(editable().find((setting) => result.errors[setting.path] !== void 0).path);
|
|
3378
|
+
return;
|
|
3379
|
+
}
|
|
3380
|
+
errors = {};
|
|
3381
|
+
busy = true;
|
|
3382
|
+
try {
|
|
3383
|
+
await onSave(result.patch);
|
|
3384
|
+
drafts = {};
|
|
3385
|
+
justSaved = { waited: waits() };
|
|
3386
|
+
} catch (cause) {
|
|
3387
|
+
const rejection = explainRejection(cause, editable());
|
|
3388
|
+
if (rejection.field === null) failure = rejection.message;
|
|
3389
|
+
else {
|
|
3390
|
+
errors = { [rejection.field]: rejection.message };
|
|
3391
|
+
await focusField(rejection.field);
|
|
3392
|
+
}
|
|
3393
|
+
} finally {
|
|
3394
|
+
busy = false;
|
|
3395
|
+
}
|
|
3396
|
+
}
|
|
3397
|
+
$$renderer.push(`<form novalidate="" class="svelte-1yckkzn"><div class="fields svelte-1yckkzn"><!--[-->`);
|
|
3398
|
+
const each_array = ensure_array_like(cells());
|
|
3399
|
+
for (let $$index_1 = 0, $$length = each_array.length; $$index_1 < $$length; $$index_1++) {
|
|
3400
|
+
let cell = each_array[$$index_1];
|
|
3401
|
+
$$renderer.push(`<div class="cell svelte-1yckkzn"><!--[-->`);
|
|
3402
|
+
const each_array_1 = ensure_array_like(cell);
|
|
3403
|
+
for (let $$index = 0, $$length = each_array_1.length; $$index < $$length; $$index++) {
|
|
3404
|
+
let setting = each_array_1[$$index];
|
|
3405
|
+
const overriddenBy = overrides[setting.path];
|
|
3406
|
+
const inUse = readSetting(active, setting.path);
|
|
3407
|
+
SettingField($$renderer, {
|
|
3408
|
+
setting,
|
|
3409
|
+
value: drafts[setting.path] ?? setting.format(readSetting(saved, setting.path)),
|
|
3410
|
+
savedValue: setting.format(readSetting(saved, setting.path)),
|
|
3411
|
+
help: setting.help(inUse, settingContext),
|
|
3412
|
+
pendingValue: isPending(setting.path, active, saved, overrides) ? setting.describe(inUse, settingContext) : void 0,
|
|
3413
|
+
error: errors[setting.path] ?? "",
|
|
3414
|
+
fixed: overriddenBy === void 0 ? void 0 : {
|
|
3415
|
+
by: overriddenBy,
|
|
3416
|
+
value: setting.describe(inUse, settingContext)
|
|
3417
|
+
},
|
|
3418
|
+
onInput: (value) => {
|
|
3419
|
+
drafts[setting.path] = value;
|
|
3420
|
+
delete errors[setting.path];
|
|
3421
|
+
justSaved = null;
|
|
3422
|
+
},
|
|
3423
|
+
onSubmit: () => void save()
|
|
3424
|
+
});
|
|
3425
|
+
}
|
|
3426
|
+
$$renderer.push(`<!--]--></div>`);
|
|
3427
|
+
}
|
|
83
3428
|
$$renderer.push(`<!--]--></div> `);
|
|
84
|
-
$$renderer.push("
|
|
3429
|
+
if (editable().length > 0) $$renderer.push(`<!--[0--><div class="actions svelte-1yckkzn"><md-filled-button type="submit"${attr("aria-label", `Save ${stringify(name)} settings`)}${attr("soft-disabled", idle() ? true : void 0)}>Save</md-filled-button> <md-text-button type="button"${attr("aria-label", `Revert ${stringify(name)} settings`)}${attr("soft-disabled", idle() ? true : void 0)}>Revert</md-text-button></div>`);
|
|
3430
|
+
else $$renderer.push("<!--[-1-->");
|
|
3431
|
+
$$renderer.push(`<!--]--> <p role="status" class="note svelte-1yckkzn">${escape_html(savedMessage())}</p> `);
|
|
3432
|
+
if (failure !== "") $$renderer.push(`<!--[0--><p role="alert" class="failure svelte-1yckkzn">${escape_html(failure)}</p>`);
|
|
3433
|
+
else $$renderer.push("<!--[-1-->");
|
|
85
3434
|
$$renderer.push(`<!--]--></form>`);
|
|
86
3435
|
});
|
|
87
3436
|
}
|
|
@@ -101,29 +3450,80 @@ function ThemeSetting($$renderer, $$props) {
|
|
|
101
3450
|
// src/routes/settings/+page.svelte
|
|
102
3451
|
function _page($$renderer, $$props) {
|
|
103
3452
|
$$renderer.component(($$renderer) => {
|
|
104
|
-
|
|
3453
|
+
let { data } = $$props;
|
|
3454
|
+
const { config: configStore, status: statusStore, theme: themeStore } = appStores();
|
|
3455
|
+
run(() => configStore.seed(data.config));
|
|
3456
|
+
const settingContext = derived(() => ({
|
|
3457
|
+
runningPlaywright: (statusStore.status ?? data.status)?.playwright.version ?? null,
|
|
3458
|
+
playwrightOff: configStore.saved?.playwright.enabled === false
|
|
3459
|
+
}));
|
|
3460
|
+
const waiting = derived(() => configStore.active === null || configStore.saved === null ? [] : waitingForRestart(configStore.active, configStore.saved, configStore.overrides, settingContext()));
|
|
3461
|
+
async function checkAgain() {
|
|
3462
|
+
await Promise.all([configStore.refresh(), statusStore.retry()]);
|
|
3463
|
+
}
|
|
105
3464
|
head("1i19ct2", $$renderer, ($$renderer) => {
|
|
106
3465
|
$$renderer.title(($$renderer) => {
|
|
107
3466
|
$$renderer.push(`<title>Settings · Speech Capture</title>`);
|
|
108
3467
|
});
|
|
109
3468
|
});
|
|
110
|
-
$$renderer
|
|
111
|
-
|
|
112
|
-
$$renderer
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
3469
|
+
Pane($$renderer, {
|
|
3470
|
+
heading: "Settings",
|
|
3471
|
+
children: ($$renderer) => {
|
|
3472
|
+
$$renderer.push(`<p class="scope intro">Bridge settings apply when the bridge is restarted. Appearance applies at once and is kept in
|
|
3473
|
+
this browser.</p> `);
|
|
3474
|
+
if (configStore.active !== null && configStore.saved !== null) {
|
|
3475
|
+
$$renderer.push("<!--[0-->");
|
|
3476
|
+
RestartSummary($$renderer, {
|
|
3477
|
+
changes: waiting(),
|
|
3478
|
+
reachable: configStore.reachable,
|
|
3479
|
+
onCheck: checkAgain
|
|
3480
|
+
});
|
|
3481
|
+
$$renderer.push(`<!----> <section class="part" aria-labelledby="capture-heading"><h2 id="capture-heading">Speech capture</h2> `);
|
|
3482
|
+
SettingsForm($$renderer, {
|
|
3483
|
+
name: "speech capture",
|
|
3484
|
+
settings: [
|
|
3485
|
+
TCP_PORT,
|
|
3486
|
+
TEXT_ENCODING,
|
|
3487
|
+
BUFFER_SIZE
|
|
3488
|
+
],
|
|
3489
|
+
active: configStore.active,
|
|
3490
|
+
saved: configStore.saved,
|
|
3491
|
+
overrides: configStore.overrides,
|
|
3492
|
+
settingContext: settingContext(),
|
|
3493
|
+
onSave: (patch) => configStore.save(patch)
|
|
3494
|
+
});
|
|
3495
|
+
$$renderer.push(`<!----></section> <section class="part" aria-labelledby="playwright-heading"><h2 id="playwright-heading">Playwright and MCP</h2> `);
|
|
3496
|
+
SettingsForm($$renderer, {
|
|
3497
|
+
name: "Playwright and MCP",
|
|
3498
|
+
settings: [[PLAYWRIGHT_ENABLED, PLAYWRIGHT_VERSION], MCP_ENABLED],
|
|
3499
|
+
active: configStore.active,
|
|
3500
|
+
saved: configStore.saved,
|
|
3501
|
+
overrides: configStore.overrides,
|
|
3502
|
+
settingContext: settingContext(),
|
|
3503
|
+
onSave: (patch) => configStore.save(patch)
|
|
3504
|
+
});
|
|
3505
|
+
$$renderer.push(`<!----></section> <section class="part" aria-labelledby="log-heading"><h2 id="log-heading">Bridge log</h2> `);
|
|
3506
|
+
SettingsForm($$renderer, {
|
|
3507
|
+
name: "bridge log",
|
|
3508
|
+
settings: [LOG_LEVEL],
|
|
3509
|
+
active: configStore.active,
|
|
3510
|
+
saved: configStore.saved,
|
|
3511
|
+
overrides: configStore.overrides,
|
|
3512
|
+
settingContext: settingContext(),
|
|
3513
|
+
onSave: (patch) => configStore.save(patch)
|
|
3514
|
+
});
|
|
3515
|
+
$$renderer.push(`<!----></section>`);
|
|
3516
|
+
} else if (!configStore.reachable) $$renderer.push(`<!--[1--><p class="scope" role="alert">The bridge is not reachable, so its settings can't be read. <button type="button">Try again</button></p>`);
|
|
3517
|
+
else $$renderer.push(`<!--[-1--><p class="scope">Reading the bridge settings…</p>`);
|
|
3518
|
+
$$renderer.push(`<!--]--> <section class="part" aria-labelledby="appearance-heading"><h2 id="appearance-heading">Appearance</h2> `);
|
|
3519
|
+
ThemeSetting($$renderer, {
|
|
3520
|
+
value: themeStore.current,
|
|
3521
|
+
onChange: (theme) => themeStore.set(theme)
|
|
3522
|
+
});
|
|
3523
|
+
$$renderer.push(`<!----></section>`);
|
|
3524
|
+
},
|
|
3525
|
+
$$slots: { default: true }
|
|
3526
|
+
});
|
|
127
3527
|
});
|
|
128
3528
|
}
|
|
129
3529
|
export { _page as default };
|