@intlayer/design-system 5.1.4 → 5.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/dist/.vite/manifest.json +34 -88
  2. package/dist/Form-BZUDRfoN.js.map +1 -1
  3. package/dist/Form-yi0CMK-a.cjs.map +1 -1
  4. package/dist/components/Auth/ExternalsLoginButtons/ExternalsLoginButtons.cjs +1 -1
  5. package/dist/components/Auth/ExternalsLoginButtons/ExternalsLoginButtons.mjs +1 -1
  6. package/dist/components/Command/index.d.ts +1 -1
  7. package/dist/components/Container/index.cjs +5 -6
  8. package/dist/components/Container/index.cjs.map +1 -1
  9. package/dist/components/Container/index.mjs +5 -6
  10. package/dist/components/Container/index.mjs.map +1 -1
  11. package/dist/components/DictionaryEditor/DictionaryEditor.cjs +3 -3
  12. package/dist/components/DictionaryEditor/DictionaryEditor.cjs.map +1 -1
  13. package/dist/components/DictionaryEditor/DictionaryEditor.d.ts +1 -1
  14. package/dist/components/DictionaryEditor/DictionaryEditor.d.ts.map +1 -1
  15. package/dist/components/DictionaryEditor/DictionaryEditor.mjs +3 -3
  16. package/dist/components/DictionaryEditor/DictionaryEditor.mjs.map +1 -1
  17. package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.cjs +33 -20
  18. package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.cjs.map +1 -1
  19. package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.d.ts.map +1 -1
  20. package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.mjs +34 -21
  21. package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.mjs.map +1 -1
  22. package/dist/components/DictionaryFieldEditor/ContentEditor.cjs +2 -2
  23. package/dist/components/DictionaryFieldEditor/ContentEditor.cjs.map +1 -1
  24. package/dist/components/DictionaryFieldEditor/ContentEditor.mjs +3 -3
  25. package/dist/components/DictionaryFieldEditor/ContentEditor.mjs.map +1 -1
  26. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.cjs +10 -7
  27. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.cjs.map +1 -1
  28. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.d.ts.map +1 -1
  29. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs +10 -7
  30. package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs.map +1 -1
  31. package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.cjs.map +1 -1
  32. package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.d.ts +1 -1
  33. package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.d.ts.map +1 -1
  34. package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.mjs.map +1 -1
  35. package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.cjs +1 -1
  36. package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs +1 -1
  37. package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.cjs +92 -120
  38. package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.cjs.map +1 -1
  39. package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.d.ts +1 -1
  40. package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.d.ts.map +1 -1
  41. package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs +94 -122
  42. package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs.map +1 -1
  43. package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.cjs +0 -143
  44. package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.cjs.map +1 -1
  45. package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.d.ts +0 -143
  46. package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.d.ts.map +1 -1
  47. package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.mjs +0 -143
  48. package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.mjs.map +1 -1
  49. package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.cjs +1 -2
  50. package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.cjs.map +1 -1
  51. package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.d.ts +0 -3
  52. package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.d.ts.map +1 -1
  53. package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.mjs +1 -2
  54. package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.mjs.map +1 -1
  55. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.cjs +51 -70
  56. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.cjs.map +1 -1
  57. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.d.ts +1 -1
  58. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.d.ts.map +1 -1
  59. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs +51 -70
  60. package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs.map +1 -1
  61. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs +52 -103
  62. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs.map +1 -1
  63. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.d.ts +3 -3
  64. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.d.ts.map +1 -1
  65. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs +56 -107
  66. package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs.map +1 -1
  67. package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.cjs +0 -32
  68. package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.cjs.map +1 -1
  69. package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.d.ts +0 -32
  70. package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.d.ts.map +1 -1
  71. package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.mjs +0 -32
  72. package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.mjs.map +1 -1
  73. package/dist/components/DictionaryFieldEditor/StructureView/StructureView.cjs +1 -0
  74. package/dist/components/DictionaryFieldEditor/StructureView/StructureView.cjs.map +1 -1
  75. package/dist/components/DictionaryFieldEditor/StructureView/StructureView.d.ts.map +1 -1
  76. package/dist/components/DictionaryFieldEditor/StructureView/StructureView.mjs +1 -0
  77. package/dist/components/DictionaryFieldEditor/StructureView/StructureView.mjs.map +1 -1
  78. package/dist/components/DictionaryFieldEditor/index.cjs +0 -2
  79. package/dist/components/DictionaryFieldEditor/index.cjs.map +1 -1
  80. package/dist/components/DictionaryFieldEditor/index.d.ts +0 -1
  81. package/dist/components/DictionaryFieldEditor/index.d.ts.map +1 -1
  82. package/dist/components/DictionaryFieldEditor/index.mjs +0 -2
  83. package/dist/components/DictionaryFieldEditor/index.mjs.map +1 -1
  84. package/dist/components/Form/FormBase.cjs +0 -1
  85. package/dist/components/Form/FormBase.cjs.map +1 -1
  86. package/dist/components/Form/FormBase.d.ts +1 -4
  87. package/dist/components/Form/FormBase.d.ts.map +1 -1
  88. package/dist/components/Form/FormBase.mjs +0 -1
  89. package/dist/components/Form/FormBase.mjs.map +1 -1
  90. package/dist/components/Form/elements/EditableFieldInputElement.d.ts +1 -1
  91. package/dist/components/Form/elements/EditableFieldInputElement.d.ts.map +1 -1
  92. package/dist/components/Form/elements/EditableFieldTextAreaElement.d.ts +1 -1
  93. package/dist/components/Form/elements/EditableFieldTextAreaElement.d.ts.map +1 -1
  94. package/dist/components/Input/Checkbox.cjs +0 -1
  95. package/dist/components/Input/Checkbox.cjs.map +1 -1
  96. package/dist/components/Input/Checkbox.mjs +0 -1
  97. package/dist/components/Input/Checkbox.mjs.map +1 -1
  98. package/dist/components/Input/Input.cjs +1 -1
  99. package/dist/components/Input/Input.cjs.map +1 -1
  100. package/dist/components/Input/Input.mjs +1 -1
  101. package/dist/components/Input/Input.mjs.map +1 -1
  102. package/dist/components/KeyboardScreenAdapter/index.cjs +25 -0
  103. package/dist/components/KeyboardScreenAdapter/index.cjs.map +1 -0
  104. package/dist/components/KeyboardScreenAdapter/index.d.ts +3 -0
  105. package/dist/components/KeyboardScreenAdapter/index.d.ts.map +1 -0
  106. package/dist/components/KeyboardScreenAdapter/index.mjs +25 -0
  107. package/dist/components/KeyboardScreenAdapter/index.mjs.map +1 -0
  108. package/dist/components/MaxHeightSmoother/index.cjs +2 -0
  109. package/dist/components/MaxHeightSmoother/index.cjs.map +1 -1
  110. package/dist/components/MaxHeightSmoother/index.d.ts.map +1 -1
  111. package/dist/components/MaxHeightSmoother/index.mjs +2 -0
  112. package/dist/components/MaxHeightSmoother/index.mjs.map +1 -1
  113. package/dist/components/Modal/Modal.cjs +15 -13
  114. package/dist/components/Modal/Modal.cjs.map +1 -1
  115. package/dist/components/Modal/Modal.d.ts.map +1 -1
  116. package/dist/components/Modal/Modal.mjs +15 -13
  117. package/dist/components/Modal/Modal.mjs.map +1 -1
  118. package/dist/components/RightDrawer/RightDrawer.cjs +1 -1
  119. package/dist/components/RightDrawer/RightDrawer.cjs.map +1 -1
  120. package/dist/components/RightDrawer/RightDrawer.mjs +1 -1
  121. package/dist/components/RightDrawer/RightDrawer.mjs.map +1 -1
  122. package/dist/components/Select/Multiselect.cjs +0 -1
  123. package/dist/components/Select/Multiselect.cjs.map +1 -1
  124. package/dist/components/Select/Multiselect.d.ts.map +1 -1
  125. package/dist/components/Select/Multiselect.mjs +1 -2
  126. package/dist/components/Select/Multiselect.mjs.map +1 -1
  127. package/dist/components/Select/Select.cjs +0 -1
  128. package/dist/components/Select/Select.cjs.map +1 -1
  129. package/dist/components/Select/Select.d.ts.map +1 -1
  130. package/dist/components/Select/Select.mjs +0 -1
  131. package/dist/components/Select/Select.mjs.map +1 -1
  132. package/dist/components/index.cjs +2 -2
  133. package/dist/components/index.d.ts +1 -0
  134. package/dist/components/index.d.ts.map +1 -1
  135. package/dist/components/index.mjs +2 -2
  136. package/dist/hooks/index.cjs +2 -0
  137. package/dist/hooks/index.cjs.map +1 -1
  138. package/dist/hooks/index.d.ts +1 -0
  139. package/dist/hooks/index.d.ts.map +1 -1
  140. package/dist/hooks/index.mjs +2 -0
  141. package/dist/hooks/index.mjs.map +1 -1
  142. package/dist/hooks/useAsync/useAsyncStateStore.cjs +8 -14
  143. package/dist/hooks/useAsync/useAsyncStateStore.cjs.map +1 -1
  144. package/dist/hooks/useAsync/useAsyncStateStore.d.ts.map +1 -1
  145. package/dist/hooks/useAsync/useAsyncStateStore.mjs +8 -14
  146. package/dist/hooks/useAsync/useAsyncStateStore.mjs.map +1 -1
  147. package/dist/hooks/useKeyboardDetector.cjs +27 -0
  148. package/dist/hooks/useKeyboardDetector.cjs.map +1 -0
  149. package/dist/hooks/useKeyboardDetector.d.ts +5 -0
  150. package/dist/hooks/useKeyboardDetector.d.ts.map +1 -0
  151. package/dist/hooks/useKeyboardDetector.mjs +27 -0
  152. package/dist/hooks/useKeyboardDetector.mjs.map +1 -0
  153. package/dist/{index-BTDHuTxL.js → index-B1w5h_6-.js} +7 -7
  154. package/dist/index-B1w5h_6-.js.map +1 -0
  155. package/dist/{index-Db5Dym4h.cjs → index-U1U6ySIn.cjs} +7 -7
  156. package/dist/index-U1U6ySIn.cjs.map +1 -0
  157. package/dist/tailwind.css +1 -1
  158. package/package.json +17 -17
  159. package/dist/index-BTDHuTxL.js.map +0 -1
  160. package/dist/index-Db5Dym4h.cjs.map +0 -1
