@payloadcms/plugin-seo 3.0.0-beta.7 → 3.0.0-canary.0017c67

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 (46) hide show
  1. package/dist/defaults.js.map +1 -1
  2. package/dist/exports/types.d.ts +2 -0
  3. package/dist/exports/types.d.ts.map +1 -0
  4. package/dist/exports/types.js +3 -0
  5. package/dist/exports/types.js.map +1 -0
  6. package/dist/fields/MetaDescription.d.ts +1 -1
  7. package/dist/fields/MetaDescription.d.ts.map +1 -1
  8. package/dist/fields/MetaDescription.js +90 -71
  9. package/dist/fields/MetaDescription.js.map +1 -1
  10. package/dist/fields/MetaImage.d.ts +1 -1
  11. package/dist/fields/MetaImage.d.ts.map +1 -1
  12. package/dist/fields/MetaImage.js +91 -76
  13. package/dist/fields/MetaImage.js.map +1 -1
  14. package/dist/fields/MetaTitle.d.ts +1 -1
  15. package/dist/fields/MetaTitle.d.ts.map +1 -1
  16. package/dist/fields/MetaTitle.js +91 -71
  17. package/dist/fields/MetaTitle.js.map +1 -1
  18. package/dist/fields/index.scss +1 -1
  19. package/dist/index.d.ts +3 -4
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +53 -28
  22. package/dist/index.js.map +1 -1
  23. package/dist/translations/index.d.ts +25 -0
  24. package/dist/translations/index.d.ts.map +1 -1
  25. package/dist/translations/index.js +22 -0
  26. package/dist/translations/index.js.map +1 -1
  27. package/dist/translations/uk.json +22 -0
  28. package/dist/types.d.ts +6 -6
  29. package/dist/types.d.ts.map +1 -1
  30. package/dist/types.js.map +1 -1
  31. package/dist/ui/LengthIndicator.d.ts.map +1 -1
  32. package/dist/ui/LengthIndicator.js +62 -41
  33. package/dist/ui/LengthIndicator.js.map +1 -1
  34. package/dist/ui/Overview.d.ts.map +1 -1
  35. package/dist/ui/Overview.js +11 -8
  36. package/dist/ui/Overview.js.map +1 -1
  37. package/dist/ui/Pill.js +7 -3
  38. package/dist/ui/Pill.js.map +1 -1
  39. package/dist/ui/Preview.d.ts +1 -1
  40. package/dist/ui/Preview.d.ts.map +1 -1
  41. package/dist/ui/Preview.js +56 -38
  42. package/dist/ui/Preview.js.map +1 -1
  43. package/package.json +46 -31
  44. package/src/index.tsx +0 -293
  45. package/types.d.ts +0 -1
  46. package/types.js +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/defaults.ts"],"sourcesContent":["export const defaults = {\n description: {\n maxLength: 150,\n minLength: 100,\n },\n title: {\n maxLength: 60,\n minLength: 50,\n },\n}\n"],"names":["defaults","description","maxLength","minLength","title"],"rangeMappings":";;;;;;;;;","mappings":"AAAA,OAAO,MAAMA,WAAW;IACtBC,aAAa;QACXC,WAAW;QACXC,WAAW;IACb;IACAC,OAAO;QACLF,WAAW;QACXC,WAAW;IACb;AACF,EAAC"}
1
+ {"version":3,"sources":["../src/defaults.ts"],"sourcesContent":["export const defaults = {\n description: {\n maxLength: 150,\n minLength: 100,\n },\n title: {\n maxLength: 60,\n minLength: 50,\n },\n}\n"],"names":["defaults","description","maxLength","minLength","title"],"mappings":"AAAA,OAAO,MAAMA,WAAW;IACtBC,aAAa;QACXC,WAAW;QACXC,WAAW;IACb;IACAC,OAAO;QACLF,WAAW;QACXC,WAAW;IACb;AACF,EAAC"}
@@ -0,0 +1,2 @@
1
+ export type { GenerateDescription, GenerateImage, GenerateTitle, GenerateURL, Meta, SEOPluginConfig, } from '../types.js';
2
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/exports/types.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,mBAAmB,EACnB,aAAa,EACb,aAAa,EACb,WAAW,EACX,IAAI,EACJ,eAAe,GAChB,MAAM,aAAa,CAAA"}
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/exports/types.ts"],"sourcesContent":["export type {\n GenerateDescription,\n GenerateImage,\n GenerateTitle,\n GenerateURL,\n Meta,\n SEOPluginConfig,\n} from '../types.js'\n"],"names":[],"mappings":"AAAA,WAOoB"}
@@ -1,4 +1,4 @@
1
- import type { FormFieldBase } from '@payloadcms/ui/fields/shared';
1
+ import type { FormFieldBase } from '@payloadcms/ui';
2
2
  import React from 'react';
