index.d.ts 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import * as React from 'react';
  2. import type { BaseSelectRef } from 'rc-select';
  3. import type { TreeSelectProps as RcTreeSelectProps } from 'rc-tree-select';
  4. import { SHOW_ALL, SHOW_CHILD, SHOW_PARENT, TreeNode } from 'rc-tree-select';
  5. import type { DataNode } from 'rc-tree-select/lib/interface';
  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. import type { TreeProps } from '../tree';
  11. import type { SwitcherIcon } from '../tree/Tree';
  12. type RawValue = string | number;
  13. type SemanticName = 'root';
  14. type PopupSemantic = 'root';
  15. export interface LabeledValue {
  16. key?: string;
  17. value: RawValue;
  18. label: React.ReactNode;
  19. }
  20. export type SelectValue = RawValue | RawValue[] | LabeledValue | LabeledValue[];
  21. export interface TreeSelectProps<ValueType = any, OptionType extends DataNode = DataNode> extends React.AriaAttributes, Omit<RcTreeSelectProps<ValueType, OptionType>, 'showTreeIcon' | 'treeMotion' | 'mode' | 'getInputElement' | 'backfill' | 'treeLine' | 'switcherIcon'> {
  22. suffixIcon?: React.ReactNode;
  23. size?: SizeType;
  24. disabled?: boolean;
  25. placement?: SelectCommonPlacement;
  26. /** @deprecated Please use `classNames.popup.root` instead */
  27. popupClassName?: string;
  28. /** @deprecated Please use `classNames.popup.root` instead */
  29. dropdownClassName?: string;
  30. /** @deprecated Please use `popupRender` instead */
  31. dropdownRender?: (menu: React.ReactElement) => React.ReactElement;
  32. popupRender?: (menu: React.ReactElement) => React.ReactElement;
  33. /** @deprecated Please use `styles.popup.root` instead */
  34. dropdownStyle?: React.CSSProperties;
  35. /** @deprecated Please use `onOpenChange` instead */
  36. onDropdownVisibleChange?: (visible: boolean) => void;
  37. onOpenChange?: (open: boolean) => void;
  38. /** @deprecated Use `variant` instead. */
  39. bordered?: boolean;
  40. treeLine?: TreeProps['showLine'];
  41. status?: InputStatus;
  42. switcherIcon?: SwitcherIcon | RcTreeSelectProps<ValueType, OptionType>['switcherIcon'];
  43. rootClassName?: string;
  44. /** @deprecated Please use `popupMatchSelectWidth` instead */
  45. dropdownMatchSelectWidth?: boolean | number;
  46. popupMatchSelectWidth?: boolean | number;
  47. /**
  48. * @deprecated `showArrow` is deprecated which will be removed in next major version. It will be a
  49. * default behavior, you can hide it by setting `suffixIcon` to null.
  50. */
  51. showArrow?: boolean;
  52. /**
  53. * @since 5.13.0
  54. * @default "outlined"
  55. */
  56. variant?: Variant;
  57. classNames?: Partial<Record<SemanticName, string>> & {
  58. popup?: Partial<Record<PopupSemantic, string>>;
  59. };
  60. styles?: Partial<Record<SemanticName, React.CSSProperties>> & {
  61. popup?: Partial<Record<PopupSemantic, React.CSSProperties>>;
  62. };
  63. }
  64. declare const TreeSelectRef: <ValueType = any, OptionType extends DataNode = DataNode>(props: React.PropsWithChildren<TreeSelectProps<ValueType, OptionType>> & React.RefAttributes<BaseSelectRef>) => React.ReactElement;
  65. type InternalTreeSelectType = typeof TreeSelectRef;
  66. type CompoundedComponent = InternalTreeSelectType & {
  67. displayName?: string;
  68. TreeNode: typeof TreeNode;
  69. SHOW_ALL: typeof SHOW_ALL;
  70. SHOW_PARENT: typeof SHOW_PARENT;
  71. SHOW_CHILD: typeof SHOW_CHILD;
  72. _InternalPanelDoNotUseOrYouWillBeFired: typeof PurePanel;
  73. };
  74. declare const TreeSelect: CompoundedComponent;
  75. declare const PurePanel: (props: import("../_util/type").AnyObject) => React.JSX.Element;
  76. export { TreeNode };
  77. export default TreeSelect;