@saltcorn/builder 0.6.1-beta.0 → 0.6.1

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.
Files changed (33) hide show
  1. package/dist/builder_bundle.js +9 -9
  2. package/package.json +1 -1
  3. package/src/components/Builder.js +77 -0
  4. package/src/components/Library.js +43 -3
  5. package/src/components/RenderNode.js +17 -1
  6. package/src/components/Toolbox.js +207 -5
  7. package/src/components/context.js +6 -0
  8. package/src/components/elements/Action.js +38 -2
  9. package/src/components/elements/Aggregation.js +29 -2
  10. package/src/components/elements/BoxModelEditor.js +18 -1
  11. package/src/components/elements/Card.js +31 -2
  12. package/src/components/elements/Column.js +28 -2
  13. package/src/components/elements/Columns.js +50 -4
  14. package/src/components/elements/Container.js +119 -3
  15. package/src/components/elements/DropDownFilter.js +27 -2
  16. package/src/components/elements/Empty.js +18 -1
  17. package/src/components/elements/Field.js +29 -2
  18. package/src/components/elements/HTMLCode.js +18 -2
  19. package/src/components/elements/Image.js +29 -2
  20. package/src/components/elements/JoinField.js +28 -2
  21. package/src/components/elements/LineBreak.js +17 -1
  22. package/src/components/elements/Link.js +34 -2
  23. package/src/components/elements/SearchBar.js +29 -2
  24. package/src/components/elements/Tabs.js +29 -2
  25. package/src/components/elements/Text.js +36 -2
  26. package/src/components/elements/ToggleFilter.js +31 -2
  27. package/src/components/elements/View.js +27 -2
  28. package/src/components/elements/ViewLink.js +36 -2
  29. package/src/components/elements/faicons.js +481 -0
  30. package/src/components/elements/utils.js +279 -16
  31. package/src/components/preview_context.js +6 -1
  32. package/src/components/storage.js +59 -2
  33. package/src/index.js +12 -0
@@ -1,3 +1,9 @@
1
+ /**
2
+ * @category saltcorn-builder
3
+ * @module components/elements/HTMLCode
4
+ * @subcategory components / elements
5
+ */
6
+
1
7
  import React from "react";
2
8
  import { useNode } from "@craftjs/core";
