@lowdefy/block-utils 4.0.0-alpha.1 → 4.0.0-alpha.10
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.
- package/dist/HtmlComponent.js +3 -4
- package/dist/blockDefaultProps.js +6 -11
- package/dist/blockSchema.js +2 -2
- package/dist/index.js +2 -4
- package/dist/makeCssClass.js +1 -1
- package/dist/mediaToCssObject.js +2 -3
- package/dist/renderHtml.js +2 -3
- package/package.json +20 -18
- package/dist/ErrorBoundary.js +0 -53
- package/dist/ErrorPage.js +0 -78
- package/dist/createIcon.js +0 -99
package/dist/HtmlComponent.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
1
|
/*
|
|
3
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
4
3
|
|
|
5
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
5
|
you may not use this file except in compliance with the License.
|
|
@@ -28,7 +27,7 @@ let HtmlComponent = class HtmlComponent extends React.Component {
|
|
|
28
27
|
render() {
|
|
29
28
|
const { div , id , methods , style } = this.props;
|
|
30
29
|
if (div === true) {
|
|
31
|
-
return(/*#__PURE__*/
|
|
30
|
+
return(/*#__PURE__*/ React.createElement("div", {
|
|
32
31
|
id: id,
|
|
33
32
|
"data-testid": id,
|
|
34
33
|
ref: (el)=>{
|
|
@@ -39,7 +38,7 @@ let HtmlComponent = class HtmlComponent extends React.Component {
|
|
|
39
38
|
className: methods.makeCssClass(style)
|
|
40
39
|
}));
|
|
41
40
|
}
|
|
42
|
-
return(/*#__PURE__*/
|
|
41
|
+
return(/*#__PURE__*/ React.createElement("span", {
|
|
43
42
|
id: id,
|
|
44
43
|
"data-testid": id,
|
|
45
44
|
ref: (el)=>{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
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.
|
|
@@ -16,12 +16,9 @@
|
|
|
16
16
|
const blockDefaultProps = {
|
|
17
17
|
basePath: '',
|
|
18
18
|
blockId: 'undefined_id',
|
|
19
|
-
components: {
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
},
|
|
23
|
-
events: {
|
|
24
|
-
},
|
|
19
|
+
components: {},
|
|
20
|
+
content: {},
|
|
21
|
+
events: {},
|
|
25
22
|
list: [],
|
|
26
23
|
menus: [],
|
|
27
24
|
methods: {
|
|
@@ -32,10 +29,8 @@ const blockDefaultProps = {
|
|
|
32
29
|
,
|
|
33
30
|
triggerEvent: ()=>undefined
|
|
34
31
|
},
|
|
35
|
-
properties: {
|
|
36
|
-
},
|
|
37
|
-
user: {
|
|
38
|
-
},
|
|
32
|
+
properties: {},
|
|
33
|
+
user: {},
|
|
39
34
|
required: false,
|
|
40
35
|
validation: {
|
|
41
36
|
status: null,
|
package/dist/blockSchema.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
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
|
|
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-
|
|
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,
|
|
21
|
+
export { blockDefaultProps, blockSchema, HtmlComponent, makeCssClass, mediaToCssObject, renderHtml };
|
package/dist/makeCssClass.js
CHANGED
package/dist/mediaToCssObject.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable no-undef */ /*
|
|
2
|
-
Copyright 2020-
|
|
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.
|
|
@@ -57,8 +57,7 @@ const mediaToCssObject = (styles, styleObjectOnly)=>{
|
|
|
57
57
|
return style.replace(mediaRegex, setReplacer);
|
|
58
58
|
}
|
|
59
59
|
if (!type.isObject(style)) {
|
|
60
|
-
return {
|
|
61
|
-
};
|
|
60
|
+
return {};
|
|
62
61
|
}
|
|
63
62
|
let mq = media;
|
|
64
63
|
if (styleObjectOnly) {
|
package/dist/renderHtml.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
1
|
/*
|
|
3
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
4
3
|
|
|
5
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
5
|
you may not use this file except in compliance with the License.
|
|
@@ -16,7 +15,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
16
15
|
*/ import React from 'react';
|
|
17
16
|
import { type } from '@lowdefy/helpers';
|
|
18
17
|
import HtmlComponent from './HtmlComponent.js';
|
|
19
|
-
const renderHtml = ({ div , html , id , methods , style })=>type.isNone(html) ? undefined : /*#__PURE__*/
|
|
18
|
+
const renderHtml = ({ div , html , id , methods , style })=>type.isNone(html) ? undefined : /*#__PURE__*/ React.createElement(HtmlComponent, {
|
|
20
19
|
div: div,
|
|
21
20
|
html: html,
|
|
22
21
|
id: id,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/block-utils",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.10",
|
|
4
4
|
"licence": "Apache-2.0",
|
|
5
5
|
"description": "Lowdefy Block Utils",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -26,41 +26,43 @@
|
|
|
26
26
|
"url": "https://github.com/lowdefy/lowdefy.git"
|
|
27
27
|
},
|
|
28
28
|
"type": "module",
|
|
29
|
-
"exports":
|
|
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
|
-
"@emotion/css": "11.
|
|
43
|
-
"@
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"react": "18.0.0-alpha-327d5c484-20211106",
|
|
48
|
-
"react-dom": "18.0.0-alpha-327d5c484-20211106"
|
|
46
|
+
"@emotion/css": "11.7.1",
|
|
47
|
+
"@lowdefy/helpers": "4.0.0-alpha.10",
|
|
48
|
+
"dompurify": "2.3.5",
|
|
49
|
+
"react": "17.0.2",
|
|
50
|
+
"react-dom": "17.0.2"
|
|
49
51
|
},
|
|
50
52
|
"devDependencies": {
|
|
51
|
-
"@
|
|
52
|
-
"@
|
|
53
|
-
"@swc/
|
|
54
|
-
"@swc/
|
|
55
|
-
"@
|
|
56
|
-
"@testing-library/dom": "8.10.1",
|
|
53
|
+
"@emotion/jest": "11.7.1",
|
|
54
|
+
"@swc/cli": "0.1.55",
|
|
55
|
+
"@swc/core": "1.2.135",
|
|
56
|
+
"@swc/jest": "0.2.17",
|
|
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",
|
|
59
|
-
"
|
|
60
|
+
"copyfiles": "2.4.1",
|
|
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": "
|
|
67
|
+
"gitHead": "d697b4b5f354697d9481a371b90a00ca0944f486"
|
|
66
68
|
}
|
package/dist/ErrorBoundary.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/*
|
|
3
|
-
Copyright 2020-2021 Lowdefy, Inc
|
|
4
|
-
|
|
5
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
you may not use this file except in compliance with the License.
|
|
7
|
-
You may obtain a copy of the License at
|
|
8
|
-
|
|
9
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
|
|
11
|
-
Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
See the License for the specific language governing permissions and
|
|
15
|
-
limitations under the License.
|
|
16
|
-
*/ import React, { Component } from 'react';
|
|
17
|
-
import ErrorPage from './ErrorPage.js';
|
|
18
|
-
let ErrorBoundary = class ErrorBoundary extends Component {
|
|
19
|
-
static getDerivedStateFromError(error) {
|
|
20
|
-
return {
|
|
21
|
-
hasError: true,
|
|
22
|
-
error
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
render() {
|
|
26
|
-
const { children , description , fallback , fullPage , message , name } = this.props;
|
|
27
|
-
const { hasError , error } = this.state;
|
|
28
|
-
if (hasError) {
|
|
29
|
-
if (fallback) {
|
|
30
|
-
return fallback(error);
|
|
31
|
-
}
|
|
32
|
-
if (fullPage) {
|
|
33
|
-
return(/*#__PURE__*/ _jsx(ErrorPage, {
|
|
34
|
-
code: error.number,
|
|
35
|
-
description: description || error.description,
|
|
36
|
-
message: message || error.message,
|
|
37
|
-
name: name || error.name
|
|
38
|
-
}));
|
|
39
|
-
}
|
|
40
|
-
// Throw to console but fail silently to user?
|
|
41
|
-
return '';
|
|
42
|
-
}
|
|
43
|
-
return children;
|
|
44
|
-
}
|
|
45
|
-
constructor(props){
|
|
46
|
-
super(props);
|
|
47
|
-
this.state = {
|
|
48
|
-
hasError: false,
|
|
49
|
-
error: null
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
export default ErrorBoundary;
|
package/dist/ErrorPage.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
/*
|
|
3
|
-
Copyright 2020-2021 Lowdefy, Inc
|
|
4
|
-
|
|
5
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
you may not use this file except in compliance with the License.
|
|
7
|
-
You may obtain a copy of the License at
|
|
8
|
-
|
|
9
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
|
|
11
|
-
Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
See the License for the specific language governing permissions and
|
|
15
|
-
limitations under the License.
|
|
16
|
-
*/ import React from 'react';
|
|
17
|
-
const ErrorPage = ({ code , description , message , name })=>/*#__PURE__*/ _jsxs("div", {
|
|
18
|
-
style: {
|
|
19
|
-
height: '100%',
|
|
20
|
-
fontFamily: 'system-ui',
|
|
21
|
-
margin: 0,
|
|
22
|
-
display: 'flex',
|
|
23
|
-
justifyContent: 'center',
|
|
24
|
-
alignItems: 'center'
|
|
25
|
-
},
|
|
26
|
-
children: [
|
|
27
|
-
/*#__PURE__*/ _jsx("div", {
|
|
28
|
-
style: {
|
|
29
|
-
flex: '0 1 auto',
|
|
30
|
-
fontSize: '4.3em',
|
|
31
|
-
fontWeight: '100',
|
|
32
|
-
paddingRight: 30
|
|
33
|
-
},
|
|
34
|
-
children: code || 500
|
|
35
|
-
}),
|
|
36
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
37
|
-
style: {
|
|
38
|
-
flex: '0 1 auto',
|
|
39
|
-
paddingLeft: 30,
|
|
40
|
-
maxWidth: 400,
|
|
41
|
-
borderLeft: '1px solid #aeaeae'
|
|
42
|
-
},
|
|
43
|
-
children: [
|
|
44
|
-
/*#__PURE__*/ _jsx("div", {
|
|
45
|
-
style: {
|
|
46
|
-
fontSize: '1.3em',
|
|
47
|
-
fontWeight: '300',
|
|
48
|
-
paddingBottom: 10
|
|
49
|
-
},
|
|
50
|
-
children: name || 'Error'
|
|
51
|
-
}),
|
|
52
|
-
/*#__PURE__*/ _jsx("div", {
|
|
53
|
-
style: {
|
|
54
|
-
fontSize: '0.9em'
|
|
55
|
-
},
|
|
56
|
-
children: message || 'An error has occurred.'
|
|
57
|
-
}),
|
|
58
|
-
/*#__PURE__*/ _jsx("div", {
|
|
59
|
-
style: {
|
|
60
|
-
fontSize: '0.9em'
|
|
61
|
-
},
|
|
62
|
-
children: description
|
|
63
|
-
}),
|
|
64
|
-
/*#__PURE__*/ _jsx("div", {
|
|
65
|
-
style: {
|
|
66
|
-
paddingTop: 20
|
|
67
|
-
},
|
|
68
|
-
children: /*#__PURE__*/ _jsx("a", {
|
|
69
|
-
href: "/",
|
|
70
|
-
children: "Return to home page"
|
|
71
|
-
})
|
|
72
|
-
})
|
|
73
|
-
]
|
|
74
|
-
})
|
|
75
|
-
]
|
|
76
|
-
})
|
|
77
|
-
;
|
|
78
|
-
export default ErrorPage;
|
package/dist/createIcon.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
/*
|
|
3
|
-
Copyright 2020-2021 Lowdefy, Inc
|
|
4
|
-
|
|
5
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
you may not use this file except in compliance with the License.
|
|
7
|
-
You may obtain a copy of the License at
|
|
8
|
-
|
|
9
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
|
|
11
|
-
Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
See the License for the specific language governing permissions and
|
|
15
|
-
limitations under the License.
|
|
16
|
-
*/ import React from 'react';
|
|
17
|
-
import classNames from 'classnames';
|
|
18
|
-
import { keyframes } from '@emotion/react';
|
|
19
|
-
import { css } from '@emotion/css';
|
|
20
|
-
import { omit, type } from '@lowdefy/helpers';
|
|
21
|
-
import blockDefaultProps from './blockDefaultProps.js';
|
|
22
|
-
import ErrorBoundary from './ErrorBoundary.js';
|
|
23
|
-
import makeCssClass from './makeCssClass.js';
|
|
24
|
-
const lowdefyProps = [
|
|
25
|
-
'actionLog',
|
|
26
|
-
'basePath',
|
|
27
|
-
'components',
|
|
28
|
-
'content',
|
|
29
|
-
'eventLog',
|
|
30
|
-
'homePageId',
|
|
31
|
-
'list',
|
|
32
|
-
'loading',
|
|
33
|
-
'menus',
|
|
34
|
-
'pageId',
|
|
35
|
-
'registerEvent',
|
|
36
|
-
'registerMethod',
|
|
37
|
-
'schemaErrors',
|
|
38
|
-
'user',
|
|
39
|
-
'validation',
|
|
40
|
-
];
|
|
41
|
-
const spin = keyframes`{
|
|
42
|
-
0% {
|
|
43
|
-
transform: rotate(0deg);
|
|
44
|
-
}
|
|
45
|
-
100% {
|
|
46
|
-
transform: rotate(359deg);
|
|
47
|
-
}
|
|
48
|
-
}`;
|
|
49
|
-
const spinClass = css`
|
|
50
|
-
animation: ${spin} 2s infinite linear;
|
|
51
|
-
`;
|
|
52
|
-
const createIcon = (Icons)=>{
|
|
53
|
-
const AiOutlineLoading3Quarters = Icons['AiOutlineLoading3Quarters'];
|
|
54
|
-
const AiOutlineExclamationCircle = Icons['AiOutlineExclamationCircle'];
|
|
55
|
-
const IconComp1 = ({ blockId , events , methods , properties , ...props })=>{
|
|
56
|
-
const propertiesObj = type.isString(properties) ? {
|
|
57
|
-
name: properties
|
|
58
|
-
} : properties;
|
|
59
|
-
const iconProps = {
|
|
60
|
-
id: blockId,
|
|
61
|
-
className: classNames({
|
|
62
|
-
[makeCssClass(propertiesObj.style)]: true,
|
|
63
|
-
[spinClass]: propertiesObj.spin
|
|
64
|
-
}),
|
|
65
|
-
rotate: propertiesObj.rotate,
|
|
66
|
-
// twoToneColor: propertiesObj.color, // TODO: track https://github.com/react-icons/react-icons/issues/508
|
|
67
|
-
...omit(props, lowdefyProps)
|
|
68
|
-
};
|
|
69
|
-
let IconComp = Icons[propertiesObj.name];
|
|
70
|
-
if (!IconComp) {
|
|
71
|
-
IconComp = AiOutlineExclamationCircle;
|
|
72
|
-
}
|
|
73
|
-
return(/*#__PURE__*/ _jsx(_Fragment, {
|
|
74
|
-
children: events.onClick && events.onClick.loading && !propertiesObj.disableLoadingIcon ? /*#__PURE__*/ _jsx(AiOutlineLoading3Quarters, {
|
|
75
|
-
...iconProps,
|
|
76
|
-
spin: true
|
|
77
|
-
}) : /*#__PURE__*/ _jsx(ErrorBoundary, {
|
|
78
|
-
fallback: ()=>/*#__PURE__*/ _jsx(AiOutlineExclamationCircle, {
|
|
79
|
-
...iconProps,
|
|
80
|
-
color: '#F00'
|
|
81
|
-
})
|
|
82
|
-
,
|
|
83
|
-
children: /*#__PURE__*/ _jsx(IconComp, {
|
|
84
|
-
id: blockId,
|
|
85
|
-
onClick: events.onClick && (()=>methods.triggerEvent({
|
|
86
|
-
name: 'onClick'
|
|
87
|
-
})
|
|
88
|
-
),
|
|
89
|
-
size: propertiesObj.size,
|
|
90
|
-
title: propertiesObj.title,
|
|
91
|
-
...iconProps
|
|
92
|
-
})
|
|
93
|
-
})
|
|
94
|
-
}));
|
|
95
|
-
};
|
|
96
|
-
IconComp1.defaultProps = blockDefaultProps;
|
|
97
|
-
return IconComp1;
|
|
98
|
-
};
|
|
99
|
-
export default createIcon;
|