rsuite 5.23.1 → 5.23.3
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/ButtonToolbar/styles/index.less +0 -4
- package/CHANGELOG.md +15 -0
- package/FormHelpText/styles/index.less +2 -2
- package/Modal/styles/index.less +6 -6
- package/Tooltip/styles/index.less +0 -1
- package/cjs/AutoComplete/utils.d.ts +3 -2
- package/cjs/AutoComplete/utils.js +1 -1
- package/cjs/ButtonToolbar/ButtonToolbar.d.ts +2 -1
- package/cjs/ButtonToolbar/ButtonToolbar.js +9 -2
- package/cjs/Cascader/Cascader.js +2 -1
- package/cjs/Cascader/utils.d.ts +17 -12
- package/cjs/Cascader/utils.js +5 -5
- package/cjs/Menu/Menu.js +1 -0
- package/cjs/MultiCascader/utils.d.ts +14 -11
- package/cjs/Nav/NavDropdownMenu.d.ts +2 -0
- package/cjs/Nav/NavDropdownMenu.js +4 -2
- package/cjs/Picker/utils.d.ts +15 -13
- package/cjs/Picker/utils.js +81 -5
- package/cjs/Stack/Stack.d.ts +4 -0
- package/cjs/Stack/Stack.js +10 -8
- package/cjs/utils/treeUtils.d.ts +30 -22
- package/dist/rsuite-rtl.css +7 -9
- package/dist/rsuite-rtl.min.css +1 -1
- package/dist/rsuite-rtl.min.css.map +1 -1
- package/dist/rsuite.css +7 -9
- package/dist/rsuite.js +9 -9
- 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/AutoComplete/utils.d.ts +3 -2
- package/esm/AutoComplete/utils.js +1 -1
- package/esm/ButtonToolbar/ButtonToolbar.d.ts +2 -1
- package/esm/ButtonToolbar/ButtonToolbar.js +9 -2
- package/esm/Cascader/Cascader.js +2 -1
- package/esm/Cascader/utils.d.ts +17 -12
- package/esm/Cascader/utils.js +5 -5
- package/esm/Menu/Menu.js +1 -0
- package/esm/MultiCascader/utils.d.ts +14 -11
- package/esm/Nav/NavDropdownMenu.d.ts +2 -0
- package/esm/Nav/NavDropdownMenu.js +4 -2
- package/esm/Picker/utils.d.ts +15 -13
- package/esm/Picker/utils.js +80 -5
- package/esm/Stack/Stack.d.ts +4 -0
- package/esm/Stack/Stack.js +10 -8
- package/esm/utils/treeUtils.d.ts +30 -22
- package/package.json +1 -1
- package/styles/variables.less +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
## [5.23.3](https://github.com/rsuite/rsuite/compare/v5.23.2...v5.23.3) (2022-12-16)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- **Modal:** fix close button alignment and color ([#2973](https://github.com/rsuite/rsuite/issues/2973)) ([b1eb5b4](https://github.com/rsuite/rsuite/commit/b1eb5b406a29788290a704414cc5a19b115690c7))
|
|
6
|
+
|
|
7
|
+
## [5.23.2](https://github.com/rsuite/rsuite/compare/v5.23.1...v5.23.2) (2022-12-09)
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
- **Form.HelpText:** change font size to 12px ([#2968](https://github.com/rsuite/rsuite/issues/2968)) ([5c3898e](https://github.com/rsuite/rsuite/commit/5c3898ed2726beb81c09accd4d91963849d0dd31))
|
|
12
|
+
- **Nav.Menu:** fix noCaret has No Effect on a Sub-menu ([#2960](https://github.com/rsuite/rsuite/issues/2960)) ([e51fb6b](https://github.com/rsuite/rsuite/commit/e51fb6b593f0221f2ac3288b55658d540db214f9))
|
|
13
|
+
- **pickers:** the focused item should be within the container's viewport ([#2957](https://github.com/rsuite/rsuite/issues/2957)) ([cab5c63](https://github.com/rsuite/rsuite/commit/cab5c63ffde3963c72363adf00531ef3ab9d9e83))
|
|
14
|
+
- **Tooltip:** should use the default text alignment ([#2965](https://github.com/rsuite/rsuite/issues/2965)) ([3280775](https://github.com/rsuite/rsuite/commit/3280775a699a3683b2c45b543fbd8e6576206142))
|
|
15
|
+
|
|
1
16
|
## [5.23.1](https://github.com/rsuite/rsuite/compare/v5.23.0...v5.23.1) (2022-12-02)
|
|
2
17
|
|
|
3
18
|
### Bug Fixes
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
color: var(--rs-text-secondary); // lighten the text some for contrast
|
|
11
11
|
//Sometimes help info is more than one line,so height can't set a fixed value
|
|
12
12
|
min-height: @line-height-computed;
|
|
13
|
-
line-height: @line-height-
|
|
14
|
-
font-size: @font-size-
|
|
13
|
+
line-height: @line-height-small;
|
|
14
|
+
font-size: @font-size-small;
|
|
15
15
|
|
|
16
16
|
&-tooltip {
|
|
17
17
|
display: inline-flex;
|
package/Modal/styles/index.less
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
//
|
|
5
5
|
// Modals
|
|
6
|
+
// Figma: https://www.figma.com/file/uEq9QBplcKUYZrcWWA3RK2/NXT-UI?node-id=0%3A1348&t=H5h3Dd3AnJVgbAbz-4
|
|
6
7
|
// --------------------------------------------------
|
|
7
8
|
|
|
8
9
|
// Modal background
|
|
@@ -100,17 +101,16 @@
|
|
|
100
101
|
padding-right: @line-height-computed;
|
|
101
102
|
|
|
102
103
|
.rs-modal-header-close {
|
|
103
|
-
// button width the same to height
|
|
104
|
-
@padding-right: 4px;
|
|
105
|
-
|
|
106
104
|
position: absolute;
|
|
107
105
|
right: @modal-content-padding;
|
|
108
106
|
top: @modal-content-padding;
|
|
109
107
|
font-size: @modal-close-btn-size;
|
|
110
|
-
line-height: @modal-close-btn-line-height;
|
|
111
108
|
color: @modal-close-btn-color;
|
|
112
|
-
|
|
113
|
-
|
|
109
|
+
padding: 0;
|
|
110
|
+
|
|
111
|
+
&:hover {
|
|
112
|
+
color: @modal-close-btn-hover-color;
|
|
113
|
+
}
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { ItemDataType } from '../@types/common';
|
|
2
1
|
export declare function transformData(data: any[]): any[];
|
|
3
|
-
export declare const shouldDisplay:
|
|
2
|
+
export declare const shouldDisplay: <TItem extends {
|
|
3
|
+
label: string;
|
|
4
|
+
}>(filterBy: ((value: string, item: TItem) => boolean) | undefined, value: string) => (item: TItem) => boolean;
|
|
@@ -37,7 +37,7 @@ var shouldDisplay = function shouldDisplay(filterBy, value) {
|
|
|
37
37
|
return false;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
var keyword =
|
|
40
|
+
var keyword = value.toLocaleLowerCase();
|
|
41
41
|
return ("" + item.label).toLocaleLowerCase().indexOf(keyword) >= 0;
|
|
42
42
|
};
|
|
43
43
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { WithAsProps, RsRefForwardingComponent } from '../@types/common';
|
|
2
|
+
import Stack from '../Stack';
|
|
2
3
|
export interface ButtonToolbarProps extends WithAsProps {
|
|
3
4
|
/**
|
|
4
5
|
* The ARIA role describing the button toolbar. Generally the default
|
|
@@ -7,5 +8,5 @@ export interface ButtonToolbarProps extends WithAsProps {
|
|
|
7
8
|
*/
|
|
8
9
|
role?: string;
|
|
9
10
|
}
|
|
10
|
-
declare const ButtonToolbar: RsRefForwardingComponent<
|
|
11
|
+
declare const ButtonToolbar: RsRefForwardingComponent<typeof Stack, ButtonToolbarProps>;
|
|
11
12
|
export default ButtonToolbar;
|
|
@@ -15,22 +15,29 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
15
15
|
|
|
16
16
|
var _utils = require("../utils");
|
|
17
17
|
|
|
18
|
+
var _Stack = _interopRequireDefault(require("../Stack"));
|
|
19
|
+
|
|
18
20
|
var ButtonToolbar = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
19
21
|
var className = props.className,
|
|
20
22
|
_props$classPrefix = props.classPrefix,
|
|
21
23
|
classPrefix = _props$classPrefix === void 0 ? 'btn-toolbar' : _props$classPrefix,
|
|
22
24
|
_props$as = props.as,
|
|
23
|
-
Component = _props$as === void 0 ?
|
|
25
|
+
Component = _props$as === void 0 ? _Stack.default : _props$as,
|
|
24
26
|
_props$role = props.role,
|
|
25
27
|
role = _props$role === void 0 ? 'toolbar' : _props$role,
|
|
26
28
|
rest = (0, _objectWithoutPropertiesLoose2.default)(props, ["className", "classPrefix", "as", "role"]);
|
|
29
|
+
var stackProps = Component === _Stack.default ? {
|
|
30
|
+
wrap: true,
|
|
31
|
+
spacing: 10,
|
|
32
|
+
childrenRenderMode: 'clone'
|
|
33
|
+
} : null;
|
|
27
34
|
|
|
28
35
|
var _useClassNames = (0, _utils.useClassNames)(classPrefix),
|
|
29
36
|
withClassPrefix = _useClassNames.withClassPrefix,
|
|
30
37
|
merge = _useClassNames.merge;
|
|
31
38
|
|
|
32
39
|
var classes = merge(className, withClassPrefix());
|
|
33
|
-
return /*#__PURE__*/_react.default.createElement(Component, (0, _extends2.default)({}, rest, {
|
|
40
|
+
return /*#__PURE__*/_react.default.createElement(Component, (0, _extends2.default)({}, stackProps, rest, {
|
|
34
41
|
role: role,
|
|
35
42
|
ref: ref,
|
|
36
43
|
className: classes
|
package/cjs/Cascader/Cascader.js
CHANGED
|
@@ -454,7 +454,8 @@ var Cascader = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
|
454
454
|
classPrefix: 'picker-cascader-menu',
|
|
455
455
|
cascadeData: columnData,
|
|
456
456
|
cascadePaths: selectedPaths,
|
|
457
|
-
activeItemValue: value
|
|
457
|
+
activeItemValue: value // FIXME make onSelect generic
|
|
458
|
+
,
|
|
458
459
|
onSelect: handleSelect,
|
|
459
460
|
renderMenu: renderMenu,
|
|
460
461
|
renderMenuItem: renderMenuItem
|
package/cjs/Cascader/utils.d.ts
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export declare function getColumnsAndPaths<T extends ItemDataType>(data: T[], value: any, options: any): {
|
|
5
|
-
columns: ItemDataType<string | number>[][];
|
|
2
|
+
export declare function getColumnsAndPaths<T extends Record<string, unknown>>(data: T[], value: any, options: any): {
|
|
3
|
+
columns: T[][];
|
|
6
4
|
paths: T[];
|
|
7
5
|
};
|
|
8
|
-
|
|
6
|
+
declare type UsePathsParams<T> = {
|
|
7
|
+
data: T[];
|
|
8
|
+
valueKey: string;
|
|
9
|
+
childrenKey: string;
|
|
10
|
+
value: unknown;
|
|
11
|
+
};
|
|
12
|
+
export declare function usePaths<T extends Record<string, unknown>>(params: UsePathsParams<T>): {
|
|
9
13
|
enforceUpdate: (nextValue: any, isAttachChildren?: boolean) => void;
|
|
10
|
-
columnData:
|
|
11
|
-
valueToPaths:
|
|
12
|
-
selectedPaths:
|
|
13
|
-
setValueToPaths: import("react").Dispatch<import("react").SetStateAction<
|
|
14
|
-
setColumnData: import("react").Dispatch<import("react").SetStateAction<
|
|
15
|
-
setSelectedPaths: import("react").Dispatch<import("react").SetStateAction<
|
|
16
|
-
addColumn: (column:
|
|
14
|
+
columnData: T[][];
|
|
15
|
+
valueToPaths: T[];
|
|
16
|
+
selectedPaths: T[];
|
|
17
|
+
setValueToPaths: import("react").Dispatch<import("react").SetStateAction<T[]>>;
|
|
18
|
+
setColumnData: import("react").Dispatch<import("react").SetStateAction<T[][]>>;
|
|
19
|
+
setSelectedPaths: import("react").Dispatch<import("react").SetStateAction<T[]>>;
|
|
20
|
+
addColumn: (column: T[], index: number) => void;
|
|
17
21
|
romoveColumnByIndex: (index: number) => void;
|
|
18
22
|
};
|
|
23
|
+
export {};
|
package/cjs/Cascader/utils.js
CHANGED
|
@@ -86,11 +86,11 @@ function getColumnsAndPaths(data, value, options) {
|
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
function usePaths(
|
|
90
|
-
var data =
|
|
91
|
-
valueKey =
|
|
92
|
-
childrenKey =
|
|
93
|
-
value =
|
|
89
|
+
function usePaths(params) {
|
|
90
|
+
var data = params.data,
|
|
91
|
+
valueKey = params.valueKey,
|
|
92
|
+
childrenKey = params.childrenKey,
|
|
93
|
+
value = params.value;
|
|
94
94
|
|
|
95
95
|
var _useMemo = (0, _react.useMemo)(function () {
|
|
96
96
|
return getColumnsAndPaths(data, value, {
|
package/cjs/Menu/Menu.js
CHANGED
|
@@ -381,6 +381,7 @@ function Menu(_ref) {
|
|
|
381
381
|
}, [disabled, closeMenu]);
|
|
382
382
|
var rootElementRef = (0, _react.useRef)(null);
|
|
383
383
|
var handleContainerBlur = (0, _react.useCallback)(function (event) {
|
|
384
|
+
/* istanbul ignore else */
|
|
384
385
|
if ((0, _events.isFocusLeaving)(event)) {
|
|
385
386
|
closeMenu(event, false);
|
|
386
387
|
}
|
|
@@ -9,25 +9,28 @@ interface ItemKeys {
|
|
|
9
9
|
labelKey: string;
|
|
10
10
|
childrenKey: string;
|
|
11
11
|
}
|
|
12
|
+
declare type MayHasParent<T extends Record<string, unknown>> = T & {
|
|
13
|
+
parent?: MayHasParent<T>;
|
|
14
|
+
};
|
|
12
15
|
/**
|
|
13
16
|
* Get all parents of a node
|
|
14
17
|
* @param node
|
|
15
18
|
*/
|
|
16
|
-
export declare const getParents: (node:
|
|
19
|
+
export declare const getParents: <T extends Record<string, unknown>>(node: MayHasParent<T>) => MayHasParent<T>[];
|
|
17
20
|
/**
|
|
18
21
|
* Check if any child nodes are selected.
|
|
19
22
|
* @param node
|
|
20
23
|
* @param value
|
|
21
24
|
* @param itemKeys
|
|
22
25
|
*/
|
|
23
|
-
export declare const isSomeChildChecked: (node:
|
|
26
|
+
export declare const isSomeChildChecked: <T extends Record<string, unknown>>(node: T, value: ValueType, itemKeys: Omit<ItemKeys, 'labelKey'>) => any;
|
|
24
27
|
/**
|
|
25
28
|
* Check if the parent is selected.
|
|
26
29
|
* @param node
|
|
27
30
|
* @param value
|
|
28
31
|
* @param itemKeys
|
|
29
32
|
*/
|
|
30
|
-
export declare const isSomeParentChecked: (node:
|
|
33
|
+
export declare const isSomeParentChecked: <T extends Record<string, unknown>>(node: MayHasParent<T>, value: ValueType, itemKeys: Pick<ItemKeys, 'valueKey'>) => any;
|
|
31
34
|
export declare const getOtherItemValuesByUnselectChild: <T>(itemNode: ItemType, value: any, itemKeys: Omit<ItemKeys, 'labelKey'>) => T[];
|
|
32
35
|
/**
|
|
33
36
|
* Remove the values of all children.
|
|
@@ -37,20 +40,20 @@ export declare const removeAllChildrenValue: <T>(value: T[], item: ItemType, ite
|
|
|
37
40
|
* A hook to flatten tree structure data
|
|
38
41
|
* @param data
|
|
39
42
|
*/
|
|
40
|
-
export declare function useFlattenData(data:
|
|
41
|
-
addFlattenData: (children:
|
|
42
|
-
flattenData:
|
|
43
|
+
export declare function useFlattenData<T>(data: T[], itemKeys: ItemKeys): {
|
|
44
|
+
addFlattenData: (children: T[], parent: T) => void;
|
|
45
|
+
flattenData: T[];
|
|
43
46
|
};
|
|
44
47
|
/**
|
|
45
48
|
* A hook for column data
|
|
46
49
|
* @param flattenData
|
|
47
50
|
*/
|
|
48
|
-
export declare function useColumnData(flattenData:
|
|
49
|
-
columnData:
|
|
50
|
-
addColumn: (column:
|
|
51
|
+
export declare function useColumnData<T extends MayHasParent<Record<string, unknown>>>(flattenData: T[]): {
|
|
52
|
+
columnData: T[][];
|
|
53
|
+
addColumn: (column: T[], index: number) => void;
|
|
51
54
|
romoveColumnByIndex: (index: number) => void;
|
|
52
|
-
setColumnData: import("react").Dispatch<import("react").SetStateAction<
|
|
53
|
-
enforceUpdateColumnData: (nextData:
|
|
55
|
+
setColumnData: import("react").Dispatch<import("react").SetStateAction<T[][]>>;
|
|
56
|
+
enforceUpdateColumnData: (nextData: T[]) => void;
|
|
54
57
|
};
|
|
55
58
|
/**
|
|
56
59
|
* A hook that converts the value into a cascading value
|
|
@@ -17,6 +17,8 @@ export interface NavDropdownMenuProps<T = any> extends StandardProps {
|
|
|
17
17
|
* @default 'end'
|
|
18
18
|
*/
|
|
19
19
|
openDirection?: 'start' | 'end';
|
|
20
|
+
/** No caret variation */
|
|
21
|
+
noCaret?: boolean;
|
|
20
22
|
/**
|
|
21
23
|
* Only used for setting the default expand state when it's a submenu.
|
|
22
24
|
*/
|
|
@@ -55,7 +55,8 @@ var NavDropdownMenu = /*#__PURE__*/_react.default.forwardRef(function (props, re
|
|
|
55
55
|
children = props.children,
|
|
56
56
|
_props$openDirection = props.openDirection,
|
|
57
57
|
openDirection = _props$openDirection === void 0 ? 'end' : _props$openDirection,
|
|
58
|
-
|
|
58
|
+
noCaret = props.noCaret,
|
|
59
|
+
rest = (0, _objectWithoutPropertiesLoose2.default)(props, ["onToggle", "eventKey", "title", "classPrefix", "children", "openDirection", "noCaret"]);
|
|
59
60
|
|
|
60
61
|
var _useCustom = (0, _useCustom2.default)('DropdownMenu'),
|
|
61
62
|
rtl = _useCustom.rtl;
|
|
@@ -110,7 +111,7 @@ var NavDropdownMenu = /*#__PURE__*/_react.default.forwardRef(function (props, re
|
|
|
110
111
|
"data-event-key-type": typeof eventKey
|
|
111
112
|
}, menuitem, (0, _omit2.default)(menuButtonProps, ['role'])), icon && /*#__PURE__*/_react.default.cloneElement(icon, {
|
|
112
113
|
className: prefix('menu-icon')
|
|
113
|
-
}), title, /*#__PURE__*/_react.default.createElement(Icon, {
|
|
114
|
+
}), title, !noCaret && /*#__PURE__*/_react.default.createElement(Icon, {
|
|
114
115
|
className: prefix(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteralLoose2.default)(["toggle-icon"])))
|
|
115
116
|
}));
|
|
116
117
|
});
|
|
@@ -151,6 +152,7 @@ NavDropdownMenu.propTypes = {
|
|
|
151
152
|
classPrefix: _propTypes.default.string,
|
|
152
153
|
pullLeft: (0, _deprecatePropType.default)(_propTypes.default.bool, 'Use openDirection="start" instead.'),
|
|
153
154
|
openDirection: _propTypes.default.oneOf(['start', 'end']),
|
|
155
|
+
noCaret: _propTypes.default.bool,
|
|
154
156
|
title: _propTypes.default.node,
|
|
155
157
|
open: _propTypes.default.bool,
|
|
156
158
|
eventKey: _propTypes.default.any,
|
package/cjs/Picker/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { OverlayTriggerHandle } from './PickerToggleTrigger';
|
|
3
|
-
import { TypeAttributes
|
|
3
|
+
import { TypeAttributes } from '../@types/common';
|
|
4
4
|
import type { ListHandle } from '../Windowing';
|
|
5
5
|
export interface NodeKeys {
|
|
6
6
|
valueKey: string;
|
|
@@ -86,24 +86,25 @@ export interface ToggleKeyDownEventProps {
|
|
|
86
86
|
* @param props
|
|
87
87
|
*/
|
|
88
88
|
export declare const useToggleKeyDownEvent: (props: ToggleKeyDownEventProps) => (event: React.KeyboardEvent) => void;
|
|
89
|
-
export interface SearchProps {
|
|
89
|
+
export interface SearchProps<TItem extends Record<string, unknown>, TLabel> {
|
|
90
90
|
labelKey: string;
|
|
91
|
-
data:
|
|
92
|
-
searchBy?: (keyword:
|
|
93
|
-
callback?: (keyword: string, data:
|
|
91
|
+
data: TItem[];
|
|
92
|
+
searchBy?: (keyword: string, label: TLabel, item: TItem) => boolean;
|
|
93
|
+
callback?: (keyword: string, data: TItem[], event: React.SyntheticEvent) => void;
|
|
94
94
|
}
|
|
95
|
+
declare type UseSearchResult<TItem extends Record<string, unknown>> = {
|
|
96
|
+
searchKeyword: string;
|
|
97
|
+
filteredData: TItem[];
|
|
98
|
+
updateFilteredData: (nextData: TItem[]) => void;
|
|
99
|
+
setSearchKeyword: (value: string) => void;
|
|
100
|
+
checkShouldDisplay: (item: TItem, keyword?: string) => boolean;
|
|
101
|
+
handleSearch: (searchKeyword: string, event: React.SyntheticEvent) => void;
|
|
102
|
+
};
|
|
95
103
|
/**
|
|
96
104
|
* A hook that handles search filter options
|
|
97
105
|
* @param props
|
|
98
106
|
*/
|
|
99
|
-
export declare function useSearch(props: SearchProps):
|
|
100
|
-
searchKeyword: string;
|
|
101
|
-
filteredData: import("../CheckTreePicker/utils").TreeNodeType[];
|
|
102
|
-
updateFilteredData: (nextData: ItemDataType[]) => void;
|
|
103
|
-
setSearchKeyword: React.Dispatch<React.SetStateAction<string>>;
|
|
104
|
-
checkShouldDisplay: (item: ItemDataType, keyword?: string) => boolean;
|
|
105
|
-
handleSearch: (searchKeyword: string, event: React.SyntheticEvent) => void;
|
|
106
|
-
};
|
|
107
|
+
export declare function useSearch<TItem extends Record<string, unknown>, TLabel>(props: SearchProps<TItem, TLabel>): UseSearchResult<TItem>;
|
|
107
108
|
export interface PickerDependentParameters {
|
|
108
109
|
triggerRef?: React.RefObject<OverlayTriggerHandle>;
|
|
109
110
|
rootRef?: React.RefObject<HTMLElement>;
|
|
@@ -116,3 +117,4 @@ export interface PickerDependentParameters {
|
|
|
116
117
|
* A hook of the exposed method of Picker
|
|
117
118
|
*/
|
|
118
119
|
export declare function usePublicMethods(ref: any, parmas: PickerDependentParameters): void;
|
|
120
|
+
export {};
|
package/cjs/Picker/utils.js
CHANGED
|
@@ -33,6 +33,8 @@ var _treeUtils = require("../utils/treeUtils");
|
|
|
33
33
|
|
|
34
34
|
var _utils = require("../utils");
|
|
35
35
|
|
|
36
|
+
var _domLib = require("dom-lib");
|
|
37
|
+
|
|
36
38
|
var defaultNodeKeys = {
|
|
37
39
|
valueKey: 'value',
|
|
38
40
|
childrenKey: 'children'
|
|
@@ -162,11 +164,51 @@ function onMenuKeyDown(event, events) {
|
|
|
162
164
|
}
|
|
163
165
|
}
|
|
164
166
|
|
|
167
|
+
/**
|
|
168
|
+
* Checks if the element has a vertical scrollbar.
|
|
169
|
+
*/
|
|
170
|
+
function hasVerticalScroll(element) {
|
|
171
|
+
var scrollHeight = element.scrollHeight,
|
|
172
|
+
clientHeight = element.clientHeight;
|
|
173
|
+
return scrollHeight > clientHeight;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Checks if the element is within the visible area of the container
|
|
177
|
+
*/
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
function isVisible(element, container, direction) {
|
|
181
|
+
if (!hasVerticalScroll(container)) {
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
var _element$getBoundingC = element.getBoundingClientRect(),
|
|
186
|
+
top = _element$getBoundingC.top,
|
|
187
|
+
bottom = _element$getBoundingC.bottom,
|
|
188
|
+
height = _element$getBoundingC.height;
|
|
189
|
+
|
|
190
|
+
var _container$getBoundin = container.getBoundingClientRect(),
|
|
191
|
+
containerTop = _container$getBoundin.top,
|
|
192
|
+
containerBottom = _container$getBoundin.bottom;
|
|
193
|
+
|
|
194
|
+
if (direction === 'top') {
|
|
195
|
+
return top + height > containerTop;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return bottom - height < containerBottom;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function scrollTo(container, direction, step) {
|
|
202
|
+
var scrollTop = container.scrollTop;
|
|
203
|
+
container.scrollTop = direction === 'top' ? scrollTop - step : scrollTop + step;
|
|
204
|
+
}
|
|
165
205
|
/**
|
|
166
206
|
* A hook that manages the focus state of the option.
|
|
167
207
|
* @param defaultFocusItemValue
|
|
168
208
|
* @param props
|
|
169
209
|
*/
|
|
210
|
+
|
|
211
|
+
|
|
170
212
|
var useFocusItemValue = function useFocusItemValue(defaultFocusItemValue, props) {
|
|
171
213
|
var _props$valueKey = props.valueKey,
|
|
172
214
|
valueKey = _props$valueKey === void 0 ? 'value' : _props$valueKey,
|
|
@@ -190,11 +232,23 @@ var useFocusItemValue = function useFocusItemValue(defaultFocusItemValue, props)
|
|
|
190
232
|
var _useState3 = (0, _react.useState)([]),
|
|
191
233
|
keys = _useState3[0],
|
|
192
234
|
setKeys = _useState3[1];
|
|
235
|
+
|
|
236
|
+
var getScrollContainer = (0, _react.useCallback)(function () {
|
|
237
|
+
var menu = (0, _isFunction.default)(target) ? target() : target; // For Cascader and MutiCascader
|
|
238
|
+
|
|
239
|
+
var subMenu = menu === null || menu === void 0 ? void 0 : menu.querySelector("[data-layer=\"" + layer + "\"]");
|
|
240
|
+
|
|
241
|
+
if (subMenu) {
|
|
242
|
+
return subMenu;
|
|
243
|
+
} // For SelectPicker、CheckPicker、Autocomplete、InputPicker、TagPicker
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
return menu === null || menu === void 0 ? void 0 : menu.querySelector('[role="listbox"]');
|
|
247
|
+
}, [layer, target]);
|
|
193
248
|
/**
|
|
194
249
|
* Get the elements visible in all options.
|
|
195
250
|
*/
|
|
196
251
|
|
|
197
|
-
|
|
198
252
|
var getFocusableMenuItems = (0, _react.useCallback)(function () {
|
|
199
253
|
if (!target) {
|
|
200
254
|
return [];
|
|
@@ -251,28 +305,50 @@ var useFocusItemValue = function useFocusItemValue(defaultFocusItemValue, props)
|
|
|
251
305
|
|
|
252
306
|
callback(items, -1);
|
|
253
307
|
}, [focusItemValue, getFocusableMenuItems, valueKey]);
|
|
308
|
+
var scrollListItem = (0, _react.useCallback)(function (direction, itemValue, willOverflow) {
|
|
309
|
+
var container = getScrollContainer();
|
|
310
|
+
var item = container === null || container === void 0 ? void 0 : container.querySelector("[data-key=\"" + itemValue + "\"]");
|
|
311
|
+
|
|
312
|
+
if (willOverflow && container) {
|
|
313
|
+
var scrollHeight = container.scrollHeight,
|
|
314
|
+
clientHeight = container.clientHeight;
|
|
315
|
+
container.scrollTop = direction === 'top' ? scrollHeight - clientHeight : 0;
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
if (item && container) {
|
|
320
|
+
if (!isVisible(item, container, direction)) {
|
|
321
|
+
var height = (0, _domLib.getHeight)(item);
|
|
322
|
+
scrollTo(container, direction, height);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}, [getScrollContainer]);
|
|
254
326
|
var focusNextMenuItem = (0, _react.useCallback)(function (event) {
|
|
255
327
|
findFocusItemIndex(function (items, index) {
|
|
256
|
-
var
|
|
328
|
+
var willOverflow = index + 2 > items.length;
|
|
329
|
+
var nextIndex = willOverflow ? 0 : index + 1;
|
|
257
330
|
var focusItem = items[nextIndex];
|
|
258
331
|
|
|
259
332
|
if (!(0, _isUndefined.default)(focusItem)) {
|
|
260
333
|
setFocusItemValue(focusItem[valueKey]);
|
|
261
334
|
callback === null || callback === void 0 ? void 0 : callback(focusItem[valueKey], event);
|
|
335
|
+
scrollListItem('bottom', focusItem[valueKey], willOverflow);
|
|
262
336
|
}
|
|
263
337
|
});
|
|
264
|
-
}, [callback, findFocusItemIndex, valueKey]);
|
|
338
|
+
}, [callback, findFocusItemIndex, scrollListItem, valueKey]);
|
|
265
339
|
var focusPrevMenuItem = (0, _react.useCallback)(function (event) {
|
|
266
340
|
findFocusItemIndex(function (items, index) {
|
|
267
|
-
var
|
|
341
|
+
var willOverflow = index === 0;
|
|
342
|
+
var nextIndex = willOverflow ? items.length - 1 : index - 1;
|
|
268
343
|
var focusItem = items[nextIndex];
|
|
269
344
|
|
|
270
345
|
if (!(0, _isUndefined.default)(focusItem)) {
|
|
271
346
|
setFocusItemValue(focusItem[valueKey]);
|
|
272
347
|
callback === null || callback === void 0 ? void 0 : callback(focusItem[valueKey], event);
|
|
348
|
+
scrollListItem('top', focusItem[valueKey], willOverflow);
|
|
273
349
|
}
|
|
274
350
|
});
|
|
275
|
-
}, [callback, findFocusItemIndex, valueKey]);
|
|
351
|
+
}, [callback, findFocusItemIndex, scrollListItem, valueKey]);
|
|
276
352
|
var getSubMenuKeys = (0, _react.useCallback)(function (nextLayer) {
|
|
277
353
|
var menu = (0, _isFunction.default)(target) ? target() : target;
|
|
278
354
|
var subMenu = menu === null || menu === void 0 ? void 0 : menu.querySelector("[data-layer=\"" + nextLayer + "\"]");
|
package/cjs/Stack/Stack.d.ts
CHANGED
|
@@ -22,6 +22,10 @@ export interface StackProps extends WithAsProps {
|
|
|
22
22
|
* Define whether the children in the stack are forced onto one line or can wrap onto multiple lines
|
|
23
23
|
*/
|
|
24
24
|
wrap?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* The render mode of the children.
|
|
27
|
+
*/
|
|
28
|
+
childrenRenderMode?: 'clone' | 'wrap';
|
|
25
29
|
}
|
|
26
30
|
export interface StackComponent extends RsRefForwardingComponent<'div', StackProps> {
|
|
27
31
|
Item: typeof StackItem;
|
package/cjs/Stack/Stack.js
CHANGED
|
@@ -26,6 +26,8 @@ var Stack = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
|
26
26
|
alignItems = _props$alignItems === void 0 ? 'center' : _props$alignItems,
|
|
27
27
|
_props$classPrefix = props.classPrefix,
|
|
28
28
|
classPrefix = _props$classPrefix === void 0 ? 'stack' : _props$classPrefix,
|
|
29
|
+
_props$childrenRender = props.childrenRenderMode,
|
|
30
|
+
childrenRenderMode = _props$childrenRender === void 0 ? 'wrap' : _props$childrenRender,
|
|
29
31
|
className = props.className,
|
|
30
32
|
children = props.children,
|
|
31
33
|
direction = props.direction,
|
|
@@ -34,7 +36,7 @@ var Stack = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
|
34
36
|
divider = props.divider,
|
|
35
37
|
style = props.style,
|
|
36
38
|
wrap = props.wrap,
|
|
37
|
-
rest = (0, _objectWithoutPropertiesLoose2.default)(props, ["as", "alignItems", "classPrefix", "className", "children", "direction", "justifyContent", "spacing", "divider", "style", "wrap"]);
|
|
39
|
+
rest = (0, _objectWithoutPropertiesLoose2.default)(props, ["as", "alignItems", "classPrefix", "childrenRenderMode", "className", "children", "direction", "justifyContent", "spacing", "divider", "style", "wrap"]);
|
|
38
40
|
|
|
39
41
|
var _useCustom = (0, _utils.useCustom)('Stack'),
|
|
40
42
|
rtl = _useCustom.rtl;
|
|
@@ -45,15 +47,15 @@ var Stack = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
|
45
47
|
prefix = _useClassNames.prefix;
|
|
46
48
|
|
|
47
49
|
var classes = merge(className, withClassPrefix());
|
|
48
|
-
var
|
|
49
|
-
var
|
|
50
|
-
var itemStyles = (_itemStyles = {}, _itemStyles[rtl ? 'marginLeft' : 'marginRight'] =
|
|
50
|
+
var isSupportGap = (0, _utils.isSupportFlexGap)();
|
|
51
|
+
var flexGap = Array.isArray(spacing) ? spacing : [spacing, spacing];
|
|
52
|
+
var itemStyles = (_itemStyles = {}, _itemStyles[rtl ? 'marginLeft' : 'marginRight'] = flexGap[0], _itemStyles.marginBottom = flexGap[1], _itemStyles);
|
|
51
53
|
var styles = (0, _extends2.default)({
|
|
52
54
|
alignItems: alignItems,
|
|
53
55
|
justifyContent: justifyContent,
|
|
54
56
|
flexDirection: direction,
|
|
55
57
|
flexWrap: wrap ? 'wrap' : undefined,
|
|
56
|
-
gap:
|
|
58
|
+
gap: isSupportGap ? spacing : undefined
|
|
57
59
|
}, style);
|
|
58
60
|
/*
|
|
59
61
|
* toArray remove undefined, null and boolean
|
|
@@ -67,13 +69,13 @@ var Stack = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
|
67
69
|
className: classes,
|
|
68
70
|
style: styles
|
|
69
71
|
}), _react.default.Children.map(filterChildren, function (child, index) {
|
|
70
|
-
var childNode = child.type !== _StackItem.default ? /*#__PURE__*/_react.default.createElement(_StackItem.default, {
|
|
72
|
+
var childNode = childrenRenderMode === 'wrap' && child.type !== _StackItem.default ? /*#__PURE__*/_react.default.createElement(_StackItem.default, {
|
|
71
73
|
key: index,
|
|
72
74
|
className: prefix('item'),
|
|
73
|
-
style: !
|
|
75
|
+
style: !isSupportGap ? itemStyles : undefined
|
|
74
76
|
}, child) : /*#__PURE__*/_react.default.cloneElement(child, {
|
|
75
77
|
className: merge(prefix('item'), child.props.className),
|
|
76
|
-
style: !
|
|
78
|
+
style: !isSupportGap ? (0, _extends2.default)({}, itemStyles, child.props.style) : child.props.style
|
|
77
79
|
});
|
|
78
80
|
return [childNode, index < count - 1 ? divider : null];
|
|
79
81
|
}));
|