@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.
- package/dist/builder_bundle.js +85 -1
- package/dist/builder_bundle.js.LICENSE.txt +65 -0
- package/package.json +32 -28
- package/src/components/Builder.js +334 -122
- package/src/components/Library.js +25 -13
- package/src/components/RenderNode.js +6 -6
- package/src/components/Toolbox.js +333 -269
- package/src/components/elements/Action.js +145 -30
- package/src/components/elements/Aggregation.js +20 -23
- package/src/components/elements/ArrayManager.js +7 -5
- package/src/components/elements/BoxModelEditor.js +19 -17
- package/src/components/elements/Card.js +47 -34
- package/src/components/elements/Clone.js +74 -2
- package/src/components/elements/Column.js +1 -1
- package/src/components/elements/Columns.js +27 -25
- package/src/components/elements/Container.js +170 -90
- package/src/components/elements/DropDownFilter.js +10 -8
- package/src/components/elements/DropMenu.js +8 -5
- package/src/components/elements/Field.js +9 -7
- package/src/components/elements/HTMLCode.js +3 -1
- package/src/components/elements/Image.js +20 -15
- package/src/components/elements/JoinField.js +15 -11
- package/src/components/elements/Link.js +18 -16
- package/src/components/elements/ListColumn.js +7 -3
- package/src/components/elements/ListColumns.js +4 -1
- package/src/components/elements/MonacoEditor.js +4 -2
- package/src/components/elements/Page.js +7 -4
- package/src/components/elements/RelationBadges.js +16 -11
- package/src/components/elements/RelationOnDemandPicker.js +18 -12
- package/src/components/elements/SearchBar.js +10 -6
- package/src/components/elements/Table.js +72 -65
- package/src/components/elements/Tabs.js +18 -15
- package/src/components/elements/Text.js +19 -14
- package/src/components/elements/ToggleFilter.js +28 -25
- package/src/components/elements/View.js +18 -11
- package/src/components/elements/ViewLink.js +15 -11
- package/src/components/elements/utils.js +224 -55
- package/src/components/storage.js +27 -129
- package/src/hooks/useTranslation.js +11 -0
- 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
|
-
|
|
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
|
|