@intlayer/design-system 5.3.3 → 5.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.vite/manifest.json +67 -49
- package/dist/{Form-MjLzPGze.js → Form-CriPBaZk.js} +11 -1
- package/dist/Form-CriPBaZk.js.map +1 -0
- package/dist/{Form-BpxW17v4.cjs → Form-DJrUK3mm.cjs} +11 -1
- package/dist/Form-DJrUK3mm.cjs.map +1 -0
- package/dist/components/Auth/ChangePasswordForm/ChangePasswordForm.cjs +1 -1
- package/dist/components/Auth/ChangePasswordForm/ChangePasswordForm.mjs +1 -1
- package/dist/components/Auth/DefineNewPasswordForm/DefineNewPasswordForm.cjs +1 -1
- package/dist/components/Auth/DefineNewPasswordForm/DefineNewPasswordForm.mjs +1 -1
- package/dist/components/Auth/ResetPasswordForm/ResetPasswordForm.cjs +1 -1
- package/dist/components/Auth/ResetPasswordForm/ResetPasswordForm.mjs +1 -1
- package/dist/components/Auth/SignInForm/SignInForm.cjs +1 -1
- package/dist/components/Auth/SignInForm/SignInForm.mjs +1 -1
- package/dist/components/Auth/SignUpForm/SignUpForm.cjs +1 -1
- package/dist/components/Auth/SignUpForm/SignUpForm.mjs +1 -1
- package/dist/components/Auth/VerifyEmailForm/VerifyEmailForm.cjs +1 -1
- package/dist/components/Auth/VerifyEmailForm/VerifyEmailForm.mjs +1 -1
- package/dist/components/ContentEditor/ContentEditor.cjs.map +1 -1
- package/dist/components/ContentEditor/ContentEditor.d.ts +3 -2
- package/dist/components/ContentEditor/ContentEditor.d.ts.map +1 -1
- package/dist/components/ContentEditor/ContentEditor.mjs.map +1 -1
- package/dist/components/ContentEditor/ContentEditorTextArea.cjs +1 -1
- package/dist/components/ContentEditor/ContentEditorTextArea.mjs +1 -1
- package/dist/components/DictionaryEditor/DictionaryEditor.cjs +2 -1
- 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 +2 -1
- package/dist/components/DictionaryEditor/DictionaryEditor.mjs.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/ArrayWrapper.cjs +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/ArrayWrapper.mjs +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/ConditionWrapper.cjs +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/ConditionWrapper.mjs +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/FileWrapper.cjs +58 -0
- package/dist/components/DictionaryEditor/NodeWrapper/FileWrapper.cjs.map +1 -0
- package/dist/components/DictionaryEditor/NodeWrapper/FileWrapper.d.ts +9 -0
- package/dist/components/DictionaryEditor/NodeWrapper/FileWrapper.d.ts.map +1 -0
- package/dist/components/DictionaryEditor/NodeWrapper/FileWrapper.mjs +58 -0
- package/dist/components/DictionaryEditor/NodeWrapper/FileWrapper.mjs.map +1 -0
- package/dist/components/DictionaryEditor/NodeWrapper/InsertionWrapper.cjs +7 -0
- package/dist/components/DictionaryEditor/NodeWrapper/InsertionWrapper.cjs.map +1 -0
- package/dist/components/DictionaryEditor/NodeWrapper/InsertionWrapper.d.ts +9 -0
- package/dist/components/DictionaryEditor/NodeWrapper/InsertionWrapper.d.ts.map +1 -0
- package/dist/components/DictionaryEditor/NodeWrapper/InsertionWrapper.mjs +7 -0
- package/dist/components/DictionaryEditor/NodeWrapper/InsertionWrapper.mjs.map +1 -0
- package/dist/components/DictionaryEditor/NodeWrapper/MarkdownWrapper.cjs +4 -15
- package/dist/components/DictionaryEditor/NodeWrapper/MarkdownWrapper.cjs.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/MarkdownWrapper.d.ts +2 -2
- package/dist/components/DictionaryEditor/NodeWrapper/MarkdownWrapper.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/MarkdownWrapper.mjs +4 -15
- package/dist/components/DictionaryEditor/NodeWrapper/MarkdownWrapper.mjs.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.cjs +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.mjs +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.cjs +8 -5
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.cjs.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.d.ts +2 -2
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.mjs +8 -5
- 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 +2 -2
- package/dist/components/DictionaryEditor/NodeWrapper/index.d.ts +4 -2
- package/dist/components/DictionaryEditor/NodeWrapper/index.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/index.mjs +2 -2
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.cjs +102 -22
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.d.ts +3 -1
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs +102 -22
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.cjs +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.cjs +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.cjs +48 -114
- 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 +49 -115
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.cjs +0 -51
- package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.d.ts +0 -105
- package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.mjs +0 -51
- package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.cjs +6 -5
- 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 +7 -6
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs +117 -78
- 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 +120 -81
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.cjs +108 -0
- package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.d.ts +231 -0
- package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.mjs +108 -0
- package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/getIsEditableSection.cjs +10 -2
- package/dist/components/DictionaryFieldEditor/getIsEditableSection.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/getIsEditableSection.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/getIsEditableSection.mjs +11 -3
- package/dist/components/DictionaryFieldEditor/getIsEditableSection.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/nodeTypeSelector.content.cjs +30 -0
- package/dist/components/DictionaryFieldEditor/nodeTypeSelector.content.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/nodeTypeSelector.content.d.ts +66 -0
- package/dist/components/DictionaryFieldEditor/nodeTypeSelector.content.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/nodeTypeSelector.content.mjs +30 -0
- package/dist/components/DictionaryFieldEditor/nodeTypeSelector.content.mjs.map +1 -1
- package/dist/components/Form/Form.cjs +1 -1
- package/dist/components/Form/Form.mjs +1 -1
- package/dist/components/Form/elements/AutoSizeTextAreaElement.cjs +1 -1
- package/dist/components/Form/elements/AutoSizeTextAreaElement.mjs +1 -1
- package/dist/components/Form/elements/CheckboxElement.cjs +1 -1
- package/dist/components/Form/elements/CheckboxElement.mjs +1 -1
- package/dist/components/Form/elements/EditableFieldInputElement.cjs +1 -1
- package/dist/components/Form/elements/EditableFieldInputElement.d.ts +2 -2
- package/dist/components/Form/elements/EditableFieldInputElement.d.ts.map +1 -1
- package/dist/components/Form/elements/EditableFieldInputElement.mjs +1 -1
- package/dist/components/Form/elements/EditableFieldTextAreaElement.cjs +1 -1
- package/dist/components/Form/elements/EditableFieldTextAreaElement.d.ts +2 -2
- package/dist/components/Form/elements/EditableFieldTextAreaElement.d.ts.map +1 -1
- package/dist/components/Form/elements/EditableFieldTextAreaElement.mjs +1 -1
- package/dist/components/Form/elements/FormElement.cjs +1 -1
- package/dist/components/Form/elements/FormElement.mjs +1 -1
- package/dist/components/Form/elements/InputElement.cjs +1 -1
- package/dist/components/Form/elements/InputElement.d.ts +2 -2
- package/dist/components/Form/elements/InputElement.d.ts.map +1 -1
- package/dist/components/Form/elements/InputElement.mjs +1 -1
- package/dist/components/Form/elements/InputPasswordElement.cjs +1 -1
- package/dist/components/Form/elements/InputPasswordElement.d.ts +2 -2
- package/dist/components/Form/elements/InputPasswordElement.d.ts.map +1 -1
- package/dist/components/Form/elements/InputPasswordElement.mjs +1 -1
- package/dist/components/Form/elements/MultiselectElement.cjs +1 -1
- package/dist/components/Form/elements/MultiselectElement.mjs +1 -1
- package/dist/components/Form/elements/SelectElement.cjs +1 -1
- package/dist/components/Form/elements/SelectElement.mjs +1 -1
- package/dist/components/Form/elements/SwitchSelectorElement.cjs +1 -1
- package/dist/components/Form/elements/SwitchSelectorElement.mjs +1 -1
- package/dist/components/Form/elements/TextAreaElement.cjs +1 -1
- package/dist/components/Form/elements/TextAreaElement.d.ts +3 -3
- package/dist/components/Form/elements/TextAreaElement.d.ts.map +1 -1
- package/dist/components/Form/elements/TextAreaElement.mjs +1 -1
- package/dist/components/Form/elements/index.cjs +1 -1
- package/dist/components/Form/elements/index.mjs +1 -1
- package/dist/components/Form/index.cjs +1 -1
- package/dist/components/Form/index.mjs +1 -1
- package/dist/components/Form/layout/FormItemLayout.cjs +1 -1
- package/dist/components/Form/layout/FormItemLayout.mjs +1 -1
- package/dist/components/Form/layout/FormLabelLayout.cjs +12 -4
- package/dist/components/Form/layout/FormLabelLayout.cjs.map +1 -1
- package/dist/components/Form/layout/FormLabelLayout.d.ts.map +1 -1
- package/dist/components/Form/layout/FormLabelLayout.mjs +12 -4
- package/dist/components/Form/layout/FormLabelLayout.mjs.map +1 -1
- package/dist/components/Form/layout/index.cjs +1 -1
- package/dist/components/Form/layout/index.mjs +1 -1
- package/dist/components/Input/Input.cjs.map +1 -1
- package/dist/components/Input/Input.d.ts +1 -7
- package/dist/components/Input/Input.d.ts.map +1 -1
- package/dist/components/Input/Input.mjs.map +1 -1
- package/dist/components/TextArea/TextArea.cjs.map +1 -1
- package/dist/components/TextArea/TextArea.d.ts +1 -7
- package/dist/components/TextArea/TextArea.d.ts.map +1 -1
- package/dist/components/TextArea/TextArea.mjs.map +1 -1
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.mjs +1 -1
- package/dist/hooks/intlayerAPIHooks.cjs.map +1 -1
- package/dist/hooks/intlayerAPIHooks.d.ts +54 -54
- package/dist/hooks/intlayerAPIHooks.d.ts.map +1 -1
- package/dist/hooks/intlayerAPIHooks.mjs.map +1 -1
- package/dist/hooks/useIntlayerAPI.d.ts +1 -1
- package/dist/hooks/useIntlayerAPI.d.ts.map +1 -1
- package/dist/{index-CVTE3oHq.js → index-CEoL1j7H.js} +48 -3
- package/dist/index-CEoL1j7H.js.map +1 -0
- package/dist/{index-BpCAhDMe.cjs → index-s_Ar0FDw.cjs} +48 -3
- package/dist/index-s_Ar0FDw.cjs.map +1 -0
- package/dist/utils/camelCase.cjs +2 -2
- package/dist/utils/camelCase.cjs.map +1 -1
- package/dist/utils/camelCase.d.ts +1 -1
- package/dist/utils/camelCase.d.ts.map +1 -1
- package/dist/utils/camelCase.mjs +2 -2
- package/dist/utils/camelCase.mjs.map +1 -1
- package/package.json +17 -19
- package/dist/Form-BpxW17v4.cjs.map +0 -1
- package/dist/Form-MjLzPGze.js.map +0 -1
- package/dist/index-BpCAhDMe.cjs.map +0 -1
- package/dist/index-CVTE3oHq.js.map +0 -1
|
@@ -21,16 +21,25 @@ const NavigationViewNode = ({
|
|
|
21
21
|
const section = core.getContentNodeByKeyPath(sectionProp, keyPath);
|
|
22
22
|
const { addEditedContent } = editorReact.useEditedContentActions();
|
|
23
23
|
const { setFocusedContentKeyPath, focusedContent } = editorReact.useFocusDictionary();
|
|
24
|
-
const {
|
|
25
|
-
addNewElement,
|
|
26
|
-
goToElement,
|
|
27
|
-
goToField,
|
|
28
|
-
goToEnumeration,
|
|
29
|
-
goToTranslation
|
|
30
|
-
} = reactIntlayer.useDictionary(components_DictionaryFieldEditor_NavigationView_navigationViewNode_content.navigationViewContent);
|
|
24
|
+
const { addNewElement, goToField } = reactIntlayer.useDictionary(components_DictionaryFieldEditor_NavigationView_navigationViewNode_content.navigationViewContent);
|
|
31
25
|
const nodeType = core.getNodeType(section);
|
|
32
26
|
const getIsSelected = (keyPath2) => (focusedContent?.keyPath?.length ?? 0) > 0 && core.isSameKeyPath(keyPath2, focusedContent?.keyPath ?? []);
|
|
27
|
+
const isEditableSubSection = components_DictionaryFieldEditor_getIsEditableSection.getIsEditableSection(section);
|
|
33
28
|
if (!section) return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
29
|
+
if (isEditableSubSection) {
|
|
30
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
31
|
+
components_Button_Button.Button,
|
|
32
|
+
{
|
|
33
|
+
label: goToField.label.value,
|
|
34
|
+
variant: "hoverable",
|
|
35
|
+
color: "text",
|
|
36
|
+
className: "w-full",
|
|
37
|
+
onClick: () => setFocusedContentKeyPath(keyPath),
|
|
38
|
+
IconRight: lucideReact.ChevronRight,
|
|
39
|
+
children: utils_camelCase.camelCaseToSentence(keyPath[keyPath.length - 1].key)
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
}
|
|
34
43
|
if (typeof section === "object") {
|
|
35
44
|
if (nodeType === core.NodeType.ReactNode) {
|
|
36
45
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: "React Node" });
|
|
@@ -41,44 +50,13 @@ const NavigationViewNode = ({
|
|
|
41
50
|
...keyPath,
|
|
42
51
|
{ type: core.NodeType.Translation, key: translationKey }
|
|
43
52
|
];
|
|
44
|
-
const subSection = core.getContentNodeByKeyPath(
|
|
45
|
-
sectionProp,
|
|
46
|
-
childKeyPath
|
|
47
|
-
);
|
|
48
|
-
const isEditableSubSection = components_DictionaryFieldEditor_getIsEditableSection.getIsEditableSection(subSection);
|
|
49
|
-
if (isEditableSubSection) {
|
|
50
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
51
|
-
components_Button_Button.Button,
|
|
52
|
-
{
|
|
53
|
-
label: `${goToTranslation.label.value} ${translationKey}`,
|
|
54
|
-
isActive: getIsSelected(childKeyPath),
|
|
55
|
-
variant: "hoverable",
|
|
56
|
-
color: "text",
|
|
57
|
-
className: "w-full",
|
|
58
|
-
onClick: () => setFocusedContentKeyPath(childKeyPath),
|
|
59
|
-
IconRight: lucideReact.ChevronRight,
|
|
60
|
-
children: translationKey
|
|
61
|
-
},
|
|
62
|
-
translationKey
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
53
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
66
|
-
|
|
54
|
+
NavigationViewNode,
|
|
67
55
|
{
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-2 flex w-full max-w-full", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 pl-10", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
73
|
-
NavigationViewNode,
|
|
74
|
-
{
|
|
75
|
-
keyPath: childKeyPath,
|
|
76
|
-
section: sectionProp,
|
|
77
|
-
dictionaryKey
|
|
78
|
-
}
|
|
79
|
-
) }) })
|
|
80
|
-
},
|
|
81
|
-
translationKey
|
|
56
|
+
keyPath: childKeyPath,
|
|
57
|
+
section: sectionProp,
|
|
58
|
+
dictionaryKey
|
|
59
|
+
}
|
|
82
60
|
);
|
|
83
61
|
}) });
|
|
84
62
|
}
|
|
@@ -90,88 +68,30 @@ const NavigationViewNode = ({
|
|
|
90
68
|
...keyPath,
|
|
91
69
|
{ type: nodeType, key }
|
|
92
70
|
];
|
|
93
|
-
const subSection = core.getContentNodeByKeyPath(
|
|
94
|
-
sectionProp,
|
|
95
|
-
childKeyPath
|
|
96
|
-
);
|
|
97
|
-
const isEditableSubSection = components_DictionaryFieldEditor_getIsEditableSection.getIsEditableSection(subSection);
|
|
98
|
-
if (isEditableSubSection) {
|
|
99
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
100
|
-
components_Button_Button.Button,
|
|
101
|
-
{
|
|
102
|
-
label: `${goToEnumeration.label.value} ${key}`,
|
|
103
|
-
isActive: getIsSelected(childKeyPath),
|
|
104
|
-
variant: "hoverable",
|
|
105
|
-
color: "text",
|
|
106
|
-
className: "w-full",
|
|
107
|
-
onClick: () => setFocusedContentKeyPath(childKeyPath),
|
|
108
|
-
IconRight: lucideReact.ChevronRight,
|
|
109
|
-
children: key
|
|
110
|
-
},
|
|
111
|
-
key
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
71
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
115
|
-
|
|
72
|
+
NavigationViewNode,
|
|
116
73
|
{
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-2 flex w-full max-w-full", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 pl-10", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
122
|
-
NavigationViewNode,
|
|
123
|
-
{
|
|
124
|
-
keyPath: childKeyPath,
|
|
125
|
-
section: sectionProp,
|
|
126
|
-
dictionaryKey
|
|
127
|
-
}
|
|
128
|
-
) }) })
|
|
129
|
-
},
|
|
130
|
-
key
|
|
74
|
+
keyPath: childKeyPath,
|
|
75
|
+
section: sectionProp,
|
|
76
|
+
dictionaryKey
|
|
77
|
+
}
|
|
131
78
|
);
|
|
132
79
|
}) });
|
|
133
80
|
}
|
|
134
81
|
if (nodeType === core.NodeType.Array) {
|
|
135
82
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col justify-between gap-2", children: [
|
|
136
|
-
section.map((
|
|
83
|
+
section.map((_, index) => {
|
|
137
84
|
const childKeyPath = [
|
|
138
85
|
...keyPath,
|
|
139
86
|
{ type: core.NodeType.Array, key: index }
|
|
140
87
|
];
|
|
141
|
-
const isEditableSubSection = components_DictionaryFieldEditor_getIsEditableSection.getIsEditableSection(subSection);
|
|
142
|
-
if (isEditableSubSection) {
|
|
143
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
144
|
-
components_Button_Button.Button,
|
|
145
|
-
{
|
|
146
|
-
label: `${goToElement.label.value} ${index}`,
|
|
147
|
-
isActive: getIsSelected(childKeyPath),
|
|
148
|
-
variant: "hoverable",
|
|
149
|
-
color: "text",
|
|
150
|
-
className: "w-full",
|
|
151
|
-
onClick: () => setFocusedContentKeyPath(childKeyPath),
|
|
152
|
-
IconRight: lucideReact.ChevronRight,
|
|
153
|
-
children: index
|
|
154
|
-
},
|
|
155
|
-
`${index}`
|
|
156
|
-
);
|
|
157
|
-
}
|
|
158
88
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
159
|
-
|
|
89
|
+
NavigationViewNode,
|
|
160
90
|
{
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-2 flex w-full max-w-full", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 pl-10", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
166
|
-
NavigationViewNode,
|
|
167
|
-
{
|
|
168
|
-
keyPath: childKeyPath,
|
|
169
|
-
section: sectionProp,
|
|
170
|
-
dictionaryKey
|
|
171
|
-
}
|
|
172
|
-
) }) })
|
|
173
|
-
},
|
|
174
|
-
`${index}`
|
|
91
|
+
keyPath: childKeyPath,
|
|
92
|
+
section: sectionProp,
|
|
93
|
+
dictionaryKey
|
|
94
|
+
}
|
|
175
95
|
);
|
|
176
96
|
}),
|
|
177
97
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -207,6 +127,20 @@ const NavigationViewNode = ({
|
|
|
207
127
|
)
|
|
208
128
|
] });
|
|
209
129
|
}
|
|
130
|
+
if (typeof section.nodeType === "string") {
|
|
131
|
+
const childKeyPath = [
|
|
132
|
+
...keyPath,
|
|
133
|
+
{ type: section.nodeType }
|
|
134
|
+
];
|
|
135
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
136
|
+
NavigationViewNode,
|
|
137
|
+
{
|
|
138
|
+
keyPath: childKeyPath,
|
|
139
|
+
section: sectionProp,
|
|
140
|
+
dictionaryKey
|
|
141
|
+
}
|
|
142
|
+
);
|
|
143
|
+
}
|
|
210
144
|
const sectionArray = Object.keys(section);
|
|
211
145
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex w-full max-w-full flex-col justify-between gap-2", children: sectionArray.map((key) => {
|
|
212
146
|
const childKeyPath = [
|
|
@@ -214,8 +148,8 @@ const NavigationViewNode = ({
|
|
|
214
148
|
{ type: core.NodeType.Object, key }
|
|
215
149
|
];
|
|
216
150
|
const subSection = core.getContentNodeByKeyPath(sectionProp, childKeyPath);
|
|
217
|
-
const
|
|
218
|
-
if (
|
|
151
|
+
const isEditableSubSection2 = components_DictionaryFieldEditor_getIsEditableSection.getIsEditableSection(subSection);
|
|
152
|
+
if (isEditableSubSection2) {
|
|
219
153
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
220
154
|
components_Button_Button.Button,
|
|
221
155
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationViewNode.cjs","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\n\nimport {\n NodeType,\n type KeyPath,\n type ContentNode,\n isSameKeyPath,\n getContentNodeByKeyPath,\n getNodeType,\n getEmptyNode,\n} from '@intlayer/core';\nimport {\n useEditedContentActions,\n useFocusDictionary,\n} from '@intlayer/editor-react';\nimport { ChevronRight, Plus } from 'lucide-react';\nimport type { FC } from 'react';\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: ContentNode;\n};\n\nexport const NavigationViewNode: FC<NodeWrapperProps> = ({\n section: sectionProp,\n keyPath,\n dictionaryKey,\n}) => {\n const { locales } = configuration?.internationalization;\n const section = getContentNodeByKeyPath(sectionProp, keyPath);\n const { addEditedContent } = useEditedContentActions();\n const { setFocusedContentKeyPath, focusedContent } = useFocusDictionary();\n const {\n addNewElement,\n goToElement,\n goToField,\n goToEnumeration,\n goToTranslation,\n } = useDictionary(navigationViewContent);\n const nodeType = getNodeType(section);\n const getIsSelected = (keyPath: KeyPath[]) =>\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(keyPath, focusedContent?.keyPath ?? []);\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 = getContentNodeByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToTranslation.label.value} ${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.value} ${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 || nodeType === NodeType.Condition) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {Object.keys(\n (section as any)[nodeType as unknown as keyof typeof section]\n ).map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: nodeType, key },\n ];\n const subSection = getContentNodeByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToEnumeration.label.value} ${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.value} ${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 unknown as ContentNode[]).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.value} ${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.value} ${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.value}\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 unknown as ContentNode[]).length,\n },\n ];\n const sectionArray = section as unknown as ContentNode[];\n const emptySectionEl =\n getEmptyNode(\n sectionArray[\n (sectionArray.length - 1) as keyof typeof sectionArray\n ] as ContentNode\n ) ?? '';\n addEditedContent(\n dictionaryKey,\n emptySectionEl,\n newKeyPath,\n false\n );\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\n const subSection = getContentNodeByKeyPath(sectionProp, childKeyPath);\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToField.label.value} ${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.value} ${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 </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":["configuration","getContentNodeByKeyPath","useEditedContentActions","useFocusDictionary","useDictionary","navigationViewContent","getNodeType","keyPath","isSameKeyPath","jsx","Fragment","NodeType","getIsEditableSection","Button","ChevronRight","Accordion","jsxs","sectionArray","getEmptyNode","Plus","camelCaseToSentence"],"mappings":";;;;;;;;;;;;;AAwBO,MAAM,YAAsB,CAAC,YAAY,MAAM,UAAU;AAQzD,MAAM,qBAA2C,CAAC;AAAA,EACvD,SAAS;AAAA,EACT;AAAA,EACA;AACF,MAAM;AACE,QAAA,EAAE,YAAYA,sBAAe;AAC7B,QAAA,UAAUC,KAAAA,wBAAwB,aAAa,OAAO;AACtD,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,EAAA,IACEC,cA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B,GAAG;AAAA,UAAA;AAAA,UARnB;AAAA,QASP;AAAA,MAAA;AAKF,aAAAL,2BAAA;AAAA,QAACM,+BAAA;AAAA,QAAA;AAAA,UAEC,OAAO,GAAG,UAAU,MAAM,KAAK,IAAI,GAAG;AAAA,UACtC,UAAU,cAAc,YAAY;AAAA,UACpC,SAAS,MAAM,yBAAyB,YAAY;AAAA,UACpD,QAAQK,oCAAoB,GAAG;AAAA,UAE/B,yCAAC,OAAI,EAAA,WAAU,+BACb,UAACX,2BAAA,IAAA,OAAA,EAAI,WAAU,gBACb,UAAAA,2BAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,SAAS;AAAA,cACT,SAAS;AAAA,cACT;AAAA,YAAA;AAAA,aAEJ,EACF,CAAA;AAAA,QAAA;AAAA,QAdK;AAAA,MAeP;AAAA,IAEH,CAAA,GACH;AAAA,EAAA;AAIJ,SACIO,2BAAA,KAAAN,qBAAA,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 configuration from '@intlayer/config/built';\n\nimport {\n NodeType,\n type KeyPath,\n type ContentNode,\n isSameKeyPath,\n getContentNodeByKeyPath,\n getNodeType,\n getEmptyNode,\n} from '@intlayer/core';\nimport {\n useEditedContentActions,\n useFocusDictionary,\n} from '@intlayer/editor-react';\nimport { ChevronRight, Plus } from 'lucide-react';\nimport type { FC } from 'react';\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: ContentNode;\n};\n\nexport const NavigationViewNode: FC<NodeWrapperProps> = ({\n section: sectionProp,\n keyPath,\n dictionaryKey,\n}) => {\n const { locales } = configuration?.internationalization;\n const section = getContentNodeByKeyPath(sectionProp, keyPath);\n const { addEditedContent } = useEditedContentActions();\n const { setFocusedContentKeyPath, focusedContent } = useFocusDictionary();\n const { addNewElement, goToField } = useDictionary(navigationViewContent);\n const nodeType = getNodeType(section);\n const getIsSelected = (keyPath: KeyPath[]) =>\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(keyPath, focusedContent?.keyPath ?? []);\n const isEditableSubSection = getIsEditableSection(section);\n\n if (!section) return <></>;\n\n if (isEditableSubSection) {\n return (\n <Button\n label={goToField.label.value}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(keyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(keyPath[keyPath.length - 1].key as string)}\n </Button>\n );\n }\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\n return (\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Enumeration || nodeType === NodeType.Condition) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {Object.keys(\n (section as any)[nodeType as unknown as keyof typeof section]\n ).map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: nodeType, key },\n ];\n\n return (\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\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 unknown as ContentNode[]).map((_, index) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Array, key: index },\n ];\n\n return (\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n );\n })}\n\n <Button\n label={addNewElement.label.value}\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 unknown as ContentNode[]).length,\n },\n ];\n const sectionArray = section as unknown as ContentNode[];\n const emptySectionEl =\n getEmptyNode(\n sectionArray[\n (sectionArray.length - 1) as keyof typeof sectionArray\n ] as ContentNode\n ) ?? '';\n addEditedContent(\n dictionaryKey,\n emptySectionEl,\n newKeyPath,\n false\n );\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n }\n\n if (typeof section.nodeType === 'string') {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: section.nodeType } as KeyPath,\n ];\n\n return (\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\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\n const subSection = getContentNodeByKeyPath(sectionProp, childKeyPath);\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToField.label.value} ${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.value} ${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 </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":["configuration","getContentNodeByKeyPath","useEditedContentActions","useFocusDictionary","useDictionary","navigationViewContent","getNodeType","keyPath","isSameKeyPath","getIsEditableSection","jsx","Fragment","Button","ChevronRight","NodeType","jsxs","sectionArray","getEmptyNode","Plus","isEditableSubSection","Accordion","camelCaseToSentence"],"mappings":";;;;;;;;;;;;;AAwBO,MAAM,YAAsB,CAAC,YAAY,MAAM,UAAU;AAQzD,MAAM,qBAA2C,CAAC;AAAA,EACvD,SAAS;AAAA,EACT;AAAA,EACA;AACF,MAAM;AACE,QAAA,EAAE,YAAYA,sBAAe;AAC7B,QAAA,UAAUC,KAAAA,wBAAwB,aAAa,OAAO;AACtD,QAAA,EAAE,iBAAiB,IAAIC,oCAAwB;AACrD,QAAM,EAAE,0BAA0B,eAAe,IAAIC,+BAAmB;AACxE,QAAM,EAAE,eAAe,cAAcC,cAAAA,cAAcC,2EAAAA,qBAAqB;AAClE,QAAA,WAAWC,iBAAY,OAAO;AACpC,QAAM,gBAAgB,CAACC,cACpB,gBAAgB,SAAS,UAAU,KAAK,KACzCC,KAAAA,cAAcD,UAAS,gBAAgB,WAAW,CAAA,CAAE;AAChD,QAAA,uBAAuBE,2EAAqB,OAAO;AAErD,MAAA,CAAC,QAAS,QAASC,+BAAAC,WAAAA,UAAA,CAA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AAAA,EAAA,GACzB;AAEJ;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationViewNode.d.ts","sourceRoot":"","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,OAAO,EACZ,KAAK,WAAW,EAKjB,MAAM,gBAAgB,CAAC;AAMxB,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAQhC,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,WAAW,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,EAAE,CAAC,gBAAgB,
|
|
1
|
+
{"version":3,"file":"NavigationViewNode.d.ts","sourceRoot":"","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,OAAO,EACZ,KAAK,WAAW,EAKjB,MAAM,gBAAgB,CAAC;AAMxB,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAQhC,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,WAAW,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,EAAE,CAAC,gBAAgB,CAsNnD,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import defaultConfiguration from "@intlayer/config/built";
|
|
3
|
-
import { getContentNodeByKeyPath, getNodeType, NodeType,
|
|
3
|
+
import { getContentNodeByKeyPath, getNodeType, NodeType, getEmptyNode, isSameKeyPath } from "@intlayer/core";
|
|
4
4
|
import { useEditedContentActions, useFocusDictionary } from "@intlayer/editor-react";
|
|
5
5
|
import { ChevronRight, Plus } from "lucide-react";
|
|
6
6
|
import { useDictionary } from "react-intlayer";
|
|
@@ -19,16 +19,25 @@ const NavigationViewNode = ({
|
|
|
19
19
|
const section = getContentNodeByKeyPath(sectionProp, keyPath);
|
|
20
20
|
const { addEditedContent } = useEditedContentActions();
|
|
21
21
|
const { setFocusedContentKeyPath, focusedContent } = useFocusDictionary();
|
|
22
|
-
const {
|
|
23
|
-
addNewElement,
|
|
24
|
-
goToElement,
|
|
25
|
-
goToField,
|
|
26
|
-
goToEnumeration,
|
|
27
|
-
goToTranslation
|
|
28
|
-
} = useDictionary(navigationViewContent);
|
|
22
|
+
const { addNewElement, goToField } = useDictionary(navigationViewContent);
|
|
29
23
|
const nodeType = getNodeType(section);
|
|
30
24
|
const getIsSelected = (keyPath2) => (focusedContent?.keyPath?.length ?? 0) > 0 && isSameKeyPath(keyPath2, focusedContent?.keyPath ?? []);
|
|
25
|
+
const isEditableSubSection = getIsEditableSection(section);
|
|
31
26
|
if (!section) return /* @__PURE__ */ jsx(Fragment, {});
|
|
27
|
+
if (isEditableSubSection) {
|
|
28
|
+
return /* @__PURE__ */ jsx(
|
|
29
|
+
Button,
|
|
30
|
+
{
|
|
31
|
+
label: goToField.label.value,
|
|
32
|
+
variant: "hoverable",
|
|
33
|
+
color: "text",
|
|
34
|
+
className: "w-full",
|
|
35
|
+
onClick: () => setFocusedContentKeyPath(keyPath),
|
|
36
|
+
IconRight: ChevronRight,
|
|
37
|
+
children: camelCaseToSentence(keyPath[keyPath.length - 1].key)
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
}
|
|
32
41
|
if (typeof section === "object") {
|
|
33
42
|
if (nodeType === NodeType.ReactNode) {
|
|
34
43
|
return /* @__PURE__ */ jsx(Fragment, { children: "React Node" });
|
|
@@ -39,44 +48,13 @@ const NavigationViewNode = ({
|
|
|
39
48
|
...keyPath,
|
|
40
49
|
{ type: NodeType.Translation, key: translationKey }
|
|
41
50
|
];
|
|
42
|
-
const subSection = getContentNodeByKeyPath(
|
|
43
|
-
sectionProp,
|
|
44
|
-
childKeyPath
|
|
45
|
-
);
|
|
46
|
-
const isEditableSubSection = getIsEditableSection(subSection);
|
|
47
|
-
if (isEditableSubSection) {
|
|
48
|
-
return /* @__PURE__ */ jsx(
|
|
49
|
-
Button,
|
|
50
|
-
{
|
|
51
|
-
label: `${goToTranslation.label.value} ${translationKey}`,
|
|
52
|
-
isActive: getIsSelected(childKeyPath),
|
|
53
|
-
variant: "hoverable",
|
|
54
|
-
color: "text",
|
|
55
|
-
className: "w-full",
|
|
56
|
-
onClick: () => setFocusedContentKeyPath(childKeyPath),
|
|
57
|
-
IconRight: ChevronRight,
|
|
58
|
-
children: translationKey
|
|
59
|
-
},
|
|
60
|
-
translationKey
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
51
|
return /* @__PURE__ */ jsx(
|
|
64
|
-
|
|
52
|
+
NavigationViewNode,
|
|
65
53
|
{
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
children: /* @__PURE__ */ jsx("div", { className: "mt-2 flex w-full max-w-full", children: /* @__PURE__ */ jsx("div", { className: "flex-1 pl-10", children: /* @__PURE__ */ jsx(
|
|
71
|
-
NavigationViewNode,
|
|
72
|
-
{
|
|
73
|
-
keyPath: childKeyPath,
|
|
74
|
-
section: sectionProp,
|
|
75
|
-
dictionaryKey
|
|
76
|
-
}
|
|
77
|
-
) }) })
|
|
78
|
-
},
|
|
79
|
-
translationKey
|
|
54
|
+
keyPath: childKeyPath,
|
|
55
|
+
section: sectionProp,
|
|
56
|
+
dictionaryKey
|
|
57
|
+
}
|
|
80
58
|
);
|
|
81
59
|
}) });
|
|
82
60
|
}
|
|
@@ -88,88 +66,30 @@ const NavigationViewNode = ({
|
|
|
88
66
|
...keyPath,
|
|
89
67
|
{ type: nodeType, key }
|
|
90
68
|
];
|
|
91
|
-
const subSection = getContentNodeByKeyPath(
|
|
92
|
-
sectionProp,
|
|
93
|
-
childKeyPath
|
|
94
|
-
);
|
|
95
|
-
const isEditableSubSection = getIsEditableSection(subSection);
|
|
96
|
-
if (isEditableSubSection) {
|
|
97
|
-
return /* @__PURE__ */ jsx(
|
|
98
|
-
Button,
|
|
99
|
-
{
|
|
100
|
-
label: `${goToEnumeration.label.value} ${key}`,
|
|
101
|
-
isActive: getIsSelected(childKeyPath),
|
|
102
|
-
variant: "hoverable",
|
|
103
|
-
color: "text",
|
|
104
|
-
className: "w-full",
|
|
105
|
-
onClick: () => setFocusedContentKeyPath(childKeyPath),
|
|
106
|
-
IconRight: ChevronRight,
|
|
107
|
-
children: key
|
|
108
|
-
},
|
|
109
|
-
key
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
69
|
return /* @__PURE__ */ jsx(
|
|
113
|
-
|
|
70
|
+
NavigationViewNode,
|
|
114
71
|
{
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
children: /* @__PURE__ */ jsx("div", { className: "mt-2 flex w-full max-w-full", children: /* @__PURE__ */ jsx("div", { className: "flex-1 pl-10", children: /* @__PURE__ */ jsx(
|
|
120
|
-
NavigationViewNode,
|
|
121
|
-
{
|
|
122
|
-
keyPath: childKeyPath,
|
|
123
|
-
section: sectionProp,
|
|
124
|
-
dictionaryKey
|
|
125
|
-
}
|
|
126
|
-
) }) })
|
|
127
|
-
},
|
|
128
|
-
key
|
|
72
|
+
keyPath: childKeyPath,
|
|
73
|
+
section: sectionProp,
|
|
74
|
+
dictionaryKey
|
|
75
|
+
}
|
|
129
76
|
);
|
|
130
77
|
}) });
|
|
131
78
|
}
|
|
132
79
|
if (nodeType === NodeType.Array) {
|
|
133
80
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col justify-between gap-2", children: [
|
|
134
|
-
section.map((
|
|
81
|
+
section.map((_, index) => {
|
|
135
82
|
const childKeyPath = [
|
|
136
83
|
...keyPath,
|
|
137
84
|
{ type: NodeType.Array, key: index }
|
|
138
85
|
];
|
|
139
|
-
const isEditableSubSection = getIsEditableSection(subSection);
|
|
140
|
-
if (isEditableSubSection) {
|
|
141
|
-
return /* @__PURE__ */ jsx(
|
|
142
|
-
Button,
|
|
143
|
-
{
|
|
144
|
-
label: `${goToElement.label.value} ${index}`,
|
|
145
|
-
isActive: getIsSelected(childKeyPath),
|
|
146
|
-
variant: "hoverable",
|
|
147
|
-
color: "text",
|
|
148
|
-
className: "w-full",
|
|
149
|
-
onClick: () => setFocusedContentKeyPath(childKeyPath),
|
|
150
|
-
IconRight: ChevronRight,
|
|
151
|
-
children: index
|
|
152
|
-
},
|
|
153
|
-
`${index}`
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
86
|
return /* @__PURE__ */ jsx(
|
|
157
|
-
|
|
87
|
+
NavigationViewNode,
|
|
158
88
|
{
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
children: /* @__PURE__ */ jsx("div", { className: "mt-2 flex w-full max-w-full", children: /* @__PURE__ */ jsx("div", { className: "flex-1 pl-10", children: /* @__PURE__ */ jsx(
|
|
164
|
-
NavigationViewNode,
|
|
165
|
-
{
|
|
166
|
-
keyPath: childKeyPath,
|
|
167
|
-
section: sectionProp,
|
|
168
|
-
dictionaryKey
|
|
169
|
-
}
|
|
170
|
-
) }) })
|
|
171
|
-
},
|
|
172
|
-
`${index}`
|
|
89
|
+
keyPath: childKeyPath,
|
|
90
|
+
section: sectionProp,
|
|
91
|
+
dictionaryKey
|
|
92
|
+
}
|
|
173
93
|
);
|
|
174
94
|
}),
|
|
175
95
|
/* @__PURE__ */ jsx(
|
|
@@ -205,6 +125,20 @@ const NavigationViewNode = ({
|
|
|
205
125
|
)
|
|
206
126
|
] });
|
|
207
127
|
}
|
|
128
|
+
if (typeof section.nodeType === "string") {
|
|
129
|
+
const childKeyPath = [
|
|
130
|
+
...keyPath,
|
|
131
|
+
{ type: section.nodeType }
|
|
132
|
+
];
|
|
133
|
+
return /* @__PURE__ */ jsx(
|
|
134
|
+
NavigationViewNode,
|
|
135
|
+
{
|
|
136
|
+
keyPath: childKeyPath,
|
|
137
|
+
section: sectionProp,
|
|
138
|
+
dictionaryKey
|
|
139
|
+
}
|
|
140
|
+
);
|
|
141
|
+
}
|
|
208
142
|
const sectionArray = Object.keys(section);
|
|
209
143
|
return /* @__PURE__ */ jsx("div", { className: "flex w-full max-w-full flex-col justify-between gap-2", children: sectionArray.map((key) => {
|
|
210
144
|
const childKeyPath = [
|
|
@@ -212,8 +146,8 @@ const NavigationViewNode = ({
|
|
|
212
146
|
{ type: NodeType.Object, key }
|
|
213
147
|
];
|
|
214
148
|
const subSection = getContentNodeByKeyPath(sectionProp, childKeyPath);
|
|
215
|
-
const
|
|
216
|
-
if (
|
|
149
|
+
const isEditableSubSection2 = getIsEditableSection(subSection);
|
|
150
|
+
if (isEditableSubSection2) {
|
|
217
151
|
return /* @__PURE__ */ jsx(
|
|
218
152
|
Button,
|
|
219
153
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationViewNode.mjs","sources":["../../../../src/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\n\nimport {\n NodeType,\n type KeyPath,\n type ContentNode,\n isSameKeyPath,\n getContentNodeByKeyPath,\n getNodeType,\n getEmptyNode,\n} from '@intlayer/core';\nimport {\n useEditedContentActions,\n useFocusDictionary,\n} from '@intlayer/editor-react';\nimport { ChevronRight, Plus } from 'lucide-react';\nimport type { FC } from 'react';\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: ContentNode;\n};\n\nexport const NavigationViewNode: FC<NodeWrapperProps> = ({\n section: sectionProp,\n keyPath,\n dictionaryKey,\n}) => {\n const { locales } = configuration?.internationalization;\n const section = getContentNodeByKeyPath(sectionProp, keyPath);\n const { addEditedContent } = useEditedContentActions();\n const { setFocusedContentKeyPath, focusedContent } = useFocusDictionary();\n const {\n addNewElement,\n goToElement,\n goToField,\n goToEnumeration,\n goToTranslation,\n } = useDictionary(navigationViewContent);\n const nodeType = getNodeType(section);\n const getIsSelected = (keyPath: KeyPath[]) =>\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(keyPath, focusedContent?.keyPath ?? []);\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 = getContentNodeByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToTranslation.label.value} ${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.value} ${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 || nodeType === NodeType.Condition) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {Object.keys(\n (section as any)[nodeType as unknown as keyof typeof section]\n ).map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: nodeType, key },\n ];\n const subSection = getContentNodeByKeyPath(\n sectionProp,\n childKeyPath\n );\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToEnumeration.label.value} ${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.value} ${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 unknown as ContentNode[]).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.value} ${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.value} ${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.value}\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 unknown as ContentNode[]).length,\n },\n ];\n const sectionArray = section as unknown as ContentNode[];\n const emptySectionEl =\n getEmptyNode(\n sectionArray[\n (sectionArray.length - 1) as keyof typeof sectionArray\n ] as ContentNode\n ) ?? '';\n addEditedContent(\n dictionaryKey,\n emptySectionEl,\n newKeyPath,\n false\n );\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\n const subSection = getContentNodeByKeyPath(sectionProp, childKeyPath);\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToField.label.value} ${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.value} ${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 </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":["configuration","keyPath","sectionArray"],"mappings":";;;;;;;;;;;AAwBO,MAAM,YAAsB,CAAC,YAAY,MAAM,UAAU;AAQzD,MAAM,qBAA2C,CAAC;AAAA,EACvD,SAAS;AAAA,EACT;AAAA,EACA;AACF,MAAM;AACE,QAAA,EAAE,YAAYA,sBAAe;AAC7B,QAAA,UAAU,wBAAwB,aAAa,OAAO;AACtD,QAAA,EAAE,iBAAiB,IAAI,wBAAwB;AACrD,QAAM,EAAE,0BAA0B,eAAe,IAAI,mBAAmB;AAClE,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACE,cAAc,qBAAqB;AACjC,QAAA,WAAW,YAAY,OAAO;AACpC,QAAM,gBAAgB,CAACC,cACpB,gBAAgB,SAAS,UAAU,KAAK,KACzC,cAAcA,UAAS,gBAAgB,WAAW,CAAA,CAAE;AAElD,MAAA,CAAC,QAAS,QAAS,oBAAA,UAAA,CAAA,CAAA;AAEnB,MAAA,OAAO,YAAY,UAAU;AAC3B,QAAA,aAAa,SAAS,WAAW;AACnC,6CAAS,UAAU,aAAA,CAAA;AAAA,IAAA;AAGjB,QAAA,aAAa,SAAS,aAAa;AACrC,iCACG,OAAI,EAAA,WAAU,uCACZ,UAAQ,QAAA,IAAI,CAAC,mBAAmB;AAC/B,cAAM,eAA0B;AAAA,UAC9B,GAAG;AAAA,UACH,EAAE,MAAM,SAAS,aAAa,KAAK,eAAe;AAAA,QACpD;AACA,cAAM,aAAa;AAAA,UACjB;AAAA,UACA;AA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/B;AAEM,YAAA,aAAa,wBAAwB,aAAa,YAAY;AAC9D,YAAA,uBAAuB,qBAAqB,UAAU;AAE5D,UAAI,sBAAsB;AAEtB,eAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,OAAO,GAAG,UAAU,MAAM,KAAK,IAAI,GAAG;AAAA,YAEtC,UAAU,cAAc,YAAY;AAAA,YACpC,SAAQ;AAAA,YACR,OAAM;AAAA,YACN,WAAU;AAAA,YACV,SAAS,MAAM,yBAAyB,YAAY;AAAA,YACpD,WAAW;AAAA,YAEV,8BAAoB,GAAG;AAAA,UAAA;AAAA,UARnB;AAAA,QASP;AAAA,MAAA;AAKF,aAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UAEC,OAAO,GAAG,UAAU,MAAM,KAAK,IAAI,GAAG;AAAA,UACtC,UAAU,cAAc,YAAY;AAAA,UACpC,SAAS,MAAM,yBAAyB,YAAY;AAAA,UACpD,QAAQ,oBAAoB,GAAG;AAAA,UAE/B,8BAAC,OAAI,EAAA,WAAU,+BACb,UAAC,oBAAA,OAAA,EAAI,WAAU,gBACb,UAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,SAAS;AAAA,cACT,SAAS;AAAA,cACT;AAAA,YAAA;AAAA,aAEJ,EACF,CAAA;AAAA,QAAA;AAAA,QAdK;AAAA,MAeP;AAAA,IAEH,CAAA,GACH;AAAA,EAAA;AAIJ,SACI,qBAAA,UAAA,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 configuration from '@intlayer/config/built';\n\nimport {\n NodeType,\n type KeyPath,\n type ContentNode,\n isSameKeyPath,\n getContentNodeByKeyPath,\n getNodeType,\n getEmptyNode,\n} from '@intlayer/core';\nimport {\n useEditedContentActions,\n useFocusDictionary,\n} from '@intlayer/editor-react';\nimport { ChevronRight, Plus } from 'lucide-react';\nimport type { FC } from 'react';\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: ContentNode;\n};\n\nexport const NavigationViewNode: FC<NodeWrapperProps> = ({\n section: sectionProp,\n keyPath,\n dictionaryKey,\n}) => {\n const { locales } = configuration?.internationalization;\n const section = getContentNodeByKeyPath(sectionProp, keyPath);\n const { addEditedContent } = useEditedContentActions();\n const { setFocusedContentKeyPath, focusedContent } = useFocusDictionary();\n const { addNewElement, goToField } = useDictionary(navigationViewContent);\n const nodeType = getNodeType(section);\n const getIsSelected = (keyPath: KeyPath[]) =>\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(keyPath, focusedContent?.keyPath ?? []);\n const isEditableSubSection = getIsEditableSection(section);\n\n if (!section) return <></>;\n\n if (isEditableSubSection) {\n return (\n <Button\n label={goToField.label.value}\n variant=\"hoverable\"\n color=\"text\"\n className=\"w-full\"\n onClick={() => setFocusedContentKeyPath(keyPath)}\n IconRight={ChevronRight}\n >\n {camelCaseToSentence(keyPath[keyPath.length - 1].key as string)}\n </Button>\n );\n }\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\n return (\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n );\n })}\n </div>\n );\n }\n\n if (nodeType === NodeType.Enumeration || nodeType === NodeType.Condition) {\n return (\n <div className=\"flex flex-col justify-between gap-2\">\n {Object.keys(\n (section as any)[nodeType as unknown as keyof typeof section]\n ).map((key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: nodeType, key },\n ];\n\n return (\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\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 unknown as ContentNode[]).map((_, index) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Array, key: index },\n ];\n\n return (\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\n );\n })}\n\n <Button\n label={addNewElement.label.value}\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 unknown as ContentNode[]).length,\n },\n ];\n const sectionArray = section as unknown as ContentNode[];\n const emptySectionEl =\n getEmptyNode(\n sectionArray[\n (sectionArray.length - 1) as keyof typeof sectionArray\n ] as ContentNode\n ) ?? '';\n addEditedContent(\n dictionaryKey,\n emptySectionEl,\n newKeyPath,\n false\n );\n setFocusedContentKeyPath(newKeyPath);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n }\n\n if (typeof section.nodeType === 'string') {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: section.nodeType } as KeyPath,\n ];\n\n return (\n <NavigationViewNode\n keyPath={childKeyPath}\n section={sectionProp}\n dictionaryKey={dictionaryKey}\n />\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\n const subSection = getContentNodeByKeyPath(sectionProp, childKeyPath);\n const isEditableSubSection = getIsEditableSection(subSection);\n\n if (isEditableSubSection) {\n return (\n <Button\n label={`${goToField.label.value} ${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.value} ${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 </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":["configuration","keyPath","sectionArray","isEditableSubSection"],"mappings":";;;;;;;;;;;AAwBO,MAAM,YAAsB,CAAC,YAAY,MAAM,UAAU;AAQzD,MAAM,qBAA2C,CAAC;AAAA,EACvD,SAAS;AAAA,EACT;AAAA,EACA;AACF,MAAM;AACE,QAAA,EAAE,YAAYA,sBAAe;AAC7B,QAAA,UAAU,wBAAwB,aAAa,OAAO;AACtD,QAAA,EAAE,iBAAiB,IAAI,wBAAwB;AACrD,QAAM,EAAE,0BAA0B,eAAe,IAAI,mBAAmB;AACxE,QAAM,EAAE,eAAe,cAAc,cAAc,qBAAqB;AAClE,QAAA,WAAW,YAAY,OAAO;AACpC,QAAM,gBAAgB,CAACC,cACpB,gBAAgB,SAAS,UAAU,KAAK,KACzC,cAAcA,UAAS,gBAA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
38
|
},
|
|
39
|
-
goToElement: {
|
|
40
|
-
label: intlayer.t({
|
|
41
|
-
en: "Go to element",
|
|
42
|
-
"en-GB": "Go to element",
|
|
43
|
-
fr: "Aller à l'élément",
|
|
44
|
-
es: "Ir al elemento",
|
|
45
|
-
de: "Zum Element gehen",
|
|
46
|
-
ja: "要素に移動",
|
|
47
|
-
ko: "요소로 이동",
|
|
48
|
-
zh: "转到元素",
|
|
49
|
-
it: "Vai all’elemento",
|
|
50
|
-
pt: "Ir para o elemento",
|
|
51
|
-
hi: "तत्व पर जाएं",
|
|
52
|
-
ar: "اذهب إلى العنصر",
|
|
53
|
-
ru: "Перейти к элементу"
|
|
54
|
-
})
|
|
55
|
-
},
|
|
56
39
|
addNewElement: {
|
|
57
40
|
label: intlayer.t({
|
|
58
41
|
en: "Click to add element",
|
|
@@ -117,40 +100,6 @@ const navigationViewContent = {
|
|
|
117
100
|
ru: "Удалить элемент"
|
|
118
101
|
})
|
|
119
102
|
},
|
|
120
|
-
goToTranslation: {
|
|
121
|
-
label: intlayer.t({
|
|
122
|
-
en: "Go to translation",
|
|
123
|
-
"en-GB": "Go to translation",
|
|
124
|
-
fr: "Aller à la traduction",
|
|
125
|
-
es: "Ir a la traducción",
|
|
126
|
-
de: "Zur Übersetzung gehen",
|
|
127
|
-
ja: "翻訳に移動",
|
|
128
|
-
ko: "번역으로 이동",
|
|
129
|
-
zh: "转到翻译",
|
|
130
|
-
it: "Vai alla traduzione",
|
|
131
|
-
pt: "Ir para a tradução",
|
|
132
|
-
hi: "अनुवाद पर जाएं",
|
|
133
|
-
ar: "اذهب إلى الترجمة",
|
|
134
|
-
ru: "Перейти к переводу"
|
|
135
|
-
})
|
|
136
|
-
},
|
|
137
|
-
goToEnumeration: {
|
|
138
|
-
label: intlayer.t({
|
|
139
|
-
en: "Go to enumeration",
|
|
140
|
-
"en-GB": "Go to enumeration",
|
|
141
|
-
fr: "Aller à l'énumération",
|
|
142
|
-
es: "Ir a la enumeración",
|
|
143
|
-
de: "Zur Aufzählung gehen",
|
|
144
|
-
ja: "列挙に移動",
|
|
145
|
-
ko: "열거로 이동",
|
|
146
|
-
zh: "转到枚举",
|
|
147
|
-
it: "Vai all ENUMERAZIONE",
|
|
148
|
-
pt: "Ir para a enumeração",
|
|
149
|
-
hi: "सूची में जाएं",
|
|
150
|
-
ar: "اذهب إلى التعداد",
|
|
151
|
-
ru: "Перейти к перечислению"
|
|
152
|
-
})
|
|
153
|
-
},
|
|
154
103
|
addNewEnumeration: {
|
|
155
104
|
label: intlayer.t({
|
|
156
105
|
en: "Click to add enumeration",
|