@sproutsocial/racine 20.5.0 → 20.6.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/CHANGELOG.md +47 -0
- package/__flow__/Listbox/Listbox.flow.js +1 -0
- package/__flow__/Menu/Menu.flow.js +25 -0
- package/commonjs/Listbox/Listbox.js +1 -0
- package/commonjs/Menu/Menu.js +67 -15
- package/commonjs/Menu/styles.js +6 -1
- package/dist/types/Listbox/Listbox.d.ts +4 -0
- package/dist/types/Listbox/Listbox.d.ts.map +1 -1
- package/dist/types/Menu/Menu.d.ts +9 -1
- package/dist/types/Menu/Menu.d.ts.map +1 -1
- package/dist/types/Menu/MenuTypes.d.ts +13 -0
- package/dist/types/Menu/MenuTypes.d.ts.map +1 -1
- package/dist/types/Menu/styles.d.ts.map +1 -1
- package/lib/Listbox/Listbox.js +1 -0
- package/lib/Menu/Menu.js +65 -14
- package/lib/Menu/styles.js +6 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,52 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 20.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 75ca2857b: Adds Menu.Switch subcomponent to Menu and Listbox
|
|
8
|
+
|
|
9
|
+
- Including a Switch in a Menu by passing it as a Menu.Item's children or elemAfter is not accessible for keyboard users.
|
|
10
|
+
- The new Menu.Switch component allows a consumer to use a Switch in a Menu while retaining keyboard accessibility.
|
|
11
|
+
- Like the Menu.Checkbox and Menu.Radio subcomponents, Menu.Switch should be used in place of a Menu.Item, not as a Menu.Item's children, elemBefore, or elemAfter.
|
|
12
|
+
- The placement of the Switch, i.e., in `elemBefore` or `elemAfter`, is determined by the `placement` prop.
|
|
13
|
+
- The text that serves as a label for the Switch can be passed into Menu.Switch as the `children` or `label` prop. Menu will handle programmatically associating the text with the Switch. You should not wrap the text in a Label component.
|
|
14
|
+
- Listbox is a variant of Menu; the same changes and guidelines apply to Listbox.
|
|
15
|
+
|
|
16
|
+
Simplified example migration:
|
|
17
|
+
|
|
18
|
+
### Before
|
|
19
|
+
|
|
20
|
+
```javascript
|
|
21
|
+
<Menu>
|
|
22
|
+
<Menu.Item>
|
|
23
|
+
<Label htmlFor="switch-id">Switch label</Label>
|
|
24
|
+
<Switch id="switch-id" onClick={handleClick} checked={selected} />
|
|
25
|
+
</Menu.Item>
|
|
26
|
+
</Menu>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### After
|
|
30
|
+
|
|
31
|
+
```javascript
|
|
32
|
+
<Menu>
|
|
33
|
+
<Menu.Switch
|
|
34
|
+
id="switch-id"
|
|
35
|
+
placement="after"
|
|
36
|
+
onClick={handleClick}
|
|
37
|
+
selected={selected}
|
|
38
|
+
>
|
|
39
|
+
Switch label
|
|
40
|
+
</Menu.Switch>
|
|
41
|
+
</Menu>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
- bc2935791: Add X (Twitter) logo to partner logos
|
|
45
|
+
|
|
46
|
+
### Patch Changes
|
|
47
|
+
|
|
48
|
+
- bc2935791: Upgrade @babel/traverse
|
|
49
|
+
|
|
3
50
|
## 20.5.0
|
|
4
51
|
|
|
5
52
|
### Minor Changes
|
|
@@ -25,6 +25,7 @@ declare class Listbox extends React.Component<TypeListboxProps> {
|
|
|
25
25
|
static Checkbox: typeof Menu.Checkbox,
|
|
26
26
|
static Radio: typeof Menu.Radio,
|
|
27
27
|
static Group: typeof Menu.Group,
|
|
28
|
+
static Switch: typeof Menu.Switch,
|
|
28
29
|
static Divider: typeof Menu.Divider,
|
|
29
30
|
static FilterInput: typeof Menu.FilterInput,
|
|
30
31
|
}
|
|
@@ -6,6 +6,8 @@ import Button from "../Button/index.flow";
|
|
|
6
6
|
import Popout from "../Popout/index.flow";
|
|
7
7
|
import type { TypeInputProps } from "../Input/index.flow";
|
|
8
8
|
import type { EnumPlacements } from "../Popout/index.flow";
|
|
9
|
+
import type { TypeSwitchProps } from "../Switch/index.flow";
|
|
10
|
+
import type { TypeTextProps } from "../Text/index.flow";
|
|
9
11
|
import type { TypeTheme } from "../types/theme.flow";
|
|
10
12
|
import type { TypeWithDisplayName } from "../types/shared.flow";
|
|
11
13
|
import type { TypeStyledComponentsCommonProps } from "../types/styled-components.flow";
|
|
@@ -65,6 +67,27 @@ export type TypeMenuItemProps = {
|
|
|
65
67
|
alignItems?: string,
|
|
66
68
|
...
|
|
67
69
|
};
|
|
70
|
+
export type TypeMenuItemSwitchProps = {
|
|
71
|
+
...TypeMenuItemProps,
|
|
72
|
+
/** Determines whether the Switch will be rendered as elemBefore or elemAfter. */
|
|
73
|
+
placement: 'before' | 'after',
|
|
74
|
+
/** Pass any valid Text props except children to the label.
|
|
75
|
+
* children is omitted because Menu.Switch's children is rendered as the label's children.*/
|
|
76
|
+
labelProps?: {
|
|
77
|
+
...TypeTextProps,
|
|
78
|
+
children: void,
|
|
79
|
+
...
|
|
80
|
+
},
|
|
81
|
+
/** Pass any valid Switch props except onClick to the Switch.
|
|
82
|
+
* onClick is omitted because it would only be triggered when the Switch itself is clicked with a mouse.
|
|
83
|
+
* The top-level onClick prop, which will be triggered for a click or keypress anywhere on the Menu Item, should be used instead. */
|
|
84
|
+
switchProps?: {
|
|
85
|
+
...TypeSwitchProps,
|
|
86
|
+
onClick: void,
|
|
87
|
+
...
|
|
88
|
+
},
|
|
89
|
+
...
|
|
90
|
+
};
|
|
68
91
|
export type TypeMenuGroupProps = {
|
|
69
92
|
children: React.Node,
|
|
70
93
|
/** If provided, a visible title will be rendered for the group. */
|
|
@@ -101,6 +124,7 @@ declare export var MenuGroup: TypeWithDisplayName<React.StatelessFunctionalCompo
|
|
|
101
124
|
declare export var MenuItem: TypeWithDisplayName<React.StatelessFunctionalComponent<TypeMenuItemProps>>;
|
|
102
125
|
declare export var MenuCheckbox: TypeWithDisplayName<React.StatelessFunctionalComponent<TypeMenuItemProps>>;
|
|
103
126
|
declare export var MenuRadio: TypeWithDisplayName<React.StatelessFunctionalComponent<TypeMenuItemProps>>;
|
|
127
|
+
declare export var MenuSwitch: TypeWithDisplayName<React.StatelessFunctionalComponent<TypeMenuItemSwitchProps>>;
|
|
104
128
|
declare export var MenuDivider: TypeWithDisplayName<React.StatelessFunctionalComponent<any>>;
|
|
105
129
|
declare var MenuFilterInput: TypeWithDisplayName<React.StatelessFunctionalComponent<TypeInputProps>>;
|
|
106
130
|
declare class Menu extends React.Component<TypeMenuProps> {
|
|
@@ -108,6 +132,7 @@ declare class Menu extends React.Component<TypeMenuProps> {
|
|
|
108
132
|
static Item: typeof MenuItem,
|
|
109
133
|
static Checkbox: typeof MenuCheckbox,
|
|
110
134
|
static Radio: typeof MenuRadio,
|
|
135
|
+
static Switch: typeof MenuSwitch,
|
|
111
136
|
static Divider: typeof MenuDivider,
|
|
112
137
|
static FilterInput: typeof MenuFilterInput,
|
|
113
138
|
}
|
|
@@ -110,6 +110,7 @@ exports.ListboxButton = ListboxButton;
|
|
|
110
110
|
Listbox.Option = Listbox.Item = _Menu.default.Item;
|
|
111
111
|
Listbox.Checkbox = _Menu.default.Checkbox;
|
|
112
112
|
Listbox.Radio = _Menu.default.Radio;
|
|
113
|
+
Listbox.Switch = _Menu.default.Switch;
|
|
113
114
|
Listbox.Group = _Menu.default.Group;
|
|
114
115
|
Listbox.Divider = _Menu.default.Divider;
|
|
115
116
|
Listbox.FilterInput = _Menu.default.FilterInput;
|
package/commonjs/Menu/Menu.js
CHANGED
|
@@ -4,7 +4,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.default = exports.MenuRadio = exports.MenuItem = exports.MenuGroup = exports.MenuDivider = exports.MenuCheckbox = exports.MenuButton = exports.Menu = void 0;
|
|
7
|
+
exports.default = exports.MenuSwitch = exports.MenuRadio = exports.MenuItem = exports.MenuGroup = exports.MenuDivider = exports.MenuCheckbox = exports.MenuButton = exports.Menu = void 0;
|
|
8
8
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
9
|
var React = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _lodash = _interopRequireDefault(require("lodash.uniqueid"));
|
|
@@ -18,14 +18,16 @@ var _Icon = _interopRequireDefault(require("../Icon"));
|
|
|
18
18
|
var _Input = _interopRequireDefault(require("../Input"));
|
|
19
19
|
var _Popout = _interopRequireDefault(require("../Popout"));
|
|
20
20
|
var _Radio = _interopRequireDefault(require("../Radio"));
|
|
21
|
+
var _Switch = _interopRequireDefault(require("../Switch"));
|
|
21
22
|
var _Text = _interopRequireDefault(require("../Text"));
|
|
22
23
|
var _utils = require("./utils");
|
|
23
24
|
var _styles = require("./styles");
|
|
24
25
|
var _excluded = ["id", "index", "as", "children", "role", "elemBefore", "elemAfter", "value", "onKeyPress", "onClick", "selected", "disabled", "indeterminate", "label"],
|
|
25
|
-
_excluded2 = ["
|
|
26
|
-
_excluded3 = ["children", "
|
|
27
|
-
_excluded4 = ["
|
|
28
|
-
_excluded5 = ["
|
|
26
|
+
_excluded2 = ["placement", "labelProps", "switchProps", "children", "id", "label"],
|
|
27
|
+
_excluded3 = ["children", "title", "titleAs", "disabled"],
|
|
28
|
+
_excluded4 = ["children", "role", "multiselect", "innerRef"],
|
|
29
|
+
_excluded5 = ["role", "children", "onChange", "value", "multiselect", "innerRef", "footerContent"],
|
|
30
|
+
_excluded6 = ["content", "popoutProps", "children", "onClick", "closeOnItemClick", "id", "placement"];
|
|
29
31
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
30
32
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
31
33
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -246,6 +248,52 @@ var MenuRadio = function MenuRadio(props) {
|
|
|
246
248
|
}, props));
|
|
247
249
|
};
|
|
248
250
|
exports.MenuRadio = MenuRadio;
|
|
251
|
+
var MenuSwitch = function MenuSwitch(props) {
|
|
252
|
+
var _useContext3 = (0, React.useContext)(_utils.MenuContext),
|
|
253
|
+
menuValue = _useContext3.value;
|
|
254
|
+
var placement = props.placement,
|
|
255
|
+
_props$labelProps = props.labelProps,
|
|
256
|
+
labelProps = _props$labelProps === void 0 ? {} : _props$labelProps,
|
|
257
|
+
_props$switchProps = props.switchProps,
|
|
258
|
+
switchProps = _props$switchProps === void 0 ? {} : _props$switchProps,
|
|
259
|
+
children = props.children,
|
|
260
|
+
id = props.id,
|
|
261
|
+
label = props.label,
|
|
262
|
+
rest = _objectWithoutProperties(props, _excluded2);
|
|
263
|
+
var menuItemId = (0, React.useMemo)(function () {
|
|
264
|
+
return id || (0, _lodash.default)('MenuItem-');
|
|
265
|
+
}, [id]);
|
|
266
|
+
var labelId = "".concat(menuItemId, "-label");
|
|
267
|
+
var switchElement = /*#__PURE__*/React.createElement(_Switch.default, _extends({
|
|
268
|
+
id: "".concat(menuItemId, "-switch"),
|
|
269
|
+
checked: props.selected || isValueSelected(menuValue, props.value),
|
|
270
|
+
"aria-hidden": "true",
|
|
271
|
+
tabIndex: -1,
|
|
272
|
+
"aria-labelledby": labelId
|
|
273
|
+
}, placement === 'before' ? {
|
|
274
|
+
mr: 300
|
|
275
|
+
} : {
|
|
276
|
+
ml: 300
|
|
277
|
+
}, switchProps, {
|
|
278
|
+
// This prop is passed after switchProps to disallow overrides.
|
|
279
|
+
onClick: noop
|
|
280
|
+
}));
|
|
281
|
+
var menuItemProps = _objectSpread({
|
|
282
|
+
id: menuItemId,
|
|
283
|
+
label: label,
|
|
284
|
+
elemBefore: placement === 'before' ? switchElement : undefined,
|
|
285
|
+
// Empty fragment prevents a check icon in elemAfter when the switch is checked. Can be overridden.
|
|
286
|
+
elemAfter: placement === 'before' ? /*#__PURE__*/React.createElement(React.Fragment, null) : switchElement
|
|
287
|
+
}, rest);
|
|
288
|
+
return /*#__PURE__*/React.createElement(MenuItem, menuItemProps, /*#__PURE__*/React.createElement(_Text.default, _extends({
|
|
289
|
+
id: labelId
|
|
290
|
+
}, labelProps, {
|
|
291
|
+
// This prop is passed after labelProps to disallow overrides.
|
|
292
|
+
// Fall back to the label prop if children is falsy.
|
|
293
|
+
children: children || label
|
|
294
|
+
})));
|
|
295
|
+
};
|
|
296
|
+
exports.MenuSwitch = MenuSwitch;
|
|
249
297
|
var MenuTitle = (0, _styledComponents.default)(_Text.default).withConfig({
|
|
250
298
|
displayName: "Menu__MenuTitle",
|
|
251
299
|
componentId: "sc-1jmjosz-0"
|
|
@@ -274,8 +322,10 @@ var MenuGroup = function MenuGroup(_ref6) {
|
|
|
274
322
|
titleAs = _ref6.titleAs,
|
|
275
323
|
_ref6$disabled = _ref6.disabled,
|
|
276
324
|
isDisabled = _ref6$disabled === void 0 ? false : _ref6$disabled,
|
|
277
|
-
props = _objectWithoutProperties(_ref6,
|
|
278
|
-
var menuTitleId = (0,
|
|
325
|
+
props = _objectWithoutProperties(_ref6, _excluded3);
|
|
326
|
+
var menuTitleId = (0, React.useMemo)(function () {
|
|
327
|
+
return (0, _lodash.default)('menu-title-');
|
|
328
|
+
}, []);
|
|
279
329
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Box.default, _extends({
|
|
280
330
|
p: 300,
|
|
281
331
|
role: "group",
|
|
@@ -305,9 +355,9 @@ var MenuFilterInput = function MenuFilterInput(props) {
|
|
|
305
355
|
var onChange = props.onChange,
|
|
306
356
|
onFocus = props.onFocus,
|
|
307
357
|
onBlur = props.onBlur;
|
|
308
|
-
var
|
|
309
|
-
state =
|
|
310
|
-
setState =
|
|
358
|
+
var _useContext4 = (0, React.useContext)(_utils.MenuContext),
|
|
359
|
+
state = _useContext4.state,
|
|
360
|
+
setState = _useContext4.setState;
|
|
311
361
|
var handleOnChange = (0, React.useCallback)(function (event, value) {
|
|
312
362
|
onChange && onChange(event, value);
|
|
313
363
|
setState({
|
|
@@ -338,7 +388,7 @@ var MenuItems = function MenuItems(_ref7) {
|
|
|
338
388
|
role = _ref7.role,
|
|
339
389
|
multiselect = _ref7.multiselect,
|
|
340
390
|
innerRef = _ref7.innerRef,
|
|
341
|
-
props = _objectWithoutProperties(_ref7,
|
|
391
|
+
props = _objectWithoutProperties(_ref7, _excluded4);
|
|
342
392
|
var _useMenuKeyDown = (0, _utils.useMenuKeyDown)(),
|
|
343
393
|
handleKeyDown = _useMenuKeyDown.handleKeyDown,
|
|
344
394
|
activeDescendent = _useMenuKeyDown.activeDescendent;
|
|
@@ -360,8 +410,8 @@ var MenuItems = function MenuItems(_ref7) {
|
|
|
360
410
|
};
|
|
361
411
|
var MenuFooter = function MenuFooter(_ref8) {
|
|
362
412
|
var children = _ref8.children;
|
|
363
|
-
var
|
|
364
|
-
setState =
|
|
413
|
+
var _useContext5 = (0, React.useContext)(_utils.MenuContext),
|
|
414
|
+
setState = _useContext5.setState;
|
|
365
415
|
var handleOnBlur = (0, React.useCallback)(function () {
|
|
366
416
|
setState({
|
|
367
417
|
isFooterFocused: false
|
|
@@ -386,7 +436,7 @@ var Menu = function Menu(_ref9) {
|
|
|
386
436
|
multiselect = _ref9.multiselect,
|
|
387
437
|
innerRef = _ref9.innerRef,
|
|
388
438
|
footerContent = _ref9.footerContent,
|
|
389
|
-
props = _objectWithoutProperties(_ref9,
|
|
439
|
+
props = _objectWithoutProperties(_ref9, _excluded5);
|
|
390
440
|
var _useDescendants = (0, _utils.useDescendants)(),
|
|
391
441
|
_useDescendants2 = _slicedToArray(_useDescendants, 2),
|
|
392
442
|
descendants = _useDescendants2[0],
|
|
@@ -434,6 +484,7 @@ MenuGroup.displayName = 'Menu.Group';
|
|
|
434
484
|
MenuItem.displayName = 'Menu.Item';
|
|
435
485
|
MenuCheckbox.displayName = 'Menu.Checkbox';
|
|
436
486
|
MenuRadio.displayName = 'Menu.Radio';
|
|
487
|
+
MenuSwitch.displayName = 'Menu.Switch';
|
|
437
488
|
MenuDivider.displayName = 'Menu.Divider';
|
|
438
489
|
MenuFilterInput.displayName = 'Menu.FilterInput';
|
|
439
490
|
Menu.displayName = 'Menu';
|
|
@@ -441,6 +492,7 @@ Menu.Group = MenuGroup;
|
|
|
441
492
|
Menu.Item = MenuItem;
|
|
442
493
|
Menu.Checkbox = MenuCheckbox;
|
|
443
494
|
Menu.Radio = MenuRadio;
|
|
495
|
+
Menu.Switch = MenuSwitch;
|
|
444
496
|
Menu.Divider = MenuDivider;
|
|
445
497
|
Menu.FilterInput = MenuFilterInput;
|
|
446
498
|
var CustomPopoutContent = (0, _styledComponents.default)(_Popout.default.Content).withConfig({
|
|
@@ -458,7 +510,7 @@ var MenuButton = function MenuButton(_ref10) {
|
|
|
458
510
|
id = _ref10$id === void 0 ? (0, _lodash.default)('MenuButton-') : _ref10$id,
|
|
459
511
|
_ref10$placement = _ref10.placement,
|
|
460
512
|
placement = _ref10$placement === void 0 ? 'bottom' : _ref10$placement,
|
|
461
|
-
props = _objectWithoutProperties(_ref10,
|
|
513
|
+
props = _objectWithoutProperties(_ref10, _excluded6);
|
|
462
514
|
var _useState5 = (0, React.useState)(false),
|
|
463
515
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
464
516
|
isOpen = _useState6[0],
|
package/commonjs/Menu/styles.js
CHANGED
|
@@ -8,13 +8,14 @@ exports.MenuItemsContainer = exports.MenuItemContainer = void 0;
|
|
|
8
8
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
9
9
|
var _mixins = require("../utils/mixins");
|
|
10
10
|
var _Box = _interopRequireDefault(require("../Box"));
|
|
11
|
+
var _styles = require("../Switch/styles");
|
|
11
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
13
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
14
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
14
15
|
var MenuItemContainer = (0, _styledComponents.default)(_Box.default).withConfig({
|
|
15
16
|
displayName: "styles__MenuItemContainer",
|
|
16
17
|
componentId: "sc-168zlb1-0"
|
|
17
|
-
})(["", ";width:100%;border-radius:", ";background-color:", ";border:none;text-align:left;color:", ";font-family:", ";font-weight:", ";padding:", ";list-style-type:none;outline:0;", ";", " ", " ", " ", " ", ""], function (props) {
|
|
18
|
+
})(["", ";width:100%;border-radius:", ";background-color:", ";border:none;text-align:left;color:", ";font-family:", ";font-weight:", ";padding:", ";list-style-type:none;outline:0;", ";", " ", " ", "{", "}", " ", " ", ""], function (props) {
|
|
18
19
|
return !props.hidden && (0, _styledComponents.css)(["display:block;"]);
|
|
19
20
|
}, function (props) {
|
|
20
21
|
return props.theme.radii[500];
|
|
@@ -40,6 +41,10 @@ var MenuItemContainer = (0, _styledComponents.default)(_Box.default).withConfig(
|
|
|
40
41
|
}, props.theme.colors.listItem.background.selected, function (props) {
|
|
41
42
|
return props.theme.colors.text.inverse;
|
|
42
43
|
});
|
|
44
|
+
}, _styles.StyledSwitchButton, function (props) {
|
|
45
|
+
return props.active && !props.disabled && (0, _styledComponents.css)(["border-color:", ";"], function (props) {
|
|
46
|
+
return props.theme.colors.container.border.base;
|
|
47
|
+
});
|
|
43
48
|
}, function (props) {
|
|
44
49
|
return !props.disabled && (0, _styledComponents.css)(["&:focus,&:hover{color:", ";background-color:", ";.Icon-svg{color:unset;}}"], function (props) {
|
|
45
50
|
return props.theme.colors.text.body;
|
|
@@ -18,6 +18,10 @@ export declare const Listbox: {
|
|
|
18
18
|
(props: import("../Menu").TypeMenuItemProps): JSX.Element;
|
|
19
19
|
displayName: string;
|
|
20
20
|
};
|
|
21
|
+
Switch: {
|
|
22
|
+
(props: import("../Menu").TypeMenuSwitchProps): JSX.Element;
|
|
23
|
+
displayName: string;
|
|
24
|
+
};
|
|
21
25
|
Group: {
|
|
22
26
|
({ children, title, titleAs, disabled: isDisabled, ...props }: import("../Menu").TypeMenuGroupProps): JSX.Element;
|
|
23
27
|
displayName: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Listbox.d.ts","sourceRoot":"","sources":["../../../src/Listbox/Listbox.tsx"],"names":[],"mappings":";AAMA,OAAO,KAAK,EAAC,gBAAgB,EAAE,sBAAsB,EAAC,MAAM,gBAAgB,CAAC;AAC7E,eAAO,MAAM,OAAO;kCAIjB,gBAAgB
|
|
1
|
+
{"version":3,"file":"Listbox.d.ts","sourceRoot":"","sources":["../../../src/Listbox/Listbox.tsx"],"names":[],"mappings":";AAMA,OAAO,KAAK,EAAC,gBAAgB,EAAE,sBAAsB,EAAC,MAAM,gBAAgB,CAAC;AAC7E,eAAO,MAAM,OAAO;kCAIjB,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAMlB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,sBAAsB,oPAuDlC,CAAC;AACF,eAAO,MAAM,aAAa,+BAGvB,sBAAsB,gBAaxB,CAAC;AAQF,eAAe,OAAO,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { TypeBoxProps } from '../Box';
|
|
3
3
|
import { TypeInputProps } from '../Input';
|
|
4
|
-
import type { TypeMenuButtonProps, TypeMenuGroupProps, TypeMenuItemProps, TypeMenuProps } from './MenuTypes';
|
|
4
|
+
import type { TypeMenuButtonProps, TypeMenuGroupProps, TypeMenuItemProps, TypeMenuProps, TypeMenuSwitchProps } from './MenuTypes';
|
|
5
5
|
export declare const MenuItem: {
|
|
6
6
|
({ id: idProp, index: indexProp, as, children, role: roleProp, elemBefore, elemAfter, value: valueProp, onKeyPress, onClick, selected, disabled, indeterminate, label: labelProp, ...props }: TypeMenuItemProps): JSX.Element;
|
|
7
7
|
displayName: string;
|
|
@@ -14,6 +14,10 @@ export declare const MenuRadio: {
|
|
|
14
14
|
(props: TypeMenuItemProps): JSX.Element;
|
|
15
15
|
displayName: string;
|
|
16
16
|
};
|
|
17
|
+
export declare const MenuSwitch: {
|
|
18
|
+
(props: TypeMenuSwitchProps): JSX.Element;
|
|
19
|
+
displayName: string;
|
|
20
|
+
};
|
|
17
21
|
export declare const MenuGroup: {
|
|
18
22
|
({ children, title, titleAs, disabled: isDisabled, ...props }: TypeMenuGroupProps): JSX.Element;
|
|
19
23
|
displayName: string;
|
|
@@ -41,6 +45,10 @@ export declare const Menu: {
|
|
|
41
45
|
(props: TypeMenuItemProps): JSX.Element;
|
|
42
46
|
displayName: string;
|
|
43
47
|
};
|
|
48
|
+
Switch: {
|
|
49
|
+
(props: TypeMenuSwitchProps): JSX.Element;
|
|
50
|
+
displayName: string;
|
|
51
|
+
};
|
|
44
52
|
Divider: {
|
|
45
53
|
(props: TypeBoxProps): JSX.Element;
|
|
46
54
|
displayName: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Menu.d.ts","sourceRoot":"","sources":["../../../src/Menu/Menu.tsx"],"names":[],"mappings":";AAcA,OAAY,EAAC,YAAY,EAAC,MAAM,UAAU,CAAC;AAI3C,OAAc,EAAC,cAAc,EAAC,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"Menu.d.ts","sourceRoot":"","sources":["../../../src/Menu/Menu.tsx"],"names":[],"mappings":";AAcA,OAAY,EAAC,YAAY,EAAC,MAAM,UAAU,CAAC;AAI3C,OAAc,EAAC,cAAc,EAAC,MAAM,YAAY,CAAC;AAKjD,OAAO,KAAK,EACV,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EAEjB,aAAa,EAEb,mBAAmB,EACpB,MAAM,aAAa,CAAC;AA8CrB,eAAO,MAAM,QAAQ;kMAgBlB,iBAAiB;;CAuLnB,CAAC;AACF,eAAO,MAAM,YAAY;YAAW,iBAAiB;;CAEpD,CAAC;AACF,eAAO,MAAM,SAAS;YAAW,iBAAiB;;CAEjD,CAAC;AAEF,eAAO,MAAM,UAAU;YAAW,mBAAmB;;CA8CpD,CAAC;AAUF,eAAO,MAAM,SAAS;mEAMnB,kBAAkB;;CA2BpB,CAAC;AAEF,eAAO,MAAM,WAAW;YAAW,YAAY;;CAQ9C,CAAC;AA4FF,eAAO,MAAM,IAAI;0FASd,aAAa;;;uEA1Ib,kBAAkB;;;;sMA7PlB,iBAAiB;;;;gBAwLgB,iBAAiB;;;;gBAGpB,iBAAiB;;;;gBAIhB,mBAAmB;;;;gBA2FlB,YAAY;;;;gBAUf,cAAc;;;CAuJ7C,CAAC;AAuBF,eAAO,MAAM,UAAU,2FASpB,mBAAmB,gBA+CrB,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -2,7 +2,9 @@ import type { TypeStyledComponentsCommonProps } from '../types/styled-components
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import type { TypeBoxProps } from '../Box';
|
|
4
4
|
import type { TypeButtonProps } from '../Button';
|
|
5
|
+
import type { TypeTextProps } from '../Text';
|
|
5
6
|
import type { EnumPlacements, TypePopoutProps } from '../Popout/PopoutTypes';
|
|
7
|
+
import type { TypeSwitchProps } from '../Switch';
|
|
6
8
|
import { MENU_ITEM_ROLES, MENU_ROLES } from './utils/constants';
|
|
7
9
|
export type TypeMenuRoles = (typeof MENU_ROLES)[keyof typeof MENU_ROLES];
|
|
8
10
|
export type TypeMenuItemRoles = (typeof MENU_ITEM_ROLES)[keyof typeof MENU_ITEM_ROLES];
|
|
@@ -53,6 +55,17 @@ export interface TypeMenuItemProps {
|
|
|
53
55
|
'data-qa-menu-item'?: string;
|
|
54
56
|
alignItems?: string;
|
|
55
57
|
}
|
|
58
|
+
export interface TypeMenuSwitchProps extends TypeMenuItemProps {
|
|
59
|
+
/** Determines whether the Switch will be rendered as elemBefore or elemAfter. */
|
|
60
|
+
placement: 'before' | 'after';
|
|
61
|
+
/** Pass any valid Text props except children to the label.
|
|
62
|
+
* children is omitted because Menu.Switch's children is rendered as the label's children.*/
|
|
63
|
+
labelProps?: Partial<Omit<TypeTextProps, 'children'>>;
|
|
64
|
+
/** Pass any valid Switch props except onClick to the Switch.
|
|
65
|
+
* onClick is omitted because it would only be triggered when the Switch itself is clicked with a mouse.
|
|
66
|
+
* The top-level onClick prop, which will be triggered for a click or keypress anywhere on the Menu Item, should be used instead. */
|
|
67
|
+
switchProps?: Partial<Omit<TypeSwitchProps, 'onClick'>>;
|
|
68
|
+
}
|
|
56
69
|
export interface TypeMenuGroupProps extends Omit<TypeBoxProps, 'title'> {
|
|
57
70
|
children: React.ReactNode;
|
|
58
71
|
/** If provided, a visible title will be rendered for the group. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuTypes.d.ts","sourceRoot":"","sources":["../../../src/Menu/MenuTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,+BAA+B,EAAC,MAAM,8BAA8B,CAAC;AAClF,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,UAAU,CAAC;AAC3C,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAC,cAAc,EAAE,eAAe,EAAC,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAC,eAAe,EAAE,UAAU,EAAC,MAAM,mBAAmB,CAAC;AAE9D,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AACzE,MAAM,MAAM,iBAAiB,GAC3B,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,OAAO,eAAe,CAAC,CAAC;AAEzD,MAAM,WAAW,aAAa;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;IAC3C,oBAAoB,EAAE,OAAO,CAAC;IAC9B,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,mBAAmB;IAClC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,KAAK,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,MAAM,EAAE,CA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CAAC,EAAE,cAAc,CAAC;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,0BAA2B,SAAQ,iBAAiB;IACnE,WAAW,EAAE,OAAO,CAAC;IACrB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,MAAM,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;CACpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/Menu/styles.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/Menu/styles.ts"],"names":[],"mappings":";AAIA,OAAO,KAAK,EAAC,0BAA0B,EAAC,MAAM,qBAAqB,CAAC;AAEpE,eAAO,MAAM,iBAAiB,mQA8E7B,CAAC;AAEF,eAAO,MAAM,kBAAkB,2OAQ9B,CAAC"}
|
package/lib/Listbox/Listbox.js
CHANGED
|
@@ -98,6 +98,7 @@ export var ListboxButton = function ListboxButton(_ref2) {
|
|
|
98
98
|
Listbox.Option = Listbox.Item = Menu.Item;
|
|
99
99
|
Listbox.Checkbox = Menu.Checkbox;
|
|
100
100
|
Listbox.Radio = Menu.Radio;
|
|
101
|
+
Listbox.Switch = Menu.Switch;
|
|
101
102
|
Listbox.Group = Menu.Group;
|
|
102
103
|
Listbox.Divider = Menu.Divider;
|
|
103
104
|
Listbox.FilterInput = Menu.FilterInput;
|
package/lib/Menu/Menu.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
2
|
import _styled from "styled-components";
|
|
3
3
|
var _excluded = ["id", "index", "as", "children", "role", "elemBefore", "elemAfter", "value", "onKeyPress", "onClick", "selected", "disabled", "indeterminate", "label"],
|
|
4
|
-
_excluded2 = ["
|
|
5
|
-
_excluded3 = ["children", "
|
|
6
|
-
_excluded4 = ["
|
|
7
|
-
_excluded5 = ["
|
|
4
|
+
_excluded2 = ["placement", "labelProps", "switchProps", "children", "id", "label"],
|
|
5
|
+
_excluded3 = ["children", "title", "titleAs", "disabled"],
|
|
6
|
+
_excluded4 = ["children", "role", "multiselect", "innerRef"],
|
|
7
|
+
_excluded5 = ["role", "children", "onChange", "value", "multiselect", "innerRef", "footerContent"],
|
|
8
|
+
_excluded6 = ["content", "popoutProps", "children", "onClick", "closeOnItemClick", "id", "placement"];
|
|
8
9
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9
10
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
11
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -33,6 +34,7 @@ import Icon from "../Icon";
|
|
|
33
34
|
import Input from "../Input";
|
|
34
35
|
import Popout from "../Popout";
|
|
35
36
|
import Radio from "../Radio";
|
|
37
|
+
import Switch from "../Switch";
|
|
36
38
|
import Text from "../Text";
|
|
37
39
|
import { MENU_ITEM_ROLES, MENU_ROLES, DescendantProvider, useDescendant, useDescendants, MenuButtonContext, MenuContext, MenuDescendantContext, useMenuKeyDown } from "./utils";
|
|
38
40
|
import { MenuItemContainer, MenuItemsContainer } from "./styles";
|
|
@@ -237,6 +239,51 @@ export var MenuRadio = function MenuRadio(props) {
|
|
|
237
239
|
role: MENU_ITEM_ROLES.RADIO
|
|
238
240
|
}, props));
|
|
239
241
|
};
|
|
242
|
+
export var MenuSwitch = function MenuSwitch(props) {
|
|
243
|
+
var _useContext3 = useContext(MenuContext),
|
|
244
|
+
menuValue = _useContext3.value;
|
|
245
|
+
var placement = props.placement,
|
|
246
|
+
_props$labelProps = props.labelProps,
|
|
247
|
+
labelProps = _props$labelProps === void 0 ? {} : _props$labelProps,
|
|
248
|
+
_props$switchProps = props.switchProps,
|
|
249
|
+
switchProps = _props$switchProps === void 0 ? {} : _props$switchProps,
|
|
250
|
+
children = props.children,
|
|
251
|
+
id = props.id,
|
|
252
|
+
label = props.label,
|
|
253
|
+
rest = _objectWithoutProperties(props, _excluded2);
|
|
254
|
+
var menuItemId = useMemo(function () {
|
|
255
|
+
return id || uniqueId('MenuItem-');
|
|
256
|
+
}, [id]);
|
|
257
|
+
var labelId = "".concat(menuItemId, "-label");
|
|
258
|
+
var switchElement = /*#__PURE__*/React.createElement(Switch, _extends({
|
|
259
|
+
id: "".concat(menuItemId, "-switch"),
|
|
260
|
+
checked: props.selected || isValueSelected(menuValue, props.value),
|
|
261
|
+
"aria-hidden": "true",
|
|
262
|
+
tabIndex: -1,
|
|
263
|
+
"aria-labelledby": labelId
|
|
264
|
+
}, placement === 'before' ? {
|
|
265
|
+
mr: 300
|
|
266
|
+
} : {
|
|
267
|
+
ml: 300
|
|
268
|
+
}, switchProps, {
|
|
269
|
+
// This prop is passed after switchProps to disallow overrides.
|
|
270
|
+
onClick: noop
|
|
271
|
+
}));
|
|
272
|
+
var menuItemProps = _objectSpread({
|
|
273
|
+
id: menuItemId,
|
|
274
|
+
label: label,
|
|
275
|
+
elemBefore: placement === 'before' ? switchElement : undefined,
|
|
276
|
+
// Empty fragment prevents a check icon in elemAfter when the switch is checked. Can be overridden.
|
|
277
|
+
elemAfter: placement === 'before' ? /*#__PURE__*/React.createElement(React.Fragment, null) : switchElement
|
|
278
|
+
}, rest);
|
|
279
|
+
return /*#__PURE__*/React.createElement(MenuItem, menuItemProps, /*#__PURE__*/React.createElement(Text, _extends({
|
|
280
|
+
id: labelId
|
|
281
|
+
}, labelProps, {
|
|
282
|
+
// This prop is passed after labelProps to disallow overrides.
|
|
283
|
+
// Fall back to the label prop if children is falsy.
|
|
284
|
+
children: children || label
|
|
285
|
+
})));
|
|
286
|
+
};
|
|
240
287
|
var MenuTitle = styled(Text).withConfig({
|
|
241
288
|
displayName: "Menu__MenuTitle",
|
|
242
289
|
componentId: "sc-1jmjosz-0"
|
|
@@ -265,8 +312,10 @@ export var MenuGroup = function MenuGroup(_ref6) {
|
|
|
265
312
|
titleAs = _ref6.titleAs,
|
|
266
313
|
_ref6$disabled = _ref6.disabled,
|
|
267
314
|
isDisabled = _ref6$disabled === void 0 ? false : _ref6$disabled,
|
|
268
|
-
props = _objectWithoutProperties(_ref6,
|
|
269
|
-
var menuTitleId =
|
|
315
|
+
props = _objectWithoutProperties(_ref6, _excluded3);
|
|
316
|
+
var menuTitleId = useMemo(function () {
|
|
317
|
+
return uniqueId('menu-title-');
|
|
318
|
+
}, []);
|
|
270
319
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Box, _extends({
|
|
271
320
|
p: 300,
|
|
272
321
|
role: "group",
|
|
@@ -294,9 +343,9 @@ var MenuFilterInput = function MenuFilterInput(props) {
|
|
|
294
343
|
var onChange = props.onChange,
|
|
295
344
|
onFocus = props.onFocus,
|
|
296
345
|
onBlur = props.onBlur;
|
|
297
|
-
var
|
|
298
|
-
state =
|
|
299
|
-
setState =
|
|
346
|
+
var _useContext4 = useContext(MenuContext),
|
|
347
|
+
state = _useContext4.state,
|
|
348
|
+
setState = _useContext4.setState;
|
|
300
349
|
var handleOnChange = useCallback(function (event, value) {
|
|
301
350
|
onChange && onChange(event, value);
|
|
302
351
|
setState({
|
|
@@ -327,7 +376,7 @@ var MenuItems = function MenuItems(_ref7) {
|
|
|
327
376
|
role = _ref7.role,
|
|
328
377
|
multiselect = _ref7.multiselect,
|
|
329
378
|
innerRef = _ref7.innerRef,
|
|
330
|
-
props = _objectWithoutProperties(_ref7,
|
|
379
|
+
props = _objectWithoutProperties(_ref7, _excluded4);
|
|
331
380
|
var _useMenuKeyDown = useMenuKeyDown(),
|
|
332
381
|
handleKeyDown = _useMenuKeyDown.handleKeyDown,
|
|
333
382
|
activeDescendent = _useMenuKeyDown.activeDescendent;
|
|
@@ -349,8 +398,8 @@ var MenuItems = function MenuItems(_ref7) {
|
|
|
349
398
|
};
|
|
350
399
|
var MenuFooter = function MenuFooter(_ref8) {
|
|
351
400
|
var children = _ref8.children;
|
|
352
|
-
var
|
|
353
|
-
setState =
|
|
401
|
+
var _useContext5 = useContext(MenuContext),
|
|
402
|
+
setState = _useContext5.setState;
|
|
354
403
|
var handleOnBlur = useCallback(function () {
|
|
355
404
|
setState({
|
|
356
405
|
isFooterFocused: false
|
|
@@ -375,7 +424,7 @@ export var Menu = function Menu(_ref9) {
|
|
|
375
424
|
multiselect = _ref9.multiselect,
|
|
376
425
|
innerRef = _ref9.innerRef,
|
|
377
426
|
footerContent = _ref9.footerContent,
|
|
378
|
-
props = _objectWithoutProperties(_ref9,
|
|
427
|
+
props = _objectWithoutProperties(_ref9, _excluded5);
|
|
379
428
|
var _useDescendants = useDescendants(),
|
|
380
429
|
_useDescendants2 = _slicedToArray(_useDescendants, 2),
|
|
381
430
|
descendants = _useDescendants2[0],
|
|
@@ -422,6 +471,7 @@ MenuGroup.displayName = 'Menu.Group';
|
|
|
422
471
|
MenuItem.displayName = 'Menu.Item';
|
|
423
472
|
MenuCheckbox.displayName = 'Menu.Checkbox';
|
|
424
473
|
MenuRadio.displayName = 'Menu.Radio';
|
|
474
|
+
MenuSwitch.displayName = 'Menu.Switch';
|
|
425
475
|
MenuDivider.displayName = 'Menu.Divider';
|
|
426
476
|
MenuFilterInput.displayName = 'Menu.FilterInput';
|
|
427
477
|
Menu.displayName = 'Menu';
|
|
@@ -429,6 +479,7 @@ Menu.Group = MenuGroup;
|
|
|
429
479
|
Menu.Item = MenuItem;
|
|
430
480
|
Menu.Checkbox = MenuCheckbox;
|
|
431
481
|
Menu.Radio = MenuRadio;
|
|
482
|
+
Menu.Switch = MenuSwitch;
|
|
432
483
|
Menu.Divider = MenuDivider;
|
|
433
484
|
Menu.FilterInput = MenuFilterInput;
|
|
434
485
|
var CustomPopoutContent = styled(Popout.Content).withConfig({
|
|
@@ -446,7 +497,7 @@ export var MenuButton = function MenuButton(_ref10) {
|
|
|
446
497
|
id = _ref10$id === void 0 ? uniqueId('MenuButton-') : _ref10$id,
|
|
447
498
|
_ref10$placement = _ref10.placement,
|
|
448
499
|
placement = _ref10$placement === void 0 ? 'bottom' : _ref10$placement,
|
|
449
|
-
props = _objectWithoutProperties(_ref10,
|
|
500
|
+
props = _objectWithoutProperties(_ref10, _excluded6);
|
|
450
501
|
var _useState5 = useState(false),
|
|
451
502
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
452
503
|
isOpen = _useState6[0],
|
package/lib/Menu/styles.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import styled, { css } from 'styled-components';
|
|
2
2
|
import { disabled, focusRing } from "../utils/mixins";
|
|
3
3
|
import Box from "../Box";
|
|
4
|
+
import { StyledSwitchButton as Switch } from "../Switch/styles";
|
|
4
5
|
export var MenuItemContainer = styled(Box).withConfig({
|
|
5
6
|
displayName: "styles__MenuItemContainer",
|
|
6
7
|
componentId: "sc-168zlb1-0"
|
|
7
|
-
})(["", ";width:100%;border-radius:", ";background-color:", ";border:none;text-align:left;color:", ";font-family:", ";font-weight:", ";padding:", ";list-style-type:none;outline:0;", ";", " ", " ", " ", " ", ""], function (props) {
|
|
8
|
+
})(["", ";width:100%;border-radius:", ";background-color:", ";border:none;text-align:left;color:", ";font-family:", ";font-weight:", ";padding:", ";list-style-type:none;outline:0;", ";", " ", " ", "{", "}", " ", " ", ""], function (props) {
|
|
8
9
|
return !props.hidden && css(["display:block;"]);
|
|
9
10
|
}, function (props) {
|
|
10
11
|
return props.theme.radii[500];
|
|
@@ -30,6 +31,10 @@ export var MenuItemContainer = styled(Box).withConfig({
|
|
|
30
31
|
}, props.theme.colors.listItem.background.selected, function (props) {
|
|
31
32
|
return props.theme.colors.text.inverse;
|
|
32
33
|
});
|
|
34
|
+
}, Switch, function (props) {
|
|
35
|
+
return props.active && !props.disabled && css(["border-color:", ";"], function (props) {
|
|
36
|
+
return props.theme.colors.container.border.base;
|
|
37
|
+
});
|
|
33
38
|
}, function (props) {
|
|
34
39
|
return !props.disabled && css(["&:focus,&:hover{color:", ";background-color:", ";.Icon-svg{color:unset;}}"], function (props) {
|
|
35
40
|
return props.theme.colors.text.body;
|