@payloadcms/plugin-seo 3.0.0-canary.ff8c8fd → 3.0.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.
Files changed (102) hide show
  1. package/dist/fields/MetaDescription/MetaDescriptionComponent.d.ts +2 -2
  2. package/dist/fields/MetaDescription/MetaDescriptionComponent.d.ts.map +1 -1
  3. package/dist/fields/MetaDescription/MetaDescriptionComponent.js +36 -23
  4. package/dist/fields/MetaDescription/MetaDescriptionComponent.js.map +1 -1
  5. package/dist/fields/MetaImage/MetaImageComponent.d.ts +2 -2
  6. package/dist/fields/MetaImage/MetaImageComponent.d.ts.map +1 -1
  7. package/dist/fields/MetaImage/MetaImageComponent.js +42 -25
  8. package/dist/fields/MetaImage/MetaImageComponent.js.map +1 -1
  9. package/dist/fields/MetaTitle/MetaTitleComponent.d.ts +2 -2
  10. package/dist/fields/MetaTitle/MetaTitleComponent.d.ts.map +1 -1
  11. package/dist/fields/MetaTitle/MetaTitleComponent.js +35 -21
  12. package/dist/fields/MetaTitle/MetaTitleComponent.js.map +1 -1
  13. package/dist/fields/Overview/OverviewComponent.d.ts +8 -0
  14. package/dist/fields/Overview/OverviewComponent.d.ts.map +1 -1
  15. package/dist/fields/Overview/OverviewComponent.js +13 -7
  16. package/dist/fields/Overview/OverviewComponent.js.map +1 -1
  17. package/dist/fields/Overview/index.d.ts +8 -0
  18. package/dist/fields/Overview/index.d.ts.map +1 -1
  19. package/dist/fields/Overview/index.js +3 -1
  20. package/dist/fields/Overview/index.js.map +1 -1
  21. package/dist/fields/Preview/PreviewComponent.d.ts.map +1 -1
  22. package/dist/fields/Preview/PreviewComponent.js +14 -4
  23. package/dist/fields/Preview/PreviewComponent.js.map +1 -1
  24. package/dist/fields/index.scss +5 -3
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +49 -29
  27. package/dist/index.js.map +1 -1
  28. package/dist/translations/cs.d.ts +3 -0
  29. package/dist/translations/cs.d.ts.map +1 -0
  30. package/dist/translations/cs.js +25 -0
  31. package/dist/translations/cs.js.map +1 -0
  32. package/dist/translations/de.d.ts +3 -0
  33. package/dist/translations/de.d.ts.map +1 -0
  34. package/dist/translations/de.js +25 -0
  35. package/dist/translations/de.js.map +1 -0
  36. package/dist/translations/en.d.ts +3 -0
  37. package/dist/translations/en.d.ts.map +1 -0
  38. package/dist/translations/en.js +25 -0
  39. package/dist/translations/en.js.map +1 -0
  40. package/dist/translations/es.d.ts +3 -0
  41. package/dist/translations/es.d.ts.map +1 -0
  42. package/dist/translations/es.js +25 -0
  43. package/dist/translations/es.js.map +1 -0
  44. package/dist/translations/fa.d.ts +3 -0
  45. package/dist/translations/fa.d.ts.map +1 -0
  46. package/dist/translations/fa.js +25 -0
  47. package/dist/translations/fa.js.map +1 -0
  48. package/dist/translations/fr.d.ts +3 -0
  49. package/dist/translations/fr.d.ts.map +1 -0
  50. package/dist/translations/fr.js +25 -0
  51. package/dist/translations/fr.js.map +1 -0
  52. package/dist/translations/index.d.ts +15 -178
  53. package/dist/translations/index.d.ts.map +1 -1
  54. package/dist/translations/index.js +26 -176
  55. package/dist/translations/index.js.map +1 -1
  56. package/dist/translations/it.d.ts +3 -0
  57. package/dist/translations/it.d.ts.map +1 -0
  58. package/dist/translations/it.js +25 -0
  59. package/dist/translations/it.js.map +1 -0
  60. package/dist/translations/nb.d.ts +3 -0
  61. package/dist/translations/nb.d.ts.map +1 -0
  62. package/dist/translations/nb.js +25 -0
  63. package/dist/translations/nb.js.map +1 -0
  64. package/dist/translations/pl.d.ts +3 -0
  65. package/dist/translations/pl.d.ts.map +1 -0
  66. package/dist/translations/pl.js +25 -0
  67. package/dist/translations/pl.js.map +1 -0
  68. package/dist/translations/ru.d.ts +3 -0
  69. package/dist/translations/ru.d.ts.map +1 -0
  70. package/dist/translations/ru.js +25 -0
  71. package/dist/translations/ru.js.map +1 -0
  72. package/dist/translations/sv.d.ts +3 -0
  73. package/dist/translations/sv.d.ts.map +1 -0
  74. package/dist/translations/sv.js +25 -0
  75. package/dist/translations/sv.js.map +1 -0
  76. package/dist/translations/tr.d.ts +3 -0
  77. package/dist/translations/tr.d.ts.map +1 -0
  78. package/dist/translations/tr.js +25 -0
  79. package/dist/translations/tr.js.map +1 -0
  80. package/dist/translations/translation-schema.json +5 -1
  81. package/dist/translations/uk.d.ts +3 -0
  82. package/dist/translations/uk.d.ts.map +1 -0
  83. package/dist/translations/uk.js +25 -0
  84. package/dist/translations/uk.js.map +1 -0
  85. package/dist/translations/vi.d.ts +3 -0
  86. package/dist/translations/vi.d.ts.map +1 -0
  87. package/dist/translations/vi.js +25 -0
  88. package/dist/translations/vi.js.map +1 -0
  89. package/dist/types.d.ts +36 -8
  90. package/dist/types.d.ts.map +1 -1
  91. package/dist/types.js.map +1 -1
  92. package/dist/ui/LengthIndicator.js +1 -1
  93. package/dist/ui/LengthIndicator.js.map +1 -1
  94. package/license.md +22 -0
  95. package/package.json +24 -17
  96. package/dist/translations/en.json +0 -22
  97. package/dist/translations/es.json +0 -22
  98. package/dist/translations/fa.json +0 -22
  99. package/dist/translations/fr.json +0 -22
  100. package/dist/translations/pl.json +0 -22
  101. package/dist/translations/ru.json +0 -22
  102. package/dist/translations/uk.json +0 -22
@@ -1,8 +1,8 @@
1
- import type { TextareaFieldProps } from 'payload';
1
+ import type { TextareaFieldClientProps } from 'payload';
2
2
  import React from 'react';
3
3
  type MetaDescriptionProps = {
4
4
  readonly hasGenerateDescriptionFn: boolean;
5
- } & TextareaFieldProps;
5
+ } & TextareaFieldClientProps;
6
6
  export declare const MetaDescriptionComponent: React.FC<MetaDescriptionProps>;
7
7
  export {};
8
8
  //# sourceMappingURL=MetaDescriptionComponent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MetaDescriptionComponent.d.ts","sourceRoot":"","sources":["../../../src/fields/MetaDescription/MetaDescriptionComponent.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAYjD,OAAO,KAAsB,MAAM,OAAO,CAAA;AAU1C,KAAK,oBAAoB,GAAG;IAC1B,QAAQ,CAAC,wBAAwB,EAAE,OAAO,CAAA;CAC3C,GAAG,kBAAkB,CAAA;AAEtB,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA4InE,CAAA"}
