@intlayer/design-system 5.3.3 → 5.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/dist/.vite/manifest.json +67 -49
  2. package/dist/{Form-MjLzPGze.js → Form-CriPBaZk.js} +11 -1
  3. package/dist/Form-CriPBaZk.js.map +1 -0
  4. package/dist/{Form-BpxW17v4.cjs → Form-DJrUK3mm.cjs} +11 -1
  5. package/dist/Form-DJrUK3mm.cjs.map +1 -0
  6. package/dist/components/Auth/ChangePasswordForm/ChangePasswordForm.cjs +1 -1
  7. package/dist/components/Auth/ChangePasswordForm/ChangePasswordForm.mjs +1 -1
  8. package/dist/components/Auth/DefineNewPasswordForm/DefineNewPasswordForm.cjs +1 -1
  9. package/dist/components/Auth/DefineNewPasswordForm/DefineNewPasswordForm.mjs +1 -1
  10. package/dist/components/Auth/ResetPasswordForm/ResetPasswordForm.cjs +1 -1
  11. package/dist/components/Auth/ResetPasswordForm/ResetPasswordForm.mjs +1 -1
  12. package/dist/components/Auth/SignInForm/SignInForm.cjs +1 -1
  13. package/dist/components/Auth/SignInForm/SignInForm.mjs +1 -1
  14. package/dist/components/Auth/SignUpForm/SignUpForm.cjs +1 -1
  15. package/dist/components/Auth/SignUpForm/SignUpForm.mjs +1 -1
  16. package/dist/components/Auth/VerifyEmailForm/VerifyEmailForm.cjs +1 -1
  17. package/dist/components/Auth/VerifyEmailForm/VerifyEmailForm.mjs +1 -1
  18. package/dist/components/ContentEditor/ContentEditor.cjs.map +1 -1
  19. package/dist/components/ContentEditor/ContentEditor.d.ts +3 -2
  20. package/dist/components/ContentEditor/ContentEditor.d.ts.map +1 -1
  21. package/dist/components/ContentEditor/ContentEditor.mjs.map +1 -1
  22. package/dist/components/ContentEditor/ContentEditorTextArea.cjs +1 -1
  23. package/dist/components/ContentEditor/ContentEditorTextArea.mjs +1 -1
  24. package/dist/components/DictionaryEditor/DictionaryEditor.cjs +2 -1
  25. package/dist/components/DictionaryEditor/DictionaryEditor.cjs.map +1 -1
  26. package/dist/components/DictionaryEditor/DictionaryEditor.d.ts.map +1 -1
  27. package/dist/components/DictionaryEditor/DictionaryEditor.mjs +2 -1
  28. package/dist/components/DictionaryEditor/DictionaryEditor.mjs.map +1 -1
  29. package/dist/components/DictionaryEditor/NodeWrapper/ArrayWrapper.cjs +1 -1
  30. package/dist/components/DictionaryEditor/NodeWrapper/ArrayWrapper.mjs +1 -1
  31. package/dist/components/DictionaryEditor/NodeWrapper/ConditionWrapper.cjs +1 -1
  32. package/dist/components/DictionaryEditor/NodeWrapper/ConditionWrapper.mjs +1 -1
  33. package/dist/components/DictionaryEditor/NodeWrapper/EnumerationWrapper.cjs +1 -1
  34. package/dist/components/DictionaryEditor/NodeWrapper/EnumerationWrapper.mjs +1 -1
  35. package/dist/components/DictionaryEditor/NodeWrapper/FileWrapper.cjs +58 -0
  36. package/dist/components/DictionaryEditor/NodeWrapper/FileWrapper.cjs.map +1 -0
  37. package/dist/components/DictionaryEditor/NodeWrapper/FileWrapper.d.ts +9 -0
  38. package/dist/components/DictionaryEditor/NodeWrapper/FileWrapper.d.ts.map +1 -0
  39. package/dist/components/DictionaryEditor/NodeWrapper/FileWrapper.mjs +58 -0
  40. package/dist/components/DictionaryEditor/NodeWrapper/FileWrapper.mjs.map +1 -0
  41. package/dist/components/DictionaryEditor/NodeWrapper/InsertionWrapper.cjs +7 -0
  42. package/dist/components/DictionaryEditor/NodeWrapper/InsertionWrapper.cjs.map +1 -0
  43. package/dist/components/DictionaryEditor/NodeWrapper/InsertionWrapper.d.ts +9 -0
  44. package/dist/components/DictionaryEditor/NodeWrapper/InsertionWrapper.d.ts.map +1 -0
  45. package/dist/components/DictionaryEditor/NodeWrapper/InsertionWrapper.mjs +7 -0
  46. package/dist/components/DictionaryEditor/NodeWrapper/InsertionWrapper.mjs.map +1 -0
  47. package/dist/components/DictionaryEditor/NodeWrapper/MarkdownWrapper.cjs +4 -15
  48. package/dist/components/DictionaryEditor/NodeWrapper/MarkdownWrapper.cjs.map +1 -1
  49. package/dist/components/DictionaryEditor/NodeWrapper/MarkdownWrapper.d.ts +2 -2
  50. package/dist/components/DictionaryEditor/NodeWrapper/MarkdownWrapper.d.ts.map +1 -1
  51. package/dist/components/DictionaryEditor/NodeWrapper/MarkdownWrapper.mjs +4 -15
  52. package/dist/components/DictionaryEditor/NodeWrapper/MarkdownWrapper.mjs.map +1 -1
  53. package/dist/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.cjs +1 -1
  54. package/dist/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.mjs +1 -1
  55. package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.cjs +8 -5
  56. package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.cjs.map +1 -1
  57. package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.d.ts +2 -2
  58. package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.d.ts.map +1 -1
  59. package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.mjs +8 -5
  60. package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.mjs.map +1 -1
  61. package/dist/components/DictionaryEditor/NodeWrapper/TranslationWrapper.cjs +1 -1
  62. package/dist/components/DictionaryEditor/NodeWrapper/TranslationWrapper.mjs +1 -1
  63. package/dist/components/DictionaryEditor/NodeWrapper/index.cjs +2 -2
  64. package/dist/components/DictionaryEditor/NodeWrapper/index.d.ts +4 -2
  65. package/dist/components/DictionaryEditor/NodeWrapper/index.d.ts.map +1 -1
  66. package/dist/components/DictionaryEditor/NodeWrapper/index.mjs +2 -2
  67. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.cjs +102 -22
  68. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.cjs.map +1 -1
  69. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.d.ts +3 -1
  70. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.d.ts.map +1 -1
  71. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs +102 -22
  72. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs.map +1 -1
  73. package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.cjs +1 -1
  74. package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs +1 -1
  75. package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.cjs +1 -1
  76. package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs +1 -1
  77. package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.cjs +48 -114
  78. package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.cjs.map +1 -1
  79. package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.d.ts.map +1 -1
  80. package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs +49 -115
  81. package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs.map +1 -1
  82. package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.cjs +0 -51
  83. package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.cjs.map +1 -1
  84. package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.d.ts +0 -105
  85. package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.d.ts.map +1 -1
  86. package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.mjs +0 -51
  87. package/dist/components/DictionaryFieldEditor/NavigationView/navigationViewNode.content.mjs.map +1 -1
  88. package/dist/components/DictionaryFieldEditor/NodeTypeSelector.cjs +6 -5
  89. package/dist/components/DictionaryFieldEditor/NodeTypeSelector.cjs.map +1 -1
  90. package/dist/components/DictionaryFieldEditor/NodeTypeSelector.d.ts.map +1 -1
  91. package/dist/components/DictionaryFieldEditor/NodeTypeSelector.mjs +7 -6
  92. package/dist/components/DictionaryFieldEditor/NodeTypeSelector.mjs.map +1 -1
  93. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs +117 -78
  94. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs.map +1 -1
  95. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.d.ts.map +1 -1
  96. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs +120 -81
  97. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs.map +1 -1
  98. package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.cjs +108 -0
  99. package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.cjs.map +1 -1
  100. package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.d.ts +231 -0
  101. package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.d.ts.map +1 -1
  102. package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.mjs +108 -0
  103. package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.mjs.map +1 -1
  104. package/dist/components/DictionaryFieldEditor/getIsEditableSection.cjs +10 -2
  105. package/dist/components/DictionaryFieldEditor/getIsEditableSection.cjs.map +1 -1
  106. package/dist/components/DictionaryFieldEditor/getIsEditableSection.d.ts.map +1 -1
  107. package/dist/components/DictionaryFieldEditor/getIsEditableSection.mjs +11 -3
  108. package/dist/components/DictionaryFieldEditor/getIsEditableSection.mjs.map +1 -1
  109. package/dist/components/DictionaryFieldEditor/nodeTypeSelector.content.cjs +30 -0
  110. package/dist/components/DictionaryFieldEditor/nodeTypeSelector.content.cjs.map +1 -1
  111. package/dist/components/DictionaryFieldEditor/nodeTypeSelector.content.d.ts +66 -0
  112. package/dist/components/DictionaryFieldEditor/nodeTypeSelector.content.d.ts.map +1 -1
  113. package/dist/components/DictionaryFieldEditor/nodeTypeSelector.content.mjs +30 -0
  114. package/dist/components/DictionaryFieldEditor/nodeTypeSelector.content.mjs.map +1 -1
  115. package/dist/components/Form/Form.cjs +1 -1
  116. package/dist/components/Form/Form.mjs +1 -1
  117. package/dist/components/Form/elements/AutoSizeTextAreaElement.cjs +1 -1
  118. package/dist/components/Form/elements/AutoSizeTextAreaElement.mjs +1 -1
  119. package/dist/components/Form/elements/CheckboxElement.cjs +1 -1
  120. package/dist/components/Form/elements/CheckboxElement.mjs +1 -1
  121. package/dist/components/Form/elements/EditableFieldInputElement.cjs +1 -1
  122. package/dist/components/Form/elements/EditableFieldInputElement.d.ts +2 -2
  123. package/dist/components/Form/elements/EditableFieldInputElement.d.ts.map +1 -1
  124. package/dist/components/Form/elements/EditableFieldInputElement.mjs +1 -1
  125. package/dist/components/Form/elements/EditableFieldTextAreaElement.cjs +1 -1
  126. package/dist/components/Form/elements/EditableFieldTextAreaElement.d.ts +2 -2
  127. package/dist/components/Form/elements/EditableFieldTextAreaElement.d.ts.map +1 -1
  128. package/dist/components/Form/elements/EditableFieldTextAreaElement.mjs +1 -1
  129. package/dist/components/Form/elements/FormElement.cjs +1 -1
  130. package/dist/components/Form/elements/FormElement.mjs +1 -1
  131. package/dist/components/Form/elements/InputElement.cjs +1 -1
  132. package/dist/components/Form/elements/InputElement.d.ts +2 -2
  133. package/dist/components/Form/elements/InputElement.d.ts.map +1 -1
  134. package/dist/components/Form/elements/InputElement.mjs +1 -1
  135. package/dist/components/Form/elements/InputPasswordElement.cjs +1 -1
  136. package/dist/components/Form/elements/InputPasswordElement.d.ts +2 -2
  137. package/dist/components/Form/elements/InputPasswordElement.d.ts.map +1 -1
  138. package/dist/components/Form/elements/InputPasswordElement.mjs +1 -1
  139. package/dist/components/Form/elements/MultiselectElement.cjs +1 -1
  140. package/dist/components/Form/elements/MultiselectElement.mjs +1 -1
  141. package/dist/components/Form/elements/SelectElement.cjs +1 -1
  142. package/dist/components/Form/elements/SelectElement.mjs +1 -1
  143. package/dist/components/Form/elements/SwitchSelectorElement.cjs +1 -1
  144. package/dist/components/Form/elements/SwitchSelectorElement.mjs +1 -1
  145. package/dist/components/Form/elements/TextAreaElement.cjs +1 -1
  146. package/dist/components/Form/elements/TextAreaElement.d.ts +3 -3
  147. package/dist/components/Form/elements/TextAreaElement.d.ts.map +1 -1
  148. package/dist/components/Form/elements/TextAreaElement.mjs +1 -1
  149. package/dist/components/Form/elements/index.cjs +1 -1
  150. package/dist/components/Form/elements/index.mjs +1 -1
  151. package/dist/components/Form/index.cjs +1 -1
  152. package/dist/components/Form/index.mjs +1 -1
  153. package/dist/components/Form/layout/FormItemLayout.cjs +1 -1
  154. package/dist/components/Form/layout/FormItemLayout.mjs +1 -1
  155. package/dist/components/Form/layout/FormLabelLayout.cjs +12 -4
  156. package/dist/components/Form/layout/FormLabelLayout.cjs.map +1 -1
  157. package/dist/components/Form/layout/FormLabelLayout.d.ts.map +1 -1
  158. package/dist/components/Form/layout/FormLabelLayout.mjs +12 -4
  159. package/dist/components/Form/layout/FormLabelLayout.mjs.map +1 -1
  160. package/dist/components/Form/layout/index.cjs +1 -1
  161. package/dist/components/Form/layout/index.mjs +1 -1
  162. package/dist/components/Input/Input.cjs.map +1 -1
  163. package/dist/components/Input/Input.d.ts +1 -7
  164. package/dist/components/Input/Input.d.ts.map +1 -1
  165. package/dist/components/Input/Input.mjs.map +1 -1
  166. package/dist/components/TextArea/TextArea.cjs.map +1 -1
  167. package/dist/components/TextArea/TextArea.d.ts +1 -7
  168. package/dist/components/TextArea/TextArea.d.ts.map +1 -1
  169. package/dist/components/TextArea/TextArea.mjs.map +1 -1
  170. package/dist/components/index.cjs +1 -1
  171. package/dist/components/index.mjs +1 -1
  172. package/dist/hooks/intlayerAPIHooks.cjs.map +1 -1
  173. package/dist/hooks/intlayerAPIHooks.d.ts +54 -54
  174. package/dist/hooks/intlayerAPIHooks.d.ts.map +1 -1
  175. package/dist/hooks/intlayerAPIHooks.mjs.map +1 -1
  176. package/dist/hooks/useIntlayerAPI.d.ts +1 -1
  177. package/dist/hooks/useIntlayerAPI.d.ts.map +1 -1
  178. package/dist/{index-CVTE3oHq.js → index-CEoL1j7H.js} +48 -3
  179. package/dist/index-CEoL1j7H.js.map +1 -0
  180. package/dist/{index-BpCAhDMe.cjs → index-s_Ar0FDw.cjs} +48 -3
  181. package/dist/index-s_Ar0FDw.cjs.map +1 -0
  182. package/dist/utils/camelCase.cjs +2 -2
  183. package/dist/utils/camelCase.cjs.map +1 -1
  184. package/dist/utils/camelCase.d.ts +1 -1
  185. package/dist/utils/camelCase.d.ts.map +1 -1
  186. package/dist/utils/camelCase.mjs +2 -2
  187. package/dist/utils/camelCase.mjs.map +1 -1
  188. package/package.json +17 -19
  189. package/dist/Form-BpxW17v4.cjs.map +0 -1
  190. package/dist/Form-MjLzPGze.js.map +0 -1
  191. package/dist/index-BpCAhDMe.cjs.map +0 -1
  192. package/dist/index-CVTE3oHq.js.map +0 -1
