rsuite 5.53.2 → 5.55.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/AutoComplete/styles/index.css +0 -2
- package/CHANGELOG.md +36 -0
- package/Cascader/styles/index.css +0 -2
- package/CheckPicker/styles/index.css +0 -2
- package/CheckTree/styles/index.css +0 -2
- package/CheckTreePicker/styles/index.css +0 -2
- package/DatePicker/styles/index.css +0 -2
- package/DateRangePicker/styles/index.css +0 -2
- package/FormGroup/styles/index.css +3 -0
- package/FormGroup/styles/index.less +2 -0
- package/InlineEdit/package.json +7 -0
- package/InlineEdit/styles/index.css +112 -0
- package/InlineEdit/styles/index.less +48 -0
- package/InputGroup/styles/index.css +0 -2
- package/InputGroup/styles/index.less +0 -2
- package/InputNumber/styles/index.css +0 -2
- package/InputPicker/styles/index.css +0 -2
- package/MultiCascader/styles/index.css +0 -2
- package/Pagination/styles/index.css +3 -2
- package/Pagination/styles/pagination-group.less +4 -0
- package/SelectPicker/styles/index.css +0 -2
- package/TagInput/styles/index.css +1 -4
- package/TagPicker/styles/index.css +1 -4
- package/TagPicker/styles/index.less +1 -2
- package/cjs/Calendar/CalendarContainer.d.ts +4 -0
- package/cjs/Calendar/CalendarContainer.js +3 -1
- package/cjs/Calendar/TableCell.js +3 -2
- package/cjs/Calendar/types.d.ts +1 -0
- package/cjs/Cascader/DropdownMenu.js +3 -1
- package/cjs/Cascader/TreeView.js +3 -1
- package/cjs/DOMHelper/index.d.ts +23 -32
- package/cjs/DatePicker/DatePicker.d.ts +6 -0
- package/cjs/DatePicker/DatePicker.js +4 -3
- package/cjs/DateRangePicker/DateRangePicker.js +8 -2
- package/cjs/InlineEdit/EditableControls.d.ts +8 -0
- package/cjs/InlineEdit/EditableControls.js +34 -0
- package/cjs/InlineEdit/InlineEdit.d.ts +56 -0
- package/cjs/InlineEdit/InlineEdit.js +98 -0
- package/cjs/InlineEdit/index.d.ts +3 -0
- package/cjs/InlineEdit/index.js +9 -0
- package/cjs/InlineEdit/renderChildren.d.ts +12 -0
- package/cjs/InlineEdit/renderChildren.js +40 -0
- package/cjs/InlineEdit/useEditState.d.ts +22 -0
- package/cjs/InlineEdit/useEditState.js +82 -0
- package/cjs/InlineEdit/useFocusEvent.d.ts +14 -0
- package/cjs/InlineEdit/useFocusEvent.js +61 -0
- package/cjs/Input/Input.js +6 -3
- package/cjs/InputNumber/InputNumber.d.ts +36 -11
- package/cjs/InputNumber/InputNumber.js +47 -28
- package/cjs/InputPicker/InputPicker.js +6 -5
- package/cjs/Pagination/LimitPicker.d.ts +15 -0
- package/cjs/Pagination/LimitPicker.js +51 -0
- package/cjs/Pagination/Pagination.js +7 -8
- package/cjs/Pagination/PaginationButton.js +3 -18
- package/cjs/Pagination/PaginationGroup.d.ts +35 -7
- package/cjs/Pagination/PaginationGroup.js +77 -98
- package/cjs/RangeSlider/RangeSlider.js +14 -11
- package/cjs/Slider/Handle.js +19 -62
- package/cjs/Slider/ProgressBar.js +2 -1
- package/cjs/Slider/Slider.d.ts +2 -0
- package/cjs/Slider/Slider.js +18 -12
- package/cjs/Slider/useDrag.d.ts +16 -0
- package/cjs/Slider/useDrag.js +88 -0
- package/cjs/Slider/utils.d.ts +6 -2
- package/cjs/Slider/utils.js +15 -1
- package/cjs/index.d.ts +2 -0
- package/cjs/index.js +3 -1
- package/cjs/internals/Overlay/positionUtils.d.ts +1 -6
- package/cjs/internals/Picker/Listbox.d.ts +5 -1
- package/cjs/internals/Picker/Listbox.js +6 -5
- package/cjs/internals/Picker/hooks/usePickerRef.js +2 -0
- package/cjs/internals/Picker/types.d.ts +2 -0
- package/cjs/internals/symbols.d.ts +2 -0
- package/cjs/internals/symbols.js +9 -0
- package/cjs/locales/cs_CZ.d.ts +120 -0
- package/cjs/locales/cs_CZ.js +88 -0
- package/cjs/locales/index.d.ts +1 -0
- package/cjs/locales/index.js +4 -2
- package/cjs/utils/getDataGroupBy.d.ts +0 -1
- package/cjs/utils/getDataGroupBy.js +3 -5
- package/dist/rsuite-no-reset-rtl.css +94 -4
- 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 +94 -4
- package/dist/rsuite-no-reset.min.css +1 -1
- package/dist/rsuite-no-reset.min.css.map +1 -1
- package/dist/rsuite-rtl.css +94 -4
- package/dist/rsuite-rtl.min.css +1 -1
- package/dist/rsuite-rtl.min.css.map +1 -1
- package/dist/rsuite.css +94 -4
- package/dist/rsuite.js +171 -61
- 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/Calendar/CalendarContainer.d.ts +4 -0
- package/esm/Calendar/CalendarContainer.js +3 -1
- package/esm/Calendar/TableCell.js +5 -4
- package/esm/Calendar/types.d.ts +1 -0
- package/esm/Cascader/DropdownMenu.js +3 -1
- package/esm/Cascader/TreeView.js +3 -1
- package/esm/DOMHelper/index.d.ts +23 -32
- package/esm/DatePicker/DatePicker.d.ts +6 -0
- package/esm/DatePicker/DatePicker.js +4 -3
- package/esm/DateRangePicker/DateRangePicker.js +8 -2
- package/esm/InlineEdit/EditableControls.d.ts +8 -0
- package/esm/InlineEdit/EditableControls.js +28 -0
- package/esm/InlineEdit/InlineEdit.d.ts +56 -0
- package/esm/InlineEdit/InlineEdit.js +92 -0
- package/esm/InlineEdit/index.d.ts +3 -0
- package/esm/InlineEdit/index.js +3 -0
- package/esm/InlineEdit/renderChildren.d.ts +12 -0
- package/esm/InlineEdit/renderChildren.js +34 -0
- package/esm/InlineEdit/useEditState.d.ts +22 -0
- package/esm/InlineEdit/useEditState.js +76 -0
- package/esm/InlineEdit/useFocusEvent.d.ts +14 -0
- package/esm/InlineEdit/useFocusEvent.js +56 -0
- package/esm/Input/Input.js +6 -3
- package/esm/InputNumber/InputNumber.d.ts +36 -11
- package/esm/InputNumber/InputNumber.js +49 -30
- package/esm/InputPicker/InputPicker.js +6 -5
- package/esm/Pagination/LimitPicker.d.ts +15 -0
- package/esm/Pagination/LimitPicker.js +44 -0
- package/esm/Pagination/Pagination.js +7 -7
- package/esm/Pagination/PaginationButton.js +4 -18
- package/esm/Pagination/PaginationGroup.d.ts +35 -7
- package/esm/Pagination/PaginationGroup.js +79 -98
- package/esm/RangeSlider/RangeSlider.js +15 -12
- package/esm/Slider/Handle.js +19 -61
- package/esm/Slider/ProgressBar.js +2 -1
- package/esm/Slider/Slider.d.ts +2 -0
- package/esm/Slider/Slider.js +20 -14
- package/esm/Slider/useDrag.d.ts +16 -0
- package/esm/Slider/useDrag.js +82 -0
- package/esm/Slider/utils.d.ts +6 -2
- package/esm/Slider/utils.js +15 -3
- package/esm/index.d.ts +2 -0
- package/esm/index.js +1 -0
- package/esm/internals/Overlay/positionUtils.d.ts +1 -6
- package/esm/internals/Picker/Listbox.d.ts +5 -1
- package/esm/internals/Picker/Listbox.js +7 -6
- package/esm/internals/Picker/hooks/usePickerRef.js +2 -0
- package/esm/internals/Picker/types.d.ts +2 -0
- package/esm/internals/symbols.d.ts +2 -0
- package/esm/internals/symbols.js +3 -0
- package/esm/locales/cs_CZ.d.ts +120 -0
- package/esm/locales/cs_CZ.js +82 -0
- package/esm/locales/index.d.ts +1 -0
- package/esm/locales/index.js +2 -1
- package/esm/utils/getDataGroupBy.d.ts +0 -1
- package/esm/utils/getDataGroupBy.js +2 -3
- package/locales/cs_CZ/package.json +7 -0
- package/package.json +2 -2
- package/styles/color-modes/dark.less +3 -0
- package/styles/color-modes/high-contrast.less +3 -0
- package/styles/color-modes/light.less +3 -0
- package/styles/index.less +1 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useRef } from 'react';
|
|
3
|
+
import { contains, ownerDocument } from 'dom-lib';
|
|
4
|
+
import { useIsomorphicLayoutEffect, useUpdateEffect, useEventCallback } from '../utils';
|
|
5
|
+
import { RSUITE_PICKER_TYPE } from '../internals/symbols';
|
|
6
|
+
var useFocusEvent = function useFocusEvent(_ref) {
|
|
7
|
+
var _ref$current;
|
|
8
|
+
var isEditing = _ref.isEditing,
|
|
9
|
+
stateOnBlur = _ref.stateOnBlur,
|
|
10
|
+
onSave = _ref.onSave,
|
|
11
|
+
onCancel = _ref.onCancel;
|
|
12
|
+
var ref = useRef(null);
|
|
13
|
+
var rootRef = useRef(null);
|
|
14
|
+
var isPicker = ((_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.type) === RSUITE_PICKER_TYPE;
|
|
15
|
+
var focus = function focus() {
|
|
16
|
+
if (isPicker) {
|
|
17
|
+
setTimeout(function () {
|
|
18
|
+
var _ref$current2, _ref$current2$target, _ref$current2$target$;
|
|
19
|
+
(_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : (_ref$current2$target = _ref$current2.target) === null || _ref$current2$target === void 0 ? void 0 : (_ref$current2$target$ = _ref$current2$target.focus) === null || _ref$current2$target$ === void 0 ? void 0 : _ref$current2$target$.call(_ref$current2$target);
|
|
20
|
+
}, 100);
|
|
21
|
+
} else {
|
|
22
|
+
var _ref$current3, _ref$current3$focus;
|
|
23
|
+
(_ref$current3 = ref.current) === null || _ref$current3 === void 0 ? void 0 : (_ref$current3$focus = _ref$current3.focus) === null || _ref$current3$focus === void 0 ? void 0 : _ref$current3$focus.call(_ref$current3);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
var handleBlur = useEventCallback(function (event) {
|
|
27
|
+
if (event) {
|
|
28
|
+
var _event$relatedTarget;
|
|
29
|
+
var relatedTarget = (_event$relatedTarget = event.relatedTarget) !== null && _event$relatedTarget !== void 0 ? _event$relatedTarget : ownerDocument(event.currentTarget).activeElement;
|
|
30
|
+
if (rootRef.current && contains(rootRef.current, relatedTarget)) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (stateOnBlur === 'save') {
|
|
35
|
+
onSave === null || onSave === void 0 ? void 0 : onSave(event);
|
|
36
|
+
} else if (stateOnBlur === 'cancel') {
|
|
37
|
+
onCancel === null || onCancel === void 0 ? void 0 : onCancel(event);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
useIsomorphicLayoutEffect(function () {
|
|
41
|
+
if (isEditing) {
|
|
42
|
+
focus();
|
|
43
|
+
}
|
|
44
|
+
}, []);
|
|
45
|
+
useUpdateEffect(function () {
|
|
46
|
+
if (isEditing) {
|
|
47
|
+
focus();
|
|
48
|
+
}
|
|
49
|
+
}, [isEditing]);
|
|
50
|
+
return {
|
|
51
|
+
target: ref,
|
|
52
|
+
root: rootRef,
|
|
53
|
+
onBlur: handleBlur
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
export default useFocusEvent;
|
package/esm/Input/Input.js
CHANGED
|
@@ -29,13 +29,14 @@ var Input = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
29
29
|
size = props.size,
|
|
30
30
|
htmlSize = props.htmlSize,
|
|
31
31
|
plaintext = props.plaintext,
|
|
32
|
+
placeholder = props.placeholder,
|
|
32
33
|
readOnly = props.readOnly,
|
|
33
34
|
onPressEnter = props.onPressEnter,
|
|
34
35
|
onFocus = props.onFocus,
|
|
35
36
|
onBlur = props.onBlur,
|
|
36
37
|
onKeyDown = props.onKeyDown,
|
|
37
38
|
onChange = props.onChange,
|
|
38
|
-
rest = _objectWithoutPropertiesLoose(props, ["className", "classPrefix", "as", "type", "disabled", "value", "defaultValue", "inputRef", "id", "size", "htmlSize", "plaintext", "readOnly", "onPressEnter", "onFocus", "onBlur", "onKeyDown", "onChange"]);
|
|
39
|
+
rest = _objectWithoutPropertiesLoose(props, ["className", "classPrefix", "as", "type", "disabled", "value", "defaultValue", "inputRef", "id", "size", "htmlSize", "plaintext", "placeholder", "readOnly", "onPressEnter", "onFocus", "onBlur", "onKeyDown", "onChange"]);
|
|
39
40
|
var handleKeyDown = function handleKeyDown(event) {
|
|
40
41
|
if (event.key === KEY_VALUES.ENTER) {
|
|
41
42
|
onPressEnter === null || onPressEnter === void 0 ? void 0 : onPressEnter(event);
|
|
@@ -60,7 +61,8 @@ var Input = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
60
61
|
if (plaintext) {
|
|
61
62
|
return /*#__PURE__*/React.createElement(Plaintext, {
|
|
62
63
|
ref: ref,
|
|
63
|
-
localeKey: "unfilled"
|
|
64
|
+
localeKey: "unfilled",
|
|
65
|
+
placeholder: placeholder
|
|
64
66
|
}, typeof value === 'undefined' ? defaultValue : value);
|
|
65
67
|
}
|
|
66
68
|
var inputable = !disabled && !readOnly;
|
|
@@ -80,7 +82,8 @@ var Input = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
80
82
|
defaultValue: defaultValue,
|
|
81
83
|
disabled: disabled,
|
|
82
84
|
readOnly: readOnly,
|
|
83
|
-
size: htmlSize
|
|
85
|
+
size: htmlSize,
|
|
86
|
+
placeholder: placeholder
|
|
84
87
|
}));
|
|
85
88
|
});
|
|
86
89
|
Input.displayName = 'Input';
|
|
@@ -1,29 +1,54 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { WithAsProps, TypeAttributes, FormControlBaseProps } from '../@types/common';
|
|
3
|
-
export interface InputNumberProps<T = number | string> extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'value' | 'defaultValue' | 'onChange' | 'size' | 'prefix'>, WithAsProps, FormControlBaseProps<T> {
|
|
4
|
-
/**
|
|
3
|
+
export interface InputNumberProps<T = number | string | null> extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'value' | 'defaultValue' | 'onChange' | 'size' | 'prefix'>, WithAsProps, FormControlBaseProps<T> {
|
|
4
|
+
/**
|
|
5
|
+
* Button can have different appearances
|
|
6
|
+
*/
|
|
5
7
|
buttonAppearance?: TypeAttributes.Appearance;
|
|
6
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* An input can show that it is disabled
|
|
10
|
+
*/
|
|
7
11
|
disabled?: boolean;
|
|
8
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Format the value of the input
|
|
14
|
+
*/
|
|
15
|
+
formatter?: (value: number | string) => string;
|
|
16
|
+
/**
|
|
17
|
+
* Minimum value
|
|
18
|
+
*/
|
|
9
19
|
min?: number;
|
|
10
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Maximum value
|
|
22
|
+
*/
|
|
11
23
|
max?: number;
|
|
12
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* The value of each step. can be decimal
|
|
26
|
+
*/
|
|
13
27
|
step?: number;
|
|
14
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* Sets the element displayed to the left of the component
|
|
30
|
+
*/
|
|
15
31
|
prefix?: React.ReactNode;
|
|
16
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* Sets the element displayed on the right side of the component
|
|
34
|
+
*/
|
|
17
35
|
postfix?: React.ReactNode;
|
|
18
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* An Input can have different sizes
|
|
38
|
+
*/
|
|
19
39
|
size?: TypeAttributes.Size;
|
|
20
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* Whether the value can be changed through the wheel event
|
|
42
|
+
*/
|
|
21
43
|
scrollable?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Callback function when wheel event is triggered
|
|
46
|
+
*/
|
|
22
47
|
onWheel?: (event: React.WheelEvent) => void;
|
|
23
48
|
}
|
|
24
49
|
/**
|
|
25
50
|
* The `InputNumber` component is used to enter a numerical value.
|
|
26
51
|
* @see https://rsuitejs.com/components/input-number
|
|
27
52
|
*/
|
|
28
|
-
declare const InputNumber: React.ForwardRefExoticComponent<InputNumberProps<string | number> & React.RefAttributes<unknown>>;
|
|
53
|
+
declare const InputNumber: React.ForwardRefExoticComponent<InputNumberProps<string | number | null> & React.RefAttributes<unknown>>;
|
|
29
54
|
export default InputNumber;
|
|
@@ -1,7 +1,7 @@
|
|
|
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, {
|
|
4
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import isNil from 'lodash/isNil';
|
|
7
7
|
import AngleUpIcon from '@rsuite/icons/legacy/AngleUp';
|
|
@@ -11,7 +11,7 @@ import InputGroup from '../InputGroup/InputGroup';
|
|
|
11
11
|
import InputGroupAddon from '../InputGroup/InputGroupAddon';
|
|
12
12
|
import Input from '../Input';
|
|
13
13
|
import Button from '../Button';
|
|
14
|
-
import { partitionHTMLProps, createChainedFunction, useClassNames, useControlled, KEY_VALUES } from '../utils';
|
|
14
|
+
import { partitionHTMLProps, createChainedFunction, useClassNames, useControlled, useEventCallback, KEY_VALUES } from '../utils';
|
|
15
15
|
import { oneOf } from '../internals/propTypes';
|
|
16
16
|
/**
|
|
17
17
|
* Check if the value is a number.
|
|
@@ -79,6 +79,7 @@ var InputNumber = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
79
79
|
_props$classPrefix = props.classPrefix,
|
|
80
80
|
classPrefix = _props$classPrefix === void 0 ? 'input-number' : _props$classPrefix,
|
|
81
81
|
disabled = props.disabled,
|
|
82
|
+
formatter = props.formatter,
|
|
82
83
|
readOnly = props.readOnly,
|
|
83
84
|
plaintext = props.plaintext,
|
|
84
85
|
valueProp = props.value,
|
|
@@ -96,12 +97,17 @@ var InputNumber = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
96
97
|
scrollable = _props$scrollable === void 0 ? true : _props$scrollable,
|
|
97
98
|
onChange = props.onChange,
|
|
98
99
|
onWheel = props.onWheel,
|
|
99
|
-
|
|
100
|
+
onBlur = props.onBlur,
|
|
101
|
+
onFocus = props.onFocus,
|
|
102
|
+
restProps = _objectWithoutPropertiesLoose(props, ["as", "className", "classPrefix", "disabled", "formatter", "readOnly", "plaintext", "value", "defaultValue", "size", "prefix", "postfix", "step", "buttonAppearance", "min", "max", "scrollable", "onChange", "onWheel", "onBlur", "onFocus"]);
|
|
100
103
|
var min = minProp !== null && minProp !== void 0 ? minProp : -Infinity;
|
|
101
104
|
var max = maxProp !== null && maxProp !== void 0 ? maxProp : Infinity;
|
|
102
105
|
var _useControlled = useControlled(valueProp, defaultValue),
|
|
103
106
|
value = _useControlled[0],
|
|
104
107
|
setValue = _useControlled[1];
|
|
108
|
+
var _useState = useState(false),
|
|
109
|
+
isFocused = _useState[0],
|
|
110
|
+
setIsFocused = _useState[1];
|
|
105
111
|
var _useClassNames = useClassNames(classPrefix),
|
|
106
112
|
withClassPrefix = _useClassNames.withClassPrefix,
|
|
107
113
|
merge = _useClassNames.merge,
|
|
@@ -111,13 +117,7 @@ var InputNumber = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
111
117
|
htmlInputProps = _partitionHTMLProps[0],
|
|
112
118
|
rest = _partitionHTMLProps[1];
|
|
113
119
|
var inputRef = useRef();
|
|
114
|
-
var
|
|
115
|
-
if (currentValue !== value) {
|
|
116
|
-
setValue(currentValue);
|
|
117
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(currentValue, event);
|
|
118
|
-
}
|
|
119
|
-
}, [onChange, setValue, value]);
|
|
120
|
-
var getSafeValue = useCallback(function (value) {
|
|
120
|
+
var getSafeValue = function getSafeValue(value) {
|
|
121
121
|
if (!Number.isNaN(value)) {
|
|
122
122
|
if (+value > max) {
|
|
123
123
|
value = max;
|
|
@@ -129,28 +129,34 @@ var InputNumber = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
129
129
|
value = '';
|
|
130
130
|
}
|
|
131
131
|
return value.toString();
|
|
132
|
-
}
|
|
132
|
+
};
|
|
133
|
+
var handleChangeValue = useEventCallback(function (currentValue, event) {
|
|
134
|
+
if (currentValue !== value) {
|
|
135
|
+
setValue(currentValue);
|
|
136
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(currentValue, event);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
133
139
|
|
|
134
140
|
// Increment value by step
|
|
135
|
-
var handleStepUp =
|
|
141
|
+
var handleStepUp = useEventCallback(function (event) {
|
|
136
142
|
var val = +(value || 0);
|
|
137
143
|
var bit = decimals(val, step);
|
|
138
144
|
handleChangeValue(getSafeValue((val + step).toFixed(bit)), event);
|
|
139
|
-
}
|
|
145
|
+
});
|
|
140
146
|
|
|
141
147
|
// Decrement value by step
|
|
142
|
-
var handleStepDown =
|
|
148
|
+
var handleStepDown = useEventCallback(function (event) {
|
|
143
149
|
var val = +(value || 0);
|
|
144
150
|
var bit = decimals(val, step);
|
|
145
151
|
handleChangeValue(getSafeValue((val - step).toFixed(bit)), event);
|
|
146
|
-
}
|
|
152
|
+
});
|
|
147
153
|
|
|
148
154
|
// Disables step up/down button when
|
|
149
155
|
// - InputNumber is disabled/readonly
|
|
150
156
|
// - value reaches max/min limits
|
|
151
157
|
var stepUpDisabled = disabled || readOnly || valueReachesMax(value, max);
|
|
152
158
|
var stepDownDisabled = disabled || readOnly || valueReachesMin(value, min);
|
|
153
|
-
var handleKeyDown =
|
|
159
|
+
var handleKeyDown = useEventCallback(function (event) {
|
|
154
160
|
switch (event.key) {
|
|
155
161
|
case KEY_VALUES.UP:
|
|
156
162
|
event.preventDefault();
|
|
@@ -173,8 +179,8 @@ var InputNumber = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
173
179
|
}
|
|
174
180
|
break;
|
|
175
181
|
}
|
|
176
|
-
}
|
|
177
|
-
var handleWheel =
|
|
182
|
+
});
|
|
183
|
+
var handleWheel = useEventCallback(function (event) {
|
|
178
184
|
if (!scrollable) {
|
|
179
185
|
event.preventDefault();
|
|
180
186
|
return;
|
|
@@ -190,18 +196,19 @@ var InputNumber = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
190
196
|
}
|
|
191
197
|
}
|
|
192
198
|
onWheel === null || onWheel === void 0 ? void 0 : onWheel(event);
|
|
193
|
-
}
|
|
194
|
-
var handleChange =
|
|
199
|
+
});
|
|
200
|
+
var handleChange = useEventCallback(function (value, event) {
|
|
195
201
|
if (!/^-?(?:\d+)?(\.)?\d*$/.test(value) && value !== '') {
|
|
196
202
|
return;
|
|
197
203
|
}
|
|
198
204
|
handleChangeValue(value, event);
|
|
199
|
-
}
|
|
200
|
-
var handleBlur =
|
|
205
|
+
});
|
|
206
|
+
var handleBlur = useEventCallback(function (event) {
|
|
201
207
|
var _event$target;
|
|
202
208
|
var targetValue = Number.parseFloat((_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.value);
|
|
203
209
|
handleChangeValue(getSafeValue(targetValue), event);
|
|
204
|
-
|
|
210
|
+
setIsFocused(false);
|
|
211
|
+
});
|
|
205
212
|
useEffect(function () {
|
|
206
213
|
var wheelListener;
|
|
207
214
|
if (inputRef.current) {
|
|
@@ -214,19 +221,31 @@ var InputNumber = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
214
221
|
(_wheelListener = wheelListener) === null || _wheelListener === void 0 ? void 0 : _wheelListener.off();
|
|
215
222
|
};
|
|
216
223
|
}, [handleWheel, scrollable]);
|
|
224
|
+
var renderValue = function renderValue() {
|
|
225
|
+
if (isNil(value)) {
|
|
226
|
+
return '';
|
|
227
|
+
}
|
|
228
|
+
if (isFocused) {
|
|
229
|
+
return value;
|
|
230
|
+
}
|
|
231
|
+
return formatter ? formatter(value) : value;
|
|
232
|
+
};
|
|
217
233
|
var input = /*#__PURE__*/React.createElement(Input, _extends({}, htmlInputProps, {
|
|
218
|
-
|
|
234
|
+
ref: plaintext ? ref : undefined,
|
|
235
|
+
inputRef: inputRef,
|
|
219
236
|
autoComplete: "off",
|
|
237
|
+
inputMode: "numeric",
|
|
220
238
|
step: step,
|
|
221
|
-
|
|
222
|
-
onChange: handleChange,
|
|
223
|
-
onBlur: createChainedFunction(handleBlur, htmlInputProps === null || htmlInputProps === void 0 ? void 0 : htmlInputProps.onBlur),
|
|
224
|
-
value: isNil(value) ? '' : "" + value,
|
|
239
|
+
value: renderValue(),
|
|
225
240
|
disabled: disabled,
|
|
226
241
|
readOnly: readOnly,
|
|
227
242
|
plaintext: plaintext,
|
|
228
|
-
|
|
229
|
-
|
|
243
|
+
onKeyDown: handleKeyDown,
|
|
244
|
+
onChange: handleChange,
|
|
245
|
+
onBlur: createChainedFunction(handleBlur, onBlur),
|
|
246
|
+
onFocus: createChainedFunction(function () {
|
|
247
|
+
return setIsFocused(true);
|
|
248
|
+
}, onFocus)
|
|
230
249
|
}));
|
|
231
250
|
if (plaintext) {
|
|
232
251
|
return input;
|
|
@@ -25,6 +25,7 @@ import Tag from '../Tag';
|
|
|
25
25
|
import InputAutosize from './InputAutosize';
|
|
26
26
|
import TextBox from './TextBox';
|
|
27
27
|
import InputPickerContext from './InputPickerContext';
|
|
28
|
+
import Stack from '../Stack';
|
|
28
29
|
var convertSize = function convertSize(size) {
|
|
29
30
|
switch (size) {
|
|
30
31
|
case 'lg':
|
|
@@ -636,12 +637,12 @@ var InputPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
636
637
|
if (plaintext) {
|
|
637
638
|
var plaintextProps = {};
|
|
638
639
|
|
|
639
|
-
//
|
|
640
|
-
// for fixing margin-left on tags from 2nd line on
|
|
640
|
+
// When multiple selection, the tag is displayed in a stack layout.
|
|
641
641
|
if (multi && hasValue) {
|
|
642
|
-
plaintextProps.
|
|
643
|
-
|
|
644
|
-
|
|
642
|
+
plaintextProps.as = Stack;
|
|
643
|
+
plaintextProps.spacing = 6;
|
|
644
|
+
plaintextProps.wrap = true;
|
|
645
|
+
plaintextProps.childrenRenderMode = 'clone';
|
|
645
646
|
}
|
|
646
647
|
return /*#__PURE__*/React.createElement(Plaintext, _extends({
|
|
647
648
|
localeKey: "notSelected",
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type SelectPickerProps } from '../SelectPicker';
|
|
3
|
+
import { PaginationLocale } from '../locales';
|
|
4
|
+
import { OnChangeCallback, TypeAttributes } from '../@types/common';
|
|
5
|
+
interface LimitPickerProps extends Omit<SelectPickerProps<any>, 'locale' | 'disabled' | 'data'> {
|
|
6
|
+
disabled?: boolean | ((eventKey: number | string) => boolean);
|
|
7
|
+
limitOptions: number[];
|
|
8
|
+
locale: PaginationLocale;
|
|
9
|
+
limit: number;
|
|
10
|
+
size?: TypeAttributes.Size;
|
|
11
|
+
prefix: (input: string) => string;
|
|
12
|
+
onChangeLimit: OnChangeCallback<any>;
|
|
13
|
+
}
|
|
14
|
+
declare const LimitPicker: (props: LimitPickerProps) => JSX.Element;
|
|
15
|
+
export default LimitPicker;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
4
|
+
import React, { useRef } from 'react';
|
|
5
|
+
import SelectPicker from '../SelectPicker';
|
|
6
|
+
import { tplTransform } from '../utils';
|
|
7
|
+
var LimitPicker = function LimitPicker(props) {
|
|
8
|
+
var disabled = props.disabled,
|
|
9
|
+
limitOptions = props.limitOptions,
|
|
10
|
+
locale = props.locale,
|
|
11
|
+
limit = props.limit,
|
|
12
|
+
onChangeLimit = props.onChangeLimit,
|
|
13
|
+
size = props.size,
|
|
14
|
+
prefix = props.prefix,
|
|
15
|
+
rest = _objectWithoutPropertiesLoose(props, ["disabled", "limitOptions", "locale", "limit", "onChangeLimit", "size", "prefix"]);
|
|
16
|
+
var containerRef = useRef(null);
|
|
17
|
+
var disabledPicker = typeof disabled === 'function' ? disabled('picker') : Boolean(disabled);
|
|
18
|
+
var formatlimitOptions = limitOptions.map(function (item) {
|
|
19
|
+
return {
|
|
20
|
+
value: item,
|
|
21
|
+
label: locale.limit && tplTransform(locale.limit, item)
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
25
|
+
className: prefix('limit'),
|
|
26
|
+
ref: containerRef
|
|
27
|
+
}, /*#__PURE__*/React.createElement(SelectPicker, _extends({}, rest, {
|
|
28
|
+
size: size,
|
|
29
|
+
cleanable: false,
|
|
30
|
+
searchable: false,
|
|
31
|
+
placement: "topStart",
|
|
32
|
+
data: formatlimitOptions,
|
|
33
|
+
value: limit,
|
|
34
|
+
onChange: onChangeLimit,
|
|
35
|
+
menuStyle: {
|
|
36
|
+
minWidth: 'auto'
|
|
37
|
+
},
|
|
38
|
+
disabled: disabledPicker,
|
|
39
|
+
container: function container() {
|
|
40
|
+
return containerRef.current;
|
|
41
|
+
}
|
|
42
|
+
})));
|
|
43
|
+
};
|
|
44
|
+
export default LimitPicker;
|
|
@@ -3,7 +3,7 @@ import _taggedTemplateLiteralLoose from "@babel/runtime/helpers/esm/taggedTempla
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
5
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
|
|
6
|
-
import React
|
|
6
|
+
import React from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import More from '@rsuite/icons/legacy/More';
|
|
9
9
|
import PagePrevious from '@rsuite/icons/legacy/PagePrevious';
|
|
@@ -55,13 +55,13 @@ var Pagination = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
55
55
|
prefix = _useClassNames.prefix;
|
|
56
56
|
var _useCustom = useCustom('Pagination', overrideLocale),
|
|
57
57
|
locale = _useCustom.locale;
|
|
58
|
-
var renderItem =
|
|
58
|
+
var renderItem = function renderItem(key, itemProps) {
|
|
59
59
|
var eventKey = itemProps.eventKey,
|
|
60
60
|
disabled = itemProps.disabled,
|
|
61
61
|
itemRest = _objectWithoutPropertiesLoose(itemProps, ["eventKey", "disabled"]);
|
|
62
|
-
var
|
|
62
|
+
var disabledButton = disabled;
|
|
63
63
|
if (typeof disabledProp !== 'undefined') {
|
|
64
|
-
|
|
64
|
+
disabledButton = typeof disabledProp === 'function' ? disabledProp(eventKey) : disabledProp;
|
|
65
65
|
}
|
|
66
66
|
var title = (locale === null || locale === void 0 ? void 0 : locale[key]) || eventKey;
|
|
67
67
|
return /*#__PURE__*/React.createElement(PaginationButton, _extends({
|
|
@@ -71,10 +71,10 @@ var Pagination = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
71
71
|
key: key + "-" + eventKey,
|
|
72
72
|
eventKey: eventKey,
|
|
73
73
|
as: linkAs,
|
|
74
|
-
disabled:
|
|
75
|
-
onSelect:
|
|
74
|
+
disabled: disabledButton,
|
|
75
|
+
onSelect: disabledButton ? undefined : onSelect
|
|
76
76
|
}));
|
|
77
|
-
}
|
|
77
|
+
};
|
|
78
78
|
var renderFirst = function renderFirst() {
|
|
79
79
|
if (!first) {
|
|
80
80
|
return null;
|
|
@@ -1,10 +1,9 @@
|
|
|
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 PropTypes from 'prop-types';
|
|
4
|
+
import React from 'react';
|
|
6
5
|
import Ripple from '../internals/Ripple';
|
|
7
|
-
import { useClassNames, createChainedFunction } from '../utils';
|
|
6
|
+
import { useClassNames, useEventCallback, createChainedFunction } from '../utils';
|
|
8
7
|
var PaginationButton = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
9
8
|
var _props$as = props.as,
|
|
10
9
|
Component = _props$as === void 0 ? 'button' : _props$as,
|
|
@@ -26,12 +25,12 @@ var PaginationButton = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
26
25
|
active: active,
|
|
27
26
|
disabled: disabled
|
|
28
27
|
}));
|
|
29
|
-
var handleClick =
|
|
28
|
+
var handleClick = useEventCallback(function (event) {
|
|
30
29
|
if (disabled) {
|
|
31
30
|
return;
|
|
32
31
|
}
|
|
33
32
|
onSelect === null || onSelect === void 0 ? void 0 : onSelect(eventKey, event);
|
|
34
|
-
}
|
|
33
|
+
});
|
|
35
34
|
var asProps = {};
|
|
36
35
|
if (typeof Component !== 'string') {
|
|
37
36
|
asProps.eventKey = eventKey;
|
|
@@ -46,17 +45,4 @@ var PaginationButton = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
46
45
|
}), children, !disabled ? /*#__PURE__*/React.createElement(Ripple, null) : null);
|
|
47
46
|
});
|
|
48
47
|
PaginationButton.displayName = 'PaginationButton';
|
|
49
|
-
PaginationButton.propTypes = {
|
|
50
|
-
classPrefix: PropTypes.string,
|
|
51
|
-
eventKey: PropTypes.any,
|
|
52
|
-
onSelect: PropTypes.func,
|
|
53
|
-
onClick: PropTypes.func,
|
|
54
|
-
disabled: PropTypes.bool,
|
|
55
|
-
active: PropTypes.bool,
|
|
56
|
-
className: PropTypes.string,
|
|
57
|
-
as: PropTypes.elementType,
|
|
58
|
-
children: PropTypes.node,
|
|
59
|
-
style: PropTypes.object,
|
|
60
|
-
renderItem: PropTypes.func
|
|
61
|
-
};
|
|
62
48
|
export default PaginationButton;
|
|
@@ -1,19 +1,47 @@
|
|
|
1
1
|
import { PaginationProps } from './Pagination';
|
|
2
2
|
import { RsRefForwardingComponent } from '../@types/common';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* The layout of the paging component.
|
|
5
|
+
*/
|
|
6
|
+
declare type LayoutType = 'total' | 'pager' | 'limit' | 'skip' | '-' | '|';
|
|
4
7
|
export interface PaginationGroupProps extends PaginationProps {
|
|
5
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* Customize the layout of a paging component.
|
|
10
|
+
* - `total` Component used to display the total.
|
|
11
|
+
* - `pager` Component used to display the page number.
|
|
12
|
+
* - `limit` Component used to display the number of rows per page.
|
|
13
|
+
* - `skip` Component used to jump to a page.
|
|
14
|
+
* - `-` Placeholder, take up the remaining space.
|
|
15
|
+
* - `|` Divider
|
|
16
|
+
*
|
|
17
|
+
* @default ['pager']
|
|
18
|
+
*/
|
|
6
19
|
layout?: LayoutType[];
|
|
7
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Customizes the options of the rows per page select field.
|
|
22
|
+
*/
|
|
8
23
|
limitOptions?: number[];
|
|
9
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* Customize the layout of a paging component.
|
|
26
|
+
*/
|
|
10
27
|
limit?: number;
|
|
11
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* Total number of data entries.
|
|
30
|
+
*/
|
|
12
31
|
total: number;
|
|
13
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* Callback fired when the page is changed.
|
|
34
|
+
*/
|
|
14
35
|
onChangePage?: (page: number) => void;
|
|
15
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* Callback fired when the number of rows per page is changed.
|
|
38
|
+
*/
|
|
16
39
|
onChangeLimit?: (limit: number) => void;
|
|
17
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Pagination component for displaying page numbers.
|
|
43
|
+
*
|
|
44
|
+
* @see https://rsuitejs.com/components/pagination
|
|
45
|
+
*/
|
|
18
46
|
declare const PaginationGroup: RsRefForwardingComponent<'div', PaginationGroupProps>;
|
|
19
47
|
export default PaginationGroup;
|