|
|
@@ -219,6 +219,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
enableLeafClick: false,
|
|
|
'aria-label': 'Cascader',
|
|
|
searchPosition: strings.SEARCH_POSITION_TRIGGER,
|
|
|
+ checkRelation: strings.RELATED,
|
|
|
})
|
|
|
|
|
|
options: any;
|
|
|
@@ -429,7 +430,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
}
|
|
|
|
|
|
static getDerivedStateFromProps(props: CascaderProps, prevState: CascaderState) {
|
|
|
- const { multiple, value, defaultValue, onChangeWithObject, leafOnly, autoMergeValue } = props;
|
|
|
+ const { multiple, value, defaultValue, onChangeWithObject, leafOnly, autoMergeValue, checkRelation } = props;
|
|
|
const { prevProps } = prevState;
|
|
|
let keyEntities = prevState.keyEntities || {};
|
|
|
const newState: Partial<CascaderState> = {};
|
|
|
@@ -498,18 +499,22 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
if (isSet(realKeys)) {
|
|
|
realKeys = [...realKeys];
|
|
|
}
|
|
|
- const calRes = calcCheckedKeys(realKeys, keyEntities);
|
|
|
- const checkedKeys = new Set(calRes.checkedKeys);
|
|
|
- const halfCheckedKeys = new Set(calRes.halfCheckedKeys);
|
|
|
- // disableStrictly
|
|
|
- if (props.disableStrictly) {
|
|
|
- newState.disabledKeys = calcDisabledKeys(keyEntities);
|
|
|
+ if (checkRelation === strings.RELATED) {
|
|
|
+ const calRes = calcCheckedKeys(realKeys, keyEntities);
|
|
|
+ const checkedKeys = new Set(calRes.checkedKeys);
|
|
|
+ const halfCheckedKeys = new Set(calRes.halfCheckedKeys);
|
|
|
+ // disableStrictly
|
|
|
+ if (props.disableStrictly) {
|
|
|
+ newState.disabledKeys = calcDisabledKeys(keyEntities);
|
|
|
+ }
|
|
|
+ const isLeafOnlyMerge = calcMergeType(autoMergeValue, leafOnly) === strings.LEAF_ONLY_MERGE_TYPE;
|
|
|
+ newState.checkedKeys = checkedKeys;
|
|
|
+ newState.halfCheckedKeys = halfCheckedKeys;
|
|
|
+ newState.resolvedCheckedKeys = new Set(normalizeKeyList(checkedKeys, keyEntities, isLeafOnlyMerge));
|
|
|
+ } else {
|
|
|
+ newState.checkedKeys = new Set(realKeys);
|
|
|
}
|
|
|
- const isLeafOnlyMerge = calcMergeType(autoMergeValue, leafOnly) === strings.LEAF_ONLY_MERGE_TYPE;
|
|
|
newState.prevProps = props;
|
|
|
- newState.checkedKeys = checkedKeys;
|
|
|
- newState.halfCheckedKeys = halfCheckedKeys;
|
|
|
- newState.resolvedCheckedKeys = new Set(normalizeKeyList(checkedKeys, keyEntities, isLeafOnlyMerge));
|
|
|
}
|
|
|
}
|
|
|
return newState;
|
|
|
@@ -594,10 +599,11 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
};
|
|
|
|
|
|
renderTagInput() {
|
|
|
- const { size, disabled, placeholder, maxTagCount, showRestTagsPopover, restTagsPopoverProps } = this.props;
|
|
|
+ const { size, disabled, placeholder, maxTagCount, showRestTagsPopover, restTagsPopoverProps, checkRelation } = this.props;
|
|
|
const { inputValue, checkedKeys, keyEntities, resolvedCheckedKeys } = this.state;
|
|
|
const tagInputcls = cls(`${prefixcls}-tagInput-wrapper`);
|
|
|
- const realKeys = this.mergeType === strings.NONE_MERGE_TYPE ? checkedKeys : resolvedCheckedKeys;
|
|
|
+ const realKeys = this.mergeType === strings.NONE_MERGE_TYPE || checkRelation === strings.UN_RELATED ?
|
|
|
+ checkedKeys : resolvedCheckedKeys;
|
|
|
return (
|
|
|
<TagInput
|
|
|
className={tagInputcls}
|
|
|
@@ -765,9 +771,10 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
};
|
|
|
|
|
|
renderMultipleTags = () => {
|
|
|
- const { autoMergeValue, maxTagCount } = this.props;
|
|
|
+ const { autoMergeValue, maxTagCount, checkRelation } = this.props;
|
|
|
const { checkedKeys, resolvedCheckedKeys } = this.state;
|
|
|
- const realKeys = this.mergeType === strings.NONE_MERGE_TYPE ? checkedKeys : resolvedCheckedKeys;
|
|
|
+ const realKeys = this.mergeType === strings.NONE_MERGE_TYPE || checkRelation === strings.UN_RELATED ?
|
|
|
+ checkedKeys : resolvedCheckedKeys;
|
|
|
const displayTag: Array<ReactNode> = [];
|
|
|
const hiddenTag: Array<ReactNode> = [];
|
|
|
[...realKeys].forEach((checkedKey, idx) => {
|