@intlayer/design-system 3.3.5 → 3.3.6

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 (83) hide show
  1. package/dist/.vite/manifest.json +20 -0
  2. package/dist/components/DictionaryEditor/DictionaryEditor.cjs +9 -6
  3. package/dist/components/DictionaryEditor/DictionaryEditor.cjs.map +1 -1
  4. package/dist/components/DictionaryEditor/DictionaryEditor.d.ts.map +1 -1
  5. package/dist/components/DictionaryEditor/DictionaryEditor.mjs +9 -6
  6. package/dist/components/DictionaryEditor/DictionaryEditor.mjs.map +1 -1
  7. package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.cjs +3 -2
  8. package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.cjs.map +1 -1
  9. package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.d.ts.map +1 -1
  10. package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.mjs +3 -2
  11. package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.mjs.map +1 -1
  12. package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.cjs +6 -3
  13. package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.cjs.map +1 -1
  14. package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.d.ts.map +1 -1
  15. package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.mjs +6 -3
  16. package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.mjs.map +1 -1
  17. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.cjs +3 -2
  18. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.cjs.map +1 -1
  19. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.d.ts.map +1 -1
  20. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs +3 -2
  21. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs.map +1 -1
  22. package/dist/components/DictionaryFieldEditor/EditorView/EditorView.cjs +12 -9
  23. package/dist/components/DictionaryFieldEditor/EditorView/EditorView.cjs.map +1 -1
  24. package/dist/components/DictionaryFieldEditor/EditorView/EditorView.d.ts.map +1 -1
  25. package/dist/components/DictionaryFieldEditor/EditorView/EditorView.mjs +12 -9
  26. package/dist/components/DictionaryFieldEditor/EditorView/EditorView.mjs.map +1 -1
  27. package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.cjs +13 -4
  28. package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.cjs.map +1 -1
  29. package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.d.ts.map +1 -1
  30. package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.mjs +13 -4
  31. package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.mjs.map +1 -1
  32. package/dist/components/DictionaryFieldEditor/JSONEditor.cjs +7 -4
  33. package/dist/components/DictionaryFieldEditor/JSONEditor.cjs.map +1 -1
  34. package/dist/components/DictionaryFieldEditor/JSONEditor.d.ts.map +1 -1
  35. package/dist/components/DictionaryFieldEditor/JSONEditor.mjs +7 -4
  36. package/dist/components/DictionaryFieldEditor/JSONEditor.mjs.map +1 -1
  37. package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.cjs +6 -3
  38. package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.cjs.map +1 -1
  39. package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.d.ts.map +1 -1
  40. package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs +6 -3
  41. package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs.map +1 -1
  42. package/dist/components/DictionaryFieldEditor/NodeEditor.cjs +10 -7
  43. package/dist/components/DictionaryFieldEditor/NodeEditor.cjs.map +1 -1
  44. package/dist/components/DictionaryFieldEditor/NodeEditor.d.ts.map +1 -1
  45. package/dist/components/DictionaryFieldEditor/NodeEditor.mjs +10 -7
  46. package/dist/components/DictionaryFieldEditor/NodeEditor.mjs.map +1 -1
  47. package/dist/components/DictionaryFieldEditor/NodeTypeSelector.cjs +6 -3
  48. package/dist/components/DictionaryFieldEditor/NodeTypeSelector.cjs.map +1 -1
  49. package/dist/components/DictionaryFieldEditor/NodeTypeSelector.d.ts.map +1 -1
  50. package/dist/components/DictionaryFieldEditor/NodeTypeSelector.mjs +6 -3
  51. package/dist/components/DictionaryFieldEditor/NodeTypeSelector.mjs.map +1 -1
  52. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs +3 -2
  53. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs.map +1 -1
  54. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.d.ts.map +1 -1
  55. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs +3 -2
  56. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs.map +1 -1
  57. package/dist/components/RightDrawer/RightDrawer.cjs +19 -5
  58. package/dist/components/RightDrawer/RightDrawer.cjs.map +1 -1
  59. package/dist/components/RightDrawer/RightDrawer.d.ts +2 -0
  60. package/dist/components/RightDrawer/RightDrawer.d.ts.map +1 -1
  61. package/dist/components/RightDrawer/RightDrawer.mjs +19 -5
  62. package/dist/components/RightDrawer/RightDrawer.mjs.map +1 -1
  63. package/dist/components/RightDrawer/index.cjs +0 -1
  64. package/dist/components/RightDrawer/index.cjs.map +1 -1
  65. package/dist/components/RightDrawer/index.mjs +1 -2
  66. package/dist/components/RightDrawer/useRightDrawerStore.cjs +11 -10
  67. package/dist/components/RightDrawer/useRightDrawerStore.cjs.map +1 -1
  68. package/dist/components/RightDrawer/useRightDrawerStore.d.ts +2 -2
  69. package/dist/components/RightDrawer/useRightDrawerStore.d.ts.map +1 -1
  70. package/dist/components/RightDrawer/useRightDrawerStore.mjs +11 -10
  71. package/dist/components/RightDrawer/useRightDrawerStore.mjs.map +1 -1
  72. package/dist/components/index.cjs +0 -1
  73. package/dist/components/index.cjs.map +1 -1
  74. package/dist/components/index.mjs +1 -2
  75. package/dist/hooks/useAsync/useAsync.cjs +3 -46
  76. package/dist/hooks/useAsync/useAsync.cjs.map +1 -1
  77. package/dist/hooks/useAsync/useAsync.mjs +3 -46
  78. package/dist/hooks/useAsync/useAsync.mjs.map +1 -1
  79. package/dist/shallow-lhDIFtEp.cjs +48 -0
  80. package/dist/shallow-lhDIFtEp.cjs.map +1 -0
  81. package/dist/shallow-m9BpCkKh.js +49 -0
  82. package/dist/shallow-m9BpCkKh.js.map +1 -0
  83. package/package.json +14 -14
