@intlayer/design-system 4.0.2 → 4.0.4
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/README.md +1 -1
- package/dist/.vite/manifest.json +58 -197
- package/dist/components/Accordion/Accordion.cjs +1 -1
- package/dist/components/Accordion/Accordion.cjs.map +1 -1
- package/dist/components/Accordion/Accordion.mjs +1 -1
- package/dist/components/Accordion/Accordion.mjs.map +1 -1
- package/dist/components/Auth/AuthModal/index.cjs +1 -1
- package/dist/components/Auth/AuthModal/index.mjs +1 -1
- package/dist/components/Auth/ExternalsLoginButtons/ExternalsLoginButtons.cjs +2 -1
- package/dist/components/Auth/ExternalsLoginButtons/ExternalsLoginButtons.cjs.map +1 -1
- package/dist/components/Auth/ExternalsLoginButtons/ExternalsLoginButtons.mjs +2 -1
- package/dist/components/Auth/ExternalsLoginButtons/ExternalsLoginButtons.mjs.map +1 -1
- package/dist/components/Auth/useAuth/index.cjs +8 -4
- package/dist/components/Auth/useAuth/index.cjs.map +1 -1
- package/dist/components/Auth/useAuth/index.d.ts +3 -1
- package/dist/components/Auth/useAuth/index.d.ts.map +1 -1
- package/dist/components/Auth/useAuth/index.mjs +8 -4
- package/dist/components/Auth/useAuth/index.mjs.map +1 -1
- package/dist/components/Auth/useAuth/useCSRF.cjs +6 -3
- package/dist/components/Auth/useAuth/useCSRF.cjs.map +1 -1
- package/dist/components/Auth/useAuth/useCSRF.d.ts +2 -1
- package/dist/components/Auth/useAuth/useCSRF.d.ts.map +1 -1
- package/dist/components/Auth/useAuth/useCSRF.mjs +5 -2
- package/dist/components/Auth/useAuth/useCSRF.mjs.map +1 -1
- package/dist/components/Auth/useAuth/useOAuth2.cjs +6 -5
- package/dist/components/Auth/useAuth/useOAuth2.cjs.map +1 -1
- package/dist/components/Auth/useAuth/useOAuth2.d.ts +2 -1
- package/dist/components/Auth/useAuth/useOAuth2.d.ts.map +1 -1
- package/dist/components/Auth/useAuth/useOAuth2.mjs +5 -4
- package/dist/components/Auth/useAuth/useOAuth2.mjs.map +1 -1
- package/dist/components/Auth/useAuth/useSession.cjs +6 -3
- package/dist/components/Auth/useAuth/useSession.cjs.map +1 -1
- package/dist/components/Auth/useAuth/useSession.d.ts +2 -1
- package/dist/components/Auth/useAuth/useSession.d.ts.map +1 -1
- package/dist/components/Auth/useAuth/useSession.mjs +6 -3
- package/dist/components/Auth/useAuth/useSession.mjs.map +1 -1
- package/dist/components/Auth/useUser/index.cjs +1 -1
- package/dist/components/Auth/useUser/index.mjs +1 -1
- package/dist/components/Container/index.d.ts +2 -2
- package/dist/components/DictionaryEditor/DictionaryEditor.cjs +4 -16
- package/dist/components/DictionaryEditor/DictionaryEditor.cjs.map +1 -1
- package/dist/components/DictionaryEditor/DictionaryEditor.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/DictionaryEditor.mjs +4 -16
- package/dist/components/DictionaryEditor/DictionaryEditor.mjs.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/ArrayWrapper.cjs +2 -1
- package/dist/components/DictionaryEditor/NodeWrapper/ArrayWrapper.cjs.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/ArrayWrapper.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/ArrayWrapper.mjs +2 -1
- package/dist/components/DictionaryEditor/NodeWrapper/ArrayWrapper.mjs.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/EnumerationWrapper.cjs +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/EnumerationWrapper.mjs +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.cjs +2 -1
- package/dist/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.cjs.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.mjs +2 -1
- package/dist/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.mjs.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.cjs +3 -3
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.cjs.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.mjs +2 -2
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.mjs.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/TranslationWrapper.cjs +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/TranslationWrapper.mjs +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/index.cjs +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/index.mjs +1 -1
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.cjs +2 -9
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.cjs.map +1 -1
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.mjs +2 -9
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.mjs.map +1 -1
- package/dist/components/DictionaryEditor/index.cjs +0 -8
- package/dist/components/DictionaryEditor/index.cjs.map +1 -1
- package/dist/components/DictionaryEditor/index.d.ts +0 -2
- package/dist/components/DictionaryEditor/index.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/index.mjs +1 -9
- package/dist/components/DictionaryEditor/index.mjs.map +1 -1
- package/dist/components/DictionaryEditor/useEditedContentStore.d.ts +1 -1
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.cjs +3 -21
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.mjs +3 -21
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.cjs +4 -2
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs +4 -2
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.cjs +4 -2
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs +4 -2
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.cjs +5 -31
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs +6 -32
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.cjs +8 -37
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.mjs +6 -35
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.cjs +6 -24
- package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.mjs +5 -23
- package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/JSONEditor.cjs +2 -29
- package/dist/components/DictionaryFieldEditor/JSONEditor.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/JSONEditor.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/JSONEditor.mjs +2 -29
- package/dist/components/DictionaryFieldEditor/JSONEditor.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.cjs +9 -33
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs +4 -28
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NodeEditor.cjs +3 -43
- package/dist/components/DictionaryFieldEditor/NodeEditor.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NodeEditor.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/NodeEditor.mjs +3 -43
- package/dist/components/DictionaryFieldEditor/NodeEditor.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.cjs +4 -27
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.mjs +3 -26
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs +9 -19
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs +9 -19
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/VersionSwitcherContext.cjs +2 -2
- package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/VersionSwitcherContext.mjs +2 -2
- package/dist/components/EditableField/EditableFieldLayout.cjs +7 -3
- package/dist/components/EditableField/EditableFieldLayout.cjs.map +1 -1
- package/dist/components/EditableField/EditableFieldLayout.d.ts.map +1 -1
- package/dist/components/EditableField/EditableFieldLayout.mjs +7 -3
- package/dist/components/EditableField/EditableFieldLayout.mjs.map +1 -1
- package/dist/components/IDE/CodeContext.cjs +2 -2
- package/dist/components/IDE/CodeContext.mjs +2 -2
- package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.cjs +2 -2
- package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.mjs +2 -2
- package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContentContext.cjs +2 -2
- package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContentContext.mjs +2 -2
- package/dist/components/Modal/Modal.cjs +12 -8
- package/dist/components/Modal/Modal.cjs.map +1 -1
- package/dist/components/Modal/Modal.d.ts.map +1 -1
- package/dist/components/Modal/Modal.mjs +12 -8
- package/dist/components/Modal/Modal.mjs.map +1 -1
- package/dist/components/Navbar/MobileNavbar.cjs +3 -3
- package/dist/components/Navbar/MobileNavbar.mjs +3 -3
- package/dist/components/Navbar/index.cjs +2 -2
- package/dist/components/Navbar/index.mjs +2 -2
- package/dist/components/RightDrawer/RightDrawer.cjs +34 -18
- package/dist/components/RightDrawer/RightDrawer.cjs.map +1 -1
- package/dist/components/RightDrawer/RightDrawer.d.ts.map +1 -1
- package/dist/components/RightDrawer/RightDrawer.mjs +33 -17
- package/dist/components/RightDrawer/RightDrawer.mjs.map +1 -1
- package/dist/components/SwitchSelector/index.cjs +2 -2
- package/dist/components/SwitchSelector/index.mjs +2 -2
- package/dist/components/TabSelector/TabSelector.cjs +2 -2
- package/dist/components/TabSelector/TabSelector.mjs +2 -2
- package/dist/components/index.cjs +0 -8
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.mjs +0 -8
- package/dist/components/index.mjs.map +1 -1
- package/dist/hooks/index.cjs +1 -1
- package/dist/hooks/index.mjs +2 -2
- package/dist/hooks/intlayerAPIHooks.cjs +5 -1
- package/dist/hooks/intlayerAPIHooks.cjs.map +1 -1
- package/dist/hooks/intlayerAPIHooks.d.ts +49 -49
- package/dist/hooks/intlayerAPIHooks.d.ts.map +1 -1
- package/dist/hooks/intlayerAPIHooks.mjs +5 -1
- package/dist/hooks/intlayerAPIHooks.mjs.map +1 -1
- package/dist/hooks/useAsync/useAsync.cjs +14 -0
- package/dist/hooks/useAsync/useAsync.cjs.map +1 -1
- package/dist/hooks/useAsync/useAsync.d.ts.map +1 -1
- package/dist/hooks/useAsync/useAsync.mjs +14 -0
- package/dist/hooks/useAsync/useAsync.mjs.map +1 -1
- package/dist/hooks/useGetAllDictionaries.cjs +3 -2
- package/dist/hooks/useGetAllDictionaries.cjs.map +1 -1
- package/dist/hooks/useGetAllDictionaries.d.ts +2 -2
- package/dist/hooks/useGetAllDictionaries.d.ts.map +1 -1
- package/dist/hooks/useGetAllDictionaries.mjs +3 -2
- package/dist/hooks/useGetAllDictionaries.mjs.map +1 -1
- package/dist/hooks/useIntlayerAPI.cjs +10 -7
- package/dist/hooks/useIntlayerAPI.cjs.map +1 -1
- package/dist/hooks/useIntlayerAPI.d.ts +8 -2
- package/dist/hooks/useIntlayerAPI.d.ts.map +1 -1
- package/dist/hooks/useIntlayerAPI.mjs +10 -7
- package/dist/hooks/useIntlayerAPI.mjs.map +1 -1
- package/dist/hooks/usePersistedStore.cjs +25 -15
- package/dist/hooks/usePersistedStore.cjs.map +1 -1
- package/dist/hooks/usePersistedStore.d.ts +2 -1
- package/dist/hooks/usePersistedStore.d.ts.map +1 -1
- package/dist/hooks/usePersistedStore.mjs +26 -16
- package/dist/hooks/usePersistedStore.mjs.map +1 -1
- package/dist/hooks/useScrollBlockage/index.cjs +5 -31
- package/dist/hooks/useScrollBlockage/index.cjs.map +1 -1
- package/dist/hooks/useScrollBlockage/index.mjs +5 -31
- package/dist/hooks/useScrollBlockage/index.mjs.map +1 -1
- package/dist/hooks/useScrollDetection.cjs +1 -1
- package/dist/hooks/useScrollDetection.mjs +1 -1
- package/dist/index-B-VAyQ9R.js +673 -0
- package/dist/index-B-VAyQ9R.js.map +1 -0
- package/dist/index-B-adg6xa.js +206 -0
- package/dist/index-B-adg6xa.js.map +1 -0
- package/dist/index-BIV0x_z2.js +206 -0
- package/dist/index-BIV0x_z2.js.map +1 -0
- package/dist/index-BNH9wXVj.cjs +205 -0
- package/dist/index-BNH9wXVj.cjs.map +1 -0
- package/dist/index-Cg-S9ry9.cjs +77 -0
- package/dist/index-Cg-S9ry9.cjs.map +1 -0
- package/dist/index-D69JRZcQ.js +206 -0
- package/dist/index-D69JRZcQ.js.map +1 -0
- package/dist/index-DAsui9u9.cjs +205 -0
- package/dist/index-DAsui9u9.cjs.map +1 -0
- package/dist/index-O_7rYrbW.js +78 -0
- package/dist/index-O_7rYrbW.js.map +1 -0
- package/dist/index-SOIahRpS.cjs +205 -0
- package/dist/index-SOIahRpS.cjs.map +1 -0
- package/dist/index-T-TjVQoD.js +671 -0
- package/dist/index-T-TjVQoD.js.map +1 -0
- package/dist/index-f8_VC6c8.cjs +672 -0
- package/dist/index-f8_VC6c8.cjs.map +1 -0
- package/dist/index-llGIfxqV.cjs +670 -0
- package/dist/index-llGIfxqV.cjs.map +1 -0
- package/dist/tailwind.css +1 -1
- package/dist/useGetAllDictionaries-B1sqs2IB.cjs +34 -0
- package/dist/useGetAllDictionaries-B1sqs2IB.cjs.map +1 -0
- package/dist/useGetAllDictionaries-BbH8vTkY.js +35 -0
- package/dist/useGetAllDictionaries-BbH8vTkY.js.map +1 -0
- package/dist/useGetAllDictionaries-Bgkytpa2.cjs +34 -0
- package/dist/useGetAllDictionaries-Bgkytpa2.cjs.map +1 -0
- package/dist/useGetAllDictionaries-D8ma3h41.cjs +33 -0
- package/dist/useGetAllDictionaries-D8ma3h41.cjs.map +1 -0
- package/dist/useGetAllDictionaries-DHgHEbD5.js +34 -0
- package/dist/useGetAllDictionaries-DHgHEbD5.js.map +1 -0
- package/dist/useGetAllDictionaries-DUzm0rIa.js +35 -0
- package/dist/useGetAllDictionaries-DUzm0rIa.js.map +1 -0
- package/package.json +24 -16
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
const jsxRuntime = require("./jsx-runtime-CgFM7lM3.cjs");
|
|
4
|
+
const core = require("@intlayer/core");
|
|
5
|
+
const require$$0 = require("react");
|
|
6
|
+
const lucideReact = require("lucide-react");
|
|
7
|
+
const components_Button_Button = require("./components/Button/Button.cjs");
|
|
8
|
+
const components_DictionaryEditor_ItemLayout = require("./components/DictionaryEditor/ItemLayout.cjs");
|
|
9
|
+
const components_DictionaryEditor_NodeWrapper_StringWrapper = require("./components/DictionaryEditor/NodeWrapper/StringWrapper.cjs");
|
|
10
|
+
const ArrayWrapper = (props) => {
|
|
11
|
+
const {
|
|
12
|
+
keyPath,
|
|
13
|
+
section,
|
|
14
|
+
onFocusKeyPath,
|
|
15
|
+
onClickEdit,
|
|
16
|
+
focusedKeyPath = []
|
|
17
|
+
} = props;
|
|
18
|
+
return section.map((subSection, key) => {
|
|
19
|
+
const newKeyPathEl = {
|
|
20
|
+
key,
|
|
21
|
+
type: core.NodeType.Array
|
|
22
|
+
};
|
|
23
|
+
const newKeyPath = [...keyPath, newKeyPathEl];
|
|
24
|
+
return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
|
|
25
|
+
components_DictionaryEditor_ItemLayout.ItemLayout,
|
|
26
|
+
{
|
|
27
|
+
level: keyPath.length,
|
|
28
|
+
title: `${key}`,
|
|
29
|
+
description: "",
|
|
30
|
+
isSelected: core.isSameKeyPath(newKeyPath, focusedKeyPath),
|
|
31
|
+
onClick: (e) => {
|
|
32
|
+
e.stopPropagation();
|
|
33
|
+
onFocusKeyPath(newKeyPath);
|
|
34
|
+
},
|
|
35
|
+
rightParam: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
|
|
36
|
+
components_Button_Button.Button,
|
|
37
|
+
{
|
|
38
|
+
Icon: lucideReact.Edit,
|
|
39
|
+
size: "icon-md",
|
|
40
|
+
variant: "hoverable",
|
|
41
|
+
color: "text",
|
|
42
|
+
label: "Open the editor",
|
|
43
|
+
onClick: (e) => {
|
|
44
|
+
e.stopPropagation();
|
|
45
|
+
onClickEdit?.(newKeyPath);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
),
|
|
49
|
+
children: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(NodeWrapper, { ...props, keyPath: newKeyPath, section: subSection })
|
|
50
|
+
},
|
|
51
|
+
JSON.stringify(subSection)
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
const EnumerationWrapper = (props) => {
|
|
56
|
+
const { keyPath, section } = props;
|
|
57
|
+
return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("div", { className: "ml-2 grid grid-cols-[auto,1fr] gap-2", children: Object.keys(section).filter((key) => !traceKeys.includes(key)).map((key) => {
|
|
58
|
+
const newKeyPathEl = {
|
|
59
|
+
type: core.NodeType.Enumeration,
|
|
60
|
+
key
|
|
61
|
+
};
|
|
62
|
+
const newKeyPath = [...keyPath, newKeyPathEl];
|
|
63
|
+
const subSection = section.enumeration[key];
|
|
64
|
+
return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment, { children: [
|
|
65
|
+
/* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("span", { className: "flex items-center font-bold", children: key }),
|
|
66
|
+
/* @__PURE__ */ require$$0.createElement(
|
|
67
|
+
NodeWrapper,
|
|
68
|
+
{
|
|
69
|
+
...props,
|
|
70
|
+
key,
|
|
71
|
+
keyPath: newKeyPath,
|
|
72
|
+
section: subSection
|
|
73
|
+
}
|
|
74
|
+
)
|
|
75
|
+
] });
|
|
76
|
+
}) });
|
|
77
|
+
};
|
|
78
|
+
const NestedObjectWrapper = (props) => {
|
|
79
|
+
const {
|
|
80
|
+
keyPath,
|
|
81
|
+
section,
|
|
82
|
+
focusedKeyPath = [],
|
|
83
|
+
onClickEdit,
|
|
84
|
+
onFocusKeyPath
|
|
85
|
+
} = props;
|
|
86
|
+
return Object.keys(section).filter((key) => !traceKeys.includes(key)).map((key) => {
|
|
87
|
+
const newKeyPathEl = { key, type: core.NodeType.Object };
|
|
88
|
+
const newKeyPath = [...keyPath, newKeyPathEl];
|
|
89
|
+
return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
|
|
90
|
+
components_DictionaryEditor_ItemLayout.ItemLayout,
|
|
91
|
+
{
|
|
92
|
+
level: keyPath.length,
|
|
93
|
+
title: key,
|
|
94
|
+
description: "",
|
|
95
|
+
isSelected: core.isSameKeyPath(newKeyPath, focusedKeyPath),
|
|
96
|
+
onClick: (e) => {
|
|
97
|
+
e.stopPropagation();
|
|
98
|
+
onFocusKeyPath(newKeyPath);
|
|
99
|
+
},
|
|
100
|
+
rightParam: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
|
|
101
|
+
components_Button_Button.Button,
|
|
102
|
+
{
|
|
103
|
+
Icon: lucideReact.Edit,
|
|
104
|
+
size: "icon-md",
|
|
105
|
+
variant: "hoverable",
|
|
106
|
+
color: "text",
|
|
107
|
+
label: "Open the editor",
|
|
108
|
+
onClick: (e) => {
|
|
109
|
+
e.stopPropagation();
|
|
110
|
+
onClickEdit?.(newKeyPath);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
),
|
|
114
|
+
children: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(NodeWrapper, { ...props, keyPath: newKeyPath, section: section[key] })
|
|
115
|
+
},
|
|
116
|
+
key
|
|
117
|
+
);
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
const TranslationWrapper = (props) => {
|
|
121
|
+
const { keyPath, section, locale } = props;
|
|
122
|
+
const newKeyPathEl = {
|
|
123
|
+
type: core.NodeType.Translation,
|
|
124
|
+
key: locale
|
|
125
|
+
};
|
|
126
|
+
const newKeyPath = [...keyPath, newKeyPathEl];
|
|
127
|
+
const subSection = section.translation[locale];
|
|
128
|
+
return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(NodeWrapper, { ...props, keyPath: newKeyPath, section: subSection });
|
|
129
|
+
};
|
|
130
|
+
const traceKeys = ["filePath", "id", "nodeType"];
|
|
131
|
+
const isReactNode = (node) => typeof node?.key !== "undefined" && typeof node?.props !== "undefined";
|
|
132
|
+
const createReactElement = (element) => {
|
|
133
|
+
if (typeof element === "string") {
|
|
134
|
+
return element;
|
|
135
|
+
}
|
|
136
|
+
const convertChildrenAsArray = (element2) => {
|
|
137
|
+
if (element2?.props && typeof element2.props.children === "object") {
|
|
138
|
+
const childrenResult = [];
|
|
139
|
+
const { children } = element2.props;
|
|
140
|
+
Object.keys(children).forEach((key) => {
|
|
141
|
+
childrenResult.push(createReactElement(children[key]));
|
|
142
|
+
});
|
|
143
|
+
return {
|
|
144
|
+
...element2,
|
|
145
|
+
props: { ...element2.props, children: childrenResult }
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
149
|
+
...element2,
|
|
150
|
+
props: { ...element2.props, children: element2.props.children }
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
const fixedElement = convertChildrenAsArray(element);
|
|
154
|
+
const { type, props } = fixedElement;
|
|
155
|
+
return require$$0.createElement(type ?? "div", props, ...props.children);
|
|
156
|
+
};
|
|
157
|
+
const NodeWrapper = (props) => {
|
|
158
|
+
const { section } = props;
|
|
159
|
+
if (typeof section === "object") {
|
|
160
|
+
if (isReactNode(section)) {
|
|
161
|
+
return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment, { children: [
|
|
162
|
+
createReactElement(section),
|
|
163
|
+
/* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("span", { className: "text-neutral dark:text-neutral-dark text-xs", children: "React node not editable" })
|
|
164
|
+
] });
|
|
165
|
+
}
|
|
166
|
+
if (section.nodeType === core.NodeType.Translation) {
|
|
167
|
+
return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
|
|
168
|
+
TranslationWrapper,
|
|
169
|
+
{
|
|
170
|
+
...props,
|
|
171
|
+
section
|
|
172
|
+
}
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
if (section.nodeType === core.NodeType.Enumeration) {
|
|
176
|
+
return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
|
|
177
|
+
EnumerationWrapper,
|
|
178
|
+
{
|
|
179
|
+
...props,
|
|
180
|
+
section
|
|
181
|
+
}
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
if (Array.isArray(section)) {
|
|
185
|
+
return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(ArrayWrapper, { ...props, section });
|
|
186
|
+
}
|
|
187
|
+
return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
|
|
188
|
+
NestedObjectWrapper,
|
|
189
|
+
{
|
|
190
|
+
...props,
|
|
191
|
+
section
|
|
192
|
+
}
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
if (typeof section === "string") {
|
|
196
|
+
return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(components_DictionaryEditor_NodeWrapper_StringWrapper.StringWrapper, { ...props, section });
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
exports.ArrayWrapper = ArrayWrapper;
|
|
200
|
+
exports.EnumerationWrapper = EnumerationWrapper;
|
|
201
|
+
exports.NestedObjectWrapper = NestedObjectWrapper;
|
|
202
|
+
exports.NodeWrapper = NodeWrapper;
|
|
203
|
+
exports.TranslationWrapper = TranslationWrapper;
|
|
204
|
+
exports.traceKeys = traceKeys;
|
|
205
|
+
//# sourceMappingURL=index-BNH9wXVj.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-BNH9wXVj.cjs","sources":["../src/components/DictionaryEditor/NodeWrapper/ArrayWrapper.tsx","../src/components/DictionaryEditor/NodeWrapper/EnumerationWrapper.tsx","../src/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.tsx","../src/components/DictionaryEditor/NodeWrapper/TranslationWrapper.tsx","../src/components/DictionaryEditor/NodeWrapper/index.tsx"],"sourcesContent":["/* eslint-disable import/no-cycle */\nimport {\n isSameKeyPath,\n NodeType,\n type DictionaryValue,\n type KeyPath,\n} from '@intlayer/core';\nimport { Edit } from 'lucide-react';\nimport type { FC } from 'react';\nimport { Button } from '../../Button';\nimport { ItemLayout } from '../ItemLayout';\nimport { NodeWrapper, type NodeWrapperProps } from './index';\n\ntype ArrayWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: DictionaryValue[];\n};\n\nexport const ArrayWrapper: FC<ArrayWrapperProps> = (props) => {\n const {\n keyPath,\n section,\n onFocusKeyPath,\n onClickEdit,\n focusedKeyPath = [],\n } = props;\n\n return section.map((subSection, key) => {\n const newKeyPathEl: KeyPath = {\n key,\n type: NodeType.Array,\n };\n const newKeyPath: KeyPath[] = [...keyPath, newKeyPathEl];\n\n return (\n <ItemLayout\n level={keyPath.length}\n key={JSON.stringify(subSection)}\n title={`${key}`}\n description=\"\"\n isSelected={isSameKeyPath(newKeyPath, focusedKeyPath)}\n onClick={(e) => {\n e.stopPropagation();\n onFocusKeyPath(newKeyPath);\n }}\n rightParam={\n <Button\n Icon={Edit}\n size=\"icon-md\"\n variant=\"hoverable\"\n color=\"text\"\n label=\"Open the editor\"\n onClick={(e) => {\n e.stopPropagation();\n\n onClickEdit?.(newKeyPath);\n }}\n />\n }\n >\n <NodeWrapper {...props} keyPath={newKeyPath} section={subSection} />\n </ItemLayout>\n );\n });\n};\n","/* eslint-disable import/no-cycle */\nimport {\n type KeyPath,\n NodeType,\n type EnumerationContent,\n type DictionaryValue,\n} from '@intlayer/core';\nimport type { FC } from 'react';\nimport { NodeWrapper, traceKeys, type NodeWrapperProps } from './index';\n\ntype EnumerationWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: EnumerationContent<DictionaryValue>;\n};\n\nexport const EnumerationWrapper: FC<EnumerationWrapperProps> = (props) => {\n const { keyPath, section } = props;\n\n return (\n <div className=\"ml-2 grid grid-cols-[auto,1fr] gap-2\">\n {Object.keys(section)\n .filter((key) => !traceKeys.includes(key))\n .map((key) => {\n const newKeyPathEl: KeyPath = {\n type: NodeType.Enumeration,\n key,\n };\n const newKeyPath: KeyPath[] = [...keyPath, newKeyPathEl];\n\n const subSection =\n section.enumeration[key as keyof (typeof section)['enumeration']]!;\n\n return (\n <>\n <span className=\"flex items-center font-bold\">{key}</span>\n <NodeWrapper\n {...props}\n key={key}\n keyPath={newKeyPath}\n section={subSection}\n />\n </>\n );\n })}\n </div>\n );\n};\n","/* eslint-disable import/no-cycle */\n\nimport {\n type KeyPath,\n isSameKeyPath,\n type DictionaryValue,\n NodeType,\n} from '@intlayer/core';\nimport { Edit } from 'lucide-react';\nimport type { FC } from 'react';\nimport { Button } from '../../Button';\nimport { ItemLayout } from '../ItemLayout';\nimport { NodeWrapper, traceKeys, type NodeWrapperProps } from './index';\n\ntype NestedObjectWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: Record<string, DictionaryValue>;\n};\n\nexport const NestedObjectWrapper: FC<NestedObjectWrapperProps> = (props) => {\n const {\n keyPath,\n section,\n focusedKeyPath = [],\n onClickEdit,\n onFocusKeyPath,\n } = props;\n\n return Object.keys(section)\n .filter((key) => !traceKeys.includes(key))\n .map((key) => {\n const newKeyPathEl: KeyPath = { key, type: NodeType.Object };\n const newKeyPath: KeyPath[] = [...keyPath, newKeyPathEl];\n\n return (\n <ItemLayout\n level={keyPath.length}\n key={key}\n title={key}\n description=\"\"\n isSelected={isSameKeyPath(newKeyPath, focusedKeyPath)}\n onClick={(e) => {\n e.stopPropagation();\n\n onFocusKeyPath(newKeyPath);\n }}\n rightParam={\n <Button\n Icon={Edit}\n size=\"icon-md\"\n variant=\"hoverable\"\n color=\"text\"\n label=\"Open the editor\"\n onClick={(e) => {\n e.stopPropagation();\n\n onClickEdit?.(newKeyPath);\n }}\n />\n }\n >\n <NodeWrapper {...props} keyPath={newKeyPath} section={section[key]} />\n </ItemLayout>\n );\n });\n};\n","/* eslint-disable import/no-cycle */\n\nimport {\n type KeyPath,\n NodeType,\n type TranslationContent,\n type DictionaryValue,\n} from '@intlayer/core';\nimport type { FC } from 'react';\nimport { NodeWrapper, type NodeWrapperProps } from './index';\n\ntype TranslationWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: TranslationContent<DictionaryValue>;\n};\n\nexport const TranslationWrapper: FC<TranslationWrapperProps> = (props) => {\n const { keyPath, section, locale } = props;\n\n const newKeyPathEl: KeyPath = {\n type: NodeType.Translation,\n key: locale,\n };\n\n const newKeyPath: KeyPath[] = [...keyPath, newKeyPathEl];\n\n const subSection =\n section.translation[\n locale as unknown as keyof (typeof section)['translation']\n ]!;\n\n return <NodeWrapper {...props} keyPath={newKeyPath} section={subSection} />;\n};\n","/* eslint-disable import/no-cycle */\n'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport {\n type EnumerationContent,\n type TranslationContent,\n NodeType,\n type KeyPath,\n type DictionaryValue,\n} from '@intlayer/core';\nimport {\n createElement,\n type ReactElement,\n type ReactNode,\n type FC,\n} from 'react';\nimport { ArrayWrapper } from './ArrayWrapper';\nimport { EnumerationWrapper } from './EnumerationWrapper';\nimport { NestedObjectWrapper } from './NestedObjectWrapper';\nimport { StringWrapper } from './StringWrapper';\nimport { TranslationWrapper } from './TranslationWrapper';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nconst isReactNode = (node: Record<string, unknown>): boolean =>\n typeof node?.key !== 'undefined' && typeof node?.props !== 'undefined';\n\nexport type NodeWrapperProps = {\n keyPath: KeyPath[];\n section: DictionaryValue;\n onContentChange: (content: { keyPath: KeyPath[]; newValue: string }) => void;\n locale: Locales;\n editedContent: DictionaryValue;\n focusedKeyPath: KeyPath[] | undefined;\n onFocusKeyPath: (keyPath: KeyPath[]) => void;\n onClickEdit?: (keyPath: KeyPath[]) => void;\n};\n\nconst createReactElement = (element: ReactElement) => {\n if (typeof element === 'string') {\n // If it's a string, simply return it (used for text content)\n return element;\n }\n\n const convertChildrenAsArray = (element: ReactElement): ReactElement => {\n if (element?.props && typeof element.props.children === 'object') {\n const childrenResult: ReactNode[] = [];\n const { children } = element.props;\n\n // Create the children elements recursively, if any\n Object.keys(children).forEach((key) => {\n childrenResult.push(createReactElement(children[key]));\n });\n\n return {\n ...element,\n props: { ...element.props, children: childrenResult },\n };\n }\n\n return {\n ...element,\n props: { ...element.props, children: element.props.children },\n };\n };\n\n const fixedElement = convertChildrenAsArray(element);\n\n const { type, props } = fixedElement;\n\n // Create and return the React element\n return createElement(type ?? 'div', props, ...props.children);\n};\n\nexport const NodeWrapper: FC<NodeWrapperProps> = (props) => {\n const { section } = props;\n\n if (typeof section === 'object') {\n if (isReactNode(section as Record<string, unknown>)) {\n return (\n <>\n {createReactElement(section as unknown as ReactElement)}\n <span className=\"text-neutral dark:text-neutral-dark text-xs\">\n React node not editable\n </span>\n </>\n );\n }\n\n if (\n (section as TranslationContent<DictionaryValue>).nodeType ===\n NodeType.Translation\n ) {\n return (\n <TranslationWrapper\n {...props}\n section={section as TranslationContent<DictionaryValue>}\n />\n );\n }\n\n if (\n (section as EnumerationContent<DictionaryValue>).nodeType ===\n NodeType.Enumeration\n ) {\n return (\n <EnumerationWrapper\n {...props}\n section={section as EnumerationContent<DictionaryValue>}\n />\n );\n }\n\n if (Array.isArray(section)) {\n return <ArrayWrapper {...props} section={section as DictionaryValue[]} />;\n }\n\n return (\n <NestedObjectWrapper\n {...props}\n section={section as Record<string, DictionaryValue>}\n />\n );\n }\n\n if (typeof section === 'string') {\n return <StringWrapper {...props} section={section} />;\n }\n};\n"],"names":["NodeType","jsx","ItemLayout","isSameKeyPath","Button","Edit","jsxs","Fragment","createElement","element","StringWrapper"],"mappings":";;;;;;;;;AAiBa,MAAA,eAAsC,CAAC,UAAU;AACtD,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,iBAAiB,CAAA;AAAA,EAAC,IAChB;AAEJ,SAAO,QAAQ,IAAI,CAAC,YAAY,QAAQ;AACtC,UAAM,eAAwB;AAAA,MAC5B;AAAA,MACA,MAAMA,KAAAA,SAAS;AAAA,IACjB;AACA,UAAM,aAAwB,CAAC,GAAG,SAAS,YAAY;AAGrD,WAAAC,2BAAA,kBAAA;AAAA,MAACC,uCAAA;AAAA,MAAA;AAAA,QACC,OAAO,QAAQ;AAAA,QAEf,OAAO,GAAG,GAAG;AAAA,QACb,aAAY;AAAA,QACZ,YAAYC,KAAAA,cAAc,YAAY,cAAc;AAAA,QACpD,SAAS,CAAC,MAAM;AACd,YAAE,gBAAgB;AAClB,yBAAe,UAAU;AAAA,QAC3B;AAAA,QACA,YACEF,2BAAA,kBAAA;AAAA,UAACG,yBAAA;AAAA,UAAA;AAAA,YACC,MAAMC,YAAA;AAAA,YACN,MAAK;AAAA,YACL,SAAQ;AAAA,YACR,OAAM;AAAA,YACN,OAAM;AAAA,YACN,SAAS,CAAC,MAAM;AACd,gBAAE,gBAAgB;AAElB,4BAAc,UAAU;AAAA,YAAA;AAAA,UAC1B;AAAA,QACF;AAAA,QAGF,2DAAC,aAAa,EAAA,GAAG,OAAO,SAAS,YAAY,SAAS,WAAY,CAAA;AAAA,MAAA;AAAA,MAvB7D,KAAK,UAAU,UAAU;AAAA,IAwBhC;AAAA,EAAA,CAEH;AACH;ACjDa,MAAA,qBAAkD,CAAC,UAAU;AAClE,QAAA,EAAE,SAAS,QAAA,IAAY;AAE7B,0D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A,IAAAS,sDAAA,eAAA,EAAe,GAAG,OAAO,QAAkB,CAAA;AAAA,EAAA;AAEvD;;;;;;;"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
const require$$0 = require("react");
|
|
4
|
+
const hooks_useGetElementOrWindow = require("./hooks/useGetElementOrWindow.cjs");
|
|
5
|
+
const hooks_useScrollBlockage_useScrollBlockageStore = require("./hooks/useScrollBlockage/useScrollBlockageStore.cjs");
|
|
6
|
+
function shallow(objA, objB) {
|
|
7
|
+
if (Object.is(objA, objB)) {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
if (typeof objA !== "object" || objA === null || typeof objB !== "object" || objB === null) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
if (objA instanceof Map && objB instanceof Map) {
|
|
14
|
+
if (objA.size !== objB.size) return false;
|
|
15
|
+
for (const [key, value] of objA) {
|
|
16
|
+
if (!Object.is(value, objB.get(key))) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
if (objA instanceof Set && objB instanceof Set) {
|
|
23
|
+
if (objA.size !== objB.size) return false;
|
|
24
|
+
for (const value of objA) {
|
|
25
|
+
if (!objB.has(value)) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
const keysA = Object.keys(objA);
|
|
32
|
+
if (keysA.length !== Object.keys(objB).length) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
for (const keyA of keysA) {
|
|
36
|
+
if (!Object.prototype.hasOwnProperty.call(objB, keyA) || !Object.is(objA[keyA], objB[keyA])) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
const { useRef } = require$$0;
|
|
43
|
+
function useShallow(selector) {
|
|
44
|
+
const prev = useRef();
|
|
45
|
+
return (state) => {
|
|
46
|
+
const next = selector(state);
|
|
47
|
+
return shallow(prev.current, next) ? prev.current : prev.current = next;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
const useScrollBlockage = (props) => {
|
|
51
|
+
const {
|
|
52
|
+
disableScroll = false,
|
|
53
|
+
element,
|
|
54
|
+
key = "unnamed_blocker"
|
|
55
|
+
} = props ?? {};
|
|
56
|
+
const { isElementScrollBlocked, addBlockage, removeBlockage } = hooks_useScrollBlockage_useScrollBlockageStore.useScrollBlockageStore(
|
|
57
|
+
useShallow((s) => ({
|
|
58
|
+
isElementScrollBlocked: s.isElementScrollBlocked,
|
|
59
|
+
addBlockage: s.addBlockage,
|
|
60
|
+
removeBlockage: s.removeBlockage
|
|
61
|
+
}))
|
|
62
|
+
);
|
|
63
|
+
const containerElement = hooks_useGetElementOrWindow.useGetElementOrWindow(element);
|
|
64
|
+
require$$0.useEffect(() => {
|
|
65
|
+
const el = element ?? window.document.body;
|
|
66
|
+
if (disableScroll) {
|
|
67
|
+
addBlockage(key, el);
|
|
68
|
+
} else {
|
|
69
|
+
removeBlockage(key, el);
|
|
70
|
+
}
|
|
71
|
+
}, [addBlockage, disableScroll, element, key, removeBlockage]);
|
|
72
|
+
const isScrollBlocked = containerElement ? isElementScrollBlocked(containerElement) : false;
|
|
73
|
+
return { isScrollBlocked };
|
|
74
|
+
};
|
|
75
|
+
exports.useScrollBlockage = useScrollBlockage;
|
|
76
|
+
exports.useShallow = useShallow;
|
|
77
|
+
//# sourceMappingURL=index-Cg-S9ry9.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-Cg-S9ry9.cjs","sources":["../../../../node_modules/.pnpm/zustand@4.5.6_@types+react@18.3.18_immer@9.0.21_react@18.3.1/node_modules/zustand/esm/react/shallow.mjs","../src/hooks/useScrollBlockage/index.tsx"],"sourcesContent":["import ReactExports from 'react';\n\nfunction shallow(objA, objB) {\n if (Object.is(objA, objB)) {\n return true;\n }\n if (typeof objA !== \"object\" || objA === null || typeof objB !== \"object\" || objB === null) {\n return false;\n }\n if (objA instanceof Map && objB instanceof Map) {\n if (objA.size !== objB.size) return false;\n for (const [key, value] of objA) {\n if (!Object.is(value, objB.get(key))) {\n return false;\n }\n }\n return true;\n }\n if (objA instanceof Set && objB instanceof Set) {\n if (objA.size !== objB.size) return false;\n for (const value of objA) {\n if (!objB.has(value)) {\n return false;\n }\n }\n return true;\n }\n const keysA = Object.keys(objA);\n if (keysA.length !== Object.keys(objB).length) {\n return false;\n }\n for (const keyA of keysA) {\n if (!Object.prototype.hasOwnProperty.call(objB, keyA) || !Object.is(objA[keyA], objB[keyA])) {\n return false;\n }\n }\n return true;\n}\n\nconst { useRef } = ReactExports;\nfunction useShallow(selector) {\n const prev = useRef();\n return (state) => {\n const next = selector(state);\n return shallow(prev.current, next) ? prev.current : prev.current = next;\n };\n}\n\nexport { useShallow };\n","'use client';\n\nimport { useEffect } from 'react';\nimport { useShallow } from 'zustand/react/shallow';\nimport { useGetElementOrWindow } from '../useGetElementOrWindow';\n\nimport { useScrollBlockageStore } from './useScrollBlockageStore';\n\ntype useScrollBlockagePropsReadOnly = {\n disableScroll: undefined;\n key: undefined;\n element?: HTMLElement; // The element to block the scroll. If not defined, the window will be used\n};\n\ntype useScrollBlockageProps = {\n disableScroll: boolean;\n key: string; // The key to identify the blockage to avoid conflicts. Required if disableScroll is defined\n element?: HTMLElement; // The element to block the scroll. If not defined, the window will be used\n};\n\nexport const useScrollBlockage = (\n props?: useScrollBlockageProps | useScrollBlockagePropsReadOnly\n) => {\n const {\n disableScroll = false,\n element,\n key = 'unnamed_blocker',\n } = props ?? {};\n\n const { isElementScrollBlocked, addBlockage, removeBlockage } =\n useScrollBlockageStore(\n useShallow((s) => ({\n isElementScrollBlocked: s.isElementScrollBlocked,\n addBlockage: s.addBlockage,\n removeBlockage: s.removeBlockage,\n }))\n );\n\n const containerElement = useGetElementOrWindow(element);\n\n useEffect(() => {\n const el = element ?? window.document.body;\n\n if (disableScroll) {\n addBlockage(key, el);\n } else {\n removeBlockage(key, el);\n }\n }, [addBlockage, disableScroll, element, key, removeBlockage]);\n\n const isScrollBlocked = containerElement\n ? isElementScrollBlocked(containerElement)\n : false;\n\n return { isScrollBlocked };\n};\n"],"names":["ReactExports","useScrollBlockageStore","useGetElementOrWindow","useEffect"],"mappings":";;;;;AAEA,SAAS,QAAQ,MAAM,MAAM;AAC3B,MAAI,OAAO,GAAG,MAAM,IAAI,GAAG;AACzB,WAAO;AAAA,EACX;AACE,MAAI,OAAO,SAAS,YAAY,SAAS,QAAQ,OAAO,SAAS,YAAY,SAAS,MAAM;AAC1F,WAAO;AAAA,EACX;AACE,MAAI,gBAAgB,OAAO,gBAAgB,KAAK;AAC9C,QAAI,KAAK,SAAS,KAAK,KAAM,QAAO;AACpC,eAAW,CAAC,KAAK,KAAK,KAAK,MAAM;AAC/B,UAAI,CAAC,OAAO,GAAG,OAAO,KAAK,IAAI,GAAG,CAAC,GAAG;AACpC,eAAO;AAAA,MACf;AAAA,IACA;AACI,WAAO;AAAA,EACX;AACE,MAAI,gBAAgB,OAAO,gBAAgB,KAAK;AAC9C,QAAI,KAAK,SAAS,KAAK,KAAM,QAAO;AACpC,eAAW,SAAS,MAAM;AACxB,UAAI,CAAC,KAAK,IAAI,KAAK,GAAG;AACpB,eAAO;AAAA,MACf;AAAA,IACA;AACI,WAAO;AAAA,EACX;AACE,QAAM,QAAQ,OAAO,KAAK,IAAI;AAC9B,MAAI,MAAM,WAAW,OAAO,KAAK,IAAI,EAAE,QAAQ;AAC7C,WAAO;AAAA,EACX;AACE,aAAW,QAAQ,OAAO;AACxB,QAAI,CAAC,OAAO,UAAU,eAAe,KAAK,MAAM,IAAI,KAAK,CAAC,OAAO,GAAG,KAAK,IAAI,GAAG,KAAK,IAAI,CAAC,GAAG;AAC3F,aAAO;AAAA,IACb;AAAA,EACA;AACE,SAAO;AACT;AAEA,MAAM,EAAE,OAAQ,IAAGA;AACnB,SAAS,WAAW,UAAU;AAC5B,QAAM,OAAO,OAAQ;AACrB,SAAO,CAAC,UAAU;AAChB,UAAM,OAAO,SAAS,KAAK;AAC3B,WAAO,QAAQ,KAAK,SAAS,IAAI,IAAI,KAAK,UAAU,KAAK,UAAU;AAAA,EACpE;AACH;AC1Ba,MAAA,oBAAoB,CAC/B,UACG;AACG,QAAA;AAAA,IACJ,gBAAgB;AAAA,IAChB;AAAA,IACA,MAAM;AAAA,EACR,IAAI,SAAS,CAAC;AAEd,QAAM,EAAE,wBAAwB,aAAa,eAC3C,IAAAC,+CAAA;AAAA,IACE,WAAW,CAAC,OAAO;AAAA,MACjB,wBAAwB,EAAE;AAAA,MAC1B,aAAa,EAAE;AAAA,MACf,gBAAgB,EAAE;AAAA,IAAA,EAClB;AAAA,EACJ;AAEI,QAAA,mBAAmBC,kDAAsB,OAAO;AAEtDC,aAAAA,UAAU,MAAM;AACR,UAAA,KAAK,WAAW,OAAO,SAAS;AAEtC,QAAI,eAAe;AACjB,kBAAY,KAAK,EAAE;AAAA,IAAA,OACd;AACL,qBAAe,KAAK,EAAE;AAAA,IAAA;AAAA,EACxB,GACC,CAAC,aAAa,eAAe,SAAS,KAAK,cAAc,CAAC;AAE7D,QAAM,kBAAkB,mBACpB,uBAAuB,gBAAgB,IACvC;AAEJ,SAAO,EAAE,gBAAgB;AAC3B;;;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { j as jsxRuntimeExports } from "./jsx-runtime-DQkoUcjV.js";
|
|
3
|
+
import { NodeType, isSameKeyPath } from "@intlayer/core";
|
|
4
|
+
import { createElement } from "react";
|
|
5
|
+
import { Edit } from "lucide-react";
|
|
6
|
+
import { Button } from "./components/Button/Button.mjs";
|
|
7
|
+
import { ItemLayout } from "./components/DictionaryEditor/ItemLayout.mjs";
|
|
8
|
+
import { StringWrapper } from "./components/DictionaryEditor/NodeWrapper/StringWrapper.mjs";
|
|
9
|
+
const ArrayWrapper = (props) => {
|
|
10
|
+
const {
|
|
11
|
+
keyPath,
|
|
12
|
+
section,
|
|
13
|
+
onFocusKeyPath,
|
|
14
|
+
onClickEdit,
|
|
15
|
+
focusedKeyPath = []
|
|
16
|
+
} = props;
|
|
17
|
+
return section.map((subSection, key) => {
|
|
18
|
+
const newKeyPathEl = {
|
|
19
|
+
key,
|
|
20
|
+
type: NodeType.Array
|
|
21
|
+
};
|
|
22
|
+
const newKeyPath = [...keyPath, newKeyPathEl];
|
|
23
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
24
|
+
ItemLayout,
|
|
25
|
+
{
|
|
26
|
+
level: keyPath.length,
|
|
27
|
+
title: `${key}`,
|
|
28
|
+
description: "",
|
|
29
|
+
isSelected: isSameKeyPath(newKeyPath, focusedKeyPath),
|
|
30
|
+
onClick: (e) => {
|
|
31
|
+
e.stopPropagation();
|
|
32
|
+
onFocusKeyPath(newKeyPath);
|
|
33
|
+
},
|
|
34
|
+
rightParam: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
35
|
+
Button,
|
|
36
|
+
{
|
|
37
|
+
Icon: Edit,
|
|
38
|
+
size: "icon-md",
|
|
39
|
+
variant: "hoverable",
|
|
40
|
+
color: "text",
|
|
41
|
+
label: "Open the editor",
|
|
42
|
+
onClick: (e) => {
|
|
43
|
+
e.stopPropagation();
|
|
44
|
+
onClickEdit?.(newKeyPath);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
),
|
|
48
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(NodeWrapper, { ...props, keyPath: newKeyPath, section: subSection })
|
|
49
|
+
},
|
|
50
|
+
JSON.stringify(subSection)
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
const EnumerationWrapper = (props) => {
|
|
55
|
+
const { keyPath, section } = props;
|
|
56
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ml-2 grid grid-cols-[auto,1fr] gap-2", children: Object.keys(section).filter((key) => !traceKeys.includes(key)).map((key) => {
|
|
57
|
+
const newKeyPathEl = {
|
|
58
|
+
type: NodeType.Enumeration,
|
|
59
|
+
key
|
|
60
|
+
};
|
|
61
|
+
const newKeyPath = [...keyPath, newKeyPathEl];
|
|
62
|
+
const subSection = section.enumeration[key];
|
|
63
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
64
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "flex items-center font-bold", children: key }),
|
|
65
|
+
/* @__PURE__ */ createElement(
|
|
66
|
+
NodeWrapper,
|
|
67
|
+
{
|
|
68
|
+
...props,
|
|
69
|
+
key,
|
|
70
|
+
keyPath: newKeyPath,
|
|
71
|
+
section: subSection
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
] });
|
|
75
|
+
}) });
|
|
76
|
+
};
|
|
77
|
+
const NestedObjectWrapper = (props) => {
|
|
78
|
+
const {
|
|
79
|
+
keyPath,
|
|
80
|
+
section,
|
|
81
|
+
focusedKeyPath = [],
|
|
82
|
+
onClickEdit,
|
|
83
|
+
onFocusKeyPath
|
|
84
|
+
} = props;
|
|
85
|
+
return Object.keys(section).filter((key) => !traceKeys.includes(key)).map((key) => {
|
|
86
|
+
const newKeyPathEl = { key, type: NodeType.Object };
|
|
87
|
+
const newKeyPath = [...keyPath, newKeyPathEl];
|
|
88
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
89
|
+
ItemLayout,
|
|
90
|
+
{
|
|
91
|
+
level: keyPath.length,
|
|
92
|
+
title: key,
|
|
93
|
+
description: "",
|
|
94
|
+
isSelected: isSameKeyPath(newKeyPath, focusedKeyPath),
|
|
95
|
+
onClick: (e) => {
|
|
96
|
+
e.stopPropagation();
|
|
97
|
+
onFocusKeyPath(newKeyPath);
|
|
98
|
+
},
|
|
99
|
+
rightParam: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
100
|
+
Button,
|
|
101
|
+
{
|
|
102
|
+
Icon: Edit,
|
|
103
|
+
size: "icon-sm",
|
|
104
|
+
variant: "hoverable",
|
|
105
|
+
color: "text",
|
|
106
|
+
label: "Open the editor",
|
|
107
|
+
onClick: (e) => {
|
|
108
|
+
e.stopPropagation();
|
|
109
|
+
onClickEdit?.(newKeyPath);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
),
|
|
113
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(NodeWrapper, { ...props, keyPath: newKeyPath, section: section[key] })
|
|
114
|
+
},
|
|
115
|
+
key
|
|
116
|
+
);
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
const TranslationWrapper = (props) => {
|
|
120
|
+
const { keyPath, section, locale } = props;
|
|
121
|
+
const newKeyPathEl = {
|
|
122
|
+
type: NodeType.Translation,
|
|
123
|
+
key: locale
|
|
124
|
+
};
|
|
125
|
+
const newKeyPath = [...keyPath, newKeyPathEl];
|
|
126
|
+
const subSection = section.translation[locale];
|
|
127
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(NodeWrapper, { ...props, keyPath: newKeyPath, section: subSection });
|
|
128
|
+
};
|
|
129
|
+
const traceKeys = ["filePath", "id", "nodeType"];
|
|
130
|
+
const isReactNode = (node) => typeof node?.key !== "undefined" && typeof node?.props !== "undefined";
|
|
131
|
+
const createReactElement = (element) => {
|
|
132
|
+
if (typeof element === "string") {
|
|
133
|
+
return element;
|
|
134
|
+
}
|
|
135
|
+
const convertChildrenAsArray = (element2) => {
|
|
136
|
+
if (element2?.props && typeof element2.props.children === "object") {
|
|
137
|
+
const childrenResult = [];
|
|
138
|
+
const { children } = element2.props;
|
|
139
|
+
Object.keys(children).forEach((key) => {
|
|
140
|
+
childrenResult.push(createReactElement(children[key]));
|
|
141
|
+
});
|
|
142
|
+
return {
|
|
143
|
+
...element2,
|
|
144
|
+
props: { ...element2.props, children: childrenResult }
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
...element2,
|
|
149
|
+
props: { ...element2.props, children: element2.props.children }
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
const fixedElement = convertChildrenAsArray(element);
|
|
153
|
+
const { type, props } = fixedElement;
|
|
154
|
+
return createElement(type ?? "div", props, ...props.children);
|
|
155
|
+
};
|
|
156
|
+
const NodeWrapper = (props) => {
|
|
157
|
+
const { section } = props;
|
|
158
|
+
if (typeof section === "object") {
|
|
159
|
+
if (isReactNode(section)) {
|
|
160
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
161
|
+
createReactElement(section),
|
|
162
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-neutral dark:text-neutral-dark text-xs", children: "React node not editable" })
|
|
163
|
+
] });
|
|
164
|
+
}
|
|
165
|
+
if (section.nodeType === NodeType.Translation) {
|
|
166
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
167
|
+
TranslationWrapper,
|
|
168
|
+
{
|
|
169
|
+
...props,
|
|
170
|
+
section
|
|
171
|
+
}
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
if (section.nodeType === NodeType.Enumeration) {
|
|
175
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
176
|
+
EnumerationWrapper,
|
|
177
|
+
{
|
|
178
|
+
...props,
|
|
179
|
+
section
|
|
180
|
+
}
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
if (Array.isArray(section)) {
|
|
184
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(ArrayWrapper, { ...props, section });
|
|
185
|
+
}
|
|
186
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
187
|
+
NestedObjectWrapper,
|
|
188
|
+
{
|
|
189
|
+
...props,
|
|
190
|
+
section
|
|
191
|
+
}
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
if (typeof section === "string") {
|
|
195
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(StringWrapper, { ...props, section });
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
export {
|
|
199
|
+
ArrayWrapper as A,
|
|
200
|
+
EnumerationWrapper as E,
|
|
201
|
+
NodeWrapper as N,
|
|
202
|
+
TranslationWrapper as T,
|
|
203
|
+
NestedObjectWrapper as a,
|
|
204
|
+
traceKeys as t
|
|
205
|
+
};
|
|
206
|
+
//# sourceMappingURL=index-D69JRZcQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-D69JRZcQ.js","sources":["../src/components/DictionaryEditor/NodeWrapper/ArrayWrapper.tsx","../src/components/DictionaryEditor/NodeWrapper/EnumerationWrapper.tsx","../src/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.tsx","../src/components/DictionaryEditor/NodeWrapper/TranslationWrapper.tsx","../src/components/DictionaryEditor/NodeWrapper/index.tsx"],"sourcesContent":["/* eslint-disable import/no-cycle */\nimport {\n isSameKeyPath,\n NodeType,\n type DictionaryValue,\n type KeyPath,\n} from '@intlayer/core';\nimport { Edit } from 'lucide-react';\nimport type { FC } from 'react';\nimport { Button } from '../../Button';\nimport { ItemLayout } from '../ItemLayout';\nimport { NodeWrapper, type NodeWrapperProps } from './index';\n\ntype ArrayWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: DictionaryValue[];\n};\n\nexport const ArrayWrapper: FC<ArrayWrapperProps> = (props) => {\n const {\n keyPath,\n section,\n onFocusKeyPath,\n onClickEdit,\n focusedKeyPath = [],\n } = props;\n\n return section.map((subSection, key) => {\n const newKeyPathEl: KeyPath = {\n key,\n type: NodeType.Array,\n };\n const newKeyPath: KeyPath[] = [...keyPath, newKeyPathEl];\n\n return (\n <ItemLayout\n level={keyPath.length}\n key={JSON.stringify(subSection)}\n title={`${key}`}\n description=\"\"\n isSelected={isSameKeyPath(newKeyPath, focusedKeyPath)}\n onClick={(e) => {\n e.stopPropagation();\n onFocusKeyPath(newKeyPath);\n }}\n rightParam={\n <Button\n Icon={Edit}\n size=\"icon-md\"\n variant=\"hoverable\"\n color=\"text\"\n label=\"Open the editor\"\n onClick={(e) => {\n e.stopPropagation();\n\n onClickEdit?.(newKeyPath);\n }}\n />\n }\n >\n <NodeWrapper {...props} keyPath={newKeyPath} section={subSection} />\n </ItemLayout>\n );\n });\n};\n","/* eslint-disable import/no-cycle */\nimport {\n type KeyPath,\n NodeType,\n type EnumerationContent,\n type DictionaryValue,\n} from '@intlayer/core';\nimport type { FC } from 'react';\nimport { NodeWrapper, traceKeys, type NodeWrapperProps } from './index';\n\ntype EnumerationWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: EnumerationContent<DictionaryValue>;\n};\n\nexport const EnumerationWrapper: FC<EnumerationWrapperProps> = (props) => {\n const { keyPath, section } = props;\n\n return (\n <div className=\"ml-2 grid grid-cols-[auto,1fr] gap-2\">\n {Object.keys(section)\n .filter((key) => !traceKeys.includes(key))\n .map((key) => {\n const newKeyPathEl: KeyPath = {\n type: NodeType.Enumeration,\n key,\n };\n const newKeyPath: KeyPath[] = [...keyPath, newKeyPathEl];\n\n const subSection =\n section.enumeration[key as keyof (typeof section)['enumeration']]!;\n\n return (\n <>\n <span className=\"flex items-center font-bold\">{key}</span>\n <NodeWrapper\n {...props}\n key={key}\n keyPath={newKeyPath}\n section={subSection}\n />\n </>\n );\n })}\n </div>\n );\n};\n","/* eslint-disable import/no-cycle */\n\nimport {\n type KeyPath,\n isSameKeyPath,\n type DictionaryValue,\n NodeType,\n} from '@intlayer/core';\nimport { Edit } from 'lucide-react';\nimport type { FC } from 'react';\nimport { Button } from '../../Button';\nimport { ItemLayout } from '../ItemLayout';\nimport { NodeWrapper, traceKeys, type NodeWrapperProps } from './index';\n\ntype NestedObjectWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: Record<string, DictionaryValue>;\n};\n\nexport const NestedObjectWrapper: FC<NestedObjectWrapperProps> = (props) => {\n const {\n keyPath,\n section,\n focusedKeyPath = [],\n onClickEdit,\n onFocusKeyPath,\n } = props;\n\n return Object.keys(section)\n .filter((key) => !traceKeys.includes(key))\n .map((key) => {\n const newKeyPathEl: KeyPath = { key, type: NodeType.Object };\n const newKeyPath: KeyPath[] = [...keyPath, newKeyPathEl];\n\n return (\n <ItemLayout\n level={keyPath.length}\n key={key}\n title={key}\n description=\"\"\n isSelected={isSameKeyPath(newKeyPath, focusedKeyPath)}\n onClick={(e) => {\n e.stopPropagation();\n\n onFocusKeyPath(newKeyPath);\n }}\n rightParam={\n <Button\n Icon={Edit}\n size=\"icon-sm\"\n variant=\"hoverable\"\n color=\"text\"\n label=\"Open the editor\"\n onClick={(e) => {\n e.stopPropagation();\n\n onClickEdit?.(newKeyPath);\n }}\n />\n }\n >\n <NodeWrapper {...props} keyPath={newKeyPath} section={section[key]} />\n </ItemLayout>\n );\n });\n};\n","/* eslint-disable import/no-cycle */\n\nimport {\n type KeyPath,\n NodeType,\n type TranslationContent,\n type DictionaryValue,\n} from '@intlayer/core';\nimport type { FC } from 'react';\nimport { NodeWrapper, type NodeWrapperProps } from './index';\n\ntype TranslationWrapperProps = Omit<NodeWrapperProps, 'section'> & {\n section: TranslationContent<DictionaryValue>;\n};\n\nexport const TranslationWrapper: FC<TranslationWrapperProps> = (props) => {\n const { keyPath, section, locale } = props;\n\n const newKeyPathEl: KeyPath = {\n type: NodeType.Translation,\n key: locale,\n };\n\n const newKeyPath: KeyPath[] = [...keyPath, newKeyPathEl];\n\n const subSection =\n section.translation[\n locale as unknown as keyof (typeof section)['translation']\n ]!;\n\n return <NodeWrapper {...props} keyPath={newKeyPath} section={subSection} />;\n};\n","/* eslint-disable import/no-cycle */\n'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport {\n type EnumerationContent,\n type TranslationContent,\n NodeType,\n type KeyPath,\n type DictionaryValue,\n} from '@intlayer/core';\nimport {\n createElement,\n type ReactElement,\n type ReactNode,\n type FC,\n} from 'react';\nimport { ArrayWrapper } from './ArrayWrapper';\nimport { EnumerationWrapper } from './EnumerationWrapper';\nimport { NestedObjectWrapper } from './NestedObjectWrapper';\nimport { StringWrapper } from './StringWrapper';\nimport { TranslationWrapper } from './TranslationWrapper';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nconst isReactNode = (node: Record<string, unknown>): boolean =>\n typeof node?.key !== 'undefined' && typeof node?.props !== 'undefined';\n\nexport type NodeWrapperProps = {\n keyPath: KeyPath[];\n section: DictionaryValue;\n onContentChange: (content: { keyPath: KeyPath[]; newValue: string }) => void;\n locale: Locales;\n editedContent: DictionaryValue;\n focusedKeyPath: KeyPath[] | undefined;\n onFocusKeyPath: (keyPath: KeyPath[]) => void;\n onClickEdit?: (keyPath: KeyPath[]) => void;\n};\n\nconst createReactElement = (element: ReactElement) => {\n if (typeof element === 'string') {\n // If it's a string, simply return it (used for text content)\n return element;\n }\n\n const convertChildrenAsArray = (element: ReactElement): ReactElement => {\n if (element?.props && typeof element.props.children === 'object') {\n const childrenResult: ReactNode[] = [];\n const { children } = element.props;\n\n // Create the children elements recursively, if any\n Object.keys(children).forEach((key) => {\n childrenResult.push(createReactElement(children[key]));\n });\n\n return {\n ...element,\n props: { ...element.props, children: childrenResult },\n };\n }\n\n return {\n ...element,\n props: { ...element.props, children: element.props.children },\n };\n };\n\n const fixedElement = convertChildrenAsArray(element);\n\n const { type, props } = fixedElement;\n\n // Create and return the React element\n return createElement(type ?? 'div', props, ...props.children);\n};\n\nexport const NodeWrapper: FC<NodeWrapperProps> = (props) => {\n const { section } = props;\n\n if (typeof section === 'object') {\n if (isReactNode(section as Record<string, unknown>)) {\n return (\n <>\n {createReactElement(section as unknown as ReactElement)}\n <span className=\"text-neutral dark:text-neutral-dark text-xs\">\n React node not editable\n </span>\n </>\n );\n }\n\n if (\n (section as TranslationContent<DictionaryValue>).nodeType ===\n NodeType.Translation\n ) {\n return (\n <TranslationWrapper\n {...props}\n section={section as TranslationContent<DictionaryValue>}\n />\n );\n }\n\n if (\n (section as EnumerationContent<DictionaryValue>).nodeType ===\n NodeType.Enumeration\n ) {\n return (\n <EnumerationWrapper\n {...props}\n section={section as EnumerationContent<DictionaryValue>}\n />\n );\n }\n\n if (Array.isArray(section)) {\n return <ArrayWrapper {...props} section={section as DictionaryValue[]} />;\n }\n\n return (\n <NestedObjectWrapper\n {...props}\n section={section as Record<string, DictionaryValue>}\n />\n );\n }\n\n if (typeof section === 'string') {\n return <StringWrapper {...props} section={section} />;\n }\n};\n"],"names":["jsx","jsxs","Fragment","element"],"mappings":";;;;;;;;AAiBa,MAAA,eAAsC,CAAC,UAAU;AACtD,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,iBAAiB,CAAA;AAAA,EAAC,IAChB;AAEJ,SAAO,QAAQ,IAAI,CAAC,YAAY,QAAQ;AACtC,UAAM,eAAwB;AAAA,MAC5B;AAAA,MACA,MAAM,SAAS;AAAA,IACjB;AACA,UAAM,aAAwB,CAAC,GAAG,SAAS,YAAY;AAGrD,WAAAA,kCAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,OAAO,QAAQ;AAAA,QAEf,OAAO,GAAG,GAAG;AAAA,QACb,aAAY;AAAA,QACZ,YAAY,cAAc,YAAY,cAAc;AAAA,QACpD,SAAS,CAAC,MAAM;AACd,YAAE,gBAAgB;AAClB,yBAAe,UAAU;AAAA,QAC3B;AAAA,QACA,YACEA,kCAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,MAAM;AAAA,YACN,MAAK;AAAA,YACL,SAAQ;AAAA,YACR,OAAM;AAAA,YACN,OAAM;AAAA,YACN,SAAS,CAAC,MAAM;AACd,gBAAE,gBAAgB;AAElB,4BAAc,UAAU;AAAA,YAAA;AAAA,UAC1B;AAAA,QACF;AAAA,QAGF,gDAAC,aAAa,EAAA,GAAG,OAAO,SAAS,YAAY,SAAS,WAAY,CAAA;AAAA,MAAA;AAAA,MAvB7D,KAAK,UAA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