@payload-enchants/translator 1.2.1 → 1.3.0-pre.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,5 @@
1
1
  import './styles.scss';
2
- import type { ReactNode } from 'react';
3
- export declare const CustomButtonWithTranslator: ({ defaultButton }: {
4
- defaultButton: ReactNode;
5
- }) => string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react").JSX.Element | null | undefined;
2
+ export declare const CustomButtonWithTranslator: ({ type }: {
3
+ type: "publish" | "save";
4
+ }) => import("react").JSX.Element;
6
5
  //# sourceMappingURL=CustomButtonWithTranslator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CustomButtonWithTranslator.d.ts","sourceRoot":"","sources":["../../../../src/client/components/CustomButton/CustomButtonWithTranslator.tsx"],"names":[],"mappings":"AAEA,OAAO,eAAe,CAAC;AAGvB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAOvC,eAAO,MAAM,0BAA0B,sBAAuB;IAAE,aAAa,EAAE,SAAS,CAAA;CAAE,gUAoBzF,CAAC"}
1
+ {"version":3,"file":"CustomButtonWithTranslator.d.ts","sourceRoot":"","sources":["../../../../src/client/components/CustomButton/CustomButtonWithTranslator.tsx"],"names":[],"mappings":"AAEA,OAAO,eAAe,CAAC;AAWvB,eAAO,MAAM,0BAA0B,aAAc;IAAE,IAAI,EAAE,SAAS,GAAG,MAAM,CAAA;CAAE,gCAsBhF,CAAC"}
@@ -5,11 +5,14 @@ import { useConfig, useDocumentInfo } from '@payloadcms/ui';
5
5
  import { TranslatorProvider } from '../../providers/Translator/TranslatorProvider';
6
6
  import { ResolverButton } from '../ResolverButton';
7
7
  import { TranslatorModal } from '../TranslatorModal';
