@intlayer/design-system 4.0.2 → 4.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (240) hide show
  1. package/README.md +1 -1
  2. package/dist/.vite/manifest.json +58 -197
  3. package/dist/components/Accordion/Accordion.cjs +1 -1
  4. package/dist/components/Accordion/Accordion.cjs.map +1 -1
  5. package/dist/components/Accordion/Accordion.mjs +1 -1
  6. package/dist/components/Accordion/Accordion.mjs.map +1 -1
  7. package/dist/components/Auth/AuthModal/index.cjs +1 -1
  8. package/dist/components/Auth/AuthModal/index.mjs +1 -1
  9. package/dist/components/Auth/ExternalsLoginButtons/ExternalsLoginButtons.cjs +2 -1
  10. package/dist/components/Auth/ExternalsLoginButtons/ExternalsLoginButtons.cjs.map +1 -1
  11. package/dist/components/Auth/ExternalsLoginButtons/ExternalsLoginButtons.mjs +2 -1
  12. package/dist/components/Auth/ExternalsLoginButtons/ExternalsLoginButtons.mjs.map +1 -1
  13. package/dist/components/Auth/useAuth/index.cjs +8 -4
  14. package/dist/components/Auth/useAuth/index.cjs.map +1 -1
  15. package/dist/components/Auth/useAuth/index.d.ts +3 -1
  16. package/dist/components/Auth/useAuth/index.d.ts.map +1 -1
  17. package/dist/components/Auth/useAuth/index.mjs +8 -4
  18. package/dist/components/Auth/useAuth/index.mjs.map +1 -1
  19. package/dist/components/Auth/useAuth/useCSRF.cjs +6 -3
  20. package/dist/components/Auth/useAuth/useCSRF.cjs.map +1 -1
  21. package/dist/components/Auth/useAuth/useCSRF.d.ts +2 -1
  22. package/dist/components/Auth/useAuth/useCSRF.d.ts.map +1 -1
  23. package/dist/components/Auth/useAuth/useCSRF.mjs +5 -2
  24. package/dist/components/Auth/useAuth/useCSRF.mjs.map +1 -1
  25. package/dist/components/Auth/useAuth/useOAuth2.cjs +6 -5
  26. package/dist/components/Auth/useAuth/useOAuth2.cjs.map +1 -1
  27. package/dist/components/Auth/useAuth/useOAuth2.d.ts +2 -1
  28. package/dist/components/Auth/useAuth/useOAuth2.d.ts.map +1 -1
  29. package/dist/components/Auth/useAuth/useOAuth2.mjs +5 -4
  30. package/dist/components/Auth/useAuth/useOAuth2.mjs.map +1 -1
  31. package/dist/components/Auth/useAuth/useSession.cjs +6 -3
  32. package/dist/components/Auth/useAuth/useSession.cjs.map +1 -1
  33. package/dist/components/Auth/useAuth/useSession.d.ts +2 -1
  34. package/dist/components/Auth/useAuth/useSession.d.ts.map +1 -1
  35. package/dist/components/Auth/useAuth/useSession.mjs +6 -3
  36. package/dist/components/Auth/useAuth/useSession.mjs.map +1 -1
  37. package/dist/components/Auth/useUser/index.cjs +1 -1
  38. package/dist/components/Auth/useUser/index.mjs +1 -1
  39. package/dist/components/Container/index.d.ts +2 -2
  40. package/dist/components/DictionaryEditor/DictionaryEditor.cjs +4 -16
  41. package/dist/components/DictionaryEditor/DictionaryEditor.cjs.map +1 -1
  42. package/dist/components/DictionaryEditor/DictionaryEditor.d.ts.map +1 -1
  43. package/dist/components/DictionaryEditor/DictionaryEditor.mjs +4 -16
  44. package/dist/components/DictionaryEditor/DictionaryEditor.mjs.map +1 -1
  45. package/dist/components/DictionaryEditor/NodeWrapper/ArrayWrapper.cjs +2 -1
  46. package/dist/components/DictionaryEditor/NodeWrapper/ArrayWrapper.cjs.map +1 -1
  47. package/dist/components/DictionaryEditor/NodeWrapper/ArrayWrapper.d.ts.map +1 -1
  48. package/dist/components/DictionaryEditor/NodeWrapper/ArrayWrapper.mjs +2 -1
  49. package/dist/components/DictionaryEditor/NodeWrapper/ArrayWrapper.mjs.map +1 -1
  50. package/dist/components/DictionaryEditor/NodeWrapper/EnumerationWrapper.cjs +1 -1
  51. package/dist/components/DictionaryEditor/NodeWrapper/EnumerationWrapper.mjs +1 -1
  52. package/dist/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.cjs +2 -1
  53. package/dist/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.cjs.map +1 -1
  54. package/dist/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.d.ts.map +1 -1
  55. package/dist/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.mjs +2 -1
  56. package/dist/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.mjs.map +1 -1
  57. package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.cjs +3 -3
  58. package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.cjs.map +1 -1
  59. package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.d.ts.map +1 -1
  60. package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.mjs +2 -2
  61. package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.mjs.map +1 -1
  62. package/dist/components/DictionaryEditor/NodeWrapper/TranslationWrapper.cjs +1 -1
  63. package/dist/components/DictionaryEditor/NodeWrapper/TranslationWrapper.mjs +1 -1
  64. package/dist/components/DictionaryEditor/NodeWrapper/index.cjs +1 -1
  65. package/dist/components/DictionaryEditor/NodeWrapper/index.mjs +1 -1
  66. package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.cjs +2 -9
  67. package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.cjs.map +1 -1
  68. package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.d.ts.map +1 -1
  69. package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.mjs +2 -9
  70. package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.mjs.map +1 -1
  71. package/dist/components/DictionaryEditor/index.cjs +0 -8
  72. package/dist/components/DictionaryEditor/index.cjs.map +1 -1
  73. package/dist/components/DictionaryEditor/index.d.ts +0 -2
  74. package/dist/components/DictionaryEditor/index.d.ts.map +1 -1
  75. package/dist/components/DictionaryEditor/index.mjs +1 -9
  76. package/dist/components/DictionaryEditor/index.mjs.map +1 -1
  77. package/dist/components/DictionaryEditor/useEditedContentStore.d.ts +1 -1
  78. package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.cjs +3 -21
  79. package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.cjs.map +1 -1
  80. package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.d.ts.map +1 -1
  81. package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.mjs +3 -21
  82. package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.mjs.map +1 -1
  83. package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.cjs +4 -2
  84. package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.cjs.map +1 -1
  85. package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs +4 -2
  86. package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs.map +1 -1
  87. package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.cjs +4 -2
  88. package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.cjs.map +1 -1
  89. package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs +4 -2
  90. package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs.map +1 -1
  91. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.cjs +5 -31
  92. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.cjs.map +1 -1
  93. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.d.ts.map +1 -1
  94. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs +6 -32
  95. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs.map +1 -1
  96. package/dist/components/DictionaryFieldEditor/EditorView/EditorView.cjs +8 -37
  97. package/dist/components/DictionaryFieldEditor/EditorView/EditorView.cjs.map +1 -1
  98. package/dist/components/DictionaryFieldEditor/EditorView/EditorView.d.ts.map +1 -1
  99. package/dist/components/DictionaryFieldEditor/EditorView/EditorView.mjs +6 -35
  100. package/dist/components/DictionaryFieldEditor/EditorView/EditorView.mjs.map +1 -1
  101. package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.cjs +6 -24
  102. package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.cjs.map +1 -1
  103. package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.d.ts.map +1 -1
  104. package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.mjs +5 -23
  105. package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.mjs.map +1 -1
  106. package/dist/components/DictionaryFieldEditor/JSONEditor.cjs +2 -29
  107. package/dist/components/DictionaryFieldEditor/JSONEditor.cjs.map +1 -1
  108. package/dist/components/DictionaryFieldEditor/JSONEditor.d.ts.map +1 -1
  109. package/dist/components/DictionaryFieldEditor/JSONEditor.mjs +2 -29
  110. package/dist/components/DictionaryFieldEditor/JSONEditor.mjs.map +1 -1
  111. package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.cjs +9 -33
  112. package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.cjs.map +1 -1
  113. package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.d.ts.map +1 -1
  114. package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs +4 -28
  115. package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs.map +1 -1
  116. package/dist/components/DictionaryFieldEditor/NodeEditor.cjs +3 -43
  117. package/dist/components/DictionaryFieldEditor/NodeEditor.cjs.map +1 -1
  118. package/dist/components/DictionaryFieldEditor/NodeEditor.d.ts.map +1 -1
  119. package/dist/components/DictionaryFieldEditor/NodeEditor.mjs +3 -43
  120. package/dist/components/DictionaryFieldEditor/NodeEditor.mjs.map +1 -1
  121. package/dist/components/DictionaryFieldEditor/NodeTypeSelector.cjs +4 -27
  122. package/dist/components/DictionaryFieldEditor/NodeTypeSelector.cjs.map +1 -1
  123. package/dist/components/DictionaryFieldEditor/NodeTypeSelector.d.ts.map +1 -1
  124. package/dist/components/DictionaryFieldEditor/NodeTypeSelector.mjs +3 -26
  125. package/dist/components/DictionaryFieldEditor/NodeTypeSelector.mjs.map +1 -1
  126. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs +9 -19
  127. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs.map +1 -1
  128. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.d.ts.map +1 -1
  129. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs +9 -19
  130. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs.map +1 -1
  131. package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/VersionSwitcherContext.cjs +2 -2
  132. package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/VersionSwitcherContext.mjs +2 -2
  133. package/dist/components/EditableField/EditableFieldLayout.cjs +7 -3
  134. package/dist/components/EditableField/EditableFieldLayout.cjs.map +1 -1
  135. package/dist/components/EditableField/EditableFieldLayout.d.ts.map +1 -1
  136. package/dist/components/EditableField/EditableFieldLayout.mjs +7 -3
  137. package/dist/components/EditableField/EditableFieldLayout.mjs.map +1 -1
  138. package/dist/components/IDE/CodeContext.cjs +2 -2
  139. package/dist/components/IDE/CodeContext.mjs +2 -2
  140. package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.cjs +2 -2
  141. package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.mjs +2 -2
  142. package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContentContext.cjs +2 -2
  143. package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContentContext.mjs +2 -2
  144. package/dist/components/Modal/Modal.cjs +12 -8
  145. package/dist/components/Modal/Modal.cjs.map +1 -1
  146. package/dist/components/Modal/Modal.d.ts.map +1 -1
  147. package/dist/components/Modal/Modal.mjs +12 -8
  148. package/dist/components/Modal/Modal.mjs.map +1 -1
  149. package/dist/components/Navbar/MobileNavbar.cjs +3 -3
  150. package/dist/components/Navbar/MobileNavbar.mjs +3 -3
  151. package/dist/components/Navbar/index.cjs +2 -2
  152. package/dist/components/Navbar/index.mjs +2 -2
  153. package/dist/components/RightDrawer/RightDrawer.cjs +34 -18
  154. package/dist/components/RightDrawer/RightDrawer.cjs.map +1 -1
  155. package/dist/components/RightDrawer/RightDrawer.d.ts.map +1 -1
  156. package/dist/components/RightDrawer/RightDrawer.mjs +33 -17
  157. package/dist/components/RightDrawer/RightDrawer.mjs.map +1 -1
  158. package/dist/components/SwitchSelector/index.cjs +2 -2
  159. package/dist/components/SwitchSelector/index.mjs +2 -2
  160. package/dist/components/TabSelector/TabSelector.cjs +2 -2
  161. package/dist/components/TabSelector/TabSelector.mjs +2 -2
  162. package/dist/components/index.cjs +0 -8
  163. package/dist/components/index.cjs.map +1 -1
  164. package/dist/components/index.mjs +0 -8
  165. package/dist/components/index.mjs.map +1 -1
  166. package/dist/hooks/index.cjs +1 -1
  167. package/dist/hooks/index.mjs +2 -2
  168. package/dist/hooks/intlayerAPIHooks.cjs +5 -1
  169. package/dist/hooks/intlayerAPIHooks.cjs.map +1 -1
  170. package/dist/hooks/intlayerAPIHooks.d.ts +49 -49
  171. package/dist/hooks/intlayerAPIHooks.d.ts.map +1 -1
  172. package/dist/hooks/intlayerAPIHooks.mjs +5 -1
  173. package/dist/hooks/intlayerAPIHooks.mjs.map +1 -1
  174. package/dist/hooks/useAsync/useAsync.cjs +14 -0
  175. package/dist/hooks/useAsync/useAsync.cjs.map +1 -1
  176. package/dist/hooks/useAsync/useAsync.d.ts.map +1 -1
  177. package/dist/hooks/useAsync/useAsync.mjs +14 -0
  178. package/dist/hooks/useAsync/useAsync.mjs.map +1 -1
  179. package/dist/hooks/useGetAllDictionaries.cjs +3 -2
  180. package/dist/hooks/useGetAllDictionaries.cjs.map +1 -1
  181. package/dist/hooks/useGetAllDictionaries.d.ts +2 -2
  182. package/dist/hooks/useGetAllDictionaries.d.ts.map +1 -1
  183. package/dist/hooks/useGetAllDictionaries.mjs +3 -2
  184. package/dist/hooks/useGetAllDictionaries.mjs.map +1 -1
  185. package/dist/hooks/useIntlayerAPI.cjs +10 -7
  186. package/dist/hooks/useIntlayerAPI.cjs.map +1 -1
  187. package/dist/hooks/useIntlayerAPI.d.ts +8 -2
  188. package/dist/hooks/useIntlayerAPI.d.ts.map +1 -1
  189. package/dist/hooks/useIntlayerAPI.mjs +10 -7
  190. package/dist/hooks/useIntlayerAPI.mjs.map +1 -1
  191. package/dist/hooks/usePersistedStore.cjs +25 -15
  192. package/dist/hooks/usePersistedStore.cjs.map +1 -1
  193. package/dist/hooks/usePersistedStore.d.ts +2 -1
  194. package/dist/hooks/usePersistedStore.d.ts.map +1 -1
  195. package/dist/hooks/usePersistedStore.mjs +26 -16
  196. package/dist/hooks/usePersistedStore.mjs.map +1 -1
  197. package/dist/hooks/useScrollBlockage/index.cjs +5 -31
  198. package/dist/hooks/useScrollBlockage/index.cjs.map +1 -1
  199. package/dist/hooks/useScrollBlockage/index.mjs +5 -31
  200. package/dist/hooks/useScrollBlockage/index.mjs.map +1 -1
  201. package/dist/hooks/useScrollDetection.cjs +1 -1
  202. package/dist/hooks/useScrollDetection.mjs +1 -1
  203. package/dist/index-B-VAyQ9R.js +673 -0
  204. package/dist/index-B-VAyQ9R.js.map +1 -0
  205. package/dist/index-B-adg6xa.js +206 -0
  206. package/dist/index-B-adg6xa.js.map +1 -0
  207. package/dist/index-BIV0x_z2.js +206 -0
  208. package/dist/index-BIV0x_z2.js.map +1 -0
  209. package/dist/index-BNH9wXVj.cjs +205 -0
  210. package/dist/index-BNH9wXVj.cjs.map +1 -0
  211. package/dist/index-Cg-S9ry9.cjs +77 -0
  212. package/dist/index-Cg-S9ry9.cjs.map +1 -0
  213. package/dist/index-D69JRZcQ.js +206 -0
  214. package/dist/index-D69JRZcQ.js.map +1 -0
  215. package/dist/index-DAsui9u9.cjs +205 -0
  216. package/dist/index-DAsui9u9.cjs.map +1 -0
  217. package/dist/index-O_7rYrbW.js +78 -0
  218. package/dist/index-O_7rYrbW.js.map +1 -0
  219. package/dist/index-SOIahRpS.cjs +205 -0
  220. package/dist/index-SOIahRpS.cjs.map +1 -0
  221. package/dist/index-T-TjVQoD.js +671 -0
  222. package/dist/index-T-TjVQoD.js.map +1 -0
  223. package/dist/index-f8_VC6c8.cjs +672 -0
  224. package/dist/index-f8_VC6c8.cjs.map +1 -0
  225. package/dist/index-llGIfxqV.cjs +670 -0
  226. package/dist/index-llGIfxqV.cjs.map +1 -0
  227. package/dist/tailwind.css +1 -1
  228. package/dist/useGetAllDictionaries-B1sqs2IB.cjs +34 -0
  229. package/dist/useGetAllDictionaries-B1sqs2IB.cjs.map +1 -0
  230. package/dist/useGetAllDictionaries-BbH8vTkY.js +35 -0
  231. package/dist/useGetAllDictionaries-BbH8vTkY.js.map +1 -0
  232. package/dist/useGetAllDictionaries-Bgkytpa2.cjs +34 -0
  233. package/dist/useGetAllDictionaries-Bgkytpa2.cjs.map +1 -0
  234. package/dist/useGetAllDictionaries-D8ma3h41.cjs +33 -0
  235. package/dist/useGetAllDictionaries-D8ma3h41.cjs.map +1 -0
  236. package/dist/useGetAllDictionaries-DHgHEbD5.js +34 -0
  237. package/dist/useGetAllDictionaries-DHgHEbD5.js.map +1 -0
  238. package/dist/useGetAllDictionaries-DUzm0rIa.js +35 -0
  239. package/dist/useGetAllDictionaries-DUzm0rIa.js.map +1 -0
  240. package/package.json +24 -16
