@lowdefy/client 4.0.0-alpha.28 → 4.0.0-alpha.29
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/package.json +9 -10
- package/dist/Client.js +0 -68
- package/dist/Context.js +0 -45
- package/dist/DisplayMessage.js +0 -29
- package/dist/ErrorBoundary.js +0 -52
- package/dist/ErrorPage.js +0 -60
- package/dist/Head.js +0 -19
- package/dist/MountEvents.js +0 -37
- package/dist/ProgressBarController.js +0 -82
- package/dist/auth/createAuthMethods.js +0 -66
- package/dist/block/Block.js +0 -60
- package/dist/block/CategorySwitch.js +0 -116
- package/dist/block/Container.js +0 -74
- package/dist/block/List.js +0 -83
- package/dist/block/LoadingBlock.js +0 -83
- package/dist/block/LoadingContainer.js +0 -65
- package/dist/block/LoadingList.js +0 -69
- package/dist/callRequest.js +0 -25
- package/dist/createIcon.js +0 -100
- package/dist/createLinkComponent.js +0 -63
- package/dist/index.js +0 -16
- package/dist/initLowdefyContext.js +0 -71
- package/dist/request.js +0 -32
- package/dist/setupLink.js +0 -51
- package/dist/style.less +0 -29
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/client",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.29",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Lowdefy Client",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -33,27 +33,26 @@
|
|
|
33
33
|
"dist/*"
|
|
34
34
|
],
|
|
35
35
|
"scripts": {
|
|
36
|
-
"build": "
|
|
36
|
+
"build": "swc src --out-dir dist --config-file ../../.swcrc --delete-dir-on-start && pnpm copyfiles",
|
|
37
37
|
"clean": "rm -rf dist",
|
|
38
38
|
"copyfiles": "copyfiles -u 1 \"./src/**/*\" dist -e \"./src/**/*.js\" -e \"./src/**/*.yaml\" -e \"./src/**/*.snap\"",
|
|
39
|
-
"
|
|
40
|
-
"swc": "swc src --out-dir dist --config-file ../../.swcrc --delete-dir-on-start && yarn copyfiles",
|
|
39
|
+
"prepublishOnly": "pnpm build",
|
|
41
40
|
"test:watch": "jest --coverage --watch",
|
|
42
41
|
"test": "jest --coverage"
|
|
43
42
|
},
|
|
44
43
|
"dependencies": {
|
|
45
44
|
"@ant-design/icons": "4.7.0",
|
|
46
|
-
"@lowdefy/block-utils": "4.0.0-alpha.
|
|
47
|
-
"@lowdefy/engine": "4.0.0-alpha.
|
|
48
|
-
"@lowdefy/helpers": "4.0.0-alpha.
|
|
49
|
-
"@lowdefy/layout": "4.0.0-alpha.
|
|
45
|
+
"@lowdefy/block-utils": "4.0.0-alpha.29",
|
|
46
|
+
"@lowdefy/engine": "4.0.0-alpha.29",
|
|
47
|
+
"@lowdefy/helpers": "4.0.0-alpha.29",
|
|
48
|
+
"@lowdefy/layout": "4.0.0-alpha.29",
|
|
50
49
|
"classnames": "2.3.1",
|
|
51
50
|
"react": "18.1.0",
|
|
52
51
|
"react-dom": "18.1.0"
|
|
53
52
|
},
|
|
54
53
|
"devDependencies": {
|
|
55
54
|
"@emotion/jest": "11.9.1",
|
|
56
|
-
"@lowdefy/jest-yaml-transform": "4.0.0-alpha.
|
|
55
|
+
"@lowdefy/jest-yaml-transform": "4.0.0-alpha.29",
|
|
57
56
|
"@swc/cli": "0.1.57",
|
|
58
57
|
"@swc/core": "1.2.194",
|
|
59
58
|
"@swc/jest": "0.2.21",
|
|
@@ -68,5 +67,5 @@
|
|
|
68
67
|
"publishConfig": {
|
|
69
68
|
"access": "public"
|
|
70
69
|
},
|
|
71
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "621a191ebc0a1569ee6669dc74c12f8be5a8c7f3"
|
|
72
71
|
}
|
package/dist/Client.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
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 React from 'react';
|
|
16
|
-
import Block from './block/Block.js';
|
|
17
|
-
import Context from './Context.js';
|
|
18
|
-
import DisplayMessage from './DisplayMessage.js';
|
|
19
|
-
import Head from './Head.js';
|
|
20
|
-
import ProgressBarController from './ProgressBarController.js';
|
|
21
|
-
import initLowdefyContext from './initLowdefyContext.js';
|
|
22
|
-
const Client = ({ auth , Components , config , resetContext ={
|
|
23
|
-
reset: false,
|
|
24
|
-
setReset: ()=>undefined
|
|
25
|
-
} , router , stage , types , window , })=>{
|
|
26
|
-
const lowdefy = initLowdefyContext({
|
|
27
|
-
auth,
|
|
28
|
-
Components,
|
|
29
|
-
config,
|
|
30
|
-
router,
|
|
31
|
-
stage,
|
|
32
|
-
types,
|
|
33
|
-
window
|
|
34
|
-
});
|
|
35
|
-
return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(ProgressBarController, {
|
|
36
|
-
id: "lowdefy-progress-bar",
|
|
37
|
-
key: `${config.pageConfig.id}-progress-bar`,
|
|
38
|
-
lowdefy: lowdefy,
|
|
39
|
-
resetContext: resetContext
|
|
40
|
-
}), /*#__PURE__*/ React.createElement(DisplayMessage, {
|
|
41
|
-
id: "lowdefy-display-message",
|
|
42
|
-
key: `${config.pageConfig.id}-display-message`,
|
|
43
|
-
Component: lowdefy._internal.blockComponents.Message,
|
|
44
|
-
methods: {
|
|
45
|
-
registerMethod: (_, method)=>{
|
|
46
|
-
lowdefy._internal.displayMessage = method;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}), /*#__PURE__*/ React.createElement(Context, {
|
|
50
|
-
key: config.pageConfig.id,
|
|
51
|
-
config: config.pageConfig,
|
|
52
|
-
lowdefy: lowdefy,
|
|
53
|
-
resetContext: resetContext
|
|
54
|
-
}, (context)=>{
|
|
55
|
-
if (!context._internal.onInitDone) return '';
|
|
56
|
-
return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(Head, {
|
|
57
|
-
Component: Components.Head,
|
|
58
|
-
properties: context._internal.RootBlocks.map[config.pageConfig.blockId].eval.properties
|
|
59
|
-
}), /*#__PURE__*/ React.createElement(Block, {
|
|
60
|
-
block: context._internal.RootBlocks.map[config.pageConfig.blockId],
|
|
61
|
-
Blocks: context._internal.RootBlocks,
|
|
62
|
-
context: context,
|
|
63
|
-
lowdefy: lowdefy,
|
|
64
|
-
parentLoading: false
|
|
65
|
-
}));
|
|
66
|
-
}));
|
|
67
|
-
};
|
|
68
|
-
export default Client;
|
package/dist/Context.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
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 React from 'react';
|
|
16
|
-
import getContext from '@lowdefy/engine';
|
|
17
|
-
import MountEvents from './MountEvents.js';
|
|
18
|
-
const Context = ({ children , config , lowdefy , resetContext })=>{
|
|
19
|
-
const context = getContext({
|
|
20
|
-
config,
|
|
21
|
-
lowdefy,
|
|
22
|
-
resetContext
|
|
23
|
-
});
|
|
24
|
-
return /*#__PURE__*/ React.createElement(MountEvents, {
|
|
25
|
-
context: context,
|
|
26
|
-
triggerEvent: async ()=>{
|
|
27
|
-
await context._internal.runOnInit(()=>{
|
|
28
|
-
lowdefy._internal.progress.dispatch({
|
|
29
|
-
type: 'increment'
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
},
|
|
33
|
-
triggerEventAsync: ()=>{
|
|
34
|
-
context._internal.runOnInitAsync(()=>{
|
|
35
|
-
lowdefy._internal.progress.dispatch({
|
|
36
|
-
type: 'increment'
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}, (loadingOnInit)=>{
|
|
41
|
-
if (loadingOnInit) return '';
|
|
42
|
-
return children(context);
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
export default Context;
|
package/dist/DisplayMessage.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
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 React from 'react';
|
|
16
|
-
import { makeCssClass } from '@lowdefy/block-utils';
|
|
17
|
-
const DisplayMessage = ({ Component , id , methods })=>{
|
|
18
|
-
return /*#__PURE__*/ React.createElement(Component, {
|
|
19
|
-
blockId: id,
|
|
20
|
-
key: id,
|
|
21
|
-
methods: {
|
|
22
|
-
makeCssClass,
|
|
23
|
-
registerMethod: methods.registerMethod,
|
|
24
|
-
triggerEvent: ()=>undefined
|
|
25
|
-
},
|
|
26
|
-
properties: {}
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
export default DisplayMessage;
|
package/dist/ErrorBoundary.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
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 React, { Component } from 'react';
|
|
16
|
-
import ErrorPage from './ErrorPage.js';
|
|
17
|
-
let ErrorBoundary = class ErrorBoundary extends Component {
|
|
18
|
-
static getDerivedStateFromError(error) {
|
|
19
|
-
return {
|
|
20
|
-
hasError: true,
|
|
21
|
-
error
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
render() {
|
|
25
|
-
const { children , description , fallback , fullPage , message , name } = this.props;
|
|
26
|
-
const { hasError , error } = this.state;
|
|
27
|
-
if (hasError) {
|
|
28
|
-
if (fallback) {
|
|
29
|
-
return fallback(error);
|
|
30
|
-
}
|
|
31
|
-
if (fullPage) {
|
|
32
|
-
return /*#__PURE__*/ React.createElement(ErrorPage, {
|
|
33
|
-
code: error.number,
|
|
34
|
-
description: description || error.description,
|
|
35
|
-
message: message || error.message,
|
|
36
|
-
name: name || error.name
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
// Throw to console but fail silently to user?
|
|
40
|
-
return '';
|
|
41
|
-
}
|
|
42
|
-
return children;
|
|
43
|
-
}
|
|
44
|
-
constructor(props){
|
|
45
|
-
super(props);
|
|
46
|
-
this.state = {
|
|
47
|
-
hasError: false,
|
|
48
|
-
error: null
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
export default ErrorBoundary;
|
package/dist/ErrorPage.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
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 React from 'react';
|
|
16
|
-
const ErrorPage = ({ code , description , message , name })=>/*#__PURE__*/ React.createElement("div", {
|
|
17
|
-
style: {
|
|
18
|
-
height: '100%',
|
|
19
|
-
fontFamily: 'system-ui',
|
|
20
|
-
margin: 0,
|
|
21
|
-
display: 'flex',
|
|
22
|
-
justifyContent: 'center',
|
|
23
|
-
alignItems: 'center'
|
|
24
|
-
}
|
|
25
|
-
}, /*#__PURE__*/ React.createElement("div", {
|
|
26
|
-
style: {
|
|
27
|
-
flex: '0 1 auto',
|
|
28
|
-
fontSize: '4.3em',
|
|
29
|
-
fontWeight: '100',
|
|
30
|
-
paddingRight: 30
|
|
31
|
-
}
|
|
32
|
-
}, code || 500), /*#__PURE__*/ React.createElement("div", {
|
|
33
|
-
style: {
|
|
34
|
-
flex: '0 1 auto',
|
|
35
|
-
paddingLeft: 30,
|
|
36
|
-
maxWidth: 400,
|
|
37
|
-
borderLeft: '1px solid #aeaeae'
|
|
38
|
-
}
|
|
39
|
-
}, /*#__PURE__*/ React.createElement("div", {
|
|
40
|
-
style: {
|
|
41
|
-
fontSize: '1.3em',
|
|
42
|
-
fontWeight: '300',
|
|
43
|
-
paddingBottom: 10
|
|
44
|
-
}
|
|
45
|
-
}, name || 'Error'), /*#__PURE__*/ React.createElement("div", {
|
|
46
|
-
style: {
|
|
47
|
-
fontSize: '0.9em'
|
|
48
|
-
}
|
|
49
|
-
}, message || 'An error has occurred.'), /*#__PURE__*/ React.createElement("div", {
|
|
50
|
-
style: {
|
|
51
|
-
fontSize: '0.9em'
|
|
52
|
-
}
|
|
53
|
-
}, description), /*#__PURE__*/ React.createElement("div", {
|
|
54
|
-
style: {
|
|
55
|
-
paddingTop: 20
|
|
56
|
-
}
|
|
57
|
-
}, /*#__PURE__*/ React.createElement("a", {
|
|
58
|
-
href: "/"
|
|
59
|
-
}, "Return to home page"))));
|
|
60
|
-
export default ErrorPage;
|
package/dist/Head.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
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 React from 'react';
|
|
16
|
-
const BindHead = ({ Component , properties })=>{
|
|
17
|
-
return /*#__PURE__*/ React.createElement(Component, null, /*#__PURE__*/ React.createElement("title", null, properties.title));
|
|
18
|
-
};
|
|
19
|
-
export default BindHead;
|
package/dist/MountEvents.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
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 React, { useEffect, useState } from 'react';
|
|
16
|
-
const MountEvents = ({ children , context , triggerEvent , triggerEventAsync })=>{
|
|
17
|
-
const [loading, setLoading] = useState(true);
|
|
18
|
-
const [error, setError] = useState(null);
|
|
19
|
-
useEffect(()=>{
|
|
20
|
-
setLoading(true);
|
|
21
|
-
const mount = async ()=>{
|
|
22
|
-
try {
|
|
23
|
-
await triggerEvent();
|
|
24
|
-
triggerEventAsync();
|
|
25
|
-
setLoading(false);
|
|
26
|
-
} catch (err) {
|
|
27
|
-
setError(err);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
mount();
|
|
31
|
-
}, [
|
|
32
|
-
context
|
|
33
|
-
]);
|
|
34
|
-
if (error) throw error;
|
|
35
|
-
return /*#__PURE__*/ React.createElement(React.Fragment, null, children(loading));
|
|
36
|
-
};
|
|
37
|
-
export default MountEvents;
|
|
@@ -1,82 +0,0 @@
|
|
|
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
|
-
*/ import React, { useReducer, useEffect } from 'react';
|
|
16
|
-
import { makeCssClass } from '@lowdefy/block-utils';
|
|
17
|
-
const initialState = {
|
|
18
|
-
progress: 0,
|
|
19
|
-
onMounts: 0
|
|
20
|
-
};
|
|
21
|
-
function reducer(state, action) {
|
|
22
|
-
switch(action.type){
|
|
23
|
-
case 'increment':
|
|
24
|
-
return {
|
|
25
|
-
...state,
|
|
26
|
-
progress: state.progress + (100 - state.progress) / 3
|
|
27
|
-
};
|
|
28
|
-
case 'increment-on-mount':
|
|
29
|
-
return {
|
|
30
|
-
...state,
|
|
31
|
-
onMounts: state.onMounts + 1
|
|
32
|
-
};
|
|
33
|
-
case 'auto-increment':
|
|
34
|
-
return {
|
|
35
|
-
...state,
|
|
36
|
-
progress: state.progress + (100 - state.progress) / 200
|
|
37
|
-
};
|
|
38
|
-
case 'done':
|
|
39
|
-
return {
|
|
40
|
-
progress: state.onMounts - 1 === 0 ? 100 : state.progress,
|
|
41
|
-
onMounts: state.onMounts - 1
|
|
42
|
-
};
|
|
43
|
-
case 'reset':
|
|
44
|
-
return {
|
|
45
|
-
progress: 0,
|
|
46
|
-
onMounts: 0
|
|
47
|
-
};
|
|
48
|
-
default:
|
|
49
|
-
throw new Error('Invalid action type for ProgressBarController reducer.');
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
const ProgressBarController = ({ id , lowdefy , resetContext })=>{
|
|
53
|
-
const [state, dispatch] = useReducer(reducer, initialState);
|
|
54
|
-
const ProgressBar = lowdefy._internal.blockComponents.ProgressBar;
|
|
55
|
-
lowdefy._internal.progress.state = state;
|
|
56
|
-
lowdefy._internal.progress.dispatch = dispatch;
|
|
57
|
-
useEffect(()=>{
|
|
58
|
-
const timer = state.progress < 95 && setInterval(()=>dispatch({
|
|
59
|
-
type: 'auto-increment'
|
|
60
|
-
}), 500);
|
|
61
|
-
return ()=>clearInterval(timer);
|
|
62
|
-
}, [
|
|
63
|
-
state
|
|
64
|
-
]);
|
|
65
|
-
if (resetContext.reset && state.progress === 100) {
|
|
66
|
-
dispatch({
|
|
67
|
-
type: 'reset'
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
return /*#__PURE__*/ React.createElement(ProgressBar, {
|
|
71
|
-
basePath: lowdefy.basePath,
|
|
72
|
-
blockId: id,
|
|
73
|
-
components: lowdefy._internal.components,
|
|
74
|
-
menus: lowdefy.menus,
|
|
75
|
-
methods: {
|
|
76
|
-
makeCssClass
|
|
77
|
-
},
|
|
78
|
-
pageId: lowdefy.pageId,
|
|
79
|
-
properties: state
|
|
80
|
-
});
|
|
81
|
-
};
|
|
82
|
-
export default ProgressBarController;
|
|
@@ -1,66 +0,0 @@
|
|
|
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 { type, urlQuery as urlQueryFn } from '@lowdefy/helpers';
|
|
16
|
-
function getCallbackUrl({ lowdefy , callbackUrl ={} }) {
|
|
17
|
-
const { home , pageId , urlQuery , url } = callbackUrl;
|
|
18
|
-
if ([
|
|
19
|
-
!home,
|
|
20
|
-
!pageId,
|
|
21
|
-
!url
|
|
22
|
-
].filter((v)=>!v).length > 1) {
|
|
23
|
-
throw Error(`Invalid Link: To avoid ambiguity, only one of 'home', 'pageId' or 'url' can be defined.`);
|
|
24
|
-
}
|
|
25
|
-
const query = type.isNone(urlQuery) ? '' : `${urlQueryFn.stringify(urlQuery)}`;
|
|
26
|
-
if (home === true) {
|
|
27
|
-
return `/${lowdefy.home.configured ? '' : lowdefy.home.pageId}${query ? `?${query}` : ''}`;
|
|
28
|
-
}
|
|
29
|
-
if (type.isString(pageId)) {
|
|
30
|
-
return `/${pageId}${query ? `?${query}` : ''}`;
|
|
31
|
-
}
|
|
32
|
-
if (type.isString(url)) {
|
|
33
|
-
return `${url}${query ? `?${query}` : ''}`;
|
|
34
|
-
}
|
|
35
|
-
return undefined;
|
|
36
|
-
}
|
|
37
|
-
function createAuthMethods({ lowdefy , auth }) {
|
|
38
|
-
// login and logout are Lowdefy function that handle action params
|
|
39
|
-
// signIn and signOut are the next-auth methods
|
|
40
|
-
function login({ authUrl , callbackUrl , providerId , ...rest } = {}) {
|
|
41
|
-
if (type.isNone(providerId) && auth.authConfig.providers.length === 1) {
|
|
42
|
-
providerId = auth.authConfig.providers[0].id;
|
|
43
|
-
}
|
|
44
|
-
auth.signIn(providerId, {
|
|
45
|
-
...rest,
|
|
46
|
-
callbackUrl: getCallbackUrl({
|
|
47
|
-
lowdefy,
|
|
48
|
-
callbackUrl
|
|
49
|
-
})
|
|
50
|
-
}, authUrl?.urlQuery);
|
|
51
|
-
}
|
|
52
|
-
function logout({ callbackUrl , redirect } = {}) {
|
|
53
|
-
auth.signOut({
|
|
54
|
-
callbackUrl: getCallbackUrl({
|
|
55
|
-
lowdefy,
|
|
56
|
-
callbackUrl
|
|
57
|
-
}),
|
|
58
|
-
redirect
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
return {
|
|
62
|
-
login,
|
|
63
|
-
logout
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
export default createAuthMethods;
|
package/dist/block/Block.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
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 React, { useState } from 'react';
|
|
16
|
-
import CategorySwitch from './CategorySwitch.js';
|
|
17
|
-
import ErrorBoundary from '../ErrorBoundary.js';
|
|
18
|
-
import MountEvents from '../MountEvents.js';
|
|
19
|
-
const Block = ({ block , Blocks , context , lowdefy , parentLoading })=>{
|
|
20
|
-
const [updates, setUpdate] = useState(0);
|
|
21
|
-
lowdefy._internal.updaters[block.id] = ()=>setUpdate(updates + 1);
|
|
22
|
-
return /*#__PURE__*/ React.createElement(ErrorBoundary, null, /*#__PURE__*/ React.createElement(MountEvents, {
|
|
23
|
-
context: context,
|
|
24
|
-
triggerEvent: async ()=>{
|
|
25
|
-
context._internal.lowdefy._internal.progress.dispatch({
|
|
26
|
-
type: 'increment-on-mount',
|
|
27
|
-
id: block.id
|
|
28
|
-
});
|
|
29
|
-
await block.triggerEvent({
|
|
30
|
-
name: 'onMount',
|
|
31
|
-
progress: ()=>{
|
|
32
|
-
lowdefy._internal.progress.dispatch({
|
|
33
|
-
type: 'increment'
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
},
|
|
38
|
-
triggerEventAsync: ()=>{
|
|
39
|
-
block.triggerEvent({
|
|
40
|
-
name: 'onMountAsync',
|
|
41
|
-
progress: ()=>{
|
|
42
|
-
lowdefy._internal.progress.dispatch({
|
|
43
|
-
type: 'increment'
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
lowdefy._internal.progress.dispatch({
|
|
48
|
-
type: 'done'
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
}, (eventLoading)=>/*#__PURE__*/ React.createElement(CategorySwitch, {
|
|
52
|
-
block: block,
|
|
53
|
-
Blocks: Blocks,
|
|
54
|
-
context: context,
|
|
55
|
-
loading: eventLoading || parentLoading || block.eval.loading,
|
|
56
|
-
lowdefy: lowdefy,
|
|
57
|
-
updates: updates
|
|
58
|
-
})));
|
|
59
|
-
};
|
|
60
|
-
export default Block;
|