@carbon/react 1.47.0-rc.0 → 1.48.0-rc.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.
Files changed (54) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +907 -996
  2. package/es/components/Button/Button.d.ts +1 -3
  3. package/es/components/Button/Button.js +9 -3
  4. package/es/components/ComposedModal/ModalHeader.js +10 -4
  5. package/es/components/DangerButton/DangerButton.js +2 -2
  6. package/es/components/DataTable/TableExpandHeader.d.ts +1 -1
  7. package/es/components/DataTable/TableExpandRow.d.ts +1 -1
  8. package/es/components/DataTable/TableExpandRow.js +0 -1
  9. package/es/components/DataTable/TableHeader.d.ts +10 -1
  10. package/es/components/DataTable/index.d.ts +3 -2
  11. package/es/components/DatePicker/DatePicker.js +3 -2
  12. package/es/components/Dropdown/Dropdown.d.ts +3 -2
  13. package/es/components/Dropdown/index.d.ts +2 -2
  14. package/es/components/ExpandableSearch/ExpandableSearch.js +6 -3
  15. package/es/components/IconButton/index.d.ts +70 -0
  16. package/es/components/IconButton/index.js +6 -5
  17. package/es/components/ListBox/ListBoxMenuIcon.d.ts +3 -6
  18. package/es/components/ListBox/ListBoxMenuIcon.js +4 -8
  19. package/es/components/ListBox/index.d.ts +1 -0
  20. package/es/components/Modal/Modal.d.ts +1 -1
  21. package/es/components/Modal/Modal.js +10 -6
  22. package/es/components/TreeView/TreeNode.js +11 -3
  23. package/es/components/TreeView/TreeView.js +1 -1
  24. package/es/components/UIShell/HeaderMenu.js +1 -1
  25. package/es/components/UIShell/SwitcherItem.d.ts +4 -0
  26. package/es/components/UIShell/SwitcherItem.js +4 -0
  27. package/es/index.js +1 -1
  28. package/lib/components/Button/Button.d.ts +1 -3
  29. package/lib/components/Button/Button.js +9 -3
  30. package/lib/components/ComposedModal/ModalHeader.js +10 -4
  31. package/lib/components/DangerButton/DangerButton.js +2 -2
  32. package/lib/components/DataTable/TableExpandHeader.d.ts +1 -1
  33. package/lib/components/DataTable/TableExpandRow.d.ts +1 -1
  34. package/lib/components/DataTable/TableExpandRow.js +0 -1
  35. package/lib/components/DataTable/TableHeader.d.ts +10 -1
  36. package/lib/components/DataTable/index.d.ts +3 -2
  37. package/lib/components/DatePicker/DatePicker.js +3 -2
  38. package/lib/components/Dropdown/Dropdown.d.ts +3 -2
  39. package/lib/components/Dropdown/index.d.ts +2 -2
  40. package/lib/components/ExpandableSearch/ExpandableSearch.js +5 -2
  41. package/lib/components/IconButton/index.d.ts +70 -0
  42. package/lib/components/IconButton/index.js +6 -4
  43. package/lib/components/ListBox/ListBoxMenuIcon.d.ts +3 -6
  44. package/lib/components/ListBox/ListBoxMenuIcon.js +3 -8
  45. package/lib/components/ListBox/index.d.ts +1 -0
  46. package/lib/components/Modal/Modal.d.ts +1 -1
  47. package/lib/components/Modal/Modal.js +10 -6
  48. package/lib/components/TreeView/TreeNode.js +11 -3
  49. package/lib/components/TreeView/TreeView.js +1 -1
  50. package/lib/components/UIShell/HeaderMenu.js +1 -1
  51. package/lib/components/UIShell/SwitcherItem.d.ts +4 -0
  52. package/lib/components/UIShell/SwitcherItem.js +4 -0
  53. package/lib/index.js +1 -0
  54. package/package.json +7 -7
