@lowdefy/block-dev 4.0.0-alpha.8 → 4.0.0-rc.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-2021 Lowdefy, Inc
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.
@@ -15,7 +15,7 @@
15
15
  */ import React from 'react';
16
16
  const BlockSchemaErrors = ({ schemaErrors })=>{
17
17
  if (!schemaErrors || schemaErrors.length === 0) return '';
18
- return(/*#__PURE__*/ React.createElement("div", {
18
+ return /*#__PURE__*/ React.createElement("div", {
19
19
  style: {
20
20
  padding: 10,
21
21
  fontSize: '0.8rem',
@@ -25,7 +25,6 @@ const BlockSchemaErrors = ({ schemaErrors })=>{
25
25
  }
26
26
  }, /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("b", null, "Schema Errors")), schemaErrors.map((error, i)=>/*#__PURE__*/ React.createElement("div", {
27
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
- )));
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))));
30
29
  };
31
30
  export default BlockSchemaErrors;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2021 Lowdefy, Inc
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.
package/dist/mockBlock.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2021 Lowdefy, Inc
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,9 @@
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 , logger , schema })=>{
17
+ const mockBlock = ({ meta , schema })=>{
18
18
  const mockMath = Object.create(global.Math);
19
- mockMath.random = ()=>0.5
20
- ;
19
+ mockMath.random = ()=>0.5;
21
20
  global.Math = mockMath;
22
21
  const moveItemDown = jest.fn();
23
22
  const moveItemUp = jest.fn();
@@ -65,8 +64,7 @@ const mockBlock = ({ meta , logger , schema })=>{
65
64
  addEventListener: jest.fn(),
66
65
  removeEventListener: jest.fn(),
67
66
  dispatchEvent: jest.fn()
68
- })
69
- )
67
+ }))
70
68
  });
71
69
  }
72
70
  if (typeof window !== 'undefined') {
@@ -87,7 +85,6 @@ const mockBlock = ({ meta , logger , schema })=>{
87
85
  return stubBlockProps({
88
86
  block,
89
87
  meta,
90
- logger,
91
88
  schema
92
89
  });
93
90
  };
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2021 Lowdefy, Inc
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.
@@ -1,5 +1,19 @@
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
+ }
1
15
  /*
2
- Copyright 2020-2021 Lowdefy, Inc
16
+ Copyright 2020-2022 Lowdefy, Inc
3
17
 
4
18
  Licensed under the Apache License, Version 2.0 (the "License");
5
19
  you may not use this file except in compliance with the License.
@@ -17,24 +31,10 @@ import { type } from '@lowdefy/helpers';
17
31
  import { render, screen } from '@testing-library/react';
18
32
  import userEvent from '@testing-library/user-event';
19
33
  import mockBlock from './mockBlock.js';
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 = ({ examples , logger , meta , mocks , schema , tests })=>{
34
+ const runMockMethodTests = ({ Block: Block1 , examples , mocks , schema , testConfig })=>{
35
+ const meta = Block1.meta;
35
36
  const { before , methods , getProps } = mockBlock({
36
37
  meta,
37
- logger,
38
38
  schema
39
39
  });
40
40
  beforeEach(()=>{
@@ -48,8 +48,8 @@ const runMockMethodTests = ({ examples , logger , meta , mocks , schema , tests
48
48
  ];
49
49
  examples.forEach((ex)=>{
50
50
  values.forEach((value, v)=>{
51
- if (tests && tests.methods) {
52
- tests.methods.forEach((method)=>{
51
+ if (testConfig && testConfig.methods) {
52
+ testConfig.methods.forEach((method)=>{
53
53
  mocks.forEach((mock)=>{
54
54
  test(`Mock for method: ${JSON.stringify(method)} - ${ex.id} - value[${v}] - ${mock.name}`, async ()=>{
55
55
  const mockFns = await mock.getMockFns();
@@ -60,7 +60,7 @@ const runMockMethodTests = ({ examples , logger , meta , mocks , schema , tests
60
60
  ...methods,
61
61
  registerMethod: props.methods.registerMethod
62
62
  };
63
- return(/*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(Block, _extends({}, props, {
63
+ return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(Block, _extends({}, props, {
64
64
  value: value
65
65
  })), /*#__PURE__*/ React.createElement("button", {
66
66
  id: `${ex.id}_button`,
@@ -68,7 +68,7 @@ const runMockMethodTests = ({ examples , logger , meta , mocks , schema , tests
68
68
  props.methods[method.name](method.args);
69
69
  },
70
70
  "data-testid": "btn_method"
71
- })));
71
+ }));
72
72
  };
