index.d.ts 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /**
  2. * Cursor rule:
  3. * 1. Only `showSearch` enabled
  4. * 2. Only `open` is `true`
  5. * 3. When typing, set `open` to `true` which hit rule of 2
  6. *
  7. * Accessibility:
  8. * - https://www.w3.org/TR/wai-aria-practices/examples/combobox/aria1.1pattern/listbox-combo.html
  9. */
  10. import type { ScrollTo } from 'rc-virtual-list/lib/List';
  11. import * as React from 'react';
  12. import type { CustomTagProps, DisplayValueType, Mode, RenderNode } from '../BaseSelect';
  13. export interface InnerSelectorProps {
  14. prefixCls: string;
  15. id: string;
  16. mode: Mode;
  17. title?: string;
  18. inputRef: React.Ref<HTMLInputElement | HTMLTextAreaElement>;
  19. placeholder?: React.ReactNode;
  20. disabled?: boolean;
  21. autoFocus?: boolean;
  22. autoComplete?: string;
  23. values: DisplayValueType[];
  24. showSearch?: boolean;
  25. searchValue: string;
  26. autoClearSearchValue?: boolean;
  27. activeDescendantId?: string;
  28. open: boolean;
  29. tabIndex?: number;
  30. maxLength?: number;
  31. onInputKeyDown: React.KeyboardEventHandler<HTMLInputElement | HTMLTextAreaElement>;
  32. onInputMouseDown: React.MouseEventHandler<HTMLInputElement | HTMLTextAreaElement>;
  33. onInputChange: React.ChangeEventHandler<HTMLInputElement | HTMLTextAreaElement>;
  34. onInputPaste: React.ClipboardEventHandler<HTMLInputElement | HTMLTextAreaElement>;
  35. onInputCompositionStart: React.CompositionEventHandler<HTMLInputElement | HTMLTextAreaElement>;
  36. onInputCompositionEnd: React.CompositionEventHandler<HTMLInputElement | HTMLTextAreaElement>;
  37. onInputBlur: React.FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;
  38. }
  39. export interface RefSelectorProps {
  40. focus: (options?: FocusOptions) => void;
  41. blur: () => void;
  42. scrollTo?: ScrollTo;
  43. }
  44. export interface SelectorProps {
  45. id: string;
  46. prefixCls: string;
  47. showSearch?: boolean;
  48. open: boolean;
  49. /** Display in the Selector value, it's not same as `value` prop */
  50. values: DisplayValueType[];
  51. mode: Mode;
  52. searchValue: string;
  53. activeValue: string;
  54. autoClearSearchValue: boolean;
  55. inputElement: JSX.Element;
  56. maxLength?: number;
  57. autoFocus?: boolean;
  58. activeDescendantId?: string;
  59. tabIndex?: number;
  60. disabled?: boolean;
  61. placeholder?: React.ReactNode;
  62. removeIcon?: RenderNode;
  63. prefix?: React.ReactNode;
  64. maxTagCount?: number | 'responsive';
  65. maxTagTextLength?: number;
  66. maxTagPlaceholder?: React.ReactNode | ((omittedValues: DisplayValueType[]) => React.ReactNode);
  67. tagRender?: (props: CustomTagProps) => React.ReactElement;
  68. /** Check if `tokenSeparators` contains `\n` or `\r\n` */
  69. tokenWithEnter?: boolean;
  70. choiceTransitionName?: string;
  71. onToggleOpen: (open?: boolean) => void;
  72. /** `onSearch` returns go next step boolean to check if need do toggle open */
  73. onSearch: (searchText: string, fromTyping: boolean, isCompositing: boolean) => boolean;
  74. onSearchSubmit?: (searchText: string) => void;
  75. onRemove: (value: DisplayValueType) => void;
  76. onInputKeyDown?: React.KeyboardEventHandler<HTMLInputElement | HTMLTextAreaElement>;
  77. onInputBlur?: () => void;
  78. /**
  79. * @private get real dom for trigger align.
  80. * This may be removed after React provides replacement of `findDOMNode`
  81. */
  82. domRef: React.Ref<HTMLDivElement>;
  83. }
  84. declare const ForwardSelector: React.ForwardRefExoticComponent<SelectorProps & React.RefAttributes<RefSelectorProps>>;
  85. export default ForwardSelector;