@lowdefy/block-utils 4.0.0-alpha.8 → 4.0.0-alpha.9

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.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2021 Lowdefy, Inc
2
+ Copyright 2020-2022 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-2021 Lowdefy, Inc
2
+ Copyright 2020-2022 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-2021 Lowdefy, Inc
2
+ Copyright 2020-2022 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.
@@ -105,7 +105,7 @@
105
105
  'string',
106
106
  'object'
107
107
  ],
108
- description: 'Name of an Ant Design Icon or properties of an Icon block to customize icon on menu item.'
108
+ description: 'Name of an React-Icon (See <a href="https://react-icons.github.io/react-icons/">all icons</a>) or properties of an Icon block to customize icon on menu item.'
109
109
  },
110
110
  danger: {
111
111
  type: 'boolean',
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2021 Lowdefy, Inc
2
+ Copyright 2020-2022 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,10 +14,8 @@
14
14
  limitations under the License.
15
15
  */ import blockDefaultProps from './blockDefaultProps.js';
16
16
  import blockSchema from './blockSchema.js';
17
- import createIcon from './createIcon.js';
18
- import ErrorBoundary from './ErrorBoundary.js';
19
17
  import HtmlComponent from './HtmlComponent.js';
20
18
  import makeCssClass from './makeCssClass.js';
21
19
  import mediaToCssObject from './mediaToCssObject.js';
22
20
  import renderHtml from './renderHtml.js';
23
- export { blockDefaultProps, blockSchema, createIcon, ErrorBoundary, HtmlComponent, makeCssClass, mediaToCssObject, renderHtml };
21
+ export { blockDefaultProps, blockSchema, HtmlComponent, makeCssClass, mediaToCssObject, renderHtml };
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2021 Lowdefy, Inc
2
+ Copyright 2020-2022 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
  /* eslint-disable no-undef */ /*
2
- Copyright 2020-2021 Lowdefy, Inc
2
+ Copyright 2020-2022 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-2021 Lowdefy, Inc
2
+ Copyright 2020-2022 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/block-utils",
3
- "version": "4.0.0-alpha.8",
3
+ "version": "4.0.0-alpha.9",
4
4
  "licence": "Apache-2.0",
5
5
  "description": "Lowdefy Block Utils",
6
6
  "homepage": "https://lowdefy.com",
@@ -26,24 +26,25 @@
26
26
  "url": "https://github.com/lowdefy/lowdefy.git"
27
27
  },
28
28
  "type": "module",
29
- "exports": "./dist/index.js",
29
+ "exports": {
30
+ ".": "./dist/index.js",
31
+ "./*": "./dist/*"
32
+ },
30
33
  "files": [
31
34
  "dist/*"
32
35
  ],
33
36
  "scripts": {
34
37
  "build": "yarn swc",
35
38
  "clean": "rm -rf dist",
39
+ "copyfiles": "copyfiles -u 1 \"./src/**/*\" dist -e \"./src/**/*.js\" -e \"./src/**/*.yaml\" -e \"./src/**/*.snap\"",
36
40
  "prepare": "yarn build",
37
- "swc": "swc src --out-dir dist --config-file ../../../.swcrc --delete-dir-on-start",
41
+ "swc": "swc src --out-dir dist --config-file ../../../.swcrc --delete-dir-on-start && yarn copyfiles",
38
42
  "test:watch": "jest --coverage --watch",
39
43
  "test": "jest --coverage"
40
44
  },
41
45
  "dependencies": {
42
- "@ant-design/icons": "4.7.0",
43
46
  "@emotion/css": "11.7.1",
44
- "@emotion/react": "11.7.1",
45
- "@lowdefy/helpers": "4.0.0-alpha.8",
46
- "classnames": "2.3.1",
47
+ "@lowdefy/helpers": "4.0.0-alpha.9",
47
48
  "dompurify": "2.3.5",
48
49
  "react": "17.0.2",
49
50
  "react-dom": "17.0.2"
@@ -56,11 +57,12 @@
56
57
  "@testing-library/dom": "8.11.3",
57
58
  "@testing-library/react": "13.0.0-alpha.4",
58
59
  "@testing-library/user-event": "14.0.0-alpha.14",
60
+ "copyfiles": "2.4.1",
59
61
  "jest": "27.5.1",
60
62
  "jest-serializer-html": "7.1.0"
61
63
  },
62
64
  "publishConfig": {
63
65
  "access": "public"
64
66
  },
