@lowdefy/client 4.0.0-rc.0 → 4.0.0-rc.10
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/dist/Client.js +7 -4
- package/dist/Context.js +2 -2
- package/dist/DisplayMessage.js +2 -2
- package/dist/ErrorBoundary.js +3 -3
- package/dist/ErrorPage.js +2 -2
- package/dist/Head.js +2 -2
- package/dist/MountEvents.js +2 -2
- package/dist/ProgressBarController.js +1 -1
- package/dist/auth/createAuthMethods.js +14 -9
- package/dist/block/Block.js +2 -2
- package/dist/block/CategorySwitch.js +2 -2
- package/dist/block/Container.js +2 -2
- package/dist/block/List.js +2 -2
- package/dist/block/LoadingBlock.js +2 -2
- package/dist/block/LoadingContainer.js +2 -2
- package/dist/block/LoadingList.js +2 -2
- package/dist/{callRequest.js → createCallRequest.js} +13 -10
- package/dist/createIcon.js +12 -25
- package/dist/createLinkComponent.js +28 -13
- package/dist/index.js +1 -1
- package/dist/initLowdefyContext.js +42 -45
- package/dist/request.js +2 -2
- package/dist/setupLink.js +5 -5
- package/dist/style.less +3 -3
- package/package.json +20 -20
package/dist/Client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -13,20 +13,23 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import React from 'react';
|
|
16
|
+
import { serializer } from '@lowdefy/helpers';
|
|
16
17
|
import Block from './block/Block.js';
|
|
17
18
|
import Context from './Context.js';
|
|
18
19
|
import DisplayMessage from './DisplayMessage.js';
|
|
19
20
|
import Head from './Head.js';
|
|
20
21
|
import ProgressBarController from './ProgressBarController.js';
|
|
21
22
|
import initLowdefyContext from './initLowdefyContext.js';
|
|
22
|
-
const Client = ({ auth
|
|
23
|
+
const Client = ({ auth, Components, config: rawConfig, lowdefy, resetContext = {
|
|
23
24
|
reset: false,
|
|
24
25
|
setReset: ()=>undefined
|
|
25
|
-
}
|
|
26
|
-
const
|
|
26
|
+
}, router, stage, types, window })=>{
|
|
27
|
+
const config = serializer.deserialize(rawConfig);
|
|
28
|
+
initLowdefyContext({
|
|
27
29
|
auth,
|
|
28
30
|
Components,
|
|
29
31
|
config,
|
|
32
|
+
lowdefy,
|
|
30
33
|
router,
|
|
31
34
|
stage,
|
|
32
35
|
types,
|
package/dist/Context.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/ import React from 'react';
|
|
16
16
|
import getContext from '@lowdefy/engine';
|
|
17
17
|
import MountEvents from './MountEvents.js';
|
|
18
|
-
const Context = ({ children
|
|
18
|
+
const Context = ({ children, config, lowdefy, resetContext })=>{
|
|
19
19
|
const context = getContext({
|
|
20
20
|
config,
|
|
21
21
|
lowdefy,
|
package/dist/DisplayMessage.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import React from 'react';
|
|
16
16
|
import { makeCssClass } from '@lowdefy/block-utils';
|
|
17
|
-
const DisplayMessage = ({ Component
|
|
17
|
+
const DisplayMessage = ({ Component, id, methods })=>{
|
|
18
18
|
return /*#__PURE__*/ React.createElement(Component, {
|
|
19
19
|
blockId: id,
|
|
20
20
|
key: id,
|
package/dist/ErrorBoundary.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -22,8 +22,8 @@ let ErrorBoundary = class ErrorBoundary extends Component {
|
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
render() {
|
|
25
|
-
const { children
|
|
26
|
-
const { hasError
|
|
25
|
+
const { children, description, fallback, fullPage, message, name } = this.props;
|
|
26
|
+
const { hasError, error } = this.state;
|
|
27
27
|
if (hasError) {
|
|
28
28
|
if (fallback) {
|
|
29
29
|
return fallback(error);
|
package/dist/ErrorPage.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import React from 'react';
|
|
16
|
-
const ErrorPage = ({ code
|
|
16
|
+
const ErrorPage = ({ code, description, message, name })=>/*#__PURE__*/ React.createElement("div", {
|
|
17
17
|
style: {
|
|
18
18
|
height: '100%',
|
|
19
19
|
fontFamily: 'system-ui',
|
package/dist/Head.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import React from 'react';
|
|
16
|
-
const BindHead = ({ Component
|
|
16
|
+
const BindHead = ({ Component, properties })=>{
|
|
17
17
|
return /*#__PURE__*/ React.createElement(Component, null, /*#__PURE__*/ React.createElement("title", null, properties.title));
|
|
18
18
|
};
|
|
19
19
|
export default BindHead;
|
package/dist/MountEvents.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import React, { useEffect, useState } from 'react';
|
|
16
|
-
const MountEvents = ({ children
|
|
16
|
+
const MountEvents = ({ children, context, triggerEvent, triggerEventAsync })=>{
|
|
17
17
|
const [loading, setLoading] = useState(true);
|
|
18
18
|
const [error, setError] = useState(null);
|
|
19
19
|
useEffect(()=>{
|
|
@@ -49,7 +49,7 @@ function reducer(state, action) {
|
|
|
49
49
|
throw new Error('Invalid action type for ProgressBarController reducer.');
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
const ProgressBarController = ({ id
|
|
52
|
+
const ProgressBarController = ({ id, lowdefy, resetContext })=>{
|
|
53
53
|
const [state, dispatch] = useReducer(reducer, initialState);
|
|
54
54
|
const ProgressBar = lowdefy._internal.blockComponents.ProgressBar;
|
|
55
55
|
lowdefy._internal.progress.state = state;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import { type, urlQuery as urlQueryFn } from '@lowdefy/helpers';
|
|
16
|
-
function getCallbackUrl({ lowdefy
|
|
17
|
-
const { home
|
|
16
|
+
function getCallbackUrl({ lowdefy, callbackUrl = {} }) {
|
|
17
|
+
const { home, pageId, urlQuery, url } = callbackUrl;
|
|
18
18
|
if ([
|
|
19
19
|
!home,
|
|
20
20
|
!pageId,
|
|
@@ -34,14 +34,14 @@ function getCallbackUrl({ lowdefy , callbackUrl ={} }) {
|
|
|
34
34
|
}
|
|
35
35
|
return undefined;
|
|
36
36
|
}
|
|
37
|
-
function createAuthMethods(
|
|
37
|
+
function createAuthMethods(lowdefy, auth) {
|
|
38
38
|
// login and logout are Lowdefy function that handle action params
|
|
39
39
|
// signIn and signOut are the next-auth methods
|
|
40
|
-
function login({ authUrl
|
|
40
|
+
function login({ authUrl, callbackUrl, providerId, ...rest } = {}) {
|
|
41
41
|
if (type.isNone(providerId) && auth.authConfig.providers.length === 1) {
|
|
42
42
|
providerId = auth.authConfig.providers[0].id;
|
|
43
43
|
}
|
|
44
|
-
auth.signIn(providerId, {
|
|
44
|
+
return auth.signIn(providerId, {
|
|
45
45
|
...rest,
|
|
46
46
|
callbackUrl: getCallbackUrl({
|
|
47
47
|
lowdefy,
|
|
@@ -49,8 +49,8 @@ function createAuthMethods({ lowdefy , auth }) {
|
|
|
49
49
|
})
|
|
50
50
|
}, authUrl?.urlQuery);
|
|
51
51
|
}
|
|
52
|
-
function logout({ callbackUrl
|
|
53
|
-
auth.signOut({
|
|
52
|
+
function logout({ callbackUrl, redirect } = {}) {
|
|
53
|
+
return auth.signOut({
|
|
54
54
|
callbackUrl: getCallbackUrl({
|
|
55
55
|
lowdefy,
|
|
56
56
|
callbackUrl
|
|
@@ -58,9 +58,14 @@ function createAuthMethods({ lowdefy , auth }) {
|
|
|
58
58
|
redirect
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
|
+
async function updateSession() {
|
|
62
|
+
const session = await auth.getSession();
|
|
63
|
+
lowdefy.user = session?.user ?? null;
|
|
64
|
+
}
|
|
61
65
|
return {
|
|
62
66
|
login,
|
|
63
|
-
logout
|
|
67
|
+
logout,
|
|
68
|
+
updateSession
|
|
64
69
|
};
|
|
65
70
|
}
|
|
66
71
|
export default createAuthMethods;
|
package/dist/block/Block.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import CategorySwitch from './CategorySwitch.js';
|
|
17
17
|
import ErrorBoundary from '../ErrorBoundary.js';
|
|
18
18
|
import MountEvents from '../MountEvents.js';
|
|
19
|
-
const Block = ({ block
|
|
19
|
+
const Block = ({ block, Blocks, context, lowdefy, parentLoading })=>{
|
|
20
20
|
const [updates, setUpdate] = useState(0);
|
|
21
21
|
lowdefy._internal.updaters[block.id] = ()=>setUpdate(updates + 1);
|
|
22
22
|
return /*#__PURE__*/ React.createElement(ErrorBoundary, null, /*#__PURE__*/ React.createElement(MountEvents, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -19,7 +19,7 @@ import { type } from '@lowdefy/helpers';
|
|
|
19
19
|
import Container from './Container.js';
|
|
20
20
|
import List from './List.js';
|
|
21
21
|
import LoadingBlock from './LoadingBlock.js';
|
|
22
|
-
const CategorySwitch = ({ block
|
|
22
|
+
const CategorySwitch = ({ block, Blocks, context, loading, lowdefy })=>{
|
|
23
23
|
if (!block.eval) return null; // TODO: check Renderer updates before eval is executed for the first time on lists. See #520
|
|
24
24
|
if (block.eval.visible === false) return /*#__PURE__*/ React.createElement("div", {
|
|
25
25
|
id: `vs-${block.blockId}`,
|
package/dist/block/Container.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import { Area, BlockLayout, layoutParamsToArea } from '@lowdefy/layout';
|
|
17
17
|
import { makeCssClass } from '@lowdefy/block-utils';
|
|
18
18
|
import Block from './Block.js';
|
|
19
|
-
const Container = ({ block
|
|
19
|
+
const Container = ({ block, Blocks, Component, context, loading, lowdefy })=>{
|
|
20
20
|
const content = {};
|
|
21
21
|
// eslint-disable-next-line prefer-destructuring
|
|
22
22
|
const areas = Blocks.subBlocks[block.id][0].areas;
|
package/dist/block/List.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import { Area, BlockLayout, layoutParamsToArea } from '@lowdefy/layout';
|
|
17
17
|
import { makeCssClass } from '@lowdefy/block-utils';
|
|
18
18
|
import Block from './Block.js';
|
|
19
|
-
const List = ({ block
|
|
19
|
+
const List = ({ block, Blocks, Component, context, loading, lowdefy })=>{
|
|
20
20
|
const content = {};
|
|
21
21
|
const contentList = [];
|
|
22
22
|
Blocks.subBlocks[block.id].forEach((SBlock)=>{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -29,7 +29,7 @@ const blockMethods = {
|
|
|
29
29
|
triggerEvent: ()=>{},
|
|
30
30
|
unshiftItem: ()=>{}
|
|
31
31
|
};
|
|
32
|
-
const LoadingBlock = ({ blockId
|
|
32
|
+
const LoadingBlock = ({ blockId, blockLayout, blockProperties, blockStyle, context, lowdefy, skeleton })=>{
|
|
33
33
|
let Component = lowdefy._internal.blockComponents[skeleton.type];
|
|
34
34
|
useEffect(()=>{
|
|
35
35
|
if (!lowdefy._internal.blockComponents[skeleton.type]) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import { Area, BlockLayout, layoutParamsToArea } from '@lowdefy/layout';
|
|
17
17
|
import { makeCssClass } from '@lowdefy/block-utils';
|
|
18
18
|
import LoadingBlock from './LoadingBlock.js';
|
|
19
|
-
const LoadingContainer = ({ blockId
|
|
19
|
+
const LoadingContainer = ({ blockId, blockLayout, blockProperties, blockStyle, Component, context, lowdefy, skeleton })=>{
|
|
20
20
|
const content = {};
|
|
21
21
|
// eslint-disable-next-line prefer-destructuring
|
|
22
22
|
Object.keys(skeleton.areas).forEach((areaKey, i)=>{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import { Area, BlockLayout, layoutParamsToArea } from '@lowdefy/layout';
|
|
17
17
|
import { makeCssClass } from '@lowdefy/block-utils';
|
|
18
18
|
import LoadingBlock from './LoadingBlock.js';
|
|
19
|
-
const LoadingList = ({ blockId
|
|
19
|
+
const LoadingList = ({ blockId, blockLayout, blockProperties, blockStyle, Component, context, lowdefy, skeleton })=>{
|
|
20
20
|
const content = {};
|
|
21
21
|
const contentList = [];
|
|
22
22
|
new Array(3).forEach(()=>{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -13,13 +13,16 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import request from './request.js';
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
function createCallRequest({ basePath }) {
|
|
17
|
+
function callRequest({ pageId, payload, requestId }) {
|
|
18
|
+
return request({
|
|
19
|
+
url: `${basePath}/api/request/${pageId}/${requestId}`,
|
|
20
|
+
method: 'POST',
|
|
21
|
+
body: {
|
|
22
|
+
payload
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return callRequest;
|
|
24
27
|
}
|
|
25
|
-
export default
|
|
28
|
+
export default createCallRequest;
|
package/dist/createIcon.js
CHANGED
|
@@ -1,19 +1,5 @@
|
|
|
1
|
-
function _extends() {
|
|
2
|
-
_extends = Object.assign || function(target) {
|
|
3
|
-
for(var i = 1; i < arguments.length; i++){
|
|
4
|
-
var source = arguments[i];
|
|
5
|
-
for(var key in source){
|
|
6
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
7
|
-
target[key] = source[key];
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
return target;
|
|
12
|
-
};
|
|
13
|
-
return _extends.apply(this, arguments);
|
|
14
|
-
}
|
|
15
1
|
/*
|
|
16
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 Lowdefy, Inc
|
|
17
3
|
|
|
18
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
19
5
|
you may not use this file except in compliance with the License.
|
|
@@ -45,12 +31,12 @@ const lowdefyProps = [
|
|
|
45
31
|
'registerEvent',
|
|
46
32
|
'registerMethod',
|
|
47
33
|
'schemaErrors',
|
|
48
|
-
'validation'
|
|
34
|
+
'validation'
|
|
49
35
|
];
|
|
50
36
|
const createIcon = (Icons)=>{
|
|
51
37
|
const AiOutlineLoading3Quarters = Icons['AiOutlineLoading3Quarters'];
|
|
52
38
|
const AiOutlineExclamationCircle = Icons['AiOutlineExclamationCircle'];
|
|
53
|
-
const IconBlock = ({ blockId
|
|
39
|
+
const IconBlock = ({ blockId, events, methods, onClick, properties, ...props })=>{
|
|
54
40
|
const propertiesObj = type.isString(properties) ? {
|
|
55
41
|
name: properties
|
|
56
42
|
} : properties;
|
|
@@ -62,7 +48,7 @@ const createIcon = (Icons)=>{
|
|
|
62
48
|
{
|
|
63
49
|
cursor: (onClick || events.onClick) && 'pointer'
|
|
64
50
|
},
|
|
65
|
-
propertiesObj.style
|
|
51
|
+
propertiesObj.style
|
|
66
52
|
])]: true,
|
|
67
53
|
'icon-spin': spin
|
|
68
54
|
}),
|
|
@@ -77,22 +63,23 @@ const createIcon = (Icons)=>{
|
|
|
77
63
|
if (!IconComp) {
|
|
78
64
|
IconComp = AiOutlineExclamationCircle;
|
|
79
65
|
}
|
|
80
|
-
return /*#__PURE__*/ React.createElement(React.Fragment, null, spin ? /*#__PURE__*/ React.createElement(AiOutlineLoading3Quarters,
|
|
81
|
-
fallback: ()=>/*#__PURE__*/ React.createElement(AiOutlineExclamationCircle,
|
|
66
|
+
return /*#__PURE__*/ React.createElement(React.Fragment, null, spin ? /*#__PURE__*/ React.createElement(AiOutlineLoading3Quarters, iconProps) : /*#__PURE__*/ React.createElement(ErrorBoundary, {
|
|
67
|
+
fallback: ()=>/*#__PURE__*/ React.createElement(AiOutlineExclamationCircle, {
|
|
82
68
|
...iconProps,
|
|
83
69
|
color: '#F00'
|
|
84
|
-
})
|
|
85
|
-
}, /*#__PURE__*/ React.createElement(IconComp,
|
|
70
|
+
})
|
|
71
|
+
}, /*#__PURE__*/ React.createElement(IconComp, {
|
|
86
72
|
id: blockId,
|
|
87
73
|
onClick: onClick || events.onClick && (()=>methods.triggerEvent({
|
|
88
74
|
name: 'onClick'
|
|
89
75
|
})),
|
|
90
76
|
size: propertiesObj.size,
|
|
91
|
-
title: propertiesObj.title
|
|
92
|
-
|
|
77
|
+
title: propertiesObj.title,
|
|
78
|
+
...iconProps
|
|
79
|
+
})));
|
|
93
80
|
};
|
|
94
81
|
const AntIcon = (all)=>/*#__PURE__*/ React.createElement(Icon, {
|
|
95
|
-
component: ()=>/*#__PURE__*/ React.createElement(IconBlock,
|
|
82
|
+
component: ()=>/*#__PURE__*/ React.createElement(IconBlock, all)
|
|
96
83
|
});
|
|
97
84
|
AntIcon.defaultProps = blockDefaultProps;
|
|
98
85
|
return AntIcon;
|
|
@@ -2,34 +2,45 @@ import React from 'react';
|
|
|
2
2
|
import { createLink } from '@lowdefy/engine';
|
|
3
3
|
import { type } from '@lowdefy/helpers';
|
|
4
4
|
const createLinkComponent = (lowdefy, Link)=>{
|
|
5
|
-
const { window
|
|
6
|
-
const backLink = ({ ariaLabel
|
|
5
|
+
const { window } = lowdefy._internal.globals;
|
|
6
|
+
const backLink = ({ ariaLabel, children, className, id, onClick = ()=>{}, rel })=>/*#__PURE__*/ React.createElement("a", {
|
|
7
7
|
id: id,
|
|
8
|
-
onClick: ()=>lowdefy._internal.router.back(),
|
|
9
8
|
className: className,
|
|
10
9
|
rel: rel,
|
|
11
|
-
"aria-label": ariaLabel || 'back'
|
|
10
|
+
"aria-label": ariaLabel || 'back',
|
|
11
|
+
onClick: (...params)=>{
|
|
12
|
+
lowdefy._internal.router.back();
|
|
13
|
+
onClick(...params);
|
|
14
|
+
}
|
|
12
15
|
}, type.isFunction(children) ? children(id) : children);
|
|
13
|
-
const newOriginLink = ({ ariaLabel
|
|
16
|
+
const newOriginLink = ({ ariaLabel, children, className, href, id, onClick = ()=>{}, newTab, pageId, query, rel, url })=>{
|
|
14
17
|
return /*#__PURE__*/ React.createElement("a", {
|
|
15
18
|
id: id,
|
|
16
19
|
"aria-label": ariaLabel,
|
|
17
20
|
className: className,
|
|
18
|
-
href: `${url}${query ? `?${query}` : ''}`,
|
|
21
|
+
href: href || `${url}${query ? `?${query}` : ''}`,
|
|
19
22
|
rel: rel || newTab && 'noopener noreferrer',
|
|
20
|
-
target: newTab && '_blank'
|
|
23
|
+
target: newTab && '_blank',
|
|
24
|
+
onClick: async (...params)=>{
|
|
25
|
+
await onClick(...params);
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
21
28
|
}, type.isFunction(children) ? children(pageId || url || id) : children);
|
|
22
29
|
};
|
|
23
|
-
const sameOriginLink = ({ ariaLabel
|
|
30
|
+
const sameOriginLink = ({ ariaLabel, children, className, id, newTab, onClick = ()=>{}, pageId, pathname, query, rel, replace, scroll, setInput, url })=>{
|
|
24
31
|
if (newTab) {
|
|
25
32
|
return(// eslint-disable-next-line react/jsx-no-target-blank
|
|
26
33
|
/*#__PURE__*/ React.createElement("a", {
|
|
27
34
|
id: id,
|
|
28
35
|
"aria-label": ariaLabel,
|
|
29
36
|
className: className,
|
|
30
|
-
href: `${window.location.origin}${lowdefy.
|
|
37
|
+
href: `${window.location.origin}${lowdefy.basePath}${pathname}${query ? `?${query}` : ''}`,
|
|
31
38
|
rel: rel || 'noopener noreferrer',
|
|
32
|
-
target: "_blank"
|
|
39
|
+
target: "_blank",
|
|
40
|
+
onClick: async (...params)=>{
|
|
41
|
+
await onClick(...params);
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
33
44
|
}, type.isFunction(children) ? children(pageId || url || id) : children));
|
|
34
45
|
}
|
|
35
46
|
return /*#__PURE__*/ React.createElement(Link, {
|
|
@@ -44,12 +55,16 @@ const createLinkComponent = (lowdefy, Link)=>{
|
|
|
44
55
|
"aria-label": ariaLabel,
|
|
45
56
|
className: className,
|
|
46
57
|
rel: rel,
|
|
47
|
-
onClick:
|
|
58
|
+
onClick: (...params)=>{
|
|
59
|
+
setInput();
|
|
60
|
+
onClick(...params);
|
|
61
|
+
}
|
|
48
62
|
}, type.isFunction(children) ? children(pageId || url || id) : children));
|
|
49
63
|
};
|
|
50
|
-
const noLink = ({ className
|
|
64
|
+
const noLink = ({ className, children, id, onClick = ()=>{} })=>/*#__PURE__*/ React.createElement("span", {
|
|
51
65
|
id: id,
|
|
52
|
-
className: className
|
|
66
|
+
className: className,
|
|
67
|
+
onClick: onClick
|
|
53
68
|
}, type.isFunction(children) ? children(id) : children);
|
|
54
69
|
return createLink({
|
|
55
70
|
backLink,
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -12,60 +12,57 @@
|
|
|
12
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
|
-
*/ import
|
|
15
|
+
*/ import createAuthMethods from './auth/createAuthMethods.js';
|
|
16
|
+
import createCallRequest from './createCallRequest.js';
|
|
16
17
|
import createIcon from './createIcon.js';
|
|
17
|
-
import createAuthMethods from './auth/createAuthMethods.js';
|
|
18
18
|
import createLinkComponent from './createLinkComponent.js';
|
|
19
19
|
import setupLink from './setupLink.js';
|
|
20
|
-
|
|
21
|
-
_internal
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return ()=>undefined;
|
|
28
|
-
},
|
|
29
|
-
link: ()=>undefined,
|
|
30
|
-
progress: {
|
|
31
|
-
state: {
|
|
32
|
-
progress: 0
|
|
20
|
+
function initLowdefyContext({ auth, Components, config, lowdefy, router, stage, types, window }) {
|
|
21
|
+
if (!lowdefy._internal?.initialised) {
|
|
22
|
+
lowdefy._internal = {
|
|
23
|
+
actions: types.actions,
|
|
24
|
+
blockComponents: types.blocks,
|
|
25
|
+
components: {
|
|
26
|
+
Icon: createIcon(types.icons)
|
|
33
27
|
},
|
|
34
|
-
|
|
28
|
+
displayMessage: ({ content })=>{
|
|
29
|
+
console.log(content);
|
|
30
|
+
return ()=>undefined;
|
|
31
|
+
},
|
|
32
|
+
globals: {
|
|
33
|
+
document: window.document,
|
|
34
|
+
fetch: window.fetch,
|
|
35
|
+
window
|
|
36
|
+
},
|
|
37
|
+
initialised: true,
|
|
38
|
+
link: ()=>undefined,
|
|
39
|
+
operators: types.operators,
|
|
40
|
+
progress: {
|
|
41
|
+
state: {
|
|
42
|
+
progress: 0
|
|
43
|
+
},
|
|
44
|
+
dispatch: ()=>undefined
|
|
45
|
+
},
|
|
46
|
+
router,
|
|
47
|
+
updaters: {}
|
|
48
|
+
};
|
|
49
|
+
lowdefy.basePath = router.basePath;
|
|
50
|
+
lowdefy.contexts = {};
|
|
51
|
+
lowdefy.inputs = {};
|
|
52
|
+
lowdefy.lowdefyGlobal = config.rootConfig.lowdefyGlobal;
|
|
53
|
+
lowdefy._internal.auth = createAuthMethods(lowdefy, auth);
|
|
54
|
+
lowdefy._internal.callRequest = createCallRequest(lowdefy);
|
|
55
|
+
lowdefy._internal.components.Link = createLinkComponent(lowdefy, Components.Link);
|
|
56
|
+
lowdefy._internal.link = setupLink(lowdefy);
|
|
57
|
+
lowdefy._internal.updateBlock = (blockId)=>lowdefy._internal.updaters[blockId] && lowdefy._internal.updaters[blockId]();
|
|
58
|
+
if (stage === 'dev') {
|
|
59
|
+
window.lowdefy = lowdefy;
|
|
35
60
|
}
|
|
36
|
-
},
|
|
37
|
-
contexts: {},
|
|
38
|
-
inputs: {},
|
|
39
|
-
lowdefyGlobal: {}
|
|
40
|
-
};
|
|
41
|
-
function initLowdefyContext({ auth , Components , config , router , stage , types , window }) {
|
|
42
|
-
if (stage === 'dev') {
|
|
43
|
-
window.lowdefy = lowdefy;
|
|
44
61
|
}
|
|
45
|
-
lowdefy.basePath = router.basePath;
|
|
46
62
|
lowdefy.home = config.rootConfig.home || {};
|
|
47
|
-
lowdefy.lowdefyGlobal = config.rootConfig.lowdefyGlobal;
|
|
48
63
|
lowdefy.menus = config.rootConfig.menus;
|
|
49
64
|
lowdefy.pageId = config.pageConfig.pageId;
|
|
50
65
|
lowdefy.user = auth?.session?.user ?? null;
|
|
51
|
-
lowdefy._internal.globals = {
|
|
52
|
-
document: window.document,
|
|
53
|
-
fetch: window.fetch,
|
|
54
|
-
window
|
|
55
|
-
};
|
|
56
|
-
lowdefy._internal.router = router;
|
|
57
|
-
lowdefy._internal.link = setupLink(lowdefy);
|
|
58
|
-
lowdefy._internal.updateBlock = (blockId)=>lowdefy._internal.updaters[blockId] && lowdefy._internal.updaters[blockId]();
|
|
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
|
-
// TODO: discuss not using object arguments
|
|
65
|
-
lowdefy._internal.auth = createAuthMethods({
|
|
66
|
-
lowdefy,
|
|
67
|
-
auth
|
|
68
|
-
});
|
|
69
66
|
return lowdefy;
|
|
70
67
|
}
|
|
71
68
|
export default initLowdefyContext;
|
package/dist/request.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
|
-
*/ async function request({ url
|
|
15
|
+
*/ async function request({ url, method = 'GET', body }) {
|
|
16
16
|
const res = await fetch(url, {
|
|
17
17
|
method,
|
|
18
18
|
headers: {
|
package/dist/setupLink.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -14,18 +14,18 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import { createLink } from '@lowdefy/engine';
|
|
16
16
|
function setupLink(lowdefy) {
|
|
17
|
-
const { router
|
|
18
|
-
const { window
|
|
17
|
+
const { router } = lowdefy._internal;
|
|
18
|
+
const { window } = lowdefy._internal.globals;
|
|
19
19
|
const backLink = ()=>router.back();
|
|
20
20
|
const disabledLink = ()=>{};
|
|
21
|
-
const newOriginLink = ({ url
|
|
21
|
+
const newOriginLink = ({ url, query, newTab })=>{
|
|
22
22
|
if (newTab) {
|
|
23
23
|
return window.open(`${url}${query ? `?${query}` : ''}`, '_blank').focus();
|
|
24
24
|
} else {
|
|
25
25
|
return window.location.assign(`${url}${query ? `?${query}` : ''}`);
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
|
-
const sameOriginLink = ({ newTab
|
|
28
|
+
const sameOriginLink = ({ newTab, pathname, query, setInput })=>{
|
|
29
29
|
if (newTab) {
|
|
30
30
|
return window.open(`${window.location.origin}${lowdefy.basePath}${pathname}${query ? `?${query}` : ''}`, '_blank').focus();
|
|
31
31
|
} else {
|
package/dist/style.less
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2023 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
|
|
21
21
|
@keyframes spin {
|
|
22
22
|
0% {
|
|
23
|
-
|
|
23
|
+
transform: rotate(0deg);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
100% {
|
|
27
|
-
|
|
27
|
+
transform: rotate(360deg);
|
|
28
28
|
}
|
|
29
29
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/client",
|
|
3
|
-
"version": "4.0.0-rc.
|
|
3
|
+
"version": "4.0.0-rc.10",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Lowdefy Client",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -37,35 +37,35 @@
|
|
|
37
37
|
"clean": "rm -rf dist",
|
|
38
38
|
"copyfiles": "copyfiles -u 1 \"./src/**/*\" dist -e \"./src/**/*.js\" -e \"./src/**/*.yaml\" -e \"./src/**/*.snap\"",
|
|
39
39
|
"prepublishOnly": "pnpm build",
|
|
40
|
-
"test
|
|
41
|
-
"test": "jest --coverage"
|
|
40
|
+
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
|
|
42
41
|
},
|
|
43
42
|
"dependencies": {
|
|
44
|
-
"@ant-design/icons": "4.
|
|
45
|
-
"@lowdefy/block-utils": "4.0.0-rc.
|
|
46
|
-
"@lowdefy/engine": "4.0.0-rc.
|
|
47
|
-
"@lowdefy/helpers": "4.0.0-rc.
|
|
48
|
-
"@lowdefy/layout": "4.0.0-rc.
|
|
49
|
-
"classnames": "2.3.
|
|
43
|
+
"@ant-design/icons": "4.8.0",
|
|
44
|
+
"@lowdefy/block-utils": "4.0.0-rc.10",
|
|
45
|
+
"@lowdefy/engine": "4.0.0-rc.10",
|
|
46
|
+
"@lowdefy/helpers": "4.0.0-rc.10",
|
|
47
|
+
"@lowdefy/layout": "4.0.0-rc.10",
|
|
48
|
+
"classnames": "2.3.2",
|
|
50
49
|
"react": "18.2.0",
|
|
51
50
|
"react-dom": "18.2.0"
|
|
52
51
|
},
|
|
53
52
|
"devDependencies": {
|
|
54
|
-
"@emotion/jest": "11.
|
|
55
|
-
"@
|
|
56
|
-
"@
|
|
57
|
-
"@swc/
|
|
58
|
-
"@swc/
|
|
59
|
-
"@
|
|
60
|
-
"@testing-library/
|
|
61
|
-
"@testing-library/
|
|
53
|
+
"@emotion/jest": "11.10.5",
|
|
54
|
+
"@jest/globals": "28.1.3",
|
|
55
|
+
"@lowdefy/jest-yaml-transform": "4.0.0-rc.10",
|
|
56
|
+
"@swc/cli": "0.1.62",
|
|
57
|
+
"@swc/core": "1.3.70",
|
|
58
|
+
"@swc/jest": "0.2.27",
|
|
59
|
+
"@testing-library/dom": "8.19.1",
|
|
60
|
+
"@testing-library/react": "13.4.0",
|
|
61
|
+
"@testing-library/user-event": "14.4.3",
|
|
62
62
|
"copyfiles": "2.4.1",
|
|
63
|
-
"jest": "28.1.
|
|
64
|
-
"jest-environment-jsdom": "28.1.
|
|
63
|
+
"jest": "28.1.3",
|
|
64
|
+
"jest-environment-jsdom": "28.1.3",
|
|
65
65
|
"jest-serializer-html": "7.1.0"
|
|
66
66
|
},
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"access": "public"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "537af074f27770e32da9da8d48490f2eda94b406"
|
|
71
71
|
}
|