@intlayer/design-system 5.1.3 → 5.1.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.
Files changed (197) hide show
  1. package/dist/.vite/manifest.json +37 -102
  2. package/dist/Form-BZUDRfoN.js.map +1 -1
  3. package/dist/Form-yi0CMK-a.cjs.map +1 -1
  4. package/dist/components/Auth/ExternalsLoginButtons/ExternalsLoginButtons.cjs +1 -1
  5. package/dist/components/Auth/ExternalsLoginButtons/ExternalsLoginButtons.mjs +1 -1
  6. package/dist/components/Command/index.d.ts +1 -1
  7. package/dist/components/Container/index.cjs +6 -7
  8. package/dist/components/Container/index.cjs.map +1 -1
  9. package/dist/components/Container/index.mjs +6 -7
  10. package/dist/components/Container/index.mjs.map +1 -1
  11. package/dist/components/DictionaryEditor/DictionaryEditor.cjs +3 -3
  12. package/dist/components/DictionaryEditor/DictionaryEditor.cjs.map +1 -1
  13. package/dist/components/DictionaryEditor/DictionaryEditor.d.ts +1 -1
  14. package/dist/components/DictionaryEditor/DictionaryEditor.d.ts.map +1 -1
  15. package/dist/components/DictionaryEditor/DictionaryEditor.mjs +3 -3
  16. package/dist/components/DictionaryEditor/DictionaryEditor.mjs.map +1 -1
  17. package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.cjs +33 -20
  18. package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.cjs.map +1 -1
  19. package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.d.ts.map +1 -1
  20. package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.mjs +34 -21
  21. package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.mjs.map +1 -1
  22. package/dist/components/DictionaryFieldEditor/ContentEditor.cjs +20 -9
  23. package/dist/components/DictionaryFieldEditor/ContentEditor.cjs.map +1 -1
  24. package/dist/components/DictionaryFieldEditor/ContentEditor.d.ts.map +1 -1
  25. package/dist/components/DictionaryFieldEditor/ContentEditor.mjs +21 -10
  26. package/dist/components/DictionaryFieldEditor/ContentEditor.mjs.map +1 -1
  27. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.cjs +241 -209
  28. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.cjs.map +1 -1
  29. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.d.ts +1 -0
  30. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.d.ts.map +1 -1
  31. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs +245 -213
  32. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs.map +1 -1
  33. package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.cjs.map +1 -1
  34. package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.d.ts +1 -1
  35. package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.d.ts.map +1 -1
  36. package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.mjs.map +1 -1
  37. package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.cjs +1 -1
  38. package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs +1 -1
  39. package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.cjs +92 -120
  40. package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.cjs.map +1 -1
  41. package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.d.ts +1 -1
  42. package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.d.ts.map +1 -1
  43. package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs +94 -122
  44. package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs.map +1 -1
  45. package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.cjs +0 -143
  46. package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.cjs.map +1 -1
  47. package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.d.ts +0 -143
  48. package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.d.ts.map +1 -1
  49. package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.mjs +0 -143
  50. package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.mjs.map +1 -1
  51. package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.cjs +1 -2
  52. package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.cjs.map +1 -1
  53. package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.d.ts +0 -3
  54. package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.d.ts.map +1 -1
  55. package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.mjs +1 -2
  56. package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.mjs.map +1 -1
  57. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.cjs +51 -70
  58. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.cjs.map +1 -1
  59. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.d.ts +1 -1
  60. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.d.ts.map +1 -1
  61. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs +51 -70
  62. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs.map +1 -1
  63. package/dist/components/DictionaryFieldEditor/EnumKeyInput.cjs +1 -1
  64. package/dist/components/DictionaryFieldEditor/EnumKeyInput.cjs.map +1 -1
  65. package/dist/components/DictionaryFieldEditor/EnumKeyInput.mjs +1 -1
  66. package/dist/components/DictionaryFieldEditor/EnumKeyInput.mjs.map +1 -1
  67. package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.cjs +18 -12
  68. package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.cjs.map +1 -1
  69. package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.d.ts.map +1 -1
  70. package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs +19 -13
  71. package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs.map +1 -1
  72. package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.cjs +64 -0
  73. package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.cjs.map +1 -1
  74. package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.d.ts +64 -0
  75. package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.d.ts.map +1 -1
  76. package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.mjs +64 -0
  77. package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.mjs.map +1 -1
  78. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs +52 -103
  79. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs.map +1 -1
  80. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.d.ts +3 -3
  81. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.d.ts.map +1 -1
  82. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs +56 -107
  83. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs.map +1 -1
  84. package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.cjs +0 -32
  85. package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.cjs.map +1 -1
  86. package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.d.ts +0 -32
  87. package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.d.ts.map +1 -1
  88. package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.mjs +0 -32
  89. package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.mjs.map +1 -1
  90. package/dist/components/DictionaryFieldEditor/StructureEditor.cjs +4 -4
  91. package/dist/components/DictionaryFieldEditor/StructureEditor.cjs.map +1 -1
  92. package/dist/components/DictionaryFieldEditor/StructureEditor.d.ts.map +1 -1
  93. package/dist/components/DictionaryFieldEditor/StructureEditor.mjs +4 -4
  94. package/dist/components/DictionaryFieldEditor/StructureEditor.mjs.map +1 -1
  95. package/dist/components/DictionaryFieldEditor/StructureView/StructureView.cjs +3 -2
  96. package/dist/components/DictionaryFieldEditor/StructureView/StructureView.cjs.map +1 -1
  97. package/dist/components/DictionaryFieldEditor/StructureView/StructureView.d.ts.map +1 -1
  98. package/dist/components/DictionaryFieldEditor/StructureView/StructureView.mjs +3 -2
  99. package/dist/components/DictionaryFieldEditor/StructureView/StructureView.mjs.map +1 -1
  100. package/dist/components/DictionaryFieldEditor/index.cjs +0 -2
  101. package/dist/components/DictionaryFieldEditor/index.cjs.map +1 -1
  102. package/dist/components/DictionaryFieldEditor/index.d.ts +0 -1
  103. package/dist/components/DictionaryFieldEditor/index.d.ts.map +1 -1
  104. package/dist/components/DictionaryFieldEditor/index.mjs +0 -2
  105. package/dist/components/DictionaryFieldEditor/index.mjs.map +1 -1
  106. package/dist/components/Form/FormBase.cjs +0 -1
  107. package/dist/components/Form/FormBase.cjs.map +1 -1
  108. package/dist/components/Form/FormBase.d.ts +1 -4
  109. package/dist/components/Form/FormBase.d.ts.map +1 -1
  110. package/dist/components/Form/FormBase.mjs +0 -1
  111. package/dist/components/Form/FormBase.mjs.map +1 -1
  112. package/dist/components/Form/elements/EditableFieldInputElement.d.ts +1 -1
  113. package/dist/components/Form/elements/EditableFieldInputElement.d.ts.map +1 -1
  114. package/dist/components/Form/elements/EditableFieldTextAreaElement.d.ts +1 -1
  115. package/dist/components/Form/elements/EditableFieldTextAreaElement.d.ts.map +1 -1
  116. package/dist/components/Input/Checkbox.cjs +0 -1
  117. package/dist/components/Input/Checkbox.cjs.map +1 -1
  118. package/dist/components/Input/Checkbox.mjs +0 -1
  119. package/dist/components/Input/Checkbox.mjs.map +1 -1
  120. package/dist/components/Input/Input.cjs +1 -1
  121. package/dist/components/Input/Input.cjs.map +1 -1
  122. package/dist/components/Input/Input.mjs +1 -1
  123. package/dist/components/Input/Input.mjs.map +1 -1
  124. package/dist/components/KeyboardScreenAdapter/index.cjs +25 -0
  125. package/dist/components/KeyboardScreenAdapter/index.cjs.map +1 -0
  126. package/dist/components/KeyboardScreenAdapter/index.d.ts +3 -0
  127. package/dist/components/KeyboardScreenAdapter/index.d.ts.map +1 -0
  128. package/dist/components/KeyboardScreenAdapter/index.mjs +25 -0
  129. package/dist/components/KeyboardScreenAdapter/index.mjs.map +1 -0
  130. package/dist/components/MaxHeightSmoother/index.cjs +3 -1
  131. package/dist/components/MaxHeightSmoother/index.cjs.map +1 -1
  132. package/dist/components/MaxHeightSmoother/index.d.ts.map +1 -1
  133. package/dist/components/MaxHeightSmoother/index.mjs +3 -1
  134. package/dist/components/MaxHeightSmoother/index.mjs.map +1 -1
  135. package/dist/components/Modal/Modal.cjs +15 -13
  136. package/dist/components/Modal/Modal.cjs.map +1 -1
  137. package/dist/components/Modal/Modal.d.ts.map +1 -1
  138. package/dist/components/Modal/Modal.mjs +15 -13
  139. package/dist/components/Modal/Modal.mjs.map +1 -1
  140. package/dist/components/RightDrawer/RightDrawer.cjs +1 -1
  141. package/dist/components/RightDrawer/RightDrawer.cjs.map +1 -1
  142. package/dist/components/RightDrawer/RightDrawer.mjs +1 -1
  143. package/dist/components/RightDrawer/RightDrawer.mjs.map +1 -1
  144. package/dist/components/Select/Multiselect.cjs +0 -1
  145. package/dist/components/Select/Multiselect.cjs.map +1 -1
  146. package/dist/components/Select/Multiselect.d.ts.map +1 -1
  147. package/dist/components/Select/Multiselect.mjs +1 -2
  148. package/dist/components/Select/Multiselect.mjs.map +1 -1
  149. package/dist/components/Select/Select.cjs +0 -1
  150. package/dist/components/Select/Select.cjs.map +1 -1
  151. package/dist/components/Select/Select.d.ts.map +1 -1
  152. package/dist/components/Select/Select.mjs +0 -1
  153. package/dist/components/Select/Select.mjs.map +1 -1
  154. package/dist/components/index.cjs +2 -2
  155. package/dist/components/index.d.ts +1 -0
  156. package/dist/components/index.d.ts.map +1 -1
  157. package/dist/components/index.mjs +2 -2
  158. package/dist/hooks/index.cjs +2 -0
  159. package/dist/hooks/index.cjs.map +1 -1
  160. package/dist/hooks/index.d.ts +1 -0
  161. package/dist/hooks/index.d.ts.map +1 -1
  162. package/dist/hooks/index.mjs +2 -0
  163. package/dist/hooks/index.mjs.map +1 -1
  164. package/dist/hooks/intlayerAPIHooks.cjs +1 -1
  165. package/dist/hooks/intlayerAPIHooks.cjs.map +1 -1
  166. package/dist/hooks/intlayerAPIHooks.d.ts.map +1 -1
  167. package/dist/hooks/intlayerAPIHooks.mjs +1 -1
  168. package/dist/hooks/intlayerAPIHooks.mjs.map +1 -1
  169. package/dist/hooks/useAsync/useAsyncStateStore.cjs +8 -14
  170. package/dist/hooks/useAsync/useAsyncStateStore.cjs.map +1 -1
  171. package/dist/hooks/useAsync/useAsyncStateStore.d.ts.map +1 -1
  172. package/dist/hooks/useAsync/useAsyncStateStore.mjs +8 -14
  173. package/dist/hooks/useAsync/useAsyncStateStore.mjs.map +1 -1
  174. package/dist/hooks/useKeyboardDetector.cjs +27 -0
  175. package/dist/hooks/useKeyboardDetector.cjs.map +1 -0
  176. package/dist/hooks/useKeyboardDetector.d.ts +5 -0
  177. package/dist/hooks/useKeyboardDetector.d.ts.map +1 -0
  178. package/dist/hooks/useKeyboardDetector.mjs +27 -0
  179. package/dist/hooks/useKeyboardDetector.mjs.map +1 -0
  180. package/dist/{index-BTDHuTxL.js → index-B1w5h_6-.js} +7 -7
  181. package/dist/index-B1w5h_6-.js.map +1 -0
  182. package/dist/index-BCuMWKyy.js.map +1 -1
  183. package/dist/index-BYzBot7l.cjs.map +1 -1
  184. package/dist/{index-Db5Dym4h.cjs → index-U1U6ySIn.cjs} +7 -7
  185. package/dist/index-U1U6ySIn.cjs.map +1 -0
  186. package/dist/tailwind.css +1 -1
  187. package/dist/zod-BV4nCGJE.js.map +1 -1
  188. package/dist/zod-DSrtTSD_.cjs.map +1 -1
  189. package/package.json +19 -19
  190. package/dist/components/DictionaryFieldEditor/ContentEditorView/EditorView.cjs +0 -49
  191. package/dist/components/DictionaryFieldEditor/ContentEditorView/EditorView.cjs.map +0 -1
  192. package/dist/components/DictionaryFieldEditor/ContentEditorView/EditorView.d.ts +0 -10
  193. package/dist/components/DictionaryFieldEditor/ContentEditorView/EditorView.d.ts.map +0 -1
  194. package/dist/components/DictionaryFieldEditor/ContentEditorView/EditorView.mjs +0 -49
  195. package/dist/components/DictionaryFieldEditor/ContentEditorView/EditorView.mjs.map +0 -1
  196. package/dist/index-BTDHuTxL.js.map +0 -1
  197. package/dist/index-Db5Dym4h.cjs.map +0 -1
