@pingux/astro 1.7.0-alpha.11 → 1.7.0-alpha.14
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/AstroWrapper/AstroWrapper.js +4 -4
- package/lib/cjs/components/ComboBoxField/ComboBoxField.js +1 -1
- package/lib/cjs/components/ComboBoxField/ComboBoxField.test.js +8 -4
- package/lib/cjs/components/ListViewItem/ListViewItem.js +2 -1
- package/lib/cjs/components/MultiselectFilter/MultiselectFilter.js +1 -1
- package/lib/cjs/components/MultiselectFilterItem/MultiselectFilterItem.js +32 -11
- package/lib/cjs/components/MultiselectFilterItem/MultiselectFilterItem.test.js +13 -1
- package/lib/cjs/components/TimeZonePicker/TimeZonePicker.js +21 -10
- package/lib/cjs/recipes/MultiselectListContainer.stories.js +352 -0
- package/lib/cjs/styles/variants/boxes.js +2 -2
- package/lib/cjs/styles/variants/multiselectListContainer.js +4 -6
- package/lib/components/AstroWrapper/AstroWrapper.js +4 -4
- package/lib/components/ComboBoxField/ComboBoxField.js +1 -1
- package/lib/components/ComboBoxField/ComboBoxField.test.js +8 -4
- package/lib/components/ListViewItem/ListViewItem.js +2 -1
- package/lib/components/MultiselectFilter/MultiselectFilter.js +1 -1
- package/lib/components/MultiselectFilterItem/MultiselectFilterItem.js +35 -12
- package/lib/components/MultiselectFilterItem/MultiselectFilterItem.test.js +11 -1
- package/lib/components/TimeZonePicker/TimeZonePicker.js +21 -10
- package/lib/recipes/MultiselectListContainer.stories.js +306 -0
- package/lib/styles/variants/boxes.js +2 -2
- package/lib/styles/variants/multiselectListContainer.js +4 -6
- package/package.json +1 -1
@@ -28,10 +28,20 @@ test('default multiselectFilter', function () {
|
|
28
28
|
expect(icon).not.toBeInTheDocument();
|
29
29
|
expect(multiselectFilterItem).toBeInTheDocument();
|
30
30
|
});
|
31
|
-
test('icon displays when icon prop is present', function () {
|
31
|
+
test('icon button displays when icon prop is present', function () {
|
32
32
|
getComponent({
|
33
33
|
icon: FilterIcon
|
34
34
|
});
|
35
35
|
var icon = screen.getByTestId(iconId);
|
36
36
|
expect(icon).toBeInTheDocument();
|
37
|
+
expect(icon.parentElement).toBeInstanceOf(HTMLButtonElement);
|
38
|
+
});
|
39
|
+
test('icon displays when icon prop is present and default selected', function () {
|
40
|
+
getComponent({
|
41
|
+
icon: FilterIcon,
|
42
|
+
isDefaultSelected: true
|
43
|
+
});
|
44
|
+
var icon = screen.getByTestId(iconId);
|
45
|
+
expect(icon).toBeInTheDocument();
|
46
|
+
expect(icon.parentElement).not.toBeInstanceOf(HTMLButtonElement);
|
37
47
|
});
|
@@ -146,16 +146,16 @@ var TimeZonePicker = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
146
146
|
return aNum - bNum;
|
147
147
|
};
|
148
148
|
|
149
|
-
var
|
150
|
-
|
149
|
+
var checkIsSelectedItem = function checkIsSelectedItem() {
|
150
|
+
return _filterInstanceProperty(timeZones).call(timeZones, function (tz) {
|
151
|
+
return tz.timeZone === search;
|
152
|
+
}).length > 0;
|
153
|
+
};
|
151
154
|
|
152
|
-
|
153
|
-
|
154
|
-
key: emptySearchText
|
155
|
-
}, emptySearchText);
|
156
|
-
}
|
155
|
+
var renderTimeZones = function renderTimeZones(timeZonesToRender) {
|
156
|
+
var _context7;
|
157
157
|
|
158
|
-
return _mapInstanceProperty(_context7 = _sortInstanceProperty(
|
158
|
+
return _mapInstanceProperty(_context7 = _sortInstanceProperty(timeZonesToRender).call(timeZonesToRender, sortByGMT)).call(_context7, function (_ref4) {
|
159
159
|
var gmt = _ref4.gmt,
|
160
160
|
time = _ref4.time,
|
161
161
|
timeZone = _ref4.timeZone;
|
@@ -177,7 +177,17 @@ var TimeZonePicker = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
177
177
|
variant: "timeZone.time"
|
178
178
|
}, time))));
|
179
179
|
});
|
180
|
-
}
|
180
|
+
};
|
181
|
+
|
182
|
+
var items = useMemo(function () {
|
183
|
+
if (filteredTimezones.length === 0) {
|
184
|
+
return ___EmotionJSX(Item, {
|
185
|
+
key: emptySearchText
|
186
|
+
}, emptySearchText);
|
187
|
+
}
|
188
|
+
|
189
|
+
return renderTimeZones(checkIsSelectedItem() ? timeZones : filteredTimezones);
|
190
|
+
}, [emptySearchText, filteredTimezones, search, timeZones]);
|
181
191
|
var comboBoxFieldProps = useMemo(function () {
|
182
192
|
return _objectSpread({
|
183
193
|
controlProps: {
|
@@ -198,7 +208,8 @@ var TimeZonePicker = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
198
208
|
}, otherProps);
|
199
209
|
}, [emptySearchText, filteredTimezones, otherProps]);
|
200
210
|
return ___EmotionJSX(ComboBoxField, _extends({}, comboBoxFieldProps, {
|
201
|
-
disabledKeys: [emptySearchText]
|
211
|
+
disabledKeys: [emptySearchText],
|
212
|
+
menuTrigger: "focus"
|
202
213
|
}), items);
|
203
214
|
});
|
204
215
|
TimeZonePicker.propTypes = {
|
@@ -0,0 +1,306 @@
|
|
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 _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
7
|
+
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
8
|
+
import _someInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/some";
|
9
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
10
|
+
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
11
|
+
import _sortInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/sort";
|
12
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
13
|
+
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
14
|
+
|
15
|
+
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; }
|
16
|
+
|
17
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
18
|
+
|
19
|
+
import React, { useMemo, useState } from 'react';
|
20
|
+
import { useFilter } from '@react-aria/i18n';
|
21
|
+
import AccountIcon from 'mdi-react/AccountIcon';
|
22
|
+
import AccountGroupIcon from 'mdi-react/AccountGroupIcon';
|
23
|
+
import CheckIcon from 'mdi-react/CheckIcon';
|
24
|
+
import Clear from 'mdi-react/CloseIcon';
|
25
|
+
import ChevronRightIcon from 'mdi-react/ChevronRightIcon';
|
26
|
+
import SearchIcon from 'mdi-react/SearchIcon';
|
27
|
+
import { Breadcrumbs, Box, CheckboxField, Chip, Icon, IconButton, Item, ListView, MultiselectFilter, MultiselectFilterItem, SearchField, Text } from '..';
|
28
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
29
|
+
export default {
|
30
|
+
title: 'Recipes/MultiselectListContainer'
|
31
|
+
};
|
32
|
+
var data = [{
|
33
|
+
id: '1',
|
34
|
+
icon: 'Group',
|
35
|
+
key: 'Avengers',
|
36
|
+
name: 'Avengers',
|
37
|
+
subtitle: 'Default',
|
38
|
+
chipValue: '25',
|
39
|
+
isDefaultSelected: true
|
40
|
+
}, {
|
41
|
+
id: '2',
|
42
|
+
icon: 'Group',
|
43
|
+
key: 'Credit Cards',
|
44
|
+
name: 'Credit Cards',
|
45
|
+
subtitle: '',
|
46
|
+
chipValue: '123'
|
47
|
+
}, {
|
48
|
+
id: '3',
|
49
|
+
icon: 'Group',
|
50
|
+
key: 'Debit Cards',
|
51
|
+
name: 'Debit Cards',
|
52
|
+
subtitle: '',
|
53
|
+
chipValue: '23'
|
54
|
+
}, {
|
55
|
+
id: '4',
|
56
|
+
icon: 'Group',
|
57
|
+
key: 'Digital Investors',
|
58
|
+
name: 'Digital Investors',
|
59
|
+
subtitle: 'N America',
|
60
|
+
chipValue: '12',
|
61
|
+
isDefaultSelected: true
|
62
|
+
}, {
|
63
|
+
id: '5',
|
64
|
+
icon: 'Group',
|
65
|
+
key: 'Mortgages',
|
66
|
+
name: 'Mortgages',
|
67
|
+
subtitle: 'N America',
|
68
|
+
chipValue: '112'
|
69
|
+
}, {
|
70
|
+
id: '6',
|
71
|
+
icon: 'Group',
|
72
|
+
key: 'Person LOC',
|
73
|
+
name: 'Person LOC',
|
74
|
+
subtitle: '',
|
75
|
+
chipValue: '45'
|
76
|
+
}, {
|
77
|
+
id: '7',
|
78
|
+
icon: 'Group',
|
79
|
+
key: 'Production',
|
80
|
+
name: 'Production',
|
81
|
+
subtitle: '',
|
82
|
+
chipValue: '55'
|
83
|
+
}, {
|
84
|
+
id: '8',
|
85
|
+
icon: 'Group',
|
86
|
+
key: 'UX Team',
|
87
|
+
name: 'UX Team',
|
88
|
+
subtitle: '',
|
89
|
+
chipValue: '61'
|
90
|
+
}, {
|
91
|
+
id: '9',
|
92
|
+
icon: 'Group',
|
93
|
+
key: 'UI Team',
|
94
|
+
name: 'UI Team',
|
95
|
+
subtitle: '',
|
96
|
+
chipValue: '29'
|
97
|
+
}];
|
98
|
+
export var Default = function Default() {
|
99
|
+
var _useState = useState(data),
|
100
|
+
_useState2 = _slicedToArray(_useState, 2),
|
101
|
+
items = _useState2[0],
|
102
|
+
setItems = _useState2[1];
|
103
|
+
|
104
|
+
var _useState3 = useState(''),
|
105
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
106
|
+
searchValue = _useState4[0],
|
107
|
+
setSearchValue = _useState4[1];
|
108
|
+
|
109
|
+
var _useFilter = useFilter({
|
110
|
+
sensitivity: 'base'
|
111
|
+
}),
|
112
|
+
contains = _useFilter.contains;
|
113
|
+
|
114
|
+
var filteredItems = useMemo(function () {
|
115
|
+
return _filterInstanceProperty(items).call(items, function (item) {
|
116
|
+
return contains(item.name, searchValue);
|
117
|
+
});
|
118
|
+
}, [items, searchValue]);
|
119
|
+
var selectedItems = useMemo(function () {
|
120
|
+
var _context;
|
121
|
+
|
122
|
+
return _sortInstanceProperty(_context = _filterInstanceProperty(items).call(items, function (item) {
|
123
|
+
return item.isDefaultSelected || item.isSelected;
|
124
|
+
}) // sort elements to display "default selected" at first place
|
125
|
+
).call(_context, function (a, b) {
|
126
|
+
return Number(!!b.isDefaultSelected) - Number(!!a.isDefaultSelected);
|
127
|
+
});
|
128
|
+
}, [items]);
|
129
|
+
|
130
|
+
var changeSelection = function changeSelection(key) {
|
131
|
+
setItems(function (prevItems) {
|
132
|
+
return _mapInstanceProperty(prevItems).call(prevItems, function (el) {
|
133
|
+
if (el.key === key) {
|
134
|
+
return _objectSpread(_objectSpread({}, el), {}, {
|
135
|
+
isSelected: !el.isSelected
|
136
|
+
});
|
137
|
+
}
|
138
|
+
|
139
|
+
return el;
|
140
|
+
});
|
141
|
+
});
|
142
|
+
};
|
143
|
+
|
144
|
+
return ___EmotionJSX(Box, null, ___EmotionJSX(Box, {
|
145
|
+
sx: {
|
146
|
+
minHeight: '60px'
|
147
|
+
},
|
148
|
+
bg: "accent.99"
|
149
|
+
}, ___EmotionJSX(Box, {
|
150
|
+
isRow: true,
|
151
|
+
flexBasis: "0px",
|
152
|
+
flexGrow: "1",
|
153
|
+
alignItems: "center",
|
154
|
+
pl: "md",
|
155
|
+
pr: "md",
|
156
|
+
justifyContent: "space-between",
|
157
|
+
zIndex: 2
|
158
|
+
}, ___EmotionJSX(Box, {
|
159
|
+
isRow: true
|
160
|
+
}, ___EmotionJSX(Icon, {
|
161
|
+
icon: AccountIcon,
|
162
|
+
alignSelf: "center",
|
163
|
+
mr: "md",
|
164
|
+
color: "accent.40",
|
165
|
+
size: 25,
|
166
|
+
flexShrink: 0,
|
167
|
+
display: "flex"
|
168
|
+
}), ___EmotionJSX(Breadcrumbs, {
|
169
|
+
icon: ChevronRightIcon
|
170
|
+
}, ___EmotionJSX(Item, {
|
171
|
+
key: "home",
|
172
|
+
variant: "link",
|
173
|
+
"data-id": "home"
|
174
|
+
}, "Ed Nepomuceno"), ___EmotionJSX(Item, {
|
175
|
+
key: "editGroups",
|
176
|
+
variant: "neutralText",
|
177
|
+
"data-id": "editGroups"
|
178
|
+
}, "Edit Groups"))), ___EmotionJSX(Box, {
|
179
|
+
isRow: true
|
180
|
+
}, ___EmotionJSX(IconButton, {
|
181
|
+
"aria-label": "Close Panel"
|
182
|
+
}, ___EmotionJSX(Icon, {
|
183
|
+
icon: Clear,
|
184
|
+
size: 20
|
185
|
+
}))))), ___EmotionJSX(Box, {
|
186
|
+
pl: "md",
|
187
|
+
pt: "25px"
|
188
|
+
}, ___EmotionJSX(Box, {
|
189
|
+
isRow: true,
|
190
|
+
justifyContent: "space-between"
|
191
|
+
}, ___EmotionJSX(Box, {
|
192
|
+
width: "100%"
|
193
|
+
}, ___EmotionJSX(SearchField, {
|
194
|
+
icon: SearchIcon,
|
195
|
+
"aria-label": "Search",
|
196
|
+
placeholder: "Search",
|
197
|
+
width: "100%",
|
198
|
+
mt: "0px",
|
199
|
+
mr: "sm",
|
200
|
+
onChange: setSearchValue
|
201
|
+
}), ___EmotionJSX(ListView, {
|
202
|
+
items: filteredItems,
|
203
|
+
style: {
|
204
|
+
width: '100%',
|
205
|
+
outline: 'none'
|
206
|
+
}
|
207
|
+
}, function (item) {
|
208
|
+
return ___EmotionJSX(Item, {
|
209
|
+
key: item.key,
|
210
|
+
textValue: item.name,
|
211
|
+
"data-id": item.key,
|
212
|
+
listItemProps: {
|
213
|
+
isRow: true,
|
214
|
+
sx: {
|
215
|
+
bg: 'white',
|
216
|
+
width: '100%',
|
217
|
+
justifyContent: 'space-between',
|
218
|
+
alignItems: 'center',
|
219
|
+
'&.is-hovered': {
|
220
|
+
bg: 'accent.99'
|
221
|
+
}
|
222
|
+
}
|
223
|
+
}
|
224
|
+
}, ___EmotionJSX(Box, {
|
225
|
+
isRow: true
|
226
|
+
}, ___EmotionJSX(Icon, {
|
227
|
+
icon: AccountGroupIcon,
|
228
|
+
alignSelf: "center",
|
229
|
+
mr: "md",
|
230
|
+
color: "accent.40",
|
231
|
+
size: 25,
|
232
|
+
flexShrink: 1
|
233
|
+
}), ___EmotionJSX(Box, null, ___EmotionJSX(Box, {
|
234
|
+
isRow: true
|
235
|
+
}, ___EmotionJSX(Text, {
|
236
|
+
variant: "listTitle",
|
237
|
+
mb: "xs",
|
238
|
+
mr: "xs"
|
239
|
+
}, item.name), ___EmotionJSX(Chip, {
|
240
|
+
label: item.chipValue,
|
241
|
+
bg: "accent.99",
|
242
|
+
textColor: "text.secondary",
|
243
|
+
sx: {
|
244
|
+
minWidth: 'max-content'
|
245
|
+
}
|
246
|
+
})), ___EmotionJSX(Text, {
|
247
|
+
variant: "listSubtitle"
|
248
|
+
}, item.subtitle))), item.isDefaultSelected ? ___EmotionJSX(Box, {
|
249
|
+
isRow: true,
|
250
|
+
sx: {
|
251
|
+
border: '1px solid',
|
252
|
+
borderColor: 'neutral.80',
|
253
|
+
borderRadius: 5,
|
254
|
+
minHeight: 22,
|
255
|
+
justifyContent: 'center',
|
256
|
+
alignItems: 'center',
|
257
|
+
p: 'xs',
|
258
|
+
maxWidth: '50%'
|
259
|
+
}
|
260
|
+
}, ___EmotionJSX(Icon, {
|
261
|
+
icon: CheckIcon,
|
262
|
+
color: "neutral.20",
|
263
|
+
size: 13,
|
264
|
+
sx: {
|
265
|
+
flexShrink: 0
|
266
|
+
}
|
267
|
+
}), ___EmotionJSX(Text, {
|
268
|
+
sx: {
|
269
|
+
fontSize: 'sm',
|
270
|
+
pl: 'xs',
|
271
|
+
maxHeight: 32,
|
272
|
+
overflow: 'hidden'
|
273
|
+
}
|
274
|
+
}, "Added by Filter")) : ___EmotionJSX(CheckboxField, {
|
275
|
+
controlProps: {
|
276
|
+
color: 'neutral.10',
|
277
|
+
'aria-label': 'Select'
|
278
|
+
},
|
279
|
+
onChange: function onChange() {
|
280
|
+
return changeSelection(item.key);
|
281
|
+
},
|
282
|
+
isSelected: _someInstanceProperty(selectedItems).call(selectedItems, function (el) {
|
283
|
+
return el.key === item.key;
|
284
|
+
})
|
285
|
+
}));
|
286
|
+
})), ___EmotionJSX(MultiselectFilter, {
|
287
|
+
items: selectedItems,
|
288
|
+
selectedFilterCount: selectedItems.length.toString(),
|
289
|
+
listTitle: "Selected Groups",
|
290
|
+
openAriaLabel: "Open filter menu?",
|
291
|
+
closeAriaLabel: "Close filter menu?"
|
292
|
+
}, function (item) {
|
293
|
+
return ___EmotionJSX(Item, {
|
294
|
+
key: item.key,
|
295
|
+
textValue: item.name,
|
296
|
+
"data-id": item.key
|
297
|
+
}, ___EmotionJSX(MultiselectFilterItem, {
|
298
|
+
text: item.name,
|
299
|
+
icon: item.isDefaultSelected ? CheckIcon : Clear,
|
300
|
+
isDefaultSelected: item.isDefaultSelected,
|
301
|
+
onPress: function onPress() {
|
302
|
+
return changeSelection(item.key);
|
303
|
+
}
|
304
|
+
}));
|
305
|
+
}))));
|
306
|
+
};
|
@@ -61,7 +61,6 @@ var listItem = _objectSpread(_objectSpread({}, base), {}, {
|
|
61
61
|
var listViewItem = _objectSpread(_objectSpread({}, base), {}, {
|
62
62
|
padding: '0px 15px 0px 25px',
|
63
63
|
flex: '1 1 0px',
|
64
|
-
cursor: 'pointer',
|
65
64
|
minHeight: '80px',
|
66
65
|
justifyContent: 'center',
|
67
66
|
bg: 'accent.99',
|
@@ -70,7 +69,8 @@ var listViewItem = _objectSpread(_objectSpread({}, base), {}, {
|
|
70
69
|
bg: 'white'
|
71
70
|
},
|
72
71
|
'&.is-hovered': {
|
73
|
-
bg: 'white'
|
72
|
+
bg: 'white',
|
73
|
+
cursor: 'pointer'
|
74
74
|
},
|
75
75
|
'&.is-focused': {
|
76
76
|
boxShadow: 'inset 0 0 5px #5873bdbf'
|
@@ -1,11 +1,8 @@
|
|
1
1
|
var multiselectListContainer = {
|
2
|
-
height: '40px',
|
3
2
|
overflowX: 'hidden',
|
4
3
|
pr: 'sm',
|
5
4
|
transition: 'right 500ms',
|
6
|
-
'
|
7
|
-
height: '100%'
|
8
|
-
}
|
5
|
+
minHeight: '80vh'
|
9
6
|
};
|
10
7
|
var multiselectListContent = {
|
11
8
|
bg: 'accent.99',
|
@@ -22,7 +19,8 @@ var multiselectListContent = {
|
|
22
19
|
display: 'flex',
|
23
20
|
minHeight: '45px',
|
24
21
|
padding: '3px',
|
25
|
-
width: '100%'
|
22
|
+
width: '100%',
|
23
|
+
justifyContent: 'space-between'
|
26
24
|
}
|
27
25
|
};
|
28
26
|
var multiselectListTitle = {
|
@@ -35,7 +33,7 @@ var multiselectListTitle = {
|
|
35
33
|
padding: '0 10px !important',
|
36
34
|
flexWrap: 'wrap',
|
37
35
|
maxWidth: 'max-content !important',
|
38
|
-
margin: '0
|
36
|
+
margin: '0'
|
39
37
|
};
|
40
38
|
var multiselectListBadge = {
|
41
39
|
borderRadius: '5px',
|