@zuzjs/ui 0.8.5 → 0.8.7
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.d.ts +1 -1
- package/dist/cjs/comps/Drawer/index.d.ts +2 -1
- package/dist/cjs/comps/Drawer/index.js +2 -2
- package/dist/cjs/comps/Drawer/types.d.ts +2 -1
- package/dist/cjs/comps/List/index.d.ts +1 -1
- package/dist/cjs/comps/Sheet/index.js +1 -1
- package/dist/cjs/comps/Toast/index.js +1 -0
- package/dist/cjs/funs/css.js +2 -0
- package/dist/cjs/hooks/index.d.ts +1 -1
- package/dist/cjs/hooks/index.js +1 -1
- package/dist/cjs/hooks/useSlider.d.ts +1 -1
- package/dist/cjs/hooks/useToast.js +1 -0
- package/dist/cjs/hooks/useUploader.d.ts +5 -1
- package/dist/cjs/hooks/useUploader.js +35 -24
- package/dist/cjs/types/enums.d.ts +1 -0
- package/dist/cjs/types/enums.js +1 -0
- package/dist/css/styles.css +1 -1
- package/dist/css/transitions.css +1 -1
- package/dist/esm/comps/Alert/index.js +1 -0
- package/dist/esm/comps/Crumb/index.d.ts +1 -1
- package/dist/esm/comps/Drawer/index.d.ts +2 -1
- package/dist/esm/comps/Drawer/index.js +2 -2
- package/dist/esm/comps/Drawer/types.d.ts +2 -1
- package/dist/esm/comps/List/index.d.ts +1 -1
- package/dist/esm/comps/Sheet/index.js +1 -1
- package/dist/esm/comps/Toast/index.js +1 -0
- package/dist/esm/funs/css.js +2 -0
- package/dist/esm/hooks/index.d.ts +1 -1
- package/dist/esm/hooks/index.js +1 -1
- package/dist/esm/hooks/useSlider.d.ts +1 -1
- package/dist/esm/hooks/useToast.js +1 -0
- package/dist/esm/hooks/useUploader.d.ts +5 -1
- package/dist/esm/hooks/useUploader.js +35 -24
- package/dist/esm/types/enums.d.ts +1 -0
- package/dist/esm/types/enums.js +1 -0
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare const Crumb: import("react").ForwardRefExoticComponent<import("..").BoxProps & {
|
|
2
2
|
items: import("./types").CrumbItem[];
|
|
3
3
|
maxItems?: number;
|
|
4
|
-
} & import("react").RefAttributes<
|
|
4
|
+
} & import("react").RefAttributes<HTMLUListElement | HTMLOListElement>>;
|
|
5
5
|
export default Crumb;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
|
-
import { DRAWER_SIDE } from "../../types/enums";
|
|
2
|
+
import { DRAWER_SIDE, TRANSITION_CURVES } from "../../types/enums";
|
|
3
3
|
import { BoxProps } from "../Box";
|
|
4
4
|
import { DrawerHandler } from "./types";
|
|
5
5
|
declare const Drawer: import("react").ForwardRefExoticComponent<BoxProps & {
|
|
@@ -9,6 +9,7 @@ declare const Drawer: import("react").ForwardRefExoticComponent<BoxProps & {
|
|
|
9
9
|
children?: string | ReactNode | ReactNode[];
|
|
10
10
|
prerender?: boolean;
|
|
11
11
|
margin?: number;
|
|
12
|
+
animation?: TRANSITION_CURVES;
|
|
12
13
|
onClose?: () => void;
|
|
13
14
|
} & import("react").RefAttributes<DrawerHandler>>;
|
|
14
15
|
export default Drawer;
|
|
@@ -6,7 +6,7 @@ import { DRAWER_SIDE, KeyCode, TRANSITION_CURVES } from "../../types/enums";
|
|
|
6
6
|
import Box from "../Box";
|
|
7
7
|
import Overlay from "../Overlay";
|
|
8
8
|
const Drawer = forwardRef((props, ref) => {
|
|
9
|
-
const { from, speed, children, margin, prerender, onClose, ...pops } = props;
|
|
9
|
+
const { from, speed, children, margin, animation, prerender, onClose, ...pops } = props;
|
|
10
10
|
const [render, setRender] = useState(undefined == prerender ? true : prerender);
|
|
11
11
|
const [visible, setVisible] = useState(false);
|
|
12
12
|
const divRef = useRef(null);
|
|
@@ -60,7 +60,7 @@ const Drawer = forwardRef((props, ref) => {
|
|
|
60
60
|
from: { ..._style.from, opacity: 0 },
|
|
61
61
|
to: { ..._style.to, opacity: 1 },
|
|
62
62
|
when: visible,
|
|
63
|
-
curve: TRANSITION_CURVES.EaseInOut,
|
|
63
|
+
curve: animation || TRANSITION_CURVES.EaseInOut,
|
|
64
64
|
duration: speed || .5,
|
|
65
65
|
}, ...rest, children: [from == DRAWER_SIDE.Top || from == DRAWER_SIDE.Bottom ? _jsx(Box, { className: `--handle` }) : null, render ? content : visible ? content : null] })] });
|
|
66
66
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
|
-
import { DRAWER_SIDE } from "../../types/enums";
|
|
2
|
+
import { DRAWER_SIDE, TRANSITION_CURVES } from "../../types/enums";
|
|
3
3
|
import { BoxProps } from "../Box";
|
|
4
4
|
export type DrawerProps = BoxProps & {
|
|
5
5
|
as?: string;
|
|
@@ -8,6 +8,7 @@ export type DrawerProps = BoxProps & {
|
|
|
8
8
|
children?: string | ReactNode | ReactNode[];
|
|
9
9
|
prerender?: boolean;
|
|
10
10
|
margin?: number;
|
|
11
|
+
animation?: TRANSITION_CURVES;
|
|
11
12
|
onClose?: () => void;
|
|
12
13
|
};
|
|
13
14
|
export interface DrawerHandler {
|
|
@@ -6,5 +6,5 @@ declare const List: import("react").ForwardRefExoticComponent<import("../..").Zu
|
|
|
6
6
|
direction?: "cols" | "rows";
|
|
7
7
|
seperator?: import("react").ReactNode;
|
|
8
8
|
ol?: boolean;
|
|
9
|
-
} & import("react").RefAttributes<
|
|
9
|
+
} & import("react").RefAttributes<HTMLUListElement | HTMLOListElement>>;
|
|
10
10
|
export default List;
|
|
@@ -178,7 +178,7 @@ const Sheet = forwardRef((props, ref) => {
|
|
|
178
178
|
}
|
|
179
179
|
}, [visible]);
|
|
180
180
|
if (sheetType == SHEET.Dialog) {
|
|
181
|
-
return _jsxs(_Fragment, { children: [_jsx(Overlay, { when: visible }), _jsxs(Box, { className: `--sheet --sheet-${sheetType.toLowerCase()} ${className} fixed`.trim(), style: style, fx: buildAnimation, ...rest, ref: innerRef, children: [_jsx(Cover, { when: loading, spinner: spinner, message: loadingMessage }), _jsxs(Box, { className: `--head flex aic rel`, children: [_jsx(Box, { className: `--${title ? `title` : `dot`} flex aic rel`, children: title || `` }), _jsx(Button, { onClick: (e) => setVisible(false), className: `--closer abs`, children: "\u00D7" })] }), _jsx(Box, { className: `--body flex aic rel ${action ? `` : `--no-action`}`.trim(), children: render ? renderMessage : null }), action && _jsx(Box, { className: `--footer flex aic rel ${actionPosition ? actionPosition == SHEET_ACTION_POSITION.Center ? `jcc` : `` : `jce`}`.trim(), children: action.map((a, i) => _jsx(Button, { onClick: (e) => a.handler ? a.handler() : a.onClick ? a.onClick() : console.log(`onClick Handler missing`), className: `--action`, children: a.label }, `sheet-${sheetID}-action-${a.key}`)) })] })] });
|
|
181
|
+
return _jsxs(_Fragment, { children: [_jsx(Overlay, { when: visible }), _jsxs(Box, { className: `--sheet --sheet-${sheetType.toLowerCase()} ${visible ? `is-visible` : ``} ${className} fixed`.trim(), style: style, fx: buildAnimation, ...rest, ref: innerRef, children: [_jsx(Cover, { when: loading, spinner: spinner, message: loadingMessage }), _jsxs(Box, { className: `--head flex aic rel`, children: [_jsx(Box, { className: `--${title ? `title` : `dot`} flex aic rel`, children: title || `` }), _jsx(Button, { onClick: (e) => setVisible(false), className: `--closer abs`, children: "\u00D7" })] }), _jsx(Box, { className: `--body flex aic rel ${action ? `` : `--no-action`}`.trim(), children: render ? renderMessage : null }), action && _jsx(Box, { className: `--footer flex aic rel ${actionPosition ? actionPosition == SHEET_ACTION_POSITION.Center ? `jcc` : `` : `jce`}`.trim(), children: action.map((a, i) => _jsx(Button, { onClick: (e) => a.handler ? a.handler() : a.onClick ? a.onClick() : console.log(`onClick Handler missing`), className: `--action`, children: a.label }, `sheet-${sheetID}-action-${a.key}`)) })] })] });
|
|
182
182
|
}
|
|
183
183
|
return _jsx(Box, { className: `--sheet --sheet-${sheetType.toLowerCase()} ${className} abs`.trim(), style: style, ...rest, fx: buildAnimation, ref: innerRef, children: visible ? msg : null });
|
|
184
184
|
});
|
package/dist/cjs/funs/css.js
CHANGED
|
@@ -935,6 +935,8 @@ export const getAnimationCurve = (curve) => {
|
|
|
935
935
|
switch (curve.toUpperCase()) {
|
|
936
936
|
case TRANSITION_CURVES.Bounce:
|
|
937
937
|
return `var(--bounce)`;
|
|
938
|
+
case TRANSITION_CURVES.Liquid:
|
|
939
|
+
return `var(--liquid)`;
|
|
938
940
|
case TRANSITION_CURVES.Spring:
|
|
939
941
|
// return `cubic-bezier(0.2, -0.36, 0, 1.46)`
|
|
940
942
|
return `var(--spring)`;
|
|
@@ -29,6 +29,6 @@ export { default as useResizeObserver } from './useResizeObserver';
|
|
|
29
29
|
export { default as useSlider } from './useSlider';
|
|
30
30
|
export { default as useToast } from './useToast';
|
|
31
31
|
export { default as useTruncateText } from './useTruncateText';
|
|
32
|
-
export { default as useUploader } from './useUploader';
|
|
32
|
+
export { QueItem as UploadQueItem, Status as UploadStatus, default as useUploader, type Uploadify } from './useUploader';
|
|
33
33
|
export { default as useViewTransition } from './useViewTransition';
|
|
34
34
|
export { default as useWebSocket, type WebSocketOptions } from './useWebSocket';
|
package/dist/cjs/hooks/index.js
CHANGED
|
@@ -30,6 +30,6 @@ export { default as useResizeObserver } from './useResizeObserver';
|
|
|
30
30
|
export { default as useSlider } from './useSlider';
|
|
31
31
|
export { default as useToast } from './useToast';
|
|
32
32
|
export { default as useTruncateText } from './useTruncateText';
|
|
33
|
-
export { default as useUploader } from './useUploader';
|
|
33
|
+
export { Status as UploadStatus, default as useUploader } from './useUploader';
|
|
34
34
|
export { default as useViewTransition } from './useViewTransition';
|
|
35
35
|
export { default as useWebSocket } from './useWebSocket';
|
|
@@ -5,7 +5,8 @@ export declare enum Status {
|
|
|
5
5
|
Idle = 0,
|
|
6
6
|
FetchingServer = 1,
|
|
7
7
|
Uploading = 2,
|
|
8
|
-
Saving = 3
|
|
8
|
+
Saving = 3,
|
|
9
|
+
Saved = 4
|
|
9
10
|
}
|
|
10
11
|
export interface QueItem {
|
|
11
12
|
ID: string;
|
|
@@ -37,9 +38,12 @@ export type Uploadify = {
|
|
|
37
38
|
export interface Uploader {
|
|
38
39
|
apiUrl: string;
|
|
39
40
|
onChange?: (file: QueItem | null) => void;
|
|
41
|
+
onComplete?: (index: number, que: QueItem[], currentFile: QueItem | null) => void;
|
|
42
|
+
onError?: (index: number, que: QueItem[], currentFile: QueItem | null) => void;
|
|
40
43
|
onQueFinished?: () => void;
|
|
41
44
|
}
|
|
42
45
|
declare const useUploader: (conf: Uploader) => {
|
|
46
|
+
get: () => import("react").RefObject<Uploadify>;
|
|
43
47
|
getQue: () => QueItem[];
|
|
44
48
|
addToQue: (f: dynamic) => void;
|
|
45
49
|
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { getCancelToken, withPost } from "@zuzjs/core";
|
|
3
|
+
import { useRef } from "react";
|
|
2
4
|
import { uuid } from "..";
|
|
3
5
|
export var Status;
|
|
4
6
|
(function (Status) {
|
|
@@ -7,21 +9,22 @@ export var Status;
|
|
|
7
9
|
Status[Status["FetchingServer"] = 1] = "FetchingServer";
|
|
8
10
|
Status[Status["Uploading"] = 2] = "Uploading";
|
|
9
11
|
Status[Status["Saving"] = 3] = "Saving";
|
|
12
|
+
Status[Status["Saved"] = 4] = "Saved";
|
|
10
13
|
})(Status || (Status = {}));
|
|
11
14
|
const useUploader = (conf) => {
|
|
12
15
|
const { apiUrl, onChange, onQueFinished } = conf;
|
|
13
|
-
const self = {
|
|
16
|
+
const self = useRef({
|
|
14
17
|
que: [],
|
|
15
18
|
index: -1,
|
|
16
19
|
speed: 0,
|
|
17
20
|
stamp: null,
|
|
18
21
|
token: null,
|
|
19
22
|
status: Status.Idle
|
|
20
|
-
};
|
|
23
|
+
});
|
|
21
24
|
const sync = () => onChange?.(currentFile());
|
|
22
25
|
const importFile = () => { };
|
|
23
26
|
const uploadFile = () => {
|
|
24
|
-
self.stamp = Date.now();
|
|
27
|
+
self.current.stamp = Date.now();
|
|
25
28
|
const file = currentFile();
|
|
26
29
|
const formData = new FormData();
|
|
27
30
|
formData.append("ID", file.ID);
|
|
@@ -30,47 +33,54 @@ const useUploader = (conf) => {
|
|
|
30
33
|
formData.append("token", file.server.token);
|
|
31
34
|
formData.append('file', file.file);
|
|
32
35
|
formData.append('fs', file.file.size.toString());
|
|
33
|
-
self.cancelToken = getCancelToken();
|
|
34
|
-
withPost(`${self.que[self.index].server.uri}/receive`, formData, 86400, true, (ev) => {
|
|
35
|
-
|
|
36
|
+
self.current.cancelToken = getCancelToken();
|
|
37
|
+
withPost(`${self.current.que[self.current.index].server.uri}/receive`, formData, 86400, true, undefined, (ev) => {
|
|
38
|
+
self.current.que[self.current.index].status = Status.Uploading;
|
|
39
|
+
onChange?.({ ...currentFile(), progress: (ev.progress || 0) });
|
|
36
40
|
})
|
|
37
|
-
.
|
|
38
|
-
console.log(`Uploaded`, resp)
|
|
41
|
+
.then(resp => {
|
|
42
|
+
// console.log(`Uploaded`, resp)
|
|
43
|
+
self.current.que[self.current.index].progress = 1;
|
|
44
|
+
self.current.que[self.current.index].status = Status.Saved;
|
|
45
|
+
self.current.status = Status.Idle;
|
|
46
|
+
sync();
|
|
47
|
+
Que();
|
|
39
48
|
})
|
|
40
49
|
.catch(err => {
|
|
41
|
-
|
|
42
|
-
self.status = Status.
|
|
50
|
+
// console.error(`UploadFailed`, err)
|
|
51
|
+
self.current.que[self.current.index].status = Status.Error;
|
|
52
|
+
self.current.status = Status.Idle;
|
|
43
53
|
sync();
|
|
44
54
|
Que();
|
|
45
55
|
});
|
|
46
56
|
};
|
|
47
57
|
const getServer = (force) => {
|
|
48
|
-
self.que[self.index].status = Status.FetchingServer;
|
|
58
|
+
self.current.que[self.current.index].status = Status.FetchingServer;
|
|
49
59
|
sync();
|
|
50
60
|
withPost(`${apiUrl}get_server`, { size: currentFile().file.size })
|
|
51
61
|
.then((resp) => {
|
|
52
|
-
self.que[self.index].server = resp.server;
|
|
53
|
-
self.que[self.index].status = Status.Uploading;
|
|
62
|
+
self.current.que[self.current.index].server = resp.server;
|
|
63
|
+
self.current.que[self.current.index].status = Status.Uploading;
|
|
54
64
|
sync();
|
|
55
65
|
uploadFile();
|
|
56
66
|
})
|
|
57
67
|
.catch((err) => {
|
|
58
|
-
self.que[self.index].status = Status.Error;
|
|
59
|
-
self.status = Status.Idle;
|
|
68
|
+
self.current.que[self.current.index].status = Status.Error;
|
|
69
|
+
self.current.status = Status.Idle;
|
|
60
70
|
sync();
|
|
61
71
|
Que();
|
|
62
72
|
});
|
|
63
73
|
};
|
|
64
|
-
const currentFile = () => self.que[self.index];
|
|
65
|
-
const getQue = () => self.que;
|
|
74
|
+
const currentFile = () => self.current.que[self.current.index];
|
|
75
|
+
const getQue = () => self.current.que;
|
|
66
76
|
const Que = () => {
|
|
67
|
-
if (self.status == Status.Idle &&
|
|
68
|
-
(self.que.length - 1) > self.index) {
|
|
69
|
-
self.status = Status.Uploading;
|
|
70
|
-
self.index++;
|
|
71
|
-
self.que[self.index].status = Status.Uploading;
|
|
77
|
+
if (self.current.status == Status.Idle &&
|
|
78
|
+
(self.current.que.length - 1) > self.current.index) {
|
|
79
|
+
self.current.status = Status.Uploading;
|
|
80
|
+
self.current.index++;
|
|
81
|
+
self.current.que[self.current.index].status = Status.Uploading;
|
|
72
82
|
sync();
|
|
73
|
-
if (self.que[self.index].remote)
|
|
83
|
+
if (self.current.que[self.current.index].remote)
|
|
74
84
|
importFile();
|
|
75
85
|
else
|
|
76
86
|
getServer(true);
|
|
@@ -79,7 +89,7 @@ const useUploader = (conf) => {
|
|
|
79
89
|
onQueFinished?.();
|
|
80
90
|
};
|
|
81
91
|
const addToQue = (f) => {
|
|
82
|
-
self.que.push({
|
|
92
|
+
self.current.que.push({
|
|
83
93
|
ID: uuid(),
|
|
84
94
|
file: f.file,
|
|
85
95
|
dir: f.dir,
|
|
@@ -94,6 +104,7 @@ const useUploader = (conf) => {
|
|
|
94
104
|
Que();
|
|
95
105
|
};
|
|
96
106
|
return {
|
|
107
|
+
get: () => self,
|
|
97
108
|
getQue,
|
|
98
109
|
addToQue,
|
|
99
110
|
};
|
package/dist/cjs/types/enums.js
CHANGED
|
@@ -45,6 +45,7 @@ export var TRANSITION_CURVES;
|
|
|
45
45
|
// Ease = "EASE",
|
|
46
46
|
// EaseIn = "EASEIN",
|
|
47
47
|
// EaseOut = "EASEOUT",
|
|
48
|
+
TRANSITION_CURVES["Liquid"] = "LIQUID";
|
|
48
49
|
TRANSITION_CURVES["EaseInOut"] = "EASEINOUT";
|
|
49
50
|
TRANSITION_CURVES["Bounce"] = "BOUNCE";
|
|
50
51
|
// Linear = "LINEAR",
|