@@ -1 +1 @@
1
- {"version":3,"file":"EditorView.cjs","sources":["../../../../src/components/DictionaryFieldEditor/EditorView/EditorView.tsx"],"sourcesContent":["'use client';\n\nimport { type Locales } from '@intlayer/config';\nimport { type KeyPath, type Dictionary } from '@intlayer/core';\nimport { RotateCcw, X } from 'lucide-react';\nimport { useMemo, type FC } from 'react';\n// @ts-ignore react-intlayer not build yet\nimport { useDictionary } from 'react-intlayer';\nimport { useShallow } from 'zustand/react/shallow';\nimport { EditableFieldInput } from '../..//EditableField';\nimport {\n camelCaseToSentence,\n sentenceToCamelCase,\n} from '../../../utils/camelCase';\nimport { getDictionaryValueByKeyPath } from '../../../utils/dictionary';\nimport { Button } from '../../Button';\nimport {\n useEditedContentStore,\n useEditionPanelStore,\n} from '../../DictionaryEditor';\nimport { Label } from '../../Label';\nimport { editorViewContent } from '../editorView.content';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { NodeTypeSelector } from '../NodeTypeSelector';\nimport { TextEditor } from './TextEditor';\n\ntype EditorViewProps = {\n dictionaryKey: string;\n dictionary: Dictionary;\n locales: Locales[];\n};\n\nexport const EditorView: FC<EditorViewProps> = ({\n dictionaryKey,\n dictionary,\n locales,\n}) => {\n const { focusedContent, setFocusedContentKeyPath } = useEditionPanelStore(\n useShallow((s) => ({\n setFocusedContentKeyPath: s.setFocusedContentKeyPath,\n focusedContent: s.focusedContent,\n }))\n );\n const keyPath = focusedContent?.keyPath ?? [];\n const initialKeyName = keyPath[keyPath.length - 1]?.key ?? '';\n const { titleInput, deleteButton, nodeTypeSelector, restoreButton } =\n useDictionary(editorViewContent);\n\n const {\n editedContent,\n renameEditedContent,\n addEditedContent,\n removeEditedContent,\n } = useEditedContentStore(\n useShallow((s) => ({\n editedContent: s.editedContent,\n renameEditedContent: s.renameEditedContent,\n addEditedContent: s.addEditedContent,\n removeEditedContent: s.removeEditedContent,\n }))\n );\n\n const editedSection = editedContent[dictionaryKey]?.content\n ? getDictionaryValueByKeyPath(editedContent[dictionaryKey].content, keyPath)\n : undefined;\n\n const dictionarySection = getDictionaryValueByKeyPath(\n dictionary.content,\n keyPath\n );\n\n const section = editedSection ?? dictionarySection;\n\n const isEdited = useMemo(\n () =>\n editedSection &&\n JSON.stringify(editedSection) !== JSON.stringify(dictionarySection),\n [editedSection, dictionarySection]\n );\n\n const isEditableSection = getIsEditableSection(section);\n\n const handleRenameNodeKey = (keyName: string) => {\n const camelCaseSentence = sentenceToCamelCase(keyName);\n renameEditedContent(dictionaryKey, camelCaseSentence, keyPath);\n const prevKeyPath: KeyPath[] = keyPath.slice(0, -1);\n const lastKeyPath: KeyPath = keyPath[keyPath.length - 1];\n const newKeyPath: KeyPath[] = [\n ...prevKeyPath,\n { ...lastKeyPath, key: camelCaseSentence } as KeyPath,\n ];\n setFocusedContentKeyPath(newKeyPath);\n };\n\n return (\n <>\n {isEditableSection && (\n <TextEditor\n key={keyPath.join('.')}\n keyPath={keyPath}\n section={section}\n dictionary={dictionary}\n locales={locales}\n />\n )}\n\n {keyPath.length > 0 ? (\n <form\n className=\"bg-text text-text-dark dark:bg-text-dark dark:text-text flex w-full flex-col items-start justify-between gap-6 px-4 py-2\"\n key={JSON.stringify(focusedContent?.keyPath)}\n >\n <div className=\"flex w-full flex-wrap items-start justify-between gap-6\">\n {typeof initialKeyName === 'string' && (\n <div className=\"flex flex-col gap-3\">\n <Label>{titleInput.label}</Label>\n <div className=\"flex flex-wrap items-center gap-4\">\n <EditableFieldInput\n name=\"key\"\n aria-label=\"Key\"\n key={initialKeyName}\n placeholder={titleInput.placeholder}\n defaultValue={camelCaseToSentence(initialKeyName)}\n onSave={(value) => handleRenameNodeKey(value)}\n className=\"h-8\"\n variant=\"invisible\"\n />\n <span className=\"text-neutral dark:text-neutral-dark text-sm\">\n ({initialKeyName})\n </span>\n </div>\n </div>\n )}\n\n <div>\n <Label>{nodeTypeSelector.label}</Label>\n\n <NodeTypeSelector\n keyPath={keyPath}\n dictionaryKey={dictionaryKey}\n section={section}\n />\n </div>\n </div>\n {keyPath.length > 0 && (\n <div className=\"ml-auto flex gap-2\">\n {isEdited && (\n <Button\n label={restoreButton.label}\n variant=\"outline\"\n color=\"text-inverse\"\n Icon={RotateCcw}\n onClick={() => removeEditedContent(dictionaryKey, keyPath)}\n >\n {restoreButton.text}\n </Button>\n )}\n <Button\n label={deleteButton.label}\n variant=\"outline\"\n color=\"error\"\n Icon={X}\n onClick={() => {\n addEditedContent(dictionaryKey, undefined, keyPath);\n\n const parentKeyPath: KeyPath[] = keyPath.slice(0, -1);\n setFocusedContentKeyPath(parentKeyPath);\n }}\n >\n {deleteButton.text}\n </Button>\n </div>\n )}\n </form>\n ) : (\n <span className=\"h-8\"></span>\n )}\n </>\n );\n};\n"],"names":["useEditionPanelStore","useShallow","useDictionary","editorViewContent","useEditedContentStore","getDictionaryValueByKeyPath","useMemo","getIsEditableSection","sentenceToCamelCase","jsxs","Fragment","jsx","TextEditor","Label","EditableFieldInput","camelCaseToSentence","NodeTypeSelector","Button","RotateCcw","X"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCO,MAAM,aAAkC,CAAC;AAAA,EAC9C;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACE,QAAA,EAAE,gBAAgB,yBAAA,IAA6BA,iDAAA;AAAA,IACnDC,QAAA,WAAW,CAAC,OAAO;AAAA,MACjB,0BAA0B,EAAE;AAAA,MAC5B,gBAAgB,EAAE;AAAA,IAAA,EAClB;AAAA,EACJ;AACM,QAAA,UAAU,gBAAgB,WAAW,CAAC;AAC5C,QAAM,iBAAiB,QAAQ,QAAQ,SAAS,CAAC,GAAG,OAAO;AAC3D,QAAM,EAAE,YAAY,cAAc,kBAAkB,cAAc,IAChEC,4BAAcC,qEAAiB;AAE3B,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACEC,kDAAA;AAAA,IACFH,QAAA,WAAW,CAAC,OAAO;AAAA,MACjB,eAAe,EAAE;AAAA,MACjB,qBAAqB,EAAE;AAAA,MACvB,kBAAkB,EAAE;AAAA,MACpB,qBAAqB,EAAE;AAAA,IAAA,EACvB;AAAA,EACJ;AAEM,QAAA,gBAAgB,cAAc,aAAa,GAAG,UAChDI,iBAAAA,4BAA4B,cAAc,aAAa,EAAE,SAAS,OAAO,IACzE;AAEJ,QAAM,oBAAoBA,iBAAA;AAAA,IACxB,WAAW;AAAA,IACX;AAAA,EACF;AAEA,QAAM,UAAU,iBAAiB;AAEjC,QAAM,WAAWC,WAAA;AAAA,IACf,MACE,iBACA,KAAK,UAAU,aAAa,MAAM,KAAK,UAAU,i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AA,MA7DG,KAAK,UAAU,gBAAgB,OAAO;AAAA,IAiE7C,IAAAR,iDAAC,QAAK,EAAA,WAAU,MAAM,CAAA;AAAA,EAAA,GAE1B;AAEJ;;"}
1
+ {"version":3,"file":"EditorView.cjs","sources":["../../../../src/components/DictionaryFieldEditor/EditorView/EditorView.tsx"],"sourcesContent":["'use client';\n\nimport { type Locales } from '@intlayer/config';\nimport { type KeyPath, type Dictionary } from '@intlayer/core';\nimport { getDictionaryValueByKeyPath } from '@intlayer/editor';\nimport { useFocusDictionary, useEditedContent } from '@intlayer/editor-react';\nimport { RotateCcw, X } from 'lucide-react';\nimport { useMemo, type FC } from 'react';\n// @ts-ignore react-intlayer not build yet\nimport { useDictionary } from 'react-intlayer';\nimport {\n camelCaseToSentence,\n sentenceToCamelCase,\n} from '../../../utils/camelCase';\nimport { Button } from '../../Button';\nimport { EditableFieldInput } from '../../EditableField';\nimport { Label } from '../../Label';\nimport { editorViewContent } from '../editorView.content';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { NodeTypeSelector } from '../NodeTypeSelector';\nimport { TextEditor } from './TextEditor';\n\ntype EditorViewProps = {\n dictionaryKey: string;\n dictionary: Dictionary;\n locales: Locales[];\n};\n\nexport const EditorView: FC<EditorViewProps> = ({\n dictionaryKey,\n dictionary,\n locales,\n}) => {\n const { focusedContent, setFocusedContentKeyPath } = useFocusDictionary();\n const keyPath = focusedContent?.keyPath ?? [];\n const initialKeyName = keyPath[keyPath.length - 1]?.key ?? '';\n const { titleInput, deleteButton, nodeTypeSelector, restoreButton } =\n useDictionary(editorViewContent);\n const {\n editedContent,\n renameEditedContent,\n addEditedContent,\n removeEditedContent,\n } = useEditedContent();\n\n const editedSection = editedContent[dictionaryKey]?.content\n ? getDictionaryValueByKeyPath(editedContent[dictionaryKey].content, keyPath)\n : undefined;\n\n const dictionarySection = getDictionaryValueByKeyPath(\n dictionary.content,\n keyPath\n );\n\n const section = editedSection ?? dictionarySection;\n\n const isEdited = useMemo(\n () =>\n editedSection &&\n JSON.stringify(editedSection) !== JSON.stringify(dictionarySection),\n [editedSection, dictionarySection]\n );\n\n const isEditableSection = getIsEditableSection(section);\n\n const handleRenameNodeKey = (keyName: string) => {\n const camelCaseSentence = sentenceToCamelCase(keyName);\n renameEditedContent(dictionaryKey, camelCaseSentence, keyPath);\n const prevKeyPath: KeyPath[] = keyPath.slice(0, -1);\n const lastKeyPath: KeyPath = keyPath[keyPath.length - 1];\n const newKeyPath: KeyPath[] = [\n ...prevKeyPath,\n { ...lastKeyPath, key: camelCaseSentence } as KeyPath,\n ];\n setFocusedContentKeyPath(newKeyPath);\n };\n\n return (\n <>\n {isEditableSection && (\n <TextEditor\n key={keyPath.join('.')}\n keyPath={keyPath}\n section={section}\n dictionary={dictionary}\n locales={locales}\n />\n )}\n\n {keyPath.length > 0 ? (\n <form\n className=\"bg-text text-text-dark dark:bg-text-dark dark:text-text flex w-full flex-col items-start justify-between gap-6 px-4 py-2\"\n key={JSON.stringify(focusedContent?.keyPath)}\n >\n <div className=\"flex w-full flex-wrap items-start justify-between gap-6\">\n {typeof initialKeyName === 'string' && (\n <div className=\"flex flex-col gap-3\">\n <Label>{titleInput.label}</Label>\n <div className=\"flex flex-wrap items-center gap-4\">\n <EditableFieldInput\n name=\"key\"\n aria-label=\"Key\"\n key={initialKeyName}\n placeholder={titleInput.placeholder}\n defaultValue={camelCaseToSentence(initialKeyName)}\n onSave={(value) => handleRenameNodeKey(value)}\n className=\"h-8\"\n variant=\"invisible\"\n />\n <span className=\"text-neutral dark:text-neutral-dark text-sm\">\n ({initialKeyName})\n </span>\n </div>\n </div>\n )}\n\n <div>\n <Label>{nodeTypeSelector.label}</Label>\n\n <NodeTypeSelector\n keyPath={keyPath}\n dictionaryKey={dictionaryKey}\n section={section}\n />\n </div>\n </div>\n {keyPath.length > 0 && (\n <div className=\"ml-auto flex gap-2\">\n {isEdited && (\n <Button\n label={restoreButton.label}\n variant=\"outline\"\n color=\"text-inverse\"\n Icon={RotateCcw}\n onClick={() => removeEditedContent(dictionaryKey, keyPath)}\n >\n {restoreButton.text}\n </Button>\n )}\n <Button\n label={deleteButton.label}\n variant=\"outline\"\n color=\"error\"\n Icon={X}\n onClick={() => {\n addEditedContent(dictionaryKey, undefined, keyPath);\n\n const parentKeyPath: KeyPath[] = keyPath.slice(0, -1);\n setFocusedContentKeyPath(parentKeyPath);\n }}\n >\n {deleteButton.text}\n </Button>\n </div>\n )}\n </form>\n ) : (\n <span className=\"h-8\"></span>\n )}\n </>\n );\n};\n"],"names":["useFocusDictionary","useDictionary","editorViewContent","useEditedContent","getDictionaryValueByKeyPath","useMemo","getIsEditableSection","sentenceToCamelCase","jsxs","Fragment","jsx","TextEditor","Label","EditableFieldInput","camelCaseToSentence","NodeTypeSelector","Button","RotateCcw","X"],"mappings":";;;;;;;;;;;;;;;;;;AA4BO,MAAM,aAAkC,CAAC;AAAA,EAC9C;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,gBAAgB,yBAAyB,IAAIA,+BAAmB;AAClE,QAAA,UAAU,gBAAgB,WAAW,CAAC;AAC5C,QAAM,iBAAiB,QAAQ,QAAQ,SAAS,CAAC,GAAG,OAAO;AAC3D,QAAM,EAAE,YAAY,cAAc,kBAAkB,cAAc,IAChEC,4BAAcC,qEAAiB;AAC3B,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACEC,6BAAiB;AAEf,QAAA,gBAAgB,cAAc,aAAa,GAAG,UAChDC,OAAAA,4BAA4B,cAAc,aAAa,EAAE,SAAS,OAAO,IACzE;AAEJ,QAAM,oBAAoBA,OAAA;AAAA,IACxB,WAAW;AAAA,IACX;AAAA,EACF;AAEA,QAAM,UAAU,iBAAiB;AAEjC,QAAM,WAAWC,WAAA;AAAA,IACf,MACE,iBACA,KAAK,UAAU,aAAa,MAAM,KAAK,UAAU,iBAAiB;AAAA,IACpE,CAAC,eAAe,iBAAiB;AAAA,EACnC;AAEM,QAAA,oB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QAAK,EAAA,WAAU,MAAM,CAAA;AAAA,EAAA,GAE1B;AAEJ;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"EditorView.d.ts","sourceRoot":"","sources":["../../../../src/components/DictionaryFieldEditor/EditorView/EditorView.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE/D,OAAO,EAAW,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAqBzC,KAAK,eAAe,GAAG;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,UAAU,CAAC;IACvB,OAAO,EAAE,OAAO,EAAE,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CAkJ1C,CAAC"}
1
+ {"version":3,"file":"EditorView.d.ts","sourceRoot":"","sources":["../../../../src/components/DictionaryFieldEditor/EditorView/EditorView.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAI/D,OAAO,EAAW,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAezC,KAAK,eAAe,GAAG;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,UAAU,CAAC;IACvB,OAAO,EAAE,OAAO,EAAE,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CAqI1C,CAAC"}
@@ -1,31 +1,14 @@
1
1
  "use client";
2
2
  import { j as jsxRuntimeExports } from "../../../jsx-runtime-DQkoUcjV.js";
3
+ import { getDictionaryValueByKeyPath } from "@intlayer/editor";
4
+ import { useFocusDictionary, useEditedContent } from "@intlayer/editor-react";
3
5
  import { RotateCcw, X } from "lucide-react";
4
6
  import { useMemo } from "react";
5
7
  import { useDictionary } from "react-intlayer";
6
- import { u as useShallow } from "../../../shallow-m9BpCkKh.js";
7
- import { EditableFieldInput } from "../../EditableField/EditableFieldInput.mjs";
8
- import "../../EditableField/EditableFieldTextArea.mjs";
9
8
  import { camelCaseToSentence, sentenceToCamelCase } from "../../../utils/camelCase.mjs";
10
- import { getDictionaryValueByKeyPath } from "../../../utils/dictionary.mjs";
11
9
  import { Button } from "../../Button/Button.mjs";
12
- import { useEditedContentStore } from "../../DictionaryEditor/useEditedContentStore.mjs";
13
- import { useEditionPanelStore } from "../../DictionaryEditor/useEditionPanelStore.mjs";
14
- import "@intlayer/core";
15
- import "clsx";
16
- import "tailwind-merge";
17
- import "../../../hooks/useScrollBlockage/useScrollBlockageStore.mjs";
18
- import "../../../hooks/useAsync/useAsyncStateStore.mjs";
19
- import "../../../index-DcWYZrJW.js";
20
- import "@intlayer/config/client";
21
- import "../../Toaster/Toast.mjs";
22
- import "@intlayer/dictionaries-entry";
23
- import "deepmerge";
24
- import "../../Form/FormBase.mjs";
25
- import "../../Form/FormField.mjs";
26
- import "../../../Form-DlqjTz3u.js";
27
- import "../../DictionaryEditor/validDictionaryChangeButtons.content.mjs";
28
- import "zod";
10
+ import { EditableFieldInput } from "../../EditableField/EditableFieldInput.mjs";
11
+ import "../../EditableField/EditableFieldTextArea.mjs";
29
12
  import { Label } from "../../Label/index.mjs";
30
13
  import { editorViewContent } from "../editorView.content.mjs";
31
14
  import { getIsEditableSection } from "../getIsEditableSection.mjs";
@@ -36,12 +19,7 @@ const EditorView = ({
36
19
  dictionary,
37
20
  locales
38
21
  }) => {
39
- const { focusedContent, setFocusedContentKeyPath } = useEditionPanelStore(
40
- useShallow((s) => ({
41
- setFocusedContentKeyPath: s.setFocusedContentKeyPath,
42
- focusedContent: s.focusedContent
43
- }))
44
- );
22
+ const { focusedContent, setFocusedContentKeyPath } = useFocusDictionary();
45
23
  const keyPath = focusedContent?.keyPath ?? [];
46
24
  const initialKeyName = keyPath[keyPath.length - 1]?.key ?? "";
47
25
  const { titleInput, deleteButton, nodeTypeSelector, restoreButton } = useDictionary(editorViewContent);
@@ -50,14 +28,7 @@ const EditorView = ({
50
28
  renameEditedContent,
51
29
  addEditedContent,
52
30
  removeEditedContent
53
- } = useEditedContentStore(
54
- useShallow((s) => ({
55
- editedContent: s.editedContent,
56
- renameEditedContent: s.renameEditedContent,
57
- addEditedContent: s.addEditedContent,
58
- removeEditedContent: s.removeEditedContent
59
- }))
60
- );
31
+ } = useEditedContent();
61
32
  const editedSection = editedContent[dictionaryKey]?.content ? getDictionaryValueByKeyPath(editedContent[dictionaryKey].content, keyPath) : void 0;
62
33
  const dictionarySection = getDictionaryValueByKeyPath(
63
34
  dictionary.content,
@@ -1 +1 @@
1
- {"version":3,"file":"EditorView.mjs","sources":["../../../../src/components/DictionaryFieldEditor/EditorView/EditorView.tsx"],"sourcesContent":["'use client';\n\nimport { type Locales } from '@intlayer/config';\nimport { type KeyPath, type Dictionary } from '@intlayer/core';\nimport { RotateCcw, X } from 'lucide-react';\nimport { useMemo, type FC } from 'react';\n// @ts-ignore react-intlayer not build yet\nimport { useDictionary } from 'react-intlayer';\nimport { useShallow } from 'zustand/react/shallow';\nimport { EditableFieldInput } from '../..//EditableField';\nimport {\n camelCaseToSentence,\n sentenceToCamelCase,\n} from '../../../utils/camelCase';\nimport { getDictionaryValueByKeyPath } from '../../../utils/dictionary';\nimport { Button } from '../../Button';\nimport {\n useEditedContentStore,\n useEditionPanelStore,\n} from '../../DictionaryEditor';\nimport { Label } from '../../Label';\nimport { editorViewContent } from '../editorView.content';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { NodeTypeSelector } from '../NodeTypeSelector';\nimport { TextEditor } from './TextEditor';\n\ntype EditorViewProps = {\n dictionaryKey: string;\n dictionary: Dictionary;\n locales: Locales[];\n};\n\nexport const EditorView: FC<EditorViewProps> = ({\n dictionaryKey,\n dictionary,\n locales,\n}) => {\n const { focusedContent, setFocusedContentKeyPath } = useEditionPanelStore(\n useShallow((s) => ({\n setFocusedContentKeyPath: s.setFocusedContentKeyPath,\n focusedContent: s.focusedContent,\n }))\n );\n const keyPath = focusedContent?.keyPath ?? [];\n const initialKeyName = keyPath[keyPath.length - 1]?.key ?? '';\n const { titleInput, deleteButton, nodeTypeSelector, restoreButton } =\n useDictionary(editorViewContent);\n\n const {\n editedContent,\n renameEditedContent,\n addEditedContent,\n removeEditedContent,\n } = useEditedContentStore(\n useShallow((s) => ({\n editedContent: s.editedContent,\n renameEditedContent: s.renameEditedContent,\n addEditedContent: s.addEditedContent,\n removeEditedContent: s.removeEditedContent,\n }))\n );\n\n const editedSection = editedContent[dictionaryKey]?.content\n ? getDictionaryValueByKeyPath(editedContent[dictionaryKey].content, keyPath)\n : undefined;\n\n const dictionarySection = getDictionaryValueByKeyPath(\n dictionary.content,\n keyPath\n );\n\n const section = editedSection ?? dictionarySection;\n\n const isEdited = useMemo(\n () =>\n editedSection &&\n JSON.stringify(editedSection) !== JSON.stringify(dictionarySection),\n [editedSection, dictionarySection]\n );\n\n const isEditableSection = getIsEditableSection(section);\n\n const handleRenameNodeKey = (keyName: string) => {\n const camelCaseSentence = sentenceToCamelCase(keyName);\n renameEditedContent(dictionaryKey, camelCaseSentence, keyPath);\n const prevKeyPath: KeyPath[] = keyPath.slice(0, -1);\n const lastKeyPath: KeyPath = keyPath[keyPath.length - 1];\n const newKeyPath: KeyPath[] = [\n ...prevKeyPath,\n { ...lastKeyPath, key: camelCaseSentence } as KeyPath,\n ];\n setFocusedContentKeyPath(newKeyPath);\n };\n\n return (\n <>\n {isEditableSection && (\n <TextEditor\n key={keyPath.join('.')}\n keyPath={keyPath}\n section={section}\n dictionary={dictionary}\n locales={locales}\n />\n )}\n\n {keyPath.length > 0 ? (\n <form\n className=\"bg-text text-text-dark dark:bg-text-dark dark:text-text flex w-full flex-col items-start justify-between gap-6 px-4 py-2\"\n key={JSON.stringify(focusedContent?.keyPath)}\n >\n <div className=\"flex w-full flex-wrap items-start justify-between gap-6\">\n {typeof initialKeyName === 'string' && (\n <div className=\"flex flex-col gap-3\">\n <Label>{titleInput.label}</Label>\n <div className=\"flex flex-wrap items-center gap-4\">\n <EditableFieldInput\n name=\"key\"\n aria-label=\"Key\"\n key={initialKeyName}\n placeholder={titleInput.placeholder}\n defaultValue={camelCaseToSentence(initialKeyName)}\n onSave={(value) => handleRenameNodeKey(value)}\n className=\"h-8\"\n variant=\"invisible\"\n />\n <span className=\"text-neutral dark:text-neutral-dark text-sm\">\n ({initialKeyName})\n </span>\n </div>\n </div>\n )}\n\n <div>\n <Label>{nodeTypeSelector.label}</Label>\n\n <NodeTypeSelector\n keyPath={keyPath}\n dictionaryKey={dictionaryKey}\n section={section}\n />\n </div>\n </div>\n {keyPath.length > 0 && (\n <div className=\"ml-auto flex gap-2\">\n {isEdited && (\n <Button\n label={restoreButton.label}\n variant=\"outline\"\n color=\"text-inverse\"\n Icon={RotateCcw}\n onClick={() => removeEditedContent(dictionaryKey, keyPath)}\n >\n {restoreButton.text}\n </Button>\n )}\n <Button\n label={deleteButton.label}\n variant=\"outline\"\n color=\"error\"\n Icon={X}\n onClick={() => {\n addEditedContent(dictionaryKey, undefined, keyPath);\n\n const parentKeyPath: KeyPath[] = keyPath.slice(0, -1);\n setFocusedContentKeyPath(parentKeyPath);\n }}\n >\n {deleteButton.text}\n </Button>\n </div>\n )}\n </form>\n ) : (\n <span className=\"h-8\"></span>\n )}\n </>\n );\n};\n"],"names":["jsxs","Fragment","jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCO,MAAM,aAAkC,CAAC;AAAA,EAC9C;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACE,QAAA,EAAE,gBAAgB,yBAAA,IAA6B;AAAA,IACnD,WAAW,CAAC,OAAO;AAAA,MACjB,0BAA0B,EAAE;AAAA,MAC5B,gBAAgB,EAAE;AAAA,IAAA,EAClB;AAAA,EACJ;AACM,QAAA,UAAU,gBAAgB,WAAW,CAAC;AAC5C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AM,oBAAoB,eAAe,OAAO;AAAA,gBAExD,UAAc,cAAA;AAAA,cAAA;AAAA,YACjB;AAAA,YAEFA,kCAAA;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,OAAO,aAAa;AAAA,gBACpB,SAAQ;AAAA,gBACR,OAAM;AAAA,gBACN,MAAM;AAAA,gBACN,SAAS,MAAM;AACI,mCAAA,eAAe,QAAW,OAAO;AAElD,wBAAM,gBAA2B,QAAQ,MAAM,GAAG,EAAE;AACpD,2CAAyB,aAAa;AAAA,gBACxC;AAAA,gBAEC,UAAa,aAAA;AAAA,cAAA;AAAA,YAAA;AAAA,UAChB,EACF,CAAA;AAAA,QAAA;AAAA,MAAA;AAAA,MA7DG,KAAK,UAAU,gBAAgB,OAAO;AAAA,IAiE7C,IAAAA,sCAAC,QAAK,EAAA,WAAU,MAAM,CAAA;AAAA,EAAA,GAE1B;AAEJ;"}
1
+ {"version":3,"file":"EditorView.mjs","sources":["../../../../src/components/DictionaryFieldEditor/EditorView/EditorView.tsx"],"sourcesContent":["'use client';\n\nimport { type Locales } from '@intlayer/config';\nimport { type KeyPath, type Dictionary } from '@intlayer/core';\nimport { getDictionaryValueByKeyPath } from '@intlayer/editor';\nimport { useFocusDictionary, useEditedContent } from '@intlayer/editor-react';\nimport { RotateCcw, X } from 'lucide-react';\nimport { useMemo, type FC } from 'react';\n// @ts-ignore react-intlayer not build yet\nimport { useDictionary } from 'react-intlayer';\nimport {\n camelCaseToSentence,\n sentenceToCamelCase,\n} from '../../../utils/camelCase';\nimport { Button } from '../../Button';\nimport { EditableFieldInput } from '../../EditableField';\nimport { Label } from '../../Label';\nimport { editorViewContent } from '../editorView.content';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { NodeTypeSelector } from '../NodeTypeSelector';\nimport { TextEditor } from './TextEditor';\n\ntype EditorViewProps = {\n dictionaryKey: string;\n dictionary: Dictionary;\n locales: Locales[];\n};\n\nexport const EditorView: FC<EditorViewProps> = ({\n dictionaryKey,\n dictionary,\n locales,\n}) => {\n const { focusedContent, setFocusedContentKeyPath } = useFocusDictionary();\n const keyPath = focusedContent?.keyPath ?? [];\n const initialKeyName = keyPath[keyPath.length - 1]?.key ?? '';\n const { titleInput, deleteButton, nodeTypeSelector, restoreButton } =\n useDictionary(editorViewContent);\n const {\n editedContent,\n renameEditedContent,\n addEditedContent,\n removeEditedContent,\n } = useEditedContent();\n\n const editedSection = editedContent[dictionaryKey]?.content\n ? getDictionaryValueByKeyPath(editedContent[dictionaryKey].content, keyPath)\n : undefined;\n\n const dictionarySection = getDictionaryValueByKeyPath(\n dictionary.content,\n keyPath\n );\n\n const section = editedSection ?? dictionarySection;\n\n const isEdited = useMemo(\n () =>\n editedSection &&\n JSON.stringify(editedSection) !== JSON.stringify(dictionarySection),\n [editedSection, dictionarySection]\n );\n\n const isEditableSection = getIsEditableSection(section);\n\n const handleRenameNodeKey = (keyName: string) => {\n const camelCaseSentence = sentenceToCamelCase(keyName);\n renameEditedContent(dictionaryKey, camelCaseSentence, keyPath);\n const prevKeyPath: KeyPath[] = keyPath.slice(0, -1);\n const lastKeyPath: KeyPath = keyPath[keyPath.length - 1];\n const newKeyPath: KeyPath[] = [\n ...prevKeyPath,\n { ...lastKeyPath, key: camelCaseSentence } as KeyPath,\n ];\n setFocusedContentKeyPath(newKeyPath);\n };\n\n return (\n <>\n {isEditableSection && (\n <TextEditor\n key={keyPath.join('.')}\n keyPath={keyPath}\n section={section}\n dictionary={dictionary}\n locales={locales}\n />\n )}\n\n {keyPath.length > 0 ? (\n <form\n className=\"bg-text text-text-dark dark:bg-text-dark dark:text-text flex w-full flex-col items-start justify-between gap-6 px-4 py-2\"\n key={JSON.stringify(focusedContent?.keyPath)}\n >\n <div className=\"flex w-full flex-wrap items-start justify-between gap-6\">\n {typeof initialKeyName === 'string' && (\n <div className=\"flex flex-col gap-3\">\n <Label>{titleInput.label}</Label>\n <div className=\"flex flex-wrap items-center gap-4\">\n <EditableFieldInput\n name=\"key\"\n aria-label=\"Key\"\n key={initialKeyName}\n placeholder={titleInput.placeholder}\n defaultValue={camelCaseToSentence(initialKeyName)}\n onSave={(value) => handleRenameNodeKey(value)}\n className=\"h-8\"\n variant=\"invisible\"\n />\n <span className=\"text-neutral dark:text-neutral-dark text-sm\">\n ({initialKeyName})\n </span>\n </div>\n </div>\n )}\n\n <div>\n <Label>{nodeTypeSelector.label}</Label>\n\n <NodeTypeSelector\n keyPath={keyPath}\n dictionaryKey={dictionaryKey}\n section={section}\n />\n </div>\n </div>\n {keyPath.length > 0 && (\n <div className=\"ml-auto flex gap-2\">\n {isEdited && (\n <Button\n label={restoreButton.label}\n variant=\"outline\"\n color=\"text-inverse\"\n Icon={RotateCcw}\n onClick={() => removeEditedContent(dictionaryKey, keyPath)}\n >\n {restoreButton.text}\n </Button>\n )}\n <Button\n label={deleteButton.label}\n variant=\"outline\"\n color=\"error\"\n Icon={X}\n onClick={() => {\n addEditedContent(dictionaryKey, undefined, keyPath);\n\n const parentKeyPath: KeyPath[] = keyPath.slice(0, -1);\n setFocusedContentKeyPath(parentKeyPath);\n }}\n >\n {deleteButton.text}\n </Button>\n </div>\n )}\n </form>\n ) : (\n <span className=\"h-8\"></span>\n )}\n </>\n );\n};\n"],"names":["jsxs","Fragment","jsx"],"mappings":";;;;;;;;;;;;;;;;AA4BO,MAAM,aAAkC,CAAC;AAAA,EAC9C;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,gBAAgB,yBAAyB,IAAI,mBAAmB;AAClE,QAAA,UAAU,gBAAgB,WAAW,CAAC;AAC5C,QAAM,iBAAiB,QAAQ,QAAQ,SAAS,CAAC,GAAG,OAAO;AAC3D,QAAM,EAAE,YAAY,cAAc,kBAAkB,cAAc,IAChE,cAAc,iBAAiB;AAC3B,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,iBAAiB;AAEf,QAAA,gBAAgB,cAAc,aAAa,GAAG,UAChD,4BAA4B,cAAc,aAAa,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,MAAA;AAAA,MA7DG,KAAK,UAAU,gBAAgB,OAAO;AAAA,IAiE7C,IAAAA,sCAAC,QAAK,EAAA,WAAU,MAAM,CAAA;AAAA,EAAA,GAE1B;AAEJ;"}
@@ -3,30 +3,18 @@
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
4
  const jsxRuntime = require("../../../jsx-runtime-CgFM7lM3.cjs");
5
5
  const core = require("@intlayer/core");
6
+ const editor = require("@intlayer/editor");
7
+ const editorReact = require("@intlayer/editor-react");
6
8
  const lucideReact = require("lucide-react");
7
9
  const require$$0 = require("react");
8
10
  const reactIntlayer = require("react-intlayer");
9
- const shallow = require("../../../shallow-lhDIFtEp.cjs");
10
11
  require("../../../hooks/useScrollBlockage/useScrollBlockageStore.cjs");
11
12
  require("../../../hooks/useAsync/useAsyncStateStore.cjs");
12
13
  const hooks_intlayerAPIHooks = require("../../../hooks/intlayerAPIHooks.cjs");
13
- require("@intlayer/dictionaries-entry");
14
14
  require("deepmerge");
15
- const utils_dictionary = require("../../../utils/dictionary.cjs");
16
15
  const utils_object = require("../../../utils/object.cjs");
17
16
  const components_Button_Button = require("../../Button/Button.cjs");
18
17
  const components_ContentEditor_ContentEditorTextArea = require("../../ContentEditor/ContentEditorTextArea.cjs");
19
- const components_DictionaryEditor_useEditedContentStore = require("../../DictionaryEditor/useEditedContentStore.cjs");
20
- require("../../DictionaryEditor/useEditionPanelStore.cjs");
21
- require("clsx");
22
- require("tailwind-merge");
23
- require("../../EditableField/EditableFieldInput.cjs");
24
- require("../../EditableField/EditableFieldTextArea.cjs");
25
- require("../../Form/FormBase.cjs");
26
- require("../../Form/FormField.cjs");
27
- require("../../../Form-CSMiPnjC.cjs");
28
- require("../../DictionaryEditor/validDictionaryChangeButtons.content.cjs");
29
- require("zod");
30
18
  require("@intlayer/config/client");
31
19
  require("fuse.js");
32
20
  require("../../Container/index.cjs");
@@ -47,9 +35,7 @@ const ContentEditorTextArea = ({
47
35
  locales,
48
36
  ...props
49
37
  }) => {
50
- const addEditedContent = components_DictionaryEditor_useEditedContentStore.useEditedContentStore(
51
- shallow.useShallow((s) => s.addEditedContent)
52
- );
38
+ const { addEditedContent } = editorReact.useEditedContent();
53
39
  const { auditContentDeclarationField, isLoading: isAuditing } = hooks_intlayerAPIHooks.useAuditContentDeclarationField();
54
40
  return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
55
41
  components_ContentEditor_ContentEditorTextArea.ContentEditorTextArea,
@@ -159,9 +145,7 @@ const EnumerationTextEditor = ({
159
145
  dictionary,
160
146
  locales
161
147
  }) => {
162
- const addEditedContent = components_DictionaryEditor_useEditedContentStore.useEditedContentStore(
163
- shallow.useShallow((s) => s.addEditedContent)
164
- );
148
+ const { addEditedContent } = editorReact.useEditedContent();
165
149
  const { addNewEnumeration } = reactIntlayer.useDictionary(components_DictionaryFieldEditor_NavigationView_navigationViewNode_content.navigationViewContent);
166
150
  return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs("table", { className: "w-full table-fixed gap-2", children: [
167
151
  /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("tbody", { className: "divide-y-[1.5px]", children: Object.keys(
@@ -254,9 +238,7 @@ const ArrayTextEditor = ({
254
238
  dictionary,
255
239
  locales
256
240
  }) => {
257
- const addEditedContent = components_DictionaryEditor_useEditedContentStore.useEditedContentStore(
258
- shallow.useShallow((s) => s.addEditedContent)
259
- );
241
+ const { addEditedContent } = editorReact.useEditedContent();
260
242
  const { addNewElement } = reactIntlayer.useDictionary(components_DictionaryFieldEditor_NavigationView_navigationViewNode_content.navigationViewContent);
261
243
  return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs("table", { className: "w-full gap-2", children: [
262
244
  /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("tbody", { className: "divide-y-[1.5px]", children: section.map((subSection, index) => /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs(
@@ -316,7 +298,7 @@ const TextEditor = ({
316
298
  locales
317
299
  }) => {
318
300
  const { tsxNotEditable } = reactIntlayer.useDictionary(components_DictionaryFieldEditor_NavigationView_navigationViewNode_content.navigationViewContent);
319
- const nodeType = utils_dictionary.getSectionType(section);
301
+ const nodeType = editor.getSectionType(section);
320
302
  const isEditableSection = components_DictionaryFieldEditor_getIsEditableSection.getIsEditableSection(section);
321
303
  if (!isEditableSection) return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(jsxRuntime.jsxRuntimeExports.Fragment, {});
322
304
  if (typeof section === "object") {
@@ -1 +1 @@
1
- {"version":3,"file":"TextEditor.cjs","sources":["../../../../src/components/DictionaryFieldEditor/EditorView/TextEditor.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n'use client';\n\nimport { Locales } from '@intlayer/config';\nimport {\n type EnumerationContent,\n type TranslationContent,\n NodeType,\n type KeyPath,\n type DictionaryValue,\n getLocaleName,\n Dictionary,\n} from '@intlayer/core';\nimport { Plus, WandSparkles, X } from 'lucide-react';\nimport {\n createElement,\n type ReactElement,\n type ReactNode,\n type FC,\n} from 'react';\n// @ts-ignore react-intlayer not build yet\nimport { useDictionary, useLocale } from 'react-intlayer';\nimport { useShallow } from 'zustand/react/shallow';\nimport { useAuditContentDeclarationField } from '../../../hooks';\nimport { getSectionType } from '../../../utils/dictionary';\nimport { renameKey } from '../../../utils/object';\nimport { Button } from '../../Button';\nimport {\n ContentEditorTextArea as ContentEditorTextAreaBase,\n ContentEditorTextAreaProps as ContentEditorTextAreaPropsBase,\n} from '../../ContentEditor/ContentEditorTextArea';\nimport { useEditedContentStore } from '../../DictionaryEditor';\nimport { useLocaleSwitcherContent } from '../../LocaleSwitcherContentDropDown';\nimport { EnumKeyInput } from '../EnumKeyInput';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from '../NavigationView/navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\ntype ContentEditorTextAreaProps = Omit<\n ContentEditorTextAreaPropsBase,\n 'onContentChange'\n> & {\n keyPath: KeyPath[];\n dictionary: Dictionary;\n locales: Locales[];\n};\n\nconst ContentEditorTextArea: FC<ContentEditorTextAreaProps> = ({\n keyPath,\n dictionary,\n locales,\n ...props\n}) => {\n const addEditedContent = useEditedContentStore(\n useShallow((s) => s.addEditedContent)\n );\n const { auditContentDeclarationField, isLoading: isAuditing } =\n useAuditContentDeclarationField();\n\n return (\n <ContentEditorTextAreaBase\n variant=\"default\"\n onContentChange={(newValue) =>\n addEditedContent(dictionary.key, newValue, keyPath)\n }\n additionalButtons={\n <Button\n Icon={WandSparkles}\n label=\"Audit\"\n variant=\"hoverable\"\n size=\"icon-sm\"\n color=\"text\"\n className=\"cursor-pointer hover:scale-110\"\n isLoading={isAuditing}\n onClick={() => {\n auditContentDeclarationField({\n fileContent: JSON.stringify(dictionary),\n keyPath,\n locales,\n }).then((response) => {\n if (!response.data) return;\n\n try {\n const editedContent = response.data.fileContent as string;\n\n addEditedContent(dictionary.key, editedContent, keyPath);\n } catch (error) {\n console.error(error);\n }\n });\n }}\n />\n }\n {...props}\n />\n );\n};\n\nconst createReactElement = (element: ReactElement) => {\n if (typeof element === 'string') {\n // If it's a string, simply return it (used for text content)\n return element;\n }\n\n const convertChildrenAsArray = (element: ReactElement): ReactElement => {\n if (element?.props && typeof element.props.children === 'object') {\n const childrenResult: ReactNode[] = [];\n const { children } = element.props;\n\n // Create the children elements recursively, if any\n Object.keys(children).forEach((key) =>\n childrenResult.push(createReactElement(children[key]))\n );\n\n return {\n ...element,\n props: { ...element.props, children: childrenResult },\n };\n }\n\n return {\n ...element,\n props: { ...element.props, children: element.props.children },\n };\n };\n\n const fixedElement = convertChildrenAsArray(element);\n\n const { type, props } = fixedElement;\n\n // Create and return the React element\n return createElement(type ?? 'div', props, ...props.children);\n};\n\nexport type TextEditorProps = {\n dictionary: Dictionary;\n keyPath: KeyPath[];\n section: DictionaryValue;\n locales: Locales[];\n};\n\nconst TranslationTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n locales,\n}: TextEditorProps) => {\n const { locale } = useLocale();\n const { selectedLocales, availableLocales } = useLocaleSwitcherContent();\n\n const sectionContent = (section as TranslationContent<string>)[\n NodeType.Translation\n ] as Record<Locales, string>;\n\n const sectionContentKeys = Object.keys(sectionContent) as Locales[];\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 return (\n <table className=\"w-full gap-2\">\n <tbody className=\"divide-y-[1.5px]\">\n {localesList.map((translationKey) => (\n <tr\n key={translationKey}\n className=\"border-text dark:border-text-dark w-full\"\n lang={translationKey}\n >\n <td className=\"flex w-full flex-col p-2\">\n {selectedLocales.length > 1 && (\n <span className=\"w-full p-2 text-xs\">\n {getLocaleName(translationKey, locale)}\n </span>\n )}\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n keyPath={[\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ]}\n dictionary={dictionary}\n locales={locales}\n >\n {\n (section as TranslationContent<string>)[NodeType.Translation][\n translationKey\n ] as string\n }\n </ContentEditorTextArea>\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n );\n};\n\nconst EnumerationTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n locales,\n}) => {\n const addEditedContent = useEditedContentStore(\n useShallow((s) => s.addEditedContent)\n );\n const { addNewEnumeration } = useDictionary(navigationViewContent);\n\n return (\n <table className=\"w-full table-fixed gap-2\">\n <tbody className=\"divide-y-[1.5px]\">\n {Object.keys(\n (section as EnumerationContent<DictionaryValue>)[NodeType.Enumeration]\n ).map((enumKey) => (\n <tr\n key={enumKey}\n className=\"border-text dark:border-text-dark w-full\"\n >\n <td className=\"border-text dark:border-text-dark w-44 border-r-[1.5px] p-2\">\n <div className=\"flex gap-1\">\n <Button\n label=\"Remove\"\n variant=\"hoverable\"\n size=\"icon-md\"\n color=\"text\"\n Icon={X}\n className=\"w-16\"\n onClick={() =>\n addEditedContent(dictionary.key, undefined, [\n ...keyPath,\n {\n type: NodeType.Enumeration,\n key: enumKey,\n },\n ])\n }\n />\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.key, newValue, keyPath);\n }}\n />\n </div>\n </td>\n <td className=\"w-full p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n keyPath={[\n ...keyPath,\n { type: NodeType.Enumeration, key: enumKey },\n ]}\n dictionary={dictionary}\n locales={locales}\n >\n {\n (section as EnumerationContent<string>)[NodeType.Enumeration][\n enumKey as any\n ] as string\n }\n </ContentEditorTextArea>\n </td>\n </tr>\n ))}\n </tbody>\n\n <tfoot>\n <Button\n label={addNewEnumeration.label}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() =>\n addEditedContent(\n dictionary.key,\n '',\n [...keyPath, { type: NodeType.Enumeration, key: 'unknown' }],\n false\n )\n }\n Icon={Plus}\n className=\"m-2\"\n >\n {addNewEnumeration.text}\n </Button>\n </tfoot>\n </table>\n );\n};\n\nconst ArrayTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n locales,\n}) => {\n const addEditedContent = useEditedContentStore(\n useShallow((s) => s.addEditedContent)\n );\n const { addNewElement } = useDictionary(navigationViewContent);\n\n return (\n <table className=\"w-full gap-2\">\n <tbody className=\"divide-y-[1.5px]\">\n {(section as DictionaryValue[]).map((subSection, index) => (\n <tr\n key={JSON.stringify(subSection)}\n className=\"border-text dark:border-text-dark w-full\"\n >\n <td className=\"p-2\">{index}</td>\n <td className=\"w-full p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n keyPath={[\n ...keyPath,\n {\n type: NodeType.Array,\n key: index,\n },\n ]}\n dictionary={dictionary}\n locales={locales}\n >\n {subSection as string}\n </ContentEditorTextArea>\n </td>\n </tr>\n ))}\n </tbody>\n <tfoot>\n <Button\n label={addNewElement.label}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as DictionaryValue[]).length,\n },\n ];\n addEditedContent(dictionary.key, '', newKeyPath, false);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </tfoot>\n </table>\n );\n};\n\nexport const TextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n locales,\n}) => {\n const { tsxNotEditable } = useDictionary(navigationViewContent);\n const nodeType = getSectionType(section);\n const isEditableSection = getIsEditableSection(section);\n\n if (!isEditableSection) return <></>;\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return (\n <>\n {createReactElement(section as unknown as ReactElement)}\n <span className=\"text-neutral dark:text-neutral-dark text-xs\">\n {tsxNotEditable}\n </span>\n </>\n );\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <TranslationTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n locales={locales}\n />\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <EnumerationTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n locales={locales}\n />\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <ArrayTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n locales={locales}\n />\n );\n }\n }\n\n if (nodeType === NodeType.Text) {\n return (\n <div className=\"border-text dark:border-text-dark w-full border-t-[1.5px] p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n keyPath={keyPath}\n dictionary={dictionary}\n locales={locales}\n >\n {section as string}\n </ContentEditorTextArea>\n </div>\n );\n }\n\n return <>Error loading section</>;\n};\n"],"names":["useEditedContentStore","useShallow","useAuditContentDeclarationField","jsx","ContentEditorTextAreaBase","Button","WandSparkles","element","createElement","useLocale","useLocaleSwitcherContent","NodeType","jsxs","getLocaleName","useDictionary","navigationViewContent","X","EnumKeyInput","renameKey","Plus","getSectionType","getIsEditableSection","Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCO,MAAM,YAAsB,CAAC,YAAY,MAAM,UAAU;AAWhE,MAAM,wBAAwD,CAAC;AAAA,EAC7D;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,mBAAmBA,kDAAA;AAAA,IACvBC,mBAAW,CAAC,MAAM,EAAE,gBAAgB;AAAA,EACtC;AACA,QAAM,EAAE,8BAA8B,WAAW,WAAA,IAC/CC,uBAAAA,gCAAgC;AAGhC,SAAAC,2BAAA,kBAAA;AAAA,IAACC,+CAAA;AAAA,IAAA;AAAA,MACC,SAAQ;AAAA,MACR,iBAAiB,CAAC,aAChB,iBAAiB,WAAW,KAAK,UAAU,OAAO;AAAA,MAEpD,mBACED,2BAAA,kBAAA;AAAA,QAACE,yBAAA;AAAA,QAAA;AAAA,UACC,MAAMC,YAAA;AAAA,UACN,OAAM;AAAA,UACN,SAAQ;AAAA,UACR,MAAK;AAAA,UACL,OAAM;AAAA,UACN,WAAU;AAAA,UACV,WAAW;AAAA,UACX,SAAS,MAAM;AACgB,yCAAA;AAAA,cAC3B,aAAa,KAAK,UAAU,UAAU;AAAA,cACtC;AAAA,cACA;AAAA,YAAA,CACD,EAAE,KAAK,CAAC,aAAa;AAChB,kBAAA,CAAC,SAAS,KAAM;AAEhB,kBAAA;AACI,sBAAA,gBAAgB,SAAS,KAAK;AAEnB,iCAAA,WAAW,KAAK,eAAe,OAAO;AAAA,uBAChD,OAAO;AACd,wBAAQ,MAAM,KAAK;AA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A,EAAK,WAAU,+CACb,UACH,eAAA,CAAA;AAAA,MAAA,GACF;AAAA,IAAA;AAIA,QAAA,aAAaQ,cAAS,aAAa;AAEnC,aAAAR,2BAAA,kBAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAIA,QAAA,aAAaQ,cAAS,aAAa;AAEnC,aAAAR,2BAAA,kBAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAIA,QAAA,aAAaQ,cAAS,OAAO;AAE7B,aAAAR,2BAAA,kBAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAAA,EAEJ;AAGE,MAAA,aAAaQ,cAAS,MAAM;AAE5B,WAAAR,2BAAAA,kBAAAA,IAAC,OAAI,EAAA,WAAU,iEACb,UAAAA,2BAAA,kBAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,SAAQ;AAAA,QACR,cAAW;AAAA,QACX;AAAA,QACA;AAAA,QACA;AAAA,QAEC,UAAA;AAAA,MAAA;AAAA,IAAA,GAEL;AAAA,EAAA;AAIJ,mGAAS,UAAqB,wBAAA,CAAA;AAChC;;;"}
1
+ {"version":3,"file":"TextEditor.cjs","sources":["../../../../src/components/DictionaryFieldEditor/EditorView/TextEditor.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n'use client';\n\nimport { Locales } from '@intlayer/config';\nimport {\n type EnumerationContent,\n type TranslationContent,\n NodeType,\n type KeyPath,\n type DictionaryValue,\n getLocaleName,\n Dictionary,\n} from '@intlayer/core';\nimport { getSectionType } from '@intlayer/editor';\nimport { useEditedContent } from '@intlayer/editor-react';\nimport { Plus, WandSparkles, X } from 'lucide-react';\nimport {\n createElement,\n type ReactElement,\n type ReactNode,\n type FC,\n} from 'react';\n// @ts-ignore react-intlayer not build yet\nimport { useDictionary, useLocale } from 'react-intlayer';\nimport { useAuditContentDeclarationField } from '../../../hooks';\nimport { renameKey } from '../../../utils/object';\nimport { Button } from '../../Button';\nimport {\n ContentEditorTextArea as ContentEditorTextAreaBase,\n ContentEditorTextAreaProps as ContentEditorTextAreaPropsBase,\n} from '../../ContentEditor/ContentEditorTextArea';\nimport { useLocaleSwitcherContent } from '../../LocaleSwitcherContentDropDown';\nimport { EnumKeyInput } from '../EnumKeyInput';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from '../NavigationView/navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\ntype ContentEditorTextAreaProps = Omit<\n ContentEditorTextAreaPropsBase,\n 'onContentChange'\n> & {\n keyPath: KeyPath[];\n dictionary: Dictionary;\n locales: Locales[];\n};\n\nconst ContentEditorTextArea: FC<ContentEditorTextAreaProps> = ({\n keyPath,\n dictionary,\n locales,\n ...props\n}) => {\n const { addEditedContent } = useEditedContent();\n const { auditContentDeclarationField, isLoading: isAuditing } =\n useAuditContentDeclarationField();\n\n return (\n <ContentEditorTextAreaBase\n variant=\"default\"\n onContentChange={(newValue) =>\n addEditedContent(dictionary.key, newValue, keyPath)\n }\n additionalButtons={\n <Button\n Icon={WandSparkles}\n label=\"Audit\"\n variant=\"hoverable\"\n size=\"icon-sm\"\n color=\"text\"\n className=\"cursor-pointer hover:scale-110\"\n isLoading={isAuditing}\n onClick={() => {\n auditContentDeclarationField({\n fileContent: JSON.stringify(dictionary),\n keyPath,\n locales,\n }).then((response) => {\n if (!response.data) return;\n\n try {\n const editedContent = response.data.fileContent as string;\n\n addEditedContent(dictionary.key, editedContent, keyPath);\n } catch (error) {\n console.error(error);\n }\n });\n }}\n />\n }\n {...props}\n />\n );\n};\n\nconst createReactElement = (element: ReactElement) => {\n if (typeof element === 'string') {\n // If it's a string, simply return it (used for text content)\n return element;\n }\n\n const convertChildrenAsArray = (element: ReactElement): ReactElement => {\n if (element?.props && typeof element.props.children === 'object') {\n const childrenResult: ReactNode[] = [];\n const { children } = element.props;\n\n // Create the children elements recursively, if any\n Object.keys(children).forEach((key) =>\n childrenResult.push(createReactElement(children[key]))\n );\n\n return {\n ...element,\n props: { ...element.props, children: childrenResult },\n };\n }\n\n return {\n ...element,\n props: { ...element.props, children: element.props.children },\n };\n };\n\n const fixedElement = convertChildrenAsArray(element);\n\n const { type, props } = fixedElement;\n\n // Create and return the React element\n return createElement(type ?? 'div', props, ...props.children);\n};\n\nexport type TextEditorProps = {\n dictionary: Dictionary;\n keyPath: KeyPath[];\n section: DictionaryValue;\n locales: Locales[];\n};\n\nconst TranslationTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n locales,\n}: TextEditorProps) => {\n const { locale } = useLocale();\n const { selectedLocales, availableLocales } = useLocaleSwitcherContent();\n\n const sectionContent = (section as TranslationContent<string>)[\n NodeType.Translation\n ] as Record<Locales, string>;\n\n const sectionContentKeys = Object.keys(sectionContent) as Locales[];\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 return (\n <table className=\"w-full gap-2\">\n <tbody className=\"divide-y-[1.5px]\">\n {localesList.map((translationKey) => (\n <tr\n key={translationKey}\n className=\"border-text dark:border-text-dark w-full\"\n lang={translationKey}\n >\n <td className=\"flex w-full flex-col p-2\">\n {selectedLocales.length > 1 && (\n <span className=\"w-full p-2 text-xs\">\n {getLocaleName(translationKey, locale)}\n </span>\n )}\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n keyPath={[\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ]}\n dictionary={dictionary}\n locales={locales}\n >\n {\n (section as TranslationContent<string>)[NodeType.Translation][\n translationKey\n ] as string\n }\n </ContentEditorTextArea>\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n );\n};\n\nconst EnumerationTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n locales,\n}) => {\n const { addEditedContent } = useEditedContent();\n const { addNewEnumeration } = useDictionary(navigationViewContent);\n\n return (\n <table className=\"w-full table-fixed gap-2\">\n <tbody className=\"divide-y-[1.5px]\">\n {Object.keys(\n (section as EnumerationContent<DictionaryValue>)[NodeType.Enumeration]\n ).map((enumKey) => (\n <tr\n key={enumKey}\n className=\"border-text dark:border-text-dark w-full\"\n >\n <td className=\"border-text dark:border-text-dark w-44 border-r-[1.5px] p-2\">\n <div className=\"flex gap-1\">\n <Button\n label=\"Remove\"\n variant=\"hoverable\"\n size=\"icon-md\"\n color=\"text\"\n Icon={X}\n className=\"w-16\"\n onClick={() =>\n addEditedContent(dictionary.key, undefined, [\n ...keyPath,\n {\n type: NodeType.Enumeration,\n key: enumKey,\n },\n ])\n }\n />\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.key, newValue, keyPath);\n }}\n />\n </div>\n </td>\n <td className=\"w-full p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n keyPath={[\n ...keyPath,\n { type: NodeType.Enumeration, key: enumKey },\n ]}\n dictionary={dictionary}\n locales={locales}\n >\n {\n (section as EnumerationContent<string>)[NodeType.Enumeration][\n enumKey as any\n ] as string\n }\n </ContentEditorTextArea>\n </td>\n </tr>\n ))}\n </tbody>\n\n <tfoot>\n <Button\n label={addNewEnumeration.label}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() =>\n addEditedContent(\n dictionary.key,\n '',\n [...keyPath, { type: NodeType.Enumeration, key: 'unknown' }],\n false\n )\n }\n Icon={Plus}\n className=\"m-2\"\n >\n {addNewEnumeration.text}\n </Button>\n </tfoot>\n </table>\n );\n};\n\nconst ArrayTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n locales,\n}) => {\n const { addEditedContent } = useEditedContent();\n const { addNewElement } = useDictionary(navigationViewContent);\n\n return (\n <table className=\"w-full gap-2\">\n <tbody className=\"divide-y-[1.5px]\">\n {(section as DictionaryValue[]).map((subSection, index) => (\n <tr\n key={JSON.stringify(subSection)}\n className=\"border-text dark:border-text-dark w-full\"\n >\n <td className=\"p-2\">{index}</td>\n <td className=\"w-full p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n keyPath={[\n ...keyPath,\n {\n type: NodeType.Array,\n key: index,\n },\n ]}\n dictionary={dictionary}\n locales={locales}\n >\n {subSection as string}\n </ContentEditorTextArea>\n </td>\n </tr>\n ))}\n </tbody>\n <tfoot>\n <Button\n label={addNewElement.label}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as DictionaryValue[]).length,\n },\n ];\n addEditedContent(dictionary.key, '', newKeyPath, false);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </tfoot>\n </table>\n );\n};\n\nexport const TextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n locales,\n}) => {\n const { tsxNotEditable } = useDictionary(navigationViewContent);\n const nodeType = getSectionType(section);\n const isEditableSection = getIsEditableSection(section);\n\n if (!isEditableSection) return <></>;\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return (\n <>\n {createReactElement(section as unknown as ReactElement)}\n <span className=\"text-neutral dark:text-neutral-dark text-xs\">\n {tsxNotEditable}\n </span>\n </>\n );\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <TranslationTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n locales={locales}\n />\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <EnumerationTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n locales={locales}\n />\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <ArrayTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n locales={locales}\n />\n );\n }\n }\n\n if (nodeType === NodeType.Text) {\n return (\n <div className=\"border-text dark:border-text-dark w-full border-t-[1.5px] p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n keyPath={keyPath}\n dictionary={dictionary}\n locales={locales}\n >\n {section as string}\n </ContentEditorTextArea>\n </div>\n );\n }\n\n return <>Error loading section</>;\n};\n"],"names":["useEditedContent","useAuditContentDeclarationField","jsx","ContentEditorTextAreaBase","Button","WandSparkles","element","createElement","useLocale","useLocaleSwitcherContent","NodeType","jsxs","getLocaleName","useDictionary","navigationViewContent","X","EnumKeyInput","renameKey","Plus","getSectionType","getIsEditableSection","Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCO,MAAM,YAAsB,CAAC,YAAY,MAAM,UAAU;AAWhE,MAAM,wBAAwD,CAAC;AAAA,EAC7D;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACE,QAAA,EAAE,iBAAiB,IAAIA,6BAAiB;AAC9C,QAAM,EAAE,8BAA8B,WAAW,WAAA,IAC/CC,uBAAAA,gCAAgC;AAGhC,SAAAC,2BAAA,kBAAA;AAAA,IAACC,+CAAA;AAAA,IAAA;AAAA,MACC,SAAQ;AAAA,MACR,iBAAiB,CAAC,aAChB,iBAAiB,WAAW,KAAK,UAAU,OAAO;AAAA,MAEpD,mBACED,2BAAA,kBAAA;AAAA,QAACE,yBAAA;AAAA,QAAA;AAAA,UACC,MAAMC,YAAA;AAAA,UACN,OAAM;AAAA,UACN,SAAQ;AAAA,UAC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ldEditor/EditorView/TextEditor.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAIL,KAAK,OAAO,EACZ,KAAK,eAAe,EAEpB,UAAU,EACX,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAIL,KAAK,EAAE,EACR,MAAM,OAAO,CAAC;AAkBf,eAAO,MAAM,SAAS,EAAE,MAAM,EAAmC,CAAC;AAkGlE,MAAM,MAAM,eAAe,GAAG;IAC5B,UAAU,EAAE,UAAU,CAAC;IACvB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,OAAO,EAAE,eAAe,CAAC;IACzB,OAAO,EAAE,OAAO,EAAE,CAAC;CACpB,CAAC;AA2OF,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CA2E1C,CAAC"}
1
+ {"version":3,"file":"TextEditor.d.ts","sourceRoot":"","sources":["../../../../src/components/DictionaryFieldEditor/EditorView/TextEditor.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAIL,KAAK,OAAO,EACZ,KAAK,eAAe,EAEpB,UAAU,EACX,MAAM,gBAAgB,CAAC;AAIxB,OAAO,EAIL,KAAK,EAAE,EACR,MAAM,OAAO,CAAC;AAef,eAAO,MAAM,SAAS,EAAE,MAAM,EAAmC,CAAC;AAgGlE,MAAM,MAAM,eAAe,GAAG;IAC5B,UAAU,EAAE,UAAU,CAAC;IACvB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,OAAO,EAAE,eAAe,CAAC;IACzB,OAAO,EAAE,OAAO,EAAE,CAAC;CACpB,CAAC;AAuOF,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CA2E1C,CAAC"}
@@ -1,30 +1,18 @@
1
1
  "use client";
2
2
  import { j as jsxRuntimeExports } from "../../../jsx-runtime-DQkoUcjV.js";
3
3
  import { NodeType, getLocaleName } from "@intlayer/core";
4
+ import { getSectionType } from "@intlayer/editor";
5
+ import { useEditedContent } from "@intlayer/editor-react";
4
6
  import { WandSparkles, X, Plus } from "lucide-react";
5
7
  import { createElement } from "react";
6
8
  import { useDictionary, useLocale } from "react-intlayer";
7
- import { u as useShallow } from "../../../shallow-m9BpCkKh.js";
8
9
  import "../../../hooks/useScrollBlockage/useScrollBlockageStore.mjs";
9
10
  import "../../../hooks/useAsync/useAsyncStateStore.mjs";
10
11
  import { useAuditContentDeclarationField } from "../../../hooks/intlayerAPIHooks.mjs";
11
- import "@intlayer/dictionaries-entry";
12
12
  import "deepmerge";
13
- import { getSectionType } from "../../../utils/dictionary.mjs";
14
13
  import { renameKey } from "../../../utils/object.mjs";
15
14
  import { Button } from "../../Button/Button.mjs";
16
15
  import { ContentEditorTextArea as ContentEditorTextArea$1 } from "../../ContentEditor/ContentEditorTextArea.mjs";
17
- import { useEditedContentStore } from "../../DictionaryEditor/useEditedContentStore.mjs";
18
- import "../../DictionaryEditor/useEditionPanelStore.mjs";
19
- import "clsx";
20
- import "tailwind-merge";
21
- import "../../EditableField/EditableFieldInput.mjs";
22
- import "../../EditableField/EditableFieldTextArea.mjs";
23
- import "../../Form/FormBase.mjs";
24
- import "../../Form/FormField.mjs";
25
- import "../../../Form-DlqjTz3u.js";
26
- import "../../DictionaryEditor/validDictionaryChangeButtons.content.mjs";
27
- import "zod";
28
16
  import "@intlayer/config/client";
29
17
  import "fuse.js";
30
18
  import "../../Container/index.mjs";
@@ -45,9 +33,7 @@ const ContentEditorTextArea = ({
45
33
  locales,
46
34
  ...props
47
35
  }) => {
48
- const addEditedContent = useEditedContentStore(
49
- useShallow((s) => s.addEditedContent)
50
- );
36
+ const { addEditedContent } = useEditedContent();
51
37
  const { auditContentDeclarationField, isLoading: isAuditing } = useAuditContentDeclarationField();
52
38
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
53
39
  ContentEditorTextArea$1,
@@ -157,9 +143,7 @@ const EnumerationTextEditor = ({
157
143
  dictionary,
158
144
  locales
159
145
  }) => {
160
- const addEditedContent = useEditedContentStore(
161
- useShallow((s) => s.addEditedContent)
162
- );
146
+ const { addEditedContent } = useEditedContent();
163
147
  const { addNewEnumeration } = useDictionary(navigationViewContent);
164
148
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("table", { className: "w-full table-fixed gap-2", children: [
165
149
  /* @__PURE__ */ jsxRuntimeExports.jsx("tbody", { className: "divide-y-[1.5px]", children: Object.keys(
@@ -252,9 +236,7 @@ const ArrayTextEditor = ({
252
236
  dictionary,
253
237
  locales
254
238
  }) => {
255
- const addEditedContent = useEditedContentStore(
256
- useShallow((s) => s.addEditedContent)
257
- );
239
+ const { addEditedContent } = useEditedContent();
258
240
  const { addNewElement } = useDictionary(navigationViewContent);
259
241
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("table", { className: "w-full gap-2", children: [
260
242
  /* @__PURE__ */ jsxRuntimeExports.jsx("tbody", { className: "divide-y-[1.5px]", children: section.map((subSection, index) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
@@ -1 +1 @@
1
- {"version":3,"file":"TextEditor.mjs","sources":["../../../../src/components/DictionaryFieldEditor/EditorView/TextEditor.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n'use client';\n\nimport { Locales } from '@intlayer/config';\nimport {\n type EnumerationContent,\n type TranslationContent,\n NodeType,\n type KeyPath,\n type DictionaryValue,\n getLocaleName,\n Dictionary,\n} from '@intlayer/core';\nimport { Plus, WandSparkles, X } from 'lucide-react';\nimport {\n createElement,\n type ReactElement,\n type ReactNode,\n type FC,\n} from 'react';\n// @ts-ignore react-intlayer not build yet\nimport { useDictionary, useLocale } from 'react-intlayer';\nimport { useShallow } from 'zustand/react/shallow';\nimport { useAuditContentDeclarationField } from '../../../hooks';\nimport { getSectionType } from '../../../utils/dictionary';\nimport { renameKey } from '../../../utils/object';\nimport { Button } from '../../Button';\nimport {\n ContentEditorTextArea as ContentEditorTextAreaBase,\n ContentEditorTextAreaProps as ContentEditorTextAreaPropsBase,\n} from '../../ContentEditor/ContentEditorTextArea';\nimport { useEditedContentStore } from '../../DictionaryEditor';\nimport { useLocaleSwitcherContent } from '../../LocaleSwitcherContentDropDown';\nimport { EnumKeyInput } from '../EnumKeyInput';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from '../NavigationView/navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\ntype ContentEditorTextAreaProps = Omit<\n ContentEditorTextAreaPropsBase,\n 'onContentChange'\n> & {\n keyPath: KeyPath[];\n dictionary: Dictionary;\n locales: Locales[];\n};\n\nconst ContentEditorTextArea: FC<ContentEditorTextAreaProps> = ({\n keyPath,\n dictionary,\n locales,\n ...props\n}) => {\n const addEditedContent = useEditedContentStore(\n useShallow((s) => s.addEditedContent)\n );\n const { auditContentDeclarationField, isLoading: isAuditing } =\n useAuditContentDeclarationField();\n\n return (\n <ContentEditorTextAreaBase\n variant=\"default\"\n onContentChange={(newValue) =>\n addEditedContent(dictionary.key, newValue, keyPath)\n }\n additionalButtons={\n <Button\n Icon={WandSparkles}\n label=\"Audit\"\n variant=\"hoverable\"\n size=\"icon-sm\"\n color=\"text\"\n className=\"cursor-pointer hover:scale-110\"\n isLoading={isAuditing}\n onClick={() => {\n auditContentDeclarationField({\n fileContent: JSON.stringify(dictionary),\n keyPath,\n locales,\n }).then((response) => {\n if (!response.data) return;\n\n try {\n const editedContent = response.data.fileContent as string;\n\n addEditedContent(dictionary.key, editedContent, keyPath);\n } catch (error) {\n console.error(error);\n }\n });\n }}\n />\n }\n {...props}\n />\n );\n};\n\nconst createReactElement = (element: ReactElement) => {\n if (typeof element === 'string') {\n // If it's a string, simply return it (used for text content)\n return element;\n }\n\n const convertChildrenAsArray = (element: ReactElement): ReactElement => {\n if (element?.props && typeof element.props.children === 'object') {\n const childrenResult: ReactNode[] = [];\n const { children } = element.props;\n\n // Create the children elements recursively, if any\n Object.keys(children).forEach((key) =>\n childrenResult.push(createReactElement(children[key]))\n );\n\n return {\n ...element,\n props: { ...element.props, children: childrenResult },\n };\n }\n\n return {\n ...element,\n props: { ...element.props, children: element.props.children },\n };\n };\n\n const fixedElement = convertChildrenAsArray(element);\n\n const { type, props } = fixedElement;\n\n // Create and return the React element\n return createElement(type ?? 'div', props, ...props.children);\n};\n\nexport type TextEditorProps = {\n dictionary: Dictionary;\n keyPath: KeyPath[];\n section: DictionaryValue;\n locales: Locales[];\n};\n\nconst TranslationTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n locales,\n}: TextEditorProps) => {\n const { locale } = useLocale();\n const { selectedLocales, availableLocales } = useLocaleSwitcherContent();\n\n const sectionContent = (section as TranslationContent<string>)[\n NodeType.Translation\n ] as Record<Locales, string>;\n\n const sectionContentKeys = Object.keys(sectionContent) as Locales[];\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 return (\n <table className=\"w-full gap-2\">\n <tbody className=\"divide-y-[1.5px]\">\n {localesList.map((translationKey) => (\n <tr\n key={translationKey}\n className=\"border-text dark:border-text-dark w-full\"\n lang={translationKey}\n >\n <td className=\"flex w-full flex-col p-2\">\n {selectedLocales.length > 1 && (\n <span className=\"w-full p-2 text-xs\">\n {getLocaleName(translationKey, locale)}\n </span>\n )}\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n keyPath={[\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ]}\n dictionary={dictionary}\n locales={locales}\n >\n {\n (section as TranslationContent<string>)[NodeType.Translation][\n translationKey\n ] as string\n }\n </ContentEditorTextArea>\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n );\n};\n\nconst EnumerationTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n locales,\n}) => {\n const addEditedContent = useEditedContentStore(\n useShallow((s) => s.addEditedContent)\n );\n const { addNewEnumeration } = useDictionary(navigationViewContent);\n\n return (\n <table className=\"w-full table-fixed gap-2\">\n <tbody className=\"divide-y-[1.5px]\">\n {Object.keys(\n (section as EnumerationContent<DictionaryValue>)[NodeType.Enumeration]\n ).map((enumKey) => (\n <tr\n key={enumKey}\n className=\"border-text dark:border-text-dark w-full\"\n >\n <td className=\"border-text dark:border-text-dark w-44 border-r-[1.5px] p-2\">\n <div className=\"flex gap-1\">\n <Button\n label=\"Remove\"\n variant=\"hoverable\"\n size=\"icon-md\"\n color=\"text\"\n Icon={X}\n className=\"w-16\"\n onClick={() =>\n addEditedContent(dictionary.key, undefined, [\n ...keyPath,\n {\n type: NodeType.Enumeration,\n key: enumKey,\n },\n ])\n }\n />\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.key, newValue, keyPath);\n }}\n />\n </div>\n </td>\n <td className=\"w-full p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n keyPath={[\n ...keyPath,\n { type: NodeType.Enumeration, key: enumKey },\n ]}\n dictionary={dictionary}\n locales={locales}\n >\n {\n (section as EnumerationContent<string>)[NodeType.Enumeration][\n enumKey as any\n ] as string\n }\n </ContentEditorTextArea>\n </td>\n </tr>\n ))}\n </tbody>\n\n <tfoot>\n <Button\n label={addNewEnumeration.label}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() =>\n addEditedContent(\n dictionary.key,\n '',\n [...keyPath, { type: NodeType.Enumeration, key: 'unknown' }],\n false\n )\n }\n Icon={Plus}\n className=\"m-2\"\n >\n {addNewEnumeration.text}\n </Button>\n </tfoot>\n </table>\n );\n};\n\nconst ArrayTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n locales,\n}) => {\n const addEditedContent = useEditedContentStore(\n useShallow((s) => s.addEditedContent)\n );\n const { addNewElement } = useDictionary(navigationViewContent);\n\n return (\n <table className=\"w-full gap-2\">\n <tbody className=\"divide-y-[1.5px]\">\n {(section as DictionaryValue[]).map((subSection, index) => (\n <tr\n key={JSON.stringify(subSection)}\n className=\"border-text dark:border-text-dark w-full\"\n >\n <td className=\"p-2\">{index}</td>\n <td className=\"w-full p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n keyPath={[\n ...keyPath,\n {\n type: NodeType.Array,\n key: index,\n },\n ]}\n dictionary={dictionary}\n locales={locales}\n >\n {subSection as string}\n </ContentEditorTextArea>\n </td>\n </tr>\n ))}\n </tbody>\n <tfoot>\n <Button\n label={addNewElement.label}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as DictionaryValue[]).length,\n },\n ];\n addEditedContent(dictionary.key, '', newKeyPath, false);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </tfoot>\n </table>\n );\n};\n\nexport const TextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n locales,\n}) => {\n const { tsxNotEditable } = useDictionary(navigationViewContent);\n const nodeType = getSectionType(section);\n const isEditableSection = getIsEditableSection(section);\n\n if (!isEditableSection) return <></>;\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return (\n <>\n {createReactElement(section as unknown as ReactElement)}\n <span className=\"text-neutral dark:text-neutral-dark text-xs\">\n {tsxNotEditable}\n </span>\n </>\n );\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <TranslationTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n locales={locales}\n />\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <EnumerationTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n locales={locales}\n />\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <ArrayTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n locales={locales}\n />\n );\n }\n }\n\n if (nodeType === NodeType.Text) {\n return (\n <div className=\"border-text dark:border-text-dark w-full border-t-[1.5px] p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n keyPath={keyPath}\n dictionary={dictionary}\n locales={locales}\n >\n {section as string}\n </ContentEditorTextArea>\n </div>\n );\n }\n\n return <>Error loading section</>;\n};\n"],"names":["jsx","ContentEditorTextAreaBase","element","jsxs","Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCO,MAAM,YAAsB,CAAC,YAAY,MAAM,UAAU;AAWhE,MAAM,wBAAwD,CAAC;AAAA,EAC7D;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,mBAAmB;AAAA,IACvB,WAAW,CAAC,MAAM,EAAE,gBAAgB;AAAA,EACtC;AACA,QAAM,EAAE,8BAA8B,WAAW,WAAA,IAC/C,gCAAgC;AAGhC,SAAAA,kCAAA;AAAA,IAACC;AAAAA,IAAA;AAAA,MACC,SAAQ;AAAA,MACR,iBAAiB,CAAC,aAChB,iBAAiB,WAAW,KAAK,UAAU,OAAO;AAAA,MAEpD,mBACED,kCAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,MAAM;AAAA,UACN,OAAM;AAAA,UACN,SAAQ;AAAA,UACR,MAAK;AAAA,UACL,OAAM;AAAA,UACN,WAAU;AAAA,UACV,WAAW;AAAA,UACX,SAAS,MAAM;AACgB,yCAAA;AAAA,cAC3B,aAAa,KAAK,UAAU,UAAU;AAAA,cACtC;AAAA,cACA;AAAA,YAAA,CACD,EAAE,KAAK,CAAC,aAAa;AAChB,kBAAA,CAAC,SAAS,KAAM;AAEhB,kBAAA;AACI,sB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AAA,QAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAIA,QAAA,aAAa,SAAS,OAAO;AAE7B,aAAAA,kCAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAAA,EAEJ;AAGE,MAAA,aAAa,SAAS,MAAM;AAE5B,WAAAA,kCAAAA,IAAC,OAAI,EAAA,WAAU,iEACb,UAAAA,kCAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,SAAQ;AAAA,QACR,cAAW;AAAA,QACX;AAAA,QACA;AAAA,QACA;AAAA,QAEC,UAAA;AAAA,MAAA;AAAA,IAAA,GAEL;AAAA,EAAA;AAIJ,6EAAS,UAAqB,wBAAA,CAAA;AAChC;"}
1
+ {"version":3,"file":"TextEditor.mjs","sources":["../../../../src/components/DictionaryFieldEditor/EditorView/TextEditor.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n'use client';\n\nimport { Locales } from '@intlayer/config';\nimport {\n type EnumerationContent,\n type TranslationContent,\n NodeType,\n type KeyPath,\n type DictionaryValue,\n getLocaleName,\n Dictionary,\n} from '@intlayer/core';\nimport { getSectionType } from '@intlayer/editor';\nimport { useEditedContent } from '@intlayer/editor-react';\nimport { Plus, WandSparkles, X } from 'lucide-react';\nimport {\n createElement,\n type ReactElement,\n type ReactNode,\n type FC,\n} from 'react';\n// @ts-ignore react-intlayer not build yet\nimport { useDictionary, useLocale } from 'react-intlayer';\nimport { useAuditContentDeclarationField } from '../../../hooks';\nimport { renameKey } from '../../../utils/object';\nimport { Button } from '../../Button';\nimport {\n ContentEditorTextArea as ContentEditorTextAreaBase,\n ContentEditorTextAreaProps as ContentEditorTextAreaPropsBase,\n} from '../../ContentEditor/ContentEditorTextArea';\nimport { useLocaleSwitcherContent } from '../../LocaleSwitcherContentDropDown';\nimport { EnumKeyInput } from '../EnumKeyInput';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from '../NavigationView/navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\ntype ContentEditorTextAreaProps = Omit<\n ContentEditorTextAreaPropsBase,\n 'onContentChange'\n> & {\n keyPath: KeyPath[];\n dictionary: Dictionary;\n locales: Locales[];\n};\n\nconst ContentEditorTextArea: FC<ContentEditorTextAreaProps> = ({\n keyPath,\n dictionary,\n locales,\n ...props\n}) => {\n const { addEditedContent } = useEditedContent();\n const { auditContentDeclarationField, isLoading: isAuditing } =\n useAuditContentDeclarationField();\n\n return (\n <ContentEditorTextAreaBase\n variant=\"default\"\n onContentChange={(newValue) =>\n addEditedContent(dictionary.key, newValue, keyPath)\n }\n additionalButtons={\n <Button\n Icon={WandSparkles}\n label=\"Audit\"\n variant=\"hoverable\"\n size=\"icon-sm\"\n color=\"text\"\n className=\"cursor-pointer hover:scale-110\"\n isLoading={isAuditing}\n onClick={() => {\n auditContentDeclarationField({\n fileContent: JSON.stringify(dictionary),\n keyPath,\n locales,\n }).then((response) => {\n if (!response.data) return;\n\n try {\n const editedContent = response.data.fileContent as string;\n\n addEditedContent(dictionary.key, editedContent, keyPath);\n } catch (error) {\n console.error(error);\n }\n });\n }}\n />\n }\n {...props}\n />\n );\n};\n\nconst createReactElement = (element: ReactElement) => {\n if (typeof element === 'string') {\n // If it's a string, simply return it (used for text content)\n return element;\n }\n\n const convertChildrenAsArray = (element: ReactElement): ReactElement => {\n if (element?.props && typeof element.props.children === 'object') {\n const childrenResult: ReactNode[] = [];\n const { children } = element.props;\n\n // Create the children elements recursively, if any\n Object.keys(children).forEach((key) =>\n childrenResult.push(createReactElement(children[key]))\n );\n\n return {\n ...element,\n props: { ...element.props, children: childrenResult },\n };\n }\n\n return {\n ...element,\n props: { ...element.props, children: element.props.children },\n };\n };\n\n const fixedElement = convertChildrenAsArray(element);\n\n const { type, props } = fixedElement;\n\n // Create and return the React element\n return createElement(type ?? 'div', props, ...props.children);\n};\n\nexport type TextEditorProps = {\n dictionary: Dictionary;\n keyPath: KeyPath[];\n section: DictionaryValue;\n locales: Locales[];\n};\n\nconst TranslationTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n locales,\n}: TextEditorProps) => {\n const { locale } = useLocale();\n const { selectedLocales, availableLocales } = useLocaleSwitcherContent();\n\n const sectionContent = (section as TranslationContent<string>)[\n NodeType.Translation\n ] as Record<Locales, string>;\n\n const sectionContentKeys = Object.keys(sectionContent) as Locales[];\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 return (\n <table className=\"w-full gap-2\">\n <tbody className=\"divide-y-[1.5px]\">\n {localesList.map((translationKey) => (\n <tr\n key={translationKey}\n className=\"border-text dark:border-text-dark w-full\"\n lang={translationKey}\n >\n <td className=\"flex w-full flex-col p-2\">\n {selectedLocales.length > 1 && (\n <span className=\"w-full p-2 text-xs\">\n {getLocaleName(translationKey, locale)}\n </span>\n )}\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n keyPath={[\n ...keyPath,\n { type: NodeType.Translation, key: translationKey },\n ]}\n dictionary={dictionary}\n locales={locales}\n >\n {\n (section as TranslationContent<string>)[NodeType.Translation][\n translationKey\n ] as string\n }\n </ContentEditorTextArea>\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n );\n};\n\nconst EnumerationTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n locales,\n}) => {\n const { addEditedContent } = useEditedContent();\n const { addNewEnumeration } = useDictionary(navigationViewContent);\n\n return (\n <table className=\"w-full table-fixed gap-2\">\n <tbody className=\"divide-y-[1.5px]\">\n {Object.keys(\n (section as EnumerationContent<DictionaryValue>)[NodeType.Enumeration]\n ).map((enumKey) => (\n <tr\n key={enumKey}\n className=\"border-text dark:border-text-dark w-full\"\n >\n <td className=\"border-text dark:border-text-dark w-44 border-r-[1.5px] p-2\">\n <div className=\"flex gap-1\">\n <Button\n label=\"Remove\"\n variant=\"hoverable\"\n size=\"icon-md\"\n color=\"text\"\n Icon={X}\n className=\"w-16\"\n onClick={() =>\n addEditedContent(dictionary.key, undefined, [\n ...keyPath,\n {\n type: NodeType.Enumeration,\n key: enumKey,\n },\n ])\n }\n />\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.key, newValue, keyPath);\n }}\n />\n </div>\n </td>\n <td className=\"w-full p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n keyPath={[\n ...keyPath,\n { type: NodeType.Enumeration, key: enumKey },\n ]}\n dictionary={dictionary}\n locales={locales}\n >\n {\n (section as EnumerationContent<string>)[NodeType.Enumeration][\n enumKey as any\n ] as string\n }\n </ContentEditorTextArea>\n </td>\n </tr>\n ))}\n </tbody>\n\n <tfoot>\n <Button\n label={addNewEnumeration.label}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() =>\n addEditedContent(\n dictionary.key,\n '',\n [...keyPath, { type: NodeType.Enumeration, key: 'unknown' }],\n false\n )\n }\n Icon={Plus}\n className=\"m-2\"\n >\n {addNewEnumeration.text}\n </Button>\n </tfoot>\n </table>\n );\n};\n\nconst ArrayTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n locales,\n}) => {\n const { addEditedContent } = useEditedContent();\n const { addNewElement } = useDictionary(navigationViewContent);\n\n return (\n <table className=\"w-full gap-2\">\n <tbody className=\"divide-y-[1.5px]\">\n {(section as DictionaryValue[]).map((subSection, index) => (\n <tr\n key={JSON.stringify(subSection)}\n className=\"border-text dark:border-text-dark w-full\"\n >\n <td className=\"p-2\">{index}</td>\n <td className=\"w-full p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n keyPath={[\n ...keyPath,\n {\n type: NodeType.Array,\n key: index,\n },\n ]}\n dictionary={dictionary}\n locales={locales}\n >\n {subSection as string}\n </ContentEditorTextArea>\n </td>\n </tr>\n ))}\n </tbody>\n <tfoot>\n <Button\n label={addNewElement.label}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as DictionaryValue[]).length,\n },\n ];\n addEditedContent(dictionary.key, '', newKeyPath, false);\n }}\n Icon={Plus}\n >\n {addNewElement.text}\n </Button>\n </tfoot>\n </table>\n );\n};\n\nexport const TextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionary,\n locales,\n}) => {\n const { tsxNotEditable } = useDictionary(navigationViewContent);\n const nodeType = getSectionType(section);\n const isEditableSection = getIsEditableSection(section);\n\n if (!isEditableSection) return <></>;\n\n if (typeof section === 'object') {\n if (nodeType === NodeType.ReactNode) {\n return (\n <>\n {createReactElement(section as unknown as ReactElement)}\n <span className=\"text-neutral dark:text-neutral-dark text-xs\">\n {tsxNotEditable}\n </span>\n </>\n );\n }\n\n if (nodeType === NodeType.Translation) {\n return (\n <TranslationTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n locales={locales}\n />\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <EnumerationTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n locales={locales}\n />\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <ArrayTextEditor\n dictionary={dictionary}\n keyPath={keyPath}\n section={section}\n locales={locales}\n />\n );\n }\n }\n\n if (nodeType === NodeType.Text) {\n return (\n <div className=\"border-text dark:border-text-dark w-full border-t-[1.5px] p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n keyPath={keyPath}\n dictionary={dictionary}\n locales={locales}\n >\n {section as string}\n </ContentEditorTextArea>\n </div>\n );\n }\n\n return <>Error loading section</>;\n};\n"],"names":["jsx","ContentEditorTextAreaBase","element","jsxs","Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCO,MAAM,YAAsB,CAAC,YAAY,MAAM,UAAU;AAWhE,MAAM,wBAAwD,CAAC;AAAA,EAC7D;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACE,QAAA,EAAE,iBAAiB,IAAI,iBAAiB;AAC9C,QAAM,EAAE,8BAA8B,WAAW,WAAA,IAC/C,gCAAgC;AAGhC,SAAAA,kCAAA;AAAA,IAACC;AAAAA,IAAA;AAAA,MACC,SAAQ;AAAA,MACR,iBAAiB,CAAC,aAChB,iBAAiB,WAAW,KAAK,UAAU,OAAO;AAAA,MAEpD,mBACED,kCAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,MAAM;AAAA,UACN,OAAM;AAAA,UACN,SAAQ;AAAA,UACR,MAAK;AAAA,UACL,OAAM;AAAA,UACN,WAAU;AAAA,UACV,WAAW;AAAA,UACX,SAAS,MAAM;AACgB,yCAAA;AAAA,cAC3B,aAAa,KAAK,UAAU,UAAU;AAAA,cACtC;AAAA,cACA;AAAA,YAAA,CACD,EAAE,KAAK,CAAC,aAAa;AAChB,kBAAA,CAAC,SAAS,KAAM;AAEhB,kBAAA;AACI,sBAAA,gBAAgB,SAAS,KAAK;AAEnB,iCAAA,WAAW,KAAK,eAAe,OAAO;AAAA,uBAChD,OAAO;AACd,wBAAQ,MAAM,KAAK;AAAA,cAAA;AAAA,YACrB,CACD;AAAA,UAAA;AAAA,QACH;AAAA,MACF;AAAA,MAED,GAAG;AAAA,IAAA;AAAA,EACN;AAEJ;AAEA,MAAM,qBAAqB,CAAC,YAA0B;AAChD,MAAA,OAAO,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UAAAA,kCAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,SAAQ;AAAA,QACR,cAAW;AAAA,QACX;AAAA,QACA;AAAA,QACA;AAAA,QAEC,UAAA;AAAA,MAAA;AAAA,IAAA,GAEL;AAAA,EAAA;AAIJ,6EAAS,UAAqB,wBAAA,CAAA;AAChC;"}
@@ -1,38 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("../../jsx-runtime-CgFM7lM3.cjs");
4
+ const editorReact = require("@intlayer/editor-react");
4
5
  const require$$0 = require("react");
5
- const shallow = require("../../shallow-lhDIFtEp.cjs");
6
- const components_DictionaryEditor_useEditedContentStore = require("../DictionaryEditor/useEditedContentStore.cjs");
7
- require("../DictionaryEditor/useEditionPanelStore.cjs");
8
- require("@intlayer/core");
9
- require("lucide-react");
10
- require("clsx");
11
- require("tailwind-merge");
12
- require("../Button/Button.cjs");
13
- require("../EditableField/EditableFieldInput.cjs");
14
- require("../EditableField/EditableFieldTextArea.cjs");
15
- require("react-intlayer");
16
- require("../../hooks/useScrollBlockage/useScrollBlockageStore.cjs");
17
- require("../../hooks/useAsync/useAsyncStateStore.cjs");
18
- require("../../index-DFc7og1d.cjs");
19
- require("@intlayer/config/client");
20
- require("../Toaster/Toast.cjs");
21
- require("@intlayer/dictionaries-entry");
22
- require("deepmerge");
23
- require("../Form/FormBase.cjs");
24
- require("../Form/FormField.cjs");
25
- require("../../Form-CSMiPnjC.cjs");
26
- require("../DictionaryEditor/validDictionaryChangeButtons.content.cjs");
27
- require("zod");
28
6
  const components_IDE_MonacoCode = require("../IDE/MonacoCode.cjs");
29
7
  const JSONEditor = ({ dictionary, isDarkMode }) => {
30
- const { setEditedContent, editedContent } = components_DictionaryEditor_useEditedContentStore.useEditedContentStore(
31
- shallow.useShallow((s) => ({
32
- editedContent: s.editedContent,
33
- setEditedContent: s.setEditedContent
34
- }))
35
- );
8
+ const { setEditedContent, editedContent } = editorReact.useEditedContent();
36
9
  const isValidJSON = (jsonString) => {
37
10
  try {
38
11
  JSON.parse(jsonString);
@@ -1 +1 @@
1
- {"version":3,"file":"JSONEditor.cjs","sources":["../../../src/components/DictionaryFieldEditor/JSONEditor.tsx"],"sourcesContent":["import { Dictionary } from '@intlayer/core';\nimport { useMemo, type FC } from 'react';\nimport { useShallow } from 'zustand/react/shallow';\nimport { useEditedContentStore } from '../DictionaryEditor';\nimport { MonacoCode } from '../IDE/MonacoCode';\n\ntype JSONEditorProps = {\n dictionary: Dictionary;\n isDarkMode?: boolean;\n};\n\nexport const JSONEditor: FC<JSONEditorProps> = ({ dictionary, isDarkMode }) => {\n const { setEditedContent, editedContent } = useEditedContentStore(\n useShallow((s) => ({\n editedContent: s.editedContent,\n setEditedContent: s.setEditedContent,\n }))\n );\n\n const isValidJSON = (jsonString: string): boolean => {\n try {\n JSON.parse(jsonString);\n return true; // Valid JSON\n } catch (_error) {\n return false; // Invalid JSON\n }\n };\n\n const displayedContent = useMemo(\n () => editedContent[dictionary.key]?.content ?? dictionary?.content ?? {},\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [dictionary]\n );\n\n return (\n <div className=\"overflow-hidden rounded-md\">\n <MonacoCode\n language=\"json\"\n onChange={(content) => {\n if (isValidJSON(content ?? '{}')) {\n setEditedContent(dictionary.key, JSON.parse(content ?? '{}'));\n }\n }}\n isDarkMode={isDarkMode}\n >\n {JSON.stringify(displayedContent, null, 2)}\n </MonacoCode>\n </div>\n );\n};\n"],"names":["useEditedContentStore","useShallow","useMemo","jsx","MonacoCode"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWO,MAAM,aAAkC,CAAC,EAAE,YAAY,iBAAiB;AACvE,QAAA,EAAE,kBAAkB,cAAA,IAAkBA,kDAAA;AAAA,IAC1CC,QAAA,WAAW,CAAC,OAAO;AAAA,MACjB,eAAe,EAAE;AAAA,MACjB,kBAAkB,EAAE;AAAA,IAAA,EACpB;AAAA,EACJ;AAEM,QAAA,cAAc,CAAC,eAAgC;AAC/C,QAAA;AACF,WAAK,MAAM,UAAU;AACd,aAAA;AAAA,aACA,QAAQ;AACR,aAAA;AAAA,IAAA;AAAA,EAEX;AAEA,QAAM,mBAAmBC,WAAA;AAAA,IACvB,MAAM,cAAc,WAAW,GAAG,GAAG,WAAW,YAAY,WAAW,CAAC;AAAA;AAAA,IAExE,CAAC,UAAU;AAAA,EACb;AAGE,SAAAC,2BAAAA,kBAAAA,IAAC,OAAI,EAAA,WAAU,8BACb,UAAAA,2BAAA,kBAAA;AAAA,IAACC,0BAAA;AAAA,IAAA;AAAA,MACC,UAAS;AAAA,MACT,UAAU,CAAC,YAAY;AACjB,YAAA,YAAY,WAAW,IAAI,GAAG;AAChC,2BAAiB,WAAW,KAAK,KAAK,MAAM,WAAW,IAAI,CAAC;AAAA,QAAA;AAAA,MAEhE;AAAA,MACA;AAAA,MAEC,UAAK,KAAA,UAAU,kBAAkB,MAAM,CAAC;AAAA,IAAA;AAAA,EAAA,GAE7C;AAEJ;;"}
1
+ {"version":3,"file":"JSONEditor.cjs","sources":["../../../src/components/DictionaryFieldEditor/JSONEditor.tsx"],"sourcesContent":["import { Dictionary } from '@intlayer/core';\nimport { useEditedContent } from '@intlayer/editor-react';\nimport { useMemo, type FC } from 'react';\nimport { MonacoCode } from '../IDE/MonacoCode';\n\ntype JSONEditorProps = {\n dictionary: Dictionary;\n isDarkMode?: boolean;\n};\n\nexport const JSONEditor: FC<JSONEditorProps> = ({ dictionary, isDarkMode }) => {\n const { setEditedContent, editedContent } = useEditedContent();\n\n const isValidJSON = (jsonString: string): boolean => {\n try {\n JSON.parse(jsonString);\n return true; // Valid JSON\n } catch (_error) {\n return false; // Invalid JSON\n }\n };\n\n const displayedContent = useMemo(\n () => editedContent[dictionary.key]?.content ?? dictionary?.content ?? {},\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [dictionary]\n );\n\n return (\n <div className=\"overflow-hidden rounded-md\">\n <MonacoCode\n language=\"json\"\n onChange={(content) => {\n if (isValidJSON(content ?? '{}')) {\n setEditedContent(dictionary.key, JSON.parse(content ?? '{}'));\n }\n }}\n isDarkMode={isDarkMode}\n >\n {JSON.stringify(displayedContent, null, 2)}\n </MonacoCode>\n </div>\n );\n};\n"],"names":["useEditedContent","useMemo","jsx","MonacoCode"],"mappings":";;;;;;AAUO,MAAM,aAAkC,CAAC,EAAE,YAAY,iBAAiB;AAC7E,QAAM,EAAE,kBAAkB,cAAc,IAAIA,6BAAiB;AAEvD,QAAA,cAAc,CAAC,eAAgC;AAC/C,QAAA;AACF,WAAK,MAAM,UAAU;AACd,aAAA;AAAA,aACA,QAAQ;AACR,aAAA;AAAA,IAAA;AAAA,EAEX;AAEA,QAAM,mBAAmBC,WAAA;AAAA,IACvB,MAAM,cAAc,WAAW,GAAG,GAAG,WAAW,YAAY,WAAW,CAAC;AAAA;AAAA,IAExE,CAAC,UAAU;AAAA,EACb;AAGE,SAAAC,2BAAAA,kBAAAA,IAAC,OAAI,EAAA,WAAU,8BACb,UAAAA,2BAAA,kBAAA;AAAA,IAACC,0BAAA;AAAA,IAAA;AAAA,MACC,UAAS;AAAA,MACT,UAAU,CAAC,YAAY;AACjB,YAAA,YAAY,WAAW,IAAI,GAAG;AAChC,2BAAiB,WAAW,KAAK,KAAK,MAAM,WAAW,IAAI,CAAC;AAAA,QAAA;AAAA,MAEhE;AAAA,MACA;AAAA,MAEC,UAAK,KAAA,UAAU,kBAAkB,MAAM,CAAC;AAAA,IAAA;AAAA,EAAA,GAE7C;AAEJ;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"JSONEditor.d.ts","sourceRoot":"","sources":["../../../src/components/DictionaryFieldEditor/JSONEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAW,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAKzC,KAAK,eAAe,GAAG;IACrB,UAAU,EAAE,UAAU,CAAC;IACvB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CAsC1C,CAAC"}
1
+ {"version":3,"file":"JSONEditor.d.ts","sourceRoot":"","sources":["../../../src/components/DictionaryFieldEditor/JSONEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAAW,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAGzC,KAAK,eAAe,GAAG;IACrB,UAAU,EAAE,UAAU,CAAC;IACvB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CAiC1C,CAAC"}