@carbon/ibm-products 2.43.2-canary.69 → 2.43.2-canary.70

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.
@@ -9,7 +9,7 @@ import React, { PropsWithChildren, ReactNode, RefObject } from 'react';
9
9
  import PropTypes from 'prop-types';
10
10
  import { type ButtonProps } from '@carbon/react';
11
11
  interface TearsheetShellProps extends PropsWithChildren {
12
- actions?: ButtonProps[];
12
+ actions?: ButtonProps<any>[];
13
13
  ariaLabel?: string;
14
14
  /**
15
15
  * An optional class or classes to be added to the outermost element.
@@ -16,7 +16,7 @@ import { getNodeTextContent } from '../../global/js/utils/getNodeTextContent.js'
16
16
  import { Button, usePrefix, ComposedModal, ModalHeader, Layer } from '@carbon/react';
17
17
  import { Wrap } from '../../global/js/utils/Wrap.js';
18
18
  import { usePortalTarget } from '../../global/js/hooks/usePortalTarget.js';
19
- import { useFocus } from '../../global/js/hooks/useFocus.js';
19
+ import { useFocus, getSpecificElement } from '../../global/js/hooks/useFocus.js';
20
20
  import { usePreviousValue } from '../../global/js/hooks/usePreviousValue.js';
21
21
  import { ActionSet } from '../ActionSet/ActionSet.js';
22
22
 
@@ -140,7 +140,8 @@ var TearsheetShell = /*#__PURE__*/React__default.forwardRef(function (_ref, ref)
140
140
  // Callback to give the tearsheet the opportunity to claim focus
141
141
  handleStackChange.claimFocus = function () {
142
142
  if (selectorPrimaryFocus) {
143
- return specifiedElement === null || specifiedElement === void 0 ? void 0 : specifiedElement.focus();
143
+ var _getSpecificElement;
144
+ return (_getSpecificElement = getSpecificElement(modalRef === null || modalRef === void 0 ? void 0 : modalRef.current, selectorPrimaryFocus)) === null || _getSpecificElement === void 0 ? void 0 : _getSpecificElement.focus();
144
145
  }
145
146
  firstElement === null || firstElement === void 0 || firstElement.focus();
146
147
  };
@@ -358,6 +359,7 @@ TearsheetShell.propTypes = _objectSpread2({
358
359
  label: PropTypes.string,
359
360
  loading: PropTypes.bool,
360
361
  // we duplicate this Button prop to improve the DocGen here
362
+ /**@ts-ignore*/
361
363
  onClick: Button.propTypes.onClick
362
364
  }))),