3
3
  type MetaDescriptionProps = FormFieldBase & {
4
4
  hasGenerateDescriptionFn: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"MetaDescription.d.ts","sourceRoot":"","sources":["../../src/fields/MetaDescription.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAWjE,OAAO,KAAsB,MAAM,OAAO,CAAA;AAU1C,KAAK,oBAAoB,GAAG,aAAa,GAAG;IAC1C,wBAAwB,EAAE,OAAO,CAAA;IACjC,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA+H1D,CAAA"}
1
+ {"version":3,"file":"MetaDescription.d.ts","sourceRoot":"","sources":["../../src/fields/MetaDescription.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAa,aAAa,EAAW,MAAM,gBAAgB,CAAA;AAYvE,OAAO,KAAsB,MAAM,OAAO,CAAA;AAW1C,KAAK,oBAAoB,GAAG,aAAa,GAAG;IAC1C,wBAAwB,EAAE,OAAO,CAAA;IACjC,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAoH1D,CAAA"}
@@ -1,18 +1,12 @@
1
1
  'use client';
2
- import { TextareaInput } from '@payloadcms/ui/fields/Textarea';
3
- import { FieldLabel } from '@payloadcms/ui/forms/FieldLabel';
4
- import { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider';
5
- import { useAllFormFields } from '@payloadcms/ui/forms/Form';
6
- import { useField } from '@payloadcms/ui/forms/useField';
7
- import { useDocumentInfo } from '@payloadcms/ui/providers/DocumentInfo';
8
- import { useLocale } from '@payloadcms/ui/providers/Locale';
9
- import { useTranslation } from '@payloadcms/ui/providers/Translation';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { FieldLabel, TextareaInput, useAllFormFields, useDocumentInfo, useField, useFieldProps, useLocale, useTranslation } from '@payloadcms/ui';
10
4
  import React, { useCallback } from 'react';
11
5
  import { defaults } from '../defaults.js';
12
6
  import { LengthIndicator } from '../ui/LengthIndicator.js';
13
7
  const { maxLength, minLength } = defaults.description;
14
8
  export const MetaDescription = (props)=>{
15
- const { CustomLabel, hasGenerateDescriptionFn, labelProps, path, required } = props;
9
+ const { CustomLabel, hasGenerateDescriptionFn, label, labelProps, path, required } = props;
16
10
  const { path: pathFromContext } = useFieldProps();
17
11
  const { t } = useTranslation();
18
12
  const locale = useLocale();
@@ -47,71 +41,96 @@ export const MetaDescription = (props)=>{
47
41
  locale,
48
42
  docInfo
49
43
  ]);
50
- return /*#__PURE__*/ React.createElement("div", {
44
+ return /*#__PURE__*/ _jsxs("div", {
51
45
  style: {
52
46
  marginBottom: '20px'
53
- }
54
- }, /*#__PURE__*/ React.createElement("div", {
55
- style: {
56
- marginBottom: '5px',
57
- position: 'relative'
58
- }
59
- }, /*#__PURE__*/ React.createElement("div", {
60
- className: "plugin-seo__field"
61
- }, CustomLabel !== undefined ? CustomLabel : /*#__PURE__*/ React.createElement(FieldLabel, labelProps || {}), required && /*#__PURE__*/ React.createElement("span", {
62
- style: {
63
- color: 'var(--theme-error-500)',
64
- marginLeft: '5px'
65
- }
66
- }, "*"), hasGenerateDescriptionFn && /*#__PURE__*/ React.createElement(React.Fragment, null, "  —  ", /*#__PURE__*/ React.createElement("button", {
67
- onClick: regenerateDescription,
68
- style: {
69
- background: 'none',
70
- backgroundColor: 'transparent',
71
- border: 'none',
72
- color: 'currentcolor',
73
- cursor: 'pointer',
74
- padding: 0,
75
- textDecoration: 'underline'
76
- },
77
- type: "button"
78
- }, t('plugin-seo:autoGenerate')))), /*#__PURE__*/ React.createElement("div", {
79
- style: {
80
- color: '#9A9A9A'
81
- }
82
- }, t('plugin-seo:lengthTipDescription', {
83
- maxLength,
84
- minLength
85
- }), /*#__PURE__*/ React.createElement("a", {
86
- href: "https://developers.google.com/search/docs/advanced/appearance/snippet#meta-descriptions",
87
- rel: "noopener noreferrer",
88
- target: "_blank"
89
- }, t('plugin-seo:bestPractices')))), /*#__PURE__*/ React.createElement("div", {
90
- style: {
91
- marginBottom: '10px',
92
- position: 'relative'
93
- }
94
- }, /*#__PURE__*/ React.createElement(TextareaInput, {
95
- CustomError: errorMessage,
96
- onChange: setValue,
97
- path: pathFromContext,
98
- required: required,
99
- showError: showError,
100
- style: {
101
- marginBottom: 0
102
47
  },
103
- value: value
104
- })), /*#__PURE__*/ React.createElement("div", {
105
- style: {
106
- alignItems: 'center',
107
- display: 'flex',
108
- width: '100%'
109
- }
110
- }, /*#__PURE__*/ React.createElement(LengthIndicator, {
111
- maxLength: maxLength,
112
- minLength: minLength,
113
- text: value
114
- })));
48
+ children: [
49
+ /*#__PURE__*/ _jsxs("div", {
50
+ style: {
51
+ marginBottom: '5px',
52
+ position: 'relative'
53
+ },
54
+ children: [
55
+ /*#__PURE__*/ _jsxs("div", {
56
+ className: "plugin-seo__field",
57
+ children: [
58
+ /*#__PURE__*/ _jsx(FieldLabel, {
59
+ CustomLabel: CustomLabel,
60
+ label: label,
61
+ ...labelProps || {}
62
+ }),
63
+ hasGenerateDescriptionFn && /*#__PURE__*/ _jsxs(React.Fragment, {
64
+ children: [
65
+ "  —  ",
66
+ /*#__PURE__*/ _jsx("button", {
67
+ onClick: regenerateDescription,
68
+ style: {
69
+ background: 'none',
70
+ backgroundColor: 'transparent',
71
+ border: 'none',
72
+ color: 'currentcolor',
73
+ cursor: 'pointer',
74
+ padding: 0,
75
+ textDecoration: 'underline'
76
+ },
77
+ type: "button",
78
+ children: t('plugin-seo:autoGenerate')
79
+ })
80
+ ]
81
+ })
82
+ ]
83
+ }),
84
+ /*#__PURE__*/ _jsxs("div", {
85
+ style: {
86
+ color: '#9A9A9A'
87
+ },
88
+ children: [
89
+ t('plugin-seo:lengthTipDescription', {
90
+ maxLength,
91
+ minLength
92
+ }),
93
+ /*#__PURE__*/ _jsx("a", {
94
+ href: "https://developers.google.com/search/docs/advanced/appearance/snippet#meta-descriptions",
95
+ rel: "noopener noreferrer",
96
+ target: "_blank",
97
+ children: t('plugin-seo:bestPractices')
98
+ })
99
+ ]
100
+ })
101
+ ]
102
+ }),
103
+ /*#__PURE__*/ _jsx("div", {
104
+ style: {
105
+ marginBottom: '10px',
106
+ position: 'relative'
107
+ },
108
+ children: /*#__PURE__*/ _jsx(TextareaInput, {
109
+ CustomError: errorMessage,
110
+ onChange: setValue,
111
+ path: pathFromContext,
112
+ required: required,
113
+ showError: showError,
114
+ style: {
115
+ marginBottom: 0
116
+ },
117
+ value: value
118
+ })
119
+ }),
120
+ /*#__PURE__*/ _jsx("div", {
121
+ style: {
122
+ alignItems: 'center',
123
+ display: 'flex',
124
+ width: '100%'
125
+ },
126
+ children: /*#__PURE__*/ _jsx(LengthIndicator, {
127
+ maxLength: maxLength,
128
+ minLength: minLength,
129
+ text: value
130
+ })
131
+ })
132
+ ]
133
+ });
115
134
  };
116
135
 
117
136
  //# sourceMappingURL=MetaDescription.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/fields/MetaDescription.tsx"],"sourcesContent":["'use client'\n\nimport type { FormFieldBase } from '@payloadcms/ui/fields/shared'\nimport type { FieldType, Options } from '@payloadcms/ui/forms/useField'\n\nimport { TextareaInput } from '@payloadcms/ui/fields/Textarea'\nimport { FieldLabel } from '@payloadcms/ui/forms/FieldLabel'\nimport { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider'\nimport { useAllFormFields } from '@payloadcms/ui/forms/Form'\nimport { useField } from '@payloadcms/ui/forms/useField'\nimport { useDocumentInfo } from '@payloadcms/ui/providers/DocumentInfo'\nimport { useLocale } from '@payloadcms/ui/providers/Locale'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport React, { useCallback } from 'react'\n\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\n// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\ntype MetaDescriptionProps = FormFieldBase & {\n hasGenerateDescriptionFn: boolean\n path: string\n}\n\nexport const MetaDescription: React.FC<MetaDescriptionProps> = (props) => {\n const { CustomLabel, hasGenerateDescriptionFn, labelProps, path, required } = props\n const { path: pathFromContext } = useFieldProps()\n\n const { t } = useTranslation()\n\n const locale = useLocale()\n const [fields] = useAllFormFields()\n const docInfo = useDocumentInfo()\n\n const field: FieldType<string> = useField({\n path,\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 ...docInfo,\n doc: { ...fields },\n locale: typeof locale === 'object' ? locale?.code : locale,\n } satisfies Parameters<GenerateDescription>[0]),\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 }, [fields, setValue, hasGenerateDescriptionFn, locale, docInfo])\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 {CustomLabel !== undefined ? CustomLabel : <FieldLabel {...(labelProps || {})} />}\n {required && (\n <span\n style={{\n color: 'var(--theme-error-500)',\n marginLeft: '5px',\n }}\n >\n *\n </span>\n )}\n\n {hasGenerateDescriptionFn && (\n <React.Fragment>\n &nbsp; &mdash; &nbsp;\n <button\n onClick={regenerateDescription}\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 CustomError={errorMessage}\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":["TextareaInput","FieldLabel","useFieldProps","useAllFormFields","useField","useDocumentInfo","useLocale","useTranslation","React","useCallback","defaults","LengthIndicator","maxLength","minLength","description","MetaDescription","props","CustomLabel","hasGenerateDescriptionFn","labelProps","path","required","pathFromContext","t","locale","fields","docInfo","field","errorMessage","setValue","showError","value","regenerateDescription","genDescriptionResponse","fetch","body","JSON","stringify","doc","code","credentials","headers","method","result","generatedDescription","json","div","style","marginBottom","position","className","undefined","span","color","marginLeft","Fragment","button","onClick","background","backgroundColor","border","cursor","padding","textDecoration","type","a","href","rel","target","CustomError","onChange","alignItems","display","width","text"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAKA,SAASA,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uBAAuBY,IAAI;QAE1EhB,SAASe,wBAAwB;IACnC,GAAG;QAACnB;QAAQI;QAAUX;QAA0BM;QAAQE;KAAQ;IAEhE,qBACE,oBAACoB;QACCC,OAAO;YACLC,cAAc;QAChB;qBAEA,oBAACF;QACCC,OAAO;YACLC,cAAc;YACdC,UAAU;QACZ;qBAEA,oBAACH;QAAII,WAAU;OACZjC,gBAAgBkC,YAAYlC,4BAAc,oBAAChB,YAAgBkB,cAAc,CAAC,IAC1EE,0BACC,oBAAC+B;QACCL,OAAO;YACLM,OAAO;YACPC,YAAY;QACd;OACD,MAKFpC,0CACC,oBAACV,MAAM+C,QAAQ,QAAC,uBAEd,oBAACC;QACCC,SAASzB;QACTe,OAAO;YACLW,YAAY;YACZC,iBAAiB;YACjBC,QAAQ;YACRP,OAAO;YACPQ,QAAQ;YACRC,SAAS;YACTC,gBAAgB;QAClB;QACAC,MAAK;OAEJzC,EAAE,6CAKX,oBAACuB;QACCC,OAAO;YACLM,OAAO;QACT;OAEC9B,EAAE,mCAAmC;QAAEX;QAAWC;IAAU,kBAC7D,oBAACoD;QACCC,MAAK;QACLC,KAAI;QACJC,QAAO;OAEN7C,EAAE,8CAIT,oBAACuB;QACCC,OAAO;YACLC,cAAc;YACdC,UAAU;QACZ;qBAEA,oBAACjD;QACCqE,aAAazC;QACb0C,UAAUzC;QACVT,MAAME;QACND,UAAUA;QACVS,WAAWA;QACXiB,OAAO;YACLC,cAAc;QAChB;QACAjB,OAAOA;uBAGX,oBAACe;QACCC,OAAO;YACLwB,YAAY;YACZC,SAAS;YACTC,OAAO;QACT;qBAEA,oBAAC9D;QAAgBC,WAAWA;QAAWC,WAAWA;QAAW6D,MAAM3C;;AAI3E,EAAC"}
1
+ {"version":3,"sources":["../../src/fields/MetaDescription.tsx"],"sourcesContent":["'use client'\n\nimport type { FieldType, FormFieldBase, Options } from '@payloadcms/ui'\n\nimport {\n FieldLabel,\n TextareaInput,\n useAllFormFields,\n useDocumentInfo,\n useField,\n useFieldProps,\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\n// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\ntype MetaDescriptionProps = FormFieldBase & {\n hasGenerateDescriptionFn: boolean\n path: string\n}\n\nexport const MetaDescription: React.FC<MetaDescriptionProps> = (props) => {\n const { CustomLabel, hasGenerateDescriptionFn, label, labelProps, path, required } = props\n const { path: pathFromContext } = useFieldProps()\n\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\n\n const locale = useLocale()\n const [fields] = useAllFormFields()\n const docInfo = useDocumentInfo()\n\n const field: FieldType<string> = useField({\n path,\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 ...docInfo,\n doc: { ...fields },\n locale: typeof locale === 'object' ? locale?.code : locale,\n } satisfies Parameters<GenerateDescription>[0]),\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 }, [fields, setValue, hasGenerateDescriptionFn, locale, docInfo])\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 CustomLabel={CustomLabel} label={label} {...(labelProps || {})} />\n {hasGenerateDescriptionFn && (\n <React.Fragment>\n &nbsp; &mdash; &nbsp;\n <button\n onClick={regenerateDescription}\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 CustomError={errorMessage}\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","useAllFormFields","useDocumentInfo","useField","useFieldProps","useLocale","useTranslation","React","useCallback","defaults","LengthIndicator","maxLength","minLength","description","MetaDescription","props","CustomLabel","hasGenerateDescriptionFn","label","labelProps","path","required","pathFromContext","t","locale","fields","docInfo","field","errorMessage","setValue","showError","value","regenerateDescription","genDescriptionResponse","fetch","body","JSON","stringify","doc","code","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","CustomError","onChange","alignItems","display","width","text"],"mappings":"AAAA;;AAIA,SACEA,UAAU,EACVC,aAAa,EACbC,gBAAgB,EAChBC,eAAe,EACfC,QAAQ,EACRC,aAAa,EACbC,SAAS,EACTC,cAAc,QACT,iBAAgB;AACvB,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAK1C,SAASC,QAAQ,QAAQ,iBAAgB;AACzC,SAASC,eAAe,QAAQ,2BAA0B;AAE1D,MAAM,EAAEC,SA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SAASrB;wCACTe,OAAO;4CACLO,YAAY;4CACZC,iBAAiB;4CACjBC,QAAQ;4CACRC,OAAO;4CACPC,QAAQ;4CACRC,SAAS;4CACTC,gBAAgB;wCAClB;wCACAC,MAAK;kDAEJtC,EAAE;;;;;;kCAKX,MAACuB;wBACCC,OAAO;4BACLU,OAAO;wBACT;;4BAEClC,EAAE,mCAAmC;gCAAEZ;gCAAWC;4BAAU;0CAC7D,KAACkD;gCACCC,MAAK;gCACLC,KAAI;gCACJC,QAAO;0CAEN1C,EAAE;;;;;;0BAIT,KAACuB;gBACCC,OAAO;oBACLC,cAAc;oBACdC,UAAU;gBACZ;0BAEA,cAAA,KAACjD;oBACCkE,aAAatC;oBACbuC,UAAUtC;oBACVT,MAAME;oBACND,UAAUA;oBACVS,WAAWA;oBACXiB,OAAO;wBACLC,cAAc;oBAChB;oBACAjB,OAAOA;;;0BAGX,KAACe;gBACCC,OAAO;oBACLqB,YAAY;oBACZC,SAAS;oBACTC,OAAO;gBACT;0BAEA,cAAA,KAAC5D;oBAAgBC,WAAWA;oBAAWC,WAAWA;oBAAW2D,MAAMxC;;;;;AAI3E,EAAC"}
@@ -1,4 +1,4 @@
1
- import type { UploadInputProps } from '@payloadcms/ui/fields/Upload';
1
+ import type { UploadInputProps } from '@payloadcms/ui';
2
2
  import React from 'react';
3
3
  type MetaImageProps = UploadInputProps & {
4
4
  hasGenerateImageFn: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"MetaImage.d.ts","sourceRoot":"","sources":["../../src/fields/MetaImage.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAWpE,OAAO,KAAsB,MAAM,OAAO,CAAA;AAO1C,KAAK,cAAc,GAAG,gBAAgB,GAAG;IACvC,kBAAkB,EAAE,OAAO,CAAA;CAC5B,CAAA;AAED,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CA8I9C,CAAA"}
1
+ {"version":3,"file":"MetaImage.d.ts","sourceRoot":"","sources":["../../src/fields/MetaImage.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAsB,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAY1E,OAAO,KAAsB,MAAM,OAAO,CAAA;AAQ1C,KAAK,cAAc,GAAG,gBAAgB,GAAG;IACvC,kBAAkB,EAAE,OAAO,CAAA;CAC5B,CAAA;AAED,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAoI9C,CAAA"}
@@ -1,16 +1,10 @@
1
1
  'use client';
2
- import { UploadInput } from '@payloadcms/ui/fields/Upload';
3
- import { FieldLabel } from '@payloadcms/ui/forms/FieldLabel';
4
- import { useAllFormFields } from '@payloadcms/ui/forms/Form';
5
- import { useField } from '@payloadcms/ui/forms/useField';
6
- import { useConfig } from '@payloadcms/ui/providers/Config';
7
- import { useDocumentInfo } from '@payloadcms/ui/providers/DocumentInfo';
8
- import { useLocale } from '@payloadcms/ui/providers/Locale';
9
- import { useTranslation } from '@payloadcms/ui/providers/Translation';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { FieldLabel, UploadInput, useAllFormFields, useConfig, useDocumentInfo, useField, useLocale, useTranslation } from '@payloadcms/ui';
10
4
  import React, { useCallback } from 'react';
11
5
  import { Pill } from '../ui/Pill.js';
12
6
  export const MetaImage = (props)=>{
13
- const { CustomLabel, hasGenerateImageFn, labelProps, relationTo, required } = props || {};
7
+ const { CustomLabel, hasGenerateImageFn, label, labelProps, relationTo, required } = props || {};
14
8
  const field = useField(props);
15
9
  const { t } = useTranslation();
16
10
  const locale = useLocale();
@@ -46,76 +40,97 @@ export const MetaImage = (props)=>{
46
40
  const config = useConfig();
47
41
  const { collections, routes: { api } = {}, serverURL } = config;
48
42
  const collection = collections?.find((coll)=>coll.slug === relationTo) || undefined;
49
- return /*#__PURE__*/ React.createElement("div", {
43
+ return /*#__PURE__*/ _jsxs("div", {
50
44
  style: {
51
45
  marginBottom: '20px'
52
- }
53
- }, /*#__PURE__*/ React.createElement("div", {
54
- style: {
55
- marginBottom: '5px',
56
- position: 'relative'
57
- }
58
- }, /*#__PURE__*/ React.createElement("div", {
59
- className: "plugin-seo__field"
60
- }, CustomLabel !== undefined ? CustomLabel : /*#__PURE__*/ React.createElement(FieldLabel, labelProps || {}), required && /*#__PURE__*/ React.createElement("span", {
61
- style: {
62
- color: 'var(--theme-error-500)',
63
- marginLeft: '5px'
64
- }
65
- }, "*"), hasGenerateImageFn && /*#__PURE__*/ React.createElement(React.Fragment, null, "  —  ", /*#__PURE__*/ React.createElement("button", {
66
- onClick: regenerateImage,
67
- style: {
68
- background: 'none',
69
- backgroundColor: 'transparent',
70
- border: 'none',
71
- color: 'currentcolor',
72
- cursor: 'pointer',
73
- padding: 0,
74
- textDecoration: 'underline'
75
- },
76
- type: "button"
77
- }, t('plugin-seo:autoGenerate')))), hasGenerateImageFn && /*#__PURE__*/ React.createElement("div", {
78
- style: {
79
- color: '#9A9A9A'
80
- }
81
- }, t('plugin-seo:imageAutoGenerationTip'))), /*#__PURE__*/ React.createElement("div", {
82
- style: {
83
- marginBottom: '10px',
84
- position: 'relative'
85
- }
86
- }, /*#__PURE__*/ React.createElement(UploadInput, {
87
- CustomError: errorMessage,
88
- api: api,
89
- collection: collection,
90
- filterOptions: {},
91
- label: undefined,
92
- onChange: (incomingImage)=>{
93
- if (incomingImage !== null) {
94
- const { id: incomingID } = incomingImage;
95
- setValue(incomingID);
96
- } else {
97
- setValue(null);
98
- }
99
- },
100
- relationTo: relationTo,
101
- required: required,
102
- serverURL: serverURL,
103
- showError: showError,
104
- style: {
105
- marginBottom: 0
106
46
  },
107
- value: value
108
- })), /*#__PURE__*/ React.createElement("div", {
109
- style: {
110
- alignItems: 'center',
111
- display: 'flex',
112
- width: '100%'
113
- }
114
- }, /*#__PURE__*/ React.createElement(Pill, {
115
- backgroundColor: hasImage ? 'green' : 'red',
116
- color: "white",
117
- label: hasImage ? t('plugin-seo:good') : t('plugin-seo:noImage')
118
- })));
47
+ children: [
48
+ /*#__PURE__*/ _jsxs("div", {
49
+ style: {
50
+ marginBottom: '5px',
51
+ position: 'relative'
52
+ },
53
+ children: [
54
+ /*#__PURE__*/ _jsxs("div", {
55
+ className: "plugin-seo__field",
56
+ children: [
57
+ /*#__PURE__*/ _jsx(FieldLabel, {
58
+ CustomLabel: CustomLabel,
59
+ label: label,
60
+ ...labelProps || {}
61
+ }),
62
+ hasGenerateImageFn && /*#__PURE__*/ _jsxs(React.Fragment, {
63
+ children: [
64
+ "  —  ",
65
+ /*#__PURE__*/ _jsx("button", {
66
+ onClick: regenerateImage,
67
+ style: {
68
+ background: 'none',
69
+ backgroundColor: 'transparent',
70
+ border: 'none',
71
+ color: 'currentcolor',
72
+ cursor: 'pointer',
73
+ padding: 0,
74
+ textDecoration: 'underline'
75
+ },
76
+ type: "button",
77
+ children: t('plugin-seo:autoGenerate')
78
+ })
79
+ ]
80
+ })
81
+ ]
82
+ }),
83
+ hasGenerateImageFn && /*#__PURE__*/ _jsx("div", {
84
+ style: {
85
+ color: '#9A9A9A'
86
+ },
87
+ children: t('plugin-seo:imageAutoGenerationTip')
88
+ })
89
+ ]
90
+ }),
91
+ /*#__PURE__*/ _jsx("div", {
92
+ style: {
93
+ marginBottom: '10px',
94
+ position: 'relative'
95
+ },
96
+ children: /*#__PURE__*/ _jsx(UploadInput, {
97
+ CustomError: errorMessage,
98
+ api: api,
99
+ collection: collection,
100
+ filterOptions: field.filterOptions,
101
+ label: undefined,
102
+ onChange: (incomingImage)=>{
103
+ if (incomingImage !== null) {
104
+ const { id: incomingID } = incomingImage;
105
+ setValue(incomingID);
106
+ } else {
107
+ setValue(null);
108
+ }
109
+ },
110
+ relationTo: relationTo,
111
+ required: required,
112
+ serverURL: serverURL,
113
+ showError: showError,
114
+ style: {
115
+ marginBottom: 0
116
+ },
117
+ value: value
118
+ })
119
+ }),
120
+ /*#__PURE__*/ _jsx("div", {
121
+ style: {
122
+ alignItems: 'center',
123
+ display: 'flex',
124
+ width: '100%'
125
+ },
126
+ children: /*#__PURE__*/ _jsx(Pill, {
127
+ backgroundColor: hasImage ? 'green' : 'red',
128
+ color: "white",
129
+ label: hasImage ? t('plugin-seo:good') : t('plugin-seo:noImage')
130
+ })
131
+ })
132
+ ]
133
+ });
119
134
  };
120
135
 
121
136
  //# sourceMappingURL=MetaImage.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/fields/MetaImage.tsx"],"sourcesContent":["'use client'\n\nimport type { UploadInputProps } from '@payloadcms/ui/fields/Upload'\nimport type { FieldType, Options } from '@payloadcms/ui/forms/useField'\n\nimport { UploadInput } from '@payloadcms/ui/fields/Upload'\nimport { FieldLabel } from '@payloadcms/ui/forms/FieldLabel'\nimport { useAllFormFields } from '@payloadcms/ui/forms/Form'\nimport { useField } from '@payloadcms/ui/forms/useField'\nimport { useConfig } from '@payloadcms/ui/providers/Config'\nimport { useDocumentInfo } from '@payloadcms/ui/providers/DocumentInfo'\nimport { useLocale } from '@payloadcms/ui/providers/Locale'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport React, { useCallback } from 'react'\n\nimport type { GenerateImage } from '../types.js'\n\nimport { Pill } from '../ui/Pill.js'\n\n// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\ntype MetaImageProps = UploadInputProps & {\n hasGenerateImageFn: boolean\n}\n\nexport const MetaImage: React.FC<MetaImageProps> = (props) => {\n const { CustomLabel, hasGenerateImageFn, labelProps, relationTo, required } = props || {}\n\n const field: FieldType<string> = useField(props as Options)\n\n const { t } = useTranslation()\n\n const locale = useLocale()\n const [fields] = useAllFormFields()\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 ...docInfo,\n doc: { ...fields },\n locale: typeof locale === 'object' ? locale?.code : locale,\n } satisfies Parameters<GenerateImage>[0]),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n const { result: generatedImage } = await genImageResponse.json()\n\n setValue(generatedImage || '')\n }, [fields, setValue, hasGenerateImageFn, locale, docInfo])\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 {CustomLabel !== undefined ? CustomLabel : <FieldLabel {...(labelProps || {})} />}\n {required && (\n <span\n style={{\n color: 'var(--theme-error-500)',\n marginLeft: '5px',\n }}\n >\n *\n </span>\n )}\n {hasGenerateImageFn && (\n <React.Fragment>\n &nbsp; &mdash; &nbsp;\n <button\n onClick={regenerateImage}\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 CustomError={errorMessage}\n api={api}\n collection={collection}\n 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":["UploadInput","FieldLabel","useAllFormFields","useField","useConfig","useDocumentInfo","useLocale","useTranslation","React","useCallback","Pill","MetaImage","props","CustomLabel","hasGenerateImageFn","labelProps","relationTo","required","field","t","locale","fields","docInfo","errorMessage","setValue","showError","value","regenerateImage","genImageResponse","fetch","body","JSON","stringify","doc","code","credentials","headers","method","result","generatedImage","json","hasImage","Boolean","config","collections","routes","api","serverURL","collection","find","coll","slug","undefined","div","style","marginBottom","position","className","span","color","marginLeft","Fragment","button","onClick","background","backgroundColor","border","cursor","padding","textDecoration","type","CustomError","filterOptions","label","onChange","incomingImage","id","incomingID","alignItems","display","width"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAKA,SAASA,WAAW,QAAQ,+BAA8B;AAC1D,SAASC,UAAU,QAAQ,kCAAiC;AAC5D,SAASC,gBAAgB,QAAQ,4BAA2B;AAC5D,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,eAAe,QAAQ,wCAAuC;AACvE,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,cAAc,QAAQ,uCAAsC;AACrE,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAI1C,SAASC,IAAI,QAAQ,gBAAe;AAOpC,OAAO,MAAMC,YAAsC,CAACC;IAClD,MAAM,EAAEC,WAAW,EAAEC,kBAAkB,EAAEC,UAAU,EAAEC,UAAU,EAAEC,QAAQ,EAAE,GAAGL,SAAS,CAAC;IAExF,MAAMM,QAA2Bf,SAASS;IAE1C,MAAM,EAAEO,CAAC,EAAE,GAAGZ;IAEd,MAAMa,SAASd;IAC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RP,OAAO;YACPQ,QAAQ;YACRC,SAAS;YACTC,gBAAgB;QAClB;QACAC,MAAK;OAEJnD,EAAE,+BAKVL,oCACC,oBAACuC;QACCC,OAAO;YACLK,OAAO;QACT;OAECxC,EAAE,sDAIT,oBAACkC;QACCC,OAAO;YACLC,cAAc;YACdC,UAAU;QACZ;qBAEA,oBAACxD;QACCuE,aAAahD;QACbuB,KAAKA;QACLE,YAAYA;QACZwB,eAAe,CAAC;QAChBC,OAAOrB;QACPsB,UAAU,CAACC;YACT,IAAIA,kBAAkB,MAAM;gBAC1B,MAAM,EAAEC,IAAIC,UAAU,EAAE,GAAGF;gBAC3BnD,SAASqD;YACX,OAAO;gBACLrD,SAAS;YACX;QACF;QACAR,YAAYA;QACZC,UAAUA;QACV8B,WAAWA;QACXtB,WAAWA;QACX6B,OAAO;YACLC,cAAc;QAChB;QACA7B,OAAOA;uBAGX,oBAAC2B;QACCC,OAAO;YACLwB,YAAY;YACZC,SAAS;YACTC,OAAO;QACT;qBAEA,oBAACtE;QACCuD,iBAAiBxB,WAAW,UAAU;QACtCkB,OAAM;QACNc,OAAOhC,WAAWtB,EAAE,qBAAqBA,EAAE;;AAKrD,EAAC"}
1
+ {"version":3,"sources":["../../src/fields/MetaImage.tsx"],"sourcesContent":["'use client'\n\nimport type { FieldType, Options, UploadInputProps } from '@payloadcms/ui'\n\nimport {\n FieldLabel,\n UploadInput,\n useAllFormFields,\n useConfig,\n useDocumentInfo,\n useField,\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\n// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\ntype MetaImageProps = UploadInputProps & {\n hasGenerateImageFn: boolean\n}\n\nexport const MetaImage: React.FC<MetaImageProps> = (props) => {\n const { CustomLabel, hasGenerateImageFn, label, labelProps, relationTo, required } = props || {}\n\n const field: FieldType<string> = useField(props as Options)\n\n const { t } = useTranslation<PluginSEOTranslations, PluginSEOTranslationKeys>()\n\n const locale = useLocale()\n const [fields] = useAllFormFields()\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 ...docInfo,\n doc: { ...fields },\n locale: typeof locale === 'object' ? locale?.code : locale,\n } satisfies Parameters<GenerateImage>[0]),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n const { result: generatedImage } = await genImageResponse.json()\n\n setValue(generatedImage || '')\n }, [fields, setValue, hasGenerateImageFn, locale, docInfo])\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 CustomLabel={CustomLabel} label={label} {...(labelProps || {})} />\n {hasGenerateImageFn && (\n <React.Fragment>\n &nbsp; &mdash; &nbsp;\n <button\n onClick={regenerateImage}\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 CustomError={errorMessage}\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","useAllFormFields","useConfig","useDocumentInfo","useField","useLocale","useTranslation","React","useCallback","Pill","MetaImage","props","CustomLabel","hasGenerateImageFn","label","labelProps","relationTo","required","field","t","locale","fields","docInfo","errorMessage","setValue","showError","value","regenerateImage","genImageResponse","fetch","body","JSON","stringify","doc","code","credentials","headers","method","result","generatedImage","json","hasImage","Boolean","config","collections","routes","api","serverURL","collection","find","coll","slug","undefined","div","style","marginBottom","position","className","Fragment","button","onClick","background","backgroundColor","border","color","cursor","padding","textDecoration","type","CustomError","filterOptions","onChange","incomingImage","id","incomingID","alignItems","display","width"],"mappings":"AAAA;;AAIA,SACEA,UAAU,EACVC,WAAW,EACXC,gBAAgB,EAChBC,SAAS,EACTC,eAAe,EACfC,QAAQ,EACRC,SAAS,EACTC,cAAc,QACT,iBAAgB;AACvB,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAK1C,SAASC,IAAI,QAAQ,gBAAe;AAOpC,OAAO,MAAMC,YAAsC,CAACC;IAClD,MAAM,EAAEC,WAAW,EAAEC,kBAAkB,EAAEC,KAAK,EAAEC,UAAU,EAAEC,UAAU,EAAEC,QAAQ,EAAE,GAAGN,SAAS,CAAC;IAE/F,MAAMO,QAA2Bd,SAASO;IAE1C,MAAM,EAAEQ,CAAC,EAAE,GAAGb;IAEd,MAAMc,SAASf;IACf,MAAM,CAACgB,OAAO,GAAGpB;IACjB,MAAMqB,UAAUnB;IAEhB,M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VN,oCACC,KAACwC;wBACCC,OAAO;4BACLU,OAAO;wBACT;kCAEC7C,EAAE;;;;0BAIT,KAACkC;gBACCC,OAAO;oBACLC,cAAc;oBACdC,UAAU;gBACZ;0BAEA,cAAA,KAACxD;oBACCqE,aAAa9C;oBACbuB,KAAKA;oBACLE,YAAYA;oBACZsB,eAAepD,MAAMoD,aAAa;oBAClCxD,OAAOsC;oBACPmB,UAAU,CAACC;wBACT,IAAIA,kBAAkB,MAAM;4BAC1B,MAAM,EAAEC,IAAIC,UAAU,EAAE,GAAGF;4BAC3BhD,SAASkD;wBACX,OAAO;4BACLlD,SAAS;wBACX;oBACF;oBACAR,YAAYA;oBACZC,UAAUA;oBACV8B,WAAWA;oBACXtB,WAAWA;oBACX6B,OAAO;wBACLC,cAAc;oBAChB;oBACA7B,OAAOA;;;0BAGX,KAAC2B;gBACCC,OAAO;oBACLqB,YAAY;oBACZC,SAAS;oBACTC,OAAO;gBACT;0BAEA,cAAA,KAACpE;oBACCqD,iBAAiBrB,WAAW,UAAU;oBACtCuB,OAAM;oBACNlD,OAAO2B,WAAWtB,EAAE,qBAAqBA,EAAE;;;;;AAKrD,EAAC"}
@@ -1,4 +1,4 @@
1
- import type { FormFieldBase } from '@payloadcms/ui/fields/shared';
1
+ import type { FormFieldBase } from '@payloadcms/ui';
2
2
  import React from 'react';
3
3
  import './index.scss';
4
4
  type MetaTitleProps = FormFieldBase & {
@@ -1 +1 @@
1
- {"version":3,"file":"MetaTitle.d.ts","sourceRoot":"","sources":["../../src/fields/MetaTitle.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAYjE,OAAO,KAAsB,MAAM,OAAO,CAAA;AAM1C,OAAO,cAAc,CAAA;AAKrB,KAAK,cAAc,GAAG,aAAa,GAAG;IACpC,kBAAkB,EAAE,OAAO,CAAA;CAC5B,CAAA;AAED,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CA+H9C,CAAA"}
1
+ {"version":3,"file":"MetaTitle.d.ts","sourceRoot":"","sources":["../../src/fields/MetaTitle.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAa,aAAa,EAAW,MAAM,gBAAgB,CAAA;AAYvE,OAAO,KAAsB,MAAM,OAAO,CAAA;AAO1C,OAAO,cAAc,CAAA;AAKrB,KAAK,cAAc,GAAG,aAAa,GAAG;IACpC,kBAAkB,EAAE,OAAO,CAAA;CAC5B,CAAA;AAED,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAqH9C,CAAA"}