Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo-mod-jslibs-dist.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'popperjs/package/lib/utils/computeAutoPlacement.js')
-rw-r--r--popperjs/package/lib/utils/computeAutoPlacement.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/popperjs/package/lib/utils/computeAutoPlacement.js b/popperjs/package/lib/utils/computeAutoPlacement.js
new file mode 100644
index 0000000..12e27c8
--- /dev/null
+++ b/popperjs/package/lib/utils/computeAutoPlacement.js
@@ -0,0 +1,47 @@
+import getVariation from "./getVariation.js";
+import { variationPlacements, basePlacements, placements as allPlacements } from "../enums.js";
+import detectOverflow from "./detectOverflow.js";
+import getBasePlacement from "./getBasePlacement.js";
+export default function computeAutoPlacement(state, options) {
+ if (options === void 0) {
+ options = {};
+ }
+
+ var _options = options,
+ placement = _options.placement,
+ boundary = _options.boundary,
+ rootBoundary = _options.rootBoundary,
+ padding = _options.padding,
+ flipVariations = _options.flipVariations,
+ _options$allowedAutoP = _options.allowedAutoPlacements,
+ allowedAutoPlacements = _options$allowedAutoP === void 0 ? allPlacements : _options$allowedAutoP;
+ var variation = getVariation(placement);
+ var placements = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {
+ return getVariation(placement) === variation;
+ }) : basePlacements;
+ var allowedPlacements = placements.filter(function (placement) {
+ return allowedAutoPlacements.indexOf(placement) >= 0;
+ });
+
+ if (allowedPlacements.length === 0) {
+ allowedPlacements = placements;
+
+ if (process.env.NODE_ENV !== "production") {
+ console.error(['Popper: The `allowedAutoPlacements` option did not allow any', 'placements. Ensure the `placement` option matches the variation', 'of the allowed placements.', 'For example, "auto" cannot be used to allow "bottom-start".', 'Use "auto-start" instead.'].join(' '));
+ }
+ } // $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions...
+
+
+ var overflows = allowedPlacements.reduce(function (acc, placement) {
+ acc[placement] = detectOverflow(state, {
+ placement: placement,
+ boundary: boundary,
+ rootBoundary: rootBoundary,
+ padding: padding
+ })[getBasePlacement(placement)];
+ return acc;
+ }, {});
+ return Object.keys(overflows).sort(function (a, b) {
+ return overflows[a] - overflows[b];
+ });
+} \ No newline at end of file