@carbon/react 1.68.0 → 1.69.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 +786 -786
- package/README.md +3 -3
- package/es/components/Accordion/AccordionItem.js +0 -1
- package/es/components/Button/Button.js +6 -0
- 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/IdPrefix/index.d.ts +26 -0
- 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/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/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 +2 -10
- package/es/components/Tag/SelectableTag.js +2 -16
- 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/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/IdPrefix/index.d.ts +26 -0
- 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/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/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 +2 -10
- package/lib/components/Tag/SelectableTag.js +2 -16
- 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 +7 -7
- package/telemetry.yml +809 -809
|
@@ -16,7 +16,7 @@ var PropTypes = require('prop-types');
|
|
|
16
16
|
var React = require('react');
|
|
17
17
|
require('../Text/index.js');
|
|
18
18
|
var iconsReact = require('@carbon/icons-react');
|
|
19
|
-
var index = require('../ListBox/index.js');
|
|
19
|
+
var index$1 = require('../ListBox/index.js');
|
|
20
20
|
var ListBoxSelection = require('../ListBox/next/ListBoxSelection.js');
|
|
21
21
|
var ListBoxTrigger = require('../ListBox/next/ListBoxTrigger.js');
|
|
22
22
|
var useId = require('../../internal/useId.js');
|
|
@@ -27,6 +27,7 @@ require('../FluidForm/FluidForm.js');
|
|
|
27
27
|
var FormContext = require('../FluidForm/FormContext.js');
|
|
28
28
|
var react = require('@floating-ui/react');
|
|
29
29
|
var floatingUi_dom = require('../../node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs.js');
|
|
30
|
+
var index = require('../FeatureFlags/index.js');
|
|
30
31
|
var Text = require('../Text/Text.js');
|
|
31
32
|
var match = require('../../internal/keyboard/match.js');
|
|
32
33
|
var ListBoxPropTypes = require('../ListBox/ListBoxPropTypes.js');
|
|
@@ -119,7 +120,6 @@ const findHighlightedIndex = (_ref3, inputValue) => {
|
|
|
119
120
|
*/
|
|
120
121
|
|
|
121
122
|
const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
122
|
-
const [cursorPosition, setCursorPosition] = React.useState(0);
|
|
123
123
|
const prevInputLengthRef = React.useRef(0);
|
|
124
124
|
const inputRef = React.useRef(null);
|
|
125
125
|
const {
|
|
@@ -157,19 +157,20 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
157
157
|
slug,
|
|
158
158
|
...rest
|
|
159
159
|
} = props;
|
|
160
|
+
const enableFloatingStyles = index.useFeatureFlag('enable-v12-dynamic-floating-styles') || autoAlign;
|
|
160
161
|
const {
|
|
161
162
|
refs,
|
|
162
163
|
floatingStyles,
|
|
163
164
|
middlewareData
|
|
164
|
-
} = react.useFloating(
|
|
165
|
+
} = react.useFloating(enableFloatingStyles ? {
|
|
165
166
|
placement: direction,
|
|
166
167
|
strategy: 'fixed',
|
|
167
|
-
middleware: [react.flip(), floatingUi_dom.hide()],
|
|
168
|
+
middleware: autoAlign ? [react.flip(), floatingUi_dom.hide()] : undefined,
|
|
168
169
|
whileElementsMounted: react.autoUpdate
|
|
169
170
|
} : {});
|
|
170
171
|
const parentWidth = refs?.reference?.current?.clientWidth;
|
|
171
172
|
React.useEffect(() => {
|
|
172
|
-
if (
|
|
173
|
+
if (enableFloatingStyles) {
|
|
173
174
|
const updatedFloatingStyles = {
|
|
174
175
|
...floatingStyles,
|
|
175
176
|
visibility: middlewareData.hide?.referenceHidden ? 'hidden' : 'visible'
|
|
@@ -183,7 +184,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
183
184
|
refs.floating.current.style.width = parentWidth + 'px';
|
|
184
185
|
}
|
|
185
186
|
}
|
|
186
|
-
}, [
|
|
187
|
+
}, [enableFloatingStyles, floatingStyles, refs.floating, parentWidth]);
|
|
187
188
|
const [inputValue, setInputValue] = React.useState(getInputValue({
|
|
188
189
|
initialSelectedItem,
|
|
189
190
|
inputValue: '',
|
|
@@ -377,7 +378,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
377
378
|
[`${prefix}--list-box--up`]: direction === 'top',
|
|
378
379
|
[`${prefix}--combo-box--warning`]: showWarning,
|
|
379
380
|
[`${prefix}--combo-box--readonly`]: readOnly,
|
|
380
|
-
[`${prefix}--autoalign`]:
|
|
381
|
+
[`${prefix}--autoalign`]: enableFloatingStyles
|
|
381
382
|
});
|
|
382
383
|
const titleClasses = cx__default["default"](`${prefix}--label`, {
|
|
383
384
|
[`${prefix}--label--disabled`]: disabled
|
|
@@ -447,7 +448,6 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
447
448
|
});
|
|
448
449
|
}
|
|
449
450
|
setHighlightedIndex(indexToHighlight(normalizedInput));
|
|
450
|
-
setCursorPosition(inputValue === null ? 0 : normalizedInput.length);
|
|
451
451
|
},
|
|
452
452
|
onSelectedItemChange(_ref5) {
|
|
453
453
|
let {
|
|
@@ -496,11 +496,6 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
496
496
|
};
|
|
497
497
|
}
|
|
498
498
|
}, [closeMenu, openMenu, reset, selectItem, setHighlightedIndex, downshiftSetInputValue, toggleMenu]);
|
|
499
|
-
React.useEffect(() => {
|
|
500
|
-
if (inputRef.current) {
|
|
501
|
-
inputRef.current.setSelectionRange(cursorPosition, cursorPosition);
|
|
502
|
-
}
|
|
503
|
-
}, [inputValue, cursorPosition]);
|
|
504
499
|
const buttonProps = getToggleButtonProps({
|
|
505
500
|
disabled: disabled || readOnly,
|
|
506
501
|
onClick: handleToggleClick(isOpen),
|
|
@@ -544,9 +539,8 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
544
539
|
|
|
545
540
|
// Memoize the value of getMenuProps to avoid an infinite loop
|
|
546
541
|
const menuProps = React.useMemo(() => getMenuProps({
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
}), [autoAlign, deprecatedAriaLabel, ariaLabel, getMenuProps, refs.setFloating]);
|
|
542
|
+
ref: enableFloatingStyles ? refs.setFloating : null
|
|
543
|
+
}), [enableFloatingStyles, deprecatedAriaLabel, ariaLabel, getMenuProps, refs.setFloating]);
|
|
550
544
|
React.useEffect(() => {
|
|
551
545
|
if (textInput.current) {
|
|
552
546
|
if (inputRef.current && typeaheadText) {
|
|
@@ -562,7 +556,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
562
556
|
}, titleText && /*#__PURE__*/React__default["default"].createElement(Text.Text, _rollupPluginBabelHelpers["extends"]({
|
|
563
557
|
as: "label",
|
|
564
558
|
className: titleClasses
|
|
565
|
-
}, getLabelProps()), titleText), /*#__PURE__*/React__default["default"].createElement(index["default"], {
|
|
559
|
+
}, getLabelProps()), titleText), /*#__PURE__*/React__default["default"].createElement(index$1["default"], {
|
|
566
560
|
onFocus: handleFocus,
|
|
567
561
|
onBlur: handleFocus,
|
|
568
562
|
className: className,
|
|
@@ -574,7 +568,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
574
568
|
light: light,
|
|
575
569
|
size: size,
|
|
576
570
|
warn: warn,
|
|
577
|
-
ref:
|
|
571
|
+
ref: enableFloatingStyles ? refs.setReference : null,
|
|
578
572
|
warnText: warnText,
|
|
579
573
|
warnTextId: warnTextId
|
|
580
574
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -587,11 +581,13 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
587
581
|
"aria-haspopup": "listbox",
|
|
588
582
|
title: textInput?.current?.value
|
|
589
583
|
}, getInputProps({
|
|
584
|
+
'aria-label': titleText ? undefined : deprecatedAriaLabel || ariaLabel,
|
|
590
585
|
'aria-controls': isOpen ? undefined : menuProps.id,
|
|
591
586
|
placeholder,
|
|
592
587
|
value: inputValue,
|
|
593
588
|
onChange: e => {
|
|
594
589
|
const newValue = e.target.value;
|
|
590
|
+
setInputValue(newValue);
|
|
595
591
|
downshiftSetInputValue(newValue);
|
|
596
592
|
},
|
|
597
593
|
ref: mergeRefs["default"](textInput, ref, inputRef),
|
|
@@ -648,7 +644,6 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
648
644
|
if (matchingItem) {
|
|
649
645
|
const newValue = itemToString(matchingItem);
|
|
650
646
|
downshiftSetInputValue(newValue);
|
|
651
|
-
setCursorPosition(newValue.length);
|
|
652
647
|
selectItem(matchingItem);
|
|
653
648
|
}
|
|
654
649
|
}
|
|
@@ -671,12 +666,12 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
671
666
|
}), /*#__PURE__*/React__default["default"].createElement(ListBoxTrigger["default"], _rollupPluginBabelHelpers["extends"]({}, buttonProps, {
|
|
672
667
|
isOpen: isOpen,
|
|
673
668
|
translateWithId: translateWithId
|
|
674
|
-
}))), normalizedSlug, /*#__PURE__*/React__default["default"].createElement(index["default"].Menu, menuProps, isOpen ? filterItems(items, itemToString, inputValue).map((item, index
|
|
669
|
+
}))), normalizedSlug, /*#__PURE__*/React__default["default"].createElement(index$1["default"].Menu, menuProps, isOpen ? filterItems(items, itemToString, inputValue).map((item, index) => {
|
|
675
670
|
const isObject = item !== null && typeof item === 'object';
|
|
676
671
|
const title = isObject && 'text' in item && itemToElement ? item.text?.toString() : itemToString(item);
|
|
677
672
|
const itemProps = getItemProps({
|
|
678
673
|
item,
|
|
679
|
-
index
|
|
674
|
+
index
|
|
680
675
|
});
|
|
681
676
|
|
|
682
677
|
// The initial implementation using <Downshift> would place the disabled attribute
|
|
@@ -689,10 +684,10 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
689
684
|
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
690
685
|
...modifiedItemProps
|
|
691
686
|
} = itemProps;
|
|
692
|
-
return /*#__PURE__*/React__default["default"].createElement(index["default"].MenuItem, _rollupPluginBabelHelpers["extends"]({
|
|
687
|
+
return /*#__PURE__*/React__default["default"].createElement(index$1["default"].MenuItem, _rollupPluginBabelHelpers["extends"]({
|
|
693
688
|
key: itemProps.id,
|
|
694
689
|
isActive: selectedItem === item,
|
|
695
|
-
isHighlighted: highlightedIndex === index
|
|
690
|
+
isHighlighted: highlightedIndex === index,
|
|
696
691
|
title: title,
|
|
697
692
|
disabled: disabled
|
|
698
693
|
}, modifiedItemProps), ItemToElement ? /*#__PURE__*/React__default["default"].createElement(ItemToElement, _rollupPluginBabelHelpers["extends"]({
|
|
@@ -14,7 +14,7 @@ var React = require('react');
|
|
|
14
14
|
var PropTypes = require('prop-types');
|
|
15
15
|
var cx = require('classnames');
|
|
16
16
|
var iconsReact = require('@carbon/icons-react');
|
|
17
|
-
var index = require('../IconButton/index.js');
|
|
17
|
+
var index$1 = require('../IconButton/index.js');
|
|
18
18
|
var Button = require('../Button/Button.js');
|
|
19
19
|
require('../Button/Button.Skeleton.js');
|
|
20
20
|
var Menu = require('../Menu/Menu.js');
|
|
@@ -24,6 +24,7 @@ var useId = require('../../internal/useId.js');
|
|
|
24
24
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
25
25
|
var react = require('@floating-ui/react');
|
|
26
26
|
var floatingUi_dom = require('../../node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs.js');
|
|
27
|
+
var index = require('../FeatureFlags/index.js');
|
|
27
28
|
var mergeRefs = require('../../tools/mergeRefs.js');
|
|
28
29
|
|
|
29
30
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -57,12 +58,18 @@ const ComboButton = /*#__PURE__*/React__default["default"].forwardRef(function C
|
|
|
57
58
|
translateWithId: t = defaultTranslateWithId,
|
|
58
59
|
...rest
|
|
59
60
|
} = _ref;
|
|
61
|
+
// feature flag utilized to separate out only the dynamic styles from @floating-ui
|
|
62
|
+
// flag is turned on when collision detection (ie. flip, hide) logic is not desired
|
|
63
|
+
const enableOnlyFloatingStyles = index.useFeatureFlag('enable-v12-dynamic-floating-styles');
|
|
60
64
|
const id = useId.useId('combobutton');
|
|
61
65
|
const prefix = usePrefix.usePrefix();
|
|
62
66
|
const containerRef = React.useRef(null);
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
67
|
+
let middlewares = [];
|
|
68
|
+
if (!enableOnlyFloatingStyles) {
|
|
69
|
+
middlewares = [react.flip({
|
|
70
|
+
crossAxis: false
|
|
71
|
+
}), floatingUi_dom.hide()];
|
|
72
|
+
}
|
|
66
73
|
if (menuAlignment === 'bottom' || menuAlignment === 'top') {
|
|
67
74
|
middlewares.push(react.size({
|
|
68
75
|
apply(_ref2) {
|
|
@@ -137,7 +144,7 @@ const ComboButton = /*#__PURE__*/React__default["default"].forwardRef(function C
|
|
|
137
144
|
size: size,
|
|
138
145
|
disabled: disabled,
|
|
139
146
|
onClick: handlePrimaryActionClick
|
|
140
|
-
}, label)), /*#__PURE__*/React__default["default"].createElement(index.IconButton, {
|
|
147
|
+
}, label)), /*#__PURE__*/React__default["default"].createElement(index$1.IconButton, {
|
|
141
148
|
ref: refs.setReference,
|
|
142
149
|
className: triggerClasses,
|
|
143
150
|
label: t('carbon.combo-button.additional-actions'),
|
|
@@ -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;
|
|
@@ -19,7 +19,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
19
19
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
20
20
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
21
21
|
|
|
22
|
-
const TableCell = _ref => {
|
|
22
|
+
const TableCell = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
|
|
23
23
|
let {
|
|
24
24
|
children,
|
|
25
25
|
className,
|
|
@@ -33,9 +33,10 @@ const TableCell = _ref => {
|
|
|
33
33
|
});
|
|
34
34
|
return /*#__PURE__*/React__default["default"].createElement("td", _rollupPluginBabelHelpers["extends"]({
|
|
35
35
|
className: tableCellClassNames ? tableCellClassNames : undefined,
|
|
36
|
+
ref: ref,
|
|
36
37
|
colSpan: colSpan
|
|
37
38
|
}, rest), children);
|
|
38
|
-
};
|
|
39
|
+
});
|
|
39
40
|
TableCell.displayName = 'TableCell';
|
|
40
41
|
|
|
41
42
|
exports["default"] = TableCell;
|
|
@@ -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 };
|
|
@@ -15,7 +15,7 @@ var Downshift = require('downshift');
|
|
|
15
15
|
var cx = require('classnames');
|
|
16
16
|
var PropTypes = require('prop-types');
|
|
17
17
|
var iconsReact = require('@carbon/icons-react');
|
|
18
|
-
var index = require('../ListBox/index.js');
|
|
18
|
+
var index$1 = require('../ListBox/index.js');
|
|
19
19
|
var mergeRefs = require('../../tools/mergeRefs.js');
|
|
20
20
|
var deprecate = require('../../prop-types/deprecate.js');
|
|
21
21
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
@@ -24,6 +24,7 @@ var FormContext = require('../FluidForm/FormContext.js');
|
|
|
24
24
|
var useId = require('../../internal/useId.js');
|
|
25
25
|
var react = require('@floating-ui/react');
|
|
26
26
|
var floatingUi_dom = require('../../node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs.js');
|
|
27
|
+
var index = require('../FeatureFlags/index.js');
|
|
27
28
|
var ListBoxPropTypes = require('../ListBox/ListBoxPropTypes.js');
|
|
28
29
|
|
|
29
30
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -81,11 +82,12 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
81
82
|
slug,
|
|
82
83
|
...other
|
|
83
84
|
} = _ref;
|
|
85
|
+
const enableFloatingStyles = index.useFeatureFlag('enable-v12-dynamic-floating-styles');
|
|
84
86
|
const {
|
|
85
87
|
refs,
|
|
86
88
|
floatingStyles,
|
|
87
89
|
middlewareData
|
|
88
|
-
} = react.useFloating(autoAlign ? {
|
|
90
|
+
} = react.useFloating(enableFloatingStyles || autoAlign ? {
|
|
89
91
|
placement: direction,
|
|
90
92
|
// The floating element is positioned relative to its nearest
|
|
91
93
|
// containing block (usually the viewport). It will in many cases also
|
|
@@ -103,12 +105,14 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
103
105
|
width: `${rects.reference.width}px`
|
|
104
106
|
});
|
|
105
107
|
}
|
|
106
|
-
}), react.flip(), floatingUi_dom.hide()],
|
|
108
|
+
}), autoAlign && react.flip(), autoAlign && floatingUi_dom.hide()],
|
|
107
109
|
whileElementsMounted: react.autoUpdate
|
|
108
|
-
} : {}
|
|
110
|
+
} : {}
|
|
111
|
+
// When autoAlign is turned off & the `enable-v12-dynamic-floating-styles` feature flag is not
|
|
112
|
+
// enabled, floating-ui will not be used
|
|
109
113
|
);
|
|
110
114
|
React.useEffect(() => {
|
|
111
|
-
if (autoAlign) {
|
|
115
|
+
if (enableFloatingStyles || autoAlign) {
|
|
112
116
|
const updatedFloatingStyles = {
|
|
113
117
|
...floatingStyles,
|
|
114
118
|
visibility: middlewareData.hide?.referenceHidden ? 'hidden' : 'visible'
|
|
@@ -247,9 +251,7 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
247
251
|
// NOTE: does not prevent click
|
|
248
252
|
evt.preventDefault();
|
|
249
253
|
// focus on the element as per readonly input behavior
|
|
250
|
-
|
|
251
|
-
mergedRef.current.focus();
|
|
252
|
-
}
|
|
254
|
+
mergedRef?.current?.focus();
|
|
253
255
|
},
|
|
254
256
|
onKeyDown: evt => {
|
|
255
257
|
const selectAccessKeys = ['ArrowDown', 'ArrowUp', ' ', 'Enter'];
|
|
@@ -277,7 +279,7 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
277
279
|
}
|
|
278
280
|
};
|
|
279
281
|
const menuProps = React.useMemo(() => getMenuProps({
|
|
280
|
-
ref: autoAlign ? refs.setFloating : null
|
|
282
|
+
ref: enableFloatingStyles || autoAlign ? refs.setFloating : null
|
|
281
283
|
}), [autoAlign, getMenuProps, refs.setFloating]);
|
|
282
284
|
|
|
283
285
|
// Slug is always size `mini`
|
|
@@ -291,7 +293,7 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
291
293
|
className: wrapperClasses
|
|
292
294
|
}, other), titleText && /*#__PURE__*/React__default["default"].createElement("label", _rollupPluginBabelHelpers["extends"]({
|
|
293
295
|
className: titleClasses
|
|
294
|
-
}, getLabelProps()), titleText), /*#__PURE__*/React__default["default"].createElement(index["default"], {
|
|
296
|
+
}, getLabelProps()), titleText), /*#__PURE__*/React__default["default"].createElement(index$1["default"], {
|
|
295
297
|
onFocus: handleFocus,
|
|
296
298
|
onBlur: handleFocus,
|
|
297
299
|
size: size,
|
|
@@ -302,7 +304,7 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
302
304
|
warnText: warnText,
|
|
303
305
|
light: light,
|
|
304
306
|
isOpen: isOpen,
|
|
305
|
-
ref: autoAlign ? refs.setReference : null,
|
|
307
|
+
ref: enableFloatingStyles || autoAlign ? refs.setReference : null,
|
|
306
308
|
id: id
|
|
307
309
|
}, invalid && /*#__PURE__*/React__default["default"].createElement(iconsReact.WarningFilled, {
|
|
308
310
|
className: `${prefix}--list-box__invalid-icon`
|
|
@@ -322,23 +324,23 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
322
324
|
ref: mergedRef
|
|
323
325
|
}), /*#__PURE__*/React__default["default"].createElement("span", {
|
|
324
326
|
className: `${prefix}--list-box__label`
|
|
325
|
-
}, selectedItem ? renderSelectedItem ? renderSelectedItem(selectedItem) : itemToString(selectedItem) : label), /*#__PURE__*/React__default["default"].createElement(index["default"].MenuIcon, {
|
|
327
|
+
}, selectedItem ? renderSelectedItem ? renderSelectedItem(selectedItem) : itemToString(selectedItem) : label), /*#__PURE__*/React__default["default"].createElement(index$1["default"].MenuIcon, {
|
|
326
328
|
isOpen: isOpen,
|
|
327
329
|
translateWithId: translateWithId
|
|
328
|
-
})), normalizedSlug, /*#__PURE__*/React__default["default"].createElement(index["default"].Menu, menuProps, isOpen && items.map((item, index
|
|
330
|
+
})), normalizedSlug, /*#__PURE__*/React__default["default"].createElement(index$1["default"].Menu, menuProps, isOpen && items.map((item, index) => {
|
|
329
331
|
const isObject = item !== null && typeof item === 'object';
|
|
330
332
|
const itemProps = getItemProps({
|
|
331
333
|
item,
|
|
332
|
-
index
|
|
334
|
+
index
|
|
333
335
|
});
|
|
334
336
|
if (item !== null && typeof item === 'object' && Object.prototype.hasOwnProperty.call(item, 'id')) {
|
|
335
337
|
itemProps.id = item['id'];
|
|
336
338
|
}
|
|
337
339
|
const title = isObject && 'text' in item && itemToElement ? item.text : itemToString(item);
|
|
338
|
-
return /*#__PURE__*/React__default["default"].createElement(index["default"].MenuItem, _rollupPluginBabelHelpers["extends"]({
|
|
340
|
+
return /*#__PURE__*/React__default["default"].createElement(index$1["default"].MenuItem, _rollupPluginBabelHelpers["extends"]({
|
|
339
341
|
key: itemProps.id,
|
|
340
342
|
isActive: selectedItem === item,
|
|
341
|
-
isHighlighted: highlightedIndex === index
|
|
343
|
+
isHighlighted: highlightedIndex === index,
|
|
342
344
|
title: title,
|
|
343
345
|
disabled: itemProps['aria-disabled']
|
|
344
346
|
}, itemProps), typeof item === 'object' && ItemToElement !== undefined && ItemToElement !== null ? /*#__PURE__*/React__default["default"].createElement(ItemToElement, _rollupPluginBabelHelpers["extends"]({
|
|
@@ -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;
|