@lowdefy/client 4.0.0-alpha.16 → 4.0.0-alpha.19

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.
@@ -14,12 +14,13 @@
14
14
  limitations under the License.
15
15
  */ import { type, urlQuery as urlQueryFn } from '@lowdefy/helpers';
16
16
  function getCallbackUrl({ lowdefy , callbackUrl ={} }) {
17
- const { home , pageId , urlQuery } = callbackUrl;
17
+ const { home , pageId , urlQuery , url } = callbackUrl;
18
18
  if ([
19
19
  !home,
20
- !pageId
20
+ !pageId,
21
+ !url
21
22
  ].filter((v)=>!v).length > 1) {
22
- throw Error(`Invalid Link: To avoid ambiguity, only one of 'home' or 'pageId' can be defined.`);
23
+ throw Error(`Invalid Link: To avoid ambiguity, only one of 'home', 'pageId' or 'url' can be defined.`);
23
24
  }
24
25
  const query = type.isNone(urlQuery) ? '' : `${urlQueryFn.stringify(urlQuery)}`;
25
26
  if (home === true) {
@@ -28,25 +29,34 @@ function getCallbackUrl({ lowdefy , callbackUrl ={} }) {
28
29
  if (type.isString(pageId)) {
29
30
  return `/${pageId}${query ? `?${query}` : ''}`;
30
31
  }
32
+ if (type.isString(url)) {
33
+ return `${url}${query ? `?${query}` : ''}`;
34
+ }
31
35
  return undefined;
32
36
  }
33
37
  function createAuthMethods({ lowdefy , auth }) {
34
38
  // login and logout are Lowdefy function that handle action params
35
39
  // signIn and signOut are the next-auth methods
36
- function login({ providerId , callbackUrl , authUrl ={} } = {}) {
40
+ function login({ authUrl , callbackUrl , providerId , ...rest } = {}) {
37
41
  if (type.isNone(providerId) && auth.authConfig.providers.length === 1) {
38
42
  providerId = auth.authConfig.providers[0].id;
39
43
  }
40
44
  auth.signIn(providerId, {
45
+ ...rest,
41
46
  callbackUrl: getCallbackUrl({
42
47
  lowdefy,
43
48
  callbackUrl
44
49
  })
45
- }, authUrl.urlQuery);
50
+ }, authUrl?.urlQuery);
46
51
  }
47
- // TODO: fix callbackUrl
48
- function logout() {
49
- auth.signOut();
52
+ function logout({ callbackUrl , redirect } = {}) {
53
+ auth.signOut({
54
+ callbackUrl: getCallbackUrl({
55
+ lowdefy,
56
+ callbackUrl
57
+ }),
58
+ redirect
59
+ });
50
60
  }
51
61
  return {
52
62
  login,
@@ -31,6 +31,8 @@ const CategorySwitch = ({ block , Blocks , context , loading , lowdefy })=>{
31
31
  if (loading && type.isObject(block.eval.skeleton)) {
32
32
  return /*#__PURE__*/ React.createElement(LoadingBlock, {
33
33
  blockLayout: block.eval.layout,
34
+ blockProperties: block.eval.properties,
35
+ blockStyle: block.eval.style,
34
36
  context: context,
35
37
  lowdefy: lowdefy,
36
38
  skeleton: block.eval.skeleton
@@ -60,7 +62,7 @@ const CategorySwitch = ({ block , Blocks , context , loading , lowdefy })=>{
60
62
  id: `bl-${block.blockId}`,
61
63
  blockStyle: block.eval.style,
62
64
  highlightBorders: lowdefy.lowdefyGlobal.highlightBorders,
63
- layout: block.eval.layout || {},
65
+ layout: block.eval.layout,
64
66
  makeCssClass: makeCssClass
65
67
  }, /*#__PURE__*/ React.createElement(Component, {
66
68
  methods: Object.assign(block.methods, {
@@ -88,7 +90,7 @@ const CategorySwitch = ({ block , Blocks , context , loading , lowdefy })=>{
88
90
  id: `bl-${block.blockId}`,
89
91
  blockStyle: block.eval.style,
90
92
  highlightBorders: lowdefy.lowdefyGlobal.highlightBorders,
91
- layout: block.eval.layout || {},
93
+ layout: block.eval.layout,
92
94
  makeCssClass: makeCssClass
93
95
  }, /*#__PURE__*/ React.createElement(Component, {
94
96
  methods: Object.assign(block.methods, {
@@ -25,13 +25,13 @@ const Container = ({ block , Blocks , Component , context , loading , lowdefy }
25
25
  id: `ar-${block.blockId}-${areaKey}`,
26
26
  key: `ar-${block.blockId}-${areaKey}-${i}`,
27
27
  area: layoutParamsToArea({
28
- area: block.eval.areas[areaKey] || {},
28
+ area: block.eval.areas[areaKey],
29
29
  areaKey,
30
- layout: block.eval.layout || {}
30
+ layout: block.eval.layout
31
31
  }),
32
32
  areaStyle: [
33
33
  areaStyle,
34
- block.eval.areas[areaKey] && block.eval.areas[areaKey].style
34
+ block.eval.areas[areaKey]?.style
35
35
  ],
36
36
  highlightBorders: lowdefy.lowdefyGlobal.highlightBorders,
37
37
  makeCssClass: makeCssClass
@@ -48,7 +48,7 @@ const Container = ({ block , Blocks , Component , context , loading , lowdefy }
48
48
  id: `bl-${block.blockId}`,
49
49
  blockStyle: block.eval.style,
50
50
  highlightBorders: lowdefy.lowdefyGlobal.highlightBorders,
51
- layout: block.eval.layout || {},
51
+ layout: block.eval.layout,
52
52
  makeCssClass: makeCssClass
53
53
  }, /*#__PURE__*/ React.createElement(Component, {
54
54
  methods: Object.assign(block.methods, {
@@ -25,13 +25,13 @@ const List = ({ block , Blocks , Component , context , loading , lowdefy })=>{
25
25
  id: `ar-${block.blockId}-${SBlock.id}-${areaKey}`,
26
26
  key: `ar-${block.blockId}-${SBlock.id}-${areaKey}`,
27
27
  area: layoutParamsToArea({
28
- area: block.eval.areas[areaKey] || {},
28
+ area: block.eval.areas[areaKey],
29
29
  areaKey,
30
- layout: block.eval.layout || {}
30
+ layout: block.eval.layout
31
31
  }),
32
32
  areaStyle: [
33
33
  areaStyle,
34
- block.eval.areas[areaKey] && block.eval.areas[areaKey].style
34
+ block.eval.areas[areaKey]?.style
35
35
  ],
36
36
  highlightBorders: lowdefy.lowdefyGlobal.highlightBorders,
37
37
  makeCssClass: makeCssClass
@@ -52,7 +52,7 @@ const List = ({ block , Blocks , Component , context , loading , lowdefy })=>{
52
52
  id: `bl-${block.blockId}`,
53
53
  blockStyle: block.eval.style,
54
54
  highlightBorders: lowdefy.lowdefyGlobal.highlightBorders,
55
- layout: block.eval.layout || {},
55
+ layout: block.eval.layout,
56
56
  makeCssClass: makeCssClass
57
57
  }, /*#__PURE__*/ React.createElement(Component, {
58
58
  methods: Object.assign(block.methods, {
@@ -29,7 +29,7 @@ const blockMethods = {
29
29
  triggerEvent: ()=>{},
30
30
  unshiftItem: ()=>{}
31
31
  };
32
- const LoadingBlock = ({ blockLayout , blockId , context , lowdefy , skeleton })=>{
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]) {
@@ -41,32 +41,32 @@ const LoadingBlock = ({ blockLayout , blockId , context , lowdefy , skeleton })
41
41
  // default to box when a skeleton block is not found - should be a basic or loader block.
42
42
  Component = lowdefy._internal.blockComponents.Box;
43
43
  }
44
- const layout = skeleton.layout || blockLayout || {};
45
44
  switch(Component.meta.category){
46
45
  case 'list':
47
46
  return /*#__PURE__*/ React.createElement(LoadingList, {
48
47
  blockId: blockId,
49
48
  Component: Component,
50
49
  context: context,
51
- layout: layout,
52
50
  lowdefy: lowdefy,
53
51
  skeleton: skeleton
54
52
  });
55
53
  case 'container':
56
54
  return /*#__PURE__*/ React.createElement(LoadingContainer, {
57
55
  blockId: blockId,
56
+ blockLayout: blockLayout,
57
+ blockProperties: blockProperties,
58
+ blockStyle: blockStyle,
58
59
  Component: Component,
59
60
  context: context,
60
- layout: layout,
61
61
  lowdefy: lowdefy,
62
62
  skeleton: skeleton
63
63
  });
64
64
  default:
65
65
  return /*#__PURE__*/ React.createElement(BlockLayout, {
66
- blockStyle: skeleton.style,
66
+ blockStyle: skeleton.style ?? blockStyle,
67
67
  highlightBorders: lowdefy.lowdefyGlobal.highlightBorders,
68
68
  id: `s-bl-${blockId}-${skeleton.id}`,
69
- layout: layout,
69
+ layout: skeleton.layout ?? blockLayout,
70
70
  makeCssClass: makeCssClass
71
71
  }, /*#__PURE__*/ React.createElement(Component, {
72
72
  basePath: lowdefy.basePath,
@@ -76,7 +76,7 @@ const LoadingBlock = ({ blockLayout , blockId , context , lowdefy , skeleton })
76
76
  menus: lowdefy.menus,
77
77
  methods: blockMethods,
78
78
  pageId: lowdefy.pageId,
79
- properties: skeleton.properties
79
+ properties: skeleton.properties ?? blockProperties
80
80
  }));
81
81
  }
82
82
  };
@@ -16,15 +16,15 @@
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 , Component , context , layout , lowdefy , skeleton })=>{
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)=>{
23
23
  content[areaKey] = (areaStyle)=>/*#__PURE__*/ React.createElement(Area, {
24
24
  area: layoutParamsToArea({
25
- area: skeleton.areas[areaKey] || {},
25
+ area: skeleton.areas[areaKey],
26
26
  areaKey,
27
- layout
27
+ layout: skeleton.layout ?? blockLayout
28
28
  }),
29
29
  areaStyle: [
30
30
  areaStyle,
@@ -43,10 +43,10 @@ const LoadingContainer = ({ blockId , Component , context , layout , lowdefy , s
43
43
  })));
44
44
  });
45
45
  return /*#__PURE__*/ React.createElement(BlockLayout, {
46
- blockStyle: skeleton.style,
46
+ blockStyle: skeleton.style ?? blockStyle,
47
47
  highlightBorders: lowdefy.lowdefyGlobal.highlightBorders,
48
48
  id: `s-bl-${blockId}-${skeleton.id}`,
49
- layout: layout,
49
+ layout: skeleton.layout ?? blockLayout,
50
50
  makeCssClass: makeCssClass
51
51
  }, /*#__PURE__*/ React.createElement(Component, {
52
52
  basePath: lowdefy.basePath,
@@ -59,7 +59,7 @@ const LoadingContainer = ({ blockId , Component , context , layout , lowdefy , s
59
59
  makeCssClass
60
60
  },
61
61
  pageId: lowdefy.pageId,
62
- properties: skeleton.properties
62
+ properties: skeleton.properties ?? blockProperties
63
63
  }));
64
64
  };
65
65
  export default LoadingContainer;
@@ -16,20 +16,20 @@
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 , Component , context , layout , lowdefy , skeleton })=>{
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(()=>{
23
23
  Object.keys(skeleton.areas).forEach((areaKey, i)=>{
24
24
  content[areaKey] = (areaStyle)=>/*#__PURE__*/ React.createElement(Area, {
25
25
  area: layoutParamsToArea({
26
- area: skeleton.areas[areaKey] || {},
26
+ area: skeleton.areas[areaKey],
27
27
  areaKey,
28
- layout
28
+ layout: skeleton.layout ?? blockLayout
29
29
  }),
30
30
  areaStyle: [
31
31
  areaStyle,
32
- skeleton.areas[areaKey] && skeleton.areas[areaKey].style
32
+ skeleton.areas[areaKey]?.style
33
33
  ],
34
34
  highlightBorders: lowdefy.lowdefyGlobal.highlightBorders,
35
35
  id: `s-ar-${blockId}-${skeleton.id}-${areaKey}`,
@@ -48,10 +48,10 @@ const LoadingList = ({ blockId , Component , context , layout , lowdefy , skelet
48
48
  });
49
49
  });
50
50
  return /*#__PURE__*/ React.createElement(BlockLayout, {
51
- blockStyle: skeleton.style,
51
+ blockStyle: skeleton.style ?? blockStyle,
52
52
  highlightBorders: lowdefy.lowdefyGlobal.highlightBorders,
53
53
  id: `s-bl-${blockId}-${skeleton.id}`,
54
- layout: layout,
54
+ layout: skeleton.layout ?? blockLayout,
55
55
  makeCssClass: makeCssClass
56
56
  }, /*#__PURE__*/ React.createElement(Component, {
57
57
  basePath: lowdefy.basePath,
@@ -63,7 +63,7 @@ const LoadingList = ({ blockId , Component , context , layout , lowdefy , skelet
63
63
  makeCssClass
64
64
  },
65
65
  pageId: lowdefy.pageId,
66
- properties: skeleton.properties
66
+ properties: skeleton.properties ?? blockProperties
67
67
  }));
68
68
  };
69
69
  export default LoadingList;
@@ -2,6 +2,7 @@ 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 } = lowdefy._internal.globals;
5
6
  const backLink = ({ ariaLabel , children , className , id , rel })=>/*#__PURE__*/ React.createElement("a", {
6
7
  id: id,
7
8
  onClick: ()=>lowdefy._internal.router.back(),
@@ -50,8 +50,11 @@ function initLowdefyContext({ auth , Components , config , router , stage , type
50
50
  lowdefy.pageId = config.pageConfig.pageId;
51
51
  lowdefy.urlQuery = urlQuery.parse(window.location.search.slice(1));
52
52
  lowdefy.user = auth?.session?.user ?? null;
53
- lowdefy._internal.window = window;
54
- lowdefy._internal.document = window.document;
53
+ lowdefy._internal.globals = {
54
+ document: window.document,
55
+ fetch: window.fetch,
56
+ window
57
+ };
55
58
  lowdefy._internal.router = router;
56
59
  lowdefy._internal.link = setupLink(lowdefy);
57
60
  lowdefy._internal.updateBlock = (blockId)=>lowdefy._internal.updaters[blockId] && lowdefy._internal.updaters[blockId]();
package/dist/setupLink.js CHANGED
@@ -14,7 +14,8 @@
14
14
  limitations under the License.
15
15
  */ import { createLink } from '@lowdefy/engine';
16
16
  function setupLink(lowdefy) {
17
- const { router , window } = lowdefy._internal;
17
+ const { router } = lowdefy._internal;
18
+ const { window } = lowdefy._internal.globals;
18
19
  const backLink = ()=>router.back();
19
20
  const disabledLink = ()=>{};
20
21
  const newOriginLink = ({ url , query , newTab })=>{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/client",
3
- "version": "4.0.0-alpha.16",
3
+ "version": "4.0.0-alpha.19",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Lowdefy Client",
6
6
  "homepage": "https://lowdefy.com",
@@ -43,17 +43,17 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@ant-design/icons": "4.7.0",
46
- "@lowdefy/block-utils": "4.0.0-alpha.16",
47
- "@lowdefy/engine": "4.0.0-alpha.16",
48
- "@lowdefy/helpers": "4.0.0-alpha.16",
49
- "@lowdefy/layout": "4.0.0-alpha.16",
46
+ "@lowdefy/block-utils": "4.0.0-alpha.19",
47
+ "@lowdefy/engine": "4.0.0-alpha.19",
48
+ "@lowdefy/helpers": "4.0.0-alpha.19",
49
+ "@lowdefy/layout": "4.0.0-alpha.19",
50
50
  "classnames": "2.3.1",
51
51
  "react": "18.1.0",
52
52
  "react-dom": "18.1.0"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@emotion/jest": "11.9.1",
56
- "@lowdefy/jest-yaml-transform": "4.0.0-alpha.16",
56
+ "@lowdefy/jest-yaml-transform": "4.0.0-alpha.19",
57
57
  "@swc/cli": "0.1.57",
58
58
  "@swc/core": "1.2.194",
59
59
  "@swc/jest": "0.2.21",
@@ -68,5 +68,5 @@
68
68
  "publishConfig": {
69
69
  "access": "public"
70
70
  },
71
- "gitHead": "91459befdeb9b22aaba40e8c51d6a173a11ea939"
71
+ "gitHead": "5240a074f7225295a8c92aaf0236b7680c296b57"
72
72
  }