363
365
  /**
@@ -1,3 +1,4 @@
1
+ export function getSpecificElement(parentEl: any, elementId: any): any;
1
2
  export function useFocus(modalRef: any, selectorPrimaryFocus: any): {
2
3
  firstElement: any;
3
4
  lastElement: any;
@@ -9,6 +9,9 @@ import { usePrefix } from '@carbon/react';
9
9
  import { pkg } from '../../../settings.js';
10
10
  import { useCallback, useEffect } from 'react';
11
11
 
12
+ var getSpecificElement = function getSpecificElement(parentEl, elementId) {
13
+ return elementId ? parentEl === null || parentEl === void 0 ? void 0 : parentEl.querySelector(elementId) : null;
14
+ };
12
15
  var useFocus = function useFocus(modalRef, selectorPrimaryFocus) {
13
16
  var carbonPrefix = usePrefix();
14
17
  var tearsheetBaseClass = "".concat(pkg.prefix, "--tearsheet");
@@ -39,7 +42,7 @@ var useFocus = function useFocus(modalRef, selectorPrimaryFocus) {
39
42
  var first = (_focusableElements2 = focusableElements) === null || _focusableElements2 === void 0 ? void 0 : _focusableElements2[0];
40
43
  var last = (_focusableElements3 = focusableElements) === null || _focusableElements3 === void 0 ? void 0 : _focusableElements3[((_focusableElements4 = focusableElements) === null || _focusableElements4 === void 0 ? void 0 : _focusableElements4.length) - 1];
41
44
  var all = focusableElements;
42
- var specifiedElement = selectorPrimaryFocus ? modalEl === null || modalEl === void 0 ? void 0 : modalEl.querySelector(selectorPrimaryFocus) : null;
45
+ var specifiedElement = getSpecificElement(modalEl, selectorPrimaryFocus);
43
46
  return {
44
47
  first: first,
45
48
  last: last,
@@ -84,4 +87,4 @@ var useFocus = function useFocus(modalRef, selectorPrimaryFocus) {
84
87
  };
85
88
  };
86
89
 
87
- export { useFocus };
90
+ export { getSpecificElement, useFocus };
@@ -9,7 +9,7 @@ import React, { PropsWithChildren, ReactNode, RefObject } from 'react';
9
9
  import PropTypes from 'prop-types';
10
10
  import { type ButtonProps } from '@carbon/react';
11
11
  interface TearsheetShellProps extends PropsWithChildren {
12
- actions?: ButtonProps[];
12
+ actions?: ButtonProps<any>[];
13
13
  ariaLabel?: string;
14
14
  /**
15
15
  * An optional class or classes to be added to the outermost element.
@@ -149,7 +149,8 @@ var TearsheetShell = /*#__PURE__*/React__default["default"].forwardRef(function
149
149
  // Callback to give the tearsheet the opportunity to claim focus
150
150
  handleStackChange.claimFocus = function () {
151
151
  if (selectorPrimaryFocus) {
152
- return specifiedElement === null || specifiedElement === void 0 ? void 0 : specifiedElement.focus();
152
+ var _getSpecificElement;
153
+ return (_getSpecificElement = useFocus.getSpecificElement(modalRef === null || modalRef === void 0 ? void 0 : modalRef.current, selectorPrimaryFocus)) === null || _getSpecificElement === void 0 ? void 0 : _getSpecificElement.focus();
153
154
  }
154
155
  firstElement === null || firstElement === void 0 || firstElement.focus();
155
156
  };
@@ -367,6 +368,7 @@ TearsheetShell.propTypes = _rollupPluginBabelHelpers.objectSpread2({
367
368
  label: index["default"].string,
368
369
  loading: index["default"].bool,
369
370
  // we duplicate this Button prop to improve the DocGen here
371
+ /**@ts-ignore*/
370
372
  onClick: react.Button.propTypes.onClick
371
373
  }))),
372
374
  /**
@@ -1,3 +1,4 @@
1
+ export function getSpecificElement(parentEl: any, elementId: any): any;
1
2
  export function useFocus(modalRef: any, selectorPrimaryFocus: any): {
2
3
  firstElement: any;
3
4
  lastElement: any;
@@ -13,6 +13,9 @@ var react = require('@carbon/react');
13
13
  var settings = require('../../../settings.js');
14
14
  var React = require('react');
15
15
 
16
+ var getSpecificElement = function getSpecificElement(parentEl, elementId) {
17
+ return elementId ? parentEl === null || parentEl === void 0 ? void 0 : parentEl.querySelector(elementId) : null;
18
+ };
16
19
  var useFocus = function useFocus(modalRef, selectorPrimaryFocus) {
17
20
  var carbonPrefix = react.usePrefix();
18
21
  var tearsheetBaseClass = "".concat(settings.pkg.prefix, "--tearsheet");
@@ -43,7 +46,7 @@ var useFocus = function useFocus(modalRef, selectorPrimaryFocus) {
43
46
  var first = (_focusableElements2 = focusableElements) === null || _focusableElements2 === void 0 ? void 0 : _focusableElements2[0];
44
47
  var last = (_focusableElements3 = focusableElements) === null || _focusableElements3 === void 0 ? void 0 : _focusableElements3[((_focusableElements4 = focusableElements) === null || _focusableElements4 === void 0 ? void 0 : _focusableElements4.length) - 1];
45
48
  var all = focusableElements;
46
- var specifiedElement = selectorPrimaryFocus ? modalEl === null || modalEl === void 0 ? void 0 : modalEl.querySelector(selectorPrimaryFocus) : null;
49
+ var specifiedElement = getSpecificElement(modalEl, selectorPrimaryFocus);
47
50
  return {
48
51
  first: first,
49
52
  last: last,
@@ -88,4 +91,5 @@ var useFocus = function useFocus(modalRef, selectorPrimaryFocus) {
88
91
  };
89
92
  };
90
93
 
94
+ exports.getSpecificElement = getSpecificElement;
91
95
  exports.useFocus = useFocus;
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.43.2-canary.69+c2b96626f",
4
+ "version": "2.43.2-canary.70+b0f63caf5",
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": "c2b96626fdc12299d1aedd35a0dd0bbb2371f726"
123
+ "gitHead": "b0f63caf5098caf27f6039ad4d9a8519d7cf63a1"
124
124
  }