Skip to content

Commit 459a57a

Browse files
committed
draft
1 parent f0d4350 commit 459a57a

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
},
4646
"dependencies": {
4747
"classnames": "2.x",
48-
"@rc-component/select": "~1.0.0",
49-
"@rc-component/tree": "~1.0.0",
48+
"@rc-component/select": "~1.0.2",
49+
"@rc-component/tree": "~1.0.1",
5050
"@rc-component/util": "^1.2.1"
5151
},
5252
"devDependencies": {

src/OptionList.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ const OptionList: React.ForwardRefRenderFunction<ReviseRefOptionListProps> = (_,
5050
leftMaxCount,
5151
leafCountOnly,
5252
valueEntities,
53+
classNames: treeClassNames,
54+
styles,
5355
} = React.useContext(TreeSelectContext);
5456

5557
const {
@@ -342,6 +344,8 @@ const OptionList: React.ForwardRefRenderFunction<ReviseRefOptionListProps> = (_,
342344
)}
343345
<UnstableContext.Provider value={{ nodeDisabled }}>
344346
<Tree
347+
classNames={treeClassNames}
348+
styles={styles}
345349
ref={treeRef}
346350
focusable={false}
347351
prefixCls={`${prefixCls}-tree`}

src/TreeSelect.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@ const TreeSelect = React.forwardRef<BaseSelectRef, TreeSelectProps>((props, ref)
174174
treeTitleRender,
175175

176176
onPopupScroll,
177+
178+
classNames: treeSelectClassNames,
179+
styles,
177180
...restProps
178181
} = props;
179182

@@ -623,6 +626,8 @@ const TreeSelect = React.forwardRef<BaseSelectRef, TreeSelectProps>((props, ref)
623626
leafCountOnly:
624627
mergedShowCheckedStrategy === 'SHOW_CHILD' && !treeCheckStrictly && !!treeCheckable,
625628
valueEntities,
629+
classNames: treeSelectClassNames,
630+
styles,
626631
};
627632
}, [
628633
virtual,
@@ -642,6 +647,8 @@ const TreeSelect = React.forwardRef<BaseSelectRef, TreeSelectProps>((props, ref)
642647
treeCheckStrictly,
643648
treeCheckable,
644649
valueEntities,
650+
treeSelectClassNames,
651+
styles,
645652
]);
646653

647654
// ======================= Legacy Context =======================
@@ -693,6 +700,16 @@ const TreeSelect = React.forwardRef<BaseSelectRef, TreeSelectProps>((props, ref)
693700
<BaseSelect
694701
ref={ref}
695702
{...restProps}
703+
classNames={{
704+
prefix: treeSelectClassNames?.prefix,
705+
suffix: treeSelectClassNames?.suffix,
706+
input: treeSelectClassNames?.input,
707+
}}
708+
styles={{
709+
prefix: styles?.prefix,
710+
suffix: styles?.suffix,
711+
input: styles?.input,
712+
}}
696713
// >>> MISC
697714
id={mergedId}
698715
prefixCls={prefixCls}

src/TreeSelectContext.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { ExpandAction } from '@rc-component/tree/lib/Tree';
33
import type { DataNode, FieldNames, Key } from './interface';
44
import type useDataEntities from './hooks/useDataEntities';
55

6+
export type SemanticName = 'itemIcon' | 'item' | 'itemTitle' | 'input' | 'prefix' | 'suffix';
67
export interface TreeSelectContextProps {
78
virtual?: boolean;
89
popupMatchSelectWidth?: boolean | number;
@@ -21,6 +22,8 @@ export interface TreeSelectContextProps {
2122
/** When `true`, only take leaf node as count, or take all as count with `maxCount` limitation */
2223
leafCountOnly: boolean;
2324
valueEntities: ReturnType<typeof useDataEntities>['valueEntities'];
25+
styles?: Partial<Record<SemanticName, React.CSSProperties>>;
26+
classNames?: Partial<Record<SemanticName, string>>;
2427
}
2528

2629
const TreeSelectContext = React.createContext<TreeSelectContextProps>(null as any);

0 commit comments

Comments
 (0)