@saltcorn/builder 0.6.3-beta.3 → 0.6.4-beta.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saltcorn/builder",
3
- "version": "0.6.3-beta.3",
3
+ "version": "0.6.4-beta.3",
4
4
  "description": "Drag and drop view builder for Saltcorn, open-source no-code platform",
5
5
  "main": "index.js",
6
6
  "homepage": "https://saltcorn.com",
@@ -15,32 +15,33 @@
15
15
  "author": "Tom Nielsen",
16
16
  "license": "MIT",
17
17
  "devDependencies": {
18
- "@babel/core": "^7.9.6",
19
- "@babel/preset-env": "^7.9.6",
20
- "@babel/preset-react": "^7.9.4",
18
+ "@babel/core": "7.9.6",
19
+ "@babel/preset-env": "7.9.6",
20
+ "@babel/preset-react": "7.9.4",
21
21
  "@craftjs/core": "0.1.0-beta.20",
22
+ "@craftjs/utils": "0.1.0-beta.20",
22
23
  "saltcorn-craft-layers-noeye": "0.1.0-beta.22",
23
- "@fonticonpicker/react-fonticonpicker": "^1.2.0",
24
- "@fortawesome/fontawesome-svg-core": "^1.2.34",
25
- "@fortawesome/free-regular-svg-icons": "^5.15.2",
26
- "@fortawesome/free-solid-svg-icons": "^5.15.2",
27
- "@fortawesome/react-fontawesome": "^0.1.14",
28
- "babel-loader": "^8.1.0",
29
- "ckeditor4-react": "^1.4.0",
30
- "classnames": "^2.2.6",
31
- "prop-types": "^15.7.2",
32
- "react": "^16.13.1",
33
- "react-bootstrap-icons": "^1.5.0",
34
- "react-contenteditable": "^3.3.5",
35
- "react-dom": "^16.13.1",
36
- "react-transition-group": "^4.4.1",
37
- "webpack": "^4.43.0",
38
- "webpack-cli": "^3.3.11"
24
+ "@fonticonpicker/react-fonticonpicker": "1.2.0",
25
+ "@fortawesome/fontawesome-svg-core": "1.2.34",
26
+ "@fortawesome/free-regular-svg-icons": "5.15.2",
27
+ "@fortawesome/free-solid-svg-icons": "5.15.2",
28
+ "@fortawesome/react-fontawesome": "0.1.14",
29
+ "babel-loader": "8.1.0",
30
+ "ckeditor4-react": "1.4.2",
31
+ "classnames": "2.2.6",
32
+ "prop-types": "15.7.2",
33
+ "react": "16.13.1",
34
+ "react-bootstrap-icons": "1.5.0",
35
+ "react-contenteditable": "3.3.5",
36
+ "react-dom": "16.13.1",
37
+ "react-transition-group": "4.4.1",
38
+ "webpack": "4.43.0",
39
+ "webpack-cli": "3.3.11"
39
40
  },
40
41
  "publishConfig": {
41
42
  "access": "public"
42
43
  },
43
44
  "dependencies": {
44
- "styled-components": "^4.4.1"
45
+ "styled-components": "4.4.1"
45
46
  }
46
47
  }
@@ -382,6 +382,7 @@ const JoinFieldElem = ({ connectors, options }) => (
382
382
  >
383
383
  <JoinField
384
384
  name={options.parent_field_list[0]}
385
+ configuration={{}}
385
386
  textStyle={""}
386
387
  block={false}
387
388
  />
@@ -621,6 +622,9 @@ const ToolboxEdit = () => {
621
622
  <HTMLElem connectors={connectors} />
622
623
  <ViewElem connectors={connectors} views={views} />
623
624
  </div>
625
+ <div className="toolbar-row">
626
+ <JoinFieldElem connectors={connectors} options={options} />
627
+ </div>
624
628
  </Fragment>
625
629
  );
626
630
  };
@@ -12,7 +12,7 @@ Copyright (c) 2017 Taha Paksu
12
12
  */
13
13
 
14
14
  export /**
15
- *
15
+ *
16
16
  * @param {object} props
17
17
  * @param {function} props.setProp
18
18
  * @param {object} props.node
@@ -21,7 +21,7 @@ export /**
21
21
  * @subcategory components
22
22
  * @namespace
23
23
  */
