Initial commit

This commit is contained in:
Marek Lesko
2025-08-19 16:58:51 +02:00
commit a2f7e2285a
908 changed files with 160315 additions and 0 deletions

View File

@@ -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 (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...
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];
});
}

View File

@@ -0,0 +1 @@
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(a,e){var e=e=void 0===e?{}:e,t=e.placement,n=e.boundary,r=e.rootBoundary,o=e.padding,i=e.flipVariations,e=e.allowedAutoPlacements,l=void 0===e?allPlacements:e,c=getVariation(t),e=c?i?variationPlacements:variationPlacements.filter(function(e){return getVariation(e)===c}):basePlacements,t=e.filter(function(e){return 0<=l.indexOf(e)}),m=(t=0===t.length?e:t).reduce(function(e,t){return e[t]=detectOverflow(a,{placement:t,boundary:n,rootBoundary:r,padding:o})[getBasePlacement(t)],e},{});return Object.keys(m).sort(function(e,t){return m[e]-m[t]})}

View File

@@ -0,0 +1,70 @@
import getBasePlacement from "./getBasePlacement.js";
import getVariation from "./getVariation.js";
import getMainAxisFromPlacement from "./getMainAxisFromPlacement.js";
import { top, right, bottom, left, start, end } from "../enums.js";
export default function computeOffsets(_ref) {
var reference = _ref.reference,
element = _ref.element,
placement = _ref.placement;
var basePlacement = placement ? getBasePlacement(placement) : null;
var variation = placement ? getVariation(placement) : null;
var commonX = reference.x + reference.width / 2 - element.width / 2;
var commonY = reference.y + reference.height / 2 - element.height / 2;
var offsets;
switch (basePlacement) {
case top:
offsets = {
x: commonX,
y: reference.y - element.height
};
break;
case bottom:
offsets = {
x: commonX,
y: reference.y + reference.height
};
break;
case right:
offsets = {
x: reference.x + reference.width,
y: commonY
};
break;
case left:
offsets = {
x: reference.x - element.width,
y: commonY
};
break;
default:
offsets = {
x: reference.x,
y: reference.y
};
}
var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
if (mainAxis != null) {
var len = mainAxis === 'y' ? 'height' : 'width';
switch (variation) {
case start:
offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
break;
case end:
offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
break;
default:
}
}
return offsets;
}

View File

@@ -0,0 +1 @@
import getBasePlacement from"./getBasePlacement.js";import getVariation from"./getVariation.js";import getMainAxisFromPlacement from"./getMainAxisFromPlacement.js";import{top,right,bottom,left,start,end}from"../enums.js";export default function computeOffsets(e){var t,a=e.reference,i=e.element,e=e.placement,r=e?getBasePlacement(e):null,e=e?getVariation(e):null,n=a.x+a.width/2-i.width/2,m=a.y+a.height/2-i.height/2;switch(r){case top:t={x:n,y:a.y-i.height};break;case bottom:t={x:n,y:a.y+a.height};break;case right:t={x:a.x+a.width,y:m};break;case left:t={x:a.x-i.width,y:m};break;default:t={x:a.x,y:a.y}}var o=r?getMainAxisFromPlacement(r):null;if(null!=o){var s="y"===o?"height":"width";switch(e){case start:t[o]=t[o]-(a[s]/2-i[s]/2);break;case end:t[o]=t[o]+(a[s]/2-i[s]/2)}}return t}

View File

@@ -0,0 +1,15 @@
export default function debounce(fn) {
var pending;
return function () {
if (!pending) {
pending = new Promise(function (resolve) {
Promise.resolve().then(function () {
pending = undefined;
resolve(fn());
});
});
}
return pending;
};
}

View File

@@ -0,0 +1 @@
export default function debounce(e){var o;return function(){return o=o||new Promise(function(n){Promise.resolve().then(function(){o=void 0,n(e())})})}}

View File

@@ -0,0 +1,65 @@
import getClippingRect from "../dom-utils/getClippingRect.js";
import getDocumentElement from "../dom-utils/getDocumentElement.js";
import getBoundingClientRect from "../dom-utils/getBoundingClientRect.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$strategy = _options.strategy,
strategy = _options$strategy === void 0 ? state.strategy : _options$strategy,
_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 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, strategy);
var referenceClientRect = getBoundingClientRect(state.elements.reference);
var popperOffsets = computeOffsets({
reference: referenceClientRect,
element: popperRect,
strategy: 'absolute',
placement: placement
});
var popperClientRect = rectToClientRect(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;
}