73
73
  const { container } = render(/*#__PURE__*/ React.createElement(Shell, null));
74
74
  expect(container.firstChild).toMatchSnapshot();
@@ -1,5 +1,19 @@
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
+ }
1
15
  /*
2
- Copyright 2020-2021 Lowdefy, Inc
16
+ Copyright 2020-2022 Lowdefy, Inc
3
17
 
4
18
  Licensed under the Apache License, Version 2.0 (the "License");
5
19
  you may not use this file except in compliance with the License.
@@ -16,22 +30,7 @@
16
30
  import { type } from '@lowdefy/helpers';
17
31
  import { render, waitFor } from '@testing-library/react';
18
32
  import mockBlock from './mockBlock.js';
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 , })=>{
33
+ const runMockRenderTests = ({ Block: Block1 , examples , logger , mocks , reset =()=>null , schema , testConfig , })=>{
35
34
  const { before , getProps } = mockBlock({
36
35
  meta: Block1.meta,
37
36
  logger,
@@ -41,8 +40,7 @@ const runMockRenderTests = ({ Block: Block1 , examples , logger , mocks , reset
41
40
  const makeCssImp = (style, op)=>JSON.stringify({
42
41
  style,
43
42
  options: op
44
- })
45
- ;
43
+ });
46
44
  beforeEach(async ()=>{
47
45
  await reset();
48
46
  before();
@@ -66,17 +64,16 @@ const runMockRenderTests = ({ Block: Block1 , examples , logger , mocks , reset
66
64
  const Block = await mock.getBlock();
67
65
  const Shell = ()=>{
68
66
  const props = getProps(ex);
69
- return(/*#__PURE__*/ React.createElement(Block, _extends({}, props, {
67
+ return /*#__PURE__*/ React.createElement(Block, _extends({}, props, {
70
68
  methods: {
71
69
  ...props.methods,
72
70
  makeCssClass
73
71
  },
74
72
  value: value
75
- })));
73
+ }));
76
74
  };
77
75
  const { container } = render(/*#__PURE__*/ React.createElement(Shell, null));
78
- await waitFor(()=>expect(container.firstChild).toMatchSnapshot()
79
- );
76
+ await waitFor(()=>expect(container.firstChild).toMatchSnapshot());
80
77
  mockFns.forEach((mockFn)=>{
81
78
  expect(mockFn.mock.calls).toMatchSnapshot();
82
79
  });
@@ -1,5 +1,19 @@
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
+ }
1
15
  /*
2
- Copyright 2020-2021 Lowdefy, Inc
16
+ Copyright 2020-2022 Lowdefy, Inc
3
17
 
4
18
  Licensed under the Apache License, Version 2.0 (the "License");
5
19
  you may not use this file except in compliance with the License.
@@ -16,22 +30,7 @@
16
30
  import { render, waitFor } from '@testing-library/react';
17
31
  import { type } from '@lowdefy/helpers';
18
32
  import mockBlock from './mockBlock.js';
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 , })=>{
33
+ const runRenderTests = ({ Block , examples , logger , reset =()=>null , schema , testConfig , validationsExamples , })=>{
35
34
  const { before , methods , getProps } = mockBlock({
36
35
  meta: Block.meta,
37
36
  logger,
@@ -57,11 +56,9 @@ const runRenderTests = ({ Block , examples , logger , reset =()=>null
57
56
  const Shell = ()=>/*#__PURE__*/ React.createElement(Block, _extends({}, getProps(ex), {
58
57
  value: value,
59
58
  methods: methods
60
- }))
61
- ;
59
+ }));
62
60
  const { container } = render(/*#__PURE__*/ React.createElement(Shell, null));
