@spaced-out/ui-design-system 0.1.46 → 0.1.48-beta.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/.cspell/custom-words.txt +2 -0
- package/.github/workflows/publish_to_npm.yml +1 -1
- package/CHANGELOG.md +14 -0
- package/design-tokens/color/app-color.json +3 -0
- package/lib/components/Badge/Badge.js +6 -1
- package/lib/components/Badge/Badge.js.flow +10 -0
- package/lib/components/Dropdown/Dropdown.js +1 -3
- package/lib/components/Dropdown/Dropdown.js.flow +0 -2
- package/lib/components/SubMenu/SubMenu.js +18 -156
- package/lib/components/SubMenu/SubMenu.js.flow +37 -239
- package/lib/components/SubMenu/SubMenu.module.css +127 -25
- package/lib/components/SubMenu/SubMenuGroup.js +108 -0
- package/lib/components/SubMenu/SubMenuGroup.js.flow +156 -0
- package/lib/components/SubMenu/SubMenuItem.js +120 -0
- package/lib/components/SubMenu/SubMenuItem.js.flow +166 -0
- package/lib/components/SubMenu/SubMenuLink.js +62 -0
- package/lib/components/SubMenu/SubMenuLink.js.flow +89 -0
- package/lib/components/SubMenu/index.js +41 -34
- package/lib/components/SubMenu/index.js.flow +4 -9
- package/lib/components/Typeahead/Typeahead.js +1 -3
- package/lib/components/Typeahead/Typeahead.js.flow +0 -2
- package/lib/styles/index.css +2 -0
- package/lib/styles/index.js +5 -3
- package/lib/styles/index.js.flow +2 -0
- package/lib/styles/variables/_color.css +2 -0
- package/lib/styles/variables/_color.js +3 -1
- package/lib/styles/variables/_color.js.flow +2 -0
- package/package.json +1 -1
package/.cspell/custom-words.txt
CHANGED
|
@@ -22,7 +22,7 @@ jobs:
|
|
|
22
22
|
- name: Check Permissions
|
|
23
23
|
id: check-permissions
|
|
24
24
|
env:
|
|
25
|
-
ALLOWED_USERS: superrover, Anant-Raj, nsfmc, ashwini-sensehq
|
|
25
|
+
ALLOWED_USERS: superrover, Anant-Raj, nsfmc, ashwini-sensehq, aditya-kaushal
|
|
26
26
|
if: ${{ !contains(env.ALLOWED_USERS, github.actor) }}
|
|
27
27
|
run: |
|
|
28
28
|
echo "You don't have correct permissions to do this release"
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.1.48-beta.0](https://github.com/spaced-out/ui-design-system/compare/v0.1.47...v0.1.48-beta.0) (2023-09-04)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* submenu updates ([#138](https://github.com/spaced-out/ui-design-system/issues/138)) ([71b0c7a](https://github.com/spaced-out/ui-design-system/commit/71b0c7ad9a537c8d42968bf5c773390c6f080329))
|
|
11
|
+
|
|
12
|
+
### [0.1.47](https://github.com/spaced-out/ui-design-system/compare/v0.1.46...v0.1.47) (2023-08-30)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* background fix for dropdown and typeahead ([2dc52ef](https://github.com/spaced-out/ui-design-system/commit/2dc52ef72eeb557e479c65abfda67d19c1576eee))
|
|
18
|
+
|
|
5
19
|
### [0.1.46](https://github.com/spaced-out/ui-design-system/compare/v0.1.45...v0.1.46) (2023-08-29)
|
|
6
20
|
|
|
7
21
|
|
|
@@ -16,10 +16,15 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
16
16
|
const BADGE_COLOR = Object.freeze({
|
|
17
17
|
gray: _color.colorGrayLightest,
|
|
18
18
|
red: _color.colorDangerLightest,
|
|
19
|
+
redDark: _color.colorDanger,
|
|
19
20
|
orange: _color.colorWarningLightest,
|
|
21
|
+
orangeDark: _color.colorWarning,
|
|
20
22
|
green: _color.colorSuccessLightest,
|
|
23
|
+
greenDark: _color.colorSuccess,
|
|
21
24
|
blue: _color.colorInformationLightest,
|
|
22
|
-
|
|
25
|
+
blueDark: _color.colorInformation,
|
|
26
|
+
indigo: _color.colorNeutralLightest,
|
|
27
|
+
indigoDark: _color.colorNeutral
|
|
23
28
|
});
|
|
24
29
|
exports.BADGE_COLOR = BADGE_COLOR;
|
|
25
30
|
const Badge = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
@@ -3,11 +3,16 @@
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
|
+
colorDanger,
|
|
6
7
|
colorDangerLightest,
|
|
7
8
|
colorGrayLightest,
|
|
9
|
+
colorInformation,
|
|
8
10
|
colorInformationLightest,
|
|
11
|
+
colorNeutral,
|
|
9
12
|
colorNeutralLightest,
|
|
13
|
+
colorSuccess,
|
|
10
14
|
colorSuccessLightest,
|
|
15
|
+
colorWarning,
|
|
11
16
|
colorWarningLightest,
|
|
12
17
|
} from '../../styles/variables/_color';
|
|
13
18
|
import classify from '../../utils/classify';
|
|
@@ -21,10 +26,15 @@ type ClassNames = $ReadOnly<{wrapper?: string, text?: string}>;
|
|
|
21
26
|
export const BADGE_COLOR = Object.freeze({
|
|
22
27
|
gray: colorGrayLightest,
|
|
23
28
|
red: colorDangerLightest,
|
|
29
|
+
redDark: colorDanger,
|
|
24
30
|
orange: colorWarningLightest,
|
|
31
|
+
orangeDark: colorWarning,
|
|
25
32
|
green: colorSuccessLightest,
|
|
33
|
+
greenDark: colorSuccess,
|
|
26
34
|
blue: colorInformationLightest,
|
|
35
|
+
blueDark: colorInformation,
|
|
27
36
|
indigo: colorNeutralLightest,
|
|
37
|
+
indigoDark: colorNeutral,
|
|
28
38
|
});
|
|
29
39
|
|
|
30
40
|
export type BadgeColorType = $Keys<typeof BADGE_COLOR>;
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.Dropdown = void 0;
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _react2 = require("@floating-ui/react");
|
|
9
|
-
var _color = require("../../styles/variables/_color");
|
|
10
9
|
var _size = require("../../styles/variables/_size");
|
|
11
10
|
var _space = require("../../styles/variables/_space");
|
|
12
11
|
var _classify = require("../../utils/classify");
|
|
@@ -81,8 +80,7 @@ const Dropdown = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
81
80
|
position: strategy,
|
|
82
81
|
top: y ?? _space.spaceNone,
|
|
83
82
|
left: x ?? _space.spaceNone,
|
|
84
|
-
width: _size.sizeFluid
|
|
85
|
-
backgroundColor: _color.colorBackgroundTertiary
|
|
83
|
+
width: _size.sizeFluid
|
|
86
84
|
}
|
|
87
85
|
}, /*#__PURE__*/React.createElement(_Menu.Menu, _extends({}, menu, {
|
|
88
86
|
onSelect: option => {
|
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
useFloating,
|
|
13
13
|
} from '@floating-ui/react';
|
|
14
14
|
|
|
15
|
-
import {colorBackgroundTertiary} from '../../styles/variables/_color';
|
|
16
15
|
import {sizeFluid} from '../../styles/variables/_size';
|
|
17
16
|
import {spaceNone, spaceXXSmall} from '../../styles/variables/_space';
|
|
18
17
|
import {classify} from '../../utils/classify';
|
|
@@ -102,7 +101,6 @@ export const Dropdown: React$AbstractComponent<
|
|
|
102
101
|
top: y ?? spaceNone,
|
|
103
102
|
left: x ?? spaceNone,
|
|
104
103
|
width: sizeFluid,
|
|
105
|
-
backgroundColor: colorBackgroundTertiary,
|
|
106
104
|
}}
|
|
107
105
|
>
|
|
108
106
|
<Menu
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.SubMenu = void 0;
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _classify = _interopRequireDefault(require("../../utils/classify"));
|
|
9
9
|
var _Button = require("../Button");
|
|
@@ -13,169 +13,23 @@ var _SubMenuModule = _interopRequireDefault(require("./SubMenu.module.css"));
|
|
|
13
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
14
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
15
|
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; }
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
let {
|
|
19
|
-
className,
|
|
20
|
-
...props
|
|
21
|
-
} = _ref;
|
|
22
|
-
return /*#__PURE__*/React.createElement(_Icon.Icon, _extends({}, props, {
|
|
23
|
-
size: "small",
|
|
24
|
-
color: _Text.TEXT_COLORS.inverseSecondary,
|
|
25
|
-
className: (0, _classify.default)(_SubMenuModule.default.menuIcon, className)
|
|
26
|
-
}));
|
|
27
|
-
};
|
|
28
|
-
exports.SubMenuItemIcon = SubMenuItemIcon;
|
|
29
|
-
SubMenuItemIcon.displayName = 'SubMenuItemIcon';
|
|
30
|
-
const SubMenuItemText = _ref2 => {
|
|
31
|
-
let {
|
|
32
|
-
children,
|
|
33
|
-
className,
|
|
34
|
-
...props
|
|
35
|
-
} = _ref2;
|
|
36
|
-
return /*#__PURE__*/React.createElement(_Text.ButtonTextSmall, _extends({}, props, {
|
|
37
|
-
className: (0, _classify.default)(_SubMenuModule.default.subMenuItemText, className),
|
|
38
|
-
color: _Text.TEXT_COLORS.inversePrimary
|
|
39
|
-
}), children);
|
|
40
|
-
};
|
|
41
|
-
exports.SubMenuItemText = SubMenuItemText;
|
|
42
|
-
SubMenuItemText.displayName = 'SubMenuItemText';
|
|
43
|
-
const SubMenuItemAction = _ref3 => {
|
|
44
|
-
let {
|
|
45
|
-
children,
|
|
46
|
-
className,
|
|
47
|
-
...props
|
|
48
|
-
} = _ref3;
|
|
49
|
-
return /*#__PURE__*/React.createElement("div", _extends({}, props, {
|
|
50
|
-
className: (0, _classify.default)(_SubMenuModule.default.subMenuItemAction, className)
|
|
51
|
-
}), children);
|
|
52
|
-
};
|
|
53
|
-
exports.SubMenuItemAction = SubMenuItemAction;
|
|
54
|
-
SubMenuItemAction.displayName = 'SubMenuItemAction';
|
|
55
|
-
const SubMenuItem = /*#__PURE__*/React.forwardRef((_ref4, ref) => {
|
|
56
|
-
let {
|
|
57
|
-
children,
|
|
58
|
-
selectedMenuKey,
|
|
59
|
-
disabled,
|
|
60
|
-
classNames,
|
|
61
|
-
onChange,
|
|
62
|
-
menuKey,
|
|
63
|
-
...props
|
|
64
|
-
} = _ref4;
|
|
65
|
-
const onChangeHandler = () => {
|
|
66
|
-
if (!disabled) {
|
|
67
|
-
onChange && onChange(menuKey);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
const onKeyDownHandler = e => {
|
|
71
|
-
if (e.key === 'Enter') {
|
|
72
|
-
onChangeHandler();
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
const selected = selectedMenuKey === menuKey;
|
|
76
|
-
const getNamedComp = comp => {
|
|
77
|
-
const childrenArray = React.Children.toArray(children);
|
|
78
|
-
if (childrenArray.length) {
|
|
79
|
-
const nodes = [];
|
|
80
|
-
for (const child of childrenArray) {
|
|
81
|
-
if (child?.type?.displayName === comp) {
|
|
82
|
-
nodes.push( /*#__PURE__*/React.cloneElement(child, {
|
|
83
|
-
selected,
|
|
84
|
-
disabled
|
|
85
|
-
}));
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return nodes.length > 1 ? nodes : nodes[0];
|
|
89
|
-
}
|
|
90
|
-
return null;
|
|
91
|
-
};
|
|
92
|
-
return /*#__PURE__*/React.createElement("div", _extends({}, props, {
|
|
93
|
-
className: (0, _classify.default)(_SubMenuModule.default.menuItem, {
|
|
94
|
-
[_SubMenuModule.default.selected]: selected,
|
|
95
|
-
[_SubMenuModule.default.disabled]: disabled
|
|
96
|
-
}, classNames?.wrapper),
|
|
97
|
-
onKeyDown: onKeyDownHandler,
|
|
98
|
-
onClick: onChangeHandler,
|
|
99
|
-
ref: ref,
|
|
100
|
-
tabIndex: disabled ? '-1' : 0
|
|
101
|
-
}), /*#__PURE__*/React.createElement("div", {
|
|
102
|
-
className: _SubMenuModule.default.menuIconName
|
|
103
|
-
}, getNamedComp('SubMenuItemIcon'), getNamedComp('SubMenuItemText')), getNamedComp('SubMenuItemAction'));
|
|
104
|
-
});
|
|
105
|
-
exports.SubMenuItem = SubMenuItem;
|
|
106
|
-
const SubMenuGroup = _ref5 => {
|
|
107
|
-
let {
|
|
108
|
-
children,
|
|
109
|
-
groupTitle,
|
|
110
|
-
collapsible = false,
|
|
111
|
-
disabled = false,
|
|
112
|
-
onChange,
|
|
113
|
-
selectedMenuKey,
|
|
114
|
-
classNames
|
|
115
|
-
} = _ref5;
|
|
116
|
-
const [collapsed, setCollapsed] = React.useState(false);
|
|
117
|
-
const collapseHandler = () => {
|
|
118
|
-
collapsible && setCollapsed(!collapsed);
|
|
119
|
-
};
|
|
120
|
-
const onChangeHandler = value => {
|
|
121
|
-
if (onChange) {
|
|
122
|
-
onChange(value);
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
const onKeyDownHandlerHeader = e => {
|
|
126
|
-
if (e.key === 'Enter') {
|
|
127
|
-
collapseHandler();
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
const childrenWithProps = React.Children.map(children, child => {
|
|
131
|
-
if ( /*#__PURE__*/React.isValidElement(child)) {
|
|
132
|
-
const {
|
|
133
|
-
disabled: disabledChild
|
|
134
|
-
} = child.props;
|
|
135
|
-
return /*#__PURE__*/React.cloneElement(child, {
|
|
136
|
-
selectedMenuKey,
|
|
137
|
-
onChange: onChangeHandler,
|
|
138
|
-
disabled: disabledChild || disabled
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
return child;
|
|
142
|
-
});
|
|
143
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
144
|
-
className: (0, _classify.default)(_SubMenuModule.default.subMenuGroupWrapper, classNames?.wrapper)
|
|
145
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
146
|
-
className: (0, _classify.default)(_SubMenuModule.default.subMenuGroupHeader, {
|
|
147
|
-
[_SubMenuModule.default.collapsible]: collapsible
|
|
148
|
-
}, classNames?.groupHeader),
|
|
149
|
-
onClick: collapseHandler,
|
|
150
|
-
onKeyDown: onKeyDownHandlerHeader,
|
|
151
|
-
tabIndex: collapsible ? 0 : -1
|
|
152
|
-
}, /*#__PURE__*/React.createElement(_Text.SubTitleExtraSmall, {
|
|
153
|
-
color: _Text.TEXT_COLORS.inverseSecondary,
|
|
154
|
-
className: _SubMenuModule.default.groupTitle
|
|
155
|
-
}, groupTitle), collapsible && /*#__PURE__*/React.createElement(_Icon.Icon, {
|
|
156
|
-
color: _Text.TEXT_COLORS.inverseSecondary,
|
|
157
|
-
name: collapsed ? 'chevron-down' : 'chevron-up',
|
|
158
|
-
size: "small"
|
|
159
|
-
})), /*#__PURE__*/React.createElement("div", {
|
|
160
|
-
className: (0, _classify.default)(_SubMenuModule.default.subMenuGroup, {
|
|
161
|
-
[_SubMenuModule.default.collapsed]: collapsible && collapsed
|
|
162
|
-
}, classNames?.menuGroup)
|
|
163
|
-
}, childrenWithProps));
|
|
164
|
-
};
|
|
165
|
-
exports.SubMenuGroup = SubMenuGroup;
|
|
166
|
-
const SubMenu = /*#__PURE__*/React.forwardRef((_ref6, ref) => {
|
|
16
|
+
|
|
17
|
+
const SubMenu = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
167
18
|
let {
|
|
168
19
|
classNames,
|
|
169
20
|
children,
|
|
170
21
|
title,
|
|
22
|
+
titleIcon,
|
|
23
|
+
titleIconSize,
|
|
24
|
+
titleIconType,
|
|
171
25
|
onClose,
|
|
172
26
|
showClose = false
|
|
173
|
-
} =
|
|
27
|
+
} = _ref;
|
|
174
28
|
const childrenWithProps = React.Children.map(children, child => {
|
|
175
29
|
if ( /*#__PURE__*/React.isValidElement(child)) {
|
|
176
30
|
return /*#__PURE__*/React.createElement("div", {
|
|
177
31
|
className: _SubMenuModule.default.menuChildWrap
|
|
178
|
-
}, child);
|
|
32
|
+
}, /*#__PURE__*/React.cloneElement(child, {}));
|
|
179
33
|
}
|
|
180
34
|
});
|
|
181
35
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -183,10 +37,18 @@ const SubMenu = /*#__PURE__*/React.forwardRef((_ref6, ref) => {
|
|
|
183
37
|
ref: ref
|
|
184
38
|
}, /*#__PURE__*/React.createElement("div", {
|
|
185
39
|
className: _SubMenuModule.default.subMenuTitleAndButton
|
|
186
|
-
}, /*#__PURE__*/React.createElement(
|
|
40
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
41
|
+
className: _SubMenuModule.default.subMenuTitleWrapper
|
|
42
|
+
}, !!titleIcon && /*#__PURE__*/React.createElement(_Icon.Icon, {
|
|
43
|
+
color: _Text.TEXT_COLORS.inverseSecondary,
|
|
44
|
+
name: titleIcon,
|
|
45
|
+
type: titleIconType,
|
|
46
|
+
size: titleIconSize,
|
|
47
|
+
className: _SubMenuModule.default.titleIcon
|
|
48
|
+
}), /*#__PURE__*/React.createElement(_Text.SubTitleMedium, {
|
|
187
49
|
className: _SubMenuModule.default.subMenuHeader,
|
|
188
50
|
color: _Text.TEXT_COLORS.inversePrimary
|
|
189
|
-
}, title), showClose && /*#__PURE__*/React.createElement(_Button.Button, {
|
|
51
|
+
}, title)), showClose && /*#__PURE__*/React.createElement(_Button.Button, {
|
|
190
52
|
ariaLabel: "Icon Button",
|
|
191
53
|
iconRightName: "close",
|
|
192
54
|
onClick: onClose,
|
|
@@ -2,249 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
|
|
5
|
-
import type {ColorTypes} from '../../types/typography';
|
|
6
5
|
import classify from '../../utils/classify';
|
|
7
6
|
import {Button} from '../Button';
|
|
8
|
-
import type {
|
|
7
|
+
import type {IconSize, IconType} from '../Icon';
|
|
9
8
|
import {Icon} from '../Icon';
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
ButtonTextSmall,
|
|
13
|
-
SubTitleExtraSmall,
|
|
14
|
-
SubTitleMedium,
|
|
15
|
-
TEXT_COLORS,
|
|
16
|
-
} from '../Text';
|
|
9
|
+
import {SubTitleMedium, TEXT_COLORS} from '../Text';
|
|
17
10
|
|
|
18
11
|
import css from './SubMenu.module.css';
|
|
19
12
|
|
|
20
13
|
|
|
21
14
|
type ClassNames = $ReadOnly<{wrapper?: string}>;
|
|
22
15
|
|
|
23
|
-
export const SubMenuItemIcon = ({
|
|
24
|
-
className,
|
|
25
|
-
...props
|
|
26
|
-
}: IconProps): React.Node => (
|
|
27
|
-
<Icon
|
|
28
|
-
{...props}
|
|
29
|
-
size="small"
|
|
30
|
-
color={TEXT_COLORS.inverseSecondary}
|
|
31
|
-
className={classify(css.menuIcon, className)}
|
|
32
|
-
/>
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
SubMenuItemIcon.displayName = 'SubMenuItemIcon';
|
|
36
|
-
|
|
37
|
-
export const SubMenuItemText = ({
|
|
38
|
-
children,
|
|
39
|
-
className,
|
|
40
|
-
...props
|
|
41
|
-
}: TextProps): React.Node => (
|
|
42
|
-
<ButtonTextSmall
|
|
43
|
-
{...props}
|
|
44
|
-
className={classify(css.subMenuItemText, className)}
|
|
45
|
-
color={TEXT_COLORS.inversePrimary}
|
|
46
|
-
>
|
|
47
|
-
{children}
|
|
48
|
-
</ButtonTextSmall>
|
|
49
|
-
);
|
|
50
|
-
SubMenuItemText.displayName = 'SubMenuItemText';
|
|
51
|
-
|
|
52
|
-
export type SubMenuItemActionProps = {
|
|
53
|
-
children?: React.Node,
|
|
54
|
-
color?: ColorTypes,
|
|
55
|
-
className?: string,
|
|
56
|
-
...
|
|
57
|
-
};
|
|
58
|
-
export const SubMenuItemAction = ({
|
|
59
|
-
children,
|
|
60
|
-
className,
|
|
61
|
-
...props
|
|
62
|
-
}: SubMenuItemActionProps): React.Node => (
|
|
63
|
-
<div {...props} className={classify(css.subMenuItemAction, className)}>
|
|
64
|
-
{children}
|
|
65
|
-
</div>
|
|
66
|
-
);
|
|
67
|
-
SubMenuItemAction.displayName = 'SubMenuItemAction';
|
|
68
|
-
|
|
69
|
-
export type SubMenuItemProps = {
|
|
70
|
-
classNames?: ClassNames,
|
|
71
|
-
children?: React.Node,
|
|
72
|
-
selectedMenuKey?: string,
|
|
73
|
-
disabled?: boolean,
|
|
74
|
-
onChange?: (selectedMenuKey: string) => mixed,
|
|
75
|
-
menuKey: string,
|
|
76
|
-
...
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export const SubMenuItem: React$AbstractComponent<
|
|
80
|
-
SubMenuItemProps,
|
|
81
|
-
HTMLElement,
|
|
82
|
-
> = React.forwardRef(
|
|
83
|
-
(
|
|
84
|
-
{
|
|
85
|
-
children,
|
|
86
|
-
selectedMenuKey,
|
|
87
|
-
disabled,
|
|
88
|
-
classNames,
|
|
89
|
-
onChange,
|
|
90
|
-
menuKey,
|
|
91
|
-
...props
|
|
92
|
-
}: SubMenuItemProps,
|
|
93
|
-
ref,
|
|
94
|
-
): React.Node => {
|
|
95
|
-
const onChangeHandler = () => {
|
|
96
|
-
if (!disabled) {
|
|
97
|
-
onChange && onChange(menuKey);
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
const onKeyDownHandler = (e) => {
|
|
102
|
-
if (e.key === 'Enter') {
|
|
103
|
-
onChangeHandler();
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
const selected = selectedMenuKey === menuKey;
|
|
108
|
-
|
|
109
|
-
const getNamedComp = (comp: string) => {
|
|
110
|
-
const childrenArray = React.Children.toArray(children);
|
|
111
|
-
if (childrenArray.length) {
|
|
112
|
-
const nodes: React.Node[] = [];
|
|
113
|
-
for (const child of childrenArray) {
|
|
114
|
-
if (child?.type?.displayName === comp) {
|
|
115
|
-
nodes.push(
|
|
116
|
-
React.cloneElement(child, {
|
|
117
|
-
selected,
|
|
118
|
-
disabled,
|
|
119
|
-
}),
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
return nodes.length > 1 ? nodes : nodes[0];
|
|
124
|
-
}
|
|
125
|
-
return null;
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
return (
|
|
129
|
-
<div
|
|
130
|
-
{...props}
|
|
131
|
-
className={classify(
|
|
132
|
-
css.menuItem,
|
|
133
|
-
{
|
|
134
|
-
[css.selected]: selected,
|
|
135
|
-
[css.disabled]: disabled,
|
|
136
|
-
},
|
|
137
|
-
classNames?.wrapper,
|
|
138
|
-
)}
|
|
139
|
-
onKeyDown={onKeyDownHandler}
|
|
140
|
-
onClick={onChangeHandler}
|
|
141
|
-
ref={ref}
|
|
142
|
-
tabIndex={disabled ? '-1' : 0}
|
|
143
|
-
>
|
|
144
|
-
<div className={css.menuIconName}>
|
|
145
|
-
{getNamedComp('SubMenuItemIcon')}
|
|
146
|
-
{getNamedComp('SubMenuItemText')}
|
|
147
|
-
</div>
|
|
148
|
-
{getNamedComp('SubMenuItemAction')}
|
|
149
|
-
</div>
|
|
150
|
-
);
|
|
151
|
-
},
|
|
152
|
-
);
|
|
153
|
-
|
|
154
|
-
type SubMenuGroupClassNames = $ReadOnly<{
|
|
155
|
-
wrapper?: string,
|
|
156
|
-
groupHeader?: string,
|
|
157
|
-
menuGroup?: string,
|
|
158
|
-
}>;
|
|
159
|
-
|
|
160
|
-
export type SubMenuGroupProps = {
|
|
161
|
-
children?: React.Node,
|
|
162
|
-
groupTitle?: string,
|
|
163
|
-
collapsible?: boolean,
|
|
164
|
-
disabled?: boolean,
|
|
165
|
-
onChange?: (value: string) => mixed,
|
|
166
|
-
selectedMenuKey?: string,
|
|
167
|
-
classNames?: SubMenuGroupClassNames,
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
export const SubMenuGroup = ({
|
|
171
|
-
children,
|
|
172
|
-
groupTitle,
|
|
173
|
-
collapsible = false,
|
|
174
|
-
disabled = false,
|
|
175
|
-
onChange,
|
|
176
|
-
selectedMenuKey,
|
|
177
|
-
classNames,
|
|
178
|
-
}: SubMenuGroupProps): React.Node => {
|
|
179
|
-
const [collapsed, setCollapsed] = React.useState(false);
|
|
180
|
-
const collapseHandler = () => {
|
|
181
|
-
collapsible && setCollapsed(!collapsed);
|
|
182
|
-
};
|
|
183
|
-
const onChangeHandler = (value) => {
|
|
184
|
-
if (onChange) {
|
|
185
|
-
onChange(value);
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
const onKeyDownHandlerHeader = (e) => {
|
|
189
|
-
if (e.key === 'Enter') {
|
|
190
|
-
collapseHandler();
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
const childrenWithProps = React.Children.map(children, (child) => {
|
|
194
|
-
if (React.isValidElement(child)) {
|
|
195
|
-
const {disabled: disabledChild} = child.props;
|
|
196
|
-
return React.cloneElement(child, {
|
|
197
|
-
selectedMenuKey,
|
|
198
|
-
onChange: onChangeHandler,
|
|
199
|
-
disabled: disabledChild || disabled,
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
return child;
|
|
203
|
-
});
|
|
204
|
-
return (
|
|
205
|
-
<div className={classify(css.subMenuGroupWrapper, classNames?.wrapper)}>
|
|
206
|
-
<div
|
|
207
|
-
className={classify(
|
|
208
|
-
css.subMenuGroupHeader,
|
|
209
|
-
{[css.collapsible]: collapsible},
|
|
210
|
-
classNames?.groupHeader,
|
|
211
|
-
)}
|
|
212
|
-
onClick={collapseHandler}
|
|
213
|
-
onKeyDown={onKeyDownHandlerHeader}
|
|
214
|
-
tabIndex={collapsible ? 0 : -1}
|
|
215
|
-
>
|
|
216
|
-
<SubTitleExtraSmall
|
|
217
|
-
color={TEXT_COLORS.inverseSecondary}
|
|
218
|
-
className={css.groupTitle}
|
|
219
|
-
>
|
|
220
|
-
{groupTitle}
|
|
221
|
-
</SubTitleExtraSmall>
|
|
222
|
-
{collapsible && (
|
|
223
|
-
<Icon
|
|
224
|
-
color={TEXT_COLORS.inverseSecondary}
|
|
225
|
-
name={collapsed ? 'chevron-down' : 'chevron-up'}
|
|
226
|
-
size="small"
|
|
227
|
-
/>
|
|
228
|
-
)}
|
|
229
|
-
</div>
|
|
230
|
-
<div
|
|
231
|
-
className={classify(
|
|
232
|
-
css.subMenuGroup,
|
|
233
|
-
{
|
|
234
|
-
[css.collapsed]: collapsible && collapsed,
|
|
235
|
-
},
|
|
236
|
-
classNames?.menuGroup,
|
|
237
|
-
)}
|
|
238
|
-
>
|
|
239
|
-
{childrenWithProps}
|
|
240
|
-
</div>
|
|
241
|
-
</div>
|
|
242
|
-
);
|
|
243
|
-
};
|
|
244
|
-
|
|
245
16
|
export type SubMenuProps = {
|
|
246
17
|
classNames?: ClassNames,
|
|
247
18
|
title: string,
|
|
19
|
+
titleIcon?: string,
|
|
20
|
+
titleIconSize?: IconSize,
|
|
21
|
+
titleIconType?: IconType,
|
|
248
22
|
children?: React.Node,
|
|
249
23
|
onClose?: () => mixed,
|
|
250
24
|
showClose?: boolean,
|
|
@@ -253,12 +27,25 @@ export type SubMenuProps = {
|
|
|
253
27
|
export const SubMenu: React$AbstractComponent<SubMenuProps, HTMLDivElement> =
|
|
254
28
|
React.forwardRef<SubMenuProps, HTMLDivElement>(
|
|
255
29
|
(
|
|
256
|
-
{
|
|
30
|
+
{
|
|
31
|
+
classNames,
|
|
32
|
+
children,
|
|
33
|
+
title,
|
|
34
|
+
titleIcon,
|
|
35
|
+
titleIconSize,
|
|
36
|
+
titleIconType,
|
|
37
|
+
onClose,
|
|
38
|
+
showClose = false,
|
|
39
|
+
}: SubMenuProps,
|
|
257
40
|
ref,
|
|
258
41
|
): React.Node => {
|
|
259
42
|
const childrenWithProps = React.Children.map(children, (child) => {
|
|
260
43
|
if (React.isValidElement(child)) {
|
|
261
|
-
return
|
|
44
|
+
return (
|
|
45
|
+
<div className={css.menuChildWrap}>
|
|
46
|
+
{React.cloneElement(child, {})}
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
262
49
|
}
|
|
263
50
|
});
|
|
264
51
|
|
|
@@ -268,12 +55,23 @@ export const SubMenu: React$AbstractComponent<SubMenuProps, HTMLDivElement> =
|
|
|
268
55
|
ref={ref}
|
|
269
56
|
>
|
|
270
57
|
<div className={css.subMenuTitleAndButton}>
|
|
271
|
-
<
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
58
|
+
<div className={css.subMenuTitleWrapper}>
|
|
59
|
+
{!!titleIcon && (
|
|
60
|
+
<Icon
|
|
61
|
+
color={TEXT_COLORS.inverseSecondary}
|
|
62
|
+
name={titleIcon}
|
|
63
|
+
type={titleIconType}
|
|
64
|
+
size={titleIconSize}
|
|
65
|
+
className={css.titleIcon}
|
|
66
|
+
/>
|
|
67
|
+
)}
|
|
68
|
+
<SubTitleMedium
|
|
69
|
+
className={css.subMenuHeader}
|
|
70
|
+
color={TEXT_COLORS.inversePrimary}
|
|
71
|
+
>
|
|
72
|
+
{title}
|
|
73
|
+
</SubTitleMedium>
|
|
74
|
+
</div>
|
|
277
75
|
{showClose && (
|
|
278
76
|
<Button
|
|
279
77
|
ariaLabel="Icon Button"
|