1
+ {"version":3,"file":"MetaDescriptionComponent.d.ts","sourceRoot":"","sources":["../../../src/fields/MetaDescription/MetaDescriptionComponent.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAavD,OAAO,KAAsB,MAAM,OAAO,CAAA;AAU1C,KAAK,oBAAoB,GAAG;IAC1B,QAAQ,CAAC,wBAAwB,EAAE,OAAO,CAAA;CAC3C,GAAG,wBAAwB,CAAA;AAE5B,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAgLnE,CAAA"}
@@ -1,33 +1,39 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { FieldLabel, TextareaInput, useDocumentInfo, useField, useFieldProps, useForm, useLocale, useTranslation } from '@payloadcms/ui';
3
+ import { FieldLabel, TextareaInput, useConfig, useDocumentInfo, useField, useForm, useLocale, useTranslation } from '@payloadcms/ui';
4
+ import { reduceToSerializableFields } from '@payloadcms/ui/shared';
4
5
  import React, { useCallback } from 'react';
5
6
  import { defaults } from '../../defaults.js';
6
7
  import { LengthIndicator } from '../../ui/LengthIndicator.js';
7
- const { maxLength, minLength } = defaults.description;
8
+ const { maxLength: maxLengthDefault, minLength: minLengthDefault } = defaults.description;
8
9
  export const MetaDescriptionComponent = (props)=>{
9
- const { field: { admin: { components: { Label } }, label, required }, hasGenerateDescriptionFn, labelProps } = props;
10
- const { path: pathFromContext } = useFieldProps();
10
+ const { field: { label, localized, maxLength: maxLengthFromProps, minLength: minLengthFromProps, required }, hasGenerateDescriptionFn, path } = props;
11
+ const { config: { routes: { api }, serverURL } } = useConfig();
11
12
  const { t } = useTranslation();
12
13
  const locale = useLocale();
13
14
  const { getData } = useForm();
14
15
  const docInfo = useDocumentInfo();
15
- const field = useField({
16
- path: pathFromContext
16
+ const maxLength = maxLengthFromProps || maxLengthDefault;
17
+ const minLength = minLengthFromProps || minLengthDefault;
18
+ const { customComponents: { AfterInput, BeforeInput, Label }, errorMessage, setValue, showError, value } = useField({
19
+ path
17
20
  });
18
- const { errorMessage, setValue, showError, value } = field;
19
21
  const regenerateDescription = useCallback(async ()=>{
20
- if (!hasGenerateDescriptionFn) return;
21
- const genDescriptionResponse = await fetch('/api/plugin-seo/generate-description', {
22
+ if (!hasGenerateDescriptionFn) {
23
+ return;
24
+ }
25
+ const endpoint = `${serverURL}${api}/plugin-seo/generate-description`;
26
+ const genDescriptionResponse = await fetch(endpoint, {
22
27
  body: JSON.stringify({
23
28
  id: docInfo.id,
24
- slug: docInfo.slug,
29
+ collectionSlug: docInfo.collectionSlug,
25
30
  doc: getData(),
26
31
  docPermissions: docInfo.docPermissions,
32
+ globalSlug: docInfo.globalSlug,
27
33
  hasPublishPermission: docInfo.hasPublishPermission,
28
34
  hasSavePermission: docInfo.hasSavePermission,
29
35
  initialData: docInfo.initialData,
30
- initialState: docInfo.initialState,
36
+ initialState: reduceToSerializableFields(docInfo.initialState),
31
37
  locale: typeof locale === 'object' ? locale?.code : locale,
32
38
  title: docInfo.title
33
39
  }),
@@ -41,7 +47,17 @@ export const MetaDescriptionComponent = (props)=>{
41
47
  setValue(generatedDescription || '');
42
48
  }, [
43
49
  hasGenerateDescriptionFn,
44
- docInfo,
50
+ serverURL,
51
+ api,
52
+ docInfo.id,
53
+ docInfo.collectionSlug,
54
+ docInfo.docPermissions,
55
+ docInfo.globalSlug,
56
+ docInfo.hasPublishPermission,
57
+ docInfo.hasSavePermission,
58
+ docInfo.initialData,
59
+ docInfo.initialState,
60
+ docInfo.title,
45
61
  getData,
46
62
  locale,
47
63
  setValue
@@ -60,11 +76,11 @@ export const MetaDescriptionComponent = (props)=>{
60
76
  /*#__PURE__*/ _jsxs("div", {
61
77
  className: "plugin-seo__field",
62
78
  children: [
63
- /*#__PURE__*/ _jsx(FieldLabel, {
64
- Label: Label,
65
- field: null,
79
+ Label ?? /*#__PURE__*/ _jsx(FieldLabel, {
66
80
  label: label,
67
- ...labelProps || {}
81
+ localized: localized,
82
+ path: path,
83
+ required: required
68
84
  }),
69
85
  hasGenerateDescriptionFn && /*#__PURE__*/ _jsxs(React.Fragment, {
70
86
  children: [
@@ -114,14 +130,11 @@ export const MetaDescriptionComponent = (props)=>{
114
130
  position: 'relative'
115
131
  },
116
132
  children: /*#__PURE__*/ _jsx(TextareaInput, {
117
- Error: {
118
- type: 'client',
119
- Component: null,
120
- RenderedComponent: errorMessage
121
- },
122
- label: label,
133
+ AfterInput: AfterInput,
134
+ BeforeInput: BeforeInput,
135
+ Error: errorMessage,
123
136
  onChange: setValue,
124
- path: pathFromContext,
137
+ path: path,
125
138
  required: required,
126
139
  showError: showError,
127
140
  style: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/MetaDescription/MetaDescriptionComponent.tsx"],"sourcesContent":["'use client'\n\nimport type { FieldType, Options } from '@payloadcms/ui'\nimport type { TextareaFieldProps } from 'payload'\n\nimport {\n FieldLabel,\n TextareaInput,\n useDocumentInfo,\n useField,\n useFieldProps,\n useForm,\n useLocale,\n useTranslation,\n} from '@payloadcms/ui'\nimport React, { useCallback } from 'react'\n\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations/index.js'\nimport type { GenerateDescription } from '../../types.js'\n\nimport { defaults } from '../../defaults.js'\nimport { LengthIndicator } from '../../ui/LengthIndicator.js'\n\nconst { maxLength, minLength } = defaults.description\n\ntype MetaDescriptionProps = {\n readonly hasGenerateDescriptionFn: boolean\n} & TextareaFieldProps\n\nexport const MetaDescriptionComponent: React.FC<MetaDescriptionProps> = (props) => {\n const {\n field: {\n admin: {\n components: { Label },\n },\n label,\n required,\n },\n hasGenerateDescriptionFn,\n labelProps,\n } = props\n const { path: pathFromContext } = useFieldProps()\n\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\n\n const locale = useLocale()\n const { getData } = useForm()\n const docInfo = useDocumentInfo()\n\n const field: FieldType<string> = useField({\n path: pathFromContext,\n } as Options)\n\n const { errorMessage, setValue, showError, value } = field\n\n const regenerateDescription = useCallback(async () => {\n if (!hasGenerateDescriptionFn) return\n\n const genDescriptionResponse = await fetch('/api/plugin-seo/generate-description', {\n body: JSON.stringify({\n id: docInfo.id,\n slug: docInfo.slug,\n doc: getData(),\n docPermissions: docInfo.docPermissions,\n hasPublishPermission: docInfo.hasPublishPermission,\n hasSavePermission: docInfo.hasSavePermission,\n initialData: docInfo.initialData,\n initialState: docInfo.initialState,\n locale: typeof locale === 'object' ? locale?.code : locale,\n title: docInfo.title,\n } satisfies Omit<Parameters<GenerateDescription>[0], 'req'>),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n const { result: generatedDescription } = await genDescriptionResponse.json()\n\n setValue(generatedDescription || '')\n }, [hasGenerateDescriptionFn, docInfo, getData, locale, setValue])\n\n return (\n <div\n style={{\n marginBottom: '20px',\n }}\n >\n <div\n style={{\n marginBottom: '5px',\n position: 'relative',\n }}\n >\n <div className=\"plugin-seo__field\">\n <FieldLabel Label={Label} field={null} label={label} {...(labelProps || {})} />\n {hasGenerateDescriptionFn && (\n <React.Fragment>\n &nbsp; &mdash; &nbsp;\n <button\n onClick={() => {\n void regenerateDescription()\n }}\n style={{\n background: 'none',\n backgroundColor: 'transparent',\n border: 'none',\n color: 'currentcolor',\n cursor: 'pointer',\n padding: 0,\n textDecoration: 'underline',\n }}\n type=\"button\"\n >\n {t('plugin-seo:autoGenerate')}\n </button>\n </React.Fragment>\n )}\n </div>\n <div\n style={{\n color: '#9A9A9A',\n }}\n >\n {t('plugin-seo:lengthTipDescription', { maxLength, minLength })}\n <a\n href=\"https://developers.google.com/search/docs/advanced/appearance/snippet#meta-descriptions\"\n rel=\"noopener noreferrer\"\n target=\"_blank\"\n >\n {t('plugin-seo:bestPractices')}\n </a>\n </div>\n </div>\n <div\n style={{\n marginBottom: '10px',\n position: 'relative',\n }}\n >\n <TextareaInput\n Error={{\n type: 'client',\n Component: null,\n RenderedComponent: errorMessage,\n }}\n label={label}\n onChange={setValue}\n path={pathFromContext}\n required={required}\n showError={showError}\n style={{\n marginBottom: 0,\n }}\n value={value}\n />\n </div>\n <div\n style={{\n alignItems: 'center',\n display: 'flex',\n width: '100%',\n }}\n >\n <LengthIndicator maxLength={maxLength} minLength={minLength} text={value} />\n </div>\n </div>\n )\n}\n"],"names":["FieldLabel","TextareaInput","useDocumentInfo","useField","useFieldProps","useForm","useLocale","useTranslation","React","useCallback","defaults","LengthIndicator","maxLength","minLength","description","MetaDescriptionComponent","props","field","admin","components","Label","label","required","hasGenerateDescriptionFn","labelProps","path","pathFromContext","t","locale","getData","docInfo","errorMessage","setValue","showError","value","regenerateDescription","genDescriptionResponse","fetch","body","JSON","stringify","id","slug","doc","docPermissions","hasPublishPermission","hasSavePermission","initialData","initialState","code","title","credentials","headers","method","result","generatedDescription","json","div","style","marginBottom","position","className","Fragment","button","onClick","background","backgroundColor","border","color","cursor","padding","textDecoration","type","a","href","rel","target","Error","Component","RenderedComponent","onChange","alignItems","display","width","text"],"mappings":"AAAA;;AAKA,SACEA,UAAU,EACVC,aAAa,EACbC,eAAe,EACfC,QAAQ,EACRC,aAAa,EACbC,OAAO,EACPC,SAAS,EACTC,cAAc,QACT,iBAAgB;AACvB,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAK1C,SAASC,QAAQ,QAAQ,oBAAmB;AAC5C,SAASC,eAAe,QAAQ,8BAA6B;AAE7D,MAAM,EAAEC,SAAS,EAAEC,SAAS,EAAE,GAAGH,SAASI,WAAW;AAMrD,OAAO,MAAMC,2BAA2D,CAACC;IACvE,MAAM,EACJ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wBAAII,WAAU;;0CACb,KAAC7D;gCAAWoB,OAAOA;gCAAOH,OAAO;gCAAMI,OAAOA;gCAAQ,GAAIG,cAAc,CAAC,CAAC;;4BACzED,0CACC,MAACf,MAAMsD,QAAQ;;oCAAC;kDAEd,KAACC;wCACCC,SAAS;4CACP,KAAK7B;wCACP;wCACAuB,OAAO;4CACLO,YAAY;4CACZC,iBAAiB;4CACjBC,QAAQ;4CACRC,OAAO;4CACPC,QAAQ;4CACRC,SAAS;4CACTC,gBAAgB;wCAClB;wCACAC,MAAK;kDAEJ7C,EAAE;;;;;;kCAKX,MAAC8B;wBACCC,OAAO;4BACLU,OAAO;wBACT;;4BAECzC,EAAE,mCAAmC;gCAAEf;gCAAWC;4BAAU;0CAC7D,KAAC4D;gCACCC,MAAK;gCACLC,KAAI;gCACJC,QAAO;0CAENjD,EAAE;;;;;;0BAIT,KAAC8B;gBACCC,OAAO;oBACLC,cAAc;oBACdC,UAAU;gBACZ;0BAEA,cAAA,KAAC3D;oBACC4E,OAAO;wBACLL,MAAM;wBACNM,WAAW;wBACXC,mBAAmBhD;oBACrB;oBACAV,OAAOA;oBACP2D,UAAUhD;oBACVP,MAAMC;oBACNJ,UAAUA;oBACVW,WAAWA;oBACXyB,OAAO;wBACLC,cAAc;oBAChB;oBACAzB,OAAOA;;;0BAGX,KAACuB;gBACCC,OAAO;oBACLuB,YAAY;oBACZC,SAAS;oBACTC,OAAO;gBACT;0BAEA,cAAA,KAACxE;oBAAgBC,WAAWA;oBAAWC,WAAWA;oBAAWuE,MAAMlD;;;;;AAI3E,EAAC"}
1
+ {"version":3,"sources":["../../../src/fields/MetaDescription/MetaDescriptionComponent.tsx"],"sourcesContent":["'use client'\n\nimport type { FieldType, Options } from '@payloadcms/ui'\nimport type { TextareaFieldClientProps } from 'payload'\n\nimport {\n FieldLabel,\n TextareaInput,\n useConfig,\n useDocumentInfo,\n useField,\n useForm,\n useLocale,\n useTranslation,\n} from '@payloadcms/ui'\nimport { reduceToSerializableFields } from '@payloadcms/ui/shared'\nimport React, { useCallback } from 'react'\n\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations/index.js'\nimport type { GenerateDescription } from '../../types.js'\n\nimport { defaults } from '../../defaults.js'\nimport { LengthIndicator } from '../../ui/LengthIndicator.js'\n\nconst { maxLength: maxLengthDefault, minLength: minLengthDefault } = defaults.description\n\ntype MetaDescriptionProps = {\n readonly hasGenerateDescriptionFn: boolean\n} & TextareaFieldClientProps\n\nexport const MetaDescriptionComponent: React.FC<MetaDescriptionProps> = (props) => {\n const {\n field: {\n label,\n localized,\n maxLength: maxLengthFromProps,\n minLength: minLengthFromProps,\n required,\n },\n hasGenerateDescriptionFn,\n path,\n } = props\n\n const {\n config: {\n routes: { api },\n serverURL,\n },\n } = useConfig()\n\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\n\n const locale = useLocale()\n const { getData } = useForm()\n const docInfo = useDocumentInfo()\n\n const maxLength = maxLengthFromProps || maxLengthDefault\n const minLength = minLengthFromProps || minLengthDefault\n\n const {\n customComponents: { AfterInput, BeforeInput, Label },\n errorMessage,\n setValue,\n showError,\n value,\n }: FieldType<string> = useField({\n path,\n } as Options)\n\n const regenerateDescription = useCallback(async () => {\n if (!hasGenerateDescriptionFn) {\n return\n }\n\n const endpoint = `${serverURL}${api}/plugin-seo/generate-description`\n\n const genDescriptionResponse = await fetch(endpoint, {\n body: JSON.stringify({\n id: docInfo.id,\n collectionSlug: docInfo.collectionSlug,\n doc: getData(),\n docPermissions: docInfo.docPermissions,\n globalSlug: docInfo.globalSlug,\n hasPublishPermission: docInfo.hasPublishPermission,\n hasSavePermission: docInfo.hasSavePermission,\n initialData: docInfo.initialData,\n initialState: reduceToSerializableFields(docInfo.initialState),\n locale: typeof locale === 'object' ? locale?.code : locale,\n title: docInfo.title,\n } satisfies Omit<\n Parameters<GenerateDescription>[0],\n 'collectionConfig' | 'globalConfig' | 'hasPublishedDoc' | 'req' | 'versionCount'\n >),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n const { result: generatedDescription } = await genDescriptionResponse.json()\n\n setValue(generatedDescription || '')\n }, [\n hasGenerateDescriptionFn,\n serverURL,\n api,\n docInfo.id,\n docInfo.collectionSlug,\n docInfo.docPermissions,\n docInfo.globalSlug,\n docInfo.hasPublishPermission,\n docInfo.hasSavePermission,\n docInfo.initialData,\n docInfo.initialState,\n docInfo.title,\n getData,\n locale,\n setValue,\n ])\n\n return (\n <div\n style={{\n marginBottom: '20px',\n }}\n >\n <div\n style={{\n marginBottom: '5px',\n position: 'relative',\n }}\n >\n <div className=\"plugin-seo__field\">\n {Label ?? (\n <FieldLabel label={label} localized={localized} path={path} required={required} />\n )}\n {hasGenerateDescriptionFn && (\n <React.Fragment>\n &nbsp; &mdash; &nbsp;\n <button\n onClick={() => {\n void regenerateDescription()\n }}\n style={{\n background: 'none',\n backgroundColor: 'transparent',\n border: 'none',\n color: 'currentcolor',\n cursor: 'pointer',\n padding: 0,\n textDecoration: 'underline',\n }}\n type=\"button\"\n >\n {t('plugin-seo:autoGenerate')}\n </button>\n </React.Fragment>\n )}\n </div>\n <div\n style={{\n color: '#9A9A9A',\n }}\n >\n {t('plugin-seo:lengthTipDescription', { maxLength, minLength })}\n <a\n href=\"https://developers.google.com/search/docs/advanced/appearance/snippet#meta-descriptions\"\n rel=\"noopener noreferrer\"\n target=\"_blank\"\n >\n {t('plugin-seo:bestPractices')}\n </a>\n </div>\n </div>\n <div\n style={{\n marginBottom: '10px',\n position: 'relative',\n }}\n >\n <TextareaInput\n AfterInput={AfterInput}\n BeforeInput={BeforeInput}\n Error={errorMessage}\n onChange={setValue}\n path={path}\n required={required}\n showError={showError}\n style={{\n marginBottom: 0,\n }}\n value={value}\n />\n </div>\n <div\n style={{\n alignItems: 'center',\n display: 'flex',\n width: '100%',\n }}\n >\n <LengthIndicator maxLength={maxLength} minLength={minLength} text={value} />\n </div>\n </div>\n )\n}\n"],"names":["FieldLabel","TextareaInput","useConfig","useDocumentInfo","useField","useForm","useLocale","useTranslation","reduceToSerializableFields","React","useCallback","defaults","LengthIndicator","maxLength","maxLengthDefault","minLength","minLengthDefault","description","MetaDescriptionComponent","props","field","label","localized","maxLengthFromProps","minLengthFromProps","required","hasGenerateDescriptionFn","path","config","routes","api","serverURL","t","locale","getData","docInfo","customComponents","AfterInput","BeforeInput","Label","errorMessage","setValue","showError","value","regenerateDescription","endpoint","genDescriptionResponse","fetch","body","JSON","stringify","id","collectionSlug","doc","docPermissions","globalSlug","hasPublishPermission","hasSavePermission","initialData","initialState","code","title","credentials","headers","method","result","generatedDescription","json","div","style","marginBottom","position","className","Fragment","button","onClick","background","backgroundColor","border","color","cursor","padding","textDecoration","type","a","href","rel","target","Error","onChange","alignItems","display","width","text"],"mappings":"AAAA;;AAKA,SACEA,UAAU,EACVC,aAAa,EACbC,SAAS,EACTC,eAAe,EACfC,QAAQ,EACRC,OAAO,EACPC,SAAS,EACTC,cAAc,QACT,iBAAgB;AACvB,SAASC,0BAA0B,QAAQ,wBAAuB;AAClE,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAK1C,SAASC,QAAQ,QAAQ,oBAAmB;AAC5C,SAASC,eAAe,QAAQ,8BAA6B;AAE7D,MAAM,EAAEC,WAAWC,gBAAgB,EAAEC,WAAWC,gBAAgB,EAAE,GAAGL,SAASM,WAAW;AAMzF,OAAO,MAAMC,2BAA2D,CAACC;IACvE,MAAM,EACJC,OAAO,EACLC,KAAK,EACLC,SAAS,EACTT,WAAWU,kBAAkB,EAC7BR,WAAWS,kBAAkB,EAC7BC,QAAQ,EACT,EACDC,wBAAwB,EACxBC,IAAI,EACL,GAAGR;IAEJ,MAAM,EACJS,QAAQ,EACNC,QAAQ,EAAEC,GAAG,EAAE,EACfC,SAAS,EACV,EACF,GAAG7B;IAEJ,MAAM,EAAE8B,CAAC,EAAE,GAAGzB;IAEd,MAAM0B,SAAS3B;IACf,MAAM,EAAE4B,OAAO,EAAE,G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ACpBxB,QAAQ0B,KAAK;QACb3B;QACAD;QACAQ;KACD;IAED,qBACE,MAAC2B;QACCC,OAAO;YACLC,cAAc;QAChB;;0BAEA,MAACF;gBACCC,OAAO;oBACLC,cAAc;oBACdC,UAAU;gBACZ;;kCAEA,MAACH;wBAAII,WAAU;;4BACZjC,uBACC,KAACvC;gCAAWqB,OAAOA;gCAAOC,WAAWA;gCAAWK,MAAMA;gCAAMF,UAAUA;;4BAEvEC,0CACC,MAACjB,MAAMgE,QAAQ;;oCAAC;kDAEd,KAACC;wCACCC,SAAS;4CACP,KAAK/B;wCACP;wCACAyB,OAAO;4CACLO,YAAY;4CACZC,iBAAiB;4CACjBC,QAAQ;4CACRC,OAAO;4CACPC,QAAQ;4CACRC,SAAS;4CACTC,gBAAgB;wCAClB;wCACAC,MAAK;kDAEJnD,EAAE;;;;;;kCAKX,MAACoC;wBACCC,OAAO;4BACLU,OAAO;wBACT;;4BAEC/C,EAAE,mCAAmC;gCAAEnB;gCAAWE;4BAAU;0CAC7D,KAACqE;gCACCC,MAAK;gCACLC,KAAI;gCACJC,QAAO;0CAENvD,EAAE;;;;;;0BAIT,KAACoC;gBACCC,OAAO;oBACLC,cAAc;oBACdC,UAAU;gBACZ;0BAEA,cAAA,KAACtE;oBACCoC,YAAYA;oBACZC,aAAaA;oBACbkD,OAAOhD;oBACPiD,UAAUhD;oBACVd,MAAMA;oBACNF,UAAUA;oBACViB,WAAWA;oBACX2B,OAAO;wBACLC,cAAc;oBAChB;oBACA3B,OAAOA;;;0BAGX,KAACyB;gBACCC,OAAO;oBACLqB,YAAY;oBACZC,SAAS;oBACTC,OAAO;gBACT;0BAEA,cAAA,KAAChF;oBAAgBC,WAAWA;oBAAWE,WAAWA;oBAAW8E,MAAMlD;;;;;AAI3E,EAAC"}
@@ -1,8 +1,8 @@
1
- import type { UploadFieldProps } from '@payloadcms/ui';
1
+ import type { UploadFieldClientProps } from 'payload';
2
2
  import React from 'react';
3
3
  type MetaImageProps = {
4
4
  readonly hasGenerateImageFn: boolean;
5
- } & UploadFieldProps;
5
+ } & UploadFieldClientProps;
6
6
  export declare const MetaImageComponent: React.FC<MetaImageProps>;
7
7
  export {};
8
8
  //# sourceMappingURL=MetaImageComponent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MetaImageComponent.d.ts","sourceRoot":"","sources":["../../../src/fields/MetaImage/MetaImageComponent.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAsB,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAa1E,OAAO,KAAsB,MAAM,OAAO,CAAA;AAO1C,KAAK,cAAc,GAAG;IACpB,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAA;CACrC,GAAG,gBAAgB,CAAA;AAEpB,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CA6JvD,CAAA"}
1
+ {"version":3,"file":"MetaImageComponent.d.ts","sourceRoot":"","sources":["../../../src/fields/MetaImage/MetaImageComponent.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAcrD,OAAO,KAAsB,MAAM,OAAO,CAAA;AAO1C,KAAK,cAAc,GAAG;IACpB,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAA;CACrC,GAAG,sBAAsB,CAAA;AAE1B,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAyLvD,CAAA"}
@@ -1,32 +1,38 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { FieldLabel, UploadInput, useConfig, useDocumentInfo, useField, useFieldProps, useForm, useLocale, useTranslation } from '@payloadcms/ui';
3
+ import { FieldLabel, RenderCustomComponent, UploadInput, useConfig, useDocumentInfo, useField, useForm, useLocale, useTranslation } from '@payloadcms/ui';
4
+ import { reduceToSerializableFields } from '@payloadcms/ui/shared';
4
5
  import React, { useCallback } from 'react';
5
6
  import { Pill } from '../../ui/Pill.js';
6
7
  export const MetaImageComponent = (props)=>{
7
- const { field: { admin: { components: { Label } }, label, relationTo, required }, hasGenerateImageFn, labelProps } = props || {};
8
- const { path: pathFromContext } = useFieldProps();
8
+ const { field: { label, localized, relationTo, required }, hasGenerateImageFn, path } = props || {};
9
+ const { config: { collections, routes: { api }, serverURL } } = useConfig();
9
10
  const field = useField({
10
11
  ...props,
11
- path: pathFromContext
12
+ path
12
13
  });
14
+ const { customComponents: { Error, Label } } = field;
13
15
  const { t } = useTranslation();
14
16
  const locale = useLocale();
15
17
  const { getData } = useForm();
16
18
  const docInfo = useDocumentInfo();
17
- const { errorMessage, setValue, showError, value } = field;
19
+ const { setValue, showError, value } = field;
18
20
  const regenerateImage = useCallback(async ()=>{
19
- if (!hasGenerateImageFn) return;
20
- const genImageResponse = await fetch('/api/plugin-seo/generate-image', {
21
+ if (!hasGenerateImageFn) {
22
+ return;
23
+ }
24
+ const endpoint = `${serverURL}${api}/plugin-seo/generate-image`;
25
+ const genImageResponse = await fetch(endpoint, {
21
26
  body: JSON.stringify({
22
27
  id: docInfo.id,
23
- slug: docInfo.slug,
28
+ collectionSlug: docInfo.collectionSlug,
24
29
  doc: getData(),
25
30
  docPermissions: docInfo.docPermissions,
31
+ globalSlug: docInfo.globalSlug,
26
32
  hasPublishPermission: docInfo.hasPublishPermission,
27
33
  hasSavePermission: docInfo.hasSavePermission,
28
34
  initialData: docInfo.initialData,
29
- initialState: docInfo.initialState,
35
+ initialState: reduceToSerializableFields(docInfo.initialState),
30
36
  locale: typeof locale === 'object' ? locale?.code : locale,
31
37
  title: docInfo.title
32
38
  }),
@@ -40,14 +46,22 @@ export const MetaImageComponent = (props)=>{
40
46
  setValue(generatedImage || '');
41
47
  }, [
42
48
  hasGenerateImageFn,
43
- docInfo,
49
+ serverURL,
50
+ api,
51
+ docInfo.id,
52
+ docInfo.collectionSlug,
53
+ docInfo.docPermissions,
54
+ docInfo.globalSlug,
55
+ docInfo.hasPublishPermission,
56
+ docInfo.hasSavePermission,
57
+ docInfo.initialData,
58
+ docInfo.initialState,
59
+ docInfo.title,
44
60
  getData,
45
61
  locale,
46
62
  setValue
47
63
  ]);
48
64
  const hasImage = Boolean(value);
49
- const { config } = useConfig();
50
- const { collections, routes: { api } = {}, serverURL } = config;
51
65
  const collection = collections?.find((coll)=>coll.slug === relationTo) || undefined;
52
66
  return /*#__PURE__*/ _jsxs("div", {
53
67
  style: {
@@ -63,11 +77,14 @@ export const MetaImageComponent = (props)=>{
63
77
  /*#__PURE__*/ _jsxs("div", {
64
78
  className: "plugin-seo__field",
65
79
  children: [
66
- /*#__PURE__*/ _jsx(FieldLabel, {
67
- Label: Label,
68
- field: null,
69
- label: label,
70
- ...labelProps || {}
80
+ /*#__PURE__*/ _jsx(RenderCustomComponent, {
81
+ CustomComponent: Label,
82
+ Fallback: /*#__PURE__*/ _jsx(FieldLabel, {
83
+ label: label,
84
+ localized: localized,
85
+ path: path,
86
+ required: required
87
+ })
71
88
  }),
72
89
  hasGenerateImageFn && /*#__PURE__*/ _jsxs(React.Fragment, {
73
90
  children: [
@@ -106,23 +123,23 @@ export const MetaImageComponent = (props)=>{
106
123
  position: 'relative'
107
124
  },
108
125
  children: /*#__PURE__*/ _jsx(UploadInput, {
109
- Error: {
110
- type: 'client',
111
- Component: null,
112
- RenderedComponent: errorMessage
113
- },
114
126
  api: api,
115
127
  collection: collection,
128
+ Error: Error,
116
129
  filterOptions: field.filterOptions,
117
- label: undefined,
118
130
  onChange: (incomingImage)=>{
119
131
  if (incomingImage !== null) {
120
- const { id: incomingID } = incomingImage;
121
- setValue(incomingID);
132
+ if (typeof incomingImage === 'object') {
133
+ const { id: incomingID } = incomingImage;
134
+ setValue(incomingID);
135
+ } else {
136
+ setValue(incomingImage);
137
+ }
122
138
  } else {
123
139
  setValue(null);
124
140
  }
125
141
  },
142
+ path: path,
126
143
  relationTo: relationTo,
127
144
  required: required,
128
145
  serverURL: serverURL,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/MetaImage/MetaImageComponent.tsx"],"sourcesContent":["'use client'\n\nimport type { FieldType, Options, UploadFieldProps } from '@payloadcms/ui'\n\nimport {\n FieldLabel,\n UploadInput,\n useConfig,\n useDocumentInfo,\n useField,\n useFieldProps,\n useForm,\n useLocale,\n useTranslation,\n} from '@payloadcms/ui'\nimport React, { useCallback } from 'react'\n\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations/index.js'\nimport type { GenerateImage } from '../../types.js'\n\nimport { Pill } from '../../ui/Pill.js'\n\ntype MetaImageProps = {\n readonly hasGenerateImageFn: boolean\n} & UploadFieldProps\n\nexport const MetaImageComponent: React.FC<MetaImageProps> = (props) => {\n const {\n field: {\n admin: {\n components: { Label },\n },\n label,\n relationTo,\n required,\n },\n hasGenerateImageFn,\n labelProps,\n } = props || {}\n const { path: pathFromContext } = useFieldProps()\n\n const field: FieldType<string> = useField({ ...props, path: pathFromContext } as Options)\n\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\n\n const locale = useLocale()\n const { getData } = useForm()\n const docInfo = useDocumentInfo()\n\n const { errorMessage, setValue, showError, value } = field\n\n const regenerateImage = useCallback(async () => {\n if (!hasGenerateImageFn) return\n\n const genImageResponse = await fetch('/api/plugin-seo/generate-image', {\n body: JSON.stringify({\n id: docInfo.id,\n slug: docInfo.slug,\n doc: getData(),\n docPermissions: docInfo.docPermissions,\n hasPublishPermission: docInfo.hasPublishPermission,\n hasSavePermission: docInfo.hasSavePermission,\n initialData: docInfo.initialData,\n initialState: docInfo.initialState,\n locale: typeof locale === 'object' ? locale?.code : locale,\n title: docInfo.title,\n } satisfies Omit<Parameters<GenerateImage>[0], 'req'>),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n const generatedImage = await genImageResponse.text()\n\n setValue(generatedImage || '')\n }, [hasGenerateImageFn, docInfo, getData, locale, setValue])\n\n const hasImage = Boolean(value)\n\n const { config } = useConfig()\n\n const { collections, routes: { api } = {}, serverURL } = config\n\n const collection = collections?.find((coll) => coll.slug === relationTo) || undefined\n\n return (\n <div\n style={{\n marginBottom: '20px',\n }}\n >\n <div\n style={{\n marginBottom: '5px',\n position: 'relative',\n }}\n >\n <div className=\"plugin-seo__field\">\n <FieldLabel Label={Label} field={null} label={label} {...(labelProps || {})} />\n {hasGenerateImageFn && (\n <React.Fragment>\n &nbsp; &mdash; &nbsp;\n <button\n onClick={() => {\n void regenerateImage()\n }}\n style={{\n background: 'none',\n backgroundColor: 'transparent',\n border: 'none',\n color: 'currentcolor',\n cursor: 'pointer',\n padding: 0,\n textDecoration: 'underline',\n }}\n type=\"button\"\n >\n {t('plugin-seo:autoGenerate')}\n </button>\n </React.Fragment>\n )}\n </div>\n {hasGenerateImageFn && (\n <div\n style={{\n color: '#9A9A9A',\n }}\n >\n {t('plugin-seo:imageAutoGenerationTip')}\n </div>\n )}\n </div>\n <div\n style={{\n marginBottom: '10px',\n position: 'relative',\n }}\n >\n <UploadInput\n Error={{\n type: 'client',\n Component: null,\n RenderedComponent: errorMessage,\n }}\n api={api}\n collection={collection}\n filterOptions={field.filterOptions}\n label={undefined}\n onChange={(incomingImage) => {\n if (incomingImage !== null) {\n const { id: incomingID } = incomingImage\n setValue(incomingID)\n } else {\n setValue(null)\n }\n }}\n relationTo={relationTo}\n required={required}\n serverURL={serverURL}\n showError={showError}\n style={{\n marginBottom: 0,\n }}\n value={value}\n />\n </div>\n <div\n style={{\n alignItems: 'center',\n display: 'flex',\n width: '100%',\n }}\n >\n <Pill\n backgroundColor={hasImage ? 'green' : 'red'}\n color=\"white\"\n label={hasImage ? t('plugin-seo:good') : t('plugin-seo:noImage')}\n />\n </div>\n </div>\n )\n}\n"],"names":["FieldLabel","UploadInput","useConfig","useDocumentInfo","useField","useFieldProps","useForm","useLocale","useTranslation","React","useCallback","Pill","MetaImageComponent","props","field","admin","components","Label","label","relationTo","required","hasGenerateImageFn","labelProps","path","pathFromContext","t","locale","getData","docInfo","errorMessage","setValue","showError","value","regenerateImage","genImageResponse","fetch","body","JSON","stringify","id","slug","doc","docPermissions","hasPublishPermission","hasSavePermission","initialData","initialState","code","title","credentials","headers","method","generatedImage","text","hasImage","Boolean","config","collections","routes","api","serverURL","collection","find","coll","undefined","div","style","marginBottom","position","className","Fragment","button","onClick","background","backgroundColor","border","color","cursor","padding","textDecoration","type","Error","Component","RenderedComponent","filterOptions","onChange","incomingImage","incomingID","alignItems","display","width"],"mappings":"AAAA;;AAIA,SACEA,UAAU,EACVC,WAAW,EACXC,SAAS,EACTC,eAAe,EACfC,QAAQ,EACRC,aAAa,EACbC,OAAO,EACPC,SAAS,EACTC,cAAc,QACT,iBAAgB;AACvB,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAK1C,SAASC,IAAI,QAAQ,mBAAkB;AAMvC,OAAO,MAAMC,qBAA+C,CAACC;IAC3D,MAAM,EACJC,OAAO,EACLC,OAAO,EACLC,YAAY,EAAEC,KAAK,EAAE,EACtB,EACDC,KAAK,EACLC,UAAU,EACVC,QAAQ,EACT,EACDC,kBAAkB,EAClBC,UAAU,EACX,GAAGT,SAAS,CAAC;IACd,MAAM,EAAEU,MAAMC,eAAe,EAAE,GAAGnB;IAElC,MAAMS,QAA2BV,SAAS;QAAE,GAAGS,KAAK;QAAEU,MAAMC;IAAgB;IAE5E,MAAM,EAAEC,CAAC,EAAE,GAAGjB;IAEd,MAAMkB,SAASnB;IACf,MAAM,EAAEoB,OAAO,EAAE,GAAGrB;IACpB,MAAMsB,UAAUzB;IAEhB,MAAM,EAAE0B,YAAY,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,KAAK,EAAE,GAAGlB;IAErD,MAAMmB,kBAAkBvB,YAAY;QAClC,IAAI,CAACW,oBAAoB;QAEzB,MAAMa,mBAAmB,MAAMC,MAAM,kCAAkC;YACrEC,MAAMC,KAAKC,SAAS,CAAC;gBACnBC,IAAIX,QAAQW,EAAE;gBACdC,MAAMZ,QAAQY,IAAI;g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AAO;4BACLU,OAAO;wBACT;kCAECnD,EAAE;;;;0BAIT,KAACwC;gBACCC,OAAO;oBACLC,cAAc;oBACdC,UAAU;gBACZ;0BAEA,cAAA,KAACnE;oBACCgF,OAAO;wBACLD,MAAM;wBACNE,WAAW;wBACXC,mBAAmBtD;oBACrB;oBACA8B,KAAKA;oBACLE,YAAYA;oBACZuB,eAAetE,MAAMsE,aAAa;oBAClClE,OAAO8C;oBACPqB,UAAU,CAACC;wBACT,IAAIA,kBAAkB,MAAM;4BAC1B,MAAM,EAAE/C,IAAIgD,UAAU,EAAE,GAAGD;4BAC3BxD,SAASyD;wBACX,OAAO;4BACLzD,SAAS;wBACX;oBACF;oBACAX,YAAYA;oBACZC,UAAUA;oBACVwC,WAAWA;oBACX7B,WAAWA;oBACXmC,OAAO;wBACLC,cAAc;oBAChB;oBACAnC,OAAOA;;;0BAGX,KAACiC;gBACCC,OAAO;oBACLsB,YAAY;oBACZC,SAAS;oBACTC,OAAO;gBACT;0BAEA,cAAA,KAAC/E;oBACC+D,iBAAiBpB,WAAW,UAAU;oBACtCsB,OAAM;oBACN1D,OAAOoC,WAAW7B,EAAE,qBAAqBA,EAAE;;;;;AAKrD,EAAC"}
1
+ {"version":3,"sources":["../../../src/fields/MetaImage/MetaImageComponent.tsx"],"sourcesContent":["'use client'\n\nimport type { FieldType, Options } from '@payloadcms/ui'\nimport type { UploadFieldClientProps } from 'payload'\n\nimport {\n FieldLabel,\n RenderCustomComponent,\n UploadInput,\n useConfig,\n useDocumentInfo,\n useField,\n useForm,\n useLocale,\n useTranslation,\n} from '@payloadcms/ui'\nimport { reduceToSerializableFields } from '@payloadcms/ui/shared'\nimport React, { useCallback } from 'react'\n\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations/index.js'\nimport type { GenerateImage } from '../../types.js'\n\nimport { Pill } from '../../ui/Pill.js'\n\ntype MetaImageProps = {\n readonly hasGenerateImageFn: boolean\n} & UploadFieldClientProps\n\nexport const MetaImageComponent: React.FC<MetaImageProps> = (props) => {\n const {\n field: { label, localized, relationTo, required },\n hasGenerateImageFn,\n path,\n } = props || {}\n\n const {\n config: {\n collections,\n routes: { api },\n serverURL,\n },\n } = useConfig()\n\n const field: FieldType<string> = useField({ ...props, path } as Options)\n const {\n customComponents: { Error, Label },\n } = field\n\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\n\n const locale = useLocale()\n const { getData } = useForm()\n const docInfo = useDocumentInfo()\n\n const { setValue, showError, value } = field\n\n const regenerateImage = useCallback(async () => {\n if (!hasGenerateImageFn) {\n return\n }\n\n const endpoint = `${serverURL}${api}/plugin-seo/generate-image`\n\n const genImageResponse = await fetch(endpoint, {\n body: JSON.stringify({\n id: docInfo.id,\n collectionSlug: docInfo.collectionSlug,\n doc: getData(),\n docPermissions: docInfo.docPermissions,\n globalSlug: docInfo.globalSlug,\n hasPublishPermission: docInfo.hasPublishPermission,\n hasSavePermission: docInfo.hasSavePermission,\n initialData: docInfo.initialData,\n initialState: reduceToSerializableFields(docInfo.initialState),\n locale: typeof locale === 'object' ? locale?.code : locale,\n title: docInfo.title,\n } satisfies Omit<\n Parameters<GenerateImage>[0],\n 'collectionConfig' | 'globalConfig' | 'hasPublishedDoc' | 'req' | 'versionCount'\n >),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n const generatedImage = await genImageResponse.text()\n\n setValue(generatedImage || '')\n }, [\n hasGenerateImageFn,\n serverURL,\n api,\n docInfo.id,\n docInfo.collectionSlug,\n docInfo.docPermissions,\n docInfo.globalSlug,\n docInfo.hasPublishPermission,\n docInfo.hasSavePermission,\n docInfo.initialData,\n docInfo.initialState,\n docInfo.title,\n getData,\n locale,\n setValue,\n ])\n\n const hasImage = Boolean(value)\n\n const collection = collections?.find((coll) => coll.slug === relationTo) || undefined\n\n return (\n <div\n style={{\n marginBottom: '20px',\n }}\n >\n <div\n style={{\n marginBottom: '5px',\n position: 'relative',\n }}\n >\n <div className=\"plugin-seo__field\">\n <RenderCustomComponent\n CustomComponent={Label}\n Fallback={\n <FieldLabel label={label} localized={localized} path={path} required={required} />\n }\n />\n {hasGenerateImageFn && (\n <React.Fragment>\n &nbsp; &mdash; &nbsp;\n <button\n onClick={() => {\n void regenerateImage()\n }}\n style={{\n background: 'none',\n backgroundColor: 'transparent',\n border: 'none',\n color: 'currentcolor',\n cursor: 'pointer',\n padding: 0,\n textDecoration: 'underline',\n }}\n type=\"button\"\n >\n {t('plugin-seo:autoGenerate')}\n </button>\n </React.Fragment>\n )}\n </div>\n {hasGenerateImageFn && (\n <div\n style={{\n color: '#9A9A9A',\n }}\n >\n {t('plugin-seo:imageAutoGenerationTip')}\n </div>\n )}\n </div>\n <div\n style={{\n marginBottom: '10px',\n position: 'relative',\n }}\n >\n <UploadInput\n api={api}\n collection={collection}\n Error={Error}\n filterOptions={field.filterOptions}\n onChange={(incomingImage) => {\n if (incomingImage !== null) {\n if (typeof incomingImage === 'object') {\n const { id: incomingID } = incomingImage\n setValue(incomingID)\n } else {\n setValue(incomingImage)\n }\n } else {\n setValue(null)\n }\n }}\n path={path}\n relationTo={relationTo}\n required={required}\n serverURL={serverURL}\n showError={showError}\n style={{\n marginBottom: 0,\n }}\n value={value}\n />\n </div>\n <div\n style={{\n alignItems: 'center',\n display: 'flex',\n width: '100%',\n }}\n >\n <Pill\n backgroundColor={hasImage ? 'green' : 'red'}\n color=\"white\"\n label={hasImage ? t('plugin-seo:good') : t('plugin-seo:noImage')}\n />\n </div>\n </div>\n )\n}\n"],"names":["FieldLabel","RenderCustomComponent","UploadInput","useConfig","useDocumentInfo","useField","useForm","useLocale","useTranslation","reduceToSerializableFields","React","useCallback","Pill","MetaImageComponent","props","field","label","localized","relationTo","required","hasGenerateImageFn","path","config","collections","routes","api","serverURL","customComponents","Error","Label","t","locale","getData","docInfo","setValue","showError","value","regenerateImage","endpoint","genImageResponse","fetch","body","JSON","stringify","id","collectionSlug","doc","docPermissions","globalSlug","hasPublishPermission","hasSavePermission","initialData","initialState","code","title","credentials","headers","method","generatedImage","text","hasImage","Boolean","collection","find","coll","slug","undefined","div","style","marginBottom","position","className","CustomComponent","Fallback","Fragment","button","onClick","background","backgroundColor","border","color","cursor","padding","textDecoration","type","filterOptions","onChange","incomingImage","incomingID","alignItems","display","width"],"mappings":"AAAA;;AAKA,SACEA,UAAU,EACVC,qBAAqB,EACrBC,WAAW,EACXC,SAAS,EACTC,eAAe,EACfC,QAAQ,EACRC,OAAO,EACPC,SAAS,EACTC,cAAc,QACT,iBAAgB;AACvB,SAASC,0BAA0B,QAAQ,wBAAuB;AAClE,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAK1C,SAASC,IAAI,QAAQ,mBAAkB;AAMvC,OAAO,MAAMC,qBAA+C,CAACC;IAC3D,MAAM,EACJC,OAAO,EAAEC,KAAK,EAAEC,SAAS,EAAEC,UAAU,EAAEC,QAAQ,EAAE,EACjDC,kBAAkB,EAClBC,IAAI,EACL,GAAGP,SAAS,CAAC;IAEd,MAAM,EACJQ,QAAQ,EACNC,WAAW,EACXC,QAAQ,EAAEC,GAAG,EAAE,EACfC,SAAS,EACV,EACF,GAAGvB;IAEJ,MAAMY,QAA2BV,SAAS;QAAE,GAAGS,KAAK;QAAEO;IAAK;IAC3D,MAAM,EACJM,kBAAkB,EAAEC,KAAK,EAAEC,KAAK,EAAE,EACnC,GAAGd;IAEJ,MAAM,EAAEe,CAAC,EAAE,GAAGtB;IAEd,MAAMuB,SAASxB;IACf,MAAM,EAAEyB,OAAO,EAAE,GAAG1B;IACpB,MAAM2B,UAAU7B;IAEhB,MAAM,EAAE8B,QAAQ,EAAEC,SAAS,EAAEC,KAAK,EAAE,GAAGrB;IAEvC,MAAMsB,kBAAkB1B,YAAY;QAClC,IAAI,CAACS,oBAAoB;YACvB;QACF;QAEA,MAAMkB,WAAW,CAAC,EAAEZ,UAAU,EAAED,IAAI,0BAA0B,CAAC;QAE/D,MAAMc,mBAAmB,MAAMC,MAAMF,UAAU;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CC,SAAS;4CACP,KAAKvC;wCACP;wCACA+B,OAAO;4CACLS,YAAY;4CACZC,iBAAiB;4CACjBC,QAAQ;4CACRC,OAAO;4CACPC,QAAQ;4CACRC,SAAS;4CACTC,gBAAgB;wCAClB;wCACAC,MAAK;kDAEJtD,EAAE;;;;;;oBAKVV,oCACC,KAAC+C;wBACCC,OAAO;4BACLY,OAAO;wBACT;kCAEClD,EAAE;;;;0BAIT,KAACqC;gBACCC,OAAO;oBACLC,cAAc;oBACdC,UAAU;gBACZ;0BAEA,cAAA,KAACpE;oBACCuB,KAAKA;oBACLqC,YAAYA;oBACZlC,OAAOA;oBACPyD,eAAetE,MAAMsE,aAAa;oBAClCC,UAAU,CAACC;wBACT,IAAIA,kBAAkB,MAAM;4BAC1B,IAAI,OAAOA,kBAAkB,UAAU;gCACrC,MAAM,EAAE3C,IAAI4C,UAAU,EAAE,GAAGD;gCAC3BrD,SAASsD;4BACX,OAAO;gCACLtD,SAASqD;4BACX;wBACF,OAAO;4BACLrD,SAAS;wBACX;oBACF;oBACAb,MAAMA;oBACNH,YAAYA;oBACZC,UAAUA;oBACVO,WAAWA;oBACXS,WAAWA;oBACXiC,OAAO;wBACLC,cAAc;oBAChB;oBACAjC,OAAOA;;;0BAGX,KAAC+B;gBACCC,OAAO;oBACLqB,YAAY;oBACZC,SAAS;oBACTC,OAAO;gBACT;0BAEA,cAAA,KAAC/E;oBACCkE,iBAAiBlB,WAAW,UAAU;oBACtCoB,OAAM;oBACNhE,OAAO4C,WAAW9B,EAAE,qBAAqBA,EAAE;;;;;AAKrD,EAAC"}
@@ -1,9 +1,9 @@
1
- import type { TextFieldProps } from 'payload';
1
+ import type { TextFieldClientProps } from 'payload';
2
2
  import React from 'react';
3
3
  import '../index.scss';
4
4
  type MetaTitleProps = {
5
5
  readonly hasGenerateTitleFn: boolean;
6
- } & TextFieldProps;
6
+ } & TextFieldClientProps;
7
7
  export declare const MetaTitleComponent: React.FC<MetaTitleProps>;
8
8
  export {};
9
9
  //# sourceMappingURL=MetaTitleComponent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MetaTitleComponent.d.ts","sourceRoot":"","sources":["../../../src/fields/MetaTitle/MetaTitleComponent.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAY7C,OAAO,KAAsB,MAAM,OAAO,CAAA;AAO1C,OAAO,eAAe,CAAA;AAItB,KAAK,cAAc,GAAG;IACpB,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAA;CACrC,GAAG,cAAc,CAAA;AAElB,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CA6IvD,CAAA"}
1
+ {"version":3,"file":"MetaTitleComponent.d.ts","sourceRoot":"","sources":["../../../src/fields/MetaTitle/MetaTitleComponent.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAanD,OAAO,KAAsB,MAAM,OAAO,CAAA;AAO1C,OAAO,eAAe,CAAA;AAItB,KAAK,cAAc,GAAG;IACpB,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAA;CACrC,GAAG,oBAAoB,CAAA;AAExB,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAoKvD,CAAA"}
@@ -1,34 +1,42 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { FieldLabel, TextInput, useDocumentInfo, useField, useFieldProps, useForm, useLocale, useTranslation } from '@payloadcms/ui';
3
+ import { FieldLabel, TextInput, useConfig, useDocumentInfo, useField, useForm, useLocale, useTranslation } from '@payloadcms/ui';
4
+ import { reduceToSerializableFields } from '@payloadcms/ui/shared';
4
5
  import React, { useCallback } from 'react';
5
6
  import { defaults } from '../../defaults.js';
6
7
  import { LengthIndicator } from '../../ui/LengthIndicator.js';
7
8
  import '../index.scss';
8
- const { maxLength, minLength } = defaults.title;
9
+ const { maxLength: maxLengthDefault, minLength: minLengthDefault } = defaults.title;
9
10
  export const MetaTitleComponent = (props)=>{
10
- const { field: { admin: { components: { Label } }, label, required }, hasGenerateTitleFn, labelProps } = props || {};
11
- const { path: pathFromContext } = useFieldProps();
11
+ const { field: { label, maxLength: maxLengthFromProps, minLength: minLengthFromProps, required }, hasGenerateTitleFn, path } = props || {};
12
12
  const { t } = useTranslation();
13
+ const { config: { routes: { api }, serverURL } } = useConfig();
13
14
  const field = useField({
14
- path: pathFromContext
15
+ path
15
16
  });
17
+ const { customComponents: { AfterInput, BeforeInput, Label } = {} } = field;
16
18
  const locale = useLocale();
17
19
  const { getData } = useForm();
18
20
  const docInfo = useDocumentInfo();
21
+ const minLength = minLengthFromProps || minLengthDefault;
22
+ const maxLength = maxLengthFromProps || maxLengthDefault;
19
23
  const { errorMessage, setValue, showError, value } = field;
20
24
  const regenerateTitle = useCallback(async ()=>{
21
- if (!hasGenerateTitleFn) return;
22
- const genTitleResponse = await fetch('/api/plugin-seo/generate-title', {
25
+ if (!hasGenerateTitleFn) {
26
+ return;
27
+ }
28
+ const endpoint = `${serverURL}${api}/plugin-seo/generate-title`;
29
+ const genTitleResponse = await fetch(endpoint, {
23
30
  body: JSON.stringify({
24
31
  id: docInfo.id,
25
- slug: docInfo.slug,
32
+ collectionSlug: docInfo.collectionSlug,
26
33
  doc: getData(),
27
34
  docPermissions: docInfo.docPermissions,
35
+ globalSlug: docInfo.globalSlug,
28
36
  hasPublishPermission: docInfo.hasPublishPermission,
29
37
  hasSavePermission: docInfo.hasSavePermission,
30
38
  initialData: docInfo.initialData,
31
- initialState: docInfo.initialState,
39
+ initialState: reduceToSerializableFields(docInfo.initialState),
32
40
  locale: typeof locale === 'object' ? locale?.code : locale,
33
41
  title: docInfo.title
34
42
  }),
@@ -42,7 +50,17 @@ export const MetaTitleComponent = (props)=>{
42
50
  setValue(generatedTitle || '');
43
51
  }, [
44
52
  hasGenerateTitleFn,
45
- docInfo,
53
+ serverURL,
54
+ api,
55
+ docInfo.id,
56
+ docInfo.collectionSlug,
57
+ docInfo.docPermissions,
58
+ docInfo.globalSlug,
59
+ docInfo.hasPublishPermission,
60
+ docInfo.hasSavePermission,
61
+ docInfo.initialData,
62
+ docInfo.initialState,
63
+ docInfo.title,
46
64
  getData,
47
65
  locale,
48
66
  setValue
@@ -61,11 +79,10 @@ export const MetaTitleComponent = (props)=>{
61
79
  /*#__PURE__*/ _jsxs("div", {
62
80
  className: "plugin-seo__field",
63
81
  children: [
64
- /*#__PURE__*/ _jsx(FieldLabel, {
65
- Label: Label,
66
- field: null,
82
+ Label ?? /*#__PURE__*/ _jsx(FieldLabel, {
67
83
  label: label,
68
- ...labelProps || {}
84
+ path: path,
85
+ required: required
69
86
  }),
70
87
  hasGenerateTitleFn && /*#__PURE__*/ _jsxs(React.Fragment, {
71
88
  children: [
@@ -116,14 +133,11 @@ export const MetaTitleComponent = (props)=>{
116
133
  position: 'relative'
117
134
  },
118
135
  children: /*#__PURE__*/ _jsx(TextInput, {
119
- Error: {
120
- type: 'client',
121
- Component: null,
122
- RenderedComponent: errorMessage
123
- },
124
- label: label,
136
+ AfterInput: AfterInput,
137
+ BeforeInput: BeforeInput,
138
+ Error: errorMessage,
125
139
  onChange: setValue,
126
- path: pathFromContext,
140
+ path: path,
127
141
  required: required,
128
142
  showError: showError,
129
143
  style: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/MetaTitle/MetaTitleComponent.tsx"],"sourcesContent":["'use client'\n\nimport type { FieldType, Options } from '@payloadcms/ui'\nimport type { TextFieldProps } from 'payload'\n\nimport {\n FieldLabel,\n TextInput,\n useDocumentInfo,\n useField,\n useFieldProps,\n useForm,\n useLocale,\n useTranslation,\n} from '@payloadcms/ui'\nimport React, { useCallback } from 'react'\n\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations/index.js'\nimport type { GenerateTitle } from '../../types.js'\n\nimport { defaults } from '../../defaults.js'\nimport { LengthIndicator } from '../../ui/LengthIndicator.js'\nimport '../index.scss'\n\nconst { maxLength, minLength } = defaults.title\n\ntype MetaTitleProps = {\n readonly hasGenerateTitleFn: boolean\n} & TextFieldProps\n\nexport const MetaTitleComponent: React.FC<MetaTitleProps> = (props) => {\n const {\n field: {\n admin: {\n components: { Label },\n },\n label,\n required,\n },\n hasGenerateTitleFn,\n labelProps,\n } = props || {}\n const { path: pathFromContext } = useFieldProps()\n\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\n\n const field: FieldType<string> = useField({\n path: pathFromContext,\n } as Options)\n\n const locale = useLocale()\n const { getData } = useForm()\n const docInfo = useDocumentInfo()\n\n const { errorMessage, setValue, showError, value } = field\n\n const regenerateTitle = useCallback(async () => {\n if (!hasGenerateTitleFn) return\n\n const genTitleResponse = await fetch('/api/plugin-seo/generate-title', {\n body: JSON.stringify({\n id: docInfo.id,\n slug: docInfo.slug,\n doc: getData(),\n docPermissions: docInfo.docPermissions,\n hasPublishPermission: docInfo.hasPublishPermission,\n hasSavePermission: docInfo.hasSavePermission,\n initialData: docInfo.initialData,\n initialState: docInfo.initialState,\n locale: typeof locale === 'object' ? locale?.code : locale,\n title: docInfo.title,\n } satisfies Omit<Parameters<GenerateTitle>[0], 'req'>),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n const { result: generatedTitle } = await genTitleResponse.json()\n\n setValue(generatedTitle || '')\n }, [hasGenerateTitleFn, docInfo, getData, locale, setValue])\n\n return (\n <div\n style={{\n marginBottom: '20px',\n }}\n >\n <div\n style={{\n marginBottom: '5px',\n position: 'relative',\n }}\n >\n <div className=\"plugin-seo__field\">\n <FieldLabel Label={Label} field={null} label={label} {...(labelProps || {})} />\n {hasGenerateTitleFn && (\n <React.Fragment>\n &nbsp; &mdash; &nbsp;\n <button\n onClick={() => {\n void regenerateTitle()\n }}\n style={{\n background: 'none',\n backgroundColor: 'transparent',\n border: 'none',\n color: 'currentcolor',\n cursor: 'pointer',\n padding: 0,\n textDecoration: 'underline',\n }}\n type=\"button\"\n >\n {t('plugin-seo:autoGenerate')}\n </button>\n </React.Fragment>\n )}\n </div>\n <div\n style={{\n color: '#9A9A9A',\n }}\n >\n {t('plugin-seo:lengthTipTitle', { maxLength, minLength })}\n <a\n href=\"https://developers.google.com/search/docs/advanced/appearance/title-link#page-titles\"\n rel=\"noopener noreferrer\"\n target=\"_blank\"\n >\n {t('plugin-seo:bestPractices')}\n </a>\n .\n </div>\n </div>\n <div\n style={{\n marginBottom: '10px',\n position: 'relative',\n }}\n >\n <TextInput\n Error={{\n type: 'client',\n Component: null,\n RenderedComponent: errorMessage,\n }}\n label={label}\n onChange={setValue}\n path={pathFromContext}\n required={required}\n showError={showError}\n style={{\n marginBottom: 0,\n }}\n value={value}\n />\n </div>\n <div\n style={{\n alignItems: 'center',\n display: 'flex',\n width: '100%',\n }}\n >\n <LengthIndicator maxLength={maxLength} minLength={minLength} text={value} />\n </div>\n </div>\n )\n}\n"],"names":["FieldLabel","TextInput","useDocumentInfo","useField","useFieldProps","useForm","useLocale","useTranslation","React","useCallback","defaults","LengthIndicator","maxLength","minLength","title","MetaTitleComponent","props","field","admin","components","Label","label","required","hasGenerateTitleFn","labelProps","path","pathFromContext","t","locale","getData","docInfo","errorMessage","setValue","showError","value","regenerateTitle","genTitleResponse","fetch","body","JSON","stringify","id","slug","doc","docPermissions","hasPublishPermission","hasSavePermission","initialData","initialState","code","credentials","headers","method","result","generatedTitle","json","div","style","marginBottom","position","className","Fragment","button","onClick","background","backgroundColor","border","color","cursor","padding","textDecoration","type","a","href","rel","target","Error","Component","RenderedComponent","onChange","alignItems","display","width","text"],"mappings":"AAAA;;AAKA,SACEA,UAAU,EACVC,SAAS,EACTC,eAAe,EACfC,QAAQ,EACRC,aAAa,EACbC,OAAO,EACPC,SAAS,EACTC,cAAc,QACT,iBAAgB;AACvB,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAK1C,SAASC,QAAQ,QAAQ,o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Content":["'use client'\n\nimport type { FieldType, Options } from '@payloadcms/ui'\nimport type { TextFieldClientProps } from 'payload'\n\nimport {\n FieldLabel,\n TextInput,\n useConfig,\n useDocumentInfo,\n useField,\n useForm,\n useLocale,\n useTranslation,\n} from '@payloadcms/ui'\nimport { reduceToSerializableFields } from '@payloadcms/ui/shared'\nimport React, { useCallback } from 'react'\n\nimport type { PluginSEOTranslationKeys, PluginSEOTranslations } from '../../translations/index.js'\nimport type { GenerateTitle } from '../../types.js'\n\nimport { defaults } from '../../defaults.js'\nimport { LengthIndicator } from '../../ui/LengthIndicator.js'\nimport '../index.scss'\n\nconst { maxLength: maxLengthDefault, minLength: minLengthDefault } = defaults.title\n\ntype MetaTitleProps = {\n readonly hasGenerateTitleFn: boolean\n} & TextFieldClientProps\n\nexport const MetaTitleComponent: React.FC<MetaTitleProps> = (props) => {\n const {\n field: { label, maxLength: maxLengthFromProps, minLength: minLengthFromProps, required },\n hasGenerateTitleFn,\n path,\n } = props || {}\n\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\n\n const {\n config: {\n routes: { api },\n serverURL,\n },\n } = useConfig()\n\n const field: FieldType<string> = useField({ path } as Options)\n const { customComponents: { AfterInput, BeforeInput, Label } = {} } = field\n\n const locale = useLocale()\n const { getData } = useForm()\n const docInfo = useDocumentInfo()\n\n const minLength = minLengthFromProps || minLengthDefault\n const maxLength = maxLengthFromProps || maxLengthDefault\n\n const { errorMessage, setValue, showError, value } = field\n\n const regenerateTitle = useCallback(async () => {\n if (!hasGenerateTitleFn) {\n return\n }\n\n const endpoint = `${serverURL}${api}/plugin-seo/generate-title`\n\n const genTitleResponse = await fetch(endpoint, {\n body: JSON.stringify({\n id: docInfo.id,\n collectionSlug: docInfo.collectionSlug,\n doc: getData(),\n docPermissions: docInfo.docPermissions,\n globalSlug: docInfo.globalSlug,\n hasPublishPermission: docInfo.hasPublishPermission,\n hasSavePermission: docInfo.hasSavePermission,\n initialData: docInfo.initialData,\n initialState: reduceToSerializableFields(docInfo.initialState),\n locale: typeof locale === 'object' ? locale?.code : locale,\n title: docInfo.title,\n } satisfies Omit<\n Parameters<GenerateTitle>[0],\n 'collectionConfig' | 'globalConfig' | 'hasPublishedDoc' | 'req' | 'versionCount'\n >),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n const { result: generatedTitle } = await genTitleResponse.json()\n\n setValue(generatedTitle || '')\n }, [\n hasGenerateTitleFn,\n serverURL,\n api,\n docInfo.id,\n docInfo.collectionSlug,\n docInfo.docPermissions,\n docInfo.globalSlug,\n docInfo.hasPublishPermission,\n docInfo.hasSavePermission,\n docInfo.initialData,\n docInfo.initialState,\n docInfo.title,\n getData,\n locale,\n setValue,\n ])\n\n return (\n <div\n style={{\n marginBottom: '20px',\n }}\n >\n <div\n style={{\n marginBottom: '5px',\n position: 'relative',\n }}\n >\n <div className=\"plugin-seo__field\">\n {Label ?? <FieldLabel label={label} path={path} required={required} />}\n {hasGenerateTitleFn && (\n <React.Fragment>\n &nbsp; &mdash; &nbsp;\n <button\n onClick={() => {\n void regenerateTitle()\n }}\n style={{\n background: 'none',\n backgroundColor: 'transparent',\n border: 'none',\n color: 'currentcolor',\n cursor: 'pointer',\n padding: 0,\n textDecoration: 'underline',\n }}\n type=\"button\"\n >\n {t('plugin-seo:autoGenerate')}\n </button>\n </React.Fragment>\n )}\n </div>\n <div\n style={{\n color: '#9A9A9A',\n }}\n >\n {t('plugin-seo:lengthTipTitle', { maxLength, minLength })}\n <a\n href=\"https://developers.google.com/search/docs/advanced/appearance/title-link#page-titles\"\n rel=\"noopener noreferrer\"\n target=\"_blank\"\n >\n {t('plugin-seo:bestPractices')}\n </a>\n .\n </div>\n </div>\n <div\n style={{\n marginBottom: '10px',\n position: 'relative',\n }}\n >\n <TextInput\n AfterInput={AfterInput}\n BeforeInput={BeforeInput}\n Error={errorMessage}\n onChange={setValue}\n path={path}\n required={required}\n showError={showError}\n style={{\n marginBottom: 0,\n }}\n value={value}\n />\n </div>\n <div\n style={{\n alignItems: 'center',\n display: 'flex',\n width: '100%',\n }}\n >\n <LengthIndicator maxLength={maxLength} minLength={minLength} text={value} />\n </div>\n </div>\n )\n}\n"],"names":["FieldLabel","TextInput","useConfig","useDocumentInfo","useField","useForm","useLocale","useTranslation","reduceToSerializableFields","React","useCallback","defaults","LengthIndicator","maxLength","maxLengthDefault","minLength","minLengthDefault","title","MetaTitleComponent","props","field","label","maxLengthFromProps","minLengthFromProps","required","hasGenerateTitleFn","path","t","config","routes","api","serverURL","customComponents","AfterInput","BeforeInput","Label","locale","getData","docInfo","errorMessage","setValue","showError","value","regenerateTitle","endpoint","genTitleResponse","fetch","body","JSON","stringify","id","collectionSlug","doc","docPermissions","globalSlug","hasPublishPermission","hasSavePermission","initialData","initialState","code","credentials","headers","method","result","generatedTitle","json","div","style","marginBottom","position","className","Fragment","button","onClick","background","backgroundColor","border","color","cursor","padding","textDecoration","type","a","href","rel","target","Error","onChange","alignItems","display","width","text"],"mappings":"AAAA;;AAKA,SACEA,UAAU,EACVC,SAAS,EACTC,SAAS,EACTC,eAAe,EACfC,QAAQ,EACRC,OAAO,EACPC,SAAS,EACTC,cAAc,QACT,iBAAgB;AACvB,SAASC,0BAA0B,QAAQ,wBAAuB;AAClE,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAK1C,SAASC,QAAQ,QAAQ,oBAAmB;AAC5C,SAASC,eAAe,QAAQ,8BAA6B;AAC7D,OAAO,gBAAe;AAEtB,MAAM,EAAEC,WAAWC,gBAAgB,EAAEC,WAAWC,gBAAgB,EAAE,GAAGL,SAASM,KAAK;AAMnF,OAAO,MAAMC,qBAA+C,CAACC;IAC3D,MAAM,EACJC,OAAO,EAAEC,KAAK,EAAER,WAAWS,kBAAkB,EAAEP,WAAWQ,kBAAkB,EAAEC,QAAQ,EAAE,EACxFC,kBAAkB,EAClBC,IAAI,EACL,GAAGP,SAAS,CAAC;IAEd,MAAM,EAAEQ,CAAC,EAAE,GAA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AgBC,WAAWA;oBAAWE,WAAWA;oBAAW4E,MAAMjD;;;;;AAI3E,EAAC"}
@@ -1,8 +1,16 @@
1
1
  import type { UIField } from 'payload';
2
2
  import React from 'react';
3
3
  type OverviewProps = {
4
+ descriptionOverrides?: {
5
+ maxLength?: number;
6
+ minLength?: number;
7
+ };
4
8
  descriptionPath?: string;
5
9
  imagePath?: string;
10
+ titleOverrides?: {
11
+ maxLength?: number;
12
+ minLength?: number;
13
+ };
6
14
  titlePath?: string;
7
15
  } & UIField;
8
16
  export declare const OverviewComponent: React.FC<OverviewProps>;
@@ -1 +1 @@
1
- {"version":3,"file":"OverviewComponent.d.ts","sourceRoot":"","sources":["../../../src/fields/Overview/OverviewComponent.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAa,OAAO,EAAE,MAAM,SAAS,CAAA;AAGjD,OAAO,KAA2C,MAAM,OAAO,CAAA;AAW/D,KAAK,aAAa,GAAG;IACnB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,GAAG,OAAO,CAAA;AAEX,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CA4DrD,CAAA"}
1
+ {"version":3,"file":"OverviewComponent.d.ts","sourceRoot":"","sources":["../../../src/fields/Overview/OverviewComponent.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAa,OAAO,EAAE,MAAM,SAAS,CAAA;AAGjD,OAAO,KAA2C,MAAM,OAAO,CAAA;AAW/D,KAAK,aAAa,GAAG;IACnB,oBAAoB,CAAC,EAAE;QACrB,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,SAAS,CAAC,EAAE,MAAM,CAAA;KACnB,CAAA;IACD,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,cAAc,CAAC,EAAE;QACf,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,SAAS,CAAC,EAAE,MAAM,CAAA;KACnB,CAAA;IACD,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,GAAG,OAAO,CAAA;AAEX,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAiErD,CAAA"}