@pingux/astro 1.4.2-alpha.1 → 1.5.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.
- package/lib/cjs/components/ListView/ListView.js +12 -13
- package/lib/cjs/components/ListView/ListView.test.js +8 -8
- package/lib/cjs/components/ListViewItem/ListViewItem.js +0 -2
- package/lib/cjs/components/MultiselectFilter/MultiselectFilter.js +143 -0
- package/lib/cjs/components/MultiselectFilter/MultiselectFilter.stories.js +283 -0
- package/lib/cjs/components/MultiselectFilter/MultiselectFilter.test.js +83 -0
- package/lib/cjs/components/MultiselectFilter/index.js +18 -0
- package/lib/cjs/components/MultiselectFilterItem/MultiselectFilterItem.js +55 -0
- package/lib/cjs/components/MultiselectFilterItem/MultiselectFilterItem.test.js +53 -0
- package/lib/cjs/components/MultiselectFilterItem/index.js +18 -0
- package/lib/cjs/components/MultiselectListContainer/MultiselectBadge.js +47 -0
- package/lib/cjs/components/MultiselectListContainer/MultiselectBadge.test.js +48 -0
- package/lib/cjs/components/MultiselectListContainer/MultiselectListContainer.js +157 -0
- package/lib/cjs/components/MultiselectListContainer/MultiselectListContainer.test.js +112 -0
- package/lib/cjs/components/MultiselectListContainer/index.js +18 -0
- package/lib/cjs/index.js +98 -32
- package/lib/cjs/styles/variants/buttons.js +25 -1
- package/lib/cjs/styles/variants/multiselectListContainer.js +73 -0
- package/lib/cjs/styles/variants/text.js +22 -0
- package/lib/cjs/styles/variants/variants.js +3 -0
- package/lib/components/ListView/ListView.js +12 -13
- package/lib/components/ListView/ListView.test.js +8 -8
- package/lib/components/ListViewItem/ListViewItem.js +0 -2
- package/lib/components/MultiselectFilter/MultiselectFilter.js +118 -0
- package/lib/components/MultiselectFilter/MultiselectFilter.stories.js +251 -0
- package/lib/components/MultiselectFilter/MultiselectFilter.test.js +69 -0
- package/lib/components/MultiselectFilter/index.js +1 -0
- package/lib/components/MultiselectFilterItem/MultiselectFilterItem.js +36 -0
- package/lib/components/MultiselectFilterItem/MultiselectFilterItem.test.js +37 -0
- package/lib/components/MultiselectFilterItem/index.js +1 -0
- package/lib/components/MultiselectListContainer/MultiselectBadge.js +31 -0
- package/lib/components/MultiselectListContainer/MultiselectBadge.test.js +34 -0
- package/lib/components/MultiselectListContainer/MultiselectListContainer.js +123 -0
- package/lib/components/MultiselectListContainer/MultiselectListContainer.test.js +81 -0
- package/lib/components/MultiselectListContainer/index.js +1 -0
- package/lib/index.js +6 -0
- package/lib/styles/variants/buttons.js +25 -1
- package/lib/styles/variants/multiselectListContainer.js +63 -0
- package/lib/styles/variants/text.js +22 -0
- package/lib/styles/variants/variants.js +2 -0
- package/package.json +1 -1
@@ -39,6 +39,8 @@ var _from = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stabl
|
|
39
39
|
|
40
40
|
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
41
41
|
|
42
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
|
43
|
+
|
42
44
|
var _react = _interopRequireWildcard(require("react"));
|
43
45
|
|
44
46
|
var _grid = require("@react-stately/grid");
|
@@ -101,9 +103,13 @@ function useListLayout(state) {
|
|
101
103
|
}
|
102
104
|
|
103
105
|
var ListView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
104
|
-
var
|
106
|
+
var disabledKeys = props.disabledKeys,
|
107
|
+
loadingState = props.loadingState,
|
105
108
|
onLoadMore = props.onLoadMore,
|
106
|
-
|
109
|
+
onSelectionChange = props.onSelectionChange,
|
110
|
+
selectionMode = props.selectionMode,
|
111
|
+
selectionStyle = props.selectionStyle,
|
112
|
+
others = (0, _objectWithoutProperties2["default"])(props, ["disabledKeys", "loadingState", "onLoadMore", "onSelectionChange", "selectionMode", "selectionStyle"]);
|
107
113
|
var isLoading = loadingState === _loadingStates["default"].LOADING_MORE || loadingState === _loadingStates["default"].LOADING;
|
108
114
|
|
109
115
|
var renderWrapper = function renderWrapper(parent, reusableView) {
|
@@ -166,8 +172,7 @@ var ListView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
166
172
|
disabledKeys: state.disabledKeys,
|
167
173
|
ref: listViewRef,
|
168
174
|
direction: direction,
|
169
|
-
collator: collator
|
170
|
-
focusMode: 'cell'
|
175
|
+
collator: collator
|
171
176
|
});
|
172
177
|
}, [state, listViewRef, direction, collator]);
|
173
178
|
|
@@ -180,13 +185,7 @@ var ListView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
180
185
|
|
181
186
|
|
182
187
|
layout.isLoading = isLoading;
|
183
|
-
var
|
184
|
-
var focusedItem = gridCollection.getItem(state.selectionManager.focusedKey);
|
185
|
-
|
186
|
-
if ((focusedItem === null || focusedItem === void 0 ? void 0 : focusedItem.parentKey) != null) {
|
187
|
-
focusedKey = focusedItem.parentKey;
|
188
|
-
}
|
189
|
-
|
188
|
+
var focusedItem = gridCollection.getFirstKey();
|
190
189
|
return (0, _react2.jsx)(_ListViewContext.ListViewContext.Provider, {
|
191
190
|
value: {
|
192
191
|
state: state,
|
@@ -195,7 +194,7 @@ var ListView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
195
194
|
}, (0, _react2.jsx)(_virtualizer.Virtualizer, (0, _extends2["default"])({}, gridProps, {
|
196
195
|
onLoadMore: onLoadMore,
|
197
196
|
ref: listViewRef,
|
198
|
-
focusedKey:
|
197
|
+
focusedKey: focusedItem === null || focusedItem === void 0 ? void 0 : focusedItem.parentKey,
|
199
198
|
renderWrapper: renderWrapper,
|
200
199
|
sizeToFit: "height",
|
201
200
|
scrollDirection: "vertical",
|
@@ -203,7 +202,7 @@ var ListView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
203
202
|
isLoading: isLoading,
|
204
203
|
collection: gridCollection,
|
205
204
|
transitionDuration: 0
|
206
|
-
}), function (type, item) {
|
205
|
+
}, others), function (type, item) {
|
207
206
|
if (type === 'item') {
|
208
207
|
return (0, _react2.jsx)(_ListViewItem["default"], {
|
209
208
|
item: item
|
@@ -127,7 +127,7 @@ test('navigating the list using the keyboard causes the isSelected and isFocused
|
|
127
127
|
skipClick: true
|
128
128
|
});
|
129
129
|
|
130
|
-
options = _testWrapper.screen.getAllByRole('
|
130
|
+
options = _testWrapper.screen.getAllByRole('gridcell');
|
131
131
|
expect(options[1]).toHaveClass('is-focused');
|
132
132
|
|
133
133
|
_userEvent["default"].type(listView, '{enter}', {
|
@@ -135,7 +135,7 @@ test('navigating the list using the keyboard causes the isSelected and isFocused
|
|
135
135
|
});
|
136
136
|
|
137
137
|
_context.next = 9;
|
138
|
-
return _testWrapper.screen.findAllByRole('
|
138
|
+
return _testWrapper.screen.findAllByRole('gridcell');
|
139
139
|
|
140
140
|
case 9:
|
141
141
|
updatedOption = _context.sent;
|
@@ -166,7 +166,7 @@ test('navigating to a disabled key will not apply the isFocused class', /*#__PUR
|
|
166
166
|
skipClick: true
|
167
167
|
});
|
168
168
|
|
169
|
-
options = _testWrapper.screen.getAllByRole('
|
169
|
+
options = _testWrapper.screen.getAllByRole('gridcell');
|
170
170
|
expect(options[1]).not.toHaveClass('is-focused');
|
171
171
|
|
172
172
|
case 6:
|
@@ -188,7 +188,7 @@ test('clicking an item on the list selects the item', /*#__PURE__*/(0, _asyncToG
|
|
188
188
|
_userEvent["default"].click(options);
|
189
189
|
|
190
190
|
_context3.next = 5;
|
191
|
-
return _testWrapper.screen.findAllByRole('
|
191
|
+
return _testWrapper.screen.findAllByRole('gridcell');
|
192
192
|
|
193
193
|
case 5:
|
194
194
|
updatedOption = _context3.sent;
|
@@ -255,12 +255,12 @@ test('does not render loader, if loadingState is not loadingMore', function () {
|
|
255
255
|
test('renders neither loader nor item if the component is given no items nor a loading state prop', function () {
|
256
256
|
getComponentEmpty();
|
257
257
|
expect(_testWrapper.screen.queryByRole('progressbar')).not.toBeInTheDocument();
|
258
|
-
expect(_testWrapper.screen.queryByRole('
|
258
|
+
expect(_testWrapper.screen.queryByRole('gridcell')).not.toBeInTheDocument();
|
259
259
|
});
|
260
260
|
test('Item accepts a data-id and the data-id can be found in the DOM', function () {
|
261
261
|
getComponent();
|
262
262
|
|
263
|
-
var options = _testWrapper.screen.getAllByRole('
|
263
|
+
var options = _testWrapper.screen.getAllByRole('gridcell');
|
264
264
|
|
265
265
|
expect(options).toHaveLength(items.length);
|
266
266
|
expect(options[0]).toHaveAttribute('data-id', items[0].name);
|
@@ -279,7 +279,7 @@ test('selectionMode "none" disallows to select item', /*#__PURE__*/(0, _asyncToG
|
|
279
279
|
_userEvent["default"].click(option1);
|
280
280
|
|
281
281
|
_context5.next = 5;
|
282
|
-
return _testWrapper.screen.findAllByRole('
|
282
|
+
return _testWrapper.screen.findAllByRole('gridcell');
|
283
283
|
|
284
284
|
case 5:
|
285
285
|
updatedOption = _context5.sent;
|
@@ -310,7 +310,7 @@ test('selectionMode "multiple" allows to select more than one item', /*#__PURE__
|
|
310
310
|
_userEvent["default"].click(option2);
|
311
311
|
|
312
312
|
_context6.next = 7;
|
313
|
-
return _testWrapper.screen.findAllByRole('
|
313
|
+
return _testWrapper.screen.findAllByRole('gridcell');
|
314
314
|
|
315
315
|
case 7:
|
316
316
|
updatedOption = _context6.sent;
|
@@ -106,7 +106,6 @@ var ListViewItem = function ListViewItem(props) {
|
|
106
106
|
classNames = _useStatusClasses.classNames;
|
107
107
|
|
108
108
|
return (0, _react2.jsx)(_react["default"].Fragment, null, (0, _react2.jsx)(_Box["default"], (0, _extends2["default"])({
|
109
|
-
as: "li",
|
110
109
|
isDisabled: isDisabled,
|
111
110
|
isRow: true
|
112
111
|
}, raRowProps, {
|
@@ -115,7 +114,6 @@ var ListViewItem = function ListViewItem(props) {
|
|
115
114
|
as: "div",
|
116
115
|
ref: cellRef
|
117
116
|
}, mergedProps, {
|
118
|
-
role: "listitem",
|
119
117
|
variant: "boxes.listViewItem",
|
120
118
|
isFocused: isDisabled ? false : isFocusVisible,
|
121
119
|
isDisabled: isDisabled,
|
@@ -0,0 +1,143 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime-corejs3/helpers/interopRequireWildcard");
|
4
|
+
|
5
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
6
|
+
|
7
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
8
|
+
|
9
|
+
_Object$defineProperty(exports, "__esModule", {
|
10
|
+
value: true
|
11
|
+
});
|
12
|
+
|
13
|
+
exports["default"] = void 0;
|
14
|
+
|
15
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
16
|
+
|
17
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
|
18
|
+
|
19
|
+
var _react = _interopRequireWildcard(require("react"));
|
20
|
+
|
21
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
22
|
+
|
23
|
+
var _focus = require("@react-aria/focus");
|
24
|
+
|
25
|
+
var _utils = require("@react-aria/utils");
|
26
|
+
|
27
|
+
var _isIterable = require("../../utils/devUtils/props/isIterable");
|
28
|
+
|
29
|
+
var _hooks = require("../../hooks");
|
30
|
+
|
31
|
+
var _MultiselectBadge = _interopRequireDefault(require("../MultiselectListContainer/MultiselectBadge"));
|
32
|
+
|
33
|
+
var _index = require("../../index");
|
34
|
+
|
35
|
+
var _react2 = require("@emotion/react");
|
36
|
+
|
37
|
+
/**
|
38
|
+
* The MultiselectFilter serves as a filter menu with a menu title
|
39
|
+
* and selected count displayed in a badge.
|
40
|
+
*/
|
41
|
+
var MultiselectFilter = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
42
|
+
var selectedFilterCount = props.selectedFilterCount,
|
43
|
+
className = props.className,
|
44
|
+
closeAriaLabel = props.closeAriaLabel,
|
45
|
+
children = props.children,
|
46
|
+
isDefaultOpen = props.isDefaultOpen,
|
47
|
+
isOpen = props.isOpen,
|
48
|
+
items = props.items,
|
49
|
+
listTitle = props.listTitle,
|
50
|
+
onOpenChange = props.onOpenChange,
|
51
|
+
onSelectionChange = props.onSelectionChange,
|
52
|
+
openAriaLabel = props.openAriaLabel,
|
53
|
+
others = (0, _objectWithoutProperties2["default"])(props, ["selectedFilterCount", "className", "closeAriaLabel", "children", "isDefaultOpen", "isOpen", "items", "listTitle", "onOpenChange", "onSelectionChange", "openAriaLabel"]);
|
54
|
+
|
55
|
+
var _useFocusRing = (0, _focus.useFocusRing)({
|
56
|
+
within: true
|
57
|
+
}),
|
58
|
+
focusWithinProps = _useFocusRing.focusProps;
|
59
|
+
|
60
|
+
var _useFocusRing2 = (0, _focus.useFocusRing)(),
|
61
|
+
focusProps = _useFocusRing2.focusProps,
|
62
|
+
isFocusVisible = _useFocusRing2.isFocusVisible;
|
63
|
+
|
64
|
+
var mergedProps = (0, _utils.mergeProps)(focusWithinProps, focusProps);
|
65
|
+
|
66
|
+
var _useStatusClasses = (0, _hooks.useStatusClasses)(className, {
|
67
|
+
isFocused: isFocusVisible
|
68
|
+
}),
|
69
|
+
classNames = _useStatusClasses.classNames;
|
70
|
+
|
71
|
+
return (0, _react2.jsx)(_index.MultiselectListContainer, {
|
72
|
+
closeAriaLabel: closeAriaLabel,
|
73
|
+
isDefaultOpen: isDefaultOpen,
|
74
|
+
isOpen: isOpen,
|
75
|
+
onOpenChange: onOpenChange,
|
76
|
+
openAriaLabel: openAriaLabel,
|
77
|
+
selectedFilterCount: selectedFilterCount
|
78
|
+
}, (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({
|
79
|
+
className: classNames,
|
80
|
+
"data-testid": "multiselect-filter",
|
81
|
+
ref: ref,
|
82
|
+
tabIndex: 0,
|
83
|
+
variant: "multiselectListContainer.multiselectListContent"
|
84
|
+
}, mergedProps, others), (0, _react2.jsx)(_index.Box, {
|
85
|
+
isRow: true,
|
86
|
+
variant: "multiselectListContainer.multiselectListTitle"
|
87
|
+
}, (0, _react2.jsx)(_index.Text, {
|
88
|
+
variant: "multiselectFilterTitle"
|
89
|
+
}, listTitle), selectedFilterCount && (0, _react2.jsx)(_MultiselectBadge["default"], {
|
90
|
+
margin: "0",
|
91
|
+
selectedFilterCount: selectedFilterCount
|
92
|
+
})), (0, _react2.jsx)(_index.Box, {
|
93
|
+
pl: "xs",
|
94
|
+
pr: "xs"
|
95
|
+
}, (0, _react2.jsx)(_index.ListView, {
|
96
|
+
items: items,
|
97
|
+
onSelectionChange: onSelectionChange,
|
98
|
+
selectionMode: "multiple",
|
99
|
+
style: {
|
100
|
+
width: '100%'
|
101
|
+
},
|
102
|
+
pl: "md"
|
103
|
+
}, children))));
|
104
|
+
});
|
105
|
+
MultiselectFilter.propTypes = {
|
106
|
+
/** Amount of selected items indicator. */
|
107
|
+
selectedFilterCount: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
|
108
|
+
|
109
|
+
/** Title of list content. */
|
110
|
+
listTitle: _propTypes["default"].string,
|
111
|
+
|
112
|
+
/** Defines a string value that labels the trigger icon when menu is open. */
|
113
|
+
closeAriaLabel: _propTypes["default"].string,
|
114
|
+
|
115
|
+
/** Sets the default open state of the overlay. */
|
116
|
+
isDefaultOpen: _propTypes["default"].bool,
|
117
|
+
|
118
|
+
/** Whether the overlay is currently open. */
|
119
|
+
isOpen: _propTypes["default"].bool,
|
120
|
+
|
121
|
+
/** The list of ListView items (controlled). */
|
122
|
+
items: _isIterable.isIterableProp,
|
123
|
+
|
124
|
+
/**
|
125
|
+
* Method that is called when the open state of the menu changes.
|
126
|
+
* Returns the new open state and the action that caused the opening of the menu.
|
127
|
+
*
|
128
|
+
* `(isOpen: boolean, overlayTrigger: OverlayTriggerAction) => void`
|
129
|
+
*/
|
130
|
+
onOpenChange: _propTypes["default"].func,
|
131
|
+
|
132
|
+
/** Callback function that fires when the selected key changes. */
|
133
|
+
onSelectionChange: _propTypes["default"].func,
|
134
|
+
|
135
|
+
/** Defines a string value that labels the trigger icon when menu is closed. */
|
136
|
+
openAriaLabel: _propTypes["default"].string
|
137
|
+
};
|
138
|
+
MultiselectFilter.defaultProps = {
|
139
|
+
isDefaultOpen: true
|
140
|
+
};
|
141
|
+
MultiselectFilter.displayName = 'MultiselectFilter';
|
142
|
+
var _default = MultiselectFilter;
|
143
|
+
exports["default"] = _default;
|
@@ -0,0 +1,283 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime-corejs3/helpers/interopRequireWildcard");
|
4
|
+
|
5
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
6
|
+
|
7
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
8
|
+
|
9
|
+
_Object$defineProperty(exports, "__esModule", {
|
10
|
+
value: true
|
11
|
+
});
|
12
|
+
|
13
|
+
exports.MultiselectWithBadge = exports.Default = exports["default"] = void 0;
|
14
|
+
|
15
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
16
|
+
|
17
|
+
var _react = _interopRequireWildcard(require("react"));
|
18
|
+
|
19
|
+
var _AccountGroupIcon = _interopRequireDefault(require("mdi-react/AccountGroupIcon"));
|
20
|
+
|
21
|
+
var _CloseIcon = _interopRequireDefault(require("mdi-react/CloseIcon"));
|
22
|
+
|
23
|
+
var _ChevronRightIcon = _interopRequireDefault(require("mdi-react/ChevronRightIcon"));
|
24
|
+
|
25
|
+
var _FilterIcon = _interopRequireDefault(require("mdi-react/FilterIcon"));
|
26
|
+
|
27
|
+
var _SearchIcon = _interopRequireDefault(require("mdi-react/SearchIcon"));
|
28
|
+
|
29
|
+
var _PersonIcon = _interopRequireDefault(require("mdi-react/PersonIcon"));
|
30
|
+
|
31
|
+
var _MultiselectFilter = _interopRequireDefault(require("./MultiselectFilter"));
|
32
|
+
|
33
|
+
var _hooks = require("../../hooks");
|
34
|
+
|
35
|
+
var _index = require("../../index");
|
36
|
+
|
37
|
+
var _react2 = require("@emotion/react");
|
38
|
+
|
39
|
+
var _default = {
|
40
|
+
title: 'MultiselectFilter',
|
41
|
+
component: _MultiselectFilter["default"],
|
42
|
+
argTypes: {
|
43
|
+
listTitle: {
|
44
|
+
defaultValue: 'Selected Groups'
|
45
|
+
},
|
46
|
+
openAriaLabel: {
|
47
|
+
defaultValue: 'Open filter menu?'
|
48
|
+
},
|
49
|
+
closeAriaLabel: {
|
50
|
+
defaultValue: 'Close filter menu?'
|
51
|
+
},
|
52
|
+
isDefaultOpen: {},
|
53
|
+
isOpen: {
|
54
|
+
onClick: {
|
55
|
+
action: 'clicked'
|
56
|
+
},
|
57
|
+
control: {
|
58
|
+
type: 'none'
|
59
|
+
}
|
60
|
+
}
|
61
|
+
}
|
62
|
+
};
|
63
|
+
exports["default"] = _default;
|
64
|
+
var items = [{
|
65
|
+
id: '1',
|
66
|
+
icon: 'Group',
|
67
|
+
key: 'Avengers',
|
68
|
+
name: 'Avengers',
|
69
|
+
subtitle: 'Default',
|
70
|
+
chipValue: '25'
|
71
|
+
}, {
|
72
|
+
id: '2',
|
73
|
+
icon: 'Group',
|
74
|
+
key: 'Credit Cards',
|
75
|
+
name: 'Credit Cards',
|
76
|
+
subtitle: '',
|
77
|
+
chipValue: '123'
|
78
|
+
}, {
|
79
|
+
id: '3',
|
80
|
+
icon: 'Group',
|
81
|
+
key: 'Debit Cards',
|
82
|
+
name: 'Debit Cards',
|
83
|
+
subtitle: '',
|
84
|
+
chipValue: '23'
|
85
|
+
}, {
|
86
|
+
id: '4',
|
87
|
+
icon: 'Group',
|
88
|
+
key: 'Digital Investors',
|
89
|
+
name: 'Digital Investors',
|
90
|
+
subtitle: 'N America',
|
91
|
+
chipValue: '12'
|
92
|
+
}, {
|
93
|
+
id: '5',
|
94
|
+
icon: 'Group',
|
95
|
+
key: 'Mortgages',
|
96
|
+
name: 'Mortgages',
|
97
|
+
subtitle: 'N America',
|
98
|
+
chipValue: '112'
|
99
|
+
}, {
|
100
|
+
id: '6',
|
101
|
+
icon: 'Group',
|
102
|
+
key: 'Person LOC',
|
103
|
+
name: 'Person LOC',
|
104
|
+
subtitle: '',
|
105
|
+
chipValue: '45'
|
106
|
+
}, {
|
107
|
+
id: '7',
|
108
|
+
icon: 'Group',
|
109
|
+
key: 'Production',
|
110
|
+
name: 'Production',
|
111
|
+
subtitle: '',
|
112
|
+
chipValue: '55'
|
113
|
+
}, {
|
114
|
+
id: '8',
|
115
|
+
icon: 'Group',
|
116
|
+
key: 'UX Team',
|
117
|
+
name: 'UX Team',
|
118
|
+
subtitle: '',
|
119
|
+
chipValue: '61'
|
120
|
+
}, {
|
121
|
+
id: '9',
|
122
|
+
icon: 'Group',
|
123
|
+
key: 'UI Team',
|
124
|
+
name: 'UI Team',
|
125
|
+
subtitle: '',
|
126
|
+
chipValue: '29'
|
127
|
+
}];
|
128
|
+
var mockData = [{
|
129
|
+
id: '10',
|
130
|
+
key: 'Avengers',
|
131
|
+
name: 'Avengers'
|
132
|
+
}, {
|
133
|
+
id: '11',
|
134
|
+
key: 'Digital Investors',
|
135
|
+
name: 'Digital Investors'
|
136
|
+
}, {
|
137
|
+
id: '12',
|
138
|
+
key: 'A very long title as well',
|
139
|
+
name: 'A very long title as well'
|
140
|
+
}];
|
141
|
+
|
142
|
+
var changeSelection = function changeSelection(selected) {
|
143
|
+
console.log(selected);
|
144
|
+
};
|
145
|
+
|
146
|
+
var Default = function Default(args) {
|
147
|
+
return (0, _react2.jsx)(_MultiselectFilter["default"], args);
|
148
|
+
};
|
149
|
+
|
150
|
+
exports.Default = Default;
|
151
|
+
|
152
|
+
var MultiselectWithBadge = function MultiselectWithBadge(args) {
|
153
|
+
var _useOverlayPanelState = (0, _hooks.useOverlayPanelState)(),
|
154
|
+
state = _useOverlayPanelState.state,
|
155
|
+
onClose = _useOverlayPanelState.onClose;
|
156
|
+
|
157
|
+
var triggerRef = (0, _react.useRef)();
|
158
|
+
return (0, _react2.jsx)(_index.OverlayProvider, null, (0, _react2.jsx)(_index.Button, {
|
159
|
+
ref: triggerRef,
|
160
|
+
onPress: state.open
|
161
|
+
}, "Open Panel"), (0, _react2.jsx)(_index.OverlayPanel, {
|
162
|
+
isOpen: state.isOpen,
|
163
|
+
size: "large",
|
164
|
+
p: "0"
|
165
|
+
}, (0, _react2.jsx)(_index.Box, {
|
166
|
+
sx: {
|
167
|
+
minHeight: '60px'
|
168
|
+
},
|
169
|
+
bg: "accent.99"
|
170
|
+
}, (0, _react2.jsx)(_index.Box, {
|
171
|
+
isRow: true,
|
172
|
+
flexBasis: "0px",
|
173
|
+
flexGrow: "1",
|
174
|
+
alignItems: "center",
|
175
|
+
pl: "md",
|
176
|
+
pr: "md",
|
177
|
+
justifyContent: "space-between",
|
178
|
+
zIndex: 2
|
179
|
+
}, (0, _react2.jsx)(_index.Box, {
|
180
|
+
isRow: true
|
181
|
+
}, (0, _react2.jsx)(_index.Icon, {
|
182
|
+
icon: _PersonIcon["default"],
|
183
|
+
alignSelf: "center",
|
184
|
+
mr: "md",
|
185
|
+
color: "accent.40",
|
186
|
+
size: 25,
|
187
|
+
flexShrink: 0,
|
188
|
+
display: "flex"
|
189
|
+
}), (0, _react2.jsx)(_index.Breadcrumbs, {
|
190
|
+
icon: _ChevronRightIcon["default"]
|
191
|
+
}, (0, _react2.jsx)(_index.Item, {
|
192
|
+
key: "home",
|
193
|
+
variant: "link",
|
194
|
+
"data-id": "home"
|
195
|
+
}, "Ed Nepomuceno"), (0, _react2.jsx)(_index.Item, {
|
196
|
+
key: "editGroups",
|
197
|
+
variant: "neutralText",
|
198
|
+
"data-id": "editGroups"
|
199
|
+
}, "Edit Groups"))), (0, _react2.jsx)(_index.Box, {
|
200
|
+
isRow: true
|
201
|
+
}, (0, _react2.jsx)(_index.IconButton, {
|
202
|
+
"aria-label": "Close Panel",
|
203
|
+
onPress: function onPress() {
|
204
|
+
onClose(state, triggerRef);
|
205
|
+
}
|
206
|
+
}, (0, _react2.jsx)(_index.Icon, {
|
207
|
+
icon: _CloseIcon["default"],
|
208
|
+
size: 20
|
209
|
+
}))))), (0, _react2.jsx)(_index.Box, {
|
210
|
+
pl: "md",
|
211
|
+
pt: "25px"
|
212
|
+
}, (0, _react2.jsx)(_index.Box, {
|
213
|
+
isRow: true,
|
214
|
+
justifyContent: "space-between"
|
215
|
+
}, (0, _react2.jsx)(_index.Box, {
|
216
|
+
width: "100%"
|
217
|
+
}, (0, _react2.jsx)(_index.SearchField, {
|
218
|
+
icon: _SearchIcon["default"],
|
219
|
+
"aria-label": "Search",
|
220
|
+
placeholder: "Search",
|
221
|
+
width: "100%",
|
222
|
+
mt: "0px",
|
223
|
+
mr: "sm"
|
224
|
+
}), (0, _react2.jsx)(_index.ListView, {
|
225
|
+
items: items,
|
226
|
+
style: {
|
227
|
+
width: '108%'
|
228
|
+
}
|
229
|
+
}, function (item) {
|
230
|
+
return (0, _react2.jsx)(_index.Item, {
|
231
|
+
key: item.key,
|
232
|
+
textValue: item.name,
|
233
|
+
"data-id": item.key,
|
234
|
+
listItemProps: {
|
235
|
+
sx: {
|
236
|
+
bg: 'white',
|
237
|
+
'&.is-hovered': {
|
238
|
+
bg: 'accent.99'
|
239
|
+
}
|
240
|
+
}
|
241
|
+
}
|
242
|
+
}, (0, _react2.jsx)(_index.Box, {
|
243
|
+
isRow: true
|
244
|
+
}, (0, _react2.jsx)(_index.Icon, {
|
245
|
+
icon: _AccountGroupIcon["default"],
|
246
|
+
alignSelf: "center",
|
247
|
+
mr: "md",
|
248
|
+
color: "accent.40",
|
249
|
+
size: 25,
|
250
|
+
flexShrink: 1
|
251
|
+
}), (0, _react2.jsx)(_index.Box, null, (0, _react2.jsx)(_index.Box, {
|
252
|
+
isRow: true
|
253
|
+
}, (0, _react2.jsx)(_index.Text, {
|
254
|
+
variant: "listTitle",
|
255
|
+
mb: "xs",
|
256
|
+
mr: "xs"
|
257
|
+
}, item.name), (0, _react2.jsx)(_index.Chip, {
|
258
|
+
label: item.chipValue,
|
259
|
+
bg: "accent.99",
|
260
|
+
textColor: "text.secondary",
|
261
|
+
sx: {
|
262
|
+
minWidth: 'max-content'
|
263
|
+
}
|
264
|
+
})), (0, _react2.jsx)(_index.Text, {
|
265
|
+
variant: "listSubtitle"
|
266
|
+
}, item.subtitle))));
|
267
|
+
})), (0, _react2.jsx)(_MultiselectFilter["default"], (0, _extends2["default"])({
|
268
|
+
items: mockData,
|
269
|
+
onSelectionChange: changeSelection,
|
270
|
+
selectedFilterCount: "1000+"
|
271
|
+
}, args), function (item) {
|
272
|
+
return (0, _react2.jsx)(_index.Item, {
|
273
|
+
key: item.key,
|
274
|
+
textValue: item.name,
|
275
|
+
"data-id": item.key
|
276
|
+
}, (0, _react2.jsx)(_index.MultiselectFilterItem, {
|
277
|
+
text: item.name,
|
278
|
+
icon: _FilterIcon["default"]
|
279
|
+
}));
|
280
|
+
})))));
|
281
|
+
};
|
282
|
+
|
283
|
+
exports.MultiselectWithBadge = MultiselectWithBadge;
|
@@ -0,0 +1,83 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
4
|
+
|
5
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
6
|
+
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
8
|
+
|
9
|
+
var _testAxe = _interopRequireDefault(require("../../utils/testUtils/testAxe"));
|
10
|
+
|
11
|
+
var _testWrapper = require("../../utils/testUtils/testWrapper");
|
12
|
+
|
13
|
+
var _MultiselectFilter = _interopRequireDefault(require("./MultiselectFilter"));
|
14
|
+
|
15
|
+
var _react2 = require("@emotion/react");
|
16
|
+
|
17
|
+
var testId = 'multiselect-filter-item';
|
18
|
+
var onSelectionChange = jest.fn();
|
19
|
+
var defaultProps = {
|
20
|
+
'data-testid': testId,
|
21
|
+
isOpen: true,
|
22
|
+
items: [{
|
23
|
+
name: 'item name'
|
24
|
+
}],
|
25
|
+
listTitle: 'Selected Groups',
|
26
|
+
selectedFilterCount: 8,
|
27
|
+
onSelectionChange: onSelectionChange
|
28
|
+
};
|
29
|
+
|
30
|
+
var getComponent = function getComponent() {
|
31
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
32
|
+
return (0, _testWrapper.render)((0, _react2.jsx)(_MultiselectFilter["default"], (0, _extends2["default"])({}, defaultProps, props)));
|
33
|
+
};
|
34
|
+
|
35
|
+
beforeAll(function () {
|
36
|
+
jest.spyOn(window.HTMLElement.prototype, 'clientWidth', 'get').mockImplementation(function () {
|
37
|
+
return 1000;
|
38
|
+
});
|
39
|
+
jest.spyOn(window.HTMLElement.prototype, 'clientHeight', 'get').mockImplementation(function () {
|
40
|
+
return 1000;
|
41
|
+
});
|
42
|
+
window.HTMLElement.prototype.scrollIntoView = jest.fn();
|
43
|
+
jest.spyOn(window.screen, 'width', 'get').mockImplementation(function () {
|
44
|
+
return 1024;
|
45
|
+
});
|
46
|
+
jest.spyOn(window, 'requestAnimationFrame').mockImplementation(function (cb) {
|
47
|
+
return cb();
|
48
|
+
});
|
49
|
+
});
|
50
|
+
afterEach(function () {
|
51
|
+
jest.clearAllMocks();
|
52
|
+
onSelectionChange.mockClear();
|
53
|
+
});
|
54
|
+
afterAll(function () {
|
55
|
+
jest.restoreAllMocks();
|
56
|
+
}); // Need to be added to each test file to test accessibility using axe.
|
57
|
+
|
58
|
+
(0, _testAxe["default"])(getComponent, {
|
59
|
+
rules: {
|
60
|
+
'aria-required-children': {
|
61
|
+
enabled: false
|
62
|
+
},
|
63
|
+
'aria-required-parent': {
|
64
|
+
enabled: false
|
65
|
+
}
|
66
|
+
}
|
67
|
+
});
|
68
|
+
test('default multiselectFilter', function () {
|
69
|
+
getComponent();
|
70
|
+
|
71
|
+
var multiselectFilter = _testWrapper.screen.getByTestId(testId);
|
72
|
+
|
73
|
+
expect(multiselectFilter).toBeInTheDocument();
|
74
|
+
});
|
75
|
+
test('custom classname can be passed', function () {
|
76
|
+
getComponent({
|
77
|
+
className: 'testing-class'
|
78
|
+
});
|
79
|
+
|
80
|
+
var multiselectFilter = _testWrapper.screen.getByTestId(testId);
|
81
|
+
|
82
|
+
expect(multiselectFilter).toHaveClass('testing-class');
|
83
|
+
});
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
4
|
+
|
5
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
6
|
+
|
7
|
+
_Object$defineProperty(exports, "__esModule", {
|
8
|
+
value: true
|
9
|
+
});
|
10
|
+
|
11
|
+
_Object$defineProperty(exports, "default", {
|
12
|
+
enumerable: true,
|
13
|
+
get: function get() {
|
14
|
+
return _MultiselectFilter["default"];
|
15
|
+
}
|
16
|
+
});
|
17
|
+
|
18
|
+
var _MultiselectFilter = _interopRequireDefault(require("./MultiselectFilter"));
|