@carbon/react 1.41.0-rc.0 → 1.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -35,6 +35,7 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
35
35
  var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
36
36
 
37
37
  const getInstanceId = setupGetInstanceId["default"]();
38
+ const ModalSizes = ['xs', 'sm', 'md', 'lg'];
38
39
  const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_ref, ref) {
39
40
  let {
40
41
  'aria-label': ariaLabelProp,
@@ -66,11 +67,11 @@ const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_
66
67
  ...rest
67
68
  } = _ref;
68
69
  const prefix = usePrefix.usePrefix();
69
- const button = React.useRef();
70
+ const button = React.useRef(null);
70
71
  const secondaryButton = React.useRef();
71
- const innerModal = React.useRef();
72
- const startTrap = React.useRef();
73
- const endTrap = React.useRef();
72
+ const innerModal = React.useRef(null);
73
+ const startTrap = React.useRef(null);
74
+ const endTrap = React.useRef(null);
74
75
  const modalInstanceId = `modal-${getInstanceId()}`;
75
76
  const modalLabelId = `${prefix}--modal-header__label--${modalInstanceId}`;
76
77
  const modalHeadingId = `${prefix}--modal-header__heading--${modalInstanceId}`;
@@ -90,7 +91,8 @@ const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_
90
91
  }
91
92
  }
92
93
  function handleMousedown(evt) {
93
- if (innerModal.current && !innerModal.current.contains(evt.target) && !wrapFocus.elementOrParentIsFloatingMenu(evt.target, selectorsFloatingMenus) && !preventCloseOnClickOutside) {
94
+ const target = evt.target;
95
+ if (innerModal.current && !innerModal.current.contains(target) && !wrapFocus.elementOrParentIsFloatingMenu(target, selectorsFloatingMenus) && !preventCloseOnClickOutside) {
94
96
  onRequestClose(evt);
95
97
  }
96
98
  }
@@ -123,9 +125,8 @@ const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_
123
125
  const modalClasses = cx__default["default"](`${prefix}--modal`, {
124
126
  [`${prefix}--modal-tall`]: !passiveModal,
125
127
  'is-visible': open,
126
- [`${prefix}--modal--danger`]: danger,
127
- [className]: className
128
- });
128
+ [`${prefix}--modal--danger`]: danger
129
+ }, className);
129
130
  const containerClasses = cx__default["default"](`${prefix}--modal-container`, {
130
131
  [`${prefix}--modal-container--${size}`]: size,
131
132
  [`${prefix}--modal-container--full-width`]: isFullWidth
@@ -136,7 +137,12 @@ const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_
136
137
  const footerClasses = cx__default["default"](`${prefix}--modal-footer`, {
137
138
  [`${prefix}--modal-footer--three-button`]: Array.isArray(secondaryButtons) && secondaryButtons.length === 2
138
139
  });
139
- const ariaLabel = modalLabel || ariaLabelProp || modalAriaLabel || modalHeading;
140
+ const asStringOrUndefined = node => {
141
+ return typeof node === 'string' ? node : undefined;
142
+ };
143
+ const modalLabelStr = asStringOrUndefined(modalLabel);
144
+ const modalHeadingStr = asStringOrUndefined(modalHeading);
145
+ const ariaLabel = modalLabelStr || ariaLabelProp || modalAriaLabel || modalHeadingStr;
140
146
  const getAriaLabelledBy = modalLabel ? modalLabelId : modalHeadingId;
141
147
  const hasScrollingContentProps = hasScrollingContent ? {
142
148
  tabIndex: 0,
@@ -158,7 +164,7 @@ const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_
158
164
  };
159
165
  }, [prefix]);
160
166
  React.useEffect(() => {
161
- toggleClass["default"](document.body, `${prefix}--body--with-modal-open`, open);
167
+ toggleClass["default"](document.body, `${prefix}--body--with-modal-open`, open ?? false);
162
168
  }, [open, prefix]);
