@saltcorn/builder 0.5.6-beta.3 → 0.6.0-beta.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.
@@ -56,7 +56,7 @@ const allElements = [
56
56
  ToggleFilter,
57
57
  ];
58
58
 
59
- export const layoutToNodes = (layout, query, actions) => {
59
+ export const layoutToNodes = (layout, query, actions, parent = "ROOT") => {
60
60
  //console.log("layoutToNodes", JSON.stringify(layout));
61
61
  function toTag(segment, ix) {
62
62
  if (!segment) return <Empty key={ix} />;
@@ -98,6 +98,7 @@ export const layoutToNodes = (layout, query, actions) => {
98
98
  textStyle={segment.textStyle || ""}
99
99
  labelFor={segment.labelFor || ""}
100
100
  icon={segment.icon}
101
+ font={segment.font || ""}
101
102
  />
102
103
  );
103
104
  } else if (segment.type === "view") {
@@ -107,6 +108,7 @@ export const layoutToNodes = (layout, query, actions) => {
107
108
  view={segment.view}
108
109
  name={segment.name}
109
110
  state={segment.state}
111
+ configuration={segment.configuration || {}}
110
112
  />
111
113
  );
112
114
  } else if (segment.type === "action") {
@@ -119,6 +121,9 @@ export const layoutToNodes = (layout, query, actions) => {
119
121
  action_style={segment.action_style || "btn-primary"}
120
122
  action_size={segment.action_size || ""}
121
123
  action_icon={segment.action_icon || ""}
124
+ action_bgcol={segment.action_bgcol || ""}
125
+ action_bordercol={segment.action_bordercol || ""}
126
+ action_textcol={segment.action_textcol || ""}
122
127
  confirm={segment.confirm}
123
128
  configuration={segment.configuration || {}}
124
129
  block={segment.block || false}
@@ -131,15 +136,10 @@ export const layoutToNodes = (layout, query, actions) => {
131
136
  <Element
132
137
  key={ix}
133
138
  canvas
134
- borderWidth={segment.borderWidth}
135
- borderStyle={segment.borderStyle}
136
- borderRadius={segment.borderRadius}
137
- borderDirection={segment.borderDirection}
138
- borderColor={segment.borderColor}
139
- borderRadiusUnit={segment.borderRadiusUnit}
140
139
  gradStartColor={segment.gradStartColor}
141
140
  gradEndColor={segment.gradEndColor}
142
141
  gradDirection={segment.gradDirection}
142
+ rotate={segment.rotate || 0}
143
143
  customClass={segment.customClass}
144
144
  customCSS={segment.customCSS}
145
145
  overflow={segment.overflow}
@@ -155,7 +155,14 @@ export const layoutToNodes = (layout, query, actions) => {
155
155
  widthUnit={segment.widthUnit || "px"}
156
156
  vAlign={segment.vAlign}
157
157
  hAlign={segment.hAlign}
158
- block={typeof segment.block === "undefined" ? true : segment.block}
158
+ display={
159
+ segment.display ||
160
+ (segment.block === true
161
+ ? "block"
162
+ : segment.block === false
163
+ ? "inline-block"
164
+ : "block")
165
+ }
159
166
  fullPageWidth={
160
167
  typeof segment.fullPageWidth === "undefined"
161
168
  ? false
@@ -164,6 +171,7 @@ export const layoutToNodes = (layout, query, actions) => {
164
171
  bgFileId={segment.bgFileId}
165
172
  imageSize={segment.imageSize || "contain"}
166
173
  bgType={segment.bgType || "None"}
174
+ style={segment.style || {}}
167
175
  bgColor={segment.bgColor || "#ffffff"}
168
176
  setTextColor={!!segment.setTextColor}
169
177
  textColor={segment.textColor || "#000000"}
@@ -231,12 +239,12 @@ export const layoutToNodes = (layout, query, actions) => {
231
239
  }
232
240
  //const node1 = query.createNode(toTag(layout));
233
241
  //actions.add(node1, );
234
- go(layout, "ROOT");
242
+ go(layout, parent);
235
243
  };
236
244
 
237
245
  const rand_ident = () => Math.floor(Math.random() * 16777215).toString(16);
238
246
 
239
- export const craftToSaltcorn = (nodes) => {
247
+ export const craftToSaltcorn = (nodes, startFrom = "ROOT") => {
240
248
  //console.log(JSON.stringify(nodes, null, 2));
241
249
  var columns = [];
242
250
  const get_nodes = (node) => {
@@ -276,12 +284,6 @@ export const craftToSaltcorn = (nodes) => {
276
284
  return {
277
285
  contents: get_nodes(node),
278
286
  type: "container",
279
- borderWidth: node.props.borderWidth,
280
- borderStyle: node.props.borderStyle,
281
- borderColor: node.props.borderColor,
282
- borderRadius: node.props.borderRadius,
283
- borderDirection: node.props.borderDirection,
284
- borderRadiusUnit: node.props.borderRadiusUnit,
285
287
  customCSS: node.props.customCSS,
286
288
  customClass: node.props.customClass,
287
289
  minHeight: node.props.minHeight,
@@ -297,7 +299,7 @@ export const craftToSaltcorn = (nodes) => {
297
299
  margin: node.props.margin,
298
300
  padding: node.props.padding,
299
301
  overflow: node.props.overflow,
300
- block: node.props.block || false,
302
+ display: node.props.display,
301
303
  fullPageWidth: node.props.fullPageWidth || false,
302
304
  bgFileId: node.props.bgFileId,
303
305
  bgType: node.props.bgType,
@@ -314,6 +316,8 @@ export const craftToSaltcorn = (nodes) => {
314
316
  gradStartColor: node.props.gradStartColor,
315
317
  gradEndColor: node.props.gradEndColor,
316
318
  gradDirection: node.props.gradDirection,
319
+ rotate: node.props.rotate,
320
+ style: node.props.style,
317
321
  };
318
322
  else return get_nodes(node);
319
323
  }
@@ -327,6 +331,7 @@ export const craftToSaltcorn = (nodes) => {
327
331
  isFormula: node.props.isFormula,
328
332
  labelFor: node.props.labelFor,
329
333
  icon: node.props.icon,
334
+ font: node.props.font,
330
335
  };
331
336
  }
332
337
 
@@ -357,6 +362,7 @@ export const craftToSaltcorn = (nodes) => {
357
362
  name:
358
363
  node.props.name === "not_assigned" ? rand_ident() : node.props.name,
359
364
  state: node.props.state,
365
+ configuration: node.props.configuration,
360
366
  };
361
367
  }
362
368
 
@@ -369,6 +375,9 @@ export const craftToSaltcorn = (nodes) => {
369
375
  action_style: node.props.action_style,
370
376
  action_size: node.props.action_size,
371
377
  action_icon: node.props.action_icon,
378
+ action_bgcol: node.props.action_bgcol,
379
+ action_bordercol: node.props.action_bordercol,
380
+ action_textcol: node.props.action_textcol,
372
381
  minRole: node.props.minRole,
373
382
  confirm: node.props.confirm,
374
383
  configuration: node.props.configuration,
@@ -385,13 +394,16 @@ export const craftToSaltcorn = (nodes) => {
385
394
  action_style: node.props.action_style,
386
395
  action_size: node.props.action_size,
387
396
  action_icon: node.props.action_icon,
397
+ action_bgcol: node.props.action_bgcol,
398
+ action_bordercol: node.props.action_bordercol,
399
+ action_textcol: node.props.action_textcol,
388
400
  minRole: node.props.minRole,
389
401
  isFormula: node.props.isFormula,
390
402
  rndid: node.props.rndid === "not_assigned" ? newid : node.props.rndid,
391
403
  };
392
404
  }
393
405
  };
394
- const layout = go(nodes["ROOT"]) || { type: "blank", contents: "" };
406
+ const layout = go(nodes[startFrom]) || { type: "blank", contents: "" };
395
407
  /*console.log("nodes", JSON.stringify(nodes));
396
408
  console.log("cols", JSON.stringify(columns));
397
409
  console.log("layout", JSON.stringify(layout));*/