@carbon/react 1.89.0-rc.0 → 1.89.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 (63) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +1113 -851
  2. package/es/components/AILabel/index.d.ts +2 -5
  3. package/es/components/AILabel/index.js +2 -42
  4. package/es/components/ComposedModal/ComposedModal.js +2 -2
  5. package/es/components/Copy/Copy.js +1 -0
  6. package/es/components/DataTable/DataTable.js +10 -3
  7. package/es/components/Dialog/Dialog.d.ts +245 -0
  8. package/es/components/Dialog/Dialog.js +593 -0
  9. package/es/components/Dialog/index.d.ts +3 -251
  10. package/es/components/Dialog/index.js +1 -609
  11. package/es/components/FeatureFlags/index.d.ts +3 -1
  12. package/es/components/FeatureFlags/index.js +5 -2
  13. package/es/components/FileUploader/FileUploader.d.ts +28 -6
  14. package/es/components/FileUploader/FileUploader.js +152 -38
  15. package/es/components/Link/Link.js +15 -1
  16. package/es/components/Menu/MenuContext.d.ts +1 -1
  17. package/es/components/Menu/MenuContext.js +11 -4
  18. package/es/components/Menu/MenuItem.js +4 -10
  19. package/es/components/Modal/Modal.js +17 -9
  20. package/es/components/MultiSelect/FilterableMultiSelect.js +1 -5
  21. package/es/components/MultiSelect/MultiSelect.js +3 -7
  22. package/es/components/Popover/index.d.ts +4 -0
  23. package/es/components/Popover/index.js +8 -2
  24. package/es/components/StructuredList/StructuredList.d.ts +16 -0
  25. package/es/components/StructuredList/StructuredList.js +23 -11
  26. package/es/components/Toggletip/index.d.ts +13 -36
  27. package/es/components/Toggletip/index.js +12 -51
  28. package/es/index.d.ts +2 -1
  29. package/es/index.js +2 -0
  30. package/es/internal/Selection.js +1 -1
  31. package/es/internal/useMergedRefs.js +4 -3
  32. package/lib/components/AILabel/index.d.ts +2 -5
  33. package/lib/components/AILabel/index.js +1 -41
  34. package/lib/components/ComposedModal/ComposedModal.js +2 -2
  35. package/lib/components/Copy/Copy.js +1 -0
  36. package/lib/components/DataTable/DataTable.js +10 -3
  37. package/lib/components/Dialog/Dialog.d.ts +245 -0
  38. package/lib/components/Dialog/Dialog.js +602 -0
  39. package/lib/components/Dialog/index.d.ts +3 -251
  40. package/lib/components/Dialog/index.js +9 -614
  41. package/lib/components/FeatureFlags/index.d.ts +3 -1
  42. package/lib/components/FeatureFlags/index.js +5 -2
  43. package/lib/components/FileUploader/FileUploader.d.ts +28 -6
  44. package/lib/components/FileUploader/FileUploader.js +151 -37
  45. package/lib/components/Link/Link.js +15 -1
  46. package/lib/components/Menu/MenuContext.d.ts +1 -1
  47. package/lib/components/Menu/MenuContext.js +11 -4
  48. package/lib/components/Menu/MenuItem.js +4 -10
  49. package/lib/components/Modal/Modal.js +24 -16
  50. package/lib/components/MultiSelect/FilterableMultiSelect.js +1 -5
  51. package/lib/components/MultiSelect/MultiSelect.js +3 -7
  52. package/lib/components/Popover/index.d.ts +4 -0
  53. package/lib/components/Popover/index.js +8 -2
  54. package/lib/components/StructuredList/StructuredList.d.ts +16 -0
  55. package/lib/components/StructuredList/StructuredList.js +23 -11
  56. package/lib/components/Toggletip/index.d.ts +13 -36
  57. package/lib/components/Toggletip/index.js +11 -50
  58. package/lib/index.d.ts +2 -1
  59. package/lib/index.js +60 -58
  60. package/lib/internal/Selection.js +1 -1
  61. package/lib/internal/useMergedRefs.js +3 -2
  62. package/package.json +15 -16
  63. package/telemetry.yml +5 -2
