@saltcorn/builder 0.7.4-beta.3 → 0.8.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.
@@ -83,220 +83,221 @@ export /**
83
83
  * @subcategory components
84
84
  * @namespace
85
85
  */
86
- const layoutToNodes = (layout, query, actions, parent = "ROOT") => {
87
- //console.log("layoutToNodes", JSON.stringify(layout));
88
- /**
89
- * @param {object} segment
90
- * @param {string} ix
91
- * @returns {Element|Text|View|Action|Tabs|Columns}
92
- */
93
- function toTag(segment, ix) {
94
- if (!segment) return <Empty key={ix} />;
86
+ const layoutToNodes = (layout, query, actions, parent = "ROOT") => {
87
+ //console.log("layoutToNodes", JSON.stringify(layout));
88
+ /**
89
+ * @param {object} segment
90
+ * @param {string} ix
91
+ * @returns {Element|Text|View|Action|Tabs|Columns}
92
+ */
93
+ function toTag(segment, ix) {
94
+ if (!segment) return <Empty key={ix} />;
95
95
 
96
- const MatchElement = allElements.find(
97
- (e) =>
98
- e.craft.related &&
99
- e.craft.related.fields &&
100
- e.craft.related.segment_type &&
101
- e.craft.related.segment_type == segment.type &&
102
- (!e.craft.related.segment_match ||
103
- e.craft.related.segment_match(segment))
104
- );
105
- if (MatchElement) {
106
- const related = MatchElement.craft.related;
107
- const props = {};
108
- related.fields.forEach((f) => {
109
- const v = segment[f.segment_name || f.name || f];
110
- props[f.name || f] = typeof v === "undefined" ? f.default : v;
111
- });
112
- if (related.fields.some((f) => f.canBeFormula))
113
- props.isFormula = segment.isFormula;
114
- if (related.hasContents)
96
+ const MatchElement = allElements.find(
97
+ (e) =>
98
+ e.craft.related &&
99
+ e.craft.related.fields &&
100
+ e.craft.related.segment_type &&
101
+ e.craft.related.segment_type == segment.type &&
102
+ (!e.craft.related.segment_match ||
103
+ e.craft.related.segment_match(segment))
104
+ );
105
+ if (MatchElement) {
106
+ const related = MatchElement.craft.related;
107
+ const props = {};
108
+ related.fields.forEach((f) => {
109
+ const v = segment[f.segment_name || f.name || f];
110
+ props[f.name || f] = typeof v === "undefined" ? f.default : v;
111
+ });
112
+ if (related.fields.some((f) => f.canBeFormula))
113
+ props.isFormula = segment.isFormula;
114
+ if (related.hasContents)
115
+ return (
116
+ <Element key={ix} canvas {...props} is={MatchElement}>
117
+ {toTag(segment.contents)}
118
+ </Element>
119
+ );
120
+ else return <MatchElement key={ix} {...props} />;
121
+ }
122
+
123
+ if (segment.type === "blank") {
124
+ return (
125
+ <Text
126
+ key={ix}
127
+ text={segment.contents}
128
+ isFormula={segment.isFormula || {}}
129
+ block={segment.block || false}
130
+ inline={segment.inline || false}
131
+ textStyle={segment.textStyle || ""}
132
+ labelFor={segment.labelFor || ""}
133
+ style={segment.style || {}}
134
+ icon={segment.icon}
135
+ font={segment.font || ""}
136
+ />
137
+ );
138
+ } else if (segment.type === "view") {
115
139
  return (
116
- <Element key={ix} canvas {...props} is={MatchElement}>
140
+ <View
141
+ key={ix}
142
+ view={segment.view}
143
+ view_name={segment.view_name}
144
+ name={segment.name}
145
+ state={segment.state}
146
+ extra_state_fml={segment.extra_state_fml}
147
+ configuration={segment.configuration || {}}
148
+ />
149
+ );
150
+ } else if (segment.type === "action") {
151
+ return (
152
+ <Action
153
+ key={ix}
154
+ name={segment.action_name}
155
+ rndid={segment.rndid || "not_assigned"}
156
+ action_label={segment.action_label || ""}
157
+ action_style={segment.action_style || "btn-primary"}
158
+ action_size={segment.action_size || ""}
159
+ action_icon={segment.action_icon || ""}
160
+ action_bgcol={segment.action_bgcol || ""}
161
+ action_bordercol={segment.action_bordercol || ""}
162
+ action_textcol={segment.action_textcol || ""}
163
+ confirm={segment.confirm}
164
+ configuration={segment.configuration || {}}
165
+ block={segment.block || false}
166
+ minRole={segment.minRole || 10}
167
+ isFormula={segment.isFormula || {}}
168
+ />
169
+ );
170
+ } else if (segment.type === "container") {
171
+ return (
172
+ <Element
173
+ key={ix}
174
+ canvas
175
+ gradStartColor={segment.gradStartColor}
176
+ gradEndColor={segment.gradEndColor}
177
+ gradDirection={segment.gradDirection}
178
+ rotate={segment.rotate || 0}
179
+ customClass={segment.customClass}
180
+ customCSS={segment.customCSS}
181
+ overflow={segment.overflow}
182
+ margin={segment.margin || [0, 0, 0, 0]}
183
+ padding={segment.padding || [0, 0, 0, 0]}
184
+ minHeight={segment.minHeight}
185
+ height={segment.height}
186
+ width={segment.width}
187
+ url={segment.url}
188
+ hoverColor={segment.hoverColor}
189
+ minHeightUnit={segment.minHeightUnit || "px"}
190
+ heightUnit={segment.heightUnit || "px"}
191
+ widthUnit={segment.widthUnit || "px"}
192
+ vAlign={segment.vAlign}
193
+ hAlign={segment.hAlign}
194
+ htmlElement={segment.htmlElement || "div"}
195
+ display={
196
+ segment.display ||
197
+ (segment.block === true
198
+ ? "block"
199
+ : segment.block === false
200
+ ? "inline-block"
201
+ : "block")
202
+ }
203
+ fullPageWidth={
204
+ typeof segment.fullPageWidth === "undefined"
205
+ ? false
206
+ : segment.fullPageWidth
207
+ }
208
+ bgFileId={segment.bgFileId}
209
+ imageSize={segment.imageSize || "contain"}
210
+ imgResponsiveWidths={segment.imgResponsiveWidths}
211
+ bgType={segment.bgType || "None"}
212
+ style={segment.style || {}}
213
+ bgColor={segment.bgColor || "#ffffff"}
214
+ setTextColor={!!segment.setTextColor}
215
+ textColor={segment.textColor || "#000000"}
216
+ isFormula={segment.isFormula || {}}
217
+ showIfFormula={segment.showIfFormula || ""}
218
+ showForRole={segment.showForRole || []}
219
+ minScreenWidth={segment.minScreenWidth || ""}
220
+ maxScreenWidth={segment.maxScreenWidth || ""}
221
+ show_for_owner={!!segment.show_for_owner}
222
+ is={Container}
223
+ >
117
224
  {toTag(segment.contents)}
118
225
  </Element>
119
226
  );
120
- else return <MatchElement key={ix} {...props} />;
121
- }
122
-
123
- if (segment.type === "blank") {
124
- return (
125
- <Text
126
- key={ix}
127
- text={segment.contents}
128
- isFormula={segment.isFormula || {}}
129
- block={segment.block || false}
130
- inline={segment.inline || false}
131
- textStyle={segment.textStyle || ""}
132
- labelFor={segment.labelFor || ""}
133
- style={segment.style || {}}
134
- icon={segment.icon}
135
- font={segment.font || ""}
136
- />
137
- );
138
- } else if (segment.type === "view") {
139
- return (
140
- <View
141
- key={ix}
142
- view={segment.view}
143
- name={segment.name}
144
- state={segment.state}
145
- extra_state_fml={segment.extra_state_fml}
146
- configuration={segment.configuration || {}}
147
- />
148
- );
149
- } else if (segment.type === "action") {
150
- return (
151
- <Action
152
- key={ix}
153
- name={segment.action_name}
154
- rndid={segment.rndid || "not_assigned"}
155
- action_label={segment.action_label || ""}
156
- action_style={segment.action_style || "btn-primary"}
157
- action_size={segment.action_size || ""}
158
- action_icon={segment.action_icon || ""}
159
- action_bgcol={segment.action_bgcol || ""}
160
- action_bordercol={segment.action_bordercol || ""}
161
- action_textcol={segment.action_textcol || ""}
162
- confirm={segment.confirm}
163
- configuration={segment.configuration || {}}
164
- block={segment.block || false}
165
- minRole={segment.minRole || 10}
166
- isFormula={segment.isFormula || {}}
167
- />
168
- );
169
- } else if (segment.type === "container") {
170
- return (
171
- <Element
172
- key={ix}
173
- canvas
174
- gradStartColor={segment.gradStartColor}
175
- gradEndColor={segment.gradEndColor}
176
- gradDirection={segment.gradDirection}
177
- rotate={segment.rotate || 0}
178
- customClass={segment.customClass}
179
- customCSS={segment.customCSS}
180
- overflow={segment.overflow}
181
- margin={segment.margin || [0, 0, 0, 0]}
182
- padding={segment.padding || [0, 0, 0, 0]}
183
- minHeight={segment.minHeight}
184
- height={segment.height}
185
- width={segment.width}
186
- url={segment.url}
187
- hoverColor={segment.hoverColor}
188
- minHeightUnit={segment.minHeightUnit || "px"}
189
- heightUnit={segment.heightUnit || "px"}
190
- widthUnit={segment.widthUnit || "px"}
191
- vAlign={segment.vAlign}
192
- hAlign={segment.hAlign}
193
- htmlElement={segment.htmlElement || "div"}
194
- display={
195
- segment.display ||
196
- (segment.block === true
197
- ? "block"
198
- : segment.block === false
199
- ? "inline-block"
200
- : "block")
201
- }
202
- fullPageWidth={
203
- typeof segment.fullPageWidth === "undefined"
204
- ? false
205
- : segment.fullPageWidth
206
- }
207
- bgFileId={segment.bgFileId}
208
- imageSize={segment.imageSize || "contain"}
209
- imgResponsiveWidths={segment.imgResponsiveWidths}
210
- bgType={segment.bgType || "None"}
211
- style={segment.style || {}}
212
- bgColor={segment.bgColor || "#ffffff"}
213
- setTextColor={!!segment.setTextColor}
214
- textColor={segment.textColor || "#000000"}
215
- isFormula={segment.isFormula || {}}
216
- showIfFormula={segment.showIfFormula || ""}
217
- showForRole={segment.showForRole || []}
218
- minScreenWidth={segment.minScreenWidth || ""}
219
- maxScreenWidth={segment.maxScreenWidth || ""}
220
- show_for_owner={!!segment.show_for_owner}
221
- is={Container}
222
- >
223
- {toTag(segment.contents)}
224
- </Element>
225
- );
226
- } else if (segment.type === "tabs") {
227
- let contentsArray = segment.contents.map(toTag);
228
- let contents;
229
- if (segment.tabsStyle === "Value switch") {
230
- contents = {};
231
- segment.titles.forEach(({ label, value }, ix) => {
232
- contents[value] = contentsArray[ix];
233
- });
234
- } else contents = contentsArray;
235
- return (
236
- <Tabs
237
- key={ix}
238
- titles={segment.titles}
239
- ntabs={segment.ntabs}
240
- independent={segment.independent}
241
- deeplink={segment.deeplink}
242
- field={segment.field}
243
- tabsStyle={segment.tabsStyle}
244
- contents={contents}
245
- />
246
- );
247
- } else if (segment.besides) {
248
- return (
249
- <Columns
250
- key={ix}
251
- breakpoints={segment.breakpoints || default_breakpoints(segment)}
252
- ncols={segment.besides.length}
253
- widths={getColWidths(segment)}
254
- style={segment.style || {}}
255
- contents={segment.besides.map(toTag)}
256
- />
257
- );
258
- } else if (segment.above) {
259
- return segment.above.map((e, ix) => toTag(e, ix));
260
- }
261
- }
262
-
263
- /**
264
- * @param {object} segment
265
- * @param {object} parent
266
- * @returns {void}
267
- */
268
- function go(segment, parent) {
269
- if (!segment) return;
270
- if (segment.above) {
271
- segment.above.forEach((child) => {
272
- if (child) go(child, parent);
273
- });
274
- } else if (segment.besides) {
275
- const node = query
276
- .parseReactElement(
227
+ } else if (segment.type === "tabs") {
228
+ let contentsArray = segment.contents.map(toTag);
229
+ let contents;
230
+ if (segment.tabsStyle === "Value switch") {
231
+ contents = {};
232
+ segment.titles.forEach(({ label, value }, ix) => {
233
+ contents[value] = contentsArray[ix];
234
+ });
235
+ } else contents = contentsArray;
236
+ return (
237
+ <Tabs
238
+ key={ix}
239
+ titles={segment.titles}
240
+ ntabs={segment.ntabs}
241
+ independent={segment.independent}
242
+ deeplink={segment.deeplink}
243
+ field={segment.field}
244
+ tabsStyle={segment.tabsStyle}
245
+ contents={contents}
246
+ />
247
+ );
248
+ } else if (segment.besides) {
249
+ return (
277
250
  <Columns
278
- widths={getColWidths(segment)}
251
+ key={ix}
279
252
  breakpoints={segment.breakpoints || default_breakpoints(segment)}
280
253
  ncols={segment.besides.length}
254
+ widths={getColWidths(segment)}
281
255
  style={segment.style || {}}
282
256
  contents={segment.besides.map(toTag)}
283
257
  />
284
- )
285
- .toNodeTree();
286
- actions.addNodeTree(node, parent);
287
- } else {
288
- const tag = toTag(segment);
289
- if (tag) {
290
- const node = query.parseReactElement(tag).toNodeTree();
291
- //console.log("other", node);
258
+ );
259
+ } else if (segment.above) {
260
+ return segment.above.map((e, ix) => toTag(e, ix));
261
+ }
262
+ }
263
+
264
+ /**
265
+ * @param {object} segment
266
+ * @param {object} parent
267
+ * @returns {void}
268
+ */
269
+ function go(segment, parent) {
270
+ if (!segment) return;
271
+ if (segment.above) {
272
+ segment.above.forEach((child) => {
273
+ if (child) go(child, parent);
274
+ });
275
+ } else if (segment.besides) {
276
+ const node = query
277
+ .parseReactElement(
278
+ <Columns
279
+ widths={getColWidths(segment)}
280
+ breakpoints={segment.breakpoints || default_breakpoints(segment)}
281
+ ncols={segment.besides.length}
282
+ style={segment.style || {}}
283
+ contents={segment.besides.map(toTag)}
284
+ />
285
+ )
286
+ .toNodeTree();
292
287
  actions.addNodeTree(node, parent);
288
+ } else {
289
+ const tag = toTag(segment);
290
+ if (tag) {
291
+ const node = query.parseReactElement(tag).toNodeTree();
292
+ //console.log("other", node);
293
+ actions.addNodeTree(node, parent);
294
+ }
293
295
  }
294
296
  }
295
- }
296
- //const node1 = query.createNode(toTag(layout));
297
- //actions.add(node1, );
298
- go(layout, parent);
299
- };
297
+ //const node1 = query.createNode(toTag(layout));
298
+ //actions.add(node1, );
299
+ go(layout, parent);
300
+ };
300
301
 
301
302
  /**
302
303
  * @returns {number}
@@ -311,196 +312,196 @@ export /**
311
312
  * @subcategory components
312
313
  * @namespace
313
314
  */
314
- const craftToSaltcorn = (nodes, startFrom = "ROOT") => {
315
- //console.log(JSON.stringify(nodes, null, 2));
316
- var columns = [];
315
+ const craftToSaltcorn = (nodes, startFrom = "ROOT") => {
316
+ //console.log(JSON.stringify(nodes, null, 2));
317
+ var columns = [];
317
318
 
318
- /**
319
- * @param {object} node
320
- * @returns {void|object}
321
- */
322
- const get_nodes = (node) => {
323
- if (!node.nodes || node.nodes.length == 0) return;
324
- else if (node.nodes.length == 1) return go(nodes[node.nodes[0]]);
325
- else return { above: node.nodes.map((nm) => go(nodes[nm])) };
326
- };
319
+ /**
320
+ * @param {object} node
321
+ * @returns {void|object}
322
+ */
323
+ const get_nodes = (node) => {
324
+ if (!node.nodes || node.nodes.length == 0) return;
325
+ else if (node.nodes.length == 1) return go(nodes[node.nodes[0]]);
326
+ else return { above: node.nodes.map((nm) => go(nodes[nm])) };
327
+ };
327
328
 
328
- /**
329
- * @param {object} node
330
- * @returns {object}
331
- */
332
- const go = (node) => {
333
- if (!node) return;
334
- const matchElement = allElements.find(
335
- (e) =>
336
- e.craft.related &&
337
- node.displayName === e.craft.displayName &&
338
- e.craft.related.fields &&
339
- e.craft.related.segment_type
340
- );
341
- if (matchElement) {
342
- const related = matchElement.craft.related;
343
- const s = { type: related.segment_type };
344
- if (related.hasContents) s.contents = get_nodes(node);
345
- related.fields.forEach((f) => {
346
- s[f.segment_name || f.name || f] = node.props[f.name || f];
347
- });
348
- if (related.fields.some((f) => f.canBeFormula))
349
- s.isFormula = node.props.isFormula;
350
- if (related.segment_vars) Object.assign(s, related.segment_vars);
351
- if (related.column_type) {
352
- const c = { type: related.column_type };
329
+ /**
330
+ * @param {object} node
331
+ * @returns {object}
332
+ */
333
+ const go = (node) => {
334
+ if (!node) return;
335
+ const matchElement = allElements.find(
336
+ (e) =>
337
+ e.craft.related &&
338
+ node.displayName === e.craft.displayName &&
339
+ e.craft.related.fields &&
340
+ e.craft.related.segment_type
341
+ );
342
+ if (matchElement) {
343
+ const related = matchElement.craft.related;
344
+ const s = { type: related.segment_type };
345
+ if (related.hasContents) s.contents = get_nodes(node);
353
346
  related.fields.forEach((f) => {
354
- c[f.column_name || f.name || f] = node.props[f.name || f];
347
+ s[f.segment_name || f.name || f] = node.props[f.name || f];
355
348
  });
356
- columns.push(c);
349
+ if (related.fields.some((f) => f.canBeFormula))
350
+ s.isFormula = node.props.isFormula;
351
+ if (related.segment_vars) Object.assign(s, related.segment_vars);
352
+ if (related.column_type) {
353
+ const c = { type: related.column_type };
354
+ related.fields.forEach((f) => {
355
+ c[f.column_name || f.name || f] = node.props[f.name || f];
356
+ });
357
+ columns.push(c);
358
+ }
359
+ return s;
357
360
  }
358
- return s;
359
- }
360
- if (node.isCanvas) {
361
- if (node.displayName === Container.craft.displayName)
361
+ if (node.isCanvas) {
362
+ if (node.displayName === Container.craft.displayName)
363
+ return {
364
+ contents: get_nodes(node),
365
+ type: "container",
366
+ customCSS: node.props.customCSS,
367
+ customClass: node.props.customClass,
368
+ minHeight: node.props.minHeight,
369
+ height: node.props.height,
370
+ width: node.props.width,
371
+ url: node.props.url,
372
+ hoverColor: node.props.hoverColor,
373
+ minHeightUnit: node.props.minHeightUnit,
374
+ heightUnit: node.props.heightUnit,
375
+ widthUnit: node.props.widthUnit,
376
+ vAlign: node.props.vAlign,
377
+ hAlign: node.props.hAlign,
378
+ htmlElement: node.props.htmlElement,
379
+ margin: node.props.margin,
380
+ padding: node.props.padding,
381
+ overflow: node.props.overflow,
382
+ display: node.props.display,
383
+ fullPageWidth: node.props.fullPageWidth || false,
384
+ bgFileId: node.props.bgFileId,
385
+ bgType: node.props.bgType,
386
+ imageSize: node.props.imageSize,
387
+ imgResponsiveWidths: node.props.imgResponsiveWidths,
388
+ bgColor: node.props.bgColor,
389
+ setTextColor: node.props.setTextColor,
390
+ textColor: node.props.textColor,
391
+ isFormula: node.props.isFormula,
392
+ showIfFormula: node.props.showIfFormula,
393
+ showForRole: node.props.showForRole,
394
+ minScreenWidth: node.props.minScreenWidth,
395
+ maxScreenWidth: node.props.maxScreenWidth,
396
+ show_for_owner: node.props.show_for_owner,
397
+ gradStartColor: node.props.gradStartColor,
398
+ gradEndColor: node.props.gradEndColor,
399
+ gradDirection: node.props.gradDirection,
400
+ rotate: node.props.rotate,
401
+ style: node.props.style,
402
+ };
403
+ else return get_nodes(node);
404
+ }
405
+
406
+ if (node.displayName === Text.craft.displayName) {
362
407
  return {
363
- contents: get_nodes(node),
364
- type: "container",
365
- customCSS: node.props.customCSS,
366
- customClass: node.props.customClass,
367
- minHeight: node.props.minHeight,
368
- height: node.props.height,
369
- width: node.props.width,
370
- url: node.props.url,
371
- hoverColor: node.props.hoverColor,
372
- minHeightUnit: node.props.minHeightUnit,
373
- heightUnit: node.props.heightUnit,
374
- widthUnit: node.props.widthUnit,
375
- vAlign: node.props.vAlign,
376
- hAlign: node.props.hAlign,
377
- htmlElement: node.props.htmlElement,
378
- margin: node.props.margin,
379
- padding: node.props.padding,
380
- overflow: node.props.overflow,
381
- display: node.props.display,
382
- fullPageWidth: node.props.fullPageWidth || false,
383
- bgFileId: node.props.bgFileId,
384
- bgType: node.props.bgType,
385
- imageSize: node.props.imageSize,
386
- imgResponsiveWidths: node.props.imgResponsiveWidths,
387
- bgColor: node.props.bgColor,
388
- setTextColor: node.props.setTextColor,
389
- textColor: node.props.textColor,
408
+ type: "blank",
409
+ contents: node.props.text,
410
+ block: node.props.block,
411
+ inline: node.props.inline,
412
+ textStyle: node.props.textStyle,
390
413
  isFormula: node.props.isFormula,
391
- showIfFormula: node.props.showIfFormula,
392
- showForRole: node.props.showForRole,
393
- minScreenWidth: node.props.minScreenWidth,
394
- maxScreenWidth: node.props.maxScreenWidth,
395
- show_for_owner: node.props.show_for_owner,
396
- gradStartColor: node.props.gradStartColor,
397
- gradEndColor: node.props.gradEndColor,
398
- gradDirection: node.props.gradDirection,
399
- rotate: node.props.rotate,
414
+ labelFor: node.props.labelFor,
400
415
  style: node.props.style,
416
+ icon: node.props.icon,
417
+ font: node.props.font,
401
418
  };
402
- else return get_nodes(node);
403
- }
404
-
405
- if (node.displayName === Text.craft.displayName) {
406
- return {
407
- type: "blank",
408
- contents: node.props.text,
409
- block: node.props.block,
410
- inline: node.props.inline,
411
- textStyle: node.props.textStyle,
412
- isFormula: node.props.isFormula,
413
- labelFor: node.props.labelFor,
414
- style: node.props.style,
415
- icon: node.props.icon,
416
- font: node.props.font,
417
- };
418
- }
419
+ }
419
420
 
420
- if (node.displayName === Columns.craft.displayName) {
421
- const widths = [...node.props.widths, 12 - sum(node.props.widths)];
422
- return {
423
- besides: widths.map((w, ix) => go(nodes[node.linkedNodes["Col" + ix]])),
424
- breakpoints: node.props.breakpoints,
425
- style: node.props.style,
426
- widths,
427
- };
428
- }
429
- if (node.displayName === Tabs.craft.displayName) {
430
- let contents;
431
- if (node.props.tabsStyle === "Value switch") {
432
- contents = node.props.titles.map(({ value }, ix) => {
433
- const useIx = typeof value === "undefined" ? ix : value;
434
- return go(nodes[node.linkedNodes["Tab" + useIx]]);
435
- });
436
- } else
437
- contents = ntimes(node.props.ntabs, (ix) =>
438
- go(nodes[node.linkedNodes["Tab" + ix]])
439
- );
440
- return {
441
- type: "tabs",
442
- contents,
443
- titles: node.props.titles,
444
- tabsStyle: node.props.tabsStyle,
445
- field: node.props.field,
446
- independent: node.props.independent,
447
- deeplink: node.props.deeplink,
448
- ntabs: node.props.ntabs,
449
- };
450
- }
421
+ if (node.displayName === Columns.craft.displayName) {
422
+ const widths = [...node.props.widths, 12 - sum(node.props.widths)];
423
+ return {
424
+ besides: widths.map((w, ix) => go(nodes[node.linkedNodes["Col" + ix]])),
425
+ breakpoints: node.props.breakpoints,
426
+ style: node.props.style,
427
+ widths,
428
+ };
429
+ }
430
+ if (node.displayName === Tabs.craft.displayName) {
431
+ let contents;
432
+ if (node.props.tabsStyle === "Value switch") {
433
+ contents = node.props.titles.map(({ value }, ix) => {
434
+ const useIx = typeof value === "undefined" ? ix : value;
435
+ return go(nodes[node.linkedNodes["Tab" + useIx]]);
436
+ });
437
+ } else
438
+ contents = ntimes(node.props.ntabs, (ix) =>
439
+ go(nodes[node.linkedNodes["Tab" + ix]])
440
+ );
441
+ return {
442
+ type: "tabs",
443
+ contents,
444
+ titles: node.props.titles,
445
+ tabsStyle: node.props.tabsStyle,
446
+ field: node.props.field,
447
+ independent: node.props.independent,
448
+ deeplink: node.props.deeplink,
449
+ ntabs: node.props.ntabs,
450
+ };
451
+ }
451
452
 
452
- if (node.displayName === View.craft.displayName) {
453
- return {
454
- type: "view",
455
- view: node.props.view,
456
- name:
457
- node.props.name === "not_assigned" ? rand_ident() : node.props.name,
458
- state: node.props.state,
459
- configuration: node.props.configuration,
460
- extra_state_fml: node.props.extra_state_fml,
461
- };
462
- }
453
+ if (node.displayName === View.craft.displayName) {
454
+ return {
455
+ type: "view",
456
+ view: node.props.view,
457
+ name:
458
+ node.props.name === "not_assigned" ? rand_ident() : node.props.name,
459
+ state: node.props.state,
460
+ configuration: node.props.configuration,
461
+ extra_state_fml: node.props.extra_state_fml,
462
+ };
463
+ }
463
464
 
464
- if (node.displayName === Action.craft.displayName) {
465
- const newid = rand_ident();
466
- columns.push({
467
- type: "Action",
468
- action_name: node.props.name,
469
- action_label: node.props.action_label,
470
- action_style: node.props.action_style,
471
- action_size: node.props.action_size,
472
- action_icon: node.props.action_icon,
473
- action_bgcol: node.props.action_bgcol,
474
- action_bordercol: node.props.action_bordercol,
475
- action_textcol: node.props.action_textcol,
476
- minRole: node.props.minRole,
477
- confirm: node.props.confirm,
478
- configuration: node.props.configuration,
479
- isFormula: node.props.isFormula,
480
- rndid: node.props.rndid === "not_assigned" ? newid : node.props.rndid,
481
- });
482
- return {
483
- type: "action",
484
- block: node.props.block,
485
- configuration: node.props.configuration,
486
- confirm: node.props.confirm,
487
- action_name: node.props.name,
488
- action_label: node.props.action_label,
489
- action_style: node.props.action_style,
490
- action_size: node.props.action_size,
491
- action_icon: node.props.action_icon,
492
- action_bgcol: node.props.action_bgcol,
493
- action_bordercol: node.props.action_bordercol,
494
- action_textcol: node.props.action_textcol,
495
- minRole: node.props.minRole,
496
- isFormula: node.props.isFormula,
497
- rndid: node.props.rndid === "not_assigned" ? newid : node.props.rndid,
498
- };
499
- }
465
+ if (node.displayName === Action.craft.displayName) {
466
+ const newid = rand_ident();
467
+ columns.push({
468
+ type: "Action",
469
+ action_name: node.props.name,
470
+ action_label: node.props.action_label,
471
+ action_style: node.props.action_style,
472
+ action_size: node.props.action_size,
473
+ action_icon: node.props.action_icon,
474
+ action_bgcol: node.props.action_bgcol,
475
+ action_bordercol: node.props.action_bordercol,
476
+ action_textcol: node.props.action_textcol,
477
+ minRole: node.props.minRole,
478
+ confirm: node.props.confirm,
479
+ configuration: node.props.configuration,
480
+ isFormula: node.props.isFormula,
481
+ rndid: node.props.rndid === "not_assigned" ? newid : node.props.rndid,
482
+ });
483
+ return {
484
+ type: "action",
485
+ block: node.props.block,
486
+ configuration: node.props.configuration,
487
+ confirm: node.props.confirm,
488
+ action_name: node.props.name,
489
+ action_label: node.props.action_label,
490
+ action_style: node.props.action_style,
491
+ action_size: node.props.action_size,
492
+ action_icon: node.props.action_icon,
493
+ action_bgcol: node.props.action_bgcol,
494
+ action_bordercol: node.props.action_bordercol,
495
+ action_textcol: node.props.action_textcol,
496
+ minRole: node.props.minRole,
497
+ isFormula: node.props.isFormula,
498
+ rndid: node.props.rndid === "not_assigned" ? newid : node.props.rndid,
499
+ };
500
+ }
501
+ };
502
+ const layout = go(nodes[startFrom]) || { type: "blank", contents: "" };
503
+ /*console.log("nodes", JSON.stringify(nodes));
504
+ console.log("cols", JSON.stringify(columns));
505
+ console.log("layout", JSON.stringify(layout));*/
506
+ return { columns, layout };
500
507
  };
501
- const layout = go(nodes[startFrom]) || { type: "blank", contents: "" };
502
- /*console.log("nodes", JSON.stringify(nodes));
503
- console.log("cols", JSON.stringify(columns));
504
- console.log("layout", JSON.stringify(layout));*/
505
- return { columns, layout };
506
- };