@yewdiel21/motion-kit 0.15.0 → 0.17.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.
Files changed (85) hide show
  1. package/README.md +25 -0
  2. package/dist/auto/index.d.ts +8 -3
  3. package/dist/auto/index.js +13 -3
  4. package/dist/auto/index.js.map +1 -1
  5. package/dist/{chunk-A6QQCF6V.js → chunk-7IQTMF7Y.js} +1542 -54
  6. package/dist/chunk-7IQTMF7Y.js.map +1 -0
  7. package/dist/{chunk-6IRJYXJU.js → chunk-BZLMCHUD.js} +2 -2
  8. package/dist/{chunk-JXRS3OEA.js → chunk-VJFPTLAK.js} +29 -7
  9. package/dist/chunk-VJFPTLAK.js.map +1 -0
  10. package/dist/css/components/chart.css +7 -0
  11. package/dist/css/components/drilldown-menu.css +130 -0
  12. package/dist/css/components/heatmap-chart.css +7 -0
  13. package/dist/css/components/pie-chart.css +7 -0
  14. package/dist/css/components/radar-chart.css +7 -0
  15. package/dist/css/components/radial-chart.css +16 -2
  16. package/dist/css/components/sankey-chart.css +7 -0
  17. package/dist/css/components/scroll-island.css +3 -0
  18. package/dist/css/components/signature-pad.css +104 -0
  19. package/dist/css/components/voice-message-bubble.css +50 -0
  20. package/dist/css/components/waveform-player.css +36 -0
  21. package/dist/css/components/wheel-picker.css +17 -0
  22. package/dist/elements/index.d.ts +90 -4
  23. package/dist/elements/index.js +290 -8
  24. package/dist/elements/index.js.map +1 -1
  25. package/dist/{reveal-BfyKKsw4.d.ts → engine-Bn6hC87X.d.ts} +206 -1
  26. package/dist/index.css +324 -2
  27. package/dist/index.d.ts +3 -3
  28. package/dist/index.js +13 -3
  29. package/dist/index.js.map +1 -1
  30. package/dist/react/index.d.ts +48 -10
  31. package/dist/react/index.js +240 -10
  32. package/dist/react/index.js.map +1 -1
  33. package/dist/{reduced-6X_bns60.d.ts → reduced-YS6TZjpa.d.ts} +1 -1
  34. package/dist/{store-CA2Qcun_.d.ts → store-CZ6vdtIE.d.ts} +5 -1
  35. package/package.json +110 -110
  36. package/registry.json +64 -0
  37. package/src/auto/auto-init.ts +308 -293
  38. package/src/components/add-to-cart/README.md +49 -34
  39. package/src/components/add-to-cart/react.tsx +4 -0
  40. package/src/components/chart/README.md +49 -34
  41. package/src/components/chart/chart.css +7 -0
  42. package/src/components/chart/element.ts +2 -1
  43. package/src/components/chart/engine.ts +105 -13
  44. package/src/components/chart/react.tsx +2 -2
  45. package/src/components/drilldown-menu/README.md +163 -0
  46. package/src/components/drilldown-menu/drilldown-menu.css +129 -0
  47. package/src/components/drilldown-menu/element.ts +59 -0
  48. package/src/components/drilldown-menu/engine.ts +338 -0
  49. package/src/components/drilldown-menu/react.tsx +76 -0
  50. package/src/components/radial-chart/README.md +10 -0
  51. package/src/components/radial-chart/element.ts +2 -2
  52. package/src/components/radial-chart/engine.ts +33 -6
  53. package/src/components/radial-chart/radial-chart.css +9 -2
  54. package/src/components/radial-chart/react.tsx +2 -2
  55. package/src/components/scroll-island/README.md +44 -34
  56. package/src/components/scroll-island/element.ts +1 -1
  57. package/src/components/scroll-island/engine.ts +25 -3
  58. package/src/components/scroll-island/react.tsx +3 -3
  59. package/src/components/scroll-island/scroll-island.css +3 -0
  60. package/src/components/signature-pad/README.md +97 -0
  61. package/src/components/signature-pad/element.ts +57 -0
  62. package/src/components/signature-pad/engine.ts +437 -0
  63. package/src/components/signature-pad/react.tsx +56 -0
  64. package/src/components/signature-pad/signature-pad.css +103 -0
  65. package/src/components/voice-message-bubble/README.md +31 -0
  66. package/src/components/voice-message-bubble/element.ts +20 -0
  67. package/src/components/voice-message-bubble/engine.ts +68 -0
  68. package/src/components/voice-message-bubble/react.tsx +27 -0
  69. package/src/components/voice-message-bubble/voice-message-bubble.css +12 -0
  70. package/src/components/waveform-player/README.md +30 -0
  71. package/src/components/waveform-player/element.ts +21 -0
  72. package/src/components/waveform-player/engine.ts +261 -0
  73. package/src/components/waveform-player/react.tsx +27 -0
  74. package/src/components/waveform-player/waveform-player.css +35 -0
  75. package/src/components/wheel-picker/README.md +33 -0
  76. package/src/components/wheel-picker/element.ts +18 -0
  77. package/src/components/wheel-picker/engine.ts +210 -0
  78. package/src/components/wheel-picker/react.tsx +32 -0
  79. package/src/components/wheel-picker/wheel-picker.css +16 -0
  80. package/src/elements/index.ts +273 -258
  81. package/src/index.ts +295 -290
  82. package/src/react/index.ts +176 -171
  83. package/dist/chunk-A6QQCF6V.js.map +0 -1
  84. package/dist/chunk-JXRS3OEA.js.map +0 -1
  85. /package/dist/{chunk-6IRJYXJU.js.map → chunk-BZLMCHUD.js.map} +0 -0
