@pingux/astro 1.17.0-alpha.1 → 1.17.0-alpha.10
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/Button/Button.stories.js +8 -3
- package/lib/cjs/components/Button/Button.test.js +5 -0
- package/lib/cjs/components/Chip/Chip.stories.js +18 -1
- package/lib/cjs/components/CollapsiblePanel/CollapsiblePanel.js +2 -0
- package/lib/cjs/components/CollapsiblePanel/CollapsiblePanel.stories.js +125 -32
- package/lib/cjs/components/CollapsiblePanelContainer/CollapsiblePanelContainer.js +4 -22
- package/lib/cjs/components/CollapsiblePanelContainer/CollapsiblePanelContainer.test.js +8 -8
- package/lib/cjs/components/CollapsiblePanelItem/CollapsiblePanelItem.js +2 -2
- package/lib/cjs/components/Link/Link.test.js +5 -0
- package/lib/cjs/components/ListView/ListView.js +1 -0
- package/lib/cjs/components/MultivaluesField/MultivaluesField.stories.js +142 -21
- package/lib/cjs/components/OverlayPanel/OverlayPanel.stories.js +1 -1
- package/lib/cjs/components/RockerButton/RockerButton.js +5 -9
- package/lib/cjs/styles/variants/boxes.js +19 -0
- package/lib/cjs/styles/variants/buttons.js +20 -3
- package/lib/cjs/styles/variants/collapsiblePanel.js +26 -7
- package/lib/cjs/styles/variants/overlayPanel.js +2 -2
- package/lib/components/Button/Button.stories.js +8 -3
- package/lib/components/Button/Button.test.js +3 -0
- package/lib/components/Chip/Chip.stories.js +14 -0
- package/lib/components/CollapsiblePanel/CollapsiblePanel.js +2 -0
- package/lib/components/CollapsiblePanel/CollapsiblePanel.stories.js +113 -31
- package/lib/components/CollapsiblePanelContainer/CollapsiblePanelContainer.js +1 -15
- package/lib/components/CollapsiblePanelContainer/CollapsiblePanelContainer.test.js +6 -6
- package/lib/components/CollapsiblePanelItem/CollapsiblePanelItem.js +2 -2
- package/lib/components/Link/Link.test.js +3 -0
- package/lib/components/ListView/ListView.js +1 -0
- package/lib/components/MultivaluesField/MultivaluesField.stories.js +142 -20
- package/lib/components/OverlayPanel/OverlayPanel.stories.js +1 -1
- package/lib/components/RockerButton/RockerButton.js +6 -10
- package/lib/styles/variants/boxes.js +19 -0
- package/lib/styles/variants/buttons.js +20 -3
- package/lib/styles/variants/collapsiblePanel.js +26 -7
- package/lib/styles/variants/overlayPanel.js +2 -2
- package/package.json +1 -1
@@ -1,14 +1,32 @@
|
|
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";
|
1
8
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
|
-
import
|
9
|
+
import _someInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/some";
|
10
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
11
|
+
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
12
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
13
|
+
import _sortInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/sort";
|
14
|
+
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
15
|
+
|
16
|
+
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; }
|
17
|
+
|
18
|
+
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; }
|
19
|
+
|
20
|
+
import React, { useRef, useState, useMemo } from 'react';
|
3
21
|
import AccountGroupIcon from 'mdi-react/AccountGroupIcon';
|
4
|
-
import Clear from 'mdi-react/CloseIcon';
|
5
22
|
import ChevronRightIcon from 'mdi-react/ChevronRightIcon';
|
6
|
-
import
|
23
|
+
import CheckIcon from 'mdi-react/CheckIcon';
|
24
|
+
import Clear from 'mdi-react/CloseIcon';
|
7
25
|
import SearchIcon from 'mdi-react/SearchIcon';
|
8
26
|
import AccountIcon from 'mdi-react/AccountIcon';
|
9
27
|
import CollapsiblePanel from './CollapsiblePanel';
|
10
28
|
import { useOverlayPanelState } from '../../hooks';
|
11
|
-
import { Breadcrumbs, Box, Button, Chip, ListView, Item, Icon, IconButton, CollapsiblePanelItem, OverlayPanel, OverlayProvider, SearchField, Text } from '../../index';
|
29
|
+
import { Breadcrumbs, Box, Button, CheckboxField, Chip, ListView, Item, Icon, IconButton, CollapsiblePanelItem, OverlayPanel, OverlayProvider, SearchField, Text } from '../../index';
|
12
30
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
13
31
|
export default {
|
14
32
|
title: 'CollapsiblePanel',
|
@@ -34,13 +52,14 @@ export default {
|
|
34
52
|
}
|
35
53
|
}
|
36
54
|
};
|
37
|
-
var
|
55
|
+
var data = [{
|
38
56
|
id: '1',
|
39
57
|
icon: 'Group',
|
40
58
|
key: 'Avengers',
|
41
59
|
name: 'Avengers',
|
42
60
|
subtitle: 'Default',
|
43
|
-
chipValue: '25'
|
61
|
+
chipValue: '25',
|
62
|
+
isDefaultSelected: true
|
44
63
|
}, {
|
45
64
|
id: '2',
|
46
65
|
icon: 'Group',
|
@@ -61,7 +80,8 @@ var items = [{
|
|
61
80
|
key: 'Digital Investors',
|
62
81
|
name: 'Digital Investors',
|
63
82
|
subtitle: 'N America',
|
64
|
-
chipValue: '12'
|
83
|
+
chipValue: '12',
|
84
|
+
isDefaultSelected: true
|
65
85
|
}, {
|
66
86
|
id: '5',
|
67
87
|
icon: 'Group',
|
@@ -98,33 +118,45 @@ var items = [{
|
|
98
118
|
subtitle: '',
|
99
119
|
chipValue: '29'
|
100
120
|
}];
|
101
|
-
var mockData = [{
|
102
|
-
id: '10',
|
103
|
-
key: 'Avengers',
|
104
|
-
name: 'Avengers'
|
105
|
-
}, {
|
106
|
-
id: '11',
|
107
|
-
key: 'Digital Investors',
|
108
|
-
name: 'Digital Investors'
|
109
|
-
}, {
|
110
|
-
id: '12',
|
111
|
-
key: 'A very long title as well',
|
112
|
-
name: 'A very long title as well'
|
113
|
-
}];
|
114
|
-
|
115
|
-
var changeSelection = function changeSelection(selected) {
|
116
|
-
console.log(selected);
|
117
|
-
};
|
118
|
-
|
119
121
|
export var Default = function Default(args) {
|
120
122
|
return ___EmotionJSX(CollapsiblePanel, args);
|
121
123
|
};
|
122
124
|
export var CollapsiblePanelWithBadge = function CollapsiblePanelWithBadge(args) {
|
125
|
+
var _useState = useState(data),
|
126
|
+
_useState2 = _slicedToArray(_useState, 2),
|
127
|
+
items = _useState2[0],
|
128
|
+
setItems = _useState2[1];
|
129
|
+
|
123
130
|
var _useOverlayPanelState = useOverlayPanelState(),
|
124
131
|
state = _useOverlayPanelState.state,
|
125
132
|
onClose = _useOverlayPanelState.onClose;
|
126
133
|
|
127
134
|
var triggerRef = useRef();
|
135
|
+
var selectedItems = useMemo(function () {
|
136
|
+
var _context;
|
137
|
+
|
138
|
+
return _sortInstanceProperty(_context = _filterInstanceProperty(items).call(items, function (item) {
|
139
|
+
return item.isDefaultSelected || item.isSelected;
|
140
|
+
}) // sort elements to display "default selected" at first place
|
141
|
+
).call(_context, function (a, b) {
|
142
|
+
return Number(!!b.isDefaultSelected) - Number(!!a.isDefaultSelected);
|
143
|
+
});
|
144
|
+
}, [items]);
|
145
|
+
|
146
|
+
var changeSelection = function changeSelection(key) {
|
147
|
+
setItems(function (prevItems) {
|
148
|
+
return _mapInstanceProperty(prevItems).call(prevItems, function (el) {
|
149
|
+
if (el.key === key) {
|
150
|
+
return _objectSpread(_objectSpread({}, el), {}, {
|
151
|
+
isSelected: !el.isSelected
|
152
|
+
});
|
153
|
+
}
|
154
|
+
|
155
|
+
return el;
|
156
|
+
});
|
157
|
+
});
|
158
|
+
};
|
159
|
+
|
128
160
|
return ___EmotionJSX(OverlayProvider, null, ___EmotionJSX(Button, {
|
129
161
|
ref: triggerRef,
|
130
162
|
onPress: state.open
|
@@ -181,7 +213,10 @@ export var CollapsiblePanelWithBadge = function CollapsiblePanelWithBadge(args)
|
|
181
213
|
pt: "25px"
|
182
214
|
}, ___EmotionJSX(Box, {
|
183
215
|
isRow: true,
|
184
|
-
justifyContent: "space-between"
|
216
|
+
justifyContent: "space-between",
|
217
|
+
sx: {
|
218
|
+
marginTop: '5px'
|
219
|
+
}
|
185
220
|
}, ___EmotionJSX(Box, {
|
186
221
|
width: "100%"
|
187
222
|
}, ___EmotionJSX(SearchField, {
|
@@ -190,11 +225,13 @@ export var CollapsiblePanelWithBadge = function CollapsiblePanelWithBadge(args)
|
|
190
225
|
placeholder: "Search",
|
191
226
|
width: "100%",
|
192
227
|
mt: "0px",
|
193
|
-
mr: "sm"
|
228
|
+
mr: "sm",
|
229
|
+
mb: "xs"
|
194
230
|
}), ___EmotionJSX(ListView, {
|
195
231
|
items: items,
|
196
232
|
style: {
|
197
|
-
width: '
|
233
|
+
width: '100%',
|
234
|
+
outline: 'none'
|
198
235
|
}
|
199
236
|
}, function (item) {
|
200
237
|
return ___EmotionJSX(Item, {
|
@@ -202,8 +239,12 @@ export var CollapsiblePanelWithBadge = function CollapsiblePanelWithBadge(args)
|
|
202
239
|
textValue: item.name,
|
203
240
|
"data-id": item.key,
|
204
241
|
listItemProps: {
|
242
|
+
isRow: true,
|
205
243
|
sx: {
|
206
244
|
bg: 'white',
|
245
|
+
width: '100%',
|
246
|
+
justifyContent: 'space-between',
|
247
|
+
alignItems: 'center',
|
207
248
|
'&.is-hovered': {
|
208
249
|
bg: 'accent.99'
|
209
250
|
}
|
@@ -233,9 +274,46 @@ export var CollapsiblePanelWithBadge = function CollapsiblePanelWithBadge(args)
|
|
233
274
|
}
|
234
275
|
})), ___EmotionJSX(Text, {
|
235
276
|
variant: "listSubtitle"
|
236
|
-
}, item.subtitle)))
|
277
|
+
}, item.subtitle))), item.isDefaultSelected ? ___EmotionJSX(Box, {
|
278
|
+
isRow: true,
|
279
|
+
sx: {
|
280
|
+
border: '1px solid',
|
281
|
+
borderColor: 'neutral.80',
|
282
|
+
borderRadius: 5,
|
283
|
+
minHeight: 22,
|
284
|
+
justifyContent: 'center',
|
285
|
+
alignItems: 'center',
|
286
|
+
p: 'xs',
|
287
|
+
maxWidth: '50%'
|
288
|
+
}
|
289
|
+
}, ___EmotionJSX(Icon, {
|
290
|
+
icon: CheckIcon,
|
291
|
+
color: "neutral.20",
|
292
|
+
size: 13,
|
293
|
+
sx: {
|
294
|
+
flexShrink: 0
|
295
|
+
}
|
296
|
+
}), ___EmotionJSX(Text, {
|
297
|
+
sx: {
|
298
|
+
fontSize: 'sm',
|
299
|
+
pl: 'xs',
|
300
|
+
maxHeight: 32,
|
301
|
+
overflow: 'hidden'
|
302
|
+
}
|
303
|
+
}, "Added by Filter")) : ___EmotionJSX(CheckboxField, {
|
304
|
+
controlProps: {
|
305
|
+
color: 'neutral.10',
|
306
|
+
'aria-label': 'Select'
|
307
|
+
},
|
308
|
+
onChange: function onChange() {
|
309
|
+
return changeSelection(item.key);
|
310
|
+
},
|
311
|
+
isSelected: _someInstanceProperty(selectedItems).call(selectedItems, function (el) {
|
312
|
+
return el.key === item.key;
|
313
|
+
})
|
314
|
+
}));
|
237
315
|
})), ___EmotionJSX(CollapsiblePanel, _extends({
|
238
|
-
items:
|
316
|
+
items: selectedItems,
|
239
317
|
onSelectionChange: changeSelection,
|
240
318
|
selectedFilterCount: "1000+"
|
241
319
|
}, args), function (item) {
|
@@ -245,7 +323,11 @@ export var CollapsiblePanelWithBadge = function CollapsiblePanelWithBadge(args)
|
|
245
323
|
"data-id": item.key
|
246
324
|
}, ___EmotionJSX(CollapsiblePanelItem, {
|
247
325
|
text: item.name,
|
248
|
-
icon:
|
326
|
+
icon: item.isDefaultSelected ? CheckIcon : Clear,
|
327
|
+
onPress: function onPress() {
|
328
|
+
return changeSelection(item.key);
|
329
|
+
},
|
330
|
+
isDefaultSelected: item.isDefaultSelected
|
249
331
|
}));
|
250
332
|
})))));
|
251
333
|
};
|
@@ -1,20 +1,6 @@
|
|
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
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
10
|
-
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
11
2
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
12
3
|
var _excluded = ["selectedFilterCount", "className", "children", "closeAriaLabel", "isDefaultOpen", "isOpen", "onOpenChange", "openAriaLabel"];
|
13
|
-
|
14
|
-
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; }
|
15
|
-
|
16
|
-
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; }
|
17
|
-
|
18
4
|
import React, { forwardRef } from 'react';
|
19
5
|
import PropTypes from 'prop-types';
|
20
6
|
import ChevronRightIcon from 'mdi-react/ChevronRightIcon';
|
@@ -90,7 +76,7 @@ var CollapsiblePanelContainer = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
90
76
|
"data-testid": "collapsible-panel-badge",
|
91
77
|
margin: "auto",
|
92
78
|
selectedFilterCount: selectedFilterCount
|
93
|
-
})),
|
79
|
+
})), children);
|
94
80
|
});
|
95
81
|
CollapsiblePanelContainer.propTypes = {
|
96
82
|
/** Amount of selected items indicator. */
|
@@ -55,13 +55,13 @@ test('updates aria label when button is clicked', function () {
|
|
55
55
|
state: state
|
56
56
|
});
|
57
57
|
var button = screen.getByTestId(collapsiblePanelButtonId);
|
58
|
+
var container = screen.getByTestId(testId);
|
58
59
|
userEvent.click(button);
|
59
|
-
var collapsiblePanel = screen.queryByTestId(collapsiblePanelId);
|
60
60
|
expect(button).toHaveAttribute('aria-label', 'Close filter menu?');
|
61
|
-
expect(
|
61
|
+
expect(container).toHaveClass('is-open');
|
62
62
|
userEvent.click(button);
|
63
63
|
expect(button).toHaveAttribute('aria-label', 'Open filter menu?');
|
64
|
-
expect(
|
64
|
+
expect(container).not.toHaveClass('is-open');
|
65
65
|
});
|
66
66
|
test('shows children when isOpen is true', function () {
|
67
67
|
getComponent({
|
@@ -73,9 +73,9 @@ test('shows children when isOpen is true', function () {
|
|
73
73
|
test('should hide children when pressing the escape key', function () {
|
74
74
|
getComponent();
|
75
75
|
var button = screen.getByTestId(collapsiblePanelButtonId);
|
76
|
+
var container = screen.getByTestId(testId);
|
76
77
|
userEvent.click(button);
|
77
|
-
|
78
|
-
expect(collapsiblePanel).toBeInTheDocument();
|
78
|
+
expect(container).toHaveClass('is-open');
|
79
79
|
userEvent.type(button, '{esc}');
|
80
|
-
expect(
|
80
|
+
expect(container).not.toHaveClass('is-open');
|
81
81
|
});
|
@@ -23,8 +23,8 @@ var CollapsiblePanelItem = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
23
23
|
variant: "collapsiblePanellItem"
|
24
24
|
}, text), iconElement && (isDefaultSelected ? iconElement : ___EmotionJSX(IconButton, {
|
25
25
|
sx: {
|
26
|
-
width:
|
27
|
-
height:
|
26
|
+
width: 20,
|
27
|
+
height: 20,
|
28
28
|
alignSelf: 'auto',
|
29
29
|
'& path': {
|
30
30
|
fill: 'inherit'
|
@@ -43,6 +43,9 @@ test('link shows focus status', function () {
|
|
43
43
|
userEvent.tab();
|
44
44
|
expect(link).toHaveFocus();
|
45
45
|
expect(link).toHaveClass('is-focused');
|
46
|
+
userEvent.tab();
|
47
|
+
expect(link).not.toHaveFocus();
|
48
|
+
expect(link).not.toHaveClass('is-focused');
|
46
49
|
});
|
47
50
|
test('link shows disabled status', function () {
|
48
51
|
// Needs href to have a tabindex
|
@@ -149,6 +149,7 @@ var ListView = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
149
149
|
|
150
150
|
layout.isLoading = isLoading;
|
151
151
|
var focusedItem = gridCollection.getFirstKey();
|
152
|
+
delete gridProps.onMouseDown;
|
152
153
|
return ___EmotionJSX(ListViewContext.Provider, {
|
153
154
|
value: {
|
154
155
|
state: state,
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
2
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
|
+
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
3
3
|
import React, { useState } from 'react';
|
4
4
|
import { Box, Item, MultivaluesField, OverlayProvider } from '../..';
|
5
5
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
@@ -7,7 +7,9 @@ export default {
|
|
7
7
|
title: 'Form/MultivaluesField',
|
8
8
|
component: MultivaluesField,
|
9
9
|
argTypes: {
|
10
|
-
direction: {
|
10
|
+
direction: {
|
11
|
+
defaultValue: 'bottom'
|
12
|
+
},
|
11
13
|
hasAutoFocus: {},
|
12
14
|
hasNoStatusIndicator: {},
|
13
15
|
isDisabled: {},
|
@@ -89,7 +91,27 @@ var items = [{
|
|
89
91
|
name: 'Shark',
|
90
92
|
key: 'Shark'
|
91
93
|
}];
|
94
|
+
|
95
|
+
var setOverlayStyle = function setOverlayStyle(direction, isOpen, mr, ml, mt) {
|
96
|
+
return {
|
97
|
+
marginRight: direction === 'right' && isOpen ? mr : 0,
|
98
|
+
marginLeft: direction === 'left' && isOpen ? ml : 0,
|
99
|
+
marginTop: direction === 'top' && isOpen ? mt : 0
|
100
|
+
};
|
101
|
+
};
|
102
|
+
|
92
103
|
export var Default = function Default(args) {
|
104
|
+
var _useState = useState(false),
|
105
|
+
_useState2 = _slicedToArray(_useState, 2),
|
106
|
+
isOpen = _useState2[0],
|
107
|
+
setIsOpen = _useState2[1];
|
108
|
+
|
109
|
+
var direction = args.direction;
|
110
|
+
|
111
|
+
var onOpenChange = function onOpenChange() {
|
112
|
+
setIsOpen(true);
|
113
|
+
};
|
114
|
+
|
93
115
|
return (// const items = [
|
94
116
|
// { id: 1, name: 'Aardvark', key: 'Aardvark' },
|
95
117
|
// { id: 2, name: 'Kangaroo', key: 'Kangaroo' },
|
@@ -99,9 +121,14 @@ export var Default = function Default(args) {
|
|
99
121
|
// { id: 6, name: 'Orangutan', key: 'Orangutan' },
|
100
122
|
// { id: 7, name: 'Shark', key: 'Shark' },
|
101
123
|
// ];
|
102
|
-
___EmotionJSX(OverlayProvider
|
124
|
+
___EmotionJSX(OverlayProvider // note: spacing for demo purpose only so that the select list renders in the correct place
|
125
|
+
, {
|
126
|
+
style: setOverlayStyle(direction, isOpen, '50%', '50%', '20%')
|
127
|
+
}, ___EmotionJSX(MultivaluesField, _extends({
|
103
128
|
items: items
|
104
|
-
}, args
|
129
|
+
}, args, {
|
130
|
+
onOpenChange: onOpenChange
|
131
|
+
}), function (item) {
|
105
132
|
return ___EmotionJSX(Item, {
|
106
133
|
key: item.key,
|
107
134
|
"data-id": item.name
|
@@ -110,10 +137,26 @@ export var Default = function Default(args) {
|
|
110
137
|
);
|
111
138
|
};
|
112
139
|
export var WithCustomValues = function WithCustomValues(args) {
|
113
|
-
|
140
|
+
var _useState3 = useState(false),
|
141
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
142
|
+
isOpen = _useState4[0],
|
143
|
+
setIsOpen = _useState4[1];
|
144
|
+
|
145
|
+
var direction = args.direction;
|
146
|
+
|
147
|
+
var onOpenChange = function onOpenChange() {
|
148
|
+
setIsOpen(true);
|
149
|
+
};
|
150
|
+
|
151
|
+
return ___EmotionJSX(OverlayProvider // note: spacing for demo purpose only so that the select list renders in the correct place
|
152
|
+
, {
|
153
|
+
style: setOverlayStyle(direction, isOpen, '50%', '50%', '20%')
|
154
|
+
}, ___EmotionJSX(MultivaluesField, _extends({
|
114
155
|
items: items,
|
115
156
|
mode: "non-restrictive"
|
116
|
-
}, args
|
157
|
+
}, args, {
|
158
|
+
onOpenChange: onOpenChange
|
159
|
+
}), function (item) {
|
117
160
|
return ___EmotionJSX(Item, {
|
118
161
|
key: item.key,
|
119
162
|
"data-id": item.name
|
@@ -126,10 +169,26 @@ WithCustomValues.argTypes = {
|
|
126
169
|
}
|
127
170
|
};
|
128
171
|
export var WithDisabledKeys = function WithDisabledKeys(args) {
|
129
|
-
|
172
|
+
var _useState5 = useState(false),
|
173
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
174
|
+
isOpen = _useState6[0],
|
175
|
+
setIsOpen = _useState6[1];
|
176
|
+
|
177
|
+
var direction = args.direction;
|
178
|
+
|
179
|
+
var onOpenChange = function onOpenChange() {
|
180
|
+
setIsOpen(true);
|
181
|
+
};
|
182
|
+
|
183
|
+
return ___EmotionJSX(OverlayProvider // note: spacing for demo purpose only so that the select list renders in the correct place
|
184
|
+
, {
|
185
|
+
style: setOverlayStyle(direction, isOpen, '50%', '50%', '20%')
|
186
|
+
}, ___EmotionJSX(MultivaluesField, _extends({
|
130
187
|
disabledKeys: ['Aardvark'],
|
131
188
|
items: items
|
132
|
-
}, args
|
189
|
+
}, args, {
|
190
|
+
onOpenChange: onOpenChange
|
191
|
+
}), function (item) {
|
133
192
|
return ___EmotionJSX(Item, {
|
134
193
|
key: item.key,
|
135
194
|
"data-id": item.name
|
@@ -137,10 +196,26 @@ export var WithDisabledKeys = function WithDisabledKeys(args) {
|
|
137
196
|
}));
|
138
197
|
};
|
139
198
|
export var Uncontrolled = function Uncontrolled(args) {
|
140
|
-
|
199
|
+
var _useState7 = useState(false),
|
200
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
201
|
+
isOpen = _useState8[0],
|
202
|
+
setIsOpen = _useState8[1];
|
203
|
+
|
204
|
+
var direction = args.direction;
|
205
|
+
|
206
|
+
var onOpenChange = function onOpenChange() {
|
207
|
+
setIsOpen(true);
|
208
|
+
};
|
209
|
+
|
210
|
+
return ___EmotionJSX(OverlayProvider // note: spacing for demo purpose only so that the select list renders in the correct place
|
211
|
+
, {
|
212
|
+
style: setOverlayStyle(direction, isOpen, '50%', '50%', '20%')
|
213
|
+
}, ___EmotionJSX(MultivaluesField, _extends({
|
141
214
|
defaultSelectedKeys: ['Aardvark', 'Snake'],
|
142
215
|
items: items
|
143
|
-
}, args
|
216
|
+
}, args, {
|
217
|
+
onOpenChange: onOpenChange
|
218
|
+
}), function (item) {
|
144
219
|
return ___EmotionJSX(Item, {
|
145
220
|
key: item.key,
|
146
221
|
"data-id": item.name
|
@@ -148,17 +223,32 @@ export var Uncontrolled = function Uncontrolled(args) {
|
|
148
223
|
}));
|
149
224
|
};
|
150
225
|
export var Controlled = function Controlled(args) {
|
151
|
-
var
|
152
|
-
|
153
|
-
selectedKeys =
|
154
|
-
setSelectedKeys =
|
226
|
+
var _useState9 = useState(['Aardvark', 'Snake']),
|
227
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
228
|
+
selectedKeys = _useState10[0],
|
229
|
+
setSelectedKeys = _useState10[1];
|
230
|
+
|
231
|
+
var _useState11 = useState(false),
|
232
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
233
|
+
isOpen = _useState12[0],
|
234
|
+
setIsOpen = _useState12[1];
|
235
|
+
|
236
|
+
var direction = args.direction;
|
155
237
|
|
156
|
-
|
238
|
+
var onOpenChange = function onOpenChange() {
|
239
|
+
setIsOpen(true);
|
240
|
+
};
|
241
|
+
|
242
|
+
return ___EmotionJSX(OverlayProvider // note: spacing for demo purpose only so that the select list renders in the correct place
|
243
|
+
, {
|
244
|
+
style: setOverlayStyle(direction, isOpen, '50%', '50%', '20%')
|
245
|
+
}, ___EmotionJSX(MultivaluesField, _extends({
|
157
246
|
label: "Field Label"
|
158
247
|
}, args, {
|
159
248
|
items: items,
|
160
249
|
onSelectionChange: setSelectedKeys,
|
161
|
-
selectedKeys: selectedKeys
|
250
|
+
selectedKeys: selectedKeys,
|
251
|
+
onOpenChange: onOpenChange
|
162
252
|
}), function (item) {
|
163
253
|
return ___EmotionJSX(Item, {
|
164
254
|
key: item.key,
|
@@ -167,6 +257,17 @@ export var Controlled = function Controlled(args) {
|
|
167
257
|
}));
|
168
258
|
};
|
169
259
|
export var WithCustomSize = function WithCustomSize(args) {
|
260
|
+
var _useState13 = useState(false),
|
261
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
262
|
+
isOpen = _useState14[0],
|
263
|
+
setIsOpen = _useState14[1];
|
264
|
+
|
265
|
+
var direction = args.direction;
|
266
|
+
|
267
|
+
var onOpenChange = function onOpenChange() {
|
268
|
+
setIsOpen(true);
|
269
|
+
};
|
270
|
+
|
170
271
|
return ___EmotionJSX(Box, {
|
171
272
|
sx: {
|
172
273
|
width: '100%',
|
@@ -175,9 +276,14 @@ export var WithCustomSize = function WithCustomSize(args) {
|
|
175
276
|
}
|
176
277
|
}, ___EmotionJSX(Box, {
|
177
278
|
width: 300
|
178
|
-
}, ___EmotionJSX(OverlayProvider
|
279
|
+
}, ___EmotionJSX(OverlayProvider // note: spacing for demo purpose only so that the select list renders in the correct place
|
280
|
+
, {
|
281
|
+
style: setOverlayStyle(direction, isOpen, '25%', '25%', '75%')
|
282
|
+
}, ___EmotionJSX(MultivaluesField, _extends({
|
179
283
|
items: items
|
180
|
-
}, args
|
284
|
+
}, args, {
|
285
|
+
onOpenChange: onOpenChange
|
286
|
+
}), function (item) {
|
181
287
|
return ___EmotionJSX(Item, {
|
182
288
|
key: item.key,
|
183
289
|
"data-id": item.name
|
@@ -185,10 +291,26 @@ export var WithCustomSize = function WithCustomSize(args) {
|
|
185
291
|
}))));
|
186
292
|
};
|
187
293
|
export var WithReadOnlyValues = function WithReadOnlyValues(args) {
|
188
|
-
|
294
|
+
var _useState15 = useState(false),
|
295
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
296
|
+
isOpen = _useState16[0],
|
297
|
+
setIsOpen = _useState16[1];
|
298
|
+
|
299
|
+
var direction = args.direction;
|
300
|
+
|
301
|
+
var onOpenChange = function onOpenChange() {
|
302
|
+
setIsOpen(true);
|
303
|
+
};
|
304
|
+
|
305
|
+
return ___EmotionJSX(OverlayProvider // note: spacing for demo purpose only so that the select list renders in the correct place
|
306
|
+
, {
|
307
|
+
style: setOverlayStyle(direction, isOpen, '50%', '50%', '20%')
|
308
|
+
}, ___EmotionJSX(MultivaluesField, _extends({
|
189
309
|
readOnlyKeys: ['Aardvark', 'Snake'],
|
190
310
|
items: items
|
191
|
-
}, args
|
311
|
+
}, args, {
|
312
|
+
onOpenChange: onOpenChange
|
313
|
+
}), function (item) {
|
192
314
|
return ___EmotionJSX(Item, {
|
193
315
|
key: item.key,
|
194
316
|
"data-id": item.name
|
@@ -16,7 +16,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
16
16
|
import React, { forwardRef, useContext, useImperativeHandle, useRef } from 'react';
|
17
17
|
import PropTypes from 'prop-types';
|
18
18
|
import { Item } from '@react-stately/collections';
|
19
|
-
import {
|
19
|
+
import { FocusRing } from '@react-aria/focus';
|
20
20
|
import { useRockerButton, useStatusClasses, usePropWarning } from '../../hooks';
|
21
21
|
import { Box } from '../../index';
|
22
22
|
import { RockerContext } from '../RockerButtonGroup';
|
@@ -29,15 +29,9 @@ export var CollectionRockerButton = /*#__PURE__*/forwardRef(function (props, ref
|
|
29
29
|
itemProps = item.props;
|
30
30
|
var state = useContext(RockerContext);
|
31
31
|
var isDisabled = state.disabledKeys.has(key);
|
32
|
-
|
33
|
-
var _useFocusRing = useFocusRing(),
|
34
|
-
isFocusVisible = _useFocusRing.isFocusVisible,
|
35
|
-
focusProps = _useFocusRing.focusProps;
|
36
|
-
|
37
32
|
var isSelected = state.selectedKey === key;
|
38
33
|
|
39
34
|
var _useStatusClasses = useStatusClasses(className, {
|
40
|
-
isFocused: isFocusVisible,
|
41
35
|
isSelected: isSelected,
|
42
36
|
isDisabled: isDisabled
|
43
37
|
}),
|
@@ -58,17 +52,19 @@ export var CollectionRockerButton = /*#__PURE__*/forwardRef(function (props, ref
|
|
58
52
|
}, state, rockerButtonRef),
|
59
53
|
rockerButtonProps = _useRockerButton.rockerButtonProps;
|
60
54
|
|
61
|
-
return ___EmotionJSX(
|
55
|
+
return ___EmotionJSX(FocusRing, {
|
56
|
+
focusRingClass: "is-focused"
|
57
|
+
}, ___EmotionJSX(Box, _extends({
|
62
58
|
as: "button",
|
63
59
|
className: classNames,
|
64
60
|
variant: "buttons.rocker"
|
65
61
|
}, rockerButtonProps, {
|
66
62
|
ref: rockerButtonRef
|
67
|
-
},
|
63
|
+
}, itemProps, {
|
68
64
|
sx: {
|
69
65
|
'&.is-selected': _objectSpread({}, itemProps.selectedStyles)
|
70
66
|
}
|
71
|
-
}), rendered);
|
67
|
+
}), rendered));
|
72
68
|
});
|
73
69
|
CollectionRockerButton.displayName = 'CollectionRockerButton';
|
74
70
|
CollectionRockerButton.propTypes = {
|
@@ -114,6 +114,23 @@ export var chip = {
|
|
114
114
|
}
|
115
115
|
};
|
116
116
|
|
117
|
+
var countDefault = _objectSpread(_objectSpread({}, chip), {}, {
|
118
|
+
width: 'fit-content',
|
119
|
+
minWidth: '17px',
|
120
|
+
height: '17px'
|
121
|
+
});
|
122
|
+
|
123
|
+
var chipCount = _objectSpread(_objectSpread({}, countDefault), {}, {
|
124
|
+
backgroundColor: '#640099 !important'
|
125
|
+
});
|
126
|
+
|
127
|
+
var countNeutral = _objectSpread(_objectSpread({}, chipCount), {}, {
|
128
|
+
backgroundColor: '#E4E6E9 !important',
|
129
|
+
'& span': {
|
130
|
+
color: 'neutral.20'
|
131
|
+
}
|
132
|
+
});
|
133
|
+
|
117
134
|
var multivaluesChip = _objectSpread(_objectSpread({}, chip), {}, {
|
118
135
|
alignSelf: 'center',
|
119
136
|
cursor: 'default',
|
@@ -316,6 +333,8 @@ export default {
|
|
316
333
|
base: base,
|
317
334
|
card: card,
|
318
335
|
chip: chip,
|
336
|
+
chipCount: chipCount,
|
337
|
+
countNeutral: countNeutral,
|
319
338
|
selectedItemChip: selectedItemChip,
|
320
339
|
readOnlyChip: readOnlyChip,
|
321
340
|
copy: copy,
|