@handaotech-design/bom 0.0.24 → 0.0.26
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.
|
@@ -35,9 +35,11 @@ const treeContainerHeight = ref<number>(0)
|
|
|
35
35
|
const treeContainerId = 'treeContainer'
|
|
36
36
|
let keyToNodeMap = new Map<string, TreeNodeWithMeta>()
|
|
37
37
|
const selectedKeys = ref<string[]>([])
|
|
38
|
-
const
|
|
38
|
+
const keepTreeState = ref<boolean>(false)
|
|
39
|
+
const initTreeState = () => {
|
|
39
40
|
searchValue.value = ''
|
|
40
|
-
|
|
41
|
+
selectedKeys.value = []
|
|
42
|
+
expandedKeys.value = []
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
const onExpand = (keys: Key[]) => {
|
|
@@ -131,15 +133,12 @@ onBeforeUnmount(() => {
|
|
|
131
133
|
watch(
|
|
132
134
|
() => _treeData.value,
|
|
133
135
|
async () => {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
136
|
+
filteredTreeData.value = _treeData.value
|
|
137
|
+
keyToNodeMap = buildKeyToNodeMap(_treeData.value ?? [])
|
|
138
|
+
initTreeState()
|
|
139
|
+
if (!keepTreeState.value) {
|
|
137
140
|
selectFirstSelectableNode()
|
|
138
141
|
}
|
|
139
|
-
else {
|
|
140
|
-
keyToNodeMap.clear()
|
|
141
|
-
await initTreeState()
|
|
142
|
-
}
|
|
143
142
|
},
|
|
144
143
|
{
|
|
145
144
|
immediate: true,
|
|
@@ -199,6 +198,28 @@ function getTitlePart(title: string, partType: 'before' | 'after') {
|
|
|
199
198
|
function hasSearchMatch(title: string) {
|
|
200
199
|
return searchValue.value && title.includes(searchValue.value)
|
|
201
200
|
}
|
|
201
|
+
|
|
202
|
+
async function withKeepTreeState(updateDataFn: () => Promise<void>) {
|
|
203
|
+
const prevSelected = selectedKeys.value?.[0]
|
|
204
|
+
const prevExpanded = [...expandedKeys.value]
|
|
205
|
+
keepTreeState.value = true
|
|
206
|
+
await updateDataFn()
|
|
207
|
+
await nextTick(() => {
|
|
208
|
+
expandedKeys.value = prevExpanded.filter(key => keyToNodeMap.has(key as string))
|
|
209
|
+
|
|
210
|
+
if (prevSelected && keyToNodeMap.has(prevSelected)) {
|
|
211
|
+
selectedKeys.value = [prevSelected]
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
selectFirstSelectableNode()
|
|
215
|
+
}
|
|
216
|
+
keepTreeState.value = false
|
|
217
|
+
})
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
defineExpose({
|
|
221
|
+
withKeepTreeState,
|
|
222
|
+
})
|
|
202
223
|
</script>
|
|
203
224
|
|
|
204
225
|
<template>
|
|
@@ -226,7 +247,7 @@ function hasSearchMatch(title: string) {
|
|
|
226
247
|
@expand="onExpand"
|
|
227
248
|
@select="onSelected"
|
|
228
249
|
>
|
|
229
|
-
<template #title="{ title, dataRef }">
|
|
250
|
+
<template #title="{ title, dataRef, data }">
|
|
230
251
|
<div :class="`tree-node-tittle flex items-center ${dataRef.selectable ? 'selectable' : 'not-selectable'}`">
|
|
231
252
|
<div
|
|
232
253
|
v-if="!!dataRef.icon"
|
|
@@ -8,6 +8,7 @@ import HdBomTree from '../bom-tree/index'
|
|
|
8
8
|
|
|
9
9
|
const props = defineProps<Props>()
|
|
10
10
|
const COMPONENT_NAME = 'HdBomWorkbench'
|
|
11
|
+
const treeRef = ref()
|
|
11
12
|
defineOptions({
|
|
12
13
|
name: COMPONENT_NAME,
|
|
13
14
|
})
|
|
@@ -38,6 +39,14 @@ watch(
|
|
|
38
39
|
},
|
|
39
40
|
{ immediate: true },
|
|
40
41
|
)
|
|
42
|
+
|
|
43
|
+
async function withKeepTreeState(fn: any) {
|
|
44
|
+
treeRef.value.withKeepTreeState(fn)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
defineExpose({
|
|
48
|
+
withKeepTreeState,
|
|
49
|
+
})
|
|
41
50
|
</script>
|
|
42
51
|
|
|
43
52
|
<template>
|
|
@@ -51,12 +60,13 @@ watch(
|
|
|
51
60
|
<slot name="tree-header" />
|
|
52
61
|
<div class="bom-tree-container">
|
|
53
62
|
<HdBomTree
|
|
63
|
+
ref="treeRef"
|
|
54
64
|
:tree-data="bomDataForTree"
|
|
55
65
|
:config="props.treeConfig"
|
|
56
66
|
@select="(data: BomNode) => onSelected(data)"
|
|
57
67
|
>
|
|
58
|
-
<template #right-click>
|
|
59
|
-
<slot name="tree-right-click" :bom-node="
|
|
68
|
+
<template #right-click="{ treeNode }">
|
|
69
|
+
<slot name="tree-right-click" :bom-node="treeNode" />
|
|
60
70
|
</template>
|
|
61
71
|
</HdBomTree>
|
|
62
72
|
</div>
|
|
@@ -35,9 +35,11 @@ const treeContainerHeight = ref<number>(0)
|
|
|
35
35
|
const treeContainerId = 'treeContainer'
|
|
36
36
|
let keyToNodeMap = new Map<string, TreeNodeWithMeta>()
|
|
37
37
|
const selectedKeys = ref<string[]>([])
|
|
38
|
-
const
|
|
38
|
+
const keepTreeState = ref<boolean>(false)
|
|
39
|
+
const initTreeState = () => {
|
|
39
40
|
searchValue.value = ''
|
|
40
|
-
|
|
41
|
+
selectedKeys.value = []
|
|
42
|
+
expandedKeys.value = []
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
const onExpand = (keys: Key[]) => {
|
|
@@ -131,15 +133,12 @@ onBeforeUnmount(() => {
|
|
|
131
133
|
watch(
|
|
132
134
|
() => _treeData.value,
|
|
133
135
|
async () => {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
136
|
+
filteredTreeData.value = _treeData.value
|
|
137
|
+
keyToNodeMap = buildKeyToNodeMap(_treeData.value ?? [])
|
|
138
|
+
initTreeState()
|
|
139
|
+
if (!keepTreeState.value) {
|
|
137
140
|
selectFirstSelectableNode()
|
|
138
141
|
}
|
|
139
|
-
else {
|
|
140
|
-
keyToNodeMap.clear()
|
|
141
|
-
await initTreeState()
|
|
142
|
-
}
|
|
143
142
|
},
|
|
144
143
|
{
|
|
145
144
|
immediate: true,
|
|
@@ -199,6 +198,28 @@ function getTitlePart(title: string, partType: 'before' | 'after') {
|
|
|
199
198
|
function hasSearchMatch(title: string) {
|
|
200
199
|
return searchValue.value && title.includes(searchValue.value)
|
|
201
200
|
}
|
|
201
|
+
|
|
202
|
+
async function withKeepTreeState(updateDataFn: () => Promise<void>) {
|
|
203
|
+
const prevSelected = selectedKeys.value?.[0]
|
|
204
|
+
const prevExpanded = [...expandedKeys.value]
|
|
205
|
+
keepTreeState.value = true
|
|
206
|
+
await updateDataFn()
|
|
207
|
+
await nextTick(() => {
|
|
208
|
+
expandedKeys.value = prevExpanded.filter(key => keyToNodeMap.has(key as string))
|
|
209
|
+
|
|
210
|
+
if (prevSelected && keyToNodeMap.has(prevSelected)) {
|
|
211
|
+
selectedKeys.value = [prevSelected]
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
selectFirstSelectableNode()
|
|
215
|
+
}
|
|
216
|
+
keepTreeState.value = false
|
|
217
|
+
})
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
defineExpose({
|
|
221
|
+
withKeepTreeState,
|
|
222
|
+
})
|
|
202
223
|
</script>
|
|
203
224
|
|
|
204
225
|
<template>
|
|
@@ -226,7 +247,7 @@ function hasSearchMatch(title: string) {
|
|
|
226
247
|
@expand="onExpand"
|
|
227
248
|
@select="onSelected"
|
|
228
249
|
>
|
|
229
|
-
<template #title="{ title, dataRef }">
|
|
250
|
+
<template #title="{ title, dataRef, data }">
|
|
230
251
|
<div :class="`tree-node-tittle flex items-center ${dataRef.selectable ? 'selectable' : 'not-selectable'}`">
|
|
231
252
|
<div
|
|
232
253
|
v-if="!!dataRef.icon"
|
|
@@ -8,6 +8,7 @@ import HdBomTree from '../bom-tree/index'
|
|
|
8
8
|
|
|
9
9
|
const props = defineProps<Props>()
|
|
10
10
|
const COMPONENT_NAME = 'HdBomWorkbench'
|
|
11
|
+
const treeRef = ref()
|
|
11
12
|
defineOptions({
|
|
12
13
|
name: COMPONENT_NAME,
|
|
13
14
|
})
|
|
@@ -38,6 +39,14 @@ watch(
|
|
|
38
39
|
},
|
|
39
40
|
{ immediate: true },
|
|
40
41
|
)
|
|
42
|
+
|
|
43
|
+
async function withKeepTreeState(fn: any) {
|
|
44
|
+
treeRef.value.withKeepTreeState(fn)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
defineExpose({
|
|
48
|
+
withKeepTreeState,
|
|
49
|
+
})
|
|
41
50
|
</script>
|
|
42
51
|
|
|
43
52
|
<template>
|
|
@@ -51,12 +60,13 @@ watch(
|
|
|
51
60
|
<slot name="tree-header" />
|
|
52
61
|
<div class="bom-tree-container">
|
|
53
62
|
<HdBomTree
|
|
63
|
+
ref="treeRef"
|
|
54
64
|
:tree-data="bomDataForTree"
|
|
55
65
|
:config="props.treeConfig"
|
|
56
66
|
@select="(data: BomNode) => onSelected(data)"
|
|
57
67
|
>
|
|
58
|
-
<template #right-click>
|
|
59
|
-
<slot name="tree-right-click" :bom-node="
|
|
68
|
+
<template #right-click="{ treeNode }">
|
|
69
|
+
<slot name="tree-right-click" :bom-node="treeNode" />
|
|
60
70
|
</template>
|
|
61
71
|
</HdBomTree>
|
|
62
72
|
</div>
|
package/dist/style.css
CHANGED
|
@@ -83,4 +83,5 @@
|
|
|
83
83
|
.blur{--un-blur:blur(8px);filter:var(--un-blur) var(--un-brightness) var(--un-contrast) var(--un-drop-shadow) var(--un-grayscale) var(--un-hue-rotate) var(--un-invert) var(--un-saturate) var(--un-sepia);}
|
|
84
84
|
.filter{filter:var(--un-blur) var(--un-brightness) var(--un-contrast) var(--un-drop-shadow) var(--un-grayscale) var(--un-hue-rotate) var(--un-invert) var(--un-saturate) var(--un-sepia);}
|
|
85
85
|
.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:150ms;}
|
|
86
|
-
.ease
|
|
86
|
+
.ease,
|
|
87
|
+
[ease=""]{transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@handaotech-design/bom",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.26",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"exports": {
|
|
@@ -21,22 +21,28 @@
|
|
|
21
21
|
"module": "./dist/es/index.js",
|
|
22
22
|
"types": "./dist/es/index.d.ts",
|
|
23
23
|
"scripts": {
|
|
24
|
-
"build": "pnpm run build:unocss
|
|
24
|
+
"build": "unbuild && pnpm run build:unocss",
|
|
25
25
|
"build:unocss": "unocss '**/*.{vue,ts}' -o dist/style.css",
|
|
26
26
|
"stub": "pnpm run build:unocss && unbuild --stub"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"
|
|
29
|
+
"vue": "*",
|
|
30
|
+
"vue-types": "*",
|
|
31
|
+
"ant-design-vue": "*",
|
|
32
|
+
"@vueuse/core": "*",
|
|
33
|
+
"@handaotech-design/vue": "workspace:*",
|
|
34
|
+
"lodash-es": "*"
|
|
30
35
|
},
|
|
31
36
|
"devDependencies": {
|
|
32
37
|
"sass": "*",
|
|
33
38
|
"unocss": "*"
|
|
34
39
|
},
|
|
35
|
-
"
|
|
40
|
+
"peerDependenciesMeta": {
|
|
36
41
|
"vue": "*",
|
|
37
42
|
"vue-types": "*",
|
|
38
43
|
"ant-design-vue": "*",
|
|
39
44
|
"@vueuse/core": "*",
|
|
45
|
+
"@handaotech-design/vue": "workspace:*",
|
|
40
46
|
"lodash-es": "*"
|
|
41
47
|
},
|
|
42
48
|
"author": "HD",
|