@carbon/react 1.68.0 → 1.69.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 +871 -871
- package/README.md +3 -3
- package/es/components/Accordion/AccordionItem.js +0 -1
- package/es/components/Button/Button.js +6 -0
- package/es/components/Checkbox/Checkbox.js +1 -1
- package/es/components/CheckboxGroup/CheckboxGroup.js +1 -2
- package/es/components/CheckboxGroup/index.d.ts +10 -0
- package/es/components/ComboBox/ComboBox.js +13 -18
- package/es/components/ComboButton/index.js +10 -3
- package/es/components/DataTable/TableCell.d.ts +1 -4
- package/es/components/DataTable/TableCell.js +3 -2
- package/es/components/Disclosure/index.d.ts +18 -0
- package/es/components/Dropdown/Dropdown.js +11 -9
- package/es/components/FileUploader/FileUploader.d.ts +8 -92
- package/es/components/FileUploader/FileUploader.js +116 -137
- package/es/components/Grid/CSSGrid.js +8 -1
- package/es/components/Grid/Grid.js +4 -0
- package/es/components/IdPrefix/index.d.ts +26 -0
- package/es/components/ListBox/next/ListBoxSelection.d.ts +9 -1
- package/es/components/ListBox/next/ListBoxSelection.js +12 -5
- package/es/components/Menu/MenuItem.js +1 -4
- package/es/components/MenuButton/index.d.ts +4 -0
- package/es/components/MenuButton/index.js +19 -5
- package/es/components/MultiSelect/FilterableMultiSelect.d.ts +4 -0
- package/es/components/MultiSelect/FilterableMultiSelect.js +32 -6
- package/es/components/MultiSelect/MultiSelect.js +11 -9
- package/es/components/OverflowMenu/next/index.d.ts +4 -0
- package/es/components/OverflowMenu/next/index.js +19 -9
- package/es/components/PaginationNav/PaginationNav.js +1 -1
- package/es/components/Popover/index.js +18 -14
- package/es/components/Portal/index.d.ts +25 -0
- package/es/components/Slider/Slider.js +2 -2
- package/es/components/Tabs/Tabs.js +46 -20
- package/es/components/Tag/DismissibleTag.js +2 -2
- package/es/components/Tag/OperationalTag.d.ts +2 -10
- package/es/components/Tag/OperationalTag.js +2 -14
- package/es/components/Tag/SelectableTag.d.ts +18 -10
- package/es/components/Tag/SelectableTag.js +22 -28
- package/es/components/Toggle/Toggle.js +2 -0
- package/es/components/ToggleSmall/ToggleSmall.Skeleton.d.ts +49 -0
- package/es/components/ToggleSmall/index.d.ts +7 -0
- package/es/components/TreeView/TreeNode.js +4 -2
- package/es/components/TreeView/TreeView.js +4 -4
- package/es/components/UIShell/SideNavMenuItem.d.ts +4 -3
- package/es/components/UIShell/SideNavMenuItem.js +1 -4
- package/es/index.js +1 -1
- package/es/internal/useIdPrefix.d.ts +9 -0
- package/lib/components/Accordion/AccordionItem.js +0 -1
- package/lib/components/Button/Button.js +6 -0
- package/lib/components/Checkbox/Checkbox.js +1 -1
- package/lib/components/CheckboxGroup/CheckboxGroup.js +1 -2
- package/lib/components/CheckboxGroup/index.d.ts +10 -0
- package/lib/components/ComboBox/ComboBox.js +18 -23
- package/lib/components/ComboButton/index.js +12 -5
- package/lib/components/DataTable/TableCell.d.ts +1 -4
- package/lib/components/DataTable/TableCell.js +3 -2
- package/lib/components/Disclosure/index.d.ts +18 -0
- package/lib/components/Dropdown/Dropdown.js +18 -16
- package/lib/components/FileUploader/FileUploader.d.ts +8 -92
- package/lib/components/FileUploader/FileUploader.js +113 -134
- package/lib/components/Grid/CSSGrid.js +8 -1
- package/lib/components/Grid/Grid.js +4 -0
- package/lib/components/IdPrefix/index.d.ts +26 -0
- package/lib/components/ListBox/next/ListBoxSelection.d.ts +9 -1
- package/lib/components/ListBox/next/ListBoxSelection.js +12 -5
- package/lib/components/Menu/MenuItem.js +1 -4
- package/lib/components/MenuButton/index.d.ts +4 -0
- package/lib/components/MenuButton/index.js +19 -5
- package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +4 -0
- package/lib/components/MultiSelect/FilterableMultiSelect.js +32 -6
- package/lib/components/MultiSelect/MultiSelect.js +18 -16
- package/lib/components/OverflowMenu/next/index.d.ts +4 -0
- package/lib/components/OverflowMenu/next/index.js +21 -11
- package/lib/components/PaginationNav/PaginationNav.js +1 -1
- package/lib/components/Popover/index.js +18 -14
- package/lib/components/Portal/index.d.ts +25 -0
- package/lib/components/Slider/Slider.js +2 -2
- package/lib/components/Tabs/Tabs.js +46 -20
- package/lib/components/Tag/DismissibleTag.js +2 -2
- package/lib/components/Tag/OperationalTag.d.ts +2 -10
- package/lib/components/Tag/OperationalTag.js +2 -14
- package/lib/components/Tag/SelectableTag.d.ts +18 -10
- package/lib/components/Tag/SelectableTag.js +22 -28
- package/lib/components/Toggle/Toggle.js +2 -0
- package/lib/components/ToggleSmall/ToggleSmall.Skeleton.d.ts +49 -0
- package/lib/components/ToggleSmall/index.d.ts +7 -0
- package/lib/components/TreeView/TreeNode.js +4 -2
- package/lib/components/TreeView/TreeView.js +4 -4
- package/lib/components/UIShell/SideNavMenuItem.d.ts +4 -3
- package/lib/components/UIShell/SideNavMenuItem.js +1 -4
- package/lib/index.js +2 -2
- package/lib/internal/useIdPrefix.d.ts +9 -0
- package/package.json +10 -9
- package/telemetry.yml +809 -809
package/README.md
CHANGED
|
@@ -135,9 +135,9 @@ Licensed under the [Apache 2.0 License](/LICENSE).
|
|
|
135
135
|
|
|
136
136
|
## <picture><source height="20" width="20" media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/ibm-telemetry/telemetry-js/main/docs/images/ibm-telemetry-dark.svg"><source height="20" width="20" media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/ibm-telemetry/telemetry-js/main/docs/images/ibm-telemetry-light.svg"><img height="20" width="20" alt="IBM Telemetry" src="https://raw.githubusercontent.com/ibm-telemetry/telemetry-js/main/docs/images/ibm-telemetry-light.svg"></picture> IBM Telemetry
|
|
137
137
|
|
|
138
|
-
This package uses IBM Telemetry to collect
|
|
139
|
-
package as a dependency you are agreeing to telemetry
|
|
140
|
-
see
|
|
138
|
+
This package uses IBM Telemetry to collect de-identified and anonymized metrics
|
|
139
|
+
data. By installing this package as a dependency you are agreeing to telemetry
|
|
140
|
+
collection. To opt out, see
|
|
141
141
|
[Opting out of IBM Telemetry data collection](https://github.com/ibm-telemetry/telemetry-js/tree/main#opting-out-of-ibm-telemetry-data-collection).
|
|
142
142
|
For more information on the data being collected, please see the
|
|
143
143
|
[IBM Telemetry documentation](https://github.com/ibm-telemetry/telemetry-js/tree/main#ibm-telemetry-collection-basics).
|
|
@@ -108,7 +108,6 @@ function AccordionItem(_ref) {
|
|
|
108
108
|
className: `${prefix}--accordion__title`
|
|
109
109
|
}, title)), /*#__PURE__*/React__default.createElement("div", {
|
|
110
110
|
ref: content,
|
|
111
|
-
hidden: !isOpen,
|
|
112
111
|
className: `${prefix}--accordion__wrapper`,
|
|
113
112
|
onTransitionEnd: onAnimationEnd
|
|
114
113
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
@@ -26,6 +26,7 @@ const Button = /*#__PURE__*/React__default.forwardRef(function Button(props, ref
|
|
|
26
26
|
const tooltipRef = useRef(null);
|
|
27
27
|
const {
|
|
28
28
|
as,
|
|
29
|
+
autoAlign = false,
|
|
29
30
|
children,
|
|
30
31
|
hasIconOnly = false,
|
|
31
32
|
iconDescription,
|
|
@@ -84,6 +85,7 @@ const Button = /*#__PURE__*/React__default.forwardRef(function Button(props, ref
|
|
|
84
85
|
onMouseLeave: onMouseLeave,
|
|
85
86
|
onFocus: onFocus,
|
|
86
87
|
onBlur: onBlur,
|
|
88
|
+
autoAlign: autoAlign,
|
|
87
89
|
onClick: composeEventHandlers([onClick, handleClick]),
|
|
88
90
|
renderIcon: iconOnlyImage ? null : ButtonImageElement // avoid doubling the icon.
|
|
89
91
|
}), iconOnlyImage ?? children);
|
|
@@ -96,6 +98,10 @@ Button.propTypes = {
|
|
|
96
98
|
* Make sure to apply all props to the root node and render children appropriately
|
|
97
99
|
*/
|
|
98
100
|
as: PropTypes.oneOfType([PropTypes.func, PropTypes.string, PropTypes.elementType]),
|
|
101
|
+
/**
|
|
102
|
+
* **Experimental**: Will attempt to automatically align the tooltip
|
|
103
|
+
*/
|
|
104
|
+
autoAlign: PropTypes.bool,
|
|
99
105
|
/**
|
|
100
106
|
* Specify the content of your Button
|
|
101
107
|
*/
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2023
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import CheckboxGroup from './CheckboxGroup';
|
|
8
|
+
import { type CheckboxGroupProps, type CustomType } from './CheckboxGroup';
|
|
9
|
+
export default CheckboxGroup;
|
|
10
|
+
export { CheckboxGroup, type CheckboxGroupProps, type CustomType };
|
|
@@ -9,7 +9,7 @@ import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js
|
|
|
9
9
|
import cx from 'classnames';
|
|
10
10
|
import { useCombobox } from 'downshift';
|
|
11
11
|
import PropTypes from 'prop-types';
|
|
12
|
-
import React__default, { forwardRef,
|
|
12
|
+
import React__default, { forwardRef, useRef, useEffect, useState, useContext, useCallback, useMemo } from 'react';
|
|
13
13
|
import '../Text/index.js';
|
|
14
14
|
import { WarningFilled, WarningAltFilled, Checkmark } from '@carbon/icons-react';
|
|
15
15
|
import ListBox from '../ListBox/index.js';
|
|
@@ -23,6 +23,7 @@ import '../FluidForm/FluidForm.js';
|
|
|
23
23
|
import { FormContext } from '../FluidForm/FormContext.js';
|
|
24
24
|
import { useFloating, flip, autoUpdate } from '@floating-ui/react';
|
|
25
25
|
import { hide } from '../../node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs.js';
|
|
26
|
+
import { useFeatureFlag } from '../FeatureFlags/index.js';
|
|
26
27
|
import { Text } from '../Text/Text.js';
|
|
27
28
|
import { match } from '../../internal/keyboard/match.js';
|
|
28
29
|
import { ListBoxSize } from '../ListBox/ListBoxPropTypes.js';
|
|
@@ -109,7 +110,6 @@ const findHighlightedIndex = (_ref3, inputValue) => {
|
|
|
109
110
|
*/
|
|
110
111
|
|
|
111
112
|
const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
112
|
-
const [cursorPosition, setCursorPosition] = useState(0);
|
|
113
113
|
const prevInputLengthRef = useRef(0);
|
|
114
114
|
const inputRef = useRef(null);
|
|
115
115
|
const {
|
|
@@ -147,19 +147,20 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
147
147
|
slug,
|
|
148
148
|
...rest
|
|
149
149
|
} = props;
|
|
150
|
+
const enableFloatingStyles = useFeatureFlag('enable-v12-dynamic-floating-styles') || autoAlign;
|
|
150
151
|
const {
|
|
151
152
|
refs,
|
|
152
153
|
floatingStyles,
|
|
153
154
|
middlewareData
|
|
154
|
-
} = useFloating(
|
|
155
|
+
} = useFloating(enableFloatingStyles ? {
|
|
155
156
|
placement: direction,
|
|
156
157
|
strategy: 'fixed',
|
|
157
|
-
middleware: [flip(), hide()],
|
|
158
|
+
middleware: autoAlign ? [flip(), hide()] : undefined,
|
|
158
159
|
whileElementsMounted: autoUpdate
|
|
159
160
|
} : {});
|
|
160
161
|
const parentWidth = refs?.reference?.current?.clientWidth;
|
|
161
162
|
useEffect(() => {
|
|
162
|
-
if (
|
|
163
|
+
if (enableFloatingStyles) {
|
|
163
164
|
const updatedFloatingStyles = {
|
|
164
165
|
...floatingStyles,
|
|
165
166
|
visibility: middlewareData.hide?.referenceHidden ? 'hidden' : 'visible'
|
|
@@ -173,7 +174,7 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
173
174
|
refs.floating.current.style.width = parentWidth + 'px';
|
|
174
175
|
}
|
|
175
176
|
}
|
|
176
|
-
}, [
|
|
177
|
+
}, [enableFloatingStyles, floatingStyles, refs.floating, parentWidth]);
|
|
177
178
|
const [inputValue, setInputValue] = useState(getInputValue({
|
|
178
179
|
initialSelectedItem,
|
|
179
180
|
inputValue: '',
|
|
@@ -367,7 +368,7 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
367
368
|
[`${prefix}--list-box--up`]: direction === 'top',
|
|
368
369
|
[`${prefix}--combo-box--warning`]: showWarning,
|
|
369
370
|
[`${prefix}--combo-box--readonly`]: readOnly,
|
|
370
|
-
[`${prefix}--autoalign`]:
|
|
371
|
+
[`${prefix}--autoalign`]: enableFloatingStyles
|
|
371
372
|
});
|
|
372
373
|
const titleClasses = cx(`${prefix}--label`, {
|
|
373
374
|
[`${prefix}--label--disabled`]: disabled
|
|
@@ -437,7 +438,6 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
437
438
|
});
|
|
438
439
|
}
|
|
439
440
|
setHighlightedIndex(indexToHighlight(normalizedInput));
|
|
440
|
-
setCursorPosition(inputValue === null ? 0 : normalizedInput.length);
|
|
441
441
|
},
|
|
442
442
|
onSelectedItemChange(_ref5) {
|
|
443
443
|
let {
|
|
@@ -486,11 +486,6 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
486
486
|
};
|
|
487
487
|
}
|
|
488
488
|
}, [closeMenu, openMenu, reset, selectItem, setHighlightedIndex, downshiftSetInputValue, toggleMenu]);
|
|
489
|
-
useEffect(() => {
|
|
490
|
-
if (inputRef.current) {
|
|
491
|
-
inputRef.current.setSelectionRange(cursorPosition, cursorPosition);
|
|
492
|
-
}
|
|
493
|
-
}, [inputValue, cursorPosition]);
|
|
494
489
|
const buttonProps = getToggleButtonProps({
|
|
495
490
|
disabled: disabled || readOnly,
|
|
496
491
|
onClick: handleToggleClick(isOpen),
|
|
@@ -534,9 +529,8 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
534
529
|
|
|
535
530
|
// Memoize the value of getMenuProps to avoid an infinite loop
|
|
536
531
|
const menuProps = useMemo(() => getMenuProps({
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
}), [autoAlign, deprecatedAriaLabel, ariaLabel, getMenuProps, refs.setFloating]);
|
|
532
|
+
ref: enableFloatingStyles ? refs.setFloating : null
|
|
533
|
+
}), [enableFloatingStyles, deprecatedAriaLabel, ariaLabel, getMenuProps, refs.setFloating]);
|
|
540
534
|
useEffect(() => {
|
|
541
535
|
if (textInput.current) {
|
|
542
536
|
if (inputRef.current && typeaheadText) {
|
|
@@ -564,7 +558,7 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
564
558
|
light: light,
|
|
565
559
|
size: size,
|
|
566
560
|
warn: warn,
|
|
567
|
-
ref:
|
|
561
|
+
ref: enableFloatingStyles ? refs.setReference : null,
|
|
568
562
|
warnText: warnText,
|
|
569
563
|
warnTextId: warnTextId
|
|
570
564
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
@@ -577,11 +571,13 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
577
571
|
"aria-haspopup": "listbox",
|
|
578
572
|
title: textInput?.current?.value
|
|
579
573
|
}, getInputProps({
|
|
574
|
+
'aria-label': titleText ? undefined : deprecatedAriaLabel || ariaLabel,
|
|
580
575
|
'aria-controls': isOpen ? undefined : menuProps.id,
|
|
581
576
|
placeholder,
|
|
582
577
|
value: inputValue,
|
|
583
578
|
onChange: e => {
|
|
584
579
|
const newValue = e.target.value;
|
|
580
|
+
setInputValue(newValue);
|
|
585
581
|
downshiftSetInputValue(newValue);
|
|
586
582
|
},
|
|
587
583
|
ref: mergeRefs(textInput, ref, inputRef),
|
|
@@ -638,7 +634,6 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
638
634
|
if (matchingItem) {
|
|
639
635
|
const newValue = itemToString(matchingItem);
|
|
640
636
|
downshiftSetInputValue(newValue);
|
|
641
|
-
setCursorPosition(newValue.length);
|
|
642
637
|
selectItem(matchingItem);
|
|
643
638
|
}
|
|
644
639
|
}
|
|
@@ -20,6 +20,7 @@ import { useId } from '../../internal/useId.js';
|
|
|
20
20
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
21
21
|
import { flip, size, useFloating, autoUpdate } from '@floating-ui/react';
|
|
22
22
|
import { hide } from '../../node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs.js';
|
|
23
|
+
import { useFeatureFlag } from '../FeatureFlags/index.js';
|
|
23
24
|
import mergeRefs from '../../tools/mergeRefs.js';
|
|
24
25
|
|
|
25
26
|
var _ChevronDown;
|
|
@@ -47,12 +48,18 @@ const ComboButton = /*#__PURE__*/React__default.forwardRef(function ComboButton(
|
|
|
47
48
|
translateWithId: t = defaultTranslateWithId,
|
|
48
49
|
...rest
|
|
49
50
|
} = _ref;
|
|
51
|
+
// feature flag utilized to separate out only the dynamic styles from @floating-ui
|
|
52
|
+
// flag is turned on when collision detection (ie. flip, hide) logic is not desired
|
|
53
|
+
const enableOnlyFloatingStyles = useFeatureFlag('enable-v12-dynamic-floating-styles');
|
|
50
54
|
const id = useId('combobutton');
|
|
51
55
|
const prefix = usePrefix();
|
|
52
56
|
const containerRef = useRef(null);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
let middlewares = [];
|
|
58
|
+
if (!enableOnlyFloatingStyles) {
|
|
59
|
+
middlewares = [flip({
|
|
60
|
+
crossAxis: false
|
|
61
|
+
}), hide()];
|
|
62
|
+
}
|
|
56
63
|
if (menuAlignment === 'bottom' || menuAlignment === 'top') {
|
|
57
64
|
middlewares.push(size({
|
|
58
65
|
apply(_ref2) {
|
|
@@ -28,8 +28,5 @@ interface TableCellProps extends ReactAttr<HTMLTableCellElement> {
|
|
|
28
28
|
*/
|
|
29
29
|
headers?: string;
|
|
30
30
|
}
|
|
31
|
-
declare const TableCell:
|
|
32
|
-
({ children, className, hasSlugHeader, colSpan, ...rest }: TableCellProps): import("react/jsx-runtime").JSX.Element;
|
|
33
|
-
displayName: string;
|
|
34
|
-
};
|
|
31
|
+
declare const TableCell: React.ForwardRefExoticComponent<TableCellProps & React.RefAttributes<HTMLTableCellElement>>;
|
|
35
32
|
export default TableCell;
|
|
@@ -10,7 +10,7 @@ import React__default from 'react';
|
|
|
10
10
|
import cx from 'classnames';
|
|
11
11
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
12
12
|
|
|
13
|
-
const TableCell = _ref => {
|
|
13
|
+
const TableCell = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
14
14
|
let {
|
|
15
15
|
children,
|
|
16
16
|
className,
|
|
@@ -24,9 +24,10 @@ const TableCell = _ref => {
|
|
|
24
24
|
});
|
|
25
25
|
return /*#__PURE__*/React__default.createElement("td", _extends({
|
|
26
26
|
className: tableCellClassNames ? tableCellClassNames : undefined,
|
|
27
|
+
ref: ref,
|
|
27
28
|
colSpan: colSpan
|
|
28
29
|
}, rest), children);
|
|
29
|
-
};
|
|
30
|
+
});
|
|
30
31
|
TableCell.displayName = 'TableCell';
|
|
31
32
|
|
|
32
33
|
export { TableCell as default };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2023
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
declare function useDisclosure(id: any): {
|
|
8
|
+
buttonProps: {
|
|
9
|
+
'aria-controls': any;
|
|
10
|
+
'aria-expanded': boolean;
|
|
11
|
+
onClick(): void;
|
|
12
|
+
};
|
|
13
|
+
contentProps: {
|
|
14
|
+
id: any;
|
|
15
|
+
};
|
|
16
|
+
open: boolean;
|
|
17
|
+
};
|
|
18
|
+
export { useDisclosure };
|
|
@@ -20,6 +20,7 @@ import { FormContext } from '../FluidForm/FormContext.js';
|
|
|
20
20
|
import { useId } from '../../internal/useId.js';
|
|
21
21
|
import { useFloating, size, flip, autoUpdate } from '@floating-ui/react';
|
|
22
22
|
import { hide } from '../../node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs.js';
|
|
23
|
+
import { useFeatureFlag } from '../FeatureFlags/index.js';
|
|
23
24
|
import { ListBoxSize, ListBoxType } from '../ListBox/ListBoxPropTypes.js';
|
|
24
25
|
|
|
25
26
|
const {
|
|
@@ -71,11 +72,12 @@ const Dropdown = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
71
72
|
slug,
|
|
72
73
|
...other
|
|
73
74
|
} = _ref;
|
|
75
|
+
const enableFloatingStyles = useFeatureFlag('enable-v12-dynamic-floating-styles');
|
|
74
76
|
const {
|
|
75
77
|
refs,
|
|
76
78
|
floatingStyles,
|
|
77
79
|
middlewareData
|
|
78
|
-
} = useFloating(autoAlign ? {
|
|
80
|
+
} = useFloating(enableFloatingStyles || autoAlign ? {
|
|
79
81
|
placement: direction,
|
|
80
82
|
// The floating element is positioned relative to its nearest
|
|
81
83
|
// containing block (usually the viewport). It will in many cases also
|
|
@@ -93,12 +95,14 @@ const Dropdown = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
93
95
|
width: `${rects.reference.width}px`
|
|
94
96
|
});
|
|
95
97
|
}
|
|
96
|
-
}), flip(), hide()],
|
|
98
|
+
}), autoAlign && flip(), autoAlign && hide()],
|
|
97
99
|
whileElementsMounted: autoUpdate
|
|
98
|
-
} : {}
|
|
100
|
+
} : {}
|
|
101
|
+
// When autoAlign is turned off & the `enable-v12-dynamic-floating-styles` feature flag is not
|
|
102
|
+
// enabled, floating-ui will not be used
|
|
99
103
|
);
|
|
100
104
|
useEffect(() => {
|
|
101
|
-
if (autoAlign) {
|
|
105
|
+
if (enableFloatingStyles || autoAlign) {
|
|
102
106
|
const updatedFloatingStyles = {
|
|
103
107
|
...floatingStyles,
|
|
104
108
|
visibility: middlewareData.hide?.referenceHidden ? 'hidden' : 'visible'
|
|
@@ -237,9 +241,7 @@ const Dropdown = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
237
241
|
// NOTE: does not prevent click
|
|
238
242
|
evt.preventDefault();
|
|
239
243
|
// focus on the element as per readonly input behavior
|
|
240
|
-
|
|
241
|
-
mergedRef.current.focus();
|
|
242
|
-
}
|
|
244
|
+
mergedRef?.current?.focus();
|
|
243
245
|
},
|
|
244
246
|
onKeyDown: evt => {
|
|
245
247
|
const selectAccessKeys = ['ArrowDown', 'ArrowUp', ' ', 'Enter'];
|
|
@@ -267,7 +269,7 @@ const Dropdown = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
267
269
|
}
|
|
268
270
|
};
|
|
269
271
|
const menuProps = useMemo(() => getMenuProps({
|
|
270
|
-
ref: autoAlign ? refs.setFloating : null
|
|
272
|
+
ref: enableFloatingStyles || autoAlign ? refs.setFloating : null
|
|
271
273
|
}), [autoAlign, getMenuProps, refs.setFloating]);
|
|
272
274
|
|
|
273
275
|
// Slug is always size `mini`
|
|
@@ -292,7 +294,7 @@ const Dropdown = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
292
294
|
warnText: warnText,
|
|
293
295
|
light: light,
|
|
294
296
|
isOpen: isOpen,
|
|
295
|
-
ref: autoAlign ? refs.setReference : null,
|
|
297
|
+
ref: enableFloatingStyles || autoAlign ? refs.setReference : null,
|
|
296
298
|
id: id
|
|
297
299
|
}, invalid && /*#__PURE__*/React__default.createElement(WarningFilled, {
|
|
298
300
|
className: `${prefix}--list-box__invalid-icon`
|
|
@@ -4,8 +4,7 @@
|
|
|
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
|
-
import React from 'react';
|
|
7
|
+
import { ReactElement } from 'react';
|
|
9
8
|
import { ReactAttr } from '../../types/common';
|
|
10
9
|
export interface FileUploaderProps extends ReactAttr<HTMLSpanElement> {
|
|
11
10
|
/**
|
|
@@ -74,93 +73,10 @@ export interface FileUploaderProps extends ReactAttr<HTMLSpanElement> {
|
|
|
74
73
|
*/
|
|
75
74
|
size?: 'sm' | 'small' | 'md' | 'field' | 'lg';
|
|
76
75
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
accept: PropTypes.Requireable<(string | null | undefined)[]>;
|
|
85
|
-
/**
|
|
86
|
-
* Specify the type of the `<FileUploaderButton>`
|
|
87
|
-
*/
|
|
88
|
-
buttonKind: PropTypes.Requireable<string>;
|
|
89
|
-
/**
|
|
90
|
-
* Provide the label text to be read by screen readers when interacting with
|
|
91
|
-
* the `<FileUploaderButton>`
|
|
92
|
-
*/
|
|
93
|
-
buttonLabel: PropTypes.Requireable<string>;
|
|
94
|
-
/**
|
|
95
|
-
* Provide a custom className to be applied to the container node
|
|
96
|
-
*/
|
|
97
|
-
className: PropTypes.Requireable<string>;
|
|
98
|
-
/**
|
|
99
|
-
* Specify whether file input is disabled
|
|
100
|
-
*/
|
|
101
|
-
disabled: PropTypes.Requireable<boolean>;
|
|
102
|
-
/**
|
|
103
|
-
* Specify the status of the File Upload
|
|
104
|
-
*/
|
|
105
|
-
filenameStatus: PropTypes.Validator<string>;
|
|
106
|
-
/**
|
|
107
|
-
* Provide a description for the complete/close icon that can be read by screen readers
|
|
108
|
-
*/
|
|
109
|
-
iconDescription: PropTypes.Requireable<string>;
|
|
110
|
-
/**
|
|
111
|
-
* Specify the description text of this `<FileUploader>`
|
|
112
|
-
*/
|
|
113
|
-
labelDescription: PropTypes.Requireable<string>;
|
|
114
|
-
/**
|
|
115
|
-
* Specify the title text of this `<FileUploader>`
|
|
116
|
-
*/
|
|
117
|
-
labelTitle: PropTypes.Requireable<string>;
|
|
118
|
-
/**
|
|
119
|
-
* Specify if the component should accept multiple files to upload
|
|
120
|
-
*/
|
|
121
|
-
multiple: PropTypes.Requireable<boolean>;
|
|
122
|
-
/**
|
|
123
|
-
* Provide a name for the underlying `<input>` node
|
|
124
|
-
*/
|
|
125
|
-
name: PropTypes.Requireable<string>;
|
|
126
|
-
/**
|
|
127
|
-
* Provide an optional `onChange` hook that is called each time the input is
|
|
128
|
-
* changed
|
|
129
|
-
*/
|
|
130
|
-
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
131
|
-
/**
|
|
132
|
-
* Provide an optional `onClick` hook that is called each time the
|
|
133
|
-
* FileUploader is clicked
|
|
134
|
-
*/
|
|
135
|
-
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
136
|
-
/**
|
|
137
|
-
* Provide an optional `onDelete` hook that is called when an uploaded item
|
|
138
|
-
* is removed
|
|
139
|
-
*/
|
|
140
|
-
onDelete: PropTypes.Requireable<(...args: any[]) => any>;
|
|
141
|
-
/**
|
|
142
|
-
* Specify the size of the FileUploaderButton, from a list of available
|
|
143
|
-
* sizes.
|
|
144
|
-
*/
|
|
145
|
-
size: PropTypes.Requireable<string>;
|
|
146
|
-
};
|
|
147
|
-
static contextType: React.Context<string>;
|
|
148
|
-
state: {
|
|
149
|
-
filenames: string[];
|
|
150
|
-
};
|
|
151
|
-
nodes: HTMLElement[];
|
|
152
|
-
uploaderButton: React.RefObject<HTMLLabelElement>;
|
|
153
|
-
static getDerivedStateFromProps({ filenameStatus }: {
|
|
154
|
-
filenameStatus: any;
|
|
155
|
-
}, state: any): {
|
|
156
|
-
filenameStatus: any;
|
|
157
|
-
prevFilenameStatus: any;
|
|
158
|
-
} | null;
|
|
159
|
-
handleChange: (evt: any) => void;
|
|
160
|
-
handleClick: (evt: any, { index, filenameStatus }: {
|
|
161
|
-
index: any;
|
|
162
|
-
filenameStatus: any;
|
|
163
|
-
}) => void;
|
|
164
|
-
clearFiles: () => void;
|
|
165
|
-
render(): import("react/jsx-runtime").JSX.Element;
|
|
166
|
-
}
|
|
76
|
+
declare const FileUploader: {
|
|
77
|
+
<ItemType>(props: FileUploaderProps): ReactElement;
|
|
78
|
+
propTypes?: any;
|
|
79
|
+
contextTypes?: any;
|
|
80
|
+
defaultProps?: any;
|
|
81
|
+
};
|
|
82
|
+
export default FileUploader;
|