@@ -18,7 +18,7 @@ import {
18
18
  slideIndicator,
19
19
  splitGraphemes,
20
20
  takeMovement
21
- } from "./chunk-A6QQCF6V.js";
21
+ } from "./chunk-7IQTMF7Y.js";
22
22
  import {
23
23
  clamp,
24
24
  damp,
@@ -4491,4 +4491,4 @@ export {
4491
4491
  createScrollDock,
4492
4492
  createLocalClock
4493
4493
  };
4494
- //# sourceMappingURL=chunk-6IRJYXJU.js.map
4494
+ //# sourceMappingURL=chunk-BZLMCHUD.js.map
@@ -27,7 +27,7 @@ import {
27
27
  startOfWeek,
28
28
  toDate,
29
29
  weekdayNames
30
- } from "./chunk-A6QQCF6V.js";
30
+ } from "./chunk-7IQTMF7Y.js";
31
31
  import {
32
32
  THEMES,
33
33
  THEME_EVENT,
@@ -2734,6 +2734,7 @@ function createRadialChart(root, initial = {}) {
2734
2734
  const percent = (ring) => new Intl.NumberFormat(void 0, { style: "percent", maximumFractionDigits: 0 }).format(ring.value / ring.max);
2735
2735
  const sweep = () => Math.min(360, Math.max(90, finite2(options.sweep) ? options.sweep : 360)) * Math.PI / 180;
2736
2736
  const startAngle = () => -sweep() / 2 + (sweep() >= Math.PI * 2 - 1e-6 ? Math.PI : 0);
2737
+ const segments = () => finite2(options.segments) ? Math.max(0, Math.min(80, Math.round(options.segments))) : 0;
2737
2738
  let geometry = { size: 240, cx: 120, cy: 120, radii: [], thickness: 12 };
2738
2739
  let arcs = [];
2739
2740
  let tracks = [];
@@ -2750,16 +2751,33 @@ function createRadialChart(root, initial = {}) {
2750
2751
  const thickness = finite2(options.thickness) ? options.thickness : Math.max(4, Math.min(16, fit));
2751
2752
  const spacing = thickness * 1.35;
2752
2753
  geometry = { size, cx: size / 2, cy: size / 2, thickness, radii: model.map((_, i) => outer - thickness / 2 - i * spacing) };
2753
- canvas.setAttribute("viewBox", `0 0 ${size} ${size}`);
2754
+ const half = sweep() <= Math.PI + 1e-6;
2755
+ const height = half ? size / 2 + 54 : size;
2756
+ canvas.setAttribute("viewBox", `0 0 ${size} ${height}`);
2754
2757
  canvas.setAttribute("width", String(size));
2755
- canvas.setAttribute("height", String(size));
2758
+ canvas.setAttribute("height", String(height));
2756
2759
  plot.style.setProperty("--mk-radial-size", `${size}px`);
2757
2760
  plot.style.setProperty("--mk-radial-thickness", `${thickness}px`);
2761
+ plot.style.setProperty("--mk-radial-center-y", half ? `${size / 2}px` : "50%");
2762
+ plot.style.setProperty("--mk-radial-center-width", n === 1 ? "0.68" : "0.36");
2758
2763
  };
2759
2764
  scope.add(() => {
2760
2765
  plot.style.removeProperty("--mk-radial-size");
2761
2766
  plot.style.removeProperty("--mk-radial-thickness");
2767
+ plot.style.removeProperty("--mk-radial-center-y");
2768
+ plot.style.removeProperty("--mk-radial-center-width");
2762
2769
  });
2770
+ const segmentedPath = (radius, share) => {
2771
+ const count = segments(), step = sweep() / count, a0 = startAngle();
2772
+ const gap = Math.min(step * 0.3, 4 / Math.max(1, radius));
2773
+ const limit = a0 + sweep() * Math.min(1, Math.max(0, share));
2774
+ const outer = radius + geometry.thickness / 2 - 1, inner = Math.max(0, radius - geometry.thickness / 2 + 1);
2775
+ return Array.from({ length: count }, (_, index) => {
2776
+ const from = a0 + index * step + gap / 2;
2777
+ const to = Math.min(a0 + (index + 1) * step - gap / 2, limit);
2778
+ return to > from ? arcPath(geometry.cx, geometry.cy, outer, inner, from, to) : "";
2779
+ }).join("");
2780
+ };
2763
2781
  const build = () => {
2764
2782
  canvas.replaceChildren();
2765
2783
  const { cx, cy, radii } = geometry;
@@ -2767,13 +2785,14 @@ function createRadialChart(root, initial = {}) {
2767
2785
  const back = svg2("g", { "data-mk-part": "tracks" });
2768
2786
  const front = svg2("g", { "data-mk-part": "series" });
2769
2787
  tracks = model.map((_, i) => {
2770
- const track = svg2("path", { d: strokeArc(cx, cy, radii[i], a0, a0 + sweep()), "data-mk-index": i });
2788
+ const track = svg2("path", { d: segments() ? segmentedPath(radii[i], 1) : strokeArc(cx, cy, radii[i], a0, a0 + sweep()), "data-mk-index": i });
2771
2789
  back.append(track);
2772
2790
  return track;
2773
2791
  });
2774
2792
  arcs = model.map((ring, i) => {
2775
2793
  const arc = svg2("path", { "data-mk-index": i, "data-mk-part": "ring" });
2776
2794
  arc.style.stroke = ring.color;
2795
+ if (segments()) arc.style.fill = ring.color;
2777
2796
  front.append(arc);
2778
2797
  return arc;
2779
2798
  });
@@ -2785,13 +2804,15 @@ function createRadialChart(root, initial = {}) {
2785
2804
  const a0 = startAngle();
2786
2805
  arcs.forEach((arc, i) => {
2787
2806
  const share = Math.min(1, Math.max(0, (values[i] ?? 0) / model[i].max));
2788
- arc.setAttribute("d", share > 1e-3 ? strokeArc(cx, cy, radii[i], a0, a0 + sweep() * share) : "");
2807
+ arc.setAttribute("d", share > 1e-3 ? segments() ? segmentedPath(radii[i], share) : strokeArc(cx, cy, radii[i], a0, a0 + sweep() * share) : "");
2789
2808
  });
2790
2809
  };
2791
2810
  const paintCenter = (animate) => {
2792
2811
  center.hidden = !model.length;
2793
2812
  const ring = selected === null ? null : model[selected];
2794
- const text = ring ? format(ring.value) : format(total());
2813
+ const denominator = ring ? ring.max : model.reduce((sum, each) => sum + each.max, 0);
2814
+ const value = ring ? ring.value : total();
2815
+ const text = options.center === "percent" ? new Intl.NumberFormat(void 0, { style: "percent", maximumFractionDigits: 1 }).format(value / (denominator || 1)) : format(value);
2795
2816
  const caption = ring ? `${ring.label} \xB7 ${percent(ring)}` : options.totalLabel ?? "Total";
2796
2817
  const changed = centerLabel.textContent !== caption;
2797
2818
  if (centerValue.textContent !== text) {
@@ -2814,6 +2835,7 @@ function createRadialChart(root, initial = {}) {
2814
2835
  };
2815
2836
  const draw = (animate) => {
2816
2837
  glide?.kill();
2838
+ scope.attr(root, "data-mk-segmented", segments() ? "" : null);
2817
2839
  const name = options.label ?? "Gr\xE1fica radial";
2818
2840
  canvas.setAttribute("aria-label", model.length ? `${name}. ${model.length} anillos, total ${format(total())}. Usa las flechas para recorrerlos.` : `${name}: ${options.emptyLabel ?? "sin datos"}`);
2819
2841
  frame.fillTable(name, ["Anillo", "Valor", "Meta", "Avance"], model.map((ring) => [ring.label, format(ring.value), format(ring.max), percent(ring)]));
@@ -3635,4 +3657,4 @@ export {
3635
3657
  createHeatmapChart,
3636
3658
  createOrbitMenu
3637
3659
  };
3638
- //# sourceMappingURL=chunk-JXRS3OEA.js.map
3660
+ //# sourceMappingURL=chunk-VJFPTLAK.js.map