@@ -5,6 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import React from 'react';
8
+ import { ToggletipBaseProps } from '../Toggletip';
8
9
  import type { DeprecatedPopoverAlignment, NewPopoverAlignment, PopoverAlignment } from '../Popover';
9
10
  export type AILabelContentProps = React.HTMLAttributes<HTMLSpanElement>;
10
11
  export declare const AILabelContent: React.ForwardRefExoticComponent<AILabelContentProps & React.RefAttributes<unknown>>;
@@ -17,15 +18,11 @@ export declare const AILabelActions: React.ForwardRefExoticComponent<AILabelActi
17
18
  export type DeprecatedAlignment = DeprecatedPopoverAlignment;
18
19
  export type NewAlignment = NewPopoverAlignment;
19
20
  export type Alignment = PopoverAlignment;
20
- export interface AILabelProps {
21
+ export interface AILabelProps extends ToggletipBaseProps {
21
22
  AILabelContent?: React.ReactNode;
22
23
  aiText?: string;
23
24
  aiTextLabel?: string;
24
25
  textLabel?: string;
25
- align?: Alignment;
26
- autoAlign?: boolean;
27
- children?: React.ReactNode;
28
- className?: string;
29
26
  kind?: 'default' | 'inline';
30
27
  onRevertClick?: (evt: React.MouseEvent<HTMLButtonElement>) => void;
31
28
  revertActive?: boolean;
@@ -8,12 +8,10 @@
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 deprecateValuesWithin from '../../prop-types/deprecateValuesWithin.js';
12
11
  import React from 'react';
13
12
  import { usePrefix } from '../../internal/usePrefix.js';
14
- import { ToggletipContent, ToggletipActions, Toggletip, ToggletipButton } from '../Toggletip/index.js';
13
+ import { Toggletip, ToggletipContent, ToggletipActions, ToggletipButton } from '../Toggletip/index.js';
15
14
  import { IconButton } from '../IconButton/index.js';
16
- import { mapPopoverAlign } from '../../tools/mapPopoverAlign.js';
17
15
  import { Undo } from '@carbon/icons-react';
18
16
  import { useId } from '../../internal/useId.js';
19
17
  import { deprecate } from '../../prop-types/deprecate.js';
@@ -143,6 +141,7 @@ const AILabel = /*#__PURE__*/React.forwardRef(function AILabel({
143
141
  });
144
142
  AILabel.displayName = 'AILabel';
145
143
  AILabel.propTypes = {
144
+ ...Toggletip.propTypes,
146
145
  /**
147
146
  * Specify the content you want rendered inside the `AILabel` ToggleTip
148
147
  */
@@ -156,49 +155,10 @@ AILabel.propTypes = {
156
155
  * Specify additional text to be rendered next to the AI label in the inline variant
157
156
  */
158
157
  aiTextLabel: deprecate(PropTypes.string, '`aiTextLabel` on `AILabel` has been deprecated - Please use the `textLabel` prop instead'),
159
- /**
160
- * Specify how the popover should align with the button
161
- */
162
- align: deprecateValuesWithin(PropTypes.oneOf(['top', 'top-left',
163
- // deprecated use top-start instead
164
- 'top-right',
165
- // deprecated use top-end instead
166
-
167
- 'bottom', 'bottom-left',
168
- // deprecated use bottom-start instead
169
- 'bottom-right',
170
- // deprecated use bottom-end instead
171
-
172
- 'left', 'left-bottom',
173
- // deprecated use left-end instead
174
- 'left-top',
175
- // deprecated use left-start instead
176
-
177
- 'right', 'right-bottom',
178
- // deprecated use right-end instead
179
- 'right-top',
180
- // deprecated use right-start instead
181
-
182
- // new values to match floating-ui
183
- 'top-start', 'top-end', 'bottom-start', 'bottom-end', 'left-end', 'left-start', 'right-end', 'right-start']), ['top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'left', 'left-start', 'left-end', 'right', 'right-start', 'right-end'], mapPopoverAlign),
184
158
  /**
185
159
  * Specify the text that will be provided to the aria-label of the `AILabel` button
186
160
  */
187
161
  'aria-label': PropTypes.string,
188
- /**
189
- * Will auto-align the popover. This prop is currently experimental and is
190
- * subject to future changes. Requires React v17+
191
- * @see https://github.com/carbon-design-system/carbon/issues/18714
192
- */
193
- autoAlign: PropTypes.bool,
194
- /**
195
- * Specify the content you want rendered inside the `AILabel` ToggleTip
196
- */
197
- children: PropTypes.node,
198
- /**
199
- * Specify an optional className to be added to the `AILabel`
200
- */
201
- className: PropTypes.string,
202
162
  /**
203
163
  * Specify the type of `AILabel`, from the following list of types:
204
164
  */
@@ -24,7 +24,7 @@ import { match } from '../../internal/keyboard/match.js';
24
24
  import { useFeatureFlag } from '../FeatureFlags/index.js';
25
25
  import { composeEventHandlers } from '../../tools/events.js';
26
26
  import { deprecate } from '../../prop-types/deprecate.js';
27
- import { unstable__Dialog } from '../Dialog/index.js';
27
+ import { Dialog } from '../Dialog/Dialog.js';
28
28
  import { warning } from '../../internal/warning.js';
29
29
  import { AILabel } from '../AILabel/index.js';
30
30
  import { isComponentElement } from '../../internal/utils.js';
@@ -304,7 +304,7 @@ const ComposedModal = /*#__PURE__*/React.forwardRef(function ComposedModal({
304
304
  const normalizedDecorator = candidateIsAILabel ? /*#__PURE__*/cloneElement(candidate, {
305
305
  size: 'sm'
306
306
  }) : null;
307
- const modalBody = enableDialogElement ? /*#__PURE__*/React.createElement(unstable__Dialog, {
307
+ const modalBody = enableDialogElement ? /*#__PURE__*/React.createElement(Dialog, {
308
308
  open: open,
309
309
  focusAfterCloseRef: launcherButtonRef,
310
310
  modal: true,
@@ -57,6 +57,7 @@ function Copy({
57
57
  autoAlign: autoAlign,
58
58
  className: classNames,
59
59
  label: animation ? feedback : initialLabel,
60
+ leaveDelayMs: animation ? feedbackTimeout : undefined,
60
61
  onClick: composeEventHandlers([onClick, handleClick]),
61
62
  onAnimationEnd: composeEventHandlers([onAnimationEnd, handleAnimationEnd])
62
63
  }, other, {
@@ -549,9 +549,16 @@ const DataTable = props => {
549
549
  * @param headerKey - The field for the header that we are sorting by.
550
550
  */
551
551
  const handleSortBy = headerKey => () => {
552
- setState(prev => getNextSortState(props, prev, {
553
- key: headerKey
554
- }));
552
+ setState(prev => {
553
+ const sortState = getNextSortState(props, prev, {
554
+ key: headerKey
555
+ });
556
+ return {
557
+ ...prev,
558
+ // Preserve ALL existing state
559
+ ...sortState // Then apply only the sorting changes
560
+ };
561
+ });
555
562
  };
556
563
 
557
564
  /**
@@ -0,0 +1,245 @@
1
+ /**
2
+ * Copyright IBM Corp. 2025
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 React, { type HTMLAttributes, type RefObject } from 'react';
8
+ import { InlineLoadingStatus } from '../InlineLoading/InlineLoading';
9
+ /**
10
+ * ----------
11
+ * Dialog
12
+ * ----------
13
+ */
14
+ interface DialogProps extends HTMLAttributes<HTMLDialogElement> {
15
+ /**
16
+ * Provide the contents of the Dialog
17
+ */
18
+ children?: React.ReactNode;
19
+ /**
20
+ * Specify an optional className to be applied to the modal root node
21
+ */
22
+ className?: string;
23
+ /**
24
+ * Provide a ref to return focus to once the dialog is closed.
25
+ */
26
+ focusAfterCloseRef?: RefObject<HTMLElement | null>;
27
+ /**
28
+ * Specifies whether the dialog is modal or non-modal. This cannot be changed
29
+ * while open=true
30
+ */
31
+ modal?: boolean;
32
+ /**
33
+ * Specify a handler for the dialog's cancel event.
34
+ * The browser fires this event when the user presses the Esc key and is cancelable.
35
+ */
36
+ onCancel?: React.ReactEventHandler<HTMLDialogElement>;
37
+ /**
38
+ * Specify a click handler applied to the dialog.
39
+ */
40
+ onClick?: React.ReactEventHandler<HTMLDialogElement>;
41
+ /**
42
+ * Specify a handler the dialog's close event.
43
+ * The browser fires this event after the dialog has closed.
44
+ */
45
+ onClose?: React.ReactEventHandler<HTMLDialogElement>;
46
+ /**
47
+ * Specify a handler for closing Dialog.
48
+ * The handler should care of closing Dialog, e.g. changing `open` prop.
49
+ */
50
+ onRequestClose?: React.ReactEventHandler<HTMLElement>;
51
+ /**
52
+ * Specify whether the Dialog is currently open
53
+ */
54
+ open?: boolean;
55
+ /**
56
+ * Specify the role of the dialog for accessibility
57
+ * 'dialog' is the default, but 'alertdialog' can be used for important messages requiring user attention
58
+ */
59
+ role?: '' | 'alertdialog';
60
+ /**
61
+ * Specify a label for screen readers
62
+ */
63
+ ariaLabel?: string;
64
+ /**
65
+ * Specify the ID of an element that labels this dialog
66
+ */
67
+ ariaLabelledBy?: string;
68
+ /**
69
+ * Specify the ID of an element that describes this dialog
70
+ */
71
+ ariaDescribedBy?: string;
72
+ }
73
+ declare const Dialog: React.ForwardRefExoticComponent<DialogProps & React.RefAttributes<unknown>>;
74
+ /**
75
+ * -------------
76
+ * DialogHeader
77
+ * -------------
78
+ */
79
+ interface DialogHeaderProps extends HTMLAttributes<HTMLDivElement> {
80
+ /**
81
+ * Provide the contents to be rendered inside of this component
82
+ */
83
+ children?: React.ReactNode;
84
+ }
85
+ declare const DialogHeader: React.ForwardRefExoticComponent<DialogHeaderProps & React.RefAttributes<HTMLDivElement>>;
86
+ /**
87
+ * ---------------
88
+ * DialogControls
89
+ * ---------------
90
+ */
91
+ interface DialogControlsProps extends HTMLAttributes<HTMLDivElement> {
92
+ /**
93
+ * Provide the contents to be rendered inside of this component
94
+ */
95
+ children?: React.ReactNode;
96
+ }
97
+ declare const DialogControls: React.ForwardRefExoticComponent<DialogControlsProps & React.RefAttributes<HTMLDivElement>>;
98
+ /**
99
+ * -------------------
100
+ * DialogCloseButton
101
+ * -------------------
102
+ */
103
+ interface DialogCloseButtonProps extends HTMLAttributes<HTMLDivElement> {
104
+ /**
105
+ * Specify a click handler applied to the IconButton
106
+ */
107
+ onClick?: React.MouseEventHandler;
108
+ }
109
+ declare const DialogCloseButton: React.ForwardRefExoticComponent<DialogCloseButtonProps & React.RefAttributes<HTMLDivElement>>;
110
+ /**
111
+ * ------------
112
+ * DialogTitle
113
+ * ------------
114
+ */
115
+ interface DialogTitleProps extends HTMLAttributes<HTMLHeadingElement> {
116
+ /**
117
+ * Provide the contents of the DialogTitle
118
+ */
119
+ children?: React.ReactNode;
120
+ /**
121
+ * Specify an optional className to be applied to the title node
122
+ */
123
+ className?: string;
124
+ /**
125
+ * Specify an optional id for the title element
126
+ */
127
+ id?: string;
128
+ }
129
+ declare const DialogTitle: React.ForwardRefExoticComponent<DialogTitleProps & React.RefAttributes<HTMLHeadingElement>>;
130
+ /**
131
+ * ---------------
132
+ * DialogSubtitle
133
+ * ---------------
134
+ */
135
+ interface DialogSubtitleProps extends HTMLAttributes<HTMLParagraphElement> {
136
+ /**
137
+ * Provide the contents of the DialogSubtitle
138
+ */
139
+ children?: React.ReactNode;
140
+ /**
141
+ * Specify an optional className to be applied to the subtitle node
142
+ */
143
+ className?: string;
144
+ /**
145
+ * Specify an optional id for the subtitle element
146
+ */
147
+ id?: string;
148
+ }
149
+ declare const DialogSubtitle: React.ForwardRefExoticComponent<DialogSubtitleProps & React.RefAttributes<HTMLParagraphElement>>;
150
+ /**
151
+ * -----------
152
+ * DialogBody
153
+ * -----------
154
+ */
155
+ interface DialogBodyProps extends HTMLAttributes<HTMLDivElement> {
156
+ /**
157
+ * Provide the contents of the DialogBody
158
+ */
159
+ children?: React.ReactNode;
160
+ /**
161
+ * Specify an optional className to be applied to the body node
162
+ */
163
+ className?: string;
164
+ /**
165
+ * Specify whether the content has overflow that should be scrollable
166
+ */
167
+ hasScrollingContent?: boolean;
168
+ }
169
+ declare const DialogBody: React.ForwardRefExoticComponent<DialogBodyProps & React.RefAttributes<HTMLDivElement>>;
170
+ /**
171
+ * -------------
172
+ * DialogFooter
173
+ * -------------
174
+ */
175
+ interface DialogFooterProps extends HTMLAttributes<HTMLDivElement> {
176
+ /**
177
+ * Provide the contents of the DialogFooter
178
+ */
179
+ children?: React.ReactNode;
180
+ /**
181
+ * Specify an optional className to be applied to the footer node
182
+ */
183
+ className?: string;
184
+ /**
185
+ * Specify a handler for closing dialog (secondary button)
186
+ */
187
+ onRequestClose?: React.ReactEventHandler<HTMLElement>;
188
+ /**
189
+ * Specify a handler for the secondary button.
190
+ * Useful if separate handler from `onRequestClose` is desirable
191
+ */
192
+ onSecondarySubmit?: React.ReactEventHandler<HTMLElement>;
193
+ /**
194
+ * Specify a handler for submitting dialog (primary button)
195
+ */
196
+ onRequestSubmit?: React.ReactEventHandler<HTMLElement>;
197
+ /**
198
+ * Specify the text for the primary button
199
+ */
200
+ primaryButtonText?: React.ReactNode;
201
+ /**
202
+ * Specify whether the Button should be disabled, or not
203
+ */
204
+ primaryButtonDisabled?: boolean;
205
+ /**
206
+ * Specify the text for the secondary button
207
+ */
208
+ secondaryButtonText?: React.ReactNode;
209
+ /**
210
+ * Specify an array of config objects for secondary buttons
211
+ */
212
+ secondaryButtons?: Array<{
213
+ buttonText: React.ReactNode;
214
+ onClick: React.MouseEventHandler<HTMLButtonElement>;
215
+ }>;
216
+ /**
217
+ * Specify whether the Dialog is for dangerous actions
218
+ */
219
+ danger?: boolean;
220
+ /**
221
+ * Specify loading status
222
+ */
223
+ loadingStatus?: InlineLoadingStatus;
224
+ /**
225
+ * Specify the description for the loading text
226
+ */
227
+ loadingDescription?: string;
228
+ /**
229
+ * Specify the description for the loading icon
230
+ */
231
+ loadingIconDescription?: string;
232
+ /**
233
+ * Specify an optional handler to be invoked when loading is
234
+ * successful
235
+ */
236
+ onLoadingSuccess?: () => void;
237
+ }
238
+ declare const DialogFooter: React.ForwardRefExoticComponent<DialogFooterProps & React.RefAttributes<HTMLDivElement>>;
239
+ /**
240
+ * -------
241
+ * Exports
242
+ * -------
243
+ */
244
+ export { Dialog, DialogHeader, DialogControls, DialogCloseButton, DialogTitle, DialogSubtitle, DialogBody, DialogFooter, };
245
+ export type { DialogProps, DialogHeaderProps, DialogControlsProps, DialogCloseButtonProps, DialogTitleProps, DialogSubtitleProps, DialogBodyProps, DialogFooterProps, };