3
9
  import {
@@ -7,7 +13,15 @@ import {
7
13
  TextStyleSetting,
8
14
  } from "./utils";
9
15
 
10
- export const HTMLCode = ({ text }) => {
16
+ export /**
17
+ * @param {object} props
18
+ * @param {string} props.text
19
+ * @returns {span}
20
+ * @namespace
21
+ * @category saltcorn-builder
22
+ * @subcategory components
23
+ */
24
+ const HTMLCode = ({ text }) => {
11
25
  const {
12
26
  selected,
13
27
  connectors: { connect, drag },
@@ -23,7 +37,6 @@ export const HTMLCode = ({ text }) => {
23
37
  );
24
38
  };
25
39
 
26
-
27
40
  const fields = [
28
41
  {
29
42
  label: "HTML Code",
@@ -33,6 +46,9 @@ const fields = [
33
46
  },
34
47
  ];
35
48
 
49
+ /**
50
+ * @type {object}
51
+ */
36
52
  HTMLCode.craft = {
37
53
  displayName: "HTMLCode",
38
54
  related: {
@@ -1,3 +1,9 @@
1
+ /**
2
+ * @category saltcorn-builder
3
+ * @module components/elements/Image
4
+ * @subcategory components / elements
5
+ */
6
+
1
7
  import React, { useContext, Fragment } from "react";
2
8
  import { useNode } from "@craftjs/core";
3
9
  import optionsCtx from "../context";
@@ -5,7 +11,19 @@ import previewCtx from "../preview_context";
5
11
 
6
12
  import { blockProps, BlockSetting, TextStyleSetting, OrFormula } from "./utils";
7
13
 
8
- export const Image = ({ fileid, block, srctype, url, alt }) => {
14
+ export /**
15
+ * @param {object} props
16
+ * @param {string} props.fileid
17
+ * @param {boolean} props.block
18
+ * @param {string} props.srctype
19
+ * @param {string} props.url
20
+ * @param {string} props.alt
21
+ * @returns {span}
22
+ * @namespace
23
+ * @category saltcorn-builder
24
+ * @subcategory components
25
+ */
26
+ const Image = ({ fileid, block, srctype, url, alt }) => {
9
27
  const {
10
28
  selected,
11
29
  connectors: { connect, drag },
@@ -26,7 +44,13 @@ export const Image = ({ fileid, block, srctype, url, alt }) => {
26
44
  );
27
45
  };
28
46
 
29
- export const ImageSettings = () => {
47
+ export /**
48
+ * @returns {table}
49
+ * @namespace
50
+ * @category saltcorn-builder
51
+ * @subcategory components
52
+ */
53
+ const ImageSettings = () => {
30
54
  const node = useNode((node) => ({
31
55
  fileid: node.data.props.fileid,
32
56
  field: node.data.props.field,
@@ -227,6 +251,9 @@ export const ImageSettings = () => {
227
251
  );
228
252
  };
229
253
 
254
+ /**
255
+ * @type {object}
256
+ */
230
257
  Image.craft = {
231
258
  displayName: "Image",
232
259
  defaultProps: {
@@ -1,3 +1,9 @@
1
+ /**
2
+ * @category saltcorn-builder
3
+ * @module components/elements/JoinField
4
+ * @subcategory components / elements
5
+ */
6
+
1
7
  import React, { useContext, useEffect, Fragment } from "react";
2
8
  import { useNode } from "@craftjs/core";
3
9
  import optionsCtx from "../context";
@@ -9,7 +15,18 @@ import {
9
15
  } from "./utils";
10
16
  import previewCtx from "../preview_context";
11
17
 
12
- export const JoinField = ({ name, block, fieldview, textStyle }) => {
18
+ export /**
19
+ * @param {object} props
20
+ * @param {string} props.name
21
+ * @param {boolean} props.block
22
+ * @param {object} props.fieldview
23
+ * @param {string} props.textStyle
24
+ * @returns {span}
25
+ * @namespace
26
+ * @category saltcorn-builder
27
+ * @subcategory components
28
+ */
29
+ const JoinField = ({ name, block, fieldview, textStyle }) => {
13
30
  const {
14
31
  selected,
15
32
  node_id,
@@ -47,7 +64,13 @@ export const JoinField = ({ name, block, fieldview, textStyle }) => {
47
64
  );
48
65
  };
49
66
 
50
- export const JoinFieldSettings = () => {
67
+ export /**
68
+ * @returns {Fragment}
69
+ * @namespace
70
+ * @category saltcorn-builder
71
+ * @subcategory components
72
+ */
73
+ const JoinFieldSettings = () => {
51
74
  const {
52
75
  actions: { setProp },
53
76
  name,
@@ -148,6 +171,9 @@ export const JoinFieldSettings = () => {
148
171
  );
149
172
  };
150
173
 
174
+ /**
175
+ * @type {object}
176
+ */
151
177
  JoinField.craft = {
152
178
  displayName: "JoinField",
153
179
  related: {
@@ -1,8 +1,21 @@
1
+ /**
2
+ * @category saltcorn-builder
3
+ * @module components/elements/LineBreak
4
+ * @subcategory components / elements
5
+ */
6
+
1
7
  import React, { Fragment } from "react";
2
8
  import { useNode } from "@craftjs/core";
3
9
  import { SettingsFromFields } from "./utils";
4
10
 
5
- export const LineBreak = ({}) => {
11
+ export /**
12
+ * @param {object} [props = {}]
13
+ * @returns {Fragment}
14
+ * @namespace
15
+ * @category saltcorn-builder
16
+ * @subcategory components
17
+ */
18
+ const LineBreak = ({}) => {
6
19
  const {
7
20
  selected,
8
21
  connectors: { connect, drag },
@@ -20,6 +33,9 @@ export const LineBreak = ({}) => {
20
33
  );
21
34
  };
22
35
 
36
+ /**
37
+ * @type {object}
38
+ */
23
39
  LineBreak.craft = {
24
40
  displayName: "LineBreak",
25
41
  related: {
@@ -1,3 +1,9 @@
1
+ /**
2
+ * @category saltcorn-builder
3
+ * @module components/elements/Link
4
+ * @subcategory components / elements
5
+ */
6
+
1
7
  import React, { Fragment, useContext } from "react";
2
8
  import { useNode } from "@craftjs/core";
3
9
  import {
@@ -10,7 +16,24 @@ import {
10
16
  } from "./utils";
11
17
  import optionsCtx from "../context";
12
18
 
13
- export const Link = ({
19
+ export /**
20
+ * @param {object} props
21
+ * @param {string} props.text
22
+ * @param {boolean} props.block
23
+ * @param {object} props.isFormula
24
+ * @param {string} props.textStyle
25
+ * @param {string} props.link_style
26
+ * @param {string} props.link_size
27
+ * @param {string} [props.link_icon]
28
+ * @param {string} [props.link_bgcol]
29
+ * @param {string} [props.link_bordercol]
30
+ * @param {string} [props.link_textcol]
31
+ * @returns {Fragment}
32
+ * @namespace
33
+ * @category saltcorn-builder
34
+ * @subcategory components
35
+ */
36
+ const Link = ({
14
37
  text,
15
38
  block,
16
39
  isFormula,
@@ -49,7 +72,13 @@ export const Link = ({
49
72
  );
50
73
  };
51
74
 
52
- export const LinkSettings = () => {
75
+ export /**
76
+ * @returns {div}
77
+ * @namespace
78
+ * @category saltcorn-builder
79
+ * @subcategory components
80
+ */
81
+ const LinkSettings = () => {
53
82
  const node = useNode((node) => ({
54
83
  text: node.data.props.text,
55
84
  url: node.data.props.url,
@@ -224,6 +253,9 @@ export const LinkSettings = () => {
224
253
  );
225
254
  };
226
255
 
256
+ /**
257
+ * @type {object}
258
+ */
227
259
  Link.craft = {
228
260
  defaultProps: {
229
261
  text: "Click here",
@@ -1,10 +1,26 @@
1
+ /**
2
+ * @category saltcorn-builder
3
+ * @module components/elements/SearchBar
4
+ * @subcategory components / elements
5
+ */
6
+
1
7
  import React, { Fragment, useState } from "react";
2
8
  import { Element, useNode } from "@craftjs/core";
3
9
  import { Column } from "./Column";
4
10
  import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
5
11
  import { faCaretDown } from "@fortawesome/free-solid-svg-icons";
6
12
 
7
- export const SearchBar = ({ has_dropdown, children, show_badges }) => {
13
+ export /**
14
+ * @param {object} props
15
+ * @param {boolean} props.has_dropdown
16
+ * @param {string} props.children
17
+ * @param {boolean} props.show_badges
18
+ * @returns {div}
19
+ * @namespace
20
+ * @category saltcorn-builder
21
+ * @subcategory components
22
+ */
23
+ const SearchBar = ({ has_dropdown, children, show_badges }) => {
8
24
  const {
9
25
  selected,
10
26
  connectors: { connect, drag },
@@ -63,7 +79,14 @@ export const SearchBar = ({ has_dropdown, children, show_badges }) => {
63
79
  </div>
64
80
  );
65
81
  };
66
- export const SearchBarSettings = () => {
82
+
83
+ export /**
84
+ * @returns {div}
85
+ * @namespace
86
+ * @category saltcorn-builder
87
+ * @subcategory components
88
+ */
89
+ const SearchBarSettings = () => {
67
90
  const {
68
91
  actions: { setProp },
69
92
  has_dropdown,
@@ -102,6 +125,10 @@ export const SearchBarSettings = () => {
102
125
  </div>
103
126
  );
104
127
  };
128
+
129
+ /**
130
+ * @type {object}
131
+ */
105
132
  SearchBar.craft = {
106
133
  displayName: "SearchBar",
107
134
  props: {
@@ -1,10 +1,27 @@
1
+ /**
2
+ * @category saltcorn-builder
3
+ * @module components/elements/Tabs
4
+ * @subcategory components / elements
5
+ */
6
+
1
7
  import React, { Fragment, useState } from "react";
2
8
  import { ntimes } from "./Columns";
3
9
  import { Column } from "./Column";
4
10
 
5
11
  import { Element, useNode } from "@craftjs/core";
6
12
 
7
- export const Tabs = ({ contents, titles, tabsStyle, ntabs }) => {
13
+ export /**
14
+ * @param {object} props
15
+ * @param {string[]} props.contents
16
+ * @param {string[]} props.titles
17
+ * @param {string} props.tabsStyle
18
+ * @param {number} props.ntabs
19
+ * @returns {div}
20
+ * @namespace
21
+ * @category saltcorn-builder
22
+ * @subcategory components
23
+ */
24
+ const Tabs = ({ contents, titles, tabsStyle, ntabs }) => {
8
25
  const {
9
26
  selected,
10
27
  connectors: { connect, drag },
@@ -83,7 +100,13 @@ export const Tabs = ({ contents, titles, tabsStyle, ntabs }) => {
83
100
  );
84
101
  };
85
102
 
86
- export const TabsSettings = () => {
103
+ export /**
104
+ * @returns {table}
105
+ * @namespace
106
+ * @category saltcorn-builder
107
+ * @subcategory components
108
+ */
109
+ const TabsSettings = () => {
87
110
  const node = useNode((node) => ({
88
111
  tabsStyle: node.data.props.tabsStyle,
89
112
  ntabs: node.data.props.ntabs,
@@ -156,6 +179,10 @@ export const TabsSettings = () => {
156
179
  </table>
157
180
  );
158
181
  };
182
+
183
+ /**
184
+ * @type {object}
185
+ */
159
186
  Tabs.craft = {
160
187
  props: {
161
188
  titles: ["Tab1", "Tab2"],
@@ -1,3 +1,9 @@
1
+ /**
2
+ * @category saltcorn-builder
3
+ * @module components/elements/Text
4
+ * @subcategory components / elements
5
+ */
6
+
1
7
  import React, { useState, useContext, useEffect, Fragment } from "react";
2
8
  import { useNode } from "@craftjs/core";
3
9
  import {
@@ -45,10 +51,29 @@ const ckConfig = {
45
51
  removeButtons:
46
52
  "Source,Save,NewPage,ExportPdf,Print,Preview,Templates,Cut,Copy,Paste,PasteText,PasteFromWord,Find,Replace,SelectAll,Form,Checkbox,Radio,TextField,Textarea,Select,Button,ImageButton,HiddenField,CopyFormatting,CreateDiv,BidiLtr,BidiRtl,Language,Anchor,Flash,Iframe,PageBreak,Maximize,ShowBlocks,About,Undo,Redo,Image",
47
53
  };
54
+
55
+ /**
56
+ * @param {string} str
57
+ * @returns {string}
58
+ */
48
59
  function escape_tags(str) {
49
60
  return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
50
61
  }
51
- export const Text = ({ text, block, isFormula, textStyle, icon, font }) => {
62
+
63
+ export /**
64
+ * @param {object} props
65
+ * @param {string} props.text
66
+ * @param {boolean} props.block
67
+ * @param {object} props.isFormula
68
+ * @param {string} props.textStyle
69
+ * @param {string} [props.icon]
70
+ * @param {string} [props.font]
71
+ * @returns {div}
72
+ * @namespace
73
+ * @category saltcorn-builder
74
+ * @subcategory components
75
+ */
76
+ const Text = ({ text, block, isFormula, textStyle, icon, font }) => {
52
77
  const {
53
78
  connectors: { connect, drag },
54
79
  selected,
@@ -103,7 +128,13 @@ export const Text = ({ text, block, isFormula, textStyle, icon, font }) => {
103
128
  };
104
129
  //<div dangerouslySetInnerHTML={{ __html: text }} />
105
130
 
106
- export const TextSettings = () => {
131
+ export /**
132
+ * @returns {div}
133
+ * @namespace
134
+ * @category saltcorn-builder
135
+ * @subcategory components
136
+ */
137
+ const TextSettings = () => {
107
138
  const node = useNode((node) => ({
108
139
  text: node.data.props.text,
109
140
  block: node.data.props.block,
@@ -220,6 +251,9 @@ export const TextSettings = () => {
220
251
  );
221
252
  };
222
253
 
254
+ /**
255
+ * @type {object}
256
+ */
223
257
  Text.craft = {
224
258
  defaultProps: {
225
259
  text: "Click here",
@@ -1,9 +1,29 @@
1
+ /**
2
+ * @category saltcorn-builder
3
+ * @module components/elements/ToggleFilter
4
+ * @subcategory components / elements
5
+ */
6
+
1
7
  import React, { useContext, Fragment } from "react";
2
8
  import { useNode } from "@craftjs/core";
3
9
  import optionsCtx from "../context";
4
10
  import { blockProps, BlockSetting, TextStyleRow } from "./utils";
5
11
 
6
- export const ToggleFilter = ({
12
+ export /**
13
+ * @param {object} props
14
+ * @param {*} props.name
15
+ * @param {string} [props.value]
16
+ * @param {string} [props.preset_value]
17
+ * @param {boolean} props.block
18
+ * @param {string} [props.label]
19
+ * @param {string} props.size
20
+ * @param {string} props.style
21
+ * @returns {table}
22
+ * @namespace
23
+ * @category saltcorn-builder
24
+ * @subcategory components
25
+ */
26
+ const ToggleFilter = ({
7
27
  name,
8
28
  value,
9
29
  preset_value,
@@ -29,7 +49,13 @@ export const ToggleFilter = ({
29
49
  );
30
50
  };
31
51
 
32
- export const ToggleFilterSettings = () => {
52
+ export /**
53
+ * @returns {table}
54
+ * @namespace
55
+ * @category saltcorn-builder
56
+ * @subcategory components
57
+ */
58
+ const ToggleFilterSettings = () => {
33
59
  const {
34
60
  actions: { setProp },
35
61
  name,
@@ -195,6 +221,9 @@ export const ToggleFilterSettings = () => {
195
221
  );
196
222
  };
197
223
 
224
+ /**
225
+ * @type {object}
226
+ */
198
227
  ToggleFilter.craft = {
199
228
  displayName: "ToggleFilter",
200
229
  related: {
@@ -1,3 +1,9 @@
1
+ /**
2
+ * @category saltcorn-builder
3
+ * @module components/elements/View
4
+ * @subcategory components / elements
5
+ */
6
+
1
7
  import React, { Fragment, useContext, useEffect } from "react";
2
8
  import { useNode } from "@craftjs/core";
3
9
  import optionsCtx from "../context";
@@ -11,7 +17,17 @@ import {
11
17
  ConfigForm,
12
18
  } from "./utils";
13
19
 
14
- export const View = ({ name, view, state }) => {
20
+ export /**
21
+ * @param {object} props
22
+ * @param {*} props.name
23
+ * @param {string} props.view
24
+ * @param {*} props.state
25
+ * @returns {div}
26
+ * @category saltcorn-builder
27
+ * @subcategory components
28
+ * @namespace
29
+ */
30
+ const View = ({ name, view, state }) => {
15
31
  const {
16
32
  selected,
17
33
  node_id,
@@ -51,7 +67,13 @@ export const View = ({ name, view, state }) => {
51
67
  );
52
68
  };
53
69
 
54
- export const ViewSettings = () => {
70
+ export /**
71
+ * @returns {div}
72
+ * @category saltcorn-builder
73
+ * @subcategory components
74
+ * @namespace
75
+ */
76
+ const ViewSettings = () => {
55
77
  const node = useNode((node) => ({
56
78
  name: node.data.props.name,
57
79
  view: node.data.props.view,
@@ -136,6 +158,9 @@ export const ViewSettings = () => {
136
158
  );
137
159
  };
138
160
 
161
+ /**
162
+ * @type {object}
163
+ */
139
164
  View.craft = {
140
165
  displayName: "View",
141
166
  related: {
@@ -1,3 +1,9 @@
1
+ /**
2
+ * @category saltcorn-builder
3
+ * @module components/elements/ViewLink
4
+ * @subcategory components / elements
5
+ */
6
+
1
7
  import React, { useContext } from "react";
2
8
  import { useNode } from "@craftjs/core";
3
9
  import optionsCtx from "../context";
@@ -10,7 +16,26 @@ import {
10
16
  ButtonOrLinkSettingsRows,
11
17
  } from "./utils";
12
18
 
13
- export const ViewLink = ({
19
+ export /**
20
+ * @param {object} props
21
+ * @param {string} props.name
22
+ * @param {boolean} props.block
23
+ * @param {*} props.minRole
24
+ * @param {string} props.link_style
25
+ * @param {string} props.link_size
26
+ * @param {string} [props.link_icon]
27
+ * @param {boolean} props.inModal
28
+ * @param {string} [props.label]
29
+ * @param {string} props.textStyle
30
+ * @param {string} [props.link_bgcol]
31
+ * @param {string} [props.link_bordercol]
32
+ * @param {string} [props.link_textcol]
33
+ * @returns {tr}
34
+ * @category saltcorn-builder
35
+ * @subcategory components
36
+ * @namespace
37
+ */
38
+ const ViewLink = ({
14
39
  name,
15
40
  block,
16
41
  minRole,
@@ -53,7 +78,13 @@ export const ViewLink = ({
53
78
  );
54
79
  };
55
80
 
56
- export const ViewLinkSettings = () => {
81
+ export /**
82
+ * @returns {div}
83
+ * @category saltcorn-builder
84
+ * @subcategory components
85
+ * @namespace
86
+ */
87
+ const ViewLinkSettings = () => {
57
88
  const node = useNode((node) => ({
58
89
  name: node.data.props.name,
59
90
  block: node.data.props.block,
@@ -147,6 +178,9 @@ export const ViewLinkSettings = () => {
147
178
  );
148
179
  };
149
180
 
181
+ /**
182
+ * @type {object}
183
+ */
150
184
  ViewLink.craft = {
151
185
  displayName: "ViewLink",
152
186
  defaultProps: {