@lowdefy/block-dev 4.0.0-rc.8 → 4.0.0

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-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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.
@@ -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
  });
@@ -48,7 +34,7 @@ const runMockMethodTests = ({ Block , examples , mocks , schema , testConfig })
48
34
  ];
49
35
  examples.forEach((ex)=>{
50
36
  values.forEach((value, v)=>{
51
- if (testConfig && testConfig.methods) {
37
+ if (testConfig?.methods) {
52
38
  testConfig.methods.forEach((method)=>{
53
39
  mocks.forEach((mock)=>{
54
40
  test(`Mock for method: ${JSON.stringify(method)} - ${ex.id} - value[${v}] - ${mock.name}`, async ()=>{
@@ -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)=>{
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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.
@@ -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();
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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.
@@ -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,36 +39,39 @@ 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
- if (testConfig && testConfig.validation) {
64
- (validationsExamples || []).map((validationEx)=>{
50
+ if (testConfig?.validation) {
51
+ (validationsExamples || []).forEach((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
  });
76
64
  }
77
- if (testConfig && testConfig.required) {
65
+ if (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-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 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.8",
3
+ "version": "4.0.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Lowdefy Block Development Tools",
6
6
  "homepage": "https://lowdefy.com",
@@ -30,32 +30,30 @@
30
30
  "files": [
31
31
  "dist/*"
32
32
  ],
33
- "scripts": {
34
- "build": "swc src --out-dir dist --config-file ../../../.swcrc --delete-dir-on-start",
35
- "clean": "rm -rf dist",
36
- "prepublishOnly": "pnpm build"
37
- },
38
33
  "dependencies": {
39
34
  "@emotion/jest": "11.10.5",
40
- "@lowdefy/block-utils": "4.0.0-rc.8",
41
- "@lowdefy/helpers": "4.0.0-rc.8",
35
+ "@lowdefy/block-utils": "4.0.0",
36
+ "@lowdefy/helpers": "4.0.0",
42
37
  "@testing-library/dom": "8.19.1",
43
38
  "@testing-library/react": "13.4.0",
44
39
  "@testing-library/user-event": "14.4.3",
45
40
  "ajv": "8.12.0",
46
41
  "ajv-errors": "3.0.0",
47
- "jest": "28.1.0",
42
+ "jest": "28.1.3",
48
43
  "jest-serializer-html": "7.1.0",
49
44
  "react": "18.2.0",
50
45
  "react-dom": "18.2.0",
51
46
  "yaml-loader": "0.8.0"
52
47
  },
53
48
  "devDependencies": {
54
- "@swc/cli": "0.1.59",
55
- "@swc/core": "1.3.24"
49
+ "@swc/cli": "0.1.63",
50
+ "@swc/core": "1.3.99"
56
51
  },
57
52
  "publishConfig": {
58
53
  "access": "public"
59
54
  },
60
- "gitHead": "db883daef0443647439b6fe2db845b846ffb6d4e"
61
- }
55
+ "scripts": {
56
+ "build": "swc src --out-dir dist --config-file ../../../.swcrc --delete-dir-on-start",
57
+ "clean": "rm -rf dist"
58
+ }
59
+ }