rsuite 5.59.1 → 5.59.3-alpha.1
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 +12 -0
- package/DateRangePicker/styles/index.css +27 -0
- package/DateRangePicker/styles/index.less +27 -0
- package/cjs/@types/common.d.ts +1 -1
- package/cjs/Calendar/CalendarContainer.js +4 -4
- package/cjs/DatePicker/DatePicker.d.ts +3 -38
- package/cjs/DatePicker/DatePicker.js +86 -137
- package/cjs/DatePicker/PredefinedRanges.d.ts +1 -1
- package/cjs/DatePicker/PredefinedRanges.js +3 -3
- package/cjs/DatePicker/Toolbar.d.ts +1 -1
- package/cjs/DatePicker/Toolbar.js +13 -12
- package/cjs/DatePicker/hooks/useFocus.d.ts +13 -0
- package/cjs/DatePicker/hooks/useFocus.js +96 -0
- package/cjs/DatePicker/hooks/useMonthView.d.ts +10 -0
- package/cjs/DatePicker/hooks/useMonthView.js +28 -0
- package/cjs/DatePicker/index.d.ts +2 -1
- package/cjs/DatePicker/types.d.ts +37 -0
- package/cjs/DatePicker/utils.d.ts +9 -0
- package/cjs/DatePicker/utils.js +20 -2
- package/cjs/DateRangePicker/DateRangePicker.d.ts +15 -3
- package/cjs/DateRangePicker/DateRangePicker.js +58 -68
- package/cjs/DateRangePicker/DateRangePickerContext.d.ts +4 -1
- package/cjs/DateRangePicker/DateRangePickerContext.js +4 -4
- package/cjs/DateRangePicker/Header.d.ts +11 -0
- package/cjs/DateRangePicker/Header.js +65 -0
- package/cjs/DateRangePicker/disabledDateUtils.d.ts +1 -1
- package/cjs/DateRangePicker/disabledDateUtils.js +1 -1
- package/cjs/DateRangePicker/index.js +5 -0
- package/cjs/Form/Form.d.ts +56 -39
- package/cjs/Form/Form.js +64 -186
- package/cjs/Form/FormContext.d.ts +12 -9
- package/cjs/Form/FormContext.js +11 -5
- package/cjs/Form/hooks/useFormRef.d.ts +55 -0
- package/cjs/Form/hooks/useFormRef.js +45 -0
- package/cjs/Form/hooks/useFormValidate.d.ts +19 -0
- package/cjs/Form/hooks/useFormValidate.js +157 -0
- package/cjs/Form/hooks/useFormValue.d.ts +2 -1
- package/cjs/Form/hooks/useFormValue.js +12 -1
- package/cjs/Form/hooks/useSchemaModel.js +5 -0
- package/cjs/Form/index.d.ts +2 -1
- package/cjs/FormControl/FormControl.d.ts +1 -1
- package/cjs/FormControl/FormControl.js +50 -68
- package/cjs/FormControl/hooks/useField.d.ts +18 -0
- package/cjs/FormControl/hooks/useField.js +54 -0
- package/cjs/FormControl/hooks/useRegisterModel.d.ts +3 -0
- package/cjs/FormControl/hooks/useRegisterModel.js +22 -0
- package/cjs/FormControl/utils.d.ts +1 -0
- package/cjs/FormControl/utils.js +8 -0
- package/cjs/FormControlLabel/FormControlLabel.js +12 -9
- package/cjs/FormErrorMessage/FormErrorMessage.js +2 -5
- package/cjs/FormGroup/FormGroup.d.ts +18 -4
- package/cjs/FormGroup/FormGroup.js +28 -2
- package/cjs/FormGroup/index.d.ts +1 -0
- package/cjs/FormGroup/index.js +4 -3
- package/cjs/FormHelpText/FormHelpText.d.ts +2 -1
- package/cjs/FormHelpText/FormHelpText.js +16 -9
- package/cjs/Input/Input.js +4 -5
- package/cjs/utils/dateUtils.d.ts +72 -10
- package/cjs/utils/dateUtils.js +88 -29
- package/dist/rsuite-no-reset-rtl.css +27 -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 +27 -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 +27 -0
- package/dist/rsuite-rtl.min.css +1 -1
- package/dist/rsuite-rtl.min.css.map +1 -1
- package/dist/rsuite.css +27 -0
- package/dist/rsuite.js +144 -44
- 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.LICENSE.txt +35 -0
- package/dist/rsuite.min.js.map +1 -1
- package/esm/@types/common.d.ts +1 -1
- package/esm/Calendar/CalendarContainer.js +5 -5
- package/esm/DatePicker/DatePicker.d.ts +3 -38
- package/esm/DatePicker/DatePicker.js +88 -139
- package/esm/DatePicker/PredefinedRanges.d.ts +1 -1
- package/esm/DatePicker/PredefinedRanges.js +3 -3
- package/esm/DatePicker/Toolbar.d.ts +1 -1
- package/esm/DatePicker/Toolbar.js +13 -12
- package/esm/DatePicker/hooks/useFocus.d.ts +13 -0
- package/esm/DatePicker/hooks/useFocus.js +90 -0
- package/esm/DatePicker/hooks/useMonthView.d.ts +10 -0
- package/esm/DatePicker/hooks/useMonthView.js +22 -0
- package/esm/DatePicker/index.d.ts +2 -1
- package/esm/DatePicker/types.d.ts +37 -0
- package/esm/DatePicker/utils.d.ts +9 -0
- package/esm/DatePicker/utils.js +18 -2
- package/esm/DateRangePicker/DateRangePicker.d.ts +15 -3
- package/esm/DateRangePicker/DateRangePicker.js +61 -71
- package/esm/DateRangePicker/DateRangePickerContext.d.ts +4 -1
- package/esm/DateRangePicker/DateRangePickerContext.js +2 -2
- package/esm/DateRangePicker/Header.d.ts +11 -0
- package/esm/DateRangePicker/Header.js +59 -0
- package/esm/DateRangePicker/disabledDateUtils.d.ts +1 -1
- package/esm/DateRangePicker/disabledDateUtils.js +1 -1
- package/esm/DateRangePicker/index.js +4 -0
- package/esm/Form/Form.d.ts +56 -39
- package/esm/Form/Form.js +62 -183
- package/esm/Form/FormContext.d.ts +12 -9
- package/esm/Form/FormContext.js +6 -2
- package/esm/Form/hooks/useFormRef.d.ts +55 -0
- package/esm/Form/hooks/useFormRef.js +40 -0
- package/esm/Form/hooks/useFormValidate.d.ts +19 -0
- package/esm/Form/hooks/useFormValidate.js +152 -0
- package/esm/Form/hooks/useFormValue.d.ts +2 -1
- package/esm/Form/hooks/useFormValue.js +12 -1
- package/esm/Form/hooks/useSchemaModel.js +5 -0
- package/esm/Form/index.d.ts +2 -1
- package/esm/FormControl/FormControl.d.ts +1 -1
- package/esm/FormControl/FormControl.js +48 -66
- package/esm/FormControl/hooks/useField.d.ts +18 -0
- package/esm/FormControl/hooks/useField.js +48 -0
- package/esm/FormControl/hooks/useRegisterModel.d.ts +3 -0
- package/esm/FormControl/hooks/useRegisterModel.js +17 -0
- package/esm/FormControl/utils.d.ts +1 -0
- package/esm/FormControl/utils.js +4 -0
- package/esm/FormControlLabel/FormControlLabel.js +12 -8
- package/esm/FormErrorMessage/FormErrorMessage.js +2 -5
- package/esm/FormGroup/FormGroup.d.ts +18 -4
- package/esm/FormGroup/FormGroup.js +27 -1
- package/esm/FormGroup/index.d.ts +1 -0
- package/esm/FormGroup/index.js +1 -0
- package/esm/FormHelpText/FormHelpText.d.ts +2 -1
- package/esm/FormHelpText/FormHelpText.js +17 -9
- package/esm/Input/Input.js +4 -5
- package/esm/utils/dateUtils.d.ts +72 -10
- package/esm/utils/dateUtils.js +86 -28
- package/package.json +2 -2
- package/cjs/Form/hooks/useFormError.d.ts +0 -6
- package/cjs/Form/hooks/useFormError.js +0 -31
- package/cjs/FormControl/useRegisterModel.d.ts +0 -4
- package/cjs/FormControl/useRegisterModel.js +0 -18
- package/esm/Form/hooks/useFormError.d.ts +0 -6
- package/esm/Form/hooks/useFormError.js +0 -26
- package/esm/FormControl/useRegisterModel.d.ts +0 -4
- package/esm/FormControl/useRegisterModel.js +0 -13
package/esm/FormGroup/index.d.ts
CHANGED
package/esm/FormGroup/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { WithAsProps, RsRefForwardingComponent } from '../@types/common';
|
|
2
|
-
export interface FormHelpTextProps extends WithAsProps {
|
|
3
|
+
export interface FormHelpTextProps extends WithAsProps, React.HTMLAttributes<HTMLSpanElement> {
|
|
3
4
|
/** Whether to show through the Tooltip component */
|
|
4
5
|
tooltip?: boolean;
|
|
5
6
|
}
|
|
@@ -1,18 +1,20 @@
|
|
|
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 from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import Tooltip from '../Tooltip';
|
|
7
7
|
import Whisper from '../Whisper';
|
|
8
8
|
import { useClassNames } from '../utils';
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
9
|
+
import { useFormGroup } from '../FormGroup';
|
|
10
|
+
import HelpIcon from '@rsuite/icons/legacy/HelpO';
|
|
11
11
|
/**
|
|
12
12
|
* The `<Form.HelpText>` component is used to display help information in the form.
|
|
13
13
|
* @see https://rsuitejs.com/components/form/
|
|
14
14
|
*/
|
|
15
15
|
var FormHelpText = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
16
|
+
var _useFormGroup = useFormGroup(),
|
|
17
|
+
helpTextId = _useFormGroup.helpTextId;
|
|
16
18
|
var _props$as = props.as,
|
|
17
19
|
Component = _props$as === void 0 ? 'span' : _props$as,
|
|
18
20
|
_props$classPrefix = props.classPrefix,
|
|
@@ -20,9 +22,9 @@ var FormHelpText = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
20
22
|
className = props.className,
|
|
21
23
|
tooltip = props.tooltip,
|
|
22
24
|
children = props.children,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
_props$id = props.id,
|
|
26
|
+
id = _props$id === void 0 ? helpTextId : _props$id,
|
|
27
|
+
rest = _objectWithoutPropertiesLoose(props, ["as", "classPrefix", "className", "tooltip", "children", "id"]);
|
|
26
28
|
var _useClassNames = useClassNames(classPrefix),
|
|
27
29
|
withClassPrefix = _useClassNames.withClassPrefix,
|
|
28
30
|
merge = _useClassNames.merge;
|
|
@@ -33,13 +35,19 @@ var FormHelpText = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
33
35
|
return /*#__PURE__*/React.createElement(Whisper, {
|
|
34
36
|
ref: ref,
|
|
35
37
|
placement: "topEnd",
|
|
36
|
-
speaker: /*#__PURE__*/React.createElement(Tooltip,
|
|
38
|
+
speaker: /*#__PURE__*/React.createElement(Tooltip, _extends({
|
|
39
|
+
id: id
|
|
40
|
+
}, rest), children)
|
|
37
41
|
}, /*#__PURE__*/React.createElement(Component, {
|
|
42
|
+
role: "img",
|
|
43
|
+
"aria-label": "help",
|
|
38
44
|
className: classes
|
|
39
|
-
}, /*#__PURE__*/React.createElement(
|
|
45
|
+
}, /*#__PURE__*/React.createElement(HelpIcon, {
|
|
46
|
+
"aria-hidden": true
|
|
47
|
+
})));
|
|
40
48
|
}
|
|
41
49
|
return /*#__PURE__*/React.createElement(Component, _extends({
|
|
42
|
-
id:
|
|
50
|
+
id: id
|
|
43
51
|
}, rest, {
|
|
44
52
|
ref: ref,
|
|
45
53
|
className: classes
|
package/esm/Input/Input.js
CHANGED
|
@@ -3,7 +3,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
3
3
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
4
4
|
import React, { useContext } from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import {
|
|
6
|
+
import { useFormGroup } from '../FormGroup';
|
|
7
7
|
import { InputGroupContext } from '../InputGroup/InputGroup';
|
|
8
8
|
import Plaintext from '../internals/Plaintext';
|
|
9
9
|
import { createChainedFunction, mergeRefs, useClassNames, KEY_VALUES } from '../utils';
|
|
@@ -54,9 +54,8 @@ var Input = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
54
54
|
plaintext: plaintext
|
|
55
55
|
}));
|
|
56
56
|
var inputGroupContext = useContext(InputGroupContext);
|
|
57
|
-
var
|
|
58
|
-
|
|
59
|
-
// Make the Input component display in plain text,
|
|
57
|
+
var _useFormGroup = useFormGroup(),
|
|
58
|
+
controlId = _useFormGroup.controlId; // Make the Input component display in plain text,
|
|
60
59
|
// and display default characters when there is no value.
|
|
61
60
|
if (plaintext) {
|
|
62
61
|
return /*#__PURE__*/React.createElement(Plaintext, {
|
|
@@ -77,7 +76,7 @@ var Input = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
77
76
|
ref: mergeRefs(ref, inputRef),
|
|
78
77
|
className: classes,
|
|
79
78
|
type: type,
|
|
80
|
-
id: id ||
|
|
79
|
+
id: id || controlId,
|
|
81
80
|
value: value,
|
|
82
81
|
defaultValue: defaultValue,
|
|
83
82
|
disabled: disabled,
|
package/esm/utils/dateUtils.d.ts
CHANGED
|
@@ -43,28 +43,84 @@ export { default as set } from 'date-fns/set';
|
|
|
43
43
|
export { default as differenceInCalendarMonths } from 'date-fns/differenceInCalendarMonths';
|
|
44
44
|
export { default as isLastDayOfMonth } from 'date-fns/isLastDayOfMonth';
|
|
45
45
|
export { default as lastDayOfMonth } from 'date-fns/lastDayOfMonth';
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
declare enum TimeProp {
|
|
47
|
+
DisabledHours = "disabledHours",
|
|
48
|
+
DisabledMinutes = "disabledMinutes",
|
|
49
|
+
DisabledSeconds = "disabledSeconds",
|
|
50
|
+
ShouldDisableHour = "shouldDisableHour",
|
|
51
|
+
ShouldDisableMinute = "shouldDisableMinute",
|
|
52
|
+
ShouldDisableSecond = "shouldDisableSecond",
|
|
53
|
+
HideHours = "hideHours",
|
|
54
|
+
HideMinutes = "hideMinutes",
|
|
55
|
+
HideSeconds = "hideSeconds"
|
|
56
|
+
}
|
|
57
|
+
export declare type CalendarOnlyPropsType = TimeProp;
|
|
58
|
+
export declare const calendarOnlyProps: readonly [TimeProp.DisabledHours, TimeProp.DisabledMinutes, TimeProp.DisabledSeconds, TimeProp.HideHours, TimeProp.HideMinutes, TimeProp.HideSeconds];
|
|
59
|
+
interface CalendarProps {
|
|
60
|
+
[TimeProp.DisabledHours]?: (hours: number, date: Date) => boolean;
|
|
61
|
+
[TimeProp.DisabledMinutes]?: (minutes: number, date: Date) => boolean;
|
|
62
|
+
[TimeProp.DisabledSeconds]?: (seconds: number, date: Date) => boolean;
|
|
63
|
+
[TimeProp.HideHours]?: (hours: number, date: Date) => boolean;
|
|
64
|
+
[TimeProp.HideMinutes]?: (minutes: number, date: Date) => boolean;
|
|
65
|
+
[TimeProp.HideSeconds]?: (seconds: number, date: Date) => boolean;
|
|
66
|
+
}
|
|
48
67
|
/**
|
|
49
68
|
* Verify that the time is valid.
|
|
50
69
|
*
|
|
51
|
-
* @param props
|
|
52
|
-
* @param date
|
|
70
|
+
* @param props - The calendar props.
|
|
71
|
+
* @param date - The date to check.
|
|
72
|
+
* @returns Whether the time is disabled.
|
|
73
|
+
*/
|
|
74
|
+
export declare function disableTime(props: CalendarProps, date: Date): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Omit the calendar-only props from an object.
|
|
77
|
+
*
|
|
78
|
+
* @param props - The object to omit props from.
|
|
79
|
+
* @returns The object with calendar-only props omitted.
|
|
80
|
+
*/
|
|
81
|
+
export declare const omitHideDisabledProps: <T extends Record<string, any>>(props: T) => Partial<Omit<T, TimeProp>>;
|
|
82
|
+
/**
|
|
83
|
+
* Check if the time should be rendered based on the format.
|
|
84
|
+
*
|
|
85
|
+
* @param format - The format string.
|
|
86
|
+
* @returns Whether the time should be rendered.
|
|
53
87
|
*/
|
|
54
|
-
export declare function disabledTime(props: any, date: Date): boolean;
|
|
55
|
-
export declare const omitHideDisabledProps: <T extends Record<string, any>>(props: T) => Partial<Omit<T, CalendarOnlyPropsType>>;
|
|
56
88
|
export declare const shouldRenderTime: (format: string) => boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Check if the month should be rendered based on the format.
|
|
91
|
+
*
|
|
92
|
+
* @param format - The format string.
|
|
93
|
+
* @returns Whether the month should be rendered.
|
|
94
|
+
*/
|
|
57
95
|
export declare const shouldRenderMonth: (format: string) => boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Check if the date should be rendered based on the format.
|
|
98
|
+
*
|
|
99
|
+
* @param format - The format string.
|
|
100
|
+
* @returns Whether the date should be rendered.
|
|
101
|
+
*/
|
|
58
102
|
export declare const shouldRenderDate: (format: string) => boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Check if only the time should be rendered based on the format.
|
|
105
|
+
*
|
|
106
|
+
* @param format - The format string.
|
|
107
|
+
* @returns Whether only the time should be rendered.
|
|
108
|
+
*/
|
|
59
109
|
export declare const shouldOnlyRenderTime: (format: string) => boolean;
|
|
60
110
|
/**
|
|
61
|
-
* Get all weeks of
|
|
62
|
-
*
|
|
63
|
-
* @
|
|
111
|
+
* Get all weeks of a month.
|
|
112
|
+
*
|
|
113
|
+
* @param monthDate - The date of the month.
|
|
114
|
+
* @param isoWeek - Whether to use ISO week numbering.
|
|
115
|
+
* @returns An array of weeks in the month.
|
|
64
116
|
*/
|
|
65
117
|
export declare function getMonthView(monthDate: Date, isoWeek: boolean): Date[];
|
|
66
118
|
/**
|
|
67
|
-
* Copy the time
|
|
119
|
+
* Copy the time from one date to another.
|
|
120
|
+
*
|
|
121
|
+
* @param from - The source date.
|
|
122
|
+
* @param to - The target date.
|
|
123
|
+
* @returns The target date with the time copied from the source date.
|
|
68
124
|
*/
|
|
69
125
|
export declare function copyTime({ from, to }: {
|
|
70
126
|
from: Date;
|
|
@@ -72,9 +128,15 @@ export declare function copyTime({ from, to }: {
|
|
|
72
128
|
}): Date;
|
|
73
129
|
/**
|
|
74
130
|
* Swap two dates without swapping the time.
|
|
131
|
+
*
|
|
132
|
+
* @param dateRange - The date range to reverse.
|
|
133
|
+
* @returns The reversed date range.
|
|
75
134
|
*/
|
|
76
135
|
export declare function reverseDateRangeOmitTime(dateRange: [Date, Date]): [Date, Date];
|
|
77
136
|
/**
|
|
78
137
|
* Get the time with AM and PM reversed.
|
|
138
|
+
*
|
|
139
|
+
* @param date - The date to reverse the time meridian.
|
|
140
|
+
* @returns The date with the time meridian reversed.
|
|
79
141
|
*/
|
|
80
142
|
export declare const getReversedTimeMeridian: (date: Date) => Date;
|
package/esm/utils/dateUtils.js
CHANGED
|
@@ -54,63 +54,111 @@ export { default as set } from 'date-fns/set';
|
|
|
54
54
|
export { default as differenceInCalendarMonths } from 'date-fns/differenceInCalendarMonths';
|
|
55
55
|
export { default as isLastDayOfMonth } from 'date-fns/isLastDayOfMonth';
|
|
56
56
|
export { default as lastDayOfMonth } from 'date-fns/lastDayOfMonth';
|
|
57
|
-
var
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
var TimeProp;
|
|
58
|
+
(function (TimeProp) {
|
|
59
|
+
TimeProp["DisabledHours"] = "disabledHours";
|
|
60
|
+
TimeProp["DisabledMinutes"] = "disabledMinutes";
|
|
61
|
+
TimeProp["DisabledSeconds"] = "disabledSeconds";
|
|
62
|
+
TimeProp["ShouldDisableHour"] = "shouldDisableHour";
|
|
63
|
+
TimeProp["ShouldDisableMinute"] = "shouldDisableMinute";
|
|
64
|
+
TimeProp["ShouldDisableSecond"] = "shouldDisableSecond";
|
|
65
|
+
TimeProp["HideHours"] = "hideHours";
|
|
66
|
+
TimeProp["HideMinutes"] = "hideMinutes";
|
|
67
|
+
TimeProp["HideSeconds"] = "hideSeconds";
|
|
68
|
+
})(TimeProp || (TimeProp = {}));
|
|
69
|
+
export var calendarOnlyProps = [TimeProp.DisabledHours, TimeProp.DisabledMinutes, TimeProp.DisabledSeconds, TimeProp.HideHours, TimeProp.HideMinutes, TimeProp.HideSeconds];
|
|
70
|
+
var HOURS_PATTERN = /(Hours?)/;
|
|
71
|
+
var MINUTES_PATTERN = /(Minutes?)/;
|
|
72
|
+
var SECONDS_PATTERN = /(Seconds?)/;
|
|
73
|
+
/**
|
|
74
|
+
* Verify that the time is valid.
|
|
75
|
+
*
|
|
76
|
+
* @param props - The calendar props.
|
|
77
|
+
* @param date - The date to check.
|
|
78
|
+
* @returns Whether the time is disabled.
|
|
79
|
+
*/
|
|
80
|
+
export function disableTime(props, date) {
|
|
61
81
|
if (!date) {
|
|
62
82
|
return false;
|
|
63
83
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
84
|
+
var disabledTimeProps = [TimeProp.DisabledHours, TimeProp.DisabledMinutes, TimeProp.DisabledSeconds, TimeProp.ShouldDisableHour, TimeProp.ShouldDisableMinute, TimeProp.ShouldDisableSecond];
|
|
85
|
+
var calendarProps = pick(props, disabledTimeProps);
|
|
86
|
+
var mapProps = new Map(Object.entries(calendarProps));
|
|
87
|
+
return Array.from(mapProps.keys()).some(function (key) {
|
|
88
|
+
if (HOURS_PATTERN.test(key)) {
|
|
89
|
+
var _mapProps$get;
|
|
90
|
+
return (_mapProps$get = mapProps.get(key)) === null || _mapProps$get === void 0 ? void 0 : _mapProps$get(getHours(date), date);
|
|
68
91
|
}
|
|
69
|
-
if (
|
|
70
|
-
var
|
|
71
|
-
return (
|
|
92
|
+
if (MINUTES_PATTERN.test(key)) {
|
|
93
|
+
var _mapProps$get2;
|
|
94
|
+
return (_mapProps$get2 = mapProps.get(key)) === null || _mapProps$get2 === void 0 ? void 0 : _mapProps$get2(getMinutes(date), date);
|
|
72
95
|
}
|
|
73
|
-
if (
|
|
74
|
-
var
|
|
75
|
-
return (
|
|
96
|
+
if (SECONDS_PATTERN.test(key)) {
|
|
97
|
+
var _mapProps$get3;
|
|
98
|
+
return (_mapProps$get3 = mapProps.get(key)) === null || _mapProps$get3 === void 0 ? void 0 : _mapProps$get3(getSeconds(date), date);
|
|
76
99
|
}
|
|
77
100
|
return false;
|
|
78
101
|
});
|
|
79
102
|
}
|
|
80
103
|
|
|
81
104
|
/**
|
|
82
|
-
*
|
|
105
|
+
* Omit the calendar-only props from an object.
|
|
83
106
|
*
|
|
84
|
-
* @param props
|
|
85
|
-
* @
|
|
107
|
+
* @param props - The object to omit props from.
|
|
108
|
+
* @returns The object with calendar-only props omitted.
|
|
86
109
|
*/
|
|
87
|
-
export function disabledTime(props, date) {
|
|
88
|
-
var calendarProps = pick(props, disabledTimeProps);
|
|
89
|
-
return validTime(calendarProps, date);
|
|
90
|
-
}
|
|
91
110
|
export var omitHideDisabledProps = function omitHideDisabledProps(props) {
|
|
92
111
|
return omitBy(props, function (_val, key) {
|
|
93
|
-
return key.startsWith('disabled') || key.startsWith('hide');
|
|
112
|
+
return key.startsWith('disabled') || key.startsWith('hide') || key.startsWith('shouldDisable');
|
|
94
113
|
});
|
|
95
114
|
};
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Check if the time should be rendered based on the format.
|
|
118
|
+
*
|
|
119
|
+
* @param format - The format string.
|
|
120
|
+
* @returns Whether the time should be rendered.
|
|
121
|
+
*/
|
|
96
122
|
export var shouldRenderTime = function shouldRenderTime(format) {
|
|
97
123
|
return /([Hhms])/.test(format);
|
|
98
124
|
};
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Check if the month should be rendered based on the format.
|
|
128
|
+
*
|
|
129
|
+
* @param format - The format string.
|
|
130
|
+
* @returns Whether the month should be rendered.
|
|
131
|
+
*/
|
|
99
132
|
export var shouldRenderMonth = function shouldRenderMonth(format) {
|
|
100
133
|
return /[Yy]/.test(format) && /[ML]/.test(format);
|
|
101
134
|
};
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Check if the date should be rendered based on the format.
|
|
138
|
+
*
|
|
139
|
+
* @param format - The format string.
|
|
140
|
+
* @returns Whether the date should be rendered.
|
|
141
|
+
*/
|
|
102
142
|
export var shouldRenderDate = function shouldRenderDate(format) {
|
|
103
143
|
return /[Yy]/.test(format) && /[ML]/.test(format) && /[Dd]/.test(format);
|
|
104
|
-
};
|
|
144
|
+
};
|
|
105
145
|
|
|
146
|
+
/**
|
|
147
|
+
* Check if only the time should be rendered based on the format.
|
|
148
|
+
*
|
|
149
|
+
* @param format - The format string.
|
|
150
|
+
* @returns Whether only the time should be rendered.
|
|
151
|
+
*/
|
|
106
152
|
export var shouldOnlyRenderTime = function shouldOnlyRenderTime(format) {
|
|
107
153
|
return /([Hhms])/.test(format) && !/([YyMDd])/.test(format);
|
|
108
|
-
};
|
|
154
|
+
};
|
|
109
155
|
|
|
110
156
|
/**
|
|
111
|
-
* Get all weeks of
|
|
112
|
-
*
|
|
113
|
-
* @
|
|
157
|
+
* Get all weeks of a month.
|
|
158
|
+
*
|
|
159
|
+
* @param monthDate - The date of the month.
|
|
160
|
+
* @param isoWeek - Whether to use ISO week numbering.
|
|
161
|
+
* @returns An array of weeks in the month.
|
|
114
162
|
*/
|
|
115
163
|
export function getMonthView(monthDate, isoWeek) {
|
|
116
164
|
var firstDayOfMonth = getDay(monthDate);
|
|
@@ -133,7 +181,11 @@ export function getMonthView(monthDate, isoWeek) {
|
|
|
133
181
|
}
|
|
134
182
|
|
|
135
183
|
/**
|
|
136
|
-
* Copy the time
|
|
184
|
+
* Copy the time from one date to another.
|
|
185
|
+
*
|
|
186
|
+
* @param from - The source date.
|
|
187
|
+
* @param to - The target date.
|
|
188
|
+
* @returns The target date with the time copied from the source date.
|
|
137
189
|
*/
|
|
138
190
|
export function copyTime(_ref) {
|
|
139
191
|
var from = _ref.from,
|
|
@@ -150,6 +202,9 @@ export function copyTime(_ref) {
|
|
|
150
202
|
|
|
151
203
|
/**
|
|
152
204
|
* Swap two dates without swapping the time.
|
|
205
|
+
*
|
|
206
|
+
* @param dateRange - The date range to reverse.
|
|
207
|
+
* @returns The reversed date range.
|
|
153
208
|
*/
|
|
154
209
|
export function reverseDateRangeOmitTime(dateRange) {
|
|
155
210
|
var start = dateRange[0],
|
|
@@ -168,6 +223,9 @@ export function reverseDateRangeOmitTime(dateRange) {
|
|
|
168
223
|
|
|
169
224
|
/**
|
|
170
225
|
* Get the time with AM and PM reversed.
|
|
226
|
+
*
|
|
227
|
+
* @param date - The date to reverse the time meridian.
|
|
228
|
+
* @returns The date with the time meridian reversed.
|
|
171
229
|
*/
|
|
172
230
|
export var getReversedTimeMeridian = function getReversedTimeMeridian(date) {
|
|
173
231
|
var clonedDate = new Date(date.valueOf());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rsuite",
|
|
3
|
-
"version": "5.59.1",
|
|
3
|
+
"version": "5.59.3-alpha.1",
|
|
4
4
|
"description": "A suite of react components",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"react-use-set": "^1.0.0",
|
|
40
40
|
"react-window": "^1.8.8",
|
|
41
41
|
"rsuite-table": "^5.18.2",
|
|
42
|
-
"schema-typed": "^2.2.
|
|
42
|
+
"schema-typed": "^2.2.2"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"react": ">=16.8.0",
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
"use strict";
|
|
3
|
-
|
|
4
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
5
|
-
exports.__esModule = true;
|
|
6
|
-
exports.default = useFormError;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var _omit = _interopRequireDefault(require("lodash/omit"));
|
|
9
|
-
var _utils = require("../../utils");
|
|
10
|
-
function useFormError(formError) {
|
|
11
|
-
var _useControlled = (0, _utils.useControlled)(formError, {}),
|
|
12
|
-
realFormError = _useControlled[0],
|
|
13
|
-
setFormError = _useControlled[1];
|
|
14
|
-
var realFormErrorRef = (0, _react.useRef)(realFormError);
|
|
15
|
-
realFormErrorRef.current = realFormError;
|
|
16
|
-
var onRemoveError = (0, _react.useCallback)(function (name) {
|
|
17
|
-
/**
|
|
18
|
-
* when this function is called when the children component is unmount,
|
|
19
|
-
* it's an old render frame so use Ref to get future error
|
|
20
|
-
*/
|
|
21
|
-
var formError = (0, _omit.default)(realFormErrorRef.current, [name]);
|
|
22
|
-
realFormErrorRef.current = formError;
|
|
23
|
-
setFormError(formError);
|
|
24
|
-
return formError;
|
|
25
|
-
}, [setFormError]);
|
|
26
|
-
return {
|
|
27
|
-
formError: realFormError,
|
|
28
|
-
setFormError: setFormError,
|
|
29
|
-
onRemoveError: onRemoveError
|
|
30
|
-
};
|
|
31
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { FieldRuleType } from '../Form/hooks/useSchemaModel';
|
|
2
|
-
import type { CheckType } from 'schema-typed';
|
|
3
|
-
declare function useRegisterModel(name: string, pushFieldRule: (n: string, r: FieldRuleType) => void, removeFieldRule: (n: string) => void, rule?: CheckType<unknown, any>): void;
|
|
4
|
-
export default useRegisterModel;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
"use strict";
|
|
3
|
-
|
|
4
|
-
exports.__esModule = true;
|
|
5
|
-
exports.default = void 0;
|
|
6
|
-
var _react = require("react");
|
|
7
|
-
function useRegisterModel(name, pushFieldRule, removeFieldRule, rule) {
|
|
8
|
-
var refRule = (0, _react.useRef)(rule);
|
|
9
|
-
refRule.current = rule;
|
|
10
|
-
(0, _react.useEffect)(function () {
|
|
11
|
-
pushFieldRule(name, refRule);
|
|
12
|
-
return function () {
|
|
13
|
-
removeFieldRule(name);
|
|
14
|
-
};
|
|
15
|
-
}, [name, pushFieldRule, removeFieldRule]);
|
|
16
|
-
}
|
|
17
|
-
var _default = useRegisterModel;
|
|
18
|
-
exports.default = _default;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { useRef, useCallback } from 'react';
|
|
3
|
-
import omit from 'lodash/omit';
|
|
4
|
-
import { useControlled } from '../../utils';
|
|
5
|
-
export default function useFormError(formError) {
|
|
6
|
-
var _useControlled = useControlled(formError, {}),
|
|
7
|
-
realFormError = _useControlled[0],
|
|
8
|
-
setFormError = _useControlled[1];
|
|
9
|
-
var realFormErrorRef = useRef(realFormError);
|
|
10
|
-
realFormErrorRef.current = realFormError;
|
|
11
|
-
var onRemoveError = useCallback(function (name) {
|
|
12
|
-
/**
|
|
13
|
-
* when this function is called when the children component is unmount,
|
|
14
|
-
* it's an old render frame so use Ref to get future error
|
|
15
|
-
*/
|
|
16
|
-
var formError = omit(realFormErrorRef.current, [name]);
|
|
17
|
-
realFormErrorRef.current = formError;
|
|
18
|
-
setFormError(formError);
|
|
19
|
-
return formError;
|
|
20
|
-
}, [setFormError]);
|
|
21
|
-
return {
|
|
22
|
-
formError: realFormError,
|
|
23
|
-
setFormError: setFormError,
|
|
24
|
-
onRemoveError: onRemoveError
|
|
25
|
-
};
|
|
26
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { FieldRuleType } from '../Form/hooks/useSchemaModel';
|
|
2
|
-
import type { CheckType } from 'schema-typed';
|
|
3
|
-
declare function useRegisterModel(name: string, pushFieldRule: (n: string, r: FieldRuleType) => void, removeFieldRule: (n: string) => void, rule?: CheckType<unknown, any>): void;
|
|
4
|
-
export default useRegisterModel;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { useRef, useEffect } from 'react';
|
|
3
|
-
function useRegisterModel(name, pushFieldRule, removeFieldRule, rule) {
|
|
4
|
-
var refRule = useRef(rule);
|
|
5
|
-
refRule.current = rule;
|
|
6
|
-
useEffect(function () {
|
|
7
|
-
pushFieldRule(name, refRule);
|
|
8
|
-
return function () {
|
|
9
|
-
removeFieldRule(name);
|
|
10
|
-
};
|
|
11
|
-
}, [name, pushFieldRule, removeFieldRule]);
|
|
12
|
-
}
|
|
13
|
-
export default useRegisterModel;
|