@lowdefy/block-dev 4.0.0-alpha.6 → 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.
- package/dist/BlockSchemaErrors.js +7 -63
- package/dist/index.js +1 -1
- package/dist/mockBlock.js +2 -3
- package/dist/runBlockSchemaTests.js +1 -1
- package/dist/runMockMethodTests.js +29 -22
- package/dist/runMockRenderTests.js +33 -16
- package/dist/runRenderTests.js +32 -22
- package/dist/schemaTest.js +1 -1
- package/dist/stubBlockProps.js +25 -26
- package/package.json +11 -11
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } 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,72 +15,17 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
16
15
|
*/ import React from 'react';
|
|
17
16
|
const BlockSchemaErrors = ({ schemaErrors })=>{
|
|
18
17
|
if (!schemaErrors || schemaErrors.length === 0) return '';
|
|
19
|
-
return(/*#__PURE__*/
|
|
18
|
+
return(/*#__PURE__*/ React.createElement("div", {
|
|
20
19
|
style: {
|
|
21
20
|
padding: 10,
|
|
22
21
|
fontSize: '0.8rem',
|
|
23
22
|
border: '1px solid red',
|
|
24
23
|
background: '#fBB',
|
|
25
24
|
width: '100%'
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
})
|
|
32
|
-
}),
|
|
33
|
-
schemaErrors.map((error, i)=>/*#__PURE__*/ _jsxs("div", {
|
|
34
|
-
children: [
|
|
35
|
-
/*#__PURE__*/ _jsx("br", {}),
|
|
36
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
37
|
-
children: [
|
|
38
|
-
/*#__PURE__*/ _jsx("b", {
|
|
39
|
-
children: "keyword:"
|
|
40
|
-
}),
|
|
41
|
-
" ",
|
|
42
|
-
error.keyword
|
|
43
|
-
]
|
|
44
|
-
}),
|
|
45
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
46
|
-
children: [
|
|
47
|
-
/*#__PURE__*/ _jsx("b", {
|
|
48
|
-
children: "message:"
|
|
49
|
-
}),
|
|
50
|
-
" ",
|
|
51
|
-
error.message
|
|
52
|
-
]
|
|
53
|
-
}),
|
|
54
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
55
|
-
children: [
|
|
56
|
-
/*#__PURE__*/ _jsx("b", {
|
|
57
|
-
children: "params:"
|
|
58
|
-
}),
|
|
59
|
-
" ",
|
|
60
|
-
JSON.stringify(error.params)
|
|
61
|
-
]
|
|
62
|
-
}),
|
|
63
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
64
|
-
children: [
|
|
65
|
-
/*#__PURE__*/ _jsx("b", {
|
|
66
|
-
children: "dataPath:"
|
|
67
|
-
}),
|
|
68
|
-
" ",
|
|
69
|
-
error.dataPath
|
|
70
|
-
]
|
|
71
|
-
}),
|
|
72
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
73
|
-
children: [
|
|
74
|
-
/*#__PURE__*/ _jsx("b", {
|
|
75
|
-
children: "schemaPath:"
|
|
76
|
-
}),
|
|
77
|
-
" ",
|
|
78
|
-
error.schemaPath
|
|
79
|
-
]
|
|
80
|
-
})
|
|
81
|
-
]
|
|
82
|
-
}, i)
|
|
83
|
-
)
|
|
84
|
-
]
|
|
85
|
-
}));
|
|
25
|
+
}
|
|
26
|
+
}, /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("b", null, "Schema Errors")), schemaErrors.map((error, i)=>/*#__PURE__*/ React.createElement("div", {
|
|
27
|
+
key: i
|
|
28
|
+
}, /*#__PURE__*/ React.createElement("br", null), /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("b", null, "keyword:"), " ", error.keyword), /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("b", null, "message:"), " ", error.message), /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("b", null, "params:"), " ", JSON.stringify(error.params)), /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("b", null, "dataPath:"), " ", error.dataPath), /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("b", null, "schemaPath:"), " ", error.schemaPath))
|
|
29
|
+
)));
|
|
86
30
|
};
|
|
87
31
|
export default BlockSchemaErrors;
|
package/dist/index.js
CHANGED
package/dist/mockBlock.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,7 +14,7 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import { makeCssClass } from '@lowdefy/block-utils';
|
|
16
16
|
import stubBlockProps from './stubBlockProps.js';
|
|
17
|
-
const mockBlock = ({ meta ,
|
|
17
|
+
const mockBlock = ({ meta , schema })=>{
|
|
18
18
|
const mockMath = Object.create(global.Math);
|
|
19
19
|
mockMath.random = ()=>0.5
|
|
20
20
|
;
|
|
@@ -87,7 +87,6 @@ const mockBlock = ({ meta , logger , schema })=>{
|
|
|
87
87
|
return stubBlockProps({
|
|
88
88
|
block,
|
|
89
89
|
meta,
|
|
90
|
-
logger,
|
|
91
90
|
schema
|
|
92
91
|
});
|
|
93
92
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } 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.
|
|
@@ -18,10 +17,24 @@ import { type } from '@lowdefy/helpers';
|
|
|
18
17
|
import { render, screen } from '@testing-library/react';
|
|
19
18
|
import userEvent from '@testing-library/user-event';
|
|
20
19
|
import mockBlock from './mockBlock.js';
|
|
21
|
-
|
|
20
|
+
function _extends() {
|
|
21
|
+
_extends = Object.assign || function(target) {
|
|
22
|
+
for(var i = 1; i < arguments.length; i++){
|
|
23
|
+
var source = arguments[i];
|
|
24
|
+
for(var key in source){
|
|
25
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
26
|
+
target[key] = source[key];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
return _extends.apply(this, arguments);
|
|
33
|
+
}
|
|
34
|
+
const runMockMethodTests = ({ Block: Block1 , examples , mocks , schema , testConfig })=>{
|
|
35
|
+
const meta = Block1.meta;
|
|
22
36
|
const { before , methods , getProps } = mockBlock({
|
|
23
37
|
meta,
|
|
24
|
-
logger,
|
|
25
38
|
schema
|
|
26
39
|
});
|
|
27
40
|
beforeEach(()=>{
|
|
@@ -35,8 +48,8 @@ const runMockMethodTests = ({ examples , logger , meta , mocks , schema , tests
|
|
|
35
48
|
];
|
|
36
49
|
examples.forEach((ex)=>{
|
|
37
50
|
values.forEach((value, v)=>{
|
|
38
|
-
if (
|
|
39
|
-
|
|
51
|
+
if (testConfig && testConfig.methods) {
|
|
52
|
+
testConfig.methods.forEach((method)=>{
|
|
40
53
|
mocks.forEach((mock)=>{
|
|
41
54
|
test(`Mock for method: ${JSON.stringify(method)} - ${ex.id} - value[${v}] - ${mock.name}`, async ()=>{
|
|
42
55
|
const mockFns = await mock.getMockFns();
|
|
@@ -47,23 +60,17 @@ const runMockMethodTests = ({ examples , logger , meta , mocks , schema , tests
|
|
|
47
60
|
...methods,
|
|
48
61
|
registerMethod: props.methods.registerMethod
|
|
49
62
|
};
|
|
50
|
-
return(/*#__PURE__*/
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
props.methods[method.name](method.args);
|
|
60
|
-
},
|
|
61
|
-
"data-testid": "btn_method"
|
|
62
|
-
})
|
|
63
|
-
]
|
|
64
|
-
}));
|
|
63
|
+
return(/*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(Block, _extends({}, props, {
|
|
64
|
+
value: value
|
|
65
|
+
})), /*#__PURE__*/ React.createElement("button", {
|
|
66
|
+
id: `${ex.id}_button`,
|
|
67
|
+
onClick: ()=>{
|
|
68
|
+
props.methods[method.name](method.args);
|
|
69
|
+
},
|
|
70
|
+
"data-testid": "btn_method"
|
|
71
|
+
})));
|
|
65
72
|
};
|
|
66
|
-
const { container } = render(/*#__PURE__*/
|
|
73
|
+
const { container } = render(/*#__PURE__*/ React.createElement(Shell, null));
|
|
67
74
|
expect(container.firstChild).toMatchSnapshot();
|
|
68
75
|
userEvent.click(screen.getByTestId('btn_method'));
|
|
69
76
|
mockFns.forEach((mockFn)=>{
|
|
@@ -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.
|
|
@@ -15,12 +14,26 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
15
14
|
limitations under the License.
|
|
16
15
|
*/ import React from 'react';
|
|
17
16
|
import { type } from '@lowdefy/helpers';
|
|
18
|
-
import { render } from '@testing-library/react';
|
|
17
|
+
import { render, waitFor } from '@testing-library/react';
|
|
19
18
|
import mockBlock from './mockBlock.js';
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
function _extends() {
|
|
20
|
+
_extends = Object.assign || function(target) {
|
|
21
|
+
for(var i = 1; i < arguments.length; i++){
|
|
22
|
+
var source = arguments[i];
|
|
23
|
+
for(var key in source){
|
|
24
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
25
|
+
target[key] = source[key];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return target;
|
|
30
|
+
};
|
|
31
|
+
return _extends.apply(this, arguments);
|
|
32
|
+
}
|
|
33
|
+
const runMockRenderTests = ({ Block: Block1 , examples , logger , mocks , reset =()=>null
|
|
34
|
+
, schema , testConfig , })=>{
|
|
22
35
|
const { before , getProps } = mockBlock({
|
|
23
|
-
meta,
|
|
36
|
+
meta: Block1.meta,
|
|
24
37
|
logger,
|
|
25
38
|
schema
|
|
26
39
|
});
|
|
@@ -36,13 +49,16 @@ const runMockRenderTests = ({ examples , logger , meta , mocks , reset =()=>null
|
|
|
36
49
|
makeCssClass.mockReset();
|
|
37
50
|
makeCssClass.mockImplementation(makeCssImp);
|
|
38
51
|
});
|
|
39
|
-
const values = meta.values ? [
|
|
40
|
-
type.enforceType(meta.valueType, null),
|
|
41
|
-
...meta.values
|
|
42
|
-
] : [
|
|
43
|
-
type.enforceType(meta.valueType, null)
|
|
44
|
-
];
|
|
45
52
|
examples.forEach((ex)=>{
|
|
53
|
+
const values = [
|
|
54
|
+
type.enforceType(Block1.meta.valueType, null)
|
|
55
|
+
];
|
|
56
|
+
if (!type.isNone(ex.value)) {
|
|
57
|
+
values.push(ex.value);
|
|
58
|
+
}
|
|
59
|
+
if (type.isArray(testConfig.values)) {
|
|
60
|
+
values.push(...testConfig.values);
|
|
61
|
+
}
|
|
46
62
|
values.forEach((value, v)=>{
|
|
47
63
|
mocks.forEach((mock)=>{
|
|
48
64
|
test(`Mock render - ${ex.id} - value[${v}] - ${mock.name}`, async ()=>{
|
|
@@ -50,16 +66,17 @@ const runMockRenderTests = ({ examples , logger , meta , mocks , reset =()=>null
|
|
|
50
66
|
const Block = await mock.getBlock();
|
|
51
67
|
const Shell = ()=>{
|
|
52
68
|
const props = getProps(ex);
|
|
53
|
-
return(/*#__PURE__*/
|
|
54
|
-
...props,
|
|
69
|
+
return(/*#__PURE__*/ React.createElement(Block, _extends({}, props, {
|
|
55
70
|
methods: {
|
|
56
71
|
...props.methods,
|
|
57
72
|
makeCssClass
|
|
58
73
|
},
|
|
59
74
|
value: value
|
|
60
|
-
}));
|
|
75
|
+
})));
|
|
61
76
|
};
|
|
62
|
-
render(/*#__PURE__*/
|
|
77
|
+
const { container } = render(/*#__PURE__*/ React.createElement(Shell, null));
|
|
78
|
+
await waitFor(()=>expect(container.firstChild).toMatchSnapshot()
|
|
79
|
+
);
|
|
63
80
|
mockFns.forEach((mockFn)=>{
|
|
64
81
|
expect(mockFn.mock.calls).toMatchSnapshot();
|
|
65
82
|
});
|
package/dist/runRenderTests.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.
|
|
@@ -17,10 +16,24 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
17
16
|
import { render, waitFor } from '@testing-library/react';
|
|
18
17
|
import { type } from '@lowdefy/helpers';
|
|
19
18
|
import mockBlock from './mockBlock.js';
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
function _extends() {
|
|
20
|
+
_extends = Object.assign || function(target) {
|
|
21
|
+
for(var i = 1; i < arguments.length; i++){
|
|
22
|
+
var source = arguments[i];
|
|
23
|
+
for(var key in source){
|
|
24
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
25
|
+
target[key] = source[key];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return target;
|
|
30
|
+
};
|
|
31
|
+
return _extends.apply(this, arguments);
|
|
32
|
+
}
|
|
33
|
+
const runRenderTests = ({ Block , examples , logger , reset =()=>null
|
|
34
|
+
, schema , testConfig , validationsExamples , })=>{
|
|
22
35
|
const { before , methods , getProps } = mockBlock({
|
|
23
|
-
meta,
|
|
36
|
+
meta: Block.meta,
|
|
24
37
|
logger,
|
|
25
38
|
schema
|
|
26
39
|
});
|
|
@@ -30,55 +43,52 @@ const runRenderTests = ({ Block , examples , logger , meta , reset =()=>null
|
|
|
30
43
|
});
|
|
31
44
|
examples.forEach((ex)=>{
|
|
32
45
|
const values = [
|
|
33
|
-
type.enforceType(meta.valueType, null)
|
|
46
|
+
type.enforceType(Block.meta.valueType, null)
|
|
34
47
|
];
|
|
35
48
|
if (!type.isNone(ex.value)) {
|
|
36
49
|
values.push(ex.value);
|
|
37
50
|
}
|
|
38
|
-
if (type.isArray(
|
|
39
|
-
values.push(...
|
|
51
|
+
if (type.isArray(testConfig.values)) {
|
|
52
|
+
values.push(...testConfig.values);
|
|
40
53
|
}
|
|
41
54
|
values.forEach((value, v)=>{
|
|
42
55
|
test(`Render ${ex.id} - value[${v}]`, async ()=>{
|
|
43
56
|
// create shell to setup react hooks with getProps before render;
|
|
44
|
-
const Shell = ()=>/*#__PURE__*/
|
|
45
|
-
...getProps(ex),
|
|
57
|
+
const Shell = ()=>/*#__PURE__*/ React.createElement(Block, _extends({}, getProps(ex), {
|
|
46
58
|
value: value,
|
|
47
59
|
methods: methods
|
|
48
|
-
})
|
|
60
|
+
}))
|
|
49
61
|
;
|
|
50
|
-
const { container } = render(/*#__PURE__*/
|
|
62
|
+
const { container } = render(/*#__PURE__*/ React.createElement(Shell, null));
|
|
51
63
|
await waitFor(()=>expect(container.firstChild).toMatchSnapshot()
|
|
52
64
|
);
|
|
53
65
|
});
|
|
54
|
-
if (
|
|
66
|
+
if (testConfig && testConfig.validation) {
|
|
55
67
|
(validationsExamples || []).map((validationEx)=>{
|
|
56
68
|
test(`Render validation.status = ${validationEx.status} ${ex.id} - value[${v}]`, async ()=>{
|
|
57
69
|
// create shell to setup react hooks with getProps before render;
|
|
58
|
-
const Shell = ()=>/*#__PURE__*/
|
|
59
|
-
...getProps(ex),
|
|
70
|
+
const Shell = ()=>/*#__PURE__*/ React.createElement(Block, _extends({}, getProps(ex), {
|
|
60
71
|
value: value,
|
|
61
72
|
methods: methods,
|
|
62
73
|
validation: validationEx
|
|
63
|
-
})
|
|
74
|
+
}))
|
|
64
75
|
;
|
|
65
|
-
const { container } = render(/*#__PURE__*/
|
|
76
|
+
const { container } = render(/*#__PURE__*/ React.createElement(Shell, null));
|
|
66
77
|
await waitFor(()=>expect(container.firstChild).toMatchSnapshot()
|
|
67
78
|
);
|
|
68
79
|
});
|
|
69
80
|
});
|
|
70
81
|
}
|
|
71
|
-
if (
|
|
82
|
+
if (testConfig && testConfig.required) {
|
|
72
83
|
test(`Render required = true ${ex.id} - value[${v}]`, async ()=>{
|
|
73
84
|
// create shell to setup react hooks with getProps before render;
|
|
74
|
-
const Shell = ()=>/*#__PURE__*/
|
|
75
|
-
...getProps(ex),
|
|
85
|
+
const Shell = ()=>/*#__PURE__*/ React.createElement(Block, _extends({}, getProps(ex), {
|
|
76
86
|
value: value,
|
|
77
87
|
methods: methods,
|
|
78
88
|
required: true
|
|
79
|
-
})
|
|
89
|
+
}))
|
|
80
90
|
;
|
|
81
|
-
const { container } = render(/*#__PURE__*/
|
|
91
|
+
const { container } = render(/*#__PURE__*/ React.createElement(Shell, null));
|
|
82
92
|
await waitFor(()=>expect(container.firstChild).toMatchSnapshot()
|
|
83
93
|
);
|
|
84
94
|
});
|
package/dist/schemaTest.js
CHANGED
package/dist/stubBlockProps.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.
|
|
@@ -19,27 +18,28 @@ import { makeCssClass, createIcon } from '@lowdefy/block-utils';
|
|
|
19
18
|
import schemaTest from './schemaTest.js';
|
|
20
19
|
const validate = {};
|
|
21
20
|
const Icons = {
|
|
22
|
-
AiIcon: (props)=>/*#__PURE__*/
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
})
|
|
21
|
+
AiIcon: ({ onClick , ...props })=>/*#__PURE__*/ React.createElement("svg", {
|
|
22
|
+
"data-testid": "AiIcon",
|
|
23
|
+
onClick: onClick
|
|
24
|
+
}, "ICON PROPS: ", JSON.stringify(props))
|
|
26
25
|
,
|
|
27
|
-
AiOutlineExclamationCircle: (props)=>/*#__PURE__*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
})
|
|
26
|
+
AiOutlineExclamationCircle: ({ onClick , ...props })=>/*#__PURE__*/ React.createElement("svg", {
|
|
27
|
+
"data-testid": "AiOutlineExclamationCircle",
|
|
28
|
+
onClick: onClick
|
|
29
|
+
}, "ICON PROPS: ", JSON.stringify(props))
|
|
31
30
|
,
|
|
32
|
-
AiOutlineLoading3Quarters: (props)=>/*#__PURE__*/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
})
|
|
31
|
+
AiOutlineLoading3Quarters: ({ onClick , ...props })=>/*#__PURE__*/ React.createElement("svg", {
|
|
32
|
+
"data-testid": "AiOutlineLoading3Quarters",
|
|
33
|
+
onClick: onClick
|
|
34
|
+
}, "ICON PROPS: ", JSON.stringify(props))
|
|
36
35
|
,
|
|
37
36
|
ErrorIcon: ()=>{
|
|
38
37
|
throw new Error('ErrorIcon');
|
|
39
38
|
}
|
|
40
39
|
};
|
|
41
40
|
const IconComponent = createIcon(Icons);
|
|
42
|
-
const stubBlockProps = ({ block , meta , logger
|
|
41
|
+
const stubBlockProps = ({ block , meta , logger =()=>null
|
|
42
|
+
, initialValue , schema })=>{
|
|
43
43
|
const [value, setState] = useState(type.enforceType(meta.valueType, block.value || initialValue));
|
|
44
44
|
const setValue = (val)=>{
|
|
45
45
|
setState(type.enforceType(meta.valueType, val));
|
|
@@ -67,11 +67,10 @@ const stubBlockProps = ({ block , meta , logger , initialValue , schema })=>{
|
|
|
67
67
|
block.eventLog = [];
|
|
68
68
|
block.components = {
|
|
69
69
|
Icon: IconComponent,
|
|
70
|
-
Link: (props)=>/*#__PURE__*/
|
|
71
|
-
"data-testid":
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
})
|
|
70
|
+
Link: ({ id , children , onClick , ...props })=>/*#__PURE__*/ React.createElement("a", {
|
|
71
|
+
"data-testid": id,
|
|
72
|
+
onClick: onClick
|
|
73
|
+
}, "LINK PROPS:", JSON.stringify(props), " - CHILDREN: ", children('default_title'))
|
|
75
74
|
};
|
|
76
75
|
// mock default block methods
|
|
77
76
|
block.methods = {
|
|
@@ -91,13 +90,13 @@ const stubBlockProps = ({ block , meta , logger , initialValue , schema })=>{
|
|
|
91
90
|
block.list = [];
|
|
92
91
|
(block.areas.content.blocks || []).forEach((bl, i)=>{
|
|
93
92
|
block.list.push({
|
|
94
|
-
content: ()=>/*#__PURE__*/
|
|
93
|
+
content: ()=>/*#__PURE__*/ React.createElement("div", {
|
|
95
94
|
"data-testid": `list-${i}-${bl.id}`,
|
|
95
|
+
key: bl.id,
|
|
96
96
|
style: {
|
|
97
97
|
border: '1px solid red',
|
|
98
98
|
padding: 10
|
|
99
|
-
}
|
|
100
|
-
children: bl.id
|
|
99
|
+
}
|
|
101
100
|
}, bl.id)
|
|
102
101
|
});
|
|
103
102
|
});
|
|
@@ -118,13 +117,13 @@ const stubBlockProps = ({ block , meta , logger , initialValue , schema })=>{
|
|
|
118
117
|
if (meta.category === 'container') {
|
|
119
118
|
block.content = {};
|
|
120
119
|
Object.keys(block.areas).forEach((key)=>{
|
|
121
|
-
block.content[key] = ()=>/*#__PURE__*/
|
|
120
|
+
block.content[key] = ()=>/*#__PURE__*/ React.createElement("div", {
|
|
122
121
|
"data-testid": `area-${key}`,
|
|
122
|
+
key: key,
|
|
123
123
|
style: {
|
|
124
124
|
border: '1px solid red',
|
|
125
125
|
padding: 10
|
|
126
|
-
}
|
|
127
|
-
children: key
|
|
126
|
+
}
|
|
128
127
|
}, key)
|
|
129
128
|
;
|
|
130
129
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/block-dev",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.9",
|
|
4
4
|
"licence": "Apache-2.0",
|
|
5
5
|
"description": "Lowdefy Block Development Tools",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -37,26 +37,26 @@
|
|
|
37
37
|
"swc": "swc src --out-dir dist --config-file ../../../.swcrc --delete-dir-on-start"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@emotion/jest": "11.
|
|
41
|
-
"@lowdefy/block-utils": "4.0.0-alpha.
|
|
42
|
-
"@lowdefy/helpers": "4.0.0-alpha.
|
|
43
|
-
"@testing-library/dom": "8.
|
|
40
|
+
"@emotion/jest": "11.7.1",
|
|
41
|
+
"@lowdefy/block-utils": "4.0.0-alpha.9",
|
|
42
|
+
"@lowdefy/helpers": "4.0.0-alpha.9",
|
|
43
|
+
"@testing-library/dom": "8.11.3",
|
|
44
44
|
"@testing-library/react": "13.0.0-alpha.4",
|
|
45
45
|
"@testing-library/user-event": "14.0.0-alpha.14",
|
|
46
|
-
"ajv": "8.
|
|
46
|
+
"ajv": "8.9.0",
|
|
47
47
|
"ajv-errors": "3.0.0",
|
|
48
|
-
"jest": "27.
|
|
48
|
+
"jest": "27.5.1",
|
|
49
49
|
"jest-serializer-html": "7.1.0",
|
|
50
|
-
"react": "
|
|
51
|
-
"react-dom": "
|
|
50
|
+
"react": "17.0.2",
|
|
51
|
+
"react-dom": "17.0.2",
|
|
52
52
|
"yaml-loader": "0.6.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@swc/cli": "0.1.55",
|
|
56
|
-
"@swc/core": "1.2.
|
|
56
|
+
"@swc/core": "1.2.135"
|
|
57
57
|
},
|
|
58
58
|
"publishConfig": {
|
|
59
59
|
"access": "public"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "98b544eca231bdcfca6c3a8601a891835d5ce571"
|
|
62
62
|
}
|