interface.d.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /// <reference types="react" />
  2. import type { CSSMotionProps } from 'rc-motion';
  3. export type Placement = 'top' | 'left' | 'right' | 'bottom' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
  4. export type AlignPointTopBottom = 't' | 'b' | 'c';
  5. export type AlignPointLeftRight = 'l' | 'r' | 'c';
  6. /** Two char of 't' 'b' 'c' 'l' 'r'. Example: 'lt' */
  7. export type AlignPoint = `${AlignPointTopBottom}${AlignPointLeftRight}`;
  8. export type OffsetType = number | `${number}%`;
  9. export interface AlignType {
  10. /**
  11. * move point of source node to align with point of target node.
  12. * Such as ['tr','cc'], align top right point of source node with center point of target node.
  13. * Point can be 't'(top), 'b'(bottom), 'c'(center), 'l'(left), 'r'(right) */
  14. points?: (string | AlignPoint)[];
  15. /**
  16. * @private Do not use in your production code
  17. */
  18. _experimental?: Record<string, any>;
  19. /**
  20. * offset source node by offset[0] in x and offset[1] in y.
  21. * If offset contains percentage string value, it is relative to sourceNode region.
  22. */
  23. offset?: OffsetType[];
  24. /**
  25. * offset target node by offset[0] in x and offset[1] in y.
  26. * If targetOffset contains percentage string value, it is relative to targetNode region.
  27. */
  28. targetOffset?: OffsetType[];
  29. /**
  30. * If adjustX field is true, will adjust source node in x direction if source node is invisible.
  31. * If adjustY field is true, will adjust source node in y direction if source node is invisible.
  32. */
  33. overflow?: {
  34. adjustX?: boolean | number;
  35. adjustY?: boolean | number;
  36. shiftX?: boolean | number;
  37. shiftY?: boolean | number;
  38. };
  39. /** Auto adjust arrow position */
  40. autoArrow?: boolean;
  41. /**
  42. * Config visible region check of html node. Default `visible`:
  43. * - `visible`:
  44. * The visible region of user browser window.
  45. * Use `clientHeight` for check.
  46. * If `visible` region not satisfy, fallback to `scroll`.
  47. * - `scroll`:
  48. * The whole region of the html scroll area.
  49. * Use `scrollHeight` for check.
  50. * - `visibleFirst`:
  51. * Similar to `visible`, but if `visible` region not satisfy, fallback to `scroll`.
  52. */
  53. htmlRegion?: 'visible' | 'scroll' | 'visibleFirst';
  54. /**
  55. * Auto chose position with `top` or `bottom` by the align result
  56. */
  57. dynamicInset?: boolean;
  58. /**
  59. * Whether use css right instead of left to position
  60. */
  61. useCssRight?: boolean;
  62. /**
  63. * Whether use css bottom instead of top to position
  64. */
  65. useCssBottom?: boolean;
  66. /**
  67. * Whether use css transform instead of left/top/right/bottom to position if browser supports.
  68. * Defaults to false.
  69. */
  70. useCssTransform?: boolean;
  71. ignoreShake?: boolean;
  72. }
  73. export interface ArrowTypeOuter {
  74. className?: string;
  75. content?: React.ReactNode;
  76. }
  77. export type ArrowPos = {
  78. x?: number;
  79. y?: number;
  80. };
  81. export type BuildInPlacements = Record<string, AlignType>;
  82. export type StretchType = string;
  83. export type ActionType = 'hover' | 'focus' | 'click' | 'contextMenu';
  84. export type AnimationType = string;
  85. export type TransitionNameType = string;
  86. export interface Point {
  87. pageX: number;
  88. pageY: number;
  89. }
  90. export interface CommonEventHandler {
  91. remove: () => void;
  92. }
  93. export interface MobileConfig {
  94. /** Set popup motion. You can ref `rc-motion` for more info. */
  95. popupMotion?: CSSMotionProps;
  96. popupClassName?: string;
  97. popupStyle?: React.CSSProperties;
  98. popupRender?: (originNode: React.ReactNode) => React.ReactNode;
  99. }