@@ -1,9 +1,9 @@
1
1
  "use client";
2
- import { jsx, Fragment, jsxs } from "react/jsx-runtime";
3
- import { getNodeType, NodeType, getLocaleName } from "@intlayer/core";
2
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
3
+ import { getNodeType, NodeType, getLocaleName, getEmptyNode } from "@intlayer/core";
4
4
  import { useEditedContent, useConfiguration } from "@intlayer/editor-react";
5
- import { X, Plus, WandSparkles } from "lucide-react";
6
- import { useState } from "react";
5
+ import { Trash, Plus, WandSparkles } from "lucide-react";
6
+ import { Fragment as Fragment$1, useState } from "react";
7
7
  import { useDictionary, useLocale } from "react-intlayer";
8
8
  import "../../../hooks/useScrollBlockage/useScrollBlockageStore.mjs";
9
9
  import "../../../hooks/useAsync/useAsyncStateStore.mjs";
@@ -11,12 +11,12 @@ import { useAuditContentDeclarationField } from "../../../hooks/intlayerAPIHooks
11
11
  import "deepmerge";
12
12
  import { renameKey } from "../../../utils/object.mjs";
13
13
  import { Button } from "../../Button/Button.mjs";
14
+ import { Container } from "../../Container/index.mjs";
14
15
  import { ContentEditorInput as ContentEditorInput$1 } from "../../ContentEditor/ContentEditorInput.mjs";
