@lowdefy/client 4.0.0-rc.9 → 4.0.0

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.
@@ -0,0 +1,76 @@
1
+ /*
2
+ Copyright 2020-2024 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, useEffect } from 'react';
16
+ const containerStyle = {
17
+ display: 'flex',
18
+ position: 'fixed',
19
+ bottom: 0,
20
+ right: 0
21
+ };
22
+ const brandStyle = {
23
+ flex: '0 1 auto',
24
+ contentAlign: 'middle',
25
+ padding: 4,
26
+ background: '#1990FF',
27
+ borderRadius: 6,
28
+ margin: 4
29
+ };
30
+ const imageStyle = {
31
+ flex: '1 0 auto',
32
+ padding: 2,
33
+ marginRight: 4
34
+ };
35
+ const textStyle = {
36
+ flex: '1 0 auto',
37
+ fontSize: 12,
38
+ color: 'white',
39
+ lineHeight: '1.2rem'
40
+ };
41
+ const checkEntitlement = async ({ setShowBranding })=>{
42
+ const license = await (await fetch('/api/license')).json();
43
+ setShowBranding(!license.entitlements.includes('NO_BRANDING'));
44
+ };
45
+ const BrandTag = ()=>{
46
+ const [showBranding, setShowBranding] = useState(false);
47
+ useEffect(()=>{
48
+ checkEntitlement({
49
+ setShowBranding
50
+ });
51
+ }, []);
52
+ if (!showBranding) {
53
+ return;
54
+ }
55
+ return /*#__PURE__*/ React.createElement("div", {
56
+ style: containerStyle
57
+ }, /*#__PURE__*/ React.createElement("span", {
58
+ style: brandStyle
59
+ }, /*#__PURE__*/ React.createElement("img", {
60
+ style: imageStyle,
61
+ src: "https://lowdefy.com/images/logo_white_40.png",
62
+ alt: "",
63
+ height: 20
64
+ }), /*#__PURE__*/ React.createElement("span", {
65
+ style: textStyle
66
+ }, /*#__PURE__*/ React.createElement("a", {
67
+ href: "https://lowdefy.com",
68
+ target: "_blank",
69
+ rel: "noreferrer",
70
+ style: {
71
+ textDecoration: 'none',
72
+ color: 'inherit'
73
+ }
74
+ }, "Built with Lowdefy"))));
75
+ };
76
+ export default BrandTag;
package/dist/Client.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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,15 +15,16 @@
15
15
  */ import React from 'react';
16
16
  import { serializer } from '@lowdefy/helpers';
17
17
  import Block from './block/Block.js';
18
+ import BrandTag from './BrandTag.js';
18
19
  import Context from './Context.js';
19
20
  import DisplayMessage from './DisplayMessage.js';
20
21
  import Head from './Head.js';
21
22
  import ProgressBarController from './ProgressBarController.js';
22
23
  import initLowdefyContext from './initLowdefyContext.js';
23
- const Client = ({ auth , Components , config: rawConfig , lowdefy , resetContext ={
24
+ const Client = ({ auth, Components, config: rawConfig, lowdefy, resetContext = {
24
25
  reset: false,
25
26
  setReset: ()=>undefined
26
- } , router , stage , types , window })=>{
27
+ }, router, stage, types, window })=>{
27
28
  const config = serializer.deserialize(rawConfig);
28
29
  initLowdefyContext({
29
30
  auth,
@@ -66,6 +67,6 @@ const Client = ({ auth , Components , config: rawConfig , lowdefy , resetContext
66
67
  lowdefy: lowdefy,
67
68
  parentLoading: false
68
69
  }));
69
- }));
70
+ }), /*#__PURE__*/ React.createElement(BrandTag, null));
70
71
  };
71
72
  export default Client;
