@teammodlr/ui-kit 2.3.23 → 3.0.0-beta.10
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/lib/components/avatar/Avatar.vue.d.ts +2 -2
- package/lib/components/badge/style/Badge.css.d.ts +2 -2
- package/lib/components/button/Button.vue.d.ts +7 -4
- package/lib/components/button/style/Button.css.d.ts +3 -3
- package/lib/components/cardcontextmenu/CardContextMenu.vue.d.ts +5 -8
- package/lib/components/cardcontextmenu/CardContextMenuItem.vue.d.ts +11 -2
- package/lib/components/cardcontextmenu/CardContextMenuTriggerProvider.vue.d.ts +2 -0
- package/lib/components/cardcontextmenu/style/Dropdown.css.d.ts +2 -1
- package/lib/components/cardcontextmenu/symbol.d.ts +1 -0
- package/lib/components/checkbox/Checkbox.vue.d.ts +15 -4
- package/lib/components/collapse/CollapseItem.vue.d.ts +3 -2
- package/lib/components/colorpicker/ColorPicker.vue.d.ts +8 -9
- package/lib/components/confirm/Confirm.vue.d.ts +9 -0
- package/lib/components/confirm/props.d.ts +4 -0
- package/lib/components/dialog/Dialog.vue.d.ts +13 -5
- package/lib/components/dialogprovider/DialogProvider.vue.d.ts +1 -0
- package/lib/components/dialogprovider/types.d.ts +1 -0
- package/lib/components/dropdown/Dropdown.vue.d.ts +3 -1
- package/lib/components/dropdown/DropdownItem.vue.d.ts +11 -1
- package/lib/components/dropdown/DropdownSeperator.vue.d.ts +1 -0
- package/lib/components/dropdown/DropdownTriggerProvider.vue.d.ts +2 -0
- package/lib/components/dropdown/style/Dropdown.css.d.ts +2 -1
- package/lib/components/dropdown/symbol.d.ts +2 -0
- package/lib/components/image/Image.vue.d.ts +1 -1
- package/lib/components/index.d.ts +1 -0
- package/lib/components/messageprovider/Message.vue.d.ts +1 -1
- package/lib/components/messageprovider/MessageProvider.vue.d.ts +24 -24
- package/lib/components/messageprovider/style/Message.css.d.ts +1 -1
- package/lib/components/messageprovider/style/Toaster.css.d.ts +1 -0
- package/lib/components/messageprovider/types.d.ts +5 -0
- package/lib/components/modal/Modal.vue.d.ts +18 -6
- package/lib/components/popover/Popover.vue.d.ts +113 -0
- package/lib/components/popover/style/Popover.css.d.ts +4 -0
- package/lib/components/popover/style/index.d.ts +1 -0
- package/lib/components/radio/Radio.vue.d.ts +2 -0
- package/lib/components/radiobuttongroup/RadioButtonGroup.vue.d.ts +1 -0
- package/lib/components/select/Select.vue.d.ts +20 -11
- package/lib/components/switch/Switch.vue.d.ts +2 -0
- package/lib/components/tab/Tab.vue.d.ts +5 -2
- package/lib/components/tab/TabGroup.vue.d.ts +8 -3
- package/lib/components/textarea/Textarea.vue.d.ts +2 -1
- package/lib/components/tooltip/Tooltip.vue.d.ts +5 -20
- package/lib/components/tooltip/TooltipTrigger.vue.d.ts +1 -10
- package/lib/components/tree/Tree.vue.d.ts +3 -3
- package/lib/components/tree/TreeNode.vue.d.ts +26 -12
- package/lib/components/tree/types.d.ts +5 -5
- package/lib/index.cjs.js +5 -14
- package/lib/index.es.js +16907 -12199
- package/lib/style.css +1 -1
- package/package.json +12 -6
- package/src/components/avatar/Avatar.vue +32 -24
- package/src/components/button/Button.vue +24 -5
- package/src/components/cardcontextmenu/CardContextMenu.vue +68 -95
- package/src/components/cardcontextmenu/CardContextMenuItem.vue +40 -50
- package/src/components/cardcontextmenu/CardContextMenuSeperator.vue +9 -7
- package/src/components/cardcontextmenu/CardContextMenuTriggerProvider.vue +15 -0
- package/src/components/cardcontextmenu/style/Dropdown.css.ts +155 -2
- package/src/components/cardcontextmenu/symbol.ts +3 -0
- package/src/components/checkbox/Checkbox.vue +37 -12
- package/src/components/checkbox/style/Checkbox.css.ts +6 -6
- package/src/components/collapse/CollapseItem.vue +46 -21
- package/src/components/collapse/style/Collapse.css.ts +5 -1
- package/src/components/colorpicker/ColorPicker.vue +76 -45
- package/src/components/confirm/Confirm.vue +15 -8
- package/src/components/confirm/props.ts +4 -0
- package/src/components/dialog/Dialog.vue +183 -37
- package/src/components/dialog/style/Dialog.css.ts +15 -1
- package/src/components/dialogprovider/types.ts +1 -0
- package/src/components/dropdown/Dropdown.vue +46 -3
- package/src/components/dropdown/DropdownItem.vue +55 -25
- package/src/components/dropdown/DropdownSeperator.vue +19 -11
- package/src/components/dropdown/DropdownTriggerProvider.vue +15 -0
- package/src/components/dropdown/examples/context.vue +2 -2
- package/src/components/dropdown/style/Dropdown.css.ts +173 -4
- package/src/components/dropdown/symbol.ts +4 -0
- package/src/components/form/examples/basic.vue +19 -8
- package/src/components/index.ts +1 -0
- package/src/components/messageprovider/MessageProvider.vue +139 -90
- package/src/components/messageprovider/examples/basic.vue +3 -1
- package/src/components/messageprovider/examples/index.stories.ts +37 -1
- package/src/components/messageprovider/style/Toaster.css.ts +24 -0
- package/src/components/messageprovider/types.ts +10 -0
- package/src/components/modal/Modal.vue +142 -67
- package/src/components/modal/style/Modal.css.ts +26 -2
- package/src/components/popover/Popover.vue +155 -0
- package/src/components/popover/examples/arrow.vue +47 -0
- package/src/components/popover/examples/basic.vue +15 -0
- package/src/components/popover/examples/index.stories.ts +19 -0
- package/src/components/popover/examples/index.ts +4 -0
- package/src/components/popover/examples/placement.vue +59 -0
- package/src/components/popover/examples/variant.vue +30 -0
- package/src/components/popover/style/Popover.css.ts +203 -0
- package/src/components/popover/style/index.ts +1 -0
- package/src/components/radio/Radio.vue +31 -17
- package/src/components/radiobutton/RadioButton.vue +15 -2
- package/src/components/radiobuttongroup/RadioButtonGroup.vue +11 -4
- package/src/components/select/Select.vue +301 -153
- package/src/components/select/examples/basic.vue +1 -1
- package/src/components/slider/Slider.vue +1 -1
- package/src/components/switch/Switch.vue +30 -10
- package/src/components/switch/style/Switch.css.ts +3 -5
- package/src/components/tab/Tab.vue +29 -20
- package/src/components/tab/TabGroup.vue +29 -38
- package/src/components/textarea/Textarea.vue +8 -4
- package/src/components/tooltip/Tooltip.vue +52 -141
- package/src/components/tooltip/TooltipTrigger.vue +14 -17
- package/src/components/tooltip/style/Tooltip.css.ts +148 -29
- package/src/components/tree/Tree.vue +138 -100
- package/src/components/tree/TreeNode.vue +105 -98
- package/src/components/tree/types.ts +4 -4
- package/src/styles/transitions.css.ts +36 -16
|
@@ -15,6 +15,122 @@ export const container = style({
|
|
|
15
15
|
zIndex: 50
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
+
const fadeOutAnimation = 'fade-out-animation';
|
|
19
|
+
globalKeyframes(fadeOutAnimation, {
|
|
20
|
+
from: {
|
|
21
|
+
opacity: 1
|
|
22
|
+
},
|
|
23
|
+
to: {
|
|
24
|
+
opacity: 0
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const slideFadeOutTopAnimation = 'tooltip-slide-fade-out-top';
|
|
29
|
+
globalKeyframes(slideFadeOutTopAnimation, {
|
|
30
|
+
from: {
|
|
31
|
+
opacity: 1,
|
|
32
|
+
transform: 'translateY(0) scale(1)'
|
|
33
|
+
},
|
|
34
|
+
to: {
|
|
35
|
+
opacity: 0,
|
|
36
|
+
transform: 'translateY(6px) scale(0.97)'
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const slideFadeOutBottomAnimation = 'tooltip-slide-fade-out-bottom';
|
|
41
|
+
globalKeyframes(slideFadeOutBottomAnimation, {
|
|
42
|
+
from: {
|
|
43
|
+
opacity: 1,
|
|
44
|
+
transform: 'translateY(0) scale(1)'
|
|
45
|
+
},
|
|
46
|
+
to: {
|
|
47
|
+
opacity: 0,
|
|
48
|
+
transform: 'translateY(-6px) scale(0.97)'
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const slideFadeOutLeftAnimation = 'tooltip-slide-fade-out-left';
|
|
53
|
+
globalKeyframes(slideFadeOutLeftAnimation, {
|
|
54
|
+
from: {
|
|
55
|
+
opacity: 1,
|
|
56
|
+
transform: 'translateX(0) scale(1)'
|
|
57
|
+
},
|
|
58
|
+
to: {
|
|
59
|
+
opacity: 0,
|
|
60
|
+
transform: 'translateX(6px) scale(0.97)'
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const slideFadeOutRightAnimation = 'tooltip-slide-fade-out-right';
|
|
65
|
+
globalKeyframes(slideFadeOutRightAnimation, {
|
|
66
|
+
from: {
|
|
67
|
+
opacity: 1,
|
|
68
|
+
transform: 'translateX(0) scale(1)'
|
|
69
|
+
},
|
|
70
|
+
to: {
|
|
71
|
+
opacity: 0,
|
|
72
|
+
transform: 'translateX(-6px) scale(0.97)'
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const fadeInAnimation = 'fade-in-animation';
|
|
77
|
+
globalKeyframes(fadeInAnimation, {
|
|
78
|
+
'0%': {
|
|
79
|
+
opacity: 0
|
|
80
|
+
},
|
|
81
|
+
'100%': {
|
|
82
|
+
opacity: 1
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const slideFadeTopAnimation = 'tooltip-slide-fade-top';
|
|
87
|
+
globalKeyframes(slideFadeTopAnimation, {
|
|
88
|
+
from: {
|
|
89
|
+
opacity: 0,
|
|
90
|
+
transform: 'translateY(6px) scale(0.97)'
|
|
91
|
+
},
|
|
92
|
+
to: {
|
|
93
|
+
opacity: 1,
|
|
94
|
+
transform: 'translateY(0) scale(1)'
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const slideFadeBottomAnimation = 'tooltip-slide-fade-bottom';
|
|
99
|
+
globalKeyframes(slideFadeBottomAnimation, {
|
|
100
|
+
from: {
|
|
101
|
+
opacity: 0,
|
|
102
|
+
transform: 'translateY(-6px) scale(0.97)'
|
|
103
|
+
},
|
|
104
|
+
to: {
|
|
105
|
+
opacity: 1,
|
|
106
|
+
transform: 'translateY(0) scale(1)'
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
const slideFadeLeftAnimation = 'tooltip-slide-fade-left';
|
|
111
|
+
globalKeyframes(slideFadeLeftAnimation, {
|
|
112
|
+
from: {
|
|
113
|
+
opacity: 0,
|
|
114
|
+
transform: 'translateX(6px) scale(0.97)'
|
|
115
|
+
},
|
|
116
|
+
to: {
|
|
117
|
+
opacity: 1,
|
|
118
|
+
transform: 'translateX(0) scale(1)'
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const slideFadeRightAnimation = 'tooltip-slide-fade-right';
|
|
123
|
+
globalKeyframes(slideFadeRightAnimation, {
|
|
124
|
+
from: {
|
|
125
|
+
opacity: 0,
|
|
126
|
+
transform: 'translateX(-6px) scale(0.97)'
|
|
127
|
+
},
|
|
128
|
+
to: {
|
|
129
|
+
opacity: 1,
|
|
130
|
+
transform: 'translateX(0) scale(1)'
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
|
|
18
134
|
export const tooltip = style({
|
|
19
135
|
vars: {
|
|
20
136
|
[vars.backgroundColor]: themeVars.color.gray[900],
|
|
@@ -22,7 +138,6 @@ export const tooltip = style({
|
|
|
22
138
|
},
|
|
23
139
|
zIndex: 50,
|
|
24
140
|
transition: 'opacity 0.3s, ease',
|
|
25
|
-
position: 'fixed',
|
|
26
141
|
fontSize: '13px',
|
|
27
142
|
fontWeight: 'normal',
|
|
28
143
|
color: vars.color,
|
|
@@ -33,18 +148,42 @@ export const tooltip = style({
|
|
|
33
148
|
width: 'max-content',
|
|
34
149
|
maxWidth: '300px',
|
|
35
150
|
boxSizing: 'border-box',
|
|
151
|
+
transformOrigin: 'var(--reka-tooltip-content-transform-origin)',
|
|
152
|
+
willChange: 'transform, opacity',
|
|
36
153
|
selectors: {
|
|
37
|
-
'&[data-
|
|
38
|
-
|
|
154
|
+
'&[data-state="delayed-open"]': {
|
|
155
|
+
animationDuration: '0.16s',
|
|
156
|
+
animationTimingFunction: 'cubic-bezier(0.16, 1, 0.3, 1)',
|
|
157
|
+
animationFillMode: 'both'
|
|
158
|
+
},
|
|
159
|
+
'&[data-state="closed"]': {
|
|
160
|
+
animationDuration: '0.12s',
|
|
161
|
+
animationTimingFunction: 'ease-out',
|
|
162
|
+
animationFillMode: 'both'
|
|
163
|
+
},
|
|
164
|
+
'&[data-state="closed"][data-side="top"]': {
|
|
165
|
+
animationName: slideFadeOutTopAnimation
|
|
166
|
+
},
|
|
167
|
+
'&[data-state="closed"][data-side="bottom"]': {
|
|
168
|
+
animationName: slideFadeOutBottomAnimation
|
|
39
169
|
},
|
|
40
|
-
'&[data-
|
|
41
|
-
|
|
170
|
+
'&[data-state="closed"][data-side="left"]': {
|
|
171
|
+
animationName: slideFadeOutLeftAnimation
|
|
42
172
|
},
|
|
43
|
-
'&[data-
|
|
44
|
-
|
|
173
|
+
'&[data-state="closed"][data-side="right"]': {
|
|
174
|
+
animationName: slideFadeOutRightAnimation
|
|
45
175
|
},
|
|
46
|
-
'&[data-
|
|
47
|
-
|
|
176
|
+
'&[data-state="delayed-open"][data-side="top"]': {
|
|
177
|
+
animationName: slideFadeTopAnimation
|
|
178
|
+
},
|
|
179
|
+
'&[data-state="delayed-open"][data-side="bottom"]': {
|
|
180
|
+
animationName: slideFadeBottomAnimation
|
|
181
|
+
},
|
|
182
|
+
'&[data-state="delayed-open"][data-side="left"]': {
|
|
183
|
+
animationName: slideFadeLeftAnimation
|
|
184
|
+
},
|
|
185
|
+
'&[data-state="delayed-open"][data-side="right"]': {
|
|
186
|
+
animationName: slideFadeRightAnimation
|
|
48
187
|
}
|
|
49
188
|
}
|
|
50
189
|
});
|
|
@@ -56,26 +195,6 @@ export const reverse = style({
|
|
|
56
195
|
}
|
|
57
196
|
});
|
|
58
197
|
|
|
59
|
-
const fadeOutAnimation = 'fade-out-animation';
|
|
60
|
-
globalKeyframes(fadeOutAnimation, {
|
|
61
|
-
from: {
|
|
62
|
-
opacity: 1
|
|
63
|
-
},
|
|
64
|
-
to: {
|
|
65
|
-
opacity: 0
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
const fadeInAnimation = 'fade-in-animation';
|
|
70
|
-
globalKeyframes(fadeInAnimation, {
|
|
71
|
-
'0%': {
|
|
72
|
-
opacity: 0
|
|
73
|
-
},
|
|
74
|
-
'100%': {
|
|
75
|
-
opacity: 1
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
|
|
79
198
|
export const fadeEnter = style({
|
|
80
199
|
animationName: fadeInAnimation,
|
|
81
200
|
animationDuration: '0.125s',
|
|
@@ -1,138 +1,176 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div ref="selfElRef">
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
:
|
|
6
|
-
|
|
7
|
-
:
|
|
8
|
-
|
|
9
|
-
<template v-slot:default="{ item }">
|
|
10
|
-
<TreeNode :node="item"/>
|
|
11
|
-
</template>
|
|
12
|
-
</VVirtualList>
|
|
3
|
+
<TreeNode
|
|
4
|
+
v-for="node in normalizedData"
|
|
5
|
+
:key="String(node[keyField])"
|
|
6
|
+
:node="node"
|
|
7
|
+
:level="0"
|
|
8
|
+
/>
|
|
13
9
|
</div>
|
|
14
10
|
</template>
|
|
15
11
|
|
|
16
12
|
<script lang="ts">
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
|
|
23
|
-
} from '
|
|
24
|
-
import TreeNode from "./TreeNode.vue";
|
|
25
|
-
import {treeInjectionKey} from "./types";
|
|
26
|
-
import {call} from "../../call";
|
|
27
|
-
import useMergedState from "../../composables/useMergedState";
|
|
13
|
+
import { computed, defineComponent, provide, ref, toRef, watch } from 'vue';
|
|
14
|
+
import { call } from '../../call';
|
|
15
|
+
import useMergedState from '../../composables/useMergedState';
|
|
16
|
+
import { treeProps } from './props';
|
|
17
|
+
import TreeNode from './TreeNode.vue';
|
|
18
|
+
import type { Key, TreeOption } from './types';
|
|
19
|
+
import { treeInjectionKey } from './types';
|
|
28
20
|
|
|
29
21
|
export default defineComponent({
|
|
30
|
-
components: {TreeNode
|
|
22
|
+
components: { TreeNode },
|
|
31
23
|
name: 'Tree',
|
|
32
24
|
props: treeProps,
|
|
33
25
|
emits: ['update:expandedKeys', 'dblclick'],
|
|
34
|
-
setup
|
|
26
|
+
setup(props, { emit }) {
|
|
35
27
|
const selfElRef = ref<HTMLDivElement | null>(null);
|
|
36
|
-
const
|
|
28
|
+
const controlledExpandedKeysRef = toRef(props, 'expandedKeys');
|
|
29
|
+
const uncontrolledExpandedKeysRef = ref<Key[]>([]);
|
|
37
30
|
|
|
38
|
-
function getScrollContainer(): HTMLElement | null | undefined {
|
|
39
|
-
return virtualListInstRef.value?.listElRef
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function getScrollContent(): HTMLElement | null | undefined {
|
|
43
|
-
return virtualListInstRef.value?.itemsElRef
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const displayTreeMateRef = computed(() => {
|
|
47
|
-
return createTreeMate<TreeOption>(
|
|
48
|
-
props.data,
|
|
49
|
-
createTreeMateOptions(
|
|
50
|
-
props.keyField,
|
|
51
|
-
props.childrenField,
|
|
52
|
-
'disabled',
|
|
53
|
-
props.getChildren
|
|
54
|
-
)
|
|
55
|
-
)
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
const dataTreeMateRef = displayTreeMateRef;
|
|
59
|
-
const controlledExpandedKeysRef = toRef(props, 'expandedKeys')
|
|
60
|
-
const uncontrolledExpandedKeysRef = ref<Key[]>([])
|
|
61
31
|
const mergedExpandedKeysRef = useMergedState(
|
|
62
32
|
controlledExpandedKeysRef,
|
|
63
33
|
uncontrolledExpandedKeysRef
|
|
64
|
-
)
|
|
65
|
-
const nodesRef = computed(() => {
|
|
66
|
-
return displayTreeMateRef.value.getFlattenedNodes(mergedExpandedKeysRef.value);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
provide(treeInjectionKey, {
|
|
70
|
-
mergedExpandedKeysRef,
|
|
71
|
-
indentRef: toRef(props, 'indent'),
|
|
72
|
-
expandOnClickRef: toRef(props, 'expandOnClick'),
|
|
73
|
-
nodePropsRef: toRef(props, 'nodeProps'),
|
|
74
|
-
labelFieldRef: toRef(props, 'labelField'),
|
|
75
|
-
keyFieldRef: toRef(props, 'keyField'),
|
|
76
|
-
childrenFieldRef: toRef(props, 'childrenField'),
|
|
77
|
-
handleDoubleClick,
|
|
78
|
-
handleToggleClick
|
|
79
|
-
});
|
|
34
|
+
);
|
|
80
35
|
|
|
81
|
-
|
|
82
|
-
//
|
|
83
|
-
// watchEffect(() => {
|
|
84
|
-
// initUncontrolledExpandedKeys(undefined);
|
|
85
|
-
// })
|
|
36
|
+
const normalizedData = computed<TreeOption[]>(() => props.data ?? []);
|
|
86
37
|
|
|
87
|
-
function
|
|
38
|
+
function getChildren(node: TreeOption): TreeOption[] {
|
|
39
|
+
const resolvedChildren = props.getChildren
|
|
40
|
+
? props.getChildren(node)
|
|
41
|
+
: node[props.childrenField];
|
|
88
42
|
|
|
89
|
-
|
|
43
|
+
return Array.isArray(resolvedChildren)
|
|
44
|
+
? (resolvedChildren as TreeOption[])
|
|
45
|
+
: [];
|
|
90
46
|
}
|
|
91
47
|
|
|
92
|
-
function
|
|
93
|
-
|
|
94
|
-
}
|
|
48
|
+
function collectNonLeafKeys(nodes: TreeOption[]): Key[] {
|
|
49
|
+
const keys: Key[] = [];
|
|
95
50
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
(expandedNodeId) => expandedNodeId === key
|
|
101
|
-
)
|
|
102
|
-
|
|
103
|
-
if (~index) {
|
|
104
|
-
const expandedKeysAfterChange = Array.from(mergedExpandedKeys);
|
|
105
|
-
expandedKeysAfterChange.splice(index, 1);
|
|
106
|
-
doUpdateExpandedKeys(expandedKeysAfterChange);
|
|
107
|
-
} else {
|
|
108
|
-
const nodeToBeExpanded = displayTreeMateRef.value.getNode(key);
|
|
109
|
-
if (!nodeToBeExpanded || nodeToBeExpanded.isLeaf) {
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
51
|
+
function walk(list: TreeOption[]) {
|
|
52
|
+
list.forEach(node => {
|
|
53
|
+
const children = getChildren(node);
|
|
54
|
+
const key = node[props.keyField] as Key | undefined;
|
|
112
55
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
56
|
+
if (children.length && typeof key !== 'undefined') {
|
|
57
|
+
keys.push(key);
|
|
58
|
+
walk(children);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
116
61
|
}
|
|
62
|
+
|
|
63
|
+
walk(nodes);
|
|
64
|
+
return keys;
|
|
117
65
|
}
|
|
118
66
|
|
|
67
|
+
watch(
|
|
68
|
+
() => [props.defaultExpandAll, normalizedData.value, props.keyField, props.childrenField],
|
|
69
|
+
() => {
|
|
70
|
+
if (
|
|
71
|
+
controlledExpandedKeysRef.value === undefined &&
|
|
72
|
+
props.defaultExpandAll
|
|
73
|
+
) {
|
|
74
|
+
uncontrolledExpandedKeysRef.value = collectNonLeafKeys(normalizedData.value);
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
{ immediate: true, deep: true }
|
|
78
|
+
);
|
|
79
|
+
|
|
119
80
|
function getOptionsByKeys(keys: Key[]): Array<TreeOption | null> {
|
|
120
|
-
const
|
|
121
|
-
|
|
81
|
+
const optionMap = new Map<Key, TreeOption>();
|
|
82
|
+
|
|
83
|
+
function walk(list: TreeOption[]) {
|
|
84
|
+
list.forEach(node => {
|
|
85
|
+
const key = node[props.keyField] as Key | undefined;
|
|
86
|
+
if (typeof key !== 'undefined') {
|
|
87
|
+
optionMap.set(key, node);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const children = getChildren(node);
|
|
91
|
+
if (children.length) {
|
|
92
|
+
walk(children);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
walk(normalizedData.value);
|
|
98
|
+
return keys.map(key => optionMap.get(key) ?? null);
|
|
122
99
|
}
|
|
123
100
|
|
|
124
101
|
function doUpdateExpandedKeys(
|
|
125
102
|
value: Key[],
|
|
103
|
+
node: TreeOption | null,
|
|
104
|
+
action: 'expand' | 'collapse' | 'filter'
|
|
126
105
|
): void {
|
|
127
106
|
uncontrolledExpandedKeysRef.value = value;
|
|
107
|
+
emit('update:expandedKeys', value);
|
|
108
|
+
|
|
109
|
+
const options = getOptionsByKeys(value);
|
|
110
|
+
const meta = node
|
|
111
|
+
? { node, action: action as 'expand' | 'collapse' }
|
|
112
|
+
: { node: null, action: 'filter' as const };
|
|
113
|
+
|
|
114
|
+
if (props['onUpdate:expandedKeys']) {
|
|
115
|
+
call(props['onUpdate:expandedKeys'] as any, value, options, meta);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (props.onUpdateExpandedKeys) {
|
|
119
|
+
call(props.onUpdateExpandedKeys as any, value, options, meta);
|
|
120
|
+
}
|
|
128
121
|
}
|
|
129
122
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
123
|
+
function handleToggle(node: TreeOption): void {
|
|
124
|
+
const key = node[props.keyField] as Key | undefined;
|
|
125
|
+
if (typeof key === 'undefined') {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const children = getChildren(node);
|
|
130
|
+
if (!children.length) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const expandedKeys = mergedExpandedKeysRef.value;
|
|
135
|
+
const isExpanded = expandedKeys.includes(key);
|
|
136
|
+
|
|
137
|
+
if (isExpanded) {
|
|
138
|
+
doUpdateExpandedKeys(
|
|
139
|
+
expandedKeys.filter(expandedKey => expandedKey !== key),
|
|
140
|
+
node,
|
|
141
|
+
'collapse'
|
|
142
|
+
);
|
|
143
|
+
} else {
|
|
144
|
+
doUpdateExpandedKeys([...expandedKeys, key], node, 'expand');
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function handleDoubleClick(node: TreeOption): void {
|
|
149
|
+
emit('dblclick', node);
|
|
150
|
+
|
|
151
|
+
if (props.onDblClick) {
|
|
152
|
+
call(props.onDblClick as any, { option: node });
|
|
153
|
+
}
|
|
134
154
|
}
|
|
135
|
-
}
|
|
136
|
-
})
|
|
137
155
|
|
|
156
|
+
provide(treeInjectionKey, {
|
|
157
|
+
mergedExpandedKeysRef,
|
|
158
|
+
indentRef: toRef(props, 'indent'),
|
|
159
|
+
expandOnClickRef: toRef(props, 'expandOnClick'),
|
|
160
|
+
nodePropsRef: toRef(props, 'nodeProps'),
|
|
161
|
+
labelFieldRef: toRef(props, 'labelField'),
|
|
162
|
+
keyFieldRef: toRef(props, 'keyField'),
|
|
163
|
+
childrenFieldRef: toRef(props, 'childrenField'),
|
|
164
|
+
getChildren,
|
|
165
|
+
handleDoubleClick,
|
|
166
|
+
handleToggle,
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
return {
|
|
170
|
+
keyField: props.keyField,
|
|
171
|
+
normalizedData,
|
|
172
|
+
selfElRef,
|
|
173
|
+
};
|
|
174
|
+
},
|
|
175
|
+
});
|
|
138
176
|
</script>
|