UNPKG

1.18 kBJavaScriptView Raw
1"use strict";
2
3var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
5Object.defineProperty(exports, "__esModule", {
6 value: true
7});
8exports.getAlignFromPlacement = getAlignFromPlacement;
9exports.getAlignPopupClassName = getAlignPopupClassName;
10
11var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
12
13function isPointsEq(a1, a2, isAlignPoint) {
14 if (isAlignPoint) {
15 return a1[0] === a2[0];
16 }
17
18 return a1[0] === a2[0] && a1[1] === a2[1];
19}
20
21function getAlignFromPlacement(builtinPlacements, placementStr, align) {
22 var baseAlign = builtinPlacements[placementStr] || {};
23 return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, baseAlign), align);
24}
25
26function getAlignPopupClassName(builtinPlacements, prefixCls, align, isAlignPoint) {
27 var points = align.points;
28 var placements = Object.keys(builtinPlacements);
29
30 for (var i = 0; i < placements.length; i += 1) {
31 var placement = placements[i];
32
33 if (isPointsEq(builtinPlacements[placement].points, points, isAlignPoint)) {
34 return "".concat(prefixCls, "-placement-").concat(placement);
35 }
36 }
37
38 return '';
39}
\No newline at end of file