@pingux/astro 2.130.4 → 2.131.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.
Files changed (64) hide show
  1. package/lib/cjs/components/GridList/GridList.d.ts +3 -0
  2. package/lib/cjs/components/GridList/GridList.js +56 -0
  3. package/lib/cjs/components/GridList/GridList.mdx +68 -0
  4. package/lib/cjs/components/GridList/GridList.stories.d.ts +185 -0
  5. package/lib/cjs/components/GridList/GridList.stories.js +137 -0
  6. package/lib/cjs/components/GridList/GridList.styles.d.ts +18 -0
  7. package/lib/cjs/components/GridList/GridList.styles.js +27 -0
  8. package/lib/cjs/components/GridList/GridList.test.d.ts +1 -0
  9. package/lib/cjs/components/GridList/GridList.test.js +153 -0
  10. package/lib/cjs/components/GridList/GridListRow.d.ts +4 -0
  11. package/lib/cjs/components/GridList/GridListRow.js +88 -0
  12. package/lib/cjs/components/GridList/gridListAttributes.d.ts +170 -0
  13. package/lib/cjs/components/GridList/gridListAttributes.js +178 -0
  14. package/lib/cjs/components/GridList/index.d.ts +2 -0
  15. package/lib/cjs/components/GridList/index.js +21 -0
  16. package/lib/cjs/components/TreeView/InsertionIndicator.js +19 -14
  17. package/lib/cjs/components/TreeView/TreeView.styles.js +2 -1
  18. package/lib/cjs/components/TreeView/index.js +7 -0
  19. package/lib/cjs/hooks/index.d.ts +2 -0
  20. package/lib/cjs/hooks/index.js +14 -0
  21. package/lib/cjs/hooks/useGridList/index.d.ts +1 -0
  22. package/lib/cjs/hooks/useGridList/index.js +14 -0
  23. package/lib/cjs/hooks/useGridList/useGridList.d.ts +18 -0
  24. package/lib/cjs/hooks/useGridList/useGridList.js +175 -0
  25. package/lib/cjs/hooks/useGridListItem/index.d.ts +1 -0
  26. package/lib/cjs/hooks/useGridListItem/index.js +14 -0
  27. package/lib/cjs/hooks/useGridListItem/useGridListItem.d.ts +308 -0
  28. package/lib/cjs/hooks/useGridListItem/useGridListItem.js +67 -0
  29. package/lib/cjs/hooks/useReorderableCollection/index.d.ts +1 -0
  30. package/lib/cjs/hooks/useReorderableCollection/index.js +14 -0
  31. package/lib/cjs/hooks/useReorderableCollection/useReorderableCollection.d.ts +9 -0
  32. package/lib/cjs/hooks/useReorderableCollection/useReorderableCollection.js +99 -0
  33. package/lib/cjs/index.d.ts +1 -0
  34. package/lib/cjs/index.js +15 -0
  35. package/lib/cjs/styles/themes/next-gen/convertedComponentList.js +1 -1
  36. package/lib/cjs/styles/variants/variants.js +2 -0
  37. package/lib/cjs/types/dnd.d.ts +66 -0
  38. package/lib/cjs/types/dnd.js +6 -0
  39. package/lib/cjs/types/gridList.d.ts +59 -0
  40. package/lib/cjs/types/gridList.js +6 -0
  41. package/lib/components/GridList/GridList.js +44 -0
  42. package/lib/components/GridList/GridList.mdx +68 -0
  43. package/lib/components/GridList/GridList.stories.js +124 -0
  44. package/lib/components/GridList/GridList.styles.js +19 -0
  45. package/lib/components/GridList/GridList.test.js +149 -0
  46. package/lib/components/GridList/GridListRow.js +74 -0
  47. package/lib/components/GridList/gridListAttributes.js +170 -0
  48. package/lib/components/GridList/index.js +2 -0
  49. package/lib/components/TreeView/InsertionIndicator.js +19 -14
  50. package/lib/components/TreeView/TreeView.styles.js +2 -1
  51. package/lib/components/TreeView/index.js +1 -0
  52. package/lib/hooks/index.js +2 -0
  53. package/lib/hooks/useGridList/index.js +1 -0
  54. package/lib/hooks/useGridList/useGridList.js +166 -0
  55. package/lib/hooks/useGridListItem/index.js +1 -0
  56. package/lib/hooks/useGridListItem/useGridListItem.js +59 -0
  57. package/lib/hooks/useReorderableCollection/index.js +1 -0
  58. package/lib/hooks/useReorderableCollection/useReorderableCollection.js +91 -0
  59. package/lib/index.js +1 -0
  60. package/lib/styles/themes/next-gen/convertedComponentList.js +1 -1
  61. package/lib/styles/variants/variants.js +2 -0
  62. package/lib/types/dnd.js +1 -0
  63. package/lib/types/gridList.js +1 -0
  64. package/package.json +3 -2