@@ -18,7 +18,7 @@ require("@intlayer/api");
18
18
  require("@hookform/resolvers");
19
19
  require("react-hook-form");
20
20
  require("../../Form/FormField.cjs");
21
- const components_Form_layout_FormItemLayout = require("../../../Form-BpxW17v4.cjs");
21
+ const components_Form_layout_FormItemLayout = require("../../../Form-DJrUK3mm.cjs");
22
22
  require("../../Auth/SignInForm/signIn.content.cjs");
23
23
  require("zod");
24
24
  require("../../Auth/SignInForm/useSignInSchema.content.cjs");
@@ -28,7 +28,7 @@ require("../../Auth/ChangePasswordForm/changePasswordForm.content.cjs");
28
28
  require("../../Auth/ChangePasswordForm/useChangePasswordSchema.content.cjs");
29
29
  require("../../Auth/ResetPasswordForm/resetPasswordContent.content.cjs");
30
30
  require("../../Auth/ResetPasswordForm/useResetPasswordSchema.content.cjs");
31
- require("../../Modal/Modal.cjs");
31
+ const components_Modal_Modal = require("../../Modal/Modal.cjs");
32
32
  require("@intlayer/config/built");
33
33
  require("../../Auth/VerifyEmailForm/index.content.cjs");
