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.
Files changed (225) hide show
  1. package/README.md +37 -0
  2. package/build/index.js +1 -184
  3. package/config/index.js +1 -44
  4. package/create/index.js +1 -230
  5. package/create/utils/generate-app-config.js +1 -34
  6. package/create/utils/generate-npm-scripts.js +1 -26
  7. package/create/utils/get-options.js +1 -204
  8. package/create/utils/npm-scripts.js +1 -62
  9. package/deploy/index.js +1 -149
  10. package/deploy/utils/get-options.js +1 -69
  11. package/deploy/utils/request-upload.js +1 -34
  12. package/deploy/utils/upload-app.js +1 -82
  13. package/index.js +1 -319
  14. package/login/index.js +1 -169
  15. package/login/utils/get-options.js +1 -58
  16. package/login/utils/zalo-login.js +1 -32
  17. package/migrate/icons/update-icon-v3.js +1 -19
  18. package/migrate/index.js +1 -60
  19. package/migrate/utils/get-options.js +1 -46
  20. package/migrate/utils/migrate-react.js +1 -33
  21. package/package.json +13 -40
  22. package/start/frame/index.html +264 -254
  23. package/start/index.js +1 -382
  24. package/sync/index-to-app-config.js +1 -146
  25. package/sync/index.js +1 -55
  26. package/utils/axios.js +1 -15
  27. package/utils/check-update.js +1 -53
  28. package/utils/constants.js +1 -20
  29. package/utils/env.js +1 -39
  30. package/utils/error.js +1 -16
  31. package/utils/find-files-by-ext.js +1 -27
  32. package/utils/find-free-port.js +1 -11
  33. package/utils/fs-extra.js +1 -90
  34. package/utils/generate-pages-map.js +1 -17
  35. package/utils/get-app-info.js +1 -22
  36. package/utils/get-current-project.js +1 -25
  37. package/utils/get-ip.js +1 -19
  38. package/utils/log.js +1 -19
  39. package/utils/node-blob.js +1 -106
  40. package/utils/resumable.d.js +1 -0
  41. package/utils/resumable.js +1 -1204
  42. package/utils/spinner.js +1 -25
  43. package/utils/tunnel.js +1 -36
  44. package/.editorconfig +0 -15
  45. package/.eslintignore +0 -8
  46. package/.eslintrc.js +0 -10
  47. package/.vscode/launch.json +0 -23
  48. package/LICENSE +0 -21
  49. package/README.git.md +0 -37
  50. package/assets/index.js +0 -147
  51. package/build/dist/index.dev.js +0 -217
  52. package/config/dist/index.dev.js +0 -48
  53. package/create/init-zmp-ui.js +0 -216
  54. package/create/templates/app-parameters.js +0 -33
  55. package/create/templates/common/css/icons.css +0 -60
  56. package/create/templates/common/icons/512x512.png +0 -0
  57. package/create/templates/common/icons/apple-touch-icon.png +0 -0
  58. package/create/templates/common/icons/favicon.png +0 -0
  59. package/create/templates/common/postcss.config.js +0 -5
  60. package/create/templates/common/splash-2732x2732.png +0 -0
  61. package/create/templates/common/tailwind/postcss.config.js +0 -5
  62. package/create/templates/common/tailwind/tailwind.config.js +0 -9
  63. package/create/templates/common/tailwind/tailwind.css +0 -3
  64. package/create/templates/common/webpack/build.js +0 -41
  65. package/create/templates/copy-assets.js +0 -158
  66. package/create/templates/core/babel.config.js +0 -11
  67. package/create/templates/core/copy-assets.js +0 -83
  68. package/create/templates/core/generate-home-page.js +0 -143
  69. package/create/templates/core/generate-root.js +0 -283
  70. package/create/templates/core/generate-routes.js +0 -155
  71. package/create/templates/core/generate-scripts.js +0 -94
  72. package/create/templates/core/pages/404.html +0 -20
  73. package/create/templates/core/pages/about.html +0 -26
  74. package/create/templates/core/pages/catalog.html +0 -40
  75. package/create/templates/core/pages/dynamic-route.html +0 -115
  76. package/create/templates/core/pages/form.html +0 -258
  77. package/create/templates/core/pages/left-page-1.html +0 -24
  78. package/create/templates/core/pages/left-page-2.html +0 -23
  79. package/create/templates/core/pages/product.html +0 -36
  80. package/create/templates/core/pages/request-and-load.html +0 -35
  81. package/create/templates/core/pages/settings.html +0 -252
  82. package/create/templates/create-folders.js +0 -30
  83. package/create/templates/dist/generate-styles.dev.js +0 -46
  84. package/create/templates/generate-config-xml.js +0 -18
  85. package/create/templates/generate-index.js +0 -49
  86. package/create/templates/generate-manifest.js +0 -49
  87. package/create/templates/generate-recoil.js +0 -56
  88. package/create/templates/generate-routes.js +0 -16
  89. package/create/templates/generate-scripts.js +0 -16
  90. package/create/templates/generate-service-worker.js +0 -126
  91. package/create/templates/generate-store.js +0 -88
  92. package/create/templates/generate-styles.js +0 -110
  93. package/create/templates/generate-webpack-config.js +0 -335
  94. package/create/templates/generate-zmp-custom.js +0 -81
  95. package/create/templates/react/babel.config.js +0 -12
  96. package/create/templates/react/components/app-items.jsx +0 -44
  97. package/create/templates/react/components/navbar-back.jsx +0 -25
  98. package/create/templates/react/components/user-card.jsx +0 -18
  99. package/create/templates/react/copy-assets.js +0 -85
  100. package/create/templates/react/dist/generate-scripts.dev.js +0 -23
  101. package/create/templates/react/generate-home-page.js +0 -111
  102. package/create/templates/react/generate-root.js +0 -84
  103. package/create/templates/react/generate-routes.js +0 -16
  104. package/create/templates/react/generate-scripts.js +0 -68
  105. package/create/templates/react/pages/404.js +0 -27
  106. package/create/templates/react/pages/about.js +0 -52
  107. package/create/templates/react/pages/catalog.js +0 -112
  108. package/create/templates/react/pages/dynamic-route.js +0 -80
  109. package/create/templates/react/pages/form.js +0 -152
  110. package/create/templates/react/pages/index copy.js +0 -17
  111. package/create/templates/react/pages/index.js +0 -17
  112. package/create/templates/react/pages/settings.js +0 -76
  113. package/create/templates/react/pages/user.js +0 -56
  114. package/create/templates/react/vite.config.js +0 -11
  115. package/create/templates/react-typescript/_tsconfig.json +0 -33
  116. package/create/templates/react-typescript/components/app-items.js +0 -53
  117. package/create/templates/react-typescript/components/index.js +0 -9
  118. package/create/templates/react-typescript/components/navbar-back.js +0 -40
  119. package/create/templates/react-typescript/components/user-card.js +0 -32
  120. package/create/templates/react-typescript/copy-assets.js +0 -94
  121. package/create/templates/react-typescript/dist/generate-scripts.dev.js +0 -23
  122. package/create/templates/react-typescript/generate-home-page.js +0 -113
  123. package/create/templates/react-typescript/generate-root.js +0 -81
  124. package/create/templates/react-typescript/generate-routes.js +0 -12
  125. package/create/templates/react-typescript/generate-scripts.js +0 -67
  126. package/create/templates/react-typescript/pages/404.js +0 -27
  127. package/create/templates/react-typescript/pages/about.js +0 -52
  128. package/create/templates/react-typescript/pages/catalog.js +0 -112
  129. package/create/templates/react-typescript/pages/dynamic-route.js +0 -80
  130. package/create/templates/react-typescript/pages/form.js +0 -152
  131. package/create/templates/react-typescript/pages/index.js +0 -17
  132. package/create/templates/react-typescript/pages/settings.js +0 -76
  133. package/create/templates/react-typescript/pages/user.js +0 -56
  134. package/create/templates/react-typescript/vite.config.js +0 -21
  135. package/create/templates/svelte/babel.config.js +0 -10
  136. package/create/templates/svelte/copy-assets.js +0 -47
  137. package/create/templates/svelte/generate-home-page.js +0 -158
  138. package/create/templates/svelte/generate-root.js +0 -235
  139. package/create/templates/svelte/generate-routes.js +0 -91
  140. package/create/templates/svelte/generate-scripts.js +0 -47
  141. package/create/templates/svelte/pages/404.svelte +0 -10
  142. package/create/templates/svelte/pages/about.svelte +0 -16
  143. package/create/templates/svelte/pages/catalog.svelte +0 -31
  144. package/create/templates/svelte/pages/dynamic-route.svelte +0 -34
  145. package/create/templates/svelte/pages/form.svelte +0 -175
  146. package/create/templates/svelte/pages/left-page-1.svelte +0 -13
  147. package/create/templates/svelte/pages/left-page-2.svelte +0 -12
  148. package/create/templates/svelte/pages/product.svelte +0 -21
  149. package/create/templates/svelte/pages/request-and-load.svelte +0 -21
  150. package/create/templates/svelte/pages/settings.svelte +0 -175
  151. package/create/templates/vue/babel.config.js +0 -10
  152. package/create/templates/vue/components/header.vue +0 -28
  153. package/create/templates/vue/components/sun-and-moon.vue +0 -34
  154. package/create/templates/vue/copy-assets.js +0 -67
  155. package/create/templates/vue/generate-home-page.js +0 -56
  156. package/create/templates/vue/generate-root.js +0 -50
  157. package/create/templates/vue/generate-routes.js +0 -7
  158. package/create/templates/vue/generate-scripts.js +0 -63
  159. package/create/templates/vue/global-components.d.ts +0 -121
  160. package/create/templates/vue/icons/moon.svg +0 -3
  161. package/create/templates/vue/icons/sun.svg +0 -3
  162. package/create/templates/vue/pages/404.vue +0 -12
  163. package/create/templates/vue/pages/about.vue +0 -15
  164. package/create/templates/vue/pages/catalog.vue +0 -39
  165. package/create/templates/vue/pages/dynamic-route.vue +0 -34
  166. package/create/templates/vue/pages/form.vue +0 -162
  167. package/create/templates/vue/pages/left-page-1.vue +0 -14
  168. package/create/templates/vue/pages/left-page-2.vue +0 -11
  169. package/create/templates/vue/pages/product.vue +0 -31
  170. package/create/templates/vue/pages/request-and-load.vue +0 -25
  171. package/create/templates/vue/pages/settings.vue +0 -18
  172. package/create/templates/vue/vite.config.js +0 -11
  173. package/create/templates/zaui/_tsconfig.json +0 -33
  174. package/create/templates/zaui/babel.config.js +0 -12
  175. package/create/templates/zaui/components/user-card.jsx +0 -16
  176. package/create/templates/zaui/copy-assets.js +0 -90
  177. package/create/templates/zaui/generate-home-page.js +0 -117
  178. package/create/templates/zaui/generate-root.js +0 -53
  179. package/create/templates/zaui/generate-routes.js +0 -10
  180. package/create/templates/zaui/generate-scripts.js +0 -39
  181. package/create/templates/zaui/generate-user-card.js +0 -55
  182. package/create/templates/zaui/pages/about.js +0 -129
  183. package/create/templates/zaui/pages/form.js +0 -123
  184. package/create/templates/zaui/pages/index.js +0 -9
  185. package/create/templates/zaui/pages/user.js +0 -109
  186. package/create/templates/zaui/vite.config.js +0 -11
  187. package/create/utils/colors.js +0 -94
  188. package/create/utils/dist/get-options.dev.js +0 -277
  189. package/create/utils/generate-gitignore.js +0 -43
  190. package/create/utils/generate-package-json.js +0 -132
  191. package/create/utils/generate-readme.js +0 -28
  192. package/create/utils/indent.js +0 -31
  193. package/create/utils/string.js +0 -13
  194. package/create/utils/styles-extension.js +0 -9
  195. package/create/utils/template-if.js +0 -9
  196. package/deploy/dist/index.dev.js +0 -227
  197. package/deploy/utils/dist/request-upload.dev.js +0 -62
  198. package/deploy/utils/dist/upload-app.dev.js +0 -113
  199. package/dist/bundle.js +0 -1
  200. package/dist/index.dev.js +0 -352
  201. package/jsconfig.json +0 -8
  202. package/login/dist/index.dev.js +0 -223
  203. package/login/utils/dist/zalo-login.dev.js +0 -41
  204. package/screenshots/wellcome.jpg +0 -0
  205. package/show-qr-app/assets/css/style.css +0 -87
  206. package/show-qr-app/assets/js/qrcode.min.js +0 -1
  207. package/show-qr-app/index.html +0 -57
  208. package/show-qr-app/package.json +0 -14
  209. package/start/dist/index.dev.js +0 -312
  210. package/start/generate-hr-config.js +0 -59
  211. package/ui/server.js +0 -194
  212. package/ui/www/css/app.css +0 -1
  213. package/ui/www/css/app.css.map +0 -1
  214. package/ui/www/fonts/ZMPIcons-Regular.eot +0 -0
  215. package/ui/www/fonts/ZMPIcons-Regular.ttf +0 -0
  216. package/ui/www/fonts/ZMPIcons-Regular.woff +0 -0
  217. package/ui/www/fonts/ZMPIcons-Regular.woff2 +0 -0
  218. package/ui/www/images/logo.png +0 -0
  219. package/ui/www/index.html +0 -1
  220. package/ui/www/js/app.js +0 -3
  221. package/ui/www/js/app.js.LICENSE.txt +0 -20
  222. package/ui/www/js/app.js.map +0 -1
  223. package/ui/www/static/icons/apple-touch-icon.png +0 -0
  224. package/ui/www/static/icons/favicon.png +0 -0
  225. package/utils/dist/get-app-info.dev.js +0 -54
@@ -1,10 +0,0 @@
1
- module.exports = (options) => {
2
- const { template } = options;
3
-
4
- if (template === 'blank') {
5
- return [];
6
- }
7
- const routes = ['/user', '/form', '/dynamic-route', '/about', '/404'];
8
-
9
- return routes;
10
- };
@@ -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,9 +0,0 @@
1
- const copyUser = require('./user');
2
- const copyForm = require('./form');
3
- const copyAbout = require('./about');
4
-
5
- module.exports = {
6
- copyUser,
7
- copyForm,
8
- copyAbout,
9
- };
@@ -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
- };
@@ -1,11 +0,0 @@
1
- import { defineConfig } from 'vite'
2
- import reactRefresh from '@vitejs/plugin-react-refresh'
3
-
4
- // https://vitejs.dev/config/
5
- export default () => {
6
- return defineConfig({
7
- root: './src',
8
- base: '',
9
- plugins: [reactRefresh()],
10
- })
11
- }
@@ -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
- };