View File

@@ -0,0 +1 @@
import getClippingRect from"../dom-utils/getClippingRect.js";import getDocumentElement from"../dom-utils/getDocumentElement.js";import getBoundingClientRect from"../dom-utils/getBoundingClientRect.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";export default function detectOverflow(e,t){var r,t=t=void 0===t?{}:t,o=t.placement,o=void 0===o?e.placement:o,n=t.strategy,n=void 0===n?e.strategy:n,p=t.boundary,p=void 0===p?clippingParents:p,i=t.rootBoundary,i=void 0===i?viewport:i,m=t.elementContext,m=void 0===m?popper:m,s=t.altBoundary,s=void 0!==s&&s,t=t.padding,t=void 0===t?0:t,t=mergePaddingObject("number"!=typeof t?t:expandToHashMap(t,basePlacements)),c=e.rects.popper,s=e.elements[s?m===popper?reference:popper:m],s=getClippingRect(isElement(s)?s:s.contextElement||getDocumentElement(e.elements.popper),p,i,n),p=getBoundingClientRect(e.elements.reference),i=computeOffsets({reference:p,element:c,strategy:"absolute",placement:o}),n=rectToClientRect(Object.assign({},c,i)),c=m===popper?n:p,l={top:s.top-c.top+t.top,bottom:c.bottom-s.bottom+t.bottom,left:s.left-c.left+t.left,right:c.right-s.right+t.right},i=e.modifiersData.offset;return m===popper&&i&&(r=i[o],Object.keys(l).forEach(function(e){var t=0<=[right,bottom].indexOf(e)?1:-1,o=0<=[top,bottom].indexOf(e)?"y":"x";l[e]+=r[o]*t})),l}

View File

@@ -0,0 +1,6 @@
export default function expandToHashMap(value, keys) {
return keys.reduce(function (hashMap, key) {
hashMap[key] = value;
return hashMap;
}, {});
}

View File

@@ -0,0 +1 @@
export default function expandToHashMap(r,e){return e.reduce(function(e,n){return e[n]=r,e},{})}

View File

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

@@ -0,0 +1 @@
export default function format(r){for(var e=arguments.length,n=new Array(1<e?e-1:0),t=1;t<e;t++)n[t-1]=arguments[t];return[].concat(n).reduce(function(r,e){return r.replace(/%s/,e)},r)}

View File

@@ -0,0 +1,3 @@
export default function getAltAxis(axis) {
return axis === 'x' ? 'y' : 'x';
}

View File

@@ -0,0 +1 @@
export default function getAltAxis(t){return"x"===t?"y":"x"}

View File

@@ -0,0 +1,3 @@
export default function getAltLen(len) {
return len === 'width' ? 'height' : 'width';
}

View File

@@ -0,0 +1 @@
export default function getAltLen(t){return"width"===t?"height":"width"}

View File

@@ -0,0 +1,4 @@
import { auto } from "../enums.js";
export default function getBasePlacement(placement) {
return placement.split('-')[0];
}

View File

@@ -0,0 +1 @@
import{auto}from"../enums.js";export default function getBasePlacement(t){return t.split("-")[0]}

View File

@@ -0,0 +1,8 @@
export default function getFreshSideObject() {
return {
top: 0,
right: 0,
bottom: 0,
left: 0
};
}

View File

@@ -0,0 +1 @@
export default function getFreshSideObject(){return{top:0,right:0,bottom:0,left:0}}

View File

@@ -0,0 +1,3 @@
export default function getMainAxisFromPlacement(placement) {
return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
}

View File

@@ -0,0 +1 @@
export default function getMainAxisFromPlacement(t){return 0<=["top","bottom"].indexOf(t)?"x":"y"}

View File

@@ -0,0 +1,11 @@
var hash = {
left: 'right',
right: 'left',
bottom: 'top',
top: 'bottom'
};
export default function getOppositePlacement(placement) {
return placement.replace(/left|right|bottom|top/g, function (matched) {
return hash[matched];
});
}