34
34
  require("../../Auth/DefineNewPasswordForm/defineNewPasswordForm.content.cjs");
@@ -40,26 +40,25 @@ const SaveForm = ({
40
40
  className,
41
41
  ...props
42
42
  }) => {
43
+ const [isFormatAlertModalOpen, setIsFormatAlertModalOpen] = ReactExports.useState(false);
43
44
  const { setLocaleDictionary } = editorReact.useDictionariesRecordActions();
44
45
  const { writeDictionary, isLoading: isWriting } = hooks_intlayerAPIHooks.useWriteDictionary();
45
46
  const { pushDictionaries, isLoading: isPushing } = hooks_intlayerAPIHooks.usePushDictionaries();
46
47
  const isLoading = isWriting || isPushing;
48
+ const isJsonFormat = mode.includes("local") && dictionary.filePath?.endsWith(".json");
47
49
  const { editedContent, restoreEditedContent } = editorReact.useEditedContent();
48
- const { resetButton, saveButton, publishButton, downloadButton } = reactIntlayer.useDictionary(components_DictionaryFieldEditor_SaveForm_saveForm_content.saveDictionaryContent);
50
+ const {
51
+ resetButton,
52
+ saveButton,
53
+ publishButton,
54
+ downloadButton,
55
+ confirmation
56
+ } = reactIntlayer.useDictionary(components_DictionaryFieldEditor_SaveForm_saveForm_content.saveDictionaryContent);
49
57
  const { isAuthenticated } = components_Auth_useAuth_index.useAuth();
50
- const editedDictionary = ReactExports.useMemo(
51
- () => editedContent?.[dictionary.key],
52
- [editedContent, dictionary.key]
53
- );
54
- const isEdited = ReactExports.useMemo(
55
- () => editedDictionary && JSON.stringify(editedDictionary) !== JSON.stringify(dictionary),
56
- [editedDictionary, dictionary, mode]
57
- );
58
- const isLocalDictionary = ReactExports.useMemo(
59
- () => typeof dictionary?._id === "undefined",
60
- [dictionary]
61
- );
62
- const handleSaveDictionary = async () => {
58
+ const editedDictionary = editedContent?.[dictionary.key];
59
+ const isEdited = editedDictionary && JSON.stringify(editedDictionary) !== JSON.stringify(dictionary);
60
+ const isLocalDictionary = typeof dictionary?._id === "undefined";
61
+ const handleSaveDictionaryConfirmation = async () => {
63
62
  if (!editedContent?.[dictionary.key]) return;
64
63
  const updatedDictionary = {
65
64
  ...dictionary,
@@ -83,68 +82,108 @@ const SaveForm = ({
83
82
  }
84
83
  });
85
84
  };
86
- return /* @__PURE__ */ jsxRuntime.jsxs(
87
- "form",
88
- {
89
- className: utils_cn.cn("flex justify-end gap-2 max-md:flex-col", className),
90
- ...props,
91
- children: [
92
- isEdited && /* @__PURE__ */ jsxRuntime.jsx(
93
- components_Form_layout_FormItemLayout.Form.Button,
94
- {
95
- label: resetButton.label.value,
96
- disabled: !isEdited,
97
- Icon: lucideReact.RotateCcw,
98
- variant: "outline",
99
- color: "text",
100
- className: "max-md:w-full",
101
- onClick: () => restoreEditedContent(dictionary.key),
102
- children: resetButton.text
103
- }
104
- ),
105
- mode.includes("local") && /* @__PURE__ */ jsxRuntime.jsx(
106
- components_Form_layout_FormItemLayout.Form.Button,
107
- {
108
- label: downloadButton.label.value,
109
- disabled: !isEdited || isLoading,
110
- Icon: lucideReact.Download,
111
- color: "text",
112
- variant: isAuthenticated ? "outline" : "default",
113
- className: "max-md:w-full",
114
- isLoading: isWriting,
115
- onClick: handleSaveDictionary,
116
- children: downloadButton.text
117
- }
118
- ),
119
- mode.includes("remote") && isAuthenticated && isLocalDictionary && /* @__PURE__ */ jsxRuntime.jsx(
120
- components_Form_layout_FormItemLayout.Form.Button,
121
- {
122
- label: publishButton.label.value,
123
- disabled: isLoading,
124
- Icon: lucideReact.ArrowUpFromLine,
125
- color: "text",
126
- className: "max-md:w-full",
127
- isLoading: isPushing,
128
- onClick: handlePushDictionary,
129
- children: publishButton.text
130
- }
131
- ),
132
- mode.includes("remote") && isAuthenticated && !isLocalDictionary && isEdited && /* @__PURE__ */ jsxRuntime.jsx(
133
- components_Form_layout_FormItemLayout.Form.Button,
134
- {
135
- label: saveButton.label.value,
136
- disabled: !isEdited || isLoading,
137
- Icon: lucideReact.Save,
138
- color: "text",
139
- className: "max-md:w-full",
140
- isLoading: isPushing,
141
- onClick: handlePushDictionary,
142
- children: saveButton.text
143
- }
144
- )
145
- ]
146
- }
147
- );
85
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
86
+ /* @__PURE__ */ jsxRuntime.jsx(
87
+ components_Modal_Modal.Modal,
88
+ {
89
+ isOpen: isFormatAlertModalOpen,
90
+ title: confirmation.title.value,
91
+ size: "md",
92
+ children: /* @__PURE__ */ jsxRuntime.jsxs("form", { className: "size-full px-3", children: [
93
+ isJsonFormat ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-neutral py-4 text-sm", children: confirmation.message }) : /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-neutral py-4 text-sm", children: confirmation.differentFormatMessage }),
94
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-12 flex justify-end gap-2 max-md:flex-col", children: [
95
+ /* @__PURE__ */ jsxRuntime.jsx(
96
+ components_Form_layout_FormItemLayout.Form.Button,
97
+ {
98
+ label: confirmation.cancelButton.label.value,
99
+ disabled: !isEdited || isLoading,
100
+ color: "text",
101
+ className: "max-md:w-full",
102
+ variant: "outline",
103
+ onClick: () => setIsFormatAlertModalOpen(false),
104
+ children: confirmation.cancelButton.text
105
+ }
106
+ ),
107
+ /* @__PURE__ */ jsxRuntime.jsx(
108
+ components_Form_layout_FormItemLayout.Form.Button,
109
+ {
110
+ label: confirmation.confirmButton.label.value,
111
+ disabled: !isEdited || isLoading,
112
+ Icon: lucideReact.Save,
113
+ color: "text",
114
+ className: "max-md:w-full",
115
+ isLoading: isPushing,
116
+ onClick: handleSaveDictionaryConfirmation,
117
+ children: confirmation.confirmButton.text
118
+ }
119
+ )
120
+ ] })
121
+ ] })
122
+ }
123
+ ),
124
+ /* @__PURE__ */ jsxRuntime.jsxs(
125
+ "form",
126
+ {
127
+ className: utils_cn.cn("flex justify-end gap-2 max-md:flex-col", className),
128
+ ...props,
129
+ children: [
130
+ isEdited && /* @__PURE__ */ jsxRuntime.jsx(
131
+ components_Form_layout_FormItemLayout.Form.Button,
132
+ {
133
+ label: resetButton.label.value,
134
+ disabled: !isEdited,
135
+ Icon: lucideReact.RotateCcw,
136
+ variant: "outline",
137
+ color: "text",
138
+ className: "max-md:w-full",
139
+ onClick: () => restoreEditedContent(dictionary.key),
140
+ children: resetButton.text
141
+ }
142
+ ),
143
+ mode.includes("local") && /* @__PURE__ */ jsxRuntime.jsx(
144
+ components_Form_layout_FormItemLayout.Form.Button,
145
+ {
146
+ label: downloadButton.label.value,
147
+ disabled: !isEdited || isLoading,
148
+ Icon: lucideReact.Download,
149
+ color: "text",
150
+ variant: isAuthenticated ? "outline" : "default",
151
+ className: "max-md:w-full",
152
+ isLoading: isWriting,
153
+ onClick: () => setIsFormatAlertModalOpen(true),
154
+ children: downloadButton.text
155
+ }
156
+ ),
157
+ mode.includes("remote") && isAuthenticated && isLocalDictionary && /* @__PURE__ */ jsxRuntime.jsx(
158
+ components_Form_layout_FormItemLayout.Form.Button,
159
+ {
160
+ label: publishButton.label.value,
161
+ disabled: isLoading,
162
+ Icon: lucideReact.ArrowUpFromLine,
163
+ color: "text",
164
+ className: "max-md:w-full",
165
+ isLoading: isPushing,
166
+ onClick: handlePushDictionary,
167
+ children: publishButton.text
168
+ }
169
+ ),
170
+ mode.includes("remote") && isAuthenticated && !isLocalDictionary && isEdited && /* @__PURE__ */ jsxRuntime.jsx(
171
+ components_Form_layout_FormItemLayout.Form.Button,
172
+ {
173
+ label: saveButton.label.value,
174
+ disabled: !isEdited || isLoading,
175
+ Icon: lucideReact.Save,
176
+ color: "text",
177
+ className: "max-md:w-full",
178
+ isLoading: isPushing,
179
+ onClick: handlePushDictionary,
180
+ children: saveButton.text
181
+ }
182
+ )
183
+ ]
184
+ }
185
+ )
186
+ ] });
148
187
  };
