@saltcorn/builder 0.9.4-beta.10 → 0.9.4-beta.12

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.9.4-beta.10",
3
+ "version": "0.9.4-beta.12",
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.9.4",
21
21
  "@craftjs/core": "0.1.0-beta.20",
22
22
  "@craftjs/utils": "0.1.0-beta.20",
23
- "@saltcorn/common-code": "0.9.4-beta.10",
23
+ "@saltcorn/common-code": "0.9.4-beta.12",
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",
@@ -124,7 +124,10 @@ const InitNewElement = ({ nodekeys, savingState, setSavingState }) => {
124
124
  });
125
125
  })
126
126
  .catch((e) => {
127
- const text = e || "Unable to save";
127
+ const text =
128
+ e.message === "Failed to fetch"
129
+ ? "Network connection lost"
130
+ : e || "Unable to save";
128
131
  // don't log duplicates
129
132
  if (savingState.error) setSavingState({ isSaving: false, error: text });
130
133
  else {
@@ -61,7 +61,7 @@ const BoxModelEditor = ({ setProp, node, sizeWithStyle }) => {
61
61
  onClick={() => setCatAndDir("margin", "top")}
62
62
  >
63
63
  <input
64
- disabled
64
+ readOnly={true}
65
65
  type="text"
66
66
  autoComplete="off"
67
67
  name="boxmodel-ex-1_top_margin"
@@ -92,7 +92,7 @@ const BoxModelEditor = ({ setProp, node, sizeWithStyle }) => {
92
92
  onClick={() => setCatAndDir("border", "top")}
93
93
  >
94
94
  <input
95
- disabled
95
+ readOnly={true}
96
96
  type="text"
97
97
  autoComplete="off"
98
98
  name="boxmodel-ex-1_top_border"
@@ -125,7 +125,7 @@ const BoxModelEditor = ({ setProp, node, sizeWithStyle }) => {
125
125
  onClick={() => setCatAndDir("padding", "top")}
126
126
  >
127
127
  <input
128
- disabled
128
+ readOnly={true}
129
129
  type="text"
130
130
  autoComplete="off"
131
131
  name="boxmodel-ex-1_top_padding"
@@ -140,7 +140,7 @@ const BoxModelEditor = ({ setProp, node, sizeWithStyle }) => {
140
140
  onClick={() => setSelectedCategory("size")}
141
141
  >
142
142
  <input
143
- disabled
143
+ readOnly={true}
144
144
  type="text"
145
145
  autoComplete="off"
146
146
  name="boxmodel-ex-1_width"
@@ -155,7 +155,7 @@ const BoxModelEditor = ({ setProp, node, sizeWithStyle }) => {
155
155
  />
156
156
  x
157
157
  <input
158
- disabled
158
+ readOnly={true}
159
159
  type="text"
160
160
  autoComplete="off"
161
161
  name="boxmodel-ex-1_height"
@@ -174,7 +174,7 @@ const BoxModelEditor = ({ setProp, node, sizeWithStyle }) => {
174
174
  onClick={() => setCatAndDir("padding", "bottom")}
175
175
  >
176
176
  <input
177
- disabled
177
+ readOnly={true}
178
178
  type="text"
179
179
  autoComplete="off"
180
180
  name="boxmodel-ex-1_bottom_padding"
@@ -199,7 +199,7 @@ const BoxModelEditor = ({ setProp, node, sizeWithStyle }) => {
199
199
  onClick={() => setCatAndDir("border", "bottom")}
200
200
  >
201
201
  <input
202
- disabled
202
+ readOnly={true}
203
203
  type="text"
204
204
  autoComplete="off"
205
205
  name="boxmodel-ex-1_bottom_border"
@@ -228,7 +228,7 @@ const BoxModelEditor = ({ setProp, node, sizeWithStyle }) => {
228
228
  onClick={() => setCatAndDir("margin", "bottom")}
229
229
  >
230
230
  <input
231
- disabled
231
+ readOnly={true}
232
232
  type="text"
233
233
  autoComplete="off"
234
234
  name="boxmodel-ex-1_bottom_margin"
@@ -259,9 +259,9 @@ const ColumnsSettings = () => {
259
259
  label: "Vertical",
260
260
  type: "btn_select",
261
261
  options: [
262
- { value: "start", title: "All", label: <AlignTop /> },
263
- { value: "center", title: "All", label: <AlignMiddle /> },
264
- { value: "end", title: "All", label: <AlignBottom /> },
262
+ { value: "start", title: "Start", label: <AlignTop /> },
263
+ { value: "center", title: "Center", label: <AlignMiddle /> },
264
+ { value: "end", title: "End", label: <AlignBottom /> },
265
265
  ],
266
266
  }}
267
267
  node={colSetsNode}
@@ -222,6 +222,7 @@ const ContainerSettings = () => {
222
222
  display: node.data.props.display,
223
223
  style: node.data.props.style,
224
224
  imgResponsiveWidths: node.data.props.imgResponsiveWidths,
225
+ click_action: node.data.props.click_action,
225
226
  }));
226
227
  const {
227
228
  actions: { setProp },
@@ -251,6 +252,7 @@ const ContainerSettings = () => {
251
252
  overflow,
252
253
  htmlElement,
253
254
  imgResponsiveWidths,
255
+ click_action,
254
256
  } = node;
255
257
  const options = useContext(optionsCtx);
256
258
  const { uploadedFiles } = useContext(previewCtx);
@@ -844,7 +846,29 @@ const ContainerSettings = () => {
844
846
  onChange={setAProp("url")}
845
847
  />
846
848
  </OrFormula>
847
-
849
+ {options.triggerActions ? (
850
+ <Fragment>
851
+ <label>Click action</label>
852
+ <select
853
+ value={click_action}
854
+ className="form-control form-select"
855
+ onChange={(e) => {
856
+ if (!e.target) return;
857
+ const value = e.target.value;
858
+ setProp((prop) => {
859
+ prop.click_action = value;
860
+ });
861
+ }}
862
+ >
863
+ <option value="">None</option>
864
+ {options.triggerActions.map((f, ix) => (
865
+ <option key={ix} value={f}>
866
+ {f}
867
+ </option>
868
+ ))}
869
+ </select>
870
+ </Fragment>
871
+ ) : null}
848
872
  <label>Hover color</label>
849
873
  <select
850
874
  value={hoverColor}
@@ -8,7 +8,11 @@ import React, { Fragment, useState } from "react";
8
8
  import { Element, useNode } from "@craftjs/core";
9
9
  import { Column } from "./Column";
10
10
  import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
11
- import { faCaretDown } from "@fortawesome/free-solid-svg-icons";
11
+ import {
12
+ faCaretDown,
13
+ faCaretSquareLeft,
14
+ faCaretSquareRight,
15
+ } from "@fortawesome/free-solid-svg-icons";
12
16
  import {
13
17
  SettingsRow,
14
18
  BlockSetting,
@@ -36,6 +40,7 @@ const DropMenu = ({
36
40
  action_textcol,
37
41
  block,
38
42
  label,
43
+ menu_direction,
39
44
  }) => {
40
45
  const {
41
46
  selected,
@@ -72,7 +77,7 @@ const DropMenu = ({
72
77
  <div
73
78
  className={`dropdown-menu dropmenu-dropdown ${
74
79
  showDropdown ? "show" : ""
75
- }`}
80
+ } ${menu_direction === "end" ? "dropdown-menu-end" : ""}`}
76
81
  >
77
82
  <div className="canvas d-flex flex-column">{children}</div>
78
83
  </div>
@@ -96,6 +101,7 @@ const DropMenuSettings = () => {
96
101
  action_bgcol: node.data.props.action_bgcol,
97
102
  action_bordercol: node.data.props.action_bordercol,
98
103
  action_textcol: node.data.props.action_textcol,
104
+ menu_direction: node.data.props.menu_direction,
99
105
  }));
100
106
  const {
101
107
  actions: { setProp },
@@ -118,12 +124,34 @@ const DropMenuSettings = () => {
118
124
  setProp={setProp}
119
125
  keyPrefix="action_"
120
126
  values={node}
127
+ allowRunOnLoad={false}
121
128
  />
122
129
  <tr>
123
130
  <td colSpan="2">
124
131
  <BlockSetting block={block} setProp={setProp} />
125
132
  </td>
126
133
  </tr>
134
+ <SettingsRow
135
+ field={{
136
+ label: "Drop direction",
137
+ name: "menu_direction",
138
+ type: "btn_select",
139
+ options: [
140
+ {
141
+ value: "end",
142
+ title: "End",
143
+ label: <FontAwesomeIcon icon={faCaretSquareLeft} />,
144
+ },
145
+ {
146
+ value: "start",
147
+ title: "Start",
148
+ label: <FontAwesomeIcon icon={faCaretSquareRight} />,
149
+ },
150
+ ],
151
+ }}
152
+ node={node}
153
+ setProp={setProp}
154
+ />
127
155
  </tbody>
128
156
  </table>
129
157
  );
@@ -151,6 +179,7 @@ DropMenu.craft = {
151
179
  "action_bgcol",
152
180
  "action_bordercol",
153
181
  "action_textcol",
182
+ "menu_direction",
154
183
  ],
155
184
  },
156
185
  };
@@ -281,6 +281,7 @@ const LinkSettings = () => {
281
281
  values={node}
282
282
  linkFirst={true}
283
283
  linkIsBlank={true}
284
+ allowRunOnLoad={false}
284
285
  />
285
286
  </tbody>
286
287
  </table>
@@ -185,6 +185,7 @@ const TabsSettings = () => {
185
185
  titles: node.data.props.titles,
186
186
  showif: node.data.props.showif,
187
187
  field: node.data.props.field,
188
+ acc_init_opens: node.data.props.acc_init_opens,
188
189
  }));
189
190
  const {
190
191
  actions: { setProp },
@@ -200,6 +201,7 @@ const TabsSettings = () => {
200
201
  tabId,
201
202
  showif,
202
203
  setting_tab_n,
204
+ acc_init_opens,
203
205
  } = node;
204
206
  const use_setting_tab_n = setting_tab_n || 0;
205
207
  const options = useContext(optionsCtx);
@@ -450,6 +452,29 @@ const TabsSettings = () => {
450
452
  </tr>
451
453
  </Fragment>
452
454
  ) : null}
455
+ {tabsStyle === "Accordion" ? (
456
+ <tr>
457
+ <td colSpan="2">
458
+ <div className="form-check">
459
+ <input
460
+ className="form-check-input"
461
+ name="block"
462
+ type="checkbox"
463
+ checked={acc_init_opens?.[use_setting_tab_n] || false}
464
+ onChange={(e) => {
465
+ if (!e.target) return;
466
+ const value = e.target.checked;
467
+ setProp((prop) => {
468
+ if (!prop.acc_init_opens) prop.acc_init_opens = [];
469
+ prop.acc_init_opens[use_setting_tab_n] = value;
470
+ });
471
+ }}
472
+ />
473
+ <label className="form-check-label">Initially open</label>
474
+ </div>
475
+ </td>
476
+ </tr>
477
+ ) : null}
453
478
  </Fragment>
454
479
  )}
455
480
  </tbody>
@@ -464,6 +489,7 @@ Tabs.craft = {
464
489
  props: {
465
490
  titles: ["Tab1", "Tab2"],
466
491
  showif: [],
492
+ acc_init_opens: [],
467
493
  ntabs: 2,
468
494
  tabsStyle: "Tabs",
469
495
  independent: false,
@@ -339,7 +339,7 @@ const ViewSettings = () => {
339
339
  )}
340
340
  </Fragment>
341
341
  )}
342
- {(state === "shared" || options.mode === "page") && (
342
+ {
343
343
  <Fragment>
344
344
  <label>
345
345
  Extra state Formula
@@ -357,7 +357,7 @@ const ViewSettings = () => {
357
357
  </small>
358
358
  ) : null}
359
359
  </Fragment>
360
- )}
360
+ }
361
361
  {view ? (
362
362
  <a
363
363
  className="d-block mt-2"
@@ -323,6 +323,7 @@ const ViewLinkSettings = () => {
323
323
  values={node}
324
324
  linkFirst={true}
325
325
  linkIsBlank={true}
326
+ allowRunOnLoad={false}
326
327
  />
327
328
  </tbody>
328
329
  </table>
@@ -1270,7 +1270,7 @@ const ButtonOrLinkSettingsRows = ({
1270
1270
  {!linkFirst ? (
1271
1271
  <option value={addBtnClass("btn-link")}>Link</option>
1272
1272
  ) : null}
1273
- {!linkFirst ? (
1273
+ {!linkFirst && allowRunOnLoad ? (
1274
1274
  <option value="on_page_load">Run on Page Load</option>
1275
1275
  ) : null}
1276
1276
  </select>
@@ -200,6 +200,7 @@ const layoutToNodes = (layout, query, actions, parent = "ROOT") => {
200
200
  minHeight={segment.minHeight}
201
201
  height={segment.height}
202
202
  width={segment.width}
203
+ click_action={segment.click_action}
203
204
  url={segment.url}
204
205
  hoverColor={segment.hoverColor}
205
206
  minHeightUnit={segment.minHeightUnit || "px"}
@@ -258,6 +259,7 @@ const layoutToNodes = (layout, query, actions, parent = "ROOT") => {
258
259
  independent={segment.independent}
259
260
  startClosed={segment.startClosed}
260
261
  deeplink={segment.deeplink}
262
+ acc_init_opens={segment.acc_init_opens}
261
263
  disable_inactive={segment.disable_inactive}
262
264
  serverRendered={segment.serverRendered}
263
265
  tabId={segment.tabId}
@@ -458,6 +460,7 @@ const craftToSaltcorn = (nodes, startFrom = "ROOT") => {
458
460
  gradStartColor: node.props.gradStartColor,
459
461
  gradEndColor: node.props.gradEndColor,
460
462
  gradDirection: node.props.gradDirection,
463
+ click_action: node.props.click_action,
461
464
  rotate: node.props.rotate,
462
465
  style: node.props.style,
463
466
  };
@@ -535,6 +538,7 @@ const craftToSaltcorn = (nodes, startFrom = "ROOT") => {
535
538
  field: node.props.field,
536
539
  independent: node.props.independent,
537
540
  startClosed: node.props.startClosed,
541
+ acc_init_opens: node.props.acc_init_opens,
538
542
  deeplink: node.props.deeplink,
539
543
  disable_inactive: node.props.disable_inactive,
540
544
  serverRendered: node.props.serverRendered,