@saltcorn/builder 1.3.0-beta.1 → 1.3.0-beta.11
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.
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/*
|
|
2
|
+
object-assign
|
|
3
|
+
(c) Sindre Sorhus
|
|
4
|
+
@license MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/*!
|
|
8
|
+
Copyright (c) 2017 Jed Watson.
|
|
9
|
+
Licensed under the MIT License (MIT), see
|
|
10
|
+
http://jedwatson.github.io/classnames
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/*!
|
|
14
|
+
* Font Awesome Free 5.15.2 by @fontawesome - https://fontawesome.com
|
|
15
|
+
* License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/*! *****************************************************************************
|
|
19
|
+
Copyright (c) Microsoft Corporation.
|
|
20
|
+
|
|
21
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
22
|
+
purpose with or without fee is hereby granted.
|
|
23
|
+
|
|
24
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
25
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
26
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
27
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
28
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
29
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
30
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
31
|
+
***************************************************************************** */
|
|
32
|
+
|
|
33
|
+
/*! *****************************************************************************
|
|
34
|
+
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
35
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
36
|
+
this file except in compliance with the License. You may obtain a copy of the
|
|
37
|
+
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
38
|
+
|
|
39
|
+
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
40
|
+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
41
|
+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
42
|
+
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
43
|
+
|
|
44
|
+
See the Apache Version 2.0 License for specific language governing permissions
|
|
45
|
+
and limitations under the License.
|
|
46
|
+
***************************************************************************** */
|
|
47
|
+
|
|
48
|
+
/*!*
|
|
49
|
+
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
|
|
50
|
+
* For licensing, see LICENSE.md.
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @license
|
|
55
|
+
* Lodash <https://lodash.com/>
|
|
56
|
+
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
57
|
+
* Released under MIT license <https://lodash.com/license>
|
|
58
|
+
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
59
|
+
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
60
|
+
*/
|
|
61
|
+
|
|
62
|
+
/** @license React v0.19.1
|
|
63
|
+
* scheduler.production.min.js
|
|
64
|
+
*
|
|
65
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
66
|
+
*
|
|
67
|
+
* This source code is licensed under the MIT license found in the
|
|
68
|
+
* LICENSE file in the root directory of this source tree.
|
|
69
|
+
*/
|
|
70
|
+
|
|
71
|
+
/** @license React v16.13.1
|
|
72
|
+
* react-dom.production.min.js
|
|
73
|
+
*
|
|
74
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
75
|
+
*
|
|
76
|
+
* This source code is licensed under the MIT license found in the
|
|
77
|
+
* LICENSE file in the root directory of this source tree.
|
|
78
|
+
*/
|
|
79
|
+
|
|
80
|
+
/** @license React v16.13.1
|
|
81
|
+
* react-is.production.min.js
|
|
82
|
+
*
|
|
83
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
84
|
+
*
|
|
85
|
+
* This source code is licensed under the MIT license found in the
|
|
86
|
+
* LICENSE file in the root directory of this source tree.
|
|
87
|
+
*/
|
|
88
|
+
|
|
89
|
+
/** @license React v16.13.1
|
|
90
|
+
* react.production.min.js
|
|
91
|
+
*
|
|
92
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
93
|
+
*
|
|
94
|
+
* This source code is licensed under the MIT license found in the
|
|
95
|
+
* LICENSE file in the root directory of this source tree.
|
|
96
|
+
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saltcorn/builder",
|
|
3
|
-
"version": "1.3.0-beta.
|
|
3
|
+
"version": "1.3.0-beta.11",
|
|
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.24.7",
|
|
21
21
|
"@craftjs/core": "0.1.0-beta.20",
|
|
22
22
|
"@craftjs/utils": "0.1.0-beta.20",
|
|
23
|
-
"@saltcorn/common-code": "1.3.0-beta.
|
|
23
|
+
"@saltcorn/common-code": "1.3.0-beta.11",
|
|
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",
|
|
@@ -78,6 +78,8 @@ const { Provider } = optionsCtx;
|
|
|
78
78
|
* @namespace
|
|
79
79
|
*/
|
|
80
80
|
const SettingsPanel = () => {
|
|
81
|
+
const options = useContext(optionsCtx);
|
|
82
|
+
|
|
81
83
|
const { actions, selected, query } = useEditor((state, query) => {
|
|
82
84
|
const currentNodeId = state.events.selected;
|
|
83
85
|
let selected;
|
|
@@ -170,6 +172,48 @@ const SettingsPanel = () => {
|
|
|
170
172
|
if (nextSib) actions.selectNode(nextSib);
|
|
171
173
|
event.preventDefault();
|
|
172
174
|
}
|
|
175
|
+
// Ctrl+C or Cmd+C pressed?
|
|
176
|
+
if ((event.ctrlKey || event.metaKey) && event.keyCode == 67 && selected) {
|
|
177
|
+
// copy elem in json format to clipboard
|
|
178
|
+
const { layout } = craftToSaltcorn(
|
|
179
|
+
JSON.parse(query.serialize()),
|
|
180
|
+
selected?.id,
|
|
181
|
+
options
|
|
182
|
+
);
|
|
183
|
+
navigator.clipboard.writeText(JSON.stringify(layout, null, 2));
|
|
184
|
+
}
|
|
185
|
+
if ((event.ctrlKey || event.metaKey) && event.keyCode == 88 && selected) {
|
|
186
|
+
// cut elem in json format to clipboard
|
|
187
|
+
const { layout } = craftToSaltcorn(
|
|
188
|
+
JSON.parse(query.serialize()),
|
|
189
|
+
selected?.id,
|
|
190
|
+
options
|
|
191
|
+
);
|
|
192
|
+
navigator.clipboard.writeText(JSON.stringify(layout, null, 2));
|
|
193
|
+
deleteThis();
|
|
194
|
+
}
|
|
195
|
+
if ((event.ctrlKey || event.metaKey) && event.keyCode == 86) {
|
|
196
|
+
// paste elem from clipboard into container element
|
|
197
|
+
|
|
198
|
+
navigator.clipboard.readText().then((clipText) => {
|
|
199
|
+
const layout = JSON.parse(clipText);
|
|
200
|
+
layoutToNodes(
|
|
201
|
+
layout,
|
|
202
|
+
query,
|
|
203
|
+
actions,
|
|
204
|
+
selected?.id || "ROOT",
|
|
205
|
+
options
|
|
206
|
+
);
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
if ((event.ctrlKey || event.metaKey) && event.keyCode == 90) {
|
|
210
|
+
// undo
|
|
211
|
+
actions.history.undo();
|
|
212
|
+
}
|
|
213
|
+
if ((event.ctrlKey || event.metaKey) && event.keyCode == 89) {
|
|
214
|
+
// redo
|
|
215
|
+
actions.history.redo();
|
|
216
|
+
}
|
|
173
217
|
}
|
|
174
218
|
};
|
|
175
219
|
useEffect(() => {
|
|
@@ -223,14 +267,17 @@ const SettingsPanel = () => {
|
|
|
223
267
|
{selected ? (
|
|
224
268
|
<Fragment>
|
|
225
269
|
{selected.isDeletable && (
|
|
226
|
-
<button
|
|
270
|
+
<button
|
|
271
|
+
className="btn btn-sm btn-danger delete-element-builder"
|
|
272
|
+
onClick={deleteThis}
|
|
273
|
+
>
|
|
227
274
|
<FontAwesomeIcon icon={faTrashAlt} className="me-1" />
|
|
228
275
|
Delete
|
|
229
276
|
</button>
|
|
230
277
|
)}
|
|
231
278
|
{hasChildren && !selected.isDeletable ? (
|
|
232
279
|
<button
|
|
233
|
-
className="btn btn-sm btn-danger"
|
|
280
|
+
className="btn btn-sm btn-danger delete-children-builder"
|
|
234
281
|
onClick={deleteChildren}
|
|
235
282
|
>
|
|
236
283
|
<FontAwesomeIcon icon={faTrashAlt} className="me-1" />
|
|
@@ -239,7 +286,7 @@ const SettingsPanel = () => {
|
|
|
239
286
|
) : (
|
|
240
287
|
<button
|
|
241
288
|
title="Duplicate element with its children"
|
|
242
|
-
className="btn btn-sm btn-secondary ms-2"
|
|
289
|
+
className="btn btn-sm btn-secondary ms-2 duplicate-element-builder"
|
|
243
290
|
onClick={duplicate}
|
|
244
291
|
>
|
|
245
292
|
<FontAwesomeIcon icon={faCopy} className="me-1" />
|
|
@@ -293,7 +340,10 @@ const AddColumnButton = () => {
|
|
|
293
340
|
);
|
|
294
341
|
};
|
|
295
342
|
return (
|
|
296
|
-
<button
|
|
343
|
+
<button
|
|
344
|
+
className="btn btn-primary mt-2 add-column-builder"
|
|
345
|
+
onClick={addColumn}
|
|
346
|
+
>
|
|
297
347
|
<FontAwesomeIcon icon={faPlus} className="me-2" />
|
|
298
348
|
Add column
|
|
299
349
|
</button>
|
|
@@ -316,7 +366,7 @@ const HistoryPanel = () => {
|
|
|
316
366
|
<Fragment>
|
|
317
367
|
{canUndo && (
|
|
318
368
|
<button
|
|
319
|
-
className="btn btn-sm btn-secondary ms-2 me-2"
|
|
369
|
+
className="btn btn-sm btn-secondary ms-2 me-2 undo-builder"
|
|
320
370
|
title="Undo"
|
|
321
371
|
onClick={() => actions.history.undo()}
|
|
322
372
|
>
|
|
@@ -325,7 +375,7 @@ const HistoryPanel = () => {
|
|
|
325
375
|
)}
|
|
326
376
|
{canRedo && (
|
|
327
377
|
<button
|
|
328
|
-
className="btn btn-sm btn-secondary"
|
|
378
|
+
className="btn btn-sm btn-secondary redo-builder"
|
|
329
379
|
title="Redo"
|
|
330
380
|
onClick={() => actions.history.redo()}
|
|
331
381
|
>
|
|
@@ -471,7 +521,9 @@ const Builder = ({ options, layout, mode }) => {
|
|
|
471
521
|
? faCaretSquareLeft
|
|
472
522
|
: faCaretSquareRight
|
|
473
523
|
}
|
|
474
|
-
className={
|
|
524
|
+
className={
|
|
525
|
+
"float-end fa-lg builder-expand-toggle-left"
|
|
526
|
+
}
|
|
475
527
|
onClick={() => setIsLeftEnlarged(!isLeftEnlarged)}
|
|
476
528
|
title={isLeftEnlarged ? "Shrink" : "Enlarge"}
|
|
477
529
|
/>
|
|
@@ -545,7 +597,9 @@ const Builder = ({ options, layout, mode }) => {
|
|
|
545
597
|
icon={
|
|
546
598
|
isEnlarged ? faCaretSquareRight : faCaretSquareLeft
|
|
547
599
|
}
|
|
548
|
-
className={
|
|
600
|
+
className={
|
|
601
|
+
"float-end me-2 mt-1 fa-lg builder-expand-toggle-right"
|
|
602
|
+
}
|
|
549
603
|
onClick={() => setIsEnlarged(!isEnlarged)}
|
|
550
604
|
title={isEnlarged ? "Shrink" : "Enlarge"}
|
|
551
605
|
/>
|
|
@@ -619,7 +619,9 @@ const ToolboxList = ({ expanded }) => {
|
|
|
619
619
|
!disable_toolbox?.view && (
|
|
620
620
|
<ViewElem connectors={connectors} views={views} />
|
|
621
621
|
),
|
|
622
|
-
|
|
622
|
+
!disable_toolbox?.dropdown_menu && (
|
|
623
|
+
<ContainerElem connectors={connectors} />
|
|
624
|
+
),
|
|
623
625
|
// <CardElem connectors={connectors} />,
|
|
624
626
|
// <TabsElem connectors={connectors} />,
|
|
625
627
|
<HTMLElem connectors={connectors} />,
|
|
@@ -197,7 +197,7 @@ const ActionSettings = () => {
|
|
|
197
197
|
setInitialConfig(setProp, value, getCfgFields(value));
|
|
198
198
|
}}
|
|
199
199
|
>
|
|
200
|
-
{options.actions.map((f, ix) =>
|
|
200
|
+
{options.actions.filter(Boolean).map((f, ix) =>
|
|
201
201
|
f.optgroup && !f.options.length ? null : f.optgroup ? (
|
|
202
202
|
<optgroup key={ix} label={f.label}>
|
|
203
203
|
{f.options.map((a, jx) => (
|
|
@@ -942,10 +942,10 @@ const ContainerSettings = () => {
|
|
|
942
942
|
</table>
|
|
943
943
|
<table className="w-100" accordiontitle="Show if...">
|
|
944
944
|
<tbody>
|
|
945
|
-
{["show", "edit", "filter"].includes(options.mode) && (
|
|
945
|
+
{["show", "edit", "filter", "list"].includes(options.mode) && (
|
|
946
946
|
<SettingsSectionHeaderRow title="Formula - show if true" />
|
|
947
947
|
)}
|
|
948
|
-
{["show", "edit", "filter"].includes(options.mode) && (
|
|
948
|
+
{["show", "edit", "filter", "list"].includes(options.mode) && (
|
|
949
949
|
<tr>
|
|
950
950
|
<td colSpan={2}>
|
|
951
951
|
<input
|