diff --git a/src/OptionList.tsx b/src/OptionList.tsx index be4d9dfe..05462245 100644 --- a/src/OptionList.tsx +++ b/src/OptionList.tsx @@ -344,8 +344,8 @@ const OptionList: React.ForwardRefRenderFunction = (_, )} - extends Omit { + extends Omit { prefixCls?: string; id?: string; children?: React.ReactNode; - + styles?: Partial> & { + popup?: Partial>; + }; + classNames?: Partial> & { + popup?: Partial>; + }; // >>> Value value?: ValueType; defaultValue?: ValueType; diff --git a/src/TreeSelectContext.ts b/src/TreeSelectContext.ts index baf9cd84..ab1813ec 100644 --- a/src/TreeSelectContext.ts +++ b/src/TreeSelectContext.ts @@ -2,8 +2,8 @@ import * as React from 'react'; import type { ExpandAction } from '@rc-component/tree/lib/Tree'; import type { DataNode, FieldNames, Key } from './interface'; import type useDataEntities from './hooks/useDataEntities'; +import { TreeSelectProps } from './TreeSelect'; -export type SemanticName = 'item' | 'itemTitle' | 'input' | 'prefix' | 'suffix'; export interface TreeSelectContextProps { virtual?: boolean; popupMatchSelectWidth?: boolean | number; @@ -22,8 +22,8 @@ export interface TreeSelectContextProps { /** When `true`, only take leaf node as count, or take all as count with `maxCount` limitation */ leafCountOnly: boolean; valueEntities: ReturnType['valueEntities']; - styles?: Partial>; - classNames?: Partial>; + classNames: TreeSelectProps['classNames']; + styles: TreeSelectProps['styles']; } const TreeSelectContext = React.createContext(null as any); diff --git a/tests/Select.spec.tsx b/tests/Select.spec.tsx index 2d8ad430..510f213a 100644 --- a/tests/Select.spec.tsx +++ b/tests/Select.spec.tsx @@ -666,15 +666,19 @@ describe('TreeSelect.basic', () => { prefix: 'test-prefix', input: 'test-input', suffix: 'test-suffix', - item: 'test-item', - itemTitle: 'test-item-title', + popup: { + item: 'test-item', + itemTitle: 'test-item-title', + }, }; const customStyles = { prefix: { color: 'green' }, input: { color: 'blue' }, suffix: { color: 'yellow' }, - item: { color: 'black' }, - itemTitle: { color: 'purple' }, + popup: { + item: { color: 'black' }, + itemTitle: { color: 'purple' }, + }, }; const { container } = render( { const input = container.querySelector('.rc-tree-select-selection-search-input'); const suffix = container.querySelector('.rc-tree-select-arrow'); const itemTitle = container.querySelector('.rc-tree-select-tree-title'); - const item = container.querySelector(`.${customClassNames.item}`); + const item = container.querySelector(`.${customClassNames.popup.item}`); expect(prefix).toHaveClass(customClassNames.prefix); expect(input).toHaveClass(customClassNames.input); expect(suffix).toHaveClass(customClassNames.suffix); - expect(itemTitle).toHaveClass(customClassNames.itemTitle); + expect(itemTitle).toHaveClass(customClassNames.popup.itemTitle); expect(prefix).toHaveStyle(customStyles.prefix); expect(input).toHaveStyle(customStyles.input); expect(suffix).toHaveStyle(customStyles.suffix); - expect(itemTitle).toHaveStyle(customStyles.itemTitle); - expect(item).toHaveStyle(customStyles.item); + expect(itemTitle).toHaveStyle(customStyles.popup.itemTitle); + expect(item).toHaveStyle(customStyles.popup.item); }); });