@saltcorn/builder 0.7.0-beta.1 → 0.7.0-beta.2
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 +2 -2
- package/package.json +1 -1
- package/src/components/Builder.js +2 -0
- package/src/components/Toolbox.js +16 -2
- package/src/components/elements/Aggregation.js +5 -10
- package/src/components/elements/DropMenu.js +156 -0
- package/src/components/elements/utils.js +1 -1
- package/src/components/storage.js +2 -0
package/package.json
CHANGED
|
@@ -26,6 +26,7 @@ import { Image } from "./elements/Image";
|
|
|
26
26
|
import { Tabs } from "./elements/Tabs";
|
|
27
27
|
import { Empty } from "./elements/Empty";
|
|
28
28
|
import { DropDownFilter } from "./elements/DropDownFilter";
|
|
29
|
+
import { DropMenu } from "./elements/DropMenu";
|
|
29
30
|
import { ToggleFilter } from "./elements/ToggleFilter";
|
|
30
31
|
import optionsCtx from "./context";
|
|
31
32
|
import PreviewCtx from "./preview_context";
|
|
@@ -446,6 +447,7 @@ const Builder = ({ options, layout, mode }) => {
|
|
|
446
447
|
Container,
|
|
447
448
|
Column,
|
|
448
449
|
DropDownFilter,
|
|
450
|
+
DropMenu,
|
|
449
451
|
Tabs,
|
|
450
452
|
ToggleFilter,
|
|
451
453
|
}}
|
|
@@ -16,6 +16,7 @@ import { ViewLink } from "./elements/ViewLink";
|
|
|
16
16
|
import { Columns } from "./elements/Columns";
|
|
17
17
|
import { Action } from "./elements/Action";
|
|
18
18
|
import { DropDownFilter } from "./elements/DropDownFilter";
|
|
19
|
+
import { DropMenu } from "./elements/DropMenu";
|
|
19
20
|
import { ToggleFilter } from "./elements/ToggleFilter";
|
|
20
21
|
import { Empty } from "./elements/Empty";
|
|
21
22
|
import { Card } from "./elements/Card";
|
|
@@ -336,7 +337,7 @@ const DropDownFilterElem = ({ connectors, fields }) => (
|
|
|
336
337
|
connectors={connectors}
|
|
337
338
|
icon="far fa-caret-square-down"
|
|
338
339
|
title="Dropdown filter"
|
|
339
|
-
label="
|
|
340
|
+
label="Select"
|
|
340
341
|
>
|
|
341
342
|
<DropDownFilter
|
|
342
343
|
name={fields[0].name}
|
|
@@ -346,6 +347,18 @@ const DropDownFilterElem = ({ connectors, fields }) => (
|
|
|
346
347
|
/>
|
|
347
348
|
</WrapElem>
|
|
348
349
|
);
|
|
350
|
+
|
|
351
|
+
const DropMenuElem = ({ connectors }) => (
|
|
352
|
+
<WrapElem
|
|
353
|
+
connectors={connectors}
|
|
354
|
+
icon="far fa-caret-square-down"
|
|
355
|
+
title="Dropdown menu"
|
|
356
|
+
label="DropMenu"
|
|
357
|
+
>
|
|
358
|
+
<DropMenu />
|
|
359
|
+
</WrapElem>
|
|
360
|
+
);
|
|
361
|
+
|
|
349
362
|
/**
|
|
350
363
|
* @param {object} props
|
|
351
364
|
* @param {object} props.connectors
|
|
@@ -456,7 +469,7 @@ const AggregationElem = ({ connectors, child_field_list, agg_field_opts }) => (
|
|
|
456
469
|
connectors={connectors}
|
|
457
470
|
text="∑"
|
|
458
471
|
title="Aggregation"
|
|
459
|
-
label="
|
|
472
|
+
label="Aggreg8"
|
|
460
473
|
bold
|
|
461
474
|
fontSize="16px"
|
|
462
475
|
disable={child_field_list.length === 0}
|
|
@@ -529,6 +542,7 @@ const ToolboxShow = () => {
|
|
|
529
542
|
</div>
|
|
530
543
|
<div className="toolbar-row">
|
|
531
544
|
<HTMLElem connectors={connectors} />
|
|
545
|
+
<DropMenuElem connectors={connectors} />
|
|
532
546
|
</div>
|
|
533
547
|
</Fragment>
|
|
534
548
|
);
|
|
@@ -10,7 +10,7 @@ import optionsCtx from "../context";
|
|
|
10
10
|
import { blockProps, BlockSetting, TextStyleRow } from "./utils";
|
|
11
11
|
|
|
12
12
|
export /**
|
|
13
|
-
* @param {object} props
|
|
13
|
+
* @param {object} props
|
|
14
14
|
* @param {string} props.agg_relation
|
|
15
15
|
* @param {string} props.agg_field
|
|
16
16
|
* @param {string} props.stat
|
|
@@ -21,13 +21,7 @@ export /**
|
|
|
21
21
|
* @subcategory components
|
|
22
22
|
* @namespace
|
|
23
23
|
*/
|
|
24
|
-
const Aggregation = ({
|
|
25
|
-
agg_relation,
|
|
26
|
-
agg_field,
|
|
27
|
-
stat,
|
|
28
|
-
block,
|
|
29
|
-
textStyle,
|
|
30
|
-
}) => {
|
|
24
|
+
const Aggregation = ({ agg_relation, agg_field, stat, block, textStyle }) => {
|
|
31
25
|
const {
|
|
32
26
|
selected,
|
|
33
27
|
connectors: { connect, drag },
|
|
@@ -129,6 +123,7 @@ const AggregationSettings = () => {
|
|
|
129
123
|
<option value={"Sum"}>Sum</option>
|
|
130
124
|
<option value={"Max"}>Max</option>
|
|
131
125
|
<option value={"Min"}>Min</option>
|
|
126
|
+
<option value={"Array_Agg"}>Array_Agg</option>
|
|
132
127
|
{options.fields
|
|
133
128
|
.filter((f) => f.type.name === "Date")
|
|
134
129
|
.map((f) => (
|
|
@@ -163,8 +158,8 @@ const AggregationSettings = () => {
|
|
|
163
158
|
);
|
|
164
159
|
};
|
|
165
160
|
|
|
166
|
-
/**
|
|
167
|
-
* @type {object}
|
|
161
|
+
/**
|
|
162
|
+
* @type {object}
|
|
168
163
|
*/
|
|
169
164
|
Aggregation.craft = {
|
|
170
165
|
displayName: "Aggregation",
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @category saltcorn-builder
|
|
3
|
+
* @module components/elements/DropMenu
|
|
4
|
+
* @subcategory components / elements
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React, { Fragment, useState } from "react";
|
|
8
|
+
import { Element, useNode } from "@craftjs/core";
|
|
9
|
+
import { Column } from "./Column";
|
|
10
|
+
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
11
|
+
import { faCaretDown } from "@fortawesome/free-solid-svg-icons";
|
|
12
|
+
import {
|
|
13
|
+
SettingsRow,
|
|
14
|
+
BlockSetting,
|
|
15
|
+
ButtonOrLinkSettingsRows,
|
|
16
|
+
DynamicFontAwesomeIcon,
|
|
17
|
+
} from "./utils";
|
|
18
|
+
|
|
19
|
+
export /**
|
|
20
|
+
* @param {object} props
|
|
21
|
+
* @param {boolean} props.has_dropdown
|
|
22
|
+
* @param {string} props.children
|
|
23
|
+
* @param {boolean} props.show_badges
|
|
24
|
+
* @returns {div}
|
|
25
|
+
* @namespace
|
|
26
|
+
* @category saltcorn-builder
|
|
27
|
+
* @subcategory components
|
|
28
|
+
*/
|
|
29
|
+
const DropMenu = ({
|
|
30
|
+
children,
|
|
31
|
+
action_style,
|
|
32
|
+
action_size,
|
|
33
|
+
action_icon,
|
|
34
|
+
action_bgcol,
|
|
35
|
+
action_bordercol,
|
|
36
|
+
action_textcol,
|
|
37
|
+
block,
|
|
38
|
+
label,
|
|
39
|
+
}) => {
|
|
40
|
+
const {
|
|
41
|
+
selected,
|
|
42
|
+
connectors: { connect, drag },
|
|
43
|
+
} = useNode((node) => ({ selected: node.events.selected }));
|
|
44
|
+
const [showDropdown, setDropdown] = useState(false);
|
|
45
|
+
//const [dropWidth, setDropWidth] = useState(200);
|
|
46
|
+
return (
|
|
47
|
+
<div
|
|
48
|
+
className={`${selected ? "selected-node" : ""} ${block ? "d-block" : ""}`}
|
|
49
|
+
ref={(dom) => connect(drag(dom))}
|
|
50
|
+
>
|
|
51
|
+
<button
|
|
52
|
+
className={`btn ${action_style || "btn-primary"} ${action_size || ""} `}
|
|
53
|
+
style={
|
|
54
|
+
action_style === "btn-custom-color"
|
|
55
|
+
? {
|
|
56
|
+
backgroundColor: action_bgcol || "#000000",
|
|
57
|
+
borderColor: action_bordercol || "#000000",
|
|
58
|
+
color: action_textcol || "#000000",
|
|
59
|
+
}
|
|
60
|
+
: {}
|
|
61
|
+
}
|
|
62
|
+
>
|
|
63
|
+
<DynamicFontAwesomeIcon icon={action_icon} className="me-1" />
|
|
64
|
+
|
|
65
|
+
{label}
|
|
66
|
+
<FontAwesomeIcon
|
|
67
|
+
icon={faCaretDown}
|
|
68
|
+
className="ms-1"
|
|
69
|
+
onClick={() => setDropdown(!showDropdown)}
|
|
70
|
+
/>
|
|
71
|
+
</button>
|
|
72
|
+
<div
|
|
73
|
+
className={`dropdown-menu dropmenu-dropdown ${
|
|
74
|
+
showDropdown ? "show" : ""
|
|
75
|
+
}`}
|
|
76
|
+
>
|
|
77
|
+
<div className="canvas d-flex flex-column">{children}</div>
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export /**
|
|
84
|
+
* @returns {div}
|
|
85
|
+
* @namespace
|
|
86
|
+
* @category saltcorn-builder
|
|
87
|
+
* @subcategory components
|
|
88
|
+
*/
|
|
89
|
+
const DropMenuSettings = () => {
|
|
90
|
+
const node = useNode((node) => ({
|
|
91
|
+
label: node.data.props.label,
|
|
92
|
+
block: node.data.props.block,
|
|
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
|
+
label,
|
|
103
|
+
block,
|
|
104
|
+
} = node;
|
|
105
|
+
return (
|
|
106
|
+
<table className="w-100">
|
|
107
|
+
<tbody>
|
|
108
|
+
<SettingsRow
|
|
109
|
+
field={{
|
|
110
|
+
label: "Label",
|
|
111
|
+
name: "label",
|
|
112
|
+
type: "String",
|
|
113
|
+
}}
|
|
114
|
+
node={node}
|
|
115
|
+
setProp={setProp}
|
|
116
|
+
/>
|
|
117
|
+
<ButtonOrLinkSettingsRows
|
|
118
|
+
setProp={setProp}
|
|
119
|
+
keyPrefix="action_"
|
|
120
|
+
values={node}
|
|
121
|
+
/>
|
|
122
|
+
<tr>
|
|
123
|
+
<td colSpan="2">
|
|
124
|
+
<BlockSetting block={block} setProp={setProp} />
|
|
125
|
+
</td>
|
|
126
|
+
</tr>
|
|
127
|
+
</tbody>
|
|
128
|
+
</table>
|
|
129
|
+
);
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* @type {object}
|
|
134
|
+
*/
|
|
135
|
+
DropMenu.craft = {
|
|
136
|
+
displayName: "DropMenu",
|
|
137
|
+
props: {
|
|
138
|
+
label: "",
|
|
139
|
+
show_badges: false,
|
|
140
|
+
},
|
|
141
|
+
related: {
|
|
142
|
+
settings: DropMenuSettings,
|
|
143
|
+
segment_type: "dropdown_menu",
|
|
144
|
+
hasContents: true,
|
|
145
|
+
fields: [
|
|
146
|
+
"label",
|
|
147
|
+
"block",
|
|
148
|
+
"action_style",
|
|
149
|
+
"action_size",
|
|
150
|
+
"action_icon",
|
|
151
|
+
"action_bgcol",
|
|
152
|
+
"action_bordercol",
|
|
153
|
+
"action_textcol",
|
|
154
|
+
],
|
|
155
|
+
},
|
|
156
|
+
};
|
|
@@ -252,7 +252,7 @@ const TextStyleSelect = ({ textStyle, setProp }) => {
|
|
|
252
252
|
<option value="h5">Heading 5</option>
|
|
253
253
|
<option value="h6">Heading 6</option>
|
|
254
254
|
<option value="fw-bold">Bold</option>
|
|
255
|
-
<option value="
|
|
255
|
+
<option value="fst-italic">Italics</option>
|
|
256
256
|
<option value="small">Small</option>
|
|
257
257
|
<option value="text-muted">Muted</option>
|
|
258
258
|
<option value="text-underline">Underline</option>
|
|
@@ -25,6 +25,7 @@ import { SearchBar } from "./elements/SearchBar";
|
|
|
25
25
|
import { Container } from "./elements/Container";
|
|
26
26
|
import { DropDownFilter } from "./elements/DropDownFilter";
|
|
27
27
|
import { ToggleFilter } from "./elements/ToggleFilter";
|
|
28
|
+
import { DropMenu } from "./elements/DropMenu";
|
|
28
29
|
|
|
29
30
|
/**
|
|
30
31
|
* @param {object} segment
|
|
@@ -69,6 +70,7 @@ const allElements = [
|
|
|
69
70
|
DropDownFilter,
|
|
70
71
|
Tabs,
|
|
71
72
|
ToggleFilter,
|
|
73
|
+
DropMenu,
|
|
72
74
|
];
|
|
73
75
|
|
|
74
76
|
export /**
|