@bimdata/design-system 2.1.0-rc.2 → 2.1.0-rc.21
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/package.json +2 -2
- package/src/BIMDataComponents/BIMDataDropdownList/BIMDataDropdownList.vue +10 -0
- package/src/BIMDataComponents/BIMDataDropdownList/_BIMDataDropdownList.scss +0 -1
- package/src/BIMDataComponents/BIMDataDropdownMenu/_BIMDataDropdownMenu.scss +0 -1
- package/src/BIMDataComponents/BIMDataIcon/BIMDataIconStandalone/BIMDataIconAddGavel.vue +19 -0
- package/src/BIMDataComponents/BIMDataIcon/BIMDataIconStandalone/BIMDataIconAddList.vue +19 -0
- package/src/BIMDataComponents/BIMDataIcon/BIMDataIconStandalone/BIMDataIconCaret.vue +19 -0
- package/src/BIMDataComponents/BIMDataIcon/BIMDataIconStandalone/BIMDataIconCreateSpace.vue +20 -0
- package/src/BIMDataComponents/BIMDataIcon/BIMDataIconStandalone/BIMDataIconCreateZone.vue +20 -0
- package/src/BIMDataComponents/BIMDataIcon/BIMDataIconStandalone/{BIMDataIconDeploy.vue → BIMDataIconGavel.vue} +3 -3
- package/src/BIMDataComponents/BIMDataIcon/BIMDataIconStandalone/BIMDataIconNamingConvention.vue +20 -0
- package/src/BIMDataComponents/BIMDataIcon/BIMDataIconStandalone/BIMDataIconPlan.vue +20 -0
- package/src/BIMDataComponents/BIMDataIcon/BIMDataIconStandalone/BIMDataIconRotate.vue +20 -0
- package/src/BIMDataComponents/BIMDataIcon/BIMDataIconStandalone/BIMDataIconSpace2.vue +19 -0
- package/src/BIMDataComponents/BIMDataIcon/BIMDataIconStandalone/BIMDataIconZone2.vue +19 -0
- package/src/BIMDataComponents/BIMDataIcon/BIMDataIconStandalone/index.js +11 -1
- package/src/BIMDataComponents/BIMDataIcon/BIMDataLibraryIcons/AddGavel.vue +21 -0
- package/src/BIMDataComponents/BIMDataIcon/BIMDataLibraryIcons/AddList.vue +27 -0
- package/src/BIMDataComponents/BIMDataIcon/BIMDataLibraryIcons/Caret.vue +3 -0
- package/src/BIMDataComponents/BIMDataIcon/BIMDataLibraryIcons/CreateSpace.vue +17 -0
- package/src/BIMDataComponents/BIMDataIcon/BIMDataLibraryIcons/CreateZone.vue +32 -0
- package/src/BIMDataComponents/BIMDataIcon/BIMDataLibraryIcons/Gavel.vue +5 -0
- package/src/BIMDataComponents/BIMDataIcon/BIMDataLibraryIcons/List.vue +6 -12
- package/src/BIMDataComponents/BIMDataIcon/BIMDataLibraryIcons/NamingConvention.vue +12 -0
- package/src/BIMDataComponents/BIMDataIcon/BIMDataLibraryIcons/Plan.vue +7 -0
- package/src/BIMDataComponents/BIMDataIcon/BIMDataLibraryIcons/Rotate.vue +21 -0
- package/src/BIMDataComponents/BIMDataIcon/BIMDataLibraryIcons/Space2.vue +9 -0
- package/src/BIMDataComponents/BIMDataIcon/BIMDataLibraryIcons/Zone2.vue +24 -0
- package/src/BIMDataComponents/BIMDataIcon/BIMDataLibraryIcons/index.js +22 -2
- package/src/BIMDataComponents/BIMDataIllustration/BIMDataLibraryIllustrations/CreateList.vue +214 -0
- package/src/BIMDataComponents/BIMDataIllustration/BIMDataLibraryIllustrations/EmptyNamingConvention.vue +47 -0
- package/src/BIMDataComponents/BIMDataIllustration/BIMDataLibraryIllustrations/ManageList.vue +206 -0
- package/src/BIMDataComponents/BIMDataIllustration/BIMDataLibraryIllustrations/RenameFile.vue +175 -0
- package/src/BIMDataComponents/BIMDataIllustration/BIMDataLibraryIllustrations/ShortcutMoveDwg.vue +145 -0
- package/src/BIMDataComponents/BIMDataIllustration/BIMDataLibraryIllustrations/ShortcutMovePlan.vue +181 -0
- package/src/BIMDataComponents/BIMDataIllustration/BIMDataLibraryIllustrations/ShortcutOpenDwg.vue +142 -0
- package/src/BIMDataComponents/BIMDataIllustration/BIMDataLibraryIllustrations/ShortcutOpenPlan.vue +178 -0
- package/src/BIMDataComponents/BIMDataIllustration/BIMDataLibraryIllustrations/ShortcutRotateDwg.vue +123 -0
- package/src/BIMDataComponents/BIMDataIllustration/BIMDataLibraryIllustrations/ShortcutRotatePlan.vue +159 -0
- package/src/BIMDataComponents/BIMDataIllustration/BIMDataLibraryIllustrations/ShortcutZoomDwg.vue +100 -0
- package/src/BIMDataComponents/BIMDataIllustration/BIMDataLibraryIllustrations/ShortcutZoomPlan.vue +136 -0
- package/src/BIMDataComponents/BIMDataIllustration/BIMDataLibraryIllustrations/index.js +26 -2
- package/src/BIMDataComponents/BIMDataInput/BIMDataInput.vue +3 -2
- package/src/BIMDataComponents/BIMDataInput/_BIMDataInput.scss +8 -8
- package/src/BIMDataComponents/BIMDataInputOutlined/BIMDataInputOutlined.vue +182 -0
- package/src/BIMDataComponents/BIMDataInputOutlined/_BIMDataInputOutlined.scss +96 -0
- package/src/BIMDataComponents/BIMDataSearch/BIMDataSearch.vue +6 -1
- package/src/BIMDataComponents/BIMDataSearch/_BIMDataSearch.scss +6 -0
- package/src/BIMDataComponents/BIMDataSelect/BIMDataSelectMulti.vue +24 -7
- package/src/BIMDataComponents/BIMDataSelect/BIMDataSelectSingle.vue +23 -6
- package/src/BIMDataComponents/BIMDataSlider/_BIMDataSlider.scss +2 -0
- package/src/BIMDataComponents/BIMDataTable/BIMDataTable.vue +224 -35
- package/src/BIMDataComponents/BIMDataTable/_BIMDataTable.scss +4 -0
- package/src/BIMDataComponents/BIMDataTable/column-filters/ColumnFilters.vue +91 -0
- package/src/BIMDataComponents/BIMDataTable/column-filters/_ColumnFilters.scss +14 -0
- package/src/BIMDataComponents/BIMDataTable/column-sorting/ColumnSorting.vue +66 -0
- package/src/BIMDataComponents/BIMDataTree/BIMDataTree.vue +123 -0
- package/src/BIMDataComponents/BIMDataTree/Node.vue +241 -0
- package/src/BIMDataComponents/BIMDataTree/state.js +239 -0
- package/src/BIMDataComponents/index.js +2 -0
- package/src/BIMDataComponents/BIMDataIcon/BIMDataLibraryIcons/Deploy.vue +0 -3
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="bimdata-tree"
|
|
4
|
+
@mousedown="onTreeMouseDown"
|
|
5
|
+
@mouseenter="onMouseEnter"
|
|
6
|
+
@mouseleave="onMouseLeave"
|
|
7
|
+
@mouseup.self="onMouseUp"
|
|
8
|
+
>
|
|
9
|
+
<div class="bimdata-tree__nodes" @mouseleave="onNodesMouseLeave">
|
|
10
|
+
<Node v-for="node of data" :key="node.id" :node="node">
|
|
11
|
+
<slot
|
|
12
|
+
name="node"
|
|
13
|
+
:node="node"
|
|
14
|
+
:depth="0"
|
|
15
|
+
:selected="node.id === state.selectedId"
|
|
16
|
+
:hovered="node.id === state.hoveredNode?.id"
|
|
17
|
+
:ancestor-selected="state.hasAncestorSelected(node)"
|
|
18
|
+
/>
|
|
19
|
+
</Node>
|
|
20
|
+
</div>
|
|
21
|
+
<div v-if="dropHelperDisplayed" class="bimdata-tree__drop-helper"></div>
|
|
22
|
+
</div>
|
|
23
|
+
</template>
|
|
24
|
+
|
|
25
|
+
<script>
|
|
26
|
+
import { provide, computed, ref } from "vue";
|
|
27
|
+
|
|
28
|
+
import Node from "./Node.vue";
|
|
29
|
+
|
|
30
|
+
import useState from "./state.js";
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @typedef { Object } Node
|
|
34
|
+
* @property { number } id
|
|
35
|
+
* @property { Array } [children=null]
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
export default {
|
|
39
|
+
components: {
|
|
40
|
+
Node,
|
|
41
|
+
},
|
|
42
|
+
provide() {
|
|
43
|
+
return {
|
|
44
|
+
root: this,
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
props: {
|
|
48
|
+
/**
|
|
49
|
+
* @type { NodeData }
|
|
50
|
+
*/
|
|
51
|
+
data: {
|
|
52
|
+
type: Array,
|
|
53
|
+
required: true,
|
|
54
|
+
validator: value => {
|
|
55
|
+
if (!Array.isArray(value)) return false;
|
|
56
|
+
|
|
57
|
+
const ids = new Set();
|
|
58
|
+
|
|
59
|
+
for (const node of value) {
|
|
60
|
+
if (!Number.isFinite(node?.id)) return false;
|
|
61
|
+
if (node.children && !Array.isArray(node.children)) return false;
|
|
62
|
+
ids.add(node.id);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return ids.size === value.length;
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
selectedId: {
|
|
69
|
+
type: Number,
|
|
70
|
+
default: null,
|
|
71
|
+
},
|
|
72
|
+
highlightedId: {
|
|
73
|
+
type: Number,
|
|
74
|
+
default: null,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
emits: ["drop", "click", "hover"],
|
|
78
|
+
setup(props, { emit }) {
|
|
79
|
+
const state = useState(props, emit);
|
|
80
|
+
|
|
81
|
+
provide("state", state);
|
|
82
|
+
|
|
83
|
+
const onNodesMouseLeave = () => state.onNodesMouseLeave();
|
|
84
|
+
const onTreeMouseDown = () => state.onTreeMouseDown();
|
|
85
|
+
|
|
86
|
+
const hover = ref(false);
|
|
87
|
+
const onMouseEnter = () => {
|
|
88
|
+
hover.value = true;
|
|
89
|
+
};
|
|
90
|
+
const onMouseLeave = () => {
|
|
91
|
+
hover.value = false;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const onMouseUp = () => state.onTreeMouseUp();
|
|
95
|
+
|
|
96
|
+
const dropHelperDisplayed = computed(
|
|
97
|
+
() =>
|
|
98
|
+
hover.value && state.dragPosition !== null && state.hoveredNode === null
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
state,
|
|
103
|
+
dropHelperDisplayed,
|
|
104
|
+
onMouseEnter,
|
|
105
|
+
onMouseLeave,
|
|
106
|
+
onNodesMouseLeave,
|
|
107
|
+
onTreeMouseDown,
|
|
108
|
+
onMouseUp,
|
|
109
|
+
};
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
</script>
|
|
113
|
+
|
|
114
|
+
<style scoped lang="scss">
|
|
115
|
+
.bimdata-tree {
|
|
116
|
+
height: 100%;
|
|
117
|
+
|
|
118
|
+
&__drop-helper {
|
|
119
|
+
height: 2px;
|
|
120
|
+
background-color: var(--color-primary);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
</style>
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
ref="nodeRef"
|
|
4
|
+
class="bimdata-tree__node"
|
|
5
|
+
:class="{
|
|
6
|
+
'bimdata-tree__node--selected': node.id === state.selectedId,
|
|
7
|
+
'bimdata-tree__node--ancestor-selected': hasAncestorSelected(node),
|
|
8
|
+
'bimdata-tree__node--highlighted': node.id === state.highlightedId,
|
|
9
|
+
}"
|
|
10
|
+
@mouseenter="onMouseEnter"
|
|
11
|
+
@mousedown="onMouseDown"
|
|
12
|
+
@mousemove="onMouseMove"
|
|
13
|
+
@mouseup="onMouseUp"
|
|
14
|
+
>
|
|
15
|
+
<div
|
|
16
|
+
v-if="dropHelperPosition === 'top' || dropHelperPosition === 'bottom'"
|
|
17
|
+
class="bimdata-tree__node__drop-helper"
|
|
18
|
+
:style="`--drop-helper-top: ${
|
|
19
|
+
dropHelperPosition === 'top' ? '0px' : '30px'
|
|
20
|
+
};`"
|
|
21
|
+
></div>
|
|
22
|
+
<div
|
|
23
|
+
class="bimdata-tree__node__content"
|
|
24
|
+
:style="`padding-left: calc(var(--spacing-unit) * 2 * ${depth});`"
|
|
25
|
+
>
|
|
26
|
+
<div class="bimdata-tree__node__content__arrow" @mousedown.stop>
|
|
27
|
+
<div
|
|
28
|
+
v-if="node.children?.length > 0"
|
|
29
|
+
class="bimdata-tree__node__content__arrow__content"
|
|
30
|
+
@click="expanded = !expanded"
|
|
31
|
+
>
|
|
32
|
+
<BIMDataIcon name="chevron" size="xxxs" :rotate="expanded ? 90 : 0" />
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
<div class="bimdata-tree__node__content__element">
|
|
37
|
+
<slot>
|
|
38
|
+
{{ node.label }}
|
|
39
|
+
</slot>
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
<NodeChildren
|
|
44
|
+
v-if="node.children?.length > 0 && expanded"
|
|
45
|
+
:node="node"
|
|
46
|
+
:depth="depth + 1"
|
|
47
|
+
/>
|
|
48
|
+
</template>
|
|
49
|
+
|
|
50
|
+
<script>
|
|
51
|
+
import { inject, ref, computed, watch, isRef, h } from "vue";
|
|
52
|
+
|
|
53
|
+
let Node, NodeChildren;
|
|
54
|
+
|
|
55
|
+
NodeChildren = {
|
|
56
|
+
inject: ["root"],
|
|
57
|
+
props: {
|
|
58
|
+
node: {
|
|
59
|
+
type: Object,
|
|
60
|
+
required: true,
|
|
61
|
+
validator: node => Number.isFinite(node?.id),
|
|
62
|
+
},
|
|
63
|
+
depth: {
|
|
64
|
+
type: Number,
|
|
65
|
+
default: 0,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
render() {
|
|
69
|
+
const { node, depth, root } = this;
|
|
70
|
+
|
|
71
|
+
const state = root.state;
|
|
72
|
+
|
|
73
|
+
return node.children.map(child =>
|
|
74
|
+
h(Node, { node: child, depth, key: child.id }, () =>
|
|
75
|
+
root.$slots.node?.({
|
|
76
|
+
node: child,
|
|
77
|
+
depth,
|
|
78
|
+
selected: child.id === state.selectedId,
|
|
79
|
+
hovered: child.id === state.hoveredNode?.id,
|
|
80
|
+
ancestorSelected: state.hasAncestorSelected(child),
|
|
81
|
+
})
|
|
82
|
+
)
|
|
83
|
+
);
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
Node = {
|
|
88
|
+
name: "Node",
|
|
89
|
+
components: {
|
|
90
|
+
NodeChildren,
|
|
91
|
+
},
|
|
92
|
+
inject: ["root"],
|
|
93
|
+
props: {
|
|
94
|
+
node: {
|
|
95
|
+
type: Object,
|
|
96
|
+
required: true,
|
|
97
|
+
},
|
|
98
|
+
depth: {
|
|
99
|
+
type: Number,
|
|
100
|
+
default: 0,
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
setup(props) {
|
|
104
|
+
const state = inject("state");
|
|
105
|
+
|
|
106
|
+
let expanded = null;
|
|
107
|
+
if (isRef(props.node.expandedRef)) {
|
|
108
|
+
expanded = props.node.expandedRef;
|
|
109
|
+
} else {
|
|
110
|
+
expanded = ref(false);
|
|
111
|
+
}
|
|
112
|
+
const nodeRef = ref(null);
|
|
113
|
+
|
|
114
|
+
let expandTimer = null;
|
|
115
|
+
|
|
116
|
+
const handleExpandTimer = () => {
|
|
117
|
+
if (
|
|
118
|
+
!props.node.children?.length ||
|
|
119
|
+
!state.dragPosition ||
|
|
120
|
+
state.hoveredNode?.id !== props.node.id ||
|
|
121
|
+
expanded.value
|
|
122
|
+
) {
|
|
123
|
+
clearTimeout(expandTimer);
|
|
124
|
+
expandTimer = null;
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const position = state.getNodeDropPosition(props.node, nodeRef.value);
|
|
129
|
+
|
|
130
|
+
if (position !== "center" && position !== "bottom") {
|
|
131
|
+
clearTimeout(expandTimer);
|
|
132
|
+
expandTimer = null;
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (expandTimer !== null) return;
|
|
137
|
+
|
|
138
|
+
expandTimer = setTimeout(() => {
|
|
139
|
+
expanded.value = true;
|
|
140
|
+
expandTimer = null;
|
|
141
|
+
}, 500);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
watch(() => state.dragPosition && state.hoveredNode, handleExpandTimer);
|
|
145
|
+
|
|
146
|
+
const onMouseEnter = () => state.onNodeMouseEnter(props.node);
|
|
147
|
+
|
|
148
|
+
const onMouseDown = mouseEvent =>
|
|
149
|
+
state.onNodeMouseDown(props.node, mouseEvent);
|
|
150
|
+
|
|
151
|
+
const onMouseMove = mouseEvent => {
|
|
152
|
+
state.onNodeMouseMove(mouseEvent);
|
|
153
|
+
handleExpandTimer();
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
const dropHelperPosition = computed(() => {
|
|
157
|
+
if (!state.dragPosition || state.hoveredNode?.id !== props.node.id)
|
|
158
|
+
return null;
|
|
159
|
+
|
|
160
|
+
return state.getNodeDropPosition(props.node, nodeRef.value);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
const onMouseUp = () =>
|
|
164
|
+
state.onNodeMouseUp(props.node, nodeRef.value, expanded.value);
|
|
165
|
+
|
|
166
|
+
return {
|
|
167
|
+
state,
|
|
168
|
+
nodeRef,
|
|
169
|
+
expanded,
|
|
170
|
+
dropHelperPosition,
|
|
171
|
+
hasAncestorSelected: state.hasAncestorSelected,
|
|
172
|
+
onMouseEnter,
|
|
173
|
+
onMouseDown,
|
|
174
|
+
onMouseMove,
|
|
175
|
+
onMouseUp,
|
|
176
|
+
};
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
export default Node;
|
|
181
|
+
</script>
|
|
182
|
+
|
|
183
|
+
<style scoped lang="scss">
|
|
184
|
+
.bimdata-tree__node {
|
|
185
|
+
height: 32px;
|
|
186
|
+
display: flex;
|
|
187
|
+
align-items: center;
|
|
188
|
+
position: relative;
|
|
189
|
+
|
|
190
|
+
user-select: none;
|
|
191
|
+
|
|
192
|
+
&__drop-helper {
|
|
193
|
+
position: absolute;
|
|
194
|
+
left: 0px;
|
|
195
|
+
right: 0px;
|
|
196
|
+
height: 2px;
|
|
197
|
+
top: var(--drop-helper-top);
|
|
198
|
+
background-color: var(--color-primary);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
&--selected {
|
|
202
|
+
background-color: var(--color-secondary-light);
|
|
203
|
+
}
|
|
204
|
+
&--ancestor-selected {
|
|
205
|
+
background-color: var(--color-secondary-lighter);
|
|
206
|
+
}
|
|
207
|
+
&--highlighted {
|
|
208
|
+
outline-offset: -1px;
|
|
209
|
+
outline: solid var(--color-primary) 1px;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
&__content {
|
|
213
|
+
width: 100%;
|
|
214
|
+
height: 100%;
|
|
215
|
+
display: flex;
|
|
216
|
+
border-radius: 6px;
|
|
217
|
+
padding: 0 calc(var(--spacing-unit) / 2);
|
|
218
|
+
|
|
219
|
+
&__arrow {
|
|
220
|
+
width: 18px;
|
|
221
|
+
flex-shrink: 0;
|
|
222
|
+
|
|
223
|
+
&__content {
|
|
224
|
+
cursor: pointer;
|
|
225
|
+
height: 100%;
|
|
226
|
+
display: flex;
|
|
227
|
+
justify-content: center;
|
|
228
|
+
align-items: center;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
&__element {
|
|
233
|
+
padding-left: calc(var(--spacing-unit) / 2);
|
|
234
|
+
width: calc(100% - 18px);
|
|
235
|
+
height: 100%;
|
|
236
|
+
display: flex;
|
|
237
|
+
align-items: center;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
</style>
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { shallowReactive, watch, shallowRef } from "vue";
|
|
2
|
+
|
|
3
|
+
export default function useState(props, emit) {
|
|
4
|
+
const state = shallowReactive({
|
|
5
|
+
selectedId: null,
|
|
6
|
+
highlightedId: null,
|
|
7
|
+
hoveredNode: null,
|
|
8
|
+
trees: props.data,
|
|
9
|
+
dragPosition: null,
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
watch(
|
|
13
|
+
() => props.selectedId,
|
|
14
|
+
() => {
|
|
15
|
+
state.selectedId = props.selectedId ?? null;
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
watch(
|
|
20
|
+
() => props.highlightedId,
|
|
21
|
+
() => {
|
|
22
|
+
state.highlightedId = props.highlightedId ?? null;
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
watch(
|
|
27
|
+
() => state.hoveredNode,
|
|
28
|
+
() => emit("hover", state.hoveredNode)
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const pressedNode = shallowRef(null);
|
|
32
|
+
|
|
33
|
+
watch(
|
|
34
|
+
() => props.data,
|
|
35
|
+
trees => {
|
|
36
|
+
state.trees = trees;
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
const onMouseUp = () => {
|
|
41
|
+
pressedNode.value = null;
|
|
42
|
+
state.dragPosition = null;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const onNodeMouseEnter = node => {
|
|
46
|
+
state.hoveredNode = node;
|
|
47
|
+
};
|
|
48
|
+
const onNodeMouseDown = (node, event) => {
|
|
49
|
+
event.stopPropagation();
|
|
50
|
+
|
|
51
|
+
emit("click", node);
|
|
52
|
+
|
|
53
|
+
pressedNode.value = node;
|
|
54
|
+
|
|
55
|
+
window.addEventListener("mouseup", onMouseUp, { once: true });
|
|
56
|
+
};
|
|
57
|
+
const onNodeMouseMove = event => {
|
|
58
|
+
if (!pressedNode.value) return;
|
|
59
|
+
|
|
60
|
+
const { clientX, clientY } = event;
|
|
61
|
+
|
|
62
|
+
state.dragPosition = { x: clientX, y: clientY };
|
|
63
|
+
};
|
|
64
|
+
const onNodeMouseUp = (node, domElement, expanded) => {
|
|
65
|
+
if (!state.dragPosition) return;
|
|
66
|
+
|
|
67
|
+
if (state.hoveredNode?.id === pressedNode.value?.id) return;
|
|
68
|
+
|
|
69
|
+
if (state.isDescendant(node, pressedNode.value)) return;
|
|
70
|
+
|
|
71
|
+
const position = getNodeDropPosition(node, domElement);
|
|
72
|
+
|
|
73
|
+
let parent = null;
|
|
74
|
+
let index = null;
|
|
75
|
+
const previousParent = getParent(pressedNode.value);
|
|
76
|
+
|
|
77
|
+
switch (position) {
|
|
78
|
+
case "top":
|
|
79
|
+
parent = getParent(node);
|
|
80
|
+
index = (parent?.children ?? state.trees).findIndex(
|
|
81
|
+
child => child.id === node.id
|
|
82
|
+
);
|
|
83
|
+
break;
|
|
84
|
+
case "bottom":
|
|
85
|
+
if (node.children && expanded) {
|
|
86
|
+
parent = node;
|
|
87
|
+
index = 0;
|
|
88
|
+
} else {
|
|
89
|
+
parent = getParent(node);
|
|
90
|
+
index =
|
|
91
|
+
(parent?.children ?? state.trees).findIndex(
|
|
92
|
+
child => child.id === node.id
|
|
93
|
+
) + 1;
|
|
94
|
+
}
|
|
95
|
+
break;
|
|
96
|
+
case "center":
|
|
97
|
+
parent = node;
|
|
98
|
+
index = 0;
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const reorder = parent?.id === previousParent?.id;
|
|
103
|
+
const previousIndex = (previousParent?.children ?? state.trees).findIndex(
|
|
104
|
+
child => child.id === pressedNode.value.id
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
if (
|
|
108
|
+
reorder &&
|
|
109
|
+
(position === "top" || position === "bottom") &&
|
|
110
|
+
previousIndex < index
|
|
111
|
+
) {
|
|
112
|
+
index--;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (reorder && index === previousIndex) return;
|
|
116
|
+
|
|
117
|
+
emit("drop", {
|
|
118
|
+
node: pressedNode.value,
|
|
119
|
+
previousParent,
|
|
120
|
+
parent,
|
|
121
|
+
index,
|
|
122
|
+
position,
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const onNodesMouseLeave = () => {
|
|
127
|
+
state.hoveredNode = null;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const onTreeMouseDown = () => {
|
|
131
|
+
emit("click", null);
|
|
132
|
+
};
|
|
133
|
+
const onTreeMouseUp = () => {
|
|
134
|
+
if (!state.dragPosition) return;
|
|
135
|
+
|
|
136
|
+
if (state.trees.indexOf(pressedNode.value) === state.trees.length - 1) {
|
|
137
|
+
// to drop the last root node at the end of the list does not fire the drop event
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const nodeIsInRootPosition = state.trees.includes(pressedNode.value);
|
|
142
|
+
|
|
143
|
+
emit("drop", {
|
|
144
|
+
node: pressedNode.value,
|
|
145
|
+
parent: null,
|
|
146
|
+
index: nodeIsInRootPosition ? state.trees.length - 1 : state.trees.length,
|
|
147
|
+
previousParent: getParent(pressedNode.value),
|
|
148
|
+
});
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
state.onNodeMouseEnter = onNodeMouseEnter;
|
|
152
|
+
state.onNodeMouseDown = onNodeMouseDown;
|
|
153
|
+
state.onNodeMouseMove = onNodeMouseMove;
|
|
154
|
+
state.onNodeMouseUp = onNodeMouseUp;
|
|
155
|
+
|
|
156
|
+
state.onNodesMouseLeave = onNodesMouseLeave;
|
|
157
|
+
|
|
158
|
+
state.onTreeMouseDown = onTreeMouseDown;
|
|
159
|
+
state.onTreeMouseUp = onTreeMouseUp;
|
|
160
|
+
|
|
161
|
+
// UTILS
|
|
162
|
+
|
|
163
|
+
const getNodeDropPosition = (node, domElement) => {
|
|
164
|
+
const { y } = state.dragPosition;
|
|
165
|
+
|
|
166
|
+
const { top, height } = domElement.getBoundingClientRect();
|
|
167
|
+
|
|
168
|
+
if (node.children) {
|
|
169
|
+
if (y < top + height / 3) return "top";
|
|
170
|
+
if (y > top + (height * 2) / 3) return "bottom";
|
|
171
|
+
|
|
172
|
+
return "center";
|
|
173
|
+
} else {
|
|
174
|
+
if (y < top + height / 2) return "top";
|
|
175
|
+
|
|
176
|
+
return "bottom";
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const getParent = (node, nodes = state.trees) => {
|
|
181
|
+
for (const childNode of nodes) {
|
|
182
|
+
if (childNode.children?.length) {
|
|
183
|
+
if (childNode.children.some(child => child.id === node.id)) {
|
|
184
|
+
return childNode;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const expectedParent = getParent(node, childNode.children);
|
|
188
|
+
|
|
189
|
+
if (expectedParent) return expectedParent;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
const isAncestor = (node, nodes = state.trees) => {
|
|
195
|
+
for (const childNode of nodes) {
|
|
196
|
+
if (childNode.id === node.id) {
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
199
|
+
if (childNode.children?.length && isAncestor(node, childNode.children)) {
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return false;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
const getAncestors = (node, nodes = state.trees) => {
|
|
207
|
+
const ancestors = [];
|
|
208
|
+
for (const childNode of nodes) {
|
|
209
|
+
if (childNode.id === node.id) {
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
if (childNode.children?.length && isAncestor(node, childNode.children)) {
|
|
213
|
+
ancestors.push(childNode, ...getAncestors(node, childNode.children));
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return ancestors;
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
const hasAncestorSelected = node => {
|
|
220
|
+
if (state.selectedId === null) return false;
|
|
221
|
+
|
|
222
|
+
return getAncestors(node).some(
|
|
223
|
+
ancestor => ancestor.id === state.selectedId
|
|
224
|
+
);
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
const isDescendant = (node, ancestor) =>
|
|
228
|
+
ancestor?.children?.some(
|
|
229
|
+
child => child.id === node.id || isDescendant(node, child)
|
|
230
|
+
) ?? false;
|
|
231
|
+
|
|
232
|
+
state.getNodeDropPosition = getNodeDropPosition;
|
|
233
|
+
state.getParent = getParent;
|
|
234
|
+
state.getAncestors = getAncestors;
|
|
235
|
+
state.hasAncestorSelected = hasAncestorSelected;
|
|
236
|
+
state.isDescendant = isDescendant;
|
|
237
|
+
|
|
238
|
+
return state;
|
|
239
|
+
}
|
|
@@ -21,6 +21,7 @@ export { default as BIMDataIcon } from "./BIMDataIcon/BIMDataIcon.vue";
|
|
|
21
21
|
export * from "./BIMDataIcon/BIMDataIconStandalone/index.js";
|
|
22
22
|
export { default as BIMDataIllustration } from "./BIMDataIllustration/BIMDataIllustration.vue";
|
|
23
23
|
export { default as BIMDataInput } from "./BIMDataInput/BIMDataInput.vue";
|
|
24
|
+
export { default as BIMDataInputOutlined } from "./BIMDataInputOutlined/BIMDataInputOutlined.vue";
|
|
24
25
|
export { default as BIMDataLoading } from "./BIMDataLoading/BIMDataLoading.vue";
|
|
25
26
|
export { default as BIMDataMenu } from "./BIMDataMenu/BIMDataMenu.vue";
|
|
26
27
|
export { default as BIMDataMenuInline } from "./BIMDataMenuInline/BIMDataMenuInline.vue";
|
|
@@ -43,3 +44,4 @@ export { default as BIMDataTextarea } from "./BIMDataTextarea/BIMDataTextarea.vu
|
|
|
43
44
|
export { default as BIMDataTextbox } from "./BIMDataTextbox/BIMDataTextbox.vue";
|
|
44
45
|
export { default as BIMDataToggle } from "./BIMDataToggle/BIMDataToggle.vue";
|
|
45
46
|
export { default as BIMDataTooltip } from "./BIMDataTooltip/BIMDataTooltip.vue";
|
|
47
|
+
export { default as BIMDataTree } from "./BIMDataTree/BIMDataTree.vue";
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<path fill-rule="evenodd" clip-rule="evenodd" d="M21.7691 6.1512C21.6937 6.0816 21.5704 6.0816 21.4948 6.1512L12.4466 14.5036L3.43681 6.18704C3.36141 6.11725 3.23794 6.11725 3.16253 6.18704L1.02253 8.16243C0.946918 8.23204 0.946918 8.34601 1.02253 8.41562L12.2989 18.8247C12.373 18.8932 12.4934 18.894 12.569 18.828C12.5923 18.8192 12.614 18.8061 12.6327 18.7889L23.9093 8.37977C23.9847 8.31017 23.9847 8.19619 23.9093 8.12659L21.7691 6.1512Z"/>
|
|
3
|
-
</template>
|