@payloadcms/ui 3.9.0 → 3.11.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 (35) hide show
  1. package/dist/elements/CopyLocaleData/index.js +1 -1
  2. package/dist/elements/CopyLocaleData/index.js.map +1 -1
  3. package/dist/elements/RelationshipTable/cells/DrawerLink/index.d.ts +1 -0
  4. package/dist/elements/RelationshipTable/cells/DrawerLink/index.d.ts.map +1 -1
  5. package/dist/elements/RelationshipTable/cells/DrawerLink/index.js +28 -10
  6. package/dist/elements/RelationshipTable/cells/DrawerLink/index.js.map +1 -1
  7. package/dist/elements/RelationshipTable/index.d.ts.map +1 -1
  8. package/dist/elements/RelationshipTable/index.js +5 -0
  9. package/dist/elements/RelationshipTable/index.js.map +1 -1
  10. package/dist/elements/Status/index.d.ts.map +1 -1
  11. package/dist/elements/Status/index.js +40 -32
  12. package/dist/elements/Status/index.js.map +1 -1
  13. package/dist/elements/Tooltip/index.js +4 -4
  14. package/dist/elements/Tooltip/index.js.map +1 -1
  15. package/dist/exports/client/index.d.ts +1 -0
  16. package/dist/exports/client/index.d.ts.map +1 -1
  17. package/dist/exports/client/index.js +10 -10
  18. package/dist/exports/client/index.js.map +3 -3
  19. package/dist/exports/shared/index.js.map +1 -1
  20. package/dist/fields/Join/index.d.ts.map +1 -1
  21. package/dist/fields/Join/index.js +44 -6
  22. package/dist/fields/Join/index.js.map +1 -1
  23. package/dist/fields/Relationship/index.js +6 -6
  24. package/dist/fields/Relationship/index.js.map +1 -1
  25. package/dist/providers/DocumentInfo/index.js +8 -8
  26. package/dist/providers/DocumentInfo/index.js.map +1 -1
  27. package/dist/providers/DocumentInfo/types.d.ts +2 -2
  28. package/dist/providers/DocumentInfo/types.js.map +1 -1
  29. package/dist/utilities/handleFormStateLocking.js +2 -2
  30. package/dist/utilities/handleFormStateLocking.js.map +1 -1
  31. package/dist/utilities/handleTakeOver.d.ts +1 -1
  32. package/dist/utilities/handleTakeOver.js.map +1 -1
  33. package/dist/views/Edit/index.js +3 -3
  34. package/dist/views/Edit/index.js.map +1 -1
  35. package/package.json +5 -5
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/elements/TableColumns/filterFields.tsx", "../../../src/elements/TableColumns/getInitialColumns.ts", "../../../src/elements/Translation/index.tsx", "../../../src/elements/withMergedProps/index.tsx", "../../../src/elements/WithServerSideProps/index.tsx", "../../../src/fields/mergeFieldStyles.ts", "../../../src/forms/Form/reduceToSerializableFields.ts", "../../../src/graphics/Icon/index.tsx", "../../../src/graphics/Logo/index.tsx", "../../../src/utilities/abortAndIgnore.ts", "../../../src/utilities/api.ts", "../../../src/utilities/findLocaleFromCode.ts", "../../../src/utilities/formatAdminURL.ts", "../../../src/utilities/formatDate.ts", "../../../src/utilities/formatDocTitle.ts", "../../../src/utilities/groupNavItems.ts", "../../../src/utilities/handleBackToDashboard.tsx", "../../../src/utilities/handleGoBack.tsx", "../../../src/utilities/handleTakeOver.tsx", "../../../src/utilities/hasSavePermission.ts", "../../../src/utilities/isClientUserObject.ts", "../../../src/utilities/isEditing.ts", "../../../src/utilities/mergeListSearchAndWhere.ts", "../../../src/utilities/sanitizeID.ts"],
4
- "sourcesContent": ["import type { ClientField, Field } from 'payload'\n\nimport { fieldIsHiddenOrDisabled, fieldIsID } from 'payload/shared'\n\n/**\n * Filters fields that are hidden, disabled, or have `disableListColumn` set to `true`\n * Does so recursively for `tabs` fields.\n */\nexport const filterFields = <T extends ClientField | Field>(incomingFields: T[]): T[] => {\n const shouldSkipField = (field: T): boolean =>\n (field.type !== 'ui' && fieldIsHiddenOrDisabled(field) && !fieldIsID(field)) ||\n field?.admin?.disableListColumn === true\n\n const fields: T[] = incomingFields?.reduce((acc, field) => {\n if (shouldSkipField(field)) {\n return acc\n }\n\n // extract top-level `tabs` fields and filter out the same\n const formattedField: T =\n field.type === 'tabs' && 'tabs' in field\n ? {\n ...field,\n tabs: field.tabs.map((tab) => ({\n ...tab,\n fields: tab.fields.filter((tabField) => !shouldSkipField(tabField)),\n })),\n }\n : field\n\n acc.push(formattedField)\n\n return acc\n }, [])\n\n return fields\n}\n", "import type { ClientField, CollectionConfig, Field } from 'payload'\n\nimport { fieldAffectsData } from 'payload/shared'\n\nimport type { ColumnPreferences } from '../../providers/ListQuery/index.js'\n\nconst getRemainingColumns = <T extends ClientField[] | Field[]>(\n fields: T,\n useAsTitle: string,\n): ColumnPreferences =>\n fields?.reduce((remaining, field) => {\n if (fieldAffectsData(field) && field.name === useAsTitle) {\n return remaining\n }\n\n if (!fieldAffectsData(field) && 'fields' in field) {\n return [...remaining, ...getRemainingColumns(field.fields, useAsTitle)]\n }\n\n if (field.type === 'tabs' && 'tabs' in field) {\n return [\n ...remaining,\n ...field.tabs.reduce(\n (tabFieldColumns, tab) => [\n ...tabFieldColumns,\n ...('name' in tab ? [tab.name] : getRemainingColumns(tab.fields, useAsTitle)),\n ],\n [],\n ),\n ]\n }\n\n return [...remaining, field.name]\n }, [])\n\n/**\n * Returns the initial columns to display in the table based on the following criteria:\n * 1. If `defaultColumns` is set in the collection config, use those columns\n * 2. Otherwise take `useAtTitle, if set, and the next 3 fields that are not hidden or disabled\n */\nexport const getInitialColumns = <T extends ClientField[] | Field[]>(\n fields: T,\n useAsTitle: CollectionConfig['admin']['useAsTitle'],\n defaultColumns: CollectionConfig['admin']['defaultColumns'],\n): ColumnPreferences => {\n let initialColumns = []\n\n if (Array.isArray(defaultColumns) && defaultColumns.length >= 1) {\n initialColumns = defaultColumns\n } else {\n if (useAsTitle) {\n initialColumns.push(useAsTitle)\n }\n\n const remainingColumns = getRemainingColumns(fields, useAsTitle)\n\n initialColumns = initialColumns.concat(remainingColumns)\n initialColumns = initialColumns.slice(0, 4)\n }\n\n return initialColumns.map((column) => ({\n accessor: column,\n active: true,\n }))\n}\n", "import type { ClientTranslationKeys, TFunction } from '@payloadcms/translations'\n\nimport * as React from 'react'\n\nconst RecursiveTranslation: React.FC<{\n elements?: Record<string, React.FC<{ children: React.ReactNode }>>\n translationString: string\n}> = ({ elements, translationString }) => {\n const regex = /(<[^>]+>.*?<\\/[^>]+>)/g\n const sections = translationString.split(regex)\n\n return (\n <span>\n {sections.map((section, index) => {\n if (elements && section.startsWith('<') && section.endsWith('>')) {\n const elementKey = section[1]\n const Element = elements[elementKey]\n\n if (Element) {\n const regex = new RegExp(`<${elementKey}>(.*?)<\\/${elementKey}>`, 'g')\n const children = section.replace(regex, (_, group) => group)\n\n return (\n <Element key={index}>\n <RecursiveTranslation translationString={children} />\n </Element>\n )\n }\n }\n\n return section\n })}\n </span>\n )\n}\n\nexport type TranslationProps = {\n elements?: Record<string, React.FC<{ children: React.ReactNode }>>\n i18nKey: ClientTranslationKeys\n t: TFunction\n variables?: Record<string, unknown>\n}\n\nexport const Translation: React.FC<TranslationProps> = ({ elements, i18nKey, t, variables }) => {\n const stringWithVariables = t(i18nKey, variables || {})\n\n if (!elements) {\n return stringWithVariables\n }\n\n return <RecursiveTranslation elements={elements} translationString={stringWithVariables} />\n}\n", "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", "import type { WithServerSidePropsComponent } from 'payload'\n\nimport { isReactServerComponentOrFunction } from 'payload/shared'\nimport React from 'react'\n\nexport const WithServerSideProps: WithServerSidePropsComponent = ({\n Component,\n serverOnlyProps,\n ...rest\n}) => {\n if (Component) {\n const WithServerSideProps: React.FC = (passedProps) => {\n const propsWithServerOnlyProps = {\n ...passedProps,\n ...(isReactServerComponentOrFunction(Component) ? (serverOnlyProps ?? {}) : {}),\n }\n\n return <Component {...propsWithServerOnlyProps} />\n }\n\n return WithServerSideProps(rest)\n }\n\n return null\n}\n", "import type { ClientField } from 'payload'\n\nexport const mergeFieldStyles = (\n field: ClientField | Omit<ClientField, 'type'>,\n): React.CSSProperties => ({\n ...(field?.admin?.style || {}),\n ...(field?.admin?.width\n ? {\n '--field-width': field.admin.width,\n }\n : {\n flex: '1 1 auto',\n }),\n // allow flex overrides to still take precedence over the fallback\n ...(field?.admin?.style?.flex\n ? {\n flex: field.admin.style.flex,\n }\n : {}),\n})\n", "import { type FormField, type FormState } from 'payload'\nimport { deepCopyObjectComplex } from 'payload/shared'\n\ntype BlacklistedKeys = 'customComponents' | 'validate'\nconst blacklistedKeys: BlacklistedKeys[] = ['validate', 'customComponents']\n\nconst sanitizeField = (incomingField: FormField): FormField => {\n const field = deepCopyObjectComplex(incomingField)\n\n blacklistedKeys.forEach((key) => {\n delete field[key]\n })\n\n return field\n}\n\n/* \n Takes in FormState and removes fields that are not serializable.\n Returns FormState without blacklisted keys.\n**/\nexport const reduceToSerializableFields = (\n fields: FormState,\n): {\n [key: string]: Omit<FormField, BlacklistedKeys>\n} => {\n return Object.keys(fields).reduce(\n (acc, key) => {\n acc[key] = sanitizeField(fields[key])\n return acc\n },\n {} as {\n [key: string]: Omit<FormField, BlacklistedKeys>\n },\n )\n}\n", "import React from 'react'\n\nexport const PayloadIcon: React.FC<{\n fill?: string\n}> = ({ fill: fillFromProps }) => {\n const fill = fillFromProps || 'var(--theme-elevation-1000)'\n\n return (\n <svg\n className=\"graphic-icon\"\n height=\"100%\"\n viewBox=\"0 0 25 25\"\n width=\"100%\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M11.8673 21.2336L4.40922 16.9845C4.31871 16.9309 4.25837 16.8355 4.25837 16.7282V10.1609C4.25837 10.0477 4.38508 9.97616 4.48162 10.0298L13.1404 14.9642C13.2611 15.0358 13.412 14.9464 13.412 14.8093V11.6091C13.412 11.4839 13.3456 11.3647 13.2309 11.2992L2.81624 5.36353C2.72573 5.30989 2.60505 5.30989 2.51454 5.36353L1.15085 6.14422C1.06034 6.19786 1 6.29321 1 6.40048V18.5995C1 18.7068 1.06034 18.8021 1.15085 18.8558L11.8491 24.9583C11.9397 25.0119 12.0603 25.0119 12.1509 24.9583L21.1355 19.8331C21.2562 19.7616 21.2562 19.5948 21.1355 19.5232L18.3357 17.9261C18.2211 17.8605 18.0883 17.8605 17.9737 17.9261L12.175 21.2336C12.0845 21.2872 11.9638 21.2872 11.8733 21.2336H11.8673Z\"\n fill={fill}\n />\n <path\n d=\"M22.8491 6.13827L12.1508 0.0417218C12.0603 -0.0119135 11.9397 -0.0119135 11.8491 0.0417218L6.19528 3.2658C6.0746 3.33731 6.0746 3.50418 6.19528 3.57569L8.97092 5.16091C9.08557 5.22647 9.21832 5.22647 9.33296 5.16091L11.8672 3.71872C11.9578 3.66508 12.0784 3.66508 12.1689 3.71872L19.627 7.96782C19.7175 8.02146 19.7778 8.11681 19.7778 8.22408V14.8212C19.7778 14.9464 19.8442 15.0656 19.9589 15.1311L22.7345 16.7104C22.8552 16.7819 23.006 16.6925 23.006 16.5554V6.40048C23.006 6.29321 22.9457 6.19786 22.8552 6.14423L22.8491 6.13827Z\"\n fill={fill}\n />\n </svg>\n )\n}\n", "import React from 'react'\n\nconst css = `\n .graphic-logo path {\n fill: var(--theme-elevation-1000);\n }\n`\n\nexport const PayloadLogo: React.FC = () => (\n <svg\n className=\"graphic-logo\"\n fill=\"none\"\n height=\"43.5\"\n id=\"b\"\n viewBox=\"0 0 193.38 43.5\"\n width=\"193.38\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <style>{css}</style>\n <g id=\"c\">\n <path d=\"M18.01,35.63l-12.36-7.13c-.15-.09-.25-.25-.25-.43v-11.02c0-.19.21-.31.37-.22l14.35,8.28c.2.12.45-.03.45-.26v-5.37c0-.21-.11-.41-.3-.52L3.01,9c-.15-.09-.35-.09-.5,0l-2.26,1.31c-.15.09-.25.25-.25.43v20.47c0,.18.1.34.25.43l17.73,10.24c.15.09.35.09.5,0l14.89-8.6c.2-.12.2-.4,0-.52l-4.64-2.68c-.19-.11-.41-.11-.6,0l-9.61,5.55c-.15.09-.35.09-.5,0Z\" />\n <path d=\"M36.21,10.3L18.48.07c-.15-.09-.35-.09-.5,0l-9.37,5.41c-.2.12-.2.4,0,.52l4.6,2.66c.19.11.41.11.6,0l4.2-2.42c.15-.09.35-.09.5,0l12.36,7.13c.15.09.25.25.25.43v11.07c0,.21.11.41.3.52l4.6,2.65c.2.12.45-.03.45-.26V10.74c0-.18-.1-.34-.25-.43Z\" />\n <g id=\"d\">\n <path d=\"M193.38,9.47c0,1.94-1.48,3.32-3.3,3.32s-3.31-1.39-3.31-3.32,1.49-3.31,3.31-3.31,3.3,1.39,3.3,3.31ZM192.92,9.47c0-1.68-1.26-2.88-2.84-2.88s-2.84,1.2-2.84,2.88,1.26,2.89,2.84,2.89,2.84-1.2,2.84-2.89ZM188.69,11.17v-3.51h1.61c.85,0,1.35.39,1.35,1.15,0,.53-.3.86-.67,1.02l.79,1.35h-.89l-.72-1.22h-.64v1.22h-.82ZM190.18,9.31c.46,0,.64-.16.64-.5s-.19-.49-.64-.49h-.67v.99h.67Z\" />\n <path d=\"M54.72,24.84v10.93h-5.4V6.1h12.26c7.02,0,11.1,3.2,11.1,9.39s-4.07,9.35-11.06,9.35h-6.9,0ZM61.12,20.52c4.07,0,6.11-1.66,6.11-5.03s-2.04-5.03-6.11-5.03h-6.4v10.06h6.4Z\" />\n <path d=\"M85.94,32.45c-1,2.41-3.66,3.78-7.02,3.78-4.11,0-7.11-2.29-7.11-6.11,0-4.24,3.32-5.98,7.61-6.48l6.32-.71v-1c0-2.58-1.58-3.82-3.99-3.82s-3.74,1.29-3.91,3.24h-5.11c.46-4.53,3.99-7.19,9.18-7.19,5.74,0,9.02,2.7,9.02,8.19v8.15c0,1.95.08,3.58.42,5.28h-5.11c-.21-1.16-.29-2.29-.29-3.32h0ZM85.73,27.58v-1.29l-4.7.54c-2.24.29-3.95.79-3.95,2.99,0,1.66,1.16,2.7,3.28,2.7,2.74,0,5.36-1.62,5.36-4.95h0Z\" />\n <path d=\"M90.39,14.66h5.4l5.86,15.92h.08l5.57-15.92h5.28l-8.23,21.49c-2,5.28-4.45,7.32-8.89,7.36-.71,0-1.7-.08-2.45-.21v-4.03c.62.13.96.13,1.41.13,2.16,0,3.07-.75,4.2-3.66l-8.23-21.07h0Z\" />\n <path d=\"M113.46,35.77V6.1h5.32v29.67h-5.32Z\" />\n <path d=\"M130.79,36.27c-6.23,0-10.68-4.2-10.68-11.05s4.45-11.05,10.68-11.05,10.68,4.24,10.68,11.05-4.45,11.05-10.68,11.05ZM130.79,32.32c3.41,0,5.36-2.66,5.36-7.11s-1.95-7.11-5.36-7.11-5.36,2.7-5.36,7.11,1.91,7.11,5.36,7.11Z\" />\n <path d=\"M156.19,32.45c-1,2.41-3.66,3.78-7.02,3.78-4.11,0-7.11-2.29-7.11-6.11,0-4.24,3.32-5.98,7.61-6.48l6.32-.71v-1c0-2.58-1.58-3.82-3.99-3.82s-3.74,1.29-3.91,3.24h-5.11c.46-4.53,3.99-7.19,9.19-7.19,5.74,0,9.02,2.7,9.02,8.19v8.15c0,1.95.08,3.58.42,5.28h-5.11c-.21-1.16-.29-2.29-.29-3.32h0ZM155.98,27.58v-1.29l-4.7.54c-2.24.29-3.95.79-3.95,2.99,0,1.66,1.16,2.7,3.28,2.7,2.74,0,5.36-1.62,5.36-4.95h0Z\" />\n <path d=\"M178.5,32.41c-1.04,2.12-3.58,3.87-6.78,3.87-5.53,0-9.31-4.49-9.31-11.05s3.78-11.05,9.31-11.05c3.28,0,5.69,1.83,6.69,3.95V6.1h5.32v29.67h-5.24v-3.37h0ZM178.55,24.84c0-4.11-1.95-6.78-5.32-6.78s-5.45,2.83-5.45,7.15,2,7.15,5.45,7.15,5.32-2.66,5.32-6.78v-.75h0Z\" />\n </g>\n </g>\n </svg>\n)\n", "export function abortAndIgnore(controller: AbortController) {\n if (controller) {\n try {\n controller.abort()\n } catch (_err) {\n // swallow error\n }\n }\n}\n", "import * as qs from 'qs-esm'\n\ntype GetOptions = {\n params?: Record<string, unknown>\n} & RequestInit\n\nexport const requests = {\n delete: (url: string, options: RequestInit = { headers: {} }): Promise<Response> => {\n const headers = options && options.headers ? { ...options.headers } : {}\n\n const formattedOptions: RequestInit = {\n ...options,\n credentials: 'include',\n headers: {\n ...headers,\n },\n method: 'delete',\n }\n\n return fetch(url, formattedOptions)\n },\n\n get: (url: string, options: GetOptions = { headers: {} }): Promise<Response> => {\n let query = ''\n if (options.params) {\n query = qs.stringify(options.params, { addQueryPrefix: true })\n }\n return fetch(`${url}${query}`, {\n credentials: 'include',\n ...options,\n })\n },\n\n patch: (url: string, options: RequestInit = { headers: {} }): Promise<Response> => {\n const headers = options && options.headers ? { ...options.headers } : {}\n\n const formattedOptions: RequestInit = {\n ...options,\n credentials: 'include',\n headers: {\n ...headers,\n },\n method: 'PATCH',\n }\n\n return fetch(url, formattedOptions)\n },\n\n post: (url: string, options: RequestInit = { headers: {} }): Promise<Response> => {\n const headers = options && options.headers ? { ...options.headers } : {}\n\n const formattedOptions: RequestInit = {\n ...options,\n credentials: 'include',\n headers: {\n ...headers,\n },\n method: 'post',\n }\n\n return fetch(`${url}`, formattedOptions)\n },\n\n put: (url: string, options: RequestInit = { headers: {} }): Promise<Response> => {\n const headers = options && options.headers ? { ...options.headers } : {}\n\n const formattedOptions: RequestInit = {\n ...options,\n credentials: 'include',\n headers: {\n ...headers,\n },\n method: 'put',\n }\n\n return fetch(url, formattedOptions)\n },\n}\n", "import type { Locale, SanitizedLocalizationConfig } from 'payload'\n/*\n return the Locale for given locale code, else return null\n*/\nexport const findLocaleFromCode = (\n localizationConfig: SanitizedLocalizationConfig,\n locale: string,\n): Locale | null => {\n if (!localizationConfig?.locales || localizationConfig.locales.length === 0) {\n return null\n }\n\n return localizationConfig.locales.find((el) => el?.code === locale)\n}\n", "import type { Config } from 'payload'\n\n/** Will read the `routes.admin` config and appropriately handle `\"/\"` admin paths */\nexport const formatAdminURL = (args: {\n adminRoute: Config['routes']['admin']\n basePath?: string\n path: string\n serverURL?: Config['serverURL']\n}): string => {\n const { adminRoute, basePath = '', path, serverURL } = args\n\n if (adminRoute) {\n if (adminRoute === '/') {\n if (!path) {\n return `${serverURL || ''}${basePath}${adminRoute}`\n }\n } else {\n return `${serverURL || ''}${basePath}${adminRoute}${path}`\n }\n }\n\n return `${serverURL || ''}${basePath}${path}`\n}\n", "import type { I18n } from '@payloadcms/translations'\n\nimport { format, formatDistanceToNow } from 'date-fns'\n\ntype FormatDateArgs = {\n date: Date | number | string | undefined\n i18n: I18n<any, any>\n pattern: string\n}\n\nexport const formatDate = ({ date, i18n, pattern }: FormatDateArgs): string => {\n const theDate = new Date(date)\n return format(theDate, pattern, { locale: i18n.dateFNS })\n}\n\ntype FormatTimeToNowArgs = {\n date: Date | number | string | undefined\n i18n: I18n<any, any>\n}\n\nexport const formatTimeToNow = ({ date, i18n }: FormatTimeToNowArgs): string => {\n const theDate = new Date(date)\n return formatDistanceToNow(theDate, { locale: i18n.dateFNS })\n}\n", "import type { I18n } from '@payloadcms/translations'\nimport type {\n ClientCollectionConfig,\n ClientGlobalConfig,\n SanitizedConfig,\n TypeWithID,\n} from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\n\nimport { formatDate } from '../utilities/formatDate.js'\n\nexport const formatDocTitle = ({\n collectionConfig,\n data,\n dateFormat: dateFormatFromConfig,\n fallback,\n globalConfig,\n i18n,\n}: {\n collectionConfig?: ClientCollectionConfig\n data: TypeWithID\n dateFormat: SanitizedConfig['admin']['dateFormat']\n fallback?: string\n globalConfig?: ClientGlobalConfig\n i18n: I18n<any, any>\n}): string => {\n let title: string\n\n if (collectionConfig) {\n const useAsTitle = collectionConfig?.admin?.useAsTitle\n\n if (useAsTitle) {\n title = data?.[useAsTitle] || title\n\n if (title) {\n const fieldConfig = collectionConfig.fields.find(\n (f) => 'name' in f && f.name === useAsTitle,\n )\n\n const isDate = fieldConfig?.type === 'date'\n\n if (isDate) {\n const dateFormat =\n ('date' in fieldConfig.admin && fieldConfig?.admin?.date?.displayFormat) ||\n dateFormatFromConfig\n title = formatDate({ date: title, i18n, pattern: dateFormat }) || title\n }\n }\n }\n }\n\n if (globalConfig) {\n title = getTranslation(globalConfig?.label, i18n) || globalConfig?.slug\n }\n\n if (!title) {\n title = fallback || `[${i18n.t('general:untitled')}]`\n }\n\n return title\n}\n", "import type { I18nClient } from '@payloadcms/translations'\nimport type {\n SanitizedCollectionConfig,\n SanitizedGlobalConfig,\n SanitizedPermissions,\n StaticLabel,\n} from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\n\nexport enum EntityType {\n collection = 'collections',\n global = 'globals',\n}\n\nexport type EntityToGroup =\n | {\n entity: SanitizedCollectionConfig\n type: EntityType.collection\n }\n | {\n entity: SanitizedGlobalConfig\n type: EntityType.global\n }\n\nexport type NavGroupType = {\n entities: {\n label: StaticLabel\n slug: string\n type: EntityType\n }[]\n label: string\n}\n\nexport function groupNavItems(\n entities: EntityToGroup[],\n permissions: SanitizedPermissions,\n i18n: I18nClient,\n): NavGroupType[] {\n const result = entities.reduce(\n (groups, entityToGroup) => {\n // Skip entities where admin.group is explicitly false\n if (entityToGroup.entity?.admin?.group === false) {\n return groups\n }\n\n if (permissions?.[entityToGroup.type.toLowerCase()]?.[entityToGroup.entity.slug]?.read) {\n const translatedGroup = getTranslation(entityToGroup.entity.admin.group, i18n)\n\n const labelOrFunction =\n 'labels' in entityToGroup.entity\n ? entityToGroup.entity.labels.plural\n : entityToGroup.entity.label\n\n const label =\n typeof labelOrFunction === 'function' ? labelOrFunction({ t: i18n.t }) : labelOrFunction\n\n if (entityToGroup.entity.admin.group) {\n const existingGroup = groups.find(\n (group) => getTranslation(group.label, i18n) === translatedGroup,\n ) as NavGroupType\n\n let matchedGroup: NavGroupType = existingGroup\n\n if (!existingGroup) {\n matchedGroup = { entities: [], label: translatedGroup }\n groups.push(matchedGroup)\n }\n\n matchedGroup.entities.push({\n slug: entityToGroup.entity.slug,\n type: entityToGroup.type,\n label,\n })\n } else {\n const defaultGroup = groups.find((group) => {\n return getTranslation(group.label, i18n) === i18n.t(`general:${entityToGroup.type}`)\n }) as NavGroupType\n defaultGroup.entities.push({\n slug: entityToGroup.entity.slug,\n type: entityToGroup.type,\n label,\n })\n }\n }\n\n return groups\n },\n [\n {\n entities: [],\n label: i18n.t('general:collections'),\n },\n {\n entities: [],\n label: i18n.t('general:globals'),\n },\n ],\n )\n\n return result.filter((group) => group.entities.length > 0)\n}\n", "import type { AppRouterInstance } from 'next/dist/shared/lib/app-router-context.shared-runtime.js'\n\nimport { formatAdminURL } from './formatAdminURL.js'\n\ntype BackToDashboardProps = {\n adminRoute: string\n router: AppRouterInstance\n}\n\nexport const handleBackToDashboard = ({ adminRoute, router }: BackToDashboardProps) => {\n const redirectRoute = formatAdminURL({\n adminRoute,\n path: '/',\n })\n router.push(redirectRoute)\n}\n", "import type { AppRouterInstance } from 'next/dist/shared/lib/app-router-context.shared-runtime.js'\n\nimport { formatAdminURL } from './formatAdminURL.js'\n\ntype GoBackProps = {\n adminRoute: string\n collectionSlug: string\n router: AppRouterInstance\n}\n\nexport const handleGoBack = ({ adminRoute, collectionSlug, router }: GoBackProps) => {\n const redirectRoute = formatAdminURL({\n adminRoute,\n path: collectionSlug ? `/collections/${collectionSlug}` : '/',\n })\n router.push(redirectRoute)\n}\n", "import type { ClientUser } from 'payload'\n\nexport const handleTakeOver = (\n id: number | string,\n collectionSlug: string,\n globalSlug: string,\n user: ClientUser | number | string,\n isWithinDoc: boolean,\n updateDocumentEditor: (\n docId: number | string,\n slug: string,\n user: ClientUser | number | string,\n ) => Promise<void>,\n setCurrentEditor: (value: React.SetStateAction<ClientUser | number | string>) => void,\n documentLockStateRef: React.RefObject<{\n hasShownLockedModal: boolean\n isLocked: boolean\n user: ClientUser | number | string\n }>,\n isLockingEnabled: boolean,\n setIsReadOnlyForIncomingUser?: (value: React.SetStateAction<boolean>) => void,\n): void => {\n if (!isLockingEnabled) {\n return\n }\n\n try {\n // Call updateDocumentEditor to update the document's owner to the current user\n void updateDocumentEditor(id, collectionSlug ?? globalSlug, user)\n\n if (!isWithinDoc) {\n documentLockStateRef.current.hasShownLockedModal = true\n }\n\n // Update the locked state to reflect the current user as the owner\n documentLockStateRef.current = {\n hasShownLockedModal: documentLockStateRef.current?.hasShownLockedModal,\n isLocked: true,\n user,\n }\n setCurrentEditor(user)\n\n // If this is a takeover within the document, ensure the document is editable\n if (isWithinDoc && setIsReadOnlyForIncomingUser) {\n setIsReadOnlyForIncomingUser(false)\n }\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Error during document takeover:', error)\n }\n}\n", "import type {\n SanitizedCollectionPermission,\n SanitizedDocumentPermissions,\n SanitizedGlobalPermission,\n} from 'payload'\n\nexport const hasSavePermission = (args: {\n /*\n * Pass either `collectionSlug` or `globalSlug`\n */\n collectionSlug?: string\n docPermissions: SanitizedDocumentPermissions\n /*\n * Pass either `collectionSlug` or `globalSlug`\n */\n globalSlug?: string\n isEditing: boolean\n}) => {\n const { collectionSlug, docPermissions, globalSlug, isEditing } = args\n\n if (collectionSlug) {\n return Boolean(\n (isEditing && docPermissions?.update) ||\n (!isEditing && (docPermissions as SanitizedCollectionPermission)?.create),\n )\n }\n\n if (globalSlug) {\n return Boolean((docPermissions as SanitizedGlobalPermission)?.update)\n }\n\n return false\n}\n", "import type { ClientUser } from 'payload'\n\nexport const isClientUserObject = (user): user is ClientUser => {\n return user && typeof user === 'object'\n}\n", "export const isEditing = ({\n id,\n collectionSlug,\n globalSlug,\n}: {\n collectionSlug?: string\n globalSlug?: string\n id?: number | string\n}): boolean => Boolean(globalSlug || (collectionSlug && !!id))\n", "import type { ClientCollectionConfig, SanitizedCollectionConfig, Where } from 'payload'\n\nconst isEmptyObject = (obj: object) => Object.keys(obj).length === 0\n\nexport const hoistQueryParamsToAnd = (currentWhere: Where, incomingWhere: Where) => {\n if (isEmptyObject(incomingWhere)) {\n return currentWhere\n }\n\n if (isEmptyObject(currentWhere)) {\n return incomingWhere\n }\n\n if ('and' in currentWhere) {\n currentWhere.and.push(incomingWhere)\n } else if ('or' in currentWhere) {\n currentWhere = {\n and: [currentWhere, incomingWhere],\n }\n } else {\n currentWhere = {\n and: [currentWhere, incomingWhere],\n }\n }\n\n return currentWhere\n}\n\ntype Args = {\n collectionConfig: ClientCollectionConfig | SanitizedCollectionConfig\n search: string\n where?: Where\n}\n\nexport const mergeListSearchAndWhere = ({ collectionConfig, search, where = {} }: Args): Where => {\n if (search) {\n let copyOfWhere = { ...(where || {}) }\n\n const searchAsConditions = (\n collectionConfig.admin.listSearchableFields || [collectionConfig.admin?.useAsTitle || 'id']\n ).map((fieldName) => ({\n [fieldName]: {\n like: search,\n },\n }))\n\n if (searchAsConditions.length > 0) {\n copyOfWhere = hoistQueryParamsToAnd(copyOfWhere, {\n or: searchAsConditions,\n })\n }\n\n if (!isEmptyObject(copyOfWhere)) {\n where = copyOfWhere\n }\n }\n\n return where\n}\n", "export function sanitizeID(id: number | string): number | string {\n if (id === undefined) {\n return id\n }\n\n if (typeof id === 'number') {\n return id\n }\n\n return decodeURIComponent(id)\n}\n"],
4
+ "sourcesContent": ["import type { ClientField, Field } from 'payload'\n\nimport { fieldIsHiddenOrDisabled, fieldIsID } from 'payload/shared'\n\n/**\n * Filters fields that are hidden, disabled, or have `disableListColumn` set to `true`\n * Does so recursively for `tabs` fields.\n */\nexport const filterFields = <T extends ClientField | Field>(incomingFields: T[]): T[] => {\n const shouldSkipField = (field: T): boolean =>\n (field.type !== 'ui' && fieldIsHiddenOrDisabled(field) && !fieldIsID(field)) ||\n field?.admin?.disableListColumn === true\n\n const fields: T[] = incomingFields?.reduce((acc, field) => {\n if (shouldSkipField(field)) {\n return acc\n }\n\n // extract top-level `tabs` fields and filter out the same\n const formattedField: T =\n field.type === 'tabs' && 'tabs' in field\n ? {\n ...field,\n tabs: field.tabs.map((tab) => ({\n ...tab,\n fields: tab.fields.filter((tabField) => !shouldSkipField(tabField)),\n })),\n }\n : field\n\n acc.push(formattedField)\n\n return acc\n }, [])\n\n return fields\n}\n", "import type { ClientField, CollectionConfig, Field } from 'payload'\n\nimport { fieldAffectsData } from 'payload/shared'\n\nimport type { ColumnPreferences } from '../../providers/ListQuery/index.js'\n\nconst getRemainingColumns = <T extends ClientField[] | Field[]>(\n fields: T,\n useAsTitle: string,\n): ColumnPreferences =>\n fields?.reduce((remaining, field) => {\n if (fieldAffectsData(field) && field.name === useAsTitle) {\n return remaining\n }\n\n if (!fieldAffectsData(field) && 'fields' in field) {\n return [...remaining, ...getRemainingColumns(field.fields, useAsTitle)]\n }\n\n if (field.type === 'tabs' && 'tabs' in field) {\n return [\n ...remaining,\n ...field.tabs.reduce(\n (tabFieldColumns, tab) => [\n ...tabFieldColumns,\n ...('name' in tab ? [tab.name] : getRemainingColumns(tab.fields, useAsTitle)),\n ],\n [],\n ),\n ]\n }\n\n return [...remaining, field.name]\n }, [])\n\n/**\n * Returns the initial columns to display in the table based on the following criteria:\n * 1. If `defaultColumns` is set in the collection config, use those columns\n * 2. Otherwise take `useAtTitle, if set, and the next 3 fields that are not hidden or disabled\n */\nexport const getInitialColumns = <T extends ClientField[] | Field[]>(\n fields: T,\n useAsTitle: CollectionConfig['admin']['useAsTitle'],\n defaultColumns: CollectionConfig['admin']['defaultColumns'],\n): ColumnPreferences => {\n let initialColumns = []\n\n if (Array.isArray(defaultColumns) && defaultColumns.length >= 1) {\n initialColumns = defaultColumns\n } else {\n if (useAsTitle) {\n initialColumns.push(useAsTitle)\n }\n\n const remainingColumns = getRemainingColumns(fields, useAsTitle)\n\n initialColumns = initialColumns.concat(remainingColumns)\n initialColumns = initialColumns.slice(0, 4)\n }\n\n return initialColumns.map((column) => ({\n accessor: column,\n active: true,\n }))\n}\n", "import type { ClientTranslationKeys, TFunction } from '@payloadcms/translations'\n\nimport * as React from 'react'\n\nconst RecursiveTranslation: React.FC<{\n elements?: Record<string, React.FC<{ children: React.ReactNode }>>\n translationString: string\n}> = ({ elements, translationString }) => {\n const regex = /(<[^>]+>.*?<\\/[^>]+>)/g\n const sections = translationString.split(regex)\n\n return (\n <span>\n {sections.map((section, index) => {\n if (elements && section.startsWith('<') && section.endsWith('>')) {\n const elementKey = section[1]\n const Element = elements[elementKey]\n\n if (Element) {\n const regex = new RegExp(`<${elementKey}>(.*?)<\\/${elementKey}>`, 'g')\n const children = section.replace(regex, (_, group) => group)\n\n return (\n <Element key={index}>\n <RecursiveTranslation translationString={children} />\n </Element>\n )\n }\n }\n\n return section\n })}\n </span>\n )\n}\n\nexport type TranslationProps = {\n elements?: Record<string, React.FC<{ children: React.ReactNode }>>\n i18nKey: ClientTranslationKeys\n t: TFunction\n variables?: Record<string, unknown>\n}\n\nexport const Translation: React.FC<TranslationProps> = ({ elements, i18nKey, t, variables }) => {\n const stringWithVariables = t(i18nKey, variables || {})\n\n if (!elements) {\n return stringWithVariables\n }\n\n return <RecursiveTranslation elements={elements} translationString={stringWithVariables} />\n}\n", "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", "import type { WithServerSidePropsComponent } from 'payload'\n\nimport { isReactServerComponentOrFunction } from 'payload/shared'\nimport React from 'react'\n\nexport const WithServerSideProps: WithServerSidePropsComponent = ({\n Component,\n serverOnlyProps,\n ...rest\n}) => {\n if (Component) {\n const WithServerSideProps: React.FC = (passedProps) => {\n const propsWithServerOnlyProps = {\n ...passedProps,\n ...(isReactServerComponentOrFunction(Component) ? (serverOnlyProps ?? {}) : {}),\n }\n\n return <Component {...propsWithServerOnlyProps} />\n }\n\n return WithServerSideProps(rest)\n }\n\n return null\n}\n", "import type { ClientField } from 'payload'\n\nexport const mergeFieldStyles = (\n field: ClientField | Omit<ClientField, 'type'>,\n): React.CSSProperties => ({\n ...(field?.admin?.style || {}),\n ...(field?.admin?.width\n ? {\n '--field-width': field.admin.width,\n }\n : {\n flex: '1 1 auto',\n }),\n // allow flex overrides to still take precedence over the fallback\n ...(field?.admin?.style?.flex\n ? {\n flex: field.admin.style.flex,\n }\n : {}),\n})\n", "import { type FormField, type FormState } from 'payload'\nimport { deepCopyObjectComplex } from 'payload/shared'\n\ntype BlacklistedKeys = 'customComponents' | 'validate'\nconst blacklistedKeys: BlacklistedKeys[] = ['validate', 'customComponents']\n\nconst sanitizeField = (incomingField: FormField): FormField => {\n const field = deepCopyObjectComplex(incomingField)\n\n blacklistedKeys.forEach((key) => {\n delete field[key]\n })\n\n return field\n}\n\n/* \n Takes in FormState and removes fields that are not serializable.\n Returns FormState without blacklisted keys.\n**/\nexport const reduceToSerializableFields = (\n fields: FormState,\n): {\n [key: string]: Omit<FormField, BlacklistedKeys>\n} => {\n return Object.keys(fields).reduce(\n (acc, key) => {\n acc[key] = sanitizeField(fields[key])\n return acc\n },\n {} as {\n [key: string]: Omit<FormField, BlacklistedKeys>\n },\n )\n}\n", "import React from 'react'\n\nexport const PayloadIcon: React.FC<{\n fill?: string\n}> = ({ fill: fillFromProps }) => {\n const fill = fillFromProps || 'var(--theme-elevation-1000)'\n\n return (\n <svg\n className=\"graphic-icon\"\n height=\"100%\"\n viewBox=\"0 0 25 25\"\n width=\"100%\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M11.8673 21.2336L4.40922 16.9845C4.31871 16.9309 4.25837 16.8355 4.25837 16.7282V10.1609C4.25837 10.0477 4.38508 9.97616 4.48162 10.0298L13.1404 14.9642C13.2611 15.0358 13.412 14.9464 13.412 14.8093V11.6091C13.412 11.4839 13.3456 11.3647 13.2309 11.2992L2.81624 5.36353C2.72573 5.30989 2.60505 5.30989 2.51454 5.36353L1.15085 6.14422C1.06034 6.19786 1 6.29321 1 6.40048V18.5995C1 18.7068 1.06034 18.8021 1.15085 18.8558L11.8491 24.9583C11.9397 25.0119 12.0603 25.0119 12.1509 24.9583L21.1355 19.8331C21.2562 19.7616 21.2562 19.5948 21.1355 19.5232L18.3357 17.9261C18.2211 17.8605 18.0883 17.8605 17.9737 17.9261L12.175 21.2336C12.0845 21.2872 11.9638 21.2872 11.8733 21.2336H11.8673Z\"\n fill={fill}\n />\n <path\n d=\"M22.8491 6.13827L12.1508 0.0417218C12.0603 -0.0119135 11.9397 -0.0119135 11.8491 0.0417218L6.19528 3.2658C6.0746 3.33731 6.0746 3.50418 6.19528 3.57569L8.97092 5.16091C9.08557 5.22647 9.21832 5.22647 9.33296 5.16091L11.8672 3.71872C11.9578 3.66508 12.0784 3.66508 12.1689 3.71872L19.627 7.96782C19.7175 8.02146 19.7778 8.11681 19.7778 8.22408V14.8212C19.7778 14.9464 19.8442 15.0656 19.9589 15.1311L22.7345 16.7104C22.8552 16.7819 23.006 16.6925 23.006 16.5554V6.40048C23.006 6.29321 22.9457 6.19786 22.8552 6.14423L22.8491 6.13827Z\"\n fill={fill}\n />\n </svg>\n )\n}\n", "import React from 'react'\n\nconst css = `\n .graphic-logo path {\n fill: var(--theme-elevation-1000);\n }\n`\n\nexport const PayloadLogo: React.FC = () => (\n <svg\n className=\"graphic-logo\"\n fill=\"none\"\n height=\"43.5\"\n id=\"b\"\n viewBox=\"0 0 193.38 43.5\"\n width=\"193.38\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <style>{css}</style>\n <g id=\"c\">\n <path d=\"M18.01,35.63l-12.36-7.13c-.15-.09-.25-.25-.25-.43v-11.02c0-.19.21-.31.37-.22l14.35,8.28c.2.12.45-.03.45-.26v-5.37c0-.21-.11-.41-.3-.52L3.01,9c-.15-.09-.35-.09-.5,0l-2.26,1.31c-.15.09-.25.25-.25.43v20.47c0,.18.1.34.25.43l17.73,10.24c.15.09.35.09.5,0l14.89-8.6c.2-.12.2-.4,0-.52l-4.64-2.68c-.19-.11-.41-.11-.6,0l-9.61,5.55c-.15.09-.35.09-.5,0Z\" />\n <path d=\"M36.21,10.3L18.48.07c-.15-.09-.35-.09-.5,0l-9.37,5.41c-.2.12-.2.4,0,.52l4.6,2.66c.19.11.41.11.6,0l4.2-2.42c.15-.09.35-.09.5,0l12.36,7.13c.15.09.25.25.25.43v11.07c0,.21.11.41.3.52l4.6,2.65c.2.12.45-.03.45-.26V10.74c0-.18-.1-.34-.25-.43Z\" />\n <g id=\"d\">\n <path d=\"M193.38,9.47c0,1.94-1.48,3.32-3.3,3.32s-3.31-1.39-3.31-3.32,1.49-3.31,3.31-3.31,3.3,1.39,3.3,3.31ZM192.92,9.47c0-1.68-1.26-2.88-2.84-2.88s-2.84,1.2-2.84,2.88,1.26,2.89,2.84,2.89,2.84-1.2,2.84-2.89ZM188.69,11.17v-3.51h1.61c.85,0,1.35.39,1.35,1.15,0,.53-.3.86-.67,1.02l.79,1.35h-.89l-.72-1.22h-.64v1.22h-.82ZM190.18,9.31c.46,0,.64-.16.64-.5s-.19-.49-.64-.49h-.67v.99h.67Z\" />\n <path d=\"M54.72,24.84v10.93h-5.4V6.1h12.26c7.02,0,11.1,3.2,11.1,9.39s-4.07,9.35-11.06,9.35h-6.9,0ZM61.12,20.52c4.07,0,6.11-1.66,6.11-5.03s-2.04-5.03-6.11-5.03h-6.4v10.06h6.4Z\" />\n <path d=\"M85.94,32.45c-1,2.41-3.66,3.78-7.02,3.78-4.11,0-7.11-2.29-7.11-6.11,0-4.24,3.32-5.98,7.61-6.48l6.32-.71v-1c0-2.58-1.58-3.82-3.99-3.82s-3.74,1.29-3.91,3.24h-5.11c.46-4.53,3.99-7.19,9.18-7.19,5.74,0,9.02,2.7,9.02,8.19v8.15c0,1.95.08,3.58.42,5.28h-5.11c-.21-1.16-.29-2.29-.29-3.32h0ZM85.73,27.58v-1.29l-4.7.54c-2.24.29-3.95.79-3.95,2.99,0,1.66,1.16,2.7,3.28,2.7,2.74,0,5.36-1.62,5.36-4.95h0Z\" />\n <path d=\"M90.39,14.66h5.4l5.86,15.92h.08l5.57-15.92h5.28l-8.23,21.49c-2,5.28-4.45,7.32-8.89,7.36-.71,0-1.7-.08-2.45-.21v-4.03c.62.13.96.13,1.41.13,2.16,0,3.07-.75,4.2-3.66l-8.23-21.07h0Z\" />\n <path d=\"M113.46,35.77V6.1h5.32v29.67h-5.32Z\" />\n <path d=\"M130.79,36.27c-6.23,0-10.68-4.2-10.68-11.05s4.45-11.05,10.68-11.05,10.68,4.24,10.68,11.05-4.45,11.05-10.68,11.05ZM130.79,32.32c3.41,0,5.36-2.66,5.36-7.11s-1.95-7.11-5.36-7.11-5.36,2.7-5.36,7.11,1.91,7.11,5.36,7.11Z\" />\n <path d=\"M156.19,32.45c-1,2.41-3.66,3.78-7.02,3.78-4.11,0-7.11-2.29-7.11-6.11,0-4.24,3.32-5.98,7.61-6.48l6.32-.71v-1c0-2.58-1.58-3.82-3.99-3.82s-3.74,1.29-3.91,3.24h-5.11c.46-4.53,3.99-7.19,9.19-7.19,5.74,0,9.02,2.7,9.02,8.19v8.15c0,1.95.08,3.58.42,5.28h-5.11c-.21-1.16-.29-2.29-.29-3.32h0ZM155.98,27.58v-1.29l-4.7.54c-2.24.29-3.95.79-3.95,2.99,0,1.66,1.16,2.7,3.28,2.7,2.74,0,5.36-1.62,5.36-4.95h0Z\" />\n <path d=\"M178.5,32.41c-1.04,2.12-3.58,3.87-6.78,3.87-5.53,0-9.31-4.49-9.31-11.05s3.78-11.05,9.31-11.05c3.28,0,5.69,1.83,6.69,3.95V6.1h5.32v29.67h-5.24v-3.37h0ZM178.55,24.84c0-4.11-1.95-6.78-5.32-6.78s-5.45,2.83-5.45,7.15,2,7.15,5.45,7.15,5.32-2.66,5.32-6.78v-.75h0Z\" />\n </g>\n </g>\n </svg>\n)\n", "export function abortAndIgnore(controller: AbortController) {\n if (controller) {\n try {\n controller.abort()\n } catch (_err) {\n // swallow error\n }\n }\n}\n", "import * as qs from 'qs-esm'\n\ntype GetOptions = {\n params?: Record<string, unknown>\n} & RequestInit\n\nexport const requests = {\n delete: (url: string, options: RequestInit = { headers: {} }): Promise<Response> => {\n const headers = options && options.headers ? { ...options.headers } : {}\n\n const formattedOptions: RequestInit = {\n ...options,\n credentials: 'include',\n headers: {\n ...headers,\n },\n method: 'delete',\n }\n\n return fetch(url, formattedOptions)\n },\n\n get: (url: string, options: GetOptions = { headers: {} }): Promise<Response> => {\n let query = ''\n if (options.params) {\n query = qs.stringify(options.params, { addQueryPrefix: true })\n }\n return fetch(`${url}${query}`, {\n credentials: 'include',\n ...options,\n })\n },\n\n patch: (url: string, options: RequestInit = { headers: {} }): Promise<Response> => {\n const headers = options && options.headers ? { ...options.headers } : {}\n\n const formattedOptions: RequestInit = {\n ...options,\n credentials: 'include',\n headers: {\n ...headers,\n },\n method: 'PATCH',\n }\n\n return fetch(url, formattedOptions)\n },\n\n post: (url: string, options: RequestInit = { headers: {} }): Promise<Response> => {\n const headers = options && options.headers ? { ...options.headers } : {}\n\n const formattedOptions: RequestInit = {\n ...options,\n credentials: 'include',\n headers: {\n ...headers,\n },\n method: 'post',\n }\n\n return fetch(`${url}`, formattedOptions)\n },\n\n put: (url: string, options: RequestInit = { headers: {} }): Promise<Response> => {\n const headers = options && options.headers ? { ...options.headers } : {}\n\n const formattedOptions: RequestInit = {\n ...options,\n credentials: 'include',\n headers: {\n ...headers,\n },\n method: 'put',\n }\n\n return fetch(url, formattedOptions)\n },\n}\n", "import type { Locale, SanitizedLocalizationConfig } from 'payload'\n/*\n return the Locale for given locale code, else return null\n*/\nexport const findLocaleFromCode = (\n localizationConfig: SanitizedLocalizationConfig,\n locale: string,\n): Locale | null => {\n if (!localizationConfig?.locales || localizationConfig.locales.length === 0) {\n return null\n }\n\n return localizationConfig.locales.find((el) => el?.code === locale)\n}\n", "import type { Config } from 'payload'\n\n/** Will read the `routes.admin` config and appropriately handle `\"/\"` admin paths */\nexport const formatAdminURL = (args: {\n adminRoute: Config['routes']['admin']\n basePath?: string\n path: string\n serverURL?: Config['serverURL']\n}): string => {\n const { adminRoute, basePath = '', path, serverURL } = args\n\n if (adminRoute) {\n if (adminRoute === '/') {\n if (!path) {\n return `${serverURL || ''}${basePath}${adminRoute}`\n }\n } else {\n return `${serverURL || ''}${basePath}${adminRoute}${path}`\n }\n }\n\n return `${serverURL || ''}${basePath}${path}`\n}\n", "import type { I18n } from '@payloadcms/translations'\n\nimport { format, formatDistanceToNow } from 'date-fns'\n\ntype FormatDateArgs = {\n date: Date | number | string | undefined\n i18n: I18n<any, any>\n pattern: string\n}\n\nexport const formatDate = ({ date, i18n, pattern }: FormatDateArgs): string => {\n const theDate = new Date(date)\n return format(theDate, pattern, { locale: i18n.dateFNS })\n}\n\ntype FormatTimeToNowArgs = {\n date: Date | number | string | undefined\n i18n: I18n<any, any>\n}\n\nexport const formatTimeToNow = ({ date, i18n }: FormatTimeToNowArgs): string => {\n const theDate = new Date(date)\n return formatDistanceToNow(theDate, { locale: i18n.dateFNS })\n}\n", "import type { I18n } from '@payloadcms/translations'\nimport type {\n ClientCollectionConfig,\n ClientGlobalConfig,\n SanitizedConfig,\n TypeWithID,\n} from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\n\nimport { formatDate } from '../utilities/formatDate.js'\n\nexport const formatDocTitle = ({\n collectionConfig,\n data,\n dateFormat: dateFormatFromConfig,\n fallback,\n globalConfig,\n i18n,\n}: {\n collectionConfig?: ClientCollectionConfig\n data: TypeWithID\n dateFormat: SanitizedConfig['admin']['dateFormat']\n fallback?: string\n globalConfig?: ClientGlobalConfig\n i18n: I18n<any, any>\n}): string => {\n let title: string\n\n if (collectionConfig) {\n const useAsTitle = collectionConfig?.admin?.useAsTitle\n\n if (useAsTitle) {\n title = data?.[useAsTitle] || title\n\n if (title) {\n const fieldConfig = collectionConfig.fields.find(\n (f) => 'name' in f && f.name === useAsTitle,\n )\n\n const isDate = fieldConfig?.type === 'date'\n\n if (isDate) {\n const dateFormat =\n ('date' in fieldConfig.admin && fieldConfig?.admin?.date?.displayFormat) ||\n dateFormatFromConfig\n title = formatDate({ date: title, i18n, pattern: dateFormat }) || title\n }\n }\n }\n }\n\n if (globalConfig) {\n title = getTranslation(globalConfig?.label, i18n) || globalConfig?.slug\n }\n\n if (!title) {\n title = fallback || `[${i18n.t('general:untitled')}]`\n }\n\n return title\n}\n", "import type { I18nClient } from '@payloadcms/translations'\nimport type {\n SanitizedCollectionConfig,\n SanitizedGlobalConfig,\n SanitizedPermissions,\n StaticLabel,\n} from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\n\nexport enum EntityType {\n collection = 'collections',\n global = 'globals',\n}\n\nexport type EntityToGroup =\n | {\n entity: SanitizedCollectionConfig\n type: EntityType.collection\n }\n | {\n entity: SanitizedGlobalConfig\n type: EntityType.global\n }\n\nexport type NavGroupType = {\n entities: {\n label: StaticLabel\n slug: string\n type: EntityType\n }[]\n label: string\n}\n\nexport function groupNavItems(\n entities: EntityToGroup[],\n permissions: SanitizedPermissions,\n i18n: I18nClient,\n): NavGroupType[] {\n const result = entities.reduce(\n (groups, entityToGroup) => {\n // Skip entities where admin.group is explicitly false\n if (entityToGroup.entity?.admin?.group === false) {\n return groups\n }\n\n if (permissions?.[entityToGroup.type.toLowerCase()]?.[entityToGroup.entity.slug]?.read) {\n const translatedGroup = getTranslation(entityToGroup.entity.admin.group, i18n)\n\n const labelOrFunction =\n 'labels' in entityToGroup.entity\n ? entityToGroup.entity.labels.plural\n : entityToGroup.entity.label\n\n const label =\n typeof labelOrFunction === 'function' ? labelOrFunction({ t: i18n.t }) : labelOrFunction\n\n if (entityToGroup.entity.admin.group) {\n const existingGroup = groups.find(\n (group) => getTranslation(group.label, i18n) === translatedGroup,\n ) as NavGroupType\n\n let matchedGroup: NavGroupType = existingGroup\n\n if (!existingGroup) {\n matchedGroup = { entities: [], label: translatedGroup }\n groups.push(matchedGroup)\n }\n\n matchedGroup.entities.push({\n slug: entityToGroup.entity.slug,\n type: entityToGroup.type,\n label,\n })\n } else {\n const defaultGroup = groups.find((group) => {\n return getTranslation(group.label, i18n) === i18n.t(`general:${entityToGroup.type}`)\n }) as NavGroupType\n defaultGroup.entities.push({\n slug: entityToGroup.entity.slug,\n type: entityToGroup.type,\n label,\n })\n }\n }\n\n return groups\n },\n [\n {\n entities: [],\n label: i18n.t('general:collections'),\n },\n {\n entities: [],\n label: i18n.t('general:globals'),\n },\n ],\n )\n\n return result.filter((group) => group.entities.length > 0)\n}\n", "import type { AppRouterInstance } from 'next/dist/shared/lib/app-router-context.shared-runtime.js'\n\nimport { formatAdminURL } from './formatAdminURL.js'\n\ntype BackToDashboardProps = {\n adminRoute: string\n router: AppRouterInstance\n}\n\nexport const handleBackToDashboard = ({ adminRoute, router }: BackToDashboardProps) => {\n const redirectRoute = formatAdminURL({\n adminRoute,\n path: '/',\n })\n router.push(redirectRoute)\n}\n", "import type { AppRouterInstance } from 'next/dist/shared/lib/app-router-context.shared-runtime.js'\n\nimport { formatAdminURL } from './formatAdminURL.js'\n\ntype GoBackProps = {\n adminRoute: string\n collectionSlug: string\n router: AppRouterInstance\n}\n\nexport const handleGoBack = ({ adminRoute, collectionSlug, router }: GoBackProps) => {\n const redirectRoute = formatAdminURL({\n adminRoute,\n path: collectionSlug ? `/collections/${collectionSlug}` : '/',\n })\n router.push(redirectRoute)\n}\n", "import type { ClientUser } from 'payload'\n\nexport const handleTakeOver = (\n id: number | string,\n collectionSlug: string,\n globalSlug: string,\n user: ClientUser | number | string,\n isWithinDoc: boolean,\n updateDocumentEditor: (\n docID: number | string,\n slug: string,\n user: ClientUser | number | string,\n ) => Promise<void>,\n setCurrentEditor: (value: React.SetStateAction<ClientUser | number | string>) => void,\n documentLockStateRef: React.RefObject<{\n hasShownLockedModal: boolean\n isLocked: boolean\n user: ClientUser | number | string\n }>,\n isLockingEnabled: boolean,\n setIsReadOnlyForIncomingUser?: (value: React.SetStateAction<boolean>) => void,\n): void => {\n if (!isLockingEnabled) {\n return\n }\n\n try {\n // Call updateDocumentEditor to update the document's owner to the current user\n void updateDocumentEditor(id, collectionSlug ?? globalSlug, user)\n\n if (!isWithinDoc) {\n documentLockStateRef.current.hasShownLockedModal = true\n }\n\n // Update the locked state to reflect the current user as the owner\n documentLockStateRef.current = {\n hasShownLockedModal: documentLockStateRef.current?.hasShownLockedModal,\n isLocked: true,\n user,\n }\n setCurrentEditor(user)\n\n // If this is a takeover within the document, ensure the document is editable\n if (isWithinDoc && setIsReadOnlyForIncomingUser) {\n setIsReadOnlyForIncomingUser(false)\n }\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Error during document takeover:', error)\n }\n}\n", "import type {\n SanitizedCollectionPermission,\n SanitizedDocumentPermissions,\n SanitizedGlobalPermission,\n} from 'payload'\n\nexport const hasSavePermission = (args: {\n /*\n * Pass either `collectionSlug` or `globalSlug`\n */\n collectionSlug?: string\n docPermissions: SanitizedDocumentPermissions\n /*\n * Pass either `collectionSlug` or `globalSlug`\n */\n globalSlug?: string\n isEditing: boolean\n}) => {\n const { collectionSlug, docPermissions, globalSlug, isEditing } = args\n\n if (collectionSlug) {\n return Boolean(\n (isEditing && docPermissions?.update) ||\n (!isEditing && (docPermissions as SanitizedCollectionPermission)?.create),\n )\n }\n\n if (globalSlug) {\n return Boolean((docPermissions as SanitizedGlobalPermission)?.update)\n }\n\n return false\n}\n", "import type { ClientUser } from 'payload'\n\nexport const isClientUserObject = (user): user is ClientUser => {\n return user && typeof user === 'object'\n}\n", "export const isEditing = ({\n id,\n collectionSlug,\n globalSlug,\n}: {\n collectionSlug?: string\n globalSlug?: string\n id?: number | string\n}): boolean => Boolean(globalSlug || (collectionSlug && !!id))\n", "import type { ClientCollectionConfig, SanitizedCollectionConfig, Where } from 'payload'\n\nconst isEmptyObject = (obj: object) => Object.keys(obj).length === 0\n\nexport const hoistQueryParamsToAnd = (currentWhere: Where, incomingWhere: Where) => {\n if (isEmptyObject(incomingWhere)) {\n return currentWhere\n }\n\n if (isEmptyObject(currentWhere)) {\n return incomingWhere\n }\n\n if ('and' in currentWhere) {\n currentWhere.and.push(incomingWhere)\n } else if ('or' in currentWhere) {\n currentWhere = {\n and: [currentWhere, incomingWhere],\n }\n } else {\n currentWhere = {\n and: [currentWhere, incomingWhere],\n }\n }\n\n return currentWhere\n}\n\ntype Args = {\n collectionConfig: ClientCollectionConfig | SanitizedCollectionConfig\n search: string\n where?: Where\n}\n\nexport const mergeListSearchAndWhere = ({ collectionConfig, search, where = {} }: Args): Where => {\n if (search) {\n let copyOfWhere = { ...(where || {}) }\n\n const searchAsConditions = (\n collectionConfig.admin.listSearchableFields || [collectionConfig.admin?.useAsTitle || 'id']\n ).map((fieldName) => ({\n [fieldName]: {\n like: search,\n },\n }))\n\n if (searchAsConditions.length > 0) {\n copyOfWhere = hoistQueryParamsToAnd(copyOfWhere, {\n or: searchAsConditions,\n })\n }\n\n if (!isEmptyObject(copyOfWhere)) {\n where = copyOfWhere\n }\n }\n\n return where\n}\n", "export function sanitizeID(id: number | string): number | string {\n if (id === undefined) {\n return id\n }\n\n if (typeof id === 'number') {\n return id\n }\n\n return decodeURIComponent(id)\n}\n"],
5
5
  "mappings": "AAEA,OAAS,2BAAAA,EAAyB,aAAAC,MAAiB,iBAM5C,IAAMC,EAA+CC,GAA6B,CACvF,IAAMC,EAAmBC,GACtBA,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AAeD,GAAoBD,GCN1D,IAAMG,EAAiBC,GAAgB,OAAO,KAAKA,CAAG,EAAE,SAAW,EAEtDC,GAAwB,CAACC,EAAqBC,IACrDJ,EAAcI,CAAa,EACtBD,EAGLH,EAAcG,CAAY,EACrBC,GAGL,QAASD,EACXA,EAAa,IAAI,KAAKC,CAAa,EAC1B,OAAQD,EACjBA,EAAe,CACb,IAAK,CAACA,EAAcC,CAAa,CACnC,EAEAD,EAAe,CACb,IAAK,CAACA,EAAcC,CAAa,CACnC,EAGKD,GASIE,GAA0B,CAAC,CAAE,iBAAAC,EAAkB,OAAAC,EAAQ,MAAAC,EAAQ,CAAC,CAAE,IAAmB,CAChG,GAAID,EAAQ,CACV,IAAIE,EAAc,CAAE,GAAID,GAAS,CAAC,CAAG,EAE/BE,GACJJ,EAAiB,MAAM,sBAAwB,CAACA,EAAiB,OAAO,YAAc,IAAI,GAC1F,IAAKK,IAAe,CACpB,CAACA,CAAS,EAAG,CACX,KAAMJ,CACR,CACF,EAAE,EAEEG,EAAmB,OAAS,IAC9BD,EAAcP,GAAsBO,EAAa,CAC/C,GAAIC,CACN,CAAC,GAGEV,EAAcS,CAAW,IAC5BD,EAAQC,EAEZ,CAEA,OAAOD,CACT,EC1DO,SAASI,GAAWC,EAAsC,CAK/D,OAJIA,IAAO,QAIP,OAAOA,GAAO,SACTA,EAGF,mBAAmBA,CAAE,CAC9B",
