@lowdefy/client 0.0.0-experimental-20231123101256

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,116 @@
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
+ import { BlockLayout } from '@lowdefy/layout';
17
+ import { makeCssClass } from '@lowdefy/block-utils';
18
+ import { type } from '@lowdefy/helpers';
19
+ import Container from './Container.js';
20
+ import List from './List.js';
21
+ import LoadingBlock from './LoadingBlock.js';
22
+ const CategorySwitch = ({ block, Blocks, context, loading, lowdefy })=>{
23
+ if (!block.eval) return null; // TODO: check Renderer updates before eval is executed for the first time on lists. See #520
24
+ if (block.eval.visible === false) return /*#__PURE__*/ React.createElement("div", {
25
+ id: `vs-${block.blockId}`,
26
+ style: {
27
+ display: 'none'
28
+ }
29
+ });
30
+ const Component = lowdefy._internal.blockComponents[block.type];
31
+ if (loading && type.isObject(block.eval.skeleton)) {
32
+ return /*#__PURE__*/ React.createElement(LoadingBlock, {
33
+ blockLayout: block.eval.layout,
34
+ blockProperties: block.eval.properties,
35
+ blockStyle: block.eval.style,
36
+ context: context,
37
+ lowdefy: lowdefy,
38
+ skeleton: block.eval.skeleton
39
+ });
40
+ }
41
+ switch(Component.meta.category){
42
+ case 'list':
43
+ return /*#__PURE__*/ React.createElement(List, {
44
+ block: block,
45
+ Blocks: Blocks,
46
+ Component: Component,
47
+ context: context,
48
+ loading: loading,
49
+ lowdefy: lowdefy
50
+ });
51
+ case 'container':
52
+ return /*#__PURE__*/ React.createElement(Container, {
53
+ block: block,
54
+ Blocks: Blocks,
55
+ Component: Component,
56
+ context: context,
57
+ loading: loading,
58
+ lowdefy: lowdefy
59
+ });
60
+ case 'input':
61
+ return /*#__PURE__*/ React.createElement(BlockLayout, {
62
+ id: `bl-${block.blockId}`,
63
+ blockStyle: block.eval.style,
64
+ highlightBorders: lowdefy.lowdefyGlobal.highlightBorders,
65
+ layout: block.eval.layout,
66
+ makeCssClass: makeCssClass
67
+ }, /*#__PURE__*/ React.createElement(Component, {
68
+ methods: Object.assign(block.methods, {
69
+ makeCssClass,
70
+ registerEvent: block.registerEvent,
71
+ registerMethod: block.registerMethod,
72
+ setValue: block.setValue,
73
+ triggerEvent: block.triggerEvent
74
+ }),
75
+ basePath: lowdefy.basePath,
76
+ blockId: block.blockId,
77
+ components: lowdefy._internal.components,
78
+ events: block.eval.events,
79
+ key: block.blockId,
80
+ loading: loading,
81
+ menus: lowdefy.menus,
82
+ pageId: lowdefy.pageId,
83
+ properties: block.eval.properties,
84
+ required: block.eval.required,
85
+ validation: block.eval.validation,
86
+ value: block.value
87
+ }));
88
+ default:
89
+ return /*#__PURE__*/ React.createElement(BlockLayout, {
90
+ id: `bl-${block.blockId}`,
91
+ blockStyle: block.eval.style,
92
+ highlightBorders: lowdefy.lowdefyGlobal.highlightBorders,
93
+ layout: block.eval.layout,
94
+ makeCssClass: makeCssClass
95
+ }, /*#__PURE__*/ React.createElement(Component, {
96
+ methods: Object.assign(block.methods, {
97
+ makeCssClass,
98
+ registerEvent: block.registerEvent,
99
+ registerMethod: block.registerMethod,
100
+ triggerEvent: block.triggerEvent
101
+ }),
102
+ basePath: lowdefy.basePath,
103
+ blockId: block.blockId,
104
+ components: lowdefy._internal.components,
105
+ events: block.eval.events,
106
+ key: block.blockId,
107
+ loading: loading,
108
+ menus: lowdefy.menus,
109
+ pageId: lowdefy.pageId,
110
+ properties: block.eval.properties,
111
+ required: block.eval.required,
112
+ validation: block.eval.validation
113
+ }));
114
+ }
115
+ };
116
+ export default CategorySwitch;
@@ -0,0 +1,74 @@
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
+ 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-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
+ 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-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, { 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-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
+ 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]?.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-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
+ 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,28 @@
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 request from './request.js';
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;
27
+ }
28
+ export default createCallRequest;
@@ -0,0 +1,86 @@
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
+ import classNames from 'classnames';
17
+ import { omit, type } from '@lowdefy/helpers';
18
+ import Icon from '@ant-design/icons';
19
+ import { blockDefaultProps, ErrorBoundary, makeCssClass } from '@lowdefy/block-utils';
20
+ const lowdefyProps = [
21
+ 'actionLog',
22
+ 'basePath',
23
+ 'components',
24
+ 'content',
25
+ 'eventLog',
26
+ 'list',
27
+ 'loading',
28
+ 'menus',
29
+ 'pageId',
30
+ 'registerEvent',
31
+ 'registerMethod',
32
+ 'schemaErrors',
33
+ 'validation'
34
+ ];
35
+ const createIcon = (Icons)=>{
36
+ const AiOutlineLoading3Quarters = Icons['AiOutlineLoading3Quarters'];
37
+ const AiOutlineExclamationCircle = Icons['AiOutlineExclamationCircle'];
38
+ const IconBlock = ({ blockId, events, methods, onClick, properties, ...props })=>{
39
+ const propertiesObj = type.isString(properties) ? {
40
+ name: properties
41
+ } : properties;
42
+ const spin = (propertiesObj.spin || events.onClick?.loading) && !propertiesObj.disableLoadingIcon;
43
+ const iconProps = {
44
+ id: blockId,
45
+ className: classNames({
46
+ [makeCssClass([
47
+ {
48
+ cursor: (onClick || events.onClick) && 'pointer'
49
+ },
50
+ propertiesObj.style
51
+ ])]: true,
52
+ 'icon-spin': spin
53
+ }),
54
+ rotate: propertiesObj.rotate,
55
+ color: propertiesObj.color,
56
+ title: propertiesObj.name,
57
+ size: propertiesObj.size,
58
+ // twoToneColor: propertiesObj.color, // TODO: track https://github.com/react-icons/react-icons/issues/508
59
+ ...omit(props, lowdefyProps)
60
+ };
61
+ let IconComp = Icons[propertiesObj.name];
62
+ if (!IconComp) {
63
+ IconComp = AiOutlineExclamationCircle;
64
+ }
65
+ return /*#__PURE__*/ React.createElement(React.Fragment, null, spin ? /*#__PURE__*/ React.createElement(AiOutlineLoading3Quarters, iconProps) : /*#__PURE__*/ React.createElement(ErrorBoundary, {
66
+ fallback: ()=>/*#__PURE__*/ React.createElement(AiOutlineExclamationCircle, {
67
+ ...iconProps,
68
+ color: '#F00'
69
+ })
70
+ }, /*#__PURE__*/ React.createElement(IconComp, {
71
+ id: blockId,
72
+ onClick: onClick || events.onClick && (()=>methods.triggerEvent({
73
+ name: 'onClick'
74
+ })),
75
+ size: propertiesObj.size,
76
+ title: propertiesObj.title,
77
+ ...iconProps
78
+ })));
79
+ };
80
+ const AntIcon = (all)=>/*#__PURE__*/ React.createElement(Icon, {
81
+ component: ()=>/*#__PURE__*/ React.createElement(IconBlock, all)
82
+ });
83
+ AntIcon.defaultProps = blockDefaultProps;
84
+ return AntIcon;
85
+ };
86
+ export default createIcon;