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
|
@@ -32,6 +32,7 @@ const StyledMenuItemWrapper = _styledComponents.default.a`
|
|
|
32
32
|
clickToOpen,
|
|
33
33
|
maxWidth,
|
|
34
34
|
inFullscreenView,
|
|
35
|
+
overrideColor,
|
|
35
36
|
as
|
|
36
37
|
}) => (0, _styledComponents.css)`
|
|
37
38
|
display: inline-block;
|
|
@@ -40,43 +41,51 @@ const StyledMenuItemWrapper = _styledComponents.default.a`
|
|
|
40
41
|
height: 40px;
|
|
41
42
|
position: relative;
|
|
42
43
|
cursor: pointer;
|
|
43
|
-
|
|
44
|
+
${!overrideColor && (0, _styledComponents.css)`
|
|
45
|
+
background-color: ${_menu.default[menuType].background};
|
|
46
|
+
`}};
|
|
47
|
+
|
|
48
|
+
${overrideColor && (0, _styledComponents.css)`
|
|
49
|
+
&&&& {
|
|
50
|
+
background-color: ${variant === "alternate" ? _menu.default[menuType].alternate : _menu.default[menuType].submenuItemBackground};
|
|
51
|
+
}
|
|
52
|
+
`}
|
|
44
53
|
|
|
45
54
|
${!inFullscreenView && (0, _styledComponents.css)`
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
a:focus,
|
|
61
|
-
button:focus {
|
|
62
|
-
box-shadow: inset 0 0 0 var(--borderWidth300)
|
|
63
|
-
var(--colorsSemanticFocus500);
|
|
64
|
-
background-color: ${_menu.default[menuType].background};
|
|
65
|
-
color: ${_menu.default[menuType].color};
|
|
66
|
-
z-index: 1;
|
|
67
|
-
position: relative;
|
|
68
|
-
}
|
|
55
|
+
max-width: inherit;
|
|
56
|
+
|
|
57
|
+
a,
|
|
58
|
+
button {
|
|
59
|
+
${maxWidth && (0, _styledComponents.css)`
|
|
60
|
+
box-sizing: border-box;
|
|
61
|
+
max-width: inherit;
|
|
62
|
+
text-overflow: ellipsis;
|
|
63
|
+
overflow: hidden;
|
|
64
|
+
white-space: nowrap;
|
|
65
|
+
vertical-align: bottom;
|
|
66
|
+
`}
|
|
67
|
+
}
|
|
69
68
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
a:focus,
|
|
70
|
+
button:focus {
|
|
71
|
+
box-shadow: inset 0 0 0 var(--borderWidth300)
|
|
72
|
+
var(--colorsSemanticFocus500);
|
|
73
|
+
background-color: ${_menu.default[menuType].background};
|
|
74
|
+
color: ${_menu.default[menuType].color};
|
|
75
|
+
z-index: 1;
|
|
76
|
+
position: relative;
|
|
77
|
+
}
|
|
74
78
|
|
|
75
|
-
|
|
79
|
+
a:hover,
|
|
80
|
+
button:hover {
|
|
81
|
+
background-color: var(--colorsComponentsMenuAutumnStandard600);
|
|
76
82
|
color: var(--colorsComponentsMenuYang100);
|
|
83
|
+
|
|
84
|
+
[data-component="icon"] {
|
|
85
|
+
color: var(--colorsComponentsMenuYang100);
|
|
86
|
+
}
|
|
77
87
|
}
|
|
78
|
-
}
|
|
79
|
-
`}
|
|
88
|
+
`}
|
|
80
89
|
|
|
81
90
|
a,
|
|
82
91
|
${_link.StyledLink} a,
|
|
@@ -109,159 +118,159 @@ const StyledMenuItemWrapper = _styledComponents.default.a`
|
|
|
109
118
|
}
|
|
110
119
|
|
|
111
120
|
${selected && (0, _styledComponents.css)`
|
|
112
|
-
background-color: ${_menu.default[menuType].selected};
|
|
113
|
-
|
|
114
|
-
a:focus,
|
|
115
|
-
button:focus {
|
|
116
121
|
background-color: ${_menu.default[menuType].selected};
|
|
117
|
-
}
|
|
118
122
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
123
|
+
a:focus,
|
|
124
|
+
button:focus {
|
|
125
|
+
background-color: ${_menu.default[menuType].selected};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
a:hover,
|
|
129
|
+
button:hover {
|
|
130
|
+
background-color: var(--colorsComponentsMenuAutumnStandard600);
|
|
131
|
+
}
|
|
132
|
+
`}
|
|
124
133
|
|
|
125
134
|
${variant === "alternate" && !inFullscreenView && (0, _styledComponents.css)`
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
135
|
+
&&& {
|
|
136
|
+
background-color: ${_menu.default[menuType].alternate};
|
|
137
|
+
}
|
|
129
138
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
139
|
+
&&& a:focus,
|
|
140
|
+
&&& button:focus {
|
|
141
|
+
background-color: ${_menu.default[menuType].alternate};
|
|
142
|
+
}
|
|
134
143
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
144
|
+
&&& a:hover,
|
|
145
|
+
&&& button:hover {
|
|
146
|
+
background-color: ${_menu.default[menuType].alternateHover};
|
|
147
|
+
}
|
|
148
|
+
`}
|
|
140
149
|
|
|
141
150
|
${isOpen && (0, _styledComponents.css)`
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
151
|
+
a,
|
|
152
|
+
button {
|
|
153
|
+
background-color: ${_menu.default[menuType].submenuItemBackground};
|
|
154
|
+
color: ${_menu.default[menuType].color};
|
|
155
|
+
}
|
|
156
|
+
`}
|
|
148
157
|
|
|
149
158
|
${hasSubmenu && (0, _styledComponents.css)`
|
|
150
|
-
background-color: ${_menu.default[menuType].submenuBackground};
|
|
151
|
-
|
|
152
|
-
a:focus,
|
|
153
|
-
button:focus {
|
|
154
159
|
background-color: ${_menu.default[menuType].submenuBackground};
|
|
155
|
-
color: ${_menu.default[menuType].color};
|
|
156
160
|
|
|
157
|
-
|
|
161
|
+
a:focus,
|
|
162
|
+
button:focus {
|
|
163
|
+
background-color: ${_menu.default[menuType].submenuBackground};
|
|
158
164
|
color: ${_menu.default[menuType].color};
|
|
165
|
+
|
|
166
|
+
[data-component="icon"] {
|
|
167
|
+
color: ${_menu.default[menuType].color};
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
${clickToOpen && isOpen && (0, _styledComponents.css)`
|
|
171
|
+
background-color: ${_menu.default[menuType].submenuOpenedBackground};
|
|
172
|
+
`}
|
|
159
173
|
}
|
|
160
174
|
|
|
161
|
-
|
|
175
|
+
a:hover,
|
|
176
|
+
button:hover {
|
|
162
177
|
background-color: ${_menu.default[menuType].submenuOpenedBackground};
|
|
163
|
-
|
|
164
|
-
}
|
|
178
|
+
color: var(--colorsComponentsMenuYang100);
|
|
165
179
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
180
|
+
${!(href || clickToOpen) && (0, _styledComponents.css)`
|
|
181
|
+
cursor: default;
|
|
182
|
+
background-color: ${_menu.default[menuType].submenuItemBackground};
|
|
183
|
+
color: ${_menu.default[menuType].color};
|
|
184
|
+
`}
|
|
170
185
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
color: ${_menu.default[menuType].color};
|
|
175
|
-
`}
|
|
176
|
-
|
|
177
|
-
[data-component="icon"] {
|
|
178
|
-
color: ${_menu.default[menuType].color};
|
|
186
|
+
[data-component="icon"] {
|
|
187
|
+
color: ${_menu.default[menuType].color};
|
|
188
|
+
}
|
|
179
189
|
}
|
|
180
|
-
}
|
|
181
190
|
|
|
182
|
-
|
|
183
|
-
background-color: ${_menu.default[menuType].submenuSelected};
|
|
184
|
-
|
|
185
|
-
a:focus,
|
|
186
|
-
button:focus {
|
|
191
|
+
${selected && (0, _styledComponents.css)`
|
|
187
192
|
background-color: ${_menu.default[menuType].submenuSelected};
|
|
188
|
-
}
|
|
189
193
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
`}
|
|
194
|
+
a:focus,
|
|
195
|
+
button:focus {
|
|
196
|
+
background-color: ${_menu.default[menuType].submenuSelected};
|
|
197
|
+
}
|
|
196
198
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
199
|
+
a:hover,
|
|
200
|
+
button:hover {
|
|
201
|
+
background-color: var(--colorsComponentsMenuAutumnStandard600);
|
|
202
|
+
color: var(--colorsComponentsMenuYang100);
|
|
203
|
+
}
|
|
204
|
+
`}
|
|
202
205
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
206
|
+
${showDropdownArrow && (0, _styledComponents.css)`
|
|
207
|
+
> a,
|
|
208
|
+
> button {
|
|
209
|
+
padding-right: 32px;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
a::before,
|
|
213
|
+
button::before {
|
|
214
|
+
display: block;
|
|
215
|
+
margin-top: -2px;
|
|
216
|
+
pointer-events: none;
|
|
217
|
+
position: absolute;
|
|
218
|
+
right: 16px;
|
|
219
|
+
top: 50%;
|
|
220
|
+
z-index: 2;
|
|
221
|
+
content: "";
|
|
222
|
+
width: 0;
|
|
223
|
+
height: 0;
|
|
224
|
+
border-top: 5px solid ${_menu.default[menuType].text};
|
|
225
|
+
border-right: 4px solid transparent;
|
|
226
|
+
border-bottom: 4px solid transparent;
|
|
227
|
+
border-left: 4px solid transparent;
|
|
228
|
+
}
|
|
229
|
+
`}
|
|
230
|
+
`}
|
|
222
231
|
|
|
223
232
|
${isSearch && (0, _styledComponents.css)`
|
|
224
|
-
|
|
225
|
-
|
|
233
|
+
padding: 2px 16px;
|
|
234
|
+
`}
|
|
226
235
|
|
|
227
236
|
${inFullscreenView && (0, _styledComponents.css)`
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
237
|
+
${as === "div" && (0, _styledComponents.css)`
|
|
238
|
+
cursor: default;
|
|
239
|
+
padding: 0 16px;
|
|
231
240
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
241
|
+
:hover {
|
|
242
|
+
background: transparent;
|
|
243
|
+
}
|
|
244
|
+
`}
|
|
236
245
|
|
|
237
|
-
|
|
246
|
+
a,
|
|
238
247
|
${_link.StyledLink} a,
|
|
239
248
|
button,
|
|
240
249
|
${_link.StyledLink} button {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
color: var(--colorsComponentsMenuYang100);
|
|
259
|
-
|
|
260
|
-
[data-component="icon"] {
|
|
250
|
+
width: 100vw;
|
|
251
|
+
box-sizing: border-box;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
a:focus,
|
|
255
|
+
button:focus {
|
|
256
|
+
box-shadow: inset 0 0 0 var(--borderWidth300)
|
|
257
|
+
var(--colorsSemanticFocus500);
|
|
258
|
+
z-index: 1;
|
|
259
|
+
position: relative;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
a:focus,
|
|
263
|
+
a:hover,
|
|
264
|
+
button:focus,
|
|
265
|
+
button:hover {
|
|
266
|
+
background-color: var(--colorsComponentsMenuAutumnStandard600);
|
|
261
267
|
color: var(--colorsComponentsMenuYang100);
|
|
268
|
+
|
|
269
|
+
[data-component="icon"] {
|
|
270
|
+
color: var(--colorsComponentsMenuYang100);
|
|
271
|
+
}
|
|
262
272
|
}
|
|
263
|
-
}
|
|
264
|
-
`}
|
|
273
|
+
`}
|
|
265
274
|
`}
|
|
266
275
|
`;
|
|
267
276
|
var _default = StyledMenuItemWrapper;
|
|
@@ -11,6 +11,8 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
11
11
|
|
|
12
12
|
var _menu = _interopRequireDefault(require("../menu.context"));
|
|
13
13
|
|
|
14
|
+
var _menuItem = _interopRequireDefault(require("../menu-item"));
|
|
15
|
+
|
|
14
16
|
var _submenu = _interopRequireDefault(require("../__internal__/submenu/submenu.context"));
|
|
15
17
|
|
|
16
18
|
var _scrollableBlock = _interopRequireDefault(require("./scrollable-block.style"));
|
|
@@ -29,6 +31,8 @@ const ScrollableBlock = ({
|
|
|
29
31
|
children,
|
|
30
32
|
height,
|
|
31
33
|
variant = "default",
|
|
34
|
+
parent,
|
|
35
|
+
parentVariant,
|
|
32
36
|
...rest
|
|
33
37
|
}) => {
|
|
34
38
|
const menuContext = (0, _react.useContext)(_menu.default);
|
|
@@ -47,14 +51,19 @@ const ScrollableBlock = ({
|
|
|
47
51
|
return /*#__PURE__*/_react.default.createElement(_scrollableBlock.default, _extends({
|
|
48
52
|
"data-component": "submenu-scrollable-block",
|
|
49
53
|
menuType: menuContext.menuType,
|
|
50
|
-
variant: variant
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
variant: variant
|
|
55
|
+
}, rest), parent && /*#__PURE__*/_react.default.createElement(_menuItem.default, {
|
|
56
|
+
overrideColor: true,
|
|
57
|
+
variant: parentVariant,
|
|
58
|
+
as: "div",
|
|
59
|
+
href: "#"
|
|
60
|
+
}, parent), /*#__PURE__*/_react.default.createElement(_box.default, {
|
|
53
61
|
overflowY: "scroll",
|
|
54
62
|
scrollVariant: scrollVariants[menuContext.menuType],
|
|
55
63
|
height: height,
|
|
56
64
|
p: 0,
|
|
57
|
-
|
|
65
|
+
as: "ul",
|
|
66
|
+
role: "list"
|
|
58
67
|
}, _react.default.Children.map(children, (child, index) => {
|
|
59
68
|
let isFocused = false;
|
|
60
69
|
const blockItemFocused = focusIndex >= blockIndex;
|
|
@@ -80,7 +89,15 @@ ScrollableBlock.propTypes = {
|
|
|
80
89
|
height: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
81
90
|
|
|
82
91
|
/** set the colour variant for a menuType */
|
|
83
|
-
variant: _propTypes.default.oneOf(["default", "alternate"])
|
|
92
|
+
variant: _propTypes.default.oneOf(["default", "alternate"]),
|
|
93
|
+
|
|
94
|
+
/** the element, if any, displayed at the top of the block to be its semantic "parent",
|
|
95
|
+
* but not part of the scrollable section
|
|
96
|
+
*/
|
|
97
|
+
parent: _propTypes.default.node,
|
|
98
|
+
|
|
99
|
+
/** the colour variant for the parent element, if different from the variant of the block */
|
|
100
|
+
parentVariant: _propTypes.default.oneOf(["default", "alternate"])
|
|
84
101
|
};
|
|
85
102
|
var _default = ScrollableBlock;
|
|
86
103
|
exports.default = _default;
|
|
@@ -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;
|
|
@@ -17,7 +17,7 @@ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return
|
|
|
17
17
|
|
|
18
18
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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; }
|
|
19
19
|
|
|
20
|
-
const StyledScrollableBlock = _styledComponents.default.
|
|
20
|
+
const StyledScrollableBlock = _styledComponents.default.li`
|
|
21
21
|
${({
|
|
22
22
|
menuType,
|
|
23
23
|
variant
|
|
@@ -180,16 +180,17 @@ const FilterableSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
180
180
|
|
|
181
181
|
fillLastFilterCharacter(key);
|
|
182
182
|
}, [fillLastFilterCharacter, onKeyDown, readOnly]);
|
|
183
|
+
const valueToUse = isControlled.current ? value : selectedValue;
|
|
183
184
|
const handleGlobalClick = (0, _react.useCallback)(event => {
|
|
184
185
|
const notInContainer = containerRef.current && !containerRef.current.contains(event.target);
|
|
185
186
|
const notInList = listboxRef.current && !listboxRef.current.contains(event.target);
|
|
186
187
|
isMouseDownReported.current = false;
|
|
187
188
|
|
|
188
189
|
if (notInContainer && notInList) {
|
|
189
|
-
setMatchingText(
|
|
190
|
+
setMatchingText(valueToUse, true);
|
|
190
191
|
setOpen(false);
|
|
191
192
|
}
|
|
192
|
-
}, [setMatchingText,
|
|
193
|
+
}, [setMatchingText, valueToUse]);
|
|
193
194
|
(0, _react.useEffect)(() => {
|
|
194
195
|
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";
|
|
195
196
|
const onChangeMissingMessage = "onChange prop required when using a controlled input element";
|
|
@@ -433,7 +434,8 @@ const FilterableSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
433
434
|
multiColumn: multiColumn,
|
|
434
435
|
loaderDataRole: "filterable-select-list-loader",
|
|
435
436
|
listPlacement: listPlacement,
|
|
436
|
-
flipEnabled: flipEnabled
|
|
437
|
+
flipEnabled: flipEnabled,
|
|
438
|
+
isOpen: isOpen
|
|
437
439
|
}, children);
|
|
438
440
|
|
|
439
441
|
return /*#__PURE__*/_react.default.createElement(_select.default, _extends({
|
|
@@ -450,11 +452,11 @@ const FilterableSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
450
452
|
}, /*#__PURE__*/_react.default.createElement(_selectTextbox.default, _extends({
|
|
451
453
|
activeDescendantId: activeDescendantId,
|
|
452
454
|
labelId: label ? labelId.current : undefined,
|
|
453
|
-
"aria-controls":
|
|
455
|
+
"aria-controls": selectListId.current,
|
|
454
456
|
isOpen: isOpen,
|
|
455
457
|
hasTextCursor: true,
|
|
456
458
|
textboxRef: textboxRef
|
|
457
|
-
}, getTextboxProps()))),
|
|
459
|
+
}, getTextboxProps()))), selectList);
|
|
458
460
|
});
|
|
459
461
|
|
|
460
462
|
FilterableSelect.propTypes = { ..._selectTextbox.formInputPropTypes,
|
|
@@ -453,7 +453,8 @@ const MultiSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
453
453
|
listPlacement: listPlacement,
|
|
454
454
|
flipEnabled: flipEnabled,
|
|
455
455
|
loaderDataRole: "multi-select-list-loader",
|
|
456
|
-
multiselectValues: actualValue
|
|
456
|
+
multiselectValues: actualValue,
|
|
457
|
+
isOpen: isOpen
|
|
457
458
|
}, children);
|
|
458
459
|
|
|
459
460
|
return /*#__PURE__*/_react.default.createElement(_multiSelect.StyledSelectMultiSelect, _extends({
|
|
@@ -473,12 +474,12 @@ const MultiSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
473
474
|
}, accessibilityLabel), /*#__PURE__*/_react.default.createElement(_selectTextbox.default, _extends({
|
|
474
475
|
accessibilityLabelId: accessibilityLabelId.current,
|
|
475
476
|
activeDescendantId: activeDescendantId,
|
|
476
|
-
"aria-controls":
|
|
477
|
+
"aria-controls": selectListId.current,
|
|
477
478
|
hasTextCursor: true,
|
|
478
479
|
isOpen: isOpen,
|
|
479
480
|
labelId: labelId.current,
|
|
480
481
|
textboxRef: textboxRef
|
|
481
|
-
}, getTextboxProps()))),
|
|
482
|
+
}, getTextboxProps()))), selectList);
|
|
482
483
|
});
|
|
483
484
|
|
|
484
485
|
MultiSelect.propTypes = { ..._selectTextbox.formInputPropTypes,
|
|
@@ -76,6 +76,7 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
76
76
|
loaderDataRole,
|
|
77
77
|
listPlacement = "bottom-start",
|
|
78
78
|
flipEnabled = true,
|
|
79
|
+
isOpen,
|
|
79
80
|
...listProps
|
|
80
81
|
}, listContainerRef) => {
|
|
81
82
|
const [currentOptionsListIndex, setCurrentOptionsListIndex] = (0, _react.useState)(-1);
|
|
@@ -91,30 +92,35 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
91
92
|
blockScroll,
|
|
92
93
|
allowScroll
|
|
93
94
|
} = (0, _useScrollBlock.default)();
|
|
95
|
+
const updateListHeight = (0, _react.useCallback)(() => {
|
|
96
|
+
if (isOpen) {
|
|
97
|
+
let newHeight = listRef.current.clientHeight;
|
|
94
98
|
|
|
95
|
-
|
|
96
|
-
|
|
99
|
+
if (listActionButtonRef.current) {
|
|
100
|
+
newHeight += listActionButtonRef.current.parentElement.clientHeight;
|
|
101
|
+
}
|
|
97
102
|
|
|
98
|
-
|
|
99
|
-
newHeight += listActionButtonRef.current.parentElement.clientHeight;
|
|
103
|
+
setListHeight(`${newHeight}px`);
|
|
100
104
|
}
|
|
101
|
-
|
|
102
|
-
setListHeight(`${newHeight}px`);
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
+
}, [isOpen]);
|
|
105
106
|
const listCallbackRef = (0, _react.useCallback)(element => {
|
|
106
107
|
listRef.current = element;
|
|
107
108
|
|
|
108
109
|
if (element) {
|
|
109
110
|
setTimeout(updateListHeight, 0);
|
|
110
111
|
}
|
|
111
|
-
}, []);
|
|
112
|
+
}, [updateListHeight]);
|
|
112
113
|
(0, _react.useEffect)(() => {
|
|
113
|
-
|
|
114
|
+
if (isOpen) {
|
|
115
|
+
blockScroll();
|
|
116
|
+
}
|
|
117
|
+
|
|
114
118
|
return () => {
|
|
115
|
-
|
|
119
|
+
if (isOpen) {
|
|
120
|
+
allowScroll();
|
|
121
|
+
}
|
|
116
122
|
};
|
|
117
|
-
}, [allowScroll, blockScroll]);
|
|
123
|
+
}, [allowScroll, blockScroll, isOpen]);
|
|
118
124
|
(0, _react.useLayoutEffect)(() => {
|
|
119
125
|
if (multiColumn) {
|
|
120
126
|
setScrollbarWidth(tableRef.current.offsetWidth - tableRef.current.clientWidth);
|
|
@@ -138,6 +144,7 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
138
144
|
selectionType: "click"
|
|
139
145
|
});
|
|
140
146
|
}, [onSelect]);
|
|
147
|
+
const childIds = (0, _react.useMemo)(() => _react.default.Children.map(children, () => (0, _guid.default)()), [children]);
|
|
141
148
|
const childrenWithListProps = (0, _react.useMemo)(() => _react.default.Children.map(children, (child, index) => {
|
|
142
149
|
if (!child || child.type !== _option.default && child.type !== _optionRow.default) {
|
|
143
150
|
return child;
|
|
@@ -145,13 +152,13 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
145
152
|
|
|
146
153
|
const newProps = {
|
|
147
154
|
index,
|
|
148
|
-
id:
|
|
155
|
+
id: childIds[index],
|
|
149
156
|
onSelect: handleSelect,
|
|
150
157
|
hidden: isLoading && _react.default.Children.count(children) === 1,
|
|
151
158
|
ref: optionRefList[index]
|
|
152
159
|
};
|
|
153
160
|
return /*#__PURE__*/_react.default.cloneElement(child, newProps);
|
|
154
|
-
}), [children, handleSelect, isLoading, optionRefList]);
|
|
161
|
+
}), [children, handleSelect, isLoading, optionRefList, childIds]);
|
|
155
162
|
const childrenList = (0, _react.useMemo)(() => _react.default.Children.toArray(childrenWithListProps), [childrenWithListProps]);
|
|
156
163
|
const lastOptionIndex = (0, _react.useMemo)(() => {
|
|
157
164
|
let lastIndex = 0;
|
|
@@ -218,6 +225,10 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
218
225
|
}
|
|
219
226
|
}, [anchorElement]);
|
|
220
227
|
const handleGlobalKeydown = (0, _react.useCallback)(event => {
|
|
228
|
+
if (!isOpen) {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
|
|
221
232
|
const {
|
|
222
233
|
key
|
|
223
234
|
} = event;
|
|
@@ -251,7 +262,7 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
251
262
|
focusOnAnchor();
|
|
252
263
|
highlightNextItem(key);
|
|
253
264
|
}
|
|
254
|
-
}, [childrenList, listActionButton, handleActionButtonTab, onSelectListClose, currentOptionsListIndex, onSelect, highlightNextItem, focusOnAnchor]);
|
|
265
|
+
}, [childrenList, listActionButton, handleActionButtonTab, onSelectListClose, currentOptionsListIndex, onSelect, highlightNextItem, focusOnAnchor, isOpen]);
|
|
255
266
|
const handleListScroll = (0, _react.useCallback)(event => {
|
|
256
267
|
const element = event.target;
|
|
257
268
|
|
|
@@ -273,7 +284,7 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
273
284
|
window.removeEventListener("resize", assignListWidth);
|
|
274
285
|
};
|
|
275
286
|
}, [assignListWidth]);
|
|
276
|
-
(0, _react.useLayoutEffect)(updateListHeight, [children]);
|
|
287
|
+
(0, _react.useLayoutEffect)(updateListHeight, [children, updateListHeight]);
|
|
277
288
|
(0, _react.useEffect)(() => {
|
|
278
289
|
const keyboardEvent = "keydown";
|
|
279
290
|
const listElement = listRef.current;
|
|
@@ -345,7 +356,7 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
345
356
|
reference: anchorRef,
|
|
346
357
|
onFirstUpdate: setPlacementCallback,
|
|
347
358
|
modifiers: popoverModifiers,
|
|
348
|
-
|
|
359
|
+
isOpen: isOpen
|
|
349
360
|
}, /*#__PURE__*/_react.default.createElement(_selectList.StyledPopoverContainer, {
|
|
350
361
|
height: listHeight,
|
|
351
362
|
width: listWidth,
|
|
@@ -428,7 +439,12 @@ SelectList.propTypes = {
|
|
|
428
439
|
listPlacement: _propTypes.default.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"]),
|
|
429
440
|
|
|
430
441
|
/** Use the opposite list placement if the set placement does not fit */
|
|
431
|
-
flipEnabled: _propTypes.default.bool
|
|
442
|
+
flipEnabled: _propTypes.default.bool,
|
|
443
|
+
|
|
444
|
+
/** @private @ignore
|
|
445
|
+
* Hides the list (with CSS display: none) if not set
|
|
446
|
+
*/
|
|
447
|
+
isOpen: _propTypes.default.bool
|
|
432
448
|
};
|
|
433
449
|
var _default = SelectList;
|
|
434
450
|
exports.default = _default;
|
|
@@ -356,7 +356,8 @@ const SimpleSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
356
356
|
multiColumn: multiColumn,
|
|
357
357
|
loaderDataRole: "simple-select-list-loader",
|
|
358
358
|
listPlacement: listPlacement,
|
|
359
|
-
flipEnabled: flipEnabled
|
|
359
|
+
flipEnabled: flipEnabled,
|
|
360
|
+
isOpen: isOpen
|
|
360
361
|
}, children);
|
|
361
362
|
|
|
362
363
|
return /*#__PURE__*/_react.default.createElement(_select.default, _extends({
|
|
@@ -370,12 +371,12 @@ const SimpleSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
370
371
|
}, (0, _utils.filterStyledSystemMarginProps)(props)), /*#__PURE__*/_react.default.createElement("div", {
|
|
371
372
|
ref: containerRef
|
|
372
373
|
}, /*#__PURE__*/_react.default.createElement(_selectTextbox.default, _extends({
|
|
373
|
-
"aria-controls":
|
|
374
|
+
"aria-controls": selectListId.current,
|
|
374
375
|
activeDescendantId: activeDescendantId,
|
|
375
376
|
labelId: labelId.current,
|
|
376
377
|
isOpen: isOpen,
|
|
377
378
|
textboxRef: textboxRef
|
|
378
|
-
}, getTextboxProps()))),
|
|
379
|
+
}, getTextboxProps()))), selectList);
|
|
379
380
|
});
|
|
380
381
|
|
|
381
382
|
SimpleSelect.propTypes = {
|