Commit 409c94b4 authored by baesangjune's avatar baesangjune
Browse files

rm node_modules

parent df52aea8
import { State, SideObject, Padding } from "../types";
import { Placement, Boundary, RootBoundary, Context } from "../enums";
export declare type Options = {
placement: Placement;
boundary: Boundary;
rootBoundary: RootBoundary;
elementContext: Context;
altBoundary: boolean;
padding: Padding;
};
export default function detectOverflow(state: State, options?: Partial<Options>): SideObject;
import getBoundingClientRect from "../dom-utils/getBoundingClientRect.js";
import getClippingRect from "../dom-utils/getClippingRect.js";
import getDocumentElement from "../dom-utils/getDocumentElement.js";
import computeOffsets from "./computeOffsets.js";
import rectToClientRect from "./rectToClientRect.js";
import { clippingParents, reference, popper, bottom, top, right, basePlacements, viewport } from "../enums.js";
import { isElement } from "../dom-utils/instanceOf.js";
import mergePaddingObject from "./mergePaddingObject.js";
import expandToHashMap from "./expandToHashMap.js"; // eslint-disable-next-line import/no-unused-modules
export default function detectOverflow(state, options) {
if (options === void 0) {
options = {};
}
var _options = options,
_options$placement = _options.placement,
placement = _options$placement === void 0 ? state.placement : _options$placement,
_options$boundary = _options.boundary,
boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
_options$rootBoundary = _options.rootBoundary,
rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
_options$elementConte = _options.elementContext,
elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
_options$altBoundary = _options.altBoundary,
altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
_options$padding = _options.padding,
padding = _options$padding === void 0 ? 0 : _options$padding;
var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
var altContext = elementContext === popper ? reference : popper;
var referenceElement = state.elements.reference;
var popperRect = state.rects.popper;
var element = state.elements[altBoundary ? altContext : elementContext];
var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
var referenceClientRect = getBoundingClientRect(referenceElement);
var popperOffsets = computeOffsets({
reference: referenceClientRect,
element: popperRect,
strategy: 'absolute',
placement: placement
});
var popperClientRect = rectToClientRect(Object.assign(Object.assign({}, popperRect), popperOffsets));
var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
// 0 or negative = within the clipping rect
var overflowOffsets = {
top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
right: elementClientRect.right - clippingClientRect.right + paddingObject.right
};
var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element
if (elementContext === popper && offsetData) {
var offset = offsetData[placement];
Object.keys(overflowOffsets).forEach(function (key) {
var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
overflowOffsets[key] += offset[axis] * multiply;
});
}
return overflowOffsets;
}
\ No newline at end of file
// @flow
import type { State, SideObject, Padding } from '../types';
import type { Placement, Boundary, RootBoundary, Context } from '../enums';
import getBoundingClientRect from '../dom-utils/getBoundingClientRect';
import getClippingRect from '../dom-utils/getClippingRect';
import getDocumentElement from '../dom-utils/getDocumentElement';
import computeOffsets from './computeOffsets';
import rectToClientRect from './rectToClientRect';
import {
clippingParents,
reference,
popper,
bottom,
top,
right,
basePlacements,
viewport,
} from '../enums';
import { isElement } from '../dom-utils/instanceOf';
import mergePaddingObject from './mergePaddingObject';
import expandToHashMap from './expandToHashMap';
// eslint-disable-next-line import/no-unused-modules
export type Options = {
placement: Placement,
boundary: Boundary,
rootBoundary: RootBoundary,
elementContext: Context,
altBoundary: boolean,
padding: Padding,
};
export default function detectOverflow(
state: State,
options: $Shape<Options> = {}
): SideObject {
const {
placement = state.placement,
boundary = clippingParents,
rootBoundary = viewport,
elementContext = popper,
altBoundary = false,
padding = 0,
} = options;
const paddingObject = mergePaddingObject(
typeof padding !== 'number'
? padding
: expandToHashMap(padding, basePlacements)
);
const altContext = elementContext === popper ? reference : popper;
const referenceElement = state.elements.reference;
const popperRect = state.rects.popper;
const element = state.elements[altBoundary ? altContext : elementContext];
const clippingClientRect = getClippingRect(
isElement(element)
? element
: element.contextElement || getDocumentElement(state.elements.popper),
boundary,
rootBoundary
);
const referenceClientRect = getBoundingClientRect(referenceElement);
const popperOffsets = computeOffsets({
reference: referenceClientRect,
element: popperRect,
strategy: 'absolute',
placement,
});
const popperClientRect = rectToClientRect({
...popperRect,
...popperOffsets,
});
const elementClientRect =
elementContext === popper ? popperClientRect : referenceClientRect;
// positive = overflowing the clipping rect
// 0 or negative = within the clipping rect
const overflowOffsets = {
top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
bottom:
elementClientRect.bottom -
clippingClientRect.bottom +
paddingObject.bottom,
left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
right:
elementClientRect.right - clippingClientRect.right + paddingObject.right,
};
const offsetData = state.modifiersData.offset;
// Offsets can be applied only to the popper element
if (elementContext === popper && offsetData) {
const offset = offsetData[placement];
Object.keys(overflowOffsets).forEach((key) => {
const multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
const axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
overflowOffsets[key] += offset[axis] * multiply;
});
}
return overflowOffsets;
}
export default function expandToHashMap<T extends number | string | boolean, K extends string>(value: T, keys: Array<K>): {
[key: string]: T;
};
export default function expandToHashMap(value, keys) {
return keys.reduce(function (hashMap, key) {
hashMap[key] = value;
return hashMap;
}, {});
}
\ No newline at end of file
// @flow
export default function expandToHashMap<
T: number | string | boolean,
K: string
>(value: T, keys: Array<K>): { [key: string]: T } {
return keys.reduce((hashMap, key) => {
hashMap[key] = value;
return hashMap;
}, {});
}
export default function format(str: string, ...args: Array<string>): string;
export default function format(str) {
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
return [].concat(args).reduce(function (p, c) {
return p.replace(/%s/, c);
}, str);
}
\ No newline at end of file
// @flow
export default function format(str: string, ...args: Array<string>) {
return [...args].reduce((p, c) => p.replace(/%s/, c), str);
}
export default function getAltAxis(axis: "x" | "y"): "x" | "y";
export default function getAltAxis(axis) {
return axis === 'x' ? 'y' : 'x';
}
\ No newline at end of file
// @flow
export default function getAltAxis(axis: 'x' | 'y'): 'x' | 'y' {
return axis === 'x' ? 'y' : 'x';
}
export default function getAltLen(len: "width" | "height"): "width" | "height";
export default function getAltLen(len) {
return len === 'width' ? 'height' : 'width';
}
\ No newline at end of file
// @flow
export default function getAltLen(len: 'width' | 'height'): 'width' | 'height' {
return len === 'width' ? 'height' : 'width';
}
import { BasePlacement, Placement, auto } from "../enums";
export default function getBasePlacement(placement: Placement | typeof auto): BasePlacement;
import { auto } from "../enums.js";
export default function getBasePlacement(placement) {
return placement.split('-')[0];
}
\ No newline at end of file
// @flow
import { type BasePlacement, type Placement, auto } from '../enums';
export default function getBasePlacement(
placement: Placement | typeof auto
): BasePlacement {
return (placement.split('-')[0]: any);
}
import { SideObject } from "../types";
export default function getFreshSideObject(): SideObject;
export default function getFreshSideObject() {
return {
top: 0,
right: 0,
bottom: 0,
left: 0
};
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment