@saltcorn/builder 0.0.1-beta.1
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/.babelrc +3 -0
- package/CHANGELOG.md +8 -0
- package/dist/builder_bundle.js +80 -0
- package/package.json +47 -0
- package/src/components/Builder.js +477 -0
- package/src/components/Library.js +224 -0
- package/src/components/RenderNode.js +203 -0
- package/src/components/Toolbox.js +688 -0
- package/src/components/context.js +9 -0
- package/src/components/elements/Action.js +204 -0
- package/src/components/elements/Aggregation.js +179 -0
- package/src/components/elements/BoxModelEditor.js +398 -0
- package/src/components/elements/Card.js +152 -0
- package/src/components/elements/Column.js +63 -0
- package/src/components/elements/Columns.js +201 -0
- package/src/components/elements/Container.js +947 -0
- package/src/components/elements/DropDownFilter.js +154 -0
- package/src/components/elements/DropMenu.js +156 -0
- package/src/components/elements/Empty.js +30 -0
- package/src/components/elements/Field.js +239 -0
- package/src/components/elements/HTMLCode.js +61 -0
- package/src/components/elements/Image.js +320 -0
- package/src/components/elements/JoinField.js +206 -0
- package/src/components/elements/LineBreak.js +46 -0
- package/src/components/elements/Link.js +305 -0
- package/src/components/elements/SearchBar.js +141 -0
- package/src/components/elements/Tabs.js +347 -0
- package/src/components/elements/Text.js +330 -0
- package/src/components/elements/ToggleFilter.js +243 -0
- package/src/components/elements/View.js +189 -0
- package/src/components/elements/ViewLink.js +225 -0
- package/src/components/elements/boxmodel.html +253 -0
- package/src/components/elements/faicons.js +1643 -0
- package/src/components/elements/utils.js +1217 -0
- package/src/components/preview_context.js +9 -0
- package/src/components/storage.js +506 -0
- package/src/index.js +73 -0
- package/webpack.config.js +21 -0
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @category saltcorn-builder
|
|
3
|
+
* @module components/elements/Action
|
|
4
|
+
* @subcategory components / elements
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React, { Fragment, useContext } from "react";
|
|
8
|
+
import { useNode } from "@craftjs/core";
|
|
9
|
+
import optionsCtx from "../context";
|
|
10
|
+
import {
|
|
11
|
+
blockProps,
|
|
12
|
+
BlockSetting,
|
|
13
|
+
MinRoleSettingRow,
|
|
14
|
+
OrFormula,
|
|
15
|
+
ConfigForm,
|
|
16
|
+
setInitialConfig,
|
|
17
|
+
ButtonOrLinkSettingsRows,
|
|
18
|
+
DynamicFontAwesomeIcon,
|
|
19
|
+
} from "./utils";
|
|
20
|
+
|
|
21
|
+
export /**
|
|
22
|
+
*
|
|
23
|
+
* @param {object} props
|
|
24
|
+
* @param {string} props.name
|
|
25
|
+
* @param {string} props.block
|
|
26
|
+
* @param {string} props.action_label
|
|
27
|
+
* @param {string} props.action_style
|
|
28
|
+
* @param {string} props.action_icon
|
|
29
|
+
* @param {string} props.action_size
|
|
30
|
+
* @param {string} props.action_bgcol
|
|
31
|
+
* @param {string} props.action_bordercol
|
|
32
|
+
* @param {string} props.action_textcol
|
|
33
|
+
* @returns {span|btn}
|
|
34
|
+
* @category saltcorn-builder
|
|
35
|
+
* @subcategory components
|
|
36
|
+
* @namespace
|
|
37
|
+
*/
|
|
38
|
+
const Action = ({
|
|
39
|
+
name,
|
|
40
|
+
block,
|
|
41
|
+
action_label,
|
|
42
|
+
action_style,
|
|
43
|
+
action_icon,
|
|
44
|
+
action_size,
|
|
45
|
+
action_bgcol,
|
|
46
|
+
action_bordercol,
|
|
47
|
+
action_textcol,
|
|
48
|
+
}) => {
|
|
49
|
+
const {
|
|
50
|
+
selected,
|
|
51
|
+
connectors: { connect, drag },
|
|
52
|
+
} = useNode((node) => ({ selected: node.events.selected }));
|
|
53
|
+
/**
|
|
54
|
+
* @type {object}
|
|
55
|
+
*/
|
|
56
|
+
return (
|
|
57
|
+
<button
|
|
58
|
+
className={`btn ${action_style || "btn-primary"} ${action_size || ""} ${
|
|
59
|
+
selected ? "selected-node" : ""
|
|
60
|
+
} ${block ? "d-block" : ""}`}
|
|
61
|
+
ref={(dom) => connect(drag(dom))}
|
|
62
|
+
style={
|
|
63
|
+
action_style === "btn-custom-color"
|
|
64
|
+
? {
|
|
65
|
+
backgroundColor: action_bgcol || "#000000",
|
|
66
|
+
borderColor: action_bordercol || "#000000",
|
|
67
|
+
color: action_textcol || "#000000",
|
|
68
|
+
}
|
|
69
|
+
: {}
|
|
70
|
+
}
|
|
71
|
+
>
|
|
72
|
+
<DynamicFontAwesomeIcon icon={action_icon} className="me-1" />
|
|
73
|
+
{action_label || name}
|
|
74
|
+
</button>
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export /**
|
|
79
|
+
* @category saltcorn-builder
|
|
80
|
+
* @subcategory components
|
|
81
|
+
* @namespace
|
|
82
|
+
* @returns {div}
|
|
83
|
+
*/
|
|
84
|
+
const ActionSettings = () => {
|
|
85
|
+
const node = useNode((node) => ({
|
|
86
|
+
name: node.data.props.name,
|
|
87
|
+
block: node.data.props.block,
|
|
88
|
+
minRole: node.data.props.minRole,
|
|
89
|
+
confirm: node.data.props.confirm,
|
|
90
|
+
action_label: node.data.props.action_label,
|
|
91
|
+
configuration: node.data.props.configuration,
|
|
92
|
+
isFormula: node.data.props.isFormula,
|
|
93
|
+
action_style: node.data.props.action_style,
|
|
94
|
+
action_size: node.data.props.action_size,
|
|
95
|
+
action_icon: node.data.props.action_icon,
|
|
96
|
+
action_bgcol: node.data.props.action_bgcol,
|
|
97
|
+
action_bordercol: node.data.props.action_bordercol,
|
|
98
|
+
action_textcol: node.data.props.action_textcol,
|
|
99
|
+
}));
|
|
100
|
+
const {
|
|
101
|
+
actions: { setProp },
|
|
102
|
+
name,
|
|
103
|
+
block,
|
|
104
|
+
minRole,
|
|
105
|
+
isFormula,
|
|
106
|
+
confirm,
|
|
107
|
+
configuration,
|
|
108
|
+
action_label,
|
|
109
|
+
} = node;
|
|
110
|
+
const options = useContext(optionsCtx);
|
|
111
|
+
const getCfgFields = (fv) => (options.actionConfigForms || {})[fv];
|
|
112
|
+
const cfgFields = getCfgFields(name);
|
|
113
|
+
return (
|
|
114
|
+
<div>
|
|
115
|
+
<table className="w-100">
|
|
116
|
+
<tbody>
|
|
117
|
+
<tr>
|
|
118
|
+
<td>
|
|
119
|
+
<label>Action</label>
|
|
120
|
+
</td>
|
|
121
|
+
<td>
|
|
122
|
+
<select
|
|
123
|
+
value={name}
|
|
124
|
+
className="form-control form-select"
|
|
125
|
+
onChange={(e) => {
|
|
126
|
+
setProp((prop) => (prop.name = e.target.value));
|
|
127
|
+
setInitialConfig(
|
|
128
|
+
setProp,
|
|
129
|
+
e.target.value,
|
|
130
|
+
getCfgFields(e.target.value)
|
|
131
|
+
);
|
|
132
|
+
}}
|
|
133
|
+
>
|
|
134
|
+
{options.actions.map((f, ix) => (
|
|
135
|
+
<option key={ix} value={f}>
|
|
136
|
+
{f}
|
|
137
|
+
</option>
|
|
138
|
+
))}
|
|
139
|
+
</select>
|
|
140
|
+
</td>
|
|
141
|
+
</tr>
|
|
142
|
+
<tr>
|
|
143
|
+
<td colSpan="2">
|
|
144
|
+
<label>Label (leave blank for default)</label>
|
|
145
|
+
<OrFormula
|
|
146
|
+
nodekey="action_label"
|
|
147
|
+
{...{ setProp, isFormula, node }}
|
|
148
|
+
>
|
|
149
|
+
<input
|
|
150
|
+
type="text"
|
|
151
|
+
className="form-control"
|
|
152
|
+
value={action_label}
|
|
153
|
+
onChange={(e) =>
|
|
154
|
+
setProp((prop) => (prop.action_label = e.target.value))
|
|
155
|
+
}
|
|
156
|
+
/>
|
|
157
|
+
</OrFormula>
|
|
158
|
+
</td>
|
|
159
|
+
</tr>
|
|
160
|
+
<ButtonOrLinkSettingsRows
|
|
161
|
+
setProp={setProp}
|
|
162
|
+
keyPrefix="action_"
|
|
163
|
+
values={node}
|
|
164
|
+
/>
|
|
165
|
+
<MinRoleSettingRow minRole={minRole} setProp={setProp} />
|
|
166
|
+
</tbody>
|
|
167
|
+
</table>
|
|
168
|
+
{options.mode === "show" || name === "Delete" || name === "Reset" ? (
|
|
169
|
+
<div className="form-check">
|
|
170
|
+
<input
|
|
171
|
+
className="form-check-input"
|
|
172
|
+
name="block"
|
|
173
|
+
type="checkbox"
|
|
174
|
+
checked={confirm}
|
|
175
|
+
onChange={(e) =>
|
|
176
|
+
setProp((prop) => (prop.confirm = e.target.checked))
|
|
177
|
+
}
|
|
178
|
+
/>
|
|
179
|
+
<label className="form-check-label">User confirmation?</label>
|
|
180
|
+
</div>
|
|
181
|
+
) : null}
|
|
182
|
+
<BlockSetting block={block} setProp={setProp} />
|
|
183
|
+
|
|
184
|
+
{cfgFields ? (
|
|
185
|
+
<ConfigForm
|
|
186
|
+
fields={cfgFields}
|
|
187
|
+
configuration={configuration}
|
|
188
|
+
setProp={setProp}
|
|
189
|
+
node={node}
|
|
190
|
+
/>
|
|
191
|
+
) : null}
|
|
192
|
+
</div>
|
|
193
|
+
);
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* @type {object}
|
|
198
|
+
*/
|
|
199
|
+
Action.craft = {
|
|
200
|
+
displayName: "Action",
|
|
201
|
+
related: {
|
|
202
|
+
settings: ActionSettings,
|
|
203
|
+
},
|
|
204
|
+
};
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @category saltcorn-builder
|
|
3
|
+
* @module components/elements/Aggregation
|
|
4
|
+
* @subcategory components / elements
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React, { useContext } from "react";
|
|
8
|
+
import { useNode } from "@craftjs/core";
|
|
9
|
+
import optionsCtx from "../context";
|
|
10
|
+
import { blockProps, BlockSetting, TextStyleRow } from "./utils";
|
|
11
|
+
|
|
12
|
+
export /**
|
|
13
|
+
* @param {object} props
|
|
14
|
+
* @param {string} props.agg_relation
|
|
15
|
+
* @param {string} props.agg_field
|
|
16
|
+
* @param {string} props.stat
|
|
17
|
+
* @param {boolean} props.block
|
|
18
|
+
* @param {string} props.textStyle
|
|
19
|
+
* @returns {span}
|
|
20
|
+
* @category saltcorn-builder
|
|
21
|
+
* @subcategory components
|
|
22
|
+
* @namespace
|
|
23
|
+
*/
|
|
24
|
+
const Aggregation = ({ agg_relation, agg_field, stat, block, textStyle }) => {
|
|
25
|
+
const {
|
|
26
|
+
selected,
|
|
27
|
+
connectors: { connect, drag },
|
|
28
|
+
} = useNode((node) => ({ selected: node.events.selected }));
|
|
29
|
+
return (
|
|
30
|
+
<span
|
|
31
|
+
className={`${textStyle} ${selected ? "selected-node" : ""}`}
|
|
32
|
+
{...blockProps(block)}
|
|
33
|
+
ref={(dom) => connect(drag(dom))}
|
|
34
|
+
>
|
|
35
|
+
[{stat} {agg_relation} {agg_field}]
|
|
36
|
+
</span>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export /**
|
|
41
|
+
* @returns {table}
|
|
42
|
+
* @category saltcorn-builder
|
|
43
|
+
* @subcategory components
|
|
44
|
+
* @namespace
|
|
45
|
+
*/
|
|
46
|
+
const AggregationSettings = () => {
|
|
47
|
+
const {
|
|
48
|
+
actions: { setProp },
|
|
49
|
+
agg_relation,
|
|
50
|
+
agg_field,
|
|
51
|
+
stat,
|
|
52
|
+
aggwhere,
|
|
53
|
+
block,
|
|
54
|
+
textStyle,
|
|
55
|
+
} = useNode((node) => ({
|
|
56
|
+
agg_relation: node.data.props.agg_relation,
|
|
57
|
+
agg_field: node.data.props.agg_field,
|
|
58
|
+
aggwhere: node.data.props.aggwhere,
|
|
59
|
+
stat: node.data.props.stat,
|
|
60
|
+
block: node.data.props.block,
|
|
61
|
+
textStyle: node.data.props.textStyle,
|
|
62
|
+
}));
|
|
63
|
+
const options = useContext(optionsCtx);
|
|
64
|
+
return (
|
|
65
|
+
<table>
|
|
66
|
+
<tbody>
|
|
67
|
+
<tr>
|
|
68
|
+
<td>
|
|
69
|
+
<label>Relation</label>
|
|
70
|
+
</td>
|
|
71
|
+
<td>
|
|
72
|
+
<select
|
|
73
|
+
className="form-control form-select"
|
|
74
|
+
value={agg_relation}
|
|
75
|
+
onChange={(e) =>
|
|
76
|
+
setProp((prop) => {
|
|
77
|
+
prop.agg_relation = e.target.value;
|
|
78
|
+
const fs = options.agg_field_opts[e.target.value];
|
|
79
|
+
if (fs && fs.length > 0) prop.agg_field = fs[0];
|
|
80
|
+
})
|
|
81
|
+
}
|
|
82
|
+
>
|
|
83
|
+
{options.child_field_list.map((f, ix) => (
|
|
84
|
+
<option key={ix} value={f}>
|
|
85
|
+
{f}
|
|
86
|
+
</option>
|
|
87
|
+
))}
|
|
88
|
+
</select>
|
|
89
|
+
</td>
|
|
90
|
+
</tr>
|
|
91
|
+
<tr>
|
|
92
|
+
<td>
|
|
93
|
+
<label>Child table field</label>
|
|
94
|
+
</td>
|
|
95
|
+
<td>
|
|
96
|
+
<select
|
|
97
|
+
className="form-control form-select"
|
|
98
|
+
value={agg_field}
|
|
99
|
+
onChange={(e) =>
|
|
100
|
+
setProp((prop) => (prop.agg_field = e.target.value))
|
|
101
|
+
}
|
|
102
|
+
>
|
|
103
|
+
{(options.agg_field_opts[agg_relation] || []).map((f, ix) => (
|
|
104
|
+
<option key={ix} value={f}>
|
|
105
|
+
{f}
|
|
106
|
+
</option>
|
|
107
|
+
))}
|
|
108
|
+
</select>
|
|
109
|
+
</td>
|
|
110
|
+
</tr>
|
|
111
|
+
<tr>
|
|
112
|
+
<td>
|
|
113
|
+
<label>Statistic</label>
|
|
114
|
+
</td>
|
|
115
|
+
<td>
|
|
116
|
+
<select
|
|
117
|
+
value={stat}
|
|
118
|
+
className="form-control form-select"
|
|
119
|
+
onChange={(e) => setProp((prop) => (prop.stat = e.target.value))}
|
|
120
|
+
>
|
|
121
|
+
<option value={"Count"}>Count</option>
|
|
122
|
+
<option value={"Avg"}>Avg</option>
|
|
123
|
+
<option value={"Sum"}>Sum</option>
|
|
124
|
+
<option value={"Max"}>Max</option>
|
|
125
|
+
<option value={"Min"}>Min</option>
|
|
126
|
+
<option value={"Array_Agg"}>Array_Agg</option>
|
|
127
|
+
{options.fields
|
|
128
|
+
.filter((f) => f.type.name === "Date")
|
|
129
|
+
.map((f) => (
|
|
130
|
+
<option value={`Latest ${f.name}`}>Latest {f.name}</option>
|
|
131
|
+
))}
|
|
132
|
+
</select>
|
|
133
|
+
</td>
|
|
134
|
+
</tr>
|
|
135
|
+
<tr>
|
|
136
|
+
<td>
|
|
137
|
+
<label>Where</label>
|
|
138
|
+
</td>
|
|
139
|
+
<td>
|
|
140
|
+
<input
|
|
141
|
+
type="text"
|
|
142
|
+
className="form-control"
|
|
143
|
+
value={aggwhere}
|
|
144
|
+
onChange={(e) =>
|
|
145
|
+
setProp((prop) => (prop.aggwhere = e.target.value))
|
|
146
|
+
}
|
|
147
|
+
/>
|
|
148
|
+
</td>
|
|
149
|
+
</tr>
|
|
150
|
+
<TextStyleRow textStyle={textStyle} setProp={setProp} />
|
|
151
|
+
<tr>
|
|
152
|
+
<td colSpan="2">
|
|
153
|
+
<BlockSetting block={block} setProp={setProp} />
|
|
154
|
+
</td>
|
|
155
|
+
</tr>
|
|
156
|
+
</tbody>
|
|
157
|
+
</table>
|
|
158
|
+
);
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* @type {object}
|
|
163
|
+
*/
|
|
164
|
+
Aggregation.craft = {
|
|
165
|
+
displayName: "Aggregation",
|
|
166
|
+
related: {
|
|
167
|
+
settings: AggregationSettings,
|
|
168
|
+
segment_type: "aggregation",
|
|
169
|
+
column_type: "Aggregation",
|
|
170
|
+
fields: [
|
|
171
|
+
"agg_relation",
|
|
172
|
+
"textStyle",
|
|
173
|
+
"block",
|
|
174
|
+
"agg_field",
|
|
175
|
+
"aggwhere",
|
|
176
|
+
"stat",
|
|
177
|
+
],
|
|
178
|
+
},
|
|
179
|
+
};
|