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
|
@@ -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>;
|
package/cjs/Modal/ModalHeader.js
CHANGED
|
@@ -14,7 +14,9 @@ var _ModalContext = require("./ModalContext");
|
|
|
14
14
|
var _CloseButton = _interopRequireDefault(require("../CloseButton"));
|
|
15
15
|
var _Close = _interopRequireDefault(require("@rsuite/icons/Close"));
|
|
16
16
|
var _IconButton = _interopRequireDefault(require("../IconButton"));
|
|
17
|
+
var _DrawerContext = _interopRequireDefault(require("../Drawer/DrawerContext"));
|
|
17
18
|
var ModalHeader = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
19
|
+
var _useContext, _useContext2;
|
|
18
20
|
var _props$as = props.as,
|
|
19
21
|
Component = _props$as === void 0 ? 'div' : _props$as,
|
|
20
22
|
_props$classPrefix = props.classPrefix,
|
|
@@ -30,16 +32,17 @@ var ModalHeader = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
|
30
32
|
withClassPrefix = _useClassNames.withClassPrefix,
|
|
31
33
|
prefix = _useClassNames.prefix;
|
|
32
34
|
var classes = merge(className, withClassPrefix());
|
|
33
|
-
var
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
onClick: (0, _utils.createChainedFunction)(onClose, context === null || context === void 0 ? void 0 : context.onModalClose)
|
|
37
|
-
}) : /*#__PURE__*/_react.default.createElement(_IconButton.default, {
|
|
35
|
+
var onModalClose = (_useContext = (0, _react.useContext)(_ModalContext.ModalContext)) === null || _useContext === void 0 ? void 0 : _useContext.onModalClose;
|
|
36
|
+
var isDrawer = (_useContext2 = (0, _react.useContext)(_DrawerContext.default)) === null || _useContext2 === void 0 ? void 0 : _useContext2.isDrawer;
|
|
37
|
+
var buttonElement = isDrawer ? /*#__PURE__*/_react.default.createElement(_IconButton.default, {
|
|
38
38
|
icon: /*#__PURE__*/_react.default.createElement(_Close.default, null),
|
|
39
39
|
appearance: "subtle",
|
|
40
40
|
size: "sm",
|
|
41
41
|
className: prefix('close'),
|
|
42
|
-
onClick: (0, _utils.createChainedFunction)(onClose,
|
|
42
|
+
onClick: (0, _utils.createChainedFunction)(onClose, onModalClose)
|
|
43
|
+
}) : /*#__PURE__*/_react.default.createElement(_CloseButton.default, {
|
|
44
|
+
className: prefix('close'),
|
|
45
|
+
onClick: (0, _utils.createChainedFunction)(onClose, onModalClose)
|
|
43
46
|
});
|
|
44
47
|
return /*#__PURE__*/_react.default.createElement(Component, (0, _extends2.default)({}, rest, {
|
|
45
48
|
ref: ref,
|
package/cjs/Modal/index.d.ts
CHANGED
|
@@ -5,4 +5,5 @@ export type { ModalDialogProps } from './ModalDialog';
|
|
|
5
5
|
export type { ModalFooterProps } from './ModalFooter';
|
|
6
6
|
export type { ModalHeaderProps } from './ModalHeader';
|
|
7
7
|
export type { ModalTitleProps } from './ModalTitle';
|
|
8
|
+
export type { ModalSize } from './utils';
|
|
8
9
|
export default Modal;
|
package/cjs/Modal/utils.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { TypeAttributes } from '../@types/common';
|
|
3
|
+
export declare type ModalSize = TypeAttributes.Size | 'full' | number | string;
|
|
2
4
|
export declare const useBodyStyles: (ref: React.RefObject<HTMLElement>, options: {
|
|
3
5
|
overflow: boolean;
|
|
4
6
|
drawer: boolean;
|
|
7
|
+
size?: ModalSize | undefined;
|
|
5
8
|
prefix: (...classes: any) => string;
|
|
6
|
-
}) => [import("react").CSSProperties, (entering?: boolean) => void, () => void];
|
|
9
|
+
}) => [import("react").CSSProperties | null, (entering?: boolean) => void, () => void];
|
package/cjs/Modal/utils.js
CHANGED
|
@@ -14,7 +14,8 @@ var useBodyStyles = function useBodyStyles(ref, options) {
|
|
|
14
14
|
setBodyStyles = _useState[1];
|
|
15
15
|
var overflow = options.overflow,
|
|
16
16
|
drawer = options.drawer,
|
|
17
|
-
prefix = options.prefix
|
|
17
|
+
prefix = options.prefix,
|
|
18
|
+
size = options.size;
|
|
18
19
|
var windowResizeListener = (0, _react.useRef)();
|
|
19
20
|
var contentElement = (0, _react.useRef)(null);
|
|
20
21
|
var contentElementResizeObserver = (0, _react.useRef)();
|
|
@@ -51,7 +52,11 @@ var useBodyStyles = function useBodyStyles(ref, options) {
|
|
|
51
52
|
contentElementResizeObserver.current = null;
|
|
52
53
|
}, []);
|
|
53
54
|
var onChangeBodyStyles = (0, _react.useCallback)(function (entering) {
|
|
54
|
-
if (
|
|
55
|
+
if (drawer || size === 'full') {
|
|
56
|
+
setBodyStyles(null);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (overflow && ref.current) {
|
|
55
60
|
updateBodyStyles(undefined, entering);
|
|
56
61
|
contentElement.current = ref.current.querySelector("." + prefix('content'));
|
|
57
62
|
if (!windowResizeListener.current) {
|
|
@@ -64,11 +69,11 @@ var useBodyStyles = function useBodyStyles(ref, options) {
|
|
|
64
69
|
contentElementResizeObserver.current.observe(contentElement.current);
|
|
65
70
|
}
|
|
66
71
|
}
|
|
67
|
-
}, [drawer, overflow, prefix, ref, updateBodyStyles]);
|
|
72
|
+
}, [drawer, overflow, prefix, ref, size, updateBodyStyles]);
|
|
68
73
|
(0, _react.useEffect)(function () {
|
|
69
74
|
return onDestroyEvents;
|
|
70
75
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
71
76
|
}, []);
|
|
72
|
-
return [overflow ? bodyStyles :
|
|
77
|
+
return [overflow ? bodyStyles : null, onChangeBodyStyles, onDestroyEvents];
|
|
73
78
|
};
|
|
74
79
|
exports.useBodyStyles = useBodyStyles;
|
|
@@ -148,6 +148,8 @@ var PickerToggle = /*#__PURE__*/_react.default.forwardRef(function (props, ref)
|
|
|
148
148
|
}, [editable, onInputPressEnter, onInputBackspace]);
|
|
149
149
|
var renderInput = (0, _react.useCallback)(function (ref, props) {
|
|
150
150
|
return /*#__PURE__*/_react.default.createElement("input", (0, _extends2.default)({
|
|
151
|
+
type: "text",
|
|
152
|
+
autoComplete: "off",
|
|
151
153
|
ref: (0, _utils.mergeRefs)(inputRef, ref),
|
|
152
154
|
name: name,
|
|
153
155
|
style: {
|
|
@@ -197,6 +199,7 @@ var PickerToggle = /*#__PURE__*/_react.default.forwardRef(function (props, ref)
|
|
|
197
199
|
},
|
|
198
200
|
"data-testid": "spinner"
|
|
199
201
|
}) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_TextMask.default, {
|
|
202
|
+
keepCharPositions: true,
|
|
200
203
|
mask: inputMask,
|
|
201
204
|
value: Array.isArray(inputValue) ? inputValue.toString() : inputValue,
|
|
202
205
|
onBlur: handleInputBlur,
|
package/cjs/Picker/utils.js
CHANGED
|
@@ -194,6 +194,12 @@ var useFocusItemValue = function useFocusItemValue(defaultFocusItemValue, props)
|
|
|
194
194
|
var _useState3 = (0, _react.useState)([]),
|
|
195
195
|
keys = _useState3[0],
|
|
196
196
|
setKeys = _useState3[1];
|
|
197
|
+
var focusCallback = (0, _react.useCallback)(function (value, event) {
|
|
198
|
+
var menu = (0, _isFunction.default)(target) ? target() : target;
|
|
199
|
+
var focusElement = menu === null || menu === void 0 ? void 0 : menu.querySelector("[data-key=\"" + value + "\"]");
|
|
200
|
+
focusElement === null || focusElement === void 0 ? void 0 : focusElement.focus();
|
|
201
|
+
callback === null || callback === void 0 ? void 0 : callback(value, event);
|
|
202
|
+
}, [callback, target]);
|
|
197
203
|
var getScrollContainer = (0, _react.useCallback)(function () {
|
|
198
204
|
var menu = (0, _isFunction.default)(target) ? target() : target;
|
|
199
205
|
|
|
@@ -279,11 +285,11 @@ var useFocusItemValue = function useFocusItemValue(defaultFocusItemValue, props)
|
|
|
279
285
|
var focusItem = items[nextIndex];
|
|
280
286
|
if (!(0, _isUndefined.default)(focusItem)) {
|
|
281
287
|
setFocusItemValue(focusItem[valueKey]);
|
|
282
|
-
|
|
288
|
+
focusCallback(focusItem[valueKey], event);
|
|
283
289
|
scrollListItem('bottom', focusItem[valueKey], willOverflow);
|
|
284
290
|
}
|
|
285
291
|
});
|
|
286
|
-
}, [
|
|
292
|
+
}, [focusCallback, findFocusItemIndex, scrollListItem, valueKey]);
|
|
287
293
|
var focusPrevMenuItem = (0, _react.useCallback)(function (event) {
|
|
288
294
|
findFocusItemIndex(function (items, index) {
|
|
289
295
|
var willOverflow = index === 0;
|
|
@@ -291,11 +297,11 @@ var useFocusItemValue = function useFocusItemValue(defaultFocusItemValue, props)
|
|
|
291
297
|
var focusItem = items[nextIndex];
|
|
292
298
|
if (!(0, _isUndefined.default)(focusItem)) {
|
|
293
299
|
setFocusItemValue(focusItem[valueKey]);
|
|
294
|
-
|
|
300
|
+
focusCallback(focusItem[valueKey], event);
|
|
295
301
|
scrollListItem('top', focusItem[valueKey], willOverflow);
|
|
296
302
|
}
|
|
297
303
|
});
|
|
298
|
-
}, [
|
|
304
|
+
}, [focusCallback, findFocusItemIndex, scrollListItem, valueKey]);
|
|
299
305
|
var getSubMenuKeys = (0, _react.useCallback)(function (nextLayer) {
|
|
300
306
|
var menu = (0, _isFunction.default)(target) ? target() : target;
|
|
301
307
|
var subMenu = menu === null || menu === void 0 ? void 0 : menu.querySelector("[data-layer=\"" + nextLayer + "\"]");
|
|
@@ -315,9 +321,9 @@ var useFocusItemValue = function useFocusItemValue(defaultFocusItemValue, props)
|
|
|
315
321
|
setKeys(nextKeys);
|
|
316
322
|
setLayer(nextLayer);
|
|
317
323
|
setFocusItemValue(nextKeys[0]);
|
|
318
|
-
|
|
324
|
+
focusCallback(nextKeys[0], event);
|
|
319
325
|
}
|
|
320
|
-
}, [
|
|
326
|
+
}, [focusCallback, getSubMenuKeys, layer]);
|
|
321
327
|
var focusPrevLevelMenu = (0, _react.useCallback)(function (event) {
|
|
322
328
|
var nextLayer = layer - 1;
|
|
323
329
|
var nextKeys = getSubMenuKeys(nextLayer);
|
|
@@ -331,10 +337,10 @@ var useFocusItemValue = function useFocusItemValue(defaultFocusItemValue, props)
|
|
|
331
337
|
var parentItemValue = (_getParent = getParent(focusItem)) === null || _getParent === void 0 ? void 0 : _getParent[valueKey];
|
|
332
338
|
if (parentItemValue) {
|
|
333
339
|
setFocusItemValue(parentItemValue);
|
|
334
|
-
|
|
340
|
+
focusCallback(parentItemValue, event);
|
|
335
341
|
}
|
|
336
342
|
}
|
|
337
|
-
}, [
|
|
343
|
+
}, [focusCallback, data, focusItemValue, getParent, getSubMenuKeys, layer, valueKey]);
|
|
338
344
|
var handleKeyDown = (0, _react.useCallback)(function (event) {
|
|
339
345
|
var _onMenuKeyDown;
|
|
340
346
|
onMenuKeyDown(event, (_onMenuKeyDown = {
|
|
@@ -376,10 +382,13 @@ var useToggleKeyDownEvent = function useToggleKeyDownEvent(props) {
|
|
|
376
382
|
onMenuPressEnter = props.onMenuPressEnter,
|
|
377
383
|
onMenuPressBackspace = props.onMenuPressBackspace;
|
|
378
384
|
var handleClose = (0, _react.useCallback)(function () {
|
|
379
|
-
var _triggerRef$current, _triggerRef$current$c;
|
|
385
|
+
var _triggerRef$current, _triggerRef$current$c, _targetRef$current, _targetRef$current$fo;
|
|
380
386
|
(_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);
|
|
387
|
+
|
|
388
|
+
// The focus is on the trigger button after closing
|
|
389
|
+
(_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);
|
|
381
390
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
382
|
-
}, [onClose, triggerRef]);
|
|
391
|
+
}, [onClose, targetRef, triggerRef]);
|
|
383
392
|
var handleOpen = (0, _react.useCallback)(function () {
|
|
384
393
|
var _triggerRef$current2, _triggerRef$current2$;
|
|
385
394
|
(_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);
|
|
@@ -541,8 +550,8 @@ function usePublicMethods(ref, parmas) {
|
|
|
541
550
|
return (_overlayRef$current = overlayRef === null || overlayRef === void 0 ? void 0 : overlayRef.current) !== null && _overlayRef$current !== void 0 ? _overlayRef$current : null;
|
|
542
551
|
},
|
|
543
552
|
get target() {
|
|
544
|
-
var _targetRef$
|
|
545
|
-
return (_targetRef$
|
|
553
|
+
var _targetRef$current2;
|
|
554
|
+
return (_targetRef$current2 = targetRef === null || targetRef === void 0 ? void 0 : targetRef.current) !== null && _targetRef$current2 !== void 0 ? _targetRef$current2 : null;
|
|
546
555
|
},
|
|
547
556
|
get list() {
|
|
548
557
|
if (!(listRef !== null && listRef !== void 0 && listRef.current)) {
|
package/cjs/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;
|