@carbon/react 1.78.1 → 1.78.2

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 (217) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +764 -764
  2. package/es/components/Accordion/AccordionItem.js +2 -2
  3. package/es/components/Button/Button.d.ts +3 -2
  4. package/es/components/Button/Button.js +2 -1
  5. package/es/components/Button/ButtonBase.js +1 -1
  6. package/es/components/ChatButton/ChatButton.d.ts +3 -2
  7. package/es/components/ChatButton/ChatButton.js +2 -1
  8. package/es/components/ComboBox/ComboBox.js +24 -34
  9. package/es/components/ComposedModal/ComposedModal.js +51 -65
  10. package/es/components/ContainedList/ContainedListItem/ContainedListItem.d.ts +2 -2
  11. package/es/components/ContainedList/ContainedListItem/ContainedListItem.js +1 -1
  12. package/es/components/ContentSwitcher/ContentSwitcher.js +3 -3
  13. package/es/components/DataTable/TableBatchAction.d.ts +3 -3
  14. package/es/components/DataTable/TableBatchAction.js +1 -1
  15. package/es/components/DataTable/TableContainer.d.ts +1 -1
  16. package/es/components/DataTable/TableContainer.js +3 -3
  17. package/es/components/DataTable/TableExpandHeader.d.ts +5 -6
  18. package/es/components/DataTable/TableToolbarMenu.d.ts +2 -2
  19. package/es/components/DataTable/TableToolbarMenu.js +1 -1
  20. package/es/components/DatePicker/DatePicker.js +2 -2
  21. package/es/components/DatePicker/plugins/fixEventsPlugin.js +1 -1
  22. package/es/components/Dialog/index.d.ts +4 -42
  23. package/es/components/ExpandableSearch/ExpandableSearch.js +2 -2
  24. package/es/components/FeatureFlags/index.d.ts +1 -3
  25. package/es/components/FeatureFlags/index.js +0 -3
  26. package/es/components/FileUploader/FileUploader.d.ts +1 -1
  27. package/es/components/FileUploader/FileUploader.js +2 -2
  28. package/es/components/FileUploader/FileUploaderButton.js +2 -2
  29. package/es/components/FileUploader/FileUploaderDropContainer.d.ts +1 -1
  30. package/es/components/FileUploader/FileUploaderDropContainer.js +4 -6
  31. package/es/components/FileUploader/FileUploaderItem.d.ts +1 -1
  32. package/es/components/FileUploader/FileUploaderItem.js +2 -2
  33. package/es/components/Grid/CSSGrid.js +14 -18
  34. package/es/components/Grid/FlexGrid.js +6 -7
  35. package/es/components/Grid/GridTypes.d.ts +3 -5
  36. package/es/components/IconButton/index.js +3 -3
  37. package/es/components/Layer/index.d.ts +6 -4
  38. package/es/components/Layer/index.js +6 -5
  39. package/es/components/Link/Link.d.ts +3 -2
  40. package/es/components/Link/Link.js +2 -1
  41. package/es/components/ListBox/ListBoxMenuItem.d.ts +3 -3
  42. package/es/components/ListBox/ListBoxMenuItem.js +15 -37
  43. package/es/components/Menu/Menu.js +2 -2
  44. package/es/components/Menu/MenuItem.d.ts +2 -2
  45. package/es/components/Menu/MenuItem.js +3 -3
  46. package/es/components/Modal/Modal.js +49 -121
  47. package/es/components/Modal/next/index.d.ts +171 -0
  48. package/es/components/ModalWrapper/ModalWrapper.js +1 -1
  49. package/es/components/MultiSelect/FilterableMultiSelect.js +3 -3
  50. package/es/components/MultiSelect/MultiSelect.js +2 -2
  51. package/es/components/Notification/Notification.d.ts +13 -5
  52. package/es/components/Notification/Notification.js +4 -3
  53. package/es/components/OverflowMenu/OverflowMenu.d.ts +8 -4
  54. package/es/components/OverflowMenu/OverflowMenu.js +3 -3
  55. package/es/components/OverflowMenu/next/index.d.ts +2 -2
  56. package/es/components/OverflowMenu/next/index.js +1 -1
  57. package/es/components/OverflowMenuItem/OverflowMenuItem.js +2 -2
  58. package/es/components/ProgressIndicator/ProgressIndicator.js +2 -2
  59. package/es/components/RadioTile/RadioTile.js +2 -2
  60. package/es/components/Search/Search.d.ts +3 -2
  61. package/es/components/Search/Search.js +6 -4
  62. package/es/components/Slider/Slider.d.ts +15 -16
  63. package/es/components/Slider/Slider.js +22 -22
  64. package/es/components/Tabs/Tabs.d.ts +6 -3
  65. package/es/components/Tabs/Tabs.js +9 -8
  66. package/es/components/Tag/DismissibleTag.d.ts +5 -3
  67. package/es/components/Tag/DismissibleTag.js +2 -1
  68. package/es/components/Tag/OperationalTag.d.ts +3 -2
  69. package/es/components/Tag/OperationalTag.js +2 -1
  70. package/es/components/Tag/SelectableTag.d.ts +5 -3
  71. package/es/components/Tag/SelectableTag.js +2 -1
  72. package/es/components/Tag/Tag.d.ts +3 -2
  73. package/es/components/Tag/Tag.js +2 -1
  74. package/es/components/Tile/Tile.d.ts +5 -3
  75. package/es/components/Tile/Tile.js +6 -8
  76. package/es/components/Toggletip/index.js +2 -2
  77. package/es/components/Tooltip/DefinitionTooltip.js +2 -2
  78. package/es/components/Tooltip/Tooltip.d.ts +1 -1
  79. package/es/components/Tooltip/Tooltip.js +2 -2
  80. package/es/components/TreeView/TreeNode.d.ts +5 -3
  81. package/es/components/TreeView/TreeNode.js +4 -3
  82. package/es/components/TreeView/TreeView.js +2 -2
  83. package/es/components/UIShell/HeaderContainer.js +2 -2
  84. package/es/components/UIShell/HeaderMenu.js +2 -2
  85. package/es/components/UIShell/HeaderPanel.js +2 -2
  86. package/es/components/UIShell/SideNav.d.ts +1 -1
  87. package/es/components/UIShell/SideNav.js +2 -2
  88. package/es/components/UIShell/SideNavHeader.d.ts +3 -2
  89. package/es/components/UIShell/SideNavHeader.js +2 -1
  90. package/es/components/UIShell/SideNavLink.d.ts +2 -2
  91. package/es/components/UIShell/SideNavLink.js +1 -1
  92. package/es/components/UIShell/SideNavMenu.d.ts +2 -2
  93. package/es/components/UIShell/SideNavMenu.js +3 -3
  94. package/es/components/UIShell/SwitcherItem.js +2 -2
  95. package/es/internal/FloatingMenu.js +4 -4
  96. package/es/internal/OptimizedResize.js +24 -21
  97. package/es/internal/focus/index.js +15 -0
  98. package/es/internal/keyboard/keys.js +2 -2
  99. package/es/internal/keyboard/match.js +41 -17
  100. package/es/internal/keyboard/navigation.js +27 -15
  101. package/es/internal/useMergedRefs.js +0 -3
  102. package/lib/components/Accordion/AccordionItem.js +2 -2
  103. package/lib/components/Button/Button.d.ts +3 -2
  104. package/lib/components/Button/Button.js +2 -1
  105. package/lib/components/Button/ButtonBase.js +1 -1
  106. package/lib/components/ChatButton/ChatButton.d.ts +3 -2
  107. package/lib/components/ChatButton/ChatButton.js +2 -1
  108. package/lib/components/ComboBox/ComboBox.js +24 -34
  109. package/lib/components/ComposedModal/ComposedModal.js +50 -64
  110. package/lib/components/ContainedList/ContainedListItem/ContainedListItem.d.ts +2 -2
  111. package/lib/components/ContainedList/ContainedListItem/ContainedListItem.js +1 -1
  112. package/lib/components/ContentSwitcher/ContentSwitcher.js +3 -3
  113. package/lib/components/DataTable/TableBatchAction.d.ts +3 -3
  114. package/lib/components/DataTable/TableBatchAction.js +1 -1
  115. package/lib/components/DataTable/TableContainer.d.ts +1 -1
  116. package/lib/components/DataTable/TableContainer.js +3 -3
  117. package/lib/components/DataTable/TableExpandHeader.d.ts +5 -6
  118. package/lib/components/DataTable/TableToolbarMenu.d.ts +2 -2
  119. package/lib/components/DataTable/TableToolbarMenu.js +1 -1
  120. package/lib/components/DatePicker/DatePicker.js +2 -2
  121. package/lib/components/DatePicker/plugins/fixEventsPlugin.js +1 -1
  122. package/lib/components/Dialog/index.d.ts +4 -42
  123. package/lib/components/ExpandableSearch/ExpandableSearch.js +2 -2
  124. package/lib/components/FeatureFlags/index.d.ts +1 -3
  125. package/lib/components/FeatureFlags/index.js +0 -3
  126. package/lib/components/FileUploader/FileUploader.d.ts +1 -1
  127. package/lib/components/FileUploader/FileUploader.js +2 -2
  128. package/lib/components/FileUploader/FileUploaderButton.js +2 -2
  129. package/lib/components/FileUploader/FileUploaderDropContainer.d.ts +1 -1
  130. package/lib/components/FileUploader/FileUploaderDropContainer.js +4 -6
  131. package/lib/components/FileUploader/FileUploaderItem.d.ts +1 -1
  132. package/lib/components/FileUploader/FileUploaderItem.js +2 -2
  133. package/lib/components/Grid/CSSGrid.js +14 -18
  134. package/lib/components/Grid/FlexGrid.js +6 -7
  135. package/lib/components/Grid/GridTypes.d.ts +3 -5
  136. package/lib/components/IconButton/index.js +3 -3
  137. package/lib/components/Layer/index.d.ts +6 -4
  138. package/lib/components/Layer/index.js +6 -5
  139. package/lib/components/Link/Link.d.ts +3 -2
  140. package/lib/components/Link/Link.js +2 -1
  141. package/lib/components/ListBox/ListBoxMenuItem.d.ts +3 -3
  142. package/lib/components/ListBox/ListBoxMenuItem.js +14 -36
  143. package/lib/components/Menu/Menu.js +2 -2
  144. package/lib/components/Menu/MenuItem.d.ts +2 -2
  145. package/lib/components/Menu/MenuItem.js +3 -3
  146. package/lib/components/Modal/Modal.js +51 -123
  147. package/lib/components/Modal/next/index.d.ts +171 -0
  148. package/lib/components/ModalWrapper/ModalWrapper.js +1 -1
  149. package/lib/components/MultiSelect/FilterableMultiSelect.js +3 -3
  150. package/lib/components/MultiSelect/MultiSelect.js +2 -2
  151. package/lib/components/Notification/Notification.d.ts +13 -5
  152. package/lib/components/Notification/Notification.js +4 -3
  153. package/lib/components/OverflowMenu/OverflowMenu.d.ts +8 -4
  154. package/lib/components/OverflowMenu/OverflowMenu.js +3 -3
  155. package/lib/components/OverflowMenu/next/index.d.ts +2 -2
  156. package/lib/components/OverflowMenu/next/index.js +1 -1
  157. package/lib/components/OverflowMenuItem/OverflowMenuItem.js +2 -2
  158. package/lib/components/ProgressIndicator/ProgressIndicator.js +2 -2
  159. package/lib/components/RadioTile/RadioTile.js +2 -2
  160. package/lib/components/Search/Search.d.ts +3 -2
  161. package/lib/components/Search/Search.js +6 -4
  162. package/lib/components/Slider/Slider.d.ts +15 -16
  163. package/lib/components/Slider/Slider.js +22 -22
  164. package/lib/components/Tabs/Tabs.d.ts +6 -3
  165. package/lib/components/Tabs/Tabs.js +9 -8
  166. package/lib/components/Tag/DismissibleTag.d.ts +5 -3
  167. package/lib/components/Tag/DismissibleTag.js +2 -1
  168. package/lib/components/Tag/OperationalTag.d.ts +3 -2
  169. package/lib/components/Tag/OperationalTag.js +2 -1
  170. package/lib/components/Tag/SelectableTag.d.ts +5 -3
  171. package/lib/components/Tag/SelectableTag.js +2 -1
  172. package/lib/components/Tag/Tag.d.ts +3 -2
  173. package/lib/components/Tag/Tag.js +2 -1
  174. package/lib/components/Tile/Tile.d.ts +5 -3
  175. package/lib/components/Tile/Tile.js +6 -8
  176. package/lib/components/Toggletip/index.js +2 -2
  177. package/lib/components/Tooltip/DefinitionTooltip.js +2 -2
  178. package/lib/components/Tooltip/Tooltip.d.ts +1 -1
  179. package/lib/components/Tooltip/Tooltip.js +2 -2
  180. package/lib/components/TreeView/TreeNode.d.ts +5 -3
  181. package/lib/components/TreeView/TreeNode.js +4 -3
  182. package/lib/components/TreeView/TreeView.js +2 -2
  183. package/lib/components/UIShell/HeaderContainer.js +2 -2
  184. package/lib/components/UIShell/HeaderMenu.js +2 -2
  185. package/lib/components/UIShell/HeaderPanel.js +2 -2
  186. package/lib/components/UIShell/SideNav.d.ts +1 -1
  187. package/lib/components/UIShell/SideNav.js +2 -2
  188. package/lib/components/UIShell/SideNavHeader.d.ts +3 -2
  189. package/lib/components/UIShell/SideNavHeader.js +2 -1
  190. package/lib/components/UIShell/SideNavLink.d.ts +2 -2
  191. package/lib/components/UIShell/SideNavLink.js +1 -1
  192. package/lib/components/UIShell/SideNavMenu.d.ts +2 -2
  193. package/lib/components/UIShell/SideNavMenu.js +3 -3
  194. package/lib/components/UIShell/SwitcherItem.js +2 -2
  195. package/lib/internal/FloatingMenu.js +5 -5
  196. package/lib/internal/OptimizedResize.js +24 -21
  197. package/lib/internal/focus/index.js +19 -0
  198. package/lib/internal/keyboard/keys.js +2 -2
  199. package/lib/internal/keyboard/match.js +41 -17
  200. package/lib/internal/keyboard/navigation.js +27 -15
  201. package/lib/internal/useMergedRefs.js +0 -3
  202. package/package.json +6 -6
  203. package/telemetry.yml +0 -1
  204. package/es/components/Dialog/index.js +0 -177
  205. package/es/internal/OptimizedResize.d.ts +0 -18
  206. package/es/internal/keyboard/index.d.ts +0 -9
  207. package/es/internal/keyboard/keys.d.ts +0 -23
  208. package/es/internal/keyboard/match.d.ts +0 -26
  209. package/es/internal/keyboard/navigation.d.ts +0 -37
  210. package/lib/components/Dialog/index.js +0 -190
  211. package/lib/internal/OptimizedResize.d.ts +0 -18
  212. package/lib/internal/keyboard/index.d.ts +0 -9
  213. package/lib/internal/keyboard/keys.d.ts +0 -23
  214. package/lib/internal/keyboard/match.d.ts +0 -26
  215. package/lib/internal/keyboard/navigation.d.ts +0 -37
  216. package/scss/components/dialog/_dialog.scss +0 -9
  217. package/scss/components/dialog/_index.scss +0 -9
