rsuite 5.44.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/Button/styles/index.less +1 -1
- package/CHANGELOG.md +25 -0
- package/DatePicker/styles/index.less +15 -0
- package/Drawer/styles/index.less +1 -1
- package/Modal/styles/index.less +24 -2
- 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/Drawer/Drawer.d.ts +2 -0
- package/cjs/Drawer/Drawer.js +16 -5
- package/cjs/Drawer/DrawerContext.d.ts +9 -0
- package/cjs/Drawer/DrawerContext.js +10 -0
- package/cjs/FormControl/FormControl.js +1 -1
- package/cjs/InputPicker/InputPicker.js +7 -4
- package/cjs/Modal/Modal.d.ts +2 -4
- package/cjs/Modal/Modal.js +24 -13
- package/cjs/Modal/ModalBody.js +14 -8
- package/cjs/Modal/ModalContext.d.ts +1 -3
- package/cjs/Modal/ModalHeader.js +9 -6
- package/cjs/Modal/index.d.ts +1 -0
- package/cjs/Modal/utils.d.ts +4 -1
- package/cjs/Modal/utils.js +9 -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 +141 -64
- 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 +141 -64
- package/dist/rsuite-no-reset.min.css +1 -1
- package/dist/rsuite-no-reset.min.css.map +1 -1
- package/dist/rsuite-rtl.css +141 -64
- package/dist/rsuite-rtl.min.css +1 -1
- package/dist/rsuite-rtl.min.css.map +1 -1
- package/dist/rsuite.css +141 -64
- package/dist/rsuite.js +73 -19
- 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/Drawer/Drawer.d.ts +2 -0
- package/esm/Drawer/Drawer.js +15 -5
- package/esm/Drawer/DrawerContext.d.ts +9 -0
- package/esm/Drawer/DrawerContext.js +4 -0
- package/esm/FormControl/FormControl.js +1 -1
- package/esm/InputPicker/InputPicker.js +7 -4
- package/esm/Modal/Modal.d.ts +2 -4
- package/esm/Modal/Modal.js +25 -14
- package/esm/Modal/ModalBody.js +14 -8
- package/esm/Modal/ModalContext.d.ts +1 -3
- package/esm/Modal/ModalHeader.js +9 -6
- package/esm/Modal/index.d.ts +1 -0
- package/esm/Modal/utils.d.ts +4 -1
- package/esm/Modal/utils.js +9 -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,
|
package/esm/Drawer/Drawer.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ import { TypeAttributes, RsRefForwardingComponent } from '../@types/common';
|
|
|
4
4
|
export interface DrawerProps extends ModalProps {
|
|
5
5
|
/** The placement of Drawer */
|
|
6
6
|
placement?: TypeAttributes.Placement4;
|
|
7
|
+
/** Custom close button */
|
|
8
|
+
closeButton?: React.ReactNode | boolean;
|
|
7
9
|
}
|
|
8
10
|
declare const DrawerBody: RsRefForwardingComponent<'div', ModalBodyProps>;
|
|
9
11
|
declare const DrawerHeader: RsRefForwardingComponent<'div', ModalHeaderProps>;
|
package/esm/Drawer/Drawer.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
-
import React from 'react';
|
|
4
|
+
import React, { useMemo } from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import Slide from '../Animation/Slide';
|
|
7
7
|
import Modal from '../Modal';
|
|
8
8
|
import { useClassNames } from '../utils';
|
|
9
9
|
import deprecateComponent from '../utils/deprecateComponent';
|
|
10
|
+
import DrawerContext from './DrawerContext';
|
|
10
11
|
var DrawerBody = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
11
12
|
return /*#__PURE__*/React.createElement(Modal.Body, _extends({
|
|
12
13
|
classPrefix: "drawer-body"
|
|
@@ -50,7 +51,9 @@ var Drawer = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
50
51
|
classPrefix = _props$classPrefix === void 0 ? 'drawer' : _props$classPrefix,
|
|
51
52
|
_props$animation = props.animation,
|
|
52
53
|
animation = _props$animation === void 0 ? Slide : _props$animation,
|
|
53
|
-
|
|
54
|
+
_props$closeButton = props.closeButton,
|
|
55
|
+
closeButton = _props$closeButton === void 0 ? true : _props$closeButton,
|
|
56
|
+
rest = _objectWithoutPropertiesLoose(props, ["className", "placement", "classPrefix", "animation", "closeButton"]);
|
|
54
57
|
var _useClassNames = useClassNames(classPrefix),
|
|
55
58
|
merge = _useClassNames.merge,
|
|
56
59
|
prefix = _useClassNames.prefix;
|
|
@@ -58,14 +61,21 @@ var Drawer = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
58
61
|
var animationProps = {
|
|
59
62
|
placement: placement
|
|
60
63
|
};
|
|
61
|
-
|
|
64
|
+
var contextValue = useMemo(function () {
|
|
65
|
+
return {
|
|
66
|
+
closeButton: closeButton,
|
|
67
|
+
isDrawer: true
|
|
68
|
+
};
|
|
69
|
+
}, [closeButton]);
|
|
70
|
+
return /*#__PURE__*/React.createElement(DrawerContext.Provider, {
|
|
71
|
+
value: contextValue
|
|
72
|
+
}, /*#__PURE__*/React.createElement(Modal, _extends({}, rest, {
|
|
62
73
|
ref: ref,
|
|
63
|
-
drawer: true,
|
|
64
74
|
classPrefix: classPrefix,
|
|
65
75
|
className: classes,
|
|
66
76
|
animation: animation,
|
|
67
77
|
animationProps: animationProps
|
|
68
|
-
}));
|
|
78
|
+
})));
|
|
69
79
|
});
|
|
70
80
|
DrawerBody.displayName = 'DrawerBody';
|
|
71
81
|
DrawerHeader.displayName = 'DrawerHeader';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface DrawerContextProps {
|
|
3
|
+
/** Custom close button */
|
|
4
|
+
closeButton?: React.ReactNode | boolean;
|
|
5
|
+
/** Render Modal as Drawer */
|
|
6
|
+
isDrawer: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare const DrawerContext: React.Context<DrawerContextProps | null>;
|
|
9
|
+
export default DrawerContext;
|
|
@@ -130,7 +130,7 @@ var FormControl = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
130
130
|
if (AccepterComponent === Toggle) {
|
|
131
131
|
valueKey = 'checked';
|
|
132
132
|
}
|
|
133
|
-
var accepterProps = (_accepterProps = {}, _accepterProps[valueKey] = val
|
|
133
|
+
var accepterProps = (_accepterProps = {}, _accepterProps[valueKey] = val === undefined ? defaultValue : val, _accepterProps);
|
|
134
134
|
return /*#__PURE__*/React.createElement(Component, {
|
|
135
135
|
className: classes,
|
|
136
136
|
ref: ref
|
|
@@ -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),
|
package/esm/Modal/Modal.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ import ModalBody from './ModalBody';
|
|
|
5
5
|
import ModalHeader from './ModalHeader';
|
|
6
6
|
import ModalTitle from './ModalTitle';
|
|
7
7
|
import ModalFooter from './ModalFooter';
|
|
8
|
-
import {
|
|
9
|
-
|
|
8
|
+
import { ModalSize } from './utils';
|
|
9
|
+
import { RsRefForwardingComponent } from '../@types/common';
|
|
10
10
|
export interface ModalProps extends BaseModalProps, Pick<React.HTMLAttributes<HTMLElement>, 'role' | 'id' | 'aria-labelledby' | 'aria-describedby'> {
|
|
11
11
|
/** A modal can have different sizes */
|
|
12
12
|
size?: ModalSize;
|
|
@@ -27,8 +27,6 @@ export interface ModalProps extends BaseModalProps, Pick<React.HTMLAttributes<HT
|
|
|
27
27
|
dialogAs?: React.ElementType;
|
|
28
28
|
/** Automatically sets the height when the body content is too long. */
|
|
29
29
|
overflow?: boolean;
|
|
30
|
-
/** Render Modal as Drawer */
|
|
31
|
-
drawer?: boolean;
|
|
32
30
|
}
|
|
33
31
|
interface ModalComponent extends RsRefForwardingComponent<'div', ModalProps> {
|
|
34
32
|
Body: typeof ModalBody;
|
package/esm/Modal/Modal.js
CHANGED
|
@@ -3,7 +3,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
3
3
|
import _taggedTemplateLiteralLoose from "@babel/runtime/helpers/esm/taggedTemplateLiteralLoose";
|
|
4
4
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
5
|
var _templateObject, _templateObject2;
|
|
6
|
-
import React, { useRef, useMemo, useState, useCallback } from 'react';
|
|
6
|
+
import React, { useRef, useMemo, useState, useCallback, useContext } from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import pick from 'lodash/pick';
|
|
9
9
|
import on from 'dom-lib/on';
|
|
@@ -20,8 +20,10 @@ import ModalFooter from './ModalFooter';
|
|
|
20
20
|
import { useBodyStyles } from './utils';
|
|
21
21
|
import useUniqueId from '../utils/useUniqueId';
|
|
22
22
|
import deprecatePropType from '../utils/deprecatePropType';
|
|
23
|
+
import DrawerContext from '../Drawer/DrawerContext';
|
|
23
24
|
var modalSizes = ['xs', 'sm', 'md', 'lg', 'full'];
|
|
24
25
|
var Modal = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
26
|
+
var _prefix;
|
|
25
27
|
var className = props.className,
|
|
26
28
|
children = props.children,
|
|
27
29
|
_props$classPrefix = props.classPrefix,
|
|
@@ -44,8 +46,6 @@ var Modal = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
44
46
|
animationTimeout = _props$animationTimeo === void 0 ? 300 : _props$animationTimeo,
|
|
45
47
|
_props$overflow = props.overflow,
|
|
46
48
|
overflow = _props$overflow === void 0 ? true : _props$overflow,
|
|
47
|
-
_props$drawer = props.drawer,
|
|
48
|
-
drawer = _props$drawer === void 0 ? false : _props$drawer,
|
|
49
49
|
onClose = props.onClose,
|
|
50
50
|
onEntered = props.onEntered,
|
|
51
51
|
onEntering = props.onEntering,
|
|
@@ -55,7 +55,7 @@ var Modal = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
55
55
|
idProp = props.id,
|
|
56
56
|
ariaLabelledby = props['aria-labelledby'],
|
|
57
57
|
ariaDescribedby = props['aria-describedby'],
|
|
58
|
-
rest = _objectWithoutPropertiesLoose(props, ["className", "children", "classPrefix", "dialogClassName", "backdropClassName", "backdrop", "dialogStyle", "animation", "open", "size", "full", "dialogAs", "animationProps", "animationTimeout", "overflow", "
|
|
58
|
+
rest = _objectWithoutPropertiesLoose(props, ["className", "children", "classPrefix", "dialogClassName", "backdropClassName", "backdrop", "dialogStyle", "animation", "open", "size", "full", "dialogAs", "animationProps", "animationTimeout", "overflow", "onClose", "onEntered", "onEntering", "onExited", "role", "id", "aria-labelledby", "aria-describedby"]);
|
|
59
59
|
var inClass = {
|
|
60
60
|
in: open && !animation
|
|
61
61
|
};
|
|
@@ -65,17 +65,21 @@ var Modal = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
65
65
|
var _useState = useState(false),
|
|
66
66
|
shake = _useState[0],
|
|
67
67
|
setShake = _useState[1];
|
|
68
|
-
var classes = merge(className, prefix(
|
|
68
|
+
var classes = merge(className, prefix((_prefix = {
|
|
69
69
|
full: full
|
|
70
|
-
}));
|
|
70
|
+
}, _prefix[size] = modalSizes.includes(size), _prefix)));
|
|
71
71
|
var dialogRef = useRef(null);
|
|
72
72
|
var transitionEndListener = useRef();
|
|
73
73
|
|
|
74
|
-
//
|
|
74
|
+
// Render Modal as Drawer
|
|
75
|
+
var _ref = useContext(DrawerContext) || {},
|
|
76
|
+
_ref$isDrawer = _ref.isDrawer,
|
|
77
|
+
isDrawer = _ref$isDrawer === void 0 ? false : _ref$isDrawer; // The style of the Modal body will be updated with the size of the window or container.
|
|
75
78
|
var _useBodyStyles = useBodyStyles(dialogRef, {
|
|
76
79
|
overflow: overflow,
|
|
77
|
-
drawer:
|
|
78
|
-
prefix: prefix
|
|
80
|
+
drawer: isDrawer,
|
|
81
|
+
prefix: prefix,
|
|
82
|
+
size: size
|
|
79
83
|
}),
|
|
80
84
|
bodyStyles = _useBodyStyles[0],
|
|
81
85
|
onChangeBodyStyles = _useBodyStyles[1],
|
|
@@ -87,10 +91,9 @@ var Modal = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
87
91
|
onModalClose: onClose,
|
|
88
92
|
getBodyStyles: function getBodyStyles() {
|
|
89
93
|
return bodyStyles;
|
|
90
|
-
}
|
|
91
|
-
isDrawer: drawer
|
|
94
|
+
}
|
|
92
95
|
};
|
|
93
|
-
}, [dialogId, onClose, bodyStyles
|
|
96
|
+
}, [dialogId, onClose, bodyStyles]);
|
|
94
97
|
var handleExited = useCallback(function (node) {
|
|
95
98
|
var _transitionEndListene;
|
|
96
99
|
onExited === null || onExited === void 0 ? void 0 : onExited(node);
|
|
@@ -144,6 +147,12 @@ var Modal = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
144
147
|
var _transitionEndListene2;
|
|
145
148
|
(_transitionEndListene2 = transitionEndListener.current) === null || _transitionEndListene2 === void 0 ? void 0 : _transitionEndListene2.off();
|
|
146
149
|
});
|
|
150
|
+
var sizeKey = 'width';
|
|
151
|
+
if (isDrawer) {
|
|
152
|
+
var _ref2 = animationProps || {},
|
|
153
|
+
placement = _ref2.placement; // The width or height of the drawer depends on the placement.
|
|
154
|
+
sizeKey = placement === 'top' || placement === 'bottom' ? 'height' : 'width';
|
|
155
|
+
}
|
|
147
156
|
return /*#__PURE__*/React.createElement(ModalContext.Provider, {
|
|
148
157
|
value: modalContextValue
|
|
149
158
|
}, /*#__PURE__*/React.createElement(BaseModal, _extends({}, rest, {
|
|
@@ -167,13 +176,15 @@ var Modal = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
167
176
|
onClick: backdrop ? handleBackdropClick : undefined,
|
|
168
177
|
onMouseDown: handleMouseDown
|
|
169
178
|
}), function (transitionProps, transitionRef) {
|
|
179
|
+
var _ref3;
|
|
170
180
|
var transitionClassName = transitionProps.className,
|
|
171
181
|
transitionRest = _objectWithoutPropertiesLoose(transitionProps, ["className"]);
|
|
172
182
|
return /*#__PURE__*/React.createElement(Dialog, _extends({
|
|
173
183
|
role: role,
|
|
174
184
|
id: dialogId,
|
|
175
185
|
"aria-labelledby": ariaLabelledby !== null && ariaLabelledby !== void 0 ? ariaLabelledby : dialogId + "-title",
|
|
176
|
-
"aria-describedby": ariaDescribedby
|
|
186
|
+
"aria-describedby": ariaDescribedby,
|
|
187
|
+
style: (_ref3 = {}, _ref3[sizeKey] = modalSizes.includes(size) ? undefined : size, _ref3)
|
|
177
188
|
}, transitionRest, pick(rest, Object.keys(modalDialogPropTypes)), {
|
|
178
189
|
ref: mergeRefs(dialogRef, transitionRef),
|
|
179
190
|
classPrefix: classPrefix,
|
|
@@ -196,7 +207,7 @@ Modal.propTypes = _extends({}, modalPropTypes, {
|
|
|
196
207
|
animationTimeout: PropTypes.number,
|
|
197
208
|
classPrefix: PropTypes.string,
|
|
198
209
|
dialogClassName: PropTypes.string,
|
|
199
|
-
size: PropTypes.oneOf(modalSizes),
|
|
210
|
+
size: PropTypes.oneOfType([PropTypes.oneOf(modalSizes), PropTypes.number, PropTypes.string]),
|
|
200
211
|
dialogStyle: PropTypes.object,
|
|
201
212
|
dialogAs: PropTypes.elementType,
|
|
202
213
|
full: deprecatePropType(PropTypes.bool, 'Use size="full" instead.'),
|
package/esm/Modal/ModalBody.js
CHANGED
|
@@ -7,8 +7,9 @@ import { useClassNames } from '../utils';
|
|
|
7
7
|
import { ModalContext } from './ModalContext';
|
|
8
8
|
import IconButton from '../IconButton';
|
|
9
9
|
import Close from '@rsuite/icons/Close';
|
|
10
|
+
import DrawerContext from '../Drawer/DrawerContext';
|
|
10
11
|
var ModalBody = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
11
|
-
var _context$getBodyStyle;
|
|
12
|
+
var _context$getBodyStyle, _useContext;
|
|
12
13
|
var _props$as = props.as,
|
|
13
14
|
Component = _props$as === void 0 ? 'div' : _props$as,
|
|
14
15
|
_props$classPrefix = props.classPrefix,
|
|
@@ -24,17 +25,22 @@ var ModalBody = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
24
25
|
var classes = merge(className, withClassPrefix());
|
|
25
26
|
var context = useContext(ModalContext);
|
|
26
27
|
var bodyStyles = context === null || context === void 0 ? void 0 : (_context$getBodyStyle = context.getBodyStyles) === null || _context$getBodyStyle === void 0 ? void 0 : _context$getBodyStyle.call(context);
|
|
28
|
+
var closeButton = (_useContext = useContext(DrawerContext)) === null || _useContext === void 0 ? void 0 : _useContext.closeButton;
|
|
29
|
+
var buttonElement = null;
|
|
30
|
+
if (closeButton) {
|
|
31
|
+
buttonElement = typeof closeButton === 'boolean' ? /*#__PURE__*/React.createElement(IconButton, {
|
|
32
|
+
icon: /*#__PURE__*/React.createElement(Close, null),
|
|
33
|
+
appearance: "subtle",
|
|
34
|
+
size: "sm",
|
|
35
|
+
className: prefix('close'),
|
|
36
|
+
onClick: context === null || context === void 0 ? void 0 : context.onModalClose
|
|
37
|
+
}) : closeButton;
|
|
38
|
+
}
|
|
27
39
|
return /*#__PURE__*/React.createElement(Component, _extends({}, rest, {
|
|
28
40
|
ref: ref,
|
|
29
41
|
style: _extends({}, bodyStyles, style),
|
|
30
42
|
className: classes
|
|
31
|
-
}),
|
|
32
|
-
icon: /*#__PURE__*/React.createElement(Close, null),
|
|
33
|
-
appearance: "subtle",
|
|
34
|
-
size: "sm",
|
|
35
|
-
className: prefix('close'),
|
|
36
|
-
onClick: context === null || context === void 0 ? void 0 : context.onModalClose
|
|
37
|
-
}), children);
|
|
43
|
+
}), buttonElement, children);
|
|
38
44
|
});
|
|
39
45
|
ModalBody.displayName = 'ModalBody';
|
|
40
46
|
ModalBody.propTypes = {
|
|
@@ -5,8 +5,6 @@ export interface ModalContextProps {
|
|
|
5
5
|
/** Pass the close event callback to the header close button. */
|
|
6
6
|
onModalClose?: (event: React.MouseEvent<Element, MouseEvent>) => void;
|
|
7
7
|
/** Pass the latest style to body. */
|
|
8
|
-
getBodyStyles?: () => React.CSSProperties;
|
|
9
|
-
/** Whether this Modal is a Drawer */
|
|
10
|
-
isDrawer: boolean;
|
|
8
|
+
getBodyStyles?: () => React.CSSProperties | null;
|
|
11
9
|
}
|
|
12
10
|
export declare const ModalContext: React.Context<ModalContextProps | null>;
|