@payloadcms/plugin-seo 3.0.0-canary.6041f49 → 3.0.0-canary.6659da8

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.
@@ -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,CAoH1D,CAAA"}
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;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,6 +1,7 @@
1
1
  'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { FieldLabel } from '@payloadcms/ui/fields/FieldLabel';
2
4
  import { TextareaInput } from '@payloadcms/ui/fields/Textarea';
3
- import { FieldLabel } from '@payloadcms/ui/forms/FieldLabel';
4
5
  import { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider';
5
6
  import { useAllFormFields } from '@payloadcms/ui/forms/Form';
6
7
  import { useField } from '@payloadcms/ui/forms/useField';
@@ -47,70 +48,96 @@ export const MetaDescription = (props)=>{
47
48
  locale,
48
49
  docInfo
49
50
  ]);
50
- return /*#__PURE__*/ React.createElement("div", {
51
+ return /*#__PURE__*/ _jsxs("div", {
51
52
  style: {
52
53
  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
- }, /*#__PURE__*/ React.createElement(FieldLabel, {
62
- CustomLabel: CustomLabel,
63
- label: label,
64
- ...labelProps || {}
65
- }), hasGenerateDescriptionFn && /*#__PURE__*/ React.createElement(React.Fragment, null, "  —  ", /*#__PURE__*/ React.createElement("button", {
66
- onClick: regenerateDescription,
67
- style: {
68
- background: 'none',
69
- backgroundColor: 'transparent',
70
- border: 'none',
71
- color: 'currentcolor',
72
- cursor: 'pointer',
73
- padding: 0,
74
- textDecoration: 'underline'
75
54
  },
76
- type: "button"
77
- }, t('plugin-seo:autoGenerate')))), /*#__PURE__*/ React.createElement("div", {
78
- style: {
79
- color: '#9A9A9A'
80
- }
81
- }, t('plugin-seo:lengthTipDescription', {
82
- maxLength,
83
- minLength
84
- }), /*#__PURE__*/ React.createElement("a", {
85
- href: "https://developers.google.com/search/docs/advanced/appearance/snippet#meta-descriptions",
86
- rel: "noopener noreferrer",
87
- target: "_blank"
88
- }, t('plugin-seo:bestPractices')))), /*#__PURE__*/ React.createElement("div", {
89
- style: {
90
- marginBottom: '10px',
91
- position: 'relative'
92
- }
93
- }, /*#__PURE__*/ React.createElement(TextareaInput, {
94
- CustomError: errorMessage,
95
- onChange: setValue,
96
- path: pathFromContext,
97
- required: required,
98
- showError: showError,
99
- style: {
100
- marginBottom: 0
101
- },
102
- value: value
103
- })), /*#__PURE__*/ React.createElement("div", {
104
- style: {
105
- alignItems: 'center',
106
- display: 'flex',
107
- width: '100%'
108
- }
109
- }, /*#__PURE__*/ React.createElement(LengthIndicator, {
110
- maxLength: maxLength,
111
- minLength: minLength,
112
- text: value
113
- })));
55
+ children: [
56
+ /*#__PURE__*/ _jsxs("div", {
57
+ style: {
58
+ marginBottom: '5px',
59
+ position: 'relative'
60
+ },
61
+ children: [
62
+ /*#__PURE__*/ _jsxs("div", {
63
+ className: "plugin-seo__field",
64
+ children: [
65
+ /*#__PURE__*/ _jsx(FieldLabel, {
66
+ CustomLabel: CustomLabel,
67
+ label: label,
68
+ ...labelProps || {}
69
+ }),
70
+ hasGenerateDescriptionFn && /*#__PURE__*/ _jsxs(React.Fragment, {
71
+ children: [
72
+ "  —  ",
73
+ /*#__PURE__*/ _jsx("button", {
74
+ onClick: regenerateDescription,
75
+ style: {
76
+ background: 'none',
77
+ backgroundColor: 'transparent',
78
+ border: 'none',
79
+ color: 'currentcolor',
80
+ cursor: 'pointer',
81
+ padding: 0,
82
+ textDecoration: 'underline'
83
+ },
84
+ type: "button",
85
+ children: t('plugin-seo:autoGenerate')
86
+ })
87
+ ]
88
+ })
89
+ ]
90
+ }),
91
+ /*#__PURE__*/ _jsxs("div", {
92
+ style: {
93
+ color: '#9A9A9A'
94
+ },
95
+ children: [
96
+ t('plugin-seo:lengthTipDescription', {
97
+ maxLength,
98
+ minLength
99
+ }),
100
+ /*#__PURE__*/ _jsx("a", {
101
+ href: "https://developers.google.com/search/docs/advanced/appearance/snippet#meta-descriptions",
102
+ rel: "noopener noreferrer",
103
+ target: "_blank",
104
+ children: t('plugin-seo:bestPractices')
105
+ })
106
+ ]
107
+ })
108
+ ]
109
+ }),
110
+ /*#__PURE__*/ _jsx("div", {
111
+ style: {
112
+ marginBottom: '10px',
113
+ position: 'relative'
114
+ },
115
+ children: /*#__PURE__*/ _jsx(TextareaInput, {
116
+ CustomError: errorMessage,
117
+ onChange: setValue,
118
+ path: pathFromContext,
119
+ required: required,
120
+ showError: showError,
121
+ style: {
122
+ marginBottom: 0
123
+ },
124
+ value: value
125
+ })
126
+ }),
127
+ /*#__PURE__*/ _jsx("div", {
128
+ style: {
129
+ alignItems: 'center',
130
+ display: 'flex',
131
+ width: '100%'
132
+ },
133
+ children: /*#__PURE__*/ _jsx(LengthIndicator, {
134
+ maxLength: maxLength,
135
+ minLength: minLength,
136
+ text: value
137
+ })
138
+ })
139
+ ]
140
+ });
114
141
  };
