@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,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,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,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
|
+
}
|