@pingux/astro 2.121.0 → 2.121.1-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/MultivaluesField/CondensedMultivaluesField.js +8 -5
- package/lib/cjs/components/MultivaluesField/MultivaluesField.stories.js +57 -18
- package/lib/cjs/components/MultivaluesField/MultivaluesField.test.js +19 -2
- package/lib/components/MultivaluesField/CondensedMultivaluesField.js +8 -5
- package/lib/components/MultivaluesField/MultivaluesField.stories.js +55 -17
- package/lib/components/MultivaluesField/MultivaluesField.test.js +19 -2
- package/package.json +1 -1
@@ -44,13 +44,13 @@ var _fieldAttributes = require("../../utils/docUtils/fieldAttributes");
|
|
44
44
|
var _statusProp = require("../../utils/docUtils/statusProp");
|
45
45
|
var _ListBox = _interopRequireDefault(require("../ListBox"));
|
46
46
|
var _react2 = require("@emotion/react");
|
47
|
-
var _excluded = ["defaultSelectedKeys", "direction", "disabledKeys", "containerProps", "hasAutoFocus", "hasNoSelectAll", "hasNoStatusIndicator", "helperText", "inputProps", "isDisabled", "isNotFlippable", "isReadOnly", "isRequired", "items", "label", "mode", "onBlur", "onFocus", "onInputChange", "onKeyDown", "onKeyUp", "onOpenChange", "onSelectionChange", "placeholder", "selectedKeys", "scrollBoxProps", "status"];
|
47
|
+
var _excluded = ["defaultSelectedKeys", "direction", "disabledKeys", "containerProps", "hasAutoFocus", "hasNoSelectAll", "hasNoStatusIndicator", "helperText", "inputProps", "isDisabled", "isNotFlippable", "isReadOnly", "isRequired", "items", "label", "mode", "onBlur", "onFocus", "onInputChange", "onKeyDown", "onKeyUp", "onOpenChange", "onSelectionChange", "placeholder", "selectedKeys", "selectedOptionText", "scrollBoxProps", "status"];
|
48
48
|
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
49
49
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
50
50
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty2(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
51
51
|
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; }
|
52
52
|
var CondensedMultivaluesField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
53
|
-
var _selectionManager$sta, _selectionManager$sta2,
|
53
|
+
var _selectionManager$sta, _selectionManager$sta2, _selectionManager$sta3, _listBoxRef$current;
|
54
54
|
var defaultSelectedKeys = props.defaultSelectedKeys,
|
55
55
|
direction = props.direction,
|
56
56
|
_props$disabledKeys = props.disabledKeys,
|
@@ -77,6 +77,7 @@ var CondensedMultivaluesField = /*#__PURE__*/(0, _react.forwardRef)(function (pr
|
|
77
77
|
onSelectionChange = props.onSelectionChange,
|
78
78
|
placeholder = props.placeholder,
|
79
79
|
selectedKeys = props.selectedKeys,
|
80
|
+
selectedOptionTextProp = props.selectedOptionText,
|
80
81
|
scrollBoxProps = props.scrollBoxProps,
|
81
82
|
status = props.status,
|
82
83
|
others = (0, _objectWithoutProperties2["default"])(props, _excluded);
|
@@ -251,9 +252,10 @@ var CondensedMultivaluesField = /*#__PURE__*/(0, _react.forwardRef)(function (pr
|
|
251
252
|
return count + (obj.children ? obj.children.length : 1);
|
252
253
|
}, 0);
|
253
254
|
var selectedKeysSize = selectionManager.selectedKeys.size;
|
254
|
-
var
|
255
|
+
var selectedOptionText = selectedOptionTextProp || "".concat(itemCount === selectedKeysSize ? 'All' : (_selectionManager$sta = selectionManager.state.selectedKeys) === null || _selectionManager$sta === void 0 ? void 0 : _selectionManager$sta.size, " Selected");
|
256
|
+
var checkboxSelected = ((_selectionManager$sta2 = selectionManager.state.selectedKeys) === null || _selectionManager$sta2 === void 0 ? void 0 : _selectionManager$sta2.size) !== 0 && (0, _react2.jsx)(_.Text, {
|
255
257
|
color: "text.secondary"
|
256
|
-
},
|
258
|
+
}, selectedOptionText);
|
257
259
|
(0, _react.useEffect)(function () {
|
258
260
|
if (selectedKeysSize < itemCount) {
|
259
261
|
setSelectionState('Select All');
|
@@ -306,6 +308,7 @@ var CondensedMultivaluesField = /*#__PURE__*/(0, _react.forwardRef)(function (pr
|
|
306
308
|
id: "emptyKeysState"
|
307
309
|
}, "Nothing Selected");
|
308
310
|
};
|
311
|
+
var placeholderText = ((_selectionManager$sta3 = selectionManager.state.selectedKeys) === null || _selectionManager$sta3 === void 0 ? void 0 : _selectionManager$sta3.size) === 0 ? placeholder || 'Select' : '';
|
309
312
|
var inputProps = _objectSpread(_objectSpread({}, customInputProps), {}, {
|
310
313
|
controlProps: {
|
311
314
|
'aria-activedescendant': activeDescendant,
|
@@ -323,7 +326,7 @@ var CondensedMultivaluesField = /*#__PURE__*/(0, _react.forwardRef)(function (pr
|
|
323
326
|
isReadOnly: isReadOnly,
|
324
327
|
isRequired: isRequired,
|
325
328
|
label: label,
|
326
|
-
placeholder:
|
329
|
+
placeholder: placeholderText,
|
327
330
|
wrapperProps: {
|
328
331
|
ref: inputWrapperRef,
|
329
332
|
variant: 'forms.input.multivaluesWrapper',
|
@@ -21,7 +21,7 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
|
|
21
21
|
_Object$defineProperty(exports, "__esModule", {
|
22
22
|
value: true
|
23
23
|
});
|
24
|
-
exports["default"] = exports.Uncontrolled = exports.ReadOnlyValues = exports.ReadOnlyField = exports.OnLoadPrev = exports.IconSlotsInBadge = exports.Error = exports.DisabledKeys = exports.Default = exports.CustomValues = exports.CustomSize = exports.Controlled = exports.CondensedWithSection = exports.Condensed = void 0;
|
24
|
+
exports["default"] = exports.Uncontrolled = exports.ReadOnlyValues = exports.ReadOnlyField = exports.OnLoadPrev = exports.IconSlotsInBadge = exports.Error = exports.DisabledKeys = exports.Default = exports.CustomValues = exports.CustomSize = exports.Controlled = exports.CondensedWithSection = exports.CondensedWithCustomText = exports.Condensed = void 0;
|
25
25
|
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
26
26
|
var _fill = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/fill"));
|
27
27
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
@@ -703,6 +703,45 @@ var CondensedWithSection = function CondensedWithSection(args) {
|
|
703
703
|
}));
|
704
704
|
};
|
705
705
|
exports.CondensedWithSection = CondensedWithSection;
|
706
|
+
var CondensedWithCustomText = function CondensedWithCustomText(args) {
|
707
|
+
var _useState27 = (0, _react.useState)(false),
|
708
|
+
_useState28 = (0, _slicedToArray2["default"])(_useState27, 2),
|
709
|
+
isOpen = _useState28[0],
|
710
|
+
setIsOpen = _useState28[1];
|
711
|
+
var _useState29 = (0, _react.useState)([]),
|
712
|
+
_useState30 = (0, _slicedToArray2["default"])(_useState29, 2),
|
713
|
+
selectedKeys = _useState30[0],
|
714
|
+
setSelectedKeys = _useState30[1];
|
715
|
+
var direction = args.direction;
|
716
|
+
var onOpenChange = function onOpenChange() {
|
717
|
+
setIsOpen(true);
|
718
|
+
};
|
719
|
+
return (0, _react2.jsx)(_index.OverlayProvider
|
720
|
+
// note: spacing for demo purpose only so that the select list renders in the right place
|
721
|
+
, {
|
722
|
+
style: setOverlayStyle(direction, isOpen, '25%', '25%', '75%')
|
723
|
+
}, (0, _react2.jsx)(_index.MultivaluesField, (0, _extends2["default"])({
|
724
|
+
items: withSection
|
725
|
+
}, args, {
|
726
|
+
mode: "condensed",
|
727
|
+
onOpenChange: onOpenChange,
|
728
|
+
placeholder: "Select your animal",
|
729
|
+
selectedOptionText: "".concat(selectedKeys.size, " Selected Animals"),
|
730
|
+
onSelectionChange: setSelectedKeys,
|
731
|
+
selectedKeys: selectedKeys
|
732
|
+
}), function (section) {
|
733
|
+
return (0, _react2.jsx)(_index.Section, {
|
734
|
+
key: section.key,
|
735
|
+
items: section.children,
|
736
|
+
title: section.name
|
737
|
+
}, function (item) {
|
738
|
+
return (0, _react2.jsx)(_index.Item, {
|
739
|
+
key: item.name
|
740
|
+
}, item.name);
|
741
|
+
});
|
742
|
+
}));
|
743
|
+
};
|
744
|
+
exports.CondensedWithCustomText = CondensedWithCustomText;
|
706
745
|
var OnLoadPrev = function OnLoadPrev() {
|
707
746
|
var _context, _context2;
|
708
747
|
var initialItems = (0, _map["default"])(_context = (0, _fill["default"])(_context2 = new Array(10)).call(_context2, {
|
@@ -715,26 +754,26 @@ var OnLoadPrev = function OnLoadPrev() {
|
|
715
754
|
id: index
|
716
755
|
};
|
717
756
|
});
|
718
|
-
var
|
719
|
-
_useState28 = (0, _slicedToArray2["default"])(_useState27, 2),
|
720
|
-
minNum = _useState28[0],
|
721
|
-
setMinNum = _useState28[1];
|
722
|
-
var _useState29 = (0, _react.useState)(10),
|
723
|
-
_useState30 = (0, _slicedToArray2["default"])(_useState29, 2),
|
724
|
-
maxNum = _useState30[0],
|
725
|
-
setMaxNum = _useState30[1];
|
726
|
-
var _useState31 = (0, _react.useState)(initialItems),
|
757
|
+
var _useState31 = (0, _react.useState)(0),
|
727
758
|
_useState32 = (0, _slicedToArray2["default"])(_useState31, 2),
|
728
|
-
|
729
|
-
|
730
|
-
var _useState33 = (0, _react.useState)(
|
759
|
+
minNum = _useState32[0],
|
760
|
+
setMinNum = _useState32[1];
|
761
|
+
var _useState33 = (0, _react.useState)(10),
|
731
762
|
_useState34 = (0, _slicedToArray2["default"])(_useState33, 2),
|
732
|
-
|
733
|
-
|
734
|
-
var _useState35 = (0, _react.useState)(
|
763
|
+
maxNum = _useState34[0],
|
764
|
+
setMaxNum = _useState34[1];
|
765
|
+
var _useState35 = (0, _react.useState)(initialItems),
|
735
766
|
_useState36 = (0, _slicedToArray2["default"])(_useState35, 2),
|
736
|
-
|
737
|
-
|
767
|
+
listItems = _useState36[0],
|
768
|
+
setListItems = _useState36[1];
|
769
|
+
var _useState37 = (0, _react.useState)(false),
|
770
|
+
_useState38 = (0, _slicedToArray2["default"])(_useState37, 2),
|
771
|
+
isOpen = _useState38[0],
|
772
|
+
setIsOpen = _useState38[1];
|
773
|
+
var _useState39 = (0, _react.useState)(_loadingStates["default"].IDLE),
|
774
|
+
_useState40 = (0, _slicedToArray2["default"])(_useState39, 2),
|
775
|
+
loadingState = _useState40[0],
|
776
|
+
setLoadingState = _useState40[1];
|
738
777
|
var onOpenChange = function onOpenChange() {
|
739
778
|
setIsOpen(true);
|
740
779
|
};
|
@@ -78,16 +78,19 @@ var withSection = [{
|
|
78
78
|
key: 'Option B3'
|
79
79
|
}]
|
80
80
|
}];
|
81
|
+
var labelText = 'Field Label';
|
81
82
|
var defaultProps = {
|
82
83
|
items: items,
|
83
|
-
label:
|
84
|
+
label: labelText
|
84
85
|
};
|
85
86
|
var defaultSectionProps = {
|
86
87
|
items: withSection,
|
87
|
-
label:
|
88
|
+
label: labelText
|
88
89
|
};
|
89
90
|
var onLoadMoreFunc = jest.fn();
|
90
91
|
var onLoadPrevFunc = jest.fn();
|
92
|
+
var placeholder = 'Select Animals';
|
93
|
+
var selectedOptionText = 'Animals Selected';
|
91
94
|
var getComponent = function getComponent() {
|
92
95
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
93
96
|
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
@@ -966,6 +969,20 @@ test('in condensed mode selects and deselects ', function () {
|
|
966
969
|
});
|
967
970
|
expect(button).toHaveTextContent('Select All');
|
968
971
|
});
|
972
|
+
test('in condensed mode custom text props work ', function () {
|
973
|
+
getComponent({
|
974
|
+
mode: 'condensed',
|
975
|
+
placeholder: 'Select Animals',
|
976
|
+
selectedOptionText: selectedOptionText
|
977
|
+
});
|
978
|
+
expect(_testWrapper.screen.getByLabelText(labelText)).toHaveAttribute('placeholder', placeholder);
|
979
|
+
_userEvent["default"].tab();
|
980
|
+
var listbox = _testWrapper.screen.getByRole('listbox');
|
981
|
+
var options = (0, _testWrapper.within)(listbox).getAllByRole('option');
|
982
|
+
var firstOption = options[0];
|
983
|
+
_userEvent["default"].click(firstOption);
|
984
|
+
expect(_testWrapper.screen.getByText('Animals Selected')).toBeInTheDocument();
|
985
|
+
});
|
969
986
|
test('in condensed mode "onSelectionChange" is called', function () {
|
970
987
|
var onSelectionChange = jest.fn();
|
971
988
|
getComponent({
|
@@ -9,7 +9,7 @@ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
|
9
9
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
10
10
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
11
11
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
12
|
-
var _excluded = ["defaultSelectedKeys", "direction", "disabledKeys", "containerProps", "hasAutoFocus", "hasNoSelectAll", "hasNoStatusIndicator", "helperText", "inputProps", "isDisabled", "isNotFlippable", "isReadOnly", "isRequired", "items", "label", "mode", "onBlur", "onFocus", "onInputChange", "onKeyDown", "onKeyUp", "onOpenChange", "onSelectionChange", "placeholder", "selectedKeys", "scrollBoxProps", "status"];
|
12
|
+
var _excluded = ["defaultSelectedKeys", "direction", "disabledKeys", "containerProps", "hasAutoFocus", "hasNoSelectAll", "hasNoStatusIndicator", "helperText", "inputProps", "isDisabled", "isNotFlippable", "isReadOnly", "isRequired", "items", "label", "mode", "onBlur", "onFocus", "onInputChange", "onKeyDown", "onKeyUp", "onOpenChange", "onSelectionChange", "placeholder", "selectedKeys", "selectedOptionText", "scrollBoxProps", "status"];
|
13
13
|
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; }
|
14
14
|
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; }
|
15
15
|
import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
|
@@ -38,7 +38,7 @@ import { statusDefaultProp, statusPropTypes } from '../../utils/docUtils/statusP
|
|
38
38
|
import ListBox from '../ListBox';
|
39
39
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
40
40
|
var CondensedMultivaluesField = /*#__PURE__*/forwardRef(function (props, ref) {
|
41
|
-
var _selectionManager$sta, _selectionManager$sta2,
|
41
|
+
var _selectionManager$sta, _selectionManager$sta2, _selectionManager$sta3, _listBoxRef$current;
|
42
42
|
var defaultSelectedKeys = props.defaultSelectedKeys,
|
43
43
|
direction = props.direction,
|
44
44
|
_props$disabledKeys = props.disabledKeys,
|
@@ -65,6 +65,7 @@ var CondensedMultivaluesField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
65
65
|
onSelectionChange = props.onSelectionChange,
|
66
66
|
placeholder = props.placeholder,
|
67
67
|
selectedKeys = props.selectedKeys,
|
68
|
+
selectedOptionTextProp = props.selectedOptionText,
|
68
69
|
scrollBoxProps = props.scrollBoxProps,
|
69
70
|
status = props.status,
|
70
71
|
others = _objectWithoutProperties(props, _excluded);
|
@@ -239,9 +240,10 @@ var CondensedMultivaluesField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
239
240
|
return count + (obj.children ? obj.children.length : 1);
|
240
241
|
}, 0);
|
241
242
|
var selectedKeysSize = selectionManager.selectedKeys.size;
|
242
|
-
var
|
243
|
+
var selectedOptionText = selectedOptionTextProp || "".concat(itemCount === selectedKeysSize ? 'All' : (_selectionManager$sta = selectionManager.state.selectedKeys) === null || _selectionManager$sta === void 0 ? void 0 : _selectionManager$sta.size, " Selected");
|
244
|
+
var checkboxSelected = ((_selectionManager$sta2 = selectionManager.state.selectedKeys) === null || _selectionManager$sta2 === void 0 ? void 0 : _selectionManager$sta2.size) !== 0 && ___EmotionJSX(Text, {
|
243
245
|
color: "text.secondary"
|
244
|
-
},
|
246
|
+
}, selectedOptionText);
|
245
247
|
useEffect(function () {
|
246
248
|
if (selectedKeysSize < itemCount) {
|
247
249
|
setSelectionState('Select All');
|
@@ -294,6 +296,7 @@ var CondensedMultivaluesField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
294
296
|
id: "emptyKeysState"
|
295
297
|
}, "Nothing Selected");
|
296
298
|
};
|
299
|
+
var placeholderText = ((_selectionManager$sta3 = selectionManager.state.selectedKeys) === null || _selectionManager$sta3 === void 0 ? void 0 : _selectionManager$sta3.size) === 0 ? placeholder || 'Select' : '';
|
297
300
|
var inputProps = _objectSpread(_objectSpread({}, customInputProps), {}, {
|
298
301
|
controlProps: {
|
299
302
|
'aria-activedescendant': activeDescendant,
|
@@ -311,7 +314,7 @@ var CondensedMultivaluesField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
311
314
|
isReadOnly: isReadOnly,
|
312
315
|
isRequired: isRequired,
|
313
316
|
label: label,
|
314
|
-
placeholder:
|
317
|
+
placeholder: placeholderText,
|
315
318
|
wrapperProps: {
|
316
319
|
ref: inputWrapperRef,
|
317
320
|
variant: 'forms.input.multivaluesWrapper',
|
@@ -680,6 +680,44 @@ export var CondensedWithSection = function CondensedWithSection(args) {
|
|
680
680
|
});
|
681
681
|
}));
|
682
682
|
};
|
683
|
+
export var CondensedWithCustomText = function CondensedWithCustomText(args) {
|
684
|
+
var _useState27 = useState(false),
|
685
|
+
_useState28 = _slicedToArray(_useState27, 2),
|
686
|
+
isOpen = _useState28[0],
|
687
|
+
setIsOpen = _useState28[1];
|
688
|
+
var _useState29 = useState([]),
|
689
|
+
_useState30 = _slicedToArray(_useState29, 2),
|
690
|
+
selectedKeys = _useState30[0],
|
691
|
+
setSelectedKeys = _useState30[1];
|
692
|
+
var direction = args.direction;
|
693
|
+
var onOpenChange = function onOpenChange() {
|
694
|
+
setIsOpen(true);
|
695
|
+
};
|
696
|
+
return ___EmotionJSX(OverlayProvider
|
697
|
+
// note: spacing for demo purpose only so that the select list renders in the right place
|
698
|
+
, {
|
699
|
+
style: setOverlayStyle(direction, isOpen, '25%', '25%', '75%')
|
700
|
+
}, ___EmotionJSX(MultivaluesField, _extends({
|
701
|
+
items: withSection
|
702
|
+
}, args, {
|
703
|
+
mode: "condensed",
|
704
|
+
onOpenChange: onOpenChange,
|
705
|
+
placeholder: "Select your animal",
|
706
|
+
selectedOptionText: "".concat(selectedKeys.size, " Selected Animals"),
|
707
|
+
onSelectionChange: setSelectedKeys,
|
708
|
+
selectedKeys: selectedKeys
|
709
|
+
}), function (section) {
|
710
|
+
return ___EmotionJSX(Section, {
|
711
|
+
key: section.key,
|
712
|
+
items: section.children,
|
713
|
+
title: section.name
|
714
|
+
}, function (item) {
|
715
|
+
return ___EmotionJSX(Item, {
|
716
|
+
key: item.name
|
717
|
+
}, item.name);
|
718
|
+
});
|
719
|
+
}));
|
720
|
+
};
|
683
721
|
export var OnLoadPrev = function OnLoadPrev() {
|
684
722
|
var _context, _context2;
|
685
723
|
var initialItems = _mapInstanceProperty(_context = _fillInstanceProperty(_context2 = new Array(10)).call(_context2, {
|
@@ -692,26 +730,26 @@ export var OnLoadPrev = function OnLoadPrev() {
|
|
692
730
|
id: index
|
693
731
|
};
|
694
732
|
});
|
695
|
-
var
|
696
|
-
_useState28 = _slicedToArray(_useState27, 2),
|
697
|
-
minNum = _useState28[0],
|
698
|
-
setMinNum = _useState28[1];
|
699
|
-
var _useState29 = useState(10),
|
700
|
-
_useState30 = _slicedToArray(_useState29, 2),
|
701
|
-
maxNum = _useState30[0],
|
702
|
-
setMaxNum = _useState30[1];
|
703
|
-
var _useState31 = useState(initialItems),
|
733
|
+
var _useState31 = useState(0),
|
704
734
|
_useState32 = _slicedToArray(_useState31, 2),
|
705
|
-
|
706
|
-
|
707
|
-
var _useState33 = useState(
|
735
|
+
minNum = _useState32[0],
|
736
|
+
setMinNum = _useState32[1];
|
737
|
+
var _useState33 = useState(10),
|
708
738
|
_useState34 = _slicedToArray(_useState33, 2),
|
709
|
-
|
710
|
-
|
711
|
-
var _useState35 = useState(
|
739
|
+
maxNum = _useState34[0],
|
740
|
+
setMaxNum = _useState34[1];
|
741
|
+
var _useState35 = useState(initialItems),
|
712
742
|
_useState36 = _slicedToArray(_useState35, 2),
|
713
|
-
|
714
|
-
|
743
|
+
listItems = _useState36[0],
|
744
|
+
setListItems = _useState36[1];
|
745
|
+
var _useState37 = useState(false),
|
746
|
+
_useState38 = _slicedToArray(_useState37, 2),
|
747
|
+
isOpen = _useState38[0],
|
748
|
+
setIsOpen = _useState38[1];
|
749
|
+
var _useState39 = useState(loadingStates.IDLE),
|
750
|
+
_useState40 = _slicedToArray(_useState39, 2),
|
751
|
+
loadingState = _useState40[0],
|
752
|
+
setLoadingState = _useState40[1];
|
715
753
|
var onOpenChange = function onOpenChange() {
|
716
754
|
setIsOpen(true);
|
717
755
|
};
|
@@ -71,16 +71,19 @@ var withSection = [{
|
|
71
71
|
key: 'Option B3'
|
72
72
|
}]
|
73
73
|
}];
|
74
|
+
var labelText = 'Field Label';
|
74
75
|
var defaultProps = {
|
75
76
|
items: items,
|
76
|
-
label:
|
77
|
+
label: labelText
|
77
78
|
};
|
78
79
|
var defaultSectionProps = {
|
79
80
|
items: withSection,
|
80
|
-
label:
|
81
|
+
label: labelText
|
81
82
|
};
|
82
83
|
var onLoadMoreFunc = jest.fn();
|
83
84
|
var onLoadPrevFunc = jest.fn();
|
85
|
+
var placeholder = 'Select Animals';
|
86
|
+
var selectedOptionText = 'Animals Selected';
|
84
87
|
var getComponent = function getComponent() {
|
85
88
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
86
89
|
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
@@ -959,6 +962,20 @@ test('in condensed mode selects and deselects ', function () {
|
|
959
962
|
});
|
960
963
|
expect(button).toHaveTextContent('Select All');
|
961
964
|
});
|
965
|
+
test('in condensed mode custom text props work ', function () {
|
966
|
+
getComponent({
|
967
|
+
mode: 'condensed',
|
968
|
+
placeholder: 'Select Animals',
|
969
|
+
selectedOptionText: selectedOptionText
|
970
|
+
});
|
971
|
+
expect(screen.getByLabelText(labelText)).toHaveAttribute('placeholder', placeholder);
|
972
|
+
userEvent.tab();
|
973
|
+
var listbox = screen.getByRole('listbox');
|
974
|
+
var options = within(listbox).getAllByRole('option');
|
975
|
+
var firstOption = options[0];
|
976
|
+
userEvent.click(firstOption);
|
977
|
+
expect(screen.getByText('Animals Selected')).toBeInTheDocument();
|
978
|
+
});
|
962
979
|
test('in condensed mode "onSelectionChange" is called', function () {
|
963
980
|
var onSelectionChange = jest.fn();
|
964
981
|
getComponent({
|