@@ -0,0 +1,74 @@
1
+ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
+ import React, { forwardRef } from 'react';
3
+ import DragIcon from '@pingux/mdi-react/DragVerticalIcon';
4
+ import { useLocalOrForwardRef } from '../../hooks';
5
+ import useGridListItem from '../../hooks/useGridListItem/useGridListItem';
6
+ import { Box, Icon, IconButton } from '../../index';
7
+ import { InsertionIndicator } from '../TreeView';
8
+ import { jsx as ___EmotionJSX } from "@emotion/react";
9
+ var GridListRow = /*#__PURE__*/forwardRef(function (props, ref) {
10
+ var colRef = React.useRef(null);
11
+ var rowRef = useLocalOrForwardRef(ref);
12
+ var buttonRef = React.useRef(null);
13
+ var cellRef = React.useRef(null);
14
+ var dragState = props.dragState,
15
+ dropState = props.dropState,
16
+ isReorderable = props.isReorderable,
17
+ item = props.item,
18
+ state = props.state;
19
+ var _useGridListItem = useGridListItem({
20
+ state: state,
21
+ item: item,
22
+ dragState: dragState,
23
+ dropState: dropState,
24
+ ref: rowRef,
25
+ cellRef: cellRef,
26
+ isReorderable: isReorderable
27
+ }),
28
+ rowProps = _useGridListItem.rowProps,
29
+ gridCellProps = _useGridListItem.gridCellProps,
30
+ buttonProps = _useGridListItem.buttonProps;
31
+ return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(InsertionIndicator, {
32
+ key: "".concat(item.key, "-before"),
33
+ target: {
34
+ type: 'item',
35
+ key: item.key,
36
+ dropPosition: 'before'
37
+ },
38
+ dropState: dropState,
39
+ collectionRef: colRef
40
+ }), ___EmotionJSX(Box, _extends({}, rowProps, {
41
+ variant: "gridList.rowContainer",
42
+ isRow: true,
43
+ ref: rowRef
44
+ }), isReorderable && ___EmotionJSX(Box, {
45
+ isRow: true,
46
+ sx: {
47
+ alignItems: 'center',
48
+ mr: 'xs'
49
+ }
50
+ }, ___EmotionJSX(IconButton, _extends({
51
+ ref: buttonRef
52
+ }, buttonProps, {
53
+ sx: {
54
+ pointerEvents: 'none'
55
+ }
56
+ }), ___EmotionJSX(Icon, {
57
+ icon: DragIcon
58
+ }))), ___EmotionJSX(Box, _extends({}, gridCellProps, {
59
+ isRow: true,
60
+ sx: {
61
+ alignItems: 'center'
62
+ }
63
+ }), item.rendered)), state.collection.getKeyAfter(item.key) == null && ___EmotionJSX(InsertionIndicator, {
64
+ key: "".concat(item.key, "-after"),
65
+ target: {
66
+ type: 'item',
67
+ key: item.key,
68
+ dropPosition: 'after'
69
+ },
70
+ dropState: dropState,
71
+ collectionRef: colRef
72
+ }));
73
+ });
74
+ export default GridListRow;
@@ -0,0 +1,170 @@
1
+ export var gridListArgTypes = {
2
+ isReorderable: {
3
+ description: 'Whether or not the list has drag and drop reorder enabled.',
4
+ control: {
5
+ type: 'boolean'
6
+ }
7
+ },
8
+ selectedKeys: {
9
+ description: 'The array of keys that is currently selected. (Controlled version).',
10
+ control: {
11
+ disable: true
12
+ }
13
+ },
14
+ disabledKeys: {
15
+ description: 'The array of keys that are unable to be selected.',
16
+ control: {
17
+ type: 'text'
18
+ }
19
+ },
20
+ defaultSelectedKeys: {
21
+ description: 'The array of keys that is selected by default. (Uncontrolled version).',
22
+ control: {
23
+ disable: true
24
+ }
25
+ },
26
+ onSelectionChange: {
27
+ description: 'A callback function that fires when the selection changes.',
28
+ control: {
29
+ disable: true
30
+ }
31
+ },
32
+ allowDuplicateSelectionEvents: {
33
+ description: 'Whether duplicate selection events are allowed.',
34
+ control: {
35
+ type: 'boolean'
36
+ }
37
+ },
38
+ autoFocus: {
39
+ description: 'Whether the grid should automatically focus on mount.',
40
+ control: {
41
+ type: 'boolean'
42
+ }
43
+ },
44
+ children: {
45
+ description: 'The child nodes to render inside the grid.',
46
+ control: {
47
+ disable: true
48
+ }
49
+ },
50
+ collection: {
51
+ description: 'The collection of items to display in the grid.',
52
+ control: {
53
+ disable: true
54
+ }
55
+ },
56
+ disabledBehavior: {
57
+ description: 'Defines how disabled items are handled.',
58
+ control: {
59
+ type: 'select',
60
+ options: ['all', 'selection']
61
+ }
62
+ },
63
+ disallowEmptySelection: {
64
+ description: 'Whether empty selection is disallowed.',
65
+ control: {
66
+ type: 'boolean'
67
+ }
68
+ },
69
+ disallowTypeAhead: {
70
+ description: 'Whether type-ahead functionality is disabled.',
71
+ control: {
72
+ type: 'boolean'
73
+ }
74
+ },
75
+ escapeKeyBehavior: {
76
+ description: 'Defines the behavior when the Escape key is pressed.',
77
+ control: {
78
+ type: 'select',
79
+ options: ['clearSelection', 'none']
80
+ }
81
+ },
82
+ filter: {
83
+ description: 'A function to filter items based on the input text.',
84
+ control: {
85
+ disable: true
86
+ }
87
+ },
88
+ getKey: {
89
+ description: 'A function to get the key for an item.',
90
+ control: {
91
+ disable: true
92
+ }
93
+ },
94
+ initialFilterText: {
95
+ description: 'The initial filter text for the grid.',
96
+ control: {
97
+ type: 'text'
98
+ }
99
+ },
100
+ initialSelectedKeys: {
101
+ description: 'The keys that are initially selected.',
102
+ control: {
103
+ disable: true
104
+ }
105
+ },
106
+ items: {
107
+ description: 'The list of items to display in the grid.',
108
+ control: {
109
+ disable: true
110
+ }
111
+ },
112
+ keyboardDelegate: {
113
+ description: 'A custom keyboard delegate for handling keyboard navigation.',
114
+ control: {
115
+ disable: true
116
+ }
117
+ },
118
+ keyboardNavigationBehavior: {
119
+ description: 'Defines the keyboard navigation behavior for the grid.',
120
+ control: {
121
+ type: 'select',
122
+ options: ['arrow', 'tab']
123
+ }
124
+ },
125
+ linkBehavior: {
126
+ description: 'Defines the behavior of links in the grid.',
127
+ control: {
128
+ type: 'select',
129
+ options: ['action', 'selection', 'override']
130
+ }
131
+ },
132
+ onAction: {
133
+ description: 'A callback function that fires when an action is performed on an item.',
134
+ control: {
135
+ disable: true
136
+ }
137
+ },
138
+ ref: {
139
+ description: 'A ref object for the grid.',
140
+ control: {
141
+ disable: true
142
+ }
143
+ },
144
+ selectionBehavior: {
145
+ description: 'Defines the selection behavior for the grid.',
146
+ control: {
147
+ type: 'select',
148
+ options: ['toggle', 'replace']
149
+ }
150
+ },
151
+ selectionMode: {
152
+ description: 'Defines the selection mode for the grid.',
153
+ control: {
154
+ type: 'select',
155
+ options: ['none', 'single', 'multiple']
156
+ }
157
+ },
158
+ shouldFocusWrap: {
159
+ description: 'Whether focus should wrap around when navigating with the keyboard.',
160
+ control: {
161
+ type: 'boolean'
162
+ }
163
+ },
164
+ shouldSelectOnPressUp: {
165
+ description: 'Whether selection should occur on key press up.',
166
+ control: {
167
+ type: 'boolean'
168
+ }
169
+ }
170
+ };
@@ -0,0 +1,2 @@
1
+ export { default } from './GridList';
2
+ export { default as GridListRow } from './GridListRow';
@@ -1,38 +1,43 @@
1
1
  import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
