@carbon/react 1.62.1 → 1.63.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 (104) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +836 -836
  2. package/es/components/Checkbox/Checkbox.js +2 -3
  3. package/es/components/CheckboxGroup/CheckboxGroup.js +2 -3
  4. package/es/components/ComboBox/ComboBox.d.ts +10 -6
  5. package/es/components/ComboBox/ComboBox.js +14 -4
  6. package/es/components/ComboButton/index.d.ts +9 -6
  7. package/es/components/ComboButton/index.js +5 -0
  8. package/es/components/DataTable/DataTable.d.ts +25 -11
  9. package/es/components/DataTable/DataTable.js +6 -1
  10. package/es/components/DataTable/TableBatchActions.d.ts +2 -2
  11. package/es/components/DataTable/TableHeader.d.ts +7 -13
  12. package/es/components/DataTable/TableSelectRow.js +3 -2
  13. package/es/components/DataTable/TableToolbarSearch.d.ts +5 -2
  14. package/es/components/DataTable/TableToolbarSearch.js +7 -4
  15. package/es/components/DatePickerInput/DatePickerInput.js +2 -3
  16. package/es/components/Dropdown/Dropdown.d.ts +2 -6
  17. package/es/components/Dropdown/Dropdown.js +3 -6
  18. package/es/components/FluidSearch/FluidSearch.Skeleton.js +40 -0
  19. package/es/components/FluidSearch/FluidSearch.js +96 -0
  20. package/es/components/FormGroup/FormGroup.d.ts +9 -1
  21. package/es/components/FormGroup/FormGroup.js +8 -1
  22. package/es/components/ListBox/ListBoxMenuIcon.d.ts +2 -7
  23. package/es/components/ListBox/ListBoxSelection.d.ts +8 -9
  24. package/es/components/ListBox/ListBoxSelection.js +5 -0
  25. package/es/components/Modal/Modal.js +2 -3
  26. package/es/components/MultiSelect/FilterableMultiSelect.d.ts +10 -5
  27. package/es/components/MultiSelect/FilterableMultiSelect.js +20 -8
  28. package/es/components/MultiSelect/MultiSelect.d.ts +2 -2
  29. package/es/components/MultiSelect/MultiSelect.js +11 -11
  30. package/es/components/NumberInput/NumberInput.d.ts +8 -7
  31. package/es/components/NumberInput/NumberInput.js +5 -0
  32. package/es/components/Pagination/experimental/PageSelector.js +2 -3
  33. package/es/components/PaginationNav/PaginationNav.d.ts +13 -6
  34. package/es/components/PaginationNav/PaginationNav.js +5 -0
  35. package/es/components/ProgressIndicator/ProgressIndicator.d.ts +12 -6
  36. package/es/components/ProgressIndicator/ProgressIndicator.js +5 -0
  37. package/es/components/RadioButtonGroup/RadioButtonGroup.js +2 -5
  38. package/es/components/Select/Select.js +3 -6
  39. package/es/components/Slider/Slider.d.ts +11 -9
  40. package/es/components/Slider/Slider.js +6 -1
  41. package/es/components/Tag/DismissibleTag.js +2 -3
  42. package/es/components/Tag/OperationalTag.js +2 -3
  43. package/es/components/Tag/SelectableTag.js +2 -3
  44. package/es/components/Tag/Tag.js +3 -5
  45. package/es/components/TextArea/TextArea.js +32 -6
  46. package/es/components/TextInput/ControlledPasswordInput.js +3 -6
  47. package/es/components/TextInput/TextInput.js +29 -2
  48. package/es/index.d.ts +1 -0
  49. package/es/index.js +2 -0
  50. package/es/internal/Selection.js +1 -1
  51. package/es/internal/useAnnouncer.js +8 -3
  52. package/es/types/common.d.ts +6 -1
  53. package/lib/components/Checkbox/Checkbox.js +2 -3
  54. package/lib/components/CheckboxGroup/CheckboxGroup.js +2 -3
  55. package/lib/components/ComboBox/ComboBox.d.ts +10 -6
  56. package/lib/components/ComboBox/ComboBox.js +14 -4
  57. package/lib/components/ComboButton/index.d.ts +9 -6
  58. package/lib/components/ComboButton/index.js +5 -0
  59. package/lib/components/DataTable/DataTable.d.ts +25 -11
  60. package/lib/components/DataTable/DataTable.js +6 -1
  61. package/lib/components/DataTable/TableBatchActions.d.ts +2 -2
  62. package/lib/components/DataTable/TableHeader.d.ts +7 -13
  63. package/lib/components/DataTable/TableSelectRow.js +2 -1
  64. package/lib/components/DataTable/TableToolbarSearch.d.ts +5 -2
  65. package/lib/components/DataTable/TableToolbarSearch.js +6 -3
  66. package/lib/components/DatePickerInput/DatePickerInput.js +2 -3
  67. package/lib/components/Dropdown/Dropdown.d.ts +2 -6
  68. package/lib/components/Dropdown/Dropdown.js +2 -5
  69. package/lib/components/FluidSearch/FluidSearch.Skeleton.js +50 -0
  70. package/lib/components/FluidSearch/FluidSearch.js +106 -0
  71. package/lib/components/FormGroup/FormGroup.d.ts +9 -1
  72. package/lib/components/FormGroup/FormGroup.js +8 -1
  73. package/lib/components/ListBox/ListBoxMenuIcon.d.ts +2 -7
  74. package/lib/components/ListBox/ListBoxSelection.d.ts +8 -9
  75. package/lib/components/ListBox/ListBoxSelection.js +5 -0
  76. package/lib/components/Modal/Modal.js +2 -3
  77. package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +10 -5
  78. package/lib/components/MultiSelect/FilterableMultiSelect.js +19 -7
  79. package/lib/components/MultiSelect/MultiSelect.d.ts +2 -2
  80. package/lib/components/MultiSelect/MultiSelect.js +10 -10
  81. package/lib/components/NumberInput/NumberInput.d.ts +8 -7
  82. package/lib/components/NumberInput/NumberInput.js +5 -0
  83. package/lib/components/Pagination/experimental/PageSelector.js +2 -3
  84. package/lib/components/PaginationNav/PaginationNav.d.ts +13 -6
  85. package/lib/components/PaginationNav/PaginationNav.js +5 -0
  86. package/lib/components/ProgressIndicator/ProgressIndicator.d.ts +12 -6
  87. package/lib/components/ProgressIndicator/ProgressIndicator.js +5 -0
  88. package/lib/components/RadioButtonGroup/RadioButtonGroup.js +2 -5
  89. package/lib/components/Select/Select.js +2 -5
  90. package/lib/components/Slider/Slider.d.ts +11 -9
  91. package/lib/components/Slider/Slider.js +6 -1
  92. package/lib/components/Tag/DismissibleTag.js +2 -3
  93. package/lib/components/Tag/OperationalTag.js +2 -3
  94. package/lib/components/Tag/SelectableTag.js +2 -3
  95. package/lib/components/Tag/Tag.js +3 -5
  96. package/lib/components/TextArea/TextArea.js +32 -6
  97. package/lib/components/TextInput/ControlledPasswordInput.js +2 -5
  98. package/lib/components/TextInput/TextInput.js +28 -1
  99. package/lib/index.d.ts +1 -0
  100. package/lib/index.js +4 -0
  101. package/lib/internal/Selection.js +1 -1
  102. package/lib/internal/useAnnouncer.js +8 -3
  103. package/lib/types/common.d.ts +6 -1
  104. package/package.json +18 -18
