@yewdiel21/motion-kit 0.14.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +174 -155
- package/bin/motion-kit.mjs +3 -3
- package/dist/auto/index.d.ts +6 -3
- package/dist/auto/index.js +8 -2
- package/dist/auto/index.js.map +1 -1
- package/dist/{chunk-EY4BJKC4.js → chunk-6IRJYXJU.js} +2 -2
- package/dist/{chunk-CU6SXW3E.js → chunk-A6QQCF6V.js} +1309 -310
- package/dist/chunk-A6QQCF6V.js.map +1 -0
- package/dist/chunk-JXRS3OEA.js +3638 -0
- package/dist/chunk-JXRS3OEA.js.map +1 -0
- package/dist/css/components/add-to-cart.css +72 -0
- package/dist/css/components/bidirectional-slider.css +168 -0
- package/dist/css/components/data-table.css +121 -26
- package/dist/css/components/filter-builder.css +10 -15
- package/dist/css/components/heatmap-chart.css +391 -0
- package/dist/css/components/hover-card.css +8 -2
- package/dist/css/components/image-preview.css +90 -2
- package/dist/css/components/json-viewer.css +33 -1
- package/dist/css/components/nav.css +102 -102
- package/dist/css/components/orbit-menu.css +130 -0
- package/dist/css/components/pagination.css +10 -5
- package/dist/css/components/pie-chart.css +390 -0
- package/dist/css/components/pill-button.css +135 -0
- package/dist/css/components/radar-chart.css +370 -0
- package/dist/css/components/radial-chart.css +398 -0
- package/dist/css/components/sankey-chart.css +358 -0
- package/dist/css/components/scroll-island.css +111 -0
- package/dist/css/components/select.css +136 -0
- package/dist/css/components/toolbar.css +122 -0
- package/dist/css/components/tree-view.css +79 -0
- package/dist/css/components/voice-dots.css +70 -0
- package/dist/elements/index.d.ts +180 -7
- package/dist/elements/index.js +287 -6
- package/dist/elements/index.js.map +1 -1
- package/dist/{engine-Cn6IhE3z.d.ts → engine-5zRIssTO.d.ts} +11 -1
- package/dist/index.css +1832 -168
- package/dist/index.d.ts +4 -4
- package/dist/index.js +33 -3
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.ts +117 -11
- package/dist/react/index.js +314 -13
- package/dist/react/index.js.map +1 -1
- package/dist/{reduced-BBUusld6.d.ts → reduced-6X_bns60.d.ts} +1 -1
- package/dist/{reveal-DEvp6U6T.d.ts → reveal-BfyKKsw4.d.ts} +97 -4
- package/dist/store-CA2Qcun_.d.ts +453 -0
- package/package.json +9 -16
- package/registry.json +1096 -948
- package/src/auto/auto-init.ts +6 -0
- package/src/components/add-to-cart/README.md +34 -0
- package/src/components/add-to-cart/add-to-cart.css +71 -0
- package/src/components/add-to-cart/element.ts +20 -0
- package/src/components/add-to-cart/engine.ts +206 -0
- package/src/components/add-to-cart/react.tsx +29 -0
- package/src/components/bidirectional-slider/README.md +46 -0
- package/src/components/bidirectional-slider/bidirectional-slider.css +167 -0
- package/src/components/bidirectional-slider/element.ts +42 -0
- package/src/components/bidirectional-slider/engine.ts +289 -0
- package/src/components/bidirectional-slider/react.tsx +45 -0
- package/src/components/chart/README.md +10 -0
- package/src/components/chart/element.ts +2 -0
- package/src/components/chart/engine.ts +50 -23
- package/src/components/chart/parts.ts +237 -0
- package/src/components/chart/react.tsx +2 -2
- package/src/components/chart/use-chart.ts +55 -0
- package/src/components/data-table/README.md +3 -3
- package/src/components/data-table/data-table.css +121 -26
- package/src/components/data-table/engine.ts +81 -29
- package/src/components/editable-table/engine.ts +67 -11
- package/src/components/filter-builder/engine.ts +33 -2
- package/src/components/filter-builder/filter-builder.css +10 -15
- package/src/components/heatmap-chart/README.md +48 -0
- package/src/components/heatmap-chart/element.ts +21 -0
- package/src/components/heatmap-chart/engine.ts +281 -0
- package/src/components/heatmap-chart/heatmap-chart.css +93 -0
- package/src/components/heatmap-chart/react.tsx +14 -0
- package/src/components/hover-card/engine.ts +30 -1
- package/src/components/hover-card/hover-card.css +8 -2
- package/src/components/image-preview/element.ts +1 -1
- package/src/components/image-preview/engine.ts +95 -15
- package/src/components/image-preview/image-preview.css +90 -2
- package/src/components/image-preview/react.tsx +3 -3
- package/src/components/json-viewer/engine.ts +11 -2
- package/src/components/json-viewer/json-viewer.css +33 -1
- package/src/components/nav/README.md +12 -10
- package/src/components/nav/element.ts +5 -5
- package/src/components/nav/engine.ts +21 -14
- package/src/components/nav/nav.css +102 -102
- package/src/components/nav/react.tsx +4 -4
- package/src/components/orbit-menu/README.md +46 -0
- package/src/components/orbit-menu/element.ts +27 -0
- package/src/components/orbit-menu/engine.ts +179 -0
- package/src/components/orbit-menu/orbit-menu.css +129 -0
- package/src/components/orbit-menu/react.tsx +44 -0
- package/src/components/pagination/README.md +1 -1
- package/src/components/pagination/engine.ts +50 -4
- package/src/components/pagination/pagination.css +10 -5
- package/src/components/pie-chart/README.md +48 -0
- package/src/components/pie-chart/element.ts +30 -0
- package/src/components/pie-chart/engine.ts +283 -0
- package/src/components/pie-chart/pie-chart.css +92 -0
- package/src/components/pie-chart/react.tsx +14 -0
- package/src/components/pill-button/README.md +46 -0
- package/src/components/pill-button/element.ts +16 -0
- package/src/components/pill-button/engine.ts +77 -0
- package/src/components/pill-button/pill-button.css +134 -0
- package/src/components/pill-button/react.tsx +32 -0
- package/src/components/radar-chart/README.md +48 -0
- package/src/components/radar-chart/element.ts +30 -0
- package/src/components/radar-chart/engine.ts +327 -0
- package/src/components/radar-chart/radar-chart.css +72 -0
- package/src/components/radar-chart/react.tsx +14 -0
- package/src/components/radial-chart/README.md +48 -0
- package/src/components/radial-chart/element.ts +30 -0
- package/src/components/radial-chart/engine.ts +290 -0
- package/src/components/radial-chart/radial-chart.css +100 -0
- package/src/components/radial-chart/react.tsx +14 -0
- package/src/components/sankey-chart/README.md +48 -0
- package/src/components/sankey-chart/element.ts +31 -0
- package/src/components/sankey-chart/engine.ts +401 -0
- package/src/components/sankey-chart/react.tsx +14 -0
- package/src/components/sankey-chart/sankey-chart.css +60 -0
- package/src/components/scroll-island/README.md +34 -0
- package/src/components/scroll-island/element.ts +16 -0
- package/src/components/scroll-island/engine.ts +252 -0
- package/src/components/scroll-island/react.tsx +26 -0
- package/src/components/scroll-island/scroll-island.css +110 -0
- package/src/components/select/README.md +34 -0
- package/src/components/select/element.ts +26 -0
- package/src/components/select/engine.ts +267 -0
- package/src/components/select/react.tsx +33 -0
- package/src/components/select/select.css +135 -0
- package/src/components/toolbar/README.md +46 -0
- package/src/components/toolbar/element.ts +30 -0
- package/src/components/toolbar/engine.ts +230 -0
- package/src/components/toolbar/react.tsx +34 -0
- package/src/components/toolbar/toolbar.css +121 -0
- package/src/components/tree-view/element.ts +1 -1
- package/src/components/tree-view/engine.ts +174 -0
- package/src/components/tree-view/react.tsx +7 -3
- package/src/components/tree-view/tree-view.css +79 -0
- package/src/components/voice-dots/README.md +48 -0
- package/src/components/voice-dots/element.ts +45 -0
- package/src/components/voice-dots/engine.ts +243 -0
- package/src/components/voice-dots/react.tsx +52 -0
- package/src/components/voice-dots/voice-dots.css +69 -0
- package/src/elements/index.ts +39 -0
- package/src/index.ts +16 -0
- package/src/motion/liquid.ts +14 -4
- package/src/react/index.ts +14 -1
- package/dist/chunk-6P4P7NU6.js +0 -1401
- package/dist/chunk-6P4P7NU6.js.map +0 -1
- package/dist/chunk-CU6SXW3E.js.map +0 -1
- package/dist/store-DjkTBX7f.d.ts +0 -195
- /package/dist/{chunk-EY4BJKC4.js.map → chunk-6IRJYXJU.js.map} +0 -0
|
@@ -213,8 +213,8 @@ function channels(start, onChange) {
|
|
|
213
213
|
gsap2.ticker.remove(tick);
|
|
214
214
|
gsap2.ticker.add(tick);
|
|
215
215
|
resolveDone?.();
|
|
216
|
-
return new Promise((
|
|
217
|
-
resolveDone =
|
|
216
|
+
return new Promise((resolve2) => {
|
|
217
|
+
resolveDone = resolve2;
|
|
218
218
|
});
|
|
219
219
|
},
|
|
220
220
|
stop() {
|
|
@@ -293,7 +293,7 @@ function requestFrame(fn) {
|
|
|
293
293
|
const id = setTimeout(() => fn(Date.now()), 16);
|
|
294
294
|
return () => clearTimeout(id);
|
|
295
295
|
}
|
|
296
|
-
var nextFrame = () => new Promise((
|
|
296
|
+
var nextFrame = () => new Promise((resolve2) => requestFrame(() => resolve2()));
|
|
297
297
|
|
|
298
298
|
// src/core/styles.ts
|
|
299
299
|
function clearStyles(targets, properties) {
|
|
@@ -525,14 +525,14 @@ function revealFrom(target, options = {}) {
|
|
|
525
525
|
paint();
|
|
526
526
|
target.append(veil);
|
|
527
527
|
let done = false;
|
|
528
|
-
let
|
|
529
|
-
const finished = new Promise((r) =>
|
|
528
|
+
let resolve2;
|
|
529
|
+
const finished = new Promise((r) => resolve2 = r);
|
|
530
530
|
const cleanup = () => {
|
|
531
531
|
if (done) return;
|
|
532
532
|
done = true;
|
|
533
533
|
veil.remove();
|
|
534
534
|
target.style.position = position2;
|
|
535
|
-
|
|
535
|
+
resolve2();
|
|
536
536
|
};
|
|
537
537
|
const [duration, fade] = TIMING.reveal[speed];
|
|
538
538
|
const timeline = gsap.timeline({ delay, onComplete: cleanup, onInterrupt: cleanup }).to(progress, { value: 100, duration, ease: "power2.out", onUpdate: paint }, 0).to(veil, { opacity: 0, duration: fade, ease: "power1.out" }, Math.max(0, duration * Math.min(1, 1 / overshoot) - 0.1));
|
|
@@ -708,14 +708,14 @@ function confetti(origin, options = {}) {
|
|
|
708
708
|
let frame = 0;
|
|
709
709
|
let last = 0;
|
|
710
710
|
let stopped = false;
|
|
711
|
-
let
|
|
712
|
-
const finished = new Promise((done) =>
|
|
711
|
+
let resolve2;
|
|
712
|
+
const finished = new Promise((done) => resolve2 = done);
|
|
713
713
|
const stop2 = () => {
|
|
714
714
|
if (stopped) return;
|
|
715
715
|
stopped = true;
|
|
716
716
|
cancelAnimationFrame(frame);
|
|
717
717
|
canvas.remove();
|
|
718
|
-
|
|
718
|
+
resolve2();
|
|
719
719
|
};
|
|
720
720
|
const draw = (now2) => {
|
|
721
721
|
const f = last ? Math.min((now2 - last) / (1e3 / 60), 3) : 1;
|
|
@@ -1376,7 +1376,7 @@ function ensureGoo() {
|
|
|
1376
1376
|
svg2.setAttribute("width", "0");
|
|
1377
1377
|
svg2.setAttribute("height", "0");
|
|
1378
1378
|
svg2.style.position = "absolute";
|
|
1379
|
-
svg2.innerHTML = `<defs><filter id="${GOO}" x="-50%" y="-50%" width="200%" height="200%"><feGaussianBlur in="SourceGraphic" stdDeviation="20"/><feColorMatrix type="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 19 -9"/></filter></defs>`;
|
|
1379
|
+
svg2.innerHTML = `<defs><filter id="${GOO}" x="-50%" y="-50%" width="200%" height="200%" color-interpolation-filters="sRGB"><feGaussianBlur in="SourceGraphic" stdDeviation="20"/><feColorMatrix type="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 19 -9"/></filter></defs>`;
|
|
1380
1380
|
document.body.append(svg2);
|
|
1381
1381
|
}
|
|
1382
1382
|
function gooLayer(surface) {
|
|
@@ -1474,7 +1474,7 @@ function liquidOpen(surface, origin, parts) {
|
|
|
1474
1474
|
}
|
|
1475
1475
|
});
|
|
1476
1476
|
const L = TIMING.liquid;
|
|
1477
|
-
|
|
1477
|
+
const settled = motion.animate(
|
|
1478
1478
|
{ top: box.top, left: box.left, width: box.width, height: box.height, radius: endRadius, scale: 1, blur: 0 },
|
|
1479
1479
|
{
|
|
1480
1480
|
top: spring(144, 14, { velocity: 2400, direction: towardY }),
|
|
@@ -1489,16 +1489,22 @@ function liquidOpen(surface, origin, parts) {
|
|
|
1489
1489
|
gsap.to(shape, { background: surfaceColor, duration: L.color, delay: L.colorDelay, ease: "power2.out" });
|
|
1490
1490
|
if (parts.length) gsap.to(parts, { opacity: 1, duration: L.color, delay: L.colorDelay, ease: "power2.out" });
|
|
1491
1491
|
gsap.to(originBlob, { opacity: 0, duration: L.ghost, delay: L.ghostDelay, ease: "power2.out" });
|
|
1492
|
+
const sharpen = setTimeout(() => {
|
|
1493
|
+
layer.style.filter = "none";
|
|
1494
|
+
originBlob.remove();
|
|
1495
|
+
}, (L.ghostDelay + L.ghost) * 1e3 + 30);
|
|
1492
1496
|
let done = false;
|
|
1493
1497
|
const finish = () => {
|
|
1494
1498
|
if (done) return;
|
|
1495
1499
|
done = true;
|
|
1496
1500
|
motion.stop();
|
|
1497
1501
|
clearTimeout(timer2);
|
|
1502
|
+
clearTimeout(sharpen);
|
|
1498
1503
|
layer.remove();
|
|
1499
1504
|
restore();
|
|
1500
1505
|
if (parts.length) gsap.set(parts, { clearProps: "opacity,transform,transformOrigin,filter" });
|
|
1501
1506
|
};
|
|
1507
|
+
void settled.then(finish);
|
|
1502
1508
|
const timer2 = setTimeout(finish, L.safetyMs);
|
|
1503
1509
|
return finish;
|
|
1504
1510
|
}
|
|
@@ -1700,7 +1706,7 @@ function textBox(element) {
|
|
|
1700
1706
|
}
|
|
1701
1707
|
var textOf = (element) => element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement ? element.value || element.placeholder : element.firstChild?.textContent ?? element.textContent ?? "";
|
|
1702
1708
|
function flyText(from, to, text, duration) {
|
|
1703
|
-
return new Promise((
|
|
1709
|
+
return new Promise((resolve2) => {
|
|
1704
1710
|
const start = textBox(from);
|
|
1705
1711
|
const end = textBox(to);
|
|
1706
1712
|
const fromSize = parseFloat(start.style.fontSize) || 16;
|
|
@@ -1742,7 +1748,7 @@ function flyText(from, to, text, duration) {
|
|
|
1742
1748
|
ease: EASE.signature,
|
|
1743
1749
|
onComplete: () => {
|
|
1744
1750
|
ghost.remove();
|
|
1745
|
-
|
|
1751
|
+
resolve2();
|
|
1746
1752
|
}
|
|
1747
1753
|
});
|
|
1748
1754
|
});
|
|
@@ -2761,6 +2767,194 @@ function createQuantity(root, options = {}) {
|
|
|
2761
2767
|
}, destroy: () => scope.dispose() };
|
|
2762
2768
|
}
|
|
2763
2769
|
|
|
2770
|
+
// src/motion/micro.ts
|
|
2771
|
+
var list2 = (targets) => !targets ? [] : targets instanceof Element ? [targets] : [...targets];
|
|
2772
|
+
var live = () => {
|
|
2773
|
+
registerMotion();
|
|
2774
|
+
return !reduced();
|
|
2775
|
+
};
|
|
2776
|
+
function press(el5) {
|
|
2777
|
+
if (!el5 || !live()) return null;
|
|
2778
|
+
gsap.killTweensOf(el5, "scaleX,scaleY");
|
|
2779
|
+
return gsap.timeline({
|
|
2780
|
+
onComplete: () => {
|
|
2781
|
+
gsap.set(el5, { clearProps: "scale,transform" });
|
|
2782
|
+
}
|
|
2783
|
+
}).to(el5, { scaleX: 0.95, scaleY: 0.9, duration: 0.1, ease: "power2.out" }).to(el5, { scaleX: 1, scaleY: 1, duration: 0.5, ease: EASE.click });
|
|
2784
|
+
}
|
|
2785
|
+
function blurIn(targets, { from = "rise", stagger = 0.05, delay = 0, duration } = {}) {
|
|
2786
|
+
const items = list2(targets);
|
|
2787
|
+
if (!items.length || !live()) return null;
|
|
2788
|
+
const start = from === "pop" ? { opacity: 0, scale: 0.7, filter: "blur(32px)" } : from === "soft" ? { opacity: 0, scale: 0.96, filter: "blur(16px)" } : { opacity: 0, y: -20, filter: "blur(16px)" };
|
|
2789
|
+
return gsap.fromTo(items, start, {
|
|
2790
|
+
opacity: 1,
|
|
2791
|
+
y: 0,
|
|
2792
|
+
scale: 1,
|
|
2793
|
+
filter: "blur(0px)",
|
|
2794
|
+
duration: duration ?? (from === "pop" ? 0.3 : 0.5),
|
|
2795
|
+
ease: from === "pop" ? EASE.pop : "power2.out",
|
|
2796
|
+
stagger,
|
|
2797
|
+
delay,
|
|
2798
|
+
clearProps: "opacity,transform,filter"
|
|
2799
|
+
});
|
|
2800
|
+
}
|
|
2801
|
+
function blurOut(targets, { to = "up", onComplete } = {}) {
|
|
2802
|
+
const items = list2(targets);
|
|
2803
|
+
if (!items.length) return null;
|
|
2804
|
+
if (!live()) {
|
|
2805
|
+
onComplete?.();
|
|
2806
|
+
return null;
|
|
2807
|
+
}
|
|
2808
|
+
const end = to === "left" ? { x: -64 } : to === "down" ? { y: 24 } : { y: -20 };
|
|
2809
|
+
return gsap.to(items, { ...end, opacity: 0, filter: "blur(16px)", duration: 0.5, ease: "power2.out", onComplete });
|
|
2810
|
+
}
|
|
2811
|
+
function collapse(el5, { onComplete } = {}) {
|
|
2812
|
+
if (!el5) return null;
|
|
2813
|
+
if (!live()) {
|
|
2814
|
+
onComplete?.();
|
|
2815
|
+
return null;
|
|
2816
|
+
}
|
|
2817
|
+
return gsap.to(el5, {
|
|
2818
|
+
height: 0,
|
|
2819
|
+
paddingTop: 0,
|
|
2820
|
+
paddingBottom: 0,
|
|
2821
|
+
marginTop: 0,
|
|
2822
|
+
marginBottom: 0,
|
|
2823
|
+
opacity: 0,
|
|
2824
|
+
filter: "blur(16px)",
|
|
2825
|
+
overflow: "hidden",
|
|
2826
|
+
duration: 0.25,
|
|
2827
|
+
ease: "power2.in",
|
|
2828
|
+
onComplete
|
|
2829
|
+
});
|
|
2830
|
+
}
|
|
2831
|
+
function shake(el5, distance = 4) {
|
|
2832
|
+
if (!el5 || !live()) return null;
|
|
2833
|
+
gsap.killTweensOf(el5, "x");
|
|
2834
|
+
return gsap.to(el5, {
|
|
2835
|
+
keyframes: { x: [0, -distance, distance, -distance, 0] },
|
|
2836
|
+
duration: 0.5,
|
|
2837
|
+
ease: EASE.shake,
|
|
2838
|
+
clearProps: "x,transform"
|
|
2839
|
+
});
|
|
2840
|
+
}
|
|
2841
|
+
function ringPulse(el5, color = "var(--mk-accent-soft)") {
|
|
2842
|
+
if (!el5 || !live()) return null;
|
|
2843
|
+
const before = { color: el5.style.outlineColor, style: el5.style.outlineStyle, offset: el5.style.outlineOffset };
|
|
2844
|
+
el5.style.outlineColor = color;
|
|
2845
|
+
el5.style.outlineStyle = "solid";
|
|
2846
|
+
el5.style.outlineOffset = "-4px";
|
|
2847
|
+
const restore = () => {
|
|
2848
|
+
el5.style.outlineColor = before.color;
|
|
2849
|
+
el5.style.outlineStyle = before.style;
|
|
2850
|
+
el5.style.outlineOffset = before.offset;
|
|
2851
|
+
el5.style.removeProperty("outline-width");
|
|
2852
|
+
if (el5.getAttribute("style") === "") el5.removeAttribute("style");
|
|
2853
|
+
};
|
|
2854
|
+
return gsap.fromTo(el5, { outlineWidth: 0 }, { keyframes: { outlineWidth: [0, 4, 0] }, duration: 1, ease: "power1.inOut", onComplete: restore, onInterrupt: restore });
|
|
2855
|
+
}
|
|
2856
|
+
function burst(origin, { count = 7, distance = 28, colors = ["var(--mk-accent)"], ring = true, size = 6 } = {}) {
|
|
2857
|
+
if (!origin || !live()) return null;
|
|
2858
|
+
const layer = document.createElement("span");
|
|
2859
|
+
layer.setAttribute("aria-hidden", "true");
|
|
2860
|
+
layer.dataset.mkBurst = "";
|
|
2861
|
+
Object.assign(layer.style, { position: "absolute", inset: "0", pointerEvents: "none", overflow: "visible", display: "grid", placeItems: "center" });
|
|
2862
|
+
const positioned = getComputedStyle(origin).position !== "static";
|
|
2863
|
+
const previousPosition = origin.style.position;
|
|
2864
|
+
if (!positioned) origin.style.position = "relative";
|
|
2865
|
+
origin.append(layer);
|
|
2866
|
+
const cleanup = () => {
|
|
2867
|
+
layer.remove();
|
|
2868
|
+
if (!positioned) origin.style.position = previousPosition;
|
|
2869
|
+
if (origin.getAttribute("style") === "") origin.removeAttribute("style");
|
|
2870
|
+
};
|
|
2871
|
+
const timeline = gsap.timeline({ onComplete: cleanup, onInterrupt: cleanup });
|
|
2872
|
+
if (ring) {
|
|
2873
|
+
const circle = document.createElement("span");
|
|
2874
|
+
Object.assign(circle.style, { position: "absolute", width: "100%", aspectRatio: "1", borderRadius: "50%", border: `2px solid ${colors[0]}` });
|
|
2875
|
+
layer.append(circle);
|
|
2876
|
+
timeline.fromTo(circle, { scale: 0.3, opacity: 0.9 }, { scale: 1.6, opacity: 0, duration: 0.5, ease: "power2.out" }, 0);
|
|
2877
|
+
}
|
|
2878
|
+
for (let i = 0; i < count; i++) {
|
|
2879
|
+
const angle2 = i / count * Math.PI * 2 - Math.PI / 2;
|
|
2880
|
+
for (const [k, scale] of [[0, 1], [1, 0.6]]) {
|
|
2881
|
+
const dot = document.createElement("span");
|
|
2882
|
+
Object.assign(dot.style, {
|
|
2883
|
+
position: "absolute",
|
|
2884
|
+
width: `${size * scale}px`,
|
|
2885
|
+
height: `${size * scale}px`,
|
|
2886
|
+
borderRadius: "50%",
|
|
2887
|
+
background: colors[(i + k) % colors.length]
|
|
2888
|
+
});
|
|
2889
|
+
layer.append(dot);
|
|
2890
|
+
const reach = distance * (k ? 0.72 : 1);
|
|
2891
|
+
const turn = k ? 0.32 : 0;
|
|
2892
|
+
timeline.fromTo(
|
|
2893
|
+
dot,
|
|
2894
|
+
{ x: 0, y: 0, scale: 0, opacity: 1 },
|
|
2895
|
+
{ x: Math.cos(angle2 + turn) * reach, y: Math.sin(angle2 + turn) * reach, scale: 1, duration: 0.45, ease: "power3.out" },
|
|
2896
|
+
0.05
|
|
2897
|
+
);
|
|
2898
|
+
timeline.to(dot, { scale: 0, opacity: 0, duration: 0.3, ease: "power2.in" }, 0.38);
|
|
2899
|
+
}
|
|
2900
|
+
}
|
|
2901
|
+
return timeline;
|
|
2902
|
+
}
|
|
2903
|
+
var rolling = /* @__PURE__ */ new WeakMap();
|
|
2904
|
+
function rollDigits(el5, text, direction = 1, duration = 0.5) {
|
|
2905
|
+
if (!el5) return null;
|
|
2906
|
+
rolling.get(el5)?.progress(1).kill();
|
|
2907
|
+
rolling.delete(el5);
|
|
2908
|
+
const previous = el5.textContent ?? "";
|
|
2909
|
+
if (previous === text || !live()) {
|
|
2910
|
+
el5.textContent = text;
|
|
2911
|
+
return null;
|
|
2912
|
+
}
|
|
2913
|
+
const width = Math.max(previous.length, text.length);
|
|
2914
|
+
const oldChars = previous.padStart(width, " ");
|
|
2915
|
+
const newChars = text.padStart(width, " ");
|
|
2916
|
+
el5.textContent = "";
|
|
2917
|
+
const label = document.createElement("span");
|
|
2918
|
+
label.className = "mk-sr-only";
|
|
2919
|
+
label.textContent = text;
|
|
2920
|
+
const visual = document.createElement("span");
|
|
2921
|
+
visual.setAttribute("aria-hidden", "true");
|
|
2922
|
+
visual.style.display = "inline-flex";
|
|
2923
|
+
const moving = [];
|
|
2924
|
+
const padding = Math.min(width - previous.length, width - text.length);
|
|
2925
|
+
for (let i = padding; i < width; i++) {
|
|
2926
|
+
const before = oldChars[i];
|
|
2927
|
+
const after = newChars[i];
|
|
2928
|
+
const cell = document.createElement("span");
|
|
2929
|
+
Object.assign(cell.style, { position: "relative", display: "inline-block", overflow: "hidden", whiteSpace: "pre" });
|
|
2930
|
+
const next = document.createElement("span");
|
|
2931
|
+
next.style.display = "inline-block";
|
|
2932
|
+
next.textContent = after;
|
|
2933
|
+
cell.append(next);
|
|
2934
|
+
if (before !== after) {
|
|
2935
|
+
const old = document.createElement("span");
|
|
2936
|
+
Object.assign(old.style, { position: "absolute", left: "0", top: "0", display: "inline-block" });
|
|
2937
|
+
old.textContent = before;
|
|
2938
|
+
cell.append(old);
|
|
2939
|
+
moving.push([old, next]);
|
|
2940
|
+
}
|
|
2941
|
+
visual.append(cell);
|
|
2942
|
+
}
|
|
2943
|
+
el5.append(label, visual);
|
|
2944
|
+
const timeline = gsap.timeline({
|
|
2945
|
+
onComplete: () => {
|
|
2946
|
+
el5.textContent = text;
|
|
2947
|
+
rolling.delete(el5);
|
|
2948
|
+
}
|
|
2949
|
+
});
|
|
2950
|
+
moving.forEach(([old, next], i) => {
|
|
2951
|
+
timeline.to(old, { yPercent: -100 * direction, opacity: 0, filter: "blur(4px)", duration, ease: EASE.signature }, i * 0.03);
|
|
2952
|
+
timeline.fromTo(next, { yPercent: 100 * direction, opacity: 0, filter: "blur(4px)" }, { yPercent: 0, opacity: 1, filter: "blur(0px)", duration, ease: EASE.signature }, i * 0.03);
|
|
2953
|
+
});
|
|
2954
|
+
rolling.set(el5, timeline);
|
|
2955
|
+
return timeline;
|
|
2956
|
+
}
|
|
2957
|
+
|
|
2764
2958
|
// src/components/pagination/engine.ts
|
|
2765
2959
|
var positive = (n, fallback) => Number.isFinite(n) ? Math.max(1, Math.min(Number.MAX_SAFE_INTEGER - 32, Math.floor(n))) : fallback;
|
|
2766
2960
|
function createPagination(root, options = {}) {
|
|
@@ -2768,16 +2962,33 @@ function createPagination(root, options = {}) {
|
|
|
2768
2962
|
if (!root || !pages) return inert({ setPage() {
|
|
2769
2963
|
}, setTotalPages() {
|
|
2770
2964
|
}, page: 1, totalPages: 1 });
|
|
2965
|
+
registerMotion();
|
|
2771
2966
|
const scope = createScope();
|
|
2772
2967
|
const original = [...pages.childNodes];
|
|
2968
|
+
const indicator = document.createElement("span");
|
|
2969
|
+
indicator.dataset.mkPaginationIndicator = "";
|
|
2970
|
+
indicator.setAttribute("aria-hidden", "true");
|
|
2971
|
+
const effects = /* @__PURE__ */ new Set();
|
|
2972
|
+
const keep = (animation) => {
|
|
2973
|
+
if (!animation) return;
|
|
2974
|
+
effects.add(animation);
|
|
2975
|
+
for (const effect of effects) if (effect.totalProgress() === 1) effects.delete(effect);
|
|
2976
|
+
};
|
|
2977
|
+
scope.add(() => {
|
|
2978
|
+
for (const effect of effects) effect.kill();
|
|
2979
|
+
effects.clear();
|
|
2980
|
+
});
|
|
2981
|
+
let placed = false;
|
|
2773
2982
|
const previous = root.querySelector("[data-mk-pagination-previous]");
|
|
2774
2983
|
const next = root.querySelector("[data-mk-pagination-next]");
|
|
2775
2984
|
let total = positive(options.totalPages, 10);
|
|
2776
2985
|
let page = Math.min(total, positive(options.page, 1));
|
|
2777
2986
|
const siblings = Math.min(10, Math.max(0, Number.isFinite(options.siblings) ? Math.floor(options.siblings) : 1));
|
|
2778
2987
|
scope.attr(root, "data-mk-ready", "");
|
|
2779
|
-
|
|
2988
|
+
scope.attr(root, "data-mk-glide", "");
|
|
2989
|
+
const render = (animate = false) => {
|
|
2780
2990
|
const hadFocus = pages.contains(document.activeElement);
|
|
2991
|
+
const before = new Map([...pages.querySelectorAll("[data-mk-page]")].map((button2) => [button2.dataset.mkPage, button2.offsetLeft]));
|
|
2781
2992
|
const selected = /* @__PURE__ */ new Set([1, total]);
|
|
2782
2993
|
for (let n = Math.max(1, page - siblings); n <= Math.min(total, page + siblings); n++) selected.add(n);
|
|
2783
2994
|
const fragment = document.createDocumentFragment();
|
|
@@ -2799,8 +3010,23 @@ function createPagination(root, options = {}) {
|
|
|
2799
3010
|
fragment.append(button2);
|
|
2800
3011
|
last = n;
|
|
2801
3012
|
}
|
|
2802
|
-
pages.replaceChildren(fragment);
|
|
3013
|
+
pages.replaceChildren(indicator, fragment);
|
|
2803
3014
|
if (hadFocus) pages.querySelector("[aria-current]")?.focus();
|
|
3015
|
+
const motion = animate && !reduced();
|
|
3016
|
+
if (motion) {
|
|
3017
|
+
for (const button2 of pages.querySelectorAll("[data-mk-page]")) {
|
|
3018
|
+
const from = before.get(button2.dataset.mkPage);
|
|
3019
|
+
if (from === void 0) keep(gsap.fromTo(button2, { opacity: 0, scale: 0.6, filter: "blur(4px)" }, { opacity: 1, scale: 1, filter: "blur(0px)", duration: 0.3, ease: EASE.pop, clearProps: "opacity,transform,filter" }));
|
|
3020
|
+
else if (from !== button2.offsetLeft) keep(gsap.fromTo(button2, { x: from - button2.offsetLeft }, { x: 0, duration: 0.35, ease: EASE.swatch, clearProps: "transform" }));
|
|
3021
|
+
}
|
|
3022
|
+
}
|
|
3023
|
+
const current3 = pages.querySelector("[aria-current]");
|
|
3024
|
+
if (current3) {
|
|
3025
|
+
const box = { x: current3.offsetLeft, width: current3.offsetWidth, height: current3.offsetHeight };
|
|
3026
|
+
if (motion && placed) keep(gsap.to(indicator, { ...box, duration: 0.4, ease: EASE.swatch }));
|
|
3027
|
+
else gsap.set(indicator, box);
|
|
3028
|
+
placed = true;
|
|
3029
|
+
}
|
|
2804
3030
|
if (previous) scope.attr(previous, "disabled", page === 1 ? "" : null);
|
|
2805
3031
|
if (next) scope.attr(next, "disabled", page === total ? "" : null);
|
|
2806
3032
|
};
|
|
@@ -2810,7 +3036,7 @@ function createPagination(root, options = {}) {
|
|
|
2810
3036
|
if (candidate === page) return;
|
|
2811
3037
|
const focused = pages.contains(document.activeElement);
|
|
2812
3038
|
page = candidate;
|
|
2813
|
-
render();
|
|
3039
|
+
render(true);
|
|
2814
3040
|
if (focused) pages.querySelector("[aria-current]")?.focus();
|
|
2815
3041
|
if (notify) {
|
|
2816
3042
|
options.onChange?.(page);
|
|
@@ -2820,6 +3046,8 @@ function createPagination(root, options = {}) {
|
|
|
2820
3046
|
scope.on(root, "click", (event) => {
|
|
2821
3047
|
const target = event.target.closest("button");
|
|
2822
3048
|
if (!target || target.disabled) return;
|
|
3049
|
+
if (!reduced()) keep(press(target));
|
|
3050
|
+
if ((target === previous || target === next) && !reduced()) keep(gsap.fromTo(target, { x: target === next ? 4 : -4 }, { x: 0, duration: 0.45, ease: EASE.click, clearProps: "x" }));
|
|
2823
3051
|
if (target === previous) setPage(page - 1);
|
|
2824
3052
|
else if (target === next) setPage(page + 1);
|
|
2825
3053
|
else if (target.dataset.mkPage) setPage(Number(target.dataset.mkPage));
|
|
@@ -2856,6 +3084,7 @@ function createPagination(root, options = {}) {
|
|
|
2856
3084
|
var sequence = 0;
|
|
2857
3085
|
var EDGE2 = 12;
|
|
2858
3086
|
var GAP2 = 12;
|
|
3087
|
+
var FOLD_MS = 400;
|
|
2859
3088
|
function createHoverCard(root, options = {}) {
|
|
2860
3089
|
const trigger = root?.querySelector("[data-mk-hover-trigger]");
|
|
2861
3090
|
const panel = root?.querySelector("[data-mk-hover-panel]");
|
|
@@ -2901,6 +3130,8 @@ function createHoverCard(root, options = {}) {
|
|
|
2901
3130
|
if (left + box.width > view.width - EDGE2) shift = view.width - EDGE2 - box.width - left;
|
|
2902
3131
|
if (left + shift < EDGE2) shift = EDGE2 - left;
|
|
2903
3132
|
if (shift) root.style.setProperty("--mk-hover-shift", `${Math.round(shift)}px`);
|
|
3133
|
+
const target = trigger.getBoundingClientRect();
|
|
3134
|
+
root.style.setProperty("--mk-hover-origin-x", `${Math.round(target.left + target.width / 2 - (left + shift))}px`);
|
|
2904
3135
|
};
|
|
2905
3136
|
let pending = null;
|
|
2906
3137
|
const schedulePlace = () => {
|
|
@@ -2915,13 +3146,33 @@ function createHoverCard(root, options = {}) {
|
|
|
2915
3146
|
clearTimeout(timer2);
|
|
2916
3147
|
timer2 = void 0;
|
|
2917
3148
|
};
|
|
3149
|
+
let folding;
|
|
3150
|
+
const settleFold = () => {
|
|
3151
|
+
clearTimeout(folding);
|
|
3152
|
+
folding = void 0;
|
|
3153
|
+
panel.removeEventListener("animationend", settleFold);
|
|
3154
|
+
if (scope.disposed) return;
|
|
3155
|
+
scope.attr(root, "data-mk-closing", null);
|
|
3156
|
+
if (!opened) scope.attr(panel, "hidden", "");
|
|
3157
|
+
};
|
|
3158
|
+
scope.add(() => {
|
|
3159
|
+
clearTimeout(folding);
|
|
3160
|
+
panel.removeEventListener("animationend", settleFold);
|
|
3161
|
+
});
|
|
2918
3162
|
const set = (value) => {
|
|
2919
3163
|
cancel();
|
|
2920
3164
|
if (scope.disposed) return;
|
|
2921
3165
|
const changed = value !== opened;
|
|
2922
3166
|
opened = value;
|
|
2923
3167
|
scope.attr(trigger, "aria-expanded", String(value));
|
|
2924
|
-
|
|
3168
|
+
if (value) {
|
|
3169
|
+
if (folding !== void 0) settleFold();
|
|
3170
|
+
scope.attr(panel, "hidden", null);
|
|
3171
|
+
} else if (changed && !reduced() && root.dataset.mkInput !== "keyboard" && !panel.hidden) {
|
|
3172
|
+
scope.attr(root, "data-mk-closing", "");
|
|
3173
|
+
panel.addEventListener("animationend", settleFold);
|
|
3174
|
+
folding = setTimeout(settleFold, FOLD_MS);
|
|
3175
|
+
} else if (folding === void 0) scope.attr(panel, "hidden", "");
|
|
2925
3176
|
scope.attr(root, "data-mk-open", value ? "" : null);
|
|
2926
3177
|
if (value && changed) {
|
|
2927
3178
|
scope.attr(root, "data-mk-input", pointerInput ? "pointer" : "keyboard");
|
|
@@ -4174,7 +4425,7 @@ function createSlotPicker(root, options = {}) {
|
|
|
4174
4425
|
ctx.add(() => flowIn(fresh, { target: ".mk-slot-picker__time", style: 2, startScale: 0.7, blur: 32, duration: 0.3, stagger: 0.02, ease: "mk-slot-in" }));
|
|
4175
4426
|
}
|
|
4176
4427
|
};
|
|
4177
|
-
const
|
|
4428
|
+
const resolve2 = (d) => {
|
|
4178
4429
|
const source = slots;
|
|
4179
4430
|
if (Array.isArray(source)) return source;
|
|
4180
4431
|
if (typeof source === "function") return source(d);
|
|
@@ -4190,7 +4441,7 @@ function createSlotPicker(root, options = {}) {
|
|
|
4190
4441
|
const mine = ++request;
|
|
4191
4442
|
let result;
|
|
4192
4443
|
try {
|
|
4193
|
-
result =
|
|
4444
|
+
result = resolve2(date);
|
|
4194
4445
|
} catch {
|
|
4195
4446
|
result = [];
|
|
4196
4447
|
}
|
|
@@ -4341,194 +4592,6 @@ function createSlotPicker(root, options = {}) {
|
|
|
4341
4592
|
};
|
|
4342
4593
|
}
|
|
4343
4594
|
|
|
4344
|
-
// src/motion/micro.ts
|
|
4345
|
-
var list2 = (targets) => !targets ? [] : targets instanceof Element ? [targets] : [...targets];
|
|
4346
|
-
var live = () => {
|
|
4347
|
-
registerMotion();
|
|
4348
|
-
return !reduced();
|
|
4349
|
-
};
|
|
4350
|
-
function press(el5) {
|
|
4351
|
-
if (!el5 || !live()) return null;
|
|
4352
|
-
gsap.killTweensOf(el5, "scaleX,scaleY");
|
|
4353
|
-
return gsap.timeline({
|
|
4354
|
-
onComplete: () => {
|
|
4355
|
-
gsap.set(el5, { clearProps: "scale,transform" });
|
|
4356
|
-
}
|
|
4357
|
-
}).to(el5, { scaleX: 0.95, scaleY: 0.9, duration: 0.1, ease: "power2.out" }).to(el5, { scaleX: 1, scaleY: 1, duration: 0.5, ease: EASE.click });
|
|
4358
|
-
}
|
|
4359
|
-
function blurIn(targets, { from = "rise", stagger = 0.05, delay = 0, duration } = {}) {
|
|
4360
|
-
const items = list2(targets);
|
|
4361
|
-
if (!items.length || !live()) return null;
|
|
4362
|
-
const start = from === "pop" ? { opacity: 0, scale: 0.7, filter: "blur(32px)" } : from === "soft" ? { opacity: 0, scale: 0.96, filter: "blur(16px)" } : { opacity: 0, y: -20, filter: "blur(16px)" };
|
|
4363
|
-
return gsap.fromTo(items, start, {
|
|
4364
|
-
opacity: 1,
|
|
4365
|
-
y: 0,
|
|
4366
|
-
scale: 1,
|
|
4367
|
-
filter: "blur(0px)",
|
|
4368
|
-
duration: duration ?? (from === "pop" ? 0.3 : 0.5),
|
|
4369
|
-
ease: from === "pop" ? EASE.pop : "power2.out",
|
|
4370
|
-
stagger,
|
|
4371
|
-
delay,
|
|
4372
|
-
clearProps: "opacity,transform,filter"
|
|
4373
|
-
});
|
|
4374
|
-
}
|
|
4375
|
-
function blurOut(targets, { to = "up", onComplete } = {}) {
|
|
4376
|
-
const items = list2(targets);
|
|
4377
|
-
if (!items.length) return null;
|
|
4378
|
-
if (!live()) {
|
|
4379
|
-
onComplete?.();
|
|
4380
|
-
return null;
|
|
4381
|
-
}
|
|
4382
|
-
const end = to === "left" ? { x: -64 } : to === "down" ? { y: 24 } : { y: -20 };
|
|
4383
|
-
return gsap.to(items, { ...end, opacity: 0, filter: "blur(16px)", duration: 0.5, ease: "power2.out", onComplete });
|
|
4384
|
-
}
|
|
4385
|
-
function collapse(el5, { onComplete } = {}) {
|
|
4386
|
-
if (!el5) return null;
|
|
4387
|
-
if (!live()) {
|
|
4388
|
-
onComplete?.();
|
|
4389
|
-
return null;
|
|
4390
|
-
}
|
|
4391
|
-
return gsap.to(el5, {
|
|
4392
|
-
height: 0,
|
|
4393
|
-
paddingTop: 0,
|
|
4394
|
-
paddingBottom: 0,
|
|
4395
|
-
marginTop: 0,
|
|
4396
|
-
marginBottom: 0,
|
|
4397
|
-
opacity: 0,
|
|
4398
|
-
filter: "blur(16px)",
|
|
4399
|
-
overflow: "hidden",
|
|
4400
|
-
duration: 0.25,
|
|
4401
|
-
ease: "power2.in",
|
|
4402
|
-
onComplete
|
|
4403
|
-
});
|
|
4404
|
-
}
|
|
4405
|
-
function shake(el5, distance = 4) {
|
|
4406
|
-
if (!el5 || !live()) return null;
|
|
4407
|
-
gsap.killTweensOf(el5, "x");
|
|
4408
|
-
return gsap.to(el5, {
|
|
4409
|
-
keyframes: { x: [0, -distance, distance, -distance, 0] },
|
|
4410
|
-
duration: 0.5,
|
|
4411
|
-
ease: EASE.shake,
|
|
4412
|
-
clearProps: "x,transform"
|
|
4413
|
-
});
|
|
4414
|
-
}
|
|
4415
|
-
function ringPulse(el5, color = "var(--mk-accent-soft)") {
|
|
4416
|
-
if (!el5 || !live()) return null;
|
|
4417
|
-
const before = { color: el5.style.outlineColor, style: el5.style.outlineStyle, offset: el5.style.outlineOffset };
|
|
4418
|
-
el5.style.outlineColor = color;
|
|
4419
|
-
el5.style.outlineStyle = "solid";
|
|
4420
|
-
el5.style.outlineOffset = "-4px";
|
|
4421
|
-
const restore = () => {
|
|
4422
|
-
el5.style.outlineColor = before.color;
|
|
4423
|
-
el5.style.outlineStyle = before.style;
|
|
4424
|
-
el5.style.outlineOffset = before.offset;
|
|
4425
|
-
el5.style.removeProperty("outline-width");
|
|
4426
|
-
if (el5.getAttribute("style") === "") el5.removeAttribute("style");
|
|
4427
|
-
};
|
|
4428
|
-
return gsap.fromTo(el5, { outlineWidth: 0 }, { keyframes: { outlineWidth: [0, 4, 0] }, duration: 1, ease: "power1.inOut", onComplete: restore, onInterrupt: restore });
|
|
4429
|
-
}
|
|
4430
|
-
function burst(origin, { count = 7, distance = 28, colors = ["var(--mk-accent)"], ring = true, size = 6 } = {}) {
|
|
4431
|
-
if (!origin || !live()) return null;
|
|
4432
|
-
const layer = document.createElement("span");
|
|
4433
|
-
layer.setAttribute("aria-hidden", "true");
|
|
4434
|
-
layer.dataset.mkBurst = "";
|
|
4435
|
-
Object.assign(layer.style, { position: "absolute", inset: "0", pointerEvents: "none", overflow: "visible", display: "grid", placeItems: "center" });
|
|
4436
|
-
const positioned = getComputedStyle(origin).position !== "static";
|
|
4437
|
-
const previousPosition = origin.style.position;
|
|
4438
|
-
if (!positioned) origin.style.position = "relative";
|
|
4439
|
-
origin.append(layer);
|
|
4440
|
-
const cleanup = () => {
|
|
4441
|
-
layer.remove();
|
|
4442
|
-
if (!positioned) origin.style.position = previousPosition;
|
|
4443
|
-
if (origin.getAttribute("style") === "") origin.removeAttribute("style");
|
|
4444
|
-
};
|
|
4445
|
-
const timeline = gsap.timeline({ onComplete: cleanup, onInterrupt: cleanup });
|
|
4446
|
-
if (ring) {
|
|
4447
|
-
const circle = document.createElement("span");
|
|
4448
|
-
Object.assign(circle.style, { position: "absolute", width: "100%", aspectRatio: "1", borderRadius: "50%", border: `2px solid ${colors[0]}` });
|
|
4449
|
-
layer.append(circle);
|
|
4450
|
-
timeline.fromTo(circle, { scale: 0.3, opacity: 0.9 }, { scale: 1.6, opacity: 0, duration: 0.5, ease: "power2.out" }, 0);
|
|
4451
|
-
}
|
|
4452
|
-
for (let i = 0; i < count; i++) {
|
|
4453
|
-
const angle2 = i / count * Math.PI * 2 - Math.PI / 2;
|
|
4454
|
-
for (const [k, scale] of [[0, 1], [1, 0.6]]) {
|
|
4455
|
-
const dot = document.createElement("span");
|
|
4456
|
-
Object.assign(dot.style, {
|
|
4457
|
-
position: "absolute",
|
|
4458
|
-
width: `${size * scale}px`,
|
|
4459
|
-
height: `${size * scale}px`,
|
|
4460
|
-
borderRadius: "50%",
|
|
4461
|
-
background: colors[(i + k) % colors.length]
|
|
4462
|
-
});
|
|
4463
|
-
layer.append(dot);
|
|
4464
|
-
const reach = distance * (k ? 0.72 : 1);
|
|
4465
|
-
const turn = k ? 0.32 : 0;
|
|
4466
|
-
timeline.fromTo(
|
|
4467
|
-
dot,
|
|
4468
|
-
{ x: 0, y: 0, scale: 0, opacity: 1 },
|
|
4469
|
-
{ x: Math.cos(angle2 + turn) * reach, y: Math.sin(angle2 + turn) * reach, scale: 1, duration: 0.45, ease: "power3.out" },
|
|
4470
|
-
0.05
|
|
4471
|
-
);
|
|
4472
|
-
timeline.to(dot, { scale: 0, opacity: 0, duration: 0.3, ease: "power2.in" }, 0.38);
|
|
4473
|
-
}
|
|
4474
|
-
}
|
|
4475
|
-
return timeline;
|
|
4476
|
-
}
|
|
4477
|
-
var rolling = /* @__PURE__ */ new WeakMap();
|
|
4478
|
-
function rollDigits(el5, text, direction = 1, duration = 0.5) {
|
|
4479
|
-
if (!el5) return null;
|
|
4480
|
-
rolling.get(el5)?.progress(1).kill();
|
|
4481
|
-
rolling.delete(el5);
|
|
4482
|
-
const previous = el5.textContent ?? "";
|
|
4483
|
-
if (previous === text || !live()) {
|
|
4484
|
-
el5.textContent = text;
|
|
4485
|
-
return null;
|
|
4486
|
-
}
|
|
4487
|
-
const width = Math.max(previous.length, text.length);
|
|
4488
|
-
const oldChars = previous.padStart(width, " ");
|
|
4489
|
-
const newChars = text.padStart(width, " ");
|
|
4490
|
-
el5.textContent = "";
|
|
4491
|
-
const label = document.createElement("span");
|
|
4492
|
-
label.className = "mk-sr-only";
|
|
4493
|
-
label.textContent = text;
|
|
4494
|
-
const visual = document.createElement("span");
|
|
4495
|
-
visual.setAttribute("aria-hidden", "true");
|
|
4496
|
-
visual.style.display = "inline-flex";
|
|
4497
|
-
const moving = [];
|
|
4498
|
-
const padding = Math.min(width - previous.length, width - text.length);
|
|
4499
|
-
for (let i = padding; i < width; i++) {
|
|
4500
|
-
const before = oldChars[i];
|
|
4501
|
-
const after = newChars[i];
|
|
4502
|
-
const cell = document.createElement("span");
|
|
4503
|
-
Object.assign(cell.style, { position: "relative", display: "inline-block", overflow: "hidden", whiteSpace: "pre" });
|
|
4504
|
-
const next = document.createElement("span");
|
|
4505
|
-
next.style.display = "inline-block";
|
|
4506
|
-
next.textContent = after;
|
|
4507
|
-
cell.append(next);
|
|
4508
|
-
if (before !== after) {
|
|
4509
|
-
const old = document.createElement("span");
|
|
4510
|
-
Object.assign(old.style, { position: "absolute", left: "0", top: "0", display: "inline-block" });
|
|
4511
|
-
old.textContent = before;
|
|
4512
|
-
cell.append(old);
|
|
4513
|
-
moving.push([old, next]);
|
|
4514
|
-
}
|
|
4515
|
-
visual.append(cell);
|
|
4516
|
-
}
|
|
4517
|
-
el5.append(label, visual);
|
|
4518
|
-
const timeline = gsap.timeline({
|
|
4519
|
-
onComplete: () => {
|
|
4520
|
-
el5.textContent = text;
|
|
4521
|
-
rolling.delete(el5);
|
|
4522
|
-
}
|
|
4523
|
-
});
|
|
4524
|
-
moving.forEach(([old, next], i) => {
|
|
4525
|
-
timeline.to(old, { yPercent: -100 * direction, opacity: 0, filter: "blur(4px)", duration, ease: EASE.signature }, i * 0.03);
|
|
4526
|
-
timeline.fromTo(next, { yPercent: 100 * direction, opacity: 0, filter: "blur(4px)" }, { yPercent: 0, opacity: 1, filter: "blur(0px)", duration, ease: EASE.signature }, i * 0.03);
|
|
4527
|
-
});
|
|
4528
|
-
rolling.set(el5, timeline);
|
|
4529
|
-
return timeline;
|
|
4530
|
-
}
|
|
4531
|
-
|
|
4532
4595
|
// src/components/attachment/engine.ts
|
|
4533
4596
|
var DEFAULT_LABELS2 = {
|
|
4534
4597
|
choose: "Elige archivos",
|
|
@@ -6244,7 +6307,9 @@ function modelOf(options) {
|
|
|
6244
6307
|
name: String(series2.name ?? ""),
|
|
6245
6308
|
values: Array.from({ length: count }, (_, j) => finite3(series2.values[j]) ? series2.values[j] : null),
|
|
6246
6309
|
color: series2.color ?? (mono ? "var(--mk-chart-mono)" : i < SLOTS ? `var(--mk-chart-${i + 1})` : "var(--mk-chart-other)"),
|
|
6247
|
-
dash: series2.dash
|
|
6310
|
+
dash: series2.dash,
|
|
6311
|
+
type: series2.type,
|
|
6312
|
+
lowerValues: series2.lowerValues ? Array.from({ length: count }, (_, j) => finite3(series2.lowerValues[j]) ? series2.lowerValues[j] : null) : void 0
|
|
6248
6313
|
}));
|
|
6249
6314
|
return { labels: fullLabels, series };
|
|
6250
6315
|
}
|
|
@@ -6312,7 +6377,9 @@ function createChart(root, initial = {}) {
|
|
|
6312
6377
|
if (options.formatValue) return options.formatValue(value);
|
|
6313
6378
|
return new Intl.NumberFormat(void 0, { maximumFractionDigits: 2 }).format(value);
|
|
6314
6379
|
};
|
|
6315
|
-
const type = () => options.type === "bar" || options.type === "area" ? options.type : "line";
|
|
6380
|
+
const type = () => options.type === "bar" || options.type === "area" || options.type === "composed" ? options.type : "line";
|
|
6381
|
+
const seriesType = (index) => type() === "composed" ? model.series[index].type ?? "line" : type();
|
|
6382
|
+
const hasBars = () => model.series.some((_, index) => seriesType(index) === "bar");
|
|
6316
6383
|
const stacked = () => type() === "bar" && Boolean(options.stacked) && model.series.length > 1;
|
|
6317
6384
|
const hasData = () => model.labels.length > 0 && model.series.some((series) => series.values.some(finite3));
|
|
6318
6385
|
const totalsOf = (values, index) => {
|
|
@@ -6327,6 +6394,13 @@ function createChart(root, initial = {}) {
|
|
|
6327
6394
|
return { up, down };
|
|
6328
6395
|
};
|
|
6329
6396
|
const targetValues = () => model.series.map((series) => series.values);
|
|
6397
|
+
const lowerValues = () => model.series.map((series) => series.lowerValues ?? []);
|
|
6398
|
+
const rangeText = (series, index) => {
|
|
6399
|
+
const value = series.values[index];
|
|
6400
|
+
const lower = series.lowerValues?.[index];
|
|
6401
|
+
if (!finite3(value)) return "\u2014";
|
|
6402
|
+
return finite3(lower) ? `${format(lower)} \u2013 ${format(value)}` : format(value);
|
|
6403
|
+
};
|
|
6330
6404
|
const totals = (index) => totalsOf(targetValues(), index);
|
|
6331
6405
|
const domainOf = (values) => {
|
|
6332
6406
|
let lo = 0;
|
|
@@ -6344,6 +6418,12 @@ function createChart(root, initial = {}) {
|
|
|
6344
6418
|
lo = Math.min(lo, value);
|
|
6345
6419
|
}
|
|
6346
6420
|
}
|
|
6421
|
+
for (const list3 of lowerValues()) {
|
|
6422
|
+
if (finite3(list3[i])) {
|
|
6423
|
+
lo = Math.min(lo, list3[i]);
|
|
6424
|
+
hi = Math.max(hi, list3[i]);
|
|
6425
|
+
}
|
|
6426
|
+
}
|
|
6347
6427
|
});
|
|
6348
6428
|
if (hi === lo) hi = lo + 1;
|
|
6349
6429
|
const step = niceStep((hi - lo) / 4);
|
|
@@ -6389,7 +6469,7 @@ function createChart(root, initial = {}) {
|
|
|
6389
6469
|
for (const series of model.series) {
|
|
6390
6470
|
const td = document.createElement("td");
|
|
6391
6471
|
const value = series.values[i];
|
|
6392
|
-
td.textContent =
|
|
6472
|
+
td.textContent = rangeText(series, i);
|
|
6393
6473
|
row.append(td);
|
|
6394
6474
|
}
|
|
6395
6475
|
if (stacked()) {
|
|
@@ -6407,11 +6487,11 @@ function createChart(root, initial = {}) {
|
|
|
6407
6487
|
const show = options.legend ?? model.series.length > 1;
|
|
6408
6488
|
legend.hidden = !show || !hasData();
|
|
6409
6489
|
if (legend.hidden) return;
|
|
6410
|
-
for (const series of model.series) {
|
|
6490
|
+
for (const [index, series] of model.series.entries()) {
|
|
6411
6491
|
const item = document.createElement("li");
|
|
6412
6492
|
const swatch = document.createElement("span");
|
|
6413
6493
|
swatch.dataset.mkChartSwatch = "";
|
|
6414
|
-
swatch.dataset.mkType =
|
|
6494
|
+
swatch.dataset.mkType = seriesType(index);
|
|
6415
6495
|
swatch.style.background = series.color;
|
|
6416
6496
|
swatch.style.color = series.color;
|
|
6417
6497
|
if (series.dash) swatch.dataset.mkDash = "";
|
|
@@ -6427,19 +6507,19 @@ function createChart(root, initial = {}) {
|
|
|
6427
6507
|
for (let i = list3.length - 1; i >= 0; i--) if (finite3(list3[i])) return i;
|
|
6428
6508
|
return -1;
|
|
6429
6509
|
};
|
|
6430
|
-
const paint = (values, lo, hi, step) => {
|
|
6510
|
+
const paint = (values, lo, hi, step, lower = lowerValues()) => {
|
|
6431
6511
|
canvas.replaceChildren();
|
|
6432
6512
|
const width = Math.max(120, Math.round(plot.clientWidth || root.clientWidth || 600));
|
|
6433
6513
|
const height = Math.max(80, Math.round(finite3(options.height) ? options.height : 240));
|
|
6434
6514
|
canvas.setAttribute("viewBox", `0 0 ${width} ${height}`);
|
|
6435
6515
|
canvas.setAttribute("width", String(width));
|
|
6436
6516
|
canvas.setAttribute("height", String(height));
|
|
6437
|
-
const bar =
|
|
6517
|
+
const bar = hasBars();
|
|
6438
6518
|
const axis = Boolean(options.axis);
|
|
6439
6519
|
const ticks = [];
|
|
6440
6520
|
for (let t = lo; t <= hi + step / 2; t += step) ticks.push(Number(t.toPrecision(12)));
|
|
6441
6521
|
const tickText = ticks.map(format);
|
|
6442
|
-
const withEnd =
|
|
6522
|
+
const withEnd = seriesType(0) !== "bar" && options.endLabel !== false && lastPoint(values[0]) >= 0;
|
|
6443
6523
|
const left = axis ? Math.min(96, Math.max(28, Math.max(...tickText.map((text) => text.length)) * 7 + 12)) : 4;
|
|
6444
6524
|
const top = 16;
|
|
6445
6525
|
const right = withEnd ? Math.min(120, Math.max(48, format(values[0][lastPoint(values[0])]).length * 7.5 + 28)) : 8;
|
|
@@ -6488,7 +6568,8 @@ function createChart(root, initial = {}) {
|
|
|
6488
6568
|
const marks = svg("g", { "data-mk-part": "series" });
|
|
6489
6569
|
const defs = svg("defs");
|
|
6490
6570
|
if (bar) {
|
|
6491
|
-
const
|
|
6571
|
+
const barIndices = model.series.flatMap((_, index) => seriesType(index) === "bar" ? [index] : []);
|
|
6572
|
+
const groups = stacked() ? 1 : barIndices.length;
|
|
6492
6573
|
const barWidth = Math.max(2, Math.min(BAR_MAX, (slot * 0.62 - GAP3 * (groups - 1)) / groups));
|
|
6493
6574
|
const totalsLayer = svg("g", { "data-mk-part": "totals" });
|
|
6494
6575
|
model.labels.forEach((_, i) => {
|
|
@@ -6524,9 +6605,10 @@ function createChart(root, initial = {}) {
|
|
|
6524
6605
|
} else {
|
|
6525
6606
|
const groupWidth = groups * barWidth + GAP3 * (groups - 1);
|
|
6526
6607
|
values.forEach((list3, k) => {
|
|
6608
|
+
if (seriesType(k) !== "bar") return;
|
|
6527
6609
|
const value = list3[i];
|
|
6528
6610
|
if (!finite3(value) || value === 0) return;
|
|
6529
|
-
const x = xs[i] - groupWidth / 2 + k * (barWidth + GAP3);
|
|
6611
|
+
const x = xs[i] - groupWidth / 2 + barIndices.indexOf(k) * (barWidth + GAP3);
|
|
6530
6612
|
const path = svg("path", { d: barPath(x, barWidth, base, y(value), true), "data-mk-index": i, "data-mk-series": k });
|
|
6531
6613
|
path.style.fill = model.series[k].color;
|
|
6532
6614
|
marks.append(path);
|
|
@@ -6534,20 +6616,23 @@ function createChart(root, initial = {}) {
|
|
|
6534
6616
|
}
|
|
6535
6617
|
});
|
|
6536
6618
|
if (totalsLayer.childNodes.length) canvas.append(totalsLayer);
|
|
6537
|
-
}
|
|
6619
|
+
}
|
|
6620
|
+
if (model.series.some((_, index) => seriesType(index) !== "bar")) {
|
|
6538
6621
|
values.forEach((list3, k) => {
|
|
6622
|
+
if (seriesType(k) === "bar") return;
|
|
6539
6623
|
const series = model.series[k];
|
|
6540
6624
|
const runs2 = [];
|
|
6541
6625
|
let run = [];
|
|
6542
6626
|
list3.forEach((value, i) => {
|
|
6543
|
-
|
|
6627
|
+
const bottomValue = lower[k]?.[i];
|
|
6628
|
+
if (finite3(value) && (!series.lowerValues || finite3(bottomValue))) run.push([xs[i], y(value), finite3(bottomValue) ? y(bottomValue) : base]);
|
|
6544
6629
|
else if (run.length) {
|
|
6545
6630
|
runs2.push(run);
|
|
6546
6631
|
run = [];
|
|
6547
6632
|
}
|
|
6548
6633
|
});
|
|
6549
6634
|
if (run.length) runs2.push(run);
|
|
6550
|
-
if (
|
|
6635
|
+
if (seriesType(k) === "area") {
|
|
6551
6636
|
const gradient = svg("linearGradient", { id: `${uid2}-fill-${k}`, x1: 0, x2: 0, y1: 0, y2: 1 });
|
|
6552
6637
|
const stop2 = (offset, opacity) => {
|
|
6553
6638
|
const element = svg("stop", { offset });
|
|
@@ -6559,8 +6644,8 @@ function createChart(root, initial = {}) {
|
|
|
6559
6644
|
defs.append(gradient);
|
|
6560
6645
|
for (const points of runs2) {
|
|
6561
6646
|
if (points.length < 2) continue;
|
|
6562
|
-
const d = `M${points.map(([px, py]) => `${round(px)},${round(py)}`).join("L")}L${
|
|
6563
|
-
const area = svg("path", { d, "data-mk-part": "area" });
|
|
6647
|
+
const d = `M${points.map(([px, py]) => `${round(px)},${round(py)}`).join("L")}L${[...points].reverse().map(([px, , py]) => `${round(px)},${round(py)}`).join("L")}Z`;
|
|
6648
|
+
const area = svg("path", { d, "data-mk-part": "area", "data-mk-series": k });
|
|
6564
6649
|
area.style.fill = `url(#${uid2}-fill-${k})`;
|
|
6565
6650
|
marks.append(area);
|
|
6566
6651
|
}
|
|
@@ -6581,7 +6666,7 @@ function createChart(root, initial = {}) {
|
|
|
6581
6666
|
}
|
|
6582
6667
|
});
|
|
6583
6668
|
const last2 = lastPoint(values[0]);
|
|
6584
|
-
if (last2 >= 0 && !model.series[0].dash) {
|
|
6669
|
+
if (last2 >= 0 && seriesType(0) !== "bar" && !model.series[0].dash) {
|
|
6585
6670
|
const point = svg("circle", { cx: round(xs[last2]), cy: round(y(values[0][last2])), r: 5, "data-mk-part": "end" });
|
|
6586
6671
|
point.style.fill = model.series[0].color;
|
|
6587
6672
|
marks.append(point);
|
|
@@ -6661,10 +6746,10 @@ function createChart(root, initial = {}) {
|
|
|
6661
6746
|
const name = document.createElement("span");
|
|
6662
6747
|
name.textContent = series.name;
|
|
6663
6748
|
const amount = document.createElement("b");
|
|
6664
|
-
amount.textContent =
|
|
6749
|
+
amount.textContent = rangeText(series, i);
|
|
6665
6750
|
row.append(swatch, name, amount);
|
|
6666
6751
|
tooltip.append(row);
|
|
6667
|
-
rows.push(`${series.name ? `${series.name}: ` : ""}${finite3(value) ?
|
|
6752
|
+
rows.push(`${series.name ? `${series.name}: ` : ""}${finite3(value) ? rangeText(series, i) : "sin dato"}`);
|
|
6668
6753
|
}
|
|
6669
6754
|
if (stacked()) {
|
|
6670
6755
|
const { up, down } = totals(i);
|
|
@@ -6732,7 +6817,7 @@ function createChart(root, initial = {}) {
|
|
|
6732
6817
|
const target = targetValues();
|
|
6733
6818
|
const domain = domainOf(target);
|
|
6734
6819
|
const finish = () => {
|
|
6735
|
-
shown4 = { values: target, lo: domain.lo, hi: domain.hi, type: type(), stacked: stacked() };
|
|
6820
|
+
shown4 = { values: target, lower: lowerValues(), lo: domain.lo, hi: domain.hi, type: type(), stacked: stacked() };
|
|
6736
6821
|
paint(target, domain.lo, domain.hi, domain.step);
|
|
6737
6822
|
paintSelection(false);
|
|
6738
6823
|
};
|
|
@@ -6751,7 +6836,11 @@ function createChart(root, initial = {}) {
|
|
|
6751
6836
|
const before = from.values[k][i];
|
|
6752
6837
|
return finite3(value) && finite3(before) ? before + (value - before) * t : value;
|
|
6753
6838
|
}));
|
|
6754
|
-
|
|
6839
|
+
const lower = lowerValues().map((list3, k) => list3.map((value, i) => {
|
|
6840
|
+
const before = from.lower[k]?.[i];
|
|
6841
|
+
return finite3(value) && finite3(before) ? before + (value - before) * t : value;
|
|
6842
|
+
}));
|
|
6843
|
+
paint(values, from.lo + (domain.lo - from.lo) * t, from.hi + (domain.hi - from.hi) * t, domain.step, lower);
|
|
6755
6844
|
paintSelection(false);
|
|
6756
6845
|
},
|
|
6757
6846
|
onComplete: () => {
|
|
@@ -7775,7 +7864,7 @@ function createImagePreview(root, options = {}) {
|
|
|
7775
7864
|
registerMotion();
|
|
7776
7865
|
const scope = createScope();
|
|
7777
7866
|
const loop = options.loop ?? true;
|
|
7778
|
-
const labels = { close: "Cerrar", prev: "Imagen anterior", next: "Imagen siguiente", dialog: "Vista de imagen", ...options.labels };
|
|
7867
|
+
const labels = { close: "Cerrar", prev: "Imagen anterior", next: "Imagen siguiente", dialog: "Vista de imagen", strip: "Miniaturas", picture: "Imagen", ...options.labels };
|
|
7779
7868
|
const pictures = () => [...root.querySelectorAll("[data-mk-image]")].map((thumb) => {
|
|
7780
7869
|
const img = thumb.matches("img") ? thumb : thumb.querySelector("img");
|
|
7781
7870
|
return {
|
|
@@ -7804,7 +7893,15 @@ function createImagePreview(root, options = {}) {
|
|
|
7804
7893
|
const counter = document.createElement("span");
|
|
7805
7894
|
counter.dataset.mkLightbox = "count";
|
|
7806
7895
|
counter.setAttribute("aria-live", "polite");
|
|
7807
|
-
|
|
7896
|
+
const strip = document.createElement("div");
|
|
7897
|
+
strip.dataset.mkLightbox = "strip";
|
|
7898
|
+
strip.setAttribute("role", "group");
|
|
7899
|
+
strip.setAttribute("aria-label", labels.strip);
|
|
7900
|
+
strip.hidden = true;
|
|
7901
|
+
const ring = document.createElement("span");
|
|
7902
|
+
ring.dataset.mkLightboxRing = "";
|
|
7903
|
+
ring.setAttribute("aria-hidden", "true");
|
|
7904
|
+
dialog.append(backdrop, stage, prev, next, close, counter, strip);
|
|
7808
7905
|
root.append(dialog);
|
|
7809
7906
|
scope.add(() => dialog.remove());
|
|
7810
7907
|
scope.attr(root, "data-mk-ready", "");
|
|
@@ -7844,6 +7941,42 @@ function createImagePreview(root, options = {}) {
|
|
|
7844
7941
|
next.disabled = !loop && i === list3.length - 1;
|
|
7845
7942
|
prev.hidden = next.hidden = list3.length < 2;
|
|
7846
7943
|
};
|
|
7944
|
+
let ringShown = false;
|
|
7945
|
+
const buildStrip = () => {
|
|
7946
|
+
const show = options.strip !== false && list3.length > 1;
|
|
7947
|
+
strip.hidden = !show;
|
|
7948
|
+
dialog.toggleAttribute("data-mk-strip", show);
|
|
7949
|
+
ringShown = false;
|
|
7950
|
+
if (!show) return strip.replaceChildren();
|
|
7951
|
+
strip.replaceChildren(
|
|
7952
|
+
ring,
|
|
7953
|
+
...list3.map((picture, i) => {
|
|
7954
|
+
const thumb = document.createElement("button");
|
|
7955
|
+
thumb.type = "button";
|
|
7956
|
+
thumb.dataset.mkLightboxThumb = String(i);
|
|
7957
|
+
thumb.setAttribute("aria-label", `${labels.picture} ${i + 1} de ${list3.length}`);
|
|
7958
|
+
const small = thumbImg(picture);
|
|
7959
|
+
const img = document.createElement("img");
|
|
7960
|
+
img.src = (small instanceof HTMLImageElement ? small.getAttribute("src") || small.currentSrc : "") || picture.src;
|
|
7961
|
+
img.alt = "";
|
|
7962
|
+
img.draggable = false;
|
|
7963
|
+
thumb.append(img);
|
|
7964
|
+
return thumb;
|
|
7965
|
+
})
|
|
7966
|
+
);
|
|
7967
|
+
};
|
|
7968
|
+
const paintStrip = () => {
|
|
7969
|
+
if (strip.hidden) return;
|
|
7970
|
+
const thumbs = [...strip.querySelectorAll("[data-mk-lightbox-thumb]")];
|
|
7971
|
+
thumbs.forEach((thumb, i) => i === index ? thumb.setAttribute("aria-current", "true") : thumb.removeAttribute("aria-current"));
|
|
7972
|
+
const active = thumbs[index];
|
|
7973
|
+
if (!active) return;
|
|
7974
|
+
const box = { x: active.offsetLeft, y: active.offsetTop, width: active.offsetWidth, height: active.offsetHeight };
|
|
7975
|
+
if (!ringShown || reduced()) gsap.set(ring, box);
|
|
7976
|
+
else keep(gsap.to(ring, { ...box, duration: 0.35, ease: EASE.swatch }));
|
|
7977
|
+
ringShown = true;
|
|
7978
|
+
if (typeof strip.scrollTo === "function") strip.scrollTo({ left: active.offsetLeft + active.offsetWidth / 2 - strip.clientWidth / 2, behavior: reduced() ? "auto" : "smooth" });
|
|
7979
|
+
};
|
|
7847
7980
|
const fromThumb = (picture) => {
|
|
7848
7981
|
const small = thumbImg(picture).getBoundingClientRect();
|
|
7849
7982
|
const big = image.getBoundingClientRect();
|
|
@@ -7871,16 +8004,18 @@ function createImagePreview(root, options = {}) {
|
|
|
7871
8004
|
isOpen = true;
|
|
7872
8005
|
index = target;
|
|
7873
8006
|
counter.textContent = "";
|
|
8007
|
+
buildStrip();
|
|
7874
8008
|
write(target);
|
|
7875
8009
|
if (typeof dialog.showModal === "function") dialog.showModal();
|
|
7876
8010
|
else dialog.setAttribute("open", "");
|
|
8011
|
+
paintStrip();
|
|
7877
8012
|
close.focus({ preventScroll: true });
|
|
7878
8013
|
const picture = list3[target];
|
|
7879
8014
|
options.onOpenChange?.(true);
|
|
7880
8015
|
root.dispatchEvent(new CustomEvent("mk:open", { bubbles: true, detail: { index } }));
|
|
7881
8016
|
if (reduced()) return;
|
|
7882
8017
|
keep(gsap.fromTo(backdrop, { opacity: 0 }, { opacity: 1, duration: 0.4, ease: "power2.out", clearProps: "opacity" }));
|
|
7883
|
-
keep(gsap.fromTo([prev, next, close, counter, caption], { opacity: 0 }, { opacity: 1, duration: 0.3, delay: 0.3, clearProps: "opacity" }));
|
|
8018
|
+
keep(gsap.fromTo([prev, next, close, counter, caption, strip], { opacity: 0 }, { opacity: 1, duration: 0.3, delay: 0.3, clearProps: "opacity" }));
|
|
7884
8019
|
const grow = () => {
|
|
7885
8020
|
const start = fromThumb(picture);
|
|
7886
8021
|
if (!start) return void keep(gsap.fromTo(image, { opacity: 0, scale: 0.92 }, { opacity: 1, scale: 1, duration: 0.35, ease: EASE.pop, clearProps: "opacity,scale,transform" }));
|
|
@@ -7912,11 +8047,11 @@ function createImagePreview(root, options = {}) {
|
|
|
7912
8047
|
gsap.set(image, { scale: 1, x: 0, y: 0 });
|
|
7913
8048
|
const end = fromThumb(picture);
|
|
7914
8049
|
keep(gsap.to(backdrop, { opacity: 0, duration: 0.35, ease: "power2.in" }));
|
|
7915
|
-
keep(gsap.to([prev, next, close, counter, caption], { opacity: 0, duration: 0.15 }));
|
|
8050
|
+
keep(gsap.to([prev, next, close, counter, caption, strip], { opacity: 0, duration: 0.15 }));
|
|
7916
8051
|
if (!end) return void keep(gsap.to(image, { opacity: 0, scale: 0.92, duration: 0.25, ease: "power2.in", onComplete: finish }));
|
|
7917
8052
|
thumbImg(picture).style.visibility = "hidden";
|
|
7918
8053
|
keep(gsap.to(image, { ...end, duration: 0.5, ease: EASE.signature, onComplete: () => {
|
|
7919
|
-
gsap.set([prev, next, close, counter, caption], { clearProps: "opacity" });
|
|
8054
|
+
gsap.set([prev, next, close, counter, caption, strip], { clearProps: "opacity" });
|
|
7920
8055
|
finish();
|
|
7921
8056
|
} }));
|
|
7922
8057
|
};
|
|
@@ -7932,12 +8067,41 @@ function createImagePreview(root, options = {}) {
|
|
|
7932
8067
|
index = target;
|
|
7933
8068
|
options.onChange?.(index);
|
|
7934
8069
|
root.dispatchEvent(new CustomEvent("mk:change", { bubbles: true, detail: { index, previous: before } }));
|
|
7935
|
-
if (reduced())
|
|
8070
|
+
if (reduced()) {
|
|
8071
|
+
write(target);
|
|
8072
|
+
paintStrip();
|
|
8073
|
+
return;
|
|
8074
|
+
}
|
|
7936
8075
|
gsap.killTweensOf(image);
|
|
7937
|
-
|
|
7938
|
-
|
|
7939
|
-
|
|
8076
|
+
ghost?.remove();
|
|
8077
|
+
const leaving = image.cloneNode();
|
|
8078
|
+
leaving.dataset.mkLightbox = "ghost";
|
|
8079
|
+
leaving.alt = "";
|
|
8080
|
+
leaving.setAttribute("aria-hidden", "true");
|
|
8081
|
+
Object.assign(leaving.style, { position: "absolute", left: `${image.offsetLeft}px`, top: `${image.offsetTop}px`, width: `${image.offsetWidth}px`, height: `${image.offsetHeight}px`, margin: "0" });
|
|
8082
|
+
stage.append(leaving);
|
|
8083
|
+
ghost = leaving;
|
|
8084
|
+
write(target);
|
|
8085
|
+
paintStrip();
|
|
8086
|
+
gsap.set(image, { opacity: 0, x: 0, y: 0 });
|
|
8087
|
+
keep(gsap.to(leaving, { xPercent: -28 * direction, scale: 0.86, opacity: 0, filter: "blur(10px)", duration: 0.45, ease: EASE.signature, onComplete: () => {
|
|
8088
|
+
leaving.remove();
|
|
8089
|
+
if (ghost === leaving) ghost = null;
|
|
8090
|
+
} }));
|
|
8091
|
+
const enter = () => {
|
|
8092
|
+
if (!isOpen || index !== target) return;
|
|
8093
|
+
keep(gsap.fromTo(image, { xPercent: 24 * direction, scale: 1.04, opacity: 0, filter: "blur(10px)" }, { xPercent: 0, scale: 1, opacity: 1, filter: "blur(0px)", duration: 0.5, ease: EASE.signature, clearProps: "transform,opacity,filter" }));
|
|
8094
|
+
};
|
|
8095
|
+
const decoded = typeof image.decode === "function" ? image.decode().catch(() => void 0) : Promise.resolve();
|
|
8096
|
+
if (image.complete && image.naturalWidth) enter();
|
|
8097
|
+
else void Promise.race([decoded, new Promise((done) => setTimeout(done, 250))]).then(enter);
|
|
7940
8098
|
}
|
|
8099
|
+
let ghost = null;
|
|
8100
|
+
scope.add(() => ghost?.remove());
|
|
8101
|
+
scope.on(strip, "click", (event) => {
|
|
8102
|
+
const thumb = event.target?.closest("[data-mk-lightbox-thumb]");
|
|
8103
|
+
if (thumb) go(Number(thumb.dataset.mkLightboxThumb));
|
|
8104
|
+
});
|
|
7941
8105
|
scope.on(root, "click", (event) => {
|
|
7942
8106
|
const thumb = event.target?.closest("[data-mk-image]");
|
|
7943
8107
|
if (!thumb || !root.contains(thumb) || dialog.contains(thumb)) return;
|
|
@@ -11710,7 +11874,7 @@ function createBreadcrumb(root, options = {}) {
|
|
|
11710
11874
|
list3.replaceChildren(...nodes);
|
|
11711
11875
|
nav.toggleAttribute("data-mk-expanded", expanded);
|
|
11712
11876
|
};
|
|
11713
|
-
const
|
|
11877
|
+
const fold7 = (keepEnd) => {
|
|
11714
11878
|
const end = Math.max(1, items.length - keepEnd);
|
|
11715
11879
|
return Array.from({ length: Math.max(0, end - 1) }, (_, i) => i + 1);
|
|
11716
11880
|
};
|
|
@@ -11722,7 +11886,7 @@ function createBreadcrumb(root, options = {}) {
|
|
|
11722
11886
|
return;
|
|
11723
11887
|
}
|
|
11724
11888
|
if (maxItems !== "auto") {
|
|
11725
|
-
hidden = items.length > maxItems ?
|
|
11889
|
+
hidden = items.length > maxItems ? fold7(maxItems - 1) : [];
|
|
11726
11890
|
render();
|
|
11727
11891
|
return;
|
|
11728
11892
|
}
|
|
@@ -11730,7 +11894,7 @@ function createBreadcrumb(root, options = {}) {
|
|
|
11730
11894
|
hidden = [];
|
|
11731
11895
|
render();
|
|
11732
11896
|
for (let keepEnd = items.length - 2; keepEnd >= 1 && !fits(); keepEnd--) {
|
|
11733
|
-
hidden =
|
|
11897
|
+
hidden = fold7(keepEnd);
|
|
11734
11898
|
render();
|
|
11735
11899
|
}
|
|
11736
11900
|
nav.removeAttribute("data-mk-measuring");
|
|
@@ -13838,6 +14002,210 @@ function describeFilter(filter, fields, nested = false) {
|
|
|
13838
14002
|
}
|
|
13839
14003
|
var cloneFilter = (filter) => JSON.parse(JSON.stringify(filter));
|
|
13840
14004
|
|
|
14005
|
+
// src/components/select/engine.ts
|
|
14006
|
+
var CHEVRON2 = '<svg aria-hidden="true" data-mk-select-chevron width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M7 10l5 5 5-5"/></svg>';
|
|
14007
|
+
var CHECK4 = '<svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg>';
|
|
14008
|
+
var fold4 = (text) => text.normalize("NFD").replace(/[̀-ͯ]/g, "").toLocaleLowerCase();
|
|
14009
|
+
function fillSelect(select, list3) {
|
|
14010
|
+
const groups = /* @__PURE__ */ new Map();
|
|
14011
|
+
const nodes = [];
|
|
14012
|
+
for (const choice of list3) {
|
|
14013
|
+
const option = new Option(choice.label, choice.value);
|
|
14014
|
+
option.disabled = Boolean(choice.disabled);
|
|
14015
|
+
if (!choice.group) {
|
|
14016
|
+
nodes.push(option);
|
|
14017
|
+
continue;
|
|
14018
|
+
}
|
|
14019
|
+
let group = groups.get(choice.group);
|
|
14020
|
+
if (!group) {
|
|
14021
|
+
group = document.createElement("optgroup");
|
|
14022
|
+
group.label = choice.group;
|
|
14023
|
+
groups.set(choice.group, group);
|
|
14024
|
+
nodes.push(group);
|
|
14025
|
+
}
|
|
14026
|
+
group.append(option);
|
|
14027
|
+
}
|
|
14028
|
+
select.replaceChildren(...nodes);
|
|
14029
|
+
}
|
|
14030
|
+
function createSelect(root, options = {}) {
|
|
14031
|
+
if (!root) return inert({ setValue() {
|
|
14032
|
+
}, setOptions() {
|
|
14033
|
+
}, refresh() {
|
|
14034
|
+
}, open() {
|
|
14035
|
+
}, close() {
|
|
14036
|
+
}, value: "" });
|
|
14037
|
+
registerMotion();
|
|
14038
|
+
const scope = createScope();
|
|
14039
|
+
const made = [];
|
|
14040
|
+
scope.add(() => made.forEach((element) => element.remove()));
|
|
14041
|
+
let native = root.querySelector("select:not([multiple])");
|
|
14042
|
+
if (!native) {
|
|
14043
|
+
native = document.createElement("select");
|
|
14044
|
+
if (options.name) native.name = options.name;
|
|
14045
|
+
root.append(native);
|
|
14046
|
+
made.push(native);
|
|
14047
|
+
} else {
|
|
14048
|
+
const select2 = native;
|
|
14049
|
+
const children = [...select2.childNodes];
|
|
14050
|
+
const value = select2.value;
|
|
14051
|
+
scope.add(() => {
|
|
14052
|
+
if (select2.childNodes.length !== children.length || children.some((node, i) => select2.childNodes[i] !== node)) select2.replaceChildren(...children);
|
|
14053
|
+
select2.value = value;
|
|
14054
|
+
});
|
|
14055
|
+
}
|
|
14056
|
+
const select = native;
|
|
14057
|
+
if (options.options) fillSelect(select, options.options);
|
|
14058
|
+
if (options.value !== void 0) select.value = options.value;
|
|
14059
|
+
scope.attr(select, "hidden", "");
|
|
14060
|
+
scope.attr(select, "tabindex", "-1");
|
|
14061
|
+
scope.attr(select, "aria-hidden", "true");
|
|
14062
|
+
const trigger = document.createElement("button");
|
|
14063
|
+
trigger.type = "button";
|
|
14064
|
+
trigger.dataset.mkSelectTrigger = "";
|
|
14065
|
+
trigger.setAttribute("aria-haspopup", "menu");
|
|
14066
|
+
trigger.setAttribute("aria-expanded", "false");
|
|
14067
|
+
const valueText = document.createElement("span");
|
|
14068
|
+
valueText.dataset.mkSelectValue = "";
|
|
14069
|
+
trigger.append(valueText);
|
|
14070
|
+
trigger.insertAdjacentHTML("beforeend", CHEVRON2);
|
|
14071
|
+
select.after(trigger);
|
|
14072
|
+
made.push(trigger);
|
|
14073
|
+
const dialog = document.createElement("dialog");
|
|
14074
|
+
dialog.className = "mk-dialog mk-menu mk-select-menu";
|
|
14075
|
+
dialog.dataset.mkSelectMenu = "";
|
|
14076
|
+
dialog.setAttribute("aria-label", options.label ?? "Opciones");
|
|
14077
|
+
root.append(dialog);
|
|
14078
|
+
made.push(dialog);
|
|
14079
|
+
scope.attr(root, "data-mk-ready", "");
|
|
14080
|
+
const effects = /* @__PURE__ */ new Set();
|
|
14081
|
+
const keep = (animation) => {
|
|
14082
|
+
if (!animation) return;
|
|
14083
|
+
effects.add(animation);
|
|
14084
|
+
for (const effect of effects) if (effect.totalProgress() === 1) effects.delete(effect);
|
|
14085
|
+
};
|
|
14086
|
+
scope.add(() => {
|
|
14087
|
+
for (const effect of effects) effect.kill();
|
|
14088
|
+
effects.clear();
|
|
14089
|
+
});
|
|
14090
|
+
const choices = () => [...select.options];
|
|
14091
|
+
const buildItems = () => {
|
|
14092
|
+
const nodes = [];
|
|
14093
|
+
const item = (option) => {
|
|
14094
|
+
const button2 = document.createElement("button");
|
|
14095
|
+
button2.type = "button";
|
|
14096
|
+
button2.dataset.mkItem = "";
|
|
14097
|
+
button2.dataset.mkValue = option.value;
|
|
14098
|
+
const text = document.createElement("span");
|
|
14099
|
+
text.textContent = option.text;
|
|
14100
|
+
button2.append(text);
|
|
14101
|
+
button2.insertAdjacentHTML("beforeend", CHECK4);
|
|
14102
|
+
if (option.disabled) button2.setAttribute("aria-disabled", "true");
|
|
14103
|
+
return button2;
|
|
14104
|
+
};
|
|
14105
|
+
for (const child of select.children) {
|
|
14106
|
+
if (child instanceof HTMLOptGroupElement) {
|
|
14107
|
+
const heading = document.createElement("p");
|
|
14108
|
+
heading.dataset.mkSelectGroup = "";
|
|
14109
|
+
heading.setAttribute("aria-hidden", "true");
|
|
14110
|
+
heading.textContent = child.label;
|
|
14111
|
+
nodes.push(heading, ...[...child.children].filter((node) => node instanceof HTMLOptionElement).map(item));
|
|
14112
|
+
} else if (child instanceof HTMLOptionElement) nodes.push(item(child));
|
|
14113
|
+
}
|
|
14114
|
+
dialog.replaceChildren(...nodes);
|
|
14115
|
+
};
|
|
14116
|
+
const placeholderText = () => options.placeholder ?? choices().find((option) => option.value === "")?.text ?? "Elige\u2026";
|
|
14117
|
+
const markItems = () => {
|
|
14118
|
+
for (const item of dialog.querySelectorAll("[data-mk-item]")) {
|
|
14119
|
+
item.setAttribute("role", "menuitemradio");
|
|
14120
|
+
item.setAttribute("aria-checked", String(item.dataset.mkValue === select.value));
|
|
14121
|
+
}
|
|
14122
|
+
};
|
|
14123
|
+
const paint = () => {
|
|
14124
|
+
const chosen = select.selectedOptions[0];
|
|
14125
|
+
const empty = !chosen || chosen.value === "";
|
|
14126
|
+
valueText.textContent = empty ? placeholderText() : chosen.text;
|
|
14127
|
+
root.toggleAttribute("data-mk-placeholder", empty);
|
|
14128
|
+
if (options.label) trigger.setAttribute("aria-label", `${options.label}: ${valueText.textContent}`);
|
|
14129
|
+
trigger.disabled = Boolean(options.disabled) || select.disabled;
|
|
14130
|
+
markItems();
|
|
14131
|
+
};
|
|
14132
|
+
scope.add(() => root.removeAttribute("data-mk-placeholder"));
|
|
14133
|
+
const choose = (value, notify) => {
|
|
14134
|
+
if (value === select.value) return;
|
|
14135
|
+
const before = choices().findIndex((option) => option.value === select.value);
|
|
14136
|
+
select.value = value;
|
|
14137
|
+
if (select.value !== value) return;
|
|
14138
|
+
const after = choices().findIndex((option) => option.value === value);
|
|
14139
|
+
paint();
|
|
14140
|
+
if (!reduced()) {
|
|
14141
|
+
gsap.killTweensOf(valueText);
|
|
14142
|
+
keep(gsap.fromTo(valueText, { y: after >= before ? 6 : -6, opacity: 0, filter: "blur(4px)" }, { y: 0, opacity: 1, filter: "blur(0px)", duration: 0.28, ease: EASE.pop, clearProps: "transform,opacity,filter" }));
|
|
14143
|
+
}
|
|
14144
|
+
if (!notify) return;
|
|
14145
|
+
select.dispatchEvent(new Event("input", { bubbles: true }));
|
|
14146
|
+
select.dispatchEvent(new Event("change", { bubbles: true }));
|
|
14147
|
+
options.onChange?.(value);
|
|
14148
|
+
root.dispatchEvent(new CustomEvent("mk:change", { bubbles: true, detail: { value } }));
|
|
14149
|
+
};
|
|
14150
|
+
const menu = createMenu(dialog, {
|
|
14151
|
+
triggers: false,
|
|
14152
|
+
onOpen: markItems,
|
|
14153
|
+
onClose: () => trigger.setAttribute("aria-expanded", "false"),
|
|
14154
|
+
onSelect: (value) => choose(value, true)
|
|
14155
|
+
});
|
|
14156
|
+
scope.add(() => menu.destroy());
|
|
14157
|
+
scope.on(dialog, "mk:select", (event) => event.stopPropagation());
|
|
14158
|
+
const open = () => {
|
|
14159
|
+
if (trigger.disabled || menu.isOpen) return;
|
|
14160
|
+
trigger.setAttribute("aria-expanded", "true");
|
|
14161
|
+
dialog.style.setProperty("--mk-select-width", `${trigger.offsetWidth}px`);
|
|
14162
|
+
menu.open(trigger);
|
|
14163
|
+
};
|
|
14164
|
+
scope.on(trigger, "click", () => {
|
|
14165
|
+
if (!reduced()) keep(press(trigger));
|
|
14166
|
+
open();
|
|
14167
|
+
});
|
|
14168
|
+
scope.on(trigger, "keydown", (event) => {
|
|
14169
|
+
const key2 = event;
|
|
14170
|
+
if (key2.ctrlKey || key2.metaKey || key2.altKey) return;
|
|
14171
|
+
if (["ArrowDown", "ArrowUp", "Enter", " "].includes(key2.key)) {
|
|
14172
|
+
key2.preventDefault();
|
|
14173
|
+
open();
|
|
14174
|
+
} else if (key2.key.length === 1 && key2.key.trim()) {
|
|
14175
|
+
const letter = fold4(key2.key);
|
|
14176
|
+
const list3 = choices();
|
|
14177
|
+
const from = list3.findIndex((option) => option.value === select.value);
|
|
14178
|
+
for (let step = 1; step <= list3.length; step++) {
|
|
14179
|
+
const option = list3[(from + step) % list3.length];
|
|
14180
|
+
if (!option.disabled && option.value !== "" && fold4(option.text).startsWith(letter)) {
|
|
14181
|
+
choose(option.value, true);
|
|
14182
|
+
break;
|
|
14183
|
+
}
|
|
14184
|
+
}
|
|
14185
|
+
}
|
|
14186
|
+
});
|
|
14187
|
+
const refresh = () => {
|
|
14188
|
+
buildItems();
|
|
14189
|
+
paint();
|
|
14190
|
+
};
|
|
14191
|
+
if (typeof MutationObserver === "function") scope.observe(new MutationObserver(() => !scope.disposed && refresh())).observe(select, { childList: true, subtree: true, attributes: true, attributeFilter: ["disabled", "label"] });
|
|
14192
|
+
refresh();
|
|
14193
|
+
return {
|
|
14194
|
+
setValue: (value, notify = true) => choose(value, notify),
|
|
14195
|
+
setOptions(next) {
|
|
14196
|
+
fillSelect(select, next);
|
|
14197
|
+
refresh();
|
|
14198
|
+
},
|
|
14199
|
+
refresh,
|
|
14200
|
+
open,
|
|
14201
|
+
close: () => menu.close(),
|
|
14202
|
+
get value() {
|
|
14203
|
+
return select.value;
|
|
14204
|
+
},
|
|
14205
|
+
destroy: () => scope.dispose()
|
|
14206
|
+
};
|
|
14207
|
+
}
|
|
14208
|
+
|
|
13841
14209
|
// src/components/filter-builder/engine.ts
|
|
13842
14210
|
var CLOSE2 = '<svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round"><path d="M7 7l10 10M17 7L7 17"/></svg>';
|
|
13843
14211
|
var COMBINATOR = { and: { short: "Y", long: "todas las condiciones", connector: "y" }, or: { short: "O", long: "alguna condici\xF3n", connector: "o" } };
|
|
@@ -13894,6 +14262,24 @@ function createFilterBuilder(root, options = {}) {
|
|
|
13894
14262
|
options.onChange?.(cloneFilter(model));
|
|
13895
14263
|
root.dispatchEvent(new CustomEvent("mk:change", { bubbles: true, detail: { value: cloneFilter(model), summary: describeFilter(model, fields) } }));
|
|
13896
14264
|
};
|
|
14265
|
+
const selects = /* @__PURE__ */ new Map();
|
|
14266
|
+
const choice = (select, label) => {
|
|
14267
|
+
const box = el4("span", { class: "mk-select", "data-mk-fb-select": "" });
|
|
14268
|
+
box.append(select);
|
|
14269
|
+
selects.set(box, createSelect(box, { label }));
|
|
14270
|
+
return box;
|
|
14271
|
+
};
|
|
14272
|
+
const dropChoices = (container) => {
|
|
14273
|
+
for (const [box, select] of selects) {
|
|
14274
|
+
if (!container.contains(box)) continue;
|
|
14275
|
+
select.destroy();
|
|
14276
|
+
selects.delete(box);
|
|
14277
|
+
}
|
|
14278
|
+
};
|
|
14279
|
+
scope.add(() => {
|
|
14280
|
+
for (const select of selects.values()) select.destroy();
|
|
14281
|
+
selects.clear();
|
|
14282
|
+
});
|
|
13897
14283
|
const valueControl = (rule, index) => {
|
|
13898
14284
|
const field = fieldOf(rule.field);
|
|
13899
14285
|
const type = typeOf(field);
|
|
@@ -13902,6 +14288,9 @@ function createFilterBuilder(root, options = {}) {
|
|
|
13902
14288
|
if (type === "select") {
|
|
13903
14289
|
control = el4("select");
|
|
13904
14290
|
control.append(el4("option", { value: "" }, "Elige\u2026"), ...(field?.options ?? []).map((option) => el4("option", { value: option.value }, option.label)));
|
|
14291
|
+
control.dataset.mkFbValue = String(index);
|
|
14292
|
+
control.value = current3 === null || current3 === void 0 ? "" : String(current3);
|
|
14293
|
+
return choice(control, index === 1 ? "Hasta" : operatorOf(field, rule.operator).arity === 2 ? "Desde" : "Valor");
|
|
13905
14294
|
} else {
|
|
13906
14295
|
control = el4("input");
|
|
13907
14296
|
control.type = type === "number" ? "text" : type === "date" ? "date" : "text";
|
|
@@ -13916,6 +14305,7 @@ function createFilterBuilder(root, options = {}) {
|
|
|
13916
14305
|
const fillValues = (row, rule) => {
|
|
13917
14306
|
const host = row.querySelector("[data-mk-fb-values]");
|
|
13918
14307
|
const { arity } = operatorOf(fieldOf(rule.field), rule.operator);
|
|
14308
|
+
dropChoices(host);
|
|
13919
14309
|
host.replaceChildren();
|
|
13920
14310
|
if (arity === 0) return;
|
|
13921
14311
|
host.append(valueControl(rule, 0));
|
|
@@ -13935,7 +14325,7 @@ function createFilterBuilder(root, options = {}) {
|
|
|
13935
14325
|
const values = el4("span", { "data-mk-fb-values": "" });
|
|
13936
14326
|
const remove = el4("button", { type: "button", "data-mk-fb-remove": "", "aria-label": "Quitar condici\xF3n" });
|
|
13937
14327
|
remove.innerHTML = CLOSE2;
|
|
13938
|
-
row.append(field, operator, values, remove);
|
|
14328
|
+
row.append(choice(field, "Campo"), choice(operator, "Operador"), values, remove);
|
|
13939
14329
|
fillOperators(row, rule);
|
|
13940
14330
|
fillValues(row, rule);
|
|
13941
14331
|
return row;
|
|
@@ -13977,6 +14367,7 @@ function createFilterBuilder(root, options = {}) {
|
|
|
13977
14367
|
}
|
|
13978
14368
|
};
|
|
13979
14369
|
const render = () => {
|
|
14370
|
+
dropChoices(tree);
|
|
13980
14371
|
tree.replaceChildren(groupBox(model, 0));
|
|
13981
14372
|
placeIndicators(true);
|
|
13982
14373
|
describe();
|
|
@@ -14000,7 +14391,7 @@ function createFilterBuilder(root, options = {}) {
|
|
|
14000
14391
|
parts.push(element);
|
|
14001
14392
|
if (isGroup(node)) placeIndicators(true);
|
|
14002
14393
|
keep(blurIn(parts, { from: "rise", stagger: 0.04 }));
|
|
14003
|
-
element.querySelector("select, input")?.focus();
|
|
14394
|
+
element.querySelector("[data-mk-select-trigger], input")?.focus();
|
|
14004
14395
|
emit();
|
|
14005
14396
|
};
|
|
14006
14397
|
const removeNode = (id) => {
|
|
@@ -14014,6 +14405,7 @@ function createFilterBuilder(root, options = {}) {
|
|
|
14014
14405
|
const box = boxOf(parent.id);
|
|
14015
14406
|
const focusAfter = box.querySelector(":scope > [data-mk-fb-actions] button");
|
|
14016
14407
|
const gone = () => {
|
|
14408
|
+
dropChoices(element);
|
|
14017
14409
|
element.remove();
|
|
14018
14410
|
link?.remove();
|
|
14019
14411
|
};
|
|
@@ -14067,6 +14459,7 @@ function createFilterBuilder(root, options = {}) {
|
|
|
14067
14459
|
setCombinator(group, next);
|
|
14068
14460
|
option.parentElement.querySelector(`[data-combinator="${next}"]`).focus();
|
|
14069
14461
|
});
|
|
14462
|
+
scope.on(tree, "mk:change", (event) => event.stopPropagation());
|
|
14070
14463
|
scope.on(tree, "change", (event) => {
|
|
14071
14464
|
const target = event.target;
|
|
14072
14465
|
const row = target.closest("[data-mk-fb-rule]");
|
|
@@ -14763,15 +15156,15 @@ function toggleCheck(nodes, checked, id, value) {
|
|
|
14763
15156
|
});
|
|
14764
15157
|
return next;
|
|
14765
15158
|
}
|
|
14766
|
-
var
|
|
15159
|
+
var fold5 = foldText;
|
|
14767
15160
|
function searchTree(nodes, query, text = (node) => node.label) {
|
|
14768
|
-
const needle =
|
|
15161
|
+
const needle = fold5(query.trim());
|
|
14769
15162
|
const matches = /* @__PURE__ */ new Set();
|
|
14770
15163
|
const visible = /* @__PURE__ */ new Set();
|
|
14771
15164
|
const open = /* @__PURE__ */ new Set();
|
|
14772
15165
|
if (!needle) return { matches, visible, open, active: false };
|
|
14773
15166
|
const visit = (node, ancestors) => {
|
|
14774
|
-
if (
|
|
15167
|
+
if (fold5(text(node)).includes(needle)) {
|
|
14775
15168
|
matches.add(node.id);
|
|
14776
15169
|
visible.add(node.id);
|
|
14777
15170
|
for (const ancestor of ancestors) {
|
|
@@ -14786,10 +15179,25 @@ function searchTree(nodes, query, text = (node) => node.label) {
|
|
|
14786
15179
|
}
|
|
14787
15180
|
|
|
14788
15181
|
// src/components/tree-view/engine.ts
|
|
14789
|
-
var
|
|
14790
|
-
var
|
|
15182
|
+
var FOLDER = '<svg aria-hidden="true" viewBox="0 0 48 40"><path data-mk-tree-folder-back d="M2 6a4 4 0 0 1 4-4h11.6a4 4 0 0 1 2.9 1.2L23.4 6H42a4 4 0 0 1 4 4v24a4 4 0 0 1-4 4H6a4 4 0 0 1-4-4z"/><path data-mk-tree-folder-front d="M2 14a4 4 0 0 1 4-4h36a4 4 0 0 1 4 4v20a4 4 0 0 1-4 4H6a4 4 0 0 1-4-4z"/></svg>';
|
|
15183
|
+
var PAGE = '<svg aria-hidden="true" viewBox="0 0 40 48"><path data-mk-tree-sheet d="M7 2h18.5L37 13.5V42a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4V6a4 4 0 0 1 4-4z"/><path data-mk-tree-fold d="M25.5 2v8.5a3 3 0 0 0 3 3H37z"/></svg>';
|
|
15184
|
+
function moveTreeNode(nodes, id, into) {
|
|
15185
|
+
let taken = null;
|
|
15186
|
+
const without = (list3) => list3.filter((node) => {
|
|
15187
|
+
if (node.id !== id) return true;
|
|
15188
|
+
taken = node;
|
|
15189
|
+
return false;
|
|
15190
|
+
}).map((node) => node.children ? { ...node, children: without(node.children) } : node);
|
|
15191
|
+
const rest = without(nodes);
|
|
15192
|
+
const moved = taken;
|
|
15193
|
+
if (!moved) return nodes;
|
|
15194
|
+
const put = (list3) => list3.map((node) => node.id === into ? { ...node, children: [...node.children ?? [], moved] } : node.children ? { ...node, children: put(node.children) } : node);
|
|
15195
|
+
return put(rest);
|
|
15196
|
+
}
|
|
15197
|
+
var CHEVRON3 = '<svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 6l6 6-6 6"/></svg>';
|
|
15198
|
+
var CHECK5 = '<svg aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><path data-mk-tree-tick d="M5 12.5l4.5 4.5L19 7.5" pathLength="1"/><path data-mk-tree-dash d="M6 12h12"/></svg>';
|
|
14791
15199
|
var sequence18 = 0;
|
|
14792
|
-
var
|
|
15200
|
+
var fold6 = foldText;
|
|
14793
15201
|
function createTreeView(root, options = {}) {
|
|
14794
15202
|
if (!root) return inert({ expand() {
|
|
14795
15203
|
}, collapse() {
|
|
@@ -14903,12 +15311,12 @@ function createTreeView(root, options = {}) {
|
|
|
14903
15311
|
line.style.setProperty("--mk-tree-depth", String(depth));
|
|
14904
15312
|
const chevron2 = document.createElement("span");
|
|
14905
15313
|
chevron2.dataset.mkTreeChevron = "";
|
|
14906
|
-
if (branch) chevron2.innerHTML =
|
|
15314
|
+
if (branch) chevron2.innerHTML = CHEVRON3;
|
|
14907
15315
|
line.append(chevron2);
|
|
14908
15316
|
if (options.checkable) {
|
|
14909
15317
|
const check2 = document.createElement("span");
|
|
14910
15318
|
check2.dataset.mkTreeCheck = "";
|
|
14911
|
-
check2.innerHTML =
|
|
15319
|
+
check2.innerHTML = CHECK5;
|
|
14912
15320
|
line.append(check2);
|
|
14913
15321
|
}
|
|
14914
15322
|
if (node.icon) {
|
|
@@ -14917,6 +15325,12 @@ function createTreeView(root, options = {}) {
|
|
|
14917
15325
|
icon2.setAttribute("aria-hidden", "true");
|
|
14918
15326
|
icon2.textContent = node.icon;
|
|
14919
15327
|
line.append(icon2);
|
|
15328
|
+
} else if (options.icons) {
|
|
15329
|
+
const icon2 = document.createElement("span");
|
|
15330
|
+
if (branch) icon2.dataset.mkTreeFolder = "";
|
|
15331
|
+
else icon2.dataset.mkTreePage = "";
|
|
15332
|
+
icon2.innerHTML = branch ? FOLDER : PAGE;
|
|
15333
|
+
line.append(icon2);
|
|
14920
15334
|
}
|
|
14921
15335
|
const label = document.createElement("span");
|
|
14922
15336
|
label.dataset.mkTreeLabel = "";
|
|
@@ -14956,12 +15370,29 @@ function createTreeView(root, options = {}) {
|
|
|
14956
15370
|
const target = focused && items.find((item) => item.dataset.id === focused) || selected && items.find((item) => item.dataset.id === selected) || items[0];
|
|
14957
15371
|
for (const item of tree.querySelectorAll('[role="treeitem"]')) item.tabIndex = item === target ? 0 : -1;
|
|
14958
15372
|
};
|
|
15373
|
+
let known = null;
|
|
15374
|
+
const allIds = (list3, into = /* @__PURE__ */ new Set()) => {
|
|
15375
|
+
for (const node of list3) {
|
|
15376
|
+
into.add(node.id);
|
|
15377
|
+
if (node.children) allIds(node.children, into);
|
|
15378
|
+
}
|
|
15379
|
+
return into;
|
|
15380
|
+
};
|
|
15381
|
+
const welcome = () => {
|
|
15382
|
+
const now2 = allIds(nodes);
|
|
15383
|
+
const fresh = known ? [...now2].filter((id) => !known.has(id)) : [];
|
|
15384
|
+
known = now2;
|
|
15385
|
+
if (reduced() || !fresh.length) return;
|
|
15386
|
+
const rows = fresh.map((id) => itemOf(id)?.querySelector(":scope > [data-mk-tree-row]")).filter((line) => !!line && visibleItems().includes(line.parentElement));
|
|
15387
|
+
if (rows.length) keep(gsap.fromTo(rows, { opacity: 0, x: -8, filter: "blur(6px)" }, { opacity: 1, x: 0, filter: "blur(0px)", duration: 0.35, stagger: 0.03, ease: "power2.out", clearProps: "opacity,transform,filter" }));
|
|
15388
|
+
};
|
|
14959
15389
|
const render = () => {
|
|
14960
15390
|
tree.replaceChildren(...nodes.map((node, i) => row(node, 0, i, nodes.length)));
|
|
14961
15391
|
paintChecks(false);
|
|
14962
15392
|
applySearch(false);
|
|
14963
15393
|
roving();
|
|
14964
15394
|
placePill(false);
|
|
15395
|
+
welcome();
|
|
14965
15396
|
};
|
|
14966
15397
|
const animateGroup = (group, open) => {
|
|
14967
15398
|
if (reduced()) {
|
|
@@ -15103,6 +15534,114 @@ function createTreeView(root, options = {}) {
|
|
|
15103
15534
|
}
|
|
15104
15535
|
});
|
|
15105
15536
|
}
|
|
15537
|
+
if (options.draggable) {
|
|
15538
|
+
let drag = null;
|
|
15539
|
+
let opening;
|
|
15540
|
+
const clearOver = () => {
|
|
15541
|
+
clearTimeout(opening);
|
|
15542
|
+
drag?.over?.removeAttribute("data-mk-tree-over");
|
|
15543
|
+
if (drag) drag.over = null;
|
|
15544
|
+
};
|
|
15545
|
+
const branchAt = (x, y) => {
|
|
15546
|
+
const under = document.elementFromPoint(x, y)?.closest('[role="treeitem"]');
|
|
15547
|
+
if (!under || !tree.contains(under) || !drag) return null;
|
|
15548
|
+
const node = nodeOf(under.dataset.id);
|
|
15549
|
+
const candidate = node && isBranch(node) ? under : under.parentElement?.closest('[role="treeitem"]') ?? null;
|
|
15550
|
+
if (!candidate) return null;
|
|
15551
|
+
const path = findNode(nodes, candidate.dataset.id)?.path.map((each) => each.id) ?? [];
|
|
15552
|
+
const parent = findNode(nodes, drag.id)?.path.at(-2)?.id;
|
|
15553
|
+
if (path.includes(drag.id) || candidate.dataset.id === parent) return null;
|
|
15554
|
+
return candidate;
|
|
15555
|
+
};
|
|
15556
|
+
const lift = (id, x, y) => {
|
|
15557
|
+
const node = nodeOf(id);
|
|
15558
|
+
const card = document.createElement("div");
|
|
15559
|
+
card.dataset.mkTreeDrag = "";
|
|
15560
|
+
card.setAttribute("aria-hidden", "true");
|
|
15561
|
+
if (options.icons) {
|
|
15562
|
+
const icon2 = document.createElement("span");
|
|
15563
|
+
if (isBranch(node)) icon2.dataset.mkTreeFolder = "";
|
|
15564
|
+
else icon2.dataset.mkTreePage = "";
|
|
15565
|
+
icon2.innerHTML = isBranch(node) ? FOLDER : PAGE;
|
|
15566
|
+
card.append(icon2);
|
|
15567
|
+
}
|
|
15568
|
+
const text = document.createElement("span");
|
|
15569
|
+
text.textContent = node.label;
|
|
15570
|
+
card.append(text);
|
|
15571
|
+
Object.assign(card.style, { left: "0px", top: "0px" });
|
|
15572
|
+
root.append(card);
|
|
15573
|
+
gsap.set(card, { x: x + 14, y: y + 10 });
|
|
15574
|
+
if (!reduced()) keep(gsap.fromTo(card, { scale: 0.85, opacity: 0 }, { scale: 1.04, opacity: 1, duration: 0.3, ease: EASE.pop }));
|
|
15575
|
+
itemOf(id)?.setAttribute("data-mk-tree-dragging", "");
|
|
15576
|
+
return card;
|
|
15577
|
+
};
|
|
15578
|
+
const end = (drop) => {
|
|
15579
|
+
if (!drag) return;
|
|
15580
|
+
const { id, card, over } = drag;
|
|
15581
|
+
clearOver();
|
|
15582
|
+
drag = null;
|
|
15583
|
+
itemOf(id)?.removeAttribute("data-mk-tree-dragging");
|
|
15584
|
+
if (!card) return;
|
|
15585
|
+
const into = drop && over ? over.dataset.id : null;
|
|
15586
|
+
const fly = (to) => {
|
|
15587
|
+
const box2 = to?.querySelector(":scope > [data-mk-tree-row]")?.getBoundingClientRect();
|
|
15588
|
+
if (reduced() || !box2 || !box2.width) return card.remove();
|
|
15589
|
+
keep(gsap.to(card, { x: box2.left + 24, y: box2.top + box2.height / 2 - 14, scale: 0.4, opacity: 0, duration: 0.32, ease: "power2.in", onComplete: () => card.remove() }));
|
|
15590
|
+
};
|
|
15591
|
+
if (!into) return fly(itemOf(id));
|
|
15592
|
+
fly(over);
|
|
15593
|
+
const node = nodeOf(id);
|
|
15594
|
+
nodes = moveTreeNode(nodes, id, into);
|
|
15595
|
+
expanded.add(into);
|
|
15596
|
+
render();
|
|
15597
|
+
const target = nodeOf(into);
|
|
15598
|
+
options.onMove?.(nodeOf(id), target);
|
|
15599
|
+
root.dispatchEvent(new CustomEvent("mk:move", { bubbles: true, detail: { node, into: target } }));
|
|
15600
|
+
};
|
|
15601
|
+
scope.on(tree, "pointerdown", (event) => {
|
|
15602
|
+
const down = event;
|
|
15603
|
+
const target = down.target;
|
|
15604
|
+
const line = target.closest("[data-mk-tree-row]");
|
|
15605
|
+
const item = line?.parentElement;
|
|
15606
|
+
if (!line || !item || down.button !== 0 || target.closest("[data-mk-tree-chevron], [data-mk-tree-check]") || item.getAttribute("aria-disabled") === "true") return;
|
|
15607
|
+
drag = { id: item.dataset.id, x: down.clientX, y: down.clientY, pointer: down.pointerId, card: null, over: null, lastX: down.clientX, lastT: performance.now() };
|
|
15608
|
+
});
|
|
15609
|
+
scope.on(window, "pointermove", (event) => {
|
|
15610
|
+
const move = event;
|
|
15611
|
+
if (!drag || move.pointerId !== drag.pointer) return;
|
|
15612
|
+
if (!drag.card) {
|
|
15613
|
+
if (Math.hypot(move.clientX - drag.x, move.clientY - drag.y) < 6) return;
|
|
15614
|
+
drag.card = lift(drag.id, move.clientX, move.clientY);
|
|
15615
|
+
}
|
|
15616
|
+
const now2 = performance.now();
|
|
15617
|
+
const speed = (move.clientX - drag.lastX) / Math.max(1, now2 - drag.lastT);
|
|
15618
|
+
drag.lastX = move.clientX;
|
|
15619
|
+
drag.lastT = now2;
|
|
15620
|
+
gsap.set(drag.card, { x: move.clientX + 14, y: move.clientY + 10 });
|
|
15621
|
+
if (!reduced()) keep(gsap.to(drag.card, { rotation: Math.max(-10, Math.min(10, speed * 12)), duration: 0.25, ease: "power2.out" }));
|
|
15622
|
+
const over = branchAt(move.clientX, move.clientY);
|
|
15623
|
+
if (over === drag.over) return;
|
|
15624
|
+
clearOver();
|
|
15625
|
+
if (!over) return;
|
|
15626
|
+
drag.over = over;
|
|
15627
|
+
over.setAttribute("data-mk-tree-over", "");
|
|
15628
|
+
if (over.getAttribute("aria-expanded") === "false") opening = setTimeout(() => void setOpen(over.dataset.id, true), 600);
|
|
15629
|
+
});
|
|
15630
|
+
scope.on(window, "pointerup", (event) => {
|
|
15631
|
+
if (drag && event.pointerId === drag.pointer) end(true);
|
|
15632
|
+
});
|
|
15633
|
+
scope.on(window, "pointercancel", () => end(false));
|
|
15634
|
+
scope.on(document, "keydown", (event) => {
|
|
15635
|
+
if (event.key === "Escape" && drag?.card) end(false);
|
|
15636
|
+
});
|
|
15637
|
+
scope.on(tree, "click", (event) => {
|
|
15638
|
+
if (drag?.card) event.stopImmediatePropagation();
|
|
15639
|
+
}, true);
|
|
15640
|
+
scope.add(() => {
|
|
15641
|
+
clearTimeout(opening);
|
|
15642
|
+
drag?.card?.remove();
|
|
15643
|
+
});
|
|
15644
|
+
}
|
|
15106
15645
|
scope.on(tree, "click", (event) => {
|
|
15107
15646
|
const target = event.target;
|
|
15108
15647
|
const item = target?.closest('[role="treeitem"]');
|
|
@@ -15184,9 +15723,9 @@ function createTreeView(root, options = {}) {
|
|
|
15184
15723
|
const now2 = Date.now();
|
|
15185
15724
|
typed = now2 - typedAt > 600 ? key2.key : typed + key2.key;
|
|
15186
15725
|
typedAt = now2;
|
|
15187
|
-
const needle =
|
|
15726
|
+
const needle = fold6(typed);
|
|
15188
15727
|
const order = [...items.slice(index + (typed.length === 1 ? 1 : 0)), ...items.slice(0, index + (typed.length === 1 ? 1 : 0))];
|
|
15189
|
-
const match = order.find((candidate) =>
|
|
15728
|
+
const match = order.find((candidate) => fold6(nodeOf(candidate.dataset.id)?.label ?? "").startsWith(needle));
|
|
15190
15729
|
if (match) go(match);
|
|
15191
15730
|
}
|
|
15192
15731
|
});
|
|
@@ -15346,8 +15885,8 @@ var ICONS2 = {
|
|
|
15346
15885
|
grid: SVG8('<rect x="4" y="4" width="6.5" height="6.5" rx="1.5"/><rect x="13.5" y="4" width="6.5" height="6.5" rx="1.5"/><rect x="4" y="13.5" width="6.5" height="6.5" rx="1.5"/><rect x="13.5" y="13.5" width="6.5" height="6.5" rx="1.5"/>')
|
|
15347
15886
|
};
|
|
15348
15887
|
var ARROW2 = '<svg aria-hidden="true" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round"><path d="M12 19V5M6 11l6-6 6 6"/></svg>';
|
|
15349
|
-
var
|
|
15350
|
-
var
|
|
15888
|
+
var FOLDER2 = '<svg aria-hidden="true" viewBox="0 0 48 40"><path data-mk-fx-folder-back d="M2 6a4 4 0 0 1 4-4h11.6a4 4 0 0 1 2.9 1.2L23.4 6H42a4 4 0 0 1 4 4v24a4 4 0 0 1-4 4H6a4 4 0 0 1-4-4z"/><path data-mk-fx-folder-front d="M2 14a4 4 0 0 1 4-4h36a4 4 0 0 1 4 4v20a4 4 0 0 1-4 4H6a4 4 0 0 1-4-4z"/></svg>';
|
|
15889
|
+
var PAGE2 = '<svg aria-hidden="true" viewBox="0 0 40 48"><path data-mk-fx-page d="M7 2h18.5L37 13.5V42a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4V6a4 4 0 0 1 4-4z"/><path data-mk-fx-fold d="M25.5 2v8.5a3 3 0 0 0 3 3H37z"/></svg>';
|
|
15351
15890
|
var SORT_LABEL = { name: "Nombre", size: "Tama\xF1o", modified: "Modificado" };
|
|
15352
15891
|
var plural = (n, one, many) => `${n} ${n === 1 ? one : many}`;
|
|
15353
15892
|
var sequence19 = 0;
|
|
@@ -15355,7 +15894,7 @@ function iconOf(entry) {
|
|
|
15355
15894
|
const icon2 = document.createElement("span");
|
|
15356
15895
|
icon2.dataset.mkFxIcon = "";
|
|
15357
15896
|
icon2.dataset.family = fileFamily(entry);
|
|
15358
|
-
icon2.innerHTML = isFolder(entry) ?
|
|
15897
|
+
icon2.innerHTML = isFolder(entry) ? FOLDER2 : PAGE2;
|
|
15359
15898
|
const extension2 = isFolder(entry) ? "" : extensionOf(entry.name);
|
|
15360
15899
|
if (extension2) {
|
|
15361
15900
|
const tag = document.createElement("span");
|
|
@@ -16461,7 +17000,7 @@ function createFileExplorer(root, options = {}) {
|
|
|
16461
17000
|
|
|
16462
17001
|
// src/components/json-viewer/engine.ts
|
|
16463
17002
|
var COPY = '<svg aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="8" y="8" width="12" height="12" rx="2.5"/><path d="M16 8V6.5A2.5 2.5 0 0 0 13.5 4h-7A2.5 2.5 0 0 0 4 6.5v7A2.5 2.5 0 0 0 6.5 16H8"/></svg>';
|
|
16464
|
-
var
|
|
17003
|
+
var CHECK6 = '<svg aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg>';
|
|
16465
17004
|
var SVG9 = (paths) => `<svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${paths}</svg>`;
|
|
16466
17005
|
var EXPAND = SVG9('<path d="M7 9l5-5 5 5M7 15l5 5 5-5"/>');
|
|
16467
17006
|
var COLLAPSE = SVG9('<path d="M7 4l5 5 5-5M7 20l5-5 5 5"/>');
|
|
@@ -16629,7 +17168,7 @@ function createJsonViewer(root, options = {}) {
|
|
|
16629
17168
|
scope.attr(root, "data-mk-ready", "");
|
|
16630
17169
|
const copied = (button2) => {
|
|
16631
17170
|
if (!button2) return;
|
|
16632
|
-
button2.innerHTML =
|
|
17171
|
+
button2.innerHTML = CHECK6;
|
|
16633
17172
|
button2.setAttribute("data-mk-copied", "");
|
|
16634
17173
|
if (!reduced()) keep(gsap.fromTo(button2.firstElementChild, { scale: 0.3, rotation: -25 }, { scale: 1, rotation: 0, duration: 0.42, ease: EASE.pop, transformOrigin: "50% 50%", clearProps: "transform" }));
|
|
16635
17174
|
scope.timeout(() => {
|
|
@@ -16713,8 +17252,14 @@ function createJsonViewer(root, options = {}) {
|
|
|
16713
17252
|
},
|
|
16714
17253
|
onSelect: (node) => {
|
|
16715
17254
|
const meta = node.data;
|
|
17255
|
+
const appearing = foot.hidden;
|
|
17256
|
+
const moved = pathText.textContent !== meta.path;
|
|
16716
17257
|
foot.hidden = false;
|
|
16717
17258
|
pathText.textContent = meta.path;
|
|
17259
|
+
if (!reduced()) {
|
|
17260
|
+
if (appearing) keep(blurIn(foot, { from: "rise", duration: 0.32 }));
|
|
17261
|
+
else if (moved) keep(blurIn(pathText, { from: "soft", duration: 0.28 }));
|
|
17262
|
+
}
|
|
16718
17263
|
options.onSelect?.(meta.path, meta.value);
|
|
16719
17264
|
root.dispatchEvent(new CustomEvent("mk:select", { bubbles: true, detail: { path: meta.path, value: meta.value } }));
|
|
16720
17265
|
}
|
|
@@ -17431,8 +17976,8 @@ function createVirtualList(root, options = {}) {
|
|
|
17431
17976
|
}
|
|
17432
17977
|
|
|
17433
17978
|
// src/components/resizable-panel/engine.ts
|
|
17434
|
-
var
|
|
17435
|
-
var ARROWS = { left:
|
|
17979
|
+
var CHEVRON4 = (path) => `<svg aria-hidden="true" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round"><path d="${path}"/></svg>`;
|
|
17980
|
+
var ARROWS = { left: CHEVRON4("M15 6l-6 6 6 6"), right: CHEVRON4("M9 6l6 6-6 6"), up: CHEVRON4("M6 15l6-6 6 6"), down: CHEVRON4("M6 9l6 6 6-6") };
|
|
17436
17981
|
var sequence21 = 0;
|
|
17437
17982
|
var round3 = (n) => Math.round(n * 10) / 10;
|
|
17438
17983
|
function normaliseSizes(sizes, count) {
|
|
@@ -17956,9 +18501,11 @@ var ICONS3 = {
|
|
|
17956
18501
|
previous: SVG10('<path d="M15 6l-6 6 6 6"/>'),
|
|
17957
18502
|
next: SVG10('<path d="M9 6l6 6-6 6"/>'),
|
|
17958
18503
|
close: SVG10('<path d="M7 7l10 10M17 7L7 17"/>', 14),
|
|
17959
|
-
arrow: SVG10('<path d="M12 19V5M6 11l6-6 6 6"/>', 12)
|
|
18504
|
+
arrow: SVG10('<path d="M12 19V5M6 11l6-6 6 6"/>', 12),
|
|
18505
|
+
chevron: SVG10('<path d="M7 10l5 5 5-5"/>', 14),
|
|
18506
|
+
check: SVG10('<path d="M5 12.5l4.5 4.5L19 7.5"/>', 16)
|
|
17960
18507
|
};
|
|
17961
|
-
var
|
|
18508
|
+
var CHECK7 = '<svg aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.2" stroke-linecap="round" stroke-linejoin="round"><path data-mk-dt-tick d="M5.5 12l4 4L18.5 7.5" pathLength="1"/><path data-mk-dt-dash d="M6.5 12h11"/></svg>';
|
|
17962
18509
|
var plural3 = (n, one, many) => `${n} ${n === 1 ? one : many}`;
|
|
17963
18510
|
var sequence22 = 0;
|
|
17964
18511
|
function createDataTable(root, options = {}) {
|
|
@@ -18169,21 +18716,18 @@ function createDataTable(root, options = {}) {
|
|
|
18169
18716
|
emptyHost.hidden = true;
|
|
18170
18717
|
const foot = el5("div", "data-mk-dt-foot");
|
|
18171
18718
|
const range = el5("span", "data-mk-dt-range");
|
|
18172
|
-
const sizeField = el5("
|
|
18719
|
+
const sizeField = el5("div", "data-mk-dt-size");
|
|
18173
18720
|
sizeField.append(el5("span", void 0, "Filas"));
|
|
18174
|
-
const
|
|
18175
|
-
|
|
18176
|
-
|
|
18177
|
-
|
|
18178
|
-
|
|
18179
|
-
|
|
18180
|
-
|
|
18181
|
-
|
|
18182
|
-
|
|
18183
|
-
|
|
18184
|
-
}
|
|
18185
|
-
sizeSelect.value = String(pageSize);
|
|
18186
|
-
sizeField.append(sizeSelect);
|
|
18721
|
+
const sizeButton = el5("button", "data-mk-dt-size-button");
|
|
18722
|
+
sizeButton.type = "button";
|
|
18723
|
+
sizeButton.setAttribute("aria-haspopup", "menu");
|
|
18724
|
+
sizeButton.setAttribute("aria-expanded", "false");
|
|
18725
|
+
const sizeValue = el5("span", "data-mk-dt-size-value", String(pageSize));
|
|
18726
|
+
sizeButton.append(sizeValue);
|
|
18727
|
+
sizeButton.insertAdjacentHTML("beforeend", ICONS3.chevron);
|
|
18728
|
+
sizeButton.setAttribute("aria-label", `Filas por p\xE1gina: ${pageSize}`);
|
|
18729
|
+
sizeField.append(sizeButton);
|
|
18730
|
+
const sizes = pageSize && !pageSizes.includes(pageSize) ? [pageSize, ...pageSizes] : [...pageSizes];
|
|
18187
18731
|
const pager = el5("nav", "data-mk-dt-pager");
|
|
18188
18732
|
pager.setAttribute("aria-label", "P\xE1ginas");
|
|
18189
18733
|
const previous = el5("button", "data-mk-dt-previous");
|
|
@@ -18224,7 +18768,7 @@ function createDataTable(root, options = {}) {
|
|
|
18224
18768
|
const status = el5("span");
|
|
18225
18769
|
status.className = "mk-sr-only";
|
|
18226
18770
|
status.setAttribute("role", "status");
|
|
18227
|
-
root.append(bar, active, scroll, emptyHost, foot,
|
|
18771
|
+
root.append(bar, bulk, active, scroll, emptyHost, foot, status);
|
|
18228
18772
|
scope.attr(root, "data-mk-ready", "");
|
|
18229
18773
|
scope.add(() => {
|
|
18230
18774
|
for (const effect of effects) effect.kill();
|
|
@@ -18237,7 +18781,7 @@ function createDataTable(root, options = {}) {
|
|
|
18237
18781
|
input.type = "checkbox";
|
|
18238
18782
|
input.setAttribute("aria-label", label);
|
|
18239
18783
|
box.append(input);
|
|
18240
|
-
box.insertAdjacentHTML("beforeend",
|
|
18784
|
+
box.insertAdjacentHTML("beforeend", CHECK7);
|
|
18241
18785
|
return { box, input };
|
|
18242
18786
|
};
|
|
18243
18787
|
const paintCheck = (box, state, animate) => {
|
|
@@ -18423,14 +18967,16 @@ function createDataTable(root, options = {}) {
|
|
|
18423
18967
|
gsap.killTweensOf(bulk);
|
|
18424
18968
|
if (show) {
|
|
18425
18969
|
bulk.hidden = false;
|
|
18426
|
-
if (animate && !reduced()) keep(gsap.fromTo(bulk, { opacity: 0, y:
|
|
18970
|
+
if (animate && !reduced()) keep(gsap.fromTo(bulk, { opacity: 0, y: -8, filter: "blur(8px)" }, { opacity: 1, y: 0, filter: "blur(0px)", duration: 0.35, ease: EASE.pop, clearProps: "opacity,transform,filter" }));
|
|
18427
18971
|
} else if (animate && !reduced()) {
|
|
18428
|
-
keep(gsap.to(bulk, { opacity: 0, y:
|
|
18972
|
+
keep(gsap.to(bulk, { opacity: 0, y: -8, filter: "blur(6px)", duration: 0.22, ease: "power2.in", onComplete: () => {
|
|
18429
18973
|
bulk.hidden = true;
|
|
18430
18974
|
gsap.set(bulk, { clearProps: "opacity,transform,filter" });
|
|
18431
18975
|
} }));
|
|
18432
18976
|
} else bulk.hidden = true;
|
|
18433
18977
|
};
|
|
18978
|
+
let slides = 0;
|
|
18979
|
+
scope.add(() => scroll.style.removeProperty("overflow-x"));
|
|
18434
18980
|
const render = (motion = "none") => {
|
|
18435
18981
|
const all = loading ? [] : results();
|
|
18436
18982
|
const pages = pageCount(all.length);
|
|
@@ -18456,7 +19002,25 @@ function createDataTable(root, options = {}) {
|
|
|
18456
19002
|
})
|
|
18457
19003
|
);
|
|
18458
19004
|
} else if (motion === "forward" || motion === "back") {
|
|
18459
|
-
|
|
19005
|
+
const fits = scroll.scrollWidth <= scroll.clientWidth + 1;
|
|
19006
|
+
const token = ++slides;
|
|
19007
|
+
if (fits) scroll.style.overflowX = "hidden";
|
|
19008
|
+
const release = () => {
|
|
19009
|
+
if (token === slides) scroll.style.removeProperty("overflow-x");
|
|
19010
|
+
};
|
|
19011
|
+
keep(
|
|
19012
|
+
gsap.fromTo(fresh, fits ? { opacity: 0, x: motion === "forward" ? 24 : -24 } : { opacity: 0, y: 6 }, {
|
|
19013
|
+
opacity: 1,
|
|
19014
|
+
x: 0,
|
|
19015
|
+
y: 0,
|
|
19016
|
+
duration: 0.32,
|
|
19017
|
+
stagger: 0.015,
|
|
19018
|
+
ease: "power2.out",
|
|
19019
|
+
clearProps: "opacity,transform",
|
|
19020
|
+
onComplete: release,
|
|
19021
|
+
onInterrupt: release
|
|
19022
|
+
})
|
|
19023
|
+
);
|
|
18460
19024
|
} else if (wasLoading) keep(gsap.fromTo(fresh, { opacity: 0, y: 6 }, { opacity: 1, y: 0, duration: 0.35, stagger: 0.025, ease: "power2.out", clearProps: "opacity,transform" }));
|
|
18461
19025
|
}
|
|
18462
19026
|
options.onRender?.(body);
|
|
@@ -18596,11 +19160,6 @@ function createDataTable(root, options = {}) {
|
|
|
18596
19160
|
keep(press(next));
|
|
18597
19161
|
setPage(page + 1);
|
|
18598
19162
|
});
|
|
18599
|
-
scope.on(sizeSelect, "change", () => {
|
|
18600
|
-
pageSize = Number(sizeSelect.value) || 0;
|
|
18601
|
-
page = 0;
|
|
18602
|
-
render("reflow");
|
|
18603
|
-
});
|
|
18604
19163
|
scope.on(clearButton, "click", clearAll);
|
|
18605
19164
|
scope.on(bulkClose, "click", () => setSelection([]));
|
|
18606
19165
|
scope.on(bulkAll, "click", () => setSelection(results().map(idOf)));
|
|
@@ -18621,11 +19180,55 @@ function createDataTable(root, options = {}) {
|
|
|
18621
19180
|
scope.add(() => dialog.remove());
|
|
18622
19181
|
return dialog;
|
|
18623
19182
|
};
|
|
19183
|
+
const sizeDialog = panelDialog("size", "Filas por p\xE1gina");
|
|
19184
|
+
sizeDialog.className = "mk-dialog mk-menu mk-dt-panel mk-dt-menu";
|
|
19185
|
+
const sizeItems = sizes.map((size) => {
|
|
19186
|
+
const item = el5("button", "data-mk-item");
|
|
19187
|
+
item.type = "button";
|
|
19188
|
+
item.dataset.mkValue = String(size);
|
|
19189
|
+
item.append(el5("span", void 0, String(size)));
|
|
19190
|
+
item.insertAdjacentHTML("beforeend", ICONS3.check);
|
|
19191
|
+
sizeDialog.append(item);
|
|
19192
|
+
return item;
|
|
19193
|
+
});
|
|
19194
|
+
const paintSize = () => {
|
|
19195
|
+
for (const item of sizeItems) {
|
|
19196
|
+
const on = Number(item.dataset.mkValue) === pageSize;
|
|
19197
|
+
item.setAttribute("role", "menuitemradio");
|
|
19198
|
+
item.setAttribute("aria-checked", String(on));
|
|
19199
|
+
}
|
|
19200
|
+
};
|
|
19201
|
+
const changePageSize = (size, animate) => {
|
|
19202
|
+
const next2 = Math.max(0, Math.floor(size));
|
|
19203
|
+
const text = String(next2);
|
|
19204
|
+
if (animate && next2 !== pageSize && !reduced()) keep(rollDigits(sizeValue, text, next2 > pageSize ? 1 : -1, 0.3));
|
|
19205
|
+
else sizeValue.textContent = text;
|
|
19206
|
+
sizeButton.setAttribute("aria-label", `Filas por p\xE1gina: ${next2}`);
|
|
19207
|
+
pageSize = next2;
|
|
19208
|
+
page = 0;
|
|
19209
|
+
paintSize();
|
|
19210
|
+
render("reflow");
|
|
19211
|
+
};
|
|
19212
|
+
const sizeMenu = createMenu(sizeDialog, {
|
|
19213
|
+
triggers: false,
|
|
19214
|
+
// The menu marks every item a plain menuitem when it opens: these are a choice.
|
|
19215
|
+
onOpen: paintSize,
|
|
19216
|
+
onClose: () => sizeButton.setAttribute("aria-expanded", "false"),
|
|
19217
|
+
onSelect: (value) => changePageSize(Number(value) || 0, true)
|
|
19218
|
+
});
|
|
19219
|
+
paintSize();
|
|
19220
|
+
scope.on(sizeDialog, "mk:select", (event) => event.stopPropagation());
|
|
19221
|
+
scope.add(() => sizeMenu.destroy());
|
|
19222
|
+
scope.on(sizeButton, "click", () => {
|
|
19223
|
+
keep(press(sizeButton));
|
|
19224
|
+
sizeButton.setAttribute("aria-expanded", "true");
|
|
19225
|
+
sizeMenu.open(sizeButton);
|
|
19226
|
+
});
|
|
18624
19227
|
let rowMenu = null;
|
|
18625
19228
|
let menuRow = null;
|
|
18626
19229
|
if (options.actions?.length) {
|
|
18627
19230
|
const dialog = panelDialog("menu", "Acciones de la fila");
|
|
18628
|
-
dialog.className = "mk-dialog mk-menu mk-dt-menu";
|
|
19231
|
+
dialog.className = "mk-dialog mk-menu mk-dt-panel mk-dt-menu";
|
|
18629
19232
|
for (const action of options.actions) {
|
|
18630
19233
|
const item = el5("button", "data-mk-item", action.label);
|
|
18631
19234
|
item.type = "button";
|
|
@@ -18794,10 +19397,7 @@ function createDataTable(root, options = {}) {
|
|
|
18794
19397
|
sortBy,
|
|
18795
19398
|
setPage,
|
|
18796
19399
|
setPageSize(size) {
|
|
18797
|
-
|
|
18798
|
-
sizeSelect.value = String(pageSize);
|
|
18799
|
-
page = 0;
|
|
18800
|
-
render("reflow");
|
|
19400
|
+
changePageSize(size, false);
|
|
18801
19401
|
},
|
|
18802
19402
|
setQuery(next2) {
|
|
18803
19403
|
query = next2;
|
|
@@ -19153,18 +19753,12 @@ function createEditableTable(root, options = {}) {
|
|
|
19153
19753
|
setValue(id, column.key, !value);
|
|
19154
19754
|
return;
|
|
19155
19755
|
}
|
|
19156
|
-
let editor;
|
|
19157
19756
|
if (kind === "select") {
|
|
19158
|
-
|
|
19159
|
-
|
|
19160
|
-
|
|
19161
|
-
|
|
19162
|
-
|
|
19163
|
-
select.append(element);
|
|
19164
|
-
}
|
|
19165
|
-
select.value = String(value ?? "");
|
|
19166
|
-
editor = select;
|
|
19167
|
-
} else {
|
|
19757
|
+
openChoices(cell, id, column, String(value ?? ""));
|
|
19758
|
+
return;
|
|
19759
|
+
}
|
|
19760
|
+
let editor;
|
|
19761
|
+
{
|
|
19168
19762
|
const input = document.createElement("input");
|
|
19169
19763
|
input.type = kind === "number" ? "text" : kind === "date" ? "date" : "text";
|
|
19170
19764
|
if (kind === "number") input.inputMode = "decimal";
|
|
@@ -19233,6 +19827,62 @@ function createEditableTable(root, options = {}) {
|
|
|
19233
19827
|
});
|
|
19234
19828
|
};
|
|
19235
19829
|
const finishEdit = (save2) => editing?.done(save2);
|
|
19830
|
+
const CHECK8 = '<svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg>';
|
|
19831
|
+
let choices = null;
|
|
19832
|
+
let choosing = null;
|
|
19833
|
+
const markChoices = (dialog) => {
|
|
19834
|
+
for (const item of dialog.querySelectorAll("[data-mk-item]")) {
|
|
19835
|
+
item.setAttribute("role", "menuitemradio");
|
|
19836
|
+
item.setAttribute("aria-checked", String(item.dataset.mkValue === choosing?.value));
|
|
19837
|
+
}
|
|
19838
|
+
};
|
|
19839
|
+
const choiceMenu = () => {
|
|
19840
|
+
if (choices) return choices;
|
|
19841
|
+
const dialog = document.createElement("dialog");
|
|
19842
|
+
dialog.className = "mk-dialog mk-menu mk-select-menu";
|
|
19843
|
+
dialog.dataset.mkEtChoices = "";
|
|
19844
|
+
root.append(dialog);
|
|
19845
|
+
scope.add(() => dialog.remove());
|
|
19846
|
+
const menu = createMenu(dialog, {
|
|
19847
|
+
triggers: false,
|
|
19848
|
+
onOpen: () => markChoices(dialog),
|
|
19849
|
+
onSelect: (value) => {
|
|
19850
|
+
const target = choosing;
|
|
19851
|
+
if (target && value !== target.value) setValue(target.id, target.key, value);
|
|
19852
|
+
},
|
|
19853
|
+
onClose: () => {
|
|
19854
|
+
const target = choosing;
|
|
19855
|
+
choosing = null;
|
|
19856
|
+
const fresh = target ? cellOf(target.id, target.key) : null;
|
|
19857
|
+
if (fresh) focusCell(fresh, false);
|
|
19858
|
+
}
|
|
19859
|
+
});
|
|
19860
|
+
scope.on(dialog, "mk:select", (event) => event.stopPropagation());
|
|
19861
|
+
scope.add(() => menu.destroy());
|
|
19862
|
+
choices = { menu, dialog };
|
|
19863
|
+
return choices;
|
|
19864
|
+
};
|
|
19865
|
+
const openChoices = (cell, id, column, value) => {
|
|
19866
|
+
const { menu, dialog } = choiceMenu();
|
|
19867
|
+
dialog.setAttribute("aria-label", column.label);
|
|
19868
|
+
dialog.replaceChildren(
|
|
19869
|
+
...(column.options ?? []).map((option) => {
|
|
19870
|
+
const item = document.createElement("button");
|
|
19871
|
+
item.type = "button";
|
|
19872
|
+
item.dataset.mkItem = "";
|
|
19873
|
+
item.dataset.mkValue = option.value;
|
|
19874
|
+
const text = document.createElement("span");
|
|
19875
|
+
text.textContent = option.label;
|
|
19876
|
+
item.append(text);
|
|
19877
|
+
item.insertAdjacentHTML("beforeend", CHECK8);
|
|
19878
|
+
return item;
|
|
19879
|
+
})
|
|
19880
|
+
);
|
|
19881
|
+
choosing = { id, key: column.key, value };
|
|
19882
|
+
markChoices(dialog);
|
|
19883
|
+
dialog.style.setProperty("--mk-select-width", `${cell.offsetWidth}px`);
|
|
19884
|
+
menu.open(cell);
|
|
19885
|
+
};
|
|
19236
19886
|
const moveFrom = (cell, move) => {
|
|
19237
19887
|
const { row, column, rows, cells } = positionOf(cell);
|
|
19238
19888
|
if (move === "right" || move === "left") {
|
|
@@ -20117,6 +20767,347 @@ function createRichTextEditor(root, options = {}) {
|
|
|
20117
20767
|
};
|
|
20118
20768
|
}
|
|
20119
20769
|
|
|
20770
|
+
// src/components/add-to-cart/engine.ts
|
|
20771
|
+
var BOX = 56;
|
|
20772
|
+
var FLIGHT = 0.62;
|
|
20773
|
+
var resolve = (option, fallback) => option instanceof HTMLElement ? option : typeof option === "string" ? document.querySelector(option) : fallback();
|
|
20774
|
+
function createAddToCart(root, options = {}) {
|
|
20775
|
+
const button2 = root ? root.matches("button") ? root : root.querySelector("button") : null;
|
|
20776
|
+
if (!root || !button2) return inert({ add() {
|
|
20777
|
+
}, setCount() {
|
|
20778
|
+
}, count: 0 });
|
|
20779
|
+
registerMotion();
|
|
20780
|
+
const scope = createScope();
|
|
20781
|
+
const quantity = Number.isFinite(options.quantity) && options.quantity > 0 ? Math.round(options.quantity) : 1;
|
|
20782
|
+
const target = () => resolve(options.target, () => {
|
|
20783
|
+
const all = [...document.querySelectorAll("[data-mk-cart-target]")];
|
|
20784
|
+
return all.find((element) => {
|
|
20785
|
+
const box = element.getBoundingClientRect();
|
|
20786
|
+
return box.width > 0 && box.bottom > 0 && box.top < innerHeight;
|
|
20787
|
+
}) ?? all[0] ?? null;
|
|
20788
|
+
});
|
|
20789
|
+
const image = () => resolve(options.image, () => button2.closest("[data-mk-cart-item]")?.querySelector("[data-mk-cart-image]") ?? null);
|
|
20790
|
+
const counter = () => target()?.querySelector("[data-mk-cart-count]") ?? null;
|
|
20791
|
+
const read = Number.parseInt(counter()?.textContent ?? "", 10);
|
|
20792
|
+
let count = Number.isFinite(options.count) ? Math.max(0, Math.round(options.count)) : Number.isFinite(read) ? read : 0;
|
|
20793
|
+
const status = document.createElement("span");
|
|
20794
|
+
status.className = "mk-sr-only";
|
|
20795
|
+
status.setAttribute("role", "status");
|
|
20796
|
+
root.append(status);
|
|
20797
|
+
scope.add(() => status.remove());
|
|
20798
|
+
scope.attr(root, "data-mk-ready", "");
|
|
20799
|
+
const boxes = /* @__PURE__ */ new Set();
|
|
20800
|
+
const effects = /* @__PURE__ */ new Set();
|
|
20801
|
+
const keep = (animation) => {
|
|
20802
|
+
if (!animation) return;
|
|
20803
|
+
effects.add(animation);
|
|
20804
|
+
for (const effect of effects) if (effect.totalProgress() === 1) effects.delete(effect);
|
|
20805
|
+
};
|
|
20806
|
+
scope.add(() => {
|
|
20807
|
+
for (const effect of effects) effect.kill();
|
|
20808
|
+
effects.clear();
|
|
20809
|
+
for (const box of boxes) box.remove();
|
|
20810
|
+
boxes.clear();
|
|
20811
|
+
});
|
|
20812
|
+
const land = (animate) => {
|
|
20813
|
+
const cart = target();
|
|
20814
|
+
const number2 = counter();
|
|
20815
|
+
const text = String(count);
|
|
20816
|
+
if (number2 && number2.textContent !== text) {
|
|
20817
|
+
if (animate) keep(rollDigits(number2, text, 1, 0.35));
|
|
20818
|
+
else number2.textContent = text;
|
|
20819
|
+
}
|
|
20820
|
+
if (cart && animate) {
|
|
20821
|
+
keep(gsap.fromTo(cart, { scale: 1 }, { scale: 1.1, duration: 0.14, ease: "power2.out", yoyo: true, repeat: 1, clearProps: "transform" }));
|
|
20822
|
+
keep(ringPulse(cart));
|
|
20823
|
+
}
|
|
20824
|
+
status.textContent = `${options.label ?? "A\xF1adido al carrito"}: ${count}`;
|
|
20825
|
+
options.onLand?.(count);
|
|
20826
|
+
root.dispatchEvent(new CustomEvent("mk:land", { bubbles: true, detail: { count } }));
|
|
20827
|
+
};
|
|
20828
|
+
const makeBox = (picture) => {
|
|
20829
|
+
const box = document.createElement("div");
|
|
20830
|
+
box.dataset.mkCartBox = "";
|
|
20831
|
+
box.setAttribute("aria-hidden", "true");
|
|
20832
|
+
let thumb = null;
|
|
20833
|
+
const src = picture instanceof HTMLImageElement ? picture.currentSrc || picture.getAttribute("src") : null;
|
|
20834
|
+
if (src) {
|
|
20835
|
+
thumb = document.createElement("img");
|
|
20836
|
+
thumb.src = src;
|
|
20837
|
+
thumb.alt = "";
|
|
20838
|
+
thumb.dataset.mkCartThumb = "";
|
|
20839
|
+
box.append(thumb);
|
|
20840
|
+
}
|
|
20841
|
+
const front = document.createElement("span");
|
|
20842
|
+
front.dataset.mkCartFront = "";
|
|
20843
|
+
const tape = document.createElement("span");
|
|
20844
|
+
tape.dataset.mkCartTape = "";
|
|
20845
|
+
front.append(tape);
|
|
20846
|
+
const left = document.createElement("span");
|
|
20847
|
+
left.dataset.mkCartFlap = "left";
|
|
20848
|
+
const right = document.createElement("span");
|
|
20849
|
+
right.dataset.mkCartFlap = "right";
|
|
20850
|
+
box.append(front, left, right);
|
|
20851
|
+
return { box, thumb, front, tape, left, right };
|
|
20852
|
+
};
|
|
20853
|
+
const add = () => {
|
|
20854
|
+
if (scope.disposed) return;
|
|
20855
|
+
count += quantity;
|
|
20856
|
+
options.onAdd?.(count);
|
|
20857
|
+
root.dispatchEvent(new CustomEvent("mk:add", { bubbles: true, detail: { count } }));
|
|
20858
|
+
if (reduced()) return land(false);
|
|
20859
|
+
keep(press(button2));
|
|
20860
|
+
const picture = image();
|
|
20861
|
+
const from = (picture ?? button2).getBoundingClientRect();
|
|
20862
|
+
const cart = target();
|
|
20863
|
+
const to = cart?.getBoundingClientRect() ?? null;
|
|
20864
|
+
const { box, thumb, front, tape, left, right } = makeBox(picture);
|
|
20865
|
+
const startX = from.left + from.width / 2 - BOX / 2;
|
|
20866
|
+
const startY = from.top + from.height / 2 - BOX / 2;
|
|
20867
|
+
Object.assign(box.style, { left: `${startX}px`, top: `${startY}px`, width: `${BOX}px`, height: `${BOX}px` });
|
|
20868
|
+
document.body.append(box);
|
|
20869
|
+
boxes.add(box);
|
|
20870
|
+
const gone = () => {
|
|
20871
|
+
box.remove();
|
|
20872
|
+
boxes.delete(box);
|
|
20873
|
+
};
|
|
20874
|
+
const timeline = gsap.timeline({
|
|
20875
|
+
onComplete: () => {
|
|
20876
|
+
gone();
|
|
20877
|
+
land(true);
|
|
20878
|
+
}
|
|
20879
|
+
});
|
|
20880
|
+
if (thumb) {
|
|
20881
|
+
const scale = Math.max(from.width, from.height) / 40 || 1;
|
|
20882
|
+
timeline.fromTo(thumb, { scale, y: 0, opacity: 1 }, { scale: 1, y: -14, duration: 0.32, ease: EASE.signature }, 0);
|
|
20883
|
+
timeline.to(thumb, { y: 4, duration: 0.16, ease: "power2.in" }, 0.3);
|
|
20884
|
+
}
|
|
20885
|
+
timeline.fromTo(front, { scaleY: 0 }, { scaleY: 1, duration: 0.26, ease: EASE.pop }, 0.08);
|
|
20886
|
+
timeline.fromTo([left, right], { opacity: 0 }, { opacity: 1, duration: 0.12 }, 0.12);
|
|
20887
|
+
timeline.fromTo(left, { rotation: -70 }, { rotation: 0, duration: 0.3, ease: EASE.click }, 0.38);
|
|
20888
|
+
timeline.fromTo(right, { rotation: 70 }, { rotation: 0, duration: 0.3, ease: EASE.click }, 0.43);
|
|
20889
|
+
timeline.fromTo(tape, { scaleY: 0 }, { scaleY: 1, duration: 0.16, ease: EASE.wipe }, 0.62);
|
|
20890
|
+
const start = 0.74;
|
|
20891
|
+
if (to) {
|
|
20892
|
+
const dx = to.left + to.width / 2 - (startX + BOX / 2);
|
|
20893
|
+
const dy = to.top + to.height / 2 - (startY + BOX / 2);
|
|
20894
|
+
const lift = Math.min(dy, 0) - 70;
|
|
20895
|
+
timeline.to(box, { x: dx, duration: FLIGHT, ease: EASE.signature }, start);
|
|
20896
|
+
timeline.to(box, { y: lift, duration: FLIGHT * 0.42, ease: "power2.out" }, start);
|
|
20897
|
+
timeline.to(box, { y: dy, duration: FLIGHT * 0.58, ease: "power2.in" }, start + FLIGHT * 0.42);
|
|
20898
|
+
timeline.fromTo(box, { rotation: 0 }, { rotation: 10, scale: 0.55, duration: FLIGHT, ease: "power1.inOut" }, start);
|
|
20899
|
+
timeline.to(box, { scale: 0.15, opacity: 0, duration: 0.14, ease: "power2.in" }, start + FLIGHT - 0.04);
|
|
20900
|
+
} else timeline.to(box, { y: -24, opacity: 0, scale: 0.8, filter: "blur(6px)", duration: 0.3, ease: "power2.in" }, start);
|
|
20901
|
+
keep(timeline);
|
|
20902
|
+
};
|
|
20903
|
+
scope.on(button2, "click", add);
|
|
20904
|
+
return {
|
|
20905
|
+
add,
|
|
20906
|
+
setCount(next) {
|
|
20907
|
+
if (!Number.isFinite(next)) return;
|
|
20908
|
+
count = Math.max(0, Math.round(next));
|
|
20909
|
+
const number2 = counter();
|
|
20910
|
+
if (number2) number2.textContent = String(count);
|
|
20911
|
+
},
|
|
20912
|
+
get count() {
|
|
20913
|
+
return count;
|
|
20914
|
+
},
|
|
20915
|
+
destroy: () => scope.dispose()
|
|
20916
|
+
};
|
|
20917
|
+
}
|
|
20918
|
+
|
|
20919
|
+
// src/components/scroll-island/engine.ts
|
|
20920
|
+
var INSET = 6;
|
|
20921
|
+
var BAR_WIDTH = 4;
|
|
20922
|
+
var ISLAND_HEIGHT = 36;
|
|
20923
|
+
var MIN_BAR = 28;
|
|
20924
|
+
function createScrollIsland(root, options = {}) {
|
|
20925
|
+
if (!root) return inert({ refresh() {
|
|
20926
|
+
} });
|
|
20927
|
+
registerMotion();
|
|
20928
|
+
const scope = createScope();
|
|
20929
|
+
const page = options.page ?? (root === document.documentElement || root === document.body);
|
|
20930
|
+
const scroller = page ? document.scrollingElement ?? document.documentElement : root;
|
|
20931
|
+
const reach = Number.isFinite(options.reach) ? Math.max(8, options.reach) : 56;
|
|
20932
|
+
const idle2 = Number.isFinite(options.idle) ? Math.max(0, options.idle) : 900;
|
|
20933
|
+
const marked3 = page ? document.documentElement : root;
|
|
20934
|
+
scope.attr(marked3, "data-mk-scroll-island-host", "");
|
|
20935
|
+
const island = document.createElement("div");
|
|
20936
|
+
island.dataset.mkScrollIsland = "";
|
|
20937
|
+
island.dataset.mkState = "hidden";
|
|
20938
|
+
island.setAttribute("aria-hidden", "true");
|
|
20939
|
+
const rail = document.createElement("span");
|
|
20940
|
+
rail.dataset.mkIslandRail = "";
|
|
20941
|
+
const thumb = document.createElement("div");
|
|
20942
|
+
thumb.dataset.mkIslandThumb = "";
|
|
20943
|
+
const content = document.createElement("span");
|
|
20944
|
+
content.dataset.mkIslandContent = "";
|
|
20945
|
+
const percent = document.createElement("span");
|
|
20946
|
+
percent.dataset.mkIslandPercent = "";
|
|
20947
|
+
const sectionText = document.createElement("span");
|
|
20948
|
+
sectionText.dataset.mkIslandSection = "";
|
|
20949
|
+
content.append(percent, sectionText);
|
|
20950
|
+
thumb.append(content);
|
|
20951
|
+
island.append(rail, thumb);
|
|
20952
|
+
document.body.append(island);
|
|
20953
|
+
scope.add(() => island.remove());
|
|
20954
|
+
const effects = /* @__PURE__ */ new Set();
|
|
20955
|
+
const keep = (animation) => {
|
|
20956
|
+
if (!animation) return;
|
|
20957
|
+
effects.add(animation);
|
|
20958
|
+
for (const effect of effects) if (effect.totalProgress() === 1) effects.delete(effect);
|
|
20959
|
+
};
|
|
20960
|
+
scope.add(() => {
|
|
20961
|
+
for (const effect of effects) effect.kill();
|
|
20962
|
+
effects.clear();
|
|
20963
|
+
});
|
|
20964
|
+
const frame = () => page ? { top: 0, left: 0, right: innerWidth, bottom: innerHeight, height: innerHeight } : root.getBoundingClientRect();
|
|
20965
|
+
const track = () => {
|
|
20966
|
+
const box = frame();
|
|
20967
|
+
return { top: box.top + INSET, height: Math.max(0, box.height - INSET * 2), right: box.right, left: box.left, bottom: box.bottom };
|
|
20968
|
+
};
|
|
20969
|
+
const range = () => Math.max(0, scroller.scrollHeight - scroller.clientHeight);
|
|
20970
|
+
const scrollable = () => range() > 1;
|
|
20971
|
+
const progress = () => range() ? Math.min(1, Math.max(0, scroller.scrollTop / range())) : 0;
|
|
20972
|
+
let state = "hidden";
|
|
20973
|
+
let section;
|
|
20974
|
+
let hideTimer;
|
|
20975
|
+
let dragging = null;
|
|
20976
|
+
scope.add(() => clearTimeout(hideTimer));
|
|
20977
|
+
const headings = () => options.sections === false ? [] : [...(page ? document.body : root).querySelectorAll(options.sections ?? "h2, h3")];
|
|
20978
|
+
const currentSection = () => {
|
|
20979
|
+
const box = frame();
|
|
20980
|
+
const line = box.top + scroller.clientHeight * 0.3;
|
|
20981
|
+
let found = null;
|
|
20982
|
+
for (const heading of headings()) if (heading.getBoundingClientRect().top <= line) found = heading;
|
|
20983
|
+
return found?.textContent?.trim() || null;
|
|
20984
|
+
};
|
|
20985
|
+
const geometry = (as) => {
|
|
20986
|
+
const { height } = track();
|
|
20987
|
+
const size = as === "island" ? ISLAND_HEIGHT : Math.max(MIN_BAR, Math.min(height, height * (scroller.clientHeight / Math.max(1, scroller.scrollHeight))));
|
|
20988
|
+
const top = (height - size) * progress();
|
|
20989
|
+
if (as !== "island") return { top, height: size, width: BAR_WIDTH, borderRadius: BAR_WIDTH / 2 };
|
|
20990
|
+
return { top, height: size, width: Math.max(ISLAND_HEIGHT, content.scrollWidth + 28), borderRadius: size / 2 };
|
|
20991
|
+
};
|
|
20992
|
+
const place3 = () => {
|
|
20993
|
+
const box = track();
|
|
20994
|
+
Object.assign(island.style, { top: `${box.top}px`, height: `${box.height}px`, left: `${box.left}px`, width: `${Math.max(0, box.right - box.left - 4)}px` });
|
|
20995
|
+
};
|
|
20996
|
+
const paintText = () => {
|
|
20997
|
+
percent.textContent = `${Math.round(progress() * 100)} %`;
|
|
20998
|
+
const now2 = currentSection();
|
|
20999
|
+
if (now2 !== section) {
|
|
21000
|
+
const first = section === void 0;
|
|
21001
|
+
section = now2;
|
|
21002
|
+
sectionText.textContent = now2 ?? "";
|
|
21003
|
+
sectionText.hidden = !now2;
|
|
21004
|
+
if (!first && state === "island" && !reduced()) keep(blurIn(sectionText, { from: "soft", duration: 0.3 }));
|
|
21005
|
+
options.onSection?.(now2);
|
|
21006
|
+
root.dispatchEvent(new CustomEvent("mk:section", { bubbles: true, detail: { section: now2 } }));
|
|
21007
|
+
}
|
|
21008
|
+
};
|
|
21009
|
+
const go = (next, follow = false) => {
|
|
21010
|
+
if (!scrollable()) next = "hidden";
|
|
21011
|
+
const changed = next !== state;
|
|
21012
|
+
state = next;
|
|
21013
|
+
island.dataset.mkState = next;
|
|
21014
|
+
place3();
|
|
21015
|
+
const shape = geometry(next === "hidden" ? "bar" : next);
|
|
21016
|
+
if (follow || !changed || reduced()) {
|
|
21017
|
+
gsap.killTweensOf(thumb);
|
|
21018
|
+
gsap.set(thumb, shape);
|
|
21019
|
+
return;
|
|
21020
|
+
}
|
|
21021
|
+
gsap.killTweensOf(thumb);
|
|
21022
|
+
keep(gsap.to(thumb, { ...shape, duration: next === "island" ? 0.42 : 0.32, ease: next === "island" ? EASE.swatch : "power3.out" }));
|
|
21023
|
+
};
|
|
21024
|
+
const settleLater = () => {
|
|
21025
|
+
clearTimeout(hideTimer);
|
|
21026
|
+
hideTimer = setTimeout(() => {
|
|
21027
|
+
if (state === "bar" && !dragging) go("hidden");
|
|
21028
|
+
}, idle2);
|
|
21029
|
+
};
|
|
21030
|
+
const onScroll = () => {
|
|
21031
|
+
paintText();
|
|
21032
|
+
if (state === "island" || dragging) go(state, true);
|
|
21033
|
+
else {
|
|
21034
|
+
go("bar", true);
|
|
21035
|
+
settleLater();
|
|
21036
|
+
}
|
|
21037
|
+
};
|
|
21038
|
+
scope.on(page ? window : root, "scroll", onScroll, { passive: true });
|
|
21039
|
+
if (!page) scope.on(window, "scroll", () => state !== "hidden" && place3(), { passive: true, capture: true });
|
|
21040
|
+
scope.on(window, "resize", () => go(state, true));
|
|
21041
|
+
const near = (x, y) => {
|
|
21042
|
+
const box = track();
|
|
21043
|
+
return y >= box.top - INSET && y <= box.top + box.height + INSET && x <= box.right && box.right - x <= reach;
|
|
21044
|
+
};
|
|
21045
|
+
scope.on(window, "pointermove", (event) => {
|
|
21046
|
+
const move = event;
|
|
21047
|
+
if (move.pointerType === "touch") return;
|
|
21048
|
+
if (dragging) {
|
|
21049
|
+
if (move.pointerId !== dragging.id) return;
|
|
21050
|
+
const box = track();
|
|
21051
|
+
const shape = geometry("island");
|
|
21052
|
+
const ratio = (move.clientY - box.top - dragging.offset) / Math.max(1, box.height - shape.height);
|
|
21053
|
+
scroller.scrollTop = Math.min(1, Math.max(0, ratio)) * range();
|
|
21054
|
+
onScroll();
|
|
21055
|
+
return;
|
|
21056
|
+
}
|
|
21057
|
+
if (near(move.clientX, move.clientY)) {
|
|
21058
|
+
if (state !== "island" && scrollable()) {
|
|
21059
|
+
clearTimeout(hideTimer);
|
|
21060
|
+
paintText();
|
|
21061
|
+
go("island");
|
|
21062
|
+
}
|
|
21063
|
+
} else if (state === "island") {
|
|
21064
|
+
const box = track();
|
|
21065
|
+
if (box.right - move.clientX > reach + 24 || move.clientY < box.top - 24 || move.clientY > box.top + box.height + 24) {
|
|
21066
|
+
go("bar");
|
|
21067
|
+
settleLater();
|
|
21068
|
+
}
|
|
21069
|
+
}
|
|
21070
|
+
});
|
|
21071
|
+
scope.on(thumb, "pointerdown", (event) => {
|
|
21072
|
+
const down = event;
|
|
21073
|
+
if (state !== "island" || down.button !== 0) return;
|
|
21074
|
+
down.preventDefault();
|
|
21075
|
+
down.stopPropagation();
|
|
21076
|
+
const box = thumb.getBoundingClientRect();
|
|
21077
|
+
dragging = { id: down.pointerId, offset: down.clientY - box.top || ISLAND_HEIGHT / 2 };
|
|
21078
|
+
island.setAttribute("data-mk-dragging", "");
|
|
21079
|
+
try {
|
|
21080
|
+
thumb.setPointerCapture(down.pointerId);
|
|
21081
|
+
} catch {
|
|
21082
|
+
}
|
|
21083
|
+
});
|
|
21084
|
+
const release = (event) => {
|
|
21085
|
+
if (!dragging || event.pointerId !== dragging.id) return;
|
|
21086
|
+
dragging = null;
|
|
21087
|
+
island.removeAttribute("data-mk-dragging");
|
|
21088
|
+
};
|
|
21089
|
+
scope.on(window, "pointerup", release);
|
|
21090
|
+
scope.on(window, "pointercancel", release);
|
|
21091
|
+
scope.on(rail, "pointerdown", (event) => {
|
|
21092
|
+
const down = event;
|
|
21093
|
+
if (state !== "island" || down.button !== 0) return;
|
|
21094
|
+
down.preventDefault();
|
|
21095
|
+
const box = track();
|
|
21096
|
+
const size = geometry("island").height;
|
|
21097
|
+
const ratio = (down.clientY - box.top - size / 2) / Math.max(1, box.height - size);
|
|
21098
|
+
scroller.scrollTo({ top: Math.round(Math.min(1, Math.max(0, ratio)) * range()), behavior: reduced() ? "auto" : "smooth" });
|
|
21099
|
+
});
|
|
21100
|
+
paintText();
|
|
21101
|
+
go("hidden");
|
|
21102
|
+
return {
|
|
21103
|
+
refresh: () => {
|
|
21104
|
+
paintText();
|
|
21105
|
+
go(state, true);
|
|
21106
|
+
},
|
|
21107
|
+
destroy: () => scope.dispose()
|
|
21108
|
+
};
|
|
21109
|
+
}
|
|
21110
|
+
|
|
20120
21111
|
export {
|
|
20121
21112
|
PATHS,
|
|
20122
21113
|
springPath,
|
|
@@ -20202,23 +21193,28 @@ export {
|
|
|
20202
21193
|
createChatBackground,
|
|
20203
21194
|
createSteps,
|
|
20204
21195
|
createQuantity,
|
|
21196
|
+
press,
|
|
21197
|
+
blurIn,
|
|
21198
|
+
blurOut,
|
|
21199
|
+
collapse,
|
|
21200
|
+
shake,
|
|
21201
|
+
ringPulse,
|
|
21202
|
+
burst,
|
|
21203
|
+
rollDigits,
|
|
20205
21204
|
createPagination,
|
|
20206
21205
|
createHoverCard,
|
|
20207
21206
|
createInputOtp,
|
|
20208
21207
|
createStudioDock,
|
|
20209
21208
|
createTrailer,
|
|
20210
21209
|
toDate,
|
|
21210
|
+
addDays,
|
|
21211
|
+
startOfWeek,
|
|
20211
21212
|
dayKey,
|
|
21213
|
+
weekdayNames,
|
|
21214
|
+
safeFormat,
|
|
21215
|
+
capitalize,
|
|
20212
21216
|
createCalendar,
|
|
20213
21217
|
createSlotPicker,
|
|
20214
|
-
press,
|
|
20215
|
-
blurIn,
|
|
20216
|
-
blurOut,
|
|
20217
|
-
collapse,
|
|
20218
|
-
shake,
|
|
20219
|
-
ringPulse,
|
|
20220
|
-
burst,
|
|
20221
|
-
rollDigits,
|
|
20222
21218
|
formatBytes,
|
|
20223
21219
|
describeAccept,
|
|
20224
21220
|
acceptsFile,
|
|
@@ -20305,6 +21301,7 @@ export {
|
|
|
20305
21301
|
matchesFilter,
|
|
20306
21302
|
hasConditions,
|
|
20307
21303
|
describeFilter,
|
|
21304
|
+
createSelect,
|
|
20308
21305
|
createFilterBuilder,
|
|
20309
21306
|
relativeTime,
|
|
20310
21307
|
dayLabel,
|
|
@@ -20329,6 +21326,8 @@ export {
|
|
|
20329
21326
|
createDataTable,
|
|
20330
21327
|
createEditableTable,
|
|
20331
21328
|
sanitizeHtml,
|
|
20332
|
-
createRichTextEditor
|
|
21329
|
+
createRichTextEditor,
|
|
21330
|
+
createAddToCart,
|
|
21331
|
+
createScrollIsland
|
|
20333
21332
|
};
|
|
20334
|
-
//# sourceMappingURL=chunk-
|
|
21333
|
+
//# sourceMappingURL=chunk-A6QQCF6V.js.map
|