@pingux/astro 1.32.0 → 1.32.1-alpha.4
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/ComboBoxField/ComboBoxField.js +15 -13
- package/lib/cjs/components/ListView/ListView.js +12 -1
- package/lib/cjs/components/ListView/ListView.test.js +31 -0
- package/lib/cjs/recipes/LogoTabs.stories.js +3 -0
- package/lib/cjs/styles/variants/stepper.js +1 -1
- package/lib/components/ComboBoxField/ComboBoxField.js +15 -13
- package/lib/components/ListView/ListView.js +12 -1
- package/lib/components/ListView/ListView.test.js +27 -0
- package/lib/recipes/LogoTabs.stories.js +3 -0
- package/lib/styles/variants/stepper.js +1 -1
- package/package.json +1 -1
- package/NOTICE.html +0 -4665
@@ -34,6 +34,8 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/e
|
|
34
34
|
|
35
35
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
|
36
36
|
|
37
|
+
var _from = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/from"));
|
38
|
+
|
37
39
|
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
38
40
|
|
39
41
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
@@ -142,18 +144,6 @@ var ComboBoxField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
142
144
|
(0, _react.useImperativeHandle)(ref, function () {
|
143
145
|
return inputRef.current;
|
144
146
|
});
|
145
|
-
/* istanbul ignore next */
|
146
|
-
|
147
|
-
var onSelectionChangeHandler = function onSelectionChangeHandler(key) {
|
148
|
-
var newVal = key || selectedKey || '';
|
149
|
-
|
150
|
-
if (hasAddOption && selectedKey !== inputValue) {
|
151
|
-
newVal = inputValue;
|
152
|
-
}
|
153
|
-
|
154
|
-
if (onSelectionChange) onSelectionChange(newVal);
|
155
|
-
};
|
156
|
-
|
157
147
|
var shouldShowAddOption = hasAddOption && inputValue && selectedKey !== inputValue;
|
158
148
|
var addOption = "ADD: ".concat(inputValue);
|
159
149
|
|
@@ -172,6 +162,18 @@ var ComboBoxField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
172
162
|
|
173
163
|
var defaultItems = getItemsArr(initialDefaultItems);
|
174
164
|
var items = getItemsArr(initialItems);
|
165
|
+
/* istanbul ignore next */
|
166
|
+
|
167
|
+
var onSelectionChangeHandler = function onSelectionChangeHandler(key) {
|
168
|
+
var newVal = key || selectedKey || '';
|
169
|
+
var arrayOfValues = (0, _from["default"])(items || defaultItems);
|
170
|
+
|
171
|
+
if (hasAddOption && selectedKey !== inputValue && arrayOfValues[arrayOfValues.length - 1].key === key) {
|
172
|
+
newVal = inputValue;
|
173
|
+
}
|
174
|
+
|
175
|
+
if (onSelectionChange) onSelectionChange(newVal);
|
176
|
+
};
|
175
177
|
|
176
178
|
var _useFilter = (0, _i18n.useFilter)({
|
177
179
|
sensitivity: 'base'
|
@@ -186,7 +188,7 @@ var ComboBoxField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
186
188
|
}));
|
187
189
|
(0, _react.useEffect)(function () {
|
188
190
|
if (shouldShowAddOption) state.selectionManager.setFocusedKey(addOption);
|
189
|
-
}, [shouldShowAddOption,
|
191
|
+
}, [shouldShowAddOption, inputValue, addOption, state.isOpen]);
|
190
192
|
|
191
193
|
var _useComboBox = (0, _combobox.useComboBox)(_objectSpread(_objectSpread({}, comboBoxOptions), {}, {
|
192
194
|
buttonRef: buttonRef,
|
@@ -158,6 +158,15 @@ var ListView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
158
158
|
layout.isLoading = isLoading;
|
159
159
|
var focusedKey = selectionManager.focusedKey;
|
160
160
|
delete gridProps.onMouseDown;
|
161
|
+
|
162
|
+
var onFocus = function onFocus(e) {
|
163
|
+
gridProps.onFocus(e);
|
164
|
+
|
165
|
+
if (others.onFocus) {
|
166
|
+
others.onFocus(e);
|
167
|
+
}
|
168
|
+
};
|
169
|
+
|
161
170
|
return (0, _react2.jsx)(_ListViewContext.ListViewContext.Provider, {
|
162
171
|
value: {
|
163
172
|
state: state
|
@@ -173,7 +182,9 @@ var ListView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
173
182
|
isLoading: isLoading,
|
174
183
|
collection: collection,
|
175
184
|
transitionDuration: 0
|
176
|
-
}, others
|
185
|
+
}, others, {
|
186
|
+
onFocus: onFocus
|
187
|
+
}), function (type, item) {
|
177
188
|
if (type === 'item') {
|
178
189
|
return (0, _react2.jsx)(_ListViewItem["default"], {
|
179
190
|
item: item
|
@@ -323,4 +323,35 @@ test('selectionMode "multiple" allows to select more than one item', /*#__PURE__
|
|
323
323
|
}
|
324
324
|
}
|
325
325
|
}, _callee6);
|
326
|
+
})));
|
327
|
+
test('when user navigates with tab and arrows keys, onFocus is called and the is-focused class is applied', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7() {
|
328
|
+
var onFocus, listView, options;
|
329
|
+
return _regenerator["default"].wrap(function _callee7$(_context7) {
|
330
|
+
while (1) {
|
331
|
+
switch (_context7.prev = _context7.next) {
|
332
|
+
case 0:
|
333
|
+
onFocus = jest.fn();
|
334
|
+
getComponent({
|
335
|
+
onFocus: onFocus
|
336
|
+
});
|
337
|
+
listView = _testWrapper.screen.getByTestId(testId);
|
338
|
+
|
339
|
+
_userEvent["default"].tab();
|
340
|
+
|
341
|
+
expect(onFocus).toHaveBeenCalled();
|
342
|
+
|
343
|
+
_userEvent["default"].type(listView, '{arrowdown}', {
|
344
|
+
skipClick: true
|
345
|
+
});
|
346
|
+
|
347
|
+
options = _testWrapper.screen.getAllByRole('gridcell');
|
348
|
+
expect(options[1]).toHaveClass('is-focused');
|
349
|
+
expect(onFocus).toHaveBeenCalled();
|
350
|
+
|
351
|
+
case 9:
|
352
|
+
case "end":
|
353
|
+
return _context7.stop();
|
354
|
+
}
|
355
|
+
}
|
356
|
+
}, _callee7);
|
326
357
|
})));
|
@@ -9,6 +9,7 @@ import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
9
9
|
import _Object$values from "@babel/runtime-corejs3/core-js-stable/object/values";
|
10
10
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
11
11
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
12
|
+
import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
|
12
13
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
13
14
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
14
15
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
@@ -94,18 +95,6 @@ var ComboBoxField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
94
95
|
useImperativeHandle(ref, function () {
|
95
96
|
return inputRef.current;
|
96
97
|
});
|
97
|
-
/* istanbul ignore next */
|
98
|
-
|
99
|
-
var onSelectionChangeHandler = function onSelectionChangeHandler(key) {
|
100
|
-
var newVal = key || selectedKey || '';
|
101
|
-
|
102
|
-
if (hasAddOption && selectedKey !== inputValue) {
|
103
|
-
newVal = inputValue;
|
104
|
-
}
|
105
|
-
|
106
|
-
if (onSelectionChange) onSelectionChange(newVal);
|
107
|
-
};
|
108
|
-
|
109
98
|
var shouldShowAddOption = hasAddOption && inputValue && selectedKey !== inputValue;
|
110
99
|
var addOption = "ADD: ".concat(inputValue);
|
111
100
|
|
@@ -124,6 +113,19 @@ var ComboBoxField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
124
113
|
|
125
114
|
var defaultItems = getItemsArr(initialDefaultItems);
|
126
115
|
var items = getItemsArr(initialItems);
|
116
|
+
/* istanbul ignore next */
|
117
|
+
|
118
|
+
var onSelectionChangeHandler = function onSelectionChangeHandler(key) {
|
119
|
+
var newVal = key || selectedKey || '';
|
120
|
+
|
121
|
+
var arrayOfValues = _Array$from(items || defaultItems);
|
122
|
+
|
123
|
+
if (hasAddOption && selectedKey !== inputValue && arrayOfValues[arrayOfValues.length - 1].key === key) {
|
124
|
+
newVal = inputValue;
|
125
|
+
}
|
126
|
+
|
127
|
+
if (onSelectionChange) onSelectionChange(newVal);
|
128
|
+
};
|
127
129
|
|
128
130
|
var _useFilter = useFilter({
|
129
131
|
sensitivity: 'base'
|
@@ -138,7 +140,7 @@ var ComboBoxField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
138
140
|
}));
|
139
141
|
useEffect(function () {
|
140
142
|
if (shouldShowAddOption) state.selectionManager.setFocusedKey(addOption);
|
141
|
-
}, [shouldShowAddOption,
|
143
|
+
}, [shouldShowAddOption, inputValue, addOption, state.isOpen]);
|
142
144
|
|
143
145
|
var _useComboBox = useComboBox(_objectSpread(_objectSpread({}, comboBoxOptions), {}, {
|
144
146
|
buttonRef: buttonRef,
|
@@ -112,6 +112,15 @@ var ListView = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
112
112
|
layout.isLoading = isLoading;
|
113
113
|
var focusedKey = selectionManager.focusedKey;
|
114
114
|
delete gridProps.onMouseDown;
|
115
|
+
|
116
|
+
var onFocus = function onFocus(e) {
|
117
|
+
gridProps.onFocus(e);
|
118
|
+
|
119
|
+
if (others.onFocus) {
|
120
|
+
others.onFocus(e);
|
121
|
+
}
|
122
|
+
};
|
123
|
+
|
115
124
|
return ___EmotionJSX(ListViewContext.Provider, {
|
116
125
|
value: {
|
117
126
|
state: state
|
@@ -127,7 +136,9 @@ var ListView = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
127
136
|
isLoading: isLoading,
|
128
137
|
collection: collection,
|
129
138
|
transitionDuration: 0
|
130
|
-
}, others
|
139
|
+
}, others, {
|
140
|
+
onFocus: onFocus
|
141
|
+
}), function (type, item) {
|
131
142
|
if (type === 'item') {
|
132
143
|
return ___EmotionJSX(ListViewItem, {
|
133
144
|
item: item
|
@@ -282,4 +282,31 @@ test('selectionMode "multiple" allows to select more than one item', /*#__PURE__
|
|
282
282
|
}
|
283
283
|
}
|
284
284
|
}, _callee6);
|
285
|
+
})));
|
286
|
+
test('when user navigates with tab and arrows keys, onFocus is called and the is-focused class is applied', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
|
287
|
+
var onFocus, listView, options;
|
288
|
+
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
289
|
+
while (1) {
|
290
|
+
switch (_context7.prev = _context7.next) {
|
291
|
+
case 0:
|
292
|
+
onFocus = jest.fn();
|
293
|
+
getComponent({
|
294
|
+
onFocus: onFocus
|
295
|
+
});
|
296
|
+
listView = screen.getByTestId(testId);
|
297
|
+
userEvent.tab();
|
298
|
+
expect(onFocus).toHaveBeenCalled();
|
299
|
+
userEvent.type(listView, '{arrowdown}', {
|
300
|
+
skipClick: true
|
301
|
+
});
|
302
|
+
options = screen.getAllByRole('gridcell');
|
303
|
+
expect(options[1]).toHaveClass('is-focused');
|
304
|
+
expect(onFocus).toHaveBeenCalled();
|
305
|
+
|
306
|
+
case 9:
|
307
|
+
case "end":
|
308
|
+
return _context7.stop();
|
309
|
+
}
|
310
|
+
}
|
311
|
+
}, _callee7);
|
285
312
|
})));
|