@pingux/astro 2.39.0 → 2.40.0-alpha.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/lib/cjs/components/TreeView/InsertionIndicator.js +50 -0
- package/lib/cjs/components/TreeView/TreeView.js +227 -34
- package/lib/cjs/components/TreeView/TreeView.stories.js +3 -2
- package/lib/cjs/components/TreeView/TreeView.styles.js +26 -6
- package/lib/cjs/components/TreeView/TreeView.test.js +258 -8
- package/lib/cjs/components/TreeView/TreeViewItem.js +28 -56
- package/lib/cjs/components/TreeView/TreeViewKeyboardDelegate.test.js +19 -0
- package/lib/cjs/components/TreeView/TreeViewRow.js +123 -32
- package/lib/cjs/components/TreeView/TreeViewSection.js +33 -67
- package/lib/cjs/utils/testUtils/dndMocks.js +232 -0
- package/lib/components/TreeView/InsertionIndicator.js +41 -0
- package/lib/components/TreeView/TreeView.js +224 -34
- package/lib/components/TreeView/TreeView.stories.js +3 -2
- package/lib/components/TreeView/TreeView.styles.js +26 -6
- package/lib/components/TreeView/TreeView.test.js +262 -7
- package/lib/components/TreeView/TreeViewItem.js +29 -57
- package/lib/components/TreeView/TreeViewKeyboardDelegate.test.js +19 -0
- package/lib/components/TreeView/TreeViewRow.js +129 -38
- package/lib/components/TreeView/TreeViewSection.js +34 -68
- package/lib/utils/testUtils/dndMocks.js +218 -0
- package/package.json +4 -1
@@ -7,19 +7,29 @@ import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-st
|
|
7
7
|
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
8
8
|
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
9
9
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
10
|
-
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
11
10
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
11
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
12
12
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
13
|
-
var _excluded = ["
|
13
|
+
var _excluded = ["value"],
|
14
|
+
_excluded2 = ["value"],
|
15
|
+
_excluded3 = ["tree", "disabledKeys", "onExpandedChange", "onDragStart", "onDrop", "onKeyDown", "pageLength"];
|
16
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
17
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context6, _context7; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context6 = ownKeys(Object(source), !0)).call(_context6, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context7 = ownKeys(Object(source))).call(_context7, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
14
18
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
19
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
15
20
|
import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
|
16
|
-
|
17
|
-
|
18
|
-
import
|
19
|
-
import {
|
21
|
+
import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
|
22
|
+
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
23
|
+
import _keysInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/keys";
|
24
|
+
import React, { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
25
|
+
import { mergeProps } from 'react-aria';
|
26
|
+
import { ListDropTargetDelegate, useDraggableCollection, useDroppableCollection } from '@react-aria/dnd';
|
27
|
+
import { useFocusRing } from '@react-aria/focus';
|
20
28
|
import { useCollator } from '@react-aria/i18n';
|
21
29
|
import { useListBox } from '@react-aria/listbox';
|
30
|
+
import { useDraggableCollectionState, useDroppableCollectionState } from '@react-stately/dnd';
|
22
31
|
import { ListLayout } from '@react-stately/layout';
|
32
|
+
import { useTreeState } from '@react-stately/tree';
|
23
33
|
import PropTypes from 'prop-types';
|
24
34
|
import { TreeViewContext } from '../../context/TreeViewContext';
|
25
35
|
import { Box, TreeViewItem, TreeViewSection } from '../../index';
|
@@ -47,23 +57,78 @@ export function useTreeViewLayout(state) {
|
|
47
57
|
layout.disabledKeys = state.disabledKeys;
|
48
58
|
return layout;
|
49
59
|
}
|
60
|
+
|
61
|
+
// if you are placing the dragged item into another item.
|
62
|
+
export var insertItem = function insertItem(tree, eventTarget, keyBeingDragged, state) {
|
63
|
+
tree.move(keyBeingDragged, eventTarget.key, 0);
|
64
|
+
// expand target, if target is closed
|
65
|
+
if (!state.expandedKeys.has(eventTarget.key)) {
|
66
|
+
state.toggleKey(eventTarget.key);
|
67
|
+
}
|
68
|
+
};
|
69
|
+
export var insertItemToPosition = function insertItemToPosition(tree, dropPosition, targetKey, droppedItem) {
|
70
|
+
// remove item
|
71
|
+
tree.remove(droppedItem.key);
|
72
|
+
|
73
|
+
// removing value and then spreading it into the top level.
|
74
|
+
// this prevents nesting ie value.value.value.... etc.
|
75
|
+
var value = droppedItem.value,
|
76
|
+
rest = _objectWithoutProperties(droppedItem, _excluded);
|
77
|
+
var buildNewItemArray = function buildNewItemArray(arr) {
|
78
|
+
return _mapInstanceProperty(arr).call(arr, function (_item) {
|
79
|
+
var _itemValue = _item.value,
|
80
|
+
_itemRest = _objectWithoutProperties(_item, _excluded2);
|
81
|
+
return _objectSpread(_objectSpread({}, _itemValue), {}, {
|
82
|
+
_itemRest: _itemRest
|
83
|
+
});
|
84
|
+
});
|
85
|
+
};
|
86
|
+
if (dropPosition === 'before') {
|
87
|
+
tree.insertBefore(targetKey, _objectSpread(_objectSpread(_objectSpread({}, rest), droppedItem.value), droppedItem.children !== undefined && {
|
88
|
+
items: buildNewItemArray(droppedItem.children)
|
89
|
+
}));
|
90
|
+
} else if (dropPosition === 'after') {
|
91
|
+
tree.insertAfter(targetKey, _objectSpread(_objectSpread(_objectSpread({}, rest), droppedItem.value), droppedItem.children !== undefined && {
|
92
|
+
items: buildNewItemArray(droppedItem.children)
|
93
|
+
}));
|
94
|
+
}
|
95
|
+
};
|
96
|
+
|
97
|
+
// split out so that it can be exported and unit tested.
|
98
|
+
export var dropItem = function dropItem(eventTarget, tree, state, droppedItem) {
|
99
|
+
// if dropPosition = 'on', just insert as first child, and then open, if closed
|
100
|
+
if (eventTarget.dropPosition === 'on') {
|
101
|
+
insertItem(tree, eventTarget, droppedItem.key, state);
|
102
|
+
} else {
|
103
|
+
insertItemToPosition(tree, eventTarget.dropPosition, eventTarget.key, droppedItem);
|
104
|
+
}
|
105
|
+
};
|
50
106
|
var TreeView = /*#__PURE__*/forwardRef(function (props, ref) {
|
51
|
-
var _tree$items$,
|
107
|
+
var _tree$items$, _context5;
|
52
108
|
var tree = props.tree,
|
53
109
|
disabledKeys = props.disabledKeys,
|
54
110
|
onExpandedChange = props.onExpandedChange,
|
111
|
+
onDragStartProp = props.onDragStart,
|
112
|
+
onDropProp = props.onDrop,
|
55
113
|
onKeyDown = props.onKeyDown,
|
56
114
|
_props$pageLength = props.pageLength,
|
57
115
|
pageLength = _props$pageLength === void 0 ? 5 : _props$pageLength,
|
58
|
-
others = _objectWithoutProperties(props,
|
59
|
-
|
116
|
+
others = _objectWithoutProperties(props, _excluded3);
|
117
|
+
var _useState = useState(''),
|
118
|
+
_useState2 = _slicedToArray(_useState, 2),
|
119
|
+
keyBeingDragged = _useState2[0],
|
120
|
+
setKeyBeingDragged = _useState2[1];
|
121
|
+
var _useState3 = useState(''),
|
122
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
123
|
+
targetKey = _useState4[0],
|
124
|
+
setTargetKey = _useState4[1];
|
60
125
|
// we are tracking the last focused item.
|
61
126
|
// this enables us to have focus jump back to the item, after focus
|
62
127
|
// leaves the tree, and then returns.
|
63
|
-
var
|
64
|
-
|
65
|
-
lastFocusedItem =
|
66
|
-
setLastFocusedItem =
|
128
|
+
var _useState5 = useState(tree === null || tree === void 0 || (_tree$items$ = tree.items[0]) === null || _tree$items$ === void 0 ? void 0 : _tree$items$.key),
|
129
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
130
|
+
lastFocusedItem = _useState6[0],
|
131
|
+
setLastFocusedItem = _useState6[1];
|
67
132
|
var level = 0;
|
68
133
|
var treeViewRef = useRef();
|
69
134
|
var selectedKeys = tree.selectedKeys;
|
@@ -82,14 +147,14 @@ var TreeView = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
82
147
|
var flattenNestedData = function flattenNestedData(_data) {
|
83
148
|
var returnArray = [];
|
84
149
|
var checkItemNesting = function checkItemNesting(item) {
|
85
|
-
var _item$value, _item$
|
86
|
-
if (((_item$value = item.value) === null || _item$value === void 0 || (_item$value = _item$value.
|
150
|
+
var _item$value, _item$children;
|
151
|
+
if (((_item$value = item.value) === null || _item$value === void 0 || (_item$value = _item$value.children) === null || _item$value === void 0 ? void 0 : _item$value.length) > 0) {
|
87
152
|
return {
|
88
153
|
isTopLevel: true,
|
89
154
|
hasChildren: true
|
90
155
|
};
|
91
156
|
}
|
92
|
-
if (((_item$
|
157
|
+
if (((_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.length) > 0) {
|
93
158
|
return {
|
94
159
|
isTopLevel: false,
|
95
160
|
hasChildren: true
|
@@ -101,12 +166,32 @@ var TreeView = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
101
166
|
};
|
102
167
|
};
|
103
168
|
var checkSection = function checkSection(isRendered, hasItems) {
|
104
|
-
|
169
|
+
if (isRendered === true && hasItems) {
|
170
|
+
return true;
|
171
|
+
}
|
172
|
+
return false;
|
105
173
|
};
|
106
|
-
var
|
174
|
+
var buildParentKeys = function buildParentKeys(parentKey, parentKeys) {
|
175
|
+
var _context;
|
176
|
+
var keyArr = [];
|
177
|
+
if (parentKey) {
|
178
|
+
keyArr.push(parentKey);
|
179
|
+
}
|
180
|
+
return _concatInstanceProperty(_context = []).call(_context, keyArr, parentKeys);
|
181
|
+
};
|
182
|
+
|
183
|
+
// data is the array being looped through
|
184
|
+
// parentKey is the immediate parent of the item
|
185
|
+
// parenKeys is the key of all the nesting levels, all the way to the root
|
186
|
+
var loop = function loop(data, parentKey, parentKeys) {
|
107
187
|
for (var i = 0; i < data.length; i += 1) {
|
188
|
+
var _data$i$value;
|
108
189
|
var obj = {
|
109
|
-
key: data[i].key
|
190
|
+
key: data[i].key,
|
191
|
+
title: data[i].key,
|
192
|
+
items: ((_data$i$value = data[i].value) === null || _data$i$value === void 0 ? void 0 : _data$i$value.children) || data[i].children || null,
|
193
|
+
parentKey: parentKey,
|
194
|
+
parentKeys: buildParentKeys(parentKey, parentKeys)
|
110
195
|
};
|
111
196
|
returnArray.push(obj);
|
112
197
|
var _checkItemNesting = checkItemNesting(data[i]),
|
@@ -114,32 +199,64 @@ var TreeView = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
114
199
|
isTopLevel = _checkItemNesting.isTopLevel;
|
115
200
|
if (checkSection(state.expandedKeys.has(data[i].key), hasChildren) === true) {
|
116
201
|
if (isTopLevel) {
|
117
|
-
var _data$i$
|
118
|
-
loop((_data$i$
|
202
|
+
var _data$i$value2;
|
203
|
+
loop((_data$i$value2 = data[i].value) === null || _data$i$value2 === void 0 ? void 0 : _data$i$value2.children, data[i].key, buildParentKeys(parentKey, parentKeys));
|
119
204
|
} else {
|
120
|
-
|
205
|
+
var _context2;
|
206
|
+
/* istanbul ignore next */
|
207
|
+
loop(data[i].children, data[i].key, _concatInstanceProperty(_context2 = [parentKey]).call(_context2, parentKeys && parentKeys));
|
121
208
|
}
|
122
209
|
}
|
123
210
|
}
|
124
211
|
};
|
125
|
-
loop(_data);
|
212
|
+
loop(_data, undefined, []);
|
126
213
|
return returnArray;
|
127
214
|
};
|
128
215
|
|
129
216
|
// list of value pairs of keys and refs
|
130
217
|
// does not need to be in order, because they are values pairs
|
131
|
-
var
|
132
|
-
|
133
|
-
refArray =
|
134
|
-
setRefs =
|
218
|
+
var _useState7 = useState([]),
|
219
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
220
|
+
refArray = _useState8[0],
|
221
|
+
setRefs = _useState8[1];
|
135
222
|
|
136
223
|
// creates a flattened list of keys for up/down keyboard use
|
137
224
|
// this DOES need to be in the same order as the HTML appears in the DOM.
|
138
225
|
// we are essentially turning all rendered items into a flat list, for up/down
|
139
226
|
var flatKeyArray = useMemo(function () {
|
140
|
-
return flattenNestedData(
|
141
|
-
}, [state.expandedKeys]);
|
227
|
+
return flattenNestedData(_Array$from(state.collection));
|
228
|
+
}, [state.expandedKeys, state.collection]);
|
142
229
|
var ariaLabel = props['aria-label'];
|
230
|
+
var onItemDrop = function onItemDrop(e) {
|
231
|
+
var _context3, _context4;
|
232
|
+
var thisItem = tree.getItem(keyBeingDragged);
|
233
|
+
var foundDraggingItem = _findInstanceProperty(flatKeyArray).call(flatKeyArray, function (_item) {
|
234
|
+
return _item.key === keyBeingDragged;
|
235
|
+
});
|
236
|
+
var foundTargetItem = _findInstanceProperty(flatKeyArray).call(flatKeyArray, function (_item) {
|
237
|
+
return _item.key === e.target.key;
|
238
|
+
});
|
239
|
+
if (_includesInstanceProperty(_context3 = _Array$from(state.disabledKeys)).call(_context3, foundTargetItem.key) && e.target.dropPosition === 'on') {
|
240
|
+
setKeyBeingDragged('');
|
241
|
+
return;
|
242
|
+
}
|
243
|
+
|
244
|
+
// disallow an item from being dropped onto itself, or its children
|
245
|
+
if (e.target.key !== keyBeingDragged && !_includesInstanceProperty(_context4 = foundTargetItem.parentKeys).call(_context4, foundDraggingItem.key)) {
|
246
|
+
dropItem(e.target, tree, state, thisItem);
|
247
|
+
state.selectionManager.state.setFocusedKey(keyBeingDragged);
|
248
|
+
if (onDropProp) {
|
249
|
+
onDropProp(e);
|
250
|
+
}
|
251
|
+
}
|
252
|
+
setKeyBeingDragged('');
|
253
|
+
};
|
254
|
+
var dragItemStart = function dragItemStart(e) {
|
255
|
+
setKeyBeingDragged(_Array$from(_keysInstanceProperty(e))[0]);
|
256
|
+
if (onDragStartProp) {
|
257
|
+
onDragStartProp(e, _keysInstanceProperty(e)[0]);
|
258
|
+
}
|
259
|
+
};
|
143
260
|
var listBoxOptions = {
|
144
261
|
disabledKeys: disabledKeys,
|
145
262
|
'aria-label': ariaLabel
|
@@ -149,6 +266,67 @@ var TreeView = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
149
266
|
keyboardDelegate: layout
|
150
267
|
}), state, treeViewRef),
|
151
268
|
listBoxProps = _useListBox.listBoxProps;
|
269
|
+
var dropState = useDroppableCollectionState(_objectSpread(_objectSpread({}, props), {}, {
|
270
|
+
onDrop: onItemDrop,
|
271
|
+
onDropEnter: function onDropEnter(e) {
|
272
|
+
return setTargetKey(e.target.key);
|
273
|
+
},
|
274
|
+
onDropExit: function onDropExit() {
|
275
|
+
return setTargetKey('');
|
276
|
+
},
|
277
|
+
collection: state.collection,
|
278
|
+
selectionManager: state.selectionManager
|
279
|
+
}));
|
280
|
+
var _useDroppableCollecti = useDroppableCollection(_objectSpread(_objectSpread({}, props), {}, {
|
281
|
+
onDrop: onItemDrop,
|
282
|
+
disabledKeys: disabledKeys,
|
283
|
+
dropTargetDelegate: new ListDropTargetDelegate(flatKeyArray, treeViewRef)
|
284
|
+
}), dropState, treeViewRef),
|
285
|
+
collectionProps = _useDroppableCollecti.collectionProps;
|
286
|
+
|
287
|
+
// Setup drag state for the collection.
|
288
|
+
var dragState = useDraggableCollectionState(_objectSpread(_objectSpread({}, props), {}, {
|
289
|
+
onDragStart: dragItemStart,
|
290
|
+
// Collection and selection manager come from list state.
|
291
|
+
collection: state.collection,
|
292
|
+
selectionManager: state.selectionManager,
|
293
|
+
// Provide data for each dragged item. This function could
|
294
|
+
getItems: function getItems() {
|
295
|
+
return _mapInstanceProperty(flatKeyArray).call(flatKeyArray, function (_item) {
|
296
|
+
return {
|
297
|
+
'text/plain': _item.key
|
298
|
+
};
|
299
|
+
});
|
300
|
+
}
|
301
|
+
}));
|
302
|
+
useEffect(function () {
|
303
|
+
if (_findInstanceProperty(refArray).call(refArray, function (item) {
|
304
|
+
return item.key === lastFocusedItem;
|
305
|
+
})) {
|
306
|
+
var _thisRef$current;
|
307
|
+
var _refArray$find = _findInstanceProperty(refArray).call(refArray, function (item) {
|
308
|
+
return item.key === lastFocusedItem;
|
309
|
+
}),
|
310
|
+
thisRef = _refArray$find.thisRef;
|
311
|
+
thisRef === null || thisRef === void 0 || (_thisRef$current = thisRef.current) === null || _thisRef$current === void 0 ? void 0 : _thisRef$current.focus();
|
312
|
+
}
|
313
|
+
}, [state.selectionManager.focusedKey]);
|
314
|
+
useDraggableCollection(props, dragState, treeViewRef);
|
315
|
+
var _useFocusRing = useFocusRing({
|
316
|
+
within: true
|
317
|
+
}),
|
318
|
+
focusWithinProps = _useFocusRing.focusProps,
|
319
|
+
isFocusedWithin = _useFocusRing.isFocused;
|
320
|
+
useEffect(function () {
|
321
|
+
if (isFocusedWithin) {
|
322
|
+
var _thisRef$current2;
|
323
|
+
var _refArray$find2 = _findInstanceProperty(refArray).call(refArray, function (item) {
|
324
|
+
return item.key === lastFocusedItem;
|
325
|
+
}),
|
326
|
+
thisRef = _refArray$find2.thisRef;
|
327
|
+
thisRef === null || thisRef === void 0 || (_thisRef$current2 = thisRef.current) === null || _thisRef$current2 === void 0 ? void 0 : _thisRef$current2.focus();
|
328
|
+
}
|
329
|
+
}, [isFocusedWithin]);
|
152
330
|
return ___EmotionJSX(TreeViewContext.Provider, {
|
153
331
|
value: {
|
154
332
|
state: state,
|
@@ -156,11 +334,15 @@ var TreeView = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
156
334
|
refArray: refArray,
|
157
335
|
setRefs: setRefs,
|
158
336
|
flatKeyArray: flatKeyArray,
|
337
|
+
dragState: dragState,
|
338
|
+
dropState: dropState,
|
159
339
|
pageLength: pageLength,
|
160
340
|
setLastFocusedItem: setLastFocusedItem,
|
161
|
-
lastFocusedItem: lastFocusedItem
|
341
|
+
lastFocusedItem: lastFocusedItem,
|
342
|
+
targetKey: targetKey,
|
343
|
+
keyBeingDragged: keyBeingDragged
|
162
344
|
}
|
163
|
-
}, ___EmotionJSX(Box, _extends({}, listBoxProps, {
|
345
|
+
}, ___EmotionJSX(Box, _extends({}, mergeProps(listBoxProps, collectionProps, focusWithinProps), focusWithinProps, {
|
164
346
|
ref: treeViewRef,
|
165
347
|
"aria-label": ariaLabel,
|
166
348
|
role: "treegrid",
|
@@ -169,10 +351,10 @@ var TreeView = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
169
351
|
p: '5px',
|
170
352
|
border: 'none !important'
|
171
353
|
}
|
172
|
-
}, others), ___EmotionJSX(TreeViewWrapper, null, _mapInstanceProperty(
|
173
|
-
return SectionOrItemRender(item.
|
354
|
+
}, others), ___EmotionJSX(TreeViewWrapper, null, _mapInstanceProperty(_context5 = _Array$from(state.collection)).call(_context5, function (item, index) {
|
355
|
+
return SectionOrItemRender(item.value.children.length > 0, ___EmotionJSX(TreeViewSection, {
|
174
356
|
item: item,
|
175
|
-
items: item.
|
357
|
+
items: item.value.children,
|
176
358
|
title: item.props.title,
|
177
359
|
key: item.props.title,
|
178
360
|
onKeyDown: onKeyDown,
|
@@ -195,6 +377,10 @@ TreeView.propTypes = {
|
|
195
377
|
this is returned from the useTreeData hook in React-Aria */
|
196
378
|
tree: PropTypes.shape({
|
197
379
|
selectedKeys: isIterableProp,
|
380
|
+
move: PropTypes.func,
|
381
|
+
remove: PropTypes.func,
|
382
|
+
insert: PropTypes.func,
|
383
|
+
getItem: PropTypes.func,
|
198
384
|
items: isIterableProp
|
199
385
|
}).isRequired,
|
200
386
|
/** The currently disabled keys in the collection. */
|
@@ -207,6 +393,10 @@ TreeView.propTypes = {
|
|
207
393
|
'aria-label': PropTypes.string,
|
208
394
|
/** Handler that is called when a key is pressed. */
|
209
395
|
onKeyDown: PropTypes.func,
|
396
|
+
/** Callback that is called when the dragging action starts. */
|
397
|
+
onDragStart: PropTypes.func,
|
398
|
+
/** Callback that is called when the dropping action occurs. */
|
399
|
+
onDrop: PropTypes.func,
|
210
400
|
/** Number of items to move the focus when page up or page down is pressed */
|
211
401
|
pageLength: PropTypes.number
|
212
402
|
};
|
@@ -70,7 +70,7 @@ export var Default = function Default(args) {
|
|
70
70
|
var tree = useTreeData({
|
71
71
|
initialItems: data,
|
72
72
|
getKey: function getKey(item) {
|
73
|
-
return item.
|
73
|
+
return item.key;
|
74
74
|
},
|
75
75
|
getChildren: function getChildren(item) {
|
76
76
|
return item.items;
|
@@ -79,7 +79,8 @@ export var Default = function Default(args) {
|
|
79
79
|
return ___EmotionJSX(TreeView, _extends({}, args, {
|
80
80
|
items: tree.items,
|
81
81
|
tree: tree,
|
82
|
-
"aria-label": "Example Tree"
|
82
|
+
"aria-label": "Example Tree",
|
83
|
+
disabledKeys: ['Single Item']
|
83
84
|
}), function (section) {
|
84
85
|
var _section$value;
|
85
86
|
return ___EmotionJSX(Item, {
|
@@ -3,7 +3,7 @@ var treeRow = {
|
|
3
3
|
cursor: 'pointer',
|
4
4
|
height: '31px',
|
5
5
|
outline: 'none',
|
6
|
-
'&.is-selected, &.is-hovered': {
|
6
|
+
'&.is-selected, &.is-hovered, &.is-drop-target': {
|
7
7
|
backgroundColor: 'active',
|
8
8
|
'& span': {
|
9
9
|
color: 'white'
|
@@ -15,9 +15,6 @@ var treeRow = {
|
|
15
15
|
fill: 'white'
|
16
16
|
}
|
17
17
|
},
|
18
|
-
'&.is-expanded': {
|
19
|
-
marginBottom: 'xs'
|
20
|
-
},
|
21
18
|
'& :focus': {
|
22
19
|
border: 'none'
|
23
20
|
}
|
@@ -26,7 +23,7 @@ var wrapper = {
|
|
26
23
|
'&.is-focused': {
|
27
24
|
boxSizing: 'unset',
|
28
25
|
outline: '1px solid',
|
29
|
-
outlineColor: '
|
26
|
+
outlineColor: 'blue',
|
30
27
|
outlineOffset: '2px'
|
31
28
|
},
|
32
29
|
width: '100%',
|
@@ -38,7 +35,30 @@ var wrapper = {
|
|
38
35
|
},
|
39
36
|
outline: 'none'
|
40
37
|
};
|
38
|
+
var rowWrapper = {
|
39
|
+
'&.is-focused': {
|
40
|
+
boxSizing: 'unset',
|
41
|
+
outline: '1px solid',
|
42
|
+
outlineColor: 'focus',
|
43
|
+
outlineOffset: '2px'
|
44
|
+
},
|
45
|
+
border: 'none',
|
46
|
+
':focus': {
|
47
|
+
border: 'none'
|
48
|
+
},
|
49
|
+
'&.is-expanded': {
|
50
|
+
marginBottom: 'xs'
|
51
|
+
},
|
52
|
+
outline: 'none'
|
53
|
+
};
|
54
|
+
var insertionIndicator = {
|
55
|
+
width: '100%',
|
56
|
+
outline: '1px solid',
|
57
|
+
outlineColor: 'active'
|
58
|
+
};
|
41
59
|
export default {
|
42
60
|
treeRow: treeRow,
|
43
|
-
|
61
|
+
rowWrapper: rowWrapper,
|
62
|
+
wrapper: wrapper,
|
63
|
+
insertionIndicator: insertionIndicator
|
44
64
|
};
|