@rc-component/trigger 1.0.0 → 1.0.1

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.
@@ -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,
@@ -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;
package/es/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
- var _excluded = ["prefixCls", "children", "action", "showAction", "hideAction", "popupVisible", "defaultPopupVisible", "onPopupVisibleChange", "afterPopupVisibleChange", "mouseEnterDelay", "mouseLeaveDelay", "focusDelay", "blurDelay", "mask", "maskClosable", "getPopupContainer", "forceRender", "autoDestroy", "destroyPopupOnHide", "popup", "popupClassName", "popupStyle", "popupPlacement", "builtinPlacements", "popupAlign", "zIndex", "stretch", "getPopupClassNameFromAlign", "alignPoint", "onPopupClick", "arrow", "popupMotion", "maskMotion", "popupTransitionName", "popupAnimation", "maskTransitionName", "maskAnimation", "className", "getTriggerDOMNode"];
4
+ var _excluded = ["prefixCls", "children", "action", "showAction", "hideAction", "popupVisible", "defaultPopupVisible", "onPopupVisibleChange", "afterPopupVisibleChange", "mouseEnterDelay", "mouseLeaveDelay", "focusDelay", "blurDelay", "mask", "maskClosable", "getPopupContainer", "forceRender", "autoDestroy", "destroyPopupOnHide", "popup", "popupClassName", "popupStyle", "popupPlacement", "builtinPlacements", "popupAlign", "zIndex", "stretch", "getPopupClassNameFromAlign", "alignPoint", "onPopupClick", "onPopupAlign", "arrow", "popupMotion", "maskMotion", "popupTransitionName", "popupAnimation", "maskTransitionName", "maskAnimation", "className", "getTriggerDOMNode"];
5
5
  import classNames from 'classnames';
6
6
  import ResizeObserver from 'rc-resize-observer';
7
7
  import useEvent from "rc-util/es/hooks/useEvent";
@@ -52,6 +52,7 @@ var Trigger = /*#__PURE__*/React.forwardRef(function (props, ref) {
52
52
  getPopupClassNameFromAlign = props.getPopupClassNameFromAlign,
53
53
  alignPoint = props.alignPoint,
54
54
  onPopupClick = props.onPopupClick,
55
+ onPopupAlign = props.onPopupAlign,
55
56
  arrow = props.arrow,
56
57
  popupMotion = props.popupMotion,
57
58
  maskMotion = props.maskMotion,
@@ -173,7 +174,7 @@ var Trigger = /*#__PURE__*/React.forwardRef(function (props, ref) {
173
174
  var setMousePosByEvent = function setMousePosByEvent(event) {
174
175
  setMousePos([event.clientX, event.clientY]);
175
176
  };
176
- var _useAlign = useAlign(mergedOpen, popupEle, alignPoint ? mousePos : targetEle, popupPlacement, builtinPlacements, popupAlign),
177
+ var _useAlign = useAlign(mergedOpen, popupEle, alignPoint ? mousePos : targetEle, popupPlacement, builtinPlacements, popupAlign, onPopupAlign),
177
178
  _useAlign2 = _slicedToArray(_useAlign, 9),
178
179
  ready = _useAlign2[0],
179
180
  offsetX = _useAlign2[1],
@@ -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,
@@ -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;
package/lib/index.js CHANGED
@@ -23,7 +23,7 @@ var _useWatch = _interopRequireDefault(require("./hooks/useWatch"));
23
23
  var _Popup = _interopRequireDefault(require("./Popup"));
24
24
  var _TriggerWrapper = _interopRequireDefault(require("./TriggerWrapper"));
25
25
  var _util = require("./util");
26
- var _excluded = ["prefixCls", "children", "action", "showAction", "hideAction", "popupVisible", "defaultPopupVisible", "onPopupVisibleChange", "afterPopupVisibleChange", "mouseEnterDelay", "mouseLeaveDelay", "focusDelay", "blurDelay", "mask", "maskClosable", "getPopupContainer", "forceRender", "autoDestroy", "destroyPopupOnHide", "popup", "popupClassName", "popupStyle", "popupPlacement", "builtinPlacements", "popupAlign", "zIndex", "stretch", "getPopupClassNameFromAlign", "alignPoint", "onPopupClick", "arrow", "popupMotion", "maskMotion", "popupTransitionName", "popupAnimation", "maskTransitionName", "maskAnimation", "className", "getTriggerDOMNode"];
26
+ var _excluded = ["prefixCls", "children", "action", "showAction", "hideAction", "popupVisible", "defaultPopupVisible", "onPopupVisibleChange", "afterPopupVisibleChange", "mouseEnterDelay", "mouseLeaveDelay", "focusDelay", "blurDelay", "mask", "maskClosable", "getPopupContainer", "forceRender", "autoDestroy", "destroyPopupOnHide", "popup", "popupClassName", "popupStyle", "popupPlacement", "builtinPlacements", "popupAlign", "zIndex", "stretch", "getPopupClassNameFromAlign", "alignPoint", "onPopupClick", "onPopupAlign", "arrow", "popupMotion", "maskMotion", "popupTransitionName", "popupAnimation", "maskTransitionName", "maskAnimation", "className", "getTriggerDOMNode"];
27
27
  var Trigger = /*#__PURE__*/React.forwardRef(function (props, ref) {
28
28
  var _props$prefixCls = props.prefixCls,
29
29
  prefixCls = _props$prefixCls === void 0 ? 'rc-trigger-popup' : _props$prefixCls,
@@ -60,6 +60,7 @@ var Trigger = /*#__PURE__*/React.forwardRef(function (props, ref) {
60
60
  getPopupClassNameFromAlign = props.getPopupClassNameFromAlign,
61
61
  alignPoint = props.alignPoint,
62
62
  onPopupClick = props.onPopupClick,
63
+ onPopupAlign = props.onPopupAlign,
63
64
  arrow = props.arrow,
64
65
  popupMotion = props.popupMotion,
65
66
  maskMotion = props.maskMotion,
@@ -181,7 +182,7 @@ var Trigger = /*#__PURE__*/React.forwardRef(function (props, ref) {
181
182
  var setMousePosByEvent = function setMousePosByEvent(event) {
182
183
  setMousePos([event.clientX, event.clientY]);
183
184
  };
184
- var _useAlign = (0, _useAlign3.default)(mergedOpen, popupEle, alignPoint ? mousePos : targetEle, popupPlacement, builtinPlacements, popupAlign),
185
+ var _useAlign = (0, _useAlign3.default)(mergedOpen, popupEle, alignPoint ? mousePos : targetEle, popupPlacement, builtinPlacements, popupAlign, onPopupAlign),
185
186
  _useAlign2 = (0, _slicedToArray2.default)(_useAlign, 9),
186
187
  ready = _useAlign2[0],
187
188
  offsetX = _useAlign2[1],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rc-component/trigger",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "base abstract trigger component for react",
5
5
  "engines": {
6
6
  "node": ">=8.x"