@@ -1 +1 @@
1
- {"version":3,"file":"EditorView.cjs","sources":["../../../../src/components/DictionaryFieldEditor/EditorView/EditorView.tsx"],"sourcesContent":["'use client';\n\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 { 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};\n\nexport const EditorView: FC<EditorViewProps> = ({\n dictionaryKey,\n dictionary,\n}) => {\n const { focusedContent, setFocusedContentKeyPath } = useEditionPanelStore(\n (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((s) => ({\n editedContent: s.editedContent,\n renameEditedContent: s.renameEditedContent,\n addEditedContent: s.addEditedContent,\n removeEditedContent: s.removeEditedContent,\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 dictionaryKey={dictionaryKey}\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.value}\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.value}\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.value}\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","useDictionary","editorViewContent","useEditedContentStore","getDictionaryValueByKeyPath","useMemo","getIsEditableSection","sentenceToCamelCase","jsxs","Fragment","jsx","TextEditor","Label","EditableFieldInput","camelCaseToSentence","NodeTypeSelector","Button","RotateCcw","X"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BO,MAAM,aAAkC,CAAC;AAAA,EAC9C;AAAA,EACA;AACF,MAAM;AACE,QAAA,EAAE,gBAAgB,yBAAA,IAA6BA,iDAAA;AAAA,IACnD,CAAC,OAAO;AAAA,MACN,0BAA0B,EAAE;AAAA,MAC5B,gBAAgB,EAAE;AAAA,IAAA;AAAA,EACpB;AAEI,QAAA,UAAU,gBAAgB,WAAW;AAC3C,QAAM,iBAAiB,QAAQ,QAAQ,SAAS,CAAC,GAAG,OAAO;AAC3D,QAA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,gBACC,OAAO,cAAc,MAAM;AAAA,gBAC3B,SAAQ;AAAA,gBACR,OAAM;AAAA,gBACN,MAAMC,YAAA;AAAA,gBACN,SAAS,MAAM,oBAAoB,eAAe,OAAO;AAAA,gBAExD,UAAc,cAAA;AAAA,cAAA;AAAA,YACjB;AAAA,YAEFP,2BAAA,kBAAA;AAAA,cAACM,yBAAA;AAAA,cAAA;AAAA,gBACC,OAAO,aAAa,MAAM;AAAA,gBAC1B,SAAQ;AAAA,gBACR,OAAM;AAAA,gBACN,MAAME,YAAA;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,YAChB;AAAA,UAAA,GACF;AAAA,QAAA;AAAA,MAAA;AAAA,MA7DG,KAAK,UAAU,gBAAgB,OAAO;AAAA,IAiE7C,IAAAR,2BAAA,kBAAA,IAAC,QAAK,EAAA,WAAU,MAAM,CAAA;AAAA,EAE1B,EAAA,CAAA;AAEJ;;"}
1
+ {"version":3,"file":"EditorView.cjs","sources":["../../../../src/components/DictionaryFieldEditor/EditorView/EditorView.tsx"],"sourcesContent":["'use client';\n\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};\n\nexport const EditorView: FC<EditorViewProps> = ({\n dictionaryKey,\n dictionary,\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 dictionaryKey={dictionaryKey}\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.value}\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.value}\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.value}\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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../../src/components/DictionaryFieldEditor/EditorView/EditorView.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE/D,OAAO,EAAW,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAoBzC,KAAK,eAAe,GAAG;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,UAAU,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CA8I1C,CAAC"}
1
+ {"version":3,"file":"EditorView.d.ts","sourceRoot":"","sources":["../../../../src/components/DictionaryFieldEditor/EditorView/EditorView.tsx"],"names":[],"mappings":"AAEA,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;CACxB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CAgJ1C,CAAC"}
@@ -3,6 +3,7 @@ import { j as jsxRuntimeExports } from "../../../jsx-runtime-DaNGiM0W.js";
3
3
  import { RotateCcw, X } from "lucide-react";
4
4
  import { useMemo } from "react";
5
5
  import { useDictionary } from "react-intlayer";
6
+ import { u as useShallow } from "../../../shallow-m9BpCkKh.js";
6
7
  import { EditableFieldInput } from "../../EditableField/EditableFieldInput.mjs";
7
8
  import "../../EditableField/EditableFieldTextArea.mjs";
8
9
  import { camelCaseToSentence, sentenceToCamelCase } from "../../../utils/camelCase.mjs";
@@ -35,10 +36,10 @@ const EditorView = ({
35
36
  dictionary
36
37
  }) => {
37
38
  const { focusedContent, setFocusedContentKeyPath } = useEditionPanelStore(
38
- (s) => ({
39
+ useShallow((s) => ({
39
40
  setFocusedContentKeyPath: s.setFocusedContentKeyPath,
40
41
  focusedContent: s.focusedContent
41
- })
42
+ }))
42
43
  );
43
44
  const keyPath = focusedContent?.keyPath ?? [];
44
45
  const initialKeyName = keyPath[keyPath.length - 1]?.key ?? "";
@@ -48,12 +49,14 @@ const EditorView = ({
48
49
  renameEditedContent,
49
50
  addEditedContent,
50
51
  removeEditedContent
51
- } = useEditedContentStore((s) => ({
52
- editedContent: s.editedContent,
53
- renameEditedContent: s.renameEditedContent,
54
- addEditedContent: s.addEditedContent,
55
- removeEditedContent: s.removeEditedContent
56
- }));
52
+ } = useEditedContentStore(
53
+ useShallow((s) => ({
54
+ editedContent: s.editedContent,
55
+ renameEditedContent: s.renameEditedContent,
56
+ addEditedContent: s.addEditedContent,
57
+ removeEditedContent: s.removeEditedContent
58
+ }))
59
+ );
57
60
  const editedSection = editedContent[dictionaryKey]?.content ? getDictionaryValueByKeyPath(editedContent[dictionaryKey].content, keyPath) : void 0;
58
61
  const dictionarySection = getDictionaryValueByKeyPath(
59
62
  dictionary.content,
@@ -91,7 +94,7 @@ const EditorView = ({
91
94
  {
92
95
  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",
93
96
  children: [
94
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex w-full flex-wrap items-start justify-between gap-6", children: [
97
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex w-full flex-wrap items-start justify-between gap-6", children: [
95
98
  typeof initialKeyName === "string" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-3", children: [
96
99
  /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { children: titleInput.label }),
97
100
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap items-center gap-4", children: [
@@ -1 +1 @@
1
- {"version":3,"file":"EditorView.mjs","sources":["../../../../src/components/DictionaryFieldEditor/EditorView/EditorView.tsx"],"sourcesContent":["'use client';\n\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 { 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};\n\nexport const EditorView: FC<EditorViewProps> = ({\n dictionaryKey,\n dictionary,\n}) => {\n const { focusedContent, setFocusedContentKeyPath } = useEditionPanelStore(\n (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((s) => ({\n editedContent: s.editedContent,\n renameEditedContent: s.renameEditedContent,\n addEditedContent: s.addEditedContent,\n removeEditedContent: s.removeEditedContent,\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 dictionaryKey={dictionaryKey}\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.value}\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.value}\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.value}\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BO,MAAM,aAAkC,CAAC;AAAA,EAC9C;AAAA,EACA;AACF,MAAM;AACE,QAAA,EAAE,gBAAgB,yBAAA,IAA6B;AAAA,IACnD,CAAC,OAAO;AAAA,MACN,0BAA0B,EAAE;AAAA,MAC5B,gBAAgB,EAAE;AAAA,IAAA;AAAA,EACpB;AAEI,QAAA,UAAU,gBAAgB,WAAW;AAC3C,QAAM,iBAAiB,QAAQ,QAAQ,SAAS,CAAC,GAAG,OAAO;AAC3D,QAAM,EAAE,YAAY,cAAc,kBAAkB,kBAClD,cAAc,iBAAiB;AAE3B,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACE,sBAAsB,CAAC,OAAO;AAAA,IAChC,eAAe,EAAE;AAAA,IACjB,qBAAqB,EAAE;AAAA,IACvB,kBAAkB,EAAE;AAAA,IACpB,qBAAqB,EAAE;AAAA,EACvB,EAAA;AAEI,QAAA,gBAAgB,cAAc,aAAa,GAAG,UAChD,4BAA4B,cAAc,aAAa,EAAE,SAAS,OAAO,IACzE;AAEJ,QAAM,oBAAoB;AAAA,IACxB,WAAW;AAAA,IACX;AAAA,EAAA;AAGF,QAAM,UAAU,iBAAiB;AAEjC,QAAM,WAAW;AAAA,IACf,MACE,iBACA,KAAK,UAAU,aAAa,MAAM,KAAK,UAAU,iBAAiB;AAAA,IACpE,CAAC,eAAe,iBAAiB;AAAA,EAAA;AAG7B,QAAA,oBAAoB,qBAAqB,OAAO;AAEhD,QAAA,sBAAsB,CAAC,YAAoB;AACzC,UA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A,YAAA,GACF;AAAA,mDAGD,OACC,EAAA,UAAA;AAAA,cAACE,kCAAAA,IAAA,OAAA,EAAO,2BAAiB,MAAM,CAAA;AAAA,cAE/BA,kCAAA;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBACC;AAAA,kBACA;AAAA,kBACA;AAAA,gBAAA;AAAA,cACF;AAAA,YAAA,GACF;AAAA,UAAA,GACF;AAAA,UACC,QAAQ,SAAS,KACfF,kCAAA,KAAA,OAAA,EAAI,WAAU,sBACZ,UAAA;AAAA,YACC,YAAAE,kCAAA;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,OAAO,cAAc,MAAM;AAAA,gBAC3B,SAAQ;AAAA,gBACR,OAAM;AAAA,gBACN,MAAM;AAAA,gBACN,SAAS,MAAM,oBAAoB,eAAe,OAAO;AAAA,gBAExD,UAAc,cAAA;AAAA,cAAA;AAAA,YACjB;AAAA,YAEFA,kCAAA;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,OAAO,aAAa,MAAM;AAAA,gBAC1B,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,YAChB;AAAA,UAAA,GACF;AAAA,QAAA;AAAA,MAAA;AAAA,MA7DG,KAAK,UAAU,gBAAgB,OAAO;AAAA,IAiE7C,IAAAA,kCAAA,IAAC,QAAK,EAAA,WAAU,MAAM,CAAA;AAAA,EAE1B,EAAA,CAAA;AAEJ;"}
1
+ {"version":3,"file":"EditorView.mjs","sources":["../../../../src/components/DictionaryFieldEditor/EditorView/EditorView.tsx"],"sourcesContent":["'use client';\n\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};\n\nexport const EditorView: FC<EditorViewProps> = ({\n dictionaryKey,\n dictionary,\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 dictionaryKey={dictionaryKey}\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.value}\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.value}\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.value}\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BO,MAAM,aAAkC,CAAC;AAAA,EAC9C;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,EAAA;AAEE,QAAA,UAAU,gBAAgB,WAAW;AAC3C,QAAM,iBAAiB,QAAQ,QAAQ,SAAS,CAAC,GAAG,OAAO;AAC3D,QAAM,EAAE,YAAY,cAAc,kBAAkB,kBAClD,cAAc,iBAAiB;AAE3B,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACE;AAAA,IACF,WAAW,CAAC,OAAO;AAAA,MACjB,eAAe,EAAE;AAAA,MACjB,qBAAqB,EAAE;AAAA,MACvB,kBAAkB,EAAE;AAAA,MACpB,qBAAqB,EAAE;AAAA,IAAA,EACvB;AAAA,EAAA;AAGE,QAAA,gBAAgB,cAAc,aAAa,GAAG,UAChD,4BAA4B,cAAc,aAAa,EAAE,SAAS,OAAO,IACzE;AAEJ,QAAM,oBAAoB;AAAA,IACxB,WAAW;AAAA,IACX;AAAA,EAAA;AAGF,QAAM,UAAU,iBAAiB;AAEjC,QAAM,WAAW;AAAA,IACf,MACE,iBACA,KAAK,UAAU,aAAa,MAAM,KAAK,UAAU,iBAAiB;AAAA,IACpE,CAAC,eAAe,iBAAiB;AAAA,EAAA;AAG7B,QAAA,oBAAoB,qBAAqB,OAAO;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Ae;AAAA,gBAAA,GACnB;AAAA,cAAA,GACF;AAAA,YAAA,GACF;AAAA,mDAGD,OACC,EAAA,UAAA;AAAA,cAACE,kCAAAA,IAAA,OAAA,EAAO,2BAAiB,MAAM,CAAA;AAAA,cAE/BA,kCAAA;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBACC;AAAA,kBACA;AAAA,kBACA;AAAA,gBAAA;AAAA,cACF;AAAA,YAAA,GACF;AAAA,UAAA,GACF;AAAA,UACC,QAAQ,SAAS,KACfF,kCAAA,KAAA,OAAA,EAAI,WAAU,sBACZ,UAAA;AAAA,YACC,YAAAE,kCAAA;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,OAAO,cAAc,MAAM;AAAA,gBAC3B,SAAQ;AAAA,gBACR,OAAM;AAAA,gBACN,MAAM;AAAA,gBACN,SAAS,MAAM,oBAAoB,eAAe,OAAO;AAAA,gBAExD,UAAc,cAAA;AAAA,cAAA;AAAA,YACjB;AAAA,YAEFA,kCAAA;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,OAAO,aAAa,MAAM;AAAA,gBAC1B,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,YAChB;AAAA,UAAA,GACF;AAAA,QAAA;AAAA,MAAA;AAAA,MA7DG,KAAK,UAAU,gBAAgB,OAAO;AAAA,IAiE7C,IAAAA,kCAAA,IAAC,QAAK,EAAA,WAAU,MAAM,CAAA;AAAA,EAE1B,EAAA,CAAA;AAEJ;"}
@@ -7,6 +7,7 @@ const core = require("@intlayer/core");
7
7
  const lucideReact = require("lucide-react");
8
8
  const require$$0 = require("react");
9
9
  const reactIntlayer = require("react-intlayer");
10
+ const shallow = require("../../../shallow-lhDIFtEp.cjs");
10
11
  const utils_dictionary = require("../../../utils/dictionary.cjs");
11
12
  const utils_object = require("../../../utils/object.cjs");
12
13
  const components_Button_Button = require("../../Button/Button.cjs");
@@ -63,7 +64,9 @@ const TranslationTextEditor = ({
63
64
  dictionaryKey
64
65
  }) => {
65
66
  const { locales } = client.getConfiguration().internationalization;
66
- const addEditedContent = components_DictionaryEditor_useEditedContentStore.useEditedContentStore((s) => s.addEditedContent);
67
+ const addEditedContent = components_DictionaryEditor_useEditedContentStore.useEditedContentStore(
68
+ shallow.useShallow((s) => s.addEditedContent)
69
+ );
67
70
  return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("table", { className: "w-full gap-2", children: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("tbody", { children: locales.map((translationKey) => /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs(
68
71
  "tr",
69
72
  {
@@ -96,7 +99,9 @@ const EnumerationTextEditor = ({
96
99
  keyPath,
97
100
  dictionaryKey
98
101
  }) => {
99
- const addEditedContent = components_DictionaryEditor_useEditedContentStore.useEditedContentStore((s) => s.addEditedContent);
102
+ const addEditedContent = components_DictionaryEditor_useEditedContentStore.useEditedContentStore(
103
+ shallow.useShallow((s) => s.addEditedContent)
104
+ );
100
105
  const { addNewEnumeration } = reactIntlayer.useDictionary(components_DictionaryFieldEditor_NavigationView_navigationViewNode_content.navigationViewContent);
101
106
  return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs("table", { className: "w-full table-fixed gap-2", children: [
102
107
  /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("tbody", { children: Object.keys(
@@ -189,7 +194,9 @@ const ArrayTextEditor = ({
189
194
  keyPath,
190
195
  dictionaryKey
191
196
  }) => {
192
- const addEditedContent = components_DictionaryEditor_useEditedContentStore.useEditedContentStore((s) => s.addEditedContent);
197
+ const addEditedContent = components_DictionaryEditor_useEditedContentStore.useEditedContentStore(
198
+ shallow.useShallow((s) => s.addEditedContent)
199
+ );
193
200
  const { addNewElement } = reactIntlayer.useDictionary(components_DictionaryFieldEditor_NavigationView_navigationViewNode_content.navigationViewContent);
194
201
  return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs("table", { className: "w-full gap-2", children: [
195
202
  /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx("tbody", { children: section.map((subSection, index) => /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs(
@@ -247,7 +254,9 @@ const TextEditor = ({
247
254
  keyPath,
248
255
  dictionaryKey
249
256
  }) => {
250
- const addEditedContent = components_DictionaryEditor_useEditedContentStore.useEditedContentStore((s) => s.addEditedContent);
257
+ const addEditedContent = components_DictionaryEditor_useEditedContentStore.useEditedContentStore(
258
+ shallow.useShallow((s) => s.addEditedContent)
259
+ );
251
260
  const { tsxNotEditable } = reactIntlayer.useDictionary(components_DictionaryFieldEditor_NavigationView_navigationViewNode_content.navigationViewContent);
252
261
  const nodeType = utils_dictionary.getSectionType(section);
253
262
  const isEditableSection = components_DictionaryFieldEditor_getIsEditableSection.getIsEditableSection(section);
@@ -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 { getConfiguration } from '@intlayer/config/client';\nimport {\n type EnumerationContent,\n type TranslationContent,\n NodeType,\n type KeyPath,\n type DictionaryValue,\n getLocaleName,\n} from '@intlayer/core';\nimport { Plus, 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 } from 'react-intlayer';\nimport { getSectionType } from '../../../utils/dictionary';\nimport { renameKey } from '../../../utils/object';\nimport { Button } from '../../Button';\nimport { ContentEditorTextArea } from '../../ContentEditor/ContentEditorTextArea';\nimport { useEditedContentStore } from '../../DictionaryEditor';\nimport { EnumKeyInput } from '../EnumKeyInput';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from '../NavigationView/navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\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 dictionaryKey: string;\n keyPath: KeyPath[];\n section: DictionaryValue;\n};\n\nconst TranslationTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionaryKey,\n}: TextEditorProps) => {\n const { locales } = getConfiguration().internationalization;\n const addEditedContent = useEditedContentStore((s) => s.addEditedContent);\n\n return (\n <table className=\"w-full gap-2\">\n <tbody>\n {locales.map((translationKey) => (\n <tr\n key={translationKey}\n className=\"border-text dark:border-text-dark w-full border-t-[1.5px]\"\n lang={translationKey}\n >\n <td className=\"border-text dark:border-text-dark border-r-[1.5px] p-2\">\n {getLocaleName(translationKey)}\n </td>\n <td className=\"w-full p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n onContentChange={(newValue) =>\n addEditedContent(dictionaryKey, newValue, [\n ...keyPath,\n {\n type: NodeType.Translation,\n key: translationKey,\n },\n ])\n }\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 dictionaryKey,\n}) => {\n const addEditedContent = useEditedContentStore((s) => s.addEditedContent);\n const { addNewEnumeration } = useDictionary(navigationViewContent);\n\n return (\n <table className=\"w-full table-fixed gap-2\">\n <tbody>\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 border-y-[1.5px]\"\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(dictionaryKey, 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(dictionaryKey, 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 onContentChange={(newValue) =>\n addEditedContent(dictionaryKey, newValue, [\n ...keyPath,\n {\n type: NodeType.Enumeration,\n key: enumKey,\n },\n ])\n }\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.value}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() =>\n addEditedContent(\n dictionaryKey,\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 dictionaryKey,\n}) => {\n const addEditedContent = useEditedContentStore((s) => s.addEditedContent);\n const { addNewElement } = useDictionary(navigationViewContent);\n\n return (\n <table className=\"w-full gap-2\">\n <tbody>\n {(section as DictionaryValue[]).map((subSection, index) => (\n <tr\n key={JSON.stringify(subSection)}\n className=\"border-text dark:border-text-dark w-full border-t-[1.5px]\"\n >\n <td className=\"border-text dark:border-text-dark border-r-[1.5px] p-2\">\n {index}\n </td>\n <td className=\"w-full p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n onContentChange={(newValue) => {\n addEditedContent(dictionaryKey, newValue, [\n ...keyPath,\n {\n type: NodeType.Array,\n key: index,\n },\n ]);\n }}\n >\n {subSection as string}\n </ContentEditorTextArea>\n </td>\n </tr>\n ))}\n </tbody>\n <tfoot>\n <Button\n label={addNewElement.label.value}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as DictionaryValue[]).length,\n },\n ];\n addEditedContent(dictionaryKey, '', 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 dictionaryKey,\n}) => {\n const addEditedContent = useEditedContentStore((s) => s.addEditedContent);\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 dictionaryKey={dictionaryKey}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <EnumerationTextEditor\n dictionaryKey={dictionaryKey}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <ArrayTextEditor\n dictionaryKey={dictionaryKey}\n keyPath={keyPath}\n section={section}\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 onContentChange={(newValue) =>\n addEditedContent(dictionaryKey, newValue, keyPath)\n }\n >\n {section as string}\n </ContentEditorTextArea>\n </div>\n );\n }\n\n return <>Error loading section</>;\n};\n"],"names":["element","createElement","getConfiguration","useEditedContentStore","jsx","jsxs","getLocaleName","ContentEditorTextArea","NodeType","useDictionary","navigationViewContent","Button","X","EnumKeyInput","renameKey","Plus","getSectionType","getIsEditableSection","Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BO,MAAM,YAAsB,CAAC,YAAY,MAAM,UAAU;AAEhE,MAAM,qBAAqB,CAAC,YAA0B;AAChD,MAAA,OAAO,YAAY,UAAU;AAExB,WAAA;AAAA,EACT;AAEM,QAAA,yBAAyB,CAACA,aAAwC;AACtE,QAAIA,UAAS,SAAS,OAAOA,SAAQ,MAAM,aAAa,UAAU;AAChE,YAAM,iBAA8B,CAAA;AAC9B,YAAA,EAAE,SAAS,IAAIA,SAAQ;AAGtB,aAAA,KAAK,QAAQ,EAAE;AAAA,QAAQ,CAAC,QAC7B,eAAe,KAAK,mBAAmB,SAAS,GAAG,CAAC,CAAC;AAAA,MAAA;AAGhD,aAAA;AAAA,QACL,GAAGA;AAAAA,QACH,OAAO,EAAE,GAAGA,SAAQ,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iB,CAAC,aAChB,iBAAiB,eAAe,UAAU,OAAO;AAAA,QAGlD,UAAA;AAAA,MAAA;AAAA,IAEL,EAAA,CAAA;AAAA,EAEJ;AAEA,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 { getConfiguration } from '@intlayer/config/client';\nimport {\n type EnumerationContent,\n type TranslationContent,\n NodeType,\n type KeyPath,\n type DictionaryValue,\n getLocaleName,\n} from '@intlayer/core';\nimport { Plus, 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 } from 'react-intlayer';\nimport { useShallow } from 'zustand/react/shallow';\nimport { getSectionType } from '../../../utils/dictionary';\nimport { renameKey } from '../../../utils/object';\nimport { Button } from '../../Button';\nimport { ContentEditorTextArea } from '../../ContentEditor/ContentEditorTextArea';\nimport { useEditedContentStore } from '../../DictionaryEditor';\nimport { EnumKeyInput } from '../EnumKeyInput';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from '../NavigationView/navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\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 dictionaryKey: string;\n keyPath: KeyPath[];\n section: DictionaryValue;\n};\n\nconst TranslationTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionaryKey,\n}: TextEditorProps) => {\n const { locales } = getConfiguration().internationalization;\n const addEditedContent = useEditedContentStore(\n useShallow((s) => s.addEditedContent)\n );\n\n return (\n <table className=\"w-full gap-2\">\n <tbody>\n {locales.map((translationKey) => (\n <tr\n key={translationKey}\n className=\"border-text dark:border-text-dark w-full border-t-[1.5px]\"\n lang={translationKey}\n >\n <td className=\"border-text dark:border-text-dark border-r-[1.5px] p-2\">\n {getLocaleName(translationKey)}\n </td>\n <td className=\"w-full p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n onContentChange={(newValue) =>\n addEditedContent(dictionaryKey, newValue, [\n ...keyPath,\n {\n type: NodeType.Translation,\n key: translationKey,\n },\n ])\n }\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 dictionaryKey,\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>\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 border-y-[1.5px]\"\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(dictionaryKey, 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(dictionaryKey, 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 onContentChange={(newValue) =>\n addEditedContent(dictionaryKey, newValue, [\n ...keyPath,\n {\n type: NodeType.Enumeration,\n key: enumKey,\n },\n ])\n }\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.value}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() =>\n addEditedContent(\n dictionaryKey,\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 dictionaryKey,\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>\n {(section as DictionaryValue[]).map((subSection, index) => (\n <tr\n key={JSON.stringify(subSection)}\n className=\"border-text dark:border-text-dark w-full border-t-[1.5px]\"\n >\n <td className=\"border-text dark:border-text-dark border-r-[1.5px] p-2\">\n {index}\n </td>\n <td className=\"w-full p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n onContentChange={(newValue) => {\n addEditedContent(dictionaryKey, newValue, [\n ...keyPath,\n {\n type: NodeType.Array,\n key: index,\n },\n ]);\n }}\n >\n {subSection as string}\n </ContentEditorTextArea>\n </td>\n </tr>\n ))}\n </tbody>\n <tfoot>\n <Button\n label={addNewElement.label.value}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as DictionaryValue[]).length,\n },\n ];\n addEditedContent(dictionaryKey, '', 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 dictionaryKey,\n}) => {\n const addEditedContent = useEditedContentStore(\n useShallow((s) => s.addEditedContent)\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 dictionaryKey={dictionaryKey}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <EnumerationTextEditor\n dictionaryKey={dictionaryKey}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <ArrayTextEditor\n dictionaryKey={dictionaryKey}\n keyPath={keyPath}\n section={section}\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 onContentChange={(newValue) =>\n addEditedContent(dictionaryKey, newValue, keyPath)\n }\n >\n {section as string}\n </ContentEditorTextArea>\n </div>\n );\n }\n\n return <>Error loading section</>;\n};\n"],"names":["element","createElement","getConfiguration","useEditedContentStore","useShallow","jsx","jsxs","getLocaleName","ContentEditorTextArea","NodeType","useDictionary","navigationViewContent","Button","X","EnumKeyInput","renameKey","Plus","getSectionType","getIsEditableSection","Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BO,MAAM,YAAsB,CAAC,YAAY,MAAM,UAAU;AAEhE,MAAM,qBAAqB,CAAC,YAA0B;AAChD,MAAA,OAAO,YAAY,UAAU;AAExB,WAAA;AAAA,EACT;AAEM,QAAA,yBAAyB,CAACA,aAAwC;AACtE,QAAIA,UAAS,SAAS,OAAOA,SAAQ,MAAM,aAAa,UAAU;AAChE,YAAM,iBAA8B,CAAA;AAC9B,YAAA,EAAE,SAAS,IAAIA,SAAQ;AAGtB,aAAA,KAAK,QAAQ,EAAE;AAAA,QAAQ,CAAC,QAC7B,eAAe,KAAK,mBAAmB,SAAS,GAAG,CAAC,CAAC;AAAA,MAAA;AAGhD,aAAA;AAAA,QACL,GAAGA;AAAAA,QACH,OAAO,EAAE,GAAGA,SAAQ,OAAO,UAAU,eAAe;AAAA,MAAA;AAAA,IAExD;AAEO,WAAA;AAAA,MACL,GAAGA;AAAAA,MACH,OAAO,EAAE,GAAGA,SAAQ,OAAO,UAAUA,SAAQ,MAAM,SAAS;AAAA,IAAA;AAAA,EAC9D;AAGI,QAAA,eAAe,uBAAuB,OAAO;AAE7C,QAAA,EAAE,MAAM,MAAU,IAAA;AAGxB,SAAOC,WAAAA,cAAc,QAAQ,OAAO,OAAO,GAAG,MAAM,QAAQ;AAC9D;AAQA,MAAM,wBAA6C,CAAC;AAAA,EAClD;AAAA,EACA;AAAA,EACA;AACF,MAAuB;AACrB,QAAM,EAAE,QAAA,IAAYC,OAAA,iBAAA,EAAmB;AACvC,QAAM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M,gBAAgB,CAAC;AAExB,OAAO,EAIL,KAAK,EAAE,EACR,MAAM,OAAO,CAAC;AAYf,eAAO,MAAM,SAAS,EAAE,MAAM,EAAmC,CAAC;AAsClE,MAAM,MAAM,eAAe,GAAG;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,OAAO,EAAE,eAAe,CAAC;CAC1B,CAAC;AA6NF,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CAwE1C,CAAC"}
1
+ {"version":3,"file":"TextEditor.d.ts","sourceRoot":"","sources":["../../../../src/components/DictionaryFieldEditor/EditorView/TextEditor.tsx"],"names":[],"mappings":"AAIA,OAAO,EAIL,KAAK,OAAO,EACZ,KAAK,eAAe,EAErB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAIL,KAAK,EAAE,EACR,MAAM,OAAO,CAAC;AAaf,eAAO,MAAM,SAAS,EAAE,MAAM,EAAmC,CAAC;AAsClE,MAAM,MAAM,eAAe,GAAG;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,OAAO,EAAE,eAAe,CAAC;CAC1B,CAAC;AAmOF,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CA0E1C,CAAC"}
@@ -5,6 +5,7 @@ import { NodeType, getLocaleName } from "@intlayer/core";
5
5
  import { X, Plus } from "lucide-react";
6
6
  import { createElement } from "react";
7
7
  import { useDictionary } from "react-intlayer";
8
+ import { u as useShallow } from "../../../shallow-m9BpCkKh.js";
8
9
  import { getSectionType } from "../../../utils/dictionary.mjs";
9
10
  import { renameKey } from "../../../utils/object.mjs";
10
11
  import { Button } from "../../Button/Button.mjs";
@@ -61,7 +62,9 @@ const TranslationTextEditor = ({
61
62
  dictionaryKey
62
63
  }) => {
63
64
  const { locales } = getConfiguration().internationalization;
64
- const addEditedContent = useEditedContentStore((s) => s.addEditedContent);
65
+ const addEditedContent = useEditedContentStore(
66
+ useShallow((s) => s.addEditedContent)
67
+ );
65
68
  return /* @__PURE__ */ jsxRuntimeExports.jsx("table", { className: "w-full gap-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx("tbody", { children: locales.map((translationKey) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
66
69
  "tr",
67
70
  {
@@ -94,7 +97,9 @@ const EnumerationTextEditor = ({
94
97
  keyPath,
95
98
  dictionaryKey
96
99
  }) => {
97
- const addEditedContent = useEditedContentStore((s) => s.addEditedContent);
100
+ const addEditedContent = useEditedContentStore(
101
+ useShallow((s) => s.addEditedContent)
102
+ );
98
103
  const { addNewEnumeration } = useDictionary(navigationViewContent);
99
104
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("table", { className: "w-full table-fixed gap-2", children: [
100
105
  /* @__PURE__ */ jsxRuntimeExports.jsx("tbody", { children: Object.keys(
@@ -187,7 +192,9 @@ const ArrayTextEditor = ({
187
192
  keyPath,
188
193
  dictionaryKey
189
194
  }) => {
190
- const addEditedContent = useEditedContentStore((s) => s.addEditedContent);
195
+ const addEditedContent = useEditedContentStore(
196
+ useShallow((s) => s.addEditedContent)
197
+ );
191
198
  const { addNewElement } = useDictionary(navigationViewContent);
192
199
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("table", { className: "w-full gap-2", children: [
193
200
  /* @__PURE__ */ jsxRuntimeExports.jsx("tbody", { children: section.map((subSection, index) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
@@ -245,7 +252,9 @@ const TextEditor = ({
245
252
  keyPath,
246
253
  dictionaryKey
247
254
  }) => {
248
- const addEditedContent = useEditedContentStore((s) => s.addEditedContent);
255
+ const addEditedContent = useEditedContentStore(
256
+ useShallow((s) => s.addEditedContent)
257
+ );
249
258
  const { tsxNotEditable } = useDictionary(navigationViewContent);
250
259
  const nodeType = getSectionType(section);
251
260
  const isEditableSection = getIsEditableSection(section);
@@ -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 { getConfiguration } from '@intlayer/config/client';\nimport {\n type EnumerationContent,\n type TranslationContent,\n NodeType,\n type KeyPath,\n type DictionaryValue,\n getLocaleName,\n} from '@intlayer/core';\nimport { Plus, 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 } from 'react-intlayer';\nimport { getSectionType } from '../../../utils/dictionary';\nimport { renameKey } from '../../../utils/object';\nimport { Button } from '../../Button';\nimport { ContentEditorTextArea } from '../../ContentEditor/ContentEditorTextArea';\nimport { useEditedContentStore } from '../../DictionaryEditor';\nimport { EnumKeyInput } from '../EnumKeyInput';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from '../NavigationView/navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\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 dictionaryKey: string;\n keyPath: KeyPath[];\n section: DictionaryValue;\n};\n\nconst TranslationTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionaryKey,\n}: TextEditorProps) => {\n const { locales } = getConfiguration().internationalization;\n const addEditedContent = useEditedContentStore((s) => s.addEditedContent);\n\n return (\n <table className=\"w-full gap-2\">\n <tbody>\n {locales.map((translationKey) => (\n <tr\n key={translationKey}\n className=\"border-text dark:border-text-dark w-full border-t-[1.5px]\"\n lang={translationKey}\n >\n <td className=\"border-text dark:border-text-dark border-r-[1.5px] p-2\">\n {getLocaleName(translationKey)}\n </td>\n <td className=\"w-full p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n onContentChange={(newValue) =>\n addEditedContent(dictionaryKey, newValue, [\n ...keyPath,\n {\n type: NodeType.Translation,\n key: translationKey,\n },\n ])\n }\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 dictionaryKey,\n}) => {\n const addEditedContent = useEditedContentStore((s) => s.addEditedContent);\n const { addNewEnumeration } = useDictionary(navigationViewContent);\n\n return (\n <table className=\"w-full table-fixed gap-2\">\n <tbody>\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 border-y-[1.5px]\"\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(dictionaryKey, 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(dictionaryKey, 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 onContentChange={(newValue) =>\n addEditedContent(dictionaryKey, newValue, [\n ...keyPath,\n {\n type: NodeType.Enumeration,\n key: enumKey,\n },\n ])\n }\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.value}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() =>\n addEditedContent(\n dictionaryKey,\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 dictionaryKey,\n}) => {\n const addEditedContent = useEditedContentStore((s) => s.addEditedContent);\n const { addNewElement } = useDictionary(navigationViewContent);\n\n return (\n <table className=\"w-full gap-2\">\n <tbody>\n {(section as DictionaryValue[]).map((subSection, index) => (\n <tr\n key={JSON.stringify(subSection)}\n className=\"border-text dark:border-text-dark w-full border-t-[1.5px]\"\n >\n <td className=\"border-text dark:border-text-dark border-r-[1.5px] p-2\">\n {index}\n </td>\n <td className=\"w-full p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n onContentChange={(newValue) => {\n addEditedContent(dictionaryKey, newValue, [\n ...keyPath,\n {\n type: NodeType.Array,\n key: index,\n },\n ]);\n }}\n >\n {subSection as string}\n </ContentEditorTextArea>\n </td>\n </tr>\n ))}\n </tbody>\n <tfoot>\n <Button\n label={addNewElement.label.value}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as DictionaryValue[]).length,\n },\n ];\n addEditedContent(dictionaryKey, '', 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 dictionaryKey,\n}) => {\n const addEditedContent = useEditedContentStore((s) => s.addEditedContent);\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 dictionaryKey={dictionaryKey}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <EnumerationTextEditor\n dictionaryKey={dictionaryKey}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <ArrayTextEditor\n dictionaryKey={dictionaryKey}\n keyPath={keyPath}\n section={section}\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 onContentChange={(newValue) =>\n addEditedContent(dictionaryKey, newValue, keyPath)\n }\n >\n {section as string}\n </ContentEditorTextArea>\n </div>\n );\n }\n\n return <>Error loading section</>;\n};\n"],"names":["element","jsx","jsxs","Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BO,MAAM,YAAsB,CAAC,YAAY,MAAM,UAAU;AAEhE,MAAM,qBAAqB,CAAC,YAA0B;AAChD,MAAA,O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AqB,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 { getConfiguration } from '@intlayer/config/client';\nimport {\n type EnumerationContent,\n type TranslationContent,\n NodeType,\n type KeyPath,\n type DictionaryValue,\n getLocaleName,\n} from '@intlayer/core';\nimport { Plus, 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 } from 'react-intlayer';\nimport { useShallow } from 'zustand/react/shallow';\nimport { getSectionType } from '../../../utils/dictionary';\nimport { renameKey } from '../../../utils/object';\nimport { Button } from '../../Button';\nimport { ContentEditorTextArea } from '../../ContentEditor/ContentEditorTextArea';\nimport { useEditedContentStore } from '../../DictionaryEditor';\nimport { EnumKeyInput } from '../EnumKeyInput';\nimport { getIsEditableSection } from '../getIsEditableSection';\nimport { navigationViewContent } from '../NavigationView/navigationViewNode.content';\n\nexport const traceKeys: string[] = ['filePath', 'id', 'nodeType'];\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 dictionaryKey: string;\n keyPath: KeyPath[];\n section: DictionaryValue;\n};\n\nconst TranslationTextEditor: FC<TextEditorProps> = ({\n section,\n keyPath,\n dictionaryKey,\n}: TextEditorProps) => {\n const { locales } = getConfiguration().internationalization;\n const addEditedContent = useEditedContentStore(\n useShallow((s) => s.addEditedContent)\n );\n\n return (\n <table className=\"w-full gap-2\">\n <tbody>\n {locales.map((translationKey) => (\n <tr\n key={translationKey}\n className=\"border-text dark:border-text-dark w-full border-t-[1.5px]\"\n lang={translationKey}\n >\n <td className=\"border-text dark:border-text-dark border-r-[1.5px] p-2\">\n {getLocaleName(translationKey)}\n </td>\n <td className=\"w-full p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n onContentChange={(newValue) =>\n addEditedContent(dictionaryKey, newValue, [\n ...keyPath,\n {\n type: NodeType.Translation,\n key: translationKey,\n },\n ])\n }\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 dictionaryKey,\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>\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 border-y-[1.5px]\"\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(dictionaryKey, 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(dictionaryKey, 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 onContentChange={(newValue) =>\n addEditedContent(dictionaryKey, newValue, [\n ...keyPath,\n {\n type: NodeType.Enumeration,\n key: enumKey,\n },\n ])\n }\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.value}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() =>\n addEditedContent(\n dictionaryKey,\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 dictionaryKey,\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>\n {(section as DictionaryValue[]).map((subSection, index) => (\n <tr\n key={JSON.stringify(subSection)}\n className=\"border-text dark:border-text-dark w-full border-t-[1.5px]\"\n >\n <td className=\"border-text dark:border-text-dark border-r-[1.5px] p-2\">\n {index}\n </td>\n <td className=\"w-full p-2\">\n <ContentEditorTextArea\n variant=\"default\"\n aria-label=\"Edit field\"\n onContentChange={(newValue) => {\n addEditedContent(dictionaryKey, newValue, [\n ...keyPath,\n {\n type: NodeType.Array,\n key: index,\n },\n ]);\n }}\n >\n {subSection as string}\n </ContentEditorTextArea>\n </td>\n </tr>\n ))}\n </tbody>\n <tfoot>\n <Button\n label={addNewElement.label.value}\n variant=\"hoverable\"\n color=\"neutral\"\n textAlign=\"left\"\n onClick={() => {\n const newKeyPath: KeyPath[] = [\n ...keyPath,\n {\n type: NodeType.Array,\n key: (section as DictionaryValue[]).length,\n },\n ];\n addEditedContent(dictionaryKey, '', 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 dictionaryKey,\n}) => {\n const addEditedContent = useEditedContentStore(\n useShallow((s) => s.addEditedContent)\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 dictionaryKey={dictionaryKey}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Enumeration) {\n return (\n <EnumerationTextEditor\n dictionaryKey={dictionaryKey}\n keyPath={keyPath}\n section={section}\n />\n );\n }\n\n if (nodeType === NodeType.Array) {\n return (\n <ArrayTextEditor\n dictionaryKey={dictionaryKey}\n keyPath={keyPath}\n section={section}\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 onContentChange={(newValue) =>\n addEditedContent(dictionaryKey, newValue, keyPath)\n }\n >\n {section as string}\n </ContentEditorTextArea>\n </div>\n );\n }\n\n return <>Error loading section</>;\n};\n"],"names":["element","jsx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C,OAAI,EAAA,WAAU,iEACb,UAAAA,kCAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,SAAQ;AAAA,QACR,cAAW;AAAA,QACX,iBAAiB,CAAC,aAChB,iBAAiB,eAAe,UAAU,OAAO;AAAA,QAGlD,UAAA;AAAA,MAAA;AAAA,IAEL,EAAA,CAAA;AAAA,EAEJ;AAEA,6EAAS,UAAqB,wBAAA,CAAA;AAChC;"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("../../jsx-runtime-XHKiWCTo.cjs");
4
+ const shallow = require("../../shallow-lhDIFtEp.cjs");
4
5
  const components_ContentEditor_ContentEditorTextArea = require("../ContentEditor/ContentEditorTextArea.cjs");
5
6
  const components_DictionaryEditor_useEditedContentStore = require("../DictionaryEditor/useEditedContentStore.cjs");
6
7
  require("../DictionaryEditor/useEditionPanelStore.cjs");
@@ -27,10 +28,12 @@ require("../DictionaryEditor/validDictionaryChangeButtons.content.cjs");
27
28
  require("zod");
28
29
  const components_DictionaryFieldEditor_SaveForm_SaveForm = require("./SaveForm/SaveForm.cjs");
29
30
  const JSONEditor = ({ dictionary }) => {
30
- const { setEditedContent, editedContent } = components_DictionaryEditor_useEditedContentStore.useEditedContentStore((s) => ({
31
- editedContent: s.editedContent,
32
- setEditedContent: s.setEditedContent
33
- }));
31
+ const { setEditedContent, editedContent } = components_DictionaryEditor_useEditedContentStore.useEditedContentStore(
32
+ shallow.useShallow((s) => ({
33
+ editedContent: s.editedContent,
34
+ setEditedContent: s.setEditedContent
35
+ }))
36
+ );
34
37
  const isValidJSON = (jsonString) => {
35
38
  try {
36
39
  JSON.parse(jsonString);
@@ -1 +1 @@
1
- {"version":3,"file":"JSONEditor.cjs","sources":["../../../src/components/DictionaryFieldEditor/JSONEditor.tsx"],"sourcesContent":["import { Dictionary } from '@intlayer/core';\nimport type { FC } from 'react';\nimport { ContentEditorTextArea } from '../ContentEditor/ContentEditorTextArea';\nimport { useEditedContentStore } from '../DictionaryEditor';\nimport { SaveForm } from './SaveForm/SaveForm';\n\ntype JSONEditorProps = {\n dictionary: Dictionary;\n};\n\nexport const JSONEditor: FC<JSONEditorProps> = ({ dictionary }) => {\n const { setEditedContent, editedContent } = useEditedContentStore((s) => ({\n editedContent: s.editedContent,\n setEditedContent: s.setEditedContent,\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 =\n editedContent[dictionary.key]?.content ?? dictionary?.content ?? {};\n\n return (\n <>\n <ContentEditorTextArea\n key={JSON.stringify(displayedContent)}\n onContentChange={(content) =>\n setEditedContent(dictionary.key, JSON.parse(content))\n }\n validate={isValidJSON}\n className=\"text-sm\"\n variant=\"default\"\n >\n {JSON.stringify(displayedContent, null, 2)}\n </ContentEditorTextArea>\n <SaveForm dictionary={dictionary} />\n </>\n );\n};\n"],"names":["useEditedContentStore","jsxs","Fragment","jsx","ContentEditorTextArea","SaveForm"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUO,MAAM,aAAkC,CAAC,EAAE,iBAAiB;AACjE,QAAM,EAAE,kBAAkB,cAAkB,IAAAA,kDAAA,sBAAsB,CAAC,OAAO;AAAA,IACxE,eAAe,EAAE;AAAA,IACjB,kBAAkB,EAAE;AAAA,EACpB,EAAA;AAEI,QAAA,cAAc,CAAC,eAAgC;AAC/C,QAAA;AACF,WAAK,MAAM,UAAU;AACd,aAAA;AAAA,aACA,QAAQ;AACR,aAAA;AAAA,IACT;AAAA,EAAA;AAGI,QAAA,mBACJ,cAAc,WAAW,GAAG,GAAG,WAAW,YAAY,WAAW;AAEnE,SAEIC,2BAAA,kBAAA,KAAAC,uCAAA,EAAA,UAAA;AAAA,IAAAC,2BAAA,kBAAA;AAAA,MAACC,+CAAA;AAAA,MAAA;AAAA,QAEC,iBAAiB,CAAC,YAChB,iBAAiB,WAAW,KAAK,KAAK,MAAM,OAAO,CAAC;AAAA,QAEtD,UAAU;AAAA,QACV,WAAU;AAAA,QACV,SAAQ;AAAA,QAEP,UAAK,KAAA,UAAU,kBAAkB,MAAM,CAAC;AAAA,MAAA;AAAA,MARpC,KAAK,UAAU,gBAAgB;AAAA,IAStC;AAAA,IACAD,iDAACE,mDAAAA,YAAS,YAAwB;AAAA,EACpC,EAAA,CAAA;AAEJ;;"}
1
+ {"version":3,"file":"JSONEditor.cjs","sources":["../../../src/components/DictionaryFieldEditor/JSONEditor.tsx"],"sourcesContent":["import { Dictionary } from '@intlayer/core';\nimport type { FC } from 'react';\nimport { useShallow } from 'zustand/react/shallow';\nimport { ContentEditorTextArea } from '../ContentEditor/ContentEditorTextArea';\nimport { useEditedContentStore } from '../DictionaryEditor';\nimport { SaveForm } from './SaveForm/SaveForm';\n\ntype JSONEditorProps = {\n dictionary: Dictionary;\n};\n\nexport const JSONEditor: FC<JSONEditorProps> = ({ dictionary }) => {\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 =\n editedContent[dictionary.key]?.content ?? dictionary?.content ?? {};\n\n return (\n <>\n <ContentEditorTextArea\n key={JSON.stringify(displayedContent)}\n onContentChange={(content) =>\n setEditedContent(dictionary.key, JSON.parse(content))\n }\n validate={isValidJSON}\n className=\"text-sm\"\n variant=\"default\"\n >\n {JSON.stringify(displayedContent, null, 2)}\n </ContentEditorTextArea>\n <SaveForm dictionary={dictionary} />\n </>\n );\n};\n"],"names":["useEditedContentStore","useShallow","jsxs","Fragment","jsx","ContentEditorTextArea","SaveForm"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWO,MAAM,aAAkC,CAAC,EAAE,iBAAiB;AAC3D,QAAA,EAAE,kBAAkB,cAAA,IAAkBA,kDAAA;AAAA,IAC1CC,QAAA,WAAW,CAAC,OAAO;AAAA,MACjB,eAAe,EAAE;AAAA,MACjB,kBAAkB,EAAE;AAAA,IAAA,EACpB;AAAA,EAAA;AAGE,QAAA,cAAc,CAAC,eAAgC;AAC/C,QAAA;AACF,WAAK,MAAM,UAAU;AACd,aAAA;AAAA,aACA,QAAQ;AACR,aAAA;AAAA,IACT;AAAA,EAAA;AAGI,QAAA,mBACJ,cAAc,WAAW,GAAG,GAAG,WAAW,YAAY,WAAW;AAEnE,SAEIC,2BAAA,kBAAA,KAAAC,uCAAA,EAAA,UAAA;AAAA,IAAAC,2BAAA,kBAAA;AAAA,MAACC,+CAAA;AAAA,MAAA;AAAA,QAEC,iBAAiB,CAAC,YAChB,iBAAiB,WAAW,KAAK,KAAK,MAAM,OAAO,CAAC;AAAA,QAEtD,UAAU;AAAA,QACV,WAAU;AAAA,QACV,SAAQ;AAAA,QAEP,UAAK,KAAA,UAAU,kBAAkB,MAAM,CAAC;AAAA,MAAA;AAAA,MARpC,KAAK,UAAU,gBAAgB;AAAA,IAStC;AAAA,IACAD,iDAACE,mDAAAA,YAAS,YAAwB;AAAA,EACpC,EAAA,CAAA;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,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAKhC,KAAK,eAAe,GAAG;IACrB,UAAU,EAAE,UAAU,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CAkC1C,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;AAC5C,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAMhC,KAAK,eAAe,GAAG;IACrB,UAAU,EAAE,UAAU,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CAoC1C,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { j as jsxRuntimeExports } from "../../jsx-runtime-DaNGiM0W.js";
2
+ import { u as useShallow } from "../../shallow-m9BpCkKh.js";
2
3
  import { ContentEditorTextArea } from "../ContentEditor/ContentEditorTextArea.mjs";
3
4
  import { useEditedContentStore } from "../DictionaryEditor/useEditedContentStore.mjs";
4
5
  import "../DictionaryEditor/useEditionPanelStore.mjs";
@@ -25,10 +26,12 @@ import "../DictionaryEditor/validDictionaryChangeButtons.content.mjs";
25
26
  import "zod";
26
27
  import { SaveForm } from "./SaveForm/SaveForm.mjs";
27
28
  const JSONEditor = ({ dictionary }) => {
28
- const { setEditedContent, editedContent } = useEditedContentStore((s) => ({
29
- editedContent: s.editedContent,
30
- setEditedContent: s.setEditedContent
31
- }));
29
+ const { setEditedContent, editedContent } = useEditedContentStore(
30
+ useShallow((s) => ({
31
+ editedContent: s.editedContent,
32
+ setEditedContent: s.setEditedContent
33
+ }))
34
+ );
32
35
  const isValidJSON = (jsonString) => {
33
36
  try {
34
37
  JSON.parse(jsonString);
@@ -1 +1 @@
1
- {"version":3,"file":"JSONEditor.mjs","sources":["../../../src/components/DictionaryFieldEditor/JSONEditor.tsx"],"sourcesContent":["import { Dictionary } from '@intlayer/core';\nimport type { FC } from 'react';\nimport { ContentEditorTextArea } from '../ContentEditor/ContentEditorTextArea';\nimport { useEditedContentStore } from '../DictionaryEditor';\nimport { SaveForm } from './SaveForm/SaveForm';\n\ntype JSONEditorProps = {\n dictionary: Dictionary;\n};\n\nexport const JSONEditor: FC<JSONEditorProps> = ({ dictionary }) => {\n const { setEditedContent, editedContent } = useEditedContentStore((s) => ({\n editedContent: s.editedContent,\n setEditedContent: s.setEditedContent,\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 =\n editedContent[dictionary.key]?.content ?? dictionary?.content ?? {};\n\n return (\n <>\n <ContentEditorTextArea\n key={JSON.stringify(displayedContent)}\n onContentChange={(content) =>\n setEditedContent(dictionary.key, JSON.parse(content))\n }\n validate={isValidJSON}\n className=\"text-sm\"\n variant=\"default\"\n >\n {JSON.stringify(displayedContent, null, 2)}\n </ContentEditorTextArea>\n <SaveForm dictionary={dictionary} />\n </>\n );\n};\n"],"names":["jsxs","Fragment","jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAUO,MAAM,aAAkC,CAAC,EAAE,iBAAiB;AACjE,QAAM,EAAE,kBAAkB,cAAkB,IAAA,sBAAsB,CAAC,OAAO;AAAA,IACxE,eAAe,EAAE;AAAA,IACjB,kBAAkB,EAAE;AAAA,EACpB,EAAA;AAEI,QAAA,cAAc,CAAC,eAAgC;AAC/C,QAAA;AACF,WAAK,MAAM,UAAU;AACd,aAAA;AAAA,aACA,QAAQ;AACR,aAAA;AAAA,IACT;AAAA,EAAA;AAGI,QAAA,mBACJ,cAAc,WAAW,GAAG,GAAG,WAAW,YAAY,WAAW;AAEnE,SAEIA,kCAAA,KAAAC,4BAAA,EAAA,UAAA;AAAA,IAAAC,kCAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QAEC,iBAAiB,CAAC,YAChB,iBAAiB,WAAW,KAAK,KAAK,MAAM,OAAO,CAAC;AAAA,QAEtD,UAAU;AAAA,QACV,WAAU;AAAA,QACV,SAAQ;AAAA,QAEP,UAAK,KAAA,UAAU,kBAAkB,MAAM,CAAC;AAAA,MAAA;AAAA,MARpC,KAAK,UAAU,gBAAgB;AAAA,IAStC;AAAA,IACAA,sCAAC,YAAS,YAAwB;AAAA,EACpC,EAAA,CAAA;AAEJ;"}
1
+ {"version":3,"file":"JSONEditor.mjs","sources":["../../../src/components/DictionaryFieldEditor/JSONEditor.tsx"],"sourcesContent":["import { Dictionary } from '@intlayer/core';\nimport type { FC } from 'react';\nimport { useShallow } from 'zustand/react/shallow';\nimport { ContentEditorTextArea } from '../ContentEditor/ContentEditorTextArea';\nimport { useEditedContentStore } from '../DictionaryEditor';\nimport { SaveForm } from './SaveForm/SaveForm';\n\ntype JSONEditorProps = {\n dictionary: Dictionary;\n};\n\nexport const JSONEditor: FC<JSONEditorProps> = ({ dictionary }) => {\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 =\n editedContent[dictionary.key]?.content ?? dictionary?.content ?? {};\n\n return (\n <>\n <ContentEditorTextArea\n key={JSON.stringify(displayedContent)}\n onContentChange={(content) =>\n setEditedContent(dictionary.key, JSON.parse(content))\n }\n validate={isValidJSON}\n className=\"text-sm\"\n variant=\"default\"\n >\n {JSON.stringify(displayedContent, null, 2)}\n </ContentEditorTextArea>\n <SaveForm dictionary={dictionary} />\n </>\n );\n};\n"],"names":["jsxs","Fragment","jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAWO,MAAM,aAAkC,CAAC,EAAE,iBAAiB;AAC3D,QAAA,EAAE,kBAAkB,cAAA,IAAkB;AAAA,IAC1C,WAAW,CAAC,OAAO;AAAA,MACjB,eAAe,EAAE;AAAA,MACjB,kBAAkB,EAAE;AAAA,IAAA,EACpB;AAAA,EAAA;AAGE,QAAA,cAAc,CAAC,eAAgC;AAC/C,QAAA;AACF,WAAK,MAAM,UAAU;AACd,aAAA;AAAA,aACA,QAAQ;AACR,aAAA;AAAA,IACT;AAAA,EAAA;AAGI,QAAA,mBACJ,cAAc,WAAW,GAAG,GAAG,WAAW,YAAY,WAAW;AAEnE,SAEIA,kCAAA,KAAAC,4BAAA,EAAA,UAAA;AAAA,IAAAC,kCAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QAEC,iBAAiB,CAAC,YAChB,iBAAiB,WAAW,KAAK,KAAK,MAAM,OAAO,CAAC;AAAA,QAEtD,UAAU;AAAA,QACV,WAAU;AAAA,QACV,SAAQ;AAAA,QAEP,UAAK,KAAA,UAAU,kBAAkB,MAAM,CAAC;AAAA,MAAA;AAAA,MARpC,KAAK,UAAU,gBAAgB;AAAA,IAStC;AAAA,IACAA,sCAAC,YAAS,YAAwB;AAAA,EACpC,EAAA,CAAA;AAEJ;"}
@@ -6,6 +6,7 @@ const core = require("@intlayer/core");
6
6
  const lucideReact = require("lucide-react");
7
7
  const require$$0 = require("react");
8
8
  const reactIntlayer = require("react-intlayer");
9
+ const shallow = require("../../../shallow-lhDIFtEp.cjs");
9
10
  const utils_camelCase = require("../../../utils/camelCase.cjs");
10
11
  const utils_dictionary = require("../../../utils/dictionary.cjs");
11
12
  const components_Accordion_Accordion = require("../../Accordion/Accordion.cjs");
@@ -37,12 +38,14 @@ const NavigationViewNode = ({
37
38
  }) => {
38
39
  const { locales } = client.getConfiguration().internationalization;
39
40
  const section = utils_dictionary.getDictionaryValueByKeyPath(sectionProp, keyPath);
40
- const addEditedContent = components_DictionaryEditor_useEditedContentStore.useEditedContentStore((s) => s.addEditedContent);
41
+ const addEditedContent = components_DictionaryEditor_useEditedContentStore.useEditedContentStore(
42
+ shallow.useShallow((s) => s.addEditedContent)
43
+ );
41
44
  const { setFocusedContentKeyPath, focusedContent } = components_DictionaryEditor_useEditionPanelStore.useEditionPanelStore(
42
- (s) => ({
45
+ shallow.useShallow((s) => ({
43
46
  setFocusedContentKeyPath: s.setFocusedContentKeyPath,
44
47
  focusedContent: s.focusedContent
45
- })
48
+ }))
46
49
  );
47
50
  const {
48
51
  addNewElement,