@itwin/itwinui-react 3.0.0-dev.7 → 3.0.0-dev.9
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/CHANGELOG.md +68 -0
- package/cjs/core/Alert/Alert.d.ts +20 -9
- package/cjs/core/Alert/Alert.js +48 -10
- package/cjs/core/ButtonGroup/ButtonGroup.js +41 -36
- package/cjs/core/Buttons/DropdownButton/DropdownButton.js +7 -19
- package/cjs/core/Buttons/IconButton/IconButton.js +27 -44
- package/cjs/core/Buttons/SplitButton/SplitButton.d.ts +4 -4
- package/cjs/core/Buttons/SplitButton/SplitButton.js +54 -29
- package/cjs/core/ColorPicker/ColorInputPanel.js +172 -231
- package/cjs/core/ComboBox/ComboBox.d.ts +2 -2
- package/cjs/core/ComboBox/ComboBox.js +33 -25
- package/cjs/core/ComboBox/ComboBoxEndIcon.js +3 -22
- package/cjs/core/ComboBox/ComboBoxInput.js +29 -21
- package/cjs/core/ComboBox/ComboBoxMenu.d.ts +2 -2
- package/cjs/core/ComboBox/ComboBoxMenu.js +73 -93
- package/cjs/core/ComboBox/ComboBoxMenuItem.d.ts +1 -1
- package/cjs/core/ComboBox/ComboBoxMenuItem.js +8 -6
- package/cjs/core/ComboBox/helpers.d.ts +5 -3
- package/cjs/core/DatePicker/DatePicker.d.ts +30 -8
- package/cjs/core/DatePicker/DatePicker.js +40 -5
- package/cjs/core/Dialog/Dialog.js +10 -16
- package/cjs/core/Dialog/DialogContext.d.ts +3 -4
- package/cjs/core/DropdownMenu/DropdownMenu.d.ts +6 -5
- package/cjs/core/DropdownMenu/DropdownMenu.js +59 -55
- package/cjs/core/ExpandableBlock/ExpandableBlock.d.ts +20 -14
- package/cjs/core/ExpandableBlock/ExpandableBlock.js +38 -15
- package/cjs/core/Header/HeaderDropdownButton.js +1 -2
- package/cjs/core/Header/HeaderSplitButton.js +2 -2
- package/cjs/core/Input/Input.d.ts +4 -0
- package/cjs/core/Input/Input.js +2 -1
- package/cjs/core/InputGrid/InputGrid.d.ts +25 -0
- package/cjs/core/InputGrid/InputGrid.js +39 -0
- package/cjs/core/InputGrid/index.d.ts +3 -0
- package/cjs/core/InputGrid/index.js +15 -0
- package/cjs/core/InputGroup/InputGroup.d.ts +13 -0
- package/cjs/core/InputGroup/InputGroup.js +35 -9
- package/cjs/core/InputWithDecorations/InputWithDecorations.d.ts +39 -0
- package/cjs/core/InputWithDecorations/InputWithDecorations.js +81 -0
- package/cjs/core/InputWithDecorations/index.d.ts +3 -0
- package/cjs/core/InputWithDecorations/index.js +15 -0
- package/cjs/core/Label/Label.d.ts +5 -0
- package/cjs/core/Label/Label.js +2 -0
- package/cjs/core/LabeledInput/LabeledInput.d.ts +22 -16
- package/cjs/core/LabeledInput/LabeledInput.js +52 -29
- package/cjs/core/LabeledSelect/LabeledSelect.d.ts +17 -7
- package/cjs/core/LabeledSelect/LabeledSelect.js +36 -17
- package/cjs/core/LabeledTextarea/LabeledTextarea.d.ts +15 -5
- package/cjs/core/LabeledTextarea/LabeledTextarea.js +12 -45
- package/cjs/core/Menu/Menu.d.ts +1 -1
- package/cjs/core/Menu/Menu.js +2 -2
- package/cjs/core/Menu/MenuDivider.d.ts +2 -1
- package/cjs/core/Menu/MenuDivider.js +1 -1
- package/cjs/core/Menu/MenuItem.d.ts +1 -1
- package/cjs/core/Menu/MenuItem.js +78 -55
- package/cjs/core/Menu/MenuItemSkeleton.d.ts +1 -1
- package/cjs/core/Menu/MenuItemSkeleton.js +0 -1
- package/cjs/core/SearchBox/SearchBox.js +1 -1
- package/cjs/core/Select/Select.d.ts +9 -5
- package/cjs/core/Select/Select.js +81 -99
- package/cjs/core/SideNavigation/SideNavigation.js +2 -0
- package/cjs/core/Slider/Thumb.js +1 -0
- package/cjs/core/StatusMessage/StatusMessage.d.ts +12 -2
- package/cjs/core/StatusMessage/StatusMessage.js +23 -9
- package/cjs/core/Table/SubRowExpander.js +2 -0
- package/cjs/core/Table/columns/actionColumn.js +3 -7
- package/cjs/core/Table/filters/DateRangeFilter/DatePickerInput.d.ts +6 -1
- package/cjs/core/Table/filters/DateRangeFilter/DatePickerInput.js +56 -33
- package/cjs/core/Table/filters/DateRangeFilter/DateRangeFilter.d.ts +2 -0
- package/cjs/core/Table/filters/DateRangeFilter/DateRangeFilter.js +2 -0
- package/cjs/core/Table/filters/FilterToggle.js +3 -2
- package/cjs/core/Textarea/Textarea.d.ts +7 -1
- package/cjs/core/Textarea/Textarea.js +6 -11
- package/cjs/core/ThemeProvider/ThemeProvider.js +1 -1
- package/cjs/core/Tile/Tile.d.ts +139 -15
- package/cjs/core/Tile/Tile.js +128 -38
- package/cjs/core/Toast/Toast.d.ts +12 -4
- package/cjs/core/Toast/Toast.js +20 -4
- package/cjs/core/Tooltip/Tooltip.d.ts +35 -28
- package/cjs/core/Tooltip/Tooltip.js +116 -117
- package/cjs/core/TransferList/TransferList.js +4 -12
- package/cjs/core/index.d.ts +3 -1
- package/cjs/core/index.js +28 -5
- package/cjs/core/utils/components/Icon.d.ts +5 -0
- package/cjs/core/utils/components/Icon.js +8 -1
- package/cjs/core/utils/components/InputContainer.d.ts +4 -5
- package/cjs/core/utils/components/InputContainer.js +21 -37
- package/cjs/core/utils/components/InputFlexContainer.d.ts +1 -0
- package/cjs/core/utils/components/InputFlexContainer.js +3 -1
- package/cjs/core/utils/components/Popover.d.ts +113 -27
- package/cjs/core/utils/components/Popover.js +156 -118
- package/cjs/core/utils/components/Portal.d.ts +27 -0
- package/cjs/core/utils/components/Portal.js +43 -0
- package/cjs/core/utils/components/index.d.ts +1 -0
- package/cjs/core/utils/components/index.js +1 -0
- package/cjs/core/utils/functions/index.d.ts +1 -0
- package/cjs/core/utils/functions/index.js +1 -0
- package/cjs/core/utils/functions/react.d.ts +8 -0
- package/cjs/core/utils/functions/react.js +40 -0
- package/cjs/core/utils/hooks/index.d.ts +1 -1
- package/cjs/core/utils/hooks/index.js +1 -1
- package/cjs/core/utils/hooks/useControlledState.d.ts +13 -0
- package/cjs/core/utils/hooks/useControlledState.js +39 -0
- package/cjs/styles.js +10 -31
- package/esm/core/Alert/Alert.d.ts +20 -9
- package/esm/core/Alert/Alert.js +49 -10
- package/esm/core/ButtonGroup/ButtonGroup.js +41 -36
- package/esm/core/Buttons/DropdownButton/DropdownButton.js +8 -24
- package/esm/core/Buttons/IconButton/IconButton.js +25 -40
- package/esm/core/Buttons/SplitButton/SplitButton.d.ts +4 -4
- package/esm/core/Buttons/SplitButton/SplitButton.js +61 -28
- package/esm/core/ColorPicker/ColorInputPanel.js +173 -232
- package/esm/core/ComboBox/ComboBox.d.ts +2 -2
- package/esm/core/ComboBox/ComboBox.js +34 -25
- package/esm/core/ComboBox/ComboBoxEndIcon.js +4 -25
- package/esm/core/ComboBox/ComboBoxInput.js +22 -21
- package/esm/core/ComboBox/ComboBoxMenu.d.ts +2 -2
- package/esm/core/ComboBox/ComboBoxMenu.js +67 -87
- package/esm/core/ComboBox/ComboBoxMenuItem.d.ts +1 -1
- package/esm/core/ComboBox/ComboBoxMenuItem.js +9 -7
- package/esm/core/ComboBox/helpers.d.ts +5 -3
- package/esm/core/DatePicker/DatePicker.d.ts +30 -8
- package/esm/core/DatePicker/DatePicker.js +25 -5
- package/esm/core/Dialog/Dialog.js +11 -23
- package/esm/core/Dialog/DialogContext.d.ts +3 -4
- package/esm/core/DropdownMenu/DropdownMenu.d.ts +6 -5
- package/esm/core/DropdownMenu/DropdownMenu.js +64 -56
- package/esm/core/ExpandableBlock/ExpandableBlock.d.ts +20 -14
- package/esm/core/ExpandableBlock/ExpandableBlock.js +39 -17
- package/esm/core/Header/HeaderDropdownButton.js +1 -2
- package/esm/core/Header/HeaderSplitButton.js +2 -2
- package/esm/core/Input/Input.d.ts +4 -0
- package/esm/core/Input/Input.js +2 -1
- package/esm/core/InputGrid/InputGrid.d.ts +25 -0
- package/esm/core/InputGrid/InputGrid.js +35 -0
- package/esm/core/InputGrid/index.d.ts +3 -0
- package/esm/core/InputGrid/index.js +6 -0
- package/esm/core/InputGroup/InputGroup.d.ts +13 -0
- package/esm/core/InputGroup/InputGroup.js +34 -10
- package/esm/core/InputWithDecorations/InputWithDecorations.d.ts +39 -0
- package/esm/core/InputWithDecorations/InputWithDecorations.js +80 -0
- package/esm/core/InputWithDecorations/index.d.ts +3 -0
- package/esm/core/InputWithDecorations/index.js +6 -0
- package/esm/core/Label/Label.d.ts +5 -0
- package/esm/core/Label/Label.js +2 -0
- package/esm/core/LabeledInput/LabeledInput.d.ts +22 -16
- package/esm/core/LabeledInput/LabeledInput.js +53 -29
- package/esm/core/LabeledSelect/LabeledSelect.d.ts +17 -7
- package/esm/core/LabeledSelect/LabeledSelect.js +37 -18
- package/esm/core/LabeledTextarea/LabeledTextarea.d.ts +15 -5
- package/esm/core/LabeledTextarea/LabeledTextarea.js +14 -45
- package/esm/core/Menu/Menu.d.ts +1 -1
- package/esm/core/Menu/Menu.js +8 -3
- package/esm/core/Menu/MenuDivider.d.ts +2 -1
- package/esm/core/Menu/MenuDivider.js +1 -1
- package/esm/core/Menu/MenuItem.d.ts +1 -1
- package/esm/core/Menu/MenuItem.js +85 -52
- package/esm/core/Menu/MenuItemSkeleton.d.ts +1 -1
- package/esm/core/Menu/MenuItemSkeleton.js +0 -1
- package/esm/core/SearchBox/SearchBox.js +1 -1
- package/esm/core/Select/Select.d.ts +9 -5
- package/esm/core/Select/Select.js +81 -96
- package/esm/core/SideNavigation/SideNavigation.js +2 -0
- package/esm/core/Slider/Thumb.js +1 -0
- package/esm/core/StatusMessage/StatusMessage.d.ts +12 -2
- package/esm/core/StatusMessage/StatusMessage.js +23 -16
- package/esm/core/Table/SubRowExpander.js +2 -0
- package/esm/core/Table/columns/actionColumn.js +3 -7
- package/esm/core/Table/filters/DateRangeFilter/DatePickerInput.d.ts +6 -1
- package/esm/core/Table/filters/DateRangeFilter/DatePickerInput.js +56 -33
- package/esm/core/Table/filters/DateRangeFilter/DateRangeFilter.d.ts +2 -0
- package/esm/core/Table/filters/DateRangeFilter/DateRangeFilter.js +2 -0
- package/esm/core/Table/filters/FilterToggle.js +3 -2
- package/esm/core/Textarea/Textarea.d.ts +7 -1
- package/esm/core/Textarea/Textarea.js +6 -11
- package/esm/core/ThemeProvider/ThemeProvider.js +4 -3
- package/esm/core/Tile/Tile.d.ts +139 -15
- package/esm/core/Tile/Tile.js +128 -38
- package/esm/core/Toast/Toast.d.ts +12 -4
- package/esm/core/Toast/Toast.js +21 -4
- package/esm/core/Tooltip/Tooltip.d.ts +35 -28
- package/esm/core/Tooltip/Tooltip.js +119 -116
- package/esm/core/TransferList/TransferList.js +4 -9
- package/esm/core/index.d.ts +3 -1
- package/esm/core/index.js +3 -0
- package/esm/core/utils/components/Icon.d.ts +5 -0
- package/esm/core/utils/components/Icon.js +8 -1
- package/esm/core/utils/components/InputContainer.d.ts +4 -5
- package/esm/core/utils/components/InputContainer.js +21 -32
- package/esm/core/utils/components/InputFlexContainer.d.ts +1 -0
- package/esm/core/utils/components/InputFlexContainer.js +3 -1
- package/esm/core/utils/components/Popover.d.ts +113 -27
- package/esm/core/utils/components/Popover.js +175 -118
- package/esm/core/utils/components/Portal.d.ts +27 -0
- package/esm/core/utils/components/Portal.js +36 -0
- package/esm/core/utils/components/index.d.ts +1 -0
- package/esm/core/utils/components/index.js +1 -0
- package/esm/core/utils/functions/index.d.ts +1 -0
- package/esm/core/utils/functions/index.js +1 -0
- package/esm/core/utils/functions/react.d.ts +8 -0
- package/esm/core/utils/functions/react.js +35 -0
- package/esm/core/utils/hooks/index.d.ts +1 -1
- package/esm/core/utils/hooks/index.js +1 -1
- package/esm/core/utils/hooks/useControlledState.d.ts +13 -0
- package/esm/core/utils/hooks/useControlledState.js +34 -0
- package/esm/styles.js +10 -31
- package/package.json +3 -5
- package/styles.css +23 -20
- package/cjs/core/ComboBox/ComboBoxDropdown.d.ts +0 -7
- package/cjs/core/ComboBox/ComboBoxDropdown.js +0 -48
- package/cjs/core/utils/hooks/useUncontrolledState.d.ts +0 -6
- package/cjs/core/utils/hooks/useUncontrolledState.js +0 -18
- package/esm/core/ComboBox/ComboBoxDropdown.d.ts +0 -7
- package/esm/core/ComboBox/ComboBoxDropdown.js +0 -42
- package/esm/core/utils/hooks/useUncontrolledState.d.ts +0 -6
- package/esm/core/utils/hooks/useUncontrolledState.js +0 -13
|
@@ -14,9 +14,9 @@ const helpers_js_1 = require('./helpers.js');
|
|
|
14
14
|
exports.ComboBoxInput = React.forwardRef((props, forwardedRef) => {
|
|
15
15
|
const {
|
|
16
16
|
onKeyDown: onKeyDownProp,
|
|
17
|
-
onFocus: onFocusProp,
|
|
18
17
|
onClick: onClickProp,
|
|
19
18
|
selectTags,
|
|
19
|
+
size,
|
|
20
20
|
...rest
|
|
21
21
|
} = props;
|
|
22
22
|
const {
|
|
@@ -26,13 +26,20 @@ exports.ComboBoxInput = React.forwardRef((props, forwardedRef) => {
|
|
|
26
26
|
enableVirtualization,
|
|
27
27
|
multiple,
|
|
28
28
|
onClickHandler,
|
|
29
|
+
popover,
|
|
30
|
+
show,
|
|
31
|
+
hide,
|
|
29
32
|
} = (0, index_js_2.useSafeContext)(helpers_js_1.ComboBoxStateContext);
|
|
30
33
|
const dispatch = (0, index_js_2.useSafeContext)(
|
|
31
34
|
helpers_js_1.ComboBoxActionContext,
|
|
32
35
|
);
|
|
33
36
|
const { inputRef, menuRef, optionsExtraInfoRef } = (0,
|
|
34
37
|
index_js_2.useSafeContext)(helpers_js_1.ComboBoxRefsContext);
|
|
35
|
-
const refs = (0, index_js_2.useMergedRefs)(
|
|
38
|
+
const refs = (0, index_js_2.useMergedRefs)(
|
|
39
|
+
inputRef,
|
|
40
|
+
popover.refs.setReference,
|
|
41
|
+
forwardedRef,
|
|
42
|
+
);
|
|
36
43
|
const focusedIndexRef = React.useRef(focusedIndex ?? -1);
|
|
37
44
|
React.useEffect(() => {
|
|
38
45
|
focusedIndexRef.current = focusedIndex ?? -1;
|
|
@@ -44,7 +51,6 @@ exports.ComboBoxInput = React.forwardRef((props, forwardedRef) => {
|
|
|
44
51
|
};
|
|
45
52
|
const handleKeyDown = React.useCallback(
|
|
46
53
|
(event) => {
|
|
47
|
-
onKeyDownProp?.(event);
|
|
48
54
|
const length = Object.keys(optionsExtraInfoRef.current).length ?? 0;
|
|
49
55
|
if (event.altKey) {
|
|
50
56
|
return;
|
|
@@ -53,7 +59,7 @@ exports.ComboBoxInput = React.forwardRef((props, forwardedRef) => {
|
|
|
53
59
|
case 'ArrowDown': {
|
|
54
60
|
event.preventDefault();
|
|
55
61
|
if (!isOpen) {
|
|
56
|
-
return
|
|
62
|
+
return show();
|
|
57
63
|
}
|
|
58
64
|
if (length === 0) {
|
|
59
65
|
return;
|
|
@@ -95,7 +101,7 @@ exports.ComboBoxInput = React.forwardRef((props, forwardedRef) => {
|
|
|
95
101
|
case 'ArrowUp': {
|
|
96
102
|
event.preventDefault();
|
|
97
103
|
if (!isOpen) {
|
|
98
|
-
return
|
|
104
|
+
return show();
|
|
99
105
|
}
|
|
100
106
|
if (length === 0) {
|
|
101
107
|
return;
|
|
@@ -139,17 +145,17 @@ exports.ComboBoxInput = React.forwardRef((props, forwardedRef) => {
|
|
|
139
145
|
onClickHandler?.(focusedIndexRef.current);
|
|
140
146
|
}
|
|
141
147
|
} else {
|
|
142
|
-
|
|
148
|
+
show();
|
|
143
149
|
}
|
|
144
150
|
break;
|
|
145
151
|
}
|
|
146
152
|
case 'Escape': {
|
|
147
153
|
event.preventDefault();
|
|
148
|
-
|
|
154
|
+
hide();
|
|
149
155
|
break;
|
|
150
156
|
}
|
|
151
157
|
case 'Tab':
|
|
152
|
-
|
|
158
|
+
hide();
|
|
153
159
|
break;
|
|
154
160
|
}
|
|
155
161
|
},
|
|
@@ -159,22 +165,18 @@ exports.ComboBoxInput = React.forwardRef((props, forwardedRef) => {
|
|
|
159
165
|
isOpen,
|
|
160
166
|
menuRef,
|
|
161
167
|
onClickHandler,
|
|
162
|
-
onKeyDownProp,
|
|
163
168
|
optionsExtraInfoRef,
|
|
169
|
+
show,
|
|
170
|
+
hide,
|
|
164
171
|
],
|
|
165
172
|
);
|
|
166
|
-
const handleFocus = React.useCallback(
|
|
167
|
-
(event) => {
|
|
168
|
-
dispatch({ type: 'open' });
|
|
169
|
-
onFocusProp?.(event);
|
|
170
|
-
},
|
|
171
|
-
[dispatch, onFocusProp],
|
|
172
|
-
);
|
|
173
173
|
const handleClick = React.useCallback(() => {
|
|
174
174
|
if (!isOpen) {
|
|
175
|
-
|
|
175
|
+
show();
|
|
176
|
+
} else {
|
|
177
|
+
hide();
|
|
176
178
|
}
|
|
177
|
-
}, [
|
|
179
|
+
}, [hide, isOpen, show]);
|
|
178
180
|
const [tagContainerWidthRef, tagContainerWidth] = (0,
|
|
179
181
|
index_js_2.useContainerWidth)();
|
|
180
182
|
return React.createElement(
|
|
@@ -182,9 +184,8 @@ exports.ComboBoxInput = React.forwardRef((props, forwardedRef) => {
|
|
|
182
184
|
null,
|
|
183
185
|
React.createElement(index_js_1.Input, {
|
|
184
186
|
ref: refs,
|
|
185
|
-
onKeyDown: handleKeyDown,
|
|
186
187
|
onClick: (0, index_js_2.mergeEventHandlers)(onClickProp, handleClick),
|
|
187
|
-
|
|
188
|
+
'aria-expanded': isOpen,
|
|
188
189
|
'aria-activedescendant':
|
|
189
190
|
isOpen && focusedIndex != undefined && focusedIndex > -1
|
|
190
191
|
? getIdFromIndex(focusedIndex)
|
|
@@ -197,7 +198,14 @@ exports.ComboBoxInput = React.forwardRef((props, forwardedRef) => {
|
|
|
197
198
|
autoCorrect: 'off',
|
|
198
199
|
style: multiple ? { paddingInlineStart: tagContainerWidth + 18 } : {},
|
|
199
200
|
'aria-describedby': multiple ? `${id}-selected-live` : undefined,
|
|
200
|
-
|
|
201
|
+
size: size,
|
|
202
|
+
...popover.getReferenceProps({
|
|
203
|
+
onKeyDown: (0, index_js_2.mergeEventHandlers)(
|
|
204
|
+
onKeyDownProp,
|
|
205
|
+
handleKeyDown,
|
|
206
|
+
),
|
|
207
|
+
...rest,
|
|
208
|
+
}),
|
|
201
209
|
}),
|
|
202
210
|
multiple && selectTags
|
|
203
211
|
? React.createElement(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Menu } from '../Menu/index.js';
|
|
3
3
|
import type { PolymorphicForwardRefComponent } from '../utils/index.js';
|
|
4
|
-
type ComboBoxMenuProps = Omit<React.ComponentPropsWithoutRef<typeof Menu>, 'onClick'> & React.ComponentPropsWithoutRef<'
|
|
5
|
-
export declare const ComboBoxMenu: PolymorphicForwardRefComponent<"
|
|
4
|
+
type ComboBoxMenuProps = Omit<React.ComponentPropsWithoutRef<typeof Menu>, 'onClick'> & React.ComponentPropsWithoutRef<'div'>;
|
|
5
|
+
export declare const ComboBoxMenu: PolymorphicForwardRefComponent<"div", ComboBoxMenuProps>;
|
|
6
6
|
export {};
|
|
@@ -9,113 +9,93 @@ const tslib_1 = require('tslib');
|
|
|
9
9
|
const classnames_1 = tslib_1.__importDefault(require('classnames'));
|
|
10
10
|
const React = tslib_1.__importStar(require('react'));
|
|
11
11
|
const index_js_1 = require('../Menu/index.js');
|
|
12
|
-
const index_js_2 = require('../
|
|
13
|
-
const index_js_3 = require('../utils/index.js');
|
|
12
|
+
const index_js_2 = require('../utils/index.js');
|
|
14
13
|
const helpers_js_1 = require('./helpers.js');
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
14
|
+
const VirtualizedComboBoxMenu = (props) => {
|
|
15
|
+
const { children, ...rest } = props;
|
|
16
|
+
const { filteredOptions, getMenuItem, focusedIndex } = (0,
|
|
17
|
+
index_js_2.useSafeContext)(helpers_js_1.ComboBoxStateContext);
|
|
18
|
+
const { menuRef } = (0, index_js_2.useSafeContext)(
|
|
19
|
+
helpers_js_1.ComboBoxRefsContext,
|
|
20
|
+
);
|
|
21
|
+
const virtualItemRenderer = React.useCallback(
|
|
22
|
+
(index) =>
|
|
23
|
+
filteredOptions.length > 0
|
|
24
|
+
? getMenuItem(filteredOptions[index], index)
|
|
25
|
+
: children, // Here is expected empty state content
|
|
26
|
+
[filteredOptions, getMenuItem, children],
|
|
27
|
+
);
|
|
28
|
+
const focusedVisibleIndex = React.useMemo(() => {
|
|
29
|
+
const currentElement = menuRef.current?.querySelector(
|
|
30
|
+
`[data-iui-index="${focusedIndex}"]`,
|
|
30
31
|
);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return focusedIndex;
|
|
37
|
-
}
|
|
38
|
-
return Number(
|
|
39
|
-
currentElement.getAttribute('data-iui-filtered-index') ?? focusedIndex,
|
|
40
|
-
);
|
|
41
|
-
}, [focusedIndex, menuRef]);
|
|
42
|
-
const { outerProps, innerProps, visibleChildren } = (0,
|
|
43
|
-
index_js_3.useVirtualization)({
|
|
44
|
-
// 'Fool' VirtualScroll by passing length 1
|
|
45
|
-
// whenever there is no elements, to show empty state message
|
|
46
|
-
itemsLength: filteredOptions.length || 1,
|
|
47
|
-
itemRenderer: virtualItemRenderer,
|
|
48
|
-
scrollToIndex: focusedVisibleIndex,
|
|
49
|
-
});
|
|
50
|
-
const surfaceStyles = {
|
|
51
|
-
minInlineSize: minWidth,
|
|
52
|
-
// set as constant because we don't want it shifting when items are unmounted
|
|
53
|
-
maxInlineSize: minWidth,
|
|
54
|
-
// max-height must be on the outermost element for virtual scroll
|
|
55
|
-
maxBlockSize: 'calc((var(--iui-component-height) - 1px) * 8.5)',
|
|
56
|
-
overflowY: isOverflowOverlaySupported() ? 'overlay' : 'auto',
|
|
57
|
-
...style,
|
|
58
|
-
};
|
|
59
|
-
return React.createElement(
|
|
60
|
-
index_js_2.Surface,
|
|
61
|
-
{ style: surfaceStyles },
|
|
62
|
-
React.createElement(
|
|
63
|
-
'div',
|
|
64
|
-
{ ...outerProps },
|
|
65
|
-
React.createElement(
|
|
66
|
-
index_js_1.Menu,
|
|
67
|
-
{
|
|
68
|
-
id: `${id}-list`,
|
|
69
|
-
setFocus: false,
|
|
70
|
-
role: 'listbox',
|
|
71
|
-
ref: (0, index_js_3.mergeRefs)(
|
|
72
|
-
menuRef,
|
|
73
|
-
innerProps.ref,
|
|
74
|
-
forwardedRef,
|
|
75
|
-
),
|
|
76
|
-
className: className,
|
|
77
|
-
style: innerProps.style,
|
|
78
|
-
...rest,
|
|
79
|
-
},
|
|
80
|
-
visibleChildren,
|
|
81
|
-
),
|
|
82
|
-
),
|
|
32
|
+
if (!currentElement) {
|
|
33
|
+
return focusedIndex;
|
|
34
|
+
}
|
|
35
|
+
return Number(
|
|
36
|
+
currentElement.getAttribute('data-iui-filtered-index') ?? focusedIndex,
|
|
83
37
|
);
|
|
84
|
-
},
|
|
85
|
-
|
|
38
|
+
}, [focusedIndex, menuRef]);
|
|
39
|
+
const { outerProps, innerProps, visibleChildren } = (0,
|
|
40
|
+
index_js_2.useVirtualization)({
|
|
41
|
+
// 'Fool' VirtualScroll by passing length 1
|
|
42
|
+
// whenever there is no elements, to show empty state message
|
|
43
|
+
itemsLength: filteredOptions.length || 1,
|
|
44
|
+
itemRenderer: virtualItemRenderer,
|
|
45
|
+
scrollToIndex: focusedVisibleIndex,
|
|
46
|
+
});
|
|
47
|
+
return React.createElement(
|
|
48
|
+
index_js_2.Box,
|
|
49
|
+
{ as: 'div', ...outerProps, ...rest },
|
|
50
|
+
React.createElement(
|
|
51
|
+
'div',
|
|
52
|
+
{ ...innerProps, ref: innerProps.ref },
|
|
53
|
+
visibleChildren,
|
|
54
|
+
),
|
|
55
|
+
);
|
|
56
|
+
};
|
|
86
57
|
exports.ComboBoxMenu = React.forwardRef((props, forwardedRef) => {
|
|
87
|
-
const { className, style, ...rest } = props;
|
|
88
|
-
const {
|
|
58
|
+
const { className, children, style, ...rest } = props;
|
|
59
|
+
const { id, enableVirtualization, popover } = (0, index_js_2.useSafeContext)(
|
|
89
60
|
helpers_js_1.ComboBoxStateContext,
|
|
90
61
|
);
|
|
91
|
-
const { menuRef } = (0,
|
|
62
|
+
const { menuRef } = (0, index_js_2.useSafeContext)(
|
|
92
63
|
helpers_js_1.ComboBoxRefsContext,
|
|
93
64
|
);
|
|
94
|
-
const refs = (0,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
maxInlineSize: `min(${minWidth * 2}px, 90vw)`,
|
|
99
|
-
}),
|
|
100
|
-
[minWidth],
|
|
65
|
+
const refs = (0, index_js_2.useMergedRefs)(
|
|
66
|
+
popover.refs.setFloating,
|
|
67
|
+
forwardedRef,
|
|
68
|
+
menuRef,
|
|
101
69
|
);
|
|
102
|
-
return
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
70
|
+
return (
|
|
71
|
+
popover.open &&
|
|
72
|
+
React.createElement(
|
|
73
|
+
index_js_2.Portal,
|
|
74
|
+
{ portal: true },
|
|
75
|
+
React.createElement(
|
|
76
|
+
index_js_1.Menu,
|
|
77
|
+
{
|
|
107
78
|
id: `${id}-list`,
|
|
108
|
-
style: { ...styles, ...style },
|
|
109
79
|
setFocus: false,
|
|
110
80
|
role: 'listbox',
|
|
111
81
|
ref: refs,
|
|
112
82
|
className: (0, classnames_1.default)('iui-scroll', className),
|
|
113
|
-
...
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
83
|
+
...popover.getFloatingProps({
|
|
84
|
+
style: !enableVirtualization
|
|
85
|
+
? style
|
|
86
|
+
: {
|
|
87
|
+
// set as constant because we don't want it shifting when items are unmounted
|
|
88
|
+
maxInlineSize: 0,
|
|
89
|
+
...style,
|
|
90
|
+
},
|
|
91
|
+
...rest,
|
|
92
|
+
}),
|
|
93
|
+
},
|
|
94
|
+
!enableVirtualization
|
|
95
|
+
? children
|
|
96
|
+
: React.createElement(VirtualizedComboBoxMenu, null, children),
|
|
97
|
+
),
|
|
98
|
+
)
|
|
119
99
|
);
|
|
120
100
|
});
|
|
121
101
|
exports.ComboBoxMenu.displayName = 'ComboBoxMenu';
|
|
@@ -4,5 +4,5 @@ import type { PolymorphicForwardRefComponent } from '../utils/index.js';
|
|
|
4
4
|
type ComboBoxMenuItemProps = MenuItemProps & {
|
|
5
5
|
index: number;
|
|
6
6
|
};
|
|
7
|
-
export declare const ComboBoxMenuItem: React.MemoExoticComponent<PolymorphicForwardRefComponent<"
|
|
7
|
+
export declare const ComboBoxMenuItem: React.MemoExoticComponent<PolymorphicForwardRefComponent<"div", ComboBoxMenuItemProps>>;
|
|
8
8
|
export {};
|
|
@@ -37,6 +37,7 @@ exports.ComboBoxMenuItem = React.memo(
|
|
|
37
37
|
return React.createElement(
|
|
38
38
|
ListItem_js_1.ListItem,
|
|
39
39
|
{
|
|
40
|
+
as: 'div',
|
|
40
41
|
actionable: true,
|
|
41
42
|
size: size,
|
|
42
43
|
active: isSelected,
|
|
@@ -68,12 +69,13 @@ exports.ComboBoxMenuItem = React.memo(
|
|
|
68
69
|
sublabel,
|
|
69
70
|
),
|
|
70
71
|
),
|
|
71
|
-
endIcon
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
endIcon ||
|
|
73
|
+
(isSelected &&
|
|
74
|
+
React.createElement(
|
|
75
|
+
ListItem_js_1.ListItem.Icon,
|
|
76
|
+
{ as: 'span', 'aria-hidden': true },
|
|
77
|
+
endIcon ?? React.createElement(index_js_1.SvgCheckmark, null),
|
|
78
|
+
)),
|
|
77
79
|
);
|
|
78
80
|
}),
|
|
79
81
|
);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { SelectOption } from '../Select/Select.js';
|
|
3
|
+
import type { usePopover } from '../utils/index.js';
|
|
3
4
|
type ComboBoxAction = {
|
|
4
5
|
type: 'multiselect';
|
|
5
6
|
value: number[];
|
|
@@ -25,8 +26,7 @@ export declare const comboBoxReducer: (state: {
|
|
|
25
26
|
};
|
|
26
27
|
export declare const ComboBoxRefsContext: React.Context<{
|
|
27
28
|
inputRef: React.RefObject<HTMLInputElement>;
|
|
28
|
-
menuRef: React.RefObject<
|
|
29
|
-
toggleButtonRef: React.RefObject<HTMLSpanElement>;
|
|
29
|
+
menuRef: React.RefObject<HTMLElement>;
|
|
30
30
|
optionsExtraInfoRef: React.MutableRefObject<Record<string, {
|
|
31
31
|
__originalIndex: number;
|
|
32
32
|
}>>;
|
|
@@ -34,13 +34,15 @@ export declare const ComboBoxRefsContext: React.Context<{
|
|
|
34
34
|
type ComboBoxStateContextProps<T = unknown> = {
|
|
35
35
|
isOpen: boolean;
|
|
36
36
|
id: string;
|
|
37
|
-
minWidth: number;
|
|
38
37
|
enableVirtualization: boolean;
|
|
39
38
|
filteredOptions: SelectOption<T>[];
|
|
40
39
|
onClickHandler?: (prop: number) => void;
|
|
41
40
|
getMenuItem: (option: SelectOption<T>, filteredIndex?: number) => JSX.Element;
|
|
42
41
|
focusedIndex?: number;
|
|
43
42
|
multiple?: boolean;
|
|
43
|
+
popover: ReturnType<typeof usePopover>;
|
|
44
|
+
show: () => void;
|
|
45
|
+
hide: () => void;
|
|
44
46
|
};
|
|
45
47
|
export declare const ComboBoxStateContext: React.Context<ComboBoxStateContextProps<unknown> | undefined>;
|
|
46
48
|
export declare const ComboBoxActionContext: React.Context<((x: ComboBoxAction) => void) | undefined>;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
1
2
|
import type { PolymorphicForwardRefComponent } from '../utils/index.js';
|
|
2
3
|
import type { TimePickerProps } from '../TimePicker/TimePicker.js';
|
|
4
|
+
export type DatePickerLocalizedNames = {
|
|
5
|
+
[key in 'months' | 'shortDays' | 'days']: string[];
|
|
6
|
+
};
|
|
3
7
|
/**
|
|
4
8
|
* Generate localized months and days strings using `Intl.DateTimeFormat` for passed locale to use in DatePicker component.
|
|
5
9
|
* If locale is not passed, browser locale will be used.
|
|
6
10
|
*/
|
|
7
|
-
export declare const generateLocalizedStrings: (locale?: string) =>
|
|
8
|
-
months: string[];
|
|
9
|
-
shortDays: string[];
|
|
10
|
-
days: string[];
|
|
11
|
-
};
|
|
11
|
+
export declare const generateLocalizedStrings: (locale?: string) => DatePickerLocalizedNames;
|
|
12
12
|
export type DateRangePickerProps = {
|
|
13
13
|
/**
|
|
14
14
|
* Enable date range support.
|
|
@@ -42,9 +42,7 @@ type DatePickerProps = {
|
|
|
42
42
|
* Pass localized week days (start from sunday) and months.
|
|
43
43
|
* Use helper function `generateLocalizedStrings` to generate strings using `Intl.DateTimeFormat`.
|
|
44
44
|
*/
|
|
45
|
-
localizedNames?:
|
|
46
|
-
[key in 'months' | 'shortDays' | 'days']: string[];
|
|
47
|
-
};
|
|
45
|
+
localizedNames?: DatePickerLocalizedNames;
|
|
48
46
|
/**
|
|
49
47
|
* Set focus on selected day or today.
|
|
50
48
|
* @default false
|
|
@@ -60,6 +58,30 @@ type DatePickerProps = {
|
|
|
60
58
|
* @default false
|
|
61
59
|
*/
|
|
62
60
|
showYearSelection?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Allows props to be passed for calendar month year, referring to the div that wraps around the month/year and the next/previous buttons.
|
|
63
|
+
*/
|
|
64
|
+
monthYearProps?: React.ComponentProps<'div'>;
|
|
65
|
+
/**
|
|
66
|
+
* Allows props to be passed for only month, referring to span that wraps around the month title.
|
|
67
|
+
*/
|
|
68
|
+
monthProps?: React.ComponentProps<'span'>;
|
|
69
|
+
/**
|
|
70
|
+
* Allows props to be passed for week days, referring to div that wraps around the week day title.
|
|
71
|
+
*/
|
|
72
|
+
weekDayProps?: React.ComponentProps<'div'>;
|
|
73
|
+
/**
|
|
74
|
+
* Allows props to be passed for individual day , referring to div element the wraps around single day number.
|
|
75
|
+
*/
|
|
76
|
+
dayProps?: React.ComponentProps<'div'>;
|
|
77
|
+
/**
|
|
78
|
+
* Allows props to be passed for calendar, referring to div that is used for listbox for wraping days and weeks.
|
|
79
|
+
*/
|
|
80
|
+
calendarProps?: React.ComponentProps<'div'>;
|
|
81
|
+
/**
|
|
82
|
+
* Allows props to be passed for weeks, referring to div that wraps around weeks.
|
|
83
|
+
*/
|
|
84
|
+
weekProps?: React.ComponentProps<'div'>;
|
|
63
85
|
/**
|
|
64
86
|
* Will disable dates for which this function returns true.
|
|
65
87
|
* Disabled dates cannot be selected.
|
|
@@ -139,6 +139,12 @@ exports.DatePicker = React.forwardRef((props, forwardedRef) => {
|
|
|
139
139
|
enableRangeSelect = false,
|
|
140
140
|
startDate,
|
|
141
141
|
endDate,
|
|
142
|
+
monthYearProps,
|
|
143
|
+
calendarProps,
|
|
144
|
+
monthProps,
|
|
145
|
+
weekDayProps,
|
|
146
|
+
dayProps,
|
|
147
|
+
weekProps,
|
|
142
148
|
isDateDisabled,
|
|
143
149
|
...rest
|
|
144
150
|
} = props;
|
|
@@ -420,7 +426,14 @@ exports.DatePicker = React.forwardRef((props, forwardedRef) => {
|
|
|
420
426
|
null,
|
|
421
427
|
React.createElement(
|
|
422
428
|
index_js_1.Box,
|
|
423
|
-
{
|
|
429
|
+
{
|
|
430
|
+
as: 'div',
|
|
431
|
+
...monthYearProps,
|
|
432
|
+
className: (0, classnames_1.default)(
|
|
433
|
+
'iui-calendar-month-year',
|
|
434
|
+
monthYearProps?.className,
|
|
435
|
+
),
|
|
436
|
+
},
|
|
424
437
|
showYearSelection &&
|
|
425
438
|
React.createElement(
|
|
426
439
|
index_js_2.IconButton,
|
|
@@ -449,9 +462,13 @@ exports.DatePicker = React.forwardRef((props, forwardedRef) => {
|
|
|
449
462
|
index_js_1.Box,
|
|
450
463
|
{
|
|
451
464
|
as: 'span',
|
|
452
|
-
className: 'iui-calendar-month',
|
|
453
465
|
id: dateTableId,
|
|
454
466
|
title: monthNames[displayedMonthIndex],
|
|
467
|
+
...monthProps,
|
|
468
|
+
className: (0, classnames_1.default)(
|
|
469
|
+
'iui-calendar-month',
|
|
470
|
+
monthProps?.className,
|
|
471
|
+
),
|
|
455
472
|
},
|
|
456
473
|
monthNames[displayedMonthIndex],
|
|
457
474
|
),
|
|
@@ -482,7 +499,14 @@ exports.DatePicker = React.forwardRef((props, forwardedRef) => {
|
|
|
482
499
|
),
|
|
483
500
|
React.createElement(
|
|
484
501
|
index_js_1.Box,
|
|
485
|
-
{
|
|
502
|
+
{
|
|
503
|
+
as: 'div',
|
|
504
|
+
...weekDayProps,
|
|
505
|
+
className: (0, classnames_1.default)(
|
|
506
|
+
'iui-calendar-weekdays',
|
|
507
|
+
weekDayProps?.className,
|
|
508
|
+
),
|
|
509
|
+
},
|
|
486
510
|
shortDays.map((day, index) =>
|
|
487
511
|
React.createElement('div', { key: day, title: longDays[index] }, day),
|
|
488
512
|
),
|
|
@@ -493,13 +517,19 @@ exports.DatePicker = React.forwardRef((props, forwardedRef) => {
|
|
|
493
517
|
onKeyDown: handleCalendarKeyDown,
|
|
494
518
|
role: 'listbox',
|
|
495
519
|
'aria-labelledby': dateTableId,
|
|
520
|
+
...calendarProps,
|
|
496
521
|
},
|
|
497
522
|
weeks.map((weekDays, weekIndex) => {
|
|
498
523
|
return React.createElement(
|
|
499
524
|
index_js_1.Box,
|
|
500
525
|
{
|
|
526
|
+
as: 'div',
|
|
501
527
|
key: `week-${displayedMonthIndex}-${weekIndex}`,
|
|
502
|
-
|
|
528
|
+
...weekProps,
|
|
529
|
+
className: (0, classnames_1.default)(
|
|
530
|
+
'iui-calendar-week',
|
|
531
|
+
weekProps?.className,
|
|
532
|
+
),
|
|
503
533
|
},
|
|
504
534
|
weekDays.map((weekDay, dayIndex) => {
|
|
505
535
|
const dateValue = weekDay.getDate();
|
|
@@ -507,8 +537,8 @@ exports.DatePicker = React.forwardRef((props, forwardedRef) => {
|
|
|
507
537
|
return React.createElement(
|
|
508
538
|
index_js_1.Box,
|
|
509
539
|
{
|
|
540
|
+
as: 'div',
|
|
510
541
|
key: `day-${displayedMonthIndex}-${dayIndex}`,
|
|
511
|
-
className: getDayClass(weekDay),
|
|
512
542
|
onClick: () => !isDisabled && onDayClick(weekDay),
|
|
513
543
|
role: 'option',
|
|
514
544
|
tabIndex: isSameDay(weekDay, focusedDay) ? 0 : -1,
|
|
@@ -517,6 +547,11 @@ exports.DatePicker = React.forwardRef((props, forwardedRef) => {
|
|
|
517
547
|
isSameDay(weekDay, focusedDay) &&
|
|
518
548
|
needFocus.current &&
|
|
519
549
|
element?.focus(),
|
|
550
|
+
...dayProps,
|
|
551
|
+
className: (0, classnames_1.default)(
|
|
552
|
+
getDayClass(weekDay),
|
|
553
|
+
dayProps?.className,
|
|
554
|
+
),
|
|
520
555
|
},
|
|
521
556
|
dateValue,
|
|
522
557
|
);
|
|
@@ -7,7 +7,6 @@ const tslib_1 = require('tslib');
|
|
|
7
7
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
8
8
|
*--------------------------------------------------------------------------------------------*/
|
|
9
9
|
const React = tslib_1.__importStar(require('react'));
|
|
10
|
-
const ReactDOM = tslib_1.__importStar(require('react-dom'));
|
|
11
10
|
const classnames_1 = tslib_1.__importDefault(require('classnames'));
|
|
12
11
|
const DialogTitleBar_js_1 = require('./DialogTitleBar.js');
|
|
13
12
|
const DialogContent_js_1 = require('./DialogContent.js');
|
|
@@ -35,20 +34,6 @@ const DialogComponent = React.forwardRef((props, ref) => {
|
|
|
35
34
|
...rest
|
|
36
35
|
} = props;
|
|
37
36
|
const dialogRootRef = React.useRef(null);
|
|
38
|
-
const context = (0, index_js_1.useGlobals)();
|
|
39
|
-
const isClient = (0, index_js_1.useIsClient)();
|
|
40
|
-
const portalTo =
|
|
41
|
-
typeof portal !== 'boolean'
|
|
42
|
-
? portal.to
|
|
43
|
-
: portal
|
|
44
|
-
? context?.portalContainer || (0, index_js_1.getDocument)()?.body
|
|
45
|
-
: null;
|
|
46
|
-
const dialog = React.createElement(index_js_1.Box, {
|
|
47
|
-
className: (0, classnames_1.default)('iui-dialog-wrapper', className),
|
|
48
|
-
'data-iui-relative': relativeTo === 'container',
|
|
49
|
-
ref: (0, index_js_1.useMergedRefs)(ref, dialogRootRef),
|
|
50
|
-
...rest,
|
|
51
|
-
});
|
|
52
37
|
return React.createElement(
|
|
53
38
|
DialogContext_js_1.DialogContext.Provider,
|
|
54
39
|
{
|
|
@@ -68,7 +53,16 @@ const DialogComponent = React.forwardRef((props, ref) => {
|
|
|
68
53
|
placement,
|
|
69
54
|
},
|
|
70
55
|
},
|
|
71
|
-
|
|
56
|
+
React.createElement(
|
|
57
|
+
index_js_1.Portal,
|
|
58
|
+
{ portal: portal },
|
|
59
|
+
React.createElement(index_js_1.Box, {
|
|
60
|
+
className: (0, classnames_1.default)('iui-dialog-wrapper', className),
|
|
61
|
+
'data-iui-relative': relativeTo === 'container',
|
|
62
|
+
ref: (0, index_js_1.useMergedRefs)(ref, dialogRootRef),
|
|
63
|
+
...rest,
|
|
64
|
+
}),
|
|
65
|
+
),
|
|
72
66
|
);
|
|
73
67
|
});
|
|
74
68
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import type { PortalProps } from '../utils/index.js';
|
|
2
3
|
export type DialogContextProps = {
|
|
3
4
|
/**
|
|
4
5
|
* Flag whether dialog should be shown.
|
|
@@ -67,11 +68,9 @@ export type DialogContextProps = {
|
|
|
67
68
|
*
|
|
68
69
|
* Can be set to an object with a `to` property to portal into a specific element.
|
|
69
70
|
*
|
|
70
|
-
*
|
|
71
|
+
* Defaults to false if using `Dialog` and true if using `Modal`.
|
|
71
72
|
*/
|
|
72
|
-
portal?:
|
|
73
|
-
to: HTMLElement;
|
|
74
|
-
};
|
|
73
|
+
portal?: PortalProps['portal'];
|
|
75
74
|
/**
|
|
76
75
|
* Dialog root ref. For internal use.
|
|
77
76
|
*/
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { Popover } from '../utils/index.js';
|
|
3
|
+
import type { PolymorphicForwardRefComponent, PortalProps } from '../utils/index.js';
|
|
3
4
|
export type DropdownMenuProps = {
|
|
4
5
|
/**
|
|
5
6
|
* List of menu items. Recommended to use MenuItem component.
|
|
6
7
|
* You can pass function that takes argument `close` that closes the dropdown menu, or a list of MenuItems.
|
|
7
8
|
*/
|
|
8
|
-
menuItems: (close: () => void) => JSX.Element[] | JSX.Element[] | JSX.Element;
|
|
9
|
+
menuItems: ((close: () => void) => JSX.Element[]) | JSX.Element[] | JSX.Element;
|
|
9
10
|
/**
|
|
10
11
|
* ARIA role. Role of menu. For menu use 'menu', for select use 'listbox'.
|
|
11
12
|
* @default 'menu'
|
|
@@ -15,10 +16,10 @@ export type DropdownMenuProps = {
|
|
|
15
16
|
* Child element to wrap dropdown with.
|
|
16
17
|
*/
|
|
17
18
|
children: React.ReactNode;
|
|
18
|
-
} &
|
|
19
|
+
} & Pick<React.ComponentProps<typeof Popover>, 'visible' | 'onVisibleChange' | 'placement' | 'matchWidth'> & React.ComponentPropsWithoutRef<'ul'> & Pick<PortalProps, 'portal'>;
|
|
19
20
|
/**
|
|
20
21
|
* Dropdown menu component.
|
|
21
|
-
*
|
|
22
|
+
* Built on top of the {@link Popover} component.
|
|
22
23
|
* @example
|
|
23
24
|
* const menuItems = (close: () => void) => [
|
|
24
25
|
* <MenuItem key={1} onClick={onClick(1, close)}>
|
|
@@ -35,5 +36,5 @@ export type DropdownMenuProps = {
|
|
|
35
36
|
* <Button>Menu</Button>
|
|
36
37
|
* </DropdownMenu>
|
|
37
38
|
*/
|
|
38
|
-
export declare const DropdownMenu:
|
|
39
|
+
export declare const DropdownMenu: PolymorphicForwardRefComponent<"div", DropdownMenuProps>;
|
|
39
40
|
export default DropdownMenu;
|