@carbon/react 1.63.0-rc.0 → 1.63.1

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 (68) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +1043 -1014
  2. package/es/components/ComboBox/ComboBox.d.ts +14 -7
  3. package/es/components/ComboBox/ComboBox.js +31 -4
  4. package/es/components/ComboButton/index.d.ts +9 -6
  5. package/es/components/ComboButton/index.js +5 -0
  6. package/es/components/DataTable/DataTable.d.ts +25 -11
  7. package/es/components/DataTable/DataTable.js +5 -0
  8. package/es/components/DataTable/TableBatchActions.d.ts +2 -2
  9. package/es/components/DataTable/TableHeader.d.ts +7 -13
  10. package/es/components/DataTable/TableToolbarSearch.d.ts +5 -2
  11. package/es/components/DataTable/TableToolbarSearch.js +4 -0
  12. package/es/components/Dropdown/Dropdown.d.ts +6 -7
  13. package/es/components/Dropdown/Dropdown.js +23 -22
  14. package/es/components/FluidMultiSelect/FluidMultiSelect.js +4 -1
  15. package/es/components/FormGroup/FormGroup.d.ts +9 -1
  16. package/es/components/FormGroup/FormGroup.js +8 -1
  17. package/es/components/ListBox/ListBoxMenuIcon.d.ts +2 -7
  18. package/es/components/ListBox/ListBoxSelection.d.ts +8 -9
  19. package/es/components/ListBox/ListBoxSelection.js +5 -0
  20. package/es/components/MultiSelect/FilterableMultiSelect.d.ts +14 -6
  21. package/es/components/MultiSelect/FilterableMultiSelect.js +17 -5
  22. package/es/components/MultiSelect/MultiSelect.d.ts +6 -3
  23. package/es/components/MultiSelect/MultiSelect.js +7 -4
  24. package/es/components/NumberInput/NumberInput.d.ts +8 -7
  25. package/es/components/NumberInput/NumberInput.js +5 -0
  26. package/es/components/PaginationNav/PaginationNav.d.ts +13 -6
  27. package/es/components/PaginationNav/PaginationNav.js +5 -0
  28. package/es/components/ProgressIndicator/ProgressIndicator.d.ts +12 -6
  29. package/es/components/ProgressIndicator/ProgressIndicator.js +5 -0
  30. package/es/components/Slider/Slider.d.ts +11 -9
  31. package/es/components/Slider/Slider.js +6 -1
  32. package/es/internal/Selection.js +1 -1
  33. package/es/internal/useId.js +39 -18
  34. package/es/types/common.d.ts +6 -1
  35. package/lib/components/ComboBox/ComboBox.d.ts +14 -7
  36. package/lib/components/ComboBox/ComboBox.js +31 -4
  37. package/lib/components/ComboButton/index.d.ts +9 -6
  38. package/lib/components/ComboButton/index.js +5 -0
  39. package/lib/components/DataTable/DataTable.d.ts +25 -11
  40. package/lib/components/DataTable/DataTable.js +5 -0
  41. package/lib/components/DataTable/TableBatchActions.d.ts +2 -2
  42. package/lib/components/DataTable/TableHeader.d.ts +7 -13
  43. package/lib/components/DataTable/TableToolbarSearch.d.ts +5 -2
  44. package/lib/components/DataTable/TableToolbarSearch.js +4 -0
  45. package/lib/components/Dropdown/Dropdown.d.ts +6 -7
  46. package/lib/components/Dropdown/Dropdown.js +23 -22
  47. package/lib/components/FluidMultiSelect/FluidMultiSelect.js +4 -1
  48. package/lib/components/FormGroup/FormGroup.d.ts +9 -1
  49. package/lib/components/FormGroup/FormGroup.js +8 -1
  50. package/lib/components/ListBox/ListBoxMenuIcon.d.ts +2 -7
  51. package/lib/components/ListBox/ListBoxSelection.d.ts +8 -9
  52. package/lib/components/ListBox/ListBoxSelection.js +5 -0
  53. package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +14 -6
  54. package/lib/components/MultiSelect/FilterableMultiSelect.js +17 -5
  55. package/lib/components/MultiSelect/MultiSelect.d.ts +6 -3
  56. package/lib/components/MultiSelect/MultiSelect.js +7 -4
  57. package/lib/components/NumberInput/NumberInput.d.ts +8 -7
  58. package/lib/components/NumberInput/NumberInput.js +5 -0
  59. package/lib/components/PaginationNav/PaginationNav.d.ts +13 -6
  60. package/lib/components/PaginationNav/PaginationNav.js +5 -0
  61. package/lib/components/ProgressIndicator/ProgressIndicator.d.ts +12 -6
  62. package/lib/components/ProgressIndicator/ProgressIndicator.js +5 -0
  63. package/lib/components/Slider/Slider.d.ts +11 -9
  64. package/lib/components/Slider/Slider.js +6 -1
  65. package/lib/internal/Selection.js +1 -1
  66. package/lib/internal/useId.js +39 -17
  67. package/lib/types/common.d.ts +6 -1
  68. package/package.json +8 -9
