@rc-component/trigger 3.6.1 → 3.6.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.
@@ -10,6 +10,7 @@ import { isDOM } from "@rc-component/util/es/Dom/findDOMNode";
10
10
  import FloatBg from "./FloatBg";
11
11
  import classNames from 'classnames';
12
12
  import MotionContent from "./MotionContent";
13
+ import { getAlignPopupClassName } from "../util";
13
14
  const UniqueProvider = ({
14
15
  children
15
16
  }) => {
@@ -62,6 +63,14 @@ const UniqueProvider = ({
62
63
  // onPopupAlign
63
64
  false // isMobile
64
65
  );
66
+ const alignedClassName = React.useMemo(() => {
67
+ if (!options) {
68
+ return '';
69
+ }
70
+ const baseClassName = getAlignPopupClassName(options.builtinPlacements || {}, options.prefixCls || '', alignInfo, false // alignPoint is false for UniqueProvider
71
+ );
72
+ return classNames(baseClassName, options.getPopupClassNameFromAlign?.(alignInfo));
73
+ }, [alignInfo, options?.getPopupClassNameFromAlign, options?.builtinPlacements, options?.prefixCls]);
65
74
  const contextValue = React.useMemo(() => ({
66
75
  show,
67
76
  hide
@@ -97,7 +106,7 @@ const UniqueProvider = ({
97
106
  prefixCls: prefixCls,
98
107
  key: popupId
99
108
  }, options.popup),
100
- className: classNames(options.popupClassName, `${prefixCls}-unique-controlled`),
109
+ className: classNames(options.popupClassName, alignedClassName, `${prefixCls}-unique-controlled`),
101
110
  style: options.popupStyle,
102
111
  target: options.target,
103
112
  open: open,
package/es/context.d.ts CHANGED
@@ -25,6 +25,7 @@ export interface UniqueShowOptions {
25
25
  maskMotion?: CSSMotionProps;
26
26
  arrow?: ArrowTypeOuter;
27
27
  getPopupContainer?: TriggerProps['getPopupContainer'];
28
+ getPopupClassNameFromAlign?: (align: AlignType) => string;
28
29
  }
29
30
  export interface UniqueContextProps {
30
31
  show: (options: UniqueShowOptions) => void;
package/es/index.js CHANGED
@@ -172,6 +172,7 @@ export function generateTrigger(PortalComponent = Portal) {
172
172
  maskMotion,
173
173
  arrow: innerArrow,
174
174
  getPopupContainer,
175
+ getPopupClassNameFromAlign,
175
176
  id
176
177
  }));
177
178
 
@@ -16,6 +16,7 @@ var _findDOMNode = require("@rc-component/util/lib/Dom/findDOMNode");
16
16
  var _FloatBg = _interopRequireDefault(require("./FloatBg"));
17
17
  var _classnames = _interopRequireDefault(require("classnames"));
18
18
  var _MotionContent = _interopRequireDefault(require("./MotionContent"));
19
+ var _util2 = require("../util");
19
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
21
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
21
22
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -71,6 +72,14 @@ const UniqueProvider = ({
71
72
  // onPopupAlign
72
73
  false // isMobile
73
74
  );
75
+ const alignedClassName = React.useMemo(() => {
76
+ if (!options) {
77
+ return '';
78
+ }
79
+ const baseClassName = (0, _util2.getAlignPopupClassName)(options.builtinPlacements || {}, options.prefixCls || '', alignInfo, false // alignPoint is false for UniqueProvider
80
+ );
81
+ return (0, _classnames.default)(baseClassName, options.getPopupClassNameFromAlign?.(alignInfo));
82
+ }, [alignInfo, options?.getPopupClassNameFromAlign, options?.builtinPlacements, options?.prefixCls]);
74
83
  const contextValue = React.useMemo(() => ({
75
84
  show,
76
85
  hide
@@ -106,7 +115,7 @@ const UniqueProvider = ({
106
115
  prefixCls: prefixCls,
107
116
  key: popupId
108
117
  }, options.popup),
109
- className: (0, _classnames.default)(options.popupClassName, `${prefixCls}-unique-controlled`),
118
+ className: (0, _classnames.default)(options.popupClassName, alignedClassName, `${prefixCls}-unique-controlled`),
110
119
  style: options.popupStyle,
111
120
  target: options.target,
112
121
  open: open,
package/lib/context.d.ts CHANGED
@@ -25,6 +25,7 @@ export interface UniqueShowOptions {
25
25
  maskMotion?: CSSMotionProps;
26
26
  arrow?: ArrowTypeOuter;
27
27
  getPopupContainer?: TriggerProps['getPopupContainer'];
28
+ getPopupClassNameFromAlign?: (align: AlignType) => string;
28
29
  }
29
30
  export interface UniqueContextProps {
30
31
  show: (options: UniqueShowOptions) => void;
package/lib/index.js CHANGED
@@ -187,6 +187,7 @@ function generateTrigger(PortalComponent = _portal.default) {
187
187
  maskMotion,
188
188
  arrow: innerArrow,
189
189
  getPopupContainer,
190
+ getPopupClassNameFromAlign,
190
191
  id
191
192
  }));
192
193
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rc-component/trigger",
3
- "version": "3.6.1",
3
+ "version": "3.6.2",
4
4
  "description": "base abstract trigger component for react",
5
5
  "engines": {
6
6
  "node": ">=8.x"