@saltcorn/builder 1.6.0-alpha.7 → 1.6.0-alpha.8

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.
Files changed (40) hide show
  1. package/dist/builder_bundle.js +85 -1
  2. package/dist/builder_bundle.js.LICENSE.txt +65 -0
  3. package/package.json +32 -28
  4. package/src/components/Builder.js +334 -122
  5. package/src/components/Library.js +25 -13
  6. package/src/components/RenderNode.js +6 -6
  7. package/src/components/Toolbox.js +333 -269
  8. package/src/components/elements/Action.js +145 -30
  9. package/src/components/elements/Aggregation.js +20 -23
  10. package/src/components/elements/ArrayManager.js +7 -5
  11. package/src/components/elements/BoxModelEditor.js +19 -17
  12. package/src/components/elements/Card.js +47 -34
  13. package/src/components/elements/Clone.js +74 -2
  14. package/src/components/elements/Column.js +1 -1
  15. package/src/components/elements/Columns.js +27 -25
  16. package/src/components/elements/Container.js +170 -90
  17. package/src/components/elements/DropDownFilter.js +10 -8
  18. package/src/components/elements/DropMenu.js +8 -5
  19. package/src/components/elements/Field.js +9 -7
  20. package/src/components/elements/HTMLCode.js +3 -1
  21. package/src/components/elements/Image.js +20 -15
  22. package/src/components/elements/JoinField.js +15 -11
  23. package/src/components/elements/Link.js +18 -16
  24. package/src/components/elements/ListColumn.js +7 -3
  25. package/src/components/elements/ListColumns.js +4 -1
  26. package/src/components/elements/MonacoEditor.js +4 -2
  27. package/src/components/elements/Page.js +7 -4
  28. package/src/components/elements/RelationBadges.js +16 -11
  29. package/src/components/elements/RelationOnDemandPicker.js +18 -12
  30. package/src/components/elements/SearchBar.js +10 -6
  31. package/src/components/elements/Table.js +72 -65
  32. package/src/components/elements/Tabs.js +18 -15
  33. package/src/components/elements/Text.js +19 -14
  34. package/src/components/elements/ToggleFilter.js +28 -25
  35. package/src/components/elements/View.js +18 -11
  36. package/src/components/elements/ViewLink.js +15 -11
  37. package/src/components/elements/utils.js +224 -55
  38. package/src/components/storage.js +27 -129
  39. package/src/hooks/useTranslation.js +11 -0
  40. package/src/index.js +6 -3
@@ -0,0 +1,11 @@
1
+ import { useContext } from "react";
2
+ import optionsCtx from "../components/context";
3
+
4
+ const useTranslation = () => {
5
+ const options = useContext(optionsCtx);
6
+ const translations = options.translations || {};
7
+ const t = (phrase) => translations[phrase] || phrase;
8
+ return { t };
9
+ };
10
+
11
+ export default useTranslation;
package/src/index.js CHANGED
@@ -49,8 +49,8 @@
49
49
  */
50
50
 
51
51
  import React from "react";
52
+ import { createRoot } from "react-dom/client";
52
53
  import Builder from "./components/Builder";
53
- import ReactDOM from "react-dom";
54
54
 
55
55
  /**
56
56
  *
@@ -60,13 +60,16 @@ import ReactDOM from "react-dom";
60
60
  * @param {string} mode
61
61
  */
62
62
  function renderBuilder(id, options, layout, mode) {
63
- ReactDOM.render(
63
+ const container = document.getElementById(id);
64
+ if (!container) return;
65
+ const root = container.__scRoot || createRoot(container);
66
+ container.__scRoot = root;
67
+ root.render(
64
68
  <Builder
65
69
  options={JSON.parse(decodeURIComponent(options))}
66
70
  layout={JSON.parse(decodeURIComponent(layout))}
67
71
  mode={mode}
68
72
  />,
69
- document.getElementById(id)
70
73
  );
71
74
  }
72
75