zmp-cli 3.8.3-0 → 3.9.0
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/assets/index.js +0 -0
- package/build/index.js +0 -0
- package/config/index.js +0 -0
- package/create/index.js +0 -0
- package/create/templates/app-parameters.js +4 -2
- package/create/templates/copy-assets.js +0 -4
- package/create/templates/dist/generate-styles.dev.js +46 -0
- package/create/templates/generate-recoil.js +56 -0
- package/create/templates/generate-store.js +2 -4
- package/create/templates/generate-styles.js +1 -10
- package/create/templates/react/components/user-card.jsx +3 -3
- package/create/templates/react/copy-assets.js +38 -22
- package/create/templates/react/dist/generate-scripts.dev.js +5 -4
- package/create/templates/react/generate-home-page.js +10 -15
- package/create/templates/react/generate-root.js +22 -32
- package/create/templates/react/generate-scripts.js +6 -14
- package/create/templates/react/pages/404.js +27 -0
- package/create/templates/react/pages/about.js +52 -0
- package/create/templates/react/pages/catalog.js +112 -0
- package/create/templates/react/pages/dynamic-route.js +80 -0
- package/create/templates/react/pages/form.js +152 -0
- package/create/templates/react/pages/index copy.js +17 -0
- package/create/templates/react/pages/index.js +17 -0
- package/create/templates/react/pages/settings.js +76 -0
- package/create/templates/react/pages/user.js +56 -0
- package/create/templates/react-typescript/_tsconfig.json +0 -1
- package/create/templates/react-typescript/components/app-items.js +1 -1
- package/create/templates/react-typescript/components/user-card.js +6 -12
- package/create/templates/react-typescript/copy-assets.js +17 -9
- package/create/templates/react-typescript/dist/generate-scripts.dev.js +23 -0
- package/create/templates/react-typescript/generate-home-page.js +9 -12
- package/create/templates/react-typescript/generate-root.js +41 -53
- package/create/templates/react-typescript/generate-scripts.js +6 -14
- package/create/templates/react-typescript/pages/about.js +2 -9
- package/create/templates/react-typescript/pages/catalog.js +52 -0
- package/create/templates/react-typescript/pages/form.js +81 -13
- package/create/templates/react-typescript/pages/settings.js +37 -0
- package/create/templates/react-typescript/pages/user.js +16 -11
- package/create/templates/vue/generate-scripts.js +5 -1
- package/create/utils/generate-package-json.js +5 -1
- package/create/utils/get-options.js +21 -1
- package/deploy/index.js +0 -0
- package/login/index.js +0 -0
- package/migrate/index.js +0 -0
- package/package.json +2 -2
- package/start/index.js +0 -0
- package/build/dist/index.dev.js +0 -185
- package/config/dist/index.dev.js +0 -52
- package/create/dist/index.dev.js +0 -300
- package/create/templates/common/tailwind/styles.css +0 -0
- package/create/templates/core/dist/copy-assets.dev.js +0 -85
- package/create/templates/core/dist/generate-home-page.dev.js +0 -24
- package/create/templates/core/dist/generate-routes.dev.js +0 -43
- package/create/templates/core/dist/generate-scripts.dev.js +0 -40
- package/create/templates/dist/app-parameters.dev.js +0 -21
- package/create/templates/dist/copy-assets.dev.js +0 -113
- package/create/templates/dist/create-folders.dev.js +0 -25
- package/create/templates/dist/generate-routes.dev.js +0 -15
- package/create/templates/dist/generate-zmp-custom.dev.js +0 -46
- package/create/templates/react/dist/copy-assets.dev.js +0 -64
- package/create/templates/react/dist/generate-home-page.dev.js +0 -23
- package/create/templates/react/dist/generate-root.dev.js +0 -33
- package/create/templates/react/dist/generate-routes.dev.js +0 -20
- package/create/templates/react/pages/404.jsx +0 -17
- package/create/templates/react/pages/about.jsx +0 -42
- package/create/templates/react/pages/catalog.jsx +0 -39
- package/create/templates/react/pages/dynamic-route.jsx +0 -70
- package/create/templates/react/pages/form-tabs.jsx +0 -64
- package/create/templates/react/pages/form.jsx +0 -61
- package/create/templates/react/pages/left-page-1.jsx +0 -17
- package/create/templates/react/pages/left-page-2.jsx +0 -16
- package/create/templates/react/pages/product.jsx +0 -25
- package/create/templates/react/pages/settings.jsx +0 -28
- package/create/templates/react/pages/user-tabs.jsx +0 -31
- package/create/templates/react/pages/user.jsx +0 -28
- package/create/templates/svelte/dist/copy-assets.dev.js +0 -55
- package/create/templates/svelte/dist/generate-home-page.dev.js +0 -23
- package/create/templates/svelte/dist/generate-root.dev.js +0 -35
- package/create/templates/svelte/dist/generate-routes.dev.js +0 -25
- package/create/templates/svelte/dist/generate-scripts.dev.js +0 -22
- package/create/templates/vue/dist/copy-assets.dev.js +0 -55
- package/create/templates/vue/dist/generate-home-page.dev.js +0 -23
- package/create/templates/vue/dist/generate-root.dev.js +0 -35
- package/create/templates/vue/dist/generate-routes.dev.js +0 -27
- package/create/templates/vue/dist/generate-scripts.dev.js +0 -22
- package/create/utils/dist/generate-app-config.dev.js +0 -29
- package/create/utils/dist/generate-gitignore.dev.js +0 -7
- package/create/utils/dist/generate-package-json.dev.js +0 -72
- package/deploy/dist/index.dev.js +0 -196
- package/deploy/utils/dist/upload-app.dev.js +0 -113
- package/dist/index.dev.js +0 -355
- package/login/dist/index.dev.js +0 -236
- package/login/utils/dist/get-options.dev.js +0 -66
- package/scripts/dist/release.dev.js +0 -105
- package/start/dist/index.dev.js +0 -247
- package/ui/dist/server.dev.js +0 -208
- package/utils/dist/constants.dev.js +0 -10
- package/utils/dist/error.dev.js +0 -18
package/assets/index.js
CHANGED
|
File without changes
|
package/build/index.js
CHANGED
|
File without changes
|
package/config/index.js
CHANGED
|
File without changes
|
package/create/index.js
CHANGED
|
File without changes
|
|
@@ -2,15 +2,17 @@ const indent = require('../utils/indent');
|
|
|
2
2
|
const templateIf = require('../utils/template-if');
|
|
3
3
|
|
|
4
4
|
module.exports = (options) => {
|
|
5
|
-
const { framework, pkg, name, bundler } = options;
|
|
5
|
+
const { framework, pkg, name, bundler, stateManagement } = options;
|
|
6
6
|
|
|
7
7
|
return indent(
|
|
8
8
|
0,
|
|
9
9
|
`
|
|
10
10
|
name: '${name}', // App name
|
|
11
11
|
theme: 'auto', // Automatic theme detection
|
|
12
|
+
${templateIf(stateManagement === 'store', () => `
|
|
12
13
|
// App store
|
|
13
14
|
store: store,
|
|
15
|
+
`)}
|
|
14
16
|
${templateIf(framework === 'core', () => `el: '#app', // App root element`)}
|
|
15
17
|
${templateIf(
|
|
16
18
|
framework === 'core' && bundler,
|
|
@@ -26,6 +28,6 @@ module.exports = (options) => {
|
|
|
26
28
|
},
|
|
27
29
|
`
|
|
28
30
|
)}
|
|
29
|
-
|
|
31
|
+
`
|
|
30
32
|
).trim();
|
|
31
33
|
};
|
|
@@ -43,10 +43,6 @@ module.exports = (options, iconFile) => {
|
|
|
43
43
|
from: path.resolve(__dirname, 'common', 'tailwind', 'tailwind.css'),
|
|
44
44
|
to: path.resolve(cwd, srcFolder, 'css', 'tailwind.css'),
|
|
45
45
|
},
|
|
46
|
-
{
|
|
47
|
-
from: path.resolve(__dirname, 'common', 'tailwind', 'styles.css'),
|
|
48
|
-
to: path.resolve(cwd, srcFolder, 'css', 'styles.css'),
|
|
49
|
-
},
|
|
50
46
|
{
|
|
51
47
|
from: path.resolve(
|
|
52
48
|
__dirname,
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var indent = require('../utils/indent');
|
|
4
|
+
|
|
5
|
+
var _require = require('../utils/colors'),
|
|
6
|
+
colorThemeCSSProperties = _require.colorThemeCSSProperties;
|
|
7
|
+
|
|
8
|
+
module.exports = function (options) {
|
|
9
|
+
var template = options.template,
|
|
10
|
+
theming = options.theming;
|
|
11
|
+
var customColor = theming.customColor,
|
|
12
|
+
color = theming.color,
|
|
13
|
+
fillBars = theming.fillBars;
|
|
14
|
+
var styles = '';
|
|
15
|
+
var themeRgb = [0, 122, 255];
|
|
16
|
+
|
|
17
|
+
if (customColor && color) {
|
|
18
|
+
var customProps = colorThemeCSSProperties("".concat(color));
|
|
19
|
+
themeRgb = customProps['--zmp-theme-color-rgb'].split(',').map(function (n) {
|
|
20
|
+
return n.trim();
|
|
21
|
+
});
|
|
22
|
+
styles += indent(0, "\n /* Custom color theme properties */\n :root {\n ".concat(Object.keys(customProps).filter(function (prop) {
|
|
23
|
+
return prop !== '--zmp-tabbar-fill-link-active-color' && prop !== '--zmp-tabbar-fill-link-active-border-color';
|
|
24
|
+
}).map(function (prop) {
|
|
25
|
+
return "".concat(prop, ": ").concat(customProps[prop], ";");
|
|
26
|
+
}).join('\n '), "\n }\n :root.theme-dark,:root .theme-dark {\n ").concat(Object.keys(customProps).map(function (prop) {
|
|
27
|
+
return "".concat(prop, ": ").concat(customProps[prop], ";");
|
|
28
|
+
}).join('\n '), "\n }\n "));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (fillBars) {
|
|
32
|
+
styles += indent(0, "\n /* Invert navigation bars to fill style */\n ");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (includeTailwind) {
|
|
36
|
+
styles += indent(0, "\n @import \"./tailwind.css\";\n ");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (template === 'split-view') {
|
|
40
|
+
styles += indent(0, "\n /* Left Panel right border when it is visible by breakpoint */\n .panel-left.panel-in-breakpoint:before {\n position: absolute;\n right: 0;\n top: 0;\n height: 100%;\n width: 1px;\n background: rgba(0,0,0,0.1);\n content: '';\n z-index: 6000;\n }\n\n /* Hide navbar link which opens left panel when it is visible by breakpoint */\n .panel-left.panel-in-breakpoint ~ .view .navbar .panel-open[data-panel=\"left\"] {\n display: none;\n }\n\n /*\n Extra borders for main view and left panel for iOS theme when it behaves as panel (before breakpoint size)\n */\n .ios .panel-left:not(.panel-in-breakpoint).panel-in ~ .view-main:before,\n .ios .panel-left:not(.panel-in-breakpoint).panel-closing ~ .view-main:before {\n position: absolute;\n left: 0;\n top: 0;\n height: 100%;\n width: 1px;\n background: rgba(0,0,0,0.1);\n content: '';\n z-index: 6000;\n }\n ");
|
|
41
|
+
} else {
|
|
42
|
+
styles += indent(0, "\n /* Your app custom styles here */\n ");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return styles.trim();
|
|
46
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const indent = require('../utils/indent');
|
|
2
|
+
const templateIf = require('../utils/template-if');
|
|
3
|
+
|
|
4
|
+
module.exports = (options) => {
|
|
5
|
+
const { framework, template } = options;
|
|
6
|
+
|
|
7
|
+
const productState = `
|
|
8
|
+
|
|
9
|
+
export const productsState = atom({
|
|
10
|
+
key: "products",
|
|
11
|
+
default: [
|
|
12
|
+
{
|
|
13
|
+
id: '1',
|
|
14
|
+
title: 'Apple iPhone 8',
|
|
15
|
+
description: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nisi tempora similique reiciendis, error nesciunt vero, blanditiis pariatur dolor, minima sed sapiente rerum, dolorem corrupti hic modi praesentium unde saepe perspiciatis.'
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
id: '2',
|
|
19
|
+
title: 'Apple iPhone 8 Plus',
|
|
20
|
+
description: 'Velit odit autem modi saepe ratione totam minus, aperiam, labore quia provident temporibus quasi est ut aliquid blanditiis beatae suscipit odio vel! Nostrum porro sunt sint eveniet maiores, dolorem itaque!'
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: '3',
|
|
24
|
+
title: 'Apple iPhone X',
|
|
25
|
+
description: 'Expedita sequi perferendis quod illum pariatur aliquam, alias laboriosam! Vero blanditiis placeat, mollitia necessitatibus reprehenderit. Labore dolores amet quos, accusamus earum asperiores officiis assumenda optio architecto quia neque, quae eum.'
|
|
26
|
+
},
|
|
27
|
+
]
|
|
28
|
+
});`;
|
|
29
|
+
|
|
30
|
+
if (framework === 'react-typescript') {
|
|
31
|
+
return `
|
|
32
|
+
import { atom } from "recoil";
|
|
33
|
+
import { userInfo } from 'zmp-sdk';
|
|
34
|
+
|
|
35
|
+
export const userState = atom<userInfo>({
|
|
36
|
+
key: "user",
|
|
37
|
+
default: {
|
|
38
|
+
id: '12345678',
|
|
39
|
+
name: 'Zalo',
|
|
40
|
+
avatar: 'ZA',
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
${templateIf(template === 'tabs', () => productState)}`;
|
|
44
|
+
}
|
|
45
|
+
return `import { atom } from "recoil";
|
|
46
|
+
|
|
47
|
+
export const userState = atom({
|
|
48
|
+
key: "user",
|
|
49
|
+
default: {
|
|
50
|
+
id: '12345678',
|
|
51
|
+
name: 'Zalo',
|
|
52
|
+
avatar: 'ZA',
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
${templateIf(template === 'tabs', () => productState)}`;
|
|
56
|
+
};
|
|
@@ -2,7 +2,7 @@ const indent = require('../utils/indent');
|
|
|
2
2
|
const { colorThemeCSSProperties } = require('../utils/colors');
|
|
3
3
|
|
|
4
4
|
module.exports = (options) => {
|
|
5
|
-
const { template, theming
|
|
5
|
+
const { template, theming } = options;
|
|
6
6
|
const { customColor, color, fillBars } = theming;
|
|
7
7
|
|
|
8
8
|
let styles = '';
|
|
@@ -44,15 +44,6 @@ module.exports = (options) => {
|
|
|
44
44
|
);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
if (includeTailwind) {
|
|
48
|
-
styles += indent(
|
|
49
|
-
0,
|
|
50
|
-
`
|
|
51
|
-
@import "./tailwind.css";
|
|
52
|
-
`
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
47
|
if (template === 'split-view') {
|
|
57
48
|
styles += indent(
|
|
58
49
|
0,
|
|
@@ -4,10 +4,10 @@ import { Avatar, Title } from 'zmp-framework/react';
|
|
|
4
4
|
const UserCard = ({ user }) => {
|
|
5
5
|
return (
|
|
6
6
|
<div style={{ display: 'flex', width: '100%' }}>
|
|
7
|
-
<Avatar story={user.
|
|
7
|
+
<Avatar story online src={user.avatar.startsWith('http') ? user.avatar : null}>{user.avatar}</Avatar>
|
|
8
8
|
<div style={{ marginLeft: 16 }}>
|
|
9
|
-
<Title style={{ marginBottom: 0 }}>{user.
|
|
10
|
-
<div>{user.
|
|
9
|
+
<Title style={{ marginBottom: 0 }}>{user.name}</Title>
|
|
10
|
+
<div>{user.id}</div>
|
|
11
11
|
</div>
|
|
12
12
|
</div>
|
|
13
13
|
)
|
|
@@ -2,36 +2,45 @@ const path = require('path');
|
|
|
2
2
|
const generateHomePage = require('./generate-home-page');
|
|
3
3
|
const generateRoot = require('./generate-root');
|
|
4
4
|
const generateStore = require('../generate-store');
|
|
5
|
+
const generateRecoil = require('../generate-recoil');
|
|
6
|
+
const copyPages = require('./pages');
|
|
5
7
|
|
|
6
8
|
module.exports = (options) => {
|
|
7
9
|
const cwd = options.cwd || process.cwd();
|
|
8
|
-
const { template } = options;
|
|
10
|
+
const { template, stateManagement } = options;
|
|
9
11
|
const toCopy = [];
|
|
10
12
|
|
|
11
13
|
// Copy Pages
|
|
14
|
+
|
|
12
15
|
let pages = [];
|
|
13
|
-
if (template !== 'blank')
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
if (template !== 'blank')
|
|
17
|
+
pages.push(
|
|
18
|
+
...[
|
|
19
|
+
{ fileName: '404', content: 'copy404' },
|
|
20
|
+
{ fileName: 'about', content: 'copyAbout' },
|
|
21
|
+
{ fileName: 'dynamic-route', content: 'copyDynamicRoute' },
|
|
22
|
+
{ fileName: 'user', content: 'copyUser' },
|
|
23
|
+
{ fileName: 'form', content: 'copyForm' },
|
|
24
|
+
]
|
|
25
|
+
);
|
|
26
|
+
if (template === 'tabs') {
|
|
27
|
+
pages.push(
|
|
28
|
+
...[
|
|
29
|
+
{ fileName: 'catalog', content: 'copyCatalog' },
|
|
30
|
+
{ fileName: 'settings', content: 'copySettings' },
|
|
31
|
+
]
|
|
32
|
+
);
|
|
33
|
+
}
|
|
19
34
|
|
|
20
|
-
pages.forEach((
|
|
21
|
-
const
|
|
22
|
-
let destPage = p;
|
|
23
|
-
if (p === 'user-tabs') {
|
|
24
|
-
destPage = 'user';
|
|
25
|
-
}
|
|
26
|
-
if (p === 'form-tabs') {
|
|
27
|
-
destPage = 'form';
|
|
28
|
-
}
|
|
29
|
-
const dest = path.resolve(cwd, 'src', 'pages', `${destPage}.jsx`);
|
|
35
|
+
pages.forEach(({ fileName, content }) => {
|
|
36
|
+
const dest = path.resolve(cwd, 'src', 'pages', `${fileName}.jsx`);
|
|
30
37
|
toCopy.push({
|
|
31
|
-
|
|
38
|
+
content: copyPages[content](options),
|
|
32
39
|
to: dest,
|
|
33
40
|
});
|
|
34
41
|
});
|
|
42
|
+
|
|
43
|
+
|
|
35
44
|
toCopy.push({
|
|
36
45
|
content: generateHomePage(options),
|
|
37
46
|
to: path.resolve(cwd, 'src', 'pages', 'index.jsx'),
|
|
@@ -55,10 +64,17 @@ module.exports = (options) => {
|
|
|
55
64
|
to: path.resolve(cwd, 'src', 'components', 'app.jsx'),
|
|
56
65
|
});
|
|
57
66
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
67
|
+
if (stateManagement === 'recoil') {
|
|
68
|
+
toCopy.push({
|
|
69
|
+
content: generateRecoil(options),
|
|
70
|
+
to: path.resolve(cwd, 'src', 'state.js'),
|
|
71
|
+
});
|
|
72
|
+
} else {
|
|
73
|
+
toCopy.push({
|
|
74
|
+
content: generateStore(options),
|
|
75
|
+
to: path.resolve(cwd, 'src', 'store.js'),
|
|
76
|
+
});
|
|
77
|
+
}
|
|
62
78
|
|
|
63
79
|
toCopy.push({
|
|
64
80
|
from: path.resolve(__dirname, 'vite.config.js'),
|
|
@@ -9,14 +9,15 @@ var stylesExtension = require('../../utils/styles-extension');
|
|
|
9
9
|
module.exports = function (options) {
|
|
10
10
|
var cssPreProcessor = options.cssPreProcessor,
|
|
11
11
|
theming = options.theming,
|
|
12
|
-
customBuild = options.customBuild
|
|
12
|
+
customBuild = options.customBuild,
|
|
13
|
+
includeTailwind = options.includeTailwind;
|
|
13
14
|
var scripts = '';
|
|
14
|
-
scripts += indent(0, "\n // Import React and ReactDOM\n import React from 'react';\n import
|
|
15
|
+
scripts += indent(0, "\n // Import React and ReactDOM\n import React from 'react';\n import { createRoot } from 'react-dom/client';\n\n // Import ZMP\n import ZMP from '".concat(customBuild ? './zmp-custom.js' : 'zmp-framework/core/lite-bundle', "';\n\n // Import ZMP-React Plugin\n import ZMPReact from 'zmp-framework/react';").concat(includeTailwind ? "\n\n // Import tailwind styles\n import './css/tailwind.css';\n " : '', "\n\n // Import ZMP Styles\n ").concat(templateIf(customBuild, function () {
|
|
15
16
|
return "\n import './css/zmp-custom.less';\n ";
|
|
16
17
|
}, function () {
|
|
17
|
-
return "\n import 'zmp-framework/zmp-bundle.min.css';\n ";
|
|
18
|
+
return "\n import 'zmp-framework/".concat(theming.useUiKits ? 'zmp-bundle.min.css' : 'zmp.min.css', "';\n ");
|
|
18
19
|
}), "\n\n // Import Icons and App Custom Styles\n ").concat(templateIf(theming.iconFonts, function () {
|
|
19
20
|
return "\n import './css/icons.css';\n ";
|
|
20
|
-
}), "\n import './css/app.").concat(stylesExtension(cssPreProcessor), "';\n\n // Import App Component\n import App from './components/app.jsx';\n import appConfig from '../app-config.json';\n\n if (!window.APP_CONFIG) {\n window.APP_CONFIG = appConfig;\n }\n\n // Init ZMP React Plugin\n ZMP.use(ZMPReact)\n\n // Mount React App\n
|
|
21
|
+
}), "\n import './css/app.").concat(stylesExtension(cssPreProcessor), "';\n\n // Import App Component\n import App from './components/app.jsx';\n import appConfig from '../app-config.json';\n\n if (!window.APP_CONFIG) {\n window.APP_CONFIG = appConfig;\n }\n\n // Init ZMP React Plugin\n ZMP.use(ZMPReact)\n\n // Mount React App\n const root = createRoot(document.getElementById('app'));\n root.render(React.createElement(App));\n "));
|
|
21
22
|
return scripts.trim();
|
|
22
23
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const indent = require('../../utils/indent');
|
|
2
2
|
module.exports = (options) => {
|
|
3
|
-
const { name, template, theming } = options;
|
|
3
|
+
const { name, template, theming, stateManagement } = options;
|
|
4
4
|
const { fillBars } = theming;
|
|
5
5
|
|
|
6
6
|
let description = '';
|
|
@@ -45,21 +45,21 @@ module.exports = (options) => {
|
|
|
45
45
|
NavTitleLarge,
|
|
46
46
|
List,
|
|
47
47
|
ListItem,
|
|
48
|
-
useStore,
|
|
49
48
|
Card,
|
|
50
|
-
|
|
49
|
+
${stateManagement === 'store' ? 'useStore,' : ''}
|
|
50
|
+
} from 'zmp-framework/react';${stateManagement === 'recoil' ? `
|
|
51
|
+
import { useRecoilValue } from 'recoil';
|
|
52
|
+
import { userState } from '../state';` : ''}
|
|
51
53
|
import AppItems from '../components/app-items';
|
|
52
54
|
import UserCard from '../components/user-card';
|
|
53
55
|
`.trim()
|
|
54
56
|
}
|
|
55
57
|
|
|
56
58
|
const HomePage = () => {
|
|
57
|
-
${template !== 'blank' ? "const user = useStore('user');" : ''}
|
|
59
|
+
${template !== 'blank' ? (stateManagement === 'recoil' ? "const user = useRecoilValue(userState);" : "const user = useStore('user');") : ''}
|
|
58
60
|
return (
|
|
59
|
-
<Page name="home" ${template === 'tabs' ? '' : 'navbarLarge'}
|
|
60
|
-
|
|
61
|
-
template !== 'tabs'
|
|
62
|
-
? `{/* Top Navbar */}
|
|
61
|
+
<Page name="home" ${template === 'tabs' ? '' : 'navbarLarge'}>${template !== 'tabs' ? `
|
|
62
|
+
{/* Top Navbar */}
|
|
63
63
|
<Navbar ${fillBars ? 'fill' : ''}>
|
|
64
64
|
<NavTitleLarge>${name}</NavTitleLarge>
|
|
65
65
|
</Navbar>`
|
|
@@ -90,10 +90,7 @@ module.exports = (options) => {
|
|
|
90
90
|
</List>
|
|
91
91
|
`.trim()
|
|
92
92
|
: ''
|
|
93
|
-
}
|
|
94
|
-
${
|
|
95
|
-
template === 'tabs'
|
|
96
|
-
? `
|
|
93
|
+
}${template === 'tabs' ? `
|
|
97
94
|
{/* Grid apps */}
|
|
98
95
|
<AppItems />
|
|
99
96
|
|
|
@@ -103,9 +100,7 @@ module.exports = (options) => {
|
|
|
103
100
|
<ListItem title="Default Route (404)" link="/something-that-doesnt-exist" />
|
|
104
101
|
<ListItem title="About" link="/about/" />
|
|
105
102
|
</List>
|
|
106
|
-
`.trim()
|
|
107
|
-
: ''
|
|
108
|
-
}
|
|
103
|
+
`.trim() : ''}
|
|
109
104
|
</Page>
|
|
110
105
|
);
|
|
111
106
|
}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
const templateIf = require('../../utils/template-if');
|
|
1
2
|
const indent = require('../../utils/indent');
|
|
2
3
|
const appParameters = require('../app-parameters');
|
|
3
4
|
|
|
4
5
|
module.exports = (options) => {
|
|
5
|
-
const { template, theming } = options;
|
|
6
|
+
const { template, theming, stateManagement } = options;
|
|
6
7
|
|
|
7
8
|
// Views
|
|
8
9
|
let views = '';
|
|
9
10
|
if (template === 'single-view' || template === 'blank') {
|
|
10
11
|
views = indent(
|
|
11
|
-
|
|
12
|
+
0,
|
|
12
13
|
`
|
|
13
14
|
{/* Your main view, should have "view-main" class */}
|
|
14
15
|
<View main className="safe-areas" url="/" />
|
|
@@ -17,7 +18,7 @@ module.exports = (options) => {
|
|
|
17
18
|
}
|
|
18
19
|
if (template === 'tabs') {
|
|
19
20
|
views = indent(
|
|
20
|
-
|
|
21
|
+
0,
|
|
21
22
|
`
|
|
22
23
|
{/* TabView container */}
|
|
23
24
|
<TabView className="safe-areas">
|
|
@@ -45,48 +46,37 @@ module.exports = (options) => {
|
|
|
45
46
|
return indent(
|
|
46
47
|
0,
|
|
47
48
|
`
|
|
48
|
-
import React, {
|
|
49
|
-
${
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
import {
|
|
53
|
-
zmp,
|
|
54
|
-
zmpready,
|
|
55
|
-
App,
|
|
56
|
-
View,
|
|
57
|
-
} from 'zmp-framework/react';
|
|
49
|
+
import React, { useEffect } from 'react';
|
|
50
|
+
${['blank', 'single-view'].indexOf(template) >= 0
|
|
51
|
+
? `
|
|
52
|
+
import { zmpready, App, View } from 'zmp-framework/react';
|
|
58
53
|
`.trim()
|
|
59
|
-
|
|
60
|
-
import {
|
|
61
|
-
zmp,
|
|
62
|
-
zmpready,
|
|
63
|
-
App,
|
|
64
|
-
TabView,
|
|
65
|
-
View,
|
|
66
|
-
Tabbar,
|
|
67
|
-
Link,
|
|
68
|
-
} from 'zmp-framework/react';
|
|
54
|
+
: `
|
|
55
|
+
import { zmpready, App, TabView, View, Tabbar, Link } from 'zmp-framework/react';
|
|
69
56
|
`.trim()
|
|
70
57
|
}
|
|
71
|
-
import store from '../store'
|
|
58
|
+
${templateIf(stateManagement === 'recoil', () => `import { RecoilRoot } from 'recoil';`, () => `import store from '../store';`)}
|
|
72
59
|
|
|
73
60
|
const MyApp = () => {
|
|
74
61
|
// ZMP Parameters
|
|
75
62
|
const zmpparams = {
|
|
76
|
-
|
|
63
|
+
${indent(8, appParameters(options))}
|
|
77
64
|
};
|
|
78
|
-
useEffect(()=>{
|
|
65
|
+
useEffect(() => {
|
|
79
66
|
zmpready(() => {
|
|
80
67
|
// Call ZMP APIs here
|
|
81
68
|
});
|
|
69
|
+
}, [])
|
|
82
70
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
71
|
+
${`
|
|
72
|
+
return (${stateManagement === 'recoil' ? `
|
|
73
|
+
<RecoilRoot>` : ''}
|
|
74
|
+
${indent(stateManagement === 'recoil' ? 2 : 0, `<App {...zmpparams} ${theming.darkTheme ? 'themeDark' : ''}>`)}
|
|
75
|
+
${indent(stateManagement === 'recoil' ? 12 : 10, views.trim())}
|
|
76
|
+
${indent(stateManagement === 'recoil' ? 2 : 0, `</App>`)}${stateManagement === 'recoil' ? `
|
|
77
|
+
</RecoilRoot>` : ''}
|
|
89
78
|
);
|
|
79
|
+
`.trim()}
|
|
90
80
|
}
|
|
91
81
|
export default MyApp;
|
|
92
82
|
`
|
|
@@ -12,7 +12,7 @@ module.exports = (options) => {
|
|
|
12
12
|
`
|
|
13
13
|
// Import React and ReactDOM
|
|
14
14
|
import React from 'react';
|
|
15
|
-
import
|
|
15
|
+
import { createRoot } from 'react-dom/client';
|
|
16
16
|
|
|
17
17
|
// Import ZMP
|
|
18
18
|
import ZMP from '${
|
|
@@ -20,16 +20,10 @@ module.exports = (options) => {
|
|
|
20
20
|
}';
|
|
21
21
|
|
|
22
22
|
// Import ZMP-React Plugin
|
|
23
|
-
import ZMPReact from 'zmp-framework/react'
|
|
23
|
+
import ZMPReact from 'zmp-framework/react';${includeTailwind ? `
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
() => `
|
|
28
|
-
// Import tailwind styles
|
|
29
|
-
import './css/styles.css';
|
|
30
|
-
`,
|
|
31
|
-
() => ''
|
|
32
|
-
)}
|
|
25
|
+
// Import tailwind styles
|
|
26
|
+
import './css/tailwind.css';` : ''}
|
|
33
27
|
|
|
34
28
|
// Import ZMP Styles
|
|
35
29
|
${templateIf(
|
|
@@ -65,10 +59,8 @@ module.exports = (options) => {
|
|
|
65
59
|
ZMP.use(ZMPReact)
|
|
66
60
|
|
|
67
61
|
// Mount React App
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
document.getElementById('app'),
|
|
71
|
-
);
|
|
62
|
+
const root = createRoot(document.getElementById('app'));
|
|
63
|
+
root.render(React.createElement(App));
|
|
72
64
|
`
|
|
73
65
|
);
|
|
74
66
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const indent = require('../../../utils/indent');
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line no-unused-vars
|
|
4
|
+
module.exports = (options) => {
|
|
5
|
+
return indent(
|
|
6
|
+
0,
|
|
7
|
+
`
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { Page, Card, Title, Box } from 'zmp-framework/react';
|
|
10
|
+
import NavbarBack from '../components/navbar-back';
|
|
11
|
+
|
|
12
|
+
const NotFoundPage = () => (
|
|
13
|
+
<Page>
|
|
14
|
+
<NavbarBack title="Not found" />
|
|
15
|
+
<Box mt="2">
|
|
16
|
+
<Card inset>
|
|
17
|
+
<Title>Sorry</Title>
|
|
18
|
+
<p>Requested content not found.</p>
|
|
19
|
+
</Card>
|
|
20
|
+
</Box>
|
|
21
|
+
</Page>
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
export default NotFoundPage;
|
|
25
|
+
`
|
|
26
|
+
).trim();
|
|
27
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const indent = require('../../../utils/indent');
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line no-unused-vars
|
|
4
|
+
module.exports = (options) => {
|
|
5
|
+
return indent(
|
|
6
|
+
0,
|
|
7
|
+
`
|
|
8
|
+
import React from 'react'
|
|
9
|
+
import { Actions, ActionsButton, ActionsGroup, ActionsLabel, Button, Card, Page, Box } from 'zmp-framework/react';
|
|
10
|
+
import NavbarBack from '../components/navbar-back';
|
|
11
|
+
|
|
12
|
+
const AboutPage = (props) => {
|
|
13
|
+
const [actionSheetOpened, setActionSheetOpened] = React.useState(false);
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<Page name="about">
|
|
17
|
+
<NavbarBack title="About" />
|
|
18
|
+
<Box mt="2">
|
|
19
|
+
<Card inset title="About My App">
|
|
20
|
+
<p>This is a demo ZMP App!</p>
|
|
21
|
+
</Card>
|
|
22
|
+
</Box>
|
|
23
|
+
<Box mb="4">
|
|
24
|
+
<Button
|
|
25
|
+
typeName="secondary"
|
|
26
|
+
responsive
|
|
27
|
+
onClick={() => setActionSheetOpened(true)}
|
|
28
|
+
>
|
|
29
|
+
Back
|
|
30
|
+
</Button>
|
|
31
|
+
</Box>
|
|
32
|
+
<Actions
|
|
33
|
+
opened={actionSheetOpened}
|
|
34
|
+
onActionsClosed={() => setActionSheetOpened(false)}
|
|
35
|
+
id="actions-two-groups"
|
|
36
|
+
>
|
|
37
|
+
<ActionsGroup>
|
|
38
|
+
<ActionsLabel>Are you sure?</ActionsLabel>
|
|
39
|
+
<ActionsButton onClick={() => props.zmprouter.back()}>Navigate back</ActionsButton>
|
|
40
|
+
</ActionsGroup>
|
|
41
|
+
<ActionsGroup>
|
|
42
|
+
<ActionsButton>Cancel</ActionsButton>
|
|
43
|
+
</ActionsGroup>
|
|
44
|
+
</Actions>
|
|
45
|
+
</Page>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default AboutPage;
|
|
50
|
+
`
|
|
51
|
+
).trim();
|
|
52
|
+
};
|