@@ -28,6 +28,12 @@ const ButtonKinds = ['primary', 'secondary', 'danger', 'ghost', 'danger--primary
28
28
  const ButtonSizes = ['sm', 'md', 'lg', 'xl', '2xl'];
29
29
  const ButtonTooltipAlignments = ['start', 'center', 'end'];
30
30
  const ButtonTooltipPositions = ['top', 'right', 'bottom', 'left'];
31
+ function isIconOnlyButton(hasIconOnly, _kind) {
32
+ if (hasIconOnly === true) {
33
+ return true;
34
+ }
35
+ return false;
36
+ }
31
37
  const Button = /*#__PURE__*/React__default["default"].forwardRef(function Button(_ref, ref) {
32
38
  let {
33
39
  as,
@@ -60,7 +66,6 @@ const Button = /*#__PURE__*/React__default["default"].forwardRef(function Button
60
66
  // Prevent clicks on the tooltip from triggering the button click event
61
67
  if (evt.target === tooltipRef.current) {
62
68
  evt.preventDefault();
63
- return;
64
69
  }
65
70
  };
66
71
  const buttonClasses = cx__default["default"](className, {
@@ -123,7 +128,7 @@ const Button = /*#__PURE__*/React__default["default"].forwardRef(function Button
123
128
  component = 'a';
124
129
  otherProps = anchorProps;
125
130
  }
126
- if (!hasIconOnly) {
131
+ if (!isIconOnlyButton(hasIconOnly)) {
127
132
  return /*#__PURE__*/React__default["default"].createElement(component, {
128
133
  onMouseEnter,
129
134
  onMouseLeave,
@@ -161,7 +166,7 @@ const Button = /*#__PURE__*/React__default["default"].forwardRef(function Button
161
166
  onFocus: onFocus,
162
167
  onBlur: onBlur,
163
168
  onClick: events.composeEventHandlers([onClick, handleClick])
164
- }, rest, commonProps, otherProps), iconOnlyImage ? iconOnlyImage : children);
169
+ }, rest, commonProps, otherProps), iconOnlyImage ?? children);
165
170
  }
166
171
  });
167
172
  Button.displayName = 'Button';
@@ -216,6 +221,7 @@ Button.propTypes = {
216
221
  /**
217
222
  * Specify the kind of Button you want to create
218
223
  */
224
+ // TODO: this should be either ButtonKinds or IconButtonKinds based on the value of "hasIconOnly"
219
225
  kind: PropTypes__default["default"].oneOf(ButtonKinds),
220
226
  /**
221
227
  * Provide an optional function to be called when the button element
@@ -15,6 +15,7 @@ var PropTypes = require('prop-types');
15
15
  var cx = require('classnames');
16
16
  var iconsReact = require('@carbon/icons-react');
17
17
  var usePrefix = require('../../internal/usePrefix.js');
18
+ var index = require('../IconButton/index.js');
18
19
 
19
20
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
20
21
 
@@ -55,16 +56,21 @@ const ModalHeader = /*#__PURE__*/React__default["default"].forwardRef(function M
55
56
  className: labelClass
56
57
  }, label), title && /*#__PURE__*/React__default["default"].createElement("h3", {
57
58
  className: titleClass
58
- }, title), children, /*#__PURE__*/React__default["default"].createElement("button", {
59
- onClick: handleCloseButtonClick,
59
+ }, title), children, /*#__PURE__*/React__default["default"].createElement("div", {
60
+ className: `${prefix}--modal-close-button`
61
+ }, /*#__PURE__*/React__default["default"].createElement(index.IconButton, {
60
62
  className: closeClass,
63
+ label: iconDescription,
64
+ onClick: handleCloseButtonClick,
61
65
  title: iconDescription,
62
66
  "aria-label": iconDescription,
63
- type: "button"
67
+ align: "left"
64
68
  }, /*#__PURE__*/React__default["default"].createElement(iconsReact.Close, {
65
69
  size: 20,
70
+ "aria-hidden": "true",
71
+ tabIndex: "-1",
66
72
  className: closeIconClass
67
- })));
73
+ }))));
68
74
  });
