@doscientos/ui 0.1.12 → 0.1.13
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 +42 -62
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -5
- package/dist/index.d.ts +4 -5
- package/dist/index.js +43 -63
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +5 -1
package/dist/index.d.cts
CHANGED
|
@@ -566,13 +566,12 @@ type ToastPromiseOptions<T> = {
|
|
|
566
566
|
description?: string;
|
|
567
567
|
position?: ToastPosition;
|
|
568
568
|
};
|
|
569
|
-
declare function dismiss(id: string): void;
|
|
570
569
|
declare const toast: ((options: ToastOptions) => string) & {
|
|
571
570
|
success: (title: string, options?: Omit<ToastOptions, "title" | "variant">) => string;
|
|
572
571
|
error: (title: string, options?: Omit<ToastOptions, "title" | "variant">) => string;
|
|
573
572
|
warning: (title: string, options?: Omit<ToastOptions, "title" | "variant">) => string;
|
|
574
573
|
info: (title: string, options?: Omit<ToastOptions, "title" | "variant">) => string;
|
|
575
|
-
dismiss:
|
|
574
|
+
dismiss: (id: string) => void;
|
|
576
575
|
promise: <T>(promise: Promise<T>, options: ToastPromiseOptions<T>) => Promise<T>;
|
|
577
576
|
};
|
|
578
577
|
declare function useToast(): ((options: ToastOptions) => string) & {
|
|
@@ -580,7 +579,7 @@ declare function useToast(): ((options: ToastOptions) => string) & {
|
|
|
580
579
|
error: (title: string, options?: Omit<ToastOptions, "title" | "variant">) => string;
|
|
581
580
|
warning: (title: string, options?: Omit<ToastOptions, "title" | "variant">) => string;
|
|
582
581
|
info: (title: string, options?: Omit<ToastOptions, "title" | "variant">) => string;
|
|
583
|
-
dismiss:
|
|
582
|
+
dismiss: (id: string) => void;
|
|
584
583
|
promise: <T>(promise: Promise<T>, options: ToastPromiseOptions<T>) => Promise<T>;
|
|
585
584
|
};
|
|
586
585
|
declare function ToastProvider({ children }: {
|
|
@@ -594,9 +593,9 @@ declare function ToastViewport({ position, visiblePosition, className }: {
|
|
|
594
593
|
visiblePosition?: ToastPosition;
|
|
595
594
|
className?: string;
|
|
596
595
|
}): React$1.JSX.Element | null;
|
|
597
|
-
declare function Toast({ id, title, description, variant, action, state, duration, onDismiss }: ToastData & {
|
|
596
|
+
declare function Toast({ id, title, description, variant, action, state, duration, position, onDismiss }: ToastData & {
|
|
598
597
|
onDismiss?: () => void;
|
|
599
|
-
}):
|
|
598
|
+
}): null;
|
|
600
599
|
|
|
601
600
|
declare function Toolbar({ className, ...props }: React$1.ComponentProps<"div">): React$1.JSX.Element;
|
|
602
601
|
declare function ToolbarGroup({ className, ...props }: React$1.ComponentProps<"div">): React$1.JSX.Element;
|
package/dist/index.d.ts
CHANGED
|
@@ -566,13 +566,12 @@ type ToastPromiseOptions<T> = {
|
|
|
566
566
|
description?: string;
|
|
567
567
|
position?: ToastPosition;
|
|
568
568
|
};
|
|
569
|
-
declare function dismiss(id: string): void;
|
|
570
569
|
declare const toast: ((options: ToastOptions) => string) & {
|
|
571
570
|
success: (title: string, options?: Omit<ToastOptions, "title" | "variant">) => string;
|
|
572
571
|
error: (title: string, options?: Omit<ToastOptions, "title" | "variant">) => string;
|
|
573
572
|
warning: (title: string, options?: Omit<ToastOptions, "title" | "variant">) => string;
|
|
574
573
|
info: (title: string, options?: Omit<ToastOptions, "title" | "variant">) => string;
|
|
575
|
-
dismiss:
|
|
574
|
+
dismiss: (id: string) => void;
|
|
576
575
|
promise: <T>(promise: Promise<T>, options: ToastPromiseOptions<T>) => Promise<T>;
|
|
577
576
|
};
|
|
578
577
|
declare function useToast(): ((options: ToastOptions) => string) & {
|
|
@@ -580,7 +579,7 @@ declare function useToast(): ((options: ToastOptions) => string) & {
|
|
|
580
579
|
error: (title: string, options?: Omit<ToastOptions, "title" | "variant">) => string;
|
|
581
580
|
warning: (title: string, options?: Omit<ToastOptions, "title" | "variant">) => string;
|
|
582
581
|
info: (title: string, options?: Omit<ToastOptions, "title" | "variant">) => string;
|
|
583
|
-
dismiss:
|
|
582
|
+
dismiss: (id: string) => void;
|
|
584
583
|
promise: <T>(promise: Promise<T>, options: ToastPromiseOptions<T>) => Promise<T>;
|
|
585
584
|
};
|
|
586
585
|
declare function ToastProvider({ children }: {
|
|
@@ -594,9 +593,9 @@ declare function ToastViewport({ position, visiblePosition, className }: {
|
|
|
594
593
|
visiblePosition?: ToastPosition;
|
|
595
594
|
className?: string;
|
|
596
595
|
}): React$1.JSX.Element | null;
|
|
597
|
-
declare function Toast({ id, title, description, variant, action, state, duration, onDismiss }: ToastData & {
|
|
596
|
+
declare function Toast({ id, title, description, variant, action, state, duration, position, onDismiss }: ToastData & {
|
|
598
597
|
onDismiss?: () => void;
|
|
599
|
-
}):
|
|
598
|
+
}): null;
|
|
600
599
|
|
|
601
600
|
declare function Toolbar({ className, ...props }: React$1.ComponentProps<"div">): React$1.JSX.Element;
|
|
602
601
|
declare function ToolbarGroup({ className, ...props }: React$1.ComponentProps<"div">): React$1.JSX.Element;
|
package/dist/index.js
CHANGED
|
@@ -32,12 +32,12 @@ function useAutosave({
|
|
|
32
32
|
}, []);
|
|
33
33
|
useEffect(() => {
|
|
34
34
|
if (!enabled) return;
|
|
35
|
-
const
|
|
35
|
+
const snapshot = serializeRef.current(data);
|
|
36
36
|
if (lastSaved.current === null) {
|
|
37
|
-
lastSaved.current =
|
|
37
|
+
lastSaved.current = snapshot;
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
|
-
if (
|
|
40
|
+
if (snapshot === lastSaved.current) return;
|
|
41
41
|
const timeout = window.setTimeout(() => void save(data), debounceMs);
|
|
42
42
|
return () => window.clearTimeout(timeout);
|
|
43
43
|
}, [data, debounceMs, enabled, save]);
|
|
@@ -2609,47 +2609,41 @@ function TabsContent({ className, ...props }) {
|
|
|
2609
2609
|
}
|
|
2610
2610
|
|
|
2611
2611
|
// src/ui/toast/toast.tsx
|
|
2612
|
-
import { useEffect as useEffect5
|
|
2613
|
-
import {
|
|
2612
|
+
import { useEffect as useEffect5 } from "react";
|
|
2613
|
+
import { sileo, Toaster as SileoToaster } from "sileo";
|
|
2614
2614
|
import { Fragment as Fragment11, jsx as jsx45, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
};
|
|
2623
|
-
var remove = (id) => {
|
|
2624
|
-
records = records.filter((record) => record.id !== id);
|
|
2625
|
-
emit();
|
|
2626
|
-
};
|
|
2627
|
-
function create(options) {
|
|
2628
|
-
const id = `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
2629
|
-
records = [...records, { ...options, id, state: "open", variant: options.variant ?? "default", duration: options.duration ?? 5e3, position: options.position ?? "bottom-right" }];
|
|
2630
|
-
emit();
|
|
2631
|
-
return id;
|
|
2632
|
-
}
|
|
2633
|
-
function dismiss(id) {
|
|
2634
|
-
if (!records.some((record) => record.id === id && record.state === "open")) return;
|
|
2635
|
-
records = records.map((record) => record.id === id ? { ...record, state: "closing" } : record);
|
|
2636
|
-
emit();
|
|
2637
|
-
window.setTimeout(() => remove(id), 180);
|
|
2615
|
+
function toSileoOptions({ title, description, duration, position, action }) {
|
|
2616
|
+
return {
|
|
2617
|
+
title,
|
|
2618
|
+
description,
|
|
2619
|
+
duration: duration === 0 ? null : duration,
|
|
2620
|
+
position,
|
|
2621
|
+
button: action ? { title: action.label, onClick: action.onPress } : void 0
|
|
2622
|
+
};
|
|
2638
2623
|
}
|
|
2639
|
-
function
|
|
2640
|
-
|
|
2641
|
-
|
|
2624
|
+
function create(options) {
|
|
2625
|
+
const sileoOptions = toSileoOptions(options);
|
|
2626
|
+
if (options.action) return sileo.action(sileoOptions);
|
|
2627
|
+
if (options.variant === "success") return sileo.success(sileoOptions);
|
|
2628
|
+
if (options.variant === "error") return sileo.error(sileoOptions);
|
|
2629
|
+
if (options.variant === "warning") return sileo.warning(sileoOptions);
|
|
2630
|
+
if (options.variant === "info") return sileo.info(sileoOptions);
|
|
2631
|
+
return sileo.show(sileoOptions);
|
|
2642
2632
|
}
|
|
2643
2633
|
var toast = Object.assign((options) => create(options), {
|
|
2644
2634
|
success: (title, options) => create({ ...options, title, variant: "success" }),
|
|
2645
2635
|
error: (title, options) => create({ ...options, title, variant: "error" }),
|
|
2646
2636
|
warning: (title, options) => create({ ...options, title, variant: "warning" }),
|
|
2647
2637
|
info: (title, options) => create({ ...options, title, variant: "info" }),
|
|
2648
|
-
dismiss,
|
|
2638
|
+
dismiss: (id) => sileo.dismiss(id),
|
|
2649
2639
|
promise: (promise, options) => {
|
|
2650
|
-
const
|
|
2651
|
-
|
|
2652
|
-
|
|
2640
|
+
const shared = { description: options.description, position: options.position };
|
|
2641
|
+
return sileo.promise(promise, {
|
|
2642
|
+
loading: { ...shared, title: options.loading },
|
|
2643
|
+
success: (value) => ({ ...shared, title: typeof options.success === "function" ? options.success(value) : options.success }),
|
|
2644
|
+
error: (error) => ({ ...shared, title: typeof options.error === "function" ? options.error(error) : options.error }),
|
|
2645
|
+
position: options.position
|
|
2646
|
+
});
|
|
2653
2647
|
}
|
|
2654
2648
|
});
|
|
2655
2649
|
function useToast() {
|
|
@@ -2661,38 +2655,24 @@ function ToastProvider({ children }) {
|
|
|
2661
2655
|
/* @__PURE__ */ jsx45(Toaster, {})
|
|
2662
2656
|
] });
|
|
2663
2657
|
}
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
"top-center": "top-4 left-1/2 -translate-x-1/2 items-center",
|
|
2667
|
-
"top-right": "top-4 right-4 items-end",
|
|
2668
|
-
"bottom-left": "bottom-4 left-4 items-start",
|
|
2669
|
-
"bottom-center": "bottom-4 left-1/2 -translate-x-1/2 items-center",
|
|
2670
|
-
"bottom-right": "bottom-4 right-4 items-end"
|
|
2671
|
-
};
|
|
2672
|
-
function Toaster({ position = "bottom-right" }) {
|
|
2673
|
-
return /* @__PURE__ */ jsx45(Fragment11, { children: Object.keys(positionClasses).map((item) => /* @__PURE__ */ jsx45(ToastViewport, { position: item, visiblePosition: position }, item)) });
|
|
2658
|
+
function Toaster({ position }) {
|
|
2659
|
+
return /* @__PURE__ */ jsx45(SileoToaster, { position });
|
|
2674
2660
|
}
|
|
2675
2661
|
function ToastViewport({ position, visiblePosition, className }) {
|
|
2676
|
-
|
|
2677
|
-
if (visiblePosition &&
|
|
2678
|
-
return /* @__PURE__ */ jsx45(
|
|
2662
|
+
void className;
|
|
2663
|
+
if (visiblePosition && visiblePosition !== position) return null;
|
|
2664
|
+
return /* @__PURE__ */ jsx45(Toaster, { position });
|
|
2679
2665
|
}
|
|
2680
|
-
function Toast({ id, title, description, variant = "default", action, state = "open", duration = 0, onDismiss }) {
|
|
2666
|
+
function Toast({ id, title, description, variant = "default", action, state = "open", duration = 0, position, onDismiss }) {
|
|
2681
2667
|
useEffect5(() => {
|
|
2682
|
-
if (state !== "open"
|
|
2683
|
-
const
|
|
2684
|
-
return () =>
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
/* @__PURE__ */ jsx45("p", { className: "animate-ui-toast-title text-sm font-semibold", children: title }),
|
|
2691
|
-
description && /* @__PURE__ */ jsx45("p", { className: "mt-1 max-h-20 animate-ui-toast-description overflow-hidden text-sm leading-5 text-muted-foreground data-[state=closing]:max-h-0", "data-state": state, children: description }),
|
|
2692
|
-
action && /* @__PURE__ */ jsx45(Button, { size: "sm", variant: "link", onPress: action.onPress, className: "mt-1 h-auto px-0", children: action.label })
|
|
2693
|
-
] }),
|
|
2694
|
-
/* @__PURE__ */ jsx45(Button, { "aria-label": "Cerrar notificaci\xF3n", onPress: onDismiss, size: "icon", variant: "ghost", className: "-mr-2 -mt-2 size-7", children: /* @__PURE__ */ jsx45(X3, {}) })
|
|
2695
|
-
] }) });
|
|
2668
|
+
if (state !== "open") return;
|
|
2669
|
+
const toastId = create({ title, description, variant, action, duration, position });
|
|
2670
|
+
return () => {
|
|
2671
|
+
sileo.dismiss(toastId);
|
|
2672
|
+
onDismiss?.();
|
|
2673
|
+
};
|
|
2674
|
+
}, [action, description, duration, id, onDismiss, position, state, title, variant]);
|
|
2675
|
+
return null;
|
|
2696
2676
|
}
|
|
2697
2677
|
|
|
2698
2678
|
// src/ui/toolbar/toolbar.tsx
|