Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/TreeSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ const TreeSelect = React.forwardRef<BaseSelectRef, TreeSelectProps>((props, ref)

const mergedId = useId(id);
const treeConduction = treeCheckable && !treeCheckStrictly;
const mergedCheckable: boolean = !!(treeCheckable || treeCheckStrictly);
const mergedCheckable = treeCheckable || treeCheckStrictly;
const mergedLabelInValue = treeCheckStrictly || labelInValue;
const mergedMultiple = mergedCheckable || multiple;

Expand Down
11 changes: 6 additions & 5 deletions src/hooks/useDataEntities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import warning from 'rc-util/lib/warning';
import { isNil } from '../utils/valueUtil';

export default (treeData: any, fieldNames: FieldNames) =>
React.useMemo<{ keyEntities: Record<string, DataEntity> }>(() => {
React.useMemo<{
valueEntities: Map<RawValueType, DataEntity>;
keyEntities: Record<string, DataEntity>;
}>(() => {
const collection = convertDataToEntities(treeData, {
fieldNames,
initWrapper: wrapper => ({
Expand All @@ -31,7 +34,5 @@ export default (treeData: any, fieldNames: FieldNames) =>
},
});

return collection;
}, [treeData, fieldNames]) as ReturnType<typeof convertDataToEntities> & {
valueEntities: Map<RawValueType, DataEntity>;
};
return collection as any;
}, [treeData, fieldNames]);
14 changes: 4 additions & 10 deletions src/utils/legacyUtil.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import * as React from 'react';
import toArray from 'rc-util/lib/Children/toArray';
import warning from 'rc-util/lib/warning';
import type {
DataNode,
LegacyDataNode,
ChangeEventExtra,
RawValueType,
LegacyCheckedNode,
} from '../interface';
import type { DataNode, ChangeEventExtra, RawValueType, LegacyCheckedNode } from '../interface';
import TreeNode from '../TreeNode';
import type { DefaultOptionType, FieldNames } from '../TreeSelect';

Expand Down Expand Up @@ -39,9 +33,9 @@ export function convertChildrenToData(nodes: React.ReactNode): DataNode[] {
.filter(data => data);
}

export function fillLegacyProps(dataNode: DataNode): LegacyDataNode {
export function fillLegacyProps(dataNode: DataNode): any {
if (!dataNode) {
return dataNode as LegacyDataNode;
return dataNode;
}

const cloneNode = { ...dataNode };
Expand All @@ -58,7 +52,7 @@ export function fillLegacyProps(dataNode: DataNode): LegacyDataNode {
});
}

return cloneNode as LegacyDataNode;
return cloneNode;
}

export function fillAdditionalInfo(
Expand Down
17 changes: 17 additions & 0 deletions tests/Select.checkable.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -753,4 +753,21 @@ describe('TreeSelect.checkable', () => {
expect.objectContaining({ checked: ['parent', 'child'] }),
);
});

it('customize checkable node', () => {
const wrapper = mount(
<TreeSelect
open
treeCheckable={<span className="little" />}
treeData={[
{
label: 'parent',
value: 'parent',
},
]}
/>,
);

expect(wrapper.exists('.little')).toBeTruthy();
});
});