@pingux/astro 1.4.2-alpha.1 → 1.5.0-alpha.2

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.
Files changed (65) hide show
  1. package/lib/cjs/components/CodeView/CodeView.js +1 -1
  2. package/lib/cjs/components/CodeView/CodeView.test.js +22 -27
  3. package/lib/cjs/components/CopyText/CopyText.js +1 -1
  4. package/lib/cjs/components/ListView/ListView.js +12 -13
  5. package/lib/cjs/components/ListView/ListView.test.js +8 -8
  6. package/lib/cjs/components/ListViewItem/ListViewItem.js +0 -2
  7. package/lib/cjs/components/MultiselectFilter/MultiselectFilter.js +143 -0
  8. package/lib/cjs/components/MultiselectFilter/MultiselectFilter.stories.js +283 -0
  9. package/lib/cjs/components/MultiselectFilter/MultiselectFilter.test.js +83 -0
  10. package/lib/cjs/components/MultiselectFilter/index.js +18 -0
  11. package/lib/cjs/components/MultiselectFilterItem/MultiselectFilterItem.js +55 -0
  12. package/lib/cjs/components/MultiselectFilterItem/MultiselectFilterItem.test.js +53 -0
  13. package/lib/cjs/components/MultiselectFilterItem/index.js +18 -0
  14. package/lib/cjs/components/MultiselectListContainer/MultiselectBadge.js +47 -0
  15. package/lib/cjs/components/MultiselectListContainer/MultiselectBadge.test.js +48 -0
  16. package/lib/cjs/components/MultiselectListContainer/MultiselectListContainer.js +157 -0
  17. package/lib/cjs/components/MultiselectListContainer/MultiselectListContainer.test.js +112 -0
  18. package/lib/cjs/components/MultiselectListContainer/index.js +18 -0
  19. package/lib/cjs/components/PopoverMenu/PopoverMenu.js +7 -2
  20. package/lib/cjs/components/Tab/Tab.js +22 -15
  21. package/lib/cjs/components/TabPicker/TabPicker.js +239 -0
  22. package/lib/cjs/components/TabPicker/index.js +18 -0
  23. package/lib/cjs/components/Tabs/Tabs.js +46 -13
  24. package/lib/cjs/components/Tabs/Tabs.stories.js +32 -2
  25. package/lib/cjs/components/Tabs/Tabs.test.js +183 -32
  26. package/lib/cjs/index.js +98 -32
  27. package/lib/cjs/styles/variants/buttons.js +38 -1
  28. package/lib/cjs/styles/variants/codeView.js +2 -1
  29. package/lib/cjs/styles/variants/multiselectListContainer.js +73 -0
  30. package/lib/cjs/styles/variants/tabs.js +5 -1
  31. package/lib/cjs/styles/variants/text.js +29 -2
  32. package/lib/cjs/styles/variants/variants.js +3 -0
  33. package/lib/components/CodeView/CodeView.js +1 -1
  34. package/lib/components/CodeView/CodeView.test.js +22 -23
  35. package/lib/components/CopyText/CopyText.js +1 -1
  36. package/lib/components/ListView/ListView.js +12 -13
  37. package/lib/components/ListView/ListView.test.js +8 -8
  38. package/lib/components/ListViewItem/ListViewItem.js +0 -2
  39. package/lib/components/MultiselectFilter/MultiselectFilter.js +118 -0
  40. package/lib/components/MultiselectFilter/MultiselectFilter.stories.js +251 -0
  41. package/lib/components/MultiselectFilter/MultiselectFilter.test.js +69 -0
  42. package/lib/components/MultiselectFilter/index.js +1 -0
  43. package/lib/components/MultiselectFilterItem/MultiselectFilterItem.js +36 -0
  44. package/lib/components/MultiselectFilterItem/MultiselectFilterItem.test.js +37 -0
  45. package/lib/components/MultiselectFilterItem/index.js +1 -0
  46. package/lib/components/MultiselectListContainer/MultiselectBadge.js +31 -0
  47. package/lib/components/MultiselectListContainer/MultiselectBadge.test.js +34 -0
  48. package/lib/components/MultiselectListContainer/MultiselectListContainer.js +123 -0
  49. package/lib/components/MultiselectListContainer/MultiselectListContainer.test.js +81 -0
  50. package/lib/components/MultiselectListContainer/index.js +1 -0
  51. package/lib/components/PopoverMenu/PopoverMenu.js +7 -2
  52. package/lib/components/Tab/Tab.js +14 -8
  53. package/lib/components/TabPicker/TabPicker.js +210 -0
  54. package/lib/components/TabPicker/index.js +1 -0
  55. package/lib/components/Tabs/Tabs.js +44 -11
  56. package/lib/components/Tabs/Tabs.stories.js +27 -0
  57. package/lib/components/Tabs/Tabs.test.js +165 -32
  58. package/lib/index.js +6 -0
  59. package/lib/styles/variants/buttons.js +38 -1
  60. package/lib/styles/variants/codeView.js +2 -1
  61. package/lib/styles/variants/multiselectListContainer.js +63 -0
  62. package/lib/styles/variants/tabs.js +5 -1
  63. package/lib/styles/variants/text.js +29 -2
  64. package/lib/styles/variants/variants.js +2 -0
  65. package/package.json +1 -1
@@ -140,7 +140,7 @@ var CodeView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
140
140
  }
141
141
 
