@particle-academy/react-fancy 5.10.0 → 5.12.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/dist/index.cjs CHANGED
@@ -6739,6 +6739,7 @@ var circularSizeMap = {
6739
6739
  md: 48,
6740
6740
  lg: 64
6741
6741
  };
6742
+ var namedStrokeWidth = { sm: 3, md: 4, lg: 5 };
6742
6743
  var textSizeClasses = {
6743
6744
  sm: "text-[8px]",
6744
6745
  md: "text-[10px]",
@@ -6750,15 +6751,18 @@ var Progress = react.forwardRef(
6750
6751
  max = 100,
6751
6752
  variant = "bar",
6752
6753
  size = "md",
6754
+ strokeWidth: strokeWidthProp,
6753
6755
  color = "blue",
6754
6756
  indeterminate = false,
6755
6757
  showValue = false,
6756
6758
  className
6757
6759
  }, ref) => {
6760
+ const named = typeof size === "number" ? "md" : size;
6758
6761
  const percentage = Math.min(100, Math.max(0, value / max * 100));
6759
6762
  if (variant === "circular") {
6760
- const diameter = circularSizeMap[size];
6761
- const strokeWidth = size === "sm" ? 3 : size === "md" ? 4 : 5;
6763
+ const pixelSize = typeof size === "number" ? size : null;
6764
+ const diameter = pixelSize ?? circularSizeMap[named];
6765
+ const strokeWidth = strokeWidthProp ?? (pixelSize === null ? namedStrokeWidth[named] : Math.max(3, Math.round(diameter * 0.075)));
6762
6766
  const radius = (diameter - strokeWidth) / 2;
6763
6767
  const circumference = 2 * Math.PI * radius;
6764
6768
  const offset = indeterminate ? circumference * 0.75 : circumference - percentage / 100 * circumference;
@@ -6771,14 +6775,19 @@ var Progress = react.forwardRef(
6771
6775
  "aria-valuemin": 0,
6772
6776
  "aria-valuemax": max,
6773
6777
  "data-react-fancy-progress": "",
6774
- className: cn("relative inline-flex items-center justify-center", className),
6775
- style: { width: diameter, height: diameter },
6778
+ "data-size": pixelSize === null ? named : void 0,
6779
+ className: cn(
6780
+ "relative inline-flex items-center justify-center",
6781
+ className
6782
+ ),
6783
+ style: pixelSize === null ? void 0 : { width: pixelSize, height: pixelSize },
6776
6784
  children: [
6777
6785
  /* @__PURE__ */ jsxRuntime.jsxs(
6778
6786
  "svg",
6779
6787
  {
6780
- width: diameter,
6781
- height: diameter,
6788
+ viewBox: `0 0 ${diameter} ${diameter}`,
6789
+ width: "100%",
6790
+ height: "100%",
6782
6791
  className: cn(indeterminate && "animate-spin"),
6783
6792
  children: [
6784
6793
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -6816,7 +6825,7 @@ var Progress = react.forwardRef(
6816
6825
  className: cn(
6817
6826
  "absolute font-medium",
6818
6827
  progressText[color],
6819
- textSizeClasses[size]
6828
+ textSizeClasses[named]
6820
6829
  ),
6821
6830
  children: [
6822
6831
  Math.round(percentage),
@@ -6844,7 +6853,7 @@ var Progress = react.forwardRef(
6844
6853
  {
6845
6854
  className: cn(
6846
6855
  "w-full overflow-hidden rounded-full bg-zinc-200 dark:bg-zinc-700",
6847
- barHeightClasses[size]
6856
+ barHeightClasses[named]
6848
6857
  ),
6849
6858
  children: /* @__PURE__ */ jsxRuntime.jsx(
6850
6859
  "div",
@@ -9171,7 +9180,8 @@ var VARIANT_ICON_COLORS = {
9171
9180
  info: "text-blue-500"
9172
9181
  };
9173
9182
  function ToastItem({ data, onDismiss }) {
9174
- const { id, title, description, variant = "default", duration = 5e3 } = data;
9183
+ const { id, title, description, variant = "default", action } = data;
9184
+ const duration = data.duration ?? (action ? 0 : 5e3);
9175
9185
  react.useEffect(() => {
9176
9186
  if (duration <= 0) return;
9177
9187
  const timer = setTimeout(() => onDismiss(id), duration);
@@ -9182,6 +9192,9 @@ function ToastItem({ data, onDismiss }) {
9182
9192
  {
9183
9193
  "data-react-fancy-toast-item": "",
9184
9194
  role: "alert",
9195
+ onKeyDown: (e) => {
9196
+ if (e.key === "Escape") onDismiss(id);
9197
+ },
9185
9198
  className: cn(
9186
9199
  "fancy-toast-in pointer-events-auto w-80 rounded-xl border p-4 shadow-lg",
9187
9200
  VARIANT_STYLES[variant]
@@ -9197,6 +9210,18 @@ function ToastItem({ data, onDismiss }) {
9197
9210
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium text-zinc-900 dark:text-zinc-100", children: title }),
9198
9211
  description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-xs text-zinc-500 dark:text-zinc-400", children: description })
9199
9212
  ] }),
9213
+ action && /* @__PURE__ */ jsxRuntime.jsx(
9214
+ "button",
9215
+ {
9216
+ type: "button",
9217
+ onClick: () => {
9218
+ action.onClick();
9219
+ onDismiss(id);
9220
+ },
9221
+ className: "shrink-0 self-center rounded-md px-2 py-1 text-xs font-medium text-zinc-700 underline-offset-2 transition-colors hover:bg-zinc-100 hover:underline dark:text-zinc-200 dark:hover:bg-zinc-800",
9222
+ children: action.label
9223
+ }
9224
+ ),
9200
9225
  /* @__PURE__ */ jsxRuntime.jsx(
9201
9226
  "button",
9202
9227
  {