15
16
  import { ContentEditorTextArea as ContentEditorTextArea$1 } from "../../ContentEditor/ContentEditorTextArea.mjs";
16
17
  import { Label } from "../../Label/index.mjs";
17
18
  import "@intlayer/config/client";
18
19
  import "fuse.js";
19
- import "../../Container/index.mjs";
20
20
  import "../../DropDown/index.mjs";
21
21
  import "../../Input/Input.mjs";
22
22
  import "../../Input/Checkbox.mjs";
@@ -25,7 +25,6 @@ import "../../LocaleSwitcherContentDropDown/localeSwitcher.content.mjs";
25
25
  import { useLocaleSwitcherContent } from "../../LocaleSwitcherContentDropDown/LocaleSwitcherContentContext.mjs";
26
26
  import { MarkdownRenderer } from "../../MarkDownRender/index.mjs";
27
27
  import { EnumKeyInput } from "../EnumKeyInput.mjs";
28
- import { getIsEditableSection } from "../getIsEditableSection.mjs";
29
28
  import { navigationViewContent } from "../NavigationView/navigationViewNode.content.mjs";
30
29
  const traceKeys = ["filePath", "id", "nodeType"];
31
30
  const ContentEditorTextArea = ({
@@ -33,7 +32,7 @@ const ContentEditorTextArea = ({
33
32
  dictionary,
34
33
  ...props
35
34
  }) => {
36
- const { addEditedContent } = useEditedContent();
35
+ const { editedContent, addEditedContent } = useEditedContent();
37
36
  const configuration = useConfiguration();
38
37
  const { auditContentDeclarationField, isLoading: isAuditing } = useAuditContentDeclarationField();
39
38
  return /* @__PURE__ */ jsx(
@@ -53,14 +52,17 @@ const ContentEditorTextArea = ({
53
52
  isLoading: isAuditing,
54
53
  onClick: () => {
55
54
  auditContentDeclarationField({
56
- fileContent: JSON.stringify(dictionary),
55
+ fileContent: JSON.stringify({
56
+ ...dictionary,
57
+ ...editedContent?.[dictionary.key] ?? {}
58
+ }),
57
59
  keyPath,
58
60
  locales: configuration.internationalization.locales ?? []
59
61
  }).then((response) => {
60
- if (!response.data) return;
62
+ if (!response?.data) return;
61
63
  try {
62
- const editedContent = response.data.fileContent;
63
- addEditedContent(dictionary.key, editedContent, keyPath);
64
+ const editedContent2 = response.data.fileContent;
65
+ addEditedContent(dictionary.key, editedContent2, keyPath);
64
66
  } catch (error) {
65
67
  console.error(error);
66
68
  }
@@ -120,7 +122,7 @@ const TranslationTextEditor = ({
120
122
  keyPath,
121
123
  dictionary
122
124
  }) => {
123
- const { locale } = useLocale();
125
+ const { locale, defaultLocale } = useLocale();
124
126
  const { selectedLocales, availableLocales } = useLocaleSwitcherContent();
125
127
  const sectionContent = section[NodeType.Translation];
126
128
  const sectionContentKeys = Object.keys(sectionContent);
@@ -129,20 +131,21 @@ const TranslationTextEditor = ({
129
131
  // If the translation include content in other locales, we display all of them
130
132
  [.../* @__PURE__ */ new Set([...availableLocales, ...sectionContentKeys])]
131
133
  );
132
- return /* @__PURE__ */ jsx("table", { className: "w-full gap-2", children: /* @__PURE__ */ jsx("tbody", { className: "divide-y-[1.5px]", children: localesList.map((translationKey) => /* @__PURE__ */ jsx("tr", { className: "w-full", lang: translationKey, children: /* @__PURE__ */ jsxs("td", { className: "flex w-full flex-col p-2", children: [
133
- selectedLocales.length > 1 && /* @__PURE__ */ jsx("span", { className: "w-full p-2 text-xs", children: getLocaleName(translationKey, locale) }),
134
- /* @__PURE__ */ jsx(
135
- TextEditor,
134
+ const content = section[NodeType.Translation];
135
+ return /* @__PURE__ */ jsx("table", { className: "w-full", children: /* @__PURE__ */ jsx("tbody", { className: "flex w-full flex-col gap-2", children: localesList.map((translationKey) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
136
+ /* @__PURE__ */ jsx("tr", { className: "mt-2 w-full p-2 text-xs", children: getLocaleName(translationKey, locale) }),
137
+ /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx(
138
+ TextEditorContainer,
136
139
  {
137
- section: section[NodeType.Translation][translationKey],
140
+ section: content[translationKey] ?? getEmptyNode(content[defaultLocale]),
138
141
  keyPath: [
139
142
  ...keyPath,
140
143
  { type: NodeType.Translation, key: translationKey }
141
144
  ],
142
145
  dictionary
143
146
  }
144
- )
145
- ] }) }, translationKey)) }) });
147
+ ) })
148
+ ] }, translationKey)) }) });
146
149
  };
147
150
  const EnumerationTextEditor = ({
148
151
  section,
@@ -150,31 +153,37 @@ const EnumerationTextEditor = ({
150
153
  dictionary
151
154
  }) => {
152
155
  const { addEditedContent } = useEditedContent();
153
- const { addNewEnumeration } = useDictionary(navigationViewContent);
154
- return /* @__PURE__ */ jsxs("table", { className: "w-full table-fixed gap-2", children: [
155
- /* @__PURE__ */ jsx("tbody", { className: "divide-y-[1.5px]", children: Object.keys(
156
+ const { addNewEnumeration, removeEnumeration } = useDictionary(
157
+ navigationViewContent
158
+ );
159
+ const content = section[NodeType.Enumeration];
160
+ const firstKey = Object.keys(content)[0];
161
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
162
+ /* @__PURE__ */ jsx("table", { className: "w-full", children: /* @__PURE__ */ jsx("tbody", { className: "flex w-full flex-col gap-2", children: Object.keys(
156
163
  section[NodeType.Enumeration]
157
- ).map((enumKey) => /* @__PURE__ */ jsxs("tr", { className: "w-full", children: [
158
- /* @__PURE__ */ jsx("td", { className: "w-44 p-2", children: /* @__PURE__ */ jsxs("div", { className: "flex gap-1", children: [
159
- /* @__PURE__ */ jsx(
164
+ ).map((enumKey) => {
165
+ const childrenKeyPath = [
166
+ ...keyPath,
167
+ { type: NodeType.Enumeration }
168
+ ];
169
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
170
+ /* @__PURE__ */ jsx("tr", { className: "mt-2 w-full", children: /* @__PURE__ */ jsx("div", { className: "flex flex-1", children: /* @__PURE__ */ jsx(
160
171
  Button,
161
172
  {
162
- label: "Remove",
173
+ label: removeEnumeration.label.value,
163
174
  variant: "hoverable",
164
- size: "icon-md",
165
175
  color: "text",
166
- Icon: X,
167
- className: "w-16",
168
- onClick: () => addEditedContent(dictionary.key, void 0, [
169
- ...keyPath,
170
- {
171
- type: NodeType.Enumeration,
172
- key: enumKey
173
- }
174
- ])
176
+ Icon: Trash,
177
+ className: "ml-auto",
178
+ onClick: () => addEditedContent(
179
+ dictionary.key,
180
+ void 0,
181
+ childrenKeyPath
182
+ ),
183
+ children: removeEnumeration.text
175
184
  }
176
- ),
177
- /* @__PURE__ */ jsx(
185
+ ) }) }),
186
+ /* @__PURE__ */ jsx("tr", { className: "w-full p-2", children: /* @__PURE__ */ jsx(
178
187
  EnumKeyInput,
179
188
  {
180
189
  value: enumKey,
@@ -192,38 +201,35 @@ const EnumerationTextEditor = ({
192
201
  addEditedContent(dictionary.key, newValue, keyPath);
193
202
  }
194
203
  }
195
- )
196
- ] }) }),
197
- /* @__PURE__ */ jsx("td", { className: "w-full p-2", children: /* @__PURE__ */ jsx(
198
- TextEditor,
199
- {
200
- section: section[NodeType.Enumeration][enumKey],
201
- keyPath: [
202
- ...keyPath,
203
- { type: NodeType.Enumeration, key: enumKey }
204
- ],
205
- dictionary
206
- }
207
- ) })
208
- ] }, enumKey)) }),
209
- /* @__PURE__ */ jsx("tfoot", { children: /* @__PURE__ */ jsx(
204
+ ) }),
205
+ /* @__PURE__ */ jsx("tr", { className: "block w-full", children: /* @__PURE__ */ jsx(
206
+ TextEditor,
207
+ {
208
+ section: content[enumKey] ?? getEmptyNode(content[firstKey]),
209
+ keyPath: childrenKeyPath,
210
+ dictionary
211
+ }
212
+ ) })
213
+ ] }, enumKey);
214
+ }) }) }),
215
+ /* @__PURE__ */ jsx(
210
216
  Button,
211
217
  {
212
218
  label: addNewEnumeration.label.value,
213
219
  variant: "hoverable",
214
220
  color: "neutral",
215
221
  textAlign: "left",
222
+ isFullWidth: true,
216
223
  onClick: () => addEditedContent(
217
224
  dictionary.key,
218
- "",
219
- [...keyPath, { type: NodeType.Enumeration, key: "unknown" }],
220
- false
225
+ getEmptyNode(content[firstKey]) ?? "",
226
+ [...keyPath, { type: NodeType.Enumeration, key: "unknown" }]
221
227
  ),
222
228
  Icon: Plus,
223
229
  className: "m-2",
224
230
  children: addNewEnumeration.text
225
231
  }
226
- ) })
232
+ )
227
233
  ] });
228
234
  };
229
235
  const ConditionTextEditor = ({
@@ -231,83 +237,24 @@ const ConditionTextEditor = ({
231
237
  keyPath,
232
238
  dictionary
233
239
  }) => {
234
- const { addEditedContent } = useEditedContent();
235
- const { addNewEnumeration } = useDictionary(navigationViewContent);
236
- return /* @__PURE__ */ jsxs("table", { className: "w-full table-fixed gap-2", children: [
237
- /* @__PURE__ */ jsx("tbody", { className: "divide-y-[1.5px]", children: ["true", "false", "fallback"].map((condKey) => /* @__PURE__ */ jsxs("tr", { className: "w-full", children: [
238
- /* @__PURE__ */ jsx("td", { className: "w-44 p-2", children: /* @__PURE__ */ jsxs("div", { className: "flex gap-1", children: [
239
- /* @__PURE__ */ jsx(
240
- Button,
240
+ const content = section[NodeType.Condition];
241
+ return /* @__PURE__ */ jsx("table", { className: "w-full", children: /* @__PURE__ */ jsx("tbody", { className: "flex w-full flex-col gap-2", children: ["true", "false", "fallback"].map((condKey) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
242
+ /* @__PURE__ */ jsx("tr", { className: "mt-2 block w-full p-2 text-xs", children: String(condKey) }, condKey),
243
+ /* @__PURE__ */ jsx("tr", { className: "block w-full", children: /* @__PURE__ */ jsx(
244
+ TextEditorContainer,
245
+ {
246
+ section: content[condKey] ?? getEmptyNode(content["true"]),
247
+ keyPath: [
248
+ ...keyPath,
241
249
  {
242
- label: "Remove",
243
- variant: "hoverable",
244
- size: "icon-md",
245
- color: "text",
246
- Icon: X,
247
- className: "w-16",
248
- onClick: () => addEditedContent(dictionary.key, void 0, [
249
- ...keyPath,
250
- {
251
- type: NodeType.Condition,
252
- key: condKey
253
- }
254
- ])
250
+ type: NodeType.Condition,
251
+ key: condKey
255
252
  }
256
- ),
257
- /* @__PURE__ */ jsx(
258
- EnumKeyInput,
259
- {
260
- value: condKey,
261
- onChange: (value) => {
262
- const preValueContent = section[NodeType.Condition];
263
- const newValueContent = renameKey(
264
- preValueContent,
265
- condKey,
266
- value
267
- );
268
- const newValue = {
269
- ...section,
270
- [NodeType.Condition]: newValueContent
271
- };
272
- addEditedContent(dictionary.key, newValue, keyPath);
273
- }
274
- }
275
- )
276
- ] }) }),
277
- /* @__PURE__ */ jsx("td", { className: "w-full p-2", children: /* @__PURE__ */ jsx(
278
- TextEditor,
279
- {
280
- section: section[NodeType.Enumeration][condKey],
281
- keyPath: [
282
- ...keyPath,
283
- {
284
- type: NodeType.Array,
285
- key: parseInt(condKey)
286
- }
287
- ],
288
- dictionary
289
- }
290
- ) })
291
- ] }, condKey)) }),
292
- /* @__PURE__ */ jsx("tfoot", { children: /* @__PURE__ */ jsx(
293
- Button,
294
- {
295
- label: addNewEnumeration.label.value,
296
- variant: "hoverable",
297
- color: "neutral",
298
- textAlign: "left",
299
- onClick: () => addEditedContent(
300
- dictionary.key,
301
- "",
302
- [...keyPath, { type: NodeType.Enumeration, key: "unknown" }],
303
- false
304
- ),
305
- Icon: Plus,
306
- className: "m-2",
307
- children: addNewEnumeration.text
253
+ ],
254
+ dictionary
308
255
  }
309
- ) })
310
- ] });
256
+ ) }, condKey)
257
+ ] }, condKey)) }) });
311
258
  };
312
259
  const ArrayTextEditor = ({
313
260
  section,
@@ -315,14 +262,38 @@ const ArrayTextEditor = ({
315
262
  dictionary
316
263
  }) => {
317
264
  const { addEditedContent } = useEditedContent();
318
- const { addNewElement } = useDictionary(navigationViewContent);
319
- return /* @__PURE__ */ jsxs("table", { className: "w-full gap-2", children: [
320
- /* @__PURE__ */ jsx("tbody", { className: "divide-y-[1.5px]", children: section.map((subSection, index) => /* @__PURE__ */ jsxs("tr", { className: "w-full", children: [
321
- /* @__PURE__ */ jsx("td", { className: "p-2", children: index }),
322
- /* @__PURE__ */ jsx("td", { className: "w-full p-2", children: /* @__PURE__ */ jsx(
323
- TextEditor,
265
+ const { addNewElement, removeElement } = useDictionary(navigationViewContent);
266
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
267
+ /* @__PURE__ */ jsx("table", { className: "w-full", children: /* @__PURE__ */ jsx("tbody", { className: "flex w-full flex-col gap-2", children: section.map((subSection, index) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
268
+ /* @__PURE__ */ jsxs("tr", { className: "mt-2 flex w-full justify-between gap-2 p-2", children: [
269
+ /* @__PURE__ */ jsx("span", { className: "text-xs", children: String(index) }),
270
+ /* @__PURE__ */ jsx(
271
+ Button,
272
+ {
273
+ label: removeElement.label.value,
274
+ variant: "hoverable",
275
+ color: "neutral",
276
+ className: "ml-auto",
277
+ textAlign: "left",
278
+ onClick: () => {
279
+ const newKeyPath = [
280
+ ...keyPath,
281
+ {
282
+ type: NodeType.Array,
283
+ key: section.length
284
+ }
285
+ ];
286
+ addEditedContent(dictionary.key, void 0, newKeyPath);
287
+ },
288
+ Icon: Trash,
289
+ children: removeElement.text
290
+ }
291
+ )
292
+ ] }),
293
+ /* @__PURE__ */ jsx("tr", { className: "block w-full", children: /* @__PURE__ */ jsx(
294
+ TextEditorContainer,
324
295
  {
325
- section: subSection,
296
+ section: subSection ?? getEmptyNode(section[0]),
326
297
  keyPath: [
327
298
  ...keyPath,
328
299
  {
@@ -333,14 +304,15 @@ const ArrayTextEditor = ({
333
304
  dictionary
334
305
  }
335
306
  ) })
336
- ] }, JSON.stringify(subSection))) }),
337
- /* @__PURE__ */ jsx("tfoot", { children: /* @__PURE__ */ jsx(
307
+ ] }, JSON.stringify(subSection))) }) }),
308
+ /* @__PURE__ */ jsx(
338
309
  Button,
339
310
  {
340
311
  label: addNewElement.label.value,
341
312
  variant: "hoverable",
342
313
  color: "neutral",
343
314
  textAlign: "left",
315
+ isFullWidth: true,
344
316
  onClick: () => {
345
317
  const newKeyPath = [
346
318
  ...keyPath,
@@ -349,14 +321,54 @@ const ArrayTextEditor = ({
349
321
  key: section.length
350
322
  }
351
323
  ];
352
- addEditedContent(dictionary.key, "", newKeyPath, false);
324
+ addEditedContent(
325
+ dictionary.key,
326
+ getEmptyNode(section[0]) ?? "",
327
+ newKeyPath,
328
+ false
329
+ );
353
330
  },
354
331
  Icon: Plus,
355
332
  children: addNewElement.text
356
333
  }
357
- ) })
334
+ )
358
335
  ] });
359
336
  };
337
+ const ObjectTextEditor = ({
338
+ section,
339
+ keyPath,
340
+ dictionary
341
+ }) => /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("table", { className: "w-full", children: /* @__PURE__ */ jsx("tbody", { className: "flex flex-col gap-2", children: Object.keys(section).map(
342
+ (key) => {
343
+ const childKeyPath = [
344
+ ...keyPath,
345
+ { type: NodeType.Object, key }
346
+ ];
347
+ const typedSection = section;
348
+ const firstKey = Object.keys(
349
+ typedSection
350
+ )[0];
351
+ const subSection = typedSection[key] ?? getEmptyNode(typedSection[firstKey]);
352
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
353
+ /* @__PURE__ */ jsx(
354
+ "tr",
355
+ {
356
+ className: "mt-2 p-2 text-xs",
357
+ children: String(key)
358
+ },
359
+ JSON.stringify(subSection)
360
+ ),
361
+ /* @__PURE__ */ jsx("tr", { className: "block w-full", children: /* @__PURE__ */ jsx(
362
+ TextEditor,
363
+ {
364
+ section: subSection,
365
+ keyPath: childKeyPath,
366
+ dictionary
367
+ }
368
+ ) }, JSON.stringify(subSection))
369
+ ] }, key);
370
+ }
371
+ ) }) }) });
360
372
  const MarkdownTextEditor = ({
361
373
  section,
362
374
  keyPath,
@@ -467,76 +479,82 @@ const TextEditor = ({
467
479
  }) => {
468
480
  const { tsxNotEditable } = useDictionary(navigationViewContent);
469
481
  const nodeType = getNodeType(section);
470
- const isEditableSection = getIsEditableSection(section);
471
- if (!isEditableSection) return /* @__PURE__ */ jsx(Fragment, {});
472
- if (typeof section === "object") {
473
- if (nodeType === NodeType.ReactNode) {
474
- return /* @__PURE__ */ jsxs(Fragment, { children: [
475
- /* @__PURE__ */ jsx("span", { children: "[React Node]" }),
476
- /* @__PURE__ */ jsx("span", { className: "text-neutral dark:text-neutral-dark text-xs", children: tsxNotEditable })
477
- ] });
478
- }
479
- if (nodeType === NodeType.Nested) {
480
- return /* @__PURE__ */ jsx(
481
- NestedTextEditor,
482
- {
483
- dictionary,
484
- keyPath,
485
- section
486
- }
487
- );
488
- }
489
- if (nodeType === NodeType.Translation) {
490
- return /* @__PURE__ */ jsx(
491
- TranslationTextEditor,
492
- {
493
- dictionary,
494
- keyPath,
495
- section
496
- }
497
- );
498
- }
499
- if (nodeType === NodeType.Enumeration) {
500
- return /* @__PURE__ */ jsx(
501
- EnumerationTextEditor,
502
- {
503
- dictionary,
504
- keyPath,
505
- section
506
- }
507
- );
508
- }
509
- if (nodeType === NodeType.Condition) {
510
- return /* @__PURE__ */ jsx(
511
- ConditionTextEditor,
512
- {
513
- dictionary,
514
- keyPath,
515
- section
516
- }
517
- );
518
- }
519
- if (nodeType === NodeType.Markdown) {
520
- return /* @__PURE__ */ jsx(
521
- MarkdownTextEditor,
522
- {
523
- dictionary,
524
- keyPath,
525
- section,
526
- isDarkMode
527
- }
528
- );
529
- }
530
- if (nodeType === NodeType.Array) {
531
- return /* @__PURE__ */ jsx(
532
- ArrayTextEditor,
533
- {
534
- dictionary,
535
- keyPath,
536
- section
537
- }
538
- );
539
- }
482
+ if (nodeType === NodeType.ReactNode) {
483
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
484
+ /* @__PURE__ */ jsx("span", { children: "[React Node]" }),
485
+ /* @__PURE__ */ jsx("span", { className: "text-neutral dark:text-neutral-dark text-xs", children: tsxNotEditable })
486
+ ] });
487
+ }
488
+ if (nodeType === NodeType.Nested) {
489
+ return /* @__PURE__ */ jsx(
490
+ NestedTextEditor,
491
+ {
492
+ dictionary,
493
+ keyPath,
494
+ section
495
+ }
496
+ );
497
+ }
498
+ if (nodeType === NodeType.Translation) {
499
+ return /* @__PURE__ */ jsx(
500
+ TranslationTextEditor,
501
+ {
502
+ dictionary,
503
+ keyPath,
504
+ section
505
+ }
506
+ );
507
+ }
508
+ if (nodeType === NodeType.Enumeration) {
509
+ return /* @__PURE__ */ jsx(
510
+ EnumerationTextEditor,
511
+ {
512
+ dictionary,
513
+ keyPath,
514
+ section
515
+ }
516
+ );
517
+ }
518
+ if (nodeType === NodeType.Condition) {
519
+ return /* @__PURE__ */ jsx(
520
+ ConditionTextEditor,
521
+ {
522
+ dictionary,
523
+ keyPath,
524
+ section
525
+ }
526
+ );
527
+ }
528
+ if (nodeType === NodeType.Markdown) {
529
+ return /* @__PURE__ */ jsx(
530
+ MarkdownTextEditor,
531
+ {
532
+ dictionary,
533
+ keyPath,
534
+ section,
535
+ isDarkMode
536
+ }
537
+ );
538
+ }
539
+ if (nodeType === NodeType.Array) {
540
+ return /* @__PURE__ */ jsx(
541
+ ArrayTextEditor,
542
+ {
543
+ dictionary,
544
+ keyPath,
545
+ section
546
+ }
547
+ );
548
+ }
549
+ if (nodeType === NodeType.Object) {
550
+ return /* @__PURE__ */ jsx(
551
+ ObjectTextEditor,
552
+ {
553
+ dictionary,
554
+ keyPath,
555
+ section
556
+ }
557
+ );
540
558
  }
541
559
  if (nodeType === NodeType.Number) {
542
560
  return /* @__PURE__ */ jsx("div", { className: "w-full p-2", children: /* @__PURE__ */ jsx(
@@ -574,11 +592,25 @@ const TextEditor = ({
574
592
  }
575
593
  return /* @__PURE__ */ jsxs("div", { className: "w-full p-2", children: [
576
594
  "Error. Format not supported.",
577
- JSON.stringify(section)
595
+ JSON.stringify(section, null, 2),
596
+ JSON.stringify(keyPath, null, 2),
597
+ "NodeType : ",
598
+ nodeType
578
599
  ] });
579
600
  };
601
+ const TextEditorContainer = (props) => /* @__PURE__ */ jsx(
602
+ Container,
603
+ {
604
+ border: true,
605
+ background: "none",
606
+ className: "top-6 flex h-full flex-1 flex-col gap-6 overflow-hidden p-2 md:sticky",
607
+ roundedSize: "xl",
608
+ children: /* @__PURE__ */ jsx(TextEditor, { ...props })
609
+ }
610
+ );
580
611
  export {
581
612
  TextEditor,
613
+ TextEditorContainer,
582
614
  traceKeys
583
615
  };
584
616
  //# sourceMappingURL=TextEditor.mjs.map