@pingux/astro 2.50.0 → 2.51.0-alpha.1
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/FieldHelperText/FieldHelperText.styles.d.ts +832 -2
- package/lib/cjs/components/ListBox/ListBox.d.ts +11 -0
- package/lib/cjs/components/ListBox/ListBox.js +7 -45
- package/lib/cjs/components/ListBox/ListBox.styles.d.ts +3 -0
- package/lib/cjs/components/ListBox/ListBox.test.d.ts +1 -0
- package/lib/cjs/components/ListBox/ListBox.test.js +29 -28
- package/lib/cjs/components/ListBox/ListBoxContext.d.ts +2 -0
- package/lib/cjs/components/ListBox/ListBoxContext.js +1 -1
- package/lib/cjs/components/ListBox/ListBoxSection.d.ts +10 -0
- package/lib/cjs/components/ListBox/ListBoxSection.js +4 -4
- package/lib/cjs/components/ListBox/Option.d.ts +4 -0
- package/lib/cjs/components/ListBox/Option.js +11 -33
- package/lib/cjs/components/ListBox/index.d.ts +2 -0
- package/lib/cjs/components/ListView/ListView.js +26 -10
- package/lib/cjs/components/ListView/ListView.stories.js +179 -13
- package/lib/cjs/components/ListView/ListView.test.js +300 -35
- package/lib/cjs/components/ListView/ListViewExpandableItem.js +100 -0
- package/lib/cjs/components/ListView/ListViewFocusWrapper.js +117 -0
- package/lib/cjs/components/ListView/ListViewItem.js +24 -16
- package/lib/cjs/components/ListViewItem/ListViewItem.styles.js +34 -1
- package/lib/cjs/components/Text/Text.styles.d.ts +1664 -18
- package/lib/cjs/hooks/useExpandableListViewItem/index.d.ts +1 -0
- package/lib/cjs/hooks/useExpandableListViewItem/index.js +14 -0
- package/lib/cjs/hooks/useExpandableListViewItem/useExpandableListViewItem.d.ts +51 -0
- package/lib/cjs/hooks/useExpandableListViewItem/useExpandableListViewItem.js +237 -0
- package/lib/cjs/hooks/useSelectField/useSelectField.d.ts +2 -2
- package/lib/cjs/hooks/useSelectField/useSelectField.js +1 -1
- package/lib/cjs/types/index.d.ts +1 -0
- package/lib/cjs/types/index.js +27 -16
- package/lib/cjs/types/listBox.d.ts +49 -0
- package/lib/cjs/types/listBox.js +6 -0
- package/lib/components/ListBox/ListBox.js +8 -46
- package/lib/components/ListBox/ListBox.test.js +23 -28
- package/lib/components/ListBox/ListBoxContext.js +1 -1
- package/lib/components/ListBox/ListBoxSection.js +4 -4
- package/lib/components/ListBox/Option.js +11 -33
- package/lib/components/ListView/ListView.js +26 -10
- package/lib/components/ListView/ListView.stories.js +177 -14
- package/lib/components/ListView/ListView.test.js +300 -35
- package/lib/components/ListView/ListViewExpandableItem.js +86 -0
- package/lib/components/ListView/ListViewFocusWrapper.js +102 -0
- package/lib/components/ListView/ListViewItem.js +25 -17
- package/lib/components/ListViewItem/ListViewItem.styles.js +34 -1
- package/lib/hooks/useExpandableListViewItem/index.js +1 -0
- package/lib/hooks/useExpandableListViewItem/useExpandableListViewItem.js +229 -0
- package/lib/hooks/useSelectField/useSelectField.js +1 -1
- package/lib/types/index.js +1 -0
- package/lib/types/listBox.js +1 -0
- package/package.json +6 -2
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './useExpandableListViewItem';
|
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
5
|
+
_Object$defineProperty(exports, "__esModule", {
|
6
|
+
value: true
|
7
|
+
});
|
8
|
+
_Object$defineProperty(exports, "default", {
|
9
|
+
enumerable: true,
|
10
|
+
get: function get() {
|
11
|
+
return _useExpandableListViewItem["default"];
|
12
|
+
}
|
13
|
+
});
|
14
|
+
var _useExpandableListViewItem = _interopRequireDefault(require("./useExpandableListViewItem"));
|
@@ -0,0 +1,51 @@
|
|
1
|
+
/// <reference types="react" />
|
2
|
+
import type { TreeState } from 'react-stately';
|
3
|
+
import type { SelectionManager } from '@react-stately/selection';
|
4
|
+
import type { GridNode } from '@react-types/grid';
|
5
|
+
interface UseExpandableListViewItemResult {
|
6
|
+
expandableRowProps: object;
|
7
|
+
cellProps: object;
|
8
|
+
expandableContainerProps: object;
|
9
|
+
expandableItemState: object;
|
10
|
+
}
|
11
|
+
interface UseExpandableListViewItem<T> {
|
12
|
+
/**
|
13
|
+
* This hook wraps the useListItem hook, and modifies it,
|
14
|
+
* providing expansion capabilities and the option for
|
15
|
+
* escaping the focus of the ListView grid.
|
16
|
+
*
|
17
|
+
* Returns four objects, three of which are spread into subcomponents,
|
18
|
+
* the fourth provides state handing props.
|
19
|
+
* @param {Object} [props] Properties provided to the underlying hooks
|
20
|
+
* @param {Boolean} [props.isHoverable] whether or not the option is hoverable
|
21
|
+
* @param {ReactRef} [props.expandableChildrenRef] the container of all of the expandable content
|
22
|
+
* @param {ReactRef} [props.expandableItemRowRef] the container of for the entire item
|
23
|
+
* @param {String} [props.className] custom css classname applied to the row
|
24
|
+
* @param {Object} [props.state] state prop passed from useTreeState. handles expansion
|
25
|
+
* @param {Object} [props.item] item object.
|
26
|
+
*
|
27
|
+
* @returns {Object} {expandableRowProps}: props spread into the entire row container
|
28
|
+
* @returns {Object} {cellProps}: props spread into the non-expanded content cell
|
29
|
+
* @returns {Object} {expandableContainerProps}: spread into the expanded content cell
|
30
|
+
* @returns {Object} {state}: expansion, focus, and additonal cell props
|
31
|
+
*/
|
32
|
+
(props: ExpandableListViewItemProps<T>): UseExpandableListViewItemResult;
|
33
|
+
}
|
34
|
+
interface ListViewState<T> extends TreeState<T> {
|
35
|
+
hover: {
|
36
|
+
hoveredItem?: string;
|
37
|
+
setHoveredItem: (hoveredItem: string | number) => unknown;
|
38
|
+
};
|
39
|
+
isLink: boolean;
|
40
|
+
selectionManager: SelectionManager;
|
41
|
+
}
|
42
|
+
interface ExpandableListViewItemProps<T> {
|
43
|
+
expandableItemRowRef: React.MutableRefObject<HTMLDivElement | null>;
|
44
|
+
expandableChildrenRef: React.MutableRefObject<HTMLDivElement | null>;
|
45
|
+
className: string;
|
46
|
+
item: GridNode<T>;
|
47
|
+
state: ListViewState<T>;
|
48
|
+
key: string | number;
|
49
|
+
}
|
50
|
+
declare const useExpandableListViewItem: UseExpandableListViewItem<object>;
|
51
|
+
export default useExpandableListViewItem;
|
@@ -0,0 +1,237 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _Object$keys = require("@babel/runtime-corejs3/core-js-stable/object/keys");
|
4
|
+
var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
|
5
|
+
var _filterInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/filter");
|
6
|
+
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
|
7
|
+
var _forEachInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
|
8
|
+
var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
|
9
|
+
var _Object$defineProperties = require("@babel/runtime-corejs3/core-js-stable/object/define-properties");
|
10
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
11
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
12
|
+
_Object$defineProperty(exports, "__esModule", {
|
13
|
+
value: true
|
14
|
+
});
|
15
|
+
exports["default"] = void 0;
|
16
|
+
var _set = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set"));
|
17
|
+
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
18
|
+
var _from = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/from"));
|
19
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
20
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
|
21
|
+
var _react = require("react");
|
22
|
+
var _reactAria = require("react-aria");
|
23
|
+
var _interactions = require("@react-aria/interactions");
|
24
|
+
var _ = require("..");
|
25
|
+
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; }
|
26
|
+
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) { (0, _defineProperty2["default"])(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; }
|
27
|
+
var useExpandableListViewItem = function useExpandableListViewItem(props) {
|
28
|
+
var _expandableChildrenRe3;
|
29
|
+
var item = props.item,
|
30
|
+
_props$item$props = props.item.props,
|
31
|
+
listItemProps = _props$item$props.listItemProps,
|
32
|
+
rowProps = _props$item$props.rowProps,
|
33
|
+
state = props.state,
|
34
|
+
expandableItemRowRef = props.expandableItemRowRef,
|
35
|
+
expandableChildrenRef = props.expandableChildrenRef,
|
36
|
+
className = props.className;
|
37
|
+
var hasSeparator = true;
|
38
|
+
|
39
|
+
// convenience extractions from props
|
40
|
+
var key = item.key;
|
41
|
+
var dataId = item.props['data-id'];
|
42
|
+
var isDisabled = state.disabledKeys.has(key);
|
43
|
+
var isSelectable = state.selectionManager.selectionMode !== 'none';
|
44
|
+
var isExpanded = state.expandedKeys.has(key);
|
45
|
+
var isSelected = state.selectionManager.isSelected(key);
|
46
|
+
|
47
|
+
// initialize state
|
48
|
+
var _useState = (0, _react.useState)(false),
|
49
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
50
|
+
isFocusEscaped = _useState2[0],
|
51
|
+
setIsFocusEscaped = _useState2[1];
|
52
|
+
|
53
|
+
// call spectrum hooks
|
54
|
+
var _useFocusRing = (0, _reactAria.useFocusRing)({
|
55
|
+
within: true
|
56
|
+
}),
|
57
|
+
isFocusVisibleWithin = _useFocusRing.isFocusVisible,
|
58
|
+
focusWithinProps = _useFocusRing.focusProps;
|
59
|
+
var _useFocusRing2 = (0, _reactAria.useFocusRing)(),
|
60
|
+
isFocusVisibleContainer = _useFocusRing2.isFocusVisible,
|
61
|
+
containerFocusProps = _useFocusRing2.focusProps;
|
62
|
+
var _useFocusRing3 = (0, _reactAria.useFocusRing)({
|
63
|
+
within: true
|
64
|
+
}),
|
65
|
+
isFocusWithinVisibleContainer = _useFocusRing3.isFocusVisible,
|
66
|
+
containerWithinFocusProps = _useFocusRing3.focusProps;
|
67
|
+
var _useFocusRing4 = (0, _reactAria.useFocusRing)(),
|
68
|
+
focusProps = _useFocusRing4.focusProps,
|
69
|
+
isFocusVisible = _useFocusRing4.isFocusVisible;
|
70
|
+
var _useHover = (0, _interactions.useHover)({
|
71
|
+
onHoverStart: /* istanbul ignore next */
|
72
|
+
function onHoverStart() {
|
73
|
+
state.hover.setHoveredItem(item.key);
|
74
|
+
},
|
75
|
+
onHoverEnd: /* istanbul ignore next */
|
76
|
+
function onHoverEnd() {
|
77
|
+
state.hover.setHoveredItem('');
|
78
|
+
}
|
79
|
+
}),
|
80
|
+
hoverProps = _useHover.hoverProps;
|
81
|
+
var _useGridListItem = (0, _reactAria.useGridListItem)({
|
82
|
+
node: item,
|
83
|
+
isVirtualized: true
|
84
|
+
}, state, expandableItemRowRef),
|
85
|
+
raRowProps = _useGridListItem.rowProps,
|
86
|
+
gridCellProps = _useGridListItem.gridCellProps;
|
87
|
+
|
88
|
+
// remove row mouse event props
|
89
|
+
// delete raRowProps.onClick;
|
90
|
+
delete raRowProps.onMouseDown;
|
91
|
+
delete raRowProps.onPointerDown;
|
92
|
+
|
93
|
+
// declare custom functions
|
94
|
+
var expandItem = function expandItem() {
|
95
|
+
var _context;
|
96
|
+
var newSet = new _set["default"]((0, _concat["default"])(_context = []).call(_context, (0, _from["default"])(state.expandedKeys), [key]));
|
97
|
+
state.setExpandedKeys(newSet);
|
98
|
+
};
|
99
|
+
var toggleExpanded = function toggleExpanded() {
|
100
|
+
if (isExpanded) {
|
101
|
+
var _context2;
|
102
|
+
var set = new _set["default"]((0, _concat["default"])(_context2 = []).call(_context2, (0, _from["default"])(state.expandedKeys)));
|
103
|
+
set["delete"](key);
|
104
|
+
state.setExpandedKeys(set);
|
105
|
+
} else {
|
106
|
+
expandItem();
|
107
|
+
}
|
108
|
+
};
|
109
|
+
|
110
|
+
// overrides the row navigation.
|
111
|
+
// if escape is pressed, focus is returned to the expanded content container
|
112
|
+
|
113
|
+
var onKeyDownEscapeFocusRowOverride = function onKeyDownEscapeFocusRowOverride(e) {
|
114
|
+
if (e.keyCode === 27) {
|
115
|
+
var _expandableChildrenRe;
|
116
|
+
/* istanbul ignore next */
|
117
|
+
setIsFocusEscaped(false);
|
118
|
+
/* istanbul ignore next */
|
119
|
+
expandableChildrenRef === null || expandableChildrenRef === void 0 || (_expandableChildrenRe = expandableChildrenRef.current) === null || _expandableChildrenRe === void 0 ? void 0 : _expandableChildrenRe.focus();
|
120
|
+
}
|
121
|
+
};
|
122
|
+
|
123
|
+
// if the row is expanded, and key left is pressed:
|
124
|
+
// return focus to the expanded content container
|
125
|
+
var listenOnRowForLeft = function listenOnRowForLeft(e) {
|
126
|
+
if (e.keyCode === 37 && e.target === expandableItemRowRef.current && isExpanded) {
|
127
|
+
var _expandableChildrenRe2;
|
128
|
+
expandableChildrenRef === null || expandableChildrenRef === void 0 || (_expandableChildrenRe2 = expandableChildrenRef.current) === null || _expandableChildrenRe2 === void 0 ? void 0 : _expandableChildrenRe2.focus();
|
129
|
+
} else if ((e.keyCode === 13 || e.keyCode === 32) && e.target === expandableItemRowRef.current) {
|
130
|
+
toggleExpanded();
|
131
|
+
} else if (raRowProps.onKeyDownCapture) {
|
132
|
+
raRowProps.onKeyDownCapture(e);
|
133
|
+
}
|
134
|
+
};
|
135
|
+
|
136
|
+
// if the expanded content container is focused, this function will call
|
137
|
+
// it returns focus to the row on right press, and calls the native left press
|
138
|
+
var expandedChildrenKeyCaptureOverride = function expandedChildrenKeyCaptureOverride(e) {
|
139
|
+
var _expandableItemRowRef;
|
140
|
+
// if left go back ie dont stifle
|
141
|
+
// if right, stifle, but then send back to row, using ref.
|
142
|
+
switch (e.keyCode) {
|
143
|
+
case 37:
|
144
|
+
if (!isFocusEscaped) {
|
145
|
+
if (raRowProps.onKeyDownCapture) {
|
146
|
+
raRowProps.onKeyDownCapture(e);
|
147
|
+
}
|
148
|
+
break;
|
149
|
+
}
|
150
|
+
break;
|
151
|
+
case 39:
|
152
|
+
expandableItemRowRef === null || expandableItemRowRef === void 0 || (_expandableItemRowRef = expandableItemRowRef.current) === null || _expandableItemRowRef === void 0 ? void 0 : _expandableItemRowRef.focus();
|
153
|
+
break;
|
154
|
+
default:
|
155
|
+
break;
|
156
|
+
}
|
157
|
+
};
|
158
|
+
|
159
|
+
// merge props and create status css classes
|
160
|
+
var mergedProps = (0, _reactAria.mergeProps)(raRowProps, focusProps, focusWithinProps);
|
161
|
+
var _useStatusClasses = (0, _.useStatusClasses)(className, {
|
162
|
+
isHovered: isSelectable && item.key === state.hover.hoveredItem,
|
163
|
+
isSelected: isSelected,
|
164
|
+
isFocused: isDisabled ? false : isFocusVisible || isFocusVisibleWithin && !isFocusEscaped && !isFocusVisibleContainer
|
165
|
+
}),
|
166
|
+
classNames = _useStatusClasses.classNames;
|
167
|
+
var _useStatusClasses2 = (0, _.useStatusClasses)('', {
|
168
|
+
isFocused: isFocusVisibleContainer
|
169
|
+
}),
|
170
|
+
focusContainerClassName = _useStatusClasses2.classNames;
|
171
|
+
var _useStatusClasses3 = (0, _.useStatusClasses)('', {
|
172
|
+
hasSeparator: hasSeparator
|
173
|
+
}),
|
174
|
+
rowClassName = _useStatusClasses3.classNames;
|
175
|
+
var expandableRowProps = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
176
|
+
isDisabled: isDisabled,
|
177
|
+
ref: expandableItemRowRef
|
178
|
+
}, mergedProps), rowProps), {}, {
|
179
|
+
onKeyDownCapture: listenOnRowForLeft
|
180
|
+
}, isFocusEscaped && {
|
181
|
+
onKeyDown: onKeyDownEscapeFocusRowOverride
|
182
|
+
}), {}, {
|
183
|
+
sx: {
|
184
|
+
outline: 'none'
|
185
|
+
}
|
186
|
+
}, (isFocusVisibleContainer || isFocusEscaped) && {
|
187
|
+
onKeyDownCapture: function onKeyDownCapture(e) {
|
188
|
+
return expandedChildrenKeyCaptureOverride(e);
|
189
|
+
}
|
190
|
+
}), {}, {
|
191
|
+
className: rowClassName,
|
192
|
+
variant: 'listViewItem.expandableRow'
|
193
|
+
});
|
194
|
+
var cellProps = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, hoverProps), {}, {
|
195
|
+
variant: 'listViewItem.expandableStyledListItem',
|
196
|
+
sx: {
|
197
|
+
minHeight: '75px',
|
198
|
+
py: 'lg',
|
199
|
+
px: 'md'
|
200
|
+
}
|
201
|
+
}, gridCellProps), {}, {
|
202
|
+
isFocused: isDisabled ? false : isFocusVisible,
|
203
|
+
isDisabled: isDisabled,
|
204
|
+
isSelected: isSelected,
|
205
|
+
className: classNames,
|
206
|
+
'data-id': dataId
|
207
|
+
}, listItemProps), {}, {
|
208
|
+
'aria-expanded': isExpanded,
|
209
|
+
'aria-controls': (_expandableChildrenRe3 = expandableChildrenRef.current) === null || _expandableChildrenRe3 === void 0 ? void 0 : _expandableChildrenRe3.id
|
210
|
+
});
|
211
|
+
var expandableContainerProps = {
|
212
|
+
ref: expandableChildrenRef,
|
213
|
+
isFocusEscaped: isFocusEscaped,
|
214
|
+
setIsFocusEscaped: setIsFocusEscaped,
|
215
|
+
className: focusContainerClassName,
|
216
|
+
isFocused: isFocusVisibleContainer,
|
217
|
+
focusProps: containerFocusProps,
|
218
|
+
focusWithinProps: containerWithinFocusProps,
|
219
|
+
isFocusWithin: isFocusWithinVisibleContainer,
|
220
|
+
'data-testid': 'focuscontainer',
|
221
|
+
variant: 'listViewItem.expandableFocusContainer'
|
222
|
+
};
|
223
|
+
var expandableItemState = {
|
224
|
+
isExpanded: isExpanded,
|
225
|
+
isFocusEscaped: isFocusEscaped,
|
226
|
+
toggleExpanded: toggleExpanded,
|
227
|
+
gridCellProps: gridCellProps
|
228
|
+
};
|
229
|
+
return {
|
230
|
+
expandableRowProps: expandableRowProps,
|
231
|
+
cellProps: cellProps,
|
232
|
+
expandableContainerProps: expandableContainerProps,
|
233
|
+
expandableItemState: expandableItemState
|
234
|
+
};
|
235
|
+
};
|
236
|
+
var _default = useExpandableListViewItem;
|
237
|
+
exports["default"] = _default;
|
@@ -3,7 +3,7 @@ import { AriaButtonProps } from 'react-aria';
|
|
3
3
|
import { SelectState } from 'react-stately';
|
4
4
|
import { CollectionChildren } from '@react-types/shared';
|
5
5
|
import { LabelProps as ThemeUILabelProps } from 'theme-ui';
|
6
|
-
import { Axis, BoxProps, FocusableElement, PlacementAxis, ReactRef, StyleProps } from '../../types';
|
6
|
+
import { Axis, BoxProps, FocusableElement, ListBoxProps, PlacementAxis, ReactRef, StyleProps } from '../../types';
|
7
7
|
import { LabelMode } from '../useColumnStyles/useColumnStyles';
|
8
8
|
import { FieldControlInputProps } from '../useField/useField';
|
9
9
|
interface UseSelectFieldProps<T> {
|
@@ -32,7 +32,7 @@ interface UseSelectFieldProps<T> {
|
|
32
32
|
onSelectionChange?: (key: Key) => unknown;
|
33
33
|
controlProps?: React.HTMLAttributes<Element>;
|
34
34
|
scrollBoxProps?: BoxProps;
|
35
|
-
listBoxProps?:
|
35
|
+
listBoxProps?: ListBoxProps;
|
36
36
|
labelProps?: ThemeUILabelProps;
|
37
37
|
containerProps?: BoxProps;
|
38
38
|
labelMode: LabelMode;
|
@@ -190,7 +190,7 @@ var useSelectField = function useSelectField(props, ref) {
|
|
190
190
|
}), (0, _react2.jsx)(_ListBox["default"], (0, _extends2["default"])({
|
191
191
|
ref: listBoxRef,
|
192
192
|
hasNoEmptySelection: true,
|
193
|
-
hasAutoFocus:
|
193
|
+
hasAutoFocus: true,
|
194
194
|
state: state,
|
195
195
|
variant: "listBox.selectField",
|
196
196
|
isLoading: isLoadingMore,
|
package/lib/cjs/types/index.d.ts
CHANGED
package/lib/cjs/types/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _context, _context2, _context3, _context4, _context5, _context6, _context7, _context8, _context9, _context10, _context11, _context12, _context13, _context14, _context15, _context16, _context17, _context18, _context19, _context20, _context21, _context22, _context23, _context24, _context25, _context26, _context27, _context28, _context29, _context30;
|
3
|
+
var _context, _context2, _context3, _context4, _context5, _context6, _context7, _context8, _context9, _context10, _context11, _context12, _context13, _context14, _context15, _context16, _context17, _context18, _context19, _context20, _context21, _context22, _context23, _context24, _context25, _context26, _context27, _context28, _context29, _context30, _context31;
|
4
4
|
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
5
5
|
var _forEachInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
|
6
6
|
var _Object$keys = require("@babel/runtime-corejs3/core-js-stable/object/keys");
|
@@ -172,8 +172,19 @@ _forEachInstanceProperty(_context15 = _Object$keys(_link)).call(_context15, func
|
|
172
172
|
}
|
173
173
|
});
|
174
174
|
});
|
175
|
+
var _listBox = require("./listBox");
|
176
|
+
_forEachInstanceProperty(_context16 = _Object$keys(_listBox)).call(_context16, function (key) {
|
177
|
+
if (key === "default" || key === "__esModule") return;
|
178
|
+
if (key in exports && exports[key] === _listBox[key]) return;
|
179
|
+
_Object$defineProperty(exports, key, {
|
180
|
+
enumerable: true,
|
181
|
+
get: function get() {
|
182
|
+
return _listBox[key];
|
183
|
+
}
|
184
|
+
});
|
185
|
+
});
|
175
186
|
var _listItem = require("./listItem");
|
176
|
-
_forEachInstanceProperty(
|
187
|
+
_forEachInstanceProperty(_context17 = _Object$keys(_listItem)).call(_context17, function (key) {
|
177
188
|
if (key === "default" || key === "__esModule") return;
|
178
189
|
if (key in exports && exports[key] === _listItem[key]) return;
|
179
190
|
_Object$defineProperty(exports, key, {
|
@@ -184,7 +195,7 @@ _forEachInstanceProperty(_context16 = _Object$keys(_listItem)).call(_context16,
|
|
184
195
|
});
|
185
196
|
});
|
186
197
|
var _loader = require("./loader");
|
187
|
-
_forEachInstanceProperty(
|
198
|
+
_forEachInstanceProperty(_context18 = _Object$keys(_loader)).call(_context18, function (key) {
|
188
199
|
if (key === "default" || key === "__esModule") return;
|
189
200
|
if (key in exports && exports[key] === _loader[key]) return;
|
190
201
|
_Object$defineProperty(exports, key, {
|
@@ -195,7 +206,7 @@ _forEachInstanceProperty(_context17 = _Object$keys(_loader)).call(_context17, fu
|
|
195
206
|
});
|
196
207
|
});
|
197
208
|
var _menu = require("./menu");
|
198
|
-
_forEachInstanceProperty(
|
209
|
+
_forEachInstanceProperty(_context19 = _Object$keys(_menu)).call(_context19, function (key) {
|
199
210
|
if (key === "default" || key === "__esModule") return;
|
200
211
|
if (key in exports && exports[key] === _menu[key]) return;
|
201
212
|
_Object$defineProperty(exports, key, {
|
@@ -206,7 +217,7 @@ _forEachInstanceProperty(_context18 = _Object$keys(_menu)).call(_context18, func
|
|
206
217
|
});
|
207
218
|
});
|
208
219
|
var _menuItem = require("./menuItem");
|
209
|
-
_forEachInstanceProperty(
|
220
|
+
_forEachInstanceProperty(_context20 = _Object$keys(_menuItem)).call(_context20, function (key) {
|
210
221
|
if (key === "default" || key === "__esModule") return;
|
211
222
|
if (key in exports && exports[key] === _menuItem[key]) return;
|
212
223
|
_Object$defineProperty(exports, key, {
|
@@ -217,7 +228,7 @@ _forEachInstanceProperty(_context19 = _Object$keys(_menuItem)).call(_context19,
|
|
217
228
|
});
|
218
229
|
});
|
219
230
|
var _overlayPanel = require("./overlayPanel");
|
220
|
-
_forEachInstanceProperty(
|
231
|
+
_forEachInstanceProperty(_context21 = _Object$keys(_overlayPanel)).call(_context21, function (key) {
|
221
232
|
if (key === "default" || key === "__esModule") return;
|
222
233
|
if (key in exports && exports[key] === _overlayPanel[key]) return;
|
223
234
|
_Object$defineProperty(exports, key, {
|
@@ -228,7 +239,7 @@ _forEachInstanceProperty(_context20 = _Object$keys(_overlayPanel)).call(_context
|
|
228
239
|
});
|
229
240
|
});
|
230
241
|
var _popoverContainer = require("./popoverContainer");
|
231
|
-
_forEachInstanceProperty(
|
242
|
+
_forEachInstanceProperty(_context22 = _Object$keys(_popoverContainer)).call(_context22, function (key) {
|
232
243
|
if (key === "default" || key === "__esModule") return;
|
233
244
|
if (key in exports && exports[key] === _popoverContainer[key]) return;
|
234
245
|
_Object$defineProperty(exports, key, {
|
@@ -239,7 +250,7 @@ _forEachInstanceProperty(_context21 = _Object$keys(_popoverContainer)).call(_con
|
|
239
250
|
});
|
240
251
|
});
|
241
252
|
var _popoverMenu = require("./popoverMenu");
|
242
|
-
_forEachInstanceProperty(
|
253
|
+
_forEachInstanceProperty(_context23 = _Object$keys(_popoverMenu)).call(_context23, function (key) {
|
243
254
|
if (key === "default" || key === "__esModule") return;
|
244
255
|
if (key in exports && exports[key] === _popoverMenu[key]) return;
|
245
256
|
_Object$defineProperty(exports, key, {
|
@@ -250,7 +261,7 @@ _forEachInstanceProperty(_context22 = _Object$keys(_popoverMenu)).call(_context2
|
|
250
261
|
});
|
251
262
|
});
|
252
263
|
var _requirementsList = require("./requirementsList");
|
253
|
-
_forEachInstanceProperty(
|
264
|
+
_forEachInstanceProperty(_context24 = _Object$keys(_requirementsList)).call(_context24, function (key) {
|
254
265
|
if (key === "default" || key === "__esModule") return;
|
255
266
|
if (key in exports && exports[key] === _requirementsList[key]) return;
|
256
267
|
_Object$defineProperty(exports, key, {
|
@@ -261,7 +272,7 @@ _forEachInstanceProperty(_context23 = _Object$keys(_requirementsList)).call(_con
|
|
261
272
|
});
|
262
273
|
});
|
263
274
|
var _rockerButtonGroup = require("./rockerButtonGroup");
|
264
|
-
_forEachInstanceProperty(
|
275
|
+
_forEachInstanceProperty(_context25 = _Object$keys(_rockerButtonGroup)).call(_context25, function (key) {
|
265
276
|
if (key === "default" || key === "__esModule") return;
|
266
277
|
if (key in exports && exports[key] === _rockerButtonGroup[key]) return;
|
267
278
|
_Object$defineProperty(exports, key, {
|
@@ -272,7 +283,7 @@ _forEachInstanceProperty(_context24 = _Object$keys(_rockerButtonGroup)).call(_co
|
|
272
283
|
});
|
273
284
|
});
|
274
285
|
var _scrollBox = require("./scrollBox");
|
275
|
-
_forEachInstanceProperty(
|
286
|
+
_forEachInstanceProperty(_context26 = _Object$keys(_scrollBox)).call(_context26, function (key) {
|
276
287
|
if (key === "default" || key === "__esModule") return;
|
277
288
|
if (key in exports && exports[key] === _scrollBox[key]) return;
|
278
289
|
_Object$defineProperty(exports, key, {
|
@@ -283,7 +294,7 @@ _forEachInstanceProperty(_context25 = _Object$keys(_scrollBox)).call(_context25,
|
|
283
294
|
});
|
284
295
|
});
|
285
296
|
var _separator = require("./separator");
|
286
|
-
_forEachInstanceProperty(
|
297
|
+
_forEachInstanceProperty(_context27 = _Object$keys(_separator)).call(_context27, function (key) {
|
287
298
|
if (key === "default" || key === "__esModule") return;
|
288
299
|
if (key in exports && exports[key] === _separator[key]) return;
|
289
300
|
_Object$defineProperty(exports, key, {
|
@@ -294,7 +305,7 @@ _forEachInstanceProperty(_context26 = _Object$keys(_separator)).call(_context26,
|
|
294
305
|
});
|
295
306
|
});
|
296
307
|
var _shared = require("./shared");
|
297
|
-
_forEachInstanceProperty(
|
308
|
+
_forEachInstanceProperty(_context28 = _Object$keys(_shared)).call(_context28, function (key) {
|
298
309
|
if (key === "default" || key === "__esModule") return;
|
299
310
|
if (key in exports && exports[key] === _shared[key]) return;
|
300
311
|
_Object$defineProperty(exports, key, {
|
@@ -305,7 +316,7 @@ _forEachInstanceProperty(_context27 = _Object$keys(_shared)).call(_context27, fu
|
|
305
316
|
});
|
306
317
|
});
|
307
318
|
var _table = require("./table");
|
308
|
-
_forEachInstanceProperty(
|
319
|
+
_forEachInstanceProperty(_context29 = _Object$keys(_table)).call(_context29, function (key) {
|
309
320
|
if (key === "default" || key === "__esModule") return;
|
310
321
|
if (key in exports && exports[key] === _table[key]) return;
|
311
322
|
_Object$defineProperty(exports, key, {
|
@@ -316,7 +327,7 @@ _forEachInstanceProperty(_context28 = _Object$keys(_table)).call(_context28, fun
|
|
316
327
|
});
|
317
328
|
});
|
318
329
|
var _text = require("./text");
|
319
|
-
_forEachInstanceProperty(
|
330
|
+
_forEachInstanceProperty(_context30 = _Object$keys(_text)).call(_context30, function (key) {
|
320
331
|
if (key === "default" || key === "__esModule") return;
|
321
332
|
if (key in exports && exports[key] === _text[key]) return;
|
322
333
|
_Object$defineProperty(exports, key, {
|
@@ -327,7 +338,7 @@ _forEachInstanceProperty(_context29 = _Object$keys(_text)).call(_context29, func
|
|
327
338
|
});
|
328
339
|
});
|
329
340
|
var _tooltipTrigger = require("./tooltipTrigger");
|
330
|
-
_forEachInstanceProperty(
|
341
|
+
_forEachInstanceProperty(_context31 = _Object$keys(_tooltipTrigger)).call(_context31, function (key) {
|
331
342
|
if (key === "default" || key === "__esModule") return;
|
332
343
|
if (key in exports && exports[key] === _tooltipTrigger[key]) return;
|
333
344
|
_Object$defineProperty(exports, key, {
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import { Key, ReactNode } from 'react';
|
2
|
+
import { ComboBoxState, ListState, Node } from 'react-stately';
|
3
|
+
import { AriaListBoxOptions, AriaOptionProps } from '@react-aria/listbox';
|
4
|
+
import { VirtualizerItemOptions } from '@react-aria/virtualizer';
|
5
|
+
import { ReusableView } from '@react-stately/virtualizer';
|
6
|
+
import type { CollectionChildren, FocusStrategy } from '@react-types/shared';
|
7
|
+
import { BoxProps } from './box';
|
8
|
+
export interface ComboBoxStateType extends ComboBoxState<object> {
|
9
|
+
focusStrategy: FocusStrategy;
|
10
|
+
}
|
11
|
+
export interface ListStateType extends ListState<object> {
|
12
|
+
focusStrategy: FocusStrategy;
|
13
|
+
}
|
14
|
+
export type ListBoxStateType = ListStateType | ComboBoxStateType;
|
15
|
+
interface ListBoxItemType extends Node<unknown> {
|
16
|
+
key: Key;
|
17
|
+
}
|
18
|
+
export interface ListBoxProps extends AriaListBoxOptions<object> {
|
19
|
+
hasAutoFocus?: boolean;
|
20
|
+
hasFocusWrap?: boolean;
|
21
|
+
hasNoEmptySelection?: boolean;
|
22
|
+
hasVirtualFocus?: boolean;
|
23
|
+
isLoading?: boolean;
|
24
|
+
isFocusedOnHover?: boolean;
|
25
|
+
isSelectedOnPressUp?: boolean;
|
26
|
+
onLoadMore?: () => void;
|
27
|
+
onScroll?: () => void;
|
28
|
+
state: ListBoxStateType;
|
29
|
+
renderEmptyState?: React.ReactNode;
|
30
|
+
variant?: string;
|
31
|
+
children?: CollectionChildren<object>;
|
32
|
+
}
|
33
|
+
export interface OptionType {
|
34
|
+
item: ListBoxItemType;
|
35
|
+
hasVirtualFocus?: boolean;
|
36
|
+
}
|
37
|
+
export interface AriaListBoxOptionsType extends AriaOptionProps {
|
38
|
+
onPressStart: () => void;
|
39
|
+
onPressUp: () => void;
|
40
|
+
}
|
41
|
+
export interface ListBoxSectionProps extends Omit<VirtualizerItemOptions<object, object>, 'ref'> {
|
42
|
+
children?: ReactNode;
|
43
|
+
header: ReusableView<object, ReactNode>;
|
44
|
+
}
|
45
|
+
export interface UseListBoxSectionProps {
|
46
|
+
headingProps: BoxProps;
|
47
|
+
groupProps: BoxProps;
|
48
|
+
}
|
49
|
+
export {};
|
@@ -13,16 +13,15 @@ import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instanc
|
|
13
13
|
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
14
14
|
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; }
|
15
15
|
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; }
|
16
|
-
import React, { forwardRef, useImperativeHandle, useMemo
|
16
|
+
import React, { forwardRef, useImperativeHandle, useMemo } from 'react';
|
17
17
|
import { mergeProps } from 'react-aria';
|
18
18
|
import { useCollator } from '@react-aria/i18n';
|
19
19
|
import { useListBox } from '@react-aria/listbox';
|
20
20
|
import { Virtualizer, VirtualizerItem } from '@react-aria/virtualizer';
|
21
21
|
import { ListLayout } from '@react-stately/layout';
|
22
|
-
import
|
23
|
-
import { isIterableProp } from '../../utils/devUtils/props/isIterable';
|
22
|
+
import { useLocalOrForwardRef } from '../../hooks';
|
24
23
|
import Loader from '../Loader';
|
25
|
-
import { Option } from './index
|
24
|
+
import { Option } from './index';
|
26
25
|
import { ListBoxContext } from './ListBoxContext';
|
27
26
|
import ListBoxSection from './ListBoxSection';
|
28
27
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
@@ -78,10 +77,10 @@ var ListBox = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
78
77
|
ariaDescribedby = props['aria-describedby'],
|
79
78
|
ariaDetails = props['aria-details'],
|
80
79
|
others = _objectWithoutProperties(props, _excluded);
|
81
|
-
|
80
|
+
|
82
81
|
// Object matching React Aria API with all options
|
83
82
|
var listBoxOptions = {
|
84
|
-
autoFocus: hasAutoFocus
|
83
|
+
autoFocus: hasAutoFocus,
|
85
84
|
defaultSelectedKeys: defaultSelectedKeys,
|
86
85
|
disabledKeys: disabledKeys,
|
87
86
|
disallowEmptySelection: hasNoEmptySelection,
|
@@ -106,13 +105,13 @@ var ListBox = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
106
105
|
'aria-describedby': ariaDescribedby,
|
107
106
|
'aria-details': ariaDetails
|
108
107
|
};
|
109
|
-
var listBoxRef =
|
108
|
+
var listBoxRef = useLocalOrForwardRef(null);
|
110
109
|
/* istanbul ignore next */
|
111
110
|
useImperativeHandle(ref, function () {
|
112
111
|
return listBoxRef.current;
|
113
112
|
});
|
114
113
|
var layout = useListBoxLayout(state);
|
115
|
-
layout.isLoading = props.isLoading;
|
114
|
+
layout.isLoading = props.isLoading ? props.isLoading : false;
|
116
115
|
|
117
116
|
// Get props for the listbox
|
118
117
|
var _useListBox = useListBox(_objectSpread(_objectSpread({}, listBoxOptions), {}, {
|
@@ -141,6 +140,7 @@ var ListBox = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
141
140
|
return ___EmotionJSX(ListBoxContext.Provider, {
|
142
141
|
value: state
|
143
142
|
}, ___EmotionJSX(Virtualizer, _extends({}, mergeProps(listBoxProps, others), {
|
143
|
+
autoFocus: hasAutoFocus,
|
144
144
|
style: {
|
145
145
|
outline: 'none'
|
146
146
|
},
|
@@ -174,42 +174,4 @@ var ListBox = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
174
174
|
return null;
|
175
175
|
}));
|
176
176
|
});
|
177
|
-
ListBox.propTypes = {
|
178
|
-
defaultSelectedKeys: isIterableProp,
|
179
|
-
disabledKeys: isIterableProp,
|
180
|
-
hasAutoFocus: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
|
181
|
-
hasFocusWrap: PropTypes.bool,
|
182
|
-
hasNoEmptySelection: PropTypes.bool,
|
183
|
-
hasVirtualFocus: PropTypes.bool,
|
184
|
-
id: PropTypes.string,
|
185
|
-
isFocusedOnHover: PropTypes.bool,
|
186
|
-
isLoading: PropTypes.bool,
|
187
|
-
isSelectedOnPressUp: PropTypes.bool,
|
188
|
-
isVirtualized: PropTypes.bool,
|
189
|
-
items: isIterableProp,
|
190
|
-
keyboardDelegate: PropTypes.shape({}),
|
191
|
-
label: PropTypes.node,
|
192
|
-
onLoadMore: PropTypes.func,
|
193
|
-
onScroll: PropTypes.func,
|
194
|
-
onSelectionChange: PropTypes.func,
|
195
|
-
renderEmptyState: PropTypes.node,
|
196
|
-
selectedKeys: isIterableProp,
|
197
|
-
selectionMode: PropTypes.oneOf(['none', 'single', 'multiple']),
|
198
|
-
'aria-label': PropTypes.string,
|
199
|
-
'aria-labelledby': PropTypes.string,
|
200
|
-
'aria-describedby': PropTypes.string,
|
201
|
-
'aria-details': PropTypes.string,
|
202
|
-
state: PropTypes.shape({
|
203
|
-
close: PropTypes.func,
|
204
|
-
collection: PropTypes.shape({}),
|
205
|
-
focusStrategy: PropTypes.string,
|
206
|
-
isOpen: PropTypes.bool,
|
207
|
-
selectionManager: PropTypes.shape({
|
208
|
-
focusedKey: PropTypes.string
|
209
|
-
})
|
210
|
-
})
|
211
|
-
};
|
212
|
-
ListBox.defaultProps = {
|
213
|
-
state: {}
|
214
|
-
};
|
215
177
|
export default ListBox;
|