142
142
  return (0, _react2.jsx)(_.CopyText, {
143
- mode: "nonClickableContent",
143
+ mode: "link",
144
144
  textToCopy: children,
145
145
  tooltipProps: {
146
146
  offset: 15
@@ -57,8 +57,21 @@ var textValue = "\nexport const Default = args => (\n <>\n <Text sx={{ fontW
57
57
  var getComponent = function getComponent() {
58
58
  var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
59
59
  return (0, _testWrapper.render)((0, _react2.jsx)(_.CodeView, (0, _extends2["default"])({}, defaultProps, props), textValue));
60
- }; // Need to be added to each test file to test accessibility using axe.
60
+ };
61
61
 
62
+ beforeEach(function () {
63
+ var mockClipboard = {
64
+ writeText: jest.fn()
65
+ };
66
+ global.navigator.clipboard = mockClipboard;
67
+ global.document.execCommand = jest.fn();
68
+ global.document.execCommand.mockReturnValue(true);
69
+ });
70
+ afterEach(function () {
71
+ jest.resetAllMocks();
72
+ global.navigator.clipboard = originalClipboard;
73
+ global.document.execCommand = originalExecCommand;
74
+ }); // Need to be added to each test file to test accessibility using axe.
62
75
 
63
76
  (0, _testAxe["default"])(getComponent);
64
77
  test('renders component in the default state', function () {
@@ -69,29 +82,22 @@ test('renders component in the default state', function () {
69
82
  expect(container).toBeInstanceOf(HTMLDivElement);
70
83
  expect(container).toBeInTheDocument();
71
84
  });
72
- test('tooltip renders on hover', function () {
85
+ test('copy button is hovered and renders tooltip via mouse', function () {
73
86
  getComponent();
74
87
 
75
- var container = _testWrapper.screen.getByTestId(testId);
88
+ var copyBtn = _testWrapper.screen.getByLabelText('copy');
76
89
 
77
- _testWrapper.fireEvent.mouseMove(container);
90
+ expect(copyBtn).not.toHaveFocus();
78
91
 
79
- _testWrapper.fireEvent.mouseEnter(container);
92
+ _userEvent["default"].hover(copyBtn);
80
93
 
94
+ expect(copyBtn).toHaveClass('is-hovered');
81
95
  expect(_testWrapper.screen.queryByRole('tooltip')).toBeInTheDocument();
82
96
  expect(_testWrapper.screen.queryByRole('tooltip')).toHaveTextContent('Copy to clipboard');
83
97
  });
84
- test('content and copy button are focused via keyboard', function () {
98
+ test('copy button is focused and renders tooltip via keyboard', function () {
85
99
  getComponent();
86
100
 
87
- var container = _testWrapper.screen.getByTestId(testId);
88
-
89
- expect(container).not.toHaveFocus();
90
-
91
- _userEvent["default"].tab();
92
-
93
- expect(container).toHaveFocus();
94
-
95
101
  var copyBtn = _testWrapper.screen.getByLabelText('copy');
96
102
 
97
103
  expect(copyBtn).not.toHaveFocus();
@@ -100,6 +106,8 @@ test('content and copy button are focused via keyboard', function () {
100
106
 
101
107
  expect(copyBtn).toHaveFocus();
102
108
  expect(copyBtn).toHaveClass('is-focused');
109
+ expect(_testWrapper.screen.queryByRole('tooltip')).toBeInTheDocument();
110
+ expect(_testWrapper.screen.queryByRole('tooltip')).toHaveTextContent('Copy to clipboard');
103
111
  });
104
112
  test('doesn\'t render copy button and tooltip with prop hasNoCopyButton', function () {
105
113
  getComponent({
@@ -126,19 +134,6 @@ test('renders line numbers with prop hasLineNumbers', function () {
126
134
  expect(_testWrapper.screen.queryByText('1')).toBeInTheDocument();
127
135
  expect(_testWrapper.screen.queryByText(linesLength)).toBeInTheDocument();
128
136
  });
129
- beforeEach(function () {
130
- var mockClipboard = {
131
- writeText: jest.fn()
132
- };
133
- global.navigator.clipboard = mockClipboard;
134
- global.document.execCommand = jest.fn();
135
- global.document.execCommand.mockReturnValue(true);
136
- });
137
- afterEach(function () {
138
- jest.resetAllMocks();
139
- global.navigator.clipboard = originalClipboard;
140
- global.document.execCommand = originalExecCommand;
141
- });
142
137
  test('click on copy button copies data to the clipboard', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
143
138
  var button;
144
139
  return _regenerator["default"].wrap(function _callee2$(_context2) {
@@ -129,7 +129,7 @@ var CopyText = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
129
129
  ref: ref,
130
130
  isRow: true,
131
131
  variant: "boxes.copy"
132
- }, others), content, (0, _react2.jsx)(TooltipWrapper, {
132
+ }, wrapperProps, others), content, (0, _react2.jsx)(TooltipWrapper, {
133
133
  isOpen: isTooltipOpen,
134
134
  tooltip: tooltip
135
135
  }, (0, _react2.jsx)(_CopyButton["default"], (0, _extends2["default"])({
@@ -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 loadingState = props.loadingState,
106
+ var disabledKeys = props.disabledKeys,
107
+ loadingState = props.loadingState,
105
108
  onLoadMore = props.onLoadMore,
106
- selectionStyle = props.selectionStyle;
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 focusedKey = state.selectionManager.focusedKey;
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: 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('listitem');
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('listitem');
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('listitem');
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('listitem');
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('listitem')).not.toBeInTheDocument();
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('listitem');
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('listitem');
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('listitem');
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;