@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.
- package/dist/.vite/manifest.json +34 -88
- package/dist/Form-BZUDRfoN.js.map +1 -1
- package/dist/Form-yi0CMK-a.cjs.map +1 -1
- package/dist/components/Auth/ExternalsLoginButtons/ExternalsLoginButtons.cjs +1 -1
- package/dist/components/Auth/ExternalsLoginButtons/ExternalsLoginButtons.mjs +1 -1
- package/dist/components/Command/index.d.ts +1 -1
- package/dist/components/Container/index.cjs +5 -6
- package/dist/components/Container/index.cjs.map +1 -1
- package/dist/components/Container/index.mjs +5 -6
- package/dist/components/Container/index.mjs.map +1 -1
- package/dist/components/DictionaryEditor/DictionaryEditor.cjs +3 -3
- package/dist/components/DictionaryEditor/DictionaryEditor.cjs.map +1 -1
- package/dist/components/DictionaryEditor/DictionaryEditor.d.ts +1 -1
- package/dist/components/DictionaryEditor/DictionaryEditor.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/DictionaryEditor.mjs +3 -3
- package/dist/components/DictionaryEditor/DictionaryEditor.mjs.map +1 -1
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.cjs +33 -20
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.cjs.map +1 -1
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.mjs +34 -21
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/ContentEditor.cjs +2 -2
- package/dist/components/DictionaryFieldEditor/ContentEditor.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/ContentEditor.mjs +3 -3
- package/dist/components/DictionaryFieldEditor/ContentEditor.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.cjs +10 -7
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs +10 -7
- package/dist/components/DictionaryFieldEditor/ContentEditorView/TextEditor.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.d.ts +1 -1
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.cjs +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.cjs +92 -120
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.d.ts +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs +94 -122
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.cjs +0 -143
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.d.ts +0 -143
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.mjs +0 -143
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/dictionaryDetails.content.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.cjs +1 -2
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.d.ts +0 -3
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.mjs +1 -2
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/useDictionaryDetailsSchema.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.cjs +51 -70
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.d.ts +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs +51 -70
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs +52 -103
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.d.ts +3 -3
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs +56 -107
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.cjs +0 -32
- package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.d.ts +0 -32
- package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.mjs +0 -32
- package/dist/components/DictionaryFieldEditor/SaveForm/saveForm.content.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/StructureView/StructureView.cjs +1 -0
- package/dist/components/DictionaryFieldEditor/StructureView/StructureView.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/StructureView/StructureView.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/StructureView/StructureView.mjs +1 -0
- package/dist/components/DictionaryFieldEditor/StructureView/StructureView.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/index.cjs +0 -2
- package/dist/components/DictionaryFieldEditor/index.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/index.d.ts +0 -1
- package/dist/components/DictionaryFieldEditor/index.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/index.mjs +0 -2
- package/dist/components/DictionaryFieldEditor/index.mjs.map +1 -1
- package/dist/components/Form/FormBase.cjs +0 -1
- package/dist/components/Form/FormBase.cjs.map +1 -1
- package/dist/components/Form/FormBase.d.ts +1 -4
- package/dist/components/Form/FormBase.d.ts.map +1 -1
- package/dist/components/Form/FormBase.mjs +0 -1
- package/dist/components/Form/FormBase.mjs.map +1 -1
- package/dist/components/Form/elements/EditableFieldInputElement.d.ts +1 -1
- package/dist/components/Form/elements/EditableFieldInputElement.d.ts.map +1 -1
- package/dist/components/Form/elements/EditableFieldTextAreaElement.d.ts +1 -1
- package/dist/components/Form/elements/EditableFieldTextAreaElement.d.ts.map +1 -1
- package/dist/components/Input/Checkbox.cjs +0 -1
- package/dist/components/Input/Checkbox.cjs.map +1 -1
- package/dist/components/Input/Checkbox.mjs +0 -1
- package/dist/components/Input/Checkbox.mjs.map +1 -1
- package/dist/components/Input/Input.cjs +1 -1
- package/dist/components/Input/Input.cjs.map +1 -1
- package/dist/components/Input/Input.mjs +1 -1
- package/dist/components/Input/Input.mjs.map +1 -1
- package/dist/components/KeyboardScreenAdapter/index.cjs +25 -0
- package/dist/components/KeyboardScreenAdapter/index.cjs.map +1 -0
- package/dist/components/KeyboardScreenAdapter/index.d.ts +3 -0
- package/dist/components/KeyboardScreenAdapter/index.d.ts.map +1 -0
- package/dist/components/KeyboardScreenAdapter/index.mjs +25 -0
- package/dist/components/KeyboardScreenAdapter/index.mjs.map +1 -0
- package/dist/components/MaxHeightSmoother/index.cjs +2 -0
- package/dist/components/MaxHeightSmoother/index.cjs.map +1 -1
- package/dist/components/MaxHeightSmoother/index.d.ts.map +1 -1
- package/dist/components/MaxHeightSmoother/index.mjs +2 -0
- package/dist/components/MaxHeightSmoother/index.mjs.map +1 -1
- package/dist/components/Modal/Modal.cjs +15 -13
- package/dist/components/Modal/Modal.cjs.map +1 -1
- package/dist/components/Modal/Modal.d.ts.map +1 -1
- package/dist/components/Modal/Modal.mjs +15 -13
- package/dist/components/Modal/Modal.mjs.map +1 -1
- package/dist/components/RightDrawer/RightDrawer.cjs +1 -1
- package/dist/components/RightDrawer/RightDrawer.cjs.map +1 -1
- package/dist/components/RightDrawer/RightDrawer.mjs +1 -1
- package/dist/components/RightDrawer/RightDrawer.mjs.map +1 -1
- package/dist/components/Select/Multiselect.cjs +0 -1
- package/dist/components/Select/Multiselect.cjs.map +1 -1
- package/dist/components/Select/Multiselect.d.ts.map +1 -1
- package/dist/components/Select/Multiselect.mjs +1 -2
- package/dist/components/Select/Multiselect.mjs.map +1 -1
- package/dist/components/Select/Select.cjs +0 -1
- package/dist/components/Select/Select.cjs.map +1 -1
- package/dist/components/Select/Select.d.ts.map +1 -1
- package/dist/components/Select/Select.mjs +0 -1
- package/dist/components/Select/Select.mjs.map +1 -1
- package/dist/components/index.cjs +2 -2
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.mjs +2 -2
- package/dist/hooks/index.cjs +2 -0
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.mjs +2 -0
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/hooks/useAsync/useAsyncStateStore.cjs +8 -14
- package/dist/hooks/useAsync/useAsyncStateStore.cjs.map +1 -1
- package/dist/hooks/useAsync/useAsyncStateStore.d.ts.map +1 -1
- package/dist/hooks/useAsync/useAsyncStateStore.mjs +8 -14
- package/dist/hooks/useAsync/useAsyncStateStore.mjs.map +1 -1
- package/dist/hooks/useKeyboardDetector.cjs +27 -0
- package/dist/hooks/useKeyboardDetector.cjs.map +1 -0
- package/dist/hooks/useKeyboardDetector.d.ts +5 -0
- package/dist/hooks/useKeyboardDetector.d.ts.map +1 -0
- package/dist/hooks/useKeyboardDetector.mjs +27 -0
- package/dist/hooks/useKeyboardDetector.mjs.map +1 -0
- package/dist/{index-BTDHuTxL.js → index-B1w5h_6-.js} +7 -7
- package/dist/index-B1w5h_6-.js.map +1 -0
- package/dist/{index-Db5Dym4h.cjs → index-U1U6ySIn.cjs} +7 -7
- package/dist/index-U1U6ySIn.cjs.map +1 -0
- package/dist/tailwind.css +1 -1
- package/package.json +17 -17
- package/dist/index-BTDHuTxL.js.map +0 -1
- 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("../../../
|
|
15
|
-
require("@
|
|
16
|
-
require("
|
|
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
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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 {
|
|
43
|
-
const {
|
|
44
|
-
const
|
|
45
|
-
const {
|
|
46
|
-
const {
|
|
47
|
-
const
|
|
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
|
|
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
|
|
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
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
-
|
|
68
|
+
"form",
|
|
104
69
|
{
|
|
105
|
-
className: "flex
|
|
106
|
-
...
|
|
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
|
|
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
|
|
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
|
|
90
|
+
disabled: !isEdited,
|
|
145
91
|
Icon: lucideReact.ArrowUpFromLine,
|
|
146
92
|
color: "text",
|
|
147
93
|
className: "max-md:w-full",
|
|
148
|
-
isLoading:
|
|
94
|
+
isLoading: isPushing,
|
|
95
|
+
onClick: handlePushDictionary,
|
|
149
96
|
children: publishButton.text
|
|
150
97
|
}
|
|
151
|
-
)
|
|
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 ||
|
|
103
|
+
disabled: !isEdited || isLoading,
|
|
157
104
|
Icon: lucideReact.Save,
|
|
158
105
|
color: "text",
|
|
159
106
|
className: "max-md:w-full",
|
|
160
|
-
isLoading:
|
|
107
|
+
isLoading: isPushing,
|
|
108
|
+
onClick: handlePushDictionary,
|
|
161
109
|
children: saveButton.text
|
|
162
110
|
}
|
|
163
|
-
)
|
|
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 ||
|
|
116
|
+
disabled: !isEdited || isLoading,
|
|
169
117
|
Icon: lucideReact.Download,
|
|
170
118
|
color: "text",
|
|
171
119
|
className: "max-md:w-full",
|
|
172
|
-
isLoading:
|
|
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 {
|
|
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","ArrowUp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AER,UAAW,WAAA;AAAA,UAAA;AAAA,QACd;AAAA,QAED,KAAK,SAAS,OAAO,KACpBJ,2BAAA;AAAA,UAACC,sCAAAA,KAAK;AAAA,UAAL;AAAA,YACC,OAAO,eAAe,MAAM;AAAA,YAC5B,UAAU,CAAC,YAAY;AAAA,YACvB,MAAMI,YAAA;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;;"}
|
|
@@ -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;
|
|
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 {
|
|
5
|
-
import {
|
|
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 {
|
|
9
|
+
import { useWriteDictionary, usePushDictionaries } from "../../../hooks/intlayerAPIHooks.mjs";
|
|
11
10
|
import "deepmerge";
|
|
12
|
-
import "../../../
|
|
13
|
-
import "@
|
|
14
|
-
import "
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
17
|
+
const SaveForm = ({
|
|
18
|
+
dictionary,
|
|
19
|
+
mode,
|
|
20
|
+
className,
|
|
21
|
+
...props
|
|
22
|
+
}) => {
|
|
23
|
+
const { editor } = useConfiguration();
|
|
39
24
|
const { setLocaleDictionary } = useDictionariesRecordActions();
|
|
40
|
-
const {
|
|
41
|
-
const {
|
|
42
|
-
const
|
|
43
|
-
const {
|
|
44
|
-
const {
|
|
45
|
-
const
|
|
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
|
|
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
|
|
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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
-
|
|
66
|
+
"form",
|
|
102
67
|
{
|
|
103
|
-
className: "flex
|
|
104
|
-
...
|
|
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
|
|
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
|
|
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
|
|
88
|
+
disabled: !isEdited,
|
|
143
89
|
Icon: ArrowUpFromLine,
|
|
144
90
|
color: "text",
|
|
145
91
|
className: "max-md:w-full",
|
|
146
|
-
isLoading:
|
|
92
|
+
isLoading: isPushing,
|
|
93
|
+
onClick: handlePushDictionary,
|
|
147
94
|
children: publishButton.text
|
|
148
95
|
}
|
|
149
|
-
)
|
|
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 ||
|
|
101
|
+
disabled: !isEdited || isLoading,
|
|
155
102
|
Icon: Save,
|
|
156
103
|
color: "text",
|
|
157
104
|
className: "max-md:w-full",
|
|
158
|
-
isLoading:
|
|
105
|
+
isLoading: isPushing,
|
|
106
|
+
onClick: handlePushDictionary,
|
|
159
107
|
children: saveButton.text
|
|
160
108
|
}
|
|
161
|
-
)
|
|
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 ||
|
|
114
|
+
disabled: !isEdited || isLoading,
|
|
167
115
|
Icon: Download,
|
|
168
116
|
color: "text",
|
|
169
117
|
className: "max-md:w-full",
|
|
170
|
-
isLoading:
|
|
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 {
|
|
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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KAAK,wBAAwB,YAClD;AAAA,UAAC,KAAK;AAAA,UAAL;AAAA,YACC,OAAO,WAAW,MAAM;AAAA,YACxB,UAAU,CAAC,YAAY;AAAA,YACvB,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",
|