@vetc-miniapp/ui-react 0.0.24 → 0.0.26
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/bridge.d.ts +17 -0
- package/dist/bridge.js +20 -0
- package/dist/components/app.d.ts +17 -0
- package/dist/components/app.js +34 -0
- package/dist/components/avatar/Avatar.d.ts +21 -0
- package/dist/components/avatar/Avatar.js +33 -0
- package/dist/components/avatar/index.js +1 -0
- package/dist/components/bottom-sheet/BottomSheet.d.ts +19 -0
- package/dist/components/bottom-sheet/BottomSheet.js +70 -0
- package/dist/components/bottom-sheet/index.js +1 -0
- package/dist/components/button/Button.d.ts +32 -0
- package/dist/components/button/Button.js +165 -0
- package/dist/components/button/index.js +1 -0
- package/dist/components/button-group/ButtonGroup.d.ts +28 -0
- package/dist/components/button-group/ButtonGroup.js +21 -0
- package/dist/components/button-group/index.js +1 -0
- package/dist/components/card/Card.d.ts +18 -0
- package/dist/components/card/Card.js +35 -0
- package/dist/components/card/index.js +1 -0
- package/dist/components/checkbox/Checkbox.d.ts +41 -0
- package/dist/components/checkbox/Checkbox.js +94 -0
- package/dist/components/checkbox/index.js +1 -0
- package/dist/components/chip/Chip.d.ts +24 -0
- package/dist/components/chip/Chip.js +83 -0
- package/dist/components/chip/index.js +1 -0
- package/dist/components/dialog/Dialog.d.ts +19 -0
- package/dist/components/dialog/Dialog.js +51 -0
- package/dist/components/dialog/index.js +1 -0
- package/dist/components/divider/Divider.d.ts +16 -0
- package/dist/components/divider/Divider.js +18 -0
- package/dist/components/divider/index.js +1 -0
- package/dist/components/input/Input.d.ts +40 -0
- package/dist/components/input/Input.js +51 -0
- package/dist/components/input/index.js +1 -0
- package/dist/components/list/List.d.ts +31 -0
- package/dist/components/list/List.js +72 -0
- package/dist/components/list/index.js +1 -0
- package/dist/components/loading/Loading.d.ts +28 -0
- package/dist/components/loading/Loading.js +33 -0
- package/dist/components/loading/index.js +1 -0
- package/dist/components/modal/Modal.d.ts +38 -0
- package/dist/components/modal/Modal.js +50 -0
- package/dist/components/modal/index.js +1 -0
- package/dist/components/navigation-bar/NavigationBar.d.ts +44 -0
- package/dist/components/navigation-bar/NavigationBar.js +70 -0
- package/dist/components/navigation-bar/index.js +1 -0
- package/dist/components/radio/Radio.d.ts +40 -0
- package/dist/components/radio/Radio.js +88 -0
- package/dist/components/radio/index.js +1 -0
- package/dist/components/select/Select.d.ts +29 -0
- package/dist/components/select/Select.js +30 -0
- package/dist/components/select/index.js +1 -0
- package/dist/components/switch/Switch.d.ts +23 -0
- package/dist/components/switch/Switch.js +81 -0
- package/dist/components/switch/index.js +1 -0
- package/dist/components/tab-bar/TabBar.d.ts +28 -0
- package/dist/components/tab-bar/TabBar.js +60 -0
- package/dist/components/tab-bar/index.js +1 -0
- package/dist/components/textarea/Textarea.d.ts +31 -0
- package/dist/components/textarea/Textarea.js +33 -0
- package/dist/components/textarea/index.js +1 -0
- package/dist/components/toast/Toast.d.ts +41 -0
- package/dist/components/toast/Toast.js +61 -0
- package/dist/components/toast/index.js +1 -0
- package/dist/components/typography/Typography.d.ts +45 -0
- package/dist/components/typography/Typography.js +143 -0
- package/dist/components/typography/index.js +1 -0
- package/dist/hooks/use-app-pause.d.ts +4 -0
- package/dist/hooks/use-app-pause.js +25 -0
- package/dist/hooks/use-app-resume.d.ts +4 -0
- package/dist/hooks/use-app-resume.js +25 -0
- package/{src/ui-react/hooks/use-app-state.ts → dist/hooks/use-app-state.d.ts} +0 -1
- package/dist/hooks/use-app-state.js +1 -0
- package/dist/hooks/use-did-hide.d.ts +6 -0
- package/dist/hooks/use-did-hide.js +20 -0
- package/dist/hooks/use-did-show.d.ts +6 -0
- package/dist/hooks/use-did-show.js +20 -0
- package/dist/hooks/use-listener-scan-qr.d.ts +10 -0
- package/dist/hooks/use-listener-scan-qr.js +25 -0
- package/dist/hooks/use-navigate.d.ts +8 -0
- package/dist/hooks/use-navigate.js +23 -0
- package/dist/hooks/use-tap-app-bar.d.ts +6 -0
- package/dist/hooks/use-tap-app-bar.js +20 -0
- package/{src/ui-react/index.ts → dist/index.d.ts} +1 -30
- package/dist/index.js +41 -0
- package/dist/styles/VETCProvider.d.ts +114 -0
- package/dist/styles/VETCProvider.js +124 -0
- package/{src/ui-react → dist}/styles/tokens.css +22 -1
- package/dist/tokens/colors.d.ts +127 -0
- package/dist/tokens/colors.js +75 -0
- package/dist/tokens/index.js +3 -0
- package/dist/tokens/spacing.d.ts +56 -0
- package/dist/tokens/spacing.js +56 -0
- package/dist/tokens/typography.d.ts +121 -0
- package/dist/tokens/typography.js +57 -0
- package/dist/types/app.d.ts +21 -0
- package/dist/types/app.js +1 -0
- package/package.json +13 -7
- package/src/dist/ui-react/index.js +0 -2
- package/src/dist/ui-react/index.js.LICENSE.txt +0 -11
- package/src/ui-react/bridge.js +0 -36
- package/src/ui-react/bridge.ts +0 -48
- package/src/ui-react/components/app.d.ts +0 -7
- package/src/ui-react/components/app.jsx +0 -80
- package/src/ui-react/components/app.tsx +0 -42
- package/src/ui-react/components/app1.js +0 -101
- package/src/ui-react/components/avatar/Avatar.tsx +0 -88
- package/src/ui-react/components/bottom-sheet/BottomSheet.tsx +0 -149
- package/src/ui-react/components/button/Button.tsx +0 -246
- package/src/ui-react/components/button-group/ButtonGroup.tsx +0 -108
- package/src/ui-react/components/card/Card.tsx +0 -77
- package/src/ui-react/components/checkbox/Checkbox.tsx +0 -232
- package/src/ui-react/components/chip/Chip.tsx +0 -137
- package/src/ui-react/components/dialog/Dialog.tsx +0 -135
- package/src/ui-react/components/divider/Divider.tsx +0 -54
- package/src/ui-react/components/input/Input.tsx +0 -195
- package/src/ui-react/components/list/List.tsx +0 -180
- package/src/ui-react/components/loading/Loading.tsx +0 -121
- package/src/ui-react/components/modal/Modal.tsx +0 -116
- package/src/ui-react/components/navigation-bar/NavigationBar.tsx +0 -188
- package/src/ui-react/components/radio/Radio.tsx +0 -216
- package/src/ui-react/components/select/Select.tsx +0 -109
- package/src/ui-react/components/switch/Switch.tsx +0 -164
- package/src/ui-react/components/tab-bar/TabBar.tsx +0 -137
- package/src/ui-react/components/textarea/Textarea.tsx +0 -109
- package/src/ui-react/components/toast/Toast.ts +0 -98
- package/src/ui-react/components/typography/Typography.tsx +0 -201
- package/src/ui-react/hooks/use-app-pause.js +0 -35
- package/src/ui-react/hooks/use-app-pause.ts +0 -33
- package/src/ui-react/hooks/use-app-resume.js +0 -37
- package/src/ui-react/hooks/use-app-resume.ts +0 -32
- package/src/ui-react/hooks/use-app-state.js +0 -35
- package/src/ui-react/hooks/use-did-hide.js +0 -25
- package/src/ui-react/hooks/use-did-hide.ts +0 -34
- package/src/ui-react/hooks/use-did-show.js +0 -26
- package/src/ui-react/hooks/use-did-show.ts +0 -34
- package/src/ui-react/hooks/use-listener-scan-qr.js +0 -33
- package/src/ui-react/hooks/use-listener-scan-qr.ts +0 -52
- package/src/ui-react/hooks/use-navigate.js +0 -15
- package/src/ui-react/hooks/use-navigate.ts +0 -41
- package/src/ui-react/hooks/use-tap-app-bar.js +0 -26
- package/src/ui-react/hooks/use-tap-app-bar.ts +0 -34
- package/src/ui-react/index.js +0 -9
- package/src/ui-react/styles/VETCProvider.tsx +0 -152
- package/src/ui-react/tokens/colors.ts +0 -91
- package/src/ui-react/tokens/spacing.ts +0 -59
- package/src/ui-react/tokens/typography.ts +0 -63
- package/src/ui-react/tokens_vetc.json +0 -1517
- package/src/ui-react/types/app.js +0 -30
- package/src/ui-react/types/app.ts +0 -32
- /package/{src/ui-react/components/avatar/index.ts → dist/components/avatar/index.d.ts} +0 -0
- /package/{src/ui-react/components/bottom-sheet/index.ts → dist/components/bottom-sheet/index.d.ts} +0 -0
- /package/{src/ui-react/components/button/index.ts → dist/components/button/index.d.ts} +0 -0
- /package/{src/ui-react/components/button-group/index.ts → dist/components/button-group/index.d.ts} +0 -0
- /package/{src/ui-react/components/card/index.ts → dist/components/card/index.d.ts} +0 -0
- /package/{src/ui-react/components/checkbox/index.ts → dist/components/checkbox/index.d.ts} +0 -0
- /package/{src/ui-react/components/chip/index.ts → dist/components/chip/index.d.ts} +0 -0
- /package/{src/ui-react/components/dialog/index.ts → dist/components/dialog/index.d.ts} +0 -0
- /package/{src/ui-react/components/divider/index.ts → dist/components/divider/index.d.ts} +0 -0
- /package/{src/ui-react/components/input/index.ts → dist/components/input/index.d.ts} +0 -0
- /package/{src/ui-react/components/list/index.ts → dist/components/list/index.d.ts} +0 -0
- /package/{src/ui-react/components/loading/index.ts → dist/components/loading/index.d.ts} +0 -0
- /package/{src/ui-react/components/modal/index.ts → dist/components/modal/index.d.ts} +0 -0
- /package/{src/ui-react/components/navigation-bar/index.ts → dist/components/navigation-bar/index.d.ts} +0 -0
- /package/{src/ui-react/components/radio/index.ts → dist/components/radio/index.d.ts} +0 -0
- /package/{src/ui-react/components/select/index.ts → dist/components/select/index.d.ts} +0 -0
- /package/{src/ui-react/components/switch/index.ts → dist/components/switch/index.d.ts} +0 -0
- /package/{src/ui-react/components/tab-bar/index.ts → dist/components/tab-bar/index.d.ts} +0 -0
- /package/{src/ui-react/components/textarea/index.ts → dist/components/textarea/index.d.ts} +0 -0
- /package/{src/ui-react/components/toast/index.ts → dist/components/toast/index.d.ts} +0 -0
- /package/{src/ui-react/components/typography/index.ts → dist/components/typography/index.d.ts} +0 -0
- /package/{src/ui-react/tokens/index.ts → dist/tokens/index.d.ts} +0 -0
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {"light" | "dark"} ThemeMode
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @typedef {Object} IAppState
|
|
7
|
-
* @property {string=} locale
|
|
8
|
-
* @property {ThemeMode=} theme
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @typedef {Object} IPageConfig
|
|
13
|
-
* @property {string} key - Key định danh page dùng cho navigation
|
|
14
|
-
* @property {string=} title - Tên hiển thị (header native)
|
|
15
|
-
* @property {string} url - URL nội bộ miniapp (nếu cần render state)
|
|
16
|
-
* @property {boolean=} canGoBack - Có cho phép back không
|
|
17
|
-
* @property {boolean=} isRoot - Có phải root page không
|
|
18
|
-
* @property {Object<string, any>=} defaultParams - Params mặc định khi mở page
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @typedef {Object} IAppConfig
|
|
23
|
-
* @property {IPageConfig[]} pages
|
|
24
|
-
* @property {string=} locale
|
|
25
|
-
* @property {ThemeMode=} theme
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
/** @type {IAppConfig} */
|
|
29
|
-
export const appConfig = {
|
|
30
|
-
locale: "vi",
|
|
31
|
-
theme: "light",
|
|
32
|
-
|
|
33
|
-
pages: [
|
|
34
|
-
]
|
|
35
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from "react";
|
|
2
|
-
|
|
3
|
-
export function useDidHide(route, callback) {
|
|
4
|
-
const saved = useRef(callback);
|
|
5
|
-
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
saved.current = callback;
|
|
8
|
-
}, [callback]);
|
|
9
|
-
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
if (!window.MiniApp) return;
|
|
12
|
-
|
|
13
|
-
const handler = (data) => {
|
|
14
|
-
if (data?.route === route) {
|
|
15
|
-
saved.current?.(data);
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
window.MiniApp.on("didHide", handler);
|
|
20
|
-
|
|
21
|
-
return () => {
|
|
22
|
-
window.MiniApp.off("didHide", handler);
|
|
23
|
-
};
|
|
24
|
-
}, [route]);
|
|
25
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from "react";
|
|
2
|
-
|
|
3
|
-
type DidHidePayload = {
|
|
4
|
-
route?: string;
|
|
5
|
-
[key: string]: any;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export function useDidHide(
|
|
9
|
-
route: string,
|
|
10
|
-
callback: (data?: DidHidePayload) => void
|
|
11
|
-
): void {
|
|
12
|
-
const saved = useRef(callback);
|
|
13
|
-
|
|
14
|
-
// luôn giữ callback mới nhất
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
saved.current = callback;
|
|
17
|
-
}, [callback]);
|
|
18
|
-
|
|
19
|
-
useEffect(() => {
|
|
20
|
-
if (typeof window === "undefined" || !window.MiniApp) return;
|
|
21
|
-
|
|
22
|
-
const handler = (data?: DidHidePayload) => {
|
|
23
|
-
if (data?.route === route) {
|
|
24
|
-
saved.current?.(data);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
window.MiniApp.on("didHide", handler);
|
|
29
|
-
|
|
30
|
-
return () => {
|
|
31
|
-
window.MiniApp.off("didHide", handler);
|
|
32
|
-
};
|
|
33
|
-
}, [route]);
|
|
34
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from "react";
|
|
2
|
-
|
|
3
|
-
export function useDidShow(route, callback) {
|
|
4
|
-
const saved = useRef(callback);
|
|
5
|
-
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
saved.current = callback;
|
|
8
|
-
}, [callback]);
|
|
9
|
-
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
if (!window.MiniApp) return;
|
|
12
|
-
|
|
13
|
-
const handler = (data) => {
|
|
14
|
-
if (data?.route === route) {
|
|
15
|
-
console.log("didShow", data)
|
|
16
|
-
saved.current?.(data);
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
window.MiniApp.on("didShow", handler);
|
|
21
|
-
|
|
22
|
-
return () => {
|
|
23
|
-
window.MiniApp.off("didShow", handler);
|
|
24
|
-
};
|
|
25
|
-
}, [route]);
|
|
26
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from "react";
|
|
2
|
-
|
|
3
|
-
type DidShowPayload = {
|
|
4
|
-
route?: string;
|
|
5
|
-
[key: string]: any;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export function useDidShow(
|
|
9
|
-
route: string,
|
|
10
|
-
callback: (data?: DidShowPayload) => void
|
|
11
|
-
): void {
|
|
12
|
-
const saved = useRef(callback);
|
|
13
|
-
|
|
14
|
-
// luôn giữ callback mới nhất
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
saved.current = callback;
|
|
17
|
-
}, [callback]);
|
|
18
|
-
|
|
19
|
-
useEffect(() => {
|
|
20
|
-
if (typeof window === "undefined" || !window.MiniApp) return;
|
|
21
|
-
|
|
22
|
-
const handler = (data?: DidShowPayload) => {
|
|
23
|
-
if (data?.route === route) {
|
|
24
|
-
saved.current?.(data);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
window.MiniApp.on("didShow", handler);
|
|
29
|
-
|
|
30
|
-
return () => {
|
|
31
|
-
window.MiniApp.off("didShow", handler);
|
|
32
|
-
};
|
|
33
|
-
}, [route]);
|
|
34
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from "react";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* useListenerScanQr
|
|
5
|
-
*
|
|
6
|
-
* Lắng nghe kết quả scan QR từ Native
|
|
7
|
-
*/
|
|
8
|
-
export function useListenerScanQr(callback) {
|
|
9
|
-
const savedCallback = useRef(callback);
|
|
10
|
-
|
|
11
|
-
// luôn giữ callback mới nhất
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
savedCallback.current = callback;
|
|
14
|
-
}, [callback]);
|
|
15
|
-
|
|
16
|
-
useEffect(() => {
|
|
17
|
-
if (typeof window === "undefined" || !window.MiniApp) return;
|
|
18
|
-
|
|
19
|
-
const handler = (data) => {
|
|
20
|
-
try {
|
|
21
|
-
savedCallback.current?.(data);
|
|
22
|
-
} catch (err) {
|
|
23
|
-
console.error("[useListenerScanQr error]", err);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
window.MiniApp.on("onScanQRResult", handler);
|
|
28
|
-
|
|
29
|
-
return () => {
|
|
30
|
-
window.MiniApp.off("onScanQRResult", handler);
|
|
31
|
-
};
|
|
32
|
-
}, []);
|
|
33
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from "react";
|
|
2
|
-
|
|
3
|
-
type ScanQrResult = {
|
|
4
|
-
raw: string;
|
|
5
|
-
type?: string;
|
|
6
|
-
[key: string]: any;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
type MiniAppBridge = {
|
|
10
|
-
on: (event: string, callback: (data: any) => void) => void;
|
|
11
|
-
off: (event: string, callback: (data: any) => void) => void;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
declare global {
|
|
15
|
-
interface Window {
|
|
16
|
-
MiniApp?: MiniAppBridge;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* useListenerScanQr
|
|
22
|
-
*
|
|
23
|
-
* Lắng nghe kết quả scan QR từ Native
|
|
24
|
-
*/
|
|
25
|
-
export function useListenerScanQr(
|
|
26
|
-
callback: (data: ScanQrResult) => void
|
|
27
|
-
): void {
|
|
28
|
-
const savedCallback = useRef(callback);
|
|
29
|
-
|
|
30
|
-
// luôn giữ callback mới nhất
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
savedCallback.current = callback;
|
|
33
|
-
}, [callback]);
|
|
34
|
-
|
|
35
|
-
useEffect(() => {
|
|
36
|
-
if (typeof window === "undefined" || !window.MiniApp) return;
|
|
37
|
-
|
|
38
|
-
const handler = (data: ScanQrResult) => {
|
|
39
|
-
try {
|
|
40
|
-
savedCallback.current?.(data);
|
|
41
|
-
} catch (err) {
|
|
42
|
-
console.error("[useListenerScanQr error]", err);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
window.MiniApp.on("scanQrResult", handler);
|
|
47
|
-
|
|
48
|
-
return () => {
|
|
49
|
-
window.MiniApp.off("scanQrResult", handler);
|
|
50
|
-
};
|
|
51
|
-
}, []);
|
|
52
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { callHost } from '../bridge.js';
|
|
2
|
-
|
|
3
|
-
export function useNavigate() {
|
|
4
|
-
return (route, params = {}, options = {}) => {
|
|
5
|
-
// POP navigation
|
|
6
|
-
if (typeof route === "number") {
|
|
7
|
-
return callHost("navigate", {
|
|
8
|
-
type: "native",
|
|
9
|
-
action: "pop",
|
|
10
|
-
delta: Math.abs(route)
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
callHost("navigate", { type: "native", action: "push", route, params, options });
|
|
14
|
-
};
|
|
15
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { callHost } from "../bridge";
|
|
2
|
-
|
|
3
|
-
/* ================= Types ================= */
|
|
4
|
-
|
|
5
|
-
export type NavigateMode = "push" | "replace";
|
|
6
|
-
|
|
7
|
-
export interface NavigateOptions {
|
|
8
|
-
replace?: boolean;
|
|
9
|
-
popTo?: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export type NavigateParams = Record<string, unknown>;
|
|
13
|
-
|
|
14
|
-
export type MiniAppRoute = string | number; // có thể đổi sang union type nếu muốn strict
|
|
15
|
-
|
|
16
|
-
/* ================= Hook ================= */
|
|
17
|
-
|
|
18
|
-
export function useNavigate() {
|
|
19
|
-
return (
|
|
20
|
-
route: MiniAppRoute,
|
|
21
|
-
params: NavigateParams = {},
|
|
22
|
-
options: NavigateOptions = {}
|
|
23
|
-
): void => {
|
|
24
|
-
// POP navigation
|
|
25
|
-
if (typeof route === "number") {
|
|
26
|
-
return callHost("navigate", {
|
|
27
|
-
type: "native",
|
|
28
|
-
action: "pop",
|
|
29
|
-
delta: Math.abs(route),
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
// Gửi sang native host
|
|
33
|
-
callHost("navigate", {
|
|
34
|
-
type: "native",
|
|
35
|
-
action: "push",
|
|
36
|
-
route,
|
|
37
|
-
params,
|
|
38
|
-
options,
|
|
39
|
-
}).catch(console.error);
|
|
40
|
-
};
|
|
41
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from "react";
|
|
2
|
-
|
|
3
|
-
export function useTapAppBar(route, callback) {
|
|
4
|
-
const saved = useRef(callback);
|
|
5
|
-
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
saved.current = callback;
|
|
8
|
-
}, [callback]);
|
|
9
|
-
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
if (!window.MiniApp) return;
|
|
12
|
-
|
|
13
|
-
const handler = (data) => {
|
|
14
|
-
if (data?.route === route) {
|
|
15
|
-
console.log("onTapAppBar", data)
|
|
16
|
-
saved.current?.(data);
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
window.MiniApp.on("onTapAppBar", handler);
|
|
21
|
-
|
|
22
|
-
return () => {
|
|
23
|
-
window.MiniApp.off("onTapAppBar", handler);
|
|
24
|
-
};
|
|
25
|
-
}, [route]);
|
|
26
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from "react";
|
|
2
|
-
|
|
3
|
-
type TapAppBarPayload = {
|
|
4
|
-
route?: string;
|
|
5
|
-
[key: string]: any;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export function useTapAppBar(
|
|
9
|
-
route: string,
|
|
10
|
-
callback: (data?: TapAppBarPayload) => void
|
|
11
|
-
): void {
|
|
12
|
-
const saved = useRef(callback);
|
|
13
|
-
|
|
14
|
-
// luôn giữ callback mới nhất
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
saved.current = callback;
|
|
17
|
-
}, [callback]);
|
|
18
|
-
|
|
19
|
-
useEffect(() => {
|
|
20
|
-
if (typeof window === "undefined" || !window.MiniApp) return;
|
|
21
|
-
|
|
22
|
-
const handler = (data?: TapAppBarPayload) => {
|
|
23
|
-
if (data?.route === route) {
|
|
24
|
-
saved.current?.(data);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
window.MiniApp.on("onTapAppBar", handler);
|
|
29
|
-
|
|
30
|
-
return () => {
|
|
31
|
-
window.MiniApp.off("onTapAppBar", handler);
|
|
32
|
-
};
|
|
33
|
-
}, [route]);
|
|
34
|
-
}
|
package/src/ui-react/index.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export * from './hooks/use-app-pause.js';
|
|
2
|
-
export * from './hooks/use-app-resume.js';
|
|
3
|
-
export * from './hooks/use-did-show.js';
|
|
4
|
-
export * from './hooks/use-did-hide.js';
|
|
5
|
-
export * from './hooks/use-tap-app-bar.js';
|
|
6
|
-
export * from './hooks/use-navigate.js';
|
|
7
|
-
export * from './hooks/use-app-state.js';
|
|
8
|
-
export * from './hooks/use-listener-scan-qr.js';
|
|
9
|
-
export * from './components/app.jsx';
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* VETC Design System — Ant Design Theme Provider
|
|
3
|
-
* Wraps children with ConfigProvider using VETC token overrides.
|
|
4
|
-
*/
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import { ConfigProvider, App as AntApp, theme } from 'antd';
|
|
7
|
-
import { colorAlias, colorGlobal } from '../tokens/colors';
|
|
8
|
-
|
|
9
|
-
export const vetcAntdTheme = {
|
|
10
|
-
token: {
|
|
11
|
-
// Brand / Primary
|
|
12
|
-
colorPrimary: colorAlias.brand, // #25a45e
|
|
13
|
-
colorPrimaryHover: colorGlobal.green35,
|
|
14
|
-
colorPrimaryActive: colorAlias.brandDark,
|
|
15
|
-
colorPrimaryBg: colorGlobal.green02,
|
|
16
|
-
colorPrimaryBgHover: colorGlobal.green05,
|
|
17
|
-
|
|
18
|
-
// Error / Danger
|
|
19
|
-
colorError: colorAlias.negative, // #da2c39
|
|
20
|
-
colorErrorHover: colorGlobal.red60,
|
|
21
|
-
colorErrorBg: colorGlobal.red02,
|
|
22
|
-
|
|
23
|
-
// Warning
|
|
24
|
-
colorWarning: colorAlias.warning, // #ff8c2f
|
|
25
|
-
colorWarningBg: colorGlobal.orange02,
|
|
26
|
-
|
|
27
|
-
// Success
|
|
28
|
-
colorSuccess: colorAlias.positive, // #208758
|
|
29
|
-
colorSuccessBg: colorGlobal.green02,
|
|
30
|
-
|
|
31
|
-
// Text
|
|
32
|
-
colorText: colorAlias.primaryOnTheme, // #181719
|
|
33
|
-
colorTextSecondary: colorAlias.secondaryOnTheme, // #5e5d64
|
|
34
|
-
colorTextDisabled: colorAlias.disabledContent, // #abacb2
|
|
35
|
-
colorTextPlaceholder: colorGlobal.gray50,
|
|
36
|
-
|
|
37
|
-
// Background
|
|
38
|
-
colorBgContainer: colorAlias.theme, // #ffffff
|
|
39
|
-
colorBgLayout: colorAlias.themeVariant, // #f1f1f2
|
|
40
|
-
colorBgSpotlight: colorAlias.inverseTheme,
|
|
41
|
-
|
|
42
|
-
// Border
|
|
43
|
-
colorBorder: colorGlobal.gray20, // #c6c8cc
|
|
44
|
-
colorBorderSecondary: colorGlobal.gray10, // #e3e4e6
|
|
45
|
-
colorSplit: colorGlobal.gray10,
|
|
46
|
-
|
|
47
|
-
// Fill states
|
|
48
|
-
colorFill: colorGlobal.gray05,
|
|
49
|
-
colorFillSecondary: colorGlobal.gray10,
|
|
50
|
-
colorFillTertiary: colorGlobal.gray15,
|
|
51
|
-
|
|
52
|
-
// Typography
|
|
53
|
-
fontFamily: '"Roboto", system-ui, -apple-system, sans-serif',
|
|
54
|
-
fontSize: 16,
|
|
55
|
-
fontSizeSM: 13,
|
|
56
|
-
fontSizeLG: 18,
|
|
57
|
-
fontSizeXL: 19,
|
|
58
|
-
fontSizeHeading1: 32,
|
|
59
|
-
fontSizeHeading2: 28,
|
|
60
|
-
fontSizeHeading3: 24,
|
|
61
|
-
fontSizeHeading4: 19,
|
|
62
|
-
fontSizeHeading5: 16,
|
|
63
|
-
fontWeightStrong: 600,
|
|
64
|
-
lineHeight: 1.5,
|
|
65
|
-
|
|
66
|
-
// Shape
|
|
67
|
-
borderRadius: 8,
|
|
68
|
-
borderRadiusSM: 6,
|
|
69
|
-
borderRadiusLG: 12,
|
|
70
|
-
borderRadiusXS: 4,
|
|
71
|
-
|
|
72
|
-
// Size
|
|
73
|
-
controlHeight: 48,
|
|
74
|
-
controlHeightSM: 32,
|
|
75
|
-
controlHeightLG: 56,
|
|
76
|
-
|
|
77
|
-
// Padding
|
|
78
|
-
paddingXS: 8,
|
|
79
|
-
paddingSM: 12,
|
|
80
|
-
padding: 16,
|
|
81
|
-
paddingMD: 16,
|
|
82
|
-
paddingLG: 24,
|
|
83
|
-
|
|
84
|
-
// Motion
|
|
85
|
-
motionDurationFast: '150ms',
|
|
86
|
-
motionDurationMid: '250ms',
|
|
87
|
-
},
|
|
88
|
-
components: {
|
|
89
|
-
Button: {
|
|
90
|
-
primaryColor: '#ffffff',
|
|
91
|
-
defaultBorderColor: colorGlobal.gray20,
|
|
92
|
-
defaultColor: colorAlias.primaryOnTheme,
|
|
93
|
-
borderRadius: 12,
|
|
94
|
-
borderRadiusSM: 8,
|
|
95
|
-
borderRadiusLG: 12,
|
|
96
|
-
controlHeight: 48,
|
|
97
|
-
controlHeightSM: 32,
|
|
98
|
-
paddingInline: 16,
|
|
99
|
-
paddingInlineSM: 12,
|
|
100
|
-
fontWeight: 600,
|
|
101
|
-
},
|
|
102
|
-
Input: {
|
|
103
|
-
borderRadius: 8,
|
|
104
|
-
controlHeight: 48,
|
|
105
|
-
paddingInline: 12,
|
|
106
|
-
colorBorder: colorGlobal.gray20,
|
|
107
|
-
hoverBorderColor: colorAlias.outline,
|
|
108
|
-
activeBorderColor: colorAlias.brand,
|
|
109
|
-
},
|
|
110
|
-
Select: {
|
|
111
|
-
borderRadius: 8,
|
|
112
|
-
controlHeight: 48,
|
|
113
|
-
},
|
|
114
|
-
Checkbox: {
|
|
115
|
-
borderRadius: 4,
|
|
116
|
-
controlInteractiveSize: 20,
|
|
117
|
-
},
|
|
118
|
-
Radio: {
|
|
119
|
-
radioSize: 20,
|
|
120
|
-
dotSize: 8,
|
|
121
|
-
},
|
|
122
|
-
Switch: {
|
|
123
|
-
trackHeight: 32,
|
|
124
|
-
trackMinWidth: 52,
|
|
125
|
-
handleSize: 28,
|
|
126
|
-
colorPrimary: colorAlias.brand,
|
|
127
|
-
},
|
|
128
|
-
Modal: {
|
|
129
|
-
borderRadiusLG: 16,
|
|
130
|
-
paddingContentHorizontalLG: 16,
|
|
131
|
-
paddingMD: 16,
|
|
132
|
-
},
|
|
133
|
-
Card: {
|
|
134
|
-
borderRadius: 16,
|
|
135
|
-
paddingLG: 16,
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
export interface VETCProviderProps {
|
|
141
|
-
children: React.ReactNode;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export function VETCProvider({ children }: VETCProviderProps) {
|
|
145
|
-
return (
|
|
146
|
-
<ConfigProvider theme={{ ...vetcAntdTheme, algorithm: theme.defaultAlgorithm }}>
|
|
147
|
-
<AntApp>
|
|
148
|
-
{children}
|
|
149
|
-
</AntApp>
|
|
150
|
-
</ConfigProvider>
|
|
151
|
-
);
|
|
152
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* VETC Design System — Color Tokens
|
|
3
|
-
* Resolved from tokens_vetc.json
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
// ─── Global palette ───────────────────────────────────────────────────────────
|
|
7
|
-
export const colorGlobal = {
|
|
8
|
-
white: '#ffffff',
|
|
9
|
-
black: '#000000',
|
|
10
|
-
|
|
11
|
-
// Blue
|
|
12
|
-
blue02: '#f4fbff', blue05: '#e4f4ff', blue10: '#cae9ff',
|
|
13
|
-
blue15: '#afddff', blue20: '#95d1ff', blue25: '#7ac4fb',
|
|
14
|
-
blue30: '#60b6f4', blue35: '#45a8eb', blue40: '#2b99df',
|
|
15
|
-
blue45: '#108ad1', blue50: '#007ac1', blue60: '#005c9e',
|
|
16
|
-
blue70: '#004179', blue80: '#002853', blue90: '#00122a',
|
|
17
|
-
|
|
18
|
-
// Green (Brand)
|
|
19
|
-
green02: '#f2fef2', green05: '#dffbdf', green10: '#bff4bf',
|
|
20
|
-
green15: '#9feca7', green20: '#82e194', green25: '#68d583',
|
|
21
|
-
green30: '#50c775', green35: '#39b669', green40: '#25a45e',
|
|
22
|
-
green45: '#23965b', green50: '#208758', green60: '#1b6b4d',
|
|
23
|
-
green70: '#15503f', green80: '#0f342d', green90: '#081a18',
|
|
24
|
-
|
|
25
|
-
// Gray
|
|
26
|
-
gray02: '#f9fafa', gray05: '#f1f1f2', gray10: '#e3e4e6',
|
|
27
|
-
gray15: '#d4d6d9', gray20: '#c6c8cc', gray25: '#b8babf',
|
|
28
|
-
gray30: '#abacb2', gray35: '#9d9ea5', gray40: '#8f9098',
|
|
29
|
-
gray45: '#82828a', gray50: '#74747d', gray60: '#5e5d64',
|
|
30
|
-
gray70: '#47464b', gray80: '#2f2f32', gray90: '#181719',
|
|
31
|
-
|
|
32
|
-
// Red
|
|
33
|
-
red02: '#fff6f9', red05: '#ffe7f0', red10: '#ffd0de',
|
|
34
|
-
red15: '#ffb8cc', red20: '#ffa1b8', red25: '#ff89a3',
|
|
35
|
-
red30: '#fb718d', red35: '#f55c78', red40: '#ee4b62',
|
|
36
|
-
red45: '#e53b4d', red50: '#da2c39', red60: '#b4211f',
|
|
37
|
-
red70: '#852419', red80: '#571f12', red90: '#2b130a',
|
|
38
|
-
|
|
39
|
-
// Orange
|
|
40
|
-
orange02: '#fffbf0', orange05: '#fff3da', orange10: '#ffe3b4',
|
|
41
|
-
orange15: '#ffd08f', orange20: '#ffbb69', orange25: '#ffa447',
|
|
42
|
-
orange30: '#ff8c2f', orange35: '#ef7720', orange40: '#dd6e1d',
|
|
43
|
-
orange45: '#cb651b', orange50: '#b85c18', orange60: '#934913',
|
|
44
|
-
orange70: '#6f370f', orange80: '#4a250a', orange90: '#251205',
|
|
45
|
-
|
|
46
|
-
// Yellow
|
|
47
|
-
yellow02: '#fff8e7', yellow05: '#ffefbc', yellow10: '#ffe374',
|
|
48
|
-
yellow15: '#ffd62b', yellow20: '#f9c600', yellow25: '#e9b900',
|
|
49
|
-
yellow30: '#daaa00', yellow35: '#ca9b00', yellow40: '#bb8b00',
|
|
50
|
-
yellow45: '#ab7b00', yellow50: '#9c6b00', yellow60: '#7c4b00',
|
|
51
|
-
yellow70: '#5d2f00', yellow80: '#3e1800', yellow90: '#1f0700',
|
|
52
|
-
} as const;
|
|
53
|
-
|
|
54
|
-
// ─── Semantic alias tokens ─────────────────────────────────────────────────────
|
|
55
|
-
export const colorAlias = {
|
|
56
|
-
brand: colorGlobal.green40, // #25a45e
|
|
57
|
-
brandDark: colorGlobal.green50, // #208758
|
|
58
|
-
brandLight: colorGlobal.green05, // #dffbdf
|
|
59
|
-
|
|
60
|
-
positive: colorGlobal.green50, // #208758
|
|
61
|
-
positiveVariant: colorGlobal.green05, // #dffbdf
|
|
62
|
-
onPositive: colorGlobal.white,
|
|
63
|
-
onPositiveVariant: colorGlobal.green60,
|
|
64
|
-
|
|
65
|
-
negative: colorGlobal.red50, // #da2c39
|
|
66
|
-
onNegative: colorGlobal.white,
|
|
67
|
-
|
|
68
|
-
warning: colorGlobal.orange30, // #ff8c2f
|
|
69
|
-
onWarning: colorGlobal.white,
|
|
70
|
-
|
|
71
|
-
outline: colorGlobal.gray50, // #74747d
|
|
72
|
-
outlineVariant: colorGlobal.gray10, // #e3e4e6
|
|
73
|
-
outlineInverse: colorGlobal.gray40,
|
|
74
|
-
|
|
75
|
-
theme: colorGlobal.white,
|
|
76
|
-
themeVariant: colorGlobal.gray05, // #f1f1f2
|
|
77
|
-
inverseTheme: colorGlobal.gray90,
|
|
78
|
-
|
|
79
|
-
primaryOnTheme: colorGlobal.gray90, // #181719
|
|
80
|
-
secondaryOnTheme: colorGlobal.gray60, // #5e5d64
|
|
81
|
-
primaryOnInverseTheme: colorGlobal.white,
|
|
82
|
-
secondaryOnInverseTheme:colorGlobal.gray20,
|
|
83
|
-
|
|
84
|
-
disabledBackground: colorGlobal.gray10, // #e3e4e6
|
|
85
|
-
disabledContent: colorGlobal.gray30, // #abacb2
|
|
86
|
-
disabledOutline: colorGlobal.gray20,
|
|
87
|
-
|
|
88
|
-
overlay: 'rgba(0, 0, 0, 0.4)',
|
|
89
|
-
overlayVariant: 'rgba(0, 0, 0, 0.16)',
|
|
90
|
-
skeleton: 'rgba(0, 0, 0, 0.1)',
|
|
91
|
-
} as const;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* VETC Design System — Spacing & Sizing Tokens
|
|
3
|
-
* Base unit: 4px
|
|
4
|
-
*/
|
|
5
|
-
export const spacing = {
|
|
6
|
-
0: '0px',
|
|
7
|
-
1: '1px',
|
|
8
|
-
2: '2px',
|
|
9
|
-
4: '4px',
|
|
10
|
-
6: '6px',
|
|
11
|
-
8: '8px',
|
|
12
|
-
10: '10px',
|
|
13
|
-
12: '12px',
|
|
14
|
-
14: '14px',
|
|
15
|
-
16: '16px',
|
|
16
|
-
20: '20px',
|
|
17
|
-
24: '24px',
|
|
18
|
-
32: '32px',
|
|
19
|
-
40: '40px',
|
|
20
|
-
48: '48px',
|
|
21
|
-
56: '56px',
|
|
22
|
-
64: '64px',
|
|
23
|
-
72: '72px',
|
|
24
|
-
80: '80px',
|
|
25
|
-
} as const;
|
|
26
|
-
|
|
27
|
-
export const borderRadius = {
|
|
28
|
-
none: '0px',
|
|
29
|
-
xs: '4px',
|
|
30
|
-
sm: '6px',
|
|
31
|
-
md: '8px',
|
|
32
|
-
lg: '12px',
|
|
33
|
-
xl: '16px',
|
|
34
|
-
'2xl': '24px',
|
|
35
|
-
pill: '1000px',
|
|
36
|
-
} as const;
|
|
37
|
-
|
|
38
|
-
/** Component height standards from Figma */
|
|
39
|
-
export const componentHeight = {
|
|
40
|
-
buttonLg: '48px',
|
|
41
|
-
buttonSm: '32px',
|
|
42
|
-
input: '48px',
|
|
43
|
-
navBar: '56px',
|
|
44
|
-
bottomNav: '56px',
|
|
45
|
-
tabBar: '56px',
|
|
46
|
-
listItem: '56px',
|
|
47
|
-
chip: '32px',
|
|
48
|
-
chipSm: '24px',
|
|
49
|
-
iconStd: '24px',
|
|
50
|
-
iconSm: '20px',
|
|
51
|
-
} as const;
|
|
52
|
-
|
|
53
|
-
/** Shadow tokens */
|
|
54
|
-
export const shadow = {
|
|
55
|
-
none: 'none',
|
|
56
|
-
sm: '0 1px 4px rgba(0, 0, 0, 0.08)',
|
|
57
|
-
md: '0 2px 8px rgba(0, 0, 0, 0.12)',
|
|
58
|
-
lg: '0 4px 16px rgba(0, 0, 0, 0.16)',
|
|
59
|
-
} as const;
|