24
- const BoxModelEditor = ({ setProp, node }) => {
24
+ const BoxModelEditor = ({ setProp, node, sizeWithStyle }) => {
25
25
  const [selectedCategory, setSelectedCategory] = useState(false);
26
26
  const [selectedDirection, setSelectedDirection] = useState(false);
27
27
  const selectedProperty = !selectedCategory
@@ -146,7 +146,9 @@ const BoxModelEditor = ({ setProp, node }) => {
146
146
  name="boxmodel-ex-1_width"
147
147
  size="3"
148
148
  value={
149
- node.width
149
+ sizeWithStyle
150
+ ? style["width"]
151
+ : node.width
150
152
  ? `${node.width}${node.widthUnits || "px"}`
151
153
  : ""
152
154
  }
@@ -159,7 +161,9 @@ const BoxModelEditor = ({ setProp, node }) => {
159
161
  name="boxmodel-ex-1_height"
160
162
  size="3"
161
163
  value={
162
- node.height
164
+ sizeWithStyle
165
+ ? style["height"]
166
+ : node.height
163
167
  ? `${node.height}${node.heightUnits || "px"}`
164
168
  : ""
165
169
  }
@@ -271,20 +275,23 @@ const BoxModelEditor = ({ setProp, node }) => {
271
275
  field={{ name: "width", label: "width", type: "DimUnits" }}
272
276
  node={node}
273
277
  setProp={setProp}
278
+ isStyle={!!sizeWithStyle}
274
279
  />
275
280
  <SettingsRow
276
281
  field={{ name: "height", label: "height", type: "DimUnits" }}
277
282
  node={node}
278
283
  setProp={setProp}
284
+ isStyle={!!sizeWithStyle}
279
285
  />
280
286
  <SettingsRow
281
287
  field={{
282
- name: "minHeight",
288
+ name: sizeWithStyle ? "min-height" : "minHeight",
283
289
  label: "min height",
284
290
  type: "DimUnits",
285
291
  }}
286
292
  node={node}
287
293
  setProp={setProp}
294
+ isStyle={!!sizeWithStyle}
288
295
  />
289
296
  </Fragment>
290
297
  )}
@@ -19,20 +19,13 @@ export /**
19
19
  * @param {string} [props.title]
20
20
  * @param {string} props.shadow
21
21
  * @param {boolean} props.noPadding
22
- * @param {object} props.style
22
+ * @param {object} props.style
23
23
  * @returns {div}
24
24
  * @category saltcorn-builder
25
25
  * @subcategory components
26
26
  * @namespace
27
27
  */
28
- const Card = ({
29
- children,
30
- isFormula,
31
- title,
32
- shadow,
33
- noPadding,
34
- style,
35
- }) => {
28
+ const Card = ({ children, isFormula, title, shadow, noPadding, style }) => {
36
29
  const {
37
30
  selected,
38
31
  connectors: { connect, drag },
@@ -119,7 +112,7 @@ const CardSettings = () => {
119
112
  </tbody>
120
113
  </table>
121
114
  <div accordiontitle="Box" className="w-100">
122
- <BoxModelEditor setProp={setProp} node={node} />
115
+ <BoxModelEditor setProp={setProp} node={node} sizeWithStyle={true} />
123
116
  </div>
124
117
  </Accordion>
125
118
  );
@@ -138,8 +131,8 @@ const fields = [
138
131
  { name: "style", default: {} },
139
132
  ];
140
133
 
141
- /**
142
- * @type {object}
134
+ /**
135
+ * @type {object}
143
136
  */
144
137
  Card.craft = {
145
138
  props: {
@@ -8,11 +8,13 @@ import React, { Fragment } from "react";
8
8
  import { Column } from "./Column";
9
9
 
10
10
  import { Element, useNode } from "@craftjs/core";
11
+ import { Accordion, reactifyStyles } from "./utils";
12
+ import { BoxModelEditor } from "./BoxModelEditor";
11
13
 
12
14
  export /**
13
- *
14
- * @param {number} n
15
- * @param {function} f
15
+ *
16
+ * @param {number} n
17
+ * @param {function} f
16
18
  * @returns {object[]}
17
19
  */
18
20
  const ntimes = (n, f) => {
@@ -24,8 +26,8 @@ const ntimes = (n, f) => {
24
26
  };
25
27
 
26
28
  export /**
27
- *
28
- * @param {number[]} xs
29
+ *
30
+ * @param {number[]} xs
29
31
  * @returns {number}
30
32
  */
31
33
  const sum = (xs) => {
@@ -35,14 +37,14 @@ const sum = (xs) => {
35
37
  };
36
38
 
37
39
  /**
38
- * @param {number} ncols
40
+ * @param {number} ncols
39
41
  * @returns {number}
40
42
  */
41
43
  const resetWidths = (ncols) => ntimes(ncols - 1, () => 12 / ncols);
42
44
 
43
45
  /**
44
- * @param {number[]} widths
45
- * @param {number} colix
46
+ * @param {number[]} widths
47
+ * @param {number} colix
46
48
  * @returns {number}
47
49
  */
48
50
  const getWidth = (widths, colix) =>
@@ -58,7 +60,7 @@ export /**
58
60
  * @category saltcorn-builder
59
61
  * @subcategory components
60
62
  */
61
- const Columns = ({ widths, contents, ncols }) => {
63
+ const Columns = ({ widths, contents, ncols, style }) => {
62
64
  const {
63
65
  selected,
64
66
  connectors: { connect, drag },
@@ -67,6 +69,7 @@ const Columns = ({ widths, contents, ncols }) => {
67
69
  <div
68
70
  className={`row ${selected ? "selected-node" : ""}`}
69
71
  ref={(dom) => connect(drag(dom))}
72
+ style={reactifyStyles(style || {})}
70
73
  >
71
74
  {ntimes(ncols, (ix) => (
72
75
  <div key={ix} className={`split-col col-sm-${getWidth(widths, ix)}`}>
@@ -86,19 +89,22 @@ export /**
86
89
  * @subcategory components
87
90
  */
88
91
  const ColumnsSettings = () => {
92
+ const node = useNode((node) => ({
93
+ widths: node.data.props.widths,
94
+ ncols: node.data.props.ncols,
95
+ breakpoints: node.data.props.breakpoints,
96
+ style: node.data.props.style,
97
+ }));
89
98
  const {
90
99
  actions: { setProp },
91
100
  widths,
92
101
  ncols,
93
102
  breakpoints,
94
- } = useNode((node) => ({
95
- widths: node.data.props.widths,
96
- ncols: node.data.props.ncols,
97
- breakpoints: node.data.props.breakpoints,
98
- }));
103
+ style,
104
+ } = node;
99
105
  return (
100
- <div>
101
- <table>
106
+ <Accordion>
107
+ <table accordiontitle="Column properties">
102
108
  <tbody>
103
109
  <tr>
104
110
  <td colSpan="3">
@@ -171,18 +177,22 @@ const ColumnsSettings = () => {
171
177
  ))}
172
178
  </tbody>
173
179
  </table>
174
- </div>
180
+ <div accordiontitle="Box" className="w-100">
181
+ <BoxModelEditor setProp={setProp} node={node} sizeWithStyle={true} />
182
+ </div>
183
+ </Accordion>
175
184
  );
176
185
  };
177
186
 
178
- /**
179
- * @type {object}
187
+ /**
188
+ * @type {object}
180
189
  */
181
190
  Columns.craft = {
182
191
  displayName: "Columns",
183
192
  defaultProps: {
184
193
  widths: [6],
185
194
  ncols: 2,
195
+ style: {},
186
196
  breakpoints: ["sm", "sm"],
187
197
  },
188
198
  related: {
@@ -10,10 +10,11 @@ import optionsCtx from "../context";
10
10
  import previewCtx from "../preview_context";
11
11
  import {
12
12
  blockProps,
13
- BlockSetting,
13
+ BlockOrInlineSetting,
14
14
  TextStyleRow,
15
15
  ConfigForm,
16
16
  setInitialConfig,
17
+ isBlock,
17
18
  fetchFieldPreview,
18
19
  } from "./utils";
19
20
 
@@ -27,9 +28,16 @@ export /**
27
28
  * @returns {div}
28
29
  * @category saltcorn-builder
29
30
  * @subcategory components
30
- * @namespace
31
+ * @namespace
31
32
  */
32
- const Field = ({ name, fieldview, block, textStyle, configuration }) => {
33
+ const Field = ({
34
+ name,
35
+ fieldview,
36
+ block,
37
+ inline,
38
+ textStyle,
39
+ configuration,
40
+ }) => {
33
41
  const {
34
42
  selected,
35
43
  node_id,
@@ -52,7 +60,7 @@ const Field = ({ name, fieldview, block, textStyle, configuration }) => {
52
60
  return (
53
61
  <div
54
62
  className={`${textStyle} ${selected ? "selected-node" : ""} ${
55
- block ? "" : "d-inline-block"
63
+ isBlock(block, inline, textStyle) ? "d-block" : "d-inline-block"
56
64
  }`}
57
65
  ref={(dom) => connect(drag(dom))}
58
66
  >
@@ -80,6 +88,7 @@ const FieldSettings = () => {
80
88
  name,
81
89
  fieldview,
82
90
  block,
91
+ inline,
83
92
  configuration,
84
93
  node_id,
85
94
  textStyle,
@@ -87,6 +96,7 @@ const FieldSettings = () => {
87
96
  name: node.data.props.name,
88
97
  fieldview: node.data.props.fieldview,
89
98
  block: node.data.props.block,
99
+ inline: node.data.props.inline,
90
100
  textStyle: node.data.props.textStyle,
91
101
  configuration: node.data.props.configuration,
92
102
  node_id: node.id,
@@ -177,7 +187,12 @@ const FieldSettings = () => {
177
187
  <tr>
178
188
  <td></td>
179
189
  <td>
180
- <BlockSetting block={block} setProp={setProp} />
190
+ <BlockOrInlineSetting
191
+ block={block}
192
+ inline={inline}
193
+ textStyle={textStyle}
194
+ setProp={setProp}
195
+ />
181
196
  </td>
182
197
  </tr>
183
198
  {!(handlesTextStyle && handlesTextStyle.includes(fieldview)) && (
@@ -197,8 +212,8 @@ const FieldSettings = () => {
197
212
  );
198
213
  };
199
214
 
200
- /**
201
- * @type {object}
215
+ /**
216
+ * @type {object}
202
217
  */
203
218
  Field.craft = {
204
219
  displayName: "Field",
@@ -211,6 +226,7 @@ Field.craft = {
211
226
  "fieldview",
212
227
  "textStyle",
213
228
  "block",
229
+ "inline",
214
230
  { name: "configuration", default: {} },
215
231
  ],
216
232
  },