@@ -3,7 +3,6 @@
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
4
  const jsxRuntime = require("react/jsx-runtime");
5
5
  const editorReact = require("@intlayer/editor-react");
6
- const intlayer = require("intlayer");
7
6
  const lucideReact = require("lucide-react");
8
7
  const ReactExports = require("react");
9
8
  const reactIntlayer = require("react-intlayer");
@@ -11,123 +10,71 @@ require("../../../hooks/useScrollBlockage/useScrollBlockageStore.cjs");
11
10
  require("../../../hooks/useAsync/useAsyncStateStore.cjs");
12
11
  const hooks_intlayerAPIHooks = require("../../../hooks/intlayerAPIHooks.cjs");
13
12
  require("deepmerge");
14
- require("../../../index-Db5Dym4h.cjs");
15
- require("@intlayer/config/client");
16
- require("../../Button/Button.cjs");
17
- require("../../Auth/ExternalsLoginButtons/externalsLoginButtons.content.cjs");
18
- const components_Form_FormBase = require("../../Form/FormBase.cjs");
13
+ const utils_cn = require("../../../utils/cn.cjs");
14
+ require("@hookform/resolvers");
15
+ require("react-hook-form");
19
16
  require("../../Form/FormField.cjs");
20
17
  const components_Form_layout_FormItemLayout = require("../../../Form-yi0CMK-a.cjs");
21
- require("../../Auth/SignInForm/signIn.content.cjs");
22
- require("zod");
23
- require("../../Auth/SignInForm/useSignInSchema.content.cjs");
24
- require("../../Auth/SignUpForm/signUpForm.content.cjs");
25
- require("../../Auth/SignUpForm/useSignUpSchema.content.cjs");
26
- const components_Auth_useAuth_index = require("../../Auth/useAuth/index.cjs");
27
- require("../../Auth/ChangePasswordForm/changePasswordForm.content.cjs");
28
- require("../../Auth/ChangePasswordForm/useChangePasswordSchema.content.cjs");
29
- require("../../Auth/ResetPasswordForm/resetPasswordContent.content.cjs");
30
- require("../../Auth/ResetPasswordForm/useResetPasswordSchema.content.cjs");
31
- require("../../Modal/Modal.cjs");
32
- require("clsx");
33
- require("tailwind-merge");
34
- require("@intlayer/api");
35
- require("../../Auth/VerifyEmailForm/index.content.cjs");
36
18
  const components_DictionaryFieldEditor_SaveForm_saveForm_content = require("./saveForm.content.cjs");