115
142
 
116
143
  //# 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, label, 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 <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":["TextareaInput","FieldLabel","useFieldProps","useAllFormFields","useField","useDocumentInfo","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"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAKA,SAASA,aAAa,QAAQ,iCAAgC;AAC9D,SAASC,UAAU,QAAQ,kCAAiC;AAC5D,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,gBAAgB,QAAQ,4BAA2B;AAC5D,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,eAAe,QAAQ,wCAAuC;AACvE,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,cAAc,QAAQ,uCAAsC;AACrE,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAI1C,SAASC,QAAQ,QAAQ,iBAAgB;AACzC,SAASC,eAAe,QAAQ,2BAA0B;AAE1D,MAAM,EAAEC,SAAS,EAAEC,SAAS,EAAE,GAAGH,SAASI,WAAW;AAQrD,OAAO,MAAMC,kBAAkD,CAACC;IAC9D,MAAM,EAAEC,WAAW,EAAEC,wBAAwB,EAAEC,KAAK,EAAEC,UAAU,EAAEC,IAAI,EAAEC,QAAQ,EAAE,GAAGN;IACrF,MAAM,EAAEK,MAAME,eAAe,EAAE,GAAGrB;IAElC,MAAM,EAAEsB,CAAC,EAAE,GAAGjB;IAEd,MAAMkB,SAASnB;IACf,MAAM,CAACoB,OAAO,GAAGvB;IACjB,MAAMwB,UAAUtB;IAEhB,MAAMuB,QAA2BxB,SA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buC,UAAUtC;QACVT,MAAME;QACND,UAAUA;QACVS,WAAWA;QACXiB,OAAO;YACLC,cAAc;QAChB;QACAjB,OAAOA;uBAGX,oBAACe;QACCC,OAAO;YACLqB,YAAY;YACZC,SAAS;YACTC,OAAO;QACT;qBAEA,oBAAC5D;QAAgBC,WAAWA;QAAWC,WAAWA;QAAW2D,MAAMxC;;AAI3E,EAAC"}
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 { FieldLabel } from '@payloadcms/ui/fields/FieldLabel'\nimport { TextareaInput } from '@payloadcms/ui/fields/Textarea'\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 { 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","useFieldProps","useAllFormFields","useField","useDocumentInfo","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"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AAKA,SAASA,UAAU,QAAQ,mCAAkC;AAC7D,SAASC,aAAa,QAAQ,iCAAgC;AAC9D,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,gBAAgB,QAAQ,4BAA2B;AAC5D,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,eAAe,QAAQ,wCAAuC;AACvE,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,cAAc,QAAQ,uCAAsC;AACrE,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAK1C,SAASC,QAAQ,QAAQ,iBAAgB;AACzC,SAASC,eAAe,QAAQ,2BAA0B;AAE1D,MAAM,EAAEC,SAAS,EAAEC,SAAS,EAAE,GAAGH,SAASI,WAAW;AAQrD,OAAO,MAAMC,kBAAkD,CAACC;IAC9D,MAAM,EAAEC,WAAW,EAAEC,wBAAwB,EAAEC,KAAK,EAAEC,UAAU,EAAEC,IAAI,EAAEC,QAAQ,EAAE,GAAGN;IACrF,MAAM,EAAEK,MAAME,eAAe,EAAE,GAAGrB;IAElC,MAAM,E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CAAWC;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 +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,CAoI9C,CAAA"}
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;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,6 +1,7 @@
1
1
  'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { FieldLabel } from '@payloadcms/ui/fields/FieldLabel';
