@doscientos/ui 0.1.9 → 0.1.10
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 +21 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +30 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -86,9 +86,9 @@ declare function AppShellContent({ className, size, padded, scrollable, ...props
|
|
|
86
86
|
type AvatarProps = React.ComponentProps<"div"> & {
|
|
87
87
|
size?: "xs" | "sm" | "default" | "lg";
|
|
88
88
|
};
|
|
89
|
-
declare function Avatar({ className, size, ...props }: AvatarProps): react.JSX.Element;
|
|
90
|
-
declare function AvatarImage({ className, ...props }: React.ComponentProps<"img">): react.JSX.Element | null;
|
|
91
|
-
declare function AvatarFallback({ className, ...props }: React.ComponentProps<"span">): react.JSX.Element;
|
|
89
|
+
declare function Avatar({ className, size, children, ...props }: AvatarProps): react.JSX.Element;
|
|
90
|
+
declare function AvatarImage({ className, src, onError, onLoad, ...props }: React.ComponentProps<"img">): react.JSX.Element | null;
|
|
91
|
+
declare function AvatarFallback({ className, ...props }: React.ComponentProps<"span">): react.JSX.Element | null;
|
|
92
92
|
declare function AvatarBadge({ className, ...props }: React.ComponentProps<"span">): react.JSX.Element;
|
|
93
93
|
declare function AvatarGroup({ className, ...props }: React.ComponentProps<"div">): react.JSX.Element;
|
|
94
94
|
declare function AvatarGroupCount({ className, ...props }: React.ComponentProps<"span">): react.JSX.Element;
|
package/dist/index.d.ts
CHANGED
|
@@ -86,9 +86,9 @@ declare function AppShellContent({ className, size, padded, scrollable, ...props
|
|
|
86
86
|
type AvatarProps = React.ComponentProps<"div"> & {
|
|
87
87
|
size?: "xs" | "sm" | "default" | "lg";
|
|
88
88
|
};
|
|
89
|
-
declare function Avatar({ className, size, ...props }: AvatarProps): react.JSX.Element;
|
|
90
|
-
declare function AvatarImage({ className, ...props }: React.ComponentProps<"img">): react.JSX.Element | null;
|
|
91
|
-
declare function AvatarFallback({ className, ...props }: React.ComponentProps<"span">): react.JSX.Element;
|
|
89
|
+
declare function Avatar({ className, size, children, ...props }: AvatarProps): react.JSX.Element;
|
|
90
|
+
declare function AvatarImage({ className, src, onError, onLoad, ...props }: React.ComponentProps<"img">): react.JSX.Element | null;
|
|
91
|
+
declare function AvatarFallback({ className, ...props }: React.ComponentProps<"span">): react.JSX.Element | null;
|
|
92
92
|
declare function AvatarBadge({ className, ...props }: React.ComponentProps<"span">): react.JSX.Element;
|
|
93
93
|
declare function AvatarGroup({ className, ...props }: React.ComponentProps<"div">): react.JSX.Element;
|
|
94
94
|
declare function AvatarGroupCount({ className, ...props }: React.ComponentProps<"span">): react.JSX.Element;
|
package/dist/index.js
CHANGED
|
@@ -256,18 +256,34 @@ function AppShellContent({
|
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
// src/ui/avatar/avatar.tsx
|
|
259
|
-
import { useState as useState4 } from "react";
|
|
259
|
+
import { createContext, useContext, useEffect as useEffect3, useState as useState4 } from "react";
|
|
260
260
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
261
261
|
var sizes = { xs: "size-5 text-[10px]", sm: "size-6 text-xs", default: "size-8 text-sm", lg: "size-10 text-base" };
|
|
262
|
-
|
|
263
|
-
|
|
262
|
+
var AvatarContext = createContext(null);
|
|
263
|
+
function Avatar({ className, size = "default", children, ...props }) {
|
|
264
|
+
const [status, setStatus] = useState4("idle");
|
|
265
|
+
return /* @__PURE__ */ jsx4(AvatarContext.Provider, { value: { status, setStatus }, children: /* @__PURE__ */ jsx4("div", { "data-slot": "avatar", "data-size": size, className: cn("group/avatar relative flex shrink-0 overflow-hidden rounded-full bg-muted text-muted-foreground", sizes[size], className), ...props, children }) });
|
|
264
266
|
}
|
|
265
|
-
function AvatarImage({ className, ...props }) {
|
|
267
|
+
function AvatarImage({ className, src, onError, onLoad, ...props }) {
|
|
268
|
+
const avatar = useContext(AvatarContext);
|
|
266
269
|
const [failed, setFailed] = useState4(false);
|
|
267
|
-
|
|
268
|
-
|
|
270
|
+
useEffect3(() => {
|
|
271
|
+
setFailed(false);
|
|
272
|
+
avatar?.setStatus(src ? "loading" : "idle");
|
|
273
|
+
}, [avatar?.setStatus, src]);
|
|
274
|
+
if (failed || avatar?.status === "error") return null;
|
|
275
|
+
return /* @__PURE__ */ jsx4("img", { "data-slot": "avatar-image", src, className: cn("aspect-square size-full object-cover", className), onLoad: (event) => {
|
|
276
|
+
avatar?.setStatus("loaded");
|
|
277
|
+
onLoad?.(event);
|
|
278
|
+
}, onError: (event) => {
|
|
279
|
+
setFailed(true);
|
|
280
|
+
avatar?.setStatus("error");
|
|
281
|
+
onError?.(event);
|
|
282
|
+
}, ...props });
|
|
269
283
|
}
|
|
270
284
|
function AvatarFallback({ className, ...props }) {
|
|
285
|
+
const avatar = useContext(AvatarContext);
|
|
286
|
+
if (avatar?.status === "loaded") return null;
|
|
271
287
|
return /* @__PURE__ */ jsx4("span", { "data-slot": "avatar-fallback", className: cn("flex size-full items-center justify-center font-medium", className), ...props });
|
|
272
288
|
}
|
|
273
289
|
function AvatarBadge({ className, ...props }) {
|
|
@@ -663,7 +679,7 @@ function FieldError2({ className, children, ...props }) {
|
|
|
663
679
|
}
|
|
664
680
|
|
|
665
681
|
// src/ui/form-feedback/form-feedback.tsx
|
|
666
|
-
import { useCallback as useCallback3, useEffect as
|
|
682
|
+
import { useCallback as useCallback3, useEffect as useEffect4, useRef as useRef3, useState as useState6 } from "react";
|
|
667
683
|
import { CheckCircle, LoaderCircle, CircleAlert } from "lucide-react";
|
|
668
684
|
import { jsx as jsx20, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
669
685
|
function useFormFeedback(options) {
|
|
@@ -674,7 +690,7 @@ function useFormFeedback(options) {
|
|
|
674
690
|
if (timer.current) clearTimeout(timer.current);
|
|
675
691
|
timer.current = null;
|
|
676
692
|
}, []);
|
|
677
|
-
|
|
693
|
+
useEffect4(() => () => clearTimer(), [clearTimer]);
|
|
678
694
|
const setPending = useCallback3(() => {
|
|
679
695
|
clearTimer();
|
|
680
696
|
setState({ status: "pending" });
|
|
@@ -1015,16 +1031,16 @@ import {
|
|
|
1015
1031
|
Search
|
|
1016
1032
|
} from "lucide-react";
|
|
1017
1033
|
import {
|
|
1018
|
-
createContext,
|
|
1019
|
-
useContext,
|
|
1034
|
+
createContext as createContext2,
|
|
1035
|
+
useContext as useContext2,
|
|
1020
1036
|
useMemo as useMemo2,
|
|
1021
1037
|
useState as useState7
|
|
1022
1038
|
} from "react";
|
|
1023
1039
|
import { Link as Link2 } from "react-aria-components";
|
|
1024
1040
|
import { Fragment as Fragment8, jsx as jsx37, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1025
|
-
var SidebarContext =
|
|
1041
|
+
var SidebarContext = createContext2(null);
|
|
1026
1042
|
function useSidebar() {
|
|
1027
|
-
const context =
|
|
1043
|
+
const context = useContext2(SidebarContext);
|
|
1028
1044
|
if (!context)
|
|
1029
1045
|
throw new Error("useSidebar must be used inside SidebarProvider");
|
|
1030
1046
|
return context;
|
|
@@ -1385,7 +1401,7 @@ function TabsContent({ className, ...props }) {
|
|
|
1385
1401
|
}
|
|
1386
1402
|
|
|
1387
1403
|
// src/ui/toast/toast.tsx
|
|
1388
|
-
import { useEffect as
|
|
1404
|
+
import { useEffect as useEffect5, useSyncExternalStore } from "react";
|
|
1389
1405
|
import { CheckCircle as CheckCircle2, Info, CircleAlert as CircleAlert2, XCircle, X as X3 } from "lucide-react";
|
|
1390
1406
|
import { Fragment as Fragment11, jsx as jsx43, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
1391
1407
|
var records = [];
|
|
@@ -1454,7 +1470,7 @@ function ToastViewport({ position, visiblePosition, className }) {
|
|
|
1454
1470
|
return /* @__PURE__ */ jsx43("div", { "aria-label": `Notificaciones ${position}`, className: cn("pointer-events-none fixed z-50 flex w-[min(24rem,calc(100vw-2rem))] flex-col gap-2", positionClasses[position], className), children: toasts.map((item) => /* @__PURE__ */ jsx43(Toast, { ...item, onDismiss: () => dismiss(item.id) }, item.id)) });
|
|
1455
1471
|
}
|
|
1456
1472
|
function Toast({ id, title, description, variant = "default", action, state = "open", duration = 0, onDismiss }) {
|
|
1457
|
-
|
|
1473
|
+
useEffect5(() => {
|
|
1458
1474
|
if (state !== "open" || duration <= 0) return;
|
|
1459
1475
|
const timeout = window.setTimeout(() => dismiss(id), duration);
|
|
1460
1476
|
return () => window.clearTimeout(timeout);
|