index.d.ts 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import * as React from 'react';
  2. import type { BaseSelectRef, SelectProps as RcSelectProps } from 'rc-select';
  3. import { OptGroup, Option } from 'rc-select';
  4. import type { OptionProps } from 'rc-select/lib/Option';
  5. import type { BaseOptionType, DefaultOptionType } from 'rc-select/lib/Select';
  6. import type { SelectCommonPlacement } from '../_util/motion';
  7. import type { InputStatus } from '../_util/statusUtils';
  8. import type { Variant } from '../config-provider';
  9. import type { SizeType } from '../config-provider/SizeContext';
  10. type RawValue = string | number;
  11. type SemanticName = 'root';
  12. type PopupSemantic = 'root';
  13. export type { BaseOptionType, DefaultOptionType, OptionProps, BaseSelectRef as RefSelectProps };
  14. export interface LabeledValue {
  15. key?: string;
  16. value: RawValue;
  17. label: React.ReactNode;
  18. }
  19. export type SelectValue = RawValue | RawValue[] | LabeledValue | LabeledValue[] | undefined;
  20. export interface InternalSelectProps<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType> extends Omit<RcSelectProps<ValueType, OptionType>, 'mode'> {
  21. rootClassName?: string;
  22. prefix?: React.ReactNode;
  23. suffixIcon?: React.ReactNode;
  24. size?: SizeType;
  25. disabled?: boolean;
  26. mode?: 'multiple' | 'tags' | 'SECRET_COMBOBOX_MODE_DO_NOT_USE' | 'combobox';
  27. /** @deprecated Use `variant` instead. */
  28. bordered?: boolean;
  29. /**
  30. * @deprecated `showArrow` is deprecated which will be removed in next major version. It will be a
  31. * default behavior, you can hide it by setting `suffixIcon` to null.
  32. */
  33. showArrow?: boolean;
  34. /**
  35. * @since 5.13.0
  36. * @default "outlined"
  37. */
  38. variant?: Variant;
  39. styles?: Partial<Record<SemanticName, React.CSSProperties>> & {
  40. popup?: Partial<Record<PopupSemantic, React.CSSProperties>>;
  41. };
  42. classNames?: Partial<Record<SemanticName, string>> & {
  43. popup?: Partial<Record<PopupSemantic, string>>;
  44. };
  45. }
  46. export interface SelectProps<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType> extends Omit<InternalSelectProps<ValueType, OptionType>, 'mode' | 'getInputElement' | 'getRawInputElement' | 'backfill' | 'placement'> {
  47. placement?: SelectCommonPlacement;
  48. mode?: 'multiple' | 'tags';
  49. status?: InputStatus;
  50. /** @deprecated Please use `classNames.popup.root` instead */
  51. popupClassName?: string;
  52. /** @deprecated Please use `classNames.popup.root` instead */
  53. dropdownClassName?: string;
  54. /** @deprecated Please use `popupMatchSelectWidth` instead */
  55. dropdownMatchSelectWidth?: boolean | number;
  56. popupMatchSelectWidth?: boolean | number;
  57. /** @deprecated Please use `popupRender` instead */
  58. dropdownRender?: (menu: React.ReactElement) => React.ReactElement;
  59. popupRender?: (menu: React.ReactElement) => React.ReactElement;
  60. /** @deprecated Please use `styles.popup.root` instead */
  61. dropdownStyle?: React.CSSProperties;
  62. /** @deprecated Please use `onOpenChange` instead */
  63. onDropdownVisibleChange?: (visible: boolean) => void;
  64. onOpenChange?: (visible: boolean) => void;
  65. }
  66. declare const Select: (<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(props: React.PropsWithChildren<SelectProps<ValueType, OptionType>> & React.RefAttributes<BaseSelectRef>) => React.ReactElement) & {
  67. displayName?: string;
  68. SECRET_COMBOBOX_MODE_DO_NOT_USE: string;
  69. Option: typeof Option;
  70. OptGroup: typeof OptGroup;
  71. _InternalPanelDoNotUseOrYouWillBeFired: typeof PurePanel;
  72. };
  73. declare const PurePanel: (props: import("../_util/type").AnyObject) => React.JSX.Element;
  74. export default Select;