@pingux/astro 2.139.0-alpha.1 → 2.139.0-alpha.3
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/DataTable/DataTable.js +9 -12
- package/lib/cjs/components/MultivaluesField/CondensedMultivaluesField.js +19 -12
- package/lib/cjs/components/MultivaluesField/MultivaluesField.test.js +16 -0
- package/lib/components/DataTable/DataTable.js +9 -12
- package/lib/components/MultivaluesField/CondensedMultivaluesField.js +19 -12
- package/lib/components/MultivaluesField/MultivaluesField.test.js +16 -0
- package/package.json +1 -1
@@ -352,20 +352,15 @@ var TableRow = function TableRow(_ref4) {
|
|
352
352
|
var isSelectable = state.selectionManager.selectionMode !== 'none';
|
353
353
|
var isSelected = state.selectionManager.isSelected(item.key);
|
354
354
|
var isDisabled = state.disabledKeys.has(item.key);
|
355
|
-
var _useFocusRing2 = (0, _reactAria.useFocusRing)(
|
356
|
-
|
357
|
-
|
358
|
-
isFocusVisibleWithin = _useFocusRing2.isFocusVisible,
|
359
|
-
focusWithinProps = _useFocusRing2.focusProps;
|
360
|
-
var _useFocusRing3 = (0, _reactAria.useFocusRing)(),
|
361
|
-
isFocusVisible = _useFocusRing3.isFocusVisible,
|
362
|
-
focusProps = _useFocusRing3.focusProps;
|
355
|
+
var _useFocusRing2 = (0, _reactAria.useFocusRing)(),
|
356
|
+
isFocusVisible = _useFocusRing2.isFocusVisible,
|
357
|
+
focusProps = _useFocusRing2.focusProps;
|
363
358
|
var _useHover = (0, _interactions.useHover)({}),
|
364
359
|
hoverProps = _useHover.hoverProps,
|
365
360
|
isHovered = _useHover.isHovered;
|
366
|
-
var props = (0, _reactAria.mergeProps)(otherProps,
|
361
|
+
var props = (0, _reactAria.mergeProps)(otherProps, focusProps, rowProps, hoverProps);
|
367
362
|
var _useStatusClasses3 = (0, _hooks.useStatusClasses)('', {
|
368
|
-
'is-row-focus-visible': isFocusVisible
|
363
|
+
'is-row-focus-visible': isFocusVisible,
|
369
364
|
isSelectable: isSelectable,
|
370
365
|
isSelected: isSelected,
|
371
366
|
isHovered: isHovered,
|
@@ -373,11 +368,13 @@ var TableRow = function TableRow(_ref4) {
|
|
373
368
|
}),
|
374
369
|
classNames = _useStatusClasses3.classNames;
|
375
370
|
var variant = isSelectable ? 'dataTable.selectableTableRow' : 'dataTable.tableRow';
|
376
|
-
return (0, _react2.jsx)(
|
371
|
+
return (0, _react2.jsx)(_reactAria.FocusRing, {
|
372
|
+
focusRingClass: "is-row-focus-visible"
|
373
|
+
}, (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({}, props, {
|
377
374
|
ref: ref,
|
378
375
|
variant: variant,
|
379
376
|
className: classNames
|
380
|
-
}), children);
|
377
|
+
}), children));
|
381
378
|
};
|
382
379
|
var TableHeaderRow = function TableHeaderRow(_ref5) {
|
383
380
|
var item = _ref5.item,
|
@@ -101,10 +101,14 @@ var CondensedMultivaluesField = /*#__PURE__*/(0, _react.forwardRef)(function (pr
|
|
101
101
|
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
102
102
|
hasFocusWithin = _useState6[0],
|
103
103
|
setFocusWithin = _useState6[1];
|
104
|
-
var _useState7 = (0, _react.useState)(
|
104
|
+
var _useState7 = (0, _react.useState)([]),
|
105
105
|
_useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
|
106
|
-
|
107
|
-
|
106
|
+
initialItems = _useState8[0],
|
107
|
+
setInitialItems = _useState8[1];
|
108
|
+
var _useState9 = (0, _react.useState)(''),
|
109
|
+
_useState10 = (0, _slicedToArray2["default"])(_useState9, 2),
|
110
|
+
activeDescendant = _useState10[0],
|
111
|
+
setActiveDescendant = _useState10[1];
|
108
112
|
var inputWrapperRef = (0, _react.useRef)();
|
109
113
|
var inputRef = (0, _react.useRef)();
|
110
114
|
var buttonRef = (0, _react.useRef)();
|
@@ -117,6 +121,9 @@ var CondensedMultivaluesField = /*#__PURE__*/(0, _react.forwardRef)(function (pr
|
|
117
121
|
inputValue: filterString
|
118
122
|
}),
|
119
123
|
showLoading = _useInputLoader.showLoading;
|
124
|
+
(0, _react.useEffect)(function () {
|
125
|
+
setInitialItems((0, _from["default"])(items));
|
126
|
+
}, []);
|
120
127
|
var toggleItems = function toggleItems(keys) {
|
121
128
|
if (onSelectionChange) onSelectionChange(keys);
|
122
129
|
};
|
@@ -195,10 +202,10 @@ var CondensedMultivaluesField = /*#__PURE__*/(0, _react.forwardRef)(function (pr
|
|
195
202
|
}, [isOpen, selectionManager.selectedKeys, updatePosition]);
|
196
203
|
|
197
204
|
// Measure the width of the input to inform the width of the menu (below).
|
198
|
-
var
|
199
|
-
|
200
|
-
menuWidth =
|
201
|
-
setMenuWidth =
|
205
|
+
var _useState11 = (0, _react.useState)(null),
|
206
|
+
_useState12 = (0, _slicedToArray2["default"])(_useState11, 2),
|
207
|
+
menuWidth = _useState12[0],
|
208
|
+
setMenuWidth = _useState12[1];
|
202
209
|
var onResize = (0, _react.useCallback)(function () {
|
203
210
|
/* istanbul ignore next */
|
204
211
|
if (inputWrapperRef.current) {
|
@@ -271,12 +278,12 @@ var CondensedMultivaluesField = /*#__PURE__*/(0, _react.forwardRef)(function (pr
|
|
271
278
|
setFilterString('');
|
272
279
|
setIsOpen(false);
|
273
280
|
};
|
274
|
-
var
|
275
|
-
|
276
|
-
selectionState =
|
277
|
-
setSelectionState =
|
281
|
+
var _useState13 = (0, _react.useState)('Select All'),
|
282
|
+
_useState14 = (0, _slicedToArray2["default"])(_useState13, 2),
|
283
|
+
selectionState = _useState14[0],
|
284
|
+
setSelectionState = _useState14[1];
|
278
285
|
var arrayItems = (0, _from["default"])(items);
|
279
|
-
var itemCount = (0, _reduce["default"])(
|
286
|
+
var itemCount = (0, _reduce["default"])(initialItems).call(initialItems, function (count, obj) {
|
280
287
|
return count + (obj.children ? obj.children.length : 1);
|
281
288
|
}, 0);
|
282
289
|
var selectedKeysSize = selectionManager.selectedKeys.size;
|
@@ -1113,6 +1113,22 @@ test('default selected keys in condensed mode ', function () {
|
|
1113
1113
|
expect(listbox).not.toBeInTheDocument();
|
1114
1114
|
expect(_testWrapper.screen.getByText('2 Selected')).toBeInTheDocument();
|
1115
1115
|
});
|
1116
|
+
test('when filtered to one item in condensed mode, it still shows the correct amount of selected items ', function () {
|
1117
|
+
var onInputChange = jest.fn();
|
1118
|
+
getComponent({
|
1119
|
+
mode: 'condensed',
|
1120
|
+
defaultSelectedKeys: [items[1].key, items[2].key],
|
1121
|
+
onInputChange: onInputChange
|
1122
|
+
});
|
1123
|
+
var input = _testWrapper.screen.getByRole('combobox');
|
1124
|
+
var value = 'Aardvark';
|
1125
|
+
_userEvent["default"].type(input, value);
|
1126
|
+
var listbox = _testWrapper.screen.getByRole('listbox');
|
1127
|
+
expect(listbox).toBeInTheDocument();
|
1128
|
+
var options = (0, _testWrapper.within)(listbox).getAllByRole('option');
|
1129
|
+
expect(options.length).toBe(1);
|
1130
|
+
expect(_testWrapper.screen.getByText('2 Selected')).toBeInTheDocument();
|
1131
|
+
});
|
1116
1132
|
test('onInputChange is called in condensed mode ', function () {
|
1117
1133
|
var onInputChange = jest.fn();
|
1118
1134
|
getComponent({
|
@@ -341,20 +341,15 @@ var TableRow = function TableRow(_ref4) {
|
|
341
341
|
var isSelectable = state.selectionManager.selectionMode !== 'none';
|
342
342
|
var isSelected = state.selectionManager.isSelected(item.key);
|
343
343
|
var isDisabled = state.disabledKeys.has(item.key);
|
344
|
-
var _useFocusRing2 = useFocusRing(
|
345
|
-
|
346
|
-
|
347
|
-
isFocusVisibleWithin = _useFocusRing2.isFocusVisible,
|
348
|
-
focusWithinProps = _useFocusRing2.focusProps;
|
349
|
-
var _useFocusRing3 = useFocusRing(),
|
350
|
-
isFocusVisible = _useFocusRing3.isFocusVisible,
|
351
|
-
focusProps = _useFocusRing3.focusProps;
|
344
|
+
var _useFocusRing2 = useFocusRing(),
|
345
|
+
isFocusVisible = _useFocusRing2.isFocusVisible,
|
346
|
+
focusProps = _useFocusRing2.focusProps;
|
352
347
|
var _useHover = useHover({}),
|
353
348
|
hoverProps = _useHover.hoverProps,
|
354
349
|
isHovered = _useHover.isHovered;
|
355
|
-
var props = mergeProps(otherProps,
|
350
|
+
var props = mergeProps(otherProps, focusProps, rowProps, hoverProps);
|
356
351
|
var _useStatusClasses3 = useStatusClasses('', {
|
357
|
-
'is-row-focus-visible': isFocusVisible
|
352
|
+
'is-row-focus-visible': isFocusVisible,
|
358
353
|
isSelectable: isSelectable,
|
359
354
|
isSelected: isSelected,
|
360
355
|
isHovered: isHovered,
|
@@ -362,11 +357,13 @@ var TableRow = function TableRow(_ref4) {
|
|
362
357
|
}),
|
363
358
|
classNames = _useStatusClasses3.classNames;
|
364
359
|
var variant = isSelectable ? 'dataTable.selectableTableRow' : 'dataTable.tableRow';
|
365
|
-
return ___EmotionJSX(
|
360
|
+
return ___EmotionJSX(FocusRing, {
|
361
|
+
focusRingClass: "is-row-focus-visible"
|
362
|
+
}, ___EmotionJSX(Box, _extends({}, props, {
|
366
363
|
ref: ref,
|
367
364
|
variant: variant,
|
368
365
|
className: classNames
|
369
|
-
}), children);
|
366
|
+
}), children));
|
370
367
|
};
|
371
368
|
var TableHeaderRow = function TableHeaderRow(_ref5) {
|
372
369
|
var item = _ref5.item,
|
@@ -89,10 +89,14 @@ var CondensedMultivaluesField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
89
89
|
_useState6 = _slicedToArray(_useState5, 2),
|
90
90
|
hasFocusWithin = _useState6[0],
|
91
91
|
setFocusWithin = _useState6[1];
|
92
|
-
var _useState7 = useState(
|
92
|
+
var _useState7 = useState([]),
|
93
93
|
_useState8 = _slicedToArray(_useState7, 2),
|
94
|
-
|
95
|
-
|
94
|
+
initialItems = _useState8[0],
|
95
|
+
setInitialItems = _useState8[1];
|
96
|
+
var _useState9 = useState(''),
|
97
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
98
|
+
activeDescendant = _useState10[0],
|
99
|
+
setActiveDescendant = _useState10[1];
|
96
100
|
var inputWrapperRef = useRef();
|
97
101
|
var inputRef = useRef();
|
98
102
|
var buttonRef = useRef();
|
@@ -105,6 +109,9 @@ var CondensedMultivaluesField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
105
109
|
inputValue: filterString
|
106
110
|
}),
|
107
111
|
showLoading = _useInputLoader.showLoading;
|
112
|
+
useEffect(function () {
|
113
|
+
setInitialItems(_Array$from(items));
|
114
|
+
}, []);
|
108
115
|
var toggleItems = function toggleItems(keys) {
|
109
116
|
if (onSelectionChange) onSelectionChange(keys);
|
110
117
|
};
|
@@ -183,10 +190,10 @@ var CondensedMultivaluesField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
183
190
|
}, [isOpen, selectionManager.selectedKeys, updatePosition]);
|
184
191
|
|
185
192
|
// Measure the width of the input to inform the width of the menu (below).
|
186
|
-
var
|
187
|
-
|
188
|
-
menuWidth =
|
189
|
-
setMenuWidth =
|
193
|
+
var _useState11 = useState(null),
|
194
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
195
|
+
menuWidth = _useState12[0],
|
196
|
+
setMenuWidth = _useState12[1];
|
190
197
|
var onResize = useCallback(function () {
|
191
198
|
/* istanbul ignore next */
|
192
199
|
if (inputWrapperRef.current) {
|
@@ -259,12 +266,12 @@ var CondensedMultivaluesField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
259
266
|
setFilterString('');
|
260
267
|
setIsOpen(false);
|
261
268
|
};
|
262
|
-
var
|
263
|
-
|
264
|
-
selectionState =
|
265
|
-
setSelectionState =
|
269
|
+
var _useState13 = useState('Select All'),
|
270
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
271
|
+
selectionState = _useState14[0],
|
272
|
+
setSelectionState = _useState14[1];
|
266
273
|
var arrayItems = _Array$from(items);
|
267
|
-
var itemCount = _reduceInstanceProperty(
|
274
|
+
var itemCount = _reduceInstanceProperty(initialItems).call(initialItems, function (count, obj) {
|
268
275
|
return count + (obj.children ? obj.children.length : 1);
|
269
276
|
}, 0);
|
270
277
|
var selectedKeysSize = selectionManager.selectedKeys.size;
|
@@ -1106,6 +1106,22 @@ test('default selected keys in condensed mode ', function () {
|
|
1106
1106
|
expect(listbox).not.toBeInTheDocument();
|
1107
1107
|
expect(screen.getByText('2 Selected')).toBeInTheDocument();
|
1108
1108
|
});
|
1109
|
+
test('when filtered to one item in condensed mode, it still shows the correct amount of selected items ', function () {
|
1110
|
+
var onInputChange = jest.fn();
|
1111
|
+
getComponent({
|
1112
|
+
mode: 'condensed',
|
1113
|
+
defaultSelectedKeys: [items[1].key, items[2].key],
|
1114
|
+
onInputChange: onInputChange
|
1115
|
+
});
|
1116
|
+
var input = screen.getByRole('combobox');
|
1117
|
+
var value = 'Aardvark';
|
1118
|
+
userEvent.type(input, value);
|
1119
|
+
var listbox = screen.getByRole('listbox');
|
1120
|
+
expect(listbox).toBeInTheDocument();
|
1121
|
+
var options = within(listbox).getAllByRole('option');
|
1122
|
+
expect(options.length).toBe(1);
|
1123
|
+
expect(screen.getByText('2 Selected')).toBeInTheDocument();
|
1124
|
+
});
|
1109
1125
|
test('onInputChange is called in condensed mode ', function () {
|
1110
1126
|
var onInputChange = jest.fn();
|
1111
1127
|
getComponent({
|