@payloadcms/ui 3.64.0-internal.fc1e451 → 3.64.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/elements/Autosave/index.js +2 -2
  2. package/dist/elements/Autosave/index.js.map +1 -1
  3. package/dist/elements/DeleteMany/index.d.ts.map +1 -1
  4. package/dist/elements/DeleteMany/index.js +1 -0
  5. package/dist/elements/DeleteMany/index.js.map +1 -1
  6. package/dist/elements/EditMany/DrawerContent.d.ts.map +1 -1
  7. package/dist/elements/EditMany/DrawerContent.js +1 -0
  8. package/dist/elements/EditMany/DrawerContent.js.map +1 -1
  9. package/dist/elements/PublishMany/DrawerContent.d.ts.map +1 -1
  10. package/dist/elements/PublishMany/DrawerContent.js +1 -0
  11. package/dist/elements/PublishMany/DrawerContent.js.map +1 -1
  12. package/dist/elements/RestoreMany/index.d.ts.map +1 -1
  13. package/dist/elements/RestoreMany/index.js +1 -0
  14. package/dist/elements/RestoreMany/index.js.map +1 -1
  15. package/dist/elements/UnpublishMany/DrawerContent.d.ts.map +1 -1
  16. package/dist/elements/UnpublishMany/DrawerContent.js +1 -0
  17. package/dist/elements/UnpublishMany/DrawerContent.js.map +1 -1
  18. package/dist/elements/withMergedProps/index.d.ts +1 -1
  19. package/dist/elements/withMergedProps/index.js +1 -1
  20. package/dist/elements/withMergedProps/index.js.map +1 -1
  21. package/dist/exports/client/index.js +12 -12
  22. package/dist/exports/client/index.js.map +4 -4
  23. package/dist/exports/shared/index.js.map +1 -1
  24. package/dist/fields/Upload/Input.d.ts.map +1 -1
  25. package/dist/fields/Upload/Input.js +54 -25
  26. package/dist/fields/Upload/Input.js.map +1 -1
  27. package/dist/forms/Form/index.d.ts.map +1 -1
  28. package/dist/forms/Form/index.js +7 -3
  29. package/dist/forms/Form/index.js.map +1 -1
  30. package/dist/providers/Auth/index.d.ts +34 -0
  31. package/dist/providers/Auth/index.d.ts.map +1 -1
  32. package/dist/providers/Auth/index.js.map +1 -1
  33. package/dist/providers/Locale/index.d.ts.map +1 -1
  34. package/dist/providers/Locale/index.js +14 -19
  35. package/dist/providers/Locale/index.js.map +1 -1
  36. package/dist/providers/TableColumns/buildColumnState/renderCell.d.ts.map +1 -1
  37. package/dist/providers/TableColumns/buildColumnState/renderCell.js +19 -1
  38. package/dist/providers/TableColumns/buildColumnState/renderCell.js.map +1 -1
  39. package/dist/utilities/normalizeRelationshipValue.d.ts +29 -0
  40. package/dist/utilities/normalizeRelationshipValue.d.ts.map +1 -0
  41. package/dist/utilities/normalizeRelationshipValue.js +59 -0
  42. package/dist/utilities/normalizeRelationshipValue.js.map +1 -0
  43. package/dist/utilities/normalizeRelationshipValue.spec.js +373 -0
  44. package/dist/utilities/normalizeRelationshipValue.spec.js.map +1 -0
  45. package/dist/views/Edit/Auth/index.d.ts.map +1 -1
  46. package/dist/views/Edit/Auth/index.js +2 -7
  47. package/dist/views/Edit/Auth/index.js.map +1 -1
  48. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"DrawerContent.js","names":["getTranslation","useRouter","useSearchParams","combineWhereConstraints","mergeListSearchAndWhere","qs","React","useCallback","toast","useConfig","useLocale","useRouteCache","useTranslation","requests","parseSearchParams","ConfirmationModal","UnpublishManyDrawerContent","props","collection","slug","labels","plural","singular","drawerSlug","ids","onSuccess","selectAll","where","config","routes","api","serverURL","code","locale","i18n","t","searchParams","router","clearRouteCache","addDefaultError","error","queryString","useMemo","whereConstraints","_status","not_equals","push","queryWithSearch","collectionConfig","search","get","id","in","stringify","addQueryPrefix","handleUnpublish","patch","body","JSON","headers","language","then","res","json","deletedDocs","docs","length","successLabel","status","success","count","label","errors","message","description","map","join","replace","page","undefined","forEach","_err","_jsx","confirmingLabel","heading","modalSlug","onConfirm"],"sources":["../../../src/elements/UnpublishMany/DrawerContent.tsx"],"sourcesContent":["import type { Where } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { useRouter, useSearchParams } from 'next/navigation.js'\nimport { combineWhereConstraints, mergeListSearchAndWhere } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport React, { useCallback } from 'react'\nimport { toast } from 'sonner'\n\nimport type { UnpublishManyProps } from './index.js'\n\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useLocale } from '../../providers/Locale/index.js'\nimport { useRouteCache } from '../../providers/RouteCache/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { requests } from '../../utilities/api.js'\nimport { parseSearchParams } from '../../utilities/parseSearchParams.js'\nimport { ConfirmationModal } from '../ConfirmationModal/index.js'\n\ntype UnpublishManyDrawerContentProps = {\n drawerSlug: string\n ids: (number | string)[]\n onSuccess?: () => void\n selectAll: boolean\n where?: Where\n} & UnpublishManyProps\n\nexport function UnpublishManyDrawerContent(props: UnpublishManyDrawerContentProps) {\n const {\n collection,\n collection: { slug, labels: { plural, singular } } = {},\n drawerSlug,\n ids,\n onSuccess,\n selectAll,\n where,\n } = props\n\n const {\n config: {\n routes: { api },\n serverURL,\n },\n } = useConfig()\n const { code: locale } = useLocale()\n const { i18n, t } = useTranslation()\n const searchParams = useSearchParams()\n const router = useRouter()\n const { clearRouteCache } = useRouteCache()\n const addDefaultError = useCallback(() => {\n toast.error(t('error:unknown'))\n }, [t])\n\n const queryString = React.useMemo((): string => {\n const whereConstraints: Where[] = [\n {\n _status: {\n not_equals: 'draft',\n },\n },\n ]\n\n if (where) {\n whereConstraints.push(where)\n }\n\n const queryWithSearch = mergeListSearchAndWhere({\n collectionConfig: collection,\n search: searchParams.get('search'),\n })\n\n if (queryWithSearch) {\n whereConstraints.push(queryWithSearch)\n }\n\n if (!selectAll) {\n // If we're not selecting all, we need to select specific docs\n whereConstraints.push({\n id: {\n in: ids || [],\n },\n })\n }\n\n return qs.stringify(\n {\n locale,\n where: combineWhereConstraints(whereConstraints),\n },\n { addQueryPrefix: true },\n )\n }, [collection, searchParams, selectAll, ids, locale, where])\n\n const handleUnpublish = useCallback(async () => {\n await requests\n .patch(`${serverURL}${api}/${slug}${queryString}`, {\n body: JSON.stringify({\n _status: 'draft',\n }),\n headers: {\n 'Accept-Language': i18n.language,\n 'Content-Type': 'application/json',\n },\n })\n .then(async (res) => {\n try {\n const json = await res.json()\n\n const deletedDocs = json?.docs.length || 0\n const successLabel = deletedDocs > 1 ? plural : singular\n\n if (res.status < 400 || deletedDocs > 0) {\n toast.success(\n t('general:updatedCountSuccessfully', {\n count: deletedDocs,\n label: getTranslation(successLabel, i18n),\n }),\n )\n\n if (json?.errors.length > 0) {\n toast.error(json.message, {\n description: json.errors.map((error) => error.message).join('\\n'),\n })\n }\n\n router.replace(\n qs.stringify(\n {\n ...parseSearchParams(searchParams),\n page: selectAll ? '1' : undefined,\n },\n { addQueryPrefix: true },\n ),\n )\n\n clearRouteCache()\n\n if (typeof onSuccess === 'function') {\n onSuccess()\n }\n\n return null\n }\n\n if (json.errors) {\n json.errors.forEach((error) => toast.error(error.message))\n } else {\n addDefaultError()\n }\n return false\n } catch (_err) {\n return addDefaultError()\n }\n })\n }, [\n serverURL,\n api,\n slug,\n queryString,\n i18n,\n plural,\n singular,\n t,\n router,\n searchParams,\n selectAll,\n clearRouteCache,\n addDefaultError,\n onSuccess,\n ])\n\n return (\n <ConfirmationModal\n body={t('version:aboutToUnpublishSelection', { label: getTranslation(plural, i18n) })}\n confirmingLabel={t('version:unpublishing')}\n heading={t('version:confirmUnpublish')}\n modalSlug={drawerSlug}\n onConfirm={handleUnpublish}\n />\n )\n}\n"],"mappings":";AAEA,SAASA,cAAc,QAAQ;AAC/B,SAASC,SAAS,EAAEC,eAAe,QAAQ;AAC3C,SAASC,uBAAuB,EAAEC,uBAAuB,QAAQ;AACjE,YAAYC,EAAA,MAAQ;AACpB,OAAOC,KAAA,IAASC,WAAW,QAAQ;AACnC,SAASC,KAAK,QAAQ;AAItB,SAASC,SAAS,QAAQ;AAC1B,SAASC,SAAS,QAAQ;AAC1B,SAASC,aAAa,QAAQ;AAC9B,SAASC,cAAc,QAA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A,CAAKS,MAAM,CAACG,GAAG,CAAEnC,KAAA,IAAUA,KAAA,CAAMiC,OAAO,EAAEG,IAAI,CAAC;YAC9D;UACF;UAEAvC,MAAA,CAAOwC,OAAO,CACZxE,EAAA,CAAGgD,SAAS,CACV;YACE,GAAGvC,iBAAA,CAAkBsB,YAAA,CAAa;YAClC0C,IAAA,EAAMpD,SAAA,GAAY,MAAMqD;UAC1B,GACA;YAAEzB,cAAA,EAAgB;UAAK;UAI3BhB,eAAA;UAEA,IAAI,OAAOb,SAAA,KAAc,YAAY;YACnCA,SAAA;UACF;UAEA,OAAO;QACT;QAEA,IAAIsC,IAAA,CAAKS,MAAM,EAAE;UACfT,IAAA,CAAKS,MAAM,CAACQ,OAAO,CAAExC,KAAA,IAAUhC,KAAA,CAAMgC,KAAK,CAACA,KAAA,CAAMiC,OAAO;QAC1D,OAAO;UACLlC,eAAA;QACF;QACA,OAAO;MACT,EAAE,OAAO0C,IAAA,EAAM;QACb,OAAO1C,eAAA;MACT;IACF;EACJ,GAAG,CACDR,SAAA,EACAD,GAAA,EACAX,IAAA,EACAsB,WAAA,EACAP,IAAA,EACAb,MAAA,EACAC,QAAA,EACAa,CAAA,EACAE,MAAA,EACAD,YAAA,EACAV,SAAA,EACAY,eAAA,EACAC,eAAA,EACAd,SAAA,CACD;EAED,oBACEyD,IAAA,CAACnE,iBAAA;IACC0C,IAAA,EAAMtB,CAAA,CAAE,qCAAqC;MAAEoC,KAAA,EAAOvE,cAAA,CAAeqB,MAAA,EAAQa,IAAA;IAAM;IACnFiD,eAAA,EAAiBhD,CAAA,CAAE;IACnBiD,OAAA,EAASjD,CAAA,CAAE;IACXkD,SAAA,EAAW9D,UAAA;IACX+D,SAAA,EAAW/B;;AAGjB","ignoreList":[]}
