Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
1 line
49 KiB
Plaintext
1 line
49 KiB
Plaintext
{"version":3,"file":"index.js","names":["useRouter","useSearchParams","extractID","formatAdminURL","formatFolderOrDocumentItem","qs","React","toast","useDrawerDepth","parseSearchParams","useConfig","useLocale","useRouteTransition","useTranslation","groupItemIDsByRelation","Context","createContext","activeCollectionFolderSlugs","allCollectionFolderSlugs","allowCreateCollectionSlugs","breadcrumbs","checkIfItemIsDisabled","clearSelections","currentFolder","documents","dragOverlayItem","undefined","focusedRowIndex","folderCollectionConfig","folderCollectionSlug","folderFieldName","folderID","FolderResultsComponent","folderType","getFolderRoute","getSelectedItems","isDragging","itemKeysToMove","moveToFolder","Promise","resolve","onItemClick","onItemKeyPress","refineFolderData","search","selectedFolderCollections","selectedItemKeys","Set","setBreadcrumbs","setFocusedRowIndex","setIsDragging","sort","subfolders","FolderProvider","activeCollectionSlugs","allowMultiSelection","baseFolderPath","_breadcrumbsFromProps","children","InitialFolderResultsComponent","onItemClickFromProps","parentFolderContext","useFolder","config","routes","drawerDepth","t","router","startRouteTransition","locale","localeCode","code","currentlySelectedIndexes","useRef","setSelectedFolderCollections","useState","setFolderResultsComponent","collections","find","collection","folders","slug","rawSearchParams","searchParams","useMemo","currentQuery","setCurrentQuery","setSelectedItemKeys","setDragOverlayItem","lastClickTime","totalCount","length","useCallback","current","mergeQuery","newQuery","page","mergedQuery","relationTo","query","updateURL","queryParams","replace","stringify","JSON","addQueryPrefix","toFolderID","adminRoute","admin","path","getItem","itemKey","doc","Array","from","reduce","acc","item","push","navigateAfterSelection","collectionSlug","docID","handleShiftSelection","targetIndex","allItems","existingIndexes","idx","has","firstSelectedIndex","Math","min","lastSelectedIndex","max","isWithinBounds","anchorIndex","distanceToFirst","abs","distanceToLast","startIndex","endIndex","newRangeIndexes","_","i","updateSelections","indexes","newSelectedFolderCollections","newSelectedItemKeys","index","includes","add","value","forEach","event","currentItem","ctrlKey","metaKey","shiftKey","isShiftPressed","isCtrlPressed","isCurrentlySelected","currentItemIndex","findIndex","preventDefault","isBackward","newItemIndex","selectedIndexes","newItem","size","prevIndex","nextIndex","clickedItem","doubleClicked","overlayItemKey","type","now","Date","args","itemsToMove","items","movingCurrentFolder","id","depth","req","fetch","apiRoute","api","body","credentials","headers","method","status","error","ids","Object","entries","limit","where","in","console","folderAcceptsItem","isArray","Boolean","some","isSelected","useEffect","_jsx","isUpload","useAsTitle","context","use","Error"],"sources":["../../../src/providers/Folders/index.tsx"],"sourcesContent":["'use client'\n\nimport type { ClientCollectionConfig, CollectionSlug, FolderSortKeys } from 'payload'\nimport type { FolderBreadcrumb, FolderDocumentItemKey, FolderOrDocument } from 'payload/shared'\n\nimport { useRouter, useSearchParams } from 'next/navigation.js'\nimport { extractID, formatAdminURL, formatFolderOrDocumentItem } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport React from 'react'\nimport { toast } from 'sonner'\n\nimport { useDrawerDepth } from '../../elements/Drawer/index.js'\nimport { parseSearchParams } from '../../utilities/parseSearchParams.js'\nimport { useConfig } from '../Config/index.js'\nimport { useLocale } from '../Locale/index.js'\nimport { useRouteTransition } from '../RouteTransition/index.js'\nimport { useTranslation } from '../Translation/index.js'\nimport { groupItemIDsByRelation } from './groupItemIDsByRelation.js'\n\ntype FolderQueryParams = {\n page?: string\n relationTo?: CollectionSlug[]\n search?: string\n sort?: string\n}\n\nexport type FileCardData = {\n filename: string\n id: number | string\n mimeType: string\n name: string\n url: string\n}\n\nexport type FolderContextValue = {\n /**\n * The collection slugs that a view can be filtered by\n * Used in the browse-by-folder view\n */\n activeCollectionFolderSlugs: CollectionSlug[]\n /**\n * Folder enabled collection slugs that can be populated within the provider\n */\n readonly allCollectionFolderSlugs?: CollectionSlug[]\n allowCreateCollectionSlugs: CollectionSlug[]\n breadcrumbs?: FolderBreadcrumb[]\n checkIfItemIsDisabled: (item: FolderOrDocument) => boolean\n clearSelections: () => void\n currentFolder?: FolderOrDocument | null\n documents?: FolderOrDocument[]\n dragOverlayItem?: FolderOrDocument | undefined\n focusedRowIndex: number\n folderCollectionConfig: ClientCollectionConfig\n folderCollectionSlug: string\n folderFieldName: string\n folderID?: number | string\n FolderResultsComponent: React.ReactNode\n folderType: CollectionSlug[] | undefined\n getFolderRoute: (toFolderID?: number | string) => string\n getSelectedItems?: () => FolderOrDocument[]\n isDragging: boolean\n itemKeysToMove?: Set<FolderDocumentItemKey>\n moveToFolder: (args: {\n itemsToMove: FolderOrDocument[]\n toFolderID?: number | string\n }) => Promise<void>\n onItemClick: (args: { event: React.MouseEvent; index: number; item: FolderOrDocument }) => void\n onItemKeyPress: (args: {\n event: React.KeyboardEvent\n index: number\n item: FolderOrDocument\n }) => void\n refineFolderData: (args: { query?: FolderQueryParams; updateURL: boolean }) => void\n search: string\n selectedFolderCollections?: CollectionSlug[]\n readonly selectedItemKeys: Set<FolderDocumentItemKey>\n setBreadcrumbs: React.Dispatch<React.SetStateAction<FolderBreadcrumb[]>>\n setFocusedRowIndex: React.Dispatch<React.SetStateAction<number>>\n setIsDragging: React.Dispatch<React.SetStateAction<boolean>>\n sort: FolderSortKeys\n subfolders?: FolderOrDocument[]\n}\n\nconst Context = React.createContext<FolderContextValue>({\n activeCollectionFolderSlugs: [],\n allCollectionFolderSlugs: [],\n allowCreateCollectionSlugs: [],\n breadcrumbs: [],\n checkIfItemIsDisabled: () => false,\n clearSelections: () => {},\n currentFolder: null,\n documents: [],\n dragOverlayItem: undefined,\n focusedRowIndex: -1,\n folderCollectionConfig: null,\n folderCollectionSlug: '',\n folderFieldName: 'folder',\n folderID: undefined,\n FolderResultsComponent: null,\n folderType: undefined,\n getFolderRoute: () => '',\n getSelectedItems: () => [],\n isDragging: false,\n itemKeysToMove: undefined,\n moveToFolder: () => Promise.resolve(undefined),\n onItemClick: () => undefined,\n onItemKeyPress: () => undefined,\n refineFolderData: () => undefined,\n search: '',\n selectedFolderCollections: undefined,\n selectedItemKeys: new Set<FolderDocumentItemKey>(),\n setBreadcrumbs: () => {},\n setFocusedRowIndex: () => -1,\n setIsDragging: () => false,\n sort: 'name',\n subfolders: [],\n})\n\nexport type FolderProviderProps = {\n /**\n * The collection slugs that are being viewed\n */\n readonly activeCollectionFolderSlugs?: CollectionSlug[]\n /**\n * Folder enabled collection slugs that can be populated within the provider\n */\n readonly allCollectionFolderSlugs: CollectionSlug[]\n /**\n * Array of slugs that can be created in the folder view\n */\n readonly allowCreateCollectionSlugs: CollectionSlug[]\n readonly allowMultiSelection?: boolean\n /**\n * The base folder route path\n *\n * @example\n * `/collections/:collectionSlug/:folderCollectionSlug`\n * or\n * `/browse-by-folder`\n */\n readonly baseFolderPath?: `/${string}`\n /**\n * Breadcrumbs for the current folder\n */\n readonly breadcrumbs?: FolderBreadcrumb[]\n /**\n * Children to render inside the provider\n */\n readonly children: React.ReactNode\n /**\n * All documents in the current folder\n */\n readonly documents: FolderOrDocument[]\n /**\n * The name of the field that contains the folder relation\n */\n readonly folderFieldName: string\n /**\n * The ID of the current folder\n */\n readonly folderID?: number | string\n /**\n * The component to render the folder results\n */\n readonly FolderResultsComponent: React.ReactNode\n /**\n * Optional function to call when an item is clicked\n */\n readonly onItemClick?: (itme: FolderOrDocument) => void\n /**\n * The intial search query\n */\n readonly search?: string\n /**\n * The sort order of the documents\n *\n * @example\n * `name` for descending\n * `-name` for ascending\n */\n readonly sort?: FolderSortKeys\n /**\n * All subfolders in the current folder\n */\n readonly subfolders: FolderOrDocument[]\n}\nexport function FolderProvider({\n activeCollectionFolderSlugs: activeCollectionSlugs,\n allCollectionFolderSlugs = [],\n allowCreateCollectionSlugs,\n allowMultiSelection = true,\n baseFolderPath,\n breadcrumbs: _breadcrumbsFromProps = [],\n children,\n documents,\n folderFieldName,\n folderID,\n FolderResultsComponent: InitialFolderResultsComponent,\n onItemClick: onItemClickFromProps,\n search,\n sort = 'name',\n subfolders,\n}: FolderProviderProps) {\n const parentFolderContext = useFolder()\n const { config } = useConfig()\n const { routes } = config\n const drawerDepth = useDrawerDepth()\n const { t } = useTranslation()\n const router = useRouter()\n const { startRouteTransition } = useRouteTransition()\n const locale = useLocale()\n const localeCode = locale ? locale.code : undefined\n\n const currentlySelectedIndexes = React.useRef(new Set<number>())\n\n const [selectedFolderCollections, setSelectedFolderCollections] = React.useState<\n CollectionSlug[]\n >([])\n const [FolderResultsComponent, setFolderResultsComponent] = React.useState(\n InitialFolderResultsComponent || (() => null),\n )\n const [folderCollectionConfig] = React.useState(() =>\n config.collections.find(\n (collection) => config.folders && collection.slug === config.folders.slug,\n ),\n )\n const folderCollectionSlug = folderCollectionConfig.slug\n\n const rawSearchParams = useSearchParams()\n const searchParams = React.useMemo(() => parseSearchParams(rawSearchParams), [rawSearchParams])\n const [currentQuery, setCurrentQuery] = React.useState<FolderQueryParams>(searchParams)\n\n const [isDragging, setIsDragging] = React.useState(false)\n const [selectedItemKeys, setSelectedItemKeys] = React.useState<Set<FolderDocumentItemKey>>(\n () => new Set(),\n )\n const [focusedRowIndex, setFocusedRowIndex] = React.useState(-1)\n // This is used to determine what data to display on the drag overlay\n const [dragOverlayItem, setDragOverlayItem] = React.useState<FolderOrDocument | undefined>()\n const [breadcrumbs, setBreadcrumbs] =\n React.useState<FolderContextValue['breadcrumbs']>(_breadcrumbsFromProps)\n const lastClickTime = React.useRef<null | number>(null)\n const totalCount = subfolders.length + documents.length\n\n const clearSelections = React.useCallback(() => {\n setFocusedRowIndex(-1)\n setSelectedItemKeys(new Set())\n setDragOverlayItem(undefined)\n currentlySelectedIndexes.current = new Set()\n }, [])\n\n const mergeQuery = React.useCallback(\n (newQuery: Partial<FolderQueryParams> = {}): Partial<FolderQueryParams> => {\n let page = 'page' in newQuery ? newQuery.page : currentQuery?.page\n\n if ('search' in newQuery) {\n page = '1'\n }\n\n const mergedQuery = {\n ...currentQuery,\n ...newQuery,\n locale: localeCode,\n page,\n relationTo: 'relationTo' in newQuery ? newQuery.relationTo : currentQuery?.relationTo,\n search: 'search' in newQuery ? newQuery.search : currentQuery?.search,\n sort: 'sort' in newQuery ? newQuery.sort : (currentQuery?.sort ?? undefined),\n }\n\n return mergedQuery\n },\n [currentQuery, localeCode],\n )\n\n const refineFolderData: FolderContextValue['refineFolderData'] = React.useCallback(\n ({ query, updateURL }) => {\n if (updateURL) {\n const queryParams = mergeQuery(query)\n\n startRouteTransition(() =>\n router.replace(\n `${qs.stringify({ ...queryParams, relationTo: JSON.stringify(queryParams.relationTo) }, { addQueryPrefix: true })}`,\n ),\n )\n\n setCurrentQuery(queryParams)\n }\n },\n [mergeQuery, router, startRouteTransition],\n )\n\n const getFolderRoute: FolderContextValue['getFolderRoute'] = React.useCallback(\n (toFolderID) => {\n const queryParams = qs.stringify(mergeQuery({ page: '1', search: '' }), {\n addQueryPrefix: true,\n })\n return formatAdminURL({\n adminRoute: config.routes.admin,\n path: `${baseFolderPath}${toFolderID ? `/${toFolderID}` : ''}${queryParams}`,\n })\n },\n [baseFolderPath, config.routes.admin, mergeQuery],\n )\n\n const getItem = React.useCallback(\n (itemKey: FolderDocumentItemKey) => {\n return [...subfolders, ...documents].find((doc) => doc.itemKey === itemKey)\n },\n [documents, subfolders],\n )\n\n const getSelectedItems = React.useCallback(() => {\n return Array.from(selectedItemKeys).reduce((acc, itemKey) => {\n const item = getItem(itemKey)\n if (item) {\n acc.push(item)\n }\n return acc\n }, [])\n }, [selectedItemKeys, getItem])\n\n const navigateAfterSelection = React.useCallback(\n ({ collectionSlug, docID }: { collectionSlug: string; docID?: number | string }) => {\n if (drawerDepth === 1) {\n // not in a drawer (default is 1)\n if (collectionSlug === folderCollectionSlug) {\n // clicked on folder, take the user to the folder view\n startRouteTransition(() => {\n router.push(getFolderRoute(docID))\n clearSelections()\n })\n } else if (collectionSlug) {\n // clicked on document, take the user to the documet view\n startRouteTransition(() => {\n router.push(\n formatAdminURL({\n adminRoute: config.routes.admin,\n path: `/collections/${collectionSlug}/${docID}`,\n }),\n )\n clearSelections()\n })\n }\n } else {\n clearSelections()\n }\n\n if (typeof onItemClickFromProps === 'function') {\n onItemClickFromProps(getItem(`${collectionSlug}-${docID}`))\n }\n },\n [\n clearSelections,\n config.routes.admin,\n drawerDepth,\n folderCollectionSlug,\n getFolderRoute,\n getItem,\n onItemClickFromProps,\n router,\n startRouteTransition,\n ],\n )\n\n const handleShiftSelection = React.useCallback(\n (targetIndex: number) => {\n const allItems = [...subfolders, ...documents]\n\n // Find existing selection boundaries\n const existingIndexes = allItems.reduce((acc, item, idx) => {\n if (selectedItemKeys.has(item.itemKey)) {\n acc.push(idx)\n }\n return acc\n }, [])\n\n if (existingIndexes.length === 0) {\n // No existing selection, just select target\n return [targetIndex]\n }\n\n const firstSelectedIndex = Math.min(...existingIndexes)\n const lastSelectedIndex = Math.max(...existingIndexes)\n const isWithinBounds = targetIndex >= firstSelectedIndex && targetIndex <= lastSelectedIndex\n\n // Choose anchor based on whether we're contracting or extending\n let anchorIndex = targetIndex\n if (isWithinBounds) {\n // Contracting: if target is at a boundary, use target as anchor\n // Otherwise, use furthest boundary to maintain opposite edge\n if (targetIndex === firstSelectedIndex || targetIndex === lastSelectedIndex) {\n anchorIndex = targetIndex\n } else {\n const distanceToFirst = Math.abs(targetIndex - firstSelectedIndex)\n const distanceToLast = Math.abs(targetIndex - lastSelectedIndex)\n anchorIndex = distanceToFirst >= distanceToLast ? firstSelectedIndex : lastSelectedIndex\n }\n } else {\n // Extending: use closest boundary\n const distanceToFirst = Math.abs(targetIndex - firstSelectedIndex)\n const distanceToLast = Math.abs(targetIndex - lastSelectedIndex)\n anchorIndex = distanceToFirst <= distanceToLast ? firstSelectedIndex : lastSelectedIndex\n }\n\n // Create range from anchor to target\n const startIndex = Math.min(anchorIndex, targetIndex)\n const endIndex = Math.max(anchorIndex, targetIndex)\n const newRangeIndexes = Array.from(\n { length: endIndex - startIndex + 1 },\n (_, i) => startIndex + i,\n )\n\n if (isWithinBounds) {\n // Contracting: replace with new range\n return newRangeIndexes\n } else {\n // Extending: union with existing\n return [...new Set([...existingIndexes, ...newRangeIndexes])]\n }\n },\n [subfolders, documents, selectedItemKeys],\n )\n\n const updateSelections = React.useCallback(\n ({ indexes }: { indexes: number[] }) => {\n const allItems = [...subfolders, ...documents]\n const { newSelectedFolderCollections, newSelectedItemKeys } = allItems.reduce(\n (acc, item, index) => {\n if (indexes.includes(index)) {\n acc.newSelectedItemKeys.add(item.itemKey)\n if (item.relationTo === folderCollectionSlug) {\n item.value.folderType?.forEach((collectionSlug) => {\n if (!acc.newSelectedFolderCollections.includes(collectionSlug)) {\n acc.newSelectedFolderCollections.push(collectionSlug)\n }\n })\n } else {\n if (!acc.newSelectedFolderCollections.includes(item.relationTo)) {\n acc.newSelectedFolderCollections.push(item.relationTo)\n }\n }\n }\n return acc\n },\n {\n newSelectedFolderCollections: [] satisfies CollectionSlug[],\n newSelectedItemKeys: new Set<FolderDocumentItemKey>(),\n },\n )\n\n setSelectedFolderCollections(newSelectedFolderCollections)\n setSelectedItemKeys(newSelectedItemKeys)\n },\n [documents, folderCollectionSlug, subfolders],\n )\n\n const onItemKeyPress: FolderContextValue['onItemKeyPress'] = React.useCallback(\n ({ event, item: currentItem }) => {\n const { code, ctrlKey, metaKey, shiftKey } = event\n const isShiftPressed = shiftKey\n const isCtrlPressed = ctrlKey || metaKey\n const isCurrentlySelected = selectedItemKeys.has(currentItem.itemKey)\n const allItems = [...subfolders, ...documents]\n const currentItemIndex = allItems.findIndex((item) => item.itemKey === currentItem.itemKey)\n\n switch (code) {\n case 'ArrowDown':\n case 'ArrowLeft':\n case 'ArrowRight':\n case 'ArrowUp': {\n event.preventDefault()\n\n if (currentItemIndex === -1) {\n break\n }\n\n const isBackward = code === 'ArrowLeft' || code === 'ArrowUp'\n const newItemIndex = isBackward ? currentItemIndex - 1 : currentItemIndex + 1\n\n if (newItemIndex < 0 || newItemIndex > totalCount - 1) {\n // out of bounds, keep current selection\n return\n }\n\n setFocusedRowIndex(newItemIndex)\n\n if (isCtrlPressed) {\n break\n }\n\n if (isShiftPressed && allowMultiSelection) {\n const selectedIndexes = handleShiftSelection(newItemIndex)\n updateSelections({ indexes: selectedIndexes })\n return\n }\n\n // Single selection without shift\n if (!isShiftPressed) {\n const newItem = allItems[newItemIndex]\n setSelectedItemKeys(new Set([newItem.itemKey]))\n }\n\n break\n }\n case 'Enter': {\n if (selectedItemKeys.size === 1) {\n setFocusedRowIndex(undefined)\n navigateAfterSelection({\n collectionSlug: currentItem.relationTo,\n docID: extractID(currentItem.value),\n })\n return\n }\n break\n }\n case 'Escape': {\n clearSelections()\n break\n }\n case 'KeyA': {\n if (allowMultiSelection && isCtrlPressed) {\n event.preventDefault()\n setFocusedRowIndex(totalCount - 1)\n updateSelections({\n indexes: Array.from({ length: totalCount }, (_, i) => i),\n })\n }\n break\n }\n case 'Space': {\n if (allowMultiSelection && isShiftPressed) {\n event.preventDefault()\n const allItems = [...subfolders, ...documents]\n updateSelections({\n indexes: allItems.reduce((acc, item, idx) => {\n if (item.itemKey === currentItem.itemKey) {\n if (isCurrentlySelected) {\n return acc\n } else {\n acc.push(idx)\n }\n } else if (selectedItemKeys.has(item.itemKey)) {\n acc.push(idx)\n }\n return acc\n }, []),\n })\n } else {\n event.preventDefault()\n updateSelections({\n indexes: isCurrentlySelected ? [] : [currentItemIndex],\n })\n }\n break\n }\n case 'Tab': {\n if (allowMultiSelection && isShiftPressed) {\n const prevIndex = currentItemIndex - 1\n if (prevIndex < 0 && selectedItemKeys?.size > 0) {\n setFocusedRowIndex(prevIndex)\n }\n } else {\n const nextIndex = currentItemIndex + 1\n if (nextIndex === totalCount && selectedItemKeys.size > 0) {\n setFocusedRowIndex(totalCount - 1)\n }\n }\n break\n }\n }\n },\n [\n selectedItemKeys,\n subfolders,\n documents,\n allowMultiSelection,\n handleShiftSelection,\n updateSelections,\n navigateAfterSelection,\n clearSelections,\n totalCount,\n ],\n )\n\n const onItemClick: FolderContextValue['onItemClick'] = React.useCallback(\n ({ event, item: clickedItem }) => {\n let doubleClicked: boolean = false\n const isCtrlPressed = event.ctrlKey || event.metaKey\n const isShiftPressed = event.shiftKey\n const isCurrentlySelected = selectedItemKeys.has(clickedItem.itemKey)\n const allItems = [...subfolders, ...documents]\n const currentItemIndex = allItems.findIndex((item) => item.itemKey === clickedItem.itemKey)\n\n if (allowMultiSelection && isCtrlPressed) {\n event.preventDefault()\n let overlayItemKey: FolderDocumentItemKey | undefined\n const indexes = allItems.reduce((acc, item, idx) => {\n if (item.itemKey === clickedItem.itemKey) {\n if (isCurrentlySelected && event.type !== 'pointermove') {\n return acc\n } else {\n acc.push(idx)\n overlayItemKey = item.itemKey\n }\n } else if (selectedItemKeys.has(item.itemKey)) {\n acc.push(idx)\n }\n return acc\n }, [])\n\n updateSelections({ indexes })\n\n if (overlayItemKey) {\n setDragOverlayItem(getItem(overlayItemKey))\n }\n } else if (allowMultiSelection && isShiftPressed) {\n if (currentItemIndex !== -1) {\n const selectedIndexes = handleShiftSelection(currentItemIndex)\n updateSelections({ indexes: selectedIndexes })\n }\n } else if (allowMultiSelection && event.type === 'pointermove') {\n // on drag start of an unselected item\n if (!isCurrentlySelected) {\n updateSelections({\n indexes: allItems.reduce((acc, item, idx) => {\n if (item.itemKey === clickedItem.itemKey) {\n acc.push(idx)\n }\n return acc\n }, []),\n })\n }\n setDragOverlayItem(getItem(clickedItem.itemKey))\n } else {\n // Normal click - select single item\n const now = Date.now()\n doubleClicked =\n now - lastClickTime.current < 400 && dragOverlayItem?.itemKey === clickedItem.itemKey\n lastClickTime.current = now\n if (!doubleClicked) {\n updateSelections({\n indexes: isCurrentlySelected && selectedItemKeys.size === 1 ? [] : [currentItemIndex],\n })\n }\n setDragOverlayItem(getItem(clickedItem.itemKey))\n }\n\n if (doubleClicked) {\n navigateAfterSelection({\n collectionSlug: clickedItem.relationTo,\n docID: extractID(clickedItem.value),\n })\n }\n },\n [\n selectedItemKeys,\n subfolders,\n documents,\n allowMultiSelection,\n dragOverlayItem,\n getItem,\n updateSelections,\n navigateAfterSelection,\n handleShiftSelection,\n ],\n )\n\n /**\n * Makes requests to the server to update the folder field on passed in documents\n *\n * Might rewrite this in the future to return the promises so errors can be handled contextually\n */\n const moveToFolder: FolderContextValue['moveToFolder'] = React.useCallback(\n async (args) => {\n const { itemsToMove: items, toFolderID } = args\n if (!items.length) {\n return\n }\n\n const movingCurrentFolder =\n items.length === 1 &&\n items[0].relationTo === folderCollectionSlug &&\n items[0].value.id === folderID\n\n if (movingCurrentFolder) {\n const queryParams = qs.stringify(\n {\n depth: 0,\n locale: localeCode,\n },\n {\n addQueryPrefix: true,\n },\n )\n const req = await fetch(\n formatAdminURL({\n apiRoute: routes.api,\n path: `/${folderCollectionSlug}/${folderID}${queryParams}`,\n }),\n {\n body: JSON.stringify({ [folderFieldName]: toFolderID || null }),\n credentials: 'include',\n headers: {\n 'content-type': 'application/json',\n },\n method: 'PATCH',\n },\n )\n if (req.status !== 200) {\n toast.error(t('general:error'))\n }\n } else {\n for (const [collectionSlug, ids] of Object.entries(groupItemIDsByRelation(items))) {\n const queryParams = qs.stringify(\n {\n depth: 0,\n limit: 0,\n locale: localeCode,\n where: {\n id: {\n in: ids,\n },\n },\n },\n {\n addQueryPrefix: true,\n },\n )\n try {\n await fetch(\n formatAdminURL({\n apiRoute: routes.api,\n path: `/${collectionSlug}${queryParams}`,\n }),\n {\n body: JSON.stringify({ [folderFieldName]: toFolderID || null }),\n credentials: 'include',\n headers: {\n 'content-type': 'application/json',\n },\n method: 'PATCH',\n },\n )\n } catch (error) {\n toast.error(t('general:error'))\n // eslint-disable-next-line no-console\n console.error(error)\n continue\n }\n }\n }\n\n clearSelections()\n },\n [folderID, clearSelections, folderCollectionSlug, folderFieldName, routes.api, t, localeCode],\n )\n\n const checkIfItemIsDisabled: FolderContextValue['checkIfItemIsDisabled'] = React.useCallback(\n (item) => {\n function folderAcceptsItem({\n item,\n selectedFolderCollections,\n }: {\n item: FolderOrDocument\n selectedFolderCollections: string[]\n }): boolean {\n if (\n !item.value.folderType ||\n (Array.isArray(item.value.folderType) && item.value.folderType.length === 0)\n ) {\n // Enable folder that accept all collections\n return false\n }\n\n if (selectedFolderCollections.length === 0) {\n // If no collections are selected, enable folders that accept all collections\n return Boolean(item.value.folderType || item.value.folderType.length > 0)\n }\n\n // Disable folders that do not accept all of the selected collections\n return selectedFolderCollections.some((slug) => {\n return !item.value.folderType.includes(slug)\n })\n }\n\n if (isDragging) {\n const isSelected = selectedItemKeys.has(item.itemKey)\n if (isSelected) {\n return true\n } else if (item.relationTo === folderCollectionSlug) {\n return folderAcceptsItem({ item, selectedFolderCollections })\n } else {\n // Non folder items are disabled on drag\n return true\n }\n } else if (parentFolderContext?.selectedItemKeys?.size) {\n // Disable selected items from being navigated to in move to drawer\n if (parentFolderContext.selectedItemKeys.has(item.itemKey)) {\n return true\n }\n // Moving items to folder\n if (item.relationTo === folderCollectionSlug) {\n return folderAcceptsItem({\n item,\n selectedFolderCollections: parentFolderContext.selectedFolderCollections,\n })\n }\n // If the item is not a folder, it is disabled on move\n return true\n }\n },\n [\n selectedFolderCollections,\n isDragging,\n selectedItemKeys,\n folderCollectionSlug,\n parentFolderContext?.selectedFolderCollections,\n parentFolderContext?.selectedItemKeys,\n ],\n )\n\n // If a new component is provided, update the state so children can re-render with the new component\n React.useEffect(() => {\n if (InitialFolderResultsComponent) {\n setFolderResultsComponent(InitialFolderResultsComponent)\n }\n }, [InitialFolderResultsComponent])\n\n return (\n <Context\n value={{\n activeCollectionFolderSlugs: activeCollectionSlugs || allCollectionFolderSlugs,\n allCollectionFolderSlugs,\n allowCreateCollectionSlugs,\n breadcrumbs,\n checkIfItemIsDisabled,\n clearSelections,\n currentFolder:\n breadcrumbs?.[breadcrumbs.length - 1]?.id !== undefined\n ? formatFolderOrDocumentItem({\n folderFieldName,\n isUpload: false,\n relationTo: folderCollectionSlug,\n useAsTitle: folderCollectionConfig.admin.useAsTitle,\n value: breadcrumbs[breadcrumbs.length - 1],\n })\n : null,\n documents,\n dragOverlayItem,\n focusedRowIndex,\n folderCollectionConfig,\n folderCollectionSlug,\n folderFieldName,\n folderID,\n FolderResultsComponent,\n folderType: breadcrumbs?.[breadcrumbs.length - 1]?.folderType,\n getFolderRoute,\n getSelectedItems,\n isDragging,\n itemKeysToMove: parentFolderContext.selectedItemKeys,\n moveToFolder,\n onItemClick,\n onItemKeyPress,\n refineFolderData,\n search,\n selectedFolderCollections,\n selectedItemKeys,\n setBreadcrumbs,\n setFocusedRowIndex,\n setIsDragging,\n sort,\n subfolders,\n }}\n >\n {children}\n </Context>\n )\n}\n\nexport function useFolder(): FolderContextValue {\n const context = React.use(Context)\n\n if (context === undefined) {\n throw new Error('useFolder must be used within a FolderProvider')\n }\n\n return context\n}\n"],"mappings":"AAAA;;;AAKA,SAASA,SAAS,EAAEC,eAAe,QAAQ;AAC3C,SAASC,SAAS,EAAEC,cAAc,EAAEC,0BAA0B,QAAQ;AACtE,YAAYC,EAAA,MAAQ;AACpB,OAAOC,KAAA,MAAW;AAClB,SAASC,KAAK,QAAQ;AAEtB,SAASC,cAAc,QAAQ;AAC/B,SAASC,iBAAiB,QAAQ;AAClC,SAASC,SAAS,QAAQ;AAC1B,SAASC,SAAS,QAAQ;AAC1B,SAASC,kBAAkB,QAAQ;AACnC,SAASC,cAAc,QAAQ;AAC/B,SAASC,sBAAsB,QAAQ;AAkEvC,MAAMC,OAAA,gBAAUT,KAAA,CAAMU,aAAa,CAAqB;EACtDC,2BAAA,EAA6B,EAAE;EAC/BC,wBAAA,EAA0B,EAAE;EAC5BC,0BAAA,EAA4B,EAAE;EAC9BC,WAAA,EAAa,EAAE;EACfC,qBAAA,EAAuBA,CAAA,KAAM;EAC7BC,eAAA,EAAiBA,CAAA,MAAO;EACxBC,aAAA,EAAe;EACfC,SAAA,EAA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