@lowdefy/blocks-basic 4.0.0-alpha.5 → 4.0.0-alpha.8

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,4 +1,3 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
1
  /*
3
2
  Copyright 2020-2021 Lowdefy, Inc
4
3
 
@@ -14,34 +13,27 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
14
13
  See the License for the specific language governing permissions and
15
14
  limitations under the License.
16
15
  */ import React from 'react';
17
- import { get, type } from '@lowdefy/helpers';
16
+ import { get } from '@lowdefy/helpers';
18
17
  import { blockDefaultProps } from '@lowdefy/block-utils';
19
- const Strong = ({ children , strong })=>strong ? /*#__PURE__*/ _jsx("b", {
20
- children: children
21
- }) : /*#__PURE__*/ _jsx(_Fragment, {
22
- children: children
23
- })
24
- ;
25
- const Tag = ({ blockId , children , className , disabled , href , Link , newTab , onClick , rel })=>disabled ? /*#__PURE__*/ _jsx("span", {
26
- id: blockId,
27
- className: className,
28
- children: children
29
- }) : /*#__PURE__*/ _jsx(Link, {
30
- id: blockId,
31
- className: className,
32
- href: href,
33
- onClick: onClick,
34
- rel: rel || 'noopener noreferrer',
35
- target: newTab ? '_blank' : '_self',
36
- children: children
37
- })
38
- ;
18
+ function _extends() {
19
+ _extends = Object.assign || function(target) {
20
+ for(var i = 1; i < arguments.length; i++){
21
+ var source = arguments[i];
22
+ for(var key in source){
23
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
24
+ target[key] = source[key];
25
+ }
26
+ }
27
+ }
28
+ return target;
29
+ };
30
+ return _extends.apply(this, arguments);
31
+ }
39
32
  const AnchorBlock = ({ blockId , events , components: { Icon , Link } , loading , methods , properties , })=>{
40
- const title = type.isNone(properties.title) ? type.isNone(properties.href) ? properties.href : blockId : properties.title;
41
33
  const showLoading = get(events, 'onClick.loading') || loading;
42
34
  const disabled = properties.disabled || showLoading;
43
- return(/*#__PURE__*/ _jsx(Tag, {
44
- blockId: blockId,
35
+ return(/*#__PURE__*/ React.createElement(Link, _extends({
36
+ id: blockId,
45
37
  className: methods.makeCssClass([
46
38
  properties.style,
47
39
  disabled && {
@@ -50,29 +42,18 @@ const AnchorBlock = ({ blockId , events , components: { Icon , Link } , loading
50
42
  },
51
43
  ]),
52
44
  disabled: disabled,
53
- href: properties.href,
54
- Link: Link,
55
- rel: properties.rel,
56
- newTab: properties.newTab,
57
45
  onClick: ()=>methods.triggerEvent({
58
46
  name: 'onClick'
59
47
  })
60
- ,
61
- children: /*#__PURE__*/ _jsxs(Strong, {
62
- strong: properties.strong,
63
- children: [
64
- properties.icon && /*#__PURE__*/ _jsx(Icon, {
65
- blockId: `${blockId}_icon`,
66
- events: events,
67
- properties: showLoading ? {
68
- name: 'LoadingOutlined',
69
- spin: true
70
- } : properties.icon
71
- }),
72
- ` ${title}`
73
- ]
74
- })
75
- }));
48
+ }, properties), (defaultTitle)=>/*#__PURE__*/ React.createElement(React.Fragment, null, properties.icon && /*#__PURE__*/ React.createElement(Icon, {
49
+ blockId: `${blockId}_icon`,
50
+ events: events,
51
+ properties: showLoading ? {
52
+ name: 'LoadingOutlined',
53
+ spin: true
54
+ } : properties.icon
55
+ }) + ` `, properties.title || defaultTitle)
56
+ ));
76
57
  };
77
58
  AnchorBlock.defaultProps = blockDefaultProps;
78
59
  AnchorBlock.meta = {
@@ -82,7 +63,8 @@ AnchorBlock.meta = {
82
63
  properties: {
83
64
  lines: 1
84
65
  }
85
- }
66
+ },
67
+ icons: [],
68
+ styles: []
86
69
  };
87
- AnchorBlock.styles = [];
88
70
  export default AnchorBlock;
@@ -4,6 +4,32 @@
4
4
  "type": "object",
5
5
  "additionalProperties": false,
6
6
  "properties": {
7
+ "ariaLabel": {
8
+ "type": "string",
9
+ "description": "Arial-label to apply to link tag."
10
+ },
11
+ "back": {
12
+ "type": "boolean",
13
+ "description": "When the link is clicked, trigger the browser back."
14
+ },
15
+ "home": {
16
+ "type": "boolean",
17
+ "description": "When the link is clicked, route to the home page."
18
+ },
19
+ "input": {
20
+ "type": "object",
21
+ "description": "When the link is clicked, pass data as the input object to the next Lowdefy page. Can only be used with pageId link and newTab false.",
22
+ "docs": {
23
+ "displayType": "yaml"
24
+ }
25
+ },
26
+ "urlQuery": {
27
+ "type": "object",
28
+ "description": "When the link is clicked, pass data as a url query to the next page.",
29
+ "docs": {
30
+ "displayType": "yaml"
31
+ }
32
+ },
7
33
  "disabled": {
8
34
  "type": "boolean",
9
35
  "default": false,
@@ -16,9 +42,13 @@
16
42
  "displayType": "icon"
17
43
  }
18
44
  },
19
- "href": {
45
+ "pageId": {
20
46
  "type": "string",
21
- "description": "Anchor element href property."
47
+ "description": "When the link is clicked, route to the provided Lowdefy page."
48
+ },
49
+ "url": {
50
+ "type": "string",
51
+ "description": "External url to link to when the anchor link is clicked."
22
52
  },
23
53
  "rel": {
24
54
  "type": "string",
@@ -30,10 +60,15 @@
30
60
  "default": false,
31
61
  "description": "Open link in a new tab when the anchor link is clicked."
32
62
  },
33
- "strong": {
63
+ "replace": {
64
+ "type": "boolean",
65
+ "default": false,
66
+ "description": "Prevent adding a new entry into browser history by replacing the url instead of pushing into history. Can only be used with pageId link and newTab false."
67
+ },
68
+ "scroll": {
34
69
  "type": "boolean",
35
70
  "default": false,
36
- "description": "Makes the text bold when true."
71
+ "description": "Disable scrolling to the top of the page after page transition. Can only be used with pageId link and newTab false."
37
72
  },
38
73
  "style": {
39
74
  "type": "object",
@@ -1,4 +1,3 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
1
  /*
3
2
  Copyright 2020-2021 Lowdefy, Inc
4
3
 
@@ -15,7 +14,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
15
14
  limitations under the License.
16
15
  */ import React from 'react';
17
16
  import { blockDefaultProps } from '@lowdefy/block-utils';
18
- const Box = ({ blockId , content , events , methods , properties })=>/*#__PURE__*/ _jsx("div", {
17
+ const Box = ({ blockId , content , events , methods , properties })=>/*#__PURE__*/ React.createElement("div", {
19
18
  id: blockId,
20
19
  "data-testid": blockId,
21
20
  onClick: ()=>methods.triggerEvent({
@@ -28,14 +27,14 @@ const Box = ({ blockId , content , events , methods , properties })=>/*#__PURE_
28
27
  cursor: events.onClick && 'pointer'
29
28
  },
30
29
  properties.style,
31
- ]),
32
- children: properties.content || content.content && content.content()
33
- })
30
+ ])
31
+ }, properties.content || content.content && content.content())
34
32
  ;
35
33
  Box.defaultProps = blockDefaultProps;
36
34
  Box.meta = {
37
35
  category: 'container',
38
- loading: false
36
+ loading: false,
37
+ icons: [],
38
+ styles: []
39
39
  };
40
- Box.styles = [];
41
40
  export default Box;
@@ -1,4 +1,3 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
1
  /*
3
2
  Copyright 2020-2021 Lowdefy, Inc
4
3
 
@@ -28,7 +27,7 @@ let DangerousHtml = class DangerousHtml extends React.Component {
28
27
  }
29
28
  render() {
30
29
  const { blockId , properties , methods } = this.props;
31
- return(/*#__PURE__*/ _jsx("div", {
30
+ return(/*#__PURE__*/ React.createElement("div", {
32
31
  id: blockId,
33
32
  "data-testid": blockId,
34
33
  ref: (el)=>{
@@ -51,7 +50,8 @@ let DangerousHtml = class DangerousHtml extends React.Component {
51
50
  DangerousHtml.defaultProps = blockDefaultProps;
52
51
  DangerousHtml.meta = {
53
52
  category: 'display',
54
- loading: false
53
+ loading: false,
54
+ icons: [],
55
+ styles: []
55
56
  };
56
- DangerousHtml.styles = [];
57
57
  export default DangerousHtml;
@@ -1,4 +1,3 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
1
  /*
3
2
  Copyright 2020-2021 Lowdefy, Inc
4
3
 
@@ -15,7 +14,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
15
14
  limitations under the License.
16
15
  */ import React from 'react';
17
16
  import { blockDefaultProps, HtmlComponent } from '@lowdefy/block-utils';
18
- const HtmlBlock = ({ blockId , properties , methods })=>/*#__PURE__*/ _jsx(HtmlComponent, {
17
+ const HtmlBlock = ({ blockId , properties , methods })=>/*#__PURE__*/ React.createElement(HtmlComponent, {
19
18
  div: true,
20
19
  html: properties.html,
21
20
  id: blockId,
@@ -26,7 +25,8 @@ const HtmlBlock = ({ blockId , properties , methods })=>/*#__PURE__*/ _jsx(Html
26
25
  HtmlBlock.defaultProps = blockDefaultProps;
27
26
  HtmlBlock.meta = {
28
27
  category: 'display',
29
- loading: false
28
+ loading: false,
29
+ icons: [],
30
+ styles: []
30
31
  };
31
- HtmlBlock.styles = [];
32
32
  export default HtmlBlock;
@@ -1,4 +1,3 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
1
  /*
3
2
  Copyright 2020-2021 Lowdefy, Inc
4
3
 
@@ -15,14 +14,27 @@ import { jsx as _jsx } from "react/jsx-runtime";
15
14
  limitations under the License.
16
15
  */ import React from 'react';
17
16
  import { blockDefaultProps } from '@lowdefy/block-utils';
18
- const IconBlock = ({ components: { Icon } , ...props })=>/*#__PURE__*/ _jsx(Icon, {
19
- ...props
20
- })
17
+ function _extends() {
18
+ _extends = Object.assign || function(target) {
19
+ for(var i = 1; i < arguments.length; i++){
20
+ var source = arguments[i];
21
+ for(var key in source){
22
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
23
+ target[key] = source[key];
24
+ }
25
+ }
26
+ }
27
+ return target;
28
+ };
29
+ return _extends.apply(this, arguments);
30
+ }
31
+ const IconBlock = ({ components: { Icon } , ...props })=>/*#__PURE__*/ React.createElement(Icon, _extends({}, props))
21
32
  ;
22
33
  IconBlock.defaultProps = blockDefaultProps;
23
34
  IconBlock.meta = {
24
35
  category: 'display',
25
- loading: false
36
+ loading: false,
37
+ icons: [],
38
+ styles: []
26
39
  };
27
- IconBlock.styles = [];
28
40
  export default IconBlock;
@@ -1,4 +1,3 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
1
  /*
3
2
  Copyright 2020-2021 Lowdefy, Inc
4
3
 
@@ -15,10 +14,23 @@ import { jsx as _jsx } from "react/jsx-runtime";
15
14
  limitations under the License.
16
15
  */ import React from 'react';
17
16
  import { blockDefaultProps } from '@lowdefy/block-utils';
17
+ function _extends() {
18
+ _extends = Object.assign || function(target) {
19
+ for(var i = 1; i < arguments.length; i++){
20
+ var source = arguments[i];
21
+ for(var key in source){
22
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
23
+ target[key] = source[key];
24
+ }
25
+ }
26
+ }
27
+ return target;
28
+ };
29
+ return _extends.apply(this, arguments);
30
+ }
18
31
  const ImgBlock = ({ blockId , events , properties , methods })=>{
19
32
  const { style , ...allProps } = properties;
20
- return(/*#__PURE__*/ _jsx("img", {
21
- ...allProps,
33
+ return(/*#__PURE__*/ React.createElement("img", _extends({}, allProps, {
22
34
  id: blockId,
23
35
  "data-testid": blockId,
24
36
  onClick: ()=>methods.triggerEvent({
@@ -32,12 +44,13 @@ const ImgBlock = ({ blockId , events , properties , methods })=>{
32
44
  },
33
45
  style,
34
46
  ])
35
- }));
47
+ })));
36
48
  };
37
49
  ImgBlock.defaultProps = blockDefaultProps;
38
50
  ImgBlock.meta = {
39
51
  category: 'display',
40
- loading: false
52
+ loading: false,
53
+ icons: [],
54
+ styles: []
41
55
  };
42
- ImgBlock.styles = [];
43
56
  export default ImgBlock;
@@ -1,4 +1,3 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
1
  /*
3
2
  Copyright 2020-2021 Lowdefy, Inc
4
3
 
@@ -24,7 +23,7 @@ const List = ({ blockId , events , list , methods , properties })=>{
24
23
  methods.registerMethod('moveItemDown', methods.moveItemDown);
25
24
  methods.registerMethod('moveItemUp', methods.moveItemUp);
26
25
  }, []);
27
- return(/*#__PURE__*/ _jsx(Box, {
26
+ return(/*#__PURE__*/ React.createElement(Box, {
28
27
  blockId: blockId,
29
28
  events: events,
30
29
  properties: {
@@ -34,8 +33,7 @@ const List = ({ blockId , events , list , methods , properties })=>{
34
33
  flexDirection: properties.direction,
35
34
  flexWrap: properties.wrap ? properties.wrap : 'wrap',
36
35
  overflow: properties.scroll ? 'auto' : 'visible'
37
- } : {
38
- },
36
+ } : {},
39
37
  ...properties.style
40
38
  }
41
39
  },
@@ -50,7 +48,8 @@ List.defaultProps = blockDefaultProps;
50
48
  List.meta = {
51
49
  category: 'list',
52
50
  valueType: 'array',
53
- loading: false
51
+ loading: false,
52
+ icons: [],
53
+ styles: []
54
54
  };
55
- List.styles = [];
56
55
  export default List;
@@ -1,4 +1,3 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
1
  /*
3
2
  Copyright 2020-2021 Lowdefy, Inc
4
3
 
@@ -15,7 +14,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
15
14
  limitations under the License.
16
15
  */ import React from 'react';
17
16
  import { blockDefaultProps } from '@lowdefy/block-utils';
18
- const Span = ({ blockId , content , events , methods , properties })=>/*#__PURE__*/ _jsx("span", {
17
+ const Span = ({ blockId , content , events , methods , properties })=>/*#__PURE__*/ React.createElement("span", {
19
18
  id: blockId,
20
19
  "data-testid": blockId,
21
20
  onClick: ()=>methods.triggerEvent({
@@ -28,14 +27,14 @@ const Span = ({ blockId , content , events , methods , properties })=>/*#__PURE
28
27
  cursor: events.onClick && 'pointer'
29
28
  },
30
29
  properties.style,
31
- ]),
32
- children: properties.content || content.content && content.content()
33
- })
30
+ ])
31
+ }, properties.content || content.content && content.content())
34
32
  ;
35
33
  Span.defaultProps = blockDefaultProps;
36
34
  Span.meta = {
37
35
  category: 'container',
38
- loading: false
36
+ loading: false,
37
+ icons: [],
38
+ styles: []
39
39
  };
40
- Span.styles = [];
41
40
  export default Span;
package/dist/types.js CHANGED
@@ -13,13 +13,15 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import * as blocks from './blocks.js';
16
- const styles = {
17
- };
16
+ const icons = {};
17
+ const styles = {};
18
18
  Object.keys(blocks).forEach((block)=>{
19
- styles[block] = blocks[block].styles || [];
19
+ icons[block] = blocks[block].meta.icons || [];
20
+ styles[block] = blocks[block].meta.styles || [];
20
21
  });
21
22
  export default {
22
23
  blocks: Object.keys(blocks),
24
+ icons,
23
25
  styles: {
24
26
  default: [],
25
27
  ...styles
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@lowdefy/blocks-basic",
3
- "version": "4.0.0-alpha.5",
3
+ "version": "4.0.0-alpha.8",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Basic html Lowdefy blocks.",
6
6
  "homepage": "https://lowdefy.com",
7
7
  "keywords": [
8
8
  "lowdefy",
9
- "lowdefy blocks"
9
+ "lowdefy blocks",
10
+ "lowdefy plugin"
10
11
  ],
11
12
  "bugs": {
12
13
  "url": "https://github.com/lowdefy/lowdefy/issues"
@@ -19,6 +20,10 @@
19
20
  {
20
21
  "name": "Gerrie van Wyk",
21
22
  "url": "https://github.com/Gervwyk"
23
+ },
24
+ {
25
+ "name": "Sandile Memela",
26
+ "url": "https://github.com/sah-memela"
22
27
  }
23
28
  ],
24
29
  "repository": {
@@ -44,29 +49,28 @@
44
49
  "test": "jest --coverage"
45
50
  },
46
51
  "dependencies": {
47
- "@lowdefy/block-utils": "4.0.0-alpha.5",
48
- "@lowdefy/helpers": "4.0.0-alpha.5",
49
- "dompurify": "2.3.3",
50
- "react": "18.0.0-alpha-327d5c484-20211106",
51
- "react-dom": "18.0.0-alpha-327d5c484-20211106"
52
+ "@lowdefy/block-utils": "4.0.0-alpha.8",
53
+ "@lowdefy/helpers": "4.0.0-alpha.8",
54
+ "dompurify": "2.3.5",
55
+ "react": "17.0.2",
56
+ "react-dom": "17.0.2"
52
57
  },
53
58
  "devDependencies": {
54
- "@babel/preset-react": "7.16.0",
55
- "@emotion/jest": "11.5.0",
56
- "@lowdefy/block-dev": "4.0.0-alpha.5",
57
- "@swc/cli": "0.1.52",
58
- "@swc/core": "1.2.112",
59
- "@swc/jest": "0.2.9",
60
- "@testing-library/dom": "8.10.1",
59
+ "@emotion/jest": "11.7.1",
60
+ "@lowdefy/block-dev": "4.0.0-alpha.8",
61
+ "@swc/cli": "0.1.55",
62
+ "@swc/core": "1.2.135",
63
+ "@swc/jest": "0.2.17",
64
+ "@testing-library/dom": "8.11.3",
61
65
  "@testing-library/react": "13.0.0-alpha.4",
62
66
  "@testing-library/user-event": "14.0.0-alpha.14",
63
67
  "copyfiles": "2.4.1",
64
- "jest": "27.3.1",
68
+ "jest": "27.5.1",
65
69
  "jest-serializer-html": "7.1.0",
66
- "jest-transform-yaml": "0.1.2"
70
+ "jest-transform-yaml": "1.0.0"
67
71
  },
68
72
  "publishConfig": {
69
73
  "access": "public"
70
74
  },
71
- "gitHead": "995fcdb020927f3cdc626fc99c15a2e4137bd962"
75
+ "gitHead": "9d56b83cf45e868afe3a1eeba750fe826eb74c8c"
72
76
  }