@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,199 @@
1
+ import getCompositeRect from "./dom-utils/getCompositeRect.js";
2
+ import getLayoutRect from "./dom-utils/getLayoutRect.js";
3
+ import listScrollParents from "./dom-utils/listScrollParents.js";
4
+ import getOffsetParent from "./dom-utils/getOffsetParent.js";
5
+ import orderModifiers from "./utils/orderModifiers.js";
6
+ import debounce from "./utils/debounce.js";
7
+ import mergeByName from "./utils/mergeByName.js";
8
+ import detectOverflow from "./utils/detectOverflow.js";
9
+ import { isElement } from "./dom-utils/instanceOf.js";
10
+ var DEFAULT_OPTIONS = {
11
+ placement: 'bottom',
12
+ modifiers: [],
13
+ strategy: 'absolute'
14
+ };
15
+
16
+ function areValidElements() {
17
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
18
+ args[_key] = arguments[_key];
19
+ }
20
+
21
+ return !args.some(function (element) {
22
+ return !(element && typeof element.getBoundingClientRect === 'function');
23
+ });
24
+ }
25
+
26
+ export function popperGenerator(generatorOptions) {
27
+ if (generatorOptions === void 0) {
28
+ generatorOptions = {};
29
+ }
30
+
31
+ var _generatorOptions = generatorOptions,
32
+ _generatorOptions$def = _generatorOptions.defaultModifiers,
33
+ defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,
34
+ _generatorOptions$def2 = _generatorOptions.defaultOptions,
35
+ defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
36
+ return function createPopper(reference, popper, options) {
37
+ if (options === void 0) {
38
+ options = defaultOptions;
39
+ }
40
+
41
+ var state = {
42
+ placement: 'bottom',
43
+ orderedModifiers: [],
44
+ options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
45
+ modifiersData: {},
46
+ elements: {
47
+ reference: reference,
48
+ popper: popper
49
+ },
50
+ attributes: {},
51
+ styles: {}
52
+ };
53
+ var effectCleanupFns = [];
54
+ var isDestroyed = false;
55
+ var instance = {
56
+ state: state,
57
+ setOptions: function setOptions(setOptionsAction) {
58
+ var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
59
+ cleanupModifierEffects();
60
+ state.options = Object.assign({}, defaultOptions, state.options, options);
61
+ state.scrollParents = {
62
+ reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
63
+ popper: listScrollParents(popper)
64
+ }; // Orders the modifiers based on their dependencies and `phase`
65
+ // properties
66
+
67
+ var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers
68
+
69
+ state.orderedModifiers = orderedModifiers.filter(function (m) {
70
+ return m.enabled;
71
+ });
72
+ runModifierEffects();
73
+ return instance.update();
74
+ },
75
+ // Sync update – it will always be executed, even if not necessary. This
76
+ // is useful for low frequency updates where sync behavior simplifies the
77
+ // logic.
78
+ // For high frequency updates (e.g. `resize` and `scroll` events), always
79
+ // prefer the async Popper#update method
80
+ forceUpdate: function forceUpdate() {
81
+ if (isDestroyed) {
82
+ return;
83
+ }
84
+
85
+ var _state$elements = state.elements,
86
+ reference = _state$elements.reference,
87
+ popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements
88
+ // anymore
89
+
90
+ if (!areValidElements(reference, popper)) {
91
+ return;
92
+ } // Store the reference and popper rects to be read by modifiers
93
+
94
+
95
+ state.rects = {
96
+ reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
97
+ popper: getLayoutRect(popper)
98
+ }; // Modifiers have the ability to reset the current update cycle. The
99
+ // most common use case for this is the `flip` modifier changing the
100
+ // placement, which then needs to re-run all the modifiers, because the
101
+ // logic was previously ran for the previous placement and is therefore
102
+ // stale/incorrect
103
+
104
+ state.reset = false;
105
+ state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier
106
+ // is filled with the initial data specified by the modifier. This means
107
+ // it doesn't persist and is fresh on each update.
108
+ // To ensure persistent data, use `${name}#persistent`
109
+
110
+ state.orderedModifiers.forEach(function (modifier) {
111
+ return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
112
+ });
113
+
114
+ for (var index = 0; index < state.orderedModifiers.length; index++) {
115
+ if (state.reset === true) {
116
+ state.reset = false;
117
+ index = -1;
118
+ continue;
119
+ }
120
+
121
+ var _state$orderedModifie = state.orderedModifiers[index],
122
+ fn = _state$orderedModifie.fn,
123
+ _state$orderedModifie2 = _state$orderedModifie.options,
124
+ _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,
125
+ name = _state$orderedModifie.name;
126
+
127
+ if (typeof fn === 'function') {
128
+ state = fn({
129
+ state: state,
130
+ options: _options,
131
+ name: name,
132
+ instance: instance
133
+ }) || state;
134
+ }
135
+ }
136
+ },
137
+ // Async and optimistically optimized update – it will not be executed if
138
+ // not necessary (debounced to run at most once-per-tick)
139
+ update: debounce(function () {
140
+ return new Promise(function (resolve) {
141
+ instance.forceUpdate();
142
+ resolve(state);
143
+ });
144
+ }),
145
+ destroy: function destroy() {
146
+ cleanupModifierEffects();
147
+ isDestroyed = true;
148
+ }
149
+ };
150
+
151
+ if (!areValidElements(reference, popper)) {
152
+ return instance;
153
+ }
154
+
155
+ instance.setOptions(options).then(function (state) {
156
+ if (!isDestroyed && options.onFirstUpdate) {
157
+ options.onFirstUpdate(state);
158
+ }
159
+ }); // Modifiers have the ability to execute arbitrary code before the first
160
+ // update cycle runs. They will be executed in the same order as the update
161
+ // cycle. This is useful when a modifier adds some persistent data that
162
+ // other modifiers need to use, but the modifier is run after the dependent
163
+ // one.
164
+
165
+ function runModifierEffects() {
166
+ state.orderedModifiers.forEach(function (_ref) {
167
+ var name = _ref.name,
168
+ _ref$options = _ref.options,
169
+ options = _ref$options === void 0 ? {} : _ref$options,
170
+ effect = _ref.effect;
171
+
172
+ if (typeof effect === 'function') {
173
+ var cleanupFn = effect({
174
+ state: state,
175
+ name: name,
176
+ instance: instance,
177
+ options: options
178
+ });
179
+
180
+ var noopFn = function noopFn() {};
181
+
182
+ effectCleanupFns.push(cleanupFn || noopFn);
183
+ }
184
+ });
185
+ }
186
+
187
+ function cleanupModifierEffects() {
188
+ effectCleanupFns.forEach(function (fn) {
189
+ return fn();
190
+ });
191
+ effectCleanupFns = [];
192
+ }
193
+
194
+ return instance;
195
+ };
196
+ }
197
+ export var createPopper = /*#__PURE__*/popperGenerator(); // eslint-disable-next-line import/no-unused-modules
198
+
199
+ export { detectOverflow };
@@ -0,0 +1,23 @@
1
+ import { isShadowRoot } from "./instanceOf.js";
2
+ export default function contains(parent, child) {
3
+ var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method
4
+
5
+ if (parent.contains(child)) {
6
+ return true;
7
+ } // then fallback to custom implementation with Shadow DOM support
8
+ else if (rootNode && isShadowRoot(rootNode)) {
9
+ var next = child;
10
+
11
+ do {
12
+ if (next && parent.isSameNode(next)) {
13
+ return true;
14
+ } // $FlowFixMe[prop-missing]: need a better way to handle this...
15
+
16
+
17
+ next = next.parentNode || next.host;
18
+ } while (next);
19
+ } // Give up, the result is false
20
+
21
+
22
+ return false;
23
+ }
@@ -0,0 +1,41 @@
1
+ import { isElement, isHTMLElement } from "./instanceOf.js";
2
+ import { round } from "../utils/math.js";
3
+ import getWindow from "./getWindow.js";
4
+ import isLayoutViewport from "./isLayoutViewport.js";
5
+ export default function getBoundingClientRect(element, includeScale, isFixedStrategy) {
6
+ if (includeScale === void 0) {
7
+ includeScale = false;
8
+ }
9
+
10
+ if (isFixedStrategy === void 0) {
11
+ isFixedStrategy = false;
12
+ }
13
+
14
+ var clientRect = element.getBoundingClientRect();
15
+ var scaleX = 1;
16
+ var scaleY = 1;
17
+
18
+ if (includeScale && isHTMLElement(element)) {
19
+ scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
20
+ scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
21
+ }
22
+
23
+ var _ref = isElement(element) ? getWindow(element) : window,
24
+ visualViewport = _ref.visualViewport;
25
+
26
+ var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
27
+ var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
28
+ var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
29
+ var width = clientRect.width / scaleX;
30
+ var height = clientRect.height / scaleY;
31
+ return {
32
+ width: width,
33
+ height: height,
34
+ top: y,
35
+ right: x + width,
36
+ bottom: y + height,
37
+ left: x,
38
+ x: x,
39
+ y: y
40
+ };
41
+ }
@@ -0,0 +1,70 @@
1
+ import { viewport } from "../enums.js";
2
+ import getViewportRect from "./getViewportRect.js";
3
+ import getDocumentRect from "./getDocumentRect.js";
4
+ import listScrollParents from "./listScrollParents.js";
5
+ import getOffsetParent from "./getOffsetParent.js";
6
+ import getDocumentElement from "./getDocumentElement.js";
7
+ import getComputedStyle from "./getComputedStyle.js";
8
+ import { isElement, isHTMLElement } from "./instanceOf.js";
9
+ import getBoundingClientRect from "./getBoundingClientRect.js";
10
+ import getParentNode from "./getParentNode.js";
11
+ import contains from "./contains.js";
12
+ import getNodeName from "./getNodeName.js";
13
+ import rectToClientRect from "../utils/rectToClientRect.js";
14
+ import { max, min } from "../utils/math.js";
15
+
16
+ function getInnerBoundingClientRect(element, strategy) {
17
+ var rect = getBoundingClientRect(element, false, strategy === 'fixed');
18
+ rect.top = rect.top + element.clientTop;
19
+ rect.left = rect.left + element.clientLeft;
20
+ rect.bottom = rect.top + element.clientHeight;
21
+ rect.right = rect.left + element.clientWidth;
22
+ rect.width = element.clientWidth;
23
+ rect.height = element.clientHeight;
24
+ rect.x = rect.left;
25
+ rect.y = rect.top;
26
+ return rect;
27
+ }
28
+
29
+ function getClientRectFromMixedType(element, clippingParent, strategy) {
30
+ return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
31
+ } // A "clipping parent" is an overflowable container with the characteristic of
32
+ // clipping (or hiding) overflowing elements with a position different from
33
+ // `initial`
34
+
35
+
36
+ function getClippingParents(element) {
37
+ var clippingParents = listScrollParents(getParentNode(element));
38
+ var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle(element).position) >= 0;
39
+ var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
40
+
41
+ if (!isElement(clipperElement)) {
42
+ return [];
43
+ } // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414
44
+
45
+
46
+ return clippingParents.filter(function (clippingParent) {
47
+ return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
48
+ });
49
+ } // Gets the maximum area that the element is visible in due to any number of
50
+ // clipping parents
51
+
52
+
53
+ export default function getClippingRect(element, boundary, rootBoundary, strategy) {
54
+ var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
55
+ var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
56
+ var firstClippingParent = clippingParents[0];
57
+ var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
58
+ var rect = getClientRectFromMixedType(element, clippingParent, strategy);
59
+ accRect.top = max(rect.top, accRect.top);
60
+ accRect.right = min(rect.right, accRect.right);
61
+ accRect.bottom = min(rect.bottom, accRect.bottom);
62
+ accRect.left = max(rect.left, accRect.left);
63
+ return accRect;
64
+ }, getClientRectFromMixedType(element, firstClippingParent, strategy));
65
+ clippingRect.width = clippingRect.right - clippingRect.left;
66
+ clippingRect.height = clippingRect.bottom - clippingRect.top;
67
+ clippingRect.x = clippingRect.left;
68
+ clippingRect.y = clippingRect.top;
69
+ return clippingRect;
70
+ }
@@ -0,0 +1,58 @@
1
+ import getBoundingClientRect from "./getBoundingClientRect.js";
2
+ import getNodeScroll from "./getNodeScroll.js";
3
+ import getNodeName from "./getNodeName.js";
4
+ import { isHTMLElement } from "./instanceOf.js";
5
+ import getWindowScrollBarX from "./getWindowScrollBarX.js";
6
+ import getDocumentElement from "./getDocumentElement.js";
7
+ import isScrollParent from "./isScrollParent.js";
8
+ import { round } from "../utils/math.js";
9
+
10
+ function isElementScaled(element) {
11
+ var rect = element.getBoundingClientRect();
12
+ var scaleX = round(rect.width) / element.offsetWidth || 1;
13
+ var scaleY = round(rect.height) / element.offsetHeight || 1;
14
+ return scaleX !== 1 || scaleY !== 1;
15
+ } // Returns the composite rect of an element relative to its offsetParent.
16
+ // Composite means it takes into account transforms as well as layout.
17
+
18
+
19
+ export default function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
20
+ if (isFixed === void 0) {
21
+ isFixed = false;
22
+ }
23
+
24
+ var isOffsetParentAnElement = isHTMLElement(offsetParent);
25
+ var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
26
+ var documentElement = getDocumentElement(offsetParent);
27
+ var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
28
+ var scroll = {
29
+ scrollLeft: 0,
30
+ scrollTop: 0
31
+ };
32
+ var offsets = {
33
+ x: 0,
34
+ y: 0
35
+ };
36
+
37
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
38
+ if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078
39
+ isScrollParent(documentElement)) {
40
+ scroll = getNodeScroll(offsetParent);
41
+ }
42
+
43
+ if (isHTMLElement(offsetParent)) {
44
+ offsets = getBoundingClientRect(offsetParent, true);
45
+ offsets.x += offsetParent.clientLeft;
46
+ offsets.y += offsetParent.clientTop;
47
+ } else if (documentElement) {
48
+ offsets.x = getWindowScrollBarX(documentElement);
49
+ }
50
+ }
51
+
52
+ return {
53
+ x: rect.left + scroll.scrollLeft - offsets.x,
54
+ y: rect.top + scroll.scrollTop - offsets.y,
55
+ width: rect.width,
56
+ height: rect.height
57
+ };
58
+ }
@@ -0,0 +1,4 @@
1
+ import getWindow from "./getWindow.js";
2
+ export default function getComputedStyle(element) {
3
+ return getWindow(element).getComputedStyle(element);
4
+ }
@@ -0,0 +1,6 @@
1
+ import { isElement } from "./instanceOf.js";
2
+ export default function getDocumentElement(element) {
3
+ // $FlowFixMe[incompatible-return]: assume body is always available
4
+ return ((isElement(element) ? element.ownerDocument : // $FlowFixMe[prop-missing]
5
+ element.document) || window.document).documentElement;
6
+ }
@@ -0,0 +1,29 @@
1
+ import getDocumentElement from "./getDocumentElement.js";
2
+ import getComputedStyle from "./getComputedStyle.js";
3
+ import getWindowScrollBarX from "./getWindowScrollBarX.js";
4
+ import getWindowScroll from "./getWindowScroll.js";
5
+ import { max } from "../utils/math.js"; // Gets the entire size of the scrollable document area, even extending outside
6
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable
7
+
8
+ export default function getDocumentRect(element) {
9
+ var _element$ownerDocumen;
10
+
11
+ var html = getDocumentElement(element);
12
+ var winScroll = getWindowScroll(element);
13
+ var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
14
+ var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
15
+ var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
16
+ var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
17
+ var y = -winScroll.scrollTop;
18
+
19
+ if (getComputedStyle(body || html).direction === 'rtl') {
20
+ x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
21
+ }
22
+
23
+ return {
24
+ width: width,
25
+ height: height,
26
+ x: x,
27
+ y: y
28
+ };
29
+ }
@@ -0,0 +1,6 @@
1
+ export default function getHTMLElementScroll(element) {
2
+ return {
3
+ scrollLeft: element.scrollLeft,
4
+ scrollTop: element.scrollTop
5
+ };
6
+ }
@@ -0,0 +1,25 @@
1
+ import getBoundingClientRect from "./getBoundingClientRect.js"; // Returns the layout rect of an element relative to its offsetParent. Layout
2
+ // means it doesn't take into account transforms.
3
+
4
+ export default function getLayoutRect(element) {
5
+ var clientRect = getBoundingClientRect(element); // Use the clientRect sizes if it's not been transformed.
6
+ // Fixes https://github.com/popperjs/popper-core/issues/1223
7
+
8
+ var width = element.offsetWidth;
9
+ var height = element.offsetHeight;
10
+
11
+ if (Math.abs(clientRect.width - width) <= 1) {
12
+ width = clientRect.width;
13
+ }
14
+
15
+ if (Math.abs(clientRect.height - height) <= 1) {
16
+ height = clientRect.height;
17
+ }
18
+
19
+ return {
20
+ x: element.offsetLeft,
21
+ y: element.offsetTop,
22
+ width: width,
23
+ height: height
24
+ };
25
+ }
@@ -0,0 +1,3 @@
1
+ export default function getNodeName(element) {
2
+ return element ? (element.nodeName || '').toLowerCase() : null;
3
+ }
@@ -0,0 +1,11 @@
1
+ import getWindowScroll from "./getWindowScroll.js";
2
+ import getWindow from "./getWindow.js";
3
+ import { isHTMLElement } from "./instanceOf.js";
4
+ import getHTMLElementScroll from "./getHTMLElementScroll.js";
5
+ export default function getNodeScroll(node) {
6
+ if (node === getWindow(node) || !isHTMLElement(node)) {
7
+ return getWindowScroll(node);
8
+ } else {
9
+ return getHTMLElementScroll(node);
10
+ }
11
+ }
@@ -0,0 +1,69 @@
1
+ import getWindow from "./getWindow.js";
2
+ import getNodeName from "./getNodeName.js";
3
+ import getComputedStyle from "./getComputedStyle.js";
4
+ import { isHTMLElement, isShadowRoot } from "./instanceOf.js";
5
+ import isTableElement from "./isTableElement.js";
6
+ import getParentNode from "./getParentNode.js";
7
+ import getUAString from "../utils/userAgent.js";
8
+
9
+ function getTrueOffsetParent(element) {
10
+ if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
11
+ getComputedStyle(element).position === 'fixed') {
12
+ return null;
13
+ }
14
+
15
+ return element.offsetParent;
16
+ } // `.offsetParent` reports `null` for fixed elements, while absolute elements
17
+ // return the containing block
18
+
19
+
20
+ function getContainingBlock(element) {
21
+ var isFirefox = /firefox/i.test(getUAString());
22
+ var isIE = /Trident/i.test(getUAString());
23
+
24
+ if (isIE && isHTMLElement(element)) {
25
+ // In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
26
+ var elementCss = getComputedStyle(element);
27
+
28
+ if (elementCss.position === 'fixed') {
29
+ return null;
30
+ }
31
+ }
32
+
33
+ var currentNode = getParentNode(element);
34
+
35
+ if (isShadowRoot(currentNode)) {
36
+ currentNode = currentNode.host;
37
+ }
38
+
39
+ while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
40
+ var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that
41
+ // create a containing block.
42
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
43
+
44
+ if (css.transform !== 'none' || css.perspective !== 'none' || css.contain === 'paint' || ['transform', 'perspective'].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === 'filter' || isFirefox && css.filter && css.filter !== 'none') {
45
+ return currentNode;
46
+ } else {
47
+ currentNode = currentNode.parentNode;
48
+ }
49
+ }
50
+
51
+ return null;
52
+ } // Gets the closest ancestor positioned element. Handles some edge cases,
53
+ // such as table ancestors and cross browser bugs.
54
+
55
+
56
+ export default function getOffsetParent(element) {
57
+ var window = getWindow(element);
58
+ var offsetParent = getTrueOffsetParent(element);
59
+
60
+ while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
61
+ offsetParent = getTrueOffsetParent(offsetParent);
62
+ }
63
+
64
+ if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static')) {
65
+ return window;
66
+ }
67
+
68
+ return offsetParent || getContainingBlock(element) || window;
69
+ }
@@ -0,0 +1,19 @@
1
+ import getNodeName from "./getNodeName.js";
2
+ import getDocumentElement from "./getDocumentElement.js";
3
+ import { isShadowRoot } from "./instanceOf.js";
4
+ export default function getParentNode(element) {
5
+ if (getNodeName(element) === 'html') {
6
+ return element;
7
+ }
8
+
9
+ return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
10
+ // $FlowFixMe[incompatible-return]
11
+ // $FlowFixMe[prop-missing]
12
+ element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
13
+ element.parentNode || ( // DOM Element detected
14
+ isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
15
+ // $FlowFixMe[incompatible-call]: HTMLElement is a Node
16
+ getDocumentElement(element) // fallback
17
+
18
+ );
19
+ }
@@ -0,0 +1,16 @@
1
+ import getParentNode from "./getParentNode.js";
2
+ import isScrollParent from "./isScrollParent.js";
3
+ import getNodeName from "./getNodeName.js";
4
+ import { isHTMLElement } from "./instanceOf.js";
5
+ export default function getScrollParent(node) {
6
+ if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
7
+ // $FlowFixMe[incompatible-return]: assume body is always available
8
+ return node.ownerDocument.body;
9
+ }
10
+
11
+ if (isHTMLElement(node) && isScrollParent(node)) {
12
+ return node;
13
+ }
14
+
15
+ return getScrollParent(getParentNode(node));
16
+ }
@@ -0,0 +1,31 @@
1
+ import getWindow from "./getWindow.js";
2
+ import getDocumentElement from "./getDocumentElement.js";
3
+ import getWindowScrollBarX from "./getWindowScrollBarX.js";
4
+ import isLayoutViewport from "./isLayoutViewport.js";
5
+ export default function getViewportRect(element, strategy) {
6
+ var win = getWindow(element);
7
+ var html = getDocumentElement(element);
8
+ var visualViewport = win.visualViewport;
9
+ var width = html.clientWidth;
10
+ var height = html.clientHeight;
11
+ var x = 0;
12
+ var y = 0;
13
+
14
+ if (visualViewport) {
15
+ width = visualViewport.width;
16
+ height = visualViewport.height;
17
+ var layoutViewport = isLayoutViewport();
18
+
19
+ if (layoutViewport || !layoutViewport && strategy === 'fixed') {
20
+ x = visualViewport.offsetLeft;
21
+ y = visualViewport.offsetTop;
22
+ }
23
+ }
24
+
25
+ return {
26
+ width: width,
27
+ height: height,
28
+ x: x + getWindowScrollBarX(element),
29
+ y: y
30
+ };
31
+ }
@@ -0,0 +1,12 @@
1
+ export default function getWindow(node) {
2
+ if (node == null) {
3
+ return window;
4
+ }
5
+
6
+ if (node.toString() !== '[object Window]') {
7
+ var ownerDocument = node.ownerDocument;
8
+ return ownerDocument ? ownerDocument.defaultView || window : window;
9
+ }
10
+
11
+ return node;
12
+ }
@@ -0,0 +1,10 @@
1
+ import getWindow from "./getWindow.js";
2
+ export default function getWindowScroll(node) {
3
+ var win = getWindow(node);
4
+ var scrollLeft = win.pageXOffset;
5
+ var scrollTop = win.pageYOffset;
6
+ return {
7
+ scrollLeft: scrollLeft,
8
+ scrollTop: scrollTop
9
+ };
10
+ }
@@ -0,0 +1,13 @@
1
+ import getBoundingClientRect from "./getBoundingClientRect.js";
2
+ import getDocumentElement from "./getDocumentElement.js";
3
+ import getWindowScroll from "./getWindowScroll.js";
4
+ export default function getWindowScrollBarX(element) {
5
+ // If <html> has a CSS width greater than the viewport, then this will be
6
+ // incorrect for RTL.
7
+ // Popper 1 is broken in this case and never had a bug report so let's assume
8
+ // it's not an issue. I don't think anyone ever specifies width on <html>
9
+ // anyway.
10
+ // Browsers where the left scrollbar doesn't cause an issue report `0` for
11
+ // this (e.g. Edge 2019, IE11, Safari)
12
+ return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
13
+ }