149
188
  exports.SaveForm = SaveForm;
150
189
  //# sourceMappingURL=SaveForm.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"SaveForm.cjs","sources":["../../../../src/components/DictionaryFieldEditor/SaveForm/SaveForm.tsx"],"sourcesContent":["'use client';\n\nimport type { Dictionary as DistantDictionary } from '@intlayer/backend';\nimport type { Dictionary } from '@intlayer/core';\nimport {\n useDictionariesRecordActions,\n useEditedContent,\n} from '@intlayer/editor-react';\nimport { ArrowUpFromLine, Download, RotateCcw, Save } from 'lucide-react';\nimport {\n type DetailedHTMLProps,\n type FormHTMLAttributes,\n useMemo,\n type FC,\n} from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { usePushDictionaries, useWriteDictionary } from '../../../hooks';\nimport { cn } from '../../../utils/cn';\nimport { useAuth } from '../../Auth';\nimport { Form } from '../../Form';\nimport { saveDictionaryContent } from './saveForm.content';\n\ntype DictionaryDetailsProps = {\n dictionary: Dictionary;\n mode: ('local' | 'remote')[];\n} & DetailedHTMLProps<FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>;\n\nexport const SaveForm: FC<DictionaryDetailsProps> = ({\n dictionary,\n mode,\n className,\n ...props\n}) => {\n const { setLocaleDictionary } = useDictionariesRecordActions();\n const { writeDictionary, isLoading: isWriting } = useWriteDictionary();\n const { pushDictionaries, isLoading: isPushing } = usePushDictionaries();\n const isLoading = isWriting || isPushing;\n\n const { editedContent, restoreEditedContent } = useEditedContent();\n const { resetButton, saveButton, publishButton, downloadButton } =\n useDictionary(saveDictionaryContent);\n const { isAuthenticated } = useAuth();\n\n const editedDictionary = useMemo(\n () => editedContent?.[dictionary.key],\n [editedContent, dictionary.key]\n );\n\n const isEdited = useMemo(\n () =>\n editedDictionary &&\n JSON.stringify(editedDictionary) !== JSON.stringify(dictionary),\n [editedDictionary, dictionary, mode]\n );\n\n const isLocalDictionary = useMemo(\n () => typeof (dictionary as DistantDictionary)?._id === 'undefined',\n [dictionary]\n );\n\n const handleSaveDictionary = async () => {\n if (!editedContent?.[dictionary.key]) return;\n\n const updatedDictionary = {\n ...dictionary,\n ...editedContent?.[dictionary.key],\n };\n\n await writeDictionary(updatedDictionary).then(() => {\n setLocaleDictionary(editedContent?.[dictionary.key]);\n restoreEditedContent(dictionary.key);\n });\n };\n\n const handlePushDictionary = async () => {\n if (!editedContent?.[dictionary.key]) return;\n\n const updatedDictionary = {\n ...dictionary,\n ...editedContent?.[dictionary.key],\n };\n\n await pushDictionaries([updatedDictionary]).then((res) => {\n if (res) {\n setLocaleDictionary(editedContent?.[dictionary.key]);\n restoreEditedContent(dictionary.key);\n }\n });\n };\n\n return (\n <form\n className={cn('flex justify-end gap-2 max-md:flex-col', className)}\n {...props}\n >\n {isEdited && (\n <Form.Button\n label={resetButton.label.value}\n disabled={!isEdited}\n Icon={RotateCcw}\n variant=\"outline\"\n color=\"text\"\n className=\"max-md:w-full\"\n onClick={() => restoreEditedContent(dictionary.key)}\n >\n {resetButton.text}\n </Form.Button>\n )}\n {mode.includes('local') && (\n <Form.Button\n label={downloadButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Download}\n color=\"text\"\n variant={isAuthenticated ? 'outline' : 'default'}\n className=\"max-md:w-full\"\n isLoading={isWriting}\n onClick={handleSaveDictionary}\n >\n {downloadButton.text}\n </Form.Button>\n )}\n {mode.includes('remote') && isAuthenticated && isLocalDictionary && (\n <Form.Button\n label={publishButton.label.value}\n disabled={isLoading}\n Icon={ArrowUpFromLine}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handlePushDictionary}\n >\n {publishButton.text}\n </Form.Button>\n )}\n {mode.includes('remote') &&\n isAuthenticated &&\n !isLocalDictionary &&\n isEdited && (\n <Form.Button\n label={saveButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Save}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handlePushDictionary}\n >\n {saveButton.text}\n </Form.Button>\n )}\n </form>\n );\n};\n"],"names":["useDictionariesRecordActions","useWriteDictionary","usePushDictionaries","useEditedContent","useDictionary","saveDictionaryContent","useAuth","useMemo","jsxs","cn","jsx","Form","RotateCcw","Download","ArrowUpFromLine","Save"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BO,MAAM,WAAuC,CAAC;AAAA,EACnD;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACE,QAAA,EAAE,oBAAoB,IAAIA,yCAA6B;AAC7D,QAAM,EAAE,iBAAiB,WAAW,UAAA,IAAcC,uBAAAA,mBAAmB;AACrE,QAAM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;AAAA,YACN,WAAU;AAAA,YACV,WAAW;AAAA,YACX,SAAS;AAAA,YAER,UAAW,WAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MACd;AAAA,IAAA;AAAA,EAEN;AAEJ;;"}
