rsuite 5.52.0 → 5.53.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/AutoComplete/styles/index.css +4 -0
- package/CHANGELOG.md +15 -0
- package/Cascader/styles/index.css +4 -0
- package/CheckPicker/styles/index.css +4 -0
- package/CheckTree/styles/index.css +34 -14
- package/CheckTreePicker/styles/index.css +34 -14
- package/CheckTreePicker/styles/index.less +39 -29
- package/DatePicker/styles/index.css +4 -0
- package/DateRangePicker/styles/index.css +4 -0
- package/InputGroup/styles/index.css +5 -0
- package/InputGroup/styles/index.less +1 -1
- package/InputNumber/styles/index.css +2 -0
- package/InputPicker/styles/index.css +4 -0
- package/Message/styles/index.css +170 -29
- package/Message/styles/index.less +42 -3
- package/Message/styles/mixin.less +18 -3
- package/MultiCascader/styles/index.css +4 -0
- package/Pagination/styles/index.css +4 -0
- package/SelectPicker/styles/index.css +4 -0
- package/Tabs/package.json +7 -0
- package/Tabs/styles/index.css +1816 -0
- package/Tabs/styles/index.less +28 -0
- package/TagInput/styles/index.css +4 -0
- package/TagPicker/styles/index.css +4 -0
- package/Tree/styles/index.css +10 -4
- package/TreePicker/styles/index.css +10 -4
- package/TreePicker/styles/index.less +9 -5
- package/cjs/CheckTreePicker/CheckTreeNode.js +1 -1
- package/cjs/DateRangePicker/DateRangePicker.d.ts +10 -10
- package/cjs/DateRangePicker/index.d.ts +1 -1
- package/cjs/Dropdown/DropdownItem.js +4 -2
- package/cjs/Message/Message.d.ts +28 -6
- package/cjs/Message/Message.js +17 -11
- package/cjs/Nav/Nav.d.ts +2 -0
- package/cjs/Nav/Nav.js +13 -8
- package/cjs/Tabs/Tab.d.ts +25 -0
- package/cjs/Tabs/Tab.js +21 -0
- package/cjs/Tabs/TabPanel.d.ts +10 -0
- package/cjs/Tabs/TabPanel.js +33 -0
- package/cjs/Tabs/Tabs.d.ts +50 -0
- package/cjs/Tabs/Tabs.js +221 -0
- package/cjs/Tabs/index.d.ts +3 -0
- package/cjs/Tabs/index.js +9 -0
- package/cjs/index.d.ts +2 -0
- package/cjs/index.js +3 -1
- package/cjs/internals/Menu/Menu.js +12 -1
- package/cjs/internals/Picker/ListCheckItem.js +7 -2
- package/cjs/internals/Picker/ListItem.js +6 -2
- package/cjs/internals/Picker/TreeView.js +1 -1
- package/cjs/utils/ReactChildren.d.ts +2 -2
- package/cjs/utils/ReactChildren.js +16 -17
- package/cjs/utils/index.d.ts +2 -0
- package/cjs/utils/index.js +8 -2
- package/cjs/utils/statusIcons.js +2 -2
- package/dist/rsuite-no-reset-rtl.css +212 -35
- 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 +212 -35
- package/dist/rsuite-no-reset.min.css +1 -1
- package/dist/rsuite-no-reset.min.css.map +1 -1
- package/dist/rsuite-rtl.css +212 -35
- package/dist/rsuite-rtl.min.css +1 -1
- package/dist/rsuite-rtl.min.css.map +1 -1
- package/dist/rsuite.css +212 -35
- package/dist/rsuite.js +78 -45
- package/dist/rsuite.js.map +1 -1
- package/dist/rsuite.min.css +1 -1
- package/dist/rsuite.min.css.map +1 -1
- package/dist/rsuite.min.js +1 -1
- package/dist/rsuite.min.js.map +1 -1
- package/esm/CheckTreePicker/CheckTreeNode.js +1 -1
- package/esm/DateRangePicker/DateRangePicker.d.ts +10 -10
- package/esm/DateRangePicker/index.d.ts +1 -1
- package/esm/Dropdown/DropdownItem.js +4 -2
- package/esm/Message/Message.d.ts +28 -6
- package/esm/Message/Message.js +19 -13
- package/esm/Nav/Nav.d.ts +2 -0
- package/esm/Nav/Nav.js +12 -7
- package/esm/Tabs/Tab.d.ts +25 -0
- package/esm/Tabs/Tab.js +15 -0
- package/esm/Tabs/TabPanel.d.ts +10 -0
- package/esm/Tabs/TabPanel.js +27 -0
- package/esm/Tabs/Tabs.d.ts +50 -0
- package/esm/Tabs/Tabs.js +215 -0
- package/esm/Tabs/index.d.ts +3 -0
- package/esm/Tabs/index.js +3 -0
- package/esm/index.d.ts +2 -0
- package/esm/index.js +1 -0
- package/esm/internals/Menu/Menu.js +12 -1
- package/esm/internals/Picker/ListCheckItem.js +7 -2
- package/esm/internals/Picker/ListItem.js +6 -2
- package/esm/internals/Picker/TreeView.js +1 -1
- package/esm/utils/ReactChildren.d.ts +2 -2
- package/esm/utils/ReactChildren.js +16 -17
- package/esm/utils/index.d.ts +2 -0
- package/esm/utils/index.js +3 -1
- package/esm/utils/statusIcons.js +2 -2
- package/internals/Picker/styles/index.less +1 -1
- package/package.json +1 -1
- package/styles/color-modes/dark.less +4 -0
- package/styles/color-modes/light.less +18 -4
- package/styles/index.less +1 -0
- package/styles/mixins/listbox.less +2 -7
- package/styles/variables.less +2 -1
|
@@ -126,7 +126,7 @@ var CheckTreeNode = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
126
126
|
title: getTitle(),
|
|
127
127
|
onSelect: handleSelect
|
|
128
128
|
}, /*#__PURE__*/React.createElement("span", {
|
|
129
|
-
className: prefix('
|
|
129
|
+
className: prefix('label-content')
|
|
130
130
|
}, typeof renderTreeNode === 'function' ? renderTreeNode(nodeData) : label))) : null;
|
|
131
131
|
});
|
|
132
132
|
CheckTreeNode.displayName = 'CheckTreeNode';
|
|
@@ -72,28 +72,28 @@ export interface DateRangePickerProps extends PickerBaseProps<DateRangePickerLoc
|
|
|
72
72
|
/** Custom render for calendar title */
|
|
73
73
|
renderTitle?: (date: Date) => React.ReactNode;
|
|
74
74
|
}
|
|
75
|
-
export interface
|
|
75
|
+
export interface DateRangePickerComponent extends PickerComponent<DateRangePickerProps> {
|
|
76
76
|
/** Allow the maximum number of days specified, other dates are disabled */
|
|
77
|
-
allowedMaxDays
|
|
77
|
+
allowedMaxDays: (days: number) => DisabledDateFunction;
|
|
78
78
|
/** Only allowed days are specified, other dates are disabled */
|
|
79
|
-
allowedDays
|
|
79
|
+
allowedDays: (days: number) => DisabledDateFunction;
|
|
80
80
|
/** Allow specified date range, other dates are disabled */
|
|
81
|
-
allowedRange
|
|
81
|
+
allowedRange: (startDate: string | Date, endDate: string | Date) => DisabledDateFunction;
|
|
82
82
|
/** Disable dates after the specified date */
|
|
83
|
-
before
|
|
83
|
+
before: (beforeDate: string | Date) => DisabledDateFunction;
|
|
84
84
|
/** Disable dates before the specified date */
|
|
85
|
-
after
|
|
85
|
+
after: (afterDate: string | Date) => DisabledDateFunction;
|
|
86
86
|
/** Disable dates after today. */
|
|
87
|
-
beforeToday
|
|
87
|
+
beforeToday: () => DisabledDateFunction;
|
|
88
88
|
/** Disable dates before today */
|
|
89
|
-
afterToday
|
|
89
|
+
afterToday: () => DisabledDateFunction;
|
|
90
90
|
/** Used to combine multiple conditions */
|
|
91
|
-
combine
|
|
91
|
+
combine: (...args: any) => DisabledDateFunction;
|
|
92
92
|
}
|
|
93
93
|
/**
|
|
94
94
|
* A date range picker allows you to select a date range from a calendar.
|
|
95
95
|
*
|
|
96
96
|
* @see https://rsuitejs.com/components/date-range-picker
|
|
97
97
|
*/
|
|
98
|
-
declare const DateRangePicker:
|
|
98
|
+
declare const DateRangePicker: DateRangePickerComponent;
|
|
99
99
|
export default DateRangePicker;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import DateRangePicker from './DateRangePicker';
|
|
2
|
-
export type {
|
|
2
|
+
export type { DateRangePickerComponent, DateRangePickerProps } from './DateRangePicker';
|
|
3
3
|
export type { ValueType, DateRange, RangeType, DisabledDateFunction } from './types';
|
|
4
4
|
export default DateRangePicker;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
3
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
4
|
-
import _pick from "lodash/pick";
|
|
5
4
|
import React, { useCallback, useContext, useEffect } from 'react';
|
|
6
5
|
import PropTypes from 'prop-types';
|
|
7
6
|
import { deprecatePropType, deprecatePropTypeNew, oneOf } from '../internals/propTypes';
|
|
8
7
|
import MenuItem from '../internals/Menu/MenuItem';
|
|
9
8
|
import DropdownContext from './DropdownContext';
|
|
10
9
|
import isNil from 'lodash/isNil';
|
|
10
|
+
import pick from 'lodash/pick';
|
|
11
11
|
import { mergeRefs, shallowEqual, useClassNames } from '../utils';
|
|
12
12
|
import NavContext from '../Nav/NavContext';
|
|
13
13
|
import useInternalId from '../utils/useInternalId';
|
|
@@ -83,7 +83,9 @@ var DropdownItem = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
83
83
|
}, props));
|
|
84
84
|
}
|
|
85
85
|
if (divider) {
|
|
86
|
-
return /*#__PURE__*/React.createElement(DropdownSeparator,
|
|
86
|
+
return /*#__PURE__*/React.createElement(DropdownSeparator, _extends({
|
|
87
|
+
as: "li"
|
|
88
|
+
}, pick(props, ['data-testid'])));
|
|
87
89
|
}
|
|
88
90
|
if (panel) {
|
|
89
91
|
return renderDropdownItem(_extends({
|
package/esm/Message/Message.d.ts
CHANGED
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { WithAsProps, TypeAttributes, RsRefForwardingComponent } from '../@types/common';
|
|
3
3
|
export interface MessageProps extends WithAsProps {
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* The type of the message box.
|
|
6
|
+
*/
|
|
5
7
|
type?: TypeAttributes.Status;
|
|
6
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* Show a border around the message box.
|
|
10
|
+
* @version 5.53.0
|
|
11
|
+
*/
|
|
12
|
+
bordered?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Center the message vertically.
|
|
15
|
+
* @version 5.53.0
|
|
16
|
+
*/
|
|
17
|
+
centered?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Whether it is possible to close the message box
|
|
20
|
+
*/
|
|
7
21
|
closable?: boolean;
|
|
8
22
|
/**
|
|
9
23
|
* Delay automatic removal of messages.
|
|
@@ -15,13 +29,21 @@ export interface MessageProps extends WithAsProps {
|
|
|
15
29
|
*
|
|
16
30
|
*/
|
|
17
31
|
duration?: number;
|
|
18
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* The title of the message
|
|
34
|
+
*/
|
|
19
35
|
header?: React.ReactNode;
|
|
20
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* Whether to display an icon
|
|
38
|
+
*/
|
|
21
39
|
showIcon?: boolean;
|
|
22
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* Fill the container
|
|
42
|
+
*/
|
|
23
43
|
full?: boolean;
|
|
24
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* Callback after the message is removed
|
|
46
|
+
*/
|
|
25
47
|
onClose?: (event?: React.MouseEvent<HTMLButtonElement>) => void;
|
|
26
48
|
}
|
|
27
49
|
/**
|
package/esm/Message/Message.js
CHANGED
|
@@ -3,9 +3,9 @@ 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, _templateObject3, _templateObject4, _templateObject5;
|
|
6
|
-
import React, { useState,
|
|
6
|
+
import React, { useState, useContext } from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
|
-
import { useClassNames, useTimeout, MESSAGE_STATUS_ICONS, STATUS, useIsMounted } from '../utils';
|
|
8
|
+
import { useClassNames, useTimeout, MESSAGE_STATUS_ICONS, STATUS, useIsMounted, useEventCallback } from '../utils';
|
|
9
9
|
import { oneOf } from '../internals/propTypes';
|
|
10
10
|
import CloseButton from '../internals/CloseButton';
|
|
11
11
|
import ToastContext from '../toaster/ToastContext';
|
|
@@ -17,6 +17,8 @@ var Message = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
17
17
|
var _withClassPrefix;
|
|
18
18
|
var _props$as = props.as,
|
|
19
19
|
Component = _props$as === void 0 ? 'div' : _props$as,
|
|
20
|
+
bordered = props.bordered,
|
|
21
|
+
centered = props.centered,
|
|
20
22
|
className = props.className,
|
|
21
23
|
_props$classPrefix = props.classPrefix,
|
|
22
24
|
classPrefix = _props$classPrefix === void 0 ? 'message' : _props$classPrefix,
|
|
@@ -30,7 +32,7 @@ var Message = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
30
32
|
type = _props$type === void 0 ? 'info' : _props$type,
|
|
31
33
|
showIcon = props.showIcon,
|
|
32
34
|
onClose = props.onClose,
|
|
33
|
-
rest = _objectWithoutPropertiesLoose(props, ["as", "className", "classPrefix", "children", "closable", "duration", "full", "header", "type", "showIcon", "onClose"]);
|
|
35
|
+
rest = _objectWithoutPropertiesLoose(props, ["as", "bordered", "centered", "className", "classPrefix", "children", "closable", "duration", "full", "header", "type", "showIcon", "onClose"]);
|
|
34
36
|
var _useState = useState('show'),
|
|
35
37
|
display = _useState[0],
|
|
36
38
|
setDisplay = _useState[1];
|
|
@@ -43,7 +45,7 @@ var Message = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
43
45
|
usedToaster = _useContext.usedToaster; // Timed close message
|
|
44
46
|
var _useTimeout = useTimeout(onClose, duration, usedToaster && duration > 0),
|
|
45
47
|
clear = _useTimeout.clear;
|
|
46
|
-
var handleClose =
|
|
48
|
+
var handleClose = useEventCallback(function (event) {
|
|
47
49
|
setDisplay('hiding');
|
|
48
50
|
onClose === null || onClose === void 0 ? void 0 : onClose(event);
|
|
49
51
|
clear();
|
|
@@ -52,12 +54,14 @@ var Message = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
52
54
|
setDisplay('hide');
|
|
53
55
|
}
|
|
54
56
|
}, 1000);
|
|
55
|
-
}
|
|
57
|
+
});
|
|
56
58
|
if (display === 'hide') {
|
|
57
59
|
return null;
|
|
58
60
|
}
|
|
59
61
|
var classes = merge(className, withClassPrefix(type, display, (_withClassPrefix = {
|
|
60
|
-
full: full
|
|
62
|
+
full: full,
|
|
63
|
+
bordered: bordered,
|
|
64
|
+
centered: centered
|
|
61
65
|
}, _withClassPrefix['has-title'] = header, _withClassPrefix['has-icon'] = showIcon, _withClassPrefix)));
|
|
62
66
|
return /*#__PURE__*/React.createElement(Component, _extends({
|
|
63
67
|
role: "alert"
|
|
@@ -69,7 +73,7 @@ var Message = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
69
73
|
}, closable && /*#__PURE__*/React.createElement(CloseButton, {
|
|
70
74
|
onClick: handleClose
|
|
71
75
|
}), showIcon && /*#__PURE__*/React.createElement("div", {
|
|
72
|
-
className: prefix(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["icon
|
|
76
|
+
className: prefix(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["icon"])))
|
|
73
77
|
}, MESSAGE_STATUS_ICONS[type]), /*#__PURE__*/React.createElement("div", {
|
|
74
78
|
className: prefix(_templateObject3 || (_templateObject3 = _taggedTemplateLiteralLoose(["content"])))
|
|
75
79
|
}, header && /*#__PURE__*/React.createElement("div", {
|
|
@@ -80,14 +84,16 @@ var Message = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
80
84
|
});
|
|
81
85
|
Message.displayName = 'Message';
|
|
82
86
|
Message.propTypes = {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
onClose: PropTypes.func,
|
|
87
|
+
bordered: PropTypes.bool,
|
|
88
|
+
centered: PropTypes.bool,
|
|
86
89
|
closable: PropTypes.bool,
|
|
87
|
-
|
|
90
|
+
className: PropTypes.string,
|
|
91
|
+
classPrefix: PropTypes.string,
|
|
88
92
|
description: PropTypes.node,
|
|
89
|
-
showIcon: PropTypes.bool,
|
|
90
93
|
full: PropTypes.bool,
|
|
91
|
-
|
|
94
|
+
onClose: PropTypes.func,
|
|
95
|
+
showIcon: PropTypes.bool,
|
|
96
|
+
title: PropTypes.node,
|
|
97
|
+
type: oneOf(STATUS)
|
|
92
98
|
};
|
|
93
99
|
export default Message;
|
package/esm/Nav/Nav.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ export interface NavProps<T = any> extends WithAsProps, Omit<React.HTMLAttribute
|
|
|
16
16
|
pullRight?: boolean;
|
|
17
17
|
/** Active key, corresponding to eventkey in <Nav.item>. */
|
|
18
18
|
activeKey?: T;
|
|
19
|
+
/** Default active key, corresponding to eventkey in <Nav.item>. */
|
|
20
|
+
defaultActiveKey?: T;
|
|
19
21
|
/** Callback function triggered after selection */
|
|
20
22
|
onSelect?: (eventKey: T | undefined, event: React.SyntheticEvent) => void;
|
|
21
23
|
}
|
package/esm/Nav/Nav.js
CHANGED
|
@@ -4,11 +4,10 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
4
4
|
import React, { useContext, useEffect, useMemo } from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import NavItem from './NavItem';
|
|
7
|
-
import { useClassNames } from '../utils';
|
|
7
|
+
import { useClassNames, useEnsuredRef, useInternalId, useControlled } from '../utils';
|
|
8
8
|
import { NavbarContext } from '../Navbar/Navbar';
|
|
9
9
|
import { SidenavContext } from '../Sidenav/Sidenav';
|
|
10
10
|
import NavContext from './NavContext';
|
|
11
|
-
import useEnsuredRef from '../utils/useEnsuredRef';
|
|
12
11
|
import Menubar from '../internals/Menu/Menubar';
|
|
13
12
|
import { oneOf } from '../internals/propTypes';
|
|
14
13
|
import NavDropdown from './NavDropdown';
|
|
@@ -20,7 +19,6 @@ import NavbarDropdownItem from '../Navbar/NavbarDropdownItem';
|
|
|
20
19
|
import SidenavDropdownItem from '../Sidenav/SidenavDropdownItem';
|
|
21
20
|
import NavbarItem from '../Navbar/NavbarItem';
|
|
22
21
|
import SidenavItem from '../Sidenav/SidenavItem';
|
|
23
|
-
import useInternalId from '../utils/useInternalId';
|
|
24
22
|
/**
|
|
25
23
|
* The `Nav` component is used to create navigation links.
|
|
26
24
|
* @see https://rsuitejs.com/components/nav
|
|
@@ -39,8 +37,9 @@ var Nav = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
39
37
|
className = props.className,
|
|
40
38
|
children = props.children,
|
|
41
39
|
activeKeyProp = props.activeKey,
|
|
40
|
+
defaultActiveKey = props.defaultActiveKey,
|
|
42
41
|
onSelectProp = props.onSelect,
|
|
43
|
-
rest = _objectWithoutPropertiesLoose(props, ["as", "classPrefix", "appearance", "vertical", "justified", "reversed", "pullRight", "className", "children", "activeKey", "onSelect"]);
|
|
42
|
+
rest = _objectWithoutPropertiesLoose(props, ["as", "classPrefix", "appearance", "vertical", "justified", "reversed", "pullRight", "className", "children", "activeKey", "defaultActiveKey", "onSelect"]);
|
|
44
43
|
var sidenav = useContext(SidenavContext);
|
|
45
44
|
|
|
46
45
|
// Whether inside a <Navbar>
|
|
@@ -65,13 +64,19 @@ var Nav = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
65
64
|
activeKeyFromSidenav = _ref.activeKey,
|
|
66
65
|
_ref$onSelect = _ref.onSelect,
|
|
67
66
|
onSelectFromSidenav = _ref$onSelect === void 0 ? onSelectProp : _ref$onSelect;
|
|
68
|
-
var
|
|
67
|
+
var _useControlled = useControlled(activeKeyProp !== null && activeKeyProp !== void 0 ? activeKeyProp : activeKeyFromSidenav, defaultActiveKey),
|
|
68
|
+
activeKey = _useControlled[0],
|
|
69
|
+
setActiveKey = _useControlled[1];
|
|
69
70
|
var contextValue = useMemo(function () {
|
|
70
71
|
return {
|
|
71
72
|
activeKey: activeKey,
|
|
72
|
-
onSelect:
|
|
73
|
+
onSelect: function onSelect(eventKey, event) {
|
|
74
|
+
setActiveKey(eventKey);
|
|
75
|
+
onSelectProp === null || onSelectProp === void 0 ? void 0 : onSelectProp(eventKey, event);
|
|
76
|
+
onSelectFromSidenav === null || onSelectFromSidenav === void 0 ? void 0 : onSelectFromSidenav(eventKey, event);
|
|
77
|
+
}
|
|
73
78
|
};
|
|
74
|
-
}, [activeKey, onSelectFromSidenav, onSelectProp]);
|
|
79
|
+
}, [activeKey, onSelectFromSidenav, onSelectProp, setActiveKey]);
|
|
75
80
|
if (sidenav !== null && sidenav !== void 0 && sidenav.expanded) {
|
|
76
81
|
return /*#__PURE__*/React.createElement(NavContext.Provider, {
|
|
77
82
|
value: contextValue
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface TabProps {
|
|
3
|
+
/**
|
|
4
|
+
* The children of the tab.
|
|
5
|
+
*/
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
/**
|
|
8
|
+
* The disabled state of the tab.
|
|
9
|
+
*/
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* The event key of the tab.
|
|
13
|
+
*/
|
|
14
|
+
eventKey?: string;
|
|
15
|
+
/**
|
|
16
|
+
* The icon of the tab.
|
|
17
|
+
*/
|
|
18
|
+
icon?: React.ReactNode;
|
|
19
|
+
/**
|
|
20
|
+
* Content for the tab title.
|
|
21
|
+
*/
|
|
22
|
+
title: React.ReactNode;
|
|
23
|
+
}
|
|
24
|
+
declare const Tab: React.FC<TabProps>;
|
|
25
|
+
export default Tab;
|
package/esm/Tabs/Tab.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
var Tab = function Tab() {
|
|
5
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
6
|
+
};
|
|
7
|
+
Tab.displayName = 'Tab';
|
|
8
|
+
Tab.propTypes = {
|
|
9
|
+
disabled: PropTypes.bool,
|
|
10
|
+
eventKey: PropTypes.string,
|
|
11
|
+
title: PropTypes.node,
|
|
12
|
+
children: PropTypes.node,
|
|
13
|
+
icon: PropTypes.node
|
|
14
|
+
};
|
|
15
|
+
export default Tab;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { WithAsProps } from '../@types/common';
|
|
3
|
+
interface TabPanelProps extends WithAsProps {
|
|
4
|
+
/** The active state of the tab. */
|
|
5
|
+
active?: boolean;
|
|
6
|
+
/** The HTML id attribute, which should be unique. */
|
|
7
|
+
id?: string;
|
|
8
|
+
}
|
|
9
|
+
declare const TabPanel: React.ForwardRefExoticComponent<TabPanelProps & React.RefAttributes<HTMLDivElement>>;
|
|
10
|
+
export default TabPanel;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { useClassNames } from '../utils';
|
|
6
|
+
var TabPanel = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
7
|
+
var _props$as = props.as,
|
|
8
|
+
Component = _props$as === void 0 ? 'div' : _props$as,
|
|
9
|
+
_props$classPrefix = props.classPrefix,
|
|
10
|
+
classPrefix = _props$classPrefix === void 0 ? 'tab-panel' : _props$classPrefix,
|
|
11
|
+
children = props.children,
|
|
12
|
+
active = props.active,
|
|
13
|
+
className = props.className,
|
|
14
|
+
rest = _objectWithoutPropertiesLoose(props, ["as", "classPrefix", "children", "active", "className"]);
|
|
15
|
+
var _useClassNames = useClassNames(classPrefix),
|
|
16
|
+
withClassPrefix = _useClassNames.withClassPrefix,
|
|
17
|
+
merge = _useClassNames.merge;
|
|
18
|
+
return /*#__PURE__*/React.createElement(Component, _extends({
|
|
19
|
+
role: "tabpanel",
|
|
20
|
+
ref: ref,
|
|
21
|
+
tabIndex: 0,
|
|
22
|
+
hidden: !active,
|
|
23
|
+
className: merge(className, withClassPrefix())
|
|
24
|
+
}, rest), children);
|
|
25
|
+
});
|
|
26
|
+
TabPanel.displayName = 'TabPanel';
|
|
27
|
+
export default TabPanel;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { WithAsProps, RsRefForwardingComponent } from '../@types/common';
|
|
3
|
+
import Tab from './Tab';
|
|
4
|
+
export interface TabsProps extends WithAsProps {
|
|
5
|
+
/**
|
|
6
|
+
* The tabs appearance style.
|
|
7
|
+
*/
|
|
8
|
+
appearance?: 'tabs' | 'subtle';
|
|
9
|
+
/**
|
|
10
|
+
* Mark the Tab with a matching `eventKey` as active.
|
|
11
|
+
*/
|
|
12
|
+
activeKey?: string;
|
|
13
|
+
/**
|
|
14
|
+
* The default active tabKey.
|
|
15
|
+
*/
|
|
16
|
+
defaultActiveKey?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Reversed display.
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
reversed?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Vertical display.
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
vertical?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* The HTML id attribute, which should be unique.
|
|
29
|
+
* @default use generated id
|
|
30
|
+
*/
|
|
31
|
+
id?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Callback fired when a Tab is selected.
|
|
34
|
+
* @param eventKey
|
|
35
|
+
* @param event
|
|
36
|
+
* @returns
|
|
37
|
+
*/
|
|
38
|
+
onSelect?: (eventKey: string, event: React.MouseEvent) => void;
|
|
39
|
+
}
|
|
40
|
+
interface TabsComponent extends RsRefForwardingComponent<'div', TabsProps> {
|
|
41
|
+
Tab: typeof Tab;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Tabs are a set of layered sections of content, known as tab panels, that display one panel of content at a time.
|
|
45
|
+
*
|
|
46
|
+
* @version 5.53.0
|
|
47
|
+
* @see https://rsuitejs.com/components/tabs
|
|
48
|
+
*/
|
|
49
|
+
declare const Tabs: TabsComponent;
|
|
50
|
+
export default Tabs;
|
package/esm/Tabs/Tabs.js
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
import _taggedTemplateLiteralLoose from "@babel/runtime/helpers/esm/taggedTemplateLiteralLoose";
|
|
4
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
+
var _templateObject;
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { useClassNames, useControlled, ReactChildren, useEventCallback, useUniqueId, useCustom } from '../utils';
|
|
9
|
+
import Nav from '../Nav';
|
|
10
|
+
import Tab from './Tab';
|
|
11
|
+
import TabPanel from './TabPanel';
|
|
12
|
+
function getFocusableTabs(tablist) {
|
|
13
|
+
var tabs = tablist === null || tablist === void 0 ? void 0 : tablist.querySelectorAll('[role=tab]');
|
|
14
|
+
return Array.from(tabs).filter(function (tab) {
|
|
15
|
+
return !(tab.getAttribute('aria-disabled') === 'true');
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function getFocusedTab(tablist) {
|
|
19
|
+
var tabs = getFocusableTabs(tablist);
|
|
20
|
+
return tabs.find(function (tab) {
|
|
21
|
+
return tab.getAttribute('aria-selected');
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function nextItem(tablist) {
|
|
25
|
+
if (!tablist) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
var item = getFocusedTab(tablist);
|
|
29
|
+
var items = getFocusableTabs(tablist);
|
|
30
|
+
if (!item) {
|
|
31
|
+
return items[0];
|
|
32
|
+
}
|
|
33
|
+
var nextItem = items[items.indexOf(item) + 1];
|
|
34
|
+
if (!nextItem || nextItem.getAttribute('role') !== 'tab') {
|
|
35
|
+
return items[0];
|
|
36
|
+
}
|
|
37
|
+
return nextItem;
|
|
38
|
+
}
|
|
39
|
+
function previousItem(tablist) {
|
|
40
|
+
if (!tablist) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
var item = getFocusedTab(tablist);
|
|
44
|
+
var items = getFocusableTabs(tablist);
|
|
45
|
+
if (!item) {
|
|
46
|
+
return items[items.length - 1];
|
|
47
|
+
}
|
|
48
|
+
var previousItem = items[items.indexOf(item) - 1];
|
|
49
|
+
if (!previousItem || previousItem.getAttribute('role') !== 'tab') {
|
|
50
|
+
return items[items.length - 1];
|
|
51
|
+
}
|
|
52
|
+
return previousItem;
|
|
53
|
+
}
|
|
54
|
+
var renderPanels = function renderPanels(children, tabProps) {
|
|
55
|
+
var id = tabProps.id,
|
|
56
|
+
activeKey = tabProps.activeKey;
|
|
57
|
+
return ReactChildren.map(children, function (child) {
|
|
58
|
+
var _child$props = child.props,
|
|
59
|
+
eventKey = _child$props.eventKey,
|
|
60
|
+
children = _child$props.children;
|
|
61
|
+
var selected = eventKey === activeKey;
|
|
62
|
+
return /*#__PURE__*/React.createElement(TabPanel, {
|
|
63
|
+
"aria-labelledby": id + "-" + eventKey,
|
|
64
|
+
"aria-hidden": !selected,
|
|
65
|
+
id: id + "-panel-" + eventKey,
|
|
66
|
+
active: selected
|
|
67
|
+
}, children);
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
var renderTabs = function renderTabs(children, tabPanelProps) {
|
|
71
|
+
var id = tabPanelProps.id,
|
|
72
|
+
activeKey = tabPanelProps.activeKey;
|
|
73
|
+
return ReactChildren.map(children, function (child) {
|
|
74
|
+
var _child$props2 = child.props,
|
|
75
|
+
eventKey = _child$props2.eventKey,
|
|
76
|
+
title = _child$props2.title,
|
|
77
|
+
disabled = _child$props2.disabled,
|
|
78
|
+
icon = _child$props2.icon;
|
|
79
|
+
var selected = eventKey === activeKey;
|
|
80
|
+
return /*#__PURE__*/React.createElement(Nav.Item, {
|
|
81
|
+
role: "tab",
|
|
82
|
+
as: "button",
|
|
83
|
+
type: "button",
|
|
84
|
+
"aria-selected": selected,
|
|
85
|
+
"aria-controls": id + "-panel-" + eventKey,
|
|
86
|
+
"aria-disabled": disabled,
|
|
87
|
+
"data-event-key": eventKey,
|
|
88
|
+
disabled: disabled,
|
|
89
|
+
icon: icon,
|
|
90
|
+
id: id + "-" + eventKey,
|
|
91
|
+
tabIndex: selected ? undefined : -1,
|
|
92
|
+
eventKey: eventKey
|
|
93
|
+
}, title);
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Tabs are a set of layered sections of content, known as tab panels, that display one panel of content at a time.
|
|
99
|
+
*
|
|
100
|
+
* @version 5.53.0
|
|
101
|
+
* @see https://rsuitejs.com/components/tabs
|
|
102
|
+
*/
|
|
103
|
+
var Tabs = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
104
|
+
var _props$as = props.as,
|
|
105
|
+
Component = _props$as === void 0 ? 'div' : _props$as,
|
|
106
|
+
_props$classPrefix = props.classPrefix,
|
|
107
|
+
classPrefix = _props$classPrefix === void 0 ? 'tabs' : _props$classPrefix,
|
|
108
|
+
_props$appearance = props.appearance,
|
|
109
|
+
appearance = _props$appearance === void 0 ? 'tabs' : _props$appearance,
|
|
110
|
+
className = props.className,
|
|
111
|
+
children = props.children,
|
|
112
|
+
activeKeyProp = props.activeKey,
|
|
113
|
+
defaultActiveKey = props.defaultActiveKey,
|
|
114
|
+
idProp = props.id,
|
|
115
|
+
reversed = props.reversed,
|
|
116
|
+
vertical = props.vertical,
|
|
117
|
+
onSelect = props.onSelect,
|
|
118
|
+
rest = _objectWithoutPropertiesLoose(props, ["as", "classPrefix", "appearance", "className", "children", "activeKey", "defaultActiveKey", "id", "reversed", "vertical", "onSelect"]);
|
|
119
|
+
var id = useUniqueId('tab-', idProp);
|
|
120
|
+
var _useCustom = useCustom(),
|
|
121
|
+
rtl = _useCustom.rtl;
|
|
122
|
+
var _useControlled = useControlled(activeKeyProp, defaultActiveKey),
|
|
123
|
+
activeKey = _useControlled[0],
|
|
124
|
+
setActiveKey = _useControlled[1];
|
|
125
|
+
var _useClassNames = useClassNames(classPrefix),
|
|
126
|
+
withClassPrefix = _useClassNames.withClassPrefix,
|
|
127
|
+
prefix = _useClassNames.prefix,
|
|
128
|
+
merge = _useClassNames.merge;
|
|
129
|
+
var tablistRef = React.useRef(null);
|
|
130
|
+
var handleSelect = useEventCallback(function (eventKey, event) {
|
|
131
|
+
setActiveKey(eventKey);
|
|
132
|
+
onSelect === null || onSelect === void 0 ? void 0 : onSelect(eventKey, event);
|
|
133
|
+
});
|
|
134
|
+
var handleKeyDown = useEventCallback(function (event) {
|
|
135
|
+
var _getFocusableTabs;
|
|
136
|
+
var target = event.target;
|
|
137
|
+
if (target.getAttribute('role') !== 'tab') {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
var previousItemKey = vertical ? 'ArrowUp' : 'ArrowLeft';
|
|
141
|
+
var nextItemKey = vertical ? 'ArrowDown' : 'ArrowRight';
|
|
142
|
+
if (!vertical && rtl) {
|
|
143
|
+
previousItemKey = 'ArrowRight';
|
|
144
|
+
nextItemKey = 'ArrowLeft';
|
|
145
|
+
}
|
|
146
|
+
var item = null;
|
|
147
|
+
switch (event.key) {
|
|
148
|
+
case previousItemKey:
|
|
149
|
+
item = previousItem(tablistRef.current);
|
|
150
|
+
event.preventDefault();
|
|
151
|
+
break;
|
|
152
|
+
case nextItemKey:
|
|
153
|
+
item = nextItem(tablistRef.current);
|
|
154
|
+
event.preventDefault();
|
|
155
|
+
break;
|
|
156
|
+
case 'Home':
|
|
157
|
+
item = (_getFocusableTabs = getFocusableTabs(tablistRef.current)) === null || _getFocusableTabs === void 0 ? void 0 : _getFocusableTabs[0];
|
|
158
|
+
event.preventDefault();
|
|
159
|
+
break;
|
|
160
|
+
case 'End':
|
|
161
|
+
var tabs = getFocusableTabs(tablistRef.current);
|
|
162
|
+
item = tabs[tabs.length - 1];
|
|
163
|
+
event.preventDefault();
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
if (item) {
|
|
167
|
+
var _item;
|
|
168
|
+
var _item$dataset = (_item = item) === null || _item === void 0 ? void 0 : _item.dataset,
|
|
169
|
+
_eventKey = _item$dataset.eventKey;
|
|
170
|
+
handleSelect(_eventKey, event);
|
|
171
|
+
item.focus();
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
return /*#__PURE__*/React.createElement(Component, _extends({
|
|
175
|
+
className: merge(className, withClassPrefix({
|
|
176
|
+
reversed: reversed,
|
|
177
|
+
vertical: vertical
|
|
178
|
+
}))
|
|
179
|
+
}, rest, {
|
|
180
|
+
ref: ref
|
|
181
|
+
}), /*#__PURE__*/React.createElement(Nav, {
|
|
182
|
+
role: "tablist",
|
|
183
|
+
"aria-orientation": vertical ? 'vertical' : 'horizontal',
|
|
184
|
+
reversed: reversed,
|
|
185
|
+
vertical: vertical,
|
|
186
|
+
appearance: appearance,
|
|
187
|
+
activeKey: activeKey,
|
|
188
|
+
onSelect: handleSelect,
|
|
189
|
+
onKeyDown: handleKeyDown,
|
|
190
|
+
ref: tablistRef
|
|
191
|
+
}, renderTabs(children, {
|
|
192
|
+
id: id,
|
|
193
|
+
activeKey: activeKey
|
|
194
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
195
|
+
className: prefix(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["content"])))
|
|
196
|
+
}, renderPanels(children, {
|
|
197
|
+
id: id,
|
|
198
|
+
activeKey: activeKey
|
|
199
|
+
})));
|
|
200
|
+
});
|
|
201
|
+
Tabs.Tab = Tab;
|
|
202
|
+
Tabs.displayName = 'Tabs';
|
|
203
|
+
Tabs.propTypes = {
|
|
204
|
+
appearance: PropTypes.oneOf(['tabs', 'subtle']),
|
|
205
|
+
activeKey: PropTypes.any,
|
|
206
|
+
defaultActiveKey: PropTypes.any,
|
|
207
|
+
reversed: PropTypes.bool,
|
|
208
|
+
vertical: PropTypes.bool,
|
|
209
|
+
id: PropTypes.string,
|
|
210
|
+
className: PropTypes.string,
|
|
211
|
+
classPrefix: PropTypes.string,
|
|
212
|
+
children: PropTypes.node,
|
|
213
|
+
onSelect: PropTypes.func
|
|
214
|
+
};
|
|
215
|
+
export default Tabs;
|
package/esm/index.d.ts
CHANGED
|
@@ -118,6 +118,8 @@ export { default as Accordion } from './Accordion';
|
|
|
118
118
|
export type { AccordionProps } from './Accordion';
|
|
119
119
|
export { default as PanelGroup } from './PanelGroup';
|
|
120
120
|
export type { PanelGroupProps } from './PanelGroup';
|
|
121
|
+
export { default as Tabs } from './Tabs';
|
|
122
|
+
export type { TabsProps } from './Tabs';
|
|
121
123
|
export { default as Table } from './Table';
|
|
122
124
|
export type { TableProps, ColumnProps, ColumnGroupProps, CellProps, TableLocaleType } from './Table';
|
|
123
125
|
export { default as Progress } from './Progress';
|
package/esm/index.js
CHANGED
|
@@ -63,6 +63,7 @@ export { default as CheckTree } from './CheckTree';
|
|
|
63
63
|
export { default as Panel } from './Panel';
|
|
64
64
|
export { default as Accordion } from './Accordion';
|
|
65
65
|
export { default as PanelGroup } from './PanelGroup';
|
|
66
|
+
export { default as Tabs } from './Tabs';
|
|
66
67
|
export { default as Table } from './Table';
|
|
67
68
|
export { default as Progress } from './Progress';
|
|
68
69
|
export { default as Timeline } from './Timeline';
|