@bimdata/design-system 2.1.0-rc.21 → 2.1.0-rc.22

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bimdata/design-system",
3
- "version": "2.1.0-rc.21",
3
+ "version": "2.1.0-rc.22",
4
4
  "main": "./src/BIMDataComponents/index.js",
5
5
  "module": "./src/BIMDataComponents/index.js",
6
6
  "files": [
@@ -7,7 +7,12 @@
7
7
  @mouseup.self="onMouseUp"
8
8
  >
9
9
  <div class="bimdata-tree__nodes" @mouseleave="onNodesMouseLeave">
10
- <Node v-for="node of data" :key="node.id" :node="node">
10
+ <Node
11
+ v-for="node of data"
12
+ :key="node.id"
13
+ :node="node"
14
+ :drag-and-drop="dragAndDrop"
15
+ >
11
16
  <slot
12
17
  name="node"
13
18
  :node="node"
@@ -73,6 +78,10 @@ export default {
73
78
  type: Number,
74
79
  default: null,
75
80
  },
81
+ dragAndDrop: {
82
+ type: Boolean,
83
+ default: false,
84
+ },
76
85
  },
77
86
  emits: ["drop", "click", "hover"],
78
87
  setup(props, { emit }) {
@@ -95,7 +104,10 @@ export default {
95
104
 
96
105
  const dropHelperDisplayed = computed(
97
106
  () =>
98
- hover.value && state.dragPosition !== null && state.hoveredNode === null
107
+ props.dragAndDrop &&
108
+ hover.value &&
109
+ state.dragPosition !== null &&
110
+ state.hoveredNode === null
99
111
  );
100
112
 
101
113
  return {
@@ -44,6 +44,7 @@
44
44
  v-if="node.children?.length > 0 && expanded"
45
45
  :node="node"
46
46
  :depth="depth + 1"
47
+ :drag-and-drop="dragAndDrop"
47
48
  />
48
49
  </template>
49
50
 
@@ -64,20 +65,25 @@ NodeChildren = {
64
65
  type: Number,
65
66
  default: 0,
66
67
  },
68
+ dragAndDrop: {
69
+ type: Boolean,
70
+ default: false,
71
+ },
67
72
  },
68
73
  render() {
69
- const { node, depth, root } = this;
74
+ const { node, depth, dragAndDrop, root } = this;
70
75
 
71
76
  const state = root.state;
72
77
 
73
78
  return node.children.map(child =>
74
- h(Node, { node: child, depth, key: child.id }, () =>
79
+ h(Node, { node: child, depth, dragAndDrop, key: child.id }, () =>
75
80
  root.$slots.node?.({
76
81
  node: child,
77
82
  depth,
78
83
  selected: child.id === state.selectedId,
79
84
  hovered: child.id === state.hoveredNode?.id,
80
85
  ancestorSelected: state.hasAncestorSelected(child),
86
+ dragAndDrop,
81
87
  })
82
88
  )
83
89
  );
@@ -99,6 +105,10 @@ Node = {
99
105
  type: Number,
100
106
  default: 0,
101
107
  },
108
+ dragAndDrop: {
109
+ type: Boolean,
110
+ default: false,
111
+ },
102
112
  },
103
113
  setup(props) {
104
114
  const state = inject("state");
@@ -154,7 +164,11 @@ Node = {
154
164
  };
155
165
 
156
166
  const dropHelperPosition = computed(() => {
157
- if (!state.dragPosition || state.hoveredNode?.id !== props.node.id)
167
+ if (
168
+ !props.dragAndDrop ||
169
+ !state.dragPosition ||
170
+ state.hoveredNode?.id !== props.node.id
171
+ )
158
172
  return null;
159
173
 
160
174
  return state.getNodeDropPosition(props.node, nodeRef.value);
@@ -62,7 +62,7 @@ export default function useState(props, emit) {
62
62
  state.dragPosition = { x: clientX, y: clientY };
63
63
  };
64
64
  const onNodeMouseUp = (node, domElement, expanded) => {
65
- if (!state.dragPosition) return;
65
+ if (!props.dragAndDrop || !state.dragPosition) return;
66
66
 
67
67
  if (state.hoveredNode?.id === pressedNode.value?.id) return;
68
68
 
@@ -131,7 +131,7 @@ export default function useState(props, emit) {
131
131
  emit("click", null);
132
132
  };
133
133
  const onTreeMouseUp = () => {
134
- if (!state.dragPosition) return;
134
+ if (!props.dragAndDrop || !state.dragPosition) return;
135
135
 
136
136
  if (state.trees.indexOf(pressedNode.value) === state.trees.length - 1) {
137
137
  // to drop the last root node at the end of the list does not fire the drop event