@carbon/react 1.94.1 → 1.95.0-rc.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 +879 -879
- package/es/components/ComboBox/ComboBox.js +1 -1
- package/es/components/DataTable/TableSlugRow.d.ts +1 -1
- package/es/components/DataTable/TableSlugRow.js +1 -1
- package/es/components/Menu/Menu.d.ts +8 -0
- package/es/components/Menu/Menu.js +13 -1
- package/es/components/MenuButton/index.d.ts +8 -0
- package/es/components/MenuButton/index.js +13 -2
- package/es/components/NumberInput/NumberInput.js +64 -1
- package/es/components/NumberInput/index.d.ts +1 -1
- package/es/components/PaginationNav/PaginationNav.js +1 -3
- package/es/components/Slider/Slider.js +75 -59
- package/es/components/Text/Text.js +1 -1
- package/es/components/Tile/Tile.js +1 -1
- package/es/index.js +1 -1
- package/es/internal/useNormalizedInputProps.js +2 -2
- package/es/prop-types/deprecateComponent.d.ts +7 -1
- package/es/prop-types/deprecateComponent.js +3 -3
- package/lib/components/ComboBox/ComboBox.js +1 -1
- package/lib/components/DataTable/TableSlugRow.d.ts +1 -1
- package/lib/components/DataTable/TableSlugRow.js +1 -1
- package/lib/components/Menu/Menu.d.ts +8 -0
- package/lib/components/Menu/Menu.js +13 -1
- package/lib/components/MenuButton/index.d.ts +8 -0
- package/lib/components/MenuButton/index.js +13 -2
- package/lib/components/NumberInput/NumberInput.js +64 -0
- package/lib/components/NumberInput/index.d.ts +1 -1
- package/lib/components/PaginationNav/PaginationNav.js +1 -3
- package/lib/components/Slider/Slider.js +75 -59
- package/lib/components/Text/Text.js +1 -1
- package/lib/components/Tile/Tile.js +1 -1
- package/lib/index.js +1 -0
- package/lib/internal/useNormalizedInputProps.js +2 -2
- package/lib/prop-types/deprecateComponent.d.ts +7 -1
- package/lib/prop-types/deprecateComponent.js +3 -5
- package/package.json +4 -4
- package/telemetry.yml +10 -4
|
@@ -732,7 +732,7 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
732
732
|
translateWithId: translateWithId
|
|
733
733
|
}))), slug ? normalizedDecorator : decorator ? /*#__PURE__*/React.createElement("div", {
|
|
734
734
|
className: `${prefix}--list-box__inner-wrapper--decorator`
|
|
735
|
-
}, normalizedDecorator) : '', /*#__PURE__*/React.createElement(ListBox.Menu, menuProps, isOpen ? filterItems(items, itemToString, inputValue).map((item, index) => {
|
|
735
|
+
}, candidateIsAILabel ? normalizedDecorator : /*#__PURE__*/React.createElement("span", null, normalizedDecorator)) : '', /*#__PURE__*/React.createElement(ListBox.Menu, menuProps, isOpen ? filterItems(items, itemToString, inputValue).map((item, index) => {
|
|
736
736
|
const isObject = item !== null && typeof item === 'object';
|
|
737
737
|
const title = isObject && 'text' in item && itemToElement ? item.text?.toString() : itemToString(item);
|
|
738
738
|
const itemProps = getItemProps({
|
|
@@ -9,7 +9,7 @@ import PropTypes from 'prop-types';
|
|
|
9
9
|
import React, { useEffect } from 'react';
|
|
10
10
|
import cx from 'classnames';
|
|
11
11
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
12
|
-
import deprecateComponent from '../../prop-types/deprecateComponent.js';
|
|
12
|
+
import { deprecateComponent } from '../../prop-types/deprecateComponent.js';
|
|
13
13
|
|
|
14
14
|
const TableSlugRow = ({
|
|
15
15
|
className,
|
|
@@ -6,6 +6,14 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import React, { ReactNode, RefObject } from 'react';
|
|
8
8
|
export interface MenuProps extends React.HTMLAttributes<HTMLUListElement> {
|
|
9
|
+
/**
|
|
10
|
+
* Specify the background token to use. Default is 'layer'.
|
|
11
|
+
*/
|
|
12
|
+
backgroundToken?: 'layer' | 'background';
|
|
13
|
+
/**
|
|
14
|
+
* Specify whether a border should be rendered on the popover
|
|
15
|
+
*/
|
|
16
|
+
border?: boolean;
|
|
9
17
|
/**
|
|
10
18
|
* The ref of the containing element, used for positioning and alignment of the menu
|
|
11
19
|
*/
|
|
@@ -23,6 +23,8 @@ import { canUseDOM } from '../../internal/environment.js';
|
|
|
23
23
|
const spacing = 8; // distance to keep to window edges, in px
|
|
24
24
|
|
|
25
25
|
const Menu = /*#__PURE__*/forwardRef(function Menu({
|
|
26
|
+
backgroundToken = 'layer',
|
|
27
|
+
border = false,
|
|
26
28
|
children,
|
|
27
29
|
className,
|
|
28
30
|
containerRef,
|
|
@@ -275,7 +277,9 @@ const Menu = /*#__PURE__*/forwardRef(function Menu({
|
|
|
275
277
|
[`${prefix}--menu--shown`]: open && !legacyAutoalign || position[0] >= 0 && position[1] >= 0,
|
|
276
278
|
[`${prefix}--menu--with-icons`]: childContext.state.hasIcons,
|
|
277
279
|
[`${prefix}--menu--with-selectable-items`]: childContext.state.hasSelectableItems,
|
|
278
|
-
[`${prefix}--autoalign`]: !legacyAutoalign
|
|
280
|
+
[`${prefix}--autoalign`]: !legacyAutoalign,
|
|
281
|
+
[`${prefix}--menu--border`]: border,
|
|
282
|
+
[`${prefix}--menu--background-token__background`]: backgroundToken === 'background'
|
|
279
283
|
});
|
|
280
284
|
const rendered = /*#__PURE__*/React.createElement(MenuContext.Provider, {
|
|
281
285
|
value: childContext
|
|
@@ -294,6 +298,14 @@ const Menu = /*#__PURE__*/forwardRef(function Menu({
|
|
|
294
298
|
return isRoot ? open && /*#__PURE__*/createPortal(rendered, target) || null : rendered;
|
|
295
299
|
});
|
|
296
300
|
Menu.propTypes = {
|
|
301
|
+
/**
|
|
302
|
+
* Specify the background token to use. Default is 'layer'.
|
|
303
|
+
*/
|
|
304
|
+
backgroundToken: PropTypes.oneOf(['layer', 'background']),
|
|
305
|
+
/**
|
|
306
|
+
* Specify whether a border should be rendered on the menu
|
|
307
|
+
*/
|
|
308
|
+
border: PropTypes.bool,
|
|
297
309
|
/**
|
|
298
310
|
* A collection of MenuItems to be rendered within this Menu.
|
|
299
311
|
*/
|
|
@@ -39,6 +39,14 @@ export interface MenuButtonProps extends ComponentProps<'div'> {
|
|
|
39
39
|
* Specify the tabIndex of the button.
|
|
40
40
|
*/
|
|
41
41
|
tabIndex?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Specify the background token to use for the menu. Default is 'layer'.
|
|
44
|
+
*/
|
|
45
|
+
menuBackgroundToken?: 'layer' | 'background';
|
|
46
|
+
/**
|
|
47
|
+
* Specify whether a border should be rendered on the menu
|
|
48
|
+
*/
|
|
49
|
+
menuBorder?: boolean;
|
|
42
50
|
/**
|
|
43
51
|
* Specify a DOM node where the Menu should be rendered in. Defaults to document.body.
|
|
44
52
|
*/
|
|
@@ -30,6 +30,8 @@ const MenuButton = /*#__PURE__*/forwardRef(({
|
|
|
30
30
|
disabled,
|
|
31
31
|
kind = defaultButtonKind,
|
|
32
32
|
label,
|
|
33
|
+
menuBackgroundToken = 'layer',
|
|
34
|
+
menuBorder = false,
|
|
33
35
|
size: size$1 = 'lg',
|
|
34
36
|
menuAlignment = 'bottom',
|
|
35
37
|
tabIndex = 0,
|
|
@@ -142,7 +144,9 @@ const MenuButton = /*#__PURE__*/forwardRef(({
|
|
|
142
144
|
size: size$1,
|
|
143
145
|
open: open,
|
|
144
146
|
onClose: handleClose,
|
|
145
|
-
target: menuTarget
|
|
147
|
+
target: menuTarget,
|
|
148
|
+
backgroundToken: menuBackgroundToken,
|
|
149
|
+
border: menuBorder
|
|
146
150
|
}, children));
|
|
147
151
|
});
|
|
148
152
|
MenuButton.propTypes = {
|
|
@@ -184,10 +188,17 @@ MenuButton.propTypes = {
|
|
|
184
188
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
185
189
|
// @ts-ignore-next-line -- avoid spurious (?) TS2322 error
|
|
186
190
|
tabIndex: PropTypes.number,
|
|
191
|
+
/**
|
|
192
|
+
* Specify the background token to use for the menu. Default is 'layer'.
|
|
193
|
+
*/
|
|
194
|
+
menuBackgroundToken: PropTypes.oneOf(['layer', 'background']),
|
|
195
|
+
/**
|
|
196
|
+
* Specify whether a border should be rendered on the menu
|
|
197
|
+
*/
|
|
198
|
+
menuBorder: PropTypes.bool,
|
|
187
199
|
/**
|
|
188
200
|
* Specify a DOM node where the Menu should be rendered in. Defaults to document.body.
|
|
189
201
|
*/
|
|
190
|
-
|
|
191
202
|
menuTarget: PropTypes.instanceOf(typeof Element !== 'undefined' ? Element : Object)
|
|
192
203
|
};
|
|
193
204
|
|
|
@@ -39,6 +39,69 @@ const defaultTranslations = {
|
|
|
39
39
|
const defaultTranslateWithId = messageId => {
|
|
40
40
|
return defaultTranslations[messageId];
|
|
41
41
|
};
|
|
42
|
+
const getSeparators = locale => {
|
|
43
|
+
const numberWithGroupAndDecimal = 1234567.89;
|
|
44
|
+
const formatted = new Intl.NumberFormat(locale).format(numberWithGroupAndDecimal);
|
|
45
|
+
|
|
46
|
+
// Extract separators using regex
|
|
47
|
+
const match = formatted.match(/(\D+)\d{3}(\D+)\d{2}$/);
|
|
48
|
+
if (match) {
|
|
49
|
+
const groupSeparator = match[1];
|
|
50
|
+
const decimalSeparator = match[2];
|
|
51
|
+
return {
|
|
52
|
+
groupSeparator,
|
|
53
|
+
decimalSeparator
|
|
54
|
+
};
|
|
55
|
+
} else {
|
|
56
|
+
return {
|
|
57
|
+
groupSeparator: null,
|
|
58
|
+
decimalSeparator: null
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const validateNumberSeparators = (input, locale) => {
|
|
63
|
+
// allow empty string
|
|
64
|
+
if (input === '' || Number.isNaN(input)) {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
const {
|
|
68
|
+
groupSeparator,
|
|
69
|
+
decimalSeparator
|
|
70
|
+
} = getSeparators(locale);
|
|
71
|
+
if (!decimalSeparator) {
|
|
72
|
+
return !isNaN(Number(input));
|
|
73
|
+
}
|
|
74
|
+
const esc = s => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
75
|
+
let group = '';
|
|
76
|
+
if (groupSeparator) {
|
|
77
|
+
if (groupSeparator.trim() === '') {
|
|
78
|
+
group = '[\\u00A0\\u202F\\s]'; // handle NBSP, narrow NBSP, space
|
|
79
|
+
} else {
|
|
80
|
+
group = esc(groupSeparator);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const decimal = esc(decimalSeparator);
|
|
84
|
+
|
|
85
|
+
// Regex for:
|
|
86
|
+
// - integers (with/without grouping)
|
|
87
|
+
// - optional decimal with 0+ digits after separator
|
|
88
|
+
const regex = new RegExp(`^-?\\d{1,3}(${group}\\d{3})*(${decimal}\\d*)?$|^-?\\d+(${decimal}\\d*)?$`);
|
|
89
|
+
if (!regex.test(input)) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Normalize
|
|
94
|
+
let normalized = input;
|
|
95
|
+
if (groupSeparator) {
|
|
96
|
+
if (groupSeparator.trim() === '') {
|
|
97
|
+
normalized = normalized?.replace(/[\u00A0\u202F\s]/g, '');
|
|
98
|
+
} else {
|
|
99
|
+
normalized = normalized?.split(groupSeparator).join('');
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
normalized = normalized?.replace(decimalSeparator, '.');
|
|
103
|
+
return !isNaN(Number(normalized));
|
|
104
|
+
};
|
|
42
105
|
|
|
43
106
|
// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
44
107
|
const NumberInput = /*#__PURE__*/React.forwardRef((props, forwardRef) => {
|
|
@@ -726,4 +789,4 @@ function disableWheel(e) {
|
|
|
726
789
|
e.preventDefault();
|
|
727
790
|
}
|
|
728
791
|
|
|
729
|
-
export { NumberInput };
|
|
792
|
+
export { NumberInput, validateNumberSeparators };
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
export { default as NumberInputSkeleton } from './NumberInput.Skeleton';
|
|
8
|
-
export { NumberInput, type NumberInputProps } from './NumberInput';
|
|
8
|
+
export { NumberInput, validateNumberSeparators, type NumberInputProps, } from './NumberInput';
|
|
@@ -274,9 +274,7 @@ const PaginationNav = /*#__PURE__*/React.forwardRef(({
|
|
|
274
274
|
return /*#__PURE__*/React.createElement("nav", _extends({
|
|
275
275
|
className: classNames,
|
|
276
276
|
ref: ref
|
|
277
|
-
}, rest, {
|
|
278
|
-
"aria-label": "pagination"
|
|
279
|
-
}), /*#__PURE__*/React.createElement("ul", {
|
|
277
|
+
}, rest), /*#__PURE__*/React.createElement("ul", {
|
|
280
278
|
className: `${prefix}--pagination-nav__list`
|
|
281
279
|
}, /*#__PURE__*/React.createElement(DirectionButton, {
|
|
282
280
|
direction: "backward",
|
|
@@ -20,6 +20,7 @@ import '../Tooltip/DefinitionTooltip.js';
|
|
|
20
20
|
import { Tooltip } from '../Tooltip/Tooltip.js';
|
|
21
21
|
import { LowerHandle, LowerHandleFocus, UpperHandle, UpperHandleFocus } from './SliderHandles.js';
|
|
22
22
|
import { clamp } from '../../internal/clamp.js';
|
|
23
|
+
import { useNormalizedInputProps } from '../../internal/useNormalizedInputProps.js';
|
|
23
24
|
import { throttle } from '../../node_modules/es-toolkit/dist/compat/function/throttle.js';
|
|
24
25
|
|
|
25
26
|
const ThumbWrapper = ({
|
|
@@ -73,6 +74,7 @@ var HandlePosition = /*#__PURE__*/function (HandlePosition) {
|
|
|
73
74
|
return HandlePosition;
|
|
74
75
|
}(HandlePosition || {}); // TODO: Delete this type and directory type the properties in the function.
|
|
75
76
|
const Slider = props => {
|
|
77
|
+
var _Fragment, _Fragment2, _Fragment3, _Fragment4;
|
|
76
78
|
// TODO: Move destructured `props` from the IIFE to here.
|
|
77
79
|
|
|
78
80
|
const initialState = {
|
|
@@ -926,63 +928,77 @@ const Slider = props => {
|
|
|
926
928
|
setState(derivedState);
|
|
927
929
|
}
|
|
928
930
|
}, [props.invalid]);
|
|
931
|
+
const {
|
|
932
|
+
ariaLabelInput,
|
|
933
|
+
unstable_ariaLabelInputUpper: ariaLabelInputUpper,
|
|
934
|
+
className,
|
|
935
|
+
hideTextInput = false,
|
|
936
|
+
id = inputIdRef.current = inputIdRef.current ||
|
|
937
|
+
// TODO:
|
|
938
|
+
// 1. Why isn't `inputId` just set to this value instead of an empty
|
|
939
|
+
// string?
|
|
940
|
+
// 2. Why this value instead of something else, like
|
|
941
|
+
// `crypto.randomUUID()` or `useId()`?
|
|
942
|
+
`__carbon-slider_${Math.random().toString(36).substr(2)}`,
|
|
943
|
+
min,
|
|
944
|
+
minLabel,
|
|
945
|
+
max,
|
|
946
|
+
maxLabel,
|
|
947
|
+
formatLabel = defaultFormatLabel,
|
|
948
|
+
labelText,
|
|
949
|
+
hideLabel,
|
|
950
|
+
step = 1,
|
|
951
|
+
// TODO: Other properties are deleted below. Why isn't this one?
|
|
952
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
953
|
+
stepMultiplier: _stepMultiplier,
|
|
954
|
+
inputType = 'number',
|
|
955
|
+
invalidText,
|
|
956
|
+
required,
|
|
957
|
+
disabled = false,
|
|
958
|
+
name,
|
|
959
|
+
unstable_nameUpper: nameUpper,
|
|
960
|
+
light,
|
|
961
|
+
readOnly = false,
|
|
962
|
+
warn = false,
|
|
963
|
+
warnText,
|
|
964
|
+
translateWithId: t = defaultTranslateWithId,
|
|
965
|
+
...other
|
|
966
|
+
} = props;
|
|
967
|
+
const {
|
|
968
|
+
value,
|
|
969
|
+
valueUpper,
|
|
970
|
+
isValid,
|
|
971
|
+
isValidUpper,
|
|
972
|
+
correctedValue,
|
|
973
|
+
correctedPosition,
|
|
974
|
+
isRtl
|
|
975
|
+
} = state;
|
|
976
|
+
const normalizedProps = useNormalizedInputProps({
|
|
977
|
+
id,
|
|
978
|
+
disabled,
|
|
979
|
+
readOnly,
|
|
980
|
+
invalid: !isValid,
|
|
981
|
+
warn
|
|
982
|
+
});
|
|
983
|
+
const normalizedUpperProps = useNormalizedInputProps({
|
|
984
|
+
id,
|
|
985
|
+
disabled,
|
|
986
|
+
readOnly,
|
|
987
|
+
invalid: !isValidUpper,
|
|
988
|
+
warn
|
|
989
|
+
});
|
|
929
990
|
|
|
930
991
|
// TODO: Delete this IIFE. It was added to maintain whitespace and to make it clear
|
|
931
992
|
// what exactly has changed.
|
|
932
|
-
return ((
|
|
933
|
-
const {
|
|
934
|
-
ariaLabelInput,
|
|
935
|
-
unstable_ariaLabelInputUpper: ariaLabelInputUpper,
|
|
936
|
-
className,
|
|
937
|
-
hideTextInput = false,
|
|
938
|
-
id = inputIdRef.current = inputIdRef.current ||
|
|
939
|
-
// TODO:
|
|
940
|
-
// 1. Why isn't `inputId` just set to this value instead of an empty
|
|
941
|
-
// string?
|
|
942
|
-
// 2. Why this value instead of something else, like
|
|
943
|
-
// `crypto.randomUUID()` or `useId()`?
|
|
944
|
-
`__carbon-slider_${Math.random().toString(36).substr(2)}`,
|
|
945
|
-
min,
|
|
946
|
-
minLabel,
|
|
947
|
-
max,
|
|
948
|
-
maxLabel,
|
|
949
|
-
formatLabel = defaultFormatLabel,
|
|
950
|
-
labelText,
|
|
951
|
-
hideLabel,
|
|
952
|
-
step = 1,
|
|
953
|
-
// TODO: Other properties are deleted below. Why isn't this one?
|
|
954
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
955
|
-
stepMultiplier: _stepMultiplier,
|
|
956
|
-
inputType = 'number',
|
|
957
|
-
invalidText,
|
|
958
|
-
required,
|
|
959
|
-
disabled = false,
|
|
960
|
-
name,
|
|
961
|
-
unstable_nameUpper: nameUpper,
|
|
962
|
-
light,
|
|
963
|
-
readOnly = false,
|
|
964
|
-
warn,
|
|
965
|
-
warnText,
|
|
966
|
-
translateWithId: t = defaultTranslateWithId,
|
|
967
|
-
...other
|
|
968
|
-
} = props;
|
|
993
|
+
return (() => {
|
|
969
994
|
delete other.onRelease;
|
|
970
995
|
delete other.invalid;
|
|
971
996
|
delete other.unstable_valueUpper;
|
|
972
|
-
const
|
|
973
|
-
value,
|
|
974
|
-
valueUpper,
|
|
975
|
-
isValid,
|
|
976
|
-
isValidUpper,
|
|
977
|
-
correctedValue,
|
|
978
|
-
correctedPosition,
|
|
979
|
-
isRtl
|
|
980
|
-
} = state;
|
|
981
|
-
const showWarning = !readOnly && warn ||
|
|
997
|
+
const showWarning = normalizedProps.warn ||
|
|
982
998
|
// TODO: https://github.com/carbon-design-system/carbon/issues/18991#issuecomment-2795709637
|
|
983
999
|
// eslint-disable-next-line valid-typeof , no-constant-binary-expression -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
984
1000
|
typeof correctedValue !== null && correctedPosition === HandlePosition.LOWER && isValid;
|
|
985
|
-
const showWarningUpper =
|
|
1001
|
+
const showWarningUpper = normalizedUpperProps.warn ||
|
|
986
1002
|
// TODO: https://github.com/carbon-design-system/carbon/issues/18991#issuecomment-2795709637
|
|
987
1003
|
// eslint-disable-next-line valid-typeof, no-constant-binary-expression -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
988
1004
|
typeof correctedValue !== null && correctedPosition === (twoHandles ? HandlePosition.UPPER : HandlePosition.LOWER) && (twoHandles ? isValidUpper : isValid);
|
|
@@ -1007,11 +1023,11 @@ const Slider = props => {
|
|
|
1007
1023
|
[`${prefix}--text-input--light`]: light
|
|
1008
1024
|
};
|
|
1009
1025
|
const lowerInputClasses = cx([...fixedInputClasses, `${prefix}--slider-text-input--lower`, conditionalInputClasses, {
|
|
1010
|
-
[`${prefix}--text-input--invalid`]:
|
|
1026
|
+
[`${prefix}--text-input--invalid`]: normalizedProps.invalid,
|
|
1011
1027
|
[`${prefix}--slider-text-input--warn`]: showWarning
|
|
1012
1028
|
}]);
|
|
1013
1029
|
const upperInputClasses = cx([...fixedInputClasses, `${prefix}--slider-text-input--upper`, conditionalInputClasses, {
|
|
1014
|
-
[`${prefix}--text-input--invalid`]:
|
|
1030
|
+
[`${prefix}--text-input--invalid`]: twoHandles ? normalizedUpperProps.invalid : normalizedProps.invalid,
|
|
1015
1031
|
[`${prefix}--slider-text-input--warn`]: showWarningUpper
|
|
1016
1032
|
}]);
|
|
1017
1033
|
const lowerInputWrapperClasses = cx([`${prefix}--text-input-wrapper`, `${prefix}--slider-text-input-wrapper`, `${prefix}--slider-text-input-wrapper--lower`, {
|
|
@@ -1071,11 +1087,11 @@ const Slider = props => {
|
|
|
1071
1087
|
onBlur: onBlurInput,
|
|
1072
1088
|
onKeyUp: props.onInputKeyUp,
|
|
1073
1089
|
onKeyDown: onInputKeyDown,
|
|
1074
|
-
"data-invalid":
|
|
1090
|
+
"data-invalid": normalizedProps.invalid ? true : null,
|
|
1075
1091
|
"data-handle-position": HandlePosition.LOWER,
|
|
1076
|
-
"aria-invalid":
|
|
1092
|
+
"aria-invalid": normalizedProps.invalid ? true : undefined,
|
|
1077
1093
|
readOnly: readOnly
|
|
1078
|
-
}),
|
|
1094
|
+
}), normalizedProps.invalid && /*#__PURE__*/React.createElement(WarningFilled, {
|
|
1079
1095
|
className: `${prefix}--slider__invalid-icon`
|
|
1080
1096
|
}), showWarning && /*#__PURE__*/React.createElement(WarningAltFilled, {
|
|
1081
1097
|
className: `${prefix}--slider__invalid-icon ${prefix}--slider__invalid-icon--warning`
|
|
@@ -1091,7 +1107,7 @@ const Slider = props => {
|
|
|
1091
1107
|
onKeyDown: onKeyDown,
|
|
1092
1108
|
role: "presentation",
|
|
1093
1109
|
tabIndex: -1,
|
|
1094
|
-
"data-invalid": (twoHandles ?
|
|
1110
|
+
"data-invalid": (twoHandles ? normalizedProps.invalid || normalizedUpperProps.invalid : normalizedProps.invalid) ? true : null
|
|
1095
1111
|
}, other), /*#__PURE__*/React.createElement(ThumbWrapper, _extends({
|
|
1096
1112
|
hasTooltip: hideTextInput,
|
|
1097
1113
|
className: lowerThumbWrapperClasses,
|
|
@@ -1174,18 +1190,18 @@ const Slider = props => {
|
|
|
1174
1190
|
onBlur: onBlurInput,
|
|
1175
1191
|
onKeyDown: onInputKeyDown,
|
|
1176
1192
|
onKeyUp: props.onInputKeyUp,
|
|
1177
|
-
"data-invalid": (twoHandles ?
|
|
1193
|
+
"data-invalid": (twoHandles ? normalizedUpperProps.invalid : normalizedProps.invalid) ? true : null,
|
|
1178
1194
|
"data-handle-position": twoHandles ? HandlePosition.UPPER : null,
|
|
1179
|
-
"aria-invalid": (twoHandles ?
|
|
1195
|
+
"aria-invalid": (twoHandles ? normalizedUpperProps.invalid : normalizedProps.invalid) ? true : undefined,
|
|
1180
1196
|
readOnly: readOnly
|
|
1181
|
-
}),
|
|
1197
|
+
}), (twoHandles ? normalizedUpperProps.invalid : normalizedProps.invalid) && /*#__PURE__*/React.createElement(WarningFilled, {
|
|
1182
1198
|
className: `${prefix}--slider__invalid-icon`
|
|
1183
1199
|
}), showWarningUpper && /*#__PURE__*/React.createElement(WarningAltFilled, {
|
|
1184
1200
|
className: `${prefix}--slider__invalid-icon ${prefix}--slider__invalid-icon--warning`
|
|
1185
|
-
}))),
|
|
1201
|
+
}))), (normalizedProps.invalid || normalizedUpperProps.invalid) && /*#__PURE__*/React.createElement(Text, {
|
|
1186
1202
|
as: "div",
|
|
1187
1203
|
className: cx(`${prefix}--slider__validation-msg`, `${prefix}--slider__validation-msg--invalid`, `${prefix}--form-requirement`)
|
|
1188
|
-
}, invalidText),
|
|
1204
|
+
}, invalidText), (normalizedProps.warn || normalizedUpperProps.warn) && /*#__PURE__*/React.createElement(Text, {
|
|
1189
1205
|
as: "div",
|
|
1190
1206
|
className: cx(`${prefix}--slider__validation-msg`, `${prefix}--form-requirement`)
|
|
1191
1207
|
}, warnText), correctedValue && /*#__PURE__*/React.createElement(Text, {
|
|
@@ -62,7 +62,7 @@ Text.propTypes = {
|
|
|
62
62
|
/**
|
|
63
63
|
* Provide child elements or text to be rendered inside of this component
|
|
64
64
|
*/
|
|
65
|
-
children: PropTypes.node
|
|
65
|
+
children: PropTypes.node,
|
|
66
66
|
/**
|
|
67
67
|
* Specify the text direction to be used for this component and any of its
|
|
68
68
|
* children
|
|
@@ -493,7 +493,7 @@ const ExpandableTile = /*#__PURE__*/React.forwardRef(({
|
|
|
493
493
|
});
|
|
494
494
|
resizeObserver.observe(aboveTheFold.current);
|
|
495
495
|
return () => resizeObserver.disconnect();
|
|
496
|
-
}, []);
|
|
496
|
+
}, [isTileMaxHeight, isTilePadding]);
|
|
497
497
|
const belowTheFoldId = useId('expandable-tile-interactive');
|
|
498
498
|
|
|
499
499
|
// AILabel is always size `xs`
|
package/es/index.js
CHANGED
|
@@ -102,7 +102,7 @@ export { FilterableMultiSelect } from './components/MultiSelect/FilterableMultiS
|
|
|
102
102
|
export { MultiSelect } from './components/MultiSelect/MultiSelect.js';
|
|
103
103
|
export { ActionableNotification, Callout, InlineNotification, NotificationActionButton, NotificationButton, StaticNotification, ToastNotification } from './components/Notification/Notification.js';
|
|
104
104
|
export { default as NumberInputSkeleton } from './components/NumberInput/NumberInput.Skeleton.js';
|
|
105
|
-
export { NumberInput } from './components/NumberInput/NumberInput.js';
|
|
105
|
+
export { NumberInput, validateNumberSeparators } from './components/NumberInput/NumberInput.js';
|
|
106
106
|
export { default as OrderedList } from './components/OrderedList/OrderedList.js';
|
|
107
107
|
export { default as OverflowMenu } from './components/OverflowMenu/index.js';
|
|
108
108
|
export { default as OverflowMenuItem } from './components/OverflowMenuItem/OverflowMenuItem.js';
|
|
@@ -32,9 +32,9 @@ const useNormalizedInputProps = ({
|
|
|
32
32
|
const prefix = usePrefix();
|
|
33
33
|
const normalizedProps = {
|
|
34
34
|
disabled: !readOnly && disabled,
|
|
35
|
-
invalid: !readOnly && invalid,
|
|
35
|
+
invalid: !readOnly && !disabled && invalid,
|
|
36
36
|
invalidId: `${id}-error-msg`,
|
|
37
|
-
warn: !readOnly && !invalid && warn,
|
|
37
|
+
warn: !readOnly && !invalid && !disabled && warn,
|
|
38
38
|
warnId: `${id}-warn-msg`,
|
|
39
39
|
validation: null,
|
|
40
40
|
icon: null,
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
|
|
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 declare const deprecateComponent: (componentName: string, message?: string) => string | undefined;
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
import { warning } from '../internal/warning.js';
|
|
9
9
|
|
|
10
10
|
const didWarnAboutDeprecation = {};
|
|
11
|
-
|
|
11
|
+
const deprecateComponent = (componentName, message) => {
|
|
12
12
|
if (!didWarnAboutDeprecation[componentName]) {
|
|
13
13
|
didWarnAboutDeprecation[componentName] = true;
|
|
14
14
|
process.env.NODE_ENV !== "production" ? warning(false, message) : void 0;
|
|
15
15
|
}
|
|
16
16
|
return componentName;
|
|
17
|
-
}
|
|
17
|
+
};
|
|
18
18
|
|
|
19
|
-
export { deprecateComponent
|
|
19
|
+
export { deprecateComponent };
|
|
@@ -736,7 +736,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
736
736
|
translateWithId: translateWithId
|
|
737
737
|
}))), slug ? normalizedDecorator : decorator ? /*#__PURE__*/React.createElement("div", {
|
|
738
738
|
className: `${prefix}--list-box__inner-wrapper--decorator`
|
|
739
|
-
}, normalizedDecorator) : '', /*#__PURE__*/React.createElement(index$2.default.Menu, menuProps, isOpen ? filterItems(items, itemToString, inputValue).map((item, index) => {
|
|
739
|
+
}, candidateIsAILabel ? normalizedDecorator : /*#__PURE__*/React.createElement("span", null, normalizedDecorator)) : '', /*#__PURE__*/React.createElement(index$2.default.Menu, menuProps, isOpen ? filterItems(items, itemToString, inputValue).map((item, index) => {
|
|
740
740
|
const isObject = item !== null && typeof item === 'object';
|
|
741
741
|
const title = isObject && 'text' in item && itemToElement ? item.text?.toString() : itemToString(item);
|
|
742
742
|
const itemProps = getItemProps({
|
|
@@ -20,7 +20,7 @@ const TableSlugRow = ({
|
|
|
20
20
|
slug
|
|
21
21
|
}) => {
|
|
22
22
|
React.useEffect(() => {
|
|
23
|
-
deprecateComponent.
|
|
23
|
+
deprecateComponent.deprecateComponent('TableSlugRow', 'The `TableSlugRow` component has been deprecated and will be removed in the next major version. Use the TableDecoratorRow component instead.');
|
|
24
24
|
}, []);
|
|
25
25
|
const prefix = usePrefix.usePrefix();
|
|
26
26
|
const TableSlugRowClasses = cx({
|
|
@@ -6,6 +6,14 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import React, { ReactNode, RefObject } from 'react';
|
|
8
8
|
export interface MenuProps extends React.HTMLAttributes<HTMLUListElement> {
|
|
9
|
+
/**
|
|
10
|
+
* Specify the background token to use. Default is 'layer'.
|
|
11
|
+
*/
|
|
12
|
+
backgroundToken?: 'layer' | 'background';
|
|
13
|
+
/**
|
|
14
|
+
* Specify whether a border should be rendered on the popover
|
|
15
|
+
*/
|
|
16
|
+
border?: boolean;
|
|
9
17
|
/**
|
|
10
18
|
* The ref of the containing element, used for positioning and alignment of the menu
|
|
11
19
|
*/
|
|
@@ -25,6 +25,8 @@ var environment = require('../../internal/environment.js');
|
|
|
25
25
|
const spacing = 8; // distance to keep to window edges, in px
|
|
26
26
|
|
|
27
27
|
const Menu = /*#__PURE__*/React.forwardRef(function Menu({
|
|
28
|
+
backgroundToken = 'layer',
|
|
29
|
+
border = false,
|
|
28
30
|
children,
|
|
29
31
|
className,
|
|
30
32
|
containerRef,
|
|
@@ -277,7 +279,9 @@ const Menu = /*#__PURE__*/React.forwardRef(function Menu({
|
|
|
277
279
|
[`${prefix}--menu--shown`]: open && !legacyAutoalign || position[0] >= 0 && position[1] >= 0,
|
|
278
280
|
[`${prefix}--menu--with-icons`]: childContext.state.hasIcons,
|
|
279
281
|
[`${prefix}--menu--with-selectable-items`]: childContext.state.hasSelectableItems,
|
|
280
|
-
[`${prefix}--autoalign`]: !legacyAutoalign
|
|
282
|
+
[`${prefix}--autoalign`]: !legacyAutoalign,
|
|
283
|
+
[`${prefix}--menu--border`]: border,
|
|
284
|
+
[`${prefix}--menu--background-token__background`]: backgroundToken === 'background'
|
|
281
285
|
});
|
|
282
286
|
const rendered = /*#__PURE__*/React.createElement(MenuContext.MenuContext.Provider, {
|
|
283
287
|
value: childContext
|
|
@@ -296,6 +300,14 @@ const Menu = /*#__PURE__*/React.forwardRef(function Menu({
|
|
|
296
300
|
return isRoot ? open && /*#__PURE__*/ReactDOM.createPortal(rendered, target) || null : rendered;
|
|
297
301
|
});
|
|
298
302
|
Menu.propTypes = {
|
|
303
|
+
/**
|
|
304
|
+
* Specify the background token to use. Default is 'layer'.
|
|
305
|
+
*/
|
|
306
|
+
backgroundToken: PropTypes.oneOf(['layer', 'background']),
|
|
307
|
+
/**
|
|
308
|
+
* Specify whether a border should be rendered on the menu
|
|
309
|
+
*/
|
|
310
|
+
border: PropTypes.bool,
|
|
299
311
|
/**
|
|
300
312
|
* A collection of MenuItems to be rendered within this Menu.
|
|
301
313
|
*/
|
|
@@ -39,6 +39,14 @@ export interface MenuButtonProps extends ComponentProps<'div'> {
|
|
|
39
39
|
* Specify the tabIndex of the button.
|
|
40
40
|
*/
|
|
41
41
|
tabIndex?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Specify the background token to use for the menu. Default is 'layer'.
|
|
44
|
+
*/
|
|
45
|
+
menuBackgroundToken?: 'layer' | 'background';
|
|
46
|
+
/**
|
|
47
|
+
* Specify whether a border should be rendered on the menu
|
|
48
|
+
*/
|
|
49
|
+
menuBorder?: boolean;
|
|
42
50
|
/**
|
|
43
51
|
* Specify a DOM node where the Menu should be rendered in. Defaults to document.body.
|
|
44
52
|
*/
|
|
@@ -32,6 +32,8 @@ const MenuButton = /*#__PURE__*/React.forwardRef(({
|
|
|
32
32
|
disabled,
|
|
33
33
|
kind = defaultButtonKind,
|
|
34
34
|
label,
|
|
35
|
+
menuBackgroundToken = 'layer',
|
|
36
|
+
menuBorder = false,
|
|
35
37
|
size = 'lg',
|
|
36
38
|
menuAlignment = 'bottom',
|
|
37
39
|
tabIndex = 0,
|
|
@@ -144,7 +146,9 @@ const MenuButton = /*#__PURE__*/React.forwardRef(({
|
|
|
144
146
|
size: size,
|
|
145
147
|
open: open,
|
|
146
148
|
onClose: handleClose,
|
|
147
|
-
target: menuTarget
|
|
149
|
+
target: menuTarget,
|
|
150
|
+
backgroundToken: menuBackgroundToken,
|
|
151
|
+
border: menuBorder
|
|
148
152
|
}, children));
|
|
149
153
|
});
|
|
150
154
|
MenuButton.propTypes = {
|
|
@@ -186,10 +190,17 @@ MenuButton.propTypes = {
|
|
|
186
190
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
187
191
|
// @ts-ignore-next-line -- avoid spurious (?) TS2322 error
|
|
188
192
|
tabIndex: PropTypes.number,
|
|
193
|
+
/**
|
|
194
|
+
* Specify the background token to use for the menu. Default is 'layer'.
|
|
195
|
+
*/
|
|
196
|
+
menuBackgroundToken: PropTypes.oneOf(['layer', 'background']),
|
|
197
|
+
/**
|
|
198
|
+
* Specify whether a border should be rendered on the menu
|
|
199
|
+
*/
|
|
200
|
+
menuBorder: PropTypes.bool,
|
|
189
201
|
/**
|
|
190
202
|
* Specify a DOM node where the Menu should be rendered in. Defaults to document.body.
|
|
191
203
|
*/
|
|
192
|
-
|
|
193
204
|
menuTarget: PropTypes.instanceOf(typeof Element !== 'undefined' ? Element : Object)
|
|
194
205
|
};
|
|
195
206
|
|