@zuzjs/ui 0.8.4 → 0.8.6
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/cjs/comps/Alert/index.js +1 -0
- package/dist/cjs/comps/Crumb/index.js +2 -2
- package/dist/cjs/comps/Drawer/index.d.ts +1 -0
- package/dist/cjs/comps/Drawer/index.js +5 -2
- package/dist/cjs/comps/Drawer/types.d.ts +1 -0
- package/dist/cjs/comps/List/index.js +7 -3
- package/dist/cjs/comps/List/item.js +1 -1
- package/dist/cjs/comps/Table/index.js +9 -3
- package/dist/cjs/comps/Table/row.js +1 -1
- package/dist/cjs/comps/Toast/index.d.ts +12 -0
- package/dist/cjs/comps/Toast/index.js +45 -0
- package/dist/cjs/comps/Toast/toast.d.ts +6 -0
- package/dist/cjs/comps/Toast/toast.js +49 -0
- package/dist/cjs/comps/Toast/types.d.ts +30 -0
- package/dist/cjs/comps/Toast/types.js +14 -0
- package/dist/cjs/comps/index.d.ts +2 -0
- package/dist/cjs/comps/index.js +2 -0
- package/dist/cjs/hooks/index.d.ts +1 -0
- package/dist/cjs/hooks/index.js +1 -0
- package/dist/cjs/hooks/useBase.js +18 -1
- package/dist/cjs/hooks/useToast.d.ts +10 -0
- package/dist/cjs/hooks/useToast.js +19 -0
- package/dist/cjs/types/interfaces.d.ts +2 -0
- package/dist/css/styles.css +1 -1
- package/dist/esm/comps/Alert/index.js +1 -0
- package/dist/esm/comps/Crumb/index.js +2 -2
- package/dist/esm/comps/Drawer/index.d.ts +1 -0
- package/dist/esm/comps/Drawer/index.js +5 -2
- package/dist/esm/comps/Drawer/types.d.ts +1 -0
- package/dist/esm/comps/List/index.js +7 -3
- package/dist/esm/comps/List/item.js +1 -1
- package/dist/esm/comps/Table/index.js +9 -3
- package/dist/esm/comps/Table/row.js +1 -1
- package/dist/esm/comps/Toast/index.d.ts +12 -0
- package/dist/esm/comps/Toast/index.js +45 -0
- package/dist/esm/comps/Toast/toast.d.ts +6 -0
- package/dist/esm/comps/Toast/toast.js +49 -0
- package/dist/esm/comps/Toast/types.d.ts +30 -0
- package/dist/esm/comps/Toast/types.js +14 -0
- package/dist/esm/comps/index.d.ts +2 -0
- package/dist/esm/comps/index.js +2 -0
- package/dist/esm/hooks/index.d.ts +1 -0
- package/dist/esm/hooks/index.js +1 -0
- package/dist/esm/hooks/useBase.js +18 -1
- package/dist/esm/hooks/useToast.d.ts +10 -0
- package/dist/esm/hooks/useToast.js +19 -0
- package/dist/esm/types/interfaces.d.ts +2 -0
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { dynamic } from "../..";
|
|
2
|
+
import { TRANSITION_CURVES } from "../../types/enums";
|
|
3
|
+
export declare enum ToastType {
|
|
4
|
+
Default = "default",
|
|
5
|
+
Success = "success",
|
|
6
|
+
Error = "error",
|
|
7
|
+
Warn = "warn",
|
|
8
|
+
Promise = "promise"
|
|
9
|
+
}
|
|
10
|
+
export declare const ToastDefaultTitle: dynamic;
|
|
11
|
+
export interface ToastData {
|
|
12
|
+
id: number;
|
|
13
|
+
type: ToastType;
|
|
14
|
+
icon?: string;
|
|
15
|
+
title?: string;
|
|
16
|
+
message?: string;
|
|
17
|
+
duration?: number;
|
|
18
|
+
onClick?: () => void;
|
|
19
|
+
}
|
|
20
|
+
export interface ToastController {
|
|
21
|
+
add: (toast: Omit<ToastData, 'id'>) => number;
|
|
22
|
+
remove: (id: number) => void;
|
|
23
|
+
clear: () => void;
|
|
24
|
+
}
|
|
25
|
+
export interface ToastContextType extends ToastController {
|
|
26
|
+
fx: {
|
|
27
|
+
curve: TRANSITION_CURVES;
|
|
28
|
+
duration: number;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export var ToastType;
|
|
2
|
+
(function (ToastType) {
|
|
3
|
+
ToastType["Default"] = "default";
|
|
4
|
+
ToastType["Success"] = "success";
|
|
5
|
+
ToastType["Error"] = "error";
|
|
6
|
+
ToastType["Warn"] = "warn";
|
|
7
|
+
ToastType["Promise"] = "promise";
|
|
8
|
+
})(ToastType || (ToastType = {}));
|
|
9
|
+
export const ToastDefaultTitle = {
|
|
10
|
+
success: "Action Successful",
|
|
11
|
+
error: "Something Went Wrong",
|
|
12
|
+
warn: "Heads Up",
|
|
13
|
+
default: "Notice"
|
|
14
|
+
};
|
|
@@ -78,6 +78,8 @@ export { default as Text, type TextProps } from './Text';
|
|
|
78
78
|
export { default as Textarea, type TextAreaProps } from './TextArea';
|
|
79
79
|
export { default as TextWheel } from './TextWheel';
|
|
80
80
|
export * from './TextWheel/types';
|
|
81
|
+
export { default as ToastProvider } from './Toast';
|
|
82
|
+
export * from './Toast/types';
|
|
81
83
|
export { default as ToolTip } from './Tooltip';
|
|
82
84
|
export * from './Tooltip/types';
|
|
83
85
|
export { default as TreeView } from './Treeview';
|
package/dist/esm/comps/index.js
CHANGED
|
@@ -78,6 +78,8 @@ export { default as Text } from './Text';
|
|
|
78
78
|
export { default as Textarea } from './TextArea';
|
|
79
79
|
export { default as TextWheel } from './TextWheel';
|
|
80
80
|
export * from './TextWheel/types';
|
|
81
|
+
export { default as ToastProvider } from './Toast';
|
|
82
|
+
export * from './Toast/types';
|
|
81
83
|
export { default as ToolTip } from './Tooltip';
|
|
82
84
|
export * from './Tooltip/types';
|
|
83
85
|
export { default as TreeView } from './Treeview';
|
|
@@ -27,6 +27,7 @@ export { default as useShortcuts } from './useShortcuts';
|
|
|
27
27
|
export { default as useNetworkStatus } from './useNetworkStatus';
|
|
28
28
|
export { default as useResizeObserver } from './useResizeObserver';
|
|
29
29
|
export { default as useSlider } from './useSlider';
|
|
30
|
+
export { default as useToast } from './useToast';
|
|
30
31
|
export { default as useTruncateText } from './useTruncateText';
|
|
31
32
|
export { default as useUploader } from './useUploader';
|
|
32
33
|
export { default as useViewTransition } from './useViewTransition';
|
package/dist/esm/hooks/index.js
CHANGED
|
@@ -28,6 +28,7 @@ export { default as useShortcuts } from './useShortcuts';
|
|
|
28
28
|
export { default as useNetworkStatus } from './useNetworkStatus';
|
|
29
29
|
export { default as useResizeObserver } from './useResizeObserver';
|
|
30
30
|
export { default as useSlider } from './useSlider';
|
|
31
|
+
export { default as useToast } from './useToast';
|
|
31
32
|
export { default as useTruncateText } from './useTruncateText';
|
|
32
33
|
export { default as useUploader } from './useUploader';
|
|
33
34
|
export { default as useViewTransition } from './useViewTransition';
|
|
@@ -34,7 +34,7 @@ const useBase = (props) => {
|
|
|
34
34
|
if (as) {
|
|
35
35
|
cx = css().Build(`string` == typeof as ? as : as.join(` `)).cx;
|
|
36
36
|
}
|
|
37
|
-
const { transition, from, to, when, duration, delay, curve } = autoTransition ? {
|
|
37
|
+
const { transition, from, to, exit, when, duration, delay, curve } = autoTransition ? {
|
|
38
38
|
transition: autoTransition,
|
|
39
39
|
duration: 0.3
|
|
40
40
|
} : fx || animate || {};
|
|
@@ -48,6 +48,23 @@ const useBase = (props) => {
|
|
|
48
48
|
else {
|
|
49
49
|
_style = transition ? getAnimationTransition(transition, false, true) : from || {};
|
|
50
50
|
}
|
|
51
|
+
// Track previous value of 'when'
|
|
52
|
+
// const prevWhenRef = useRef<boolean | undefined>(when);
|
|
53
|
+
// if (undefined === when) {
|
|
54
|
+
// _style = transition ? getAnimationTransition(transition, true) : { ...from, ...to };
|
|
55
|
+
// } else if (true === when) {
|
|
56
|
+
// _style = transition ? getAnimationTransition(transition, false) : { ...(to || {}) };
|
|
57
|
+
// } else {
|
|
58
|
+
// // Check if exit style should be applied
|
|
59
|
+
// const wasTrue = prevWhenRef.current === true;
|
|
60
|
+
// if (wasTrue && exit) {
|
|
61
|
+
// _style = { ...(exit || {}) };
|
|
62
|
+
// } else {
|
|
63
|
+
// _style = transition ? getAnimationTransition(transition, false, true) : from || {};
|
|
64
|
+
// }
|
|
65
|
+
// }
|
|
66
|
+
// // Update previous value for next render
|
|
67
|
+
// prevWhenRef.current = when;
|
|
51
68
|
const _transition = {};
|
|
52
69
|
if (transition || (from && to)) {
|
|
53
70
|
// { transition: `all ${duration || `0.2`}s ${getAnimationCurve(curve)} ${delay || 0}s` }
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const useToast: () => {
|
|
2
|
+
show: (title: string, message?: string, icon?: string, duration?: number) => number;
|
|
3
|
+
hide: (id: number) => void;
|
|
4
|
+
success: (title: string, message?: string, icon?: string, duration?: number) => number;
|
|
5
|
+
error: (title: string, message?: string, icon?: string, duration?: number) => number;
|
|
6
|
+
warn: (title: string, message?: string, icon?: string, duration?: number) => number;
|
|
7
|
+
promise: (title: string, message?: string, icon?: string, duration?: number) => number;
|
|
8
|
+
clearAll: () => void;
|
|
9
|
+
};
|
|
10
|
+
export default useToast;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useContext } from "react";
|
|
3
|
+
import { ToastContext } from "../comps/Toast";
|
|
4
|
+
import { ToastType } from "../comps/Toast/types";
|
|
5
|
+
const useToast = () => {
|
|
6
|
+
const ctx = useContext(ToastContext);
|
|
7
|
+
if (!ctx)
|
|
8
|
+
throw new Error('useToast must be used inside <ToastProvider>');
|
|
9
|
+
const base = (type, data) => ctx.add({ ...data, type });
|
|
10
|
+
const clearAll = () => ctx.clear();
|
|
11
|
+
const hide = (id) => ctx.remove(id);
|
|
12
|
+
const show = (title, message, icon, duration) => base(ToastType.Default, { title, message, icon, duration });
|
|
13
|
+
const success = (title, message, icon, duration) => base(ToastType.Success, { title, message, icon, duration });
|
|
14
|
+
const error = (title, message, icon, duration) => base(ToastType.Error, { title, message, icon, duration });
|
|
15
|
+
const warn = (title, message, icon, duration) => base(ToastType.Warn, { title, message, icon, duration });
|
|
16
|
+
const promise = (title, message, icon, duration) => base(ToastType.Promise, { title, message, icon, duration });
|
|
17
|
+
return { show, hide, success, error, warn, promise, clearAll };
|
|
18
|
+
};
|
|
19
|
+
export default useToast;
|
|
@@ -16,6 +16,8 @@ export interface animationProps {
|
|
|
16
16
|
from?: dynamicObject;
|
|
17
17
|
/** Target style properties after the animation completes */
|
|
18
18
|
to?: dynamicObject;
|
|
19
|
+
/** Target style properties for exit animation */
|
|
20
|
+
exit?: dynamicObject;
|
|
19
21
|
/** Condition that determines when the animation should trigger */
|
|
20
22
|
when?: boolean;
|
|
21
23
|
/** Duration of the animation in milliseconds */
|