carbon-react 110.2.4 → 110.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/__internal__/i18n-context/index.d.ts +2 -1
- package/esm/__internal__/popover/popover.component.d.ts +2 -1
- package/esm/__internal__/popover/popover.component.js +15 -4
- package/esm/__internal__/popover/popover.style.d.ts +6 -2
- package/esm/__internal__/popover/popover.style.js +6 -2
- package/esm/__internal__/radio-button-mapper/index.d.ts +2 -0
- package/esm/__internal__/radio-button-mapper/index.js +1 -0
- package/esm/__internal__/radio-button-mapper/radio-button-mapper.d.ts +21 -0
- package/esm/__internal__/sticky-footer/index.d.ts +1 -0
- package/esm/__internal__/sticky-footer/sticky-footer.component.d.ts +15 -0
- package/esm/__internal__/sticky-footer/sticky-footer.style.d.ts +2 -0
- package/esm/__internal__/utils/helpers/tags/index.d.ts +1 -0
- package/esm/__spec_helper__/mock-resize-observer.d.ts +1 -1
- package/esm/__spec_helper__/mock-resize-observer.js +2 -2
- package/esm/components/button-toggle/button-toggle.component.d.ts +3 -3
- package/esm/components/button-toggle/button-toggle.component.js +21 -20
- package/esm/components/button-toggle/button-toggle.style.d.ts +1 -1
- package/esm/components/button-toggle-group/button-toggle-group.component.d.ts +45 -0
- package/esm/components/button-toggle-group/button-toggle-group.component.js +187 -92
- package/esm/components/button-toggle-group/button-toggle-group.style.d.ts +4 -0
- package/esm/components/button-toggle-group/button-toggle-group.style.js +2 -2
- package/esm/components/button-toggle-group/index.d.ts +2 -1
- package/esm/components/drawer/drawer.component.d.ts +37 -0
- package/esm/components/drawer/drawer.component.js +43 -54
- package/esm/components/drawer/drawer.style.d.ts +27 -0
- package/esm/components/drawer/drawer.style.js +2 -2
- package/esm/components/drawer/index.d.ts +2 -1
- package/esm/components/drawer/index.js +1 -2
- package/esm/components/i18n-provider/i18n-provider.component.d.ts +8 -0
- package/esm/components/i18n-provider/i18n-provider.component.js +100 -80
- package/esm/components/i18n-provider/index.d.ts +2 -1
- package/esm/components/menu/__internal__/submenu/submenu.component.js +22 -4
- package/esm/components/menu/menu-item/menu-item.component.js +6 -1
- package/esm/components/menu/menu-item/menu-item.d.ts +4 -0
- package/esm/components/menu/menu-item/menu-item.style.js +158 -149
- package/esm/components/menu/scrollable-block/scrollable-block.component.js +21 -5
- package/esm/components/menu/scrollable-block/scrollable-block.d.ts +6 -0
- package/esm/components/menu/scrollable-block/scrollable-block.style.js +1 -1
- package/esm/components/select/filterable-select/filterable-select.component.js +7 -5
- package/esm/components/select/multi-select/multi-select.component.js +4 -3
- package/esm/components/select/select-list/select-list.component.js +34 -18
- package/esm/components/select/simple-select/simple-select.component.js +4 -3
- package/esm/components/tabs/__internal__/tabs-header/tabs-header.style.d.ts +6 -0
- package/esm/components/tabs/tab/tab.style.d.ts +2 -0
- package/esm/components/tabs/tabs.style.d.ts +2 -0
- package/lib/__internal__/i18n-context/index.d.ts +2 -1
- package/lib/__internal__/popover/popover.component.d.ts +2 -1
- package/lib/__internal__/popover/popover.component.js +16 -5
- package/lib/__internal__/popover/popover.style.d.ts +6 -2
- package/lib/__internal__/popover/popover.style.js +8 -3
- package/lib/__internal__/radio-button-mapper/index.d.ts +2 -0
- package/lib/{components/button-toggle-group/documentation → __internal__/radio-button-mapper}/index.js +2 -2
- package/lib/__internal__/radio-button-mapper/package.json +6 -0
- package/lib/__internal__/radio-button-mapper/radio-button-mapper.d.ts +21 -0
- package/lib/__internal__/sticky-footer/index.d.ts +1 -0
- package/lib/__internal__/sticky-footer/sticky-footer.component.d.ts +15 -0
- package/lib/__internal__/sticky-footer/sticky-footer.style.d.ts +2 -0
- package/lib/__internal__/utils/helpers/tags/index.d.ts +1 -0
- package/lib/__spec_helper__/mock-resize-observer.d.ts +1 -1
- package/lib/__spec_helper__/mock-resize-observer.js +2 -2
- package/lib/components/button-toggle/button-toggle.component.d.ts +3 -3
- package/lib/components/button-toggle/button-toggle.component.js +22 -20
- package/lib/components/button-toggle/button-toggle.style.d.ts +1 -1
- package/lib/components/button-toggle-group/button-toggle-group.component.d.ts +45 -0
- package/lib/components/button-toggle-group/button-toggle-group.component.js +190 -93
- package/lib/components/button-toggle-group/button-toggle-group.style.d.ts +4 -0
- package/lib/components/button-toggle-group/button-toggle-group.style.js +2 -2
- package/lib/components/button-toggle-group/index.d.ts +2 -1
- package/lib/components/drawer/drawer.component.d.ts +37 -0
- package/lib/components/drawer/drawer.component.js +43 -55
- package/lib/components/drawer/drawer.style.d.ts +27 -0
- package/lib/components/drawer/drawer.style.js +3 -3
- package/lib/components/drawer/index.d.ts +2 -1
- package/lib/components/i18n-provider/i18n-provider.component.d.ts +8 -0
- package/lib/components/i18n-provider/i18n-provider.component.js +102 -82
- package/lib/components/i18n-provider/index.d.ts +2 -1
- package/lib/components/menu/__internal__/submenu/submenu.component.js +23 -4
- package/lib/components/menu/menu-item/menu-item.component.js +6 -1
- package/lib/components/menu/menu-item/menu-item.d.ts +4 -0
- package/lib/components/menu/menu-item/menu-item.style.js +158 -149
- package/lib/components/menu/scrollable-block/scrollable-block.component.js +22 -5
- package/lib/components/menu/scrollable-block/scrollable-block.d.ts +6 -0
- package/lib/components/menu/scrollable-block/scrollable-block.style.js +1 -1
- package/lib/components/select/filterable-select/filterable-select.component.js +7 -5
- package/lib/components/select/multi-select/multi-select.component.js +4 -3
- package/lib/components/select/select-list/select-list.component.js +34 -18
- package/lib/components/select/simple-select/simple-select.component.js +4 -3
- package/lib/components/tabs/__internal__/tabs-header/tabs-header.style.d.ts +6 -0
- package/lib/components/tabs/tab/tab.style.d.ts +2 -0
- package/lib/components/tabs/tabs.style.d.ts +2 -0
- package/package.json +1 -1
- package/esm/components/button-toggle-group/__definition__.js +0 -38
- package/esm/components/button-toggle-group/button-toggle-group.d.ts +0 -58
- package/esm/components/button-toggle-group/documentation/index.js +0 -1
- package/esm/components/drawer/drawer.d.ts +0 -44
- package/esm/components/i18n-provider/i18n-provider.d.ts +0 -11
- package/lib/components/button-toggle-group/__definition__.js +0 -50
- package/lib/components/button-toggle-group/button-toggle-group.d.ts +0 -58
- package/lib/components/button-toggle-group/documentation/package.json +0 -6
- package/lib/components/drawer/drawer.d.ts +0 -44
- package/lib/components/i18n-provider/i18n-provider.d.ts +0 -11
|
@@ -15,6 +15,7 @@ const StyledMenuItemWrapper = styled.a`
|
|
|
15
15
|
clickToOpen,
|
|
16
16
|
maxWidth,
|
|
17
17
|
inFullscreenView,
|
|
18
|
+
overrideColor,
|
|
18
19
|
as
|
|
19
20
|
}) => css`
|
|
20
21
|
display: inline-block;
|
|
@@ -23,43 +24,51 @@ const StyledMenuItemWrapper = styled.a`
|
|
|
23
24
|
height: 40px;
|
|
24
25
|
position: relative;
|
|
25
26
|
cursor: pointer;
|
|
26
|
-
|
|
27
|
+
${!overrideColor && css`
|
|
28
|
+
background-color: ${menuConfigVariants[menuType].background};
|
|
29
|
+
`}};
|
|
30
|
+
|
|
31
|
+
${overrideColor && css`
|
|
32
|
+
&&&& {
|
|
33
|
+
background-color: ${variant === "alternate" ? menuConfigVariants[menuType].alternate : menuConfigVariants[menuType].submenuItemBackground};
|
|
34
|
+
}
|
|
35
|
+
`}
|
|
27
36
|
|
|
28
37
|
${!inFullscreenView && css`
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
a:focus,
|
|
44
|
-
button:focus {
|
|
45
|
-
box-shadow: inset 0 0 0 var(--borderWidth300)
|
|
46
|
-
var(--colorsSemanticFocus500);
|
|
47
|
-
background-color: ${menuConfigVariants[menuType].background};
|
|
48
|
-
color: ${menuConfigVariants[menuType].color};
|
|
49
|
-
z-index: 1;
|
|
50
|
-
position: relative;
|
|
51
|
-
}
|
|
38
|
+
max-width: inherit;
|
|
39
|
+
|
|
40
|
+
a,
|
|
41
|
+
button {
|
|
42
|
+
${maxWidth && css`
|
|
43
|
+
box-sizing: border-box;
|
|
44
|
+
max-width: inherit;
|
|
45
|
+
text-overflow: ellipsis;
|
|
46
|
+
overflow: hidden;
|
|
47
|
+
white-space: nowrap;
|
|
48
|
+
vertical-align: bottom;
|
|
49
|
+
`}
|
|
50
|
+
}
|
|
52
51
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
a:focus,
|
|
53
|
+
button:focus {
|
|
54
|
+
box-shadow: inset 0 0 0 var(--borderWidth300)
|
|
55
|
+
var(--colorsSemanticFocus500);
|
|
56
|
+
background-color: ${menuConfigVariants[menuType].background};
|
|
57
|
+
color: ${menuConfigVariants[menuType].color};
|
|
58
|
+
z-index: 1;
|
|
59
|
+
position: relative;
|
|
60
|
+
}
|
|
57
61
|
|
|
58
|
-
|
|
62
|
+
a:hover,
|
|
63
|
+
button:hover {
|
|
64
|
+
background-color: var(--colorsComponentsMenuAutumnStandard600);
|
|
59
65
|
color: var(--colorsComponentsMenuYang100);
|
|
66
|
+
|
|
67
|
+
[data-component="icon"] {
|
|
68
|
+
color: var(--colorsComponentsMenuYang100);
|
|
69
|
+
}
|
|
60
70
|
}
|
|
61
|
-
}
|
|
62
|
-
`}
|
|
71
|
+
`}
|
|
63
72
|
|
|
64
73
|
a,
|
|
65
74
|
${StyledLink} a,
|
|
@@ -92,159 +101,159 @@ const StyledMenuItemWrapper = styled.a`
|
|
|
92
101
|
}
|
|
93
102
|
|
|
94
103
|
${selected && css`
|
|
95
|
-
background-color: ${menuConfigVariants[menuType].selected};
|
|
96
|
-
|
|
97
|
-
a:focus,
|
|
98
|
-
button:focus {
|
|
99
104
|
background-color: ${menuConfigVariants[menuType].selected};
|
|
100
|
-
}
|
|
101
105
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
106
|
+
a:focus,
|
|
107
|
+
button:focus {
|
|
108
|
+
background-color: ${menuConfigVariants[menuType].selected};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
a:hover,
|
|
112
|
+
button:hover {
|
|
113
|
+
background-color: var(--colorsComponentsMenuAutumnStandard600);
|
|
114
|
+
}
|
|
115
|
+
`}
|
|
107
116
|
|
|
108
117
|
${variant === "alternate" && !inFullscreenView && css`
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
118
|
+
&&& {
|
|
119
|
+
background-color: ${menuConfigVariants[menuType].alternate};
|
|
120
|
+
}
|
|
112
121
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
122
|
+
&&& a:focus,
|
|
123
|
+
&&& button:focus {
|
|
124
|
+
background-color: ${menuConfigVariants[menuType].alternate};
|
|
125
|
+
}
|
|
117
126
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
127
|
+
&&& a:hover,
|
|
128
|
+
&&& button:hover {
|
|
129
|
+
background-color: ${menuConfigVariants[menuType].alternateHover};
|
|
130
|
+
}
|
|
131
|
+
`}
|
|
123
132
|
|
|
124
133
|
${isOpen && css`
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
134
|
+
a,
|
|
135
|
+
button {
|
|
136
|
+
background-color: ${menuConfigVariants[menuType].submenuItemBackground};
|
|
137
|
+
color: ${menuConfigVariants[menuType].color};
|
|
138
|
+
}
|
|
139
|
+
`}
|
|
131
140
|
|
|
132
141
|
${hasSubmenu && css`
|
|
133
|
-
background-color: ${menuConfigVariants[menuType].submenuBackground};
|
|
134
|
-
|
|
135
|
-
a:focus,
|
|
136
|
-
button:focus {
|
|
137
142
|
background-color: ${menuConfigVariants[menuType].submenuBackground};
|
|
138
|
-
color: ${menuConfigVariants[menuType].color};
|
|
139
143
|
|
|
140
|
-
|
|
144
|
+
a:focus,
|
|
145
|
+
button:focus {
|
|
146
|
+
background-color: ${menuConfigVariants[menuType].submenuBackground};
|
|
141
147
|
color: ${menuConfigVariants[menuType].color};
|
|
148
|
+
|
|
149
|
+
[data-component="icon"] {
|
|
150
|
+
color: ${menuConfigVariants[menuType].color};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
${clickToOpen && isOpen && css`
|
|
154
|
+
background-color: ${menuConfigVariants[menuType].submenuOpenedBackground};
|
|
155
|
+
`}
|
|
142
156
|
}
|
|
143
157
|
|
|
144
|
-
|
|
158
|
+
a:hover,
|
|
159
|
+
button:hover {
|
|
145
160
|
background-color: ${menuConfigVariants[menuType].submenuOpenedBackground};
|
|
146
|
-
|
|
147
|
-
}
|
|
161
|
+
color: var(--colorsComponentsMenuYang100);
|
|
148
162
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
163
|
+
${!(href || clickToOpen) && css`
|
|
164
|
+
cursor: default;
|
|
165
|
+
background-color: ${menuConfigVariants[menuType].submenuItemBackground};
|
|
166
|
+
color: ${menuConfigVariants[menuType].color};
|
|
167
|
+
`}
|
|
153
168
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
color: ${menuConfigVariants[menuType].color};
|
|
158
|
-
`}
|
|
159
|
-
|
|
160
|
-
[data-component="icon"] {
|
|
161
|
-
color: ${menuConfigVariants[menuType].color};
|
|
169
|
+
[data-component="icon"] {
|
|
170
|
+
color: ${menuConfigVariants[menuType].color};
|
|
171
|
+
}
|
|
162
172
|
}
|
|
163
|
-
}
|
|
164
173
|
|
|
165
|
-
|
|
166
|
-
background-color: ${menuConfigVariants[menuType].submenuSelected};
|
|
167
|
-
|
|
168
|
-
a:focus,
|
|
169
|
-
button:focus {
|
|
174
|
+
${selected && css`
|
|
170
175
|
background-color: ${menuConfigVariants[menuType].submenuSelected};
|
|
171
|
-
}
|
|
172
176
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
178
|
-
`}
|
|
177
|
+
a:focus,
|
|
178
|
+
button:focus {
|
|
179
|
+
background-color: ${menuConfigVariants[menuType].submenuSelected};
|
|
180
|
+
}
|
|
179
181
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
182
|
+
a:hover,
|
|
183
|
+
button:hover {
|
|
184
|
+
background-color: var(--colorsComponentsMenuAutumnStandard600);
|
|
185
|
+
color: var(--colorsComponentsMenuYang100);
|
|
186
|
+
}
|
|
187
|
+
`}
|
|
185
188
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
189
|
+
${showDropdownArrow && css`
|
|
190
|
+
> a,
|
|
191
|
+
> button {
|
|
192
|
+
padding-right: 32px;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
a::before,
|
|
196
|
+
button::before {
|
|
197
|
+
display: block;
|
|
198
|
+
margin-top: -2px;
|
|
199
|
+
pointer-events: none;
|
|
200
|
+
position: absolute;
|
|
201
|
+
right: 16px;
|
|
202
|
+
top: 50%;
|
|
203
|
+
z-index: 2;
|
|
204
|
+
content: "";
|
|
205
|
+
width: 0;
|
|
206
|
+
height: 0;
|
|
207
|
+
border-top: 5px solid ${menuConfigVariants[menuType].text};
|
|
208
|
+
border-right: 4px solid transparent;
|
|
209
|
+
border-bottom: 4px solid transparent;
|
|
210
|
+
border-left: 4px solid transparent;
|
|
211
|
+
}
|
|
212
|
+
`}
|
|
213
|
+
`}
|
|
205
214
|
|
|
206
215
|
${isSearch && css`
|
|
207
|
-
|
|
208
|
-
|
|
216
|
+
padding: 2px 16px;
|
|
217
|
+
`}
|
|
209
218
|
|
|
210
219
|
${inFullscreenView && css`
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
220
|
+
${as === "div" && css`
|
|
221
|
+
cursor: default;
|
|
222
|
+
padding: 0 16px;
|
|
214
223
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
224
|
+
:hover {
|
|
225
|
+
background: transparent;
|
|
226
|
+
}
|
|
227
|
+
`}
|
|
219
228
|
|
|
220
|
-
|
|
229
|
+
a,
|
|
221
230
|
${StyledLink} a,
|
|
222
231
|
button,
|
|
223
232
|
${StyledLink} button {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
color: var(--colorsComponentsMenuYang100);
|
|
242
|
-
|
|
243
|
-
[data-component="icon"] {
|
|
233
|
+
width: 100vw;
|
|
234
|
+
box-sizing: border-box;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
a:focus,
|
|
238
|
+
button:focus {
|
|
239
|
+
box-shadow: inset 0 0 0 var(--borderWidth300)
|
|
240
|
+
var(--colorsSemanticFocus500);
|
|
241
|
+
z-index: 1;
|
|
242
|
+
position: relative;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
a:focus,
|
|
246
|
+
a:hover,
|
|
247
|
+
button:focus,
|
|
248
|
+
button:hover {
|
|
249
|
+
background-color: var(--colorsComponentsMenuAutumnStandard600);
|
|
244
250
|
color: var(--colorsComponentsMenuYang100);
|
|
251
|
+
|
|
252
|
+
[data-component="icon"] {
|
|
253
|
+
color: var(--colorsComponentsMenuYang100);
|
|
254
|
+
}
|
|
245
255
|
}
|
|
246
|
-
}
|
|
247
|
-
`}
|
|
256
|
+
`}
|
|
248
257
|
`}
|
|
249
258
|
`;
|
|
250
259
|
export default StyledMenuItemWrapper;
|
|
@@ -3,6 +3,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
3
3
|
import React, { useContext } from "react";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
5
|
import MenuContext from "../menu.context";
|
|
6
|
+
import MenuItem from "../menu-item";
|
|
6
7
|
import SubmenuContext from "../__internal__/submenu/submenu.context";
|
|
7
8
|
import StyledScrollableBlock from "./scrollable-block.style";
|
|
8
9
|
import Box from "../../box";
|
|
@@ -11,6 +12,8 @@ const ScrollableBlock = ({
|
|
|
11
12
|
children,
|
|
12
13
|
height,
|
|
13
14
|
variant = "default",
|
|
15
|
+
parent,
|
|
16
|
+
parentVariant,
|
|
14
17
|
...rest
|
|
15
18
|
}) => {
|
|
16
19
|
const menuContext = useContext(MenuContext);
|
|
@@ -29,14 +32,19 @@ const ScrollableBlock = ({
|
|
|
29
32
|
return /*#__PURE__*/React.createElement(StyledScrollableBlock, _extends({
|
|
30
33
|
"data-component": "submenu-scrollable-block",
|
|
31
34
|
menuType: menuContext.menuType,
|
|
32
|
-
variant: variant
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
variant: variant
|
|
36
|
+
}, rest), parent && /*#__PURE__*/React.createElement(MenuItem, {
|
|
37
|
+
overrideColor: true,
|
|
38
|
+
variant: parentVariant,
|
|
39
|
+
as: "div",
|
|
40
|
+
href: "#"
|
|
41
|
+
}, parent), /*#__PURE__*/React.createElement(Box, {
|
|
35
42
|
overflowY: "scroll",
|
|
36
43
|
scrollVariant: scrollVariants[menuContext.menuType],
|
|
37
44
|
height: height,
|
|
38
45
|
p: 0,
|
|
39
|
-
|
|
46
|
+
as: "ul",
|
|
47
|
+
role: "list"
|
|
40
48
|
}, React.Children.map(children, (child, index) => {
|
|
41
49
|
let isFocused = false;
|
|
42
50
|
const blockItemFocused = focusIndex >= blockIndex;
|
|
@@ -62,6 +70,14 @@ ScrollableBlock.propTypes = {
|
|
|
62
70
|
height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
63
71
|
|
|
64
72
|
/** set the colour variant for a menuType */
|
|
65
|
-
variant: PropTypes.oneOf(["default", "alternate"])
|
|
73
|
+
variant: PropTypes.oneOf(["default", "alternate"]),
|
|
74
|
+
|
|
75
|
+
/** the element, if any, displayed at the top of the block to be its semantic "parent",
|
|
76
|
+
* but not part of the scrollable section
|
|
77
|
+
*/
|
|
78
|
+
parent: PropTypes.node,
|
|
79
|
+
|
|
80
|
+
/** the colour variant for the parent element, if different from the variant of the block */
|
|
81
|
+
parentVariant: PropTypes.oneOf(["default", "alternate"])
|
|
66
82
|
};
|
|
67
83
|
export default ScrollableBlock;
|
|
@@ -7,6 +7,12 @@ export interface ScrollableBlockProps {
|
|
|
7
7
|
height?: string | number;
|
|
8
8
|
/** set the colour variant for a menuType */
|
|
9
9
|
variant?: "default" | "alternate";
|
|
10
|
+
/** the element, if any, displayed at the top of the block to be its semantic "parent",
|
|
11
|
+
* but not part of the scrollable section
|
|
12
|
+
*/
|
|
13
|
+
parent?: React.ReactElement;
|
|
14
|
+
/** the colour variant for the parent element, if different from the variant of the block */
|
|
15
|
+
parentVariant?: "default" | "alternate";
|
|
10
16
|
}
|
|
11
17
|
|
|
12
18
|
declare function ScrollableBlock(props: ScrollableBlockProps): JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
2
|
import StyledMenuItemWrapper from "../menu-item/menu-item.style";
|
|
3
3
|
import menuConfigVariants from "../menu.config";
|
|
4
|
-
const StyledScrollableBlock = styled.
|
|
4
|
+
const StyledScrollableBlock = styled.li`
|
|
5
5
|
${({
|
|
6
6
|
menuType,
|
|
7
7
|
variant
|
|
@@ -155,16 +155,17 @@ const FilterableSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
155
155
|
|
|
156
156
|
fillLastFilterCharacter(key);
|
|
157
157
|
}, [fillLastFilterCharacter, onKeyDown, readOnly]);
|
|
158
|
+
const valueToUse = isControlled.current ? value : selectedValue;
|
|
158
159
|
const handleGlobalClick = useCallback(event => {
|
|
159
160
|
const notInContainer = containerRef.current && !containerRef.current.contains(event.target);
|
|
160
161
|
const notInList = listboxRef.current && !listboxRef.current.contains(event.target);
|
|
161
162
|
isMouseDownReported.current = false;
|
|
162
163
|
|
|
163
164
|
if (notInContainer && notInList) {
|
|
164
|
-
setMatchingText(
|
|
165
|
+
setMatchingText(valueToUse, true);
|
|
165
166
|
setOpen(false);
|
|
166
167
|
}
|
|
167
|
-
}, [setMatchingText,
|
|
168
|
+
}, [setMatchingText, valueToUse]);
|
|
168
169
|
useEffect(() => {
|
|
169
170
|
const modeSwitchedMessage = "Input elements should not switch from uncontrolled to controlled (or vice versa). " + "Decide between using a controlled or uncontrolled input element for the lifetime of the component";
|
|
170
171
|
const onChangeMissingMessage = "onChange prop required when using a controlled input element";
|
|
@@ -408,7 +409,8 @@ const FilterableSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
408
409
|
multiColumn: multiColumn,
|
|
409
410
|
loaderDataRole: "filterable-select-list-loader",
|
|
410
411
|
listPlacement: listPlacement,
|
|
411
|
-
flipEnabled: flipEnabled
|
|
412
|
+
flipEnabled: flipEnabled,
|
|
413
|
+
isOpen: isOpen
|
|
412
414
|
}, children);
|
|
413
415
|
return /*#__PURE__*/React.createElement(StyledSelect, _extends({
|
|
414
416
|
ref: containerRef,
|
|
@@ -424,11 +426,11 @@ const FilterableSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
424
426
|
}, /*#__PURE__*/React.createElement(SelectTextbox, _extends({
|
|
425
427
|
activeDescendantId: activeDescendantId,
|
|
426
428
|
labelId: label ? labelId.current : undefined,
|
|
427
|
-
"aria-controls":
|
|
429
|
+
"aria-controls": selectListId.current,
|
|
428
430
|
isOpen: isOpen,
|
|
429
431
|
hasTextCursor: true,
|
|
430
432
|
textboxRef: textboxRef
|
|
431
|
-
}, getTextboxProps()))),
|
|
433
|
+
}, getTextboxProps()))), selectList);
|
|
432
434
|
});
|
|
433
435
|
FilterableSelect.propTypes = { ...formInputPropTypes,
|
|
434
436
|
|
|
@@ -425,7 +425,8 @@ const MultiSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
425
425
|
listPlacement: listPlacement,
|
|
426
426
|
flipEnabled: flipEnabled,
|
|
427
427
|
loaderDataRole: "multi-select-list-loader",
|
|
428
|
-
multiselectValues: actualValue
|
|
428
|
+
multiselectValues: actualValue,
|
|
429
|
+
isOpen: isOpen
|
|
429
430
|
}, children);
|
|
430
431
|
return /*#__PURE__*/React.createElement(StyledSelectMultiSelect, _extends({
|
|
431
432
|
disabled: disabled,
|
|
@@ -444,12 +445,12 @@ const MultiSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
444
445
|
}, accessibilityLabel), /*#__PURE__*/React.createElement(SelectTextbox, _extends({
|
|
445
446
|
accessibilityLabelId: accessibilityLabelId.current,
|
|
446
447
|
activeDescendantId: activeDescendantId,
|
|
447
|
-
"aria-controls":
|
|
448
|
+
"aria-controls": selectListId.current,
|
|
448
449
|
hasTextCursor: true,
|
|
449
450
|
isOpen: isOpen,
|
|
450
451
|
labelId: labelId.current,
|
|
451
452
|
textboxRef: textboxRef
|
|
452
|
-
}, getTextboxProps()))),
|
|
453
|
+
}, getTextboxProps()))), selectList);
|
|
453
454
|
});
|
|
454
455
|
MultiSelect.propTypes = { ...formInputPropTypes,
|
|
455
456
|
|
|
@@ -46,6 +46,7 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
|
|
|
46
46
|
loaderDataRole,
|
|
47
47
|
listPlacement = "bottom-start",
|
|
48
48
|
flipEnabled = true,
|
|
49
|
+
isOpen,
|
|
49
50
|
...listProps
|
|
50
51
|
}, listContainerRef) => {
|
|
51
52
|
const [currentOptionsListIndex, setCurrentOptionsListIndex] = useState(-1);
|
|
@@ -61,30 +62,35 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
|
|
|
61
62
|
blockScroll,
|
|
62
63
|
allowScroll
|
|
63
64
|
} = useScrollBlock();
|
|
65
|
+
const updateListHeight = useCallback(() => {
|
|
66
|
+
if (isOpen) {
|
|
67
|
+
let newHeight = listRef.current.clientHeight;
|
|
64
68
|
|
|
65
|
-
|
|
66
|
-
|
|
69
|
+
if (listActionButtonRef.current) {
|
|
70
|
+
newHeight += listActionButtonRef.current.parentElement.clientHeight;
|
|
71
|
+
}
|
|
67
72
|
|
|
68
|
-
|
|
69
|
-
newHeight += listActionButtonRef.current.parentElement.clientHeight;
|
|
73
|
+
setListHeight(`${newHeight}px`);
|
|
70
74
|
}
|
|
71
|
-
|
|
72
|
-
setListHeight(`${newHeight}px`);
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
+
}, [isOpen]);
|
|
75
76
|
const listCallbackRef = useCallback(element => {
|
|
76
77
|
listRef.current = element;
|
|
77
78
|
|
|
78
79
|
if (element) {
|
|
79
80
|
setTimeout(updateListHeight, 0);
|
|
80
81
|
}
|
|
81
|
-
}, []);
|
|
82
|
+
}, [updateListHeight]);
|
|
82
83
|
useEffect(() => {
|
|
83
|
-
|
|
84
|
+
if (isOpen) {
|
|
85
|
+
blockScroll();
|
|
86
|
+
}
|
|
87
|
+
|
|
84
88
|
return () => {
|
|
85
|
-
|
|
89
|
+
if (isOpen) {
|
|
90
|
+
allowScroll();
|
|
91
|
+
}
|
|
86
92
|
};
|
|
87
|
-
}, [allowScroll, blockScroll]);
|
|
93
|
+
}, [allowScroll, blockScroll, isOpen]);
|
|
88
94
|
useLayoutEffect(() => {
|
|
89
95
|
if (multiColumn) {
|
|
90
96
|
setScrollbarWidth(tableRef.current.offsetWidth - tableRef.current.clientWidth);
|
|
@@ -108,6 +114,7 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
|
|
|
108
114
|
selectionType: "click"
|
|
109
115
|
});
|
|
110
116
|
}, [onSelect]);
|
|
117
|
+
const childIds = useMemo(() => React.Children.map(children, () => guid()), [children]);
|
|
111
118
|
const childrenWithListProps = useMemo(() => React.Children.map(children, (child, index) => {
|
|
112
119
|
if (!child || child.type !== Option && child.type !== OptionRow) {
|
|
113
120
|
return child;
|
|
@@ -115,13 +122,13 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
|
|
|
115
122
|
|
|
116
123
|
const newProps = {
|
|
117
124
|
index,
|
|
118
|
-
id:
|
|
125
|
+
id: childIds[index],
|
|
119
126
|
onSelect: handleSelect,
|
|
120
127
|
hidden: isLoading && React.Children.count(children) === 1,
|
|
121
128
|
ref: optionRefList[index]
|
|
122
129
|
};
|
|
123
130
|
return /*#__PURE__*/React.cloneElement(child, newProps);
|
|
124
|
-
}), [children, handleSelect, isLoading, optionRefList]);
|
|
131
|
+
}), [children, handleSelect, isLoading, optionRefList, childIds]);
|
|
125
132
|
const childrenList = useMemo(() => React.Children.toArray(childrenWithListProps), [childrenWithListProps]);
|
|
126
133
|
const lastOptionIndex = useMemo(() => {
|
|
127
134
|
let lastIndex = 0;
|
|
@@ -188,6 +195,10 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
|
|
|
188
195
|
}
|
|
189
196
|
}, [anchorElement]);
|
|
190
197
|
const handleGlobalKeydown = useCallback(event => {
|
|
198
|
+
if (!isOpen) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
|
|
191
202
|
const {
|
|
192
203
|
key
|
|
193
204
|
} = event;
|
|
@@ -221,7 +232,7 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
|
|
|
221
232
|
focusOnAnchor();
|
|
222
233
|
highlightNextItem(key);
|
|
223
234
|
}
|
|
224
|
-
}, [childrenList, listActionButton, handleActionButtonTab, onSelectListClose, currentOptionsListIndex, onSelect, highlightNextItem, focusOnAnchor]);
|
|
235
|
+
}, [childrenList, listActionButton, handleActionButtonTab, onSelectListClose, currentOptionsListIndex, onSelect, highlightNextItem, focusOnAnchor, isOpen]);
|
|
225
236
|
const handleListScroll = useCallback(event => {
|
|
226
237
|
const element = event.target;
|
|
227
238
|
|
|
@@ -243,7 +254,7 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
|
|
|
243
254
|
window.removeEventListener("resize", assignListWidth);
|
|
244
255
|
};
|
|
245
256
|
}, [assignListWidth]);
|
|
246
|
-
useLayoutEffect(updateListHeight, [children]);
|
|
257
|
+
useLayoutEffect(updateListHeight, [children, updateListHeight]);
|
|
247
258
|
useEffect(() => {
|
|
248
259
|
const keyboardEvent = "keydown";
|
|
249
260
|
const listElement = listRef.current;
|
|
@@ -315,7 +326,7 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
|
|
|
315
326
|
reference: anchorRef,
|
|
316
327
|
onFirstUpdate: setPlacementCallback,
|
|
317
328
|
modifiers: popoverModifiers,
|
|
318
|
-
|
|
329
|
+
isOpen: isOpen
|
|
319
330
|
}, /*#__PURE__*/React.createElement(StyledPopoverContainer, {
|
|
320
331
|
height: listHeight,
|
|
321
332
|
width: listWidth,
|
|
@@ -397,6 +408,11 @@ SelectList.propTypes = {
|
|
|
397
408
|
listPlacement: PropTypes.oneOf(["auto", "auto-start", "auto-end", "top", "top-start", "top-end", "bottom", "bottom-start", "bottom-end", "right", "right-start", "right-end", "left", "left-start", "left-end"]),
|
|
398
409
|
|
|
399
410
|
/** Use the opposite list placement if the set placement does not fit */
|
|
400
|
-
flipEnabled: PropTypes.bool
|
|
411
|
+
flipEnabled: PropTypes.bool,
|
|
412
|
+
|
|
413
|
+
/** @private @ignore
|
|
414
|
+
* Hides the list (with CSS display: none) if not set
|
|
415
|
+
*/
|
|
416
|
+
isOpen: PropTypes.bool
|
|
401
417
|
};
|
|
402
418
|
export default SelectList;
|
|
@@ -331,7 +331,8 @@ const SimpleSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
331
331
|
multiColumn: multiColumn,
|
|
332
332
|
loaderDataRole: "simple-select-list-loader",
|
|
333
333
|
listPlacement: listPlacement,
|
|
334
|
-
flipEnabled: flipEnabled
|
|
334
|
+
flipEnabled: flipEnabled,
|
|
335
|
+
isOpen: isOpen
|
|
335
336
|
}, children);
|
|
336
337
|
return /*#__PURE__*/React.createElement(StyledSelect, _extends({
|
|
337
338
|
transparent: transparent,
|
|
@@ -344,12 +345,12 @@ const SimpleSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
344
345
|
}, filterStyledSystemMarginProps(props)), /*#__PURE__*/React.createElement("div", {
|
|
345
346
|
ref: containerRef
|
|
346
347
|
}, /*#__PURE__*/React.createElement(SelectTextbox, _extends({
|
|
347
|
-
"aria-controls":
|
|
348
|
+
"aria-controls": selectListId.current,
|
|
348
349
|
activeDescendantId: activeDescendantId,
|
|
349
350
|
labelId: labelId.current,
|
|
350
351
|
isOpen: isOpen,
|
|
351
352
|
textboxRef: textboxRef
|
|
352
|
-
}, getTextboxProps()))),
|
|
353
|
+
}, getTextboxProps()))), selectList);
|
|
353
354
|
});
|
|
354
355
|
SimpleSelect.propTypes = {
|
|
355
356
|
/** Styled system spacing props */
|