zmp-cli 3.15.6 → 3.15.8
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/README.md +37 -0
- package/build/index.js +1 -184
- package/config/index.js +1 -44
- package/create/index.js +1 -230
- package/create/utils/generate-app-config.js +1 -34
- package/create/utils/generate-npm-scripts.js +1 -26
- package/create/utils/get-options.js +1 -204
- package/create/utils/npm-scripts.js +1 -62
- package/deploy/index.js +1 -149
- package/deploy/utils/get-options.js +1 -69
- package/deploy/utils/request-upload.js +1 -34
- package/deploy/utils/upload-app.js +1 -82
- package/index.js +1 -319
- package/login/index.js +1 -169
- package/login/utils/get-options.js +1 -58
- package/login/utils/zalo-login.js +1 -32
- package/migrate/icons/update-icon-v3.js +1 -19
- package/migrate/index.js +1 -60
- package/migrate/utils/get-options.js +1 -46
- package/migrate/utils/migrate-react.js +1 -33
- package/package.json +13 -40
- package/start/frame/index.html +264 -254
- package/start/index.js +1 -382
- package/sync/index-to-app-config.js +1 -146
- package/sync/index.js +1 -55
- package/utils/axios.js +1 -15
- package/utils/check-update.js +1 -53
- package/utils/constants.js +1 -20
- package/utils/env.js +1 -39
- package/utils/error.js +1 -16
- package/utils/find-files-by-ext.js +1 -27
- package/utils/find-free-port.js +1 -11
- package/utils/fs-extra.js +1 -90
- package/utils/generate-pages-map.js +1 -17
- package/utils/get-app-info.js +1 -22
- package/utils/get-current-project.js +1 -25
- package/utils/get-ip.js +1 -19
- package/utils/log.js +1 -19
- package/utils/node-blob.js +1 -106
- package/utils/resumable.d.js +1 -0
- package/utils/resumable.js +1 -1204
- package/utils/spinner.js +1 -25
- package/utils/tunnel.js +1 -36
- package/.editorconfig +0 -15
- package/.eslintignore +0 -8
- package/.eslintrc.js +0 -10
- package/.vscode/launch.json +0 -23
- package/LICENSE +0 -21
- package/README.git.md +0 -37
- package/assets/index.js +0 -147
- package/build/dist/index.dev.js +0 -217
- package/config/dist/index.dev.js +0 -48
- package/create/init-zmp-ui.js +0 -216
- package/create/templates/app-parameters.js +0 -33
- package/create/templates/common/css/icons.css +0 -60
- package/create/templates/common/icons/512x512.png +0 -0
- package/create/templates/common/icons/apple-touch-icon.png +0 -0
- package/create/templates/common/icons/favicon.png +0 -0
- package/create/templates/common/postcss.config.js +0 -5
- package/create/templates/common/splash-2732x2732.png +0 -0
- package/create/templates/common/tailwind/postcss.config.js +0 -5
- package/create/templates/common/tailwind/tailwind.config.js +0 -9
- package/create/templates/common/tailwind/tailwind.css +0 -3
- package/create/templates/common/webpack/build.js +0 -41
- package/create/templates/copy-assets.js +0 -158
- package/create/templates/core/babel.config.js +0 -11
- package/create/templates/core/copy-assets.js +0 -83
- package/create/templates/core/generate-home-page.js +0 -143
- package/create/templates/core/generate-root.js +0 -283
- package/create/templates/core/generate-routes.js +0 -155
- package/create/templates/core/generate-scripts.js +0 -94
- package/create/templates/core/pages/404.html +0 -20
- package/create/templates/core/pages/about.html +0 -26
- package/create/templates/core/pages/catalog.html +0 -40
- package/create/templates/core/pages/dynamic-route.html +0 -115
- package/create/templates/core/pages/form.html +0 -258
- package/create/templates/core/pages/left-page-1.html +0 -24
- package/create/templates/core/pages/left-page-2.html +0 -23
- package/create/templates/core/pages/product.html +0 -36
- package/create/templates/core/pages/request-and-load.html +0 -35
- package/create/templates/core/pages/settings.html +0 -252
- package/create/templates/create-folders.js +0 -30
- package/create/templates/dist/generate-styles.dev.js +0 -46
- package/create/templates/generate-config-xml.js +0 -18
- package/create/templates/generate-index.js +0 -49
- package/create/templates/generate-manifest.js +0 -49
- package/create/templates/generate-recoil.js +0 -56
- package/create/templates/generate-routes.js +0 -16
- package/create/templates/generate-scripts.js +0 -16
- package/create/templates/generate-service-worker.js +0 -126
- package/create/templates/generate-store.js +0 -88
- package/create/templates/generate-styles.js +0 -110
- package/create/templates/generate-webpack-config.js +0 -335
- package/create/templates/generate-zmp-custom.js +0 -81
- package/create/templates/react/babel.config.js +0 -12
- package/create/templates/react/components/app-items.jsx +0 -44
- package/create/templates/react/components/navbar-back.jsx +0 -25
- package/create/templates/react/components/user-card.jsx +0 -18
- package/create/templates/react/copy-assets.js +0 -85
- package/create/templates/react/dist/generate-scripts.dev.js +0 -23
- package/create/templates/react/generate-home-page.js +0 -111
- package/create/templates/react/generate-root.js +0 -84
- package/create/templates/react/generate-routes.js +0 -16
- package/create/templates/react/generate-scripts.js +0 -68
- package/create/templates/react/pages/404.js +0 -27
- package/create/templates/react/pages/about.js +0 -52
- package/create/templates/react/pages/catalog.js +0 -112
- package/create/templates/react/pages/dynamic-route.js +0 -80
- package/create/templates/react/pages/form.js +0 -152
- package/create/templates/react/pages/index copy.js +0 -17
- package/create/templates/react/pages/index.js +0 -17
- package/create/templates/react/pages/settings.js +0 -76
- package/create/templates/react/pages/user.js +0 -56
- package/create/templates/react/vite.config.js +0 -11
- package/create/templates/react-typescript/_tsconfig.json +0 -33
- package/create/templates/react-typescript/components/app-items.js +0 -53
- package/create/templates/react-typescript/components/index.js +0 -9
- package/create/templates/react-typescript/components/navbar-back.js +0 -40
- package/create/templates/react-typescript/components/user-card.js +0 -32
- package/create/templates/react-typescript/copy-assets.js +0 -94
- package/create/templates/react-typescript/dist/generate-scripts.dev.js +0 -23
- package/create/templates/react-typescript/generate-home-page.js +0 -113
- package/create/templates/react-typescript/generate-root.js +0 -81
- package/create/templates/react-typescript/generate-routes.js +0 -12
- package/create/templates/react-typescript/generate-scripts.js +0 -67
- package/create/templates/react-typescript/pages/404.js +0 -27
- package/create/templates/react-typescript/pages/about.js +0 -52
- package/create/templates/react-typescript/pages/catalog.js +0 -112
- package/create/templates/react-typescript/pages/dynamic-route.js +0 -80
- package/create/templates/react-typescript/pages/form.js +0 -152
- package/create/templates/react-typescript/pages/index.js +0 -17
- package/create/templates/react-typescript/pages/settings.js +0 -76
- package/create/templates/react-typescript/pages/user.js +0 -56
- package/create/templates/react-typescript/vite.config.js +0 -21
- package/create/templates/svelte/babel.config.js +0 -10
- package/create/templates/svelte/copy-assets.js +0 -47
- package/create/templates/svelte/generate-home-page.js +0 -158
- package/create/templates/svelte/generate-root.js +0 -235
- package/create/templates/svelte/generate-routes.js +0 -91
- package/create/templates/svelte/generate-scripts.js +0 -47
- package/create/templates/svelte/pages/404.svelte +0 -10
- package/create/templates/svelte/pages/about.svelte +0 -16
- package/create/templates/svelte/pages/catalog.svelte +0 -31
- package/create/templates/svelte/pages/dynamic-route.svelte +0 -34
- package/create/templates/svelte/pages/form.svelte +0 -175
- package/create/templates/svelte/pages/left-page-1.svelte +0 -13
- package/create/templates/svelte/pages/left-page-2.svelte +0 -12
- package/create/templates/svelte/pages/product.svelte +0 -21
- package/create/templates/svelte/pages/request-and-load.svelte +0 -21
- package/create/templates/svelte/pages/settings.svelte +0 -175
- package/create/templates/vue/babel.config.js +0 -10
- package/create/templates/vue/components/header.vue +0 -28
- package/create/templates/vue/components/sun-and-moon.vue +0 -34
- package/create/templates/vue/copy-assets.js +0 -67
- package/create/templates/vue/generate-home-page.js +0 -56
- package/create/templates/vue/generate-root.js +0 -50
- package/create/templates/vue/generate-routes.js +0 -7
- package/create/templates/vue/generate-scripts.js +0 -63
- package/create/templates/vue/global-components.d.ts +0 -121
- package/create/templates/vue/icons/moon.svg +0 -3
- package/create/templates/vue/icons/sun.svg +0 -3
- package/create/templates/vue/pages/404.vue +0 -12
- package/create/templates/vue/pages/about.vue +0 -15
- package/create/templates/vue/pages/catalog.vue +0 -39
- package/create/templates/vue/pages/dynamic-route.vue +0 -34
- package/create/templates/vue/pages/form.vue +0 -162
- package/create/templates/vue/pages/left-page-1.vue +0 -14
- package/create/templates/vue/pages/left-page-2.vue +0 -11
- package/create/templates/vue/pages/product.vue +0 -31
- package/create/templates/vue/pages/request-and-load.vue +0 -25
- package/create/templates/vue/pages/settings.vue +0 -18
- package/create/templates/vue/vite.config.js +0 -11
- package/create/templates/zaui/_tsconfig.json +0 -33
- package/create/templates/zaui/babel.config.js +0 -12
- package/create/templates/zaui/components/user-card.jsx +0 -16
- package/create/templates/zaui/copy-assets.js +0 -90
- package/create/templates/zaui/generate-home-page.js +0 -117
- package/create/templates/zaui/generate-root.js +0 -53
- package/create/templates/zaui/generate-routes.js +0 -10
- package/create/templates/zaui/generate-scripts.js +0 -39
- package/create/templates/zaui/generate-user-card.js +0 -55
- package/create/templates/zaui/pages/about.js +0 -129
- package/create/templates/zaui/pages/form.js +0 -123
- package/create/templates/zaui/pages/index.js +0 -9
- package/create/templates/zaui/pages/user.js +0 -109
- package/create/templates/zaui/vite.config.js +0 -11
- package/create/utils/colors.js +0 -94
- package/create/utils/dist/get-options.dev.js +0 -277
- package/create/utils/generate-gitignore.js +0 -43
- package/create/utils/generate-package-json.js +0 -132
- package/create/utils/generate-readme.js +0 -28
- package/create/utils/indent.js +0 -31
- package/create/utils/string.js +0 -13
- package/create/utils/styles-extension.js +0 -9
- package/create/utils/template-if.js +0 -9
- package/deploy/dist/index.dev.js +0 -227
- package/deploy/utils/dist/request-upload.dev.js +0 -62
- package/deploy/utils/dist/upload-app.dev.js +0 -113
- package/dist/bundle.js +0 -1
- package/dist/index.dev.js +0 -352
- package/jsconfig.json +0 -8
- package/login/dist/index.dev.js +0 -223
- package/login/utils/dist/zalo-login.dev.js +0 -41
- package/screenshots/wellcome.jpg +0 -0
- package/show-qr-app/assets/css/style.css +0 -87
- package/show-qr-app/assets/js/qrcode.min.js +0 -1
- package/show-qr-app/index.html +0 -57
- package/show-qr-app/package.json +0 -14
- package/start/dist/index.dev.js +0 -312
- package/start/generate-hr-config.js +0 -59
- package/ui/server.js +0 -194
- package/ui/www/css/app.css +0 -1
- package/ui/www/css/app.css.map +0 -1
- package/ui/www/fonts/ZMPIcons-Regular.eot +0 -0
- package/ui/www/fonts/ZMPIcons-Regular.ttf +0 -0
- package/ui/www/fonts/ZMPIcons-Regular.woff +0 -0
- package/ui/www/fonts/ZMPIcons-Regular.woff2 +0 -0
- package/ui/www/images/logo.png +0 -0
- package/ui/www/index.html +0 -1
- package/ui/www/js/app.js +0 -3
- package/ui/www/js/app.js.LICENSE.txt +0 -20
- package/ui/www/js/app.js.map +0 -1
- package/ui/www/static/icons/apple-touch-icon.png +0 -0
- package/ui/www/static/icons/favicon.png +0 -0
- package/utils/dist/get-app-info.dev.js +0 -54
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
const indent = require('../../utils/indent');
|
|
2
|
-
const stylesExtension = require('../../utils/styles-extension');
|
|
3
|
-
|
|
4
|
-
module.exports = (options) => {
|
|
5
|
-
const { cssPreProcessor, includeTailwind, framework } = options;
|
|
6
|
-
|
|
7
|
-
let scripts = '';
|
|
8
|
-
|
|
9
|
-
scripts += indent(
|
|
10
|
-
0,
|
|
11
|
-
`
|
|
12
|
-
// Import React and ReactDOM
|
|
13
|
-
import React from 'react';
|
|
14
|
-
import { createRoot } from 'react-dom/client';
|
|
15
|
-
${includeTailwind ? `
|
|
16
|
-
|
|
17
|
-
// Import tailwind styles
|
|
18
|
-
import './css/tailwind.css';` : ''}
|
|
19
|
-
|
|
20
|
-
import 'zmp-ui/zaui.css';
|
|
21
|
-
|
|
22
|
-
import './css/app.${stylesExtension(cssPreProcessor)}';
|
|
23
|
-
|
|
24
|
-
// Import App Component
|
|
25
|
-
import App from './components/app';
|
|
26
|
-
import appConfig from '../app-config.json';
|
|
27
|
-
|
|
28
|
-
if (!window.APP_CONFIG) {
|
|
29
|
-
window.APP_CONFIG = appConfig;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Mount React App
|
|
33
|
-
${framework === 'react-typescript' ? "const root = createRoot(document.getElementById('app')!);" : "const root = createRoot(document.getElementById('app'));"}
|
|
34
|
-
root.render(React.createElement(App));
|
|
35
|
-
`
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
return scripts.trim();
|
|
39
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
const indent = require('../../utils/indent');
|
|
2
|
-
const {projectFramework} = require('../../../utils/constants')
|
|
3
|
-
// eslint-disable-next-line no-unused-vars
|
|
4
|
-
module.exports = (options) => {
|
|
5
|
-
const {framework} = options
|
|
6
|
-
if(framework === projectFramework.REACT_TYPESCRIPT){
|
|
7
|
-
return indent(
|
|
8
|
-
0,
|
|
9
|
-
`
|
|
10
|
-
import React from 'react';
|
|
11
|
-
import { Avatar, Box, Text } from 'zmp-ui';
|
|
12
|
-
import { userInfo } from 'zmp-sdk';
|
|
13
|
-
|
|
14
|
-
interface UserProps{
|
|
15
|
-
user: userInfo
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const UserCard: React.FunctionComponent<UserProps> = ({ user }) => {
|
|
19
|
-
return (
|
|
20
|
-
<Box flex>
|
|
21
|
-
<Avatar story='default' online src={user.avatar.startsWith('http') ? user.avatar : undefined}>{user.avatar}</Avatar>
|
|
22
|
-
<Box ml={4}>
|
|
23
|
-
<Text.Title>{user.name}</Text.Title>
|
|
24
|
-
<Text>{user.id}</Text>
|
|
25
|
-
</Box>
|
|
26
|
-
</Box>
|
|
27
|
-
)
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export default UserCard;
|
|
31
|
-
`
|
|
32
|
-
).trim();
|
|
33
|
-
}
|
|
34
|
-
return indent(
|
|
35
|
-
0,
|
|
36
|
-
`
|
|
37
|
-
import React from 'react';
|
|
38
|
-
import { Avatar, Box, Text } from 'zmp-ui';
|
|
39
|
-
|
|
40
|
-
const UserCard = ({ user }) => {
|
|
41
|
-
return (
|
|
42
|
-
<Box flex>
|
|
43
|
-
<Avatar story='default' online src={user.avatar.startsWith('http') ? user.avatar : null}>{user.avatar}</Avatar>
|
|
44
|
-
<Box ml={4}>
|
|
45
|
-
<Text.Title>{user.name}</Text.Title>
|
|
46
|
-
<Text>{user.id}</Text>
|
|
47
|
-
</Box>
|
|
48
|
-
</Box>
|
|
49
|
-
)
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export default UserCard;
|
|
53
|
-
`
|
|
54
|
-
).trim();
|
|
55
|
-
};
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
const indent = require('../../../utils/indent');
|
|
2
|
-
const {projectFramework} = require('../../../../utils/constants')
|
|
3
|
-
|
|
4
|
-
// eslint-disable-next-line no-unused-vars
|
|
5
|
-
module.exports = (options) => {
|
|
6
|
-
const {framework} = options
|
|
7
|
-
|
|
8
|
-
if(framework === projectFramework.REACT_TYPESCRIPT){
|
|
9
|
-
return indent(
|
|
10
|
-
0,
|
|
11
|
-
`
|
|
12
|
-
import React from "react";
|
|
13
|
-
import { Sheet, Button, Page, Text, useNavigate } from "zmp-ui";
|
|
14
|
-
|
|
15
|
-
const AboutPage: React.FunctionComponent = (props) => {
|
|
16
|
-
const [actionSheetOpened, setActionSheetOpened] = React.useState(false);
|
|
17
|
-
const navigate = useNavigate()
|
|
18
|
-
return (
|
|
19
|
-
<Page className="page">
|
|
20
|
-
<div className="section-container">
|
|
21
|
-
<Text>This mini app was generated by zmp-cli</Text>
|
|
22
|
-
</div>
|
|
23
|
-
<div>
|
|
24
|
-
<Button
|
|
25
|
-
variant='secondary'
|
|
26
|
-
fullWidth
|
|
27
|
-
onClick={() => setActionSheetOpened(true)}
|
|
28
|
-
>
|
|
29
|
-
Back
|
|
30
|
-
</Button>
|
|
31
|
-
</div>
|
|
32
|
-
<Sheet.Actions
|
|
33
|
-
visible={actionSheetOpened}
|
|
34
|
-
onClose={() => setActionSheetOpened(false)}
|
|
35
|
-
actions={[
|
|
36
|
-
[
|
|
37
|
-
{
|
|
38
|
-
text: "Go back",
|
|
39
|
-
onClick: () => {
|
|
40
|
-
navigate(-1);
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
text: "Action 1",
|
|
45
|
-
close: true,
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
text: "Action 2",
|
|
49
|
-
close: true,
|
|
50
|
-
},
|
|
51
|
-
],
|
|
52
|
-
[
|
|
53
|
-
{
|
|
54
|
-
text: "Close",
|
|
55
|
-
close: true,
|
|
56
|
-
danger: true,
|
|
57
|
-
},
|
|
58
|
-
],
|
|
59
|
-
]}
|
|
60
|
-
></Sheet.Actions>
|
|
61
|
-
</Page>
|
|
62
|
-
);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export default AboutPage;
|
|
66
|
-
`
|
|
67
|
-
).trim();
|
|
68
|
-
}
|
|
69
|
-
return indent(
|
|
70
|
-
0,
|
|
71
|
-
`
|
|
72
|
-
import React from "react";
|
|
73
|
-
import { Sheet, Button, Page, Text, useNavigate } from "zmp-ui";
|
|
74
|
-
|
|
75
|
-
const AboutPage = (props) => {
|
|
76
|
-
const [actionSheetOpened, setActionSheetOpened] = React.useState(false);
|
|
77
|
-
const navigate = useNavigate()
|
|
78
|
-
return (
|
|
79
|
-
<Page className="page">
|
|
80
|
-
<div className="section-container">
|
|
81
|
-
<Text>This mini app was generated by zmp-cli</Text>
|
|
82
|
-
</div>
|
|
83
|
-
<div>
|
|
84
|
-
<Button
|
|
85
|
-
variant='secondary'
|
|
86
|
-
fullWidth
|
|
87
|
-
onClick={() => setActionSheetOpened(true)}
|
|
88
|
-
>
|
|
89
|
-
Back
|
|
90
|
-
</Button>
|
|
91
|
-
</div>
|
|
92
|
-
<Sheet.Actions
|
|
93
|
-
visible={actionSheetOpened}
|
|
94
|
-
onClose={() => setActionSheetOpened(false)}
|
|
95
|
-
actions={[
|
|
96
|
-
[
|
|
97
|
-
{
|
|
98
|
-
text: "Go back",
|
|
99
|
-
onClick: () => {
|
|
100
|
-
navigate(-1);
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
text: "Action 1",
|
|
105
|
-
close: true,
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
text: "Action 2",
|
|
109
|
-
close: true,
|
|
110
|
-
},
|
|
111
|
-
],
|
|
112
|
-
[
|
|
113
|
-
{
|
|
114
|
-
text: "Close",
|
|
115
|
-
close: true,
|
|
116
|
-
danger: true,
|
|
117
|
-
},
|
|
118
|
-
],
|
|
119
|
-
]}
|
|
120
|
-
></Sheet.Actions>
|
|
121
|
-
</Page>
|
|
122
|
-
);
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
export default AboutPage;
|
|
126
|
-
|
|
127
|
-
`
|
|
128
|
-
).trim();
|
|
129
|
-
};
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
const indent = require('../../../utils/indent');
|
|
2
|
-
const {projectFramework} = require('../../../../utils/constants');
|
|
3
|
-
|
|
4
|
-
module.exports = (options) => {
|
|
5
|
-
const { framework } = options
|
|
6
|
-
|
|
7
|
-
if(framework === projectFramework.REACT_TYPESCRIPT){
|
|
8
|
-
return indent(
|
|
9
|
-
0,
|
|
10
|
-
`
|
|
11
|
-
import React from 'react';
|
|
12
|
-
import { Button, Input, Box, Page, useSnackbar } from 'zmp-ui';
|
|
13
|
-
import { useRecoilState } from 'recoil';
|
|
14
|
-
import { userInfo } from 'zmp-sdk';
|
|
15
|
-
import { userState } from '../state';
|
|
16
|
-
|
|
17
|
-
type UserForm = Omit<userInfo, "id">
|
|
18
|
-
|
|
19
|
-
const FormPage: React.FunctionComponent = () => {
|
|
20
|
-
const [user, setUser] = useRecoilState<userInfo>(userState)
|
|
21
|
-
const [form, setForm] = React.useState<UserForm>({ name: user.name, avatar: user.avatar, birthday: user.birthday, gender: user.gender });
|
|
22
|
-
const snackbar = useSnackbar()
|
|
23
|
-
|
|
24
|
-
const handleChangeInput = (field, value) => {
|
|
25
|
-
setForm({ ...form, [field]: value })
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const handleSubmit = () => {
|
|
29
|
-
snackbar.openSnackbar({duration: 3000, text: 'saved', type: 'success'});
|
|
30
|
-
setUser((user) => ({ ...user, ...form }));
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<Page className="page">
|
|
35
|
-
<div className='section-container'>
|
|
36
|
-
<Box >
|
|
37
|
-
<Input
|
|
38
|
-
id="name"
|
|
39
|
-
label="Name"
|
|
40
|
-
type="text"
|
|
41
|
-
placeholder="Zalo"
|
|
42
|
-
value={form?.name}
|
|
43
|
-
onChange={(e) => handleChangeInput('name', e.target.value)}
|
|
44
|
-
/>
|
|
45
|
-
<Input
|
|
46
|
-
label="Avatar"
|
|
47
|
-
type="text"
|
|
48
|
-
placeholder="zalo@zalo.me"
|
|
49
|
-
value={form?.avatar}
|
|
50
|
-
onChange={(e) => handleChangeInput('avatar', e.target.value)}
|
|
51
|
-
/>
|
|
52
|
-
<Box mt={4}>
|
|
53
|
-
<Button fullWidth variant='primary' onClick={handleSubmit}>
|
|
54
|
-
Submit
|
|
55
|
-
</Button>
|
|
56
|
-
</Box>
|
|
57
|
-
</Box>
|
|
58
|
-
</div>
|
|
59
|
-
</Page>
|
|
60
|
-
)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export default FormPage;
|
|
64
|
-
`
|
|
65
|
-
).trim();
|
|
66
|
-
}
|
|
67
|
-
return indent(
|
|
68
|
-
0,
|
|
69
|
-
`
|
|
70
|
-
import React from 'react';
|
|
71
|
-
import { Button,Input, Box, Page, useSnackbar } from 'zmp-ui';
|
|
72
|
-
import { useRecoilState } from 'recoil';
|
|
73
|
-
import { userState } from '../state';
|
|
74
|
-
|
|
75
|
-
const FormPage = () => {
|
|
76
|
-
const [user, setUser] = useRecoilState(userState)
|
|
77
|
-
const [form, setForm] = React.useState({ ...user });
|
|
78
|
-
const snackbar = useSnackbar()
|
|
79
|
-
|
|
80
|
-
const handleChangeInput = (field, value) => {
|
|
81
|
-
setForm({ ...form, [field]: value })
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const handleSubmit = () => {
|
|
85
|
-
snackbar.openSnackbar({duration: 3000, text: 'saved', type: 'success'})
|
|
86
|
-
setUser(form);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return (
|
|
90
|
-
<Page className="page">
|
|
91
|
-
<div className='section-container'>
|
|
92
|
-
<Box >
|
|
93
|
-
<Input
|
|
94
|
-
id="name"
|
|
95
|
-
label="Name"
|
|
96
|
-
type="text"
|
|
97
|
-
placeholder="Zalo"
|
|
98
|
-
value={form?.name}
|
|
99
|
-
onChange={(e) => handleChangeInput('name', e.target.value)}
|
|
100
|
-
/>
|
|
101
|
-
<Input
|
|
102
|
-
label="Avatar"
|
|
103
|
-
type="text"
|
|
104
|
-
placeholder="zalo@zalo.me"
|
|
105
|
-
value={form?.avatar}
|
|
106
|
-
onChange={(e) => handleChangeInput('avatar', e.target.value)}
|
|
107
|
-
/>
|
|
108
|
-
<Box mt={4}>
|
|
109
|
-
<Button fullWidth variant='primary' onClick={handleSubmit}>
|
|
110
|
-
Submit
|
|
111
|
-
</Button>
|
|
112
|
-
</Box>
|
|
113
|
-
</Box>
|
|
114
|
-
</div>
|
|
115
|
-
</Page>
|
|
116
|
-
)
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export default FormPage;
|
|
120
|
-
`
|
|
121
|
-
).trim();
|
|
122
|
-
|
|
123
|
-
};
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
const indent = require('../../../utils/indent');
|
|
2
|
-
const { projectFramework } = require('../../../../utils/constants')
|
|
3
|
-
|
|
4
|
-
module.exports = (options) => {
|
|
5
|
-
const { framework } = options;
|
|
6
|
-
|
|
7
|
-
if(framework === projectFramework.REACT_TYPESCRIPT){
|
|
8
|
-
return indent(
|
|
9
|
-
0,
|
|
10
|
-
`
|
|
11
|
-
import React from "react";
|
|
12
|
-
import { Avatar, List, Text, Box, Page, Button, Icon, useNavigate } from "zmp-ui";
|
|
13
|
-
import { useRecoilValue } from "recoil";
|
|
14
|
-
import { userState } from "../state";
|
|
15
|
-
import { userInfo } from "zmp-sdk";
|
|
16
|
-
|
|
17
|
-
const UserPage = () => {
|
|
18
|
-
const user = useRecoilValue<userInfo>(userState);
|
|
19
|
-
const navigate = useNavigate()
|
|
20
|
-
return (
|
|
21
|
-
<Page className="page">
|
|
22
|
-
<Box flex flexDirection="column" justifyContent="center" alignItems="center">
|
|
23
|
-
<Box>
|
|
24
|
-
<Avatar
|
|
25
|
-
story='default'
|
|
26
|
-
size={96}
|
|
27
|
-
online
|
|
28
|
-
src={user.avatar.startsWith("http") ? user.avatar : undefined}
|
|
29
|
-
>
|
|
30
|
-
{user.avatar}
|
|
31
|
-
</Avatar>
|
|
32
|
-
</Box>
|
|
33
|
-
<Box flex flexDirection="row" alignItems="center" ml={8}>
|
|
34
|
-
<Box>
|
|
35
|
-
<Text.Title >{user.name}</Text.Title>
|
|
36
|
-
</Box>
|
|
37
|
-
<Box ml={4}>
|
|
38
|
-
<Button onClick={()=>{navigate('/form')}} size='small' icon={<Icon icon="zi-edit"/>}/>
|
|
39
|
-
</Box>
|
|
40
|
-
</Box>
|
|
41
|
-
</Box>
|
|
42
|
-
<Box m={0} p={0} mt={4}>
|
|
43
|
-
<div className="section-container">
|
|
44
|
-
<List>
|
|
45
|
-
<List.Item title="Display name" subTitle={user.name} />
|
|
46
|
-
<List.Item title="ID" subTitle={user.id} />
|
|
47
|
-
</List>
|
|
48
|
-
</div>
|
|
49
|
-
</Box>
|
|
50
|
-
|
|
51
|
-
</Page>
|
|
52
|
-
);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export default UserPage;
|
|
56
|
-
`
|
|
57
|
-
).trim();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return indent(
|
|
61
|
-
0,
|
|
62
|
-
`
|
|
63
|
-
import React from "react";
|
|
64
|
-
import { Avatar, List, Text, Box, Page, Button, Icon, useNavigate } from "zmp-ui";
|
|
65
|
-
import { useRecoilValue } from "recoil";
|
|
66
|
-
import { userState } from "../state";
|
|
67
|
-
|
|
68
|
-
const UserPage = () => {
|
|
69
|
-
const user = useRecoilValue(userState);
|
|
70
|
-
const navigate = useNavigate()
|
|
71
|
-
return (
|
|
72
|
-
<Page className="page">
|
|
73
|
-
<Box flex flexDirection="column" justifyContent="center" alignItems="center">
|
|
74
|
-
<Box>
|
|
75
|
-
<Avatar
|
|
76
|
-
story
|
|
77
|
-
size={96}
|
|
78
|
-
online
|
|
79
|
-
src={user.avatar.startsWith("http") ? user.avatar : null}
|
|
80
|
-
>
|
|
81
|
-
{user.avatar}
|
|
82
|
-
</Avatar>
|
|
83
|
-
</Box>
|
|
84
|
-
<Box flex flexDirection="row" alignItems="center" ml={8}>
|
|
85
|
-
<Box>
|
|
86
|
-
<Text.Title >{user.name}</Text.Title>
|
|
87
|
-
</Box>
|
|
88
|
-
<Box ml={4}>
|
|
89
|
-
<Button onClick={()=>{navigate('/form')}} size='small' icon={<Icon icon="zi-edit"/>}/>
|
|
90
|
-
</Box>
|
|
91
|
-
</Box>
|
|
92
|
-
</Box>
|
|
93
|
-
<Box m={0} p={0} mt={4}>
|
|
94
|
-
<div className="section-container">
|
|
95
|
-
<List>
|
|
96
|
-
<List.Item title="Display name" subTitle={user.name} />
|
|
97
|
-
<List.Item title="ID" subTitle={user.id} />
|
|
98
|
-
</List>
|
|
99
|
-
</div>
|
|
100
|
-
</Box>
|
|
101
|
-
|
|
102
|
-
</Page>
|
|
103
|
-
);
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
export default UserPage;
|
|
107
|
-
`
|
|
108
|
-
).trim();
|
|
109
|
-
};
|
package/create/utils/colors.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
function colorHexToRgb(hex) {
|
|
2
|
-
const h = hex.replace(
|
|
3
|
-
/^#?([a-f\d])([a-f\d])([a-f\d])$/i,
|
|
4
|
-
(m, r, g, b) => r + r + g + g + b + b
|
|
5
|
-
);
|
|
6
|
-
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(h);
|
|
7
|
-
return result ? result.slice(1).map((n) => parseInt(n, 16)) : null;
|
|
8
|
-
}
|
|
9
|
-
function colorRgbToHex(r, g, b) {
|
|
10
|
-
const result = [r, g, b]
|
|
11
|
-
.map((n) => {
|
|
12
|
-
const hex = n.toString(16);
|
|
13
|
-
return hex.length === 1 ? `0${hex}` : hex;
|
|
14
|
-
})
|
|
15
|
-
.join('');
|
|
16
|
-
return `#${result}`;
|
|
17
|
-
}
|
|
18
|
-
function colorRgbToHsl(r, g, b) {
|
|
19
|
-
r /= 255; // eslint-disable-line
|
|
20
|
-
g /= 255; // eslint-disable-line
|
|
21
|
-
b /= 255; // eslint-disable-line
|
|
22
|
-
const max = Math.max(r, g, b);
|
|
23
|
-
const min = Math.min(r, g, b);
|
|
24
|
-
const d = max - min;
|
|
25
|
-
let h;
|
|
26
|
-
if (d === 0) h = 0;
|
|
27
|
-
else if (max === r) h = ((g - b) / d) % 6;
|
|
28
|
-
else if (max === g) h = (b - r) / d + 2;
|
|
29
|
-
else if (max === b) h = (r - g) / d + 4;
|
|
30
|
-
const l = (min + max) / 2;
|
|
31
|
-
const s = d === 0 ? 0 : d / (1 - Math.abs(2 * l - 1));
|
|
32
|
-
return [h * 60, s, l];
|
|
33
|
-
}
|
|
34
|
-
function colorHslToRgb(h, s, l) {
|
|
35
|
-
const c = (1 - Math.abs(2 * l - 1)) * s;
|
|
36
|
-
const hp = h / 60;
|
|
37
|
-
const x = c * (1 - Math.abs((hp % 2) - 1));
|
|
38
|
-
let rgb1;
|
|
39
|
-
if (Number.isNaN(h) || typeof h === 'undefined') {
|
|
40
|
-
rgb1 = [0, 0, 0];
|
|
41
|
-
} else if (hp <= 1) rgb1 = [c, x, 0];
|
|
42
|
-
else if (hp <= 2) rgb1 = [x, c, 0];
|
|
43
|
-
else if (hp <= 3) rgb1 = [0, c, x];
|
|
44
|
-
else if (hp <= 4) rgb1 = [0, x, c];
|
|
45
|
-
else if (hp <= 5) rgb1 = [x, 0, c];
|
|
46
|
-
else if (hp <= 6) rgb1 = [c, 0, x];
|
|
47
|
-
const m = l - c / 2;
|
|
48
|
-
return rgb1.map((n) => Math.max(0, Math.min(255, Math.round(255 * (n + m)))));
|
|
49
|
-
}
|
|
50
|
-
function colorThemeCSSProperties(...args) {
|
|
51
|
-
let hex;
|
|
52
|
-
let rgb;
|
|
53
|
-
if (args.length === 1) {
|
|
54
|
-
[hex] = args;
|
|
55
|
-
rgb = colorHexToRgb(hex);
|
|
56
|
-
} else if (args.length === 3) {
|
|
57
|
-
rgb = args;
|
|
58
|
-
hex = colorRgbToHex(...rgb);
|
|
59
|
-
}
|
|
60
|
-
if (!rgb) return {};
|
|
61
|
-
const hsl = colorRgbToHsl(...rgb);
|
|
62
|
-
const hslShade = [hsl[0], hsl[1], Math.max(0, hsl[2] - 0.08)];
|
|
63
|
-
const hslTint = [hsl[0], hsl[1], Math.max(0, hsl[2] + 0.08)];
|
|
64
|
-
const shade = colorRgbToHex(...colorHslToRgb(...hslShade));
|
|
65
|
-
const tint = colorRgbToHex(...colorHslToRgb(...hslTint));
|
|
66
|
-
const hslSecondaryColor = [hsl[0], hsl[1], Math.max(0, hsl[2] + 0.6)];
|
|
67
|
-
const secondaryColor = colorRgbToHex(...colorHslToRgb(...hslSecondaryColor));
|
|
68
|
-
return {
|
|
69
|
-
'--zmp-theme-color': hex,
|
|
70
|
-
'--zmp-theme-color-rgb': rgb.join(', '),
|
|
71
|
-
'--zmp-theme-color-shade': shade,
|
|
72
|
-
'--zmp-theme-color-tint': tint,
|
|
73
|
-
'--zmp-checkbox-active-color-disabled': 'var(--zmp-theme-color-shade)',
|
|
74
|
-
'--zmp-radio-active-color-disabled': 'var(--zmp-theme-color-shade)',
|
|
75
|
-
'--zmp-toggle-active-color-disabled': 'var(--zmp-theme-color-shade)',
|
|
76
|
-
'--zmp-picker-action-button-hover-bg-color': 'var(--zmp-theme-color-shade)',
|
|
77
|
-
'--zmp-button-pressed-bg-color-primary': 'var(--zmp-theme-color-shade)',
|
|
78
|
-
' --zmp-button-bg-color-secondary': secondaryColor,
|
|
79
|
-
'--zmp-button-pressed-bg-color-secondary': secondaryColor,
|
|
80
|
-
'--zmp-button-pressed-color-secondary': 'var(--zmp-theme-color)',
|
|
81
|
-
'--zmp-button-border-color-secondary': 'var(--zmp-theme-color)',
|
|
82
|
-
'--zmp-tabbar-fill-link-active-color': 'var(--zmp-theme-color)',
|
|
83
|
-
'--zmp-tabbar-fill-link-active-border-color': 'var(--zmp-theme-color)',
|
|
84
|
-
'--zmp-fab-pressed-bg-color': 'var(--zmp-theme-color-shade)',
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
module.exports = {
|
|
89
|
-
colorHexToRgb,
|
|
90
|
-
colorHslToRgb,
|
|
91
|
-
colorRgbToHex,
|
|
92
|
-
colorRgbToHsl,
|
|
93
|
-
colorThemeCSSProperties,
|
|
94
|
-
};
|