1 | "use strict";
|
2 |
|
3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4 |
|
5 | Object.defineProperty(exports, "__esModule", {
|
6 | value: true
|
7 | });
|
8 | exports.default = getPlacements;
|
9 | exports.getOverflowOptions = getOverflowOptions;
|
10 |
|
11 | var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
12 |
|
13 | var _placements = require("../vc-tooltip/src/placements");
|
14 |
|
15 | var autoAdjustOverflowEnabled = {
|
16 | adjustX: 1,
|
17 | adjustY: 1
|
18 | };
|
19 | var autoAdjustOverflowDisabled = {
|
20 | adjustX: 0,
|
21 | adjustY: 0
|
22 | };
|
23 | var targetOffset = [0, 0];
|
24 |
|
25 | function getOverflowOptions(autoAdjustOverflow) {
|
26 | if (typeof autoAdjustOverflow === 'boolean') {
|
27 | return autoAdjustOverflow ? autoAdjustOverflowEnabled : autoAdjustOverflowDisabled;
|
28 | }
|
29 |
|
30 | return (0, _extends2.default)((0, _extends2.default)({}, autoAdjustOverflowDisabled), autoAdjustOverflow);
|
31 | }
|
32 |
|
33 | function getPlacements(config) {
|
34 | var _config$arrowWidth = config.arrowWidth,
|
35 | arrowWidth = _config$arrowWidth === void 0 ? 4 : _config$arrowWidth,
|
36 | _config$horizontalArr = config.horizontalArrowShift,
|
37 | horizontalArrowShift = _config$horizontalArr === void 0 ? 16 : _config$horizontalArr,
|
38 | _config$verticalArrow = config.verticalArrowShift,
|
39 | verticalArrowShift = _config$verticalArrow === void 0 ? 8 : _config$verticalArrow,
|
40 | autoAdjustOverflow = config.autoAdjustOverflow,
|
41 | arrowPointAtCenter = config.arrowPointAtCenter;
|
42 | var placementMap = {
|
43 | left: {
|
44 | points: ['cr', 'cl'],
|
45 | offset: [-4, 0]
|
46 | },
|
47 | right: {
|
48 | points: ['cl', 'cr'],
|
49 | offset: [4, 0]
|
50 | },
|
51 | top: {
|
52 | points: ['bc', 'tc'],
|
53 | offset: [0, -4]
|
54 | },
|
55 | bottom: {
|
56 | points: ['tc', 'bc'],
|
57 | offset: [0, 4]
|
58 | },
|
59 | topLeft: {
|
60 | points: ['bl', 'tc'],
|
61 | offset: [-(horizontalArrowShift + arrowWidth), -4]
|
62 | },
|
63 | leftTop: {
|
64 | points: ['tr', 'cl'],
|
65 | offset: [-4, -(verticalArrowShift + arrowWidth)]
|
66 | },
|
67 | topRight: {
|
68 | points: ['br', 'tc'],
|
69 | offset: [horizontalArrowShift + arrowWidth, -4]
|
70 | },
|
71 | rightTop: {
|
72 | points: ['tl', 'cr'],
|
73 | offset: [4, -(verticalArrowShift + arrowWidth)]
|
74 | },
|
75 | bottomRight: {
|
76 | points: ['tr', 'bc'],
|
77 | offset: [horizontalArrowShift + arrowWidth, 4]
|
78 | },
|
79 | rightBottom: {
|
80 | points: ['bl', 'cr'],
|
81 | offset: [4, verticalArrowShift + arrowWidth]
|
82 | },
|
83 | bottomLeft: {
|
84 | points: ['tl', 'bc'],
|
85 | offset: [-(horizontalArrowShift + arrowWidth), 4]
|
86 | },
|
87 | leftBottom: {
|
88 | points: ['br', 'cl'],
|
89 | offset: [-4, verticalArrowShift + arrowWidth]
|
90 | }
|
91 | };
|
92 | Object.keys(placementMap).forEach(function (key) {
|
93 | placementMap[key] = arrowPointAtCenter ? (0, _extends2.default)((0, _extends2.default)({}, placementMap[key]), {
|
94 | overflow: getOverflowOptions(autoAdjustOverflow),
|
95 | targetOffset: targetOffset
|
96 | }) : (0, _extends2.default)((0, _extends2.default)({}, _placements.placements[key]), {
|
97 | overflow: getOverflowOptions(autoAdjustOverflow)
|
98 | });
|
99 | placementMap[key].ignoreShake = true;
|
100 | });
|
101 | return placementMap;
|
102 | } |
\ | No newline at end of file |