@lowdefy/client 4.0.0-alpha.29 → 4.0.0-alpha.31

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,74 @@
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 { Area, BlockLayout, layoutParamsToArea } from '@lowdefy/layout';
17
+ import { makeCssClass } from '@lowdefy/block-utils';
18
+ import Block from './Block.js';
19
+ const Container = ({ block , Blocks , Component , context , loading , lowdefy })=>{
20
+ const content = {};
21
+ // eslint-disable-next-line prefer-destructuring
22
+ const areas = Blocks.subBlocks[block.id][0].areas;
23
+ Object.keys(areas).forEach((areaKey, i)=>{
24
+ content[areaKey] = (areaStyle)=>/*#__PURE__*/ React.createElement(Area, {
25
+ id: `ar-${block.blockId}-${areaKey}`,
26
+ key: `ar-${block.blockId}-${areaKey}-${i}`,
27
+ area: layoutParamsToArea({
28
+ area: block.eval.areas[areaKey],
29
+ areaKey,
30
+ layout: block.eval.layout
31
+ }),
32
+ areaStyle: [
33
+ areaStyle,
34
+ block.eval.areas[areaKey]?.style
35
+ ],
36
+ highlightBorders: lowdefy.lowdefyGlobal.highlightBorders,
37
+ makeCssClass: makeCssClass
38
+ }, areas[areaKey].blocks.map((bl, k)=>/*#__PURE__*/ React.createElement(Block, {
39
+ key: `co-${bl.blockId}-${k}`,
40
+ Blocks: Blocks.subBlocks[block.id][0],
41
+ block: bl,
42
+ context: context,
43
+ parentLoading: loading,
44
+ lowdefy: lowdefy
45
+ })));
46
+ });
47
+ return /*#__PURE__*/ React.createElement(BlockLayout, {
48
+ id: `bl-${block.blockId}`,
49
+ blockStyle: block.eval.style,
50
+ highlightBorders: lowdefy.lowdefyGlobal.highlightBorders,
51
+ layout: block.eval.layout,
52
+ makeCssClass: makeCssClass
53
+ }, /*#__PURE__*/ React.createElement(Component, {
54
+ methods: Object.assign(block.methods, {
55
+ makeCssClass,
56
+ registerEvent: block.registerEvent,
57
+ registerMethod: block.registerMethod,
58
+ triggerEvent: block.triggerEvent
59
+ }),
60
+ basePath: lowdefy.basePath,
61
+ blockId: block.blockId,
62
+ components: lowdefy._internal.components,
63
+ content: content,
64
+ events: block.eval.events,
65
+ key: block.blockId,
66
+ loading: loading,
67
+ menus: lowdefy.menus,
68
+ pageId: lowdefy.pageId,
69
+ properties: block.eval.properties,
70
+ required: block.eval.required,
71
+ validation: block.eval.validation
72
+ }));
73
+ };
74
+ export default Container;
@@ -0,0 +1,83 @@
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 { Area, BlockLayout, layoutParamsToArea } from '@lowdefy/layout';
17
+ import { makeCssClass } from '@lowdefy/block-utils';
18
+ import Block from './Block.js';
19
+ const List = ({ block , Blocks , Component , context , loading , lowdefy })=>{
20
+ const content = {};
21
+ const contentList = [];
22
+ Blocks.subBlocks[block.id].forEach((SBlock)=>{
23
+ Object.keys(SBlock.areas).forEach((areaKey)=>{
24
+ content[areaKey] = (areaStyle)=>/*#__PURE__*/ React.createElement(Area, {
25
+ id: `ar-${block.blockId}-${SBlock.id}-${areaKey}`,
26
+ key: `ar-${block.blockId}-${SBlock.id}-${areaKey}`,
27
+ area: layoutParamsToArea({
28
+ area: block.eval.areas[areaKey],
29
+ areaKey,
30
+ layout: block.eval.layout
31
+ }),
32
+ areaStyle: [
33
+ areaStyle,
34
+ block.eval.areas[areaKey]?.style
35
+ ],
36
+ highlightBorders: lowdefy.lowdefyGlobal.highlightBorders,
37
+ makeCssClass: makeCssClass
38
+ }, SBlock.areas[areaKey].blocks.map((bl)=>/*#__PURE__*/ React.createElement(Block, {
39
+ key: `ls-${bl.blockId}`,
40
+ Blocks: SBlock,
41
+ block: bl,
42
+ context: context,
43
+ parentLoading: loading,
44
+ lowdefy: lowdefy
45
+ })));
46
+ });
47
+ contentList.push({
48
+ ...content
49
+ });
50
+ });
51
+ return /*#__PURE__*/ React.createElement(BlockLayout, {
52
+ id: `bl-${block.blockId}`,
53
+ blockStyle: block.eval.style,
54
+ highlightBorders: lowdefy.lowdefyGlobal.highlightBorders,
55
+ layout: block.eval.layout,
56
+ makeCssClass: makeCssClass
57
+ }, /*#__PURE__*/ React.createElement(Component, {
58
+ methods: Object.assign(block.methods, {
59
+ makeCssClass,
60
+ moveItemDown: block.moveItemDown,
61
+ moveItemUp: block.moveItemUp,
62
+ pushItem: block.pushItem,
63
+ registerEvent: block.registerEvent,
64
+ registerMethod: block.registerMethod,
65
+ removeItem: block.removeItem,
66
+ triggerEvent: block.triggerEvent,
67
+ unshiftItem: block.unshiftItem
68
+ }),
69
+ basePath: lowdefy.basePath,
70
+ blockId: block.blockId,
71
+ components: lowdefy._internal.components,
72
+ events: block.eval.events,
73
+ key: block.blockId,
74
+ list: contentList,
75
+ loading: loading,
76
+ menus: lowdefy.menus,
77
+ pageId: lowdefy.pageId,
78
+ properties: block.eval.properties,
79
+ required: block.eval.required,
80
+ validation: block.eval.validation
81
+ }));
82
+ };
83
+ export default List;
@@ -0,0 +1,83 @@
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 } from 'react';
16
+ import { BlockLayout } from '@lowdefy/layout';
17
+ import { makeCssClass } from '@lowdefy/block-utils';
18
+ import LoadingContainer from './LoadingContainer.js';
19
+ import LoadingList from './LoadingList.js';
20
+ const blockMethods = {
21
+ makeCssClass,
22
+ moveItemDown: ()=>{},
23
+ moveItemUp: ()=>{},
24
+ pushItem: ()=>{},
25
+ registerEvent: ()=>{},
26
+ registerMethod: ()=>{},
27
+ removeItem: ()=>{},
28
+ setValue: ()=>{},
29
+ triggerEvent: ()=>{},
30
+ unshiftItem: ()=>{}
31
+ };
32
+ const LoadingBlock = ({ blockId , blockLayout , blockProperties , blockStyle , context , lowdefy , skeleton , })=>{
33
+ let Component = lowdefy._internal.blockComponents[skeleton.type];
34
+ useEffect(()=>{
35
+ if (!lowdefy._internal.blockComponents[skeleton.type]) {
36
+ console.warn(`Skeleton block type not found for ${skeleton.type} in ${blockId}. Only '@lowdefy/blocks-basic' and '@lowdefy/blocks-loaders' block types are supported for skeletons.`);
37
+ }
38
+ return;
39
+ }, []);
40
+ if (!Component) {
41
+ // default to box when a skeleton block is not found - should be a basic or loader block.
42
+ Component = lowdefy._internal.blockComponents.Box;
43
+ }
44
+ switch(Component.meta.category){
45
+ case 'list':
46
+ return /*#__PURE__*/ React.createElement(LoadingList, {
47
+ blockId: blockId,
48
+ Component: Component,
49
+ context: context,
50
+ lowdefy: lowdefy,
51
+ skeleton: skeleton
52
+ });
53
+ case 'container':
54
+ return /*#__PURE__*/ React.createElement(LoadingContainer, {
55
+ blockId: blockId,
56
+ blockLayout: blockLayout,
57
+ blockProperties: blockProperties,
58
+ blockStyle: blockStyle,
59
+ Component: Component,
60
+ context: context,
61
+ lowdefy: lowdefy,
62
+ skeleton: skeleton
63
+ });
64
+ default:
65
+ return /*#__PURE__*/ React.createElement(BlockLayout, {
66
+ blockStyle: skeleton.style ?? blockStyle,
67
+ highlightBorders: lowdefy.lowdefyGlobal.highlightBorders,
68
+ id: `s-bl-${blockId}-${skeleton.id}`,
69
+ layout: skeleton.layout ?? blockLayout,
70
+ makeCssClass: makeCssClass
71
+ }, /*#__PURE__*/ React.createElement(Component, {
72
+ basePath: lowdefy.basePath,
73
+ blockId: blockId,
74
+ components: lowdefy._internal.components,
75
+ key: `s-${blockId}-${skeleton.id}`,
76
+ menus: lowdefy.menus,
77
+ methods: blockMethods,
78
+ pageId: lowdefy.pageId,
79
+ properties: skeleton.properties ?? blockProperties
80
+ }));
81
+ }
82
+ };
83
+ export default LoadingBlock;
@@ -0,0 +1,65 @@
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 { Area, BlockLayout, layoutParamsToArea } from '@lowdefy/layout';
17
+ import { makeCssClass } from '@lowdefy/block-utils';
18
+ import LoadingBlock from './LoadingBlock.js';
19
+ const LoadingContainer = ({ blockId , blockLayout , blockProperties , blockStyle , Component , context , lowdefy , skeleton , })=>{
20
+ const content = {};
21
+ // eslint-disable-next-line prefer-destructuring
22
+ Object.keys(skeleton.areas).forEach((areaKey, i)=>{
23
+ content[areaKey] = (areaStyle)=>/*#__PURE__*/ React.createElement(Area, {
24
+ area: layoutParamsToArea({
25
+ area: skeleton.areas[areaKey],
26
+ areaKey,
27
+ layout: skeleton.layout ?? blockLayout
28
+ }),
29
+ areaStyle: [
30
+ areaStyle,
31
+ skeleton.areas[areaKey] && skeleton.areas[areaKey].style
32
+ ],
33
+ highlightBorders: lowdefy.lowdefyGlobal.highlightBorders,
34
+ id: `s-ar-${blockId}-${skeleton.id}-${areaKey}`,
35
+ key: `s-ar-${blockId}-${skeleton.id}-${areaKey}-${i}`,
36
+ makeCssClass: makeCssClass
37
+ }, skeleton.areas[areaKey].blocks.map((skl, k)=>/*#__PURE__*/ React.createElement(LoadingBlock, {
38
+ blockId: blockId,
39
+ context: context,
40
+ key: `s-co-${skl.id}-${k}`,
41
+ lowdefy: lowdefy,
42
+ skeleton: skl
43
+ })));
44
+ });
45
+ return /*#__PURE__*/ React.createElement(BlockLayout, {
46
+ blockStyle: skeleton.style ?? blockStyle,
47
+ highlightBorders: lowdefy.lowdefyGlobal.highlightBorders,
48
+ id: `s-bl-${blockId}-${skeleton.id}`,
49
+ layout: skeleton.layout ?? blockLayout,
50
+ makeCssClass: makeCssClass
51
+ }, /*#__PURE__*/ React.createElement(Component, {
52
+ basePath: lowdefy.basePath,
53
+ blockId: blockId,
54
+ components: lowdefy._internal.components,
55
+ content: content,
56
+ key: skeleton.id,
57
+ menus: lowdefy.menus,
58
+ methods: {
59
+ makeCssClass
60
+ },
61
+ pageId: lowdefy.pageId,
62
+ properties: skeleton.properties ?? blockProperties
63
+ }));
64
+ };
65
+ export default LoadingContainer;
@@ -0,0 +1,69 @@
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 { Area, BlockLayout, layoutParamsToArea } from '@lowdefy/layout';
17
+ import { makeCssClass } from '@lowdefy/block-utils';
18
+ import LoadingBlock from './LoadingBlock.js';
19
+ const LoadingList = ({ blockId , blockLayout , blockProperties , blockStyle , Component , context , lowdefy , skeleton , })=>{
20
+ const content = {};
21
+ const contentList = [];
22
+ new Array(3).forEach(()=>{
23
+ Object.keys(skeleton.areas).forEach((areaKey, i)=>{
24
+ content[areaKey] = (areaStyle)=>/*#__PURE__*/ React.createElement(Area, {
25
+ area: layoutParamsToArea({
26
+ area: skeleton.areas[areaKey],
27
+ areaKey,
28
+ layout: skeleton.layout ?? blockLayout
29
+ }),
30
+ areaStyle: [
31
+ areaStyle,
32
+ skeleton.areas[areaKey]?.style
33
+ ],
34
+ highlightBorders: lowdefy.lowdefyGlobal.highlightBorders,
35
+ id: `s-ar-${blockId}-${skeleton.id}-${areaKey}`,
36
+ key: `s-ar-${blockId}-${skeleton.id}-${areaKey}-${i}`,
37
+ makeCssClass: makeCssClass
38
+ }, skeleton.areas[areaKey].blocks.map((skl, k)=>/*#__PURE__*/ React.createElement(LoadingBlock, {
39
+ blockId: blockId,
40
+ context: context,
41
+ key: `s-co-${skl.id}-${k}`,
42
+ lowdefy: lowdefy,
43
+ skeleton: skl
44
+ })));
45
+ });
46
+ contentList.push({
47
+ ...content
48
+ });
49
+ });
50
+ return /*#__PURE__*/ React.createElement(BlockLayout, {
51
+ blockStyle: skeleton.style ?? blockStyle,
52
+ highlightBorders: lowdefy.lowdefyGlobal.highlightBorders,
53
+ id: `s-bl-${blockId}-${skeleton.id}`,
54
+ layout: skeleton.layout ?? blockLayout,
55
+ makeCssClass: makeCssClass
56
+ }, /*#__PURE__*/ React.createElement(Component, {
57
+ basePath: lowdefy.basePath,
58
+ blockId: blockId,
59
+ components: lowdefy._internal.components,
60
+ list: contentList,
61
+ menus: lowdefy.menus,
62
+ methods: {
63
+ makeCssClass
64
+ },
65
+ pageId: lowdefy.pageId,
66
+ properties: skeleton.properties ?? blockProperties
67
+ }));
68
+ };
69
+ export default LoadingList;
@@ -0,0 +1,25 @@
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 request from './request.js';
16
+ function callRequest({ pageId , payload , requestId }) {
17
+ return request({
18
+ url: `/api/request/${pageId}/${requestId}`,
19
+ method: 'POST',
20
+ body: {
21
+ payload
22
+ }
23
+ });
24
+ }
25
+ export default callRequest;
@@ -0,0 +1,100 @@
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
+ /*
16
+ Copyright 2020-2022 Lowdefy, Inc
17
+
18
+ Licensed under the Apache License, Version 2.0 (the "License");
19
+ you may not use this file except in compliance with the License.
20
+ You may obtain a copy of the License at
21
+
22
+ http://www.apache.org/licenses/LICENSE-2.0
23
+
24
+ Unless required by applicable law or agreed to in writing, software
25
+ distributed under the License is distributed on an "AS IS" BASIS,
26
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27
+ See the License for the specific language governing permissions and
28
+ limitations under the License.
29
+ */ import React from 'react';
30
+ import classNames from 'classnames';
31
+ import { omit, type } from '@lowdefy/helpers';
32
+ import Icon from '@ant-design/icons';
33
+ import { blockDefaultProps, makeCssClass } from '@lowdefy/block-utils';
34
+ import ErrorBoundary from './ErrorBoundary.js';
35
+ const lowdefyProps = [
36
+ 'actionLog',
37
+ 'basePath',
38
+ 'components',
39
+ 'content',
40
+ 'eventLog',
41
+ 'list',
42
+ 'loading',
43
+ 'menus',
44
+ 'pageId',
45
+ 'registerEvent',
46
+ 'registerMethod',
47
+ 'schemaErrors',
48
+ 'validation',
49
+ ];
50
+ const createIcon = (Icons)=>{
51
+ const AiOutlineLoading3Quarters = Icons['AiOutlineLoading3Quarters'];
52
+ const AiOutlineExclamationCircle = Icons['AiOutlineExclamationCircle'];
53
+ const IconBlock = ({ blockId , events , methods , onClick , properties , ...props })=>{
54
+ const propertiesObj = type.isString(properties) ? {
55
+ name: properties
56
+ } : properties;
57
+ const spin = (propertiesObj.spin || events.onClick && events.onClick.loading) && !propertiesObj.disableLoadingIcon;
58
+ const iconProps = {
59
+ id: blockId,
60
+ className: classNames({
61
+ [makeCssClass([
62
+ {
63
+ cursor: (onClick || events.onClick) && 'pointer'
64
+ },
65
+ propertiesObj.style,
66
+ ])]: true,
67
+ 'icon-spin': spin
68
+ }),
69
+ rotate: propertiesObj.rotate,
70
+ color: propertiesObj.color,
71
+ title: propertiesObj.name,
72
+ size: propertiesObj.size,
73
+ // twoToneColor: propertiesObj.color, // TODO: track https://github.com/react-icons/react-icons/issues/508
74
+ ...omit(props, lowdefyProps)
75
+ };
76
+ let IconComp = Icons[propertiesObj.name];
77
+ if (!IconComp) {
78
+ IconComp = AiOutlineExclamationCircle;
79
+ }
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({}, {
82
+ ...iconProps,
83
+ color: '#F00'
84
+ }))
85
+ }, /*#__PURE__*/ React.createElement(IconComp, _extends({
86
+ id: blockId,
87
+ onClick: onClick || events.onClick && (()=>methods.triggerEvent({
88
+ name: 'onClick'
89
+ })),
90
+ size: propertiesObj.size,
91
+ title: propertiesObj.title
92
+ }, iconProps))));
93
+ };
94
+ const AntIcon = (all)=>/*#__PURE__*/ React.createElement(Icon, {
95
+ component: ()=>/*#__PURE__*/ React.createElement(IconBlock, _extends({}, all))
96
+ });
97
+ AntIcon.defaultProps = blockDefaultProps;
98
+ return AntIcon;
99
+ };
100
+ export default createIcon;
@@ -0,0 +1,63 @@
1
+ import React from 'react';
2
+ import { createLink } from '@lowdefy/engine';
3
+ import { type } from '@lowdefy/helpers';
4
+ const createLinkComponent = (lowdefy, Link)=>{
5
+ const { window } = lowdefy._internal.globals;
6
+ const backLink = ({ ariaLabel , children , className , id , rel })=>/*#__PURE__*/ React.createElement("a", {
7
+ id: id,
8
+ onClick: ()=>lowdefy._internal.router.back(),
9
+ className: className,
10
+ rel: rel,
11
+ "aria-label": ariaLabel || 'back'
12
+ }, type.isFunction(children) ? children(id) : children);
13
+ const newOriginLink = ({ ariaLabel , children , className , id , newTab , pageId , query , rel , url , })=>{
14
+ return /*#__PURE__*/ React.createElement("a", {
15
+ id: id,
16
+ "aria-label": ariaLabel,
17
+ className: className,
18
+ href: `${url}${query ? `?${query}` : ''}`,
19
+ rel: rel || newTab && 'noopener noreferrer',
20
+ target: newTab && '_blank'
21
+ }, type.isFunction(children) ? children(pageId || url || id) : children);
22
+ };
23
+ const sameOriginLink = ({ ariaLabel , children , className , id , newTab , pageId , pathname , query , rel , replace , scroll , setInput , url , })=>{
24
+ if (newTab) {
25
+ return(// eslint-disable-next-line react/jsx-no-target-blank
26
+ /*#__PURE__*/ React.createElement("a", {
27
+ id: id,
28
+ "aria-label": ariaLabel,
29
+ className: className,
30
+ href: `${window.location.origin}${lowdefy._internal.router.basePath}${pathname}${query ? `?${query}` : ''}`,
31
+ rel: rel || 'noopener noreferrer',
32
+ target: "_blank"
33
+ }, type.isFunction(children) ? children(pageId || url || id) : children));
34
+ }
35
+ return /*#__PURE__*/ React.createElement(Link, {
36
+ href: {
37
+ pathname,
38
+ query
39
+ },
40
+ replace: replace,
41
+ scroll: scroll
42
+ }, /*#__PURE__*/ React.createElement("a", {
43
+ id: id,
44
+ "aria-label": ariaLabel,
45
+ className: className,
46
+ rel: rel,
47
+ onClick: setInput
48
+ }, type.isFunction(children) ? children(pageId || url || id) : children));
49
+ };
50
+ const noLink = ({ className , children , id })=>/*#__PURE__*/ React.createElement("span", {
51
+ id: id,
52
+ className: className
53
+ }, type.isFunction(children) ? children(id) : children);
54
+ return createLink({
55
+ backLink,
56
+ lowdefy,
57
+ newOriginLink,
58
+ sameOriginLink,
59
+ noLink,
60
+ disabledLink: noLink
61
+ });
62
+ };
63
+ export default createLinkComponent;
package/dist/index.js ADDED
@@ -0,0 +1,16 @@
1
+ /*
2
+ Copyright 2020-2022 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ import Client from './Client.js';
16
+ export default Client;
@@ -0,0 +1,71 @@
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 callRequest from './callRequest.js';
16
+ import createIcon from './createIcon.js';
17
+ import createAuthMethods from './auth/createAuthMethods.js';
18
+ import createLinkComponent from './createLinkComponent.js';
19
+ import setupLink from './setupLink.js';
20
+ const lowdefy = {
21
+ _internal: {
22
+ callRequest,
23
+ components: {},
24
+ updaters: {},
25
+ displayMessage: ({ content })=>{
26
+ console.log(content);
27
+ return ()=>undefined;
28
+ },
29
+ link: ()=>undefined,
30
+ progress: {
31
+ state: {
32
+ progress: 0
33
+ },
34
+ dispatch: ()=>undefined
35
+ }
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
+ }
45
+ lowdefy.basePath = router.basePath;
46
+ lowdefy.home = config.rootConfig.home || {};
47
+ lowdefy.lowdefyGlobal = config.rootConfig.lowdefyGlobal;
48
+ lowdefy.menus = config.rootConfig.menus;
49
+ lowdefy.pageId = config.pageConfig.pageId;
50
+ 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
+ return lowdefy;
70
+ }
71
+ export default initLowdefyContext;