@carbon/ibm-products 2.54.0-canary.70 → 2.54.0-canary.71

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.
@@ -196,7 +196,8 @@ var CreateTearsheet = /*#__PURE__*/forwardRef(function (_ref, ref) {
196
196
  slug: slug,
197
197
  title: title,
198
198
  verticalPosition: verticalPosition,
199
- closeIconDescription: ''
199
+ closeIconDescription: '',
200
+ currentStep: currentStep
200
201
  }), /*#__PURE__*/React__default.createElement("div", {
201
202
  className: "".concat(blockClass, "__content"),
202
203
  ref: contentRef
@@ -19,6 +19,10 @@ interface TearsheetShellProps extends PropsWithChildren {
19
19
  * An optional class or classes to be added to the outermost element.
20
20
  */
21
21
  className?: string;
22
+ /**
23
+ * Used to track the current step on components which use `StepsContext` and `TearsheetShell`
24
+ */
25
+ currentStep?: number;
22
26
  /**
23
27
  * A description of the flow, displayed in the header area of the tearsheet.
24
28
  */
@@ -21,7 +21,7 @@ import { usePortalTarget } from '../../global/js/hooks/usePortalTarget.js';
21
21
  import { useFocus, claimFocus } from '../../global/js/hooks/useFocus.js';
22
22
  import { usePreviousValue } from '../../global/js/hooks/usePreviousValue.js';
23
23
 
24
- var _excluded = ["actions", "aiLabel", "ariaLabel", "children", "className", "closeIconDescription", "description", "hasCloseIcon", "headerActions", "influencer", "influencerPosition", "influencerWidth", "label", "navigation", "onClose", "open", "portalTarget", "selectorPrimaryFocus", "selectorsFloatingMenus", "size", "slug", "title", "verticalPosition", "launcherButtonRef"];
24
+ var _excluded = ["actions", "aiLabel", "ariaLabel", "children", "className", "closeIconDescription", "currentStep", "description", "hasCloseIcon", "headerActions", "influencer", "influencerPosition", "influencerWidth", "label", "navigation", "onClose", "open", "portalTarget", "selectorPrimaryFocus", "selectorsFloatingMenus", "size", "slug", "title", "verticalPosition", "launcherButtonRef"];
25
25
  // The block part of our conventional BEM class names (bc__E--M).
26
26
  var bc = "".concat(pkg.prefix, "--tearsheet");
27
27
  var componentName = 'TearsheetShell';
@@ -68,6 +68,7 @@ var TearsheetShell = /*#__PURE__*/React__default.forwardRef(function (_ref, ref)
68
68
  children = _ref.children,
69
69
  className = _ref.className,
70
70
  closeIconDescription = _ref.closeIconDescription,
71
+ currentStep = _ref.currentStep,
71
72
  description = _ref.description,
72
73
  hasCloseIcon = _ref.hasCloseIcon,
73
74
  headerActions = _ref.headerActions,
@@ -100,8 +101,7 @@ var TearsheetShell = /*#__PURE__*/React__default.forwardRef(function (_ref, ref)
100
101
  var prevOpen = usePreviousValue(open);
101
102
  var _useFocus = useFocus(modalRef, selectorPrimaryFocus),
102
103
  firstElement = _useFocus.firstElement,
103
- keyDownListener = _useFocus.keyDownListener,
104
- specifiedElement = _useFocus.specifiedElement;
104
+ keyDownListener = _useFocus.keyDownListener;
105
105
  var modalRefValue = modalRef.current;
106
106
 
107
107
  // Function to strip html tags out of a string.
@@ -137,23 +137,12 @@ var TearsheetShell = /*#__PURE__*/React__default.forwardRef(function (_ref, ref)
137
137
  setDepth(newDepth);
138
138
  setPosition(newPosition);
139
139
  }
140
- handleStackChange.checkFocus = function () {
141
- // if we are now the topmost tearsheet, ensure we have focus
142
- if (open && position === depth && modalRefValue && !modalRefValue.contains(document.activeElement)) {
143
- handleStackChange.claimFocus();
144
- }
145
- };
146
-
147
- // Callback to give the tearsheet the opportunity to claim focus
148
- handleStackChange.claimFocus = function () {
149
- claimFocus(firstElement, modalRef, selectorPrimaryFocus);
150
- };
151
140
  useEffect(function () {
152
- if (open) {
141
+ if (open && position === depth) {
153
142
  // Focusing the first element or selectorPrimaryFocus element
154
143
  claimFocus(firstElement, modalRef, selectorPrimaryFocus);
155
144
  }
156
- }, [firstElement, modalRef, open, selectorPrimaryFocus]);
145
+ }, [currentStep, depth, firstElement, modalRef, modalRefValue, open, position, selectorPrimaryFocus]);
157
146
  useEffect(function () {
158
147
  if (prevOpen && !open && launcherButtonRef) {
159
148
  setTimeout(function () {
@@ -161,22 +150,10 @@ var TearsheetShell = /*#__PURE__*/React__default.forwardRef(function (_ref, ref)
161
150
  }, 0);
162
151
  }
163
152
  }, [launcherButtonRef, open, prevOpen]);
164
- useEffect(function () {
165
- if (open && position !== depth) {
166
- setTimeout(function () {
167
- if (selectorPrimaryFocus) {
168
- return specifiedElement === null || specifiedElement === void 0 ? void 0 : specifiedElement.focus();
169
- }
170
- firstElement === null || firstElement === void 0 || firstElement.focus();
171
- }, 0);
172
- }
173
- }, [position, depth, firstElement, open, specifiedElement, selectorPrimaryFocus]);
174
153
  useEffect(function () {
175
154
  var notify = function notify() {
176
155
  return stack.all.forEach(function (handler) {
177
- var _handler$checkFocus;
178
156
  handler(Math.min(stack.open.length, maxDepth), stack.open.indexOf(handler) + 1);
179
- (_handler$checkFocus = handler.checkFocus) === null || _handler$checkFocus === void 0 || _handler$checkFocus.call(handler);
180
157
  });
181
158
  };
182
159
 
@@ -211,14 +188,6 @@ var TearsheetShell = /*#__PURE__*/React__default.forwardRef(function (_ref, ref)
211
188
  }
212
189
  };
213
190
  }, [open, size]);
214
- function handleFocus() {
215
- // If something within us is receiving focus but we are not the topmost
216
- // stacked tearsheet, transfer focus to the topmost tearsheet instead
217
- if (position < depth) {
218
- var _stack$open$claimFocu, _stack$open;
219
- (_stack$open$claimFocu = (_stack$open = stack.open[stack.open.length - 1]).claimFocus) === null || _stack$open$claimFocu === void 0 || _stack$open$claimFocu.call(_stack$open);
220
- }
221
- }
222
191
  if (position <= depth) {
223
192
  var _prevDepth$current;
224
193
  // Include a modal header if and only if one or more of these is given.
@@ -250,7 +219,6 @@ var TearsheetShell = /*#__PURE__*/React__default.forwardRef(function (_ref, ref)
250
219
  onClose: onClose,
251
220
  open: open,
252
221
  selectorPrimaryFocus: selectorPrimaryFocus,
253
- onFocus: handleFocus,
254
222
  onKeyDown: keyDownListener,
255
223
  preventCloseOnClickOutside: !isPassive,
256
224
  ref: modalRef,
@@ -12,4 +12,4 @@ export function useFocus(modalRef: any, selectorPrimaryFocus: any): {
12
12
  specified: any;
13
13
  };
14
14
  };
15
- export function claimFocus(firstElement: any, modalRef: any, selectorPrimaryFocus?: string | undefined): any;
15
+ export function claimFocus(firstElement: any, modalRef: any, selectorPrimaryFocus?: string | undefined): void;
@@ -116,12 +116,15 @@ var claimFocus = function claimFocus(firstElement, modalRef) {
116
116
  var _window2;
117
117
  var specifiedEl = getSpecificElement(modalRef === null || modalRef === void 0 ? void 0 : modalRef.current, selectorPrimaryFocus);
118
118
  if (specifiedEl && ((_window2 = window) === null || _window2 === void 0 || (_window2 = _window2.getComputedStyle(specifiedEl)) === null || _window2 === void 0 ? void 0 : _window2.display) !== 'none') {
119
- return specifiedEl.focus();
119
+ setTimeout(function () {
120
+ return specifiedEl.focus();
121
+ }, 0);
120
122
  }
123
+ } else {
124
+ setTimeout(function () {
125
+ return firstElement === null || firstElement === void 0 ? void 0 : firstElement.focus();
126
+ }, 0);
121
127
  }
122
- setTimeout(function () {
123
- return firstElement === null || firstElement === void 0 ? void 0 : firstElement.focus();
124
- }, 0);
125
128
  };
126
129
 
127
130
  export { claimFocus, getSpecificElement, useFocus };
@@ -198,7 +198,8 @@ exports.CreateTearsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
198
198
  slug: slug,
199
199
  title: title,
200
200
  verticalPosition: verticalPosition,
201
- closeIconDescription: ''
201
+ closeIconDescription: '',
202
+ currentStep: currentStep
202
203
  }), /*#__PURE__*/React.createElement("div", {
203
204
  className: "".concat(blockClass, "__content"),
204
205
  ref: contentRef
@@ -19,6 +19,10 @@ interface TearsheetShellProps extends PropsWithChildren {
19
19
  * An optional class or classes to be added to the outermost element.
20
20
  */
21
21
  className?: string;
22
+ /**
23
+ * Used to track the current step on components which use `StepsContext` and `TearsheetShell`
24
+ */
25
+ currentStep?: number;
22
26
  /**
23
27
  * A description of the flow, displayed in the header area of the tearsheet.
24
28
  */
@@ -23,7 +23,7 @@ var usePortalTarget = require('../../global/js/hooks/usePortalTarget.js');
23
23
  var useFocus = require('../../global/js/hooks/useFocus.js');
24
24
  var usePreviousValue = require('../../global/js/hooks/usePreviousValue.js');
25
25
 
26
- var _excluded = ["actions", "aiLabel", "ariaLabel", "children", "className", "closeIconDescription", "description", "hasCloseIcon", "headerActions", "influencer", "influencerPosition", "influencerWidth", "label", "navigation", "onClose", "open", "portalTarget", "selectorPrimaryFocus", "selectorsFloatingMenus", "size", "slug", "title", "verticalPosition", "launcherButtonRef"];
26
+ var _excluded = ["actions", "aiLabel", "ariaLabel", "children", "className", "closeIconDescription", "currentStep", "description", "hasCloseIcon", "headerActions", "influencer", "influencerPosition", "influencerWidth", "label", "navigation", "onClose", "open", "portalTarget", "selectorPrimaryFocus", "selectorsFloatingMenus", "size", "slug", "title", "verticalPosition", "launcherButtonRef"];
27
27
  // The block part of our conventional BEM class names (bc__E--M).
28
28
  var bc = "".concat(settings.pkg.prefix, "--tearsheet");
29
29
  var componentName = 'TearsheetShell';
@@ -70,6 +70,7 @@ var TearsheetShell = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
70
70
  children = _ref.children,
71
71
  className = _ref.className,
72
72
  closeIconDescription = _ref.closeIconDescription,
73
+ currentStep = _ref.currentStep,
73
74
  description = _ref.description,
74
75
  hasCloseIcon = _ref.hasCloseIcon,
75
76
  headerActions = _ref.headerActions,
@@ -102,8 +103,7 @@ var TearsheetShell = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
102
103
  var prevOpen = usePreviousValue.usePreviousValue(open);
103
104
  var _useFocus = useFocus.useFocus(modalRef, selectorPrimaryFocus),
104
105
  firstElement = _useFocus.firstElement,
105
- keyDownListener = _useFocus.keyDownListener,
106
- specifiedElement = _useFocus.specifiedElement;
106
+ keyDownListener = _useFocus.keyDownListener;
107
107
  var modalRefValue = modalRef.current;
108
108
 
109
109
  // Function to strip html tags out of a string.
@@ -139,23 +139,12 @@ var TearsheetShell = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
139
139
  setDepth(newDepth);
140
140
  setPosition(newPosition);
141
141
  }
142
- handleStackChange.checkFocus = function () {
143
- // if we are now the topmost tearsheet, ensure we have focus
144
- if (open && position === depth && modalRefValue && !modalRefValue.contains(document.activeElement)) {
145
- handleStackChange.claimFocus();
146
- }
147
- };
148
-
149
- // Callback to give the tearsheet the opportunity to claim focus
150
- handleStackChange.claimFocus = function () {
151
- useFocus.claimFocus(firstElement, modalRef, selectorPrimaryFocus);
152
- };
153
142
  React.useEffect(function () {
154
- if (open) {
143
+ if (open && position === depth) {
155
144
  // Focusing the first element or selectorPrimaryFocus element
156
145
  useFocus.claimFocus(firstElement, modalRef, selectorPrimaryFocus);
157
146
  }
158
- }, [firstElement, modalRef, open, selectorPrimaryFocus]);
147
+ }, [currentStep, depth, firstElement, modalRef, modalRefValue, open, position, selectorPrimaryFocus]);
159
148
  React.useEffect(function () {
160
149
  if (prevOpen && !open && launcherButtonRef) {
161
150
  setTimeout(function () {
@@ -163,22 +152,10 @@ var TearsheetShell = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
163
152
  }, 0);
164
153
  }
165
154
  }, [launcherButtonRef, open, prevOpen]);
166
- React.useEffect(function () {
167
- if (open && position !== depth) {
168
- setTimeout(function () {
169
- if (selectorPrimaryFocus) {
170
- return specifiedElement === null || specifiedElement === void 0 ? void 0 : specifiedElement.focus();
171
- }
172
- firstElement === null || firstElement === void 0 || firstElement.focus();
173
- }, 0);
174
- }
175
- }, [position, depth, firstElement, open, specifiedElement, selectorPrimaryFocus]);
176
155
  React.useEffect(function () {
177
156
  var notify = function notify() {
178
157
  return stack.all.forEach(function (handler) {
179
- var _handler$checkFocus;
180
158
  handler(Math.min(stack.open.length, maxDepth), stack.open.indexOf(handler) + 1);
181
- (_handler$checkFocus = handler.checkFocus) === null || _handler$checkFocus === void 0 || _handler$checkFocus.call(handler);
182
159
  });
183
160
  };
184
161
 
@@ -213,14 +190,6 @@ var TearsheetShell = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
213
190
  }
214
191
  };
215
192
  }, [open, size]);
216
- function handleFocus() {
217
- // If something within us is receiving focus but we are not the topmost
218
- // stacked tearsheet, transfer focus to the topmost tearsheet instead
219
- if (position < depth) {
220
- var _stack$open$claimFocu, _stack$open;
221
- (_stack$open$claimFocu = (_stack$open = stack.open[stack.open.length - 1]).claimFocus) === null || _stack$open$claimFocu === void 0 || _stack$open$claimFocu.call(_stack$open);
222
- }
223
- }
224
193
  if (position <= depth) {
225
194
  var _prevDepth$current;
226
195
  // Include a modal header if and only if one or more of these is given.
@@ -252,7 +221,6 @@ var TearsheetShell = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
252
221
  onClose: onClose,
253
222
  open: open,
254
223
  selectorPrimaryFocus: selectorPrimaryFocus,
255
- onFocus: handleFocus,
256
224
  onKeyDown: keyDownListener,
257
225
  preventCloseOnClickOutside: !isPassive,
258
226
  ref: modalRef,
@@ -12,4 +12,4 @@ export function useFocus(modalRef: any, selectorPrimaryFocus: any): {
12
12
  specified: any;
13
13
  };
14
14
  };
15
- export function claimFocus(firstElement: any, modalRef: any, selectorPrimaryFocus?: string | undefined): any;
15
+ export function claimFocus(firstElement: any, modalRef: any, selectorPrimaryFocus?: string | undefined): void;
@@ -118,12 +118,15 @@ var claimFocus = function claimFocus(firstElement, modalRef) {
118
118
  var _window2;
119
119
  var specifiedEl = getSpecificElement(modalRef === null || modalRef === void 0 ? void 0 : modalRef.current, selectorPrimaryFocus);
120
120
  if (specifiedEl && ((_window2 = window) === null || _window2 === void 0 || (_window2 = _window2.getComputedStyle(specifiedEl)) === null || _window2 === void 0 ? void 0 : _window2.display) !== 'none') {
121
- return specifiedEl.focus();
121
+ setTimeout(function () {
122
+ return specifiedEl.focus();
123
+ }, 0);
122
124
  }
125
+ } else {
126
+ setTimeout(function () {
127
+ return firstElement === null || firstElement === void 0 ? void 0 : firstElement.focus();
128
+ }, 0);
123
129
  }
124
- setTimeout(function () {
125
- return firstElement === null || firstElement === void 0 ? void 0 : firstElement.focus();
126
- }, 0);
127
130
  };
128
131
 
129
132
  exports.claimFocus = claimFocus;
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.54.0-canary.70+13e845c84",
4
+ "version": "2.54.0-canary.71+1c918d160",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -120,5 +120,5 @@
120
120
  "react": "^16.8.6 || ^17.0.1 || ^18.2.0",
121
121
  "react-dom": "^16.8.6 || ^17.0.1 || ^18.2.0"
122
122
  },
123
- "gitHead": "13e845c84e1583e4cdc5d037f31a8c3b826fabfc"
123
+ "gitHead": "1c918d1605f2a370988d7ade503c1e57e0d43df1"
124
124
  }