@intlayer/design-system 4.0.0 → 4.0.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/README.md +39 -21
- package/dist/.vite/manifest.json +26 -156
- 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/DictionaryEditor/DictionaryEditor.cjs +3 -15
- 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 +3 -15
- package/dist/components/DictionaryEditor/DictionaryEditor.mjs.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.cjs +2 -2
- 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 +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.mjs.map +1 -1
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.cjs +2 -8
- 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 -8
- 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 +2 -20
- 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 +2 -20
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.cjs +7 -24
- 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 +7 -24
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.cjs +6 -35
- 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 +4 -33
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.cjs +5 -23
- 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 +8 -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 -29
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NodeEditor.cjs +6 -38
- 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 +6 -38
- package/dist/components/DictionaryFieldEditor/NodeEditor.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.cjs +3 -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 -27
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs +2 -14
- 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 +2 -14
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs.map +1 -1
- package/dist/components/Modal/Modal.cjs +1 -1
- package/dist/components/Modal/Modal.mjs +1 -1
- package/dist/components/Navbar/MobileNavbar.cjs +1 -1
- package/dist/components/Navbar/MobileNavbar.mjs +1 -1
- package/dist/components/RightDrawer/RightDrawer.cjs +2 -3
- package/dist/components/RightDrawer/RightDrawer.cjs.map +1 -1
- package/dist/components/RightDrawer/RightDrawer.mjs +1 -2
- package/dist/components/RightDrawer/RightDrawer.mjs.map +1 -1
- 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/usePersistedStore.cjs +8 -5
- 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 +8 -5
- 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-Cg-S9ry9.cjs +77 -0
- package/dist/index-Cg-S9ry9.cjs.map +1 -0
- package/dist/index-O_7rYrbW.js +78 -0
- package/dist/index-O_7rYrbW.js.map +1 -0
- package/package.json +18 -15
|
@@ -1,38 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("../../jsx-runtime-CgFM7lM3.cjs");
|
|
4
|
+
const editorReact = require("@intlayer/editor-react");
|
|
4
5
|
const require$$0 = require("react");
|
|
5
|
-
const shallow = require("../../shallow-lhDIFtEp.cjs");
|
|
6
|
-
const components_DictionaryEditor_useEditedContentStore = require("../DictionaryEditor/useEditedContentStore.cjs");
|
|
7
|
-
require("../DictionaryEditor/useEditionPanelStore.cjs");
|
|
8
|
-
require("@intlayer/core");
|
|
9
|
-
require("lucide-react");
|
|
10
|
-
require("clsx");
|
|
11
|
-
require("tailwind-merge");
|
|
12
|
-
require("../Button/Button.cjs");
|
|
13
|
-
require("../EditableField/EditableFieldInput.cjs");
|
|
14
|
-
require("../EditableField/EditableFieldTextArea.cjs");
|
|
15
|
-
require("react-intlayer");
|
|
16
|
-
require("../../hooks/useScrollBlockage/useScrollBlockageStore.cjs");
|
|
17
|
-
require("../../hooks/useAsync/useAsyncStateStore.cjs");
|
|
18
|
-
require("../../index-DFc7og1d.cjs");
|
|
19
|
-
require("@intlayer/config/client");
|
|
20
|
-
require("../Toaster/Toast.cjs");
|
|
21
|
-
require("@intlayer/dictionaries-entry");
|
|
22
|
-
require("deepmerge");
|
|
23
|
-
require("../Form/FormBase.cjs");
|
|
24
|
-
require("../Form/FormField.cjs");
|
|
25
|
-
require("../../Form-CSMiPnjC.cjs");
|
|
26
|
-
require("../DictionaryEditor/validDictionaryChangeButtons.content.cjs");
|
|
27
|
-
require("zod");
|
|
28
6
|
const components_IDE_MonacoCode = require("../IDE/MonacoCode.cjs");
|
|
29
7
|
const JSONEditor = ({ dictionary, isDarkMode }) => {
|
|
30
|
-
const { setEditedContent, editedContent } =
|
|
31
|
-
shallow.useShallow((s) => ({
|
|
32
|
-
editedContent: s.editedContent,
|
|
33
|
-
setEditedContent: s.setEditedContent
|
|
34
|
-
}))
|
|
35
|
-
);
|
|
8
|
+
const { setEditedContent, editedContent } = editorReact.useEditedContent();
|
|
36
9
|
const isValidJSON = (jsonString) => {
|
|
37
10
|
try {
|
|
38
11
|
JSON.parse(jsonString);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JSONEditor.cjs","sources":["../../../src/components/DictionaryFieldEditor/JSONEditor.tsx"],"sourcesContent":["import { Dictionary } from '@intlayer/core';\nimport {
|
|
1
|
+
{"version":3,"file":"JSONEditor.cjs","sources":["../../../src/components/DictionaryFieldEditor/JSONEditor.tsx"],"sourcesContent":["import { Dictionary } from '@intlayer/core';\nimport { useEditedContent } from '@intlayer/editor-react';\nimport { useMemo, type FC } from 'react';\nimport { MonacoCode } from '../IDE/MonacoCode';\n\ntype JSONEditorProps = {\n dictionary: Dictionary;\n isDarkMode?: boolean;\n};\n\nexport const JSONEditor: FC<JSONEditorProps> = ({ dictionary, isDarkMode }) => {\n const { setEditedContent, editedContent } = useEditedContent();\n\n const isValidJSON = (jsonString: string): boolean => {\n try {\n JSON.parse(jsonString);\n return true; // Valid JSON\n } catch (_error) {\n return false; // Invalid JSON\n }\n };\n\n const displayedContent = useMemo(\n () => editedContent[dictionary.key]?.content ?? dictionary?.content ?? {},\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [dictionary]\n );\n\n return (\n <div className=\"overflow-hidden rounded-md\">\n <MonacoCode\n language=\"json\"\n onChange={(content) => {\n if (isValidJSON(content ?? '{}')) {\n setEditedContent(dictionary.key, JSON.parse(content ?? '{}'));\n }\n }}\n isDarkMode={isDarkMode}\n >\n {JSON.stringify(displayedContent, null, 2)}\n </MonacoCode>\n </div>\n );\n};\n"],"names":["useEditedContent","useMemo","jsx","MonacoCode"],"mappings":";;;;;;AAUO,MAAM,aAAkC,CAAC,EAAE,YAAY,iBAAiB;AAC7E,QAAM,EAAE,kBAAkB,cAAc,IAAIA,6BAAiB;AAEvD,QAAA,cAAc,CAAC,eAAgC;AAC/C,QAAA;AACF,WAAK,MAAM,UAAU;AACd,aAAA;AAAA,aACA,QAAQ;AACR,aAAA;AAAA,IAAA;AAAA,EAEX;AAEA,QAAM,mBAAmBC,WAAA;AAAA,IACvB,MAAM,cAAc,WAAW,GAAG,GAAG,WAAW,YAAY,WAAW,CAAC;AAAA;AAAA,IAExE,CAAC,UAAU;AAAA,EACb;AAGE,SAAAC,2BAAAA,kBAAAA,IAAC,OAAI,EAAA,WAAU,8BACb,UAAAA,2BAAA,kBAAA;AAAA,IAACC,0BAAA;AAAA,IAAA;AAAA,MACC,UAAS;AAAA,MACT,UAAU,CAAC,YAAY;AACjB,YAAA,YAAY,WAAW,IAAI,GAAG;AAChC,2BAAiB,WAAW,KAAK,KAAK,MAAM,WAAW,IAAI,CAAC;AAAA,QAAA;AAAA,MAEhE;AAAA,MACA;AAAA,MAEC,UAAK,KAAA,UAAU,kBAAkB,MAAM,CAAC;AAAA,IAAA;AAAA,EAAA,GAE7C;AAEJ;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JSONEditor.d.ts","sourceRoot":"","sources":["../../../src/components/DictionaryFieldEditor/JSONEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"JSONEditor.d.ts","sourceRoot":"","sources":["../../../src/components/DictionaryFieldEditor/JSONEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAAW,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAGzC,KAAK,eAAe,GAAG;IACrB,UAAU,EAAE,UAAU,CAAC;IACvB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CAiC1C,CAAC"}
|
|
@@ -1,36 +1,9 @@
|
|
|
1
1
|
import { j as jsxRuntimeExports } from "../../jsx-runtime-DQkoUcjV.js";
|
|
2
|
+
import { useEditedContent } from "@intlayer/editor-react";
|
|
2
3
|
import { useMemo } from "react";
|
|
3
|
-
import { u as useShallow } from "../../shallow-m9BpCkKh.js";
|
|
4
|
-
import { useEditedContentStore } from "../DictionaryEditor/useEditedContentStore.mjs";
|
|
5
|
-
import "../DictionaryEditor/useEditionPanelStore.mjs";
|
|
6
|
-
import "@intlayer/core";
|
|
7
|
-
import "lucide-react";
|
|
8
|
-
import "clsx";
|
|
9
|
-
import "tailwind-merge";
|
|
10
|
-
import "../Button/Button.mjs";
|
|
11
|
-
import "../EditableField/EditableFieldInput.mjs";
|
|
12
|
-
import "../EditableField/EditableFieldTextArea.mjs";
|
|
13
|
-
import "react-intlayer";
|
|
14
|
-
import "../../hooks/useScrollBlockage/useScrollBlockageStore.mjs";
|
|
15
|
-
import "../../hooks/useAsync/useAsyncStateStore.mjs";
|
|
16
|
-
import "../../index-DcWYZrJW.js";
|
|
17
|
-
import "@intlayer/config/client";
|
|
18
|
-
import "../Toaster/Toast.mjs";
|
|
19
|
-
import "@intlayer/dictionaries-entry";
|
|
20
|
-
import "deepmerge";
|
|
21
|
-
import "../Form/FormBase.mjs";
|
|
22
|
-
import "../Form/FormField.mjs";
|
|
23
|
-
import "../../Form-DlqjTz3u.js";
|
|
24
|
-
import "../DictionaryEditor/validDictionaryChangeButtons.content.mjs";
|
|
25
|
-
import "zod";
|
|
26
4
|
import { MonacoCode } from "../IDE/MonacoCode.mjs";
|
|
27
5
|
const JSONEditor = ({ dictionary, isDarkMode }) => {
|
|
28
|
-
const { setEditedContent, editedContent } =
|
|
29
|
-
useShallow((s) => ({
|
|
30
|
-
editedContent: s.editedContent,
|
|
31
|
-
setEditedContent: s.setEditedContent
|
|
32
|
-
}))
|
|
33
|
-
);
|
|
6
|
+
const { setEditedContent, editedContent } = useEditedContent();
|
|
34
7
|
const isValidJSON = (jsonString) => {
|
|
35
8
|
try {
|
|
36
9
|
JSON.parse(jsonString);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JSONEditor.mjs","sources":["../../../src/components/DictionaryFieldEditor/JSONEditor.tsx"],"sourcesContent":["import { Dictionary } from '@intlayer/core';\nimport {
|
|
1
|
+
{"version":3,"file":"JSONEditor.mjs","sources":["../../../src/components/DictionaryFieldEditor/JSONEditor.tsx"],"sourcesContent":["import { Dictionary } from '@intlayer/core';\nimport { useEditedContent } from '@intlayer/editor-react';\nimport { useMemo, type FC } from 'react';\nimport { MonacoCode } from '../IDE/MonacoCode';\n\ntype JSONEditorProps = {\n dictionary: Dictionary;\n isDarkMode?: boolean;\n};\n\nexport const JSONEditor: FC<JSONEditorProps> = ({ dictionary, isDarkMode }) => {\n const { setEditedContent, editedContent } = useEditedContent();\n\n const isValidJSON = (jsonString: string): boolean => {\n try {\n JSON.parse(jsonString);\n return true; // Valid JSON\n } catch (_error) {\n return false; // Invalid JSON\n }\n };\n\n const displayedContent = useMemo(\n () => editedContent[dictionary.key]?.content ?? dictionary?.content ?? {},\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [dictionary]\n );\n\n return (\n <div className=\"overflow-hidden rounded-md\">\n <MonacoCode\n language=\"json\"\n onChange={(content) => {\n if (isValidJSON(content ?? '{}')) {\n setEditedContent(dictionary.key, JSON.parse(content ?? '{}'));\n }\n }}\n isDarkMode={isDarkMode}\n >\n {JSON.stringify(displayedContent, null, 2)}\n </MonacoCode>\n </div>\n );\n};\n"],"names":["jsx"],"mappings":";;;;AAUO,MAAM,aAAkC,CAAC,EAAE,YAAY,iBAAiB;AAC7E,QAAM,EAAE,kBAAkB,cAAc,IAAI,iBAAiB;AAEvD,QAAA,cAAc,CAAC,eAAgC;AAC/C,QAAA;AACF,WAAK,MAAM,UAAU;AACd,aAAA;AAAA,aACA,QAAQ;AACR,aAAA;AAAA,IAAA;AAAA,EAEX;AAEA,QAAM,mBAAmB;AAAA,IACvB,MAAM,cAAc,WAAW,GAAG,GAAG,WAAW,YAAY,WAAW,CAAC;AAAA;AAAA,IAExE,CAAC,UAAU;AAAA,EACb;AAGE,SAAAA,kCAAAA,IAAC,OAAI,EAAA,WAAU,8BACb,UAAAA,kCAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,UAAS;AAAA,MACT,UAAU,CAAC,YAAY;AACjB,YAAA,YAAY,WAAW,IAAI,GAAG;AAChC,2BAAiB,WAAW,KAAK,KAAK,MAAM,WAAW,IAAI,CAAC;AAAA,QAAA;AAAA,MAEhE;AAAA,MACA;AAAA,MAEC,UAAK,KAAA,UAAU,kBAAkB,MAAM,CAAC;AAAA,IAAA;AAAA,EAAA,GAE7C;AAEJ;"}
|
|
@@ -3,31 +3,13 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const jsxRuntime = require("../../../jsx-runtime-CgFM7lM3.cjs");
|
|
4
4
|
const client = require("@intlayer/config/client");
|
|
5
5
|
const core = require("@intlayer/core");
|
|
6
|
+
const editorReact = require("@intlayer/editor-react");
|
|
6
7
|
const lucideReact = require("lucide-react");
|
|
7
8
|
const require$$0 = require("react");
|
|
8
9
|
const reactIntlayer = require("react-intlayer");
|
|
9
|
-
const shallow = require("../../../shallow-lhDIFtEp.cjs");
|
|
10
10
|
const utils_camelCase = require("../../../utils/camelCase.cjs");
|
|
11
|
-
const utils_dictionary = require("../../../utils/dictionary.cjs");
|
|
12
11
|
const components_Accordion_Accordion = require("../../Accordion/Accordion.cjs");
|
|
13
12
|
const components_Button_Button = require("../../Button/Button.cjs");
|
|
14
|
-
const components_DictionaryEditor_useEditedContentStore = require("../../DictionaryEditor/useEditedContentStore.cjs");
|
|
15
|
-
const components_DictionaryEditor_useEditionPanelStore = require("../../DictionaryEditor/useEditionPanelStore.cjs");
|
|
16
|
-
require("clsx");
|
|
17
|
-
require("tailwind-merge");
|
|
18
|
-
require("../../EditableField/EditableFieldInput.cjs");
|
|
19
|
-
require("../../EditableField/EditableFieldTextArea.cjs");
|
|
20
|
-
require("../../../hooks/useScrollBlockage/useScrollBlockageStore.cjs");
|
|
21
|
-
require("../../../hooks/useAsync/useAsyncStateStore.cjs");
|
|
22
|
-
require("../../../index-DFc7og1d.cjs");
|
|
23
|
-
require("../../Toaster/Toast.cjs");
|
|
24
|
-
require("@intlayer/dictionaries-entry");
|
|
25
|
-
require("deepmerge");
|
|
26
|
-
require("../../Form/FormBase.cjs");
|
|
27
|
-
require("../../Form/FormField.cjs");
|
|
28
|
-
require("../../../Form-CSMiPnjC.cjs");
|
|
29
|
-
require("../../DictionaryEditor/validDictionaryChangeButtons.content.cjs");
|
|
30
|
-
require("zod");
|
|
31
13
|
const components_DictionaryFieldEditor_getIsEditableSection = require("../getIsEditableSection.cjs");
|
|
32
14
|
const components_DictionaryFieldEditor_NavigationView_navigationViewNode_content = require("./navigationViewNode.content.cjs");
|
|
33
15
|
const traceKeys = ["filePath", "id", "nodeType"];
|
|
@@ -37,16 +19,9 @@ const NavigationViewNode = ({
|
|
|
37
19
|
dictionaryKey
|
|
38
20
|
}) => {
|
|
39
21
|
const { locales } = client.getConfiguration().internationalization;
|
|
40
|
-
const section =
|
|
41
|
-
const addEditedContent =
|
|
42
|
-
|
|
43
|
-
);
|
|
44
|
-
const { setFocusedContentKeyPath, focusedContent } = components_DictionaryEditor_useEditionPanelStore.useEditionPanelStore(
|
|
45
|
-
shallow.useShallow((s) => ({
|
|
46
|
-
setFocusedContentKeyPath: s.setFocusedContentKeyPath,
|
|
47
|
-
focusedContent: s.focusedContent
|
|
48
|
-
}))
|
|
49
|
-
);
|
|
22
|
+
const section = core.getDictionaryValueByKeyPath(sectionProp, keyPath);
|
|
23
|
+
const { addEditedContent } = editorReact.useEditedContentActions();
|
|
24
|
+
const { setFocusedContentKeyPath, focusedContent } = editorReact.useFocusDictionary();
|
|
50
25
|
const {
|
|
51
26
|
addNewElement,
|
|
52
27
|
addNewField,
|
|
@@ -55,7 +30,7 @@ const NavigationViewNode = ({
|
|
|
55
30
|
goToEnumeration,
|
|
56
31
|
goToTranslation
|
|
57
32
|
} = reactIntlayer.useDictionary(components_DictionaryFieldEditor_NavigationView_navigationViewNode_content.navigationViewContent);
|
|
58
|
-
const nodeType =
|
|
33
|
+
const nodeType = core.getSectionType(section);
|
|
59
34
|
const isEditableSection = components_DictionaryFieldEditor_getIsEditableSection.getIsEditableSection(section);
|
|
60
35
|
const getIsSelected = require$$0.useCallback(
|
|
61
36
|
(keyPath2) => (focusedContent?.keyPath?.length ?? 0) > 0 && core.isSameKeyPath(keyPath2, focusedContent?.keyPath ?? []),
|
|
@@ -73,7 +48,7 @@ const NavigationViewNode = ({
|
|
|
73
48
|
...keyPath,
|
|
74
49
|
{ type: core.NodeType.Translation, key: translationKey }
|
|
75
50
|
];
|
|
76
|
-
const subSection =
|
|
51
|
+
const subSection = core.getDictionaryValueByKeyPath(
|
|
77
52
|
sectionProp,
|
|
78
53
|
childKeyPath
|
|
79
54
|
);
|
|
@@ -122,7 +97,7 @@ const NavigationViewNode = ({
|
|
|
122
97
|
...keyPath,
|
|
123
98
|
{ type: core.NodeType.Enumeration, key }
|
|
124
99
|
];
|
|
125
|
-
const subSection =
|
|
100
|
+
const subSection = core.getDictionaryValueByKeyPath(
|
|
126
101
|
sectionProp,
|
|
127
102
|
childKeyPath
|
|
128
103
|
);
|
|
@@ -237,7 +212,7 @@ const NavigationViewNode = ({
|
|
|
237
212
|
...keyPath,
|
|
238
213
|
{ type: core.NodeType.Object, key }
|
|
239
214
|
];
|
|
240
|
-
const subSection =
|
|
215
|
+
const subSection = core.getDictionaryValueByKeyPath(
|
|
241
216
|
sectionProp,
|
|
242
217
|
childKeyPath
|
|
243
218
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationViewNode.cjs","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/client';\nimport {\n type EnumerationContent,\n NodeType,\n type KeyPath,\n type DictionaryValue,\n isSameKeyPath,\n} from '@intlayer/core';\nimport { ChevronRight, Plus } from 'lucide-react';\nimport { useCallback, type FC } from 'react';\n// @ts-ignore react-intlayer not build yet\nimport { useDictionary } from 'react-intlayer';\nimport { useShallow } from 'zustand/react/shallow';\nimport { camelCaseToSentence } from '../../../utils/camelCase';\nimport {\n getDictionaryValueByKeyPath,\n getSectionType,\n} from '../../../utils/dictionary';\nimport { Accordion } from '../../Accordion';\nimport { Button } from '../../Button';\nimport {\n useEditedContentStore,\n useEditionPanelStore,\n} from '../../DictionaryEditor';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from './navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nexport type NodeWrapperProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: DictionaryValue;\n};\n\nexport const NavigationViewNode: FC<NodeWrapperProps> = ({\n section: sectionProp,\n keyPath,\n dictionaryKey,\n}) => {\n const { locales } = getConfiguration().internationalization;\n const section = getDictionaryValueByKeyPath(sectionProp, keyPath);\n const addEditedContent = useEditedContentStore(\n useShallow((s) => s.addEditedContent)\n );\n const { setFocusedContentKeyPath, focusedContent } = useEditionPanelStore(\n useShallow((s) => ({\n setFocusedContentKeyPath: s.setFocusedContentKeyPath,\n focusedContent: s.focusedContent,\n }))\n );\n const {\n addNewElement,\n addNewField,\n goToElement,\n goToField,\n goToEnumeration,\n goToTranslation,\n } = useDictionary(navigationViewContent);\n const nodeType = getSectionType(section);\n const isEditableSection = getIsEditableSection(section);\n const getIsSelected = useCallback(\n (keyPath: KeyPath[]) =>\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(keyPath, focusedContent?.keyPath ?? []),\n [focusedContent?.keyPath]\n );\n\n if (isEditableSection) return <>-</>;\n\n if (!section) return <>-</>;\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return <>React Node</>;\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {locales.map((translationKey) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ];\n const subSection = getDictionaryValueByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToTranslation.label} ${translationKey}`}\n key={translationKey}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {translationKey}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={translationKey}\n label={`${goToTranslation.label} ${translationKey}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={translationKey}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {Object.keys(\n (section as EnumerationContent<DictionaryValue>)[\n NodeType.Enumeration\n ]\n ).map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Enumeration, key },\n ];\n const subSection = getDictionaryValueByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToEnumeration.label} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {key}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n label={`${goToEnumeration.label} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={key}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {(section as DictionaryValue[]).map((subSection, index) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Array, key: index },\n ];\n\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToElement.label} ${index}`}\n key={`${index}`}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {index}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={`${index}`}\n label={`${goToElement.label} ${index}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={index}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n\n <Button\n label={addNewElement.label}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as DictionaryValue[]).length,\n },\n ];\n addEditedContent(dictionaryKey, {}, newKeyPath, false);\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n }\n\n const sectionArray = Object.keys(section);\n return (\n <div className=\"flex w-full max-w-full flex-col justify-between gap-2\">\n {sectionArray.map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key },\n ];\n const subSection = getDictionaryValueByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToField.label} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(key)}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n label={`${goToField.label} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={camelCaseToSentence(key)}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n\n <Button\n label={addNewField.label}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key: 'newField' },\n ];\n addEditedContent(dictionaryKey, {}, newKeyPath, false);\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewField.text}\n </Button>\n </div>\n );\n }\n\n return (\n <>\n Error loading section --\n {nodeType}\n --\n {JSON.stringify(section)}\n --\n {JSON.stringify(keyPath)}\n </>\n );\n};\n"],"names":["getConfiguration","getDictionaryValueByKeyPath","useEditedContentStore","useShallow","useEditionPanelStore","useDictionary","navigationViewContent","getSectionType","getIsEditableSection","useCallback","keyPath","isSameKeyPath","jsx","Fragment","NodeType","Button","ChevronRight","Accordion","jsxs","Plus","camelCaseToSentence"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BO,MAAM,YAAsB,CAAC,YAAY,MAAM,UAAU;AAQzD,MAAM,qBAA2C,CAAC;AAAA,EACvD,SAAS;AAAA,EACT;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,QAAA,IAAYA,OAAA,iBAAA,EAAmB;AACjC,QAAA,UAAUC,iBAAAA,4BAA4B,aAAa,OAAO;AAChE,QAAM,mBAAmBC,kDAAA;AAAA,IACvBC,mBAAW,CAAC,MAAM,EAAE,gBAAgB;AAAA,EACtC;AACM,QAAA,EAAE,0BAA0B,eAAA,IAAmBC,iDAAA;AAAA,IACnDD,QAAA,WAAW,CAAC,OAAO;AAAA,MACjB,0BAA0B,EAAE;AAAA,MAC5B,gBAAgB,EAAE;AAAA,IAAA,EACl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AAA,MAAA;AAAA,IACf,GACF;AAAA,EAAA;AAIJ,SACID,2BAAA,kBAAA,KAAAL,uCAAA,EAAA,UAAA;AAAA,IAAA;AAAA,IAEC;AAAA,IAAS;AAAA,IAET,KAAK,UAAU,OAAO;AAAA,IAAE;AAAA,IAExB,KAAK,UAAU,OAAO;AAAA,EAAA,GACzB;AAEJ;;;"}
|
|
1
|
+
{"version":3,"file":"NavigationViewNode.cjs","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/client';\nimport {\n type EnumerationContent,\n NodeType,\n type KeyPath,\n type DictionaryValue,\n isSameKeyPath,\n getDictionaryValueByKeyPath,\n getSectionType,\n} from '@intlayer/core';\nimport {\n useEditedContentActions,\n useFocusDictionary,\n} from '@intlayer/editor-react';\nimport { ChevronRight, Plus } from 'lucide-react';\nimport { useCallback, type FC } from 'react';\n// @ts-ignore react-intlayer not build yet\nimport { useDictionary } from 'react-intlayer';\nimport { camelCaseToSentence } from '../../../utils/camelCase';\nimport { Accordion } from '../../Accordion';\nimport { Button } from '../../Button';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from './navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nexport type NodeWrapperProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: DictionaryValue;\n};\n\nexport const NavigationViewNode: FC<NodeWrapperProps> = ({\n section: sectionProp,\n keyPath,\n dictionaryKey,\n}) => {\n const { locales } = getConfiguration().internationalization;\n const section = getDictionaryValueByKeyPath(sectionProp, keyPath);\n const { addEditedContent } = useEditedContentActions();\n const { setFocusedContentKeyPath, focusedContent } = useFocusDictionary();\n const {\n addNewElement,\n addNewField,\n goToElement,\n goToField,\n goToEnumeration,\n goToTranslation,\n } = useDictionary(navigationViewContent);\n const nodeType = getSectionType(section);\n const isEditableSection = getIsEditableSection(section);\n const getIsSelected = useCallback(\n (keyPath: KeyPath[]) =>\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(keyPath, focusedContent?.keyPath ?? []),\n [focusedContent?.keyPath]\n );\n\n if (isEditableSection) return <>-</>;\n\n if (!section) return <>-</>;\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return <>React Node</>;\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {locales.map((translationKey) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ];\n const subSection = getDictionaryValueByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToTranslation.label} ${translationKey}`}\n key={translationKey}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {translationKey}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={translationKey}\n label={`${goToTranslation.label} ${translationKey}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={translationKey}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {Object.keys(\n (section as EnumerationContent<DictionaryValue>)[\n NodeType.Enumeration\n ]\n ).map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Enumeration, key },\n ];\n const subSection = getDictionaryValueByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToEnumeration.label} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {key}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n label={`${goToEnumeration.label} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={key}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {(section as DictionaryValue[]).map((subSection, index) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Array, key: index },\n ];\n\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToElement.label} ${index}`}\n key={`${index}`}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {index}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={`${index}`}\n label={`${goToElement.label} ${index}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={index}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n\n <Button\n label={addNewElement.label}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as DictionaryValue[]).length,\n },\n ];\n addEditedContent(dictionaryKey, {}, newKeyPath, false);\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n }\n\n const sectionArray = Object.keys(section);\n return (\n <div className=\"flex w-full max-w-full flex-col justify-between gap-2\">\n {sectionArray.map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key },\n ];\n const subSection = getDictionaryValueByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToField.label} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(key)}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n label={`${goToField.label} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={camelCaseToSentence(key)}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n\n <Button\n label={addNewField.label}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key: 'newField' },\n ];\n addEditedContent(dictionaryKey, {}, newKeyPath, false);\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewField.text}\n </Button>\n </div>\n );\n }\n\n return (\n <>\n Error loading section --\n {nodeType}\n --\n {JSON.stringify(section)}\n --\n {JSON.stringify(keyPath)}\n </>\n );\n};\n"],"names":["getConfiguration","getDictionaryValueByKeyPath","useEditedContentActions","useFocusDictionary","useDictionary","navigationViewContent","getSectionType","getIsEditableSection","useCallback","keyPath","isSameKeyPath","jsx","Fragment","NodeType","Button","ChevronRight","Accordion","jsxs","Plus","camelCaseToSentence"],"mappings":";;;;;;;;;;;;;;AAwBO,MAAM,YAAsB,CAAC,YAAY,MAAM,UAAU;AAQzD,MAAM,qBAA2C,CAAC;AAAA,EACvD,SAAS;AAAA,EACT;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,QAAA,IAAYA,OAAA,iBAAA,EAAmB;AACjC,QAAA,UAAUC,KAAAA,4BAA4B,aAAa,OAAO;AAC1D,QAAA,EAAE,iBAAiB,IAAIC,oCAAwB;AACrD,QAAM,EAAE,0BAA0B,eAAe,IAAIC,+BAAmB;AAClE,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACEC,cAAAA,cAAcC,2EAAAA,qBAAqB;AACjC,QAAA,WAAWC,oBAAe,OAAO;AACjC,QAAA,oBAAoBC,2EAAqB,OAAO;AACtD,QAAM,gBAAgBC,WAAA;AAAA,IACpB,CAACC,cACE,gBAAgB,SAAS,UAAU,KAAK,KACzCC,KAAA,cAAcD,UAAS,gBAAgB,WAAW,CAAA,CAAE;AAAA,IACtD,CAAC,gBAAgB,OAAO;AAAA,EAC1B;AAEI,MAAA,kBAA0B,QAAAE,2BAAA,kBAAA,IAAAC,WAAA,kBAAA,UAAA,EAAE,UAAC,KAAA;AAEjC,MAAI,CAAC,QAAgB,QAAAD,2BAAA,kBAAA,IAAAC,WAAA,kBAAA,UAAA,EAAE,UAAC,KAAA;AAEpB,MAAA,OAAO,YAAY,UAAU;AAC3B,QAAA,aAAaC,cAAS,WAAW;AACnC,uGAAS,UAAU,aAAA,CAAA;AAAA,IAAA;AAGjB,QAAA,aAAaA,cAAS,aAAa;AACrC,8DACG,OAAI,EAAA,WAAU,uCACZ,UAA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ACT;AAAA,cAAA;AAAA,eAEJ,EACF,CAAA;AAAA,UAAA;AAAA,UAdK;AAAA,QAeP;AAAA,MAAA,CAEH;AAAA,MAEDA,2BAAA,kBAAA;AAAA,QAACG,yBAAA;AAAA,QAAA;AAAA,UACC,OAAO,YAAY;AAAA,UACnB,SAAQ;AAAA,UACR,OAAM;AAAA,UACN,WAAU;AAAA,UACV,SAAS,MAAM;AACb,kBAAM,aAAwB;AAAA,cAC5B,GAAG;AAAA,cACH,EAAE,MAAMD,KAAAA,SAAS,QAAQ,KAAK,WAAW;AAAA,YAC3C;AACA,6BAAiB,eAAe,IAAI,YAAY,KAAK;AACrD,qCAAyB,UAAU;AAAA,UACrC;AAAA,UACA,MAAMK,YAAA;AAAA,UAEL,UAAY,YAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACf,GACF;AAAA,EAAA;AAIJ,SACID,2BAAA,kBAAA,KAAAL,uCAAA,EAAA,UAAA;AAAA,IAAA;AAAA,IAEC;AAAA,IAAS;AAAA,IAET,KAAK,UAAU,OAAO;AAAA,IAAE;AAAA,IAExB,KAAK,UAAU,OAAO;AAAA,EAAA,GACzB;AAEJ;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationViewNode.d.ts","sourceRoot":"","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,OAAO,EACZ,KAAK,eAAe,
|
|
1
|
+
{"version":3,"file":"NavigationViewNode.d.ts","sourceRoot":"","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,OAAO,EACZ,KAAK,eAAe,EAIrB,MAAM,gBAAgB,CAAC;AAMxB,OAAO,EAAe,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAS7C,eAAO,MAAM,SAAS,EAAE,MAAM,EAAmC,CAAC;AAElE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,OAAO,EAAE,eAAe,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,EAAE,CAAC,gBAAgB,CAiTnD,CAAC"}
|
|
@@ -1,31 +1,13 @@
|
|
|
1
1
|
import { j as jsxRuntimeExports } from "../../../jsx-runtime-DQkoUcjV.js";
|
|
2
2
|
import { getConfiguration } from "@intlayer/config/client";
|
|
3
|
-
import { isSameKeyPath, NodeType } from "@intlayer/core";
|
|
3
|
+
import { getDictionaryValueByKeyPath, getSectionType, isSameKeyPath, NodeType } from "@intlayer/core";
|
|
4
|
+
import { useEditedContentActions, useFocusDictionary } from "@intlayer/editor-react";
|
|
4
5
|
import { ChevronRight, Plus } from "lucide-react";
|
|
5
6
|
import { useCallback } from "react";
|
|
6
7
|
import { useDictionary } from "react-intlayer";
|
|
7
|
-
import { u as useShallow } from "../../../shallow-m9BpCkKh.js";
|
|
8
8
|
import { camelCaseToSentence } from "../../../utils/camelCase.mjs";
|
|
9
|
-
import { getDictionaryValueByKeyPath, getSectionType } from "../../../utils/dictionary.mjs";
|
|
10
9
|
import { Accordion } from "../../Accordion/Accordion.mjs";
|
|
11
10
|
import { Button } from "../../Button/Button.mjs";
|
|
12
|
-
import { useEditedContentStore } from "../../DictionaryEditor/useEditedContentStore.mjs";
|
|
13
|
-
import { useEditionPanelStore } from "../../DictionaryEditor/useEditionPanelStore.mjs";
|
|
14
|
-
import "clsx";
|
|
15
|
-
import "tailwind-merge";
|
|
16
|
-
import "../../EditableField/EditableFieldInput.mjs";
|
|
17
|
-
import "../../EditableField/EditableFieldTextArea.mjs";
|
|
18
|
-
import "../../../hooks/useScrollBlockage/useScrollBlockageStore.mjs";
|
|
19
|
-
import "../../../hooks/useAsync/useAsyncStateStore.mjs";
|
|
20
|
-
import "../../../index-DcWYZrJW.js";
|
|
21
|
-
import "../../Toaster/Toast.mjs";
|
|
22
|
-
import "@intlayer/dictionaries-entry";
|
|
23
|
-
import "deepmerge";
|
|
24
|
-
import "../../Form/FormBase.mjs";
|
|
25
|
-
import "../../Form/FormField.mjs";
|
|
26
|
-
import "../../../Form-DlqjTz3u.js";
|
|
27
|
-
import "../../DictionaryEditor/validDictionaryChangeButtons.content.mjs";
|
|
28
|
-
import "zod";
|
|
29
11
|
import { getIsEditableSection } from "../getIsEditableSection.mjs";
|
|
30
12
|
import { navigationViewContent } from "./navigationViewNode.content.mjs";
|
|
31
13
|
const traceKeys = ["filePath", "id", "nodeType"];
|
|
@@ -36,15 +18,8 @@ const NavigationViewNode = ({
|
|
|
36
18
|
}) => {
|
|
37
19
|
const { locales } = getConfiguration().internationalization;
|
|
38
20
|
const section = getDictionaryValueByKeyPath(sectionProp, keyPath);
|
|
39
|
-
const addEditedContent =
|
|
40
|
-
|
|
41
|
-
);
|
|
42
|
-
const { setFocusedContentKeyPath, focusedContent } = useEditionPanelStore(
|
|
43
|
-
useShallow((s) => ({
|
|
44
|
-
setFocusedContentKeyPath: s.setFocusedContentKeyPath,
|
|
45
|
-
focusedContent: s.focusedContent
|
|
46
|
-
}))
|
|
47
|
-
);
|
|
21
|
+
const { addEditedContent } = useEditedContentActions();
|
|
22
|
+
const { setFocusedContentKeyPath, focusedContent } = useFocusDictionary();
|
|
48
23
|
const {
|
|
49
24
|
addNewElement,
|
|
50
25
|
addNewField,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationViewNode.mjs","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/client';\nimport {\n type EnumerationContent,\n NodeType,\n type KeyPath,\n type DictionaryValue,\n isSameKeyPath,\n} from '@intlayer/core';\nimport { ChevronRight, Plus } from 'lucide-react';\nimport { useCallback, type FC } from 'react';\n// @ts-ignore react-intlayer not build yet\nimport { useDictionary } from 'react-intlayer';\nimport { useShallow } from 'zustand/react/shallow';\nimport { camelCaseToSentence } from '../../../utils/camelCase';\nimport {\n getDictionaryValueByKeyPath,\n getSectionType,\n} from '../../../utils/dictionary';\nimport { Accordion } from '../../Accordion';\nimport { Button } from '../../Button';\nimport {\n useEditedContentStore,\n useEditionPanelStore,\n} from '../../DictionaryEditor';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from './navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nexport type NodeWrapperProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: DictionaryValue;\n};\n\nexport const NavigationViewNode: FC<NodeWrapperProps> = ({\n section: sectionProp,\n keyPath,\n dictionaryKey,\n}) => {\n const { locales } = getConfiguration().internationalization;\n const section = getDictionaryValueByKeyPath(sectionProp, keyPath);\n const addEditedContent = useEditedContentStore(\n useShallow((s) => s.addEditedContent)\n );\n const { setFocusedContentKeyPath, focusedContent } = useEditionPanelStore(\n useShallow((s) => ({\n setFocusedContentKeyPath: s.setFocusedContentKeyPath,\n focusedContent: s.focusedContent,\n }))\n );\n const {\n addNewElement,\n addNewField,\n goToElement,\n goToField,\n goToEnumeration,\n goToTranslation,\n } = useDictionary(navigationViewContent);\n const nodeType = getSectionType(section);\n const isEditableSection = getIsEditableSection(section);\n const getIsSelected = useCallback(\n (keyPath: KeyPath[]) =>\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(keyPath, focusedContent?.keyPath ?? []),\n [focusedContent?.keyPath]\n );\n\n if (isEditableSection) return <>-</>;\n\n if (!section) return <>-</>;\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return <>React Node</>;\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {locales.map((translationKey) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ];\n const subSection = getDictionaryValueByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToTranslation.label} ${translationKey}`}\n key={translationKey}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {translationKey}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={translationKey}\n label={`${goToTranslation.label} ${translationKey}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={translationKey}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {Object.keys(\n (section as EnumerationContent<DictionaryValue>)[\n NodeType.Enumeration\n ]\n ).map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Enumeration, key },\n ];\n const subSection = getDictionaryValueByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToEnumeration.label} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {key}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n label={`${goToEnumeration.label} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={key}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {(section as DictionaryValue[]).map((subSection, index) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Array, key: index },\n ];\n\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToElement.label} ${index}`}\n key={`${index}`}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {index}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={`${index}`}\n label={`${goToElement.label} ${index}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={index}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n\n <Button\n label={addNewElement.label}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as DictionaryValue[]).length,\n },\n ];\n addEditedContent(dictionaryKey, {}, newKeyPath, false);\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n }\n\n const sectionArray = Object.keys(section);\n return (\n <div className=\"flex w-full max-w-full flex-col justify-between gap-2\">\n {sectionArray.map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key },\n ];\n const subSection = getDictionaryValueByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToField.label} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(key)}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n label={`${goToField.label} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={camelCaseToSentence(key)}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n\n <Button\n label={addNewField.label}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key: 'newField' },\n ];\n addEditedContent(dictionaryKey, {}, newKeyPath, false);\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewField.text}\n </Button>\n </div>\n );\n }\n\n return (\n <>\n Error loading section --\n {nodeType}\n --\n {JSON.stringify(section)}\n --\n {JSON.stringify(keyPath)}\n </>\n );\n};\n"],"names":["keyPath","jsx","Fragment","jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BO,MAAM,YAAsB,CAAC,YAAY,MAAM,UAAU;AAQzD,MAAM,qBAA2C,CAAC;AAAA,EACvD,SAAS;AAAA,EACT;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,QAAA,IAAY,iBAAA,EAAmB;AACjC,QAAA,UAAU,4BAA4B,aAAa,OAAO;AAChE,QAAM,mBAAmB;AAAA,IACvB,WAAW,CAAC,MAAM,EAAE,gBAAgB;AAAA,EACtC;AACM,QAAA,EAAE,0BAA0B,eAAA,IAAmB;AAAA,IACnD,WAAW,CA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WAAW;AAAA,cAEV,8BAAoB,GAAG;AAAA,YAAA;AAAA,YARnB;AAAA,UASP;AAAA,QAAA;AAKF,eAAAA,kCAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YAEC,OAAO,GAAG,UAAU,KAAK,IAAI,GAAG;AAAA,YAChC,UAAU,cAAc,YAAY;AAAA,YACpC,SAAS,MAAM,yBAAyB,YAAY;AAAA,YACpD,QAAQ,oBAAoB,GAAG;AAAA,YAE/B,gDAAC,OAAI,EAAA,WAAU,+BACb,UAACA,kCAAA,IAAA,OAAA,EAAI,WAAU,gBACb,UAAAA,kCAAA;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,SAAS;AAAA,gBACT,SAAS;AAAA,gBACT;AAAA,cAAA;AAAA,eAEJ,EACF,CAAA;AAAA,UAAA;AAAA,UAdK;AAAA,QAeP;AAAA,MAAA,CAEH;AAAA,MAEDA,kCAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,OAAO,YAAY;AAAA,UACnB,SAAQ;AAAA,UACR,OAAM;AAAA,UACN,WAAU;AAAA,UACV,SAAS,MAAM;AACb,kBAAM,aAAwB;AAAA,cAC5B,GAAG;AAAA,cACH,EAAE,MAAM,SAAS,QAAQ,KAAK,WAAW;AAAA,YAC3C;AACA,6BAAiB,eAAe,IAAI,YAAY,KAAK;AACrD,qCAAyB,UAAU;AAAA,UACrC;AAAA,UACA,MAAM;AAAA,UAEL,UAAY,YAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACf,GACF;AAAA,EAAA;AAIJ,SACIE,kCAAA,KAAAD,4BAAA,EAAA,UAAA;AAAA,IAAA;AAAA,IAEC;AAAA,IAAS;AAAA,IAET,KAAK,UAAU,OAAO;AAAA,IAAE;AAAA,IAExB,KAAK,UAAU,OAAO;AAAA,EAAA,GACzB;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"NavigationViewNode.mjs","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/client';\nimport {\n type EnumerationContent,\n NodeType,\n type KeyPath,\n type DictionaryValue,\n isSameKeyPath,\n getDictionaryValueByKeyPath,\n getSectionType,\n} from '@intlayer/core';\nimport {\n useEditedContentActions,\n useFocusDictionary,\n} from '@intlayer/editor-react';\nimport { ChevronRight, Plus } from 'lucide-react';\nimport { useCallback, type FC } from 'react';\n// @ts-ignore react-intlayer not build yet\nimport { useDictionary } from 'react-intlayer';\nimport { camelCaseToSentence } from '../../../utils/camelCase';\nimport { Accordion } from '../../Accordion';\nimport { Button } from '../../Button';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from './navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\nexport type NodeWrapperProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n section: DictionaryValue;\n};\n\nexport const NavigationViewNode: FC<NodeWrapperProps> = ({\n section: sectionProp,\n keyPath,\n dictionaryKey,\n}) => {\n const { locales } = getConfiguration().internationalization;\n const section = getDictionaryValueByKeyPath(sectionProp, keyPath);\n const { addEditedContent } = useEditedContentActions();\n const { setFocusedContentKeyPath, focusedContent } = useFocusDictionary();\n const {\n addNewElement,\n addNewField,\n goToElement,\n goToField,\n goToEnumeration,\n goToTranslation,\n } = useDictionary(navigationViewContent);\n const nodeType = getSectionType(section);\n const isEditableSection = getIsEditableSection(section);\n const getIsSelected = useCallback(\n (keyPath: KeyPath[]) =>\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(keyPath, focusedContent?.keyPath ?? []),\n [focusedContent?.keyPath]\n );\n\n if (isEditableSection) return <>-</>;\n\n if (!section) return <>-</>;\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return <>React Node</>;\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {locales.map((translationKey) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ];\n const subSection = getDictionaryValueByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToTranslation.label} ${translationKey}`}\n key={translationKey}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {translationKey}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={translationKey}\n label={`${goToTranslation.label} ${translationKey}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={translationKey}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {Object.keys(\n (section as EnumerationContent<DictionaryValue>)[\n NodeType.Enumeration\n ]\n ).map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Enumeration, key },\n ];\n const subSection = getDictionaryValueByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToEnumeration.label} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {key}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n label={`${goToEnumeration.label} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={key}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {(section as DictionaryValue[]).map((subSection, index) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Array, key: index },\n ];\n\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToElement.label} ${index}`}\n key={`${index}`}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {index}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={`${index}`}\n label={`${goToElement.label} ${index}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={index}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n\n <Button\n label={addNewElement.label}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as DictionaryValue[]).length,\n },\n ];\n addEditedContent(dictionaryKey, {}, newKeyPath, false);\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n }\n\n const sectionArray = Object.keys(section);\n return (\n <div className=\"flex w-full max-w-full flex-col justify-between gap-2\">\n {sectionArray.map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key },\n ];\n const subSection = getDictionaryValueByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToField.label} ${key}`}\n key={key}\n isActive={getIsSelected(childKeyPath)}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(key)}\n </Button>\n );\n }\n\n return (\n <Accordion\n key={key}\n label={`${goToField.label} ${key}`}\n isActive={getIsSelected(childKeyPath)}\n onClick={() => setFocusedContentKeyPath(childKeyPath)}\n header={camelCaseToSentence(key)}\n >\n <div className=\"mt-2 flex w-full max-w-full\">\n <div className=\"flex-1 pl-10\">\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n </div>\n </div>\n </Accordion>\n );\n })}\n\n <Button\n label={addNewField.label}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key: 'newField' },\n ];\n addEditedContent(dictionaryKey, {}, newKeyPath, false);\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewField.text}\n </Button>\n </div>\n );\n }\n\n return (\n <>\n Error loading section --\n {nodeType}\n --\n {JSON.stringify(section)}\n --\n {JSON.stringify(keyPath)}\n </>\n );\n};\n"],"names":["keyPath","jsx","Fragment","jsxs"],"mappings":";;;;;;;;;;;;AAwBO,MAAM,YAAsB,CAAC,YAAY,MAAM,UAAU;AAQzD,MAAM,qBAA2C,CAAC;AAAA,EACvD,SAAS;AAAA,EACT;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,QAAA,IAAY,iBAAA,EAAmB;AACjC,QAAA,UAAU,4BAA4B,aAAa,OAAO;AAC1D,QAAA,EAAE,iBAAiB,IAAI,wBAAwB;AACrD,QAAM,EAAE,0BAA0B,eAAe,IAAI,mBA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AAA,kCAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YAEC,OAAO,GAAG,UAAU,KAAK,IAAI,GAAG;AAAA,YAChC,UAAU,cAAc,YAAY;AAAA,YACpC,SAAS,MAAM,yBAAyB,YAAY;AAAA,YACpD,QAAQ,oBAAoB,GAAG;AAAA,YAE/B,gDAAC,OAAI,EAAA,WAAU,+BACb,UAACA,kCAAA,IAAA,OAAA,EAAI,WAAU,gBACb,UAAAA,kCAAA;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,SAAS;AAAA,gBACT,SAAS;AAAA,gBACT;AAAA,cAAA;AAAA,eAEJ,EACF,CAAA;AAAA,UAAA;AAAA,UAdK;AAAA,QAeP;AAAA,MAAA,CAEH;AAAA,MAEDA,kCAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,OAAO,YAAY;AAAA,UACnB,SAAQ;AAAA,UACR,OAAM;AAAA,UACN,WAAU;AAAA,UACV,SAAS,MAAM;AACb,kBAAM,aAAwB;AAAA,cAC5B,GAAG;AAAA,cACH,EAAE,MAAM,SAAS,QAAQ,KAAK,WAAW;AAAA,YAC3C;AACA,6BAAiB,eAAe,IAAI,YAAY,KAAK;AACrD,qCAAyB,UAAU;AAAA,UACrC;AAAA,UACA,MAAM;AAAA,UAEL,UAAY,YAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACf,GACF;AAAA,EAAA;AAIJ,SACIE,kCAAA,KAAAD,4BAAA,EAAA,UAAA;AAAA,IAAA;AAAA,IAEC;AAAA,IAAS;AAAA,IAET,KAAK,UAAU,OAAO;AAAA,IAAE;AAAA,IAExB,KAAK,UAAU,OAAO;AAAA,EAAA,GACzB;AAEJ;"}
|
|
@@ -2,31 +2,9 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
4
|
const jsxRuntime = require("../../jsx-runtime-CgFM7lM3.cjs");
|
|
5
|
+
const editorReact = require("@intlayer/editor-react");
|
|
5
6
|
const require$$0 = require("react");
|
|
6
|
-
const shallow = require("../../shallow-lhDIFtEp.cjs");
|
|
7
7
|
const components_Container_index = require("../Container/index.cjs");
|
|
8
|
-
const components_DictionaryEditor_useEditedContentStore = require("../DictionaryEditor/useEditedContentStore.cjs");
|
|
9
|
-
const components_DictionaryEditor_useEditionPanelStore = require("../DictionaryEditor/useEditionPanelStore.cjs");
|
|
10
|
-
require("@intlayer/core");
|
|
11
|
-
require("lucide-react");
|
|
12
|
-
require("clsx");
|
|
13
|
-
require("tailwind-merge");
|
|
14
|
-
require("../Button/Button.cjs");
|
|
15
|
-
require("../EditableField/EditableFieldInput.cjs");
|
|
16
|
-
require("../EditableField/EditableFieldTextArea.cjs");
|
|
17
|
-
require("react-intlayer");
|
|
18
|
-
require("../../hooks/useScrollBlockage/useScrollBlockageStore.cjs");
|
|
19
|
-
require("../../hooks/useAsync/useAsyncStateStore.cjs");
|
|
20
|
-
require("../../index-DFc7og1d.cjs");
|
|
21
|
-
require("@intlayer/config/client");
|
|
22
|
-
require("../Toaster/Toast.cjs");
|
|
23
|
-
require("@intlayer/dictionaries-entry");
|
|
24
|
-
require("deepmerge");
|
|
25
|
-
require("../Form/FormBase.cjs");
|
|
26
|
-
require("../Form/FormField.cjs");
|
|
27
|
-
require("../../Form-CSMiPnjC.cjs");
|
|
28
|
-
require("../DictionaryEditor/validDictionaryChangeButtons.content.cjs");
|
|
29
|
-
require("zod");
|
|
30
8
|
const components_LocaleSwitcherContentDropDown_LocaleSwitcherContent = require("../LocaleSwitcherContentDropDown/LocaleSwitcherContent.cjs");
|
|
31
9
|
require("../LocaleSwitcherContentDropDown/LocaleSwitcherContentContext.cjs");
|
|
32
10
|
const components_DictionaryFieldEditor_EditorView_EditorView = require("./EditorView/EditorView.cjs");
|
|
@@ -34,27 +12,17 @@ const components_DictionaryFieldEditor_KeyPathBreadcrumb = require("./KeyPathBre
|
|
|
34
12
|
const components_DictionaryFieldEditor_NavigationView_NavigationViewNode = require("./NavigationView/NavigationViewNode.cjs");
|
|
35
13
|
const NodeEditor = ({ dictionary, locales }) => {
|
|
36
14
|
const { content: dictionaryContent, key } = dictionary;
|
|
37
|
-
const {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
dictionaryRecord: s.dictionariesRecord,
|
|
41
|
-
setDictionariesRecord: s.setDictionariesRecord
|
|
42
|
-
}))
|
|
43
|
-
);
|
|
44
|
-
const { focusedContent, setFocusedContentKeyPath } = components_DictionaryEditor_useEditionPanelStore.useEditionPanelStore(
|
|
45
|
-
shallow.useShallow((s) => ({
|
|
46
|
-
focusedContent: s.focusedContent,
|
|
47
|
-
setFocusedContentKeyPath: s.setFocusedContentKeyPath
|
|
48
|
-
}))
|
|
49
|
-
);
|
|
15
|
+
const { dictionariesRecord, setDictionariesRecord } = editorReact.useDictionariesRecord();
|
|
16
|
+
const { editedContent } = editorReact.useEditedContent();
|
|
17
|
+
const { focusedContent, setFocusedContentKeyPath } = editorReact.useFocusDictionary();
|
|
50
18
|
const focusedKeyPath = focusedContent?.keyPath;
|
|
51
19
|
const section = editedContent[key]?.content ?? dictionaryContent;
|
|
52
20
|
require$$0.useEffect(() => {
|
|
53
|
-
if (
|
|
21
|
+
if (dictionariesRecord[key]) return;
|
|
54
22
|
setDictionariesRecord({
|
|
55
23
|
[key]: dictionary
|
|
56
24
|
});
|
|
57
|
-
}, [dictionary, key, setDictionariesRecord,
|
|
25
|
+
}, [dictionary, key, setDictionariesRecord, dictionariesRecord]);
|
|
58
26
|
return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment, { children: [
|
|
59
27
|
/* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between gap-2", children: [
|
|
60
28
|
/* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeEditor.cjs","sources":["../../../src/components/DictionaryFieldEditor/NodeEditor.tsx"],"sourcesContent":["'use client';\n\nimport { type Locales } from '@intlayer/config';\nimport { Dictionary } from '@intlayer/core';\nimport {
|
|
1
|
+
{"version":3,"file":"NodeEditor.cjs","sources":["../../../src/components/DictionaryFieldEditor/NodeEditor.tsx"],"sourcesContent":["'use client';\n\nimport { type Locales } from '@intlayer/config';\nimport { Dictionary } from '@intlayer/core';\nimport {\n useDictionariesRecord,\n useEditedContent,\n useFocusDictionary,\n} from '@intlayer/editor-react';\nimport { useEffect, type FC } from 'react';\nimport { Container } from '../Container';\nimport { LocaleSwitcherContent } from '../LocaleSwitcherContentDropDown';\nimport { EditorView } from './EditorView/EditorView';\nimport { KeyPathBreadcrumb } from './KeyPathBreadcrumb';\nimport { NavigationViewNode } from './NavigationView/NavigationViewNode';\n\ntype NodeEditorProps = {\n dictionary: Dictionary;\n locales: Locales[];\n};\n\nexport const NodeEditor: FC<NodeEditorProps> = ({ dictionary, locales }) => {\n const { content: dictionaryContent, key } = dictionary;\n const { dictionariesRecord, setDictionariesRecord } = useDictionariesRecord();\n const { editedContent } = useEditedContent();\n const { focusedContent, setFocusedContentKeyPath } = useFocusDictionary();\n\n const focusedKeyPath = focusedContent?.keyPath;\n\n const section = editedContent[key]?.content ?? dictionaryContent;\n\n useEffect(() => {\n if (dictionariesRecord[key]) return;\n\n setDictionariesRecord({\n [key]: dictionary,\n });\n }, [dictionary, key, setDictionariesRecord, dictionariesRecord]);\n\n return (\n <>\n <div className=\"flex items-center justify-between gap-2\">\n <KeyPathBreadcrumb\n dictionaryKey={key}\n keyPath={focusedKeyPath ?? []}\n onClickKeyPath={setFocusedContentKeyPath}\n />\n <div className=\"flex items-center gap-2\">\n <LocaleSwitcherContent />\n </div>\n </div>\n\n <div className=\"flex gap-2 max-md:flex-col\">\n <Container\n border\n background={false}\n className=\"top-6 flex h-full flex-col items-start gap-0.5 overflow-auto p-2 md:sticky md:max-w-[50%]\"\n roundedSize=\"xl\"\n transparency=\"sm\"\n >\n <NavigationViewNode\n keyPath={[]}\n section={section}\n dictionaryKey={key}\n />\n </Container>\n <div className=\"top-6 flex h-full flex-1 flex-col gap-6 md:sticky\">\n {(focusedKeyPath?.length ?? 0) > 0 && (\n <Container\n border\n background={false}\n className=\"h-full flex-1 overflow-hidden\"\n roundedSize=\"xl\"\n >\n <EditorView\n dictionary={dictionary}\n dictionaryKey={key}\n locales={locales}\n />\n </Container>\n )}\n </div>\n </div>\n </>\n );\n};\n"],"names":["useDictionariesRecord","useEditedContent","useFocusDictionary","useEffect","jsxs","Fragment","jsx","KeyPathBreadcrumb","LocaleSwitcherContent","Container","NavigationViewNode","EditorView"],"mappings":";;;;;;;;;;;;AAqBO,MAAM,aAAkC,CAAC,EAAE,YAAY,cAAc;AAC1E,QAAM,EAAE,SAAS,mBAAmB,IAAQ,IAAA;AAC5C,QAAM,EAAE,oBAAoB,sBAAsB,IAAIA,kCAAsB;AACtE,QAAA,EAAE,cAAc,IAAIC,6BAAiB;AAC3C,QAAM,EAAE,gBAAgB,yBAAyB,IAAIC,+BAAmB;AAExE,QAAM,iBAAiB,gBAAgB;AAEvC,QAAM,UAAU,cAAc,GAAG,GAAG,WAAW;AAE/CC,aAAAA,UAAU,MAAM;AACV,QAAA,mBAAmB,GAAG,EAAG;AAEP,0BAAA;AAAA,MACpB,CAAC,GAAG,GAAG;AAAA,IAAA,CACR;AAAA,KACA,CAAC,YAAY,KAAK,uBAAuB,kBAAkB,CAAC;AAE/D,SAEIC,2BAAA,kBAAA,KAAAC,uCAAA,EAAA,UAAA;AAAA,IAACD,2BAAAA,kBAAAA,KAAA,OAAA,EAAI,WAAU,2CACb,UAAA;AAAA,MAAAE,2BAAA,kBAAA;AAAA,QAACC,mDAAA;AAAA,QAAA;AAAA,UACC,eAAe;AAAA,UACf,SAAS,kBAAkB,CAAC;AAAA,UAC5B,gBAAgB;AAAA,QAAA;AAAA,MAClB;AAAA,uDACC,OAAI,EAAA,WAAU,2BACb,UAAAD,2BAAA,kBAAA,IAACE,wFAAsB,EACzB,CAAA;AAAA,IAAA,GACF;AAAA,IAEAJ,2BAAAA,kBAAAA,KAAC,OAAI,EAAA,WAAU,8BACb,UAAA;AAAA,MAAAE,2BAAA,kBAAA;AAAA,QAACG,2BAAA;AAAA,QAAA;AAAA,UACC,QAAM;AAAA,UACN,YAAY;AAAA,UACZ,WAAU;AAAA,UACV,aAAY;AAAA,UACZ,cAAa;AAAA,UAEb,UAAAH,2BAAA,kBAAA;AAAA,YAACI,mEAAA;AAAA,YAAA;AAAA,cACC,SAAS,CAAC;AAAA,cACV;AAAA,cACA,eAAe;AAAA,YAAA;AAAA,UAAA;AAAA,QACjB;AAAA,MACF;AAAA,uDACC,OAAI,EAAA,WAAU,qDACX,WAAgB,gBAAA,UAAU,KAAK,KAC/BJ,2BAAA,kBAAA;AAAA,QAACG,2BAAA;AAAA,QAAA;AAAA,UACC,QAAM;AAAA,UACN,YAAY;AAAA,UACZ,WAAU;AAAA,UACV,aAAY;AAAA,UAEZ,UAAAH,2BAAA,kBAAA;AAAA,YAACK,uDAAA;AAAA,YAAA;AAAA,cACC;AAAA,cACA,eAAe;AAAA,cACf;AAAA,YAAA;AAAA,UAAA;AAAA,QACF;AAAA,MAAA,EAGN,CAAA;AAAA,IAAA,EACF,CAAA;AAAA,EAAA,GACF;AAEJ;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeEditor.d.ts","sourceRoot":"","sources":["../../../src/components/DictionaryFieldEditor/NodeEditor.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"NodeEditor.d.ts","sourceRoot":"","sources":["../../../src/components/DictionaryFieldEditor/NodeEditor.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAM5C,OAAO,EAAa,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAO3C,KAAK,eAAe,GAAG;IACrB,UAAU,EAAE,UAAU,CAAC;IACvB,OAAO,EAAE,OAAO,EAAE,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CAgE1C,CAAC"}
|
|
@@ -1,30 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { j as jsxRuntimeExports } from "../../jsx-runtime-DQkoUcjV.js";
|
|
3
|
+
import { useDictionariesRecord, useEditedContent, useFocusDictionary } from "@intlayer/editor-react";
|
|
3
4
|
import { useEffect } from "react";
|
|
4
|
-
import { u as useShallow } from "../../shallow-m9BpCkKh.js";
|
|
5
5
|
import { Container } from "../Container/index.mjs";
|
|
6
|
-
import { useEditedContentStore } from "../DictionaryEditor/useEditedContentStore.mjs";
|
|
7
|
-
import { useEditionPanelStore } from "../DictionaryEditor/useEditionPanelStore.mjs";
|
|
8
|
-
import "@intlayer/core";
|
|
9
|
-
import "lucide-react";
|
|
10
|
-
import "clsx";
|
|
11
|
-
import "tailwind-merge";
|
|
12
|
-
import "../Button/Button.mjs";
|
|
13
|
-
import "../EditableField/EditableFieldInput.mjs";
|
|
14
|
-
import "../EditableField/EditableFieldTextArea.mjs";
|
|
15
|
-
import "react-intlayer";
|
|
16
|
-
import "../../hooks/useScrollBlockage/useScrollBlockageStore.mjs";
|
|
17
|
-
import "../../hooks/useAsync/useAsyncStateStore.mjs";
|
|
18
|
-
import "../../index-DcWYZrJW.js";
|
|
19
|
-
import "@intlayer/config/client";
|
|
20
|
-
import "../Toaster/Toast.mjs";
|
|
21
|
-
import "@intlayer/dictionaries-entry";
|
|
22
|
-
import "deepmerge";
|
|
23
|
-
import "../Form/FormBase.mjs";
|
|
24
|
-
import "../Form/FormField.mjs";
|
|
25
|
-
import "../../Form-DlqjTz3u.js";
|
|
26
|
-
import "../DictionaryEditor/validDictionaryChangeButtons.content.mjs";
|
|
27
|
-
import "zod";
|
|
28
6
|
import { LocaleSwitcherContent } from "../LocaleSwitcherContentDropDown/LocaleSwitcherContent.mjs";
|
|
29
7
|
import "../LocaleSwitcherContentDropDown/LocaleSwitcherContentContext.mjs";
|
|
30
8
|
import { EditorView } from "./EditorView/EditorView.mjs";
|
|
@@ -32,27 +10,17 @@ import { KeyPathBreadcrumb } from "./KeyPathBreadcrumb.mjs";
|
|
|
32
10
|
import { NavigationViewNode } from "./NavigationView/NavigationViewNode.mjs";
|
|
33
11
|
const NodeEditor = ({ dictionary, locales }) => {
|
|
34
12
|
const { content: dictionaryContent, key } = dictionary;
|
|
35
|
-
const {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
dictionaryRecord: s.dictionariesRecord,
|
|
39
|
-
setDictionariesRecord: s.setDictionariesRecord
|
|
40
|
-
}))
|
|
41
|
-
);
|
|
42
|
-
const { focusedContent, setFocusedContentKeyPath } = useEditionPanelStore(
|
|
43
|
-
useShallow((s) => ({
|
|
44
|
-
focusedContent: s.focusedContent,
|
|
45
|
-
setFocusedContentKeyPath: s.setFocusedContentKeyPath
|
|
46
|
-
}))
|
|
47
|
-
);
|
|
13
|
+
const { dictionariesRecord, setDictionariesRecord } = useDictionariesRecord();
|
|
14
|
+
const { editedContent } = useEditedContent();
|
|
15
|
+
const { focusedContent, setFocusedContentKeyPath } = useFocusDictionary();
|
|
48
16
|
const focusedKeyPath = focusedContent?.keyPath;
|
|
49
17
|
const section = editedContent[key]?.content ?? dictionaryContent;
|
|
50
18
|
useEffect(() => {
|
|
51
|
-
if (
|
|
19
|
+
if (dictionariesRecord[key]) return;
|
|
52
20
|
setDictionariesRecord({
|
|
53
21
|
[key]: dictionary
|
|
54
22
|
});
|
|
55
|
-
}, [dictionary, key, setDictionariesRecord,
|
|
23
|
+
}, [dictionary, key, setDictionariesRecord, dictionariesRecord]);
|
|
56
24
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
57
25
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between gap-2", children: [
|
|
58
26
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|