react-aria-components 1.9.0 → 1.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/dist/Checkbox.main.js +4 -1
- package/dist/Checkbox.main.js.map +1 -1
- package/dist/Checkbox.mjs +5 -2
- package/dist/Checkbox.module.js +5 -2
- package/dist/Checkbox.module.js.map +1 -1
- package/dist/Collection.main.js +31 -7
- package/dist/Collection.main.js.map +1 -1
- package/dist/Collection.mjs +32 -9
- package/dist/Collection.module.js +32 -9
- package/dist/Collection.module.js.map +1 -1
- package/dist/ComboBox.main.js +10 -1
- package/dist/ComboBox.main.js.map +1 -1
- package/dist/ComboBox.mjs +10 -1
- package/dist/ComboBox.module.js +10 -1
- package/dist/ComboBox.module.js.map +1 -1
- package/dist/DatePicker.main.js +11 -2
- package/dist/DatePicker.main.js.map +1 -1
- package/dist/DatePicker.mjs +11 -2
- package/dist/DatePicker.module.js +11 -2
- package/dist/DatePicker.module.js.map +1 -1
- package/dist/DragAndDrop.main.js.map +1 -1
- package/dist/DragAndDrop.module.js.map +1 -1
- package/dist/Popover.main.js +12 -2
- package/dist/Popover.main.js.map +1 -1
- package/dist/Popover.mjs +13 -3
- package/dist/Popover.module.js +13 -3
- package/dist/Popover.module.js.map +1 -1
- package/dist/RadioGroup.main.js +4 -1
- package/dist/RadioGroup.main.js.map +1 -1
- package/dist/RadioGroup.mjs +5 -2
- package/dist/RadioGroup.module.js +5 -2
- package/dist/RadioGroup.module.js.map +1 -1
- package/dist/Select.main.js +10 -2
- package/dist/Select.main.js.map +1 -1
- package/dist/Select.mjs +10 -2
- package/dist/Select.module.js +10 -2
- package/dist/Select.module.js.map +1 -1
- package/dist/Tree.main.js +296 -18
- package/dist/Tree.main.js.map +1 -1
- package/dist/Tree.mjs +299 -21
- package/dist/Tree.module.js +299 -21
- package/dist/Tree.module.js.map +1 -1
- package/dist/TreeDropTargetDelegate.main.js +213 -0
- package/dist/TreeDropTargetDelegate.main.js.map +1 -0
- package/dist/TreeDropTargetDelegate.mjs +208 -0
- package/dist/TreeDropTargetDelegate.module.js +208 -0
- package/dist/TreeDropTargetDelegate.module.js.map +1 -0
- package/dist/Virtualizer.main.js +8 -9
- package/dist/Virtualizer.main.js.map +1 -1
- package/dist/Virtualizer.mjs +9 -10
- package/dist/Virtualizer.module.js +9 -10
- package/dist/Virtualizer.module.js.map +1 -1
- package/dist/main.js.map +1 -1
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +23 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/useDragAndDrop.main.js +2 -2
- package/dist/useDragAndDrop.main.js.map +1 -1
- package/dist/useDragAndDrop.mjs +2 -2
- package/dist/useDragAndDrop.module.js +2 -2
- package/dist/useDragAndDrop.module.js.map +1 -1
- package/package.json +32 -28
- package/src/Checkbox.tsx +2 -2
- package/src/Collection.tsx +39 -5
- package/src/ComboBox.tsx +5 -1
- package/src/DatePicker.tsx +7 -2
- package/src/DragAndDrop.tsx +1 -1
- package/src/Popover.tsx +21 -5
- package/src/RadioGroup.tsx +2 -2
- package/src/Select.tsx +6 -2
- package/src/Tree.tsx +364 -38
- package/src/TreeDropTargetDelegate.ts +304 -0
- package/src/Virtualizer.tsx +7 -8
- package/src/index.ts +3 -2
- package/src/useDragAndDrop.tsx +2 -1
package/dist/Tree.mjs
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import {ButtonContext as $d2b4bc8c273e7be6$export$24d547caef80ccd1} from "./Button.mjs";
|
|
2
2
|
import {CheckboxContext as $4e85f108e88277b8$export$b085522c77523c51} from "./RSPContexts.mjs";
|
|
3
|
-
import {CollectionRendererContext as $7135fc7d473fd974$export$4feb769f8ddf26c5, DefaultCollectionRenderer as $7135fc7d473fd974$export$a164736487e3f0ae
|
|
3
|
+
import {CollectionRendererContext as $7135fc7d473fd974$export$4feb769f8ddf26c5, DefaultCollectionRenderer as $7135fc7d473fd974$export$a164736487e3f0ae} from "./Collection.mjs";
|
|
4
4
|
import {DEFAULT_SLOT as $64fa3d84918910a7$export$c62b8e45d58ddad9, Provider as $64fa3d84918910a7$export$2881499e37b75b9a, useContextProps as $64fa3d84918910a7$export$29f1550f4b0d4415, useRenderProps as $64fa3d84918910a7$export$4d86445c2cf5e3} from "./utils.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import {DragAndDropContext as $612b8eb6cb90e02d$export$d188a835a7bc5783, DropIndicatorContext as $612b8eb6cb90e02d$export$f55761759794cf55, useDndPersistedKeys as $612b8eb6cb90e02d$export$d1e8e3fbb7461f6, useRenderDropIndicator as $612b8eb6cb90e02d$export$971707d8a129a1f7} from "./DragAndDrop.mjs";
|
|
6
|
+
import {TreeDropTargetDelegate as $7e0f784ed4e400df$export$82c13862611c034e} from "./TreeDropTargetDelegate.mjs";
|
|
7
|
+
import {useLocale as $kUtXx$useLocale, useCollator as $kUtXx$useCollator, useTree as $kUtXx$useTree, ListKeyboardDelegate as $kUtXx$ListKeyboardDelegate, useFocusRing as $kUtXx$useFocusRing, FocusScope as $kUtXx$FocusScope, mergeProps as $kUtXx$mergeProps, useTreeItem as $kUtXx$useTreeItem, useHover as $kUtXx$useHover, useGridListSelectionCheckbox as $kUtXx$useGridListSelectionCheckbox, useVisuallyHidden as $kUtXx$useVisuallyHidden, useId as $kUtXx$useId} from "react-aria";
|
|
6
8
|
import {CollectionBuilder as $kUtXx$CollectionBuilder, Collection as $kUtXx$Collection, createLeafComponent as $kUtXx$createLeafComponent, createBranchComponent as $kUtXx$createBranchComponent, useCachedChildren as $kUtXx$useCachedChildren} from "@react-aria/collections";
|
|
7
|
-
import {filterDOMProps as $kUtXx$filterDOMProps, useObjectRef as $kUtXx$useObjectRef} from "@react-aria/utils";
|
|
8
9
|
import {useTreeState as $kUtXx$useTreeState} from "react-stately";
|
|
9
|
-
import
|
|
10
|
+
import {filterDOMProps as $kUtXx$filterDOMProps, useObjectRef as $kUtXx$useObjectRef} from "@react-aria/utils";
|
|
11
|
+
import $kUtXx$react, {createContext as $kUtXx$createContext, forwardRef as $kUtXx$forwardRef, useRef as $kUtXx$useRef, useEffect as $kUtXx$useEffect, useContext as $kUtXx$useContext, useMemo as $kUtXx$useMemo, useState as $kUtXx$useState} from "react";
|
|
10
12
|
import {useControlledState as $kUtXx$useControlledState} from "@react-stately/utils";
|
|
11
13
|
|
|
12
14
|
/*
|
|
@@ -29,6 +31,8 @@ import {useControlledState as $kUtXx$useControlledState} from "@react-stately/ut
|
|
|
29
31
|
|
|
30
32
|
|
|
31
33
|
|
|
34
|
+
|
|
35
|
+
|
|
32
36
|
class $2f5eaf4a2a47b4cf$var$TreeCollection {
|
|
33
37
|
// TODO: should this collection's getters reflect the flattened structure or the original structure
|
|
34
38
|
// If we respresent the flattened structure, it is easier for the keyboard nav but harder to find all the nodes
|
|
@@ -107,9 +111,36 @@ const $2f5eaf4a2a47b4cf$export$7fbedc92909ed28e = /*#__PURE__*/ (0, $kUtXx$forwa
|
|
|
107
111
|
treeRef: ref
|
|
108
112
|
}));
|
|
109
113
|
});
|
|
114
|
+
const $2f5eaf4a2a47b4cf$var$EXPANSION_KEYS = {
|
|
115
|
+
'expand': {
|
|
116
|
+
ltr: 'ArrowRight',
|
|
117
|
+
rtl: 'ArrowLeft'
|
|
118
|
+
},
|
|
119
|
+
'collapse': {
|
|
120
|
+
ltr: 'ArrowLeft',
|
|
121
|
+
rtl: 'ArrowRight'
|
|
122
|
+
}
|
|
123
|
+
};
|
|
110
124
|
function $2f5eaf4a2a47b4cf$var$TreeInner({ props: props, collection: collection, treeRef: ref }) {
|
|
125
|
+
const { dragAndDropHooks: dragAndDropHooks } = props;
|
|
126
|
+
let { direction: direction } = (0, $kUtXx$useLocale)();
|
|
127
|
+
let collator = (0, $kUtXx$useCollator)({
|
|
128
|
+
usage: 'search',
|
|
129
|
+
sensitivity: 'base'
|
|
130
|
+
});
|
|
131
|
+
let hasDragHooks = !!(dragAndDropHooks === null || dragAndDropHooks === void 0 ? void 0 : dragAndDropHooks.useDraggableCollectionState);
|
|
132
|
+
let hasDropHooks = !!(dragAndDropHooks === null || dragAndDropHooks === void 0 ? void 0 : dragAndDropHooks.useDroppableCollectionState);
|
|
133
|
+
let dragHooksProvided = (0, $kUtXx$useRef)(hasDragHooks);
|
|
134
|
+
let dropHooksProvided = (0, $kUtXx$useRef)(hasDropHooks);
|
|
135
|
+
(0, $kUtXx$useEffect)(()=>{
|
|
136
|
+
if (dragHooksProvided.current !== hasDragHooks) console.warn('Drag hooks were provided during one render, but not another. This should be avoided as it may produce unexpected behavior.');
|
|
137
|
+
if (dropHooksProvided.current !== hasDropHooks) console.warn('Drop hooks were provided during one render, but not another. This should be avoided as it may produce unexpected behavior.');
|
|
138
|
+
}, [
|
|
139
|
+
hasDragHooks,
|
|
140
|
+
hasDropHooks
|
|
141
|
+
]);
|
|
111
142
|
let { selectionMode: selectionMode = 'none', expandedKeys: propExpandedKeys, defaultExpandedKeys: propDefaultExpandedKeys, onExpandedChange: onExpandedChange, disabledBehavior: disabledBehavior = 'all' } = props;
|
|
112
|
-
let { CollectionRoot: CollectionRoot, isVirtualized: isVirtualized, layoutDelegate: layoutDelegate } = (0, $kUtXx$useContext)((0, $7135fc7d473fd974$export$4feb769f8ddf26c5));
|
|
143
|
+
let { CollectionRoot: CollectionRoot, isVirtualized: isVirtualized, layoutDelegate: layoutDelegate, dropTargetDelegate: ctxDropTargetDelegate } = (0, $kUtXx$useContext)((0, $7135fc7d473fd974$export$4feb769f8ddf26c5));
|
|
113
144
|
// Kinda annoying that we have to replicate this code here as well as in useTreeState, but don't want to add
|
|
114
145
|
// flattenCollection stuff to useTreeState. Think about this later
|
|
115
146
|
let [expandedKeys, setExpandedKeys] = (0, $kUtXx$useControlledState)(propExpandedKeys ? $2f5eaf4a2a47b4cf$var$convertExpanded(propExpandedKeys) : undefined, propDefaultExpandedKeys ? $2f5eaf4a2a47b4cf$var$convertExpanded(propDefaultExpandedKeys) : new Set(), onExpandedChange);
|
|
@@ -136,11 +167,96 @@ function $2f5eaf4a2a47b4cf$var$TreeInner({ props: props, collection: collection,
|
|
|
136
167
|
isVirtualized: isVirtualized,
|
|
137
168
|
layoutDelegate: layoutDelegate
|
|
138
169
|
}, state, ref);
|
|
170
|
+
let dragState = undefined;
|
|
171
|
+
let dropState = undefined;
|
|
172
|
+
let droppableCollection = undefined;
|
|
173
|
+
let isRootDropTarget = false;
|
|
174
|
+
let dragPreview = null;
|
|
175
|
+
let preview = (0, $kUtXx$useRef)(null);
|
|
176
|
+
if (hasDragHooks && dragAndDropHooks) {
|
|
177
|
+
dragState = dragAndDropHooks.useDraggableCollectionState({
|
|
178
|
+
collection: state.collection,
|
|
179
|
+
selectionManager: state.selectionManager,
|
|
180
|
+
preview: dragAndDropHooks.renderDragPreview ? preview : undefined
|
|
181
|
+
});
|
|
182
|
+
dragAndDropHooks.useDraggableCollection({}, dragState, ref);
|
|
183
|
+
let DragPreview = dragAndDropHooks.DragPreview;
|
|
184
|
+
dragPreview = dragAndDropHooks.renderDragPreview ? /*#__PURE__*/ (0, $kUtXx$react).createElement(DragPreview, {
|
|
185
|
+
ref: preview
|
|
186
|
+
}, dragAndDropHooks.renderDragPreview) : null;
|
|
187
|
+
}
|
|
188
|
+
let [treeDropTargetDelegate] = (0, $kUtXx$useState)(()=>new (0, $7e0f784ed4e400df$export$82c13862611c034e)());
|
|
189
|
+
if (hasDropHooks && dragAndDropHooks) {
|
|
190
|
+
dropState = dragAndDropHooks.useDroppableCollectionState({
|
|
191
|
+
collection: state.collection,
|
|
192
|
+
selectionManager: state.selectionManager
|
|
193
|
+
});
|
|
194
|
+
let dropTargetDelegate = dragAndDropHooks.dropTargetDelegate || ctxDropTargetDelegate || new dragAndDropHooks.ListDropTargetDelegate(state.collection, ref, {
|
|
195
|
+
direction: direction
|
|
196
|
+
});
|
|
197
|
+
treeDropTargetDelegate.setup(dropTargetDelegate, state, direction);
|
|
198
|
+
let keyboardDelegate = new (0, $kUtXx$ListKeyboardDelegate)({
|
|
199
|
+
collection: state.collection,
|
|
200
|
+
collator: collator,
|
|
201
|
+
ref: ref,
|
|
202
|
+
disabledKeys: state.selectionManager.disabledKeys,
|
|
203
|
+
disabledBehavior: state.selectionManager.disabledBehavior,
|
|
204
|
+
direction: direction,
|
|
205
|
+
layoutDelegate: layoutDelegate
|
|
206
|
+
});
|
|
207
|
+
droppableCollection = dragAndDropHooks.useDroppableCollection({
|
|
208
|
+
keyboardDelegate: keyboardDelegate,
|
|
209
|
+
dropTargetDelegate: treeDropTargetDelegate,
|
|
210
|
+
onDropActivate: (e)=>{
|
|
211
|
+
// Expand collapsed item when dragging over. For keyboard, allow collapsing.
|
|
212
|
+
if (e.target.type === 'item') {
|
|
213
|
+
var _dragAndDropHooks_isVirtualDragging;
|
|
214
|
+
let key = e.target.key;
|
|
215
|
+
let item = state.collection.getItem(key);
|
|
216
|
+
let isExpanded = expandedKeys !== 'all' && expandedKeys.has(key);
|
|
217
|
+
if (item && item.hasChildNodes && (!isExpanded || (dragAndDropHooks === null || dragAndDropHooks === void 0 ? void 0 : (_dragAndDropHooks_isVirtualDragging = dragAndDropHooks.isVirtualDragging) === null || _dragAndDropHooks_isVirtualDragging === void 0 ? void 0 : _dragAndDropHooks_isVirtualDragging.call(dragAndDropHooks)))) state.toggleKey(key);
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
onKeyDown: (e)=>{
|
|
221
|
+
let target = dropState === null || dropState === void 0 ? void 0 : dropState.target;
|
|
222
|
+
if (target && target.type === 'item' && target.dropPosition === 'on') {
|
|
223
|
+
let item = state.collection.getItem(target.key);
|
|
224
|
+
if (e.key === $2f5eaf4a2a47b4cf$var$EXPANSION_KEYS['expand'][direction] && (item === null || item === void 0 ? void 0 : item.hasChildNodes) && !state.expandedKeys.has(target.key)) state.toggleKey(target.key);
|
|
225
|
+
else if (e.key === $2f5eaf4a2a47b4cf$var$EXPANSION_KEYS['collapse'][direction] && (item === null || item === void 0 ? void 0 : item.hasChildNodes) && state.expandedKeys.has(target.key)) state.toggleKey(target.key);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}, dropState, ref);
|
|
229
|
+
// Prevent dropping items onto themselves or their descendants
|
|
230
|
+
let originalGetDropOperation = dropState.getDropOperation;
|
|
231
|
+
dropState.getDropOperation = (options)=>{
|
|
232
|
+
let { target: target, isInternal: isInternal } = options;
|
|
233
|
+
var _dragState_draggingKeys;
|
|
234
|
+
let currentDraggingKeys = (_dragState_draggingKeys = dragState === null || dragState === void 0 ? void 0 : dragState.draggingKeys) !== null && _dragState_draggingKeys !== void 0 ? _dragState_draggingKeys : new Set();
|
|
235
|
+
if (isInternal && target.type === 'item' && currentDraggingKeys.size > 0) {
|
|
236
|
+
if (currentDraggingKeys.has(target.key) && target.dropPosition === 'on') return 'cancel';
|
|
237
|
+
let currentKey = target.key;
|
|
238
|
+
while(currentKey != null){
|
|
239
|
+
let item = state.collection.getItem(currentKey);
|
|
240
|
+
let parentKey = item === null || item === void 0 ? void 0 : item.parentKey;
|
|
241
|
+
if (parentKey != null && currentDraggingKeys.has(parentKey)) return 'cancel';
|
|
242
|
+
currentKey = parentKey !== null && parentKey !== void 0 ? parentKey : null;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return originalGetDropOperation(options);
|
|
246
|
+
};
|
|
247
|
+
isRootDropTarget = dropState.isDropTarget({
|
|
248
|
+
type: 'root'
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
let isTreeDraggable = !!(hasDragHooks && !(dragState === null || dragState === void 0 ? void 0 : dragState.isDisabled));
|
|
139
252
|
let { focusProps: focusProps, isFocused: isFocused, isFocusVisible: isFocusVisible } = (0, $kUtXx$useFocusRing)();
|
|
140
253
|
let renderValues = {
|
|
141
254
|
isEmpty: state.collection.size === 0,
|
|
142
255
|
isFocused: isFocused,
|
|
143
256
|
isFocusVisible: isFocusVisible,
|
|
257
|
+
isDropTarget: isRootDropTarget,
|
|
258
|
+
selectionMode: state.selectionManager.selectionMode,
|
|
259
|
+
allowsDragging: !!isTreeDraggable,
|
|
144
260
|
state: state
|
|
145
261
|
};
|
|
146
262
|
let renderProps = (0, $64fa3d84918910a7$export$4d86445c2cf5e3)({
|
|
@@ -174,28 +290,46 @@ function $2f5eaf4a2a47b4cf$var$TreeInner({ props: props, collection: collection,
|
|
|
174
290
|
}
|
|
175
291
|
}, content));
|
|
176
292
|
}
|
|
177
|
-
return /*#__PURE__*/ (0, $kUtXx$react).createElement((0, $kUtXx$FocusScope), null, /*#__PURE__*/ (0, $kUtXx$react).createElement("div", {
|
|
293
|
+
return /*#__PURE__*/ (0, $kUtXx$react).createElement((0, $kUtXx$react).Fragment, null, /*#__PURE__*/ (0, $kUtXx$react).createElement((0, $kUtXx$FocusScope), null, /*#__PURE__*/ (0, $kUtXx$react).createElement("div", {
|
|
178
294
|
...(0, $kUtXx$filterDOMProps)(props),
|
|
179
295
|
...renderProps,
|
|
180
|
-
...(0, $kUtXx$mergeProps)(gridProps, focusProps),
|
|
296
|
+
...(0, $kUtXx$mergeProps)(gridProps, focusProps, droppableCollection === null || droppableCollection === void 0 ? void 0 : droppableCollection.collectionProps),
|
|
181
297
|
ref: ref,
|
|
182
298
|
slot: props.slot || undefined,
|
|
183
299
|
onScroll: props.onScroll,
|
|
184
300
|
"data-empty": state.collection.size === 0 || undefined,
|
|
185
301
|
"data-focused": isFocused || undefined,
|
|
186
|
-
"data-
|
|
302
|
+
"data-drop-target": isRootDropTarget || undefined,
|
|
303
|
+
"data-focus-visible": isFocusVisible || undefined,
|
|
304
|
+
"data-selection-mode": state.selectionManager.selectionMode === 'none' ? undefined : state.selectionManager.selectionMode,
|
|
305
|
+
"data-allows-dragging": !!isTreeDraggable || undefined
|
|
187
306
|
}, /*#__PURE__*/ (0, $kUtXx$react).createElement((0, $64fa3d84918910a7$export$2881499e37b75b9a), {
|
|
188
307
|
values: [
|
|
189
308
|
[
|
|
190
309
|
$2f5eaf4a2a47b4cf$export$8953bccafd7bce87,
|
|
191
310
|
state
|
|
311
|
+
],
|
|
312
|
+
[
|
|
313
|
+
(0, $612b8eb6cb90e02d$export$d188a835a7bc5783),
|
|
314
|
+
{
|
|
315
|
+
dragAndDropHooks: dragAndDropHooks,
|
|
316
|
+
dragState: dragState,
|
|
317
|
+
dropState: dropState
|
|
318
|
+
}
|
|
319
|
+
],
|
|
320
|
+
[
|
|
321
|
+
(0, $612b8eb6cb90e02d$export$f55761759794cf55),
|
|
322
|
+
{
|
|
323
|
+
render: $2f5eaf4a2a47b4cf$var$TreeDropIndicatorWrapper
|
|
324
|
+
}
|
|
192
325
|
]
|
|
193
326
|
]
|
|
194
|
-
}, /*#__PURE__*/ (0, $kUtXx$react).createElement(CollectionRoot, {
|
|
327
|
+
}, hasDropHooks && /*#__PURE__*/ (0, $kUtXx$react).createElement($2f5eaf4a2a47b4cf$var$RootDropIndicator, null), /*#__PURE__*/ (0, $kUtXx$react).createElement(CollectionRoot, {
|
|
195
328
|
collection: state.collection,
|
|
196
|
-
persistedKeys: (0, $
|
|
197
|
-
scrollRef: ref
|
|
198
|
-
|
|
329
|
+
persistedKeys: (0, $612b8eb6cb90e02d$export$d1e8e3fbb7461f6)(state.selectionManager, dragAndDropHooks, dropState),
|
|
330
|
+
scrollRef: ref,
|
|
331
|
+
renderDropIndicator: (0, $612b8eb6cb90e02d$export$971707d8a129a1f7)(dragAndDropHooks, dropState)
|
|
332
|
+
})), emptyState)), dragPreview);
|
|
199
333
|
}
|
|
200
334
|
const $2f5eaf4a2a47b4cf$export$4b687e3f663d618c = /*#__PURE__*/ (0, $kUtXx$createLeafComponent)('content', function TreeItemContent(props) {
|
|
201
335
|
let values = (0, $kUtXx$useContext)($2f5eaf4a2a47b4cf$export$36b5dda0d9bc8f78);
|
|
@@ -212,10 +346,12 @@ const $2f5eaf4a2a47b4cf$export$53d36ab85dc89436 = /*#__PURE__*/ (0, $kUtXx$creat
|
|
|
212
346
|
var _this;
|
|
213
347
|
let state = (0, $kUtXx$useContext)($2f5eaf4a2a47b4cf$export$8953bccafd7bce87);
|
|
214
348
|
ref = (0, $kUtXx$useObjectRef)(ref);
|
|
349
|
+
let { dragAndDropHooks: dragAndDropHooks, dragState: dragState, dropState: dropState } = (0, $kUtXx$useContext)((0, $612b8eb6cb90e02d$export$d188a835a7bc5783));
|
|
215
350
|
// TODO: remove this when we support description in tree row
|
|
216
351
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
217
352
|
let { rowProps: rowProps, gridCellProps: gridCellProps, expandButtonProps: expandButtonProps, descriptionProps: descriptionProps, ...states } = (0, $kUtXx$useTreeItem)({
|
|
218
|
-
node: item
|
|
353
|
+
node: item,
|
|
354
|
+
shouldSelectOnPressUp: !!dragState
|
|
219
355
|
}, state, ref);
|
|
220
356
|
let isExpanded = rowProps['aria-expanded'] === true;
|
|
221
357
|
let hasChildItems = props.hasChildItems || ((_this = [
|
|
@@ -235,6 +371,26 @@ const $2f5eaf4a2a47b4cf$export$53d36ab85dc89436 = /*#__PURE__*/ (0, $kUtXx$creat
|
|
|
235
371
|
let { checkboxProps: checkboxProps } = (0, $kUtXx$useGridListSelectionCheckbox)({
|
|
236
372
|
key: item.key
|
|
237
373
|
}, state);
|
|
374
|
+
let draggableItem = null;
|
|
375
|
+
if (dragState && dragAndDropHooks) draggableItem = dragAndDropHooks.useDraggableItem({
|
|
376
|
+
key: item.key,
|
|
377
|
+
hasDragButton: true
|
|
378
|
+
}, dragState);
|
|
379
|
+
let dropIndicator = null;
|
|
380
|
+
let expandButtonRef = (0, $kUtXx$useRef)(null);
|
|
381
|
+
let dropIndicatorRef = (0, $kUtXx$useRef)(null);
|
|
382
|
+
let activateButtonRef = (0, $kUtXx$useRef)(null);
|
|
383
|
+
let { visuallyHiddenProps: visuallyHiddenProps } = (0, $kUtXx$useVisuallyHidden)();
|
|
384
|
+
if (dropState && dragAndDropHooks) dropIndicator = dragAndDropHooks.useDropIndicator({
|
|
385
|
+
target: {
|
|
386
|
+
type: 'item',
|
|
387
|
+
key: item.key,
|
|
388
|
+
dropPosition: 'on'
|
|
389
|
+
},
|
|
390
|
+
activateButtonRef: activateButtonRef
|
|
391
|
+
}, dropState, dropIndicatorRef);
|
|
392
|
+
let isDragging = dragState && dragState.isDragging(item.key);
|
|
393
|
+
let isDropTarget = dropIndicator === null || dropIndicator === void 0 ? void 0 : dropIndicator.isDropTarget;
|
|
238
394
|
let selectionMode = state.selectionManager.selectionMode;
|
|
239
395
|
let selectionBehavior = state.selectionManager.selectionBehavior;
|
|
240
396
|
let renderPropValues = (0, $kUtXx$react).useMemo(()=>({
|
|
@@ -248,19 +404,25 @@ const $2f5eaf4a2a47b4cf$export$53d36ab85dc89436 = /*#__PURE__*/ (0, $kUtXx$creat
|
|
|
248
404
|
selectionBehavior: selectionBehavior,
|
|
249
405
|
isFocusVisibleWithin: isFocusVisibleWithin,
|
|
250
406
|
state: state,
|
|
251
|
-
id: item.key
|
|
407
|
+
id: item.key,
|
|
408
|
+
allowsDragging: !!dragState,
|
|
409
|
+
isDragging: isDragging,
|
|
410
|
+
isDropTarget: isDropTarget
|
|
252
411
|
}), [
|
|
253
412
|
states,
|
|
254
413
|
isHovered,
|
|
255
414
|
isFocusVisible,
|
|
256
|
-
selectionMode,
|
|
257
|
-
selectionBehavior,
|
|
258
415
|
isExpanded,
|
|
259
416
|
hasChildItems,
|
|
260
417
|
level,
|
|
261
418
|
isFocusVisibleWithin,
|
|
262
419
|
state,
|
|
263
|
-
item.key
|
|
420
|
+
item.key,
|
|
421
|
+
dragState,
|
|
422
|
+
isDragging,
|
|
423
|
+
isDropTarget,
|
|
424
|
+
selectionBehavior,
|
|
425
|
+
selectionMode
|
|
264
426
|
]);
|
|
265
427
|
let renderProps = (0, $64fa3d84918910a7$export$4d86445c2cf5e3)({
|
|
266
428
|
...props,
|
|
@@ -278,11 +440,15 @@ const $2f5eaf4a2a47b4cf$export$53d36ab85dc89436 = /*#__PURE__*/ (0, $kUtXx$creat
|
|
|
278
440
|
}, [
|
|
279
441
|
item.textValue
|
|
280
442
|
]);
|
|
281
|
-
let expandButtonRef = (0, $kUtXx$useRef)(null);
|
|
282
443
|
(0, $kUtXx$useEffect)(()=>{
|
|
283
444
|
if (hasChildItems && !expandButtonRef.current && process.env.NODE_ENV !== 'production') console.warn('Expandable tree items must contain a expand button so screen reader users can expand/collapse the item.');
|
|
284
445
|
// eslint-disable-next-line
|
|
285
446
|
}, []);
|
|
447
|
+
let dragButtonRef = (0, $kUtXx$useRef)(null);
|
|
448
|
+
(0, $kUtXx$useEffect)(()=>{
|
|
449
|
+
if (dragState && !dragButtonRef.current && process.env.NODE_ENV !== 'production') console.warn('Draggable items in a Tree must contain a <Button slot="drag"> element so that keyboard and screen reader users can drag them.');
|
|
450
|
+
// eslint-disable-next-line
|
|
451
|
+
}, []);
|
|
286
452
|
let children = (0, $kUtXx$useCachedChildren)({
|
|
287
453
|
items: state.collection.getChildren(item.key),
|
|
288
454
|
children: (item)=>{
|
|
@@ -299,8 +465,34 @@ const $2f5eaf4a2a47b4cf$export$53d36ab85dc89436 = /*#__PURE__*/ (0, $kUtXx$creat
|
|
|
299
465
|
}
|
|
300
466
|
}
|
|
301
467
|
});
|
|
302
|
-
|
|
303
|
-
|
|
468
|
+
let activateButtonId = (0, $kUtXx$useId)();
|
|
469
|
+
return /*#__PURE__*/ (0, $kUtXx$react).createElement((0, $kUtXx$react).Fragment, null, dropIndicator && !dropIndicator.isHidden && /*#__PURE__*/ (0, $kUtXx$react).createElement("div", {
|
|
470
|
+
role: "row",
|
|
471
|
+
"aria-level": rowProps['aria-level'],
|
|
472
|
+
"aria-expanded": rowProps['aria-expanded'],
|
|
473
|
+
"aria-label": dropIndicator.dropIndicatorProps['aria-label']
|
|
474
|
+
}, /*#__PURE__*/ (0, $kUtXx$react).createElement("div", {
|
|
475
|
+
role: "gridcell",
|
|
476
|
+
"aria-colindex": 1,
|
|
477
|
+
style: {
|
|
478
|
+
display: 'contents'
|
|
479
|
+
}
|
|
480
|
+
}, /*#__PURE__*/ (0, $kUtXx$react).createElement("div", {
|
|
481
|
+
role: "button",
|
|
482
|
+
...visuallyHiddenProps,
|
|
483
|
+
...dropIndicator.dropIndicatorProps,
|
|
484
|
+
ref: dropIndicatorRef
|
|
485
|
+
}), rowProps['aria-expanded'] != null ? // Button to allow touch screen reader users to expand the item while dragging.
|
|
486
|
+
/*#__PURE__*/ (0, $kUtXx$react).createElement("div", {
|
|
487
|
+
role: "button",
|
|
488
|
+
...visuallyHiddenProps,
|
|
489
|
+
id: activateButtonId,
|
|
490
|
+
"aria-label": expandButtonProps['aria-label'],
|
|
491
|
+
"aria-labelledby": `${activateButtonId} ${rowProps.id}`,
|
|
492
|
+
tabIndex: -1,
|
|
493
|
+
ref: activateButtonRef
|
|
494
|
+
}) : null)), /*#__PURE__*/ (0, $kUtXx$react).createElement("div", {
|
|
495
|
+
...(0, $kUtXx$mergeProps)((0, $kUtXx$filterDOMProps)(props), rowProps, focusProps, hoverProps, focusWithinProps, draggableItem === null || draggableItem === void 0 ? void 0 : draggableItem.dragProps),
|
|
304
496
|
...renderProps,
|
|
305
497
|
ref: ref,
|
|
306
498
|
// TODO: missing selectionBehavior, hasAction and allowsSelection data attribute equivalents (available in renderProps). Do we want those?
|
|
@@ -313,7 +505,10 @@ const $2f5eaf4a2a47b4cf$export$53d36ab85dc89436 = /*#__PURE__*/ (0, $kUtXx$creat
|
|
|
313
505
|
"data-focused": states.isFocused || undefined,
|
|
314
506
|
"data-focus-visible": isFocusVisible || undefined,
|
|
315
507
|
"data-pressed": states.isPressed || undefined,
|
|
316
|
-
"data-selection-mode": state.selectionManager.selectionMode === 'none' ? undefined : state.selectionManager.selectionMode
|
|
508
|
+
"data-selection-mode": state.selectionManager.selectionMode === 'none' ? undefined : state.selectionManager.selectionMode,
|
|
509
|
+
"data-allows-dragging": !!dragState || undefined,
|
|
510
|
+
"data-dragging": isDragging || undefined,
|
|
511
|
+
"data-drop-target": isDropTarget || undefined
|
|
317
512
|
}, /*#__PURE__*/ (0, $kUtXx$react).createElement("div", {
|
|
318
513
|
...gridCellProps,
|
|
319
514
|
style: {
|
|
@@ -339,6 +534,13 @@ const $2f5eaf4a2a47b4cf$export$53d36ab85dc89436 = /*#__PURE__*/ (0, $kUtXx$creat
|
|
|
339
534
|
chevron: {
|
|
340
535
|
...expandButtonProps,
|
|
341
536
|
ref: expandButtonRef
|
|
537
|
+
},
|
|
538
|
+
drag: {
|
|
539
|
+
...draggableItem === null || draggableItem === void 0 ? void 0 : draggableItem.dragButtonProps,
|
|
540
|
+
ref: dragButtonRef,
|
|
541
|
+
style: {
|
|
542
|
+
pointerEvents: 'none'
|
|
543
|
+
}
|
|
342
544
|
}
|
|
343
545
|
}
|
|
344
546
|
}
|
|
@@ -422,6 +624,82 @@ function $2f5eaf4a2a47b4cf$var$flattenTree(collection, opts) {
|
|
|
422
624
|
keyMap: keyMap
|
|
423
625
|
};
|
|
424
626
|
}
|
|
627
|
+
function $2f5eaf4a2a47b4cf$var$TreeDropIndicatorWrapper(props, ref) {
|
|
628
|
+
var _dropState_collection_getItem;
|
|
629
|
+
ref = (0, $kUtXx$useObjectRef)(ref);
|
|
630
|
+
let { dragAndDropHooks: dragAndDropHooks, dropState: dropState } = (0, $kUtXx$useContext)((0, $612b8eb6cb90e02d$export$d188a835a7bc5783));
|
|
631
|
+
let buttonRef = (0, $kUtXx$useRef)(null);
|
|
632
|
+
let { dropIndicatorProps: dropIndicatorProps, isHidden: isHidden, isDropTarget: isDropTarget } = dragAndDropHooks.useDropIndicator(props, dropState, buttonRef);
|
|
633
|
+
if (isHidden) return null;
|
|
634
|
+
let level = dropState && props.target.type === 'item' ? (((_dropState_collection_getItem = dropState.collection.getItem(props.target.key)) === null || _dropState_collection_getItem === void 0 ? void 0 : _dropState_collection_getItem.level) || 0) + 1 : 1;
|
|
635
|
+
return /*#__PURE__*/ (0, $kUtXx$react).createElement($2f5eaf4a2a47b4cf$var$TreeDropIndicatorForwardRef, {
|
|
636
|
+
...props,
|
|
637
|
+
dropIndicatorProps: dropIndicatorProps,
|
|
638
|
+
isDropTarget: isDropTarget,
|
|
639
|
+
ref: ref,
|
|
640
|
+
buttonRef: buttonRef,
|
|
641
|
+
level: level
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
function $2f5eaf4a2a47b4cf$var$TreeDropIndicator(props, ref) {
|
|
645
|
+
let { dropIndicatorProps: dropIndicatorProps, isDropTarget: isDropTarget, buttonRef: buttonRef, level: level, ...otherProps } = props;
|
|
646
|
+
let { visuallyHiddenProps: visuallyHiddenProps } = (0, $kUtXx$useVisuallyHidden)();
|
|
647
|
+
let renderProps = (0, $64fa3d84918910a7$export$4d86445c2cf5e3)({
|
|
648
|
+
...otherProps,
|
|
649
|
+
defaultClassName: 'react-aria-DropIndicator',
|
|
650
|
+
defaultStyle: {
|
|
651
|
+
position: 'relative',
|
|
652
|
+
// @ts-ignore
|
|
653
|
+
'--tree-item-level': level
|
|
654
|
+
},
|
|
655
|
+
values: {
|
|
656
|
+
isDropTarget: isDropTarget
|
|
657
|
+
}
|
|
658
|
+
});
|
|
659
|
+
return /*#__PURE__*/ (0, $kUtXx$react).createElement("div", {
|
|
660
|
+
...renderProps,
|
|
661
|
+
role: "row",
|
|
662
|
+
"aria-level": level,
|
|
663
|
+
ref: ref,
|
|
664
|
+
"data-drop-target": isDropTarget || undefined
|
|
665
|
+
}, /*#__PURE__*/ (0, $kUtXx$react).createElement("div", {
|
|
666
|
+
role: "gridcell"
|
|
667
|
+
}, /*#__PURE__*/ (0, $kUtXx$react).createElement("div", {
|
|
668
|
+
...visuallyHiddenProps,
|
|
669
|
+
role: "button",
|
|
670
|
+
...dropIndicatorProps,
|
|
671
|
+
ref: buttonRef
|
|
672
|
+
}), renderProps.children));
|
|
673
|
+
}
|
|
674
|
+
const $2f5eaf4a2a47b4cf$var$TreeDropIndicatorForwardRef = /*#__PURE__*/ (0, $kUtXx$forwardRef)($2f5eaf4a2a47b4cf$var$TreeDropIndicator);
|
|
675
|
+
function $2f5eaf4a2a47b4cf$var$RootDropIndicator() {
|
|
676
|
+
let { dragAndDropHooks: dragAndDropHooks, dropState: dropState } = (0, $kUtXx$useContext)((0, $612b8eb6cb90e02d$export$d188a835a7bc5783));
|
|
677
|
+
let ref = (0, $kUtXx$useRef)(null);
|
|
678
|
+
let { dropIndicatorProps: dropIndicatorProps } = dragAndDropHooks.useDropIndicator({
|
|
679
|
+
target: {
|
|
680
|
+
type: 'root'
|
|
681
|
+
}
|
|
682
|
+
}, dropState, ref);
|
|
683
|
+
let isDropTarget = dropState.isDropTarget({
|
|
684
|
+
type: 'root'
|
|
685
|
+
});
|
|
686
|
+
let { visuallyHiddenProps: visuallyHiddenProps } = (0, $kUtXx$useVisuallyHidden)();
|
|
687
|
+
if (!isDropTarget && dropIndicatorProps['aria-hidden']) return null;
|
|
688
|
+
return /*#__PURE__*/ (0, $kUtXx$react).createElement("div", {
|
|
689
|
+
role: "row",
|
|
690
|
+
"aria-hidden": dropIndicatorProps['aria-hidden'],
|
|
691
|
+
style: {
|
|
692
|
+
position: 'absolute'
|
|
693
|
+
}
|
|
694
|
+
}, /*#__PURE__*/ (0, $kUtXx$react).createElement("div", {
|
|
695
|
+
role: "gridcell"
|
|
696
|
+
}, /*#__PURE__*/ (0, $kUtXx$react).createElement("div", {
|
|
697
|
+
role: "button",
|
|
698
|
+
...visuallyHiddenProps,
|
|
699
|
+
...dropIndicatorProps,
|
|
700
|
+
ref: ref
|
|
701
|
+
})));
|
|
702
|
+
}
|
|
425
703
|
|
|
426
704
|
|
|
427
705
|
export {$2f5eaf4a2a47b4cf$export$dfae7d399eea2568 as TreeContext, $2f5eaf4a2a47b4cf$export$8953bccafd7bce87 as TreeStateContext, $2f5eaf4a2a47b4cf$export$7fbedc92909ed28e as Tree, $2f5eaf4a2a47b4cf$export$4b687e3f663d618c as TreeItemContent, $2f5eaf4a2a47b4cf$export$36b5dda0d9bc8f78 as TreeItemContentContext, $2f5eaf4a2a47b4cf$export$53d36ab85dc89436 as TreeItem, $2f5eaf4a2a47b4cf$export$9d1a587784d97b41 as UNSTABLE_TreeLoadingIndicator};
|