@@ -12,11 +12,10 @@ import cx from 'classnames';
12
12
  import '../Text/index.js';
13
13
  import { usePrefix } from '../../internal/usePrefix.js';
14
14
  import { WarningFilled, WarningAltFilled } from '@carbon/icons-react';
15
- import setupGetInstanceId from '../../tools/setupGetInstanceId.js';
15
+ import { useId } from '../../internal/useId.js';
16
16
  import { noopFn } from '../../internal/noopFn.js';
17
17
  import { Text } from '../Text/Text.js';
18
18
 
19
- const getInstanceId = setupGetInstanceId();
20
19
  const Checkbox = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
21
20
  let {
22
21
  className,
@@ -39,7 +38,7 @@ const Checkbox = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
39
38
  const prefix = usePrefix();
40
39
  const showWarning = !readOnly && !invalid && warn;
41
40
  const showHelper = !invalid && !warn;
42
- const checkboxGroupInstanceId = getInstanceId();
41
+ const checkboxGroupInstanceId = useId();
43
42
  const helperId = !helperText ? undefined : `checkbox-helper-text-${checkboxGroupInstanceId}`;
44
43
  const helper = helperText ? /*#__PURE__*/React__default.createElement("div", {
45
44
  id: helperId,
@@ -11,9 +11,8 @@ import React__default from 'react';
11
11
  import cx from 'classnames';
12
12
  import { usePrefix } from '../../internal/usePrefix.js';
13
13
  import { WarningFilled, WarningAltFilled } from '@carbon/icons-react';
14
- import setupGetInstanceId from '../../tools/setupGetInstanceId.js';
14
+ import { useId } from '../../internal/useId.js';
15
15
 
16
- const getInstanceId = setupGetInstanceId();
17
16
  const CheckboxGroup = _ref => {
18
17
  let {
19
18
  children,
@@ -33,7 +32,7 @@ const CheckboxGroup = _ref => {
33
32
  const prefix = usePrefix();
34
33
  const showWarning = !readOnly && !invalid && warn;
35
34
  const showHelper = !invalid && !warn;
36
- const checkboxGroupInstanceId = getInstanceId();
35
+ const checkboxGroupInstanceId = useId();
37
36
  const helperId = !helperText ? undefined : `checkbox-group-helper-text-${checkboxGroupInstanceId}`;
38
37
  const helper = helperText ? /*#__PURE__*/React__default.createElement("div", {
39
38
  id: helperId,
@@ -7,13 +7,22 @@
7
7
  import { UseComboboxProps } from 'downshift';
8
8
  import { type ReactNode, type ComponentType, type ReactElement, type RefAttributes, type PropsWithChildren, type PropsWithRef, type InputHTMLAttributes, type MouseEvent } from 'react';
9
9
  import { ListBoxSize } from '../ListBox';
10
+ import { TranslateWithId } from '../../types/common';
10
11
  type ExcludedAttributes = 'id' | 'onChange' | 'onClick' | 'type' | 'size';
11
12
  interface OnChangeData<ItemType> {
12
13
  selectedItem: ItemType | null | undefined;
13
14
  inputValue?: string | null;
14
15
  }
16
+ /**
17
+ * Message ids that will be passed to translateWithId().
18
+ * Combination of message ids from ListBox/next/ListBoxSelection.js and
19
+ * ListBox/next/ListBoxTrigger.js, but we can't access those values directly
20
+ * because those components aren't Typescript. (If you try, TranslationKey
21
+ * ends up just being defined as "string".)
22
+ */
23
+ type TranslationKey = 'close.menu' | 'open.menu' | 'clear.all' | 'clear.selection';
15
24
  type ItemToStringHandler<ItemType> = (item: ItemType | null) => string;
16
- export interface ComboBoxProps<ItemType> extends Omit<InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes> {
25
+ export interface ComboBoxProps<ItemType> extends Omit<InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes>, TranslateWithId<TranslationKey> {
17
26
  /**
18
27
  * Specify whether or not the ComboBox should allow a value that is
19
28
  * not in the list to be entered in the input
@@ -150,11 +159,6 @@ export interface ComboBoxProps<ItemType> extends Omit<InputHTMLAttributes<HTMLIn
150
159
  * combobox via ARIA attributes.
151
160
  */
152
161
  titleText?: ReactNode;
153
- /**
154
- * Specify a custom translation function that takes in a message identifier
155
- * and returns the localized string for the message
156
- */
157
- translateWithId?: (id: string) => string;
158
162
  /**
159
163
  * Specify whether the control is currently in warning state
160
164
  */
@@ -13,7 +13,7 @@ import React__default, { forwardRef, useEffect, useContext, useRef, useState, us
13
13
  import '../Text/index.js';
14
14
  import { WarningFilled, WarningAltFilled, Checkmark } from '@carbon/icons-react';
15
15
  import ListBox from '../ListBox/index.js';
16
- import setupGetInstanceId from '../../tools/setupGetInstanceId.js';
16
+ import { useId } from '../../internal/useId.js';
17
17
  import mergeRefs from '../../tools/mergeRefs.js';
18
18
  import deprecate from '../../prop-types/deprecate.js';
19
19
  import { usePrefix } from '../../internal/usePrefix.js';
@@ -82,7 +82,15 @@ const findHighlightedIndex = (_ref2, inputValue) => {
82
82
  }
83
83
  return -1;
84
84
  };
85
- const getInstanceId = setupGetInstanceId();
85
+
86
+ /**
87
+ * Message ids that will be passed to translateWithId().
88
+ * Combination of message ids from ListBox/next/ListBoxSelection.js and
89
+ * ListBox/next/ListBoxTrigger.js, but we can't access those values directly
90
+ * because those components aren't Typescript. (If you try, TranslationKey
91
+ * ends up just being defined as "string".)
92
+ */
93
+
86
94
  const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
87
95
  const {
88
96
  ['aria-label']: ariaLabel = 'Choose an item',
@@ -144,7 +152,7 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
144
152
  isFluid
145
153
  } = useContext(FormContext);
146
154
  const textInput = useRef(null);
147
- const comboBoxInstanceId = getInstanceId();
155
+ const comboBoxInstanceId = useId();
148
156
  const [inputValue, setInputValue] = useState(getInputValue({
149
157
  initialSelectedItem,
150
158
  inputValue: '',
@@ -383,10 +391,12 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
383
391
  // when both the message is supplied *and* when the component is in
384
392
  // the matching state (invalid, warn, etc).
385
393
  const ariaDescribedBy = invalid && invalidText && invalidTextId || warn && warnText && warnTextId || helperText && !isFluid && helperTextId || undefined;
394
+
395
+ // Memoize the value of getMenuProps to avoid an infinite loop
386
396
  const menuProps = useMemo(() => getMenuProps({
387
397
  'aria-label': deprecatedAriaLabel || ariaLabel,
388
398
  ref: autoAlign ? refs.setFloating : null
389
- }), [autoAlign, deprecatedAriaLabel, ariaLabel]);
399
+ }), [autoAlign, deprecatedAriaLabel, ariaLabel, getMenuProps, refs.setFloating]);
390
400
  return /*#__PURE__*/React__default.createElement("div", {
391
401
  className: wrapperClasses
392
402
  }, titleText && /*#__PURE__*/React__default.createElement(Text, _extends({
@@ -9,7 +9,15 @@ import { IconButton } from '../IconButton';
9
9
  import Button from '../Button';
10
10
  import { Menu } from '../Menu';
11
11
  import { MenuAlignment } from '../MenuButton';
12
- interface ComboButtonProps {
12
+ import { TranslateWithId } from '../../types/common';
13
+ declare const defaultTranslations: {
14
+ 'carbon.combo-button.additional-actions': string;
15
+ };
16
+ /**
17
+ * Message ids that will be passed to translateWithId().
18
+ */
19
+ type TranslationKey = keyof typeof defaultTranslations;
20
+ interface ComboButtonProps extends TranslateWithId<TranslationKey> {
13
21
  /**
14
22
  * A collection of `MenuItems` to be rendered as additional actions for this `ComboButton`.
15
23
  */
@@ -42,11 +50,6 @@ interface ComboButtonProps {
42
50
  * Specify how the trigger tooltip should be aligned.
43
51
  */
44
52
  tooltipAlignment?: React.ComponentProps<typeof IconButton>['align'];
45
- /**
46
- * Optional method that takes in a message `id` and returns an
47
- * internationalized string.
48
- */
49
- translateWithId?: (id: string) => string;
50
53
  }
51
54
  declare const ComboButton: React.ForwardRefExoticComponent<ComboButtonProps & React.RefAttributes<HTMLDivElement>>;
52
55
  export { ComboButton, type ComboButtonProps };
@@ -25,6 +25,11 @@ var _ChevronDown;
25
25
  const defaultTranslations = {
26
26
  'carbon.combo-button.additional-actions': 'Additional actions'
27
27
  };
28
+
29
+ /**
30
+ * Message ids that will be passed to translateWithId().
31
+ */
32
+
28
33
  function defaultTranslateWithId(messageId) {
29
34
  return defaultTranslations[messageId];
30
35
  }
@@ -28,6 +28,21 @@ import TableToolbarAction from './TableToolbarAction';
28
28
  import TableToolbarContent from './TableToolbarContent';
29
29
  import TableToolbarSearch from './TableToolbarSearch';
30
30
  import TableToolbarMenu from './TableToolbarMenu';
31
+ import { TranslateWithId } from '../../types/common';
32
+ declare const translationKeys: {
33
+ readonly expandRow: "carbon.table.row.expand";
34
+ readonly collapseRow: "carbon.table.row.collapse";
35
+ readonly expandAll: "carbon.table.all.expand";
36
+ readonly collapseAll: "carbon.table.all.collapse";
37
+ readonly selectAll: "carbon.table.all.select";
38
+ readonly unselectAll: "carbon.table.all.unselect";
39
+ readonly selectRow: "carbon.table.row.select";
40
+ readonly unselectRow: "carbon.table.row.unselect";
41
+ };
42
+ /**
43
+ * Message ids that will be passed to translateWithId().
44
+ */
45
+ type TranslationKey = (typeof translationKeys)[keyof typeof translationKeys];
31
46
  export type DataTableSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
32
47
  export interface DataTableCell<T> {
33
48
  id: string;
@@ -168,7 +183,7 @@ export interface DataTableRenderProps<RowType, ColTypes extends any[]> {
168
183
  expandAll: () => void;
169
184
  radio: boolean | undefined;
170
185
  }
171
- export interface DataTableProps<RowType, ColTypes extends any[]> {
186
+ export interface DataTableProps<RowType, ColTypes extends any[]> extends TranslateWithId<TranslationKey> {
172
187
  children?: (renderProps: DataTableRenderProps<RowType, ColTypes>) => React.ReactElement;
173
188
  experimentalAutoAlign?: boolean;
174
189
  filterRows?: (filterRowsArgs: {
@@ -192,7 +207,6 @@ export interface DataTableProps<RowType, ColTypes extends any[]> {
192
207
  locale: string;
193
208
  }) => number;
194
209
  stickyHeader?: boolean;
195
- translateWithId?: (id: string) => string;
196
210
  useStaticWidth?: boolean;
197
211
  useZebraStyles?: boolean;
198
212
  }
@@ -295,7 +309,7 @@ declare class DataTable<RowType, ColTypes extends any[]> extends React.Component
295
309
  */
296
310
  useZebraStyles: PropTypes.Requireable<boolean>;
297
311
  };
298
- static translationKeys: string[];
312
+ static translationKeys: ("carbon.table.row.expand" | "carbon.table.row.collapse" | "carbon.table.all.expand" | "carbon.table.all.collapse" | "carbon.table.all.select" | "carbon.table.all.unselect" | "carbon.table.row.select" | "carbon.table.row.unselect")[];
299
313
  static Table: typeof Table;
300
314
  static TableActionList: typeof TableActionList;
301
315
  static TableBatchAction: typeof TableBatchAction;
@@ -360,8 +374,8 @@ declare class DataTable<RowType, ColTypes extends any[]> extends React.Component
360
374
  }) => void) | undefined;
361
375
  onExpand?: ((e: MouseEvent) => void) | undefined;
362
376
  }) => {
363
- ariaLabel: string;
364
- 'aria-label': string;
377
+ ariaLabel: any;
378
+ 'aria-label': any;
365
379
  'aria-controls': string;
366
380
  isExpanded: boolean;
367
381
  onExpand: any;
@@ -398,8 +412,8 @@ declare class DataTable<RowType, ColTypes extends any[]> extends React.Component
398
412
  key: string;
399
413
  onExpand: any;
400
414
  isExpanded: boolean | undefined;
401
- ariaLabel: string;
402
- 'aria-label': string;
415
+ ariaLabel: any;
416
+ 'aria-label': any;
403
417
  'aria-controls': string;
404
418
  isSelected: boolean | undefined;
405
419
  disabled: boolean | undefined;
@@ -436,13 +450,13 @@ declare class DataTable<RowType, ColTypes extends any[]> extends React.Component
436
450
  onSelect: any;
437
451
  id: string;
438
452
  name: string;
439
- ariaLabel: string;
440
- 'aria-label': string;
453
+ ariaLabel: any;
454
+ 'aria-label': any;
441
455
  disabled: boolean | undefined;
442
456
  radio: true | null;
443
457
  } | {
444
- ariaLabel: string;
445
- 'aria-label': string;
458
+ ariaLabel: any;
459
+ 'aria-label': any;
446
460
  checked: boolean;
447
461
  id: string;
448
462
  indeterminate: boolean;
@@ -8,7 +8,7 @@
8
8
  import { defineProperty as _defineProperty } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import PropTypes from 'prop-types';
10
10
  import React__default from 'react';
11
- import isEqual from 'lodash.isequal';
11
+ import isEqual from 'react-fast-compare';
12
12
  import getDerivedStateFromProps from './state/getDerivedStateFromProps.js';
13
13
  import { getNextSortState } from './state/sorting.js';
14
14
  import { getCellId } from './tools/cells.js';
@@ -49,6 +49,11 @@ const translationKeys = {
49
49
  selectRow: 'carbon.table.row.select',
50
50
  unselectRow: 'carbon.table.row.unselect'
51
51
  };
52
+
53
+ /**
54
+ * Message ids that will be passed to translateWithId().
55
+ */
56
+
52
57
  const defaultTranslations = {
53
58
  [translationKeys.expandAll]: 'Expand all rows',
54
59
  [translationKeys.collapseAll]: 'Collapse all rows',
@@ -5,14 +5,14 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import React, { type MouseEventHandler } from 'react';
8
- import type { InternationalProps } from '../../types/common';
8
+ import type { TranslateWithId } from '../../types/common';
9
9
  declare const TableBatchActionsTranslationKeys: readonly ["carbon.table.batch.cancel", "carbon.table.batch.items.selected", "carbon.table.batch.item.selected", "carbon.table.batch.selectAll"];
10
10
  export type TableBatchActionsTranslationKey = (typeof TableBatchActionsTranslationKeys)[number];
11
11
  export interface TableBatchActionsTranslationArgs {
12
12
  totalSelected?: number;
13
13
  totalCount?: number;
14
14
  }
15
- export interface TableBatchActionsProps extends React.HTMLAttributes<HTMLDivElement>, InternationalProps<TableBatchActionsTranslationKey, TableBatchActionsTranslationArgs> {
15
+ export interface TableBatchActionsProps extends React.HTMLAttributes<HTMLDivElement>, TranslateWithId<TableBatchActionsTranslationKey, TableBatchActionsTranslationArgs> {
16
16
  /**
17
17
  * Provide elements to be rendered inside of the component.
18
18
  */
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import React, { type MouseEventHandler, ReactNode } from 'react';
8
8
  import { sortStates } from './state/sorting';
9
- import { ReactAttr } from '../../types/common';
9
+ import { TranslateWithId, ReactAttr } from '../../types/common';
10
10
  import { DataTableSortState } from './state/sortStates';
11
11
  export type TableHeaderTranslationKey = 'carbon.table.header.icon.description';
12
12
  export interface TableHeaderTranslationArgs {
@@ -15,7 +15,12 @@ export interface TableHeaderTranslationArgs {
15
15
  sortDirection?: DataTableSortState;
16
16
  sortStates: typeof sortStates;
17
17
  }
18
- interface TableHeaderProps extends ReactAttr<HTMLTableCellElement & HTMLButtonElement> {
18
+ interface TableHeaderProps extends ReactAttr<HTMLTableCellElement & HTMLButtonElement>, TranslateWithId<TableHeaderTranslationKey, {
19
+ header: any;
20
+ sortDirection: any;
21
+ isSortHeader: any;
22
+ sortStates: any;
23
+ }> {
19
24
  /**
20
25
  * Pass in children that will be embedded in the table header label
21
26
  */
@@ -61,17 +66,6 @@ interface TableHeaderProps extends ReactAttr<HTMLTableCellElement & HTMLButtonEl
61
66
  * NONE, or ASC.
62
67
  */
63
68
  sortDirection?: string;
64
- /**
65
- * Supply a method to translate internal strings with your i18n tool of
66
- * choice. Translation keys are available on the `translationKeys` field for
67
- * this component.
68
- */
69
- translateWithId?: (key: TableHeaderTranslationKey, { header, sortDirection, isSortHeader, sortStates }: {
70
- header: any;
71
- sortDirection: any;
72
- isSortHeader: any;
73
- sortStates: any;
74
- }) => string;
75
69
  }
76
70
  declare const TableHeader: React.ForwardRefExoticComponent<TableHeaderProps & React.RefAttributes<HTMLTableCellElement>>;
77
71
  export default TableHeader;
@@ -7,7 +7,7 @@
7
7
 
8
8
  import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import PropTypes from 'prop-types';
10
- import React__default from 'react';
10
+ import React__default, { useId } from 'react';
11
11
  import cx from 'classnames';
12
12
  import InlineCheckbox from '../InlineCheckbox/InlineCheckbox.js';
13
13
  import RadioButton from '../RadioButton/RadioButton.js';
@@ -28,9 +28,10 @@ const TableSelectRow = _ref => {
28
28
  className
29
29
  } = _ref;
30
30
  const prefix = usePrefix();
31
+ const uniqueNameId = useId();
31
32
  const selectionInputProps = {
32
33
  id,
33
- name,
34
+ name: name ? name : uniqueNameId,
34
35
  onClick: onSelect,
35
36
  onChange,
36
37
  checked,
@@ -7,11 +7,14 @@
7
7
  import PropTypes from 'prop-types';
8
8
  import { ChangeEvent, FocusEvent, ReactNode } from 'react';
9
9
  import { SearchProps } from '../Search';
10
- import { InternationalProps } from '../../types/common';
10
+ import { TranslateWithId } from '../../types/common';
11
+ /**
12
+ * Message ids that will be passed to translateWithId().
13
+ */
11
14
  export type TableToolbarTranslationKey = 'carbon.table.toolbar.search.label' | 'carbon.table.toolbar.search.placeholder';
12
15
  type ExcludedInheritedProps = 'defaultValue' | 'labelText' | 'onBlur' | 'onChange' | 'onExpand' | 'onFocus' | 'tabIndex';
13
16
  export type TableToolbarSearchHandleExpand = (event: FocusEvent<HTMLInputElement>, newValue?: boolean) => void;
14
- export interface TableToolbarSearchProps extends Omit<SearchProps, ExcludedInheritedProps>, InternationalProps<TableToolbarTranslationKey> {
17
+ export interface TableToolbarSearchProps extends Omit<SearchProps, ExcludedInheritedProps>, TranslateWithId<TableToolbarTranslationKey> {
15
18
  /**
16
19
  * Specifies if the search should initially render in an expanded state
17
20
  */
@@ -8,14 +8,17 @@
8
8
  import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import cx from 'classnames';
10
10
  import PropTypes from 'prop-types';
11
- import React__default, { useRef, useState, useMemo, useEffect } from 'react';
11
+ import React__default, { useRef, useState, useEffect } from 'react';
12
12
  import Search from '../Search/Search.js';
13
13
  import '../Search/Search.Skeleton.js';
14
- import setupGetInstanceId from './tools/instanceId.js';
14
+ import { useId } from '../../internal/useId.js';
15
15
  import { usePrefix } from '../../internal/usePrefix.js';
16
16
  import { noopFn } from '../../internal/noopFn.js';
17
17
 
18
- const getInstanceId = setupGetInstanceId();
18
+ /**
19
+ * Message ids that will be passed to translateWithId().
20
+ */
21
+
19
22
  const translationKeys = {
20
23
  'carbon.table.toolbar.search.label': 'Filter table',
21
24
  'carbon.table.toolbar.search.placeholder': 'Filter table'
@@ -51,7 +54,7 @@ const TableToolbarSearch = _ref => {
51
54
  const [expandedState, setExpandedState] = useState(Boolean(defaultExpanded || defaultValue));
52
55
  const expanded = controlled ? expandedProp : expandedState;
53
56
  const [value, setValue] = useState(defaultValue || '');
54
- const uniqueId = useMemo(getInstanceId, []);
57
+ const uniqueId = useId();
55
58
  const [focusTarget, setFocusTarget] = useState(null);
56
59
  const prefix = usePrefix();
57
60
  useEffect(() => {
@@ -12,11 +12,10 @@ import React__default, { useContext } from 'react';
12
12
  import { usePrefix } from '../../internal/usePrefix.js';
13
13
  import '../FluidForm/FluidForm.js';
14
14
  import { FormContext } from '../FluidForm/FormContext.js';
15
- import setupGetInstanceId from '../../tools/setupGetInstanceId.js';
15
+ import { useId } from '../../internal/useId.js';
16
16
  import '../Text/index.js';
17
17
  import { Text } from '../Text/Text.js';
18
18
 
19
- const getInstanceId = setupGetInstanceId();
20
19
  const DatePickerInput = /*#__PURE__*/React__default.forwardRef(function DatePickerInput(props, ref) {
21
20
  const {
22
21
  datePickerType,
@@ -42,7 +41,7 @@ const DatePickerInput = /*#__PURE__*/React__default.forwardRef(function DatePick
42
41
  const {
43
42
  isFluid
44
43
  } = useContext(FormContext);
45
- const datePickerInputInstanceId = getInstanceId();
44
+ const datePickerInputInstanceId = useId();
46
45
  const datePickerInputProps = {
47
46
  id,
48
47
  onChange: event => {
@@ -7,12 +7,12 @@
7
7
  import React, { ReactNode } from 'react';
8
8
  import { UseSelectProps } from 'downshift';
9
9
  import { type ListBoxMenuIconTranslationKey, ListBoxSize, ListBoxType } from '../ListBox';
10
- import { ReactAttr } from '../../types/common';
10
+ import { TranslateWithId, ReactAttr } from '../../types/common';
11
11
  type ExcludedAttributes = 'id' | 'onChange';
12
12
  export interface OnChangeData<ItemType> {
13
13
  selectedItem: ItemType | null;
14
14
  }
15
- export interface DropdownProps<ItemType> extends Omit<ReactAttr<HTMLDivElement>, ExcludedAttributes> {
15
+ export interface DropdownProps<ItemType> extends Omit<ReactAttr<HTMLDivElement>, ExcludedAttributes>, TranslateWithId<ListBoxMenuIconTranslationKey> {
16
16
  /**
17
17
  * Specify a label to be read by screen readers on the container node
18
18
  * 'aria-label' of the ListBox component.
@@ -123,10 +123,6 @@ export interface DropdownProps<ItemType> extends Omit<ReactAttr<HTMLDivElement>,
123
123
  * visiting this control
124
124
  */
125
125
  titleText?: ReactNode;
126
- /**
127
- * Callback function for translating ListBoxMenuIcon SVG title
128
- */
129
- translateWithId?(messageId: ListBoxMenuIconTranslationKey, args?: Record<string, unknown>): string;
130
126
  /**
131
127
  * The dropdown type, `default` or `inline`
132
128
  */
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
- import React__default, { useEffect, useContext, useRef, useState, useMemo } from 'react';
9
+ import React__default, { useEffect, useContext, useState, useMemo } from 'react';
10
10
  import { useSelect } from 'downshift';
11
11
  import cx from 'classnames';
12
12
  import PropTypes from 'prop-types';
@@ -17,11 +17,10 @@ import deprecate from '../../prop-types/deprecate.js';
17
17
  import { usePrefix } from '../../internal/usePrefix.js';
18
18
  import '../FluidForm/FluidForm.js';
19
19
  import { FormContext } from '../FluidForm/FormContext.js';
20
- import setupGetInstanceId from '../../tools/setupGetInstanceId.js';
20
+ import { useId } from '../../internal/useId.js';
21
21
  import { useFloating, size, flip, autoUpdate } from '@floating-ui/react';
22
22
  import { ListBoxSize, ListBoxType } from '../ListBox/ListBoxPropTypes.js';
23
23
 
24
- const getInstanceId = setupGetInstanceId();
25
24
  const {
26
25
  ToggleButtonKeyDownArrowDown,
27
26
  ToggleButtonKeyDownArrowUp,
@@ -125,9 +124,7 @@ const Dropdown = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
125
124
  return isObject && 'disabled' in item && item.disabled === true;
126
125
  }
127
126
  };
128
- const {
129
- current: dropdownInstanceId
130
- } = useRef(getInstanceId());
127
+ const dropdownInstanceId = useId();
131
128
  function stateReducer(state, actionAndChanges) {
132
129
  const {
133
130
  changes,
@@ -0,0 +1,40 @@
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
+
8
+ import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
+ import PropTypes from 'prop-types';
10
+ import React__default from 'react';
11
+ import cx from 'classnames';
12
+ import { usePrefix } from '../../internal/usePrefix.js';
13
+ import { FormContext } from '../FluidForm/FormContext.js';
14
+
15
+ function FluidSearchSkeleton(_ref) {
16
+ let {
17
+ className,
18
+ ...other
19
+ } = _ref;
20
+ const prefix = usePrefix();
21
+ return /*#__PURE__*/React__default.createElement(FormContext.Provider, {
22
+ value: {
23
+ isFluid: true
24
+ }
25
+ }, /*#__PURE__*/React__default.createElement("div", _extends({
26
+ className: cx(`${prefix}--form-item ${prefix}--text-input--fluid__skeleton`, className)
27
+ }, other), /*#__PURE__*/React__default.createElement("span", {
28
+ className: `${prefix}--label ${prefix}--skeleton`
29
+ }), /*#__PURE__*/React__default.createElement("div", {
30
+ className: `${prefix}--skeleton ${prefix}--text-input`
31
+ })));
32
+ }
33
+ FluidSearchSkeleton.propTypes = {
34
+ /**
35
+ * Specify an optional className to be applied to the outer FluidForm wrapper
36
+ */
37
+ className: PropTypes.string
38
+ };
39
+
40
+ export { FluidSearchSkeleton as default };
@@ -0,0 +1,96 @@
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
+
8
+ import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
+ import PropTypes from 'prop-types';
10
+ import React__default from 'react';
11
+ import cx from 'classnames';
12
+ import Search from '../Search/Search.js';
13
+ import '../Search/Search.Skeleton.js';
14
+ import { usePrefix } from '../../internal/usePrefix.js';
15
+ import { FormContext } from '../FluidForm/FormContext.js';
16
+
17
+ const FluidSearch = /*#__PURE__*/React__default.forwardRef(function FluidSearch(_ref, ref) {
18
+ let {
19
+ className,
20
+ ...other
21
+ } = _ref;
22
+ const prefix = usePrefix();
23
+ const classNames = cx(`${prefix}--search--fluid`, className);
24
+ return /*#__PURE__*/React__default.createElement(FormContext.Provider, {
25
+ value: {
26
+ isFluid: true
27
+ }
28
+ }, /*#__PURE__*/React__default.createElement(Search, _extends({
29
+ ref: ref,
30
+ className: classNames
31
+ }, other)));
32
+ });
33
+ FluidSearch.propTypes = {
34
+ /**
35
+ * Specify an optional value for the `autocomplete` property on the underlying
36
+ * `<input>`, defaults to "off"
37
+ */
38
+ autoComplete: PropTypes.string,
39
+ /**
40
+ * Specify an optional className to be applied to the container node
41
+ */
42
+ className: PropTypes.string,
43
+ /**
44
+ * Specify a label to be read by screen readers on the "close" button
45
+ */
46
+ closeButtonLabelText: PropTypes.string,
47
+ /**
48
+ * Optionally provide the default value of the `<input>`
49
+ */
50
+ defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
51
+ /**
52
+ * Specify whether the `<input>` should be disabled
53
+ */
54
+ disabled: PropTypes.bool,
55
+ /**
56
+ * Specify a custom `id` for the input
57
+ */
58
+ id: PropTypes.string,
59
+ /**
60
+ * Provide the label text for the Search icon
61
+ */
62
+ labelText: PropTypes.node.isRequired,
63
+ /**
64
+ * Optional callback called when the search value changes.
65
+ */
66
+ onChange: PropTypes.func,
67
+ /**
68
+ * Optional callback called when the search value is cleared.
69
+ */
70
+ onClear: PropTypes.func,
71
+ /**
72
+ * Provide a handler that is invoked on the key down event for the input
73
+ */
74
+ onKeyDown: PropTypes.func,
75
+ /**
76
+ * Provide an optional placeholder text for the Search.
77
+ * Note: if the label and placeholder differ,
78
+ * VoiceOver on Mac will read both
79
+ */
80
+ placeholder: PropTypes.string,
81
+ /**
82
+ * Specify the role for the underlying `<input>`, defaults to `searchbox`
83
+ */
84
+ role: PropTypes.string,
85
+ /**
86
+ * Optional prop to specify the type of the `<input>`
87
+ */
88
+ type: PropTypes.string,
89
+ /**
90
+ * Specify the value of the `<input>`
91
+ */
92
+ value: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
93
+ };
94
+ var FluidSearch$1 = FluidSearch;
95
+
96
+ export { FluidSearch$1 as default };
@@ -16,6 +16,10 @@ export interface FormGroupProps extends ReactAttr<HTMLFieldSetElement> {
16
16
  * Provide a custom className to be applied to the containing <fieldset> node
17
17
  */
18
18
  className?: string;
19
+ /**
20
+ * Specify whether the FormGroup should be disabled
21
+ */
22
+ disabled?: boolean;
19
23
  /**
20
24
  * Specify whether the <FormGroup> is invalid
21
25
  */
@@ -39,7 +43,7 @@ export interface FormGroupProps extends ReactAttr<HTMLFieldSetElement> {
39
43
  messageText?: string;
40
44
  }
41
45
  declare const FormGroup: {
42
- ({ legendId, legendText, invalid, children, className, message, messageText, ...rest }: FormGroupProps): import("react/jsx-runtime").JSX.Element;
46
+ ({ disabled, legendId, legendText, invalid, children, className, message, messageText, ...rest }: FormGroupProps): import("react/jsx-runtime").JSX.Element;
43
47
  propTypes: {
44
48
  /**
45
49
  * Provide the children form elements to be rendered inside of the <fieldset>
@@ -49,6 +53,10 @@ declare const FormGroup: {
49
53
  * Provide a custom className to be applied to the containing <fieldset> node
50
54
  */
51
55
  className: PropTypes.Requireable<string>;
56
+ /**
57
+ * Specify whether the FormGroup should be disabled
58
+ */
59
+ disabled: PropTypes.Requireable<boolean>;
52
60
  /**
53
61
  * Specify whether the <FormGroup> is invalid
54
62
  */