rsuite 5.54.0 → 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/CHANGELOG.md +18 -0
- package/Pagination/styles/index.css +3 -0
- package/Pagination/styles/pagination-group.less +4 -0
- 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 +3 -2
- package/cjs/DateRangePicker/DateRangePicker.js +3 -2
- package/cjs/InputNumber/InputNumber.d.ts +36 -11
- package/cjs/InputNumber/InputNumber.js +47 -28
- 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.js +14 -10
- 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/internals/Overlay/positionUtils.d.ts +1 -6
- 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/dist/rsuite-no-reset-rtl.css +3 -0
- 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 +3 -0
- package/dist/rsuite-no-reset.min.css +1 -1
- package/dist/rsuite-no-reset.min.css.map +1 -1
- package/dist/rsuite-rtl.css +3 -0
- package/dist/rsuite-rtl.min.css +1 -1
- package/dist/rsuite-rtl.min.css.map +1 -1
- package/dist/rsuite.css +3 -0
- package/dist/rsuite.js +88 -55
- 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 +3 -2
- package/esm/DateRangePicker/DateRangePicker.js +3 -2
- package/esm/InputNumber/InputNumber.d.ts +36 -11
- package/esm/InputNumber/InputNumber.js +49 -30
- 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.js +16 -12
- 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/internals/Overlay/positionUtils.d.ts +1 -6
- 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/locales/cs_CZ/package.json +7 -0
- package/package.json +2 -2
|
@@ -58,6 +58,10 @@ export interface CalendarProps extends WithAsProps, Omit<HTMLAttributes<HTMLDivE
|
|
|
58
58
|
onSelect?: (date: Date, event: React.MouseEvent) => void;
|
|
59
59
|
/** Custom rendering cell*/
|
|
60
60
|
renderCell?: (date: Date) => React.ReactNode;
|
|
61
|
+
/**
|
|
62
|
+
* Custom rendering cell on the picker
|
|
63
|
+
*/
|
|
64
|
+
renderCellOnPicker?: (date: Date) => React.ReactNode;
|
|
61
65
|
/** Custom cell classes base on it's date */
|
|
62
66
|
cellClassName?: (date: Date) => string | undefined;
|
|
63
67
|
/** Called when opening the month view */
|
|
@@ -44,12 +44,13 @@ var CalendarContainer = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
44
44
|
calendarDateProp = props.calendarDate,
|
|
45
45
|
cellClassName = props.cellClassName,
|
|
46
46
|
renderCell = props.renderCell,
|
|
47
|
+
renderCellOnPicker = props.renderCellOnPicker,
|
|
47
48
|
renderTitle = props.renderTitle,
|
|
48
49
|
renderToolbar = props.renderToolbar,
|
|
49
50
|
showMeridian = props.showMeridian,
|
|
50
51
|
showWeekNumbers = props.showWeekNumbers,
|
|
51
52
|
inline = props.inline,
|
|
52
|
-
rest = _objectWithoutPropertiesLoose(props, ["as", "className", "classPrefix", "dateRange", "disabledBackward", "defaultState", "disabledDate", "disabledForward", "format", "hoverRangeValue", "isoWeek", "targetId", "limitEndYear", "limitStartYear", "locale", "onChangeMonth", "onChangeTime", "onMouseMove", "onMoveBackward", "onMoveForward", "onSelect", "onToggleMeridian", "onToggleMonthDropdown", "onToggleTimeDropdown", "calendarDate", "cellClassName", "renderCell", "renderTitle", "renderToolbar", "showMeridian", "showWeekNumbers", "inline"]);
|
|
53
|
+
rest = _objectWithoutPropertiesLoose(props, ["as", "className", "classPrefix", "dateRange", "disabledBackward", "defaultState", "disabledDate", "disabledForward", "format", "hoverRangeValue", "isoWeek", "targetId", "limitEndYear", "limitStartYear", "locale", "onChangeMonth", "onChangeTime", "onMouseMove", "onMoveBackward", "onMoveForward", "onSelect", "onToggleMeridian", "onToggleMonthDropdown", "onToggleTimeDropdown", "calendarDate", "cellClassName", "renderCell", "renderCellOnPicker", "renderTitle", "renderToolbar", "showMeridian", "showWeekNumbers", "inline"]);
|
|
53
54
|
var _useClassNames = useClassNames(classPrefix),
|
|
54
55
|
withClassPrefix = _useClassNames.withClassPrefix,
|
|
55
56
|
merge = _useClassNames.merge,
|
|
@@ -134,6 +135,7 @@ var CalendarContainer = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
134
135
|
onSelect: onSelect,
|
|
135
136
|
cellClassName: cellClassName,
|
|
136
137
|
renderCell: renderCell,
|
|
138
|
+
renderCellOnPicker: renderCellOnPicker,
|
|
137
139
|
showWeekNumbers: showWeekNumbers,
|
|
138
140
|
inline: inline
|
|
139
141
|
};
|
|
@@ -3,8 +3,8 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
3
3
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import partial from 'lodash/partial';
|
|
6
|
-
import {
|
|
7
|
-
import { isSameDay } from '../utils/dateUtils';
|
|
6
|
+
import { useClassNames, useCustom } from '../utils';
|
|
7
|
+
import { isSameDay, getDate } from '../utils/dateUtils';
|
|
8
8
|
import { useCalendarContext } from './CalendarContext';
|
|
9
9
|
import { getAriaLabel } from './utils';
|
|
10
10
|
var TableCell = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
@@ -25,6 +25,7 @@ var TableCell = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
25
25
|
onMouseMove = _useCalendarContext.onMouseMove,
|
|
26
26
|
cellClassName = _useCalendarContext.cellClassName,
|
|
27
27
|
renderCell = _useCalendarContext.renderCell,
|
|
28
|
+
renderCellOnPicker = _useCalendarContext.renderCellOnPicker,
|
|
28
29
|
overrideLocale = _useCalendarContext.locale;
|
|
29
30
|
var _useClassNames = useClassNames(classPrefix),
|
|
30
31
|
prefix = _useClassNames.prefix,
|
|
@@ -58,9 +59,9 @@ var TableCell = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
58
59
|
onClick: onSelect ? partial(onSelect, date, disabled) : undefined
|
|
59
60
|
}, rest), /*#__PURE__*/React.createElement("div", {
|
|
60
61
|
className: prefix('cell-content')
|
|
61
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
62
|
+
}, renderCellOnPicker ? renderCellOnPicker(date) : /*#__PURE__*/React.createElement("span", {
|
|
62
63
|
className: prefix('cell-day')
|
|
63
|
-
},
|
|
64
|
+
}, getDate(date)), renderCell === null || renderCell === void 0 ? void 0 : renderCell(date)));
|
|
64
65
|
});
|
|
65
66
|
TableCell.displayName = 'CalendarTableCell';
|
|
66
67
|
export default TableCell;
|
package/esm/Calendar/types.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export interface CalendarInnerContextValue {
|
|
|
13
13
|
onMouseMove?: (date: Date) => void;
|
|
14
14
|
onSelect?: (date: Date, event: React.MouseEvent) => void;
|
|
15
15
|
renderCell?: (date: Date) => React.ReactNode;
|
|
16
|
+
renderCellOnPicker?: (date: Date) => React.ReactNode;
|
|
16
17
|
cellClassName?: (date: Date) => string | undefined;
|
|
17
18
|
showWeekNumbers?: boolean;
|
|
18
19
|
inline?: boolean;
|
|
@@ -65,7 +65,9 @@ var TreeView = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
65
65
|
if (activeItem) {
|
|
66
66
|
var position = getPosition(activeItem, column);
|
|
67
67
|
// Let the active option scroll into view.
|
|
68
|
-
|
|
68
|
+
if (position !== null && position !== void 0 && position.top) {
|
|
69
|
+
scrollTop(column, position === null || position === void 0 ? void 0 : position.top);
|
|
70
|
+
}
|
|
69
71
|
}
|
|
70
72
|
});
|
|
71
73
|
}, [prefix]);
|
package/esm/Cascader/TreeView.js
CHANGED
|
@@ -65,7 +65,9 @@ var TreeView = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
65
65
|
if (activeItem) {
|
|
66
66
|
var position = getPosition(activeItem, column);
|
|
67
67
|
// Let the active option scroll into view.
|
|
68
|
-
|
|
68
|
+
if (position !== null && position !== void 0 && position.top) {
|
|
69
|
+
scrollTop(column, position === null || position === void 0 ? void 0 : position.top);
|
|
70
|
+
}
|
|
69
71
|
}
|
|
70
72
|
});
|
|
71
73
|
}, [prefix]);
|
package/esm/DOMHelper/index.d.ts
CHANGED
|
@@ -11,43 +11,34 @@ declare const DOMHelper: {
|
|
|
11
11
|
off: typeof helpers.off;
|
|
12
12
|
WheelHandler: typeof helpers.WheelHandler;
|
|
13
13
|
DOMMouseMoveTracker: typeof helpers.DOMMouseMoveTracker;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
PointerMoveTracker: typeof helpers.PointerMoveTracker;
|
|
15
|
+
addClass: typeof helpers.addClass;
|
|
16
|
+
removeClass: typeof helpers.removeClass;
|
|
17
|
+
hasClass: typeof helpers.hasClass;
|
|
18
|
+
toggleClass: typeof helpers.toggleClass;
|
|
19
|
+
cancelAnimationFramePolyfill: typeof cancelAnimationFrame;
|
|
19
20
|
requestAnimationFramePolyfill: typeof requestAnimationFrame | ((callback: (t: number) => void) => NodeJS.Timeout);
|
|
20
21
|
getAnimationEnd: typeof helpers.getAnimationEnd;
|
|
21
|
-
ownerDocument:
|
|
22
|
-
ownerWindow:
|
|
23
|
-
getWindow:
|
|
24
|
-
getContainer:
|
|
22
|
+
ownerDocument: typeof helpers.ownerDocument;
|
|
23
|
+
ownerWindow: typeof helpers.ownerWindow;
|
|
24
|
+
getWindow: typeof helpers.getWindow;
|
|
25
|
+
getContainer: typeof helpers.getContainer;
|
|
25
26
|
canUseDOM: boolean;
|
|
26
27
|
contains: (context: Element, node: Node & ParentNode) => boolean;
|
|
27
|
-
scrollTop:
|
|
28
|
-
scrollLeft:
|
|
29
|
-
getOffset:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
getPosition: (node: Element, offsetParent?: Element | undefined, calcMargin?: boolean | undefined) => DOMRect | {
|
|
38
|
-
top: number;
|
|
39
|
-
left: number;
|
|
40
|
-
height: number;
|
|
41
|
-
width: number;
|
|
42
|
-
} | null;
|
|
43
|
-
isOverflowing: (container: Element) => boolean;
|
|
44
|
-
getScrollbarSize: (recalc?: boolean | undefined) => number | void;
|
|
45
|
-
getHeight: (node: Element | Window, client?: Element | undefined) => number;
|
|
46
|
-
getWidth: (node: Element | Window, client?: Element | undefined) => number;
|
|
28
|
+
scrollTop: typeof helpers.scrollTop;
|
|
29
|
+
scrollLeft: typeof helpers.scrollLeft;
|
|
30
|
+
getOffset: typeof helpers.getOffset;
|
|
31
|
+
nodeName: typeof helpers.nodeName;
|
|
32
|
+
getOffsetParent: typeof helpers.getOffsetParent;
|
|
33
|
+
getPosition: typeof helpers.getPosition;
|
|
34
|
+
isOverflowing: typeof helpers.isOverflowing;
|
|
35
|
+
getScrollbarSize: typeof helpers.getScrollbarSize;
|
|
36
|
+
getHeight: typeof helpers.getHeight;
|
|
37
|
+
getWidth: typeof helpers.getWidth;
|
|
47
38
|
isFocusable: typeof helpers.isFocusable;
|
|
48
|
-
getStyle:
|
|
49
|
-
removeStyle:
|
|
50
|
-
addStyle:
|
|
39
|
+
getStyle: typeof helpers.getStyle;
|
|
40
|
+
removeStyle: typeof helpers.removeStyle;
|
|
41
|
+
addStyle: typeof helpers.addStyle;
|
|
51
42
|
translateDOMPositionXY: (style: CSSStyleDeclaration, x?: number | undefined, y?: number | undefined) => CSSStyleDeclaration;
|
|
52
43
|
};
|
|
53
44
|
export default DOMHelper;
|
|
@@ -117,6 +117,12 @@ export interface DatePickerProps extends PickerBaseProps<DatePickerLocale>, Form
|
|
|
117
117
|
* @deprecated
|
|
118
118
|
*/
|
|
119
119
|
renderValue?: (value: Date, format: string) => string;
|
|
120
|
+
/**
|
|
121
|
+
* Custom rendering calendar cell content.
|
|
122
|
+
*
|
|
123
|
+
* @version 5.54.0
|
|
124
|
+
*/
|
|
125
|
+
renderCell?: (date: Date) => React.ReactNode;
|
|
120
126
|
}
|
|
121
127
|
/**
|
|
122
128
|
* A date picker allows users to select a date from a calendar.
|
|
@@ -95,7 +95,8 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
95
95
|
onToggleMonthDropdown = props.onToggleMonthDropdown,
|
|
96
96
|
onToggleTimeDropdown = props.onToggleTimeDropdown,
|
|
97
97
|
onShortcutClick = props.onShortcutClick,
|
|
98
|
-
|
|
98
|
+
renderCell = props.renderCell,
|
|
99
|
+
restProps = _objectWithoutPropertiesLoose(props, ["as", "className", "classPrefix", "calendarDefaultDate", "cleanable", "editable", "defaultValue", "disabled", "readOnly", "plaintext", "format", "id", "isoWeek", "limitEndYear", "limitStartYear", "locale", "loading", "label", "menuClassName", "menuStyle", "appearance", "placement", "oneTap", "placeholder", "ranges", "value", "showMeridian", "showWeekNumbers", "style", "size", "caretAs", "disabledDate", "disabledHours", "disabledMinutes", "disabledSeconds", "shouldDisableDate", "shouldDisableHour", "shouldDisableMinute", "shouldDisableSecond", "onChange", "onChangeCalendarDate", "onClean", "onClose", "onEntered", "onExited", "onNextMonth", "onOk", "onOpen", "onPrevMonth", "onSelect", "onToggleMonthDropdown", "onToggleTimeDropdown", "onShortcutClick", "renderCell"]);
|
|
99
100
|
var id = useUniqueId('rs-', idProp);
|
|
100
101
|
var _usePickerRef = usePickerRef(ref),
|
|
101
102
|
trigger = _usePickerRef.trigger,
|
|
@@ -451,6 +452,7 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
451
452
|
format: formatStr,
|
|
452
453
|
isoWeek: isoWeek,
|
|
453
454
|
calendarDate: calendarDate,
|
|
455
|
+
renderCellOnPicker: renderCell,
|
|
454
456
|
onMoveForward: handleMoveForward,
|
|
455
457
|
onMoveBackward: handleMoveBackward,
|
|
456
458
|
onSelect: handleSelect,
|
|
@@ -576,7 +578,6 @@ DatePicker.propTypes = _extends({}, pickerPropTypes, {
|
|
|
576
578
|
onToggleMonthDropdown: PropTypes.func,
|
|
577
579
|
onToggleTimeDropdown: PropTypes.func,
|
|
578
580
|
oneTap: PropTypes.bool,
|
|
579
|
-
panelContainerRef: PropTypes.any,
|
|
580
581
|
ranges: PropTypes.array,
|
|
581
582
|
showMeridian: PropTypes.bool,
|
|
582
583
|
showWeekNumbers: PropTypes.bool,
|
|
@@ -166,7 +166,7 @@ var DateRangePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
166
166
|
var nextValue = dateRange;
|
|
167
167
|
|
|
168
168
|
// The time should remain the same when the dates in the date range are changed.
|
|
169
|
-
if (shouldRenderTime(formatStr) && dateRange !== null && dateRange !== void 0 && dateRange.length && eventName !== 'changeTime') {
|
|
169
|
+
if (shouldRenderTime(formatStr) && dateRange !== null && dateRange !== void 0 && dateRange.length && eventName !== 'changeTime' && eventName !== 'shortcutSelection') {
|
|
170
170
|
var _startDate = copyTime({
|
|
171
171
|
from: getCalendarDatetime('start'),
|
|
172
172
|
to: dateRange[0]
|
|
@@ -441,7 +441,8 @@ var DateRangePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
441
441
|
}
|
|
442
442
|
var value = range.value;
|
|
443
443
|
setCalendarDateRange({
|
|
444
|
-
dateRange: value
|
|
444
|
+
dateRange: value,
|
|
445
|
+
eventName: 'shortcutSelection'
|
|
445
446
|
});
|
|
446
447
|
if (closeOverlay) {
|
|
447
448
|
setDateRange(event, value, closeOverlay);
|
|
@@ -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;
|
|
@@ -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;
|