163
169
  React.useEffect(() => {
164
170
  if (!open && launcherButtonRef) {
@@ -178,7 +184,7 @@ const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_
178
184
  };
179
185
  const focusButton = focusContainerElement => {
180
186
  const target = initialFocus(focusContainerElement);
181
- if (target) {
187
+ if (target !== null) {
182
188
  target.focus();
183
189
  }
184
190
  };
@@ -206,7 +212,7 @@ const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_
206
212
  className: containerClasses,
207
213
  "aria-label": ariaLabel,
208
214
  "aria-modal": "true",
209
- tabIndex: "-1"
215
+ tabIndex: -1
210
216
  }), /*#__PURE__*/React__default["default"].createElement("div", {
211
217
  className: `${prefix}--modal-header`
212
218
  }, passiveModal && modalButton, modalLabel && /*#__PURE__*/React__default["default"].createElement(Text.Text, {
@@ -253,12 +259,12 @@ const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_
253
259
  ref: ref
254
260
  }), /*#__PURE__*/React__default["default"].createElement("span", {
255
261
  ref: startTrap,
256
- tabIndex: "0",
262
+ tabIndex: 0,
257
263
  role: "link",
258
264
  className: `${prefix}--visually-hidden`
259
265
  }, "Focus sentinel"), modalBody, /*#__PURE__*/React__default["default"].createElement("span", {
260
266
  ref: endTrap,
261
- tabIndex: "0",
267
+ tabIndex: 0,
262
268
  role: "link",
263
269
  className: `${prefix}--visually-hidden`
264
270
  }, "Focus sentinel"));
@@ -393,7 +399,7 @@ Modal.propTypes = {
393
399
  * Specify CSS selectors that match DOM elements working as floating menus.
394
400
  * Focusing on those elements won't trigger "focus-wrap" behavior
395
401
  */
396
- selectorsFloatingMenus: PropTypes__default["default"].arrayOf(PropTypes__default["default"].string),
402
+ selectorsFloatingMenus: PropTypes__default["default"].arrayOf(PropTypes__default["default"].string.isRequired),
397
403
  /**
398
404
  * Specify if Enter key should be used as "submit" action
399
405
  */
@@ -401,8 +407,8 @@ Modal.propTypes = {
401
407
  /**
402
408
  * Specify the size variant.
403
409
  */
404
- size: PropTypes__default["default"].oneOf(['xs', 'sm', 'md', 'lg'])
410
+ size: PropTypes__default["default"].oneOf(ModalSizes)
405
411
  };
406
- var Modal$1 = Modal;
407
412
 
408
- exports["default"] = Modal$1;
413
+ exports.ModalSizes = ModalSizes;
414
+ exports["default"] = Modal;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import Modal from './Modal';
8
+ export default Modal;
9
+ export { Modal };
@@ -92,7 +92,6 @@ const ClickableTile = /*#__PURE__*/React__default["default"].forwardRef(function
92
92
  evt?.persist?.();
93
93
  if (match.matches(evt, [keys.Enter, keys.Space])) {
94
94
  setIsSelected(!isSelected);
95
- onKeyDown(evt);
96
95
  }
97
96
  onKeyDown(evt);
98
97
  }
@@ -112,6 +111,7 @@ const ClickableTile = /*#__PURE__*/React__default["default"].forwardRef(function
112
111
  return /*#__PURE__*/React__default["default"].createElement(Link["default"], _rollupPluginBabelHelpers["extends"]({
113
112
  className: classes,
114
113
  href: href,
114
+ tabIndex: !href && !disabled ? 0 : undefined,
115
115
  onClick: !disabled ? handleOnClick : undefined,
116
116
  onKeyDown: handleOnKeyDown,
117
117
  ref: ref,
@@ -37,6 +37,7 @@ export declare namespace ToggletipLabel {
37
37
  interface ToggletipProps<E extends ElementType> {
38
38
  align?: PopoverAlignment | undefined;
39
39
  as?: E | undefined;
40
+ autoAlign?: boolean | undefined;
40
41
  className?: string | undefined;
41
42
  children?: ReactNode;
42
43
  defaultOpen?: boolean | undefined;
@@ -46,7 +47,7 @@ interface ToggletipProps<E extends ElementType> {
46
47
  * is responsible for coordinating between interactions with the button and the
47
48
  * visibility of the content
48
49
  */
49
- export declare function Toggletip<E extends ElementType = 'span'>({ align, as, className: customClassName, children, defaultOpen, }: ToggletipProps<E>): JSX.Element;
50
+ export declare function Toggletip<E extends ElementType = 'span'>({ align, as, autoAlign, className: customClassName, children, defaultOpen, }: ToggletipProps<E>): JSX.Element;
50
51
  export declare namespace Toggletip {
51
52
  var propTypes: {
52
53
  /**
@@ -58,6 +59,10 @@ export declare namespace Toggletip {
58
59
  * component.
59
60
  */
60
61
  as: PropTypes.Requireable<PropTypes.ReactComponentLike>;
62
+ /**
63
+ * Will auto-align the popover on first render if it is not visible. This prop is currently experimental and is subject to future changes.
64
+ */
65
+ autoAlign: PropTypes.Requireable<boolean>;
61
66
  /**
62
67
  * Custom children to be rendered as the content of the label
63
68
  */
@@ -73,6 +73,7 @@ function Toggletip(_ref2) {
73
73
  let {
74
74
  align,
75
75
  as,
76
+ autoAlign,
76
77
  className: customClassName,
77
78
  children,
78
79
  defaultOpen = false
@@ -147,7 +148,8 @@ function Toggletip(_ref2) {
147
148
  open: open,
148
149
  onKeyDown: onKeyDown,
149
150
  onBlur: handleBlur,
150
- ref: ref
151
+ ref: ref,
152
+ autoAlign: autoAlign
151
153
  }, children));
152
154
  }
153
155
  Toggletip.propTypes = {
@@ -160,6 +162,10 @@ Toggletip.propTypes = {
160
162
  * component.
161
163
  */
162
164
  as: PropTypes__default["default"].elementType,
165
+ /**
166
+ * Will auto-align the popover on first render if it is not visible. This prop is currently experimental and is subject to future changes.
167
+ */
168
+ autoAlign: PropTypes__default["default"].bool,
163
169
  /**
164
170
  * Custom children to be rendered as the content of the label
165
171
  */
package/lib/index.js CHANGED
@@ -62,6 +62,7 @@ var Link = require('./components/Link/Link.js');
62
62
  var ListItem = require('./components/ListItem/ListItem.js');
63
63
  var Loading = require('./components/Loading/Loading.js');
64
64
  var index$7 = require('./components/MenuButton/index.js');
65
+ var Modal = require('./components/Modal/Modal.js');
65
66
  var Notification = require('./components/Notification/Notification.js');
66
67
  var NumberInput_Skeleton = require('./components/NumberInput/NumberInput.Skeleton.js');
67
68
  var NumberInput = require('./components/NumberInput/NumberInput.js');
@@ -209,7 +210,6 @@ var ErrorBoundaryContext = require('./components/ErrorBoundary/ErrorBoundaryCont
209
210
  var FilterableMultiSelect = require('./components/MultiSelect/FilterableMultiSelect.js');
210
211
  var Menu = require('./components/Menu/Menu.js');
211
212
  var MenuItem = require('./components/Menu/MenuItem.js');
212
- var Modal = require('./components/Modal/Modal.js');
213
213
  var MultiSelect = require('./components/MultiSelect/MultiSelect.js');
214
214
  var Pagination$1 = require('./components/Pagination/Pagination.js');
215
215
  var PaginationNav = require('./components/PaginationNav/PaginationNav.js');
@@ -283,6 +283,7 @@ exports.Link = Link["default"];
283
283
  exports.ListItem = ListItem["default"];
284
284
  exports.Loading = Loading["default"];
285
285
  exports.MenuButton = index$7.MenuButton;
286
+ exports.Modal = Modal["default"];
286
287
  exports.ActionableNotification = Notification.ActionableNotification;
287
288
  exports.InlineNotification = Notification.InlineNotification;
288
289
  exports.NotificationActionButton = Notification.NotificationActionButton;
@@ -466,7 +467,6 @@ exports.MenuItemDivider = MenuItem.MenuItemDivider;
466
467
  exports.MenuItemGroup = MenuItem.MenuItemGroup;
467
468
  exports.MenuItemRadioGroup = MenuItem.MenuItemRadioGroup;
468
469
  exports.MenuItemSelectable = MenuItem.MenuItemSelectable;
469
- exports.Modal = Modal["default"];
470
470
  exports.MultiSelect = MultiSelect["default"];
471
471
  exports.Pagination = Pagination$1["default"];
472
472
  exports.PaginationNav = PaginationNav["default"];
@@ -32,11 +32,11 @@ function elementOrParentIsFloatingMenu(node) {
32
32
  /**
33
33
  * Ensures the focus is kept in the given `modalNode`, implementing "focus-wrap" behavior.
34
34
  * @param {object} options The options.
35
- * @param {HTMLElement|null} options.bodyNode
36
- * @param {HTMLElement|null} options.startTrapNode The DOM node of the focus sentinel the is placed earlier next to `modalNode`.
37
- * @param {HTMLElement|null} options.endTrapNode The DOM node of the focus sentinel the is placed next to `modalNode`.
38
- * @param {HTMLElement} options.currentActiveNode The DOM node that has focus.
39
- * @param {HTMLElement} options.oldActiveNode The DOM node that previously had focus.
35
+ * @param {Node|null} options.bodyNode
36
+ * @param {Node|null} options.startTrapNode The DOM node of the focus sentinel the is placed earlier next to `modalNode`.
37
+ * @param {Node|null} options.endTrapNode The DOM node of the focus sentinel the is placed next to `modalNode`.
38
+ * @param {Node} options.currentActiveNode The DOM node that has focus.
39
+ * @param {Node} options.oldActiveNode The DOM node that previously had focus.
40
40
  * @param {string[]} [options.selectorsFloatingMenus] The CSS selectors that matches floating menus.
41
41
  */
42
42
  function wrapFocus(_ref) {
@@ -12,8 +12,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
12
12
  /**
13
13
  * @param {string} name The name of the prop that must exist to validate
14
14
  * the current prop.
15
- * @param {Function} propType The original prop type checker.
16
- * @returns {Function} The new prop type checker for the current prop that
15
+ * @param {React.Validator} propType The original prop type checker.
16
+ * @returns {React.Validator} The new prop type checker for the current prop that
17
17
  * becomes required if the prop corresponding to the provided prop name exists.
18
18
  */
19
19
  function requiredIfGivenPropIsTruthy(name, propType) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@carbon/react",
3
3
  "description": "React components for the Carbon Design System",
4
- "version": "1.41.0-rc.0",
4
+ "version": "1.41.0",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -47,9 +47,9 @@
47
47
  "dependencies": {
48
48
  "@babel/runtime": "^7.18.3",
49
49
  "@carbon/feature-flags": "^0.16.0",
50
- "@carbon/icons-react": "^11.29.0-rc.0",
51
- "@carbon/layout": "^11.20.0-rc.0",
52
- "@carbon/styles": "^1.41.0-rc.0",
50
+ "@carbon/icons-react": "^11.29.0",
51
+ "@carbon/layout": "^11.20.0",
52
+ "@carbon/styles": "^1.41.0",
53
53
  "@carbon/telemetry": "0.1.0",
54
54
  "classnames": "2.3.2",
55
55
  "copy-to-clipboard": "^3.3.1",
@@ -77,7 +77,7 @@
77
77
  "@babel/preset-react": "^7.22.3",
78
78
  "@babel/preset-typescript": "^7.21.5",
79
79
  "@carbon/test-utils": "^10.30.0",
80
- "@carbon/themes": "^11.26.0-rc.0",
80
+ "@carbon/themes": "^11.26.0",
81
81
  "@rollup/plugin-babel": "^6.0.0",
82
82
  "@rollup/plugin-commonjs": "^25.0.0",
83
83
  "@rollup/plugin-node-resolve": "^15.0.0",
@@ -124,7 +124,7 @@
124
124
  "storybook-readme": "^5.0.9",
125
125
  "stream-browserify": "^3.0.0",
126
126
  "style-loader": "^3.3.1",
127
- "typescript-config-carbon": "^0.2.0-rc.0",
127
+ "typescript-config-carbon": "^0.2.0",
128
128
  "webpack": "^5.65.0",
129
129
  "webpack-dev-server": "^4.7.4"
130
130
  },
@@ -139,5 +139,5 @@
139
139
  "**/*.scss",
140
140
  "**/*.css"
141
141
  ],
142
- "gitHead": "da28d28a2d3a34503099e25255076efd3da4db9f"
142
+ "gitHead": "abe693e46a9b76731f51e47104f3634b6346f845"
143
143
  }
@@ -0,0 +1,9 @@
1
+ // Code generated by @carbon/react. DO NOT EDIT.
2
+ //
3
+ // Copyright IBM Corp. 2018, 2023
4
+ //
5
+ // This source code is licensed under the Apache-2.0 license found in the
6
+ // LICENSE file in the root directory of this source tree.
7
+ //
8
+
9
+ @forward '@carbon/styles/scss/components/slug';
@@ -0,0 +1,9 @@
1
+ // Code generated by @carbon/react. DO NOT EDIT.
2
+ //
3
+ // Copyright IBM Corp. 2018, 2023
4
+ //
5
+ // This source code is licensed under the Apache-2.0 license found in the
6
+ // LICENSE file in the root directory of this source tree.
7
+ //
8
+
9
+ @forward '@carbon/styles/scss/components/slug/slug';