rsuite 4.10.10 → 4.11.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/CHANGELOG.md +12 -0
- package/dist/rsuite.js +1 -1
- package/dist/rsuite.min.js +1 -1
- package/dist/rsuite.min.js.map +1 -1
- package/es/CheckPicker/CheckPicker.d.ts +10 -3
- package/es/CheckTreePicker/CheckTreePicker.js +7 -3
- package/es/InputPicker/InputPicker.d.ts +2 -2
- package/es/SelectPicker/SelectPicker.d.ts +9 -8
- package/es/TagPicker/TagPicker.d.ts +10 -3
- package/lib/CheckPicker/CheckPicker.d.ts +10 -3
- package/lib/CheckTreePicker/CheckTreePicker.js +7 -3
- package/lib/InputPicker/InputPicker.d.ts +2 -2
- package/lib/SelectPicker/SelectPicker.d.ts +9 -8
- package/lib/TagPicker/TagPicker.d.ts +10 -3
- package/package.json +1 -1
- package/src/CheckPicker/CheckPicker.d.ts +10 -3
- package/src/CheckTreePicker/CheckTreePicker.tsx +4 -3
- package/src/CheckTreePicker/test/CheckTreePickerSpec.js +58 -38
- package/src/InputPicker/InputPicker.d.ts +2 -2
- package/src/SelectPicker/SelectPicker.d.ts +9 -8
- package/src/SelectPicker/test/SelectPickerSpec.js +9 -7
- package/src/TagPicker/TagPicker.d.ts +10 -3
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
-
import { FormControlPickerProps } from '../@types/common';
|
|
4
|
-
import {
|
|
3
|
+
import { FormControlPickerProps, ItemDataType } from '../@types/common';
|
|
4
|
+
import { BaseSelectProps } from '../SelectPicker/SelectPicker.d';
|
|
5
5
|
|
|
6
|
-
export interface CheckPickerProps extends FormControlPickerProps<any[]>,
|
|
6
|
+
export interface CheckPickerProps extends FormControlPickerProps<any[]>, BaseSelectProps {
|
|
7
7
|
/** Top the selected option in the options */
|
|
8
8
|
sticky?: boolean;
|
|
9
9
|
|
|
10
10
|
/** A picker that can be counted */
|
|
11
11
|
countable?: boolean;
|
|
12
|
+
|
|
13
|
+
/** Custom render selected items */
|
|
14
|
+
renderValue?: (
|
|
15
|
+
value: any[],
|
|
16
|
+
item: ItemDataType[],
|
|
17
|
+
selectedElement: React.ReactNode
|
|
18
|
+
) => React.ReactNode;
|
|
12
19
|
}
|
|
13
20
|
|
|
14
21
|
declare const CheckPicker: React.ComponentType<CheckPickerProps>;
|
|
@@ -427,7 +427,7 @@ function (_React$Component) {
|
|
|
427
427
|
_this.unserializeLists({
|
|
428
428
|
check: nextValue,
|
|
429
429
|
expand: _nextExpandItemValues
|
|
430
|
-
}, _props);
|
|
430
|
+
}, _props, true);
|
|
431
431
|
|
|
432
432
|
_this.state = {
|
|
433
433
|
data: data,
|
|
@@ -901,13 +901,17 @@ function (_React$Component) {
|
|
|
901
901
|
return list;
|
|
902
902
|
};
|
|
903
903
|
|
|
904
|
-
_proto.unserializeLists = function unserializeLists(lists, nextProps) {
|
|
904
|
+
_proto.unserializeLists = function unserializeLists(lists, nextProps, initial) {
|
|
905
905
|
var _this8 = this;
|
|
906
906
|
|
|
907
907
|
if (nextProps === void 0) {
|
|
908
908
|
nextProps = this.props;
|
|
909
909
|
}
|
|
910
910
|
|
|
911
|
+
if (initial === void 0) {
|
|
912
|
+
initial = false;
|
|
913
|
+
}
|
|
914
|
+
|
|
911
915
|
var _nextProps = nextProps,
|
|
912
916
|
valueKey = _nextProps.valueKey,
|
|
913
917
|
cascade = _nextProps.cascade,
|
|
@@ -945,7 +949,7 @@ function (_React$Component) {
|
|
|
945
949
|
}
|
|
946
950
|
});
|
|
947
951
|
} else {
|
|
948
|
-
_this8.nodes[refKey][listKey] = expandAll;
|
|
952
|
+
_this8.nodes[refKey][listKey] = initial ? expandAll : false;
|
|
949
953
|
}
|
|
950
954
|
}
|
|
951
955
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
3
|
import { FormControlPickerProps } from '../@types/common';
|
|
4
|
-
import {
|
|
4
|
+
import { BaseSelectProps } from '../SelectPicker/SelectPicker.d';
|
|
5
5
|
import { TagProps } from '../Tag/Tag.d';
|
|
6
6
|
|
|
7
|
-
export interface InputPickerProps extends FormControlPickerProps<any>,
|
|
7
|
+
export interface InputPickerProps extends FormControlPickerProps<any>, BaseSelectProps {
|
|
8
8
|
/** Settings can create new options */
|
|
9
9
|
creatable?: boolean;
|
|
10
10
|
|
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { FormControlPickerProps, ItemDataType } from '../@types/common';
|
|
4
4
|
import { ListProps } from 'react-virtualized/dist/commonjs/List';
|
|
5
5
|
|
|
6
|
-
export interface
|
|
6
|
+
export interface BaseSelectProps {
|
|
7
7
|
/** Set group condition key in data */
|
|
8
8
|
groupBy?: string;
|
|
9
9
|
|
|
@@ -22,13 +22,6 @@ export interface SelectProps<ValueType = any> {
|
|
|
22
22
|
/** Custom render menu group */
|
|
23
23
|
renderMenuGroup?: (title: React.ReactNode, item: ItemDataType) => React.ReactNode;
|
|
24
24
|
|
|
25
|
-
/** Custom render selected items */
|
|
26
|
-
renderValue?: (
|
|
27
|
-
value: ValueType,
|
|
28
|
-
item: ItemDataType | ItemDataType[],
|
|
29
|
-
selectedElement: React.ReactNode
|
|
30
|
-
) => React.ReactNode;
|
|
31
|
-
|
|
32
25
|
/** Called when the option is selected */
|
|
33
26
|
onSelect?: (value: any, item: ItemDataType, event: React.SyntheticEvent<any>) => void;
|
|
34
27
|
|
|
@@ -53,6 +46,14 @@ export interface SelectProps<ValueType = any> {
|
|
|
53
46
|
/** Custom search rules. */
|
|
54
47
|
searchBy?: (keyword: string, label: React.ReactNode, item: ItemDataType) => boolean;
|
|
55
48
|
}
|
|
49
|
+
export interface SelectProps<ValueType> extends BaseSelectProps {
|
|
50
|
+
/** Custom render selected items */
|
|
51
|
+
renderValue?: (
|
|
52
|
+
value: ValueType,
|
|
53
|
+
item: ItemDataType,
|
|
54
|
+
selectedElement: React.ReactNode
|
|
55
|
+
) => React.ReactNode;
|
|
56
|
+
}
|
|
56
57
|
|
|
57
58
|
export interface SelectPickerProps extends FormControlPickerProps<any>, SelectProps<any> {}
|
|
58
59
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
-
import { FormControlPickerProps } from '../@types/common';
|
|
4
|
-
import {
|
|
3
|
+
import { FormControlPickerProps, ItemDataType } from '../@types/common';
|
|
4
|
+
import { BaseSelectProps } from '../SelectPicker/SelectPicker.d';
|
|
5
5
|
import { TagProps } from '../Tag/Tag.d';
|
|
6
6
|
|
|
7
|
-
export interface TagPickerProps extends FormControlPickerProps,
|
|
7
|
+
export interface TagPickerProps extends FormControlPickerProps, BaseSelectProps {
|
|
8
8
|
/** Option to cache value when searching asynchronously */
|
|
9
9
|
cacheData?: any[];
|
|
10
10
|
|
|
@@ -16,6 +16,13 @@ export interface TagPickerProps extends FormControlPickerProps, SelectProps<any[
|
|
|
16
16
|
* https://github.com/rsuite/rsuite/blob/master/src/Tag/Tag.d.ts
|
|
17
17
|
*/
|
|
18
18
|
tagProps?: TagProps;
|
|
19
|
+
|
|
20
|
+
/** Custom render selected items */
|
|
21
|
+
renderValue?: (
|
|
22
|
+
value: any[],
|
|
23
|
+
item: ItemDataType[],
|
|
24
|
+
selectedElement: React.ReactNode
|
|
25
|
+
) => React.ReactNode;
|
|
19
26
|
}
|
|
20
27
|
|
|
21
28
|
declare const TagPicker: React.ComponentType<TagPickerProps>;
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
-
import { FormControlPickerProps } from '../@types/common';
|
|
4
|
-
import {
|
|
3
|
+
import { FormControlPickerProps, ItemDataType } from '../@types/common';
|
|
4
|
+
import { BaseSelectProps } from '../SelectPicker/SelectPicker.d';
|
|
5
5
|
|
|
6
|
-
export interface CheckPickerProps extends FormControlPickerProps<any[]>,
|
|
6
|
+
export interface CheckPickerProps extends FormControlPickerProps<any[]>, BaseSelectProps {
|
|
7
7
|
/** Top the selected option in the options */
|
|
8
8
|
sticky?: boolean;
|
|
9
9
|
|
|
10
10
|
/** A picker that can be counted */
|
|
11
11
|
countable?: boolean;
|
|
12
|
+
|
|
13
|
+
/** Custom render selected items */
|
|
14
|
+
renderValue?: (
|
|
15
|
+
value: any[],
|
|
16
|
+
item: ItemDataType[],
|
|
17
|
+
selectedElement: React.ReactNode
|
|
18
|
+
) => React.ReactNode;
|
|
12
19
|
}
|
|
13
20
|
|
|
14
21
|
declare const CheckPicker: React.ComponentType<CheckPickerProps>;
|
|
@@ -461,7 +461,7 @@ function (_React$Component) {
|
|
|
461
461
|
_this.unserializeLists({
|
|
462
462
|
check: nextValue,
|
|
463
463
|
expand: _nextExpandItemValues
|
|
464
|
-
}, _props);
|
|
464
|
+
}, _props, true);
|
|
465
465
|
|
|
466
466
|
_this.state = {
|
|
467
467
|
data: data,
|
|
@@ -935,13 +935,17 @@ function (_React$Component) {
|
|
|
935
935
|
return list;
|
|
936
936
|
};
|
|
937
937
|
|
|
938
|
-
_proto.unserializeLists = function unserializeLists(lists, nextProps) {
|
|
938
|
+
_proto.unserializeLists = function unserializeLists(lists, nextProps, initial) {
|
|
939
939
|
var _this8 = this;
|
|
940
940
|
|
|
941
941
|
if (nextProps === void 0) {
|
|
942
942
|
nextProps = this.props;
|
|
943
943
|
}
|
|
944
944
|
|
|
945
|
+
if (initial === void 0) {
|
|
946
|
+
initial = false;
|
|
947
|
+
}
|
|
948
|
+
|
|
945
949
|
var _nextProps = nextProps,
|
|
946
950
|
valueKey = _nextProps.valueKey,
|
|
947
951
|
cascade = _nextProps.cascade,
|
|
@@ -979,7 +983,7 @@ function (_React$Component) {
|
|
|
979
983
|
}
|
|
980
984
|
});
|
|
981
985
|
} else {
|
|
982
|
-
_this8.nodes[refKey][listKey] = expandAll;
|
|
986
|
+
_this8.nodes[refKey][listKey] = initial ? expandAll : false;
|
|
983
987
|
}
|
|
984
988
|
}
|
|
985
989
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
3
|
import { FormControlPickerProps } from '../@types/common';
|
|
4
|
-
import {
|
|
4
|
+
import { BaseSelectProps } from '../SelectPicker/SelectPicker.d';
|
|
5
5
|
import { TagProps } from '../Tag/Tag.d';
|
|
6
6
|
|
|
7
|
-
export interface InputPickerProps extends FormControlPickerProps<any>,
|
|
7
|
+
export interface InputPickerProps extends FormControlPickerProps<any>, BaseSelectProps {
|
|
8
8
|
/** Settings can create new options */
|
|
9
9
|
creatable?: boolean;
|
|
10
10
|
|
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { FormControlPickerProps, ItemDataType } from '../@types/common';
|
|
4
4
|
import { ListProps } from 'react-virtualized/dist/commonjs/List';
|
|
5
5
|
|
|
6
|
-
export interface
|
|
6
|
+
export interface BaseSelectProps {
|
|
7
7
|
/** Set group condition key in data */
|
|
8
8
|
groupBy?: string;
|
|
9
9
|
|
|
@@ -22,13 +22,6 @@ export interface SelectProps<ValueType = any> {
|
|
|
22
22
|
/** Custom render menu group */
|
|
23
23
|
renderMenuGroup?: (title: React.ReactNode, item: ItemDataType) => React.ReactNode;
|
|
24
24
|
|
|
25
|
-
/** Custom render selected items */
|
|
26
|
-
renderValue?: (
|
|
27
|
-
value: ValueType,
|
|
28
|
-
item: ItemDataType | ItemDataType[],
|
|
29
|
-
selectedElement: React.ReactNode
|
|
30
|
-
) => React.ReactNode;
|
|
31
|
-
|
|
32
25
|
/** Called when the option is selected */
|
|
33
26
|
onSelect?: (value: any, item: ItemDataType, event: React.SyntheticEvent<any>) => void;
|
|
34
27
|
|
|
@@ -53,6 +46,14 @@ export interface SelectProps<ValueType = any> {
|
|
|
53
46
|
/** Custom search rules. */
|
|
54
47
|
searchBy?: (keyword: string, label: React.ReactNode, item: ItemDataType) => boolean;
|
|
55
48
|
}
|
|
49
|
+
export interface SelectProps<ValueType> extends BaseSelectProps {
|
|
50
|
+
/** Custom render selected items */
|
|
51
|
+
renderValue?: (
|
|
52
|
+
value: ValueType,
|
|
53
|
+
item: ItemDataType,
|
|
54
|
+
selectedElement: React.ReactNode
|
|
55
|
+
) => React.ReactNode;
|
|
56
|
+
}
|
|
56
57
|
|
|
57
58
|
export interface SelectPickerProps extends FormControlPickerProps<any>, SelectProps<any> {}
|
|
58
59
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
-
import { FormControlPickerProps } from '../@types/common';
|
|
4
|
-
import {
|
|
3
|
+
import { FormControlPickerProps, ItemDataType } from '../@types/common';
|
|
4
|
+
import { BaseSelectProps } from '../SelectPicker/SelectPicker.d';
|
|
5
5
|
import { TagProps } from '../Tag/Tag.d';
|
|
6
6
|
|
|
7
|
-
export interface TagPickerProps extends FormControlPickerProps,
|
|
7
|
+
export interface TagPickerProps extends FormControlPickerProps, BaseSelectProps {
|
|
8
8
|
/** Option to cache value when searching asynchronously */
|
|
9
9
|
cacheData?: any[];
|
|
10
10
|
|
|
@@ -16,6 +16,13 @@ export interface TagPickerProps extends FormControlPickerProps, SelectProps<any[
|
|
|
16
16
|
* https://github.com/rsuite/rsuite/blob/master/src/Tag/Tag.d.ts
|
|
17
17
|
*/
|
|
18
18
|
tagProps?: TagProps;
|
|
19
|
+
|
|
20
|
+
/** Custom render selected items */
|
|
21
|
+
renderValue?: (
|
|
22
|
+
value: any[],
|
|
23
|
+
item: ItemDataType[],
|
|
24
|
+
selectedElement: React.ReactNode
|
|
25
|
+
) => React.ReactNode;
|
|
19
26
|
}
|
|
20
27
|
|
|
21
28
|
declare const TagPicker: React.ComponentType<TagPickerProps>;
|
package/package.json
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
-
import { FormControlPickerProps } from '../@types/common';
|
|
4
|
-
import {
|
|
3
|
+
import { FormControlPickerProps, ItemDataType } from '../@types/common';
|
|
4
|
+
import { BaseSelectProps } from '../SelectPicker/SelectPicker.d';
|
|
5
5
|
|
|
6
|
-
export interface CheckPickerProps extends FormControlPickerProps<any[]>,
|
|
6
|
+
export interface CheckPickerProps extends FormControlPickerProps<any[]>, BaseSelectProps {
|
|
7
7
|
/** Top the selected option in the options */
|
|
8
8
|
sticky?: boolean;
|
|
9
9
|
|
|
10
10
|
/** A picker that can be counted */
|
|
11
11
|
countable?: boolean;
|
|
12
|
+
|
|
13
|
+
/** Custom render selected items */
|
|
14
|
+
renderValue?: (
|
|
15
|
+
value: any[],
|
|
16
|
+
item: ItemDataType[],
|
|
17
|
+
selectedElement: React.ReactNode
|
|
18
|
+
) => React.ReactNode;
|
|
12
19
|
}
|
|
13
20
|
|
|
14
21
|
declare const CheckPicker: React.ComponentType<CheckPickerProps>;
|
|
@@ -144,7 +144,8 @@ class CheckTreePicker extends React.Component<CheckTreePickerProps, CheckTreePic
|
|
|
144
144
|
check: nextValue,
|
|
145
145
|
expand: nextExpandItemValues
|
|
146
146
|
},
|
|
147
|
-
props
|
|
147
|
+
props,
|
|
148
|
+
true
|
|
148
149
|
);
|
|
149
150
|
|
|
150
151
|
this.state = {
|
|
@@ -582,7 +583,7 @@ class CheckTreePicker extends React.Component<CheckTreePickerProps, CheckTreePic
|
|
|
582
583
|
return list;
|
|
583
584
|
}
|
|
584
585
|
|
|
585
|
-
unserializeLists(lists: any, nextProps: CheckTreePickerProps = this.props) {
|
|
586
|
+
unserializeLists(lists: any, nextProps: CheckTreePickerProps = this.props, initial = false) {
|
|
586
587
|
const { valueKey, cascade, uncheckableItemValues = [] } = nextProps;
|
|
587
588
|
const expandAll = getExpandAll(nextProps);
|
|
588
589
|
// Reset values to false
|
|
@@ -613,7 +614,7 @@ class CheckTreePicker extends React.Component<CheckTreePickerProps, CheckTreePic
|
|
|
613
614
|
}
|
|
614
615
|
});
|
|
615
616
|
} else {
|
|
616
|
-
this.nodes[refKey][listKey] = expandAll;
|
|
617
|
+
this.nodes[refKey][listKey] = initial ? expandAll : false;
|
|
617
618
|
}
|
|
618
619
|
}
|
|
619
620
|
});
|
|
@@ -567,45 +567,65 @@ describe('CheckTreePicker', () => {
|
|
|
567
567
|
4
|
|
568
568
|
);
|
|
569
569
|
});
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
570
|
+
|
|
571
|
+
describe('data change', () => {
|
|
572
|
+
const renderStart = () => {
|
|
573
|
+
const containerRef = React.createRef();
|
|
574
|
+
const Wrapper = () => {
|
|
575
|
+
const nextData = [
|
|
576
|
+
{
|
|
577
|
+
label: 'Fujian',
|
|
578
|
+
value: 3,
|
|
579
|
+
children: [
|
|
580
|
+
{
|
|
581
|
+
label: 'Fuzhou',
|
|
582
|
+
value: 36
|
|
583
|
+
}
|
|
584
|
+
]
|
|
585
|
+
},
|
|
586
|
+
{
|
|
587
|
+
label: 'Guangdong',
|
|
588
|
+
value: 4,
|
|
589
|
+
children: [
|
|
590
|
+
{
|
|
591
|
+
label: 'Guangzhou',
|
|
592
|
+
value: 45
|
|
593
|
+
}
|
|
594
|
+
]
|
|
595
|
+
}
|
|
596
|
+
];
|
|
597
|
+
const [willChangeData, setData] = useState(data);
|
|
598
|
+
const handleClick = () => {
|
|
599
|
+
setData(nextData);
|
|
600
|
+
};
|
|
601
|
+
return (
|
|
602
|
+
<div ref={containerRef}>
|
|
603
|
+
<button onClick={handleClick} className="change-data">
|
|
604
|
+
change data
|
|
605
|
+
</button>
|
|
606
|
+
<CheckTreePicker inline defaultExpandAll data={willChangeData} />
|
|
607
|
+
</div>
|
|
608
|
+
);
|
|
597
609
|
};
|
|
598
|
-
|
|
599
|
-
<
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
);
|
|
610
|
+
ReactTestUtils.act(() => {
|
|
611
|
+
ReactDOM.render(<Wrapper />, container);
|
|
612
|
+
});
|
|
613
|
+
return containerRef.current;
|
|
614
|
+
};
|
|
615
|
+
|
|
616
|
+
it('Should expand when has props defaultExpandAll', () => {
|
|
617
|
+
const container = renderStart();
|
|
618
|
+
ReactTestUtils.Simulate.click(container.querySelector('.change-data'));
|
|
619
|
+
expect(container.querySelectorAll('.rs-check-tree-open').length).to.equal(2);
|
|
620
|
+
});
|
|
621
|
+
|
|
622
|
+
it('Should be all closed, when click close icon', () => {
|
|
623
|
+
const container = renderStart();
|
|
624
|
+
ReactTestUtils.Simulate.click(container.querySelector('.change-data'));
|
|
625
|
+
container.querySelectorAll('.rs-check-tree-node-expand-icon').forEach(element => {
|
|
626
|
+
ReactTestUtils.Simulate.click(element);
|
|
627
|
+
});
|
|
628
|
+
expect(container.querySelectorAll('.rs-check-tree-open').length).to.equal(0);
|
|
606
629
|
});
|
|
607
|
-
const instance = getDOMNode(<Wrapper />);
|
|
608
|
-
ReactTestUtils.Simulate.click(instance.querySelector('.change-data'));
|
|
609
|
-
expect(instance.querySelectorAll('.rs-check-tree-open').length).to.equal(2);
|
|
610
630
|
});
|
|
611
631
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
3
|
import { FormControlPickerProps } from '../@types/common';
|
|
4
|
-
import {
|
|
4
|
+
import { BaseSelectProps } from '../SelectPicker/SelectPicker.d';
|
|
5
5
|
import { TagProps } from '../Tag/Tag.d';
|
|
6
6
|
|
|
7
|
-
export interface InputPickerProps extends FormControlPickerProps<any>,
|
|
7
|
+
export interface InputPickerProps extends FormControlPickerProps<any>, BaseSelectProps {
|
|
8
8
|
/** Settings can create new options */
|
|
9
9
|
creatable?: boolean;
|
|
10
10
|
|
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { FormControlPickerProps, ItemDataType } from '../@types/common';
|
|
4
4
|
import { ListProps } from 'react-virtualized/dist/commonjs/List';
|
|
5
5
|
|
|
6
|
-
export interface
|
|
6
|
+
export interface BaseSelectProps {
|
|
7
7
|
/** Set group condition key in data */
|
|
8
8
|
groupBy?: string;
|
|
9
9
|
|
|
@@ -22,13 +22,6 @@ export interface SelectProps<ValueType = any> {
|
|
|
22
22
|
/** Custom render menu group */
|
|
23
23
|
renderMenuGroup?: (title: React.ReactNode, item: ItemDataType) => React.ReactNode;
|
|
24
24
|
|
|
25
|
-
/** Custom render selected items */
|
|
26
|
-
renderValue?: (
|
|
27
|
-
value: ValueType,
|
|
28
|
-
item: ItemDataType | ItemDataType[],
|
|
29
|
-
selectedElement: React.ReactNode
|
|
30
|
-
) => React.ReactNode;
|
|
31
|
-
|
|
32
25
|
/** Called when the option is selected */
|
|
33
26
|
onSelect?: (value: any, item: ItemDataType, event: React.SyntheticEvent<any>) => void;
|
|
34
27
|
|
|
@@ -53,6 +46,14 @@ export interface SelectProps<ValueType = any> {
|
|
|
53
46
|
/** Custom search rules. */
|
|
54
47
|
searchBy?: (keyword: string, label: React.ReactNode, item: ItemDataType) => boolean;
|
|
55
48
|
}
|
|
49
|
+
export interface SelectProps<ValueType> extends BaseSelectProps {
|
|
50
|
+
/** Custom render selected items */
|
|
51
|
+
renderValue?: (
|
|
52
|
+
value: ValueType,
|
|
53
|
+
item: ItemDataType,
|
|
54
|
+
selectedElement: React.ReactNode
|
|
55
|
+
) => React.ReactNode;
|
|
56
|
+
}
|
|
56
57
|
|
|
57
58
|
export interface SelectPickerProps extends FormControlPickerProps<any>, SelectProps<any> {}
|
|
58
59
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
1
|
+
import React, { useState, useRef } from 'react';
|
|
2
2
|
import ReactDOM from 'react-dom';
|
|
3
3
|
import ReactTestUtils from 'react-dom/test-utils';
|
|
4
4
|
import { globalKey, getDOMNode, getInstance } from '@test/testUtils';
|
|
@@ -338,14 +338,15 @@ describe('SelectPicker', () => {
|
|
|
338
338
|
assert.ok(list[0].innerText, 'Louisa');
|
|
339
339
|
});
|
|
340
340
|
|
|
341
|
-
it
|
|
341
|
+
it('SearchWord should be reset when controlled and triggered off', done => {
|
|
342
342
|
let searchRef = '';
|
|
343
343
|
let onClose = null;
|
|
344
344
|
const promise = new Promise(resolve => {
|
|
345
345
|
onClose = resolve;
|
|
346
346
|
});
|
|
347
|
-
const Wrapper =
|
|
347
|
+
const Wrapper = () => {
|
|
348
348
|
const [search, setSearch] = useState(searchRef);
|
|
349
|
+
const containerRef = useRef();
|
|
349
350
|
searchRef = search;
|
|
350
351
|
const handleSearch = value => {
|
|
351
352
|
setSearch(value);
|
|
@@ -354,11 +355,11 @@ describe('SelectPicker', () => {
|
|
|
354
355
|
onClose();
|
|
355
356
|
};
|
|
356
357
|
return (
|
|
357
|
-
<div>
|
|
358
|
+
<div ref={containerRef}>
|
|
358
359
|
<button id="exit">exit</button>
|
|
359
360
|
<Dropdown
|
|
361
|
+
container={() => containerRef.current}
|
|
360
362
|
search={search}
|
|
361
|
-
ref={ref}
|
|
362
363
|
defaultOpen
|
|
363
364
|
onClose={handleClose}
|
|
364
365
|
onSearch={handleSearch}
|
|
@@ -366,14 +367,15 @@ describe('SelectPicker', () => {
|
|
|
366
367
|
/>
|
|
367
368
|
</div>
|
|
368
369
|
);
|
|
369
|
-
}
|
|
370
|
+
};
|
|
370
371
|
Wrapper.displayName = 'WrapperSelectPicker';
|
|
371
372
|
ReactTestUtils.act(() => {
|
|
372
373
|
ReactDOM.render(<Wrapper />, container);
|
|
373
374
|
});
|
|
374
375
|
|
|
375
376
|
const exit = container?.querySelector('#exit');
|
|
376
|
-
const input =
|
|
377
|
+
const input = container.querySelector(searchInputClassName);
|
|
378
|
+
|
|
377
379
|
// change search
|
|
378
380
|
input.value = 'a';
|
|
379
381
|
ReactTestUtils.Simulate.change(input);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
-
import { FormControlPickerProps } from '../@types/common';
|
|
4
|
-
import {
|
|
3
|
+
import { FormControlPickerProps, ItemDataType } from '../@types/common';
|
|
4
|
+
import { BaseSelectProps } from '../SelectPicker/SelectPicker.d';
|
|
5
5
|
import { TagProps } from '../Tag/Tag.d';
|
|
6
6
|
|
|
7
|
-
export interface TagPickerProps extends FormControlPickerProps,
|
|
7
|
+
export interface TagPickerProps extends FormControlPickerProps, BaseSelectProps {
|
|
8
8
|
/** Option to cache value when searching asynchronously */
|
|
9
9
|
cacheData?: any[];
|
|
10
10
|
|
|
@@ -16,6 +16,13 @@ export interface TagPickerProps extends FormControlPickerProps, SelectProps<any[
|
|
|
16
16
|
* https://github.com/rsuite/rsuite/blob/master/src/Tag/Tag.d.ts
|
|
17
17
|
*/
|
|
18
18
|
tagProps?: TagProps;
|
|
19
|
+
|
|
20
|
+
/** Custom render selected items */
|
|
21
|
+
renderValue?: (
|
|
22
|
+
value: any[],
|
|
23
|
+
item: ItemDataType[],
|
|
24
|
+
selectedElement: React.ReactNode
|
|
25
|
+
) => React.ReactNode;
|
|
19
26
|
}
|
|
20
27
|
|
|
21
28
|
declare const TagPicker: React.ComponentType<TagPickerProps>;
|