@lowdefy/server 3.23.2 → 4.0.0-alpha.6
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/.eslintrc.yaml +1 -0
- package/README.md +17 -1
- package/next.config.js +34 -0
- package/package.json +31 -25
- package/public/.DS_Store +0 -0
- package/public/apple-touch-icon.png +0 -0
- package/public/favicon.ico +0 -0
- package/public/icon-512.png +0 -0
- package/public/icon.svg +17 -0
- package/public/logo-dark-theme.png +0 -0
- package/public/logo-light-theme.png +0 -0
- package/public/logo-square-dark-theme.png +0 -0
- package/public/logo-square-light-theme.png +0 -0
- package/public/manifest.webmanifest +16 -0
- package/src/components/Context.js +61 -0
- package/src/components/Head.js +28 -0
- package/src/components/LowdefyContext.js +49 -0
- package/src/components/Page.js +60 -0
- package/src/components/block/Block.js +57 -0
- package/src/components/block/CategorySwitch.js +120 -0
- package/src/components/block/Container.js +87 -0
- package/src/components/block/List.js +94 -0
- package/src/components/block/LoadingBlock.js +22 -0
- package/src/components/block/MountEvents.js +46 -0
- package/src/components/components.js +25 -0
- package/src/pages/404.js +38 -0
- package/src/pages/[pageId].js +50 -0
- package/src/pages/_app.js +37 -0
- package/src/pages/_document.js +38 -0
- package/src/pages/api/auth/[...nextauth].js +28 -0
- package/src/pages/api/request/[pageId]/[requestId].js +44 -0
- package/src/pages/index.js +50 -0
- package/src/utils/callRequest.js +27 -0
- package/src/utils/request.js +35 -0
- package/src/utils/setupLink.js +44 -0
- package/dist/index.js +0 -106
package/.eslintrc.yaml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
extends: 'plugin:@next/next/core-web-vitals'
|
package/README.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @lowdefy/server
|
|
2
2
|
|
|
3
|
+
## Development
|
|
4
|
+
|
|
5
|
+
To run the server in locally as a development server, run the following:
|
|
6
|
+
|
|
7
|
+
- Run `yarn && yarn build` at the root of the repository.
|
|
8
|
+
- Add a `lowdefy.yaml` file in the server directory (`packages/server`).
|
|
9
|
+
- run `yarn dev` in the server directory.
|
|
10
|
+
|
|
11
|
+
To run the server in locally as a development server, with a next production build, run the following:
|
|
12
|
+
|
|
13
|
+
- Run `yarn && yarn build` at the root of the repository.
|
|
14
|
+
- Add a `lowdefy.yaml` file in the server directory (`packages/server`).
|
|
15
|
+
- run `yarn dev:prod` in the server directory.
|
|
16
|
+
|
|
17
|
+
> When running a development server, the `package.json` file is updated with the plugins used in the Lowdefy app. Please do not commit the changes made to the `package.json`, `.pnp.cjs` and `yarn.lock` files.
|
|
18
|
+
|
|
3
19
|
## Licence
|
|
4
20
|
|
|
5
|
-
[Apache-2.0](https://github.com/lowdefy/lowdefy/blob/main/LICENSE)
|
|
21
|
+
[Apache-2.0](https://github.com/lowdefy/lowdefy/blob/main/LICENSE)
|
package/next.config.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const withLess = require('next-with-less');
|
|
2
|
+
const lowdefyConfig = require('./build/config.json');
|
|
3
|
+
|
|
4
|
+
module.exports = withLess({
|
|
5
|
+
lessLoaderOptions: {
|
|
6
|
+
lessOptions: {
|
|
7
|
+
modifyVars: lowdefyConfig.theme.lessVariables,
|
|
8
|
+
},
|
|
9
|
+
},
|
|
10
|
+
reactStrictMode: true,
|
|
11
|
+
webpack: (config, { isServer }) => {
|
|
12
|
+
if (!isServer) {
|
|
13
|
+
config.resolve.fallback = {
|
|
14
|
+
assert: false,
|
|
15
|
+
buffer: false,
|
|
16
|
+
crypto: false,
|
|
17
|
+
events: false,
|
|
18
|
+
fs: false,
|
|
19
|
+
path: false,
|
|
20
|
+
process: require.resolve('process/browser'),
|
|
21
|
+
util: false,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return config;
|
|
25
|
+
},
|
|
26
|
+
poweredByHeader: false,
|
|
27
|
+
// productionBrowserSourceMaps: true
|
|
28
|
+
// experimental: {
|
|
29
|
+
// concurrentFeatures: true,
|
|
30
|
+
// },
|
|
31
|
+
eslint: {
|
|
32
|
+
ignoreDuringBuilds: true,
|
|
33
|
+
},
|
|
34
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/server",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.6",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -25,39 +25,45 @@
|
|
|
25
25
|
"type": "git",
|
|
26
26
|
"url": "https://github.com/lowdefy/lowdefy.git"
|
|
27
27
|
},
|
|
28
|
-
"main": "dist/index.js",
|
|
29
28
|
"files": [
|
|
30
|
-
"
|
|
29
|
+
"src/*",
|
|
30
|
+
"public/*",
|
|
31
|
+
"next.config.js",
|
|
32
|
+
".eslintrc.yaml"
|
|
31
33
|
],
|
|
32
34
|
"scripts": {
|
|
33
|
-
"
|
|
34
|
-
"build": "
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"start": "
|
|
35
|
+
"build:lowdefy": "lowdefy-build",
|
|
36
|
+
"build:next": "next build",
|
|
37
|
+
"dev": "yarn build:lowdefy && yarn && next dev",
|
|
38
|
+
"dev:prod": "yarn build:lowdefy && yarn && yarn build:next && next start",
|
|
39
|
+
"start": "next start",
|
|
40
|
+
"lint": "next lint",
|
|
41
|
+
"next": "next"
|
|
38
42
|
},
|
|
39
43
|
"dependencies": {
|
|
40
|
-
"@lowdefy/
|
|
41
|
-
"@lowdefy/
|
|
42
|
-
"@lowdefy/
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
44
|
+
"@lowdefy/api": "4.0.0-alpha.6",
|
|
45
|
+
"@lowdefy/block-utils": "4.0.0-alpha.6",
|
|
46
|
+
"@lowdefy/engine": "4.0.0-alpha.6",
|
|
47
|
+
"@lowdefy/helpers": "4.0.0-alpha.6",
|
|
48
|
+
"@lowdefy/layout": "4.0.0-alpha.6",
|
|
49
|
+
"@lowdefy/node-utils": "4.0.0-alpha.6",
|
|
50
|
+
"@lowdefy/operators-js": "4.0.0-alpha.6",
|
|
51
|
+
"next": "12.0.3",
|
|
52
|
+
"next-auth": "4.0.0-beta.6",
|
|
53
|
+
"process": "0.11.10",
|
|
54
|
+
"react": "18.0.0-alpha-327d5c484-20211106",
|
|
55
|
+
"react-dom": "18.0.0-alpha-327d5c484-20211106",
|
|
56
|
+
"react-icons": "4.3.1"
|
|
47
57
|
},
|
|
48
58
|
"devDependencies": {
|
|
49
|
-
"@
|
|
50
|
-
"@
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"babel-jest": "26.6.3",
|
|
55
|
-
"babel-loader": "8.2.2",
|
|
56
|
-
"jest": "26.6.3",
|
|
57
|
-
"nodemon": "2.0.7"
|
|
59
|
+
"@lowdefy/build": "4.0.0-alpha.6",
|
|
60
|
+
"@next/eslint-plugin-next": "12.0.4",
|
|
61
|
+
"less": "4.1.2",
|
|
62
|
+
"less-loader": "10.2.0",
|
|
63
|
+
"next-with-less": "2.0.2"
|
|
58
64
|
},
|
|
59
65
|
"publishConfig": {
|
|
60
66
|
"access": "public"
|
|
61
67
|
},
|
|
62
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "2530e31af795b6a3c75ac8f72c8dbe0ab5d1251b"
|
|
63
69
|
}
|
package/public/.DS_Store
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/public/icon.svg
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
2
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
3
|
+
<svg width="100%" height="100%" viewBox="0 0 94 94" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
|
4
|
+
<g transform="matrix(1,0,0,1,-979.672,-59.6924)">
|
|
5
|
+
<g transform="matrix(1,0,0,1.03297,-38.3284,-294.615)">
|
|
6
|
+
<g transform="matrix(1,0,0,1,952,232)">
|
|
7
|
+
<path d="M160,129.634C160,119.35 151.375,111 140.751,111L85.249,111C74.625,111 66,119.35 66,129.634L66,183.366C66,193.65 74.625,202 85.249,202L140.751,202C151.375,202 160,193.65 160,183.366L160,129.634Z"/>
|
|
8
|
+
</g>
|
|
9
|
+
<g transform="matrix(0.872141,0,0,1,1002.6,346)">
|
|
10
|
+
<rect x="36" y="12" width="36" height="59" style="fill:white;"/>
|
|
11
|
+
</g>
|
|
12
|
+
<g transform="matrix(0.78125,0,0,0.862069,1010.84,356.663)">
|
|
13
|
+
<rect x="77" y="41" width="32" height="29" style="fill:rgb(24,144,255);"/>
|
|
14
|
+
</g>
|
|
15
|
+
</g>
|
|
16
|
+
</g>
|
|
17
|
+
</svg>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"short_name": "Lowdefy App",
|
|
3
|
+
"name": "Lowdefy App",
|
|
4
|
+
"description": "Lowdefy App",
|
|
5
|
+
"icons": [
|
|
6
|
+
{
|
|
7
|
+
"src": "/public/icon-512.png",
|
|
8
|
+
"type": "image/png",
|
|
9
|
+
"sizes": "512x512"
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"start_url": "/",
|
|
13
|
+
"background_color": "#FFFFFF",
|
|
14
|
+
"display": "browser",
|
|
15
|
+
"scope": "/"
|
|
16
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2021 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import React, { useEffect, useState } from 'react';
|
|
18
|
+
import getContext from '@lowdefy/engine';
|
|
19
|
+
|
|
20
|
+
import MountEvents from './block/MountEvents.js';
|
|
21
|
+
|
|
22
|
+
const Context = ({ children, lowdefy, config }) => {
|
|
23
|
+
const [context, setContext] = useState({});
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
let mounted = true;
|
|
27
|
+
const mount = async () => {
|
|
28
|
+
const ctx = await getContext({
|
|
29
|
+
config,
|
|
30
|
+
lowdefy,
|
|
31
|
+
});
|
|
32
|
+
if (mounted) {
|
|
33
|
+
setContext(ctx);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
mount();
|
|
37
|
+
return () => {
|
|
38
|
+
mounted = false;
|
|
39
|
+
};
|
|
40
|
+
}, [config, lowdefy]);
|
|
41
|
+
const loadingPage = context.id !== config.id;
|
|
42
|
+
|
|
43
|
+
if (loadingPage) {
|
|
44
|
+
return children(context, loadingPage, 'pager');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<MountEvents
|
|
49
|
+
asyncEventName="onEnterAsync"
|
|
50
|
+
context={context}
|
|
51
|
+
eventName="onEnter"
|
|
52
|
+
triggerEvent={({ name, context }) =>
|
|
53
|
+
context._internal.RootBlocks.areas.root.blocks[0].triggerEvent({ name })
|
|
54
|
+
}
|
|
55
|
+
>
|
|
56
|
+
{(loading) => children(context, loading, 'mounter')}
|
|
57
|
+
</MountEvents>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export default Context;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2021 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import React from 'react';
|
|
18
|
+
import Head from 'next/head';
|
|
19
|
+
|
|
20
|
+
const BindHead = ({ properties }) => {
|
|
21
|
+
return (
|
|
22
|
+
<Head>
|
|
23
|
+
<title>{properties.title}</title>
|
|
24
|
+
</Head>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default BindHead;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2021 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import React from 'react';
|
|
18
|
+
|
|
19
|
+
import callRequest from '../utils/callRequest.js';
|
|
20
|
+
import blockComponents from '../../build/plugins/blocks.js';
|
|
21
|
+
import operators from '../../build/plugins/operatorsClient.js';
|
|
22
|
+
import components from './components.js';
|
|
23
|
+
|
|
24
|
+
const LowdefyContext = ({ children }) => {
|
|
25
|
+
const lowdefy = {
|
|
26
|
+
_internal: {
|
|
27
|
+
blockComponents,
|
|
28
|
+
callRequest,
|
|
29
|
+
components,
|
|
30
|
+
document,
|
|
31
|
+
operators,
|
|
32
|
+
updaters: {},
|
|
33
|
+
window,
|
|
34
|
+
displayMessage: ({ content }) => {
|
|
35
|
+
alert(content);
|
|
36
|
+
return () => undefined;
|
|
37
|
+
},
|
|
38
|
+
link: () => undefined,
|
|
39
|
+
},
|
|
40
|
+
contexts: {},
|
|
41
|
+
inputs: {},
|
|
42
|
+
lowdefyGlobal: {},
|
|
43
|
+
};
|
|
44
|
+
lowdefy._internal.updateBlock = (blockId) =>
|
|
45
|
+
lowdefy._internal.updaters[blockId] && lowdefy._internal.updaters[blockId]();
|
|
46
|
+
return <>{children(lowdefy)}</>;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export default LowdefyContext;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2021 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import React from 'react';
|
|
18
|
+
|
|
19
|
+
import { useRouter } from 'next/router';
|
|
20
|
+
|
|
21
|
+
import Context from './Context.js';
|
|
22
|
+
import Head from './Head.js';
|
|
23
|
+
import Block from './block/Block.js';
|
|
24
|
+
import setupLink from '../utils/setupLink.js';
|
|
25
|
+
|
|
26
|
+
const LoadingBlock = () => <div>Loading...</div>;
|
|
27
|
+
|
|
28
|
+
const Page = ({ lowdefy, pageConfig, rootConfig }) => {
|
|
29
|
+
const router = useRouter();
|
|
30
|
+
lowdefy._internal.basePath = router.basePath;
|
|
31
|
+
lowdefy._internal.pathname = router.pathname;
|
|
32
|
+
lowdefy._internal.query = router.query;
|
|
33
|
+
lowdefy._internal.router = router;
|
|
34
|
+
lowdefy._internal.link = setupLink({ lowdefy });
|
|
35
|
+
lowdefy.home = rootConfig.home;
|
|
36
|
+
lowdefy.lowdefyGlobal = rootConfig.lowdefyGlobal;
|
|
37
|
+
lowdefy.menus = rootConfig.menus;
|
|
38
|
+
return (
|
|
39
|
+
<Context config={pageConfig} lowdefy={lowdefy}>
|
|
40
|
+
{(context, loading) => {
|
|
41
|
+
if (loading) {
|
|
42
|
+
return <LoadingBlock />;
|
|
43
|
+
}
|
|
44
|
+
return (
|
|
45
|
+
<>
|
|
46
|
+
<Head properties={context._internal.RootBlocks.map[pageConfig.id].eval.properties} />
|
|
47
|
+
<Block
|
|
48
|
+
block={context._internal.RootBlocks.map[pageConfig.id]}
|
|
49
|
+
Blocks={context._internal.RootBlocks}
|
|
50
|
+
context={context}
|
|
51
|
+
lowdefy={lowdefy}
|
|
52
|
+
/>
|
|
53
|
+
</>
|
|
54
|
+
);
|
|
55
|
+
}}
|
|
56
|
+
</Context>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export default Page;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2021 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import React, { Suspense, useState } from 'react';
|
|
18
|
+
|
|
19
|
+
import { ErrorBoundary } from '@lowdefy/block-utils';
|
|
20
|
+
|
|
21
|
+
import CategorySwitch from './CategorySwitch.js';
|
|
22
|
+
import LoadingBlock from './LoadingBlock.js';
|
|
23
|
+
import MountEvents from './MountEvents.js';
|
|
24
|
+
|
|
25
|
+
const Block = ({ block, Blocks, context, isRoot, lowdefy }) => {
|
|
26
|
+
const [updates, setUpdate] = useState(0);
|
|
27
|
+
lowdefy._internal.updaters[block.id] = () => setUpdate(updates + 1);
|
|
28
|
+
return (
|
|
29
|
+
<ErrorBoundary>
|
|
30
|
+
<Suspense fallback={<LoadingBlock block={block} lowdefy={lowdefy} />}>
|
|
31
|
+
<MountEvents
|
|
32
|
+
asyncEventName="onMountAsync"
|
|
33
|
+
context={context}
|
|
34
|
+
eventName="onMount"
|
|
35
|
+
triggerEvent={block.triggerEvent}
|
|
36
|
+
>
|
|
37
|
+
{(loading) =>
|
|
38
|
+
loading ? (
|
|
39
|
+
<LoadingBlock block={block} lowdefy={lowdefy} />
|
|
40
|
+
) : (
|
|
41
|
+
<CategorySwitch
|
|
42
|
+
block={block}
|
|
43
|
+
Blocks={Blocks}
|
|
44
|
+
context={context}
|
|
45
|
+
isRoot={isRoot}
|
|
46
|
+
lowdefy={lowdefy}
|
|
47
|
+
updates={updates}
|
|
48
|
+
/>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
</MountEvents>
|
|
52
|
+
</Suspense>
|
|
53
|
+
</ErrorBoundary>
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export default Block;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2021 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import React from 'react';
|
|
18
|
+
import { BlockLayout } from '@lowdefy/layout';
|
|
19
|
+
import { makeCssClass } from '@lowdefy/block-utils';
|
|
20
|
+
|
|
21
|
+
import Container from './Container.js';
|
|
22
|
+
import List from './List.js';
|
|
23
|
+
|
|
24
|
+
const CategorySwitch = ({ block, Blocks, context, lowdefy }) => {
|
|
25
|
+
if (!block.eval) return null; // Renderer updates before eval is executed for the first time on lists. See #520
|
|
26
|
+
if (block.eval.visible === false)
|
|
27
|
+
return <div id={`vs-${block.blockId}`} style={{ display: 'none' }} />;
|
|
28
|
+
const Component = lowdefy._internal.blockComponents[block.type];
|
|
29
|
+
switch (Component.meta.category) {
|
|
30
|
+
case 'list':
|
|
31
|
+
return (
|
|
32
|
+
<List
|
|
33
|
+
block={block}
|
|
34
|
+
Blocks={Blocks}
|
|
35
|
+
Component={Component}
|
|
36
|
+
context={context}
|
|
37
|
+
lowdefy={lowdefy}
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
case 'container':
|
|
41
|
+
return (
|
|
42
|
+
<Container
|
|
43
|
+
block={block}
|
|
44
|
+
Blocks={Blocks}
|
|
45
|
+
Component={Component}
|
|
46
|
+
context={context}
|
|
47
|
+
lowdefy={lowdefy}
|
|
48
|
+
/>
|
|
49
|
+
);
|
|
50
|
+
case 'input':
|
|
51
|
+
return (
|
|
52
|
+
<BlockLayout
|
|
53
|
+
id={`bl-${block.blockId}`}
|
|
54
|
+
blockStyle={block.eval.style}
|
|
55
|
+
highlightBorders={lowdefy.lowdefyGlobal.highlightBorders}
|
|
56
|
+
layout={block.eval.layout || {}}
|
|
57
|
+
makeCssClass={makeCssClass}
|
|
58
|
+
>
|
|
59
|
+
<Component
|
|
60
|
+
methods={Object.assign(block.methods, {
|
|
61
|
+
makeCssClass,
|
|
62
|
+
registerEvent: block.registerEvent,
|
|
63
|
+
registerMethod: block.registerMethod,
|
|
64
|
+
setValue: block.setValue,
|
|
65
|
+
triggerEvent: block.triggerEvent,
|
|
66
|
+
})}
|
|
67
|
+
// TODO: React throws a basePath warning
|
|
68
|
+
basePath={lowdefy._internal.basePath}
|
|
69
|
+
blockId={block.blockId}
|
|
70
|
+
components={lowdefy._internal.components}
|
|
71
|
+
events={block.eval.events}
|
|
72
|
+
homePageId={lowdefy.home.pageId}
|
|
73
|
+
key={block.blockId}
|
|
74
|
+
loading={block.loading}
|
|
75
|
+
menus={lowdefy.menus}
|
|
76
|
+
pageId={lowdefy.pageId}
|
|
77
|
+
properties={block.eval.properties}
|
|
78
|
+
required={block.eval.required}
|
|
79
|
+
user={lowdefy.user}
|
|
80
|
+
validation={block.eval.validation}
|
|
81
|
+
value={block.value}
|
|
82
|
+
/>
|
|
83
|
+
</BlockLayout>
|
|
84
|
+
);
|
|
85
|
+
default:
|
|
86
|
+
return (
|
|
87
|
+
<BlockLayout
|
|
88
|
+
id={`bl-${block.blockId}`}
|
|
89
|
+
blockStyle={block.eval.style}
|
|
90
|
+
highlightBorders={lowdefy.lowdefyGlobal.highlightBorders}
|
|
91
|
+
layout={block.eval.layout || {}}
|
|
92
|
+
makeCssClass={makeCssClass}
|
|
93
|
+
>
|
|
94
|
+
<Component
|
|
95
|
+
methods={Object.assign(block.methods, {
|
|
96
|
+
makeCssClass,
|
|
97
|
+
registerEvent: block.registerEvent,
|
|
98
|
+
registerMethod: block.registerMethod,
|
|
99
|
+
triggerEvent: block.triggerEvent,
|
|
100
|
+
})}
|
|
101
|
+
basePath={lowdefy._internal.basePath}
|
|
102
|
+
blockId={block.blockId}
|
|
103
|
+
components={lowdefy._internal.components}
|
|
104
|
+
events={block.eval.events}
|
|
105
|
+
homePageId={lowdefy.home.pageId}
|
|
106
|
+
key={block.blockId}
|
|
107
|
+
loading={block.loading}
|
|
108
|
+
menus={lowdefy.menus}
|
|
109
|
+
pageId={lowdefy.pageId}
|
|
110
|
+
properties={block.eval.properties}
|
|
111
|
+
required={block.eval.required}
|
|
112
|
+
user={lowdefy.user}
|
|
113
|
+
validation={block.eval.validation}
|
|
114
|
+
/>
|
|
115
|
+
</BlockLayout>
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export default CategorySwitch;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2021 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import React from 'react';
|
|
18
|
+
import { Area, BlockLayout, layoutParamsToArea } from '@lowdefy/layout';
|
|
19
|
+
import { makeCssClass } from '@lowdefy/block-utils';
|
|
20
|
+
|
|
21
|
+
import Block from './Block.js';
|
|
22
|
+
|
|
23
|
+
const Container = ({ block, Blocks, Component, context, lowdefy }) => {
|
|
24
|
+
const content = {};
|
|
25
|
+
// eslint-disable-next-line prefer-destructuring
|
|
26
|
+
const areas = Blocks.subBlocks[block.id][0].areas;
|
|
27
|
+
Object.keys(areas).forEach((areaKey) => {
|
|
28
|
+
content[areaKey] = (areaStyle) => (
|
|
29
|
+
<Area
|
|
30
|
+
id={`ar-${block.blockId}-${areaKey}`}
|
|
31
|
+
key={`ar-${block.blockId}-${areaKey}`}
|
|
32
|
+
area={layoutParamsToArea({
|
|
33
|
+
area: block.eval.areas[areaKey] || {},
|
|
34
|
+
areaKey,
|
|
35
|
+
layout: block.eval.layout || {},
|
|
36
|
+
})}
|
|
37
|
+
areaStyle={[areaStyle, block.eval.areas[areaKey] && block.eval.areas[areaKey].style]}
|
|
38
|
+
highlightBorders={lowdefy.lowdefyGlobal.highlightBorders}
|
|
39
|
+
makeCssClass={makeCssClass}
|
|
40
|
+
>
|
|
41
|
+
{areas[areaKey].blocks.map((bl) => (
|
|
42
|
+
<Block
|
|
43
|
+
key={`co-${bl.blockId}`}
|
|
44
|
+
Blocks={Blocks.subBlocks[block.id][0]}
|
|
45
|
+
block={bl}
|
|
46
|
+
context={context}
|
|
47
|
+
lowdefy={lowdefy}
|
|
48
|
+
/>
|
|
49
|
+
))}
|
|
50
|
+
</Area>
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
return (
|
|
54
|
+
<BlockLayout
|
|
55
|
+
id={`bl-${block.blockId}`}
|
|
56
|
+
blockStyle={block.eval.style}
|
|
57
|
+
highlightBorders={lowdefy.lowdefyGlobal.highlightBorders}
|
|
58
|
+
layout={block.eval.layout || {}}
|
|
59
|
+
makeCssClass={makeCssClass}
|
|
60
|
+
>
|
|
61
|
+
<Component
|
|
62
|
+
methods={Object.assign(block.methods, {
|
|
63
|
+
makeCssClass,
|
|
64
|
+
registerEvent: block.registerEvent,
|
|
65
|
+
registerMethod: block.registerMethod,
|
|
66
|
+
triggerEvent: block.triggerEvent,
|
|
67
|
+
})}
|
|
68
|
+
basePath={lowdefy._internal.basePath}
|
|
69
|
+
blockId={block.blockId}
|
|
70
|
+
components={lowdefy._internal.components}
|
|
71
|
+
content={content}
|
|
72
|
+
events={block.eval.events}
|
|
73
|
+
homePageId={lowdefy.home.pageId}
|
|
74
|
+
key={block.blockId}
|
|
75
|
+
loading={block.loading}
|
|
76
|
+
menus={lowdefy.menus}
|
|
77
|
+
pageId={lowdefy.pageId}
|
|
78
|
+
properties={block.eval.properties}
|
|
79
|
+
required={block.eval.required}
|
|
80
|
+
user={lowdefy.user}
|
|
81
|
+
validation={block.eval.validation}
|
|
82
|
+
/>
|
|
83
|
+
</BlockLayout>
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export default Container;
|