@lowdefy/block-dev 4.0.0-rc.0 → 4.0.0-rc.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.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2022 Lowdefy, Inc
2
+ Copyright 2020-2023 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.
@@ -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/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2022 Lowdefy, Inc
2
+ Copyright 2020-2023 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/dist/mockBlock.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2022 Lowdefy, Inc
2
+ Copyright 2020-2023 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 , 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;
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2022 Lowdefy, Inc
2
+ Copyright 2020-2023 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.
@@ -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}`, ()=>{
@@ -1,19 +1,5 @@
1
- function _extends() {
2
- _extends = Object.assign || function(target) {
3
- for(var i = 1; i < arguments.length; i++){
4
- var source = arguments[i];
5
- for(var key in source){
6
- if (Object.prototype.hasOwnProperty.call(source, key)) {
7
- target[key] = source[key];
8
- }
9
- }
10
- }
11
- return target;
12
- };
13
- return _extends.apply(this, arguments);
14
- }
15
1
  /*
16
- Copyright 2020-2022 Lowdefy, Inc
2
+ Copyright 2020-2023 Lowdefy, Inc
17
3
 
18
4
  Licensed under the Apache License, Version 2.0 (the "License");
19
5
  you may not use this file except in compliance with the License.
@@ -31,9 +17,9 @@ 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: Block1 , examples , mocks , schema , testConfig })=>{
35
- const meta = Block1.meta;
36
- const { before , methods , getProps } = mockBlock({
20
+ const runMockMethodTests = ({ Block, examples, mocks, schema, testConfig })=>{
21
+ const meta = Block.meta;
22
+ const { before, methods, getProps } = mockBlock({
37
23
  meta,
38
24
  schema
39
25
  });
@@ -60,9 +46,10 @@ const runMockMethodTests = ({ Block: Block1 , examples , mocks , schema , testCo
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: Block1 , examples , mocks , schema , testCo
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)=>{
@@ -1,19 +1,5 @@
1
- function _extends() {
2
- _extends = Object.assign || function(target) {
3
- for(var i = 1; i < arguments.length; i++){
4
- var source = arguments[i];
5
- for(var key in source){
6
- if (Object.prototype.hasOwnProperty.call(source, key)) {
7
- target[key] = source[key];
8
- }
9
- }
10
- }
11
- return target;
12
- };
13
- return _extends.apply(this, arguments);
14
- }
15
1
  /*
16
- Copyright 2020-2022 Lowdefy, Inc
2
+ Copyright 2020-2023 Lowdefy, Inc
17
3
 
18
4
  Licensed under the Apache License, Version 2.0 (the "License");
19
5
  you may not use this file except in compliance with the License.
@@ -30,9 +16,9 @@ function _extends() {
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: Block1 , examples , logger , mocks , reset =()=>null , schema , testConfig , })=>{
34
- const { before , getProps } = mockBlock({
35
- meta: Block1.meta,
19
+ const runMockRenderTests = ({ Block, examples, logger, mocks, reset = ()=>null, schema, testConfig })=>{
20
+ const { before, getProps } = mockBlock({
21
+ meta: Block.meta,
36
22
  logger,
37
23
  schema
38
24
  });
@@ -49,7 +35,7 @@ const runMockRenderTests = ({ Block: Block1 , examples , logger , mocks , reset
49
35
  });
50
36
  examples.forEach((ex)=>{
51
37
  const values = [
52
- type.enforceType(Block1.meta.valueType, null)
38
+ type.enforceType(Block.meta.valueType, null)
53
39
  ];
54
40
  if (!type.isNone(ex.value)) {
55
41
  values.push(ex.value);
@@ -64,15 +50,16 @@ const runMockRenderTests = ({ Block: Block1 , examples , logger , mocks , reset
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();
@@ -1,19 +1,5 @@
1
- function _extends() {
2
- _extends = Object.assign || function(target) {
3
- for(var i = 1; i < arguments.length; i++){
4
- var source = arguments[i];
5
- for(var key in source){
6
- if (Object.prototype.hasOwnProperty.call(source, key)) {
7
- target[key] = source[key];
8
- }
9
- }
10
- }
11
- return target;
12
- };
13
- return _extends.apply(this, arguments);
14
- }
15
1
  /*
16
- Copyright 2020-2022 Lowdefy, Inc
2
+ Copyright 2020-2023 Lowdefy, Inc
17
3
 
18
4
  Licensed under the Apache License, Version 2.0 (the "License");
19
5
  you may not use this file except in compliance with the License.
@@ -30,8 +16,8 @@ function _extends() {
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
  }
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2022 Lowdefy, Inc
2
+ Copyright 2020-2023 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-2022 Lowdefy, Inc
2
+ Copyright 2020-2023 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.
@@ -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.0",
3
+ "version": "4.0.0-rc.10",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Lowdefy Block Development Tools",
6
6
  "homepage": "https://lowdefy.com",
@@ -36,26 +36,26 @@
36
36
  "prepublishOnly": "pnpm build"
37
37
  },
38
38
  "dependencies": {
39
- "@emotion/jest": "11.9.1",
40
- "@lowdefy/block-utils": "4.0.0-rc.0",
41
- "@lowdefy/helpers": "4.0.0-rc.0",
42
- "@testing-library/dom": "8.13.0",
43
- "@testing-library/react": "13.3.0",
44
- "@testing-library/user-event": "14.2.0",
45
- "ajv": "8.11.0",
39
+ "@emotion/jest": "11.10.5",
40
+ "@lowdefy/block-utils": "4.0.0-rc.10",
41
+ "@lowdefy/helpers": "4.0.0-rc.10",
42
+ "@testing-library/dom": "8.19.1",
43
+ "@testing-library/react": "13.4.0",
44
+ "@testing-library/user-event": "14.4.3",
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.57",
55
- "@swc/core": "1.2.194"
54
+ "@swc/cli": "0.1.62",
55
+ "@swc/core": "1.3.70"
56
56
  },
57
57
  "publishConfig": {
58
58
  "access": "public"
59
59
  },
60
- "gitHead": "f6872d7ff6da421710096536fce7b2016ef8f35c"
60
+ "gitHead": "537af074f27770e32da9da8d48490f2eda94b406"
61
61
  }