@@ -5,12 +5,17 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import React, { ReactNode } from 'react';
8
+ import { TranslateWithId } from '../../types/common';
8
9
  export declare const translationIds: {
9
- 'increment.number': string;
10
- 'decrement.number': string;
10
+ readonly 'increment.number': "increment.number";
11
+ readonly 'decrement.number': "decrement.number";
11
12
  };
13
+ /**
14
+ * Message ids that will be passed to translateWithId().
15
+ */
16
+ type TranslationKey = keyof typeof translationIds;
12
17
  type ExcludedAttributes = 'defaultValue' | 'id' | 'min' | 'max' | 'onChange' | 'onClick' | 'size' | 'step' | 'value';
13
- export interface NumberInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes> {
18
+ export interface NumberInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes>, TranslateWithId<TranslationKey> {
14
19
  /**
15
20
  * `true` to allow empty string.
16
21
  */
@@ -115,10 +120,6 @@ export interface NumberInputProps extends Omit<React.InputHTMLAttributes<HTMLInp
115
120
  * Specify how much the values should increase/decrease upon clicking on up/down button
116
121
  */
117
122
  step?: number;
118
- /**
119
- * Provide custom text for the component for each translation id
120
- */
121
- translateWithId?: (id: string) => string;
122
123
  /**
123
124
  * Specify the value of the input
124
125
  */
@@ -34,6 +34,11 @@ const translationIds = {
34
34
  'increment.number': 'increment.number',
35
35
  'decrement.number': 'decrement.number'
36
36
  };
37
+
38
+ /**
39
+ * Message ids that will be passed to translateWithId().
40
+ */
41
+
37
42
  const defaultTranslations = {
38
43
  [translationIds['increment.number']]: 'Increment number',
39
44
  [translationIds['decrement.number']]: 'Decrement number'
@@ -5,7 +5,19 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import React from 'react';
8
- interface PaginationNavProps extends Omit<React.HTMLAttributes<HTMLElement>, 'onChange'> {
8
+ import { TranslateWithId } from '../../types/common';
9
+ declare const translationIds: {
10
+ readonly 'carbon.pagination-nav.next': "Next";
11
+ readonly 'carbon.pagination-nav.previous': "Previous";
12
+ readonly 'carbon.pagination-nav.item': "Page";
13
+ readonly 'carbon.pagination-nav.active': "Active";
14
+ readonly 'carbon.pagination-nav.of': "of";
15
+ };
16
+ /**
17
+ * Message ids that will be passed to translateWithId().
18
+ */
19
+ type TranslationKey = keyof typeof translationIds;
20
+ interface PaginationNavProps extends Omit<React.HTMLAttributes<HTMLElement>, 'onChange'>, TranslateWithId<TranslationKey> {
9
21
  /**
10
22
  * Additional CSS class names.
11
23
  */
@@ -35,11 +47,6 @@ interface PaginationNavProps extends Omit<React.HTMLAttributes<HTMLElement>, 'on
35
47
  * The total number of items.
36
48
  */
37
49
  totalItems?: number;
38
- /**
39
- * Specify a custom translation function that takes in a message identifier
40
- * and returns the localized string for the message
41
- */
42
- translateWithId?: (id: string) => string;
43
50
  }
44
51
  declare const PaginationNav: React.ForwardRefExoticComponent<PaginationNavProps & React.RefAttributes<HTMLElement>>;
45
52
  export default PaginationNav;
@@ -31,6 +31,11 @@ const translationIds = {
31
31
  'carbon.pagination-nav.active': 'Active',
32
32
  'carbon.pagination-nav.of': 'of'
33
33
  };
34
+
35
+ /**
36
+ * Message ids that will be passed to translateWithId().
37
+ */
38
+
34
39
  function translateWithId(messageId) {
35
40
  return translationIds[messageId];
36
41
  }
@@ -6,6 +6,17 @@
6
6
  */
7
7
  import PropTypes from 'prop-types';
8
8
  import React from 'react';
9
+ import { TranslateWithId } from '../../types/common';
10
+ declare const defaultTranslations: {
11
+ readonly 'carbon.progress-step.complete': "Complete";
12
+ readonly 'carbon.progress-step.incomplete': "Incomplete";
13
+ readonly 'carbon.progress-step.current': "Current";
14
+ readonly 'carbon.progress-step.invalid': "Invalid";
15
+ };
16
+ /**
17
+ * Message ids that will be passed to translateWithId().
18
+ */
19
+ type TranslationKey = keyof typeof defaultTranslations;
9
20
  export interface ProgressIndicatorProps extends Omit<React.HTMLAttributes<HTMLUListElement>, 'onChange'> {
10
21
  /**
11
22
  * Provide `<ProgressStep>` components to be rendered in the
@@ -63,7 +74,7 @@ declare namespace ProgressIndicator {
63
74
  vertical: PropTypes.Requireable<boolean>;
64
75
  };
65
76
  }
66
- export interface ProgressStepProps {
77
+ export interface ProgressStepProps extends TranslateWithId<TranslationKey> {
67
78
  /**
68
79
  * Provide an optional className to be applied to the containing `<li>` node
69
80
  */
@@ -112,11 +123,6 @@ export interface ProgressStepProps {
112
123
  * The ID of the tooltip content.
113
124
  */
114
125
  tooltipId?: string;
115
- /**
116
- * Optional method that takes in a message id and returns an
117
- * internationalized string.
118
- */
119
- translateWithId?: (id: string) => string;
120
126
  }
121
127
  declare function ProgressStep({ label, description, className, current, complete, invalid, secondaryLabel, disabled, onClick, translateWithId: t, ...rest }: ProgressStepProps): import("react/jsx-runtime").JSX.Element;
122
128
  declare namespace ProgressStep {
@@ -32,6 +32,11 @@ const defaultTranslations = {
32
32
  'carbon.progress-step.current': 'Current',
33
33
  'carbon.progress-step.invalid': 'Invalid'
34
34
  };
35
+
36
+ /**
37
+ * Message ids that will be passed to translateWithId().
38
+ */
39
+
35
40
  function translateWithId(messageId) {
36
41
  return defaultTranslations[messageId];
37
42
  }
@@ -6,6 +6,14 @@
6
6
  */
7
7
  import React, { type KeyboardEventHandler, PureComponent, ReactNode } from 'react';
8
8
  import PropTypes from 'prop-types';
9
+ import { TranslateWithId } from '../../types/common';
10
+ declare const translationIds: {
11
+ readonly autoCorrectAnnouncement: "carbon.slider.auto-correct-announcement";
12
+ };
13
+ /**
14
+ * Message ids that will be passed to translateWithId().
15
+ */
16
+ type TranslationKey = (typeof translationIds)[keyof typeof translationIds];
9
17
  /**
10
18
  * Distinguish two handles by lower and upper positions.
11
19
  */
@@ -14,7 +22,9 @@ declare enum HandlePosition {
14
22
  UPPER = "upper"
15
23
  }
16
24
  type ExcludedAttributes = 'onChange' | 'onBlur';
17
- export interface SliderProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes> {
25
+ export interface SliderProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes>, TranslateWithId<TranslationKey, {
26
+ correctedValue?: string;
27
+ }> {
18
28
  /**
19
29
  * The `ariaLabel` for the `<input>`.
20
30
  */
@@ -136,14 +146,6 @@ export interface SliderProps extends Omit<React.InputHTMLAttributes<HTMLInputEle
136
146
  * which will be `(max - min) / stepMultiplier`.
137
147
  */
138
148
  stepMultiplier?: number;
139
- /**
140
- * Supply a method to translate internal strings with your i18n tool of
141
- * choice. Translation keys are available on the `translationIds` field for
142
- * this component.
143
- */
144
- translateWithId?: (translationId: string, translationState: {
145
- correctedValue?: string;
146
- }) => string;
147
149
  /**
148
150
  * The value of the slider. When there are two handles, value is the lower
149
151
  * bound.
@@ -83,8 +83,13 @@ ThumbWrapper.propTypes = {
83
83
  const translationIds = {
84
84
  autoCorrectAnnouncement: 'carbon.slider.auto-correct-announcement'
85
85
  };
86
+
87
+ /**
88
+ * Message ids that will be passed to translateWithId().
89
+ */
90
+
86
91
  function translateWithId(translationId, translationState) {
87
- if (translationId === translationIds.autoCorrectAnnouncement && translationState?.correctedValue) {
92
+ if (translationState?.correctedValue) {
88
93
  const {
89
94
  correctedValue
90
95
  } = translationState;
@@ -12,7 +12,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
12
12
  var _rollupPluginBabelHelpers = require('../_virtual/_rollupPluginBabelHelpers.js');
13
13
  var React = require('react');
14
14
  var PropTypes = require('prop-types');
15
- var isEqual = require('lodash.isequal');
15
+ var isEqual = require('react-fast-compare');
16
16
 
17
17
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
18
18
 
@@ -18,49 +18,70 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
18
18
 
19
19
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
20
20
 
21
- // This file was heavily inspired by Reach UI and their work on their auto-id
22
- const getId = setupGetInstanceId["default"]();
21
+ // This file was heavily inspired by:
22
+
23
+ // This tricks bundlers so they can't statically analyze this and produce
24
+ // compilation warnings/errors.
25
+ // https://github.com/webpack/webpack/issues/14814
26
+ // https://github.com/mui/material-ui/issues/41190
27
+ const _React = {
28
+ ...React__default["default"]
29
+ };
30
+ const instanceId = setupGetInstanceId["default"]();
23
31
  const useIsomorphicLayoutEffect = environment.canUseDOM ? React.useLayoutEffect : React.useEffect;
24
32
  let serverHandoffCompleted = false;
33
+ const defaultId = 'id';
25
34
 
26
35
  /**
27
- * Generate a unique ID with an optional prefix prepended to it
36
+ * Generate a unique ID for React <=17 with an optional prefix prepended to it.
37
+ * This is an internal utility, not intended for public usage.
28
38
  * @param {string} [prefix]
29
39
  * @returns {string}
30
40
  */
31
- function useId() {
32
- let prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'id';
33
- const _prefix = useIdPrefix.useIdPrefix();
41
+ function useCompatibleId() {
42
+ let prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultId;
43
+ const contextPrefix = useIdPrefix.useIdPrefix();
34
44
  const [id, setId] = React.useState(() => {
35
45
  if (serverHandoffCompleted) {
36
- return `${_prefix ? `${_prefix}-` : ``}${prefix}-${getId()}`;
46
+ return `${contextPrefix ? `${contextPrefix}-` : ``}${prefix}-${instanceId()}`;
37
47
  }
38
48
  return null;
39
49
  });
40
50
  useIsomorphicLayoutEffect(() => {
41
51
  if (id === null) {
42
- setId(`${_prefix ? `${_prefix}-` : ``}${prefix}-${getId()}`);
52
+ setId(`${contextPrefix ? `${contextPrefix}-` : ``}${prefix}-${instanceId()}`);
43
53
  }
44
- }, [getId]);
54
+ }, [instanceId]);
45
55
  React.useEffect(() => {
46
56
  if (serverHandoffCompleted === false) {
47
57
  serverHandoffCompleted = true;
48
58
  }
49
59
  }, []);
50
- if (typeof React__default["default"]['useId'] === 'function') {
51
- const id = nativeReactUseId(_prefix, prefix);
52
- return id;
53
- }
54
60
  return id;
55
61
  }
56
- function nativeReactUseId(_prefix, prefix) {
57
- const getId = React__default["default"]['useId']();
58
- const id = `${_prefix ? `${_prefix}-` : ``}${prefix}-${getId}`;
59
- return id;
62
+
63
+ /**
64
+ * Generate a unique ID for React >=18 with an optional prefix prepended to it.
65
+ * This is an internal utility, not intended for public usage.
66
+ * @param {string} [prefix]
67
+ * @returns {string}
68
+ */
69
+ function useReactId() {
70
+ let prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultId;
71
+ const contextPrefix = useIdPrefix.useIdPrefix();
72
+ return `${contextPrefix ? `${contextPrefix}-` : ``}${prefix}-${_React.useId()}`;
60
73
  }
61
74
 
75
+ /**
76
+ * Uses React 18's built-in `useId()` when available, or falls back to a
77
+ * slightly less performant (requiring a double render) implementation for
78
+ * earlier React versions.
79
+ */
80
+ const useId = _React.useId ? useReactId : useCompatibleId;
81
+
62
82
  /**
63
83
  * Generate a unique id if a given `id` is not provided
84
+ * This is an internal utility, not intended for public usage.
64
85
  * @param {string|undefined} id
65
86
  * @returns {string}
66
87
  */
@@ -69,5 +90,6 @@ function useFallbackId(id) {
69
90
  return id ?? fallback;
70
91
  }
71
92
 
93
+ exports.useCompatibleId = useCompatibleId;
72
94
  exports.useFallbackId = useFallbackId;
73
95
  exports.useId = useId;
@@ -9,10 +9,15 @@ export type ForwardRefReturn<T, P = unknown> = React.ForwardRefExoticComponent<F
9
9
  export type PolymorphicProps<Element extends React.ElementType, Props> = Props & Omit<React.ComponentProps<Element>, 'as'> & {
10
10
  as?: Element;
11
11
  };
12
- export interface InternationalProps<MID = string, ARGS = Record<string, unknown>> {
12
+ export interface TranslateWithId<MID = string, ARGS = Record<string, unknown>> {
13
13
  /**
14
14
  * Supply a method to translate internal strings with your i18n tool of
15
15
  * choice.
16
16
  */
17
17
  translateWithId?(messageId: MID, args?: ARGS): string;
18
18
  }
19
+ /**
20
+ * Alias of TranslateWithId. Will be removed in v12
21
+ * @deprecated Use TranslateWithId instead
22
+ */
23
+ export type InternationalProps<MID = string, ARGS = Record<string, unknown>> = TranslateWithId<MID, ARGS>;
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.63.0-rc.0",
4
+ "version": "1.63.1",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -48,10 +48,10 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "@babel/runtime": "^7.24.7",
51
- "@carbon/feature-flags": "^0.21.0-rc.0",
52
- "@carbon/icons-react": "^11.46.0-rc.0",
53
- "@carbon/layout": "^11.24.0-rc.0",
54
- "@carbon/styles": "^1.62.0-rc.0",
51
+ "@carbon/feature-flags": "^0.21.0",
52
+ "@carbon/icons-react": "^11.46.0",
53
+ "@carbon/layout": "^11.24.0",
54
+ "@carbon/styles": "^1.62.0",
55
55
  "@floating-ui/react": "^0.26.0",
56
56
  "@ibm/telemetry-js": "^1.5.0",
57
57
  "classnames": "2.5.1",
@@ -61,7 +61,6 @@
61
61
  "invariant": "^2.2.3",
62
62
  "lodash.debounce": "^4.0.8",
63
63
  "lodash.findlast": "^4.5.0",
64
- "lodash.isequal": "^4.5.0",
65
64
  "lodash.omit": "^4.5.0",
66
65
  "lodash.throttle": "^4.1.1",
67
66
  "prop-types": "^15.7.2",
@@ -81,7 +80,7 @@
81
80
  "@babel/preset-react": "^7.24.7",
82
81
  "@babel/preset-typescript": "^7.24.7",
83
82
  "@carbon/test-utils": "^10.30.0",
84
- "@carbon/themes": "^11.38.0-rc.0",
83
+ "@carbon/themes": "^11.38.0",
85
84
  "@figma/code-connect": "^1.0.2",
86
85
  "@rollup/plugin-babel": "^6.0.0",
87
86
  "@rollup/plugin-commonjs": "^26.0.0",
@@ -100,7 +99,7 @@
100
99
  "autoprefixer": "^10.4.0",
101
100
  "babel-loader": "^9.0.0",
102
101
  "babel-plugin-dev-expression": "^0.2.3",
103
- "babel-preset-carbon": "^0.6.0-rc.0",
102
+ "babel-preset-carbon": "^0.6.0",
104
103
  "browserify-zlib": "^0.2.0",
105
104
  "browserslist-config-carbon": "^11.2.0",
106
105
  "clipboardy": "^2.1.0",
@@ -142,5 +141,5 @@
142
141
  "**/*.scss",
143
142
  "**/*.css"
144
143
  ],
145
- "gitHead": "326ac312c2b669937ede1c0c68c0e3a6d9c34135"
144
+ "gitHead": "950953f450dcdfbee94deceba31ce2cab8807414"
146
145
  }