2
4
  import { UploadInput } from '@payloadcms/ui/fields/Upload';
3
- import { FieldLabel } from '@payloadcms/ui/forms/FieldLabel';
4
5
  import { useAllFormFields } from '@payloadcms/ui/forms/Form';
5
6
  import { useField } from '@payloadcms/ui/forms/useField';
6
7
  import { useConfig } from '@payloadcms/ui/providers/Config';
@@ -46,75 +47,97 @@ export const MetaImage = (props)=>{
46
47
  const config = useConfig();
47
48
  const { collections, routes: { api } = {}, serverURL } = config;
48
49
  const collection = collections?.find((coll)=>coll.slug === relationTo) || undefined;
49
- return /*#__PURE__*/ React.createElement("div", {
50
+ return /*#__PURE__*/ _jsxs("div", {
50
51
  style: {
51
52
  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
- }, /*#__PURE__*/ React.createElement(FieldLabel, {
61
- CustomLabel: CustomLabel,
62
- label: label,
63
- ...labelProps || {}
64
- }), hasGenerateImageFn && /*#__PURE__*/ React.createElement(React.Fragment, null, "  —  ", /*#__PURE__*/ React.createElement("button", {
65
- onClick: regenerateImage,
66
- style: {
67
- background: 'none',
68
- backgroundColor: 'transparent',
69
- border: 'none',
70
- color: 'currentcolor',
71
- cursor: 'pointer',
72
- padding: 0,
73
- textDecoration: 'underline'
74
- },
75
- type: "button"
76
- }, t('plugin-seo:autoGenerate')))), hasGenerateImageFn && /*#__PURE__*/ React.createElement("div", {
77
- style: {
78
- color: '#9A9A9A'
79
- }
80
- }, t('plugin-seo:imageAutoGenerationTip'))), /*#__PURE__*/ React.createElement("div", {
81
- style: {
82
- marginBottom: '10px',
83
- position: 'relative'
84
- }
85
- }, /*#__PURE__*/ React.createElement(UploadInput, {
86
- CustomError: errorMessage,
87
- api: api,
88
- collection: collection,
89
- filterOptions: {},
90
- label: undefined,
91
- onChange: (incomingImage)=>{
92
- if (incomingImage !== null) {
93
- const { id: incomingID } = incomingImage;
94
- setValue(incomingID);
95
- } else {
96
- setValue(null);
97
- }
98
- },
99
- relationTo: relationTo,
100
- required: required,
101
- serverURL: serverURL,
102
- showError: showError,
103
- style: {
104
- marginBottom: 0
105
53
  },
106
- value: value
107
- })), /*#__PURE__*/ React.createElement("div", {
108
- style: {
109
- alignItems: 'center',
110
- display: 'flex',
111
- width: '100%'
112
- }
113
- }, /*#__PURE__*/ React.createElement(Pill, {
114
- backgroundColor: hasImage ? 'green' : 'red',
115
- color: "white",
116
- label: hasImage ? t('plugin-seo:good') : t('plugin-seo:noImage')
117
- })));
54
+ children: [
55
+ /*#__PURE__*/ _jsxs("div", {
56
+ style: {
57
+ marginBottom: '5px',
58
+ position: 'relative'
59
+ },
60
+ children: [
61
+ /*#__PURE__*/ _jsxs("div", {
62
+ className: "plugin-seo__field",
63
+ children: [
64
+ /*#__PURE__*/ _jsx(FieldLabel, {
65
+ CustomLabel: CustomLabel,
66
+ label: label,
67
+ ...labelProps || {}
68
+ }),
69
+ hasGenerateImageFn && /*#__PURE__*/ _jsxs(React.Fragment, {
70
+ children: [
71
+ "  —  ",
72
+ /*#__PURE__*/ _jsx("button", {
73
+ onClick: regenerateImage,
74
+ style: {
75
+ background: 'none',
76
+ backgroundColor: 'transparent',
77
+ border: 'none',
78
+ color: 'currentcolor',
79
+ cursor: 'pointer',
80
+ padding: 0,
81
+ textDecoration: 'underline'
82
+ },
83
+ type: "button",
84
+ children: t('plugin-seo:autoGenerate')
85
+ })
86
+ ]
87
+ })
88
+ ]
89
+ }),
90
+ hasGenerateImageFn && /*#__PURE__*/ _jsx("div", {
91
+ style: {
92
+ color: '#9A9A9A'
93
+ },
94
+ children: t('plugin-seo:imageAutoGenerationTip')
95
+ })
96
+ ]
97
+ }),
98
+ /*#__PURE__*/ _jsx("div", {
99
+ style: {
100
+ marginBottom: '10px',
101
+ position: 'relative'
102
+ },
103
+ children: /*#__PURE__*/ _jsx(UploadInput, {
104
+ CustomError: errorMessage,
105
+ api: api,
106
+ collection: collection,
107
+ filterOptions: field.filterOptions,
108
+ label: undefined,
109
+ onChange: (incomingImage)=>{
110
+ if (incomingImage !== null) {
111
+ const { id: incomingID } = incomingImage;
112
+ setValue(incomingID);
113
+ } else {
114
+ setValue(null);
115
+ }
116
+ },
117
+ relationTo: relationTo,
118
+ required: required,
119
+ serverURL: serverURL,
120
+ showError: showError,
121
+ style: {
122
+ marginBottom: 0
123
+ },
124
+ value: value
125
+ })
126
+ }),
127
+ /*#__PURE__*/ _jsx("div", {
128
+ style: {
129
+ alignItems: 'center',
130
+ display: 'flex',
131
+ width: '100%'
132
+ },
133
+ children: /*#__PURE__*/ _jsx(Pill, {
134
+ backgroundColor: hasImage ? 'green' : 'red',
135
+ color: "white",
136
+ label: hasImage ? t('plugin-seo:good') : t('plugin-seo:noImage')
137
+ })
138
+ })
139
+ ]
140
+ });
118
141
  };
