Files
klz-cables.com/.pnpm-store/v10/files/e3/7b7f538c746648ae2f212e5a334578bccdbae93bfa39130c81bad0f958cc3674dd8e2415fb5b308b95af35814cf7f6f515cba3384db8ec7db836cb7a08a82d
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

122 lines
2.9 KiB
Plaintext

import { getEventCoordinates } from '@dnd-kit/utilities';
function createSnapModifier(gridSize) {
return _ref => {
let {
transform
} = _ref;
return { ...transform,
x: Math.ceil(transform.x / gridSize) * gridSize,
y: Math.ceil(transform.y / gridSize) * gridSize
};
};
}
const restrictToHorizontalAxis = _ref => {
let {
transform
} = _ref;
return { ...transform,
y: 0
};
};
function restrictToBoundingRect(transform, rect, boundingRect) {
const value = { ...transform
};
if (rect.top + transform.y <= boundingRect.top) {
value.y = boundingRect.top - rect.top;
} else if (rect.bottom + transform.y >= boundingRect.top + boundingRect.height) {
value.y = boundingRect.top + boundingRect.height - rect.bottom;
}
if (rect.left + transform.x <= boundingRect.left) {
value.x = boundingRect.left - rect.left;
} else if (rect.right + transform.x >= boundingRect.left + boundingRect.width) {
value.x = boundingRect.left + boundingRect.width - rect.right;
}
return value;
}
const restrictToParentElement = _ref => {
let {
containerNodeRect,
draggingNodeRect,
transform
} = _ref;
if (!draggingNodeRect || !containerNodeRect) {
return transform;
}
return restrictToBoundingRect(transform, draggingNodeRect, containerNodeRect);
};
const restrictToFirstScrollableAncestor = _ref => {
let {
draggingNodeRect,
transform,
scrollableAncestorRects
} = _ref;
const firstScrollableAncestorRect = scrollableAncestorRects[0];
if (!draggingNodeRect || !firstScrollableAncestorRect) {
return transform;
}
return restrictToBoundingRect(transform, draggingNodeRect, firstScrollableAncestorRect);
};
const restrictToVerticalAxis = _ref => {
let {
transform
} = _ref;
return { ...transform,
x: 0
};
};
const restrictToWindowEdges = _ref => {
let {
transform,
draggingNodeRect,
windowRect
} = _ref;
if (!draggingNodeRect || !windowRect) {
return transform;
}
return restrictToBoundingRect(transform, draggingNodeRect, windowRect);
};
const snapCenterToCursor = _ref => {
let {
activatorEvent,
draggingNodeRect,
transform
} = _ref;
if (draggingNodeRect && activatorEvent) {
const activatorCoordinates = getEventCoordinates(activatorEvent);
if (!activatorCoordinates) {
return transform;
}
const offsetX = activatorCoordinates.x - draggingNodeRect.left;
const offsetY = activatorCoordinates.y - draggingNodeRect.top;
return { ...transform,
x: transform.x + offsetX - draggingNodeRect.width / 2,
y: transform.y + offsetY - draggingNodeRect.height / 2
};
}
return transform;
};
export { createSnapModifier, restrictToFirstScrollableAncestor, restrictToHorizontalAxis, restrictToParentElement, restrictToVerticalAxis, restrictToWindowEdges, snapCenterToCursor };
//# sourceMappingURL=modifiers.esm.js.map