@saltcorn/builder 1.1.4-alpha.1 → 1.1.4-alpha.2

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": "1.1.4-alpha.1",
3
+ "version": "1.1.4-alpha.2",
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",
@@ -20,7 +20,7 @@
20
20
  "@babel/preset-react": "7.24.7",
21
21
  "@craftjs/core": "0.1.0-beta.20",
22
22
  "@craftjs/utils": "0.1.0-beta.20",
23
- "@saltcorn/common-code": "1.1.4-alpha.1",
23
+ "@saltcorn/common-code": "1.1.4-alpha.2",
24
24
  "saltcorn-craft-layers-noeye": "0.1.0-beta.22",
25
25
  "@fonticonpicker/react-fonticonpicker": "1.2.0",
26
26
  "@fortawesome/fontawesome-svg-core": "1.2.34",
@@ -86,6 +86,7 @@ const Columns = ({
86
86
  vAligns,
87
87
  colClasses,
88
88
  colStyles,
89
+ customClass,
89
90
  }) => {
90
91
  const {
91
92
  selected,
@@ -93,7 +94,7 @@ const Columns = ({
93
94
  } = useNode((node) => ({ selected: node.events.selected }));
94
95
  return (
95
96
  <div
96
- className={`row builder-columns ${selected ? "selected-node" : ""} ${
97
+ className={`row builder-columns ${customClass || ""} ${selected ? "selected-node" : ""} ${
97
98
  typeof gx !== "undefined" && gx !== null ? `gx-${gx}` : ""
98
99
  } ${typeof gy !== "undefined" && gy !== null ? `gy-${gy}` : ""}`}
99
100
  ref={(dom) => connect(drag(dom))}
@@ -135,6 +136,7 @@ const ColumnsSettings = () => {
135
136
  aligns: node.data.props.aligns,
136
137
  colClasses: node.data.props.colClasses,
137
138
  colStyles: node.data.props.colStyles,
139
+ customClass: node.data.props.customClass,
138
140
  }));
139
141
  const {
140
142
  actions: { setProp },
@@ -147,6 +149,7 @@ const ColumnsSettings = () => {
147
149
  aligns,
148
150
  colClasses,
149
151
  colStyles,
152
+ customClass,
150
153
  } = node;
151
154
  const colSetsNode = {
152
155
  vAlign: vAligns?.[setting_col_n - 1],
@@ -326,7 +329,7 @@ const ColumnsSettings = () => {
326
329
  </tbody>
327
330
  </table>
328
331
  </div>
329
- <table className="w-100" accordiontitle="Gutters">
332
+ <table className="w-100" accordiontitle="Gutters and class">
330
333
  <tbody>
331
334
  <SettingsRow
332
335
  field={{
@@ -346,6 +349,15 @@ const ColumnsSettings = () => {
346
349
  node={node}
347
350
  setProp={setProp}
348
351
  />
352
+ <SettingsRow
353
+ field={{
354
+ name: "customClass",
355
+ label: "Custom class",
356
+ type: "String",
357
+ }}
358
+ node={node}
359
+ setProp={setProp}
360
+ />
349
361
  </tbody>
350
362
  </table>
351
363
  <div accordiontitle="Box" className="w-100">
@@ -366,6 +378,7 @@ Columns.craft = {
366
378
  style: {},
367
379
  breakpoints: ["sm", "sm"],
368
380
  setting_col_n: 1,
381
+ customClass: "",
369
382
  },
370
383
  related: {
371
384
  settings: ColumnsSettings,
@@ -33,6 +33,7 @@ const Table = ({
33
33
  bs_bordered,
34
34
  bs_borderless,
35
35
  bs_wauto,
36
+ customClass
36
37
  }) => {
37
38
  const {
38
39
  selected,
@@ -40,7 +41,7 @@ const Table = ({
40
41
  } = useNode((node) => ({ selected: node.events.selected }));
41
42
  return (
42
43
  <table
43
- className={`${selected ? "selected-node" : ""} ${
44
+ className={`${selected ? "selected-node" : ""} ${customClass} ${
44
45
  bs_style ? "table" : ""
45
46
  } ${bs_style && bs_small ? "table-sm" : ""} ${
46
47
  bs_style && bs_striped ? "table-striped" : ""
@@ -79,6 +80,11 @@ const fields = [
79
80
  type: "Integer",
80
81
  attributes: { min: 0 },
81
82
  },
83
+ {
84
+ name: "customClass",
85
+ label: "Custom class",
86
+ type: "String",
87
+ },
82
88
  {
83
89
  label: "Bootstrap style",
84
90
  name: "bs_style",
@@ -545,6 +545,9 @@ const fetchPreview = ({ url, body, options, setPreviews, node_id, isView }) => {
545
545
  }
546
546
  const newHtml = $(".preview-scratchpad").html();
547
547
  setPreviews((prevState) => ({ ...prevState, [node_id]: newHtml }));
548
+
549
+ // for react-view previews
550
+ document.dispatchEvent(new Event("preview-loaded"));
548
551
  })
549
552
  .catch((e) => {
550
553
  console.log("Unable to fetch the preview:");
@@ -248,8 +248,8 @@ const layoutToNodes = (
248
248
  (segment.block === true
249
249
  ? "block"
250
250
  : segment.block === false
251
- ? "inline-block"
252
- : "block")
251
+ ? "inline-block"
252
+ : "block")
253
253
  }
254
254
  fullPageWidth={
255
255
  typeof segment.fullPageWidth === "undefined"
@@ -314,6 +314,7 @@ const layoutToNodes = (
314
314
  rows={segment.rows || 2}
315
315
  columns={segment.columns || 2}
316
316
  bs_style={segment.bs_style || false}
317
+ customClass={segment.customClass}
317
318
  bs_small={segment.bs_small || false}
318
319
  bs_striped={segment.bs_striped || false}
319
320
  bs_bordered={segment.bs_bordered || false}
@@ -357,6 +358,7 @@ const layoutToNodes = (
357
358
  style={segment.style || {}}
358
359
  gx={segment.gx}
359
360
  gy={segment.gy}
361
+ customClass={segment.customClass}
360
362
  vAligns={segment.vAligns}
361
363
  colClasses={segment.colClasses}
362
364
  colStyles={segment.colStyles}
@@ -392,6 +394,7 @@ const layoutToNodes = (
392
394
  style={segment.style || {}}
393
395
  gx={segment.gx}
394
396
  gy={segment.gy}
397
+ customClass={segment.customClass}
395
398
  vAligns={segment.vAligns}
396
399
  colClasses={segment.colClasses}
397
400
  colStyles={segment.colStyles}
@@ -602,6 +605,7 @@ const craftToSaltcorn = (nodes, startFrom = "ROOT", options) => {
602
605
  columns,
603
606
  contents,
604
607
  bs_style: node.props.bs_style,
608
+ customClass: node.props.customClass,
605
609
  bs_small: node.props.bs_small,
606
610
  bs_striped: node.props.bs_striped,
607
611
  bs_bordered: node.props.bs_bordered,
@@ -616,6 +620,7 @@ const craftToSaltcorn = (nodes, startFrom = "ROOT", options) => {
616
620
  return {
617
621
  besides: widths.map((w, ix) => go(nodes[node.linkedNodes["Col" + ix]])),
618
622
  breakpoints: node.props.breakpoints,
623
+ customClass: node.props.customClass,
619
624
  gx: +node.props.gx,
620
625
  gy: +node.props.gy,
621
626
  aligns: node.props.aligns,