@rc-component/trigger 1.10.1 → 1.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Popup/Arrow.d.ts +8 -0
- package/lib/Popup/Mask.d.ts +10 -0
- package/lib/Popup/PopupContent.d.ts +7 -0
- package/lib/Popup/index.d.ts +38 -0
- package/lib/TriggerWrapper.d.ts +8 -0
- package/lib/context.d.ts +6 -0
- package/lib/hooks/useAction.d.ts +4 -0
- package/lib/hooks/useAlign.d.ts +13 -0
- package/lib/hooks/useWatch.d.ts +1 -0
- package/lib/index.d.ts +64 -0
- package/lib/interface.d.ts +82 -0
- package/lib/mock.d.ts +3 -0
- package/lib/util.d.ts +25 -0
- package/package.json +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { CSSMotionProps } from 'rc-motion';
|
|
3
|
+
export interface MaskProps {
|
|
4
|
+
prefixCls: string;
|
|
5
|
+
open?: boolean;
|
|
6
|
+
zIndex?: number;
|
|
7
|
+
mask?: boolean;
|
|
8
|
+
motion?: CSSMotionProps;
|
|
9
|
+
}
|
|
10
|
+
export default function Mask(props: MaskProps): JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface PopupContentProps {
|
|
3
|
+
children?: React.ReactNode;
|
|
4
|
+
cache?: boolean;
|
|
5
|
+
}
|
|
6
|
+
declare const PopupContent: React.MemoExoticComponent<({ children }: PopupContentProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>>>;
|
|
7
|
+
export default PopupContent;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { CSSMotionProps } from 'rc-motion';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import type { TriggerProps } from '../';
|
|
4
|
+
import type { AlignType, ArrowType } from '../interface';
|
|
5
|
+
export interface PopupProps {
|
|
6
|
+
prefixCls: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
style?: React.CSSProperties;
|
|
9
|
+
popup?: TriggerProps['popup'];
|
|
10
|
+
target: HTMLElement;
|
|
11
|
+
onMouseEnter?: React.MouseEventHandler<HTMLDivElement>;
|
|
12
|
+
onMouseLeave?: React.MouseEventHandler<HTMLDivElement>;
|
|
13
|
+
zIndex?: number;
|
|
14
|
+
mask?: boolean;
|
|
15
|
+
onVisibleChanged: (visible: boolean) => void;
|
|
16
|
+
align?: AlignType;
|
|
17
|
+
arrow?: ArrowType;
|
|
18
|
+
open: boolean;
|
|
19
|
+
/** Tell Portal that should keep in screen. e.g. should wait all motion end */
|
|
20
|
+
keepDom: boolean;
|
|
21
|
+
onClick?: React.MouseEventHandler<HTMLDivElement>;
|
|
22
|
+
motion?: CSSMotionProps;
|
|
23
|
+
maskMotion?: CSSMotionProps;
|
|
24
|
+
forceRender?: boolean;
|
|
25
|
+
getPopupContainer?: TriggerProps['getPopupContainer'];
|
|
26
|
+
autoDestroy?: boolean;
|
|
27
|
+
portal: React.ComponentType<any>;
|
|
28
|
+
ready: boolean;
|
|
29
|
+
offsetX: number;
|
|
30
|
+
offsetY: number;
|
|
31
|
+
onAlign: VoidFunction;
|
|
32
|
+
onPrepare: () => Promise<void>;
|
|
33
|
+
stretch?: string;
|
|
34
|
+
targetWidth?: number;
|
|
35
|
+
targetHeight?: number;
|
|
36
|
+
}
|
|
37
|
+
declare const Popup: React.ForwardRefExoticComponent<PopupProps & React.RefAttributes<HTMLDivElement>>;
|
|
38
|
+
export default Popup;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { TriggerProps } from '.';
|
|
3
|
+
export interface TriggerWrapperProps {
|
|
4
|
+
getTriggerDOMNode?: TriggerProps['getTriggerDOMNode'];
|
|
5
|
+
children: React.ReactElement;
|
|
6
|
+
}
|
|
7
|
+
declare const TriggerWrapper: React.ForwardRefExoticComponent<TriggerWrapperProps & React.RefAttributes<HTMLElement>>;
|
|
8
|
+
export default TriggerWrapper;
|
package/lib/context.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ActionType } from '../interface';
|
|
2
|
+
declare type ActionTypes = ActionType | ActionType[];
|
|
3
|
+
export default function useAction(mobile: boolean, action: ActionTypes, showAction?: ActionTypes, hideAction?: ActionTypes): [showAction: Set<ActionType>, hideAction: Set<ActionType>];
|
|
4
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TriggerProps } from '..';
|
|
2
|
+
import type { AlignType } from '../interface';
|
|
3
|
+
export default function useAlign(open: boolean, popupEle: HTMLElement, target: HTMLElement | [x: number, y: number], placement: string, builtinPlacements: any, popupAlign?: AlignType, onPopupAlign?: TriggerProps['onPopupAlign']): [
|
|
4
|
+
ready: boolean,
|
|
5
|
+
offsetX: number,
|
|
6
|
+
offsetY: number,
|
|
7
|
+
arrowX: number,
|
|
8
|
+
arrowY: number,
|
|
9
|
+
scaleX: number,
|
|
10
|
+
scaleY: number,
|
|
11
|
+
align: AlignType,
|
|
12
|
+
onAlign: VoidFunction
|
|
13
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function useWatch(open: boolean, target: HTMLElement, popup: HTMLElement, onAlign: VoidFunction): void;
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { CSSMotionProps } from 'rc-motion';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import type { ActionType, AlignType, AnimationType, ArrowTypeOuter, BuildInPlacements, TransitionNameType } from './interface';
|
|
4
|
+
export type { BuildInPlacements, AlignType, ActionType, ArrowTypeOuter as ArrowType, };
|
|
5
|
+
export interface TriggerRef {
|
|
6
|
+
forceAlign: VoidFunction;
|
|
7
|
+
}
|
|
8
|
+
export interface TriggerProps {
|
|
9
|
+
children: React.ReactElement;
|
|
10
|
+
action?: ActionType | ActionType[];
|
|
11
|
+
showAction?: ActionType[];
|
|
12
|
+
hideAction?: ActionType[];
|
|
13
|
+
prefixCls?: string;
|
|
14
|
+
zIndex?: number;
|
|
15
|
+
onPopupAlign?: (element: HTMLElement, align: AlignType) => void;
|
|
16
|
+
stretch?: string;
|
|
17
|
+
popupVisible?: boolean;
|
|
18
|
+
defaultPopupVisible?: boolean;
|
|
19
|
+
onPopupVisibleChange?: (visible: boolean) => void;
|
|
20
|
+
afterPopupVisibleChange?: (visible: boolean) => void;
|
|
21
|
+
getPopupContainer?: (node: HTMLElement) => HTMLElement;
|
|
22
|
+
forceRender?: boolean;
|
|
23
|
+
autoDestroy?: boolean;
|
|
24
|
+
/** @deprecated Please use `autoDestroy` instead */
|
|
25
|
+
destroyPopupOnHide?: boolean;
|
|
26
|
+
mask?: boolean;
|
|
27
|
+
maskClosable?: boolean;
|
|
28
|
+
/** Set popup motion. You can ref `rc-motion` for more info. */
|
|
29
|
+
popupMotion?: CSSMotionProps;
|
|
30
|
+
/** Set mask motion. You can ref `rc-motion` for more info. */
|
|
31
|
+
maskMotion?: CSSMotionProps;
|
|
32
|
+
/** @deprecated Please us `popupMotion` instead. */
|
|
33
|
+
popupTransitionName?: TransitionNameType;
|
|
34
|
+
/** @deprecated Please us `popupMotion` instead. */
|
|
35
|
+
popupAnimation?: AnimationType;
|
|
36
|
+
/** @deprecated Please us `maskMotion` instead. */
|
|
37
|
+
maskTransitionName?: TransitionNameType;
|
|
38
|
+
/** @deprecated Please us `maskMotion` instead. */
|
|
39
|
+
maskAnimation?: AnimationType;
|
|
40
|
+
mouseEnterDelay?: number;
|
|
41
|
+
mouseLeaveDelay?: number;
|
|
42
|
+
focusDelay?: number;
|
|
43
|
+
blurDelay?: number;
|
|
44
|
+
popup: React.ReactNode | (() => React.ReactNode);
|
|
45
|
+
popupPlacement?: string;
|
|
46
|
+
builtinPlacements?: BuildInPlacements;
|
|
47
|
+
popupAlign?: AlignType;
|
|
48
|
+
popupClassName?: string;
|
|
49
|
+
popupStyle?: React.CSSProperties;
|
|
50
|
+
getPopupClassNameFromAlign?: (align: AlignType) => string;
|
|
51
|
+
onPopupClick?: React.MouseEventHandler<HTMLDivElement>;
|
|
52
|
+
alignPoint?: boolean;
|
|
53
|
+
arrow?: boolean | ArrowTypeOuter;
|
|
54
|
+
/** @deprecated Add `className` on `children`. Please add `className` directly instead. */
|
|
55
|
+
className?: string;
|
|
56
|
+
/**
|
|
57
|
+
* @private Get trigger DOM node.
|
|
58
|
+
* Used for some component is function component which can not access by `findDOMNode`
|
|
59
|
+
*/
|
|
60
|
+
getTriggerDOMNode?: (node: React.ReactInstance) => HTMLElement;
|
|
61
|
+
}
|
|
62
|
+
export declare function generateTrigger(PortalComponent?: React.ComponentType<any>): React.ForwardRefExoticComponent<TriggerProps & React.RefAttributes<TriggerRef>>;
|
|
63
|
+
declare const _default: React.ForwardRefExoticComponent<TriggerProps & React.RefAttributes<TriggerRef>>;
|
|
64
|
+
export default _default;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { CSSMotionProps } from 'rc-motion';
|
|
3
|
+
export declare type Placement = 'top' | 'left' | 'right' | 'bottom' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
|
|
4
|
+
export declare type AlignPointTopBottom = 't' | 'b' | 'c';
|
|
5
|
+
export declare type AlignPointLeftRight = 'l' | 'r' | 'c';
|
|
6
|
+
/** Two char of 't' 'b' 'c' 'l' 'r'. Example: 'lt' */
|
|
7
|
+
export declare type AlignPoint = `${AlignPointTopBottom}${AlignPointLeftRight}`;
|
|
8
|
+
export interface AlignType {
|
|
9
|
+
/**
|
|
10
|
+
* move point of source node to align with point of target node.
|
|
11
|
+
* Such as ['tr','cc'], align top right point of source node with center point of target node.
|
|
12
|
+
* Point can be 't'(top), 'b'(bottom), 'c'(center), 'l'(left), 'r'(right) */
|
|
13
|
+
points?: (string | AlignPoint)[];
|
|
14
|
+
/**
|
|
15
|
+
* offset source node by offset[0] in x and offset[1] in y.
|
|
16
|
+
* If offset contains percentage string value, it is relative to sourceNode region.
|
|
17
|
+
*/
|
|
18
|
+
offset?: number[];
|
|
19
|
+
/**
|
|
20
|
+
* offset target node by offset[0] in x and offset[1] in y.
|
|
21
|
+
* If targetOffset contains percentage string value, it is relative to targetNode region.
|
|
22
|
+
*/
|
|
23
|
+
targetOffset?: number[];
|
|
24
|
+
/**
|
|
25
|
+
* If adjustX field is true, will adjust source node in x direction if source node is invisible.
|
|
26
|
+
* If adjustY field is true, will adjust source node in y direction if source node is invisible.
|
|
27
|
+
*/
|
|
28
|
+
overflow?: {
|
|
29
|
+
adjustX?: boolean | number;
|
|
30
|
+
adjustY?: boolean | number;
|
|
31
|
+
shiftX?: boolean | number;
|
|
32
|
+
shiftY?: boolean | number;
|
|
33
|
+
};
|
|
34
|
+
/** Auto adjust arrow position */
|
|
35
|
+
autoArrow?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Config visible region check of html node. Default `visible`:
|
|
38
|
+
* - `visible`: The visible region of user browser window. Use `clientHeight` for check.
|
|
39
|
+
* - `scroll`: The whole region of the html scroll area. Use `scrollHeight` for check.
|
|
40
|
+
*/
|
|
41
|
+
htmlRegion?: 'visible' | 'scroll';
|
|
42
|
+
/**
|
|
43
|
+
* Whether use css right instead of left to position
|
|
44
|
+
*/
|
|
45
|
+
useCssRight?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Whether use css bottom instead of top to position
|
|
48
|
+
*/
|
|
49
|
+
useCssBottom?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Whether use css transform instead of left/top/right/bottom to position if browser supports.
|
|
52
|
+
* Defaults to false.
|
|
53
|
+
*/
|
|
54
|
+
useCssTransform?: boolean;
|
|
55
|
+
ignoreShake?: boolean;
|
|
56
|
+
}
|
|
57
|
+
export interface ArrowTypeOuter {
|
|
58
|
+
className?: string;
|
|
59
|
+
}
|
|
60
|
+
export declare type ArrowType = ArrowTypeOuter & {
|
|
61
|
+
x?: number;
|
|
62
|
+
y?: number;
|
|
63
|
+
};
|
|
64
|
+
export declare type BuildInPlacements = Record<string, AlignType>;
|
|
65
|
+
export declare type StretchType = string;
|
|
66
|
+
export declare type ActionType = 'hover' | 'focus' | 'click' | 'contextMenu';
|
|
67
|
+
export declare type AnimationType = string;
|
|
68
|
+
export declare type TransitionNameType = string;
|
|
69
|
+
export interface Point {
|
|
70
|
+
pageX: number;
|
|
71
|
+
pageY: number;
|
|
72
|
+
}
|
|
73
|
+
export interface CommonEventHandler {
|
|
74
|
+
remove: () => void;
|
|
75
|
+
}
|
|
76
|
+
export interface MobileConfig {
|
|
77
|
+
/** Set popup motion. You can ref `rc-motion` for more info. */
|
|
78
|
+
popupMotion?: CSSMotionProps;
|
|
79
|
+
popupClassName?: string;
|
|
80
|
+
popupStyle?: React.CSSProperties;
|
|
81
|
+
popupRender?: (originNode: React.ReactNode) => React.ReactNode;
|
|
82
|
+
}
|
package/lib/mock.d.ts
ADDED
package/lib/util.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { CSSMotionProps } from 'rc-motion';
|
|
2
|
+
import type { AlignType, AnimationType, BuildInPlacements, TransitionNameType } from './interface';
|
|
3
|
+
export declare function getAlignPopupClassName(builtinPlacements: BuildInPlacements, prefixCls: string, align: AlignType, isAlignPoint: boolean): string;
|
|
4
|
+
/** @deprecated We should not use this if we can refactor all deps */
|
|
5
|
+
export declare function getMotion(prefixCls: string, motion: CSSMotionProps, animation: AnimationType, transitionName: TransitionNameType): CSSMotionProps;
|
|
6
|
+
export declare function getWin(ele: HTMLElement): Window & typeof globalThis;
|
|
7
|
+
/**
|
|
8
|
+
* Get all the scrollable parent elements of the element
|
|
9
|
+
* @param ele The element to be detected
|
|
10
|
+
* @param areaOnly Only return the parent which will cut visible area
|
|
11
|
+
*/
|
|
12
|
+
export declare function collectScroller(ele: HTMLElement): HTMLElement[];
|
|
13
|
+
export declare function toNum(num: number): number;
|
|
14
|
+
export interface VisibleArea {
|
|
15
|
+
left: number;
|
|
16
|
+
top: number;
|
|
17
|
+
right: number;
|
|
18
|
+
bottom: number;
|
|
19
|
+
}
|
|
20
|
+
export declare function getVisibleArea(initArea: VisibleArea, scrollerList?: HTMLElement[]): {
|
|
21
|
+
left: number;
|
|
22
|
+
top: number;
|
|
23
|
+
right: number;
|
|
24
|
+
bottom: number;
|
|
25
|
+
};
|