@veltra/desktop 1.7.6 → 1.7.8
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/dist/components/cascade/use-check.js +5 -2
- package/dist/components/cascade/use-check.js.map +1 -1
- package/dist/components/cascade/use-select.js +5 -1
- package/dist/components/cascade/use-select.js.map +1 -1
- package/dist/components/code-editor/langs/bash/index.js +1 -1
- package/dist/components/code-editor/langs/powershell/index.js +1 -1
- package/dist/components/date-range-picker/date-range-picker.js +46 -12
- package/dist/components/date-range-picker/date-range-picker.js.map +1 -1
- package/dist/components/table/style2.css +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/node_modules/.bun/{@codemirror_legacy-modes@6.5.3 → @codemirror_legacy-modes@6.5.4}/node_modules/@codemirror/legacy-modes/mode/powershell.js +1 -1
- package/dist/node_modules/.bun/{@codemirror_legacy-modes@6.5.3 → @codemirror_legacy-modes@6.5.4}/node_modules/@codemirror/legacy-modes/mode/powershell.js.map +1 -1
- package/dist/node_modules/.bun/{@codemirror_legacy-modes@6.5.3 → @codemirror_legacy-modes@6.5.4}/node_modules/@codemirror/legacy-modes/mode/shell.js +1 -1
- package/dist/node_modules/.bun/{@codemirror_legacy-modes@6.5.3 → @codemirror_legacy-modes@6.5.4}/node_modules/@codemirror/legacy-modes/mode/shell.js.map +1 -1
- package/dist/types/cascade.d.ts +6 -2
- package/dist/types/date-range-picker.d.ts +13 -3
- package/dist/types/index.d.ts +2 -2
- package/package.json +14 -14
- package/src/components/cascade/__test__/cascade.test.ts +103 -0
- package/src/components/cascade/use-check.ts +5 -2
- package/src/components/cascade/use-select.ts +2 -1
- package/src/components/date-range-picker/__test__/date-range-picker.test.ts +278 -0
- package/src/components/date-range-picker/date-range-picker.vue +61 -17
- package/src/components/table/style.scss +1 -1
- package/src/types/cascade.ts +10 -2
- package/src/types/date-range-picker.ts +14 -2
package/dist/types/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { TreeEmit, TreeExposed, TreeNode, TreeNodeProps, TreeProps, _TreeExposed
|
|
|
5
5
|
import { TreeSelectEmits, TreeSelectExposed, TreeSelectProps, _TreeSelectExposed } from "./tree-select.js";
|
|
6
6
|
import { LayoutEmits, LayoutExposed, LayoutProps, _LayoutExposed } from "./layout.js";
|
|
7
7
|
import { TagEmits, TagExposed, TagProps } from "./tag.js";
|
|
8
|
-
import { DateRangePickerEmits, DateRangePickerExposed, DateRangePickerProps, _DateRangePickerExposed } from "./date-range-picker.js";
|
|
8
|
+
import { DateRangePickerDataType, DateRangePickerEmits, DateRangePickerExposed, DateRangePickerProps, DateRangeValue, _DateRangePickerExposed } from "./date-range-picker.js";
|
|
9
9
|
import { RadioGroupEmits, RadioGroupExposed, RadioGroupProps, _RadioGroupExposed } from "./radio-group.js";
|
|
10
10
|
import { ScrollEmits, ScrollExposed, ScrollPosition, ScrollProps, _ScrollExposed } from "./scroll.js";
|
|
11
11
|
import { WatermarkEmits, WatermarkExposed, WatermarkProps, _WatermarkExposed } from "./watermark.js";
|
|
@@ -81,4 +81,4 @@ import { FileViewerEmits, FileViewerExposed, FileViewerItem, FileViewerKind, Fil
|
|
|
81
81
|
import { CollapseEmits, CollapseItemEmits, CollapseItemProps, CollapseModelValue, CollapseProps, CollapseValue } from "./collapse.js";
|
|
82
82
|
import { SegmentEmits, SegmentExposed, SegmentItem, SegmentProps, _SegmentExposed } from "./segment.js";
|
|
83
83
|
export type * from "@veltra/utils";
|
|
84
|
-
export { ActionEmits, ActionExposed, ActionGroupExposed, ActionGroupProps, ActionProps, AnimationEmits, AnimationExposed, AnimationProps, AutoCompleteEmits, AutoCompleteExposed, AutoCompleteProps, BadgeEmits, BadgeExposed, BadgeProps, BarType, BatchEditColumn, BatchEditEmits, BatchEditExposed, BatchEditFeature, BatchEditFormStatus, BatchEditProps, BatchEditSlots, BatchEditStates, BreadcrumbEmits, BreadcrumbExposed, BreadcrumbItem, BreadcrumbProps, BreadcrumbSlotScope, BreakCols, Breakpoint, ButtonEmits, ButtonExposed, ButtonProps, ButtonType, CalendarDay, CalendarEmits, CalendarExposed, CalendarMonth, CalendarProps, CalendarYear, CardActionProps, CardContentProps, CardCoverProps, CardEmits, CardExposed, CardProps, CascadeEmits, CascadeExposed, CascadeNode, CascadeProps, CheckTagEmits, CheckTagExposed, CheckTagProps, CheckboxButtonEmits, CheckboxButtonProps, CheckboxEmits, CheckboxExposed, CheckboxGroupEmits, CheckboxGroupExposed, CheckboxGroupProps, CheckboxProps, CodeEditorEmits, CodeEditorExposed, CodeEditorLang, CodeEditorProps, CollapseEmits, CollapseItemEmits, CollapseItemProps, CollapseModelValue, CollapseProps, CollapseValue, ConditionConnector, ConditionEditorEmits, ConditionEditorExposed, ConditionEditorProps, ConditionExpression, ConditionField, ConditionGroup, ConditionLeaf, ConditionNode, ConditionValue, ContextmenuEmits, ContextmenuExposed, ContextmenuItem, ContextmenuProps, CssTransitionEmits, CssTransitionExposed, CssTransitionProps, DatePanelEmits, DatePanelProps, DatePickerDataType, DatePickerEmits, DatePickerExposed, DatePickerProps, DateRangePickerEmits, DateRangePickerExposed, DateRangePickerProps, DialogEmits, DialogExposed, DialogProps, DialogTransition, DrawerDirection, DrawerEmits, DrawerExposed, DrawerMode, DrawerProps, DropdownEmits, DropdownExposed, DropdownProps, DualNavEmits, DualNavExposed, DualNavProps, DualNavRailVariant, DualNavRootItem, EmptyEmits, EmptyExposed, EmptyProps, ExpressionEditorEmits, ExpressionEditorExposed, ExpressionEditorProps, ExpressionSelectableLevels, FileViewerEmits, FileViewerExposed, FileViewerItem, FileViewerKind, FileViewerProps, FloatButtonEmits, FloatButtonExposed, FloatButtonItem, FloatButtonProps, FormEmits, FormExposed, FormItemEmits, FormItemExposed, FormItemProps, FormProps, GanttChartEmits, GanttChartExposed, GanttChartProps, GridEmits, GridExposed, GridInputEmits, GridInputExposed, GridInputProps, GridItemProps, GridProps, GroupInputEmits, GroupInputExposed, GroupInputProps, GroupNavEmits, GroupNavGroup, GroupNavProps, IconEmits, IconExposed, IconProps, InputEmits, InputExposed, InputProps, LayoutEmits, LayoutExposed, LayoutProps, ListEmits, ListExposed, ListProps, LoadingEmits, LoadingExposed, LoadingProps, LoadingType, Message, MessageConfirm, MessageConfirmAction, MessageConfirmEmits, MessageConfirmExposed, MessageConfirmInstance, MessageConfirmOptions, MessageConfirmProps, MessageEmits, MessageExposed, MessageInstance, MessageOptions, MessageProps, MessageType, MultiAutoCompleteEmits, MultiAutoCompleteExposed, MultiAutoCompleteProps, MultiSelectEmits, MultiSelectExposed, MultiSelectProps, MultiTreeSelectEmits, MultiTreeSelectExposed, MultiTreeSelectProps, NavEmits, NavExposed, NavItem, NavProps, NodeRenderExposed, NodeRenderProps, Notification, NotificationEmits, NotificationExposed, NotificationInstance, NotificationOptions, NotificationPosition, NotificationProps, NumberEmits, NumberExposed, NumberInputEmits, NumberInputExposed, NumberInputProps, NumberProps, NumberRangeInputEmits, NumberRangeInputExposed, NumberRangeInputProps, NumberRangeTuple, PaginatorEmits, PaginatorExposed, PaginatorProps, PaletteColorType, PaletteEmits, PaletteExposed, PaletteHSV, PaletteProps, PaletteRGB, PanelItem, PanelType, PasswordInputEmits, PasswordInputExposed, PasswordInputProps, PopConfirmEmits, PopConfirmExposed, PopConfirmProps, PopEmits, PopExposed, PopProps, ProgressEmits, ProgressExposed, ProgressNodesEmits, ProgressNodesExposed, ProgressNodesProps, ProgressProps, QuickBatchEditEmits, QuickBatchEditExposed, QuickBatchEditProps, RadioEmits, RadioExposed, RadioGroupEmits, RadioGroupExposed, RadioGroupProps, RadioProps, RichTextEditorEmits, RichTextEditorExposed, RichTextEditorProps, RichTextFormat, ScrollEmits, ScrollExposed, ScrollPosition, ScrollProps, SegmentEmits, SegmentExposed, SegmentItem, SegmentProps, SelectEmits, SelectExposed, SelectProps, SliderEmits, SliderExposed, SliderProps, StepsEmits, StepsExposed, StepsProps, StepsSlotScope, SwitchEmits, SwitchExposed, SwitchProps, TabItem, TableColumn, TableColumnAlign, TableColumnNode, TableColumnRenderContext, TableColumnSlotsScope, TableEditorEmits, TableEditorExposed, TableEditorProps, TableEmits, TableExposed, TableProps, TableRow, TableRowSlotsScope, TableSummaryContext, TabsEmits, TabsExposed, TabsHorizontalEmits, TabsHorizontalExposed, TabsHorizontalProps, TabsProps, TabsVerticalEmits, TabsVerticalExposed, TabsVerticalProps, TagEmits, TagExposed, TagProps, TextEditorEmits, TextEditorExposed, TextEditorProps, TextEmits, TextExposed, TextProps, TextareaEmits, TextareaExposed, TextareaProps, ThemeExposed, ThemeProps, TipAlign, TipDirection, TipEmits, TipExposed, TipProps, ToolbarItem, TreeEmit, TreeExposed, TreeNode, TreeNodeProps, TreeProps, TreeSelectEmits, TreeSelectExposed, TreeSelectProps, UploaderEmits, UploaderExposed, UploaderProps, VariableItem, WatermarkEmits, WatermarkExposed, WatermarkProps, _ActionExposed, _ActionGroupExposed, _AnimationExposed, _AutoCompleteExposed, _BadgeExposed, _BatchEditExposed, _BreadcrumbExposed, _ButtonExposed, _CalendarExposed, _CardExposed, _CascadeExposed, _CheckTagExposed, _CodeEditorExposed, _ConditionEditorExposed, _ContextmenuExposed, _CssTransitionExposed, _DatePickerExposed, _DateRangePickerExposed, _DialogExposed, _DrawerExposed, _DropdownExposed, _DualNavExposed, _EmptyExposed, _ExpressionEditorExposed, _FileViewerExposed, _FloatButtonExposed, _FormExposed, _GanttChartExposed, _GridExposed, _GridInputExposed, _GroupInputExposed, _InputExposed, _LayoutExposed, _ListExposed, _LoadingExposed, _MessageConfirmExposed, _MessageExposed, _MultiAutoCompleteExposed, _MultiSelectExposed, _MultiTreeSelectExposed, _NavExposed, _NotificationExposed, _PaginatorExposed, _PaletteExposed, _PasswordInputExposed, _PopConfirmExposed, _PopExposed, _ProgressExposed, _ProgressNodesExposed, _QuickBatchEditExposed, _RadioExposed, _RadioGroupExposed, _RichTextEditorExposed, _ScrollExposed, _SegmentExposed, _SelectExposed, _SliderExposed, _StepsExposed, _SwitchExposed, _TableEditorExposed, _TableExposed, _TabsExposed, _TabsHorizontalExposed, _TabsVerticalExposed, _TextEditorExposed, _TextExposed, _TextareaExposed, _ThemeExposed, _TipExposed, _TreeExposed, _TreeSelectExposed, _UploaderExposed, _WatermarkExposed };
|
|
84
|
+
export { ActionEmits, ActionExposed, ActionGroupExposed, ActionGroupProps, ActionProps, AnimationEmits, AnimationExposed, AnimationProps, AutoCompleteEmits, AutoCompleteExposed, AutoCompleteProps, BadgeEmits, BadgeExposed, BadgeProps, BarType, BatchEditColumn, BatchEditEmits, BatchEditExposed, BatchEditFeature, BatchEditFormStatus, BatchEditProps, BatchEditSlots, BatchEditStates, BreadcrumbEmits, BreadcrumbExposed, BreadcrumbItem, BreadcrumbProps, BreadcrumbSlotScope, BreakCols, Breakpoint, ButtonEmits, ButtonExposed, ButtonProps, ButtonType, CalendarDay, CalendarEmits, CalendarExposed, CalendarMonth, CalendarProps, CalendarYear, CardActionProps, CardContentProps, CardCoverProps, CardEmits, CardExposed, CardProps, CascadeEmits, CascadeExposed, CascadeNode, CascadeProps, CheckTagEmits, CheckTagExposed, CheckTagProps, CheckboxButtonEmits, CheckboxButtonProps, CheckboxEmits, CheckboxExposed, CheckboxGroupEmits, CheckboxGroupExposed, CheckboxGroupProps, CheckboxProps, CodeEditorEmits, CodeEditorExposed, CodeEditorLang, CodeEditorProps, CollapseEmits, CollapseItemEmits, CollapseItemProps, CollapseModelValue, CollapseProps, CollapseValue, ConditionConnector, ConditionEditorEmits, ConditionEditorExposed, ConditionEditorProps, ConditionExpression, ConditionField, ConditionGroup, ConditionLeaf, ConditionNode, ConditionValue, ContextmenuEmits, ContextmenuExposed, ContextmenuItem, ContextmenuProps, CssTransitionEmits, CssTransitionExposed, CssTransitionProps, DatePanelEmits, DatePanelProps, DatePickerDataType, DatePickerEmits, DatePickerExposed, DatePickerProps, DateRangePickerDataType, DateRangePickerEmits, DateRangePickerExposed, DateRangePickerProps, DateRangeValue, DialogEmits, DialogExposed, DialogProps, DialogTransition, DrawerDirection, DrawerEmits, DrawerExposed, DrawerMode, DrawerProps, DropdownEmits, DropdownExposed, DropdownProps, DualNavEmits, DualNavExposed, DualNavProps, DualNavRailVariant, DualNavRootItem, EmptyEmits, EmptyExposed, EmptyProps, ExpressionEditorEmits, ExpressionEditorExposed, ExpressionEditorProps, ExpressionSelectableLevels, FileViewerEmits, FileViewerExposed, FileViewerItem, FileViewerKind, FileViewerProps, FloatButtonEmits, FloatButtonExposed, FloatButtonItem, FloatButtonProps, FormEmits, FormExposed, FormItemEmits, FormItemExposed, FormItemProps, FormProps, GanttChartEmits, GanttChartExposed, GanttChartProps, GridEmits, GridExposed, GridInputEmits, GridInputExposed, GridInputProps, GridItemProps, GridProps, GroupInputEmits, GroupInputExposed, GroupInputProps, GroupNavEmits, GroupNavGroup, GroupNavProps, IconEmits, IconExposed, IconProps, InputEmits, InputExposed, InputProps, LayoutEmits, LayoutExposed, LayoutProps, ListEmits, ListExposed, ListProps, LoadingEmits, LoadingExposed, LoadingProps, LoadingType, Message, MessageConfirm, MessageConfirmAction, MessageConfirmEmits, MessageConfirmExposed, MessageConfirmInstance, MessageConfirmOptions, MessageConfirmProps, MessageEmits, MessageExposed, MessageInstance, MessageOptions, MessageProps, MessageType, MultiAutoCompleteEmits, MultiAutoCompleteExposed, MultiAutoCompleteProps, MultiSelectEmits, MultiSelectExposed, MultiSelectProps, MultiTreeSelectEmits, MultiTreeSelectExposed, MultiTreeSelectProps, NavEmits, NavExposed, NavItem, NavProps, NodeRenderExposed, NodeRenderProps, Notification, NotificationEmits, NotificationExposed, NotificationInstance, NotificationOptions, NotificationPosition, NotificationProps, NumberEmits, NumberExposed, NumberInputEmits, NumberInputExposed, NumberInputProps, NumberProps, NumberRangeInputEmits, NumberRangeInputExposed, NumberRangeInputProps, NumberRangeTuple, PaginatorEmits, PaginatorExposed, PaginatorProps, PaletteColorType, PaletteEmits, PaletteExposed, PaletteHSV, PaletteProps, PaletteRGB, PanelItem, PanelType, PasswordInputEmits, PasswordInputExposed, PasswordInputProps, PopConfirmEmits, PopConfirmExposed, PopConfirmProps, PopEmits, PopExposed, PopProps, ProgressEmits, ProgressExposed, ProgressNodesEmits, ProgressNodesExposed, ProgressNodesProps, ProgressProps, QuickBatchEditEmits, QuickBatchEditExposed, QuickBatchEditProps, RadioEmits, RadioExposed, RadioGroupEmits, RadioGroupExposed, RadioGroupProps, RadioProps, RichTextEditorEmits, RichTextEditorExposed, RichTextEditorProps, RichTextFormat, ScrollEmits, ScrollExposed, ScrollPosition, ScrollProps, SegmentEmits, SegmentExposed, SegmentItem, SegmentProps, SelectEmits, SelectExposed, SelectProps, SliderEmits, SliderExposed, SliderProps, StepsEmits, StepsExposed, StepsProps, StepsSlotScope, SwitchEmits, SwitchExposed, SwitchProps, TabItem, TableColumn, TableColumnAlign, TableColumnNode, TableColumnRenderContext, TableColumnSlotsScope, TableEditorEmits, TableEditorExposed, TableEditorProps, TableEmits, TableExposed, TableProps, TableRow, TableRowSlotsScope, TableSummaryContext, TabsEmits, TabsExposed, TabsHorizontalEmits, TabsHorizontalExposed, TabsHorizontalProps, TabsProps, TabsVerticalEmits, TabsVerticalExposed, TabsVerticalProps, TagEmits, TagExposed, TagProps, TextEditorEmits, TextEditorExposed, TextEditorProps, TextEmits, TextExposed, TextProps, TextareaEmits, TextareaExposed, TextareaProps, ThemeExposed, ThemeProps, TipAlign, TipDirection, TipEmits, TipExposed, TipProps, ToolbarItem, TreeEmit, TreeExposed, TreeNode, TreeNodeProps, TreeProps, TreeSelectEmits, TreeSelectExposed, TreeSelectProps, UploaderEmits, UploaderExposed, UploaderProps, VariableItem, WatermarkEmits, WatermarkExposed, WatermarkProps, _ActionExposed, _ActionGroupExposed, _AnimationExposed, _AutoCompleteExposed, _BadgeExposed, _BatchEditExposed, _BreadcrumbExposed, _ButtonExposed, _CalendarExposed, _CardExposed, _CascadeExposed, _CheckTagExposed, _CodeEditorExposed, _ConditionEditorExposed, _ContextmenuExposed, _CssTransitionExposed, _DatePickerExposed, _DateRangePickerExposed, _DialogExposed, _DrawerExposed, _DropdownExposed, _DualNavExposed, _EmptyExposed, _ExpressionEditorExposed, _FileViewerExposed, _FloatButtonExposed, _FormExposed, _GanttChartExposed, _GridExposed, _GridInputExposed, _GroupInputExposed, _InputExposed, _LayoutExposed, _ListExposed, _LoadingExposed, _MessageConfirmExposed, _MessageExposed, _MultiAutoCompleteExposed, _MultiSelectExposed, _MultiTreeSelectExposed, _NavExposed, _NotificationExposed, _PaginatorExposed, _PaletteExposed, _PasswordInputExposed, _PopConfirmExposed, _PopExposed, _ProgressExposed, _ProgressNodesExposed, _QuickBatchEditExposed, _RadioExposed, _RadioGroupExposed, _RichTextEditorExposed, _ScrollExposed, _SegmentExposed, _SelectExposed, _SliderExposed, _StepsExposed, _SwitchExposed, _TableEditorExposed, _TableExposed, _TabsExposed, _TabsHorizontalExposed, _TabsVerticalExposed, _TextEditorExposed, _TextExposed, _TextareaExposed, _ThemeExposed, _TipExposed, _TreeExposed, _TreeSelectExposed, _UploaderExposed, _WatermarkExposed };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veltra/desktop",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.8",
|
|
4
4
|
"homepage": "https://github.com/cabinet-fe/ultra-ui#readme",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/cabinet-fe/ultra-ui/issues"
|
|
@@ -51,15 +51,15 @@
|
|
|
51
51
|
"@embedpdf/plugin-scroll": "^2.15.0",
|
|
52
52
|
"@embedpdf/plugin-viewport": "^2.15.0",
|
|
53
53
|
"@embedpdf/plugin-zoom": "^2.15.0",
|
|
54
|
-
"@lexical/history": "^0.
|
|
55
|
-
"@lexical/html": "^0.
|
|
56
|
-
"@lexical/link": "^0.
|
|
57
|
-
"@lexical/list": "^0.
|
|
58
|
-
"@lexical/rich-text": "^0.
|
|
59
|
-
"@lexical/selection": "^0.
|
|
60
|
-
"@lexical/utils": "^0.
|
|
54
|
+
"@lexical/history": "^0.50.0",
|
|
55
|
+
"@lexical/html": "^0.50.0",
|
|
56
|
+
"@lexical/link": "^0.50.0",
|
|
57
|
+
"@lexical/list": "^0.50.0",
|
|
58
|
+
"@lexical/rich-text": "^0.50.0",
|
|
59
|
+
"@lexical/selection": "^0.50.0",
|
|
60
|
+
"@lexical/utils": "^0.50.0",
|
|
61
61
|
"docx-preview": "^0.4.0",
|
|
62
|
-
"lexical": "^0.
|
|
62
|
+
"lexical": "^0.50.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@codemirror/autocomplete": "6.20.3",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"@codemirror/lang-markdown": "6.5.2",
|
|
71
71
|
"@codemirror/lang-sql": "6.10.0",
|
|
72
72
|
"@codemirror/language": "6.12.4",
|
|
73
|
-
"@codemirror/legacy-modes": "6.5.
|
|
73
|
+
"@codemirror/legacy-modes": "6.5.4",
|
|
74
74
|
"@codemirror/lint": "6.9.7",
|
|
75
75
|
"@codemirror/search": "6.7.1",
|
|
76
76
|
"@codemirror/state": "6.7.1",
|
|
@@ -80,12 +80,12 @@
|
|
|
80
80
|
"peerDependencies": {
|
|
81
81
|
"@cat-kit/core": ">=1.2.1",
|
|
82
82
|
"@cat-kit/fe": ">=1.2.1",
|
|
83
|
-
"@veltra/compositions": "^1.7.
|
|
84
|
-
"@veltra/directives": "^1.7.
|
|
83
|
+
"@veltra/compositions": "^1.7.8",
|
|
84
|
+
"@veltra/directives": "^1.7.8",
|
|
85
85
|
"@veltra/icons": "^1.5.0",
|
|
86
86
|
"@veltra/sheet-core": "^2.5.4",
|
|
87
|
-
"@veltra/styles": "^1.7.
|
|
88
|
-
"@veltra/utils": "^1.7.
|
|
87
|
+
"@veltra/styles": "^1.7.8",
|
|
88
|
+
"@veltra/utils": "^1.7.8",
|
|
89
89
|
"vue": ">=3.5.42"
|
|
90
90
|
},
|
|
91
91
|
"peerDependenciesMeta": {
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { createApp, h, nextTick, ref } from 'vue'
|
|
3
|
+
|
|
4
|
+
import UCascade from '../cascade.vue'
|
|
5
|
+
|
|
6
|
+
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))
|
|
7
|
+
|
|
8
|
+
const cascadeData = [
|
|
9
|
+
{
|
|
10
|
+
label: '浙江省',
|
|
11
|
+
value: 'zhejiang',
|
|
12
|
+
children: [
|
|
13
|
+
{
|
|
14
|
+
label: '杭州市',
|
|
15
|
+
value: 'hangzhou',
|
|
16
|
+
children: [
|
|
17
|
+
{ label: '西湖区', value: 'xihu' },
|
|
18
|
+
{ label: '余杭区', value: 'yuhang' }
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
label: '江苏省',
|
|
25
|
+
value: 'jiangsu',
|
|
26
|
+
children: [
|
|
27
|
+
{ label: '南京市', value: 'nanjing', children: [{ label: '玄武区', value: 'xuanwu' }] }
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
function queryCascadeItems() {
|
|
33
|
+
return [...document.body.querySelectorAll<HTMLElement>('.u-cascade-panel-item__option')]
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function openDropdown(host: HTMLElement) {
|
|
37
|
+
const trigger = (host.querySelector('.u-cascade') ||
|
|
38
|
+
host.querySelector('.u-dropdown') ||
|
|
39
|
+
host.firstElementChild) as HTMLElement
|
|
40
|
+
trigger.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true }))
|
|
41
|
+
for (let attempt = 0; attempt < 20; attempt++) {
|
|
42
|
+
await nextTick()
|
|
43
|
+
await sleep(25)
|
|
44
|
+
if (queryCascadeItems().length > 0) return
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function clickItemByLabel(label: string) {
|
|
49
|
+
const item = queryCascadeItems().find((el) => el.textContent?.includes(label))
|
|
50
|
+
expect(item, `cascade item "${label}" not found`).toBeTruthy()
|
|
51
|
+
item!.dispatchEvent(new MouseEvent('click', { bubbles: true }))
|
|
52
|
+
await nextTick()
|
|
53
|
+
await sleep(30)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
describe('UCascade change event fullLabel', () => {
|
|
57
|
+
it('should emit fullLabel in change event for single select', async () => {
|
|
58
|
+
const host = document.createElement('div')
|
|
59
|
+
document.body.appendChild(host)
|
|
60
|
+
|
|
61
|
+
const model = ref<string | undefined>()
|
|
62
|
+
let changeResult: { item: any; fullLabel?: string } | undefined
|
|
63
|
+
|
|
64
|
+
const app = createApp({
|
|
65
|
+
render() {
|
|
66
|
+
return h(UCascade, {
|
|
67
|
+
data: cascadeData,
|
|
68
|
+
modelValue: model.value,
|
|
69
|
+
'onUpdate:modelValue': (val: string) => {
|
|
70
|
+
model.value = val
|
|
71
|
+
},
|
|
72
|
+
onChange: (item: any, fullLabel?: string) => {
|
|
73
|
+
changeResult = { item, fullLabel }
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
app.mount(host)
|
|
80
|
+
await nextTick()
|
|
81
|
+
|
|
82
|
+
await openDropdown(host)
|
|
83
|
+
|
|
84
|
+
// 点击第一列 "浙江省"
|
|
85
|
+
await clickItemByLabel('浙江省')
|
|
86
|
+
|
|
87
|
+
// 点击第二列 "杭州市"
|
|
88
|
+
await clickItemByLabel('杭州市')
|
|
89
|
+
|
|
90
|
+
// 点击第三列 "西湖区"
|
|
91
|
+
await clickItemByLabel('西湖区')
|
|
92
|
+
|
|
93
|
+
expect(changeResult).toBeDefined()
|
|
94
|
+
expect(changeResult?.fullLabel).toBe('浙江省/杭州市/西湖区')
|
|
95
|
+
expect(changeResult?.item).toBeDefined()
|
|
96
|
+
expect(changeResult?.item.value).toBe('xihu')
|
|
97
|
+
expect(changeResult?.item.label).toBe('西湖区')
|
|
98
|
+
expect(changeResult?.item.fullLabel).toBe('浙江省/杭州市/西湖区')
|
|
99
|
+
|
|
100
|
+
app.unmount()
|
|
101
|
+
host.remove()
|
|
102
|
+
})
|
|
103
|
+
})
|
|
@@ -68,10 +68,13 @@ export function useCheck(options: CheckOptions): UseCheckReturned {
|
|
|
68
68
|
const checkedArr = Array.from(checkedSet.value)
|
|
69
69
|
const targetValues = checkedArr.map((item) => item.value)
|
|
70
70
|
const targetLabels = checkedArr.map((item) => item.label)
|
|
71
|
-
const targetItems = checkedArr.map((item) =>
|
|
71
|
+
const targetItems = checkedArr.map((item) => {
|
|
72
|
+
const data = item.data as Record<string, any>
|
|
73
|
+
return data ? Object.assign({}, data, { fullLabel: item.label }) : data
|
|
74
|
+
})
|
|
72
75
|
emit('update:modelValue', targetValues)
|
|
73
76
|
emit('update:label', targetLabels.length ? targetLabels : undefined)
|
|
74
|
-
emit('change', targetItems)
|
|
77
|
+
emit('change', targetItems, targetLabels.length ? targetLabels : undefined)
|
|
75
78
|
}
|
|
76
79
|
|
|
77
80
|
const restTag = computed(() => {
|
|
@@ -115,10 +115,11 @@ export function useSelect(options: SelectOptions): UseSelectReturned {
|
|
|
115
115
|
: leafLabel
|
|
116
116
|
|
|
117
117
|
const leafNode = leafKey ? dataMap.value.get(leafKey) : undefined
|
|
118
|
+
const changeItem = leafNode?.data ? { ...leafNode.data, fullLabel: targetLabel } : undefined
|
|
118
119
|
|
|
119
120
|
emit('update:modelValue', targetValue)
|
|
120
121
|
emit('update:label', targetLabel)
|
|
121
|
-
emit('change',
|
|
122
|
+
emit('change', changeItem, targetLabel)
|
|
122
123
|
}
|
|
123
124
|
|
|
124
125
|
/**
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import { date } from '@cat-kit/core'
|
|
2
|
+
import { describe, expect, it } from 'vitest'
|
|
3
|
+
import { createApp, h, nextTick, ref } from 'vue'
|
|
4
|
+
|
|
5
|
+
import UDateRangePicker from '../date-range-picker.vue'
|
|
6
|
+
|
|
7
|
+
function mountDateRangePicker(
|
|
8
|
+
props: Record<string, unknown> = {},
|
|
9
|
+
emits: Record<string, Function> = {}
|
|
10
|
+
) {
|
|
11
|
+
const host = document.createElement('div')
|
|
12
|
+
document.body.appendChild(host)
|
|
13
|
+
|
|
14
|
+
const model = ref(props.modelValue)
|
|
15
|
+
const app = createApp({
|
|
16
|
+
render() {
|
|
17
|
+
return h(UDateRangePicker, {
|
|
18
|
+
...props,
|
|
19
|
+
modelValue: model.value,
|
|
20
|
+
'onUpdate:modelValue': (value: unknown) => {
|
|
21
|
+
model.value = value
|
|
22
|
+
emits['update:modelValue']?.(value)
|
|
23
|
+
},
|
|
24
|
+
onChange: (dates?: [Date, Date]) => {
|
|
25
|
+
emits.change?.(dates)
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
app.component('Transition', (_, { slots }) => slots.default?.())
|
|
32
|
+
|
|
33
|
+
app.mount(host)
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
host,
|
|
37
|
+
model,
|
|
38
|
+
app,
|
|
39
|
+
unmount() {
|
|
40
|
+
app.unmount()
|
|
41
|
+
host.remove()
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
describe('UDateRangePicker', () => {
|
|
47
|
+
it('defaults dataType to string and emits change with native Date tuple', async () => {
|
|
48
|
+
let changedDates: [Date, Date] | undefined
|
|
49
|
+
let updatedVal: unknown
|
|
50
|
+
|
|
51
|
+
const { host, unmount } = mountDateRangePicker(
|
|
52
|
+
{},
|
|
53
|
+
{
|
|
54
|
+
'update:modelValue': (val: unknown) => {
|
|
55
|
+
updatedVal = val
|
|
56
|
+
},
|
|
57
|
+
change: (d?: [Date, Date]) => {
|
|
58
|
+
changedDates = d
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
const inputEl = host.querySelector('input')
|
|
65
|
+
expect(inputEl).not.toBeNull()
|
|
66
|
+
inputEl?.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true }))
|
|
67
|
+
await nextTick()
|
|
68
|
+
await nextTick()
|
|
69
|
+
|
|
70
|
+
const cells = document.querySelectorAll<HTMLElement>('.u-date-panel__cell:not(.is-disabled)')
|
|
71
|
+
expect(cells.length).toBeGreaterThanOrEqual(20)
|
|
72
|
+
|
|
73
|
+
cells[10]!.click()
|
|
74
|
+
await nextTick()
|
|
75
|
+
cells[15]!.click()
|
|
76
|
+
await nextTick()
|
|
77
|
+
|
|
78
|
+
expect(Array.isArray(updatedVal)).toBe(true)
|
|
79
|
+
const range = updatedVal as string[]
|
|
80
|
+
expect(range.length).toBe(2)
|
|
81
|
+
expect(typeof range[0]).toBe('string')
|
|
82
|
+
expect(typeof range[1]).toBe('string')
|
|
83
|
+
expect(range[0]).toMatch(/^\d{4}-\d{2}-\d{2}$/)
|
|
84
|
+
expect(range[1]).toMatch(/^\d{4}-\d{2}-\d{2}$/)
|
|
85
|
+
|
|
86
|
+
expect(Array.isArray(changedDates)).toBe(true)
|
|
87
|
+
expect(changedDates![0] instanceof Date).toBe(true)
|
|
88
|
+
expect(changedDates![1] instanceof Date).toBe(true)
|
|
89
|
+
} finally {
|
|
90
|
+
unmount()
|
|
91
|
+
}
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
it('supports dataType="date" and emits native Date tuple for modelValue and change', async () => {
|
|
95
|
+
let changedDates: [Date, Date] | undefined
|
|
96
|
+
let updatedVal: unknown
|
|
97
|
+
|
|
98
|
+
const { host, unmount } = mountDateRangePicker(
|
|
99
|
+
{ dataType: 'date', valueFormat: 'yyyyMMdd' },
|
|
100
|
+
{
|
|
101
|
+
'update:modelValue': (val: unknown) => {
|
|
102
|
+
updatedVal = val
|
|
103
|
+
},
|
|
104
|
+
change: (d?: [Date, Date]) => {
|
|
105
|
+
changedDates = d
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
try {
|
|
111
|
+
const inputEl = host.querySelector('input')
|
|
112
|
+
inputEl?.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true }))
|
|
113
|
+
await nextTick()
|
|
114
|
+
await nextTick()
|
|
115
|
+
|
|
116
|
+
const cells = document.querySelectorAll<HTMLElement>('.u-date-panel__cell:not(.is-disabled)')
|
|
117
|
+
cells[10]!.click()
|
|
118
|
+
await nextTick()
|
|
119
|
+
cells[15]!.click()
|
|
120
|
+
await nextTick()
|
|
121
|
+
|
|
122
|
+
expect(Array.isArray(updatedVal)).toBe(true)
|
|
123
|
+
const range = updatedVal as unknown[]
|
|
124
|
+
expect(range[0] instanceof Date).toBe(true)
|
|
125
|
+
expect(range[1] instanceof Date).toBe(true)
|
|
126
|
+
|
|
127
|
+
expect(Array.isArray(changedDates)).toBe(true)
|
|
128
|
+
expect(changedDates![0] instanceof Date).toBe(true)
|
|
129
|
+
expect(changedDates![1] instanceof Date).toBe(true)
|
|
130
|
+
} finally {
|
|
131
|
+
unmount()
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
it('supports dataType="timestamp" and emits timestamp tuple for modelValue and native Date tuple for change', async () => {
|
|
136
|
+
let changedDates: [Date, Date] | undefined
|
|
137
|
+
let updatedVal: unknown
|
|
138
|
+
|
|
139
|
+
const { host, unmount } = mountDateRangePicker(
|
|
140
|
+
{ dataType: 'timestamp', valueFormat: 'yyyyMMdd' },
|
|
141
|
+
{
|
|
142
|
+
'update:modelValue': (val: unknown) => {
|
|
143
|
+
updatedVal = val
|
|
144
|
+
},
|
|
145
|
+
change: (d?: [Date, Date]) => {
|
|
146
|
+
changedDates = d
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
try {
|
|
152
|
+
const inputEl = host.querySelector('input')
|
|
153
|
+
inputEl?.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true }))
|
|
154
|
+
await nextTick()
|
|
155
|
+
await nextTick()
|
|
156
|
+
|
|
157
|
+
const cells = document.querySelectorAll<HTMLElement>('.u-date-panel__cell:not(.is-disabled)')
|
|
158
|
+
cells[10]!.click()
|
|
159
|
+
await nextTick()
|
|
160
|
+
cells[15]!.click()
|
|
161
|
+
await nextTick()
|
|
162
|
+
|
|
163
|
+
expect(Array.isArray(updatedVal)).toBe(true)
|
|
164
|
+
const range = updatedVal as number[]
|
|
165
|
+
expect(typeof range[0]).toBe('number')
|
|
166
|
+
expect(typeof range[1]).toBe('number')
|
|
167
|
+
expect(range[0]).toBeGreaterThan(0)
|
|
168
|
+
expect(range[1]).toBeGreaterThan(0)
|
|
169
|
+
|
|
170
|
+
expect(Array.isArray(changedDates)).toBe(true)
|
|
171
|
+
expect(changedDates![0] instanceof Date).toBe(true)
|
|
172
|
+
expect(changedDates![1] instanceof Date).toBe(true)
|
|
173
|
+
} finally {
|
|
174
|
+
unmount()
|
|
175
|
+
}
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
it('applies valueFormat when dataType="string"', async () => {
|
|
179
|
+
let changedDates: [Date, Date] | undefined
|
|
180
|
+
let updatedVal: unknown
|
|
181
|
+
|
|
182
|
+
const { host, unmount } = mountDateRangePicker(
|
|
183
|
+
{ dataType: 'string', valueFormat: 'yyyy/MM/dd' },
|
|
184
|
+
{
|
|
185
|
+
'update:modelValue': (val: unknown) => {
|
|
186
|
+
updatedVal = val
|
|
187
|
+
},
|
|
188
|
+
change: (d?: [Date, Date]) => {
|
|
189
|
+
changedDates = d
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
try {
|
|
195
|
+
const inputEl = host.querySelector('input')
|
|
196
|
+
inputEl?.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true }))
|
|
197
|
+
await nextTick()
|
|
198
|
+
await nextTick()
|
|
199
|
+
|
|
200
|
+
const cells = document.querySelectorAll<HTMLElement>('.u-date-panel__cell:not(.is-disabled)')
|
|
201
|
+
cells[10]!.click()
|
|
202
|
+
await nextTick()
|
|
203
|
+
cells[15]!.click()
|
|
204
|
+
await nextTick()
|
|
205
|
+
|
|
206
|
+
expect(Array.isArray(updatedVal)).toBe(true)
|
|
207
|
+
const range = updatedVal as string[]
|
|
208
|
+
expect(range[0]).toMatch(/^\d{4}\/\d{2}\/\d{2}$/)
|
|
209
|
+
expect(range[1]).toMatch(/^\d{4}\/\d{2}\/\d{2}$/)
|
|
210
|
+
expect(changedDates![0] instanceof Date).toBe(true)
|
|
211
|
+
expect(changedDates![1] instanceof Date).toBe(true)
|
|
212
|
+
} finally {
|
|
213
|
+
unmount()
|
|
214
|
+
}
|
|
215
|
+
})
|
|
216
|
+
|
|
217
|
+
it('emits undefined for modelValue and change when cleared', async () => {
|
|
218
|
+
let changedDates: [Date, Date] | undefined = [new Date(), new Date()]
|
|
219
|
+
let updatedVal: unknown = ['2024-05-01', '2024-05-10']
|
|
220
|
+
|
|
221
|
+
const { host, unmount } = mountDateRangePicker(
|
|
222
|
+
{ modelValue: ['2024-05-01', '2024-05-10'], clearable: true },
|
|
223
|
+
{
|
|
224
|
+
'update:modelValue': (val: unknown) => {
|
|
225
|
+
updatedVal = val
|
|
226
|
+
},
|
|
227
|
+
change: (d?: [Date, Date]) => {
|
|
228
|
+
changedDates = d
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
)
|
|
232
|
+
|
|
233
|
+
try {
|
|
234
|
+
const dropdown = host.firstElementChild as HTMLElement
|
|
235
|
+
dropdown.dispatchEvent(new MouseEvent('mouseenter', { bubbles: true }))
|
|
236
|
+
await new Promise((r) => setTimeout(r, 50))
|
|
237
|
+
|
|
238
|
+
const clearBtn = host.querySelector('.u-date-range-picker__clear') as HTMLElement
|
|
239
|
+
expect(clearBtn).not.toBeNull()
|
|
240
|
+
clearBtn.click()
|
|
241
|
+
await nextTick()
|
|
242
|
+
|
|
243
|
+
expect(updatedVal).toBeUndefined()
|
|
244
|
+
expect(changedDates).toBeUndefined()
|
|
245
|
+
} finally {
|
|
246
|
+
unmount()
|
|
247
|
+
}
|
|
248
|
+
})
|
|
249
|
+
|
|
250
|
+
it('correctly parses modelValue of Date tuple, timestamp tuple, and custom formatted strings', async () => {
|
|
251
|
+
const dates: [Date, Date] = [new Date(2024, 4, 15), new Date(2024, 4, 20)]
|
|
252
|
+
const d1 = mountDateRangePicker({ modelValue: dates })
|
|
253
|
+
await nextTick()
|
|
254
|
+
const inputs1 = d1.host.querySelectorAll('input')
|
|
255
|
+
expect(inputs1[0]?.value).toBe('2024-05-15')
|
|
256
|
+
expect(inputs1[1]?.value).toBe('2024-05-20')
|
|
257
|
+
d1.unmount()
|
|
258
|
+
|
|
259
|
+
const ts1 = date('2024-06-20').timestamp
|
|
260
|
+
const ts2 = date('2024-06-25').timestamp
|
|
261
|
+
const d2 = mountDateRangePicker({ modelValue: [ts1, ts2] })
|
|
262
|
+
await nextTick()
|
|
263
|
+
const inputs2 = d2.host.querySelectorAll('input')
|
|
264
|
+
expect(inputs2[0]?.value).toBe('2024-06-20')
|
|
265
|
+
expect(inputs2[1]?.value).toBe('2024-06-25')
|
|
266
|
+
d2.unmount()
|
|
267
|
+
|
|
268
|
+
const d3 = mountDateRangePicker({
|
|
269
|
+
modelValue: ['20240725', '20240730'],
|
|
270
|
+
valueFormat: 'yyyyMMdd'
|
|
271
|
+
})
|
|
272
|
+
await nextTick()
|
|
273
|
+
const inputs3 = d3.host.querySelectorAll('input')
|
|
274
|
+
expect(inputs3[0]?.value).toBe('2024-07-25')
|
|
275
|
+
expect(inputs3[1]?.value).toBe('2024-07-30')
|
|
276
|
+
d3.unmount()
|
|
277
|
+
})
|
|
278
|
+
})
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
|
|
32
32
|
<Transition name="zoom-in" mode="out-in">
|
|
33
33
|
<UIcon
|
|
34
|
-
v-if="clearable && modelValue && hovered && !disabled"
|
|
34
|
+
v-if="clearable && (modelValue?.length || currentRangeDate) && hovered && !disabled"
|
|
35
35
|
:class="[cls.e('icon'), cls.e('clear')]"
|
|
36
36
|
title="清除"
|
|
37
37
|
@click.stop="handleClear"
|
|
@@ -62,14 +62,19 @@
|
|
|
62
62
|
</template>
|
|
63
63
|
|
|
64
64
|
<script lang="ts" setup>
|
|
65
|
-
import { date,
|
|
65
|
+
import { date, Dater } from '@cat-kit/core'
|
|
66
66
|
import { useFormFallbackProps, useUserAction } from '@veltra/compositions'
|
|
67
67
|
import { Calendar, Close } from '@veltra/icons/normal'
|
|
68
68
|
import { bem, FORM_EMPTY_CONTENT } from '@veltra/utils'
|
|
69
69
|
import { injectFormContext } from '@veltra/utils'
|
|
70
70
|
import { computed, shallowRef, watch } from 'vue'
|
|
71
71
|
|
|
72
|
-
import type {
|
|
72
|
+
import type {
|
|
73
|
+
DateRangePickerEmits,
|
|
74
|
+
DateRangePickerProps,
|
|
75
|
+
DateRangeValue,
|
|
76
|
+
DropdownExposed
|
|
77
|
+
} from '../../types'
|
|
73
78
|
import { UDatePanel } from '../date-panel'
|
|
74
79
|
import { UDropdown } from '../dropdown'
|
|
75
80
|
import { UIcon } from '../icon'
|
|
@@ -79,6 +84,7 @@ defineOptions({ name: 'UDateRangePicker', inheritAttrs: false })
|
|
|
79
84
|
const props = withDefaults(defineProps<DateRangePickerProps>(), {
|
|
80
85
|
placeholder: () => ['起始日期', '结束日期'],
|
|
81
86
|
type: 'date',
|
|
87
|
+
dataType: 'string',
|
|
82
88
|
disabled: undefined,
|
|
83
89
|
readonly: undefined,
|
|
84
90
|
clearable: true
|
|
@@ -113,14 +119,6 @@ const { userAction, isUserActive } = useUserAction()
|
|
|
113
119
|
|
|
114
120
|
const currentRangeDate = shallowRef<[Dater, Dater]>()
|
|
115
121
|
|
|
116
|
-
const displayedOfStart = computed(() => {
|
|
117
|
-
return props.modelValue?.[0]
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
const displayedOfEnd = computed(() => {
|
|
121
|
-
return props.modelValue?.[1]
|
|
122
|
-
})
|
|
123
|
-
|
|
124
122
|
const formatStr = computed(() => {
|
|
125
123
|
const { format, type } = props
|
|
126
124
|
if (format) return format
|
|
@@ -130,25 +128,70 @@ const formatStr = computed(() => {
|
|
|
130
128
|
return 'yyyy-MM-dd'
|
|
131
129
|
})
|
|
132
130
|
|
|
131
|
+
const displayedOfStart = computed(() => {
|
|
132
|
+
return currentRangeDate.value?.[0]?.format(formatStr.value) ?? ''
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
const displayedOfEnd = computed(() => {
|
|
136
|
+
return currentRangeDate.value?.[1]?.format(formatStr.value) ?? ''
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
function parseDateValue(val?: string | number | Date): Dater | undefined {
|
|
140
|
+
if (val == null || val === '') return undefined
|
|
141
|
+
if (val instanceof Date || typeof val === 'number') {
|
|
142
|
+
const d = date(val)
|
|
143
|
+
return isNaN(d.timestamp) ? undefined : d
|
|
144
|
+
}
|
|
145
|
+
if (typeof val === 'string') {
|
|
146
|
+
if (props.dataType === 'string' && props.valueFormat) {
|
|
147
|
+
const parsed = Dater.parse(val, props.valueFormat)
|
|
148
|
+
if (!isNaN(parsed.timestamp)) return parsed
|
|
149
|
+
}
|
|
150
|
+
const fallback = date(val)
|
|
151
|
+
return isNaN(fallback.timestamp) ? undefined : fallback
|
|
152
|
+
}
|
|
153
|
+
return undefined
|
|
154
|
+
}
|
|
155
|
+
|
|
133
156
|
watch(
|
|
134
157
|
() => props.modelValue,
|
|
135
158
|
(val) => {
|
|
136
159
|
if (isUserActive()) return
|
|
137
|
-
if (val
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
160
|
+
if (val && val.length === 2) {
|
|
161
|
+
const d1 = parseDateValue(val[0])
|
|
162
|
+
const d2 = parseDateValue(val[1])
|
|
163
|
+
if (d1 && d2) {
|
|
164
|
+
currentRangeDate.value = [d1, d2]
|
|
165
|
+
return
|
|
166
|
+
}
|
|
141
167
|
}
|
|
168
|
+
currentRangeDate.value = undefined
|
|
142
169
|
},
|
|
143
170
|
{ immediate: true }
|
|
144
171
|
)
|
|
145
172
|
|
|
146
|
-
|
|
173
|
+
function formatDateValue(d: Dater) {
|
|
174
|
+
if (props.dataType === 'date') {
|
|
175
|
+
return d.raw
|
|
176
|
+
}
|
|
177
|
+
if (props.dataType === 'timestamp') {
|
|
178
|
+
return d.timestamp
|
|
179
|
+
}
|
|
180
|
+
return d.format(props.valueFormat ?? formatStr.value)
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function formatModelValue(range: [Dater, Dater]): DateRangeValue {
|
|
184
|
+
return [formatDateValue(range[0]), formatDateValue(range[1])] as DateRangeValue
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const commitSelectedRange = userAction((rangeDate: [Dater, Dater]) => {
|
|
147
188
|
currentRangeDate.value = rangeDate
|
|
148
|
-
emit('update:modelValue', rangeDate
|
|
189
|
+
emit('update:modelValue', formatModelValue(rangeDate))
|
|
190
|
+
emit('change', [rangeDate[0].raw, rangeDate[1].raw])
|
|
149
191
|
})
|
|
150
192
|
|
|
151
193
|
async function handleSelect(rangeDate: [Dater, Dater] | undefined) {
|
|
194
|
+
if (!rangeDate) return
|
|
152
195
|
await commitSelectedRange(rangeDate)
|
|
153
196
|
dropdownRef.value?.close()
|
|
154
197
|
}
|
|
@@ -158,5 +201,6 @@ const hovered = shallowRef(false)
|
|
|
158
201
|
function handleClear() {
|
|
159
202
|
currentRangeDate.value = undefined
|
|
160
203
|
emit('update:modelValue', undefined)
|
|
204
|
+
emit('change', undefined)
|
|
161
205
|
}
|
|
162
206
|
</script>
|
package/src/types/cascade.ts
CHANGED
|
@@ -62,8 +62,16 @@ export interface CascadeEmits {
|
|
|
62
62
|
/** 触发更新 label 事件 */
|
|
63
63
|
(e: 'update:label', label?: string | string[]): void
|
|
64
64
|
(e: 'update:modelValue', value?: string | string[]): void
|
|
65
|
-
(
|
|
66
|
-
|
|
65
|
+
(
|
|
66
|
+
e: 'change',
|
|
67
|
+
items: (Record<string, any> & { fullLabel?: string })[],
|
|
68
|
+
fullLabels?: string[]
|
|
69
|
+
): void
|
|
70
|
+
(
|
|
71
|
+
e: 'change',
|
|
72
|
+
item: (Record<string, any> & { fullLabel?: string }) | undefined,
|
|
73
|
+
fullLabel?: string
|
|
74
|
+
): void
|
|
67
75
|
(e: 'clear'): void
|
|
68
76
|
}
|
|
69
77
|
|