View File

@@ -0,0 +1 @@
var hash={left:"right",right:"left",bottom:"top",top:"bottom"};export default function getOppositePlacement(t){return t.replace(/left|right|bottom|top/g,function(t){return hash[t]})}

View File

@@ -0,0 +1,9 @@
var hash = {
start: 'end',
end: 'start'
};
export default function getOppositeVariationPlacement(placement) {
return placement.replace(/start|end/g, function (matched) {
return hash[matched];
});
}

View File

@@ -0,0 +1 @@
var hash={start:"end",end:"start"};export default function getOppositeVariationPlacement(t){return t.replace(/start|end/g,function(t){return hash[t]})}

View File

@@ -0,0 +1,3 @@
export default function getVariation(placement) {
return placement.split('-')[1];
}

View File

@@ -0,0 +1 @@
export default function getVariation(t){return t.split("-")[1]}

View File

@@ -0,0 +1,3 @@
export var max = Math.max;
export var min = Math.min;
export var round = Math.round;

View File

@@ -0,0 +1 @@
var max=Math.max,min=Math.min,round=Math.round;export{max,min,round};

View File

@@ -0,0 +1,14 @@
export default function mergeByName(modifiers) {
var merged = modifiers.reduce(function (merged, current) {
var existing = merged[current.name];
merged[current.name] = existing ? Object.assign({}, existing, current, {
options: Object.assign({}, existing.options, current.options),
data: Object.assign({}, existing.data, current.data)
}) : current;
return merged;
}, {}); // IE11 does not support Object.values
return Object.keys(merged).map(function (key) {
return merged[key];
});
}

View File

@@ -0,0 +1 @@
export default function mergeByName(t){var e=t.reduce(function(t,e){var n=t[e.name];return t[e.name]=n?Object.assign({},n,e,{options:Object.assign({},n.options,e.options),data:Object.assign({},n.data,e.data)}):e,t},{});return Object.keys(e).map(function(t){return e[t]})}

View File

@@ -0,0 +1,4 @@
import getFreshSideObject from "./getFreshSideObject.js";
export default function mergePaddingObject(paddingObject) {
return Object.assign({}, getFreshSideObject(), paddingObject);
}

View File

@@ -0,0 +1 @@
import getFreshSideObject from"./getFreshSideObject.js";export default function mergePaddingObject(e){return Object.assign({},getFreshSideObject(),e)}

View File

@@ -0,0 +1,44 @@
import { modifierPhases } from "../enums.js"; // source: https://stackoverflow.com/questions/49875255
function order(modifiers) {
var map = new Map();
var visited = new Set();
var result = [];
modifiers.forEach(function (modifier) {
map.set(modifier.name, modifier);
}); // On visiting object, check for its dependencies and visit them recursively
function sort(modifier) {
visited.add(modifier.name);
var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
requires.forEach(function (dep) {
if (!visited.has(dep)) {
var depModifier = map.get(dep);
if (depModifier) {
sort(depModifier);
}
}
});
result.push(modifier);
}
modifiers.forEach(function (modifier) {
if (!visited.has(modifier.name)) {
// check for visited object
sort(modifier);
}
});
return result;
}
export default function orderModifiers(modifiers) {
// order based on dependencies
var orderedModifiers = order(modifiers); // order based on phase
return modifierPhases.reduce(function (acc, phase) {
return acc.concat(orderedModifiers.filter(function (modifier) {
return modifier.phase === phase;
}));
}, []);
}

View File

@@ -0,0 +1 @@
import{modifierPhases}from"../enums.js";function order(e){var n=new Map,o=new Set,t=[];return e.forEach(function(e){n.set(e.name,e)}),e.forEach(function(e){o.has(e.name)||!function r(e){o.add(e.name),[].concat(e.requires||[],e.requiresIfExists||[]).forEach(function(e){o.has(e)||(e=n.get(e))&&r(e)}),t.push(e)}(e)}),t}export default function orderModifiers(e){var n=order(e);return modifierPhases.reduce(function(e,r){return e.concat(n.filter(function(e){return e.phase===r}))},[])}

View File

@@ -0,0 +1,8 @@
export default function rectToClientRect(rect) {
return Object.assign({}, rect, {
left: rect.x,
top: rect.y,
right: rect.x + rect.width,
bottom: rect.y + rect.height
});
}

