@doscientos/ui 0.1.9 → 0.1.11

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/README.md CHANGED
@@ -2,13 +2,13 @@
2
2
 
3
3
  Primitives React accesibles, rápidas y temables para los productos de Doscientos. No depende de Next.js, Astro, router, backend ni estado de datos.
4
4
 
5
- ## Alcance de la primera versión
5
+ ## Alcance
6
6
 
7
- - Tokens CSS del backoffice y tema claro/oscuro.
8
- - Controles: botón, input, textarea, label, badge, separadores, atajos de teclado y skeleton.
9
- - Formularios: `Field`, descripción y errores accesibles.
10
- - Navegación y overlays: tabs, tooltip, popover, `Dialog` y `ConfirmDialog` controlado.
11
- - Búsqueda: `Combobox` composable sobre React Aria y `HighlightMatch` sin distinción de mayúsculas o acentos.
7
+ - Foundations: tokens CSS, tema claro/oscuro y utilidades de clases y texto.
8
+ - Controles y formularios: botones, campos, selección, feedback, búsqueda y validación accesible.
9
+ - Navegación y overlays: tabs, menús, breadcrumbs, tooltip, popover, dialogs y drawers.
10
+ - Datos y estados: tablas, cards, avatares, badges, skeletons, alertas y estados vacíos.
11
+ - Patrones de aplicación: shell, sidebar, cabeceras, toolbars, paginación, toasts y carga.
12
12
  - Hooks: debounce, cambios no guardados y autosave sin acoplamiento a transporte o datos.
13
13
 
14
14
  Los componentes de dominio, llamadas API, navegación, toasts y layouts permanecen en cada aplicación.
package/dist/index.cjs CHANGED
@@ -439,15 +439,31 @@ function AppShellContent({
439
439
  var import_react4 = require("react");
440
440
  var import_jsx_runtime4 = require("react/jsx-runtime");
441
441
  var sizes = { xs: "size-5 text-[10px]", sm: "size-6 text-xs", default: "size-8 text-sm", lg: "size-10 text-base" };
442
- function Avatar({ className, size = "default", ...props }) {
443
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("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 });
442
+ var AvatarContext = (0, import_react4.createContext)(null);
443
+ function Avatar({ className, size = "default", children, ...props }) {
444
+ const [status, setStatus] = (0, import_react4.useState)("idle");
445
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AvatarContext.Provider, { value: { status, setStatus }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("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 }) });
444
446
  }
445
- function AvatarImage({ className, ...props }) {
447
+ function AvatarImage({ className, src, onError, onLoad, ...props }) {
448
+ const avatar = (0, import_react4.useContext)(AvatarContext);
446
449
  const [failed, setFailed] = (0, import_react4.useState)(false);
447
- if (failed) return null;
448
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("img", { "data-slot": "avatar-image", className: cn("aspect-square size-full object-cover", className), onError: () => setFailed(true), ...props });
450
+ (0, import_react4.useEffect)(() => {
451
+ setFailed(false);
452
+ avatar?.setStatus(src ? "loading" : "idle");
453
+ }, [avatar?.setStatus, src]);
454
+ if (failed || avatar?.status === "error") return null;
455
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("img", { "data-slot": "avatar-image", src, className: cn("aspect-square size-full object-cover", className), onLoad: (event) => {
456
+ avatar?.setStatus("loaded");
457
+ onLoad?.(event);
458
+ }, onError: (event) => {
459
+ setFailed(true);
460
+ avatar?.setStatus("error");
461
+ onError?.(event);
462
+ }, ...props });
449
463
  }
450
464
  function AvatarFallback({ className, ...props }) {
465
+ const avatar = (0, import_react4.useContext)(AvatarContext);
466
+ if (avatar?.status === "loaded") return null;
451
467
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-slot": "avatar-fallback", className: cn("flex size-full items-center justify-center font-medium", className), ...props });
452
468
  }
453
469
  function AvatarBadge({ className, ...props }) {