@carbon/react 1.77.0 → 1.78.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.
- package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +1038 -916
- package/es/components/Accordion/AccordionItem.js +1 -1
- package/es/components/BadgeIndicator/index.d.ts +23 -0
- package/es/components/BadgeIndicator/index.js +45 -0
- package/es/components/Breadcrumb/Breadcrumb.d.ts +5 -0
- package/es/components/Breadcrumb/Breadcrumb.js +8 -2
- package/es/components/Button/Button.d.ts +9 -0
- package/es/components/Button/Button.js +13 -0
- package/es/components/ComboBox/ComboBox.js +19 -15
- package/es/components/ComboButton/index.js +0 -1
- package/es/components/ContextMenu/useContextMenu.d.ts +0 -1
- package/es/components/ContextMenu/useContextMenu.js +1 -2
- package/es/components/Dropdown/Dropdown.d.ts +1 -1
- package/es/components/Dropdown/Dropdown.js +3 -2
- package/es/components/FileUploader/FileUploader.js +1 -1
- package/es/components/FileUploader/FileUploaderItem.js +1 -1
- package/es/components/IconButton/index.d.ts +7 -1
- package/es/components/IconButton/index.js +18 -2
- package/es/components/IconIndicator/index.d.ts +1 -1
- package/es/components/InlineLoading/InlineLoading.js +2 -5
- package/es/components/Menu/Menu.d.ts +1 -0
- package/es/components/Menu/Menu.js +5 -7
- package/es/components/Menu/MenuContext.d.ts +4 -4
- package/es/components/Menu/MenuContext.js +6 -1
- package/es/components/Menu/MenuItem.d.ts +1 -1
- package/es/components/Menu/MenuItem.js +15 -23
- package/es/components/MenuButton/index.js +14 -2
- package/es/components/Modal/Modal.d.ts +3 -3
- package/es/components/Modal/Modal.js +9 -3
- package/es/components/Modal/next/index.d.ts +1 -5
- package/es/components/MultiSelect/MultiSelect.js +3 -2
- package/es/components/MultiSelect/MultiSelectPropTypes.d.ts +5 -2
- package/es/components/MultiSelect/tools/sorting.js +8 -7
- package/es/components/Notification/Notification.js +5 -6
- package/es/components/NumberInput/NumberInput.js +12 -12
- package/es/components/OverflowMenu/OverflowMenu.d.ts +8 -20
- package/es/components/OverflowMenu/OverflowMenu.js +7 -9
- package/es/components/OverflowMenuItem/OverflowMenuItem.js +1 -1
- package/es/components/ProgressIndicator/ProgressIndicator.js +1 -1
- package/es/components/RadioTile/RadioTile.js +1 -1
- package/es/components/Select/Select.js +11 -2
- package/es/components/ShapeIndicator/index.d.ts +29 -0
- package/es/components/ShapeIndicator/index.js +92 -0
- package/es/components/Tabs/Tabs.d.ts +6 -4
- package/es/components/Tabs/Tabs.js +27 -8
- package/es/components/Tag/OperationalTag.d.ts +1 -36
- package/es/components/Tag/OperationalTag.js +7 -5
- package/es/components/Text/Text.d.ts +11 -9
- package/es/components/Text/Text.js +6 -6
- package/es/components/Text/TextDirection.d.ts +7 -9
- package/es/components/Text/TextDirection.js +5 -2
- package/es/components/Text/TextDirectionContext.d.ts +14 -0
- package/es/components/Text/TextDirectionContext.js +6 -2
- package/es/components/Text/createTextComponent.d.ts +5 -5
- package/es/components/Text/createTextComponent.js +5 -4
- package/es/components/Text/index.d.ts +6 -7
- package/es/components/Text/index.js +3 -2
- package/es/components/Tile/Tile.d.ts +6 -0
- package/es/components/Tile/Tile.js +5 -9
- package/es/components/Toggletip/index.d.ts +3 -2
- package/es/components/Tooltip/DefinitionTooltip.d.ts +4 -0
- package/es/components/Tooltip/DefinitionTooltip.js +7 -1
- package/es/components/Tooltip/Tooltip.d.ts +5 -66
- package/es/components/Tooltip/Tooltip.js +26 -26
- package/es/components/UIShell/HeaderGlobalAction.d.ts +9 -0
- package/es/components/UIShell/HeaderGlobalAction.js +16 -1
- package/es/index.d.ts +4 -1
- package/es/index.js +2 -1
- package/es/internal/FloatingMenu.d.ts +83 -0
- package/es/internal/FloatingMenu.js +216 -408
- package/es/internal/wrapFocus.js +1 -1
- package/lib/components/Accordion/AccordionItem.js +1 -1
- package/lib/components/BadgeIndicator/index.d.ts +23 -0
- package/lib/components/BadgeIndicator/index.js +56 -0
- package/lib/components/Breadcrumb/Breadcrumb.d.ts +5 -0
- package/lib/components/Breadcrumb/Breadcrumb.js +8 -2
- package/lib/components/Button/Button.d.ts +9 -0
- package/lib/components/Button/Button.js +13 -0
- package/lib/components/ComboBox/ComboBox.js +19 -15
- package/lib/components/ComboButton/index.js +0 -1
- package/lib/components/ContextMenu/useContextMenu.d.ts +0 -1
- package/lib/components/ContextMenu/useContextMenu.js +1 -2
- package/lib/components/Dropdown/Dropdown.d.ts +1 -1
- package/lib/components/Dropdown/Dropdown.js +2 -1
- package/lib/components/FileUploader/FileUploader.js +1 -1
- package/lib/components/FileUploader/FileUploaderItem.js +1 -1
- package/lib/components/IconButton/index.d.ts +7 -1
- package/lib/components/IconButton/index.js +18 -2
- package/lib/components/IconIndicator/index.d.ts +1 -1
- package/lib/components/InlineLoading/InlineLoading.js +2 -5
- package/lib/components/Menu/Menu.d.ts +1 -0
- package/lib/components/Menu/Menu.js +5 -7
- package/lib/components/Menu/MenuContext.d.ts +4 -4
- package/lib/components/Menu/MenuContext.js +6 -1
- package/lib/components/Menu/MenuItem.d.ts +1 -1
- package/lib/components/Menu/MenuItem.js +14 -22
- package/lib/components/MenuButton/index.js +14 -2
- package/lib/components/Modal/Modal.d.ts +3 -3
- package/lib/components/Modal/Modal.js +9 -3
- package/lib/components/Modal/next/index.d.ts +1 -5
- package/lib/components/MultiSelect/MultiSelect.js +2 -1
- package/lib/components/MultiSelect/MultiSelectPropTypes.d.ts +5 -2
- package/lib/components/MultiSelect/tools/sorting.js +8 -7
- package/lib/components/Notification/Notification.js +5 -6
- package/lib/components/NumberInput/NumberInput.js +12 -12
- package/lib/components/OverflowMenu/OverflowMenu.d.ts +8 -20
- package/lib/components/OverflowMenu/OverflowMenu.js +7 -9
- package/lib/components/OverflowMenuItem/OverflowMenuItem.js +1 -1
- package/lib/components/ProgressIndicator/ProgressIndicator.js +1 -1
- package/lib/components/RadioTile/RadioTile.js +1 -1
- package/lib/components/Select/Select.js +11 -2
- package/lib/components/ShapeIndicator/index.d.ts +29 -0
- package/lib/components/ShapeIndicator/index.js +104 -0
- package/lib/components/Tabs/Tabs.d.ts +6 -4
- package/lib/components/Tabs/Tabs.js +42 -23
- package/lib/components/Tag/OperationalTag.d.ts +1 -36
- package/lib/components/Tag/OperationalTag.js +6 -4
- package/lib/components/Text/Text.d.ts +11 -9
- package/lib/components/Text/Text.js +5 -5
- package/lib/components/Text/TextDirection.d.ts +7 -9
- package/lib/components/Text/TextDirection.js +5 -2
- package/lib/components/Text/TextDirectionContext.d.ts +14 -0
- package/lib/components/Text/TextDirectionContext.js +6 -2
- package/lib/components/Text/createTextComponent.d.ts +5 -5
- package/lib/components/Text/createTextComponent.js +5 -4
- package/lib/components/Text/index.d.ts +6 -7
- package/lib/components/Text/index.js +4 -3
- package/lib/components/Tile/Tile.d.ts +6 -0
- package/lib/components/Tile/Tile.js +5 -9
- package/lib/components/Toggletip/index.d.ts +3 -2
- package/lib/components/Tooltip/DefinitionTooltip.d.ts +4 -0
- package/lib/components/Tooltip/DefinitionTooltip.js +7 -1
- package/lib/components/Tooltip/Tooltip.d.ts +5 -66
- package/lib/components/Tooltip/Tooltip.js +26 -26
- package/lib/components/UIShell/HeaderGlobalAction.d.ts +9 -0
- package/lib/components/UIShell/HeaderGlobalAction.js +16 -1
- package/lib/index.d.ts +4 -1
- package/lib/index.js +42 -40
- package/lib/internal/FloatingMenu.d.ts +83 -0
- package/lib/internal/FloatingMenu.js +216 -409
- package/lib/internal/wrapFocus.js +1 -1
- package/package.json +5 -5
- package/scss/components/badge-indicator/_badge-indicator.scss +9 -0
- package/scss/components/badge-indicator/_index.scss +9 -0
|
@@ -10,20 +10,19 @@ import cx from 'classnames';
|
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
11
|
import React__default, { forwardRef, useState, useContext, useRef, useEffect } from 'react';
|
|
12
12
|
import { useFloating, autoUpdate, offset, useInteractions, useHover, safePolygon, FloatingFocusManager } from '@floating-ui/react';
|
|
13
|
-
import { CaretLeft, CaretRight
|
|
13
|
+
import { Checkmark, CaretLeft, CaretRight } from '@carbon/icons-react';
|
|
14
14
|
import { useControllableState } from '../../internal/useControllableState.js';
|
|
15
15
|
import { useMergedRefs } from '../../internal/useMergedRefs.js';
|
|
16
16
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
17
|
-
import { warning } from '../../internal/warning.js';
|
|
18
17
|
import { Menu } from './Menu.js';
|
|
19
18
|
import { MenuContext } from './MenuContext.js';
|
|
20
19
|
import '../Text/index.js';
|
|
21
20
|
import { useLayoutDirection } from '../LayoutDirection/useLayoutDirection.js';
|
|
22
|
-
import { Text } from '../Text/Text.js';
|
|
23
21
|
import { match } from '../../internal/keyboard/match.js';
|
|
22
|
+
import { Text } from '../Text/Text.js';
|
|
24
23
|
import { ArrowRight, Enter, Space } from '../../internal/keyboard/keys.js';
|
|
25
24
|
|
|
26
|
-
var _CaretLeft, _CaretRight;
|
|
25
|
+
var _Checkmark, _CaretLeft, _CaretRight;
|
|
27
26
|
const MenuItem = /*#__PURE__*/forwardRef(function MenuItem(_ref, forwardRef) {
|
|
28
27
|
let {
|
|
29
28
|
children,
|
|
@@ -134,15 +133,14 @@ const MenuItem = /*#__PURE__*/forwardRef(function MenuItem(_ref, forwardRef) {
|
|
|
134
133
|
setRtl(false);
|
|
135
134
|
}
|
|
136
135
|
}, [direction]);
|
|
137
|
-
const iconsAllowed = context.state.mode === 'basic' || rest.role === 'menuitemcheckbox' || rest.role === 'menuitemradio';
|
|
138
136
|
useEffect(() => {
|
|
139
|
-
if (
|
|
137
|
+
if (IconElement && !context.state.hasIcons) {
|
|
140
138
|
// @ts-ignore - TODO: Should we be passing payload?
|
|
141
139
|
context.dispatch({
|
|
142
140
|
type: 'enableIcons'
|
|
143
141
|
});
|
|
144
142
|
}
|
|
145
|
-
}, [
|
|
143
|
+
}, [IconElement, context.state.hasIcons, context]);
|
|
146
144
|
useEffect(() => {
|
|
147
145
|
Object.keys(floatingStyles).forEach(style => {
|
|
148
146
|
if (refs.floating.current && style !== 'position') {
|
|
@@ -166,8 +164,10 @@ const MenuItem = /*#__PURE__*/forwardRef(function MenuItem(_ref, forwardRef) {
|
|
|
166
164
|
onClick: handleClick,
|
|
167
165
|
onKeyDown: handleKeyDown
|
|
168
166
|
}, getReferenceProps()), /*#__PURE__*/React__default.createElement("div", {
|
|
167
|
+
className: `${prefix}--menu-item__selection-icon`
|
|
168
|
+
}, rest['aria-checked'] && (_Checkmark || (_Checkmark = /*#__PURE__*/React__default.createElement(Checkmark, null)))), /*#__PURE__*/React__default.createElement("div", {
|
|
169
169
|
className: `${prefix}--menu-item__icon`
|
|
170
|
-
},
|
|
170
|
+
}, IconElement && /*#__PURE__*/React__default.createElement(IconElement, null)), /*#__PURE__*/React__default.createElement(Text, {
|
|
171
171
|
as: "div",
|
|
172
172
|
className: `${prefix}--menu-item__label`,
|
|
173
173
|
title: label
|
|
@@ -212,7 +212,7 @@ MenuItem.propTypes = {
|
|
|
212
212
|
// @ts-ignore-next-line -- avoid spurious (?) TS2322 error
|
|
213
213
|
onClick: PropTypes.func,
|
|
214
214
|
/**
|
|
215
|
-
*
|
|
215
|
+
* Sets the menu item's icon.
|
|
216
216
|
*/
|
|
217
217
|
// @ts-ignore-next-line -- avoid spurious (?) TS2322 error
|
|
218
218
|
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
@@ -233,9 +233,6 @@ const MenuItemSelectable = /*#__PURE__*/forwardRef(function MenuItemSelectable(_
|
|
|
233
233
|
} = _ref2;
|
|
234
234
|
const prefix = usePrefix();
|
|
235
235
|
const context = useContext(MenuContext);
|
|
236
|
-
if (context.state.mode === 'basic') {
|
|
237
|
-
process.env.NODE_ENV !== "production" ? warning(false, 'MenuItemSelectable is not supported when the menu is in "basic" mode.') : void 0;
|
|
238
|
-
}
|
|
239
236
|
const [checked, setChecked] = useControllableState({
|
|
240
237
|
value: selected,
|
|
241
238
|
onChange,
|
|
@@ -245,13 +242,13 @@ const MenuItemSelectable = /*#__PURE__*/forwardRef(function MenuItemSelectable(_
|
|
|
245
242
|
setChecked(!checked);
|
|
246
243
|
}
|
|
247
244
|
useEffect(() => {
|
|
248
|
-
if (!context.state.
|
|
245
|
+
if (!context.state.hasSelectableItems) {
|
|
249
246
|
// @ts-ignore - TODO: Should we be passing payload?
|
|
250
247
|
context.dispatch({
|
|
251
|
-
type: '
|
|
248
|
+
type: 'enableSelectableItems'
|
|
252
249
|
});
|
|
253
250
|
}
|
|
254
|
-
}, [context.state.
|
|
251
|
+
}, [context.state.hasSelectableItems, context]);
|
|
255
252
|
const classNames = cx(className, `${prefix}--menu-item-selectable--selected`);
|
|
256
253
|
return /*#__PURE__*/React__default.createElement(MenuItem, _extends({}, rest, {
|
|
257
254
|
ref: forwardRef,
|
|
@@ -259,7 +256,6 @@ const MenuItemSelectable = /*#__PURE__*/forwardRef(function MenuItemSelectable(_
|
|
|
259
256
|
className: classNames,
|
|
260
257
|
role: "menuitemcheckbox",
|
|
261
258
|
"aria-checked": checked,
|
|
262
|
-
renderIcon: checked ? Checkmark : undefined,
|
|
263
259
|
onClick: handleClick
|
|
264
260
|
}));
|
|
265
261
|
});
|
|
@@ -334,9 +330,6 @@ const MenuItemRadioGroup = /*#__PURE__*/forwardRef(function MenuItemRadioGroup(_
|
|
|
334
330
|
} = _ref4;
|
|
335
331
|
const prefix = usePrefix();
|
|
336
332
|
const context = useContext(MenuContext);
|
|
337
|
-
if (context.state.mode === 'basic') {
|
|
338
|
-
process.env.NODE_ENV !== "production" ? warning(false, 'MenuItemRadioGroup is not supported when the menu is in "basic" mode.') : void 0;
|
|
339
|
-
}
|
|
340
333
|
const [selection, setSelection] = useControllableState({
|
|
341
334
|
value: selectedItem,
|
|
342
335
|
onChange,
|
|
@@ -346,13 +339,13 @@ const MenuItemRadioGroup = /*#__PURE__*/forwardRef(function MenuItemRadioGroup(_
|
|
|
346
339
|
setSelection(item);
|
|
347
340
|
}
|
|
348
341
|
useEffect(() => {
|
|
349
|
-
if (!context.state.
|
|
342
|
+
if (!context.state.hasSelectableItems) {
|
|
350
343
|
// @ts-ignore - TODO: Should we be passing payload?
|
|
351
344
|
context.dispatch({
|
|
352
|
-
type: '
|
|
345
|
+
type: 'enableSelectableItems'
|
|
353
346
|
});
|
|
354
347
|
}
|
|
355
|
-
}, [context.state.
|
|
348
|
+
}, [context.state.hasSelectableItems, context]);
|
|
356
349
|
const classNames = cx(className, `${prefix}--menu-item-radio-group`);
|
|
357
350
|
return /*#__PURE__*/React__default.createElement("li", {
|
|
358
351
|
className: classNames,
|
|
@@ -366,7 +359,6 @@ const MenuItemRadioGroup = /*#__PURE__*/forwardRef(function MenuItemRadioGroup(_
|
|
|
366
359
|
label: itemToString(item),
|
|
367
360
|
role: "menuitemradio",
|
|
368
361
|
"aria-checked": item === selection,
|
|
369
|
-
renderIcon: item === selection ? Checkmark : undefined,
|
|
370
362
|
onClick: e => {
|
|
371
363
|
handleClick(item);
|
|
372
364
|
}
|
|
@@ -73,6 +73,15 @@ const MenuButton = /*#__PURE__*/forwardRef(function MenuButton(_ref, forwardRef)
|
|
|
73
73
|
// “break” the floating element out of a clipping ancestor.
|
|
74
74
|
// https://floating-ui.com/docs/misc#clipping
|
|
75
75
|
strategy: 'fixed',
|
|
76
|
+
// Submenus are using a fixed position to break out of the parent menu's
|
|
77
|
+
// box avoiding clipping while allowing for vertical scroll. When an
|
|
78
|
+
// element is using transform it establishes a new containing block
|
|
79
|
+
// block for all of its descendants. Therefore, its padding box will be
|
|
80
|
+
// used for fixed-positioned descendants. This would cause the submenu
|
|
81
|
+
// to be clipped by its parent menu.
|
|
82
|
+
// Reference: https://www.w3.org/TR/2019/CR-css-transforms-1-20190214/#current-transformation-matrix-computation
|
|
83
|
+
// Reference: https://github.com/carbon-design-system/carbon/pull/18153#issuecomment-2498548835
|
|
84
|
+
transform: false,
|
|
76
85
|
// Middleware order matters, arrow should be last
|
|
77
86
|
middleware: middlewares,
|
|
78
87
|
whileElementsMounted: autoUpdate
|
|
@@ -87,7 +96,11 @@ const MenuButton = /*#__PURE__*/forwardRef(function MenuButton(_ref, forwardRef)
|
|
|
87
96
|
useLayoutEffect(() => {
|
|
88
97
|
Object.keys(floatingStyles).forEach(style => {
|
|
89
98
|
if (refs.floating.current) {
|
|
90
|
-
|
|
99
|
+
let value = floatingStyles[style];
|
|
100
|
+
if (['top', 'right', 'bottom', 'left'].includes(style) && Number(value)) {
|
|
101
|
+
value += 'px';
|
|
102
|
+
}
|
|
103
|
+
refs.floating.current.style[style] = value;
|
|
91
104
|
}
|
|
92
105
|
});
|
|
93
106
|
}, [floatingStyles, refs.floating, middlewareData, placement, open]);
|
|
@@ -126,7 +139,6 @@ const MenuButton = /*#__PURE__*/forwardRef(function MenuButton(_ref, forwardRef)
|
|
|
126
139
|
id: id,
|
|
127
140
|
legacyAutoalign: false,
|
|
128
141
|
label: label,
|
|
129
|
-
mode: "basic",
|
|
130
142
|
size: size$1,
|
|
131
143
|
open: open,
|
|
132
144
|
onClose: handleClose,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2016,
|
|
2
|
+
* Copyright IBM Corp. 2016, 2025
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import React, { ReactNode } from 'react';
|
|
7
|
+
import React, { type ReactNode, type Ref } from 'react';
|
|
8
8
|
import { ReactAttr } from '../../types/common';
|
|
9
9
|
import { InlineLoadingStatus } from '../InlineLoading/InlineLoading';
|
|
10
10
|
export declare const ModalSizes: readonly ["xs", "sm", "md", "lg"];
|
|
@@ -58,7 +58,7 @@ export interface ModalProps extends ReactAttr<HTMLDivElement> {
|
|
|
58
58
|
/**
|
|
59
59
|
* Provide a ref to return focus to once the modal is closed.
|
|
60
60
|
*/
|
|
61
|
-
launcherButtonRef?:
|
|
61
|
+
launcherButtonRef?: Ref<HTMLButtonElement>;
|
|
62
62
|
/**
|
|
63
63
|
* Specify the description for the loading text
|
|
64
64
|
*/
|
|
@@ -28,8 +28,8 @@ import { useFeatureFlag } from '../FeatureFlags/index.js';
|
|
|
28
28
|
import { composeEventHandlers } from '../../tools/events.js';
|
|
29
29
|
import deprecate from '../../prop-types/deprecate.js';
|
|
30
30
|
import { debounce } from '../../node_modules/es-toolkit/dist/compat/function/debounce.mjs.js';
|
|
31
|
-
import { Text } from '../Text/Text.js';
|
|
32
31
|
import { match } from '../../internal/keyboard/match.js';
|
|
32
|
+
import { Text } from '../Text/Text.js';
|
|
33
33
|
import { Escape, Enter, Tab } from '../../internal/keyboard/keys.js';
|
|
34
34
|
|
|
35
35
|
const ModalSizes = ['xs', 'sm', 'md', 'lg'];
|
|
@@ -190,7 +190,9 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
|
|
|
190
190
|
useEffect(() => {
|
|
191
191
|
if (!open && launcherButtonRef) {
|
|
192
192
|
setTimeout(() => {
|
|
193
|
-
launcherButtonRef
|
|
193
|
+
if ('current' in launcherButtonRef) {
|
|
194
|
+
launcherButtonRef.current?.focus();
|
|
195
|
+
}
|
|
194
196
|
});
|
|
195
197
|
}
|
|
196
198
|
}, [open, launcherButtonRef]);
|
|
@@ -373,7 +375,11 @@ Modal.propTypes = {
|
|
|
373
375
|
* Provide a ref to return focus to once the modal is closed.
|
|
374
376
|
*/
|
|
375
377
|
launcherButtonRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
376
|
-
current: PropTypes.
|
|
378
|
+
current: PropTypes.oneOfType([
|
|
379
|
+
// `PropTypes.instanceOf(HTMLButtonElement)` alone won't work because
|
|
380
|
+
// `HTMLButtonElement` is not defined in the test environment even
|
|
381
|
+
// though `testEnvironment` is set to `jsdom`.
|
|
382
|
+
typeof HTMLButtonElement !== 'undefined' ? PropTypes.instanceOf(HTMLButtonElement) : PropTypes.any, PropTypes.oneOf([null])]).isRequired
|
|
377
383
|
})]),
|
|
378
384
|
/**
|
|
379
385
|
* Specify the description for the loading text
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2016,
|
|
2
|
+
* Copyright IBM Corp. 2016, 2025
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -50,10 +50,6 @@ export interface BaseModalProps extends ReactAttr<HTMLDivElement> {
|
|
|
50
50
|
* Specify whether or not the Modal content should have any inner padding.
|
|
51
51
|
*/
|
|
52
52
|
isFullWidth?: boolean;
|
|
53
|
-
/**
|
|
54
|
-
* Provide a ref to return focus to once the modal is closed.
|
|
55
|
-
*/
|
|
56
|
-
launcherButtonRef?: any;
|
|
57
53
|
/**
|
|
58
54
|
* Specify the description for the loading text
|
|
59
55
|
*/
|
|
@@ -11,7 +11,7 @@ import cx from 'classnames';
|
|
|
11
11
|
import { useSelect } from 'downshift';
|
|
12
12
|
import isEqual from 'react-fast-compare';
|
|
13
13
|
import PropTypes from 'prop-types';
|
|
14
|
-
import React__default, { useMemo, useContext, useState, useLayoutEffect } from 'react';
|
|
14
|
+
import React__default, { useMemo, useContext, useState, useLayoutEffect, isValidElement } from 'react';
|
|
15
15
|
import ListBox from '../ListBox/index.js';
|
|
16
16
|
import { sortingPropTypes } from './MultiSelectPropTypes.js';
|
|
17
17
|
import { defaultSortItems, defaultCompareItems } from './tools/sorting.js';
|
|
@@ -424,11 +424,12 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
424
424
|
const menuProps = useMemo(() => getMenuProps({
|
|
425
425
|
ref: enableFloatingStyles ? refs.setFloating : null
|
|
426
426
|
}), [enableFloatingStyles, getMenuProps, refs.setFloating]);
|
|
427
|
+
const labelProps = ! /*#__PURE__*/isValidElement(titleText) ? getLabelProps() : null;
|
|
427
428
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
428
429
|
className: wrapperClasses
|
|
429
430
|
}, /*#__PURE__*/React__default.createElement("label", _extends({
|
|
430
431
|
className: titleClasses
|
|
431
|
-
},
|
|
432
|
+
}, labelProps), titleText && titleText, selectedItems.length > 0 && /*#__PURE__*/React__default.createElement("span", {
|
|
432
433
|
className: `${prefix}--visually-hidden`
|
|
433
434
|
}, clearSelectionDescription, " ", selectedItems.length, ' ', itemsSelectedText, ",", clearSelectionText)), /*#__PURE__*/React__default.createElement(ListBox, {
|
|
434
435
|
onFocus: isFluid ? handleFocus : undefined,
|
|
@@ -40,8 +40,11 @@ interface DownshiftTypedProps<ItemType> {
|
|
|
40
40
|
interface SharedOptions {
|
|
41
41
|
locale: string;
|
|
42
42
|
}
|
|
43
|
+
interface CompareItems {
|
|
44
|
+
(itemA: string, itemB: string, options: SharedOptions): number;
|
|
45
|
+
}
|
|
43
46
|
export interface SortItemsOptions<ItemType> extends SharedOptions, DownshiftTypedProps<ItemType> {
|
|
44
|
-
compareItems
|
|
47
|
+
compareItems: CompareItems;
|
|
45
48
|
selectedItems: ItemType[];
|
|
46
49
|
}
|
|
47
50
|
export interface MultiSelectSortingProps<ItemType> {
|
|
@@ -49,7 +52,7 @@ export interface MultiSelectSortingProps<ItemType> {
|
|
|
49
52
|
* Provide a compare function that is used to determine the ordering of
|
|
50
53
|
* options. See 'sortItems' for more control.
|
|
51
54
|
*/
|
|
52
|
-
compareItems
|
|
55
|
+
compareItems?: CompareItems;
|
|
53
56
|
/**
|
|
54
57
|
* Provide a method that sorts all options in the control. Overriding this
|
|
55
58
|
* prop means that you also have to handle the sort logic for selected versus
|
|
@@ -6,14 +6,15 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* Use the
|
|
10
|
-
*
|
|
9
|
+
* Use the locale `localeCompare` with the `numeric` option to sort two
|
|
10
|
+
* alpha-numeric strings.
|
|
11
11
|
*
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {
|
|
14
|
-
* @param {object} options
|
|
15
|
-
* @param {string} options.locale
|
|
16
|
-
* @returns {number}
|
|
12
|
+
* @param {string} itemA - The first string to compare.
|
|
13
|
+
* @param {string} itemB - The second string to compare.
|
|
14
|
+
* @param {object} options - Options for comparing.
|
|
15
|
+
* @param {string} options.locale - The locale to use for comparison.
|
|
16
|
+
* @returns {number} A negative number if itemA comes before itemB, a positive
|
|
17
|
+
* number if itemA comes after itemB, or 0 if they are equal.
|
|
17
18
|
*/
|
|
18
19
|
const defaultCompareItems = (itemA, itemB, _ref) => {
|
|
19
20
|
let {
|
|
@@ -23,8 +23,8 @@ import wrapFocus, { wrapFocusWithoutSentinels } from '../../internal/wrapFocus.j
|
|
|
23
23
|
import { useFeatureFlag } from '../FeatureFlags/index.js';
|
|
24
24
|
import { warning } from '../../internal/warning.js';
|
|
25
25
|
import deprecateValuesWithin from '../../prop-types/deprecateValuesWithin.js';
|
|
26
|
-
import { Text } from '../Text/Text.js';
|
|
27
26
|
import { match, matches } from '../../internal/keyboard/match.js';
|
|
27
|
+
import { Text } from '../Text/Text.js';
|
|
28
28
|
import { Tab, Escape } from '../../internal/keyboard/keys.js';
|
|
29
29
|
|
|
30
30
|
/**
|
|
@@ -730,11 +730,9 @@ function Callout(_ref8) {
|
|
|
730
730
|
[`${prefix}--actionable-notification--${kind}`]: kind,
|
|
731
731
|
[`${prefix}--actionable-notification--hide-close-button`]: true
|
|
732
732
|
});
|
|
733
|
-
const
|
|
734
|
-
useInteractiveChildrenNeedDescription(
|
|
735
|
-
return /*#__PURE__*/React__default.createElement("div", _extends({
|
|
736
|
-
ref: ref
|
|
737
|
-
}, rest, {
|
|
733
|
+
const childrenContainer = useRef(null);
|
|
734
|
+
useInteractiveChildrenNeedDescription(childrenContainer, `interactive child node(s) should have an \`aria-describedby\` property with a value matching the value of \`titleId\``);
|
|
735
|
+
return /*#__PURE__*/React__default.createElement("div", _extends({}, rest, {
|
|
738
736
|
className: containerClassName
|
|
739
737
|
}), /*#__PURE__*/React__default.createElement("div", {
|
|
740
738
|
className: `${prefix}--actionable-notification__details`
|
|
@@ -743,6 +741,7 @@ function Callout(_ref8) {
|
|
|
743
741
|
kind: kind,
|
|
744
742
|
iconDescription: statusIconDescription || `${kind} icon`
|
|
745
743
|
}), /*#__PURE__*/React__default.createElement("div", {
|
|
744
|
+
ref: childrenContainer,
|
|
746
745
|
className: `${prefix}--actionable-notification__text-wrapper`
|
|
747
746
|
}, title && /*#__PURE__*/React__default.createElement(Text, {
|
|
748
747
|
as: "div",
|
|
@@ -163,20 +163,20 @@ const NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(
|
|
|
163
163
|
[`${prefix}--number-input--fluid--disabled`]: isFluid && disabled
|
|
164
164
|
});
|
|
165
165
|
const Icon = normalizedProps.icon;
|
|
166
|
-
|
|
166
|
+
const getDecimalPlaces = num => {
|
|
167
|
+
const parts = num.toString().split('.');
|
|
168
|
+
return parts[1] ? parts[1].length : 0;
|
|
169
|
+
};
|
|
170
|
+
const handleStepperClick = (event, direction) => {
|
|
167
171
|
if (inputRef.current) {
|
|
168
172
|
const currentValue = Number(inputRef.current.value);
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
if (max !== undefined) {
|
|
174
|
-
newValue = Math.min(newValue, max);
|
|
175
|
-
}
|
|
176
|
-
const currentInputValue = inputRef.current ? inputRef.current.value : '';
|
|
173
|
+
const rawValue = direction === 'up' ? currentValue + step : currentValue - step;
|
|
174
|
+
const precision = Math.max(getDecimalPlaces(currentValue), getDecimalPlaces(step));
|
|
175
|
+
const floatValue = parseFloat(rawValue.toFixed(precision));
|
|
176
|
+
const newValue = typeof min !== 'undefined' && typeof max !== 'undefined' ? Math.min(Math.max(floatValue, min), max) : floatValue;
|
|
177
177
|
const state = {
|
|
178
|
-
value: allowEmpty &&
|
|
179
|
-
direction
|
|
178
|
+
value: allowEmpty && inputRef.current.value === '' && step === 0 ? '' : newValue,
|
|
179
|
+
direction
|
|
180
180
|
};
|
|
181
181
|
setValue(state.value);
|
|
182
182
|
if (onChange) {
|
|
@@ -186,7 +186,7 @@ const NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(
|
|
|
186
186
|
onClick(event, state);
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
|
-
}
|
|
189
|
+
};
|
|
190
190
|
|
|
191
191
|
// AILabel always size `mini`
|
|
192
192
|
let normalizedDecorator = /*#__PURE__*/React__default.isValidElement(slug ?? decorator) ? slug ?? decorator : null;
|
|
@@ -1,25 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2016,
|
|
2
|
+
* Copyright IBM Corp. 2016, 2025
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
+
import { type MenuDirection, type MenuOffset } from '../../internal/FloatingMenu';
|
|
7
8
|
import React, { ComponentType } from 'react';
|
|
8
9
|
import PropTypes from 'prop-types';
|
|
9
|
-
|
|
10
|
-
* @param {Element} menuBody The menu body with the menu arrow.
|
|
11
|
-
* @param {string} direction The floating menu direction.
|
|
12
|
-
* @returns {FloatingMenu~offset} The adjustment of the floating menu position, upon the position of the menu arrow.
|
|
13
|
-
* @private
|
|
14
|
-
*/
|
|
15
|
-
export declare const getMenuOffset: (menuBody: any, direction: any, trigger: any, flip: any) => {
|
|
16
|
-
left: number;
|
|
17
|
-
top: number;
|
|
18
|
-
} | undefined;
|
|
19
|
-
interface Offset {
|
|
20
|
-
top?: number | null | undefined;
|
|
21
|
-
left?: number | null | undefined;
|
|
22
|
-
}
|
|
10
|
+
export declare const getMenuOffset: MenuOffset;
|
|
23
11
|
type IconProps = {
|
|
24
12
|
className?: string;
|
|
25
13
|
'aria-label'?: string;
|
|
@@ -46,7 +34,7 @@ export interface OverflowMenuProps {
|
|
|
46
34
|
/**
|
|
47
35
|
* The menu direction.
|
|
48
36
|
*/
|
|
49
|
-
direction?:
|
|
37
|
+
direction?: MenuDirection;
|
|
50
38
|
/**
|
|
51
39
|
* `true` if the menu alignment should be flipped.
|
|
52
40
|
*/
|
|
@@ -75,11 +63,11 @@ export interface OverflowMenuProps {
|
|
|
75
63
|
/**
|
|
76
64
|
* The adjustment in position applied to the floating menu.
|
|
77
65
|
*/
|
|
78
|
-
menuOffset?:
|
|
66
|
+
menuOffset?: MenuOffset;
|
|
79
67
|
/**
|
|
80
68
|
* The adjustment in position applied to the floating menu.
|
|
81
69
|
*/
|
|
82
|
-
menuOffsetFlip?:
|
|
70
|
+
menuOffsetFlip?: MenuOffset;
|
|
83
71
|
/**
|
|
84
72
|
* The class to apply to the menu options
|
|
85
73
|
*/
|
|
@@ -246,10 +234,10 @@ declare class OverflowMenu extends React.Component<OverflowMenuProps, OverflowMe
|
|
|
246
234
|
_hBlurTimeout: any;
|
|
247
235
|
/**
|
|
248
236
|
* The element ref of the tooltip's trigger button.
|
|
249
|
-
* @type {React.RefObject<
|
|
237
|
+
* @type {React.RefObject<HTMLElement>}
|
|
250
238
|
* @private
|
|
251
239
|
*/
|
|
252
|
-
_triggerRef: React.RefObject<
|
|
240
|
+
_triggerRef: React.RefObject<HTMLElement>;
|
|
253
241
|
componentDidUpdate(_: any, prevState: any): void;
|
|
254
242
|
componentDidMount(): void;
|
|
255
243
|
static getDerivedStateFromProps({ open }: {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { defineProperty as _defineProperty, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
-
import FloatingMenu,
|
|
9
|
+
import { FloatingMenu, DIRECTION_TOP, DIRECTION_BOTTOM } from '../../internal/FloatingMenu.js';
|
|
10
10
|
import React__default from 'react';
|
|
11
11
|
import ClickListener from '../../internal/ClickListener.js';
|
|
12
12
|
import { IconButton } from '../IconButton/index.js';
|
|
@@ -53,13 +53,6 @@ const triggerButtonPositionFactors = {
|
|
|
53
53
|
[DIRECTION_TOP]: -2,
|
|
54
54
|
[DIRECTION_BOTTOM]: -1
|
|
55
55
|
};
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* @param {Element} menuBody The menu body with the menu arrow.
|
|
59
|
-
* @param {string} direction The floating menu direction.
|
|
60
|
-
* @returns {FloatingMenu~offset} The adjustment of the floating menu position, upon the position of the menu arrow.
|
|
61
|
-
* @private
|
|
62
|
-
*/
|
|
63
56
|
const getMenuOffset = (menuBody, direction, trigger, flip) => {
|
|
64
57
|
const triggerButtonPositionProp = triggerButtonPositionProps[direction];
|
|
65
58
|
const triggerButtonPositionFactor = triggerButtonPositionFactors[direction];
|
|
@@ -81,6 +74,11 @@ const getMenuOffset = (menuBody, direction, trigger, flip) => {
|
|
|
81
74
|
top: 0
|
|
82
75
|
};
|
|
83
76
|
}
|
|
77
|
+
default:
|
|
78
|
+
return {
|
|
79
|
+
left: 0,
|
|
80
|
+
top: 0
|
|
81
|
+
};
|
|
84
82
|
}
|
|
85
83
|
};
|
|
86
84
|
class OverflowMenu extends React__default.Component {
|
|
@@ -106,7 +104,7 @@ class OverflowMenu extends React__default.Component {
|
|
|
106
104
|
_defineProperty(this, "_hBlurTimeout", void 0);
|
|
107
105
|
/**
|
|
108
106
|
* The element ref of the tooltip's trigger button.
|
|
109
|
-
* @type {React.RefObject<
|
|
107
|
+
* @type {React.RefObject<HTMLElement>}
|
|
110
108
|
* @private
|
|
111
109
|
*/
|
|
112
110
|
_defineProperty(this, "_triggerRef", /*#__PURE__*/React__default.createRef());
|
|
@@ -12,8 +12,8 @@ import React__default from 'react';
|
|
|
12
12
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
13
13
|
import { warning } from '../../internal/warning.js';
|
|
14
14
|
import '../Text/index.js';
|
|
15
|
-
import { Text } from '../Text/Text.js';
|
|
16
15
|
import { match } from '../../internal/keyboard/match.js';
|
|
16
|
+
import { Text } from '../Text/Text.js';
|
|
17
17
|
import { ArrowDown, ArrowUp } from '../../internal/keyboard/keys.js';
|
|
18
18
|
|
|
19
19
|
const OverflowMenuItem = /*#__PURE__*/React__default.forwardRef(function OverflowMenuItem(_ref, ref) {
|
|
@@ -12,8 +12,8 @@ import React__default, { useState } from 'react';
|
|
|
12
12
|
import { Warning, Incomplete, CheckmarkOutline, CircleDash } from '@carbon/icons-react';
|
|
13
13
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
14
14
|
import '../Text/index.js';
|
|
15
|
-
import { Text } from '../Text/Text.js';
|
|
16
15
|
import { matches } from '../../internal/keyboard/match.js';
|
|
16
|
+
import { Text } from '../Text/Text.js';
|
|
17
17
|
import { Enter, Space } from '../../internal/keyboard/keys.js';
|
|
18
18
|
|
|
19
19
|
const defaultTranslations = {
|
|
@@ -16,8 +16,8 @@ import deprecate from '../../prop-types/deprecate.js';
|
|
|
16
16
|
import { noopFn } from '../../internal/noopFn.js';
|
|
17
17
|
import '../Text/index.js';
|
|
18
18
|
import { useFeatureFlag } from '../FeatureFlags/index.js';
|
|
19
|
-
import { Text } from '../Text/Text.js';
|
|
20
19
|
import { matches } from '../../internal/keyboard/match.js';
|
|
20
|
+
import { Text } from '../Text/Text.js';
|
|
21
21
|
import { Enter, Space } from '../../internal/keyboard/keys.js';
|
|
22
22
|
|
|
23
23
|
var _RadioButtonChecked, _RadioButton, _CheckmarkFilled;
|
|
@@ -49,8 +49,16 @@ const Select = /*#__PURE__*/React__default.forwardRef(function Select(_ref, ref)
|
|
|
49
49
|
isFluid
|
|
50
50
|
} = useContext(FormContext);
|
|
51
51
|
const [isFocused, setIsFocused] = useState(false);
|
|
52
|
-
const [title, setTitle] = useState('');
|
|
53
52
|
const selectInstanceId = useId();
|
|
53
|
+
// Convert children to an array of valid elements once using type narrowing
|
|
54
|
+
const validChildren = React__default.Children.toArray(children).filter(child => /*#__PURE__*/React__default.isValidElement(child));
|
|
55
|
+
|
|
56
|
+
// Find the default option based on the specified defaultValue
|
|
57
|
+
const defaultOption = validChildren.find(child => child.props?.value === other?.defaultValue);
|
|
58
|
+
|
|
59
|
+
// Use the default option's text if available; otherwise, fallback to the first option's text
|
|
60
|
+
const initialTitle = defaultOption?.props?.text || validChildren[0]?.props?.text || '';
|
|
61
|
+
const [title, setTitle] = useState(initialTitle);
|
|
54
62
|
const selectClasses = cx({
|
|
55
63
|
[`${prefix}--select`]: true,
|
|
56
64
|
[`${prefix}--select--inline`]: inline,
|
|
@@ -105,7 +113,8 @@ const Select = /*#__PURE__*/React__default.forwardRef(function Select(_ref, ref)
|
|
|
105
113
|
setIsFocused(evt.type === 'focus' ? true : false);
|
|
106
114
|
};
|
|
107
115
|
const handleChange = evt => {
|
|
108
|
-
|
|
116
|
+
const selectedOption = evt?.target?.options[evt.target.selectedIndex];
|
|
117
|
+
setTitle(selectedOption?.text);
|
|
109
118
|
};
|
|
110
119
|
const readOnlyEventHandlers = {
|
|
111
120
|
onMouseDown: evt => {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2025, 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 from 'react';
|
|
8
|
+
export declare const ShapeIndicatorKinds: string[];
|
|
9
|
+
export type ShapeIndicatorKind = (typeof ShapeIndicatorKinds)[number];
|
|
10
|
+
export interface ShapeIndicatorProps {
|
|
11
|
+
/**
|
|
12
|
+
* Specify an optional className to add.
|
|
13
|
+
*/
|
|
14
|
+
className?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Specify the kind of shape to be used
|
|
17
|
+
*/
|
|
18
|
+
kind: ShapeIndicatorKind;
|
|
19
|
+
/**
|
|
20
|
+
* Label next to the shape
|
|
21
|
+
*/
|
|
22
|
+
label: string;
|
|
23
|
+
/**
|
|
24
|
+
* Specify the text size of the Shape Indicator. Defaults to 12.
|
|
25
|
+
*/
|
|
26
|
+
textSize?: 12 | 14;
|
|
27
|
+
}
|
|
28
|
+
export declare const ShapeIndicator: React.ForwardRefExoticComponent<ShapeIndicatorProps & React.RefAttributes<HTMLDivElement>>;
|
|
29
|
+
export default ShapeIndicator;
|