@intlayer/design-system 7.5.6 → 7.5.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (246) hide show
  1. package/dist/esm/components/Breadcrumb/index.mjs +28 -2
  2. package/dist/esm/components/Breadcrumb/index.mjs.map +1 -1
  3. package/dist/esm/components/Browser/Browser.mjs +29 -40
  4. package/dist/esm/components/Browser/Browser.mjs.map +1 -1
  5. package/dist/esm/components/Browser/{Browser.content.mjs → browser.content.mjs} +42 -4
  6. package/dist/esm/components/Browser/{Browser.content.mjs.map → browser.content.mjs.map} +1 -1
  7. package/dist/esm/components/Button/Button.mjs +6 -2
  8. package/dist/esm/components/Button/Button.mjs.map +1 -1
  9. package/dist/esm/components/ContentEditor/ContentEditorTextArea.mjs +1 -1
  10. package/dist/esm/components/DictionaryEditor/DictionaryEditor.mjs +9 -19
  11. package/dist/esm/components/DictionaryEditor/DictionaryEditor.mjs.map +1 -1
  12. package/dist/esm/components/DictionaryFieldEditor/ContentEditor.mjs +2 -2
  13. package/dist/esm/components/DictionaryFieldEditor/ContentEditor.mjs.map +1 -1
  14. package/dist/esm/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs +123 -88
  15. package/dist/esm/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs.map +1 -1
  16. package/dist/esm/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs +3 -2
  17. package/dist/esm/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs.map +1 -1
  18. package/dist/esm/components/DictionaryFieldEditor/KeyPathBreadcrumb.mjs +7 -6
  19. package/dist/esm/components/DictionaryFieldEditor/KeyPathBreadcrumb.mjs.map +1 -1
  20. package/dist/esm/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs +28 -6
  21. package/dist/esm/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs.map +1 -1
  22. package/dist/esm/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs +2 -0
  23. package/dist/esm/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs.map +1 -1
  24. package/dist/esm/components/DictionaryFieldEditor/index.mjs +5 -1
  25. package/dist/esm/components/DropDown/index.mjs +19 -4
  26. package/dist/esm/components/DropDown/index.mjs.map +1 -1
  27. package/dist/esm/components/Flags/Flag.mjs +55 -2
  28. package/dist/esm/components/Flags/Flag.mjs.map +1 -1
  29. package/dist/esm/components/Flags/bw.mjs +35 -0
  30. package/dist/esm/components/Flags/bw.mjs.map +1 -0
  31. package/dist/esm/components/Flags/cu.mjs +45 -0
  32. package/dist/esm/components/Flags/cu.mjs.map +1 -0
  33. package/dist/esm/components/Flags/cv.mjs +45 -0
  34. package/dist/esm/components/Flags/cv.mjs.map +1 -0
  35. package/dist/esm/components/Flags/dj.mjs +45 -0
  36. package/dist/esm/components/Flags/dj.mjs.map +1 -0
  37. package/dist/esm/components/Flags/flags.mjs +242 -7
  38. package/dist/esm/components/Flags/flags.mjs.map +1 -1
  39. package/dist/esm/components/Flags/gh.mjs +38 -0
  40. package/dist/esm/components/Flags/gh.mjs.map +1 -0
  41. package/dist/esm/components/Flags/gw.mjs +69 -0
  42. package/dist/esm/components/Flags/gw.mjs.map +1 -0
  43. package/dist/esm/components/Flags/km.mjs +54 -0
  44. package/dist/esm/components/Flags/km.mjs.map +1 -0
  45. package/dist/esm/components/Flags/lk.mjs +75 -0
  46. package/dist/esm/components/Flags/lk.mjs.map +1 -0
  47. package/dist/esm/components/Flags/md.mjs +319 -0
  48. package/dist/esm/components/Flags/md.mjs.map +1 -0
  49. package/dist/esm/components/Flags/mr.mjs +39 -0
  50. package/dist/esm/components/Flags/mr.mjs.map +1 -0
  51. package/dist/esm/components/Flags/mz.mjs +94 -0
  52. package/dist/esm/components/Flags/mz.mjs.map +1 -0
  53. package/dist/esm/components/Flags/ps.mjs +47 -0
  54. package/dist/esm/components/Flags/ps.mjs.map +1 -0
  55. package/dist/esm/components/Flags/sd.mjs +46 -0
  56. package/dist/esm/components/Flags/sd.mjs.map +1 -0
  57. package/dist/esm/components/Flags/so.mjs +39 -0
  58. package/dist/esm/components/Flags/so.mjs.map +1 -0
  59. package/dist/esm/components/Flags/st.mjs +75 -0
  60. package/dist/esm/components/Flags/st.mjs.map +1 -0
  61. package/dist/esm/components/Flags/td.mjs +35 -0
  62. package/dist/esm/components/Flags/td.mjs.map +1 -0
  63. package/dist/esm/components/Flags/tl.mjs +45 -0
  64. package/dist/esm/components/Flags/tl.mjs.map +1 -0
  65. package/dist/esm/components/Flags/tz.mjs +46 -0
  66. package/dist/esm/components/Flags/tz.mjs.map +1 -0
  67. package/dist/esm/components/Flags/ug.mjs +147 -0
  68. package/dist/esm/components/Flags/ug.mjs.map +1 -0
  69. package/dist/esm/components/Form/FormLabel.mjs +1 -1
  70. package/dist/esm/components/Form/elements/AutoSizeTextAreaElement.mjs +1 -1
  71. package/dist/esm/components/Form/elements/EditableFieldTextAreaElement.mjs +1 -1
  72. package/dist/esm/components/Form/elements/MultiselectElement.mjs +1 -1
  73. package/dist/esm/components/Form/elements/OTPElement.mjs +2 -2
  74. package/dist/esm/components/Form/elements/OTPElement.mjs.map +1 -1
  75. package/dist/esm/components/Form/elements/SelectElement.mjs +1 -1
  76. package/dist/esm/components/Form/elements/SwitchSelectorElement.mjs +1 -1
  77. package/dist/esm/components/Form/elements/TextAreaElement.mjs +1 -1
  78. package/dist/esm/components/IDE/CodeFormatSelector.mjs +1 -1
  79. package/dist/esm/components/IDE/ContentDeclarationFormatSelector.mjs +1 -1
  80. package/dist/esm/components/IDE/PackageManagerSelector.mjs +1 -1
  81. package/dist/esm/components/Input/Input.mjs +3 -1
  82. package/dist/esm/components/Input/Input.mjs.map +1 -1
  83. package/dist/esm/components/Input/OTPInput.mjs +2 -2
  84. package/dist/esm/components/Input/OTPInput.mjs.map +1 -1
  85. package/dist/esm/components/Input/SearchInput.mjs +1 -1
  86. package/dist/esm/components/Input/SearchInput.mjs.map +1 -1
  87. package/dist/esm/components/KeyboardShortcut/KeyboardShortcut.mjs +8 -4
  88. package/dist/esm/components/KeyboardShortcut/KeyboardShortcut.mjs.map +1 -1
  89. package/dist/esm/components/Link/Link.mjs +11 -3
  90. package/dist/esm/components/Link/Link.mjs.map +1 -1
  91. package/dist/esm/components/Link/index.mjs +2 -2
  92. package/dist/esm/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.mjs +20 -14
  93. package/dist/esm/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.mjs.map +1 -1
  94. package/dist/esm/components/MarkDownRender/MarkDownRender.mjs +1 -1
  95. package/dist/esm/components/MarkDownRender/MarkDownRender.mjs.map +1 -1
  96. package/dist/esm/components/Modal/Modal.mjs +2 -2
  97. package/dist/esm/components/Modal/Modal.mjs.map +1 -1
  98. package/dist/esm/components/RightDrawer/RightDrawer.mjs +83 -127
  99. package/dist/esm/components/RightDrawer/RightDrawer.mjs.map +1 -1
  100. package/dist/esm/components/RightDrawer/rightDrawer.content.mjs +51 -0
  101. package/dist/esm/components/RightDrawer/rightDrawer.content.mjs.map +1 -0
  102. package/dist/esm/components/Table/Table.mjs +1 -1
  103. package/dist/esm/components/TextArea/AutocompleteTextArea.mjs +2 -29
  104. package/dist/esm/components/TextArea/AutocompleteTextArea.mjs.map +1 -1
  105. package/dist/esm/components/index.mjs +23 -19
  106. package/dist/esm/hooks/index.mjs +2 -2
  107. package/dist/esm/hooks/reactQuery.mjs +32 -3
  108. package/dist/esm/hooks/reactQuery.mjs.map +1 -1
  109. package/dist/esm/hooks/usePersistedStore.mjs +1 -1
  110. package/dist/esm/hooks/usePersistedStore.mjs.map +1 -1
  111. package/dist/types/components/Badge/index.d.ts +2 -2
  112. package/dist/types/components/Breadcrumb/breadcrumb.content.d.ts +3 -3
  113. package/dist/types/components/Breadcrumb/index.d.ts +2 -2
  114. package/dist/types/components/Breadcrumb/index.d.ts.map +1 -1
  115. package/dist/types/components/Browser/Browser.d.ts +2 -2
  116. package/dist/types/components/Browser/Browser.d.ts.map +1 -1
  117. package/dist/types/components/Browser/{Browser.content.d.ts → browser.content.d.ts} +97 -15
  118. package/dist/types/components/Browser/browser.content.d.ts.map +1 -0
  119. package/dist/types/components/Button/Button.d.ts +7 -7
  120. package/dist/types/components/Button/Button.d.ts.map +1 -1
  121. package/dist/types/components/CollapsibleTable/CollapsibleTable.d.ts +4 -4
  122. package/dist/types/components/CollapsibleTable/CollapsibleTable.d.ts.map +1 -1
  123. package/dist/types/components/Command/index.d.ts +16 -16
  124. package/dist/types/components/Command/index.d.ts.map +1 -1
  125. package/dist/types/components/Container/index.d.ts +9 -9
  126. package/dist/types/components/Container/index.d.ts.map +1 -1
  127. package/dist/types/components/CopyButton/CopyButton.content.d.ts +3 -3
  128. package/dist/types/components/CopyButton/CopyButton.content.d.ts.map +1 -1
  129. package/dist/types/components/DictionaryEditor/DictionaryEditor.d.ts +0 -1
  130. package/dist/types/components/DictionaryEditor/DictionaryEditor.d.ts.map +1 -1
  131. package/dist/types/components/DictionaryFieldEditor/ContentEditorView/TextEditor.d.ts.map +1 -1
  132. package/dist/types/components/DictionaryFieldEditor/DictionaryCreationForm/dictionaryCreationForm.content.d.ts +25 -25
  133. package/dist/types/components/DictionaryFieldEditor/DictionaryCreationForm/useDictionaryFormSchema.content.d.ts +9 -9
  134. package/dist/types/components/DictionaryFieldEditor/DictionaryCreationForm/useDictionaryFormSchema.content.d.ts.map +1 -1
  135. package/dist/types/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.d.ts +33 -33
  136. package/dist/types/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.content.d.ts +25 -25
  137. package/dist/types/components/DictionaryFieldEditor/KeyPathBreadcrumb.d.ts +5 -1
  138. package/dist/types/components/DictionaryFieldEditor/KeyPathBreadcrumb.d.ts.map +1 -1
  139. package/dist/types/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.d.ts +25 -25
  140. package/dist/types/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.d.ts.map +1 -1
  141. package/dist/types/components/DictionaryFieldEditor/SaveForm/saveForm.content.d.ts +33 -33
  142. package/dist/types/components/DictionaryFieldEditor/StructureView/structureView.content.d.ts +9 -9
  143. package/dist/types/components/DictionaryFieldEditor/VersionSwitcherDropDown/versionSwitcherDropDown.content.d.ts +7 -7
  144. package/dist/types/components/DictionaryFieldEditor/VersionSwitcherDropDown/versionSwitcherDropDown.content.d.ts.map +1 -1
  145. package/dist/types/components/DictionaryFieldEditor/dictionaryFieldEditor.content.d.ts +5 -5
  146. package/dist/types/components/DictionaryFieldEditor/index.d.ts +5 -1
  147. package/dist/types/components/DictionaryFieldEditor/nodeTypeSelector.content.d.ts +31 -31
  148. package/dist/types/components/DropDown/index.d.ts +16 -2
  149. package/dist/types/components/DropDown/index.d.ts.map +1 -1
  150. package/dist/types/components/ExpandCollapse/expandCollapse.content.d.ts +3 -3
  151. package/dist/types/components/Flags/Flag.d.ts.map +1 -1
  152. package/dist/types/components/Flags/flags.d.ts +169 -7
  153. package/dist/types/components/Flags/flags.d.ts.map +1 -1
  154. package/dist/types/components/Form/FormBase.d.ts +2 -2
  155. package/dist/types/components/Form/FormBase.d.ts.map +1 -1
  156. package/dist/types/components/Form/FormField.d.ts +2 -2
  157. package/dist/types/components/Form/FormField.d.ts.map +1 -1
  158. package/dist/types/components/Form/FormItem.d.ts +2 -2
  159. package/dist/types/components/Form/elements/EditableFieldInputElement.d.ts +2 -2
  160. package/dist/types/components/Form/elements/EditableFieldInputElement.d.ts.map +1 -1
  161. package/dist/types/components/Form/elements/EditableFieldTextAreaElement.d.ts +2 -2
  162. package/dist/types/components/Form/elements/EditableFieldTextAreaElement.d.ts.map +1 -1
  163. package/dist/types/components/Form/elements/FormElement.d.ts +2 -2
  164. package/dist/types/components/Form/elements/FormElement.d.ts.map +1 -1
  165. package/dist/types/components/Form/elements/MultiselectElement.d.ts +2 -2
  166. package/dist/types/components/Form/elements/OTPElement.d.ts +2 -2
  167. package/dist/types/components/Form/elements/OTPElement.d.ts.map +1 -1
  168. package/dist/types/components/Form/elements/SelectElement.d.ts +2 -2
  169. package/dist/types/components/Form/elements/SwitchSelectorElement.d.ts +2 -2
  170. package/dist/types/components/IDE/CodeContext.d.ts +2 -2
  171. package/dist/types/components/IDE/CodeContext.d.ts.map +1 -1
  172. package/dist/types/components/IDE/code.content.d.ts +5 -5
  173. package/dist/types/components/IDE/copyCode.content.d.ts +5 -5
  174. package/dist/types/components/IDE/copyCode.content.d.ts.map +1 -1
  175. package/dist/types/components/IDE/selectors.content.d.ts +7 -7
  176. package/dist/types/components/Input/Checkbox.d.ts +4 -4
  177. package/dist/types/components/Input/Checkbox.d.ts.map +1 -1
  178. package/dist/types/components/Input/Input.d.ts +6 -9
  179. package/dist/types/components/Input/Input.d.ts.map +1 -1
  180. package/dist/types/components/Input/OTPInput.d.ts +6 -6
  181. package/dist/types/components/Input/OTPInput.d.ts.map +1 -1
  182. package/dist/types/components/Input/SearchInput.d.ts +2 -2
  183. package/dist/types/components/Input/SearchInput.d.ts.map +1 -1
  184. package/dist/types/components/Link/Link.d.ts +9 -8
  185. package/dist/types/components/Link/Link.d.ts.map +1 -1
  186. package/dist/types/components/Link/index.d.ts +2 -2
  187. package/dist/types/components/Loader/index.content.d.ts +3 -3
  188. package/dist/types/components/Loader/index.content.d.ts.map +1 -1
  189. package/dist/types/components/Loader/index.d.ts.map +1 -1
  190. package/dist/types/components/Loader/spinner.d.ts +2 -2
  191. package/dist/types/components/Loader/spinner.d.ts.map +1 -1
  192. package/dist/types/components/LocaleSwitcherContentDropDown/localeSwitcher.content.d.ts +17 -17
  193. package/dist/types/components/LocaleSwitcherContentDropDown/localeSwitcher.content.d.ts.map +1 -1
  194. package/dist/types/components/LocaleSwitcherDropDown/localeSwitcher.content.d.ts +13 -13
  195. package/dist/types/components/LocaleSwitcherDropDown/localeSwitcher.content.d.ts.map +1 -1
  196. package/dist/types/components/MarkDownRender/MarkDownRender.d.ts.map +1 -1
  197. package/dist/types/components/MarkDownRender/processor.d.ts.map +1 -1
  198. package/dist/types/components/MaxWidthSmoother/index.d.ts +2 -2
  199. package/dist/types/components/MaxWidthSmoother/index.d.ts.map +1 -1
  200. package/dist/types/components/Modal/Modal.d.ts.map +1 -1
  201. package/dist/types/components/Navbar/Burger.d.ts +2 -2
  202. package/dist/types/components/Navbar/Burger.d.ts.map +1 -1
  203. package/dist/types/components/Navbar/DesktopNavbar.d.ts +2 -2
  204. package/dist/types/components/Navbar/DesktopNavbar.d.ts.map +1 -1
  205. package/dist/types/components/Navbar/MobileNavbar.d.ts +2 -2
  206. package/dist/types/components/Navbar/MobileNavbar.d.ts.map +1 -1
  207. package/dist/types/components/Navbar/index.d.ts +2 -2
  208. package/dist/types/components/Navbar/index.d.ts.map +1 -1
  209. package/dist/types/components/Pagination/Pagination.d.ts +4 -4
  210. package/dist/types/components/Pagination/Pagination.d.ts.map +1 -1
  211. package/dist/types/components/Pagination/pagination.content.d.ts +11 -11
  212. package/dist/types/components/RightDrawer/RightDrawer.d.ts +7 -150
  213. package/dist/types/components/RightDrawer/RightDrawer.d.ts.map +1 -1
  214. package/dist/types/components/RightDrawer/rightDrawer.content.d.ts +93 -0
  215. package/dist/types/components/RightDrawer/rightDrawer.content.d.ts.map +1 -0
  216. package/dist/types/components/RightDrawer/useRightDrawerStore.d.ts +2 -2
  217. package/dist/types/components/Select/Select.d.ts +3 -3
  218. package/dist/types/components/Select/Select.d.ts.map +1 -1
  219. package/dist/types/components/SocialNetworks/index.d.ts +2 -2
  220. package/dist/types/components/SocialNetworks/index.d.ts.map +1 -1
  221. package/dist/types/components/SwitchSelector/index.d.ts +7 -7
  222. package/dist/types/components/SwitchSelector/index.d.ts.map +1 -1
  223. package/dist/types/components/Tab/Tab.d.ts +6 -6
  224. package/dist/types/components/Tab/Tab.d.ts.map +1 -1
  225. package/dist/types/components/Tab/TabContext.d.ts +2 -2
  226. package/dist/types/components/Tab/TabContext.d.ts.map +1 -1
  227. package/dist/types/components/TabSelector/TabSelector.d.ts +5 -5
  228. package/dist/types/components/TabSelector/TabSelector.d.ts.map +1 -1
  229. package/dist/types/components/Table/table.content.d.ts +3 -3
  230. package/dist/types/components/Table/table.content.d.ts.map +1 -1
  231. package/dist/types/components/Tag/index.d.ts +5 -5
  232. package/dist/types/components/Tag/index.d.ts.map +1 -1
  233. package/dist/types/components/Terminal/terminal.content.d.ts +5 -5
  234. package/dist/types/components/Terminal/terminal.content.d.ts.map +1 -1
  235. package/dist/types/components/Toaster/Toast.d.ts +3 -3
  236. package/dist/types/components/Toaster/Toast.d.ts.map +1 -1
  237. package/dist/types/components/Toaster/Toaster.d.ts +2 -2
  238. package/dist/types/components/Toaster/Toaster.d.ts.map +1 -1
  239. package/dist/types/components/index.d.ts +7 -3
  240. package/dist/types/hooks/index.d.ts +2 -2
  241. package/dist/types/hooks/reactQuery.d.ts +2 -1
  242. package/dist/types/hooks/reactQuery.d.ts.map +1 -1
  243. package/dist/types/hooks/useItemSelector.d.ts.map +1 -1
  244. package/dist/types/hooks/useScrollBlockage/useScrollBlockageStore.d.ts +2 -2
  245. package/package.json +14 -14
  246. package/dist/types/components/Browser/Browser.content.d.ts.map +0 -1
