@payloadcms/plugin-search 4.0.0-internal.688c4d0 → 4.0.0-internal.811e0a4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/dist/Search/ui/LinkToDoc/index.client.d.ts +1 -0
- package/dist/Search/ui/LinkToDoc/index.client.d.ts.map +1 -1
- package/dist/Search/ui/LinkToDoc/index.client.js +9 -15
- package/dist/Search/ui/LinkToDoc/index.client.js.map +1 -1
- package/dist/Search/ui/LinkToDoc/index.css +26 -0
- package/dist/Search/ui/ReindexButton/ReindexButtonLabel/index.d.ts +10 -1
- package/dist/Search/ui/ReindexButton/ReindexButtonLabel/index.d.ts.map +1 -1
- package/dist/Search/ui/ReindexButton/ReindexButtonLabel/index.js +14 -4
- package/dist/Search/ui/ReindexButton/ReindexButtonLabel/index.js.map +1 -1
- package/dist/Search/ui/ReindexButton/index.client.js +3 -1
- package/dist/Search/ui/ReindexButton/index.client.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +9 -11
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +5 -5
package/LICENSE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2018-
|
|
3
|
+
Copyright (c) 2018-2026 Payload CMS, LLC <info@payloadcms.com>
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
6
|
a copy of this software and associated documentation files (the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.client.d.ts","sourceRoot":"","sources":["../../../../src/Search/ui/LinkToDoc/index.client.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"index.client.d.ts","sourceRoot":"","sources":["../../../../src/Search/ui/LinkToDoc/index.client.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,aAAa,CAAA;AAIpB,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAmCnC,CAAA"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { CopyToClipboard, Link, useConfig, useField } from '@payloadcms/ui';
|
|
3
|
+
import { CopyToClipboard, FieldLabel, Link, useConfig, useField } from '@payloadcms/ui';
|
|
4
4
|
import { formatAdminURL } from 'payload/shared';
|
|
5
5
|
import React from 'react';
|
|
6
|
+
import './index.css';
|
|
7
|
+
const baseClass = 'link-to-doc';
|
|
6
8
|
export const LinkToDocClient = ()=>{
|
|
7
9
|
const { config } = useConfig();
|
|
8
10
|
const { routes: { admin: adminRoute }, serverURL } = config;
|
|
@@ -18,18 +20,14 @@ export const LinkToDocClient = ()=>{
|
|
|
18
20
|
serverURL
|
|
19
21
|
});
|
|
20
22
|
return /*#__PURE__*/ _jsxs("div", {
|
|
21
|
-
|
|
22
|
-
marginBottom: 'var(--spacing-field, 1rem)'
|
|
23
|
-
},
|
|
23
|
+
className: baseClass,
|
|
24
24
|
children: [
|
|
25
25
|
/*#__PURE__*/ _jsxs("div", {
|
|
26
|
+
className: `${baseClass}__header`,
|
|
26
27
|
children: [
|
|
27
|
-
/*#__PURE__*/ _jsx(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
color: '#9A9A9A'
|
|
31
|
-
},
|
|
32
|
-
children: "Doc URL"
|
|
28
|
+
/*#__PURE__*/ _jsx(FieldLabel, {
|
|
29
|
+
htmlFor: baseClass,
|
|
30
|
+
label: "Doc URL"
|
|
33
31
|
}),
|
|
34
32
|
/*#__PURE__*/ _jsx(CopyToClipboard, {
|
|
35
33
|
value: href
|
|
@@ -37,11 +35,7 @@ export const LinkToDocClient = ()=>{
|
|
|
37
35
|
]
|
|
38
36
|
}),
|
|
39
37
|
/*#__PURE__*/ _jsx("div", {
|
|
40
|
-
|
|
41
|
-
fontWeight: '600',
|
|
42
|
-
overflow: 'hidden',
|
|
43
|
-
textOverflow: 'ellipsis'
|
|
44
|
-
},
|
|
38
|
+
className: `${baseClass}__url`,
|
|
45
39
|
children: /*#__PURE__*/ _jsx(Link, {
|
|
46
40
|
href: href,
|
|
47
41
|
rel: "noopener noreferrer",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/Search/ui/LinkToDoc/index.client.tsx"],"sourcesContent":["'use client'\n\nimport { CopyToClipboard, Link, useConfig, useField } from '@payloadcms/ui'\nimport { formatAdminURL } from 'payload/shared'\nimport React from 'react'\n\nexport const LinkToDocClient: React.FC = () => {\n const { config } = useConfig()\n\n const {\n routes: {\n admin: adminRoute, // already includes leading slash\n },\n serverURL,\n } = config\n\n const { value } = useField<{ relationTo?: string; value?: string }>({ path: 'doc' })\n\n if (!value?.relationTo || !value?.value) {\n return null\n }\n\n const href = formatAdminURL({\n adminRoute,\n path: `/collections/${value.relationTo || ''}/${value.value || ''}`,\n serverURL,\n })\n\n return (\n <div
|
|
1
|
+
{"version":3,"sources":["../../../../src/Search/ui/LinkToDoc/index.client.tsx"],"sourcesContent":["'use client'\n\nimport { CopyToClipboard, FieldLabel, Link, useConfig, useField } from '@payloadcms/ui'\nimport { formatAdminURL } from 'payload/shared'\nimport React from 'react'\n\nimport './index.css'\n\nconst baseClass = 'link-to-doc'\n\nexport const LinkToDocClient: React.FC = () => {\n const { config } = useConfig()\n\n const {\n routes: {\n admin: adminRoute, // already includes leading slash\n },\n serverURL,\n } = config\n\n const { value } = useField<{ relationTo?: string; value?: string }>({ path: 'doc' })\n\n if (!value?.relationTo || !value?.value) {\n return null\n }\n\n const href = formatAdminURL({\n adminRoute,\n path: `/collections/${value.relationTo || ''}/${value.value || ''}`,\n serverURL,\n })\n\n return (\n <div className={baseClass}>\n <div className={`${baseClass}__header`}>\n <FieldLabel htmlFor={baseClass} label=\"Doc URL\" />\n <CopyToClipboard value={href} />\n </div>\n <div className={`${baseClass}__url`}>\n <Link href={href} rel=\"noopener noreferrer\" target=\"_blank\">\n {href}\n </Link>\n </div>\n </div>\n )\n}\n"],"names":["CopyToClipboard","FieldLabel","Link","useConfig","useField","formatAdminURL","React","baseClass","LinkToDocClient","config","routes","admin","adminRoute","serverURL","value","path","relationTo","href","div","className","htmlFor","label","rel","target"],"mappings":"AAAA;;AAEA,SAASA,eAAe,EAAEC,UAAU,EAAEC,IAAI,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,iBAAgB;AACvF,SAASC,cAAc,QAAQ,iBAAgB;AAC/C,OAAOC,WAAW,QAAO;AAEzB,OAAO,cAAa;AAEpB,MAAMC,YAAY;AAElB,OAAO,MAAMC,kBAA4B;IACvC,MAAM,EAAEC,MAAM,EAAE,GAAGN;IAEnB,MAAM,EACJO,QAAQ,EACNC,OAAOC,UAAU,EAClB,EACDC,SAAS,EACV,GAAGJ;IAEJ,MAAM,EAAEK,KAAK,EAAE,GAAGV,SAAkD;QAAEW,MAAM;IAAM;IAElF,IAAI,CAACD,OAAOE,cAAc,CAACF,OAAOA,OAAO;QACvC,OAAO;IACT;IAEA,MAAMG,OAAOZ,eAAe;QAC1BO;QACAG,MAAM,CAAC,aAAa,EAAED,MAAME,UAAU,IAAI,GAAG,CAAC,EAAEF,MAAMA,KAAK,IAAI,IAAI;QACnED;IACF;IAEA,qBACE,MAACK;QAAIC,WAAWZ;;0BACd,MAACW;gBAAIC,WAAW,GAAGZ,UAAU,QAAQ,CAAC;;kCACpC,KAACN;wBAAWmB,SAASb;wBAAWc,OAAM;;kCACtC,KAACrB;wBAAgBc,OAAOG;;;;0BAE1B,KAACC;gBAAIC,WAAW,GAAGZ,UAAU,KAAK,CAAC;0BACjC,cAAA,KAACL;oBAAKe,MAAMA;oBAAMK,KAAI;oBAAsBC,QAAO;8BAChDN;;;;;AAKX,EAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
@layer payload-default {
|
|
2
|
+
.link-to-doc {
|
|
3
|
+
margin-bottom: var(--spacing-field);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.link-to-doc__header {
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
width: fit-content;
|
|
10
|
+
gap: var(--spacer-1);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.link-to-doc__url {
|
|
14
|
+
overflow: hidden;
|
|
15
|
+
font-weight: 600;
|
|
16
|
+
text-overflow: ellipsis;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.link-to-doc__url a {
|
|
20
|
+
color: var(--color-text-secondary);
|
|
21
|
+
|
|
22
|
+
&:hover {
|
|
23
|
+
color: var(--color-text);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -1,2 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type ReindexButtonLabelProps = {
|
|
3
|
+
readonly active?: boolean;
|
|
4
|
+
readonly 'aria-expanded'?: boolean;
|
|
5
|
+
readonly 'aria-haspopup'?: true;
|
|
6
|
+
readonly onClick?: React.MouseEventHandler;
|
|
7
|
+
readonly onKeyDown?: React.KeyboardEventHandler;
|
|
8
|
+
};
|
|
9
|
+
export declare const ReindexButtonLabel: React.FC<ReindexButtonLabelProps>;
|
|
10
|
+
export {};
|
|
2
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/Search/ui/ReindexButton/ReindexButtonLabel/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/Search/ui/ReindexButton/ReindexButtonLabel/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,KAAK,uBAAuB,GAAG;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAA;IAClC,QAAQ,CAAC,eAAe,CAAC,EAAE,IAAI,CAAA;IAC/B,QAAQ,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAA;IAC1C,QAAQ,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,oBAAoB,CAAA;CAChD,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAuBhE,CAAA"}
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Button, useTranslation } from '@payloadcms/ui';
|
|
3
|
-
|
|
2
|
+
import { Button, ChevronIcon, useTranslation } from '@payloadcms/ui';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
export const ReindexButtonLabel = ({ active, onClick, onKeyDown, ...ariaProps })=>{
|
|
4
5
|
const { i18n: { t } } = useTranslation();
|
|
5
6
|
return /*#__PURE__*/ _jsx(Button, {
|
|
6
|
-
buttonStyle: "
|
|
7
|
-
|
|
7
|
+
buttonStyle: "secondary",
|
|
8
|
+
extraButtonProps: {
|
|
9
|
+
onKeyDown
|
|
10
|
+
},
|
|
11
|
+
icon: /*#__PURE__*/ _jsx(ChevronIcon, {
|
|
12
|
+
direction: active ? 'up' : 'down',
|
|
13
|
+
size: 16
|
|
14
|
+
}),
|
|
8
15
|
iconPosition: "right",
|
|
16
|
+
onClick: onClick,
|
|
17
|
+
selected: active,
|
|
9
18
|
size: "medium",
|
|
19
|
+
...ariaProps,
|
|
10
20
|
children: t('general:reindex')
|
|
11
21
|
});
|
|
12
22
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/Search/ui/ReindexButton/ReindexButtonLabel/index.tsx"],"sourcesContent":["import { Button, ChevronIcon, useTranslation } from '@payloadcms/ui'\n\nexport const ReindexButtonLabel = () => {\n const {\n i18n: { t },\n } = useTranslation()\n return (\n <Button
|
|
1
|
+
{"version":3,"sources":["../../../../../src/Search/ui/ReindexButton/ReindexButtonLabel/index.tsx"],"sourcesContent":["import { Button, ChevronIcon, useTranslation } from '@payloadcms/ui'\nimport React from 'react'\n\ntype ReindexButtonLabelProps = {\n readonly active?: boolean\n readonly 'aria-expanded'?: boolean\n readonly 'aria-haspopup'?: true\n readonly onClick?: React.MouseEventHandler\n readonly onKeyDown?: React.KeyboardEventHandler\n}\n\nexport const ReindexButtonLabel: React.FC<ReindexButtonLabelProps> = ({\n active,\n onClick,\n onKeyDown,\n ...ariaProps\n}) => {\n const {\n i18n: { t },\n } = useTranslation()\n return (\n <Button\n buttonStyle=\"secondary\"\n extraButtonProps={{ onKeyDown }}\n icon={<ChevronIcon direction={active ? 'up' : 'down'} size={16} />}\n iconPosition=\"right\"\n onClick={onClick}\n selected={active}\n size=\"medium\"\n {...ariaProps}\n >\n {t('general:reindex')}\n </Button>\n )\n}\n"],"names":["Button","ChevronIcon","useTranslation","React","ReindexButtonLabel","active","onClick","onKeyDown","ariaProps","i18n","t","buttonStyle","extraButtonProps","icon","direction","size","iconPosition","selected"],"mappings":";AAAA,SAASA,MAAM,EAAEC,WAAW,EAAEC,cAAc,QAAQ,iBAAgB;AACpE,OAAOC,WAAW,QAAO;AAUzB,OAAO,MAAMC,qBAAwD,CAAC,EACpEC,MAAM,EACNC,OAAO,EACPC,SAAS,EACT,GAAGC,WACJ;IACC,MAAM,EACJC,MAAM,EAAEC,CAAC,EAAE,EACZ,GAAGR;IACJ,qBACE,KAACF;QACCW,aAAY;QACZC,kBAAkB;YAAEL;QAAU;QAC9BM,oBAAM,KAACZ;YAAYa,WAAWT,SAAS,OAAO;YAAQU,MAAM;;QAC5DC,cAAa;QACbV,SAASA;QACTW,UAAUZ;QACVU,MAAK;QACJ,GAAGP,SAAS;kBAEZE,EAAE;;AAGT,EAAC"}
|
|
@@ -97,7 +97,6 @@ export const ReindexButtonClient = ({ collectionLabels, searchCollections, searc
|
|
|
97
97
|
return /*#__PURE__*/ _jsxs("div", {
|
|
98
98
|
children: [
|
|
99
99
|
/*#__PURE__*/ _jsx(Popup, {
|
|
100
|
-
button: /*#__PURE__*/ _jsx(ReindexButtonLabel, {}),
|
|
101
100
|
render: ({ close })=>/*#__PURE__*/ _jsxs(PopupList.ButtonGroup, {
|
|
102
101
|
children: [
|
|
103
102
|
searchCollections.map((collectionSlug)=>/*#__PURE__*/ _jsx(PopupList.Button, {
|
|
@@ -110,6 +109,9 @@ export const ReindexButtonClient = ({ collectionLabels, searchCollections, searc
|
|
|
110
109
|
})
|
|
111
110
|
]
|
|
112
111
|
}),
|
|
112
|
+
renderButton: (buttonProps)=>/*#__PURE__*/ _jsx(ReindexButtonLabel, {
|
|
113
|
+
...buttonProps
|
|
114
|
+
}),
|
|
113
115
|
showScrollbar: true,
|
|
114
116
|
size: "large",
|
|
115
117
|
verticalAlign: "bottom"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/Search/ui/ReindexButton/index.client.tsx"],"sourcesContent":["'use client'\n\nimport {\n ConfirmationModal,\n Popup,\n PopupList,\n toast,\n useConfig,\n useLocale,\n useModal,\n useRouter,\n useTranslation,\n} from '@payloadcms/ui'\nimport { formatAdminURL } from 'payload/shared'\nimport React, { useCallback, useMemo, useState } from 'react'\n\nimport type { ReindexButtonProps } from './types.js'\n\nimport { ReindexButtonLabel } from './ReindexButtonLabel/index.js'\n\nconst confirmReindexModalSlug = 'confirm-reindex-modal'\n\nexport const ReindexButtonClient: React.FC<ReindexButtonProps> = ({\n collectionLabels,\n searchCollections,\n searchSlug,\n}) => {\n const { openModal } = useModal()\n\n const { config } = useConfig()\n\n const {\n i18n: { t },\n } = useTranslation()\n\n const locale = useLocale()\n const router = useRouter()\n\n const [reindexCollections, setReindexCollections] = useState<string[]>([])\n\n const openConfirmModal = useCallback(() => openModal(confirmReindexModalSlug), [openModal])\n\n const handleReindexSubmit = useCallback(async () => {\n if (!reindexCollections.length) {\n return\n }\n\n try {\n const res = await fetch(\n formatAdminURL({\n apiRoute: config.routes.api,\n path: `/${searchSlug}/reindex?locale=${locale.code}`,\n }),\n {\n body: JSON.stringify({\n collections: reindexCollections,\n }),\n method: 'POST',\n },\n )\n\n const { message } = (await res.json()) as { message: string }\n\n if (!res.ok) {\n toast.error(message)\n } else {\n toast.success(message)\n return router.refresh()\n }\n } catch (_err: unknown) {\n // swallow error, toast shown above\n } finally {\n setReindexCollections([])\n }\n }, [reindexCollections, router, searchSlug, locale, config])\n\n const handleShowConfirmModal = useCallback(\n (collections: string | string[] = searchCollections) => {\n setReindexCollections(typeof collections === 'string' ? [collections] : collections)\n openConfirmModal()\n },\n [openConfirmModal, searchCollections],\n )\n\n const handlePopupButtonClick = useCallback(\n (closePopup: () => void, slug?: string) => {\n closePopup()\n handleShowConfirmModal(slug)\n },\n [handleShowConfirmModal],\n )\n\n const getPluralizedLabel = useCallback(\n (slug: string) => {\n const label = collectionLabels[slug]\n if (typeof label === 'string') {\n return label\n } else {\n return label && Object.hasOwn(label, locale.code) ? label[locale.code] : slug\n }\n },\n [collectionLabels, locale.code],\n )\n\n const pluralizedLabels = useMemo(() => {\n return searchCollections.reduce<Record<string, string>>((acc, slug) => {\n const label = getPluralizedLabel(slug)\n if (label) {\n acc[slug] = label\n }\n return acc\n }, {})\n }, [searchCollections, getPluralizedLabel])\n\n const selectedAll = reindexCollections.length === searchCollections.length\n const selectedLabels = reindexCollections.map((slug) => pluralizedLabels[slug]).join(', ')\n\n const modalTitle = selectedAll\n ? t('general:confirmReindexAll')\n : t('general:confirmReindex', { collections: selectedLabels })\n const modalDescription = selectedAll\n ? t('general:confirmReindexDescriptionAll')\n : t('general:confirmReindexDescription', { collections: selectedLabels })\n\n return (\n <div>\n <Popup\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/Search/ui/ReindexButton/index.client.tsx"],"sourcesContent":["'use client'\n\nimport {\n ConfirmationModal,\n Popup,\n PopupList,\n toast,\n useConfig,\n useLocale,\n useModal,\n useRouter,\n useTranslation,\n} from '@payloadcms/ui'\nimport { formatAdminURL } from 'payload/shared'\nimport React, { useCallback, useMemo, useState } from 'react'\n\nimport type { ReindexButtonProps } from './types.js'\n\nimport { ReindexButtonLabel } from './ReindexButtonLabel/index.js'\n\nconst confirmReindexModalSlug = 'confirm-reindex-modal'\n\nexport const ReindexButtonClient: React.FC<ReindexButtonProps> = ({\n collectionLabels,\n searchCollections,\n searchSlug,\n}) => {\n const { openModal } = useModal()\n\n const { config } = useConfig()\n\n const {\n i18n: { t },\n } = useTranslation()\n\n const locale = useLocale()\n const router = useRouter()\n\n const [reindexCollections, setReindexCollections] = useState<string[]>([])\n\n const openConfirmModal = useCallback(() => openModal(confirmReindexModalSlug), [openModal])\n\n const handleReindexSubmit = useCallback(async () => {\n if (!reindexCollections.length) {\n return\n }\n\n try {\n const res = await fetch(\n formatAdminURL({\n apiRoute: config.routes.api,\n path: `/${searchSlug}/reindex?locale=${locale.code}`,\n }),\n {\n body: JSON.stringify({\n collections: reindexCollections,\n }),\n method: 'POST',\n },\n )\n\n const { message } = (await res.json()) as { message: string }\n\n if (!res.ok) {\n toast.error(message)\n } else {\n toast.success(message)\n return router.refresh()\n }\n } catch (_err: unknown) {\n // swallow error, toast shown above\n } finally {\n setReindexCollections([])\n }\n }, [reindexCollections, router, searchSlug, locale, config])\n\n const handleShowConfirmModal = useCallback(\n (collections: string | string[] = searchCollections) => {\n setReindexCollections(typeof collections === 'string' ? [collections] : collections)\n openConfirmModal()\n },\n [openConfirmModal, searchCollections],\n )\n\n const handlePopupButtonClick = useCallback(\n (closePopup: () => void, slug?: string) => {\n closePopup()\n handleShowConfirmModal(slug)\n },\n [handleShowConfirmModal],\n )\n\n const getPluralizedLabel = useCallback(\n (slug: string) => {\n const label = collectionLabels[slug]\n if (typeof label === 'string') {\n return label\n } else {\n return label && Object.hasOwn(label, locale.code) ? label[locale.code] : slug\n }\n },\n [collectionLabels, locale.code],\n )\n\n const pluralizedLabels = useMemo(() => {\n return searchCollections.reduce<Record<string, string>>((acc, slug) => {\n const label = getPluralizedLabel(slug)\n if (label) {\n acc[slug] = label\n }\n return acc\n }, {})\n }, [searchCollections, getPluralizedLabel])\n\n const selectedAll = reindexCollections.length === searchCollections.length\n const selectedLabels = reindexCollections.map((slug) => pluralizedLabels[slug]).join(', ')\n\n const modalTitle = selectedAll\n ? t('general:confirmReindexAll')\n : t('general:confirmReindex', { collections: selectedLabels })\n const modalDescription = selectedAll\n ? t('general:confirmReindexDescriptionAll')\n : t('general:confirmReindexDescription', { collections: selectedLabels })\n\n return (\n <div>\n <Popup\n render={({ close }) => (\n <PopupList.ButtonGroup>\n {searchCollections.map((collectionSlug) => (\n <PopupList.Button\n key={collectionSlug}\n onClick={() => handlePopupButtonClick(close, collectionSlug)}\n >\n {pluralizedLabels[collectionSlug]}\n </PopupList.Button>\n ))}\n <PopupList.Button onClick={() => handlePopupButtonClick(close)}>\n {t('general:allCollections')}\n </PopupList.Button>\n </PopupList.ButtonGroup>\n )}\n renderButton={(buttonProps) => <ReindexButtonLabel {...buttonProps} />}\n showScrollbar\n size=\"large\"\n verticalAlign=\"bottom\"\n />\n <ConfirmationModal\n body={modalDescription}\n heading={modalTitle}\n modalSlug={confirmReindexModalSlug}\n onConfirm={handleReindexSubmit}\n />\n </div>\n )\n}\n"],"names":["ConfirmationModal","Popup","PopupList","toast","useConfig","useLocale","useModal","useRouter","useTranslation","formatAdminURL","React","useCallback","useMemo","useState","ReindexButtonLabel","confirmReindexModalSlug","ReindexButtonClient","collectionLabels","searchCollections","searchSlug","openModal","config","i18n","t","locale","router","reindexCollections","setReindexCollections","openConfirmModal","handleReindexSubmit","length","res","fetch","apiRoute","routes","api","path","code","body","JSON","stringify","collections","method","message","json","ok","error","success","refresh","_err","handleShowConfirmModal","handlePopupButtonClick","closePopup","slug","getPluralizedLabel","label","Object","hasOwn","pluralizedLabels","reduce","acc","selectedAll","selectedLabels","map","join","modalTitle","modalDescription","div","render","close","ButtonGroup","collectionSlug","Button","onClick","renderButton","buttonProps","showScrollbar","size","verticalAlign","heading","modalSlug","onConfirm"],"mappings":"AAAA;;AAEA,SACEA,iBAAiB,EACjBC,KAAK,EACLC,SAAS,EACTC,KAAK,EACLC,SAAS,EACTC,SAAS,EACTC,QAAQ,EACRC,SAAS,EACTC,cAAc,QACT,iBAAgB;AACvB,SAASC,cAAc,QAAQ,iBAAgB;AAC/C,OAAOC,SAASC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AAI7D,SAASC,kBAAkB,QAAQ,gCAA+B;AAElE,MAAMC,0BAA0B;AAEhC,OAAO,MAAMC,sBAAoD,CAAC,EAChEC,gBAAgB,EAChBC,iBAAiB,EACjBC,UAAU,EACX;IACC,MAAM,EAAEC,SAAS,EAAE,GAAGd;IAEtB,MAAM,EAAEe,MAAM,EAAE,GAAGjB;IAEnB,MAAM,EACJkB,MAAM,EAAEC,CAAC,EAAE,EACZ,GAAGf;IAEJ,MAAMgB,SAASnB;IACf,MAAMoB,SAASlB;IAEf,MAAM,CAACmB,oBAAoBC,sBAAsB,GAAGd,SAAmB,EAAE;IAEzE,MAAMe,mBAAmBjB,YAAY,IAAMS,UAAUL,0BAA0B;QAACK;KAAU;IAE1F,MAAMS,sBAAsBlB,YAAY;QACtC,IAAI,CAACe,mBAAmBI,MAAM,EAAE;YAC9B;QACF;QAEA,IAAI;YACF,MAAMC,MAAM,MAAMC,MAChBvB,eAAe;gBACbwB,UAAUZ,OAAOa,MAAM,CAACC,GAAG;gBAC3BC,MAAM,CAAC,CAAC,EAAEjB,WAAW,gBAAgB,EAAEK,OAAOa,IAAI,EAAE;YACtD,IACA;gBACEC,MAAMC,KAAKC,SAAS,CAAC;oBACnBC,aAAaf;gBACf;gBACAgB,QAAQ;YACV;YAGF,MA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ASK,gBAAgB,CAACL,KAAK,EAAEW,IAAI,CAAC;IAErF,MAAMC,aAAaJ,cACftC,EAAE,+BACFA,EAAE,0BAA0B;QAAEkB,aAAaqB;IAAe;IAC9D,MAAMI,mBAAmBL,cACrBtC,EAAE,0CACFA,EAAE,qCAAqC;QAAEkB,aAAaqB;IAAe;IAEzE,qBACE,MAACK;;0BACC,KAAClE;gBACCmE,QAAQ,CAAC,EAAEC,KAAK,EAAE,iBAChB,MAACnE,UAAUoE,WAAW;;4BACnBpD,kBAAkB6C,GAAG,CAAC,CAACQ,+BACtB,KAACrE,UAAUsE,MAAM;oCAEfC,SAAS,IAAMtB,uBAAuBkB,OAAOE;8CAE5Cb,gBAAgB,CAACa,eAAe;mCAH5BA;0CAMT,KAACrE,UAAUsE,MAAM;gCAACC,SAAS,IAAMtB,uBAAuBkB;0CACrD9C,EAAE;;;;gBAITmD,cAAc,CAACC,4BAAgB,KAAC7D;wBAAoB,GAAG6D,WAAW;;gBAClEC,aAAa;gBACbC,MAAK;gBACLC,eAAc;;0BAEhB,KAAC9E;gBACCsC,MAAM4B;gBACNa,SAASd;gBACTe,WAAWjE;gBACXkE,WAAWpD;;;;AAInB,EAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Config } from 'payload';
|
|
2
1
|
import type { SearchPluginConfig } from './types.js';
|
|
3
|
-
export declare const searchPlugin:
|
|
2
|
+
export declare const searchPlugin: (options: SearchPluginConfig) => import("payload").Plugin;
|
|
4
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAA+B,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAQjF,eAAO,MAAM,YAAY,2DA8EvB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { definePlugin } from 'payload';
|
|
1
2
|
import { deleteFromSearch } from './Search/hooks/deleteFromSearch.js';
|
|
2
3
|
import { syncWithSearch } from './Search/hooks/syncWithSearch.js';
|
|
3
4
|
import { generateSearchCollection } from './Search/index.js';
|
|
4
|
-
export const searchPlugin = (
|
|
5
|
+
export const searchPlugin = definePlugin({
|
|
6
|
+
slug: '@payloadcms/plugin-search',
|
|
7
|
+
plugin: ({ config, options: incomingPluginConfig })=>{
|
|
5
8
|
const { collections } = config;
|
|
6
9
|
// If the user defines `localize` to either true or false, use that
|
|
7
10
|
// Otherwise, set it based on if their config has localization enabled or disabled
|
|
@@ -62,6 +65,7 @@ export const searchPlugin = (incomingPluginConfig)=>(config)=>{
|
|
|
62
65
|
};
|
|
63
66
|
}
|
|
64
67
|
return config;
|
|
65
|
-
}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
66
70
|
|
|
67
71
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { CollectionAfterChangeHook
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { CollectionAfterChangeHook } from 'payload'\n\nimport { definePlugin } from 'payload'\n\nimport type { SanitizedSearchPluginConfig, SearchPluginConfig } from './types.js'\n\nimport { deleteFromSearch } from './Search/hooks/deleteFromSearch.js'\nimport { syncWithSearch } from './Search/hooks/syncWithSearch.js'\nimport { generateSearchCollection } from './Search/index.js'\n\ntype CollectionAfterChangeHookArgs = Parameters<CollectionAfterChangeHook>[0]\n\nexport const searchPlugin = definePlugin<SearchPluginConfig>({\n slug: '@payloadcms/plugin-search',\n plugin: ({ config, options: incomingPluginConfig }) => {\n const { collections } = config\n\n // If the user defines `localize` to either true or false, use that\n // Otherwise, set it based on if their config has localization enabled or disabled\n const shouldLocalize =\n typeof incomingPluginConfig.localize === 'boolean'\n ? incomingPluginConfig.localize\n : Boolean(config.localization)\n incomingPluginConfig.localize = shouldLocalize\n\n if (collections) {\n // O(1) slug lookup for enabled-collection checks; replaces an Array.indexOf in the\n // hook-attachment pass that was O(M) per collection.\n const enabledSlugSet = new Set(incomingPluginConfig.collections ?? [])\n\n const labels: Record<string, (typeof collections)[number]['labels']> = {}\n for (const collection of collections) {\n if (enabledSlugSet.has(collection.slug)) {\n labels[collection.slug] = collection.labels\n }\n }\n\n const pluginConfig: SanitizedSearchPluginConfig = {\n // write any config defaults here\n deleteDrafts: true,\n labels,\n reindexBatchSize: incomingPluginConfig?.reindexBatchSize || 50,\n syncDrafts: false,\n ...incomingPluginConfig,\n }\n\n // add afterChange and afterDelete hooks to every search-enabled collection\n const collectionsWithSearchHooks = config?.collections\n ?.map((collection) => {\n const { hooks: existingHooks } = collection\n\n const isEnabled = enabledSlugSet.has(collection.slug)\n if (isEnabled) {\n return {\n ...collection,\n hooks: {\n ...collection.hooks,\n afterChange: [\n ...(existingHooks?.afterChange || []),\n async (args: CollectionAfterChangeHookArgs) => {\n await syncWithSearch({\n ...args,\n collection: collection.slug,\n pluginConfig,\n })\n },\n ],\n beforeDelete: [\n ...(existingHooks?.beforeDelete || []),\n deleteFromSearch(pluginConfig),\n ],\n },\n }\n }\n\n return collection\n })\n .filter(Boolean)\n\n return {\n ...config,\n collections: [\n ...(collectionsWithSearchHooks || []),\n generateSearchCollection(pluginConfig),\n ],\n }\n }\n\n return config\n },\n})\n"],"names":["definePlugin","deleteFromSearch","syncWithSearch","generateSearchCollection","searchPlugin","slug","plugin","config","options","incomingPluginConfig","collections","shouldLocalize","localize","Boolean","localization","enabledSlugSet","Set","labels","collection","has","pluginConfig","deleteDrafts","reindexBatchSize","syncDrafts","collectionsWithSearchHooks","map","hooks","existingHooks","isEnabled","afterChange","args","beforeDelete","filter"],"mappings":"AAEA,SAASA,YAAY,QAAQ,UAA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WAAWb,IAAI;wCAC3Be;oCACF;gCACF;6BACD;4BACDW,cAAc;mCACRJ,eAAeI,gBAAgB,EAAE;gCACrC9B,iBAAiBmB;6BAClB;wBACH;oBACF;gBACF;gBAEA,OAAOF;YACT,GACCc,OAAOnB;YAEV,OAAO;gBACL,GAAGN,MAAM;gBACTG,aAAa;uBACPc,8BAA8B,EAAE;oBACpCrB,yBAAyBiB;iBAC1B;YACH;QACF;QAEA,OAAOb;IACT;AACF,GAAE"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CollectionAfterChangeHook, CollectionBeforeDeleteHook, CollectionConfig, Field, Locale, Payload, PayloadRequest, StaticLabel } from 'payload';
|
|
1
|
+
import type { CollectionAfterChangeHook, CollectionBeforeDeleteHook, CollectionConfig, Field, Locale, Payload, PayloadRequest, StaticLabel, TypedLocale } from 'payload';
|
|
2
2
|
export type DocToSync = {
|
|
3
3
|
[key: string]: any;
|
|
4
4
|
doc: {
|
|
@@ -19,15 +19,13 @@ export type BeforeSync = (args: {
|
|
|
19
19
|
export type FieldsOverride = (args: {
|
|
20
20
|
defaultFields: Field[];
|
|
21
21
|
}) => Field[];
|
|
22
|
-
export type SkipSyncFunction
|
|
22
|
+
export type SkipSyncFunction = (args: {
|
|
23
23
|
collectionSlug: string;
|
|
24
24
|
doc: any;
|
|
25
|
-
locale:
|
|
26
|
-
locale: unknown;
|
|
27
|
-
} ? ConfigTypes['locale'] : string | undefined;
|
|
25
|
+
locale: TypedLocale | undefined;
|
|
28
26
|
req: PayloadRequest;
|
|
29
27
|
}) => boolean | Promise<boolean>;
|
|
30
|
-
export type SearchPluginConfig
|
|
28
|
+
export type SearchPluginConfig = {
|
|
31
29
|
beforeSync?: BeforeSync;
|
|
32
30
|
collections?: string[];
|
|
33
31
|
defaultPriorities?: {
|
|
@@ -69,7 +67,7 @@ export type SearchPluginConfig<ConfigTypes = unknown> = {
|
|
|
69
67
|
* return !tenant.allowedLocales.includes(locale)
|
|
70
68
|
* }
|
|
71
69
|
*/
|
|
72
|
-
skipSync?: SkipSyncFunction
|
|
70
|
+
skipSync?: SkipSyncFunction;
|
|
73
71
|
/**
|
|
74
72
|
* Controls whether drafts are synced to the search index
|
|
75
73
|
*
|
|
@@ -83,13 +81,13 @@ export type CollectionLabels = {
|
|
|
83
81
|
export type ResolvedCollectionLabels = {
|
|
84
82
|
[collection: string]: StaticLabel;
|
|
85
83
|
};
|
|
86
|
-
export type SearchPluginConfigWithLocales
|
|
84
|
+
export type SearchPluginConfigWithLocales = {
|
|
87
85
|
labels?: CollectionLabels;
|
|
88
|
-
} & SearchPluginConfig
|
|
89
|
-
export type SanitizedSearchPluginConfig
|
|
86
|
+
} & SearchPluginConfig;
|
|
87
|
+
export type SanitizedSearchPluginConfig = {
|
|
90
88
|
reindexBatchSize: number;
|
|
91
89
|
syncDrafts: boolean;
|
|
92
|
-
} & SearchPluginConfigWithLocales
|
|
90
|
+
} & SearchPluginConfigWithLocales;
|
|
93
91
|
export type SyncWithSearchArgs = {
|
|
94
92
|
collection: string;
|
|
95
93
|
pluginConfig: SanitizedSearchPluginConfig;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,0BAA0B,EAC1B,gBAAgB,EAChB,KAAK,EACL,MAAM,EACN,OAAO,EACP,cAAc,EACd,WAAW,EACZ,MAAM,SAAS,CAAA;AAEhB,MAAM,MAAM,SAAS,GAAG;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;IAClB,GAAG,EAAE;QACH,UAAU,EAAE,MAAM,CAAA;QAClB,KAAK,EAAE,MAAM,CAAA;KACd,CAAA;IACD,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,MAAM,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE;IAC9B,cAAc,E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;AAEtB,MAAM,MAAM,2BAA2B,GAAG;IACxC,gBAAgB,EAAE,MAAM,CAAA;IACxB,UAAU,EAAE,OAAO,CAAA;CACpB,GAAG,6BAA6B,CAAA;AAEjC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,2BAA2B,CAAA;CAC1C,GAAG,IAAI,CAAC,UAAU,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAA;AAEhE,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;IACvB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAA;CACzB,GAAG,IAAI,CAAC,kBAAkB,EAAE,SAAS,GAAG,aAAa,CAAC,CAAA;AAIvD,MAAM,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,kBAAkB,KAAK,UAAU,CAAC,yBAAyB,CAAC,CAAA;AAEhG,MAAM,MAAM,gBAAgB,GAAG,CAAC,IAAI,EAAE,kBAAkB,KAAK,0BAA0B,CAAA"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n CollectionAfterChangeHook,\n CollectionBeforeDeleteHook,\n CollectionConfig,\n Field,\n Locale,\n Payload,\n PayloadRequest,\n StaticLabel,\n} from 'payload'\n\nexport type DocToSync = {\n [key: string]: any\n doc: {\n relationTo: string\n value: string\n }\n title: string\n}\n\nexport type BeforeSync = (args: {\n collectionSlug: string\n originalDoc: {\n [key: string]: any\n }\n payload: Payload\n req: PayloadRequest\n searchDoc: DocToSync\n}) => DocToSync | Promise<DocToSync>\n\nexport type FieldsOverride = (args: { defaultFields: Field[] }) => Field[]\n\nexport type SkipSyncFunction
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n CollectionAfterChangeHook,\n CollectionBeforeDeleteHook,\n CollectionConfig,\n Field,\n Locale,\n Payload,\n PayloadRequest,\n StaticLabel,\n TypedLocale,\n} from 'payload'\n\nexport type DocToSync = {\n [key: string]: any\n doc: {\n relationTo: string\n value: string\n }\n title: string\n}\n\nexport type BeforeSync = (args: {\n collectionSlug: string\n originalDoc: {\n [key: string]: any\n }\n payload: Payload\n req: PayloadRequest\n searchDoc: DocToSync\n}) => DocToSync | Promise<DocToSync>\n\nexport type FieldsOverride = (args: { defaultFields: Field[] }) => Field[]\n\nexport type SkipSyncFunction = (args: {\n collectionSlug: string\n doc: any\n locale: TypedLocale | undefined\n req: PayloadRequest\n}) => boolean | Promise<boolean>\n\nexport type SearchPluginConfig = {\n beforeSync?: BeforeSync\n collections?: string[]\n defaultPriorities?: {\n [collection: string]: ((doc: any) => number | Promise<number>) | number\n }\n /**\n * Controls whether drafts are deleted from the search index\n *\n * @default true\n */\n deleteDrafts?: boolean\n localize?: boolean\n /**\n * We use batching when re-indexing large collections. You can control the amount of items per batch, lower numbers should help with memory.\n *\n * @default 50\n */\n reindexBatchSize?: number\n searchOverrides?: { fields?: FieldsOverride } & Partial<Omit<CollectionConfig, 'fields'>>\n /**\n * Determine whether to skip syncing a document for a specific locale.\n * Useful for multi-tenant applications, conditional indexing, or any scenario where\n * sync behavior should vary by locale, document, or other factors.\n *\n * @default undefined - All configured locales will be synced\n *\n * @example\n * // Skip syncing based on document's tenant settings\n * skipSync: async ({ locale, req, doc, collectionSlug }) => {\n * // For non-localized collections, locale will be undefined\n * if (!locale) return false\n *\n * const tenant = await req.payload.findByID({\n * collection: 'tenants',\n * id: doc.tenant.id\n * })\n * return !tenant.allowedLocales.includes(locale)\n * }\n */\n skipSync?: SkipSyncFunction\n /**\n * Controls whether drafts are synced to the search index\n *\n * @default false\n */\n syncDrafts?: boolean\n}\n\nexport type CollectionLabels = {\n [collection: string]: CollectionConfig['labels']\n}\n\nexport type ResolvedCollectionLabels = {\n [collection: string]: StaticLabel\n}\n\nexport type SearchPluginConfigWithLocales = {\n labels?: CollectionLabels\n} & SearchPluginConfig\n\nexport type SanitizedSearchPluginConfig = {\n reindexBatchSize: number\n syncDrafts: boolean\n} & SearchPluginConfigWithLocales\n\nexport type SyncWithSearchArgs = {\n collection: string\n pluginConfig: SanitizedSearchPluginConfig\n} & Omit<Parameters<CollectionAfterChangeHook>[0], 'collection'>\n\nexport type SyncDocArgs = {\n locale?: Locale['code']\n onSyncError?: () => void\n} & Omit<SyncWithSearchArgs, 'context' | 'previousDoc'>\n\n// Extend the `CollectionAfterChangeHook` with more function args\n// Convert the `collection` arg from `SanitizedCollectionConfig` to a string\nexport type SyncWithSearch = (Args: SyncWithSearchArgs) => ReturnType<CollectionAfterChangeHook>\n\nexport type DeleteFromSearch = (args: SearchPluginConfig) => CollectionBeforeDeleteHook\n"],"names":[],"mappings":"AAwHA,WAAuF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/plugin-search",
|
|
3
|
-
"version": "4.0.0-internal.
|
|
3
|
+
"version": "4.0.0-internal.811e0a4",
|
|
4
4
|
"description": "Search plugin for Payload",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"payload",
|
|
@@ -50,19 +50,19 @@
|
|
|
50
50
|
"dist"
|
|
51
51
|
],
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@payloadcms/next": "4.0.0-internal.
|
|
54
|
-
"@payloadcms/ui": "4.0.0-internal.
|
|
53
|
+
"@payloadcms/next": "4.0.0-internal.811e0a4",
|
|
54
|
+
"@payloadcms/ui": "4.0.0-internal.811e0a4"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@types/react": "19.2.14",
|
|
58
58
|
"@types/react-dom": "19.2.3",
|
|
59
59
|
"@payloadcms/eslint-config": "3.28.0",
|
|
60
|
-
"payload": "4.0.0-internal.
|
|
60
|
+
"payload": "4.0.0-internal.811e0a4"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"react": "^19.0.1 || ^19.1.2 || ^19.2.1",
|
|
64
64
|
"react-dom": "^19.0.1 || ^19.1.2 || ^19.2.1",
|
|
65
|
-
"payload": "4.0.0-internal.
|
|
65
|
+
"payload": "4.0.0-internal.811e0a4"
|
|
66
66
|
},
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"registry": "https://registry.npmjs.org/"
|