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,23 +1,19 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import _taggedTemplateLiteralLoose from "@babel/runtime/helpers/esm/taggedTemplateLiteralLoose";
|
|
3
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
import _taggedTemplateLiteralLoose from "@babel/runtime/helpers/esm/taggedTemplateLiteralLoose";
|
|
4
4
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
-
var _templateObject
|
|
6
|
-
import React, {
|
|
7
|
-
import PropTypes from 'prop-types';
|
|
8
|
-
import debounce from 'lodash/debounce';
|
|
5
|
+
var _templateObject;
|
|
6
|
+
import React, { useRef, useMemo } from 'react';
|
|
9
7
|
import ToggleButton from './ToggleButton';
|
|
10
|
-
import
|
|
11
|
-
import { useClassNames, useCustom, KEY_VALUES, mergeRefs } from '../utils';
|
|
8
|
+
import { useClassNames, mergeRefs, useEventCallback } from '../utils';
|
|
12
9
|
import Plaintext from '../Plaintext';
|
|
13
10
|
import useToggleCaret from '../utils/useToggleCaret';
|
|
14
|
-
import TextMask from '../MaskedInput/TextMask';
|
|
15
|
-
import deprecatePropType from '../utils/deprecatePropType';
|
|
16
|
-
import Loader from '../Loader';
|
|
17
11
|
import Stack from '../Stack';
|
|
18
|
-
|
|
12
|
+
import PickerIndicator from './PickerIndicator';
|
|
13
|
+
import PickerLabel from './PickerLabel';
|
|
14
|
+
import useCombobox from './hooks/useCombobox';
|
|
19
15
|
var PickerToggle = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
20
|
-
var
|
|
16
|
+
var active = props.active,
|
|
21
17
|
_props$as = props.as,
|
|
22
18
|
Component = _props$as === void 0 ? ToggleButton : _props$as,
|
|
23
19
|
_props$classPrefix = props.classPrefix,
|
|
@@ -30,26 +26,14 @@ var PickerToggle = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
30
26
|
readOnly = props.readOnly,
|
|
31
27
|
plaintext = props.plaintext,
|
|
32
28
|
hasValue = props.hasValue,
|
|
33
|
-
editable = props.editable,
|
|
34
29
|
_props$loading = props.loading,
|
|
35
30
|
loading = _props$loading === void 0 ? false : _props$loading,
|
|
36
|
-
|
|
31
|
+
cleanable = props.cleanable,
|
|
37
32
|
_props$tabIndex = props.tabIndex,
|
|
38
|
-
|
|
39
|
-
id = props.id,
|
|
40
|
-
value = props.value,
|
|
41
|
-
inputPlaceholder = props.inputPlaceholder,
|
|
33
|
+
tabIndex = _props$tabIndex === void 0 ? 0 : _props$tabIndex,
|
|
42
34
|
inputValueProp = props.inputValue,
|
|
43
|
-
|
|
44
|
-
inputMask = _props$inputMask === void 0 ? defaultInputMask : _props$inputMask,
|
|
45
|
-
onInputChange = props.onInputChange,
|
|
46
|
-
onInputPressEnter = props.onInputPressEnter,
|
|
47
|
-
onInputBackspace = props.onInputBackspace,
|
|
48
|
-
onInputBlur = props.onInputBlur,
|
|
49
|
-
onInputFocus = props.onInputFocus,
|
|
35
|
+
focusItemValue = props.focusItemValue,
|
|
50
36
|
onClean = props.onClean,
|
|
51
|
-
onFocus = props.onFocus,
|
|
52
|
-
onBlur = props.onBlur,
|
|
53
37
|
_props$placement = props.placement,
|
|
54
38
|
placement = _props$placement === void 0 ? 'bottomStart' : _props$placement,
|
|
55
39
|
caretComponent = props.caretComponent,
|
|
@@ -57,102 +41,33 @@ var PickerToggle = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
57
41
|
caretAs = _props$caretAs === void 0 ? caretComponent : _props$caretAs,
|
|
58
42
|
label = props.label,
|
|
59
43
|
name = props.name,
|
|
60
|
-
rest = _objectWithoutPropertiesLoose(props, ["active", "as", "classPrefix", "children", "caret", "className", "disabled", "readOnly", "plaintext", "hasValue", "
|
|
61
|
-
var
|
|
62
|
-
locale = _useCustom.locale;
|
|
63
|
-
var inputRef = useRef(null);
|
|
64
|
-
var comboboxRef = useRef(null);
|
|
65
|
-
var _useState = useState(false),
|
|
66
|
-
activeState = _useState[0],
|
|
67
|
-
setActive = _useState[1];
|
|
44
|
+
rest = _objectWithoutPropertiesLoose(props, ["active", "as", "classPrefix", "children", "caret", "className", "disabled", "readOnly", "plaintext", "hasValue", "loading", "cleanable", "tabIndex", "inputValue", "focusItemValue", "onClean", "placement", "caretComponent", "caretAs", "label", "name"]);
|
|
45
|
+
var combobox = useRef(null);
|
|
68
46
|
var _useClassNames = useClassNames(classPrefix),
|
|
69
47
|
withClassPrefix = _useClassNames.withClassPrefix,
|
|
70
48
|
merge = _useClassNames.merge,
|
|
71
49
|
prefix = _useClassNames.prefix;
|
|
72
|
-
var
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (
|
|
80
|
-
|
|
81
|
-
setInputValue(_value);
|
|
50
|
+
var _useCombobox = useCombobox(),
|
|
51
|
+
id = _useCombobox.id,
|
|
52
|
+
labelId = _useCombobox.labelId,
|
|
53
|
+
popupType = _useCombobox.popupType;
|
|
54
|
+
var inputValue = useMemo(function () {
|
|
55
|
+
if (typeof inputValueProp === 'number' || typeof inputValueProp === 'string') {
|
|
56
|
+
return inputValueProp;
|
|
57
|
+
} else if (Array.isArray(inputValueProp)) {
|
|
58
|
+
return inputValueProp.join(',');
|
|
82
59
|
}
|
|
83
|
-
|
|
60
|
+
return '';
|
|
61
|
+
}, [inputValueProp]);
|
|
84
62
|
var classes = merge(className, withClassPrefix({
|
|
85
|
-
active:
|
|
63
|
+
active: active
|
|
86
64
|
}));
|
|
87
|
-
var
|
|
88
|
-
|
|
89
|
-
setActive(true);
|
|
90
|
-
}
|
|
91
|
-
if (editable) {
|
|
92
|
-
// Avoid firing the onFocus event twice when DatePicker and DateRangePicker allow keyboard input.
|
|
93
|
-
if (event.target === inputRef.current) {
|
|
94
|
-
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// Force the input to be focused and editable.
|
|
98
|
-
if (document.activeElement === comboboxRef.current) {
|
|
99
|
-
var _inputRef$current;
|
|
100
|
-
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
|
|
101
|
-
}
|
|
102
|
-
} else {
|
|
103
|
-
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|
|
104
|
-
}
|
|
105
|
-
}, [editable, loading, onFocus]);
|
|
106
|
-
var handleBlur = useCallback(function (event) {
|
|
107
|
-
if (inputRef.current && !editable) {
|
|
108
|
-
setActive(false);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// When activeElement is an input, it remains active.
|
|
112
|
-
if (editable && inputRef.current && document.activeElement !== inputRef.current) {
|
|
113
|
-
setActive(false);
|
|
114
|
-
}
|
|
115
|
-
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
116
|
-
}, [editable, onBlur]);
|
|
117
|
-
var handleInputBlur = function handleInputBlur(event) {
|
|
118
|
-
setInputValue(getInputValue());
|
|
119
|
-
onInputBlur === null || onInputBlur === void 0 ? void 0 : onInputBlur(event);
|
|
120
|
-
};
|
|
121
|
-
var handleClean = useCallback(function (event) {
|
|
122
|
-
var _inputRef$current2, _comboboxRef$current;
|
|
65
|
+
var handleClean = useEventCallback(function (event) {
|
|
66
|
+
var _combobox$current;
|
|
123
67
|
event.stopPropagation();
|
|
124
68
|
onClean === null || onClean === void 0 ? void 0 : onClean(event);
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
editable ? (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.focus() : (_comboboxRef$current = comboboxRef.current) === null || _comboboxRef$current === void 0 ? void 0 : _comboboxRef$current.focus();
|
|
128
|
-
}, [editable, onClean]);
|
|
129
|
-
var handleInputChange = useCallback(function (event) {
|
|
130
|
-
var _event$target;
|
|
131
|
-
var value = (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.value;
|
|
132
|
-
setInputValue(value);
|
|
133
|
-
onInputChange === null || onInputChange === void 0 ? void 0 : onInputChange(value, event);
|
|
134
|
-
}, [onInputChange]);
|
|
135
|
-
var handleInputKeyDown = useCallback(function (event) {
|
|
136
|
-
if (editable) {
|
|
137
|
-
if (event.key === KEY_VALUES.ENTER) {
|
|
138
|
-
onInputPressEnter === null || onInputPressEnter === void 0 ? void 0 : onInputPressEnter(event);
|
|
139
|
-
}
|
|
140
|
-
if (event.key === KEY_VALUES.BACKSPACE) {
|
|
141
|
-
onInputBackspace === null || onInputBackspace === void 0 ? void 0 : onInputBackspace(event);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}, [editable, onInputPressEnter, onInputBackspace]);
|
|
145
|
-
var renderInput = useCallback(function (ref, props) {
|
|
146
|
-
return /*#__PURE__*/React.createElement("input", _extends({
|
|
147
|
-
type: "text",
|
|
148
|
-
autoComplete: "off",
|
|
149
|
-
ref: mergeRefs(inputRef, ref),
|
|
150
|
-
name: name,
|
|
151
|
-
style: {
|
|
152
|
-
pointerEvents: editable ? undefined : 'none'
|
|
153
|
-
}
|
|
154
|
-
}, props));
|
|
155
|
-
}, [editable, name]);
|
|
69
|
+
(_combobox$current = combobox.current) === null || _combobox$current === void 0 ? void 0 : _combobox$current.focus();
|
|
70
|
+
});
|
|
156
71
|
var ToggleCaret = useToggleCaret(placement);
|
|
157
72
|
var Caret = caretAs !== null && caretAs !== void 0 ? caretAs : ToggleCaret;
|
|
158
73
|
if (plaintext) {
|
|
@@ -161,88 +76,55 @@ var PickerToggle = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
161
76
|
localeKey: "notSelected"
|
|
162
77
|
}, hasValue ? children : null);
|
|
163
78
|
}
|
|
164
|
-
var showCleanButton =
|
|
165
|
-
|
|
166
|
-
// When the component is read-only or disabled, the input is not interactive.
|
|
167
|
-
var inputFocused = readOnly || disabled ? false : editable && activeState;
|
|
168
|
-
var tabIndex = disabled ? undefined : tabIndexProp;
|
|
79
|
+
var showCleanButton = cleanable && hasValue && !readOnly;
|
|
169
80
|
return /*#__PURE__*/React.createElement(Component, _extends({
|
|
170
81
|
role: "combobox",
|
|
171
|
-
|
|
172
|
-
"aria-
|
|
82
|
+
id: id,
|
|
83
|
+
"aria-haspopup": popupType,
|
|
84
|
+
"aria-expanded": active,
|
|
173
85
|
"aria-disabled": disabled,
|
|
174
|
-
"aria-
|
|
86
|
+
"aria-controls": id + "-" + popupType,
|
|
87
|
+
"aria-labelledby": labelId,
|
|
88
|
+
"aria-describedby": id + "-describe",
|
|
89
|
+
"aria-activedescendant": active && focusItemValue ? id + "-opt-" + focusItemValue : undefined
|
|
175
90
|
}, rest, {
|
|
176
|
-
ref: mergeRefs(
|
|
91
|
+
ref: mergeRefs(combobox, ref),
|
|
177
92
|
disabled: disabled,
|
|
178
|
-
tabIndex: tabIndex,
|
|
179
|
-
className: classes
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
,
|
|
183
|
-
|
|
184
|
-
}), /*#__PURE__*/React.createElement(Stack, null, label && /*#__PURE__*/React.createElement(Stack.Item, null, /*#__PURE__*/React.createElement("span", {
|
|
185
|
-
className: prefix('label')
|
|
93
|
+
tabIndex: disabled ? undefined : tabIndex,
|
|
94
|
+
className: classes
|
|
95
|
+
}), /*#__PURE__*/React.createElement(Stack, null, label && /*#__PURE__*/React.createElement(Stack.Item, null, /*#__PURE__*/React.createElement(PickerLabel, {
|
|
96
|
+
as: "span",
|
|
97
|
+
className: prefix('label'),
|
|
98
|
+
id: labelId
|
|
186
99
|
}, label)), /*#__PURE__*/React.createElement(Stack.Item, {
|
|
187
100
|
grow: 1,
|
|
188
101
|
style: {
|
|
189
102
|
overflow: 'hidden'
|
|
190
103
|
}
|
|
191
|
-
},
|
|
104
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
105
|
+
readOnly: true,
|
|
106
|
+
"aria-hidden": true,
|
|
107
|
+
tabIndex: -1,
|
|
108
|
+
"data-testid": "picker-toggle-input",
|
|
109
|
+
name: name,
|
|
110
|
+
value: inputValue,
|
|
111
|
+
className: prefix('textbox', 'read-only'),
|
|
192
112
|
style: {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
},
|
|
196
|
-
"data-testid": "spinner"
|
|
197
|
-
}) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TextMask, {
|
|
198
|
-
keepCharPositions: true,
|
|
199
|
-
mask: inputMask,
|
|
200
|
-
value: Array.isArray(inputValue) ? inputValue.toString() : inputValue,
|
|
201
|
-
onBlur: handleInputBlur,
|
|
202
|
-
onFocus: onInputFocus,
|
|
203
|
-
onChange: handleInputChange,
|
|
204
|
-
onKeyDown: handleInputKeyDown,
|
|
205
|
-
id: id,
|
|
206
|
-
"aria-hidden": !inputFocused,
|
|
207
|
-
readOnly: !inputFocused,
|
|
208
|
-
disabled: disabled,
|
|
209
|
-
"aria-controls": id ? id + "-listbox" : undefined,
|
|
210
|
-
tabIndex: editable ? 0 : -1,
|
|
211
|
-
className: prefix('textbox', {
|
|
212
|
-
'read-only': !inputFocused
|
|
213
|
-
}),
|
|
214
|
-
placeholder: inputPlaceholder,
|
|
215
|
-
render: renderInput,
|
|
216
|
-
"data-testid": "picker-toggle-input"
|
|
113
|
+
pointerEvents: 'none'
|
|
114
|
+
}
|
|
217
115
|
}), children ? /*#__PURE__*/React.createElement("span", {
|
|
218
116
|
className: prefix(hasValue ? 'value' : 'placeholder'),
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
})));
|
|
117
|
+
id: id + "-describe",
|
|
118
|
+
"data-testid": "picker-describe"
|
|
119
|
+
}, children) : null), /*#__PURE__*/React.createElement(Stack.Item, {
|
|
120
|
+
className: prefix(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["indicator"])))
|
|
121
|
+
}, /*#__PURE__*/React.createElement(PickerIndicator, {
|
|
122
|
+
as: React.Fragment,
|
|
123
|
+
loading: loading,
|
|
124
|
+
caretAs: caret ? Caret : null,
|
|
125
|
+
onClose: handleClean,
|
|
126
|
+
showCleanButton: showCleanButton
|
|
127
|
+
}))));
|
|
230
128
|
});
|
|
231
129
|
PickerToggle.displayName = 'PickerToggle';
|
|
232
|
-
PickerToggle.propTypes = {
|
|
233
|
-
classPrefix: PropTypes.string,
|
|
234
|
-
hasValue: PropTypes.bool,
|
|
235
|
-
cleanable: PropTypes.bool,
|
|
236
|
-
className: PropTypes.string,
|
|
237
|
-
children: PropTypes.node,
|
|
238
|
-
caret: PropTypes.bool,
|
|
239
|
-
as: PropTypes.elementType,
|
|
240
|
-
onClean: PropTypes.func,
|
|
241
|
-
active: PropTypes.bool,
|
|
242
|
-
readOnly: PropTypes.bool,
|
|
243
|
-
disabled: PropTypes.bool,
|
|
244
|
-
plaintext: PropTypes.bool,
|
|
245
|
-
caretComponent: deprecatePropType(PropTypes.elementType, 'Use `caretAs` instead.'),
|
|
246
|
-
caretAs: PropTypes.elementType
|
|
247
|
-
};
|
|
248
130
|
export default PickerToggle;
|
|
@@ -4,6 +4,14 @@ import { PositionChildProps } from '../Overlay/Position';
|
|
|
4
4
|
import { TypeAttributes, AnimationEventProps } from '../@types/common';
|
|
5
5
|
export type { OverlayTriggerHandle, PositionChildProps };
|
|
6
6
|
export interface PickerToggleTriggerProps extends Omit<AnimationEventProps, 'onEntering' | 'onExiting'>, Pick<OverlayTriggerProps, 'speaker' | 'onClose'> {
|
|
7
|
+
id?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Identifies the combobox has having a popout, and indicates the type.
|
|
10
|
+
*
|
|
11
|
+
* @see MDN https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-haspopup
|
|
12
|
+
*/
|
|
13
|
+
popupType?: 'listbox' | 'tree' | 'grid' | 'dialog' | 'menu';
|
|
14
|
+
multiple?: boolean;
|
|
7
15
|
placement?: TypeAttributes.Placement;
|
|
8
16
|
pickerProps: any;
|
|
9
17
|
open?: boolean;
|
|
@@ -12,5 +20,12 @@ export interface PickerToggleTriggerProps extends Omit<AnimationEventProps, 'onE
|
|
|
12
20
|
}
|
|
13
21
|
export declare const omitTriggerPropKeys: string[];
|
|
14
22
|
export declare const pickTriggerPropKeys: string[];
|
|
23
|
+
export interface ComboboxContextProps {
|
|
24
|
+
id?: string;
|
|
25
|
+
multiple?: boolean;
|
|
26
|
+
hasLabel?: boolean;
|
|
27
|
+
popupType?: 'listbox' | 'tree' | 'grid' | 'dialog' | 'menu';
|
|
28
|
+
}
|
|
29
|
+
export declare const ComboboxContextContext: React.Context<ComboboxContextProps>;
|
|
15
30
|
declare const PickerToggleTrigger: React.ForwardRefExoticComponent<PickerToggleTriggerProps & React.RefAttributes<any>>;
|
|
16
31
|
export default PickerToggleTrigger;
|
|
@@ -4,26 +4,41 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import pick from 'lodash/pick';
|
|
6
6
|
import OverlayTrigger from '../Overlay/OverlayTrigger';
|
|
7
|
-
import { placementPolyfill, useCustom } from '../utils';
|
|
7
|
+
import { placementPolyfill, useCustom, useUniqueId } from '../utils';
|
|
8
8
|
export var omitTriggerPropKeys = ['onEntered', 'onExited', 'onEnter', 'onEntering', 'onExit', 'onExiting', 'open', 'defaultOpen', 'container', 'containerPadding', 'preventOverflow'];
|
|
9
|
-
export var pickTriggerPropKeys = [].concat(omitTriggerPropKeys, ['disabled', 'plaintext', 'readOnly', 'loading']);
|
|
9
|
+
export var pickTriggerPropKeys = [].concat(omitTriggerPropKeys, ['disabled', 'plaintext', 'readOnly', 'loading', 'label']);
|
|
10
|
+
export var ComboboxContextContext = /*#__PURE__*/React.createContext({
|
|
11
|
+
popupType: 'listbox'
|
|
12
|
+
});
|
|
10
13
|
var PickerToggleTrigger = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
11
14
|
var pickerProps = props.pickerProps,
|
|
12
15
|
speaker = props.speaker,
|
|
13
16
|
placement = props.placement,
|
|
14
17
|
_props$trigger = props.trigger,
|
|
15
18
|
trigger = _props$trigger === void 0 ? 'click' : _props$trigger,
|
|
16
|
-
|
|
19
|
+
id = props.id,
|
|
20
|
+
multiple = props.multiple,
|
|
21
|
+
_props$popupType = props.popupType,
|
|
22
|
+
popupType = _props$popupType === void 0 ? 'listbox' : _props$popupType,
|
|
23
|
+
rest = _objectWithoutPropertiesLoose(props, ["pickerProps", "speaker", "placement", "trigger", "id", "multiple", "popupType"]);
|
|
17
24
|
var pickerTriggerProps = pick(pickerProps, pickTriggerPropKeys);
|
|
25
|
+
var pickerId = useUniqueId('rs-', id);
|
|
18
26
|
var _useCustom = useCustom(),
|
|
19
27
|
rtl = _useCustom.rtl;
|
|
20
|
-
return /*#__PURE__*/React.createElement(
|
|
28
|
+
return /*#__PURE__*/React.createElement(ComboboxContextContext.Provider, {
|
|
29
|
+
value: {
|
|
30
|
+
id: pickerId,
|
|
31
|
+
hasLabel: typeof pickerTriggerProps.label !== 'undefined',
|
|
32
|
+
multiple: multiple,
|
|
33
|
+
popupType: popupType
|
|
34
|
+
}
|
|
35
|
+
}, /*#__PURE__*/React.createElement(OverlayTrigger, _extends({}, pickerTriggerProps, rest, {
|
|
21
36
|
disabled: pickerTriggerProps.disabled || pickerTriggerProps.loading,
|
|
22
37
|
ref: ref,
|
|
23
38
|
trigger: trigger,
|
|
24
39
|
placement: placementPolyfill(placement, rtl),
|
|
25
40
|
speaker: speaker
|
|
26
|
-
}));
|
|
41
|
+
})));
|
|
27
42
|
});
|
|
28
43
|
PickerToggleTrigger.displayName = 'PickerToggleTrigger';
|
|
29
44
|
export default PickerToggleTrigger;
|
package/esm/Picker/SearchBar.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
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 get from 'lodash/get';
|
|
4
|
+
import React from 'react';
|
|
6
5
|
import PropTypes from 'prop-types';
|
|
7
6
|
import Search from '@rsuite/icons/legacy/Search';
|
|
8
|
-
import { useClassNames } from '../utils';
|
|
7
|
+
import { useClassNames, useEventCallback } from '../utils';
|
|
9
8
|
var SearchBar = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
10
9
|
var _props$as = props.as,
|
|
11
10
|
Component = _props$as === void 0 ? 'div' : _props$as,
|
|
@@ -23,15 +22,15 @@ var SearchBar = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
23
22
|
merge = _useClassNames.merge,
|
|
24
23
|
prefix = _useClassNames.prefix;
|
|
25
24
|
var classes = merge(className, withClassPrefix());
|
|
26
|
-
var handleChange =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}, rest, {
|
|
25
|
+
var handleChange = useEventCallback(function (event) {
|
|
26
|
+
var _event$target;
|
|
27
|
+
onChange === null || onChange === void 0 ? void 0 : onChange((_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.value, event);
|
|
28
|
+
});
|
|
29
|
+
return /*#__PURE__*/React.createElement(Component, _extends({}, rest, {
|
|
32
30
|
ref: ref,
|
|
33
31
|
className: classes
|
|
34
32
|
}), /*#__PURE__*/React.createElement("input", {
|
|
33
|
+
role: "searchbox",
|
|
35
34
|
className: prefix('input'),
|
|
36
35
|
value: value,
|
|
37
36
|
onChange: handleChange,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface TreeViewProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
treeRootClassName: string;
|
|
4
|
+
multiselectable?: boolean;
|
|
5
|
+
}
|
|
6
|
+
declare const TreeView: React.ForwardRefExoticComponent<TreeViewProps & React.RefAttributes<HTMLDivElement>>;
|
|
7
|
+
export default TreeView;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import useCombobox from './hooks/useCombobox';
|
|
6
|
+
var TreeView = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
7
|
+
var children = props.children,
|
|
8
|
+
treeRootClassName = props.treeRootClassName,
|
|
9
|
+
multiselectable = props.multiselectable,
|
|
10
|
+
rest = _objectWithoutPropertiesLoose(props, ["children", "treeRootClassName", "multiselectable"]);
|
|
11
|
+
var _useCombobox = useCombobox(),
|
|
12
|
+
id = _useCombobox.id,
|
|
13
|
+
labelId = _useCombobox.labelId,
|
|
14
|
+
popupType = _useCombobox.popupType;
|
|
15
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
16
|
+
role: "tree",
|
|
17
|
+
id: id + "-" + popupType,
|
|
18
|
+
"aria-multiselectable": multiselectable,
|
|
19
|
+
"aria-labelledby": labelId,
|
|
20
|
+
ref: ref
|
|
21
|
+
}, rest), /*#__PURE__*/React.createElement("div", {
|
|
22
|
+
className: treeRootClassName
|
|
23
|
+
}, children));
|
|
24
|
+
});
|
|
25
|
+
export default TreeView;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as usePickerRef } from './usePickerRef';
|
|
2
|
+
export { default as useCombobox } from './useCombobox';
|
|
3
|
+
export { default as useFocusItemValue } from './useFocusItemValue';
|
|
4
|
+
export { default as useToggleKeyDownEvent } from './useToggleKeyDownEvent';
|
|
5
|
+
export { default as useSearch } from './useSearch';
|
|
6
|
+
export { default as usePickerClassName } from './usePickerClassName';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
export { default as usePickerRef } from './usePickerRef';
|
|
3
|
+
export { default as useCombobox } from './useCombobox';
|
|
4
|
+
export { default as useFocusItemValue } from './useFocusItemValue';
|
|
5
|
+
export { default as useToggleKeyDownEvent } from './useToggleKeyDownEvent';
|
|
6
|
+
export { default as useSearch } from './useSearch';
|
|
7
|
+
export { default as usePickerClassName } from './usePickerClassName';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useContext } from 'react';
|
|
3
|
+
import { ComboboxContextContext } from '../PickerToggleTrigger';
|
|
4
|
+
function useCombobox() {
|
|
5
|
+
var _useContext = useContext(ComboboxContextContext),
|
|
6
|
+
id = _useContext.id,
|
|
7
|
+
hasLabel = _useContext.hasLabel,
|
|
8
|
+
popupType = _useContext.popupType,
|
|
9
|
+
multiple = _useContext.multiple;
|
|
10
|
+
return {
|
|
11
|
+
id: id,
|
|
12
|
+
popupType: popupType,
|
|
13
|
+
multiple: multiple,
|
|
14
|
+
labelId: hasLabel ? id + "-label" : undefined
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export default useCombobox;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface FocusItemValueProps<T = unknown> {
|
|
3
|
+
target: HTMLElement | null | (() => HTMLElement | null);
|
|
4
|
+
data?: T[];
|
|
5
|
+
/**
|
|
6
|
+
* When the down arrow key is pressed, whether to automatically focus on the option
|
|
7
|
+
*/
|
|
8
|
+
focusToOption?: boolean;
|
|
9
|
+
valueKey?: string;
|
|
10
|
+
focusableQueryKey?: string;
|
|
11
|
+
defaultLayer?: number;
|
|
12
|
+
rtl?: boolean;
|
|
13
|
+
callback?: (value: any, event: React.KeyboardEvent) => void;
|
|
14
|
+
getParent?: (node: T) => T | undefined;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A hook that manages the focus state of the option.
|
|
18
|
+
* @param defaultFocusItemValue
|
|
19
|
+
* @param props
|
|
20
|
+
*/
|
|
21
|
+
declare const useFocusItemValue: <T, D>(defaultFocusItemValue: T | null | undefined, props: FocusItemValueProps<D>) => {
|
|
22
|
+
focusItemValue: T | null | undefined;
|
|
23
|
+
setFocusItemValue: import("react").Dispatch<import("react").SetStateAction<T | null | undefined>>;
|
|
24
|
+
layer: number;
|
|
25
|
+
setLayer: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
26
|
+
keys: any[];
|
|
27
|
+
setKeys: import("react").Dispatch<import("react").SetStateAction<any[]>>;
|
|
28
|
+
onKeyDown: (...args: any[]) => any;
|
|
29
|
+
};
|
|
30
|
+
export default useFocusItemValue;
|