@pingux/astro 1.7.0-alpha.9 → 1.8.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/lib/cjs/components/AccordionGridGroup/AccordionGridGroup.js +1 -0
- package/lib/cjs/components/AccordionGridItem/AccordionGridItem.js +3 -0
- package/lib/cjs/components/AccordionGridItem/AccordionGridItemBody.js +3 -0
- package/lib/cjs/components/AccordionGridItem/AccordionGridItemHeader.js +10 -4
- package/lib/cjs/components/ArrayField/ArrayField.test.js +13 -0
- package/lib/cjs/components/ArrayField/ArrayFieldDeleteButton.js +3 -8
- package/lib/cjs/components/AstroWrapper/AstroWrapper.js +4 -4
- package/lib/cjs/components/CodeView/CodeView.js +11 -4
- package/lib/cjs/components/CodeView/CodeView.stories.js +33 -2
- package/lib/cjs/components/ComboBoxField/ComboBoxField.js +1 -1
- package/lib/cjs/components/ComboBoxField/ComboBoxField.test.js +8 -4
- package/lib/cjs/components/Image/Image.js +132 -11
- package/lib/cjs/components/Image/Image.stories.js +52 -6
- package/lib/cjs/components/Image/Image.test.js +138 -2
- package/lib/cjs/components/Image/imageConstants.js +13 -0
- package/lib/cjs/components/ImageUploadField/ImageUploadField.test.js +27 -8
- 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/NavBar/NavBar.js +20 -8
- package/lib/cjs/components/NavBar/NavBar.stories.js +3 -2
- package/lib/cjs/components/NavBarSection/NavBarItem.js +1 -1
- package/lib/cjs/components/NavBarSection/NavBarItemButton.js +1 -1
- package/lib/cjs/components/NavBarSection/NavBarItemHeader.js +61 -4
- package/lib/cjs/components/NavBarSection/NavBarItemLink.js +1 -1
- package/lib/cjs/components/NavBarSection/NavBarSection.js +5 -2
- package/lib/cjs/components/NumberField/NumberField.js +32 -2
- package/lib/cjs/components/Text/Text.js +5 -1
- package/lib/cjs/components/Text/Text.stories.js +56 -2
- package/lib/cjs/components/Text/Text.test.js +46 -0
- package/lib/cjs/components/TimeZonePicker/TimeZonePicker.js +21 -10
- package/lib/cjs/hooks/index.js +10 -1
- package/lib/cjs/hooks/useFallbackImage/index.js +18 -0
- package/lib/cjs/hooks/useFallbackImage/useFallbackImage.js +46 -0
- package/lib/cjs/hooks/useFallbackImage/useFallbackImage.test.js +65 -0
- package/lib/cjs/hooks/useNavBarPress/useNavBarPress.js +3 -3
- package/lib/cjs/hooks/useNavBarPress/useNavBarPress.test.js +4 -4
- package/lib/cjs/recipes/MultiselectListContainer.stories.js +352 -0
- package/lib/cjs/styles/variants/accordion.js +1 -1
- package/lib/cjs/styles/variants/boxes.js +2 -2
- package/lib/cjs/styles/variants/multiselectListContainer.js +4 -6
- package/lib/cjs/styles/variants/navBar.js +10 -1
- package/lib/cjs/styles/variants/separator.js +3 -3
- package/lib/cjs/styles/variants/text.js +5 -3
- package/lib/components/AccordionGridGroup/AccordionGridGroup.js +1 -0
- package/lib/components/AccordionGridItem/AccordionGridItem.js +3 -0
- package/lib/components/AccordionGridItem/AccordionGridItemBody.js +3 -0
- package/lib/components/AccordionGridItem/AccordionGridItemHeader.js +10 -4
- package/lib/components/ArrayField/ArrayField.test.js +9 -0
- package/lib/components/ArrayField/ArrayFieldDeleteButton.js +3 -8
- package/lib/components/AstroWrapper/AstroWrapper.js +4 -4
- package/lib/components/CodeView/CodeView.js +12 -5
- package/lib/components/CodeView/CodeView.stories.js +26 -0
- package/lib/components/ComboBoxField/ComboBoxField.js +1 -1
- package/lib/components/ComboBoxField/ComboBoxField.test.js +8 -4
- package/lib/components/Image/Image.js +123 -9
- package/lib/components/Image/Image.stories.js +39 -4
- package/lib/components/Image/Image.test.js +118 -1
- package/lib/components/Image/imageConstants.js +2 -0
- package/lib/components/ImageUploadField/ImageUploadField.test.js +27 -7
- 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/NavBar/NavBar.js +20 -8
- package/lib/components/NavBar/NavBar.stories.js +3 -2
- package/lib/components/NavBarSection/NavBarItem.js +1 -1
- package/lib/components/NavBarSection/NavBarItemButton.js +1 -1
- package/lib/components/NavBarSection/NavBarItemHeader.js +46 -4
- package/lib/components/NavBarSection/NavBarItemLink.js +1 -1
- package/lib/components/NavBarSection/NavBarSection.js +5 -2
- package/lib/components/NumberField/NumberField.js +32 -2
- package/lib/components/Text/Text.js +7 -2
- package/lib/components/Text/Text.stories.js +50 -0
- package/lib/components/Text/Text.test.js +36 -0
- package/lib/components/TimeZonePicker/TimeZonePicker.js +21 -10
- package/lib/hooks/index.js +2 -1
- package/lib/hooks/useFallbackImage/index.js +1 -0
- package/lib/hooks/useFallbackImage/useFallbackImage.js +32 -0
- package/lib/hooks/useFallbackImage/useFallbackImage.test.js +51 -0
- package/lib/hooks/useNavBarPress/useNavBarPress.js +3 -3
- package/lib/hooks/useNavBarPress/useNavBarPress.test.js +4 -4
- package/lib/recipes/MultiselectListContainer.stories.js +306 -0
- package/lib/styles/variants/accordion.js +1 -1
- package/lib/styles/variants/boxes.js +2 -2
- package/lib/styles/variants/multiselectListContainer.js +4 -6
- package/lib/styles/variants/navBar.js +10 -1
- package/lib/styles/variants/separator.js +3 -3
- package/lib/styles/variants/text.js +5 -3
- package/package.json +2 -1
@@ -9,6 +9,7 @@ var _excluded = ["children", "bg"];
|
|
9
9
|
var _context;
|
10
10
|
|
11
11
|
import React from 'react';
|
12
|
+
import { Divider } from 'theme-ui';
|
12
13
|
import Text from './Text';
|
13
14
|
import { textVariants } from '../../utils/devUtils/constants/variants.js';
|
14
15
|
import { flatColorList } from '../../styles/colors.js';
|
@@ -93,4 +94,53 @@ export var WithCustomWidth = function WithCustomWidth() {
|
|
93
94
|
}, ___EmotionJSX(Text, {
|
94
95
|
p: "xl"
|
95
96
|
}, "superlongtextinonelinewithnowhitespacessoitcanbelongerthatanywidth"));
|
97
|
+
};
|
98
|
+
export var TypographyStyleProps = function TypographyStyleProps() {
|
99
|
+
var textProps = {
|
100
|
+
fontFamily: 'times',
|
101
|
+
fontSize: 'md',
|
102
|
+
fontWeight: 900,
|
103
|
+
lineHeight: '2em',
|
104
|
+
letterSpacing: '5px',
|
105
|
+
textAlign: 'right',
|
106
|
+
fontStyle: 'italic'
|
107
|
+
};
|
108
|
+
var loremText = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.';
|
109
|
+
return ___EmotionJSX(Box, {
|
110
|
+
p: "xx",
|
111
|
+
gap: "md"
|
112
|
+
}, ___EmotionJSX(Text, {
|
113
|
+
variant: "title"
|
114
|
+
}, "The Text component allows typography style props to be passed in directly."), ___EmotionJSX(Text, textProps, loremText), ___EmotionJSX(Divider, null), ___EmotionJSX(Text, {
|
115
|
+
variant: "title"
|
116
|
+
}, "Typography styles can also be passed in through the sx prop for the same result."), ___EmotionJSX(Text, {
|
117
|
+
sx: textProps
|
118
|
+
}, loremText));
|
119
|
+
};
|
120
|
+
TypographyStyleProps.argTypes = {
|
121
|
+
variant: {
|
122
|
+
control: {
|
123
|
+
type: 'none'
|
124
|
+
}
|
125
|
+
},
|
126
|
+
children: {
|
127
|
+
control: {
|
128
|
+
type: 'none'
|
129
|
+
}
|
130
|
+
},
|
131
|
+
color: {
|
132
|
+
control: {
|
133
|
+
type: 'none'
|
134
|
+
}
|
135
|
+
},
|
136
|
+
bg: {
|
137
|
+
control: {
|
138
|
+
type: 'none'
|
139
|
+
}
|
140
|
+
},
|
141
|
+
tabPanelProps: {
|
142
|
+
control: {
|
143
|
+
type: 'none'
|
144
|
+
}
|
145
|
+
}
|
96
146
|
};
|
@@ -1,4 +1,18 @@
|
|
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 _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
1
10
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
11
|
+
|
12
|
+
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; }
|
13
|
+
|
14
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
15
|
+
|
2
16
|
import React from 'react';
|
3
17
|
import { ThemeProvider } from 'theme-ui';
|
4
18
|
import { render, screen } from '../../utils/testUtils/testWrapper';
|
@@ -26,4 +40,26 @@ test('default text', function () {
|
|
26
40
|
var text = screen.getByTestId(testId);
|
27
41
|
expect(text).toBeInstanceOf(HTMLSpanElement);
|
28
42
|
expect(text).toBeInTheDocument();
|
43
|
+
});
|
44
|
+
test('typography props will be applied', function () {
|
45
|
+
var customTypographyProps = {
|
46
|
+
fontFamily: 'times',
|
47
|
+
fontSize: 'xx',
|
48
|
+
fontWeight: 900,
|
49
|
+
lineHeight: '2em',
|
50
|
+
letterSpacing: '5px',
|
51
|
+
textAlign: 'right',
|
52
|
+
fontStyle: 'italic'
|
53
|
+
};
|
54
|
+
getComponent(_objectSpread({}, customTypographyProps));
|
55
|
+
var text = screen.getByTestId(testId);
|
56
|
+
expect(text).toHaveStyle({
|
57
|
+
fontFamily: 'times',
|
58
|
+
fontSize: '23px',
|
59
|
+
fontWeight: 900,
|
60
|
+
lineHeight: '2em',
|
61
|
+
letterSpacing: '5px',
|
62
|
+
textAlign: 'right',
|
63
|
+
fontStyle: 'italic'
|
64
|
+
});
|
29
65
|
});
|
@@ -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 = {
|
package/lib/hooks/index.js
CHANGED
@@ -10,4 +10,5 @@ export { default as useNavBarPress } from './useNavBarPress';
|
|
10
10
|
export { default as useRockerButton } from './useRockerButton';
|
11
11
|
export { default as useSelectField } from './useSelectField';
|
12
12
|
export { default as useStatusClasses } from './useStatusClasses';
|
13
|
-
export { default as useDebounce } from './useDebounce';
|
13
|
+
export { default as useDebounce } from './useDebounce';
|
14
|
+
export { default as useFallbackImage } from './useFallbackImage';
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './useFallbackImage';
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import _setTimeout from "@babel/runtime-corejs3/core-js-stable/set-timeout";
|
2
|
+
import { useEffect, useMemo } from 'react';
|
3
|
+
|
4
|
+
var useFallbackImage = function useFallbackImage(_ref) {
|
5
|
+
var imageSrc = _ref.src,
|
6
|
+
onImageLoad = _ref.onImageLoad,
|
7
|
+
onImageError = _ref.onImageError,
|
8
|
+
fallbackTimeout = _ref.fallbackTimeout,
|
9
|
+
onFallbackTimeout = _ref.onFallbackTimeout;
|
10
|
+
var displayImage = useMemo(function () {
|
11
|
+
return document.createElement('img');
|
12
|
+
}, []);
|
13
|
+
useEffect(function () {
|
14
|
+
displayImage.src = imageSrc;
|
15
|
+
displayImage.onload = onImageLoad;
|
16
|
+
displayImage.onerror = onImageError;
|
17
|
+
return function () {
|
18
|
+
displayImage.onload = null;
|
19
|
+
displayImage.onerror = null;
|
20
|
+
};
|
21
|
+
}, []);
|
22
|
+
useEffect(function () {
|
23
|
+
var timeoutId = 0;
|
24
|
+
timeoutId = _setTimeout(onFallbackTimeout, fallbackTimeout);
|
25
|
+
return function () {
|
26
|
+
return clearTimeout(timeoutId);
|
27
|
+
};
|
28
|
+
}, []);
|
29
|
+
return displayImage;
|
30
|
+
};
|
31
|
+
|
32
|
+
export default useFallbackImage;
|
@@ -0,0 +1,51 @@
|
|
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 _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
10
|
+
|
11
|
+
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; }
|
12
|
+
|
13
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
14
|
+
|
15
|
+
import { renderHook } from '@testing-library/react-hooks';
|
16
|
+
import useFallbackImage from './useFallbackImage';
|
17
|
+
var defaultProps = {
|
18
|
+
src: 'test-src',
|
19
|
+
fallbackImage: 'test-fallback-src',
|
20
|
+
onImageLoad: jest.fn(),
|
21
|
+
onImageError: jest.fn(),
|
22
|
+
fallbackTimeout: 5,
|
23
|
+
onFallbackTimeout: jest.fn()
|
24
|
+
};
|
25
|
+
test('should return node if all props are correct ', function () {
|
26
|
+
var _renderHook = renderHook(function () {
|
27
|
+
return useFallbackImage(defaultProps);
|
28
|
+
}),
|
29
|
+
current = _renderHook.result.current;
|
30
|
+
|
31
|
+
expect(current).toBeInstanceOf(HTMLImageElement);
|
32
|
+
});
|
33
|
+
test('should not trigger onImageLoad if no fallback passed', function () {
|
34
|
+
renderHook(function () {
|
35
|
+
return useFallbackImage(_objectSpread(_objectSpread({}, defaultProps), {}, {
|
36
|
+
fallbackImage: null
|
37
|
+
}));
|
38
|
+
});
|
39
|
+
expect(defaultProps.onImageLoad).not.toHaveBeenCalled();
|
40
|
+
});
|
41
|
+
test('should not trigger onImageLoad if component unmounted', function () {
|
42
|
+
var _renderHook2 = renderHook(function () {
|
43
|
+
return useFallbackImage(_objectSpread(_objectSpread({}, defaultProps), {}, {
|
44
|
+
fallbackImage: null
|
45
|
+
}));
|
46
|
+
}),
|
47
|
+
unmount = _renderHook2.unmount;
|
48
|
+
|
49
|
+
unmount();
|
50
|
+
expect(defaultProps.onImageLoad).not.toHaveBeenCalled();
|
51
|
+
});
|
@@ -3,16 +3,16 @@
|
|
3
3
|
* @param {Object} params The accepted parameters object
|
4
4
|
* @param {string} props.key The unique identifier that is assigned to the element being pressed
|
5
5
|
* @param {Object} state The state object tracking selected keys
|
6
|
-
* @param {function} state.
|
6
|
+
* @param {function} state.setSelectedKey The function that sets the selected keys
|
7
7
|
* @callback props.onPressCallback The callback that will be called only if provided
|
8
8
|
*/
|
9
9
|
var useNavBarPress = function useNavBarPress(_ref, state) {
|
10
10
|
var key = _ref.key,
|
11
11
|
onPressCallback = _ref.onPressCallback;
|
12
|
-
var
|
12
|
+
var setSelectedKey = state.setSelectedKey;
|
13
13
|
|
14
14
|
var onNavPress = function onNavPress() {
|
15
|
-
|
15
|
+
setSelectedKey(key);
|
16
16
|
|
17
17
|
if (onPressCallback) {
|
18
18
|
onPressCallback();
|
@@ -3,14 +3,14 @@ import useNavBarPress from './';
|
|
3
3
|
var key = 'testKey';
|
4
4
|
test('using the onPress prop works as a callback', function () {
|
5
5
|
var onPress = jest.fn();
|
6
|
-
var
|
6
|
+
var setSelectedKey = jest.fn();
|
7
7
|
|
8
8
|
var _renderHook = renderHook(function () {
|
9
9
|
return useNavBarPress({
|
10
10
|
key: key,
|
11
11
|
onPressCallback: onPress
|
12
12
|
}, {
|
13
|
-
|
13
|
+
setSelectedKey: setSelectedKey
|
14
14
|
});
|
15
15
|
}),
|
16
16
|
result = _renderHook.result;
|
@@ -20,13 +20,13 @@ test('using the onPress prop works as a callback', function () {
|
|
20
20
|
});
|
21
21
|
test('if no onPress prop there is no callback', function () {
|
22
22
|
var onPress = jest.fn();
|
23
|
-
var
|
23
|
+
var setSelectedKey = jest.fn();
|
24
24
|
|
25
25
|
var _renderHook2 = renderHook(function () {
|
26
26
|
return useNavBarPress({
|
27
27
|
key: key
|
28
28
|
}, {
|
29
|
-
|
29
|
+
setSelectedKey: setSelectedKey
|
30
30
|
});
|
31
31
|
}),
|
32
32
|
result = _renderHook2.result;
|
@@ -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
|
+
};
|
@@ -71,7 +71,6 @@ var accordionGridHeader = {
|
|
71
71
|
}
|
72
72
|
};
|
73
73
|
var accordionGridHeaderNav = {
|
74
|
-
padding: '10px 15px 10px 15px',
|
75
74
|
cursor: 'pointer',
|
76
75
|
minHeight: '40px',
|
77
76
|
lineHeight: '30px',
|
@@ -100,6 +99,7 @@ var accordionGridHeaderNav = {
|
|
100
99
|
};
|
101
100
|
|
102
101
|
var accordionGridNavItem = _objectSpread(_objectSpread({}, accordionGridHeaderNav), {}, {
|
102
|
+
padding: '10px 15px 10px 15px',
|
103
103
|
'&.is-selected': {
|
104
104
|
backgroundColor: 'accent.5',
|
105
105
|
boxShadow: 'inset 2px 0 0 0 white'
|
@@ -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'
|