@lowdefy/block-dev 4.0.0-rc.1 → 4.0.0-rc.11

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.
@@ -13,7 +13,7 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import React from 'react';
16
- const BlockSchemaErrors = ({ schemaErrors })=>{
16
+ const BlockSchemaErrors = ({ schemaErrors })=>{
17
17
  if (!schemaErrors || schemaErrors.length === 0) return '';
18
18
  return /*#__PURE__*/ React.createElement("div", {
19
19
  style: {
package/dist/mockBlock.js CHANGED
@@ -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 , schema })=>{
17
+ const mockBlock = ({ meta, schema })=>{
18
18
  const mockMath = Object.create(global.Math);
19
19
  mockMath.random = ()=>0.5;
20
20
  global.Math = mockMath;
@@ -13,7 +13,7 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import schemaTest from './schemaTest.js';
16
- const runBlockSchemaTests = ({ examples , schema })=>{
16
+ const runBlockSchemaTests = ({ examples, schema })=>{
17
17
  const validate = schemaTest(schema);
18
18
  examples.forEach((block)=>{
19
19
  test(`Test Schema ${block.id}`, ()=>{
@@ -12,28 +12,14 @@
12
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
- */ function _extends() {
16
- _extends = Object.assign || function(target) {
17
- for(var i = 1; i < arguments.length; i++){
18
- var source = arguments[i];
19
- for(var key in source){
20
- if (Object.prototype.hasOwnProperty.call(source, key)) {
21
- target[key] = source[key];
22
- }
23
- }
24
- }
25
- return target;
26
- };
27
- return _extends.apply(this, arguments);
28
- }
29
- import React from 'react';
15
+ */ import React from 'react';
30
16
  import { type } from '@lowdefy/helpers';
31
17
  import { render, screen } from '@testing-library/react';
32
18
  import userEvent from '@testing-library/user-event';
33
19
  import mockBlock from './mockBlock.js';
34
- const runMockMethodTests = ({ Block , examples , mocks , schema , testConfig })=>{
20
+ const runMockMethodTests = ({ Block, examples, mocks, schema, testConfig })=>{
35
21
  const meta = Block.meta;
36
- const { before , methods , getProps } = mockBlock({
22
+ const { before, methods, getProps } = mockBlock({
37
23
  meta,
38
24
  schema
39
25
  });
@@ -60,9 +46,10 @@ const runMockMethodTests = ({ Block , examples , mocks , schema , testConfig })
60
46
  ...methods,
61
47
  registerMethod: props.methods.registerMethod
62
48
  };
63
- return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(Block, _extends({}, props, {
49
+ return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(Block, {
50
+ ...props,
64
51
  value: value
65
- })), /*#__PURE__*/ React.createElement("button", {
52
+ }), /*#__PURE__*/ React.createElement("button", {
66
53
  id: `${ex.id}_button`,
67
54
  onClick: ()=>{
68
55
  props.methods[method.name](method.args);
@@ -70,7 +57,7 @@ const runMockMethodTests = ({ Block , examples , mocks , schema , testConfig })
70
57
  "data-testid": "btn_method"
71
58
  }));
72
59
  };
73
- const { container } = render(/*#__PURE__*/ React.createElement(Shell, null));
60
+ const { container } = render(/*#__PURE__*/ React.createElement(Shell, null));
74
61
  expect(container.firstChild).toMatchSnapshot();
75
62
  userEvent.click(screen.getByTestId('btn_method'));
76
63
  mockFns.forEach((mockFn)=>{
@@ -12,26 +12,12 @@
12
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
- */ function _extends() {
16
- _extends = Object.assign || function(target) {
17
- for(var i = 1; i < arguments.length; i++){
18
- var source = arguments[i];
19
- for(var key in source){
20
- if (Object.prototype.hasOwnProperty.call(source, key)) {
21
- target[key] = source[key];
22
- }
23
- }
24
- }
25
- return target;
26
- };
27
- return _extends.apply(this, arguments);
28
- }
29
- import React from 'react';
15
+ */ import React from 'react';
30
16
  import { type } from '@lowdefy/helpers';
31
17
  import { render, waitFor } from '@testing-library/react';
32
18
  import mockBlock from './mockBlock.js';
33
- const runMockRenderTests = ({ Block , examples , logger , mocks , reset =()=>null , schema , testConfig })=>{
34
- const { before , getProps } = mockBlock({
19
+ const runMockRenderTests = ({ Block, examples, logger, mocks, reset = ()=>null, schema, testConfig })=>{
20
+ const { before, getProps } = mockBlock({
35
21
  meta: Block.meta,
36
22
  logger,
37
23
  schema
@@ -64,15 +50,16 @@ const runMockRenderTests = ({ Block , examples , logger , mocks , reset =()=>nul
64
50
  const Block = await mock.getBlock();
65
51
  const Shell = ()=>{
66
52
  const props = getProps(ex);
67
- return /*#__PURE__*/ React.createElement(Block, _extends({}, props, {
53
+ return /*#__PURE__*/ React.createElement(Block, {
54
+ ...props,
68
55
  methods: {
69
56
  ...props.methods,
70
57
  makeCssClass
71
58
  },
72
59
  value: value
73
- }));
60
+ });
74
61
  };
75
- const { container } = render(/*#__PURE__*/ React.createElement(Shell, null));
62
+ const { container } = render(/*#__PURE__*/ React.createElement(Shell, null));
76
63
  await waitFor(()=>expect(container.firstChild).toMatchSnapshot());
77
64
  mockFns.forEach((mockFn)=>{
78
65
  expect(mockFn.mock.calls).toMatchSnapshot();
@@ -12,26 +12,12 @@
12
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
- */ function _extends() {
16
- _extends = Object.assign || function(target) {
17
- for(var i = 1; i < arguments.length; i++){
18
- var source = arguments[i];
19
- for(var key in source){
20
- if (Object.prototype.hasOwnProperty.call(source, key)) {
21
- target[key] = source[key];
22
- }
23
- }
24
- }
25
- return target;
26
- };
27
- return _extends.apply(this, arguments);
28
- }
29
- import React from 'react';
15
+ */ import React from 'react';
30
16
  import { render, waitFor } from '@testing-library/react';
31
17
  import { type } from '@lowdefy/helpers';
32
18
  import mockBlock from './mockBlock.js';
33
- const runRenderTests = ({ Block , examples , logger , reset =()=>null , schema , testConfig , validationsExamples })=>{
34
- const { before , methods , getProps } = mockBlock({
19
+ const runRenderTests = ({ Block, examples, logger, reset = ()=>null, schema, testConfig, validationsExamples })=>{
20
+ const { before, methods, getProps } = mockBlock({
35
21
  meta: Block.meta,
36
22
  logger,
37
23
  schema
@@ -53,23 +39,25 @@ const runRenderTests = ({ Block , examples , logger , reset =()=>null , schema ,
53
39
  values.forEach((value, v)=>{
54
40
  test(`Render ${ex.id} - value[${v}]`, async ()=>{
55
41
  // create shell to setup react hooks with getProps before render;
56
- const Shell = ()=>/*#__PURE__*/ React.createElement(Block, _extends({}, getProps(ex), {
42
+ const Shell = ()=>/*#__PURE__*/ React.createElement(Block, {
43
+ ...getProps(ex),
57
44
  value: value,
58
45
  methods: methods
59
- }));
60
- const { container } = render(/*#__PURE__*/ React.createElement(Shell, null));
46
+ });
47
+ const { container } = render(/*#__PURE__*/ React.createElement(Shell, null));
61
48
  await waitFor(()=>expect(container.firstChild).toMatchSnapshot());
62
49
  });
63
50
  if (testConfig && testConfig.validation) {
64
51
  (validationsExamples || []).map((validationEx)=>{
65
52
  test(`Render validation.status = ${validationEx.status} ${ex.id} - value[${v}]`, async ()=>{
66
53
  // create shell to setup react hooks with getProps before render;
67
- const Shell = ()=>/*#__PURE__*/ React.createElement(Block, _extends({}, getProps(ex), {
54
+ const Shell = ()=>/*#__PURE__*/ React.createElement(Block, {
55
+ ...getProps(ex),
68
56
  value: value,
69
57
  methods: methods,
70
58
  validation: validationEx
71
- }));
72
- const { container } = render(/*#__PURE__*/ React.createElement(Shell, null));
59
+ });
60
+ const { container } = render(/*#__PURE__*/ React.createElement(Shell, null));
73
61
  await waitFor(()=>expect(container.firstChild).toMatchSnapshot());
74
62
  });
75
63
  });
@@ -77,12 +65,13 @@ const runRenderTests = ({ Block , examples , logger , reset =()=>null , schema ,
77
65
  if (testConfig && testConfig.required) {
78
66
  test(`Render required = true ${ex.id} - value[${v}]`, async ()=>{
79
67
  // create shell to setup react hooks with getProps before render;
80
- const Shell = ()=>/*#__PURE__*/ React.createElement(Block, _extends({}, getProps(ex), {
68
+ const Shell = ()=>/*#__PURE__*/ React.createElement(Block, {
69
+ ...getProps(ex),
81
70
  value: value,
82
71
  methods: methods,
83
72
  required: true
84
- }));
85
- const { container } = render(/*#__PURE__*/ React.createElement(Shell, null));
73
+ });
74
+ const { container } = render(/*#__PURE__*/ React.createElement(Shell, null));
86
75
  await waitFor(()=>expect(container.firstChild).toMatchSnapshot());
87
76
  });
88
77
  }
@@ -18,15 +18,15 @@ import { makeCssClass, createIcon } from '@lowdefy/block-utils';
18
18
  import schemaTest from './schemaTest.js';
19
19
  const validate = {};
20
20
  const Icons = {
21
- AiIcon: ({ onClick , ...props })=>/*#__PURE__*/ React.createElement("svg", {
21
+ AiIcon: ({ onClick, ...props })=>/*#__PURE__*/ React.createElement("svg", {
22
22
  "data-testid": "AiIcon",
23
23
  onClick: onClick
24
24
  }, "ICON PROPS: ", JSON.stringify(props)),
25
- AiOutlineExclamationCircle: ({ onClick , ...props })=>/*#__PURE__*/ React.createElement("svg", {
25
+ AiOutlineExclamationCircle: ({ onClick, ...props })=>/*#__PURE__*/ React.createElement("svg", {
26
26
  "data-testid": "AiOutlineExclamationCircle",
27
27
  onClick: onClick
28
28
  }, "ICON PROPS: ", JSON.stringify(props)),
29
- AiOutlineLoading3Quarters: ({ onClick , ...props })=>/*#__PURE__*/ React.createElement("svg", {
29
+ AiOutlineLoading3Quarters: ({ onClick, ...props })=>/*#__PURE__*/ React.createElement("svg", {
30
30
  "data-testid": "AiOutlineLoading3Quarters",
31
31
  onClick: onClick
32
32
  }, "ICON PROPS: ", JSON.stringify(props)),
@@ -35,7 +35,7 @@ const Icons = {
35
35
  }
36
36
  };
37
37
  const IconComponent = createIcon(Icons);
38
- const stubBlockProps = ({ block , meta , logger =()=>null , initialValue , schema })=>{
38
+ const stubBlockProps = ({ block, meta, logger = ()=>null, initialValue, schema })=>{
39
39
  const [value, setState] = useState(type.enforceType(meta.valueType, block.value || initialValue));
40
40
  const setValue = (val)=>{
41
41
  setState(type.enforceType(meta.valueType, val));
@@ -63,7 +63,7 @@ const stubBlockProps = ({ block , meta , logger =()=>null , initialValue , schem
63
63
  block.eventLog = [];
64
64
  block.components = {
65
65
  Icon: IconComponent,
66
- Link: ({ id , children , onClick , ...props })=>/*#__PURE__*/ React.createElement("a", {
66
+ Link: ({ id, children, onClick, ...props })=>/*#__PURE__*/ React.createElement("a", {
67
67
  "data-testid": id,
68
68
  onClick: onClick
69
69
  }, "LINK PROPS:", JSON.stringify(props), " - CHILDREN: ", children('default_title'))
@@ -71,7 +71,7 @@ const stubBlockProps = ({ block , meta , logger =()=>null , initialValue , schem
71
71
  // mock default block methods
72
72
  block.methods = {
73
73
  makeCssClass,
74
- registerEvent: ({ name , actions })=>{
74
+ registerEvent: ({ name, actions })=>{
75
75
  block.events[name] = actions;
76
76
  return;
77
77
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/block-dev",
3
- "version": "4.0.0-rc.1",
3
+ "version": "4.0.0-rc.11",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Lowdefy Block Development Tools",
6
6
  "homepage": "https://lowdefy.com",
@@ -37,25 +37,25 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@emotion/jest": "11.10.5",
40
- "@lowdefy/block-utils": "4.0.0-rc.1",
41
- "@lowdefy/helpers": "4.0.0-rc.1",
40
+ "@lowdefy/block-utils": "4.0.0-rc.11",
41
+ "@lowdefy/helpers": "4.0.0-rc.11",
42
42
  "@testing-library/dom": "8.19.1",
43
43
  "@testing-library/react": "13.4.0",
44
44
  "@testing-library/user-event": "14.4.3",
45
45
  "ajv": "8.12.0",
46
46
  "ajv-errors": "3.0.0",
47
- "jest": "28.1.0",
47
+ "jest": "28.1.3",
48
48
  "jest-serializer-html": "7.1.0",
49
49
  "react": "18.2.0",
50
50
  "react-dom": "18.2.0",
51
51
  "yaml-loader": "0.8.0"
52
52
  },
53
53
  "devDependencies": {
54
- "@swc/cli": "0.1.59",
55
- "@swc/core": "1.3.24"
54
+ "@swc/cli": "0.1.62",
55
+ "@swc/core": "1.3.92"
56
56
  },
57
57
  "publishConfig": {
58
58
  "access": "public"
59
59
  },
60
- "gitHead": "ecc4f16c19eede929eda177db524cf13a8053379"
60
+ "gitHead": "dbc49d3688a6d2f44de25cc3f4bc071627f7ebfa"
61
61
  }