65
- "gitHead": "9d56b83cf45e868afe3a1eeba750fe826eb74c8c"
67
+ "gitHead": "98b544eca231bdcfca6c3a8601a891835d5ce571"
66
68
  }
@@ -1,52 +0,0 @@
1
- /*
2
- Copyright 2020-2021 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,61 +0,0 @@
1
- /*
2
- Copyright 2020-2021 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
- ;
61
- export default ErrorPage;
@@ -1,114 +0,0 @@
1
- /*
2
- Copyright 2020-2021 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 { keyframes } from '@emotion/react';
18
- import { css } from '@emotion/css';
19
- import { omit, type } from '@lowdefy/helpers';
20
- import Icon from '@ant-design/icons';
21
- import blockDefaultProps from './blockDefaultProps.js';
22
- import ErrorBoundary from './ErrorBoundary.js';
23
- import makeCssClass from './makeCssClass.js';
24
- function _extends() {
25
- _extends = Object.assign || function(target) {
26
- for(var i = 1; i < arguments.length; i++){
27
- var source = arguments[i];
28
- for(var key in source){
29
- if (Object.prototype.hasOwnProperty.call(source, key)) {
30
- target[key] = source[key];
31
- }
32
- }
33
- }
34
- return target;
35
- };
36
- return _extends.apply(this, arguments);
37
- }
38
- const lowdefyProps = [
39
- 'actionLog',
40
- 'basePath',
41
- 'components',
42
- 'content',
43
- 'eventLog',
44
- 'list',
45
- 'loading',
46
- 'menus',
47
- 'pageId',
48
- 'registerEvent',
49
- 'registerMethod',
50
- 'schemaErrors',
51
- 'user',
52
- 'validation',
53
- ];
54
- const spin = keyframes`{
55
- 0% {
56
- transform: rotate(0deg);
57
- }
58
- 100% {
59
- transform: rotate(359deg);
60
- }
61
- }`;
62
- const spinClass = css`
63
- animation: ${spin} 2s infinite linear;
64
- `;
65
- const createIcon = (Icons)=>{
66
- const AiOutlineLoading3Quarters = Icons['AiOutlineLoading3Quarters'];
67
- const AiOutlineExclamationCircle = Icons['AiOutlineExclamationCircle'];
68
- const IconBlock = ({ blockId , events , methods , properties , ...props })=>{
69
- const propertiesObj = type.isString(properties) ? {
70
- name: properties
71
- } : properties;
72
- const iconProps = {
73
- id: blockId,
74
- className: classNames({
75
- [makeCssClass(propertiesObj.style)]: true,
76
- [spinClass]: propertiesObj.spin
77
- }),
78
- rotate: propertiesObj.rotate,
79
- color: propertiesObj.color,
80
- title: propertiesObj.name,
81
- size: propertiesObj.size,
82
- // twoToneColor: propertiesObj.color, // TODO: track https://github.com/react-icons/react-icons/issues/508
83
- ...omit(props, lowdefyProps)
84
- };
85
- let IconComp = Icons[propertiesObj.name];
86
- if (!IconComp) {
87
- IconComp = AiOutlineExclamationCircle;
88
- }
89
- return(/*#__PURE__*/ React.createElement(React.Fragment, null, events.onClick && events.onClick.loading && !propertiesObj.disableLoadingIcon ? /*#__PURE__*/ React.createElement(AiOutlineLoading3Quarters, _extends({}, {
90
- ...iconProps,
91
- spin: true
92
- })) : /*#__PURE__*/ React.createElement(ErrorBoundary, {
93
- fallback: ()=>/*#__PURE__*/ React.createElement(AiOutlineExclamationCircle, _extends({}, {
94
- ...iconProps,
95
- color: '#F00'
96
- }))
97
- }, /*#__PURE__*/ React.createElement(IconComp, _extends({
98
- id: blockId,
99
- onClick: events.onClick && (()=>methods.triggerEvent({
100
- name: 'onClick'
101
- })
102
- ),
103
- size: propertiesObj.size,
104
- title: propertiesObj.title
105
- }, iconProps)))));
106
- };
107
- const AntIcon = (all)=>/*#__PURE__*/ React.createElement(Icon, {
108
- component: ()=>/*#__PURE__*/ React.createElement(IconBlock, _extends({}, all))
109
- })
110
- ;
111
- AntIcon.defaultProps = blockDefaultProps;
112
- return AntIcon;
113
- };
114
- export default createIcon;