@saltcorn/builder 1.7.0-beta.2 → 1.7.0-beta.3

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": "1.7.0-beta.2",
3
+ "version": "1.7.0-beta.3",
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",
@@ -30,7 +30,7 @@
30
30
  "@fortawesome/free-solid-svg-icons": "5.15.2",
31
31
  "@fortawesome/react-fontawesome": "0.1.14",
32
32
  "@monaco-editor/react": "4.7.0",
33
- "@saltcorn/common-code": "1.7.0-beta.2",
33
+ "@saltcorn/common-code": "1.7.0-beta.3",
34
34
  "@tippyjs/react": "4.2.6",
35
35
  "babel-loader": "9.2.1",
36
36
  "ckeditor4-react": "2.0.0",
@@ -5,7 +5,7 @@
5
5
  */
6
6
  /* globals $, validate_expression_elem */
7
7
 
8
- import React, { useContext, Fragment } from "react";
8
+ import React, { useContext, Fragment, useRef } from "react";
9
9
 
10
10
  import { Element, useNode } from "@craftjs/core";
11
11
  import { Column } from "./Column";
@@ -48,6 +48,7 @@ import {
48
48
  import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
49
49
  import { faScroll, faRobot } from "@fortawesome/free-solid-svg-icons";
50
50
  import { BoxModelEditor } from "./BoxModelEditor";
51
+ import { SingleLineEditor } from "./MonacoEditor";
51
52
  import previewCtx from "../preview_context";
52
53
 
53
54
  export /**
@@ -344,6 +345,7 @@ const ContainerSettings = () => {
344
345
  * @returns {function}
345
346
  */
346
347
  const setAProp = setAPropGen(setProp);
348
+ const showIfEditorRef = useRef(null);
347
349
  //console.log("transform", transform);
348
350
 
349
351
  return (
@@ -1033,14 +1035,15 @@ const ContainerSettings = () => {
1033
1035
  )}
1034
1036
  <tr>
1035
1037
  <td colSpan={2}>
1036
- <input
1037
- type="text"
1038
- placeholder={t("Example: x === y")}
1039
- className="form-control text-to-display"
1038
+ <SingleLineEditor
1039
+ ref={showIfEditorRef}
1040
1040
  value={showIfFormula}
1041
- spellCheck={false}
1042
- onChange={setAProp("showIfFormula")}
1043
- onInput={(e) => validate_expression_elem($(e.target))}
1041
+ setProp={setProp}
1042
+ propKey="showIfFormula"
1043
+ placeholder={t("Example: x === y")}
1044
+ onInput={(value) =>
1045
+ validate_expression_elem(value, showIfEditorRef.current)
1046
+ }
1044
1047
  />
1045
1048
  <div style={{ marginTop: "-5px" }}>
1046
1049
  <small className="text-muted font-monospace">
@@ -3,14 +3,16 @@
3
3
  * @module components/elements/Tabs
4
4
  * @subcategory components / elements
5
5
  */
6
+ /* globals validate_expression_elem */
6
7
 
7
- import React, { Fragment, useState, useContext, useEffect } from "react";
8
+ import React, { Fragment, useState, useContext, useEffect, useRef } from "react";
8
9
  import useTranslation from "../../hooks/useTranslation";
9
10
  import { ntimes } from "./Columns";
10
11
  import { Column } from "./Column";
11
12
  import optionsCtx from "../context";
12
13
  import { setAPropGen, buildOptions, ConfigField } from "./utils";
13
14
  import { ArrayManager } from "./ArrayManager";
15
+ import { SingleLineEditor } from "./MonacoEditor";
14
16
 
15
17
  import { Element, useNode } from "@craftjs/core";
16
18
 
@@ -235,6 +237,7 @@ const TabsSettings = () => {
235
237
  });
236
238
  }, [field]);
237
239
  const setAProp = setAPropGen(setProp);
240
+ const showIfEditorRef = useRef(null);
238
241
  const styleOptions = ["Tabs", "Pills", "Accordion"];
239
242
  if (["show", "edit"].includes(options.mode))
240
243
  styleOptions.push("Value switch");
@@ -456,19 +459,18 @@ const TabsSettings = () => {
456
459
  </tr>
457
460
  <tr>
458
461
  <td colSpan={2}>
459
- <input
460
- type="text"
461
- spellCheck={false}
462
- className="form-control text-to-display"
462
+ <SingleLineEditor
463
+ ref={showIfEditorRef}
463
464
  value={showif?.[use_setting_tab_n] || ""}
464
- onChange={(e) => {
465
- if (!e.target) return;
466
- const value = e.target.value;
465
+ onChange={(value) => {
467
466
  setProp((prop) => {
468
467
  if (!prop.showif) prop.showif = [];
469
468
  prop.showif[use_setting_tab_n] = value;
470
469
  });
471
470
  }}
471
+ onInput={(value) =>
472
+ validate_expression_elem(value, showIfEditorRef.current)
473
+ }
472
474
  />
473
475
  </td>
474
476
  </tr>