@carbon/ibm-products 2.3.0 → 2.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (26) hide show
  1. package/README.md +38 -0
  2. package/es/components/APIKeyModal/APIKeyModal.js +25 -21
  3. package/es/components/ActionBar/ActionBar.js +5 -5
  4. package/es/components/CreateFullPage/CreateFullPage.js +4 -2
  5. package/es/components/CreateModal/CreateModal.docs-page.js +1 -1
  6. package/es/components/CreateModal/CreateModal.js +2 -1
  7. package/es/components/CreateSidePanel/CreateSidePanel.docs-page.js +1 -1
  8. package/es/components/CreateSidePanel/CreateSidePanel.js +6 -2
  9. package/es/components/CreateTearsheet/CreateTearsheet.js +3 -1
  10. package/es/components/CreateTearsheetNarrow/CreateTearsheetNarrow.js +6 -2
  11. package/es/components/EditSidePanel/EditSidePanel.js +6 -2
  12. package/es/components/Tearsheet/TearsheetShell.js +2 -1
  13. package/es/global/js/hooks/useResizeObserver.js +1 -1
  14. package/lib/components/APIKeyModal/APIKeyModal.js +25 -21
  15. package/lib/components/ActionBar/ActionBar.js +5 -5
  16. package/lib/components/CreateFullPage/CreateFullPage.js +4 -2
  17. package/lib/components/CreateModal/CreateModal.docs-page.js +1 -1
  18. package/lib/components/CreateModal/CreateModal.js +2 -1
  19. package/lib/components/CreateSidePanel/CreateSidePanel.docs-page.js +1 -1
  20. package/lib/components/CreateSidePanel/CreateSidePanel.js +6 -2
  21. package/lib/components/CreateTearsheet/CreateTearsheet.js +3 -1
  22. package/lib/components/CreateTearsheetNarrow/CreateTearsheetNarrow.js +6 -2
  23. package/lib/components/EditSidePanel/EditSidePanel.js +6 -2
  24. package/lib/components/Tearsheet/TearsheetShell.js +2 -1
  25. package/lib/global/js/hooks/useResizeObserver.js +1 -1
  26. package/package.json +3 -3
package/README.md CHANGED
@@ -104,6 +104,44 @@ const App = () => {
104
104
  };
