rsuite 5.4.0 → 5.4.4
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/Button/styles/index.less +1 -5
- package/CHANGELOG.md +38 -0
- package/CheckTreePicker/styles/index.less +1 -1
- package/Drawer/styles/index.less +3 -0
- package/Dropdown/styles/index.less +6 -22
- package/Dropdown/styles/mixin.less +0 -2
- package/Modal/styles/index.less +23 -22
- package/Navbar/styles/index.less +20 -8
- package/README.md +1 -1
- package/Sidenav/styles/index.less +8 -2
- package/cjs/Affix/Affix.js +3 -1
- package/cjs/AvatarGroup/AvatarGroup.js +9 -4
- package/cjs/ButtonGroup/ButtonGroup.js +9 -4
- package/cjs/Calendar/Calendar.js +21 -20
- package/cjs/Calendar/Header.js +1 -3
- package/cjs/Calendar/Table.js +1 -1
- package/cjs/Calendar/TableRow.js +12 -7
- package/cjs/Calendar/View.js +9 -5
- package/cjs/Calendar/useCalendarDate.d.ts +1 -1
- package/cjs/Calendar/useCalendarDate.js +1 -1
- package/cjs/Carousel/Carousel.js +7 -1
- package/cjs/Cascader/Cascader.js +13 -2
- package/cjs/CheckPicker/CheckPicker.d.ts +5 -2
- package/cjs/CheckPicker/test/CheckPicker.test.js +8 -0
- package/cjs/CheckTree/index.js +9 -4
- package/cjs/CheckTreePicker/CheckTreePicker.js +1 -1
- package/cjs/CheckTreePicker/utils.js +1 -1
- package/cjs/Container/Container.js +6 -3
- package/cjs/CustomProvider/CustomProvider.d.ts +14 -14
- package/cjs/CustomProvider/CustomProvider.js +4 -3
- package/cjs/DatePicker/DatePicker.d.ts +1 -1
- package/cjs/DatePicker/DatePicker.js +5 -5
- package/cjs/DateRangePicker/DateRangePicker.js +3 -3
- package/cjs/Disclosure/Disclosure.d.ts +8 -5
- package/cjs/Disclosure/Disclosure.js +51 -11
- package/cjs/Disclosure/DisclosureButton.d.ts +2 -2
- package/cjs/Disclosure/DisclosureContext.d.ts +6 -1
- package/cjs/Dropdown/Dropdown.js +1 -1
- package/cjs/Dropdown/DropdownItem.js +9 -10
- package/cjs/Dropdown/DropdownMenu.js +78 -26
- package/cjs/FormGroup/FormGroup.js +9 -4
- package/cjs/Menu/MenuItem.js +1 -1
- package/cjs/Modal/Modal.js +34 -22
- package/cjs/Modal/utils.js +16 -8
- package/cjs/MultiCascader/MultiCascader.js +6 -3
- package/cjs/Nav/Nav.js +10 -15
- package/cjs/Nav/NavItem.js +3 -1
- package/cjs/Navbar/index.d.ts +1 -0
- package/cjs/Navbar/index.js +4 -3
- package/cjs/Overlay/Modal.js +18 -32
- package/cjs/PanelGroup/PanelGroup.js +8 -5
- package/cjs/Picker/DropdownMenu.js +5 -0
- package/cjs/Picker/PickerToggle.js +2 -4
- package/cjs/SelectPicker/SelectPicker.d.ts +5 -2
- package/cjs/SelectPicker/test/SelectPicker.test.js +8 -0
- package/cjs/Toggle/Toggle.js +2 -1
- package/cjs/Tree/Tree.js +9 -4
- package/cjs/Uploader/UploadFileItem.d.ts +1 -1
- package/cjs/Uploader/UploadFileItem.js +1 -1
- package/cjs/Uploader/Uploader.js +3 -0
- package/cjs/utils/index.d.ts +1 -0
- package/cjs/utils/index.js +7 -2
- package/cjs/utils/propTypeChecker.d.ts +2 -6
- package/cjs/utils/propTypeChecker.js +7 -59
- package/cjs/utils/useClickOutside.js +6 -2
- package/cjs/utils/useMount.d.ts +2 -0
- package/cjs/utils/useMount.js +19 -0
- package/dist/rsuite-rtl.css +336 -180
- package/dist/rsuite-rtl.min.css +1 -1
- package/dist/rsuite-rtl.min.css.map +1 -1
- package/dist/rsuite.css +336 -180
- package/dist/rsuite.js +67 -45
- 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/Affix/Affix.js +4 -2
- package/esm/AvatarGroup/AvatarGroup.js +7 -4
- package/esm/ButtonGroup/ButtonGroup.js +7 -4
- package/esm/Calendar/Calendar.js +22 -21
- package/esm/Calendar/Header.js +1 -3
- package/esm/Calendar/Table.js +1 -1
- package/esm/Calendar/TableRow.js +13 -8
- package/esm/Calendar/View.js +10 -6
- package/esm/Calendar/useCalendarDate.d.ts +1 -1
- package/esm/Calendar/useCalendarDate.js +1 -1
- package/esm/Carousel/Carousel.js +9 -3
- package/esm/Cascader/Cascader.js +13 -2
- package/esm/CheckPicker/CheckPicker.d.ts +5 -2
- package/esm/CheckPicker/test/CheckPicker.test.js +7 -0
- package/esm/CheckTree/index.js +7 -4
- package/esm/CheckTreePicker/CheckTreePicker.js +1 -1
- package/esm/CheckTreePicker/utils.js +1 -1
- package/esm/Container/Container.js +7 -4
- package/esm/CustomProvider/CustomProvider.d.ts +14 -14
- package/esm/CustomProvider/CustomProvider.js +2 -2
- package/esm/DatePicker/DatePicker.d.ts +1 -1
- package/esm/DatePicker/DatePicker.js +5 -4
- package/esm/DateRangePicker/DateRangePicker.js +3 -3
- package/esm/Disclosure/Disclosure.d.ts +8 -5
- package/esm/Disclosure/Disclosure.js +52 -13
- package/esm/Disclosure/DisclosureButton.d.ts +2 -2
- package/esm/Disclosure/DisclosureContext.d.ts +6 -1
- package/esm/Dropdown/Dropdown.js +1 -1
- package/esm/Dropdown/DropdownItem.js +9 -9
- package/esm/Dropdown/DropdownMenu.js +79 -27
- package/esm/FormGroup/FormGroup.js +7 -4
- package/esm/Menu/MenuItem.js +1 -1
- package/esm/Modal/Modal.js +36 -24
- package/esm/Modal/utils.js +16 -8
- package/esm/MultiCascader/MultiCascader.js +6 -3
- package/esm/Nav/Nav.js +11 -16
- package/esm/Nav/NavItem.js +3 -1
- package/esm/Navbar/index.d.ts +1 -0
- package/esm/Navbar/index.js +1 -0
- package/esm/Overlay/Modal.js +19 -33
- package/esm/PanelGroup/PanelGroup.js +9 -6
- package/esm/Picker/DropdownMenu.js +5 -0
- package/esm/Picker/PickerToggle.js +2 -4
- package/esm/SelectPicker/SelectPicker.d.ts +5 -2
- package/esm/SelectPicker/test/SelectPicker.test.js +7 -0
- package/esm/Toggle/Toggle.js +2 -1
- package/esm/Tree/Tree.js +7 -4
- package/esm/Uploader/UploadFileItem.d.ts +1 -1
- package/esm/Uploader/UploadFileItem.js +1 -1
- package/esm/Uploader/Uploader.js +4 -1
- package/esm/utils/index.d.ts +1 -0
- package/esm/utils/index.js +2 -1
- package/esm/utils/propTypeChecker.d.ts +2 -6
- package/esm/utils/propTypeChecker.js +7 -59
- package/esm/utils/useClickOutside.js +6 -2
- package/esm/utils/useMount.d.ts +2 -0
- package/esm/utils/useMount.js +13 -0
- package/package.json +2 -2
- package/styles/color-modes/dark.less +1 -0
- package/styles/color-modes/high-contrast.less +1 -0
- package/styles/color-modes/light.less +1 -0
- package/styles/mixins/utilities.less +17 -5
package/esm/Affix/Affix.js
CHANGED
|
@@ -3,7 +3,7 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
3
3
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import getOffset from 'dom-lib/getOffset';
|
|
6
|
-
import { mergeRefs, useClassNames, useElementResize, useEventListener } from '../utils';
|
|
6
|
+
import { mergeRefs, useClassNames, useElementResize, useEventListener, useMount } from '../utils';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Get the layout size and offset of the mount element
|
|
@@ -21,7 +21,9 @@ function useOffset(mountRef) {
|
|
|
21
21
|
return mountRef.current;
|
|
22
22
|
}, updateOffset); // Initialize after the first render
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
useMount(updateOffset); // Update after window size changes
|
|
25
|
+
|
|
26
|
+
useEventListener(window, 'resize', updateOffset, false);
|
|
25
27
|
return offset;
|
|
26
28
|
}
|
|
27
29
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
import React from 'react';
|
|
3
|
+
import React, { useMemo } from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import { useClassNames, useCustom } from '../utils';
|
|
6
6
|
export var AvatarGroupContext = /*#__PURE__*/React.createContext({});
|
|
@@ -26,13 +26,16 @@ var AvatarGroup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
26
26
|
var classes = merge(className, withClassPrefix({
|
|
27
27
|
stack: stack
|
|
28
28
|
}));
|
|
29
|
+
var contextValue = useMemo(function () {
|
|
30
|
+
return {
|
|
31
|
+
size: size
|
|
32
|
+
};
|
|
33
|
+
}, [size]);
|
|
29
34
|
return /*#__PURE__*/React.createElement(Component, _extends({}, rest, {
|
|
30
35
|
ref: ref,
|
|
31
36
|
className: classes
|
|
32
37
|
}), /*#__PURE__*/React.createElement(AvatarGroupContext.Provider, {
|
|
33
|
-
value:
|
|
34
|
-
size: size
|
|
35
|
-
}
|
|
38
|
+
value: contextValue
|
|
36
39
|
}, spacing ? React.Children.map(children, function (child) {
|
|
37
40
|
var _extends2;
|
|
38
41
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
import React from 'react';
|
|
3
|
+
import React, { useMemo } from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import { useClassNames } from '../utils';
|
|
6
6
|
import ButtonGroupContext from './ButtonGroupContext';
|
|
@@ -28,10 +28,13 @@ var ButtonGroup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
28
28
|
vertical: vertical,
|
|
29
29
|
justified: justified
|
|
30
30
|
}));
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
var contextValue = useMemo(function () {
|
|
32
|
+
return {
|
|
33
33
|
size: size
|
|
34
|
-
}
|
|
34
|
+
};
|
|
35
|
+
}, [size]);
|
|
36
|
+
return /*#__PURE__*/React.createElement(ButtonGroupContext.Provider, {
|
|
37
|
+
value: contextValue
|
|
35
38
|
}, /*#__PURE__*/React.createElement(Component, _extends({}, rest, {
|
|
36
39
|
role: role,
|
|
37
40
|
ref: ref,
|
package/esm/Calendar/Calendar.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
import React, { useCallback } from 'react';
|
|
3
|
+
import React, { useCallback, useMemo } from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import pick from 'lodash/pick';
|
|
6
6
|
import MonthDropdown from './MonthDropdown';
|
|
@@ -56,11 +56,11 @@ var Calendar = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
56
56
|
withClassPrefix = _useClassNames.withClassPrefix,
|
|
57
57
|
merge = _useClassNames.merge;
|
|
58
58
|
|
|
59
|
-
var isDisabledDate = function
|
|
59
|
+
var isDisabledDate = useCallback(function (date) {
|
|
60
60
|
var _disabledDate;
|
|
61
61
|
|
|
62
62
|
return (_disabledDate = disabledDate === null || disabledDate === void 0 ? void 0 : disabledDate(date)) !== null && _disabledDate !== void 0 ? _disabledDate : false;
|
|
63
|
-
};
|
|
63
|
+
}, [disabledDate]);
|
|
64
64
|
|
|
65
65
|
var isTimeDisabled = function isTimeDisabled(date) {
|
|
66
66
|
return DateUtils.disabledTime(props, date);
|
|
@@ -92,27 +92,28 @@ var Calendar = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
92
92
|
'show-week-numbers': showWeekNumbers
|
|
93
93
|
}));
|
|
94
94
|
var timeDropdownProps = pick(rest, DateUtils.calendarOnlyProps);
|
|
95
|
-
var contextValue = {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
95
|
+
var contextValue = useMemo(function () {
|
|
96
|
+
return {
|
|
97
|
+
date: calendarDate,
|
|
98
|
+
dateRange: dateRange,
|
|
99
|
+
disabledDate: isDisabledDate,
|
|
100
|
+
format: format,
|
|
101
|
+
hoverRangeValue: hoverRangeValue,
|
|
102
|
+
inSameMonth: inSameMonth !== null && inSameMonth !== void 0 ? inSameMonth : inSameThisMonthDate,
|
|
103
|
+
isoWeek: isoWeek,
|
|
104
|
+
locale: locale,
|
|
105
|
+
onChangePageDate: onChangePageDate,
|
|
106
|
+
onChangePageTime: onChangePageTime,
|
|
107
|
+
onMouseMove: onMouseMove,
|
|
108
|
+
onSelect: onSelect,
|
|
109
|
+
renderCell: renderCell,
|
|
110
|
+
showWeekNumbers: showWeekNumbers,
|
|
111
|
+
inline: inline
|
|
112
|
+
};
|
|
113
|
+
}, [calendarDate, dateRange, format, hoverRangeValue, inSameMonth, inSameThisMonthDate, inline, isDisabledDate, isoWeek, locale, onChangePageDate, onChangePageTime, onMouseMove, onSelect, renderCell, showWeekNumbers]);
|
|
112
114
|
return /*#__PURE__*/React.createElement(CalendarProvider, {
|
|
113
115
|
value: contextValue
|
|
114
116
|
}, /*#__PURE__*/React.createElement(Component, _extends({}, DateUtils.omitHideDisabledProps(rest), {
|
|
115
|
-
role: "table",
|
|
116
117
|
className: calendarClasses,
|
|
117
118
|
ref: ref
|
|
118
119
|
}), /*#__PURE__*/React.createElement(Header, {
|
package/esm/Calendar/Header.js
CHANGED
|
@@ -117,9 +117,7 @@ var Header = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
117
117
|
'has-month': hasMonth,
|
|
118
118
|
'has-time': showTime
|
|
119
119
|
}));
|
|
120
|
-
return /*#__PURE__*/React.createElement(Component, _extends({
|
|
121
|
-
role: "row"
|
|
122
|
-
}, rest, {
|
|
120
|
+
return /*#__PURE__*/React.createElement(Component, _extends({}, rest, {
|
|
123
121
|
ref: ref,
|
|
124
122
|
className: classes
|
|
125
123
|
}), hasMonth && monthToolbar, showTime && /*#__PURE__*/React.createElement("div", {
|
package/esm/Calendar/Table.js
CHANGED
|
@@ -21,7 +21,7 @@ var Table = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
21
21
|
|
|
22
22
|
var classes = merge(className, withClassPrefix());
|
|
23
23
|
return /*#__PURE__*/React.createElement(Component, _extends({
|
|
24
|
-
role: "
|
|
24
|
+
role: "grid"
|
|
25
25
|
}, rest, {
|
|
26
26
|
ref: ref,
|
|
27
27
|
className: classes
|
package/esm/Calendar/TableRow.js
CHANGED
|
@@ -3,7 +3,7 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
3
3
|
import React, { useCallback } from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import partial from 'lodash/partial';
|
|
6
|
-
import { DateUtils, useClassNames, DATERANGE_DISABLED_TARGET } from '../utils';
|
|
6
|
+
import { DateUtils, useClassNames, DATERANGE_DISABLED_TARGET, useCustom } from '../utils';
|
|
7
7
|
import { useCalendarContext } from './CalendarContext';
|
|
8
8
|
var TableRow = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
9
9
|
var _props$as = props.as,
|
|
@@ -20,16 +20,19 @@ var TableRow = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
20
20
|
selected = _useCalendarContext$d === void 0 ? new Date() : _useCalendarContext$d,
|
|
21
21
|
dateRange = _useCalendarContext.dateRange,
|
|
22
22
|
disabledDate = _useCalendarContext.disabledDate,
|
|
23
|
-
formatDate = _useCalendarContext.formatDate,
|
|
24
23
|
hoverRangeValue = _useCalendarContext.hoverRangeValue,
|
|
25
24
|
inSameMonth = _useCalendarContext.inSameMonth,
|
|
26
25
|
isoWeek = _useCalendarContext.isoWeek,
|
|
27
26
|
onMouseMove = _useCalendarContext.onMouseMove,
|
|
28
27
|
onSelect = _useCalendarContext.onSelect,
|
|
29
28
|
renderCell = _useCalendarContext.renderCell,
|
|
30
|
-
|
|
29
|
+
overrideLocale = _useCalendarContext.locale,
|
|
31
30
|
showWeekNumbers = _useCalendarContext.showWeekNumbers;
|
|
32
31
|
|
|
32
|
+
var _useCustom = useCustom('Calendar', overrideLocale),
|
|
33
|
+
locale = _useCustom.locale,
|
|
34
|
+
formatDate = _useCustom.formatDate;
|
|
35
|
+
|
|
33
36
|
var _useClassNames = useClassNames(classPrefix),
|
|
34
37
|
prefix = _useClassNames.prefix,
|
|
35
38
|
merge = _useClassNames.merge;
|
|
@@ -43,7 +46,7 @@ var TableRow = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
43
46
|
}, [onSelect]);
|
|
44
47
|
|
|
45
48
|
var renderDays = function renderDays() {
|
|
46
|
-
var formatStr =
|
|
49
|
+
var formatStr = locale.formattedDayPattern;
|
|
47
50
|
var days = [];
|
|
48
51
|
|
|
49
52
|
var _ref = dateRange || [],
|
|
@@ -64,7 +67,7 @@ var TableRow = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
64
67
|
var unSameMonth = !(inSameMonth !== null && inSameMonth !== void 0 && inSameMonth(thisDate));
|
|
65
68
|
var isStartSelected = !unSameMonth && selectedStartDate && DateUtils.isSameDay(thisDate, selectedStartDate);
|
|
66
69
|
var isEndSelected = !unSameMonth && selectedEndDate && DateUtils.isSameDay(thisDate, selectedEndDate);
|
|
67
|
-
var isSelected = isStartSelected || isEndSelected;
|
|
70
|
+
var isSelected = isRangeSelectionMode ? isStartSelected || isEndSelected : DateUtils.isSameDay(thisDate, selected);
|
|
68
71
|
var inRange = false; // for Selected
|
|
69
72
|
|
|
70
73
|
if (selectedStartDate && selectedEndDate) {
|
|
@@ -91,7 +94,7 @@ var TableRow = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
91
94
|
var _classes = prefix('cell', {
|
|
92
95
|
'cell-un-same-month': unSameMonth,
|
|
93
96
|
'cell-is-today': isToday,
|
|
94
|
-
'cell-selected':
|
|
97
|
+
'cell-selected': isSelected,
|
|
95
98
|
'cell-selected-start': isStartSelected,
|
|
96
99
|
'cell-selected-end': isEndSelected,
|
|
97
100
|
'cell-in-range': !unSameMonth && inRange,
|
|
@@ -100,8 +103,10 @@ var TableRow = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
100
103
|
|
|
101
104
|
var title = formatDate ? formatDate(thisDate, formatStr) : DateUtils.format(thisDate, formatStr);
|
|
102
105
|
days.push( /*#__PURE__*/React.createElement("div", {
|
|
103
|
-
role: "
|
|
106
|
+
role: "gridcell",
|
|
104
107
|
key: title,
|
|
108
|
+
"aria-label": title,
|
|
109
|
+
"aria-selected": isSelected || undefined,
|
|
105
110
|
className: _classes
|
|
106
111
|
}, /*#__PURE__*/React.createElement("div", {
|
|
107
112
|
role: "button",
|
|
@@ -125,7 +130,7 @@ var TableRow = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
125
130
|
className: classes
|
|
126
131
|
}), showWeekNumbers && /*#__PURE__*/React.createElement("div", {
|
|
127
132
|
className: prefix('cell-week-number'),
|
|
128
|
-
role: "
|
|
133
|
+
role: "rowheader"
|
|
129
134
|
}, DateUtils.format(weekendDate, isoWeek ? 'I' : 'w')), renderDays());
|
|
130
135
|
});
|
|
131
136
|
TableRow.displayName = 'TableRow';
|
package/esm/Calendar/View.js
CHANGED
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
|
-
import { DateUtils, useClassNames } from '../utils';
|
|
5
|
+
import { DateUtils, useClassNames, useCustom } from '../utils';
|
|
6
6
|
import Table from './Table';
|
|
7
7
|
import { useCalendarContext } from './CalendarContext';
|
|
8
8
|
var View = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
@@ -16,7 +16,12 @@ var View = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
16
16
|
var _useCalendarContext = useCalendarContext(),
|
|
17
17
|
_useCalendarContext$d = _useCalendarContext.date,
|
|
18
18
|
date = _useCalendarContext$d === void 0 ? new Date() : _useCalendarContext$d,
|
|
19
|
-
isoWeek = _useCalendarContext.isoWeek
|
|
19
|
+
isoWeek = _useCalendarContext.isoWeek,
|
|
20
|
+
overrideLocale = _useCalendarContext.locale;
|
|
21
|
+
|
|
22
|
+
var _useCustom = useCustom('Calendar', overrideLocale),
|
|
23
|
+
locale = _useCustom.locale,
|
|
24
|
+
formatDate = _useCustom.formatDate;
|
|
20
25
|
|
|
21
26
|
var thisMonthDate = DateUtils.setDate(date, 1);
|
|
22
27
|
|
|
@@ -25,13 +30,12 @@ var View = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
25
30
|
withClassPrefix = _useClassNames.withClassPrefix;
|
|
26
31
|
|
|
27
32
|
var classes = merge(className, withClassPrefix());
|
|
28
|
-
return /*#__PURE__*/React.createElement(Component, _extends({
|
|
29
|
-
role: "row"
|
|
30
|
-
}, rest, {
|
|
33
|
+
return /*#__PURE__*/React.createElement(Component, _extends({}, rest, {
|
|
31
34
|
ref: ref,
|
|
32
35
|
className: classes
|
|
33
36
|
}), /*#__PURE__*/React.createElement(Table, {
|
|
34
|
-
rows: DateUtils.getMonthView(thisMonthDate, isoWeek)
|
|
37
|
+
rows: DateUtils.getMonthView(thisMonthDate, isoWeek),
|
|
38
|
+
"aria-label": formatDate(thisMonthDate, locale.formattedMonthPattern)
|
|
35
39
|
}));
|
|
36
40
|
});
|
|
37
41
|
View.displayName = 'View';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const useCalendarDate: (value: Date | undefined, defaultDate: Date | undefined) => {
|
|
1
|
+
declare const useCalendarDate: (value: Date | null | undefined, defaultDate: Date | undefined) => {
|
|
2
2
|
calendarDate: Date;
|
|
3
3
|
setCalendarDate: (date: Date | undefined) => void;
|
|
4
4
|
};
|
|
@@ -19,7 +19,7 @@ var useCalendarDate = function useCalendarDate(value, defaultDate) {
|
|
|
19
19
|
var _valueRef$current;
|
|
20
20
|
|
|
21
21
|
if ((value === null || value === void 0 ? void 0 : value.valueOf()) !== ((_valueRef$current = valueRef.current) === null || _valueRef$current === void 0 ? void 0 : _valueRef$current.valueOf())) {
|
|
22
|
-
setCalendarDate(value);
|
|
22
|
+
setCalendarDate(value !== null && value !== void 0 ? value : new Date());
|
|
23
23
|
valueRef.current = value;
|
|
24
24
|
}
|
|
25
25
|
}, [value]);
|
package/esm/Carousel/Carousel.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
import React, { useState, useMemo, useCallback } from 'react';
|
|
3
|
+
import React, { useState, useMemo, useCallback, useRef } from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import classNames from 'classnames';
|
|
6
|
-
import { useClassNames, useCustom, guid, ReactChildren, useTimeout } from '../utils';
|
|
6
|
+
import { useClassNames, useCustom, guid, ReactChildren, useTimeout, mergeRefs } from '../utils';
|
|
7
7
|
var Carousel = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
8
8
|
var _sliderStyles, _ref;
|
|
9
9
|
|
|
@@ -46,7 +46,13 @@ var Carousel = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
46
46
|
lastIndex = _useState2[0],
|
|
47
47
|
setLastIndex = _useState2[1];
|
|
48
48
|
|
|
49
|
+
var rootRef = useRef(null);
|
|
50
|
+
|
|
49
51
|
var handleSlide = function handleSlide(nextActiveIndex, event) {
|
|
52
|
+
if (!rootRef.current) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
50
56
|
clear();
|
|
51
57
|
var index = nextActiveIndex !== null && nextActiveIndex !== void 0 ? nextActiveIndex : activeIndex + 1; // When index is greater than count, start from 1 again.
|
|
52
58
|
|
|
@@ -111,7 +117,7 @@ var Carousel = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
111
117
|
var sliderStyles = (_sliderStyles = {}, _sliderStyles[lengthKey] = count * 100 + "%", _sliderStyles.transform = vertical ? "translate3d(0, " + activeRatio + " ,0)" : "translate3d(" + activeRatio + ", 0 ,0)", _sliderStyles);
|
|
112
118
|
var showMask = count > 1 && activeIndex === 0 && activeIndex !== lastIndex;
|
|
113
119
|
return /*#__PURE__*/React.createElement(Component, _extends({}, rest, {
|
|
114
|
-
ref: ref,
|
|
120
|
+
ref: mergeRefs(ref, rootRef),
|
|
115
121
|
className: classes
|
|
116
122
|
}), /*#__PURE__*/React.createElement("div", {
|
|
117
123
|
className: prefix('content')
|
package/esm/Cascader/Cascader.js
CHANGED
|
@@ -188,10 +188,18 @@ var Cascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
188
188
|
}
|
|
189
189
|
}, [getSearchResult, onSearch, setFocusItemValue, setKeys, setLayer, valueKey]);
|
|
190
190
|
var handleEntered = useCallback(function () {
|
|
191
|
+
if (!targetRef.current) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
|
|
191
195
|
onOpen === null || onOpen === void 0 ? void 0 : onOpen();
|
|
192
196
|
setActive(true);
|
|
193
197
|
}, [onOpen]);
|
|
194
198
|
var handleExited = useCallback(function () {
|
|
199
|
+
if (!targetRef.current) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
|
|
195
203
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
196
204
|
setActive(false);
|
|
197
205
|
setSearchKeyword('');
|
|
@@ -202,7 +210,7 @@ var Cascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
202
210
|
(_triggerRef$current = triggerRef.current) === null || _triggerRef$current === void 0 ? void 0 : _triggerRef$current.close();
|
|
203
211
|
}, [triggerRef]);
|
|
204
212
|
var handleClean = useCallback(function (event) {
|
|
205
|
-
if (disabled) {
|
|
213
|
+
if (disabled || !targetRef.current) {
|
|
206
214
|
return;
|
|
207
215
|
}
|
|
208
216
|
|
|
@@ -260,7 +268,10 @@ var Cascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
260
268
|
children.then(function (data) {
|
|
261
269
|
node.loading = false;
|
|
262
270
|
node[childrenKey] = data;
|
|
263
|
-
|
|
271
|
+
|
|
272
|
+
if (targetRef.current) {
|
|
273
|
+
addColumn(data, cascadePaths.length);
|
|
274
|
+
}
|
|
264
275
|
});
|
|
265
276
|
} else {
|
|
266
277
|
node.loading = false;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { Ref } from 'react';
|
|
2
2
|
import { PickerLocale } from '../locales';
|
|
3
|
+
import { PickerInstance } from '../Picker';
|
|
3
4
|
import { ItemDataType, FormControlPickerProps } from '../@types/common';
|
|
4
5
|
import type { MultipleSelectProps } from '../SelectPicker';
|
|
5
6
|
export declare type ValueType = (number | string)[];
|
|
@@ -10,7 +11,9 @@ export interface CheckPickerProps<T> extends FormControlPickerProps<T[], PickerL
|
|
|
10
11
|
countable?: boolean;
|
|
11
12
|
}
|
|
12
13
|
export interface CheckPickerComponent {
|
|
13
|
-
<T>(props: CheckPickerProps<T>
|
|
14
|
+
<T>(props: CheckPickerProps<T> & {
|
|
15
|
+
ref?: Ref<PickerInstance>;
|
|
16
|
+
}): JSX.Element | null;
|
|
14
17
|
displayName?: string;
|
|
15
18
|
propTypes?: React.WeakValidationMap<CheckPickerProps<any>>;
|
|
16
19
|
}
|
|
@@ -61,4 +61,11 @@ React.createElement(CheckPicker, {
|
|
|
61
61
|
onChange: function onChange(newValue) {
|
|
62
62
|
expectType(newValue);
|
|
63
63
|
}
|
|
64
|
+
});
|
|
65
|
+
var pickerRef = /*#__PURE__*/React.createRef();
|
|
66
|
+
|
|
67
|
+
/*#__PURE__*/
|
|
68
|
+
React.createElement(CheckPicker, {
|
|
69
|
+
ref: pickerRef,
|
|
70
|
+
data: []
|
|
64
71
|
});
|
package/esm/CheckTree/index.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { useMemo } from 'react';
|
|
3
3
|
import CheckTreePicker from '../CheckTreePicker';
|
|
4
4
|
import TreeContext from '../Tree/TreeContext';
|
|
5
5
|
var CheckTree = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
var contextValue = useMemo(function () {
|
|
7
|
+
return {
|
|
8
8
|
inline: true
|
|
9
|
-
}
|
|
9
|
+
};
|
|
10
|
+
}, []);
|
|
11
|
+
return /*#__PURE__*/React.createElement(TreeContext.Provider, {
|
|
12
|
+
value: contextValue
|
|
10
13
|
}, /*#__PURE__*/React.createElement(CheckTreePicker, _extends({
|
|
11
14
|
ref: ref
|
|
12
15
|
}, props)));
|
|
@@ -621,7 +621,7 @@ var CheckTreePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
621
621
|
var renderCheckTree = function renderCheckTree() {
|
|
622
622
|
var _withCheckTreeClassPr, _merge2;
|
|
623
623
|
|
|
624
|
-
var classes = withCheckTreeClassPrefix((_withCheckTreeClassPr = {}, _withCheckTreeClassPr[className !== null && className !== void 0 ? className : ''] = inline, _withCheckTreeClassPr['without-children'] = !isSomeNodeHasChildren, _withCheckTreeClassPr.virtualized = virtualized, _withCheckTreeClassPr));
|
|
624
|
+
var classes = withCheckTreeClassPrefix((_withCheckTreeClassPr = {}, _withCheckTreeClassPr[className !== null && className !== void 0 ? className : ''] = inline, _withCheckTreeClassPr['without-children'] = !isSomeNodeHasChildren(data, childrenKey), _withCheckTreeClassPr.virtualized = virtualized, _withCheckTreeClassPr));
|
|
625
625
|
var formattedNodes = getFormattedNodes(renderNode);
|
|
626
626
|
|
|
627
627
|
if (!formattedNodes.some(function (v) {
|
|
@@ -38,7 +38,7 @@ export function isSomeChildChecked(nodes, parent, childrenKey) {
|
|
|
38
38
|
}
|
|
39
39
|
export function isSomeNodeHasChildren(data, childrenKey) {
|
|
40
40
|
return data.some(function (node) {
|
|
41
|
-
return node[childrenKey];
|
|
41
|
+
return Array.isArray(node[childrenKey]);
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
import React, { useState } from 'react';
|
|
3
|
+
import React, { useState, useMemo } from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import { useClassNames } from '../utils';
|
|
6
6
|
export var ContainerContext = /*#__PURE__*/React.createContext({});
|
|
@@ -24,10 +24,13 @@ var Container = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
24
24
|
var classes = merge(className, withClassPrefix({
|
|
25
25
|
'has-sidebar': hasSidebar
|
|
26
26
|
}));
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
var contextValue = useMemo(function () {
|
|
28
|
+
return {
|
|
29
29
|
setHasSidebar: setHasSidebar
|
|
30
|
-
}
|
|
30
|
+
};
|
|
31
|
+
}, [setHasSidebar]);
|
|
32
|
+
return /*#__PURE__*/React.createElement(ContainerContext.Provider, {
|
|
33
|
+
value: contextValue
|
|
31
34
|
}, /*#__PURE__*/React.createElement(Component, _extends({}, rest, {
|
|
32
35
|
ref: ref,
|
|
33
36
|
className: classes
|
|
@@ -72,10 +72,10 @@ declare const CustomContext: React.Context<CustomProviderProps<{
|
|
|
72
72
|
saturday: string;
|
|
73
73
|
ok: string;
|
|
74
74
|
today: string;
|
|
75
|
-
yesterday: string;
|
|
75
|
+
yesterday: string;
|
|
76
76
|
hours: string;
|
|
77
77
|
minutes: string;
|
|
78
|
-
seconds: string;
|
|
78
|
+
seconds: string; /** Support right-to-left */
|
|
79
79
|
formattedMonthPattern: string;
|
|
80
80
|
formattedDayPattern: string;
|
|
81
81
|
dateLocale: any;
|
|
@@ -90,10 +90,10 @@ declare const CustomContext: React.Context<CustomProviderProps<{
|
|
|
90
90
|
saturday: string;
|
|
91
91
|
ok: string;
|
|
92
92
|
today: string;
|
|
93
|
-
yesterday: string;
|
|
93
|
+
yesterday: string;
|
|
94
94
|
hours: string;
|
|
95
95
|
minutes: string;
|
|
96
|
-
seconds: string;
|
|
96
|
+
seconds: string; /** Support right-to-left */
|
|
97
97
|
formattedMonthPattern: string;
|
|
98
98
|
formattedDayPattern: string;
|
|
99
99
|
dateLocale: any;
|
|
@@ -109,10 +109,10 @@ declare const CustomContext: React.Context<CustomProviderProps<{
|
|
|
109
109
|
saturday: string;
|
|
110
110
|
ok: string;
|
|
111
111
|
today: string;
|
|
112
|
-
yesterday: string;
|
|
112
|
+
yesterday: string;
|
|
113
113
|
hours: string;
|
|
114
114
|
minutes: string;
|
|
115
|
-
seconds: string;
|
|
115
|
+
seconds: string; /** Support right-to-left */
|
|
116
116
|
formattedMonthPattern: string;
|
|
117
117
|
formattedDayPattern: string;
|
|
118
118
|
dateLocale: any;
|
|
@@ -120,7 +120,7 @@ declare const CustomContext: React.Context<CustomProviderProps<{
|
|
|
120
120
|
Picker?: {
|
|
121
121
|
noResultsText: string;
|
|
122
122
|
placeholder: string;
|
|
123
|
-
searchPlaceholder: string;
|
|
123
|
+
searchPlaceholder: string;
|
|
124
124
|
checkAll: string;
|
|
125
125
|
} | undefined;
|
|
126
126
|
InputPicker?: {
|
|
@@ -176,10 +176,10 @@ declare const Consumer: React.Consumer<CustomProviderProps<{
|
|
|
176
176
|
saturday: string;
|
|
177
177
|
ok: string;
|
|
178
178
|
today: string;
|
|
179
|
-
yesterday: string;
|
|
179
|
+
yesterday: string;
|
|
180
180
|
hours: string;
|
|
181
181
|
minutes: string;
|
|
182
|
-
seconds: string;
|
|
182
|
+
seconds: string; /** Support right-to-left */
|
|
183
183
|
formattedMonthPattern: string;
|
|
184
184
|
formattedDayPattern: string;
|
|
185
185
|
dateLocale: any;
|
|
@@ -194,10 +194,10 @@ declare const Consumer: React.Consumer<CustomProviderProps<{
|
|
|
194
194
|
saturday: string;
|
|
195
195
|
ok: string;
|
|
196
196
|
today: string;
|
|
197
|
-
yesterday: string;
|
|
197
|
+
yesterday: string;
|
|
198
198
|
hours: string;
|
|
199
199
|
minutes: string;
|
|
200
|
-
seconds: string;
|
|
200
|
+
seconds: string; /** Support right-to-left */
|
|
201
201
|
formattedMonthPattern: string;
|
|
202
202
|
formattedDayPattern: string;
|
|
203
203
|
dateLocale: any;
|
|
@@ -213,10 +213,10 @@ declare const Consumer: React.Consumer<CustomProviderProps<{
|
|
|
213
213
|
saturday: string;
|
|
214
214
|
ok: string;
|
|
215
215
|
today: string;
|
|
216
|
-
yesterday: string;
|
|
216
|
+
yesterday: string;
|
|
217
217
|
hours: string;
|
|
218
218
|
minutes: string;
|
|
219
|
-
seconds: string;
|
|
219
|
+
seconds: string; /** Support right-to-left */
|
|
220
220
|
formattedMonthPattern: string;
|
|
221
221
|
formattedDayPattern: string;
|
|
222
222
|
dateLocale: any;
|
|
@@ -224,7 +224,7 @@ declare const Consumer: React.Consumer<CustomProviderProps<{
|
|
|
224
224
|
Picker?: {
|
|
225
225
|
noResultsText: string;
|
|
226
226
|
placeholder: string;
|
|
227
|
-
searchPlaceholder: string;
|
|
227
|
+
searchPlaceholder: string;
|
|
228
228
|
checkAll: string;
|
|
229
229
|
} | undefined;
|
|
230
230
|
InputPicker?: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
import React from 'react';
|
|
3
|
+
import React, { useEffect } from 'react';
|
|
4
4
|
import { getClassNamePrefix, prefix } from '../utils/prefix';
|
|
5
5
|
import { addClass, removeClass, canUseDOM } from '../DOMHelper';
|
|
6
6
|
var CustomContext = /*#__PURE__*/React.createContext({});
|
|
@@ -21,7 +21,7 @@ var CustomProvider = function CustomProvider(props) {
|
|
|
21
21
|
theme: theme
|
|
22
22
|
}, rest);
|
|
23
23
|
}, [classPrefix, theme, rest]);
|
|
24
|
-
|
|
24
|
+
useEffect(function () {
|
|
25
25
|
if (canUseDOM && theme) {
|
|
26
26
|
addClass(document.body, prefix(classPrefix, "theme-" + theme)); // Remove the className that will cause style conflicts
|
|
27
27
|
|
|
@@ -3,7 +3,7 @@ import { RangeType } from './Toolbar';
|
|
|
3
3
|
import { DatePickerLocale } from '../locales';
|
|
4
4
|
import { FormControlBaseProps, PickerBaseProps, RsRefForwardingComponent } from '../@types/common';
|
|
5
5
|
export type { RangeType } from './Toolbar';
|
|
6
|
-
export interface DatePickerProps extends PickerBaseProps<DatePickerLocale>, FormControlBaseProps<Date> {
|
|
6
|
+
export interface DatePickerProps extends PickerBaseProps<DatePickerLocale>, FormControlBaseProps<Date | null> {
|
|
7
7
|
/** Configure shortcut options */
|
|
8
8
|
ranges?: RangeType<Date>[];
|
|
9
9
|
/** Calendar panel default presentation date and time */
|
|
@@ -2,7 +2,6 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
import React, { useCallback, useMemo, useRef, useState } from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
|
-
import isNil from 'lodash/isNil';
|
|
6
5
|
import mapValues from 'lodash/mapValues';
|
|
7
6
|
import pick from 'lodash/pick';
|
|
8
7
|
import omit from 'lodash/omit';
|
|
@@ -166,11 +165,11 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
166
165
|
closeOverlay = true;
|
|
167
166
|
}
|
|
168
167
|
|
|
169
|
-
var nextValue =
|
|
168
|
+
var nextValue = typeof nextPageDate !== 'undefined' ? nextPageDate : calendarDate;
|
|
170
169
|
setCalendarDate(nextValue || new Date());
|
|
171
170
|
setValue(nextValue);
|
|
172
171
|
|
|
173
|
-
if (nextValue !== value
|
|
172
|
+
if (nextValue !== value) {
|
|
174
173
|
onChange === null || onChange === void 0 ? void 0 : onChange(nextValue, event);
|
|
175
174
|
} // `closeOverlay` default value is `true`
|
|
176
175
|
|
|
@@ -371,6 +370,7 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
371
370
|
top: top
|
|
372
371
|
};
|
|
373
372
|
return /*#__PURE__*/React.createElement(PickerOverlay, {
|
|
373
|
+
role: "dialog",
|
|
374
374
|
className: classes,
|
|
375
375
|
ref: mergeRefs(overlayRef, speakerRef),
|
|
376
376
|
style: styles,
|
|
@@ -444,7 +444,8 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
444
444
|
active: active,
|
|
445
445
|
placement: placement,
|
|
446
446
|
disabled: disabled,
|
|
447
|
-
caretAs: caretAs
|
|
447
|
+
caretAs: caretAs,
|
|
448
|
+
"aria-haspopup": "dialog"
|
|
448
449
|
}), renderDate())));
|
|
449
450
|
});
|
|
450
451
|
DatePicker.displayName = 'DatePicker';
|