carbon-react 110.3.0 → 110.5.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/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__/utils/helpers/tags/index.d.ts +1 -0
- 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/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/search/search.component.js +28 -2
- package/esm/components/search/search.d.ts +3 -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/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__/utils/helpers/tags/index.d.ts +1 -0
- 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/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/search/search.component.js +28 -2
- package/lib/components/search/search.d.ts +3 -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/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/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/i18n-provider/i18n-provider.d.ts +0 -11
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import merge from "lodash/merge";
|
|
3
2
|
import PropTypes from "prop-types";
|
|
3
|
+
import merge from "lodash/merge";
|
|
4
4
|
import Context from "../../__internal__/i18n-context";
|
|
5
5
|
import enGB from "../../locales/en-gb";
|
|
6
6
|
|
|
@@ -9,87 +9,107 @@ const I18nProvider = ({
|
|
|
9
9
|
children
|
|
10
10
|
}) => locale ? /*#__PURE__*/React.createElement(Context.Provider, {
|
|
11
11
|
value: merge({}, enGB, locale)
|
|
12
|
-
}, children) : children;
|
|
12
|
+
}, children) : /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
13
13
|
|
|
14
|
-
I18nProvider.defaultProps = {
|
|
15
|
-
locale: undefined
|
|
16
|
-
};
|
|
17
14
|
I18nProvider.propTypes = {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
})
|
|
88
|
-
}),
|
|
89
|
-
|
|
90
|
-
|
|
15
|
+
"children": PropTypes.node,
|
|
16
|
+
"locale": PropTypes.shape({
|
|
17
|
+
"actionPopover": PropTypes.shape({
|
|
18
|
+
"ariaLabel": PropTypes.func.isRequired
|
|
19
|
+
}),
|
|
20
|
+
"actions": PropTypes.shape({
|
|
21
|
+
"delete": PropTypes.func.isRequired,
|
|
22
|
+
"edit": PropTypes.func.isRequired
|
|
23
|
+
}),
|
|
24
|
+
"batchSelection": PropTypes.shape({
|
|
25
|
+
"selected": PropTypes.func.isRequired
|
|
26
|
+
}),
|
|
27
|
+
"confirm": PropTypes.shape({
|
|
28
|
+
"no": PropTypes.func.isRequired,
|
|
29
|
+
"yes": PropTypes.func.isRequired
|
|
30
|
+
}),
|
|
31
|
+
"date": PropTypes.shape({
|
|
32
|
+
"dateFnsLocale": PropTypes.func.isRequired
|
|
33
|
+
}),
|
|
34
|
+
"dialog": PropTypes.shape({
|
|
35
|
+
"ariaLabels": PropTypes.shape({
|
|
36
|
+
"close": PropTypes.func.isRequired
|
|
37
|
+
}).isRequired
|
|
38
|
+
}),
|
|
39
|
+
"dialogFullScreen": PropTypes.shape({
|
|
40
|
+
"ariaLabels": PropTypes.shape({
|
|
41
|
+
"close": PropTypes.func.isRequired
|
|
42
|
+
}).isRequired
|
|
43
|
+
}),
|
|
44
|
+
"errors": PropTypes.shape({
|
|
45
|
+
"messages": PropTypes.shape({
|
|
46
|
+
"formSummary": PropTypes.func.isRequired
|
|
47
|
+
}).isRequired
|
|
48
|
+
}),
|
|
49
|
+
"heading": PropTypes.shape({
|
|
50
|
+
"backLinkAriaLabel": PropTypes.func.isRequired
|
|
51
|
+
}),
|
|
52
|
+
"link": PropTypes.shape({
|
|
53
|
+
"skipLinkLabel": PropTypes.func.isRequired
|
|
54
|
+
}),
|
|
55
|
+
"locale": PropTypes.func,
|
|
56
|
+
"message": PropTypes.shape({
|
|
57
|
+
"closeButtonAriaLabel": PropTypes.func.isRequired
|
|
58
|
+
}),
|
|
59
|
+
"numeralDate": PropTypes.shape({
|
|
60
|
+
"validation": PropTypes.shape({
|
|
61
|
+
"day": PropTypes.func.isRequired,
|
|
62
|
+
"month": PropTypes.func.isRequired,
|
|
63
|
+
"year": PropTypes.func.isRequired
|
|
64
|
+
}).isRequired
|
|
65
|
+
}),
|
|
66
|
+
"pager": PropTypes.shape({
|
|
67
|
+
"first": PropTypes.func.isRequired,
|
|
68
|
+
"last": PropTypes.func.isRequired,
|
|
69
|
+
"next": PropTypes.func.isRequired,
|
|
70
|
+
"ofY": PropTypes.func.isRequired,
|
|
71
|
+
"pageX": PropTypes.func.isRequired,
|
|
72
|
+
"previous": PropTypes.func.isRequired,
|
|
73
|
+
"records": PropTypes.func.isRequired,
|
|
74
|
+
"show": PropTypes.func.isRequired
|
|
75
|
+
}),
|
|
76
|
+
"select": PropTypes.shape({
|
|
77
|
+
"actionButtonText": PropTypes.func.isRequired,
|
|
78
|
+
"noResultsForTerm": PropTypes.func.isRequired,
|
|
79
|
+
"placeholder": PropTypes.func.isRequired
|
|
80
|
+
}),
|
|
81
|
+
"sidebar": PropTypes.shape({
|
|
82
|
+
"ariaLabels": PropTypes.shape({
|
|
83
|
+
"close": PropTypes.func.isRequired
|
|
84
|
+
}).isRequired
|
|
85
|
+
}),
|
|
86
|
+
"switch": PropTypes.shape({
|
|
87
|
+
"off": PropTypes.func.isRequired,
|
|
88
|
+
"on": PropTypes.func.isRequired
|
|
89
|
+
}),
|
|
90
|
+
"textEditor": PropTypes.shape({
|
|
91
|
+
"ariaLabels": PropTypes.shape({
|
|
92
|
+
"bold": PropTypes.func.isRequired,
|
|
93
|
+
"bulletList": PropTypes.func.isRequired,
|
|
94
|
+
"italic": PropTypes.func.isRequired,
|
|
95
|
+
"numberList": PropTypes.func.isRequired
|
|
96
|
+
}).isRequired,
|
|
97
|
+
"tooltipMessages": PropTypes.shape({
|
|
98
|
+
"bold": PropTypes.func.isRequired,
|
|
99
|
+
"bulletList": PropTypes.func.isRequired,
|
|
100
|
+
"italic": PropTypes.func.isRequired,
|
|
101
|
+
"numberList": PropTypes.func.isRequired
|
|
102
|
+
}).isRequired
|
|
103
|
+
}),
|
|
104
|
+
"tileSelect": PropTypes.shape({
|
|
105
|
+
"deselect": PropTypes.func.isRequired
|
|
106
|
+
}),
|
|
107
|
+
"toast": PropTypes.shape({
|
|
108
|
+
"ariaLabels": PropTypes.shape({
|
|
109
|
+
"close": PropTypes.func.isRequired
|
|
110
|
+
}).isRequired
|
|
91
111
|
})
|
|
92
|
-
})
|
|
93
|
-
children: PropTypes.node.isRequired
|
|
112
|
+
})
|
|
94
113
|
};
|
|
114
|
+
export { I18nProvider };
|
|
95
115
|
export default I18nProvider;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { default } from "./i18n-provider";
|
|
1
|
+
export { default } from "./i18n-provider.component";
|
|
2
|
+
export type { I18nProviderProps } from "./i18n-provider.component";
|
|
@@ -30,6 +30,10 @@ const Search = ({
|
|
|
30
30
|
"aria-label": ariaLabel = "search",
|
|
31
31
|
inputRef,
|
|
32
32
|
tabIndex,
|
|
33
|
+
error,
|
|
34
|
+
warning,
|
|
35
|
+
info,
|
|
36
|
+
tooltipPosition,
|
|
33
37
|
...rest
|
|
34
38
|
}) => {
|
|
35
39
|
const isControlled = value !== undefined;
|
|
@@ -159,7 +163,11 @@ const Search = ({
|
|
|
159
163
|
onChange: handleChange,
|
|
160
164
|
onKeyDown: handleKeyDown,
|
|
161
165
|
inputRef: assignInput,
|
|
162
|
-
tabIndex: tabIndex
|
|
166
|
+
tabIndex: tabIndex,
|
|
167
|
+
error: error,
|
|
168
|
+
warning: warning,
|
|
169
|
+
info: info,
|
|
170
|
+
tooltipPosition: tooltipPosition
|
|
163
171
|
}), searchButton && /*#__PURE__*/React.createElement(StyledSearchButton, null, Boolean(isFocused || (!isControlled ? searchValue.length : value.length)) && /*#__PURE__*/React.createElement(Button, _extends({
|
|
164
172
|
tabIndex: iconTabIndex,
|
|
165
173
|
size: "medium",
|
|
@@ -238,6 +246,24 @@ Search.propTypes = {
|
|
|
238
246
|
}),
|
|
239
247
|
|
|
240
248
|
/** Input tabindex */
|
|
241
|
-
tabIndex: PropTypes.number
|
|
249
|
+
tabIndex: PropTypes.number,
|
|
250
|
+
|
|
251
|
+
/** Indicate that error has occurred
|
|
252
|
+
Pass string to display icon, tooltip and red border
|
|
253
|
+
Pass true boolean to only display red border */
|
|
254
|
+
error: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
|
|
255
|
+
|
|
256
|
+
/** Indicate that warning has occurred
|
|
257
|
+
Pass string to display icon, tooltip and orange border
|
|
258
|
+
Pass true boolean to only display orange border */
|
|
259
|
+
warning: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
|
|
260
|
+
|
|
261
|
+
/** Indicate additional information
|
|
262
|
+
Pass string to display icon, tooltip and blue border
|
|
263
|
+
Pass true boolean to only display blue border */
|
|
264
|
+
info: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
|
|
265
|
+
|
|
266
|
+
/** Overrides the default tooltip position */
|
|
267
|
+
tooltipPosition: PropTypes.oneOf(["top", "bottom", "left", "right"])
|
|
242
268
|
};
|
|
243
269
|
export default Search;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { MarginProps } from "styled-system";
|
|
3
3
|
|
|
4
|
-
export interface SearchProps extends MarginProps {
|
|
4
|
+
export interface SearchProps extends ValidationProps, MarginProps {
|
|
5
5
|
/** Prop to specify the aria-label of the search component */
|
|
6
6
|
"aria-label"?: string;
|
|
7
7
|
/** Prop for `uncontrolled` use */
|
|
@@ -42,6 +42,8 @@ export interface SearchProps extends MarginProps {
|
|
|
42
42
|
inputRef?: React.RefObject<HTMLInputElement>;
|
|
43
43
|
/** Input tabindex */
|
|
44
44
|
tabIndex?: number;
|
|
45
|
+
/** Overrides the default tooltip position */
|
|
46
|
+
tooltipPosition?: "top" | "bottom" | "left" | "right";
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
declare function Search(props: SearchProps): JSX.Element;
|
|
@@ -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 */
|
|
@@ -13,6 +13,7 @@ export interface PopoverProps {
|
|
|
13
13
|
onFirstUpdate?: (state: Partial<State>) => void;
|
|
14
14
|
disablePortal?: boolean;
|
|
15
15
|
reference: React.RefObject<HTMLElement>;
|
|
16
|
+
isOpen?: boolean;
|
|
16
17
|
}
|
|
17
|
-
declare const Popover: ({ children, placement, disablePortal, reference, onFirstUpdate, modifiers, disableBackgroundUI, }: PopoverProps) => JSX.Element;
|
|
18
|
+
declare const Popover: ({ children, placement, disablePortal, reference, onFirstUpdate, modifiers, disableBackgroundUI, isOpen, }: PopoverProps) => JSX.Element;
|
|
18
19
|
export default Popover;
|
|
@@ -15,7 +15,7 @@ var _core = require("@popperjs/core");
|
|
|
15
15
|
|
|
16
16
|
var _useResizeObserver = _interopRequireDefault(require("../../hooks/__internal__/useResizeObserver"));
|
|
17
17
|
|
|
18
|
-
var _popover =
|
|
18
|
+
var _popover = require("./popover.style");
|
|
19
19
|
|
|
20
20
|
var _carbonScopedTokensProvider = _interopRequireDefault(require("../../style/design-tokens/carbon-scoped-tokens-provider/carbon-scoped-tokens-provider.component"));
|
|
21
21
|
|
|
@@ -34,12 +34,12 @@ const Popover = ({
|
|
|
34
34
|
reference,
|
|
35
35
|
onFirstUpdate,
|
|
36
36
|
modifiers,
|
|
37
|
-
disableBackgroundUI
|
|
37
|
+
disableBackgroundUI,
|
|
38
|
+
isOpen = true
|
|
38
39
|
}) => {
|
|
39
40
|
var _reference$current;
|
|
40
41
|
|
|
41
|
-
const elementDOM = (0, _react.useRef)(null);
|
|
42
|
-
|
|
42
|
+
const elementDOM = (0, _react.useRef)(null);
|
|
43
43
|
const {
|
|
44
44
|
isInModal
|
|
45
45
|
} = (0, _react.useContext)(_modal.ModalContext);
|
|
@@ -73,6 +73,13 @@ const Popover = ({
|
|
|
73
73
|
|
|
74
74
|
popperInstance === null || popperInstance === void 0 ? void 0 : (_popperInstance$curre = popperInstance.current) === null || _popperInstance$curre === void 0 ? void 0 : _popperInstance$curre.update();
|
|
75
75
|
});
|
|
76
|
+
(0, _react.useEffect)(() => {
|
|
77
|
+
if (isOpen) {
|
|
78
|
+
var _popperInstance$curre2;
|
|
79
|
+
|
|
80
|
+
popperInstance === null || popperInstance === void 0 ? void 0 : (_popperInstance$curre2 = popperInstance.current) === null || _popperInstance$curre2 === void 0 ? void 0 : _popperInstance$curre2.update();
|
|
81
|
+
}
|
|
82
|
+
}, [isOpen]);
|
|
76
83
|
(0, _react.useLayoutEffect)(() => {
|
|
77
84
|
if (reference.current) {
|
|
78
85
|
popperInstance.current = (0, _core.createPopper)(reference.current, popperElementRef.current, {
|
|
@@ -103,9 +110,12 @@ const Popover = ({
|
|
|
103
110
|
}
|
|
104
111
|
};
|
|
105
112
|
}, [disablePortal, mountNode]);
|
|
113
|
+
content = /*#__PURE__*/_react.default.createElement(_popover.StyledPopoverContent, {
|
|
114
|
+
isOpen: isOpen
|
|
115
|
+
}, content);
|
|
106
116
|
|
|
107
117
|
if (disableBackgroundUI) {
|
|
108
|
-
content = /*#__PURE__*/_react.default.createElement(_popover.
|
|
118
|
+
content = /*#__PURE__*/_react.default.createElement(_popover.StyledBackdrop, null, content);
|
|
109
119
|
}
|
|
110
120
|
|
|
111
121
|
if (disablePortal) {
|
|
@@ -119,6 +129,7 @@ Popover.propTypes = {
|
|
|
119
129
|
"children": _propTypes.default.element.isRequired,
|
|
120
130
|
"disableBackgroundUI": _propTypes.default.bool,
|
|
121
131
|
"disablePortal": _propTypes.default.bool,
|
|
132
|
+
"isOpen": _propTypes.default.bool,
|
|
122
133
|
"modifiers": _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
123
134
|
"enabled": _propTypes.default.bool,
|
|
124
135
|
"name": _propTypes.default.string.isRequired,
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
declare const StyledBackdrop: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
|
-
|
|
1
|
+
export declare const StyledBackdrop: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
|
+
declare type StyledPopoverContentProps = {
|
|
3
|
+
isOpen?: boolean;
|
|
4
|
+
};
|
|
5
|
+
export declare const StyledPopoverContent: import("styled-components").StyledComponent<"div", any, StyledPopoverContentProps, never>;
|
|
6
|
+
export {};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.StyledPopoverContent = exports.StyledBackdrop = void 0;
|
|
7
7
|
|
|
8
8
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
9
|
|
|
@@ -22,8 +22,13 @@ const StyledBackdrop = _styledComponents.default.div`
|
|
|
22
22
|
}) => theme.zIndex.popover};
|
|
23
23
|
background: transparent;
|
|
24
24
|
`;
|
|
25
|
+
exports.StyledBackdrop = StyledBackdrop;
|
|
25
26
|
StyledBackdrop.defaultProps = {
|
|
26
27
|
theme: _base.default
|
|
27
28
|
};
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
const StyledPopoverContent = _styledComponents.default.div`
|
|
30
|
+
${({
|
|
31
|
+
isOpen
|
|
32
|
+
}) => !isOpen && "display: none;"}
|
|
33
|
+
`;
|
|
34
|
+
exports.StyledPopoverContent = StyledPopoverContent;
|
|
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
Object.defineProperty(exports, "default", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: function () {
|
|
9
|
-
return
|
|
9
|
+
return _radioButtonMapper.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _radioButtonMapper = _interopRequireDefault(require("./radio-button-mapper.component"));
|
|
14
14
|
|
|
15
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
export interface RadioButtonMapperProps {
|
|
4
|
+
/** The RadioButton objects to be rendered in the group */
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
/** Specifies the name prop to be applied to each button in the group */
|
|
7
|
+
name: string;
|
|
8
|
+
/** Callback fired when each RadioButton is blurred */
|
|
9
|
+
onBlur?: (ev: React.FocusEvent<HTMLInputElement>) => void;
|
|
10
|
+
/** Callback fired when the user selects a RadioButton */
|
|
11
|
+
onChange?: (ev: React.ChangeEvent<HTMLInputElement>) => void;
|
|
12
|
+
/** Callback fired on key down */
|
|
13
|
+
onKeyDown?: (ev: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
14
|
+
/** Value of the selected RadioButton */
|
|
15
|
+
value?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
declare function RadioButtonMapper(props?: RadioButtonMapperProps): JSX.Element;
|
|
19
|
+
RadioButtonMapper.displayName = "RadioButtonMapper";
|
|
20
|
+
|
|
21
|
+
export default RadioButtonMapper;
|