@spaced-out/ui-design-system 0.2.5 → 0.2.6
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 +14 -0
- package/lib/components/ButtonTabs/ButtonTab/ButtonTab.js +1 -2
- package/lib/components/ButtonTabs/ButtonTab/ButtonTab.js.flow +1 -2
- package/lib/components/ButtonTabs/ButtonTab/ButtonTab.module.css +46 -57
- package/lib/components/ButtonTabs/ButtonTabs.js +3 -9
- package/lib/components/ButtonTabs/ButtonTabs.js.flow +3 -13
- package/lib/components/ButtonTabs/ButtonTabs.module.css +2 -24
- package/lib/components/Menu/Menu.js +15 -8
- package/lib/components/Menu/Menu.js.flow +21 -9
- package/lib/utils/menu/menu.js +12 -10
- package/lib/utils/menu/menu.js.flow +21 -16
- package/package.json +1 -1
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.2.6](https://github.com/spaced-out/ui-design-system/compare/v0.2.6-beta.0...v0.2.6) (2024-10-22)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* disabled button tab styling ([#281](https://github.com/spaced-out/ui-design-system/issues/281)) ([f99fdf9](https://github.com/spaced-out/ui-design-system/commit/f99fdf9115836ed99df6d72c2ed6068af16ec720))
|
|
11
|
+
|
|
12
|
+
### [0.2.6-beta.0](https://github.com/spaced-out/ui-design-system/compare/v0.2.5...v0.2.6-beta.0) (2024-10-21)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* adding custom staticLabels prop in menu ([#282](https://github.com/spaced-out/ui-design-system/issues/282)) ([696a433](https://github.com/spaced-out/ui-design-system/commit/696a433a6d2b2c15ac1f4946c7018e17116dc612))
|
|
18
|
+
|
|
5
19
|
### [0.2.5](https://github.com/spaced-out/ui-design-system/compare/v0.2.4...v0.2.5) (2024-10-18)
|
|
6
20
|
|
|
7
21
|
|
|
@@ -30,7 +30,7 @@ const ButtonTab = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
30
30
|
return /*#__PURE__*/React.createElement(_Button.Button, _extends({}, props, {
|
|
31
31
|
disabled: disabled,
|
|
32
32
|
size: size,
|
|
33
|
-
type:
|
|
33
|
+
type: "tertiary",
|
|
34
34
|
ref: ref,
|
|
35
35
|
classNames: {
|
|
36
36
|
wrapper: (0, _classify.default)(_ButtonTabModule.default.buttonTabWrapper, {
|
|
@@ -38,7 +38,6 @@ const ButtonTab = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
38
38
|
[_ButtonTabModule.default.smallButtonTab]: size === 'small',
|
|
39
39
|
[_ButtonTabModule.default.onlyIcon]: iconName && !children,
|
|
40
40
|
[_ButtonTabModule.default.isSelected]: id === selectedButtonTabId,
|
|
41
|
-
[_ButtonTabModule.default.isUnSelected]: id !== selectedButtonTabId,
|
|
42
41
|
[_ButtonTabModule.default.disabled]: disabled,
|
|
43
42
|
[_ButtonTabModule.default.leftCurved]: isLeftCurved,
|
|
44
43
|
[_ButtonTabModule.default.rightCurved]: isRightCurved
|
|
@@ -54,7 +54,7 @@ export const ButtonTab: React$AbstractComponent<
|
|
|
54
54
|
{...props}
|
|
55
55
|
disabled={disabled}
|
|
56
56
|
size={size}
|
|
57
|
-
type=
|
|
57
|
+
type="tertiary"
|
|
58
58
|
ref={ref}
|
|
59
59
|
classNames={{
|
|
60
60
|
wrapper: classify(
|
|
@@ -64,7 +64,6 @@ export const ButtonTab: React$AbstractComponent<
|
|
|
64
64
|
[css.smallButtonTab]: size === 'small',
|
|
65
65
|
[css.onlyIcon]: iconName && !children,
|
|
66
66
|
[css.isSelected]: id === selectedButtonTabId,
|
|
67
|
-
[css.isUnSelected]: id !== selectedButtonTabId,
|
|
68
67
|
[css.disabled]: disabled,
|
|
69
68
|
[css.leftCurved]: isLeftCurved,
|
|
70
69
|
[css.rightCurved]: isRightCurved,
|
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
size34
|
|
11
11
|
) from '../../../styles/variables/_size.css';
|
|
12
12
|
@value (
|
|
13
|
-
|
|
13
|
+
spaceNone,
|
|
14
|
+
spaceSmall,
|
|
15
|
+
spaceMedium
|
|
14
16
|
) from '../../../styles/variables/_space.css';
|
|
15
17
|
@value (
|
|
16
18
|
borderWidthPrimary,
|
|
@@ -18,72 +20,68 @@
|
|
|
18
20
|
borderRadiusNone,
|
|
19
21
|
borderRadiusMedium
|
|
20
22
|
) from '../../../styles/variables/_border.css';
|
|
23
|
+
@value (elevationCard) from '../../../styles/variables/_elevation.css';
|
|
21
24
|
|
|
22
25
|
.buttonTabWrapper {
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
border: borderWidthPrimary solid colorBorderPrimary;
|
|
27
|
+
border-radius: borderRadiusNone;
|
|
28
|
+
border-right-width: borderWidthNone;
|
|
29
|
+
text-align: left;
|
|
30
|
+
min-width: initial;
|
|
31
|
+
padding: spaceNone spaceMedium;
|
|
25
32
|
height: size42;
|
|
26
33
|
color: colorTextSecondary;
|
|
27
|
-
min-width: initial;
|
|
28
|
-
text-align: left;
|
|
29
|
-
}
|
|
30
34
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
35
|
+
&.mediumButtonTab {
|
|
36
|
+
height: size42;
|
|
37
|
+
}
|
|
34
38
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
+
&.smallButtonTab {
|
|
40
|
+
height: size34;
|
|
41
|
+
}
|
|
39
42
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
&.rightCurved {
|
|
44
|
+
border-right-width: borderWidthPrimary;
|
|
45
|
+
border-top-right-radius: borderRadiusMedium;
|
|
46
|
+
border-bottom-right-radius: borderRadiusMedium;
|
|
47
|
+
}
|
|
43
48
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
&.leftCurved {
|
|
50
|
+
border-top-left-radius: borderRadiusMedium;
|
|
51
|
+
border-bottom-left-radius: borderRadiusMedium;
|
|
52
|
+
}
|
|
47
53
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
54
|
+
&.disabled {
|
|
55
|
+
color: colorTextDisabled;
|
|
56
|
+
border: borderWidthPrimary solid colorBorderPrimary;
|
|
57
|
+
border-right-width: borderWidthNone;
|
|
58
|
+
}
|
|
51
59
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
60
|
+
&:hover {
|
|
61
|
+
color: colorTextPrimary;
|
|
62
|
+
background-color: initial;
|
|
63
|
+
}
|
|
57
64
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
65
|
+
&:focus {
|
|
66
|
+
z-index: elevationCard;
|
|
67
|
+
}
|
|
61
68
|
|
|
62
|
-
|
|
63
|
-
|
|
69
|
+
&.icon {
|
|
70
|
+
color: colorTextSecondary;
|
|
71
|
+
}
|
|
64
72
|
}
|
|
65
73
|
|
|
66
|
-
.buttonTabWrapper.
|
|
67
|
-
background-color: colorFillSecondary;
|
|
74
|
+
.buttonTabWrapper:hover .icon {
|
|
68
75
|
color: colorTextPrimary;
|
|
69
|
-
border-top-width: borderWidthPrimary;
|
|
70
|
-
border-right-width: borderWidthPrimary;
|
|
71
|
-
border-bottom-width: borderWidthPrimary;
|
|
72
|
-
border-style: solid;
|
|
73
|
-
border-color: colorBorderPrimary;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
.buttonTabWrapper.leftCurved {
|
|
77
|
-
border-radius: borderRadiusMedium borderRadiusNone borderRadiusNone
|
|
78
|
-
borderRadiusMedium;
|
|
79
76
|
}
|
|
80
77
|
|
|
81
|
-
.
|
|
82
|
-
|
|
83
|
-
|
|
78
|
+
.onlyIcon {
|
|
79
|
+
color: colorTextSecondary;
|
|
80
|
+
padding: spaceNone spaceSmall;
|
|
84
81
|
}
|
|
85
82
|
|
|
86
|
-
.buttonTabWrapper.isSelected
|
|
83
|
+
.buttonTabWrapper.isSelected {
|
|
84
|
+
color: colorTextPrimary;
|
|
87
85
|
background-color: colorFillSecondary;
|
|
88
86
|
}
|
|
89
87
|
|
|
@@ -91,15 +89,6 @@
|
|
|
91
89
|
color: colorTextPrimary;
|
|
92
90
|
}
|
|
93
91
|
|
|
94
|
-
.buttonTabWrapper.disabled {
|
|
95
|
-
color: colorTextDisabled;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
92
|
.buttonTabWrapper.disabled .icon {
|
|
99
93
|
color: colorTextDisabled;
|
|
100
94
|
}
|
|
101
|
-
|
|
102
|
-
.buttonTabWrapper.isUnSelected {
|
|
103
|
-
padding-left: spaceSmall;
|
|
104
|
-
padding-right: spaceSmall;
|
|
105
|
-
}
|
|
@@ -49,23 +49,17 @@ const ButtonTabs = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
49
49
|
} = child.props;
|
|
50
50
|
const isFirst = index === 0;
|
|
51
51
|
const isLast = index === unwrappedNodes.length - 1;
|
|
52
|
-
const isSingleChild = unwrappedNodes.length === 1;
|
|
53
52
|
return /*#__PURE__*/React.cloneElement(child, {
|
|
54
53
|
...child.props,
|
|
55
54
|
isFluid,
|
|
56
55
|
size,
|
|
57
|
-
isLeftCurved: isFirst
|
|
58
|
-
isRightCurved: isLast
|
|
56
|
+
isLeftCurved: isFirst,
|
|
57
|
+
isRightCurved: isLast,
|
|
59
58
|
disabled: disabledChild || disabled,
|
|
60
59
|
selectedButtonTabId,
|
|
61
60
|
onButtonTabSelect,
|
|
62
61
|
classNames: {
|
|
63
|
-
wrapper:
|
|
64
|
-
[_ButtonTabsModule.default.firstChild]: isFirst && !isSingleChild,
|
|
65
|
-
[_ButtonTabsModule.default.lastChild]: isLast && !isSingleChild,
|
|
66
|
-
[_ButtonTabsModule.default.children]: !isFirst && !isLast,
|
|
67
|
-
[_ButtonTabsModule.default.singleChild]: isSingleChild
|
|
68
|
-
}, classNamesChild?.wrapper)
|
|
62
|
+
wrapper: classNamesChild?.wrapper
|
|
69
63
|
}
|
|
70
64
|
});
|
|
71
65
|
}
|
|
@@ -77,28 +77,18 @@ export const ButtonTabs: React$AbstractComponent<
|
|
|
77
77
|
child.props;
|
|
78
78
|
const isFirst = index === 0;
|
|
79
79
|
const isLast = index === unwrappedNodes.length - 1;
|
|
80
|
-
const isSingleChild = unwrappedNodes.length === 1;
|
|
81
80
|
|
|
82
81
|
return React.cloneElement(child, {
|
|
83
82
|
...child.props,
|
|
84
83
|
isFluid,
|
|
85
84
|
size,
|
|
86
|
-
isLeftCurved: isFirst
|
|
87
|
-
isRightCurved: isLast
|
|
85
|
+
isLeftCurved: isFirst,
|
|
86
|
+
isRightCurved: isLast,
|
|
88
87
|
disabled: disabledChild || disabled,
|
|
89
88
|
selectedButtonTabId,
|
|
90
89
|
onButtonTabSelect,
|
|
91
90
|
classNames: {
|
|
92
|
-
wrapper:
|
|
93
|
-
css.buttonTab,
|
|
94
|
-
{
|
|
95
|
-
[css.firstChild]: isFirst && !isSingleChild,
|
|
96
|
-
[css.lastChild]: isLast && !isSingleChild,
|
|
97
|
-
[css.children]: !isFirst && !isLast,
|
|
98
|
-
[css.singleChild]: isSingleChild,
|
|
99
|
-
},
|
|
100
|
-
classNamesChild?.wrapper,
|
|
101
|
-
),
|
|
91
|
+
wrapper: classNamesChild?.wrapper,
|
|
102
92
|
},
|
|
103
93
|
});
|
|
104
94
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
@value (
|
|
2
|
-
colorBackgroundTertiary
|
|
3
|
-
colorBorderPrimary
|
|
2
|
+
colorBackgroundTertiary
|
|
4
3
|
) from '../../styles/variables/_color.css';
|
|
5
4
|
@value (
|
|
6
5
|
size42,
|
|
@@ -8,10 +7,7 @@
|
|
|
8
7
|
sizeFluid
|
|
9
8
|
) from '../../styles/variables/_size.css';
|
|
10
9
|
@value (
|
|
11
|
-
|
|
12
|
-
borderWidthPrimary,
|
|
13
|
-
borderRadiusMedium,
|
|
14
|
-
borderRadiusNone
|
|
10
|
+
borderRadiusMedium
|
|
15
11
|
) from '../../styles/variables/_border.css';
|
|
16
12
|
|
|
17
13
|
.buttonTabsWrapper {
|
|
@@ -19,8 +15,6 @@
|
|
|
19
15
|
background-color: colorBackgroundTertiary;
|
|
20
16
|
align-items: center;
|
|
21
17
|
width: fit-content;
|
|
22
|
-
composes: borderTopPrimary from '../../styles/border.module.css';
|
|
23
|
-
composes: borderBottomPrimary from '../../styles/border.module.css';
|
|
24
18
|
border-radius: borderRadiusMedium;
|
|
25
19
|
}
|
|
26
20
|
|
|
@@ -35,19 +29,3 @@
|
|
|
35
29
|
.buttonTabsWrapper.isFluid {
|
|
36
30
|
width: sizeFluid;
|
|
37
31
|
}
|
|
38
|
-
|
|
39
|
-
.buttonTab {
|
|
40
|
-
border-color: colorBorderPrimary;
|
|
41
|
-
border-width: borderWidthNone borderWidthPrimary;
|
|
42
|
-
border-style: none solid;
|
|
43
|
-
border-radius: borderRadiusNone;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.children,
|
|
47
|
-
.lastChild {
|
|
48
|
-
border-left-width: borderWidthNone;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.singleChild {
|
|
52
|
-
border-radius: borderRadiusMedium;
|
|
53
|
-
}
|
|
@@ -28,6 +28,11 @@ const RenderOption = _ref => {
|
|
|
28
28
|
classNames,
|
|
29
29
|
searchText = '',
|
|
30
30
|
showResultText = true,
|
|
31
|
+
staticLabels = {
|
|
32
|
+
RESULT: 'result',
|
|
33
|
+
RESULTS: 'results',
|
|
34
|
+
SEARCH_PLACEHOLDER: 'Search...'
|
|
35
|
+
},
|
|
31
36
|
...restProps
|
|
32
37
|
} = _ref;
|
|
33
38
|
const {
|
|
@@ -41,7 +46,7 @@ const RenderOption = _ref => {
|
|
|
41
46
|
} = restProps;
|
|
42
47
|
if (options && Array.isArray(options) && options.length) {
|
|
43
48
|
const optionsFiltered = !allowSearch ? options : (0, _menu.getFilteredOptionsFromSearchText)(options, searchText);
|
|
44
|
-
const
|
|
49
|
+
const finalResultText = !allowSearch ? '' : (0, _menu.getFilteredOptionsResultText)(optionsFiltered, staticLabels);
|
|
45
50
|
const {
|
|
46
51
|
enable: isVirtualizationEnabled,
|
|
47
52
|
menuHeight,
|
|
@@ -50,7 +55,7 @@ const RenderOption = _ref => {
|
|
|
50
55
|
return /*#__PURE__*/React.createElement(React.Fragment, null, allowSearch && showResultText && /*#__PURE__*/React.createElement(_Text.FormLabelSmall, {
|
|
51
56
|
className: _MenuModule.default.filterOptionsResultText,
|
|
52
57
|
color: "tertiary"
|
|
53
|
-
},
|
|
58
|
+
}, finalResultText), virtualization && isVirtualizationEnabled ? /*#__PURE__*/React.createElement(_reactWindow.FixedSizeList, {
|
|
54
59
|
height: menuHeight || (size === 'medium' ? menuSizeMedium : menuSizeSmall),
|
|
55
60
|
itemSize: itemHeight || (size === 'medium' ? buttonSizeMedium : buttonSizeSmall),
|
|
56
61
|
itemCount: optionsFiltered.length
|
|
@@ -80,11 +85,11 @@ const RenderOption = _ref => {
|
|
|
80
85
|
}
|
|
81
86
|
if (composeOptions && Array.isArray(composeOptions) && composeOptions.length) {
|
|
82
87
|
const optionsFiltered = !allowSearch ? composeOptions : (0, _menu.getFilteredComposeOptionsFromSearchText)(composeOptions, searchText);
|
|
83
|
-
const
|
|
88
|
+
const finalResultText = !allowSearch ? '' : (0, _menu.getFilteredComposeOptionsResultText)(optionsFiltered, staticLabels);
|
|
84
89
|
return /*#__PURE__*/React.createElement(React.Fragment, null, allowSearch && showResultText && /*#__PURE__*/React.createElement(_Text.FormLabelSmall, {
|
|
85
90
|
className: _MenuModule.default.filterOptionsResultText,
|
|
86
91
|
color: "tertiary"
|
|
87
|
-
},
|
|
92
|
+
}, finalResultText), optionsFiltered.map((composeMenuOptions, index) =>
|
|
88
93
|
/*#__PURE__*/
|
|
89
94
|
// eslint-disable-next-line react/no-array-index-key
|
|
90
95
|
React.createElement("span", {
|
|
@@ -101,11 +106,11 @@ const RenderOption = _ref => {
|
|
|
101
106
|
}
|
|
102
107
|
if (groupTitleOptions && Array.isArray(groupTitleOptions) && groupTitleOptions.length) {
|
|
103
108
|
const optionsFiltered = !allowSearch ? groupTitleOptions : (0, _menu.getFilteredGroupTitleOptionsFromSearchText)(groupTitleOptions, searchText);
|
|
104
|
-
const
|
|
109
|
+
const finalResultText = !allowSearch ? '' : (0, _menu.getFilteredGroupTitleOptionsResultText)(optionsFiltered, staticLabels);
|
|
105
110
|
return /*#__PURE__*/React.createElement(React.Fragment, null, allowSearch && showResultText && /*#__PURE__*/React.createElement(_Text.FormLabelSmall, {
|
|
106
111
|
className: _MenuModule.default.filterOptionsResultText,
|
|
107
112
|
color: "tertiary"
|
|
108
|
-
},
|
|
113
|
+
}, finalResultText), optionsFiltered.map((optionsGroup, index) =>
|
|
109
114
|
/*#__PURE__*/
|
|
110
115
|
// eslint-disable-next-line react/no-array-index-key
|
|
111
116
|
React.createElement(React.Fragment, {
|
|
@@ -136,7 +141,8 @@ const Menu = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
136
141
|
itemHeight: null
|
|
137
142
|
},
|
|
138
143
|
header,
|
|
139
|
-
footer
|
|
144
|
+
footer,
|
|
145
|
+
staticLabels
|
|
140
146
|
} = props;
|
|
141
147
|
const [searchText, setSearchText] = React.useState('');
|
|
142
148
|
const {
|
|
@@ -169,7 +175,8 @@ const Menu = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
169
175
|
value: searchText,
|
|
170
176
|
onChange: e => setSearchText(e.target.value),
|
|
171
177
|
onClear: () => setSearchText(''),
|
|
172
|
-
size: size
|
|
178
|
+
size: size,
|
|
179
|
+
placeholder: staticLabels?.SEARCH_PLACEHOLDER ?? 'Search...'
|
|
173
180
|
}), /*#__PURE__*/React.createElement(RenderOption, _extends({}, props, {
|
|
174
181
|
searchText: searchText
|
|
175
182
|
})), hasFooter && /*#__PURE__*/React.createElement("div", {
|
|
@@ -76,6 +76,11 @@ export type BaseMenuProps = {
|
|
|
76
76
|
header?: React.Node,
|
|
77
77
|
footer?: React.Node,
|
|
78
78
|
showResultText?: boolean,
|
|
79
|
+
staticLabels?: {
|
|
80
|
+
RESULT?: string,
|
|
81
|
+
RESULTS?: string,
|
|
82
|
+
SEARCH_PLACEHOLDER?: string,
|
|
83
|
+
},
|
|
79
84
|
};
|
|
80
85
|
|
|
81
86
|
export type MenuOptionTypes = {
|
|
@@ -116,6 +121,11 @@ const RenderOption = ({
|
|
|
116
121
|
classNames,
|
|
117
122
|
searchText = '',
|
|
118
123
|
showResultText = true,
|
|
124
|
+
staticLabels = {
|
|
125
|
+
RESULT: 'result',
|
|
126
|
+
RESULTS: 'results',
|
|
127
|
+
SEARCH_PLACEHOLDER: 'Search...',
|
|
128
|
+
},
|
|
119
129
|
...restProps
|
|
120
130
|
}: RenderOptionProps): React.Node => {
|
|
121
131
|
const {
|
|
@@ -131,9 +141,9 @@ const RenderOption = ({
|
|
|
131
141
|
const optionsFiltered = !allowSearch
|
|
132
142
|
? options
|
|
133
143
|
: getFilteredOptionsFromSearchText(options, searchText);
|
|
134
|
-
const
|
|
144
|
+
const finalResultText = !allowSearch
|
|
135
145
|
? ''
|
|
136
|
-
: getFilteredOptionsResultText(optionsFiltered);
|
|
146
|
+
: getFilteredOptionsResultText(optionsFiltered, staticLabels);
|
|
137
147
|
|
|
138
148
|
const {
|
|
139
149
|
enable: isVirtualizationEnabled,
|
|
@@ -148,7 +158,7 @@ const RenderOption = ({
|
|
|
148
158
|
className={css.filterOptionsResultText}
|
|
149
159
|
color="tertiary"
|
|
150
160
|
>
|
|
151
|
-
{
|
|
161
|
+
{finalResultText}
|
|
152
162
|
</FormLabelSmall>
|
|
153
163
|
)}
|
|
154
164
|
{virtualization && isVirtualizationEnabled ? (
|
|
@@ -200,9 +210,9 @@ const RenderOption = ({
|
|
|
200
210
|
const optionsFiltered = !allowSearch
|
|
201
211
|
? composeOptions
|
|
202
212
|
: getFilteredComposeOptionsFromSearchText(composeOptions, searchText);
|
|
203
|
-
const
|
|
213
|
+
const finalResultText = !allowSearch
|
|
204
214
|
? ''
|
|
205
|
-
: getFilteredComposeOptionsResultText(optionsFiltered);
|
|
215
|
+
: getFilteredComposeOptionsResultText(optionsFiltered, staticLabels);
|
|
206
216
|
|
|
207
217
|
return (
|
|
208
218
|
<>
|
|
@@ -211,7 +221,7 @@ const RenderOption = ({
|
|
|
211
221
|
className={css.filterOptionsResultText}
|
|
212
222
|
color="tertiary"
|
|
213
223
|
>
|
|
214
|
-
{
|
|
224
|
+
{finalResultText}
|
|
215
225
|
</FormLabelSmall>
|
|
216
226
|
)}
|
|
217
227
|
{optionsFiltered.map((composeMenuOptions, index) => (
|
|
@@ -246,9 +256,9 @@ const RenderOption = ({
|
|
|
246
256
|
groupTitleOptions,
|
|
247
257
|
searchText,
|
|
248
258
|
);
|
|
249
|
-
const
|
|
259
|
+
const finalResultText = !allowSearch
|
|
250
260
|
? ''
|
|
251
|
-
: getFilteredGroupTitleOptionsResultText(optionsFiltered);
|
|
261
|
+
: getFilteredGroupTitleOptionsResultText(optionsFiltered, staticLabels);
|
|
252
262
|
|
|
253
263
|
return (
|
|
254
264
|
<>
|
|
@@ -257,7 +267,7 @@ const RenderOption = ({
|
|
|
257
267
|
className={css.filterOptionsResultText}
|
|
258
268
|
color="tertiary"
|
|
259
269
|
>
|
|
260
|
-
{
|
|
270
|
+
{finalResultText}
|
|
261
271
|
</FormLabelSmall>
|
|
262
272
|
)}
|
|
263
273
|
{optionsFiltered.map((optionsGroup, index) => (
|
|
@@ -312,6 +322,7 @@ export const Menu: React$AbstractComponent<MenuProps, HTMLDivElement> =
|
|
|
312
322
|
},
|
|
313
323
|
header,
|
|
314
324
|
footer,
|
|
325
|
+
staticLabels,
|
|
315
326
|
} = props;
|
|
316
327
|
const [searchText, setSearchText] = React.useState('');
|
|
317
328
|
const {menuHeight} = virtualization;
|
|
@@ -361,6 +372,7 @@ export const Menu: React$AbstractComponent<MenuProps, HTMLDivElement> =
|
|
|
361
372
|
onChange={(e) => setSearchText(e.target.value)}
|
|
362
373
|
onClear={() => setSearchText('')}
|
|
363
374
|
size={size}
|
|
375
|
+
placeholder={staticLabels?.SEARCH_PLACEHOLDER ?? 'Search...'}
|
|
364
376
|
/>
|
|
365
377
|
)}
|
|
366
378
|
<RenderOption {...props} searchText={searchText} />
|
package/lib/utils/menu/menu.js
CHANGED
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getTextLabelFromSelectedKeys = exports.getSelectedKeysFromSelectedOption = exports.getOptionsFromKeys = exports.getOptionFromKey = exports.getFilteredOptionsResultText = exports.getFilteredOptionsFromSearchText = exports.getFilteredGroupTitleOptionsResultText = exports.getFilteredGroupTitleOptionsFromSearchText = exports.getFilteredComposeOptionsResultText = exports.getFilteredComposeOptionsFromSearchText = exports.getButtonLabelFromSelectedKeys = void 0;
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _string = require("../string");
|
|
9
8
|
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); }
|
|
10
9
|
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; }
|
|
11
10
|
|
|
@@ -58,11 +57,12 @@ const getFilteredOptionsFromSearchText = (options, searchText) => {
|
|
|
58
57
|
return options.filter(option => option.label?.toLowerCase().includes(searchText.toLowerCase()));
|
|
59
58
|
};
|
|
60
59
|
exports.getFilteredOptionsFromSearchText = getFilteredOptionsFromSearchText;
|
|
61
|
-
const getFilteredOptionsResultText =
|
|
62
|
-
let resultText = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'result';
|
|
60
|
+
const getFilteredOptionsResultText = (options, staticLabels) => {
|
|
63
61
|
let resultCount = 0;
|
|
64
62
|
resultCount += options.length;
|
|
65
|
-
const
|
|
63
|
+
const singleResultMessage = staticLabels.RESULT ?? 'result';
|
|
64
|
+
const multipleResultsMessage = staticLabels.RESULTS ?? 'results';
|
|
65
|
+
const generatedResultText = `${resultCount} ${resultCount > 1 ? multipleResultsMessage : singleResultMessage}`;
|
|
66
66
|
return generatedResultText;
|
|
67
67
|
};
|
|
68
68
|
exports.getFilteredOptionsResultText = getFilteredOptionsResultText;
|
|
@@ -73,13 +73,14 @@ const getFilteredComposeOptionsFromSearchText = (composeOptions, searchText) =>
|
|
|
73
73
|
return composeOptions.map(optionGroup => optionGroup.filter(option => option.label?.toLowerCase().includes(searchText.toLowerCase()))).filter(group => group.length > 0);
|
|
74
74
|
};
|
|
75
75
|
exports.getFilteredComposeOptionsFromSearchText = getFilteredComposeOptionsFromSearchText;
|
|
76
|
-
const getFilteredComposeOptionsResultText =
|
|
77
|
-
let resultText = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'result';
|
|
76
|
+
const getFilteredComposeOptionsResultText = (composeOptions, staticLabels) => {
|
|
78
77
|
let resultCount = 0;
|
|
79
78
|
composeOptions.forEach(optionGroup => {
|
|
80
79
|
resultCount += optionGroup.length;
|
|
81
80
|
});
|
|
82
|
-
const
|
|
81
|
+
const singleResultMessage = staticLabels.RESULT ?? 'result';
|
|
82
|
+
const multipleResultsMessage = staticLabels.RESULTS ?? 'results';
|
|
83
|
+
const generatedResultText = `${resultCount} ${resultCount > 1 ? multipleResultsMessage : singleResultMessage}`;
|
|
83
84
|
return generatedResultText;
|
|
84
85
|
};
|
|
85
86
|
exports.getFilteredComposeOptionsResultText = getFilteredComposeOptionsResultText;
|
|
@@ -93,15 +94,16 @@ const getFilteredGroupTitleOptionsFromSearchText = (groupTitleOptions, searchTex
|
|
|
93
94
|
})).filter(group => group.options && group.options.length > 0);
|
|
94
95
|
};
|
|
95
96
|
exports.getFilteredGroupTitleOptionsFromSearchText = getFilteredGroupTitleOptionsFromSearchText;
|
|
96
|
-
const getFilteredGroupTitleOptionsResultText =
|
|
97
|
-
let resultText = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'result';
|
|
97
|
+
const getFilteredGroupTitleOptionsResultText = (groupTitleOptions, staticLabels) => {
|
|
98
98
|
let resultCount = 0;
|
|
99
99
|
groupTitleOptions.forEach(group => {
|
|
100
100
|
if (group.options) {
|
|
101
101
|
resultCount += group.options.length;
|
|
102
102
|
}
|
|
103
103
|
});
|
|
104
|
-
const
|
|
104
|
+
const singleResultMessage = staticLabels.RESULT ?? 'result';
|
|
105
|
+
const multipleResultsMessage = staticLabels.RESULTS ?? 'results';
|
|
106
|
+
const generatedResultText = `${resultCount} ${resultCount > 1 ? multipleResultsMessage : singleResultMessage}`;
|
|
105
107
|
return generatedResultText;
|
|
106
108
|
};
|
|
107
109
|
exports.getFilteredGroupTitleOptionsResultText = getFilteredGroupTitleOptionsResultText;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
|
|
4
4
|
import type {MenuGroupTitleOption, MenuOption} from '../../components/Menu';
|
|
5
|
-
import {formatWord} from '../string';
|
|
6
5
|
|
|
7
6
|
|
|
8
7
|
export const getSelectedKeysFromSelectedOption = (
|
|
@@ -96,16 +95,18 @@ export const getFilteredOptionsFromSearchText = (
|
|
|
96
95
|
|
|
97
96
|
export const getFilteredOptionsResultText = (
|
|
98
97
|
options: MenuOption[],
|
|
99
|
-
|
|
98
|
+
staticLabels: {[key: string]: string},
|
|
100
99
|
): string => {
|
|
101
100
|
let resultCount = 0;
|
|
102
101
|
|
|
103
102
|
resultCount += options.length;
|
|
104
103
|
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
104
|
+
const singleResultMessage = staticLabels.RESULT ?? 'result';
|
|
105
|
+
const multipleResultsMessage = staticLabels.RESULTS ?? 'results';
|
|
106
|
+
|
|
107
|
+
const generatedResultText = `${resultCount} ${
|
|
108
|
+
resultCount > 1 ? multipleResultsMessage : singleResultMessage
|
|
109
|
+
}`;
|
|
109
110
|
|
|
110
111
|
return generatedResultText;
|
|
111
112
|
};
|
|
@@ -129,7 +130,7 @@ export const getFilteredComposeOptionsFromSearchText = (
|
|
|
129
130
|
|
|
130
131
|
export const getFilteredComposeOptionsResultText = (
|
|
131
132
|
composeOptions: Array<Array<MenuOption>>,
|
|
132
|
-
|
|
133
|
+
staticLabels: {[key: string]: string},
|
|
133
134
|
): string => {
|
|
134
135
|
let resultCount = 0;
|
|
135
136
|
|
|
@@ -137,10 +138,12 @@ export const getFilteredComposeOptionsResultText = (
|
|
|
137
138
|
resultCount += optionGroup.length;
|
|
138
139
|
});
|
|
139
140
|
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
const singleResultMessage = staticLabels.RESULT ?? 'result';
|
|
142
|
+
const multipleResultsMessage = staticLabels.RESULTS ?? 'results';
|
|
143
|
+
|
|
144
|
+
const generatedResultText = `${resultCount} ${
|
|
145
|
+
resultCount > 1 ? multipleResultsMessage : singleResultMessage
|
|
146
|
+
}`;
|
|
144
147
|
|
|
145
148
|
return generatedResultText;
|
|
146
149
|
};
|
|
@@ -169,7 +172,7 @@ export const getFilteredGroupTitleOptionsFromSearchText = (
|
|
|
169
172
|
|
|
170
173
|
export const getFilteredGroupTitleOptionsResultText = (
|
|
171
174
|
groupTitleOptions: Array<MenuGroupTitleOption>,
|
|
172
|
-
|
|
175
|
+
staticLabels: {[key: string]: string},
|
|
173
176
|
): string => {
|
|
174
177
|
let resultCount = 0;
|
|
175
178
|
|
|
@@ -179,10 +182,12 @@ export const getFilteredGroupTitleOptionsResultText = (
|
|
|
179
182
|
}
|
|
180
183
|
});
|
|
181
184
|
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
185
|
+
const singleResultMessage = staticLabels.RESULT ?? 'result';
|
|
186
|
+
const multipleResultsMessage = staticLabels.RESULTS ?? 'results';
|
|
187
|
+
|
|
188
|
+
const generatedResultText = `${resultCount} ${
|
|
189
|
+
resultCount > 1 ? multipleResultsMessage : singleResultMessage
|
|
190
|
+
}`;
|
|
186
191
|
|
|
187
192
|
return generatedResultText;
|
|
188
193
|
};
|