1
+ {"version":3,"file":"SaveForm.cjs","sources":["../../../../src/components/DictionaryFieldEditor/SaveForm/SaveForm.tsx"],"sourcesContent":["'use client';\n\nimport type { Dictionary as DistantDictionary } from '@intlayer/backend';\nimport type { Dictionary } from '@intlayer/core';\nimport {\n useDictionariesRecordActions,\n useEditedContent,\n} from '@intlayer/editor-react';\nimport { ArrowUpFromLine, Download, RotateCcw, Save } from 'lucide-react';\nimport {\n type DetailedHTMLProps,\n type FormHTMLAttributes,\n type FC,\n useState,\n} from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { usePushDictionaries, useWriteDictionary } from '../../../hooks';\nimport { cn } from '../../../utils/cn';\nimport { useAuth } from '../../Auth';\nimport { Form } from '../../Form';\nimport { saveDictionaryContent } from './saveForm.content';\nimport { Modal } from '../../../components/Modal';\n\ntype DictionaryDetailsProps = {\n dictionary: Dictionary;\n mode: ('local' | 'remote')[];\n} & DetailedHTMLProps<FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>;\n\nexport const SaveForm: FC<DictionaryDetailsProps> = ({\n dictionary,\n mode,\n className,\n ...props\n}) => {\n const [isFormatAlertModalOpen, setIsFormatAlertModalOpen] = useState(false);\n const { setLocaleDictionary } = useDictionariesRecordActions();\n const { writeDictionary, isLoading: isWriting } = useWriteDictionary();\n const { pushDictionaries, isLoading: isPushing } = usePushDictionaries();\n const isLoading = isWriting || isPushing;\n const isJsonFormat =\n mode.includes('local') && dictionary.filePath?.endsWith('.json');\n\n const { editedContent, restoreEditedContent } = useEditedContent();\n const {\n resetButton,\n saveButton,\n publishButton,\n downloadButton,\n confirmation,\n } = useDictionary(saveDictionaryContent);\n const { isAuthenticated } = useAuth();\n\n const editedDictionary = editedContent?.[dictionary.key];\n\n const isEdited =\n editedDictionary &&\n JSON.stringify(editedDictionary) !== JSON.stringify(dictionary);\n\n const isLocalDictionary =\n typeof (dictionary as DistantDictionary)?._id === 'undefined';\n\n const handleSaveDictionaryConfirmation = async () => {\n if (!editedContent?.[dictionary.key]) return;\n\n const updatedDictionary = {\n ...dictionary,\n ...editedContent?.[dictionary.key],\n };\n\n await writeDictionary(updatedDictionary).then(() => {\n setLocaleDictionary(editedContent?.[dictionary.key]);\n restoreEditedContent(dictionary.key);\n });\n };\n\n const handlePushDictionary = async () => {\n if (!editedContent?.[dictionary.key]) return;\n\n const updatedDictionary = {\n ...dictionary,\n ...editedContent?.[dictionary.key],\n };\n\n await pushDictionaries([updatedDictionary]).then((res) => {\n if (res) {\n setLocaleDictionary(editedContent?.[dictionary.key]);\n restoreEditedContent(dictionary.key);\n }\n });\n };\n\n return (\n <>\n <Modal\n isOpen={isFormatAlertModalOpen}\n title={confirmation.title.value}\n size=\"md\"\n >\n <form className=\"size-full px-3\">\n {isJsonFormat ? (\n <p className=\"text-neutral py-4 text-sm\">{confirmation.message}</p>\n ) : (\n <p className=\"text-neutral py-4 text-sm\">\n {confirmation.differentFormatMessage}\n </p>\n )}\n <div className=\"mt-12 flex justify-end gap-2 max-md:flex-col\">\n <Form.Button\n label={confirmation.cancelButton.label.value}\n disabled={!isEdited || isLoading}\n color=\"text\"\n className=\"max-md:w-full\"\n variant=\"outline\"\n onClick={() => setIsFormatAlertModalOpen(false)}\n >\n {confirmation.cancelButton.text}\n </Form.Button>\n <Form.Button\n label={confirmation.confirmButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Save}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handleSaveDictionaryConfirmation}\n >\n {confirmation.confirmButton.text}\n </Form.Button>\n </div>\n </form>\n </Modal>\n <form\n className={cn('flex justify-end gap-2 max-md:flex-col', className)}\n {...props}\n >\n {isEdited && (\n <Form.Button\n label={resetButton.label.value}\n disabled={!isEdited}\n Icon={RotateCcw}\n variant=\"outline\"\n color=\"text\"\n className=\"max-md:w-full\"\n onClick={() => restoreEditedContent(dictionary.key)}\n >\n {resetButton.text}\n </Form.Button>\n )}\n {mode.includes('local') && (\n <Form.Button\n label={downloadButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Download}\n color=\"text\"\n variant={isAuthenticated ? 'outline' : 'default'}\n className=\"max-md:w-full\"\n isLoading={isWriting}\n onClick={() => setIsFormatAlertModalOpen(true)}\n >\n {downloadButton.text}\n </Form.Button>\n )}\n {mode.includes('remote') && isAuthenticated && isLocalDictionary && (\n <Form.Button\n label={publishButton.label.value}\n disabled={isLoading}\n Icon={ArrowUpFromLine}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handlePushDictionary}\n >\n {publishButton.text}\n </Form.Button>\n )}\n {mode.includes('remote') &&\n isAuthenticated &&\n !isLocalDictionary &&\n isEdited && (\n <Form.Button\n label={saveButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Save}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handlePushDictionary}\n >\n {saveButton.text}\n </Form.Button>\n )}\n </form>\n </>\n );\n};\n"],"names":["useState","useDictionariesRecordActions","useWriteDictionary","usePushDictionaries","useEditedContent","useDictionary","saveDictionaryContent","useAuth","jsxs","Fragment","jsx","Modal","Form","Save","cn","RotateCcw","Download","ArrowUpFromLine"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BO,MAAM,WAAuC,CAAC;AAAA,EACnD;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,CAAC,wBAAwB,yBAAyB,IAAIA,aAAAA,SAAS,KAAK;AACpE,QAAA,EAAE,oBAAoB,IAAIC,yCAA6B;AAC7D,QAAM,EAAE,iBAAiB,WAAW,UAAA,IAAcC,uBAAAA,mBAAmB;AACrE,QAAM,EAAE,kBAAkB,WAAW,UAAA,IAAcC,uBAAAA,oBAAoB;AACv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N,WAAU;AAAA,cACV,SAAS,MAAM,qBAAqB,WAAW,GAAG;AAAA,cAEjD,UAAY,YAAA;AAAA,YAAA;AAAA,UACf;AAAA,UAED,KAAK,SAAS,OAAO,KACpBL,2BAAA;AAAA,YAACE,sCAAAA,KAAK;AAAA,YAAL;AAAA,cACC,OAAO,eAAe,MAAM;AAAA,cAC5B,UAAU,CAAC,YAAY;AAAA,cACvB,MAAMI,YAAA;AAAA,cACN,OAAM;AAAA,cACN,SAAS,kBAAkB,YAAY;AAAA,cACvC,WAAU;AAAA,cACV,WAAW;AAAA,cACX,SAAS,MAAM,0BAA0B,IAAI;AAAA,cAE5C,UAAe,eAAA;AAAA,YAAA;AAAA,UAClB;AAAA,UAED,KAAK,SAAS,QAAQ,KAAK,mBAAmB,qBAC7CN,2BAAA;AAAA,YAACE,sCAAAA,KAAK;AAAA,YAAL;AAAA,cACC,OAAO,cAAc,MAAM;AAAA,cAC3B,UAAU;AAAA,cACV,MAAMK,YAAA;AAAA,cACN,OAAM;AAAA,cACN,WAAU;AAAA,cACV,WAAW;AAAA,cACX,SAAS;AAAA,cAER,UAAc,cAAA;AAAA,YAAA;AAAA,UACjB;AAAA,UAED,KAAK,SAAS,QAAQ,KACrB,mBACA,CAAC,qBACD,YACEP,2BAAA;AAAA,YAACE,sCAAAA,KAAK;AAAA,YAAL;AAAA,cACC,OAAO,WAAW,MAAM;AAAA,cACxB,UAAU,CAAC,YAAY;AAAA,cACvB,MAAMC,YAAA;AAAA,cACN,OAAM;AAAA,cACN,WAAU;AAAA,cACV,WAAW;AAAA,cACX,SAAS;AAAA,cAER,UAAW,WAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QACd;AAAA,MAAA;AAAA,IAAA;AAAA,EAEN,GACF;AAEJ;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"SaveForm.d.ts","sourceRoot":"","sources":["../../../../src/components/DictionaryFieldEditor/SaveForm/SaveForm.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAMjD,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EAEvB,KAAK,EAAE,EACR,MAAM,OAAO,CAAC;AAQf,KAAK,sBAAsB,GAAG;IAC5B,UAAU,EAAE,UAAU,CAAC;IACvB,IAAI,EAAE,CAAC,OAAO,GAAG,QAAQ,CAAC,EAAE,CAAC;CAC9B,GAAG,iBAAiB,CAAC,kBAAkB,CAAC,eAAe,CAAC,EAAE,eAAe,CAAC,CAAC;AAE5E,eAAO,MAAM,QAAQ,EAAE,EAAE,CAAC,sBAAsB,CA8H/C,CAAC"}
1
+ {"version":3,"file":"SaveForm.d.ts","sourceRoot":"","sources":["../../../../src/components/DictionaryFieldEditor/SaveForm/SaveForm.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAMjD,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,EAAE,EAER,MAAM,OAAO,CAAC;AASf,KAAK,sBAAsB,GAAG;IAC5B,UAAU,EAAE,UAAU,CAAC;IACvB,IAAI,EAAE,CAAC,OAAO,GAAG,QAAQ,CAAC,EAAE,CAAC;CAC9B,GAAG,iBAAiB,CAAC,kBAAkB,CAAC,eAAe,CAAC,EAAE,eAAe,CAAC,CAAC;AAE5E,eAAO,MAAM,QAAQ,EAAE,EAAE,CAAC,sBAAsB,CAsK/C,CAAC"}
@@ -1,8 +1,8 @@
1
1
  "use client";
2
- import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
3
3
  import { useDictionariesRecordActions, useEditedContent } from "@intlayer/editor-react";
4
- import { RotateCcw, Download, ArrowUpFromLine, Save } from "lucide-react";
5
- import { useMemo } from "react";
4
+ import { Save, RotateCcw, Download, ArrowUpFromLine } from "lucide-react";
5
+ import { useState } from "react";
6
6
  import { useDictionary } from "react-intlayer";
7
7
  import "../../../hooks/useScrollBlockage/useScrollBlockageStore.mjs";
8
8
  import "../../../hooks/useAsync/useAsyncStateStore.mjs";
@@ -16,7 +16,7 @@ import "@intlayer/api";
16
16
  import "@hookform/resolvers";
17
17
  import "react-hook-form";
18
18
  import "../../Form/FormField.mjs";
19
- import { F as Form } from "../../../Form-MjLzPGze.js";
19
+ import { F as Form } from "../../../Form-CriPBaZk.js";
20
20
  import "../../Auth/SignInForm/signIn.content.mjs";
21
21
  import "zod";
22
22
  import "../../Auth/SignInForm/useSignInSchema.content.mjs";
@@ -26,7 +26,7 @@ import "../../Auth/ChangePasswordForm/changePasswordForm.content.mjs";
26
26
  import "../../Auth/ChangePasswordForm/useChangePasswordSchema.content.mjs";
27
27
  import "../../Auth/ResetPasswordForm/resetPasswordContent.content.mjs";
28
28
  import "../../Auth/ResetPasswordForm/useResetPasswordSchema.content.mjs";
29
- import "../../Modal/Modal.mjs";
29
+ import { Modal } from "../../Modal/Modal.mjs";
30
30
  import "@intlayer/config/built";
31
31
  import "../../Auth/VerifyEmailForm/index.content.mjs";
32
32
  import "../../Auth/DefineNewPasswordForm/defineNewPasswordForm.content.mjs";
@@ -38,26 +38,25 @@ const SaveForm = ({
38
38
  className,
39
39
  ...props
40
40
  }) => {
41
+ const [isFormatAlertModalOpen, setIsFormatAlertModalOpen] = useState(false);
41
42
  const { setLocaleDictionary } = useDictionariesRecordActions();
42
43
  const { writeDictionary, isLoading: isWriting } = useWriteDictionary();
43
44
  const { pushDictionaries, isLoading: isPushing } = usePushDictionaries();
44
45
  const isLoading = isWriting || isPushing;
46
+ const isJsonFormat = mode.includes("local") && dictionary.filePath?.endsWith(".json");
45
47
  const { editedContent, restoreEditedContent } = useEditedContent();
46
- const { resetButton, saveButton, publishButton, downloadButton } = useDictionary(saveDictionaryContent);
48
+ const {
49
+ resetButton,
50
+ saveButton,
51
+ publishButton,
52
+ downloadButton,
53
+ confirmation
54
+ } = useDictionary(saveDictionaryContent);
47
55
  const { isAuthenticated } = useAuth();
48
- const editedDictionary = useMemo(
49
- () => editedContent?.[dictionary.key],
50
- [editedContent, dictionary.key]
51
- );
52
- const isEdited = useMemo(
53
- () => editedDictionary && JSON.stringify(editedDictionary) !== JSON.stringify(dictionary),
54
- [editedDictionary, dictionary, mode]
55
- );
56
- const isLocalDictionary = useMemo(
57
- () => typeof dictionary?._id === "undefined",
58
- [dictionary]
59
- );
60
- const handleSaveDictionary = async () => {
56
+ const editedDictionary = editedContent?.[dictionary.key];
57
+ const isEdited = editedDictionary && JSON.stringify(editedDictionary) !== JSON.stringify(dictionary);
58
+ const isLocalDictionary = typeof dictionary?._id === "undefined";
59
+ const handleSaveDictionaryConfirmation = async () => {
61
60
  if (!editedContent?.[dictionary.key]) return;
62
61
  const updatedDictionary = {
63
62
  ...dictionary,
@@ -81,68 +80,108 @@ const SaveForm = ({
81
80
  }
82
81
  });
83
82
  };
84
- return /* @__PURE__ */ jsxs(
85
- "form",
86
- {
87
- className: cn("flex justify-end gap-2 max-md:flex-col", className),
88
- ...props,
89
- children: [
90
- isEdited && /* @__PURE__ */ jsx(
91
- Form.Button,
92
- {
93
- label: resetButton.label.value,
94
- disabled: !isEdited,
95
- Icon: RotateCcw,
96
- variant: "outline",
97
- color: "text",
98
- className: "max-md:w-full",
99
- onClick: () => restoreEditedContent(dictionary.key),
100
- children: resetButton.text
101
- }
102
- ),
103
- mode.includes("local") && /* @__PURE__ */ jsx(
104
- Form.Button,
105
- {
106
- label: downloadButton.label.value,
107
- disabled: !isEdited || isLoading,
108
- Icon: Download,
109
- color: "text",
110
- variant: isAuthenticated ? "outline" : "default",
111
- className: "max-md:w-full",
112
- isLoading: isWriting,
113
- onClick: handleSaveDictionary,
114
- children: downloadButton.text
115
- }
116
- ),
117
- mode.includes("remote") && isAuthenticated && isLocalDictionary && /* @__PURE__ */ jsx(
118
- Form.Button,
119
- {
120
- label: publishButton.label.value,
121
- disabled: isLoading,
122
- Icon: ArrowUpFromLine,
123
- color: "text",
124
- className: "max-md:w-full",
125
- isLoading: isPushing,
126
- onClick: handlePushDictionary,
127
- children: publishButton.text
128
- }
129
- ),
130
- mode.includes("remote") && isAuthenticated && !isLocalDictionary && isEdited && /* @__PURE__ */ jsx(
131
- Form.Button,
132
- {
133
- label: saveButton.label.value,
134
- disabled: !isEdited || isLoading,
135
- Icon: Save,
136
- color: "text",
137
- className: "max-md:w-full",
138
- isLoading: isPushing,
139
- onClick: handlePushDictionary,
140
- children: saveButton.text
141
- }
142
- )
143
- ]
144
- }
145
- );
83
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
84
+ /* @__PURE__ */ jsx(
85
+ Modal,
86
+ {
87
+ isOpen: isFormatAlertModalOpen,
88
+ title: confirmation.title.value,
89
+ size: "md",
90
+ children: /* @__PURE__ */ jsxs("form", { className: "size-full px-3", children: [
91
+ isJsonFormat ? /* @__PURE__ */ jsx("p", { className: "text-neutral py-4 text-sm", children: confirmation.message }) : /* @__PURE__ */ jsx("p", { className: "text-neutral py-4 text-sm", children: confirmation.differentFormatMessage }),
92
+ /* @__PURE__ */ jsxs("div", { className: "mt-12 flex justify-end gap-2 max-md:flex-col", children: [
93
+ /* @__PURE__ */ jsx(
94
+ Form.Button,
95
+ {
96
+ label: confirmation.cancelButton.label.value,
97
+ disabled: !isEdited || isLoading,
98
+ color: "text",
99
+ className: "max-md:w-full",
100
+ variant: "outline",
101
+ onClick: () => setIsFormatAlertModalOpen(false),
102
+ children: confirmation.cancelButton.text
103
+ }
104
+ ),
105
+ /* @__PURE__ */ jsx(
106
+ Form.Button,
107
+ {
108
+ label: confirmation.confirmButton.label.value,
109
+ disabled: !isEdited || isLoading,
110
+ Icon: Save,
111
+ color: "text",
112
+ className: "max-md:w-full",
113
+ isLoading: isPushing,
114
+ onClick: handleSaveDictionaryConfirmation,
115
+ children: confirmation.confirmButton.text
116
+ }
117
+ )
118
+ ] })
119
+ ] })
120
+ }
121
+ ),
122
+ /* @__PURE__ */ jsxs(
123
+ "form",
124
+ {
125
+ className: cn("flex justify-end gap-2 max-md:flex-col", className),
126
+ ...props,
127
+ children: [
128
+ isEdited && /* @__PURE__ */ jsx(
129
+ Form.Button,
130
+ {
131
+ label: resetButton.label.value,
132
+ disabled: !isEdited,
133
+ Icon: RotateCcw,
134
+ variant: "outline",
135
+ color: "text",
136
+ className: "max-md:w-full",
137
+ onClick: () => restoreEditedContent(dictionary.key),
138
+ children: resetButton.text
139
+ }
140
+ ),
141
+ mode.includes("local") && /* @__PURE__ */ jsx(
142
+ Form.Button,
143
+ {
144
+ label: downloadButton.label.value,
145
+ disabled: !isEdited || isLoading,
146
+ Icon: Download,
147
+ color: "text",
148
+ variant: isAuthenticated ? "outline" : "default",
149
+ className: "max-md:w-full",
150
+ isLoading: isWriting,
151
+ onClick: () => setIsFormatAlertModalOpen(true),
152
+ children: downloadButton.text
153
+ }
154
+ ),
155
+ mode.includes("remote") && isAuthenticated && isLocalDictionary && /* @__PURE__ */ jsx(
156
+ Form.Button,
157
+ {
158
+ label: publishButton.label.value,
159
+ disabled: isLoading,
160
+ Icon: ArrowUpFromLine,
161
+ color: "text",
162
+ className: "max-md:w-full",
163
+ isLoading: isPushing,
164
+ onClick: handlePushDictionary,
165
+ children: publishButton.text
166
+ }
167
+ ),
168
+ mode.includes("remote") && isAuthenticated && !isLocalDictionary && isEdited && /* @__PURE__ */ jsx(
169
+ Form.Button,
170
+ {
171
+ label: saveButton.label.value,
172
+ disabled: !isEdited || isLoading,
173
+ Icon: Save,
174
+ color: "text",
175
+ className: "max-md:w-full",
176
+ isLoading: isPushing,
177
+ onClick: handlePushDictionary,
178
+ children: saveButton.text
179
+ }
180
+ )
181
+ ]
182
+ }
183
+ )
184
+ ] });
146
185
  };
147
186
  export {
148
187
  SaveForm
@@ -1 +1 @@
1
- {"version":3,"file":"SaveForm.mjs","sources":["../../../../src/components/DictionaryFieldEditor/SaveForm/SaveForm.tsx"],"sourcesContent":["'use client';\n\nimport type { Dictionary as DistantDictionary } from '@intlayer/backend';\nimport type { Dictionary } from '@intlayer/core';\nimport {\n useDictionariesRecordActions,\n useEditedContent,\n} from '@intlayer/editor-react';\nimport { ArrowUpFromLine, Download, RotateCcw, Save } from 'lucide-react';\nimport {\n type DetailedHTMLProps,\n type FormHTMLAttributes,\n useMemo,\n type FC,\n} from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { usePushDictionaries, useWriteDictionary } from '../../../hooks';\nimport { cn } from '../../../utils/cn';\nimport { useAuth } from '../../Auth';\nimport { Form } from '../../Form';\nimport { saveDictionaryContent } from './saveForm.content';\n\ntype DictionaryDetailsProps = {\n dictionary: Dictionary;\n mode: ('local' | 'remote')[];\n} & DetailedHTMLProps<FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>;\n\nexport const SaveForm: FC<DictionaryDetailsProps> = ({\n dictionary,\n mode,\n className,\n ...props\n}) => {\n const { setLocaleDictionary } = useDictionariesRecordActions();\n const { writeDictionary, isLoading: isWriting } = useWriteDictionary();\n const { pushDictionaries, isLoading: isPushing } = usePushDictionaries();\n const isLoading = isWriting || isPushing;\n\n const { editedContent, restoreEditedContent } = useEditedContent();\n const { resetButton, saveButton, publishButton, downloadButton } =\n useDictionary(saveDictionaryContent);\n const { isAuthenticated } = useAuth();\n\n const editedDictionary = useMemo(\n () => editedContent?.[dictionary.key],\n [editedContent, dictionary.key]\n );\n\n const isEdited = useMemo(\n () =>\n editedDictionary &&\n JSON.stringify(editedDictionary) !== JSON.stringify(dictionary),\n [editedDictionary, dictionary, mode]\n );\n\n const isLocalDictionary = useMemo(\n () => typeof (dictionary as DistantDictionary)?._id === 'undefined',\n [dictionary]\n );\n\n const handleSaveDictionary = async () => {\n if (!editedContent?.[dictionary.key]) return;\n\n const updatedDictionary = {\n ...dictionary,\n ...editedContent?.[dictionary.key],\n };\n\n await writeDictionary(updatedDictionary).then(() => {\n setLocaleDictionary(editedContent?.[dictionary.key]);\n restoreEditedContent(dictionary.key);\n });\n };\n\n const handlePushDictionary = async () => {\n if (!editedContent?.[dictionary.key]) return;\n\n const updatedDictionary = {\n ...dictionary,\n ...editedContent?.[dictionary.key],\n };\n\n await pushDictionaries([updatedDictionary]).then((res) => {\n if (res) {\n setLocaleDictionary(editedContent?.[dictionary.key]);\n restoreEditedContent(dictionary.key);\n }\n });\n };\n\n return (\n <form\n className={cn('flex justify-end gap-2 max-md:flex-col', className)}\n {...props}\n >\n {isEdited && (\n <Form.Button\n label={resetButton.label.value}\n disabled={!isEdited}\n Icon={RotateCcw}\n variant=\"outline\"\n color=\"text\"\n className=\"max-md:w-full\"\n onClick={() => restoreEditedContent(dictionary.key)}\n >\n {resetButton.text}\n </Form.Button>\n )}\n {mode.includes('local') && (\n <Form.Button\n label={downloadButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Download}\n color=\"text\"\n variant={isAuthenticated ? 'outline' : 'default'}\n className=\"max-md:w-full\"\n isLoading={isWriting}\n onClick={handleSaveDictionary}\n >\n {downloadButton.text}\n </Form.Button>\n )}\n {mode.includes('remote') && isAuthenticated && isLocalDictionary && (\n <Form.Button\n label={publishButton.label.value}\n disabled={isLoading}\n Icon={ArrowUpFromLine}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handlePushDictionary}\n >\n {publishButton.text}\n </Form.Button>\n )}\n {mode.includes('remote') &&\n isAuthenticated &&\n !isLocalDictionary &&\n isEdited && (\n <Form.Button\n label={saveButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Save}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handlePushDictionary}\n >\n {saveButton.text}\n </Form.Button>\n )}\n </form>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BO,MAAM,WAAuC,CAAC;AAAA,EACnD;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACE,QAAA,EAAE,oBAAoB,IAAI,6BAA6B;AAC7D,QAAM,EAAE,iBAAiB,WAAW,UAAA,IAAc,mBAAmB;AACrE,QA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{"version":3,"file":"SaveForm.mjs","sources":["../../../../src/components/DictionaryFieldEditor/SaveForm/SaveForm.tsx"],"sourcesContent":["'use client';\n\nimport type { Dictionary as DistantDictionary } from '@intlayer/backend';\nimport type { Dictionary } from '@intlayer/core';\nimport {\n useDictionariesRecordActions,\n useEditedContent,\n} from '@intlayer/editor-react';\nimport { ArrowUpFromLine, Download, RotateCcw, Save } from 'lucide-react';\nimport {\n type DetailedHTMLProps,\n type FormHTMLAttributes,\n type FC,\n useState,\n} from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport { usePushDictionaries, useWriteDictionary } from '../../../hooks';\nimport { cn } from '../../../utils/cn';\nimport { useAuth } from '../../Auth';\nimport { Form } from '../../Form';\nimport { saveDictionaryContent } from './saveForm.content';\nimport { Modal } from '../../../components/Modal';\n\ntype DictionaryDetailsProps = {\n dictionary: Dictionary;\n mode: ('local' | 'remote')[];\n} & DetailedHTMLProps<FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>;\n\nexport const SaveForm: FC<DictionaryDetailsProps> = ({\n dictionary,\n mode,\n className,\n ...props\n}) => {\n const [isFormatAlertModalOpen, setIsFormatAlertModalOpen] = useState(false);\n const { setLocaleDictionary } = useDictionariesRecordActions();\n const { writeDictionary, isLoading: isWriting } = useWriteDictionary();\n const { pushDictionaries, isLoading: isPushing } = usePushDictionaries();\n const isLoading = isWriting || isPushing;\n const isJsonFormat =\n mode.includes('local') && dictionary.filePath?.endsWith('.json');\n\n const { editedContent, restoreEditedContent } = useEditedContent();\n const {\n resetButton,\n saveButton,\n publishButton,\n downloadButton,\n confirmation,\n } = useDictionary(saveDictionaryContent);\n const { isAuthenticated } = useAuth();\n\n const editedDictionary = editedContent?.[dictionary.key];\n\n const isEdited =\n editedDictionary &&\n JSON.stringify(editedDictionary) !== JSON.stringify(dictionary);\n\n const isLocalDictionary =\n typeof (dictionary as DistantDictionary)?._id === 'undefined';\n\n const handleSaveDictionaryConfirmation = async () => {\n if (!editedContent?.[dictionary.key]) return;\n\n const updatedDictionary = {\n ...dictionary,\n ...editedContent?.[dictionary.key],\n };\n\n await writeDictionary(updatedDictionary).then(() => {\n setLocaleDictionary(editedContent?.[dictionary.key]);\n restoreEditedContent(dictionary.key);\n });\n };\n\n const handlePushDictionary = async () => {\n if (!editedContent?.[dictionary.key]) return;\n\n const updatedDictionary = {\n ...dictionary,\n ...editedContent?.[dictionary.key],\n };\n\n await pushDictionaries([updatedDictionary]).then((res) => {\n if (res) {\n setLocaleDictionary(editedContent?.[dictionary.key]);\n restoreEditedContent(dictionary.key);\n }\n });\n };\n\n return (\n <>\n <Modal\n isOpen={isFormatAlertModalOpen}\n title={confirmation.title.value}\n size=\"md\"\n >\n <form className=\"size-full px-3\">\n {isJsonFormat ? (\n <p className=\"text-neutral py-4 text-sm\">{confirmation.message}</p>\n ) : (\n <p className=\"text-neutral py-4 text-sm\">\n {confirmation.differentFormatMessage}\n </p>\n )}\n <div className=\"mt-12 flex justify-end gap-2 max-md:flex-col\">\n <Form.Button\n label={confirmation.cancelButton.label.value}\n disabled={!isEdited || isLoading}\n color=\"text\"\n className=\"max-md:w-full\"\n variant=\"outline\"\n onClick={() => setIsFormatAlertModalOpen(false)}\n >\n {confirmation.cancelButton.text}\n </Form.Button>\n <Form.Button\n label={confirmation.confirmButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Save}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handleSaveDictionaryConfirmation}\n >\n {confirmation.confirmButton.text}\n </Form.Button>\n </div>\n </form>\n </Modal>\n <form\n className={cn('flex justify-end gap-2 max-md:flex-col', className)}\n {...props}\n >\n {isEdited && (\n <Form.Button\n label={resetButton.label.value}\n disabled={!isEdited}\n Icon={RotateCcw}\n variant=\"outline\"\n color=\"text\"\n className=\"max-md:w-full\"\n onClick={() => restoreEditedContent(dictionary.key)}\n >\n {resetButton.text}\n </Form.Button>\n )}\n {mode.includes('local') && (\n <Form.Button\n label={downloadButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Download}\n color=\"text\"\n variant={isAuthenticated ? 'outline' : 'default'}\n className=\"max-md:w-full\"\n isLoading={isWriting}\n onClick={() => setIsFormatAlertModalOpen(true)}\n >\n {downloadButton.text}\n </Form.Button>\n )}\n {mode.includes('remote') && isAuthenticated && isLocalDictionary && (\n <Form.Button\n label={publishButton.label.value}\n disabled={isLoading}\n Icon={ArrowUpFromLine}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handlePushDictionary}\n >\n {publishButton.text}\n </Form.Button>\n )}\n {mode.includes('remote') &&\n isAuthenticated &&\n !isLocalDictionary &&\n isEdited && (\n <Form.Button\n label={saveButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Save}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isPushing}\n onClick={handlePushDictionary}\n >\n {saveButton.text}\n </Form.Button>\n )}\n </form>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BO,MAAM,WAAuC,CAAC;AAAA,EACnD;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,CAAC,wBAAwB,yBAAyB,IAAI,SAAS,KAAK;AACpE,QAAA,EAAE,oBAAoB,IAAI,6BAA6B;AAC7D,QAAM,EAAE,iBAAiB,WAAW,UAAA,IAAc,mBAAmB;AACrE,QAAM,EAAE,kBAAkB,WAAW,UAAA,IAAc,oBAAoB;AACvE,QAAM,YAAY,aAAa;AACzB,QAAA,eACJ,KAAK,SAAS,OAAO,KAAK,WAAW,UAAU,SAAS,OAAO;AAEjE,QAAM,EAAE,eAAe,qBAAqB,IAAI,iBAAiB;AAC3D,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACE,cAAc,qBAAqB;AACjC,QAAA,EAAE,gBAAgB,IAAI,QAAQ;AAE9B,QAAA,mBAAmB,gBAAgB,WAAW,GA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