package/dist/Context.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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 , config , lowdefy , resetContext })=>{
18
+ const Context = ({ children, config, lowdefy, resetContext })=>{
19
19
  const context = getContext({
20
20
  config,
21
21
  lowdefy,
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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 , id , methods })=>{
17
+ const DisplayMessage = ({ Component, id, methods })=>{
18
18
  return /*#__PURE__*/ React.createElement(Component, {
19
19
  blockId: id,
20
20
  key: id,
package/dist/Head.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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 , properties })=>{
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;
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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 , context , triggerEvent , triggerEventAsync })=>{
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 , lowdefy , resetContext })=>{
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-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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 , callbackUrl ={} }) {
17
- const { home , pageId , urlQuery , url } = callbackUrl;
16
+ function getCallbackUrl({ lowdefy, callbackUrl = {} }) {
17
+ const { home, pageId, urlQuery, url } = callbackUrl;
18
18
  if ([
19
19
  !home,
20
20
  !pageId,
@@ -37,8 +37,8 @@ function getCallbackUrl({ lowdefy , callbackUrl ={} }) {
37
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 , callbackUrl , providerId , ...rest } = {}) {
41
- if (type.isNone(providerId) && auth.authConfig.providers.length === 1) {
40
+ function login({ authUrl, callbackUrl, providerId, ...rest } = {}) {
41
+ if (type.isNone(providerId) && auth.authConfig?.providers.length === 1) {
42
42
  providerId = auth.authConfig.providers[0].id;
43
43
  }
44
44
  return auth.signIn(providerId, {
@@ -49,7 +49,7 @@ function createAuthMethods(lowdefy, auth) {
49
49
  })
50
50
  }, authUrl?.urlQuery);
51
51
  }
52
- function logout({ callbackUrl , redirect } = {}) {
52
+ function logout({ callbackUrl, redirect } = {}) {
53
53
  return auth.signOut({
54
54
  callbackUrl: getCallbackUrl({
55
55
  lowdefy,
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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,10 +13,10 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import React, { useState } from 'react';
16
+ import { ErrorBoundary } from '@lowdefy/block-utils';
16
17
  import CategorySwitch from './CategorySwitch.js';
17
- import ErrorBoundary from '../ErrorBoundary.js';
18
18
  import MountEvents from '../MountEvents.js';
19
- const Block = ({ block , Blocks , context , lowdefy , parentLoading })=>{
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-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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 , Blocks , context , loading , lowdefy })=>{
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}`,
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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 , Blocks , Component , context , loading , lowdefy })=>{
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;
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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 , Blocks , Component , context , loading , lowdefy })=>{
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-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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 , blockLayout , blockProperties , blockStyle , 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]) {
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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 , blockLayout , blockProperties , blockStyle , Component , context , 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)=>{
@@ -28,7 +28,7 @@ const LoadingContainer = ({ blockId , blockLayout , blockProperties , blockStyle
28
28
  }),
29
29
  areaStyle: [
30
30
  areaStyle,
31
- skeleton.areas[areaKey] && skeleton.areas[areaKey].style
31
+ skeleton.areas[areaKey]?.style
32
32
  ],
33
33
  highlightBorders: lowdefy.lowdefyGlobal.highlightBorders,
34
34
  id: `s-ar-${blockId}-${skeleton.id}-${areaKey}`,
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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 , blockLayout , blockProperties , blockStyle , Component , context , 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(()=>{
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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 request from './request.js';
16
- function createCallRequest({ basePath }) {
17
- function callRequest({ pageId , payload , requestId }) {
16
+ function createCallRequest({ basePath }) {
17
+ function callRequest({ pageId, payload, requestId }) {
18
18
  return request({
19
19
  url: `${basePath}/api/request/${pageId}/${requestId}`,
20
20
  method: 'POST',
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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,26 +12,11 @@
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
- */ function _extends() {
16
- _extends = Object.assign || function(target) {
17
- for(var i = 1; i < arguments.length; i++){
18
- var source = arguments[i];
19
- for(var key in source){
20
- if (Object.prototype.hasOwnProperty.call(source, key)) {
21
- target[key] = source[key];
22
- }
23
- }
24
- }
25
- return target;
26
- };
27
- return _extends.apply(this, arguments);
28
- }
29
- import React from 'react';
15
+ */ import React from 'react';
30
16
  import classNames from 'classnames';
31
17
  import { omit, type } from '@lowdefy/helpers';
32
18
  import Icon from '@ant-design/icons';
33
- import { blockDefaultProps, makeCssClass } from '@lowdefy/block-utils';
34
- import ErrorBoundary from './ErrorBoundary.js';
19
+ import { blockDefaultProps, ErrorBoundary, makeCssClass } from '@lowdefy/block-utils';
35
20
  const lowdefyProps = [
36
21
  'actionLog',
37
22
  'basePath',
@@ -50,11 +35,11 @@ const lowdefyProps = [
50
35
  const createIcon = (Icons)=>{
51
36
  const AiOutlineLoading3Quarters = Icons['AiOutlineLoading3Quarters'];
52
37
  const AiOutlineExclamationCircle = Icons['AiOutlineExclamationCircle'];
53
- const IconBlock = ({ blockId , events , methods , onClick , properties , ...props })=>{
38
+ const IconBlock = ({ blockId, events, methods, onClick, properties, ...props })=>{
54
39
  const propertiesObj = type.isString(properties) ? {
55
40
  name: properties
56
41
  } : properties;
57
- const spin = (propertiesObj.spin || events.onClick && events.onClick.loading) && !propertiesObj.disableLoadingIcon;
42
+ const spin = (propertiesObj.spin || events.onClick?.loading) && !propertiesObj.disableLoadingIcon;
58
43
  const iconProps = {
59
44
  id: blockId,
60
45
  className: classNames({
@@ -77,22 +62,23 @@ const createIcon = (Icons)=>{
77
62
  if (!IconComp) {
78
63
  IconComp = AiOutlineExclamationCircle;
79
64
  }
80
- return /*#__PURE__*/ React.createElement(React.Fragment, null, spin ? /*#__PURE__*/ React.createElement(AiOutlineLoading3Quarters, _extends({}, iconProps)) : /*#__PURE__*/ React.createElement(ErrorBoundary, {
81
- fallback: ()=>/*#__PURE__*/ React.createElement(AiOutlineExclamationCircle, _extends({}, {
65
+ return /*#__PURE__*/ React.createElement(React.Fragment, null, spin ? /*#__PURE__*/ React.createElement(AiOutlineLoading3Quarters, iconProps) : /*#__PURE__*/ React.createElement(ErrorBoundary, {
66
+ fallback: ()=>/*#__PURE__*/ React.createElement(AiOutlineExclamationCircle, {
82
67
  ...iconProps,
83
68
  color: '#F00'
84
- }))
85
- }, /*#__PURE__*/ React.createElement(IconComp, _extends({
69
+ })
70
+ }, /*#__PURE__*/ React.createElement(IconComp, {
86
71
  id: blockId,
87
72
  onClick: onClick || events.onClick && (()=>methods.triggerEvent({
88
73
  name: 'onClick'
89
74
  })),
90
75
  size: propertiesObj.size,
91
- title: propertiesObj.title
92
- }, iconProps))));
76
+ title: propertiesObj.title,
77
+ ...iconProps
78
+ })));
93
79
  };
94
80
  const AntIcon = (all)=>/*#__PURE__*/ React.createElement(Icon, {
95
- component: ()=>/*#__PURE__*/ React.createElement(IconBlock, _extends({}, all))
81
+ component: ()=>/*#__PURE__*/ React.createElement(IconBlock, all)
96
82
  });
97
83
  AntIcon.defaultProps = blockDefaultProps;
98
84
  return AntIcon;
@@ -2,32 +2,32 @@ 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;
6
- const backLink = ({ ariaLabel , children , className , id , onClick =()=>{} , rel })=>/*#__PURE__*/ React.createElement("a", {
5
+ const { window } = lowdefy._internal.globals;
6
+ const backLink = ({ ariaLabel, children, className, id, onClick = ()=>{}, rel })=>/*#__PURE__*/ React.createElement("a", {
7
7
  id: id,
8
8
  className: className,
9
9
  rel: rel,
10
- "aria-label": ariaLabel || 'back',
10
+ "aria-label": ariaLabel ?? 'back',
11
11
  onClick: (...params)=>{
12
12
  lowdefy._internal.router.back();
13
13
  onClick(...params);
14
14
  }
15
15
  }, type.isFunction(children) ? children(id) : children);
16
- const newOriginLink = ({ ariaLabel , children , className , href , id , onClick =()=>{} , newTab , pageId , query , rel , url })=>{
16
+ const newOriginLink = ({ ariaLabel, children, className, href, id, onClick = ()=>{}, newTab, pageId, query, rel, url })=>{
17
17
  return /*#__PURE__*/ React.createElement("a", {
18
18
  id: id,
19
19
  "aria-label": ariaLabel,
20
20
  className: className,
21
- href: href || `${url}${query ? `?${query}` : ''}`,
22
- rel: rel || newTab && 'noopener noreferrer',
21
+ href: href ?? `${url}${query ? `?${query}` : ''}`,
22
+ rel: rel ?? (newTab && 'noopener noreferrer'),
23
23
  target: newTab && '_blank',
24
24
  onClick: async (...params)=>{
25
25
  await onClick(...params);
26
26
  return true;
27
27
  }
28
- }, type.isFunction(children) ? children(pageId || url || id) : children);
28
+ }, type.isFunction(children) ? children(pageId ?? url ?? id) : children);
29
29
  };
30
- const sameOriginLink = ({ ariaLabel , children , className , id , newTab , onClick =()=>{} , pageId , pathname , query , rel , replace , scroll , setInput , url })=>{
30
+ const sameOriginLink = ({ ariaLabel, children, className, id, newTab, onClick = ()=>{}, pageId, pathname, query, rel, replace, scroll, setInput, url })=>{
31
31
  if (newTab) {
32
32
  return(// eslint-disable-next-line react/jsx-no-target-blank
33
33
  /*#__PURE__*/ React.createElement("a", {
@@ -35,22 +35,22 @@ const createLinkComponent = (lowdefy, Link)=>{
35
35
  "aria-label": ariaLabel,
36
36
  className: className,
37
37
  href: `${window.location.origin}${lowdefy.basePath}${pathname}${query ? `?${query}` : ''}`,
38
- rel: rel || 'noopener noreferrer',
38
+ rel: rel ?? 'noopener noreferrer',
39
39
  target: "_blank",
40
40
  onClick: async (...params)=>{
41
41
  await onClick(...params);
42
42
  return true;
43
43
  }
44
- }, type.isFunction(children) ? children(pageId || url || id) : children));
44
+ }, type.isFunction(children) ? children(pageId ?? url ?? id) : children));
45
45
  }
46
- return /*#__PURE__*/ React.createElement(Link, {
46
+ return(// This code can be made simpler.
47
+ /*#__PURE__*/ React.createElement(Link, {
47
48
  href: {
48
49
  pathname,
49
50
  query
50
51
  },
51
52
  replace: replace,
52
- scroll: scroll
53
- }, /*#__PURE__*/ React.createElement("a", {
53
+ scroll: scroll,
54
54
  id: id,
55
55
  "aria-label": ariaLabel,
56
56
  className: className,
@@ -59,9 +59,9 @@ const createLinkComponent = (lowdefy, Link)=>{
59
59
  setInput();
60
60
  onClick(...params);
61
61
  }
62
- }, type.isFunction(children) ? children(pageId || url || id) : children));
62
+ }, type.isFunction(children) ? children(pageId ?? url ?? id) : children));
63
63
  };
64
- const noLink = ({ className , children , id , onClick =()=>{} })=>/*#__PURE__*/ React.createElement("span", {
64
+ const noLink = ({ className, children, id, onClick = ()=>{} })=>/*#__PURE__*/ React.createElement("span", {
65
65
  id: id,
66
66
  className: className,
67
67
  onClick: onClick
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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.
@@ -17,7 +17,7 @@ import createCallRequest from './createCallRequest.js';
17
17
  import createIcon from './createIcon.js';
18
18
  import createLinkComponent from './createLinkComponent.js';
19
19
  import setupLink from './setupLink.js';
20
- function initLowdefyContext({ auth , Components , config , lowdefy , router , stage , types , window }) {
20
+ function initLowdefyContext({ auth, Components, config, lowdefy, router, stage, types, window }) {
21
21
  if (!lowdefy._internal?.initialised) {
22
22
  lowdefy._internal = {
23
23
  actions: types.actions,
@@ -25,7 +25,7 @@ function initLowdefyContext({ auth , Components , config , lowdefy , router , st
25
25
  components: {
26
26
  Icon: createIcon(types.icons)
27
27
  },
28
- displayMessage: ({ content })=>{
28
+ displayMessage: ({ content })=>{
29
29
  console.log(content);
30
30
  return ()=>undefined;
31
31
  },
package/dist/request.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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 , method ='GET' , body }) {
15
+ */ async function request({ url, method = 'GET', body }) {
16
16
  const res = await fetch(url, {
17
17
  method,
18
18
  headers: {
@@ -22,10 +22,10 @@
22
22
  });
23
23
  if (!res.ok) {
24
24
  // TODO: check
25
- const body1 = await res.json();
25
+ const body = await res.json();
26
26
  console.log(res);
27
- console.log(body1);
28
- throw new Error(body1.message || 'Request error');
27
+ console.log(body);
28
+ throw new Error(body.message || 'Request error');
29
29
  }
30
30
  return res.json();
31
31
  }
package/dist/setupLink.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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,26 @@
14
14
  limitations under the License.
15
15
  */ import { createLink } from '@lowdefy/engine';
16
16
  function setupLink(lowdefy) {
17
- const { router } = lowdefy._internal;
18
- const { window } = lowdefy._internal.globals;
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 , query , newTab })=>{
21
+ const newOriginLink = ({ url, query, newTab })=>{
22
22
  if (newTab) {
23
- return window.open(`${url}${query ? `?${query}` : ''}`, '_blank').focus();
24
- } else {
25
- return window.location.assign(`${url}${query ? `?${query}` : ''}`);
23
+ const handle = window.open(`${url}${query ? `?${query}` : ''}`, '_blank');
24
+ if (!handle) {
25
+ lowdefy._internal.displayMessage({
26
+ content: 'A popup blocker may be preventing the application from opening the page. Approve the popup to continue.',
27
+ status: 'info',
28
+ duration: 10
29
+ });
30
+ return;
31
+ }
32
+ return handle.focus();
26
33
  }
34
+ return window.location.assign(`${url}${query ? `?${query}` : ''}`);
27
35
  };
28
- const sameOriginLink = ({ newTab , pathname , query , setInput })=>{
36
+ const sameOriginLink = ({ newTab, pathname, query, setInput })=>{
29
37
  if (newTab) {
30
38
  return window.open(`${window.location.origin}${lowdefy.basePath}${pathname}${query ? `?${query}` : ''}`, '_blank').focus();
31
39
  } else {
package/dist/style.less CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/client",
3
- "version": "4.0.0-rc.9",
3
+ "version": "4.0.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Lowdefy Client",
6
6
  "homepage": "https://lowdefy.com",
@@ -32,40 +32,38 @@
32
32
  "files": [
33
33
  "dist/*"
34
34
  ],
35
- "scripts": {
36
- "build": "swc src --out-dir dist --config-file ../../.swcrc --delete-dir-on-start && pnpm copyfiles",
37
- "clean": "rm -rf dist",
38
- "copyfiles": "copyfiles -u 1 \"./src/**/*\" dist -e \"./src/**/*.js\" -e \"./src/**/*.yaml\" -e \"./src/**/*.snap\"",
39
- "prepublishOnly": "pnpm build",
40
- "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
41
- },
42
35
  "dependencies": {
43
36
  "@ant-design/icons": "4.8.0",
44
- "@lowdefy/block-utils": "4.0.0-rc.9",
45
- "@lowdefy/engine": "4.0.0-rc.9",
46
- "@lowdefy/helpers": "4.0.0-rc.9",
47
- "@lowdefy/layout": "4.0.0-rc.9",
37
+ "@lowdefy/block-utils": "4.0.0",
38
+ "@lowdefy/engine": "4.0.0",
39
+ "@lowdefy/helpers": "4.0.0",
40
+ "@lowdefy/layout": "4.0.0",
48
41
  "classnames": "2.3.2",
49
42
  "react": "18.2.0",
50
43
  "react-dom": "18.2.0"
51
44
  },
52
45
  "devDependencies": {
53
46
  "@emotion/jest": "11.10.5",
54
- "@jest/globals": "28.1.0",
55
- "@lowdefy/jest-yaml-transform": "4.0.0-rc.9",
56
- "@swc/cli": "0.1.59",
57
- "@swc/core": "1.3.24",
58
- "@swc/jest": "0.2.24",
47
+ "@jest/globals": "28.1.3",
48
+ "@lowdefy/jest-yaml-transform": "4.0.0",
49
+ "@swc/cli": "0.1.63",
50
+ "@swc/core": "1.3.99",
51
+ "@swc/jest": "0.2.29",
59
52
  "@testing-library/dom": "8.19.1",
60
53
  "@testing-library/react": "13.4.0",
61
54
  "@testing-library/user-event": "14.4.3",
62
55
  "copyfiles": "2.4.1",
63
- "jest": "28.1.0",
64
- "jest-environment-jsdom": "28.1.0",
56
+ "jest": "28.1.3",
57
+ "jest-environment-jsdom": "28.1.3",
65
58
  "jest-serializer-html": "7.1.0"
66
59
  },
67
60
  "publishConfig": {
68
61
  "access": "public"
69
62
  },
70
- "gitHead": "d20e6ac424643feca527a732dc2b0710713c8243"
71
- }
63
+ "scripts": {
64
+ "build": "swc src --out-dir dist --config-file ../../.swcrc --delete-dir-on-start && pnpm copyfiles",
65
+ "clean": "rm -rf dist",
66
+ "copyfiles": "copyfiles -u 1 \"./src/**/*\" dist -e \"./src/**/*.js\" -e \"./src/**/*.yaml\" -e \"./src/**/*.snap\"",
67
+ "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
68
+ }
69
+ }
@@ -1,52 +0,0 @@
1
- /*
2
- Copyright 2020-2023 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-2023 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;