2
  import React from 'react';
3
+ import { useVisuallyHidden } from 'react-aria';
3
4
  import { useDropIndicator } from '@react-aria/dnd';
4
5
  import PropTypes from 'prop-types';
5
6
  import { Box } from '../..';
6
- import { useStatusClasses } from '../../hooks';
7
7
  import { jsx as ___EmotionJSX } from "@emotion/react";
8
8
  var InsertionIndicator = function InsertionIndicator(props) {
9
9
  var insertRef = React.useRef(null);
10
10
  var target = props.target,
11
11
  state = props.dropState;
12
+ var _useVisuallyHidden = useVisuallyHidden(),
13
+ visuallyHiddenProps = _useVisuallyHidden.visuallyHiddenProps;
12
14
  var _useDropIndicator = useDropIndicator({
13
- target: target,
14
- isPresentationOnly: true
15
+ target: target
15
16
  }, state, {
16
17
  ref: insertRef
17
18
  }),
18
19
  dropIndicatorProps = _useDropIndicator.dropIndicatorProps,
19
20
  isHidden = _useDropIndicator.isHidden,
20
21
  isDropTarget = _useDropIndicator.isDropTarget;
21
- var _useStatusClasses = useStatusClasses('', {
22
- isDropTarget: isDropTarget
23
- }),
24
- classNames = _useStatusClasses.classNames;
25
22
  if (isHidden) {
26
23
  return null;
27
24
  }
28
- return ___EmotionJSX(Box, _extends({
29
- as: "li"
30
- }, dropIndicatorProps, {
31
- role: "option",
32
- ref: insertRef,
33
- className: classNames,
25
+ if (!isDropTarget) {
26
+ return null;
27
+ }
28
+ return ___EmotionJSX(Box, {
29
+ role: "row",
30
+ "aria-hidden": dropIndicatorProps['aria-hidden'],
31
+ "data-testid": "insertion-indicator"
32
+ }, ___EmotionJSX(Box, {
33
+ role: "gridcell",
34
+ "aria-selected": "false",
34
35
  variant: "treeView.insertionIndicator"
35
- }));
36
+ }, ___EmotionJSX(Box, _extends({}, visuallyHiddenProps, {
37
+ role: "button"
38
+ }, dropIndicatorProps, {
39
+ ref: insertRef
40
+ }))));
36
41
  };