@@ -1,177 +0,0 @@
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, { useRef, useEffect } from 'react';
11
- import { usePrefix } from '../../internal/usePrefix.js';
12
- import cx from 'classnames';
13
- import { Close } from '@carbon/icons-react';
14
- import { IconButton } from '../IconButton/index.js';
15
- import { noopFn } from '../../internal/noopFn.js';
16
-
17
- const unstable__Dialog = /*#__PURE__*/React__default.forwardRef((_ref, forwardRef) => {
18
- let {
19
- children,
20
- className,
21
- modal,
22
- onCancel = noopFn,
23
- onClick = noopFn,
24
- onClose = noopFn,
25
- onRequestClose = noopFn,
26
- open = false,
27
- ...rest
28
- } = _ref;
29
- const prefix = usePrefix();
30
-
31
- // This component needs access to a ref, placed on the dialog, to call the
32
- // various imperative dialog functions (show(), close(), etc.).
33
- // If the parent component has not passed a ref for forwardRef, forwardRef
34
- // will be null. A "backup" ref is needed to ensure the dialog's instance
35
- // methods can always be called within this component.
36
- const backupRef = useRef(null);
37
- const ref = forwardRef ?? backupRef;
38
-
39
- // Clicks on the backdrop of an open modal dialog should request the consuming component to close
40
- // the dialog. Clicks elsewhere, or on non-modal dialogs should not request
41
- // to close the dialog.
42
- function handleModalBackdropClick(e) {
43
- if (open && modal && e.target === ref.current) {
44
- onRequestClose(e);
45
- }
46
- }
47
- function handleClick(e) {
48
- handleModalBackdropClick(e);
49
-
50
- // onClick should always be called, no matter if the target is a modal
51
- // dialog, modal dialog backdrop, or non-modal dialog.
52
- onClick(e);
53
- }
54
- useEffect(() => {
55
- if (ref.current) {
56
- if (open) {
57
- if (modal) {
58
- // Display the dialog as a modal, over the top of any other dialogs
59
- // that might be present. Everything outside the dialog are inert
60
- // with interactions outside the dialog being blocked.
61
- ref.current.showModal();
62
- } else {
63
- // Display the dialog modelessly, i.e. still allowing interaction
64
- // with content outside of the dialog.
65
- ref.current.show();
66
- }
67
- } else {
68
- ref.current.close();
69
- }
70
- }
71
- }, [modal, open]);
72
- return /*#__PURE__*/React__default.createElement("dialog", _extends({}, rest, {
73
- className: cx(`${prefix}--dialog`, {
74
- [`${prefix}--dialog--modal`]: modal
75
- }, className),
76
- ref: ref,
77
- onCancel: onCancel,
78
- onClick: handleClick,
79
- onClose: onClose
80
- }), children);
81
- });
82
- unstable__Dialog.displayName = 'Dialog';
83
- unstable__Dialog.propTypes = {
84
- /**
85
- * Provide children to be rendered inside of the Dialog
86
- */
87
- children: PropTypes.node,
88
- /**
89
- * Specify an optional className to be applied to the modal root node
90
- */
91
- className: PropTypes.string,
92
- /**
93
- * Modal specifies whether the Dialog is modal or non-modal. This cannot be
94
- * changed while open=true
95
- */
96
- modal: PropTypes.bool,
97
- /**
98
- * Specify a handler for closing Dialog.
99
- * The handler should care of closing Dialog, e.g. changing `open` prop.
100
- */
101
- onRequestClose: PropTypes.func,
102
- /**
103
- * open initial state
104
- */
105
- open: PropTypes.bool
106
- };
107
- const DialogHeader = /*#__PURE__*/React__default.forwardRef((_ref2, ref) => {
108
- let {
109
- children,
110
- ...rest
111
- } = _ref2;
112
- const prefix = usePrefix();
113
- return /*#__PURE__*/React__default.createElement("div", _extends({
114
- className: `${prefix}--dialog__header`,
115
- ref: ref
116
- }, rest), children);
117
- });
118
- DialogHeader.propTypes = {
119
- /**
120
- * Provide the contents to be rendered inside of this component
121
- */
122
- children: PropTypes.node
123
- };
124
- const DialogControls = /*#__PURE__*/React__default.forwardRef((_ref3, ref) => {
125
- let {
126
- children,
127
- ...rest
128
- } = _ref3;
129
- const prefix = usePrefix();
130
- return (
131
- /*#__PURE__*/
132
- // @ts-ignore
133
- React__default.createElement("div", _extends({
134
- className: `${prefix}--dialog__header-controls`,
135
- ref: ref
136
- }, rest), children)
137
- );
138
- });
139
- DialogControls.propTypes = {
140
- /**
141
- * Provide children to be rendered inside of this component
142
- */
143
- children: PropTypes.node
144
- };
145
- const DialogCloseButton = /*#__PURE__*/React__default.forwardRef((_ref4, ref) => {
146
- let {
147
- onClick,
148
- ...rest
149
- } = _ref4;
150
- const prefix = usePrefix();
151
- return (
152
- /*#__PURE__*/
153
- // @ts-ignore
154
- React__default.createElement(IconButton, _extends({
155
- kind: "ghost",
156
- className: `${prefix}--dialog__close`,
157
- label: "Close",
158
- title: "Close",
159
- "aria-label": "Close",
160
- align: "left",
161
- onClick: onClick
162
- }, rest), /*#__PURE__*/React__default.createElement(Close, {
163
- size: 20,
164
- "aria-hidden": "true",
165
- tabIndex: "-1",
166
- className: `${prefix}--icon__close`
167
- }))
168
- );
169
- });
170
- DialogCloseButton.propTypes = {
171
- /**
172
- * Specify a click handler applied to the IconButton
173
- */
174
- onClick: PropTypes.func
175
- };
176
-
177
- export { DialogCloseButton, DialogControls, DialogHeader, unstable__Dialog };
@@ -1,18 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 2016, 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
- /**
8
- * A callback function to be executed on `resize`.
9
- */
10
- type Callback = () => void;
11
- export declare const OptimizedResize: {
12
- /** Adds a callback function to be executed on window `resize`. */
13
- add: (callback: Callback) => {
14
- /** Removes the callback. */
15
- remove: () => void;
16
- };
17
- };
18
- export {};
@@ -1,9 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 2016, 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
- export * as keys from './keys';
8
- export * from './match';
9
- export * from './navigation';
@@ -1,23 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 2016, 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 { KeyboardEvent } from 'react';
8
- export type Key = Pick<KeyboardEvent, 'which' | 'keyCode' | 'code'> & {
9
- key?: string | string[];
10
- };
11
- export declare const Tab: Key;
12
- export declare const Enter: Key;
13
- export declare const Escape: Key;
14
- export declare const Space: Key;
15
- export declare const PageUp: Key;
16
- export declare const PageDown: Key;
17
- export declare const End: Key;
18
- export declare const Home: Key;
19
- export declare const ArrowLeft: Key;
20
- export declare const ArrowUp: Key;
21
- export declare const ArrowRight: Key;
22
- export declare const ArrowDown: Key;
23
- export declare const Delete: Key;
@@ -1,26 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 2016, 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 type { KeyboardEvent as ReactKeyboardEvent } from 'react';
8
- import type { Key } from './keys';
9
- /**
10
- * Check to see if at least one key code matches the key code of the
11
- * given event.
12
- *
13
- * @param event - The event to test.
14
- * @param keysToMatch - An array of key definitions to match against.
15
- * @returns `true` if one of the keys matches.
16
- */
17
- export declare const matches: (event: ReactKeyboardEvent | KeyboardEvent, keysToMatch: Key[]) => boolean;
18
- /**
19
- * Check to see if the given key matches the corresponding keyboard event. Also
20
- * supports passing in the value directly if you can't use the given event.
21
- *
22
- * @param eventOrCode - A `KeyboardEvent`, a number, or a string value.
23
- * @param keyObj - An object with key properties to match against.
24
- * @returns `true` if the event or code matches the key definition.
25
- */
26
- export declare const match: (eventOrCode: ReactKeyboardEvent | KeyboardEvent | number | string, { key, which, keyCode, code }: Key) => boolean;
@@ -1,37 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 2016, 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 { KeyboardEvent } from 'react';
8
- /**
9
- * A "ring buffer" function that takes an array and, depending on an ArrowRight
10
- * or ArrowLeft key input, loops from last index to first or first index to last.
11
- *
12
- * @param key - the left or right arrow key (KeyboardEvent, number, or string)
13
- * @param index - the current index in the array
14
- * @param arrayLength - the total length of the array
15
- *
16
- * @example
17
- * getNextIndex(keyCodes.RIGHT, 0, 4)
18
- */
19
- export declare const getNextIndex: (key: KeyboardEvent | number | string, index: number, arrayLength: number) => number | undefined;
20
- /**
21
- * A flag `node.compareDocumentPosition(target)` returns that indicates
22
- * `target` is located earlier than `node` in the document or `target` contains `node`.
23
- */
24
- export declare const DOCUMENT_POSITION_BROAD_PRECEDING: number;
25
- /**
26
- * A flag `node.compareDocumentPosition(target)` returns that indicates
27
- * `target` is located later than `node` in the document or `node` contains `target`.
28
- */
29
- export declare const DOCUMENT_POSITION_BROAD_FOLLOWING: number;
30
- /**
31
- * CSS selector that selects major nodes that are sequentially focusable.
32
- */
33
- export declare const selectorTabbable = "\n a[href], area[href], input:not([disabled]):not([tabindex='-1']),\n button:not([disabled]):not([tabindex='-1']),select:not([disabled]):not([tabindex='-1']),\n textarea:not([disabled]):not([tabindex='-1']),\n iframe, object, embed, *[tabindex]:not([tabindex='-1']):not([disabled]), *[contenteditable=true]\n";
34
- /**
35
- * CSS selector that selects major nodes that are click focusable.
36
- */
37
- export declare const selectorFocusable = "\n a[href], area[href], input:not([disabled]),\n button:not([disabled]),select:not([disabled]),\n textarea:not([disabled]),\n iframe, object, embed, *[tabindex]:not([disabled]), *[contenteditable=true]\n";
@@ -1,190 +0,0 @@
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
- 'use strict';
9
-
10
- Object.defineProperty(exports, '__esModule', { value: true });
11
-
12
- var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
13
- var PropTypes = require('prop-types');
14
- var React = require('react');
15
- var usePrefix = require('../../internal/usePrefix.js');
16
- var cx = require('classnames');
17
- var iconsReact = require('@carbon/icons-react');
18
- var index = require('../IconButton/index.js');
19
- var noopFn = require('../../internal/noopFn.js');
20
-
21
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
22
-
23
- var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
24
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
25
- var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
26
-
27
- const unstable__Dialog = /*#__PURE__*/React__default["default"].forwardRef((_ref, forwardRef) => {
28
- let {
29
- children,
30
- className,
31
- modal,
32
- onCancel = noopFn.noopFn,
33
- onClick = noopFn.noopFn,
34
- onClose = noopFn.noopFn,
35
- onRequestClose = noopFn.noopFn,
36
- open = false,
37
- ...rest
38
- } = _ref;
39
- const prefix = usePrefix.usePrefix();
40
-
41
- // This component needs access to a ref, placed on the dialog, to call the
42
- // various imperative dialog functions (show(), close(), etc.).
43
- // If the parent component has not passed a ref for forwardRef, forwardRef
44
- // will be null. A "backup" ref is needed to ensure the dialog's instance
45
- // methods can always be called within this component.
46
- const backupRef = React.useRef(null);
47
- const ref = forwardRef ?? backupRef;
48
-
49
- // Clicks on the backdrop of an open modal dialog should request the consuming component to close
50
- // the dialog. Clicks elsewhere, or on non-modal dialogs should not request
51
- // to close the dialog.
52
- function handleModalBackdropClick(e) {
53
- if (open && modal && e.target === ref.current) {
54
- onRequestClose(e);
55
- }
56
- }
57
- function handleClick(e) {
58
- handleModalBackdropClick(e);
59
-
60
- // onClick should always be called, no matter if the target is a modal
61
- // dialog, modal dialog backdrop, or non-modal dialog.
62
- onClick(e);
63
- }
64
- React.useEffect(() => {
65
- if (ref.current) {
66
- if (open) {
67
- if (modal) {
68
- // Display the dialog as a modal, over the top of any other dialogs
69
- // that might be present. Everything outside the dialog are inert
70
- // with interactions outside the dialog being blocked.
71
- ref.current.showModal();
72
- } else {
73
- // Display the dialog modelessly, i.e. still allowing interaction
74
- // with content outside of the dialog.
75
- ref.current.show();
76
- }
77
- } else {
78
- ref.current.close();
79
- }
80
- }
81
- }, [modal, open]);
82
- return /*#__PURE__*/React__default["default"].createElement("dialog", _rollupPluginBabelHelpers["extends"]({}, rest, {
83
- className: cx__default["default"](`${prefix}--dialog`, {
84
- [`${prefix}--dialog--modal`]: modal
85
- }, className),
86
- ref: ref,
87
- onCancel: onCancel,
88
- onClick: handleClick,
89
- onClose: onClose
90
- }), children);
91
- });
92
- unstable__Dialog.displayName = 'Dialog';
93
- unstable__Dialog.propTypes = {
94
- /**
95
- * Provide children to be rendered inside of the Dialog
96
- */
97
- children: PropTypes__default["default"].node,
98
- /**
99
- * Specify an optional className to be applied to the modal root node
100
- */
101
- className: PropTypes__default["default"].string,
102
- /**
103
- * Modal specifies whether the Dialog is modal or non-modal. This cannot be
104
- * changed while open=true
105
- */
106
- modal: PropTypes__default["default"].bool,
107
- /**
108
- * Specify a handler for closing Dialog.
109
- * The handler should care of closing Dialog, e.g. changing `open` prop.
110
- */
111
- onRequestClose: PropTypes__default["default"].func,
112
- /**
113
- * open initial state
114
- */
115
- open: PropTypes__default["default"].bool
116
- };
117
- const DialogHeader = /*#__PURE__*/React__default["default"].forwardRef((_ref2, ref) => {
118
- let {
119
- children,
120
- ...rest
121
- } = _ref2;
122
- const prefix = usePrefix.usePrefix();
123
- return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
124
- className: `${prefix}--dialog__header`,
125
- ref: ref
126
- }, rest), children);
127
- });
128
- DialogHeader.propTypes = {
129
- /**
130
- * Provide the contents to be rendered inside of this component
131
- */
132
- children: PropTypes__default["default"].node
133
- };
134
- const DialogControls = /*#__PURE__*/React__default["default"].forwardRef((_ref3, ref) => {
135
- let {
136
- children,
137
- ...rest
138
- } = _ref3;
139
- const prefix = usePrefix.usePrefix();
140
- return (
141
- /*#__PURE__*/
142
- // @ts-ignore
143
- React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
144
- className: `${prefix}--dialog__header-controls`,
145
- ref: ref
146
- }, rest), children)
147
- );
148
- });
149
- DialogControls.propTypes = {
150
- /**
151
- * Provide children to be rendered inside of this component
152
- */
153
- children: PropTypes__default["default"].node
154
- };
155
- const DialogCloseButton = /*#__PURE__*/React__default["default"].forwardRef((_ref4, ref) => {
156
- let {
157
- onClick,
158
- ...rest
159
- } = _ref4;
160
- const prefix = usePrefix.usePrefix();
161
- return (
162
- /*#__PURE__*/
163
- // @ts-ignore
164
- React__default["default"].createElement(index.IconButton, _rollupPluginBabelHelpers["extends"]({
165
- kind: "ghost",
166
- className: `${prefix}--dialog__close`,
167
- label: "Close",
168
- title: "Close",
169
- "aria-label": "Close",
170
- align: "left",
171
- onClick: onClick
172
- }, rest), /*#__PURE__*/React__default["default"].createElement(iconsReact.Close, {
173
- size: 20,
174
- "aria-hidden": "true",
175
- tabIndex: "-1",
176
- className: `${prefix}--icon__close`
177
- }))
178
- );
179
- });
180
- DialogCloseButton.propTypes = {
181
- /**
182
- * Specify a click handler applied to the IconButton
183
- */
184
- onClick: PropTypes__default["default"].func
185
- };
186
-
187
- exports.DialogCloseButton = DialogCloseButton;
188
- exports.DialogControls = DialogControls;
189
- exports.DialogHeader = DialogHeader;
190
- exports.unstable__Dialog = unstable__Dialog;
@@ -1,18 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 2016, 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
- /**
8
- * A callback function to be executed on `resize`.
9
- */
10
- type Callback = () => void;
11
- export declare const OptimizedResize: {
12
- /** Adds a callback function to be executed on window `resize`. */
13
- add: (callback: Callback) => {
14
- /** Removes the callback. */
15
- remove: () => void;
16
- };
17
- };
18
- export {};
@@ -1,9 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 2016, 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
- export * as keys from './keys';
8
- export * from './match';
9
- export * from './navigation';
@@ -1,23 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 2016, 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 { KeyboardEvent } from 'react';
8
- export type Key = Pick<KeyboardEvent, 'which' | 'keyCode' | 'code'> & {
9
- key?: string | string[];
10
- };
11
- export declare const Tab: Key;
12
- export declare const Enter: Key;
13
- export declare const Escape: Key;
14
- export declare const Space: Key;
15
- export declare const PageUp: Key;
16
- export declare const PageDown: Key;
17
- export declare const End: Key;
18
- export declare const Home: Key;
19
- export declare const ArrowLeft: Key;
20
- export declare const ArrowUp: Key;
21
- export declare const ArrowRight: Key;
22
- export declare const ArrowDown: Key;
23
- export declare const Delete: Key;
@@ -1,26 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 2016, 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 type { KeyboardEvent as ReactKeyboardEvent } from 'react';
8
- import type { Key } from './keys';
9
- /**
10
- * Check to see if at least one key code matches the key code of the
11
- * given event.
12
- *
13
- * @param event - The event to test.
14
- * @param keysToMatch - An array of key definitions to match against.
15
- * @returns `true` if one of the keys matches.
16
- */
17
- export declare const matches: (event: ReactKeyboardEvent | KeyboardEvent, keysToMatch: Key[]) => boolean;
18
- /**
19
- * Check to see if the given key matches the corresponding keyboard event. Also
20
- * supports passing in the value directly if you can't use the given event.
21
- *
22
- * @param eventOrCode - A `KeyboardEvent`, a number, or a string value.
23
- * @param keyObj - An object with key properties to match against.
24
- * @returns `true` if the event or code matches the key definition.
25
- */
26
- export declare const match: (eventOrCode: ReactKeyboardEvent | KeyboardEvent | number | string, { key, which, keyCode, code }: Key) => boolean;
@@ -1,37 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 2016, 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 { KeyboardEvent } from 'react';
8
- /**
9
- * A "ring buffer" function that takes an array and, depending on an ArrowRight
10
- * or ArrowLeft key input, loops from last index to first or first index to last.
11
- *
12
- * @param key - the left or right arrow key (KeyboardEvent, number, or string)
13
- * @param index - the current index in the array
14
- * @param arrayLength - the total length of the array
15
- *
16
- * @example
17
- * getNextIndex(keyCodes.RIGHT, 0, 4)
18
- */
19
- export declare const getNextIndex: (key: KeyboardEvent | number | string, index: number, arrayLength: number) => number | undefined;
20
- /**
21
- * A flag `node.compareDocumentPosition(target)` returns that indicates
22
- * `target` is located earlier than `node` in the document or `target` contains `node`.
23
- */
24
- export declare const DOCUMENT_POSITION_BROAD_PRECEDING: number;
25
- /**
26
- * A flag `node.compareDocumentPosition(target)` returns that indicates
27
- * `target` is located later than `node` in the document or `node` contains `target`.
28
- */
29
- export declare const DOCUMENT_POSITION_BROAD_FOLLOWING: number;
30
- /**
31
- * CSS selector that selects major nodes that are sequentially focusable.
32
- */
33
- export declare const selectorTabbable = "\n a[href], area[href], input:not([disabled]):not([tabindex='-1']),\n button:not([disabled]):not([tabindex='-1']),select:not([disabled]):not([tabindex='-1']),\n textarea:not([disabled]):not([tabindex='-1']),\n iframe, object, embed, *[tabindex]:not([tabindex='-1']):not([disabled]), *[contenteditable=true]\n";
34
- /**
35
- * CSS selector that selects major nodes that are click focusable.
36
- */
37
- export declare const selectorFocusable = "\n a[href], area[href], input:not([disabled]),\n button:not([disabled]),select:not([disabled]),\n textarea:not([disabled]),\n iframe, object, embed, *[tabindex]:not([disabled]), *[contenteditable=true]\n";
@@ -1,9 +0,0 @@
1
- // Code generated by @carbon/react. DO NOT EDIT.
2
- //
3
- // Copyright IBM Corp. 2018, 2025
4
- //
5
- // This source code is licensed under the Apache-2.0 license found in the
6
- // LICENSE file in the root directory of this source tree.
7
- //
8
-
9
- @forward '@carbon/styles/scss/components/dialog/dialog';
@@ -1,9 +0,0 @@
1
- // Code generated by @carbon/react. DO NOT EDIT.
2
- //
3
- // Copyright IBM Corp. 2018, 2025
4
- //
5
- // This source code is licensed under the Apache-2.0 license found in the
6
- // LICENSE file in the root directory of this source tree.
7
- //
8
-
9
- @forward '@carbon/styles/scss/components/dialog';