6
6
  "names": ["fieldIsHiddenOrDisabled", "fieldIsID", "filterFields", "incomingFields", "shouldSkipField", "field", "acc", "formattedField", "tab", "tabField", "fieldAffectsData", "getRemainingColumns", "fields", "useAsTitle", "remaining", "field", "tabFieldColumns", "tab", "getInitialColumns", "defaultColumns", "initialColumns", "remainingColumns", "column", "React", "RecursiveTranslation", "elements", "translationString", "regex", "sections", "section", "index", "elementKey", "Element", "children", "_", "group", "Translation", "i18nKey", "t", "variables", "stringWithVariables", "isReactServerComponentOrFunction", "serverProps", "React", "withMergedProps", "Component", "sanitizeServerOnlyProps", "toMergeIntoProps", "passedProps", "mergedProps", "simpleMergeProps", "prop", "props", "toMerge", "isReactServerComponentOrFunction", "React", "WithServerSideProps", "Component", "serverOnlyProps", "rest", "passedProps", "propsWithServerOnlyProps", "mergeFieldStyles", "field", "deepCopyObjectComplex", "blacklistedKeys", "sanitizeField", "incomingField", "field", "key", "reduceToSerializableFields", "fields", "acc", "React", "PayloadIcon", "fillFromProps", "fill", "React", "css", "PayloadLogo", "abortAndIgnore", "controller", "qs", "requests", "url", "options", "headers", "formattedOptions", "query", "findLocaleFromCode", "localizationConfig", "locale", "el", "formatAdminURL", "args", "adminRoute", "basePath", "path", "serverURL", "format", "formatDistanceToNow", "formatDate", "date", "i18n", "pattern", "theDate", "getTranslation", "formatDocTitle", "collectionConfig", "data", "dateFormatFromConfig", "fallback", "globalConfig", "i18n", "title", "useAsTitle", "fieldConfig", "f", "dateFormat", "formatDate", "getTranslation", "getTranslation", "EntityType", "groupNavItems", "entities", "permissions", "i18n", "groups", "entityToGroup", "translatedGroup", "labelOrFunction", "label", "existingGroup", "group", "matchedGroup", "handleBackToDashboard", "adminRoute", "router", "redirectRoute", "formatAdminURL", "handleGoBack", "adminRoute", "collectionSlug", "router", "redirectRoute", "formatAdminURL", "handleTakeOver", "id", "collectionSlug", "globalSlug", "user", "isWithinDoc", "updateDocumentEditor", "setCurrentEditor", "documentLockStateRef", "isLockingEnabled", "setIsReadOnlyForIncomingUser", "error", "hasSavePermission", "args", "collectionSlug", "docPermissions", "globalSlug", "isEditing", "isClientUserObject", "user", "isEditing", "id", "collectionSlug", "globalSlug", "isEmptyObject", "obj", "hoistQueryParamsToAnd", "currentWhere", "incomingWhere", "mergeListSearchAndWhere", "collectionConfig", "search", "where", "copyOfWhere", "searchAsConditions", "fieldName", "sanitizeID", "id"]
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Join/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,eAAe,EAIhB,MAAM,SAAS,CAAA;AAIhB,OAAO,KAAkB,MAAM,OAAO,CAAA;AAqJtC,eAAO,MAAM,SAAS;;;;+EAAoC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Join/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,eAAe,EAIhB,MAAM,SAAS,CAAA;AAIhB,OAAO,KAAkB,MAAM,OAAO,CAAA;AAqMtC,eAAO,MAAM,SAAS;;;;+EAAoC,CAAA"}
@@ -18,6 +18,7 @@ const ObjectId = ObjectIdImport.default || ObjectIdImport;
18
18
  * Recursively builds the default data for joined collection
