@astryx-vue/core 0.1.0 → 0.1.3
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 +1 -1
- package/dist/AppShell/index.d.ts +2 -0
- package/dist/AppShell/index.js +2 -0
- package/dist/AppShell-b0PWt9Fz.js +249 -0
- package/dist/AspectRatio/index.d.ts +2 -0
- package/dist/AspectRatio/index.js +2 -0
- package/dist/AspectRatio-Bij7e-tq.js +40 -0
- package/dist/AvatarGroup/index.d.ts +1 -1
- package/dist/Banner/index.d.ts +1 -1
- package/dist/BottomSheet/index.d.ts +1 -1
- package/dist/Button/index.d.ts +1 -1
- package/dist/ButtonGroup/index.d.ts +1 -1
- package/dist/Calendar/index.js +1 -1
- package/dist/{Calendar-DpYFXwgb.js → Calendar-CYhGDT6f.js} +2 -1
- package/dist/Chat/index.js +1 -1
- package/dist/{Chat-Bfd-YPAK.js → Chat-C1aWl5V3.js} +2 -2
- package/dist/CheckboxInput/index.d.ts +1 -1
- package/dist/CheckboxInput/index.js +1 -1
- package/dist/{CheckboxInput-C86o3XoG.js → CheckboxInput-CMsEE1_4.js} +4 -2
- package/dist/CheckboxList/index.d.ts +2 -0
- package/dist/CheckboxList/index.js +2 -0
- package/dist/CheckboxList-EsIEXjK_.js +174 -0
- package/dist/Citation/index.js +1 -1
- package/dist/{Citation-DaDd1teb.js → Citation-C1X0Rde8.js} +2 -2
- package/dist/ClickableCard/index.d.ts +2 -0
- package/dist/ClickableCard/index.js +2 -0
- package/dist/ClickableCard-Bhds4RRe.js +112 -0
- package/dist/Code/index.js +1 -1
- package/dist/{CodeBlock-CK-NWM_1.js → CodeBlock-BQdooQy2.js} +1 -1
- package/dist/Collapsible/index.d.ts +2 -2
- package/dist/Collapsible/index.js +2 -2
- package/dist/Collapsible-BS9ctCQV.js +192 -0
- package/dist/CommandPalette/index.d.ts +2 -0
- package/dist/CommandPalette/index.js +2 -0
- package/dist/CommandPalette-u5h_E05P.js +489 -0
- package/dist/ComplexSelector/index.d.ts +2 -0
- package/dist/ComplexSelector/index.js +2 -0
- package/dist/ComplexSelector-BHmGWml0.js +293 -0
- package/dist/ContextMenu/index.d.ts +1 -1
- package/dist/ContextMenu/index.js +1 -1
- package/dist/{ContextMenu-BJh99Exj.js → ContextMenu-dA-ppaRQ.js} +284 -12
- package/dist/DateInput/index.d.ts +1 -1
- package/dist/DateInput/index.js +1 -1
- package/dist/{DateInput-zJAdXByM.js → DateInput-D2ErjXYO.js} +18 -10
- package/dist/DateRangeInput/index.d.ts +2 -0
- package/dist/DateRangeInput/index.js +2 -0
- package/dist/DateRangeInput-fmQlr_A7.js +385 -0
- package/dist/DateTimeInput/index.d.ts +2 -0
- package/dist/DateTimeInput/index.js +2 -0
- package/dist/DateTimeInput-Bs1JmcIp.js +196 -0
- package/dist/Divider/index.d.ts +1 -1
- package/dist/DropdownMenu/index.d.ts +1 -1
- package/dist/DropdownMenu/index.js +1 -1
- package/dist/{DropdownMenu-C3j2zaEn.js → DropdownMenu-B0gogrvG.js} +2 -2
- package/dist/Field/index.d.ts +2 -2
- package/dist/Field/index.js +3 -4
- package/dist/{Field-VlTBsIEo.js → Field-8zRxzDHE.js} +11 -3
- package/dist/{FieldLabel-B1NRyQlS.js → FieldLabel-DmmJyX7w.js} +6 -1
- package/dist/FieldStatus/index.d.ts +2 -0
- package/dist/FieldStatus/index.js +2 -0
- package/dist/FileInput/index.d.ts +2 -0
- package/dist/FileInput/index.js +2 -0
- package/dist/FileInput-CmAfOpkA.js +238 -0
- package/dist/FormLayout/index.d.ts +2 -0
- package/dist/FormLayout/index.js +2 -0
- package/dist/FormLayout-D47FjiOq.js +40 -0
- package/dist/HoverCard/index.d.ts +1 -1
- package/dist/{Icon-B6qNgBP9.js → Icon-5MdZQ18k.js} +10 -2
- package/dist/Layout/index.d.ts +2 -0
- package/dist/Layout/index.js +3 -0
- package/dist/Layout-Bed3kP0M.js +56 -0
- package/dist/LayoutPanel-C34uOq3e.js +358 -0
- package/dist/List/index.d.ts +1 -1
- package/dist/Markdown/index.d.ts +1 -1
- package/dist/Markdown/index.js +1 -1
- package/dist/{Markdown-DyKIwAL_.js → Markdown-CwtLr3f_.js} +2 -2
- package/dist/MetadataList/index.d.ts +2 -0
- package/dist/MetadataList/index.js +2 -0
- package/dist/MetadataList-DlXQTLog.js +124 -0
- package/dist/MobileNav/index.d.ts +1 -1
- package/dist/MobileNav/index.js +1 -1
- package/dist/{MobileNavToggle-BK2iRJF-.js → MobileNavToggle-CgQamG6E.js} +19 -12
- package/dist/MoreMenu/index.d.ts +1 -1
- package/dist/MoreMenu/index.js +1 -1
- package/dist/{MoreMenu-BjUsVWWk.js → MoreMenu-BXL6Dqsu.js} +2 -2
- package/dist/MultiSelector/index.d.ts +1 -1
- package/dist/MultiSelector/index.js +1 -1
- package/dist/{MultiSelector-CKTbTj1A.js → MultiSelector-DT8ZccMI.js} +3 -3
- package/dist/NavItem/index.d.ts +1 -1
- package/dist/NavMenu/index.d.ts +1 -1
- package/dist/NumberInput/index.d.ts +1 -1
- package/dist/NumberInput/index.js +1 -1
- package/dist/{NumberInput-DU3_rw7z.js → NumberInput-DspJO6z6.js} +1 -1
- package/dist/OverflowList/index.d.ts +1 -1
- package/dist/OverflowList/index.js +1 -1
- package/dist/{OverflowList-B2T5UtiQ.js → OverflowList-zXg3g6fy.js} +1 -1
- package/dist/Overlay/index.d.ts +1 -1
- package/dist/Pagination/index.js +1 -1
- package/dist/{Pagination-qCgNwwhr.js → Pagination-DXfgMUKJ.js} +2 -2
- package/dist/Popover/index.d.ts +2 -1
- package/dist/Radio/index.d.ts +2 -2
- package/dist/Radio/index.js +2 -2
- package/dist/{Radio-BioQfwHQ.js → RadioGroup-BqjdSCfJ.js} +21 -88
- package/dist/RadioList/index.d.ts +2 -0
- package/dist/RadioList/index.js +2 -0
- package/dist/RadioList-DI8ujXcT.js +122 -0
- package/dist/Resizable/index.d.ts +2 -0
- package/dist/Resizable/index.js +2 -0
- package/dist/Resizable-BuGKvU9I.js +261 -0
- package/dist/ScrollableArea/index.d.ts +2 -0
- package/dist/ScrollableArea/index.js +2 -0
- package/dist/ScrollableArea-DQDYjnxO.js +78 -0
- package/dist/Section/index.d.ts +2 -0
- package/dist/Section/index.js +2 -0
- package/dist/Section-C48Wqfc7.js +68 -0
- package/dist/SegmentedControl/index.d.ts +1 -1
- package/dist/SelectableCard/index.d.ts +2 -0
- package/dist/SelectableCard/index.js +2 -0
- package/dist/SelectableCard-Bj5s_tIN.js +108 -0
- package/dist/Selector/index.d.ts +1 -1
- package/dist/Selector/index.js +1 -1
- package/dist/{Selector-C6sPJMtH.js → Selector-DlZpQh42.js} +1 -1
- package/dist/SideNav/index.d.ts +1 -1
- package/dist/SideNav/index.js +2 -1
- package/dist/{SideNav-D9lnn-sM.js → SideNav-Cdrigq2A.js} +49 -27
- package/dist/Slider/index.js +1 -1
- package/dist/{Slider-DTnWxtnb.js → Slider-D8h_RKcF.js} +1 -1
- package/dist/Stack/index.d.ts +1 -1
- package/dist/Stepper/index.d.ts +2 -0
- package/dist/Stepper/index.js +2 -0
- package/dist/Stepper-DxmLfh8O.js +423 -0
- package/dist/Switch/index.d.ts +1 -1
- package/dist/Switch/index.js +1 -1
- package/dist/{Switch-CNdnr5TP.js → Switch-SesQzPGZ.js} +4 -2
- package/dist/TabList/index.d.ts +2 -2
- package/dist/TabList/index.js +2 -2
- package/dist/TabList-C411uNQU.js +380 -0
- package/dist/Table/index.d.ts +3 -0
- package/dist/Table/index.js +2 -0
- package/dist/Table-7qRmlIQd.js +967 -0
- package/dist/Text/index.d.ts +1 -1
- package/dist/TextArea/index.d.ts +1 -1
- package/dist/TextArea/index.js +1 -1
- package/dist/{TextArea-BL0NuB99.js → TextArea-Cv9UVbzS.js} +5 -3
- package/dist/TextInput/index.d.ts +1 -1
- package/dist/TextInput/index.js +1 -1
- package/dist/{TextInput-B0IKC7g5.js → TextInput-BasnjVvy.js} +5 -3
- package/dist/Thumbnail/index.d.ts +2 -0
- package/dist/Thumbnail/index.js +2 -0
- package/dist/Thumbnail-BWVzLLyI.js +163 -0
- package/dist/TimeField-l3QzU6vC.js +214 -0
- package/dist/TimeInput/index.d.ts +2 -0
- package/dist/TimeInput/index.js +2 -0
- package/dist/TimeInput-OkgX-xbQ.js +121 -0
- package/dist/Timestamp/index.d.ts +2 -0
- package/dist/Timestamp/index.js +2 -0
- package/dist/Timestamp-DUoP9ari.js +465 -0
- package/dist/ToggleButton/index.d.ts +1 -1
- package/dist/Token/index.js +1 -1
- package/dist/{Token-Ctf9jekS.js → Token-C4KD0fZD.js} +1 -1
- package/dist/Tokenizer/index.d.ts +1 -1
- package/dist/Tokenizer/index.js +1 -1
- package/dist/{Tokenizer-D5MPgau0.js → Tokenizer-BA8sTMPZ.js} +3 -3
- package/dist/Toolbar/index.d.ts +1 -1
- package/dist/Tooltip/index.d.ts +1 -1
- package/dist/TopNav/index.d.ts +1 -1
- package/dist/TopNav/index.js +1 -1
- package/dist/{TopNav-CjbMCbkC.js → TopNav-CZokS7E_.js} +57 -31
- package/dist/TreeList/index.d.ts +2 -0
- package/dist/TreeList/index.js +2 -0
- package/dist/TreeList-CIbAGOMf.js +506 -0
- package/dist/Typeahead/index.d.ts +1 -1
- package/dist/Typeahead/index.js +1 -1
- package/dist/{Typeahead-BMoU3hfx.js → Typeahead-DIw-K4aa.js} +3 -3
- package/dist/composables/index.d.ts +3 -2
- package/dist/composables/index.js +8 -2
- package/dist/composables-CVfjp9h4.js +502 -0
- package/dist/context-BjNya0v8.js +19 -0
- package/dist/context-Cfjh8te1.js +29 -0
- package/dist/{locale-56lkR7OK.js → context-D6ECRdc5.js} +267 -18
- package/dist/index-1uRMrk63.d.ts +54 -0
- package/dist/{index-Dw21t7Uf.d.ts → index-2u4l3wq8.d.ts} +2 -2
- package/dist/{index-CvLlWLIZ.d.ts → index-B4OOtNP8.d.ts} +4 -4
- package/dist/{index-_1-uvr27.d.ts → index-B8MbfMwV.d.ts} +1 -1
- package/dist/{index-MPcg1Pm4.d.ts → index-BKr7yvVv.d.ts} +1 -1
- package/dist/index-Be1czg3M.d.ts +167 -0
- package/dist/{index-Dbmgcm8a.d.ts → index-BeR-1LgF.d.ts} +2 -0
- package/dist/{index-CnVbMebA.d.ts → index-Bqb_Fyju.d.ts} +3 -3
- package/dist/index-BrJzFA5X.d.ts +38 -0
- package/dist/{index-BDZCJ9ri.d.ts → index-BuubzuE8.d.ts} +2 -2
- package/dist/index-By2mSzUA.d.ts +67 -0
- package/dist/{index-HV6W3xCx.d.ts → index-Byar3h1e.d.ts} +1 -1
- package/dist/{index-BQuN_dWR.d.ts → index-BzqRns96.d.ts} +1 -1
- package/dist/{index-BkIgRYGz.d.ts → index-C5p2NeCr.d.ts} +2 -2
- package/dist/{index-Cc2HGODZ.d.ts → index-C6RecznD.d.ts} +3 -3
- package/dist/{index-BSRk8MFK.d.ts → index-C8wDPDcP.d.ts} +1 -1
- package/dist/index-CDdRQQF3.d.ts +170 -0
- package/dist/index-COqjznX0.d.ts +47 -0
- package/dist/{index-Cz9ZHVf6.d.ts → index-CT8KEpec.d.ts} +2 -2
- package/dist/{index-CxspvLBl.d.ts → index-CTolyeii.d.ts} +1 -1
- package/dist/index-CVn0GBdB.d.ts +115 -0
- package/dist/index-CX97hlld.d.ts +158 -0
- package/dist/index-C_2Z65Rp.d.ts +67 -0
- package/dist/index-CjtAH60j.d.ts +38 -0
- package/dist/index-CtlkhQ55.d.ts +36 -0
- package/dist/{index-JeZ0YTyd.d.ts → index-D-ZuubCK.d.ts} +4 -4
- package/dist/index-DA52oIdw.d.ts +171 -0
- package/dist/{index-C8NW9xre.d.ts → index-DGNqi2za.d.ts} +7 -7
- package/dist/{index-CCA4R0Mf.d.ts → index-DT9S92sh.d.ts} +31 -6
- package/dist/index-DXSs3rwa.d.ts +252 -0
- package/dist/{index-C0S2Xzoi.d.ts → index-DYChvBOM.d.ts} +135 -0
- package/dist/index-Da7Jm8Ht.d.ts +10 -0
- package/dist/{index-CaHXYQ_E.d.ts → index-Df2YvC8o.d.ts} +717 -147
- package/dist/{index-DjOdQv5B.d.ts → index-DfgHJE7H.d.ts} +1 -1
- package/dist/{index-CPhDtlv-.d.ts → index-FEy8qFSD.d.ts} +3 -3
- package/dist/{index-DBcbfStA.d.ts → index-SMh42NI8.d.ts} +182 -2
- package/dist/{index-Cdi82rTW.d.ts → index-ZJyk8RtQ.d.ts} +6 -2
- package/dist/{index-BeJqhW4l.d.ts → index-fa72tWIU.d.ts} +3 -3
- package/dist/{index-COxy6LEW.d.ts → index-gW0HW02U.d.ts} +1 -1
- package/dist/{index-BQa836Vz.d.ts → index-iBLzInje.d.ts} +6 -14
- package/dist/{index-BhYFxnjV.d.ts → index-kaKBOZSU.d.ts} +2 -2
- package/dist/index-nKlTsNfV.d.ts +42 -0
- package/dist/index-utZGF4GR.d.ts +79 -0
- package/dist/index.d.ts +76 -59
- package/dist/index.js +119 -78
- package/dist/locale/index.d.ts +1 -1
- package/dist/locale/index.js +2 -1
- package/dist/locale-Cpk_nrLA.js +18 -0
- package/dist/size-BuTzpgnR.d.ts +14 -0
- package/dist/size-xcIqExkS.js +79 -0
- package/dist/{index-Cp0NlzQv.d.ts → types-Db3Owy8Q.d.ts} +1 -36
- package/dist/types-JktRxujg.d.ts +107 -0
- package/dist/useAppShellMobile-DTsyuAJ4.js +19 -0
- package/dist/useClickableContainer-DyNpnSEa.js +112 -0
- package/dist/useFileSelection-BPtaegqK.js +58 -0
- package/dist/useMonthGrid-CmJsZTcB.js +139 -0
- package/dist/useResizable-CeESZS1v.d.ts +72 -0
- package/dist/useScrollableArea-DDk_CluT.js +172 -0
- package/dist/useTimeValue-DWk6oTAZ.js +113 -0
- package/package.json +97 -1
- package/styles/app-shell.css +151 -0
- package/styles/aspect-ratio.css +49 -0
- package/styles/bordered-control.css +87 -0
- package/styles/calendar.css +8 -2
- package/styles/card.css +5 -1
- package/styles/checkbox-list.css +15 -0
- package/styles/clickable-card.css +101 -0
- package/styles/collapsible.css +37 -0
- package/styles/command-palette.css +183 -0
- package/styles/complex-selector.css +114 -0
- package/styles/date-range-input.css +163 -0
- package/styles/date-time-input.css +40 -0
- package/styles/field.css +14 -3
- package/styles/file-input.css +87 -0
- package/styles/form-layout.css +31 -0
- package/styles/heading.css +19 -17
- package/styles/icon.css +32 -0
- package/styles/layout.css +280 -0
- package/styles/metadata-list.css +107 -0
- package/styles/number-input.css +6 -0
- package/styles/radio.css +32 -0
- package/styles/resize-handle.css +128 -0
- package/styles/scrollable-area.css +50 -0
- package/styles/section.css +60 -0
- package/styles/selector.css +10 -0
- package/styles/side-nav.css +26 -0
- package/styles/stepper.css +357 -0
- package/styles/tab-menu.css +91 -0
- package/styles/table.css +256 -0
- package/styles/text-area.css +6 -1
- package/styles/text-input.css +6 -0
- package/styles/thumbnail.css +151 -0
- package/styles/time-input.css +51 -0
- package/styles/timestamp.css +93 -0
- package/styles/tree-list.css +229 -0
- package/styles.css +23 -0
- package/dist/Collapsible-ByXCGhT8.js +0 -102
- package/dist/TabList-LV1U4ZD6.js +0 -184
- package/dist/composables-Dq9RS33w.js +0 -111
- package/dist/index-TnaIHsCS.d.ts +0 -87
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { t as useMediaQuery } from "./useMediaQuery-GMmgp28-.js";
|
|
2
|
+
import { n as useAppShellMobile } from "./useAppShellMobile-DTsyuAJ4.js";
|
|
2
3
|
import { t as useListFocus } from "./useListFocus-D0iOJl39.js";
|
|
3
|
-
import { a as useAstryxMessages } from "./
|
|
4
|
-
import { t as _sfc_main$7 } from "./
|
|
5
|
-
import {
|
|
4
|
+
import { a as useAstryxMessages } from "./context-D6ECRdc5.js";
|
|
5
|
+
import { n as _sfc_main$8, r as mobileNavKey, t as _sfc_main$7 } from "./MobileNavToggle-CgQamG6E.js";
|
|
6
|
+
import { t as _sfc_main$9 } from "./Icon-5MdZQ18k.js";
|
|
6
7
|
import { n as resolveNavRoot } from "./link-CdcUSxAj.js";
|
|
7
8
|
import { t as _sfc_main$10 } from "./NavItem-FFOisITc.js";
|
|
8
9
|
import { n as navMenuCloseKey, t as _sfc_main$11 } from "./NavDisclosure-DHrSNRDR.js";
|
|
9
10
|
import { n as _sfc_main$13, t as _sfc_main$12 } from "./NavMenuItem-mzNQESpB.js";
|
|
10
|
-
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, inject, normalizeClass, openBlock, ref, renderList, renderSlot, resolveDynamicComponent, toDisplayString, unref, useId, useSlots, vShow, withCtx, withDirectives } from "vue";
|
|
11
|
+
import { Fragment, Teleport, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, inject, normalizeClass, openBlock, ref, renderList, renderSlot, resolveDynamicComponent, toDisplayString, unref, useId, useSlots, vShow, withCtx, withDirectives } from "vue";
|
|
11
12
|
import "../styles/top-nav.css";
|
|
12
13
|
//#region src/TopNav/TopNav.vue
|
|
13
14
|
const _hoisted_1$5 = ["aria-label"];
|
|
@@ -26,6 +27,7 @@ const _hoisted_5$1 = {
|
|
|
26
27
|
};
|
|
27
28
|
const _hoisted_6$1 = { class: "astryx-top-nav__end" };
|
|
28
29
|
const _hoisted_7$1 = { class: "astryx-top-nav__drawer" };
|
|
30
|
+
const _hoisted_8$1 = { class: "astryx-top-nav__drawer" };
|
|
29
31
|
const _sfc_main$6 = /*@__PURE__*/ defineComponent({
|
|
30
32
|
name: "AstryxTopNav",
|
|
31
33
|
__name: "TopNav",
|
|
@@ -39,38 +41,62 @@ const _sfc_main$6 = /*@__PURE__*/ defineComponent({
|
|
|
39
41
|
const messages = useAstryxMessages();
|
|
40
42
|
const drawerId = `astryx-top-nav-${useId()}`;
|
|
41
43
|
const mobileOpen = ref(false);
|
|
44
|
+
const shell = useAppShellMobile();
|
|
42
45
|
const queryMatches = props.mobileQuery ? useMediaQuery(props.mobileQuery) : ref(false);
|
|
43
|
-
const
|
|
46
|
+
const shellCompact = computed(() => shell.isMobile && shell.isMobileNavEnabled);
|
|
47
|
+
const isCompact = computed(() => shellCompact.value || Boolean(props.mobileQuery) && queryMatches.value);
|
|
48
|
+
const ownsDrawer = computed(() => isCompact.value && !shellCompact.value);
|
|
44
49
|
const hasCenter = computed(() => slots.center != null);
|
|
45
50
|
const hasDrawer = computed(() => slots.start != null || slots.default != null || slots.center != null);
|
|
51
|
+
const showShellToggle = computed(() => shellCompact.value && shell.hasAutoToggle && (hasDrawer.value || shell.hasSideNav));
|
|
52
|
+
function setShellOpen(next) {
|
|
53
|
+
if (next) shell.openMobileNav();
|
|
54
|
+
else shell.closeMobileNav();
|
|
55
|
+
}
|
|
46
56
|
const label = computed(() => props.label || messages.value.nav.topNav);
|
|
47
57
|
return (_ctx, _cache) => {
|
|
48
|
-
return openBlock(), createElementBlock(Fragment, null, [
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
58
|
+
return openBlock(), createElementBlock(Fragment, null, [
|
|
59
|
+
createElementVNode("nav", {
|
|
60
|
+
class: normalizeClass(["astryx-top-nav", { "astryx-top-nav--centered": hasCenter.value && !isCompact.value }]),
|
|
61
|
+
"aria-label": label.value
|
|
62
|
+
}, [
|
|
63
|
+
createElementVNode("div", _hoisted_2$5, [unref(slots).heading ? (openBlock(), createElementBlock("div", _hoisted_3$3, [renderSlot(_ctx.$slots, "heading")])) : createCommentVNode("v-if", true), !isCompact.value ? (openBlock(), createElementBlock("div", _hoisted_4$3, [renderSlot(_ctx.$slots, "start"), renderSlot(_ctx.$slots, "default")])) : createCommentVNode("v-if", true)]),
|
|
64
|
+
hasCenter.value && !isCompact.value ? (openBlock(), createElementBlock("div", _hoisted_5$1, [renderSlot(_ctx.$slots, "center")])) : createCommentVNode("v-if", true),
|
|
65
|
+
createElementVNode("div", _hoisted_6$1, [renderSlot(_ctx.$slots, "end"), showShellToggle.value ? (openBlock(), createBlock(_sfc_main$7, {
|
|
66
|
+
key: 0,
|
|
67
|
+
"is-open": unref(shell).isMobileNavOpen,
|
|
68
|
+
controls: unref(shell).mobileNavId,
|
|
69
|
+
"onUpdate:isOpen": setShellOpen
|
|
70
|
+
}, null, 8, ["is-open", "controls"])) : ownsDrawer.value && hasDrawer.value ? (openBlock(), createBlock(_sfc_main$7, {
|
|
71
|
+
key: 1,
|
|
72
|
+
"is-open": mobileOpen.value,
|
|
73
|
+
"onUpdate:isOpen": _cache[0] || (_cache[0] = ($event) => mobileOpen.value = $event),
|
|
74
|
+
controls: drawerId
|
|
75
|
+
}, null, 8, ["is-open"])) : createCommentVNode("v-if", true)])
|
|
76
|
+
], 10, _hoisted_1$5),
|
|
77
|
+
shellCompact.value && hasDrawer.value ? (openBlock(), createBlock(Teleport, {
|
|
55
78
|
key: 0,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
controls: drawerId
|
|
59
|
-
}, null, 8, ["is-open"])) : createCommentVNode("v-if", true)])
|
|
60
|
-
], 10, _hoisted_1$5), isCompact.value && hasDrawer.value ? (openBlock(), createBlock(_sfc_main$9, {
|
|
61
|
-
key: 0,
|
|
62
|
-
id: drawerId,
|
|
63
|
-
"is-open": mobileOpen.value,
|
|
64
|
-
"onUpdate:isOpen": _cache[1] || (_cache[1] = ($event) => mobileOpen.value = $event),
|
|
65
|
-
label: label.value
|
|
66
|
-
}, {
|
|
67
|
-
default: withCtx(() => [createElementVNode("div", _hoisted_7$1, [
|
|
79
|
+
to: `#${unref(shell).mobileNavId}-items`
|
|
80
|
+
}, [createElementVNode("div", _hoisted_7$1, [
|
|
68
81
|
renderSlot(_ctx.$slots, "start"),
|
|
69
82
|
renderSlot(_ctx.$slots, "default"),
|
|
70
83
|
renderSlot(_ctx.$slots, "center")
|
|
71
|
-
])]),
|
|
72
|
-
|
|
73
|
-
|
|
84
|
+
])], 8, ["to"])) : createCommentVNode("v-if", true),
|
|
85
|
+
ownsDrawer.value && hasDrawer.value ? (openBlock(), createBlock(_sfc_main$8, {
|
|
86
|
+
key: 1,
|
|
87
|
+
id: drawerId,
|
|
88
|
+
"is-open": mobileOpen.value,
|
|
89
|
+
"onUpdate:isOpen": _cache[1] || (_cache[1] = ($event) => mobileOpen.value = $event),
|
|
90
|
+
label: label.value
|
|
91
|
+
}, {
|
|
92
|
+
default: withCtx(() => [createElementVNode("div", _hoisted_8$1, [
|
|
93
|
+
renderSlot(_ctx.$slots, "start"),
|
|
94
|
+
renderSlot(_ctx.$slots, "default"),
|
|
95
|
+
renderSlot(_ctx.$slots, "center")
|
|
96
|
+
])]),
|
|
97
|
+
_: 3
|
|
98
|
+
}, 8, ["is-open", "label"])) : createCommentVNode("v-if", true)
|
|
99
|
+
], 64);
|
|
74
100
|
};
|
|
75
101
|
}
|
|
76
102
|
});
|
|
@@ -217,7 +243,7 @@ const _sfc_main$3 = /*@__PURE__*/ defineComponent({
|
|
|
217
243
|
class: "astryx-top-nav-menu__drawer-trigger",
|
|
218
244
|
"aria-expanded": expanded.value ? "true" : "false",
|
|
219
245
|
onClick: _cache[0] || (_cache[0] = ($event) => expanded.value = !expanded.value)
|
|
220
|
-
}, [createElementVNode("span", null, toDisplayString(__props.label), 1), createVNode(_sfc_main$
|
|
246
|
+
}, [createElementVNode("span", null, toDisplayString(__props.label), 1), createVNode(_sfc_main$9, {
|
|
221
247
|
icon: "chevronDown",
|
|
222
248
|
size: "sm",
|
|
223
249
|
class: normalizeClass({ "astryx-top-nav-menu__chevron--open": expanded.value })
|
|
@@ -237,7 +263,7 @@ const _sfc_main$3 = /*@__PURE__*/ defineComponent({
|
|
|
237
263
|
"aria-expanded": isOpen ? "true" : "false",
|
|
238
264
|
"aria-controls": panelId,
|
|
239
265
|
"aria-haspopup": "menu"
|
|
240
|
-
}, [createElementVNode("span", null, toDisplayString(__props.label), 1), createVNode(_sfc_main$
|
|
266
|
+
}, [createElementVNode("span", null, toDisplayString(__props.label), 1), createVNode(_sfc_main$9, {
|
|
241
267
|
icon: "chevronDown",
|
|
242
268
|
size: "sm",
|
|
243
269
|
class: normalizeClass(["astryx-top-nav-menu__chevron", { "astryx-top-nav-menu__chevron--open": isOpen }])
|
|
@@ -388,7 +414,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
388
414
|
class: "astryx-top-nav-menu__drawer-trigger",
|
|
389
415
|
"aria-expanded": expanded.value ? "true" : "false",
|
|
390
416
|
onClick: _cache[0] || (_cache[0] = ($event) => expanded.value = !expanded.value)
|
|
391
|
-
}, [createElementVNode("span", null, toDisplayString(__props.label), 1), createVNode(_sfc_main$
|
|
417
|
+
}, [createElementVNode("span", null, toDisplayString(__props.label), 1), createVNode(_sfc_main$9, {
|
|
392
418
|
icon: "chevronDown",
|
|
393
419
|
size: "sm",
|
|
394
420
|
class: normalizeClass({ "astryx-top-nav-menu__chevron--open": expanded.value })
|
|
@@ -423,7 +449,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
423
449
|
"aria-expanded": isOpen ? "true" : "false",
|
|
424
450
|
"aria-controls": panelId,
|
|
425
451
|
"aria-haspopup": "menu"
|
|
426
|
-
}, [createElementVNode("span", null, toDisplayString(__props.label), 1), createVNode(_sfc_main$
|
|
452
|
+
}, [createElementVNode("span", null, toDisplayString(__props.label), 1), createVNode(_sfc_main$9, {
|
|
427
453
|
icon: "chevronDown",
|
|
428
454
|
size: "sm",
|
|
429
455
|
class: normalizeClass(["astryx-top-nav-menu__chevron", { "astryx-top-nav-menu__chevron--open": isOpen }])
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as TreeListItemData, c as TreeListVariant, i as TreeListDensity, n as useTreeFocus, o as TreeListProps, r as _default, s as TreeListSlots, t as UseTreeFocusOptions } from "../index-C_2Z65Rp.js";
|
|
2
|
+
export { _default as TreeList, type TreeListDensity, type TreeListItemData, type TreeListProps, type TreeListSlots, type TreeListVariant, type UseTreeFocusOptions, useTreeFocus };
|
|
@@ -0,0 +1,506 @@
|
|
|
1
|
+
import { a as useAstryxMessages } from "./context-D6ECRdc5.js";
|
|
2
|
+
import { t as _sfc_main$2 } from "./Badge-Ba0EwsTj.js";
|
|
3
|
+
import { n as isIconGlyph, t as _sfc_main$3 } from "./Icon-5MdZQ18k.js";
|
|
4
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, normalizeClass, normalizeStyle, onMounted, openBlock, reactive, ref, renderList, renderSlot, resolveComponent, toDisplayString, unref, useId, vShow, withCtx, withDirectives } from "vue";
|
|
5
|
+
import "../styles/tree-list.css";
|
|
6
|
+
//#region src/TreeList/TreeListItem.vue
|
|
7
|
+
const _hoisted_1$1 = [
|
|
8
|
+
"data-tree-id",
|
|
9
|
+
"data-tree-disabled",
|
|
10
|
+
"aria-level",
|
|
11
|
+
"aria-posinset",
|
|
12
|
+
"aria-setsize",
|
|
13
|
+
"aria-selected",
|
|
14
|
+
"aria-disabled",
|
|
15
|
+
"aria-expanded",
|
|
16
|
+
"tabindex"
|
|
17
|
+
];
|
|
18
|
+
const _hoisted_2$1 = ["data-span"];
|
|
19
|
+
const _hoisted_3 = { class: "astryx-tree-list__row" };
|
|
20
|
+
const _hoisted_4 = [
|
|
21
|
+
"data-density",
|
|
22
|
+
"data-selected",
|
|
23
|
+
"data-disabled",
|
|
24
|
+
"data-interactive",
|
|
25
|
+
"data-guide-inset"
|
|
26
|
+
];
|
|
27
|
+
const _hoisted_5 = [
|
|
28
|
+
"data-state",
|
|
29
|
+
"aria-expanded",
|
|
30
|
+
"aria-label",
|
|
31
|
+
"disabled"
|
|
32
|
+
];
|
|
33
|
+
const _hoisted_6 = {
|
|
34
|
+
key: 1,
|
|
35
|
+
class: "astryx-tree-list__start"
|
|
36
|
+
};
|
|
37
|
+
const _hoisted_7 = {
|
|
38
|
+
key: 1,
|
|
39
|
+
class: "astryx-tree-list__icon"
|
|
40
|
+
};
|
|
41
|
+
const _hoisted_8 = ["href", "target"];
|
|
42
|
+
const _hoisted_9 = { class: "astryx-tree-list__label" };
|
|
43
|
+
const _hoisted_10 = {
|
|
44
|
+
key: 0,
|
|
45
|
+
class: "astryx-tree-list__description"
|
|
46
|
+
};
|
|
47
|
+
const _hoisted_11 = ["disabled"];
|
|
48
|
+
const _hoisted_12 = { class: "astryx-tree-list__label" };
|
|
49
|
+
const _hoisted_13 = {
|
|
50
|
+
key: 0,
|
|
51
|
+
class: "astryx-tree-list__description"
|
|
52
|
+
};
|
|
53
|
+
const _hoisted_14 = {
|
|
54
|
+
key: 4,
|
|
55
|
+
class: "astryx-tree-list__main"
|
|
56
|
+
};
|
|
57
|
+
const _hoisted_15 = { class: "astryx-tree-list__label" };
|
|
58
|
+
const _hoisted_16 = {
|
|
59
|
+
key: 0,
|
|
60
|
+
class: "astryx-tree-list__description"
|
|
61
|
+
};
|
|
62
|
+
const _hoisted_17 = {
|
|
63
|
+
key: 5,
|
|
64
|
+
class: "astryx-tree-list__end"
|
|
65
|
+
};
|
|
66
|
+
const _hoisted_18 = {
|
|
67
|
+
key: 2,
|
|
68
|
+
class: "astryx-tree-list__icon"
|
|
69
|
+
};
|
|
70
|
+
const _hoisted_19 = {
|
|
71
|
+
key: 1,
|
|
72
|
+
class: "astryx-tree-list__group",
|
|
73
|
+
role: "group"
|
|
74
|
+
};
|
|
75
|
+
const branchMargin = "calc(var(--astryx-spacing-2, 8px) + var(--astryx-spacing-0-5, 2px))";
|
|
76
|
+
const _sfc_main$1 = /*@__PURE__*/ defineComponent({
|
|
77
|
+
name: "AstryxTreeListItem",
|
|
78
|
+
__name: "TreeListItem",
|
|
79
|
+
props: {
|
|
80
|
+
item: {},
|
|
81
|
+
density: {},
|
|
82
|
+
variant: {},
|
|
83
|
+
nestedLevel: {},
|
|
84
|
+
isLast: { type: Boolean },
|
|
85
|
+
ancestorsIsLast: {},
|
|
86
|
+
expanded: {},
|
|
87
|
+
hasExpandableItems: { type: Boolean },
|
|
88
|
+
tabbableId: {},
|
|
89
|
+
posInSet: {},
|
|
90
|
+
setSize: {}
|
|
91
|
+
},
|
|
92
|
+
emits: ["toggle"],
|
|
93
|
+
setup(__props, { emit: __emit }) {
|
|
94
|
+
const props = __props;
|
|
95
|
+
const emit = __emit;
|
|
96
|
+
const messages = useAstryxMessages();
|
|
97
|
+
const hasChildren = computed(() => (props.item.children?.length ?? 0) > 0);
|
|
98
|
+
const isExpanded = computed(() => hasChildren.value && props.expanded[props.item.id] === true);
|
|
99
|
+
const reservesChevron = computed(() => !hasChildren.value && props.hasExpandableItems);
|
|
100
|
+
const indent = computed(() => reservesChevron.value ? `calc(${props.nestedLevel} * var(--tree-list-indent) + var(--astryx-spacing-4, 16px) + var(--astryx-spacing-2, 8px))` : `calc(${props.nestedLevel} * var(--tree-list-indent))`);
|
|
101
|
+
const childAncestors = computed(() => [...props.ancestorsIsLast, props.isLast]);
|
|
102
|
+
function branchOffset(level) {
|
|
103
|
+
return `calc(${branchMargin} + ${level} * var(--tree-list-indent))`;
|
|
104
|
+
}
|
|
105
|
+
function onRowClick(event) {
|
|
106
|
+
if (props.item.isDisabled) return;
|
|
107
|
+
const target = event.target;
|
|
108
|
+
if (target instanceof Element && target.closest("button, a, input, select, textarea")) return;
|
|
109
|
+
if (props.item.onClick) props.item.onClick(event);
|
|
110
|
+
else if (hasChildren.value) emit("toggle", props.item.id);
|
|
111
|
+
}
|
|
112
|
+
function onToggle(event) {
|
|
113
|
+
event.stopPropagation();
|
|
114
|
+
emit("toggle", props.item.id);
|
|
115
|
+
}
|
|
116
|
+
return (_ctx, _cache) => {
|
|
117
|
+
const _component_TreeListItem = resolveComponent("TreeListItem", true);
|
|
118
|
+
return openBlock(), createElementBlock("li", {
|
|
119
|
+
class: "astryx-tree-list__item",
|
|
120
|
+
role: "treeitem",
|
|
121
|
+
"data-tree-id": __props.item.id,
|
|
122
|
+
"data-tree-disabled": __props.item.isDisabled ? "true" : void 0,
|
|
123
|
+
"aria-level": __props.nestedLevel + 1,
|
|
124
|
+
"aria-posinset": __props.posInSet,
|
|
125
|
+
"aria-setsize": __props.setSize,
|
|
126
|
+
"aria-selected": __props.item.isSelected || void 0,
|
|
127
|
+
"aria-disabled": __props.item.isDisabled || void 0,
|
|
128
|
+
"aria-expanded": hasChildren.value ? isExpanded.value : void 0,
|
|
129
|
+
tabindex: __props.item.id === __props.tabbableId ? 0 : -1
|
|
130
|
+
}, [
|
|
131
|
+
__props.variant === "lineGuides" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.ancestorsIsLast, (ancestorIsLast, level) => {
|
|
132
|
+
return withDirectives((openBlock(), createElementBlock("span", {
|
|
133
|
+
key: level,
|
|
134
|
+
class: "astryx-tree-list__guide",
|
|
135
|
+
style: normalizeStyle({ insetInlineStart: branchOffset(level) })
|
|
136
|
+
}, [..._cache[2] || (_cache[2] = [createElementVNode("span", {
|
|
137
|
+
class: "astryx-tree-list__guide-line",
|
|
138
|
+
"data-span": "full"
|
|
139
|
+
}, null, -1)])], 4)), [[vShow, !ancestorIsLast && level !== __props.nestedLevel - 1]]);
|
|
140
|
+
}), 128)), __props.nestedLevel > 0 ? (openBlock(), createElementBlock("span", {
|
|
141
|
+
key: 0,
|
|
142
|
+
class: "astryx-tree-list__guide",
|
|
143
|
+
style: normalizeStyle({ insetInlineStart: branchOffset(__props.nestedLevel - 1) })
|
|
144
|
+
}, [createElementVNode("span", {
|
|
145
|
+
class: "astryx-tree-list__guide-line",
|
|
146
|
+
"data-span": __props.isLast ? "last" : "full"
|
|
147
|
+
}, null, 8, _hoisted_2$1)], 4)) : createCommentVNode("v-if", true)], 64)) : createCommentVNode("v-if", true),
|
|
148
|
+
createElementVNode("div", _hoisted_3, [createCommentVNode(" eslint-disable-next-line vue-a11y/click-events-have-key-events, vue-a11y/no-static-element-interactions -- 键盘由外层 role=\"tree\" 处理,这一层只接指针点击。 "), createElementVNode("div", {
|
|
149
|
+
class: "astryx-tree-list__content",
|
|
150
|
+
"data-density": __props.density,
|
|
151
|
+
"data-selected": __props.item.isSelected || void 0,
|
|
152
|
+
"data-disabled": __props.item.isDisabled || void 0,
|
|
153
|
+
"data-interactive": __props.item.onClick != null || __props.item.href != null || hasChildren.value || void 0,
|
|
154
|
+
"data-guide-inset": __props.variant === "lineGuides" && __props.nestedLevel > 0 && !reservesChevron.value || void 0,
|
|
155
|
+
style: normalizeStyle({ "--_tree-indent": indent.value }),
|
|
156
|
+
onClick: onRowClick
|
|
157
|
+
}, [
|
|
158
|
+
hasChildren.value ? (openBlock(), createElementBlock("button", {
|
|
159
|
+
key: 0,
|
|
160
|
+
type: "button",
|
|
161
|
+
class: "astryx-tree-list__chevron",
|
|
162
|
+
"data-tree-toggle": "",
|
|
163
|
+
"data-state": isExpanded.value ? "expanded" : "collapsed",
|
|
164
|
+
"aria-expanded": isExpanded.value,
|
|
165
|
+
"aria-label": unref(messages).treeList.toggleChildren,
|
|
166
|
+
disabled: __props.item.isDisabled,
|
|
167
|
+
tabindex: "-1",
|
|
168
|
+
onClick: onToggle
|
|
169
|
+
}, [createVNode(_sfc_main$3, {
|
|
170
|
+
icon: "chevronRight",
|
|
171
|
+
size: "sm",
|
|
172
|
+
color: "inherit"
|
|
173
|
+
})], 8, _hoisted_5)) : createCommentVNode("v-if", true),
|
|
174
|
+
__props.item.icon ? (openBlock(), createElementBlock("span", _hoisted_6, [unref(isIconGlyph)(__props.item.icon) ? (openBlock(), createBlock(_sfc_main$3, {
|
|
175
|
+
key: 0,
|
|
176
|
+
icon: __props.item.icon,
|
|
177
|
+
size: "sm"
|
|
178
|
+
}, null, 8, ["icon"])) : (openBlock(), createElementBlock("span", _hoisted_7, [createElementVNode("i", {
|
|
179
|
+
class: normalizeClass(__props.item.icon),
|
|
180
|
+
"aria-hidden": "true"
|
|
181
|
+
}, null, 2)]))])) : createCommentVNode("v-if", true),
|
|
182
|
+
__props.item.href ? (openBlock(), createElementBlock("a", {
|
|
183
|
+
key: 2,
|
|
184
|
+
class: "astryx-tree-list__action",
|
|
185
|
+
href: __props.item.href,
|
|
186
|
+
target: __props.item.target,
|
|
187
|
+
tabindex: "-1"
|
|
188
|
+
}, [createElementVNode("span", _hoisted_9, toDisplayString(__props.item.label), 1), __props.item.description ? (openBlock(), createElementBlock("span", _hoisted_10, toDisplayString(__props.item.description), 1)) : createCommentVNode("v-if", true)], 8, _hoisted_8)) : __props.item.onClick ? (openBlock(), createElementBlock("button", {
|
|
189
|
+
key: 3,
|
|
190
|
+
type: "button",
|
|
191
|
+
class: "astryx-tree-list__action",
|
|
192
|
+
disabled: __props.item.isDisabled,
|
|
193
|
+
tabindex: "-1",
|
|
194
|
+
onClick: _cache[0] || (_cache[0] = ($event) => __props.item.onClick($event))
|
|
195
|
+
}, [createElementVNode("span", _hoisted_12, toDisplayString(__props.item.label), 1), __props.item.description ? (openBlock(), createElementBlock("span", _hoisted_13, toDisplayString(__props.item.description), 1)) : createCommentVNode("v-if", true)], 8, _hoisted_11)) : (openBlock(), createElementBlock("span", _hoisted_14, [createElementVNode("span", _hoisted_15, toDisplayString(__props.item.label), 1), __props.item.description ? (openBlock(), createElementBlock("span", _hoisted_16, toDisplayString(__props.item.description), 1)) : createCommentVNode("v-if", true)])),
|
|
196
|
+
__props.item.badge || __props.item.endIcon ? (openBlock(), createElementBlock("span", _hoisted_17, [__props.item.badge ? (openBlock(), createBlock(_sfc_main$2, { key: 0 }, {
|
|
197
|
+
default: withCtx(() => [createTextVNode(toDisplayString(__props.item.badge), 1)]),
|
|
198
|
+
_: 1
|
|
199
|
+
})) : __props.item.endIcon && unref(isIconGlyph)(__props.item.endIcon) ? (openBlock(), createBlock(_sfc_main$3, {
|
|
200
|
+
key: 1,
|
|
201
|
+
icon: __props.item.endIcon,
|
|
202
|
+
size: "sm"
|
|
203
|
+
}, null, 8, ["icon"])) : __props.item.endIcon ? (openBlock(), createElementBlock("span", _hoisted_18, [createElementVNode("i", {
|
|
204
|
+
class: normalizeClass(__props.item.endIcon),
|
|
205
|
+
"aria-hidden": "true"
|
|
206
|
+
}, null, 2)])) : createCommentVNode("v-if", true)])) : createCommentVNode("v-if", true)
|
|
207
|
+
], 12, _hoisted_4)]),
|
|
208
|
+
hasChildren.value && isExpanded.value ? (openBlock(), createElementBlock("ul", _hoisted_19, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.item.children, (child, index) => {
|
|
209
|
+
return openBlock(), createBlock(_component_TreeListItem, {
|
|
210
|
+
key: child.id,
|
|
211
|
+
item: child,
|
|
212
|
+
density: __props.density,
|
|
213
|
+
variant: __props.variant,
|
|
214
|
+
"nested-level": __props.nestedLevel + 1,
|
|
215
|
+
"is-last": index === (__props.item.children?.length ?? 1) - 1,
|
|
216
|
+
"ancestors-is-last": childAncestors.value,
|
|
217
|
+
expanded: __props.expanded,
|
|
218
|
+
"has-expandable-items": __props.hasExpandableItems,
|
|
219
|
+
"tabbable-id": __props.tabbableId,
|
|
220
|
+
"pos-in-set": index + 1,
|
|
221
|
+
"set-size": __props.item.children?.length ?? 0,
|
|
222
|
+
onToggle: _cache[1] || (_cache[1] = ($event) => emit("toggle", $event))
|
|
223
|
+
}, null, 8, [
|
|
224
|
+
"item",
|
|
225
|
+
"density",
|
|
226
|
+
"variant",
|
|
227
|
+
"nested-level",
|
|
228
|
+
"is-last",
|
|
229
|
+
"ancestors-is-last",
|
|
230
|
+
"expanded",
|
|
231
|
+
"has-expandable-items",
|
|
232
|
+
"tabbable-id",
|
|
233
|
+
"pos-in-set",
|
|
234
|
+
"set-size"
|
|
235
|
+
]);
|
|
236
|
+
}), 128))])) : createCommentVNode("v-if", true)
|
|
237
|
+
], 8, _hoisted_1$1);
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
//#endregion
|
|
242
|
+
//#region src/TreeList/useTreeFocus.ts
|
|
243
|
+
const NAVIGATION_KEYS = /* @__PURE__ */ new Set([
|
|
244
|
+
"ArrowDown",
|
|
245
|
+
"ArrowUp",
|
|
246
|
+
"ArrowRight",
|
|
247
|
+
"ArrowLeft",
|
|
248
|
+
"Home",
|
|
249
|
+
"End",
|
|
250
|
+
"Enter",
|
|
251
|
+
" "
|
|
252
|
+
]);
|
|
253
|
+
function isRtl(element) {
|
|
254
|
+
return element != null && getComputedStyle(element).direction === "rtl";
|
|
255
|
+
}
|
|
256
|
+
function useTreeFocus(options) {
|
|
257
|
+
const treeRef = ref(null);
|
|
258
|
+
const typeahead = {
|
|
259
|
+
buffer: "",
|
|
260
|
+
timer: void 0
|
|
261
|
+
};
|
|
262
|
+
function items() {
|
|
263
|
+
const root = treeRef.value;
|
|
264
|
+
if (root == null) return [];
|
|
265
|
+
return [...root.querySelectorAll("[role=\"treeitem\"]")];
|
|
266
|
+
}
|
|
267
|
+
function disabled(item) {
|
|
268
|
+
return item.dataset.treeDisabled === "true" || item.getAttribute("aria-disabled") === "true";
|
|
269
|
+
}
|
|
270
|
+
function levelOf(item) {
|
|
271
|
+
return Number(item.getAttribute("aria-level") ?? "1");
|
|
272
|
+
}
|
|
273
|
+
function focusItem(item) {
|
|
274
|
+
for (const candidate of items()) candidate.tabIndex = candidate === item ? 0 : -1;
|
|
275
|
+
item.focus();
|
|
276
|
+
}
|
|
277
|
+
function focusEnabledFrom(list, start, step) {
|
|
278
|
+
for (let index = start; index >= 0 && index < list.length; index += step) {
|
|
279
|
+
const item = list[index];
|
|
280
|
+
if (item != null && !disabled(item)) {
|
|
281
|
+
focusItem(item);
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
function syncTabStops() {
|
|
287
|
+
const list = items();
|
|
288
|
+
const active = document.activeElement;
|
|
289
|
+
const current = active instanceof Element ? active.closest("[role=\"treeitem\"]") : null;
|
|
290
|
+
const owned = current != null && list.includes(current) ? current : list.find((item) => item.tabIndex === 0) ?? list.find((item) => !disabled(item));
|
|
291
|
+
for (const item of list) item.tabIndex = item === owned ? 0 : -1;
|
|
292
|
+
}
|
|
293
|
+
onMounted(syncTabStops);
|
|
294
|
+
function handleKeyDown(event) {
|
|
295
|
+
const list = items();
|
|
296
|
+
if (list.length === 0) return;
|
|
297
|
+
const active = document.activeElement;
|
|
298
|
+
const activeItem = active instanceof Element ? active.closest("[role=\"treeitem\"]") : null;
|
|
299
|
+
const currentIndex = list.findIndex((item) => item === activeItem);
|
|
300
|
+
const current = currentIndex >= 0 ? list[currentIndex] : void 0;
|
|
301
|
+
if (event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey && !NAVIGATION_KEYS.has(event.key)) {
|
|
302
|
+
typeahead.buffer += event.key.toLowerCase();
|
|
303
|
+
clearTimeout(typeahead.timer);
|
|
304
|
+
typeahead.timer = setTimeout(() => {
|
|
305
|
+
typeahead.buffer = "";
|
|
306
|
+
}, 500);
|
|
307
|
+
const query = typeahead.buffer;
|
|
308
|
+
const match = [...list.slice(currentIndex + 1), ...list.slice(0, currentIndex + 1)].find((item) => !disabled(item) && (item.textContent ?? "").trim().toLowerCase().startsWith(query));
|
|
309
|
+
if (match != null) {
|
|
310
|
+
event.preventDefault();
|
|
311
|
+
focusItem(match);
|
|
312
|
+
}
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
if (!NAVIGATION_KEYS.has(event.key)) return;
|
|
316
|
+
let key = event.key;
|
|
317
|
+
if ((key === "ArrowLeft" || key === "ArrowRight") && isRtl(treeRef.value)) key = key === "ArrowLeft" ? "ArrowRight" : "ArrowLeft";
|
|
318
|
+
switch (key) {
|
|
319
|
+
case "ArrowDown":
|
|
320
|
+
event.preventDefault();
|
|
321
|
+
focusEnabledFrom(list, currentIndex < 0 ? 0 : currentIndex + 1, 1);
|
|
322
|
+
break;
|
|
323
|
+
case "ArrowUp":
|
|
324
|
+
event.preventDefault();
|
|
325
|
+
focusEnabledFrom(list, currentIndex < 0 ? list.length - 1 : currentIndex - 1, -1);
|
|
326
|
+
break;
|
|
327
|
+
case "ArrowRight": {
|
|
328
|
+
if (current == null) break;
|
|
329
|
+
event.preventDefault();
|
|
330
|
+
const expanded = current.getAttribute("aria-expanded");
|
|
331
|
+
if (expanded === "false") options.onToggleExpand?.(current.dataset.treeId ?? "");
|
|
332
|
+
else if (expanded === "true") {
|
|
333
|
+
const next = list[currentIndex + 1];
|
|
334
|
+
if (next != null && levelOf(next) > levelOf(current)) focusItem(next);
|
|
335
|
+
}
|
|
336
|
+
break;
|
|
337
|
+
}
|
|
338
|
+
case "ArrowLeft":
|
|
339
|
+
if (current == null) break;
|
|
340
|
+
event.preventDefault();
|
|
341
|
+
if (current.getAttribute("aria-expanded") === "true") options.onToggleExpand?.(current.dataset.treeId ?? "");
|
|
342
|
+
else {
|
|
343
|
+
const currentLevel = levelOf(current);
|
|
344
|
+
for (let index = currentIndex - 1; index >= 0; index -= 1) {
|
|
345
|
+
const candidate = list[index];
|
|
346
|
+
if (candidate != null && levelOf(candidate) < currentLevel) {
|
|
347
|
+
focusItem(candidate);
|
|
348
|
+
break;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
break;
|
|
353
|
+
case "Home":
|
|
354
|
+
event.preventDefault();
|
|
355
|
+
focusEnabledFrom(list, 0, 1);
|
|
356
|
+
break;
|
|
357
|
+
case "End":
|
|
358
|
+
event.preventDefault();
|
|
359
|
+
focusEnabledFrom(list, list.length - 1, -1);
|
|
360
|
+
break;
|
|
361
|
+
case "Enter":
|
|
362
|
+
case " ":
|
|
363
|
+
if (current == null || disabled(current)) break;
|
|
364
|
+
event.preventDefault();
|
|
365
|
+
if (!(options.onActivate?.(current) === true) && current.getAttribute("aria-expanded") != null) options.onToggleExpand?.(current.dataset.treeId ?? "");
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
function handleFocus() {
|
|
369
|
+
syncTabStops();
|
|
370
|
+
}
|
|
371
|
+
return {
|
|
372
|
+
treeRef,
|
|
373
|
+
handleKeyDown,
|
|
374
|
+
handleFocus
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
//#endregion
|
|
378
|
+
//#region src/TreeList/TreeList.vue
|
|
379
|
+
const _hoisted_1 = ["data-density", "data-variant"];
|
|
380
|
+
const _hoisted_2 = ["aria-label", "aria-labelledby"];
|
|
381
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
382
|
+
name: "AstryxTreeList",
|
|
383
|
+
inheritAttrs: false,
|
|
384
|
+
__name: "TreeList",
|
|
385
|
+
props: {
|
|
386
|
+
items: {},
|
|
387
|
+
density: { default: "balanced" },
|
|
388
|
+
variant: { default: "lineGuides" },
|
|
389
|
+
header: {},
|
|
390
|
+
label: {}
|
|
391
|
+
},
|
|
392
|
+
setup(__props) {
|
|
393
|
+
const props = __props;
|
|
394
|
+
const headerId = `astryx-tree-list-${useId()}`;
|
|
395
|
+
const expanded = reactive({});
|
|
396
|
+
function walk(items, visit) {
|
|
397
|
+
for (const item of items) {
|
|
398
|
+
visit(item);
|
|
399
|
+
if (item.children) walk(item.children, visit);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
walk(props.items, (item) => {
|
|
403
|
+
if (item.isExpanded && item.children && item.children.length > 0) expanded[item.id] = true;
|
|
404
|
+
});
|
|
405
|
+
function currentExpanded(id, items) {
|
|
406
|
+
let found = false;
|
|
407
|
+
let seeded = false;
|
|
408
|
+
walk(items, (item) => {
|
|
409
|
+
if (item.id === id) {
|
|
410
|
+
found = true;
|
|
411
|
+
seeded = item.isExpanded === true;
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
if (!found) return false;
|
|
415
|
+
return id in expanded ? expanded[id] === true : seeded;
|
|
416
|
+
}
|
|
417
|
+
function toggle(id) {
|
|
418
|
+
expanded[id] = !currentExpanded(id, props.items);
|
|
419
|
+
}
|
|
420
|
+
const hasExpandable = computed(() => {
|
|
421
|
+
let found = false;
|
|
422
|
+
walk(props.items, (item) => {
|
|
423
|
+
if (item.children && item.children.length > 0) found = true;
|
|
424
|
+
});
|
|
425
|
+
return found;
|
|
426
|
+
});
|
|
427
|
+
function initialTabbable(items) {
|
|
428
|
+
let firstEnabled;
|
|
429
|
+
const visit = (list) => {
|
|
430
|
+
for (const item of list) {
|
|
431
|
+
if (item.isSelected && item.isDisabled !== true) return item.id;
|
|
432
|
+
if (firstEnabled == null && item.isDisabled !== true) firstEnabled = item.id;
|
|
433
|
+
if (item.children && item.children.length > 0) {
|
|
434
|
+
const selected = visit(item.children);
|
|
435
|
+
if (selected != null) return selected;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
};
|
|
439
|
+
return visit(items) ?? firstEnabled ?? items[0]?.id;
|
|
440
|
+
}
|
|
441
|
+
const tabbableId = computed(() => initialTabbable(props.items));
|
|
442
|
+
const { treeRef, handleKeyDown, handleFocus } = useTreeFocus({
|
|
443
|
+
onToggleExpand: toggle,
|
|
444
|
+
onActivate: (current) => {
|
|
445
|
+
const candidates = current.querySelectorAll("a[href], button:not([data-tree-toggle])");
|
|
446
|
+
for (const candidate of candidates) if (candidate.closest("[role=\"treeitem\"]") === current) {
|
|
447
|
+
candidate.click();
|
|
448
|
+
return true;
|
|
449
|
+
}
|
|
450
|
+
return false;
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
function onKeyDown(event) {
|
|
454
|
+
if (treeRef.value != null && event.target instanceof Node && treeRef.value.contains(event.target)) handleKeyDown(event);
|
|
455
|
+
}
|
|
456
|
+
return (_ctx, _cache) => {
|
|
457
|
+
return openBlock(), createElementBlock(Fragment, null, [createCommentVNode(" eslint-disable-next-line vue-a11y/no-static-element-interactions -- 方向键从内部 role=\"tree\" 冒泡上来,这一层只负责转发给树的键盘逻辑。 "), createElementVNode("div", {
|
|
458
|
+
class: normalizeClass(["astryx-tree-list", _ctx.$attrs.class]),
|
|
459
|
+
style: normalizeStyle(_ctx.$attrs.style),
|
|
460
|
+
"data-density": __props.density,
|
|
461
|
+
"data-variant": __props.variant,
|
|
462
|
+
onKeydown: onKeyDown
|
|
463
|
+
}, [__props.header || _ctx.$slots.header ? (openBlock(), createElementBlock("div", {
|
|
464
|
+
key: 0,
|
|
465
|
+
id: headerId,
|
|
466
|
+
class: "astryx-tree-list__header"
|
|
467
|
+
}, [renderSlot(_ctx.$slots, "header", {}, () => [createTextVNode(toDisplayString(__props.header), 1)])])) : createCommentVNode("v-if", true), createElementVNode("ul", {
|
|
468
|
+
ref_key: "treeRef",
|
|
469
|
+
ref: treeRef,
|
|
470
|
+
class: "astryx-tree-list__list",
|
|
471
|
+
role: "tree",
|
|
472
|
+
"aria-label": __props.header || _ctx.$slots.header ? void 0 : __props.label,
|
|
473
|
+
"aria-labelledby": __props.header || _ctx.$slots.header ? headerId : void 0,
|
|
474
|
+
onFocus: _cache[0] || (_cache[0] = (...args) => unref(handleFocus) && unref(handleFocus)(...args))
|
|
475
|
+
}, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.items, (item, index) => {
|
|
476
|
+
return openBlock(), createBlock(_sfc_main$1, {
|
|
477
|
+
key: item.id,
|
|
478
|
+
item,
|
|
479
|
+
density: __props.density,
|
|
480
|
+
variant: __props.variant,
|
|
481
|
+
"nested-level": 0,
|
|
482
|
+
"is-last": index === __props.items.length - 1,
|
|
483
|
+
"ancestors-is-last": [],
|
|
484
|
+
expanded,
|
|
485
|
+
"has-expandable-items": hasExpandable.value,
|
|
486
|
+
"tabbable-id": tabbableId.value,
|
|
487
|
+
"pos-in-set": index + 1,
|
|
488
|
+
"set-size": __props.items.length,
|
|
489
|
+
onToggle: toggle
|
|
490
|
+
}, null, 8, [
|
|
491
|
+
"item",
|
|
492
|
+
"density",
|
|
493
|
+
"variant",
|
|
494
|
+
"is-last",
|
|
495
|
+
"expanded",
|
|
496
|
+
"has-expandable-items",
|
|
497
|
+
"tabbable-id",
|
|
498
|
+
"pos-in-set",
|
|
499
|
+
"set-size"
|
|
500
|
+
]);
|
|
501
|
+
}), 128))], 40, _hoisted_2)], 46, _hoisted_1)], 2112);
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
//#endregion
|
|
506
|
+
export { useTreeFocus as n, _sfc_main as t };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as TypeaheadSlots, i as TypeaheadSize, n as TypeaheadEmits, o as TypeaheadStatus, r as TypeaheadProps, t as _default } from "../index-
|
|
1
|
+
import { a as TypeaheadSlots, i as TypeaheadSize, n as TypeaheadEmits, o as TypeaheadStatus, r as TypeaheadProps, t as _default } from "../index-Bqb_Fyju.js";
|
|
2
2
|
export { _default as Typeahead, type TypeaheadEmits, type TypeaheadProps, type TypeaheadSize, type TypeaheadSlots, type TypeaheadStatus };
|
package/dist/Typeahead/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as _sfc_main } from "../Typeahead-
|
|
1
|
+
import { t as _sfc_main } from "../Typeahead-DIw-K4aa.js";
|
|
2
2
|
export { _sfc_main as Typeahead };
|