63
- await waitFor(()=>expect(container.firstChild).toMatchSnapshot()
64
- );
61
+ await waitFor(()=>expect(container.firstChild).toMatchSnapshot());
65
62
  });
66
63
  if (testConfig && testConfig.validation) {
67
64
  (validationsExamples || []).map((validationEx)=>{
@@ -71,11 +68,9 @@ const runRenderTests = ({ Block , examples , logger , reset =()=>null
71
68
  value: value,
72
69
  methods: methods,
73
70
  validation: validationEx
74
- }))
75
- ;
71
+ }));
76
72
  const { container } = render(/*#__PURE__*/ React.createElement(Shell, null));
77
- await waitFor(()=>expect(container.firstChild).toMatchSnapshot()
78
- );
73
+ await waitFor(()=>expect(container.firstChild).toMatchSnapshot());
79
74
  });
80
75
  });
81
76
  }
@@ -86,11 +81,9 @@ const runRenderTests = ({ Block , examples , logger , reset =()=>null
86
81
  value: value,
87
82
  methods: methods,
88
83
  required: true
89
- }))
90
- ;
84
+ }));
91
85
  const { container } = render(/*#__PURE__*/ React.createElement(Shell, null));
92
- await waitFor(()=>expect(container.firstChild).toMatchSnapshot()
93
- );
86
+ await waitFor(()=>expect(container.firstChild).toMatchSnapshot());
94
87
  });
95
88
  }
96
89
  });
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2021 Lowdefy, Inc
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.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2021 Lowdefy, Inc
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,40 +16,26 @@
16
16
  import { type } from '@lowdefy/helpers';
17
17
  import { makeCssClass, createIcon } from '@lowdefy/block-utils';
18
18
  import schemaTest from './schemaTest.js';
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
19
  const validate = {};
34
20
  const Icons = {
35
- AiIcon: (props)=>/*#__PURE__*/ React.createElement("svg", _extends({}, props, {
36
- "data-testid": "AiIcon"
37
- }))
38
- ,
39
- AiOutlineExclamationCircle: (props)=>/*#__PURE__*/ React.createElement("svg", _extends({}, props, {
40
- "data-testid": "AiOutlineExclamationCircle"
41
- }))
42
- ,
43
- AiOutlineLoading3Quarters: (props)=>/*#__PURE__*/ React.createElement("svg", _extends({}, props, {
44
- "data-testid": "AiOutlineLoading3Quarters"
45
- }))
46
- ,
21
+ AiIcon: ({ onClick , ...props })=>/*#__PURE__*/ React.createElement("svg", {
22
+ "data-testid": "AiIcon",
23
+ onClick: onClick
24
+ }, "ICON PROPS: ", JSON.stringify(props)),
25
+ AiOutlineExclamationCircle: ({ onClick , ...props })=>/*#__PURE__*/ React.createElement("svg", {
26
+ "data-testid": "AiOutlineExclamationCircle",
27
+ onClick: onClick
28
+ }, "ICON PROPS: ", JSON.stringify(props)),
29
+ AiOutlineLoading3Quarters: ({ onClick , ...props })=>/*#__PURE__*/ React.createElement("svg", {
30
+ "data-testid": "AiOutlineLoading3Quarters",
31
+ onClick: onClick
32
+ }, "ICON PROPS: ", JSON.stringify(props)),
47
33
  ErrorIcon: ()=>{
48
34
  throw new Error('ErrorIcon');
49
35
  }
50
36
  };
51
37
  const IconComponent = createIcon(Icons);
