payload-intl 1.3.2 → 1.4.0
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/README.md +23 -3
- package/dist/components/MessagesField.d.ts +12 -0
- package/dist/components/MessagesField.d.ts.map +1 -0
- package/dist/components/MessagesField.js +36 -0
- package/dist/components/MessagesField.js.map +1 -0
- package/dist/components/MessagesImport.d.ts +2 -0
- package/dist/components/MessagesImport.d.ts.map +1 -0
- package/dist/components/MessagesImport.js +68 -0
- package/dist/components/MessagesImport.js.map +1 -0
- package/dist/components/MessagesImport.module.css +8 -0
- package/dist/components/input/LexicalInput.d.ts +8 -0
- package/dist/components/input/LexicalInput.d.ts.map +1 -0
- package/dist/components/input/LexicalInput.js +21 -0
- package/dist/components/input/LexicalInput.js.map +1 -0
- package/dist/components/input/MessageInput.d.ts +12 -0
- package/dist/components/input/MessageInput.d.ts.map +1 -0
- package/dist/components/{inputs → input}/MessageInput.js +31 -38
- package/dist/components/input/MessageInput.js.map +1 -0
- package/dist/components/{inputs → input}/MessageInput.module.css +14 -19
- package/dist/components/{inputs → input}/ReferencePopover.d.ts +1 -1
- package/dist/components/input/ReferencePopover.d.ts.map +1 -0
- package/dist/components/{inputs → input}/ReferencePopover.js +20 -5
- package/dist/components/input/ReferencePopover.js.map +1 -0
- package/dist/components/input/SingleLinePlugin.d.ts.map +1 -0
- package/dist/components/input/SingleLinePlugin.js.map +1 -0
- package/dist/components/{hooks → input}/useHtmlLexicalAdapter.d.ts.map +1 -1
- package/dist/components/{hooks → input}/useHtmlLexicalAdapter.js.map +1 -1
- package/dist/{utils/format.d.ts → components/input/utils.d.ts} +2 -2
- package/dist/components/input/utils.d.ts.map +1 -0
- package/dist/{utils/format.js → components/input/utils.js} +2 -2
- package/dist/components/input/utils.js.map +1 -0
- package/dist/components/input/variables/VariableChip.d.ts.map +1 -0
- package/dist/components/{inputs → input}/variables/VariableChip.js +1 -2
- package/dist/components/input/variables/VariableChip.js.map +1 -0
- package/dist/components/input/variables/VariableIcon.d.ts.map +1 -0
- package/dist/components/input/variables/VariableIcon.js.map +1 -0
- package/dist/components/input/variables/VariableNode.d.ts.map +1 -0
- package/dist/components/input/variables/VariableNode.js.map +1 -0
- package/dist/components/input/variables/VariableSuggestion.d.ts.map +1 -0
- package/dist/components/input/variables/VariableSuggestion.js.map +1 -0
- package/dist/components/input/variables/editors/PluralVariableEditor.d.ts.map +1 -0
- package/dist/components/{inputs → input}/variables/editors/PluralVariableEditor.js +1 -1
- package/dist/components/input/variables/editors/PluralVariableEditor.js.map +1 -0
- package/dist/components/input/variables/editors/SelectVariableEditor.d.ts.map +1 -0
- package/dist/components/{inputs → input}/variables/editors/SelectVariableEditor.js +1 -1
- package/dist/components/input/variables/editors/SelectVariableEditor.js.map +1 -0
- package/dist/components/input/variables/editors/TagVariableEditor.d.ts.map +1 -0
- package/dist/components/{inputs → input}/variables/editors/TagVariableEditor.js +1 -1
- package/dist/components/input/variables/editors/TagVariableEditor.js.map +1 -0
- package/dist/components/input/variables/editors/TemporalVariableEditor.d.ts.map +1 -0
- package/dist/components/input/variables/editors/TemporalVariableEditor.js.map +1 -0
- package/dist/components/input/variables/pickers/NumericVariableEditor.d.ts.map +1 -0
- package/dist/components/{inputs → input}/variables/pickers/NumericVariableEditor.js +1 -1
- package/dist/components/input/variables/pickers/NumericVariableEditor.js.map +1 -0
- package/dist/components/input/variables/pickers/TemporalVariablePicker.d.ts.map +1 -0
- package/dist/components/{inputs → input}/variables/pickers/TemporalVariablePicker.js +1 -1
- package/dist/components/input/variables/pickers/TemporalVariablePicker.js.map +1 -0
- package/dist/components/layout/MessageField.d.ts +5 -4
- package/dist/components/layout/MessageField.d.ts.map +1 -1
- package/dist/components/layout/MessageField.js +44 -51
- package/dist/components/layout/MessageField.js.map +1 -1
- package/dist/components/layout/MessageField.module.css +17 -5
- package/dist/components/layout/MessagesTabs.d.ts.map +1 -1
- package/dist/components/layout/MessagesTabs.js +9 -19
- package/dist/components/layout/MessagesTabs.js.map +1 -1
- package/dist/components/layout/MessagesTree.d.ts +7 -5
- package/dist/components/layout/MessagesTree.d.ts.map +1 -1
- package/dist/components/layout/MessagesTree.js +12 -22
- package/dist/components/layout/MessagesTree.js.map +1 -1
- package/dist/components/layout/MessagesTree.module.css +7 -3
- package/dist/{utils/config.d.ts → config.d.ts} +1 -1
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js.map +1 -0
- package/dist/const.d.ts +3 -9
- package/dist/const.d.ts.map +1 -1
- package/dist/const.js +3 -12
- package/dist/const.js.map +1 -1
- package/dist/exports/client.d.ts +3 -1
- package/dist/exports/client.d.ts.map +1 -1
- package/dist/exports/client.js +3 -1
- package/dist/exports/client.js.map +1 -1
- package/dist/exports/fetchMessages.d.ts +4 -0
- package/dist/exports/fetchMessages.d.ts.map +1 -0
- package/dist/exports/fetchMessages.js +18 -0
- package/dist/exports/fetchMessages.js.map +1 -0
- package/dist/exports/rsc.d.ts +0 -2
- package/dist/exports/rsc.d.ts.map +1 -1
- package/dist/exports/rsc.js +0 -2
- package/dist/exports/rsc.js.map +1 -1
- package/dist/file-storage-hooks.d.ts +17 -0
- package/dist/file-storage-hooks.d.ts.map +1 -0
- package/dist/file-storage-hooks.js +37 -0
- package/dist/file-storage-hooks.js.map +1 -0
- package/dist/hooks.d.ts +19 -3
- package/dist/hooks.d.ts.map +1 -1
- package/dist/hooks.js +41 -20
- package/dist/hooks.js.map +1 -1
- package/dist/icu/guards.d.ts.map +1 -0
- package/dist/icu/guards.js.map +1 -0
- package/dist/icu/index.d.ts +6 -0
- package/dist/icu/index.d.ts.map +1 -0
- package/dist/icu/index.js +7 -0
- package/dist/icu/index.js.map +1 -0
- package/dist/{utils/icu-tranform.d.ts → icu/lexical.d.ts} +1 -10
- package/dist/icu/lexical.d.ts.map +1 -0
- package/dist/{utils/icu-tranform.js → icu/lexical.js} +4 -44
- package/dist/icu/lexical.js.map +1 -0
- package/dist/icu/schema.d.ts +4 -0
- package/dist/icu/schema.d.ts.map +1 -0
- package/dist/icu/schema.js +43 -0
- package/dist/icu/schema.js.map +1 -0
- package/dist/icu/serialize.d.ts +11 -0
- package/dist/icu/serialize.d.ts.map +1 -0
- package/dist/icu/serialize.js +45 -0
- package/dist/icu/serialize.js.map +1 -0
- package/dist/icu/validate.d.ts.map +1 -0
- package/dist/icu/validate.js.map +1 -0
- package/dist/index.d.ts +23 -22
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +181 -37
- package/dist/index.js.map +1 -1
- package/dist/payload-types.d.ts +43 -16
- package/dist/payload-types.d.ts.map +1 -1
- package/dist/types.d.ts +24 -8
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/file-storage.d.ts +26 -0
- package/dist/utils/file-storage.d.ts.map +1 -0
- package/dist/utils/file-storage.js +61 -0
- package/dist/utils/file-storage.js.map +1 -0
- package/dist/utils/sanitize.d.ts +5 -3
- package/dist/utils/sanitize.d.ts.map +1 -1
- package/dist/utils/sanitize.js +4 -2
- package/dist/utils/sanitize.js.map +1 -1
- package/dist/utils/schema.d.ts +5 -7
- package/dist/utils/schema.d.ts.map +1 -1
- package/dist/utils/schema.js +11 -39
- package/dist/utils/schema.js.map +1 -1
- package/dist/utils/scopes.d.ts +3 -0
- package/dist/utils/scopes.d.ts.map +1 -0
- package/dist/utils/scopes.js +24 -0
- package/dist/utils/scopes.js.map +1 -0
- package/package.json +5 -5
- package/dist/components/MessageFormField.d.ts +0 -14
- package/dist/components/MessageFormField.d.ts.map +0 -1
- package/dist/components/MessageFormField.js +0 -28
- package/dist/components/MessageFormField.js.map +0 -1
- package/dist/components/MessagesForm.d.ts +0 -13
- package/dist/components/MessagesForm.d.ts.map +0 -1
- package/dist/components/MessagesForm.js +0 -120
- package/dist/components/MessagesForm.js.map +0 -1
- package/dist/components/MessagesForm.module.css +0 -41
- package/dist/components/MessagesFormProvider.d.ts +0 -33
- package/dist/components/MessagesFormProvider.d.ts.map +0 -1
- package/dist/components/MessagesFormProvider.js +0 -34
- package/dist/components/MessagesFormProvider.js.map +0 -1
- package/dist/components/MessagesLink.d.ts +0 -8
- package/dist/components/MessagesLink.d.ts.map +0 -1
- package/dist/components/MessagesLink.js +0 -22
- package/dist/components/MessagesLink.js.map +0 -1
- package/dist/components/MessagesView.d.ts +0 -10
- package/dist/components/MessagesView.d.ts.map +0 -1
- package/dist/components/MessagesView.js +0 -57
- package/dist/components/MessagesView.js.map +0 -1
- package/dist/components/actions/CopyMessages.d.ts +0 -2
- package/dist/components/actions/CopyMessages.d.ts.map +0 -1
- package/dist/components/actions/CopyMessages.js +0 -41
- package/dist/components/actions/CopyMessages.js.map +0 -1
- package/dist/components/actions/CopyMessages.module.css +0 -8
- package/dist/components/actions/JsonImport.d.ts +0 -5
- package/dist/components/actions/JsonImport.d.ts.map +0 -1
- package/dist/components/actions/JsonImport.js +0 -52
- package/dist/components/actions/JsonImport.js.map +0 -1
- package/dist/components/actions/JsonImport.module.css +0 -14
- package/dist/components/hooks/useMessagesFormSubmit.d.ts +0 -11
- package/dist/components/hooks/useMessagesFormSubmit.d.ts.map +0 -1
- package/dist/components/hooks/useMessagesFormSubmit.js +0 -44
- package/dist/components/hooks/useMessagesFormSubmit.js.map +0 -1
- package/dist/components/inputs/FieldWrapper.d.ts +0 -8
- package/dist/components/inputs/FieldWrapper.d.ts.map +0 -1
- package/dist/components/inputs/FieldWrapper.js +0 -24
- package/dist/components/inputs/FieldWrapper.js.map +0 -1
- package/dist/components/inputs/FieldWrapper.module.css +0 -24
- package/dist/components/inputs/LexicalInput.d.ts +0 -9
- package/dist/components/inputs/LexicalInput.d.ts.map +0 -1
- package/dist/components/inputs/LexicalInput.js +0 -26
- package/dist/components/inputs/LexicalInput.js.map +0 -1
- package/dist/components/inputs/MessageInput.d.ts +0 -14
- package/dist/components/inputs/MessageInput.d.ts.map +0 -1
- package/dist/components/inputs/MessageInput.js.map +0 -1
- package/dist/components/inputs/ReferencePopover.d.ts.map +0 -1
- package/dist/components/inputs/ReferencePopover.js.map +0 -1
- package/dist/components/inputs/SingleLinePlugin.d.ts.map +0 -1
- package/dist/components/inputs/SingleLinePlugin.js.map +0 -1
- package/dist/components/inputs/variables/VariableChip.d.ts.map +0 -1
- package/dist/components/inputs/variables/VariableChip.js.map +0 -1
- package/dist/components/inputs/variables/VariableIcon.d.ts.map +0 -1
- package/dist/components/inputs/variables/VariableIcon.js.map +0 -1
- package/dist/components/inputs/variables/VariableNode.d.ts.map +0 -1
- package/dist/components/inputs/variables/VariableNode.js.map +0 -1
- package/dist/components/inputs/variables/VariableSuggestion.d.ts.map +0 -1
- package/dist/components/inputs/variables/VariableSuggestion.js.map +0 -1
- package/dist/components/inputs/variables/editors/PluralVariableEditor.d.ts.map +0 -1
- package/dist/components/inputs/variables/editors/PluralVariableEditor.js.map +0 -1
- package/dist/components/inputs/variables/editors/SelectVariableEditor.d.ts.map +0 -1
- package/dist/components/inputs/variables/editors/SelectVariableEditor.js.map +0 -1
- package/dist/components/inputs/variables/editors/TagVariableEditor.d.ts.map +0 -1
- package/dist/components/inputs/variables/editors/TagVariableEditor.js.map +0 -1
- package/dist/components/inputs/variables/editors/TemporalVariableEditor.d.ts.map +0 -1
- package/dist/components/inputs/variables/editors/TemporalVariableEditor.js.map +0 -1
- package/dist/components/inputs/variables/pickers/NumericVariableEditor.d.ts.map +0 -1
- package/dist/components/inputs/variables/pickers/NumericVariableEditor.js.map +0 -1
- package/dist/components/inputs/variables/pickers/TemporalVariablePicker.d.ts.map +0 -1
- package/dist/components/inputs/variables/pickers/TemporalVariablePicker.js.map +0 -1
- package/dist/components/layout/GroupStatusDot.d.ts +0 -6
- package/dist/components/layout/GroupStatusDot.d.ts.map +0 -1
- package/dist/components/layout/GroupStatusDot.js +0 -24
- package/dist/components/layout/GroupStatusDot.js.map +0 -1
- package/dist/components/layout/StatusDot.d.ts +0 -7
- package/dist/components/layout/StatusDot.d.ts.map +0 -1
- package/dist/components/layout/StatusDot.js +0 -12
- package/dist/components/layout/StatusDot.js.map +0 -1
- package/dist/components/layout/StatusDot.module.css +0 -16
- package/dist/endpoints/set-messages.d.ts +0 -3
- package/dist/endpoints/set-messages.d.ts.map +0 -1
- package/dist/endpoints/set-messages.js +0 -105
- package/dist/endpoints/set-messages.js.map +0 -1
- package/dist/entities.d.ts +0 -5
- package/dist/entities.d.ts.map +0 -1
- package/dist/entities.js +0 -42
- package/dist/entities.js.map +0 -1
- package/dist/requests/fetchMessages.d.ts +0 -3
- package/dist/requests/fetchMessages.d.ts.map +0 -1
- package/dist/requests/fetchMessages.js +0 -40
- package/dist/requests/fetchMessages.js.map +0 -1
- package/dist/utils/config.d.ts.map +0 -1
- package/dist/utils/config.js.map +0 -1
- package/dist/utils/format.d.ts.map +0 -1
- package/dist/utils/format.js.map +0 -1
- package/dist/utils/guards.d.ts.map +0 -1
- package/dist/utils/guards.js.map +0 -1
- package/dist/utils/icu-tranform.d.ts.map +0 -1
- package/dist/utils/icu-tranform.js.map +0 -1
- package/dist/utils/validate.d.ts.map +0 -1
- package/dist/utils/validate.js.map +0 -1
- /package/dist/components/{inputs → input}/ReferencePopover.module.css +0 -0
- /package/dist/components/{inputs → input}/SingleLinePlugin.d.ts +0 -0
- /package/dist/components/{inputs → input}/SingleLinePlugin.js +0 -0
- /package/dist/components/{hooks → input}/useHtmlLexicalAdapter.d.ts +0 -0
- /package/dist/components/{hooks → input}/useHtmlLexicalAdapter.js +0 -0
- /package/dist/components/{inputs → input}/variables/VariableChip.d.ts +0 -0
- /package/dist/components/{inputs → input}/variables/VariableChip.module.css +0 -0
- /package/dist/components/{inputs → input}/variables/VariableIcon.d.ts +0 -0
- /package/dist/components/{inputs → input}/variables/VariableIcon.js +0 -0
- /package/dist/components/{inputs → input}/variables/VariableNode.d.ts +0 -0
- /package/dist/components/{inputs → input}/variables/VariableNode.js +0 -0
- /package/dist/components/{inputs → input}/variables/VariableSuggestion.d.ts +0 -0
- /package/dist/components/{inputs → input}/variables/VariableSuggestion.js +0 -0
- /package/dist/components/{inputs → input}/variables/VariableSuggestion.module.css +0 -0
- /package/dist/components/{inputs → input}/variables/editors/PluralVariableEditor.d.ts +0 -0
- /package/dist/components/{inputs → input}/variables/editors/PluralVariableEditor.module.css +0 -0
- /package/dist/components/{inputs → input}/variables/editors/SelectVariableEditor.d.ts +0 -0
- /package/dist/components/{inputs → input}/variables/editors/SelectVariableEditor.module.css +0 -0
- /package/dist/components/{inputs → input}/variables/editors/TagVariableEditor.d.ts +0 -0
- /package/dist/components/{inputs → input}/variables/editors/TagVariableEditor.module.css +0 -0
- /package/dist/components/{inputs → input}/variables/editors/TemporalVariableEditor.d.ts +0 -0
- /package/dist/components/{inputs → input}/variables/editors/TemporalVariableEditor.js +0 -0
- /package/dist/components/{inputs → input}/variables/pickers/NumericVariableEditor.d.ts +0 -0
- /package/dist/components/{inputs → input}/variables/pickers/NumericVariableEditor.module.css +0 -0
- /package/dist/components/{inputs → input}/variables/pickers/TemporalVariablePicker.d.ts +0 -0
- /package/dist/components/{inputs → input}/variables/pickers/TemporalVariablePicker.module.css +0 -0
- /package/dist/{utils/config.js → config.js} +0 -0
- /package/dist/{utils → icu}/guards.d.ts +0 -0
- /package/dist/{utils → icu}/guards.js +0 -0
- /package/dist/{utils → icu}/validate.d.ts +0 -0
- /package/dist/{utils → icu}/validate.js +0 -0
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { UseFormReturn } from 'react-hook-form';
|
|
2
|
-
import type { Locale, Messages, Translations } from '../types';
|
|
3
|
-
export type FormValues = Translations<Messages>;
|
|
4
|
-
interface MessagesFormProviderProps {
|
|
5
|
-
locales: Locale[];
|
|
6
|
-
defaultLocale: Locale;
|
|
7
|
-
activeLocale: Locale;
|
|
8
|
-
form: UseFormReturn<FormValues>;
|
|
9
|
-
}
|
|
10
|
-
export declare function MessagesFormProvider({ locales, defaultLocale, activeLocale, form, children, }: React.PropsWithChildren<MessagesFormProviderProps>): import("react/jsx-runtime").JSX.Element;
|
|
11
|
-
export declare const useMessagesForm: () => {
|
|
12
|
-
watch: import("react-hook-form").UseFormWatch<FormValues>;
|
|
13
|
-
getValues: import("react-hook-form").UseFormGetValues<FormValues>;
|
|
14
|
-
getFieldState: import("react-hook-form").UseFormGetFieldState<FormValues>;
|
|
15
|
-
setError: import("react-hook-form").UseFormSetError<FormValues>;
|
|
16
|
-
clearErrors: import("react-hook-form").UseFormClearErrors<FormValues>;
|
|
17
|
-
setValue: import("react-hook-form").UseFormSetValue<FormValues>;
|
|
18
|
-
trigger: import("react-hook-form").UseFormTrigger<FormValues>;
|
|
19
|
-
formState: import("react-hook-form").FormState<FormValues>;
|
|
20
|
-
resetField: import("react-hook-form").UseFormResetField<FormValues>;
|
|
21
|
-
reset: import("react-hook-form").UseFormReset<FormValues>;
|
|
22
|
-
handleSubmit: import("react-hook-form").UseFormHandleSubmit<FormValues, FormValues>;
|
|
23
|
-
unregister: import("react-hook-form").UseFormUnregister<FormValues>;
|
|
24
|
-
control: import("react-hook-form").Control<FormValues, any, FormValues>;
|
|
25
|
-
register: import("react-hook-form").UseFormRegister<FormValues>;
|
|
26
|
-
setFocus: import("react-hook-form").UseFormSetFocus<FormValues>;
|
|
27
|
-
subscribe: import("react-hook-form").UseFormSubscribe<FormValues>;
|
|
28
|
-
locales: Locale[];
|
|
29
|
-
defaultLocale: Locale;
|
|
30
|
-
activeLocale: Locale;
|
|
31
|
-
};
|
|
32
|
-
export {};
|
|
33
|
-
//# sourceMappingURL=MessagesFormProvider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MessagesFormProvider.d.ts","sourceRoot":"","sources":["../../src/components/MessagesFormProvider.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE9D,MAAM,MAAM,UAAU,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;AAYhD,UAAU,yBAAyB;IACjC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;CACjC;AAED,wBAAgB,oBAAoB,CAAC,EACnC,OAAO,EACP,aAAa,EACb,YAAY,EACZ,IAAI,EACJ,QAAQ,GACT,EAAE,KAAK,CAAC,iBAAiB,CAAC,yBAAyB,CAAC,2CAMpD;AAED,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;aA9BjB,MAAM,EAAE;mBACF,MAAM;kBACP,MAAM;CAmCrB,CAAC"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { createContext, use } from 'react';
|
|
4
|
-
import { FormProvider, useFormContext } from 'react-hook-form';
|
|
5
|
-
const MessagesFormContext = /*#__PURE__*/ createContext({
|
|
6
|
-
locales: [
|
|
7
|
-
'en'
|
|
8
|
-
],
|
|
9
|
-
defaultLocale: 'en',
|
|
10
|
-
activeLocale: 'en'
|
|
11
|
-
});
|
|
12
|
-
export function MessagesFormProvider({ locales, defaultLocale, activeLocale, form, children }) {
|
|
13
|
-
return /*#__PURE__*/ _jsx(MessagesFormContext, {
|
|
14
|
-
value: {
|
|
15
|
-
locales,
|
|
16
|
-
defaultLocale,
|
|
17
|
-
activeLocale
|
|
18
|
-
},
|
|
19
|
-
children: /*#__PURE__*/ _jsx(FormProvider, {
|
|
20
|
-
...form,
|
|
21
|
-
children: children
|
|
22
|
-
})
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
export const useMessagesForm = ()=>{
|
|
26
|
-
const context = use(MessagesFormContext);
|
|
27
|
-
const form = useFormContext();
|
|
28
|
-
return {
|
|
29
|
-
...context,
|
|
30
|
-
...form
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
//# sourceMappingURL=MessagesFormProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/MessagesFormProvider.tsx"],"sourcesContent":["'use client';\n\nimport { createContext, use } from 'react';\nimport type { UseFormReturn } from 'react-hook-form';\nimport { FormProvider, useFormContext } from 'react-hook-form';\nimport type { Locale, Messages, Translations } from '@/types';\n\nexport type FormValues = Translations<Messages>;\n\nconst MessagesFormContext = createContext<{\n locales: Locale[];\n defaultLocale: Locale;\n activeLocale: Locale;\n}>({\n locales: ['en'],\n defaultLocale: 'en',\n activeLocale: 'en',\n});\n\ninterface MessagesFormProviderProps {\n locales: Locale[];\n defaultLocale: Locale;\n activeLocale: Locale;\n form: UseFormReturn<FormValues>;\n}\n\nexport function MessagesFormProvider({\n locales,\n defaultLocale,\n activeLocale,\n form,\n children,\n}: React.PropsWithChildren<MessagesFormProviderProps>) {\n return (\n <MessagesFormContext value={{ locales, defaultLocale, activeLocale }}>\n <FormProvider {...form}>{children}</FormProvider>\n </MessagesFormContext>\n );\n}\n\nexport const useMessagesForm = () => {\n const context = use(MessagesFormContext);\n const form = useFormContext<FormValues>();\n return {\n ...context,\n ...form,\n };\n};\n"],"names":["createContext","use","FormProvider","useFormContext","MessagesFormContext","locales","defaultLocale","activeLocale","MessagesFormProvider","form","children","value","useMessagesForm","context"],"mappings":"AAAA;;AAEA,SAASA,aAAa,EAAEC,GAAG,QAAQ,QAAQ;AAE3C,SAASC,YAAY,EAAEC,cAAc,QAAQ,kBAAkB;AAK/D,MAAMC,oCAAsBJ,cAIzB;IACDK,SAAS;QAAC;KAAK;IACfC,eAAe;IACfC,cAAc;AAChB;AASA,OAAO,SAASC,qBAAqB,EACnCH,OAAO,EACPC,aAAa,EACbC,YAAY,EACZE,IAAI,EACJC,QAAQ,EAC2C;IACnD,qBACE,KAACN;QAAoBO,OAAO;YAAEN;YAASC;YAAeC;QAAa;kBACjE,cAAA,KAACL;YAAc,GAAGO,IAAI;sBAAGC;;;AAG/B;AAEA,OAAO,MAAME,kBAAkB;IAC7B,MAAMC,UAAUZ,IAAIG;IACpB,MAAMK,OAAON;IACb,OAAO;QACL,GAAGU,OAAO;QACV,GAAGJ,IAAI;IACT;AACF,EAAE"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { PayloadRequest } from 'payload';
|
|
2
|
-
import type { MessagesGuard } from '../types';
|
|
3
|
-
export interface MessagesLinkProps {
|
|
4
|
-
access?: MessagesGuard;
|
|
5
|
-
req: PayloadRequest;
|
|
6
|
-
}
|
|
7
|
-
export declare function MessagesLink({ access, req, }: MessagesLinkProps): Promise<import("react/jsx-runtime").JSX.Element | null>;
|
|
8
|
-
//# sourceMappingURL=MessagesLink.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MessagesLink.d.ts","sourceRoot":"","sources":["../../src/components/MessagesLink.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,GAAG,EAAE,cAAc,CAAC;CACrB;AAED,wBAAsB,YAAY,CAAC,EACjC,MAAmB,EACnB,GAAG,GACJ,EAAE,iBAAiB,2DAanB"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { getAdminURL } from '@davincicoding/payload-plugin-kit';
|
|
3
|
-
import { Button } from '@payloadcms/ui';
|
|
4
|
-
import { IconWorld } from '@tabler/icons-react';
|
|
5
|
-
export async function MessagesLink({ access = ()=>true, req }) {
|
|
6
|
-
const hasAccess = await access(req);
|
|
7
|
-
if (!hasAccess) return null;
|
|
8
|
-
return /*#__PURE__*/ _jsx(Button, {
|
|
9
|
-
buttonStyle: "tab",
|
|
10
|
-
el: "link",
|
|
11
|
-
to: getAdminURL({
|
|
12
|
-
req,
|
|
13
|
-
path: '/intl'
|
|
14
|
-
}),
|
|
15
|
-
children: /*#__PURE__*/ _jsx(IconWorld, {
|
|
16
|
-
size: 20,
|
|
17
|
-
strokeWidth: 1.5
|
|
18
|
-
})
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
//# sourceMappingURL=MessagesLink.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/MessagesLink.tsx"],"sourcesContent":["import { getAdminURL } from '@davincicoding/payload-plugin-kit';\nimport { Button } from '@payloadcms/ui';\nimport { IconWorld } from '@tabler/icons-react';\nimport type { PayloadRequest } from 'payload';\nimport type { MessagesGuard } from '@/types';\n\nexport interface MessagesLinkProps {\n access?: MessagesGuard;\n req: PayloadRequest;\n}\n\nexport async function MessagesLink({\n access = () => true,\n req,\n}: MessagesLinkProps) {\n const hasAccess = await access(req);\n if (!hasAccess) return null;\n\n return (\n <Button\n buttonStyle=\"tab\"\n el=\"link\"\n to={getAdminURL({ req, path: '/intl' })}\n >\n <IconWorld size={20} strokeWidth={1.5} />\n </Button>\n );\n}\n"],"names":["getAdminURL","Button","IconWorld","MessagesLink","access","req","hasAccess","buttonStyle","el","to","path","size","strokeWidth"],"mappings":";AAAA,SAASA,WAAW,QAAQ,oCAAoC;AAChE,SAASC,MAAM,QAAQ,iBAAiB;AACxC,SAASC,SAAS,QAAQ,sBAAsB;AAShD,OAAO,eAAeC,aAAa,EACjCC,SAAS,IAAM,IAAI,EACnBC,GAAG,EACe;IAClB,MAAMC,YAAY,MAAMF,OAAOC;IAC/B,IAAI,CAACC,WAAW,OAAO;IAEvB,qBACE,KAACL;QACCM,aAAY;QACZC,IAAG;QACHC,IAAIT,YAAY;YAAEK;YAAKK,MAAM;QAAQ;kBAErC,cAAA,KAACR;YAAUS,MAAM;YAAIC,aAAa;;;AAGxC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { AdminViewServerProps } from 'payload';
|
|
2
|
-
import type { Locale, Messages, MessagesGuard } from '../types';
|
|
3
|
-
export interface MessagesViewProps {
|
|
4
|
-
locales: Locale[];
|
|
5
|
-
schema: Messages;
|
|
6
|
-
tabs: boolean | undefined;
|
|
7
|
-
access: MessagesGuard;
|
|
8
|
-
}
|
|
9
|
-
export declare function MessagesView({ access, initPageResult: { req, locale, permissions, visibleEntities }, locales, params, payload, schema, searchParams, tabs, }: AdminViewServerProps & MessagesViewProps): Promise<import("react/jsx-runtime").JSX.Element | null>;
|
|
10
|
-
//# sourceMappingURL=MessagesView.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MessagesView.d.ts","sourceRoot":"","sources":["../../src/components/MessagesView.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,KAAK,EAEV,MAAM,EACN,QAAQ,EACR,aAAa,EAEd,MAAM,SAAS,CAAC;AAKjB,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,EAAE,QAAQ,CAAC;IACjB,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC;IAC1B,MAAM,EAAE,aAAa,CAAC;CACvB;AAED,wBAAsB,YAAY,CAAC,EACjC,MAAM,EACN,cAAc,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,eAAe,EAAE,EAC7D,OAAO,EACP,MAAM,EACN,OAAO,EACP,MAAM,EACN,YAAY,EACZ,IAAY,GACb,EAAE,oBAAoB,GAAG,iBAAiB,2DAwD1C"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { getAdminURL } from '@davincicoding/payload-plugin-kit';
|
|
3
|
-
import { DefaultTemplate } from '@payloadcms/next/templates';
|
|
4
|
-
import { Gutter } from '@payloadcms/ui';
|
|
5
|
-
import { RedirectType, redirect } from 'next/navigation';
|
|
6
|
-
import { sanitizeMessages } from '../utils/sanitize';
|
|
7
|
-
import { fetchMessages } from '../requests/fetchMessages';
|
|
8
|
-
import { MessagesForm } from './MessagesForm';
|
|
9
|
-
export async function MessagesView({ access, initPageResult: { req, locale, permissions, visibleEntities }, locales, params, payload, schema, searchParams, tabs = false }) {
|
|
10
|
-
const apiUrl = payload.getAPIURL();
|
|
11
|
-
const endpointUrl = apiUrl.endsWith('/') ? `${apiUrl}intl-plugin` : `${apiUrl}/intl-plugin`;
|
|
12
|
-
const hasAccess = await access(req);
|
|
13
|
-
if (!hasAccess) redirect(getAdminURL({
|
|
14
|
-
req
|
|
15
|
-
}), RedirectType.replace);
|
|
16
|
-
if (!payload.config.localization) {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
const defaultLocale = payload.config.localization.defaultLocale;
|
|
20
|
-
const activeLocale = typeof locale === 'string' ? locale : locale?.code ?? defaultLocale;
|
|
21
|
-
const translations = {};
|
|
22
|
-
for (const loc of locales){
|
|
23
|
-
const messages = await fetchMessages(payload, loc);
|
|
24
|
-
translations[loc] = sanitizeMessages(schema, messages, {
|
|
25
|
-
useSchemaDefaults: loc === defaultLocale
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
return /*#__PURE__*/ _jsx(DefaultTemplate, {
|
|
29
|
-
i18n: req.i18n,
|
|
30
|
-
locale: locale,
|
|
31
|
-
params: params,
|
|
32
|
-
payload: req.payload,
|
|
33
|
-
permissions: permissions,
|
|
34
|
-
searchParams: searchParams,
|
|
35
|
-
user: req.user || undefined,
|
|
36
|
-
viewActions: payload.config.admin.components.actions.filter((action)=>{
|
|
37
|
-
if (typeof action !== 'object') {
|
|
38
|
-
return true;
|
|
39
|
-
}
|
|
40
|
-
return action.exportName !== 'MessagesLink';
|
|
41
|
-
}),
|
|
42
|
-
visibleEntities: visibleEntities,
|
|
43
|
-
children: /*#__PURE__*/ _jsx(Gutter, {
|
|
44
|
-
children: /*#__PURE__*/ _jsx(MessagesForm, {
|
|
45
|
-
activeLocale: activeLocale,
|
|
46
|
-
defaultLocale: defaultLocale,
|
|
47
|
-
endpointUrl: endpointUrl,
|
|
48
|
-
locales: locales,
|
|
49
|
-
schema: schema,
|
|
50
|
-
tabs: tabs,
|
|
51
|
-
values: translations
|
|
52
|
-
})
|
|
53
|
-
})
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
//# sourceMappingURL=MessagesView.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/MessagesView.tsx"],"sourcesContent":["import { getAdminURL } from '@davincicoding/payload-plugin-kit';\nimport { DefaultTemplate } from '@payloadcms/next/templates';\nimport { Gutter } from '@payloadcms/ui';\nimport { RedirectType, redirect } from 'next/navigation';\nimport type { AdminViewServerProps } from 'payload';\nimport type {\n DeepPartial,\n Locale,\n Messages,\n MessagesGuard,\n Translations,\n} from '@/types';\nimport { sanitizeMessages } from '@/utils/sanitize';\nimport { fetchMessages } from '../requests/fetchMessages';\nimport { MessagesForm } from './MessagesForm';\n\nexport interface MessagesViewProps {\n locales: Locale[];\n schema: Messages;\n tabs: boolean | undefined;\n access: MessagesGuard;\n}\n\nexport async function MessagesView({\n access,\n initPageResult: { req, locale, permissions, visibleEntities },\n locales,\n params,\n payload,\n schema,\n searchParams,\n tabs = false,\n}: AdminViewServerProps & MessagesViewProps) {\n const apiUrl = payload.getAPIURL();\n const endpointUrl = apiUrl.endsWith('/')\n ? `${apiUrl}intl-plugin`\n : `${apiUrl}/intl-plugin`;\n\n const hasAccess = await access(req);\n if (!hasAccess) redirect(getAdminURL({ req }), RedirectType.replace);\n\n if (!payload.config.localization) {\n return null;\n }\n const defaultLocale = payload.config.localization.defaultLocale;\n const activeLocale =\n typeof locale === 'string' ? locale : (locale?.code ?? defaultLocale);\n\n const translations: Translations<DeepPartial<Messages>> = {};\n\n for (const loc of locales) {\n const messages = await fetchMessages(payload, loc);\n\n translations[loc] = sanitizeMessages(schema, messages, {\n useSchemaDefaults: loc === defaultLocale,\n });\n }\n\n return (\n <DefaultTemplate\n i18n={req.i18n}\n locale={locale}\n params={params}\n payload={req.payload}\n permissions={permissions}\n searchParams={searchParams}\n user={req.user || undefined}\n viewActions={payload.config.admin.components.actions.filter((action) => {\n if (typeof action !== 'object') {\n return true;\n }\n return action.exportName !== 'MessagesLink';\n })}\n visibleEntities={visibleEntities}\n >\n <Gutter>\n <MessagesForm\n activeLocale={activeLocale}\n defaultLocale={defaultLocale}\n endpointUrl={endpointUrl}\n locales={locales}\n schema={schema}\n tabs={tabs}\n values={translations}\n />\n </Gutter>\n </DefaultTemplate>\n );\n}\n"],"names":["getAdminURL","DefaultTemplate","Gutter","RedirectType","redirect","sanitizeMessages","fetchMessages","MessagesForm","MessagesView","access","initPageResult","req","locale","permissions","visibleEntities","locales","params","payload","schema","searchParams","tabs","apiUrl","getAPIURL","endpointUrl","endsWith","hasAccess","replace","config","localization","defaultLocale","activeLocale","code","translations","loc","messages","useSchemaDefaults","i18n","user","undefined","viewActions","admin","components","actions","filter","action","exportName","values"],"mappings":";AAAA,SAASA,WAAW,QAAQ,oCAAoC;AAChE,SAASC,eAAe,QAAQ,6BAA6B;AAC7D,SAASC,MAAM,QAAQ,iBAAiB;AACxC,SAASC,YAAY,EAAEC,QAAQ,QAAQ,kBAAkB;AASzD,SAASC,gBAAgB,QAAQ,mBAAmB;AACpD,SAASC,aAAa,QAAQ,4BAA4B;AAC1D,SAASC,YAAY,QAAQ,iBAAiB;AAS9C,OAAO,eAAeC,aAAa,EACjCC,MAAM,EACNC,gBAAgB,EAAEC,GAAG,EAAEC,MAAM,EAAEC,WAAW,EAAEC,eAAe,EAAE,EAC7DC,OAAO,EACPC,MAAM,EACNC,OAAO,EACPC,MAAM,EACNC,YAAY,EACZC,OAAO,KAAK,EAC6B;IACzC,MAAMC,SAASJ,QAAQK,SAAS;IAChC,MAAMC,cAAcF,OAAOG,QAAQ,CAAC,OAChC,GAAGH,OAAO,WAAW,CAAC,GACtB,GAAGA,OAAO,YAAY,CAAC;IAE3B,MAAMI,YAAY,MAAMhB,OAAOE;IAC/B,IAAI,CAACc,WAAWrB,SAASJ,YAAY;QAAEW;IAAI,IAAIR,aAAauB,OAAO;IAEnE,IAAI,CAACT,QAAQU,MAAM,CAACC,YAAY,EAAE;QAChC,OAAO;IACT;IACA,MAAMC,gBAAgBZ,QAAQU,MAAM,CAACC,YAAY,CAACC,aAAa;IAC/D,MAAMC,eACJ,OAAOlB,WAAW,WAAWA,SAAUA,QAAQmB,QAAQF;IAEzD,MAAMG,eAAoD,CAAC;IAE3D,KAAK,MAAMC,OAAOlB,QAAS;QACzB,MAAMmB,WAAW,MAAM5B,cAAcW,SAASgB;QAE9CD,YAAY,CAACC,IAAI,GAAG5B,iBAAiBa,QAAQgB,UAAU;YACrDC,mBAAmBF,QAAQJ;QAC7B;IACF;IAEA,qBACE,KAAC5B;QACCmC,MAAMzB,IAAIyB,IAAI;QACdxB,QAAQA;QACRI,QAAQA;QACRC,SAASN,IAAIM,OAAO;QACpBJ,aAAaA;QACbM,cAAcA;QACdkB,MAAM1B,IAAI0B,IAAI,IAAIC;QAClBC,aAAatB,QAAQU,MAAM,CAACa,KAAK,CAACC,UAAU,CAACC,OAAO,CAACC,MAAM,CAAC,CAACC;YAC3D,IAAI,OAAOA,WAAW,UAAU;gBAC9B,OAAO;YACT;YACA,OAAOA,OAAOC,UAAU,KAAK;QAC/B;QACA/B,iBAAiBA;kBAEjB,cAAA,KAACZ;sBACC,cAAA,KAACK;gBACCuB,cAAcA;gBACdD,eAAeA;gBACfN,aAAaA;gBACbR,SAASA;gBACTG,QAAQA;gBACRE,MAAMA;gBACN0B,QAAQd;;;;AAKlB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CopyMessages.d.ts","sourceRoot":"","sources":["../../../src/components/actions/CopyMessages.tsx"],"names":[],"mappings":"AAQA,wBAAgB,YAAY,4CA4B3B"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Button } from '@payloadcms/ui';
|
|
3
|
-
import { IconBraces } from '@tabler/icons-react';
|
|
4
|
-
import { get } from 'lodash-es';
|
|
5
|
-
import { useMessagesForm } from '../../components/MessagesFormProvider';
|
|
6
|
-
import styles from './CopyMessages.module.css';
|
|
7
|
-
export function CopyMessages() {
|
|
8
|
-
const { getValues, setValue, locales } = useMessagesForm();
|
|
9
|
-
const handleCopy = ()=>{
|
|
10
|
-
const sourcePath = prompt('Source path');
|
|
11
|
-
if (!sourcePath) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
const targetPath = prompt('Target path');
|
|
15
|
-
if (!targetPath) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
locales.forEach((locale)=>{
|
|
19
|
-
const sourceValue = get(getValues(), [
|
|
20
|
-
locale,
|
|
21
|
-
sourcePath
|
|
22
|
-
].join('.'));
|
|
23
|
-
setValue([
|
|
24
|
-
locale,
|
|
25
|
-
targetPath
|
|
26
|
-
].join('.'), sourceValue);
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
return /*#__PURE__*/ _jsx(Button, {
|
|
30
|
-
buttonStyle: "subtle",
|
|
31
|
-
className: styles.button,
|
|
32
|
-
icon: /*#__PURE__*/ _jsx(IconBraces, {
|
|
33
|
-
className: styles.icon
|
|
34
|
-
}),
|
|
35
|
-
iconPosition: "left",
|
|
36
|
-
onClick: handleCopy,
|
|
37
|
-
children: "Copy"
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
//# sourceMappingURL=CopyMessages.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/actions/CopyMessages.tsx"],"sourcesContent":["import { Button } from '@payloadcms/ui';\nimport { IconBraces } from '@tabler/icons-react';\nimport { get } from 'lodash-es';\n\nimport { useMessagesForm } from '@/components/MessagesFormProvider';\n\nimport styles from './CopyMessages.module.css';\n\nexport function CopyMessages() {\n const { getValues, setValue, locales } = useMessagesForm();\n const handleCopy = () => {\n const sourcePath = prompt('Source path');\n if (!sourcePath) {\n return;\n }\n const targetPath = prompt('Target path');\n if (!targetPath) {\n return;\n }\n\n locales.forEach((locale) => {\n const sourceValue = get(getValues(), [locale, sourcePath].join('.'));\n setValue([locale, targetPath].join('.'), sourceValue);\n });\n };\n return (\n <Button\n buttonStyle=\"subtle\"\n className={styles.button}\n icon={<IconBraces className={styles.icon} />}\n iconPosition=\"left\"\n onClick={handleCopy}\n >\n Copy\n </Button>\n );\n}\n"],"names":["Button","IconBraces","get","useMessagesForm","styles","CopyMessages","getValues","setValue","locales","handleCopy","sourcePath","prompt","targetPath","forEach","locale","sourceValue","join","buttonStyle","className","button","icon","iconPosition","onClick"],"mappings":";AAAA,SAASA,MAAM,QAAQ,iBAAiB;AACxC,SAASC,UAAU,QAAQ,sBAAsB;AACjD,SAASC,GAAG,QAAQ,YAAY;AAEhC,SAASC,eAAe,QAAQ,oCAAoC;AAEpE,OAAOC,YAAY,4BAA4B;AAE/C,OAAO,SAASC;IACd,MAAM,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,OAAO,EAAE,GAAGL;IACzC,MAAMM,aAAa;QACjB,MAAMC,aAAaC,OAAO;QAC1B,IAAI,CAACD,YAAY;YACf;QACF;QACA,MAAME,aAAaD,OAAO;QAC1B,IAAI,CAACC,YAAY;YACf;QACF;QAEAJ,QAAQK,OAAO,CAAC,CAACC;YACf,MAAMC,cAAcb,IAAII,aAAa;gBAACQ;gBAAQJ;aAAW,CAACM,IAAI,CAAC;YAC/DT,SAAS;gBAACO;gBAAQF;aAAW,CAACI,IAAI,CAAC,MAAMD;QAC3C;IACF;IACA,qBACE,KAACf;QACCiB,aAAY;QACZC,WAAWd,OAAOe,MAAM;QACxBC,oBAAM,KAACnB;YAAWiB,WAAWd,OAAOgB,IAAI;;QACxCC,cAAa;QACbC,SAASb;kBACV;;AAIL"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"JsonImport.d.ts","sourceRoot":"","sources":["../../../src/components/actions/JsonImport.tsx"],"names":[],"mappings":"AAQA,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,MAAM,CAAC;CACtB;AACD,wBAAgB,UAAU,CAAC,EAAE,YAAY,EAAE,EAAE,eAAe,2CA6C3D"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { Button } from '@payloadcms/ui';
|
|
3
|
-
import { IconBraces } from '@tabler/icons-react';
|
|
4
|
-
import { useRef } from 'react';
|
|
5
|
-
import { useMessagesForm } from '../../components/MessagesFormProvider';
|
|
6
|
-
import styles from './JsonImport.module.css';
|
|
7
|
-
export function JsonImport({ activeLocale }) {
|
|
8
|
-
const { setValue } = useMessagesForm();
|
|
9
|
-
const inputRef = useRef(null);
|
|
10
|
-
const handleImportJSON = (event)=>{
|
|
11
|
-
const file = event.target.files?.[0];
|
|
12
|
-
if (!file) {
|
|
13
|
-
event.target.value = '';
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
const reader = new FileReader();
|
|
17
|
-
reader.onload = (readerEvent)=>{
|
|
18
|
-
const text = readerEvent.target?.result;
|
|
19
|
-
const data = JSON.parse(text);
|
|
20
|
-
setValue(activeLocale, data, {
|
|
21
|
-
shouldDirty: true,
|
|
22
|
-
shouldValidate: true
|
|
23
|
-
});
|
|
24
|
-
// Clear the input value to allow re-selection of the same or different file
|
|
25
|
-
event.target.value = '';
|
|
26
|
-
};
|
|
27
|
-
reader.readAsText(file);
|
|
28
|
-
};
|
|
29
|
-
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
30
|
-
children: [
|
|
31
|
-
/*#__PURE__*/ _jsx("input", {
|
|
32
|
-
accept: ".json",
|
|
33
|
-
hidden: true,
|
|
34
|
-
onChange: handleImportJSON,
|
|
35
|
-
ref: inputRef,
|
|
36
|
-
type: "file"
|
|
37
|
-
}),
|
|
38
|
-
/*#__PURE__*/ _jsx(Button, {
|
|
39
|
-
buttonStyle: "subtle",
|
|
40
|
-
className: styles.button,
|
|
41
|
-
icon: /*#__PURE__*/ _jsx(IconBraces, {
|
|
42
|
-
className: styles.icon
|
|
43
|
-
}),
|
|
44
|
-
iconPosition: "left",
|
|
45
|
-
onClick: ()=>inputRef.current?.click(),
|
|
46
|
-
children: "Import"
|
|
47
|
-
})
|
|
48
|
-
]
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
//# sourceMappingURL=JsonImport.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/actions/JsonImport.tsx"],"sourcesContent":["import { Button } from '@payloadcms/ui';\nimport { IconBraces } from '@tabler/icons-react';\nimport { useRef } from 'react';\n\nimport { useMessagesForm } from '@/components/MessagesFormProvider';\n\nimport styles from './JsonImport.module.css';\n\nexport interface JsonImportProps {\n activeLocale: string;\n}\nexport function JsonImport({ activeLocale }: JsonImportProps) {\n const { setValue } = useMessagesForm();\n const inputRef = useRef<HTMLInputElement>(null);\n\n const handleImportJSON = (event: React.ChangeEvent<HTMLInputElement>) => {\n const file = event.target.files?.[0];\n if (!file) {\n event.target.value = '';\n return;\n }\n\n const reader = new FileReader();\n reader.onload = (readerEvent) => {\n const text = readerEvent.target?.result as string;\n const data = JSON.parse(text);\n setValue(activeLocale, data, {\n shouldDirty: true,\n shouldValidate: true,\n });\n // Clear the input value to allow re-selection of the same or different file\n event.target.value = '';\n };\n reader.readAsText(file);\n };\n\n return (\n <>\n <input\n accept=\".json\"\n hidden\n onChange={handleImportJSON}\n ref={inputRef}\n type=\"file\"\n />\n <Button\n buttonStyle=\"subtle\"\n className={styles.button}\n icon={<IconBraces className={styles.icon} />}\n iconPosition=\"left\"\n onClick={() => inputRef.current?.click()}\n >\n Import\n </Button>\n </>\n );\n}\n"],"names":["Button","IconBraces","useRef","useMessagesForm","styles","JsonImport","activeLocale","setValue","inputRef","handleImportJSON","event","file","target","files","value","reader","FileReader","onload","readerEvent","text","result","data","JSON","parse","shouldDirty","shouldValidate","readAsText","input","accept","hidden","onChange","ref","type","buttonStyle","className","button","icon","iconPosition","onClick","current","click"],"mappings":";AAAA,SAASA,MAAM,QAAQ,iBAAiB;AACxC,SAASC,UAAU,QAAQ,sBAAsB;AACjD,SAASC,MAAM,QAAQ,QAAQ;AAE/B,SAASC,eAAe,QAAQ,oCAAoC;AAEpE,OAAOC,YAAY,0BAA0B;AAK7C,OAAO,SAASC,WAAW,EAAEC,YAAY,EAAmB;IAC1D,MAAM,EAAEC,QAAQ,EAAE,GAAGJ;IACrB,MAAMK,WAAWN,OAAyB;IAE1C,MAAMO,mBAAmB,CAACC;QACxB,MAAMC,OAAOD,MAAME,MAAM,CAACC,KAAK,EAAE,CAAC,EAAE;QACpC,IAAI,CAACF,MAAM;YACTD,MAAME,MAAM,CAACE,KAAK,GAAG;YACrB;QACF;QAEA,MAAMC,SAAS,IAAIC;QACnBD,OAAOE,MAAM,GAAG,CAACC;YACf,MAAMC,OAAOD,YAAYN,MAAM,EAAEQ;YACjC,MAAMC,OAAOC,KAAKC,KAAK,CAACJ;YACxBZ,SAASD,cAAce,MAAM;gBAC3BG,aAAa;gBACbC,gBAAgB;YAClB;YACA,4EAA4E;YAC5Ef,MAAME,MAAM,CAACE,KAAK,GAAG;QACvB;QACAC,OAAOW,UAAU,CAACf;IACpB;IAEA,qBACE;;0BACE,KAACgB;gBACCC,QAAO;gBACPC,MAAM;gBACNC,UAAUrB;gBACVsB,KAAKvB;gBACLwB,MAAK;;0BAEP,KAAChC;gBACCiC,aAAY;gBACZC,WAAW9B,OAAO+B,MAAM;gBACxBC,oBAAM,KAACnC;oBAAWiC,WAAW9B,OAAOgC,IAAI;;gBACxCC,cAAa;gBACbC,SAAS,IAAM9B,SAAS+B,OAAO,EAAEC;0BAClC;;;;AAKP"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { UseFormReturn } from 'react-hook-form';
|
|
2
|
-
import type { FormValues } from '../../components/MessagesFormProvider';
|
|
3
|
-
import type { DeepPartial, Messages, Translations } from '../../types';
|
|
4
|
-
interface UseMessagesFormSubmitOptions {
|
|
5
|
-
endpointUrl: string;
|
|
6
|
-
defaultValues: Translations<DeepPartial<Messages>>;
|
|
7
|
-
form: UseFormReturn<FormValues>;
|
|
8
|
-
}
|
|
9
|
-
export declare function useMessagesFormSubmit({ endpointUrl, defaultValues, form, }: UseMessagesFormSubmitOptions): (currentValues: FormValues) => Promise<void>;
|
|
10
|
-
export {};
|
|
11
|
-
//# sourceMappingURL=useMessagesFormSubmit.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useMessagesFormSubmit.d.ts","sourceRoot":"","sources":["../../../src/components/hooks/useMessagesFormSubmit.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGnE,UAAU,4BAA4B;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,YAAY,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC;IACnD,IAAI,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;CACjC;AAED,wBAAgB,qBAAqB,CAAC,EACpC,WAAW,EACX,aAAa,EACb,IAAI,GACL,EAAE,4BAA4B,mBAGc,UAAU,mBAyCtD"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { toast, useDocumentEvents } from '@payloadcms/ui';
|
|
2
|
-
import { isEqual } from 'lodash-es';
|
|
3
|
-
import { getErrorMessage } from '../../utils/error-handling';
|
|
4
|
-
export function useMessagesFormSubmit({ endpointUrl, defaultValues, form }) {
|
|
5
|
-
const { reportUpdate } = useDocumentEvents();
|
|
6
|
-
const handleSubmit = async (currentValues)=>{
|
|
7
|
-
const toastId = toast.loading('Saving...');
|
|
8
|
-
const changes = Object.entries(currentValues).reduce((acc, [locale, value])=>{
|
|
9
|
-
const hasChanged = !isEqual(value, defaultValues[locale]);
|
|
10
|
-
if (!hasChanged) return acc;
|
|
11
|
-
acc[locale] = value;
|
|
12
|
-
return acc;
|
|
13
|
-
}, {});
|
|
14
|
-
try {
|
|
15
|
-
const response = await fetch(endpointUrl, {
|
|
16
|
-
method: 'PUT',
|
|
17
|
-
headers: {
|
|
18
|
-
'Content-Type': 'application/json'
|
|
19
|
-
},
|
|
20
|
-
body: JSON.stringify(changes)
|
|
21
|
-
});
|
|
22
|
-
if (!response.ok) {
|
|
23
|
-
const error = await getErrorMessage(response);
|
|
24
|
-
throw new Error(error);
|
|
25
|
-
}
|
|
26
|
-
form.reset(currentValues);
|
|
27
|
-
reportUpdate({
|
|
28
|
-
entitySlug: 'messages',
|
|
29
|
-
operation: 'update',
|
|
30
|
-
updatedAt: new Date().toISOString()
|
|
31
|
-
});
|
|
32
|
-
toast.success('Saved', {
|
|
33
|
-
id: toastId
|
|
34
|
-
});
|
|
35
|
-
} catch (error) {
|
|
36
|
-
toast.error(`Failed to save: ${error instanceof Error ? error.message : 'Unknown error'}`, {
|
|
37
|
-
id: toastId
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
return handleSubmit;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
//# sourceMappingURL=useMessagesFormSubmit.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/hooks/useMessagesFormSubmit.ts"],"sourcesContent":["import { toast, useDocumentEvents } from '@payloadcms/ui';\nimport { isEqual } from 'lodash-es';\nimport type { UseFormReturn } from 'react-hook-form';\nimport type { FormValues } from '@/components/MessagesFormProvider';\nimport type { DeepPartial, Messages, Translations } from '@/types';\nimport { getErrorMessage } from '@/utils/error-handling';\n\ninterface UseMessagesFormSubmitOptions {\n endpointUrl: string;\n defaultValues: Translations<DeepPartial<Messages>>;\n form: UseFormReturn<FormValues>;\n}\n\nexport function useMessagesFormSubmit({\n endpointUrl,\n defaultValues,\n form,\n}: UseMessagesFormSubmitOptions) {\n const { reportUpdate } = useDocumentEvents();\n\n const handleSubmit = async (currentValues: FormValues) => {\n const toastId = toast.loading('Saving...');\n const changes = Object.entries(currentValues).reduce<\n Translations<Messages>\n >((acc, [locale, value]) => {\n const hasChanged = !isEqual(value, defaultValues[locale]);\n if (!hasChanged) return acc;\n acc[locale] = value;\n return acc;\n }, {});\n\n try {\n const response = await fetch(endpointUrl, {\n method: 'PUT',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(changes),\n });\n\n if (!response.ok) {\n const error = await getErrorMessage(response);\n throw new Error(error);\n }\n\n form.reset(currentValues);\n reportUpdate({\n entitySlug: 'messages',\n operation: 'update',\n updatedAt: new Date().toISOString(),\n });\n toast.success('Saved', { id: toastId });\n } catch (error) {\n toast.error(\n `Failed to save: ${error instanceof Error ? error.message : 'Unknown error'}`,\n { id: toastId },\n );\n }\n };\n\n return handleSubmit;\n}\n"],"names":["toast","useDocumentEvents","isEqual","getErrorMessage","useMessagesFormSubmit","endpointUrl","defaultValues","form","reportUpdate","handleSubmit","currentValues","toastId","loading","changes","Object","entries","reduce","acc","locale","value","hasChanged","response","fetch","method","headers","body","JSON","stringify","ok","error","Error","reset","entitySlug","operation","updatedAt","Date","toISOString","success","id","message"],"mappings":"AAAA,SAASA,KAAK,EAAEC,iBAAiB,QAAQ,iBAAiB;AAC1D,SAASC,OAAO,QAAQ,YAAY;AAIpC,SAASC,eAAe,QAAQ,yBAAyB;AAQzD,OAAO,SAASC,sBAAsB,EACpCC,WAAW,EACXC,aAAa,EACbC,IAAI,EACyB;IAC7B,MAAM,EAAEC,YAAY,EAAE,GAAGP;IAEzB,MAAMQ,eAAe,OAAOC;QAC1B,MAAMC,UAAUX,MAAMY,OAAO,CAAC;QAC9B,MAAMC,UAAUC,OAAOC,OAAO,CAACL,eAAeM,MAAM,CAElD,CAACC,KAAK,CAACC,QAAQC,MAAM;YACrB,MAAMC,aAAa,CAAClB,QAAQiB,OAAOb,aAAa,CAACY,OAAO;YACxD,IAAI,CAACE,YAAY,OAAOH;YACxBA,GAAG,CAACC,OAAO,GAAGC;YACd,OAAOF;QACT,GAAG,CAAC;QAEJ,IAAI;YACF,MAAMI,WAAW,MAAMC,MAAMjB,aAAa;gBACxCkB,QAAQ;gBACRC,SAAS;oBACP,gBAAgB;gBAClB;gBACAC,MAAMC,KAAKC,SAAS,CAACd;YACvB;YAEA,IAAI,CAACQ,SAASO,EAAE,EAAE;gBAChB,MAAMC,QAAQ,MAAM1B,gBAAgBkB;gBACpC,MAAM,IAAIS,MAAMD;YAClB;YAEAtB,KAAKwB,KAAK,CAACrB;YACXF,aAAa;gBACXwB,YAAY;gBACZC,WAAW;gBACXC,WAAW,IAAIC,OAAOC,WAAW;YACnC;YACApC,MAAMqC,OAAO,CAAC,SAAS;gBAAEC,IAAI3B;YAAQ;QACvC,EAAE,OAAOkB,OAAO;YACd7B,MAAM6B,KAAK,CACT,CAAC,gBAAgB,EAAEA,iBAAiBC,QAAQD,MAAMU,OAAO,GAAG,iBAAiB,EAC7E;gBAAED,IAAI3B;YAAQ;QAElB;IACF;IAEA,OAAOF;AACT"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { FieldError } from 'react-hook-form';
|
|
2
|
-
export interface FieldWrapperProps {
|
|
3
|
-
error: FieldError | undefined;
|
|
4
|
-
className?: string;
|
|
5
|
-
reference?: string;
|
|
6
|
-
}
|
|
7
|
-
export declare function FieldWrapper({ error, reference, className, children, }: React.PropsWithChildren<FieldWrapperProps>): import("react/jsx-runtime").JSX.Element;
|
|
8
|
-
//# sourceMappingURL=FieldWrapper.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FieldWrapper.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/FieldWrapper.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAKlD,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,UAAU,GAAG,SAAS,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,SAAS,EACT,SAAS,EACT,QAAQ,GACT,EAAE,KAAK,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,2CAa5C"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import clsx from 'clsx';
|
|
3
|
-
import styles from './FieldWrapper.module.css';
|
|
4
|
-
import { ReferencePopover } from './ReferencePopover';
|
|
5
|
-
export function FieldWrapper({ error, reference, className, children }) {
|
|
6
|
-
return /*#__PURE__*/ _jsxs("div", {
|
|
7
|
-
className: clsx(styles.wrapper, className),
|
|
8
|
-
children: [
|
|
9
|
-
/*#__PURE__*/ _jsx(ReferencePopover, {
|
|
10
|
-
reference: reference,
|
|
11
|
-
children: /*#__PURE__*/ _jsx("fieldset", {
|
|
12
|
-
className: clsx(styles.fieldset, error && styles.fieldsetError),
|
|
13
|
-
children: children
|
|
14
|
-
})
|
|
15
|
-
}),
|
|
16
|
-
error?.message && /*#__PURE__*/ _jsx("p", {
|
|
17
|
-
className: styles.errorMessage,
|
|
18
|
-
children: error.message
|
|
19
|
-
})
|
|
20
|
-
]
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
//# sourceMappingURL=FieldWrapper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/inputs/FieldWrapper.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport type { FieldError } from 'react-hook-form';\n\nimport styles from './FieldWrapper.module.css';\nimport { ReferencePopover } from './ReferencePopover';\n\nexport interface FieldWrapperProps {\n error: FieldError | undefined;\n className?: string;\n reference?: string;\n}\n\nexport function FieldWrapper({\n error,\n reference,\n className,\n children,\n}: React.PropsWithChildren<FieldWrapperProps>) {\n return (\n <div className={clsx(styles.wrapper, className)}>\n <ReferencePopover reference={reference}>\n <fieldset\n className={clsx(styles.fieldset, error && styles.fieldsetError)}\n >\n {children}\n </fieldset>\n </ReferencePopover>\n {error?.message && <p className={styles.errorMessage}>{error.message}</p>}\n </div>\n );\n}\n"],"names":["clsx","styles","ReferencePopover","FieldWrapper","error","reference","className","children","div","wrapper","fieldset","fieldsetError","message","p","errorMessage"],"mappings":";AAAA,OAAOA,UAAU,OAAO;AAGxB,OAAOC,YAAY,4BAA4B;AAC/C,SAASC,gBAAgB,QAAQ,qBAAqB;AAQtD,OAAO,SAASC,aAAa,EAC3BC,KAAK,EACLC,SAAS,EACTC,SAAS,EACTC,QAAQ,EACmC;IAC3C,qBACE,MAACC;QAAIF,WAAWN,KAAKC,OAAOQ,OAAO,EAAEH;;0BACnC,KAACJ;gBAAiBG,WAAWA;0BAC3B,cAAA,KAACK;oBACCJ,WAAWN,KAAKC,OAAOS,QAAQ,EAAEN,SAASH,OAAOU,aAAa;8BAE7DJ;;;YAGJH,OAAOQ,yBAAW,KAACC;gBAAEP,WAAWL,OAAOa,YAAY;0BAAGV,MAAMQ,OAAO;;;;AAG1E"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
.wrapper {
|
|
2
|
-
display: flex;
|
|
3
|
-
height: 100%;
|
|
4
|
-
min-width: 1.25rem;
|
|
5
|
-
flex-direction: column;
|
|
6
|
-
gap: 0.25rem;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.fieldset {
|
|
10
|
-
margin-inline: 0;
|
|
11
|
-
padding: 0;
|
|
12
|
-
border: none;
|
|
13
|
-
flex: 1;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.legend {
|
|
17
|
-
padding-inline: 0.375rem;
|
|
18
|
-
font-size: var(--font-size-base);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.errorMessage {
|
|
22
|
-
font-size: var(--font-size-base);
|
|
23
|
-
color: var(--theme-error-400);
|
|
24
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { FieldWrapperProps } from './FieldWrapper';
|
|
2
|
-
export interface LexicalInputProps extends FieldWrapperProps {
|
|
3
|
-
lang: string;
|
|
4
|
-
value: string;
|
|
5
|
-
onChange: (value: string) => void;
|
|
6
|
-
onBlur: () => void;
|
|
7
|
-
}
|
|
8
|
-
export declare function LexicalInput({ error, value, onChange, className, }: LexicalInputProps): React.ReactNode;
|
|
9
|
-
//# sourceMappingURL=LexicalInput.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LexicalInput.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/LexicalInput.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGxD,MAAM,WAAW,iBAAkB,SAAQ,iBAAiB;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAED,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,KAAK,EACL,QAAQ,EACR,SAAS,GACV,EAAE,iBAAiB,GAAG,KAAK,CAAC,SAAS,CAoBrC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { RenderLexical } from '@payloadcms/richtext-lexical/client';
|
|
3
|
-
import { useHtmlLexicalAdapter } from '../hooks/useHtmlLexicalAdapter';
|
|
4
|
-
import { FieldWrapper } from './FieldWrapper';
|
|
5
|
-
export function LexicalInput({ error, value, onChange, className }) {
|
|
6
|
-
const editor = useHtmlLexicalAdapter({
|
|
7
|
-
html: value,
|
|
8
|
-
onChange
|
|
9
|
-
});
|
|
10
|
-
return /*#__PURE__*/ _jsx(FieldWrapper, {
|
|
11
|
-
className: className,
|
|
12
|
-
error: error,
|
|
13
|
-
children: /*#__PURE__*/ _jsx(RenderLexical, {
|
|
14
|
-
field: {
|
|
15
|
-
name: 'myCustomEditor',
|
|
16
|
-
label: false,
|
|
17
|
-
type: 'richText'
|
|
18
|
-
},
|
|
19
|
-
schemaPath: "global.intl-plugin.editorTemplate",
|
|
20
|
-
setValue: (val)=>editor.setValue(val),
|
|
21
|
-
value: editor.value
|
|
22
|
-
})
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
//# sourceMappingURL=LexicalInput.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/inputs/LexicalInput.tsx"],"sourcesContent":["import { RenderLexical } from '@payloadcms/richtext-lexical/client';\nimport type { SerializedEditorState } from '@payloadcms/richtext-lexical/lexical';\nimport { useHtmlLexicalAdapter } from '../hooks/useHtmlLexicalAdapter';\nimport type { FieldWrapperProps } from './FieldWrapper';\nimport { FieldWrapper } from './FieldWrapper';\n\nexport interface LexicalInputProps extends FieldWrapperProps {\n lang: string;\n value: string;\n onChange: (value: string) => void;\n onBlur: () => void;\n}\n\nexport function LexicalInput({\n error,\n value,\n onChange,\n className,\n}: LexicalInputProps): React.ReactNode {\n const editor = useHtmlLexicalAdapter({\n html: value,\n onChange,\n });\n\n return (\n <FieldWrapper className={className} error={error}>\n <RenderLexical\n field={{\n name: 'myCustomEditor',\n label: false,\n type: 'richText',\n }}\n schemaPath=\"global.intl-plugin.editorTemplate\"\n setValue={(val) => editor.setValue(val as SerializedEditorState)}\n value={editor.value}\n />\n </FieldWrapper>\n );\n}\n"],"names":["RenderLexical","useHtmlLexicalAdapter","FieldWrapper","LexicalInput","error","value","onChange","className","editor","html","field","name","label","type","schemaPath","setValue","val"],"mappings":";AAAA,SAASA,aAAa,QAAQ,sCAAsC;AAEpE,SAASC,qBAAqB,QAAQ,iCAAiC;AAEvE,SAASC,YAAY,QAAQ,iBAAiB;AAS9C,OAAO,SAASC,aAAa,EAC3BC,KAAK,EACLC,KAAK,EACLC,QAAQ,EACRC,SAAS,EACS;IAClB,MAAMC,SAASP,sBAAsB;QACnCQ,MAAMJ;QACNC;IACF;IAEA,qBACE,KAACJ;QAAaK,WAAWA;QAAWH,OAAOA;kBACzC,cAAA,KAACJ;YACCU,OAAO;gBACLC,MAAM;gBACNC,OAAO;gBACPC,MAAM;YACR;YACAC,YAAW;YACXC,UAAU,CAACC,MAAQR,OAAOO,QAAQ,CAACC;YACnCX,OAAOG,OAAOH,KAAK;;;AAI3B"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { TemplateVariable } from '../../types';
|
|
2
|
-
import type { FieldWrapperProps } from './FieldWrapper';
|
|
3
|
-
export interface MessageInputProps extends FieldWrapperProps {
|
|
4
|
-
value: string;
|
|
5
|
-
lang: string;
|
|
6
|
-
variables: TemplateVariable[];
|
|
7
|
-
onChange: (value: string) => void;
|
|
8
|
-
onBlur: () => void;
|
|
9
|
-
readOnly?: boolean;
|
|
10
|
-
multiline?: boolean;
|
|
11
|
-
reference?: string;
|
|
12
|
-
}
|
|
13
|
-
export declare function MessageInput({ value, lang, error, variables, onChange, onBlur, className, multiline, reference, }: MessageInputProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
-
//# sourceMappingURL=MessageInput.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MessageInput.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/MessageInput.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAShD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AA2BxD,MAAM,WAAW,iBAAkB,SAAQ,iBAAiB;IAC1D,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,gBAAgB,EAAE,CAAC;IAC9B,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,IAAI,EACJ,KAAK,EACL,SAAS,EACT,QAAQ,EACR,MAAM,EACN,SAAS,EACT,SAAS,EACT,SAAS,GACV,EAAE,iBAAiB,2CAkFnB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/inputs/MessageInput.tsx"],"sourcesContent":["'use client';\n\nimport type { EditorState } from '@payloadcms/richtext-lexical/lexical';\nimport { $getRoot } from '@payloadcms/richtext-lexical/lexical';\nimport { LexicalComposer } from '@payloadcms/richtext-lexical/lexical/react/LexicalComposer';\nimport { useLexicalComposerContext } from '@payloadcms/richtext-lexical/lexical/react/LexicalComposerContext';\nimport { ContentEditable } from '@payloadcms/richtext-lexical/lexical/react/LexicalContentEditable';\nimport { LexicalErrorBoundary } from '@payloadcms/richtext-lexical/lexical/react/LexicalErrorBoundary';\nimport { HistoryPlugin } from '@payloadcms/richtext-lexical/lexical/react/LexicalHistoryPlugin';\nimport { OnChangePlugin } from '@payloadcms/richtext-lexical/lexical/react/LexicalOnChangePlugin';\nimport { PlainTextPlugin } from '@payloadcms/richtext-lexical/lexical/react/LexicalPlainTextPlugin';\nimport clsx from 'clsx';\nimport {\n BeautifulMentionNode,\n BeautifulMentionsPlugin,\n} from 'lexical-beautiful-mentions';\nimport { useCallback, useEffect, useMemo } from 'react';\nimport type { TemplateVariable } from '@/types';\n\nimport { formatVariableLabel } from '@/utils/format';\nimport { isTagElement } from '@/utils/guards';\nimport {\n parseIcuToLexicalState,\n serializeICUMessage,\n} from '@/utils/icu-tranform';\n\nimport type { FieldWrapperProps } from './FieldWrapper';\nimport { FieldWrapper } from './FieldWrapper';\nimport styles from './MessageInput.module.css';\nimport { SingleLinePlugin } from './SingleLinePlugin';\nimport { VariableMentionNode } from './variables/VariableNode';\nimport { MentionMenu, MentionMenuItem } from './variables/VariableSuggestion';\n\nfunction SyncValuePlugin({ value }: { value: string }) {\n const [editor] = useLexicalComposerContext();\n\n useEffect(() => {\n const currentText = editor\n .getEditorState()\n .read(() => $getRoot().getTextContent());\n if (value !== currentText) {\n queueMicrotask(() => {\n const newState = editor.parseEditorState(\n JSON.stringify(parseIcuToLexicalState(value)),\n );\n editor.setEditorState(newState);\n });\n }\n }, [value, editor]);\n\n return null;\n}\n\nexport interface MessageInputProps extends FieldWrapperProps {\n value: string;\n lang: string;\n variables: TemplateVariable[];\n onChange: (value: string) => void;\n onBlur: () => void;\n readOnly?: boolean;\n multiline?: boolean;\n reference?: string;\n}\n\nexport function MessageInput({\n value,\n lang,\n error,\n variables,\n onChange,\n onBlur,\n className,\n multiline,\n reference,\n}: MessageInputProps) {\n const handleChange = useCallback(\n (editorState: EditorState) => {\n editorState.read(() => {\n onChange($getRoot().getTextContent());\n });\n },\n [onChange],\n );\n\n const mentionItems = useMemo(() => {\n const toItem = (v: TemplateVariable) => ({\n value: v.value,\n label: formatVariableLabel(v),\n icu: serializeICUMessage([v]),\n });\n\n return {\n '@': variables.map(toItem),\n '{': variables.filter((v) => !isTagElement(v)).map(toItem),\n '<': variables.filter((v) => isTagElement(v)).map(toItem),\n };\n }, [variables]);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: LexicalComposer only reads initialConfig on mount\n const initialConfig = useMemo(\n () => ({\n namespace: 'ICUMessageEditor',\n nodes: [\n VariableMentionNode,\n {\n replace: BeautifulMentionNode,\n with: (node: BeautifulMentionNode) =>\n new VariableMentionNode(\n node.getTrigger(),\n node.getValue(),\n node.getData(),\n ),\n withKlass: VariableMentionNode,\n },\n ],\n editorState: JSON.stringify(parseIcuToLexicalState(value)),\n editable: true,\n onError: console.error,\n }),\n [],\n );\n\n return (\n <FieldWrapper className={className} error={error} reference={reference}>\n <LexicalComposer initialConfig={initialConfig}>\n <div\n className={clsx(styles.editor, multiline && styles.multiline)}\n lang={lang}\n >\n <PlainTextPlugin\n contentEditable={\n <ContentEditable\n className={clsx(\n styles.contentEditable,\n error && styles.contentEditableError,\n )}\n onBlur={onBlur}\n />\n }\n ErrorBoundary={LexicalErrorBoundary}\n />\n {multiline && <SingleLinePlugin />}\n <SyncValuePlugin value={value} />\n <OnChangePlugin onChange={handleChange} />\n <HistoryPlugin />\n\n <BeautifulMentionsPlugin\n items={mentionItems}\n menuAnchorClassName={styles.menuAnchor}\n menuComponent={MentionMenu}\n menuItemComponent={MentionMenuItem}\n />\n </div>\n </LexicalComposer>\n </FieldWrapper>\n );\n}\n"],"names":["$getRoot","LexicalComposer","useLexicalComposerContext","ContentEditable","LexicalErrorBoundary","HistoryPlugin","OnChangePlugin","PlainTextPlugin","clsx","BeautifulMentionNode","BeautifulMentionsPlugin","useCallback","useEffect","useMemo","formatVariableLabel","isTagElement","parseIcuToLexicalState","serializeICUMessage","FieldWrapper","styles","SingleLinePlugin","VariableMentionNode","MentionMenu","MentionMenuItem","SyncValuePlugin","value","editor","currentText","getEditorState","read","getTextContent","queueMicrotask","newState","parseEditorState","JSON","stringify","setEditorState","MessageInput","lang","error","variables","onChange","onBlur","className","multiline","reference","handleChange","editorState","mentionItems","toItem","v","label","icu","map","filter","initialConfig","namespace","nodes","replace","with","node","getTrigger","getValue","getData","withKlass","editable","onError","console","div","contentEditable","contentEditableError","ErrorBoundary","items","menuAnchorClassName","menuAnchor","menuComponent","menuItemComponent"],"mappings":"AAAA;;AAGA,SAASA,QAAQ,QAAQ,uCAAuC;AAChE,SAASC,eAAe,QAAQ,6DAA6D;AAC7F,SAASC,yBAAyB,QAAQ,oEAAoE;AAC9G,SAASC,eAAe,QAAQ,oEAAoE;AACpG,SAASC,oBAAoB,QAAQ,kEAAkE;AACvG,SAASC,aAAa,QAAQ,kEAAkE;AAChG,SAASC,cAAc,QAAQ,mEAAmE;AAClG,SAASC,eAAe,QAAQ,oEAAoE;AACpG,OAAOC,UAAU,OAAO;AACxB,SACEC,oBAAoB,EACpBC,uBAAuB,QAClB,6BAA6B;AACpC,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,QAAQ,QAAQ;AAGxD,SAASC,mBAAmB,QAAQ,iBAAiB;AACrD,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,SACEC,sBAAsB,EACtBC,mBAAmB,QACd,uBAAuB;AAG9B,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,OAAOC,YAAY,4BAA4B;AAC/C,SAASC,gBAAgB,QAAQ,qBAAqB;AACtD,SAASC,mBAAmB,QAAQ,2BAA2B;AAC/D,SAASC,WAAW,EAAEC,eAAe,QAAQ,iCAAiC;AAE9E,SAASC,gBAAgB,EAAEC,KAAK,EAAqB;IACnD,MAAM,CAACC,OAAO,GAAGxB;IAEjBU,UAAU;QACR,MAAMe,cAAcD,OACjBE,cAAc,GACdC,IAAI,CAAC,IAAM7B,WAAW8B,cAAc;QACvC,IAAIL,UAAUE,aAAa;YACzBI,eAAe;gBACb,MAAMC,WAAWN,OAAOO,gBAAgB,CACtCC,KAAKC,SAAS,CAACnB,uBAAuBS;gBAExCC,OAAOU,cAAc,CAACJ;YACxB;QACF;IACF,GAAG;QAACP;QAAOC;KAAO;IAElB,OAAO;AACT;AAaA,OAAO,SAASW,aAAa,EAC3BZ,KAAK,EACLa,IAAI,EACJC,KAAK,EACLC,SAAS,EACTC,QAAQ,EACRC,MAAM,EACNC,SAAS,EACTC,SAAS,EACTC,SAAS,EACS;IAClB,MAAMC,eAAenC,YACnB,CAACoC;QACCA,YAAYlB,IAAI,CAAC;YACfY,SAASzC,WAAW8B,cAAc;QACpC;IACF,GACA;QAACW;KAAS;IAGZ,MAAMO,eAAenC,QAAQ;QAC3B,MAAMoC,SAAS,CAACC,IAAyB,CAAA;gBACvCzB,OAAOyB,EAAEzB,KAAK;gBACd0B,OAAOrC,oBAAoBoC;gBAC3BE,KAAKnC,oBAAoB;oBAACiC;iBAAE;YAC9B,CAAA;QAEA,OAAO;YACL,KAAKV,UAAUa,GAAG,CAACJ;YACnB,KAAKT,UAAUc,MAAM,CAAC,CAACJ,IAAM,CAACnC,aAAamC,IAAIG,GAAG,CAACJ;YACnD,KAAKT,UAAUc,MAAM,CAAC,CAACJ,IAAMnC,aAAamC,IAAIG,GAAG,CAACJ;QACpD;IACF,GAAG;QAACT;KAAU;IAEd,6GAA6G;IAC7G,MAAMe,gBAAgB1C,QACpB,IAAO,CAAA;YACL2C,WAAW;YACXC,OAAO;gBACLpC;gBACA;oBACEqC,SAASjD;oBACTkD,MAAM,CAACC,OACL,IAAIvC,oBACFuC,KAAKC,UAAU,IACfD,KAAKE,QAAQ,IACbF,KAAKG,OAAO;oBAEhBC,WAAW3C;gBACb;aACD;YACD0B,aAAab,KAAKC,SAAS,CAACnB,uBAAuBS;YACnDwC,UAAU;YACVC,SAASC,QAAQ5B,KAAK;QACxB,CAAA,GACA,EAAE;IAGJ,qBACE,KAACrB;QAAayB,WAAWA;QAAWJ,OAAOA;QAAOM,WAAWA;kBAC3D,cAAA,KAAC5C;YAAgBsD,eAAeA;sBAC9B,cAAA,MAACa;gBACCzB,WAAWnC,KAAKW,OAAOO,MAAM,EAAEkB,aAAazB,OAAOyB,SAAS;gBAC5DN,MAAMA;;kCAEN,KAAC/B;wBACC8D,+BACE,KAAClE;4BACCwC,WAAWnC,KACTW,OAAOkD,eAAe,EACtB9B,SAASpB,OAAOmD,oBAAoB;4BAEtC5B,QAAQA;;wBAGZ6B,eAAenE;;oBAEhBwC,2BAAa,KAACxB;kCACf,KAACI;wBAAgBC,OAAOA;;kCACxB,KAACnB;wBAAemC,UAAUK;;kCAC1B,KAACzC;kCAED,KAACK;wBACC8D,OAAOxB;wBACPyB,qBAAqBtD,OAAOuD,UAAU;wBACtCC,eAAerD;wBACfsD,mBAAmBrD;;;;;;AAM/B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReferencePopover.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/ReferencePopover.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAI1C,MAAM,WAAW,qBAAqB;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,YAAY,CAAC;CACxB;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,SAAS,EACT,QAAQ,GACT,EAAE,qBAAqB,2CAqBvB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/inputs/ReferencePopover.tsx"],"sourcesContent":["import { Popover } from '@base-ui/react/popover';\n\nimport { IconX } from '@tabler/icons-react';\nimport type { ReactElement } from 'react';\n\nimport styles from './ReferencePopover.module.css';\n\nexport interface ReferencePopoverProps {\n reference?: string;\n children: ReactElement;\n}\n\nexport function ReferencePopover({\n reference,\n children,\n}: ReferencePopoverProps) {\n if (!reference) return children;\n return (\n <Popover.Root>\n <Popover.Trigger nativeButton={false} render={children} />\n <Popover.Portal>\n <Popover.Positioner align=\"start\" side=\"top\" sideOffset={4}>\n <Popover.Popup\n className={styles.popup}\n initialFocus={false}\n onMouseDown={(e) => e.preventDefault()}\n >\n <Popover.Close className={styles.dismiss} type=\"button\">\n <IconX size={14} />\n </Popover.Close>\n <p className={styles.text}>{reference}</p>\n </Popover.Popup>\n </Popover.Positioner>\n </Popover.Portal>\n </Popover.Root>\n );\n}\n"],"names":["Popover","IconX","styles","ReferencePopover","reference","children","Root","Trigger","nativeButton","render","Portal","Positioner","align","side","sideOffset","Popup","className","popup","initialFocus","onMouseDown","e","preventDefault","Close","dismiss","type","size","p","text"],"mappings":";AAAA,SAASA,OAAO,QAAQ,yBAAyB;AAEjD,SAASC,KAAK,QAAQ,sBAAsB;AAG5C,OAAOC,YAAY,gCAAgC;AAOnD,OAAO,SAASC,iBAAiB,EAC/BC,SAAS,EACTC,QAAQ,EACc;IACtB,IAAI,CAACD,WAAW,OAAOC;IACvB,qBACE,MAACL,QAAQM,IAAI;;0BACX,KAACN,QAAQO,OAAO;gBAACC,cAAc;gBAAOC,QAAQJ;;0BAC9C,KAACL,QAAQU,MAAM;0BACb,cAAA,KAACV,QAAQW,UAAU;oBAACC,OAAM;oBAAQC,MAAK;oBAAMC,YAAY;8BACvD,cAAA,MAACd,QAAQe,KAAK;wBACZC,WAAWd,OAAOe,KAAK;wBACvBC,cAAc;wBACdC,aAAa,CAACC,IAAMA,EAAEC,cAAc;;0CAEpC,KAACrB,QAAQsB,KAAK;gCAACN,WAAWd,OAAOqB,OAAO;gCAAEC,MAAK;0CAC7C,cAAA,KAACvB;oCAAMwB,MAAM;;;0CAEf,KAACC;gCAAEV,WAAWd,OAAOyB,IAAI;0CAAGvB;;;;;;;;AAMxC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SingleLinePlugin.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/SingleLinePlugin.tsx"],"names":[],"mappings":"AASA,wBAAgB,gBAAgB,SA2B/B"}
|