@uipath/apollo-wind 1.0.0 → 1.0.2
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/dist/components/custom/grid-maestro.d.ts +2 -2
- package/dist/components/ui/button.cjs +1 -0
- package/dist/components/ui/button.js +1 -0
- package/dist/components/ui/index.cjs +12 -12
- package/dist/components/ui/tree-view.cjs +63 -63
- package/dist/components/ui/tree-view.d.ts +3 -3
- package/dist/components/ui/tree-view.js +63 -63
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
export declare function Canvas({ children, className
|
|
2
|
+
export declare function Canvas({ children, className }: {
|
|
3
3
|
children: React.ReactNode;
|
|
4
4
|
className?: string;
|
|
5
5
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -9,7 +9,7 @@ export declare function Canvas({ children, className, }: {
|
|
|
9
9
|
* 768–1023 → 2 columns
|
|
10
10
|
* >= 1024 → 4 columns
|
|
11
11
|
*/
|
|
12
|
-
export declare function Grid({ children, className
|
|
12
|
+
export declare function Grid({ children, className }: {
|
|
13
13
|
children: React.ReactNode;
|
|
14
14
|
className?: string;
|
|
15
15
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -15,7 +15,7 @@ var __webpack_modules__ = {
|
|
|
15
15
|
"./avatar" (module) {
|
|
16
16
|
module.exports = require("./avatar.cjs");
|
|
17
17
|
},
|
|
18
|
-
"
|
|
18
|
+
"./badge" (module) {
|
|
19
19
|
module.exports = require("./badge.cjs");
|
|
20
20
|
},
|
|
21
21
|
"./breadcrumb" (module) {
|
|
@@ -27,7 +27,7 @@ var __webpack_modules__ = {
|
|
|
27
27
|
"@/components/ui/button" (module) {
|
|
28
28
|
module.exports = require("./button.cjs");
|
|
29
29
|
},
|
|
30
|
-
"
|
|
30
|
+
"@/components/ui/calendar" (module) {
|
|
31
31
|
module.exports = require("./calendar.cjs");
|
|
32
32
|
},
|
|
33
33
|
"@/components/ui/card" (module) {
|
|
@@ -42,7 +42,7 @@ var __webpack_modules__ = {
|
|
|
42
42
|
"./combobox" (module) {
|
|
43
43
|
module.exports = require("./combobox.cjs");
|
|
44
44
|
},
|
|
45
|
-
"
|
|
45
|
+
"./command" (module) {
|
|
46
46
|
module.exports = require("./command.cjs");
|
|
47
47
|
},
|
|
48
48
|
"./context-menu" (module) {
|
|
@@ -57,13 +57,13 @@ var __webpack_modules__ = {
|
|
|
57
57
|
"./datetime-picker" (module) {
|
|
58
58
|
module.exports = require("./datetime-picker.cjs");
|
|
59
59
|
},
|
|
60
|
-
"
|
|
60
|
+
"@/components/ui/dialog" (module) {
|
|
61
61
|
module.exports = require("./dialog.cjs");
|
|
62
62
|
},
|
|
63
63
|
"./dropdown-menu" (module) {
|
|
64
64
|
module.exports = require("./dropdown-menu.cjs");
|
|
65
65
|
},
|
|
66
|
-
"
|
|
66
|
+
"./editable-cell" (module) {
|
|
67
67
|
module.exports = require("./editable-cell.cjs");
|
|
68
68
|
},
|
|
69
69
|
"./empty-state" (module) {
|
|
@@ -78,7 +78,7 @@ var __webpack_modules__ = {
|
|
|
78
78
|
"./input" (module) {
|
|
79
79
|
module.exports = require("./input.cjs");
|
|
80
80
|
},
|
|
81
|
-
"
|
|
81
|
+
"@/components/ui/label" (module) {
|
|
82
82
|
module.exports = require("./label.cjs");
|
|
83
83
|
},
|
|
84
84
|
"./layout" (module) {
|
|
@@ -241,7 +241,7 @@ var __webpack_exports__ = {};
|
|
|
241
241
|
"default"
|
|
242
242
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_avatar__rspack_import_4[__rspack_import_key];
|
|
243
243
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
244
|
-
var _badge__rspack_import_5 = __webpack_require__("
|
|
244
|
+
var _badge__rspack_import_5 = __webpack_require__("./badge");
|
|
245
245
|
var __rspack_reexport = {};
|
|
246
246
|
for(const __rspack_import_key in _badge__rspack_import_5)if ([
|
|
247
247
|
"TreeView",
|
|
@@ -269,7 +269,7 @@ var __webpack_exports__ = {};
|
|
|
269
269
|
"default"
|
|
270
270
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_button_group__rspack_import_8[__rspack_import_key];
|
|
271
271
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
272
|
-
var _calendar__rspack_import_9 = __webpack_require__("
|
|
272
|
+
var _calendar__rspack_import_9 = __webpack_require__("@/components/ui/calendar");
|
|
273
273
|
var __rspack_reexport = {};
|
|
274
274
|
for(const __rspack_import_key in _calendar__rspack_import_9)if ([
|
|
275
275
|
"TreeView",
|
|
@@ -304,7 +304,7 @@ var __webpack_exports__ = {};
|
|
|
304
304
|
"default"
|
|
305
305
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_combobox__rspack_import_13[__rspack_import_key];
|
|
306
306
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
307
|
-
var _command__rspack_import_14 = __webpack_require__("
|
|
307
|
+
var _command__rspack_import_14 = __webpack_require__("./command");
|
|
308
308
|
var __rspack_reexport = {};
|
|
309
309
|
for(const __rspack_import_key in _command__rspack_import_14)if ([
|
|
310
310
|
"TreeView",
|
|
@@ -339,7 +339,7 @@ var __webpack_exports__ = {};
|
|
|
339
339
|
"default"
|
|
340
340
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_datetime_picker__rspack_import_18[__rspack_import_key];
|
|
341
341
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
342
|
-
var _dialog__rspack_import_19 = __webpack_require__("
|
|
342
|
+
var _dialog__rspack_import_19 = __webpack_require__("@/components/ui/dialog");
|
|
343
343
|
var __rspack_reexport = {};
|
|
344
344
|
for(const __rspack_import_key in _dialog__rspack_import_19)if ([
|
|
345
345
|
"TreeView",
|
|
@@ -353,7 +353,7 @@ var __webpack_exports__ = {};
|
|
|
353
353
|
"default"
|
|
354
354
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_dropdown_menu__rspack_import_20[__rspack_import_key];
|
|
355
355
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
356
|
-
var _editable_cell__rspack_import_21 = __webpack_require__("
|
|
356
|
+
var _editable_cell__rspack_import_21 = __webpack_require__("./editable-cell");
|
|
357
357
|
var __rspack_reexport = {};
|
|
358
358
|
for(const __rspack_import_key in _editable_cell__rspack_import_21)if ([
|
|
359
359
|
"TreeView",
|
|
@@ -388,7 +388,7 @@ var __webpack_exports__ = {};
|
|
|
388
388
|
"default"
|
|
389
389
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_input__rspack_import_25[__rspack_import_key];
|
|
390
390
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
391
|
-
var _label__rspack_import_26 = __webpack_require__("
|
|
391
|
+
var _label__rspack_import_26 = __webpack_require__("@/components/ui/label");
|
|
392
392
|
var __rspack_reexport = {};
|
|
393
393
|
for(const __rspack_import_key in _label__rspack_import_26)if ([
|
|
394
394
|
"TreeView",
|
|
@@ -51,19 +51,19 @@ const buildItemMap = (items)=>{
|
|
|
51
51
|
};
|
|
52
52
|
const getCheckState = (item, itemMap)=>{
|
|
53
53
|
const originalItem = itemMap.get(item.id);
|
|
54
|
-
if (!originalItem) return
|
|
55
|
-
if (!originalItem.children || 0 === originalItem.children.length) return originalItem.checked ?
|
|
54
|
+
if (!originalItem) return 'unchecked';
|
|
55
|
+
if (!originalItem.children || 0 === originalItem.children.length) return originalItem.checked ? 'checked' : 'unchecked';
|
|
56
56
|
let checkedCount = 0;
|
|
57
57
|
let indeterminateCount = 0;
|
|
58
58
|
originalItem.children.forEach((child)=>{
|
|
59
59
|
const childState = getCheckState(child, itemMap);
|
|
60
|
-
if (
|
|
61
|
-
if (
|
|
60
|
+
if ('checked' === childState) checkedCount++;
|
|
61
|
+
if ('indeterminate' === childState) indeterminateCount++;
|
|
62
62
|
});
|
|
63
63
|
const totalChildren = originalItem.children.length;
|
|
64
|
-
if (checkedCount === totalChildren) return
|
|
65
|
-
if (checkedCount > 0 || indeterminateCount > 0) return
|
|
66
|
-
return
|
|
64
|
+
if (checkedCount === totalChildren) return 'checked';
|
|
65
|
+
if (checkedCount > 0 || indeterminateCount > 0) return 'indeterminate';
|
|
66
|
+
return 'unchecked';
|
|
67
67
|
};
|
|
68
68
|
const defaultIconMap = {
|
|
69
69
|
file: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Box, {
|
|
@@ -78,7 +78,7 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
78
78
|
const isSelected = selectedIds.has(item.id);
|
|
79
79
|
const isDisabled = true === item.disabled;
|
|
80
80
|
const itemRef = (0, external_react_namespaceObject.useRef)(null);
|
|
81
|
-
const [selectionStyle, setSelectionStyle] = (0, external_react_namespaceObject.useState)(
|
|
81
|
+
const [selectionStyle, setSelectionStyle] = (0, external_react_namespaceObject.useState)('');
|
|
82
82
|
const getVisibleItems = (0, external_react_namespaceObject.useCallback)((items)=>{
|
|
83
83
|
let visibleItems = [];
|
|
84
84
|
items.forEach((item)=>{
|
|
@@ -93,7 +93,7 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
93
93
|
expandedIds
|
|
94
94
|
]);
|
|
95
95
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
96
|
-
if (!isSelected) return void setSelectionStyle(
|
|
96
|
+
if (!isSelected) return void setSelectionStyle('');
|
|
97
97
|
const visibleItems = getVisibleItems(allItems);
|
|
98
98
|
const currentIndex = visibleItems.findIndex((i)=>i.id === item.id);
|
|
99
99
|
const prevItem = visibleItems[currentIndex - 1];
|
|
@@ -102,7 +102,7 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
102
102
|
const isNextSelected = nextItem && selectedIds.has(nextItem.id);
|
|
103
103
|
const roundTop = !isPrevSelected;
|
|
104
104
|
const roundBottom = !isNextSelected;
|
|
105
|
-
setSelectionStyle(`${roundTop ?
|
|
105
|
+
setSelectionStyle(`${roundTop ? 'rounded-t-md' : ''} ${roundBottom ? 'rounded-b-md' : ''}`);
|
|
106
106
|
}, [
|
|
107
107
|
isSelected,
|
|
108
108
|
selectedIds,
|
|
@@ -114,10 +114,10 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
114
114
|
const handleClick = (e)=>{
|
|
115
115
|
e.stopPropagation();
|
|
116
116
|
e.preventDefault();
|
|
117
|
-
if (isDisabled ||
|
|
117
|
+
if (isDisabled || 'none' === selectionMode) return;
|
|
118
118
|
let newSelection = new Set(selectedIds);
|
|
119
119
|
if (!itemRef.current) return;
|
|
120
|
-
if (
|
|
120
|
+
if ('single' === selectionMode) {
|
|
121
121
|
newSelection = new Set([
|
|
122
122
|
item.id
|
|
123
123
|
]);
|
|
@@ -127,18 +127,18 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
127
127
|
return;
|
|
128
128
|
}
|
|
129
129
|
if (e.shiftKey && null !== lastSelectedId.current) {
|
|
130
|
-
const items = Array.from(document.querySelectorAll(
|
|
131
|
-
const lastIndex = items.findIndex((el)=>el.getAttribute(
|
|
130
|
+
const items = Array.from(document.querySelectorAll('[data-tree-item]'));
|
|
131
|
+
const lastIndex = items.findIndex((el)=>el.getAttribute('data-id') === lastSelectedId.current);
|
|
132
132
|
const currentIndex = items.findIndex((el)=>el === itemRef.current);
|
|
133
133
|
const [start, end] = [
|
|
134
134
|
Math.min(lastIndex, currentIndex),
|
|
135
135
|
Math.max(lastIndex, currentIndex)
|
|
136
136
|
];
|
|
137
137
|
items.slice(start, end + 1).forEach((el)=>{
|
|
138
|
-
const id = el.getAttribute(
|
|
139
|
-
const isDisabledEl =
|
|
138
|
+
const id = el.getAttribute('data-id');
|
|
139
|
+
const isDisabledEl = 'true' === el.getAttribute('data-disabled');
|
|
140
140
|
const parentFolderClosed = el.closest('[data-folder-closed="true"]');
|
|
141
|
-
const isClosedFolder =
|
|
141
|
+
const isClosedFolder = 'true' === el.getAttribute('data-folder-closed');
|
|
142
142
|
if (id && !isDisabledEl && (isClosedFolder || !parentFolderClosed)) newSelection.add(id);
|
|
143
143
|
});
|
|
144
144
|
} else if (e.ctrlKey || e.metaKey) if (newSelection.has(item.id)) newSelection.delete(item.id);
|
|
@@ -156,7 +156,7 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
156
156
|
e.stopPropagation();
|
|
157
157
|
if (onAccessChange) {
|
|
158
158
|
const currentState = getCheckState(item, itemMap);
|
|
159
|
-
const newChecked =
|
|
159
|
+
const newChecked = 'checked' !== currentState;
|
|
160
160
|
onAccessChange(item, newChecked);
|
|
161
161
|
}
|
|
162
162
|
};
|
|
@@ -179,7 +179,7 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
179
179
|
}
|
|
180
180
|
};
|
|
181
181
|
findParent(item, items);
|
|
182
|
-
return path.join(
|
|
182
|
+
return path.join(' → ');
|
|
183
183
|
};
|
|
184
184
|
const getSelectedChildrenCount = (item)=>{
|
|
185
185
|
let count = 0;
|
|
@@ -200,7 +200,7 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
200
200
|
ref: itemRef,
|
|
201
201
|
role: "treeitem",
|
|
202
202
|
"aria-expanded": item.children ? isOpen : void 0,
|
|
203
|
-
"aria-selected": isSelected &&
|
|
203
|
+
"aria-selected": isSelected && 'none' !== selectionMode,
|
|
204
204
|
"aria-disabled": isDisabled,
|
|
205
205
|
tabIndex: 0,
|
|
206
206
|
"data-tree-item": true,
|
|
@@ -208,7 +208,7 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
208
208
|
"data-depth": depth,
|
|
209
209
|
"data-folder-closed": item.children && !isOpen,
|
|
210
210
|
"data-disabled": isDisabled,
|
|
211
|
-
className: `select-none rounded-md px-1 ${isDisabled ?
|
|
211
|
+
className: `select-none rounded-md px-1 ${isDisabled ? 'cursor-not-allowed opacity-50 text-muted-foreground' : `cursor-pointer ${isSelected && 'none' !== selectionMode ? `bg-accent ${selectionStyle}` : 'text-foreground hover:bg-muted/50'}`}`,
|
|
212
212
|
style: {
|
|
213
213
|
paddingLeft: `${20 * depth}px`
|
|
214
214
|
},
|
|
@@ -255,7 +255,7 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
255
255
|
onClick: handleAccessClick,
|
|
256
256
|
"aria-label": `Toggle access for ${item.name}`,
|
|
257
257
|
children: [
|
|
258
|
-
|
|
258
|
+
'checked' === getCheckState(item, itemMap) && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
259
259
|
className: "w-4 h-4 border rounded bg-primary border-primary flex items-center justify-center",
|
|
260
260
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("svg", {
|
|
261
261
|
className: "h-3 w-3 text-primary-foreground",
|
|
@@ -270,10 +270,10 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
270
270
|
})
|
|
271
271
|
})
|
|
272
272
|
}),
|
|
273
|
-
|
|
273
|
+
'unchecked' === getCheckState(item, itemMap) && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
274
274
|
className: "w-4 h-4 border rounded border-input"
|
|
275
275
|
}),
|
|
276
|
-
|
|
276
|
+
'indeterminate' === getCheckState(item, itemMap) && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
277
277
|
className: "w-4 h-4 border rounded bg-primary border-primary flex items-center justify-center",
|
|
278
278
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
279
279
|
className: "h-0.5 w-2 bg-primary-foreground"
|
|
@@ -354,8 +354,8 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
354
354
|
className: "font-medium",
|
|
355
355
|
children: "Type:"
|
|
356
356
|
}),
|
|
357
|
-
|
|
358
|
-
item.type.charAt(0).toUpperCase() + item.type.slice(1).replace(
|
|
357
|
+
' ',
|
|
358
|
+
item.type.charAt(0).toUpperCase() + item.type.slice(1).replace('_', ' ')
|
|
359
359
|
]
|
|
360
360
|
}),
|
|
361
361
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
@@ -374,7 +374,7 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
374
374
|
className: "font-medium",
|
|
375
375
|
children: "Location:"
|
|
376
376
|
}),
|
|
377
|
-
|
|
377
|
+
' ',
|
|
378
378
|
getItemPath(item, allItems)
|
|
379
379
|
]
|
|
380
380
|
}),
|
|
@@ -384,7 +384,7 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
384
384
|
className: "font-medium",
|
|
385
385
|
children: "Items:"
|
|
386
386
|
}),
|
|
387
|
-
|
|
387
|
+
' ',
|
|
388
388
|
item.children?.length ?? 0,
|
|
389
389
|
" direct items"
|
|
390
390
|
]
|
|
@@ -431,8 +431,8 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
431
431
|
className: "font-medium",
|
|
432
432
|
children: "Type:"
|
|
433
433
|
}),
|
|
434
|
-
|
|
435
|
-
item.type.charAt(0).toUpperCase() + item.type.slice(1).replace(
|
|
434
|
+
' ',
|
|
435
|
+
item.type.charAt(0).toUpperCase() + item.type.slice(1).replace('_', ' ')
|
|
436
436
|
]
|
|
437
437
|
}),
|
|
438
438
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
@@ -451,7 +451,7 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
451
451
|
className: "font-medium",
|
|
452
452
|
children: "Location:"
|
|
453
453
|
}),
|
|
454
|
-
|
|
454
|
+
' ',
|
|
455
455
|
getItemPath(item, allItems)
|
|
456
456
|
]
|
|
457
457
|
}),
|
|
@@ -461,7 +461,7 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
461
461
|
className: "font-medium",
|
|
462
462
|
children: "Items:"
|
|
463
463
|
}),
|
|
464
|
-
|
|
464
|
+
' ',
|
|
465
465
|
item.children?.length ?? 0,
|
|
466
466
|
" direct items"
|
|
467
467
|
]
|
|
@@ -480,11 +480,11 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
480
480
|
showSelectionCheckboxes && !item.children && !isDisabled && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_checkbox_cjs_namespaceObject.Checkbox, {
|
|
481
481
|
checked: isSelected,
|
|
482
482
|
onCheckedChange: (checked)=>{
|
|
483
|
-
if (
|
|
484
|
-
const newSelection =
|
|
483
|
+
if ('none' === selectionMode) return;
|
|
484
|
+
const newSelection = 'single' === selectionMode ? new Set(checked ? [
|
|
485
485
|
item.id
|
|
486
486
|
] : []) : new Set(selectedIds);
|
|
487
|
-
if (
|
|
487
|
+
if ('multiple' === selectionMode) if (checked) newSelection.add(item.id);
|
|
488
488
|
else newSelection.delete(item.id);
|
|
489
489
|
lastSelectedId.current = item.id;
|
|
490
490
|
onSelect(newSelection);
|
|
@@ -580,8 +580,8 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
580
580
|
className: "font-medium",
|
|
581
581
|
children: "Type:"
|
|
582
582
|
}),
|
|
583
|
-
|
|
584
|
-
item.type.charAt(0).toUpperCase() + item.type.slice(1).replace(
|
|
583
|
+
' ',
|
|
584
|
+
item.type.charAt(0).toUpperCase() + item.type.slice(1).replace('_', ' ')
|
|
585
585
|
]
|
|
586
586
|
}),
|
|
587
587
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
@@ -600,7 +600,7 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
600
600
|
className: "font-medium",
|
|
601
601
|
children: "Location:"
|
|
602
602
|
}),
|
|
603
|
-
|
|
603
|
+
' ',
|
|
604
604
|
getItemPath(item, allItems)
|
|
605
605
|
]
|
|
606
606
|
})
|
|
@@ -646,8 +646,8 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
646
646
|
className: "font-medium",
|
|
647
647
|
children: "Type:"
|
|
648
648
|
}),
|
|
649
|
-
|
|
650
|
-
item.type.charAt(0).toUpperCase() + item.type.slice(1).replace(
|
|
649
|
+
' ',
|
|
650
|
+
item.type.charAt(0).toUpperCase() + item.type.slice(1).replace('_', ' ')
|
|
651
651
|
]
|
|
652
652
|
}),
|
|
653
653
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
@@ -666,7 +666,7 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
666
666
|
className: "font-medium",
|
|
667
667
|
children: "Location:"
|
|
668
668
|
}),
|
|
669
|
-
|
|
669
|
+
' ',
|
|
670
670
|
getItemPath(item, allItems)
|
|
671
671
|
]
|
|
672
672
|
})
|
|
@@ -695,7 +695,7 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
695
695
|
opacity: 0
|
|
696
696
|
},
|
|
697
697
|
animate: {
|
|
698
|
-
height:
|
|
698
|
+
height: 'auto',
|
|
699
699
|
opacity: 1
|
|
700
700
|
},
|
|
701
701
|
exit: {
|
|
@@ -754,16 +754,16 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
754
754
|
});
|
|
755
755
|
}
|
|
756
756
|
function TreeView({ className, containerClassName, checkboxLabels = {
|
|
757
|
-
check:
|
|
758
|
-
uncheck:
|
|
759
|
-
}, data, iconMap, searchPlaceholder =
|
|
757
|
+
check: 'Check',
|
|
758
|
+
uncheck: 'Uncheck'
|
|
759
|
+
}, data, iconMap, searchPlaceholder = 'Search...', selectionText = 'selected', showExpandAll = true, showCheckboxes = false, showSelectionCheckboxes = false, selectionMode = 'multiple', title, getIcon, onSelectionChange, onAction, onCheckChange, menuItems }) {
|
|
760
760
|
const [currentMousePos, setCurrentMousePos] = (0, external_react_namespaceObject.useState)(0);
|
|
761
761
|
const [dragStart, setDragStart] = (0, external_react_namespaceObject.useState)(null);
|
|
762
762
|
const [dragStartPosition, setDragStartPosition] = (0, external_react_namespaceObject.useState)(null);
|
|
763
763
|
const [expandedIds, setExpandedIds] = (0, external_react_namespaceObject.useState)(new Set());
|
|
764
764
|
const [isDragging, setIsDragging] = (0, external_react_namespaceObject.useState)(false);
|
|
765
765
|
const [selectedIds, setSelectedIds] = (0, external_react_namespaceObject.useState)(new Set());
|
|
766
|
-
const [searchQuery, setSearchQuery] = (0, external_react_namespaceObject.useState)(
|
|
766
|
+
const [searchQuery, setSearchQuery] = (0, external_react_namespaceObject.useState)('');
|
|
767
767
|
const dragRef = (0, external_react_namespaceObject.useRef)(null);
|
|
768
768
|
const lastSelectedId = (0, external_react_namespaceObject.useRef)(null);
|
|
769
769
|
const treeRef = (0, external_react_namespaceObject.useRef)(null);
|
|
@@ -816,14 +816,14 @@ function TreeView({ className, containerClassName, checkboxLabels = {
|
|
|
816
816
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
817
817
|
const handleClickAway = (e)=>{
|
|
818
818
|
const target = e.target;
|
|
819
|
-
const clickedInside = treeRef.current && treeRef.current.contains(target) || dragRef.current && dragRef.current.contains(target) || target.closest('[role="menu"]') || target.closest(
|
|
819
|
+
const clickedInside = treeRef.current && treeRef.current.contains(target) || dragRef.current && dragRef.current.contains(target) || target.closest('[role="menu"]') || target.closest('[data-radix-popper-content-wrapper]');
|
|
820
820
|
if (!clickedInside) {
|
|
821
821
|
setSelectedIds(new Set());
|
|
822
822
|
lastSelectedId.current = null;
|
|
823
823
|
}
|
|
824
824
|
};
|
|
825
|
-
document.addEventListener(
|
|
826
|
-
return ()=>document.removeEventListener(
|
|
825
|
+
document.addEventListener('mousedown', handleClickAway);
|
|
826
|
+
return ()=>document.removeEventListener('mousedown', handleClickAway);
|
|
827
827
|
}, []);
|
|
828
828
|
const getAllFolderIds = (items)=>{
|
|
829
829
|
let ids = [];
|
|
@@ -874,14 +874,14 @@ function TreeView({ className, containerClassName, checkboxLabels = {
|
|
|
874
874
|
getSelectedItems
|
|
875
875
|
]);
|
|
876
876
|
const handleMouseDown = (0, external_react_namespaceObject.useCallback)((e)=>{
|
|
877
|
-
if (0 !== e.button || e.target.closest(
|
|
877
|
+
if (0 !== e.button || e.target.closest('button')) return;
|
|
878
878
|
setDragStartPosition({
|
|
879
879
|
x: e.clientX,
|
|
880
880
|
y: e.clientY
|
|
881
881
|
});
|
|
882
882
|
}, []);
|
|
883
883
|
const handleMouseMove = (0, external_react_namespaceObject.useCallback)((e)=>{
|
|
884
|
-
if (
|
|
884
|
+
if ('none' === selectionMode) return;
|
|
885
885
|
if (!(1 & e.buttons)) {
|
|
886
886
|
setIsDragging(false);
|
|
887
887
|
setDragStart(null);
|
|
@@ -904,7 +904,7 @@ function TreeView({ className, containerClassName, checkboxLabels = {
|
|
|
904
904
|
return;
|
|
905
905
|
}
|
|
906
906
|
if (!dragRef.current) return;
|
|
907
|
-
const items = Array.from(dragRef.current.querySelectorAll(
|
|
907
|
+
const items = Array.from(dragRef.current.querySelectorAll('[data-tree-item]'));
|
|
908
908
|
const startY = dragStart;
|
|
909
909
|
const currentY = e.clientY;
|
|
910
910
|
const [selectionStart, selectionEnd] = [
|
|
@@ -917,9 +917,9 @@ function TreeView({ className, containerClassName, checkboxLabels = {
|
|
|
917
917
|
const itemTop = rect.top;
|
|
918
918
|
const itemBottom = rect.top + rect.height;
|
|
919
919
|
if (itemBottom >= selectionStart && itemTop <= selectionEnd) {
|
|
920
|
-
const id = item.getAttribute(
|
|
921
|
-
const isDisabledEl =
|
|
922
|
-
const isClosedFolder =
|
|
920
|
+
const id = item.getAttribute('data-id');
|
|
921
|
+
const isDisabledEl = 'true' === item.getAttribute('data-disabled');
|
|
922
|
+
const isClosedFolder = 'true' === item.getAttribute('data-folder-closed');
|
|
923
923
|
const parentFolderClosed = item.closest('[data-folder-closed="true"]');
|
|
924
924
|
if (id && !isDisabledEl && (isClosedFolder || !parentFolderClosed)) newSelection.add(id);
|
|
925
925
|
}
|
|
@@ -940,12 +940,12 @@ function TreeView({ className, containerClassName, checkboxLabels = {
|
|
|
940
940
|
}, []);
|
|
941
941
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
942
942
|
if (isDragging) {
|
|
943
|
-
document.addEventListener(
|
|
944
|
-
document.addEventListener(
|
|
943
|
+
document.addEventListener('mouseup', handleMouseUp);
|
|
944
|
+
document.addEventListener('mouseleave', handleMouseUp);
|
|
945
945
|
}
|
|
946
946
|
return ()=>{
|
|
947
|
-
document.removeEventListener(
|
|
948
|
-
document.removeEventListener(
|
|
947
|
+
document.removeEventListener('mouseup', handleMouseUp);
|
|
948
|
+
document.removeEventListener('mouseleave', handleMouseUp);
|
|
949
949
|
};
|
|
950
950
|
}, [
|
|
951
951
|
isDragging,
|
|
@@ -959,10 +959,10 @@ function TreeView({ className, containerClassName, checkboxLabels = {
|
|
|
959
959
|
getSelectedItems
|
|
960
960
|
]);
|
|
961
961
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
962
|
-
className: (0, index_cjs_namespaceObject.cn)(
|
|
962
|
+
className: (0, index_cjs_namespaceObject.cn)('flex gap-4 min-w-0', containerClassName ? 'w-full' : ''),
|
|
963
963
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
964
964
|
ref: treeRef,
|
|
965
|
-
className: (0, index_cjs_namespaceObject.cn)(
|
|
965
|
+
className: (0, index_cjs_namespaceObject.cn)('bg-background rounded-xl border space-y-4 relative shadow-lg flex flex-col min-w-0 overflow-hidden', containerClassName ?? 'p-6 max-w-2xl w-[600px]'),
|
|
966
966
|
children: [
|
|
967
967
|
title && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
968
968
|
className: "text-sm font-medium text-foreground shrink-0",
|
|
@@ -1006,7 +1006,7 @@ function TreeView({ className, containerClassName, checkboxLabels = {
|
|
|
1006
1006
|
]
|
|
1007
1007
|
})
|
|
1008
1008
|
}),
|
|
1009
|
-
|
|
1009
|
+
'none' !== selectionMode && selectedIds.size > 0 ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
1010
1010
|
className: "flex items-center gap-2",
|
|
1011
1011
|
children: [
|
|
1012
1012
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("span", {
|
|
@@ -1072,7 +1072,7 @@ function TreeView({ className, containerClassName, checkboxLabels = {
|
|
|
1072
1072
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("section", {
|
|
1073
1073
|
ref: dragRef,
|
|
1074
1074
|
"aria-label": "Tree view content",
|
|
1075
|
-
className: (0, index_cjs_namespaceObject.cn)(
|
|
1075
|
+
className: (0, index_cjs_namespaceObject.cn)('rounded-lg relative select-none min-w-0 overflow-x-hidden', className),
|
|
1076
1076
|
onMouseDown: handleMouseDown,
|
|
1077
1077
|
onMouseMove: handleMouseMove,
|
|
1078
1078
|
children: [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as React from
|
|
1
|
+
import * as React from 'react';
|
|
2
2
|
/**
|
|
3
3
|
* Action shown in the item's dropdown menu (Edit, Delete, etc.).
|
|
4
4
|
* Actions appear as a single "more" icon that opens a dropdown to avoid horizontal overflow.
|
|
@@ -51,7 +51,7 @@ export interface TreeViewMenuItem {
|
|
|
51
51
|
* - `"single"`: Only one item can be selected at a time
|
|
52
52
|
* - `"none"`: No selection; expand/collapse only
|
|
53
53
|
*/
|
|
54
|
-
export type TreeViewSelectionMode =
|
|
54
|
+
export type TreeViewSelectionMode = 'single' | 'multiple' | 'none';
|
|
55
55
|
export interface TreeViewProps {
|
|
56
56
|
className?: string;
|
|
57
57
|
containerClassName?: string;
|
|
@@ -63,7 +63,7 @@ export interface TreeViewProps {
|
|
|
63
63
|
showSelectionCheckboxes?: boolean;
|
|
64
64
|
/** Selection behavior: "multiple" (default), "single", or "none" */
|
|
65
65
|
selectionMode?: TreeViewSelectionMode;
|
|
66
|
-
checkboxPosition?:
|
|
66
|
+
checkboxPosition?: 'left' | 'right';
|
|
67
67
|
searchPlaceholder?: string;
|
|
68
68
|
selectionText?: string;
|
|
69
69
|
checkboxLabels?: {
|
|
@@ -23,19 +23,19 @@ const buildItemMap = (items)=>{
|
|
|
23
23
|
};
|
|
24
24
|
const getCheckState = (item, itemMap)=>{
|
|
25
25
|
const originalItem = itemMap.get(item.id);
|
|
26
|
-
if (!originalItem) return
|
|
27
|
-
if (!originalItem.children || 0 === originalItem.children.length) return originalItem.checked ?
|
|
26
|
+
if (!originalItem) return 'unchecked';
|
|
27
|
+
if (!originalItem.children || 0 === originalItem.children.length) return originalItem.checked ? 'checked' : 'unchecked';
|
|
28
28
|
let checkedCount = 0;
|
|
29
29
|
let indeterminateCount = 0;
|
|
30
30
|
originalItem.children.forEach((child)=>{
|
|
31
31
|
const childState = getCheckState(child, itemMap);
|
|
32
|
-
if (
|
|
33
|
-
if (
|
|
32
|
+
if ('checked' === childState) checkedCount++;
|
|
33
|
+
if ('indeterminate' === childState) indeterminateCount++;
|
|
34
34
|
});
|
|
35
35
|
const totalChildren = originalItem.children.length;
|
|
36
|
-
if (checkedCount === totalChildren) return
|
|
37
|
-
if (checkedCount > 0 || indeterminateCount > 0) return
|
|
38
|
-
return
|
|
36
|
+
if (checkedCount === totalChildren) return 'checked';
|
|
37
|
+
if (checkedCount > 0 || indeterminateCount > 0) return 'indeterminate';
|
|
38
|
+
return 'unchecked';
|
|
39
39
|
};
|
|
40
40
|
const defaultIconMap = {
|
|
41
41
|
file: /*#__PURE__*/ jsx(Box, {
|
|
@@ -50,7 +50,7 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
50
50
|
const isSelected = selectedIds.has(item.id);
|
|
51
51
|
const isDisabled = true === item.disabled;
|
|
52
52
|
const itemRef = useRef(null);
|
|
53
|
-
const [selectionStyle, setSelectionStyle] = useState(
|
|
53
|
+
const [selectionStyle, setSelectionStyle] = useState('');
|
|
54
54
|
const getVisibleItems = useCallback((items)=>{
|
|
55
55
|
let visibleItems = [];
|
|
56
56
|
items.forEach((item)=>{
|
|
@@ -65,7 +65,7 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
65
65
|
expandedIds
|
|
66
66
|
]);
|
|
67
67
|
useEffect(()=>{
|
|
68
|
-
if (!isSelected) return void setSelectionStyle(
|
|
68
|
+
if (!isSelected) return void setSelectionStyle('');
|
|
69
69
|
const visibleItems = getVisibleItems(allItems);
|
|
70
70
|
const currentIndex = visibleItems.findIndex((i)=>i.id === item.id);
|
|
71
71
|
const prevItem = visibleItems[currentIndex - 1];
|
|
@@ -74,7 +74,7 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
74
74
|
const isNextSelected = nextItem && selectedIds.has(nextItem.id);
|
|
75
75
|
const roundTop = !isPrevSelected;
|
|
76
76
|
const roundBottom = !isNextSelected;
|
|
77
|
-
setSelectionStyle(`${roundTop ?
|
|
77
|
+
setSelectionStyle(`${roundTop ? 'rounded-t-md' : ''} ${roundBottom ? 'rounded-b-md' : ''}`);
|
|
78
78
|
}, [
|
|
79
79
|
isSelected,
|
|
80
80
|
selectedIds,
|
|
@@ -86,10 +86,10 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
86
86
|
const handleClick = (e)=>{
|
|
87
87
|
e.stopPropagation();
|
|
88
88
|
e.preventDefault();
|
|
89
|
-
if (isDisabled ||
|
|
89
|
+
if (isDisabled || 'none' === selectionMode) return;
|
|
90
90
|
let newSelection = new Set(selectedIds);
|
|
91
91
|
if (!itemRef.current) return;
|
|
92
|
-
if (
|
|
92
|
+
if ('single' === selectionMode) {
|
|
93
93
|
newSelection = new Set([
|
|
94
94
|
item.id
|
|
95
95
|
]);
|
|
@@ -99,18 +99,18 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
99
99
|
return;
|
|
100
100
|
}
|
|
101
101
|
if (e.shiftKey && null !== lastSelectedId.current) {
|
|
102
|
-
const items = Array.from(document.querySelectorAll(
|
|
103
|
-
const lastIndex = items.findIndex((el)=>el.getAttribute(
|
|
102
|
+
const items = Array.from(document.querySelectorAll('[data-tree-item]'));
|
|
103
|
+
const lastIndex = items.findIndex((el)=>el.getAttribute('data-id') === lastSelectedId.current);
|
|
104
104
|
const currentIndex = items.findIndex((el)=>el === itemRef.current);
|
|
105
105
|
const [start, end] = [
|
|
106
106
|
Math.min(lastIndex, currentIndex),
|
|
107
107
|
Math.max(lastIndex, currentIndex)
|
|
108
108
|
];
|
|
109
109
|
items.slice(start, end + 1).forEach((el)=>{
|
|
110
|
-
const id = el.getAttribute(
|
|
111
|
-
const isDisabledEl =
|
|
110
|
+
const id = el.getAttribute('data-id');
|
|
111
|
+
const isDisabledEl = 'true' === el.getAttribute('data-disabled');
|
|
112
112
|
const parentFolderClosed = el.closest('[data-folder-closed="true"]');
|
|
113
|
-
const isClosedFolder =
|
|
113
|
+
const isClosedFolder = 'true' === el.getAttribute('data-folder-closed');
|
|
114
114
|
if (id && !isDisabledEl && (isClosedFolder || !parentFolderClosed)) newSelection.add(id);
|
|
115
115
|
});
|
|
116
116
|
} else if (e.ctrlKey || e.metaKey) if (newSelection.has(item.id)) newSelection.delete(item.id);
|
|
@@ -128,7 +128,7 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
128
128
|
e.stopPropagation();
|
|
129
129
|
if (onAccessChange) {
|
|
130
130
|
const currentState = getCheckState(item, itemMap);
|
|
131
|
-
const newChecked =
|
|
131
|
+
const newChecked = 'checked' !== currentState;
|
|
132
132
|
onAccessChange(item, newChecked);
|
|
133
133
|
}
|
|
134
134
|
};
|
|
@@ -151,7 +151,7 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
151
151
|
}
|
|
152
152
|
};
|
|
153
153
|
findParent(item, items);
|
|
154
|
-
return path.join(
|
|
154
|
+
return path.join(' → ');
|
|
155
155
|
};
|
|
156
156
|
const getSelectedChildrenCount = (item)=>{
|
|
157
157
|
let count = 0;
|
|
@@ -172,7 +172,7 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
172
172
|
ref: itemRef,
|
|
173
173
|
role: "treeitem",
|
|
174
174
|
"aria-expanded": item.children ? isOpen : void 0,
|
|
175
|
-
"aria-selected": isSelected &&
|
|
175
|
+
"aria-selected": isSelected && 'none' !== selectionMode,
|
|
176
176
|
"aria-disabled": isDisabled,
|
|
177
177
|
tabIndex: 0,
|
|
178
178
|
"data-tree-item": true,
|
|
@@ -180,7 +180,7 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
180
180
|
"data-depth": depth,
|
|
181
181
|
"data-folder-closed": item.children && !isOpen,
|
|
182
182
|
"data-disabled": isDisabled,
|
|
183
|
-
className: `select-none rounded-md px-1 ${isDisabled ?
|
|
183
|
+
className: `select-none rounded-md px-1 ${isDisabled ? 'cursor-not-allowed opacity-50 text-muted-foreground' : `cursor-pointer ${isSelected && 'none' !== selectionMode ? `bg-accent ${selectionStyle}` : 'text-foreground hover:bg-muted/50'}`}`,
|
|
184
184
|
style: {
|
|
185
185
|
paddingLeft: `${20 * depth}px`
|
|
186
186
|
},
|
|
@@ -227,7 +227,7 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
227
227
|
onClick: handleAccessClick,
|
|
228
228
|
"aria-label": `Toggle access for ${item.name}`,
|
|
229
229
|
children: [
|
|
230
|
-
|
|
230
|
+
'checked' === getCheckState(item, itemMap) && /*#__PURE__*/ jsx("div", {
|
|
231
231
|
className: "w-4 h-4 border rounded bg-primary border-primary flex items-center justify-center",
|
|
232
232
|
children: /*#__PURE__*/ jsx("svg", {
|
|
233
233
|
className: "h-3 w-3 text-primary-foreground",
|
|
@@ -242,10 +242,10 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
242
242
|
})
|
|
243
243
|
})
|
|
244
244
|
}),
|
|
245
|
-
|
|
245
|
+
'unchecked' === getCheckState(item, itemMap) && /*#__PURE__*/ jsx("div", {
|
|
246
246
|
className: "w-4 h-4 border rounded border-input"
|
|
247
247
|
}),
|
|
248
|
-
|
|
248
|
+
'indeterminate' === getCheckState(item, itemMap) && /*#__PURE__*/ jsx("div", {
|
|
249
249
|
className: "w-4 h-4 border rounded bg-primary border-primary flex items-center justify-center",
|
|
250
250
|
children: /*#__PURE__*/ jsx("div", {
|
|
251
251
|
className: "h-0.5 w-2 bg-primary-foreground"
|
|
@@ -326,8 +326,8 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
326
326
|
className: "font-medium",
|
|
327
327
|
children: "Type:"
|
|
328
328
|
}),
|
|
329
|
-
|
|
330
|
-
item.type.charAt(0).toUpperCase() + item.type.slice(1).replace(
|
|
329
|
+
' ',
|
|
330
|
+
item.type.charAt(0).toUpperCase() + item.type.slice(1).replace('_', ' ')
|
|
331
331
|
]
|
|
332
332
|
}),
|
|
333
333
|
/*#__PURE__*/ jsxs("div", {
|
|
@@ -346,7 +346,7 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
346
346
|
className: "font-medium",
|
|
347
347
|
children: "Location:"
|
|
348
348
|
}),
|
|
349
|
-
|
|
349
|
+
' ',
|
|
350
350
|
getItemPath(item, allItems)
|
|
351
351
|
]
|
|
352
352
|
}),
|
|
@@ -356,7 +356,7 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
356
356
|
className: "font-medium",
|
|
357
357
|
children: "Items:"
|
|
358
358
|
}),
|
|
359
|
-
|
|
359
|
+
' ',
|
|
360
360
|
item.children?.length ?? 0,
|
|
361
361
|
" direct items"
|
|
362
362
|
]
|
|
@@ -403,8 +403,8 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
403
403
|
className: "font-medium",
|
|
404
404
|
children: "Type:"
|
|
405
405
|
}),
|
|
406
|
-
|
|
407
|
-
item.type.charAt(0).toUpperCase() + item.type.slice(1).replace(
|
|
406
|
+
' ',
|
|
407
|
+
item.type.charAt(0).toUpperCase() + item.type.slice(1).replace('_', ' ')
|
|
408
408
|
]
|
|
409
409
|
}),
|
|
410
410
|
/*#__PURE__*/ jsxs("div", {
|
|
@@ -423,7 +423,7 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
423
423
|
className: "font-medium",
|
|
424
424
|
children: "Location:"
|
|
425
425
|
}),
|
|
426
|
-
|
|
426
|
+
' ',
|
|
427
427
|
getItemPath(item, allItems)
|
|
428
428
|
]
|
|
429
429
|
}),
|
|
@@ -433,7 +433,7 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
433
433
|
className: "font-medium",
|
|
434
434
|
children: "Items:"
|
|
435
435
|
}),
|
|
436
|
-
|
|
436
|
+
' ',
|
|
437
437
|
item.children?.length ?? 0,
|
|
438
438
|
" direct items"
|
|
439
439
|
]
|
|
@@ -452,11 +452,11 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
452
452
|
showSelectionCheckboxes && !item.children && !isDisabled && /*#__PURE__*/ jsx(Checkbox, {
|
|
453
453
|
checked: isSelected,
|
|
454
454
|
onCheckedChange: (checked)=>{
|
|
455
|
-
if (
|
|
456
|
-
const newSelection =
|
|
455
|
+
if ('none' === selectionMode) return;
|
|
456
|
+
const newSelection = 'single' === selectionMode ? new Set(checked ? [
|
|
457
457
|
item.id
|
|
458
458
|
] : []) : new Set(selectedIds);
|
|
459
|
-
if (
|
|
459
|
+
if ('multiple' === selectionMode) if (checked) newSelection.add(item.id);
|
|
460
460
|
else newSelection.delete(item.id);
|
|
461
461
|
lastSelectedId.current = item.id;
|
|
462
462
|
onSelect(newSelection);
|
|
@@ -552,8 +552,8 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
552
552
|
className: "font-medium",
|
|
553
553
|
children: "Type:"
|
|
554
554
|
}),
|
|
555
|
-
|
|
556
|
-
item.type.charAt(0).toUpperCase() + item.type.slice(1).replace(
|
|
555
|
+
' ',
|
|
556
|
+
item.type.charAt(0).toUpperCase() + item.type.slice(1).replace('_', ' ')
|
|
557
557
|
]
|
|
558
558
|
}),
|
|
559
559
|
/*#__PURE__*/ jsxs("div", {
|
|
@@ -572,7 +572,7 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
572
572
|
className: "font-medium",
|
|
573
573
|
children: "Location:"
|
|
574
574
|
}),
|
|
575
|
-
|
|
575
|
+
' ',
|
|
576
576
|
getItemPath(item, allItems)
|
|
577
577
|
]
|
|
578
578
|
})
|
|
@@ -618,8 +618,8 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
618
618
|
className: "font-medium",
|
|
619
619
|
children: "Type:"
|
|
620
620
|
}),
|
|
621
|
-
|
|
622
|
-
item.type.charAt(0).toUpperCase() + item.type.slice(1).replace(
|
|
621
|
+
' ',
|
|
622
|
+
item.type.charAt(0).toUpperCase() + item.type.slice(1).replace('_', ' ')
|
|
623
623
|
]
|
|
624
624
|
}),
|
|
625
625
|
/*#__PURE__*/ jsxs("div", {
|
|
@@ -638,7 +638,7 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
638
638
|
className: "font-medium",
|
|
639
639
|
children: "Location:"
|
|
640
640
|
}),
|
|
641
|
-
|
|
641
|
+
' ',
|
|
642
642
|
getItemPath(item, allItems)
|
|
643
643
|
]
|
|
644
644
|
})
|
|
@@ -667,7 +667,7 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
667
667
|
opacity: 0
|
|
668
668
|
},
|
|
669
669
|
animate: {
|
|
670
|
-
height:
|
|
670
|
+
height: 'auto',
|
|
671
671
|
opacity: 1
|
|
672
672
|
},
|
|
673
673
|
exit: {
|
|
@@ -726,16 +726,16 @@ function TreeItem({ item, depth = 0, selectedIds, lastSelectedId, onSelect, expa
|
|
|
726
726
|
});
|
|
727
727
|
}
|
|
728
728
|
function TreeView({ className, containerClassName, checkboxLabels = {
|
|
729
|
-
check:
|
|
730
|
-
uncheck:
|
|
731
|
-
}, data, iconMap, searchPlaceholder =
|
|
729
|
+
check: 'Check',
|
|
730
|
+
uncheck: 'Uncheck'
|
|
731
|
+
}, data, iconMap, searchPlaceholder = 'Search...', selectionText = 'selected', showExpandAll = true, showCheckboxes = false, showSelectionCheckboxes = false, selectionMode = 'multiple', title, getIcon, onSelectionChange, onAction, onCheckChange, menuItems }) {
|
|
732
732
|
const [currentMousePos, setCurrentMousePos] = useState(0);
|
|
733
733
|
const [dragStart, setDragStart] = useState(null);
|
|
734
734
|
const [dragStartPosition, setDragStartPosition] = useState(null);
|
|
735
735
|
const [expandedIds, setExpandedIds] = useState(new Set());
|
|
736
736
|
const [isDragging, setIsDragging] = useState(false);
|
|
737
737
|
const [selectedIds, setSelectedIds] = useState(new Set());
|
|
738
|
-
const [searchQuery, setSearchQuery] = useState(
|
|
738
|
+
const [searchQuery, setSearchQuery] = useState('');
|
|
739
739
|
const dragRef = useRef(null);
|
|
740
740
|
const lastSelectedId = useRef(null);
|
|
741
741
|
const treeRef = useRef(null);
|
|
@@ -788,14 +788,14 @@ function TreeView({ className, containerClassName, checkboxLabels = {
|
|
|
788
788
|
useEffect(()=>{
|
|
789
789
|
const handleClickAway = (e)=>{
|
|
790
790
|
const target = e.target;
|
|
791
|
-
const clickedInside = treeRef.current && treeRef.current.contains(target) || dragRef.current && dragRef.current.contains(target) || target.closest('[role="menu"]') || target.closest(
|
|
791
|
+
const clickedInside = treeRef.current && treeRef.current.contains(target) || dragRef.current && dragRef.current.contains(target) || target.closest('[role="menu"]') || target.closest('[data-radix-popper-content-wrapper]');
|
|
792
792
|
if (!clickedInside) {
|
|
793
793
|
setSelectedIds(new Set());
|
|
794
794
|
lastSelectedId.current = null;
|
|
795
795
|
}
|
|
796
796
|
};
|
|
797
|
-
document.addEventListener(
|
|
798
|
-
return ()=>document.removeEventListener(
|
|
797
|
+
document.addEventListener('mousedown', handleClickAway);
|
|
798
|
+
return ()=>document.removeEventListener('mousedown', handleClickAway);
|
|
799
799
|
}, []);
|
|
800
800
|
const getAllFolderIds = (items)=>{
|
|
801
801
|
let ids = [];
|
|
@@ -846,14 +846,14 @@ function TreeView({ className, containerClassName, checkboxLabels = {
|
|
|
846
846
|
getSelectedItems
|
|
847
847
|
]);
|
|
848
848
|
const handleMouseDown = useCallback((e)=>{
|
|
849
|
-
if (0 !== e.button || e.target.closest(
|
|
849
|
+
if (0 !== e.button || e.target.closest('button')) return;
|
|
850
850
|
setDragStartPosition({
|
|
851
851
|
x: e.clientX,
|
|
852
852
|
y: e.clientY
|
|
853
853
|
});
|
|
854
854
|
}, []);
|
|
855
855
|
const handleMouseMove = useCallback((e)=>{
|
|
856
|
-
if (
|
|
856
|
+
if ('none' === selectionMode) return;
|
|
857
857
|
if (!(1 & e.buttons)) {
|
|
858
858
|
setIsDragging(false);
|
|
859
859
|
setDragStart(null);
|
|
@@ -876,7 +876,7 @@ function TreeView({ className, containerClassName, checkboxLabels = {
|
|
|
876
876
|
return;
|
|
877
877
|
}
|
|
878
878
|
if (!dragRef.current) return;
|
|
879
|
-
const items = Array.from(dragRef.current.querySelectorAll(
|
|
879
|
+
const items = Array.from(dragRef.current.querySelectorAll('[data-tree-item]'));
|
|
880
880
|
const startY = dragStart;
|
|
881
881
|
const currentY = e.clientY;
|
|
882
882
|
const [selectionStart, selectionEnd] = [
|
|
@@ -889,9 +889,9 @@ function TreeView({ className, containerClassName, checkboxLabels = {
|
|
|
889
889
|
const itemTop = rect.top;
|
|
890
890
|
const itemBottom = rect.top + rect.height;
|
|
891
891
|
if (itemBottom >= selectionStart && itemTop <= selectionEnd) {
|
|
892
|
-
const id = item.getAttribute(
|
|
893
|
-
const isDisabledEl =
|
|
894
|
-
const isClosedFolder =
|
|
892
|
+
const id = item.getAttribute('data-id');
|
|
893
|
+
const isDisabledEl = 'true' === item.getAttribute('data-disabled');
|
|
894
|
+
const isClosedFolder = 'true' === item.getAttribute('data-folder-closed');
|
|
895
895
|
const parentFolderClosed = item.closest('[data-folder-closed="true"]');
|
|
896
896
|
if (id && !isDisabledEl && (isClosedFolder || !parentFolderClosed)) newSelection.add(id);
|
|
897
897
|
}
|
|
@@ -912,12 +912,12 @@ function TreeView({ className, containerClassName, checkboxLabels = {
|
|
|
912
912
|
}, []);
|
|
913
913
|
useEffect(()=>{
|
|
914
914
|
if (isDragging) {
|
|
915
|
-
document.addEventListener(
|
|
916
|
-
document.addEventListener(
|
|
915
|
+
document.addEventListener('mouseup', handleMouseUp);
|
|
916
|
+
document.addEventListener('mouseleave', handleMouseUp);
|
|
917
917
|
}
|
|
918
918
|
return ()=>{
|
|
919
|
-
document.removeEventListener(
|
|
920
|
-
document.removeEventListener(
|
|
919
|
+
document.removeEventListener('mouseup', handleMouseUp);
|
|
920
|
+
document.removeEventListener('mouseleave', handleMouseUp);
|
|
921
921
|
};
|
|
922
922
|
}, [
|
|
923
923
|
isDragging,
|
|
@@ -931,10 +931,10 @@ function TreeView({ className, containerClassName, checkboxLabels = {
|
|
|
931
931
|
getSelectedItems
|
|
932
932
|
]);
|
|
933
933
|
return /*#__PURE__*/ jsx("div", {
|
|
934
|
-
className: cn(
|
|
934
|
+
className: cn('flex gap-4 min-w-0', containerClassName ? 'w-full' : ''),
|
|
935
935
|
children: /*#__PURE__*/ jsxs("div", {
|
|
936
936
|
ref: treeRef,
|
|
937
|
-
className: cn(
|
|
937
|
+
className: cn('bg-background rounded-xl border space-y-4 relative shadow-lg flex flex-col min-w-0 overflow-hidden', containerClassName ?? 'p-6 max-w-2xl w-[600px]'),
|
|
938
938
|
children: [
|
|
939
939
|
title && /*#__PURE__*/ jsx("div", {
|
|
940
940
|
className: "text-sm font-medium text-foreground shrink-0",
|
|
@@ -978,7 +978,7 @@ function TreeView({ className, containerClassName, checkboxLabels = {
|
|
|
978
978
|
]
|
|
979
979
|
})
|
|
980
980
|
}),
|
|
981
|
-
|
|
981
|
+
'none' !== selectionMode && selectedIds.size > 0 ? /*#__PURE__*/ jsxs("div", {
|
|
982
982
|
className: "flex items-center gap-2",
|
|
983
983
|
children: [
|
|
984
984
|
/*#__PURE__*/ jsxs("span", {
|
|
@@ -1044,7 +1044,7 @@ function TreeView({ className, containerClassName, checkboxLabels = {
|
|
|
1044
1044
|
/*#__PURE__*/ jsxs("section", {
|
|
1045
1045
|
ref: dragRef,
|
|
1046
1046
|
"aria-label": "Tree view content",
|
|
1047
|
-
className: cn(
|
|
1047
|
+
className: cn('rounded-lg relative select-none min-w-0 overflow-x-hidden', className),
|
|
1048
1048
|
onMouseDown: handleMouseDown,
|
|
1049
1049
|
onMouseMove: handleMouseMove,
|
|
1050
1050
|
children: [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/apollo-wind",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "UiPath wind design system - A Tailwind CSS based React component library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -145,7 +145,7 @@
|
|
|
145
145
|
"postcss-import": "^16.1.1",
|
|
146
146
|
"react": "19.2.3",
|
|
147
147
|
"react-dom": "19.2.3",
|
|
148
|
-
"react-scan": "^0.
|
|
148
|
+
"react-scan": "^0.5.3",
|
|
149
149
|
"semantic-release": "^25.0.3",
|
|
150
150
|
"storybook": "^10.2.15",
|
|
151
151
|
"tailwindcss": "^4.1.17",
|