@expcat/tigercat-vue 2.0.19 → 2.1.1
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 +20 -10
- package/dist/chunk-26QCTL2E.mjs +180 -0
- package/dist/{chunk-7W3NALIL.mjs → chunk-3FPS7XVB.mjs} +26 -27
- package/dist/{chunk-2OI6GWOT.mjs → chunk-3KAHJF7D.mjs} +12 -11
- package/dist/chunk-3OCHBGPF.mjs +835 -0
- package/dist/chunk-3ONCXHE5.mjs +184 -0
- package/dist/{chunk-4HUYX5WW.mjs → chunk-4PQZMDBK.mjs} +29 -8
- package/dist/{chunk-DI6RRAGQ.mjs → chunk-562Z32GR.mjs} +3 -3
- package/dist/{chunk-OQVGB7X6.mjs → chunk-626VUZ2Q.mjs} +1 -1
- package/dist/{chunk-WUQMFKQ6.mjs → chunk-67VS6QHJ.mjs} +29 -15
- package/dist/chunk-6GR3XC5V.mjs +281 -0
- package/dist/chunk-6GR5U4UB.mjs +225 -0
- package/dist/{chunk-KFJIZED5.mjs → chunk-6JAAXPBW.mjs} +7 -6
- package/dist/{chunk-XGXZF27U.mjs → chunk-6NYC7EY2.mjs} +32 -18
- package/dist/{chunk-6BDDX2R4.mjs → chunk-73Z7N7VG.mjs} +1 -4
- package/dist/chunk-7C7SG3SS.mjs +269 -0
- package/dist/{chunk-NNC75I7F.mjs → chunk-7TJE7OYH.mjs} +7 -6
- package/dist/{chunk-AU6IC6K7.mjs → chunk-ABNS4B5V.mjs} +35 -15
- package/dist/chunk-AECXFT7D.mjs +121 -0
- package/dist/chunk-AOLRZG4E.mjs +347 -0
- package/dist/chunk-AY7CGLMO.mjs +368 -0
- package/dist/chunk-BBNCP55O.mjs +156 -0
- package/dist/{chunk-EGIMTTZA.mjs → chunk-BOHE5URZ.mjs} +18 -3
- package/dist/{chunk-5RIHHZF6.mjs → chunk-BQK7LH2L.mjs} +4 -1
- package/dist/{chunk-E6EZHSGY.mjs → chunk-BSOLH6R5.mjs} +0 -1
- package/dist/{chunk-RSM6FOWX.mjs → chunk-CCC3S6LK.mjs} +6 -3
- package/dist/{chunk-U75YXWSA.mjs → chunk-CLTRADS7.mjs} +17 -5
- package/dist/{chunk-BEIPGX74.mjs → chunk-DRLQCY7R.mjs} +162 -7
- package/dist/{chunk-KBJANUZZ.mjs → chunk-E523VGZP.mjs} +1 -1
- package/dist/{chunk-D3U2NJ32.mjs → chunk-FEQ7PZXI.mjs} +8 -2
- package/dist/{chunk-PE5OA4YG.mjs → chunk-FHUGOSEY.mjs} +8 -2
- package/dist/{chunk-OAPIT53X.mjs → chunk-FIEECAJV.mjs} +7 -10
- package/dist/{chunk-7SFB77JR.mjs → chunk-GBPMQJJJ.mjs} +8 -1
- package/dist/{chunk-KOG3HKOF.mjs → chunk-GQOPDD44.mjs} +2 -5
- package/dist/{chunk-5RXYJWNA.mjs → chunk-H4DEIGEG.mjs} +77 -25
- package/dist/{chunk-ZGA66PSG.mjs → chunk-IK2WHKDA.mjs} +32 -18
- package/dist/{chunk-HGXD57QM.mjs → chunk-JBS3AESR.mjs} +65 -23
- package/dist/{chunk-PYRKFQ6J.mjs → chunk-JIU5UEOU.mjs} +70 -26
- package/dist/{chunk-JALHMWKW.mjs → chunk-K5MHUMKR.mjs} +2 -2
- package/dist/{chunk-5E4LINDO.mjs → chunk-LH2V2JMZ.mjs} +26 -10
- package/dist/{chunk-PQBKN2NH.mjs → chunk-LRFKHJDU.mjs} +14 -5
- package/dist/{chunk-OTHJIFDV.mjs → chunk-M4FWWEMX.mjs} +18 -9
- package/dist/{chunk-NGAA73CV.mjs → chunk-N2XV37BL.mjs} +40 -44
- package/dist/{chunk-2LIIMWBR.mjs → chunk-OYU47A57.mjs} +1 -2
- package/dist/{chunk-KU2Q5V3L.mjs → chunk-P62TYR3M.mjs} +18 -2
- package/dist/chunk-P6FMU4AT.mjs +54 -0
- package/dist/{chunk-P5FDKBXG.mjs → chunk-P7X46BAW.mjs} +70 -3
- package/dist/chunk-PFIV5MXD.mjs +48 -0
- package/dist/{chunk-KROVW4AW.mjs → chunk-PJQTRDIG.mjs} +13 -3
- package/dist/{chunk-26OI3TEA.mjs → chunk-PMQSXEMT.mjs} +42 -6
- package/dist/{chunk-XLNK3Z2P.mjs → chunk-POWDTOMF.mjs} +88 -79
- package/dist/{chunk-AXDBME5A.mjs → chunk-PSGVG4TN.mjs} +38 -21
- package/dist/chunk-PWWWACHC.mjs +302 -0
- package/dist/{chunk-UUWTKCMY.mjs → chunk-QWLD5FMJ.mjs} +1 -1
- package/dist/{chunk-ALIUAGJO.mjs → chunk-QZLOF36M.mjs} +7 -13
- package/dist/{chunk-WLYQHKLZ.mjs → chunk-QZRSFGZZ.mjs} +50 -11
- package/dist/{chunk-MAKOSWR6.mjs → chunk-RHQWQJ4I.mjs} +7 -6
- package/dist/{chunk-GS4SV2HK.mjs → chunk-RRLE7QRH.mjs} +43 -22
- package/dist/{chunk-RID7A5V7.mjs → chunk-RRNQL6MJ.mjs} +23 -6
- package/dist/{chunk-VJ6YM2EW.mjs → chunk-S4BKVFQ7.mjs} +1 -1
- package/dist/{chunk-LPZBXTJ6.mjs → chunk-SAC4PAG3.mjs} +4 -4
- package/dist/{chunk-W5RZPTFD.mjs → chunk-SNNT64HK.mjs} +13 -2
- package/dist/{chunk-N3C6YI7I.mjs → chunk-SWMYIORV.mjs} +22 -7
- package/dist/{chunk-2XCXK3NQ.mjs → chunk-SX3NAN4M.mjs} +1 -1
- package/dist/chunk-TBOXTAIA.mjs +94 -0
- package/dist/{chunk-JL3CN4UK.mjs → chunk-TDBMAKTJ.mjs} +10 -3
- package/dist/{chunk-EDBMWZKH.mjs → chunk-TPESRDUG.mjs} +5 -1
- package/dist/chunk-UEGNXN5B.mjs +28 -0
- package/dist/{chunk-NEEGXKJW.mjs → chunk-UGHLEKEZ.mjs} +22 -3
- package/dist/{chunk-HKYRRQS7.mjs → chunk-UNQO7EVG.mjs} +1 -1
- package/dist/chunk-UR5F74ZB.mjs +601 -0
- package/dist/{chunk-VCCK4CDT.mjs → chunk-URPXBKK4.mjs} +23 -5
- package/dist/chunk-UUWPSRNV.mjs +337 -0
- package/dist/chunk-UXJRH72H.mjs +834 -0
- package/dist/chunk-VFS5XAZ3.mjs +602 -0
- package/dist/{chunk-7KCOF5US.mjs → chunk-VY6FVIOZ.mjs} +10 -8
- package/dist/{chunk-KICZSLOX.mjs → chunk-W2ICYZVU.mjs} +1 -1
- package/dist/{chunk-FIVVKBBF.mjs → chunk-W3QOMJKQ.mjs} +8 -6
- package/dist/{chunk-DCMRB3HR.mjs → chunk-WV25G4M3.mjs} +4 -3
- package/dist/{chunk-3KITFMBJ.mjs → chunk-X5LJT76O.mjs} +52 -35
- package/dist/{chunk-BNYA5IUB.mjs → chunk-YNXP34KO.mjs} +39 -38
- package/dist/{chunk-2T2NEZRZ.mjs → chunk-YVDTXHQ6.mjs} +1 -1
- package/dist/{chunk-AUMTHL6N.mjs → chunk-ZOP7PEKY.mjs} +2 -1
- package/dist/components/ActivityFeed.d.mts +29 -11
- package/dist/components/ActivityFeed.mjs +3 -3
- package/dist/components/Affix.d.mts +4 -4
- package/dist/components/Affix.mjs +1 -1
- package/dist/components/Alert.d.mts +4 -4
- package/dist/components/Anchor.d.mts +2 -2
- package/dist/components/Anchor.mjs +1 -1
- package/dist/components/AreaChart.d.mts +3 -3
- package/dist/components/AreaChart.mjs +5 -4
- package/dist/components/AspectRatio.d.mts +44 -0
- package/dist/components/AspectRatio.mjs +8 -0
- package/dist/components/AutoComplete.d.mts +3 -3
- package/dist/components/AutoComplete.mjs +1 -1
- package/dist/components/Avatar.d.mts +2 -2
- package/dist/components/AvatarGroup.d.mts +2 -2
- package/dist/components/BackTop.d.mts +2 -2
- package/dist/components/Badge.d.mts +5 -5
- package/dist/components/BarChart.d.mts +2 -2
- package/dist/components/BarChart.mjs +5 -4
- package/dist/components/Breadcrumb.d.mts +2 -2
- package/dist/components/Button.d.mts +5 -5
- package/dist/components/ButtonGroup.d.mts +1 -1
- package/dist/components/Calendar.d.mts +2 -2
- package/dist/components/Calendar.mjs +1 -1
- package/dist/components/Card.d.mts +3 -3
- package/dist/components/Carousel.d.mts +3 -3
- package/dist/components/Cascader.d.mts +37 -3
- package/dist/components/Cascader.mjs +1 -1
- package/dist/components/ChartCanvas.d.mts +8 -4
- package/dist/components/ChartCanvas.mjs +1 -1
- package/dist/components/ChartGrid.d.mts +1 -1
- package/dist/components/ChartLegend.d.mts +2 -2
- package/dist/components/ChartTooltip.d.mts +1 -1
- package/dist/components/ChatWindow.d.mts +29 -11
- package/dist/components/ChatWindow.mjs +4 -4
- package/dist/components/Checkbox.d.mts +1 -1
- package/dist/components/Code.d.mts +33 -6
- package/dist/components/Code.mjs +3 -1
- package/dist/components/CodeEditor.d.mts +1 -1
- package/dist/components/CodeEditor.mjs +1 -1
- package/dist/components/Collapse.d.mts +1 -1
- package/dist/components/CollapsePanel.mjs +1 -1
- package/dist/components/ColorPicker.mjs +1 -1
- package/dist/components/ColorSwatch.d.mts +8 -2
- package/dist/components/ColorSwatch.mjs +1 -1
- package/dist/components/CommentThread.d.mts +63 -27
- package/dist/components/CommentThread.mjs +2 -2
- package/dist/components/Container.d.mts +1 -1
- package/dist/components/ContextMenu.d.mts +234 -0
- package/dist/components/ContextMenu.mjs +17 -0
- package/dist/components/Countdown.d.mts +1 -1
- package/dist/components/CronEditor.d.mts +3 -3
- package/dist/components/CropUpload.d.mts +1 -1
- package/dist/components/DataExport.d.mts +1 -1
- package/dist/components/DataExport.mjs +2 -2
- package/dist/components/DataTableWithToolbar.d.mts +11 -11
- package/dist/components/DataTableWithToolbar.mjs +8 -8
- package/dist/components/DatePicker.d.mts +5 -5
- package/dist/components/Descriptions.d.mts +3 -3
- package/dist/components/DonutChart.d.mts +3 -3
- package/dist/components/DonutChart.mjs +5 -5
- package/dist/components/Drawer.d.mts +6 -6
- package/dist/components/Dropdown.d.mts +21 -2
- package/dist/components/Dropdown.mjs +1 -1
- package/dist/components/Empty.d.mts +1 -1
- package/dist/components/FileManager.d.mts +10 -4
- package/dist/components/FileManager.mjs +1 -1
- package/dist/components/FloatButton.d.mts +37 -7
- package/dist/components/FloatButton.mjs +1 -1
- package/dist/components/Form.d.mts +2 -2
- package/dist/components/FormWizard.d.mts +4 -4
- package/dist/components/FormWizard.mjs +1 -1
- package/dist/components/FunnelChart.d.mts +4 -4
- package/dist/components/FunnelChart.mjs +4 -4
- package/dist/components/Gantt.d.mts +6 -4
- package/dist/components/Gantt.mjs +2 -2
- package/dist/components/GaugeChart.d.mts +4 -4
- package/dist/components/GaugeChart.mjs +2 -2
- package/dist/components/Header.d.mts +1 -1
- package/dist/components/HeatmapChart.d.mts +3 -3
- package/dist/components/HeatmapChart.mjs +3 -3
- package/dist/components/Highlight.d.mts +146 -0
- package/dist/components/Highlight.mjs +8 -0
- package/dist/components/Icon.d.mts +2 -2
- package/dist/components/Image.d.mts +2 -2
- package/dist/components/Image.mjs +3 -3
- package/dist/components/ImageAnnotation.d.mts +4 -4
- package/dist/components/ImageCompare.d.mts +284 -0
- package/dist/components/ImageCompare.mjs +8 -0
- package/dist/components/ImageCropper.d.mts +1 -1
- package/dist/components/ImageGroup.mjs +2 -2
- package/dist/components/ImagePreview.d.mts +1 -1
- package/dist/components/ImagePreview.mjs +1 -1
- package/dist/components/ImageViewer.d.mts +1 -1
- package/dist/components/InfiniteScroll.d.mts +4 -4
- package/dist/components/Input.d.mts +7 -7
- package/dist/components/Input.mjs +1 -1
- package/dist/components/InputGroup.d.mts +2 -2
- package/dist/components/InputNumber.d.mts +3 -3
- package/dist/components/InputNumber.mjs +1 -1
- package/dist/components/InputOTP.d.mts +261 -0
- package/dist/components/InputOTP.mjs +11 -0
- package/dist/components/Kanban.d.mts +1 -1
- package/dist/components/Kanban.mjs +2 -2
- package/dist/components/Kbd.d.mts +118 -0
- package/dist/components/Kbd.mjs +8 -0
- package/dist/components/LineChart.d.mts +2 -2
- package/dist/components/LineChart.mjs +5 -4
- package/dist/components/Link.d.mts +1 -1
- package/dist/components/List.d.mts +7 -7
- package/dist/components/List.mjs +2 -2
- package/dist/components/Loading.d.mts +7 -7
- package/dist/components/Loading.mjs +1 -1
- package/dist/components/LoadingBar.d.mts +8 -0
- package/dist/components/LoadingBar.mjs +114 -0
- package/dist/components/LoadingBarContainer.d.mts +78 -0
- package/dist/components/LoadingBarContainer.mjs +8 -0
- package/dist/components/LoadingBarRoot.d.mts +6 -0
- package/dist/components/LoadingBarRoot.mjs +6 -0
- package/dist/components/MarkdownEditor.d.mts +4 -4
- package/dist/components/Marquee.d.mts +158 -0
- package/dist/components/Marquee.mjs +8 -0
- package/dist/components/MaskInput.d.mts +207 -0
- package/dist/components/MaskInput.mjs +11 -0
- package/dist/components/Masonry.d.mts +66 -0
- package/dist/components/Masonry.mjs +8 -0
- package/dist/components/Mentions.d.mts +1 -1
- package/dist/components/Menu.d.mts +4 -4
- package/dist/components/Modal.d.mts +7 -7
- package/dist/components/NavigationMenu.d.mts +411 -0
- package/dist/components/NavigationMenu.mjs +25 -0
- package/dist/components/NotificationCenter.d.mts +48 -30
- package/dist/components/NotificationCenter.mjs +4 -4
- package/dist/components/NumberKeyboard.d.mts +4 -4
- package/dist/components/OrgChart.d.mts +4 -4
- package/dist/components/OrgChart.mjs +2 -2
- package/dist/components/PageHeader.d.mts +140 -0
- package/dist/components/PageHeader.mjs +11 -0
- package/dist/components/Pagination.d.mts +5 -5
- package/dist/components/Pagination.mjs +1 -1
- package/dist/components/PieChart.d.mts +3 -3
- package/dist/components/PieChart.mjs +4 -4
- package/dist/components/Popconfirm.d.mts +4 -4
- package/dist/components/Popconfirm.mjs +2 -2
- package/dist/components/Popover.d.mts +5 -5
- package/dist/components/Popover.mjs +2 -2
- package/dist/components/Progress.d.mts +7 -7
- package/dist/components/QRCode.d.mts +4 -13
- package/dist/components/QRCode.mjs +1 -1
- package/dist/components/RadarChart.d.mts +3 -3
- package/dist/components/RadarChart.mjs +4 -4
- package/dist/components/Radio.d.mts +1 -1
- package/dist/components/Radio.mjs +1 -1
- package/dist/components/Rate.d.mts +1 -1
- package/dist/components/Rate.mjs +1 -1
- package/dist/components/Result.d.mts +1 -1
- package/dist/components/RichTextEditor.d.mts +4 -4
- package/dist/components/Row.d.mts +1 -1
- package/dist/components/ScatterChart.d.mts +3 -3
- package/dist/components/ScatterChart.mjs +5 -4
- package/dist/components/ScrollArea.d.mts +136 -0
- package/dist/components/ScrollArea.mjs +8 -0
- package/dist/components/ScrollSpy.d.mts +2 -2
- package/dist/components/ScrollSpy.mjs +1 -1
- package/dist/components/Segmented.d.mts +2 -2
- package/dist/components/Select.d.mts +3 -3
- package/dist/components/Signature.d.mts +6 -6
- package/dist/components/Signature.mjs +1 -1
- package/dist/components/Skeleton.d.mts +2 -2
- package/dist/components/Slider.d.mts +19 -1
- package/dist/components/Slider.mjs +1 -1
- package/dist/components/Space.d.mts +2 -2
- package/dist/components/SplitButton.d.mts +286 -0
- package/dist/components/SplitButton.mjs +12 -0
- package/dist/components/Splitter.d.mts +4 -4
- package/dist/components/Splitter.mjs +1 -1
- package/dist/components/Spotlight.d.mts +6 -6
- package/dist/components/Statistic.d.mts +1 -1
- package/dist/components/Stepper.d.mts +7 -1
- package/dist/components/Stepper.mjs +1 -1
- package/dist/components/Steps.d.mts +1 -1
- package/dist/components/SunburstChart.d.mts +2 -2
- package/dist/components/SunburstChart.mjs +4 -4
- package/dist/components/Switch.d.mts +22 -6
- package/dist/components/Switch.mjs +1 -1
- package/dist/components/Table.d.mts +9 -9
- package/dist/components/Table.mjs +3 -3
- package/dist/components/Tabs.d.mts +5 -5
- package/dist/components/Tag.d.mts +3 -3
- package/dist/components/TagsInput.d.mts +214 -0
- package/dist/components/TagsInput.mjs +12 -0
- package/dist/components/TaskBoard.d.mts +2 -2
- package/dist/components/TaskBoard.mjs +1 -1
- package/dist/components/Text.d.mts +3 -3
- package/dist/components/Textarea.d.mts +4 -4
- package/dist/components/Textarea.mjs +1 -1
- package/dist/components/TimePicker.d.mts +6 -6
- package/dist/components/Timeline.d.mts +2 -2
- package/dist/components/Tooltip.d.mts +2 -2
- package/dist/components/Tooltip.mjs +2 -2
- package/dist/components/Tour.d.mts +4 -4
- package/dist/components/Tour.mjs +1 -1
- package/dist/components/Transfer.d.mts +5 -4
- package/dist/components/Transfer.mjs +1 -1
- package/dist/components/Tree.d.mts +6 -6
- package/dist/components/TreeMapChart.d.mts +3 -3
- package/dist/components/TreeMapChart.mjs +4 -4
- package/dist/components/TreeSelect.d.mts +54 -3
- package/dist/components/TreeSelect.mjs +2 -1
- package/dist/components/Upload.d.mts +4 -4
- package/dist/components/Upload.mjs +1 -1
- package/dist/components/VirtualTable.d.mts +5 -5
- package/dist/components/Watermark.d.mts +6 -6
- package/dist/composables/useChartInteraction.d.mts +5 -0
- package/dist/composables/useChartInteraction.mjs +1 -1
- package/dist/index.d.mts +17 -1
- package/dist/index.mjs +406 -0
- package/package.json +117 -2
- package/dist/chunk-OTGGPXDT.mjs +0 -433
- package/dist/chunk-WC5MKASU.mjs +0 -393
|
@@ -0,0 +1,835 @@
|
|
|
1
|
+
import {
|
|
2
|
+
renderVueOverlayTeleport,
|
|
3
|
+
useVueAnchoredOverlay
|
|
4
|
+
} from "./chunk-Q7Y22OFX.mjs";
|
|
5
|
+
import {
|
|
6
|
+
useTigerConfig
|
|
7
|
+
} from "./chunk-UOJOJBEU.mjs";
|
|
8
|
+
|
|
9
|
+
// src/components/Cascader.ts
|
|
10
|
+
import { defineComponent, computed, ref, h, watch, nextTick } from "vue";
|
|
11
|
+
import {
|
|
12
|
+
classNames,
|
|
13
|
+
cascaderBaseClasses,
|
|
14
|
+
cascaderDropdownClasses,
|
|
15
|
+
cascaderColumnClasses,
|
|
16
|
+
cascaderSearchInputClasses,
|
|
17
|
+
cascaderEmptyStateClasses,
|
|
18
|
+
cascaderSearchResultClasses,
|
|
19
|
+
getCascaderTriggerClasses,
|
|
20
|
+
getCascaderOptionClasses,
|
|
21
|
+
getCascaderColumns,
|
|
22
|
+
getCascaderDisplayLabel,
|
|
23
|
+
flattenCascaderOptions,
|
|
24
|
+
filterCascaderOptions,
|
|
25
|
+
isCascaderOptionExpandable,
|
|
26
|
+
getCascaderVirtualItemHeight,
|
|
27
|
+
getCascaderVirtualRange,
|
|
28
|
+
getCascaderVirtualAlignScrollTop,
|
|
29
|
+
CASCADER_DEFAULT_LIST_HEIGHT,
|
|
30
|
+
getPickerComboboxAria,
|
|
31
|
+
getPickerListboxAria,
|
|
32
|
+
getPickerOptionAria,
|
|
33
|
+
getPickerTriggerKeyAction,
|
|
34
|
+
getPickerNavigationIndex,
|
|
35
|
+
getPickerOptionId,
|
|
36
|
+
findFirstEnabledIndex,
|
|
37
|
+
icon20ViewBox,
|
|
38
|
+
chevronDownSolidIcon20PathD,
|
|
39
|
+
closeSolidIcon20PathD,
|
|
40
|
+
coerceClassValue,
|
|
41
|
+
resolveLocaleText,
|
|
42
|
+
mergeTigerLocale
|
|
43
|
+
} from "@expcat/tigercat-core";
|
|
44
|
+
var cascaderInstanceId = 0;
|
|
45
|
+
var ChevronRightIcon = h(
|
|
46
|
+
"svg",
|
|
47
|
+
{
|
|
48
|
+
class: "w-4 h-4 text-[var(--tiger-text-muted,#9ca3af)]",
|
|
49
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
50
|
+
viewBox: "0 0 20 20",
|
|
51
|
+
fill: "currentColor"
|
|
52
|
+
},
|
|
53
|
+
[
|
|
54
|
+
h("path", {
|
|
55
|
+
"fill-rule": "evenodd",
|
|
56
|
+
d: "M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z",
|
|
57
|
+
"clip-rule": "evenodd"
|
|
58
|
+
})
|
|
59
|
+
]
|
|
60
|
+
);
|
|
61
|
+
var Cascader = defineComponent({
|
|
62
|
+
name: "TigerCascader",
|
|
63
|
+
props: {
|
|
64
|
+
modelValue: {
|
|
65
|
+
type: Array,
|
|
66
|
+
default: () => []
|
|
67
|
+
},
|
|
68
|
+
options: {
|
|
69
|
+
type: Array,
|
|
70
|
+
default: () => []
|
|
71
|
+
},
|
|
72
|
+
placeholder: {
|
|
73
|
+
type: String,
|
|
74
|
+
default: "Please select"
|
|
75
|
+
},
|
|
76
|
+
size: {
|
|
77
|
+
type: String,
|
|
78
|
+
default: "md"
|
|
79
|
+
},
|
|
80
|
+
disabled: {
|
|
81
|
+
type: Boolean,
|
|
82
|
+
default: false
|
|
83
|
+
},
|
|
84
|
+
clearable: {
|
|
85
|
+
type: Boolean,
|
|
86
|
+
default: true
|
|
87
|
+
},
|
|
88
|
+
searchable: {
|
|
89
|
+
type: [Boolean, Object],
|
|
90
|
+
default: false
|
|
91
|
+
},
|
|
92
|
+
searchValue: {
|
|
93
|
+
type: String,
|
|
94
|
+
default: void 0
|
|
95
|
+
},
|
|
96
|
+
defaultSearchValue: {
|
|
97
|
+
type: String,
|
|
98
|
+
default: ""
|
|
99
|
+
},
|
|
100
|
+
expandTrigger: {
|
|
101
|
+
type: String,
|
|
102
|
+
default: "click"
|
|
103
|
+
},
|
|
104
|
+
changeOnSelect: {
|
|
105
|
+
type: Boolean,
|
|
106
|
+
default: false
|
|
107
|
+
},
|
|
108
|
+
separator: {
|
|
109
|
+
type: String,
|
|
110
|
+
default: " / "
|
|
111
|
+
},
|
|
112
|
+
emptyText: {
|
|
113
|
+
type: String,
|
|
114
|
+
default: void 0
|
|
115
|
+
},
|
|
116
|
+
/**
|
|
117
|
+
* Whether to use virtual scrolling for column and search lists
|
|
118
|
+
*/
|
|
119
|
+
virtual: {
|
|
120
|
+
type: Boolean,
|
|
121
|
+
default: false
|
|
122
|
+
},
|
|
123
|
+
/**
|
|
124
|
+
* Height of each column panel (and searchable list) in pixels
|
|
125
|
+
* @default 256
|
|
126
|
+
*/
|
|
127
|
+
listHeight: {
|
|
128
|
+
type: Number,
|
|
129
|
+
default: CASCADER_DEFAULT_LIST_HEIGHT
|
|
130
|
+
},
|
|
131
|
+
/**
|
|
132
|
+
* Locale overrides merged on top of ConfigProvider locale
|
|
133
|
+
*/
|
|
134
|
+
locale: {
|
|
135
|
+
type: Object,
|
|
136
|
+
default: void 0
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
emits: ["update:modelValue", "update:searchValue", "change", "search-change"],
|
|
140
|
+
setup(props, { emit, attrs }) {
|
|
141
|
+
const instanceId = ++cascaderInstanceId;
|
|
142
|
+
const listboxId = `tiger-cascader-listbox-${instanceId}`;
|
|
143
|
+
const config = useTigerConfig();
|
|
144
|
+
const mergedLocale = computed(() => mergeTigerLocale(config.value.locale, props.locale));
|
|
145
|
+
const isOpen = ref(false);
|
|
146
|
+
const uncontrolledSearchValue = ref(props.defaultSearchValue);
|
|
147
|
+
const searchQuery = computed(() => props.searchValue ?? uncontrolledSearchValue.value);
|
|
148
|
+
const activePath = ref([]);
|
|
149
|
+
const triggerRef = ref(null);
|
|
150
|
+
const dropdownRef = ref(null);
|
|
151
|
+
const searchInputRef = ref(null);
|
|
152
|
+
const overlay = useVueAnchoredOverlay({
|
|
153
|
+
enabled: isOpen,
|
|
154
|
+
referenceRef: triggerRef,
|
|
155
|
+
floatingRef: dropdownRef,
|
|
156
|
+
placement: "bottom-start",
|
|
157
|
+
offset: 4,
|
|
158
|
+
layout: "fullscreen-sm",
|
|
159
|
+
matchReferenceWidth: true,
|
|
160
|
+
dismissOnOutside: true,
|
|
161
|
+
dismissOnEscape: true,
|
|
162
|
+
restoreFocusOnDismiss: true,
|
|
163
|
+
onDismiss: closeDropdown
|
|
164
|
+
});
|
|
165
|
+
const columnScrollTops = ref([]);
|
|
166
|
+
const columnScrollEls = ref([]);
|
|
167
|
+
const columnActiveIndices = ref([]);
|
|
168
|
+
const searchScrollTop = ref(0);
|
|
169
|
+
const searchScrollEl = ref(null);
|
|
170
|
+
const searchActiveIndex = ref(-1);
|
|
171
|
+
const focusedColumnIndex = ref(0);
|
|
172
|
+
const displayLabel = computed(() => {
|
|
173
|
+
if (!props.modelValue || props.modelValue.length === 0) return "";
|
|
174
|
+
return getCascaderDisplayLabel(props.options, props.modelValue, props.separator);
|
|
175
|
+
});
|
|
176
|
+
const columns = computed(() => {
|
|
177
|
+
return getCascaderColumns(props.options, activePath.value);
|
|
178
|
+
});
|
|
179
|
+
const isSearchMode = computed(() => {
|
|
180
|
+
return props.searchable && searchQuery.value.length > 0;
|
|
181
|
+
});
|
|
182
|
+
const flattenedOptions = computed(() => {
|
|
183
|
+
if (!props.searchable) return [];
|
|
184
|
+
return flattenCascaderOptions(props.options, [], [], props.changeOnSelect);
|
|
185
|
+
});
|
|
186
|
+
const searchResults = computed(() => {
|
|
187
|
+
if (!isSearchMode.value) return [];
|
|
188
|
+
return filterCascaderOptions(flattenedOptions.value, searchQuery.value, props.searchable);
|
|
189
|
+
});
|
|
190
|
+
const triggerClasses = computed(
|
|
191
|
+
() => classNames(
|
|
192
|
+
getCascaderTriggerClasses(props.size, props.disabled, isOpen.value),
|
|
193
|
+
coerceClassValue(attrs.class)
|
|
194
|
+
)
|
|
195
|
+
);
|
|
196
|
+
function selectedIndexInColumn(options, selectedValue) {
|
|
197
|
+
if (selectedValue === void 0) return -1;
|
|
198
|
+
return options.findIndex((option) => option.value === selectedValue);
|
|
199
|
+
}
|
|
200
|
+
function alignVirtualScroll(el, index, setScrollTop) {
|
|
201
|
+
if (!props.virtual || !el || index < 0) return;
|
|
202
|
+
const itemH = getCascaderVirtualItemHeight(props.size);
|
|
203
|
+
const next = getCascaderVirtualAlignScrollTop(el.scrollTop, index, itemH, props.listHeight);
|
|
204
|
+
if (el.scrollTop !== next) el.scrollTop = next;
|
|
205
|
+
setScrollTop(next);
|
|
206
|
+
}
|
|
207
|
+
watch(isOpen, (open) => {
|
|
208
|
+
if (open) {
|
|
209
|
+
columnScrollTops.value = [];
|
|
210
|
+
columnScrollEls.value = [];
|
|
211
|
+
columnActiveIndices.value = [];
|
|
212
|
+
searchScrollTop.value = 0;
|
|
213
|
+
searchActiveIndex.value = -1;
|
|
214
|
+
focusedColumnIndex.value = 0;
|
|
215
|
+
activePath.value = props.modelValue ? [...props.modelValue] : [];
|
|
216
|
+
updateSearchValue("");
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
watch(
|
|
220
|
+
[isOpen, columns],
|
|
221
|
+
() => {
|
|
222
|
+
if (!isOpen.value) return;
|
|
223
|
+
const cols = columns.value;
|
|
224
|
+
columnActiveIndices.value = cols.map((col, i) => {
|
|
225
|
+
const prev = columnActiveIndices.value[i];
|
|
226
|
+
if (prev !== void 0 && prev >= 0 && prev < col.options.length && !col.options[prev]?.disabled) {
|
|
227
|
+
return prev;
|
|
228
|
+
}
|
|
229
|
+
return selectedIndexInColumn(col.options, col.selectedValue);
|
|
230
|
+
});
|
|
231
|
+
if (focusedColumnIndex.value > cols.length - 1) {
|
|
232
|
+
focusedColumnIndex.value = Math.max(0, cols.length - 1);
|
|
233
|
+
}
|
|
234
|
+
if (!props.virtual) return;
|
|
235
|
+
const itemH = getCascaderVirtualItemHeight(props.size);
|
|
236
|
+
columnScrollTops.value = cols.map((col, i) => {
|
|
237
|
+
const stored = columnScrollTops.value[i];
|
|
238
|
+
if (stored !== void 0) return stored;
|
|
239
|
+
return getCascaderVirtualAlignScrollTop(
|
|
240
|
+
0,
|
|
241
|
+
columnActiveIndices.value[i] ?? -1,
|
|
242
|
+
itemH,
|
|
243
|
+
props.listHeight
|
|
244
|
+
);
|
|
245
|
+
});
|
|
246
|
+
},
|
|
247
|
+
{ immediate: true }
|
|
248
|
+
);
|
|
249
|
+
watch(
|
|
250
|
+
columnActiveIndices,
|
|
251
|
+
(indices) => {
|
|
252
|
+
if (!props.virtual) return;
|
|
253
|
+
nextTick(() => {
|
|
254
|
+
indices.forEach((idx, colIndex) => {
|
|
255
|
+
alignVirtualScroll(columnScrollEls.value[colIndex] ?? null, idx, (top) => {
|
|
256
|
+
columnScrollTops.value[colIndex] = top;
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
},
|
|
261
|
+
{ deep: true }
|
|
262
|
+
);
|
|
263
|
+
watch(searchActiveIndex, (idx) => {
|
|
264
|
+
if (!props.virtual) return;
|
|
265
|
+
nextTick(() => {
|
|
266
|
+
alignVirtualScroll(searchScrollEl.value, idx, (top) => {
|
|
267
|
+
searchScrollTop.value = top;
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
watch(searchQuery, () => {
|
|
272
|
+
searchScrollTop.value = 0;
|
|
273
|
+
searchActiveIndex.value = -1;
|
|
274
|
+
});
|
|
275
|
+
function updateSearchValue(value) {
|
|
276
|
+
if (props.searchValue === void 0) {
|
|
277
|
+
uncontrolledSearchValue.value = value;
|
|
278
|
+
}
|
|
279
|
+
emit("update:searchValue", value);
|
|
280
|
+
emit("search-change", value);
|
|
281
|
+
}
|
|
282
|
+
function toggleOpen() {
|
|
283
|
+
if (props.disabled) return;
|
|
284
|
+
isOpen.value = !isOpen.value;
|
|
285
|
+
}
|
|
286
|
+
function closeDropdown() {
|
|
287
|
+
isOpen.value = false;
|
|
288
|
+
}
|
|
289
|
+
function isOptionDisabled(option) {
|
|
290
|
+
return !!option.disabled;
|
|
291
|
+
}
|
|
292
|
+
function getColumnOptionDomId(colIndex, optionIndex) {
|
|
293
|
+
return `${listboxId}-col${colIndex}-opt${optionIndex}`;
|
|
294
|
+
}
|
|
295
|
+
function getCurrentColumnIndex() {
|
|
296
|
+
const last = columns.value.length - 1;
|
|
297
|
+
if (last < 0) return 0;
|
|
298
|
+
const focused = focusedColumnIndex.value;
|
|
299
|
+
if (focused >= 0 && focused <= last) return focused;
|
|
300
|
+
return last;
|
|
301
|
+
}
|
|
302
|
+
function setColumnActiveIndex(colIndex, index) {
|
|
303
|
+
const next = columnActiveIndices.value.slice();
|
|
304
|
+
next[colIndex] = index;
|
|
305
|
+
columnActiveIndices.value = next;
|
|
306
|
+
}
|
|
307
|
+
function activateColumnOption(colIndex, index) {
|
|
308
|
+
setColumnActiveIndex(colIndex, index);
|
|
309
|
+
focusedColumnIndex.value = colIndex;
|
|
310
|
+
}
|
|
311
|
+
function resolveColumnActiveIndex(colIndex) {
|
|
312
|
+
const col = columns.value[colIndex];
|
|
313
|
+
if (!col) return -1;
|
|
314
|
+
const current = columnActiveIndices.value[colIndex];
|
|
315
|
+
if (current !== void 0 && current >= 0 && current < col.options.length && !col.options[current].disabled) {
|
|
316
|
+
return current;
|
|
317
|
+
}
|
|
318
|
+
const selected = selectedIndexInColumn(col.options, col.selectedValue);
|
|
319
|
+
if (selected >= 0 && !col.options[selected]?.disabled) return selected;
|
|
320
|
+
return findFirstEnabledIndex(col.options, isOptionDisabled);
|
|
321
|
+
}
|
|
322
|
+
function handleOptionClick(option, level) {
|
|
323
|
+
if (option.disabled) return;
|
|
324
|
+
const optionIndex = columns.value[level]?.options.findIndex(
|
|
325
|
+
(item) => item.value === option.value
|
|
326
|
+
);
|
|
327
|
+
const newPath = activePath.value.slice(0, level);
|
|
328
|
+
newPath.push(option.value);
|
|
329
|
+
activePath.value = newPath;
|
|
330
|
+
if (optionIndex !== void 0 && optionIndex >= 0) {
|
|
331
|
+
activateColumnOption(level, optionIndex);
|
|
332
|
+
}
|
|
333
|
+
const hasChildren = isCascaderOptionExpandable(option);
|
|
334
|
+
if (!hasChildren) {
|
|
335
|
+
emit("update:modelValue", newPath);
|
|
336
|
+
emit("change", newPath);
|
|
337
|
+
closeDropdown();
|
|
338
|
+
} else if (props.changeOnSelect) {
|
|
339
|
+
emit("update:modelValue", newPath);
|
|
340
|
+
emit("change", newPath);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
function handleOptionHover(option, level) {
|
|
344
|
+
const optionIndex = columns.value[level]?.options.findIndex(
|
|
345
|
+
(item) => item.value === option.value
|
|
346
|
+
);
|
|
347
|
+
if (optionIndex !== void 0 && optionIndex >= 0 && !option.disabled) {
|
|
348
|
+
activateColumnOption(level, optionIndex);
|
|
349
|
+
}
|
|
350
|
+
if (props.expandTrigger !== "hover" || option.disabled) return;
|
|
351
|
+
const newPath = activePath.value.slice(0, level);
|
|
352
|
+
newPath.push(option.value);
|
|
353
|
+
activePath.value = newPath;
|
|
354
|
+
}
|
|
355
|
+
function handleSearchResultClick(valuePath, disabled) {
|
|
356
|
+
if (disabled) return;
|
|
357
|
+
emit("update:modelValue", valuePath);
|
|
358
|
+
emit("change", valuePath);
|
|
359
|
+
closeDropdown();
|
|
360
|
+
}
|
|
361
|
+
function handleClear(e) {
|
|
362
|
+
e.stopPropagation();
|
|
363
|
+
emit("update:modelValue", []);
|
|
364
|
+
emit("change", []);
|
|
365
|
+
}
|
|
366
|
+
function handleSearchInput(e) {
|
|
367
|
+
updateSearchValue(e.target.value);
|
|
368
|
+
}
|
|
369
|
+
function handleVirtualListKeyDown(e, items, current, setIndex) {
|
|
370
|
+
if (e.key !== "ArrowDown" && e.key !== "ArrowUp" && e.key !== "Home" && e.key !== "End") {
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
e.preventDefault();
|
|
374
|
+
e.stopPropagation();
|
|
375
|
+
setIndex(getPickerNavigationIndex(items, current, e.key));
|
|
376
|
+
}
|
|
377
|
+
function renderVirtualWindow(itemCount, scrollTop, onScrollTop, setScrollEl, renderItem, extraAttrs, onKeyDown) {
|
|
378
|
+
const itemH = getCascaderVirtualItemHeight(props.size);
|
|
379
|
+
const { startIndex, endIndex, totalHeight } = getCascaderVirtualRange(
|
|
380
|
+
scrollTop,
|
|
381
|
+
props.listHeight,
|
|
382
|
+
itemCount,
|
|
383
|
+
itemH
|
|
384
|
+
);
|
|
385
|
+
const fromIndex = itemCount <= 0 ? 0 : Math.min(startIndex, endIndex, itemCount - 1);
|
|
386
|
+
const toIndex = itemCount <= 0 ? -1 : Math.min(endIndex, itemCount - 1);
|
|
387
|
+
const visible = [];
|
|
388
|
+
if (fromIndex <= toIndex) {
|
|
389
|
+
for (let i = fromIndex; i <= toIndex; i++) {
|
|
390
|
+
const node = renderItem(i);
|
|
391
|
+
if (node) visible.push(node);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
return h(
|
|
395
|
+
"div",
|
|
396
|
+
{
|
|
397
|
+
...extraAttrs,
|
|
398
|
+
ref: ((el) => {
|
|
399
|
+
setScrollEl(el);
|
|
400
|
+
}),
|
|
401
|
+
"data-tiger-cascader-virtual": "",
|
|
402
|
+
tabindex: 0,
|
|
403
|
+
style: { maxHeight: `${props.listHeight}px`, overflowY: "auto" },
|
|
404
|
+
onScroll: (e) => {
|
|
405
|
+
onScrollTop(e.target.scrollTop);
|
|
406
|
+
},
|
|
407
|
+
onKeydown: onKeyDown
|
|
408
|
+
},
|
|
409
|
+
[
|
|
410
|
+
h("div", { style: { height: `${totalHeight}px`, position: "relative" } }, [
|
|
411
|
+
h("div", { style: { transform: `translateY(${fromIndex * itemH}px)` } }, visible)
|
|
412
|
+
])
|
|
413
|
+
]
|
|
414
|
+
);
|
|
415
|
+
}
|
|
416
|
+
function commitActiveOption() {
|
|
417
|
+
if (isSearchMode.value) {
|
|
418
|
+
const item = searchResults.value[searchActiveIndex.value];
|
|
419
|
+
if (!item || item.disabled) return;
|
|
420
|
+
handleSearchResultClick(item.valuePath, item.disabled);
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
const colIndex = getCurrentColumnIndex();
|
|
424
|
+
const col = columns.value[colIndex];
|
|
425
|
+
const idx = columnActiveIndices.value[colIndex] ?? -1;
|
|
426
|
+
const option = col?.options[idx];
|
|
427
|
+
if (!option || option.disabled) return;
|
|
428
|
+
handleOptionClick(option, colIndex);
|
|
429
|
+
if (isCascaderOptionExpandable(option)) {
|
|
430
|
+
nextTick(() => {
|
|
431
|
+
const nextCol = colIndex + 1;
|
|
432
|
+
if (!columns.value[nextCol]) return;
|
|
433
|
+
activateColumnOption(nextCol, resolveColumnActiveIndex(nextCol));
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
function handleOpenListKeyDown(e, fromSearchInput = false) {
|
|
438
|
+
const key = e.key;
|
|
439
|
+
if (fromSearchInput && key === " ") return false;
|
|
440
|
+
if (isSearchMode.value) {
|
|
441
|
+
if (key === "ArrowDown" || key === "ArrowUp" || key === "Home" || key === "End") {
|
|
442
|
+
e.preventDefault();
|
|
443
|
+
e.stopPropagation();
|
|
444
|
+
searchActiveIndex.value = getPickerNavigationIndex(
|
|
445
|
+
searchResults.value,
|
|
446
|
+
searchActiveIndex.value,
|
|
447
|
+
key,
|
|
448
|
+
(item) => !!item.disabled
|
|
449
|
+
);
|
|
450
|
+
return true;
|
|
451
|
+
}
|
|
452
|
+
if (key === "Enter" || key === " ") {
|
|
453
|
+
e.preventDefault();
|
|
454
|
+
e.stopPropagation();
|
|
455
|
+
commitActiveOption();
|
|
456
|
+
return true;
|
|
457
|
+
}
|
|
458
|
+
return false;
|
|
459
|
+
}
|
|
460
|
+
const colIndex = getCurrentColumnIndex();
|
|
461
|
+
const col = columns.value[colIndex];
|
|
462
|
+
if (!col) return false;
|
|
463
|
+
if (key === "ArrowDown" || key === "ArrowUp" || key === "Home" || key === "End") {
|
|
464
|
+
e.preventDefault();
|
|
465
|
+
e.stopPropagation();
|
|
466
|
+
const current = columnActiveIndices.value[colIndex] ?? -1;
|
|
467
|
+
const next = getPickerNavigationIndex(col.options, current, key, isOptionDisabled);
|
|
468
|
+
activateColumnOption(colIndex, next);
|
|
469
|
+
return true;
|
|
470
|
+
}
|
|
471
|
+
if (key === "ArrowRight") {
|
|
472
|
+
e.preventDefault();
|
|
473
|
+
e.stopPropagation();
|
|
474
|
+
const idx = columnActiveIndices.value[colIndex] ?? -1;
|
|
475
|
+
const option = col.options[idx];
|
|
476
|
+
if (option && !option.disabled && isCascaderOptionExpandable(option)) {
|
|
477
|
+
handleOptionClick(option, colIndex);
|
|
478
|
+
nextTick(() => {
|
|
479
|
+
const nextCol = colIndex + 1;
|
|
480
|
+
if (!columns.value[nextCol]) return;
|
|
481
|
+
activateColumnOption(nextCol, resolveColumnActiveIndex(nextCol));
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
return true;
|
|
485
|
+
}
|
|
486
|
+
if (key === "ArrowLeft") {
|
|
487
|
+
e.preventDefault();
|
|
488
|
+
e.stopPropagation();
|
|
489
|
+
if (activePath.value.length > 0) {
|
|
490
|
+
activePath.value = activePath.value.slice(0, -1);
|
|
491
|
+
nextTick(() => {
|
|
492
|
+
focusedColumnIndex.value = Math.max(0, Math.min(colIndex - 1, columns.value.length - 1));
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
return true;
|
|
496
|
+
}
|
|
497
|
+
if (key === "Enter" || key === " ") {
|
|
498
|
+
e.preventDefault();
|
|
499
|
+
e.stopPropagation();
|
|
500
|
+
commitActiveOption();
|
|
501
|
+
return true;
|
|
502
|
+
}
|
|
503
|
+
return false;
|
|
504
|
+
}
|
|
505
|
+
function handleTriggerKeyDown(e) {
|
|
506
|
+
if (props.disabled) return;
|
|
507
|
+
if (isOpen.value && handleOpenListKeyDown(e)) return;
|
|
508
|
+
const action = getPickerTriggerKeyAction(e.key, isOpen.value);
|
|
509
|
+
if (action === "none") return;
|
|
510
|
+
e.preventDefault();
|
|
511
|
+
if (action === "toggle") {
|
|
512
|
+
toggleOpen();
|
|
513
|
+
} else if (action === "open") {
|
|
514
|
+
isOpen.value = true;
|
|
515
|
+
} else if (action === "close") {
|
|
516
|
+
closeDropdown();
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
function handleDropdownKeyDown(e) {
|
|
520
|
+
if (e.target instanceof HTMLInputElement) return;
|
|
521
|
+
if (!isOpen.value) return;
|
|
522
|
+
handleOpenListKeyDown(e);
|
|
523
|
+
}
|
|
524
|
+
function handleSearchKeyDown(e) {
|
|
525
|
+
switch (e.key) {
|
|
526
|
+
case " ":
|
|
527
|
+
e.stopPropagation();
|
|
528
|
+
return;
|
|
529
|
+
case "ArrowDown":
|
|
530
|
+
case "ArrowUp":
|
|
531
|
+
case "Enter":
|
|
532
|
+
handleOpenListKeyDown(e, true);
|
|
533
|
+
return;
|
|
534
|
+
case "Escape":
|
|
535
|
+
e.preventDefault();
|
|
536
|
+
e.stopPropagation();
|
|
537
|
+
closeDropdown();
|
|
538
|
+
nextTick(() => {
|
|
539
|
+
;
|
|
540
|
+
triggerRef.value?.focus();
|
|
541
|
+
});
|
|
542
|
+
return;
|
|
543
|
+
default:
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
return () => {
|
|
548
|
+
const hasValue = props.modelValue && props.modelValue.length > 0;
|
|
549
|
+
const showClear = props.clearable && hasValue && !props.disabled;
|
|
550
|
+
const currentCol = getCurrentColumnIndex();
|
|
551
|
+
const currentOpt = columnActiveIndices.value[currentCol] ?? -1;
|
|
552
|
+
const activeOptionId = !isOpen.value ? void 0 : isSearchMode.value ? searchActiveIndex.value >= 0 ? getPickerOptionId(listboxId, searchActiveIndex.value) : void 0 : currentOpt >= 0 ? getColumnOptionDomId(currentCol, currentOpt) : void 0;
|
|
553
|
+
const chevronIcon = h(
|
|
554
|
+
"span",
|
|
555
|
+
{
|
|
556
|
+
class: classNames("inline-flex", isOpen.value && "rotate-180"),
|
|
557
|
+
"aria-hidden": "true"
|
|
558
|
+
},
|
|
559
|
+
[
|
|
560
|
+
h(
|
|
561
|
+
"svg",
|
|
562
|
+
{
|
|
563
|
+
class: "w-5 h-5 text-[var(--tiger-cascader-icon,var(--tiger-text-muted,#9ca3af))] transition-transform",
|
|
564
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
565
|
+
viewBox: icon20ViewBox,
|
|
566
|
+
fill: "currentColor"
|
|
567
|
+
},
|
|
568
|
+
[
|
|
569
|
+
h("path", {
|
|
570
|
+
"fill-rule": "evenodd",
|
|
571
|
+
d: chevronDownSolidIcon20PathD,
|
|
572
|
+
"clip-rule": "evenodd"
|
|
573
|
+
})
|
|
574
|
+
]
|
|
575
|
+
)
|
|
576
|
+
]
|
|
577
|
+
);
|
|
578
|
+
const clearButton = showClear ? h(
|
|
579
|
+
"button",
|
|
580
|
+
{
|
|
581
|
+
type: "button",
|
|
582
|
+
class: "pointer-events-auto inline-flex rounded-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--tiger-cascader-ring,var(--tiger-primary,#2563eb))]",
|
|
583
|
+
"data-tiger-cascader-clear": "",
|
|
584
|
+
"aria-label": resolveLocaleText(
|
|
585
|
+
"Clear selection",
|
|
586
|
+
mergedLocale.value?.common?.clearText
|
|
587
|
+
),
|
|
588
|
+
onClick: handleClear
|
|
589
|
+
},
|
|
590
|
+
[
|
|
591
|
+
h(
|
|
592
|
+
"svg",
|
|
593
|
+
{
|
|
594
|
+
class: "w-4 h-4 text-[var(--tiger-cascader-icon,var(--tiger-text-muted,#9ca3af))] hover:text-[var(--tiger-cascader-icon-hover,var(--tiger-text-muted,#6b7280))]",
|
|
595
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
596
|
+
viewBox: icon20ViewBox,
|
|
597
|
+
fill: "currentColor"
|
|
598
|
+
},
|
|
599
|
+
[
|
|
600
|
+
h("path", {
|
|
601
|
+
"fill-rule": "evenodd",
|
|
602
|
+
d: closeSolidIcon20PathD,
|
|
603
|
+
"clip-rule": "evenodd"
|
|
604
|
+
})
|
|
605
|
+
]
|
|
606
|
+
)
|
|
607
|
+
]
|
|
608
|
+
) : null;
|
|
609
|
+
const trigger = h(
|
|
610
|
+
"button",
|
|
611
|
+
{
|
|
612
|
+
ref: triggerRef,
|
|
613
|
+
type: "button",
|
|
614
|
+
class: classNames(triggerClasses.value, showClear ? "pr-14" : "pr-9"),
|
|
615
|
+
disabled: props.disabled,
|
|
616
|
+
...getPickerComboboxAria({
|
|
617
|
+
expanded: isOpen.value,
|
|
618
|
+
listboxId,
|
|
619
|
+
activeOptionId
|
|
620
|
+
}),
|
|
621
|
+
onClick: toggleOpen,
|
|
622
|
+
onKeydown: handleTriggerKeyDown
|
|
623
|
+
},
|
|
624
|
+
[
|
|
625
|
+
h(
|
|
626
|
+
"span",
|
|
627
|
+
{
|
|
628
|
+
class: classNames(
|
|
629
|
+
"flex-1 text-left truncate",
|
|
630
|
+
!hasValue && "text-[var(--tiger-cascader-placeholder,var(--tiger-text-muted,#9ca3af))]"
|
|
631
|
+
)
|
|
632
|
+
},
|
|
633
|
+
hasValue ? displayLabel.value : props.placeholder
|
|
634
|
+
)
|
|
635
|
+
]
|
|
636
|
+
);
|
|
637
|
+
const iconRow = h(
|
|
638
|
+
"span",
|
|
639
|
+
{ class: "pointer-events-none absolute inset-y-0 right-3 flex items-center gap-1" },
|
|
640
|
+
[clearButton, chevronIcon]
|
|
641
|
+
);
|
|
642
|
+
let dropdownContent = null;
|
|
643
|
+
if (isOpen.value) {
|
|
644
|
+
const children = [];
|
|
645
|
+
if (props.searchable) {
|
|
646
|
+
children.push(
|
|
647
|
+
h("input", {
|
|
648
|
+
ref: searchInputRef,
|
|
649
|
+
type: "text",
|
|
650
|
+
class: cascaderSearchInputClasses,
|
|
651
|
+
placeholder: resolveLocaleText(
|
|
652
|
+
"Search...",
|
|
653
|
+
mergedLocale.value?.common?.searchPlaceholder
|
|
654
|
+
),
|
|
655
|
+
value: searchQuery.value,
|
|
656
|
+
onInput: handleSearchInput,
|
|
657
|
+
onKeydown: handleSearchKeyDown,
|
|
658
|
+
"aria-label": resolveLocaleText(
|
|
659
|
+
"Search options",
|
|
660
|
+
mergedLocale.value?.common?.searchPlaceholder
|
|
661
|
+
)
|
|
662
|
+
})
|
|
663
|
+
);
|
|
664
|
+
}
|
|
665
|
+
if (isSearchMode.value) {
|
|
666
|
+
if (searchResults.value.length === 0) {
|
|
667
|
+
children.push(
|
|
668
|
+
h(
|
|
669
|
+
"div",
|
|
670
|
+
{ class: cascaderEmptyStateClasses },
|
|
671
|
+
resolveLocaleText(
|
|
672
|
+
"No results found",
|
|
673
|
+
props.emptyText,
|
|
674
|
+
mergedLocale.value?.common?.emptyText
|
|
675
|
+
)
|
|
676
|
+
)
|
|
677
|
+
);
|
|
678
|
+
} else {
|
|
679
|
+
const renderSearchItem = (item, index) => {
|
|
680
|
+
const isActive = searchActiveIndex.value === index;
|
|
681
|
+
return h(
|
|
682
|
+
"div",
|
|
683
|
+
{
|
|
684
|
+
key: item.valuePath.join(","),
|
|
685
|
+
id: getPickerOptionId(listboxId, index),
|
|
686
|
+
"data-option-index": index,
|
|
687
|
+
"data-active": isActive || void 0,
|
|
688
|
+
class: classNames(
|
|
689
|
+
cascaderSearchResultClasses,
|
|
690
|
+
isActive && "bg-[var(--tiger-cascader-option-bg-selected,var(--tiger-outline-bg-hover,#eff6ff))]",
|
|
691
|
+
item.disabled && "opacity-50 cursor-not-allowed"
|
|
692
|
+
),
|
|
693
|
+
...getPickerOptionAria({
|
|
694
|
+
selected: props.modelValue?.join(",") === item.valuePath.join(","),
|
|
695
|
+
disabled: item.disabled
|
|
696
|
+
}),
|
|
697
|
+
onMouseenter: () => {
|
|
698
|
+
if (!item.disabled) searchActiveIndex.value = index;
|
|
699
|
+
},
|
|
700
|
+
onClick: () => handleSearchResultClick(item.valuePath, item.disabled)
|
|
701
|
+
},
|
|
702
|
+
typeof props.searchable === "object" && props.searchable.render ? props.searchable.render(searchQuery.value, item.path) : item.label
|
|
703
|
+
);
|
|
704
|
+
};
|
|
705
|
+
const searchList = props.virtual ? renderVirtualWindow(
|
|
706
|
+
searchResults.value.length,
|
|
707
|
+
searchScrollTop.value,
|
|
708
|
+
(top) => {
|
|
709
|
+
searchScrollTop.value = top;
|
|
710
|
+
},
|
|
711
|
+
(el) => {
|
|
712
|
+
searchScrollEl.value = el;
|
|
713
|
+
},
|
|
714
|
+
(index) => renderSearchItem(searchResults.value[index], index),
|
|
715
|
+
{
|
|
716
|
+
...getPickerListboxAria({ id: listboxId })
|
|
717
|
+
},
|
|
718
|
+
(e) => handleVirtualListKeyDown(
|
|
719
|
+
e,
|
|
720
|
+
searchResults.value,
|
|
721
|
+
searchActiveIndex.value,
|
|
722
|
+
(index) => {
|
|
723
|
+
searchActiveIndex.value = index;
|
|
724
|
+
}
|
|
725
|
+
)
|
|
726
|
+
) : h(
|
|
727
|
+
"div",
|
|
728
|
+
{ class: "max-h-64 overflow-auto", ...getPickerListboxAria({ id: listboxId }) },
|
|
729
|
+
searchResults.value.map((item, index) => renderSearchItem(item, index))
|
|
730
|
+
);
|
|
731
|
+
children.push(searchList);
|
|
732
|
+
}
|
|
733
|
+
} else {
|
|
734
|
+
const renderColumnOption = (option, col, colIndex, optionIndex) => {
|
|
735
|
+
const isSelected = col.selectedValue === option.value;
|
|
736
|
+
const isActive = (columnActiveIndices.value[colIndex] ?? -1) === optionIndex;
|
|
737
|
+
const hasChildren = isCascaderOptionExpandable(option);
|
|
738
|
+
return h(
|
|
739
|
+
"div",
|
|
740
|
+
{
|
|
741
|
+
key: option.value,
|
|
742
|
+
id: getColumnOptionDomId(colIndex, optionIndex),
|
|
743
|
+
"data-option-index": optionIndex,
|
|
744
|
+
"data-active": isActive || void 0,
|
|
745
|
+
class: getCascaderOptionClasses(
|
|
746
|
+
isSelected || isActive,
|
|
747
|
+
!!option.disabled,
|
|
748
|
+
props.size
|
|
749
|
+
),
|
|
750
|
+
...getPickerOptionAria({ selected: isSelected, disabled: !!option.disabled }),
|
|
751
|
+
onClick: () => handleOptionClick(option, colIndex),
|
|
752
|
+
onMouseenter: () => handleOptionHover(option, colIndex)
|
|
753
|
+
},
|
|
754
|
+
[
|
|
755
|
+
h("span", { class: "flex-1 truncate" }, option.label),
|
|
756
|
+
hasChildren ? ChevronRightIcon : null
|
|
757
|
+
]
|
|
758
|
+
);
|
|
759
|
+
};
|
|
760
|
+
const columnElements = columns.value.map((col, colIndex) => {
|
|
761
|
+
const listboxAttrs = getPickerListboxAria({
|
|
762
|
+
id: colIndex === 0 ? listboxId : void 0,
|
|
763
|
+
label: `Level ${colIndex + 1}`
|
|
764
|
+
});
|
|
765
|
+
if (props.virtual) {
|
|
766
|
+
return renderVirtualWindow(
|
|
767
|
+
col.options.length,
|
|
768
|
+
columnScrollTops.value[colIndex] ?? 0,
|
|
769
|
+
(top) => {
|
|
770
|
+
columnScrollTops.value[colIndex] = top;
|
|
771
|
+
},
|
|
772
|
+
(el) => {
|
|
773
|
+
const next = columnScrollEls.value.slice();
|
|
774
|
+
next[colIndex] = el;
|
|
775
|
+
columnScrollEls.value = next;
|
|
776
|
+
},
|
|
777
|
+
(index) => renderColumnOption(col.options[index], col, colIndex, index),
|
|
778
|
+
{
|
|
779
|
+
class: cascaderColumnClasses,
|
|
780
|
+
...listboxAttrs
|
|
781
|
+
},
|
|
782
|
+
(e) => handleVirtualListKeyDown(
|
|
783
|
+
e,
|
|
784
|
+
col.options,
|
|
785
|
+
columnActiveIndices.value[colIndex] ?? -1,
|
|
786
|
+
(index) => setColumnActiveIndex(colIndex, index)
|
|
787
|
+
)
|
|
788
|
+
);
|
|
789
|
+
}
|
|
790
|
+
return h(
|
|
791
|
+
"div",
|
|
792
|
+
{
|
|
793
|
+
class: cascaderColumnClasses,
|
|
794
|
+
...listboxAttrs
|
|
795
|
+
},
|
|
796
|
+
col.options.map(
|
|
797
|
+
(option, optionIndex) => renderColumnOption(option, col, colIndex, optionIndex)
|
|
798
|
+
)
|
|
799
|
+
);
|
|
800
|
+
});
|
|
801
|
+
children.push(h("div", { class: "flex" }, columnElements));
|
|
802
|
+
}
|
|
803
|
+
dropdownContent = h(
|
|
804
|
+
"div",
|
|
805
|
+
{
|
|
806
|
+
ref: dropdownRef,
|
|
807
|
+
class: classNames(
|
|
808
|
+
cascaderDropdownClasses,
|
|
809
|
+
isSearchMode.value && "flex-col",
|
|
810
|
+
overlay.floatingClasses.value
|
|
811
|
+
),
|
|
812
|
+
style: overlay.floatingStyles.value,
|
|
813
|
+
"data-positioned": overlay.positioned.value,
|
|
814
|
+
onKeydown: handleDropdownKeyDown
|
|
815
|
+
},
|
|
816
|
+
children
|
|
817
|
+
);
|
|
818
|
+
}
|
|
819
|
+
return h(
|
|
820
|
+
"div",
|
|
821
|
+
{
|
|
822
|
+
class: cascaderBaseClasses,
|
|
823
|
+
"data-testid": "cascader"
|
|
824
|
+
},
|
|
825
|
+
[trigger, iconRow, renderVueOverlayTeleport(dropdownContent, overlay.target.value)]
|
|
826
|
+
);
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
});
|
|
830
|
+
var Cascader_default = Cascader;
|
|
831
|
+
|
|
832
|
+
export {
|
|
833
|
+
Cascader,
|
|
834
|
+
Cascader_default
|
|
835
|
+
};
|