19
19
  */
20
20
  const getInitialDrawerData = ({
21
+ collectionSlug,
21
22
  docID,
22
23
  fields,
23
24
  segments
@@ -25,16 +26,26 @@ const getInitialDrawerData = ({
25
26
  const flattenedFields = flattenTopLevelFields(fields);
26
27
  const path = segments[0];
27
28
  const field = flattenedFields.find(field => field.name === path);
29
+ if (!field) {
30
+ return null;
31
+ }
28
32
  if (field.type === 'relationship' || field.type === 'upload') {
33
+ let value = docID;
34
+ if (Array.isArray(field.relationTo)) {
35
+ value = {
36
+ relationTo: collectionSlug,
37
+ value: docID
38
+ };
39
+ }
29
40
  return {
30
- // TODO: Handle polymorphic https://github.com/payloadcms/payload/pull/9990
31
- [field.name]: field.hasMany ? [docID] : docID
41
+ [field.name]: field.hasMany ? [value] : value
32
42
  };
33
43
  }
34
44
  const nextSegments = segments.slice(1, segments.length);
35
45
  if (field.type === 'tab' || field.type === 'group') {
36
46
  return {
37
47
  [field.name]: getInitialDrawerData({
48
+ collectionSlug,
38
49
  docID,
39
50
  fields: field.fields,
40
51
  segments: nextSegments
@@ -43,6 +54,7 @@ const getInitialDrawerData = ({
43
54
  }
44
55
  if (field.type === 'array') {
45
56
  const initialData = getInitialDrawerData({
57
+ collectionSlug,
46
58
  docID,
47
59
  fields: field.fields,
48
60
  segments: nextSegments
@@ -52,6 +64,23 @@ const getInitialDrawerData = ({
52
64
  [field.name]: [initialData]
53
65
  };
54
66
  }
67
+ if (field.type === 'blocks') {
68
+ for (const block of field.blocks) {
69
+ const blockInitialData = getInitialDrawerData({
70
+ collectionSlug,
71
+ docID,
72
+ fields: block.fields,
73
+ segments: nextSegments
74
+ });
75
+ if (blockInitialData) {
76
+ blockInitialData.id = ObjectId().toHexString();
77
+ blockInitialData.blockType = block.slug;
78
+ return {
79
+ [field.name]: [blockInitialData]
80
+ };
81
+ }
82
+ }
83
+ }
55
84
  };
56
85
  const JoinFieldComponent = props => {
57
86
  const {
@@ -70,7 +99,8 @@ const JoinFieldComponent = props => {
70
99
  path
71
100
  } = props;
72
101
  const {
73
- id: docID
102
+ id: docID,
103
+ docConfig
74
104
  } = useDocumentInfo();
75
105
  const {
76
106
  config: {
@@ -92,9 +122,16 @@ const JoinFieldComponent = props => {
92
122
  if (!docID) {
93
123
  return null;
94
124
  }
125
+ let value_0 = docID;
126
+ if (Array.isArray(field.targetField.relationTo)) {
127
+ value_0 = {
128
+ relationTo: docConfig.slug,
129
+ value: value_0
130
+ };
131
+ }
95
132
  const where = {
96
133
  [on]: {
97
- equals: docID
134
+ equals: value_0
98
135
  }
99
136
  };
100
137
  if (field.where) {
@@ -103,15 +140,16 @@ const JoinFieldComponent = props => {
103
140
  };
104
141
  }
105
142
  return where;
106
- }, [docID, on, field.where]);
143
+ }, [docID, field.targetField.relationTo, field.where, on, docConfig.slug]);
107
144
  const initialDrawerData = useMemo(() => {
108
145
  const relatedCollection = collections.find(collection_0 => collection_0.slug === field.collection);
109
146
  return getInitialDrawerData({
147
+ collectionSlug: docConfig.slug,
110
148
  docID,
111
149
  fields: relatedCollection.fields,
112
150
  segments: field.on.split('.')
113
151
  });
114
- }, [collections, field.on, docID, field.collection]);
152
+ }, [collections, field.on, field.collection, docConfig.slug, docID]);
115
153
  return /*#__PURE__*/_jsxs("div", {
116
154
  className: [fieldBaseClass, 'join'].filter(Boolean).join(' '),
117
155
  id: `field-${path?.replace(/\./g, '__')}`,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["ObjectIdImport","flattenTopLevelFields","React","useMemo","RelationshipTable","RenderCustomComponent","useField","withCondition","useConfig","useDocumentInfo","FieldDescription","FieldLabel","fieldBaseClass","ObjectId","default","getInitialDrawerData","docID","fields","segments","flattenedFields","path","field","find","name","type","hasMany","nextSegments","slice","length","initialData","id","toHexString","JoinFieldComponent","props","admin","allowCreate","description","collection","label","localized","on","required","config","collections","customComponents","AfterInput","BeforeInput","Description","Label","value","filterOptions","where","equals","and","initialDrawerData","relatedCollection","slug","split","_jsxs","className","filter","Boolean","join","replace","_jsx","disableTable","docs","style","margin","relationTo","CustomComponent","Fallback","JoinField"],"sources":["../../../src/fields/Join/index.tsx"],"sourcesContent":["'use client'\n\nimport type {\n ClientField,\n JoinFieldClient,\n JoinFieldClientComponent,\n PaginatedDocs,\n Where,\n} from 'payload'\n\nimport ObjectIdImport from 'bson-objectid'\nimport { flattenTopLevelFields } from 'payload/shared'\nimport React, { useMemo } from 'react'\n\nimport { RelationshipTable } from '../../elements/RelationshipTable/index.js'\nimport { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { FieldDescription } from '../FieldDescription/index.js'\nimport { FieldLabel } from '../FieldLabel/index.js'\nimport { fieldBaseClass } from '../index.js'\n\nconst ObjectId = (ObjectIdImport.default ||\n ObjectIdImport) as unknown as typeof ObjectIdImport.default\n\n/**\n * Recursively builds the default data for joined collection\n */\nconst getInitialDrawerData = ({\n docID,\n fields,\n segments,\n}: {\n docID: number | string\n fields: ClientField[]\n segments: string[]\n}) => {\n const flattenedFields = flattenTopLevelFields(fields)\n\n const path = segments[0]\n\n const field = flattenedFields.find((field) => field.name === path)\n\n if (field.type === 'relationship' || field.type === 'upload') {\n return {\n // TODO: Handle polymorphic https://github.com/payloadcms/payload/pull/9990\n [field.name]: field.hasMany ? [docID] : docID,\n }\n }\n\n const nextSegments = segments.slice(1, segments.length)\n\n if (field.type === 'tab' || field.type === 'group') {\n return {\n [field.name]: getInitialDrawerData({ docID, fields: field.fields, segments: nextSegments }),\n }\n }\n\n if (field.type === 'array') {\n const initialData = getInitialDrawerData({\n docID,\n fields: field.fields,\n segments: nextSegments,\n })\n\n initialData.id = ObjectId().toHexString()\n\n return {\n [field.name]: [initialData],\n }\n }\n}\n\nconst JoinFieldComponent: JoinFieldClientComponent = (props) => {\n const {\n field,\n field: {\n admin: { allowCreate, description },\n collection,\n label,\n localized,\n on,\n required,\n },\n path,\n } = props\n\n const { id: docID } = useDocumentInfo()\n\n const {\n config: { collections },\n } = useConfig()\n\n const { customComponents: { AfterInput, BeforeInput, Description, Label } = {}, value } =\n useField<PaginatedDocs>({\n path,\n })\n\n const filterOptions: null | Where = useMemo(() => {\n if (!docID) {\n return null\n }\n\n const where = {\n [on]: {\n equals: docID,\n },\n }\n\n if (field.where) {\n return {\n and: [where, field.where],\n }\n }\n\n return where\n }, [docID, on, field.where])\n\n const initialDrawerData = useMemo(() => {\n const relatedCollection = collections.find((collection) => collection.slug === field.collection)\n\n return getInitialDrawerData({\n docID,\n fields: relatedCollection.fields,\n segments: field.on.split('.'),\n })\n }, [collections, field.on, docID, field.collection])\n\n return (\n <div\n className={[fieldBaseClass, 'join'].filter(Boolean).join(' ')}\n id={`field-${path?.replace(/\\./g, '__')}`}\n >\n <RelationshipTable\n AfterInput={AfterInput}\n allowCreate={typeof docID !== 'undefined' && allowCreate}\n BeforeInput={BeforeInput}\n disableTable={filterOptions === null}\n field={field as JoinFieldClient}\n filterOptions={filterOptions}\n initialData={docID && value ? value : ({ docs: [] } as PaginatedDocs)}\n initialDrawerData={initialDrawerData}\n Label={\n <h4 style={{ margin: 0 }}>\n {Label || (\n <FieldLabel label={label} localized={localized} path={path} required={required} />\n )}\n </h4>\n }\n relationTo={collection}\n />\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n )\n}\n\nexport const JoinField = withCondition(JoinFieldComponent)\n"],"mappings":"AAAA;;;AAUA,OAAOA,cAAA,MAAoB;AAC3B,SAASC,qBAAqB,QAAQ;AACtC,OAAOC,KAAA,IAASC,OAAO,QAAQ;AAE/B,SAASC,iBAAiB,QAAQ;AAClC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,QAAQ,QAAQ;AACzB,SAASC,aAAa,QAAQ;AAC9B,SAASC,SAAS,QAAQ;AAC1B,SAASC,eAAe,QAAQ;AAChC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,UAAU,QAAQ;AAC3B,SAASC,cAAc,QAAQ;AAE/B,MAAMC,QAAA,GAAYb,cAAA,CAAec,OAAO,IACtCd,cAAA;AAEF;;;AAGA,MAAMe,oBAAA,GAAuBA,CAAC;EAC5BC,KAAK;EACLC,MAAM;EACNC;AAAQ,CAKT;EACC,MAAMC,eAAA,GAAkBlB,qBAAA,CAAsBgB,MAAA;EAE9C,MAAMG,IAAA,GAAOF,QAAQ,CAAC,EAAE;EAExB,MAAMG,KAAA,GAAQF,eAAA,CAAgBG,IAAI,CAAED,KAAA,IAAUA,KAAA,CAAME,IAAI,KAAKH,IAAA;EAE7D,IAAIC,KAAA,CAAMG,IAAI,KAAK,kBAAkBH,KAAA,CAAMG,IAAI,KAAK,UAAU;IAC5D,OAAO;MACL;MACA,CAACH,KAAA,CAAME,IAAI,GAAGF,KAAA,CAAMI,OAAO,GAAG,CAACT,KAAA,CAAM,GAAGA;IAC1C;EACF;EAEA,MAAMU,YAAA,GAAeR,QAAA,CAASS,KAAK,CAAC,GAAGT,QAAA,CAASU,MAAM;EAEtD,IAAIP,KAAA,CAAMG,IAAI,KAAK,SAASH,KAAA,CAAMG,IAAI,KAAK,SAAS;IAClD,OAAO;MACL,CAACH,KAAA,CAAME,IAAI,GAAGR,oBAAA,CAAqB;QAAEC,KAA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5E4B,UAAA,EAAYhC;qBAEd2B,IAAA,CAAC3D,qBAAA;MACCiE,eAAA,EAAiBvB,WAAA;MACjBwB,QAAA,eAAUP,IAAA,CAACtD,gBAAA;QAAiB0B,WAAA,EAAaA,WAAA;QAAahB,IAAA,EAAMA;;;;AAIpE;AAEA,OAAO,MAAMoD,SAAA,GAAYjE,aAAA,CAAcyB,kBAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["ObjectIdImport","flattenTopLevelFields","React","useMemo","RelationshipTable","RenderCustomComponent","useField","withCondition","useConfig","useDocumentInfo","FieldDescription","FieldLabel","fieldBaseClass","ObjectId","default","getInitialDrawerData","collectionSlug","docID","fields","segments","flattenedFields","path","field","find","name","type","value","Array","isArray","relationTo","hasMany","nextSegments","slice","length","initialData","id","toHexString","block","blocks","blockInitialData","blockType","slug","JoinFieldComponent","props","admin","allowCreate","description","collection","label","localized","on","required","docConfig","config","collections","customComponents","AfterInput","BeforeInput","Description","Label","filterOptions","targetField","where","equals","and","initialDrawerData","relatedCollection","split","_jsxs","className","filter","Boolean","join","replace","_jsx","disableTable","docs","style","margin","CustomComponent","Fallback","JoinField"],"sources":["../../../src/fields/Join/index.tsx"],"sourcesContent":["'use client'\n\nimport type {\n ClientField,\n JoinFieldClient,\n JoinFieldClientComponent,\n PaginatedDocs,\n Where,\n} from 'payload'\n\nimport ObjectIdImport from 'bson-objectid'\nimport { flattenTopLevelFields } from 'payload/shared'\nimport React, { useMemo } from 'react'\n\nimport { RelationshipTable } from '../../elements/RelationshipTable/index.js'\nimport { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { FieldDescription } from '../FieldDescription/index.js'\nimport { FieldLabel } from '../FieldLabel/index.js'\nimport { fieldBaseClass } from '../index.js'\n\nconst ObjectId = (ObjectIdImport.default ||\n ObjectIdImport) as unknown as typeof ObjectIdImport.default\n\n/**\n * Recursively builds the default data for joined collection\n */\nconst getInitialDrawerData = ({\n collectionSlug,\n docID,\n fields,\n segments,\n}: {\n collectionSlug: string\n docID: number | string\n fields: ClientField[]\n segments: string[]\n}) => {\n const flattenedFields = flattenTopLevelFields(fields)\n\n const path = segments[0]\n\n const field = flattenedFields.find((field) => field.name === path)\n\n if (!field) {\n return null\n }\n\n if (field.type === 'relationship' || field.type === 'upload') {\n let value: { relationTo: string; value: number | string } | number | string = docID\n if (Array.isArray(field.relationTo)) {\n value = {\n relationTo: collectionSlug,\n value: docID,\n }\n }\n return {\n [field.name]: field.hasMany ? [value] : value,\n }\n }\n\n const nextSegments = segments.slice(1, segments.length)\n\n if (field.type === 'tab' || field.type === 'group') {\n return {\n [field.name]: getInitialDrawerData({\n collectionSlug,\n docID,\n fields: field.fields,\n segments: nextSegments,\n }),\n }\n }\n\n if (field.type === 'array') {\n const initialData = getInitialDrawerData({\n collectionSlug,\n docID,\n fields: field.fields,\n segments: nextSegments,\n })\n\n initialData.id = ObjectId().toHexString()\n\n return {\n [field.name]: [initialData],\n }\n }\n\n if (field.type === 'blocks') {\n for (const block of field.blocks) {\n const blockInitialData = getInitialDrawerData({\n collectionSlug,\n docID,\n fields: block.fields,\n segments: nextSegments,\n })\n\n if (blockInitialData) {\n blockInitialData.id = ObjectId().toHexString()\n blockInitialData.blockType = block.slug\n\n return {\n [field.name]: [blockInitialData],\n }\n }\n }\n }\n}\n\nconst JoinFieldComponent: JoinFieldClientComponent = (props) => {\n const {\n field,\n field: {\n admin: { allowCreate, description },\n collection,\n label,\n localized,\n on,\n required,\n },\n path,\n } = props\n\n const { id: docID, docConfig } = useDocumentInfo()\n\n const {\n config: { collections },\n } = useConfig()\n\n const { customComponents: { AfterInput, BeforeInput, Description, Label } = {}, value } =\n useField<PaginatedDocs>({\n path,\n })\n\n const filterOptions: null | Where = useMemo(() => {\n if (!docID) {\n return null\n }\n\n let value: { relationTo: string; value: number | string } | number | string = docID\n\n if (Array.isArray(field.targetField.relationTo)) {\n value = {\n relationTo: docConfig.slug,\n value,\n }\n }\n\n const where = {\n [on]: {\n equals: value,\n },\n }\n\n if (field.where) {\n return {\n and: [where, field.where],\n }\n }\n\n return where\n }, [docID, field.targetField.relationTo, field.where, on, docConfig.slug])\n\n const initialDrawerData = useMemo(() => {\n const relatedCollection = collections.find((collection) => collection.slug === field.collection)\n\n return getInitialDrawerData({\n collectionSlug: docConfig.slug,\n docID,\n fields: relatedCollection.fields,\n segments: field.on.split('.'),\n })\n }, [collections, field.on, field.collection, docConfig.slug, docID])\n\n return (\n <div\n className={[fieldBaseClass, 'join'].filter(Boolean).join(' ')}\n id={`field-${path?.replace(/\\./g, '__')}`}\n >\n <RelationshipTable\n AfterInput={AfterInput}\n allowCreate={typeof docID !== 'undefined' && allowCreate}\n BeforeInput={BeforeInput}\n disableTable={filterOptions === null}\n field={field as JoinFieldClient}\n filterOptions={filterOptions}\n initialData={docID && value ? value : ({ docs: [] } as PaginatedDocs)}\n initialDrawerData={initialDrawerData}\n Label={\n <h4 style={{ margin: 0 }}>\n {Label || (\n <FieldLabel label={label} localized={localized} path={path} required={required} />\n )}\n </h4>\n }\n relationTo={collection}\n />\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n )\n}\n\nexport const JoinField = withCondition(JoinFieldComponent)\n"],"mappings":"AAAA;;;AAUA,OAAOA,cAAA,MAAoB;AAC3B,SAASC,qBAAqB,QAAQ;AACtC,OAAOC,KAAA,IAASC,OAAO,QAAQ;AAE/B,SAASC,iBAAiB,QAAQ;AAClC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,QAAQ,QAAQ;AACzB,SAASC,aAAa,QAAQ;AAC9B,SAASC,SAAS,QAAQ;AAC1B,SAASC,eAAe,QAAQ;AAChC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,UAAU,QAAQ;AAC3B,SAASC,cAA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zDrC,EAAA,EAAI,SAASd,IAAA,EAAMoD,OAAA,CAAQ,OAAO,OAAO;4BAEzCC,IAAA,CAACtE,iBAAA;MACCoD,UAAA,EAAYA,UAAA;MACZX,WAAA,EAAa,OAAO5B,KAAA,KAAU,eAAe4B,WAAA;MAC7CY,WAAA,EAAaA,WAAA;MACbkB,YAAA,EAAcf,aAAA,KAAkB;MAChCtC,KAAA,EAAOA,KAAA;MACPsC,aAAA,EAAeA,aAAA;MACf1B,WAAA,EAAajB,KAAA,IAASS,KAAA,GAAQA,KAAA,GAAS;QAAEkD,IAAA,EAAM;MAAG;MAClDX,iBAAA,EAAmBA,iBAAA;MACnBN,KAAA,eACEe,IAAA,CAAC;QAAGG,KAAA,EAAO;UAAEC,MAAA,EAAQ;QAAE;kBACpBnB,KAAA,iBACCe,IAAA,CAAC/D,UAAA;UAAWqC,KAAA,EAAOA,KAAA;UAAOC,SAAA,EAAWA,SAAA;UAAW5B,IAAA,EAAMA,IAAA;UAAM8B,QAAA,EAAUA;;;MAI5EtB,UAAA,EAAYkB;qBAEd2B,IAAA,CAACrE,qBAAA;MACC0E,eAAA,EAAiBrB,WAAA;MACjBsB,QAAA,eAAUN,IAAA,CAAChE,gBAAA;QAAiBoC,WAAA,EAAaA,WAAA;QAAazB,IAAA,EAAMA;;;;AAIpE;AAEA,OAAO,MAAM4D,SAAA,GAAY1E,aAAA,CAAcmC,kBAAA","ignoreList":[]}
@@ -361,19 +361,19 @@ const RelationshipFieldComponent = props => {
361
361
  i18n
362
362
  });
363
363
  const currentValue = valueRef.current;
364
- const docId = args.doc.id;
364
+ const docID = args.doc.id;
365
365
  if (hasMany) {
366
- const unchanged = currentValue.some(option_0 => typeof option_0 === 'string' ? option_0 === docId : option_0.value === docId);
367
- const valuesToSet = currentValue.map(option_1 => option_1.value === docId ? {
366
+ const unchanged = currentValue.some(option_0 => typeof option_0 === 'string' ? option_0 === docID : option_0.value === docID);
367
+ const valuesToSet = currentValue.map(option_1 => option_1.value === docID ? {
368
368
  relationTo: args.collectionConfig.slug,
369
- value: docId
369
+ value: docID
370
370
  } : option_1);
371
371
  setValue(valuesToSet, unchanged);
372
372
  } else {
373
- const unchanged_0 = currentValue === docId;
373
+ const unchanged_0 = currentValue === docID;
374
374
  setValue({
375
375
  relationTo: args.collectionConfig.slug,
376
- value: docId
376
+ value: docID
377
377
  }, unchanged_0);
378
378
  }
379
379
  }, [i18n, config, hasMany, setValue]);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["wordBoundariesRegex","qs","React","useCallback","useEffect","useMemo","useReducer","useRef","useState","AddNewRelation","useDocumentDrawer","ReactSelect","RenderCustomComponent","FieldDescription","FieldError","FieldLabel","useField","withCondition","useDebouncedCallback","useIgnoredEffect","useAuth","useConfig","useLocale","useTranslation","mergeFieldStyles","fieldBaseClass","createRelationMap","findOptionsByValue","optionsReducer","MultiValueLabel","SingleValue","maxResultsPerRequest","baseClass","RelationshipFieldComponent","props","field","admin","allowCreate","allowEdit","className","description","isSortable","sortOptions","hasMany","label","localized","relationTo","required","path","readOnly","validate","config","collections","routes","api","serverURL","i18n","t","permissions","code","locale","hasMultipleRelations","Array","isArray","currentlyOpenRelationship","setCurrentlyOpenRelationship","id","undefined","collectionSlug","hasReadPermission","lastFullyLoadedRelation","setLastFullyLoadedRelation","lastLoadedPage","setLastLoadedPage","errorLoading","setErrorLoading","search","setSearch","isLoading","setIsLoading","enableWordBoundarySearch","setEnableWordBoundarySearch","menuIsOpen","setMenuIsOpen","hasLoadedFirstPageRef","memoizedValidate","value","validationOptions","customComponents","AfterInput","BeforeInput","Description","Error","Label","filterOptions","initialValue","setValue","showError","options","dispatchOptions","valueRef","current","DocumentDrawer","isDrawerOpen","openDrawer","openDrawerWhenRelationChanges","getResults","lastFullyLoadedRelationArg","lastLoadedPageArg","onSuccess","searchArg","sort","valueArg","lastFullyLoadedRelationToUse","relations","relationsToFetch","slice","resultsFetched","relationMap","reduce","priorRelation","relation","relationFilterOption","lastLoadedPageToUse","indexOf","Promise","resolve","collection","find","coll","slug","fieldToSearch","useAsTitle","fieldToSort","defaultSort","query","depth","draft","limit","page","where","and","not_in","push","like","response","fetch","body","stringify","credentials","headers","language","method","ok","data","json","prevState","nextPage","docs","length","type","status","ids","updateSearch","handleInputChange","Object","entries","idsToLoad","filter","optionGroup","option","in","isIdOnly","idOnly","exemptValues","onSave","args","collectionConfig","doc","currentValue","docId","unchanged","some","valuesToSet","map","onDuplicate","concat","onDelete","filterOption","item","searchFilter","r","breakApartThreshold","labelString","String","indexOfSpace","test","onDocumentDrawerOpen","valueToRender","styles","_jsxs","Boolean","join","replace","style","_jsx","CustomComponent","Fallback","backspaceRemovesValue","components","customProps","disableKeyDown","disableMouseDown","disabled","getOptionValue","isMulti","onChange","selected","onInputChange","newSearch","onMenuClose","onMenuOpen","onMenuScrollToBottom","RelationshipField"],"sources":["../../../src/fields/Relationship/index.tsx"],"sourcesContent":["'use client'\nimport type { PaginatedDocs, RelationshipFieldClientComponent, Where } from 'payload'\n\nimport { wordBoundariesRegex } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport React, { useCallback, useEffect, useMemo, useReducer, useRef, useState } from 'react'\n\nimport type { DocumentDrawerProps } from '../../elements/DocumentDrawer/types.js'\nimport type { ReactSelectAdapterProps } from '../../elements/ReactSelect/types.js'\nimport type { GetResults, Option, Value } from './types.js'\n\nimport { AddNewRelation } from '../../elements/AddNewRelation/index.js'\nimport { useDocumentDrawer } from '../../elements/DocumentDrawer/index.js'\nimport { ReactSelect } from '../../elements/ReactSelect/index.js'\nimport { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js'\nimport { FieldDescription } from '../../fields/FieldDescription/index.js'\nimport { FieldError } from '../../fields/FieldError/index.js'\nimport { FieldLabel } from '../../fields/FieldLabel/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useDebouncedCallback } from '../../hooks/useDebouncedCallback.js'\nimport { useIgnoredEffect } from '../../hooks/useIgnoredEffect.js'\nimport { useAuth } from '../../providers/Auth/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useLocale } from '../../providers/Locale/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { mergeFieldStyles } from '../mergeFieldStyles.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport { createRelationMap } from './createRelationMap.js'\nimport { findOptionsByValue } from './findOptionsByValue.js'\nimport { optionsReducer } from './optionsReducer.js'\nimport { MultiValueLabel } from './select-components/MultiValueLabel/index.js'\nimport { SingleValue } from './select-components/SingleValue/index.js'\nimport './index.scss'\n\nconst maxResultsPerRequest = 10\n\nconst baseClass = 'relationship'\n\nconst RelationshipFieldComponent: RelationshipFieldClientComponent = (props) => {\n const {\n field,\n field: {\n admin: {\n allowCreate = true,\n allowEdit = true,\n className,\n description,\n isSortable = true,\n sortOptions,\n } = {},\n hasMany,\n label,\n localized,\n relationTo,\n required,\n },\n path,\n readOnly,\n validate,\n } = props\n\n const { config } = useConfig()\n\n const {\n collections,\n routes: { api },\n serverURL,\n } = config\n\n const { i18n, t } = useTranslation()\n const { permissions } = useAuth()\n const { code: locale } = useLocale()\n const hasMultipleRelations = Array.isArray(relationTo)\n\n const [currentlyOpenRelationship, setCurrentlyOpenRelationship] = useState<\n Parameters<ReactSelectAdapterProps['customProps']['onDocumentDrawerOpen']>[0]\n >({\n id: undefined,\n collectionSlug: undefined,\n hasReadPermission: false,\n })\n\n const [lastFullyLoadedRelation, setLastFullyLoadedRelation] = useState(-1)\n const [lastLoadedPage, setLastLoadedPage] = useState<Record<string, number>>({})\n const [errorLoading, setErrorLoading] = useState('')\n const [search, setSearch] = useState('')\n const [isLoading, setIsLoading] = useState(false)\n const [enableWordBoundarySearch, setEnableWordBoundarySearch] = useState(false)\n const [menuIsOpen, setMenuIsOpen] = useState(false)\n const hasLoadedFirstPageRef = useRef(false)\n\n const memoizedValidate = useCallback(\n (value, validationOptions) => {\n if (typeof validate === 'function') {\n return validate(value, { ...validationOptions, required })\n }\n },\n [validate, required],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n filterOptions,\n initialValue,\n setValue,\n showError,\n value,\n } = useField<Value | Value[]>({\n path,\n validate: memoizedValidate,\n })\n const [options, dispatchOptions] = useReducer(optionsReducer, [])\n\n const valueRef = useRef(value)\n valueRef.current = value\n\n const [DocumentDrawer, , { isDrawerOpen, openDrawer }] = useDocumentDrawer({\n id: currentlyOpenRelationship.id,\n collectionSlug: currentlyOpenRelationship.collectionSlug,\n })\n\n const openDrawerWhenRelationChanges = useRef(false)\n\n const getResults: GetResults = useCallback(\n async ({\n filterOptions,\n lastFullyLoadedRelation: lastFullyLoadedRelationArg,\n lastLoadedPage: lastLoadedPageArg,\n onSuccess,\n search: searchArg,\n sort,\n value: valueArg,\n }) => {\n if (!permissions) {\n return\n }\n const lastFullyLoadedRelationToUse =\n typeof lastFullyLoadedRelationArg !== 'undefined' ? lastFullyLoadedRelationArg : -1\n\n const relations = Array.isArray(relationTo) ? relationTo : [relationTo]\n const relationsToFetch =\n lastFullyLoadedRelationToUse === -1\n ? relations\n : relations.slice(lastFullyLoadedRelationToUse + 1)\n\n let resultsFetched = 0\n const relationMap = createRelationMap({\n hasMany,\n relationTo,\n value: valueArg,\n })\n\n if (!errorLoading) {\n await relationsToFetch.reduce(async (priorRelation, relation) => {\n const relationFilterOption = filterOptions?.[relation]\n\n let lastLoadedPageToUse\n if (search !== searchArg) {\n lastLoadedPageToUse = 1\n } else {\n lastLoadedPageToUse = lastLoadedPageArg[relation] + 1\n }\n await priorRelation\n\n if (relationFilterOption === false) {\n setLastFullyLoadedRelation(relations.indexOf(relation))\n return Promise.resolve()\n }\n\n if (resultsFetched < 10) {\n const collection = collections.find((coll) => coll.slug === relation)\n const fieldToSearch = collection?.admin?.useAsTitle || 'id'\n let fieldToSort = collection?.defaultSort || 'id'\n if (typeof sortOptions === 'string') {\n fieldToSort = sortOptions\n } else if (sortOptions?.[relation]) {\n fieldToSort = sortOptions[relation]\n }\n\n const query: {\n [key: string]: unknown\n where: Where\n } = {\n depth: 0,\n draft: true,\n limit: maxResultsPerRequest,\n locale,\n page: lastLoadedPageToUse,\n sort: fieldToSort,\n where: {\n and: [\n {\n id: {\n not_in: relationMap[relation],\n },\n },\n ],\n },\n }\n\n if (searchArg) {\n query.where.and.push({\n [fieldToSearch]: {\n like: searchArg,\n },\n })\n }\n\n if (relationFilterOption && typeof relationFilterOption !== 'boolean') {\n query.where.and.push(relationFilterOption)\n }\n\n const response = await fetch(`${serverURL}${api}/${relation}`, {\n body: qs.stringify(query),\n credentials: 'include',\n headers: {\n 'Accept-Language': i18n.language,\n 'Content-Type': 'application/x-www-form-urlencoded',\n 'X-HTTP-Method-Override': 'GET',\n },\n method: 'POST',\n })\n\n if (response.ok) {\n const data: PaginatedDocs<unknown> = await response.json()\n setLastLoadedPage((prevState) => {\n return {\n ...prevState,\n [relation]: lastLoadedPageToUse,\n }\n })\n\n if (!data.nextPage) {\n setLastFullyLoadedRelation(relations.indexOf(relation))\n }\n\n if (data.docs.length > 0) {\n resultsFetched += data.docs.length\n\n dispatchOptions({\n type: 'ADD',\n collection,\n config,\n docs: data.docs,\n i18n,\n sort,\n })\n }\n } else if (response.status === 403) {\n setLastFullyLoadedRelation(relations.indexOf(relation))\n dispatchOptions({\n type: 'ADD',\n collection,\n config,\n docs: [],\n i18n,\n ids: relationMap[relation],\n sort,\n })\n } else {\n setErrorLoading(t('error:unspecific'))\n }\n }\n }, Promise.resolve())\n\n if (typeof onSuccess === 'function') {\n onSuccess()\n }\n }\n },\n [\n permissions,\n relationTo,\n hasMany,\n errorLoading,\n search,\n collections,\n locale,\n serverURL,\n sortOptions,\n api,\n i18n,\n config,\n t,\n ],\n )\n\n const updateSearch = useDebouncedCallback((searchArg: string, valueArg: Value | Value[]) => {\n void getResults({\n filterOptions,\n lastLoadedPage: {},\n search: searchArg,\n sort: true,\n value: valueArg,\n })\n setSearch(searchArg)\n }, 300)\n\n const handleInputChange = useCallback(\n (searchArg: string, valueArg: Value | Value[]) => {\n if (search !== searchArg) {\n setLastLoadedPage({})\n updateSearch(searchArg, valueArg, searchArg !== '')\n }\n },\n [search, updateSearch],\n )\n\n // ///////////////////////////////////\n // Ensure we have an option for each value\n // ///////////////////////////////////\n useIgnoredEffect(\n () => {\n const relationMap = createRelationMap({\n hasMany,\n relationTo,\n value,\n })\n\n void Object.entries(relationMap).reduce(async (priorRelation, [relation, ids]) => {\n await priorRelation\n\n const idsToLoad = ids.filter((id) => {\n return !options.find((optionGroup) =>\n optionGroup?.options?.find(\n (option) => option.value === id && option.relationTo === relation,\n ),\n )\n })\n\n if (idsToLoad.length > 0) {\n const query = {\n depth: 0,\n draft: true,\n limit: idsToLoad.length,\n locale,\n where: {\n id: {\n in: idsToLoad,\n },\n },\n }\n\n if (!errorLoading) {\n const response = await fetch(`${serverURL}${api}/${relation}`, {\n body: qs.stringify(query),\n credentials: 'include',\n headers: {\n 'Accept-Language': i18n.language,\n 'Content-Type': 'application/x-www-form-urlencoded',\n 'X-HTTP-Method-Override': 'GET',\n },\n method: 'POST',\n })\n\n const collection = collections.find((coll) => coll.slug === relation)\n let docs = []\n\n if (response.ok) {\n const data = await response.json()\n docs = data.docs\n }\n\n dispatchOptions({\n type: 'ADD',\n collection,\n config,\n docs,\n i18n,\n ids: idsToLoad,\n sort: true,\n })\n }\n }\n }, Promise.resolve())\n },\n [value],\n [\n options,\n hasMany,\n errorLoading,\n collections,\n hasMultipleRelations,\n serverURL,\n api,\n i18n,\n relationTo,\n locale,\n config,\n ],\n )\n\n // Determine if we should switch to word boundary search\n useEffect(() => {\n const relations = Array.isArray(relationTo) ? relationTo : [relationTo]\n const isIdOnly = relations.reduce((idOnly, relation) => {\n const collection = collections.find((coll) => coll.slug === relation)\n const fieldToSearch = collection?.admin?.useAsTitle || 'id'\n return fieldToSearch === 'id' && idOnly\n }, true)\n setEnableWordBoundarySearch(!isIdOnly)\n }, [relationTo, collections])\n\n // When (`relationTo` || `filterOptions` || `locale`) changes, reset component\n // Note - effect should not run on first run\n useIgnoredEffect(\n () => {\n // If the menu is open while filterOptions changes\n // due to latency of form state and fast clicking into this field,\n // re-fetch options\n if (hasLoadedFirstPageRef.current && menuIsOpen) {\n setIsLoading(true)\n void getResults({\n filterOptions,\n lastLoadedPage: {},\n onSuccess: () => {\n hasLoadedFirstPageRef.current = true\n setIsLoading(false)\n },\n value: valueRef.current,\n })\n }\n\n // If the menu is not open, still reset the field state\n // because we need to get new options next time the menu opens\n dispatchOptions({\n type: 'CLEAR',\n exemptValues: valueRef.current,\n })\n\n setLastFullyLoadedRelation(-1)\n setLastLoadedPage({})\n },\n [relationTo, filterOptions, locale, path, menuIsOpen],\n [getResults],\n )\n\n const onSave = useCallback<DocumentDrawerProps['onSave']>(\n (args) => {\n dispatchOptions({\n type: 'UPDATE',\n collection: args.collectionConfig,\n config,\n doc: args.doc,\n i18n,\n })\n\n const currentValue = valueRef.current\n const docId = args.doc.id\n\n if (hasMany) {\n const unchanged = (currentValue as Option[]).some((option) =>\n typeof option === 'string' ? option === docId : option.value === docId,\n )\n\n const valuesToSet = (currentValue as Option[]).map((option) =>\n option.value === docId\n ? { relationTo: args.collectionConfig.slug, value: docId }\n : option,\n )\n\n setValue(valuesToSet, unchanged)\n } else {\n const unchanged = currentValue === docId\n\n setValue({ relationTo: args.collectionConfig.slug, value: docId }, unchanged)\n }\n },\n [i18n, config, hasMany, setValue],\n )\n\n const onDuplicate = useCallback<DocumentDrawerProps['onDuplicate']>(\n (args) => {\n dispatchOptions({\n type: 'ADD',\n collection: args.collectionConfig,\n config,\n docs: [args.doc],\n i18n,\n sort: true,\n })\n\n if (hasMany) {\n setValue(\n valueRef.current\n ? (valueRef.current as Option[]).concat({\n relationTo: args.collectionConfig.slug,\n value: args.doc.id,\n } as Option)\n : null,\n )\n } else {\n setValue({\n relationTo: args.collectionConfig.slug,\n value: args.doc.id,\n })\n }\n },\n [i18n, config, hasMany, setValue],\n )\n\n const onDelete = useCallback<DocumentDrawerProps['onDelete']>(\n (args) => {\n dispatchOptions({\n id: args.id,\n type: 'REMOVE',\n collection: args.collectionConfig,\n config,\n i18n,\n })\n\n if (hasMany) {\n setValue(\n valueRef.current\n ? (valueRef.current as Option[]).filter((option) => {\n return option.value !== args.id\n })\n : null,\n )\n } else {\n setValue(null)\n }\n\n return\n },\n [i18n, config, hasMany, setValue],\n )\n\n const filterOption = useCallback((item: Option, searchFilter: string) => {\n if (!searchFilter) {\n return true\n }\n const r = wordBoundariesRegex(searchFilter || '')\n // breaking the labels to search into smaller parts increases performance\n const breakApartThreshold = 250\n let labelString = String(item.label)\n // strings less than breakApartThreshold length won't be chunked\n while (labelString.length > breakApartThreshold) {\n // slicing by the next space after the length of the search input prevents slicing the string up by partial words\n const indexOfSpace = labelString.indexOf(' ', searchFilter.length)\n if (\n r.test(labelString.slice(0, indexOfSpace === -1 ? searchFilter.length : indexOfSpace + 1))\n ) {\n return true\n }\n labelString = labelString.slice(indexOfSpace === -1 ? searchFilter.length : indexOfSpace + 1)\n }\n return r.test(labelString.slice(-breakApartThreshold))\n }, [])\n\n const onDocumentDrawerOpen = useCallback<\n ReactSelectAdapterProps['customProps']['onDocumentDrawerOpen']\n >(({ id, collectionSlug, hasReadPermission }) => {\n openDrawerWhenRelationChanges.current = true\n setCurrentlyOpenRelationship({\n id,\n collectionSlug,\n hasReadPermission,\n })\n }, [])\n\n useEffect(() => {\n if (openDrawerWhenRelationChanges.current) {\n openDrawer()\n openDrawerWhenRelationChanges.current = false\n }\n }, [openDrawer, currentlyOpenRelationship])\n\n const valueToRender = findOptionsByValue({ allowEdit, options, value })\n\n if (!Array.isArray(valueToRender) && valueToRender?.value === 'null') {\n valueToRender.value = null\n }\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n return (\n <div\n className={[\n fieldBaseClass,\n baseClass,\n className,\n showError && 'error',\n errorLoading && 'error-loading',\n readOnly && `${baseClass}--read-only`,\n !readOnly && allowCreate && `${baseClass}--allow-create`,\n ]\n .filter(Boolean)\n .join(' ')}\n id={`field-${path.replace(/\\./g, '__')}`}\n style={styles}\n >\n <RenderCustomComponent\n CustomComponent={Label}\n Fallback={\n <FieldLabel label={label} localized={localized} path={path} required={required} />\n }\n />\n <div className={`${fieldBaseClass}__wrap`}>\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError path={path} showError={showError} />}\n />\n {BeforeInput}\n {!errorLoading && (\n <div className={`${baseClass}__wrap`}>\n <ReactSelect\n backspaceRemovesValue={!isDrawerOpen}\n components={{\n MultiValueLabel,\n SingleValue,\n }}\n customProps={{\n disableKeyDown: isDrawerOpen,\n disableMouseDown: isDrawerOpen,\n onDocumentDrawerOpen,\n onSave,\n }}\n disabled={readOnly || isDrawerOpen}\n filterOption={enableWordBoundarySearch ? filterOption : undefined}\n getOptionValue={(option) => {\n if (!option) {\n return undefined\n }\n return hasMany && Array.isArray(relationTo)\n ? `${option.relationTo}_${option.value}`\n : (option.value as string)\n }}\n isLoading={isLoading}\n isMulti={hasMany}\n isSortable={isSortable}\n onChange={\n !readOnly\n ? (selected) => {\n if (selected === null) {\n setValue(hasMany ? [] : null)\n } else if (hasMany && Array.isArray(selected)) {\n setValue(\n selected\n ? selected.map((option) => {\n if (hasMultipleRelations) {\n return {\n relationTo: option.relationTo,\n value: option.value,\n }\n }\n\n return option.value\n })\n : null,\n )\n } else if (hasMultipleRelations && !Array.isArray(selected)) {\n setValue({\n relationTo: selected.relationTo,\n value: selected.value,\n })\n } else if (!Array.isArray(selected)) {\n setValue(selected.value)\n }\n }\n : undefined\n }\n onInputChange={(newSearch) => handleInputChange(newSearch, value)}\n onMenuClose={() => {\n setMenuIsOpen(false)\n }}\n onMenuOpen={() => {\n setMenuIsOpen(true)\n\n if (!hasLoadedFirstPageRef.current) {\n setIsLoading(true)\n void getResults({\n filterOptions,\n lastLoadedPage: {},\n onSuccess: () => {\n hasLoadedFirstPageRef.current = true\n setIsLoading(false)\n },\n value: initialValue,\n })\n }\n }}\n onMenuScrollToBottom={() => {\n void getResults({\n filterOptions,\n lastFullyLoadedRelation,\n lastLoadedPage,\n search,\n sort: false,\n value: initialValue,\n })\n }}\n options={options}\n showError={showError}\n value={valueToRender ?? null}\n />\n {!readOnly && allowCreate && (\n <AddNewRelation\n hasMany={hasMany}\n path={path}\n relationTo={relationTo}\n setValue={setValue}\n value={value}\n />\n )}\n </div>\n )}\n {errorLoading && <div className={`${baseClass}__error-loading`}>{errorLoading}</div>}\n {AfterInput}\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n {currentlyOpenRelationship.collectionSlug && currentlyOpenRelationship.hasReadPermission && (\n <DocumentDrawer onDelete={onDelete} onDuplicate={onDuplicate} onSave={onSave} />\n )}\n </div>\n )\n}\n\nexport const RelationshipField = withCondition(RelationshipFieldComponent)\n"],"mappings":"AAAA;;;AAGA,SAASA,mBAAmB,QAAQ;AACpC,YAAYC,EAAA,MAAQ;AACpB,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,UAAU,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAMrF,SAASC,cAAc,QAAQ;AAC/B,SAASC,iBAAiB,QAAQ;AAClC,SAASC,WAAW,QAAQ;AAC5B,SAASC,qBAAqB,QAAQ;AACtC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,UAAU,QAAQ;AAC3B,SAASC,UAAU,QAAQ;AAC3B,SAASC,QAAQ,QAAQ;AACzB,SAASC,aAAa,QAAQ;AAC9B,SAASC,oBAAoB,QAAQ;AACrC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,OAAO,QAAQ;AACxB,SAASC,SAAS,QAAQ;AAC1B,SAASC,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAC/B,SAASC,gBAAgB,QAAQ;AACjC,SAASC,cAAc,QAAQ;AAC/B,SAASC,iBAAiB,QAAQ;AAClC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,c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IAAiB;YAEzB,CAACrJ,QAAA,IAAYZ,WAAA,iBACZwK,IAAA,CAACpM,cAAA;UACCkC,OAAA,EAASA,OAAA;UACTK,IAAA,EAAMA,IAAA;UACNF,UAAA,EAAYA,UAAA;UACZkD,QAAA,EAAUA,QAAA;UACVV,KAAA,EAAOA;;UAKdZ,YAAA,iBAAgBmI,IAAA,CAAC;QAAItK,SAAA,EAAW,GAAGP,SAAA,iBAA0B;kBAAG0C;UAChEe,UAAA,E,aACDoH,IAAA,CAACjM,qBAAA;QACCkM,eAAA,EAAiBnH,WAAA;QACjBoH,QAAA,eAAUF,IAAA,CAAChM,gBAAA;UAAiB2B,WAAA,EAAaA,WAAA;UAAaQ,IAAA,EAAMA;;;QAG/DgB,yBAAA,CAA0BI,cAAc,IAAIJ,yBAAA,CAA0BK,iBAAiB,iBACtFwI,IAAA,CAACvG,cAAA;MAAeqF,QAAA,EAAUA,QAAA;MAAUF,WAAA,EAAaA,WAAA;MAAaV,MAAA,EAAQA;;;AAI9E;AAEA,OAAO,MAAMgD,iBAAA,GAAoB9M,aAAA,CAAcgB,0BAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["wordBoundariesRegex","qs","React","useCallback","useEffect","useMemo","useReducer","useRef","useState","AddNewRelation","useDocumentDrawer","ReactSelect","RenderCustomComponent","FieldDescription","FieldError","FieldLabel","useField","withCondition","useDebouncedCallback","useIgnoredEffect","useAuth","useConfig","useLocale","useTranslation","mergeFieldStyles","fieldBaseClass","createRelationMap","findOptionsByValue","optionsReducer","MultiValueLabel","SingleValue","maxResultsPerRequest","baseClass","RelationshipFieldComponent","props","field","admin","allowCreate","allowEdit","className","description","isSortable","sortOptions","hasMany","label","localized","relationTo","required","path","readOnly","validate","config","collections","routes","api","serverURL","i18n","t","permissions","code","locale","hasMultipleRelations","Array","isArray","currentlyOpenRelationship","setCurrentlyOpenRelationship","id","undefined","collectionSlug","hasReadPermission","lastFullyLoadedRelation","setLastFullyLoadedRelation","lastLoadedPage","setLastLoadedPage","errorLoading","setErrorLoading","search","setSearch","isLoading","setIsLoading","enableWordBoundarySearch","setEnableWordBoundarySearch","menuIsOpen","setMenuIsOpen","hasLoadedFirstPageRef","memoizedValidate","value","validationOptions","customComponents","AfterInput","BeforeInput","Description","Error","Label","filterOptions","initialValue","setValue","showError","options","dispatchOptions","valueRef","current","DocumentDrawer","isDrawerOpen","openDrawer","openDrawerWhenRelationChanges","getResults","lastFullyLoadedRelationArg","lastLoadedPageArg","onSuccess","searchArg","sort","valueArg","lastFullyLoadedRelationToUse","relations","relationsToFetch","slice","resultsFetched","relationMap","reduce","priorRelation","relation","relationFilterOption","lastLoadedPageToUse","indexOf","Promise","resolve","collection","find","coll","slug","fieldToSearch","useAsTitle","fieldToSort","defaultSort","query","depth","draft","limit","page","where","and","not_in","push","like","response","fetch","body","stringify","credentials","headers","language","method","ok","data","json","prevState","nextPage","docs","length","type","status","ids","updateSearch","handleInputChange","Object","entries","idsToLoad","filter","optionGroup","option","in","isIdOnly","idOnly","exemptValues","onSave","args","collectionConfig","doc","currentValue","docID","unchanged","some","valuesToSet","map","onDuplicate","concat","onDelete","filterOption","item","searchFilter","r","breakApartThreshold","labelString","String","indexOfSpace","test","onDocumentDrawerOpen","valueToRender","styles","_jsxs","Boolean","join","replace","style","_jsx","CustomComponent","Fallback","backspaceRemovesValue","components","customProps","disableKeyDown","disableMouseDown","disabled","getOptionValue","isMulti","onChange","selected","onInputChange","newSearch","onMenuClose","onMenuOpen","onMenuScrollToBottom","RelationshipField"],"sources":["../../../src/fields/Relationship/index.tsx"],"sourcesContent":["'use client'\nimport type { PaginatedDocs, RelationshipFieldClientComponent, Where } from 'payload'\n\nimport { wordBoundariesRegex } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport React, { useCallback, useEffect, useMemo, useReducer, useRef, useState } from 'react'\n\nimport type { DocumentDrawerProps } from '../../elements/DocumentDrawer/types.js'\nimport type { ReactSelectAdapterProps } from '../../elements/ReactSelect/types.js'\nimport type { GetResults, Option, Value } from './types.js'\n\nimport { AddNewRelation } from '../../elements/AddNewRelation/index.js'\nimport { useDocumentDrawer } from '../../elements/DocumentDrawer/index.js'\nimport { ReactSelect } from '../../elements/ReactSelect/index.js'\nimport { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js'\nimport { FieldDescription } from '../../fields/FieldDescription/index.js'\nimport { FieldError } from '../../fields/FieldError/index.js'\nimport { FieldLabel } from '../../fields/FieldLabel/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useDebouncedCallback } from '../../hooks/useDebouncedCallback.js'\nimport { useIgnoredEffect } from '../../hooks/useIgnoredEffect.js'\nimport { useAuth } from '../../providers/Auth/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useLocale } from '../../providers/Locale/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { mergeFieldStyles } from '../mergeFieldStyles.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport { createRelationMap } from './createRelationMap.js'\nimport { findOptionsByValue } from './findOptionsByValue.js'\nimport { optionsReducer } from './optionsReducer.js'\nimport { MultiValueLabel } from './select-components/MultiValueLabel/index.js'\nimport { SingleValue } from './select-components/SingleValue/index.js'\nimport './index.scss'\n\nconst maxResultsPerRequest = 10\n\nconst baseClass = 'relationship'\n\nconst RelationshipFieldComponent: RelationshipFieldClientComponent = (props) => {\n const {\n field,\n field: {\n admin: {\n allowCreate = true,\n allowEdit = true,\n className,\n description,\n isSortable = true,\n sortOptions,\n } = {},\n hasMany,\n label,\n localized,\n relationTo,\n required,\n },\n path,\n readOnly,\n validate,\n } = props\n\n const { config } = useConfig()\n\n const {\n collections,\n routes: { api },\n serverURL,\n } = config\n\n const { i18n, t } = useTranslation()\n const { permissions } = useAuth()\n const { code: locale } = useLocale()\n const hasMultipleRelations = Array.isArray(relationTo)\n\n const [currentlyOpenRelationship, setCurrentlyOpenRelationship] = useState<\n Parameters<ReactSelectAdapterProps['customProps']['onDocumentDrawerOpen']>[0]\n >({\n id: undefined,\n collectionSlug: undefined,\n hasReadPermission: false,\n })\n\n const [lastFullyLoadedRelation, setLastFullyLoadedRelation] = useState(-1)\n const [lastLoadedPage, setLastLoadedPage] = useState<Record<string, number>>({})\n const [errorLoading, setErrorLoading] = useState('')\n const [search, setSearch] = useState('')\n const [isLoading, setIsLoading] = useState(false)\n const [enableWordBoundarySearch, setEnableWordBoundarySearch] = useState(false)\n const [menuIsOpen, setMenuIsOpen] = useState(false)\n const hasLoadedFirstPageRef = useRef(false)\n\n const memoizedValidate = useCallback(\n (value, validationOptions) => {\n if (typeof validate === 'function') {\n return validate(value, { ...validationOptions, required })\n }\n },\n [validate, required],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n filterOptions,\n initialValue,\n setValue,\n showError,\n value,\n } = useField<Value | Value[]>({\n path,\n validate: memoizedValidate,\n })\n const [options, dispatchOptions] = useReducer(optionsReducer, [])\n\n const valueRef = useRef(value)\n valueRef.current = value\n\n const [DocumentDrawer, , { isDrawerOpen, openDrawer }] = useDocumentDrawer({\n id: currentlyOpenRelationship.id,\n collectionSlug: currentlyOpenRelationship.collectionSlug,\n })\n\n const openDrawerWhenRelationChanges = useRef(false)\n\n const getResults: GetResults = useCallback(\n async ({\n filterOptions,\n lastFullyLoadedRelation: lastFullyLoadedRelationArg,\n lastLoadedPage: lastLoadedPageArg,\n onSuccess,\n search: searchArg,\n sort,\n value: valueArg,\n }) => {\n if (!permissions) {\n return\n }\n const lastFullyLoadedRelationToUse =\n typeof lastFullyLoadedRelationArg !== 'undefined' ? lastFullyLoadedRelationArg : -1\n\n const relations = Array.isArray(relationTo) ? relationTo : [relationTo]\n const relationsToFetch =\n lastFullyLoadedRelationToUse === -1\n ? relations\n : relations.slice(lastFullyLoadedRelationToUse + 1)\n\n let resultsFetched = 0\n const relationMap = createRelationMap({\n hasMany,\n relationTo,\n value: valueArg,\n })\n\n if (!errorLoading) {\n await relationsToFetch.reduce(async (priorRelation, relation) => {\n const relationFilterOption = filterOptions?.[relation]\n\n let lastLoadedPageToUse\n if (search !== searchArg) {\n lastLoadedPageToUse = 1\n } else {\n lastLoadedPageToUse = lastLoadedPageArg[relation] + 1\n }\n await priorRelation\n\n if (relationFilterOption === false) {\n setLastFullyLoadedRelation(relations.indexOf(relation))\n return Promise.resolve()\n }\n\n if (resultsFetched < 10) {\n const collection = collections.find((coll) => coll.slug === relation)\n const fieldToSearch = collection?.admin?.useAsTitle || 'id'\n let fieldToSort = collection?.defaultSort || 'id'\n if (typeof sortOptions === 'string') {\n fieldToSort = sortOptions\n } else if (sortOptions?.[relation]) {\n fieldToSort = sortOptions[relation]\n }\n\n const query: {\n [key: string]: unknown\n where: Where\n } = {\n depth: 0,\n draft: true,\n limit: maxResultsPerRequest,\n locale,\n page: lastLoadedPageToUse,\n sort: fieldToSort,\n where: {\n and: [\n {\n id: {\n not_in: relationMap[relation],\n },\n },\n ],\n },\n }\n\n if (searchArg) {\n query.where.and.push({\n [fieldToSearch]: {\n like: searchArg,\n },\n })\n }\n\n if (relationFilterOption && typeof relationFilterOption !== 'boolean') {\n query.where.and.push(relationFilterOption)\n }\n\n const response = await fetch(`${serverURL}${api}/${relation}`, {\n body: qs.stringify(query),\n credentials: 'include',\n headers: {\n 'Accept-Language': i18n.language,\n 'Content-Type': 'application/x-www-form-urlencoded',\n 'X-HTTP-Method-Override': 'GET',\n },\n method: 'POST',\n })\n\n if (response.ok) {\n const data: PaginatedDocs<unknown> = await response.json()\n setLastLoadedPage((prevState) => {\n return {\n ...prevState,\n [relation]: lastLoadedPageToUse,\n }\n })\n\n if (!data.nextPage) {\n setLastFullyLoadedRelation(relations.indexOf(relation))\n }\n\n if (data.docs.length > 0) {\n resultsFetched += data.docs.length\n\n dispatchOptions({\n type: 'ADD',\n collection,\n config,\n docs: data.docs,\n i18n,\n sort,\n })\n }\n } else if (response.status === 403) {\n setLastFullyLoadedRelation(relations.indexOf(relation))\n dispatchOptions({\n type: 'ADD',\n collection,\n config,\n docs: [],\n i18n,\n ids: relationMap[relation],\n sort,\n })\n } else {\n setErrorLoading(t('error:unspecific'))\n }\n }\n }, Promise.resolve())\n\n if (typeof onSuccess === 'function') {\n onSuccess()\n }\n }\n },\n [\n permissions,\n relationTo,\n hasMany,\n errorLoading,\n search,\n collections,\n locale,\n serverURL,\n sortOptions,\n api,\n i18n,\n config,\n t,\n ],\n )\n\n const updateSearch = useDebouncedCallback((searchArg: string, valueArg: Value | Value[]) => {\n void getResults({\n filterOptions,\n lastLoadedPage: {},\n search: searchArg,\n sort: true,\n value: valueArg,\n })\n setSearch(searchArg)\n }, 300)\n\n const handleInputChange = useCallback(\n (searchArg: string, valueArg: Value | Value[]) => {\n if (search !== searchArg) {\n setLastLoadedPage({})\n updateSearch(searchArg, valueArg, searchArg !== '')\n }\n },\n [search, updateSearch],\n )\n\n // ///////////////////////////////////\n // Ensure we have an option for each value\n // ///////////////////////////////////\n useIgnoredEffect(\n () => {\n const relationMap = createRelationMap({\n hasMany,\n relationTo,\n value,\n })\n\n void Object.entries(relationMap).reduce(async (priorRelation, [relation, ids]) => {\n await priorRelation\n\n const idsToLoad = ids.filter((id) => {\n return !options.find((optionGroup) =>\n optionGroup?.options?.find(\n (option) => option.value === id && option.relationTo === relation,\n ),\n )\n })\n\n if (idsToLoad.length > 0) {\n const query = {\n depth: 0,\n draft: true,\n limit: idsToLoad.length,\n locale,\n where: {\n id: {\n in: idsToLoad,\n },\n },\n }\n\n if (!errorLoading) {\n const response = await fetch(`${serverURL}${api}/${relation}`, {\n body: qs.stringify(query),\n credentials: 'include',\n headers: {\n 'Accept-Language': i18n.language,\n 'Content-Type': 'application/x-www-form-urlencoded',\n 'X-HTTP-Method-Override': 'GET',\n },\n method: 'POST',\n })\n\n const collection = collections.find((coll) => coll.slug === relation)\n let docs = []\n\n if (response.ok) {\n const data = await response.json()\n docs = data.docs\n }\n\n dispatchOptions({\n type: 'ADD',\n collection,\n config,\n docs,\n i18n,\n ids: idsToLoad,\n sort: true,\n })\n }\n }\n }, Promise.resolve())\n },\n [value],\n [\n options,\n hasMany,\n errorLoading,\n collections,\n hasMultipleRelations,\n serverURL,\n api,\n i18n,\n relationTo,\n locale,\n config,\n ],\n )\n\n // Determine if we should switch to word boundary search\n useEffect(() => {\n const relations = Array.isArray(relationTo) ? relationTo : [relationTo]\n const isIdOnly = relations.reduce((idOnly, relation) => {\n const collection = collections.find((coll) => coll.slug === relation)\n const fieldToSearch = collection?.admin?.useAsTitle || 'id'\n return fieldToSearch === 'id' && idOnly\n }, true)\n setEnableWordBoundarySearch(!isIdOnly)\n }, [relationTo, collections])\n\n // When (`relationTo` || `filterOptions` || `locale`) changes, reset component\n // Note - effect should not run on first run\n useIgnoredEffect(\n () => {\n // If the menu is open while filterOptions changes\n // due to latency of form state and fast clicking into this field,\n // re-fetch options\n if (hasLoadedFirstPageRef.current && menuIsOpen) {\n setIsLoading(true)\n void getResults({\n filterOptions,\n lastLoadedPage: {},\n onSuccess: () => {\n hasLoadedFirstPageRef.current = true\n setIsLoading(false)\n },\n value: valueRef.current,\n })\n }\n\n // If the menu is not open, still reset the field state\n // because we need to get new options next time the menu opens\n dispatchOptions({\n type: 'CLEAR',\n exemptValues: valueRef.current,\n })\n\n setLastFullyLoadedRelation(-1)\n setLastLoadedPage({})\n },\n [relationTo, filterOptions, locale, path, menuIsOpen],\n [getResults],\n )\n\n const onSave = useCallback<DocumentDrawerProps['onSave']>(\n (args) => {\n dispatchOptions({\n type: 'UPDATE',\n collection: args.collectionConfig,\n config,\n doc: args.doc,\n i18n,\n })\n\n const currentValue = valueRef.current\n const docID = args.doc.id\n\n if (hasMany) {\n const unchanged = (currentValue as Option[]).some((option) =>\n typeof option === 'string' ? option === docID : option.value === docID,\n )\n\n const valuesToSet = (currentValue as Option[]).map((option) =>\n option.value === docID\n ? { relationTo: args.collectionConfig.slug, value: docID }\n : option,\n )\n\n setValue(valuesToSet, unchanged)\n } else {\n const unchanged = currentValue === docID\n\n setValue({ relationTo: args.collectionConfig.slug, value: docID }, unchanged)\n }\n },\n [i18n, config, hasMany, setValue],\n )\n\n const onDuplicate = useCallback<DocumentDrawerProps['onDuplicate']>(\n (args) => {\n dispatchOptions({\n type: 'ADD',\n collection: args.collectionConfig,\n config,\n docs: [args.doc],\n i18n,\n sort: true,\n })\n\n if (hasMany) {\n setValue(\n valueRef.current\n ? (valueRef.current as Option[]).concat({\n relationTo: args.collectionConfig.slug,\n value: args.doc.id,\n } as Option)\n : null,\n )\n } else {\n setValue({\n relationTo: args.collectionConfig.slug,\n value: args.doc.id,\n })\n }\n },\n [i18n, config, hasMany, setValue],\n )\n\n const onDelete = useCallback<DocumentDrawerProps['onDelete']>(\n (args) => {\n dispatchOptions({\n id: args.id,\n type: 'REMOVE',\n collection: args.collectionConfig,\n config,\n i18n,\n })\n\n if (hasMany) {\n setValue(\n valueRef.current\n ? (valueRef.current as Option[]).filter((option) => {\n return option.value !== args.id\n })\n : null,\n )\n } else {\n setValue(null)\n }\n\n return\n },\n [i18n, config, hasMany, setValue],\n )\n\n const filterOption = useCallback((item: Option, searchFilter: string) => {\n if (!searchFilter) {\n return true\n }\n const r = wordBoundariesRegex(searchFilter || '')\n // breaking the labels to search into smaller parts increases performance\n const breakApartThreshold = 250\n let labelString = String(item.label)\n // strings less than breakApartThreshold length won't be chunked\n while (labelString.length > breakApartThreshold) {\n // slicing by the next space after the length of the search input prevents slicing the string up by partial words\n const indexOfSpace = labelString.indexOf(' ', searchFilter.length)\n if (\n r.test(labelString.slice(0, indexOfSpace === -1 ? searchFilter.length : indexOfSpace + 1))\n ) {\n return true\n }\n labelString = labelString.slice(indexOfSpace === -1 ? searchFilter.length : indexOfSpace + 1)\n }\n return r.test(labelString.slice(-breakApartThreshold))\n }, [])\n\n const onDocumentDrawerOpen = useCallback<\n ReactSelectAdapterProps['customProps']['onDocumentDrawerOpen']\n >(({ id, collectionSlug, hasReadPermission }) => {\n openDrawerWhenRelationChanges.current = true\n setCurrentlyOpenRelationship({\n id,\n collectionSlug,\n hasReadPermission,\n })\n }, [])\n\n useEffect(() => {\n if (openDrawerWhenRelationChanges.current) {\n openDrawer()\n openDrawerWhenRelationChanges.current = false\n }\n }, [openDrawer, currentlyOpenRelationship])\n\n const valueToRender = findOptionsByValue({ allowEdit, options, value })\n\n if (!Array.isArray(valueToRender) && valueToRender?.value === 'null') {\n valueToRender.value = null\n }\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n return (\n <div\n className={[\n fieldBaseClass,\n baseClass,\n className,\n showError && 'error',\n errorLoading && 'error-loading',\n readOnly && `${baseClass}--read-only`,\n !readOnly && allowCreate && `${baseClass}--allow-create`,\n ]\n .filter(Boolean)\n .join(' ')}\n id={`field-${path.replace(/\\./g, '__')}`}\n style={styles}\n >\n <RenderCustomComponent\n CustomComponent={Label}\n Fallback={\n <FieldLabel label={label} localized={localized} path={path} required={required} />\n }\n />\n <div className={`${fieldBaseClass}__wrap`}>\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError path={path} showError={showError} />}\n />\n {BeforeInput}\n {!errorLoading && (\n <div className={`${baseClass}__wrap`}>\n <ReactSelect\n backspaceRemovesValue={!isDrawerOpen}\n components={{\n MultiValueLabel,\n SingleValue,\n }}\n customProps={{\n disableKeyDown: isDrawerOpen,\n disableMouseDown: isDrawerOpen,\n onDocumentDrawerOpen,\n onSave,\n }}\n disabled={readOnly || isDrawerOpen}\n filterOption={enableWordBoundarySearch ? filterOption : undefined}\n getOptionValue={(option) => {\n if (!option) {\n return undefined\n }\n return hasMany && Array.isArray(relationTo)\n ? `${option.relationTo}_${option.value}`\n : (option.value as string)\n }}\n isLoading={isLoading}\n isMulti={hasMany}\n isSortable={isSortable}\n onChange={\n !readOnly\n ? (selected) => {\n if (selected === null) {\n setValue(hasMany ? [] : null)\n } else if (hasMany && Array.isArray(selected)) {\n setValue(\n selected\n ? selected.map((option) => {\n if (hasMultipleRelations) {\n return {\n relationTo: option.relationTo,\n value: option.value,\n }\n }\n\n return option.value\n })\n : null,\n )\n } else if (hasMultipleRelations && !Array.isArray(selected)) {\n setValue({\n relationTo: selected.relationTo,\n value: selected.value,\n })\n } else if (!Array.isArray(selected)) {\n setValue(selected.value)\n }\n }\n : undefined\n }\n onInputChange={(newSearch) => handleInputChange(newSearch, value)}\n onMenuClose={() => {\n setMenuIsOpen(false)\n }}\n onMenuOpen={() => {\n setMenuIsOpen(true)\n\n if (!hasLoadedFirstPageRef.current) {\n setIsLoading(true)\n void getResults({\n filterOptions,\n lastLoadedPage: {},\n onSuccess: () => {\n hasLoadedFirstPageRef.current = true\n setIsLoading(false)\n },\n value: initialValue,\n })\n }\n }}\n onMenuScrollToBottom={() => {\n void getResults({\n filterOptions,\n lastFullyLoadedRelation,\n lastLoadedPage,\n search,\n sort: false,\n value: initialValue,\n })\n }}\n options={options}\n showError={showError}\n value={valueToRender ?? null}\n />\n {!readOnly && allowCreate && (\n <AddNewRelation\n hasMany={hasMany}\n path={path}\n relationTo={relationTo}\n setValue={setValue}\n value={value}\n />\n )}\n </div>\n )}\n {errorLoading && <div className={`${baseClass}__error-loading`}>{errorLoading}</div>}\n {AfterInput}\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n {currentlyOpenRelationship.collectionSlug && currentlyOpenRelationship.hasReadPermission && (\n <DocumentDrawer onDelete={onDelete} onDuplicate={onDuplicate} onSave={onSave} />\n )}\n </div>\n )\n}\n\nexport const RelationshipField = withCondition(RelationshipFieldComponent)\n"],"mappings":"AAAA;;;AAGA,SAASA,mBAAmB,QAAQ;AACpC,YAAYC,EAAA,MAAQ;AACpB,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,UAAU,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAMrF,SAASC,cAAc,QAAQ;AAC/B,SAASC,iBAAiB,QAAQ;AAClC,SAASC,WAAW,QAAQ;AAC5B,SAASC,qBAAqB,QAAQ;AAC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