rsuite 5.45.0 → 5.46.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 +13 -0
- package/DatePicker/styles/index.less +15 -0
- package/cjs/Calendar/MonthDropdown.js +1 -2
- package/cjs/Calendar/MonthDropdownItem.js +26 -13
- package/cjs/Calendar/TableCell.d.ts +14 -0
- package/cjs/Calendar/TableCell.js +72 -0
- package/cjs/Calendar/TableHeaderRow.js +3 -1
- package/cjs/Calendar/TableRow.js +22 -46
- package/cjs/Calendar/useCalendarDate.d.ts +1 -1
- package/cjs/Calendar/utils.d.ts +7 -0
- package/cjs/Calendar/utils.js +15 -0
- package/cjs/Cascader/Cascader.js +13 -3
- package/cjs/DatePicker/DatePicker.js +145 -38
- package/cjs/InputPicker/InputPicker.js +7 -4
- package/cjs/Picker/PickerToggle.js +3 -0
- package/cjs/Picker/utils.js +21 -12
- package/cjs/Table/Table.d.ts +7 -7
- package/dist/rsuite-no-reset-rtl.css +108 -60
- 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 +108 -60
- package/dist/rsuite-no-reset.min.css +1 -1
- package/dist/rsuite-no-reset.min.css.map +1 -1
- package/dist/rsuite-rtl.css +108 -60
- package/dist/rsuite-rtl.min.css +1 -1
- package/dist/rsuite-rtl.min.css.map +1 -1
- package/dist/rsuite.css +108 -60
- package/dist/rsuite.js +56 -13
- package/dist/rsuite.js.map +1 -1
- package/dist/rsuite.min.css +1 -1
- package/dist/rsuite.min.css.map +1 -1
- package/dist/rsuite.min.js +1 -1
- package/dist/rsuite.min.js.map +1 -1
- package/esm/Calendar/MonthDropdown.js +1 -2
- package/esm/Calendar/MonthDropdownItem.js +28 -15
- package/esm/Calendar/TableCell.d.ts +14 -0
- package/esm/Calendar/TableCell.js +66 -0
- package/esm/Calendar/TableHeaderRow.js +3 -1
- package/esm/Calendar/TableRow.js +23 -47
- package/esm/Calendar/useCalendarDate.d.ts +1 -1
- package/esm/Calendar/utils.d.ts +7 -0
- package/esm/Calendar/utils.js +12 -0
- package/esm/Cascader/Cascader.js +13 -3
- package/esm/DatePicker/DatePicker.js +147 -40
- package/esm/InputPicker/InputPicker.js +7 -4
- package/esm/Picker/PickerToggle.js +3 -0
- package/esm/Picker/utils.js +21 -12
- package/esm/Table/Table.d.ts +7 -7
- package/package.json +2 -2
- package/styles/color-modes/dark.less +0 -40
- package/styles/color-modes/high-contrast.less +0 -35
- package/styles/color-modes/light.less +0 -46
|
@@ -6,6 +6,7 @@ import PropTypes from 'prop-types';
|
|
|
6
6
|
import mapValues from 'lodash/mapValues';
|
|
7
7
|
import pick from 'lodash/pick';
|
|
8
8
|
import omit from 'lodash/omit';
|
|
9
|
+
import delay from 'lodash/delay';
|
|
9
10
|
import debounce from 'lodash/debounce';
|
|
10
11
|
import IconCalendar from '@rsuite/icons/legacy/Calendar';
|
|
11
12
|
import IconClockO from '@rsuite/icons/legacy/ClockO';
|
|
@@ -15,10 +16,12 @@ import { isEveryDateInMonth } from '../Calendar/MonthDropdown';
|
|
|
15
16
|
import Toolbar from './Toolbar';
|
|
16
17
|
import Stack from '../Stack';
|
|
17
18
|
import PredefinedRanges from './PredefinedRanges';
|
|
18
|
-
import { composeFunctions, createChainedFunction,
|
|
19
|
-
import {
|
|
19
|
+
import { composeFunctions, createChainedFunction, mergeRefs, useClassNames, useControlled, useCustom } from '../utils';
|
|
20
|
+
import { shouldRenderMonth, shouldRenderDate, shouldRenderTime, shouldOnlyRenderTime, setHours, getHours, addMonths, addDays, setMinutes, getMinutes, setSeconds, getSeconds, isValid, format, getDateMask, disabledTime, isMatch, calendarOnlyProps } from '../utils/dateUtils';
|
|
21
|
+
import { PickerOverlay, pickerPropTypes, PickerToggle, PickerToggleTrigger, pickTriggerPropKeys, omitTriggerPropKeys, usePickerClassName, usePublicMethods, useToggleKeyDownEvent, onMenuKeyDown } from '../Picker';
|
|
20
22
|
import { OverlayCloseCause } from '../Overlay/OverlayTrigger';
|
|
21
23
|
import { deprecatePropTypeNew } from '../utils/deprecatePropType';
|
|
24
|
+
import { getAriaLabel } from '../Calendar/utils';
|
|
22
25
|
var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
23
26
|
var _props$as = props.as,
|
|
24
27
|
Component = _props$as === void 0 ? 'div' : _props$as,
|
|
@@ -92,12 +95,17 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
92
95
|
calendarDate = _useCalendarDate.calendarDate,
|
|
93
96
|
setCalendarDate = _useCalendarDate.setCalendarDate,
|
|
94
97
|
resetCalendarDate = _useCalendarDate.resetCalendarDate;
|
|
95
|
-
var _useState = useState(),
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
var
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
var _useState = useState(false),
|
|
99
|
+
showMonthDropdown = _useState[0],
|
|
100
|
+
setShowMonthDropdown = _useState[1]; // Show only the calendar month panel. formatStr = 'yyyy-MM'
|
|
101
|
+
var onlyShowMonth = shouldRenderMonth(formatStr) && !shouldRenderDate(formatStr);
|
|
102
|
+
var showMonth = onlyShowMonth || showMonthDropdown;
|
|
103
|
+
var _useState2 = useState(),
|
|
104
|
+
inputState = _useState2[0],
|
|
105
|
+
setInputState = _useState2[1];
|
|
106
|
+
var _useState3 = useState(false),
|
|
107
|
+
active = _useState3[0],
|
|
108
|
+
setActive = _useState3[1];
|
|
101
109
|
var triggerRef = useRef(null);
|
|
102
110
|
var rootRef = useRef(null);
|
|
103
111
|
var targetRef = useRef(null);
|
|
@@ -151,9 +159,9 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
151
159
|
* The callback triggered when PM/AM is switched.
|
|
152
160
|
*/
|
|
153
161
|
var handleToggleMeridian = useCallback(function () {
|
|
154
|
-
var hours =
|
|
162
|
+
var hours = getHours(calendarDate);
|
|
155
163
|
var nextHours = hours >= 12 ? hours - 12 : hours + 12;
|
|
156
|
-
var nextDate =
|
|
164
|
+
var nextDate = setHours(calendarDate, nextHours);
|
|
157
165
|
handleChangeTime(nextDate);
|
|
158
166
|
}, [calendarDate, handleChangeTime]);
|
|
159
167
|
var updateValue = useCallback(function (event, nextPageDate, closeOverlay) {
|
|
@@ -183,13 +191,57 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
183
191
|
onShortcutClick === null || onShortcutClick === void 0 ? void 0 : onShortcutClick(range, event);
|
|
184
192
|
}, [handleDateChange, onShortcutClick, updateValue]);
|
|
185
193
|
|
|
194
|
+
/**
|
|
195
|
+
* Get the corresponding container based on date selection and month selection
|
|
196
|
+
*/
|
|
197
|
+
var getOverlayContainer = useCallback(function () {
|
|
198
|
+
var _overlayRef$current;
|
|
199
|
+
return (_overlayRef$current = overlayRef.current) === null || _overlayRef$current === void 0 ? void 0 : _overlayRef$current.querySelector(showMonth ? '[role="menu"]' : '[role="grid"]');
|
|
200
|
+
}, [showMonth]);
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Check whether the date is focusable
|
|
204
|
+
*/
|
|
205
|
+
var checkFocusable = useCallback(function (date) {
|
|
206
|
+
var formatStr = showMonth ? locale.formattedMonthPattern : locale.formattedDayPattern;
|
|
207
|
+
var ariaLabel = getAriaLabel(date, formatStr, formatDate);
|
|
208
|
+
var container = getOverlayContainer();
|
|
209
|
+
var dateElement = container.querySelector("[aria-label=\"" + ariaLabel + "\"]");
|
|
210
|
+
if (dateElement !== null && dateElement !== void 0 && dateElement.hasAttribute('aria-disabled')) {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
return true;
|
|
214
|
+
}, [formatDate, getOverlayContainer, locale, showMonth]);
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Focus on the currently selected date element
|
|
218
|
+
*/
|
|
219
|
+
var focusSelectedDate = useCallback(function () {
|
|
220
|
+
delay(function () {
|
|
221
|
+
var container = getOverlayContainer();
|
|
222
|
+
var selectedElement = container === null || container === void 0 ? void 0 : container.querySelector('[aria-selected="true"]');
|
|
223
|
+
selectedElement === null || selectedElement === void 0 ? void 0 : selectedElement.focus();
|
|
224
|
+
}, 1);
|
|
225
|
+
}, [getOverlayContainer]);
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Focus on the input element
|
|
229
|
+
*/
|
|
230
|
+
var focusTargetButton = useCallback(function () {
|
|
231
|
+
delay(function () {
|
|
232
|
+
var _targetRef$current, _targetRef$current$qu;
|
|
233
|
+
(_targetRef$current = targetRef.current) === null || _targetRef$current === void 0 ? void 0 : (_targetRef$current$qu = _targetRef$current.querySelector('input')) === null || _targetRef$current$qu === void 0 ? void 0 : _targetRef$current$qu.focus();
|
|
234
|
+
}, 100);
|
|
235
|
+
}, []);
|
|
236
|
+
|
|
186
237
|
/**
|
|
187
238
|
* The callback triggered after clicking the OK button.
|
|
188
239
|
*/
|
|
189
240
|
var handleOK = useCallback(function (event) {
|
|
190
241
|
updateValue(event);
|
|
191
242
|
onOk === null || onOk === void 0 ? void 0 : onOk(calendarDate, event);
|
|
192
|
-
|
|
243
|
+
focusTargetButton();
|
|
244
|
+
}, [updateValue, onOk, calendarDate, focusTargetButton]);
|
|
193
245
|
|
|
194
246
|
/**
|
|
195
247
|
* Callback after clicking the clear button.
|
|
@@ -198,6 +250,54 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
198
250
|
updateValue(event, null);
|
|
199
251
|
resetCalendarDate(null);
|
|
200
252
|
}, [resetCalendarDate, updateValue]);
|
|
253
|
+
var handlePickerToggleKeyDown = useCallback(function (event) {
|
|
254
|
+
var _event$target;
|
|
255
|
+
var tagName = (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.tagName;
|
|
256
|
+
if (tagName === 'INPUT') {
|
|
257
|
+
if (event.key === 'ArrowDown') {
|
|
258
|
+
event.preventDefault();
|
|
259
|
+
focusSelectedDate();
|
|
260
|
+
} else if (event.key === 'Enter') {
|
|
261
|
+
var _triggerRef$current2, _triggerRef$current2$;
|
|
262
|
+
(_triggerRef$current2 = triggerRef.current) === null || _triggerRef$current2 === void 0 ? void 0 : (_triggerRef$current2$ = _triggerRef$current2.open) === null || _triggerRef$current2$ === void 0 ? void 0 : _triggerRef$current2$.call(_triggerRef$current2);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}, [focusSelectedDate]);
|
|
266
|
+
var handlePickerOverlayKeyDown = useCallback(function (event) {
|
|
267
|
+
var delta = 0;
|
|
268
|
+
var step = showMonth ? 6 : 7;
|
|
269
|
+
var changeDateFunc = showMonth ? addMonths : addDays;
|
|
270
|
+
onMenuKeyDown(event, {
|
|
271
|
+
down: function down() {
|
|
272
|
+
delta = step;
|
|
273
|
+
},
|
|
274
|
+
up: function up() {
|
|
275
|
+
delta = -step;
|
|
276
|
+
},
|
|
277
|
+
right: function right() {
|
|
278
|
+
delta = 1;
|
|
279
|
+
},
|
|
280
|
+
left: function left() {
|
|
281
|
+
delta = -1;
|
|
282
|
+
},
|
|
283
|
+
enter: function enter() {
|
|
284
|
+
handleOK(event);
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
var nextDate = changeDateFunc(calendarDate, delta);
|
|
288
|
+
if (checkFocusable(nextDate)) {
|
|
289
|
+
setCalendarDate(nextDate);
|
|
290
|
+
focusSelectedDate();
|
|
291
|
+
}
|
|
292
|
+
}, [showMonth, calendarDate, checkFocusable, handleOK, setCalendarDate, focusSelectedDate]);
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* The callback triggered after the month selection box is opened or closed.
|
|
296
|
+
*/
|
|
297
|
+
var handleToggleMonthDropdown = useCallback(function (toggle) {
|
|
298
|
+
onToggleMonthDropdown === null || onToggleMonthDropdown === void 0 ? void 0 : onToggleMonthDropdown(toggle);
|
|
299
|
+
setShowMonthDropdown(toggle);
|
|
300
|
+
}, [onToggleMonthDropdown]);
|
|
201
301
|
|
|
202
302
|
/**
|
|
203
303
|
* Handle keyboard events.
|
|
@@ -205,8 +305,10 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
205
305
|
var onPickerKeyDown = useToggleKeyDownEvent(_extends({
|
|
206
306
|
triggerRef: triggerRef,
|
|
207
307
|
targetRef: targetRef,
|
|
308
|
+
overlayRef: overlayRef,
|
|
208
309
|
active: active,
|
|
209
|
-
onExit: handleClean
|
|
310
|
+
onExit: handleClean,
|
|
311
|
+
onKeyDown: handlePickerToggleKeyDown
|
|
210
312
|
}, rest));
|
|
211
313
|
|
|
212
314
|
/**
|
|
@@ -218,18 +320,18 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
218
320
|
}
|
|
219
321
|
setCalendarDate(
|
|
220
322
|
// Determine whether the current value contains time, if not, use calendarDate.
|
|
221
|
-
|
|
222
|
-
return
|
|
323
|
+
shouldRenderTime(formatStr) ? nextValue : composeFunctions(function (d) {
|
|
324
|
+
return setHours(d, getHours(calendarDate));
|
|
223
325
|
}, function (d) {
|
|
224
|
-
return
|
|
326
|
+
return setMinutes(d, getMinutes(calendarDate));
|
|
225
327
|
}, function (d) {
|
|
226
|
-
return
|
|
328
|
+
return setSeconds(d, getSeconds(calendarDate));
|
|
227
329
|
})(nextValue));
|
|
228
330
|
handleDateChange(nextValue);
|
|
229
331
|
if (oneTap && updatableValue) {
|
|
230
332
|
updateValue(event, nextValue);
|
|
231
333
|
}
|
|
232
|
-
}, [formatStr, handleDateChange, oneTap, calendarDate,
|
|
334
|
+
}, [setCalendarDate, formatStr, handleDateChange, oneTap, calendarDate, updateValue]);
|
|
233
335
|
|
|
234
336
|
/**
|
|
235
337
|
* A callback triggered when the date on the calendar changes.
|
|
@@ -237,13 +339,11 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
237
339
|
var handleChangeMonth = useCallback(function (nextPageDate, event) {
|
|
238
340
|
setCalendarDate(nextPageDate);
|
|
239
341
|
handleDateChange(nextPageDate);
|
|
240
|
-
|
|
241
|
-
// Show only the calendar month panel. formatStr = 'yyyy-MM'
|
|
242
|
-
var onlyShowMonth = DateUtils.shouldRenderMonth(formatStr) && !DateUtils.shouldRenderDate(formatStr);
|
|
342
|
+
focusSelectedDate();
|
|
243
343
|
if (oneTap && onlyShowMonth) {
|
|
244
344
|
updateValue(event, nextPageDate);
|
|
245
345
|
}
|
|
246
|
-
}, [
|
|
346
|
+
}, [focusSelectedDate, handleDateChange, oneTap, onlyShowMonth, setCalendarDate, updateValue]);
|
|
247
347
|
var isDateDisabled = useCallback(function (date) {
|
|
248
348
|
if (typeof shouldDisableDate === 'function') {
|
|
249
349
|
return shouldDisableDate(date);
|
|
@@ -262,7 +362,7 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
262
362
|
|
|
263
363
|
// isMatch('01/11/2020', 'MM/dd/yyyy') ==> true
|
|
264
364
|
// isMatch('2020-11-01', 'MM/dd/yyyy') ==> false
|
|
265
|
-
if (!
|
|
365
|
+
if (!isMatch(value, formatStr, {
|
|
266
366
|
locale: locale.dateLocale
|
|
267
367
|
})) {
|
|
268
368
|
setInputState('Error');
|
|
@@ -271,10 +371,10 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
271
371
|
var date = parseDate(value, formatStr);
|
|
272
372
|
|
|
273
373
|
// If only the time is included in the characters, it will default to today.
|
|
274
|
-
if (
|
|
275
|
-
date = new Date(
|
|
374
|
+
if (shouldOnlyRenderTime(formatStr)) {
|
|
375
|
+
date = new Date(format(new Date(), 'yyyy-MM-dd') + " " + value);
|
|
276
376
|
}
|
|
277
|
-
if (!
|
|
377
|
+
if (!isValid(date)) {
|
|
278
378
|
setInputState('Error');
|
|
279
379
|
return;
|
|
280
380
|
}
|
|
@@ -315,7 +415,7 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
315
415
|
var disabledToolbarHandle = useCallback(function (date) {
|
|
316
416
|
var _DEPRECATED_disabledD;
|
|
317
417
|
var allowDate = (_DEPRECATED_disabledD = DEPRECATED_disabledDate === null || DEPRECATED_disabledDate === void 0 ? void 0 : DEPRECATED_disabledDate(date)) !== null && _DEPRECATED_disabledD !== void 0 ? _DEPRECATED_disabledD : false;
|
|
318
|
-
var allowTime =
|
|
418
|
+
var allowTime = disabledTime(props, date);
|
|
319
419
|
return allowDate || allowTime;
|
|
320
420
|
}, [DEPRECATED_disabledDate, props]);
|
|
321
421
|
|
|
@@ -326,13 +426,13 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
326
426
|
* - If format is month, disable ok button if all dates in the month of selected date are disabled
|
|
327
427
|
*/
|
|
328
428
|
var isOKButtonDisabled = useCallback(function (selectedDate) {
|
|
329
|
-
if (
|
|
429
|
+
if (shouldRenderMonth(formatStr) && !shouldRenderDate(formatStr)) {
|
|
330
430
|
return isEveryDateInMonth(selectedDate.getFullYear(), selectedDate.getMonth(), disabledToolbarHandle);
|
|
331
431
|
}
|
|
332
432
|
return disabledToolbarHandle(selectedDate);
|
|
333
433
|
}, [disabledToolbarHandle, formatStr]);
|
|
334
434
|
var calendarProps = useMemo(function () {
|
|
335
|
-
return mapValues(pick(props,
|
|
435
|
+
return mapValues(pick(props, calendarOnlyProps), function (disabledOrHiddenTimeFunc) {
|
|
336
436
|
return function (next, date) {
|
|
337
437
|
var _disabledOrHiddenTime;
|
|
338
438
|
return (_disabledOrHiddenTime = disabledOrHiddenTimeFunc === null || disabledOrHiddenTimeFunc === void 0 ? void 0 : disabledOrHiddenTimeFunc(next, date)) !== null && _disabledOrHiddenTime !== void 0 ? _disabledOrHiddenTime : false;
|
|
@@ -355,15 +455,19 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
355
455
|
onMoveForward: handleMoveForward,
|
|
356
456
|
onMoveBackward: handleMoveBackward,
|
|
357
457
|
onSelect: handleSelect,
|
|
358
|
-
onToggleMonthDropdown:
|
|
458
|
+
onToggleMonthDropdown: handleToggleMonthDropdown,
|
|
359
459
|
onToggleTimeDropdown: onToggleTimeDropdown,
|
|
360
460
|
onChangeMonth: handleChangeMonth,
|
|
361
461
|
onChangeTime: handleChangeTime,
|
|
362
462
|
onToggleMeridian: handleToggleMeridian
|
|
363
463
|
}));
|
|
464
|
+
|
|
465
|
+
// The shortcut option on the left side of the calendar panel
|
|
364
466
|
var sideRanges = (ranges === null || ranges === void 0 ? void 0 : ranges.filter(function (range) {
|
|
365
467
|
return (range === null || range === void 0 ? void 0 : range.placement) === 'left';
|
|
366
468
|
})) || [];
|
|
469
|
+
|
|
470
|
+
// The shortcut option on the bottom of the calendar panel
|
|
367
471
|
var bottomRanges = (ranges === null || ranges === void 0 ? void 0 : ranges.filter(function (range) {
|
|
368
472
|
return (range === null || range === void 0 ? void 0 : range.placement) === 'bottom' || (range === null || range === void 0 ? void 0 : range.placement) === undefined;
|
|
369
473
|
})) || [];
|
|
@@ -381,7 +485,8 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
381
485
|
className: classes,
|
|
382
486
|
ref: mergeRefs(overlayRef, speakerRef),
|
|
383
487
|
style: styles,
|
|
384
|
-
target: triggerRef
|
|
488
|
+
target: triggerRef,
|
|
489
|
+
onKeyDown: handlePickerOverlayKeyDown
|
|
385
490
|
}, /*#__PURE__*/React.createElement(Stack, {
|
|
386
491
|
alignItems: "flex-start"
|
|
387
492
|
}, sideRanges.length > 0 && /*#__PURE__*/React.createElement(PredefinedRanges, {
|
|
@@ -422,20 +527,22 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
422
527
|
return (_renderValue = renderValue === null || renderValue === void 0 ? void 0 : renderValue(value, formatStr)) !== null && _renderValue !== void 0 ? _renderValue : formatDate(value, formatStr);
|
|
423
528
|
}, [formatStr, formatDate, placeholder, renderValue, value]);
|
|
424
529
|
var caretAs = useMemo(function () {
|
|
425
|
-
return caretAsProp || (
|
|
530
|
+
return caretAsProp || (shouldOnlyRenderTime(formatStr) ? IconClockO : IconCalendar);
|
|
426
531
|
}, [caretAsProp, formatStr]);
|
|
532
|
+
var handleTriggerClose = useCallback(function (cause) {
|
|
533
|
+
// Unless overlay is closing on user clicking "OK" button,
|
|
534
|
+
// reset the selected date on calendar panel
|
|
535
|
+
if (cause !== OverlayCloseCause.ImperativeHandle) {
|
|
536
|
+
resetCalendarDate();
|
|
537
|
+
}
|
|
538
|
+
setShowMonthDropdown(false);
|
|
539
|
+
}, [resetCalendarDate]);
|
|
427
540
|
return /*#__PURE__*/React.createElement(PickerToggleTrigger, {
|
|
428
541
|
trigger: "active",
|
|
429
542
|
pickerProps: pick(props, pickTriggerPropKeys),
|
|
430
543
|
ref: triggerRef,
|
|
431
544
|
placement: placement,
|
|
432
|
-
onClose:
|
|
433
|
-
// Unless overlay is closing on user clicking "OK" button,
|
|
434
|
-
// reset the selected date on calendar panel
|
|
435
|
-
if (cause !== OverlayCloseCause.ImperativeHandle) {
|
|
436
|
-
resetCalendarDate();
|
|
437
|
-
}
|
|
438
|
-
},
|
|
545
|
+
onClose: handleTriggerClose,
|
|
439
546
|
onEntered: createChainedFunction(handleEntered, onEntered),
|
|
440
547
|
onExited: createChainedFunction(handleExited, onExited),
|
|
441
548
|
speaker: renderDropdownMenu
|
|
@@ -443,7 +550,7 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
443
550
|
className: merge(className, classes),
|
|
444
551
|
style: style,
|
|
445
552
|
ref: rootRef
|
|
446
|
-
}, /*#__PURE__*/React.createElement(PickerToggle, _extends({}, omit(rest, [].concat(omitTriggerPropKeys, usedClassNamePropKeys,
|
|
553
|
+
}, /*#__PURE__*/React.createElement(PickerToggle, _extends({}, omit(rest, [].concat(omitTriggerPropKeys, usedClassNamePropKeys, calendarOnlyProps)), {
|
|
447
554
|
className: prefix({
|
|
448
555
|
error: inputState === 'Error'
|
|
449
556
|
}),
|
|
@@ -453,7 +560,7 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
453
560
|
editable: editable,
|
|
454
561
|
inputValue: value ? formatDate(value, formatStr) : '',
|
|
455
562
|
inputPlaceholder: typeof placeholder === 'string' && placeholder ? placeholder : formatStr,
|
|
456
|
-
inputMask:
|
|
563
|
+
inputMask: getDateMask(formatStr),
|
|
457
564
|
onInputChange: handleInputChange,
|
|
458
565
|
onInputBlur: handleInputPressEnd,
|
|
459
566
|
onInputPressEnter: handleInputPressEnd,
|
|
@@ -143,9 +143,12 @@ var InputPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
143
143
|
return multi ? clone(value) || [] : value;
|
|
144
144
|
}, [multi, value]);
|
|
145
145
|
var handleClose = useCallback(function () {
|
|
146
|
-
var _triggerRef$current;
|
|
146
|
+
var _triggerRef$current, _targetRef$current, _targetRef$current$fo;
|
|
147
147
|
triggerRef === null || triggerRef === void 0 ? void 0 : (_triggerRef$current = triggerRef.current) === null || _triggerRef$current === void 0 ? void 0 : _triggerRef$current.close();
|
|
148
|
-
|
|
148
|
+
|
|
149
|
+
// The focus is on the trigger button after closing
|
|
150
|
+
(_targetRef$current = targetRef.current) === null || _targetRef$current === void 0 ? void 0 : (_targetRef$current$fo = _targetRef$current.focus) === null || _targetRef$current$fo === void 0 ? void 0 : _targetRef$current$fo.call(_targetRef$current);
|
|
151
|
+
}, []);
|
|
149
152
|
|
|
150
153
|
// Used to hover the focuse item when trigger `onKeydown`
|
|
151
154
|
var _useFocusItemValue = useFocusItemValue(multi ? value === null || value === void 0 ? void 0 : value[0] : value, {
|
|
@@ -651,7 +654,7 @@ var InputPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
651
654
|
plaintext: plaintext,
|
|
652
655
|
ref: targetRef,
|
|
653
656
|
as: toggleAs,
|
|
654
|
-
tabIndex:
|
|
657
|
+
tabIndex: tabIndex,
|
|
655
658
|
onClean: handleClean,
|
|
656
659
|
cleanable: cleanable && !disabled,
|
|
657
660
|
hasValue: hasValue,
|
|
@@ -663,7 +666,7 @@ var InputPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
663
666
|
}), searching || multi && hasValue ? null : itemNode || placeholderNode), !(!multi && disabled) && /*#__PURE__*/React.createElement("div", {
|
|
664
667
|
className: prefix(_templateObject5 || (_templateObject5 = _taggedTemplateLiteralLoose(["tag-wrapper"])))
|
|
665
668
|
}, tagElements, displaySearchInput && /*#__PURE__*/React.createElement(InputSearch, _extends({}, inputProps, {
|
|
666
|
-
tabIndex:
|
|
669
|
+
tabIndex: -1,
|
|
667
670
|
readOnly: readOnly,
|
|
668
671
|
onBlur: onBlur,
|
|
669
672
|
onFocus: createChainedFunction(handleFocus, onFocus),
|
|
@@ -142,6 +142,8 @@ var PickerToggle = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
142
142
|
}, [editable, onInputPressEnter, onInputBackspace]);
|
|
143
143
|
var renderInput = useCallback(function (ref, props) {
|
|
144
144
|
return /*#__PURE__*/React.createElement("input", _extends({
|
|
145
|
+
type: "text",
|
|
146
|
+
autoComplete: "off",
|
|
145
147
|
ref: mergeRefs(inputRef, ref),
|
|
146
148
|
name: name,
|
|
147
149
|
style: {
|
|
@@ -191,6 +193,7 @@ var PickerToggle = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
191
193
|
},
|
|
192
194
|
"data-testid": "spinner"
|
|
193
195
|
}) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TextMask, {
|
|
196
|
+
keepCharPositions: true,
|
|
194
197
|
mask: inputMask,
|
|
195
198
|
value: Array.isArray(inputValue) ? inputValue.toString() : inputValue,
|
|
196
199
|
onBlur: handleInputBlur,
|
package/esm/Picker/utils.js
CHANGED
|
@@ -182,6 +182,12 @@ export var useFocusItemValue = function useFocusItemValue(defaultFocusItemValue,
|
|
|
182
182
|
var _useState3 = useState([]),
|
|
183
183
|
keys = _useState3[0],
|
|
184
184
|
setKeys = _useState3[1];
|
|
185
|
+
var focusCallback = useCallback(function (value, event) {
|
|
186
|
+
var menu = isFunction(target) ? target() : target;
|
|
187
|
+
var focusElement = menu === null || menu === void 0 ? void 0 : menu.querySelector("[data-key=\"" + value + "\"]");
|
|
188
|
+
focusElement === null || focusElement === void 0 ? void 0 : focusElement.focus();
|
|
189
|
+
callback === null || callback === void 0 ? void 0 : callback(value, event);
|
|
190
|
+
}, [callback, target]);
|
|
185
191
|
var getScrollContainer = useCallback(function () {
|
|
186
192
|
var menu = isFunction(target) ? target() : target;
|
|
187
193
|
|
|
@@ -267,11 +273,11 @@ export var useFocusItemValue = function useFocusItemValue(defaultFocusItemValue,
|
|
|
267
273
|
var focusItem = items[nextIndex];
|
|
268
274
|
if (!isUndefined(focusItem)) {
|
|
269
275
|
setFocusItemValue(focusItem[valueKey]);
|
|
270
|
-
|
|
276
|
+
focusCallback(focusItem[valueKey], event);
|
|
271
277
|
scrollListItem('bottom', focusItem[valueKey], willOverflow);
|
|
272
278
|
}
|
|
273
279
|
});
|
|
274
|
-
}, [
|
|
280
|
+
}, [focusCallback, findFocusItemIndex, scrollListItem, valueKey]);
|
|
275
281
|
var focusPrevMenuItem = useCallback(function (event) {
|
|
276
282
|
findFocusItemIndex(function (items, index) {
|
|
277
283
|
var willOverflow = index === 0;
|
|
@@ -279,11 +285,11 @@ export var useFocusItemValue = function useFocusItemValue(defaultFocusItemValue,
|
|
|
279
285
|
var focusItem = items[nextIndex];
|
|
280
286
|
if (!isUndefined(focusItem)) {
|
|
281
287
|
setFocusItemValue(focusItem[valueKey]);
|
|
282
|
-
|
|
288
|
+
focusCallback(focusItem[valueKey], event);
|
|
283
289
|
scrollListItem('top', focusItem[valueKey], willOverflow);
|
|
284
290
|
}
|
|
285
291
|
});
|
|
286
|
-
}, [
|
|
292
|
+
}, [focusCallback, findFocusItemIndex, scrollListItem, valueKey]);
|
|
287
293
|
var getSubMenuKeys = useCallback(function (nextLayer) {
|
|
288
294
|
var menu = isFunction(target) ? target() : target;
|
|
289
295
|
var subMenu = menu === null || menu === void 0 ? void 0 : menu.querySelector("[data-layer=\"" + nextLayer + "\"]");
|
|
@@ -303,9 +309,9 @@ export var useFocusItemValue = function useFocusItemValue(defaultFocusItemValue,
|
|
|
303
309
|
setKeys(nextKeys);
|
|
304
310
|
setLayer(nextLayer);
|
|
305
311
|
setFocusItemValue(nextKeys[0]);
|
|
306
|
-
|
|
312
|
+
focusCallback(nextKeys[0], event);
|
|
307
313
|
}
|
|
308
|
-
}, [
|
|
314
|
+
}, [focusCallback, getSubMenuKeys, layer]);
|
|
309
315
|
var focusPrevLevelMenu = useCallback(function (event) {
|
|
310
316
|
var nextLayer = layer - 1;
|
|
311
317
|
var nextKeys = getSubMenuKeys(nextLayer);
|
|
@@ -319,10 +325,10 @@ export var useFocusItemValue = function useFocusItemValue(defaultFocusItemValue,
|
|
|
319
325
|
var parentItemValue = (_getParent = getParent(focusItem)) === null || _getParent === void 0 ? void 0 : _getParent[valueKey];
|
|
320
326
|
if (parentItemValue) {
|
|
321
327
|
setFocusItemValue(parentItemValue);
|
|
322
|
-
|
|
328
|
+
focusCallback(parentItemValue, event);
|
|
323
329
|
}
|
|
324
330
|
}
|
|
325
|
-
}, [
|
|
331
|
+
}, [focusCallback, data, focusItemValue, getParent, getSubMenuKeys, layer, valueKey]);
|
|
326
332
|
var handleKeyDown = useCallback(function (event) {
|
|
327
333
|
var _onMenuKeyDown;
|
|
328
334
|
onMenuKeyDown(event, (_onMenuKeyDown = {
|
|
@@ -363,10 +369,13 @@ export var useToggleKeyDownEvent = function useToggleKeyDownEvent(props) {
|
|
|
363
369
|
onMenuPressEnter = props.onMenuPressEnter,
|
|
364
370
|
onMenuPressBackspace = props.onMenuPressBackspace;
|
|
365
371
|
var handleClose = useCallback(function () {
|
|
366
|
-
var _triggerRef$current, _triggerRef$current$c;
|
|
372
|
+
var _triggerRef$current, _triggerRef$current$c, _targetRef$current, _targetRef$current$fo;
|
|
367
373
|
(_triggerRef$current = triggerRef.current) === null || _triggerRef$current === void 0 ? void 0 : (_triggerRef$current$c = _triggerRef$current.close) === null || _triggerRef$current$c === void 0 ? void 0 : _triggerRef$current$c.call(_triggerRef$current);
|
|
374
|
+
|
|
375
|
+
// The focus is on the trigger button after closing
|
|
376
|
+
(_targetRef$current = targetRef.current) === null || _targetRef$current === void 0 ? void 0 : (_targetRef$current$fo = _targetRef$current.focus) === null || _targetRef$current$fo === void 0 ? void 0 : _targetRef$current$fo.call(_targetRef$current);
|
|
368
377
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
369
|
-
}, [onClose, triggerRef]);
|
|
378
|
+
}, [onClose, targetRef, triggerRef]);
|
|
370
379
|
var handleOpen = useCallback(function () {
|
|
371
380
|
var _triggerRef$current2, _triggerRef$current2$;
|
|
372
381
|
(_triggerRef$current2 = triggerRef.current) === null || _triggerRef$current2 === void 0 ? void 0 : (_triggerRef$current2$ = _triggerRef$current2.open) === null || _triggerRef$current2$ === void 0 ? void 0 : _triggerRef$current2$.call(_triggerRef$current2);
|
|
@@ -527,8 +536,8 @@ export function usePublicMethods(ref, parmas) {
|
|
|
527
536
|
return (_overlayRef$current = overlayRef === null || overlayRef === void 0 ? void 0 : overlayRef.current) !== null && _overlayRef$current !== void 0 ? _overlayRef$current : null;
|
|
528
537
|
},
|
|
529
538
|
get target() {
|
|
530
|
-
var _targetRef$
|
|
531
|
-
return (_targetRef$
|
|
539
|
+
var _targetRef$current2;
|
|
540
|
+
return (_targetRef$current2 = targetRef === null || targetRef === void 0 ? void 0 : targetRef.current) !== null && _targetRef$current2 !== void 0 ? _targetRef$current2 : null;
|
|
532
541
|
},
|
|
533
542
|
get list() {
|
|
534
543
|
if (!(listRef !== null && listRef !== void 0 && listRef.current)) {
|
package/esm/Table/Table.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Column, TableProps, RowDataType, TableInstance, CellProps as TableCellProps } from 'rsuite-table';
|
|
3
|
-
export interface CellProps<
|
|
2
|
+
import { Column, TableProps, RowDataType, TableInstance, CellProps as TableCellProps, RowKeyType } from 'rsuite-table';
|
|
3
|
+
export interface CellProps<Row extends RowDataType> extends Omit<TableCellProps<Row>, 'rowData' | 'dataKey'> {
|
|
4
4
|
/** Data binding key, but also a sort of key */
|
|
5
|
-
dataKey?: string | keyof
|
|
5
|
+
dataKey?: string | keyof Row;
|
|
6
6
|
/** Row Data */
|
|
7
|
-
rowData?:
|
|
7
|
+
rowData?: Row;
|
|
8
8
|
}
|
|
9
|
-
declare const _default: (<Row extends RowDataType<never>, Key>(props: TableProps<Row, Key> & React.RefAttributes<TableInstance<Row, Key>>) => React.ReactElement<any, string | React.JSXElementConstructor<any>>) & {
|
|
10
|
-
Cell:
|
|
9
|
+
declare const _default: (<Row extends RowDataType<never>, Key extends RowKeyType>(props: TableProps<Row, Key> & React.RefAttributes<TableInstance<Row, Key>>) => React.ReactElement<any, string | React.JSXElementConstructor<any>>) & {
|
|
10
|
+
Cell: <Row_1 extends RowDataType<never>, Key_1 extends RowKeyType>(props: import("rsuite-table/lib/Cell").InnerCellProps<Row_1, Key_1> & React.RefAttributes<HTMLDivElement>) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
11
11
|
Column: typeof Column;
|
|
12
|
-
HeaderCell:
|
|
12
|
+
HeaderCell: <Row_2 extends RowDataType<never>, Key_2 extends RowKeyType>(props: import("rsuite-table").HeaderCellProps<Row_2, Key_2> & React.RefAttributes<HTMLDivElement>) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
13
13
|
ColumnGroup: React.ForwardRefExoticComponent<import("rsuite-table").ColumnGroupProps & React.RefAttributes<HTMLDivElement>>;
|
|
14
14
|
};
|
|
15
15
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rsuite",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.46.0",
|
|
4
4
|
"description": "A suite of react components",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"prop-types": "^15.8.1",
|
|
39
39
|
"react-use-set": "^1.0.0",
|
|
40
40
|
"react-window": "^1.8.8",
|
|
41
|
-
"rsuite-table": "^5.
|
|
41
|
+
"rsuite-table": "^5.18.1",
|
|
42
42
|
"schema-typed": "^2.1.3"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
@@ -363,44 +363,4 @@
|
|
|
363
363
|
|
|
364
364
|
// Popover
|
|
365
365
|
--rs-popover-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
|
|
366
|
-
|
|
367
|
-
// CSS relative color syntax is not supported
|
|
368
|
-
// https://developer.chrome.com/blog/css-relative-color-syntax/
|
|
369
|
-
@supports not (color: rgb(from white r g b)) {
|
|
370
|
-
// Misc
|
|
371
|
-
--rs-bg-backdrop: fade(@B900-dark, 80%);
|
|
372
|
-
--rs-color-focus-ring: 0 0 0 3px fade(@H500-dark, 25%);
|
|
373
|
-
--rs-state-focus-shadow: 0 0 0 3px fade(@H500-dark, 25%);
|
|
374
|
-
--rs-state-focus-outline: 3px solid fade(@H500-dark, 25%);
|
|
375
|
-
|
|
376
|
-
// Loader
|
|
377
|
-
--rs-loader-ring: fade(@B050-dark, 30);
|
|
378
|
-
--rs-loader-backdrop: fade(@B900-dark, 83%);
|
|
379
|
-
--rs-loader-ring-inverse: fade(@B050-dark, 80);
|
|
380
|
-
--rs-loader-backdrop-inverse: fade(@B000-dark, 90);
|
|
381
|
-
|
|
382
|
-
// Dropdown
|
|
383
|
-
--rs-dropdown-item-bg-active: fade(@H900-dark, 20);
|
|
384
|
-
|
|
385
|
-
// ARIA Listboxes
|
|
386
|
-
--rs-listbox-option-selected-bg: fade(@H900-dark, 20%);
|
|
387
|
-
|
|
388
|
-
// Slider
|
|
389
|
-
--rs-slider-thumb-hover-shadow: 0 0 0 8px fade(@H500-dark, 25);
|
|
390
|
-
|
|
391
|
-
// Uploader
|
|
392
|
-
--rs-uploader-overlay-bg: fade(@B600-dark, 80);
|
|
393
|
-
|
|
394
|
-
// Carousel
|
|
395
|
-
--rs-carousel-indicator: fade(@B000-dark, 40);
|
|
396
|
-
|
|
397
|
-
// List
|
|
398
|
-
--rs-list-placeholder-bg: fade(@H900-dark, 20%);
|
|
399
|
-
|
|
400
|
-
// Calendar
|
|
401
|
-
--rs-calendar-range-bg: fade(@H900-dark, 50%);
|
|
402
|
-
|
|
403
|
-
// Placeholder
|
|
404
|
-
--rs-placeholder-active: lighten(@B600-dark, 5%);
|
|
405
|
-
}
|
|
406
366
|
}
|
|
@@ -379,39 +379,4 @@
|
|
|
379
379
|
|
|
380
380
|
// Popover
|
|
381
381
|
--rs-popover-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
|
|
382
|
-
|
|
383
|
-
// CSS relative color syntax is not supported
|
|
384
|
-
// https://developer.chrome.com/blog/css-relative-color-syntax/
|
|
385
|
-
@supports not (color: rgb(from white r g b)) {
|
|
386
|
-
// Misc
|
|
387
|
-
--rs-bg-backdrop: fade(@B900-high-contrast, 80%);
|
|
388
|
-
--rs-state-focus-outline: 3px solid fade(@H500-high-contrast, 25%);
|
|
389
|
-
|
|
390
|
-
// Loader
|
|
391
|
-
--rs-loader-ring: fade(@B050-high-contrast, 30);
|
|
392
|
-
--rs-loader-backdrop: fade(@B900-high-contrast, 83%);
|
|
393
|
-
--rs-loader-ring-inverse: fade(@B050-high-contrast, 80);
|
|
394
|
-
--rs-loader-backdrop-inverse: fade(@B000-high-contrast, 90);
|
|
395
|
-
|
|
396
|
-
// Dropdown
|
|
397
|
-
--rs-dropdown-item-bg-active: fade(@H900-high-contrast, 20);
|
|
398
|
-
|
|
399
|
-
// Slider
|
|
400
|
-
--rs-slider-thumb-hover-shadow: 0 0 0 8px fade(@H500-high-contrast, 25);
|
|
401
|
-
|
|
402
|
-
// Uploader
|
|
403
|
-
--rs-uploader-overlay-bg: fade(@B600-high-contrast, 80);
|
|
404
|
-
|
|
405
|
-
// Carousel
|
|
406
|
-
--rs-carousel-indicator: fade(@B000-high-contrast, 40);
|
|
407
|
-
|
|
408
|
-
// List
|
|
409
|
-
--rs-list-placeholder-bg: fade(@H900-high-contrast, 20%);
|
|
410
|
-
|
|
411
|
-
// Calendar
|
|
412
|
-
--rs-calendar-range-bg: fade(@H900-high-contrast, 50%);
|
|
413
|
-
|
|
414
|
-
// Placeholder
|
|
415
|
-
--rs-placeholder-active: lighten(@B600-high-contrast, 5%);
|
|
416
|
-
}
|
|
417
382
|
}
|