52
- const stubBlockProps = ({ block , meta , logger , initialValue , schema })=>{
38
+ const stubBlockProps = ({ block , meta , logger =()=>null , initialValue , schema })=>{
53
39
  const [value, setState] = useState(type.enforceType(meta.valueType, block.value || initialValue));
54
40
  const setValue = (val)=>{
55
41
  setState(type.enforceType(meta.valueType, val));
@@ -77,9 +63,10 @@ const stubBlockProps = ({ block , meta , logger , initialValue , schema })=>{
77
63
  block.eventLog = [];
78
64
  block.components = {
79
65
  Icon: IconComponent,
80
- Link: (props)=>/*#__PURE__*/ React.createElement("a", _extends({
81
- "data-testid": `link-${props.href}`
82
- }, props), props.children)
66
+ Link: ({ id , children , onClick , ...props })=>/*#__PURE__*/ React.createElement("a", {
67
+ "data-testid": id,
68
+ onClick: onClick
69
+ }, "LINK PROPS:", JSON.stringify(props), " - CHILDREN: ", children('default_title'))
83
70
  };
84
71
  // mock default block methods
85
72
  block.methods = {
@@ -110,16 +97,11 @@ const stubBlockProps = ({ block , meta , logger , initialValue , schema })=>{
110
97
  });
111
98
  });
112
99
  block.methods = {
113
- pushItem: ()=>log('List pushItem')
114
- ,
115
- unshiftItem: ()=>log('List unshiftItem')
116
- ,
117
- removeItem: (i)=>log(`List removeItem ${i}`)
118
- ,
119
- moveItemDown: (i)=>log(`List moveItemDown ${i}`)
120
- ,
121
- moveItemUp: (i)=>log(`List moveItemUp ${i}`)
122
- ,
100
+ pushItem: ()=>log('List pushItem'),
101
+ unshiftItem: ()=>log('List unshiftItem'),
102
+ removeItem: (i)=>log(`List removeItem ${i}`),
103
+ moveItemDown: (i)=>log(`List moveItemDown ${i}`),
104
+ moveItemUp: (i)=>log(`List moveItemUp ${i}`),
123
105
  ...block.methods
124
106
  };
125
107
  }
@@ -133,8 +115,7 @@ const stubBlockProps = ({ block , meta , logger , initialValue , schema })=>{
133
115
  border: '1px solid red',
134
116
  padding: 10
135
117
  }
136
- }, key)
137
- ;
118
+ }, key);
138
119
  });
139
120
  }
140
121
  if (meta.category === 'input') {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lowdefy/block-dev",
3
- "version": "4.0.0-alpha.8",
4
- "licence": "Apache-2.0",
3
+ "version": "4.0.0-rc.0",
4
+ "license": "Apache-2.0",
5
5
  "description": "Lowdefy Block Development Tools",
6
6
  "homepage": "https://lowdefy.com",
7
7
  "keywords": [
@@ -31,32 +31,31 @@
31
31
  "dist/*"
32
32
  ],
33
33
  "scripts": {
34
- "build": "yarn swc",
34
+ "build": "swc src --out-dir dist --config-file ../../../.swcrc --delete-dir-on-start",
35
35
  "clean": "rm -rf dist",
36
- "prepare": "yarn build",
37
- "swc": "swc src --out-dir dist --config-file ../../../.swcrc --delete-dir-on-start"
36
+ "prepublishOnly": "pnpm build"
38
37
  },
39
38
  "dependencies": {
40
- "@emotion/jest": "11.7.1",
41
- "@lowdefy/block-utils": "4.0.0-alpha.8",
42
- "@lowdefy/helpers": "4.0.0-alpha.8",
43
- "@testing-library/dom": "8.11.3",
44
- "@testing-library/react": "13.0.0-alpha.4",
45
- "@testing-library/user-event": "14.0.0-alpha.14",
46
- "ajv": "8.9.0",
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",
47
46
  "ajv-errors": "3.0.0",
48
- "jest": "27.5.1",
47
+ "jest": "28.1.0",
49
48
  "jest-serializer-html": "7.1.0",
50
- "react": "17.0.2",
51
- "react-dom": "17.0.2",
52
- "yaml-loader": "0.6.0"
49
+ "react": "18.2.0",
50
+ "react-dom": "18.2.0",
51
+ "yaml-loader": "0.8.0"
53
52
  },
54
53
  "devDependencies": {
55
- "@swc/cli": "0.1.55",
56
- "@swc/core": "1.2.135"
54
+ "@swc/cli": "0.1.57",
55
+ "@swc/core": "1.2.194"
57
56
  },
58
57
  "publishConfig": {
59
58
  "access": "public"
60
59
  },
61
- "gitHead": "9d56b83cf45e868afe3a1eeba750fe826eb74c8c"
60
+ "gitHead": "f6872d7ff6da421710096536fce7b2016ef8f35c"
62
61
  }