@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.
- package/dist/builder_bundle.js +18 -10
- package/dist/builder_bundle.js.map +1 -0
- package/package.json +6 -3
- package/src/components/Builder.js +230 -86
- package/src/components/Library.js +184 -0
- package/src/components/Toolbox.js +130 -69
- package/src/components/elements/Action.js +68 -108
- package/src/components/elements/Aggregation.js +0 -1
- package/src/components/elements/BoxModelEditor.js +374 -0
- package/src/components/elements/Column.js +4 -1
- package/src/components/elements/Columns.js +1 -2
- package/src/components/elements/Container.js +208 -274
- package/src/components/elements/DropDownFilter.js +16 -1
- package/src/components/elements/Field.js +1 -1
- package/src/components/elements/Image.js +92 -33
- package/src/components/elements/Link.js +139 -133
- package/src/components/elements/SearchBar.js +1 -1
- package/src/components/elements/Text.js +60 -26
- package/src/components/elements/ToggleFilter.js +12 -14
- package/src/components/elements/View.js +46 -19
- package/src/components/elements/ViewLink.js +62 -72
- package/src/components/elements/boxmodel.html +253 -0
- package/src/components/elements/utils.js +324 -65
- package/src/components/storage.js +30 -18
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
import React, { useContext, Fragment, useState } from "react";
|
|
2
|
+
import { SettingsRow, SettingsSectionHeaderRow, bstyleopt } from "./utils";
|
|
3
|
+
/*
|
|
4
|
+
Contains code from https://github.com/tpaksu/boxmodel
|
|
5
|
+
Copyright (c) 2017 Taha Paksu
|
|
6
|
+
*/
|
|
7
|
+
export const BoxModelEditor = ({ setProp, node }) => {
|
|
8
|
+
const [selectedCategory, setSelectedCategory] = useState(false);
|
|
9
|
+
const [selectedDirection, setSelectedDirection] = useState(false);
|
|
10
|
+
const selectedProperty = !selectedCategory
|
|
11
|
+
? false
|
|
12
|
+
: selectedDirection
|
|
13
|
+
? `${selectedCategory}-${selectedDirection}`
|
|
14
|
+
: selectedCategory;
|
|
15
|
+
const setCatAndDir = (c, d) => {
|
|
16
|
+
setSelectedCategory(c);
|
|
17
|
+
setSelectedDirection(d);
|
|
18
|
+
};
|
|
19
|
+
//console.log(node.style);
|
|
20
|
+
const style = node.style;
|
|
21
|
+
return (
|
|
22
|
+
<Fragment>
|
|
23
|
+
<div className="w-100 text-center">
|
|
24
|
+
<div className="boxmodel-container boxmodel-chrome-skin mt-2 mx-auto text-center">
|
|
25
|
+
<div className="boxmodel-container">
|
|
26
|
+
<div className="boxmodel-margin">
|
|
27
|
+
<span
|
|
28
|
+
className="boxmodel-text boxmodel-header"
|
|
29
|
+
onClick={() => setCatAndDir("margin", null)}
|
|
30
|
+
>
|
|
31
|
+
Margin
|
|
32
|
+
</span>
|
|
33
|
+
<span
|
|
34
|
+
className="boxmodel-input-container boxmodel-input-direction-left"
|
|
35
|
+
onClick={() => setCatAndDir("margin", "left")}
|
|
36
|
+
>
|
|
37
|
+
<div className="rotate dim-display">
|
|
38
|
+
{style["margin-left"] || style["margin"] || ""}
|
|
39
|
+
</div>
|
|
40
|
+
</span>
|
|
41
|
+
<div className="flex-row">
|
|
42
|
+
<span
|
|
43
|
+
className="boxmodel-input-container boxmodel-input-direction-top"
|
|
44
|
+
onClick={() => setCatAndDir("margin", "top")}
|
|
45
|
+
>
|
|
46
|
+
<input
|
|
47
|
+
disabled
|
|
48
|
+
type="text"
|
|
49
|
+
autoComplete="off"
|
|
50
|
+
name="boxmodel-ex-1_top_margin"
|
|
51
|
+
size="3"
|
|
52
|
+
value={style["margin-top"] || style["margin"] || ""}
|
|
53
|
+
/>
|
|
54
|
+
</span>
|
|
55
|
+
<div className="boxmodel-border">
|
|
56
|
+
<span
|
|
57
|
+
className="boxmodel-text boxmodel-header"
|
|
58
|
+
onClick={() => setCatAndDir("border", null)}
|
|
59
|
+
>
|
|
60
|
+
Border
|
|
61
|
+
</span>
|
|
62
|
+
<span
|
|
63
|
+
className="boxmodel-input-container boxmodel-input-direction-left"
|
|
64
|
+
onClick={() => setCatAndDir("border", "left")}
|
|
65
|
+
>
|
|
66
|
+
<div className="rotate dim-display">
|
|
67
|
+
{style["border-left-width"] ||
|
|
68
|
+
style["border-width"] ||
|
|
69
|
+
""}
|
|
70
|
+
</div>
|
|
71
|
+
</span>
|
|
72
|
+
<div className="flex-row">
|
|
73
|
+
<span
|
|
74
|
+
className="boxmodel-input-container boxmodel-input-direction-top"
|
|
75
|
+
onClick={() => setCatAndDir("border", "top")}
|
|
76
|
+
>
|
|
77
|
+
<input
|
|
78
|
+
disabled
|
|
79
|
+
type="text"
|
|
80
|
+
autoComplete="off"
|
|
81
|
+
name="boxmodel-ex-1_top_border"
|
|
82
|
+
value={
|
|
83
|
+
style["border-top-width"] ||
|
|
84
|
+
style["border-width"] ||
|
|
85
|
+
""
|
|
86
|
+
}
|
|
87
|
+
size="3"
|
|
88
|
+
/>
|
|
89
|
+
</span>
|
|
90
|
+
<div className="boxmodel-padding">
|
|
91
|
+
<span
|
|
92
|
+
className="boxmodel-text boxmodel-header"
|
|
93
|
+
onClick={() => setCatAndDir("padding", null)}
|
|
94
|
+
>
|
|
95
|
+
Padding
|
|
96
|
+
</span>
|
|
97
|
+
<span
|
|
98
|
+
className="boxmodel-input-container boxmodel-input-direction-left"
|
|
99
|
+
onClick={() => setCatAndDir("padding", "left")}
|
|
100
|
+
>
|
|
101
|
+
<div className="rotate dim-display-padding">
|
|
102
|
+
{style["padding-left"] || style["padding"] || ""}
|
|
103
|
+
</div>
|
|
104
|
+
</span>
|
|
105
|
+
<div className="flex-row">
|
|
106
|
+
<span
|
|
107
|
+
className="boxmodel-input-container boxmodel-input-direction-top"
|
|
108
|
+
onClick={() => setCatAndDir("padding", "top")}
|
|
109
|
+
>
|
|
110
|
+
<input
|
|
111
|
+
disabled
|
|
112
|
+
type="text"
|
|
113
|
+
autoComplete="off"
|
|
114
|
+
name="boxmodel-ex-1_top_padding"
|
|
115
|
+
value={
|
|
116
|
+
style["padding-top"] || style["padding"] || ""
|
|
117
|
+
}
|
|
118
|
+
size="3"
|
|
119
|
+
/>
|
|
120
|
+
</span>
|
|
121
|
+
<div
|
|
122
|
+
className="boxmodel-content"
|
|
123
|
+
onClick={() => setSelectedCategory("size")}
|
|
124
|
+
>
|
|
125
|
+
<input
|
|
126
|
+
disabled
|
|
127
|
+
type="text"
|
|
128
|
+
autoComplete="off"
|
|
129
|
+
name="boxmodel-ex-1_width"
|
|
130
|
+
size="3"
|
|
131
|
+
value={
|
|
132
|
+
node.width
|
|
133
|
+
? `${node.width}${node.widthUnits || "px"}`
|
|
134
|
+
: ""
|
|
135
|
+
}
|
|
136
|
+
/>
|
|
137
|
+
x
|
|
138
|
+
<input
|
|
139
|
+
disabled
|
|
140
|
+
type="text"
|
|
141
|
+
autoComplete="off"
|
|
142
|
+
name="boxmodel-ex-1_height"
|
|
143
|
+
size="3"
|
|
144
|
+
value={
|
|
145
|
+
node.height
|
|
146
|
+
? `${node.height}${node.heightUnits || "px"}`
|
|
147
|
+
: ""
|
|
148
|
+
}
|
|
149
|
+
/>
|
|
150
|
+
</div>
|
|
151
|
+
<span
|
|
152
|
+
className="boxmodel-input-container boxmodel-input-direction-bottom"
|
|
153
|
+
onClick={() => setCatAndDir("padding", "bottom")}
|
|
154
|
+
>
|
|
155
|
+
<input
|
|
156
|
+
disabled
|
|
157
|
+
type="text"
|
|
158
|
+
autoComplete="off"
|
|
159
|
+
name="boxmodel-ex-1_bottom_padding"
|
|
160
|
+
size="3"
|
|
161
|
+
value={
|
|
162
|
+
style["padding-bottom"] || style["padding"] || ""
|
|
163
|
+
}
|
|
164
|
+
/>
|
|
165
|
+
</span>
|
|
166
|
+
</div>
|
|
167
|
+
<span
|
|
168
|
+
className="boxmodel-input-container boxmodel-input-direction-right"
|
|
169
|
+
onClick={() => setCatAndDir("padding", "right")}
|
|
170
|
+
>
|
|
171
|
+
<div className="rotate dim-display-padding">
|
|
172
|
+
{style["padding-right"] || style["padding"] || ""}
|
|
173
|
+
</div>
|
|
174
|
+
</span>
|
|
175
|
+
</div>
|
|
176
|
+
<span
|
|
177
|
+
className="boxmodel-input-container boxmodel-input-direction-bottom"
|
|
178
|
+
onClick={() => setCatAndDir("border", "bottom")}
|
|
179
|
+
>
|
|
180
|
+
<input
|
|
181
|
+
disabled
|
|
182
|
+
type="text"
|
|
183
|
+
autoComplete="off"
|
|
184
|
+
name="boxmodel-ex-1_bottom_border"
|
|
185
|
+
size="3"
|
|
186
|
+
value={
|
|
187
|
+
style["border-bottom-width"] ||
|
|
188
|
+
style["border-width"] ||
|
|
189
|
+
""
|
|
190
|
+
}
|
|
191
|
+
/>
|
|
192
|
+
</span>
|
|
193
|
+
</div>
|
|
194
|
+
<span
|
|
195
|
+
className="boxmodel-input-container boxmodel-input-direction-right"
|
|
196
|
+
onClick={() => setCatAndDir("border", "right")}
|
|
197
|
+
>
|
|
198
|
+
<div className="rotate dim-display">
|
|
199
|
+
{style["border-right-width"] ||
|
|
200
|
+
style["border-width"] ||
|
|
201
|
+
""}
|
|
202
|
+
</div>
|
|
203
|
+
</span>
|
|
204
|
+
</div>
|
|
205
|
+
<span
|
|
206
|
+
className="boxmodel-input-container boxmodel-input-direction-bottom"
|
|
207
|
+
onClick={() => setCatAndDir("margin", "bottom")}
|
|
208
|
+
>
|
|
209
|
+
<input
|
|
210
|
+
disabled
|
|
211
|
+
type="text"
|
|
212
|
+
autoComplete="off"
|
|
213
|
+
name="boxmodel-ex-1_bottom_margin"
|
|
214
|
+
size="3"
|
|
215
|
+
value={style["margin-bottom"] || style["margin"] || ""}
|
|
216
|
+
/>
|
|
217
|
+
</span>
|
|
218
|
+
</div>
|
|
219
|
+
<span
|
|
220
|
+
className="boxmodel-input-container boxmodel-input-direction-right"
|
|
221
|
+
onClick={() => setCatAndDir("margin", "right")}
|
|
222
|
+
>
|
|
223
|
+
<div className="rotate dim-display">
|
|
224
|
+
{style["margin-right"] || style["margin"] || ""}
|
|
225
|
+
</div>
|
|
226
|
+
</span>
|
|
227
|
+
</div>
|
|
228
|
+
</div>
|
|
229
|
+
</div>
|
|
230
|
+
</div>
|
|
231
|
+
<table className="w-100 mt-2">
|
|
232
|
+
<tbody>
|
|
233
|
+
<tr>
|
|
234
|
+
<td width="45%"></td>
|
|
235
|
+
<td></td>
|
|
236
|
+
</tr>
|
|
237
|
+
{selectedProperty &&
|
|
238
|
+
["margin", "padding"].includes(selectedCategory) && (
|
|
239
|
+
<SettingsRow
|
|
240
|
+
field={{
|
|
241
|
+
name: selectedProperty,
|
|
242
|
+
label: selectedProperty,
|
|
243
|
+
type: "DimUnits",
|
|
244
|
+
autoable: selectedCategory === "margin",
|
|
245
|
+
}}
|
|
246
|
+
node={node}
|
|
247
|
+
setProp={setProp}
|
|
248
|
+
isStyle={true}
|
|
249
|
+
/>
|
|
250
|
+
)}
|
|
251
|
+
{selectedCategory === "size" && (
|
|
252
|
+
<Fragment>
|
|
253
|
+
<SettingsRow
|
|
254
|
+
field={{ name: "width", label: "width", type: "DimUnits" }}
|
|
255
|
+
node={node}
|
|
256
|
+
setProp={setProp}
|
|
257
|
+
/>
|
|
258
|
+
<SettingsRow
|
|
259
|
+
field={{ name: "height", label: "height", type: "DimUnits" }}
|
|
260
|
+
node={node}
|
|
261
|
+
setProp={setProp}
|
|
262
|
+
/>
|
|
263
|
+
<SettingsRow
|
|
264
|
+
field={{
|
|
265
|
+
name: "minHeight",
|
|
266
|
+
label: "min height",
|
|
267
|
+
type: "DimUnits",
|
|
268
|
+
}}
|
|
269
|
+
node={node}
|
|
270
|
+
setProp={setProp}
|
|
271
|
+
/>
|
|
272
|
+
</Fragment>
|
|
273
|
+
)}
|
|
274
|
+
{selectedCategory === "border" && (
|
|
275
|
+
<Fragment>
|
|
276
|
+
<SettingsSectionHeaderRow title={selectedProperty} />
|
|
277
|
+
<SettingsRow
|
|
278
|
+
field={{
|
|
279
|
+
name: selectedProperty + "-width",
|
|
280
|
+
label: "width",
|
|
281
|
+
type: "DimUnits",
|
|
282
|
+
}}
|
|
283
|
+
node={node}
|
|
284
|
+
setProp={setProp}
|
|
285
|
+
isStyle={true}
|
|
286
|
+
/>
|
|
287
|
+
<SettingsRow
|
|
288
|
+
field={{
|
|
289
|
+
name: selectedProperty + "-style",
|
|
290
|
+
label: "style",
|
|
291
|
+
type: "btn_select",
|
|
292
|
+
btnClass: "btnstylesel",
|
|
293
|
+
options: [
|
|
294
|
+
"solid",
|
|
295
|
+
"dotted",
|
|
296
|
+
"dashed",
|
|
297
|
+
"double",
|
|
298
|
+
"groove",
|
|
299
|
+
"ridge",
|
|
300
|
+
"inset",
|
|
301
|
+
"outset",
|
|
302
|
+
].map(bstyleopt),
|
|
303
|
+
}}
|
|
304
|
+
node={node}
|
|
305
|
+
isStyle={true}
|
|
306
|
+
setProp={setProp}
|
|
307
|
+
/>
|
|
308
|
+
<SettingsRow
|
|
309
|
+
field={{
|
|
310
|
+
name: selectedProperty + "-color",
|
|
311
|
+
label: "color",
|
|
312
|
+
type: "Color",
|
|
313
|
+
}}
|
|
314
|
+
node={node}
|
|
315
|
+
isStyle={true}
|
|
316
|
+
setProp={setProp}
|
|
317
|
+
/>
|
|
318
|
+
{!selectedDirection && (
|
|
319
|
+
<SettingsRow
|
|
320
|
+
field={{
|
|
321
|
+
name: selectedProperty + "-radius",
|
|
322
|
+
label: "radius",
|
|
323
|
+
type: "DimUnits",
|
|
324
|
+
}}
|
|
325
|
+
node={node}
|
|
326
|
+
setProp={setProp}
|
|
327
|
+
isStyle={true}
|
|
328
|
+
/>
|
|
329
|
+
)}
|
|
330
|
+
{selectedDirection &&
|
|
331
|
+
radiusCornerDirections[selectedDirection].map((corner, ix) => (
|
|
332
|
+
<SettingsRow
|
|
333
|
+
key={ix}
|
|
334
|
+
field={{
|
|
335
|
+
name: `border-${corner}-radius`,
|
|
336
|
+
label: corner.replace("-", " ") + " radius",
|
|
337
|
+
type: "DimUnits",
|
|
338
|
+
}}
|
|
339
|
+
node={node}
|
|
340
|
+
setProp={setProp}
|
|
341
|
+
isStyle={true}
|
|
342
|
+
/>
|
|
343
|
+
))}
|
|
344
|
+
</Fragment>
|
|
345
|
+
)}
|
|
346
|
+
{!selectedProperty && (
|
|
347
|
+
<tr>
|
|
348
|
+
<td colSpan={2}>
|
|
349
|
+
<div>Click above to select a property to adjust.</div>
|
|
350
|
+
<div>
|
|
351
|
+
<small>
|
|
352
|
+
Click a label (margin, border, padding) to adjust all edges.
|
|
353
|
+
</small>
|
|
354
|
+
</div>
|
|
355
|
+
<div>
|
|
356
|
+
<small>Click an edge to adjust that edge.</small>
|
|
357
|
+
</div>
|
|
358
|
+
<div>
|
|
359
|
+
<small>Click center to adjust height and width</small>
|
|
360
|
+
</div>
|
|
361
|
+
</td>
|
|
362
|
+
</tr>
|
|
363
|
+
)}
|
|
364
|
+
</tbody>
|
|
365
|
+
</table>
|
|
366
|
+
</Fragment>
|
|
367
|
+
);
|
|
368
|
+
};
|
|
369
|
+
const radiusCornerDirections = {
|
|
370
|
+
left: ["bottom-left", "top-left"],
|
|
371
|
+
right: ["bottom-right", "top-right"],
|
|
372
|
+
top: ["top-left", "top-right"],
|
|
373
|
+
bottom: ["bottom-left", "bottom-right"],
|
|
374
|
+
};
|
|
@@ -6,6 +6,7 @@ import optionsCtx from "../context";
|
|
|
6
6
|
export const Column = ({ children, align }) => {
|
|
7
7
|
const {
|
|
8
8
|
selected,
|
|
9
|
+
id,
|
|
9
10
|
connectors: { connect, drag },
|
|
10
11
|
} = useNode((node) => ({ selected: node.events.selected }));
|
|
11
12
|
return (
|
|
@@ -13,7 +14,9 @@ export const Column = ({ children, align }) => {
|
|
|
13
14
|
className={selected ? "selected-node" : ""}
|
|
14
15
|
ref={(dom) => connect(drag(dom))}
|
|
15
16
|
>
|
|
16
|
-
<div className="canvas"
|
|
17
|
+
<div className={`canvas ${id === "ROOT" ? "root-canvas" : ""}`}>
|
|
18
|
+
{children}
|
|
19
|
+
</div>
|
|
17
20
|
</div>
|
|
18
21
|
);
|
|
19
22
|
};
|
|
@@ -85,7 +85,6 @@ export const ColumnsSettings = () => {
|
|
|
85
85
|
{ntimes(ncols, (ix) => (
|
|
86
86
|
<Fragment key={ix}>
|
|
87
87
|
<tr>
|
|
88
|
-
{" "}
|
|
89
88
|
<th colSpan="4">Column {ix + 1}</th>
|
|
90
89
|
</tr>
|
|
91
90
|
<tr>
|
|
@@ -127,7 +126,7 @@ export const ColumnsSettings = () => {
|
|
|
127
126
|
</td>
|
|
128
127
|
</tr>
|
|
129
128
|
</Fragment>
|
|
130
|
-
))}
|
|
129
|
+
))}
|
|
131
130
|
</tbody>
|
|
132
131
|
</table>
|
|
133
132
|
</div>
|