37
- const components_DictionaryFieldEditor_SaveForm_SaveFormSchema = require("./SaveFormSchema.cjs");
38
- const SaveForm = ({ dictionary, mode }) => {
39
- const { session } = components_Auth_useAuth_index.useAuth();
40
- const project = session?.project;
19
+ const SaveForm = ({
20
+ dictionary,
21
+ mode,
22
+ className,
23
+ ...props
24
+ }) => {
25
+ const { editor } = editorReact.useConfiguration();
41
26
  const { setLocaleDictionary } = editorReact.useDictionariesRecordActions();
42
- const { pushDictionaries } = hooks_intlayerAPIHooks.usePushDictionaries();
43
- const { writeDictionary } = hooks_intlayerAPIHooks.useWriteDictionary();
44
- const SaveFormSchema = components_DictionaryFieldEditor_SaveForm_SaveFormSchema.getSaveFormSchema();
45
- const { isLoading: isAuditing, auditContentDeclaration } = hooks_intlayerAPIHooks.useAuditContentDeclaration();
46
- const { editedContent, restoreEditedContent, setEditedContent } = editorReact.useEditedContent();
47
- const { form, isSubmitting } = components_Form_FormBase.useForm(SaveFormSchema);
48
- const {
49
- auditButton,
50
- resetButton,
51
- saveButton,
52
- publishButton,
53
- downloadButton
54
- } = reactIntlayer.useDictionary(components_DictionaryFieldEditor_SaveForm_saveForm_content.saveDictionaryContent);
27
+ const { writeDictionary, isLoading: isWriting } = hooks_intlayerAPIHooks.useWriteDictionary();
28
+ const { pushDictionaries, isLoading: isPushing } = hooks_intlayerAPIHooks.usePushDictionaries();
29
+ const isLoading = isWriting || isPushing;
30
+ const { editedContent, restoreEditedContent } = editorReact.useEditedContent();
31
+ const { resetButton, saveButton, publishButton, downloadButton } = reactIntlayer.useDictionary(components_DictionaryFieldEditor_SaveForm_saveForm_content.saveDictionaryContent);
32
+ const hasIntlayerAccessKey = Boolean(editor.clientId && editor.clientSecret);
55
33
  const editedDictionary = ReactExports.useMemo(
56
34
  () => editedContent?.[dictionary.key],
57
35
  [editedContent, dictionary.key]
58
36
  );
59
37
  const isEdited = ReactExports.useMemo(
60
- () => editedDictionary && JSON.stringify(editedDictionary.content) !== JSON.stringify(dictionary.content),
38
+ () => editedDictionary && JSON.stringify(editedDictionary) !== JSON.stringify(dictionary),
61
39
  [editedDictionary, dictionary, mode]
62
40
  );
63
41
  const isLocalDictionary = ReactExports.useMemo(
64
42
  () => typeof dictionary?._id === "undefined",
65
43
  [dictionary]
66
44
  );
67
- const onSubmitSuccess = ReactExports.useCallback(async () => {
45
+ const handleSaveDictionary = async () => {
68
46
  if (!editedContent?.[dictionary.key]) return;
69
47
  const updatedDictionary = {
70
48
  ...dictionary,
71
49
  ...editedContent?.[dictionary.key]
72
50
  };
73
- if (mode === "remote") {
74
- await pushDictionaries([updatedDictionary]);
75
- } else {
76
- await writeDictionary(updatedDictionary);
77
- }
78
- setLocaleDictionary(editedContent?.[dictionary.key]);
79
- restoreEditedContent(dictionary.key);
80
- }, [
81
- dictionary,
82
- editedContent,
83
- pushDictionaries,
84
- setLocaleDictionary,
85
- writeDictionary,
86
- restoreEditedContent,
87
- mode
88
- ]);
89
- const handleOnAuditFile = async () => await auditContentDeclaration({
90
- defaultLocale: project?.configuration?.internationalization?.defaultLocale ?? intlayer.Locales.ENGLISH,
91
- locales: project?.configuration?.internationalization?.locales ?? [
92
- intlayer.Locales.ENGLISH
93
- ],
94
- fileContent: JSON.stringify(editedDictionary ?? dictionary)
95
- }).then((response) => {
96
- if (!response.data) return;
97
- const editedDictionary2 = JSON.parse(
98
- response.data.fileContent
99
- );
100
- setEditedContent(dictionary.key, editedDictionary2.content);
101
- });
51
+ await writeDictionary(updatedDictionary).then(() => {
52
+ setLocaleDictionary(editedContent?.[dictionary.key]);
53
+ restoreEditedContent(dictionary.key);
54
+ });
55
+ };
56
+ const handlePushDictionary = async () => {
57
+ if (!editedContent?.[dictionary.key]) return;
58
+ const updatedDictionary = {
59
+ ...dictionary,
60
+ ...editedContent?.[dictionary.key]
61
+ };
62
+ await pushDictionaries([updatedDictionary]).then(() => {
63
+ setLocaleDictionary(editedContent?.[dictionary.key]);
64
+ restoreEditedContent(dictionary.key);
65
+ });
66
+ };
102
67
  return /* @__PURE__ */ jsxRuntime.jsxs(
103
- components_Form_layout_FormItemLayout.Form,
68
+ "form",
104
69
  {
105
- className: "flex w-full flex-1 flex-row flex-wrap justify-end gap-3",
106
- ...form,
107
- schema: SaveFormSchema,
108
- onSubmitSuccess,
70
+ className: utils_cn.cn("flex justify-end gap-2 max-md:flex-col", className),
71
+ ...props,
109
72
  children: [
110
- /* @__PURE__ */ jsxRuntime.jsx(
111
- components_Form_layout_FormItemLayout.Form.Button,
112
- {
113
- type: "button",
114
- label: auditButton.label.value,
115
- disabled: isSubmitting,
116
- Icon: lucideReact.WandSparkles,
117
- variant: "outline",
118
- color: "text",
119
- className: "ml-auto max-md:w-full",
120
- isLoading: isAuditing,
121
- onClick: handleOnAuditFile,
122
- children: auditButton.text
123
- }
124
- ),
125
73
  isEdited && /* @__PURE__ */ jsxRuntime.jsx(
126
74
  components_Form_layout_FormItemLayout.Form.Button,
127
75
  {
128
- type: "button",
129
76
  label: resetButton.label.value,
130
- disabled: !isEdited || isSubmitting,
77
+ disabled: !isEdited,
131
78
  Icon: lucideReact.RotateCcw,
132
79
  variant: "outline",
133
80
  color: "text",
@@ -136,40 +83,42 @@ const SaveForm = ({ dictionary, mode }) => {
136
83
  children: resetButton.text
137
84
  }
138
85
  ),
139
- mode === "remote" ? isLocalDictionary ? /* @__PURE__ */ jsxRuntime.jsx(
86
+ mode.includes("remote") && hasIntlayerAccessKey && isLocalDictionary && /* @__PURE__ */ jsxRuntime.jsx(
140
87
  components_Form_layout_FormItemLayout.Form.Button,
141
88
  {
142
- type: "submit",
143
89
  label: publishButton.label.value,
144
- disabled: !isEdited || isSubmitting,
90
+ disabled: !isEdited,
145
91
  Icon: lucideReact.ArrowUpFromLine,
146
92
  color: "text",
147
93
  className: "max-md:w-full",
148
- isLoading: isSubmitting,
94
+ isLoading: isPushing,
95
+ onClick: handlePushDictionary,
149
96
  children: publishButton.text
150
97
  }
151
- ) : isEdited && /* @__PURE__ */ jsxRuntime.jsx(
98
+ ),
99
+ mode.includes("remote") && hasIntlayerAccessKey && isEdited && /* @__PURE__ */ jsxRuntime.jsx(
152
100
  components_Form_layout_FormItemLayout.Form.Button,
153
101
  {
154
- type: "submit",
155
102
  label: saveButton.label.value,
156
- disabled: !isEdited || isSubmitting,
103
+ disabled: !isEdited || isLoading,
157
104
  Icon: lucideReact.Save,
158
105
  color: "text",
159
106
  className: "max-md:w-full",
160
- isLoading: isSubmitting,
107
+ isLoading: isPushing,
108
+ onClick: handlePushDictionary,
161
109
  children: saveButton.text
162
110
  }
163
- ) : /* @__PURE__ */ jsxRuntime.jsx(
111
+ ),
112
+ mode.includes("local") && /* @__PURE__ */ jsxRuntime.jsx(
164
113
  components_Form_layout_FormItemLayout.Form.Button,
165
114
  {
166
- type: "submit",
167
115
  label: downloadButton.label.value,
168
- disabled: !isEdited || isSubmitting,
116
+ disabled: !isEdited || isLoading,
169
117
  Icon: lucideReact.Download,
170
118
  color: "text",
171
119
  className: "max-md:w-full",
172
- isLoading: isSubmitting,
120
+ isLoading: isWriting,
121
+ onClick: handleSaveDictionary,
173
122
  children: downloadButton.text
174
123
  }
175
124
  )
@@ -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 { Locales } from 'intlayer';\nimport {\n ArrowUpFromLine,\n Download,\n RotateCcw,\n Save,\n WandSparkles,\n} from 'lucide-react';\nimport { useCallback, useMemo, type FC } from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport {\n usePushDictionaries,\n useAuditContentDeclaration,\n useWriteDictionary,\n} from '../../../hooks';\nimport { useAuth } from '../../Auth';\nimport { Form, useForm } from '../../Form';\nimport { saveDictionaryContent } from './saveForm.content';\nimport { getSaveFormSchema } from './SaveFormSchema';\n\ntype DictionaryDetailsProps = {\n dictionary: Dictionary;\n mode: 'local' | 'remote';\n};\n\nexport const SaveForm: FC<DictionaryDetailsProps> = ({ dictionary, mode }) => {\n const { session } = useAuth();\n const project = session?.project;\n const { setLocaleDictionary } = useDictionariesRecordActions();\n const { pushDictionaries } = usePushDictionaries();\n const { writeDictionary } = useWriteDictionary();\n const SaveFormSchema = getSaveFormSchema();\n const { isLoading: isAuditing, auditContentDeclaration } =\n useAuditContentDeclaration();\n\n const { editedContent, restoreEditedContent, setEditedContent } =\n useEditedContent();\n const { form, isSubmitting } = useForm(SaveFormSchema);\n const {\n auditButton,\n resetButton,\n saveButton,\n publishButton,\n downloadButton,\n } = useDictionary(saveDictionaryContent);\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.content) !==\n JSON.stringify(dictionary.content),\n [editedDictionary, dictionary, mode]\n );\n\n const isLocalDictionary = useMemo(\n () => typeof (dictionary as DistantDictionary)?._id === 'undefined',\n [dictionary]\n );\n\n const onSubmitSuccess = useCallback(async () => {\n if (!editedContent?.[dictionary.key]) return;\n\n const updatedDictionary = {\n ...dictionary,\n ...editedContent?.[dictionary.key],\n };\n\n if (mode === 'remote') {\n await pushDictionaries([updatedDictionary]);\n } else {\n await writeDictionary(updatedDictionary);\n }\n setLocaleDictionary(editedContent?.[dictionary.key]);\n restoreEditedContent(dictionary.key);\n }, [\n dictionary,\n editedContent,\n pushDictionaries,\n setLocaleDictionary,\n writeDictionary,\n restoreEditedContent,\n mode,\n ]);\n\n const handleOnAuditFile = async () =>\n await auditContentDeclaration({\n defaultLocale:\n project?.configuration?.internationalization?.defaultLocale ??\n Locales.ENGLISH,\n locales: project?.configuration?.internationalization?.locales ?? [\n Locales.ENGLISH,\n ],\n fileContent: JSON.stringify(editedDictionary ?? dictionary),\n }).then((response) => {\n if (!response.data) return;\n\n const editedDictionary = JSON.parse(\n response.data.fileContent\n ) as Dictionary;\n\n setEditedContent(dictionary.key, editedDictionary.content);\n });\n\n return (\n <Form\n className=\"flex w-full flex-1 flex-row flex-wrap justify-end gap-3\"\n {...form}\n schema={SaveFormSchema}\n onSubmitSuccess={onSubmitSuccess}\n >\n <Form.Button\n type=\"button\"\n label={auditButton.label.value}\n disabled={isSubmitting}\n Icon={WandSparkles}\n variant=\"outline\"\n color=\"text\"\n className=\"ml-auto max-md:w-full\"\n isLoading={isAuditing}\n onClick={handleOnAuditFile}\n >\n {auditButton.text}\n </Form.Button>\n {isEdited && (\n <Form.Button\n type=\"button\"\n label={resetButton.label.value}\n disabled={!isEdited || isSubmitting}\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 === 'remote' ? (\n isLocalDictionary ? (\n <Form.Button\n type=\"submit\"\n label={publishButton.label.value}\n disabled={!isEdited || isSubmitting}\n Icon={ArrowUpFromLine}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isSubmitting}\n >\n {publishButton.text}\n </Form.Button>\n ) : (\n isEdited && (\n <Form.Button\n type=\"submit\"\n label={saveButton.label.value}\n disabled={!isEdited || isSubmitting}\n Icon={Save}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isSubmitting}\n >\n {saveButton.text}\n </Form.Button>\n )\n )\n ) : (\n <Form.Button\n type=\"submit\"\n label={downloadButton.label.value}\n disabled={!isEdited || isSubmitting}\n Icon={Download}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isSubmitting}\n >\n {downloadButton.text}\n </Form.Button>\n )}\n </Form>\n );\n};\n"],"names":["useAuth","useDictionariesRecordActions","usePushDictionaries","useWriteDictionary","getSaveFormSchema","useAuditContentDeclaration","useEditedContent","useForm","useDictionary","saveDictionaryContent","useMemo","useCallback","Locales","editedDictionary","jsxs","Form","jsx","WandSparkles","RotateCcw","ArrowUpFromLine","Save","Download"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;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AM;AAAA,YACN,WAAU;AAAA,YACV,SAAS,MAAM,qBAAqB,WAAW,GAAG;AAAA,YAEjD,UAAY,YAAA;AAAA,UAAA;AAAA,QACf;AAAA,QAED,SAAS,WACR,oBACEF,2BAAA;AAAA,UAACD,sCAAAA,KAAK;AAAA,UAAL;AAAA,YACC,MAAK;AAAA,YACL,OAAO,cAAc,MAAM;AAAA,YAC3B,UAAU,CAAC,YAAY;AAAA,YACvB,MAAMI,YAAA;AAAA,YACN,OAAM;AAAA,YACN,WAAU;AAAA,YACV,WAAW;AAAA,YAEV,UAAc,cAAA;AAAA,UAAA;AAAA,YAGjB,YACEH,2BAAA;AAAA,UAACD,sCAAAA,KAAK;AAAA,UAAL;AAAA,YACC,MAAK;AAAA,YACL,OAAO,WAAW,MAAM;AAAA,YACxB,UAAU,CAAC,YAAY;AAAA,YACvB,MAAMK,YAAA;AAAA,YACN,OAAM;AAAA,YACN,WAAU;AAAA,YACV,WAAW;AAAA,YAEV,UAAW,WAAA;AAAA,UAAA;AAAA,QAAA,IAKlBJ,2BAAA;AAAA,UAACD,sCAAAA,KAAK;AAAA,UAAL;AAAA,YACC,MAAK;AAAA,YACL,OAAO,eAAe,MAAM;AAAA,YAC5B,UAAU,CAAC,YAAY;AAAA,YACvB,MAAMM,YAAA;AAAA,YACN,OAAM;AAAA,YACN,WAAU;AAAA,YACV,WAAW;AAAA,YAEV,UAAe,eAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MAClB;AAAA,IAAA;AAAA,EAEJ;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 useConfiguration,\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 { 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 { editor } = useConfiguration();\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\n const hasIntlayerAccessKey = Boolean(editor.clientId && editor.clientSecret);\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(() => {\n setLocaleDictionary(editedContent?.[dictionary.key]);\n restoreEditedContent(dictionary.key);\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('remote') && hasIntlayerAccessKey && isLocalDictionary && (\n <Form.Button\n label={publishButton.label.value}\n disabled={!isEdited}\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') && hasIntlayerAccessKey && 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 {mode.includes('local') && (\n <Form.Button\n label={downloadButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Download}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isWriting}\n onClick={handleSaveDictionary}\n >\n {downloadButton.text}\n </Form.Button>\n )}\n </form>\n );\n};\n"],"names":["useConfiguration","useDictionariesRecordActions","useWriteDictionary","usePushDictionaries","useEditedContent","useDictionary","saveDictionaryContent","useMemo","jsxs","cn","jsx","Form","RotateCcw","ArrowUpFromLine","Save","Download"],"mappings":";;;;;;;;;;;;;;;;;;AA2BO,MAAM,WAAuC,CAAC;AAAA,EACnD;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACE,QAAA,EAAE,OAAO,IAAIA,6BAAiB;AAC9B,QAAA,EAAE,oBAAoB,IAAIC,yCAA6B;AAC7D,QAAM,EAAE,iBAAiB,WAAW,UAAA,IAAcC,uBAAAA,mBAAmB;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AAA,YAER,UAAe,eAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MAClB;AAAA,IAAA;AAAA,EAEJ;AAEJ;;"}
@@ -1,9 +1,9 @@
1
1
  import { Dictionary } from '@intlayer/core';
2
- import { FC } from 'react';
2
+ import { DetailedHTMLProps, FormHTMLAttributes, FC } from 'react';
3
3
  type DictionaryDetailsProps = {
4
4
  dictionary: Dictionary;
5
- mode: 'local' | 'remote';
6
- };
5
+ mode: ('local' | 'remote')[];
6
+ } & DetailedHTMLProps<FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>;
7
7
  export declare const SaveForm: FC<DictionaryDetailsProps>;
8
8
  export {};
9
9
  //# sourceMappingURL=SaveForm.d.ts.map
@@ -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;AAajD,OAAO,EAAwB,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAYtD,KAAK,sBAAsB,GAAG;IAC5B,UAAU,EAAE,UAAU,CAAC;IACvB,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,EAAE,CAAC,sBAAsB,CAgK/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;AAOjD,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EAEvB,KAAK,EAAE,EACR,MAAM,OAAO,CAAC;AAOf,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,CA0H/C,CAAC"}
@@ -1,131 +1,78 @@
1
1
  "use client";
2
2
  import { jsxs, jsx } from "react/jsx-runtime";
3
- import { useDictionariesRecordActions, useEditedContent } from "@intlayer/editor-react";
4
- import { Locales } from "intlayer";
5
- import { WandSparkles, RotateCcw, ArrowUpFromLine, Save, Download } from "lucide-react";
6
- import { useMemo, useCallback } from "react";
3
+ import { useConfiguration, useDictionariesRecordActions, useEditedContent } from "@intlayer/editor-react";
4
+ import { RotateCcw, ArrowUpFromLine, Save, Download } from "lucide-react";
5
+ import { useMemo } from "react";
7
6
  import { useDictionary } from "react-intlayer";
8
7
  import "../../../hooks/useScrollBlockage/useScrollBlockageStore.mjs";
9
8
  import "../../../hooks/useAsync/useAsyncStateStore.mjs";
10
- import { usePushDictionaries, useWriteDictionary, useAuditContentDeclaration } from "../../../hooks/intlayerAPIHooks.mjs";
9
+ import { useWriteDictionary, usePushDictionaries } from "../../../hooks/intlayerAPIHooks.mjs";
11
10
  import "deepmerge";
12
- import "../../../index-BTDHuTxL.js";
13
- import "@intlayer/config/client";
14
- import "../../Button/Button.mjs";
15
- import "../../Auth/ExternalsLoginButtons/externalsLoginButtons.content.mjs";
16
- import { useForm } from "../../Form/FormBase.mjs";
11
+ import { cn } from "../../../utils/cn.mjs";
12
+ import "@hookform/resolvers";
13
+ import "react-hook-form";
17
14
  import "../../Form/FormField.mjs";
18
15
  import { F as Form } from "../../../Form-BZUDRfoN.js";
19
- import "../../Auth/SignInForm/signIn.content.mjs";
20
- import "zod";
21
- import "../../Auth/SignInForm/useSignInSchema.content.mjs";
22
- import "../../Auth/SignUpForm/signUpForm.content.mjs";
23
- import "../../Auth/SignUpForm/useSignUpSchema.content.mjs";
24
- import { useAuth } from "../../Auth/useAuth/index.mjs";
25
- import "../../Auth/ChangePasswordForm/changePasswordForm.content.mjs";
26
- import "../../Auth/ChangePasswordForm/useChangePasswordSchema.content.mjs";
27
- import "../../Auth/ResetPasswordForm/resetPasswordContent.content.mjs";
28
- import "../../Auth/ResetPasswordForm/useResetPasswordSchema.content.mjs";
29
- import "../../Modal/Modal.mjs";
30
- import "clsx";
31
- import "tailwind-merge";
32
- import "@intlayer/api";
33
- import "../../Auth/VerifyEmailForm/index.content.mjs";
34
16
  import { saveDictionaryContent } from "./saveForm.content.mjs";
35
- import { getSaveFormSchema } from "./SaveFormSchema.mjs";
36
- const SaveForm = ({ dictionary, mode }) => {
37
- const { session } = useAuth();
38
- const project = session?.project;
17
+ const SaveForm = ({
18
+ dictionary,
19
+ mode,
20
+ className,
21
+ ...props
22
+ }) => {
23
+ const { editor } = useConfiguration();
39
24
  const { setLocaleDictionary } = useDictionariesRecordActions();
40
- const { pushDictionaries } = usePushDictionaries();
41
- const { writeDictionary } = useWriteDictionary();
42
- const SaveFormSchema = getSaveFormSchema();
43
- const { isLoading: isAuditing, auditContentDeclaration } = useAuditContentDeclaration();
44
- const { editedContent, restoreEditedContent, setEditedContent } = useEditedContent();
45
- const { form, isSubmitting } = useForm(SaveFormSchema);
46
- const {
47
- auditButton,
48
- resetButton,
49
- saveButton,
50
- publishButton,
51
- downloadButton
52
- } = useDictionary(saveDictionaryContent);
25
+ const { writeDictionary, isLoading: isWriting } = useWriteDictionary();
26
+ const { pushDictionaries, isLoading: isPushing } = usePushDictionaries();
27
+ const isLoading = isWriting || isPushing;
28
+ const { editedContent, restoreEditedContent } = useEditedContent();
29
+ const { resetButton, saveButton, publishButton, downloadButton } = useDictionary(saveDictionaryContent);
30
+ const hasIntlayerAccessKey = Boolean(editor.clientId && editor.clientSecret);
53
31
  const editedDictionary = useMemo(
54
32
  () => editedContent?.[dictionary.key],
55
33
  [editedContent, dictionary.key]
56
34
  );
57
35
  const isEdited = useMemo(
58
- () => editedDictionary && JSON.stringify(editedDictionary.content) !== JSON.stringify(dictionary.content),
36
+ () => editedDictionary && JSON.stringify(editedDictionary) !== JSON.stringify(dictionary),
59
37
  [editedDictionary, dictionary, mode]
60
38
  );
61
39
  const isLocalDictionary = useMemo(
62
40
  () => typeof dictionary?._id === "undefined",
63
41
  [dictionary]
64
42
  );
65
- const onSubmitSuccess = useCallback(async () => {
43
+ const handleSaveDictionary = async () => {
66
44
  if (!editedContent?.[dictionary.key]) return;
67
45
  const updatedDictionary = {
68
46
  ...dictionary,
69
47
  ...editedContent?.[dictionary.key]
70
48
  };
71
- if (mode === "remote") {
72
- await pushDictionaries([updatedDictionary]);
73
- } else {
74
- await writeDictionary(updatedDictionary);
75
- }
76
- setLocaleDictionary(editedContent?.[dictionary.key]);
77
- restoreEditedContent(dictionary.key);
78
- }, [
79
- dictionary,
80
- editedContent,
81
- pushDictionaries,
82
- setLocaleDictionary,
83
- writeDictionary,
84
- restoreEditedContent,
85
- mode
86
- ]);
87
- const handleOnAuditFile = async () => await auditContentDeclaration({
88
- defaultLocale: project?.configuration?.internationalization?.defaultLocale ?? Locales.ENGLISH,
89
- locales: project?.configuration?.internationalization?.locales ?? [
90
- Locales.ENGLISH
91
- ],
92
- fileContent: JSON.stringify(editedDictionary ?? dictionary)
93
- }).then((response) => {
94
- if (!response.data) return;
95
- const editedDictionary2 = JSON.parse(
96
- response.data.fileContent
97
- );
98
- setEditedContent(dictionary.key, editedDictionary2.content);
99
- });
49
+ await writeDictionary(updatedDictionary).then(() => {
50
+ setLocaleDictionary(editedContent?.[dictionary.key]);
51
+ restoreEditedContent(dictionary.key);
52
+ });
53
+ };
54
+ const handlePushDictionary = async () => {
55
+ if (!editedContent?.[dictionary.key]) return;
56
+ const updatedDictionary = {
57
+ ...dictionary,
58
+ ...editedContent?.[dictionary.key]
59
+ };
60
+ await pushDictionaries([updatedDictionary]).then(() => {
61
+ setLocaleDictionary(editedContent?.[dictionary.key]);
62
+ restoreEditedContent(dictionary.key);
63
+ });
64
+ };
100
65
  return /* @__PURE__ */ jsxs(
101
- Form,
66
+ "form",
102
67
  {
103
- className: "flex w-full flex-1 flex-row flex-wrap justify-end gap-3",
104
- ...form,
105
- schema: SaveFormSchema,
106
- onSubmitSuccess,
68
+ className: cn("flex justify-end gap-2 max-md:flex-col", className),
69
+ ...props,
107
70
  children: [
108
- /* @__PURE__ */ jsx(
109
- Form.Button,
110
- {
111
- type: "button",
112
- label: auditButton.label.value,
113
- disabled: isSubmitting,
114
- Icon: WandSparkles,
115
- variant: "outline",
116
- color: "text",
117
- className: "ml-auto max-md:w-full",
118
- isLoading: isAuditing,
119
- onClick: handleOnAuditFile,
120
- children: auditButton.text
121
- }
122
- ),
123
71
  isEdited && /* @__PURE__ */ jsx(
124
72
  Form.Button,
125
73
  {
126
- type: "button",
127
74
  label: resetButton.label.value,
128
- disabled: !isEdited || isSubmitting,
75
+ disabled: !isEdited,
129
76
  Icon: RotateCcw,
130
77
  variant: "outline",
131
78
  color: "text",
@@ -134,40 +81,42 @@ const SaveForm = ({ dictionary, mode }) => {
134
81
  children: resetButton.text
135
82
  }
136
83
  ),
137
- mode === "remote" ? isLocalDictionary ? /* @__PURE__ */ jsx(
84
+ mode.includes("remote") && hasIntlayerAccessKey && isLocalDictionary && /* @__PURE__ */ jsx(
138
85
  Form.Button,
139
86
  {
140
- type: "submit",
141
87
  label: publishButton.label.value,
142
- disabled: !isEdited || isSubmitting,
88
+ disabled: !isEdited,
143
89
  Icon: ArrowUpFromLine,
144
90
  color: "text",
145
91
  className: "max-md:w-full",
146
- isLoading: isSubmitting,
92
+ isLoading: isPushing,
93
+ onClick: handlePushDictionary,
147
94
  children: publishButton.text
148
95
  }
149
- ) : isEdited && /* @__PURE__ */ jsx(
96
+ ),
97
+ mode.includes("remote") && hasIntlayerAccessKey && isEdited && /* @__PURE__ */ jsx(
150
98
  Form.Button,
151
99
  {
152
- type: "submit",
153
100
  label: saveButton.label.value,
154
- disabled: !isEdited || isSubmitting,
101
+ disabled: !isEdited || isLoading,
155
102
  Icon: Save,
156
103
  color: "text",
157
104
  className: "max-md:w-full",
158
- isLoading: isSubmitting,
105
+ isLoading: isPushing,
106
+ onClick: handlePushDictionary,
159
107
  children: saveButton.text
160
108
  }
161
- ) : /* @__PURE__ */ jsx(
109
+ ),
110
+ mode.includes("local") && /* @__PURE__ */ jsx(
162
111
  Form.Button,
163
112
  {
164
- type: "submit",
165
113
  label: downloadButton.label.value,
166
- disabled: !isEdited || isSubmitting,
114
+ disabled: !isEdited || isLoading,
167
115
  Icon: Download,
168
116
  color: "text",
169
117
  className: "max-md:w-full",
170
- isLoading: isSubmitting,
118
+ isLoading: isWriting,
119
+ onClick: handleSaveDictionary,
171
120
  children: downloadButton.text
172
121
  }
173
122
  )
@@ -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 { Locales } from 'intlayer';\nimport {\n ArrowUpFromLine,\n Download,\n RotateCcw,\n Save,\n WandSparkles,\n} from 'lucide-react';\nimport { useCallback, useMemo, type FC } from 'react';\nimport { useDictionary } from 'react-intlayer';\nimport {\n usePushDictionaries,\n useAuditContentDeclaration,\n useWriteDictionary,\n} from '../../../hooks';\nimport { useAuth } from '../../Auth';\nimport { Form, useForm } from '../../Form';\nimport { saveDictionaryContent } from './saveForm.content';\nimport { getSaveFormSchema } from './SaveFormSchema';\n\ntype DictionaryDetailsProps = {\n dictionary: Dictionary;\n mode: 'local' | 'remote';\n};\n\nexport const SaveForm: FC<DictionaryDetailsProps> = ({ dictionary, mode }) => {\n const { session } = useAuth();\n const project = session?.project;\n const { setLocaleDictionary } = useDictionariesRecordActions();\n const { pushDictionaries } = usePushDictionaries();\n const { writeDictionary } = useWriteDictionary();\n const SaveFormSchema = getSaveFormSchema();\n const { isLoading: isAuditing, auditContentDeclaration } =\n useAuditContentDeclaration();\n\n const { editedContent, restoreEditedContent, setEditedContent } =\n useEditedContent();\n const { form, isSubmitting } = useForm(SaveFormSchema);\n const {\n auditButton,\n resetButton,\n saveButton,\n publishButton,\n downloadButton,\n } = useDictionary(saveDictionaryContent);\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.content) !==\n JSON.stringify(dictionary.content),\n [editedDictionary, dictionary, mode]\n );\n\n const isLocalDictionary = useMemo(\n () => typeof (dictionary as DistantDictionary)?._id === 'undefined',\n [dictionary]\n );\n\n const onSubmitSuccess = useCallback(async () => {\n if (!editedContent?.[dictionary.key]) return;\n\n const updatedDictionary = {\n ...dictionary,\n ...editedContent?.[dictionary.key],\n };\n\n if (mode === 'remote') {\n await pushDictionaries([updatedDictionary]);\n } else {\n await writeDictionary(updatedDictionary);\n }\n setLocaleDictionary(editedContent?.[dictionary.key]);\n restoreEditedContent(dictionary.key);\n }, [\n dictionary,\n editedContent,\n pushDictionaries,\n setLocaleDictionary,\n writeDictionary,\n restoreEditedContent,\n mode,\n ]);\n\n const handleOnAuditFile = async () =>\n await auditContentDeclaration({\n defaultLocale:\n project?.configuration?.internationalization?.defaultLocale ??\n Locales.ENGLISH,\n locales: project?.configuration?.internationalization?.locales ?? [\n Locales.ENGLISH,\n ],\n fileContent: JSON.stringify(editedDictionary ?? dictionary),\n }).then((response) => {\n if (!response.data) return;\n\n const editedDictionary = JSON.parse(\n response.data.fileContent\n ) as Dictionary;\n\n setEditedContent(dictionary.key, editedDictionary.content);\n });\n\n return (\n <Form\n className=\"flex w-full flex-1 flex-row flex-wrap justify-end gap-3\"\n {...form}\n schema={SaveFormSchema}\n onSubmitSuccess={onSubmitSuccess}\n >\n <Form.Button\n type=\"button\"\n label={auditButton.label.value}\n disabled={isSubmitting}\n Icon={WandSparkles}\n variant=\"outline\"\n color=\"text\"\n className=\"ml-auto max-md:w-full\"\n isLoading={isAuditing}\n onClick={handleOnAuditFile}\n >\n {auditButton.text}\n </Form.Button>\n {isEdited && (\n <Form.Button\n type=\"button\"\n label={resetButton.label.value}\n disabled={!isEdited || isSubmitting}\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 === 'remote' ? (\n isLocalDictionary ? (\n <Form.Button\n type=\"submit\"\n label={publishButton.label.value}\n disabled={!isEdited || isSubmitting}\n Icon={ArrowUpFromLine}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isSubmitting}\n >\n {publishButton.text}\n </Form.Button>\n ) : (\n isEdited && (\n <Form.Button\n type=\"submit\"\n label={saveButton.label.value}\n disabled={!isEdited || isSubmitting}\n Icon={Save}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isSubmitting}\n >\n {saveButton.text}\n </Form.Button>\n )\n )\n ) : (\n <Form.Button\n type=\"submit\"\n label={downloadButton.label.value}\n disabled={!isEdited || isSubmitting}\n Icon={Download}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isSubmitting}\n >\n {downloadButton.text}\n </Form.Button>\n )}\n </Form>\n );\n};\n"],"names":["editedDictionary"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCO,MAAM,WAAuC,CAAC,EAAE,YAAY,WAAW;AACtE,QAAA,EAAE,QAAQ,IAAI,QAAQ;AAC5B,QAAM,UAAU,SAAS;AACnB,QAAA,EAAE,oBAAoB,IAAI,6BAA6B;AACvD,QAAA,EAAE,iBAAiB,IAAI,oBAAoB;AAC3C,QAAA,EAAE,gBAAgB,IAAI,mBAAmB;AAC/C,QAAM,iBAAiB,kBAAkB;AACzC,QAAM,EAAE,WAAW,YAAY,wBAAA,IAC7B,2BAA2B;AAE7B,QAAM,EAAE,eAAe,sBAAsB,iBAAA,I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YACV,WAAW;AAAA,YAEV,UAAW,WAAA;AAAA,UAAA;AAAA,QAAA,IAKlB;AAAA,UAAC,KAAK;AAAA,UAAL;AAAA,YACC,MAAK;AAAA,YACL,OAAO,eAAe,MAAM;AAAA,YAC5B,UAAU,CAAC,YAAY;AAAA,YACvB,MAAM;AAAA,YACN,OAAM;AAAA,YACN,WAAU;AAAA,YACV,WAAW;AAAA,YAEV,UAAe,eAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MAClB;AAAA,IAAA;AAAA,EAEJ;AAEJ;"}
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 useConfiguration,\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 { 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 { editor } = useConfiguration();\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\n const hasIntlayerAccessKey = Boolean(editor.clientId && editor.clientSecret);\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(() => {\n setLocaleDictionary(editedContent?.[dictionary.key]);\n restoreEditedContent(dictionary.key);\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('remote') && hasIntlayerAccessKey && isLocalDictionary && (\n <Form.Button\n label={publishButton.label.value}\n disabled={!isEdited}\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') && hasIntlayerAccessKey && 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 {mode.includes('local') && (\n <Form.Button\n label={downloadButton.label.value}\n disabled={!isEdited || isLoading}\n Icon={Download}\n color=\"text\"\n className=\"max-md:w-full\"\n isLoading={isWriting}\n onClick={handleSaveDictionary}\n >\n {downloadButton.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,OAAO,IAAI,iBAAiB;AAC9B,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;AAE/B,QAAM,EAAE,eAAe,qBAAqB,IAAI,iBAAiB;AACjE,QAAM,EAAE,aAAa,YAAY,eAAe,eAAe,IAC7D,cAAc,qBAAqB;AAErC,QAAM,uBAAuB,QAAQ,OAAO,YAAY,OAAO,YAAY;AAE3E,QAAM,mBAAmB;AAAA,IACvB,MAAM,gBAAgB,WAAW,GAAG;AAAA,IACpC,CAAC,eAAe,WAAW,GAAG;AAAA,EAChC;AAEA,QAAM,WAAW;AAAA,IACf,MACE,oBACA,KAAK,UAAU,gBAAgB,MAAM,KAAK,UAAU,UAAU;AAAA,IAChE,CAAC,kBAAkB,YAAY,IAAI;AAAA,EACrC;AAEA,QAAM,oBAAoB;AAAA,IACxB,MAAM,OAAQ,YAAkC,QAAQ;AAAA,IACxD,CAAC,UAAU;AAAA,EACb;AAEA,QAAM,uBAAuB,YAAY;AACvC,QAAI,CAAC,gBAAgB,WAAW,GAAG,EAAG;AAEtC,UAAM,oBAAoB;AAAA,MACxB,GAAG;AAAA,MACH,GAAG,gBAAgB,WAAW,GAAG;AAAA,IACnC;AAEA,UA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ACvB,MAAM;AAAA,YACN,OAAM;AAAA,YACN,WAAU;AAAA,YACV,WAAW;AAAA,YACX,SAAS;AAAA,YAER,UAAW,WAAA;AAAA,UAAA;AAAA,QACd;AAAA,QAED,KAAK,SAAS,OAAO,KACpB;AAAA,UAAC,KAAK;AAAA,UAAL;AAAA,YACC,OAAO,eAAe,MAAM;AAAA,YAC5B,UAAU,CAAC,YAAY;AAAA,YACvB,MAAM;AAAA,YACN,OAAM;AAAA,YACN,WAAU;AAAA,YACV,WAAW;AAAA,YACX,SAAS;AAAA,YAER,UAAe,eAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MAClB;AAAA,IAAA;AAAA,EAEJ;AAEJ;"}
@@ -4,38 +4,6 @@ const intlayer = require("intlayer");
4
4
  const saveDictionaryContent = {
5
5
  key: "save-dictionary-details",
6
6
  content: {
7
- auditButton: {
8
- text: intlayer.t({
9
- en: "Audit all content",
10
- "en-GB": "Audit all content",
11
- fr: "Auditer tout le contenu",
12
- es: "Auditar todo el contenido",
13
- de: "Allen Inhalt überprüfen",
14
- ja: "すべてのコンテンツを監査する",
15
- ko: "모든 콘텐츠 감사",
16
- zh: "审核所有内容",
17
- it: "Controlla tutto il contenuto",
18
- pt: "Auditar todo o conteúdo",
19
- hi: "सभी सामग्री ऑडिट करें",
20
- ar: "التدقيق على كل المحتوى",
21
- ru: "Отслеживание всего контента"
22
- }),
23
- label: intlayer.t({
24
- en: "Audit",
25
- "en-GB": "Audit",
26
- fr: "Auditer",
27
- es: "Auditar",
28
- de: "Prüfen",
29
- ja: "監査",
30
- ko: "감사",
31
- zh: "审核",
32
- it: "Controllo",
33
- pt: "Auditar",
34
- hi: "ऑडिट",
35
- ar: "التدقيق",
36
- ru: "Отслеживание"
37
- })
38
- },
39
7
  resetButton: {
40
8
  text: intlayer.t({
41
9
  en: "Reset all changes",