69
75
  ModalHeader.propTypes = {
70
76
  /**
@@ -18,8 +18,8 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
18
18
 
19
19
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
20
20
 
21
- const DangerButton = props => /*#__PURE__*/React__default["default"].createElement(Button["default"], _rollupPluginBabelHelpers["extends"]({
21
+ const DangerButton = props => /*#__PURE__*/React__default["default"].createElement(Button["default"], _rollupPluginBabelHelpers["extends"]({}, props, {
22
22
  kind: "danger"
23
- }, props));
23
+ }));
24
24
 
25
25
  exports["default"] = DangerButton;
@@ -11,7 +11,7 @@ type TableExpandHeaderPropsBase = {
11
11
  /**
12
12
  * Space separated list of one or more ID values referencing the TableExpandedRow(s) being controlled by the TableExpandHeader
13
13
  */
14
- ['aria-controls']: string;
14
+ ['aria-controls']?: string;
15
15
  /**
16
16
  * @deprecated This prop has been deprecated and will be
17
17
  * removed in the next major release of Carbon. Use the
@@ -10,7 +10,7 @@ interface TableExpandRowProps extends PropsWithChildren<TableRowProps> {
10
10
  /**
11
11
  * Space separated list of one or more ID values referencing the TableExpandedRow(s) being controlled by the TableExpandRow
12
12
  */
13
- ['aria-controls']: string;
13
+ ['aria-controls']?: string;
14
14
  /**
15
15
  * @deprecated This prop has been deprecated and will be
16
16
  * removed in the next major release of Carbon. Use the
@@ -87,7 +87,6 @@ TableExpandRow.propTypes = {
87
87
  * Space separated list of one or more ID values referencing the TableExpandedRow(s) being controlled by the TableExpandRow
88
88
  * TODO: make this required in v12
89
89
  */
90
- /**@ts-ignore*/
91
90
  ['aria-controls']: PropTypes__default["default"].string,
92
91
  /**
93
92
  * Specify the string read by a voice reader when the expand trigger is
@@ -6,7 +6,16 @@
6
6
  */
7
7
  import { ReactNodeLike } from 'prop-types';
8
8
  import React, { type MouseEventHandler } from 'react';
9
+ import { sortStates } from './state/sorting';
9
10
  import { ReactAttr } from '../../types/common';
11
+ import { DataTableSortState } from './state/sortStates';
12
+ export type TableHeaderTranslationKey = 'carbon.table.header.icon.description';
13
+ export interface TableHeaderTranslationArgs {
14
+ header: React.ReactNode;
15
+ isSortHeader?: boolean;
16
+ sortDirection?: DataTableSortState;
17
+ sortStates: typeof sortStates;
18
+ }
10
19
  interface TableHeaderProps extends ReactAttr<HTMLTableCellElement & HTMLButtonElement> {
11
20
  /**
12
21
  * Pass in children that will be embedded in the table header label
@@ -58,7 +67,7 @@ interface TableHeaderProps extends ReactAttr<HTMLTableCellElement & HTMLButtonEl
58
67
  * choice. Translation keys are available on the `translationKeys` field for
59
68
  * this component.
60
69
  */
61
- translateWithId?: (key: string, { header, sortDirection, isSortHeader, sortStates }: {
70
+ translateWithId?: (key: TableHeaderTranslationKey, { header, sortDirection, isSortHeader, sortStates }: {
62
71
  header: any;
63
72
  sortDirection: any;
64
73
  isSortHeader: any;
@@ -16,7 +16,7 @@ import TableExpandHeader from './TableExpandHeader';
16
16
  import TableExpandRow from './TableExpandRow';
17
17
  import TableExpandedRow from './TableExpandedRow';
18
18
  import TableHead from './TableHead';
19
- import TableHeader from './TableHeader';
19
+ import TableHeader, { TableHeaderTranslationKey, TableHeaderTranslationArgs } from './TableHeader';
20
20
  import TableRow from './TableRow';
21
21
  import TableSelectAll from './TableSelectAll';
22
22
  import TableSelectRow from './TableSelectRow';
@@ -26,5 +26,6 @@ import TableToolbarAction from './TableToolbarAction';
26
26
  import TableToolbarContent from './TableToolbarContent';
27
27
  import TableToolbarSearch from './TableToolbarSearch';
28
28
  import TableToolbarMenu from './TableToolbarMenu';
29
- export { DataTable, type DataTableCell, type DataTableHeader, type DataTableProps, type DataTableRenderProps, type DataTableRow, type DataTableSize, Table, TableActionList, TableBatchAction, TableBatchActions, TableBody, TableCell, TableContainer, TableExpandHeader, TableExpandRow, TableExpandedRow, TableHead, TableHeader, TableRow, TableSelectAll, TableSelectRow, TableSlugRow, TableToolbar, TableToolbarAction, TableToolbarContent, TableToolbarSearch, TableToolbarMenu, };
29
+ import type { DataTableSortState } from './state/sortStates';
30
+ export { DataTable, type DataTableCell, type DataTableHeader, type DataTableProps, type DataTableRenderProps, type DataTableSortState, type DataTableRow, type DataTableSize, Table, TableActionList, TableBatchAction, TableBatchActions, TableBody, TableCell, TableContainer, TableExpandHeader, TableExpandRow, TableExpandedRow, TableHead, TableHeader, type TableHeaderTranslationKey, type TableHeaderTranslationArgs, TableRow, TableSelectAll, TableSelectRow, TableSlugRow, TableToolbar, TableToolbarAction, TableToolbarContent, TableToolbarSearch, TableToolbarMenu, };
30
31
  export default DataTable;
@@ -348,7 +348,7 @@ const DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Da
348
348
  }
349
349
  }
350
350
  function handleOnChange(event) {
351
- if (datePickerType == 'single') {
351
+ if (datePickerType == 'single' && closeOnSelect) {
352
352
  calendar.calendarContainer.classList.remove('open');
353
353
  }
354
354
  const {
@@ -413,7 +413,8 @@ const DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Da
413
413
  end.removeEventListener('change', handleOnChange);
414
414
  }
415
415
  };
416
- }, [savedOnChange, savedOnClose, savedOnOpen, readOnly, hasInput]); //eslint-disable-line react-hooks/exhaustive-deps
416
+ // eslint-disable-next-line react-hooks/exhaustive-deps
417
+ }, [savedOnChange, savedOnClose, savedOnOpen, readOnly, closeOnSelect, hasInput]);
417
418
 
418
419
  // this hook allows consumers to access the flatpickr calendar
419
420
  // instance for cases where functions like open() or close()
@@ -7,7 +7,7 @@
7
7
  import React, { ReactNode } from 'react';
8
8
  import { UseSelectProps } from 'downshift';
9
9
  import { ReactNodeLike } from 'prop-types';
10
- import { ListBoxSize, ListBoxType } from '../ListBox';
10
+ import { type ListBoxMenuIconTranslationKey, ListBoxSize, ListBoxType } from '../ListBox';
11
11
  import { ReactAttr } from '../../types/common';
12
12
  type ExcludedAttributes = 'id' | 'onChange';
13
13
  export interface OnChangeData<ItemType> {
@@ -123,7 +123,7 @@ export interface DropdownProps<ItemType> extends Omit<ReactAttr<HTMLDivElement>,
123
123
  /**
124
124
  * Callback function for translating ListBoxMenuIcon SVG title
125
125
  */
126
- translateWithId?(messageId: string, args?: Record<string, unknown>): string;
126
+ translateWithId?(messageId: ListBoxMenuIconTranslationKey, args?: Record<string, unknown>): string;
127
127
  /**
128
128
  * The dropdown type, `default` or `inline`
129
129
  */
@@ -137,6 +137,7 @@ export interface DropdownProps<ItemType> extends Omit<ReactAttr<HTMLDivElement>,
137
137
  */
138
138
  warnText?: React.ReactNode;
139
139
  }
140
+ export type DropdownTranslationKey = ListBoxMenuIconTranslationKey;
140
141
  type DropdownComponentProps<ItemType> = React.PropsWithoutRef<React.PropsWithChildren<DropdownProps<ItemType>> & React.RefAttributes<HTMLButtonElement>>;
141
142
  interface DropdownComponent {
142
143
  <ItemType>(props: DropdownComponentProps<ItemType>): React.ReactElement | null;
@@ -4,8 +4,8 @@
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import Dropdown, { OnChangeData } from './Dropdown';
8
- export type { OnChangeData };
7
+ import Dropdown, { type DropdownTranslationKey, type OnChangeData } from './Dropdown';
8
+ export type { DropdownTranslationKey, OnChangeData };
9
9
  export { Dropdown };
10
10
  export { default as DropdownSkeleton } from './Dropdown.Skeleton';
11
11
  export default Dropdown;
@@ -40,10 +40,13 @@ function ExpandableSearch(_ref) {
40
40
  const prefix = usePrefix.usePrefix();
41
41
  function handleBlur(evt) {
42
42
  const relatedTargetIsAllowed = evt.relatedTarget && evt.relatedTarget.classList.contains(`${prefix}--search-close`);
43
- if (expanded && !relatedTargetIsAllowed && !hasContent) {
43
+ if (expanded && !relatedTargetIsAllowed && !hasContent && !isExpanded) {
44
44
  setExpanded(false);
45
45
  }
46
46
  }
47
+ React.useEffect(() => {
48
+ setExpanded(!!isExpanded);
49
+ }, [isExpanded]);
47
50
  function handleChange(evt) {
48
51
  setHasContent(evt.target.value !== '');
49
52
  }
@@ -56,7 +59,7 @@ function ExpandableSearch(_ref) {
56
59
  evt.stopPropagation();
57
60
 
58
61
  // escape key only clears if the input is empty, otherwise it clears the input
59
- if (!evt.target?.value) {
62
+ if (!evt.target?.value && !isExpanded) {
60
63
  setExpanded(false);
61
64
  }
62
65
  }
@@ -0,0 +1,70 @@
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 { ReactNodeLike } from 'prop-types';
8
+ import React from 'react';
9
+ import { ButtonSize } from '../Button';
10
+ export declare const IconButtonKinds: readonly ["primary", "secondary", "ghost", "tertiary"];
11
+ export type IconButtonKind = (typeof IconButtonKinds)[number];
12
+ interface IconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
13
+ /**
14
+ * Specify how the trigger should align with the tooltip
15
+ */
16
+ align?: 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right' | 'left' | 'right';
17
+ /**
18
+ * Provide an icon or asset to be rendered inside of the IconButton
19
+ */
20
+ children?: React.ReactNode;
21
+ /**
22
+ * Specify an optional className to be added to your Button
23
+ */
24
+ className?: string;
25
+ /**
26
+ * Determines whether the tooltip should close when inner content is activated (click, Enter or Space)
27
+ */
28
+ closeOnActivation?: boolean;
29
+ /**
30
+ * Specify whether the tooltip should be open when it first renders
31
+ */
32
+ defaultOpen?: boolean;
33
+ /**
34
+ * Specify whether the Button should be disabled, or not
35
+ */
36
+ disabled?: boolean;
37
+ /**
38
+ * Specify the duration in milliseconds to delay before displaying the tooltip
39
+ */
40
+ enterDelayMs?: number;
41
+ /**
42
+ * Specify whether the IconButton is currently selected
43
+ */
44
+ isSelected?: boolean;
45
+ /**
46
+ * Specify the type of button to be used as the base for the IconButton
47
+ */
48
+ kind?: IconButtonKind;
49
+ /**
50
+ * Provide the label to be rendered inside of the Tooltip. The label will use
51
+ * `aria-labelledby` and will fully describe the child node that is provided.
52
+ * This means that if you have text in the child node it will not be
53
+ * announced to the screen reader.
54
+ */
55
+ label: ReactNodeLike;
56
+ /**
57
+ * Specify the duration in milliseconds to delay before hiding the tooltip
58
+ */
59
+ leaveDelayMs?: number;
60
+ /**
61
+ * Specify the size of the Button. Defaults to `md`.
62
+ */
63
+ size?: ButtonSize;
64
+ /**
65
+ * Specify an optional className to be added to your Tooltip wrapper
66
+ */
67
+ wrapperClasses?: string;
68
+ }
69
+ declare const IconButton: React.ForwardRefExoticComponent<IconButtonProps & React.RefAttributes<unknown>>;
70
+ export { IconButton };
@@ -25,8 +25,9 @@ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
25
25
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
26
26
  var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
27
27
 
28
- const IconButton = /*#__PURE__*/React__default["default"].forwardRef(function IconButton(props, ref) {
29
- const {
28
+ const IconButtonKinds = ['primary', 'secondary', 'ghost', 'tertiary'];
29
+ const IconButton = /*#__PURE__*/React__default["default"].forwardRef(function IconButton(_ref, ref) {
30
+ let {
30
31
  align,
31
32
  children,
32
33
  className,
@@ -41,7 +42,7 @@ const IconButton = /*#__PURE__*/React__default["default"].forwardRef(function Ic
41
42
  size,
42
43
  isSelected,
43
44
  ...rest
44
- } = props;
45
+ } = _ref;
45
46
  const prefix = usePrefix.usePrefix();
46
47
  const tooltipClasses = cx__default["default"](wrapperClasses, `${prefix}--icon-tooltip`, {
47
48
  [`${prefix}--icon-tooltip--disabled`]: disabled
@@ -101,7 +102,7 @@ IconButton.propTypes = {
101
102
  /**
102
103
  * Specify the type of button to be used as the base for the IconButton
103
104
  */
104
- kind: PropTypes__default["default"].oneOf(['primary', 'secondary', 'ghost', 'tertiary']),
105
+ kind: PropTypes__default["default"].oneOf(IconButtonKinds),
105
106
  /**
106
107
  * Provide the label to be rendered inside of the Tooltip. The label will use
107
108
  * `aria-labelledby` and will fully describe the child node that is provided.
@@ -124,3 +125,4 @@ IconButton.propTypes = {
124
125
  };
125
126
 
126
127
  exports.IconButton = IconButton;
128
+ exports.IconButtonKinds = IconButtonKinds;
@@ -5,10 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import React from 'react';
8
- export declare const translationIds: {
9
- 'close.menu': string;
10
- 'open.menu': string;
11
- };
8
+ export type ListBoxMenuIconTranslationKey = 'close.menu' | 'open.menu';
12
9
  export interface ListBoxMenuIconProps {
13
10
  /**
14
11
  * Specify whether the menu is currently open, which will influence the
@@ -17,10 +14,10 @@ export interface ListBoxMenuIconProps {
17
14
  isOpen: boolean;
18
15
  /**
19
16
  * i18n hook used to provide the appropriate description for the given menu
20
- * icon. This function takes in an id defined in `translationIds` and should
17
+ * icon. This function takes in a ListBoxMenuIconTranslationKey and should
21
18
  * return a string message for that given message id.
22
19
  */
23
- translateWithId?(messageId: string, args?: Record<string, unknown>): string;
20
+ translateWithId?(messageId: ListBoxMenuIconTranslationKey, args?: Record<string, unknown>): string;
24
21
  }
25
22
  export type ListBoxMenuIconComponent = React.FC<ListBoxMenuIconProps>;
26
23
  /**
@@ -21,13 +21,9 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
21
21
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
22
22
  var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
23
23
 
24
- const translationIds = {
25
- 'close.menu': 'close.menu',
26
- 'open.menu': 'open.menu'
27
- };
28
24
  const defaultTranslations = {
29
- [translationIds['close.menu']]: 'Close menu',
30
- [translationIds['open.menu']]: 'Open menu'
25
+ 'close.menu': 'Close menu',
26
+ 'open.menu': 'Open menu'
31
27
  };
32
28
  const defaultTranslateWithId = id => defaultTranslations[id];
33
29
  /**
@@ -59,11 +55,10 @@ ListBoxMenuIcon.propTypes = {
59
55
  isOpen: PropTypes__default["default"].bool.isRequired,
60
56
  /**
61
57
  * i18n hook used to provide the appropriate description for the given menu
62
- * icon. This function takes in an id defined in `translationIds` and should
58
+ * icon. This function takes a ListBoxMenuIconTranslationKey and should
63
59
  * return a string message for that given message id.
64
60
  */
65
61
  translateWithId: PropTypes__default["default"].func
66
62
  };
67
63
 
68
64
  exports["default"] = ListBoxMenuIcon;
69
- exports.translationIds = translationIds;
@@ -21,3 +21,4 @@ export interface ListBoxComponent extends ListBoxPartialComponent {
21
21
  }
22
22
  declare const ListBox: ListBoxComponent;
23
23
  export default ListBox;
24
+ export type { ListBoxMenuIconTranslationKey } from './ListBoxMenuIcon';
@@ -11,7 +11,7 @@ import { InlineLoadingStatus } from '../InlineLoading/InlineLoading';
11
11
  export declare const ModalSizes: readonly ["xs", "sm", "md", "lg"];
12
12
  export type ModalSize = (typeof ModalSizes)[number];
13
13
  export interface ModalSecondaryButton {
14
- buttonText?: string;
14
+ buttonText?: string | React.ReactNode;
15
15
  onClick?: React.MouseEventHandler<HTMLButtonElement>;
16
16
  }
17
17
  export interface ModalProps extends ReactAttr<HTMLDivElement> {
@@ -23,6 +23,7 @@ var requiredIfGivenPropIsTruthy = require('../../prop-types/requiredIfGivenPropI
23
23
  var wrapFocus = require('../../internal/wrapFocus.js');
24
24
  var setupGetInstanceId = require('../../tools/setupGetInstanceId.js');
25
25
  var usePrefix = require('../../internal/usePrefix.js');
26
+ var index = require('../IconButton/index.js');
26
27
  var noopFn = require('../../internal/noopFn.js');
27
28
  require('../Text/index.js');
28
29
  var Text = require('../Text/Text.js');
@@ -61,7 +62,7 @@ const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_
61
62
  shouldSubmitOnEnter,
62
63
  size,
63
64
  hasScrollingContent = false,
64
- closeButtonLabel,
65
+ closeButtonLabel = 'Close',
65
66
  preventCloseOnClickOutside = false,
66
67
  isFullWidth,
67
68
  launcherButtonRef,
@@ -211,19 +212,22 @@ const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_
211
212
  size: 'lg'
212
213
  });
213
214
  }
214
- const modalButton = /*#__PURE__*/React__default["default"].createElement("button", {
215
+ const modalButton = /*#__PURE__*/React__default["default"].createElement("div", {
216
+ className: `${prefix}--modal-close-button`
217
+ }, /*#__PURE__*/React__default["default"].createElement(index.IconButton, {
215
218
  className: modalCloseButtonClass,
216
- type: "button",
219
+ label: closeButtonLabel,
217
220
  onClick: onRequestClose,
218
- title: ariaLabel,
219
- "aria-label": closeButtonLabel ? closeButtonLabel : 'close',
221
+ title: closeButtonLabel,
222
+ "aria-label": closeButtonLabel,
223
+ align: "left",
220
224
  ref: button
221
225
  }, /*#__PURE__*/React__default["default"].createElement(iconsReact.Close, {
222
226
  size: 20,
223
227
  "aria-hidden": "true",
224
228
  tabIndex: "-1",
225
229
  className: `${modalCloseButtonClass}__icon`
226
- }));
230
+ })));
227
231
  const modalBody = /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
228
232
  ref: innerModal,
229
233
  role: "dialog"
@@ -32,6 +32,7 @@ const TreeNode = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
32
32
  className,
33
33
  depth,
34
34
  disabled,
35
+ id: nodeId,
35
36
  isExpanded,
36
37
  label,
37
38
  onNodeFocusEvent,
@@ -45,7 +46,7 @@ const TreeNode = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
45
46
  } = _ref;
46
47
  const {
47
48
  current: id
48
- } = React.useRef(rest.id || uniqueId["default"]());
49
+ } = React.useRef(nodeId || uniqueId["default"]());
49
50
  const [expanded, setExpanded] = React.useState(isExpanded);
50
51
  const currentNode = React.useRef(null);
51
52
  const currentNodeLabel = React.useRef(null);
@@ -256,7 +257,8 @@ const TreeNode = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
256
257
  });
257
258
  TreeNode.propTypes = {
258
259
  /**
259
- * The value of the active node in the tree
260
+ * **Note:** this is controlled by the parent TreeView component, do not set manually.
261
+ * The ID of the active node in the tree
260
262
  */
261
263
  active: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].number]),
262
264
  /**
@@ -268,13 +270,18 @@ TreeNode.propTypes = {
268
270
  */
269
271
  className: PropTypes__default["default"].string,
270
272
  /**
271
- * TreeNode depth to determine spacing, automatically calculated by default
273
+ * * **Note:** this is controlled by the parent TreeView component, do not set manually.
274
+ * TreeNode depth to determine spacing
272
275
  */
273
276
  depth: PropTypes__default["default"].number,
274
277
  /**
275
278
  * Specify if the TreeNode is disabled
276
279
  */
277
280
  disabled: PropTypes__default["default"].bool,
281
+ /**
282
+ * Specify the TreeNode's ID. Must be unique in the DOM and is used for props.active and props.selected
283
+ */
284
+ id: PropTypes__default["default"].string,
278
285
  /**
279
286
  * Specify if the TreeNode is expanded (only applicable to parent nodes)
280
287
  */
@@ -305,6 +312,7 @@ TreeNode.propTypes = {
305
312
  */
306
313
  renderIcon: PropTypes__default["default"].oneOfType([PropTypes__default["default"].func, PropTypes__default["default"].object]),
307
314
  /**
315
+ * **Note:** this is controlled by the parent TreeView component, do not set manually.
308
316
  * Array containing all selected node IDs in the tree
309
317
  */
310
318
  selected: PropTypes__default["default"].arrayOf(PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].number])),
@@ -202,7 +202,7 @@ function TreeView(_ref) {
202
202
  }
203
203
  TreeView.propTypes = {
204
204
  /**
205
- * Mark the active node in the tree, represented by its value
205
+ * Mark the active node in the tree, represented by its ID
206
206
  */
207
207
  active: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].number]),