View File

@@ -0,0 +1 @@
export default function rectToClientRect(t){return Object.assign({},t,{left:t.x,top:t.y,right:t.x+t.width,bottom:t.y+t.height})}

View File

@@ -0,0 +1,11 @@
export default function uniqueBy(arr, fn) {
var identifiers = new Set();
return arr.filter(function (item) {
var identifier = fn(item);
if (!identifiers.has(identifier)) {
identifiers.add(identifier);
return true;
}
});
}

View File

@@ -0,0 +1 @@
export default function uniqueBy(e,n){var t=new Set;return e.filter(function(e){e=n(e);if(!t.has(e))return t.add(e),!0})}

View File

@@ -0,0 +1,11 @@
export default function getUAString() {
var uaData = navigator.userAgentData;
if (uaData != null && uaData.brands) {
return uaData.brands.map(function (item) {
return item.brand + "/" + item.version;
}).join(' ');
}
return navigator.userAgent;
}

View File

@@ -0,0 +1 @@
export default function getUAString(){var n=navigator.userAgentData;return null!=n&&n.brands?n.brands.map(function(n){return n.brand+"/"+n.version}).join(" "):navigator.userAgent}

View File

@@ -0,0 +1,81 @@
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

@@ -0,0 +1 @@
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',MISSING_DEPENDENCY_ERROR='Popper: modifier "%s" requires "%s", but "%s" modifier is not available',VALID_PROPERTIES=["name","enabled","phase","fn","effect","requires","options"];export default function validateModifiers(o){o.forEach(function(n){[].concat(Object.keys(n),VALID_PROPERTIES).filter(function(e,r,n){return n.indexOf(e)===r}).forEach(function(e){switch(e){case"name":"string"!=typeof n.name&&console.error(format(INVALID_MODIFIER_ERROR,String(n.name),'"name"','"string"','"'+String(n.name)+'"'));break;case"enabled":"boolean"!=typeof n.enabled&&console.error(format(INVALID_MODIFIER_ERROR,n.name,'"enabled"','"boolean"','"'+String(n.enabled)+'"'));break;case"phase":modifierPhases.indexOf(n.phase)<0&&console.error(format(INVALID_MODIFIER_ERROR,n.name,'"phase"',"either "+modifierPhases.join(", "),'"'+String(n.phase)+'"'));break;case"fn":"function"!=typeof n.fn&&console.error(format(INVALID_MODIFIER_ERROR,n.name,'"fn"','"function"','"'+String(n.fn)+'"'));break;case"effect":null!=n.effect&&"function"!=typeof n.effect&&console.error(format(INVALID_MODIFIER_ERROR,n.name,'"effect"','"function"','"'+String(n.fn)+'"'));break;case"requires":null==n.requires||Array.isArray(n.requires)||console.error(format(INVALID_MODIFIER_ERROR,n.name,'"requires"','"array"','"'+String(n.requires)+'"'));break;case"requiresIfExists":Array.isArray(n.requiresIfExists)||console.error(format(INVALID_MODIFIER_ERROR,n.name,'"requiresIfExists"','"array"','"'+String(n.requiresIfExists)+'"'));break;case"options":case"data":break;default:console.error('PopperJS: an invalid property has been provided to the "'+n.name+'" modifier, valid properties are '+VALID_PROPERTIES.map(function(e){return'"'+e+'"'}).join(", ")+'; but "'+e+'" was provided.')}n.requires&&n.requires.forEach(function(r){null==o.find(function(e){return e.name===r})&&console.error(format(MISSING_DEPENDENCY_ERROR,String(n.name),r,r))})})})}

View File

@@ -0,0 +1,8 @@
import { max as mathMax, min as mathMin } from "./math.js";
export function within(min, value, max) {
return mathMax(min, mathMin(value, max));
}
export function withinMaxClamp(min, value, max) {
var v = within(min, value, max);
return v > max ? max : v;
}

View File

@@ -0,0 +1 @@
import{max as mathMax,min as mathMin}from"./math.js";function within(i,t,a){return mathMax(i,mathMin(t,a))}function withinMaxClamp(i,t,a){i=within(i,t,a);return a<i?a:i}export{within,withinMaxClamp};