1
+ {"version":3,"file":"DrawerContent.js","names":["getTranslation","useRouter","useSearchParams","combineWhereConstraints","mergeListSearchAndWhere","qs","React","useCallback","toast","useConfig","useLocale","useRouteCache","useTranslation","requests","parseSearchParams","ConfirmationModal","UnpublishManyDrawerContent","props","collection","slug","labels","plural","singular","drawerSlug","ids","onSuccess","selectAll","where","config","routes","api","serverURL","code","locale","i18n","t","searchParams","router","clearRouteCache","addDefaultError","error","queryString","useMemo","whereConstraints","_status","not_equals","push","queryWithSearch","collectionConfig","search","get","id","in","stringify","select","addQueryPrefix","handleUnpublish","patch","body","JSON","headers","language","then","res","json","deletedDocs","docs","length","successLabel","status","success","count","label","errors","message","description","map","join","replace","page","undefined","forEach","_err","_jsx","confirmingLabel","heading","modalSlug","onConfirm"],"sources":["../../../src/elements/UnpublishMany/DrawerContent.tsx"],"sourcesContent":["import type { Where } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { useRouter, useSearchParams } from 'next/navigation.js'\nimport { combineWhereConstraints, mergeListSearchAndWhere } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport React, { useCallback } from 'react'\nimport { toast } from 'sonner'\n\nimport type { UnpublishManyProps } from './index.js'\n\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useLocale } from '../../providers/Locale/index.js'\nimport { useRouteCache } from '../../providers/RouteCache/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { requests } from '../../utilities/api.js'\nimport { parseSearchParams } from '../../utilities/parseSearchParams.js'\nimport { ConfirmationModal } from '../ConfirmationModal/index.js'\n\ntype UnpublishManyDrawerContentProps = {\n drawerSlug: string\n ids: (number | string)[]\n onSuccess?: () => void\n selectAll: boolean\n where?: Where\n} & UnpublishManyProps\n\nexport function UnpublishManyDrawerContent(props: UnpublishManyDrawerContentProps) {\n const {\n collection,\n collection: { slug, labels: { plural, singular } } = {},\n drawerSlug,\n ids,\n onSuccess,\n selectAll,\n where,\n } = props\n\n const {\n config: {\n routes: { api },\n serverURL,\n },\n } = useConfig()\n const { code: locale } = useLocale()\n const { i18n, t } = useTranslation()\n const searchParams = useSearchParams()\n const router = useRouter()\n const { clearRouteCache } = useRouteCache()\n const addDefaultError = useCallback(() => {\n toast.error(t('error:unknown'))\n }, [t])\n\n const queryString = React.useMemo((): string => {\n const whereConstraints: Where[] = [\n {\n _status: {\n not_equals: 'draft',\n },\n },\n ]\n\n if (where) {\n whereConstraints.push(where)\n }\n\n const queryWithSearch = mergeListSearchAndWhere({\n collectionConfig: collection,\n search: searchParams.get('search'),\n })\n\n if (queryWithSearch) {\n whereConstraints.push(queryWithSearch)\n }\n\n if (!selectAll) {\n // If we're not selecting all, we need to select specific docs\n whereConstraints.push({\n id: {\n in: ids || [],\n },\n })\n }\n\n return qs.stringify(\n {\n locale,\n select: {},\n where: combineWhereConstraints(whereConstraints),\n },\n { addQueryPrefix: true },\n )\n }, [collection, searchParams, selectAll, ids, locale, where])\n\n const handleUnpublish = useCallback(async () => {\n await requests\n .patch(`${serverURL}${api}/${slug}${queryString}`, {\n body: JSON.stringify({\n _status: 'draft',\n }),\n headers: {\n 'Accept-Language': i18n.language,\n 'Content-Type': 'application/json',\n },\n })\n .then(async (res) => {\n try {\n const json = await res.json()\n\n const deletedDocs = json?.docs.length || 0\n const successLabel = deletedDocs > 1 ? plural : singular\n\n if (res.status < 400 || deletedDocs > 0) {\n toast.success(\n t('general:updatedCountSuccessfully', {\n count: deletedDocs,\n label: getTranslation(successLabel, i18n),\n }),\n )\n\n if (json?.errors.length > 0) {\n toast.error(json.message, {\n description: json.errors.map((error) => error.message).join('\\n'),\n })\n }\n\n router.replace(\n qs.stringify(\n {\n ...parseSearchParams(searchParams),\n page: selectAll ? '1' : undefined,\n },\n { addQueryPrefix: true },\n ),\n )\n\n clearRouteCache()\n\n if (typeof onSuccess === 'function') {\n onSuccess()\n }\n\n return null\n }\n\n if (json.errors) {\n json.errors.forEach((error) => toast.error(error.message))\n } else {\n addDefaultError()\n }\n return false\n } catch (_err) {\n return addDefaultError()\n }\n })\n }, [\n serverURL,\n api,\n slug,\n queryString,\n i18n,\n plural,\n singular,\n t,\n router,\n searchParams,\n selectAll,\n clearRouteCache,\n addDefaultError,\n onSuccess,\n ])\n\n return (\n <ConfirmationModal\n body={t('version:aboutToUnpublishSelection', { label: getTranslation(plural, i18n) })}\n confirmingLabel={t('version:unpublishing')}\n heading={t('version:confirmUnpublish')}\n modalSlug={drawerSlug}\n onConfirm={handleUnpublish}\n />\n )\n}\n"],"mappings":";AAEA,SAASA,cAAc,QAAQ;AAC/B,SAASC,SAAS,EAAEC,eAAe,QAAQ;AAC3C,SAASC,uBAAuB,EAAEC,uBAAuB,QAAQ;AACjE,YAAYC,EAAA,MAAQ;AACpB,OAAOC,KAAA,IAASC,WAAW,QAAQ;AACnC,SAASC,KAAK,QAAQ;AAItB,SAASC,SAAS,QAAQ;AAC1B,SAASC,SAAS,QAAQ;AAC1B,SAASC,aAAa,QAAQ;AAC9B,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,QAAQ;AACzB,SAASC,iBAAiB,QAAQ;AAClC,SAASC,iBAAiB,QAAQ;AAUlC,OAAO,SAASC,2BAA2BC,KAAsC;EAC/E,MAAM;IACJC,UAAU;IACVA,UAAA,EAAY;MAAEC,IAAI;MAAEC,MAAA,EAAQ;QAAEC,MAAM;QAAEC;MAAQ;IAAE,CAAE,GAAG,CAAC,CAAC;IACvDC,UAAU;IACVC,GAAG;IACHC,SAAS;IACTC,SAAS;IACTC;EAAK,CACN,GAAGV,KAAA;EAEJ,MAAM;IACJW,MAAA,EAAQ;MACNC,MAAA,EAAQ;QAAEC;MAAG,CAAE;MACfC;IAAS;EACV,CACF,GAAGtB,SAAA;EACJ,MAAM;IAAEuB,IAAA,EAAMC;EAAM,CAAE,GAAGvB,SAAA;EACzB,MAAM;IAAEwB,IAAI;IAAEC;EAAC,CAAE,GAAGvB,cAAA;EACpB,MAAMwB,YAAA,GAAelC,eAAA;EACrB,MAAMmC,MAAA,GAASpC,SAAA;EACf,MAAM;IAAEqC;EAAe,CAAE,GAAG3B,aAAA;EAC5B,MAAM4B,eAAA,GAAkBhC,WAAA,CAAY;IAClCC,KAAA,CAAMgC,KAAK,CAACL,CAAA,CAAE;EA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,MAAA,EACAD,YAAA,EACAV,SAAA,EACAY,eAAA,EACAC,eAAA,EACAd,SAAA,CACD;EAED,oBACE0D,IAAA,CAACpE,iBAAA;IACC2C,IAAA,EAAMvB,CAAA,CAAE,qCAAqC;MAAEqC,KAAA,EAAOxE,cAAA,CAAeqB,MAAA,EAAQa,IAAA;IAAM;IACnFkD,eAAA,EAAiBjD,CAAA,CAAE;IACnBkD,OAAA,EAASlD,CAAA,CAAE;IACXmD,SAAA,EAAW/D,UAAA;IACXgE,SAAA,EAAW/B;;AAGjB","ignoreList":[]}
@@ -8,7 +8,7 @@ import React from 'react';
8
8
  * rendering the original component.
