@andreagiugni/tailwind-dashboard-ui 1.0.26 → 1.0.28

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.d.cts CHANGED
@@ -267,6 +267,7 @@ interface CardProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "title">,
267
267
  declare const Card: React.FC<CardProps>;
268
268
 
269
269
  type ToastVariant = "success" | "danger" | "warning" | "info";
270
+ type ToastPosition = "left" | "center" | "right";
270
271
  interface ToastProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "title">, ColorOverrideProps {
271
272
  /** Color/severity variant. */
272
273
  variant?: ToastVariant;
@@ -282,6 +283,10 @@ interface ToastProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "title">
282
283
  onClose?: () => void;
283
284
  /** Hide the colored accent bar at the bottom. */
284
285
  hideAccentBar?: boolean;
286
+ /** Fixed bottom alignment. Default: `"right"`. */
287
+ position?: ToastPosition;
288
+ /** Auto-dismiss duration in milliseconds. Omit or pass `0` to keep visible. */
289
+ duration?: number;
285
290
  }
286
291
  declare const Toast: React.FC<ToastProps>;
287
292
 
package/dist/index.d.ts CHANGED
@@ -267,6 +267,7 @@ interface CardProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "title">,
267
267
  declare const Card: React.FC<CardProps>;
268
268
 
269
269
  type ToastVariant = "success" | "danger" | "warning" | "info";
270
+ type ToastPosition = "left" | "center" | "right";
270
271
  interface ToastProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "title">, ColorOverrideProps {
271
272
  /** Color/severity variant. */
272
273
  variant?: ToastVariant;
@@ -282,6 +283,10 @@ interface ToastProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "title">
282
283
  onClose?: () => void;
283
284
  /** Hide the colored accent bar at the bottom. */
284
285
  hideAccentBar?: boolean;
286
+ /** Fixed bottom alignment. Default: `"right"`. */
287
+ position?: ToastPosition;
288
+ /** Auto-dismiss duration in milliseconds. Omit or pass `0` to keep visible. */
289
+ duration?: number;
285
290
  }
286
291
  declare const Toast: React.FC<ToastProps>;
287
292
 
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import { cn } from './chunk-ZLIYUUA4.js';
9
9
  export { cn } from './chunk-ZLIYUUA4.js';
10
10
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
11
11
  import { Info, CircleAlert, CircleX, CircleCheck, Upload, Sun, Moon, X, Check, Copy, ChevronDown, Calendar, Clock, Eye, EyeOff, ChevronRight, ChevronUp } from 'lucide-react';
12
- import React5, { useRef, useState, useEffect, useLayoutEffect, useCallback, useId, useMemo } from 'react';
12
+ import React6, { useRef, useState, useEffect, useLayoutEffect, useCallback, useId, useMemo } from 'react';
13
13
  import { createPortal } from 'react-dom';
14
14
  import flatpickr from 'flatpickr';
15
15
  import 'flatpickr/dist/flatpickr.css';
@@ -1096,6 +1096,11 @@ var variantIcons2 = {
1096
1096
  warning: CircleAlert,
1097
1097
  info: Info
1098
1098
  };