37
42
  InsertionIndicator.propTypes = {
38
43
  dropState: PropTypes.shape({}),
@@ -54,7 +54,8 @@ var rowWrapper = {
54
54
  var insertionIndicator = {
55
55
  width: '100%',
56
56
  outline: '1px solid',
57
- outlineColor: 'active'
57
+ outlineColor: 'active',
58
+ mt: '3px'
58
59
  };
59
60
  export default {
60
61
  treeRow: treeRow,
@@ -1,3 +1,4 @@
1
+ export { default as InsertionIndicator } from './InsertionIndicator';
1
2
  export { default } from './TreeView';
2
3
  export { default as TreeViewItem } from './TreeViewItem';
3
4
  export { default as TreeViewSection } from './TreeViewSection';
@@ -8,6 +8,8 @@ export { default as useDevelopmentWarning } from './useDevelopmentWarning';
8
8
  export { default as useFallbackImage } from './useFallbackImage';
9
9
  export { default as useField } from './useField';
10
10
  export { default as useGetTheme } from './useGetTheme';
11
+ export { default as useGridList } from './useGridList';
12
+ export { default as useGridListItem } from './useGridListItem';
11
13
  export { default as useInputLoader } from './useInputLoader';
12
14
  export { default as useLabelHeight } from './useLabelHeight';
13
15
  export { default as useLocalOrForwardRef } from './useLocalOrForwardRef';
@@ -0,0 +1 @@
1
+ export { default } from './useGridList';
@@ -0,0 +1,166 @@
1
+ import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
2
+ import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
3
+ import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
4
+ import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
5
+ import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
6
+ import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
7
+ import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
8
+ import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
9
+ 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; }
10
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
11
+ import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
12
+ import { useListState } from 'react-stately';
13
+ import { useGridList as raUseGridList } from '@react-aria/gridlist';
14
+ import { useListData } from '@react-stately/data';
15
+ import useReorderableCollection from '../useReorderableCollection';
16
+ var useGridList = function useGridList(props) {
17
+ var acceptedDragTypes = props.acceptedDragTypes,
18
+ allowDuplicateSelectionEvents = props.allowDuplicateSelectionEvents,
19
+ autoFocus = props.autoFocus,
20
+ children = props.children,
21
+ collection = props.collection,
22
+ defaultSelectedKeys = props.defaultSelectedKeys,
23
+ disabledBehavior = props.disabledBehavior,
24
+ disabledKeys = props.disabledKeys,
25
+ disallowEmptySelection = props.disallowEmptySelection,
26
+ disallowTypeAhead = props.disallowTypeAhead,
27
+ escapeKeyBehavior = props.escapeKeyBehavior,
28
+ filter = _filterInstanceProperty(props),
29
+ getDropOperation = props.getDropOperation,
30
+ initialFilterText = props.initialFilterText,
31
+ initialSelectedKeys = props.initialSelectedKeys,
32
+ isReorderable = props.isReorderable,
33
+ items = props.items,
34
+ keyboardDelegate = props.keyboardDelegate,
35
+ keyboardNavigationBehavior = props.keyboardNavigationBehavior,
36
+ linkBehavior = props.linkBehavior,
37
+ onDragEnd = props.onDragEnd,
38
+ onDragMove = props.onDragMove,
39
+ onDragStart = props.onDragStart,
40
+ onDrop = props.onDrop,
41
+ onDropActivate = props.onDropActivate,
42
+ onDropEnter = props.onDropEnter,
43
+ onDropExit = props.onDropExit,
44
+ onInsert = props.onInsert,
45
+ onItemDrop = props.onItemDrop,
46
+ onReorder = props.onReorder,
47
+ onRootDrop = props.onRootDrop,
48
+ onSelectionChange = props.onSelectionChange,
49
+ ref = props.ref,
50
+ selectionBehavior = props.selectionBehavior,
51
+ selectionMode = props.selectionMode,
52
+ selectedKeys = props.selectedKeys,
53
+ shouldAcceptItemDrop = props.shouldAcceptItemDrop,
54
+ shouldFocusWrap = props.shouldFocusWrap,
55
+ shouldSelectOnPressUp = props.shouldSelectOnPressUp;
56
+ var draggableCollectionStateOptions = {
57
+ isDisabled: !isReorderable,
58
+ onDragEnd: onDragEnd,
59
+ onDragMove: onDragMove,
60
+ onDragStart: onDragStart
61
+ };
62
+ var droppableCollectionStateOptions = {
63
+ acceptedDragTypes: acceptedDragTypes,
64
+ getDropOperation: getDropOperation,
65
+ isDisabled: isReorderable,
66
+ onDrop: onDrop,
67
+ onDropEnter: onDropEnter,
68
+ onDropExit: onDropExit,
69
+ onInsert: onInsert,
70
+ onItemDrop: onItemDrop,
71
+ onReorder: onReorder,
72
+ onRootDrop: onRootDrop,
73
+ shouldAcceptItemDrop: shouldAcceptItemDrop
74
+ };
75
+ var useDroppableCollectionOptions = {
76
+ acceptedDragTypes: acceptedDragTypes,
77
+ onInsert: onInsert,
78
+ onRootDrop: onRootDrop,
79
+ onItemDrop: onItemDrop,
80
+ onReorder: onReorder,
81
+ shouldAcceptItemDrop: shouldAcceptItemDrop,
82
+ onDropEnter: onDropEnter,
83
+ onDropActivate: onDropActivate,
84
+ onDropExit: onDropExit,
85
+ onDrop: onDrop,
86
+ getDropOperation: getDropOperation
87
+ };
88
+ var listOptions = {
89
+ filter: filter,
90
+ initialFilterText: initialFilterText,
91
+ initialItems: items,
92
+ initialSelectedKeys: initialSelectedKeys
93
+ };
94
+ var listStateOptions = {
95
+ allowDuplicateSelectionEvents: allowDuplicateSelectionEvents,
96
+ children: children,
97
+ collection: collection,
98
+ defaultSelectedKeys: defaultSelectedKeys,
99
+ disabledBehavior: disabledBehavior,
100
+ disabledKeys: disabledKeys,
101
+ disallowEmptySelection: disallowEmptySelection,
102
+ filter: filter,
103
+ onSelectionChange: onSelectionChange,
104
+ selectedKeys: selectedKeys,
105
+ selectionBehavior: selectionBehavior,
106
+ selectionMode: selectionMode
107
+ };
108
+ var list = useListData(_objectSpread({}, listOptions));
109
+ var state = useListState(_objectSpread(_objectSpread({}, listStateOptions), {}, {
110
+ items: list.items
111
+ }));
112
+ var gridOptions = {
113
+ autoFocus: autoFocus,
114
+ defaultSelectedKeys: defaultSelectedKeys,
115
+ disabledBehavior: disabledBehavior,
116
+ disabledKeys: disabledKeys,
117
+ disallowEmptySelection: disallowEmptySelection,
118
+ disallowTypeAhead: disallowTypeAhead,
119
+ escapeKeyBehavior: escapeKeyBehavior,
120
+ items: list.items,
121
+ keyboardDelegate: keyboardDelegate,
122
+ keyboardNavigationBehavior: keyboardNavigationBehavior,
123
+ linkBehavior: linkBehavior,
124
+ onSelectionChange: onSelectionChange,
125
+ selectedKeys: selectedKeys,
126
+ selectionMode: selectionMode,
127
+ shouldFocusWrap: shouldFocusWrap,
128
+ shouldSelectOnPressUp: shouldSelectOnPressUp
129
+ };
130
+ var _raUseGridList = raUseGridList(_objectSpread(_objectSpread({}, gridOptions), {}, {
131
+ 'aria-label': 'Reorderable list',
132
+ disabledBehavior: disabledBehavior,
133
+ shouldFocusWrap: true
134
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
135
+ }), state, ref),
136
+ gridProps = _raUseGridList.gridProps;
137
+ var dndOptions = {
138
+ draggableCollectionStateOptions: draggableCollectionStateOptions,
139
+ droppableCollectionStateOptions: droppableCollectionStateOptions,
140
+ isReorderable: isReorderable,
141
+ list: list,
142
+ ref: ref,
143
+ state: state,
144
+ useDroppableCollectionOptions: useDroppableCollectionOptions
145
+ };
146
+ var _useReorderableCollec = useReorderableCollection(_objectSpread({}, dndOptions)),
147
+ dragState = _useReorderableCollec.dragState,
148
+ dropState = _useReorderableCollec.dropState,
149
+ collectionProps = _useReorderableCollec.collectionProps;
150
+ var gridListItemProps = {
151
+ dragState: dragState,
152
+ dropState: dropState,
153
+ isReorderable: isReorderable,
154
+ shouldSelectOnPressUp: shouldSelectOnPressUp,
155
+ state: state
156
+ };
157
+ return {
158
+ collectionProps: collectionProps,
159
+ dragState: dragState,
160
+ dropState: dropState,
161
+ gridListItemProps: gridListItemProps,
162
+ gridProps: gridProps,
163
+ state: state
164
+ };
165
+ };
166
+ export default useGridList;
@@ -0,0 +1 @@
1
+ export { default } from './useGridListItem';
@@ -0,0 +1,59 @@
1
+ import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
2
+ import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
3
+ import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
4
+ import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
5
+ import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
6
+ import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
7
+ import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
8
+ import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
9
+ import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
10
+ 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; }
11
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
12
+ import { mergeProps } from 'react-aria';
13
+ import { useDraggableItem } from '@react-aria/dnd';
14
+ import { useFocusRing } from '@react-aria/focus';
15
+ import { useGridListItem as raUseGridListItem } from '@react-aria/gridlist';
16
+ import { useStatusClasses } from '..';
17
+ var useGridListItem = function useGridListItem(props) {
18
+ var dragState = props.dragState,
19
+ isReorderable = props.isReorderable,
20
+ item = props.item,
21
+ ref = props.ref,
22
+ state = props.state;
23
+ var _raUseGridListItem = raUseGridListItem({
24
+ node: item,
25
+ hasChildItems: true
26
+ },
27
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
+ state, ref),
29
+ rowProps = _raUseGridListItem.rowProps,
30
+ gridCellProps = _raUseGridListItem.gridCellProps;
31
+
32
+ // Register the item as a drag source.
33
+ var _useDraggableItem = useDraggableItem({
34
+ hasDragButton: true,
35
+ key: item.key
36
+ }, dragState),
37
+ dragProps = _useDraggableItem.dragProps,
38
+ dragButtonProps = _useDraggableItem.dragButtonProps;
39
+ var _useFocusRing = useFocusRing(),
40
+ focusProps = _useFocusRing.focusProps,
41
+ isFocusVisible = _useFocusRing.isFocusVisible;
42
+ var isDragging = dragState.draggedKey === item.key;
43
+ var _useStatusClasses = useStatusClasses('', {
44
+ isFocused: isFocusVisible,
45
+ isDragging: isDragging
46
+ }),
47
+ classNames = _useStatusClasses.classNames;
48
+ var mergedRowProps = _objectSpread({}, mergeProps(rowProps, focusProps, _objectSpread({}, isReorderable && dragProps), {
49
+ className: classNames
50
+ }));
51
+ var buttonProps = _objectSpread({}, mergeProps(dragButtonProps));
52
+ return {
53
+ buttonProps: buttonProps,
54
+ gridCellProps: gridCellProps,
55
+ isDragging: isDragging,
56
+ rowProps: mergedRowProps
57
+ };
58
+ };
59
+ export default useGridListItem;
@@ -0,0 +1 @@
1
+ export { default } from './useReorderableCollection';
@@ -0,0 +1,91 @@
1
+ import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
2
+ import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
3
+ import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
4
+ import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
5
+ import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
6
+ import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
7
+ import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
8
+ import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
9
+ import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
10
+ import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
11
+ import _valuesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/values";
12
+ import _keysInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/keys";
13
+ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
14
+ import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
15
+ 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; }
16
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
17
+ import { useState } from 'react';
18
+ import { ListDropTargetDelegate, useDraggableCollection, useDroppableCollection } from '@react-aria/dnd';
19
+ import { ListKeyboardDelegate } from '@react-aria/selection';
20
+ import { useDraggableCollectionState, useDroppableCollectionState } from '@react-stately/dnd';
21
+ var useReorderableCollection = function useReorderableCollection(props) {
22
+ var _useState = useState(''),
23
+ _useState2 = _slicedToArray(_useState, 2),
24
+ draggingKey = _useState2[0],
25
+ setDraggingKey = _useState2[1];
26
+ var draggableCollectionStateOptions = props.draggableCollectionStateOptions,
27
+ droppableCollectionStateOptions = props.droppableCollectionStateOptions,
28
+ isReorderable = props.isReorderable,
29
+ list = props.list,
30
+ useDroppableCollectionOptions = props.useDroppableCollectionOptions,
31
+ ref = props.ref,
32
+ state = props.state;
33
+ var _onReorder = useDroppableCollectionOptions.onReorder;
34
+ var onDropFunction = function onDropFunction(e) {
35
+ if (e.target.dropPosition === 'before') {
36
+ list.moveBefore(e.target.key, [draggingKey]);
37
+ } else if (e.target.dropPosition === 'after') {
38
+ list.moveAfter(e.target.key, [draggingKey]);
39
+ }
40
+ };
41
+ var draggableStateOptions = _objectSpread(_objectSpread({}, draggableCollectionStateOptions), {}, {
42
+ onDragStart: function onDragStart(e) {
43
+ var _context;
44
+ setDraggingKey(_valuesInstanceProperty(_context = _keysInstanceProperty(e)).call(_context).next().value);
45
+ },
46
+ collection: state.collection,
47
+ selectionManager: state.selectionManager,
48
+ getItems: function getItems() {
49
+ var _context2;
50
+ return _mapInstanceProperty(_context2 = _Array$from(state.collection)).call(_context2, function (_item) {
51
+ return {
52
+ 'text/plain': _item.key
53
+ };
54
+ });
55
+ }
56
+ });
57
+
58
+ // Setup drag state for the collection.
59
+ var dragState = useDraggableCollectionState(_objectSpread({}, draggableStateOptions));
60
+ var dropState = useDroppableCollectionState(_objectSpread(_objectSpread(_objectSpread({}, droppableCollectionStateOptions), isReorderable && {
61
+ onReorder: onDropFunction
62
+ }), {}, {
63
+ collection: state.collection,
64
+ selectionManager: state.selectionManager
65
+ }));
66
+
67
+ // not having this be an any would require bumping the react-aria global version.
68
+ // not sure we want to do that at this time.
69
+ var keyboardDelegate = new ListKeyboardDelegate(
70
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
71
+ state.collection, state.disabledKeys, ref);
72
+ var _useDroppableCollecti = useDroppableCollection(_objectSpread(_objectSpread({}, useDroppableCollectionOptions), {}, {
73
+ onReorder: function onReorder(e) {
74
+ onDropFunction(e);
75
+ if (_onReorder) {
76
+ _onReorder(e);
77
+ }
78
+ },
79
+ dropTargetDelegate: new ListDropTargetDelegate(state.collection, ref),
80
+ keyboardDelegate: keyboardDelegate
81
+ }), dropState, ref),
82
+ collectionProps = _useDroppableCollecti.collectionProps;
83
+ useDraggableCollection(props, dragState, ref);
84
+ return {
85
+ collectionProps: collectionProps,
86
+ dragState: dragState,
87
+ dropState: dropState,
88
+ state: state
89
+ };
90
+ };
91
+ export default useReorderableCollection;
package/lib/index.js CHANGED
@@ -86,6 +86,7 @@ export { default as FileInputField } from './components/FileInputField';
86
86
  export { default as Footer } from './components/Footer';
87
87
  export * from './components/Footer';
88
88
  export { default as Grid } from './components/Grid';
89
+ export { default as GridList, GridListRow } from './components/GridList';
89
90
  export { default as HelpHint } from './components/HelpHint';
90
91
  export * from './components/HelpHint';
91
92
  export { default as Icon } from './components/Icon';