119
142
 
120
143
  //# 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, label, 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 <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={{}}\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","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"],"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,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;QACZ;qBAEA,oBAACH;QAAII,WAAU;qBACb,oBAACzD;QAAWY,aAAaA;QAAaE,OAAOA;QAAQ,GAAIC,cAAc,CAAC,CAAC;QACxEF,oCACC,oBAACN,MAAMmD,QAAQ,QAAC,uBAEd,oBAACC;QACCC,SAASjC;QACT2B,OAAO;YACLO,YAAY;YACZC,iBAAiB;YACjBC,QAAQ;YACRC,OAAO;YACPC,QAAQ;YACRC,SAAS;YACTC,gBAAgB;QAClB;QACAC,MAAK;OAEJjD,EAAE,+BAKVN,oCACC,oBAACwC;QACCC,OAAO;YACLU,OAAO;QACT;OAEC7C,EAAE,sDAIT,oBAACkC;QACCC,OAAO;YACLC,cAAc;YACdC,UAAU;QACZ;qBAEA,oBAACzD;QACCsE,aAAa9C;QACbuB,KAAKA;QACLE,YAAYA;QACZsB,eAAe,CAAC;QAChBxD,OAAOsC;QACPmB,UAAU,CAACC;YACT,IAAIA,kBAAkB,MAAM;gBAC1B,MAAM,EAAEC,IAAIC,UAAU,EAAE,GAAGF;gBAC3BhD,SAASkD;YACX,OAAO;gBACLlD,SAAS;YACX;QACF;QACAR,YAAYA;QACZC,UAAUA;QACV8B,WAAWA;QACXtB,WAAWA;QACX6B,OAAO;YACLC,cAAc;QAChB;QACA7B,OAAOA;uBAGX,oBAAC2B;QACCC,OAAO;YACLqB,YAAY;YACZC,SAAS;YACTC,OAAO;QACT;qBAEA,oBAACpE;QACCqD,iBAAiBrB,WAAW,UAAU;QACtCuB,OAAM;QACNlD,OAAO2B,WAAWtB,EAAE,qBAAqBA,EAAE;;AAKrD,EAAC"}
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 { FieldLabel } from '@payloadcms/ui/fields/FieldLabel'\nimport { UploadInput } from '@payloadcms/ui/fields/Upload'\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 { 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","useField","useConfig","useDocumentInfo","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"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;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 +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,CAqH9C,CAAA"}
1
+ {"version":3,"file":"MetaTitle.d.ts","sourceRoot":"","sources":["../../src/fields/MetaTitle.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAWjE,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"}
@@ -1,6 +1,7 @@
1
1
  'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { FieldLabel } from '@payloadcms/ui/fields/FieldLabel';
2
4
  import { TextInput } from '@payloadcms/ui/fields/Text';
3
- import { FieldLabel } from '@payloadcms/ui/forms/FieldLabel';
4
5
  import { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider';
5
6
  import { useAllFormFields } from '@payloadcms/ui/forms/Form';
6
7
  import { useField } from '@payloadcms/ui/forms/useField';
@@ -48,70 +49,97 @@ export const MetaTitle = (props)=>{
48
49
  locale,
49
50
  docInfo
50
51
  ]);
51
- return /*#__PURE__*/ React.createElement("div", {
52
+ return /*#__PURE__*/ _jsxs("div", {
52
53
  style: {
53
54
  marginBottom: '20px'
54
- }
55
- }, /*#__PURE__*/ React.createElement("div", {
56
- style: {
57
- marginBottom: '5px',
58
- position: 'relative'
59
- }
60
- }, /*#__PURE__*/ React.createElement("div", {
61
- className: "plugin-seo__field"
62
- }, /*#__PURE__*/ React.createElement(FieldLabel, {
63
- CustomLabel: CustomLabel,
64
- label: label,
65
- ...labelProps || {}
66
- }), hasGenerateTitleFn && /*#__PURE__*/ React.createElement(React.Fragment, null, "  —  ", /*#__PURE__*/ React.createElement("button", {
67
- onClick: regenerateTitle,
68
- style: {
69
- background: 'none',
70
- backgroundColor: 'transparent',
71
- border: 'none',
72
- color: 'currentcolor',
73
- cursor: 'pointer',
74
- padding: 0,
75
- textDecoration: 'underline'
76
55
  },
77
- type: "button"
78
- }, t('plugin-seo:autoGenerate')))), /*#__PURE__*/ React.createElement("div", {
79
- style: {
80
- color: '#9A9A9A'
81
- }
82
- }, t('plugin-seo:lengthTipTitle', {
83
- maxLength,
84
- minLength
85
- }), /*#__PURE__*/ React.createElement("a", {
86
- href: "https://developers.google.com/search/docs/advanced/appearance/title-link#page-titles",
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(TextInput, {
95
- CustomError: errorMessage,
96
- onChange: setValue,
97
- path: pathFromContext,
98
- required: required,
99
- showError: showError,
100
- style: {
101
- marginBottom: 0
102
- },
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
- })));
56
+ children: [
57
+ /*#__PURE__*/ _jsxs("div", {
58
+ style: {
59
+ marginBottom: '5px',
60
+ position: 'relative'
61
+ },
62
+ children: [
63
+ /*#__PURE__*/ _jsxs("div", {
64
+ className: "plugin-seo__field",
65
+ children: [
66
+ /*#__PURE__*/ _jsx(FieldLabel, {
67
+ CustomLabel: CustomLabel,
68
+ label: label,
69
+ ...labelProps || {}
70
+ }),
71
+ hasGenerateTitleFn && /*#__PURE__*/ _jsxs(React.Fragment, {
72
+ children: [
73
+ "  —  ",
74
+ /*#__PURE__*/ _jsx("button", {
75
+ onClick: regenerateTitle,
76
+ style: {
77
+ background: 'none',
78
+ backgroundColor: 'transparent',
79
+ border: 'none',
80
+ color: 'currentcolor',
81
+ cursor: 'pointer',
82
+ padding: 0,
83
+ textDecoration: 'underline'
84
+ },
85
+ type: "button",
86
+ children: t('plugin-seo:autoGenerate')
87
+ })
88
+ ]
89
+ })
90
+ ]
91
+ }),
92
+ /*#__PURE__*/ _jsxs("div", {
93
+ style: {
94
+ color: '#9A9A9A'
95
+ },
96
+ children: [
97
+ t('plugin-seo:lengthTipTitle', {
98
+ maxLength,
99
+ minLength
100
+ }),
101
+ /*#__PURE__*/ _jsx("a", {
102
+ href: "https://developers.google.com/search/docs/advanced/appearance/title-link#page-titles",
103
+ rel: "noopener noreferrer",
104
+ target: "_blank",
105
+ children: t('plugin-seo:bestPractices')
106
+ }),
107
+ "."
108
+ ]
109
+ })
110
+ ]
111
+ }),
112
+ /*#__PURE__*/ _jsx("div", {
113
+ style: {
114
+ marginBottom: '10px',
115
+ position: 'relative'
116
+ },
117
+ children: /*#__PURE__*/ _jsx(TextInput, {
118
+ CustomError: errorMessage,
119
+ onChange: setValue,
120
+ path: pathFromContext,
121
+ required: required,
122
+ showError: showError,
123
+ style: {
124
+ marginBottom: 0
125
+ },
126
+ value: value
127
+ })
128
+ }),
129
+ /*#__PURE__*/ _jsx("div", {
130
+ style: {
131
+ alignItems: 'center',
132
+ display: 'flex',
133
+ width: '100%'
134
+ },
135
+ children: /*#__PURE__*/ _jsx(LengthIndicator, {
136
+ maxLength: maxLength,
137
+ minLength: minLength,
138
+ text: value
139
+ })
140
+ })
141
+ ]
142
+ });
115
143
  };
116
144
 
117
145
  //# sourceMappingURL=MetaTitle.js.map