208
208
  /**
@@ -158,7 +158,7 @@ class HeaderMenu extends React__default["default"].Component {
158
158
  onKeyDown,
159
159
  ...rest
160
160
  } = this.props;
161
- const hasActiveDescendant = childrenArg => React__default["default"].Children.toArray(childrenArg).some(child => child.props.isActive || child.props.isCurrentPage || child.props.children instanceof Array && hasActiveDescendant(child.props.children));
161
+ const hasActiveDescendant = childrenArg => React__default["default"].Children.toArray(childrenArg).some(child => child.props && (child.props.isActive || child.props.isCurrentPage || child.props.children instanceof Array && hasActiveDescendant(child.props.children)));
162
162
  const accessibilityLabel = {
163
163
  'aria-label': ariaLabel,
164
164
  'aria-labelledby': ariaLabelledBy
@@ -23,6 +23,10 @@ interface BaseSwitcherItemProps {
23
23
  * event handlers
24
24
  */
25
25
  onKeyDown?: (event: KeyboardEvent) => void;
26
+ /**
27
+ * event handlers
28
+ */
29
+ onClick?: (event: MouseEvent) => void;
26
30
  /**
27
31
  * Specify the tab index of the Link
28
32
  */
@@ -98,6 +98,10 @@ SwitcherItem.propTypes = {
98
98
  * Specify the index of the SwitcherItem
99
99
  */
100
100
  index: PropTypes__default["default"].number,
101
+ /**
102
+ * event handlers
103
+ */
104
+ onClick: PropTypes__default["default"].func,
101
105
  /**
102
106
  * event handlers
103
107
  */
package/lib/index.js CHANGED
@@ -394,6 +394,7 @@ exports.unstable_useFeatureFlags = index.useFeatureFlags;
394
394
  exports.Heading = index$d.Heading;
395
395
  exports.Section = index$d.Section;
396
396
  exports.IconButton = index$e.IconButton;
397
+ exports.IconButtonKinds = index$e.IconButtonKinds;
397
398
  exports.Layer = index$f.Layer;
398
399
  exports.useLayer = index$f.useLayer;
399
400
  exports.unstable_Layout = index$1.Layout;
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.47.0-rc.0",
4
+ "version": "1.48.0-rc.0",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -49,13 +49,13 @@
49
49
  "dependencies": {
50
50
  "@babel/runtime": "^7.18.3",
51
51
  "@carbon/feature-flags": "^0.16.0",
52
- "@carbon/icons-react": "^11.33.0",
52
+ "@carbon/icons-react": "^11.34.0-rc.0",
53
53
  "@carbon/layout": "^11.20.0",
54
- "@carbon/styles": "^1.47.0-rc.0",
54
+ "@carbon/styles": "^1.48.0-rc.0",
55
55
  "@ibm/telemetry-js": "^1.1.0",
56
- "classnames": "2.5.0",
56
+ "classnames": "2.5.1",
57
57
  "copy-to-clipboard": "^3.3.1",
58
- "downshift": "8.2.4",
58
+ "downshift": "8.3.1",
59
59
  "flatpickr": "4.6.9",
60
60
  "invariant": "^2.2.3",
61
61
  "lodash.debounce": "^4.0.8",
@@ -79,7 +79,7 @@
79
79
  "@babel/preset-react": "^7.22.3",
80
80
  "@babel/preset-typescript": "^7.21.5",
81
81
  "@carbon/test-utils": "^10.30.0",
82
- "@carbon/themes": "^11.28.0",
82
+ "@carbon/themes": "^11.29.0-rc.0",
83
83
  "@rollup/plugin-babel": "^6.0.0",
84
84
  "@rollup/plugin-commonjs": "^25.0.0",
85
85
  "@rollup/plugin-node-resolve": "^15.0.0",
@@ -139,5 +139,5 @@
139
139
  "**/*.scss",
140
140
  "**/*.css"
141
141
  ],
142
- "gitHead": "c5ffdecd6cac213d5edc6aef7ab9157db1ca17e9"
142
+ "gitHead": "5eb449df62a21a69a467895cb94d758ba8554620"
143
143
  }