@@ -1,39 +1,29 @@
1
1
  'use client';
2
2
 
3
- import { SaveForm } from "../DictionaryFieldEditor/SaveForm/SaveForm.mjs";
4
3
  import { NodeWrapper } from "./NodeWrapper/index.mjs";
5
- import { createElement, useMemo } from "react";
6
- import { jsx, jsxs } from "react/jsx-runtime";
4
+ import { createElement } from "react";
5
+ import { jsx } from "react/jsx-runtime";
7
6
  import { useEditedContent, useFocusUnmergedDictionary } from "@intlayer/editor-react";
8
7
 
9
8
  //#region src/components/DictionaryEditor/DictionaryEditor.tsx
10
- const DictionaryEditor = ({ dictionary, mode, onDelete, ...props }) => {
9
+ const DictionaryEditor = ({ dictionary, ...props }) => {
11
10
  const { editedContent, addEditedContent } = useEditedContent();
12
- const { focusedContent, setFocusedContentKeyPath, setFocusedContent } = useFocusUnmergedDictionary();
13
- const focusedKeyPath = useMemo(() => focusedContent?.keyPath, [focusedContent?.keyPath]);
14
- return /* @__PURE__ */ jsxs("div", {
15
- className: "flex flex-1 flex-col justify-between gap-2",
16
- children: [/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ createElement(NodeWrapper, {
11
+ const { focusedContent, setFocusedContentKeyPath } = useFocusUnmergedDictionary();
12
+ return /* @__PURE__ */ jsx("div", {
13
+ className: "flex flex-col gap-2",
14
+ children: /* @__PURE__ */ createElement(NodeWrapper, {
17
15
  ...props,
18
16
  keyPath: [],
19
17
  dictionary,
20
18
  key: JSON.stringify((editedContent?.[dictionary.localId] ?? dictionary).content),
21
19
  editedContent: editedContent?.[dictionary.localId]?.content,
22
- focusedKeyPath,
20
+ focusedKeyPath: focusedContent?.keyPath,
23
21
  section: dictionary.content,
24
22
  onContentChange: (content) => {
25
23
  addEditedContent(dictionary.localId, content.newValue, content.keyPath);
26
24
  },
27
25
  onFocusKeyPath: setFocusedContentKeyPath
28
- }) }), /* @__PURE__ */ jsx(SaveForm, {
29
- dictionary,
30
- mode,
31
- className: "mb-4 flex-col",
32
- onDelete: () => {
33
- setFocusedContent(null);
34
- onDelete?.();
35
- }
36
- })]
26
+ })
37
27
  });
38
28
  };
39
29
 
@@ -1 +1 @@
1
- {"version":3,"file":"DictionaryEditor.mjs","names":["DictionaryEditor: FC<DictionaryEditorProps>"],"sources":["../../../../src/components/DictionaryEditor/DictionaryEditor.tsx"],"sourcesContent":["'use client';\n\nimport {\n useEditedContent,\n useFocusUnmergedDictionary,\n} from '@intlayer/editor-react';\nimport type { Dictionary, Locale } from '@intlayer/types';\nimport { type FC, useMemo } from 'react';\nimport { SaveForm } from '../DictionaryFieldEditor/SaveForm/SaveForm';\nimport { NodeWrapper } from './NodeWrapper';\n\ntype DictionaryEditorProps = {\n dictionary: Dictionary;\n locale: Locale;\n mode: ('local' | 'remote')[];\n onDelete?: () => void;\n};\n\nexport const DictionaryEditor: FC<DictionaryEditorProps> = ({\n dictionary,\n mode,\n onDelete,\n ...props\n}) => {\n const { editedContent, addEditedContent } = useEditedContent();\n const { focusedContent, setFocusedContentKeyPath, setFocusedContent } =\n useFocusUnmergedDictionary();\n\n const focusedKeyPath = useMemo(\n () => focusedContent?.keyPath,\n [focusedContent?.keyPath]\n );\n\n return (\n <div className=\"flex flex-1 flex-col justify-between gap-2\">\n <div>\n <NodeWrapper\n {...props}\n keyPath={[]}\n dictionary={dictionary}\n key={JSON.stringify(\n (editedContent?.[dictionary.localId!] ?? dictionary).content\n )}\n editedContent={editedContent?.[dictionary.localId!]?.content}\n focusedKeyPath={focusedKeyPath}\n section={dictionary.content}\n onContentChange={(content) => {\n addEditedContent(\n dictionary.localId!,\n content.newValue,\n content.keyPath\n );\n }}\n onFocusKeyPath={setFocusedContentKeyPath}\n />\n </div>\n <SaveForm\n dictionary={dictionary}\n mode={mode}\n className=\"mb-4 flex-col\"\n onDelete={() => {\n setFocusedContent(null);\n onDelete?.();\n }}\n />\n </div>\n );\n};\n"],"mappings":";;;;;;;;;AAkBA,MAAaA,oBAA+C,EAC1D,YACA,MACA,UACA,GAAG,YACC;CACJ,MAAM,EAAE,eAAe,qBAAqB,kBAAkB;CAC9D,MAAM,EAAE,gBAAgB,0BAA0B,sBAChD,4BAA4B;CAE9B,MAAM,iBAAiB,cACf,gBAAgB,SACtB,CAAC,gBAAgB,QAAQ,CAC1B;AAED,QACE,qBAAC;EAAI,WAAU;aACb,oBAAC,mBACC,8BAAC;GACC,GAAI;GACJ,SAAS,EAAE;GACC;GACZ,KAAK,KAAK,WACP,gBAAgB,WAAW,YAAa,YAAY,QACtD;GACD,eAAe,gBAAgB,WAAW,UAAW;GACrC;GAChB,SAAS,WAAW;GACpB,kBAAkB,YAAY;AAC5B,qBACE,WAAW,SACX,QAAQ,UACR,QAAQ,QACT;;GAEH,gBAAgB;IAChB,GACE,EACN,oBAAC;GACa;GACN;GACN,WAAU;GACV,gBAAgB;AACd,sBAAkB,KAAK;AACvB,gBAAY;;IAEd;GACE"}
1
+ {"version":3,"file":"DictionaryEditor.mjs","names":["DictionaryEditor: FC<DictionaryEditorProps>"],"sources":["../../../../src/components/DictionaryEditor/DictionaryEditor.tsx"],"sourcesContent":["'use client';\n\nimport {\n useEditedContent,\n useFocusUnmergedDictionary,\n} from '@intlayer/editor-react';\nimport type { Dictionary, Locale } from '@intlayer/types';\nimport type { FC } from 'react';\nimport { NodeWrapper } from './NodeWrapper';\n\ntype DictionaryEditorProps = {\n dictionary: Dictionary;\n locale: Locale;\n onDelete?: () => void;\n};\n\nexport const DictionaryEditor: FC<DictionaryEditorProps> = ({\n dictionary,\n ...props\n}) => {\n const { editedContent, addEditedContent } = useEditedContent();\n const { focusedContent, setFocusedContentKeyPath } =\n useFocusUnmergedDictionary();\n\n return (\n <div className=\"flex flex-col gap-2\">\n <NodeWrapper\n {...props}\n keyPath={[]}\n dictionary={dictionary}\n key={JSON.stringify(\n (editedContent?.[dictionary.localId!] ?? dictionary).content\n )}\n editedContent={editedContent?.[dictionary.localId!]?.content}\n focusedKeyPath={focusedContent?.keyPath}\n section={dictionary.content}\n onContentChange={(content) => {\n addEditedContent(\n dictionary.localId!,\n content.newValue,\n content.keyPath\n );\n }}\n onFocusKeyPath={setFocusedContentKeyPath}\n />\n </div>\n );\n};\n"],"mappings":";;;;;;;;AAgBA,MAAaA,oBAA+C,EAC1D,YACA,GAAG,YACC;CACJ,MAAM,EAAE,eAAe,qBAAqB,kBAAkB;CAC9D,MAAM,EAAE,gBAAgB,6BACtB,4BAA4B;AAE9B,QACE,oBAAC;EAAI,WAAU;YACb,8BAAC;GACC,GAAI;GACJ,SAAS,EAAE;GACC;GACZ,KAAK,KAAK,WACP,gBAAgB,WAAW,YAAa,YAAY,QACtD;GACD,eAAe,gBAAgB,WAAW,UAAW;GACrD,gBAAgB,gBAAgB;GAChC,SAAS,WAAW;GACpB,kBAAkB,YAAY;AAC5B,qBACE,WAAW,SACX,QAAQ,UACR,QAAQ,QACT;;GAEH,gBAAgB;IAChB;GACE"}
@@ -36,11 +36,11 @@ const ContentEditor = ({ dictionary, isDarkMode }) => {
36
36
  children: /* @__PURE__ */ jsx(LocaleSwitcherContent, {})
37
37
  })]
