@doscientos/ui 0.1.12 → 0.1.14
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 +6 -1
package/dist/index.cjs
CHANGED
|
@@ -254,12 +254,12 @@ function useAutosave({
|
|
|
254
254
|
}, []);
|
|
255
255
|
(0, import_react.useEffect)(() => {
|
|
256
256
|
if (!enabled) return;
|
|
257
|
-
const
|
|
257
|
+
const snapshot = serializeRef.current(data);
|
|
258
258
|
if (lastSaved.current === null) {
|
|
259
|
-
lastSaved.current =
|
|
259
|
+
lastSaved.current = snapshot;
|
|
260
260
|
return;
|
|
261
261
|
}
|
|
262
|
-
if (
|
|
262
|
+
if (snapshot === lastSaved.current) return;
|
|
263
263
|
const timeout = window.setTimeout(() => void save(data), debounceMs);
|
|
264
264
|
return () => window.clearTimeout(timeout);
|
|
265
265
|
}, [data, debounceMs, enabled, save]);
|
|
@@ -2744,46 +2744,40 @@ function TabsContent({ className, ...props }) {
|
|
|
2744
2744
|
|
|
2745
2745
|
// src/ui/toast/toast.tsx
|
|
2746
2746
|
var import_react12 = require("react");
|
|
2747
|
-
var
|
|
2747
|
+
var import_sileo = require("sileo");
|
|
2748
2748
|
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
};
|
|
2757
|
-
var remove = (id) => {
|
|
2758
|
-
records = records.filter((record) => record.id !== id);
|
|
2759
|
-
emit();
|
|
2760
|
-
};
|
|
2761
|
-
function create(options) {
|
|
2762
|
-
const id = `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
2763
|
-
records = [...records, { ...options, id, state: "open", variant: options.variant ?? "default", duration: options.duration ?? 5e3, position: options.position ?? "bottom-right" }];
|
|
2764
|
-
emit();
|
|
2765
|
-
return id;
|
|
2766
|
-
}
|
|
2767
|
-
function dismiss(id) {
|
|
2768
|
-
if (!records.some((record) => record.id === id && record.state === "open")) return;
|
|
2769
|
-
records = records.map((record) => record.id === id ? { ...record, state: "closing" } : record);
|
|
2770
|
-
emit();
|
|
2771
|
-
window.setTimeout(() => remove(id), 180);
|
|
2749
|
+
function toSileoOptions({ title, description, duration, position, action }) {
|
|
2750
|
+
return {
|
|
2751
|
+
title,
|
|
2752
|
+
description,
|
|
2753
|
+
duration: duration === 0 ? null : duration,
|
|
2754
|
+
position,
|
|
2755
|
+
button: action ? { title: action.label, onClick: action.onPress } : void 0
|
|
2756
|
+
};
|
|
2772
2757
|
}
|
|
2773
|
-
function
|
|
2774
|
-
|
|
2775
|
-
|
|
2758
|
+
function create(options) {
|
|
2759
|
+
const sileoOptions = toSileoOptions(options);
|
|
2760
|
+
if (options.action) return import_sileo.sileo.action(sileoOptions);
|
|
2761
|
+
if (options.variant === "success") return import_sileo.sileo.success(sileoOptions);
|
|
2762
|
+
if (options.variant === "error") return import_sileo.sileo.error(sileoOptions);
|
|
2763
|
+
if (options.variant === "warning") return import_sileo.sileo.warning(sileoOptions);
|
|
2764
|
+
if (options.variant === "info") return import_sileo.sileo.info(sileoOptions);
|
|
2765
|
+
return import_sileo.sileo.show(sileoOptions);
|
|
2776
2766
|
}
|
|
2777
2767
|
var toast = Object.assign((options) => create(options), {
|
|
2778
2768
|
success: (title, options) => create({ ...options, title, variant: "success" }),
|
|
2779
2769
|
error: (title, options) => create({ ...options, title, variant: "error" }),
|
|
2780
2770
|
warning: (title, options) => create({ ...options, title, variant: "warning" }),
|
|
2781
2771
|
info: (title, options) => create({ ...options, title, variant: "info" }),
|
|
2782
|
-
dismiss,
|
|
2772
|
+
dismiss: (id) => import_sileo.sileo.dismiss(id),
|
|
2783
2773
|
promise: (promise, options) => {
|
|
2784
|
-
const
|
|
2785
|
-
|
|
2786
|
-
|
|
2774
|
+
const shared = { description: options.description, position: options.position };
|
|
2775
|
+
return import_sileo.sileo.promise(promise, {
|
|
2776
|
+
loading: { ...shared, title: options.loading },
|
|
2777
|
+
success: (value) => ({ ...shared, title: typeof options.success === "function" ? options.success(value) : options.success }),
|
|
2778
|
+
error: (error) => ({ ...shared, title: typeof options.error === "function" ? options.error(error) : options.error }),
|
|
2779
|
+
position: options.position
|
|
2780
|
+
});
|
|
2787
2781
|
}
|
|
2788
2782
|
});
|
|
2789
2783
|
function useToast() {
|
|
@@ -2795,38 +2789,24 @@ function ToastProvider({ children }) {
|
|
|
2795
2789
|
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Toaster, {})
|
|
2796
2790
|
] });
|
|
2797
2791
|
}
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
"top-center": "top-4 left-1/2 -translate-x-1/2 items-center",
|
|
2801
|
-
"top-right": "top-4 right-4 items-end",
|
|
2802
|
-
"bottom-left": "bottom-4 left-4 items-start",
|
|
2803
|
-
"bottom-center": "bottom-4 left-1/2 -translate-x-1/2 items-center",
|
|
2804
|
-
"bottom-right": "bottom-4 right-4 items-end"
|
|
2805
|
-
};
|
|
2806
|
-
function Toaster({ position = "bottom-right" }) {
|
|
2807
|
-
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_jsx_runtime45.Fragment, { children: Object.keys(positionClasses).map((item) => /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(ToastViewport, { position: item, visiblePosition: position }, item)) });
|
|
2792
|
+
function Toaster({ position }) {
|
|
2793
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_sileo.Toaster, { position });
|
|
2808
2794
|
}
|
|
2809
2795
|
function ToastViewport({ position, visiblePosition, className }) {
|
|
2810
|
-
|
|
2811
|
-
if (visiblePosition &&
|
|
2812
|
-
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
2796
|
+
void className;
|
|
2797
|
+
if (visiblePosition && visiblePosition !== position) return null;
|
|
2798
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Toaster, { position });
|
|
2813
2799
|
}
|
|
2814
|
-
function Toast({ id, title, description, variant = "default", action, state = "open", duration = 0, onDismiss }) {
|
|
2800
|
+
function Toast({ id, title, description, variant = "default", action, state = "open", duration = 0, position, onDismiss }) {
|
|
2815
2801
|
(0, import_react12.useEffect)(() => {
|
|
2816
|
-
if (state !== "open"
|
|
2817
|
-
const
|
|
2818
|
-
return () =>
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", { className: "animate-ui-toast-title text-sm font-semibold", children: title }),
|
|
2825
|
-
description && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("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 }),
|
|
2826
|
-
action && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Button, { size: "sm", variant: "link", onPress: action.onPress, className: "mt-1 h-auto px-0", children: action.label })
|
|
2827
|
-
] }),
|
|
2828
|
-
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Button, { "aria-label": "Cerrar notificaci\xF3n", onPress: onDismiss, size: "icon", variant: "ghost", className: "-mr-2 -mt-2 size-7", children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_lucide_react14.X, {}) })
|
|
2829
|
-
] }) });
|
|
2802
|
+
if (state !== "open") return;
|
|
2803
|
+
const toastId = create({ title, description, variant, action, duration, position });
|
|
2804
|
+
return () => {
|
|
2805
|
+
import_sileo.sileo.dismiss(toastId);
|
|
2806
|
+
onDismiss?.();
|
|
2807
|
+
};
|
|
2808
|
+
}, [action, description, duration, id, onDismiss, position, state, title, variant]);
|
|
2809
|
+
return null;
|
|
2830
2810
|
}
|
|
2831
2811
|
|
|
2832
2812
|
// src/ui/toolbar/toolbar.tsx
|