@dynamic-framework/ui-react 1.30.0 → 1.30.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.
Files changed (96) hide show
  1. package/dist/css/dynamic-ui-non-root.css +42 -32
  2. package/dist/css/dynamic-ui-non-root.min.css +2 -2
  3. package/dist/css/dynamic-ui-root.css +1 -1
  4. package/dist/css/dynamic-ui-root.min.css +1 -1
  5. package/dist/css/dynamic-ui.css +42 -32
  6. package/dist/css/dynamic-ui.min.css +2 -2
  7. package/dist/index.esm.js +14 -4
  8. package/dist/index.esm.js.map +1 -1
  9. package/dist/index.js +14 -3
  10. package/dist/index.js.map +1 -1
  11. package/dist/js/cjs/enums.js +65 -0
  12. package/dist/js/cjs/popper-base.js +939 -0
  13. package/dist/js/cjs/popper-lite.js +1260 -0
  14. package/dist/js/cjs/popper.js +1819 -0
  15. package/dist/js/esm/createPopper.js +199 -0
  16. package/dist/js/esm/dom-utils/contains.js +23 -0
  17. package/dist/js/esm/dom-utils/getBoundingClientRect.js +41 -0
  18. package/dist/js/esm/dom-utils/getClippingRect.js +70 -0
  19. package/dist/js/esm/dom-utils/getCompositeRect.js +58 -0
  20. package/dist/js/esm/dom-utils/getComputedStyle.js +4 -0
  21. package/dist/js/esm/dom-utils/getDocumentElement.js +6 -0
  22. package/dist/js/esm/dom-utils/getDocumentRect.js +29 -0
  23. package/dist/js/esm/dom-utils/getHTMLElementScroll.js +6 -0
  24. package/dist/js/esm/dom-utils/getLayoutRect.js +25 -0
  25. package/dist/js/esm/dom-utils/getNodeName.js +3 -0
  26. package/dist/js/esm/dom-utils/getNodeScroll.js +11 -0
  27. package/dist/js/esm/dom-utils/getOffsetParent.js +69 -0
  28. package/dist/js/esm/dom-utils/getParentNode.js +19 -0
  29. package/dist/js/esm/dom-utils/getScrollParent.js +16 -0
  30. package/dist/js/esm/dom-utils/getViewportRect.js +31 -0
  31. package/dist/js/esm/dom-utils/getWindow.js +12 -0
  32. package/dist/js/esm/dom-utils/getWindowScroll.js +10 -0
  33. package/dist/js/esm/dom-utils/getWindowScrollBarX.js +13 -0
  34. package/dist/js/esm/dom-utils/instanceOf.js +23 -0
  35. package/dist/js/esm/dom-utils/isLayoutViewport.js +4 -0
  36. package/dist/js/esm/dom-utils/isScrollParent.js +10 -0
  37. package/dist/js/esm/dom-utils/isTableElement.js +4 -0
  38. package/dist/js/esm/dom-utils/listScrollParents.js +26 -0
  39. package/dist/js/esm/enums.js +31 -0
  40. package/dist/js/esm/index.js +8 -0
  41. package/dist/js/esm/modifiers/applyStyles.js +84 -0
  42. package/dist/js/esm/modifiers/arrow.js +90 -0
  43. package/dist/js/esm/modifiers/computeStyles.js +169 -0
  44. package/dist/js/esm/modifiers/eventListeners.js +49 -0
  45. package/dist/js/esm/modifiers/flip.js +147 -0
  46. package/dist/js/esm/modifiers/hide.js +61 -0
  47. package/dist/js/esm/modifiers/index.js +9 -0
  48. package/dist/js/esm/modifiers/offset.js +54 -0
  49. package/dist/js/esm/modifiers/popperOffsets.js +25 -0
  50. package/dist/js/esm/modifiers/preventOverflow.js +142 -0
  51. package/dist/js/esm/popper-base.js +3 -0
  52. package/dist/js/esm/popper-lite.js +11 -0
  53. package/dist/js/esm/popper.js +20 -0
  54. package/dist/js/esm/types.js +0 -0
  55. package/dist/js/esm/utils/computeAutoPlacement.js +43 -0
  56. package/dist/js/esm/utils/computeOffsets.js +70 -0
  57. package/dist/js/esm/utils/debounce.js +15 -0
  58. package/dist/js/esm/utils/detectOverflow.js +65 -0
  59. package/dist/js/esm/utils/expandToHashMap.js +6 -0
  60. package/dist/js/esm/utils/getAltAxis.js +3 -0
  61. package/dist/js/esm/utils/getAltLen.js +3 -0
  62. package/dist/js/esm/utils/getBasePlacement.js +4 -0
  63. package/dist/js/esm/utils/getFreshSideObject.js +8 -0
  64. package/dist/js/esm/utils/getMainAxisFromPlacement.js +3 -0
  65. package/dist/js/esm/utils/getOppositePlacement.js +11 -0
  66. package/dist/js/esm/utils/getOppositeVariationPlacement.js +9 -0
  67. package/dist/js/esm/utils/getVariation.js +3 -0
  68. package/dist/js/esm/utils/math.js +3 -0
  69. package/dist/js/esm/utils/mergeByName.js +14 -0
  70. package/dist/js/esm/utils/mergePaddingObject.js +4 -0
  71. package/dist/js/esm/utils/orderModifiers.js +44 -0
  72. package/dist/js/esm/utils/rectToClientRect.js +8 -0
  73. package/dist/js/esm/utils/uniqueBy.js +11 -0
  74. package/dist/js/esm/utils/userAgent.js +11 -0
  75. package/dist/js/esm/utils/within.js +8 -0
  76. package/dist/js/umd/enums.js +71 -0
  77. package/dist/js/umd/enums.min.js +6 -0
  78. package/dist/js/umd/popper-base.js +945 -0
  79. package/dist/js/umd/popper-base.min.js +6 -0
  80. package/dist/js/umd/popper-lite.js +1266 -0
  81. package/dist/js/umd/popper-lite.min.js +6 -0
  82. package/dist/js/umd/popper.js +1825 -0
  83. package/dist/js/umd/popper.min.js +6 -0
  84. package/dist/types/components/DSkeleton/DSkeleton.d.ts +3 -0
  85. package/dist/types/components/index.d.ts +1 -0
  86. package/package.json +9 -5
  87. package/src/style/abstracts/variables/_+import.scss +1 -0
  88. package/src/style/abstracts/variables/_breadcrumb.scss +5 -0
  89. package/src/style/abstracts/variables/_modals.scss +6 -6
  90. package/src/style/abstracts/variables/_offcanvas.scss +7 -4
  91. package/src/style/abstracts/variables/_pagination.scss +6 -4
  92. package/src/style/abstracts/variables/_progress.scss +3 -3
  93. package/src/style/base/_alert.scss +0 -2
  94. package/src/style/base/_pagination.scss +11 -1
  95. package/src/style/components/_d-offcanvas.scss +10 -1
  96. package/src/style/components/_d-stepper-desktop.scss +2 -2
