@sesionario/blocks 1.32.0 → 1.33.1

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/dist/charts.js CHANGED
@@ -292,6 +292,7 @@ function ChartProvider({
292
292
  orientation: value.orientation,
293
293
  stacked: value.stacked,
294
294
  stackOffsets: value.stackOffsets,
295
+ squareSnap: value.squareSnap,
295
296
  composedBarDataKeys: value.composedBarDataKeys,
296
297
  composedBarSize: value.composedBarSize,
297
298
  composedMaxBarSize: value.composedMaxBarSize,
@@ -337,6 +338,7 @@ function ChartProvider({
337
338
  value.orientation,
338
339
  value.stacked,
339
340
  value.stackOffsets,
341
+ value.squareSnap,
340
342
  value.composedBarDataKeys,
341
343
  value.composedBarSize,
342
344
  value.composedMaxBarSize,
@@ -3857,11 +3859,6 @@ function useAnimatedSeriesPath({
3857
3859
  [renderData, xAccessor, xScale, yScale, dataKey]
3858
3860
  );
3859
3861
  const prevTransitionSignatureRef = useRef(transitionSignature);
3860
- useEffect(() => {
3861
- if (!animatingRef.current) {
3862
- displayedPointsRef.current = targetPoints;
3863
- }
3864
- }, [targetPoints]);
3865
3862
  useEffect(() => {
3866
3863
  const shouldAnimate = enabled && !reducedMotion && chartPhase === "ready" && durationMs > 0 && renderData.length > 0;
3867
3864
  if (!shouldAnimate) {
@@ -3924,6 +3921,11 @@ function useAnimatedSeriesPath({
3924
3921
  dataKey,
3925
3922
  targetPoints
3926
3923
  ]);
3924
+ useEffect(() => {
3925
+ if (!animatingRef.current) {
3926
+ displayedPointsRef.current = targetPoints;
3927
+ }
3928
+ }, [targetPoints]);
3927
3929
  const activePoints = animatedPoints ?? targetPoints;
3928
3930
  const pathD = useMemo(
3929
3931
  () => seriesPathFromPoints(activePoints, curve),
@@ -11993,7 +11995,6 @@ function PieCenterShell({
11993
11995
  return () => {
11994
11996
  cancelAnimationFrame(outerRaf);
11995
11997
  cancelAnimationFrame(innerRaf);
11996
- introStartedRef.current = false;
11997
11998
  };
11998
11999
  }
11999
12000
  setFlowTotal(centerValue);
@@ -12755,6 +12756,256 @@ function useRingHover() {
12755
12756
  function useRing() {
12756
12757
  return { ...useRingStable(), ...useRingHover() };
12757
12758
  }
12759
+ function generateArcPath(innerRadius, outerRadius, startAngle, endAngle, cornerRadius) {
12760
+ const generator = arc({
12761
+ innerRadius,
12762
+ outerRadius,
12763
+ cornerRadius
12764
+ });
12765
+ return generator({ startAngle, endAngle }) || "";
12766
+ }
12767
+ function ringHoverScale(isHovered, isPushedOut) {
12768
+ if (isHovered) {
12769
+ return 1.03;
12770
+ }
12771
+ if (isPushedOut) {
12772
+ return 1.02;
12773
+ }
12774
+ return 1;
12775
+ }
12776
+ function RingProgressPath({
12777
+ progressComplete,
12778
+ progressPath,
12779
+ animatedProgressPath,
12780
+ color
12781
+ }) {
12782
+ if (progressComplete) {
12783
+ if (!progressPath) {
12784
+ return null;
12785
+ }
12786
+ return /* @__PURE__ */ jsx("path", { d: progressPath, fill: color });
12787
+ }
12788
+ return /* @__PURE__ */ jsx(motion.path, { d: animatedProgressPath, fill: color });
12789
+ }
12790
+ var Ring = memo(function Ring2({
12791
+ index,
12792
+ color: colorProp,
12793
+ animate: animate7 = true,
12794
+ showGlow = true,
12795
+ lineCap = "round"
12796
+ }) {
12797
+ const {
12798
+ data,
12799
+ getColor,
12800
+ getRingRadii,
12801
+ startAngle,
12802
+ endAngle,
12803
+ enterTransition,
12804
+ enterStaggerScale,
12805
+ animationKey
12806
+ } = useRingStable();
12807
+ const { hoveredIndex, setHoveredIndex } = useRingHover();
12808
+ const expandDelay = index * 0.08 * enterStaggerScale;
12809
+ const expandProgress = useMountProgress(
12810
+ enterTransition,
12811
+ expandDelay,
12812
+ `${animationKey}-expand-${index}`
12813
+ );
12814
+ const expandComplete = useEnterComplete(expandProgress);
12815
+ const progressDelay = (0.6 + index * 0.1) * enterStaggerScale;
12816
+ const progressMount = useMountProgress(
12817
+ enterTransition,
12818
+ progressDelay,
12819
+ `${animationKey}-progress-${index}`
12820
+ );
12821
+ const progressComplete = useEnterComplete(progressMount);
12822
+ const ringData = data[index];
12823
+ const progress = ringData ? ringData.value / ringData.maxValue : 0;
12824
+ const arcRange = endAngle - startAngle;
12825
+ const animatedProgressPath = useTransform(progressMount, (v) => {
12826
+ if (!ringData) {
12827
+ return "";
12828
+ }
12829
+ const currentEndAngle = startAngle + arcRange * progress * v;
12830
+ if (currentEndAngle <= startAngle + 0.01) {
12831
+ return "";
12832
+ }
12833
+ const radii = getRingRadii(index);
12834
+ const corner = lineCap === "round" ? (radii.outerRadius - radii.innerRadius) / 2 : 0;
12835
+ return generateArcPath(
12836
+ radii.innerRadius,
12837
+ radii.outerRadius,
12838
+ startAngle,
12839
+ currentEndAngle,
12840
+ corner
12841
+ );
12842
+ });
12843
+ const enterScale = useTransform(expandProgress, [0, 1], [0, 1]);
12844
+ const handleMouseEnter = useCallback(
12845
+ () => setHoveredIndex(index),
12846
+ [index, setHoveredIndex]
12847
+ );
12848
+ const handleMouseLeave = useCallback(
12849
+ () => setHoveredIndex(null),
12850
+ [setHoveredIndex]
12851
+ );
12852
+ if (!ringData) {
12853
+ return null;
12854
+ }
12855
+ const { innerRadius, outerRadius } = getRingRadii(index);
12856
+ const color = colorProp || getColor(index);
12857
+ const isHovered = hoveredIndex === index;
12858
+ const isFaded = hoveredIndex !== null && hoveredIndex !== index;
12859
+ const isPushedOut = hoveredIndex !== null && hoveredIndex < index;
12860
+ const cornerRadius = lineCap === "round" ? (outerRadius - innerRadius) / 2 : 0;
12861
+ const bgPath = generateArcPath(
12862
+ innerRadius,
12863
+ outerRadius,
12864
+ startAngle,
12865
+ endAngle,
12866
+ cornerRadius
12867
+ );
12868
+ const progressEndAngle = startAngle + arcRange * progress;
12869
+ const progressPath = progressEndAngle <= startAngle + 0.01 ? "" : generateArcPath(
12870
+ innerRadius,
12871
+ outerRadius,
12872
+ startAngle,
12873
+ progressEndAngle,
12874
+ cornerRadius
12875
+ );
12876
+ const hoverScale = ringHoverScale(isHovered, isPushedOut);
12877
+ const layerOpacity = isFaded ? 0.35 : 1;
12878
+ const enterDone = !animate7 || expandComplete && progressComplete;
12879
+ const glowStyle = {
12880
+ filter: showGlow && isHovered ? `drop-shadow(0 0 12px ${color})` : "none"
12881
+ };
12882
+ const groupStyle = {
12883
+ cursor: "pointer",
12884
+ transformOrigin: "0px 0px"
12885
+ };
12886
+ if (enterDone) {
12887
+ return /* @__PURE__ */ jsx(
12888
+ motion.g,
12889
+ {
12890
+ animate: { scale: hoverScale, opacity: layerOpacity },
12891
+ initial: { opacity: layerOpacity, scale: 1 },
12892
+ onMouseEnter: handleMouseEnter,
12893
+ onMouseLeave: handleMouseLeave,
12894
+ style: groupStyle,
12895
+ transition: {
12896
+ scale: { type: "spring", stiffness: 400, damping: 25 },
12897
+ opacity: { duration: 0.15 }
12898
+ },
12899
+ children: /* @__PURE__ */ jsxs("g", { style: glowStyle, children: [
12900
+ /* @__PURE__ */ jsx("path", { d: bgPath, fill: ringCssVars.ringBackground }),
12901
+ progressPath ? /* @__PURE__ */ jsx("path", { d: progressPath, fill: color }) : null
12902
+ ] })
12903
+ }
12904
+ );
12905
+ }
12906
+ if (!expandComplete) {
12907
+ return /* @__PURE__ */ jsx(
12908
+ motion.g,
12909
+ {
12910
+ onMouseEnter: handleMouseEnter,
12911
+ onMouseLeave: handleMouseLeave,
12912
+ style: {
12913
+ ...groupStyle,
12914
+ scale: enterScale,
12915
+ opacity: layerOpacity
12916
+ },
12917
+ children: /* @__PURE__ */ jsx("g", { style: glowStyle, children: /* @__PURE__ */ jsx("path", { d: bgPath, fill: ringCssVars.ringBackground }) })
12918
+ }
12919
+ );
12920
+ }
12921
+ return /* @__PURE__ */ jsx(
12922
+ motion.g,
12923
+ {
12924
+ animate: { scale: hoverScale, opacity: layerOpacity },
12925
+ initial: { opacity: layerOpacity, scale: 1 },
12926
+ onMouseEnter: handleMouseEnter,
12927
+ onMouseLeave: handleMouseLeave,
12928
+ style: groupStyle,
12929
+ transition: {
12930
+ scale: { type: "spring", stiffness: 400, damping: 25 },
12931
+ opacity: { duration: 0.15 }
12932
+ },
12933
+ children: /* @__PURE__ */ jsxs("g", { style: glowStyle, children: [
12934
+ /* @__PURE__ */ jsx("path", { d: bgPath, fill: ringCssVars.ringBackground }),
12935
+ /* @__PURE__ */ jsx(
12936
+ RingProgressPath,
12937
+ {
12938
+ animatedProgressPath,
12939
+ color,
12940
+ progressComplete,
12941
+ progressPath
12942
+ }
12943
+ )
12944
+ ] })
12945
+ }
12946
+ );
12947
+ });
12948
+ Ring.displayName = "Ring";
12949
+ function RingCenter({
12950
+ defaultLabel = "Total",
12951
+ formatOptions = defaultChartStatFlowFormat,
12952
+ children,
12953
+ className = "",
12954
+ valueClassName = chartCenterValueClassName,
12955
+ labelClassName = chartCenterLabelClassName,
12956
+ prefix,
12957
+ suffix
12958
+ }) {
12959
+ const { data, totalValue, baseInnerRadius } = useRingStable();
12960
+ const { hoveredIndex } = useRingHover();
12961
+ const hoveredData = hoveredIndex === null ? null : data[hoveredIndex];
12962
+ const displayValue = hoveredData ? hoveredData.value : totalValue;
12963
+ const displayLabel = hoveredData ? hoveredData.label : defaultLabel;
12964
+ const centerSize = baseInnerRadius * 2 - 16;
12965
+ if (children && hoveredData) {
12966
+ return /* @__PURE__ */ jsx(
12967
+ "div",
12968
+ {
12969
+ className: cn(
12970
+ chartCenterContainerClassName,
12971
+ "flex items-center justify-center",
12972
+ className
12973
+ ),
12974
+ style: { width: centerSize, height: centerSize },
12975
+ children: children({
12976
+ value: displayValue,
12977
+ label: displayLabel,
12978
+ isHovered: hoveredIndex !== null,
12979
+ data: hoveredData
12980
+ })
12981
+ }
12982
+ );
12983
+ }
12984
+ return /* @__PURE__ */ jsx(
12985
+ "div",
12986
+ {
12987
+ className: cn(
12988
+ chartCenterContainerClassName,
12989
+ "flex flex-col items-center justify-center text-center",
12990
+ className
12991
+ ),
12992
+ style: { width: centerSize, height: centerSize },
12993
+ children: /* @__PURE__ */ jsx(
12994
+ ChartStatFlow,
12995
+ {
12996
+ formatOptions,
12997
+ label: displayLabel,
12998
+ labelClassName,
12999
+ prefix,
13000
+ suffix,
13001
+ value: displayValue,
13002
+ valueClassName
13003
+ }
13004
+ )
13005
+ }
13006
+ );
13007
+ }
13008
+ RingCenter.displayName = "RingCenter";
12758
13009
  function generateRingArcPath(innerRadius, outerRadius, startAngle, endAngle, cornerRadius) {
12759
13010
  const generator = arc({
12760
13011
  innerRadius,
@@ -12764,10 +13015,10 @@ function generateRingArcPath(innerRadius, outerRadius, startAngle, endAngle, cor
12764
13015
  return generator({ startAngle, endAngle }) || "";
12765
13016
  }
12766
13017
  function isRing(child) {
12767
- return isValidElement(child) && typeof child.type === "function" && (child.type.displayName === "Ring" || child.type.name === "Ring");
13018
+ return isValidElement(child) && child.type === Ring;
12768
13019
  }
12769
13020
  function isRingCenter(child) {
12770
- return isValidElement(child) && typeof child.type === "function" && (child.type.displayName === "RingCenter" || child.type.name === "RingCenter");
13021
+ return isValidElement(child) && child.type === RingCenter;
12771
13022
  }
12772
13023
  function RingChartInner(props) {
12773
13024
  const size = Math.min(props.width, props.height);
@@ -13063,252 +13314,6 @@ function RingChart({
13063
13314
  }
13064
13315
  );
13065
13316
  }
13066
- function generateArcPath(innerRadius, outerRadius, startAngle, endAngle, cornerRadius) {
13067
- const generator = arc({
13068
- innerRadius,
13069
- outerRadius,
13070
- cornerRadius
13071
- });
13072
- return generator({ startAngle, endAngle }) || "";
13073
- }
13074
- function ringHoverScale(isHovered, isPushedOut) {
13075
- if (isHovered) {
13076
- return 1.03;
13077
- }
13078
- if (isPushedOut) {
13079
- return 1.02;
13080
- }
13081
- return 1;
13082
- }
13083
- function RingProgressPath({
13084
- progressComplete,
13085
- progressPath,
13086
- animatedProgressPath,
13087
- color
13088
- }) {
13089
- if (progressComplete) {
13090
- if (!progressPath) {
13091
- return null;
13092
- }
13093
- return /* @__PURE__ */ jsx("path", { d: progressPath, fill: color });
13094
- }
13095
- return /* @__PURE__ */ jsx(motion.path, { d: animatedProgressPath, fill: color });
13096
- }
13097
- var Ring = memo(function Ring2({
13098
- index,
13099
- color: colorProp,
13100
- animate: animate7 = true,
13101
- showGlow = true,
13102
- lineCap = "round"
13103
- }) {
13104
- const {
13105
- data,
13106
- getColor,
13107
- getRingRadii,
13108
- startAngle,
13109
- endAngle,
13110
- enterTransition,
13111
- enterStaggerScale,
13112
- animationKey
13113
- } = useRingStable();
13114
- const { hoveredIndex, setHoveredIndex } = useRingHover();
13115
- const expandDelay = index * 0.08 * enterStaggerScale;
13116
- const expandProgress = useMountProgress(
13117
- enterTransition,
13118
- expandDelay,
13119
- `${animationKey}-expand-${index}`
13120
- );
13121
- const expandComplete = useEnterComplete(expandProgress);
13122
- const progressDelay = (0.6 + index * 0.1) * enterStaggerScale;
13123
- const progressMount = useMountProgress(
13124
- enterTransition,
13125
- progressDelay,
13126
- `${animationKey}-progress-${index}`
13127
- );
13128
- const progressComplete = useEnterComplete(progressMount);
13129
- const ringData = data[index];
13130
- const progress = ringData ? ringData.value / ringData.maxValue : 0;
13131
- const arcRange = endAngle - startAngle;
13132
- const animatedProgressPath = useTransform(progressMount, (v) => {
13133
- if (!ringData) {
13134
- return "";
13135
- }
13136
- const currentEndAngle = startAngle + arcRange * progress * v;
13137
- if (currentEndAngle <= startAngle + 0.01) {
13138
- return "";
13139
- }
13140
- const radii = getRingRadii(index);
13141
- const corner = lineCap === "round" ? (radii.outerRadius - radii.innerRadius) / 2 : 0;
13142
- return generateArcPath(
13143
- radii.innerRadius,
13144
- radii.outerRadius,
13145
- startAngle,
13146
- currentEndAngle,
13147
- corner
13148
- );
13149
- });
13150
- const enterScale = useTransform(expandProgress, [0, 1], [0, 1]);
13151
- const handleMouseEnter = useCallback(
13152
- () => setHoveredIndex(index),
13153
- [index, setHoveredIndex]
13154
- );
13155
- const handleMouseLeave = useCallback(
13156
- () => setHoveredIndex(null),
13157
- [setHoveredIndex]
13158
- );
13159
- if (!ringData) {
13160
- return null;
13161
- }
13162
- const { innerRadius, outerRadius } = getRingRadii(index);
13163
- const color = colorProp || getColor(index);
13164
- const isHovered = hoveredIndex === index;
13165
- const isFaded = hoveredIndex !== null && hoveredIndex !== index;
13166
- const isPushedOut = hoveredIndex !== null && hoveredIndex < index;
13167
- const cornerRadius = lineCap === "round" ? (outerRadius - innerRadius) / 2 : 0;
13168
- const bgPath = generateArcPath(
13169
- innerRadius,
13170
- outerRadius,
13171
- startAngle,
13172
- endAngle,
13173
- cornerRadius
13174
- );
13175
- const progressEndAngle = startAngle + arcRange * progress;
13176
- const progressPath = progressEndAngle <= startAngle + 0.01 ? "" : generateArcPath(
13177
- innerRadius,
13178
- outerRadius,
13179
- startAngle,
13180
- progressEndAngle,
13181
- cornerRadius
13182
- );
13183
- const hoverScale = ringHoverScale(isHovered, isPushedOut);
13184
- const layerOpacity = isFaded ? 0.35 : 1;
13185
- const enterDone = !animate7 || expandComplete && progressComplete;
13186
- const groupStyle = {
13187
- cursor: "pointer",
13188
- transformOrigin: "0px 0px",
13189
- filter: showGlow && isHovered ? `drop-shadow(0 0 12px ${color})` : "none"
13190
- };
13191
- if (enterDone) {
13192
- return /* @__PURE__ */ jsxs(
13193
- motion.g,
13194
- {
13195
- animate: { scale: hoverScale, opacity: layerOpacity },
13196
- onMouseEnter: handleMouseEnter,
13197
- onMouseLeave: handleMouseLeave,
13198
- style: groupStyle,
13199
- transition: {
13200
- scale: { type: "spring", stiffness: 400, damping: 25 },
13201
- opacity: { duration: 0.15 }
13202
- },
13203
- children: [
13204
- /* @__PURE__ */ jsx("path", { d: bgPath, fill: ringCssVars.ringBackground }),
13205
- progressPath ? /* @__PURE__ */ jsx("path", { d: progressPath, fill: color }) : null
13206
- ]
13207
- }
13208
- );
13209
- }
13210
- if (!expandComplete) {
13211
- return /* @__PURE__ */ jsx(
13212
- motion.g,
13213
- {
13214
- onMouseEnter: handleMouseEnter,
13215
- onMouseLeave: handleMouseLeave,
13216
- style: {
13217
- ...groupStyle,
13218
- scale: enterScale,
13219
- opacity: layerOpacity
13220
- },
13221
- children: /* @__PURE__ */ jsx("path", { d: bgPath, fill: ringCssVars.ringBackground })
13222
- }
13223
- );
13224
- }
13225
- return /* @__PURE__ */ jsxs(
13226
- motion.g,
13227
- {
13228
- animate: { scale: hoverScale, opacity: layerOpacity },
13229
- onMouseEnter: handleMouseEnter,
13230
- onMouseLeave: handleMouseLeave,
13231
- style: groupStyle,
13232
- transition: {
13233
- scale: { type: "spring", stiffness: 400, damping: 25 },
13234
- opacity: { duration: 0.15 }
13235
- },
13236
- children: [
13237
- /* @__PURE__ */ jsx("path", { d: bgPath, fill: ringCssVars.ringBackground }),
13238
- /* @__PURE__ */ jsx(
13239
- RingProgressPath,
13240
- {
13241
- animatedProgressPath,
13242
- color,
13243
- progressComplete,
13244
- progressPath
13245
- }
13246
- )
13247
- ]
13248
- }
13249
- );
13250
- });
13251
- Ring.displayName = "Ring";
13252
- function RingCenter({
13253
- defaultLabel = "Total",
13254
- formatOptions = defaultChartStatFlowFormat,
13255
- children,
13256
- className = "",
13257
- valueClassName = chartCenterValueClassName,
13258
- labelClassName = chartCenterLabelClassName,
13259
- prefix,
13260
- suffix
13261
- }) {
13262
- const { data, totalValue, baseInnerRadius } = useRingStable();
13263
- const { hoveredIndex } = useRingHover();
13264
- const hoveredData = hoveredIndex === null ? null : data[hoveredIndex];
13265
- const displayValue = hoveredData ? hoveredData.value : totalValue;
13266
- const displayLabel = hoveredData ? hoveredData.label : defaultLabel;
13267
- const centerSize = baseInnerRadius * 2 - 16;
13268
- if (children && hoveredData) {
13269
- return /* @__PURE__ */ jsx(
13270
- "div",
13271
- {
13272
- className: cn(
13273
- chartCenterContainerClassName,
13274
- "flex items-center justify-center",
13275
- className
13276
- ),
13277
- style: { width: centerSize, height: centerSize },
13278
- children: children({
13279
- value: displayValue,
13280
- label: displayLabel,
13281
- isHovered: hoveredIndex !== null,
13282
- data: hoveredData
13283
- })
13284
- }
13285
- );
13286
- }
13287
- return /* @__PURE__ */ jsx(
13288
- "div",
13289
- {
13290
- className: cn(
13291
- chartCenterContainerClassName,
13292
- "flex flex-col items-center justify-center text-center",
13293
- className
13294
- ),
13295
- style: { width: centerSize, height: centerSize },
13296
- children: /* @__PURE__ */ jsx(
13297
- ChartStatFlow,
13298
- {
13299
- formatOptions,
13300
- label: displayLabel,
13301
- labelClassName,
13302
- prefix,
13303
- suffix,
13304
- value: displayValue,
13305
- valueClassName
13306
- }
13307
- )
13308
- }
13309
- );
13310
- }
13311
- RingCenter.displayName = "RingCenter";
13312
13317
  function Card({ className, ...props }) {
13313
13318
  return /* @__PURE__ */ jsx(
13314
13319
  "div",