Update Bootstrap to 5.3.2

This commit is contained in:
Will Faught
2023-09-15 22:47:28 -07:00
parent 7282c89d2b
commit 544b51c0b3
141 changed files with 620 additions and 2240 deletions

View File

@@ -2,18 +2,11 @@ import getCompositeRect from "./dom-utils/getCompositeRect.js";
import getLayoutRect from "./dom-utils/getLayoutRect.js";
import listScrollParents from "./dom-utils/listScrollParents.js";
import getOffsetParent from "./dom-utils/getOffsetParent.js";
import getComputedStyle from "./dom-utils/getComputedStyle.js";
import orderModifiers from "./utils/orderModifiers.js";
import debounce from "./utils/debounce.js";
import validateModifiers from "./utils/validateModifiers.js";
import uniqueBy from "./utils/uniqueBy.js";
import getBasePlacement from "./utils/getBasePlacement.js";
import mergeByName from "./utils/mergeByName.js";
import detectOverflow from "./utils/detectOverflow.js";
import { isElement } from "./dom-utils/instanceOf.js";
import { auto } from "./enums.js";
var INVALID_ELEMENT_ERROR = 'Popper: Invalid reference or popper argument provided. They must be either a DOM element or virtual element.';
var INFINITE_LOOP_ERROR = 'Popper: An infinite loop in the modifiers cycle has been detected! The cycle has been interrupted to prevent a browser crash.';
var DEFAULT_OPTIONS = {
placement: 'bottom',
modifiers: [],
@@ -75,42 +68,7 @@ export function popperGenerator(generatorOptions) {
state.orderedModifiers = orderedModifiers.filter(function (m) {
return m.enabled;
}); // Validate the provided modifiers so that the consumer will get warned
// if one of the modifiers is invalid for any reason
if (process.env.NODE_ENV !== "production") {
var modifiers = uniqueBy([].concat(orderedModifiers, state.options.modifiers), function (_ref) {
var name = _ref.name;
return name;
});
validateModifiers(modifiers);
if (getBasePlacement(state.options.placement) === auto) {
var flipModifier = state.orderedModifiers.find(function (_ref2) {
var name = _ref2.name;
return name === 'flip';
});
if (!flipModifier) {
console.error(['Popper: "auto" placements require the "flip" modifier be', 'present and enabled to work.'].join(' '));
}
}
var _getComputedStyle = getComputedStyle(popper),
marginTop = _getComputedStyle.marginTop,
marginRight = _getComputedStyle.marginRight,
marginBottom = _getComputedStyle.marginBottom,
marginLeft = _getComputedStyle.marginLeft; // We no longer take into account `margins` on the popper, and it can
// cause bugs with positioning, so we'll warn the consumer
if ([marginTop, marginRight, marginBottom, marginLeft].some(function (margin) {
return parseFloat(margin);
})) {
console.warn(['Popper: CSS "margin" styles cannot be used to apply padding', 'between the popper and its reference element or boundary.', 'To replicate margin, use the `offset` modifier, as well as', 'the `padding` option in the `preventOverflow` and `flip`', 'modifiers.'].join(' '));
}
}
});
runModifierEffects();
return instance.update();
},
@@ -130,10 +88,6 @@ export function popperGenerator(generatorOptions) {
// anymore
if (!areValidElements(reference, popper)) {
if (process.env.NODE_ENV !== "production") {
console.error(INVALID_ELEMENT_ERROR);
}
return;
} // Store the reference and popper rects to be read by modifiers
@@ -156,18 +110,8 @@ export function popperGenerator(generatorOptions) {
state.orderedModifiers.forEach(function (modifier) {
return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
});
var __debug_loops__ = 0;
for (var index = 0; index < state.orderedModifiers.length; index++) {
if (process.env.NODE_ENV !== "production") {
__debug_loops__ += 1;
if (__debug_loops__ > 100) {
console.error(INFINITE_LOOP_ERROR);
break;
}
}
if (state.reset === true) {
state.reset = false;
index = -1;
@@ -205,10 +149,6 @@ export function popperGenerator(generatorOptions) {
};
if (!areValidElements(reference, popper)) {
if (process.env.NODE_ENV !== "production") {
console.error(INVALID_ELEMENT_ERROR);
}
return instance;
}
@@ -223,11 +163,11 @@ export function popperGenerator(generatorOptions) {
// one.
function runModifierEffects() {
state.orderedModifiers.forEach(function (_ref3) {
var name = _ref3.name,
_ref3$options = _ref3.options,
options = _ref3$options === void 0 ? {} : _ref3$options,
effect = _ref3.effect;
state.orderedModifiers.forEach(function (_ref) {
var name = _ref.name,
_ref$options = _ref.options,
options = _ref$options === void 0 ? {} : _ref$options,
effect = _ref.effect;
if (typeof effect === 'function') {
var cleanupFn = effect({

View File

@@ -10,21 +10,11 @@ import getCompositeRect from './dom-utils/getCompositeRect';
import getLayoutRect from './dom-utils/getLayoutRect';
import listScrollParents from './dom-utils/listScrollParents';
import getOffsetParent from './dom-utils/getOffsetParent';
import getComputedStyle from './dom-utils/getComputedStyle';
import orderModifiers from './utils/orderModifiers';
import debounce from './utils/debounce';
import validateModifiers from './utils/validateModifiers';
import uniqueBy from './utils/uniqueBy';
import getBasePlacement from './utils/getBasePlacement';
import mergeByName from './utils/mergeByName';
import detectOverflow from './utils/detectOverflow';
import { isElement } from './dom-utils/instanceOf';
import { auto } from './enums';
const INVALID_ELEMENT_ERROR =
'Popper: Invalid reference or popper argument provided. They must be either a DOM element or virtual element.';
const INFINITE_LOOP_ERROR =
'Popper: An infinite loop in the modifiers cycle has been detected! The cycle has been interrupted to prevent a browser crash.';
const DEFAULT_OPTIONS: OptionsGeneric<any> = {
placement: 'bottom',
@@ -45,10 +35,8 @@ function areValidElements(...args: Array<any>): boolean {
}
export function popperGenerator(generatorOptions: PopperGeneratorArgs = {}) {
const {
defaultModifiers = [],
defaultOptions = DEFAULT_OPTIONS,
} = generatorOptions;
const { defaultModifiers = [], defaultOptions = DEFAULT_OPTIONS } =
generatorOptions;
return function createPopper<TModifier: $Shape<Modifier<any, any>>>(
reference: Element | VirtualElement,
@@ -106,57 +94,6 @@ export function popperGenerator(generatorOptions: PopperGeneratorArgs = {}) {
// Strip out disabled modifiers
state.orderedModifiers = orderedModifiers.filter((m) => m.enabled);
// Validate the provided modifiers so that the consumer will get warned
// if one of the modifiers is invalid for any reason
if (false) {
const modifiers = uniqueBy(
[...orderedModifiers, ...state.options.modifiers],
({ name }) => name
);
validateModifiers(modifiers);
if (getBasePlacement(state.options.placement) === auto) {
const flipModifier = state.orderedModifiers.find(
({ name }) => name === 'flip'
);
if (!flipModifier) {
console.error(
[
'Popper: "auto" placements require the "flip" modifier be',
'present and enabled to work.',
].join(' ')
);
}
}
const {
marginTop,
marginRight,
marginBottom,
marginLeft,
} = getComputedStyle(popper);
// We no longer take into account `margins` on the popper, and it can
// cause bugs with positioning, so we'll warn the consumer
if (
[marginTop, marginRight, marginBottom, marginLeft].some((margin) =>
parseFloat(margin)
)
) {
console.warn(
[
'Popper: CSS "margin" styles cannot be used to apply padding',
'between the popper and its reference element or boundary.',
'To replicate margin, use the `offset` modifier, as well as',
'the `padding` option in the `preventOverflow` and `flip`',
'modifiers.',
].join(' ')
);
}
}
runModifierEffects();
return instance.update();
@@ -177,9 +114,6 @@ export function popperGenerator(generatorOptions: PopperGeneratorArgs = {}) {
// Don't proceed if `reference` or `popper` are not valid elements
// anymore
if (!areValidElements(reference, popper)) {
if (false) {
console.error(INVALID_ELEMENT_ERROR);
}
return;
}
@@ -213,16 +147,7 @@ export function popperGenerator(generatorOptions: PopperGeneratorArgs = {}) {
})
);
let __debug_loops__ = 0;
for (let index = 0; index < state.orderedModifiers.length; index++) {
if (false) {
__debug_loops__ += 1;
if (__debug_loops__ > 100) {
console.error(INFINITE_LOOP_ERROR);
break;
}
}
if (state.reset === true) {
state.reset = false;
index = -1;
@@ -254,9 +179,6 @@ export function popperGenerator(generatorOptions: PopperGeneratorArgs = {}) {
};
if (!areValidElements(reference, popper)) {
if (false) {
console.error(INVALID_ELEMENT_ERROR);
}
return instance;
}

View File

@@ -6,8 +6,7 @@ import getMainAxisFromPlacement from "../utils/getMainAxisFromPlacement.js";
import { within } from "../utils/within.js";
import mergePaddingObject from "../utils/mergePaddingObject.js";
import expandToHashMap from "../utils/expandToHashMap.js";
import { left, right, basePlacements, top, bottom } from "../enums.js";
import { isHTMLElement } from "../dom-utils/instanceOf.js"; // eslint-disable-next-line import/no-unused-modules
import { left, right, basePlacements, top, bottom } from "../enums.js"; // eslint-disable-next-line import/no-unused-modules
var toPaddingObject = function toPaddingObject(padding, state) {
padding = typeof padding === 'function' ? padding(Object.assign({}, state.rects, {
@@ -72,17 +71,7 @@ function effect(_ref2) {
}
}
if (process.env.NODE_ENV !== "production") {
if (!isHTMLElement(arrowElement)) {
console.error(['Popper: "arrow" element must be an HTMLElement (not an SVGElement).', 'To use an SVG arrow, wrap it in an HTMLElement that will be used as', 'the arrow.'].join(' '));
}
}
if (!contains(state.elements.popper, arrowElement)) {
if (process.env.NODE_ENV !== "production") {
console.error(['Popper: "arrow" modifier\'s `element` must be a child of the popper', 'element.'].join(' '));
}
return;
}

View File

@@ -10,7 +10,6 @@ import { within } from '../utils/within';
import mergePaddingObject from '../utils/mergePaddingObject';
import expandToHashMap from '../utils/expandToHashMap';
import { left, right, basePlacements, top, bottom } from '../enums';
import { isHTMLElement } from '../dom-utils/instanceOf';
// eslint-disable-next-line import/no-unused-modules
export type Options = {
@@ -101,28 +100,7 @@ function effect({ state, options }: ModifierArguments<Options>) {
}
}
if (false) {
if (!isHTMLElement(arrowElement)) {
console.error(
[
'Popper: "arrow" element must be an HTMLElement (not an SVGElement).',
'To use an SVG arrow, wrap it in an HTMLElement that will be used as',
'the arrow.',
].join(' ')
);
}
}
if (!contains(state.elements.popper, arrowElement)) {
if (false) {
console.error(
[
'Popper: "arrow" modifier\'s `element` must be a child of the popper',
'element.',
].join(' ')
);
}
return;
}

View File

@@ -127,17 +127,6 @@ function computeStyles(_ref5) {
adaptive = _options$adaptive === void 0 ? true : _options$adaptive,
_options$roundOffsets = options.roundOffsets,
roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
if (process.env.NODE_ENV !== "production") {
var transitionProperty = getComputedStyle(state.elements.popper).transitionProperty || '';
if (adaptive && ['transform', 'top', 'right', 'bottom', 'left'].some(function (property) {
return transitionProperty.indexOf(property) >= 0;
})) {
console.warn(['Popper: Detected CSS transitions on at least one of the following', 'CSS properties: "transform", "top", "right", "bottom", "left".', '\n\n', 'Disable the "computeStyles" modifier\'s `adaptive` option to allow', 'for smooth transitions, or remove these properties from the CSS', 'transition declaration on the popper element if only transitioning', 'opacity or background-color for example.', '\n\n', 'We recommend using the popper element as a wrapper around an inner', 'element that can have any CSS property transitioned for animations.'].join(' '));
}
}
var commonStyles = {
placement: getBasePlacement(state.placement),
variation: getVariation(state.placement),

View File

@@ -81,9 +81,7 @@ export function mapToStyles({
let { x = 0, y = 0 } = offsets;
({ x, y } =
typeof roundOffsets === 'function'
? roundOffsets({ x, y })
: { x, y });
typeof roundOffsets === 'function' ? roundOffsets({ x, y }) : { x, y });
const hasX = offsets.hasOwnProperty('x');
const hasY = offsets.hasOwnProperty('y');
@@ -183,33 +181,6 @@ function computeStyles({ state, options }: ModifierArguments<Options>) {
roundOffsets = true,
} = options;
if (false) {
const transitionProperty =
getComputedStyle(state.elements.popper).transitionProperty || '';
if (
adaptive &&
['transform', 'top', 'right', 'bottom', 'left'].some(
(property) => transitionProperty.indexOf(property) >= 0
)
) {
console.warn(
[
'Popper: Detected CSS transitions on at least one of the following',
'CSS properties: "transform", "top", "right", "bottom", "left".',
'\n\n',
'Disable the "computeStyles" modifier\'s `adaptive` option to allow',
'for smooth transitions, or remove these properties from the CSS',
'transition declaration on the popper element if only transitioning',
'opacity or background-color for example.',
'\n\n',
'We recommend using the popper element as a wrapper around an inner',
'element that can have any CSS property transitioned for animations.',
].join(' ')
);
}
}
const commonStyles = {
placement: getBasePlacement(state.placement),
variation: getVariation(state.placement),

View File

@@ -25,10 +25,6 @@ export default function computeAutoPlacement(state, options) {
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...

View File

@@ -55,18 +55,6 @@ export default function computeAutoPlacement(
if (allowedPlacements.length === 0) {
allowedPlacements = placements;
if (false) {
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...

View File

@@ -1 +0,0 @@
export default function format(str: string, ...args: Array<string>): string;

View File

@@ -1,9 +0,0 @@
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);
}

View File

@@ -1,5 +0,0 @@
// @flow
export default function format(str: string, ...args: Array<string>) {
return [...args].reduce((p, c) => p.replace(/%s/, c), str);
}

View File

@@ -1 +0,0 @@
export default function validateModifiers(modifiers: Array<any>): void;

View File

@@ -1,81 +0,0 @@
import format from "./format.js";
import { modifierPhases } from "../enums.js";
var INVALID_MODIFIER_ERROR = 'Popper: modifier "%s" provided an invalid %s property, expected %s but got %s';
var MISSING_DEPENDENCY_ERROR = 'Popper: modifier "%s" requires "%s", but "%s" modifier is not available';
var VALID_PROPERTIES = ['name', 'enabled', 'phase', 'fn', 'effect', 'requires', 'options'];
export default function validateModifiers(modifiers) {
modifiers.forEach(function (modifier) {
[].concat(Object.keys(modifier), VALID_PROPERTIES) // IE11-compatible replacement for `new Set(iterable)`
.filter(function (value, index, self) {
return self.indexOf(value) === index;
}).forEach(function (key) {
switch (key) {
case 'name':
if (typeof modifier.name !== 'string') {
console.error(format(INVALID_MODIFIER_ERROR, String(modifier.name), '"name"', '"string"', "\"" + String(modifier.name) + "\""));
}
break;
case 'enabled':
if (typeof modifier.enabled !== 'boolean') {
console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"enabled"', '"boolean"', "\"" + String(modifier.enabled) + "\""));
}
break;
case 'phase':
if (modifierPhases.indexOf(modifier.phase) < 0) {
console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"phase"', "either " + modifierPhases.join(', '), "\"" + String(modifier.phase) + "\""));
}
break;
case 'fn':
if (typeof modifier.fn !== 'function') {
console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"fn"', '"function"', "\"" + String(modifier.fn) + "\""));
}
break;
case 'effect':
if (modifier.effect != null && typeof modifier.effect !== 'function') {
console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"effect"', '"function"', "\"" + String(modifier.fn) + "\""));
}
break;
case 'requires':
if (modifier.requires != null && !Array.isArray(modifier.requires)) {
console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requires"', '"array"', "\"" + String(modifier.requires) + "\""));
}
break;
case 'requiresIfExists':
if (!Array.isArray(modifier.requiresIfExists)) {
console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requiresIfExists"', '"array"', "\"" + String(modifier.requiresIfExists) + "\""));
}
break;
case 'options':
case 'data':
break;
default:
console.error("PopperJS: an invalid property has been provided to the \"" + modifier.name + "\" modifier, valid properties are " + VALID_PROPERTIES.map(function (s) {
return "\"" + s + "\"";
}).join(', ') + "; but \"" + key + "\" was provided.");
}
modifier.requires && modifier.requires.forEach(function (requirement) {
if (modifiers.find(function (mod) {
return mod.name === requirement;
}) == null) {
console.error(format(MISSING_DEPENDENCY_ERROR, String(modifier.name), requirement, requirement));
}
});
});
});
}

View File

@@ -1,151 +0,0 @@
// @flow
import format from './format';
import { modifierPhases } from '../enums';
const INVALID_MODIFIER_ERROR =
'Popper: modifier "%s" provided an invalid %s property, expected %s but got %s';
const MISSING_DEPENDENCY_ERROR =
'Popper: modifier "%s" requires "%s", but "%s" modifier is not available';
const VALID_PROPERTIES = [
'name',
'enabled',
'phase',
'fn',
'effect',
'requires',
'options',
];
export default function validateModifiers(modifiers: Array<any>): void {
modifiers.forEach((modifier) => {
[...Object.keys(modifier), ...VALID_PROPERTIES]
// IE11-compatible replacement for `new Set(iterable)`
.filter((value, index, self) => self.indexOf(value) === index)
.forEach((key) => {
switch (key) {
case 'name':
if (typeof modifier.name !== 'string') {
console.error(
format(
INVALID_MODIFIER_ERROR,
String(modifier.name),
'"name"',
'"string"',
`"${String(modifier.name)}"`
)
);
}
break;
case 'enabled':
if (typeof modifier.enabled !== 'boolean') {
console.error(
format(
INVALID_MODIFIER_ERROR,
modifier.name,
'"enabled"',
'"boolean"',
`"${String(modifier.enabled)}"`
)
);
}
break;
case 'phase':
if (modifierPhases.indexOf(modifier.phase) < 0) {
console.error(
format(
INVALID_MODIFIER_ERROR,
modifier.name,
'"phase"',
`either ${modifierPhases.join(', ')}`,
`"${String(modifier.phase)}"`
)
);
}
break;
case 'fn':
if (typeof modifier.fn !== 'function') {
console.error(
format(
INVALID_MODIFIER_ERROR,
modifier.name,
'"fn"',
'"function"',
`"${String(modifier.fn)}"`
)
);
}
break;
case 'effect':
if (
modifier.effect != null &&
typeof modifier.effect !== 'function'
) {
console.error(
format(
INVALID_MODIFIER_ERROR,
modifier.name,
'"effect"',
'"function"',
`"${String(modifier.fn)}"`
)
);
}
break;
case 'requires':
if (
modifier.requires != null &&
!Array.isArray(modifier.requires)
) {
console.error(
format(
INVALID_MODIFIER_ERROR,
modifier.name,
'"requires"',
'"array"',
`"${String(modifier.requires)}"`
)
);
}
break;
case 'requiresIfExists':
if (!Array.isArray(modifier.requiresIfExists)) {
console.error(
format(
INVALID_MODIFIER_ERROR,
modifier.name,
'"requiresIfExists"',
'"array"',
`"${String(modifier.requiresIfExists)}"`
)
);
}
break;
case 'options':
case 'data':
break;
default:
console.error(
`PopperJS: an invalid property has been provided to the "${
modifier.name
}" modifier, valid properties are ${VALID_PROPERTIES.map(
(s) => `"${s}"`
).join(', ')}; but "${key}" was provided.`
);
}
modifier.requires &&
modifier.requires.forEach((requirement) => {
if (modifiers.find((mod) => mod.name === requirement) == null) {
console.error(
format(
MISSING_DEPENDENCY_ERROR,
String(modifier.name),
requirement,
requirement
)
);
}
});
});
});
}