1 | "use strict";
|
2 |
|
3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4 |
|
5 | exports.__esModule = true;
|
6 | exports.toModifierMap = toModifierMap;
|
7 | exports.toModifierArray = toModifierArray;
|
8 | exports["default"] = mergeOptionsWithPopperConfig;
|
9 |
|
10 | var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
11 |
|
12 | function toModifierMap(modifiers) {
|
13 | var result = {};
|
14 |
|
15 | if (!Array.isArray(modifiers)) {
|
16 | return modifiers || result;
|
17 | }
|
18 |
|
19 |
|
20 | modifiers == null ? void 0 : modifiers.forEach(function (m) {
|
21 | result[m.name] = m;
|
22 | });
|
23 | return result;
|
24 | }
|
25 |
|
26 | function toModifierArray(map) {
|
27 | if (map === void 0) {
|
28 | map = {};
|
29 | }
|
30 |
|
31 | if (Array.isArray(map)) return map;
|
32 | return Object.keys(map).map(function (k) {
|
33 | map[k].name = k;
|
34 | return map[k];
|
35 | });
|
36 | }
|
37 |
|
38 | function mergeOptionsWithPopperConfig(_ref) {
|
39 | var _modifiers$preventOve, _modifiers$preventOve2, _modifiers$offset, _modifiers$arrow;
|
40 |
|
41 | var enabled = _ref.enabled,
|
42 | enableEvents = _ref.enableEvents,
|
43 | placement = _ref.placement,
|
44 | flip = _ref.flip,
|
45 | offset = _ref.offset,
|
46 | fixed = _ref.fixed,
|
47 | containerPadding = _ref.containerPadding,
|
48 | arrowElement = _ref.arrowElement,
|
49 | _ref$popperConfig = _ref.popperConfig,
|
50 | popperConfig = _ref$popperConfig === void 0 ? {} : _ref$popperConfig;
|
51 | var modifiers = toModifierMap(popperConfig.modifiers);
|
52 | return (0, _extends2["default"])({}, popperConfig, {
|
53 | placement: placement,
|
54 | enabled: enabled,
|
55 | strategy: fixed ? 'fixed' : popperConfig.strategy,
|
56 | modifiers: toModifierArray((0, _extends2["default"])({}, modifiers, {
|
57 | eventListeners: {
|
58 | enabled: enableEvents
|
59 | },
|
60 | preventOverflow: (0, _extends2["default"])({}, modifiers.preventOverflow, {
|
61 | options: containerPadding ? (0, _extends2["default"])({
|
62 | padding: containerPadding
|
63 | }, (_modifiers$preventOve = modifiers.preventOverflow) == null ? void 0 : _modifiers$preventOve.options) : (_modifiers$preventOve2 = modifiers.preventOverflow) == null ? void 0 : _modifiers$preventOve2.options
|
64 | }),
|
65 | offset: {
|
66 | options: (0, _extends2["default"])({
|
67 | offset: offset
|
68 | }, (_modifiers$offset = modifiers.offset) == null ? void 0 : _modifiers$offset.options)
|
69 | },
|
70 | arrow: (0, _extends2["default"])({}, modifiers.arrow, {
|
71 | enabled: !!arrowElement,
|
72 | options: (0, _extends2["default"])({}, (_modifiers$arrow = modifiers.arrow) == null ? void 0 : _modifiers$arrow.options, {
|
73 | element: arrowElement
|
74 | })
|
75 | }),
|
76 | flip: (0, _extends2["default"])({
|
77 | enabled: !!flip
|
78 | }, modifiers.flip)
|
79 | }))
|
80 | });
|
81 | } |
\ | No newline at end of file |