@rc-component/trigger 1.0.0 → 1.0.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/es/Popup/index.d.ts +1 -0
- package/es/Popup/index.js +1 -1
- package/es/hooks/useAlign.d.ts +2 -1
- package/es/hooks/useAlign.js +2 -1
- package/es/index.d.ts +5 -2
- package/es/index.js +398 -391
- package/es/mock.d.ts +3 -0
- package/es/mock.js +11 -0
- package/lib/Popup/index.d.ts +1 -0
- package/lib/Popup/index.js +2 -2
- package/lib/hooks/useAlign.d.ts +2 -1
- package/lib/hooks/useAlign.js +2 -1
- package/lib/index.d.ts +5 -2
- package/lib/index.js +399 -391
- package/lib/mock.d.ts +3 -0
- package/lib/mock.js +19 -0
- package/package.json +2 -2
package/es/Popup/index.d.ts
CHANGED
package/es/Popup/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
|
-
import Portal from '@rc-component/portal';
|
|
5
4
|
import classNames from 'classnames';
|
|
6
5
|
import CSSMotion from 'rc-motion';
|
|
7
6
|
import ResizeObserver from 'rc-resize-observer';
|
|
@@ -29,6 +28,7 @@ var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
29
28
|
forceRender = props.forceRender,
|
|
30
29
|
getPopupContainer = props.getPopupContainer,
|
|
31
30
|
autoDestroy = props.autoDestroy,
|
|
31
|
+
Portal = props.portal,
|
|
32
32
|
zIndex = props.zIndex,
|
|
33
33
|
onMouseEnter = props.onMouseEnter,
|
|
34
34
|
onMouseLeave = props.onMouseLeave,
|
package/es/hooks/useAlign.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { TriggerProps } from '..';
|
|
1
2
|
import type { AlignType } from '../interface';
|
|
2
|
-
export default function useAlign(open: boolean, popupEle: HTMLElement, target: HTMLElement | [x: number, y: number], placement: string, builtinPlacements: any, popupAlign?: AlignType): [
|
|
3
|
+
export default function useAlign(open: boolean, popupEle: HTMLElement, target: HTMLElement | [x: number, y: number], placement: string, builtinPlacements: any, popupAlign?: AlignType, onPopupAlign?: TriggerProps['onPopupAlign']): [
|
|
3
4
|
ready: boolean,
|
|
4
5
|
offsetX: number,
|
|
5
6
|
offsetY: number,
|
package/es/hooks/useAlign.js
CHANGED
|
@@ -53,7 +53,7 @@ function reversePoints(points, index) {
|
|
|
53
53
|
return point;
|
|
54
54
|
}).join('');
|
|
55
55
|
}
|
|
56
|
-
export default function useAlign(open, popupEle, target, placement, builtinPlacements, popupAlign) {
|
|
56
|
+
export default function useAlign(open, popupEle, target, placement, builtinPlacements, popupAlign, onPopupAlign) {
|
|
57
57
|
var _React$useState = React.useState({
|
|
58
58
|
ready: false,
|
|
59
59
|
offsetX: 0,
|
|
@@ -233,6 +233,7 @@ export default function useAlign(open, popupEle, target, placement, builtinPlace
|
|
|
233
233
|
var minBottom = Math.min(popupBottom, targetBottom);
|
|
234
234
|
var yCenter = (maxTop + minBottom) / 2;
|
|
235
235
|
var nextArrowY = yCenter - popupTop;
|
|
236
|
+
onPopupAlign === null || onPopupAlign === void 0 ? void 0 : onPopupAlign(popupEle, nextAlignInfo);
|
|
236
237
|
setOffsetInfo({
|
|
237
238
|
ready: true,
|
|
238
239
|
offsetX: nextOffsetX / _scaleX,
|
package/es/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { CSSMotionProps } from 'rc-motion';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import type { ActionType, AlignType, AnimationType, BuildInPlacements, TransitionNameType } from './interface';
|
|
4
|
+
export type { BuildInPlacements, AlignType, ActionType };
|
|
4
5
|
export interface TriggerRef {
|
|
5
6
|
forceAlign: VoidFunction;
|
|
6
7
|
}
|
|
@@ -11,6 +12,7 @@ export interface TriggerProps {
|
|
|
11
12
|
hideAction?: ActionType[];
|
|
12
13
|
prefixCls?: string;
|
|
13
14
|
zIndex?: number;
|
|
15
|
+
onPopupAlign?: (element: HTMLElement, align: AlignType) => void;
|
|
14
16
|
stretch?: string;
|
|
15
17
|
popupVisible?: boolean;
|
|
16
18
|
defaultPopupVisible?: boolean;
|
|
@@ -57,5 +59,6 @@ export interface TriggerProps {
|
|
|
57
59
|
*/
|
|
58
60
|
getTriggerDOMNode?: (node: React.ReactInstance) => HTMLElement;
|
|
59
61
|
}
|
|
60
|
-
declare
|
|
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;
|