9
9
  *
10
10
  * @example
11
- * const PredefinedComponent = withMergedProps({
11
+ * const PredefinedComponent = getMergedPropsComponent({
12
12
  * Component: OriginalComponent,
13
13
  * toMergeIntoProps: { someExtraValue: 5 }
14
14
  * });
@@ -10,7 +10,7 @@ import React from 'react';
10
10
  * rendering the original component.
11
11
  *
12
12
  * @example
13
- * const PredefinedComponent = withMergedProps({
13
+ * const PredefinedComponent = getMergedPropsComponent({
14
14
  * Component: OriginalComponent,
15
15
  * toMergeIntoProps: { someExtraValue: 5 }
16
16
  * });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["isReactServerComponentOrFunction","serverProps","React","withMergedProps","Component","sanitizeServerOnlyProps","toMergeIntoProps","undefined","MergedPropsComponent","passedProps","mergedProps","simpleMergeProps","forEach","prop","_jsx","props","toMerge"],"sources":["../../../src/elements/withMergedProps/index.tsx"],"sourcesContent":["import { isReactServerComponentOrFunction, serverProps } from 'payload/shared'\nimport React from 'react'\n\n/**\n * Creates a higher-order component (HOC) that merges predefined properties (`toMergeIntoProps`)\n * with any properties passed to the resulting component.\n *\n * Use this when you want to pre-specify some props for a component, while also allowing users to\n * pass in their own props. The HOC ensures the passed props and predefined props are combined before\n * rendering the original component.\n *\n * @example\n * const PredefinedComponent = withMergedProps({\n * Component: OriginalComponent,\n * toMergeIntoProps: { someExtraValue: 5 }\n * });\n * // Using <PredefinedComponent customProp=\"value\" /> will result in\n * // <OriginalComponent customProp=\"value\" someExtraValue={5} />\n *\n * @returns A higher-order component with combined properties.\n *\n * @param Component - The original component to wrap.\n * @param sanitizeServerOnlyProps - If true, server-only props will be removed from the merged props. @default true if the component is not a server component, false otherwise.\n * @param toMergeIntoProps - The properties to merge into the passed props.\n */\nexport function withMergedProps<ToMergeIntoProps, CompleteReturnProps>({\n Component,\n sanitizeServerOnlyProps,\n toMergeIntoProps,\n}: {\n Component: React.FC<CompleteReturnProps>\n sanitizeServerOnlyProps?: boolean\n toMergeIntoProps: ToMergeIntoProps\n}): React.FC<CompleteReturnProps> {\n if (sanitizeServerOnlyProps === undefined) {\n sanitizeServerOnlyProps = !isReactServerComponentOrFunction(Component)\n }\n // A wrapper around the args.Component to inject the args.toMergeArgs as props, which are merged with the passed props\n const MergedPropsComponent: React.FC<CompleteReturnProps> = (passedProps) => {\n const mergedProps = simpleMergeProps(passedProps, toMergeIntoProps) as CompleteReturnProps\n\n if (sanitizeServerOnlyProps) {\n serverProps.forEach((prop) => {\n delete mergedProps[prop]\n })\n }\n\n return <Component {...mergedProps} />\n }\n\n return MergedPropsComponent\n}\n\nfunction simpleMergeProps(props, toMerge) {\n return { ...props, ...toMerge }\n}\n"],"mappings":";AAAA,SAASA,gCAAgC,EAAEC,WAAW,QAAQ;AAC9D,OAAOC,KAAA,MAAW;AAElB;;;;;;;;;;;;;;;;;;;;;;AAsBA,OAAO,SAASC,gBAAuD;EACrEC,SAAS;EACTC,uBAAuB;EACvBC;AAAgB,CAKjB;EACC,IAAID,uBAAA,KAA4BE,SAAA,EAAW;IACzCF,uBAAA,GAA0B,CAACL,gCAAA,CAAiCI,SAAA;EAC9D;EACA;EACA,MAAMI,oBAAA,GAAuDC,WAAA;IAC3D,MAAMC,WAAA,GAAcC,gBAAA,CAAiBF,WAAA,EAAaH,gBAAA;IAElD,IAAID,uBAAA,EAAyB;MAC3BJ,WAAA,CAAYW,OAAO,CAAEC,IAAA;QACnB,OAAOH,WAAW,CAACG,IAAA,CAAK;MAC1B;IACF;IAEA,oBAAOC,IAAA,CAACV,SAAA;MAAW,GAAGM;;EACxB;EAEA,OAAOF,oBAAA;AACT;AAEA,SAASG,iBAAiBI,KAAK,EAAEC,OAAO;EACtC,OAAO;IAAE,GAAGD,KAAK;IAAE,GAAGC;EAAQ;AAChC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["isReactServerComponentOrFunction","serverProps","React","withMergedProps","Component","sanitizeServerOnlyProps","toMergeIntoProps","undefined","MergedPropsComponent","passedProps","mergedProps","simpleMergeProps","forEach","prop","_jsx","props","toMerge"],"sources":["../../../src/elements/withMergedProps/index.tsx"],"sourcesContent":["import { isReactServerComponentOrFunction, serverProps } from 'payload/shared'\nimport React from 'react'\n\n/**\n * Creates a higher-order component (HOC) that merges predefined properties (`toMergeIntoProps`)\n * with any properties passed to the resulting component.\n *\n * Use this when you want to pre-specify some props for a component, while also allowing users to\n * pass in their own props. The HOC ensures the passed props and predefined props are combined before\n * rendering the original component.\n *\n * @example\n * const PredefinedComponent = getMergedPropsComponent({\n * Component: OriginalComponent,\n * toMergeIntoProps: { someExtraValue: 5 }\n * });\n * // Using <PredefinedComponent customProp=\"value\" /> will result in\n * // <OriginalComponent customProp=\"value\" someExtraValue={5} />\n *\n * @returns A higher-order component with combined properties.\n *\n * @param Component - The original component to wrap.\n * @param sanitizeServerOnlyProps - If true, server-only props will be removed from the merged props. @default true if the component is not a server component, false otherwise.\n * @param toMergeIntoProps - The properties to merge into the passed props.\n */\nexport function withMergedProps<ToMergeIntoProps, CompleteReturnProps>({\n Component,\n sanitizeServerOnlyProps,\n toMergeIntoProps,\n}: {\n Component: React.FC<CompleteReturnProps>\n sanitizeServerOnlyProps?: boolean\n toMergeIntoProps: ToMergeIntoProps\n}): React.FC<CompleteReturnProps> {\n if (sanitizeServerOnlyProps === undefined) {\n sanitizeServerOnlyProps = !isReactServerComponentOrFunction(Component)\n }\n // A wrapper around the args.Component to inject the args.toMergeArgs as props, which are merged with the passed props\n const MergedPropsComponent: React.FC<CompleteReturnProps> = (passedProps) => {\n const mergedProps = simpleMergeProps(passedProps, toMergeIntoProps) as CompleteReturnProps\n\n if (sanitizeServerOnlyProps) {\n serverProps.forEach((prop) => {\n delete mergedProps[prop]\n })\n }\n\n return <Component {...mergedProps} />\n }\n\n return MergedPropsComponent\n}\n\nfunction simpleMergeProps(props, toMerge) {\n return { ...props, ...toMerge }\n}\n"],"mappings":";AAAA,SAASA,gCAAgC,EAAEC,WAAW,QAAQ;AAC9D,OAAOC,KAAA,MAAW;AAElB;;;;;;;;;;;;;;;;;;;;;;AAsBA,OAAO,SAASC,gBAAuD;EACrEC,SAAS;EACTC,uBAAuB;EACvBC;AAAgB,CAKjB;EACC,IAAID,uBAAA,KAA4BE,SAAA,EAAW;IACzCF,uBAAA,GAA0B,CAACL,gCAAA,CAAiCI,SAAA;EAC9D;EACA;EACA,MAAMI,oBAAA,GAAuDC,WAAA;IAC3D,MAAMC,WAAA,GAAcC,gBAAA,CAAiBF,WAAA,EAAaH,gBAAA;IAElD,IAAID,uBAAA,EAAyB;MAC3BJ,WAAA,CAAYW,OAAO,CAAEC,IAAA;QACnB,OAAOH,WAAW,CAACG,IAAA,CAAK;MAC1B;IACF;IAEA,oBAAOC,IAAA,CAACV,SAAA;MAAW,GAAGM;;EACxB;EAEA,OAAOF,oBAAA;AACT;AAEA,SAASG,iBAAiBI,KAAK,EAAEC,OAAO;EACtC,OAAO;IAAE,GAAGD,KAAK;IAAE,GAAGC;EAAQ;AAChC","ignoreList":[]}