@@ -0,0 +1,61 @@
1
+ import { top, bottom, left, right } from "../enums.js";
2
+ import detectOverflow from "../utils/detectOverflow.js";
3
+
4
+ function getSideOffsets(overflow, rect, preventedOffsets) {
5
+ if (preventedOffsets === void 0) {
6
+ preventedOffsets = {
7
+ x: 0,
8
+ y: 0
9
+ };
10
+ }
11
+
12
+ return {
13
+ top: overflow.top - rect.height - preventedOffsets.y,
14
+ right: overflow.right - rect.width + preventedOffsets.x,
15
+ bottom: overflow.bottom - rect.height + preventedOffsets.y,
16
+ left: overflow.left - rect.width - preventedOffsets.x
17
+ };
18
+ }
19
+
20
+ function isAnySideFullyClipped(overflow) {
21
+ return [top, right, bottom, left].some(function (side) {
22
+ return overflow[side] >= 0;
23
+ });
24
+ }
25
+
26
+ function hide(_ref) {
27
+ var state = _ref.state,
28
+ name = _ref.name;
29
+ var referenceRect = state.rects.reference;
30
+ var popperRect = state.rects.popper;
31
+ var preventedOffsets = state.modifiersData.preventOverflow;
32
+ var referenceOverflow = detectOverflow(state, {
33
+ elementContext: 'reference'
34
+ });
35
+ var popperAltOverflow = detectOverflow(state, {
36
+ altBoundary: true
37
+ });
38
+ var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
39
+ var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
40
+ var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
41
+ var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
42
+ state.modifiersData[name] = {
43
+ referenceClippingOffsets: referenceClippingOffsets,
44
+ popperEscapeOffsets: popperEscapeOffsets,
45
+ isReferenceHidden: isReferenceHidden,
46
+ hasPopperEscaped: hasPopperEscaped
47
+ };
48
+ state.attributes.popper = Object.assign({}, state.attributes.popper, {
49
+ 'data-popper-reference-hidden': isReferenceHidden,
50
+ 'data-popper-escaped': hasPopperEscaped
51
+ });
52
+ } // eslint-disable-next-line import/no-unused-modules
53
+
54
+
55
+ export default {
56
+ name: 'hide',
57
+ enabled: true,
58
+ phase: 'main',
59
+ requiresIfExists: ['preventOverflow'],
60
+ fn: hide
61
+ };
@@ -0,0 +1,9 @@
1
+ export { default as applyStyles } from "./applyStyles.js";
2
+ export { default as arrow } from "./arrow.js";
3
+ export { default as computeStyles } from "./computeStyles.js";
4
+ export { default as eventListeners } from "./eventListeners.js";
5
+ export { default as flip } from "./flip.js";
6
+ export { default as hide } from "./hide.js";
7
+ export { default as offset } from "./offset.js";
8
+ export { default as popperOffsets } from "./popperOffsets.js";
9
+ export { default as preventOverflow } from "./preventOverflow.js";
@@ -0,0 +1,54 @@
1
+ import getBasePlacement from "../utils/getBasePlacement.js";
2
+ import { top, left, right, placements } from "../enums.js"; // eslint-disable-next-line import/no-unused-modules
3
+
4
+ export function distanceAndSkiddingToXY(placement, rects, offset) {
5
+ var basePlacement = getBasePlacement(placement);
6
+ var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
7
+
8
+ var _ref = typeof offset === 'function' ? offset(Object.assign({}, rects, {
9
+ placement: placement
10
+ })) : offset,
11
+ skidding = _ref[0],
12
+ distance = _ref[1];
13
+
14
+ skidding = skidding || 0;
15
+ distance = (distance || 0) * invertDistance;
16
+ return [left, right].indexOf(basePlacement) >= 0 ? {
17
+ x: distance,
18
+ y: skidding
19
+ } : {
20
+ x: skidding,
21
+ y: distance
22
+ };
23
+ }
24
+
25
+ function offset(_ref2) {
26
+ var state = _ref2.state,
27
+ options = _ref2.options,
28
+ name = _ref2.name;
29
+ var _options$offset = options.offset,
30
+ offset = _options$offset === void 0 ? [0, 0] : _options$offset;
31
+ var data = placements.reduce(function (acc, placement) {
32
+ acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
33
+ return acc;
34
+ }, {});
35
+ var _data$state$placement = data[state.placement],
36
+ x = _data$state$placement.x,
37
+ y = _data$state$placement.y;
38
+
39
+ if (state.modifiersData.popperOffsets != null) {
40
+ state.modifiersData.popperOffsets.x += x;
41
+ state.modifiersData.popperOffsets.y += y;
42
+ }
43
+
44
+ state.modifiersData[name] = data;
45
+ } // eslint-disable-next-line import/no-unused-modules
46
+
47
+
48
+ export default {
49
+ name: 'offset',
50
+ enabled: true,
51
+ phase: 'main',
52
+ requires: ['popperOffsets'],
53
+ fn: offset
54
+ };
@@ -0,0 +1,25 @@
1
+ import computeOffsets from "../utils/computeOffsets.js";
2
+
3
+ function popperOffsets(_ref) {
4
+ var state = _ref.state,
5
+ name = _ref.name;
6
+ // Offsets are the actual position the popper needs to have to be
7
+ // properly positioned near its reference element
8
+ // This is the most basic placement, and will be adjusted by
9
+ // the modifiers in the next step
10
+ state.modifiersData[name] = computeOffsets({
11
+ reference: state.rects.reference,
12
+ element: state.rects.popper,
13
+ strategy: 'absolute',
14
+ placement: state.placement
15
+ });
16
+ } // eslint-disable-next-line import/no-unused-modules
17
+
18
+
19
+ export default {
20
+ name: 'popperOffsets',
21
+ enabled: true,
22
+ phase: 'read',
23
+ fn: popperOffsets,
24
+ data: {}
25
+ };
@@ -0,0 +1,142 @@
1
+ import { top, left, right, bottom, start } from "../enums.js";
2
+ import getBasePlacement from "../utils/getBasePlacement.js";
3
+ import getMainAxisFromPlacement from "../utils/getMainAxisFromPlacement.js";
4
+ import getAltAxis from "../utils/getAltAxis.js";
5
+ import { within, withinMaxClamp } from "../utils/within.js";
6
+ import getLayoutRect from "../dom-utils/getLayoutRect.js";
7
+ import getOffsetParent from "../dom-utils/getOffsetParent.js";
8
+ import detectOverflow from "../utils/detectOverflow.js";
9
+ import getVariation from "../utils/getVariation.js";
10
+ import getFreshSideObject from "../utils/getFreshSideObject.js";
11
+ import { min as mathMin, max as mathMax } from "../utils/math.js";
12
+
13
+ function preventOverflow(_ref) {
14
+ var state = _ref.state,
15
+ options = _ref.options,
16
+ name = _ref.name;
17
+ var _options$mainAxis = options.mainAxis,
18
+ checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
19
+ _options$altAxis = options.altAxis,
20
+ checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis,
21
+ boundary = options.boundary,
22
+ rootBoundary = options.rootBoundary,
23
+ altBoundary = options.altBoundary,
24
+ padding = options.padding,
25
+ _options$tether = options.tether,
26
+ tether = _options$tether === void 0 ? true : _options$tether,
27
+ _options$tetherOffset = options.tetherOffset,
28
+ tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
29
+ var overflow = detectOverflow(state, {
30
+ boundary: boundary,
31
+ rootBoundary: rootBoundary,
32
+ padding: padding,
33
+ altBoundary: altBoundary
34
+ });
35
+ var basePlacement = getBasePlacement(state.placement);
36
+ var variation = getVariation(state.placement);
37
+ var isBasePlacement = !variation;
38
+ var mainAxis = getMainAxisFromPlacement(basePlacement);
39
+ var altAxis = getAltAxis(mainAxis);
40
+ var popperOffsets = state.modifiersData.popperOffsets;
41
+ var referenceRect = state.rects.reference;
42
+ var popperRect = state.rects.popper;
43
+ var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
44
+ placement: state.placement
45
+ })) : tetherOffset;
46
+ var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {
47
+ mainAxis: tetherOffsetValue,
48
+ altAxis: tetherOffsetValue
49
+ } : Object.assign({
50
+ mainAxis: 0,
51
+ altAxis: 0
52
+ }, tetherOffsetValue);
53
+ var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
54
+ var data = {
55
+ x: 0,
56
+ y: 0
57
+ };
58
+
59
+ if (!popperOffsets) {
60
+ return;
61
+ }
62
+
63
+ if (checkMainAxis) {
64
+ var _offsetModifierState$;
65
+
66
+ var mainSide = mainAxis === 'y' ? top : left;
67
+ var altSide = mainAxis === 'y' ? bottom : right;
68
+ var len = mainAxis === 'y' ? 'height' : 'width';
69
+ var offset = popperOffsets[mainAxis];
70
+ var min = offset + overflow[mainSide];
71
+ var max = offset - overflow[altSide];
72
+ var additive = tether ? -popperRect[len] / 2 : 0;
73
+ var minLen = variation === start ? referenceRect[len] : popperRect[len];
74
+ var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
75
+ // outside the reference bounds
76
+
77
+ var arrowElement = state.elements.arrow;
78
+ var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
79
+ width: 0,
80
+ height: 0
81
+ };
82
+ var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();
83
+ var arrowPaddingMin = arrowPaddingObject[mainSide];
84
+ var arrowPaddingMax = arrowPaddingObject[altSide]; // If the reference length is smaller than the arrow length, we don't want
85
+ // to include its full size in the calculation. If the reference is small
86
+ // and near the edge of a boundary, the popper can overflow even if the
87
+ // reference is not overflowing as well (e.g. virtual elements with no
88
+ // width or height)
89
+
90
+ var arrowLen = within(0, referenceRect[len], arrowRect[len]);
91
+ var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
92
+ var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
93
+ var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
94
+ var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
95
+ var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
96
+ var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
97
+ var tetherMax = offset + maxOffset - offsetModifierValue;
98
+ var preventedOffset = within(tether ? mathMin(min, tetherMin) : min, offset, tether ? mathMax(max, tetherMax) : max);
99
+ popperOffsets[mainAxis] = preventedOffset;
100
+ data[mainAxis] = preventedOffset - offset;
101
+ }
102
+
103
+ if (checkAltAxis) {
104
+ var _offsetModifierState$2;
105
+
106
+ var _mainSide = mainAxis === 'x' ? top : left;
107
+
108
+ var _altSide = mainAxis === 'x' ? bottom : right;
109
+
110
+ var _offset = popperOffsets[altAxis];
111
+
112
+ var _len = altAxis === 'y' ? 'height' : 'width';
113
+
114
+ var _min = _offset + overflow[_mainSide];
115
+
116
+ var _max = _offset - overflow[_altSide];
117
+
118
+ var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
119
+
120
+ var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
121
+
122
+ var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
123
+
124
+ var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
125
+
126
+ var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
127
+
128
+ popperOffsets[altAxis] = _preventedOffset;
129
+ data[altAxis] = _preventedOffset - _offset;
130
+ }
131
+
132
+ state.modifiersData[name] = data;
133
+ } // eslint-disable-next-line import/no-unused-modules
134
+
135
+
136
+ export default {
137
+ name: 'preventOverflow',
138
+ enabled: true,
139
+ phase: 'main',
140
+ fn: preventOverflow,
141
+ requiresIfExists: ['offset']
142
+ };
@@ -0,0 +1,3 @@
1
+ import { createPopper, popperGenerator, detectOverflow } from "./createPopper.js";
2
+ // eslint-disable-next-line import/no-unused-modules
3
+ export { createPopper, popperGenerator, detectOverflow };
@@ -0,0 +1,11 @@
1
+ import { popperGenerator, detectOverflow } from "./createPopper.js";
2
+ import eventListeners from "./modifiers/eventListeners.js";
3
+ import popperOffsets from "./modifiers/popperOffsets.js";
4
+ import computeStyles from "./modifiers/computeStyles.js";
5
+ import applyStyles from "./modifiers/applyStyles.js";
6
+ var defaultModifiers = [eventListeners, popperOffsets, computeStyles, applyStyles];
7
+ var createPopper = /*#__PURE__*/popperGenerator({
8
+ defaultModifiers: defaultModifiers
9
+ }); // eslint-disable-next-line import/no-unused-modules
10
+
11
+ export { createPopper, popperGenerator, defaultModifiers, detectOverflow };
@@ -0,0 +1,20 @@
1
+ import { popperGenerator, detectOverflow } from "./createPopper.js";
2
+ import eventListeners from "./modifiers/eventListeners.js";
3
+ import popperOffsets from "./modifiers/popperOffsets.js";
4
+ import computeStyles from "./modifiers/computeStyles.js";
5
+ import applyStyles from "./modifiers/applyStyles.js";
6
+ import offset from "./modifiers/offset.js";
7
+ import flip from "./modifiers/flip.js";
8
+ import preventOverflow from "./modifiers/preventOverflow.js";
9
+ import arrow from "./modifiers/arrow.js";
10
+ import hide from "./modifiers/hide.js";
11
+ var defaultModifiers = [eventListeners, popperOffsets, computeStyles, applyStyles, offset, flip, preventOverflow, arrow, hide];
12
+ var createPopper = /*#__PURE__*/popperGenerator({
13
+ defaultModifiers: defaultModifiers
14
+ }); // eslint-disable-next-line import/no-unused-modules
15
+
16
+ export { createPopper, popperGenerator, defaultModifiers, detectOverflow }; // eslint-disable-next-line import/no-unused-modules
17
+
18
+ export { createPopper as createPopperLite } from "./popper-lite.js"; // eslint-disable-next-line import/no-unused-modules
19
+
20
+ export * from "./modifiers/index.js";
File without changes
@@ -0,0 +1,43 @@
1
+ import getVariation from "./getVariation.js";
2
+ import { variationPlacements, basePlacements, placements as allPlacements } from "../enums.js";
3
+ import detectOverflow from "./detectOverflow.js";
4
+ import getBasePlacement from "./getBasePlacement.js";
5
+ export default function computeAutoPlacement(state, options) {
6
+ if (options === void 0) {
7
+ options = {};
8
+ }
9
+
10
+ var _options = options,
11
+ placement = _options.placement,
12
+ boundary = _options.boundary,
13
+ rootBoundary = _options.rootBoundary,
14
+ padding = _options.padding,
15
+ flipVariations = _options.flipVariations,
16
+ _options$allowedAutoP = _options.allowedAutoPlacements,
17
+ allowedAutoPlacements = _options$allowedAutoP === void 0 ? allPlacements : _options$allowedAutoP;
18
+ var variation = getVariation(placement);
19
+ var placements = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {
20
+ return getVariation(placement) === variation;
21
+ }) : basePlacements;
22
+ var allowedPlacements = placements.filter(function (placement) {
23
+ return allowedAutoPlacements.indexOf(placement) >= 0;
24
+ });
25
+
26
+ if (allowedPlacements.length === 0) {
27
+ allowedPlacements = placements;
28
+ } // $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions...
29
+
30
+
31
+ var overflows = allowedPlacements.reduce(function (acc, placement) {
32
+ acc[placement] = detectOverflow(state, {
33
+ placement: placement,
34
+ boundary: boundary,
35
+ rootBoundary: rootBoundary,
36
+ padding: padding
37
+ })[getBasePlacement(placement)];
38
+ return acc;
39
+ }, {});
40
+ return Object.keys(overflows).sort(function (a, b) {
41
+ return overflows[a] - overflows[b];
42
+ });
43
+ }
@@ -0,0 +1,70 @@
1
+ import getBasePlacement from "./getBasePlacement.js";
2
+ import getVariation from "./getVariation.js";
3
+ import getMainAxisFromPlacement from "./getMainAxisFromPlacement.js";
4
+ import { top, right, bottom, left, start, end } from "../enums.js";
5
+ export default function computeOffsets(_ref) {
6
+ var reference = _ref.reference,
7
+ element = _ref.element,
8
+ placement = _ref.placement;
9
+ var basePlacement = placement ? getBasePlacement(placement) : null;
10
+ var variation = placement ? getVariation(placement) : null;
11
+ var commonX = reference.x + reference.width / 2 - element.width / 2;
12
+ var commonY = reference.y + reference.height / 2 - element.height / 2;
13
+ var offsets;
14
+
15
+ switch (basePlacement) {
16
+ case top:
17
+ offsets = {
18
+ x: commonX,
19
+ y: reference.y - element.height
20
+ };
21
+ break;
22
+
23
+ case bottom:
24
+ offsets = {
25
+ x: commonX,
26
+ y: reference.y + reference.height
27
+ };
28
+ break;
29
+
30
+ case right:
31
+ offsets = {
32
+ x: reference.x + reference.width,
33
+ y: commonY
34
+ };
35
+ break;
36
+
37
+ case left:
38
+ offsets = {
39
+ x: reference.x - element.width,
40
+ y: commonY
41
+ };
42
+ break;
43
+
44
+ default:
45
+ offsets = {
46
+ x: reference.x,
47
+ y: reference.y
48
+ };
49
+ }
50
+
51
+ var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
52
+
53
+ if (mainAxis != null) {
54
+ var len = mainAxis === 'y' ? 'height' : 'width';
55
+
56
+ switch (variation) {
57
+ case start:
58
+ offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
59
+ break;
60
+
61
+ case end:
62
+ offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
63
+ break;
64
+
65
+ default:
66
+ }
67
+ }
68
+
69
+ return offsets;
70
+ }
@@ -0,0 +1,15 @@
1
+ export default function debounce(fn) {
2
+ var pending;
3
+ return function () {
4
+ if (!pending) {
5
+ pending = new Promise(function (resolve) {
6
+ Promise.resolve().then(function () {
7
+ pending = undefined;
8
+ resolve(fn());
9
+ });
10
+ });
11
+ }
12
+
13
+ return pending;
14
+ };
15
+ }
@@ -0,0 +1,65 @@
1
+ import getClippingRect from "../dom-utils/getClippingRect.js";
2
+ import getDocumentElement from "../dom-utils/getDocumentElement.js";
3
+ import getBoundingClientRect from "../dom-utils/getBoundingClientRect.js";
4
+ import computeOffsets from "./computeOffsets.js";
5
+ import rectToClientRect from "./rectToClientRect.js";
6
+ import { clippingParents, reference, popper, bottom, top, right, basePlacements, viewport } from "../enums.js";
7
+ import { isElement } from "../dom-utils/instanceOf.js";
8
+ import mergePaddingObject from "./mergePaddingObject.js";
9
+ import expandToHashMap from "./expandToHashMap.js"; // eslint-disable-next-line import/no-unused-modules
10
+
11
+ export default function detectOverflow(state, options) {
12
+ if (options === void 0) {
13
+ options = {};
14
+ }
15
+
16
+ var _options = options,
17
+ _options$placement = _options.placement,
18
+ placement = _options$placement === void 0 ? state.placement : _options$placement,
19
+ _options$strategy = _options.strategy,
20
+ strategy = _options$strategy === void 0 ? state.strategy : _options$strategy,
21
+ _options$boundary = _options.boundary,
22
+ boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
23
+ _options$rootBoundary = _options.rootBoundary,
24
+ rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
25
+ _options$elementConte = _options.elementContext,
26
+ elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
27
+ _options$altBoundary = _options.altBoundary,
28
+ altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
29
+ _options$padding = _options.padding,
30
+ padding = _options$padding === void 0 ? 0 : _options$padding;
31
+ var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
32
+ var altContext = elementContext === popper ? reference : popper;
33
+ var popperRect = state.rects.popper;
34
+ var element = state.elements[altBoundary ? altContext : elementContext];
35
+ var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);
36
+ var referenceClientRect = getBoundingClientRect(state.elements.reference);
37
+ var popperOffsets = computeOffsets({
38
+ reference: referenceClientRect,
39
+ element: popperRect,
40
+ strategy: 'absolute',
41
+ placement: placement
42
+ });
43
+ var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));
44
+ var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
45
+ // 0 or negative = within the clipping rect
46
+
47
+ var overflowOffsets = {
48
+ top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
49
+ bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
50
+ left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
51
+ right: elementClientRect.right - clippingClientRect.right + paddingObject.right
52
+ };
53
+ var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element
54
+
55
+ if (elementContext === popper && offsetData) {
56
+ var offset = offsetData[placement];
57
+ Object.keys(overflowOffsets).forEach(function (key) {
58
+ var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
59
+ var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
60
+ overflowOffsets[key] += offset[axis] * multiply;
61
+ });
62
+ }
63
+
64
+ return overflowOffsets;
65
+ }
@@ -0,0 +1,6 @@
1
+ export default function expandToHashMap(value, keys) {
2
+ return keys.reduce(function (hashMap, key) {
3
+ hashMap[key] = value;
4
+ return hashMap;
5
+ }, {});
6
+ }
@@ -0,0 +1,3 @@
1
+ export default function getAltAxis(axis) {
2
+ return axis === 'x' ? 'y' : 'x';
3
+ }
@@ -0,0 +1,3 @@
1
+ export default function getAltLen(len) {
2
+ return len === 'width' ? 'height' : 'width';
3
+ }
@@ -0,0 +1,4 @@
1
+ import { auto } from "../enums.js";
2
+ export default function getBasePlacement(placement) {
3
+ return placement.split('-')[0];
4
+ }
@@ -0,0 +1,8 @@
1
+ export default function getFreshSideObject() {
2
+ return {
3
+ top: 0,
4
+ right: 0,
5
+ bottom: 0,
6
+ left: 0
7
+ };
8
+ }
@@ -0,0 +1,3 @@
1
+ export default function getMainAxisFromPlacement(placement) {
2
+ return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
3
+ }
@@ -0,0 +1,11 @@
1
+ var hash = {
2
+ left: 'right',
3
+ right: 'left',
4
+ bottom: 'top',
5
+ top: 'bottom'
6
+ };
7
+ export default function getOppositePlacement(placement) {
8
+ return placement.replace(/left|right|bottom|top/g, function (matched) {
9
+ return hash[matched];
10
+ });
11
+ }
@@ -0,0 +1,9 @@
1
+ var hash = {
2
+ start: 'end',
3
+ end: 'start'
4
+ };
5
+ export default function getOppositeVariationPlacement(placement) {
6
+ return placement.replace(/start|end/g, function (matched) {
7
+ return hash[matched];
8
+ });
9
+ }
@@ -0,0 +1,3 @@
1
+ export default function getVariation(placement) {
2
+ return placement.split('-')[1];
3
+ }
@@ -0,0 +1,3 @@
1
+ export var max = Math.max;
2
+ export var min = Math.min;
3
+ export var round = Math.round;
@@ -0,0 +1,14 @@
1
+ export default function mergeByName(modifiers) {
2
+ var merged = modifiers.reduce(function (merged, current) {
3
+ var existing = merged[current.name];
4
+ merged[current.name] = existing ? Object.assign({}, existing, current, {
5
+ options: Object.assign({}, existing.options, current.options),
6
+ data: Object.assign({}, existing.data, current.data)
7
+ }) : current;
8
+ return merged;
9
+ }, {}); // IE11 does not support Object.values
10
+
11
+ return Object.keys(merged).map(function (key) {
12
+ return merged[key];
13
+ });
14
+ }
@@ -0,0 +1,4 @@
1
+ import getFreshSideObject from "./getFreshSideObject.js";
2
+ export default function mergePaddingObject(paddingObject) {
3
+ return Object.assign({}, getFreshSideObject(), paddingObject);
4
+ }