38
38
  }), /* @__PURE__ */ jsxs("div", {
39
- className: "flex gap-2 max-md:flex-col",
39
+ className: "flex flex-1 gap-2 overflow-visible max-md:flex-col",
40
40
  children: [typeof section === "object" && section && !isEditableBaseSection && Object.keys(section).length > 0 && /* @__PURE__ */ jsx(Container, {
41
41
  border: true,
42
42
  background: "none",
43
- className: "top-6 flex h-full flex-col items-start gap-0.5 overflow-auto p-2 md:sticky md:max-w-[50%]",
43
+ className: "top-30 flex h-full flex-col items-start gap-0.5 overflow-auto p-2 md:sticky md:max-w-[50%]",
44
44
  roundedSize: "xl",
45
45
  transparency: "sm",
46
46
  children: /* @__PURE__ */ jsx(NavigationViewNode, {
@@ -1 +1 @@
1
- {"version":3,"file":"ContentEditor.mjs","names":["ContentEditor: FC<NodeEditorProps>"],"sources":["../../../../src/components/DictionaryFieldEditor/ContentEditor.tsx"],"sourcesContent":["'use client';\n\nimport { getContentNodeByKeyPath } from '@intlayer/core';\nimport {\n useEditedContent,\n useEditorLocale,\n useFocusUnmergedDictionary,\n} from '@intlayer/editor-react';\nimport type { Dictionary, LocalDictionaryId } from '@intlayer/types';\nimport { type FC, useEffect } from 'react';\nimport { Container } from '../Container';\nimport { LocaleSwitcherContent } from '../LocaleSwitcherContentDropDown';\nimport { TextEditorContainer } from './ContentEditorView/TextEditor';\nimport { getIsEditableSection } from './getIsEditableSection';\nimport { KeyPathBreadcrumb } from './KeyPathBreadcrumb';\nimport { NavigationViewNode } from './NavigationView/NavigationViewNode';\n\ntype NodeEditorProps = {\n dictionary: Dictionary;\n isDarkMode?: boolean;\n};\n\nexport const ContentEditor: FC<NodeEditorProps> = ({\n dictionary,\n isDarkMode,\n}) => {\n const { content, key, localId } = dictionary;\n const { editedContent } = useEditedContent();\n const { focusedContent, setFocusedContentKeyPath } =\n useFocusUnmergedDictionary();\n\n const focusedKeyPath = focusedContent?.keyPath;\n const section =\n typeof editedContent?.[localId as LocalDictionaryId]?.content ===\n 'undefined'\n ? content\n : editedContent?.[localId as LocalDictionaryId]?.content;\n\n const currentLocale = useEditorLocale();\n const focusedSection = getContentNodeByKeyPath(\n section,\n focusedKeyPath ?? [],\n currentLocale\n );\n const isEditableBaseSection = getIsEditableSection(section);\n const isEditableFocusedSection = getIsEditableSection(focusedSection);\n\n useEffect(() => {\n if (typeof focusedSection === 'undefined') {\n setFocusedContentKeyPath(focusedContent?.keyPath?.slice(0, -1) ?? []);\n }\n }, []);\n\n return (\n <div>\n <div className=\"mb-6 flex items-center justify-between gap-2\">\n <KeyPathBreadcrumb\n dictionaryKey={key}\n keyPath={focusedKeyPath ?? []}\n onClickKeyPath={setFocusedContentKeyPath}\n />\n <div className=\"flex items-center gap-2\">\n <LocaleSwitcherContent />\n </div>\n </div>\n <div className=\"flex gap-2 max-md:flex-col\">\n {typeof section === 'object' &&\n section &&\n !isEditableBaseSection &&\n Object.keys(section).length > 0 && (\n <Container\n border\n background=\"none\"\n className=\"top-6 flex h-full flex-col items-start gap-0.5 overflow-auto p-2 md:sticky md:max-w-[50%]\"\n roundedSize=\"xl\"\n transparency=\"sm\"\n >\n <NavigationViewNode\n keyPath={[]}\n section={section}\n dictionary={dictionary}\n />\n </Container>\n )}\n {(isEditableFocusedSection || (focusedKeyPath ?? []).length > 0) && (\n <TextEditorContainer\n keyPath={focusedKeyPath ?? []}\n section={focusedSection}\n dictionary={dictionary}\n isDarkMode={isDarkMode}\n />\n )}\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;AAsBA,MAAaA,iBAAsC,EACjD,YACA,iBACI;CACJ,MAAM,EAAE,SAAS,KAAK,YAAY;CAClC,MAAM,EAAE,kBAAkB,kBAAkB;CAC5C,MAAM,EAAE,gBAAgB,6BACtB,4BAA4B;CAE9B,MAAM,iBAAiB,gBAAgB;CACvC,MAAM,UACJ,OAAO,gBAAgB,UAA+B,YACtD,cACI,UACA,gBAAgB,UAA+B;CAErD,MAAM,gBAAgB,iBAAiB;CACvC,MAAM,iBAAiB,wBACrB,SACA,kBAAkB,EAAE,EACpB,cACD;CACD,MAAM,wBAAwB,qBAAqB,QAAQ;CAC3D,MAAM,2BAA2B,qBAAqB,eAAe;AAErE,iBAAgB;AACd,MAAI,OAAO,mBAAmB,YAC5B,0BAAyB,gBAAgB,SAAS,MAAM,GAAG,GAAG,IAAI,EAAE,CAAC;IAEtE,EAAE,CAAC;AAEN,QACE,qBAAC,oBACC,qBAAC;EAAI,WAAU;aACb,oBAAC;GACC,eAAe;GACf,SAAS,kBAAkB,EAAE;GAC7B,gBAAgB;IAChB,EACF,oBAAC;GAAI,WAAU;aACb,oBAAC,0BAAwB;IACrB;GACF,EACN,qBAAC;EAAI,WAAU;aACZ,OAAO,YAAY,YAClB,WACA,CAAC,yBACD,OAAO,KAAK,QAAQ,CAAC,SAAS,KAC5B,oBAAC;GACC;GACA,YAAW;GACX,WAAU;GACV,aAAY;GACZ,cAAa;aAEb,oBAAC;IACC,SAAS,EAAE;IACF;IACG;KACZ;IACQ,GAEd,6BAA6B,kBAAkB,EAAE,EAAE,SAAS,MAC5D,oBAAC;GACC,SAAS,kBAAkB,EAAE;GAC7B,SAAS;GACG;GACA;IACZ;GAEA,IACF"}
1
+ {"version":3,"file":"ContentEditor.mjs","names":["ContentEditor: FC<NodeEditorProps>"],"sources":["../../../../src/components/DictionaryFieldEditor/ContentEditor.tsx"],"sourcesContent":["'use client';\n\nimport { getContentNodeByKeyPath } from '@intlayer/core';\nimport {\n useEditedContent,\n useEditorLocale,\n useFocusUnmergedDictionary,\n} from '@intlayer/editor-react';\nimport type { Dictionary, LocalDictionaryId } from '@intlayer/types';\nimport { type FC, useEffect } from 'react';\nimport { Container } from '../Container';\nimport { LocaleSwitcherContent } from '../LocaleSwitcherContentDropDown';\nimport { TextEditorContainer } from './ContentEditorView/TextEditor';\nimport { getIsEditableSection } from './getIsEditableSection';\nimport { KeyPathBreadcrumb } from './KeyPathBreadcrumb';\nimport { NavigationViewNode } from './NavigationView/NavigationViewNode';\n\ntype NodeEditorProps = {\n dictionary: Dictionary;\n isDarkMode?: boolean;\n};\n\nexport const ContentEditor: FC<NodeEditorProps> = ({\n dictionary,\n isDarkMode,\n}) => {\n const { content, key, localId } = dictionary;\n const { editedContent } = useEditedContent();\n const { focusedContent, setFocusedContentKeyPath } =\n useFocusUnmergedDictionary();\n\n const focusedKeyPath = focusedContent?.keyPath;\n const section =\n typeof editedContent?.[localId as LocalDictionaryId]?.content ===\n 'undefined'\n ? content\n : editedContent?.[localId as LocalDictionaryId]?.content;\n\n const currentLocale = useEditorLocale();\n const focusedSection = getContentNodeByKeyPath(\n section,\n focusedKeyPath ?? [],\n currentLocale\n );\n const isEditableBaseSection = getIsEditableSection(section);\n const isEditableFocusedSection = getIsEditableSection(focusedSection);\n\n useEffect(() => {\n if (typeof focusedSection === 'undefined') {\n setFocusedContentKeyPath(focusedContent?.keyPath?.slice(0, -1) ?? []);\n }\n }, []);\n\n return (\n <div>\n <div className=\"mb-6 flex items-center justify-between gap-2\">\n <KeyPathBreadcrumb\n dictionaryKey={key}\n keyPath={focusedKeyPath ?? []}\n onClickKeyPath={setFocusedContentKeyPath}\n />\n <div className=\"flex items-center gap-2\">\n <LocaleSwitcherContent />\n </div>\n </div>\n <div className=\"flex flex-1 gap-2 overflow-visible max-md:flex-col\">\n {typeof section === 'object' &&\n section &&\n !isEditableBaseSection &&\n Object.keys(section).length > 0 && (\n <Container\n border\n background=\"none\"\n className=\"top-30 flex h-full flex-col items-start gap-0.5 overflow-auto p-2 md:sticky md:max-w-[50%]\"\n roundedSize=\"xl\"\n transparency=\"sm\"\n >\n <NavigationViewNode\n keyPath={[]}\n section={section}\n dictionary={dictionary}\n />\n </Container>\n )}\n {(isEditableFocusedSection || (focusedKeyPath ?? []).length > 0) && (\n <TextEditorContainer\n keyPath={focusedKeyPath ?? []}\n section={focusedSection}\n dictionary={dictionary}\n isDarkMode={isDarkMode}\n />\n )}\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;AAsBA,MAAaA,iBAAsC,EACjD,YACA,iBACI;CACJ,MAAM,EAAE,SAAS,KAAK,YAAY;CAClC,MAAM,EAAE,kBAAkB,kBAAkB;CAC5C,MAAM,EAAE,gBAAgB,6BACtB,4BAA4B;CAE9B,MAAM,iBAAiB,gBAAgB;CACvC,MAAM,UACJ,OAAO,gBAAgB,UAA+B,YACtD,cACI,UACA,gBAAgB,UAA+B;CAErD,MAAM,gBAAgB,iBAAiB;CACvC,MAAM,iBAAiB,wBACrB,SACA,kBAAkB,EAAE,EACpB,cACD;CACD,MAAM,wBAAwB,qBAAqB,QAAQ;CAC3D,MAAM,2BAA2B,qBAAqB,eAAe;AAErE,iBAAgB;AACd,MAAI,OAAO,mBAAmB,YAC5B,0BAAyB,gBAAgB,SAAS,MAAM,GAAG,GAAG,IAAI,EAAE,CAAC;IAEtE,EAAE,CAAC;AAEN,QACE,qBAAC,oBACC,qBAAC;EAAI,WAAU;aACb,oBAAC;GACC,eAAe;GACf,SAAS,kBAAkB,EAAE;GAC7B,gBAAgB;IAChB,EACF,oBAAC;GAAI,WAAU;aACb,oBAAC,0BAAwB;IACrB;GACF,EACN,qBAAC;EAAI,WAAU;aACZ,OAAO,YAAY,YAClB,WACA,CAAC,yBACD,OAAO,KAAK,QAAQ,CAAC,SAAS,KAC5B,oBAAC;GACC;GACA,YAAW;GACX,WAAU;GACV,aAAY;GACZ,cAAa;aAEb,oBAAC;IACC,SAAS,EAAE;IACF;IACG;KACZ;IACQ,GAEd,6BAA6B,kBAAkB,EAAE,EAAE,SAAS,MAC5D,oBAAC;GACC,SAAS,kBAAkB,EAAE;GAC7B,SAAS;GACG;GACA;IACZ;GAEA,IACF"}
@@ -2,14 +2,14 @@
2
2
 
3
3
  import { Container } from "../../Container/index.mjs";
4
4
  import { Button, ButtonColor, ButtonSize, ButtonTextAlign, ButtonVariant } from "../../Button/Button.mjs";
5
- import { useAuditContentDeclarationField } from "../../../hooks/reactQuery.mjs";
6
5
  import { InputVariant } from "../../Input/Input.mjs";
7
- import { Label } from "../../Label/index.mjs";
6
+ import { useAuditContentDeclarationField } from "../../../hooks/reactQuery.mjs";
8
7
  import { SwitchSelector, SwitchSelectorColor, SwitchSelectorSize } from "../../SwitchSelector/index.mjs";
9
8
  import { useLocaleSwitcherContent } from "../../LocaleSwitcherContentDropDown/LocaleSwitcherContentContext.mjs";
10
9
  import { renameKey } from "../../../utils/object.mjs";
11
10
  import { ContentEditorInput as ContentEditorInput$1 } from "../../ContentEditor/ContentEditorInput.mjs";
12
11
  import { ContentEditorTextArea as ContentEditorTextArea$1 } from "../../ContentEditor/ContentEditorTextArea.mjs";
12
+ import { Label } from "../../Label/index.mjs";
13
13
  import { MarkdownRenderer } from "../../MarkDownRender/MarkDownRender.mjs";
14
14
  import { EnumKeyInput } from "../EnumKeyInput.mjs";
15
15
  import { Plus, Trash, WandSparkles } from "lucide-react";
@@ -108,13 +108,13 @@ const TranslationTextEditor = ({ section, keyPath, dictionary, renderSection })
108
108
  children: localesList.map((translationKey) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("tr", {
109
109
  className: "mt-2 w-full p-2 text-xs",
110
110
  children: /* @__PURE__ */ jsx("td", {
111
- className: "w-full",
111
+ className: "flex w-full",
112
112
  children: getLocaleName(translationKey, locale)
113
113
  })
114
114
  }), /* @__PURE__ */ jsx("tr", {
115
115
  className: "flex",
116
116
  children: /* @__PURE__ */ jsx("td", {
117
- className: "w-full",
117
+ className: "flex w-full",
118
118
  children: /* @__PURE__ */ jsx(TextEditorContainer, {
119
119
  section: content[translationKey] ?? getEmptyNode(content[defaultLocale]),
120
120
  keyPath: [...keyPath, {
@@ -141,45 +141,59 @@ const EnumerationTextEditor = ({ section, keyPath, dictionary, renderSection })
141
141
  children: /* @__PURE__ */ jsx("tbody", {
142
142
  className: "flex w-full flex-col gap-2",
143
143
  children: Object.keys(section[NodeType.Enumeration]).map((enumKey) => {
144
- const childrenKeyPath = [...keyPath, { type: NodeType.Enumeration }];
144
+ const childrenKeyPath = [...keyPath, {
145
+ type: NodeType.Enumeration,
146
+ key: enumKey
147
+ }];
145
148
  return /* @__PURE__ */ jsxs(Fragment, { children: [
146
149
  /* @__PURE__ */ jsx("tr", {
147
150
  className: "mt-2 w-full",
148
- children: /* @__PURE__ */ jsx("div", {
149
- className: "flex flex-1",
150
- children: /* @__PURE__ */ jsx(Button, {
151
- label: removeEnumeration.label.value,
152
- variant: ButtonVariant.HOVERABLE,
153
- color: ButtonColor.TEXT,
154
- Icon: Trash,
155
- className: "ml-auto",
156
- onClick: () => addEditedContent(dictionary.localId, void 0, childrenKeyPath),
157
- children: removeEnumeration.text
151
+ children: /* @__PURE__ */ jsx("td", {
152
+ className: "flex w-full",
153
+ children: /* @__PURE__ */ jsx("div", {
154
+ className: "flex flex-1",
155
+ children: /* @__PURE__ */ jsx(Button, {
156
+ label: removeEnumeration.label.value,
157
+ variant: "hoverable",
158
+ size: "sm",
159
+ color: "error",
160
+ className: "ml-auto text-neutral hover:text-error",
161
+ Icon: Trash,
162
+ onClick: () => addEditedContent(dictionary.localId, void 0, childrenKeyPath),
163
+ children: removeEnumeration.text
164
+ })
158
165
  })
159
166
  })
160
167
  }),
161
168
  /* @__PURE__ */ jsx("tr", {
162
169
  className: "w-full p-2",
163
- children: /* @__PURE__ */ jsx(EnumKeyInput, {
164
- value: enumKey,
165
- onChange: (value) => {
166
- const preValueContent = section[NodeType.Enumeration];
167
- const newValueContent = renameKey(preValueContent, enumKey, value);
168
- const newValue = {
169
- ...section,
170
- [NodeType.Enumeration]: newValueContent
171
- };
172
- addEditedContent(dictionary.localId, newValue, keyPath);
173
- }
170
+ children: /* @__PURE__ */ jsx("td", {
171
+ className: "flex w-full",
172
+ children: /* @__PURE__ */ jsx(EnumKeyInput, {
173
+ value: enumKey,
174
+ onChange: (value) => {
175
+ const preValueContent = section[NodeType.Enumeration];
176
+ const newValueContent = renameKey(preValueContent, enumKey, value);
177
+ const newValue = {
178
+ ...section,
179
+ [NodeType.Enumeration]: newValueContent
180
+ };
181
+ console.log("newValue", newValue);
182
+ addEditedContent(dictionary.localId, newValue, keyPath);
183
+ }
184
+ })
174
185
  })
175
186
  }),
176
187
  /* @__PURE__ */ jsx("tr", {
177
188
  className: "block w-full",
178
- children: /* @__PURE__ */ jsx(TextEditor, {
179
- section: content[enumKey] ?? getEmptyNode(content[firstKey]),
180
- keyPath: childrenKeyPath,
181
- dictionary,
182
- renderSection
189
+ children: /* @__PURE__ */ jsx("td", {
190
+ className: "flex w-full",
191
+ children: /* @__PURE__ */ jsx(TextEditor, {
192
+ section: content[enumKey] ?? getEmptyNode(content[firstKey]),
193
+ keyPath: childrenKeyPath,
194
+ dictionary,
195
+ renderSection
196
+ })
183
197
  })
184
198
  })
185
199
  ] }, enumKey);
@@ -214,19 +228,22 @@ const ConditionTextEditor = ({ section, keyPath, dictionary, renderSection }) =>
214
228
  ].map((condKey) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("tr", {
215
229
  className: "mt-2 block w-full p-2 text-xs",
216
230
  children: /* @__PURE__ */ jsx("td", {
217
- className: "w-full",
231
+ className: "flex w-full",
218
232
  children: String(condKey)
219
233
  })
220
234
  }, condKey), /* @__PURE__ */ jsx("tr", {
221
235
  className: "block w-full",
222
- children: /* @__PURE__ */ jsx(TextEditorContainer, {
223
- section: content[condKey] ?? getEmptyNode(content.true),
224
- keyPath: [...keyPath, {
225
- type: NodeType.Condition,
226
- key: condKey
227
- }],
228
- dictionary,
229
- renderSection
236
+ children: /* @__PURE__ */ jsx("td", {
237
+ className: "flex w-full",
238
+ children: /* @__PURE__ */ jsx(TextEditorContainer, {
239
+ section: content[condKey] ?? getEmptyNode(content.true),
240
+ keyPath: [...keyPath, {
241
+ type: NodeType.Condition,
242
+ key: condKey
243
+ }],
244
+ dictionary,
245
+ renderSection
246
+ })
230
247
  })
231
248
  }, condKey)] }, condKey))
232
249
  })
@@ -245,19 +262,22 @@ const GenderTextEditor = ({ section, keyPath, dictionary, renderSection }) => {
245
262
  ].map((condKey) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("tr", {
246
263
  className: "mt-2 block w-full p-2 text-xs",
247
264
  children: /* @__PURE__ */ jsx("td", {
248
- className: "w-full",
265
+ className: "flex w-full",
249
266
  children: String(condKey)
250
267
  })
251
268
  }, condKey), /* @__PURE__ */ jsx("tr", {
252
269
  className: "block w-full",
253
- children: /* @__PURE__ */ jsx(TextEditorContainer, {
254
- section: content[condKey] ?? getEmptyNode(content.male),
255
- keyPath: [...keyPath, {
256
- type: NodeType.Gender,
257
- key: condKey
258
- }],
259
- dictionary,
260
- renderSection
270
+ children: /* @__PURE__ */ jsx("td", {
271
+ className: "flex w-full",
272
+ children: /* @__PURE__ */ jsx(TextEditorContainer, {
273
+ section: content[condKey] ?? getEmptyNode(content.male),
274
+ keyPath: [...keyPath, {
275
+ type: NodeType.Gender,
276
+ key: condKey
277
+ }],
278
+ dictionary,
279
+ renderSection
280
+ })
261
281
  })
262
282
  }, condKey)] }, condKey))
263
283
  })
@@ -272,37 +292,46 @@ const ArrayTextEditor = ({ section, keyPath, dictionary, renderSection }) => {
272
292
  className: "w-full",
273
293
  children: /* @__PURE__ */ jsx("tbody", {
274
294
  className: "flex w-full flex-col gap-2",
275
- children: section.map((subSection, index) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("tr", {
276
- className: "mt-2 flex w-full items-center justify-between gap-2 p-2",
277
- children: [/* @__PURE__ */ jsx("span", {
278
- className: "text-xs",
279
- children: String(index)
280
- }), /* @__PURE__ */ jsx(Button, {
281
- label: removeElement.label.value,
282
- variant: ButtonVariant.HOVERABLE,
283
- color: ButtonColor.NEUTRAL,
284
- className: "ml-auto",
285
- textAlign: ButtonTextAlign.LEFT,
286
- onClick: () => {
287
- const newKeyPath = [...keyPath, {
288
- type: NodeType.Array,
289
- key: section.length
290
- }];
291
- addEditedContent(dictionary.localId, void 0, newKeyPath);
292
- },
293
- Icon: Trash,
294
- children: removeElement.text
295
- })]
295
+ children: section.map((subSection, index) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("tr", {
296
+ className: "mt-2 w-full p-2",
297
+ children: /* @__PURE__ */ jsx("td", {
298
+ className: "flex w-full",
299
+ children: /* @__PURE__ */ jsxs("div", {
300
+ className: "flex w-full items-center justify-between gap-2",
301
+ children: [/* @__PURE__ */ jsx("span", {
302
+ className: "text-xs",
303
+ children: String(index)
304
+ }), /* @__PURE__ */ jsx(Button, {
305
+ label: removeElement.label.value,
306
+ variant: "hoverable",
307
+ size: "sm",
308
+ color: "error",
309
+ className: "ml-auto text-neutral hover:text-error",
310
+ onClick: () => {
311
+ const newKeyPath = [...keyPath, {
312
+ type: NodeType.Array,
313
+ key: index
314
+ }];
315
+ addEditedContent(dictionary.localId, void 0, newKeyPath);
316
+ },
317
+ Icon: Trash,
318
+ children: removeElement.text
319
+ })]
320
+ })
321
+ })
296
322
  }), /* @__PURE__ */ jsx("tr", {
297
323
  className: "block w-full",
298
- children: /* @__PURE__ */ jsx(TextEditorContainer, {
299
- section: subSection ?? getEmptyNode(section[0]),
300
- keyPath: [...keyPath, {
301
- type: NodeType.Array,
302
- key: index
303
- }],
304
- dictionary,
305
- renderSection
324
+ children: /* @__PURE__ */ jsx("td", {
325
+ className: "flex w-full",
326
+ children: /* @__PURE__ */ jsx(TextEditorContainer, {
327
+ section: subSection ?? getEmptyNode(section[0]),
328
+ keyPath: [...keyPath, {
329
+ type: NodeType.Array,
330
+ key: index
331
+ }],
332
+ dictionary,
333
+ renderSection
334
+ })
306
335
  })
307
336
  })] }, JSON.stringify(subSection)))
308
337
  })
@@ -339,16 +368,19 @@ const ObjectTextEditor = ({ section, keyPath, dictionary, renderSection }) => /*
339
368
  return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("tr", {
340
369
  className: "mt-2 p-2 text-xs",
341
370
  children: /* @__PURE__ */ jsx("td", {
342
- className: "w-full",
371
+ className: "flex w-full",
343
372
  children: String(key)
344
373
  })
345
374
  }, JSON.stringify(subSection)), /* @__PURE__ */ jsx("tr", {
346
375
  className: "block w-full",
347
- children: /* @__PURE__ */ jsx(TextEditor, {
348
- section: subSection,
349
- keyPath: childKeyPath,
350
- dictionary,
351
- renderSection
376
+ children: /* @__PURE__ */ jsx("td", {
377
+ className: "flex w-full",
378
+ children: /* @__PURE__ */ jsx(TextEditor, {
379
+ section: subSection,
380
+ keyPath: childKeyPath,
381
+ dictionary,
382
+ renderSection
383
+ })
352
384
  })
353
385
  }, JSON.stringify(subSection))] }, key);
354
386
  })
@@ -459,10 +491,13 @@ const NestedTextEditor = ({ keyPath, dictionary, renderSection, section, ...prop
459
491
  const TextEditor = ({ section, keyPath, dictionary, renderSection, isDarkMode }) => {
460
492
  const { tsxNotEditable } = useIntlayer("navigation-view");
461
493
  const nodeType = getNodeType(section);
462
- if (nodeType === NodeType.ReactNode) return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", { children: "[React Node]" }), /* @__PURE__ */ jsx("span", {
463
- className: "text-neutral text-xs",
464
- children: tsxNotEditable
465
- })] });
494
+ if (nodeType === NodeType.ReactNode) return /* @__PURE__ */ jsxs("div", {
495
+ className: "flex w-full flex-col gap-2",
496
+ children: [/* @__PURE__ */ jsx("span", { children: "(React Node)" }), /* @__PURE__ */ jsx("span", {
497
+ className: "flex text-neutral text-xs",
498
+ children: tsxNotEditable
499
+ })]
500
+ });
466
501
  if (nodeType === NodeType.Nested) return /* @__PURE__ */ jsx(NestedTextEditor, {
467
502
  dictionary,
468
503
  renderSection,
@@ -1 +1 @@
1
- {"version":3,"file":"TextEditor.mjs","names":["traceKeys: string[]","ContentEditorTextArea: FC<ContentEditorTextAreaProps>","ContentEditorTextAreaBase","editedContent","ContentEditorInput: FC<ContentEditorInputProps>","ContentEditorInputBase","ContentEditorToggle: FC<ContentEditorToggleProps>","TranslationTextEditor: FC<TextEditorProps>","content: any","EnumerationTextEditor: FC<TextEditorProps>","ConditionTextEditor: FC<TextEditorProps>","GenderTextEditor: FC<TextEditorProps>","ArrayTextEditor: FC<TextEditorProps>","newKeyPath: KeyPath[]","ObjectTextEditor: FC<TextEditorProps>","childKeyPath: KeyPath[]","MarkdownTextEditor: FC<TextEditorProps>","toggleContent","content","InsertionTextEditor: FC<TextEditorProps>","FileTextEditor: FC<TextEditorProps>","NestedTextEditor: FC<TextEditorProps>","TextEditor: FC<TextEditorProps>","TextEditorContainer: FC<TextEditorProps>"],"sources":["../../../../../src/components/DictionaryFieldEditor/ContentEditorView/TextEditor.tsx"],"sourcesContent":["'use client';\n\nimport {\n type ConditionContent,\n type EnumerationContent,\n type FileContent,\n type GenderContent,\n getEmptyNode,\n getLocaleName,\n getNodeType,\n type InsertionContent,\n type MarkdownContent,\n type TranslationContent,\n} from '@intlayer/core';\nimport { useConfiguration, useEditedContent } from '@intlayer/editor-react';\nimport {\n type ContentNode,\n type Dictionary,\n type KeyPath,\n type Locale,\n type LocalesValues,\n NodeType,\n} from '@intlayer/types';\nimport { Plus, Trash, WandSparkles } from 'lucide-react';\nimport { type FC, Fragment, type ReactNode, useState } from 'react';\nimport { useIntlayer, useLocale } from 'react-intlayer';\nimport { useAuditContentDeclarationField } from '../../../hooks';\nimport { renameKey } from '../../../utils/object';\nimport {\n Button,\n ButtonColor,\n ButtonSize,\n ButtonTextAlign,\n ButtonVariant,\n} from '../../Button';\nimport { Container } from '../../Container';\nimport {\n ContentEditorInput as ContentEditorInputBase,\n type ContentEditorInputProps as ContentEditorInputPropsBase,\n} from '../../ContentEditor/ContentEditorInput';\nimport {\n ContentEditorTextArea as ContentEditorTextAreaBase,\n type ContentEditorTextAreaProps as ContentEditorTextAreaPropsBase,\n} from '../../ContentEditor/ContentEditorTextArea';\nimport { InputVariant } from '../../Input';\nimport { Label } from '../../Label';\nimport { useLocaleSwitcherContent } from '../../LocaleSwitcherContentDropDown';\nimport { MarkdownRenderer } from '../../MarkDownRender';\nimport {\n SwitchSelector,\n type SwitchSelectorChoices,\n SwitchSelectorColor,\n type SwitchSelectorProps,\n SwitchSelectorSize,\n} from '../../SwitchSelector';\nimport { EnumKeyInput } from '../EnumKeyInput';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\ntype ContentEditorTextAreaProps = Omit<\n ContentEditorTextAreaPropsBase,\n 'onContentChange'\n> & {\n keyPath: KeyPath[];\n dictionary: Dictionary;\n};\n\nconst ContentEditorTextArea: FC<ContentEditorTextAreaProps> = ({\n keyPath,\n dictionary,\n ...props\n}) => {\n const { editedContent, addEditedContent } = useEditedContent();\n const configuration = useConfiguration();\n const { mutate: auditContentDeclarationField, isPending: isAuditing } =\n useAuditContentDeclarationField();\n\n return (\n <ContentEditorTextAreaBase\n variant={InputVariant.DEFAULT}\n onContentChange={(newValue) =>\n addEditedContent(dictionary.localId!, newValue, keyPath)\n }\n additionalButtons={\n <Button\n Icon={WandSparkles}\n label=\"Audit\"\n variant={ButtonVariant.HOVERABLE}\n size={ButtonSize.ICON_SM}\n color={ButtonColor.TEXT}\n className=\"cursor-pointer hover:scale-110\"\n isLoading={isAuditing}\n onClick={() => {\n auditContentDeclarationField(\n {\n fileContent: JSON.stringify({\n ...dictionary,\n ...(editedContent?.[dictionary.localId!] ?? {}),\n }),\n keyPath,\n locales: configuration.internationalization.locales ?? [],\n aiOptions: {\n apiKey: configuration.ai?.apiKey,\n model: configuration.ai?.model,\n temperature: configuration.ai?.temperature,\n },\n },\n {\n onSuccess: (response) => {\n if (!response?.data) return;\n\n try {\n const editedContent = response.data.fileContent as string;\n\n addEditedContent(\n dictionary.localId!,\n editedContent,\n keyPath\n );\n } catch (error) {\n console.error(error);\n }\n },\n }\n );\n }}\n />\n }\n {...props}\n />\n );\n};\n\ntype ContentEditorInputProps = Omit<\n ContentEditorInputPropsBase,\n 'onContentChange'\n> & {\n keyPath: KeyPath[];\n dictionary: Dictionary;\n};\n\nconst ContentEditorInput: FC<ContentEditorInputProps> = ({\n keyPath,\n dictionary,\n ...props\n}) => {\n const { addEditedContent } = useEditedContent();\n\n return (\n <ContentEditorInputBase\n variant={InputVariant.DEFAULT}\n onContentChange={(newValue) =>\n addEditedContent(dictionary.localId!, newValue, keyPath)\n }\n {...props}\n />\n );\n};\n\nconst toggleContent = [\n {\n content: 'False',\n value: false,\n },\n {\n content: 'True',\n value: true,\n },\n] as SwitchSelectorChoices<boolean>;\n\ntype ContentEditorToggleProps = SwitchSelectorProps & {\n dictionary: Dictionary;\n keyPath: KeyPath[];\n};\n\nconst ContentEditorToggle: FC<ContentEditorToggleProps> = ({\n dictionary,\n keyPath,\n ...props\n}) => {\n const { addEditedContent } = useEditedContent();\n\n return (\n <SwitchSelector\n choices={toggleContent}\n value={true}\n onChange={(value) =>\n addEditedContent(dictionary.localId!, value, keyPath)\n }\n color={SwitchSelectorColor.TEXT}\n size={SwitchSelectorSize.SM}\n {...props}\n />\n );\n};\n\nexport type TextEditorProps = {\n dictionary: Dictionary;\n keyPath: KeyPath[];\n section: ContentNode;\n isDarkMode?: boolean;\n renderSection?: (content: string) => ReactNode;\n onContentChange?: (newValue: string) => void;\n};\n\nconst TranslationTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}: TextEditorProps) => {\n const { locale, defaultLocale } = useLocale();\n const { selectedLocales, availableLocales } = useLocaleSwitcherContent();\n\n const sectionContent = (section as TranslationContent<string>)[\n NodeType.Translation\n ] as Record<Locale, string>;\n\n const sectionContentKeys = Object.keys(sectionContent) as LocalesValues[];\n\n const isFiltered = availableLocales.length > selectedLocales.length;\n\n const localesList = isFiltered\n ? selectedLocales\n : // If the translation include content in other locales, we display all of them\n [...new Set([...availableLocales, ...sectionContentKeys])];\n\n const content: any = (section as TranslationContent<string>)[\n NodeType.Translation\n ];\n\n return (\n <table className=\"w-full\">\n <tbody className=\"flex w-full flex-col gap-2\">\n {localesList.map((translationKey) => (\n <Fragment key={translationKey}>\n <tr className=\"mt-2 w-full p-2 text-xs\">\n <td className=\"w-full\">\n {getLocaleName(translationKey, locale)}\n </td>\n </tr>\n <tr className=\"flex\">\n <td className=\"w-full\">\n <TextEditorContainer\n section={\n content[translationKey] ??\n getEmptyNode(content[defaultLocale])\n }\n keyPath={[\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ]}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </td>\n </tr>\n </Fragment>\n ))}\n </tbody>\n </table>\n );\n};\n\nconst EnumerationTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}) => {\n const { addEditedContent } = useEditedContent();\n const { addNewEnumeration, removeEnumeration } =\n useIntlayer('navigation-view');\n\n const content = (section as EnumerationContent<string>)[NodeType.Enumeration];\n const firstKey = Object.keys(content)[0] as keyof typeof content;\n\n return (\n <div className=\"flex flex-col gap-2\">\n <table className=\"w-full\">\n <tbody className=\"flex w-full flex-col gap-2\">\n {Object.keys(\n (section as EnumerationContent<ContentNode>)[NodeType.Enumeration]\n ).map((enumKey) => {\n const childrenKeyPath = [\n ...keyPath,\n { type: NodeType.Enumeration },\n ] as KeyPath[];\n return (\n <Fragment key={enumKey}>\n <tr className=\"mt-2 w-full\">\n <div className=\"flex flex-1\">\n <Button\n label={removeEnumeration.label.value}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.TEXT}\n Icon={Trash}\n className=\"ml-auto\"\n onClick={() =>\n addEditedContent(\n dictionary.localId!,\n undefined,\n childrenKeyPath\n )\n }\n >\n {removeEnumeration.text}\n </Button>\n </div>\n </tr>\n <tr className=\"w-full p-2\">\n <EnumKeyInput\n value={enumKey}\n onChange={(value) => {\n const preValueContent = (\n section as EnumerationContent<string>\n )[NodeType.Enumeration];\n const newValueContent = renameKey(\n preValueContent,\n enumKey as keyof typeof preValueContent,\n value\n );\n const newValue = {\n ...(section as EnumerationContent<string>),\n [NodeType.Enumeration]: newValueContent,\n };\n\n addEditedContent(dictionary.localId!, newValue, keyPath);\n }}\n />\n </tr>\n <tr className=\"block w-full\">\n <TextEditor\n section={\n content[enumKey as keyof typeof content] ??\n getEmptyNode(content[firstKey])\n }\n keyPath={childrenKeyPath}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </tr>\n </Fragment>\n );\n })}\n </tbody>\n </table>\n\n <Button\n label={addNewEnumeration.label.value}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.NEUTRAL}\n textAlign={ButtonTextAlign.LEFT}\n isFullWidth\n onClick={() =>\n addEditedContent(\n dictionary.localId!,\n getEmptyNode(content[firstKey]) ?? '',\n [...keyPath, { type: NodeType.Enumeration, key: 'unknown' }]\n )\n }\n Icon={Plus}\n className=\"m-2\"\n >\n {addNewEnumeration.text}\n </Button>\n </div>\n );\n};\n\nconst ConditionTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}) => {\n const content = (section as ConditionContent<string>)[NodeType.Condition];\n\n return (\n <table className=\"w-full\">\n <tbody className=\"flex w-full flex-col gap-2\">\n {['true', 'false', 'fallback'].map((condKey) => (\n <Fragment key={condKey}>\n <tr key={condKey} className=\"mt-2 block w-full p-2 text-xs\">\n <td className=\"w-full\">{String(condKey)}</td>\n </tr>\n <tr key={condKey} className=\"block w-full\">\n <TextEditorContainer\n section={\n content[condKey as keyof typeof content] ??\n getEmptyNode(content.true)\n }\n keyPath={[\n ...keyPath,\n {\n type: NodeType.Condition,\n key: condKey,\n } as KeyPath,\n ]}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </tr>\n </Fragment>\n ))}\n </tbody>\n </table>\n );\n};\n\nconst GenderTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}) => {\n const content = (section as GenderContent<string>)[NodeType.Gender];\n\n return (\n <table className=\"w-full\">\n <tbody className=\"flex w-full flex-col gap-2\">\n {['male', 'female', 'fallback'].map((condKey) => (\n <Fragment key={condKey}>\n <tr key={condKey} className=\"mt-2 block w-full p-2 text-xs\">\n <td className=\"w-full\">{String(condKey)}</td>\n </tr>\n <tr key={condKey} className=\"block w-full\">\n <TextEditorContainer\n section={\n content[condKey as keyof typeof content] ??\n getEmptyNode(content.male)\n }\n keyPath={[\n ...keyPath,\n {\n type: NodeType.Gender,\n key: condKey,\n } as KeyPath,\n ]}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </tr>\n </Fragment>\n ))}\n </tbody>\n </table>\n );\n};\n\nconst ArrayTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}) => {\n const { addEditedContent } = useEditedContent();\n const { addNewElement, removeElement } = useIntlayer('navigation-view');\n\n return (\n <div className=\"flex flex-col gap-2\">\n <table className=\"w-full\">\n <tbody className=\"flex w-full flex-col gap-2\">\n {(section as unknown as ContentNode[]).map((subSection, index) => (\n <Fragment key={JSON.stringify(subSection)}>\n <tr className=\"mt-2 flex w-full items-center justify-between gap-2 p-2\">\n <span className=\"text-xs\">{String(index)}</span>\n <Button\n label={removeElement.label.value}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.NEUTRAL}\n className=\"ml-auto\"\n textAlign={ButtonTextAlign.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 addEditedContent(\n dictionary.localId!,\n undefined,\n newKeyPath\n );\n }}\n Icon={Trash}\n >\n {removeElement.text}\n </Button>\n </tr>\n\n <tr className=\"block w-full\">\n <TextEditorContainer\n section={\n subSection ??\n getEmptyNode((section as unknown as ContentNode[])[0])\n }\n keyPath={[\n ...keyPath,\n {\n type: NodeType.Array,\n key: index,\n },\n ]}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </tr>\n </Fragment>\n ))}\n </tbody>\n </table>\n <Button\n label={addNewElement.label.value}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.NEUTRAL}\n textAlign={ButtonTextAlign.LEFT}\n isFullWidth\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as unknown as ContentNode[]).length,\n },\n ];\n addEditedContent(\n dictionary.localId!,\n getEmptyNode((section as unknown as ContentNode[])[0]) ?? '',\n newKeyPath,\n false\n );\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n};\n\nconst ObjectTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}) => (\n <>\n <table className=\"w-full\">\n <tbody className=\"flex flex-col gap-2\">\n {Object.keys(section as unknown as Record<string, ContentNode>).map(\n (key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key },\n ];\n const typedSection = section as unknown as Record<\n string,\n ContentNode\n >;\n const firstKey = Object.keys(\n typedSection\n )[0] as keyof typeof section;\n const subSection =\n typedSection[key as keyof typeof section] ??\n getEmptyNode(typedSection[firstKey]);\n\n return (\n <Fragment key={key}>\n <tr\n key={JSON.stringify(subSection)}\n className=\"mt-2 p-2 text-xs\"\n >\n <td className=\"w-full\">{String(key)}</td>\n </tr>\n <tr key={JSON.stringify(subSection)} className=\"block w-full\">\n <TextEditor\n section={subSection}\n keyPath={childKeyPath}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </tr>\n </Fragment>\n );\n }\n )}\n </tbody>\n </table>\n </>\n);\n\nenum MarkdownViewMode {\n Edit,\n Preview,\n}\n\nconst MarkdownTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n isDarkMode,\n}) => {\n const [mode, setMode] = useState(MarkdownViewMode.Edit);\n const toggleContent = [\n {\n content: 'Edit',\n value: MarkdownViewMode.Edit,\n },\n {\n content: 'Preview',\n value: MarkdownViewMode.Preview,\n },\n ] as SwitchSelectorChoices<MarkdownViewMode>;\n const childKeyPath: KeyPath[] = [...keyPath, { type: NodeType.Markdown }];\n\n const content = (section as MarkdownContent<ContentNode>)[\n NodeType.Markdown\n ] as ContentNode;\n\n return (\n <div className=\"flex w-full flex-col justify-center gap-6 p-2\">\n <SwitchSelector\n choices={toggleContent}\n value={mode}\n onChange={setMode}\n color={SwitchSelectorColor.TEXT}\n size={SwitchSelectorSize.SM}\n className=\"ml-auto\"\n />\n\n <TextEditorContainer\n section={content}\n keyPath={childKeyPath}\n dictionary={dictionary}\n renderSection={\n mode === MarkdownViewMode.Preview\n ? (content) => (\n <MarkdownRenderer isDarkMode={isDarkMode}>\n {content}\n </MarkdownRenderer>\n )\n : undefined\n }\n />\n </div>\n );\n};\n\nconst InsertionTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n ...props\n}) => {\n const childKeyPath: KeyPath[] = [...keyPath, { type: NodeType.Insertion }];\n\n const content = (section as InsertionContent<ContentNode>)[\n NodeType.Insertion\n ];\n\n return (\n <div className=\"flex w-full flex-col justify-center gap-6 p-2\">\n <TextEditorContainer\n section={content}\n keyPath={childKeyPath}\n {...props}\n />\n </div>\n );\n};\n\nconst FileTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n ...props\n}) => {\n const childKeyPath: KeyPath[] = [...keyPath, { type: NodeType.File }];\n\n const fileUrl = (section as FileContent)[NodeType.File];\n const { content } = section as FileContent;\n\n return (\n <div className=\"flex w-full flex-col justify-center gap-6 p-2\">\n <span className=\"text-neutral text-sm\">{fileUrl} </span>\n <TextEditorContainer\n section={content}\n keyPath={childKeyPath}\n {...props}\n />\n </div>\n );\n};\n\nconst NestedTextEditor: FC<TextEditorProps> = ({\n keyPath,\n dictionary,\n renderSection,\n section,\n ...props\n}) => {\n const { addEditedContent } = useEditedContent();\n\n const content = (section as any)[NodeType.Nested];\n const childrenKeyPath = [...keyPath, { type: NodeType.Nested }] as KeyPath[];\n\n return (\n <div className=\"flex w-full flex-col gap-4 p-2\">\n <Label>Dictionary key</Label>\n <ContentEditorInputBase\n aria-label=\"Edit field\"\n type=\"text\"\n variant={InputVariant.DEFAULT}\n {...props}\n onContentChange={(newValue) => {\n addEditedContent(\n dictionary.localId!,\n {\n ...content,\n dictionaryKey: String(newValue),\n },\n childrenKeyPath\n );\n }}\n >\n {content.dictionaryKey ?? ''}\n </ContentEditorInputBase>\n\n <Label>Path (optional)</Label>\n <ContentEditorInputBase\n aria-label=\"Edit field\"\n type=\"text\"\n variant={InputVariant.DEFAULT}\n {...props}\n onContentChange={(newValue) => {\n addEditedContent(\n dictionary.localId!,\n {\n ...content,\n path: newValue !== '' ? newValue : undefined,\n },\n childrenKeyPath\n );\n }}\n >\n {content.path ?? ''}\n </ContentEditorInputBase>\n </div>\n );\n};\n\nexport const TextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n isDarkMode,\n}) => {\n const { tsxNotEditable } = useIntlayer('navigation-view');\n const nodeType = getNodeType(section);\n\n if (nodeType === NodeType.ReactNode) {\n return (\n <>\n <span>[React Node]</span>\n <span className=\"text-neutral text-xs\">{tsxNotEditable}</span>\n </>\n );\n }\n\n if (nodeType === NodeType.Nested) {\n return (\n <NestedTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <TranslationTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <EnumerationTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Condition) {\n return (\n <ConditionTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Gender) {\n return (\n <GenderTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Insertion) {\n return (\n <InsertionTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Markdown) {\n return (\n <MarkdownTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n isDarkMode={isDarkMode}\n />\n );\n }\n\n if (nodeType === NodeType.File) {\n return (\n <FileTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <ArrayTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Object) {\n return (\n <ObjectTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Number) {\n return (\n <div className=\"w-full p-2\">\n <ContentEditorInput\n dictionary={dictionary}\n keyPath={keyPath}\n type=\"number\"\n aria-label=\"Edit field\"\n >\n {section as number}\n </ContentEditorInput>\n </div>\n );\n }\n\n if (nodeType === NodeType.Text) {\n return (\n <div className=\"w-full p-2\">\n {typeof renderSection === 'function' ? (\n renderSection(section as string)\n ) : (\n <ContentEditorTextArea\n variant={InputVariant.DEFAULT}\n aria-label=\"Edit field\"\n keyPath={keyPath}\n dictionary={dictionary}\n >\n {section as string}\n </ContentEditorTextArea>\n )}\n </div>\n );\n }\n\n if (nodeType === NodeType.Boolean) {\n return (\n <div className=\"w-full p-2\">\n <ContentEditorToggle\n dictionary={dictionary}\n keyPath={keyPath}\n value={section as boolean}\n />\n </div>\n );\n }\n\n return (\n <div className=\"w-full p-2\">\n Error. Format not supported.\n {JSON.stringify(section, null, 2)}\n {JSON.stringify(keyPath, null, 2)}\n NodeType : {nodeType}\n </div>\n );\n};\n\nexport const TextEditorContainer: FC<TextEditorProps> = (props) => (\n <Container\n border\n background=\"none\"\n className=\"top-6 flex h-full flex-1 flex-col gap-6 overflow-hidden p-2 md:sticky\"\n roundedSize=\"xl\"\n >\n <TextEditor {...props} />\n </Container>\n);\n"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A;GACT;AAIN,KAAI,aAAa,SAAS,SACxB,QACE,oBAAC;EACa;EACH;EACA;EACG;GACZ;AAIN,KAAI,aAAa,SAAS,KACxB,QACE,oBAAC;EACa;EACG;EACN;EACA;GACT;AAIN,KAAI,aAAa,SAAS,MACxB,QACE,oBAAC;EACa;EACG;EACN;EACA;GACT;AAIN,KAAI,aAAa,SAAS,OACxB,QACE,oBAAC;EACa;EACG;EACN;EACA;GACT;AAIN,KAAI,aAAa,SAAS,OACxB,QACE,oBAAC;EAAI,WAAU;YACb,oBAAC;GACa;GACH;GACT,MAAK;GACL,cAAW;aAEV;IACkB;GACjB;AAIV,KAAI,aAAa,SAAS,KACxB,QACE,oBAAC;EAAI,WAAU;YACZ,OAAO,kBAAkB,aACxB,cAAc,QAAkB,GAEhC,oBAAC;GACC,SAAS,aAAa;GACtB,cAAW;GACF;GACG;aAEX;IACqB;GAEtB;AAIV,KAAI,aAAa,SAAS,QACxB,QACE,oBAAC;EAAI,WAAU;YACb,oBAAC;GACa;GACH;GACT,OAAO;IACP;GACE;AAIV,QACE,qBAAC;EAAI,WAAU;;GAAa;GAEzB,KAAK,UAAU,SAAS,MAAM,EAAE;GAChC,KAAK,UAAU,SAAS,MAAM,EAAE;GAAC;GACtB;;GACR;;AAIV,MAAaC,uBAA4C,UACvD,oBAAC;CACC;CACA,YAAW;CACX,WAAU;CACV,aAAY;WAEZ,oBAAC,cAAW,GAAI,QAAS;EACf"}
1
+ {"version":3,"file":"TextEditor.mjs","names":["traceKeys: string[]","ContentEditorTextArea: FC<ContentEditorTextAreaProps>","ContentEditorTextAreaBase","editedContent","ContentEditorInput: FC<ContentEditorInputProps>","ContentEditorInputBase","ContentEditorToggle: FC<ContentEditorToggleProps>","TranslationTextEditor: FC<TextEditorProps>","content: any","EnumerationTextEditor: FC<TextEditorProps>","ConditionTextEditor: FC<TextEditorProps>","GenderTextEditor: FC<TextEditorProps>","ArrayTextEditor: FC<TextEditorProps>","newKeyPath: KeyPath[]","ObjectTextEditor: FC<TextEditorProps>","childKeyPath: KeyPath[]","MarkdownTextEditor: FC<TextEditorProps>","toggleContent","content","InsertionTextEditor: FC<TextEditorProps>","FileTextEditor: FC<TextEditorProps>","NestedTextEditor: FC<TextEditorProps>","TextEditor: FC<TextEditorProps>","TextEditorContainer: FC<TextEditorProps>"],"sources":["../../../../../src/components/DictionaryFieldEditor/ContentEditorView/TextEditor.tsx"],"sourcesContent":["'use client';\n\nimport {\n type ConditionContent,\n type EnumerationContent,\n type FileContent,\n type GenderContent,\n getEmptyNode,\n getLocaleName,\n getNodeType,\n type InsertionContent,\n type MarkdownContent,\n type TranslationContent,\n} from '@intlayer/core';\nimport { useConfiguration, useEditedContent } from '@intlayer/editor-react';\nimport {\n type ContentNode,\n type Dictionary,\n type KeyPath,\n type Locale,\n type LocalesValues,\n NodeType,\n} from '@intlayer/types';\nimport { Plus, Trash, WandSparkles } from 'lucide-react';\nimport { type FC, Fragment, type ReactNode, useState } from 'react';\nimport { useIntlayer, useLocale } from 'react-intlayer';\nimport { useAuditContentDeclarationField } from '../../../hooks';\nimport { renameKey } from '../../../utils/object';\nimport {\n Button,\n ButtonColor,\n ButtonSize,\n ButtonTextAlign,\n ButtonVariant,\n} from '../../Button';\nimport { Container } from '../../Container';\nimport {\n ContentEditorInput as ContentEditorInputBase,\n type ContentEditorInputProps as ContentEditorInputPropsBase,\n} from '../../ContentEditor/ContentEditorInput';\nimport {\n ContentEditorTextArea as ContentEditorTextAreaBase,\n type ContentEditorTextAreaProps as ContentEditorTextAreaPropsBase,\n} from '../../ContentEditor/ContentEditorTextArea';\nimport { InputVariant } from '../../Input';\nimport { Label } from '../../Label';\nimport { useLocaleSwitcherContent } from '../../LocaleSwitcherContentDropDown';\nimport { MarkdownRenderer } from '../../MarkDownRender';\nimport {\n SwitchSelector,\n type SwitchSelectorChoices,\n SwitchSelectorColor,\n type SwitchSelectorProps,\n SwitchSelectorSize,\n} from '../../SwitchSelector';\nimport { EnumKeyInput } from '../EnumKeyInput';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\ntype ContentEditorTextAreaProps = Omit<\n ContentEditorTextAreaPropsBase,\n 'onContentChange'\n> & {\n keyPath: KeyPath[];\n dictionary: Dictionary;\n};\n\nconst ContentEditorTextArea: FC<ContentEditorTextAreaProps> = ({\n keyPath,\n dictionary,\n ...props\n}) => {\n const { editedContent, addEditedContent } = useEditedContent();\n const configuration = useConfiguration();\n const { mutate: auditContentDeclarationField, isPending: isAuditing } =\n useAuditContentDeclarationField();\n\n return (\n <ContentEditorTextAreaBase\n variant={InputVariant.DEFAULT}\n onContentChange={(newValue) =>\n addEditedContent(dictionary.localId!, newValue, keyPath)\n }\n additionalButtons={\n <Button\n Icon={WandSparkles}\n label=\"Audit\"\n variant={ButtonVariant.HOVERABLE}\n size={ButtonSize.ICON_SM}\n color={ButtonColor.TEXT}\n className=\"cursor-pointer hover:scale-110\"\n isLoading={isAuditing}\n onClick={() => {\n auditContentDeclarationField(\n {\n fileContent: JSON.stringify({\n ...dictionary,\n ...(editedContent?.[dictionary.localId!] ?? {}),\n }),\n keyPath,\n locales: configuration.internationalization.locales ?? [],\n aiOptions: {\n apiKey: configuration.ai?.apiKey,\n model: configuration.ai?.model,\n temperature: configuration.ai?.temperature,\n },\n },\n {\n onSuccess: (response) => {\n if (!response?.data) return;\n\n try {\n const editedContent = response.data.fileContent as string;\n\n addEditedContent(\n dictionary.localId!,\n editedContent,\n keyPath\n );\n } catch (error) {\n console.error(error);\n }\n },\n }\n );\n }}\n />\n }\n {...props}\n />\n );\n};\n\ntype ContentEditorInputProps = Omit<\n ContentEditorInputPropsBase,\n 'onContentChange'\n> & {\n keyPath: KeyPath[];\n dictionary: Dictionary;\n};\n\nconst ContentEditorInput: FC<ContentEditorInputProps> = ({\n keyPath,\n dictionary,\n ...props\n}) => {\n const { addEditedContent } = useEditedContent();\n\n return (\n <ContentEditorInputBase\n variant={InputVariant.DEFAULT}\n onContentChange={(newValue) =>\n addEditedContent(dictionary.localId!, newValue, keyPath)\n }\n {...props}\n />\n );\n};\n\nconst toggleContent = [\n {\n content: 'False',\n value: false,\n },\n {\n content: 'True',\n value: true,\n },\n] as SwitchSelectorChoices<boolean>;\n\ntype ContentEditorToggleProps = SwitchSelectorProps & {\n dictionary: Dictionary;\n keyPath: KeyPath[];\n};\n\nconst ContentEditorToggle: FC<ContentEditorToggleProps> = ({\n dictionary,\n keyPath,\n ...props\n}) => {\n const { addEditedContent } = useEditedContent();\n\n return (\n <SwitchSelector\n choices={toggleContent}\n value={true}\n onChange={(value) =>\n addEditedContent(dictionary.localId!, value, keyPath)\n }\n color={SwitchSelectorColor.TEXT}\n size={SwitchSelectorSize.SM}\n {...props}\n />\n );\n};\n\nexport type TextEditorProps = {\n dictionary: Dictionary;\n keyPath: KeyPath[];\n section: ContentNode;\n isDarkMode?: boolean;\n renderSection?: (content: string) => ReactNode;\n onContentChange?: (newValue: string) => void;\n};\n\nconst TranslationTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}: TextEditorProps) => {\n const { locale, defaultLocale } = useLocale();\n const { selectedLocales, availableLocales } = useLocaleSwitcherContent();\n\n const sectionContent = (section as TranslationContent<string>)[\n NodeType.Translation\n ] as Record<Locale, string>;\n\n const sectionContentKeys = Object.keys(sectionContent) as LocalesValues[];\n\n const isFiltered = availableLocales.length > selectedLocales.length;\n\n const localesList = isFiltered\n ? selectedLocales\n : // If the translation include content in other locales, we display all of them\n [...new Set([...availableLocales, ...sectionContentKeys])];\n\n const content: any = (section as TranslationContent<string>)[\n NodeType.Translation\n ];\n\n return (\n <table className=\"w-full\">\n <tbody className=\"flex w-full flex-col gap-2\">\n {localesList.map((translationKey) => (\n <Fragment key={translationKey}>\n <tr className=\"mt-2 w-full p-2 text-xs\">\n <td className=\"flex w-full\">\n {getLocaleName(translationKey, locale)}\n </td>\n </tr>\n <tr className=\"flex\">\n <td className=\"flex w-full\">\n <TextEditorContainer\n section={\n content[translationKey] ??\n getEmptyNode(content[defaultLocale])\n }\n keyPath={[\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ]}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </td>\n </tr>\n </Fragment>\n ))}\n </tbody>\n </table>\n );\n};\n\nconst EnumerationTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}) => {\n const { addEditedContent } = useEditedContent();\n const { addNewEnumeration, removeEnumeration } =\n useIntlayer('navigation-view');\n\n const content = (section as EnumerationContent<string>)[NodeType.Enumeration];\n const firstKey = Object.keys(content)[0] as keyof typeof content;\n\n return (\n <div className=\"flex flex-col gap-2\">\n <table className=\"w-full\">\n <tbody className=\"flex w-full flex-col gap-2\">\n {Object.keys(\n (section as EnumerationContent<ContentNode>)[NodeType.Enumeration]\n ).map((enumKey) => {\n const childrenKeyPath = [\n ...keyPath,\n { type: NodeType.Enumeration, key: enumKey },\n ] as KeyPath[];\n\n return (\n <Fragment key={enumKey}>\n <tr className=\"mt-2 w-full\">\n <td className=\"flex w-full\">\n <div className=\"flex flex-1\">\n <Button\n label={removeEnumeration.label.value}\n variant=\"hoverable\"\n size=\"sm\"\n color=\"error\"\n className=\"ml-auto text-neutral hover:text-error\"\n Icon={Trash}\n onClick={() =>\n addEditedContent(\n dictionary.localId!,\n undefined,\n childrenKeyPath\n )\n }\n >\n {removeEnumeration.text}\n </Button>\n </div>\n </td>\n </tr>\n <tr className=\"w-full p-2\">\n <td className=\"flex w-full\">\n <EnumKeyInput\n value={enumKey}\n onChange={(value) => {\n const preValueContent = (\n section as EnumerationContent<string>\n )[NodeType.Enumeration];\n\n const newValueContent = renameKey(\n preValueContent,\n enumKey as keyof typeof preValueContent,\n value\n );\n const newValue = {\n ...(section as EnumerationContent<string>),\n [NodeType.Enumeration]: newValueContent,\n };\n\n console.log('newValue', newValue);\n\n addEditedContent(\n dictionary.localId!,\n newValue,\n keyPath\n );\n }}\n />\n </td>\n </tr>\n <tr className=\"block w-full\">\n <td className=\"flex w-full\">\n <TextEditor\n section={\n content[enumKey as keyof typeof content] ??\n getEmptyNode(content[firstKey])\n }\n keyPath={childrenKeyPath}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </td>\n </tr>\n </Fragment>\n );\n })}\n </tbody>\n </table>\n\n <Button\n label={addNewEnumeration.label.value}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.NEUTRAL}\n textAlign={ButtonTextAlign.LEFT}\n isFullWidth\n onClick={() =>\n addEditedContent(\n dictionary.localId!,\n getEmptyNode(content[firstKey]) ?? '',\n [...keyPath, { type: NodeType.Enumeration, key: 'unknown' }]\n )\n }\n Icon={Plus}\n className=\"m-2\"\n >\n {addNewEnumeration.text}\n </Button>\n </div>\n );\n};\n\nconst ConditionTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}) => {\n const content = (section as ConditionContent<string>)[NodeType.Condition];\n\n return (\n <table className=\"w-full\">\n <tbody className=\"flex w-full flex-col gap-2\">\n {['true', 'false', 'fallback'].map((condKey) => (\n <Fragment key={condKey}>\n <tr key={condKey} className=\"mt-2 block w-full p-2 text-xs\">\n <td className=\"flex w-full\">{String(condKey)}</td>\n </tr>\n <tr key={condKey} className=\"block w-full\">\n <td className=\"flex w-full\">\n <TextEditorContainer\n section={\n content[condKey as keyof typeof content] ??\n getEmptyNode(content.true)\n }\n keyPath={[\n ...keyPath,\n {\n type: NodeType.Condition,\n key: condKey,\n } as KeyPath,\n ]}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </td>\n </tr>\n </Fragment>\n ))}\n </tbody>\n </table>\n );\n};\n\nconst GenderTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}) => {\n const content = (section as GenderContent<string>)[NodeType.Gender];\n\n return (\n <table className=\"w-full\">\n <tbody className=\"flex w-full flex-col gap-2\">\n {['male', 'female', 'fallback'].map((condKey) => (\n <Fragment key={condKey}>\n <tr key={condKey} className=\"mt-2 block w-full p-2 text-xs\">\n <td className=\"flex w-full\">{String(condKey)}</td>\n </tr>\n <tr key={condKey} className=\"block w-full\">\n <td className=\"flex w-full\">\n <TextEditorContainer\n section={\n content[condKey as keyof typeof content] ??\n getEmptyNode(content.male)\n }\n keyPath={[\n ...keyPath,\n {\n type: NodeType.Gender,\n key: condKey,\n } as KeyPath,\n ]}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </td>\n </tr>\n </Fragment>\n ))}\n </tbody>\n </table>\n );\n};\n\nconst ArrayTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}) => {\n const { addEditedContent } = useEditedContent();\n const { addNewElement, removeElement } = useIntlayer('navigation-view');\n\n return (\n <div className=\"flex flex-col gap-2\">\n <table className=\"w-full\">\n <tbody className=\"flex w-full flex-col gap-2\">\n {(section as unknown as ContentNode[]).map((subSection, index) => (\n <Fragment key={JSON.stringify(subSection)}>\n <tr className=\"mt-2 w-full p-2\">\n <td className=\"flex w-full\">\n <div className=\"flex w-full items-center justify-between gap-2\">\n <span className=\"text-xs\">{String(index)}</span>\n <Button\n label={removeElement.label.value}\n variant=\"hoverable\"\n size=\"sm\"\n color=\"error\"\n className=\"ml-auto text-neutral hover:text-error\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: index, // Fixed: Use index instead of length\n },\n ];\n addEditedContent(\n dictionary.localId!,\n undefined,\n newKeyPath\n );\n }}\n Icon={Trash}\n >\n {removeElement.text}\n </Button>\n </div>\n </td>\n </tr>\n\n <tr className=\"block w-full\">\n <td className=\"flex w-full\">\n <TextEditorContainer\n section={\n subSection ??\n getEmptyNode((section as unknown as ContentNode[])[0])\n }\n keyPath={[\n ...keyPath,\n {\n type: NodeType.Array,\n key: index,\n },\n ]}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </td>\n </tr>\n </Fragment>\n ))}\n </tbody>\n </table>\n <Button\n label={addNewElement.label.value}\n variant={ButtonVariant.HOVERABLE}\n color={ButtonColor.NEUTRAL}\n textAlign={ButtonTextAlign.LEFT}\n isFullWidth\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as unknown as ContentNode[]).length, // Keeps length for adding new items\n },\n ];\n addEditedContent(\n dictionary.localId!,\n getEmptyNode((section as unknown as ContentNode[])[0]) ?? '',\n newKeyPath,\n false\n );\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </div>\n );\n};\n\nconst ObjectTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n}) => (\n <>\n <table className=\"w-full\">\n <tbody className=\"flex flex-col gap-2\">\n {Object.keys(section as unknown as Record<string, ContentNode>).map(\n (key) => {\n const childKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Object, key },\n ];\n const typedSection = section as unknown as Record<\n string,\n ContentNode\n >;\n const firstKey = Object.keys(\n typedSection\n )[0] as keyof typeof section;\n const subSection =\n typedSection[key as keyof typeof section] ??\n getEmptyNode(typedSection[firstKey]);\n\n return (\n <Fragment key={key}>\n <tr\n key={JSON.stringify(subSection)}\n className=\"mt-2 p-2 text-xs\"\n >\n <td className=\"flex w-full\">{String(key)}</td>\n </tr>\n <tr key={JSON.stringify(subSection)} className=\"block w-full\">\n <td className=\"flex w-full\">\n <TextEditor\n section={subSection}\n keyPath={childKeyPath}\n dictionary={dictionary}\n renderSection={renderSection}\n />\n </td>\n </tr>\n </Fragment>\n );\n }\n )}\n </tbody>\n </table>\n </>\n);\n\nenum MarkdownViewMode {\n Edit,\n Preview,\n}\n\nconst MarkdownTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n isDarkMode,\n}) => {\n const [mode, setMode] = useState(MarkdownViewMode.Edit);\n const toggleContent = [\n {\n content: 'Edit',\n value: MarkdownViewMode.Edit,\n },\n {\n content: 'Preview',\n value: MarkdownViewMode.Preview,\n },\n ] as SwitchSelectorChoices<MarkdownViewMode>;\n const childKeyPath: KeyPath[] = [...keyPath, { type: NodeType.Markdown }];\n\n const content = (section as MarkdownContent<ContentNode>)[\n NodeType.Markdown\n ] as ContentNode;\n\n return (\n <div className=\"flex w-full flex-col justify-center gap-6 p-2\">\n <SwitchSelector\n choices={toggleContent}\n value={mode}\n onChange={setMode}\n color={SwitchSelectorColor.TEXT}\n size={SwitchSelectorSize.SM}\n className=\"ml-auto\"\n />\n\n <TextEditorContainer\n section={content}\n keyPath={childKeyPath}\n dictionary={dictionary}\n renderSection={\n mode === MarkdownViewMode.Preview\n ? (content) => (\n <MarkdownRenderer isDarkMode={isDarkMode}>\n {content}\n </MarkdownRenderer>\n )\n : undefined\n }\n />\n </div>\n );\n};\n\nconst InsertionTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n ...props\n}) => {\n const childKeyPath: KeyPath[] = [...keyPath, { type: NodeType.Insertion }];\n\n const content = (section as InsertionContent<ContentNode>)[\n NodeType.Insertion\n ];\n\n return (\n <div className=\"flex w-full flex-col justify-center gap-6 p-2\">\n <TextEditorContainer\n section={content}\n keyPath={childKeyPath}\n {...props}\n />\n </div>\n );\n};\n\nconst FileTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n ...props\n}) => {\n const childKeyPath: KeyPath[] = [...keyPath, { type: NodeType.File }];\n\n const fileUrl = (section as FileContent)[NodeType.File];\n const { content } = section as FileContent;\n\n return (\n <div className=\"flex w-full flex-col justify-center gap-6 p-2\">\n <span className=\"text-neutral text-sm\">{fileUrl} </span>\n <TextEditorContainer\n section={content}\n keyPath={childKeyPath}\n {...props}\n />\n </div>\n );\n};\n\nconst NestedTextEditor: FC<TextEditorProps> = ({\n keyPath,\n dictionary,\n renderSection,\n section,\n ...props\n}) => {\n const { addEditedContent } = useEditedContent();\n\n const content = (section as any)[NodeType.Nested];\n const childrenKeyPath = [...keyPath, { type: NodeType.Nested }] as KeyPath[];\n\n return (\n <div className=\"flex w-full flex-col gap-4 p-2\">\n <Label>Dictionary key</Label>\n <ContentEditorInputBase\n aria-label=\"Edit field\"\n type=\"text\"\n variant={InputVariant.DEFAULT}\n {...props}\n onContentChange={(newValue) => {\n addEditedContent(\n dictionary.localId!,\n {\n ...content,\n dictionaryKey: String(newValue),\n },\n childrenKeyPath\n );\n }}\n >\n {content.dictionaryKey ?? ''}\n </ContentEditorInputBase>\n\n <Label>Path (optional)</Label>\n <ContentEditorInputBase\n aria-label=\"Edit field\"\n type=\"text\"\n variant={InputVariant.DEFAULT}\n {...props}\n onContentChange={(newValue) => {\n addEditedContent(\n dictionary.localId!,\n {\n ...content,\n path: newValue !== '' ? newValue : undefined,\n },\n childrenKeyPath\n );\n }}\n >\n {content.path ?? ''}\n </ContentEditorInputBase>\n </div>\n );\n};\n\nexport const TextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n renderSection,\n isDarkMode,\n}) => {\n const { tsxNotEditable } = useIntlayer('navigation-view');\n const nodeType = getNodeType(section);\n\n if (nodeType === NodeType.ReactNode) {\n return (\n <div className=\"flex w-full flex-col gap-2\">\n <span>(React Node)</span>\n <span className=\"flex text-neutral text-xs\">{tsxNotEditable}</span>\n </div>\n );\n }\n\n if (nodeType === NodeType.Nested) {\n return (\n <NestedTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <TranslationTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <EnumerationTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Condition) {\n return (\n <ConditionTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Gender) {\n return (\n <GenderTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Insertion) {\n return (\n <InsertionTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Markdown) {\n return (\n <MarkdownTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n isDarkMode={isDarkMode}\n />\n );\n }\n\n if (nodeType === NodeType.File) {\n return (\n <FileTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <ArrayTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Object) {\n return (\n <ObjectTextEditor\n dictionary={dictionary}\n renderSection={renderSection}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Number) {\n return (\n <div className=\"w-full p-2\">\n <ContentEditorInput\n dictionary={dictionary}\n keyPath={keyPath}\n type=\"number\"\n aria-label=\"Edit field\"\n >\n {section as number}\n </ContentEditorInput>\n </div>\n );\n }\n\n if (nodeType === NodeType.Text) {\n return (\n <div className=\"w-full p-2\">\n {typeof renderSection === 'function' ? (\n renderSection(section as string)\n ) : (\n <ContentEditorTextArea\n variant={InputVariant.DEFAULT}\n aria-label=\"Edit field\"\n keyPath={keyPath}\n dictionary={dictionary}\n >\n {section as string}\n </ContentEditorTextArea>\n )}\n </div>\n );\n }\n\n if (nodeType === NodeType.Boolean) {\n return (\n <div className=\"w-full p-2\">\n <ContentEditorToggle\n dictionary={dictionary}\n keyPath={keyPath}\n value={section as boolean}\n />\n </div>\n );\n }\n\n return (\n <div className=\"w-full p-2\">\n Error. Format not supported.\n {JSON.stringify(section, null, 2)}\n {JSON.stringify(keyPath, null, 2)}\n NodeType : {nodeType}\n </div>\n );\n};\n\nexport const TextEditorContainer: FC<TextEditorProps> = (props) => (\n <Container\n border\n background=\"none\"\n className=\"top-6 flex h-full flex-1 flex-col gap-6 overflow-hidden p-2 md:sticky\"\n roundedSize=\"xl\"\n >\n <TextEditor {...props} />\n </Container>\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAyDA,MAAaA,YAAsB;CAAC;CAAY;CAAM;CAAW;AAUjE,MAAMC,yBAAyD,EAC7D,SACA,YACA,GAAG,YACC;CACJ,MAAM,EAAE,eAAe,qBAAqB,kBAAkB;CAC9D,MAAM,gBAAgB,kBAAkB;CACxC,MAAM,EAAE,QAAQ,8BAA8B,WAAW,eACvD,iCAAiC;AAEnC,QACE,oBAACC;EACC,SAAS,aAAa;EACtB,kBAAkB,aAChB,iBAAiB,WAAW,SAAU,UAAU,QAAQ;EAE1D,mBACE,oBAAC;GACC,MAAM;GACN,OAAM;GACN,SAAS,cAAc;GACvB,MAAM,WAAW;GACjB,OAAO,YAAY;GACnB,WAAU;GACV,WAAW;GACX,eAAe;AACb,iCACE;KACE,aAAa,KAAK,UAAU;MAC1B,GAAG;MACH,GAAI,gBAAgB,WAAW,YAAa,EAAE;MAC/C,CAAC;KACF;KACA,SAAS,cAAc,qBAAqB,WAAW,EAAE;KACzD,WAAW;MACT,QAAQ,cAAc,IAAI;MAC1B,OAAO,cAAc,IAAI;MACzB,aAAa,cAAc,IAAI;MAChC;KACF,EACD,EACE,YAAY,aAAa;AACvB,SAAI,CAAC,UAAU,KAAM;AAErB,SAAI;MACF,MAAMC,kBAAgB,SAAS,KAAK;AAEpC,uBACE,WAAW,SACXA,iBACA,QACD;cACM,OAAO;AACd,cAAQ,MAAM,MAAM;;OAGzB,CACF;;IAEH;EAEJ,GAAI;GACJ;;AAYN,MAAMC,sBAAmD,EACvD,SACA,YACA,GAAG,YACC;CACJ,MAAM,EAAE,qBAAqB,kBAAkB;AAE/C,QACE,oBAACC;EACC,SAAS,aAAa;EACtB,kBAAkB,aAChB,iBAAiB,WAAW,SAAU,UAAU,QAAQ;EAE1D,GAAI;GACJ;;AAIN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AAC;CACC;CACA,YAAW;CACX,WAAU;CACV,aAAY;WAEZ,oBAAC,cAAW,GAAI,QAAS;EACf"}
@@ -2,11 +2,11 @@
2
2
 
3
3
  import { Button, ButtonColor, ButtonVariant } from "../Button/Button.mjs";
4
4
  import { SwitchSelector } from "../SwitchSelector/index.mjs";
5
- import { SaveForm } from "./SaveForm/SaveForm.mjs";
6
5
  import { LocaleSwitcherContentProvider } from "../LocaleSwitcherContentDropDown/LocaleSwitcherContentContext.mjs";
7
6
  import { ContentEditor } from "./ContentEditor.mjs";
8
7
  import { DictionaryDetailsForm } from "./DictionaryDetails/DictionaryDetailsForm.mjs";
9
8
  import { JSONEditor } from "./JSONEditor.mjs";
9
+ import { SaveForm } from "./SaveForm/SaveForm.mjs";
10
10
  import { StructureEditor } from "./StructureEditor.mjs";
11
11
  import { ArrowLeft } from "lucide-react";
12
12
  import { useEffect, useState } from "react";
@@ -42,7 +42,7 @@ const DictionaryFieldEditor = ({ dictionary, onClickDictionaryList, isDarkMode,
42
42
  return /* @__PURE__ */ jsx(LocaleSwitcherContentProvider, {
43
43
  availableLocales: config?.internationalization.locales ?? [],
44
44
  children: /* @__PURE__ */ jsxs("div", {
45
- className: "flex size-full flex-col gap-6 px-2",
45
+ className: "relative flex size-full flex-col gap-6 px-2",
46
46
  children: [
47
47
  /* @__PURE__ */ jsx(Button, {
48
48
  onClick: onClickDictionaryList,
@@ -57,6 +57,7 @@ const DictionaryFieldEditor = ({ dictionary, onClickDictionaryList, isDarkMode,
57
57
  defaultValue: editorView,
58
58
  onChange: (value) => setEditorView(value),
59
59
  color: "text",
60
+ size: "sm",
60
61
  choices: [
61
62
  {
62
63
  content: "Details",