@carbon/react 1.86.0 → 1.87.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 +838 -838
- package/es/components/Button/Button.Skeleton.js +2 -1
- package/es/components/Button/Button.d.ts +1 -1
- package/es/components/Button/Button.js +2 -2
- package/es/components/Button/ButtonBase.js +2 -0
- package/es/components/CodeSnippet/CodeSnippet.js +1 -0
- package/es/components/ComboBox/ComboBox.d.ts +7 -0
- package/es/components/ComboBox/ComboBox.js +10 -1
- package/es/components/ContainedList/ContainedList.d.ts +1 -1
- package/es/components/ContainedList/ContainedList.js +3 -3
- package/es/components/Dropdown/Dropdown.Skeleton.js +4 -4
- package/es/components/FluidNumberInput/FluidNumberInput.d.ts +3 -2
- package/es/components/FluidNumberInput/FluidNumberInput.js +3 -2
- package/es/components/IconButton/index.d.ts +1 -1
- package/es/components/MultiSelect/FilterableMultiSelect.d.ts +7 -0
- package/es/components/MultiSelect/FilterableMultiSelect.js +17 -7
- package/es/components/NumberInput/NumberInput.d.ts +3 -2
- package/es/components/NumberInput/NumberInput.js +4 -3
- package/es/components/Popover/index.js +5 -4
- package/es/components/Toggletip/index.d.ts +1 -1
- package/es/components/Toggletip/index.js +1 -1
- package/es/internal/useEvent.d.ts +2 -2
- package/es/internal/useEvent.js +4 -3
- package/lib/components/Button/Button.Skeleton.js +2 -1
- package/lib/components/Button/Button.d.ts +1 -1
- package/lib/components/Button/Button.js +2 -2
- package/lib/components/Button/ButtonBase.js +2 -0
- package/lib/components/CodeSnippet/CodeSnippet.js +1 -0
- package/lib/components/ComboBox/ComboBox.d.ts +7 -0
- package/lib/components/ComboBox/ComboBox.js +10 -1
- package/lib/components/ContainedList/ContainedList.d.ts +1 -1
- package/lib/components/ContainedList/ContainedList.js +3 -3
- package/lib/components/Dropdown/Dropdown.Skeleton.js +4 -4
- package/lib/components/FluidNumberInput/FluidNumberInput.d.ts +3 -2
- package/lib/components/FluidNumberInput/FluidNumberInput.js +3 -2
- package/lib/components/IconButton/index.d.ts +1 -1
- package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +7 -0
- package/lib/components/MultiSelect/FilterableMultiSelect.js +17 -7
- package/lib/components/NumberInput/NumberInput.d.ts +3 -2
- package/lib/components/NumberInput/NumberInput.js +4 -3
- package/lib/components/Popover/index.js +4 -3
- package/lib/components/Toggletip/index.d.ts +1 -1
- package/lib/components/Toggletip/index.js +1 -1
- package/lib/internal/useEvent.d.ts +2 -2
- package/lib/internal/useEvent.js +4 -3
- package/package.json +5 -5
- package/telemetry.yml +1 -0
|
@@ -22,6 +22,7 @@ const ButtonSkeleton = ({
|
|
|
22
22
|
const buttonClasses = cx(className, {
|
|
23
23
|
[`${prefix}--skeleton`]: true,
|
|
24
24
|
[`${prefix}--btn`]: true,
|
|
25
|
+
[`${prefix}--btn--xs`]: size === 'xs',
|
|
25
26
|
[`${prefix}--btn--sm`]: small || size === 'sm',
|
|
26
27
|
[`${prefix}--btn--md`]: size === 'md',
|
|
27
28
|
[`${prefix}--btn--lg`]: size === 'lg',
|
|
@@ -54,7 +55,7 @@ ButtonSkeleton.propTypes = {
|
|
|
54
55
|
* For `default` buttons, this prop can remain unspecified or use `default`.
|
|
55
56
|
* In the next major release of Carbon, `default`, `field`, and `small` will be removed
|
|
56
57
|
*/
|
|
57
|
-
size: PropTypes.oneOf(['sm', 'md', 'lg', 'xl', '2xl']),
|
|
58
|
+
size: PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl', '2xl']),
|
|
58
59
|
/**
|
|
59
60
|
* @deprecated This property will be removed in the next major Carbon version,
|
|
60
61
|
* use size={sm} instead.
|
|
@@ -9,7 +9,7 @@ import { IconButtonKind } from '../IconButton';
|
|
|
9
9
|
import { PolymorphicComponentPropWithRef } from '../../internal/PolymorphicProps';
|
|
10
10
|
export declare const ButtonKinds: readonly ["primary", "secondary", "danger", "ghost", "danger--primary", "danger--ghost", "danger--tertiary", "tertiary"];
|
|
11
11
|
export type ButtonKind = (typeof ButtonKinds)[number];
|
|
12
|
-
export declare const ButtonSizes: readonly ["sm", "md", "lg", "xl", "2xl"];
|
|
12
|
+
export declare const ButtonSizes: readonly ["xs", "sm", "md", "lg", "xl", "2xl"];
|
|
13
13
|
export type ButtonSize = (typeof ButtonSizes)[number];
|
|
14
14
|
export declare const ButtonTooltipAlignments: readonly ["start", "center", "end"];
|
|
15
15
|
export type ButtonTooltipAlignment = (typeof ButtonTooltipAlignments)[number];
|
|
@@ -12,7 +12,7 @@ import { IconButton, IconButtonKinds } from '../IconButton/index.js';
|
|
|
12
12
|
import ButtonBase from './ButtonBase.js';
|
|
13
13
|
|
|
14
14
|
const ButtonKinds = ['primary', 'secondary', 'danger', 'ghost', 'danger--primary', 'danger--ghost', 'danger--tertiary', 'tertiary'];
|
|
15
|
-
const ButtonSizes = ['sm', 'md', 'lg', 'xl', '2xl'];
|
|
15
|
+
const ButtonSizes = ['xs', 'sm', 'md', 'lg', 'xl', '2xl'];
|
|
16
16
|
const ButtonTooltipAlignments = ['start', 'center', 'end'];
|
|
17
17
|
const ButtonTooltipPositions = ['top', 'right', 'bottom', 'left'];
|
|
18
18
|
function isIconOnlyButton(hasIconOnly, _kind) {
|
|
@@ -210,7 +210,7 @@ Button.propTypes = {
|
|
|
210
210
|
/**
|
|
211
211
|
* Specify the size of the button, from the following list of sizes:
|
|
212
212
|
*/
|
|
213
|
-
size: PropTypes.oneOf(['sm', 'md', 'lg', 'xl', '2xl']),
|
|
213
|
+
size: PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl', '2xl']),
|
|
214
214
|
/**
|
|
215
215
|
* Optional prop to specify the tabIndex of the Button
|
|
216
216
|
*/
|
|
@@ -36,6 +36,8 @@ const ButtonBase = /*#__PURE__*/React.forwardRef(function ButtonBase({
|
|
|
36
36
|
const prefix = usePrefix();
|
|
37
37
|
const buttonClasses = cx(className, {
|
|
38
38
|
[`${prefix}--btn`]: true,
|
|
39
|
+
[`${prefix}--btn--xs`]: size === 'xs' && !isExpressive,
|
|
40
|
+
// TODO: V12 - Remove this class
|
|
39
41
|
[`${prefix}--btn--sm`]: size === 'sm' && !isExpressive,
|
|
40
42
|
// TODO: V12 - Remove this class
|
|
41
43
|
[`${prefix}--btn--md`]: size === 'md' && !isExpressive,
|
|
@@ -157,6 +157,7 @@ function CodeSnippet({
|
|
|
157
157
|
"aria-label": deprecatedAriaLabel || ariaLabel,
|
|
158
158
|
"aria-describedby": uid,
|
|
159
159
|
className: codeSnippetClasses,
|
|
160
|
+
disabled: disabled,
|
|
160
161
|
feedback: feedback,
|
|
161
162
|
feedbackTimeout: feedbackTimeout
|
|
162
163
|
}), /*#__PURE__*/React.createElement("code", {
|
|
@@ -195,6 +195,13 @@ export interface ComboBoxProps<ItemType> extends Omit<InputHTMLAttributes<HTMLIn
|
|
|
195
195
|
* Provide the text that is displayed when the control is in warning state
|
|
196
196
|
*/
|
|
197
197
|
warnText?: ReactNode;
|
|
198
|
+
/**
|
|
199
|
+
* Specify native input attributes to place on the `<input>`, like maxLength.
|
|
200
|
+
* These are passed to downshift's getInputProps() and will override the
|
|
201
|
+
* internal input props.
|
|
202
|
+
* https://github.com/downshift-js/downshift?tab=readme-ov-file#getinputprops
|
|
203
|
+
*/
|
|
204
|
+
inputProps?: InputHTMLAttributes<HTMLInputElement>;
|
|
198
205
|
}
|
|
199
206
|
type ComboboxComponentProps<ItemType> = PropsWithRef<PropsWithChildren<ComboBoxProps<ItemType>> & RefAttributes<HTMLInputElement>>;
|
|
200
207
|
export interface ComboBoxComponent {
|
|
@@ -150,6 +150,7 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
150
150
|
warnText,
|
|
151
151
|
allowCustomValue = false,
|
|
152
152
|
slug,
|
|
153
|
+
inputProps,
|
|
153
154
|
...rest
|
|
154
155
|
} = props;
|
|
155
156
|
const enableFloatingStyles = useFeatureFlag('enable-v12-dynamic-floating-styles') || autoAlign;
|
|
@@ -623,6 +624,7 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
623
624
|
'aria-controls': isOpen ? undefined : menuProps.id,
|
|
624
625
|
placeholder,
|
|
625
626
|
value: inputValue,
|
|
627
|
+
...inputProps,
|
|
626
628
|
onChange: e => {
|
|
627
629
|
const newValue = e.target.value;
|
|
628
630
|
setInputValue(newValue);
|
|
@@ -924,7 +926,14 @@ ComboBox.propTypes = {
|
|
|
924
926
|
/**
|
|
925
927
|
* Provide the text that is displayed when the control is in warning state
|
|
926
928
|
*/
|
|
927
|
-
warnText: PropTypes.node
|
|
929
|
+
warnText: PropTypes.node,
|
|
930
|
+
/**
|
|
931
|
+
* Specify native input attributes to place on the `<input>`, like maxLength.
|
|
932
|
+
* These are passed to downshift's getInputProps() and will override the
|
|
933
|
+
* internal input props.
|
|
934
|
+
* https://github.com/downshift-js/downshift?tab=readme-ov-file#getinputprops
|
|
935
|
+
*/
|
|
936
|
+
inputProps: PropTypes.object
|
|
928
937
|
};
|
|
929
938
|
|
|
930
939
|
export { ComboBox as default };
|
|
@@ -76,7 +76,7 @@ const ContainedList = ({
|
|
|
76
76
|
const renderedChildren = renderChildren(children);
|
|
77
77
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
78
78
|
className: classes
|
|
79
|
-
}, rest), /*#__PURE__*/React.createElement("div", {
|
|
79
|
+
}, rest), label && /*#__PURE__*/React.createElement("div", {
|
|
80
80
|
className: `${prefix}--contained-list__header`
|
|
81
81
|
}, /*#__PURE__*/React.createElement("div", {
|
|
82
82
|
id: labelId,
|
|
@@ -99,7 +99,7 @@ const ContainedList = ({
|
|
|
99
99
|
// eslint-disable-next-line jsx-a11y/no-redundant-roles
|
|
100
100
|
React.createElement("ul", {
|
|
101
101
|
role: "list",
|
|
102
|
-
"aria-labelledby": labelId
|
|
102
|
+
"aria-labelledby": label ? labelId : undefined
|
|
103
103
|
}, isActionSearch ? filteredChildren : renderedChildren));
|
|
104
104
|
};
|
|
105
105
|
ContainedList.propTypes = {
|
|
@@ -126,7 +126,7 @@ ContainedList.propTypes = {
|
|
|
126
126
|
/**
|
|
127
127
|
* A label describing the contained list.
|
|
128
128
|
*/
|
|
129
|
-
label: PropTypes.oneOfType([PropTypes.string, PropTypes.node])
|
|
129
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
130
130
|
/**
|
|
131
131
|
* Specify the size of the contained list.
|
|
132
132
|
*/
|
|
@@ -20,15 +20,15 @@ const DropdownSkeleton = ({
|
|
|
20
20
|
...rest
|
|
21
21
|
}) => {
|
|
22
22
|
const prefix = usePrefix();
|
|
23
|
-
const wrapperClasses = cx(className, `${prefix}--skeleton`, `${prefix}--form-item
|
|
24
|
-
[`${prefix}--list-box--${size}`]: size
|
|
25
|
-
});
|
|
23
|
+
const wrapperClasses = cx(className, `${prefix}--skeleton`, `${prefix}--form-item`);
|
|
26
24
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
27
25
|
className: wrapperClasses
|
|
28
26
|
}, rest), !hideLabel && /*#__PURE__*/React.createElement("span", {
|
|
29
27
|
className: `${prefix}--label ${prefix}--skeleton`
|
|
30
28
|
}), /*#__PURE__*/React.createElement("div", {
|
|
31
|
-
className: `${prefix}--skeleton ${prefix}--dropdown
|
|
29
|
+
className: cx(`${prefix}--skeleton ${prefix}--dropdown`, {
|
|
30
|
+
[`${prefix}--list-box--${size}`]: size
|
|
31
|
+
})
|
|
32
32
|
}));
|
|
33
33
|
};
|
|
34
34
|
DropdownSkeleton.propTypes = {
|
|
@@ -43,8 +43,9 @@ export interface FluidNumberInputProps {
|
|
|
43
43
|
*/
|
|
44
44
|
id: string;
|
|
45
45
|
/**
|
|
46
|
-
* Instruct the browser which keyboard to display on mobile devices.
|
|
47
|
-
* standard numeric keyboards vary across devices
|
|
46
|
+
* Instruct the browser which keyboard to display on mobile devices. Defaults
|
|
47
|
+
* to `decimal`, but note that standard numeric keyboards vary across devices
|
|
48
|
+
* and operating systems.
|
|
48
49
|
* @see https://css-tricks.com/everything-you-ever-wanted-to-know-about-inputmode/
|
|
49
50
|
*/
|
|
50
51
|
inputMode?: React.HTMLAttributes<HTMLInputElement>['inputMode'];
|
|
@@ -67,8 +67,9 @@ FluidNumberInput.propTypes = {
|
|
|
67
67
|
*/
|
|
68
68
|
id: PropTypes.string.isRequired,
|
|
69
69
|
/**
|
|
70
|
-
* Instruct the browser which keyboard to display on mobile devices.
|
|
71
|
-
* standard numeric keyboards vary across devices
|
|
70
|
+
* Instruct the browser which keyboard to display on mobile devices. Defaults
|
|
71
|
+
* to `decimal`, but note that standard numeric keyboards vary across devices
|
|
72
|
+
* and operating systems.
|
|
72
73
|
* @see https://css-tricks.com/everything-you-ever-wanted-to-know-about-inputmode/
|
|
73
74
|
*/
|
|
74
75
|
inputMode: PropTypes.oneOf(['none', 'text', 'tel', 'url', 'email', 'numeric', 'decimal', 'search']),
|
|
@@ -88,7 +88,7 @@ export interface IconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonEl
|
|
|
88
88
|
/**
|
|
89
89
|
* Specify the size of the Button.
|
|
90
90
|
*/
|
|
91
|
-
size?: Extract<ButtonSize, 'sm' | 'md' | 'lg'>;
|
|
91
|
+
size?: Extract<ButtonSize, 'xs' | 'sm' | 'md' | 'lg'>;
|
|
92
92
|
/**
|
|
93
93
|
* Optionally specify a `target` when using an `<a>` element.
|
|
94
94
|
*/
|
|
@@ -191,6 +191,13 @@ export interface FilterableMultiSelectProps<ItemType> extends MultiSelectSorting
|
|
|
191
191
|
* Provide the text that is displayed when the control is in warning state
|
|
192
192
|
*/
|
|
193
193
|
warnText?: ReactNode;
|
|
194
|
+
/**
|
|
195
|
+
* Specify native input attributes to place on the `<input>`, like maxLength.
|
|
196
|
+
* These are passed to downshift's getInputProps() and will override the
|
|
197
|
+
* internal input props.
|
|
198
|
+
* https://github.com/downshift-js/downshift?tab=readme-ov-file#getinputprops
|
|
199
|
+
*/
|
|
200
|
+
inputProps?: React.InputHTMLAttributes<HTMLInputElement>;
|
|
194
201
|
}
|
|
195
202
|
export declare const FilterableMultiSelect: {
|
|
196
203
|
<ItemType>(props: FilterableMultiSelectProps<ItemType>): ReactElement<any>;
|
|
@@ -102,7 +102,8 @@ const FilterableMultiSelect = /*#__PURE__*/forwardRef(function FilterableMultiSe
|
|
|
102
102
|
useTitleInItem,
|
|
103
103
|
warn,
|
|
104
104
|
warnText,
|
|
105
|
-
slug
|
|
105
|
+
slug,
|
|
106
|
+
inputProps
|
|
106
107
|
}, ref) {
|
|
107
108
|
const {
|
|
108
109
|
isFluid
|
|
@@ -338,7 +339,7 @@ const FilterableMultiSelect = /*#__PURE__*/forwardRef(function FilterableMultiSe
|
|
|
338
339
|
}
|
|
339
340
|
return {
|
|
340
341
|
...changes,
|
|
341
|
-
highlightedIndex:
|
|
342
|
+
highlightedIndex: controlledSelectedItems.length > 0 ? 0 : -1
|
|
342
343
|
};
|
|
343
344
|
case InputChange:
|
|
344
345
|
if (onInputValueChange) {
|
|
@@ -351,6 +352,7 @@ const FilterableMultiSelect = /*#__PURE__*/forwardRef(function FilterableMultiSe
|
|
|
351
352
|
highlightedIndex: 0
|
|
352
353
|
};
|
|
353
354
|
case InputClick:
|
|
355
|
+
setIsOpen(changes.isOpen || false);
|
|
354
356
|
validateHighlightFocus();
|
|
355
357
|
if (changes.isOpen && !changes.selectedItem) {
|
|
356
358
|
return {
|
|
@@ -360,7 +362,7 @@ const FilterableMultiSelect = /*#__PURE__*/forwardRef(function FilterableMultiSe
|
|
|
360
362
|
return {
|
|
361
363
|
...changes,
|
|
362
364
|
isOpen: false,
|
|
363
|
-
highlightedIndex:
|
|
365
|
+
highlightedIndex: controlledSelectedItems.length > 0 ? 0 : -1
|
|
364
366
|
};
|
|
365
367
|
case MenuMouseLeave:
|
|
366
368
|
return {
|
|
@@ -482,7 +484,7 @@ const FilterableMultiSelect = /*#__PURE__*/forwardRef(function FilterableMultiSe
|
|
|
482
484
|
}
|
|
483
485
|
}
|
|
484
486
|
});
|
|
485
|
-
const
|
|
487
|
+
const inputProp = getInputProps(getDropdownProps({
|
|
486
488
|
'aria-controls': isOpen ? menuId : undefined,
|
|
487
489
|
'aria-describedby': helperText ? helperId : undefined,
|
|
488
490
|
'aria-haspopup': 'listbox',
|
|
@@ -492,6 +494,7 @@ const FilterableMultiSelect = /*#__PURE__*/forwardRef(function FilterableMultiSe
|
|
|
492
494
|
disabled,
|
|
493
495
|
placeholder,
|
|
494
496
|
preventKeyAction: isOpen,
|
|
497
|
+
...inputProps,
|
|
495
498
|
onClick: () => handleMenuChange(true),
|
|
496
499
|
onKeyDown(event) {
|
|
497
500
|
const $input = event.target;
|
|
@@ -545,7 +548,7 @@ const FilterableMultiSelect = /*#__PURE__*/forwardRef(function FilterableMultiSe
|
|
|
545
548
|
setIsFocused(evt?.type === 'focus' ? true : false);
|
|
546
549
|
}
|
|
547
550
|
};
|
|
548
|
-
const mergedRef = mergeRefs(textInput,
|
|
551
|
+
const mergedRef = mergeRefs(textInput, inputProp.ref);
|
|
549
552
|
const readOnlyEventHandlers = readOnly ? {
|
|
550
553
|
onClick: evt => {
|
|
551
554
|
// NOTE: does not prevent click
|
|
@@ -600,7 +603,7 @@ const FilterableMultiSelect = /*#__PURE__*/forwardRef(function FilterableMultiSe
|
|
|
600
603
|
disabled: disabled
|
|
601
604
|
}), /*#__PURE__*/React.createElement("input", _extends({
|
|
602
605
|
className: inputClasses
|
|
603
|
-
},
|
|
606
|
+
}, inputProp, {
|
|
604
607
|
ref: mergedRef
|
|
605
608
|
}, readOnlyEventHandlers, {
|
|
606
609
|
readOnly: readOnly
|
|
@@ -815,7 +818,14 @@ FilterableMultiSelect.propTypes = {
|
|
|
815
818
|
/**
|
|
816
819
|
* Provide the text that is displayed when the control is in warning state
|
|
817
820
|
*/
|
|
818
|
-
warnText: PropTypes.node
|
|
821
|
+
warnText: PropTypes.node,
|
|
822
|
+
/**
|
|
823
|
+
* Specify native input attributes to place on the `<input>`, like maxLength.
|
|
824
|
+
* These are passed to downshift's getInputProps() and will override the
|
|
825
|
+
* internal input props.
|
|
826
|
+
* https://github.com/downshift-js/downshift?tab=readme-ov-file#getinputprops
|
|
827
|
+
*/
|
|
828
|
+
inputProps: PropTypes.object
|
|
819
829
|
};
|
|
820
830
|
|
|
821
831
|
export { FilterableMultiSelect };
|
|
@@ -72,8 +72,9 @@ export interface NumberInputProps extends Omit<React.InputHTMLAttributes<HTMLInp
|
|
|
72
72
|
*/
|
|
73
73
|
id: string;
|
|
74
74
|
/**
|
|
75
|
-
* Instruct the browser which keyboard to display on mobile devices.
|
|
76
|
-
* standard numeric keyboards vary across devices
|
|
75
|
+
* Instruct the browser which keyboard to display on mobile devices. Defaults
|
|
76
|
+
* to `decimal`, but note that standard numeric keyboards vary across devices
|
|
77
|
+
* and operating systems.
|
|
77
78
|
* @see https://css-tricks.com/everything-you-ever-wanted-to-know-about-inputmode/
|
|
78
79
|
*/
|
|
79
80
|
inputMode?: React.HTMLAttributes<HTMLInputElement>['inputMode'];
|
|
@@ -54,7 +54,7 @@ const NumberInput = /*#__PURE__*/React.forwardRef(function NumberInput(props, fo
|
|
|
54
54
|
hideSteppers,
|
|
55
55
|
iconDescription,
|
|
56
56
|
id,
|
|
57
|
-
inputMode,
|
|
57
|
+
inputMode = 'decimal',
|
|
58
58
|
invalid = false,
|
|
59
59
|
invalidText,
|
|
60
60
|
label,
|
|
@@ -495,8 +495,9 @@ NumberInput.propTypes = {
|
|
|
495
495
|
*/
|
|
496
496
|
id: PropTypes.string.isRequired,
|
|
497
497
|
/**
|
|
498
|
-
* Instruct the browser which keyboard to display on mobile devices.
|
|
499
|
-
* standard numeric keyboards vary across devices
|
|
498
|
+
* Instruct the browser which keyboard to display on mobile devices. Defaults
|
|
499
|
+
* to `decimal`, but note that standard numeric keyboards vary across devices
|
|
500
|
+
* and operating systems.
|
|
500
501
|
* @see https://css-tricks.com/everything-you-ever-wanted-to-know-about-inputmode/
|
|
501
502
|
*/
|
|
502
503
|
inputMode: PropTypes.oneOf(['none', 'text', 'tel', 'url', 'email', 'numeric', 'decimal', 'search']),
|
|
@@ -13,7 +13,7 @@ import React, { useRef, useMemo, useEffect } from 'react';
|
|
|
13
13
|
import useIsomorphicEffect from '../../internal/useIsomorphicEffect.js';
|
|
14
14
|
import { useMergedRefs } from '../../internal/useMergedRefs.js';
|
|
15
15
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
16
|
-
import { useWindowEvent } from '../../internal/useEvent.js';
|
|
16
|
+
import { useEvent, useWindowEvent } from '../../internal/useEvent.js';
|
|
17
17
|
import { mapPopoverAlign } from '../../tools/mapPopoverAlign.js';
|
|
18
18
|
import { useFloating, offset, flip, arrow, hide, autoUpdate } from '@floating-ui/react';
|
|
19
19
|
import { useFeatureFlag } from '../FeatureFlags/index.js';
|
|
@@ -59,9 +59,10 @@ forwardRef) {
|
|
|
59
59
|
const enableFloatingStyles = useFeatureFlag('enable-v12-dynamic-floating-styles') || autoAlign;
|
|
60
60
|
let align = mapPopoverAlign(initialAlign);
|
|
61
61
|
|
|
62
|
-
//
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
// The `Popover` should close whenever it and its children loses focus
|
|
63
|
+
useEvent(popover, 'focusout', event => {
|
|
64
|
+
const relatedTarget = event.relatedTarget;
|
|
65
|
+
if (!popover.current?.contains(relatedTarget)) {
|
|
65
66
|
onRequestClose?.();
|
|
66
67
|
}
|
|
67
68
|
});
|
|
@@ -58,7 +58,7 @@ export declare namespace Toggletip {
|
|
|
58
58
|
*/
|
|
59
59
|
align: PropTypes.Requireable<string>;
|
|
60
60
|
/**
|
|
61
|
-
* Provide an offset value for alignment axis.
|
|
61
|
+
* **Experimental:** Provide an offset value for alignment axis. Only takes effect when `autoalign` is enabled.
|
|
62
62
|
*/
|
|
63
63
|
alignmentAxisOffset: PropTypes.Requireable<number>;
|
|
64
64
|
/**
|
|
@@ -176,7 +176,7 @@ Toggletip.propTypes = {
|
|
|
176
176
|
// new values to match floating-ui
|
|
177
177
|
'top-start', 'top-end', 'bottom-start', 'bottom-end', 'left-end', 'left-start', 'right-end', 'right-start']),
|
|
178
178
|
/**
|
|
179
|
-
* Provide an offset value for alignment axis.
|
|
179
|
+
* **Experimental:** Provide an offset value for alignment axis. Only takes effect when `autoalign` is enabled.
|
|
180
180
|
*/
|
|
181
181
|
alignmentAxisOffset: PropTypes.number,
|
|
182
182
|
/**
|
|
@@ -4,6 +4,6 @@
|
|
|
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 {
|
|
8
|
-
export declare const useEvent: <E extends keyof GlobalEventHandlersEventMap>(elementOrRef: HTMLElement |
|
|
7
|
+
import { RefObject } from 'react';
|
|
8
|
+
export declare const useEvent: <E extends keyof GlobalEventHandlersEventMap>(elementOrRef: HTMLElement | RefObject<Element | null>, eventName: E, callback: (event: GlobalEventHandlersEventMap[E]) => void) => void;
|
|
9
9
|
export declare const useWindowEvent: <E extends keyof WindowEventMap>(eventName: E, callback: (event: WindowEventMap[E]) => void) => void;
|
package/es/internal/useEvent.js
CHANGED
|
@@ -13,15 +13,16 @@ const useEvent = (elementOrRef, eventName, callback) => {
|
|
|
13
13
|
savedCallback.current = callback;
|
|
14
14
|
}, [callback]);
|
|
15
15
|
useEffect(() => {
|
|
16
|
+
const element = 'current' in elementOrRef ? elementOrRef.current : elementOrRef;
|
|
17
|
+
if (!element) return;
|
|
16
18
|
const handler = event => {
|
|
17
19
|
if (savedCallback.current) {
|
|
18
20
|
savedCallback.current(event);
|
|
19
21
|
}
|
|
20
22
|
};
|
|
21
|
-
|
|
22
|
-
element?.addEventListener(eventName, handler);
|
|
23
|
+
element.addEventListener(eventName, handler);
|
|
23
24
|
return () => {
|
|
24
|
-
element
|
|
25
|
+
element.removeEventListener(eventName, handler);
|
|
25
26
|
};
|
|
26
27
|
}, [elementOrRef, eventName]);
|
|
27
28
|
};
|
|
@@ -32,6 +32,7 @@ const ButtonSkeleton = ({
|
|
|
32
32
|
const buttonClasses = cx__default["default"](className, {
|
|
33
33
|
[`${prefix}--skeleton`]: true,
|
|
34
34
|
[`${prefix}--btn`]: true,
|
|
35
|
+
[`${prefix}--btn--xs`]: size === 'xs',
|
|
35
36
|
[`${prefix}--btn--sm`]: small || size === 'sm',
|
|
36
37
|
[`${prefix}--btn--md`]: size === 'md',
|
|
37
38
|
[`${prefix}--btn--lg`]: size === 'lg',
|
|
@@ -64,7 +65,7 @@ ButtonSkeleton.propTypes = {
|
|
|
64
65
|
* For `default` buttons, this prop can remain unspecified or use `default`.
|
|
65
66
|
* In the next major release of Carbon, `default`, `field`, and `small` will be removed
|
|
66
67
|
*/
|
|
67
|
-
size: PropTypes__default["default"].oneOf(['sm', 'md', 'lg', 'xl', '2xl']),
|
|
68
|
+
size: PropTypes__default["default"].oneOf(['xs', 'sm', 'md', 'lg', 'xl', '2xl']),
|
|
68
69
|
/**
|
|
69
70
|
* @deprecated This property will be removed in the next major Carbon version,
|
|
70
71
|
* use size={sm} instead.
|
|
@@ -9,7 +9,7 @@ import { IconButtonKind } from '../IconButton';
|
|
|
9
9
|
import { PolymorphicComponentPropWithRef } from '../../internal/PolymorphicProps';
|
|
10
10
|
export declare const ButtonKinds: readonly ["primary", "secondary", "danger", "ghost", "danger--primary", "danger--ghost", "danger--tertiary", "tertiary"];
|
|
11
11
|
export type ButtonKind = (typeof ButtonKinds)[number];
|
|
12
|
-
export declare const ButtonSizes: readonly ["sm", "md", "lg", "xl", "2xl"];
|
|
12
|
+
export declare const ButtonSizes: readonly ["xs", "sm", "md", "lg", "xl", "2xl"];
|
|
13
13
|
export type ButtonSize = (typeof ButtonSizes)[number];
|
|
14
14
|
export declare const ButtonTooltipAlignments: readonly ["start", "center", "end"];
|
|
15
15
|
export type ButtonTooltipAlignment = (typeof ButtonTooltipAlignments)[number];
|
|
@@ -21,7 +21,7 @@ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
|
21
21
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
22
22
|
|
|
23
23
|
const ButtonKinds = ['primary', 'secondary', 'danger', 'ghost', 'danger--primary', 'danger--ghost', 'danger--tertiary', 'tertiary'];
|
|
24
|
-
const ButtonSizes = ['sm', 'md', 'lg', 'xl', '2xl'];
|
|
24
|
+
const ButtonSizes = ['xs', 'sm', 'md', 'lg', 'xl', '2xl'];
|
|
25
25
|
const ButtonTooltipAlignments = ['start', 'center', 'end'];
|
|
26
26
|
const ButtonTooltipPositions = ['top', 'right', 'bottom', 'left'];
|
|
27
27
|
function isIconOnlyButton(hasIconOnly, _kind) {
|
|
@@ -219,7 +219,7 @@ Button.propTypes = {
|
|
|
219
219
|
/**
|
|
220
220
|
* Specify the size of the button, from the following list of sizes:
|
|
221
221
|
*/
|
|
222
|
-
size: PropTypes__default["default"].oneOf(['sm', 'md', 'lg', 'xl', '2xl']),
|
|
222
|
+
size: PropTypes__default["default"].oneOf(['xs', 'sm', 'md', 'lg', 'xl', '2xl']),
|
|
223
223
|
/**
|
|
224
224
|
* Optional prop to specify the tabIndex of the Button
|
|
225
225
|
*/
|
|
@@ -45,6 +45,8 @@ const ButtonBase = /*#__PURE__*/React__default["default"].forwardRef(function Bu
|
|
|
45
45
|
const prefix = usePrefix.usePrefix();
|
|
46
46
|
const buttonClasses = cx__default["default"](className, {
|
|
47
47
|
[`${prefix}--btn`]: true,
|
|
48
|
+
[`${prefix}--btn--xs`]: size === 'xs' && !isExpressive,
|
|
49
|
+
// TODO: V12 - Remove this class
|
|
48
50
|
[`${prefix}--btn--sm`]: size === 'sm' && !isExpressive,
|
|
49
51
|
// TODO: V12 - Remove this class
|
|
50
52
|
[`${prefix}--btn--md`]: size === 'md' && !isExpressive,
|
|
@@ -168,6 +168,7 @@ function CodeSnippet({
|
|
|
168
168
|
"aria-label": deprecatedAriaLabel || ariaLabel,
|
|
169
169
|
"aria-describedby": uid,
|
|
170
170
|
className: codeSnippetClasses,
|
|
171
|
+
disabled: disabled,
|
|
171
172
|
feedback: feedback,
|
|
172
173
|
feedbackTimeout: feedbackTimeout
|
|
173
174
|
}), /*#__PURE__*/React__default["default"].createElement("code", {
|
|
@@ -195,6 +195,13 @@ export interface ComboBoxProps<ItemType> extends Omit<InputHTMLAttributes<HTMLIn
|
|
|
195
195
|
* Provide the text that is displayed when the control is in warning state
|
|
196
196
|
*/
|
|
197
197
|
warnText?: ReactNode;
|
|
198
|
+
/**
|
|
199
|
+
* Specify native input attributes to place on the `<input>`, like maxLength.
|
|
200
|
+
* These are passed to downshift's getInputProps() and will override the
|
|
201
|
+
* internal input props.
|
|
202
|
+
* https://github.com/downshift-js/downshift?tab=readme-ov-file#getinputprops
|
|
203
|
+
*/
|
|
204
|
+
inputProps?: InputHTMLAttributes<HTMLInputElement>;
|
|
198
205
|
}
|
|
199
206
|
type ComboboxComponentProps<ItemType> = PropsWithRef<PropsWithChildren<ComboBoxProps<ItemType>> & RefAttributes<HTMLInputElement>>;
|
|
200
207
|
export interface ComboBoxComponent {
|
|
@@ -161,6 +161,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
161
161
|
warnText,
|
|
162
162
|
allowCustomValue = false,
|
|
163
163
|
slug,
|
|
164
|
+
inputProps,
|
|
164
165
|
...rest
|
|
165
166
|
} = props;
|
|
166
167
|
const enableFloatingStyles = index.useFeatureFlag('enable-v12-dynamic-floating-styles') || autoAlign;
|
|
@@ -634,6 +635,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
634
635
|
'aria-controls': isOpen ? undefined : menuProps.id,
|
|
635
636
|
placeholder,
|
|
636
637
|
value: inputValue,
|
|
638
|
+
...inputProps,
|
|
637
639
|
onChange: e => {
|
|
638
640
|
const newValue = e.target.value;
|
|
639
641
|
setInputValue(newValue);
|
|
@@ -935,7 +937,14 @@ ComboBox.propTypes = {
|
|
|
935
937
|
/**
|
|
936
938
|
* Provide the text that is displayed when the control is in warning state
|
|
937
939
|
*/
|
|
938
|
-
warnText: PropTypes__default["default"].node
|
|
940
|
+
warnText: PropTypes__default["default"].node,
|
|
941
|
+
/**
|
|
942
|
+
* Specify native input attributes to place on the `<input>`, like maxLength.
|
|
943
|
+
* These are passed to downshift's getInputProps() and will override the
|
|
944
|
+
* internal input props.
|
|
945
|
+
* https://github.com/downshift-js/downshift?tab=readme-ov-file#getinputprops
|
|
946
|
+
*/
|
|
947
|
+
inputProps: PropTypes__default["default"].object
|
|
939
948
|
};
|
|
940
949
|
|
|
941
950
|
exports["default"] = ComboBox;
|
|
@@ -86,7 +86,7 @@ const ContainedList = ({
|
|
|
86
86
|
const renderedChildren = renderChildren(children);
|
|
87
87
|
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
|
|
88
88
|
className: classes
|
|
89
|
-
}, rest), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
89
|
+
}, rest), label && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
90
90
|
className: `${prefix}--contained-list__header`
|
|
91
91
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
92
92
|
id: labelId,
|
|
@@ -109,7 +109,7 @@ const ContainedList = ({
|
|
|
109
109
|
// eslint-disable-next-line jsx-a11y/no-redundant-roles
|
|
110
110
|
React__default["default"].createElement("ul", {
|
|
111
111
|
role: "list",
|
|
112
|
-
"aria-labelledby": labelId
|
|
112
|
+
"aria-labelledby": label ? labelId : undefined
|
|
113
113
|
}, isActionSearch ? filteredChildren : renderedChildren));
|
|
114
114
|
};
|
|
115
115
|
ContainedList.propTypes = {
|
|
@@ -136,7 +136,7 @@ ContainedList.propTypes = {
|
|
|
136
136
|
/**
|
|
137
137
|
* A label describing the contained list.
|
|
138
138
|
*/
|
|
139
|
-
label: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].node])
|
|
139
|
+
label: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].node]),
|
|
140
140
|
/**
|
|
141
141
|
* Specify the size of the contained list.
|
|
142
142
|
*/
|
|
@@ -30,15 +30,15 @@ const DropdownSkeleton = ({
|
|
|
30
30
|
...rest
|
|
31
31
|
}) => {
|
|
32
32
|
const prefix = usePrefix.usePrefix();
|
|
33
|
-
const wrapperClasses = cx__default["default"](className, `${prefix}--skeleton`, `${prefix}--form-item
|
|
34
|
-
[`${prefix}--list-box--${size}`]: size
|
|
35
|
-
});
|
|
33
|
+
const wrapperClasses = cx__default["default"](className, `${prefix}--skeleton`, `${prefix}--form-item`);
|
|
36
34
|
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
|
|
37
35
|
className: wrapperClasses
|
|
38
36
|
}, rest), !hideLabel && /*#__PURE__*/React__default["default"].createElement("span", {
|
|
39
37
|
className: `${prefix}--label ${prefix}--skeleton`
|
|
40
38
|
}), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
41
|
-
className: `${prefix}--skeleton ${prefix}--dropdown
|
|
39
|
+
className: cx__default["default"](`${prefix}--skeleton ${prefix}--dropdown`, {
|
|
40
|
+
[`${prefix}--list-box--${size}`]: size
|
|
41
|
+
})
|
|
42
42
|
}));
|
|
43
43
|
};
|
|
44
44
|
DropdownSkeleton.propTypes = {
|
|
@@ -43,8 +43,9 @@ export interface FluidNumberInputProps {
|
|
|
43
43
|
*/
|
|
44
44
|
id: string;
|
|
45
45
|
/**
|
|
46
|
-
* Instruct the browser which keyboard to display on mobile devices.
|
|
47
|
-
* standard numeric keyboards vary across devices
|
|
46
|
+
* Instruct the browser which keyboard to display on mobile devices. Defaults
|
|
47
|
+
* to `decimal`, but note that standard numeric keyboards vary across devices
|
|
48
|
+
* and operating systems.
|
|
48
49
|
* @see https://css-tricks.com/everything-you-ever-wanted-to-know-about-inputmode/
|
|
49
50
|
*/
|
|
50
51
|
inputMode?: React.HTMLAttributes<HTMLInputElement>['inputMode'];
|
|
@@ -77,8 +77,9 @@ FluidNumberInput.propTypes = {
|
|
|
77
77
|
*/
|
|
78
78
|
id: PropTypes__default["default"].string.isRequired,
|
|
79
79
|
/**
|
|
80
|
-
* Instruct the browser which keyboard to display on mobile devices.
|
|
81
|
-
* standard numeric keyboards vary across devices
|
|
80
|
+
* Instruct the browser which keyboard to display on mobile devices. Defaults
|
|
81
|
+
* to `decimal`, but note that standard numeric keyboards vary across devices
|
|
82
|
+
* and operating systems.
|
|
82
83
|
* @see https://css-tricks.com/everything-you-ever-wanted-to-know-about-inputmode/
|
|
83
84
|
*/
|
|
84
85
|
inputMode: PropTypes__default["default"].oneOf(['none', 'text', 'tel', 'url', 'email', 'numeric', 'decimal', 'search']),
|
|
@@ -88,7 +88,7 @@ export interface IconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonEl
|
|
|
88
88
|
/**
|
|
89
89
|
* Specify the size of the Button.
|
|
90
90
|
*/
|
|
91
|
-
size?: Extract<ButtonSize, 'sm' | 'md' | 'lg'>;
|
|
91
|
+
size?: Extract<ButtonSize, 'xs' | 'sm' | 'md' | 'lg'>;
|
|
92
92
|
/**
|
|
93
93
|
* Optionally specify a `target` when using an `<a>` element.
|
|
94
94
|
*/
|