1099
+ var positionStyles = {
1100
+ left: "bottom-6 left-4 right-4 sm:left-6 sm:right-auto sm:w-full",
1101
+ center: "bottom-6 left-1/2 w-[calc(100%-2rem)] -translate-x-1/2 sm:w-full",
1102
+ right: "bottom-6 left-4 right-4 sm:left-auto sm:right-6 sm:w-full"
1103
+ };
1099
1104
  var Toast = ({
1100
1105
  variant = "success",
1101
1106
  title,
@@ -1105,6 +1110,8 @@ var Toast = ({
1105
1110
  showCloseButton = true,
1106
1111
  onClose,
1107
1112
  hideAccentBar = false,
1113
+ position = "right",
1114
+ duration,
1108
1115
  className,
1109
1116
  bgColor,
1110
1117
  textColor,
@@ -1114,12 +1121,24 @@ var Toast = ({
1114
1121
  }) => {
1115
1122
  const styles = variantStyles[variant];
1116
1123
  const Icon = variantIcons2[variant];
1124
+ const [isVisible, setIsVisible] = useState(true);
1125
+ const handleClose = useCallback(() => {
1126
+ setIsVisible(false);
1127
+ onClose?.();
1128
+ }, [onClose]);
1129
+ useEffect(() => {
1130
+ if (!duration || duration <= 0) return;
1131
+ const timer = window.setTimeout(handleClose, duration);
1132
+ return () => window.clearTimeout(timer);
1133
+ }, [duration, handleClose]);
1134
+ if (!isVisible) return null;
1117
1135
  return /* @__PURE__ */ jsxs(
1118
1136
  "div",
1119
1137
  {
1120
1138
  role: "alert",
1121
1139
  className: cn(
1122
- "relative flex items-center gap-3 overflow-hidden rounded-xl border border-gray-200 bg-white px-4 py-3.5 pr-10 shadow-theme-sm dark:border-gray-800 dark:bg-white/[0.03]",
1140
+ "fixed z-9999 flex max-w-md items-center gap-3 overflow-hidden rounded-xl border border-gray-200 bg-white px-4 py-3.5 pr-10 shadow-theme-sm dark:border-gray-800 dark:bg-gray-900",
1141
+ positionStyles[position],
1123
1142
  className
1124
1143
  ),
1125
1144
  style: { ...styleOverride({ bgColor, textColor, borderColor }), ...style },
@@ -1144,7 +1163,7 @@ var Toast = ({
1144
1163
  {
1145
1164
  type: "button",
1146
1165
  "aria-label": "Close",
1147
- onClick: onClose,
1166
+ onClick: handleClose,
1148
1167
  className: "absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 transition hover:text-gray-700 dark:hover:text-gray-200",
1149
1168
  children: /* @__PURE__ */ jsx(X, { className: "size-4", "aria-hidden": "true" })
1150
1169
  }
@@ -1160,7 +1179,7 @@ var Toast = ({
1160
1179
  }
1161
1180
  );
1162
1181
  };
1163
- var AccordionContext = React5.createContext(null);
1182
+ var AccordionContext = React6.createContext(null);
1164
1183
  var ChevronIcon2 = ({ open }) => /* @__PURE__ */ jsx(
1165
1184
  ChevronDown,
1166
1185
  {
@@ -1180,7 +1199,7 @@ var AccordionItem = ({
1180
1199
  className,
1181
1200
  ...rest
1182
1201
  }) => {
1183
- const ctx = React5.useContext(AccordionContext);
1202
+ const ctx = React6.useContext(AccordionContext);
1184
1203
  if (!ctx) {
1185
1204
  throw new Error("AccordionItem must be used within an Accordion");
1186
1205
  }
@@ -1292,8 +1311,8 @@ var Tabs = ({
1292
1311
  className,
1293
1312
  ...rest
1294
1313
  }) => {
1295
- const tabs = React5.Children.toArray(children).filter(
1296
- React5.isValidElement
1314
+ const tabs = React6.Children.toArray(children).filter(
1315
+ React6.isValidElement
1297
1316
  );
1298
1317
  const firstKey = tabs[0]?.props.tabKey;
1299
1318
  const isControlled = selectedKey !== void 0;
@@ -1873,9 +1892,9 @@ var Progress = ({
1873
1892
  ] });
1874
1893
  };
1875
1894
  var trackSizes = {
1876
- sm: "h-2",
1877
- md: "h-2.5",
1878
- lg: "h-3.5"
1895
+ sm: "h-2.5",
1896
+ md: "h-3",
1897
+ lg: "h-4"
1879
1898
  };
1880
1899
  var colorStyles = {
1881
1900
  primary: "bg-brand-500",
@@ -1969,7 +1988,7 @@ var PollResults = ({
1969
1988
  return /* @__PURE__ */ jsx(
1970
1989
  "div",
1971
1990
  {
1972
- className: cn("w-full space-y-7 text-gray-800 dark:text-white/90", className),
1991
+ className: cn("w-full space-y-5 text-gray-800 dark:text-white/90", className),
1973
1992
  style: { ...styleOverride({ bgColor, textColor, borderColor }), ...style },
1974
1993
  ...rest,
1975
1994
  children: options.map((option, optionIndex) => {
@@ -1985,7 +2004,7 @@ var PollResults = ({
1985
2004
  const isGrouped = series.length > 1;
1986
2005
  const singlePercent = toPercent(series[0]?.value ?? 0, safeMax);
1987
2006
  return /* @__PURE__ */ jsxs("div", { children: [
1988
- /* @__PURE__ */ jsxs("div", { className: "mb-3 flex items-center justify-between gap-4", children: [
2007
+ /* @__PURE__ */ jsxs("div", { className: "mb-2 flex items-center justify-between gap-4", children: [
1989
2008
  /* @__PURE__ */ jsx(
1990
2009
  "span",
1991
2010
  {
@@ -2003,7 +2022,7 @@ var PollResults = ({
2003
2022
  }
2004
2023
  )
2005
2024
  ] }),
2006
- /* @__PURE__ */ jsx("div", { className: cn("flex flex-col", isGrouped ? "gap-3" : "gap-0"), children: series.map((entry, seriesIndex) => {
2025
+ /* @__PURE__ */ jsx("div", { className: cn("flex flex-col", isGrouped ? "gap-2.5" : "gap-0"), children: series.map((entry, seriesIndex) => {
2007
2026
  const percent = toPercent(entry.value, safeMax);
2008
2027
  const fillColor = entry.fillColor;
2009
2028
  const entryColor = entry.color ?? (isGrouped ? defaultSeriesColorCycle[seriesIndex % defaultSeriesColorCycle.length] : option.color ?? defaultColorCycle[optionIndex % defaultColorCycle.length]) ?? color;