index.d.ts 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import type { AlignType, BuildInPlacements } from '@rc-component/trigger/lib/interface';
  2. import type { ScrollConfig, ScrollTo } from 'rc-virtual-list/lib/List';
  3. import * as React from 'react';
  4. import type { DisplayInfoType, DisplayValueType, Mode, Placement, RawValueType, RenderDOMFunc, RenderNode } from '../interface';
  5. export type { DisplayInfoType, DisplayValueType, Mode, Placement, RenderDOMFunc, RenderNode, RawValueType, };
  6. export interface RefOptionListProps {
  7. onKeyDown: React.KeyboardEventHandler;
  8. onKeyUp: React.KeyboardEventHandler;
  9. scrollTo?: (args: number | ScrollConfig) => void;
  10. }
  11. export type CustomTagProps = {
  12. label: React.ReactNode;
  13. value: any;
  14. disabled: boolean;
  15. onClose: (event?: React.MouseEvent<HTMLElement, MouseEvent>) => void;
  16. closable: boolean;
  17. isMaxTag: boolean;
  18. };
  19. export interface BaseSelectRef {
  20. focus: (options?: FocusOptions) => void;
  21. blur: () => void;
  22. scrollTo: ScrollTo;
  23. nativeElement: HTMLElement;
  24. }
  25. export interface BaseSelectPrivateProps {
  26. id: string;
  27. prefixCls: string;
  28. omitDomProps?: string[];
  29. displayValues: DisplayValueType[];
  30. onDisplayValuesChange: (values: DisplayValueType[], info: {
  31. type: DisplayInfoType;
  32. values: DisplayValueType[];
  33. }) => void;
  34. /** Current dropdown list active item string value */
  35. activeValue?: string;
  36. /** Link search input with target element */
  37. activeDescendantId?: string;
  38. onActiveValueChange?: (value: string | null) => void;
  39. searchValue: string;
  40. autoClearSearchValue?: boolean;
  41. /** Trigger onSearch, return false to prevent trigger open event */
  42. onSearch: (searchValue: string, info: {
  43. source: 'typing' | 'effect' | 'submit' | 'blur';
  44. }) => void;
  45. /** Trigger when search text match the `tokenSeparators`. Will provide split content */
  46. onSearchSplit?: (words: string[]) => void;
  47. OptionList: React.ForwardRefExoticComponent<React.PropsWithoutRef<any> & React.RefAttributes<RefOptionListProps>>;
  48. /** Tell if provided `options` is empty */
  49. emptyOptions: boolean;
  50. }
  51. export type BaseSelectPropsWithoutPrivate = Omit<BaseSelectProps, keyof BaseSelectPrivateProps>;
  52. export interface BaseSelectProps extends BaseSelectPrivateProps, React.AriaAttributes {
  53. className?: string;
  54. style?: React.CSSProperties;
  55. title?: string;
  56. showSearch?: boolean;
  57. tagRender?: (props: CustomTagProps) => React.ReactElement;
  58. direction?: 'ltr' | 'rtl';
  59. maxLength?: number;
  60. tabIndex?: number;
  61. autoFocus?: boolean;
  62. notFoundContent?: React.ReactNode;
  63. placeholder?: React.ReactNode;
  64. onClear?: () => void;
  65. choiceTransitionName?: string;
  66. mode?: Mode;
  67. disabled?: boolean;
  68. loading?: boolean;
  69. open?: boolean;
  70. defaultOpen?: boolean;
  71. onDropdownVisibleChange?: (open: boolean) => void;
  72. /** @private Internal usage. Do not use in your production. */
  73. getInputElement?: () => JSX.Element;
  74. /** @private Internal usage. Do not use in your production. */
  75. getRawInputElement?: () => JSX.Element;
  76. maxTagTextLength?: number;
  77. maxTagCount?: number | 'responsive';
  78. maxTagPlaceholder?: React.ReactNode | ((omittedValues: DisplayValueType[]) => React.ReactNode);
  79. tokenSeparators?: string[];
  80. allowClear?: boolean | {
  81. clearIcon?: RenderNode;
  82. };
  83. prefix?: React.ReactNode;
  84. suffixIcon?: RenderNode;
  85. /**
  86. * Clear all icon
  87. * @deprecated Please use `allowClear` instead
  88. **/
  89. clearIcon?: RenderNode;
  90. /** Selector remove icon */
  91. removeIcon?: RenderNode;
  92. animation?: string;
  93. transitionName?: string;
  94. dropdownStyle?: React.CSSProperties;
  95. dropdownClassName?: string;
  96. dropdownMatchSelectWidth?: boolean | number;
  97. dropdownRender?: (menu: React.ReactElement) => React.ReactElement;
  98. dropdownAlign?: AlignType;
  99. placement?: Placement;
  100. builtinPlacements?: BuildInPlacements;
  101. getPopupContainer?: RenderDOMFunc;
  102. showAction?: ('focus' | 'click')[];
  103. onBlur?: React.FocusEventHandler<HTMLElement>;
  104. onFocus?: React.FocusEventHandler<HTMLElement>;
  105. onKeyUp?: React.KeyboardEventHandler<HTMLDivElement>;
  106. onKeyDown?: React.KeyboardEventHandler<HTMLDivElement>;
  107. onMouseDown?: React.MouseEventHandler<HTMLDivElement>;
  108. onPopupScroll?: React.UIEventHandler<HTMLDivElement>;
  109. onInputKeyDown?: React.KeyboardEventHandler<HTMLInputElement | HTMLTextAreaElement>;
  110. onMouseEnter?: React.MouseEventHandler<HTMLDivElement>;
  111. onMouseLeave?: React.MouseEventHandler<HTMLDivElement>;
  112. onClick?: React.MouseEventHandler<HTMLDivElement>;
  113. }
  114. export declare const isMultiple: (mode: Mode) => boolean;
  115. declare const BaseSelect: React.ForwardRefExoticComponent<BaseSelectProps & React.RefAttributes<BaseSelectRef>>;
  116. export default BaseSelect;