@neo4j-ndl/react 2.9.4 → 2.10.0
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/CHANGELOG.md +6 -0
- package/lib/LICENSES.txt +26 -0
- package/lib/NOTICE.txt +6 -0
- package/lib/cjs/_common/utils.js +41 -1
- package/lib/cjs/_common/utils.js.map +1 -1
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/tree-view/TreeItemWrapper.js +201 -0
- package/lib/cjs/tree-view/TreeItemWrapper.js.map +1 -0
- package/lib/cjs/tree-view/TreeView.js +314 -0
- package/lib/cjs/tree-view/TreeView.js.map +1 -0
- package/lib/cjs/tree-view/TreeViewItem.js +89 -0
- package/lib/cjs/tree-view/TreeViewItem.js.map +1 -0
- package/lib/cjs/tree-view/TreeViewTextItem.js +153 -0
- package/lib/cjs/tree-view/TreeViewTextItem.js.map +1 -0
- package/lib/cjs/tree-view/TreeViewTrail.js +30 -0
- package/lib/cjs/tree-view/TreeViewTrail.js.map +1 -0
- package/lib/cjs/tree-view/index.js +26 -0
- package/lib/cjs/tree-view/index.js.map +1 -0
- package/lib/cjs/tree-view/tree-view-keyboard-coordinates.js +119 -0
- package/lib/cjs/tree-view/tree-view-keyboard-coordinates.js.map +1 -0
- package/lib/cjs/tree-view/tree-view-keyboard-helpers.js +75 -0
- package/lib/cjs/tree-view/tree-view-keyboard-helpers.js.map +1 -0
- package/lib/cjs/tree-view/tree-view-types.js +24 -0
- package/lib/cjs/tree-view/tree-view-types.js.map +1 -0
- package/lib/cjs/tree-view/tree-view-utils.js +187 -0
- package/lib/cjs/tree-view/tree-view-utils.js.map +1 -0
- package/lib/esm/_common/utils.js +38 -0
- package/lib/esm/_common/utils.js.map +1 -1
- package/lib/esm/index.js +1 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/tree-view/TreeItemWrapper.js +172 -0
- package/lib/esm/tree-view/TreeItemWrapper.js.map +1 -0
- package/lib/esm/tree-view/TreeView.js +310 -0
- package/lib/esm/tree-view/TreeView.js.map +1 -0
- package/lib/esm/tree-view/TreeViewItem.js +63 -0
- package/lib/esm/tree-view/TreeViewItem.js.map +1 -0
- package/lib/esm/tree-view/TreeViewTextItem.js +147 -0
- package/lib/esm/tree-view/TreeViewTextItem.js.map +1 -0
- package/lib/esm/tree-view/TreeViewTrail.js +26 -0
- package/lib/esm/tree-view/TreeViewTrail.js.map +1 -0
- package/lib/esm/tree-view/index.js +22 -0
- package/lib/esm/tree-view/index.js.map +1 -0
- package/lib/esm/tree-view/tree-view-keyboard-coordinates.js +115 -0
- package/lib/esm/tree-view/tree-view-keyboard-coordinates.js.map +1 -0
- package/lib/esm/tree-view/tree-view-keyboard-helpers.js +68 -0
- package/lib/esm/tree-view/tree-view-keyboard-helpers.js.map +1 -0
- package/lib/esm/tree-view/tree-view-types.js +23 -0
- package/lib/esm/tree-view/tree-view-types.js.map +1 -0
- package/lib/esm/tree-view/tree-view-utils.js +179 -0
- package/lib/esm/tree-view/tree-view-utils.js.map +1 -0
- package/lib/types/_common/utils.d.ts +12 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/table/Table.d.ts +1 -1
- package/lib/types/tree-view/TreeItemWrapper.d.ts +32 -0
- package/lib/types/tree-view/TreeView.d.ts +34 -0
- package/lib/types/tree-view/TreeViewItem.d.ts +52 -0
- package/lib/types/tree-view/TreeViewTextItem.d.ts +23 -0
- package/lib/types/tree-view/TreeViewTrail.d.ts +24 -0
- package/lib/types/tree-view/index.d.ts +23 -0
- package/lib/types/tree-view/tree-view-keyboard-coordinates.d.ts +23 -0
- package/lib/types/tree-view/tree-view-keyboard-helpers.d.ts +25 -0
- package/lib/types/tree-view/tree-view-types.d.ts +80 -0
- package/lib/types/tree-view/tree-view-utils.d.ts +77 -0
- package/lib/types/typography/Typography.d.ts +1 -1
- package/package.json +3 -1
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.TreeView = void 0;
|
|
15
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* Copyright (c) "Neo4j"
|
|
19
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
20
|
+
*
|
|
21
|
+
* This file is part of Neo4j.
|
|
22
|
+
*
|
|
23
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
24
|
+
* it under the terms of the GNU General Public License as published by
|
|
25
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
26
|
+
* (at your option) any later version.
|
|
27
|
+
*
|
|
28
|
+
* This program is distributed in the hope that it will be useful,
|
|
29
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
30
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
31
|
+
* GNU General Public License for more details.
|
|
32
|
+
*
|
|
33
|
+
* You should have received a copy of the GNU General Public License
|
|
34
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
35
|
+
*/
|
|
36
|
+
const core_1 = require("@dnd-kit/core");
|
|
37
|
+
const sortable_1 = require("@dnd-kit/sortable");
|
|
38
|
+
const react_1 = require("react");
|
|
39
|
+
const react_dom_1 = require("react-dom");
|
|
40
|
+
const TreeItemWrapper_1 = require("./TreeItemWrapper");
|
|
41
|
+
const TreeViewItem_1 = require("./TreeViewItem");
|
|
42
|
+
const TreeViewTextItem_1 = require("./TreeViewTextItem");
|
|
43
|
+
const tree_view_keyboard_coordinates_1 = require("./tree-view-keyboard-coordinates");
|
|
44
|
+
const tree_view_utils_1 = require("./tree-view-utils");
|
|
45
|
+
const indentationWidth = 20;
|
|
46
|
+
const ACTIVE_PLACEHOLDER_ID = 'ndl-active-tree-item';
|
|
47
|
+
const dropAnimationConfig = {
|
|
48
|
+
keyframes({ transform }) {
|
|
49
|
+
return [
|
|
50
|
+
{
|
|
51
|
+
opacity: 1,
|
|
52
|
+
transform: (0, tree_view_utils_1.transformToString)(transform.initial),
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
opacity: 0,
|
|
56
|
+
transform: (0, tree_view_utils_1.transformToString)(Object.assign(Object.assign({}, transform.final), { y: transform.final.y + 5, x: transform.final.x + 5 })),
|
|
57
|
+
},
|
|
58
|
+
];
|
|
59
|
+
},
|
|
60
|
+
easing: 'ease-out',
|
|
61
|
+
sideEffects({ active }) {
|
|
62
|
+
active.node.animate([{ opacity: 0 }, { opacity: 1 }], {
|
|
63
|
+
duration: core_1.defaultDropAnimation.duration,
|
|
64
|
+
easing: core_1.defaultDropAnimation.easing,
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
const TreeView = (_a) => {
|
|
69
|
+
var _b;
|
|
70
|
+
var { items, TreeItemComponent, onItemsChanged } = _a, rest = __rest(_a, ["items", "TreeItemComponent", "onItemsChanged"]);
|
|
71
|
+
const flattenItems = (0, react_1.useMemo)(() => (0, tree_view_utils_1.flattenTree)(items), [items]);
|
|
72
|
+
const [activeId, setActiveId] = (0, react_1.useState)(null);
|
|
73
|
+
const [overId, setOverId] = (0, react_1.useState)(null);
|
|
74
|
+
const [focusedRowId, setFocusedRowId] = (0, react_1.useState)(null);
|
|
75
|
+
const [currentPosition, setCurrentPosition] = (0, react_1.useState)(null);
|
|
76
|
+
const [offsetLeft, setOffsetLeft] = (0, react_1.useState)(0);
|
|
77
|
+
/* ------------------------------ Setup of Data ------------------------------ */
|
|
78
|
+
const flattenedAndRemovedCollapsedItems = (0, react_1.useMemo)(() => {
|
|
79
|
+
const collapsedItemsIds = flattenItems
|
|
80
|
+
.filter((item) => item.canHaveSubItems && item.isCollapsed)
|
|
81
|
+
.map((item) => item.id);
|
|
82
|
+
return (0, tree_view_utils_1.removeChildrenOf)([...flattenItems], activeId !== null ? [activeId, ...collapsedItemsIds] : collapsedItemsIds);
|
|
83
|
+
}, [activeId, flattenItems]);
|
|
84
|
+
const activeItem = (0, react_1.useMemo)(() => (activeId ? flattenItems.find(({ id }) => id === activeId) : null), [activeId, flattenItems]);
|
|
85
|
+
const flattenedAndRemovedCollapsedItemsWithActive = (0, react_1.useMemo)(() => {
|
|
86
|
+
const collapsedItems = flattenItems.reduce((acc, item) => {
|
|
87
|
+
if (item.canHaveSubItems && item.isCollapsed) {
|
|
88
|
+
return [...acc, item.id];
|
|
89
|
+
}
|
|
90
|
+
return acc;
|
|
91
|
+
}, []);
|
|
92
|
+
const ItemsWithCollapsedRemoved = (0, tree_view_utils_1.removeChildrenOf)(flattenItems, activeId ? [activeId, ...collapsedItems] : collapsedItems);
|
|
93
|
+
const newArray = [];
|
|
94
|
+
for (const item of ItemsWithCollapsedRemoved) {
|
|
95
|
+
newArray.push(item);
|
|
96
|
+
if (item.id === activeId) {
|
|
97
|
+
newArray.push(Object.assign(Object.assign({}, item), { id: ACTIVE_PLACEHOLDER_ID }));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return newArray;
|
|
101
|
+
}, [flattenItems, activeId]);
|
|
102
|
+
activeItem && activeItem.canHaveSubItems && !activeItem.isCollapsed
|
|
103
|
+
? flattenedAndRemovedCollapsedItems.concat(Object.assign(Object.assign({}, activeItem), { id: ACTIVE_PLACEHOLDER_ID }))
|
|
104
|
+
: flattenedAndRemovedCollapsedItems;
|
|
105
|
+
const sensorContext = (0, react_1.useRef)({
|
|
106
|
+
items: flattenedAndRemovedCollapsedItemsWithActive,
|
|
107
|
+
offset: offsetLeft,
|
|
108
|
+
});
|
|
109
|
+
const coordinateGetter = (0, react_1.useMemo)(() => {
|
|
110
|
+
sensorContext.current.items = flattenedAndRemovedCollapsedItemsWithActive;
|
|
111
|
+
sensorContext.current.offset = offsetLeft;
|
|
112
|
+
return (0, tree_view_keyboard_coordinates_1.sortableTreeKeyboardCoordinates)(sensorContext, true, indentationWidth);
|
|
113
|
+
}, [flattenedAndRemovedCollapsedItemsWithActive, offsetLeft]);
|
|
114
|
+
const sensors = (0, core_1.useSensors)((0, core_1.useSensor)(core_1.PointerSensor), (0, core_1.useSensor)(core_1.KeyboardSensor, {
|
|
115
|
+
coordinateGetter: coordinateGetter,
|
|
116
|
+
}));
|
|
117
|
+
const projected = (0, react_1.useMemo)(() => activeId && overId
|
|
118
|
+
? (0, tree_view_utils_1.getProjection)(flattenedAndRemovedCollapsedItemsWithActive, activeId, overId, offsetLeft, indentationWidth)
|
|
119
|
+
: null, [activeId, overId, flattenedAndRemovedCollapsedItemsWithActive, offsetLeft]);
|
|
120
|
+
/* ------------------------------ Handlers ------------------------------ */
|
|
121
|
+
function handleDragStart({ active }) {
|
|
122
|
+
const activeId = active.id;
|
|
123
|
+
setActiveId(activeId);
|
|
124
|
+
setOverId(activeId);
|
|
125
|
+
const activeItem = flattenItems.find(({ id }) => id === activeId);
|
|
126
|
+
if (activeItem) {
|
|
127
|
+
setCurrentPosition({
|
|
128
|
+
parentId: activeItem.parentId,
|
|
129
|
+
overId: activeId,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
document.body.style.setProperty('cursor', 'grabbing');
|
|
133
|
+
}
|
|
134
|
+
function handleDragMove({ delta }) {
|
|
135
|
+
setOffsetLeft(delta.x);
|
|
136
|
+
}
|
|
137
|
+
function handleDragOver({ over }) {
|
|
138
|
+
var _a;
|
|
139
|
+
setOverId((_a = over === null || over === void 0 ? void 0 : over.id) !== null && _a !== void 0 ? _a : null);
|
|
140
|
+
}
|
|
141
|
+
function resetState() {
|
|
142
|
+
setOverId(null);
|
|
143
|
+
setActiveId(null);
|
|
144
|
+
setOffsetLeft(0);
|
|
145
|
+
setCurrentPosition(null);
|
|
146
|
+
document.body.style.setProperty('cursor', '');
|
|
147
|
+
}
|
|
148
|
+
const handleDragEnd = (0, react_1.useCallback)((event) => {
|
|
149
|
+
const { active, over } = event;
|
|
150
|
+
resetState();
|
|
151
|
+
let overIndex = flattenItems.findIndex((item) => item.id === (over === null || over === void 0 ? void 0 : over.id));
|
|
152
|
+
if ((over === null || over === void 0 ? void 0 : over.id) === ACTIVE_PLACEHOLDER_ID) {
|
|
153
|
+
overIndex = flattenItems.findIndex((item) => item.id === active.id);
|
|
154
|
+
}
|
|
155
|
+
if (projected && over) {
|
|
156
|
+
const { depth, parentId } = projected;
|
|
157
|
+
const clonedItems = [...flattenItems];
|
|
158
|
+
const parentIndex = clonedItems.findIndex((item) => item.id === parentId);
|
|
159
|
+
const activeIndex = clonedItems.findIndex(({ id }) => id === active.id);
|
|
160
|
+
const activeTreeItem = clonedItems[activeIndex];
|
|
161
|
+
clonedItems[activeIndex] = Object.assign(Object.assign({}, activeTreeItem), { depth, parentId });
|
|
162
|
+
const parentItem = clonedItems[parentIndex];
|
|
163
|
+
if (parentItem && parentItem.canHaveSubItems) {
|
|
164
|
+
clonedItems[parentIndex] = Object.assign(Object.assign({}, parentItem), { isCollapsed: false });
|
|
165
|
+
}
|
|
166
|
+
const newItems = (0, tree_view_utils_1.buildTree)((0, sortable_1.arrayMove)(clonedItems, activeIndex, overIndex));
|
|
167
|
+
onItemsChanged(newItems, {
|
|
168
|
+
reason: 'dropped',
|
|
169
|
+
item: activeTreeItem,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}, [flattenItems, onItemsChanged, projected]);
|
|
173
|
+
function handleToggleCollapse(id) {
|
|
174
|
+
const item = flattenItems.find((item) => item.id === id);
|
|
175
|
+
if (!item || item.canHaveSubItems !== true)
|
|
176
|
+
return;
|
|
177
|
+
onItemsChanged((0, tree_view_utils_1.buildTree)(flattenItems.map((item) => {
|
|
178
|
+
if (item.id === id && item.canHaveSubItems === true) {
|
|
179
|
+
return Object.assign(Object.assign({}, item), { isCollapsed: !item.isCollapsed });
|
|
180
|
+
}
|
|
181
|
+
return item;
|
|
182
|
+
})), {
|
|
183
|
+
reason: item.isCollapsed ? 'expanded' : 'collapsed',
|
|
184
|
+
item,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
function handleDragCancel() {
|
|
188
|
+
resetState();
|
|
189
|
+
}
|
|
190
|
+
/* ------------------------------ Keyboard functions ------------------------------ */
|
|
191
|
+
const getMovementAnnouncement = (eventName, activeId, overId) => {
|
|
192
|
+
if (overId && projected) {
|
|
193
|
+
if (eventName !== 'onDragEnd') {
|
|
194
|
+
if (currentPosition &&
|
|
195
|
+
projected.parentId === currentPosition.parentId &&
|
|
196
|
+
overId === currentPosition.overId) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
setCurrentPosition({
|
|
201
|
+
parentId: projected.parentId,
|
|
202
|
+
overId,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
const clonedItems = [
|
|
207
|
+
...flattenedAndRemovedCollapsedItemsWithActive,
|
|
208
|
+
];
|
|
209
|
+
const overIndex = clonedItems.findIndex(({ id }) => id === overId);
|
|
210
|
+
const activeIndex = clonedItems.findIndex(({ id }) => id === activeId);
|
|
211
|
+
const sortedItems = (0, sortable_1.arrayMove)(clonedItems, activeIndex, overIndex);
|
|
212
|
+
const previousItem = sortedItems[overIndex - 1];
|
|
213
|
+
let announcement;
|
|
214
|
+
const movedVerb = eventName === 'onDragEnd' ? 'dropped' : 'moved';
|
|
215
|
+
const nestedVerb = eventName === 'onDragEnd' ? 'dropped' : 'nested';
|
|
216
|
+
if (!previousItem) {
|
|
217
|
+
const nextItem = sortedItems[overIndex + 1];
|
|
218
|
+
announcement = `${activeId} was ${movedVerb} before ${nextItem.id}.`;
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
if (projected.depth > previousItem.depth) {
|
|
222
|
+
announcement = `${activeId} was ${nestedVerb} under ${previousItem.id}.`;
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
let previousSibling = previousItem;
|
|
226
|
+
while (previousSibling && projected.depth < previousSibling.depth) {
|
|
227
|
+
const parentId = previousSibling.parentId;
|
|
228
|
+
previousSibling = sortedItems.find(({ id }) => id === parentId);
|
|
229
|
+
}
|
|
230
|
+
if (previousSibling) {
|
|
231
|
+
announcement = `${activeId} was ${movedVerb} after ${previousSibling.id}.`;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return announcement;
|
|
236
|
+
}
|
|
237
|
+
return;
|
|
238
|
+
};
|
|
239
|
+
const announcements = {
|
|
240
|
+
onDragStart({ active }) {
|
|
241
|
+
return `Picked up ${active.id}.`;
|
|
242
|
+
},
|
|
243
|
+
onDragMove({ active, over }) {
|
|
244
|
+
return getMovementAnnouncement('onDragMove', active.id, over === null || over === void 0 ? void 0 : over.id);
|
|
245
|
+
},
|
|
246
|
+
onDragOver({ active, over }) {
|
|
247
|
+
return getMovementAnnouncement('onDragOver', active.id, over === null || over === void 0 ? void 0 : over.id);
|
|
248
|
+
},
|
|
249
|
+
onDragEnd({ active, over }) {
|
|
250
|
+
return getMovementAnnouncement('onDragEnd', active.id, over === null || over === void 0 ? void 0 : over.id);
|
|
251
|
+
},
|
|
252
|
+
onDragCancel({ active }) {
|
|
253
|
+
return `Moving was cancelled. ${active.id} was dropped in its original position.`;
|
|
254
|
+
},
|
|
255
|
+
};
|
|
256
|
+
/* ------------------------------ Visual ------------------------------ */
|
|
257
|
+
function getTrailList() {
|
|
258
|
+
const trails = {};
|
|
259
|
+
//Loop through the items in reverse
|
|
260
|
+
[...flattenedAndRemovedCollapsedItemsWithActive]
|
|
261
|
+
.reverse()
|
|
262
|
+
.forEach((item, itemIndex, reversedList) => {
|
|
263
|
+
const trailList = [];
|
|
264
|
+
const nextItem = reversedList[itemIndex - 1];
|
|
265
|
+
//Loop through the depth of the item
|
|
266
|
+
for (let trailDepth = 0; trailDepth < item.depth; trailDepth++) {
|
|
267
|
+
//Not closest to the item so should be straight or none
|
|
268
|
+
if (trailDepth < item.depth - 1) {
|
|
269
|
+
if (nextItem === undefined) {
|
|
270
|
+
trailList.push('none');
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
else if (trails[nextItem === null || nextItem === void 0 ? void 0 : nextItem.id][trailDepth] === 'none') {
|
|
274
|
+
trailList.push('none');
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
else if (nextItem && nextItem.depth <= trailDepth) {
|
|
278
|
+
trailList.push('none');
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
trailList.push('straight');
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
if ((nextItem && trails[nextItem === null || nextItem === void 0 ? void 0 : nextItem.id][trailDepth] === 'none') ||
|
|
285
|
+
nextItem === undefined ||
|
|
286
|
+
nextItem.depth <= trailDepth) {
|
|
287
|
+
trailList.push('curved');
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
trailList.push('straight-curved');
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
trails[item.id] = trailList;
|
|
295
|
+
});
|
|
296
|
+
return trails;
|
|
297
|
+
}
|
|
298
|
+
const measuring = {
|
|
299
|
+
droppable: {
|
|
300
|
+
strategy: core_1.MeasuringStrategy.Always,
|
|
301
|
+
},
|
|
302
|
+
};
|
|
303
|
+
const trails = getTrailList();
|
|
304
|
+
const rowIdWithFocus = focusedRowId !== null && focusedRowId !== void 0 ? focusedRowId : (_b = flattenedAndRemovedCollapsedItemsWithActive[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
305
|
+
return ((0, jsx_runtime_1.jsx)(core_1.DndContext, { accessibility: { announcements }, sensors: sensors, collisionDetection: core_1.closestCenter, onDragEnd: handleDragEnd, onDragStart: handleDragStart, onDragMove: handleDragMove, onDragOver: handleDragOver, onDragCancel: handleDragCancel, measuring: measuring, children: (0, jsx_runtime_1.jsxs)(sortable_1.SortableContext, { items: flattenedAndRemovedCollapsedItemsWithActive.map((item) => item.id), strategy: sortable_1.verticalListSortingStrategy, children: [(0, jsx_runtime_1.jsx)("ol", Object.assign({ className: "ndl-tree-view-list", role: "tree" }, rest, { children: flattenedAndRemovedCollapsedItemsWithActive.map((item) => {
|
|
306
|
+
var _a;
|
|
307
|
+
return ((0, jsx_runtime_1.jsx)(TreeViewItem_1.SortableTreeViewItem, { depth: item.id === activeId && projected ? projected.depth : item.depth, indentationWidth: indentationWidth, item: item, isLast: false, parent: (_a = flattenItems.find((i) => i.id === item.parentId)) !== null && _a !== void 0 ? _a : null, id: item.id, trails: trails[item.id], keepGhostInPlace: item.id === ACTIVE_PLACEHOLDER_ID, TreeItemComponent: TreeItemComponent === undefined
|
|
308
|
+
? TreeViewTextItem_1.TreeViewTextItem
|
|
309
|
+
: TreeItemComponent, onCollapse: () => handleToggleCollapse(item.id), onItemsChanged: (newItems, itemChangedReason) => onItemsChanged((0, tree_view_utils_1.buildTree)(newItems), itemChangedReason), items: flattenItems, tabIndex: item.id === rowIdWithFocus ? 0 : -1, onFocus: () => setFocusedRowId(item.id), shouldDisableSorting: item.isSortable === false }, item.id));
|
|
310
|
+
}) })), (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)(core_1.DragOverlay, { dropAnimation: dropAnimationConfig }), document.body)] }) }));
|
|
311
|
+
};
|
|
312
|
+
exports.TreeView = TreeView;
|
|
313
|
+
exports.TreeView.TreeItemWrapper = TreeItemWrapper_1.TreeItemWrapper;
|
|
314
|
+
//# sourceMappingURL=TreeView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file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,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAC7C,OAAO,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,EACvC,oBAAoB,EAAE,IAAI,CAAC,UAAU,KAAK,KAAK,IAvB1C,IAAI,CAAC,EAAE,CAwBZ,CACH,CAAA;qBAAA,CAAC,IACC,EAEJ,IAAA,wBAAY,EACX,uBAAC,kBAAW,IAAC,aAAa,EAAE,mBAAmB,GAAgB,EAC/D,QAAQ,CAAC,IAAI,CACd,IACe,GACP,CACd,CAAC;AACJ,CAAC,CAAC;AA/YW,QAAA,QAAQ,YA+YnB;AAEF,gBAAQ,CAAC,eAAe,GAAG,iCAAe,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Copyright (c) "Neo4j"
|
|
4
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
5
|
+
*
|
|
6
|
+
* This file is part of Neo4j.
|
|
7
|
+
*
|
|
8
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU General Public License as published by
|
|
10
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
* (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU General Public License
|
|
19
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
"use strict";
|
|
23
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
26
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
27
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
28
|
+
}
|
|
29
|
+
Object.defineProperty(o, k2, desc);
|
|
30
|
+
}) : (function(o, m, k, k2) {
|
|
31
|
+
if (k2 === undefined) k2 = k;
|
|
32
|
+
o[k2] = m[k];
|
|
33
|
+
}));
|
|
34
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
35
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
36
|
+
}) : function(o, v) {
|
|
37
|
+
o["default"] = v;
|
|
38
|
+
});
|
|
39
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
40
|
+
if (mod && mod.__esModule) return mod;
|
|
41
|
+
var result = {};
|
|
42
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
43
|
+
__setModuleDefault(result, mod);
|
|
44
|
+
return result;
|
|
45
|
+
};
|
|
46
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
47
|
+
var t = {};
|
|
48
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
49
|
+
t[p] = s[p];
|
|
50
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
51
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
52
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
53
|
+
t[p[i]] = s[p[i]];
|
|
54
|
+
}
|
|
55
|
+
return t;
|
|
56
|
+
};
|
|
57
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
58
|
+
exports.SortableTreeViewItem = void 0;
|
|
59
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
60
|
+
const sortable_1 = require("@dnd-kit/sortable");
|
|
61
|
+
const react_1 = __importStar(require("react"));
|
|
62
|
+
const tree_view_utils_1 = require("./tree-view-utils");
|
|
63
|
+
const animateLayoutChanges = ({ isSorting, isDragging, }) => (isSorting || isDragging ? false : true);
|
|
64
|
+
const SortableTreeViewItemNotMemoized = function SortableTreeViewItem(_a) {
|
|
65
|
+
var { id, depth, isLast, TreeItemComponent, parent, shouldDisableSorting,
|
|
66
|
+
// need to destruct to avoid passing it to the component
|
|
67
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
68
|
+
sortableProps, keepGhostInPlace, item, onCollapse, trails, onItemsChanged, items, tabIndex, onFocus } = _a, restProps = __rest(_a, ["id", "depth", "isLast", "TreeItemComponent", "parent", "shouldDisableSorting", "sortableProps", "keepGhostInPlace", "item", "onCollapse", "trails", "onItemsChanged", "items", "tabIndex", "onFocus"]);
|
|
69
|
+
const { attributes, listeners, setNodeRef, transform, setActivatorNodeRef, transition, isDragging, isSorting, isOver, } = (0, sortable_1.useSortable)({
|
|
70
|
+
id: id,
|
|
71
|
+
animateLayoutChanges,
|
|
72
|
+
transition: {
|
|
73
|
+
duration: 150,
|
|
74
|
+
easing: 'cubic-bezier(0.25, 1, 0.5, 1)',
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
const style = {
|
|
78
|
+
transform: transform ? (0, tree_view_utils_1.transformToString)(transform) : undefined,
|
|
79
|
+
transition: transition !== null && transition !== void 0 ? transition : undefined,
|
|
80
|
+
};
|
|
81
|
+
const localCollapse = (0, react_1.useMemo)(() => {
|
|
82
|
+
if (!onCollapse)
|
|
83
|
+
return undefined;
|
|
84
|
+
return () => onCollapse === null || onCollapse === void 0 ? void 0 : onCollapse(item.id);
|
|
85
|
+
}, [item.id, onCollapse]);
|
|
86
|
+
return ((0, jsx_runtime_1.jsx)(TreeItemComponent, Object.assign({ item: item, isOverParent: false }, restProps, { setActivatorNodeRef: setActivatorNodeRef, setNodeRef: setNodeRef, style: style, depth: depth, isGhost: keepGhostInPlace, shouldDisableInteraction: isSorting, isLastInParent: isLast, parent: parent, dragHandleProps: Object.assign(Object.assign({}, attributes), listeners), isIndicator: isDragging, onCollapse: localCollapse, onItemsChanged: onItemsChanged, items: items, shouldDisableSorting: shouldDisableSorting, isOver: isOver, trails: trails, tabIndex: tabIndex, onFocus: onFocus })));
|
|
87
|
+
};
|
|
88
|
+
exports.SortableTreeViewItem = react_1.default.memo(SortableTreeViewItemNotMemoized);
|
|
89
|
+
//# sourceMappingURL=TreeViewItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeViewItem.js","sourceRoot":"","sources":["../../../src/tree-view/TreeViewItem.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,gDAI2B;AAC3B,+CAA2D;AAO3D,uDAAsD;AAkBtD,MAAM,oBAAoB,GAAyB,CAAC,EAClD,SAAS,EACT,UAAU,GACX,EAAE,EAAE,CAAC,CAAC,SAAS,IAAI,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAqB/C,MAAM,+BAA+B,GAAG,SAAS,oBAAoB,CAGnE,EAmB4B;QAnB5B,EACA,EAAE,EACF,KAAK,EACL,MAAM,EACN,iBAAiB,EACjB,MAAM,EACN,oBAAoB;IACpB,wDAAwD;IACxD,6DAA6D;IAC7D,aAAa,EACb,gBAAgB,EAChB,IAAI,EACJ,UAAU,EACV,MAAM,EACN,cAAc,EACd,KAAK,EACL,QAAQ,EACR,OAAO,OAEqB,EADzB,SAAS,cAlBZ,uMAmBD,CADa;IAEZ,MAAM,EACJ,UAAU,EACV,SAAS,EACT,UAAU,EACV,SAAS,EACT,mBAAmB,EACnB,UAAU,EACV,UAAU,EACV,SAAS,EACT,MAAM,GACP,GAAG,IAAA,sBAAW,EAAC;QACd,EAAE,EAAE,EAAE;QACN,oBAAoB;QACpB,UAAU,EAAE;YACV,QAAQ,EAAE,GAA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|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.TreeViewTextItem = void 0;
|
|
18
|
+
const react_1 = require("react");
|
|
19
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* Copyright (c) "Neo4j"
|
|
23
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
24
|
+
*
|
|
25
|
+
* This file is part of Neo4j.
|
|
26
|
+
*
|
|
27
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
28
|
+
* it under the terms of the GNU General Public License as published by
|
|
29
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
30
|
+
* (at your option) any later version.
|
|
31
|
+
*
|
|
32
|
+
* This program is distributed in the hope that it will be useful,
|
|
33
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
34
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
35
|
+
* GNU General Public License for more details.
|
|
36
|
+
*
|
|
37
|
+
* You should have received a copy of the GNU General Public License
|
|
38
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
39
|
+
*/
|
|
40
|
+
const react_2 = __importDefault(require("react"));
|
|
41
|
+
const coditionalWrap_1 = require("../_common/coditionalWrap");
|
|
42
|
+
const button_1 = require("../button");
|
|
43
|
+
const checkbox_1 = require("../checkbox");
|
|
44
|
+
const icons_1 = require("../icons");
|
|
45
|
+
const typography_1 = require("../typography");
|
|
46
|
+
const TreeItemWrapper_1 = require("./TreeItemWrapper");
|
|
47
|
+
/**
|
|
48
|
+
* checks if any parent is checked
|
|
49
|
+
* @param item
|
|
50
|
+
* @param items
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
const parentIsCheckedRecursively = (item, items) => {
|
|
54
|
+
const parent = items.find((i) => i.id === item.parentId);
|
|
55
|
+
if (parent) {
|
|
56
|
+
if (parent.isSelected) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
return parentIsCheckedRecursively(parent, items);
|
|
60
|
+
}
|
|
61
|
+
return false;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* checks if any children are checked
|
|
65
|
+
* @param item
|
|
66
|
+
* @param items
|
|
67
|
+
* @returns
|
|
68
|
+
*/
|
|
69
|
+
const childrenCheckedRecursively = (item, items) => {
|
|
70
|
+
const children = items.filter((i) => i.parentId === item.id);
|
|
71
|
+
if (children.length === 0) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
return children.some((i) => i.isSelected || childrenCheckedRecursively(i, items));
|
|
75
|
+
};
|
|
76
|
+
exports.TreeViewTextItem = react_2.default.forwardRef(function TreeViewTextItem(_a, ref) {
|
|
77
|
+
var { depth, shouldDisableInteraction, shouldDisableSorting, isGhost, indentationWidth, isIndicator, isCollapsed, onCollapse, item, parent, isOver, isOverParent, setNodeRef, setActivatorNodeRef, dragHandleProps, style, trails, onItemsChanged, items, tabIndex } = _a, restProps = __rest(_a, ["depth", "shouldDisableInteraction", "shouldDisableSorting", "isGhost", "indentationWidth", "isIndicator", "isCollapsed", "onCollapse", "item", "parent", "isOver", "isOverParent", "setNodeRef", "setActivatorNodeRef", "dragHandleProps", "style", "trails", "onItemsChanged", "items", "tabIndex"]);
|
|
78
|
+
const checkboxRef = react_2.default.useRef(null);
|
|
79
|
+
const isAnyParentChecked = parentIsCheckedRecursively(item, items);
|
|
80
|
+
if (checkboxRef.current) {
|
|
81
|
+
const isAnyChildChecked = childrenCheckedRecursively(item, items);
|
|
82
|
+
if (isAnyChildChecked && !isAnyParentChecked && !item.isSelected) {
|
|
83
|
+
checkboxRef.current.indeterminate = true;
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
checkboxRef.current.indeterminate = false;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return ((0, jsx_runtime_1.jsxs)(TreeItemWrapper_1.TreeItemWrapper, Object.assign({ depth: depth, shouldDisableInteraction: shouldDisableInteraction, shouldDisableSorting: shouldDisableSorting, isGhost: isGhost, indentationWidth: indentationWidth, isIndicator: isIndicator, isCollapsed: isCollapsed, onCollapse: onCollapse, item: item, parent: parent, isOver: isOver, isOverParent: isOverParent, setNodeRef: setNodeRef, setActivatorNodeRef: setActivatorNodeRef, dragHandleProps: dragHandleProps, style: style, trails: trails,
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
91
|
+
onItemsChanged: () => { }, ref: ref, items: items, tabIndex: tabIndex }, restProps, { children: [item.canHaveSubItems && onCollapse && ((0, jsx_runtime_1.jsxs)("button", { className: "ndl-tree-view-collapse-button", onClick: () => onCollapse(), "aria-label": item.isCollapsed ? 'Expand' : 'Collapse', "aria-expanded": item.isCollapsed ? 'false' : 'true', "aria-pressed": !item.isCollapsed,
|
|
92
|
+
/**
|
|
93
|
+
* Tab index is set to -1 to prevent the item from being focused when the tree is navigated with tab
|
|
94
|
+
* since we use the arrow keys instead
|
|
95
|
+
*/
|
|
96
|
+
tabIndex: tabIndex, children: [item.isCollapsed && (0, jsx_runtime_1.jsx)(icons_1.ChevronRightIconOutline, { className: "ndl-icon" }), !item.isCollapsed && (0, jsx_runtime_1.jsx)(icons_1.ChevronDownIconOutline, { className: "ndl-icon" })] })), item.isSelected !== undefined && ((0, jsx_runtime_1.jsx)(checkbox_1.Checkbox, { ref: checkboxRef, checked: item.isSelected, tabIndex: tabIndex, onChange: (event) => {
|
|
97
|
+
const newItems = items.map((i) => {
|
|
98
|
+
if (i.id === item.id) {
|
|
99
|
+
return Object.assign(Object.assign({}, i), { isSelected: event.target.checked });
|
|
100
|
+
}
|
|
101
|
+
return i;
|
|
102
|
+
});
|
|
103
|
+
//Uncheck parents if a child is unchecked
|
|
104
|
+
if (!event.target.checked) {
|
|
105
|
+
let parentId = item.parentId;
|
|
106
|
+
while (parentId !== null) {
|
|
107
|
+
const parent = newItems.find((newItem) => newItem.id === parentId);
|
|
108
|
+
if (parent) {
|
|
109
|
+
newItems.forEach((newItem) => {
|
|
110
|
+
if (newItem.id === parent.id) {
|
|
111
|
+
newItem.isSelected = false;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
parentId = parent.parentId;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
parentId = null;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
//Check children if a parent is checked
|
|
122
|
+
if (item.canHaveSubItems) {
|
|
123
|
+
const childIdsToUncheck = items
|
|
124
|
+
.filter((i) => i.parentId === item.id)
|
|
125
|
+
.map((i) => i.id);
|
|
126
|
+
while (childIdsToUncheck.length > 0) {
|
|
127
|
+
const childId = childIdsToUncheck.pop();
|
|
128
|
+
const child = items.find((i) => i.id === childId);
|
|
129
|
+
if (child) {
|
|
130
|
+
newItems.forEach((newItem) => {
|
|
131
|
+
if (newItem.id === child.id) {
|
|
132
|
+
newItem.isSelected = event.target.checked;
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
newItems
|
|
136
|
+
.filter((i) => i.parentId === child.id)
|
|
137
|
+
.forEach((i) => {
|
|
138
|
+
childIdsToUncheck.push(i.id);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
onItemsChanged(newItems, { item, reason: 'selected' });
|
|
144
|
+
}, "aria-label": item.data.text })), (0, jsx_runtime_1.jsx)(coditionalWrap_1.ConditionalWrap, { condition: item.data.onTextClick !== undefined, wrapper: (children) => ((0, jsx_runtime_1.jsx)("button", { onClick: item.data.onTextClick, className: "ndl-tree-view-text-clickable", tabIndex: tabIndex, children: children })), children: (0, jsx_runtime_1.jsx)(typography_1.Typography, { style: {
|
|
145
|
+
overflow: 'hidden',
|
|
146
|
+
textOverflow: 'ellipsis',
|
|
147
|
+
whiteSpace: 'nowrap',
|
|
148
|
+
}, variant: item.canHaveSubItems ? 'subheading-small' : 'body-medium', children: item.data.text }) }), (0, jsx_runtime_1.jsx)("div", { className: "ndl-tree-view-actions", children: item.data.actions &&
|
|
149
|
+
item.data.actions.map((action, index) => {
|
|
150
|
+
return ((0, react_1.createElement)(button_1.IconButton, Object.assign({}, action.buttonProps, { key: index, className: "ndl-tree-view-action", clean: true, size: "small", tabIndex: tabIndex }), action.icon));
|
|
151
|
+
}) })] })));
|
|
152
|
+
});
|
|
153
|
+
//# sourceMappingURL=TreeViewTextItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeViewTextItem.js","sourceRoot":"","sources":["../../../src/tree-view/TreeViewTextItem.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,kDAA0B;AAE1B,8DAA4D;AAC5D,sCAAuC;AACvC,0CAAuC;AACvC,oCAA2E;AAC3E,8CAA2C;AAC3C,uDAAoD;AAOpD;;;;;GAKG;AACH,MAAM,0BAA0B,GAAG,CACjC,IAAqC,EACrC,KAAwC,EAC/B,EAAE;IACX,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,QAAQ,CAAC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E,EAAE,CAAC,CACrB,mCACE,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,EAC9B,SAAS,EAAC,8BAA8B,EACxC,QAAQ,EAAE,QAAQ,YAEjB,QAAQ,GACF,CACV,YAED,uBAAC,uBAAU,IACT,KAAK,EAAE;wBACL,QAAQ,EAAE,QAAQ;wBAClB,YAAY,EAAE,UAAU;wBACxB,UAAU,EAAE,QAAQ;qBACrB,EACD,OAAO,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,aAAa,YAEjE,IAAI,CAAC,IAAI,CAAC,IAAI,GACJ,GACG,EAClB,gCAAK,SAAS,EAAC,uBAAuB,YACnC,IAAI,CAAC,IAAI,CAAC,OAAO;oBAChB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;wBACtC,OAAO,CACL,2BAAC,mBAAU,oBACL,MAAM,CAAC,WAAW,IACtB,GAAG,EAAE,KAAK,EACV,SAAS,EAAC,sBAAsB,EAChC,KAAK,QACL,IAAI,EAAC,OAAO,EACZ,QAAQ,EAAE,QAAQ,KAEjB,MAAM,CAAC,IAAI,CACD,CACd,CAAC;oBACJ,CAAC,CAAC,GACA,KACU,CACnB,CAAC;AACJ,CAAC,CAKsB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Copyright (c) "Neo4j"
|
|
4
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
5
|
+
*
|
|
6
|
+
* This file is part of Neo4j.
|
|
7
|
+
*
|
|
8
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU General Public License as published by
|
|
10
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
* (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU General Public License
|
|
19
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
"use strict";
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.Trail = void 0;
|
|
25
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
26
|
+
const Trail = ({ variant }) => {
|
|
27
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "ndl-trail", children: [variant === 'straight' && ((0, jsx_runtime_1.jsx)("svg", { className: "ndl-trail-straight", width: "2", height: "24", viewBox: "0 0 2 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: (0, jsx_runtime_1.jsx)("path", { d: "M1.00001 16.0005L1 -4.00049L1 28.0004", stroke: "#BBBEC3" }) })), variant === 'curved' && ((0, jsx_runtime_1.jsx)("svg", { className: "ndl-trail-curved", width: "9", height: "13", viewBox: "0 0 9 13", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: (0, jsx_runtime_1.jsx)("path", { d: "M1 -4L1 3.99988C1 8.41816 4.58172 11.9999 9 11.9999V11.9999", stroke: "#BBBEC3" }) })), variant === 'straight-curved' && ((0, jsx_runtime_1.jsxs)("svg", { className: "ndl-trail-straight-curved", width: "16", height: "24", viewBox: "0 0 16 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [(0, jsx_runtime_1.jsx)("g", { clipPath: "url(#clip0_16990_133)", children: (0, jsx_runtime_1.jsx)("path", { d: "M16 12V12C11.5817 12 8.00001 8.41828 8.00001 4L8.00001 -4L8 28", stroke: "#BBBEC3" }) }), (0, jsx_runtime_1.jsx)("defs", { children: (0, jsx_runtime_1.jsx)("clipPath", { id: "clip0_16990_133", children: (0, jsx_runtime_1.jsx)("rect", { width: "16", height: "24", fill: "white" }) }) })] }))] }));
|
|
28
|
+
};
|
|
29
|
+
exports.Trail = Trail;
|
|
30
|
+
//# sourceMappingURL=TreeViewTrail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeViewTrail.js","sourceRoot":"","sources":["../../../src/tree-view/TreeViewTrail.tsx"],"names":[],"mappings":";;;;AAwBO,MAAM,KAAK,GAAG,CAAC,EAAE,OAAO,EAAc,EAAE,EAAE;IAC/C,OAAO,CACL,iCAAK,SAAS,EAAC,WAAW,aACvB,OAAO,KAAK,UAAU,IAAI,CACzB,gCACE,SAAS,EAAC,oBAAoB,EAC9B,KAAK,EAAC,GAAG,EACT,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,UAAU,EAClB,IAAI,EAAC,MAAM,EACX,KAAK,EAAC,4BAA4B,YAElC,iCAAM,CAAC,EAAC,uCAAuC,EAAC,MAAM,EAAC,SAAS,GAAG,GAC/D,CACP,EACA,OAAO,KAAK,QAAQ,IAAI,CACvB,gCACE,SAAS,EAAC,kBAAkB,EAC5B,KAAK,EAAC,GAAG,EACT,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,UAAU,EAClB,IAAI,EAAC,MAAM,EACX,KAAK,EAAC,4BAA4B,YAElC,iCACE,CAAC,EAAC,6DAA6D,EAC/D,MAAM,EAAC,SAAS,GAChB,GACE,CACP,EACA,OAAO,KAAK,iBAAiB,IAAI,CAChC,iCACE,SAAS,EAAC,2BAA2B,EACrC,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,KAAK,EAAC,4BAA4B,aAElC,8BAAG,QAAQ,EAAC,uBAAuB,YACjC,iCACE,CAAC,EAAC,gEAAgE,EAClE,MAAM,EAAC,SAAS,GAChB,GACA,EACJ,2CACE,qCAAU,EAAE,EAAC,iBAAiB,YAC5B,iCAAM,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,IAAI,EAAC,OAAO,GAAG,GACnC,GACN,IACH,CACP,IACG,CACP,CAAC;AACJ,CAAC,CAAC;AAtDW,QAAA,KAAK,SAsDhB"}
|