@rc-component/cascader 1.3.0 → 1.4.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/README.md +25 -6
- package/es/Cascader.d.ts +10 -6
- package/es/Cascader.js +7 -5
- package/es/OptionList/List.js +0 -1
- package/es/OptionList/useActive.js +0 -1
- package/es/OptionList/useKeyboard.d.ts +1 -1
- package/es/hooks/useSearchConfig.d.ts +2 -2
- package/es/hooks/useSearchConfig.js +11 -3
- package/es/hooks/useSearchOptions.d.ts +2 -2
- package/es/index.d.ts +1 -1
- package/lib/Cascader.d.ts +10 -6
- package/lib/Cascader.js +7 -5
- package/lib/OptionList/List.js +0 -1
- package/lib/OptionList/useActive.js +0 -1
- package/lib/OptionList/useKeyboard.d.ts +1 -1
- package/lib/hooks/useSearchConfig.d.ts +2 -2
- package/lib/hooks/useSearchConfig.js +11 -3
- package/lib/hooks/useSearchOptions.d.ts +2 -2
- package/lib/index.d.ts +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -114,12 +114,6 @@ React.render(
|
|
|
114
114
|
</tr>
|
|
115
115
|
</thead>
|
|
116
116
|
<tbody>
|
|
117
|
-
<tr>
|
|
118
|
-
<td>autoClearSearchValue</td>
|
|
119
|
-
<td>boolean</td>
|
|
120
|
-
<td>true</td>
|
|
121
|
-
<td>Whether the current search will be cleared on selecting an item. Only applies when checkable</td>
|
|
122
|
-
</tr>
|
|
123
117
|
<tr>
|
|
124
118
|
<td>options</td>
|
|
125
119
|
<td>Object</td>
|
|
@@ -234,9 +228,28 @@ React.render(
|
|
|
234
228
|
<td>>true</td>
|
|
235
229
|
<td>hide popup on select</td>
|
|
236
230
|
</tr>
|
|
231
|
+
<tr>
|
|
232
|
+
<td>showSearch</td>
|
|
233
|
+
<td>boolean | object</td>
|
|
234
|
+
<td>false</td>
|
|
235
|
+
<td>Whether show search input in single mode</td>
|
|
236
|
+
</tr>
|
|
237
237
|
</tbody>
|
|
238
238
|
</table>
|
|
239
239
|
|
|
240
|
+
### showSearch
|
|
241
|
+
|
|
242
|
+
| Property | Description | Type | Default | Version |
|
|
243
|
+
| --- | --- | --- | --- | --- |
|
|
244
|
+
| autoClearSearchValue | Whether the current search will be cleared on selecting an item. Only applies when checkable| boolean | true |
|
|
245
|
+
| filter | The function will receive two arguments, inputValue and option, if the function returns true, the option will be included in the filtered set; Otherwise, it will be excluded | function(inputValue, path): boolean | - | |
|
|
246
|
+
| limit | Set the count of filtered items | number \| false | 50 | |
|
|
247
|
+
| matchInputWidth | Whether the width of list matches input, ([how it looks](https://github.com/ant-design/ant-design/issues/25779)) | boolean | true | |
|
|
248
|
+
| render | Used to render filtered options | function(inputValue, path): ReactNode | - | |
|
|
249
|
+
| sort | Used to sort filtered options | function(a, b, inputValue) | - | |
|
|
250
|
+
| searchValue | The current input "search" text | string | - | - |
|
|
251
|
+
| onSearch | called when input changed | function | - | - |
|
|
252
|
+
|
|
240
253
|
### option
|
|
241
254
|
|
|
242
255
|
<table class="table table-bordered table-striped">
|
|
@@ -298,3 +311,9 @@ $ npm run coverage
|
|
|
298
311
|
## License
|
|
299
312
|
|
|
300
313
|
rc-cascader is released under the MIT license.
|
|
314
|
+
|
|
315
|
+
## 🤝 Contributing
|
|
316
|
+
|
|
317
|
+
<a href="https://openomy.app/github/react-component/cascader" target="_blank" style="display: block; width: 100%;" align="center">
|
|
318
|
+
<img src="https://www.openomy.app/svg?repo=react-component/cascader&chart=bubble&latestMonth=24" target="_blank" alt="Contribution Leaderboard" style="display: block; width: 100%;" />
|
|
319
|
+
</a>
|
package/es/Cascader.d.ts
CHANGED
|
@@ -12,12 +12,15 @@ export interface BaseOptionType {
|
|
|
12
12
|
children?: DefaultOptionType[];
|
|
13
13
|
}
|
|
14
14
|
export type DefaultOptionType = BaseOptionType & Record<string, any>;
|
|
15
|
-
export interface
|
|
15
|
+
export interface SearchConfig<OptionType extends DefaultOptionType = DefaultOptionType, ValueField extends keyof OptionType = keyof OptionType> {
|
|
16
16
|
filter?: (inputValue: string, options: OptionType[], fieldNames: FieldNames<OptionType, ValueField>) => boolean;
|
|
17
17
|
render?: (inputValue: string, path: OptionType[], prefixCls: string, fieldNames: FieldNames<OptionType, ValueField>) => React.ReactNode;
|
|
18
18
|
sort?: (a: OptionType[], b: OptionType[], inputValue: string, fieldNames: FieldNames<OptionType, ValueField>) => number;
|
|
19
19
|
matchInputWidth?: boolean;
|
|
20
20
|
limit?: number | false;
|
|
21
|
+
searchValue?: string;
|
|
22
|
+
onSearch?: (value: string) => void;
|
|
23
|
+
autoClearSearchValue?: boolean;
|
|
21
24
|
}
|
|
22
25
|
export type ShowCheckedStrategy = typeof SHOW_PARENT | typeof SHOW_CHILD;
|
|
23
26
|
interface BaseCascaderProps<OptionType extends DefaultOptionType = DefaultOptionType, ValueField extends keyof OptionType = keyof OptionType> extends Omit<BaseSelectPropsWithoutPrivate, 'tokenSeparators' | 'labelInValue' | 'mode' | 'showSearch'> {
|
|
@@ -30,9 +33,12 @@ interface BaseCascaderProps<OptionType extends DefaultOptionType = DefaultOption
|
|
|
30
33
|
displayRender?: (label: string[], selectedOptions?: OptionType[]) => React.ReactNode;
|
|
31
34
|
checkable?: boolean | React.ReactNode;
|
|
32
35
|
showCheckedStrategy?: ShowCheckedStrategy;
|
|
36
|
+
/** @deprecated please use showSearch.autoClearSearchValue */
|
|
33
37
|
autoClearSearchValue?: boolean;
|
|
34
|
-
showSearch?: boolean |
|
|
38
|
+
showSearch?: boolean | SearchConfig<OptionType>;
|
|
39
|
+
/** @deprecated please use showSearch.searchValue */
|
|
35
40
|
searchValue?: string;
|
|
41
|
+
/** @deprecated please use showSearch.onSearch */
|
|
36
42
|
onSearch?: (value: string) => void;
|
|
37
43
|
expandTrigger?: 'hover' | 'click';
|
|
38
44
|
options?: OptionType[];
|
|
@@ -81,10 +87,8 @@ export type InternalCascaderProps = Omit<CascaderProps, 'onChange' | 'value' | '
|
|
|
81
87
|
onChange?: (value: InternalValueType, selectOptions: BaseOptionType[] | BaseOptionType[][]) => void;
|
|
82
88
|
};
|
|
83
89
|
export type CascaderRef = Omit<BaseSelectRef, 'scrollTo'>;
|
|
84
|
-
declare const Cascader: (<OptionType extends DefaultOptionType = DefaultOptionType, ValueField extends keyof OptionType = keyof OptionType, Multiple extends React.ReactNode = false>(props: CascaderProps<OptionType, ValueField, Multiple
|
|
85
|
-
|
|
86
|
-
} & {
|
|
87
|
-
ref?: React.Ref<CascaderRef> | undefined;
|
|
90
|
+
declare const Cascader: (<OptionType extends DefaultOptionType = DefaultOptionType, ValueField extends keyof OptionType = keyof OptionType, Multiple extends React.ReactNode = false>(props: React.PropsWithChildren<CascaderProps<OptionType, ValueField, Multiple>> & {
|
|
91
|
+
ref?: React.Ref<CascaderRef>;
|
|
88
92
|
}) => React.ReactElement) & {
|
|
89
93
|
displayName?: string | undefined;
|
|
90
94
|
SHOW_PARENT: typeof SHOW_PARENT;
|
package/es/Cascader.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
import { BaseSelect } from '@rc-component/select';
|
|
3
|
-
import useId from "@rc-component/
|
|
3
|
+
import useId from "@rc-component/util/es/hooks/useId";
|
|
4
4
|
import useEvent from "@rc-component/util/es/hooks/useEvent";
|
|
5
5
|
import useMergedState from "@rc-component/util/es/hooks/useMergedState";
|
|
6
6
|
import * as React from 'react';
|
|
@@ -31,9 +31,6 @@ const Cascader = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
31
31
|
displayRender,
|
|
32
32
|
checkable,
|
|
33
33
|
// Search
|
|
34
|
-
autoClearSearchValue = true,
|
|
35
|
-
searchValue,
|
|
36
|
-
onSearch,
|
|
37
34
|
showSearch,
|
|
38
35
|
// Trigger
|
|
39
36
|
expandTrigger,
|
|
@@ -77,6 +74,12 @@ const Cascader = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
77
74
|
const [mergedOptions, getPathKeyEntities, getValueByKeyPath] = useOptions(mergedFieldNames, options);
|
|
78
75
|
|
|
79
76
|
// =========================== Search ===========================
|
|
77
|
+
const [mergedShowSearch, searchConfig] = useSearchConfig(showSearch, props);
|
|
78
|
+
const {
|
|
79
|
+
autoClearSearchValue = true,
|
|
80
|
+
searchValue,
|
|
81
|
+
onSearch
|
|
82
|
+
} = searchConfig;
|
|
80
83
|
const [mergedSearchValue, setSearchValue] = useMergedState('', {
|
|
81
84
|
value: searchValue,
|
|
82
85
|
postState: search => search || ''
|
|
@@ -87,7 +90,6 @@ const Cascader = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
87
90
|
onSearch(searchText);
|
|
88
91
|
}
|
|
89
92
|
};
|
|
90
|
-
const [mergedShowSearch, searchConfig] = useSearchConfig(showSearch);
|
|
91
93
|
const searchOptions = useSearchOptions(mergedSearchValue, mergedOptions, mergedFieldNames, popupPrefixCls || prefixCls, searchConfig, changeOnSelect || multiple);
|
|
92
94
|
|
|
93
95
|
// =========================== Values ===========================
|
package/es/OptionList/List.js
CHANGED
|
@@ -155,7 +155,6 @@ const RawOptionList = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
155
155
|
const cellKeyPath = toPathKey(cellPath);
|
|
156
156
|
const ele = containerRef.current?.querySelector(`li[data-path-key="${cellKeyPath.replace(/\\{0,2}"/g, '\\"')}"]` // matches unescaped double quotes
|
|
157
157
|
);
|
|
158
|
-
|
|
159
158
|
if (ele) {
|
|
160
159
|
scrollIntoParentView(ele);
|
|
161
160
|
}
|
|
@@ -19,7 +19,6 @@ const useActive = (multiple, open) => {
|
|
|
19
19
|
}, /* eslint-disable react-hooks/exhaustive-deps */
|
|
20
20
|
[open, firstValueCells]
|
|
21
21
|
/* eslint-enable react-hooks/exhaustive-deps */);
|
|
22
|
-
|
|
23
22
|
return [activeValueCells, setActiveValueCells];
|
|
24
23
|
};
|
|
25
24
|
export default useActive;
|
|
@@ -2,7 +2,7 @@ import type { RefOptionListProps } from '@rc-component/select/lib/OptionList';
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import type { DefaultOptionType, InternalFieldNames, LegacyKey, SingleValueType } from '../Cascader';
|
|
4
4
|
declare const _default: (ref: React.Ref<RefOptionListProps>, options: DefaultOptionType[], fieldNames: InternalFieldNames, activeValueCells: LegacyKey[], setActiveValueCells: (activeValueCells: LegacyKey[]) => void, onKeyBoardSelect: (valueCells: SingleValueType, option: DefaultOptionType) => void, contextProps: {
|
|
5
|
-
direction?: "
|
|
5
|
+
direction?: "rtl" | "ltr" | undefined;
|
|
6
6
|
searchValue: string;
|
|
7
7
|
toggleOpen: (open?: boolean) => void;
|
|
8
8
|
open?: boolean | undefined;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { CascaderProps,
|
|
2
|
-
export default function useSearchConfig(showSearch?: CascaderProps['showSearch']): [boolean,
|
|
1
|
+
import type { CascaderProps, SearchConfig } from '../Cascader';
|
|
2
|
+
export default function useSearchConfig(showSearch?: CascaderProps['showSearch'], props?: any): [boolean, SearchConfig<import("../Cascader").DefaultOptionType, string>];
|
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
import warning from "@rc-component/util/es/warning";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
// Convert `showSearch` to unique config
|
|
4
|
-
export default function useSearchConfig(showSearch) {
|
|
4
|
+
export default function useSearchConfig(showSearch, props) {
|
|
5
|
+
const {
|
|
6
|
+
autoClearSearchValue,
|
|
7
|
+
searchValue,
|
|
8
|
+
onSearch
|
|
9
|
+
} = props;
|
|
5
10
|
return React.useMemo(() => {
|
|
6
11
|
if (!showSearch) {
|
|
7
12
|
return [false, {}];
|
|
8
13
|
}
|
|
9
14
|
let searchConfig = {
|
|
10
15
|
matchInputWidth: true,
|
|
11
|
-
limit: 50
|
|
16
|
+
limit: 50,
|
|
17
|
+
autoClearSearchValue,
|
|
18
|
+
searchValue,
|
|
19
|
+
onSearch
|
|
12
20
|
};
|
|
13
21
|
if (showSearch && typeof showSearch === 'object') {
|
|
14
22
|
searchConfig = {
|
|
@@ -23,5 +31,5 @@ export default function useSearchConfig(showSearch) {
|
|
|
23
31
|
}
|
|
24
32
|
}
|
|
25
33
|
return [true, searchConfig];
|
|
26
|
-
}, [showSearch]);
|
|
34
|
+
}, [showSearch, autoClearSearchValue, searchValue, onSearch]);
|
|
27
35
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DefaultOptionType, InternalFieldNames,
|
|
1
|
+
import type { DefaultOptionType, InternalFieldNames, SearchConfig } from '../Cascader';
|
|
2
2
|
export declare const SEARCH_MARK = "__rc_cascader_search_mark__";
|
|
3
|
-
declare const useSearchOptions: (search: string, options: DefaultOptionType[], fieldNames: InternalFieldNames, prefixCls: string, config:
|
|
3
|
+
declare const useSearchOptions: (search: string, options: DefaultOptionType[], fieldNames: InternalFieldNames, prefixCls: string, config: SearchConfig, enableHalfPath?: boolean) => DefaultOptionType[];
|
|
4
4
|
export default useSearchOptions;
|
package/es/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Cascader from './Cascader';
|
|
2
2
|
import Panel from './Panel';
|
|
3
|
-
export type { BaseOptionType, DefaultOptionType, CascaderProps, FieldNames,
|
|
3
|
+
export type { BaseOptionType, DefaultOptionType, CascaderProps, FieldNames, SearchConfig, CascaderRef, } from './Cascader';
|
|
4
4
|
export { Panel };
|
|
5
5
|
export default Cascader;
|
package/lib/Cascader.d.ts
CHANGED
|
@@ -12,12 +12,15 @@ export interface BaseOptionType {
|
|
|
12
12
|
children?: DefaultOptionType[];
|
|
13
13
|
}
|
|
14
14
|
export type DefaultOptionType = BaseOptionType & Record<string, any>;
|
|
15
|
-
export interface
|
|
15
|
+
export interface SearchConfig<OptionType extends DefaultOptionType = DefaultOptionType, ValueField extends keyof OptionType = keyof OptionType> {
|
|
16
16
|
filter?: (inputValue: string, options: OptionType[], fieldNames: FieldNames<OptionType, ValueField>) => boolean;
|
|
17
17
|
render?: (inputValue: string, path: OptionType[], prefixCls: string, fieldNames: FieldNames<OptionType, ValueField>) => React.ReactNode;
|
|
18
18
|
sort?: (a: OptionType[], b: OptionType[], inputValue: string, fieldNames: FieldNames<OptionType, ValueField>) => number;
|
|
19
19
|
matchInputWidth?: boolean;
|
|
20
20
|
limit?: number | false;
|
|
21
|
+
searchValue?: string;
|
|
22
|
+
onSearch?: (value: string) => void;
|
|
23
|
+
autoClearSearchValue?: boolean;
|
|
21
24
|
}
|
|
22
25
|
export type ShowCheckedStrategy = typeof SHOW_PARENT | typeof SHOW_CHILD;
|
|
23
26
|
interface BaseCascaderProps<OptionType extends DefaultOptionType = DefaultOptionType, ValueField extends keyof OptionType = keyof OptionType> extends Omit<BaseSelectPropsWithoutPrivate, 'tokenSeparators' | 'labelInValue' | 'mode' | 'showSearch'> {
|
|
@@ -30,9 +33,12 @@ interface BaseCascaderProps<OptionType extends DefaultOptionType = DefaultOption
|
|
|
30
33
|
displayRender?: (label: string[], selectedOptions?: OptionType[]) => React.ReactNode;
|
|
31
34
|
checkable?: boolean | React.ReactNode;
|
|
32
35
|
showCheckedStrategy?: ShowCheckedStrategy;
|
|
36
|
+
/** @deprecated please use showSearch.autoClearSearchValue */
|
|
33
37
|
autoClearSearchValue?: boolean;
|
|
34
|
-
showSearch?: boolean |
|
|
38
|
+
showSearch?: boolean | SearchConfig<OptionType>;
|
|
39
|
+
/** @deprecated please use showSearch.searchValue */
|
|
35
40
|
searchValue?: string;
|
|
41
|
+
/** @deprecated please use showSearch.onSearch */
|
|
36
42
|
onSearch?: (value: string) => void;
|
|
37
43
|
expandTrigger?: 'hover' | 'click';
|
|
38
44
|
options?: OptionType[];
|
|
@@ -81,10 +87,8 @@ export type InternalCascaderProps = Omit<CascaderProps, 'onChange' | 'value' | '
|
|
|
81
87
|
onChange?: (value: InternalValueType, selectOptions: BaseOptionType[] | BaseOptionType[][]) => void;
|
|
82
88
|
};
|
|
83
89
|
export type CascaderRef = Omit<BaseSelectRef, 'scrollTo'>;
|
|
84
|
-
declare const Cascader: (<OptionType extends DefaultOptionType = DefaultOptionType, ValueField extends keyof OptionType = keyof OptionType, Multiple extends React.ReactNode = false>(props: CascaderProps<OptionType, ValueField, Multiple
|
|
85
|
-
|
|
86
|
-
} & {
|
|
87
|
-
ref?: React.Ref<CascaderRef> | undefined;
|
|
90
|
+
declare const Cascader: (<OptionType extends DefaultOptionType = DefaultOptionType, ValueField extends keyof OptionType = keyof OptionType, Multiple extends React.ReactNode = false>(props: React.PropsWithChildren<CascaderProps<OptionType, ValueField, Multiple>> & {
|
|
91
|
+
ref?: React.Ref<CascaderRef>;
|
|
88
92
|
}) => React.ReactElement) & {
|
|
89
93
|
displayName?: string | undefined;
|
|
90
94
|
SHOW_PARENT: typeof SHOW_PARENT;
|
package/lib/Cascader.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _select = require("@rc-component/select");
|
|
8
|
-
var _useId = _interopRequireDefault(require("@rc-component/
|
|
8
|
+
var _useId = _interopRequireDefault(require("@rc-component/util/lib/hooks/useId"));
|
|
9
9
|
var _useEvent = _interopRequireDefault(require("@rc-component/util/lib/hooks/useEvent"));
|
|
10
10
|
var _useMergedState = _interopRequireDefault(require("@rc-component/util/lib/hooks/useMergedState"));
|
|
11
11
|
var React = _interopRequireWildcard(require("react"));
|
|
@@ -40,9 +40,6 @@ const Cascader = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
40
40
|
displayRender,
|
|
41
41
|
checkable,
|
|
42
42
|
// Search
|
|
43
|
-
autoClearSearchValue = true,
|
|
44
|
-
searchValue,
|
|
45
|
-
onSearch,
|
|
46
43
|
showSearch,
|
|
47
44
|
// Trigger
|
|
48
45
|
expandTrigger,
|
|
@@ -86,6 +83,12 @@ const Cascader = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
86
83
|
const [mergedOptions, getPathKeyEntities, getValueByKeyPath] = (0, _useOptions.default)(mergedFieldNames, options);
|
|
87
84
|
|
|
88
85
|
// =========================== Search ===========================
|
|
86
|
+
const [mergedShowSearch, searchConfig] = (0, _useSearchConfig.default)(showSearch, props);
|
|
87
|
+
const {
|
|
88
|
+
autoClearSearchValue = true,
|
|
89
|
+
searchValue,
|
|
90
|
+
onSearch
|
|
91
|
+
} = searchConfig;
|
|
89
92
|
const [mergedSearchValue, setSearchValue] = (0, _useMergedState.default)('', {
|
|
90
93
|
value: searchValue,
|
|
91
94
|
postState: search => search || ''
|
|
@@ -96,7 +99,6 @@ const Cascader = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
96
99
|
onSearch(searchText);
|
|
97
100
|
}
|
|
98
101
|
};
|
|
99
|
-
const [mergedShowSearch, searchConfig] = (0, _useSearchConfig.default)(showSearch);
|
|
100
102
|
const searchOptions = (0, _useSearchOptions.default)(mergedSearchValue, mergedOptions, mergedFieldNames, popupPrefixCls || prefixCls, searchConfig, changeOnSelect || multiple);
|
|
101
103
|
|
|
102
104
|
// =========================== Values ===========================
|
package/lib/OptionList/List.js
CHANGED
|
@@ -163,7 +163,6 @@ const RawOptionList = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
163
163
|
const cellKeyPath = (0, _commonUtil.toPathKey)(cellPath);
|
|
164
164
|
const ele = containerRef.current?.querySelector(`li[data-path-key="${cellKeyPath.replace(/\\{0,2}"/g, '\\"')}"]` // matches unescaped double quotes
|
|
165
165
|
);
|
|
166
|
-
|
|
167
166
|
if (ele) {
|
|
168
167
|
(0, _commonUtil.scrollIntoParentView)(ele);
|
|
169
168
|
}
|
|
@@ -28,7 +28,6 @@ const useActive = (multiple, open) => {
|
|
|
28
28
|
}, /* eslint-disable react-hooks/exhaustive-deps */
|
|
29
29
|
[open, firstValueCells]
|
|
30
30
|
/* eslint-enable react-hooks/exhaustive-deps */);
|
|
31
|
-
|
|
32
31
|
return [activeValueCells, setActiveValueCells];
|
|
33
32
|
};
|
|
34
33
|
var _default = exports.default = useActive;
|
|
@@ -2,7 +2,7 @@ import type { RefOptionListProps } from '@rc-component/select/lib/OptionList';
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import type { DefaultOptionType, InternalFieldNames, LegacyKey, SingleValueType } from '../Cascader';
|
|
4
4
|
declare const _default: (ref: React.Ref<RefOptionListProps>, options: DefaultOptionType[], fieldNames: InternalFieldNames, activeValueCells: LegacyKey[], setActiveValueCells: (activeValueCells: LegacyKey[]) => void, onKeyBoardSelect: (valueCells: SingleValueType, option: DefaultOptionType) => void, contextProps: {
|
|
5
|
-
direction?: "
|
|
5
|
+
direction?: "rtl" | "ltr" | undefined;
|
|
6
6
|
searchValue: string;
|
|
7
7
|
toggleOpen: (open?: boolean) => void;
|
|
8
8
|
open?: boolean | undefined;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { CascaderProps,
|
|
2
|
-
export default function useSearchConfig(showSearch?: CascaderProps['showSearch']): [boolean,
|
|
1
|
+
import type { CascaderProps, SearchConfig } from '../Cascader';
|
|
2
|
+
export default function useSearchConfig(showSearch?: CascaderProps['showSearch'], props?: any): [boolean, SearchConfig<import("../Cascader").DefaultOptionType, string>];
|
|
@@ -10,14 +10,22 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
10
10
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
12
|
// Convert `showSearch` to unique config
|
|
13
|
-
function useSearchConfig(showSearch) {
|
|
13
|
+
function useSearchConfig(showSearch, props) {
|
|
14
|
+
const {
|
|
15
|
+
autoClearSearchValue,
|
|
16
|
+
searchValue,
|
|
17
|
+
onSearch
|
|
18
|
+
} = props;
|
|
14
19
|
return React.useMemo(() => {
|
|
15
20
|
if (!showSearch) {
|
|
16
21
|
return [false, {}];
|
|
17
22
|
}
|
|
18
23
|
let searchConfig = {
|
|
19
24
|
matchInputWidth: true,
|
|
20
|
-
limit: 50
|
|
25
|
+
limit: 50,
|
|
26
|
+
autoClearSearchValue,
|
|
27
|
+
searchValue,
|
|
28
|
+
onSearch
|
|
21
29
|
};
|
|
22
30
|
if (showSearch && typeof showSearch === 'object') {
|
|
23
31
|
searchConfig = {
|
|
@@ -32,5 +40,5 @@ function useSearchConfig(showSearch) {
|
|
|
32
40
|
}
|
|
33
41
|
}
|
|
34
42
|
return [true, searchConfig];
|
|
35
|
-
}, [showSearch]);
|
|
43
|
+
}, [showSearch, autoClearSearchValue, searchValue, onSearch]);
|
|
36
44
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DefaultOptionType, InternalFieldNames,
|
|
1
|
+
import type { DefaultOptionType, InternalFieldNames, SearchConfig } from '../Cascader';
|
|
2
2
|
export declare const SEARCH_MARK = "__rc_cascader_search_mark__";
|
|
3
|
-
declare const useSearchOptions: (search: string, options: DefaultOptionType[], fieldNames: InternalFieldNames, prefixCls: string, config:
|
|
3
|
+
declare const useSearchOptions: (search: string, options: DefaultOptionType[], fieldNames: InternalFieldNames, prefixCls: string, config: SearchConfig, enableHalfPath?: boolean) => DefaultOptionType[];
|
|
4
4
|
export default useSearchOptions;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Cascader from './Cascader';
|
|
2
2
|
import Panel from './Panel';
|
|
3
|
-
export type { BaseOptionType, DefaultOptionType, CascaderProps, FieldNames,
|
|
3
|
+
export type { BaseOptionType, DefaultOptionType, CascaderProps, FieldNames, SearchConfig, CascaderRef, } from './Cascader';
|
|
4
4
|
export { Panel };
|
|
5
5
|
export default Cascader;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rc-component/cascader",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "cascade select ui component for react",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"test": "rc-test"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@rc-component/select": "~1.0.
|
|
46
|
+
"@rc-component/select": "~1.0.7",
|
|
47
47
|
"@rc-component/tree": "~1.0.0",
|
|
48
48
|
"@rc-component/util": "^1.2.1",
|
|
49
49
|
"classnames": "^2.3.1"
|