@teammodlr/ui-kit 2.1.7 → 2.1.9
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/avatargroup/symbol.d.ts +2 -2
- package/lib/components/breadcrumb/style/index.d.ts +1 -1
- package/lib/components/breadcrumb/symbol.d.ts +1 -1
- package/lib/components/buttongroup/symbol.d.ts +2 -2
- package/lib/components/colorpicker/ColorPicker.vue.d.ts +1 -1
- package/lib/components/dropdown/Dropdown.vue.d.ts +1 -1
- package/lib/components/dropdown/symbol.d.ts +1 -1
- package/lib/components/form/symbol.d.ts +1 -1
- package/lib/components/messageprovider/style/index.d.ts +1 -1
- package/lib/components/radiobuttongroup/symbol.d.ts +2 -2
- package/lib/components/tooltip/Tooltip.vue.d.ts +1 -1
- package/lib/components/tree/TreeNode.vue.d.ts +2 -0
- package/lib/components/tree/TreeNodeToggle.vue.d.ts +7 -1
- package/lib/components/tree/props.d.ts +4 -4
- package/lib/components/tree/style/Tree.css.d.ts +7 -0
- package/lib/components/tree/style/index.d.ts +1 -0
- package/lib/components/tree/types.d.ts +11 -10
- package/lib/composables/element.d.ts +1 -1
- package/lib/composables/useInteractive.d.ts +1 -1
- package/lib/composables/useMount.d.ts +1 -1
- package/lib/composables/usePopper.d.ts +2 -2
- package/lib/composables/useZIndex.d.ts +1 -1
- package/lib/index.cjs.js +9 -9
- package/lib/index.es.js +2522 -2490
- package/lib/install.d.ts +1 -1
- package/lib/nuxt.js +17 -15
- package/lib/nuxt.plugin.js +6 -6
- package/lib/style.css +1 -1
- package/package.json +89 -79
- package/src/__storybook__/argTypes.ts +5 -13
- package/src/__storybook__/createStory.ts +10 -10
- package/src/call.ts +14 -14
- package/src/components/avatar/Avatar.vue +1 -1
- package/src/components/avatar/examples/index.stories.ts +4 -7
- package/src/components/avatar/style/Avatar.css.ts +17 -17
- package/src/components/avatargroup/examples/index.stories.ts +5 -10
- package/src/components/avatargroup/style/AvatarGroup.css.ts +9 -4
- package/src/components/avatargroup/symbol.ts +5 -5
- package/src/components/badge/examples/index.stories.ts +4 -6
- package/src/components/badge/style/Badge.css.ts +36 -36
- package/src/components/breadcrumb/examples/index.stories.ts +6 -10
- package/src/components/breadcrumb/style/Breadcrumb.css.ts +17 -17
- package/src/components/breadcrumb/style/index.ts +1 -1
- package/src/components/breadcrumb/symbol.ts +4 -3
- package/src/components/button/examples/index.stories.ts +4 -4
- package/src/components/button/style/Button.css.ts +143 -133
- package/src/components/buttongroup/examples/index.stories.ts +6 -12
- package/src/components/buttongroup/style/ButtonGroup.css.ts +13 -11
- package/src/components/buttongroup/symbol.ts +5 -4
- package/src/components/checkbox/Checkbox.vue +8 -8
- package/src/components/checkbox/examples/index.stories.ts +4 -9
- package/src/components/checkbox/examples/index.ts +0 -1
- package/src/components/checkbox/style/Checkbox.css.ts +31 -27
- package/src/components/checkbox/style/index.ts +1 -1
- package/src/components/colorpicker/examples/index.stories.ts +5 -10
- package/src/components/colorpicker/examples/index.ts +1 -1
- package/src/components/colorpicker/style/ColorPicker.css.ts +22 -14
- package/src/components/colorpicker/utils.ts +46 -28
- package/src/components/confirm/examples/index.stories.ts +5 -8
- package/src/components/confirm/props.ts +2 -2
- package/src/components/confirm/providerProps.ts +1 -2
- package/src/components/confirm/types.ts +15 -16
- package/src/components/confirm/useConfirm.ts +3 -1
- package/src/components/dialog/examples/index.stories.ts +5 -9
- package/src/components/dialog/style/Dialog.css.ts +38 -37
- package/src/components/dropdown/examples/index.stories.ts +3 -7
- package/src/components/dropdown/hooks.ts +20 -20
- package/src/components/dropdown/style/Dropdown.css.ts +24 -24
- package/src/components/dropdown/symbol.ts +3 -2
- package/src/components/form/Form.vue +1 -1
- package/src/components/form/examples/index.stories.ts +2 -4
- package/src/components/form/style/Form.css.ts +13 -8
- package/src/components/form/style/index.ts +2 -2
- package/src/components/form/symbol.ts +10 -5
- package/src/components/image/examples/index.stories.ts +5 -7
- package/src/components/input/Input.vue +8 -9
- package/src/components/input/examples/index.stories.ts +5 -7
- package/src/components/input/style/Input.css.ts +40 -43
- package/src/components/link/examples/index.stories.ts +4 -9
- package/src/components/messageprovider/examples/index.stories.ts +5 -8
- package/src/components/messageprovider/style/Message.css.ts +31 -31
- package/src/components/messageprovider/style/index.ts +1 -1
- package/src/components/messageprovider/types.ts +31 -22
- package/src/components/messageprovider/useMessage.ts +6 -4
- package/src/components/modal/examples/index.stories.ts +5 -10
- package/src/components/modal/style/Modal.css.ts +76 -73
- package/src/components/pagination/examples/index.stories.ts +5 -9
- package/src/components/pagination/examples/index.ts +1 -1
- package/src/components/pagination/style/Pagination.css.ts +41 -37
- package/src/components/radio/Radio.vue +7 -7
- package/src/components/radio/examples/index.stories.ts +4 -9
- package/src/components/radio/examples/index.ts +0 -1
- package/src/components/radio/style/Checkbox.css.ts +30 -31
- package/src/components/radio/style/index.ts +1 -1
- package/src/components/radiobutton/RadioButton.vue +3 -3
- package/src/components/radiobutton/style/RadioButton.css.ts +41 -36
- package/src/components/radiobuttongroup/examples/index.stories.ts +6 -10
- package/src/components/radiobuttongroup/examples/index.ts +0 -1
- package/src/components/radiobuttongroup/style/RadioButtonGroup.css.ts +14 -14
- package/src/components/radiobuttongroup/style/index.ts +1 -1
- package/src/components/radiobuttongroup/symbol.ts +8 -7
- package/src/components/renderer/examlpes/index.stories.ts +4 -8
- package/src/components/renderer/props.ts +2 -3
- package/src/components/renderer/renderer.ts +3 -3
- package/src/components/select/Select.vue +3 -4
- package/src/components/select/examples/index.stories.ts +4 -10
- package/src/components/select/style/Select.css.ts +62 -61
- package/src/components/skeleton/examples/index.stories.ts +5 -9
- package/src/components/skeleton/style/Skeleton.css.ts +16 -16
- package/src/components/skeleton/style/index.ts +2 -2
- package/src/components/slider/style/Slider.css.ts +12 -5
- package/src/components/switch/Switch.vue +4 -4
- package/src/components/switch/examples/index.stories.ts +4 -9
- package/src/components/switch/examples/index.ts +0 -1
- package/src/components/switch/style/Switch.css.ts +56 -57
- package/src/components/switch/style/index.ts +1 -1
- package/src/components/tab/examples/index.stories.ts +5 -11
- package/src/components/table/examples/index.stories.ts +6 -12
- package/src/components/table/style/Table.css.ts +22 -17
- package/src/components/table/style/index.ts +1 -1
- package/src/components/table/types/index.ts +1 -1
- package/src/components/tag/examples/index.stories.ts +4 -10
- package/src/components/tag/style/Tag.css.ts +14 -9
- package/src/components/textarea/Textarea.vue +7 -8
- package/src/components/textarea/examples/index.stories.ts +4 -8
- package/src/components/textarea/style/Textarea.css.ts +33 -33
- package/src/components/tooltip/examples/index.stories.ts +5 -10
- package/src/components/tooltip/examples/index.ts +2 -2
- package/src/components/tooltip/style/Tooltip.css.ts +24 -25
- package/src/components/transfer/examples/index.stories.ts +5 -9
- package/src/components/transfer/style/Transfer.css.ts +41 -40
- package/src/components/tree/Tree.vue +110 -109
- package/src/components/tree/TreeNode.vue +29 -23
- package/src/components/tree/TreeNodeToggle.vue +37 -25
- package/src/components/tree/examples/basic.vue +1 -1
- package/src/components/tree/examples/index.stories.ts +6 -10
- package/src/components/tree/props.ts +20 -18
- package/src/components/tree/style/Tree.css.ts +75 -0
- package/src/components/tree/style/index.ts +1 -0
- package/src/components/tree/types.ts +60 -61
- package/src/components/virtualscroll/examples/index.stories.ts +4 -8
- package/src/components/virtualscroll/style/VirtualScroll.css.ts +1 -2
- package/src/composables/element.ts +4 -4
- package/src/composables/useCachedUid.ts +7 -6
- package/src/composables/useEventListener.ts +11 -6
- package/src/composables/useInput.ts +63 -41
- package/src/composables/useInteractive.ts +10 -11
- package/src/composables/useMergedState.ts +7 -7
- package/src/composables/useMount.ts +11 -11
- package/src/composables/usePopper.ts +57 -36
- package/src/composables/useZIndex.ts +5 -5
- package/src/create.ts +10 -6
- package/src/examples/cards/cards.stories.ts +3 -3
- package/src/examples/modal/modal.stories.ts +3 -3
- package/src/exports/nuxt.js +17 -15
- package/src/exports/nuxt.plugin.js +6 -6
- package/src/index.ts +0 -2
- package/src/install.ts +5 -5
- package/src/shims-vue.d.ts +3 -3
- package/src/styles/theme.css.ts +51 -43
- package/src/styles/transitions.css.ts +26 -28
- package/src/types/props.ts +16 -2
- package/src/utils/injection.ts +3 -3
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
<div ref="selfElRef">
|
|
3
|
+
<VVirtualList
|
|
4
|
+
ref="virtualListInstRef"
|
|
5
|
+
:items="nodesRef"
|
|
6
|
+
itemResizable
|
|
7
|
+
:itemSize="20"
|
|
8
|
+
>
|
|
9
|
+
<template v-slot:default="{ item }">
|
|
10
|
+
<TreeNode :node="item"/>
|
|
11
|
+
</template>
|
|
12
|
+
</VVirtualList>
|
|
13
|
+
</div>
|
|
14
14
|
</template>
|
|
15
15
|
|
|
16
16
|
<script lang="ts">
|
|
@@ -19,7 +19,7 @@ import {computed, defineComponent, provide, ref, toRef} from 'vue'
|
|
|
19
19
|
import {createTreeMateOptions, treeProps} from "./props";
|
|
20
20
|
import type {Key, TmNode, TreeOption} from "./types";
|
|
21
21
|
import {
|
|
22
|
-
|
|
22
|
+
createTreeMate,
|
|
23
23
|
} from 'treemate'
|
|
24
24
|
import TreeNode from "./TreeNode.vue";
|
|
25
25
|
import {treeInjectionKey} from "./types";
|
|
@@ -27,111 +27,112 @@ import {call} from "../../call";
|
|
|
27
27
|
import useMergedState from "../../composables/useMergedState";
|
|
28
28
|
|
|
29
29
|
export default defineComponent({
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
const mergedExpandedKeysRef = useMergedState(
|
|
62
|
-
controlledExpandedKeysRef,
|
|
63
|
-
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
|
-
handleDoubleClick,
|
|
77
|
-
handleToggleClick
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
// const { watchProps } = props;
|
|
81
|
-
//
|
|
82
|
-
// watchEffect(() => {
|
|
83
|
-
// initUncontrolledExpandedKeys(undefined);
|
|
84
|
-
// })
|
|
85
|
-
|
|
86
|
-
function handleToggleClick(node: TmNode): void {
|
|
87
|
-
|
|
88
|
-
toggleExpand(node);
|
|
89
|
-
}
|
|
30
|
+
components: {TreeNode, VVirtualList},
|
|
31
|
+
name: 'Tree',
|
|
32
|
+
props: treeProps,
|
|
33
|
+
emits: ['update:expandedKeys', 'dblclick'],
|
|
34
|
+
setup: function (props, {emit}) {
|
|
35
|
+
const selfElRef = ref<HTMLDivElement | null>(null);
|
|
36
|
+
const virtualListInstRef = ref<VirtualListInst | null>(null)
|
|
37
|
+
|
|
38
|
+
function getScrollContainer(): HTMLElement | null | undefined {
|
|
39
|
+
return virtualListInstRef.value?.listElRef
|
|
40
|
+
}
|
|
90
41
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
42
|
+
function getScrollContent(): HTMLElement | null | undefined {
|
|
43
|
+
return virtualListInstRef.value?.itemsElRef
|
|
44
|
+
}
|
|
94
45
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
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
|
+
const mergedExpandedKeysRef = useMergedState(
|
|
62
|
+
controlledExpandedKeysRef,
|
|
63
|
+
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
|
+
});
|
|
80
|
+
|
|
81
|
+
// const { watchProps } = props;
|
|
82
|
+
//
|
|
83
|
+
// watchEffect(() => {
|
|
84
|
+
// initUncontrolledExpandedKeys(undefined);
|
|
85
|
+
// })
|
|
86
|
+
|
|
87
|
+
function handleToggleClick(node: TmNode): void {
|
|
88
|
+
|
|
89
|
+
toggleExpand(node);
|
|
110
90
|
}
|
|
111
91
|
|
|
112
|
-
|
|
92
|
+
function handleDoubleClick(node: TreeOption): void {
|
|
93
|
+
emit('dblclick', node);
|
|
94
|
+
}
|
|
113
95
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
96
|
+
function toggleExpand(node: TmNode): void {
|
|
97
|
+
const {key} = node;
|
|
98
|
+
const {value: mergedExpandedKeys} = mergedExpandedKeysRef
|
|
99
|
+
const index = mergedExpandedKeys.findIndex(
|
|
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
|
+
}
|
|
112
|
+
|
|
113
|
+
let nextKeys: Key[] = mergedExpandedKeys.concat(key);
|
|
114
|
+
|
|
115
|
+
doUpdateExpandedKeys(nextKeys)
|
|
116
|
+
}
|
|
117
|
+
}
|
|
117
118
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
119
|
+
function getOptionsByKeys(keys: Key[]): Array<TreeOption | null> {
|
|
120
|
+
const {getNode} = dataTreeMateRef.value;
|
|
121
|
+
return keys.map((key) => getNode(key)?.rawNode || null);
|
|
122
|
+
}
|
|
122
123
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
124
|
+
function doUpdateExpandedKeys(
|
|
125
|
+
value: Key[],
|
|
126
|
+
): void {
|
|
127
|
+
uncontrolledExpandedKeysRef.value = value;
|
|
128
|
+
}
|
|
128
129
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
130
|
+
return {
|
|
131
|
+
nodesRef,
|
|
132
|
+
displayTreeMateRef,
|
|
133
|
+
selfElRef
|
|
134
|
+
}
|
|
133
135
|
}
|
|
134
|
-
}
|
|
135
136
|
})
|
|
136
137
|
|
|
137
138
|
</script>
|
|
@@ -1,29 +1,35 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
@dblclick="doDoubleClick"
|
|
4
|
+
:class="style.nodeWrapper"
|
|
5
|
+
|
|
5
6
|
>
|
|
6
|
-
<
|
|
7
|
-
<
|
|
8
|
-
<div
|
|
7
|
+
<div :class="style.node">
|
|
8
|
+
<template v-if="indentCount > 0">
|
|
9
|
+
<div v-for="i in indentCount" style="flex-grow: 0; flex-shrink: 0; height: 0;">
|
|
10
|
+
<div :key="i" style="width: 16px;"></div>
|
|
11
|
+
</div>
|
|
12
|
+
</template>
|
|
13
|
+
<TreeNodeToggle
|
|
14
|
+
:hide="node.isLeaf"
|
|
15
|
+
:node="node"
|
|
16
|
+
:expanded="expanded"
|
|
17
|
+
@click="handleToggleClick"
|
|
18
|
+
/>
|
|
19
|
+
|
|
20
|
+
<div :class="style.nodeContent">
|
|
21
|
+
<div :class="style.nodeContentText">{{ labelField }}</div>
|
|
9
22
|
</div>
|
|
10
|
-
</
|
|
11
|
-
<TreeNodeToggle
|
|
12
|
-
:hide="node.isLeaf"
|
|
13
|
-
:node="node"
|
|
14
|
-
:expanded="expanded"
|
|
15
|
-
@click="handleToggleClick"
|
|
16
|
-
/>
|
|
17
|
-
{{ labelField }}
|
|
23
|
+
</div>
|
|
18
24
|
</div>
|
|
19
25
|
</template>
|
|
20
26
|
|
|
21
27
|
<script lang="ts">
|
|
22
|
-
import {ref, defineComponent, type PropType, inject, computed} from "vue";
|
|
28
|
+
import {ref, defineComponent, type PropType, inject, computed, unref} from "vue";
|
|
23
29
|
import type {TmNode, TreeOption} from "./types";
|
|
24
30
|
import {treeInjectionKey} from "./types";
|
|
25
31
|
import TreeNodeToggle from "@/components/tree/TreeNodeToggle.vue";
|
|
26
|
-
import
|
|
32
|
+
import * as style from "./style";
|
|
27
33
|
|
|
28
34
|
export default defineComponent({
|
|
29
35
|
name: 'TreeNode',
|
|
@@ -40,6 +46,7 @@ export default defineComponent({
|
|
|
40
46
|
nodePropsRef,
|
|
41
47
|
labelFieldRef,
|
|
42
48
|
keyFieldRef,
|
|
49
|
+
childrenFieldRef,
|
|
43
50
|
indentRef,
|
|
44
51
|
handleToggleClick: handleToggleClickTree,
|
|
45
52
|
handleDoubleClick
|
|
@@ -67,14 +74,12 @@ export default defineComponent({
|
|
|
67
74
|
}
|
|
68
75
|
|
|
69
76
|
function doDoubleClick(e: MouseEvent) {
|
|
70
|
-
|
|
71
|
-
let
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
[labelFieldRef.value]: node.rawNode[labelFieldRef.value]
|
|
75
|
-
} as TreeOption;
|
|
76
|
-
handleDoubleClick(nodeData);
|
|
77
|
+
let node = unref(props.node.rawNode);
|
|
78
|
+
let clone = Object.assign({}, node);
|
|
79
|
+
delete clone[childrenFieldRef.value];
|
|
80
|
+
handleDoubleClick(clone);
|
|
77
81
|
}
|
|
82
|
+
|
|
78
83
|
const indentCount = computed(() => {
|
|
79
84
|
return props.node.level;
|
|
80
85
|
})
|
|
@@ -96,7 +101,8 @@ export default defineComponent({
|
|
|
96
101
|
labelField,
|
|
97
102
|
expanded: expanded,
|
|
98
103
|
handleToggleClick,
|
|
99
|
-
doDoubleClick
|
|
104
|
+
doDoubleClick,
|
|
105
|
+
style
|
|
100
106
|
}
|
|
101
107
|
}
|
|
102
108
|
});
|
|
@@ -1,36 +1,48 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
<div
|
|
3
|
+
@click="onClick"
|
|
4
|
+
:class="iconClass"
|
|
5
|
+
>
|
|
6
|
+
<template v-if="!hide">
|
|
7
|
+
<svg v-if="expanded" :class="style.icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
|
|
8
|
+
<path d="M12 8l10 8l-10 8z"></path>
|
|
9
|
+
</svg>
|
|
10
|
+
<svg v-else :class="style.icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
|
|
11
|
+
<path d="M12 8l10 8l-10 8z"></path>
|
|
12
|
+
</svg>
|
|
13
|
+
</template>
|
|
14
|
+
</div>
|
|
11
15
|
</template>
|
|
12
16
|
|
|
13
17
|
<script lang="ts">
|
|
14
|
-
import {defineComponent, type PropType} from "vue";
|
|
18
|
+
import {computed, defineComponent, type PropType} from "vue";
|
|
15
19
|
import type {TmNode} from "./types";
|
|
20
|
+
import * as style from "./style";
|
|
16
21
|
|
|
17
22
|
export default defineComponent({
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return {
|
|
23
|
+
name: "TreeNodeToggle",
|
|
24
|
+
props: {
|
|
25
|
+
expanded: Boolean,
|
|
26
|
+
selected: Boolean,
|
|
27
|
+
onClick: Function as PropType<(e: MouseEvent) => void>,
|
|
28
|
+
hide: Boolean,
|
|
29
|
+
node: {
|
|
30
|
+
type: Object as PropType<TmNode>,
|
|
31
|
+
required: true
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
setup(props) {
|
|
32
35
|
|
|
33
|
-
|
|
36
|
+
const iconClass = computed(() => {
|
|
37
|
+
return {
|
|
38
|
+
[style.toggle]: true,
|
|
39
|
+
[style.iconRotate["90"]]: props.expanded,
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
return {
|
|
43
|
+
style,
|
|
44
|
+
iconClass
|
|
34
45
|
}
|
|
46
|
+
}
|
|
35
47
|
})
|
|
36
48
|
</script>
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
import MTree from
|
|
1
|
+
import MTree from '../Tree.vue';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
MTreeBasic
|
|
5
|
-
} from "./index";
|
|
3
|
+
import { MTreeBasic } from './index';
|
|
6
4
|
|
|
7
|
-
import {
|
|
8
|
-
createStory,
|
|
9
|
-
} from "../../../__storybook__";
|
|
5
|
+
import { createStory } from '../../../__storybook__';
|
|
10
6
|
|
|
11
7
|
export default {
|
|
12
8
|
component: MTree,
|
|
13
|
-
title:
|
|
14
|
-
}
|
|
9
|
+
title: 'Components/Tree'
|
|
10
|
+
};
|
|
15
11
|
|
|
16
|
-
export const Basic = createStory(MTreeBasic)
|
|
12
|
+
export const Basic = createStory(MTreeBasic);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {ExtractPublicPropTypes, PropType} from
|
|
1
|
+
import type { ExtractPublicPropTypes, PropType } from 'vue';
|
|
2
2
|
import type {
|
|
3
3
|
TreeOptions,
|
|
4
4
|
Key,
|
|
@@ -6,24 +6,24 @@ import type {
|
|
|
6
6
|
OnUpdateIndeterminateKeys,
|
|
7
7
|
onUpdateExpandedKeys,
|
|
8
8
|
TreeNodeDoubleClick
|
|
9
|
-
} from
|
|
10
|
-
import type {TreeMateOptions} from
|
|
11
|
-
import type {MaybeArray} from
|
|
9
|
+
} from './types';
|
|
10
|
+
import type { TreeMateOptions } from 'treemate';
|
|
11
|
+
import type { MaybeArray } from '../../call';
|
|
12
12
|
|
|
13
13
|
export const treeSharedProps = {
|
|
14
14
|
expandedKeys: Array as PropType<Key[]>,
|
|
15
15
|
defaultExpandAll: Boolean,
|
|
16
16
|
keyField: {
|
|
17
17
|
type: String,
|
|
18
|
-
default: 'key'
|
|
18
|
+
default: 'key'
|
|
19
19
|
},
|
|
20
20
|
labelField: {
|
|
21
21
|
type: String,
|
|
22
|
-
default: 'label'
|
|
22
|
+
default: 'label'
|
|
23
23
|
},
|
|
24
24
|
childrenField: {
|
|
25
25
|
type: String,
|
|
26
|
-
default: 'children'
|
|
26
|
+
default: 'children'
|
|
27
27
|
},
|
|
28
28
|
onDblClick: Function as PropType<TreeNodeDoubleClick>,
|
|
29
29
|
onUpdateIndeterminateKeys: [Function, Array] as PropType<
|
|
@@ -40,7 +40,7 @@ export const treeSharedProps = {
|
|
|
40
40
|
>
|
|
41
41
|
} as const;
|
|
42
42
|
|
|
43
|
-
export const treeProps= {
|
|
43
|
+
export const treeProps = {
|
|
44
44
|
data: {
|
|
45
45
|
type: Array as PropType<TreeOptions>,
|
|
46
46
|
default: () => []
|
|
@@ -64,32 +64,34 @@ export const treeProps= {
|
|
|
64
64
|
virtualScroll: Boolean,
|
|
65
65
|
nodeProps: Function as PropType<TreeNodeProps>,
|
|
66
66
|
getChildren: Function as PropType<GetChildren>,
|
|
67
|
-
...treeSharedProps
|
|
67
|
+
...treeSharedProps
|
|
68
68
|
} as const;
|
|
69
69
|
|
|
70
70
|
export type TreeProps = ExtractPublicPropTypes<typeof treeProps>;
|
|
71
|
-
export type GetChildren = (option: any) => unknown
|
|
71
|
+
export type GetChildren = (option: any) => unknown;
|
|
72
72
|
|
|
73
|
-
export function createTreeMateOptions<T>
|
|
73
|
+
export function createTreeMateOptions<T>(
|
|
74
74
|
keyField: string,
|
|
75
75
|
childrenField: string,
|
|
76
76
|
disabledField: string,
|
|
77
|
-
getChildren: GetChildren | undefined
|
|
77
|
+
getChildren: GetChildren | undefined
|
|
78
78
|
): TreeMateOptions<T, T, T> {
|
|
79
|
-
const settledGetChildren: GetChildren =
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
const settledGetChildren: GetChildren =
|
|
80
|
+
getChildren ||
|
|
81
|
+
((node: T) => {
|
|
82
|
+
return (node as any)[childrenField];
|
|
83
|
+
});
|
|
82
84
|
|
|
83
85
|
return {
|
|
84
86
|
getIsGroup() {
|
|
85
87
|
return false;
|
|
86
88
|
},
|
|
87
89
|
getKey(node: T) {
|
|
88
|
-
return (node as any)[keyField]
|
|
90
|
+
return (node as any)[keyField];
|
|
89
91
|
},
|
|
90
92
|
getChildren: settledGetChildren,
|
|
91
93
|
getDisabled(node: T) {
|
|
92
|
-
return !!(
|
|
94
|
+
return !!(node as any)[disabledField];
|
|
93
95
|
}
|
|
94
|
-
}
|
|
96
|
+
};
|
|
95
97
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createVar,
|
|
3
|
+
globalKeyframes,
|
|
4
|
+
globalStyle,
|
|
5
|
+
style,
|
|
6
|
+
styleVariants
|
|
7
|
+
} from '@vanilla-extract/css';
|
|
8
|
+
import { themeVars } from '../../../styles/theme.css';
|
|
9
|
+
|
|
10
|
+
export const toggle = style({
|
|
11
|
+
cursor: 'pointer',
|
|
12
|
+
display: 'inline-flex',
|
|
13
|
+
flexShrink: 0,
|
|
14
|
+
height: `24px`,
|
|
15
|
+
width: `24px`,
|
|
16
|
+
alignItems: 'center',
|
|
17
|
+
justifyContent: 'center',
|
|
18
|
+
verticalAlign: 'bottom',
|
|
19
|
+
transition: `transform .15s ${themeVars.transition.default}`
|
|
20
|
+
});
|
|
21
|
+
export const icon = style({
|
|
22
|
+
position: 'relative',
|
|
23
|
+
height: `14px`,
|
|
24
|
+
width: `14px`,
|
|
25
|
+
display: 'flex',
|
|
26
|
+
fontSize: `14px`,
|
|
27
|
+
fill: 'currentColor',
|
|
28
|
+
color: themeVars.color.gray['600']
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export const iconRotate = styleVariants({
|
|
32
|
+
90: {
|
|
33
|
+
transform: `rotate(90deg)`
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export const nodeWrapper = style({
|
|
38
|
+
boxSizing: 'border-box',
|
|
39
|
+
padding: `${themeVars.space['0.5']} 0`
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
export const node = style({
|
|
43
|
+
transform: `translate3d(0, 0, 0)`,
|
|
44
|
+
position: 'relative',
|
|
45
|
+
display: 'flex',
|
|
46
|
+
borderRadius: themeVars.rounded.small,
|
|
47
|
+
transition: `background-color .3s ${themeVars.transition.default}`,
|
|
48
|
+
selectors: {
|
|
49
|
+
[`&:hover`]: {
|
|
50
|
+
backgroundColor: themeVars.color.gray['150']
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
export const nodeContent = style({
|
|
56
|
+
cursor: 'pointer',
|
|
57
|
+
position: 'relative',
|
|
58
|
+
display: 'inline-flex',
|
|
59
|
+
alignItems: 'center',
|
|
60
|
+
minHeight: `24px`,
|
|
61
|
+
boxSizing: 'border-box',
|
|
62
|
+
verticalAlign: 'bottom',
|
|
63
|
+
padding: `0 ${themeVars.space['1']} 0 ${themeVars.space['1']}`,
|
|
64
|
+
borderRadius: themeVars.rounded.default,
|
|
65
|
+
lineHeight: 1.5,
|
|
66
|
+
userSelect: 'none',
|
|
67
|
+
flexGrow: 1
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
export const nodeContentText = style({
|
|
71
|
+
flexGrow: 1,
|
|
72
|
+
maxWidth: `100%`,
|
|
73
|
+
fontSize: themeVars.fontSize.base,
|
|
74
|
+
color: themeVars.color.gray['700']
|
|
75
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Tree.css';
|