carbon-react 126.9.1 → 126.10.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/LICENSE CHANGED
@@ -2,180 +2,180 @@
2
2
  Version 2.0, January 2004
3
3
  http://www.apache.org/licenses/
4
4
 
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
179
 
180
180
  To apply the Apache License to your work, attach the following
181
181
  boilerplate notice, with the fields enclosed by brackets "{}"
@@ -186,16 +186,16 @@
186
186
  same "printed page" as the copyright notice for easier
187
187
  identification within third-party archives.
188
188
 
189
- Copyright 2016-2023 Sage (UK) Ltd
189
+ Copyright 2016-2024 Sage (UK) Ltd
190
190
 
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
194
 
195
195
  http://www.apache.org/licenses/LICENSE-2.0
196
196
 
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -51,4 +51,4 @@ Thanks to [Chromatic](https://www.chromatic.com/) for providing the visual testi
51
51
 
52
52
  Carbon is licensed under the [Apache-2.0 licence](LICENSE).
53
53
 
54
- Copyright (c) 2018-2022 Sage Group Plc. All rights reserved.
54
+ Copyright (c) 2018-2024 Sage Group Plc. All rights reserved.
@@ -114,7 +114,9 @@ export const ActionPopoverItem = ({
114
114
  // focuses item on opening of actionPopover submenu
115
115
  useEffect(() => {
116
116
  if (focusItem) {
117
- ref.current?.focus();
117
+ ref.current?.focus({
118
+ preventScroll: true
119
+ });
118
120
  }
119
121
  }, [focusItem]);
120
122
  useEffect(() => {
@@ -12,6 +12,10 @@ export interface ButtonProps extends SpaceProps, TagProps {
12
12
  * Defaults to the iconType, when the component has only an icon
13
13
  */
14
14
  "aria-label"?: string;
15
+ /** Identifies the element(s) labelling the button. */
16
+ "aria-labelledby"?: string;
17
+ /** Identifies the element(s) offering additional information about the button the user might require. */
18
+ "aria-describedby"?: string;
15
19
  /** Color variants for new business themes: "primary" | "secondary" | "tertiary" | "darkBackground" */
16
20
  buttonType?: ButtonTypes;
17
21
  /** The text the button displays */
@@ -60,26 +60,28 @@ function renderChildren({
60
60
  let deprecatedForwardRefWarnTriggered = false;
61
61
  let deprecatedDashedButtonWarnTriggered = false;
62
62
  const Button = /*#__PURE__*/React.forwardRef(({
63
- size: sizeProp = "medium",
64
- subtext = "",
65
- children,
66
- forwardRef,
63
+ "aria-describedby": ariaDescribedBy,
67
64
  "aria-label": ariaLabel,
68
- disabled = false,
69
- destructive = false,
65
+ "aria-labelledby": ariaLabelledBy,
70
66
  buttonType: buttonTypeProp = "secondary",
71
- iconType,
72
- iconPosition: iconPositionProp = "before",
67
+ children,
68
+ destructive = false,
69
+ disabled = false,
70
+ forwardRef,
71
+ fullWidth: fullWidthProp = false,
73
72
  href,
74
- m = 0,
75
- px,
76
- noWrap,
77
- target,
78
- rel,
73
+ iconPosition: iconPositionProp = "before",
79
74
  iconTooltipMessage,
80
75
  iconTooltipPosition,
81
- fullWidth: fullWidthProp = false,
76
+ iconType,
77
+ m = 0,
78
+ noWrap,
82
79
  onClick,
80
+ px,
81
+ rel,
82
+ size: sizeProp = "medium",
83
+ subtext = "",
84
+ target,
83
85
  ...rest
84
86
  }, ref) => {
85
87
  const {
@@ -137,6 +139,8 @@ const Button = /*#__PURE__*/React.forwardRef(({
137
139
  const isValidChildren = children !== undefined && children !== false;
138
140
  return /*#__PURE__*/React.createElement(StyledButton, _extends({
139
141
  "aria-label": !isValidChildren && iconType ? ariaLabel || iconType : ariaLabel,
142
+ "aria-labelledby": ariaLabelledBy,
143
+ "aria-describedby": ariaDescribedBy,
140
144
  as: !disabled && href ? "a" : "button",
141
145
  onKeyDown: href ? handleLinkKeyDown : undefined,
142
146
  onClick: inSplitButton ? onChildButtonClick?.(onClick) : onClick,
@@ -174,7 +178,9 @@ const Button = /*#__PURE__*/React.forwardRef(({
174
178
  }));
175
179
  });
176
180
  Button.propTypes = {
181
+ "aria-describedby": PropTypes.string,
177
182
  "aria-label": PropTypes.string,
183
+ "aria-labelledby": PropTypes.string,
178
184
  "buttonType": PropTypes.oneOf(["darkBackground", "dashed", "gradient-grey", "gradient-white", "primary", "secondary", "tertiary"]),
179
185
  "children": PropTypes.node,
180
186
  "data-component": PropTypes.string,
@@ -524,7 +530,9 @@ const ButtonWithForwardRef = /*#__PURE__*/React.forwardRef((props, ref) => {
524
530
  }, props));
525
531
  });
526
532
  ButtonWithForwardRef.propTypes = {
533
+ "aria-describedby": PropTypes.string,
527
534
  "aria-label": PropTypes.string,
535
+ "aria-labelledby": PropTypes.string,
528
536
  "buttonType": PropTypes.oneOf(["darkBackground", "dashed", "gradient-grey", "gradient-white", "primary", "secondary", "tertiary"]),
529
537
  "children": PropTypes.node,
530
538
  "data-component": PropTypes.string,
@@ -12,7 +12,7 @@ export interface ButtonToggleGroupProps extends MarginProps, TagProps {
12
12
  id: string;
13
13
  /** Specifies the name prop to be applied to each button in the group */
14
14
  name?: string;
15
- /** Togglable buttons to be rendered. Only accepts children of type ButtonToggle */
15
+ /** Toggle buttons to be rendered. Only accepts children of type ButtonToggle */
16
16
  children?: React.ReactNode;
17
17
  /** aria-label for the group wrapper. Required for accessibility when no text label is provided */
18
18
  "aria-label"?: string;
@@ -32,7 +32,7 @@ export interface ButtonToggleGroupProps extends MarginProps, TagProps {
32
32
  fieldHelpInline?: boolean;
33
33
  /** [Legacy] Sets the label to be inline. */
34
34
  labelInline?: boolean;
35
- /** The percentage width of the label. */
35
+ /** [Legacy] The percentage width of the label. */
36
36
  labelWidth?: number;
37
37
  /** If true all ButtonToggle children will flex to the full width of the ButtonToggleGroup parent */
38
38
  fullWidth?: boolean;
@@ -63,6 +63,8 @@ declare type ButtonToggleGroupContextType = {
63
63
  isDisabled?: boolean;
64
64
  firstButton?: HTMLButtonElement;
65
65
  childButtonCallbackRef?: (button: HTMLButtonElement | null) => void;
66
+ /** Identifier for the hint text, if it exists, that is rendered by ButtonToggleGroup */
67
+ hintTextId?: string;
66
68
  };
67
69
  export declare const ButtonToggleGroupContext: React.Context<ButtonToggleGroupContextType>;
68
70
  declare const ButtonToggleGroup: {
@@ -56,6 +56,7 @@ const ButtonToggleGroup = ({
56
56
  }, [children]);
57
57
  !hasCorrectItemStructure ? process.env.NODE_ENV !== "production" ? invariant(false, `\`ButtonToggleGroup\` only accepts children of type \`${ButtonToggle.displayName}\``) : invariant(false) : void 0;
58
58
  const labelId = useRef(guid());
59
+ const hintTextId = useRef(guid());
59
60
  const wrapperRef = useRef(null);
60
61
  const [pressedButtonValue, setPressedButtonValue] = useState();
61
62
  if (name && !deprecateNameWarnTriggered) {
@@ -121,7 +122,7 @@ const ButtonToggleGroup = ({
121
122
  }, /*#__PURE__*/React.createElement(InputGroupBehaviour, null, /*#__PURE__*/React.createElement(FormField, _extends({
122
123
  label: label,
123
124
  labelHelp: computeLabelPropValues(labelHelp),
124
- labelSpacing: labelSpacing,
125
+ labelSpacing: computeLabelPropValues(labelSpacing),
125
126
  fieldHelp: computeLabelPropValues(fieldHelp),
126
127
  fieldHelpInline: computeLabelPropValues(fieldHelpInline),
127
128
  labelInline: computeLabelPropValues(labelInline),
@@ -144,9 +145,11 @@ const ButtonToggleGroup = ({
144
145
  isInGroup: true,
145
146
  isDisabled: disabled,
146
147
  firstButton,
147
- childButtonCallbackRef
148
+ childButtonCallbackRef,
149
+ hintTextId: inputHint ? hintTextId.current : undefined
148
150
  }
149
151
  }, inputHint && /*#__PURE__*/React.createElement(StyledHintText, {
152
+ id: hintTextId.current,
150
153
  isDisabled: disabled
151
154
  }, inputHint), /*#__PURE__*/React.createElement(StyledButtonToggleGroupWrapper, {
152
155
  labelInline: labelInline,
@@ -64,7 +64,8 @@ export const ButtonToggle = ({
64
64
  isInGroup,
65
65
  isDisabled,
66
66
  firstButton,
67
- childButtonCallbackRef
67
+ childButtonCallbackRef,
68
+ hintTextId
68
69
  } = useContext(ButtonToggleGroupContext);
69
70
  const callbackRef = element => {
70
71
  buttonRef.current = element;
@@ -73,15 +74,6 @@ export const ButtonToggle = ({
73
74
  }
74
75
  };
75
76
  const inputGuid = useRef(guid());
76
- let icon;
77
- if (buttonIcon) {
78
- icon = /*#__PURE__*/React.createElement(ButtonToggleIcon, {
79
- buttonIcon: buttonIcon,
80
- buttonIconSize: buttonIconSize,
81
- disabled: disabled,
82
- hasContent: !!children
83
- });
84
- }
85
77
  function handleClick(ev) {
86
78
  if (onClick) {
87
79
  onClick(ev);
@@ -131,6 +123,7 @@ export const ButtonToggle = ({
131
123
  }, /*#__PURE__*/React.createElement(StyledButtonToggle, _extends({
132
124
  "aria-label": ariaLabel,
133
125
  "aria-labelledby": ariaLabelledBy,
126
+ "aria-describedby": hintTextId || undefined,
134
127
  "aria-pressed": !!isPressed,
135
128
  buttonIcon: buttonIcon,
136
129
  buttonIconSize: buttonIconSize,
@@ -151,7 +144,12 @@ export const ButtonToggle = ({
151
144
  }, {
152
145
  allowDeselect: allowDeselect,
153
146
  ref: callbackRef
154
- }), icon, children));
147
+ }), buttonIcon && /*#__PURE__*/React.createElement(ButtonToggleIcon, {
148
+ buttonIcon: buttonIcon,
149
+ buttonIconSize: buttonIconSize,
150
+ disabled: disabled,
151
+ hasContent: !!children
152
+ }), children));
155
153
  };
156
154
  ButtonToggle.displayName = "ButtonToggle";
157
155
  export default ButtonToggle;
@@ -123,7 +123,9 @@ const ActionPopoverItem = ({
123
123
  // focuses item on opening of actionPopover submenu
124
124
  (0, _react.useEffect)(() => {
125
125
  if (focusItem) {
126
- ref.current?.focus();
126
+ ref.current?.focus({
127
+ preventScroll: true
128
+ });
127
129
  }
128
130
  }, [focusItem]);
129
131
  (0, _react.useEffect)(() => {
@@ -12,6 +12,10 @@ export interface ButtonProps extends SpaceProps, TagProps {
12
12
  * Defaults to the iconType, when the component has only an icon
13
13
  */
14
14
  "aria-label"?: string;
15
+ /** Identifies the element(s) labelling the button. */
16
+ "aria-labelledby"?: string;
17
+ /** Identifies the element(s) offering additional information about the button the user might require. */
18
+ "aria-describedby"?: string;
15
19
  /** Color variants for new business themes: "primary" | "secondary" | "tertiary" | "darkBackground" */
16
20
  buttonType?: ButtonTypes;
17
21
  /** The text the button displays */
@@ -69,26 +69,28 @@ function renderChildren({
69
69
  let deprecatedForwardRefWarnTriggered = false;
70
70
  let deprecatedDashedButtonWarnTriggered = false;
71
71
  const Button = /*#__PURE__*/_react.default.forwardRef(({
72
- size: sizeProp = "medium",
73
- subtext = "",
74
- children,
75
- forwardRef,
72
+ "aria-describedby": ariaDescribedBy,
76
73
  "aria-label": ariaLabel,
77
- disabled = false,
78
- destructive = false,
74
+ "aria-labelledby": ariaLabelledBy,
79
75
  buttonType: buttonTypeProp = "secondary",
80
- iconType,
81
- iconPosition: iconPositionProp = "before",
76
+ children,
77
+ destructive = false,
78
+ disabled = false,
79
+ forwardRef,
80
+ fullWidth: fullWidthProp = false,
82
81
  href,
83
- m = 0,
84
- px,
85
- noWrap,
86
- target,
87
- rel,
82
+ iconPosition: iconPositionProp = "before",
88
83
  iconTooltipMessage,
89
84
  iconTooltipPosition,
90
- fullWidth: fullWidthProp = false,
85
+ iconType,
86
+ m = 0,
87
+ noWrap,
91
88
  onClick,
89
+ px,
90
+ rel,
91
+ size: sizeProp = "medium",
92
+ subtext = "",
93
+ target,
92
94
  ...rest
93
95
  }, ref) => {
94
96
  const {
@@ -146,6 +148,8 @@ const Button = /*#__PURE__*/_react.default.forwardRef(({
146
148
  const isValidChildren = children !== undefined && children !== false;
147
149
  return /*#__PURE__*/_react.default.createElement(_button.default, _extends({
148
150
  "aria-label": !isValidChildren && iconType ? ariaLabel || iconType : ariaLabel,
151
+ "aria-labelledby": ariaLabelledBy,
152
+ "aria-describedby": ariaDescribedBy,
149
153
  as: !disabled && href ? "a" : "button",
150
154
  onKeyDown: href ? handleLinkKeyDown : undefined,
151
155
  onClick: inSplitButton ? onChildButtonClick?.(onClick) : onClick,
@@ -183,7 +187,9 @@ const Button = /*#__PURE__*/_react.default.forwardRef(({
183
187
  }));
184
188
  });
185
189
  Button.propTypes = {
190
+ "aria-describedby": _propTypes.default.string,
186
191
  "aria-label": _propTypes.default.string,
192
+ "aria-labelledby": _propTypes.default.string,
187
193
  "buttonType": _propTypes.default.oneOf(["darkBackground", "dashed", "gradient-grey", "gradient-white", "primary", "secondary", "tertiary"]),
188
194
  "children": _propTypes.default.node,
189
195
  "data-component": _propTypes.default.string,
@@ -533,7 +539,9 @@ const ButtonWithForwardRef = exports.ButtonWithForwardRef = /*#__PURE__*/_react.
533
539
  }, props));
534
540
  });
535
541
  ButtonWithForwardRef.propTypes = {
542
+ "aria-describedby": _propTypes.default.string,
536
543
  "aria-label": _propTypes.default.string,
544
+ "aria-labelledby": _propTypes.default.string,
537
545
  "buttonType": _propTypes.default.oneOf(["darkBackground", "dashed", "gradient-grey", "gradient-white", "primary", "secondary", "tertiary"]),
538
546
  "children": _propTypes.default.node,
539
547
  "data-component": _propTypes.default.string,
@@ -12,7 +12,7 @@ export interface ButtonToggleGroupProps extends MarginProps, TagProps {
12
12
  id: string;
13
13
  /** Specifies the name prop to be applied to each button in the group */
14
14
  name?: string;
15
- /** Togglable buttons to be rendered. Only accepts children of type ButtonToggle */
15
+ /** Toggle buttons to be rendered. Only accepts children of type ButtonToggle */
16
16
  children?: React.ReactNode;
17
17
  /** aria-label for the group wrapper. Required for accessibility when no text label is provided */
18
18
  "aria-label"?: string;
@@ -32,7 +32,7 @@ export interface ButtonToggleGroupProps extends MarginProps, TagProps {
32
32
  fieldHelpInline?: boolean;
33
33
  /** [Legacy] Sets the label to be inline. */
34
34
  labelInline?: boolean;
35
- /** The percentage width of the label. */
35
+ /** [Legacy] The percentage width of the label. */
36
36
  labelWidth?: number;
37
37
  /** If true all ButtonToggle children will flex to the full width of the ButtonToggleGroup parent */
38
38
  fullWidth?: boolean;
@@ -63,6 +63,8 @@ declare type ButtonToggleGroupContextType = {
63
63
  isDisabled?: boolean;
64
64
  firstButton?: HTMLButtonElement;
65
65
  childButtonCallbackRef?: (button: HTMLButtonElement | null) => void;
66
+ /** Identifier for the hint text, if it exists, that is rendered by ButtonToggleGroup */
67
+ hintTextId?: string;
66
68
  };
67
69
  export declare const ButtonToggleGroupContext: React.Context<ButtonToggleGroupContextType>;
68
70
  declare const ButtonToggleGroup: {
@@ -65,6 +65,7 @@ const ButtonToggleGroup = ({
65
65
  }, [children]);
66
66
  !hasCorrectItemStructure ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, `\`ButtonToggleGroup\` only accepts children of type \`${_.ButtonToggle.displayName}\``) : (0, _invariant.default)(false) : void 0;
67
67
  const labelId = (0, _react.useRef)((0, _guid.default)());
68
+ const hintTextId = (0, _react.useRef)((0, _guid.default)());
68
69
  const wrapperRef = (0, _react.useRef)(null);
69
70
  const [pressedButtonValue, setPressedButtonValue] = (0, _react.useState)();
70
71
  if (name && !deprecateNameWarnTriggered) {
@@ -130,7 +131,7 @@ const ButtonToggleGroup = ({
130
131
  }, /*#__PURE__*/_react.default.createElement(_inputBehaviour.InputGroupBehaviour, null, /*#__PURE__*/_react.default.createElement(_formField.default, _extends({
131
132
  label: label,
132
133
  labelHelp: computeLabelPropValues(labelHelp),
133
- labelSpacing: labelSpacing,
134
+ labelSpacing: computeLabelPropValues(labelSpacing),
134
135
  fieldHelp: computeLabelPropValues(fieldHelp),
135
136
  fieldHelpInline: computeLabelPropValues(fieldHelpInline),
136
137
  labelInline: computeLabelPropValues(labelInline),
@@ -153,9 +154,11 @@ const ButtonToggleGroup = ({
153
154
  isInGroup: true,
154
155
  isDisabled: disabled,
155
156
  firstButton,
156
- childButtonCallbackRef
157
+ childButtonCallbackRef,
158
+ hintTextId: inputHint ? hintTextId.current : undefined
157
159
  }
158
160
  }, inputHint && /*#__PURE__*/_react.default.createElement(_buttonToggleGroup.StyledHintText, {
161
+ id: hintTextId.current,
159
162
  isDisabled: disabled
160
163
  }, inputHint), /*#__PURE__*/_react.default.createElement(_buttonToggleGroup.StyledButtonToggleGroupWrapper, {
161
164
  labelInline: labelInline,
@@ -73,7 +73,8 @@ const ButtonToggle = ({
73
73
  isInGroup,
74
74
  isDisabled,
75
75
  firstButton,
76
- childButtonCallbackRef
76
+ childButtonCallbackRef,
77
+ hintTextId
77
78
  } = (0, _react.useContext)(_buttonToggleGroup.ButtonToggleGroupContext);
78
79
  const callbackRef = element => {
79
80
  buttonRef.current = element;
@@ -82,15 +83,6 @@ const ButtonToggle = ({
82
83
  }
83
84
  };
84
85
  const inputGuid = (0, _react.useRef)((0, _guid.default)());
85
- let icon;
86
- if (buttonIcon) {
87
- icon = /*#__PURE__*/_react.default.createElement(_buttonToggleIcon.default, {
88
- buttonIcon: buttonIcon,
89
- buttonIconSize: buttonIconSize,
90
- disabled: disabled,
91
- hasContent: !!children
92
- });
93
- }
94
86
  function handleClick(ev) {
95
87
  if (onClick) {
96
88
  onClick(ev);
@@ -140,6 +132,7 @@ const ButtonToggle = ({
140
132
  }, /*#__PURE__*/_react.default.createElement(_buttonToggle.StyledButtonToggle, _extends({
141
133
  "aria-label": ariaLabel,
142
134
  "aria-labelledby": ariaLabelledBy,
135
+ "aria-describedby": hintTextId || undefined,
143
136
  "aria-pressed": !!isPressed,
144
137
  buttonIcon: buttonIcon,
145
138
  buttonIconSize: buttonIconSize,
@@ -160,7 +153,12 @@ const ButtonToggle = ({
160
153
  }, {
161
154
  allowDeselect: allowDeselect,
162
155
  ref: callbackRef
163
- }), icon, children));
156
+ }), buttonIcon && /*#__PURE__*/_react.default.createElement(_buttonToggleIcon.default, {
157
+ buttonIcon: buttonIcon,
158
+ buttonIconSize: buttonIconSize,
159
+ disabled: disabled,
160
+ hasContent: !!children
161
+ }), children));
164
162
  };
165
163
  exports.ButtonToggle = ButtonToggle;
166
164
  ButtonToggle.displayName = "ButtonToggle";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "126.9.1",
3
+ "version": "126.10.1",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",
@@ -106,6 +106,7 @@
106
106
  "@types/react-is": "^17.0.4",
107
107
  "@types/react-test-renderer": "^17.0.2",
108
108
  "@types/react-transition-group": "^4.4.9",
109
+ "@types/sinon": "^17.0.3",
109
110
  "@types/sprintf-js": "^1.1.4",
110
111
  "@types/styled-components": "5.1.17",
111
112
  "@types/uuid": "^8.3.4",
@@ -200,6 +201,7 @@
200
201
  "react-dnd-html5-backend": "^15.1.3",
201
202
  "react-is": "^17.0.2",
202
203
  "react-transition-group": "^4.4.5",
204
+ "sinon": "^17.0.1",
203
205
  "styled-system": "^5.1.5"
204
206
  },
205
207
  "overrides": {