105
105
  ```
106
106
 
107
+ ### Package prefix
108
+
109
+ The `@carbon/ibm-products` package uses a default prefix of `c4p` for CSS
110
+ selectors and some IDs.
111
+
112
+ #### Changing the prefix
113
+
114
+ Before any `@carbon/ibm-products` components are loaded in script or styling
115
+ ensure you have done the following.
116
+
117
+ ```js
118
+ import { pkg } from '@carbon/ibm-products/es/settings';
119
+
120
+ pkg.prefix = 'tst';
121
+ ```
122
+
123
+ When using multiple components from the library:
124
+
125
+ ```css
126
+ @use '@carbon/ibm-products/scss' with (
127
+ $pkg-prefix: 'tst'
128
+ );
129
+ ```
130
+
131
+ When using individual components e.g. AboutModal:
132
+
133
+ ```css
134
+ @use '@carbon/ibm-products/scss/config' with (
135
+ $pkg-prefix: 'tst'
136
+ );
137
+
138
+ @use '@carbon/ibm-products/scss/components/AboutModal';
139
+ ```
140
+
141
+ See the
142
+ [example gallery](https://ibm-products.carbondesignsystem.com/?path=/story/overview-examples--c-4-p-gallery-code-sandbox)
143
+ for the most up-to-date prefix examples.
144
+
107
145
  ### Enabling Canary components and flagged features
108
146
 
109
147
  Components that have not yet completed the release review process are considered
@@ -77,18 +77,22 @@ export var APIKeyModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
77
77
  previousStepButtonText = _ref.previousStepButtonText,
78
78
  showAPIKeyLabel = _ref.showAPIKeyLabel,
79
79
  rest = _objectWithoutProperties(_ref, _excluded);
80
- var _useState = useState(false),
80
+ var _useState = useState(null),
81
81
  _useState2 = _slicedToArray(_useState, 2),
82
- copyError = _useState2[0],
83
- setCopyError = _useState2[1];
84
- var _useState3 = useState(apiKeyName),
82
+ title = _useState2[0],
83
+ setTitle = _useState2[1];
84
+ var _useState3 = useState(false),
85
85
  _useState4 = _slicedToArray(_useState3, 2),
86
- name = _useState4[0],
87
- setName = _useState4[1];
88
- var _useState5 = useState(0),
86
+ copyError = _useState4[0],
87
+ setCopyError = _useState4[1];
88
+ var _useState5 = useState(apiKeyName),
89
89
  _useState6 = _slicedToArray(_useState5, 2),
90
- currentStep = _useState6[0],
91
- setCurrentStep = _useState6[1];
90
+ name = _useState6[0],
91
+ setName = _useState6[1];
92
+ var _useState7 = useState(0),
93
+ _useState8 = _slicedToArray(_useState7, 2),
94
+ currentStep = _useState8[0],
95
+ setCurrentStep = _useState8[1];
92
96
  var copyRef = useRef();
93
97
  var apiKeyInputId = useRef(uuidv4());
94
98
  var nameInputId = useRef(uuidv4());
@@ -141,18 +145,17 @@ export var APIKeyModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
141
145
  }
142
146
  return closeButtonText;
143
147
  };
144
- var getTitle = function getTitle() {
148
+ useEffect(function () {
145
149
  if (editing && editSuccess) {
146
- return editSuccessTitle;
147
- }
148
- if (apiKeyLoaded) {
149
- return generateSuccessTitle;
150
- }
151
- if (hasSteps) {
152
- return customSteps[currentStep].title;
150
+ setTitle(editSuccessTitle);
151
+ } else if (apiKeyLoaded) {
152
+ setTitle(generateSuccessTitle);
153
+ } else if (hasSteps) {
154
+ setTitle(customSteps[currentStep].title);
155
+ } else {
156
+ setTitle(generateTitle);
153
157
  }
154
- return generateTitle;
155
- };
158
+ }, [apiKeyLoaded, editing, editSuccess, editSuccessTitle, hasSteps, generateSuccessTitle, generateTitle, currentStep, customSteps]);
156
159
  var setNameHandler = function setNameHandler(evt) {
157
160
  setName(evt.target.value);
158
161
  };
@@ -235,7 +238,7 @@ export var APIKeyModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
235
238
  preventCloseOnClickOutside: true
236
239
  }), /*#__PURE__*/React.createElement(ModalHeader, {
237
240
  className: "".concat(blockClass, "__header"),
238
- title: getTitle(),
241
+ title: title,
239
242
  label: modalLabel
240
243
  }), /*#__PURE__*/React.createElement(ModalBody, {
241
244
  className: "".concat(blockClass, "__body-container")
@@ -253,7 +256,8 @@ export var APIKeyModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
253
256
  labelText: apiKeyLabel,
254
257
  id: apiKeyInputId.current
255
258
  }), (editing || !apiKeyLoaded && nameRequired) && /*#__PURE__*/React.createElement(Form, {
256
- onSubmit: submitHandler
259
+ onSubmit: submitHandler,
260
+ "aria-label": title
257
261
  }, /*#__PURE__*/React.createElement(TextInput, {
258
262
  helperText: nameHelperText,
259
263
  placeholder: namePlaceholder,
@@ -74,13 +74,12 @@ export var ActionBar = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
74
74
  className: "".concat(blockClass, "__hidden-sizing-items"),
75
75
  "aria-hidden": true,
76
76
  ref: sizingRef
77
- }, /*#__PURE__*/React.createElement("span", {
78
- "aria-hidden": false
79
- }, /*#__PURE__*/React.createElement(ActionBarOverflowItems, {
77
+ }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(ActionBarOverflowItems, {
80
78
  className: "".concat(blockClass, "__hidden-sizing-item"),
81
79
  overflowAriaLabel: "hidden sizing overflow items",
82
80
  overflowItems: [],
83
- key: "hidden-overflow-menu"
81
+ key: "hidden-overflow-menu",
82
+ tabIndex: -1
84
83
  }), actions.map(function (_ref2) {
85
84
  var key = _ref2.key,
86
85
  id = _ref2.id,
@@ -89,7 +88,8 @@ export var ActionBar = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
89
88
  // ensure id is not duplicated
90
89
  "data-original-id": id,
91
90
  key: "hidden-item-".concat(key),
92
- className: "".concat(blockClass, "__hidden-sizing-item")
91
+ className: "".concat(blockClass, "__hidden-sizing-item"),
92
+ tabIndex: -1
93
93
  }));
94
94
  }))));
95
95
  }, [actions]);
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- var _excluded = ["backButtonText", "cancelButtonText", "children", "className", "modalDangerButtonText", "modalDescription", "modalSecondaryButtonText", "modalTitle", "nextButtonText", "onClose", "onRequestSubmit", "firstFocusElement", "submitButtonText"];
4
+ var _excluded = ["backButtonText", "cancelButtonText", "children", "className", "modalDangerButtonText", "modalDescription", "modalSecondaryButtonText", "modalTitle", "nextButtonText", "onClose", "onRequestSubmit", "firstFocusElement", "submitButtonText", "title"];
5
5
  /**
6
6
  * Copyright IBM Corp. 2021, 2023
7
7
  *
@@ -62,6 +62,7 @@ export var CreateFullPage = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
62
62
  onRequestSubmit = _ref.onRequestSubmit,
63
63
  firstFocusElement = _ref.firstFocusElement,
64
64
  submitButtonText = _ref.submitButtonText,
65
+ title = _ref.title,
65
66
  rest = _objectWithoutProperties(_ref, _excluded);
66
67
  var _useState = useState([]),
67
68
  _useState2 = _slicedToArray(_useState, 2),
@@ -172,7 +173,8 @@ export var CreateFullPage = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
172
173
  }, /*#__PURE__*/React.createElement("div", {
173
174
  className: "".concat(blockClass, "__content")
174
175
  }, /*#__PURE__*/React.createElement(Form, {
175
- className: "".concat(blockClass, "__form")
176
+ className: "".concat(blockClass, "__form"),
177
+ "aria-label": title
176
178
  }, /*#__PURE__*/React.createElement(StepsContext.Provider, {
177
179
  value: {
178
180
  currentStep: currentStep,
@@ -8,7 +8,7 @@ var DocsPage = function DocsPage() {
8
8
  story: stories.Default
9
9
  }, {
10
10
  title: 'Form validation',
11
- description: "All forms, including that within the `CreateModal` should follow C&CS guidelines\nfor form validation.\n\nThis includes the following:\n\n- The `Submit` button in the modal should be disabled, until all required inputs\n are filled in and valid\n- All required inputs should _only_ throw an invalid error _after_ the element\n loses focus\n- All optional form fields should have an `(optional)` text at the end of the\n input `labelText`. Optional should always be in parentheses\n\nYou can find more information on how to validate your form fields in\n[Carbon's Form usage page](https://www.carbondesignsystem.com/components/form/usage)."
11
+ description: "All forms, including that within the `CreateModal` should follow @carbon/ibm-products guidelines\nfor form validation.\n\nThis includes the following:\n\n- The `Submit` button in the modal should be disabled, until all required inputs\n are filled in and valid\n- All required inputs should _only_ throw an invalid error _after_ the element\n loses focus\n- All optional form fields should have an `(optional)` text at the end of the\n input `labelText`. Optional should always be in parentheses\n\nYou can find more information on how to validate your form fields in\n[Carbon's Form usage page](https://www.carbondesignsystem.com/components/form/usage)."
12
12
  }, {
13
13
  title: 'Overriding Carbon theme',
14
14
  description: "The design recommendation is to use a dark theme for the CreateModal if the\napplication is currently using a light theme, and vice versa. The theme applied\nto the CreateModal can easily be customized as follows:\n\nIn SCSS:",
@@ -73,7 +73,8 @@ export var CreateModal = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
73
73
  }, description && /*#__PURE__*/React.createElement("p", {
74
74
  className: "".concat(blockClass, "__description")
75
75
  }, description), /*#__PURE__*/React.createElement(Form, {
76
- className: "".concat(blockClass, "__form")
76
+ className: "".concat(blockClass, "__form"),
77
+ "aria-label": title
77
78
  }, children)), /*#__PURE__*/React.createElement(ModalFooter, null, /*#__PURE__*/React.createElement(Button, {
78
79
  type: "button",
79
80
  kind: "secondary",
@@ -11,7 +11,7 @@ var DocsPage = function DocsPage() {
11
11
  story: stories.Default
12
12
  }, {
13
13
  title: 'Form validation',
14
- description: "All forms, including that within the `CreateSidePanel` should follow C&CS\nguidelines for form validation.\n\nThis includes the following:\n\n- The `Submit` button in the side panel should be disabled, until all required\n inputs are filled in and valid\n- All required inputs should _only_ throw an invalid error _after_ the element\n loses focus\n- All optional form fields should have an `(optional)` text at the end of the\n input `labelText`. Optional should always be in parentheses\n\nYou can find more information on how to validate your form fields in\n[Carbon's Form usage page](https://www.carbondesignsystem.com/components/form/usage)."
14
+ description: "All forms, including that within the `CreateSidePanel` should follow @carbon/ibm-products\nguidelines for form validation.\n\nThis includes the following:\n\n- The `Submit` button in the side panel should be disabled, until all required\n inputs are filled in and valid\n- All required inputs should _only_ throw an invalid error _after_ the element\n loses focus\n- All optional form fields should have an `(optional)` text at the end of the\n input `labelText`. Optional should always be in parentheses\n\nYou can find more information on how to validate your form fields in\n[Carbon's Form usage page](https://www.carbondesignsystem.com/components/form/usage)."
15
15
  }]
16
16
  });
17
17
  };
@@ -23,6 +23,7 @@ import { getDevtoolsProps } from '../../global/js/utils/devtools';
23
23
  // Carbon and package components we use.
24
24
  import { Form } from '@carbon/react';
25
25
  import { SidePanel } from '../SidePanel';
26
+ import uuidv4 from '../../global/js/utils/uuidv4';
26
27
 
27
28
  // The block part of our conventional BEM class names (blockClass__E--M).
28
29
  var blockClass = "".concat(pkg.prefix, "--create-side-panel");
@@ -63,6 +64,7 @@ export var CreateSidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref)
63
64
  onClick: onRequestClose,
64
65
  kind: 'secondary'
65
66
  }];
67
+ var formTitleId = uuidv4();
66
68
  return selectorPageContent && /*#__PURE__*/React.createElement(SidePanel, _extends({}, rest, _objectSpread({
67
69
  open: open,
68
70
  ref: ref,
@@ -79,11 +81,13 @@ export var CreateSidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref)
79
81
  size: "md",
80
82
  actions: actions
81
83
  }), /*#__PURE__*/React.createElement("h3", {
82
- className: "".concat(blockClass, "__form-title-text ").concat(blockClass, "__content-text")
84
+ className: "".concat(blockClass, "__form-title-text ").concat(blockClass, "__content-text"),
85
+ id: formTitleId
83
86
  }, formTitle), /*#__PURE__*/React.createElement("p", {
84
87
  className: "".concat(blockClass, "__form-description-text ").concat(blockClass, "__content-text")
85
88
  }, formDescription), /*#__PURE__*/React.createElement(Form, {
86
- className: "".concat(blockClass, "__form")
89
+ className: "".concat(blockClass, "__form"),
90
+ "aria-labelledby": formTitleId
87
91
  }, children));
88
92
  });
89
93
  CreateSidePanel = pkg.checkComponentEnabled(CreateSidePanel, componentName);
@@ -196,7 +196,9 @@ export var CreateTearsheet = /*#__PURE__*/forwardRef(function (_ref, ref) {
196
196
  className: "".concat(blockClass, "__content"),
197
197
  onBlur: handleBlur,
198
198
  ref: contentRef
199
- }, /*#__PURE__*/React.createElement(Form, null, /*#__PURE__*/React.createElement(StepsContext.Provider, {
199
+ }, /*#__PURE__*/React.createElement(Form, {
200
+ "aria-label": title
201
+ }, /*#__PURE__*/React.createElement(StepsContext.Provider, {
200
202
  value: {
201
203
  currentStep: currentStep,
202
204
  setIsDisabled: setIsDisabled,
@@ -18,6 +18,7 @@ import { Form } from '@carbon/react';
18
18
  import { getDevtoolsProps } from '../../global/js/utils/devtools';
19
19
  import { pkg } from '../../settings';
20
20
  import { TearsheetNarrow } from '../Tearsheet/TearsheetNarrow';
21
+ import uuidv4 from '../../global/js/utils/uuidv4';
21
22
 
22
23
  // The block part of our conventional BEM class names (blockClass__E--M).
23
24
  var blockClass = "".concat(pkg.prefix, "--create-tearsheet-narrow");
@@ -57,6 +58,7 @@ export var CreateTearsheetNarrow = /*#__PURE__*/React.forwardRef(function (_ref,
57
58
  kind: 'secondary'
58
59
  }];
59
60
  var formTextClass = "".concat(blockClass, "__content-text");
61
+ var formTitleId = uuidv4();
60
62
  return /*#__PURE__*/React.createElement(TearsheetNarrow, _extends({}, rest, {
61
63
  title: title,
62
64
  description: description,
@@ -73,11 +75,13 @@ export var CreateTearsheetNarrow = /*#__PURE__*/React.forwardRef(function (_ref,
73
75
  verticalPosition: verticalPosition,
74
76
  role: "presentation"
75
77
  }, getDevtoolsProps(componentName)), /*#__PURE__*/React.createElement("h3", {
76
- className: cx("".concat(blockClass, "__form-title-text"), formTextClass)
78
+ className: cx("".concat(blockClass, "__form-title-text"), formTextClass),
79
+ id: formTitleId
77
80
  }, formTitle), /*#__PURE__*/React.createElement("p", {
78
81
  className: cx("".concat(blockClass, "__form-description-text"), formTextClass)
79
82
  }, formDescription), /*#__PURE__*/React.createElement(Form, {
80
- className: "".concat(blockClass, "__form")
83
+ className: "".concat(blockClass, "__form"),
84
+ "aria-labelledby": formTitleId
81
85
  }, children));
82
86
  });
83
87
 
@@ -24,6 +24,7 @@ import { pkg /*, carbon */ } from '../../settings';
24
24
  import { Form } from '@carbon/react';
25
25
  import { SidePanel } from '../SidePanel';
26
26
  import '../../global/js/utils/props-helper';
27
+ import uuidv4 from '../../global/js/utils/uuidv4';
27
28
 
28
29
  // The block part of our conventional BEM class names (blockClass__E--M).
29
30
  var blockClass = "".concat(pkg.prefix, "--edit-side-panel");
@@ -75,6 +76,7 @@ export var EditSidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
75
76
  onClick: onRequestClose,
76
77
  kind: 'secondary'
77
78
  }];
79
+ var formTitleId = uuidv4();
78
80
  return /*#__PURE__*/React.createElement(SidePanel, _extends({}, rest, _objectSpread({
79
81
  open: open,
80
82
  ref: ref,
@@ -92,11 +94,13 @@ export var EditSidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
92
94
  preventCloseOnClickOutside: true,
93
95
  actions: actions
94
96
  }), formTitle && /*#__PURE__*/React.createElement("h3", {
97
+ id: formTitleId,
95
98
  className: "".concat(blockClass, "__form-title-text ").concat(blockClass, "__content-text")
96
99
  }, formTitle), formDescription && /*#__PURE__*/React.createElement("p", {
97
100
  className: "".concat(blockClass, "__form-description-text ").concat(blockClass, "__content-text")
98
101
  }, formDescription), /*#__PURE__*/React.createElement(Form, {
99
- className: "".concat(blockClass, "__form")
102
+ className: "".concat(blockClass, "__form"),
103
+ "aria-labelledby": formTitleId
100
104
  }, children));
101
105
  });
102
106
 
@@ -131,7 +135,7 @@ EditSidePanel.propTypes = {
131
135
  /**
132
136
  * Specifies a required field that provides a title for a form
133
137
  */
134
- formTitle: PropTypes.node,
138
+ formTitle: PropTypes.node.isRequired,
135
139
  /**
136
140
  * Specifies an optional handler which is called when the CreateSidePanel
137
141
  * is closed.
@@ -261,7 +261,8 @@ export var TearsheetShell = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
261
261
  actions: actions,
262
262
  buttonSize: wide ? '2xl' : null,
263
263
  className: "".concat(bc, "__buttons"),
264
- size: wide ? '2xl' : 'lg'
264
+ size: wide ? '2xl' : 'lg',
265
+ "aria-hidden": !open
265
266
  })))), /*#__PURE__*/React.createElement("div", {
266
267
  className: "".concat(bc, "__resize-detector"),
267
268
  ref: resizer
@@ -52,7 +52,7 @@ export var useResizeObserver = function useResizeObserver(ref, callback) {
52
52
  observer = null;
53
53
  };
54
54
  // eslint-disable-next-line react-hooks/exhaustive-deps
55
- }, [ref]);
55
+ }, [ref.current]);
56
56
  return {
57
57
  width: width,
58
58
  height: height
@@ -85,18 +85,22 @@ var APIKeyModal = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
85
85
  previousStepButtonText = _ref.previousStepButtonText,
86
86
  showAPIKeyLabel = _ref.showAPIKeyLabel,
87
87
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
88
- var _useState = (0, _react.useState)(false),
88
+ var _useState = (0, _react.useState)(null),
89
89
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
90
- copyError = _useState2[0],
91
- setCopyError = _useState2[1];
92
- var _useState3 = (0, _react.useState)(apiKeyName),
90
+ title = _useState2[0],
91
+ setTitle = _useState2[1];
92
+ var _useState3 = (0, _react.useState)(false),
93
93
  _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
94
- name = _useState4[0],
95
- setName = _useState4[1];
96
- var _useState5 = (0, _react.useState)(0),
94
+ copyError = _useState4[0],
95
+ setCopyError = _useState4[1];
96
+ var _useState5 = (0, _react.useState)(apiKeyName),
97
97
  _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
98
- currentStep = _useState6[0],
99
- setCurrentStep = _useState6[1];
98
+ name = _useState6[0],
99
+ setName = _useState6[1];
100
+ var _useState7 = (0, _react.useState)(0),
101
+ _useState8 = (0, _slicedToArray2.default)(_useState7, 2),
102
+ currentStep = _useState8[0],
103
+ setCurrentStep = _useState8[1];
100
104
  var copyRef = (0, _react.useRef)();
101
105
  var apiKeyInputId = (0, _react.useRef)((0, _uuidv.default)());
102
106
  var nameInputId = (0, _react.useRef)((0, _uuidv.default)());
@@ -149,18 +153,17 @@ var APIKeyModal = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
149
153
  }
150
154
  return closeButtonText;
151
155
  };
152
- var getTitle = function getTitle() {
156
+ (0, _react.useEffect)(function () {
153
157
  if (editing && editSuccess) {
154
- return editSuccessTitle;
155
- }
156
- if (apiKeyLoaded) {
157
- return generateSuccessTitle;
158
- }
159
- if (hasSteps) {
160
- return customSteps[currentStep].title;
158
+ setTitle(editSuccessTitle);
159
+ } else if (apiKeyLoaded) {
160
+ setTitle(generateSuccessTitle);
161
+ } else if (hasSteps) {
162
+ setTitle(customSteps[currentStep].title);
163
+ } else {
164
+ setTitle(generateTitle);
161
165
  }
162
- return generateTitle;
163
- };
166
+ }, [apiKeyLoaded, editing, editSuccess, editSuccessTitle, hasSteps, generateSuccessTitle, generateTitle, currentStep, customSteps]);
164
167
  var setNameHandler = function setNameHandler(evt) {
165
168
  setName(evt.target.value);
166
169
  };
@@ -243,7 +246,7 @@ var APIKeyModal = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
243
246
  preventCloseOnClickOutside: true
244
247
  }), /*#__PURE__*/_react.default.createElement(_react2.ModalHeader, {
245
248
  className: "".concat(blockClass, "__header"),
246
- title: getTitle(),
249
+ title: title,
247
250
  label: modalLabel
248
251
  }), /*#__PURE__*/_react.default.createElement(_react2.ModalBody, {
249
252
  className: "".concat(blockClass, "__body-container")
@@ -261,7 +264,8 @@ var APIKeyModal = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
261
264
  labelText: apiKeyLabel,
262
265
  id: apiKeyInputId.current
263
266
  }), (editing || !apiKeyLoaded && nameRequired) && /*#__PURE__*/_react.default.createElement(_react2.Form, {
264
- onSubmit: submitHandler
267
+ onSubmit: submitHandler,
268
+ "aria-label": title
265
269
  }, /*#__PURE__*/_react.default.createElement(_react2.TextInput, {
266
270
  helperText: nameHelperText,
267
271
  placeholder: namePlaceholder,
@@ -79,13 +79,12 @@ var ActionBar = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
79
79
  className: "".concat(blockClass, "__hidden-sizing-items"),
80
80
  "aria-hidden": true,
81
81
  ref: sizingRef
82
- }, /*#__PURE__*/_react.default.createElement("span", {
83
- "aria-hidden": false
84
- }, /*#__PURE__*/_react.default.createElement(_ActionBarOverflowItems.ActionBarOverflowItems, {
82
+ }, /*#__PURE__*/_react.default.createElement("span", null, /*#__PURE__*/_react.default.createElement(_ActionBarOverflowItems.ActionBarOverflowItems, {
85
83
  className: "".concat(blockClass, "__hidden-sizing-item"),
86
84
  overflowAriaLabel: "hidden sizing overflow items",
87
85
  overflowItems: [],
88
- key: "hidden-overflow-menu"
86
+ key: "hidden-overflow-menu",
87
+ tabIndex: -1
89
88
  }), actions.map(function (_ref2) {
90
89
  var key = _ref2.key,
91
90
  id = _ref2.id,
@@ -94,7 +93,8 @@ var ActionBar = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
94
93
  // ensure id is not duplicated
95
94
  "data-original-id": id,
96
95
  key: "hidden-item-".concat(key),
97
- className: "".concat(blockClass, "__hidden-sizing-item")
96
+ className: "".concat(blockClass, "__hidden-sizing-item"),
97
+ tabIndex: -1
98
98
  }));
99
99
  }))));
100
100
  }, [actions]);
@@ -19,7 +19,7 @@ var _CreateInfluencer = require("../CreateInfluencer");
19
19
  var _ActionSet = require("../ActionSet");
20
20
  var _hooks = require("../../global/js/hooks");
21
21
  var _lastIndexInArray = require("../../global/js/utils/lastIndexInArray");
22
- var _excluded = ["backButtonText", "cancelButtonText", "children", "className", "modalDangerButtonText", "modalDescription", "modalSecondaryButtonText", "modalTitle", "nextButtonText", "onClose", "onRequestSubmit", "firstFocusElement", "submitButtonText"];
22
+ var _excluded = ["backButtonText", "cancelButtonText", "children", "className", "modalDangerButtonText", "modalDescription", "modalSecondaryButtonText", "modalTitle", "nextButtonText", "onClose", "onRequestSubmit", "firstFocusElement", "submitButtonText", "title"];
23
23
  /**
24
24
  * Copyright IBM Corp. 2021, 2023
25
25
  *
@@ -71,6 +71,7 @@ var CreateFullPage = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref)
71
71
  onRequestSubmit = _ref.onRequestSubmit,
72
72
  firstFocusElement = _ref.firstFocusElement,
73
73
  submitButtonText = _ref.submitButtonText,
74
+ title = _ref.title,
74
75
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
75
76
  var _useState = (0, _react.useState)([]),
76
77
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
@@ -181,7 +182,8 @@ var CreateFullPage = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref)
181
182
  }, /*#__PURE__*/_react.default.createElement("div", {
182
183
  className: "".concat(blockClass, "__content")
183
184
  }, /*#__PURE__*/_react.default.createElement(_react2.Form, {
184
- className: "".concat(blockClass, "__form")
185
+ className: "".concat(blockClass, "__form"),
186
+ "aria-label": title
185
187
  }, /*#__PURE__*/_react.default.createElement(StepsContext.Provider, {
186
188
  value: {
187
189
  currentStep: currentStep,
@@ -18,7 +18,7 @@ var DocsPage = function DocsPage() {
18
18
  story: stories.Default
19
19
  }, {
20
20
  title: 'Form validation',
21
- description: "All forms, including that within the `CreateModal` should follow C&CS guidelines\nfor form validation.\n\nThis includes the following:\n\n- The `Submit` button in the modal should be disabled, until all required inputs\n are filled in and valid\n- All required inputs should _only_ throw an invalid error _after_ the element\n loses focus\n- All optional form fields should have an `(optional)` text at the end of the\n input `labelText`. Optional should always be in parentheses\n\nYou can find more information on how to validate your form fields in\n[Carbon's Form usage page](https://www.carbondesignsystem.com/components/form/usage)."
21
+ description: "All forms, including that within the `CreateModal` should follow @carbon/ibm-products guidelines\nfor form validation.\n\nThis includes the following:\n\n- The `Submit` button in the modal should be disabled, until all required inputs\n are filled in and valid\n- All required inputs should _only_ throw an invalid error _after_ the element\n loses focus\n- All optional form fields should have an `(optional)` text at the end of the\n input `labelText`. Optional should always be in parentheses\n\nYou can find more information on how to validate your form fields in\n[Carbon's Form usage page](https://www.carbondesignsystem.com/components/form/usage)."
22
22
  }, {
23
23
  title: 'Overriding Carbon theme',
24
24
  description: "The design recommendation is to use a dark theme for the CreateModal if the\napplication is currently using a light theme, and vice versa. The theme applied\nto the CreateModal can easily be customized as follows:\n\nIn SCSS:",
@@ -78,7 +78,8 @@ var CreateModal = /*#__PURE__*/_react.default.forwardRef(function (_ref2, ref) {
78
78
  }, description && /*#__PURE__*/_react.default.createElement("p", {
79
79
  className: "".concat(blockClass, "__description")
80
80
  }, description), /*#__PURE__*/_react.default.createElement(_react2.Form, {
81
- className: "".concat(blockClass, "__form")
81
+ className: "".concat(blockClass, "__form"),
82
+ "aria-label": title
82
83
  }, children)), /*#__PURE__*/_react.default.createElement(_react2.ModalFooter, null, /*#__PURE__*/_react.default.createElement(_react2.Button, {
83
84
  type: "button",
84
85
  kind: "secondary",
@@ -21,7 +21,7 @@ var DocsPage = function DocsPage() {
21
21
  story: stories.Default
22
22
  }, {
23
23
  title: 'Form validation',
24
- description: "All forms, including that within the `CreateSidePanel` should follow C&CS\nguidelines for form validation.\n\nThis includes the following:\n\n- The `Submit` button in the side panel should be disabled, until all required\n inputs are filled in and valid\n- All required inputs should _only_ throw an invalid error _after_ the element\n loses focus\n- All optional form fields should have an `(optional)` text at the end of the\n input `labelText`. Optional should always be in parentheses\n\nYou can find more information on how to validate your form fields in\n[Carbon's Form usage page](https://www.carbondesignsystem.com/components/form/usage)."
24
+ description: "All forms, including that within the `CreateSidePanel` should follow @carbon/ibm-products\nguidelines for form validation.\n\nThis includes the following:\n\n- The `Submit` button in the side panel should be disabled, until all required\n inputs are filled in and valid\n- All required inputs should _only_ throw an invalid error _after_ the element\n loses focus\n- All optional form fields should have an `(optional)` text at the end of the\n input `labelText`. Optional should always be in parentheses\n\nYou can find more information on how to validate your form fields in\n[Carbon's Form usage page](https://www.carbondesignsystem.com/components/form/usage)."
25
25
  }]
26
26
  });
27
27
  };
@@ -15,6 +15,7 @@ var _settings = require("../../settings");
15
15
  var _devtools = require("../../global/js/utils/devtools");
16
16
  var _react2 = require("@carbon/react");
17
17
  var _SidePanel = require("../SidePanel");
18
+ var _uuidv = _interopRequireDefault(require("../../global/js/utils/uuidv4"));
18
19
  var _excluded = ["className", "children", "disableSubmit", "formTitle", "formDescription", "onRequestClose", "onRequestSubmit", "open", "primaryButtonText", "secondaryButtonText", "selectorPageContent", "selectorPrimaryFocus", "subtitle", "title"];
19
20
  /**
20
21
  * Copyright IBM Corp. 2021, 2021
@@ -66,6 +67,7 @@ var CreateSidePanel = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
66
67
  onClick: onRequestClose,
67
68
  kind: 'secondary'
68
69
  }];
70
+ var formTitleId = (0, _uuidv.default)();
69
71
  return selectorPageContent && /*#__PURE__*/_react.default.createElement(_SidePanel.SidePanel, (0, _extends2.default)({}, rest, _objectSpread({
70
72
  open: open,
71
73
  ref: ref,
@@ -82,11 +84,13 @@ var CreateSidePanel = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
82
84
  size: "md",
83
85
  actions: actions
84
86
  }), /*#__PURE__*/_react.default.createElement("h3", {
85
- className: "".concat(blockClass, "__form-title-text ").concat(blockClass, "__content-text")
87
+ className: "".concat(blockClass, "__form-title-text ").concat(blockClass, "__content-text"),
88
+ id: formTitleId
86
89
  }, formTitle), /*#__PURE__*/_react.default.createElement("p", {
87
90
  className: "".concat(blockClass, "__form-description-text ").concat(blockClass, "__content-text")
88
91
  }, formDescription), /*#__PURE__*/_react.default.createElement(_react2.Form, {
89
- className: "".concat(blockClass, "__form")
92
+ className: "".concat(blockClass, "__form"),
93
+ "aria-labelledby": formTitleId
90
94
  }, children));
91
95
  });
92
96
  exports.CreateSidePanel = CreateSidePanel;
@@ -207,7 +207,9 @@ var CreateTearsheet = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
207
207
  className: "".concat(blockClass, "__content"),
208
208
  onBlur: handleBlur,
209
209
  ref: contentRef
210
- }, /*#__PURE__*/_react.default.createElement(_react2.Form, null, /*#__PURE__*/_react.default.createElement(StepsContext.Provider, {
210
+ }, /*#__PURE__*/_react.default.createElement(_react2.Form, {
211
+ "aria-label": title
212
+ }, /*#__PURE__*/_react.default.createElement(StepsContext.Provider, {
211
213
  value: {
212
214
  currentStep: currentStep,
213
215
  setIsDisabled: setIsDisabled,
@@ -14,6 +14,7 @@ var _react2 = require("@carbon/react");
14
14
  var _devtools = require("../../global/js/utils/devtools");
15
15
  var _settings = require("../../settings");
16
16
  var _TearsheetNarrow = require("../Tearsheet/TearsheetNarrow");
17
+ var _uuidv = _interopRequireDefault(require("../../global/js/utils/uuidv4"));
17
18
  var _excluded = ["children", "className", "description", "disableSubmit", "formDescription", "formTitle", "label", "open", "onRequestClose", "onRequestSubmit", "primaryButtonText", "secondaryButtonText", "selectorPrimaryFocus", "title", "verticalPosition"];
18
19
  /**
19
20
  * Copyright IBM Corp. 2021, 2021
@@ -61,6 +62,7 @@ var CreateTearsheetNarrow = /*#__PURE__*/_react.default.forwardRef(function (_re
61
62
  kind: 'secondary'
62
63
  }];
63
64
  var formTextClass = "".concat(blockClass, "__content-text");
65
+ var formTitleId = (0, _uuidv.default)();
64
66
  return /*#__PURE__*/_react.default.createElement(_TearsheetNarrow.TearsheetNarrow, (0, _extends2.default)({}, rest, {
65
67
  title: title,
66
68
  description: description,
@@ -77,11 +79,13 @@ var CreateTearsheetNarrow = /*#__PURE__*/_react.default.forwardRef(function (_re
77
79
  verticalPosition: verticalPosition,
78
80
  role: "presentation"
79
81
  }, (0, _devtools.getDevtoolsProps)(componentName)), /*#__PURE__*/_react.default.createElement("h3", {
80
- className: (0, _classnames.default)("".concat(blockClass, "__form-title-text"), formTextClass)
82
+ className: (0, _classnames.default)("".concat(blockClass, "__form-title-text"), formTextClass),
83
+ id: formTitleId
81
84
  }, formTitle), /*#__PURE__*/_react.default.createElement("p", {
82
85
  className: (0, _classnames.default)("".concat(blockClass, "__form-description-text"), formTextClass)
83
86
  }, formDescription), /*#__PURE__*/_react.default.createElement(_react2.Form, {
84
- className: "".concat(blockClass, "__form")
87
+ className: "".concat(blockClass, "__form"),
88
+ "aria-labelledby": formTitleId
85
89
  }, children));
86
90
  });
87
91
 
@@ -16,6 +16,7 @@ var _settings = require("../../settings");
16
16
  var _react2 = require("@carbon/react");
17
17
  var _SidePanel = require("../SidePanel");
18
18
  require("../../global/js/utils/props-helper");
19
+ var _uuidv = _interopRequireDefault(require("../../global/js/utils/uuidv4"));
19
20
  var _excluded = ["children", "className", "disableSubmit", "formTitle", "formDescription", "onRequestClose", "onRequestSubmit", "open", "placement", "primaryButtonText", "secondaryButtonText", "selectorPrimaryFocus", "selectorPageContent", "size", "slideIn", "subtitle", "title"];
20
21
  /**
21
22
  * Copyright IBM Corp. 2021, 2021
@@ -78,6 +79,7 @@ var EditSidePanel = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref)
78
79
  onClick: onRequestClose,
79
80
  kind: 'secondary'
80
81
  }];
82
+ var formTitleId = (0, _uuidv.default)();
81
83
  return /*#__PURE__*/_react.default.createElement(_SidePanel.SidePanel, (0, _extends2.default)({}, rest, _objectSpread({
82
84
  open: open,
83
85
  ref: ref,
@@ -95,11 +97,13 @@ var EditSidePanel = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref)
95
97
  preventCloseOnClickOutside: true,
96
98
  actions: actions
97
99
  }), formTitle && /*#__PURE__*/_react.default.createElement("h3", {
100
+ id: formTitleId,
98
101
  className: "".concat(blockClass, "__form-title-text ").concat(blockClass, "__content-text")
99
102
  }, formTitle), formDescription && /*#__PURE__*/_react.default.createElement("p", {
100
103
  className: "".concat(blockClass, "__form-description-text ").concat(blockClass, "__content-text")
101
104
  }, formDescription), /*#__PURE__*/_react.default.createElement(_react2.Form, {
102
- className: "".concat(blockClass, "__form")
105
+ className: "".concat(blockClass, "__form"),
106
+ "aria-labelledby": formTitleId
103
107
  }, children));
104
108
  });
105
109
 
@@ -135,7 +139,7 @@ EditSidePanel.propTypes = {
135
139
  /**
136
140
  * Specifies a required field that provides a title for a form
137
141
  */
138
- formTitle: _propTypes.default.node,
142
+ formTitle: _propTypes.default.node.isRequired,
139
143
  /**
140
144
  * Specifies an optional handler which is called when the CreateSidePanel
141
145
  * is closed.
@@ -270,7 +270,8 @@ var TearsheetShell = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref)
270
270
  actions: actions,
271
271
  buttonSize: wide ? '2xl' : null,
272
272
  className: "".concat(bc, "__buttons"),
273
- size: wide ? '2xl' : 'lg'
273
+ size: wide ? '2xl' : 'lg',
274
+ "aria-hidden": !open
274
275
  })))), /*#__PURE__*/_react.default.createElement("div", {
275
276
  className: "".concat(bc, "__resize-detector"),
276
277
  ref: resizer
@@ -60,7 +60,7 @@ var useResizeObserver = function useResizeObserver(ref, callback) {
60
60
  observer = null;
61
61
  };
62
62
  // eslint-disable-next-line react-hooks/exhaustive-deps
63
- }, [ref]);
63
+ }, [ref.current]);
64
64
  return {
65
65
  width: width,
66
66
  height: height
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@carbon/ibm-products",
3
3
  "description": "Carbon for IBM Products",
4
- "version": "2.3.0",
4
+ "version": "2.3.2",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -88,11 +88,11 @@
88
88
  "@carbon/grid": "^11.15.0",
89
89
  "@carbon/layout": "^11.15.0",
90
90
  "@carbon/motion": "^11.12.0",
91
- "@carbon/react": "~1.31.3",
91
+ "@carbon/react": "^1.31.3",
92
92
  "@carbon/themes": "^11.20.0",
93
93
  "@carbon/type": "^11.19.0",
94
94
  "react": "^16.8.6 || ^17.0.1",
95
95
  "react-dom": "^16.8.6 || ^17.0.1"
96
96
  },
97
- "gitHead": "921bd04d38883be8c837181166e3b8156210a24f"
97
+ "gitHead": "d10acc630bdeb946d794ea2430d5df1ebf650c14"
98
98
  }