mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-07 17:44:35 +08:00

* feat: Input filled variant * feat: InputNumber filled variant * feat: mentions variant * fix: TextArea status with affix * chore: update snapshot * chore: update snapshot * feat: pagination input * fix: fix diff * feat: input-number disabled * fixL InputNumber * chore: update snapshot * feat: better style * chore: update * chore: update snapshot * feat: use variant classNames * chore: update snapshot * feat: mentions affix style * chore
29 lines
767 B
TypeScript
29 lines
767 B
TypeScript
type DefaultVariant = 'outlined' | 'borderless';
|
|
|
|
/**
|
|
* Compatible for legacy `bordered` prop.
|
|
*/
|
|
const useVariant = <T extends string>(
|
|
variant: T | undefined,
|
|
legacyBordered: boolean | undefined,
|
|
variants: readonly (T | DefaultVariant)[],
|
|
options?: {
|
|
omitOutlined?: boolean;
|
|
},
|
|
): [T | DefaultVariant, boolean] => {
|
|
let mergedVariant: T | DefaultVariant;
|
|
if (typeof variant !== 'undefined') {
|
|
mergedVariant = variant;
|
|
} else if (legacyBordered === false) {
|
|
mergedVariant = 'borderless';
|
|
} else {
|
|
mergedVariant = 'outlined';
|
|
}
|
|
|
|
const enableVariantCls =
|
|
variants.includes(mergedVariant) && (!options?.omitOutlined || mergedVariant !== 'outlined');
|
|
return [mergedVariant, enableVariantCls];
|
|
};
|
|
|
|
export default useVariant;
|