8
- export const CustomButtonWithTranslator = ({ defaultButton })=>{
9
- const config = useConfig();
8
+ import { DefaultPublishButton } from '@payloadcms/ui';
9
+ import { DefaultSaveButton } from '@payloadcms/ui';
10
+ export const CustomButtonWithTranslator = ({ type })=>{
11
+ const { config } = useConfig();
12
+ const DefaultButton = type === 'publish' ? DefaultPublishButton : DefaultSaveButton;
10
13
  const { globalSlug, id } = useDocumentInfo();
11
14
  const resolvers = config.admin?.custom?.translator?.resolvers ?? [];
12
- if (!id && !globalSlug) return defaultButton;
15
+ if (!id && !globalSlug) return /*#__PURE__*/ _jsx(DefaultButton, {});
13
16
  return /*#__PURE__*/ _jsx(TranslatorProvider, {
14
17
  children: /*#__PURE__*/ _jsxs("div", {
15
18
  className: 'translator__custom-save-button',
@@ -18,7 +21,7 @@ export const CustomButtonWithTranslator = ({ defaultButton })=>{
18
21
  resolvers.map((resolver)=>/*#__PURE__*/ _jsx(ResolverButton, {
19
22
  resolver: resolver
20
23
  }, resolver.key)),
21
- defaultButton
24
+ /*#__PURE__*/ _jsx(DefaultButton, {})
22
25
  ]
23
26
  })
24
27
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/client/components/CustomButton/CustomButtonWithTranslator.tsx"],"sourcesContent":["'use client';\n\nimport './styles.scss';\n\nimport { useConfig, useDocumentInfo } from '@payloadcms/ui';\nimport type { ReactNode } from 'react';\n\nimport type { TranslateResolver } from '../../../resolvers/types';\nimport { TranslatorProvider } from '../../providers/Translator/TranslatorProvider';\nimport { ResolverButton } from '../ResolverButton';\nimport { TranslatorModal } from '../TranslatorModal';\n\nexport const CustomButtonWithTranslator = ({ defaultButton }: { defaultButton: ReactNode }) => {\n const config = useConfig();\n\n const { globalSlug, id } = useDocumentInfo();\n\n const resolvers = (config.admin?.custom?.translator?.resolvers as TranslateResolver[]) ?? [];\n\n if (!id && !globalSlug) return defaultButton;\n\n return (\n <TranslatorProvider>\n <div className={'translator__custom-save-button'}>\n <TranslatorModal />\n {resolvers.map((resolver) => (\n <ResolverButton key={resolver.key} resolver={resolver} />\n ))}\n {defaultButton}\n </div>\n </TranslatorProvider>\n );\n};\n"],"names":["useConfig","useDocumentInfo","TranslatorProvider","ResolverButton","TranslatorModal","CustomButtonWithTranslator","defaultButton","config","globalSlug","id","resolvers","admin","custom","translator","div","className","map","resolver","key"],"mappings":"AAAA;;AAEA,OAAO,gBAAgB;AAEvB,SAASA,SAAS,EAAEC,eAAe,QAAQ,iBAAiB;AAI5D,SAASC,kBAAkB,QAAQ,gDAAgD;AACnF,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,eAAe,QAAQ,qBAAqB;AAErD,OAAO,MAAMC,6BAA6B,CAAC,EAAEC,aAAa,EAAgC;IACxF,MAAMC,SAASP;IAEf,MAAM,EAAEQ,UAAU,EAAEC,EAAE,EAAE,GAAGR;IAE3B,MAAMS,YAAY,AAACH,OAAOI,KAAK,EAAEC,QAAQC,YAAYH,aAAqC,EAAE;IAE5F,IAAI,CAACD,MAAM,CAACD,YAAY,OAAOF;IAE/B,qBACE,KAACJ;kBACC,cAAA,MAACY;YAAIC,WAAW;;8BACd,KAACX;gBACAM,UAAUM,GAAG,CAAC,CAACC,yBACd,KAACd;wBAAkCc,UAAUA;uBAAxBA,SAASC,GAAG;gBAElCZ;;;;AAIT,EAAE"}
1
+ {"version":3,"sources":["../../../../src/client/components/CustomButton/CustomButtonWithTranslator.tsx"],"sourcesContent":["'use client';\n\nimport './styles.scss';\n\nimport { useConfig, useDocumentInfo } from '@payloadcms/ui';\n\nimport type { TranslateResolver } from '../../../resolvers/types';\nimport { TranslatorProvider } from '../../providers/Translator/TranslatorProvider';\nimport { ResolverButton } from '../ResolverButton';\nimport { TranslatorModal } from '../TranslatorModal';\nimport { DefaultPublishButton } from '@payloadcms/ui';\nimport { DefaultSaveButton } from '@payloadcms/ui';\n\nexport const CustomButtonWithTranslator = ({ type }: { type: 'publish' | 'save' }) => {\n const { config } = useConfig();\n\n const DefaultButton = type === 'publish' ? DefaultPublishButton : DefaultSaveButton;\n\n const { globalSlug, id } = useDocumentInfo();\n\n const resolvers = (config.admin?.custom?.translator?.resolvers as TranslateResolver[]) ?? [];\n\n if (!id && !globalSlug) return <DefaultButton />;\n\n return (\n <TranslatorProvider>\n <div className={'translator__custom-save-button'}>\n <TranslatorModal />\n {resolvers.map((resolver) => (\n <ResolverButton key={resolver.key} resolver={resolver} />\n ))}\n {<DefaultButton />}\n </div>\n </TranslatorProvider>\n );\n};\n"],"names":["useConfig","useDocumentInfo","TranslatorProvider","ResolverButton","TranslatorModal","DefaultPublishButton","DefaultSaveButton","CustomButtonWithTranslator","type","config","DefaultButton","globalSlug","id","resolvers","admin","custom","translator","div","className","map","resolver","key"],"mappings":"AAAA;;AAEA,OAAO,gBAAgB;AAEvB,SAASA,SAAS,EAAEC,eAAe,QAAQ,iBAAiB;AAG5D,SAASC,kBAAkB,QAAQ,gDAAgD;AACnF,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,eAAe,QAAQ,qBAAqB;AACrD,SAASC,oBAAoB,QAAQ,iBAAiB;AACtD,SAASC,iBAAiB,QAAQ,iBAAiB;AAEnD,OAAO,MAAMC,6BAA6B,CAAC,EAAEC,IAAI,EAAgC;IAC/E,MAAM,EAAEC,MAAM,EAAE,GAAGT;IAEnB,MAAMU,gBAAgBF,SAAS,YAAYH,uBAAuBC;IAElE,MAAM,EAAEK,UAAU,EAAEC,EAAE,EAAE,GAAGX;IAE3B,MAAMY,YAAY,AAACJ,OAAOK,KAAK,EAAEC,QAAQC,YAAYH,aAAqC,EAAE;IAE5F,IAAI,CAACD,MAAM,CAACD,YAAY,qBAAO,KAACD;IAEhC,qBACE,KAACR;kBACC,cAAA,MAACe;YAAIC,WAAW;;8BACd,KAACd;gBACAS,UAAUM,GAAG,CAAC,CAACC,yBACd,KAACjB;wBAAkCiB,UAAUA;uBAAxBA,SAASC,GAAG;8BAElC,KAACX;;;;AAIV,EAAE"}
@@ -1,2 +1,3 @@
1
- export declare const CustomButton: (type: "publish" | "save") => () => import("react").JSX.Element;
1
+ import { CustomPublishButton, CustomSaveButton } from 'payload';
2
+ export declare const CustomButton: (type: "publish" | "save") => CustomSaveButton | CustomPublishButton;
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/client/components/CustomButton/index.tsx"],"names":[],"mappings":"AAIA,eAAO,MAAM,YAAY,SAAU,SAAS,GAAG,MAAM,sCAMpD,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/client/components/CustomButton/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhE,eAAO,MAAM,YAAY,SAAU,SAAS,GAAG,MAAM,KAAG,gBAAgB,GAAG,mBAO1E,CAAC"}
@@ -1,12 +1,9 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { DefaultPublishButton, DefaultSaveButton } from '@payloadcms/ui';
3
- import { CustomButtonWithTranslator } from './CustomButtonWithTranslator';
4
1
  export const CustomButton = (type)=>{
5
- return ()=>{
6
- const defaultButton = type === 'publish' ? /*#__PURE__*/ _jsx(DefaultPublishButton, {}) : /*#__PURE__*/ _jsx(DefaultSaveButton, {});
7
- return /*#__PURE__*/ _jsx(CustomButtonWithTranslator, {
8
- defaultButton: defaultButton
9
- });
2
+ return {
3
+ path: `@payload-enchants/translator/client#CustomButtonWithTranslator`,
4
+ clientProps: {
5
+ type
6
+ }
10
7
  };
11
8
  };
12
9
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/client/components/CustomButton/index.tsx"],"sourcesContent":["import { DefaultPublishButton, DefaultSaveButton } from '@payloadcms/ui';\n\nimport { CustomButtonWithTranslator } from './CustomButtonWithTranslator';\n\nexport const CustomButton = (type: 'publish' | 'save') => {\n return () => {\n const defaultButton = type === 'publish' ? <DefaultPublishButton /> : <DefaultSaveButton />;\n\n return <CustomButtonWithTranslator defaultButton={defaultButton} />;\n };\n};\n"],"names":["DefaultPublishButton","DefaultSaveButton","CustomButtonWithTranslator","CustomButton","type","defaultButton"],"mappings":";AAAA,SAASA,oBAAoB,EAAEC,iBAAiB,QAAQ,iBAAiB;AAEzE,SAASC,0BAA0B,QAAQ,+BAA+B;AAE1E,OAAO,MAAMC,eAAe,CAACC;IAC3B,OAAO;QACL,MAAMC,gBAAgBD,SAAS,0BAAY,KAACJ,0CAA0B,KAACC;QAEvE,qBAAO,KAACC;YAA2BG,eAAeA;;IACpD;AACF,EAAE"}
1
+ {"version":3,"sources":["../../../../src/client/components/CustomButton/index.tsx"],"sourcesContent":["import { CustomPublishButton, CustomSaveButton } from 'payload';\n\nexport const CustomButton = (type: 'publish' | 'save'): CustomSaveButton | CustomPublishButton => {\n return {\n path: `@payload-enchants/translator/client#CustomButtonWithTranslator`,\n clientProps: {\n type,\n },\n };\n};\n"],"names":["CustomButton","type","path","clientProps"],"mappings":"AAEA,OAAO,MAAMA,eAAe,CAACC;IAC3B,OAAO;QACLC,MAAM,CAAC,8DAA8D,CAAC;QACtEC,aAAa;YACXF;QACF;IACF;AACF,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"file":"TranslatorProvider.d.ts","sourceRoot":"","sources":["../../../../src/client/providers/Translator/TranslatorProvider.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAE,KAAK,SAAS,EAAgC,MAAM,OAAO,CAAC;AASrE,eAAO,MAAM,kBAAkB,iBAAkB;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,gCAoIvE,CAAC"}
1
+ {"version":3,"file":"TranslatorProvider.d.ts","sourceRoot":"","sources":["../../../../src/client/providers/Translator/TranslatorProvider.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAE,KAAK,SAAS,EAAgC,MAAM,OAAO,CAAC;AASrE,eAAO,MAAM,kBAAkB,iBAAkB;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,gCAsIvE,CAAC"}
@@ -18,7 +18,7 @@ export const TranslatorProvider = ({ children })=>{
18
18
  return t(`plugin-translator:resolver_${resolver}_${key}`);
19
19
  };
20
20
  const locale = useLocale();
21
- const { admin: { custom }, localization, routes: { api }, serverURL } = useConfig();
21
+ const { config: { admin: { custom }, localization, routes: { api }, serverURL } } = useConfig();
22
22
  const apiClient = createClient({
23
23
  api,
24
24
  serverURL
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/client/providers/Translator/TranslatorProvider.tsx"],"sourcesContent":["import {\n toast,\n useAllFormFields,\n useConfig,\n useDocumentInfo,\n useForm,\n useLocale,\n useModal,\n useTranslation,\n} from '@payloadcms/ui';\nimport { getFormState } from '@payloadcms/ui/shared';\nimport { reduceFieldsToValues } from 'payload/shared';\nimport { type ReactNode, useEffect, useMemo, useState } from 'react';\n\nimport type { TranslateResolver } from '../../../resolvers/types';\nimport type { TranslateArgs } from '../../../translate/types';\nimport { createClient } from '../../api';\nimport { TranslatorContext } from './context';\n\nconst modalSlug = 'translator-modal';\n\nexport const TranslatorProvider = ({ children }: { children: ReactNode }) => {\n const [resolver, setResolver] = useState<null | string>(null);\n\n const [data, dispatch] = useAllFormFields();\n\n const { collectionSlug, globalSlug, id } = useDocumentInfo();\n\n const { setModified } = useForm();\n\n const modal = useModal();\n\n const { t } = useTranslation();\n\n const resolverT = (\n key:\n | 'buttonLabel'\n | 'errorMessage'\n | 'modalTitle'\n | 'submitButtonLabelEmpty'\n | 'submitButtonLabelFull'\n | 'successMessage',\n ) => {\n if (!resolver) return '';\n\n return t(`plugin-translator:resolver_${resolver}_${key}` as Parameters<typeof t>[0]);\n };\n\n const locale = useLocale();\n\n const {\n admin: { custom },\n localization,\n routes: { api },\n serverURL,\n } = useConfig();\n\n const apiClient = createClient({ api, serverURL });\n\n const resolverConfig = useMemo(() => {\n if (!resolver) return null;\n\n const resolvers = (custom?.translator?.resolvers as TranslateResolver[]) || undefined;\n\n if (!resolvers) return null;\n\n const resolverConfig = resolvers.find((each) => each.key === resolver);\n\n return resolverConfig ?? null;\n }, [custom, resolver]);\n\n if (!localization)\n throw new Error('Localization config is not provided and PluginTranslator is used');\n\n const localesOptions = localization.locales.filter((each) => each.code !== locale.code);\n\n const [localeToTranslateFrom, setLocaleToTranslateFrom] = useState<string>('');\n\n useEffect(() => {\n const defaultFromOptions = localesOptions.find(\n (each) => localization.defaultLocale === each.code,\n );\n\n if (defaultFromOptions) setLocaleToTranslateFrom(defaultFromOptions.code);\n setLocaleToTranslateFrom(localesOptions[0].code);\n }, [locale]);\n\n const closeTranslator = () => modal.closeModal(modalSlug);\n\n const submit = async ({ emptyOnly }: { emptyOnly: boolean }) => {\n if (!resolver) return;\n\n const args: TranslateArgs = {\n collectionSlug,\n data: reduceFieldsToValues(data, true),\n emptyOnly,\n globalSlug,\n id: id === null ? undefined : id,\n locale: locale.code,\n localeFrom: localeToTranslateFrom,\n resolver,\n };\n\n const result = await apiClient.translate(args);\n\n if (!result.success) {\n toast.error(resolverT('errorMessage'));\n\n return;\n }\n\n dispatch({\n state: await getFormState({\n apiRoute: api,\n body: {\n collectionSlug,\n data: result.translatedData,\n globalSlug,\n locale: locale.code,\n schemaPath: collectionSlug || globalSlug || '',\n },\n serverURL,\n }),\n type: 'REPLACE_STATE',\n });\n\n if (resolverConfig) {\n setModified(true);\n toast.success(resolverT('successMessage'));\n }\n closeTranslator();\n };\n\n return (\n <TranslatorContext.Provider\n value={{\n closeTranslator,\n localeToTranslateFrom,\n localesOptions,\n modalSlug,\n openTranslator: ({ resolverKey }) => {\n setResolver(resolverKey);\n modal.openModal(modalSlug);\n },\n resolver: resolverConfig,\n resolverT,\n setLocaleToTranslateFrom,\n submit,\n }}\n >\n {children}\n </TranslatorContext.Provider>\n );\n};\n"],"names":["toast","useAllFormFields","useConfig","useDocumentInfo","useForm","useLocale","useModal","useTranslation","getFormState","reduceFieldsToValues","useEffect","useMemo","useState","createClient","TranslatorContext","modalSlug","TranslatorProvider","children","resolver","setResolver","data","dispatch","collectionSlug","globalSlug","id","setModified","modal","t","resolverT","key","locale","admin","custom","localization","routes","api","serverURL","apiClient","resolverConfig","resolvers","translator","undefined","find","each","Error","localesOptions","locales","filter","code","localeToTranslateFrom","setLocaleToTranslateFrom","defaultFromOptions","defaultLocale","closeTranslator","closeModal","submit","emptyOnly","args","localeFrom","result","translate","success","error","state","apiRoute","body","translatedData","schemaPath","type","Provider","value","openTranslator","resolverKey","openModal"],"mappings":";AAAA,SACEA,KAAK,EACLC,gBAAgB,EAChBC,SAAS,EACTC,eAAe,EACfC,OAAO,EACPC,SAAS,EACTC,QAAQ,EACRC,cAAc,QACT,iBAAiB;AACxB,SAASC,YAAY,QAAQ,wBAAwB;AACrD,SAASC,oBAAoB,QAAQ,iBAAiB;AACtD,SAAyBC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AAIrE,SAASC,YAAY,QAAQ,YAAY;AACzC,SAASC,iBAAiB,QAAQ,YAAY;AAE9C,MAAMC,YAAY;AAElB,OAAO,MAAMC,qBAAqB,CAAC,EAAEC,QAAQ,EAA2B;IACtE,MAAM,CAACC,UAAUC,YAAY,GAAGP,SAAwB;IAExD,MAAM,CAACQ,MAAMC,SAAS,GAAGpB;IAEzB,MAAM,EAAEqB,cAAc,EAAEC,UAAU,EAAEC,EAAE,EAAE,GAAGrB;IAE3C,MAAM,EAAEsB,WAAW,EAAE,GAAGrB;IAExB,MAAMsB,QAAQpB;IAEd,MAAM,EAAEqB,CAAC,EAAE,GAAGpB;IAEd,MAAMqB,YAAY,CAChBC;QAQA,IAAI,CAACX,UAAU,OAAO;QAEtB,OAAOS,EAAE,CAAC,2BAA2B,EAAET,SAAS,CAAC,EAAEW,IAAI,CAAC;IAC1D;IAEA,MAAMC,SAASzB;IAEf,MAAM,EACJ0B,OAAO,EAAEC,MAAM,EAAE,EACjBC,YAAY,EACZC,QAAQ,EAAEC,GAAG,EAAE,EACfC,SAAS,EACV,GAAGlC;IAEJ,MAAMmC,YAAYxB,aAAa;QAAEsB;QAAKC;IAAU;IAEhD,MAAME,iBAAiB3B,QAAQ;QAC7B,IAAI,CAACO,UAAU,OAAO;QAEtB,MAAMq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AkBC,cAAc;gBAC9C;gBACAa;YACF;YACAgC,MAAM;QACR;QAEA,IAAI9B,gBAAgB;YAClBb,YAAY;YACZzB,MAAM6D,OAAO,CAACjC,UAAU;QAC1B;QACAyB;IACF;IAEA,qBACE,KAACvC,kBAAkBuD,QAAQ;QACzBC,OAAO;YACLjB;YACAJ;YACAJ;YACA9B;YACAwD,gBAAgB,CAAC,EAAEC,WAAW,EAAE;gBAC9BrD,YAAYqD;gBACZ9C,MAAM+C,SAAS,CAAC1D;YAClB;YACAG,UAAUoB;YACVV;YACAsB;YACAK;QACF;kBAECtC;;AAGP,EAAE"}
1
+ {"version":3,"sources":["../../../../src/client/providers/Translator/TranslatorProvider.tsx"],"sourcesContent":["import {\n toast,\n useAllFormFields,\n useConfig,\n useDocumentInfo,\n useForm,\n useLocale,\n useModal,\n useTranslation,\n} from '@payloadcms/ui';\nimport { getFormState } from '@payloadcms/ui/shared';\nimport { reduceFieldsToValues } from 'payload/shared';\nimport { type ReactNode, useEffect, useMemo, useState } from 'react';\n\nimport type { TranslateResolver } from '../../../resolvers/types';\nimport type { TranslateArgs } from '../../../translate/types';\nimport { createClient } from '../../api';\nimport { TranslatorContext } from './context';\n\nconst modalSlug = 'translator-modal';\n\nexport const TranslatorProvider = ({ children }: { children: ReactNode }) => {\n const [resolver, setResolver] = useState<null | string>(null);\n\n const [data, dispatch] = useAllFormFields();\n\n const { collectionSlug, globalSlug, id } = useDocumentInfo();\n\n const { setModified } = useForm();\n\n const modal = useModal();\n\n const { t } = useTranslation();\n\n const resolverT = (\n key:\n | 'buttonLabel'\n | 'errorMessage'\n | 'modalTitle'\n | 'submitButtonLabelEmpty'\n | 'submitButtonLabelFull'\n | 'successMessage',\n ) => {\n if (!resolver) return '';\n\n return t(`plugin-translator:resolver_${resolver}_${key}` as Parameters<typeof t>[0]);\n };\n\n const locale = useLocale();\n\n const {\n config: {\n admin: { custom },\n localization,\n routes: { api },\n serverURL,\n },\n } = useConfig();\n\n const apiClient = createClient({ api, serverURL });\n\n const resolverConfig = useMemo(() => {\n if (!resolver) return null;\n\n const resolvers = (custom?.translator?.resolvers as TranslateResolver[]) || undefined;\n\n if (!resolvers) return null;\n\n const resolverConfig = resolvers.find((each) => each.key === resolver);\n\n return resolverConfig ?? null;\n }, [custom, resolver]);\n\n if (!localization)\n throw new Error('Localization config is not provided and PluginTranslator is used');\n\n const localesOptions = localization.locales.filter((each) => each.code !== locale.code);\n\n const [localeToTranslateFrom, setLocaleToTranslateFrom] = useState<string>('');\n\n useEffect(() => {\n const defaultFromOptions = localesOptions.find(\n (each) => localization.defaultLocale === each.code,\n );\n\n if (defaultFromOptions) setLocaleToTranslateFrom(defaultFromOptions.code);\n setLocaleToTranslateFrom(localesOptions[0].code);\n }, [locale]);\n\n const closeTranslator = () => modal.closeModal(modalSlug);\n\n const submit = async ({ emptyOnly }: { emptyOnly: boolean }) => {\n if (!resolver) return;\n\n const args: TranslateArgs = {\n collectionSlug,\n data: reduceFieldsToValues(data, true),\n emptyOnly,\n globalSlug,\n id: id === null ? undefined : id,\n locale: locale.code,\n localeFrom: localeToTranslateFrom,\n resolver,\n };\n\n const result = await apiClient.translate(args);\n\n if (!result.success) {\n toast.error(resolverT('errorMessage'));\n\n return;\n }\n\n dispatch({\n state: await getFormState({\n apiRoute: api,\n body: {\n collectionSlug,\n data: result.translatedData,\n globalSlug,\n locale: locale.code,\n schemaPath: collectionSlug || globalSlug || '',\n },\n serverURL,\n }),\n type: 'REPLACE_STATE',\n });\n\n if (resolverConfig) {\n setModified(true);\n toast.success(resolverT('successMessage'));\n }\n closeTranslator();\n };\n\n return (\n <TranslatorContext.Provider\n value={{\n closeTranslator,\n localeToTranslateFrom,\n localesOptions,\n modalSlug,\n openTranslator: ({ resolverKey }) => {\n setResolver(resolverKey);\n modal.openModal(modalSlug);\n },\n resolver: resolverConfig,\n resolverT,\n setLocaleToTranslateFrom,\n submit,\n }}\n >\n {children}\n </TranslatorContext.Provider>\n );\n};\n"],"names":["toast","useAllFormFields","useConfig","useDocumentInfo","useForm","useLocale","useModal","useTranslation","getFormState","reduceFieldsToValues","useEffect","useMemo","useState","createClient","TranslatorContext","modalSlug","TranslatorProvider","children","resolver","setResolver","data","dispatch","collectionSlug","globalSlug","id","setModified","modal","t","resolverT","key","locale","config","admin","custom","localization","routes","api","serverURL","apiClient","resolverConfig","resolvers","translator","undefined","find","each","Error","localesOptions","locales","filter","code","localeToTranslateFrom","setLocaleToTranslateFrom","defaultFromOptions","defaultLocale","closeTranslator","closeModal","submit","emptyOnly","args","localeFrom","result","translate","success","error","state","apiRoute","body","translatedData","schemaPath","type","Provider","value","openTranslator","resolverKey","openModal"],"mappings":";AAAA,SACEA,KAAK,EACLC,gBAAgB,EAChBC,SAAS,EACTC,eAAe,EACfC,OAAO,EACPC,SAAS,EACTC,QAAQ,EACRC,cAAc,QACT,iBAAiB;AACxB,SAASC,YAAY,QAAQ,wBAAwB;AACrD,SAASC,oBAAoB,QAAQ,iBAAiB;AACtD,SAAyBC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AAIrE,SAASC,YAAY,QAAQ,YAAY;AACzC,SAASC,iBAAiB,QAAQ,YAAY;AAE9C,MAAMC,YAAY;AAElB,OAAO,MAAMC,qBAAqB,CAAC,EAAEC,QAAQ,EAA2B;IACtE,MAAM,CAACC,UAAUC,YAAY,GAAGP,SAAwB;IAExD,MAAM,CAACQ,MAAMC,SAAS,GAAGpB;IAEzB,MAAM,EAAEqB,cAAc,EAAEC,UAAU,EAAEC,EAAE,EAAE,GAAGrB;IAE3C,MAAM,EAAEsB,WAAW,EAAE,GAAGrB;IAExB,MAAMsB,QAAQpB;IAEd,MAAM,EAAEqB,CAAC,EAAE,GAAGpB;IAEd,MAAMqB,YAAY,CAChBC;QAQA,IAAI,CAACX,UAAU,OAAO;QAEtB,OAAOS,EAAE,CAAC,2BAA2B,EAAET,SAAS,CAAC,EAAEW,IAAI,CAAC;IAC1D;IAEA,MAAMC,SAASzB;IAEf,MAA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IAAI,CAACE,OAAOE,OAAO,EAAE;YACnB9D,MAAM+D,KAAK,CAACnC,UAAU;YAEtB;QACF;QAEAP,SAAS;YACP2C,OAAO,MAAMxD,aAAa;gBACxByD,UAAU7B;gBACV8B,MAAM;oBACJ5C;oBACAF,MAAMwC,OAAOO,cAAc;oBAC3B5C;oBACAO,QAAQA,OAAOmB,IAAI;oBACnBmB,YAAY9C,kBAAkBC,cAAc;gBAC9C;gBACAc;YACF;YACAgC,MAAM;QACR;QAEA,IAAI9B,gBAAgB;YAClBd,YAAY;YACZzB,MAAM8D,OAAO,CAAClC,UAAU;QAC1B;QACA0B;IACF;IAEA,qBACE,KAACxC,kBAAkBwD,QAAQ;QACzBC,OAAO;YACLjB;YACAJ;YACAJ;YACA/B;YACAyD,gBAAgB,CAAC,EAAEC,WAAW,EAAE;gBAC9BtD,YAAYsD;gBACZ/C,MAAMgD,SAAS,CAAC3D;YAClB;YACAG,UAAUqB;YACVX;YACAuB;YACAK;QACF;kBAECvC;;AAGP,EAAE"}
@@ -0,0 +1,2 @@
1
+ export { CustomButtonWithTranslator } from '../client/components/CustomButton/CustomButtonWithTranslator';
2
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/exports/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,8DAA8D,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { CustomButtonWithTranslator } from '../client/components/CustomButton/CustomButtonWithTranslator';
2
+
3
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["export { CustomButtonWithTranslator } from '../client/components/CustomButton/CustomButtonWithTranslator';\n"],"names":["CustomButtonWithTranslator"],"mappings":"AAAA,SAASA,0BAA0B,QAAQ,+DAA+D"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAMtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAE9B,eAAO,MAAM,UAAU,EAAE,CAAC,YAAY,EAAE,gBAAgB,KAAK,MA4E5D,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAU,MAAM,EAAE,MAAM,SAAS,CAAC;AAM9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAE9B,eAAO,MAAM,UAAU,EAAE,CAAC,YAAY,EAAE,gBAAgB,KAAK,MA8E5D,CAAC"}
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ export { translateOperation };
7
7
  export const translator = (pluginConfig)=>{
8
8
  return (config)=>{
9
9
  if (pluginConfig.disabled || !config.localization || config.localization.locales.length < 2) return config;
10
- return {
10
+ const updatedConfig = {
11
11
  ...config,
12
12
  admin: {
13
13
  ...config.admin ?? {},
@@ -75,6 +75,7 @@ export const translator = (pluginConfig)=>{
75
75
  }
76
76
  }
77
77
  };
78
+ return updatedConfig;
78
79
  };
79
80
  };
80
81
 
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/* eslint-disable perfectionist/sort-named-exports */\nimport type { Plugin } from 'payload';\nimport { deepMerge } from 'payload/shared';\n\nimport { CustomButton } from './client/components/CustomButton';\nimport { translations } from './i18n-translations';\nimport { translateEndpoint } from './translate/endpoint';\nimport { translateOperation } from './translate/operation';\nimport type { TranslatorConfig } from './types';\n\nexport { translateOperation };\n\nexport const translator: (pluginConfig: TranslatorConfig) => Plugin = (pluginConfig) => {\n return (config) => {\n if (pluginConfig.disabled || !config.localization || config.localization.locales.length < 2)\n return config;\n\n return {\n ...config,\n admin: {\n ...(config.admin ?? {}),\n custom: {\n ...(config.admin?.custom ?? {}),\n translator: {\n resolvers: pluginConfig.resolvers.map(({ key }) => ({ key })),\n },\n },\n },\n collections:\n config.collections?.map((collection) => {\n if (!pluginConfig.collections.includes(collection.slug)) return collection;\n\n return {\n ...collection,\n admin: {\n ...(collection.admin ?? {}),\n components: {\n ...(collection.admin?.components ?? {}),\n edit: {\n ...(collection.admin?.components?.edit ?? {}),\n PublishButton: CustomButton('publish'),\n SaveButton: CustomButton('save'),\n },\n },\n },\n };\n }) ?? [],\n custom: {\n ...(config.custom ?? {}),\n translator: {\n resolvers: pluginConfig.resolvers,\n },\n },\n endpoints: [\n ...(config.endpoints ?? []),\n {\n handler: translateEndpoint,\n method: 'post',\n path: '/translator/translate',\n },\n ],\n globals:\n config.globals?.map((global) => {\n if (!pluginConfig.globals.includes(global.slug)) return global;\n\n return {\n ...global,\n admin: {\n ...(global.admin ?? {}),\n components: {\n ...(global.admin?.components ?? {}),\n elements: {\n ...(global.admin?.components?.elements ?? {}),\n PublishButton: CustomButton('publish'),\n SaveButton: CustomButton('save'),\n },\n },\n },\n };\n }) ?? [],\n i18n: {\n ...config.i18n,\n translations: {\n ...deepMerge(config.i18n?.translations ?? {}, translations),\n },\n },\n };\n };\n};\n"],"names":["deepMerge","CustomButton","translations","translateEndpoint","translateOperation","translator","pluginConfig","config","disabled","localization","locales","length","admin","custom","resolvers","map","key","collections","collection","includes","slug","components","edit","PublishButton","SaveButton","endpoints","handler","method","path","globals","global","elements","i18n"],"mappings":"AAAA,mDAAmD,GAEnD,SAASA,SAAS,QAAQ,iBAAiB;AAE3C,SAASC,YAAY,QAAQ,mCAAmC;AAChE,SAASC,YAAY,QAAQ,sBAAsB;AACnD,SAASC,iBAAiB,QAAQ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,EAAEd,IAAI,CAACe;gBACnB,IAAI,CAACxB,aAAauB,OAAO,CAACV,QAAQ,CAACW,OAAOV,IAAI,GAAG,OAAOU;gBAExD,OAAO;oBACL,GAAGA,MAAM;oBACTlB,OAAO;wBACL,GAAIkB,OAAOlB,KAAK,IAAI,CAAC,CAAC;wBACtBS,YAAY;4BACV,GAAIS,OAAOlB,KAAK,EAAES,cAAc,CAAC,CAAC;4BAClCU,UAAU;gCACR,GAAID,OAAOlB,KAAK,EAAES,YAAYU,YAAY,CAAC,CAAC;gCAC5CR,eAAetB,aAAa;gCAC5BuB,YAAYvB,aAAa;4BAC3B;wBACF;oBACF;gBACF;YACF,MAAM,EAAE;YACV+B,MAAM;gBACJ,GAAGzB,OAAOyB,IAAI;gBACd9B,cAAc;oBACZ,GAAGF,UAAUO,OAAOyB,IAAI,EAAE9B,gBAAgB,CAAC,GAAGA,aAAa;gBAC7D;YACF;QACF;IACF;AACF,EAAE"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/* eslint-disable perfectionist/sort-named-exports */\nimport type { Config, Plugin } from 'payload';\nimport { deepMerge } from 'payload/shared';\n\nimport { CustomButton } from './client/components/CustomButton';\nimport { translations } from './i18n-translations';\nimport { translateEndpoint } from './translate/endpoint';\nimport { translateOperation } from './translate/operation';\nimport type { TranslatorConfig } from './types';\n\nexport { translateOperation };\n\nexport const translator: (pluginConfig: TranslatorConfig) => Plugin = (pluginConfig) => {\n return (config) => {\n if (pluginConfig.disabled || !config.localization || config.localization.locales.length < 2)\n return config;\n\n const updatedConfig: Config = {\n ...config,\n admin: {\n ...(config.admin ?? {}),\n custom: {\n ...(config.admin?.custom ?? {}),\n translator: {\n resolvers: pluginConfig.resolvers.map(({ key }) => ({ key })),\n },\n },\n },\n collections:\n config.collections?.map((collection) => {\n if (!pluginConfig.collections.includes(collection.slug)) return collection;\n\n return {\n ...collection,\n admin: {\n ...(collection.admin ?? {}),\n components: {\n ...(collection.admin?.components ?? {}),\n edit: {\n ...(collection.admin?.components?.edit ?? {}),\n PublishButton: CustomButton('publish'),\n SaveButton: CustomButton('save'),\n },\n },\n },\n };\n }) ?? [],\n custom: {\n ...(config.custom ?? {}),\n translator: {\n resolvers: pluginConfig.resolvers,\n },\n },\n endpoints: [\n ...(config.endpoints ?? []),\n {\n handler: translateEndpoint,\n method: 'post',\n path: '/translator/translate',\n },\n ],\n globals:\n config.globals?.map((global) => {\n if (!pluginConfig.globals.includes(global.slug)) return global;\n\n return {\n ...global,\n admin: {\n ...(global.admin ?? {}),\n components: {\n ...(global.admin?.components ?? {}),\n elements: {\n ...(global.admin?.components?.elements ?? {}),\n PublishButton: CustomButton('publish'),\n SaveButton: CustomButton('save'),\n },\n },\n },\n };\n }) ?? [],\n i18n: {\n ...config.i18n,\n translations: {\n ...deepMerge(config.i18n?.translations ?? {}, translations),\n },\n },\n };\n\n return updatedConfig;\n };\n};\n"],"names":["deepMerge","CustomButton","translations","translateEndpoint","translateOperation","translator","pluginConfig","config","disabled","localization","locales","length","updatedConfig","admin","custom","resolvers","map","key","collections","collection","includes","slug","components","edit","PublishButton","SaveButton","endpoints","handler","method","path","globals","global","elements","i18n"],"mappings":"AAAA,mDAAmD,GAEnD,SAASA,SAAS,QAAQ,iBAAiB;AAE3C,SAASC,YAAY,QAAQ,mCAAmC;AAChE,SAASC,YAAY,QAAQ,sBAAsB;AACnD,SAASC,iBAAiB,QAAQ,uBAAuB;AACzD,SAASC,kBAAkB,QAAQ,wBAAwB;AAG3D,SAASA,kBAAkB,GAAG;AAE9B,OAAO,MAAMC,aAAyD,CAACC;IACrE,OAAO,CAACC;QACN,IAAID,aAAaE,QAAQ,IAAI,CAACD,OAAOE,YAAY,IAAIF,OAAOE,YAAY,CAACC,OAAO,CAACC,MAAM,GAAG,GACxF,OAAOJ;QAET,MAAMK,gBAAwB;YAC5B,GAAGL,MAAM;YACTM,OAAO;gBACL,GAAIN,OAAOM,KAAK,IAAI,CAAC,CAAC;gBACtBC,QAAQ;oBACN,GAA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gCAC5BwB,YAAYxB,aAAa;4BAC3B;wBACF;oBACF;gBACF;YACF,MAAM,EAAE;YACVgC,MAAM;gBACJ,GAAG1B,OAAO0B,IAAI;gBACd/B,cAAc;oBACZ,GAAGF,UAAUO,OAAO0B,IAAI,EAAE/B,gBAAgB,CAAC,GAAGA,aAAa;gBAC7D;YACF;QACF;QAEA,OAAOU;IACT;AACF,EAAE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payload-enchants/translator",
3
- "version": "1.2.1",
3
+ "version": "1.3.0-pre.0",
4
4
  "private": false,
5
5
  "bugs": "https://github.com/r1tsuu/payload-enchants/issues",
6
6
  "repository": "https://github.com/r1tsuu/payload-enchants",
@@ -37,6 +37,11 @@
37
37
  "import": "./dist/resolvers/openAI.js",
38
38
  "require": "./dist/resolvers/openAI.js",
39
39
  "types": "./dist/resolvers/openAI.d.ts"
40
+ },
41
+ "./client": {
42
+ "import": "./dist/exports/client.js",
43
+ "require": "./dist/exports/client.js",
44
+ "types": "./dist/exports/client.d.ts"
40
45
  }
41
46
  },
42
47
  "files": [
@@ -46,19 +51,19 @@
46
51
  "bson-objectid": "^2.0.4"
47
52
  },
48
53
  "devDependencies": {
49
- "@payloadcms/translations": "3.0.0-beta.61",
50
- "@payloadcms/ui": "3.0.0-beta.61",
54
+ "@payloadcms/translations": "3.0.0-beta.84",
55
+ "@payloadcms/ui": "3.0.0-beta.84",
51
56
  "@types/react": "npm:types-react@19.0.0-beta.2",
52
57
  "@types/react-dom": "npm:types-react-dom@19.0.0-beta.2",
53
- "payload": "3.0.0-beta.61",
54
- "react": "19.0.0-rc-f994737d14-20240522",
55
- "react-dom": "19.0.0-rc-f994737d14-20240522",
58
+ "payload": "3.0.0-beta.84",
59
+ "react": "19.0.0-rc-06d0b89e-20240801",
60
+ "react-dom": "19.0.0-rc-06d0b89e-20240801",
56
61
  "typescript": "^5.5.2"
57
62
  },
58
63
  "peerDependencies": {
59
- "@payloadcms/translations": "^3.0.0-beta.61",
60
- "@payloadcms/ui": "^3.0.0-beta.61",
61
- "payload": "^3.0.0-beta.61"
64
+ "@payloadcms/translations": "^3.0.0-beta.84",
65
+ "@payloadcms/ui": "^3.0.0-beta.84",
66
+ "payload": "^3.0.0-beta.84"
62
67
  },
63
68
  "publishConfig": {
64
69
  "registry": "https://registry.npmjs.org/"