rsuite 5.49.0 → 5.51.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/CHANGELOG.md +24 -0
- package/Cascader/styles/index.less +4 -4
- package/CheckTreePicker/styles/index.less +3 -3
- package/DatePicker/styles/index.less +1 -1
- package/DateRangePicker/styles/index.less +15 -5
- package/Dropdown/styles/index.less +5 -4
- package/Dropdown/styles/mixin.less +0 -11
- package/Form/styles/mixin.less +1 -2
- package/InputGroup/styles/index.less +0 -14
- package/InputPicker/styles/index.less +1 -1
- package/Picker/styles/index.less +33 -26
- package/Picker/styles/mixin.less +20 -16
- package/README.md +4 -4
- package/TagInput/styles/index.less +2 -2
- package/TagPicker/styles/index.less +5 -1
- package/TreePicker/styles/index.less +2 -2
- package/cjs/@types/common.d.ts +8 -0
- package/cjs/AutoComplete/AutoComplete.js +39 -37
- package/cjs/AutoComplete/Combobox.d.ts +8 -0
- package/cjs/AutoComplete/Combobox.js +31 -0
- package/cjs/Calendar/Calendar.d.ts +5 -1
- package/cjs/Calendar/CalendarContainer.d.ts +5 -1
- package/cjs/Calendar/CalendarContainer.js +35 -37
- package/cjs/Cascader/Cascader.js +58 -59
- package/cjs/Cascader/DropdownMenu.d.ts +3 -20
- package/cjs/Cascader/DropdownMenu.js +48 -48
- package/cjs/Cascader/TreeView.d.ts +24 -0
- package/cjs/Cascader/TreeView.js +174 -0
- package/cjs/CheckPicker/CheckPicker.d.ts +2 -2
- package/cjs/CheckPicker/CheckPicker.js +42 -44
- package/cjs/CheckTreePicker/CheckTreeNode.d.ts +2 -2
- package/cjs/CheckTreePicker/CheckTreeNode.js +31 -59
- package/cjs/CheckTreePicker/CheckTreePicker.js +81 -84
- package/cjs/DatePicker/DatePicker.d.ts +5 -1
- package/cjs/DatePicker/DatePicker.js +7 -10
- package/cjs/DatePicker/Toolbar.js +2 -1
- package/cjs/DateRangeInput/DateRangeInput.js +2 -2
- package/cjs/DateRangePicker/Calendar.js +24 -23
- package/cjs/DateRangePicker/DateRangePicker.d.ts +18 -4
- package/cjs/DateRangePicker/DateRangePicker.js +239 -202
- package/cjs/DateRangePicker/types.d.ts +11 -3
- package/cjs/DateRangePicker/utils.d.ts +2 -1
- package/cjs/DateRangePicker/utils.js +7 -5
- package/cjs/Form/Form.d.ts +14 -0
- package/cjs/Form/Form.js +39 -30
- package/cjs/Form/FormContext.d.ts +1 -0
- package/cjs/FormControl/FormControl.d.ts +11 -1
- package/cjs/FormControl/FormControl.js +40 -17
- package/cjs/FormGroup/FormGroup.js +2 -1
- package/cjs/InputPicker/InputPicker.js +108 -92
- package/cjs/InputPicker/InputSearch.js +3 -15
- package/cjs/InputPicker/TagList.d.ts +3 -0
- package/cjs/InputPicker/TagList.js +29 -0
- package/cjs/InputPicker/TextBox.d.ts +18 -0
- package/cjs/InputPicker/TextBox.js +48 -0
- package/cjs/MultiCascader/MultiCascader.js +53 -52
- package/cjs/MultiCascader/{DropdownMenu.d.ts → TreeView.d.ts} +3 -3
- package/cjs/MultiCascader/{DropdownMenu.js → TreeView.js} +77 -74
- package/{esm/Picker/DropdownMenuCheckItem.d.ts → cjs/Picker/ListCheckItem.d.ts} +3 -3
- package/cjs/Picker/{DropdownMenuCheckItem.js → ListCheckItem.js} +14 -30
- package/cjs/Picker/{DropdownMenuItem.d.ts → ListItem.d.ts} +4 -4
- package/cjs/Picker/{DropdownMenuItem.js → ListItem.js} +15 -24
- package/cjs/Picker/ListItemGroup.d.ts +6 -0
- package/cjs/Picker/{DropdownMenuGroup.js → ListItemGroup.js} +3 -9
- package/cjs/Picker/Listbox.d.ts +35 -0
- package/cjs/Picker/{DropdownMenu.js → Listbox.js} +49 -64
- package/cjs/{DatePicker → Picker}/PickerIndicator.d.ts +1 -1
- package/cjs/{DatePicker → Picker}/PickerIndicator.js +2 -1
- package/cjs/{DatePicker → Picker}/PickerLabel.d.ts +1 -1
- package/cjs/Picker/{PickerOverlay.d.ts → PickerPopup.d.ts} +3 -3
- package/cjs/Picker/{PickerOverlay.js → PickerPopup.js} +9 -7
- package/cjs/Picker/PickerToggle.d.ts +17 -22
- package/cjs/Picker/PickerToggle.js +63 -181
- package/cjs/Picker/PickerToggleTrigger.d.ts +15 -0
- package/cjs/Picker/PickerToggleTrigger.js +21 -5
- package/cjs/Picker/SearchBar.js +7 -9
- package/cjs/Picker/TreeView.d.ts +7 -0
- package/cjs/Picker/TreeView.js +31 -0
- package/cjs/Picker/hooks/index.d.ts +6 -0
- package/cjs/Picker/hooks/index.js +18 -0
- package/cjs/Picker/hooks/useCombobox.d.ts +7 -0
- package/cjs/Picker/hooks/useCombobox.js +22 -0
- package/cjs/Picker/hooks/useFocusItemValue.d.ts +30 -0
- package/cjs/Picker/hooks/useFocusItemValue.js +246 -0
- package/cjs/Picker/hooks/usePickerClassName.d.ts +21 -0
- package/cjs/Picker/hooks/usePickerClassName.js +39 -0
- package/cjs/Picker/{usePickerRef.d.ts → hooks/usePickerRef.d.ts} +5 -3
- package/cjs/Picker/{usePickerRef.js → hooks/usePickerRef.js} +13 -7
- package/cjs/Picker/hooks/useSearch.d.ts +18 -0
- package/cjs/Picker/hooks/useSearch.js +57 -0
- package/cjs/Picker/hooks/useToggleKeyDownEvent.d.ts +25 -0
- package/cjs/Picker/hooks/useToggleKeyDownEvent.js +101 -0
- package/cjs/Picker/index.d.ts +9 -5
- package/cjs/Picker/index.js +32 -16
- package/cjs/Picker/propTypes.d.ts +0 -6
- package/cjs/Picker/propTypes.js +0 -5
- package/cjs/Picker/utils.d.ts +2 -100
- package/cjs/Picker/utils.js +1 -473
- package/cjs/SelectPicker/SelectPicker.d.ts +2 -2
- package/cjs/SelectPicker/SelectPicker.js +47 -50
- package/cjs/TagInput/index.js +4 -0
- package/cjs/TreePicker/TreeNode.d.ts +2 -2
- package/cjs/TreePicker/TreeNode.js +22 -56
- package/cjs/TreePicker/TreePicker.js +91 -95
- package/cjs/utils/constants.d.ts +2 -1
- package/cjs/utils/constants.js +1 -0
- package/cjs/utils/dateUtils.d.ts +0 -1
- package/cjs/utils/dateUtils.js +0 -6
- package/cjs/utils/getStringLength.d.ts +2 -0
- package/cjs/utils/getStringLength.js +18 -0
- package/cjs/utils/index.d.ts +1 -0
- package/cjs/utils/index.js +4 -1
- package/dist/rsuite-no-reset-rtl.css +201 -186
- package/dist/rsuite-no-reset-rtl.min.css +1 -1
- package/dist/rsuite-no-reset-rtl.min.css.map +1 -1
- package/dist/rsuite-no-reset.css +201 -186
- package/dist/rsuite-no-reset.min.css +1 -1
- package/dist/rsuite-no-reset.min.css.map +1 -1
- package/dist/rsuite-rtl.css +201 -186
- package/dist/rsuite-rtl.min.css +1 -1
- package/dist/rsuite-rtl.min.css.map +1 -1
- package/dist/rsuite.css +201 -186
- package/dist/rsuite.js +235 -104
- package/dist/rsuite.js.map +1 -1
- package/dist/rsuite.min.css +1 -1
- package/dist/rsuite.min.css.map +1 -1
- package/dist/rsuite.min.js +1 -1
- package/dist/rsuite.min.js.map +1 -1
- package/esm/@types/common.d.ts +8 -0
- package/esm/AutoComplete/AutoComplete.js +42 -40
- package/esm/AutoComplete/Combobox.d.ts +8 -0
- package/esm/AutoComplete/Combobox.js +25 -0
- package/esm/Calendar/Calendar.d.ts +5 -1
- package/esm/Calendar/CalendarContainer.d.ts +5 -1
- package/esm/Calendar/CalendarContainer.js +37 -39
- package/esm/Cascader/Cascader.js +61 -62
- package/esm/Cascader/DropdownMenu.d.ts +3 -20
- package/esm/Cascader/DropdownMenu.js +50 -49
- package/esm/Cascader/TreeView.d.ts +24 -0
- package/esm/Cascader/TreeView.js +167 -0
- package/esm/CheckPicker/CheckPicker.d.ts +2 -2
- package/esm/CheckPicker/CheckPicker.js +45 -47
- package/esm/CheckTreePicker/CheckTreeNode.d.ts +2 -2
- package/esm/CheckTreePicker/CheckTreeNode.js +33 -61
- package/esm/CheckTreePicker/CheckTreePicker.js +84 -87
- package/esm/DatePicker/DatePicker.d.ts +5 -1
- package/esm/DatePicker/DatePicker.js +5 -8
- package/esm/DatePicker/Toolbar.js +2 -1
- package/esm/DateRangeInput/DateRangeInput.js +2 -2
- package/esm/DateRangePicker/Calendar.js +25 -23
- package/esm/DateRangePicker/DateRangePicker.d.ts +18 -4
- package/esm/DateRangePicker/DateRangePicker.js +241 -204
- package/esm/DateRangePicker/types.d.ts +11 -3
- package/esm/DateRangePicker/utils.d.ts +2 -1
- package/esm/DateRangePicker/utils.js +7 -5
- package/esm/Form/Form.d.ts +14 -0
- package/esm/Form/Form.js +41 -32
- package/esm/Form/FormContext.d.ts +1 -0
- package/esm/FormControl/FormControl.d.ts +11 -1
- package/esm/FormControl/FormControl.js +41 -18
- package/esm/FormGroup/FormGroup.js +3 -2
- package/esm/InputPicker/InputPicker.js +110 -94
- package/esm/InputPicker/InputSearch.js +4 -15
- package/esm/InputPicker/TagList.d.ts +3 -0
- package/esm/InputPicker/TagList.js +23 -0
- package/esm/InputPicker/TextBox.d.ts +18 -0
- package/esm/InputPicker/TextBox.js +42 -0
- package/esm/MultiCascader/MultiCascader.js +56 -55
- package/esm/MultiCascader/{DropdownMenu.d.ts → TreeView.d.ts} +3 -3
- package/esm/MultiCascader/{DropdownMenu.js → TreeView.js} +79 -75
- package/{cjs/Picker/DropdownMenuCheckItem.d.ts → esm/Picker/ListCheckItem.d.ts} +3 -3
- package/esm/Picker/{DropdownMenuCheckItem.js → ListCheckItem.js} +15 -30
- package/esm/Picker/{DropdownMenuItem.d.ts → ListItem.d.ts} +4 -4
- package/esm/Picker/{DropdownMenuItem.js → ListItem.js} +16 -24
- package/esm/Picker/ListItemGroup.d.ts +6 -0
- package/esm/Picker/{DropdownMenuGroup.js → ListItemGroup.js} +3 -9
- package/esm/Picker/Listbox.d.ts +35 -0
- package/esm/Picker/{DropdownMenu.js → Listbox.js} +50 -64
- package/esm/{DatePicker → Picker}/PickerIndicator.d.ts +1 -1
- package/esm/{DatePicker → Picker}/PickerIndicator.js +2 -1
- package/esm/{DatePicker → Picker}/PickerLabel.d.ts +1 -1
- package/esm/Picker/{PickerOverlay.d.ts → PickerPopup.d.ts} +3 -3
- package/esm/Picker/{PickerOverlay.js → PickerPopup.js} +10 -8
- package/esm/Picker/PickerToggle.d.ts +17 -22
- package/esm/Picker/PickerToggle.js +65 -183
- package/esm/Picker/PickerToggleTrigger.d.ts +15 -0
- package/esm/Picker/PickerToggleTrigger.js +20 -5
- package/esm/Picker/SearchBar.js +8 -9
- package/esm/Picker/TreeView.d.ts +7 -0
- package/esm/Picker/TreeView.js +25 -0
- package/esm/Picker/hooks/index.d.ts +6 -0
- package/esm/Picker/hooks/index.js +7 -0
- package/esm/Picker/hooks/useCombobox.d.ts +7 -0
- package/esm/Picker/hooks/useCombobox.js +17 -0
- package/esm/Picker/hooks/useFocusItemValue.d.ts +30 -0
- package/esm/Picker/hooks/useFocusItemValue.js +240 -0
- package/esm/Picker/hooks/usePickerClassName.d.ts +21 -0
- package/esm/Picker/hooks/usePickerClassName.js +33 -0
- package/esm/Picker/{usePickerRef.d.ts → hooks/usePickerRef.d.ts} +5 -3
- package/esm/Picker/{usePickerRef.js → hooks/usePickerRef.js} +13 -8
- package/esm/Picker/hooks/useSearch.d.ts +18 -0
- package/esm/Picker/hooks/useSearch.js +51 -0
- package/esm/Picker/hooks/useToggleKeyDownEvent.d.ts +25 -0
- package/esm/Picker/hooks/useToggleKeyDownEvent.js +96 -0
- package/esm/Picker/index.d.ts +9 -5
- package/esm/Picker/index.js +9 -5
- package/esm/Picker/propTypes.d.ts +0 -6
- package/esm/Picker/propTypes.js +0 -5
- package/esm/Picker/utils.d.ts +2 -100
- package/esm/Picker/utils.js +2 -467
- package/esm/SelectPicker/SelectPicker.d.ts +2 -2
- package/esm/SelectPicker/SelectPicker.js +50 -53
- package/esm/TagInput/index.js +4 -0
- package/esm/TreePicker/TreeNode.d.ts +2 -2
- package/esm/TreePicker/TreeNode.js +24 -58
- package/esm/TreePicker/TreePicker.js +94 -98
- package/esm/utils/constants.d.ts +2 -1
- package/esm/utils/constants.js +1 -0
- package/esm/utils/dateUtils.d.ts +0 -1
- package/esm/utils/dateUtils.js +0 -5
- package/esm/utils/getStringLength.d.ts +2 -0
- package/esm/utils/getStringLength.js +13 -0
- package/esm/utils/index.d.ts +1 -0
- package/esm/utils/index.js +1 -0
- package/package.json +1 -1
- package/styles/mixins/combobox.less +10 -0
- package/styles/variables.less +1 -3
- package/cjs/Picker/DropdownMenu.d.ts +0 -59
- package/cjs/Picker/DropdownMenuGroup.d.ts +0 -6
- package/esm/Picker/DropdownMenu.d.ts +0 -59
- package/esm/Picker/DropdownMenuGroup.d.ts +0 -6
- /package/cjs/{DatePicker → Picker}/PickerLabel.js +0 -0
- /package/esm/{DatePicker → Picker}/PickerLabel.js +0 -0
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
3
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
4
|
-
import React
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
var
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { useClassNames, useEventCallback } from '../utils';
|
|
6
|
+
import useCombobox from './hooks/useCombobox';
|
|
7
|
+
var ListItem = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
8
8
|
var _props$as = props.as,
|
|
9
9
|
Component = _props$as === void 0 ? 'div' : _props$as,
|
|
10
|
-
|
|
10
|
+
_props$role = props.role,
|
|
11
|
+
role = _props$role === void 0 ? 'option' : _props$role,
|
|
11
12
|
_props$classPrefix = props.classPrefix,
|
|
12
13
|
classPrefix = _props$classPrefix === void 0 ? 'dropdown-menu-item' : _props$classPrefix,
|
|
14
|
+
active = props.active,
|
|
13
15
|
children = props.children,
|
|
14
16
|
className = props.className,
|
|
15
17
|
disabled = props.disabled,
|
|
@@ -18,13 +20,15 @@ var DropdownMenuItem = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
18
20
|
onKeyDown = props.onKeyDown,
|
|
19
21
|
onSelect = props.onSelect,
|
|
20
22
|
renderItem = props.renderItem,
|
|
21
|
-
rest = _objectWithoutPropertiesLoose(props, ["as", "
|
|
22
|
-
var
|
|
23
|
+
rest = _objectWithoutPropertiesLoose(props, ["as", "role", "classPrefix", "active", "children", "className", "disabled", "focus", "value", "onKeyDown", "onSelect", "renderItem"]);
|
|
24
|
+
var _useCombobox = useCombobox(),
|
|
25
|
+
id = _useCombobox.id;
|
|
26
|
+
var handleClick = useEventCallback(function (event) {
|
|
23
27
|
event.preventDefault();
|
|
24
28
|
if (!disabled) {
|
|
25
29
|
onSelect === null || onSelect === void 0 ? void 0 : onSelect(value, event);
|
|
26
30
|
}
|
|
27
|
-
}
|
|
31
|
+
});
|
|
28
32
|
var _useClassNames = useClassNames(classPrefix),
|
|
29
33
|
withClassPrefix = _useClassNames.withClassPrefix;
|
|
30
34
|
var classes = withClassPrefix({
|
|
@@ -33,9 +37,10 @@ var DropdownMenuItem = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
33
37
|
disabled: disabled
|
|
34
38
|
});
|
|
35
39
|
return /*#__PURE__*/React.createElement(Component, _extends({
|
|
36
|
-
role:
|
|
40
|
+
role: role,
|
|
37
41
|
"aria-selected": active,
|
|
38
42
|
"aria-disabled": disabled,
|
|
43
|
+
id: id ? id + "-opt-" + value : undefined,
|
|
39
44
|
"data-key": value
|
|
40
45
|
}, rest, {
|
|
41
46
|
ref: ref,
|
|
@@ -47,18 +52,5 @@ var DropdownMenuItem = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
47
52
|
className: classes
|
|
48
53
|
}, renderItem ? renderItem(value) : children));
|
|
49
54
|
});
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
classPrefix: PropTypes.string,
|
|
53
|
-
active: PropTypes.bool,
|
|
54
|
-
disabled: PropTypes.bool,
|
|
55
|
-
value: PropTypes.any,
|
|
56
|
-
onSelect: PropTypes.func,
|
|
57
|
-
onKeyDown: PropTypes.func,
|
|
58
|
-
focus: PropTypes.bool,
|
|
59
|
-
title: PropTypes.string,
|
|
60
|
-
className: PropTypes.string,
|
|
61
|
-
children: PropTypes.node,
|
|
62
|
-
as: PropTypes.elementType
|
|
63
|
-
};
|
|
64
|
-
export default DropdownMenuItem;
|
|
55
|
+
ListItem.displayName = 'ListItem';
|
|
56
|
+
export default ListItem;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { WithAsProps } from '../@types/common';
|
|
3
|
+
export interface ListItemGroupProps extends WithAsProps, React.HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
}
|
|
5
|
+
declare const ListItemGroup: React.ForwardRefExoticComponent<ListItemGroupProps & React.RefAttributes<HTMLDivElement>>;
|
|
6
|
+
export default ListItemGroup;
|
|
@@ -4,10 +4,9 @@ import _taggedTemplateLiteralLoose from "@babel/runtime/helpers/esm/taggedTempla
|
|
|
4
4
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
5
|
var _templateObject, _templateObject2;
|
|
6
6
|
import React from 'react';
|
|
7
|
-
import PropTypes from 'prop-types';
|
|
8
7
|
import { useClassNames } from '../utils';
|
|
9
8
|
import ArrowDown from '@rsuite/icons/legacy/ArrowDown';
|
|
10
|
-
var
|
|
9
|
+
var ListItemGroup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
11
10
|
var _props$as = props.as,
|
|
12
11
|
Component = _props$as === void 0 ? 'div' : _props$as,
|
|
13
12
|
_props$classPrefix = props.classPrefix,
|
|
@@ -33,10 +32,5 @@ var DropdownMenuGroup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
33
32
|
className: prefix(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["caret"])))
|
|
34
33
|
})));
|
|
35
34
|
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
classPrefix: PropTypes.string,
|
|
39
|
-
className: PropTypes.string,
|
|
40
|
-
children: PropTypes.node
|
|
41
|
-
};
|
|
42
|
-
export default DropdownMenuGroup;
|
|
35
|
+
ListItemGroup.displayName = 'ListItemGroup';
|
|
36
|
+
export default ListItemGroup;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ListProps, ListHandle } from '../Windowing';
|
|
3
|
+
import { StandardProps, ItemDataType } from '../@types/common';
|
|
4
|
+
export interface ListboxProps<Multiple = false> extends StandardProps, Omit<React.HTMLAttributes<HTMLDivElement>, 'onSelect'> {
|
|
5
|
+
classPrefix: string;
|
|
6
|
+
data?: ItemDataType[];
|
|
7
|
+
group?: boolean;
|
|
8
|
+
groupBy?: string;
|
|
9
|
+
disabledItemValues?: any[];
|
|
10
|
+
activeItemValues?: any[];
|
|
11
|
+
focusItemValue?: any;
|
|
12
|
+
maxHeight?: number;
|
|
13
|
+
valueKey?: string;
|
|
14
|
+
labelKey?: string;
|
|
15
|
+
className?: string;
|
|
16
|
+
style?: React.CSSProperties;
|
|
17
|
+
listItemAs: React.ElementType | string;
|
|
18
|
+
listItemClassPrefix?: string;
|
|
19
|
+
listItemProps?: any;
|
|
20
|
+
rowHeight?: number;
|
|
21
|
+
rowGroupHeight?: number;
|
|
22
|
+
virtualized?: boolean;
|
|
23
|
+
listProps?: Partial<ListProps>;
|
|
24
|
+
listRef?: React.Ref<ListHandle>;
|
|
25
|
+
/** Custom selected option */
|
|
26
|
+
renderMenuItem?: (itemLabel: React.ReactNode, item: any) => React.ReactNode;
|
|
27
|
+
renderMenuGroup?: (title: React.ReactNode, item: any) => React.ReactNode;
|
|
28
|
+
onSelect?: Multiple extends true ? (value: any, item: any, event: React.MouseEvent, checked: boolean) => void : Multiple extends false ? (value: any, item: any, event: React.MouseEvent) => void : any;
|
|
29
|
+
onGroupTitleClick?: (event: React.MouseEvent) => void;
|
|
30
|
+
}
|
|
31
|
+
export declare type ListboxComponent = React.ForwardRefExoticComponent<ListboxProps> & {
|
|
32
|
+
<Multiple = false>(props: ListboxProps<Multiple>): React.ReactElement | null;
|
|
33
|
+
};
|
|
34
|
+
declare const Listbox: ListboxComponent;
|
|
35
|
+
export default Listbox;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
3
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
4
|
-
import _get from "lodash/get";
|
|
5
4
|
var _this = this;
|
|
6
|
-
import React, { useRef, useState, useEffect
|
|
7
|
-
import PropTypes from 'prop-types';
|
|
5
|
+
import React, { useRef, useState, useEffect } from 'react';
|
|
8
6
|
import isUndefined from 'lodash/isUndefined';
|
|
9
7
|
import isString from 'lodash/isString';
|
|
10
8
|
import isNumber from 'lodash/isNumber';
|
|
@@ -13,13 +11,15 @@ import pickBy from 'lodash/pickBy';
|
|
|
13
11
|
import getPosition from 'dom-lib/getPosition';
|
|
14
12
|
import scrollTop from 'dom-lib/scrollTop';
|
|
15
13
|
import getHeight from 'dom-lib/getHeight';
|
|
14
|
+
import get from 'lodash/get';
|
|
16
15
|
import classNames from 'classnames';
|
|
17
16
|
import { List, AutoSizer, VariableSizeList } from '../Windowing';
|
|
18
17
|
import shallowEqual from '../utils/shallowEqual';
|
|
19
|
-
import { mergeRefs, useClassNames, useMount } from '../utils';
|
|
20
|
-
import
|
|
18
|
+
import { mergeRefs, useClassNames, useMount, useEventCallback } from '../utils';
|
|
19
|
+
import ListItemGroup from './ListItemGroup';
|
|
21
20
|
import { KEY_GROUP, KEY_GROUP_TITLE } from '../utils/getDataGroupBy';
|
|
22
|
-
|
|
21
|
+
import useCombobox from './hooks/useCombobox';
|
|
22
|
+
var Listbox = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
23
23
|
var _props$data = props.data,
|
|
24
24
|
data = _props$data === void 0 ? [] : _props$data,
|
|
25
25
|
group = props.group,
|
|
@@ -42,9 +42,9 @@ var DropdownMenu = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
42
42
|
className = props.className,
|
|
43
43
|
style = props.style,
|
|
44
44
|
focusItemValue = props.focusItemValue,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
listItemClassPrefix = props.listItemClassPrefix,
|
|
46
|
+
ListItem = props.listItemAs,
|
|
47
|
+
listItemProps = props.listItemProps,
|
|
48
48
|
_props$rowHeight = props.rowHeight,
|
|
49
49
|
rowHeight = _props$rowHeight === void 0 ? 36 : _props$rowHeight,
|
|
50
50
|
_props$rowGroupHeight = props.rowGroupHeight,
|
|
@@ -53,7 +53,7 @@ var DropdownMenu = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
53
53
|
renderMenuItem = props.renderMenuItem,
|
|
54
54
|
onGroupTitleClick = props.onGroupTitleClick,
|
|
55
55
|
onSelect = props.onSelect,
|
|
56
|
-
rest = _objectWithoutPropertiesLoose(props, ["data", "group", "groupBy", "maxHeight", "activeItemValues", "disabledItemValues", "classPrefix", "valueKey", "labelKey", "virtualized", "listProps", "listRef", "className", "style", "focusItemValue", "
|
|
56
|
+
rest = _objectWithoutPropertiesLoose(props, ["data", "group", "groupBy", "maxHeight", "activeItemValues", "disabledItemValues", "classPrefix", "valueKey", "labelKey", "virtualized", "listProps", "listRef", "className", "style", "focusItemValue", "listItemClassPrefix", "listItemAs", "listItemProps", "rowHeight", "rowGroupHeight", "renderMenuGroup", "renderMenuItem", "onGroupTitleClick", "onSelect"]);
|
|
57
57
|
var _useClassNames = useClassNames(classPrefix),
|
|
58
58
|
withClassPrefix = _useClassNames.withClassPrefix,
|
|
59
59
|
prefix = _useClassNames.prefix,
|
|
@@ -61,12 +61,17 @@ var DropdownMenu = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
61
61
|
var classes = merge(className, withClassPrefix('items', {
|
|
62
62
|
grouped: group
|
|
63
63
|
}));
|
|
64
|
+
var _useCombobox = useCombobox(),
|
|
65
|
+
id = _useCombobox.id,
|
|
66
|
+
labelId = _useCombobox.labelId,
|
|
67
|
+
popupType = _useCombobox.popupType,
|
|
68
|
+
multiple = _useCombobox.multiple;
|
|
64
69
|
var menuBodyContainerRef = useRef(null);
|
|
65
70
|
var listRef = useRef(null);
|
|
66
71
|
var _useState = useState([]),
|
|
67
72
|
foldedGroupKeys = _useState[0],
|
|
68
73
|
setFoldedGroupKeys = _useState[1];
|
|
69
|
-
var handleGroupTitleClick =
|
|
74
|
+
var handleGroupTitleClick = useEventCallback(function (key, event) {
|
|
70
75
|
var nextGroupKeys = foldedGroupKeys.filter(function (item) {
|
|
71
76
|
return item !== key;
|
|
72
77
|
});
|
|
@@ -75,10 +80,10 @@ var DropdownMenu = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
75
80
|
}
|
|
76
81
|
setFoldedGroupKeys(nextGroupKeys);
|
|
77
82
|
onGroupTitleClick === null || onGroupTitleClick === void 0 ? void 0 : onGroupTitleClick(event);
|
|
78
|
-
}
|
|
79
|
-
var handleSelect =
|
|
83
|
+
});
|
|
84
|
+
var handleSelect = useEventCallback(function (item, value, event, checked) {
|
|
80
85
|
onSelect === null || onSelect === void 0 ? void 0 : onSelect(value, item, event, checked);
|
|
81
|
-
}
|
|
86
|
+
});
|
|
82
87
|
var getRowHeight = function getRowHeight(list, index) {
|
|
83
88
|
var item = list[index];
|
|
84
89
|
if (group && item[KEY_GROUP] && index !== 0) {
|
|
@@ -107,6 +112,24 @@ var DropdownMenu = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
107
112
|
scrollTop(container, Math.max(0, position.top - sHeight + 32));
|
|
108
113
|
}
|
|
109
114
|
}, [focusItemValue, menuBodyContainerRef, prefix]);
|
|
115
|
+
var filteredItems = group ? data.filter(function (item) {
|
|
116
|
+
var _item$parent;
|
|
117
|
+
// Display group title items
|
|
118
|
+
if (item[KEY_GROUP]) return true;
|
|
119
|
+
|
|
120
|
+
// Display items under the unfolded group
|
|
121
|
+
// FIXME-Doma
|
|
122
|
+
// `groupBy` is bound to be string when `group` is true
|
|
123
|
+
// because `group` is actually redundant as a prop
|
|
124
|
+
// It could simply be derived from `groupBy` value
|
|
125
|
+
var groupValue = get(item, groupBy, '') || ( // FIXME-Doma
|
|
126
|
+
// Usage of `item.parent` is strongly discouraged
|
|
127
|
+
// It's only here for legacy support
|
|
128
|
+
// Remove once `item.parent` is completely removed across related components
|
|
129
|
+
(_item$parent = item.parent) === null || _item$parent === void 0 ? void 0 : _item$parent[KEY_GROUP_TITLE]);
|
|
130
|
+
return !foldedGroupKeys.includes(groupValue);
|
|
131
|
+
}) : data;
|
|
132
|
+
var rowCount = filteredItems.length;
|
|
110
133
|
var renderItem = function renderItem(_ref) {
|
|
111
134
|
var _ref$index = _ref.index,
|
|
112
135
|
index = _ref$index === void 0 ? 0 : _ref$index,
|
|
@@ -124,13 +147,13 @@ var DropdownMenu = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
124
147
|
var itemKey = isString(value) || isNumber(value) ? value : index;
|
|
125
148
|
|
|
126
149
|
/**
|
|
127
|
-
* Render <
|
|
150
|
+
* Render <ListboxGroup>
|
|
128
151
|
* when if `group` is enabled
|
|
129
152
|
*/
|
|
130
153
|
if (group && item[KEY_GROUP]) {
|
|
131
154
|
var groupValue = item[KEY_GROUP_TITLE];
|
|
132
155
|
// TODO: grouped options should be owned by group
|
|
133
|
-
return /*#__PURE__*/React.createElement(
|
|
156
|
+
return /*#__PURE__*/React.createElement(ListItemGroup, {
|
|
134
157
|
style: style,
|
|
135
158
|
classPrefix: 'picker-menu-group',
|
|
136
159
|
className: classNames({
|
|
@@ -151,37 +174,21 @@ var DropdownMenu = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
151
174
|
return shallowEqual(v, value);
|
|
152
175
|
});
|
|
153
176
|
var focus = !isUndefined(focusItemValue) && shallowEqual(focusItemValue, value);
|
|
154
|
-
return /*#__PURE__*/React.createElement(
|
|
177
|
+
return /*#__PURE__*/React.createElement(ListItem, _extends({
|
|
178
|
+
"aria-posinset": index + 1,
|
|
179
|
+
"aria-setsize": rowCount,
|
|
155
180
|
style: style,
|
|
156
181
|
key: itemKey,
|
|
157
182
|
disabled: disabled,
|
|
158
183
|
active: active,
|
|
159
184
|
focus: focus,
|
|
160
185
|
value: value,
|
|
161
|
-
classPrefix:
|
|
186
|
+
classPrefix: listItemClassPrefix,
|
|
162
187
|
onSelect: handleSelect.bind(null, item)
|
|
163
|
-
}, pickBy(
|
|
188
|
+
}, pickBy(listItemProps, function (v) {
|
|
164
189
|
return v !== undefined;
|
|
165
190
|
})), renderMenuItem ? renderMenuItem(label, item) : label);
|
|
166
191
|
};
|
|
167
|
-
var filteredItems = group ? data.filter(function (item) {
|
|
168
|
-
var _item$parent;
|
|
169
|
-
// Display group title items
|
|
170
|
-
if (item[KEY_GROUP]) return true;
|
|
171
|
-
|
|
172
|
-
// Display items under the unfolded group
|
|
173
|
-
// FIXME-Doma
|
|
174
|
-
// `groupBy` is bound to be string when `group` is true
|
|
175
|
-
// because `group` is actually redundant as a prop
|
|
176
|
-
// It could simply be derived from `groupBy` value
|
|
177
|
-
var groupValue = _get(item, groupBy, '') || ( // FIXME-Doma
|
|
178
|
-
// Usage of `item.parent` is strongly discouraged
|
|
179
|
-
// It's only here for legacy support
|
|
180
|
-
// Remove once `item.parent` is completely removed across related components
|
|
181
|
-
(_item$parent = item.parent) === null || _item$parent === void 0 ? void 0 : _item$parent[KEY_GROUP_TITLE]);
|
|
182
|
-
return !foldedGroupKeys.includes(groupValue);
|
|
183
|
-
}) : data;
|
|
184
|
-
var rowCount = filteredItems.length;
|
|
185
192
|
useMount(function () {
|
|
186
193
|
var _listRef$current, _listRef$current$scro;
|
|
187
194
|
var itemIndex = findIndex(filteredItems, function (item) {
|
|
@@ -190,7 +197,10 @@ var DropdownMenu = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
190
197
|
(_listRef$current = listRef.current) === null || _listRef$current === void 0 ? void 0 : (_listRef$current$scro = _listRef$current.scrollToItem) === null || _listRef$current$scro === void 0 ? void 0 : _listRef$current$scro.call(_listRef$current, itemIndex);
|
|
191
198
|
});
|
|
192
199
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
193
|
-
role: "listbox"
|
|
200
|
+
role: "listbox",
|
|
201
|
+
id: id + "-" + popupType,
|
|
202
|
+
"aria-labelledby": labelId,
|
|
203
|
+
"aria-multiselectable": multiple
|
|
194
204
|
}, rest, {
|
|
195
205
|
className: classes,
|
|
196
206
|
ref: mergeRefs(menuBodyContainerRef, ref),
|
|
@@ -220,29 +230,5 @@ var DropdownMenu = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
220
230
|
});
|
|
221
231
|
}));
|
|
222
232
|
});
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
className: PropTypes.string,
|
|
226
|
-
dropdownMenuItemAs: PropTypes.elementType.isRequired,
|
|
227
|
-
dropdownMenuItemClassPrefix: PropTypes.string,
|
|
228
|
-
data: PropTypes.array,
|
|
229
|
-
group: PropTypes.bool,
|
|
230
|
-
disabledItemValues: PropTypes.array,
|
|
231
|
-
activeItemValues: PropTypes.array,
|
|
232
|
-
focusItemValue: PropTypes.any,
|
|
233
|
-
maxHeight: PropTypes.number,
|
|
234
|
-
valueKey: PropTypes.string,
|
|
235
|
-
labelKey: PropTypes.string,
|
|
236
|
-
style: PropTypes.object,
|
|
237
|
-
renderMenuItem: PropTypes.func,
|
|
238
|
-
renderMenuGroup: PropTypes.func,
|
|
239
|
-
onSelect: PropTypes.func,
|
|
240
|
-
onGroupTitleClick: PropTypes.func,
|
|
241
|
-
virtualized: PropTypes.bool,
|
|
242
|
-
listProps: PropTypes.any,
|
|
243
|
-
rowHeight: PropTypes.number,
|
|
244
|
-
rowGroupHeight: PropTypes.number
|
|
245
|
-
};
|
|
246
|
-
DropdownMenu.displayName = 'DropdownMenu';
|
|
247
|
-
DropdownMenu.propTypes = dropdownMenuPropTypes;
|
|
248
|
-
export default DropdownMenu;
|
|
233
|
+
Listbox.displayName = 'Listbox';
|
|
234
|
+
export default Listbox;
|
|
@@ -34,7 +34,8 @@ var PickerIndicator = function PickerIndicator(_ref) {
|
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
return caretAs && /*#__PURE__*/React.createElement(Icon, {
|
|
37
|
-
as: caretAs
|
|
37
|
+
as: caretAs,
|
|
38
|
+
className: prefix('caret-icon')
|
|
38
39
|
});
|
|
39
40
|
};
|
|
40
41
|
return /*#__PURE__*/React.createElement(Component, null, addon());
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { WithAsProps, RsRefForwardingComponent } from '../@types/common';
|
|
3
3
|
import { OverlayTriggerHandle } from '../Picker';
|
|
4
|
-
export interface
|
|
4
|
+
export interface PickerPopupProps extends WithAsProps {
|
|
5
5
|
placement?: string;
|
|
6
6
|
autoWidth?: boolean;
|
|
7
7
|
children?: React.ReactNode;
|
|
8
8
|
target?: React.RefObject<OverlayTriggerHandle>;
|
|
9
9
|
onKeyDown?: (event: React.KeyboardEvent) => void;
|
|
10
10
|
}
|
|
11
|
-
declare const
|
|
12
|
-
export default
|
|
11
|
+
declare const PickerPopup: RsRefForwardingComponent<'div', PickerPopupProps>;
|
|
12
|
+
export default PickerPopup;
|
|
@@ -5,14 +5,14 @@ import React, { useRef, useCallback, useEffect } from 'react';
|
|
|
5
5
|
import omit from 'lodash/omit';
|
|
6
6
|
import addStyle from 'dom-lib/addStyle';
|
|
7
7
|
import getWidth from 'dom-lib/getWidth';
|
|
8
|
-
import { getDOMNode, mergeRefs, useElementResize, useClassNames } from '../utils';
|
|
8
|
+
import { getDOMNode, mergeRefs, useElementResize, useClassNames, useEventCallback } from '../utils';
|
|
9
9
|
var omitProps = ['placement', 'arrowOffsetLeft', 'arrowOffsetTop', 'positionLeft', 'positionTop', 'getPositionInstance', 'getToggleInstance', 'autoWidth'];
|
|
10
10
|
var resizePlacement = ['topStart', 'topEnd', 'leftEnd', 'rightEnd', 'auto', 'autoVerticalStart', 'autoVerticalEnd', 'autoHorizontalEnd'];
|
|
11
|
-
var
|
|
11
|
+
var PickerPopup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
12
12
|
var _props$as = props.as,
|
|
13
13
|
Component = _props$as === void 0 ? 'div' : _props$as,
|
|
14
14
|
_props$classPrefix = props.classPrefix,
|
|
15
|
-
classPrefix = _props$classPrefix === void 0 ? 'picker-
|
|
15
|
+
classPrefix = _props$classPrefix === void 0 ? 'picker-popup' : _props$classPrefix,
|
|
16
16
|
autoWidth = props.autoWidth,
|
|
17
17
|
className = props.className,
|
|
18
18
|
_props$placement = props.placement,
|
|
@@ -20,12 +20,12 @@ var PickerOverlay = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
20
20
|
target = props.target,
|
|
21
21
|
rest = _objectWithoutPropertiesLoose(props, ["as", "classPrefix", "autoWidth", "className", "placement", "target"]);
|
|
22
22
|
var overlayRef = useRef(null);
|
|
23
|
-
var handleResize =
|
|
23
|
+
var handleResize = useEventCallback(function () {
|
|
24
24
|
var instance = target === null || target === void 0 ? void 0 : target.current;
|
|
25
25
|
if (instance && resizePlacement.includes(placement)) {
|
|
26
26
|
instance.updatePosition();
|
|
27
27
|
}
|
|
28
|
-
}
|
|
28
|
+
});
|
|
29
29
|
useElementResize(useCallback(function () {
|
|
30
30
|
return overlayRef.current;
|
|
31
31
|
}, []), handleResize);
|
|
@@ -44,10 +44,12 @@ var PickerOverlay = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
44
44
|
withClassPrefix = _useClassNames.withClassPrefix,
|
|
45
45
|
merge = _useClassNames.merge;
|
|
46
46
|
var classes = merge(className, withClassPrefix());
|
|
47
|
-
return /*#__PURE__*/React.createElement(Component, _extends({
|
|
47
|
+
return /*#__PURE__*/React.createElement(Component, _extends({
|
|
48
|
+
"data-testid": "picker-popup"
|
|
49
|
+
}, omit(rest, omitProps), {
|
|
48
50
|
ref: mergeRefs(overlayRef, ref),
|
|
49
51
|
className: classes
|
|
50
52
|
}));
|
|
51
53
|
});
|
|
52
|
-
|
|
53
|
-
export default
|
|
54
|
+
PickerPopup.displayName = 'PickerPopup';
|
|
55
|
+
export default PickerPopup;
|
|
@@ -4,38 +4,33 @@ import { RsRefForwardingComponent, TypeAttributes } from '../@types/common';
|
|
|
4
4
|
import { IconProps } from '@rsuite/icons/lib/Icon';
|
|
5
5
|
declare type ValueType = string | number;
|
|
6
6
|
export interface PickerToggleProps extends ToggleButtonProps {
|
|
7
|
-
|
|
8
|
-
inputValue?: ValueType | ValueType[];
|
|
9
|
-
id?: string;
|
|
7
|
+
active?: boolean;
|
|
10
8
|
hasValue?: boolean;
|
|
11
9
|
cleanable?: boolean;
|
|
12
10
|
caret?: boolean;
|
|
13
|
-
active?: boolean;
|
|
14
|
-
disabled?: boolean;
|
|
15
|
-
readOnly?: boolean;
|
|
16
|
-
plaintext?: boolean;
|
|
17
|
-
tabIndex?: number;
|
|
18
|
-
/** Whether to display an loading indicator on toggle button */
|
|
19
|
-
loading?: boolean;
|
|
20
|
-
editable?: boolean;
|
|
21
|
-
name?: string;
|
|
22
|
-
inputPlaceholder?: string;
|
|
23
|
-
inputMask?: (string | RegExp)[];
|
|
24
|
-
onInputChange?: (value: string, event: React.ChangeEvent) => void;
|
|
25
|
-
onInputPressEnter?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
26
|
-
onInputBackspace?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
27
|
-
onInputBlur?: (event: React.FocusEvent<HTMLElement>) => void;
|
|
28
|
-
onInputFocus?: (event: React.FocusEvent<HTMLElement>) => void;
|
|
29
|
-
placement?: TypeAttributes.Placement;
|
|
30
11
|
/**
|
|
31
12
|
* Custom caret component
|
|
32
13
|
* @deprecated Use `caretAs` instead
|
|
33
14
|
*/
|
|
34
15
|
caretComponent?: React.FC<IconProps>;
|
|
35
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Custom caret component
|
|
18
|
+
*/
|
|
36
19
|
caretAs?: React.ElementType;
|
|
37
|
-
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
placement?: TypeAttributes.Placement;
|
|
22
|
+
readOnly?: boolean;
|
|
23
|
+
plaintext?: boolean;
|
|
24
|
+
tabIndex?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Whether to display an loading indicator on toggle button
|
|
27
|
+
*/
|
|
28
|
+
loading?: boolean;
|
|
38
29
|
label?: React.ReactNode;
|
|
30
|
+
name?: string;
|
|
31
|
+
inputValue?: ValueType | ValueType[];
|
|
32
|
+
focusItemValue?: ValueType | null;
|
|
33
|
+
onClean?: (event: React.MouseEvent) => void;
|
|
39
34
|
}
|
|
40
35
|
declare const PickerToggle: RsRefForwardingComponent<typeof ToggleButton, PickerToggleProps>;
|
|
41
36
|
export default PickerToggle;
|