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
|
@@ -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,
|
|
@@ -437,7 +438,7 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
437
438
|
locale: locale,
|
|
438
439
|
disabledShortcut: disabledToolbarHandle,
|
|
439
440
|
onShortcutClick: handleShortcutPageDate
|
|
440
|
-
}), /*#__PURE__*/React.createElement(
|
|
441
|
+
}), /*#__PURE__*/React.createElement(Stack.Item, null, /*#__PURE__*/React.createElement(CalendarContainer, _extends({}, calendarProps, {
|
|
441
442
|
targetId: id,
|
|
442
443
|
locale: locale,
|
|
443
444
|
showWeekNumbers: showWeekNumbers,
|
|
@@ -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);
|
|
@@ -668,6 +669,11 @@ var DateRangePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
668
669
|
if (!value) {
|
|
669
670
|
return false;
|
|
670
671
|
}
|
|
672
|
+
|
|
673
|
+
// If the value is an empty array, it is not an error value.
|
|
674
|
+
if (Array.isArray(value) && value.length === 0) {
|
|
675
|
+
return false;
|
|
676
|
+
}
|
|
671
677
|
var startDate = value[0],
|
|
672
678
|
endDate = value[1];
|
|
673
679
|
if (!isValid(startDate) || !isValid(endDate)) {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type StackProps } from '../Stack';
|
|
3
|
+
interface EditableControlsProps extends StackProps {
|
|
4
|
+
onSave: () => void;
|
|
5
|
+
onCancel: () => void;
|
|
6
|
+
}
|
|
7
|
+
declare const EditableControls: React.ForwardRefExoticComponent<EditableControlsProps & React.RefAttributes<HTMLDivElement>>;
|
|
8
|
+
export default EditableControls;
|
|
@@ -0,0 +1,28 @@
|
|
|
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 CheckIcon from '@rsuite/icons/Check';
|
|
6
|
+
import CloseIcon from '@rsuite/icons/Close';
|
|
7
|
+
import IconButton from '../IconButton';
|
|
8
|
+
import Stack from '../Stack';
|
|
9
|
+
var EditableControls = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
10
|
+
var onSave = props.onSave,
|
|
11
|
+
onCancel = props.onCancel,
|
|
12
|
+
rest = _objectWithoutPropertiesLoose(props, ["onSave", "onCancel"]);
|
|
13
|
+
return /*#__PURE__*/React.createElement(Stack, _extends({
|
|
14
|
+
ref: ref,
|
|
15
|
+
spacing: 6
|
|
16
|
+
}, rest), /*#__PURE__*/React.createElement(IconButton, {
|
|
17
|
+
size: "sm",
|
|
18
|
+
icon: /*#__PURE__*/React.createElement(CheckIcon, null),
|
|
19
|
+
"aria-label": "Save",
|
|
20
|
+
onClick: onSave
|
|
21
|
+
}), /*#__PURE__*/React.createElement(IconButton, {
|
|
22
|
+
size: "sm",
|
|
23
|
+
icon: /*#__PURE__*/React.createElement(CloseIcon, null),
|
|
24
|
+
"aria-label": "Cancel",
|
|
25
|
+
onClick: onCancel
|
|
26
|
+
}));
|
|
27
|
+
});
|
|
28
|
+
export default EditableControls;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { WithAsProps, RsRefForwardingComponent } from '../@types/common';
|
|
3
|
+
import { type ChildrenProps } from './renderChildren';
|
|
4
|
+
export interface InlineEditProps extends WithAsProps {
|
|
5
|
+
/**
|
|
6
|
+
* If true, the InlineEdit will be disabled.
|
|
7
|
+
*/
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* The initial value of the InlineEdit when it is not controlled.
|
|
11
|
+
*/
|
|
12
|
+
defaultValue?: any;
|
|
13
|
+
/**
|
|
14
|
+
* The value of the InlineEdit.
|
|
15
|
+
*/
|
|
16
|
+
value?: any;
|
|
17
|
+
/**
|
|
18
|
+
* show the control buttons when editing.
|
|
19
|
+
* @default true
|
|
20
|
+
*/
|
|
21
|
+
showControls?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* The placeholder of the InlineEdit.
|
|
24
|
+
*/
|
|
25
|
+
placeholder?: string;
|
|
26
|
+
/**
|
|
27
|
+
* The size of the InlineEdit.
|
|
28
|
+
*/
|
|
29
|
+
size?: 'lg' | 'md' | 'sm' | 'xs';
|
|
30
|
+
/**
|
|
31
|
+
* The state of the InlineEdit when it is blurred.
|
|
32
|
+
*/
|
|
33
|
+
stateOnBlur?: 'save' | 'cancel';
|
|
34
|
+
/**
|
|
35
|
+
* The callback function that is called when the value of the InlineEdit is changed.
|
|
36
|
+
*/
|
|
37
|
+
onChange?: (value: any, event: React.ChangeEvent) => void;
|
|
38
|
+
/**
|
|
39
|
+
* The callback function that is called when the InlineEdit is canceled.
|
|
40
|
+
*/
|
|
41
|
+
onCancel?: (event?: React.SyntheticEvent) => void;
|
|
42
|
+
/**
|
|
43
|
+
* The callback function that is called when the InlineEdit is saved.
|
|
44
|
+
*/
|
|
45
|
+
onSave?: (event?: React.SyntheticEvent) => void;
|
|
46
|
+
/**
|
|
47
|
+
* The callback function that is called when the InlineEdit is clicked.
|
|
48
|
+
*/
|
|
49
|
+
onEdit?: (event: React.SyntheticEvent) => void;
|
|
50
|
+
/**
|
|
51
|
+
* The render function of the InlineEdit.
|
|
52
|
+
*/
|
|
53
|
+
children?: ((props: ChildrenProps, ref: React.Ref<any>) => React.ReactElement) | React.ReactElement;
|
|
54
|
+
}
|
|
55
|
+
declare const InlineEdit: RsRefForwardingComponent<'div', InlineEditProps>;
|
|
56
|
+
export default InlineEdit;
|
|
@@ -0,0 +1,92 @@
|
|
|
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 PropTypes from 'prop-types';
|
|
6
|
+
import { useClassNames, mergeRefs } from '../utils';
|
|
7
|
+
import { oneOf } from '../internals/propTypes';
|
|
8
|
+
import EditableControls from './EditableControls';
|
|
9
|
+
import useFocusEvent from './useFocusEvent';
|
|
10
|
+
import useEditState from './useEditState';
|
|
11
|
+
import { renderChildren, defaultRenderInput } from './renderChildren';
|
|
12
|
+
var InlineEdit = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
13
|
+
var _props$as = props.as,
|
|
14
|
+
Component = _props$as === void 0 ? 'div' : _props$as,
|
|
15
|
+
_props$children = props.children,
|
|
16
|
+
children = _props$children === void 0 ? defaultRenderInput : _props$children,
|
|
17
|
+
_props$classPrefix = props.classPrefix,
|
|
18
|
+
classPrefix = _props$classPrefix === void 0 ? 'inline-edit' : _props$classPrefix,
|
|
19
|
+
className = props.className,
|
|
20
|
+
disabled = props.disabled,
|
|
21
|
+
size = props.size,
|
|
22
|
+
_props$showControls = props.showControls,
|
|
23
|
+
showControls = _props$showControls === void 0 ? true : _props$showControls,
|
|
24
|
+
_props$stateOnBlur = props.stateOnBlur,
|
|
25
|
+
stateOnBlur = _props$stateOnBlur === void 0 ? 'save' : _props$stateOnBlur,
|
|
26
|
+
placeholder = props.placeholder,
|
|
27
|
+
rest = _objectWithoutPropertiesLoose(props, ["as", "children", "classPrefix", "className", "disabled", "size", "showControls", "stateOnBlur", "placeholder"]);
|
|
28
|
+
var _useClassNames = useClassNames(classPrefix),
|
|
29
|
+
withClassPrefix = _useClassNames.withClassPrefix,
|
|
30
|
+
merge = _useClassNames.merge,
|
|
31
|
+
prefix = _useClassNames.prefix;
|
|
32
|
+
var _useEditState = useEditState(_extends({}, rest, {
|
|
33
|
+
disabled: disabled
|
|
34
|
+
})),
|
|
35
|
+
value = _useEditState.value,
|
|
36
|
+
isEditing = _useEditState.isEditing,
|
|
37
|
+
onSave = _useEditState.onSave,
|
|
38
|
+
onCancel = _useEditState.onCancel,
|
|
39
|
+
onChange = _useEditState.onChange,
|
|
40
|
+
onKeyDown = _useEditState.onKeyDown,
|
|
41
|
+
onClick = _useEditState.onClick,
|
|
42
|
+
htmlProps = _useEditState.htmlProps;
|
|
43
|
+
var _useFocusEvent = useFocusEvent({
|
|
44
|
+
isEditing: isEditing,
|
|
45
|
+
stateOnBlur: stateOnBlur,
|
|
46
|
+
onSave: onSave,
|
|
47
|
+
onCancel: onCancel
|
|
48
|
+
}),
|
|
49
|
+
target = _useFocusEvent.target,
|
|
50
|
+
root = _useFocusEvent.root,
|
|
51
|
+
onBlur = _useFocusEvent.onBlur;
|
|
52
|
+
var childrenProps = {
|
|
53
|
+
size: size,
|
|
54
|
+
value: value,
|
|
55
|
+
disabled: disabled,
|
|
56
|
+
placeholder: placeholder,
|
|
57
|
+
plaintext: !isEditing,
|
|
58
|
+
onChange: onChange,
|
|
59
|
+
onBlur: onBlur
|
|
60
|
+
};
|
|
61
|
+
return /*#__PURE__*/React.createElement(Component, _extends({
|
|
62
|
+
ref: mergeRefs(root, ref),
|
|
63
|
+
tabIndex: 0,
|
|
64
|
+
className: merge(className, withClassPrefix(size, {
|
|
65
|
+
disabled: disabled
|
|
66
|
+
})),
|
|
67
|
+
onClick: onClick,
|
|
68
|
+
onKeyDown: onKeyDown
|
|
69
|
+
}, htmlProps), renderChildren(children, childrenProps, target), showControls && isEditing && /*#__PURE__*/React.createElement(EditableControls, {
|
|
70
|
+
className: prefix('controls'),
|
|
71
|
+
onSave: onSave,
|
|
72
|
+
onCancel: onCancel
|
|
73
|
+
}));
|
|
74
|
+
});
|
|
75
|
+
InlineEdit.displayName = 'InlineEdit';
|
|
76
|
+
InlineEdit.propTypes = {
|
|
77
|
+
children: PropTypes.any,
|
|
78
|
+
classPrefix: PropTypes.string,
|
|
79
|
+
className: PropTypes.string,
|
|
80
|
+
disabled: PropTypes.bool,
|
|
81
|
+
defaultValue: PropTypes.any,
|
|
82
|
+
value: PropTypes.any,
|
|
83
|
+
showControls: PropTypes.bool,
|
|
84
|
+
placeholder: PropTypes.string,
|
|
85
|
+
size: oneOf(['lg', 'md', 'sm', 'xs']),
|
|
86
|
+
stateOnBlur: oneOf(['save', 'cancel']),
|
|
87
|
+
onChange: PropTypes.func,
|
|
88
|
+
onCancel: PropTypes.func,
|
|
89
|
+
onSave: PropTypes.func,
|
|
90
|
+
onEdit: PropTypes.func
|
|
91
|
+
};
|
|
92
|
+
export default InlineEdit;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface ChildrenProps {
|
|
3
|
+
size?: 'lg' | 'md' | 'sm' | 'xs';
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
placeholder?: string;
|
|
6
|
+
plaintext?: boolean;
|
|
7
|
+
value: any;
|
|
8
|
+
onChange: (value: any, event: React.SyntheticEvent) => void;
|
|
9
|
+
onBlur?: (event: React.SyntheticEvent) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare function defaultRenderInput(props: ChildrenProps, ref: React.Ref<any>): JSX.Element;
|
|
12
|
+
export declare function renderChildren(children: ((props: ChildrenProps, ref: React.Ref<any>) => React.ReactElement) | React.ReactElement, props: ChildrenProps, ref: React.Ref<any>): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import Input from '../Input';
|
|
6
|
+
export function defaultRenderInput(props, ref) {
|
|
7
|
+
return /*#__PURE__*/React.createElement(Input, _extends({
|
|
8
|
+
ref: ref
|
|
9
|
+
}, props));
|
|
10
|
+
}
|
|
11
|
+
var pickers = ['DatePicker', 'DateRangePicker', 'InputPicker', 'TagPicker', 'Cascader', 'MultiCascader', 'SelectPicker', 'CheckPicker', 'CheckTreePicker', 'TreePicker'];
|
|
12
|
+
function getDisplayName(Component) {
|
|
13
|
+
var _Component$type;
|
|
14
|
+
if (typeof (Component === null || Component === void 0 ? void 0 : Component.type) === 'string') {
|
|
15
|
+
return Component === null || Component === void 0 ? void 0 : Component.type;
|
|
16
|
+
}
|
|
17
|
+
return (Component === null || Component === void 0 ? void 0 : (_Component$type = Component.type) === null || _Component$type === void 0 ? void 0 : _Component$type.displayName) || '';
|
|
18
|
+
}
|
|
19
|
+
export function renderChildren(children, props, ref) {
|
|
20
|
+
if (typeof children === 'function') {
|
|
21
|
+
return children(props, ref);
|
|
22
|
+
}
|
|
23
|
+
if (pickers.includes(getDisplayName(children))) {
|
|
24
|
+
var onBlur = props.onBlur,
|
|
25
|
+
rest = _objectWithoutPropertiesLoose(props, ["onBlur"]); // if the children is a picker, we should pass the onBlur to the onClose
|
|
26
|
+
return /*#__PURE__*/React.cloneElement(children, _extends({}, rest, {
|
|
27
|
+
onClose: onBlur,
|
|
28
|
+
ref: ref
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
return /*#__PURE__*/React.cloneElement(children, _extends({}, props, {
|
|
32
|
+
ref: ref
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface EditStateProps {
|
|
3
|
+
value?: any;
|
|
4
|
+
defaultValue?: any;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
onChange?: (value: any, event: React.ChangeEvent) => void;
|
|
7
|
+
onEdit?: (event: React.SyntheticEvent) => void;
|
|
8
|
+
onCancel?: (event?: React.MouseEvent) => void;
|
|
9
|
+
onSave?: (event?: React.MouseEvent) => void;
|
|
10
|
+
onClick?: (event: React.SyntheticEvent) => void;
|
|
11
|
+
}
|
|
12
|
+
declare const useEditState: (props: EditStateProps) => {
|
|
13
|
+
isEditing: boolean;
|
|
14
|
+
value: any;
|
|
15
|
+
onClick: (...args: any[]) => any;
|
|
16
|
+
onChange: (...args: any[]) => any;
|
|
17
|
+
onCancel: (...args: any[]) => any;
|
|
18
|
+
onSave: (...args: any[]) => any;
|
|
19
|
+
onKeyDown: (...args: any[]) => any;
|
|
20
|
+
htmlProps: {};
|
|
21
|
+
};
|
|
22
|
+
export default useEditState;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { useEventCallback, useControlled } from '../utils';
|
|
5
|
+
var useEditState = function useEditState(props) {
|
|
6
|
+
var valueProp = props.value,
|
|
7
|
+
defaultValue = props.defaultValue,
|
|
8
|
+
disabled = props.disabled,
|
|
9
|
+
onChange = props.onChange,
|
|
10
|
+
onEdit = props.onEdit,
|
|
11
|
+
onCancel = props.onCancel,
|
|
12
|
+
onSave = props.onSave,
|
|
13
|
+
onClick = props.onClick,
|
|
14
|
+
htmlProps = _objectWithoutPropertiesLoose(props, ["value", "defaultValue", "disabled", "onChange", "onEdit", "onCancel", "onSave", "onClick"]);
|
|
15
|
+
var _useState = useState(false),
|
|
16
|
+
isEditing = _useState[0],
|
|
17
|
+
setIsEditing = _useState[1];
|
|
18
|
+
var _useControlled = useControlled(valueProp, defaultValue),
|
|
19
|
+
value = _useControlled[0],
|
|
20
|
+
setValue = _useControlled[1]; // When editing, the value is not updated, and the original value is restored when canceling
|
|
21
|
+
var _useState2 = useState(),
|
|
22
|
+
resetValue = _useState2[0],
|
|
23
|
+
setResetValue = _useState2[1];
|
|
24
|
+
var handleClick = useEventCallback(function (event) {
|
|
25
|
+
if (disabled) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
29
|
+
onEdit === null || onEdit === void 0 ? void 0 : onEdit(event);
|
|
30
|
+
setIsEditing(true);
|
|
31
|
+
setResetValue(value);
|
|
32
|
+
});
|
|
33
|
+
var handleChange = useEventCallback(function (value, event) {
|
|
34
|
+
setValue(value);
|
|
35
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(value, event);
|
|
36
|
+
});
|
|
37
|
+
var handleCancel = useEventCallback(function (event) {
|
|
38
|
+
var _event$stopPropagatio;
|
|
39
|
+
setIsEditing(false);
|
|
40
|
+
setValue(resetValue);
|
|
41
|
+
onCancel === null || onCancel === void 0 ? void 0 : onCancel(event);
|
|
42
|
+
event === null || event === void 0 ? void 0 : (_event$stopPropagatio = event.stopPropagation) === null || _event$stopPropagatio === void 0 ? void 0 : _event$stopPropagatio.call(event);
|
|
43
|
+
});
|
|
44
|
+
var handleSave = useEventCallback(function (event) {
|
|
45
|
+
var _event$stopPropagatio2;
|
|
46
|
+
setIsEditing(false);
|
|
47
|
+
onSave === null || onSave === void 0 ? void 0 : onSave(event);
|
|
48
|
+
event === null || event === void 0 ? void 0 : (_event$stopPropagatio2 = event.stopPropagation) === null || _event$stopPropagatio2 === void 0 ? void 0 : _event$stopPropagatio2.call(event);
|
|
49
|
+
});
|
|
50
|
+
var handleKeyDown = useEventCallback(function (event) {
|
|
51
|
+
var _event$target;
|
|
52
|
+
if (isEditing) {
|
|
53
|
+
switch (event.key) {
|
|
54
|
+
case 'Enter':
|
|
55
|
+
if (((_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.tagName) === 'INPUT') {
|
|
56
|
+
handleSave(event);
|
|
57
|
+
}
|
|
58
|
+
break;
|
|
59
|
+
case 'Escape':
|
|
60
|
+
handleCancel(event);
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
return {
|
|
66
|
+
isEditing: isEditing,
|
|
67
|
+
value: value,
|
|
68
|
+
onClick: handleClick,
|
|
69
|
+
onChange: handleChange,
|
|
70
|
+
onCancel: handleCancel,
|
|
71
|
+
onSave: handleSave,
|
|
72
|
+
onKeyDown: handleKeyDown,
|
|
73
|
+
htmlProps: htmlProps
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
export default useEditState;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { PickerHandle } from '../internals/Picker/types';
|
|
3
|
+
interface FocusEventProps {
|
|
4
|
+
isEditing: boolean;
|
|
5
|
+
stateOnBlur?: 'save' | 'cancel';
|
|
6
|
+
onSave?: (event?: React.FocusEvent) => void;
|
|
7
|
+
onCancel?: (event?: React.FocusEvent) => void;
|
|
8
|
+
}
|
|
9
|
+
declare const useFocusEvent: ({ isEditing, stateOnBlur, onSave, onCancel }: FocusEventProps) => {
|
|
10
|
+
target: import("react").RefObject<HTMLInputElement | PickerHandle>;
|
|
11
|
+
root: import("react").RefObject<HTMLDivElement>;
|
|
12
|
+
onBlur: (...args: any[]) => any;
|
|
13
|
+
};
|
|
14
|
+
export default useFocusEvent;
|