Skip to content

Commit 6a518cd

Browse files
committed
chore: Default remove some shared props
1 parent c4759be commit 6a518cd

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

src/Select.tsx

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,6 @@ import generateSelector, { SelectProps, RefSelectProps } from './generate';
4747
import { DefaultValueType } from './interface/generator';
4848
import warningProps from './utils/warningPropsUtil';
4949

50-
const OMIT_PROPS = [
51-
'removeIcon',
52-
'placeholder',
53-
'autoFocus',
54-
'maxTagCount',
55-
'maxTagTextLength',
56-
'maxTagPlaceholder',
57-
'choiceTransitionName',
58-
'onInputKeyDown',
59-
];
60-
6150
const RefSelect = generateSelector<SelectOptionsType>({
6251
prefixCls: 'rc-select',
6352
components: {
@@ -71,13 +60,6 @@ const RefSelect = generateSelector<SelectOptionsType>({
7160
findValueOption: findSelectValueOption,
7261
warningProps,
7362
fillOptionsWithMissingValue,
74-
omitDOMProps: (props: object) => {
75-
const cloneProps = { ...props };
76-
OMIT_PROPS.forEach(prop => {
77-
delete cloneProps[prop];
78-
});
79-
return cloneProps;
80-
},
8163
});
8264

8365
export type SelectProps<ValueType extends DefaultValueType = DefaultValueType> = SelectProps<

src/generate.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ import useDelayReset from './hooks/useDelayReset';
3434
import useLayoutEffect from './hooks/useLayoutEffect';
3535
import { getSeparatedContent } from './utils/valueUtil';
3636

37+
const DEFAULT_OMIT_PROPS = [
38+
'removeIcon',
39+
'placeholder',
40+
'autoFocus',
41+
'maxTagCount',
42+
'maxTagTextLength',
43+
'maxTagPlaceholder',
44+
'choiceTransitionName',
45+
'onInputKeyDown',
46+
];
47+
3748
export interface RefSelectProps {
3849
focus: () => void;
3950
blur: () => void;
@@ -158,7 +169,7 @@ export interface GenerateConfig<OptionsType extends object[]> {
158169
optionLabelProp: string,
159170
labelInValue: boolean,
160171
) => OptionsType;
161-
omitDOMProps: (props: object) => object;
172+
omitDOMProps?: (props: object) => object;
162173
}
163174

164175
/**
@@ -264,7 +275,10 @@ export default function generateSelector<
264275
...restProps
265276
} = props;
266277

267-
const domProps = omitDOMProps(restProps);
278+
const domProps = omitDOMProps ? omitDOMProps(restProps) : restProps;
279+
DEFAULT_OMIT_PROPS.forEach(prop => {
280+
delete domProps[prop];
281+
});
268282

269283
const selectorRef = React.useRef<RefSelectorProps>(null);
270284
const listRef = React.useRef<RefOptionListProps>(null);

0 commit comments

Comments
 (0)