rsuite 5.68.1 → 5.69.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 +17 -0
- package/Calendar/styles/index.css +1 -1
- package/Calendar/styles/index.less +1 -1
- package/DatePicker/styles/index.css +1 -1
- package/DateRangePicker/styles/index.css +1 -1
- package/cjs/Calendar/Calendar.d.ts +7 -2
- package/cjs/Calendar/Calendar.js +1 -1
- package/cjs/Calendar/CalendarContainer.d.ts +5 -0
- package/cjs/Calendar/CalendarContainer.js +15 -44
- package/cjs/Calendar/CalendarContext.d.ts +126 -2
- package/cjs/Calendar/CalendarContext.js +11 -3
- package/cjs/Calendar/CalendarHeader.js +3 -20
- package/cjs/Calendar/MonthDropdown.js +39 -29
- package/cjs/Calendar/TimeDropdown.js +0 -14
- package/cjs/Calendar/index.d.ts +1 -2
- package/cjs/CustomProvider/CustomProvider.d.ts +13 -16
- package/cjs/DateInput/hooks/useDateInputState.d.ts +0 -2
- package/cjs/DateInput/hooks/useDateInputState.js +4 -1
- package/cjs/DatePicker/DatePicker.d.ts +6 -1
- package/cjs/DatePicker/DatePicker.js +10 -8
- package/cjs/DateRangePicker/Calendar.d.ts +3 -3
- package/cjs/DateRangePicker/Calendar.js +1 -1
- package/cjs/DateRangePicker/DateRangePicker.d.ts +15 -3
- package/cjs/DateRangePicker/DateRangePicker.js +30 -25
- package/cjs/InputNumber/InputNumber.d.ts +9 -0
- package/cjs/InputNumber/InputNumber.js +28 -8
- package/cjs/internals/Windowing/List.d.ts +13 -3
- package/cjs/internals/Windowing/index.d.ts +1 -1
- package/cjs/internals/hooks/useCustom.js +25 -12
- package/cjs/useMediaQuery/useMediaQuery.js +12 -6
- package/dist/rsuite-no-reset-rtl.css +1 -1
- 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 +1 -1
- package/dist/rsuite-no-reset.min.css +1 -1
- package/dist/rsuite-no-reset.min.css.map +1 -1
- package/dist/rsuite-rtl.css +1 -1
- package/dist/rsuite-rtl.min.css +1 -1
- package/dist/rsuite-rtl.min.css.map +1 -1
- package/dist/rsuite.css +1 -1
- package/dist/rsuite.js +16 -16
- 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/Calendar.d.ts +7 -2
- package/esm/Calendar/Calendar.js +1 -1
- package/esm/Calendar/CalendarContainer.d.ts +5 -0
- package/esm/Calendar/CalendarContainer.js +15 -44
- package/esm/Calendar/CalendarContext.d.ts +126 -2
- package/esm/Calendar/CalendarContext.js +12 -3
- package/esm/Calendar/CalendarHeader.js +3 -20
- package/esm/Calendar/MonthDropdown.js +39 -29
- package/esm/Calendar/TimeDropdown.js +0 -14
- package/esm/Calendar/index.d.ts +1 -2
- package/esm/CustomProvider/CustomProvider.d.ts +13 -16
- package/esm/DateInput/hooks/useDateInputState.d.ts +0 -2
- package/esm/DateInput/hooks/useDateInputState.js +5 -2
- package/esm/DatePicker/DatePicker.d.ts +6 -1
- package/esm/DatePicker/DatePicker.js +10 -8
- package/esm/DateRangePicker/Calendar.d.ts +3 -3
- package/esm/DateRangePicker/Calendar.js +1 -1
- package/esm/DateRangePicker/DateRangePicker.d.ts +15 -3
- package/esm/DateRangePicker/DateRangePicker.js +19 -14
- package/esm/InputNumber/InputNumber.d.ts +9 -0
- package/esm/InputNumber/InputNumber.js +29 -9
- package/esm/internals/Windowing/List.d.ts +13 -3
- package/esm/internals/Windowing/index.d.ts +1 -1
- package/esm/internals/hooks/useCustom.js +25 -12
- package/esm/useMediaQuery/useMediaQuery.js +13 -7
- package/package.json +1 -1
- package/cjs/Calendar/types.d.ts +0 -28
- package/cjs/Calendar/types.js +0 -4
- package/esm/Calendar/types.d.ts +0 -28
- package/esm/Calendar/types.js +0 -2
|
@@ -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;
|
|
6
|
-
var _excluded = ["as", "className", "classPrefix", "calendarDefaultDate", "cleanable", "editable", "defaultValue", "disabled", "readOnly", "plaintext", "format", "id", "isoWeek", "weekStart", "limitEndYear", "limitStartYear", "locale", "loading", "label", "menuClassName", "menuStyle", "appearance", "placement", "oneTap", "placeholder", "ranges", "value", "showMeridian", "showWeekNumbers", "style", "size", "
|
|
6
|
+
var _excluded = ["as", "className", "classPrefix", "calendarDefaultDate", "cleanable", "caretAs", "editable", "defaultValue", "disabled", "readOnly", "plaintext", "format", "id", "isoWeek", "weekStart", "limitEndYear", "limitStartYear", "locale", "loading", "label", "menuClassName", "menuStyle", "appearance", "placement", "oneTap", "placeholder", "ranges", "value", "showMeridian", "showWeekNumbers", "style", "size", "monthDropdownProps", "shouldDisableDate", "shouldDisableHour", "shouldDisableMinute", "shouldDisableSecond", "onChange", "onChangeCalendarDate", "onClean", "onEnter", "onExit", "onNextMonth", "onOk", "onPrevMonth", "onSelect", "onToggleMonthDropdown", "onToggleTimeDropdown", "onShortcutClick", "renderCell", "renderValue", "disabledDate", "disabledHours", "disabledMinutes", "disabledSeconds"];
|
|
7
7
|
import React, { useMemo } from 'react';
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
9
9
|
import mapValues from 'lodash/mapValues';
|
|
@@ -12,21 +12,21 @@ import IconCalendar from '@rsuite/icons/legacy/Calendar';
|
|
|
12
12
|
import IconClockO from '@rsuite/icons/legacy/ClockO';
|
|
13
13
|
import CalendarContainer from "../Calendar/CalendarContainer.js";
|
|
14
14
|
import useCalendarDate from "../Calendar/useCalendarDate.js";
|
|
15
|
-
import { isEveryDateInMonth } from "../Calendar/MonthDropdown.js";
|
|
16
15
|
import Toolbar from "./Toolbar.js";
|
|
17
16
|
import Stack from "../Stack/index.js";
|
|
18
17
|
import PredefinedRanges from "./PredefinedRanges.js";
|
|
18
|
+
import DateInput from "../DateInput/index.js";
|
|
19
|
+
import InputGroup from "../InputGroup/index.js";
|
|
20
|
+
import useMonthView from "./hooks/useMonthView.js";
|
|
21
|
+
import useFocus from "./hooks/useFocus.js";
|
|
22
|
+
import useCustomizedInput from "./hooks/useCustomizedInput.js";
|
|
23
|
+
import { isEveryDateInMonth } from "../Calendar/MonthDropdown.js";
|
|
19
24
|
import { mergeRefs, partitionHTMLProps, createChainedFunction } from "../internals/utils/index.js";
|
|
20
25
|
import { useClassNames, useControlled, useCustom, useUniqueId, useEventCallback } from "../internals/hooks/index.js";
|
|
21
26
|
import { shouldRenderMonth, shouldRenderDate, shouldRenderTime, shouldOnlyRenderTime, setHours, getHours, isValid, copyTime, disableTime, calendarOnlyProps } from "../internals/utils/date/index.js";
|
|
22
27
|
import { PickerPopup, PickerLabel, PickerIndicator, PickerToggleTrigger, pickerPropTypes, pickTriggerPropKeys, usePickerClassName, usePickerRef, onMenuKeyDown } from "../internals/Picker/index.js";
|
|
23
28
|
import { OverlayCloseCause } from "../internals/Overlay/OverlayTrigger.js";
|
|
24
|
-
import DateInput from "../DateInput/index.js";
|
|
25
|
-
import InputGroup from "../InputGroup/index.js";
|
|
26
29
|
import { splitRanges, deprecatedPropTypes, getRestProps } from "./utils.js";
|
|
27
|
-
import useMonthView from "./hooks/useMonthView.js";
|
|
28
|
-
import useFocus from "./hooks/useFocus.js";
|
|
29
|
-
import useCustomizedInput from "./hooks/useCustomizedInput.js";
|
|
30
30
|
/**
|
|
31
31
|
* A date picker allows users to select a date from a calendar.
|
|
32
32
|
*
|
|
@@ -42,6 +42,7 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
42
42
|
calendarDefaultDate = props.calendarDefaultDate,
|
|
43
43
|
_props$cleanable = props.cleanable,
|
|
44
44
|
cleanable = _props$cleanable === void 0 ? true : _props$cleanable,
|
|
45
|
+
caretAsProp = props.caretAs,
|
|
45
46
|
_props$editable = props.editable,
|
|
46
47
|
editable = _props$editable === void 0 ? true : _props$editable,
|
|
47
48
|
defaultValue = props.defaultValue,
|
|
@@ -75,7 +76,7 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
75
76
|
showWeekNumbers = props.showWeekNumbers,
|
|
76
77
|
style = props.style,
|
|
77
78
|
size = props.size,
|
|
78
|
-
|
|
79
|
+
monthDropdownProps = props.monthDropdownProps,
|
|
79
80
|
shouldDisableDate = props.shouldDisableDate,
|
|
80
81
|
shouldDisableHour = props.shouldDisableHour,
|
|
81
82
|
shouldDisableMinute = props.shouldDisableMinute,
|
|
@@ -413,6 +414,7 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
413
414
|
isoWeek: isoWeek,
|
|
414
415
|
weekStart: weekStart,
|
|
415
416
|
calendarDate: calendarDate,
|
|
417
|
+
monthDropdownProps: monthDropdownProps,
|
|
416
418
|
renderCellOnPicker: renderCell,
|
|
417
419
|
onMoveForward: handleMoveForward,
|
|
418
420
|
onMoveBackward: handleMoveBackward,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { DATERANGE_DISABLED_TARGET } from '../internals/constants';
|
|
3
2
|
import { CalendarProps as CalendarCoreProps } from '../Calendar/CalendarContainer';
|
|
3
|
+
import { DATERANGE_DISABLED_TARGET } from '../internals/constants';
|
|
4
4
|
import { DateRange } from './types';
|
|
5
5
|
import { RsRefForwardingComponent, WithAsProps } from '../internals/types';
|
|
6
6
|
import { DatePickerLocale } from '../locales';
|
|
@@ -16,13 +16,13 @@ export interface CalendarProps extends WithAsProps, Omit<CalendarCoreProps, Omit
|
|
|
16
16
|
limitEndYear?: number;
|
|
17
17
|
limitStartYear?: number;
|
|
18
18
|
locale?: DatePickerLocale;
|
|
19
|
+
showWeekNumbers?: boolean;
|
|
20
|
+
value?: [] | [Date] | [Date, Date];
|
|
19
21
|
onChangeCalendarMonth?: (index: number, date: Date) => void;
|
|
20
22
|
onChangeCalendarTime?: (index: number, date: Date) => void;
|
|
21
23
|
onToggleMeridian: (index: number, event: React.MouseEvent) => void;
|
|
22
24
|
onSelect?: (index: number, date: Date, event: React.SyntheticEvent) => void;
|
|
23
25
|
onMouseMove?: (date: Date) => void;
|
|
24
|
-
showWeekNumbers?: boolean;
|
|
25
|
-
value?: [] | [Date] | [Date, Date];
|
|
26
26
|
}
|
|
27
27
|
declare const Calendar: RsRefForwardingComponent<'div', CalendarProps>;
|
|
28
28
|
export default Calendar;
|
|
@@ -3,10 +3,10 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
3
3
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
4
4
|
var _excluded = ["as", "calendarDate", "format", "disabledDate", "index", "limitEndYear", "limitStartYear", "onChangeCalendarMonth", "onChangeCalendarTime", "onToggleMeridian", "onSelect", "value"];
|
|
5
5
|
import React from 'react';
|
|
6
|
+
import CalendarCore from "../Calendar/CalendarContainer.js";
|
|
6
7
|
import { addMonths } from "../internals/utils/date/index.js";
|
|
7
8
|
import { DATERANGE_DISABLED_TARGET } from "../internals/constants/index.js";
|
|
8
9
|
import { useEventCallback } from "../internals/hooks/index.js";
|
|
9
|
-
import CalendarCore from "../Calendar/CalendarContainer.js";
|
|
10
10
|
var Calendar = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
11
11
|
var _props$as = props.as,
|
|
12
12
|
Component = _props$as === void 0 ? CalendarCore : _props$as,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { FormControlBaseProps, PickerBaseProps } from '../internals/types';
|
|
3
|
-
import { DateRangePickerLocale } from '../locales';
|
|
4
2
|
import { PickerComponent } from '../internals/Picker';
|
|
5
|
-
import { DisabledDateFunction, RangeType, DateRange } from './types';
|
|
3
|
+
import type { DisabledDateFunction, RangeType, DateRange } from './types';
|
|
4
|
+
import type { FormControlBaseProps, PickerBaseProps } from '../internals/types';
|
|
5
|
+
import type { DateRangePickerLocale } from '../locales';
|
|
6
|
+
import type { MonthDropdownProps } from '../Calendar/CalendarContext';
|
|
6
7
|
export interface DateRangePickerProps extends PickerBaseProps<DateRangePickerLocale>, FormControlBaseProps<DateRange | null> {
|
|
7
8
|
/**
|
|
8
9
|
* Custom caret component
|
|
@@ -85,6 +86,17 @@ export interface DateRangePickerProps extends PickerBaseProps<DateRangePickerLoc
|
|
|
85
86
|
* @default ' ~ '
|
|
86
87
|
*/
|
|
87
88
|
character?: string;
|
|
89
|
+
/**
|
|
90
|
+
* The props for the Month Dropdown component.
|
|
91
|
+
*/
|
|
92
|
+
monthDropdownProps?: MonthDropdownProps;
|
|
93
|
+
/**
|
|
94
|
+
* If the user selects a date on the right calendar first, it will automatically switch to the left calendar.
|
|
95
|
+
* Always keep the date on the left calendar as the start date.
|
|
96
|
+
* @default false
|
|
97
|
+
* @version 5.69.0
|
|
98
|
+
*/
|
|
99
|
+
calendarSnapping?: boolean;
|
|
88
100
|
/**
|
|
89
101
|
* Disabled date
|
|
90
102
|
* @deprecated Use {@link shouldDisableDate} instead
|
|
@@ -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;
|
|
6
|
-
var _excluded = ["as", "classPrefix", "className", "appearance", "editable", "cleanable", "character", "defaultCalendarValue", "defaultValue", "plaintext", "disabled", "disabledDate", "shouldDisableDate", "format", "hoverRange", "id", "isoWeek", "weekStart", "limitEndYear", "limitStartYear", "locale", "loading", "label", "menuClassName", "menuStyle", "oneTap", "placeholder", "placement", "ranges", "readOnly", "showOneCalendar", "showWeekNumbers", "showMeridian", "showHeader", "style", "size", "caretAs", "value", "onChange", "onClean", "onEnter", "onExit", "onOk", "onSelect", "onShortcutClick", "renderTitle", "renderValue"];
|
|
6
|
+
var _excluded = ["as", "classPrefix", "className", "appearance", "editable", "cleanable", "character", "calendarSnapping", "defaultCalendarValue", "defaultValue", "plaintext", "disabled", "disabledDate", "shouldDisableDate", "format", "hoverRange", "id", "isoWeek", "weekStart", "limitEndYear", "limitStartYear", "locale", "loading", "label", "menuClassName", "menuStyle", "oneTap", "placeholder", "placement", "ranges", "readOnly", "showOneCalendar", "showWeekNumbers", "showMeridian", "showHeader", "style", "size", "caretAs", "value", "monthDropdownProps", "onChange", "onClean", "onEnter", "onExit", "onOk", "onSelect", "onShortcutClick", "renderTitle", "renderValue"];
|
|
7
7
|
import React, { useEffect, useRef, useState, useMemo } from 'react';
|
|
8
8
|
import isNil from 'lodash/isNil';
|
|
9
9
|
import omit from 'lodash/omit';
|
|
@@ -14,20 +14,20 @@ import IconClockO from '@rsuite/icons/legacy/ClockO';
|
|
|
14
14
|
import Toolbar from "../DatePicker/Toolbar.js";
|
|
15
15
|
import PredefinedRanges from "../DatePicker/PredefinedRanges.js";
|
|
16
16
|
import Stack from "../Stack/index.js";
|
|
17
|
-
import { DATERANGE_DISABLED_TARGET as TARGET } from "../internals/constants/index.js";
|
|
18
|
-
import { omitTriggerPropKeys, PickerPopup, pickerPropTypes, PickerToggleTrigger, PickerIndicator, PickerLabel, pickTriggerPropKeys, usePickerClassName, usePickerRef, onMenuKeyDown } from "../internals/Picker/index.js";
|
|
19
|
-
import { useClassNames, useControlled, useCustom, useUniqueId, useEventCallback } from "../internals/hooks/index.js";
|
|
20
|
-
import { createChainedFunction, mergeRefs, partitionHTMLProps, getStringLength } from "../internals/utils/index.js";
|
|
21
|
-
import { addMonths, isValid, isBefore, isSameDay, addDays, startOfDay, endOfDay, shouldRenderTime, isAfter, isSameMonth, shouldRenderMonth, shouldRenderDate, calendarOnlyProps, getReversedTimeMeridian, reverseDateRangeOmitTime, copyTime, shouldOnlyRenderTime } from "../internals/utils/date/index.js";
|
|
22
|
-
import Calendar from "./Calendar.js";
|
|
23
|
-
import { getSafeCalendarDate, getMonthHoverRange, getWeekHoverRange, isSameRange } from "./utils.js";
|
|
24
|
-
import { deprecatePropTypeNew, oneOf } from "../internals/propTypes/index.js";
|
|
25
17
|
import DateRangePickerContext from "./DateRangePickerContext.js";
|
|
26
18
|
import DateRangeInput from "../DateRangeInput/index.js";
|
|
27
19
|
import InputGroup from "../InputGroup/index.js";
|
|
28
20
|
import Header from "./Header.js";
|
|
29
21
|
import useDateDisabled from "./hooks/useDateDisabled.js";
|
|
30
22
|
import useCustomizedInput from "../DatePicker/hooks/useCustomizedInput.js";
|
|
23
|
+
import Calendar from "./Calendar.js";
|
|
24
|
+
import { getSafeCalendarDate, getMonthHoverRange, getWeekHoverRange, isSameRange } from "./utils.js";
|
|
25
|
+
import { deprecatePropTypeNew, oneOf } from "../internals/propTypes/index.js";
|
|
26
|
+
import { DATERANGE_DISABLED_TARGET as TARGET } from "../internals/constants/index.js";
|
|
27
|
+
import { omitTriggerPropKeys, PickerPopup, pickerPropTypes, PickerToggleTrigger, PickerIndicator, PickerLabel, pickTriggerPropKeys, usePickerClassName, usePickerRef, onMenuKeyDown } from "../internals/Picker/index.js";
|
|
28
|
+
import { useClassNames, useControlled, useCustom, useUniqueId, useEventCallback } from "../internals/hooks/index.js";
|
|
29
|
+
import { createChainedFunction, mergeRefs, partitionHTMLProps, getStringLength } from "../internals/utils/index.js";
|
|
30
|
+
import { addMonths, isValid, isBefore, isSameDay, addDays, startOfDay, endOfDay, shouldRenderTime, isAfter, isSameMonth, shouldRenderMonth, shouldRenderDate, calendarOnlyProps, getReversedTimeMeridian, reverseDateRangeOmitTime, copyTime, shouldOnlyRenderTime } from "../internals/utils/date/index.js";
|
|
31
31
|
/**
|
|
32
32
|
* A date range picker allows you to select a date range from a calendar.
|
|
33
33
|
*
|
|
@@ -48,6 +48,7 @@ var DateRangePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
48
48
|
cleanable = _props$cleanable === void 0 ? true : _props$cleanable,
|
|
49
49
|
_props$character = props.character,
|
|
50
50
|
character = _props$character === void 0 ? ' ~ ' : _props$character,
|
|
51
|
+
calendarSnapping = props.calendarSnapping,
|
|
51
52
|
defaultCalendarValue = props.defaultCalendarValue,
|
|
52
53
|
defaultValue = props.defaultValue,
|
|
53
54
|
plaintext = props.plaintext,
|
|
@@ -87,6 +88,7 @@ var DateRangePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
87
88
|
size = props.size,
|
|
88
89
|
caretAsProp = props.caretAs,
|
|
89
90
|
valueProp = props.value,
|
|
91
|
+
monthDropdownProps = props.monthDropdownProps,
|
|
90
92
|
onChange = props.onChange,
|
|
91
93
|
onClean = props.onClean,
|
|
92
94
|
onEnter = props.onEnter,
|
|
@@ -368,11 +370,13 @@ var DateRangePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
368
370
|
setActiveCalendarKey('start');
|
|
369
371
|
}
|
|
370
372
|
setSelectedDates(nextSelectDates);
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
373
|
+
if (!isSameMonth(calendarDate[index], date) || calendarSnapping) {
|
|
374
|
+
setCalendarDateRange({
|
|
375
|
+
dateRange: nextSelectDates,
|
|
376
|
+
calendarKey: calendarKey,
|
|
377
|
+
eventName: 'changeDate'
|
|
378
|
+
});
|
|
379
|
+
}
|
|
376
380
|
onSelect === null || onSelect === void 0 ? void 0 : onSelect(date, event);
|
|
377
381
|
setSelectedIdle(!isSelectedIdle);
|
|
378
382
|
});
|
|
@@ -618,6 +622,7 @@ var DateRangePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
618
622
|
showWeekNumbers: showWeekNumbers,
|
|
619
623
|
format: formatStr,
|
|
620
624
|
value: selectedDates,
|
|
625
|
+
monthDropdownProps: monthDropdownProps,
|
|
621
626
|
hoverRangeValue: hoverDateRange !== null && hoverDateRange !== void 0 ? hoverDateRange : undefined,
|
|
622
627
|
disabledDate: disableCalendarDate,
|
|
623
628
|
onSelect: handleSelectDate,
|
|
@@ -9,6 +9,15 @@ export interface InputNumberProps<T = number | string | null> extends Omit<React
|
|
|
9
9
|
* An input can show that it is disabled
|
|
10
10
|
*/
|
|
11
11
|
disabled?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* Decimal separator
|
|
15
|
+
* https://en.wikipedia.org/wiki/Decimal_separator
|
|
16
|
+
*
|
|
17
|
+
* @default '.'
|
|
18
|
+
* @version 5.69.0
|
|
19
|
+
*/
|
|
20
|
+
decimalSeparator?: string;
|
|
12
21
|
/**
|
|
13
22
|
* Format the value of the input
|
|
14
23
|
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
3
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
4
|
-
var _excluded = ["as", "className", "classPrefix", "disabled", "formatter", "readOnly", "plaintext", "value", "defaultValue", "size", "prefix", "postfix", "step", "buttonAppearance", "min", "max", "scrollable", "onChange", "onWheel", "onBlur", "onFocus"];
|
|
5
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
4
|
+
var _excluded = ["as", "className", "classPrefix", "disabled", "decimalSeparator", "formatter", "readOnly", "plaintext", "value", "defaultValue", "size", "prefix", "postfix", "step", "buttonAppearance", "min", "max", "scrollable", "onChange", "onWheel", "onBlur", "onFocus"];
|
|
5
|
+
import React, { useEffect, useRef, useState, useMemo, useCallback } from 'react';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import isNil from 'lodash/isNil';
|
|
8
8
|
import AngleUpIcon from '@rsuite/icons/legacy/AngleUp';
|
|
@@ -82,6 +82,7 @@ var InputNumber = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
82
82
|
_props$classPrefix = props.classPrefix,
|
|
83
83
|
classPrefix = _props$classPrefix === void 0 ? 'input-number' : _props$classPrefix,
|
|
84
84
|
disabled = props.disabled,
|
|
85
|
+
decimalSeparator = props.decimalSeparator,
|
|
85
86
|
formatter = props.formatter,
|
|
86
87
|
readOnly = props.readOnly,
|
|
87
88
|
plaintext = props.plaintext,
|
|
@@ -201,14 +202,30 @@ var InputNumber = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
201
202
|
onWheel === null || onWheel === void 0 ? void 0 : onWheel(event);
|
|
202
203
|
});
|
|
203
204
|
var handleChange = useEventCallback(function (value, event) {
|
|
204
|
-
|
|
205
|
+
var separator = decimalSeparator || '.';
|
|
206
|
+
var escapedSeparator = separator.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
207
|
+
var regex = new RegExp("^-?(?:\\d+)?(" + escapedSeparator + ")?\\d*$");
|
|
208
|
+
if (!regex.test(value) && value !== '') {
|
|
205
209
|
return;
|
|
206
210
|
}
|
|
207
211
|
handleChangeValue(value, event);
|
|
208
212
|
});
|
|
213
|
+
var replaceDecimalSeparator = useCallback(function (value) {
|
|
214
|
+
if (decimalSeparator && value) {
|
|
215
|
+
return value.toString().replace('.', decimalSeparator);
|
|
216
|
+
}
|
|
217
|
+
return value;
|
|
218
|
+
}, [decimalSeparator]);
|
|
219
|
+
var restoreDecimalSeparator = useCallback(function (value) {
|
|
220
|
+
if (decimalSeparator && value) {
|
|
221
|
+
return value.replace(decimalSeparator, '.');
|
|
222
|
+
}
|
|
223
|
+
return value;
|
|
224
|
+
}, [decimalSeparator]);
|
|
209
225
|
var handleBlur = useEventCallback(function (event) {
|
|
210
226
|
var _event$target;
|
|
211
|
-
var
|
|
227
|
+
var value = restoreDecimalSeparator((_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.value);
|
|
228
|
+
var targetValue = Number.parseFloat(value);
|
|
212
229
|
handleChangeValue(getSafeValue(targetValue), event);
|
|
213
230
|
setIsFocused(false);
|
|
214
231
|
});
|
|
@@ -224,22 +241,25 @@ var InputNumber = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
224
241
|
(_wheelListener = wheelListener) === null || _wheelListener === void 0 ? void 0 : _wheelListener.off();
|
|
225
242
|
};
|
|
226
243
|
}, [handleWheel, scrollable]);
|
|
227
|
-
var
|
|
244
|
+
var inputValue = useMemo(function () {
|
|
228
245
|
if (isNil(value)) {
|
|
229
246
|
return '';
|
|
230
247
|
}
|
|
231
248
|
if (isFocused) {
|
|
232
|
-
return value;
|
|
249
|
+
return replaceDecimalSeparator(value);
|
|
233
250
|
}
|
|
234
|
-
|
|
235
|
-
|
|
251
|
+
if (formatter) {
|
|
252
|
+
return formatter(value);
|
|
253
|
+
}
|
|
254
|
+
return replaceDecimalSeparator(value);
|
|
255
|
+
}, [formatter, isFocused, replaceDecimalSeparator, value]);
|
|
236
256
|
var input = /*#__PURE__*/React.createElement(Input, _extends({}, htmlInputProps, {
|
|
237
257
|
ref: plaintext ? ref : undefined,
|
|
238
258
|
inputRef: inputRef,
|
|
239
259
|
autoComplete: "off",
|
|
240
260
|
inputMode: "numeric",
|
|
241
261
|
step: step,
|
|
242
|
-
value:
|
|
262
|
+
value: inputValue,
|
|
243
263
|
disabled: disabled,
|
|
244
264
|
readOnly: readOnly,
|
|
245
265
|
plaintext: plaintext,
|
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { VariableSizeList, ListItemKeySelector, ListOnScrollProps, ListOnItemsRenderedProps, ListProps as BaseListProps } from 'react-window';
|
|
3
|
+
import { RsRefForwardingComponent } from '../types';
|
|
3
4
|
export declare const defaultItemSize: () => number;
|
|
4
|
-
export interface ListProps<T = any> extends
|
|
5
|
+
export interface ListProps<T = any> extends Omit<BaseListProps, 'width'> {
|
|
6
|
+
ref?: React.Ref<ListHandle>;
|
|
7
|
+
/**
|
|
8
|
+
* Width of the list.
|
|
9
|
+
*
|
|
10
|
+
* For horizontal lists, this must be a number. It affects the number of columns that will be rendered (and displayed) at any given time.
|
|
11
|
+
*
|
|
12
|
+
* For vertical lists, this can be a number or a string (e.g. "50%").
|
|
13
|
+
*/
|
|
14
|
+
width?: number | string;
|
|
5
15
|
/**
|
|
6
16
|
* @deprecated use itemSize instead
|
|
7
17
|
* Either a fixed row height (number) or a function that returns the height of a row given its index: ({ index: number }): number
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { default as AutoSizer } from './AutoSizer';
|
|
2
2
|
export { default as List, defaultItemSize } from './List';
|
|
3
3
|
export { FixedSizeList, VariableSizeList } from 'react-window';
|
|
4
|
-
export type { ListChildComponentProps } from 'react-window';
|
|
4
|
+
export type { ListChildComponentProps, FixedSizeListProps } from 'react-window';
|
|
5
5
|
export type { ListProps, ListHandle } from './List';
|
|
@@ -37,25 +37,38 @@ export function useCustom(keys, overrideLocale) {
|
|
|
37
37
|
if (overrideLocale) {
|
|
38
38
|
componentLocale = mergeObject([componentLocale, overrideLocale]);
|
|
39
39
|
}
|
|
40
|
-
var
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
40
|
+
var _formatDate = useCallback(function (date, formatStr, options) {
|
|
41
|
+
try {
|
|
42
|
+
var _locale$Calendar;
|
|
43
|
+
if (formatDate) {
|
|
44
|
+
return formatDate(date, formatStr, options);
|
|
45
|
+
}
|
|
46
|
+
return format(isValid(date) ? date : new Date(), formatStr, _extends({
|
|
47
|
+
locale: locale === null || locale === void 0 ? void 0 : (_locale$Calendar = locale.Calendar) === null || _locale$Calendar === void 0 ? void 0 : _locale$Calendar.dateLocale
|
|
48
|
+
}, options));
|
|
49
|
+
} catch (error) {
|
|
50
|
+
if (process.env.NODE_ENV === 'development') {
|
|
51
|
+
console.error('Error: Invalid date format', error);
|
|
52
|
+
}
|
|
53
|
+
return 'Error: Invalid date format';
|
|
54
|
+
}
|
|
55
|
+
}, [formatDate, locale === null || locale === void 0 ? void 0 : (_locale$Calendar2 = locale.Calendar) === null || _locale$Calendar2 === void 0 ? void 0 : _locale$Calendar2.dateLocale]);
|
|
56
|
+
var _parseDate = useCallback(function (dateString, formatString, referenceDate, options) {
|
|
47
57
|
var _locale$Calendar3;
|
|
48
|
-
|
|
58
|
+
if (parseDate) {
|
|
59
|
+
return parseDate(dateString, formatString, referenceDate, options);
|
|
60
|
+
}
|
|
61
|
+
return parse(dateString, formatString, referenceDate || new Date(), _extends({
|
|
49
62
|
locale: locale === null || locale === void 0 ? void 0 : (_locale$Calendar3 = locale.Calendar) === null || _locale$Calendar3 === void 0 ? void 0 : _locale$Calendar3.dateLocale
|
|
50
|
-
});
|
|
51
|
-
}, [(_locale$Calendar4 = locale.Calendar) === null || _locale$Calendar4 === void 0 ? void 0 : _locale$Calendar4.dateLocale]);
|
|
63
|
+
}, options));
|
|
64
|
+
}, [parseDate, locale === null || locale === void 0 ? void 0 : (_locale$Calendar4 = locale.Calendar) === null || _locale$Calendar4 === void 0 ? void 0 : _locale$Calendar4.dateLocale]);
|
|
52
65
|
return {
|
|
53
66
|
locale: componentLocale,
|
|
54
67
|
rtl: rtl,
|
|
55
68
|
toasters: toasters,
|
|
56
69
|
disableRipple: disableRipple,
|
|
57
|
-
formatDate:
|
|
58
|
-
parseDate:
|
|
70
|
+
formatDate: _formatDate,
|
|
71
|
+
parseDate: _parseDate
|
|
59
72
|
};
|
|
60
73
|
}
|
|
61
74
|
export default useCustom;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
import React, { useEffect, useState, useCallback, useRef } from 'react';
|
|
3
|
+
import React, { useEffect, useState, useCallback, useRef, useMemo } from 'react';
|
|
4
4
|
import canUseDOM from 'dom-lib/canUseDOM';
|
|
5
5
|
import pick from 'lodash/pick';
|
|
6
6
|
export var mediaQuerySizeMap = {
|
|
@@ -32,9 +32,12 @@ var matchMedia = function matchMedia(query) {
|
|
|
32
32
|
*/
|
|
33
33
|
export function useMediaQueryOld(query) {
|
|
34
34
|
var queries = Array.isArray(query) ? query : [query];
|
|
35
|
-
var mediaQueries =
|
|
36
|
-
return
|
|
37
|
-
|
|
35
|
+
var mediaQueries = useMemo(function () {
|
|
36
|
+
return queries.map(function (query) {
|
|
37
|
+
return mediaQuerySizeMap[query] || query;
|
|
38
|
+
});
|
|
39
|
+
}, // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
40
|
+
[].concat(queries));
|
|
38
41
|
var _useState = useState(function () {
|
|
39
42
|
return mediaQueries.map(function (query) {
|
|
40
43
|
return pick(matchMedia(query), ['matches', 'media']);
|
|
@@ -78,9 +81,12 @@ export function useMediaQueryOld(query) {
|
|
|
78
81
|
export function useMediaQuery(query) {
|
|
79
82
|
var _React$useSyncExterna;
|
|
80
83
|
var queries = Array.isArray(query) ? query : [query];
|
|
81
|
-
var mediaQueries =
|
|
82
|
-
return
|
|
83
|
-
|
|
84
|
+
var mediaQueries = useMemo(function () {
|
|
85
|
+
return queries.map(function (query) {
|
|
86
|
+
return mediaQuerySizeMap[query] || query;
|
|
87
|
+
});
|
|
88
|
+
}, // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
89
|
+
[].concat(queries));
|
|
84
90
|
var mediaQueryArray = useRef(mediaQueries.map(function (query) {
|
|
85
91
|
return matchMedia(query).matches;
|
|
86
92
|
}));
|
package/package.json
CHANGED
package/cjs/Calendar/types.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { CalendarLocale } from '../locales';
|
|
3
|
-
export interface CalendarInnerContextValue {
|
|
4
|
-
date: Date;
|
|
5
|
-
dateRange?: Date[];
|
|
6
|
-
format?: string;
|
|
7
|
-
hoverRangeValue?: [Date, Date];
|
|
8
|
-
inline?: boolean;
|
|
9
|
-
isoWeek: boolean;
|
|
10
|
-
weekStart: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
11
|
-
showWeekNumbers?: boolean;
|
|
12
|
-
targetId?: string;
|
|
13
|
-
disabledDate?: (date: Date, selectRangeValue?: Date[], type?: string) => boolean;
|
|
14
|
-
inSameMonth?: (date: Date) => boolean;
|
|
15
|
-
onChangeMonth?: (nextPageDate: Date, event: React.MouseEvent) => void;
|
|
16
|
-
onChangeTime?: (nextPageTime: Date, event: React.MouseEvent) => void;
|
|
17
|
-
onMouseMove?: (date: Date) => void;
|
|
18
|
-
onSelect?: (date: Date, event: React.MouseEvent) => void;
|
|
19
|
-
renderCell?: (date: Date) => React.ReactNode;
|
|
20
|
-
renderCellOnPicker?: (date: Date) => React.ReactNode;
|
|
21
|
-
cellClassName?: (date: Date) => string | undefined;
|
|
22
|
-
}
|
|
23
|
-
export interface CalendarContextValue extends CalendarInnerContextValue {
|
|
24
|
-
locale: CalendarLocale;
|
|
25
|
-
formatDate?: (date: Date | string | number, format?: string, options?: {
|
|
26
|
-
locale?: any;
|
|
27
|
-
}) => string;
|
|
28
|
-
}
|
package/cjs/Calendar/types.js
DELETED
package/esm/Calendar/types.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { CalendarLocale } from '../locales';
|
|
3
|
-
export interface CalendarInnerContextValue {
|
|
4
|
-
date: Date;
|
|
5
|
-
dateRange?: Date[];
|
|
6
|
-
format?: string;
|
|
7
|
-
hoverRangeValue?: [Date, Date];
|
|
8
|
-
inline?: boolean;
|
|
9
|
-
isoWeek: boolean;
|
|
10
|
-
weekStart: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
11
|
-
showWeekNumbers?: boolean;
|
|
12
|
-
targetId?: string;
|
|
13
|
-
disabledDate?: (date: Date, selectRangeValue?: Date[], type?: string) => boolean;
|
|
14
|
-
inSameMonth?: (date: Date) => boolean;
|
|
15
|
-
onChangeMonth?: (nextPageDate: Date, event: React.MouseEvent) => void;
|
|
16
|
-
onChangeTime?: (nextPageTime: Date, event: React.MouseEvent) => void;
|
|
17
|
-
onMouseMove?: (date: Date) => void;
|
|
18
|
-
onSelect?: (date: Date, event: React.MouseEvent) => void;
|
|
19
|
-
renderCell?: (date: Date) => React.ReactNode;
|
|
20
|
-
renderCellOnPicker?: (date: Date) => React.ReactNode;
|
|
21
|
-
cellClassName?: (date: Date) => string | undefined;
|
|
22
|
-
}
|
|
23
|
-
export interface CalendarContextValue extends CalendarInnerContextValue {
|
|
24
|
-
locale: CalendarLocale;
|
|
25
|
-
formatDate?: (date: Date | string | number, format?: string, options?: {
|
|
26
|
-
locale?: any;
|
|
27
|
-
}) => string;
|
|
28
|
-
}
|
package/esm/Calendar/types.js
DELETED