@lowdefy/client 4.0.0-alpha.9
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/LICENSE +201 -0
- package/README.md +3 -0
- package/dist/Client.js +67 -0
- package/dist/Context.js +45 -0
- package/dist/DisplayMessage.js +29 -0
- package/dist/ErrorBoundary.js +52 -0
- package/dist/ErrorPage.js +61 -0
- package/dist/Head.js +19 -0
- package/dist/MountEvents.js +43 -0
- package/dist/ProgressBarController.js +85 -0
- package/dist/block/Block.js +62 -0
- package/dist/block/CategorySwitch.js +116 -0
- package/dist/block/Container.js +77 -0
- package/dist/block/List.js +86 -0
- package/dist/block/LoadingBlock.js +84 -0
- package/dist/block/LoadingContainer.js +68 -0
- package/dist/block/LoadingList.js +72 -0
- package/dist/callRequest.js +25 -0
- package/dist/createIcon.js +103 -0
- package/dist/createLinkComponent.js +65 -0
- package/dist/index.js +16 -0
- package/dist/initLowdefyContext.js +66 -0
- package/dist/request.js +32 -0
- package/dist/setupLink.js +51 -0
- package/dist/style.less +29 -0
- package/package.json +71 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { createLink } from '@lowdefy/engine';
|
|
3
|
+
import { type } from '@lowdefy/helpers';
|
|
4
|
+
const createLinkComponent = (lowdefy, Link)=>{
|
|
5
|
+
const backLink = ({ ariaLabel , children , className , id , rel })=>/*#__PURE__*/ React.createElement("a", {
|
|
6
|
+
id: id,
|
|
7
|
+
onClick: ()=>lowdefy._internal.router.back()
|
|
8
|
+
,
|
|
9
|
+
className: className,
|
|
10
|
+
rel: rel,
|
|
11
|
+
"aria-label": ariaLabel || 'back'
|
|
12
|
+
}, type.isFunction(children) ? children(id) : children)
|
|
13
|
+
;
|
|
14
|
+
const newOriginLink = ({ ariaLabel , children , className , id , newTab , pageId , query , rel , url , })=>{
|
|
15
|
+
return(/*#__PURE__*/ React.createElement("a", {
|
|
16
|
+
id: id,
|
|
17
|
+
"aria-label": ariaLabel,
|
|
18
|
+
className: className,
|
|
19
|
+
href: `${url}${query ? `?${query}` : ''}`,
|
|
20
|
+
rel: rel || newTab && 'noopener noreferrer',
|
|
21
|
+
target: newTab && '_blank'
|
|
22
|
+
}, type.isFunction(children) ? children(pageId || url || id) : children));
|
|
23
|
+
};
|
|
24
|
+
const sameOriginLink = ({ ariaLabel , children , className , id , newTab , pageId , pathname , query , rel , replace , scroll , setInput , url , })=>{
|
|
25
|
+
if (newTab) {
|
|
26
|
+
return(// eslint-disable-next-line react/jsx-no-target-blank
|
|
27
|
+
/*#__PURE__*/ React.createElement("a", {
|
|
28
|
+
id: id,
|
|
29
|
+
"aria-label": ariaLabel,
|
|
30
|
+
className: className,
|
|
31
|
+
href: `${window.location.origin}${lowdefy._internal.router.basePath}${pathname}${query ? `?${query}` : ''}`,
|
|
32
|
+
rel: rel || 'noopener noreferrer',
|
|
33
|
+
target: "_blank"
|
|
34
|
+
}, type.isFunction(children) ? children(pageId || url || id) : children));
|
|
35
|
+
}
|
|
36
|
+
return(/*#__PURE__*/ React.createElement(Link, {
|
|
37
|
+
href: {
|
|
38
|
+
pathname,
|
|
39
|
+
query
|
|
40
|
+
},
|
|
41
|
+
replace: replace,
|
|
42
|
+
scroll: scroll
|
|
43
|
+
}, /*#__PURE__*/ React.createElement("a", {
|
|
44
|
+
id: id,
|
|
45
|
+
"aria-label": ariaLabel,
|
|
46
|
+
className: className,
|
|
47
|
+
rel: rel,
|
|
48
|
+
onClick: setInput
|
|
49
|
+
}, type.isFunction(children) ? children(pageId || url || id) : children)));
|
|
50
|
+
};
|
|
51
|
+
const noLink = ({ className , children , id })=>/*#__PURE__*/ React.createElement("span", {
|
|
52
|
+
id: id,
|
|
53
|
+
className: className
|
|
54
|
+
}, type.isFunction(children) ? children(id) : children)
|
|
55
|
+
;
|
|
56
|
+
return createLink({
|
|
57
|
+
backLink,
|
|
58
|
+
lowdefy,
|
|
59
|
+
newOriginLink,
|
|
60
|
+
sameOriginLink,
|
|
61
|
+
noLink,
|
|
62
|
+
disabledLink: noLink
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
export default createLinkComponent;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 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
|
+
*/ import Client from './Client.js';
|
|
16
|
+
export default Client;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 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
|
+
*/ import { urlQuery } from '@lowdefy/helpers';
|
|
16
|
+
import callRequest from './callRequest.js';
|
|
17
|
+
import createIcon from './createIcon.js';
|
|
18
|
+
import createLinkComponent from './createLinkComponent.js';
|
|
19
|
+
import setupLink from './setupLink.js';
|
|
20
|
+
const lowdefy = {
|
|
21
|
+
_internal: {
|
|
22
|
+
callRequest,
|
|
23
|
+
components: {},
|
|
24
|
+
updaters: {},
|
|
25
|
+
displayMessage: ({ content })=>{
|
|
26
|
+
console.log(content);
|
|
27
|
+
return ()=>undefined
|
|
28
|
+
;
|
|
29
|
+
},
|
|
30
|
+
link: ()=>undefined
|
|
31
|
+
,
|
|
32
|
+
progress: {
|
|
33
|
+
state: {
|
|
34
|
+
progress: 0
|
|
35
|
+
},
|
|
36
|
+
dispatch: ()=>undefined
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
contexts: {},
|
|
40
|
+
inputs: {},
|
|
41
|
+
lowdefyGlobal: {}
|
|
42
|
+
};
|
|
43
|
+
function initLowdefyContext({ Components , config , router , stage , types , window }) {
|
|
44
|
+
if (stage === 'dev') {
|
|
45
|
+
window.lowdefy = lowdefy;
|
|
46
|
+
}
|
|
47
|
+
lowdefy.basePath = router.basePath;
|
|
48
|
+
lowdefy.home = config.rootConfig.home || {};
|
|
49
|
+
lowdefy.lowdefyGlobal = config.rootConfig.lowdefyGlobal;
|
|
50
|
+
lowdefy.menus = config.rootConfig.menus;
|
|
51
|
+
lowdefy.pageId = config.pageConfig.pageId;
|
|
52
|
+
lowdefy.urlQuery = urlQuery.parse(window.location.search.slice(1));
|
|
53
|
+
lowdefy._internal.window = window;
|
|
54
|
+
lowdefy._internal.document = window.document;
|
|
55
|
+
lowdefy._internal.router = router;
|
|
56
|
+
lowdefy._internal.link = setupLink(lowdefy);
|
|
57
|
+
lowdefy._internal.updateBlock = (blockId)=>lowdefy._internal.updaters[blockId] && lowdefy._internal.updaters[blockId]()
|
|
58
|
+
;
|
|
59
|
+
lowdefy._internal.components.Link = createLinkComponent(lowdefy, Components.Link);
|
|
60
|
+
lowdefy._internal.components.Icon = createIcon(types.icons);
|
|
61
|
+
lowdefy._internal.actions = types.actions;
|
|
62
|
+
lowdefy._internal.blockComponents = types.blocks;
|
|
63
|
+
lowdefy._internal.operators = types.operators;
|
|
64
|
+
return lowdefy;
|
|
65
|
+
}
|
|
66
|
+
export default initLowdefyContext;
|
package/dist/request.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 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
|
+
*/ async function request({ url , method ='GET' , body }) {
|
|
16
|
+
const res = await fetch(url, {
|
|
17
|
+
method,
|
|
18
|
+
headers: {
|
|
19
|
+
'Content-Type': 'application/json'
|
|
20
|
+
},
|
|
21
|
+
body: JSON.stringify(body)
|
|
22
|
+
});
|
|
23
|
+
if (!res.ok) {
|
|
24
|
+
// TODO: check
|
|
25
|
+
const body = await res.json();
|
|
26
|
+
console.log(res);
|
|
27
|
+
console.log(body);
|
|
28
|
+
throw new Error(body.message || 'Request error');
|
|
29
|
+
}
|
|
30
|
+
return res.json();
|
|
31
|
+
}
|
|
32
|
+
export default request;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 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
|
+
*/ import { createLink } from '@lowdefy/engine';
|
|
16
|
+
function setupLink(lowdefy) {
|
|
17
|
+
const { router , window } = lowdefy._internal;
|
|
18
|
+
const backLink = ()=>router.back()
|
|
19
|
+
;
|
|
20
|
+
const disabledLink = ()=>{};
|
|
21
|
+
const newOriginLink = ({ url , query , newTab })=>{
|
|
22
|
+
if (newTab) {
|
|
23
|
+
return window.open(`${url}${query ? `?${query}` : ''}`, '_blank').focus();
|
|
24
|
+
} else {
|
|
25
|
+
return window.location.assign(`${url}${query ? `?${query}` : ''}`);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const sameOriginLink = ({ newTab , pathname , query , setInput })=>{
|
|
29
|
+
if (newTab) {
|
|
30
|
+
return window.open(`${window.location.origin}${lowdefy.basePath}${pathname}${query ? `?${query}` : ''}`, '_blank').focus();
|
|
31
|
+
} else {
|
|
32
|
+
setInput();
|
|
33
|
+
return router.push({
|
|
34
|
+
pathname,
|
|
35
|
+
query
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const noLink = ()=>{
|
|
40
|
+
throw new Error(`Invalid Link.`);
|
|
41
|
+
};
|
|
42
|
+
return createLink({
|
|
43
|
+
backLink,
|
|
44
|
+
disabledLink,
|
|
45
|
+
lowdefy,
|
|
46
|
+
newOriginLink,
|
|
47
|
+
noLink,
|
|
48
|
+
sameOriginLink
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
export default setupLink;
|
package/dist/style.less
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 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
|
+
.icon-spin {
|
|
18
|
+
animation: spin 1s infinite linear;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@keyframes spin {
|
|
22
|
+
0% {
|
|
23
|
+
transform: rotate(0deg);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
100% {
|
|
27
|
+
transform: rotate(360deg);
|
|
28
|
+
}
|
|
29
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lowdefy/client",
|
|
3
|
+
"version": "4.0.0-alpha.9",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"description": "Lowdefy Client",
|
|
6
|
+
"homepage": "https://lowdefy.com",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"lowdefy"
|
|
9
|
+
],
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/lowdefy/lowdefy/issues"
|
|
12
|
+
},
|
|
13
|
+
"contributors": [
|
|
14
|
+
{
|
|
15
|
+
"name": "Sam Tolmay",
|
|
16
|
+
"url": "https://github.com/SamTolmay"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "Gerrie van Wyk",
|
|
20
|
+
"url": "https://github.com/Gervwyk"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "https://github.com/lowdefy/lowdefy.git"
|
|
26
|
+
},
|
|
27
|
+
"type": "module",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": "./dist/index.js",
|
|
30
|
+
"./*": "./dist/*"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist/*"
|
|
34
|
+
],
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "yarn swc",
|
|
37
|
+
"clean": "rm -rf dist",
|
|
38
|
+
"copyfiles": "copyfiles -u 1 \"./src/**/*\" dist -e \"./src/**/*.js\" -e \"./src/**/*.yaml\" -e \"./src/**/*.snap\"",
|
|
39
|
+
"prepare": "yarn build",
|
|
40
|
+
"swc": "swc src --out-dir dist --config-file ../../.swcrc --delete-dir-on-start && yarn copyfiles",
|
|
41
|
+
"test:watch": "jest --coverage --watch",
|
|
42
|
+
"test": "jest --coverage"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@ant-design/icons": "4.7.0",
|
|
46
|
+
"@lowdefy/block-utils": "4.0.0-alpha.9",
|
|
47
|
+
"@lowdefy/engine": "4.0.0-alpha.9",
|
|
48
|
+
"@lowdefy/helpers": "4.0.0-alpha.9",
|
|
49
|
+
"@lowdefy/layout": "4.0.0-alpha.9",
|
|
50
|
+
"classnames": "2.3.1",
|
|
51
|
+
"react": "17.0.2",
|
|
52
|
+
"react-dom": "17.0.2"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@emotion/jest": "11.7.1",
|
|
56
|
+
"@swc/cli": "0.1.55",
|
|
57
|
+
"@swc/core": "1.2.135",
|
|
58
|
+
"@swc/jest": "0.2.17",
|
|
59
|
+
"@testing-library/dom": "8.11.3",
|
|
60
|
+
"@testing-library/react": "13.0.0-alpha.4",
|
|
61
|
+
"@testing-library/user-event": "14.0.0-alpha.14",
|
|
62
|
+
"copyfiles": "2.4.1",
|
|
63
|
+
"jest": "27.5.1",
|
|
64
|
+
"jest-serializer-html": "7.1.0",
|
|
65
|
+
"jest-transform-yaml": "1.0.0"
|
|
66
|
+
},
|
|
67
|
+
"publishConfig": {
|
|
68
|
+
"access": "public"
|
|
69
|
+
},
|
|
70
|
+
"gitHead": "98b544eca231bdcfca6c3a8601a891835d5ce571"
|
|
71
|
+
}
|