@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/mock.d.ts
ADDED
package/es/mock.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { generateTrigger } from "./index";
|
|
3
|
+
var MockPortal = function MockPortal(_ref) {
|
|
4
|
+
var children = _ref.children,
|
|
5
|
+
getContainer = _ref.getContainer;
|
|
6
|
+
React.useEffect(function () {
|
|
7
|
+
getContainer();
|
|
8
|
+
});
|
|
9
|
+
return children;
|
|
10
|
+
};
|
|
11
|
+
export default generateTrigger(MockPortal);
|
package/lib/Popup/index.d.ts
CHANGED
package/lib/Popup/index.js
CHANGED
|
@@ -9,7 +9,6 @@ exports.default = void 0;
|
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
10
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
11
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
|
-
var _portal = _interopRequireDefault(require("@rc-component/portal"));
|
|
13
12
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
14
13
|
var _rcMotion = _interopRequireDefault(require("rc-motion"));
|
|
15
14
|
var _rcResizeObserver = _interopRequireDefault(require("rc-resize-observer"));
|
|
@@ -37,6 +36,7 @@ var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
37
36
|
forceRender = props.forceRender,
|
|
38
37
|
getPopupContainer = props.getPopupContainer,
|
|
39
38
|
autoDestroy = props.autoDestroy,
|
|
39
|
+
Portal = props.portal,
|
|
40
40
|
zIndex = props.zIndex,
|
|
41
41
|
onMouseEnter = props.onMouseEnter,
|
|
42
42
|
onMouseLeave = props.onMouseLeave,
|
|
@@ -98,7 +98,7 @@ var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
98
98
|
if (!open) {
|
|
99
99
|
miscStyle.pointerEvents = 'none';
|
|
100
100
|
}
|
|
101
|
-
return /*#__PURE__*/React.createElement(
|
|
101
|
+
return /*#__PURE__*/React.createElement(Portal, {
|
|
102
102
|
open: forceRender || isNodeVisible,
|
|
103
103
|
getContainer: getPopupContainer && function () {
|
|
104
104
|
return getPopupContainer(target);
|
package/lib/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/lib/hooks/useAlign.js
CHANGED
|
@@ -61,7 +61,7 @@ function reversePoints(points, index) {
|
|
|
61
61
|
return point;
|
|
62
62
|
}).join('');
|
|
63
63
|
}
|
|
64
|
-
function useAlign(open, popupEle, target, placement, builtinPlacements, popupAlign) {
|
|
64
|
+
function useAlign(open, popupEle, target, placement, builtinPlacements, popupAlign, onPopupAlign) {
|
|
65
65
|
var _React$useState = React.useState({
|
|
66
66
|
ready: false,
|
|
67
67
|
offsetX: 0,
|
|
@@ -241,6 +241,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
|
|
|
241
241
|
var minBottom = Math.min(popupBottom, targetBottom);
|
|
242
242
|
var yCenter = (maxTop + minBottom) / 2;
|
|
243
243
|
var nextArrowY = yCenter - popupTop;
|
|
244
|
+
onPopupAlign === null || onPopupAlign === void 0 ? void 0 : onPopupAlign(popupEle, nextAlignInfo);
|
|
244
245
|
setOffsetInfo({
|
|
245
246
|
ready: true,
|
|
246
247
|
offsetX: nextOffsetX / _scaleX,
|
package/lib/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;
|