rsuite 5.67.0 → 5.68.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/Nav/styles/index.css +68 -0
- package/Nav/styles/index.less +37 -0
- package/Tabs/styles/index.css +68 -3
- package/Tabs/styles/index.less +0 -4
- package/cjs/CheckTree/utils.d.ts +1 -1
- package/cjs/CheckTree/utils.js +1 -1
- package/cjs/DateInput/DateInput.js +18 -2
- package/cjs/DateInput/hooks/useDateInputState.d.ts +1 -0
- package/cjs/DateInput/hooks/useDateInputState.js +10 -9
- package/cjs/DateInput/hooks/useKeyboardInputEvent.js +5 -0
- package/cjs/DateRangeInput/DateRangeInput.js +24 -2
- package/cjs/Form/Form.js +4 -10
- package/cjs/Form/FormContext.d.ts +2 -4
- package/cjs/Form/hooks/useFormValidate.d.ts +2 -2
- package/cjs/Form/hooks/useFormValidate.js +99 -35
- package/cjs/FormControl/FormControl.js +6 -22
- package/cjs/Nav/AdaptiveNavItem.d.ts +1 -1
- package/cjs/Nav/Nav.d.ts +28 -9
- package/cjs/Nav/Nav.js +1 -1
- package/cjs/Nav/NavContext.d.ts +2 -2
- package/cjs/Nav/NavItem.d.ts +1 -1
- package/cjs/Navbar/NavbarItem.d.ts +1 -1
- package/cjs/Sidenav/Sidenav.d.ts +3 -3
- package/cjs/Tabs/Tabs.d.ts +20 -17
- package/cjs/Tabs/Tabs.js +5 -1
- package/cjs/internals/Overlay/OverlayTrigger.d.ts +2 -2
- package/cjs/internals/Overlay/OverlayTrigger.js +17 -8
- package/cjs/internals/utils/BrowserDetection.js +6 -0
- package/cjs/internals/utils/ReactChildren.d.ts +6 -0
- package/cjs/internals/utils/ReactChildren.js +1 -0
- package/dist/rsuite-no-reset-rtl.css +65 -3
- 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 +65 -3
- package/dist/rsuite-no-reset.min.css +1 -1
- package/dist/rsuite-no-reset.min.css.map +1 -1
- package/dist/rsuite-rtl.css +65 -3
- package/dist/rsuite-rtl.min.css +1 -1
- package/dist/rsuite-rtl.min.css.map +1 -1
- package/dist/rsuite.css +65 -3
- package/dist/rsuite.js +13 -13
- 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/CheckTree/utils.d.ts +1 -1
- package/esm/CheckTree/utils.js +1 -1
- package/esm/DateInput/DateInput.js +18 -2
- package/esm/DateInput/hooks/useDateInputState.d.ts +1 -0
- package/esm/DateInput/hooks/useDateInputState.js +11 -10
- package/esm/DateInput/hooks/useKeyboardInputEvent.js +5 -0
- package/esm/DateRangeInput/DateRangeInput.js +24 -2
- package/esm/Form/Form.js +4 -10
- package/esm/Form/FormContext.d.ts +2 -4
- package/esm/Form/hooks/useFormValidate.d.ts +2 -2
- package/esm/Form/hooks/useFormValidate.js +98 -34
- package/esm/FormControl/FormControl.js +6 -22
- package/esm/Nav/AdaptiveNavItem.d.ts +1 -1
- package/esm/Nav/Nav.d.ts +28 -9
- package/esm/Nav/Nav.js +1 -1
- package/esm/Nav/NavContext.d.ts +2 -2
- package/esm/Nav/NavItem.d.ts +1 -1
- package/esm/Navbar/NavbarItem.d.ts +1 -1
- package/esm/Sidenav/Sidenav.d.ts +3 -3
- package/esm/Tabs/Tabs.d.ts +20 -17
- package/esm/Tabs/Tabs.js +6 -1
- package/esm/internals/Overlay/OverlayTrigger.d.ts +2 -2
- package/esm/internals/Overlay/OverlayTrigger.js +18 -9
- package/esm/internals/utils/BrowserDetection.js +6 -0
- package/esm/internals/utils/ReactChildren.d.ts +6 -0
- package/esm/internals/utils/ReactChildren.js +1 -1
- package/package.json +1 -1
- package/styles/color-modes/dark.less +7 -0
- package/styles/color-modes/high-contrast.less +7 -0
- package/styles/color-modes/light.less +8 -0
- package/styles/plugins/palette.js +34 -6
package/esm/Sidenav/Sidenav.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import SidenavBody from './SidenavBody';
|
|
|
3
3
|
import SidenavHeader from './SidenavHeader';
|
|
4
4
|
import SidenavToggle from './SidenavToggle';
|
|
5
5
|
import { WithAsProps, RsRefForwardingComponent } from '../internals/types';
|
|
6
|
-
export interface SidenavProps<T = string> extends WithAsProps {
|
|
6
|
+
export interface SidenavProps<T = string | number> extends WithAsProps {
|
|
7
7
|
/** Whether to expand the Sidenav */
|
|
8
8
|
expanded?: boolean;
|
|
9
9
|
/** Menu style */
|
|
@@ -25,8 +25,8 @@ export interface SidenavProps<T = string> extends WithAsProps {
|
|
|
25
25
|
*/
|
|
26
26
|
onSelect?: (eventKey: T | undefined, event: React.SyntheticEvent) => void;
|
|
27
27
|
}
|
|
28
|
-
export declare const SidenavContext: React.Context<SidenavContextType<string> | null>;
|
|
29
|
-
export interface SidenavContextType<T = string> {
|
|
28
|
+
export declare const SidenavContext: React.Context<SidenavContextType<string | number> | null>;
|
|
29
|
+
export interface SidenavContextType<T = string | number> {
|
|
30
30
|
openKeys: T[];
|
|
31
31
|
/**
|
|
32
32
|
* @deprecated Use activeKey from NavContext instead
|
package/esm/Tabs/Tabs.d.ts
CHANGED
|
@@ -1,41 +1,44 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { WithAsProps, RsRefForwardingComponent } from '../internals/types';
|
|
3
3
|
import Tab from './Tab';
|
|
4
|
+
/**
|
|
5
|
+
* Props for the Tabs component.
|
|
6
|
+
*/
|
|
4
7
|
export interface TabsProps extends WithAsProps {
|
|
5
8
|
/**
|
|
6
|
-
* The
|
|
9
|
+
* The appearance of the tabs.
|
|
10
|
+
* @default 'tabs'
|
|
11
|
+
* @version 'pills' is supported in version 5.68.0
|
|
7
12
|
*/
|
|
8
|
-
appearance?: 'tabs' | 'subtle';
|
|
13
|
+
appearance?: 'tabs' | 'subtle' | 'pills';
|
|
9
14
|
/**
|
|
10
|
-
*
|
|
15
|
+
* The key of the active tab.
|
|
11
16
|
*/
|
|
12
|
-
activeKey?: string;
|
|
17
|
+
activeKey?: string | number;
|
|
13
18
|
/**
|
|
14
|
-
* The default active
|
|
19
|
+
* The default key of the active tab.
|
|
15
20
|
*/
|
|
16
|
-
defaultActiveKey?: string;
|
|
21
|
+
defaultActiveKey?: string | number;
|
|
17
22
|
/**
|
|
18
|
-
*
|
|
19
|
-
* @default false
|
|
23
|
+
* Whether to reverse the order of the tabs.
|
|
20
24
|
*/
|
|
21
25
|
reversed?: boolean;
|
|
22
26
|
/**
|
|
23
|
-
*
|
|
24
|
-
* @default false
|
|
27
|
+
* Whether to display the tabs vertically.
|
|
25
28
|
*/
|
|
26
29
|
vertical?: boolean;
|
|
27
30
|
/**
|
|
28
|
-
* The
|
|
29
|
-
* @default
|
|
31
|
+
* The ID of the tabs.
|
|
32
|
+
* @default A unique ID is automatically generated.
|
|
30
33
|
*/
|
|
31
34
|
id?: string;
|
|
32
35
|
/**
|
|
33
|
-
* Callback
|
|
34
|
-
*
|
|
35
|
-
* @param
|
|
36
|
-
* @
|
|
36
|
+
* Callback function that is called when a tab is selected.
|
|
37
|
+
*
|
|
38
|
+
* @param eventKey - The key of the selected tab.
|
|
39
|
+
* @param event - The event object.
|
|
37
40
|
*/
|
|
38
|
-
onSelect?: (eventKey: string | undefined, event: React.SyntheticEvent) => void;
|
|
41
|
+
onSelect?: (eventKey: string | number | undefined, event: React.SyntheticEvent) => void;
|
|
39
42
|
}
|
|
40
43
|
interface TabsComponent extends RsRefForwardingComponent<'div', TabsProps> {
|
|
41
44
|
Tab: typeof Tab;
|
package/esm/Tabs/Tabs.js
CHANGED
|
@@ -11,6 +11,11 @@ import { ReactChildren } from "../internals/utils/index.js";
|
|
|
11
11
|
import Nav from "../Nav/index.js";
|
|
12
12
|
import Tab from "./Tab.js";
|
|
13
13
|
import TabPanel from "./TabPanel.js";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Props for the Tabs component.
|
|
17
|
+
*/
|
|
18
|
+
|
|
14
19
|
function getFocusableTabs(tablist) {
|
|
15
20
|
var tabs = tablist === null || tablist === void 0 ? void 0 : tablist.querySelectorAll('[role=tab]');
|
|
16
21
|
return Array.from(tabs).filter(function (tab) {
|
|
@@ -203,7 +208,7 @@ var Tabs = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
203
208
|
Tabs.Tab = Tab;
|
|
204
209
|
Tabs.displayName = 'Tabs';
|
|
205
210
|
Tabs.propTypes = {
|
|
206
|
-
appearance: PropTypes.oneOf(['tabs', 'subtle']),
|
|
211
|
+
appearance: PropTypes.oneOf(['tabs', 'subtle', 'pills']),
|
|
207
212
|
activeKey: PropTypes.any,
|
|
208
213
|
defaultActiveKey: PropTypes.any,
|
|
209
214
|
reversed: PropTypes.bool,
|
|
@@ -31,7 +31,7 @@ export interface OverlayTriggerProps extends Omit<StandardProps, 'children'>, An
|
|
|
31
31
|
/** Whether mouse is allowed to enter the floating layer of popover, whose default value is false. */
|
|
32
32
|
enterable?: boolean;
|
|
33
33
|
/** For the monitored component, the event will be bound to this component. */
|
|
34
|
-
children: React.
|
|
34
|
+
children: React.ReactNode | ((props: any, ref: any) => React.ReactElement);
|
|
35
35
|
/** Whether to allow clicking document to close the overlay */
|
|
36
36
|
rootClose?: boolean;
|
|
37
37
|
/** Once disabled, the event cannot be triggered. */
|
|
@@ -73,7 +73,7 @@ export declare enum OverlayCloseCause {
|
|
|
73
73
|
ImperativeHandle = 1
|
|
74
74
|
}
|
|
75
75
|
export interface OverlayTriggerHandle {
|
|
76
|
-
root
|
|
76
|
+
root?: HTMLElement | null;
|
|
77
77
|
updatePosition: () => void;
|
|
78
78
|
open: (delay?: number) => void;
|
|
79
79
|
close: (delay?: number) => void;
|
|
@@ -3,13 +3,14 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
3
3
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
4
4
|
import _isUndefined from "lodash/isUndefined";
|
|
5
5
|
var _excluded = ["children", "container", "controlId", "defaultOpen", "trigger", "disabled", "followCursor", "readOnly", "plaintext", "open", "delay", "delayOpen", "delayClose", "enterable", "placement", "speaker", "rootClose", "onClick", "onMouseOver", "onMouseMove", "onMouseOut", "onContextMenu", "onFocus", "onBlur", "onOpen", "onClose", "onExited"];
|
|
6
|
-
import React, { useRef, useEffect, useImperativeHandle, useCallback, useContext, useState, useMemo } from 'react';
|
|
6
|
+
import React, { useRef, useEffect, useImperativeHandle, useCallback, useContext, useState, useMemo, isValidElement, cloneElement } from 'react';
|
|
7
7
|
import get from 'lodash/get';
|
|
8
8
|
import isNil from 'lodash/isNil';
|
|
9
9
|
import contains from 'dom-lib/contains';
|
|
10
10
|
import Overlay from "./Overlay.js";
|
|
11
11
|
import { usePortal, useControlled } from "../hooks/index.js";
|
|
12
12
|
import { createChainedFunction, isOneOf } from "../utils/index.js";
|
|
13
|
+
import { isFragment } from "../utils/ReactChildren.js";
|
|
13
14
|
import OverlayContext from "./OverlayContext.js";
|
|
14
15
|
function mergeEvents(events, props) {
|
|
15
16
|
if (events === void 0) {
|
|
@@ -98,7 +99,7 @@ var OverlayTrigger = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
98
99
|
}),
|
|
99
100
|
Portal = _usePortal.Portal,
|
|
100
101
|
containerElement = _usePortal.target;
|
|
101
|
-
var triggerRef = useRef();
|
|
102
|
+
var triggerRef = useRef(null);
|
|
102
103
|
var overlayRef = useRef();
|
|
103
104
|
var _useControlled = useControlled(openProp, defaultOpen),
|
|
104
105
|
open = _useControlled[0],
|
|
@@ -361,13 +362,21 @@ var OverlayTrigger = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
361
362
|
}), ref);
|
|
362
363
|
} : speaker);
|
|
363
364
|
};
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
365
|
+
var triggerElement = useMemo(function () {
|
|
366
|
+
if (typeof children === 'function') {
|
|
367
|
+
return children(triggerEvents, triggerRef);
|
|
368
|
+
} else if (isFragment(children) || ! /*#__PURE__*/isValidElement(children)) {
|
|
369
|
+
return /*#__PURE__*/React.createElement("span", _extends({
|
|
370
|
+
ref: triggerRef,
|
|
371
|
+
"aria-describedby": controlId
|
|
372
|
+
}, triggerEvents), children);
|
|
373
|
+
}
|
|
374
|
+
return /*#__PURE__*/cloneElement(children, _extends({
|
|
375
|
+
ref: triggerRef,
|
|
376
|
+
'aria-describedby': controlId
|
|
377
|
+
}, mergeEvents(triggerEvents, children.props)));
|
|
378
|
+
}, [children, controlId, triggerEvents]);
|
|
379
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, triggerElement, /*#__PURE__*/React.createElement(Portal, null, renderOverlay()));
|
|
371
380
|
});
|
|
372
381
|
OverlayTrigger.displayName = 'OverlayTrigger';
|
|
373
382
|
export default OverlayTrigger;
|
|
@@ -41,6 +41,12 @@ export var getSafariVersion = function getSafariVersion() {
|
|
|
41
41
|
* @see https://caniuse.com/flexbox-gap
|
|
42
42
|
*/
|
|
43
43
|
export var isSupportFlexGap = function isSupportFlexGap() {
|
|
44
|
+
// Check if the browser supports the `gap` property
|
|
45
|
+
if (typeof CSS !== 'undefined' && typeof CSS.supports !== 'undefined') {
|
|
46
|
+
return CSS.supports('(gap: 1px)');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// IE does not support flex-gap
|
|
44
50
|
if (isIE()) {
|
|
45
51
|
return false;
|
|
46
52
|
}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Checks if the given children is a React fragment.
|
|
4
|
+
* @param children - The children to check.
|
|
5
|
+
* @returns True if the children is a React fragment, false otherwise.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isFragment(children: React.ReactNode): boolean;
|
|
2
8
|
/**
|
|
3
9
|
* Finds the first child that satisfies the given condition.
|
|
4
10
|
* @param children - The children to search.
|
|
@@ -18,7 +18,7 @@ function typeOf(object) {
|
|
|
18
18
|
* @param children - The children to check.
|
|
19
19
|
* @returns True if the children is a React fragment, false otherwise.
|
|
20
20
|
*/
|
|
21
|
-
function isFragment(children) {
|
|
21
|
+
export function isFragment(children) {
|
|
22
22
|
return React.Children.count(children) === 1 && typeOf(children) === Symbol.for('react.fragment');
|
|
23
23
|
}
|
|
24
24
|
|
package/package.json
CHANGED
|
@@ -201,6 +201,13 @@
|
|
|
201
201
|
--rs-navs-subtle-border: var(--rs-gray-600);
|
|
202
202
|
--rs-navs-selected: var(--rs-primary-500);
|
|
203
203
|
|
|
204
|
+
// Nav Pills
|
|
205
|
+
--rs-navs-pills-bg: var(--rs-gray-700);
|
|
206
|
+
--rs-navs-pills-item-color: var(--rs-text-secondary);
|
|
207
|
+
--rs-navs-pills-item-active-bg: var(--rs-gray-600);
|
|
208
|
+
--rs-navs-pills-item-active-color: var(--rs-gray-0);
|
|
209
|
+
--rs-navs-pills-item-disabled-color: var(--rs-gray-400);
|
|
210
|
+
|
|
204
211
|
// Navbar
|
|
205
212
|
--rs-navbar-default-bg: var(--rs-gray-800);
|
|
206
213
|
--rs-navbar-default-text: var(--rs-gray-200);
|
|
@@ -206,6 +206,13 @@
|
|
|
206
206
|
--rs-navs-subtle-border: var(--rs-gray-600);
|
|
207
207
|
--rs-navs-selected: var(--rs-primary-500);
|
|
208
208
|
|
|
209
|
+
// Nav Pills
|
|
210
|
+
--rs-navs-pills-bg: var(--rs-gray-700);
|
|
211
|
+
--rs-navs-pills-item-color: var(--rs-text-secondary);
|
|
212
|
+
--rs-navs-pills-item-active-bg: var(--rs-gray-600);
|
|
213
|
+
--rs-navs-pills-item-active-color: var(--rs-primary-500);
|
|
214
|
+
--rs-navs-pills-item-disabled-color: var(--rs-gray-400);
|
|
215
|
+
|
|
209
216
|
// Navbar
|
|
210
217
|
--rs-navbar-default-bg: var(--rs-gray-800);
|
|
211
218
|
--rs-navbar-default-text: var(--rs-gray-50);
|
|
@@ -220,6 +220,14 @@
|
|
|
220
220
|
--rs-navs-subtle-border: var(--rs-gray-50);
|
|
221
221
|
--rs-navs-selected: var(--rs-primary-700);
|
|
222
222
|
|
|
223
|
+
// Nav Pills
|
|
224
|
+
--rs-navs-pills-bg: var(--rs-gray-100);
|
|
225
|
+
--rs-navs-pills-item-color: var(--rs-text-secondary);
|
|
226
|
+
--rs-navs-pills-item-active-bg: var(--rs-gray-0);
|
|
227
|
+
--rs-navs-pills-item-active-color: var(--rs-gray-900);
|
|
228
|
+
--rs-navs-pills-item-disabled-color: var(--rs-gray-400);
|
|
229
|
+
--rs-navs-pills-item-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
|
|
230
|
+
|
|
223
231
|
// Navbar
|
|
224
232
|
--rs-navbar-default-bg: var(--rs-gray-50);
|
|
225
233
|
--rs-navbar-default-text: var(--rs-gray-800);
|
|
@@ -1345,7 +1345,39 @@ function calculateBrightness(originalBrightness, index) {
|
|
|
1345
1345
|
);
|
|
1346
1346
|
}
|
|
1347
1347
|
|
|
1348
|
+
function generatePalette(colorStr, name) {
|
|
1349
|
+
const { _r, _g, _b, _a } = tinycolor(colorStr);
|
|
1350
|
+
const color = {
|
|
1351
|
+
rgb: [_r, _g, _b],
|
|
1352
|
+
alpha: _a
|
|
1353
|
+
};
|
|
1354
|
+
|
|
1355
|
+
return COLOR_NUMBER_SET.map((level, index) => {
|
|
1356
|
+
const {
|
|
1357
|
+
rgb: [r, g, b],
|
|
1358
|
+
alpha: a
|
|
1359
|
+
} = color;
|
|
1360
|
+
|
|
1361
|
+
const hsv = tinycolor({ r, g, b, a }).toHsv();
|
|
1362
|
+
const tiny = tinycolor({
|
|
1363
|
+
h: calculateHue(hsv.h, index),
|
|
1364
|
+
s: calculateSaturation(hsv.s, index),
|
|
1365
|
+
v: calculateBrightness(hsv.v, index)
|
|
1366
|
+
});
|
|
1367
|
+
|
|
1368
|
+
return {
|
|
1369
|
+
level,
|
|
1370
|
+
hex: tiny.toHexString(),
|
|
1371
|
+
rgb: tiny.toRgbString(),
|
|
1372
|
+
hls: tiny.toHslString(),
|
|
1373
|
+
cssVar: `--rs-${name}-${level}`
|
|
1374
|
+
};
|
|
1375
|
+
});
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1348
1378
|
module.exports = {
|
|
1379
|
+
tinycolor,
|
|
1380
|
+
generatePalette,
|
|
1349
1381
|
install: function (less, pluginManager, functions) {
|
|
1350
1382
|
/**
|
|
1351
1383
|
* Calculate color
|
|
@@ -1357,12 +1389,8 @@ module.exports = {
|
|
|
1357
1389
|
rgb: [r, g, b],
|
|
1358
1390
|
alpha: a
|
|
1359
1391
|
} = color;
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
g,
|
|
1363
|
-
b,
|
|
1364
|
-
a
|
|
1365
|
-
}).toHsv();
|
|
1392
|
+
|
|
1393
|
+
const hsv = tinycolor({ r, g, b, a }).toHsv();
|
|
1366
1394
|
const index = COLOR_NUMBER_SET.indexOf('' + colorNumber.value);
|
|
1367
1395
|
if (index === -1 || index === PRIMARY_INDEX) {
|
|
1368
1396
|
return less.color(color.rgb);
|