@dynamic-framework/ui-react 1.30.0 → 1.31.0
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.
- package/dist/css/dynamic-ui-non-root.css +86 -56
- package/dist/css/dynamic-ui-non-root.min.css +2 -2
- package/dist/css/dynamic-ui-root.css +7 -6
- package/dist/css/dynamic-ui-root.min.css +2 -2
- package/dist/css/dynamic-ui.css +92 -61
- package/dist/css/dynamic-ui.min.css +2 -2
- package/dist/index.esm.js +20 -9
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +20 -8
- package/dist/index.js.map +1 -1
- package/dist/js/cjs/enums.js +65 -0
- package/dist/js/cjs/popper-base.js +939 -0
- package/dist/js/cjs/popper-lite.js +1260 -0
- package/dist/js/cjs/popper.js +1819 -0
- package/dist/js/esm/createPopper.js +199 -0
- package/dist/js/esm/dom-utils/contains.js +23 -0
- package/dist/js/esm/dom-utils/getBoundingClientRect.js +41 -0
- package/dist/js/esm/dom-utils/getClippingRect.js +70 -0
- package/dist/js/esm/dom-utils/getCompositeRect.js +58 -0
- package/dist/js/esm/dom-utils/getComputedStyle.js +4 -0
- package/dist/js/esm/dom-utils/getDocumentElement.js +6 -0
- package/dist/js/esm/dom-utils/getDocumentRect.js +29 -0
- package/dist/js/esm/dom-utils/getHTMLElementScroll.js +6 -0
- package/dist/js/esm/dom-utils/getLayoutRect.js +25 -0
- package/dist/js/esm/dom-utils/getNodeName.js +3 -0
- package/dist/js/esm/dom-utils/getNodeScroll.js +11 -0
- package/dist/js/esm/dom-utils/getOffsetParent.js +69 -0
- package/dist/js/esm/dom-utils/getParentNode.js +19 -0
- package/dist/js/esm/dom-utils/getScrollParent.js +16 -0
- package/dist/js/esm/dom-utils/getViewportRect.js +31 -0
- package/dist/js/esm/dom-utils/getWindow.js +12 -0
- package/dist/js/esm/dom-utils/getWindowScroll.js +10 -0
- package/dist/js/esm/dom-utils/getWindowScrollBarX.js +13 -0
- package/dist/js/esm/dom-utils/instanceOf.js +23 -0
- package/dist/js/esm/dom-utils/isLayoutViewport.js +4 -0
- package/dist/js/esm/dom-utils/isScrollParent.js +10 -0
- package/dist/js/esm/dom-utils/isTableElement.js +4 -0
- package/dist/js/esm/dom-utils/listScrollParents.js +26 -0
- package/dist/js/esm/enums.js +31 -0
- package/dist/js/esm/index.js +8 -0
- package/dist/js/esm/modifiers/applyStyles.js +84 -0
- package/dist/js/esm/modifiers/arrow.js +90 -0
- package/dist/js/esm/modifiers/computeStyles.js +169 -0
- package/dist/js/esm/modifiers/eventListeners.js +49 -0
- package/dist/js/esm/modifiers/flip.js +147 -0
- package/dist/js/esm/modifiers/hide.js +61 -0
- package/dist/js/esm/modifiers/index.js +9 -0
- package/dist/js/esm/modifiers/offset.js +54 -0
- package/dist/js/esm/modifiers/popperOffsets.js +25 -0
- package/dist/js/esm/modifiers/preventOverflow.js +142 -0
- package/dist/js/esm/popper-base.js +3 -0
- package/dist/js/esm/popper-lite.js +11 -0
- package/dist/js/esm/popper.js +20 -0
- package/dist/js/esm/types.js +0 -0
- package/dist/js/esm/utils/computeAutoPlacement.js +43 -0
- package/dist/js/esm/utils/computeOffsets.js +70 -0
- package/dist/js/esm/utils/debounce.js +15 -0
- package/dist/js/esm/utils/detectOverflow.js +65 -0
- package/dist/js/esm/utils/expandToHashMap.js +6 -0
- package/dist/js/esm/utils/getAltAxis.js +3 -0
- package/dist/js/esm/utils/getAltLen.js +3 -0
- package/dist/js/esm/utils/getBasePlacement.js +4 -0
- package/dist/js/esm/utils/getFreshSideObject.js +8 -0
- package/dist/js/esm/utils/getMainAxisFromPlacement.js +3 -0
- package/dist/js/esm/utils/getOppositePlacement.js +11 -0
- package/dist/js/esm/utils/getOppositeVariationPlacement.js +9 -0
- package/dist/js/esm/utils/getVariation.js +3 -0
- package/dist/js/esm/utils/math.js +3 -0
- package/dist/js/esm/utils/mergeByName.js +14 -0
- package/dist/js/esm/utils/mergePaddingObject.js +4 -0
- package/dist/js/esm/utils/orderModifiers.js +44 -0
- package/dist/js/esm/utils/rectToClientRect.js +8 -0
- package/dist/js/esm/utils/uniqueBy.js +11 -0
- package/dist/js/esm/utils/userAgent.js +11 -0
- package/dist/js/esm/utils/within.js +8 -0
- package/dist/js/umd/enums.js +71 -0
- package/dist/js/umd/enums.min.js +6 -0
- package/dist/js/umd/popper-base.js +945 -0
- package/dist/js/umd/popper-base.min.js +6 -0
- package/dist/js/umd/popper-lite.js +1266 -0
- package/dist/js/umd/popper-lite.min.js +6 -0
- package/dist/js/umd/popper.js +1825 -0
- package/dist/js/umd/popper.min.js +6 -0
- package/dist/types/components/DSkeleton/DSkeleton.d.ts +3 -0
- package/dist/types/components/DStepperDesktop/DStepperDesktop.d.ts +3 -1
- package/dist/types/components/index.d.ts +1 -0
- package/package.json +12 -5
- package/src/style/abstracts/variables/_+import.scss +1 -1
- package/src/style/abstracts/variables/_breadcrumb.scss +5 -0
- package/src/style/abstracts/variables/_forms.scss +3 -3
- package/src/style/abstracts/variables/_modals.scss +6 -6
- package/src/style/abstracts/variables/_offcanvas.scss +7 -4
- package/src/style/abstracts/variables/_pagination.scss +6 -4
- package/src/style/abstracts/variables/_progress.scss +3 -3
- package/src/style/abstracts/variables/_tooltip.scss +4 -4
- package/src/style/base/_alert.scss +0 -2
- package/src/style/base/_form-check.scss +6 -2
- package/src/style/base/_label.scss +1 -0
- package/src/style/base/_pagination.scss +11 -1
- package/src/style/components/_d-offcanvas.scss +10 -1
- package/src/style/components/_d-stepper-desktop.scss +27 -7
- package/src/style/components/_d-stepper-mobile.scss +6 -6
- package/src/style/root/_root.scss +2 -1
- package/src/style/abstracts/variables/_box-shadow.scss +0 -6
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import getWindow from "./getWindow.js";
|
|
2
|
+
|
|
3
|
+
function isElement(node) {
|
|
4
|
+
var OwnElement = getWindow(node).Element;
|
|
5
|
+
return node instanceof OwnElement || node instanceof Element;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function isHTMLElement(node) {
|
|
9
|
+
var OwnElement = getWindow(node).HTMLElement;
|
|
10
|
+
return node instanceof OwnElement || node instanceof HTMLElement;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function isShadowRoot(node) {
|
|
14
|
+
// IE 11 has no ShadowRoot
|
|
15
|
+
if (typeof ShadowRoot === 'undefined') {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
var OwnElement = getWindow(node).ShadowRoot;
|
|
20
|
+
return node instanceof OwnElement || node instanceof ShadowRoot;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { isElement, isHTMLElement, isShadowRoot };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import getComputedStyle from "./getComputedStyle.js";
|
|
2
|
+
export default function isScrollParent(element) {
|
|
3
|
+
// Firefox wants us to check `-x` and `-y` variations as well
|
|
4
|
+
var _getComputedStyle = getComputedStyle(element),
|
|
5
|
+
overflow = _getComputedStyle.overflow,
|
|
6
|
+
overflowX = _getComputedStyle.overflowX,
|
|
7
|
+
overflowY = _getComputedStyle.overflowY;
|
|
8
|
+
|
|
9
|
+
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
|
|
10
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import getScrollParent from "./getScrollParent.js";
|
|
2
|
+
import getParentNode from "./getParentNode.js";
|
|
3
|
+
import getWindow from "./getWindow.js";
|
|
4
|
+
import isScrollParent from "./isScrollParent.js";
|
|
5
|
+
/*
|
|
6
|
+
given a DOM element, return the list of all scroll parents, up the list of ancesors
|
|
7
|
+
until we get to the top window object. This list is what we attach scroll listeners
|
|
8
|
+
to, because if any of these parent elements scroll, we'll need to re-calculate the
|
|
9
|
+
reference element's position.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export default function listScrollParents(element, list) {
|
|
13
|
+
var _element$ownerDocumen;
|
|
14
|
+
|
|
15
|
+
if (list === void 0) {
|
|
16
|
+
list = [];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
var scrollParent = getScrollParent(element);
|
|
20
|
+
var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
|
|
21
|
+
var win = getWindow(scrollParent);
|
|
22
|
+
var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
|
|
23
|
+
var updatedList = list.concat(target);
|
|
24
|
+
return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
|
|
25
|
+
updatedList.concat(listScrollParents(getParentNode(target)));
|
|
26
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export var top = 'top';
|
|
2
|
+
export var bottom = 'bottom';
|
|
3
|
+
export var right = 'right';
|
|
4
|
+
export var left = 'left';
|
|
5
|
+
export var auto = 'auto';
|
|
6
|
+
export var basePlacements = [top, bottom, right, left];
|
|
7
|
+
export var start = 'start';
|
|
8
|
+
export var end = 'end';
|
|
9
|
+
export var clippingParents = 'clippingParents';
|
|
10
|
+
export var viewport = 'viewport';
|
|
11
|
+
export var popper = 'popper';
|
|
12
|
+
export var reference = 'reference';
|
|
13
|
+
export var variationPlacements = /*#__PURE__*/basePlacements.reduce(function (acc, placement) {
|
|
14
|
+
return acc.concat([placement + "-" + start, placement + "-" + end]);
|
|
15
|
+
}, []);
|
|
16
|
+
export var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {
|
|
17
|
+
return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
|
|
18
|
+
}, []); // modifiers that need to read the DOM
|
|
19
|
+
|
|
20
|
+
export var beforeRead = 'beforeRead';
|
|
21
|
+
export var read = 'read';
|
|
22
|
+
export var afterRead = 'afterRead'; // pure-logic modifiers
|
|
23
|
+
|
|
24
|
+
export var beforeMain = 'beforeMain';
|
|
25
|
+
export var main = 'main';
|
|
26
|
+
export var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state)
|
|
27
|
+
|
|
28
|
+
export var beforeWrite = 'beforeWrite';
|
|
29
|
+
export var write = 'write';
|
|
30
|
+
export var afterWrite = 'afterWrite';
|
|
31
|
+
export var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./enums.js";
|
|
2
|
+
export * from "./modifiers/index.js"; // eslint-disable-next-line import/no-unused-modules
|
|
3
|
+
|
|
4
|
+
export { popperGenerator, detectOverflow, createPopper as createPopperBase } from "./createPopper.js"; // eslint-disable-next-line import/no-unused-modules
|
|
5
|
+
|
|
6
|
+
export { createPopper } from "./popper.js"; // eslint-disable-next-line import/no-unused-modules
|
|
7
|
+
|
|
8
|
+
export { createPopper as createPopperLite } from "./popper-lite.js";
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import getNodeName from "../dom-utils/getNodeName.js";
|
|
2
|
+
import { isHTMLElement } from "../dom-utils/instanceOf.js"; // This modifier takes the styles prepared by the `computeStyles` modifier
|
|
3
|
+
// and applies them to the HTMLElements such as popper and arrow
|
|
4
|
+
|
|
5
|
+
function applyStyles(_ref) {
|
|
6
|
+
var state = _ref.state;
|
|
7
|
+
Object.keys(state.elements).forEach(function (name) {
|
|
8
|
+
var style = state.styles[name] || {};
|
|
9
|
+
var attributes = state.attributes[name] || {};
|
|
10
|
+
var element = state.elements[name]; // arrow is optional + virtual elements
|
|
11
|
+
|
|
12
|
+
if (!isHTMLElement(element) || !getNodeName(element)) {
|
|
13
|
+
return;
|
|
14
|
+
} // Flow doesn't support to extend this property, but it's the most
|
|
15
|
+
// effective way to apply styles to an HTMLElement
|
|
16
|
+
// $FlowFixMe[cannot-write]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
Object.assign(element.style, style);
|
|
20
|
+
Object.keys(attributes).forEach(function (name) {
|
|
21
|
+
var value = attributes[name];
|
|
22
|
+
|
|
23
|
+
if (value === false) {
|
|
24
|
+
element.removeAttribute(name);
|
|
25
|
+
} else {
|
|
26
|
+
element.setAttribute(name, value === true ? '' : value);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function effect(_ref2) {
|
|
33
|
+
var state = _ref2.state;
|
|
34
|
+
var initialStyles = {
|
|
35
|
+
popper: {
|
|
36
|
+
position: state.options.strategy,
|
|
37
|
+
left: '0',
|
|
38
|
+
top: '0',
|
|
39
|
+
margin: '0'
|
|
40
|
+
},
|
|
41
|
+
arrow: {
|
|
42
|
+
position: 'absolute'
|
|
43
|
+
},
|
|
44
|
+
reference: {}
|
|
45
|
+
};
|
|
46
|
+
Object.assign(state.elements.popper.style, initialStyles.popper);
|
|
47
|
+
state.styles = initialStyles;
|
|
48
|
+
|
|
49
|
+
if (state.elements.arrow) {
|
|
50
|
+
Object.assign(state.elements.arrow.style, initialStyles.arrow);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return function () {
|
|
54
|
+
Object.keys(state.elements).forEach(function (name) {
|
|
55
|
+
var element = state.elements[name];
|
|
56
|
+
var attributes = state.attributes[name] || {};
|
|
57
|
+
var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them
|
|
58
|
+
|
|
59
|
+
var style = styleProperties.reduce(function (style, property) {
|
|
60
|
+
style[property] = '';
|
|
61
|
+
return style;
|
|
62
|
+
}, {}); // arrow is optional + virtual elements
|
|
63
|
+
|
|
64
|
+
if (!isHTMLElement(element) || !getNodeName(element)) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
Object.assign(element.style, style);
|
|
69
|
+
Object.keys(attributes).forEach(function (attribute) {
|
|
70
|
+
element.removeAttribute(attribute);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
} // eslint-disable-next-line import/no-unused-modules
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
export default {
|
|
78
|
+
name: 'applyStyles',
|
|
79
|
+
enabled: true,
|
|
80
|
+
phase: 'write',
|
|
81
|
+
fn: applyStyles,
|
|
82
|
+
effect: effect,
|
|
83
|
+
requires: ['computeStyles']
|
|
84
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import getBasePlacement from "../utils/getBasePlacement.js";
|
|
2
|
+
import getLayoutRect from "../dom-utils/getLayoutRect.js";
|
|
3
|
+
import contains from "../dom-utils/contains.js";
|
|
4
|
+
import getOffsetParent from "../dom-utils/getOffsetParent.js";
|
|
5
|
+
import getMainAxisFromPlacement from "../utils/getMainAxisFromPlacement.js";
|
|
6
|
+
import { within } from "../utils/within.js";
|
|
7
|
+
import mergePaddingObject from "../utils/mergePaddingObject.js";
|
|
8
|
+
import expandToHashMap from "../utils/expandToHashMap.js";
|
|
9
|
+
import { left, right, basePlacements, top, bottom } from "../enums.js"; // eslint-disable-next-line import/no-unused-modules
|
|
10
|
+
|
|
11
|
+
var toPaddingObject = function toPaddingObject(padding, state) {
|
|
12
|
+
padding = typeof padding === 'function' ? padding(Object.assign({}, state.rects, {
|
|
13
|
+
placement: state.placement
|
|
14
|
+
})) : padding;
|
|
15
|
+
return mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
function arrow(_ref) {
|
|
19
|
+
var _state$modifiersData$;
|
|
20
|
+
|
|
21
|
+
var state = _ref.state,
|
|
22
|
+
name = _ref.name,
|
|
23
|
+
options = _ref.options;
|
|
24
|
+
var arrowElement = state.elements.arrow;
|
|
25
|
+
var popperOffsets = state.modifiersData.popperOffsets;
|
|
26
|
+
var basePlacement = getBasePlacement(state.placement);
|
|
27
|
+
var axis = getMainAxisFromPlacement(basePlacement);
|
|
28
|
+
var isVertical = [left, right].indexOf(basePlacement) >= 0;
|
|
29
|
+
var len = isVertical ? 'height' : 'width';
|
|
30
|
+
|
|
31
|
+
if (!arrowElement || !popperOffsets) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
var paddingObject = toPaddingObject(options.padding, state);
|
|
36
|
+
var arrowRect = getLayoutRect(arrowElement);
|
|
37
|
+
var minProp = axis === 'y' ? top : left;
|
|
38
|
+
var maxProp = axis === 'y' ? bottom : right;
|
|
39
|
+
var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
|
|
40
|
+
var startDiff = popperOffsets[axis] - state.rects.reference[axis];
|
|
41
|
+
var arrowOffsetParent = getOffsetParent(arrowElement);
|
|
42
|
+
var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
|
|
43
|
+
var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is
|
|
44
|
+
// outside of the popper bounds
|
|
45
|
+
|
|
46
|
+
var min = paddingObject[minProp];
|
|
47
|
+
var max = clientSize - arrowRect[len] - paddingObject[maxProp];
|
|
48
|
+
var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
|
|
49
|
+
var offset = within(min, center, max); // Prevents breaking syntax highlighting...
|
|
50
|
+
|
|
51
|
+
var axisProp = axis;
|
|
52
|
+
state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function effect(_ref2) {
|
|
56
|
+
var state = _ref2.state,
|
|
57
|
+
options = _ref2.options;
|
|
58
|
+
var _options$element = options.element,
|
|
59
|
+
arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element;
|
|
60
|
+
|
|
61
|
+
if (arrowElement == null) {
|
|
62
|
+
return;
|
|
63
|
+
} // CSS selector
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
if (typeof arrowElement === 'string') {
|
|
67
|
+
arrowElement = state.elements.popper.querySelector(arrowElement);
|
|
68
|
+
|
|
69
|
+
if (!arrowElement) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (!contains(state.elements.popper, arrowElement)) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
state.elements.arrow = arrowElement;
|
|
79
|
+
} // eslint-disable-next-line import/no-unused-modules
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
export default {
|
|
83
|
+
name: 'arrow',
|
|
84
|
+
enabled: true,
|
|
85
|
+
phase: 'main',
|
|
86
|
+
fn: arrow,
|
|
87
|
+
effect: effect,
|
|
88
|
+
requires: ['popperOffsets'],
|
|
89
|
+
requiresIfExists: ['preventOverflow']
|
|
90
|
+
};
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { top, left, right, bottom, end } from "../enums.js";
|
|
2
|
+
import getOffsetParent from "../dom-utils/getOffsetParent.js";
|
|
3
|
+
import getWindow from "../dom-utils/getWindow.js";
|
|
4
|
+
import getDocumentElement from "../dom-utils/getDocumentElement.js";
|
|
5
|
+
import getComputedStyle from "../dom-utils/getComputedStyle.js";
|
|
6
|
+
import getBasePlacement from "../utils/getBasePlacement.js";
|
|
7
|
+
import getVariation from "../utils/getVariation.js";
|
|
8
|
+
import { round } from "../utils/math.js"; // eslint-disable-next-line import/no-unused-modules
|
|
9
|
+
|
|
10
|
+
var unsetSides = {
|
|
11
|
+
top: 'auto',
|
|
12
|
+
right: 'auto',
|
|
13
|
+
bottom: 'auto',
|
|
14
|
+
left: 'auto'
|
|
15
|
+
}; // Round the offsets to the nearest suitable subpixel based on the DPR.
|
|
16
|
+
// Zooming can change the DPR, but it seems to report a value that will
|
|
17
|
+
// cleanly divide the values into the appropriate subpixels.
|
|
18
|
+
|
|
19
|
+
function roundOffsetsByDPR(_ref, win) {
|
|
20
|
+
var x = _ref.x,
|
|
21
|
+
y = _ref.y;
|
|
22
|
+
var dpr = win.devicePixelRatio || 1;
|
|
23
|
+
return {
|
|
24
|
+
x: round(x * dpr) / dpr || 0,
|
|
25
|
+
y: round(y * dpr) / dpr || 0
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function mapToStyles(_ref2) {
|
|
30
|
+
var _Object$assign2;
|
|
31
|
+
|
|
32
|
+
var popper = _ref2.popper,
|
|
33
|
+
popperRect = _ref2.popperRect,
|
|
34
|
+
placement = _ref2.placement,
|
|
35
|
+
variation = _ref2.variation,
|
|
36
|
+
offsets = _ref2.offsets,
|
|
37
|
+
position = _ref2.position,
|
|
38
|
+
gpuAcceleration = _ref2.gpuAcceleration,
|
|
39
|
+
adaptive = _ref2.adaptive,
|
|
40
|
+
roundOffsets = _ref2.roundOffsets,
|
|
41
|
+
isFixed = _ref2.isFixed;
|
|
42
|
+
var _offsets$x = offsets.x,
|
|
43
|
+
x = _offsets$x === void 0 ? 0 : _offsets$x,
|
|
44
|
+
_offsets$y = offsets.y,
|
|
45
|
+
y = _offsets$y === void 0 ? 0 : _offsets$y;
|
|
46
|
+
|
|
47
|
+
var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({
|
|
48
|
+
x: x,
|
|
49
|
+
y: y
|
|
50
|
+
}) : {
|
|
51
|
+
x: x,
|
|
52
|
+
y: y
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
x = _ref3.x;
|
|
56
|
+
y = _ref3.y;
|
|
57
|
+
var hasX = offsets.hasOwnProperty('x');
|
|
58
|
+
var hasY = offsets.hasOwnProperty('y');
|
|
59
|
+
var sideX = left;
|
|
60
|
+
var sideY = top;
|
|
61
|
+
var win = window;
|
|
62
|
+
|
|
63
|
+
if (adaptive) {
|
|
64
|
+
var offsetParent = getOffsetParent(popper);
|
|
65
|
+
var heightProp = 'clientHeight';
|
|
66
|
+
var widthProp = 'clientWidth';
|
|
67
|
+
|
|
68
|
+
if (offsetParent === getWindow(popper)) {
|
|
69
|
+
offsetParent = getDocumentElement(popper);
|
|
70
|
+
|
|
71
|
+
if (getComputedStyle(offsetParent).position !== 'static' && position === 'absolute') {
|
|
72
|
+
heightProp = 'scrollHeight';
|
|
73
|
+
widthProp = 'scrollWidth';
|
|
74
|
+
}
|
|
75
|
+
} // $FlowFixMe[incompatible-cast]: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
offsetParent = offsetParent;
|
|
79
|
+
|
|
80
|
+
if (placement === top || (placement === left || placement === right) && variation === end) {
|
|
81
|
+
sideY = bottom;
|
|
82
|
+
var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : // $FlowFixMe[prop-missing]
|
|
83
|
+
offsetParent[heightProp];
|
|
84
|
+
y -= offsetY - popperRect.height;
|
|
85
|
+
y *= gpuAcceleration ? 1 : -1;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (placement === left || (placement === top || placement === bottom) && variation === end) {
|
|
89
|
+
sideX = right;
|
|
90
|
+
var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : // $FlowFixMe[prop-missing]
|
|
91
|
+
offsetParent[widthProp];
|
|
92
|
+
x -= offsetX - popperRect.width;
|
|
93
|
+
x *= gpuAcceleration ? 1 : -1;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
var commonStyles = Object.assign({
|
|
98
|
+
position: position
|
|
99
|
+
}, adaptive && unsetSides);
|
|
100
|
+
|
|
101
|
+
var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
|
|
102
|
+
x: x,
|
|
103
|
+
y: y
|
|
104
|
+
}, getWindow(popper)) : {
|
|
105
|
+
x: x,
|
|
106
|
+
y: y
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
x = _ref4.x;
|
|
110
|
+
y = _ref4.y;
|
|
111
|
+
|
|
112
|
+
if (gpuAcceleration) {
|
|
113
|
+
var _Object$assign;
|
|
114
|
+
|
|
115
|
+
return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function computeStyles(_ref5) {
|
|
122
|
+
var state = _ref5.state,
|
|
123
|
+
options = _ref5.options;
|
|
124
|
+
var _options$gpuAccelerat = options.gpuAcceleration,
|
|
125
|
+
gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
|
|
126
|
+
_options$adaptive = options.adaptive,
|
|
127
|
+
adaptive = _options$adaptive === void 0 ? true : _options$adaptive,
|
|
128
|
+
_options$roundOffsets = options.roundOffsets,
|
|
129
|
+
roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
|
|
130
|
+
var commonStyles = {
|
|
131
|
+
placement: getBasePlacement(state.placement),
|
|
132
|
+
variation: getVariation(state.placement),
|
|
133
|
+
popper: state.elements.popper,
|
|
134
|
+
popperRect: state.rects.popper,
|
|
135
|
+
gpuAcceleration: gpuAcceleration,
|
|
136
|
+
isFixed: state.options.strategy === 'fixed'
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
if (state.modifiersData.popperOffsets != null) {
|
|
140
|
+
state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
|
|
141
|
+
offsets: state.modifiersData.popperOffsets,
|
|
142
|
+
position: state.options.strategy,
|
|
143
|
+
adaptive: adaptive,
|
|
144
|
+
roundOffsets: roundOffsets
|
|
145
|
+
})));
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (state.modifiersData.arrow != null) {
|
|
149
|
+
state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
|
|
150
|
+
offsets: state.modifiersData.arrow,
|
|
151
|
+
position: 'absolute',
|
|
152
|
+
adaptive: false,
|
|
153
|
+
roundOffsets: roundOffsets
|
|
154
|
+
})));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
state.attributes.popper = Object.assign({}, state.attributes.popper, {
|
|
158
|
+
'data-popper-placement': state.placement
|
|
159
|
+
});
|
|
160
|
+
} // eslint-disable-next-line import/no-unused-modules
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
export default {
|
|
164
|
+
name: 'computeStyles',
|
|
165
|
+
enabled: true,
|
|
166
|
+
phase: 'beforeWrite',
|
|
167
|
+
fn: computeStyles,
|
|
168
|
+
data: {}
|
|
169
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import getWindow from "../dom-utils/getWindow.js"; // eslint-disable-next-line import/no-unused-modules
|
|
2
|
+
|
|
3
|
+
var passive = {
|
|
4
|
+
passive: true
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
function effect(_ref) {
|
|
8
|
+
var state = _ref.state,
|
|
9
|
+
instance = _ref.instance,
|
|
10
|
+
options = _ref.options;
|
|
11
|
+
var _options$scroll = options.scroll,
|
|
12
|
+
scroll = _options$scroll === void 0 ? true : _options$scroll,
|
|
13
|
+
_options$resize = options.resize,
|
|
14
|
+
resize = _options$resize === void 0 ? true : _options$resize;
|
|
15
|
+
var window = getWindow(state.elements.popper);
|
|
16
|
+
var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
|
|
17
|
+
|
|
18
|
+
if (scroll) {
|
|
19
|
+
scrollParents.forEach(function (scrollParent) {
|
|
20
|
+
scrollParent.addEventListener('scroll', instance.update, passive);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (resize) {
|
|
25
|
+
window.addEventListener('resize', instance.update, passive);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return function () {
|
|
29
|
+
if (scroll) {
|
|
30
|
+
scrollParents.forEach(function (scrollParent) {
|
|
31
|
+
scrollParent.removeEventListener('scroll', instance.update, passive);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (resize) {
|
|
36
|
+
window.removeEventListener('resize', instance.update, passive);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
} // eslint-disable-next-line import/no-unused-modules
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
export default {
|
|
43
|
+
name: 'eventListeners',
|
|
44
|
+
enabled: true,
|
|
45
|
+
phase: 'write',
|
|
46
|
+
fn: function fn() {},
|
|
47
|
+
effect: effect,
|
|
48
|
+
data: {}
|
|
49
|
+
};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import getOppositePlacement from "../utils/getOppositePlacement.js";
|
|
2
|
+
import getBasePlacement from "../utils/getBasePlacement.js";
|
|
3
|
+
import getOppositeVariationPlacement from "../utils/getOppositeVariationPlacement.js";
|
|
4
|
+
import detectOverflow from "../utils/detectOverflow.js";
|
|
5
|
+
import computeAutoPlacement from "../utils/computeAutoPlacement.js";
|
|
6
|
+
import { bottom, top, start, right, left, auto } from "../enums.js";
|
|
7
|
+
import getVariation from "../utils/getVariation.js"; // eslint-disable-next-line import/no-unused-modules
|
|
8
|
+
|
|
9
|
+
function getExpandedFallbackPlacements(placement) {
|
|
10
|
+
if (getBasePlacement(placement) === auto) {
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
var oppositePlacement = getOppositePlacement(placement);
|
|
15
|
+
return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function flip(_ref) {
|
|
19
|
+
var state = _ref.state,
|
|
20
|
+
options = _ref.options,
|
|
21
|
+
name = _ref.name;
|
|
22
|
+
|
|
23
|
+
if (state.modifiersData[name]._skip) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var _options$mainAxis = options.mainAxis,
|
|
28
|
+
checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
|
|
29
|
+
_options$altAxis = options.altAxis,
|
|
30
|
+
checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis,
|
|
31
|
+
specifiedFallbackPlacements = options.fallbackPlacements,
|
|
32
|
+
padding = options.padding,
|
|
33
|
+
boundary = options.boundary,
|
|
34
|
+
rootBoundary = options.rootBoundary,
|
|
35
|
+
altBoundary = options.altBoundary,
|
|
36
|
+
_options$flipVariatio = options.flipVariations,
|
|
37
|
+
flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio,
|
|
38
|
+
allowedAutoPlacements = options.allowedAutoPlacements;
|
|
39
|
+
var preferredPlacement = state.options.placement;
|
|
40
|
+
var basePlacement = getBasePlacement(preferredPlacement);
|
|
41
|
+
var isBasePlacement = basePlacement === preferredPlacement;
|
|
42
|
+
var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
|
|
43
|
+
var placements = [preferredPlacement].concat(fallbackPlacements).reduce(function (acc, placement) {
|
|
44
|
+
return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, {
|
|
45
|
+
placement: placement,
|
|
46
|
+
boundary: boundary,
|
|
47
|
+
rootBoundary: rootBoundary,
|
|
48
|
+
padding: padding,
|
|
49
|
+
flipVariations: flipVariations,
|
|
50
|
+
allowedAutoPlacements: allowedAutoPlacements
|
|
51
|
+
}) : placement);
|
|
52
|
+
}, []);
|
|
53
|
+
var referenceRect = state.rects.reference;
|
|
54
|
+
var popperRect = state.rects.popper;
|
|
55
|
+
var checksMap = new Map();
|
|
56
|
+
var makeFallbackChecks = true;
|
|
57
|
+
var firstFittingPlacement = placements[0];
|
|
58
|
+
|
|
59
|
+
for (var i = 0; i < placements.length; i++) {
|
|
60
|
+
var placement = placements[i];
|
|
61
|
+
|
|
62
|
+
var _basePlacement = getBasePlacement(placement);
|
|
63
|
+
|
|
64
|
+
var isStartVariation = getVariation(placement) === start;
|
|
65
|
+
var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
|
|
66
|
+
var len = isVertical ? 'width' : 'height';
|
|
67
|
+
var overflow = detectOverflow(state, {
|
|
68
|
+
placement: placement,
|
|
69
|
+
boundary: boundary,
|
|
70
|
+
rootBoundary: rootBoundary,
|
|
71
|
+
altBoundary: altBoundary,
|
|
72
|
+
padding: padding
|
|
73
|
+
});
|
|
74
|
+
var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
|
|
75
|
+
|
|
76
|
+
if (referenceRect[len] > popperRect[len]) {
|
|
77
|
+
mainVariationSide = getOppositePlacement(mainVariationSide);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
var altVariationSide = getOppositePlacement(mainVariationSide);
|
|
81
|
+
var checks = [];
|
|
82
|
+
|
|
83
|
+
if (checkMainAxis) {
|
|
84
|
+
checks.push(overflow[_basePlacement] <= 0);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (checkAltAxis) {
|
|
88
|
+
checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (checks.every(function (check) {
|
|
92
|
+
return check;
|
|
93
|
+
})) {
|
|
94
|
+
firstFittingPlacement = placement;
|
|
95
|
+
makeFallbackChecks = false;
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
checksMap.set(placement, checks);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (makeFallbackChecks) {
|
|
103
|
+
// `2` may be desired in some cases – research later
|
|
104
|
+
var numberOfChecks = flipVariations ? 3 : 1;
|
|
105
|
+
|
|
106
|
+
var _loop = function _loop(_i) {
|
|
107
|
+
var fittingPlacement = placements.find(function (placement) {
|
|
108
|
+
var checks = checksMap.get(placement);
|
|
109
|
+
|
|
110
|
+
if (checks) {
|
|
111
|
+
return checks.slice(0, _i).every(function (check) {
|
|
112
|
+
return check;
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
if (fittingPlacement) {
|
|
118
|
+
firstFittingPlacement = fittingPlacement;
|
|
119
|
+
return "break";
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
for (var _i = numberOfChecks; _i > 0; _i--) {
|
|
124
|
+
var _ret = _loop(_i);
|
|
125
|
+
|
|
126
|
+
if (_ret === "break") break;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (state.placement !== firstFittingPlacement) {
|
|
131
|
+
state.modifiersData[name]._skip = true;
|
|
132
|
+
state.placement = firstFittingPlacement;
|
|
133
|
+
state.reset = true;
|
|
134
|
+
}
|
|
135
|
+
} // eslint-disable-next-line import/no-unused-modules
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
export default {
|
|
139
|
+
name: 'flip',
|
|
140
|
+
enabled: true,
|
|
141
|
+
phase: 'main',
|
|
142
|
+
fn: flip,
|
|
143
|
+
requiresIfExists: ['offset'],
|
|
144
|
+
data: {
|
|
145
|
+
_skip: false
|
|
146
|
+
}
|
|
147
|
+
};
|