@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
@@ -0,0 +1,123 @@
|
|
1
|
+
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
2
|
+
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
3
|
+
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
4
|
+
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
5
|
+
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
6
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
7
|
+
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
8
|
+
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
9
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
10
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
11
|
+
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
12
|
+
|
13
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); if (enumerableOnly) symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
14
|
+
|
15
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; _forEachInstanceProperty(_context = ownKeys(Object(source), true)).call(_context, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { var _context2; _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
16
|
+
|
17
|
+
import React, { forwardRef } from 'react';
|
18
|
+
import PropTypes from 'prop-types';
|
19
|
+
import ChevronRightIcon from 'mdi-react/ChevronRightIcon';
|
20
|
+
import ChevronLeftIcon from 'mdi-react/ChevronLeftIcon';
|
21
|
+
import { useOverlayTriggerState } from '@react-stately/overlays';
|
22
|
+
import MultiselectBadge from './MultiselectBadge';
|
23
|
+
import { Icon, IconButton, Box } from '../../index';
|
24
|
+
import { useStatusClasses } from '../../hooks';
|
25
|
+
/**
|
26
|
+
* The MultiselectListContainer serves as a wrapper around a list and its associated trigger,
|
27
|
+
* linking the list's open state with the trigger's press state and providing necessary context.
|
28
|
+
*/
|
29
|
+
|
30
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
31
|
+
var MultiselectListContainer = /*#__PURE__*/forwardRef(function (props, ref) {
|
32
|
+
var selectedFilterCount = props.selectedFilterCount,
|
33
|
+
className = props.className,
|
34
|
+
children = props.children,
|
35
|
+
closeAriaLabel = props.closeAriaLabel,
|
36
|
+
isDefaultOpen = props.isDefaultOpen,
|
37
|
+
isOpen = props.isOpen,
|
38
|
+
onOpenChange = props.onOpenChange,
|
39
|
+
openAriaLabel = props.openAriaLabel,
|
40
|
+
others = _objectWithoutProperties(props, ["selectedFilterCount", "className", "children", "closeAriaLabel", "isDefaultOpen", "isOpen", "onOpenChange", "openAriaLabel"]);
|
41
|
+
|
42
|
+
var triggerRef = React.useRef();
|
43
|
+
var state = useOverlayTriggerState({
|
44
|
+
defaultOpen: isDefaultOpen,
|
45
|
+
isOpen: isOpen,
|
46
|
+
onOpenChange: onOpenChange
|
47
|
+
});
|
48
|
+
var close = state.close;
|
49
|
+
|
50
|
+
var _useStatusClasses = useStatusClasses(className, {
|
51
|
+
isOpen: state.isOpen
|
52
|
+
}),
|
53
|
+
classNames = _useStatusClasses.classNames;
|
54
|
+
|
55
|
+
var handleButtonPress = function handleButtonPress() {
|
56
|
+
if (state.isOpen) {
|
57
|
+
close(state, triggerRef, close);
|
58
|
+
} else {
|
59
|
+
state.open();
|
60
|
+
}
|
61
|
+
};
|
62
|
+
|
63
|
+
var handleClose = function handleClose(e) {
|
64
|
+
if (e.key === 'Escape') {
|
65
|
+
close(state, triggerRef, close);
|
66
|
+
}
|
67
|
+
};
|
68
|
+
|
69
|
+
return ___EmotionJSX(Box, _extends({
|
70
|
+
className: classNames,
|
71
|
+
onKeyUp: handleClose,
|
72
|
+
ref: ref,
|
73
|
+
variant: "multiselectListContainer.multiselectListContainer",
|
74
|
+
isRow: true
|
75
|
+
}, others), ___EmotionJSX(IconButton, {
|
76
|
+
isRow: true,
|
77
|
+
"aria-label": state.isOpen ? closeAriaLabel : openAriaLabel,
|
78
|
+
"data-testid": "multiselect-list-button",
|
79
|
+
onPress: handleButtonPress,
|
80
|
+
ref: triggerRef,
|
81
|
+
variant: "multiselectToggle",
|
82
|
+
pr: "sm"
|
83
|
+
}, ___EmotionJSX(Icon, {
|
84
|
+
color: "active",
|
85
|
+
icon: state.isOpen ? ChevronRightIcon : ChevronLeftIcon,
|
86
|
+
role: "button",
|
87
|
+
size: "30px"
|
88
|
+
}), !state.isOpen && selectedFilterCount && ___EmotionJSX(MultiselectBadge, {
|
89
|
+
"data-testid": "multiselect-list-badge",
|
90
|
+
margin: "auto",
|
91
|
+
selectedFilterCount: selectedFilterCount
|
92
|
+
})), state.isOpen && _objectSpread({}, children));
|
93
|
+
});
|
94
|
+
MultiselectListContainer.propTypes = {
|
95
|
+
/** Amount of selected items indicator. */
|
96
|
+
selectedFilterCount: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
97
|
+
|
98
|
+
/** Defines a string value that labels the trigger icon when menu is open. */
|
99
|
+
closeAriaLabel: PropTypes.string,
|
100
|
+
|
101
|
+
/** Sets the default open state of the overlay. */
|
102
|
+
isDefaultOpen: PropTypes.bool,
|
103
|
+
|
104
|
+
/** Whether the overlay is currently open. */
|
105
|
+
isOpen: PropTypes.bool,
|
106
|
+
|
107
|
+
/**
|
108
|
+
* Method that is called when the open state of the menu changes.
|
109
|
+
* Returns the new open state and the action that caused the opening of the menu.
|
110
|
+
*
|
111
|
+
* `(isOpen: boolean, overlayTrigger: OverlayTriggerAction) => void`
|
112
|
+
*/
|
113
|
+
onOpenChange: PropTypes.func,
|
114
|
+
|
115
|
+
/** Defines a string value that labels the trigger icon when menu is closed. */
|
116
|
+
openAriaLabel: PropTypes.string
|
117
|
+
};
|
118
|
+
MultiselectListContainer.defaultProps = {
|
119
|
+
openAriaLabel: 'Open filter menu?',
|
120
|
+
closeAriaLabel: 'Close filter menu?'
|
121
|
+
};
|
122
|
+
MultiselectListContainer.displayName = 'MultiselectListContainer';
|
123
|
+
export default MultiselectListContainer;
|
@@ -0,0 +1,81 @@
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
|
+
import React from 'react';
|
3
|
+
import userEvent from '@testing-library/user-event';
|
4
|
+
import axeTest from '../../utils/testUtils/testAxe';
|
5
|
+
import { render, screen } from '../../utils/testUtils/testWrapper';
|
6
|
+
import MultiselectListContainer from './MultiselectListContainer';
|
7
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
8
|
+
var testId = 'test-multiselectListContainer';
|
9
|
+
var multiselectListBadgeId = 'multiselect-list-badge';
|
10
|
+
var multiselectListButtonId = 'multiselect-list-button';
|
11
|
+
var multiselectFilterId = 'multiselect-filter';
|
12
|
+
var defaultProps = {
|
13
|
+
'data-testid': testId
|
14
|
+
};
|
15
|
+
|
16
|
+
var getComponent = function getComponent() {
|
17
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
18
|
+
return render(___EmotionJSX(MultiselectListContainer, _extends({}, defaultProps, props), ___EmotionJSX("div", {
|
19
|
+
"data-testid": multiselectFilterId
|
20
|
+
})));
|
21
|
+
};
|
22
|
+
|
23
|
+
afterEach(function () {
|
24
|
+
jest.restoreAllMocks();
|
25
|
+
}); // Need to be added to each test file to test accessibility using axe.
|
26
|
+
|
27
|
+
axeTest(getComponent);
|
28
|
+
test('default MultiselectListContainer', function () {
|
29
|
+
getComponent();
|
30
|
+
var multiselectListContainer = screen.getByTestId(testId);
|
31
|
+
expect(multiselectListContainer).toBeInTheDocument();
|
32
|
+
});
|
33
|
+
test('custom classname can be passed', function () {
|
34
|
+
getComponent({
|
35
|
+
className: 'testing-class'
|
36
|
+
});
|
37
|
+
var multiselectListContainer = screen.getByTestId(testId);
|
38
|
+
expect(multiselectListContainer).toHaveClass('testing-class');
|
39
|
+
});
|
40
|
+
test('shows badge when container is closed', function () {
|
41
|
+
getComponent({
|
42
|
+
selectedFilterCount: 9,
|
43
|
+
state: {
|
44
|
+
isOpen: false
|
45
|
+
}
|
46
|
+
});
|
47
|
+
var badge = screen.getByTestId(multiselectListBadgeId);
|
48
|
+
expect(badge).toBeInTheDocument();
|
49
|
+
});
|
50
|
+
test('updates aria label when button is clicked', function () {
|
51
|
+
var state = {
|
52
|
+
isOpen: true
|
53
|
+
};
|
54
|
+
getComponent({
|
55
|
+
state: state
|
56
|
+
});
|
57
|
+
var button = screen.getByTestId(multiselectListButtonId);
|
58
|
+
userEvent.click(button);
|
59
|
+
var multiSelect = screen.queryByTestId(multiselectFilterId);
|
60
|
+
expect(button).toHaveAttribute('aria-label', 'Close filter menu?');
|
61
|
+
expect(multiSelect).toBeInTheDocument();
|
62
|
+
userEvent.click(button);
|
63
|
+
expect(button).toHaveAttribute('aria-label', 'Open filter menu?');
|
64
|
+
expect(multiSelect).not.toBeInTheDocument();
|
65
|
+
});
|
66
|
+
test('shows children when isOpen is true', function () {
|
67
|
+
getComponent({
|
68
|
+
isOpen: true
|
69
|
+
});
|
70
|
+
var multiselectFilter = screen.getByTestId(multiselectFilterId);
|
71
|
+
expect(multiselectFilter).toBeInTheDocument();
|
72
|
+
});
|
73
|
+
test('should hide children when pressing the escape key', function () {
|
74
|
+
getComponent();
|
75
|
+
var button = screen.getByTestId(multiselectListButtonId);
|
76
|
+
userEvent.click(button);
|
77
|
+
var multiSelect = screen.queryByTestId(multiselectFilterId);
|
78
|
+
expect(multiSelect).toBeInTheDocument();
|
79
|
+
userEvent.type(button, '{esc}');
|
80
|
+
expect(multiSelect).not.toBeInTheDocument();
|
81
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './MultiselectListContainer';
|
package/lib/index.js
CHANGED
@@ -72,6 +72,12 @@ export { default as Messages } from './components/Messages';
|
|
72
72
|
export * from './components/Messages';
|
73
73
|
export { default as Modal } from './components/Modal';
|
74
74
|
export * from './components/Modal';
|
75
|
+
export { default as MultiselectFilter } from './components/MultiselectFilter';
|
76
|
+
export * from './components/MultiselectFilter';
|
77
|
+
export { default as MultiselectFilterItem } from './components/MultiselectFilterItem';
|
78
|
+
export * from './components/MultiselectFilterItem';
|
79
|
+
export { default as MultiselectListContainer } from './components/MultiselectListContainer';
|
80
|
+
export * from './components/MultiselectListContainer';
|
75
81
|
export { default as NavBar } from './components/NavBar';
|
76
82
|
export * from './components/NavBar';
|
77
83
|
export { default as NavBarSection } from './components/NavBarSection';
|
@@ -125,6 +125,24 @@ var modalCloseButton = _objectSpread(_objectSpread({}, iconButton), {}, {
|
|
125
125
|
right: 10
|
126
126
|
});
|
127
127
|
|
128
|
+
var multiselectToggle = _objectSpread(_objectSpread({}, square), {}, {
|
129
|
+
bg: 'accent.99',
|
130
|
+
height: '40px',
|
131
|
+
minWidth: 'max-content',
|
132
|
+
pl: '0px',
|
133
|
+
ml: '10px',
|
134
|
+
path: {
|
135
|
+
fill: 'active'
|
136
|
+
},
|
137
|
+
'&.is-hovered': {
|
138
|
+
backgroundColor: 'accent.99'
|
139
|
+
},
|
140
|
+
'&.is-focused': _objectSpread({}, defaultFocus),
|
141
|
+
'&.is-pressed': {
|
142
|
+
backgroundColor: 'accent.99'
|
143
|
+
}
|
144
|
+
});
|
145
|
+
|
128
146
|
var close = _objectSpread(_objectSpread({}, iconButton), {}, {
|
129
147
|
p: 0,
|
130
148
|
ml: 'auto',
|
@@ -461,6 +479,10 @@ var link = _objectSpread(_objectSpread({}, text), {}, {
|
|
461
479
|
width: 'max-content'
|
462
480
|
});
|
463
481
|
|
482
|
+
var neutralText = _objectSpread(_objectSpread({}, link), {}, {
|
483
|
+
color: 'neutral.10'
|
484
|
+
});
|
485
|
+
|
464
486
|
var expandableRow = {
|
465
487
|
chartWrapper: {
|
466
488
|
display: 'flex',
|
@@ -657,5 +679,7 @@ export default {
|
|
657
679
|
tooltipChip: tooltipChip,
|
658
680
|
tooltipIconButton: tooltipIconButton,
|
659
681
|
tooltipInline: tooltipInline,
|
660
|
-
colorBlock: colorBlock
|
682
|
+
colorBlock: colorBlock,
|
683
|
+
multiselectToggle: multiselectToggle,
|
684
|
+
neutralText: neutralText
|
661
685
|
};
|
@@ -0,0 +1,63 @@
|
|
1
|
+
var multiselectListContainer = {
|
2
|
+
height: '40px',
|
3
|
+
overflowX: 'hidden',
|
4
|
+
pr: 'sm',
|
5
|
+
transition: 'right 500ms',
|
6
|
+
'&.is-open': {
|
7
|
+
height: '100%'
|
8
|
+
}
|
9
|
+
};
|
10
|
+
var multiselectListContent = {
|
11
|
+
bg: 'accent.99',
|
12
|
+
fontSize: 'sm',
|
13
|
+
height: '100%',
|
14
|
+
width: '300px',
|
15
|
+
'&.is-focused': {
|
16
|
+
borderColor: 'accent.80',
|
17
|
+
boxShadow: 'focus',
|
18
|
+
outline: 'none'
|
19
|
+
},
|
20
|
+
'& div': {
|
21
|
+
alignItems: 'center',
|
22
|
+
display: 'flex',
|
23
|
+
minHeight: '45px',
|
24
|
+
padding: '3px',
|
25
|
+
width: '100%'
|
26
|
+
}
|
27
|
+
};
|
28
|
+
var multiselectListTitle = {
|
29
|
+
alignContent: 'center',
|
30
|
+
bg: 'accent.99',
|
31
|
+
display: 'flex',
|
32
|
+
fontWeight: '500',
|
33
|
+
minHeight: '40px',
|
34
|
+
alignItems: 'center',
|
35
|
+
padding: '0 10px !important',
|
36
|
+
flexWrap: 'wrap',
|
37
|
+
maxWidth: 'max-content !important',
|
38
|
+
margin: '0 auto'
|
39
|
+
};
|
40
|
+
var multiselectListBadge = {
|
41
|
+
borderRadius: '5px',
|
42
|
+
display: 'flex',
|
43
|
+
height: '17px',
|
44
|
+
justifyContent: 'center',
|
45
|
+
minWidth: 'max-content',
|
46
|
+
position: 'relative',
|
47
|
+
pb: '0px !important',
|
48
|
+
pr: '3px !important',
|
49
|
+
pl: '3px !important',
|
50
|
+
alignItems: 'center',
|
51
|
+
fontWeight: 500
|
52
|
+
};
|
53
|
+
var multiselectFilterItem = {
|
54
|
+
minHeight: '45px',
|
55
|
+
margin: 'auto'
|
56
|
+
};
|
57
|
+
export default {
|
58
|
+
multiselectListContainer: multiselectListContainer,
|
59
|
+
multiselectListContent: multiselectListContent,
|
60
|
+
multiselectListTitle: multiselectListTitle,
|
61
|
+
multiselectListBadge: multiselectListBadge,
|
62
|
+
multiselectFilterItem: multiselectFilterItem
|
63
|
+
};
|
@@ -141,6 +141,26 @@ var navBarHeaderText = _objectSpread(_objectSpread({}, wordWrap), {}, {
|
|
141
141
|
fontWeight: 1
|
142
142
|
});
|
143
143
|
|
144
|
+
var multiselectFilterItem = _objectSpread(_objectSpread({}, wordWrap), {}, {
|
145
|
+
color: 'neutral.30',
|
146
|
+
fontSize: 'sm',
|
147
|
+
fontWeight: 500,
|
148
|
+
overflow: 'hidden',
|
149
|
+
marginRight: 'xs',
|
150
|
+
textOverflow: 'ellipsis',
|
151
|
+
whiteSpace: 'nowrap'
|
152
|
+
});
|
153
|
+
|
154
|
+
var multiselectFilterTitle = _objectSpread(_objectSpread({}, wordWrap), {}, {
|
155
|
+
fontSize: 'sm',
|
156
|
+
fontWeight: 500,
|
157
|
+
color: 'text.secondary',
|
158
|
+
whiteSpace: 'nowrap',
|
159
|
+
overflow: 'hidden',
|
160
|
+
textOverflow: 'ellipsis',
|
161
|
+
mr: 'xs'
|
162
|
+
});
|
163
|
+
|
144
164
|
var maskedValue = {
|
145
165
|
width: 252,
|
146
166
|
wordBreak: 'break-all',
|
@@ -229,6 +249,8 @@ export var text = {
|
|
229
249
|
}),
|
230
250
|
maskedValue: maskedValue,
|
231
251
|
expandableRow: expandableRow,
|
252
|
+
multiselectFilterItem: multiselectFilterItem,
|
253
|
+
multiselectFilterTitle: multiselectFilterTitle,
|
232
254
|
navBarHeaderText: navBarHeaderText,
|
233
255
|
navBarSubtitle: navBarSubtitle,
|
234
256
|
placeholder: {
|
@@ -34,6 +34,7 @@ import stepper from './stepper';
|
|
34
34
|
import table from './table';
|
35
35
|
import * as tabs from './tabs';
|
36
36
|
import tooltip from './tooltip';
|
37
|
+
import multiselectListContainer from './multiselectListContainer';
|
37
38
|
export default _objectSpread(_objectSpread({
|
38
39
|
accordion: accordion,
|
39
40
|
boxes: boxes,
|
@@ -47,6 +48,7 @@ export default _objectSpread(_objectSpread({
|
|
47
48
|
menuItem: menuItem,
|
48
49
|
messages: messages,
|
49
50
|
modal: modal,
|
51
|
+
multiselectListContainer: multiselectListContainer,
|
50
52
|
navBar: navBar,
|
51
53
|
numberField: numberField,
|
52
54
|
overlayPanel: overlayPanel,
|