@payloadcms/ui 3.57.0-internal.f26caed → 3.57.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.
- package/dist/elements/BulkUpload/FileSidebar/index.d.ts.map +1 -1
- package/dist/elements/BulkUpload/FileSidebar/index.js +74 -38
- package/dist/elements/BulkUpload/FileSidebar/index.js.map +1 -1
- package/dist/elements/BulkUpload/FileSidebar/index.scss +14 -1
- package/dist/elements/BulkUpload/FormsManager/index.d.ts +6 -1
- package/dist/elements/BulkUpload/FormsManager/index.d.ts.map +1 -1
- package/dist/elements/BulkUpload/FormsManager/index.js +52 -14
- package/dist/elements/BulkUpload/FormsManager/index.js.map +1 -1
- package/dist/elements/BulkUpload/FormsManager/reducer.d.ts +2 -2
- package/dist/elements/BulkUpload/FormsManager/reducer.d.ts.map +1 -1
- package/dist/elements/BulkUpload/FormsManager/reducer.js +5 -5
- package/dist/elements/BulkUpload/FormsManager/reducer.js.map +1 -1
- package/dist/elements/BulkUpload/index.d.ts +30 -5
- package/dist/elements/BulkUpload/index.d.ts.map +1 -1
- package/dist/elements/BulkUpload/index.js +130 -28
- package/dist/elements/BulkUpload/index.js.map +1 -1
- package/dist/elements/ConfirmationModal/index.d.ts.map +1 -1
- package/dist/elements/ConfirmationModal/index.js +1 -0
- package/dist/elements/ConfirmationModal/index.js.map +1 -1
- package/dist/elements/DocumentLocked/index.d.ts.map +1 -1
- package/dist/elements/DocumentLocked/index.js +41 -33
- package/dist/elements/DocumentLocked/index.js.map +1 -1
- package/dist/elements/DocumentTakeOver/index.d.ts.map +1 -1
- package/dist/elements/DocumentTakeOver/index.js +27 -19
- package/dist/elements/DocumentTakeOver/index.js.map +1 -1
- package/dist/elements/Drawer/index.d.ts.map +1 -1
- package/dist/elements/Drawer/index.js +1 -0
- package/dist/elements/Drawer/index.js.map +1 -1
- package/dist/elements/FullscreenModal/index.d.ts.map +1 -1
- package/dist/elements/FullscreenModal/index.js +1 -0
- package/dist/elements/FullscreenModal/index.js.map +1 -1
- package/dist/elements/LivePreview/IFrame/index.d.ts +1 -7
- package/dist/elements/LivePreview/IFrame/index.d.ts.map +1 -1
- package/dist/elements/LivePreview/IFrame/index.js +39 -18
- package/dist/elements/LivePreview/IFrame/index.js.map +1 -1
- package/dist/elements/LivePreview/Window/index.d.ts.map +1 -1
- package/dist/elements/LivePreview/Window/index.js +135 -61
- package/dist/elements/LivePreview/Window/index.js.map +1 -1
- package/dist/elements/PublishButton/index.js +1 -1
- package/dist/elements/PublishButton/index.js.map +1 -1
- package/dist/elements/SearchBar/index.scss +4 -0
- package/dist/elements/Status/index.d.ts.map +1 -1
- package/dist/elements/Status/index.js +9 -19
- package/dist/elements/Status/index.js.map +1 -1
- package/dist/elements/Table/DefaultCell/index.d.ts.map +1 -1
- package/dist/elements/Table/DefaultCell/index.js +20 -14
- package/dist/elements/Table/DefaultCell/index.js.map +1 -1
- package/dist/elements/Thumbnail/index.d.ts +4 -2
- package/dist/elements/Thumbnail/index.d.ts.map +1 -1
- package/dist/elements/Thumbnail/index.js +6 -2
- package/dist/elements/Thumbnail/index.js.map +1 -1
- package/dist/elements/Thumbnail/index.scss +11 -9
- package/dist/elements/Toasts/fieldErrors.js +1 -1
- package/dist/elements/Toasts/fieldErrors.js.map +1 -1
- package/dist/exports/client/index.js +24 -24
- package/dist/exports/client/index.js.map +4 -4
- package/dist/exports/rsc/index.d.ts +1 -0
- package/dist/exports/rsc/index.d.ts.map +1 -1
- package/dist/exports/rsc/index.js +1 -0
- package/dist/exports/rsc/index.js.map +1 -1
- package/dist/exports/shared/index.js +2 -2
- package/dist/exports/shared/index.js.map +3 -3
- package/dist/fields/Blocks/index.d.ts.map +1 -1
- package/dist/fields/Blocks/index.js +36 -16
- package/dist/fields/Blocks/index.js.map +1 -1
- package/dist/fields/Relationship/Input.d.ts.map +1 -1
- package/dist/fields/Relationship/Input.js +1 -5
- package/dist/fields/Relationship/Input.js.map +1 -1
- package/dist/fields/Upload/Input.js +20 -20
- package/dist/fields/Upload/Input.js.map +1 -1
- package/dist/forms/Form/index.js +1 -2
- package/dist/forms/Form/index.js.map +1 -1
- package/dist/forms/Form/mergeServerFormState.d.ts.map +1 -1
- package/dist/forms/Form/mergeServerFormState.js +8 -0
- package/dist/forms/Form/mergeServerFormState.js.map +1 -1
- package/dist/forms/Form/types.d.ts +2 -2
- package/dist/forms/Form/types.d.ts.map +1 -1
- package/dist/forms/Form/types.js.map +1 -1
- package/dist/forms/RenderFields/RenderField.js +223 -236
- package/dist/forms/RenderFields/RenderField.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.js +33 -2
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/renderField.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/renderField.js +2 -1
- package/dist/forms/fieldSchemasToFormState/renderField.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/serverFunctions/renderFieldServerFn.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/serverFunctions/renderFieldServerFn.js +2 -0
- package/dist/forms/fieldSchemasToFormState/serverFunctions/renderFieldServerFn.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/types.d.ts +6 -0
- package/dist/forms/fieldSchemasToFormState/types.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/types.js.map +1 -1
- package/dist/forms/useField/index.d.ts.map +1 -1
- package/dist/forms/useField/index.js +76 -73
- package/dist/forms/useField/index.js.map +1 -1
- package/dist/forms/useField/types.d.ts +5 -9
- package/dist/forms/useField/types.d.ts.map +1 -1
- package/dist/forms/useField/types.js.map +1 -1
- package/dist/providers/LivePreview/context.d.ts +17 -2
- package/dist/providers/LivePreview/context.d.ts.map +1 -1
- package/dist/providers/LivePreview/context.js +3 -2
- package/dist/providers/LivePreview/context.js.map +1 -1
- package/dist/providers/LivePreview/index.d.ts +2 -2
- package/dist/providers/LivePreview/index.d.ts.map +1 -1
- package/dist/providers/LivePreview/index.js +33 -19
- package/dist/providers/LivePreview/index.js.map +1 -1
- package/dist/providers/RouteCache/index.d.ts.map +1 -1
- package/dist/providers/RouteCache/index.js +62 -25
- package/dist/providers/RouteCache/index.js.map +1 -1
- package/dist/providers/TableColumns/buildColumnState/index.d.ts +2 -1
- package/dist/providers/TableColumns/buildColumnState/index.d.ts.map +1 -1
- package/dist/providers/TableColumns/buildColumnState/index.js +2 -0
- package/dist/providers/TableColumns/buildColumnState/index.js.map +1 -1
- package/dist/providers/TableColumns/buildColumnState/renderCell.d.ts +3 -2
- package/dist/providers/TableColumns/buildColumnState/renderCell.d.ts.map +1 -1
- package/dist/providers/TableColumns/buildColumnState/renderCell.js +39 -2
- package/dist/providers/TableColumns/buildColumnState/renderCell.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/utilities/buildFormState.d.ts +2 -0
- package/dist/utilities/buildFormState.d.ts.map +1 -1
- package/dist/utilities/buildFormState.js +20 -1
- package/dist/utilities/buildFormState.js.map +1 -1
- package/dist/utilities/formatAbsoluteURL.d.ts +8 -0
- package/dist/utilities/formatAbsoluteURL.d.ts.map +1 -0
- package/dist/utilities/formatAbsoluteURL.js +15 -0
- package/dist/utilities/formatAbsoluteURL.js.map +1 -0
- package/dist/utilities/getFolderResultsComponentAndData.d.ts.map +1 -1
- package/dist/utilities/getFolderResultsComponentAndData.js +0 -4
- package/dist/utilities/getFolderResultsComponentAndData.js.map +1 -1
- package/dist/utilities/handleLivePreview.d.ts +58 -0
- package/dist/utilities/handleLivePreview.d.ts.map +1 -0
- package/dist/utilities/handleLivePreview.js +96 -0
- package/dist/utilities/handleLivePreview.js.map +1 -0
- package/dist/utilities/handleTakeOver.d.ts +17 -4
- package/dist/utilities/handleTakeOver.d.ts.map +1 -1
- package/dist/utilities/handleTakeOver.js +18 -2
- package/dist/utilities/handleTakeOver.js.map +1 -1
- package/dist/utilities/renderTable.d.ts +3 -2
- package/dist/utilities/renderTable.d.ts.map +1 -1
- package/dist/utilities/renderTable.js +2 -0
- package/dist/utilities/renderTable.js.map +1 -1
- package/dist/views/Edit/index.d.ts.map +1 -1
- package/dist/views/Edit/index.js +48 -13
- package/dist/views/Edit/index.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["DndContext","React","useCallback","useEffect","useMemo","useRef","useState","usePopupWindow","useDocumentInfo","usePreferences","customCollisionDetection","LivePreviewContext","sizeReducer","getAbsoluteUrl","url","URL","window","location","origin","href","LivePreviewProvider","breakpoints","incomingBreakpoints","children","isLivePreviewEnabled","isLivePreviewing","incomingIsLivePreviewing","incomingUrl","previewWindowType","setPreviewWindowType","setIsLivePreviewing","name","height","label","width","setURL","startsWith","isPopupOpen","openPopupWindow","popupRef","eventType","appIsReady","setAppIsReady","listeningForMessages","setListeningForMessages","collectionSlug","globalSlug","isFirstRender","setPreference","iframeRef","iframeHasLoaded","setIframeHasLoaded","zoom","setZoom","position","setPosition","x","y","size","setSize","useReducer","measuredDeviceSize","setMeasuredDeviceSize","breakpoint","setBreakpoint","handleDragEnd","ev","over","id","newPos","delta","setWidth","type","value","setHeight","foundBreakpoint","find","bp","handleMessage","event","data","ready","addEventListener","removeEventListener","handleWindowChange","newPreviewWindowType","current","editViewType","_jsx","setToolbarPosition","toolbarPosition","collisionDetection","onDragEnd"],"sources":["../../../src/providers/LivePreview/index.tsx"],"sourcesContent":["'use client'\nimport type { CollectionPreferences, LivePreviewConfig } from 'payload'\n\nimport { DndContext } from '@dnd-kit/core'\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'\n\nimport { usePopupWindow } from '../../hooks/usePopupWindow.js'\nimport { useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { usePreferences } from '../../providers/Preferences/index.js'\nimport { customCollisionDetection } from './collisionDetection.js'\nimport { LivePreviewContext } from './context.js'\nimport { sizeReducer } from './sizeReducer.js'\n\nexport type LivePreviewProviderProps = {\n appIsReady?: boolean\n breakpoints?: LivePreviewConfig['breakpoints']\n children: React.ReactNode\n deviceSize?: {\n height: number\n width: number\n }\n isLivePreviewEnabled?: boolean\n isLivePreviewing: boolean\n url: string\n}\n\nconst getAbsoluteUrl = (url) => {\n try {\n return new URL(url, window.location.origin).href\n } catch {\n return url\n }\n}\n\nexport const LivePreviewProvider: React.FC<LivePreviewProviderProps> = ({\n breakpoints: incomingBreakpoints,\n children,\n isLivePreviewEnabled,\n isLivePreviewing: incomingIsLivePreviewing,\n url: incomingUrl,\n}) => {\n const [previewWindowType, setPreviewWindowType] = useState<'iframe' | 'popup'>('iframe')\n const [isLivePreviewing, setIsLivePreviewing] = useState(incomingIsLivePreviewing)\n\n const breakpoints: LivePreviewConfig['breakpoints'] = useMemo(\n () => [\n ...(incomingBreakpoints || []),\n {\n name: 'responsive',\n height: '100%',\n label: 'Responsive',\n width: '100%',\n },\n ],\n [incomingBreakpoints],\n )\n\n const [url, setURL] = useState<string>('')\n\n // This needs to be done in a useEffect to prevent hydration issues\n // as the URL may not be absolute when passed in as a prop,\n // and getAbsoluteUrl requires the window object to be available\n useEffect(\n () =>\n setURL(\n incomingUrl?.startsWith('http://') || incomingUrl?.startsWith('https://')\n ? incomingUrl\n : getAbsoluteUrl(incomingUrl),\n ),\n [incomingUrl],\n )\n\n const { isPopupOpen, openPopupWindow, popupRef } = usePopupWindow({\n eventType: 'payload-live-preview',\n url,\n })\n\n const [appIsReady, setAppIsReady] = useState(false)\n const [listeningForMessages, setListeningForMessages] = useState(false)\n\n const { collectionSlug, globalSlug } = useDocumentInfo()\n\n const isFirstRender = useRef(true)\n\n const { setPreference } = usePreferences()\n\n const iframeRef = React.useRef<HTMLIFrameElement>(null)\n\n const [iframeHasLoaded, setIframeHasLoaded] = useState(false)\n\n const [zoom, setZoom] = useState(1)\n\n const [position, setPosition] = useState({ x: 0, y: 0 })\n\n const [size, setSize] = React.useReducer(sizeReducer, { height: 0, width: 0 })\n\n const [measuredDeviceSize, setMeasuredDeviceSize] = useState({\n height: 0,\n width: 0,\n })\n\n const [breakpoint, setBreakpoint] =\n React.useState<LivePreviewConfig['breakpoints'][0]['name']>('responsive')\n\n // The toolbar needs to freely drag and drop around the page\n const handleDragEnd = (ev) => {\n // only update position if the toolbar is completely within the preview area\n // otherwise reset it back to the previous position\n // TODO: reset to the nearest edge of the preview area\n if (ev.over && ev.over.id === 'live-preview-area') {\n const newPos = {\n x: position.x + ev.delta.x,\n y: position.y + ev.delta.y,\n }\n\n setPosition(newPos)\n } else {\n // reset\n }\n }\n\n const setWidth = useCallback(\n (width) => {\n setSize({ type: 'width', value: width })\n },\n [setSize],\n )\n\n const setHeight = useCallback(\n (height) => {\n setSize({ type: 'height', value: height })\n },\n [setSize],\n )\n\n // explicitly set new width and height when as new breakpoints are selected\n // exclude `custom` breakpoint as it is handled by the `setWidth` and `setHeight` directly\n useEffect(() => {\n const foundBreakpoint = breakpoints?.find((bp) => bp.name === breakpoint)\n\n if (\n foundBreakpoint &&\n breakpoint !== 'responsive' &&\n breakpoint !== 'custom' &&\n typeof foundBreakpoint?.width === 'number' &&\n typeof foundBreakpoint?.height === 'number'\n ) {\n setSize({\n type: 'reset',\n value: {\n height: foundBreakpoint.height,\n width: foundBreakpoint.width,\n },\n })\n }\n }, [breakpoint, breakpoints])\n\n // Receive the `ready` message from the popup window\n // This indicates that the app is ready to receive `window.postMessage` events\n // This is also the only cross-origin way of detecting when a popup window has loaded\n // Unlike iframe elements which have an `onLoad` handler, there is no way to access `window.open` on popups\n useEffect(() => {\n const handleMessage = (event: MessageEvent) => {\n if (\n url?.startsWith(event.origin) &&\n event.data &&\n typeof event.data === 'object' &&\n event.data.type === 'payload-live-preview'\n ) {\n if (event.data.ready) {\n setAppIsReady(true)\n }\n }\n }\n\n window.addEventListener('message', handleMessage)\n\n setListeningForMessages(true)\n\n return () => {\n window.removeEventListener('message', handleMessage)\n }\n }, [url, listeningForMessages])\n\n const handleWindowChange = useCallback(\n (type: 'iframe' | 'popup') => {\n setAppIsReady(false)\n setPreviewWindowType(type)\n if (type === 'popup') {\n openPopupWindow()\n }\n },\n [openPopupWindow],\n )\n\n // when the user closes the popup window, switch back to the iframe\n // the `usePopupWindow` reports the `isPopupOpen` state for us to use here\n useEffect(() => {\n const newPreviewWindowType = isPopupOpen ? 'popup' : 'iframe'\n\n if (newPreviewWindowType !== previewWindowType) {\n handleWindowChange('iframe')\n }\n }, [previewWindowType, isPopupOpen, handleWindowChange])\n\n useEffect(() => {\n if (isFirstRender.current) {\n isFirstRender.current = false\n return\n }\n\n void setPreference<CollectionPreferences>(\n collectionSlug ? `collection-${collectionSlug}` : `global-${globalSlug}`,\n {\n editViewType: isLivePreviewing ? 'live-preview' : 'default',\n },\n true,\n )\n }, [isLivePreviewing, setPreference, collectionSlug, globalSlug])\n\n return (\n <LivePreviewContext\n value={{\n appIsReady,\n breakpoint,\n breakpoints,\n iframeHasLoaded,\n iframeRef,\n isLivePreviewEnabled,\n isLivePreviewing,\n isPopupOpen,\n listeningForMessages,\n measuredDeviceSize,\n openPopupWindow,\n popupRef,\n previewWindowType,\n setAppIsReady,\n setBreakpoint,\n setHeight,\n setIframeHasLoaded,\n setIsLivePreviewing,\n setMeasuredDeviceSize,\n setPreviewWindowType: handleWindowChange,\n setSize,\n setToolbarPosition: setPosition,\n setWidth,\n setZoom,\n size,\n toolbarPosition: position,\n url,\n zoom,\n }}\n >\n <DndContext collisionDetection={customCollisionDetection} onDragEnd={handleDragEnd}>\n {children}\n </DndContext>\n </LivePreviewContext>\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,UAAU,QAAQ;AAC3B,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAEzE,SAASC,cAAc,QAAQ;AAC/B,SAASC,eAAe,QAAQ;AAChC,SAASC,cAAc,QAAQ;AAC/B,SAASC,wBAAwB,QAAQ;AACzC,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AACxF,UAAA;MAAW2F,kBAAA,EAAoBjF,wBAAA;MAA0BkF,SAAA,EAAW3B,aAAA;gBAClE1C;;;AAIT","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["DndContext","React","useCallback","useEffect","useMemo","useRef","useState","usePopupWindow","useDocumentInfo","usePreferences","formatAbsoluteURL","customCollisionDetection","LivePreviewContext","sizeReducer","LivePreviewProvider","breakpoints","incomingBreakpoints","children","isLivePreviewEnabled","isLivePreviewing","incomingIsLivePreviewing","typeofLivePreviewURL","url","urlFromProps","previewWindowType","setPreviewWindowType","setIsLivePreviewing","name","height","label","width","setURL","isPopupOpen","openPopupWindow","popupRef","eventType","appIsReady","setAppIsReady","listeningForMessages","setListeningForMessages","collectionSlug","globalSlug","isFirstRender","setPreference","iframeRef","loadedURL","setLoadedURL","zoom","setZoom","position","setPosition","x","y","size","setSize","useReducer","measuredDeviceSize","setMeasuredDeviceSize","breakpoint","setBreakpoint","setLivePreviewURL","_incomingURL","incomingURL","handleDragEnd","ev","over","id","newPos","delta","setWidth","type","value","setHeight","foundBreakpoint","find","bp","handleMessage","event","startsWith","origin","data","ready","window","addEventListener","removeEventListener","handleWindowChange","newPreviewWindowType","current","editViewType","_jsx","setToolbarPosition","toolbarPosition","collisionDetection","onDragEnd"],"sources":["../../../src/providers/LivePreview/index.tsx"],"sourcesContent":["'use client'\nimport type { CollectionPreferences, LivePreviewConfig } from 'payload'\n\nimport { DndContext } from '@dnd-kit/core'\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'\n\nimport type { LivePreviewContextType } from './context.js'\n\nimport { usePopupWindow } from '../../hooks/usePopupWindow.js'\nimport { useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { usePreferences } from '../../providers/Preferences/index.js'\nimport { formatAbsoluteURL } from '../../utilities/formatAbsoluteURL.js'\nimport { customCollisionDetection } from './collisionDetection.js'\nimport { LivePreviewContext } from './context.js'\nimport { sizeReducer } from './sizeReducer.js'\n\nexport type LivePreviewProviderProps = {\n appIsReady?: boolean\n breakpoints?: LivePreviewConfig['breakpoints']\n children: React.ReactNode\n deviceSize?: {\n height: number\n width: number\n }\n isLivePreviewEnabled?: boolean\n isLivePreviewing: boolean\n} & Pick<LivePreviewContextType, 'typeofLivePreviewURL' | 'url'>\n\nexport const LivePreviewProvider: React.FC<LivePreviewProviderProps> = ({\n breakpoints: incomingBreakpoints,\n children,\n isLivePreviewEnabled,\n isLivePreviewing: incomingIsLivePreviewing,\n typeofLivePreviewURL,\n url: urlFromProps,\n}) => {\n const [previewWindowType, setPreviewWindowType] = useState<'iframe' | 'popup'>('iframe')\n const [isLivePreviewing, setIsLivePreviewing] = useState(incomingIsLivePreviewing)\n\n const breakpoints: LivePreviewConfig['breakpoints'] = useMemo(\n () => [\n ...(incomingBreakpoints || []),\n {\n name: 'responsive',\n height: '100%',\n label: 'Responsive',\n width: '100%',\n },\n ],\n [incomingBreakpoints],\n )\n\n const [url, setURL] = useState<string>('')\n\n const { isPopupOpen, openPopupWindow, popupRef } = usePopupWindow({\n eventType: 'payload-live-preview',\n url,\n })\n\n const [appIsReady, setAppIsReady] = useState(false)\n const [listeningForMessages, setListeningForMessages] = useState(false)\n\n const { collectionSlug, globalSlug } = useDocumentInfo()\n\n const isFirstRender = useRef(true)\n\n const { setPreference } = usePreferences()\n\n const iframeRef = React.useRef<HTMLIFrameElement>(null)\n\n const [loadedURL, setLoadedURL] = useState<string>()\n\n const [zoom, setZoom] = useState(1)\n\n const [position, setPosition] = useState({ x: 0, y: 0 })\n\n const [size, setSize] = React.useReducer(sizeReducer, { height: 0, width: 0 })\n\n const [measuredDeviceSize, setMeasuredDeviceSize] = useState({\n height: 0,\n width: 0,\n })\n\n const [breakpoint, setBreakpoint] =\n React.useState<LivePreviewConfig['breakpoints'][0]['name']>('responsive')\n\n /**\n * A \"middleware\" callback fn that does some additional work before `setURL`.\n * This is what we provide through context, bc it:\n * - ensures the URL is absolute\n * - resets `appIsReady` to `false` while the new URL is loading\n */\n const setLivePreviewURL = useCallback<LivePreviewContextType['setURL']>(\n (_incomingURL) => {\n const incomingURL = formatAbsoluteURL(_incomingURL)\n\n if (incomingURL !== url) {\n setAppIsReady(false)\n setURL(incomingURL)\n }\n },\n [url],\n )\n\n /**\n * `url` needs to be relative to the window, which cannot be done on initial render.\n */\n useEffect(() => {\n setURL(formatAbsoluteURL(urlFromProps))\n }, [urlFromProps])\n\n // The toolbar needs to freely drag and drop around the page\n const handleDragEnd = (ev) => {\n // only update position if the toolbar is completely within the preview area\n // otherwise reset it back to the previous position\n // TODO: reset to the nearest edge of the preview area\n if (ev.over && ev.over.id === 'live-preview-area') {\n const newPos = {\n x: position.x + ev.delta.x,\n y: position.y + ev.delta.y,\n }\n\n setPosition(newPos)\n } else {\n // reset\n }\n }\n\n const setWidth = useCallback(\n (width) => {\n setSize({ type: 'width', value: width })\n },\n [setSize],\n )\n\n const setHeight = useCallback(\n (height) => {\n setSize({ type: 'height', value: height })\n },\n [setSize],\n )\n\n // explicitly set new width and height when as new breakpoints are selected\n // exclude `custom` breakpoint as it is handled by the `setWidth` and `setHeight` directly\n useEffect(() => {\n const foundBreakpoint = breakpoints?.find((bp) => bp.name === breakpoint)\n\n if (\n foundBreakpoint &&\n breakpoint !== 'responsive' &&\n breakpoint !== 'custom' &&\n typeof foundBreakpoint?.width === 'number' &&\n typeof foundBreakpoint?.height === 'number'\n ) {\n setSize({\n type: 'reset',\n value: {\n height: foundBreakpoint.height,\n width: foundBreakpoint.width,\n },\n })\n }\n }, [breakpoint, breakpoints])\n\n /**\n * Receive the `ready` message from the popup window\n * This indicates that the app is ready to receive `window.postMessage` events\n * This is also the only cross-origin way of detecting when a popup window has loaded\n * Unlike iframe elements which have an `onLoad` handler, there is no way to access `window.open` on popups\n */\n useEffect(() => {\n const handleMessage = (event: MessageEvent) => {\n if (\n url?.startsWith(event.origin) &&\n event.data &&\n typeof event.data === 'object' &&\n event.data.type === 'payload-live-preview'\n ) {\n if (event.data.ready) {\n setAppIsReady(true)\n }\n }\n }\n\n window.addEventListener('message', handleMessage)\n\n setListeningForMessages(true)\n\n return () => {\n window.removeEventListener('message', handleMessage)\n }\n }, [url, listeningForMessages])\n\n const handleWindowChange = useCallback(\n (type: 'iframe' | 'popup') => {\n setAppIsReady(false)\n setPreviewWindowType(type)\n if (type === 'popup') {\n openPopupWindow()\n }\n },\n [openPopupWindow],\n )\n\n // when the user closes the popup window, switch back to the iframe\n // the `usePopupWindow` reports the `isPopupOpen` state for us to use here\n useEffect(() => {\n const newPreviewWindowType = isPopupOpen ? 'popup' : 'iframe'\n\n if (newPreviewWindowType !== previewWindowType) {\n handleWindowChange('iframe')\n }\n }, [previewWindowType, isPopupOpen, handleWindowChange])\n\n useEffect(() => {\n if (isFirstRender.current) {\n isFirstRender.current = false\n return\n }\n\n void setPreference<CollectionPreferences>(\n collectionSlug ? `collection-${collectionSlug}` : `global-${globalSlug}`,\n {\n editViewType: isLivePreviewing ? 'live-preview' : 'default',\n },\n true,\n )\n }, [isLivePreviewing, setPreference, collectionSlug, globalSlug])\n\n return (\n <LivePreviewContext\n value={{\n appIsReady,\n breakpoint,\n breakpoints,\n iframeRef,\n isLivePreviewEnabled,\n isLivePreviewing,\n isPopupOpen,\n listeningForMessages,\n loadedURL,\n measuredDeviceSize,\n openPopupWindow,\n popupRef,\n previewWindowType,\n setAppIsReady,\n setBreakpoint,\n setHeight,\n setIsLivePreviewing,\n setLoadedURL,\n setMeasuredDeviceSize,\n setPreviewWindowType: handleWindowChange,\n setSize,\n setToolbarPosition: setPosition,\n setURL: setLivePreviewURL,\n setWidth,\n setZoom,\n size,\n toolbarPosition: position,\n typeofLivePreviewURL,\n url,\n zoom,\n }}\n >\n <DndContext collisionDetection={customCollisionDetection} onDragEnd={handleDragEnd}>\n {children}\n </DndContext>\n </LivePreviewContext>\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,UAAU,QAAQ;AAC3B,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,OA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/B,OAAA;MACAoC,kBAAA,EAAoBxC,WAAA;MACpBnB,MAAA,EAAQ6B,iBAAA;MACRS,QAAA;MACArB,OAAA;MACAK,IAAA;MACAsC,eAAA,EAAiB1C,QAAA;MACjB5B,oBAAA;MACAC,GAAA;MACAyB;IACF;cAEA,aAAA0C,IAAA,CAACzF,UAAA;MAAW4F,kBAAA,EAAoBjF,wBAAA;MAA0BkF,SAAA,EAAW9B,aAAA;gBAClE9C;;;AAIT","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/RouteCache/index.tsx"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/RouteCache/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA6D,MAAM,OAAO,CAAA;AAIjF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,cAAc,EAAE,OAAO,CAAA;IACvB,eAAe,EAAE,MAAM,IAAI,CAAA;CAC5B,CAAA;AAOD,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,cAAc,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,CA4CxF,CAAA;AAED,eAAO,MAAM,aAAa,yBAAqB,CAAA"}
|
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
import { c as _c } from "react/compiler-runtime";
|
|
4
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
5
|
import { usePathname, useRouter } from 'next/navigation.js';
|
|
6
|
-
import React, { createContext, use, useCallback, useEffect } from 'react';
|
|
6
|
+
import React, { createContext, use, useCallback, useEffect, useRef } from 'react';
|
|
7
|
+
import { useEffectEvent } from '../../hooks/useEffectEvent.js';
|
|
7
8
|
const Context = /*#__PURE__*/createContext({
|
|
8
9
|
cachingEnabled: true,
|
|
9
10
|
clearRouteCache: () => {}
|
|
10
11
|
});
|
|
11
12
|
export const RouteCache = t0 => {
|
|
12
|
-
const $ = _c(
|
|
13
|
+
const $ = _c(17);
|
|
13
14
|
const {
|
|
14
15
|
cachingEnabled: t1,
|
|
15
16
|
children
|
|
@@ -17,6 +18,7 @@ export const RouteCache = t0 => {
|
|
|
17
18
|
const cachingEnabled = t1 === undefined ? true : t1;
|
|
18
19
|
const pathname = usePathname();
|
|
19
20
|
const router = useRouter();
|
|
21
|
+
const clearAfterPathnameChange = useRef(false);
|
|
20
22
|
let t2;
|
|
21
23
|
if ($[0] !== router) {
|
|
22
24
|
t2 = () => {
|
|
@@ -29,46 +31,81 @@ export const RouteCache = t0 => {
|
|
|
29
31
|
}
|
|
30
32
|
const clearRouteCache = t2;
|
|
31
33
|
let t3;
|
|
32
|
-
if ($[2]
|
|
34
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
33
35
|
t3 = () => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
36
|
+
const handlePopState = () => {
|
|
37
|
+
clearAfterPathnameChange.current = true;
|
|
38
|
+
};
|
|
39
|
+
window.addEventListener("popstate", handlePopState);
|
|
40
|
+
return () => {
|
|
41
|
+
window.removeEventListener("popstate", handlePopState);
|
|
42
|
+
};
|
|
37
43
|
};
|
|
38
|
-
$[2] =
|
|
39
|
-
$[3] = clearRouteCache;
|
|
40
|
-
$[4] = t3;
|
|
44
|
+
$[2] = t3;
|
|
41
45
|
} else {
|
|
42
|
-
t3 = $[
|
|
46
|
+
t3 = $[2];
|
|
43
47
|
}
|
|
44
48
|
let t4;
|
|
45
|
-
if ($[
|
|
46
|
-
t4 = [
|
|
47
|
-
$[
|
|
48
|
-
$[
|
|
49
|
-
$[7] = pathname;
|
|
50
|
-
$[8] = t4;
|
|
49
|
+
if ($[3] !== router) {
|
|
50
|
+
t4 = [router];
|
|
51
|
+
$[3] = router;
|
|
52
|
+
$[4] = t4;
|
|
51
53
|
} else {
|
|
52
|
-
t4 = $[
|
|
54
|
+
t4 = $[4];
|
|
53
55
|
}
|
|
54
56
|
useEffect(t3, t4);
|
|
55
57
|
let t5;
|
|
56
|
-
if ($[
|
|
57
|
-
t5 =
|
|
58
|
+
if ($[5] !== cachingEnabled || $[6] !== clearRouteCache) {
|
|
59
|
+
t5 = pathname_0 => {
|
|
60
|
+
if (cachingEnabled || clearAfterPathnameChange.current) {
|
|
61
|
+
clearAfterPathnameChange.current = false;
|
|
62
|
+
clearRouteCache();
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
$[5] = cachingEnabled;
|
|
66
|
+
$[6] = clearRouteCache;
|
|
67
|
+
$[7] = t5;
|
|
68
|
+
} else {
|
|
69
|
+
t5 = $[7];
|
|
70
|
+
}
|
|
71
|
+
const handlePathnameChange = useEffectEvent(t5);
|
|
72
|
+
let t6;
|
|
73
|
+
if ($[8] !== handlePathnameChange || $[9] !== pathname) {
|
|
74
|
+
t6 = () => {
|
|
75
|
+
handlePathnameChange(pathname);
|
|
76
|
+
};
|
|
77
|
+
$[8] = handlePathnameChange;
|
|
78
|
+
$[9] = pathname;
|
|
79
|
+
$[10] = t6;
|
|
80
|
+
} else {
|
|
81
|
+
t6 = $[10];
|
|
82
|
+
}
|
|
83
|
+
let t7;
|
|
84
|
+
if ($[11] !== pathname) {
|
|
85
|
+
t7 = [pathname];
|
|
86
|
+
$[11] = pathname;
|
|
87
|
+
$[12] = t7;
|
|
88
|
+
} else {
|
|
89
|
+
t7 = $[12];
|
|
90
|
+
}
|
|
91
|
+
useEffect(t6, t7);
|
|
92
|
+
let t8;
|
|
93
|
+
if ($[13] !== cachingEnabled || $[14] !== children || $[15] !== clearRouteCache) {
|
|
94
|
+
t8 = _jsx(Context, {
|
|
58
95
|
value: {
|
|
59
96
|
cachingEnabled,
|
|
60
97
|
clearRouteCache
|
|
61
98
|
},
|
|
62
99
|
children
|
|
63
100
|
});
|
|
64
|
-
$[
|
|
65
|
-
$[
|
|
66
|
-
$[
|
|
67
|
-
$[
|
|
101
|
+
$[13] = cachingEnabled;
|
|
102
|
+
$[14] = children;
|
|
103
|
+
$[15] = clearRouteCache;
|
|
104
|
+
$[16] = t8;
|
|
68
105
|
} else {
|
|
69
|
-
|
|
106
|
+
t8 = $[16];
|
|
70
107
|
}
|
|
71
|
-
return
|
|
108
|
+
return t8;
|
|
72
109
|
};
|
|
73
110
|
export const useRouteCache = () => use(Context);
|
|
74
111
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","usePathname","useRouter","React","createContext","use","useCallback","useEffect","Context","cachingEnabled","clearRouteCache","RouteCache","t0","$","t1","children","undefined","pathname","router","t2","refresh","t3","t4","t5","_jsx","value","useRouteCache"],"sources":["../../../src/providers/RouteCache/index.tsx"],"sourcesContent":["'use client'\n\nimport { usePathname, useRouter } from 'next/navigation.js'\nimport React, { createContext, use, useCallback, useEffect } from 'react'\n\nexport type RouteCacheContext = {\n cachingEnabled: boolean\n clearRouteCache: () => void\n}\n\nconst Context = createContext<RouteCacheContext>({\n cachingEnabled: true,\n clearRouteCache: () => {},\n})\n\nexport const RouteCache: React.FC<{ cachingEnabled?: boolean; children: React.ReactNode }> = ({\n cachingEnabled = true,\n children,\n}) => {\n const pathname = usePathname()\n const router = useRouter()\n\n const clearRouteCache = useCallback(() => {\n router.refresh()\n }, [router])\n\n useEffect(() => {\n
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","usePathname","useRouter","React","createContext","use","useCallback","useEffect","useRef","useEffectEvent","Context","cachingEnabled","clearRouteCache","RouteCache","t0","$","t1","children","undefined","pathname","router","clearAfterPathnameChange","t2","refresh","t3","Symbol","for","handlePopState","current","window","addEventListener","removeEventListener","t4","t5","pathname_0","handlePathnameChange","t6","t7","t8","_jsx","value","useRouteCache"],"sources":["../../../src/providers/RouteCache/index.tsx"],"sourcesContent":["'use client'\n\nimport { usePathname, useRouter } from 'next/navigation.js'\nimport React, { createContext, use, useCallback, useEffect, useRef } from 'react'\n\nimport { useEffectEvent } from '../../hooks/useEffectEvent.js'\n\nexport type RouteCacheContext = {\n cachingEnabled: boolean\n clearRouteCache: () => void\n}\n\nconst Context = createContext<RouteCacheContext>({\n cachingEnabled: true,\n clearRouteCache: () => {},\n})\n\nexport const RouteCache: React.FC<{ cachingEnabled?: boolean; children: React.ReactNode }> = ({\n cachingEnabled = true,\n children,\n}) => {\n const pathname = usePathname()\n const router = useRouter()\n\n /**\n * Next.js caches pages in memory in their {@link https://nextjs.org/docs/app/guides/caching#client-side-router-cache Client-side Router Cache},\n * causing forward/back browser navigation to show stale data from a previous visit.\n * The problem is this bfcache-like behavior has no opt-out, even if the page is dynamic, requires authentication, etc.\n * The workaround is to force a refresh when navigating via the browser controls.\n * This should be removed if/when Next.js supports this natively.\n */\n const clearAfterPathnameChange = useRef(false)\n\n const clearRouteCache = useCallback(() => {\n router.refresh()\n }, [router])\n\n useEffect(() => {\n const handlePopState = () => {\n clearAfterPathnameChange.current = true\n }\n\n window.addEventListener('popstate', handlePopState)\n\n return () => {\n window.removeEventListener('popstate', handlePopState)\n }\n }, [router])\n\n const handlePathnameChange = useEffectEvent((pathname: string) => {\n if (cachingEnabled || clearAfterPathnameChange.current) {\n clearAfterPathnameChange.current = false\n clearRouteCache()\n }\n })\n\n useEffect(() => {\n handlePathnameChange(pathname)\n }, [pathname])\n\n return <Context value={{ cachingEnabled, clearRouteCache }}>{children}</Context>\n}\n\nexport const useRouteCache = () => use(Context)\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAEA,SAASC,WAAW,EAAEC,SAAS,QAAQ;AACvC,OAAOC,KAAA,IAASC,aAAa,EAAEC,GAAG,EAAEC,WAAW,EAAEC,SAAS,EAAEC,MAAM,QAAQ;AAE1E,SAASC,cAAc,QAAQ;AAO/B,MAAMC,OAAA,gBAAUN,aAAA,CAAiC;EAC/CO,cAAA,EAAgB;EAChBC,eAAA,EAAiBA,CAAA,MAAO;AAC1B;AAEA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kBU,wBAAA,CAAAO,OAAgC;QACpDP,wBAAA,CAAAO,OAAA;QACAhB,eAAA;MAAA;IAAA;IAEJG,CAAA,MAAAJ,cAAA;IAAAI,CAAA,MAAAH,eAAA;IAAAG,CAAA,MAAAkB,EAAA;EAAA;IAAAA,EAAA,GAAAlB,CAAA;EAAA;EALA,MAAAoB,oBAAA,GAA6B1B,cAAA,CAAewB,EAK5C;EAAA,IAAAG,EAAA;EAAA,IAAArB,CAAA,QAAAoB,oBAAA,IAAApB,CAAA,QAAAI,QAAA;IAEUiB,EAAA,GAAAA,CAAA;MACRD,oBAAA,CAAqBhB,QAAA;IAAA;IACvBJ,CAAA,MAAAoB,oBAAA;IAAApB,CAAA,MAAAI,QAAA;IAAAJ,CAAA,OAAAqB,EAAA;EAAA;IAAAA,EAAA,GAAArB,CAAA;EAAA;EAAA,IAAAsB,EAAA;EAAA,IAAAtB,CAAA,SAAAI,QAAA;IAAGkB,EAAA,IAAClB,QAAA;IAASJ,CAAA,OAAAI,QAAA;IAAAJ,CAAA,OAAAsB,EAAA;EAAA;IAAAA,EAAA,GAAAtB,CAAA;EAAA;EAFbR,SAAA,CAAU6B,EAEV,EAAGC,EAAU;EAAA,IAAAC,EAAA;EAAA,IAAAvB,CAAA,SAAAJ,cAAA,IAAAI,CAAA,SAAAE,QAAA,IAAAF,CAAA,SAAAH,eAAA;IAEN0B,EAAA,GAAAC,IAAA,CAAA7B,OAAA;MAAA8B,KAAA;QAAA7B,cAAA;QAAAC;MAAA;MAAAK;IAAA,C;;;;;;;;SAAAqB,E;CACT;AAEA,OAAO,MAAMG,aAAA,GAAgBA,CAAA,KAAMpC,GAAA,CAAIK,OAAA","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { I18nClient } from '@payloadcms/translations';
|
|
2
|
-
import type { ClientField, CollectionPreferences, CollectionSlug, Column, DefaultCellComponentProps, Document, Field, PaginatedDocs, Payload, SanitizedCollectionConfig, ViewTypes } from 'payload';
|
|
2
|
+
import type { ClientField, CollectionPreferences, CollectionSlug, Column, DefaultCellComponentProps, Document, Field, PaginatedDocs, Payload, PayloadRequest, SanitizedCollectionConfig, ViewTypes } from 'payload';
|
|
3
3
|
import type { SortColumnProps } from '../../../elements/SortColumn/index.js';
|
|
4
4
|
export type BuildColumnStateArgs = {
|
|
5
5
|
beforeRows?: Column[];
|
|
@@ -11,6 +11,7 @@ export type BuildColumnStateArgs = {
|
|
|
11
11
|
enableRowTypes?: boolean;
|
|
12
12
|
i18n: I18nClient;
|
|
13
13
|
payload: Payload;
|
|
14
|
+
req?: PayloadRequest;
|
|
14
15
|
serverFields: Field[];
|
|
15
16
|
sortColumnProps?: Partial<SortColumnProps>;
|
|
16
17
|
useAsTitle: SanitizedCollectionConfig['admin']['useAsTitle'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/providers/TableColumns/buildColumnState/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EAEV,WAAW,EACX,qBAAqB,EACrB,cAAc,EACd,MAAM,EACN,yBAAyB,EACzB,QAAQ,EACR,KAAK,EACL,aAAa,EACb,OAAO,EACP,yBAAyB,EAGzB,SAAS,EACV,MAAM,SAAS,CAAA;AAUhB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAA;AAY5E,MAAM,MAAM,oBAAoB,GAAG;IACjC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IACrB,YAAY,EAAE,WAAW,EAAE,CAAA;IAC3B,OAAO,CAAC,EAAE,qBAAqB,CAAC,SAAS,CAAC,CAAA;IAC1C,eAAe,EAAE,yBAAyB,CAAC,iBAAiB,CAAC,CAAA;IAC7D,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,mBAAmB,EAAE,OAAO,CAAA;IAC5B,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,IAAI,EAAE,UAAU,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,YAAY,EAAE,KAAK,EAAE,CAAA;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAA;IAC1C,UAAU,EAAE,yBAAyB,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,CAAA;IAC5D,QAAQ,CAAC,EAAE,SAAS,CAAA;CACrB,GAAG,CACA;IACE,cAAc,EAAE,cAAc,CAAA;IAC9B,QAAQ,EAAE,aAAa,CAAA;IACvB,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CAC5B,GACD;IACE,cAAc,CAAC,EAAE,SAAS,CAAA;IAC1B,QAAQ,EAAE,aAAa,CAAA;IACvB,IAAI,EAAE;QACJ,UAAU,EAAE,cAAc,CAAA;QAC1B,KAAK,EAAE,QAAQ,CAAA;KAChB,EAAE,CAAA;CACJ,CACJ,CAAA;AAED,eAAO,MAAM,gBAAgB,SAAU,oBAAoB,KAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/providers/TableColumns/buildColumnState/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EAEV,WAAW,EACX,qBAAqB,EACrB,cAAc,EACd,MAAM,EACN,yBAAyB,EACzB,QAAQ,EACR,KAAK,EACL,aAAa,EACb,OAAO,EACP,cAAc,EACd,yBAAyB,EAGzB,SAAS,EACV,MAAM,SAAS,CAAA;AAUhB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAA;AAY5E,MAAM,MAAM,oBAAoB,GAAG;IACjC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IACrB,YAAY,EAAE,WAAW,EAAE,CAAA;IAC3B,OAAO,CAAC,EAAE,qBAAqB,CAAC,SAAS,CAAC,CAAA;IAC1C,eAAe,EAAE,yBAAyB,CAAC,iBAAiB,CAAC,CAAA;IAC7D,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,mBAAmB,EAAE,OAAO,CAAA;IAC5B,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,IAAI,EAAE,UAAU,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,GAAG,CAAC,EAAE,cAAc,CAAA;IACpB,YAAY,EAAE,KAAK,EAAE,CAAA;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAA;IAC1C,UAAU,EAAE,yBAAyB,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,CAAA;IAC5D,QAAQ,CAAC,EAAE,SAAS,CAAA;CACrB,GAAG,CACA;IACE,cAAc,EAAE,cAAc,CAAA;IAC9B,QAAQ,EAAE,aAAa,CAAA;IACvB,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CAC5B,GACD;IACE,cAAc,CAAC,EAAE,SAAS,CAAA;IAC1B,QAAQ,EAAE,aAAa,CAAA;IACvB,IAAI,EAAE;QACJ,UAAU,EAAE,cAAc,CAAA;QAC1B,KAAK,EAAE,QAAQ,CAAA;KAChB,EAAE,CAAA;CACJ,CACJ,CAAA;AAED,eAAO,MAAM,gBAAgB,SAAU,oBAAoB,KAAG,MAAM,EA2MnE,CAAA"}
|
|
@@ -20,6 +20,7 @@ export const buildColumnState = args => {
|
|
|
20
20
|
enableRowSelections,
|
|
21
21
|
i18n,
|
|
22
22
|
payload,
|
|
23
|
+
req,
|
|
23
24
|
serverFields,
|
|
24
25
|
sortColumnProps,
|
|
25
26
|
useAsTitle,
|
|
@@ -132,6 +133,7 @@ export const buildColumnState = args => {
|
|
|
132
133
|
i18n,
|
|
133
134
|
isLinkedColumn: enableLinkedCell && colIndex === activeColumnsIndices[0],
|
|
134
135
|
payload,
|
|
136
|
+
req,
|
|
135
137
|
rowIndex,
|
|
136
138
|
serverField,
|
|
137
139
|
viewType
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["fieldIsHiddenOrDisabled","fieldIsID","fieldIsPresentationalOnly","flattenTopLevelFields","React","RenderServerComponent","SortColumn","filterFields","isColumnActive","renderCell","sortFieldMap","buildColumnState","args","beforeRows","clientFields","collectionSlug","columns","customCellProps","dataType","docs","enableLinkedCell","enableRowSelections","i18n","payload","serverFields","sortColumnProps","useAsTitle","viewType","sortedFieldMap","keepPresentationalFields","moveSubFieldsToTop","_sortedFieldMap","idFieldIndex","findIndex","field","idField","splice","unshift","useAsTitleFieldIndex","name","useAsTitleField","sortTo","activeColumnsIndices","sorted","reduce","acc","clientField","colIndex","accessor","undefined","serverField","find","f","fAccessor","hasCustomCell","admin","components","Cell","type","columnPref","preference","isActive","column","includes","push","CustomLabel","CustomLabelToRender","Label","clientProps","customLabelServerProps","Component","importMap","serverProps","fieldAffectsDataSubFields","label","labelWithPrefix","dotAccessor","replace","Heading","_jsx","disable","active","renderedCells","map","doc","rowIndex","relationTo","columnIndex","value","isLinkedColumn"],"sources":["../../../../src/providers/TableColumns/buildColumnState/index.tsx"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type {\n ClientComponentProps,\n ClientField,\n CollectionPreferences,\n CollectionSlug,\n Column,\n DefaultCellComponentProps,\n Document,\n Field,\n PaginatedDocs,\n Payload,\n SanitizedCollectionConfig,\n ServerComponentProps,\n StaticLabel,\n ViewTypes,\n} from 'payload'\n\nimport {\n fieldIsHiddenOrDisabled,\n fieldIsID,\n fieldIsPresentationalOnly,\n flattenTopLevelFields,\n} from 'payload/shared'\nimport React from 'react'\n\nimport type { SortColumnProps } from '../../../elements/SortColumn/index.js'\n\nimport { RenderServerComponent } from '../../../elements/RenderServerComponent/index.js'\nimport {\n SortColumn,\n // eslint-disable-next-line payload/no-imports-from-exports-dir -- MUST reference the exports dir: https://github.com/payloadcms/payload/issues/12002#issuecomment-2791493587\n} from '../../../exports/client/index.js'\nimport { filterFields } from './filterFields.js'\nimport { isColumnActive } from './isColumnActive.js'\nimport { renderCell } from './renderCell.js'\nimport { sortFieldMap } from './sortFieldMap.js'\n\nexport type BuildColumnStateArgs = {\n beforeRows?: Column[]\n clientFields: ClientField[]\n columns?: CollectionPreferences['columns']\n customCellProps: DefaultCellComponentProps['customCellProps']\n enableLinkedCell?: boolean\n enableRowSelections: boolean\n enableRowTypes?: boolean\n i18n: I18nClient\n payload: Payload\n serverFields: Field[]\n sortColumnProps?: Partial<SortColumnProps>\n useAsTitle: SanitizedCollectionConfig['admin']['useAsTitle']\n viewType?: ViewTypes\n} & (\n | {\n collectionSlug: CollectionSlug\n dataType: 'monomorphic'\n docs: PaginatedDocs['docs']\n }\n | {\n collectionSlug?: undefined\n dataType: 'polymorphic'\n docs: {\n relationTo: CollectionSlug\n value: Document\n }[]\n }\n)\n\nexport const buildColumnState = (args: BuildColumnStateArgs): Column[] => {\n const {\n beforeRows,\n clientFields,\n collectionSlug,\n columns,\n customCellProps,\n dataType,\n docs,\n enableLinkedCell = true,\n enableRowSelections,\n i18n,\n payload,\n serverFields,\n sortColumnProps,\n useAsTitle,\n viewType,\n } = args\n\n // clientFields contains the fake `id` column\n let sortedFieldMap = flattenTopLevelFields(filterFields(clientFields), {\n i18n,\n keepPresentationalFields: true,\n moveSubFieldsToTop: true,\n }) as ClientField[]\n\n let _sortedFieldMap = flattenTopLevelFields(filterFields(serverFields), {\n i18n,\n keepPresentationalFields: true,\n moveSubFieldsToTop: true,\n }) as Field[] // TODO: think of a way to avoid this additional flatten\n\n // place the `ID` field first, if it exists\n // do the same for the `useAsTitle` field with precedence over the `ID` field\n // then sort the rest of the fields based on the `defaultColumns` or `columns`\n const idFieldIndex = sortedFieldMap?.findIndex((field) => fieldIsID(field))\n\n if (idFieldIndex > -1) {\n const idField = sortedFieldMap.splice(idFieldIndex, 1)[0]\n sortedFieldMap.unshift(idField)\n }\n\n const useAsTitleFieldIndex = useAsTitle\n ? sortedFieldMap.findIndex((field) => 'name' in field && field.name === useAsTitle)\n : -1\n\n if (useAsTitleFieldIndex > -1) {\n const useAsTitleField = sortedFieldMap.splice(useAsTitleFieldIndex, 1)[0]\n sortedFieldMap.unshift(useAsTitleField)\n }\n\n const sortTo = columns\n\n if (sortTo) {\n // sort the fields to the order of `defaultColumns` or `columns`\n sortedFieldMap = sortFieldMap<ClientField>(sortedFieldMap, sortTo)\n _sortedFieldMap = sortFieldMap<Field>(_sortedFieldMap, sortTo) // TODO: think of a way to avoid this additional sort\n }\n\n const activeColumnsIndices = []\n\n const sorted: Column[] = sortedFieldMap?.reduce((acc, clientField, colIndex) => {\n if (fieldIsHiddenOrDisabled(clientField) && !fieldIsID(clientField)) {\n return acc\n }\n\n const accessor =\n (clientField as any).accessor ?? ('name' in clientField ? clientField.name : undefined)\n\n const serverField = _sortedFieldMap.find((f) => {\n const fAccessor = (f as any).accessor ?? ('name' in f ? f.name : undefined)\n return fAccessor === accessor\n })\n\n const hasCustomCell =\n serverField?.admin &&\n 'components' in serverField.admin &&\n serverField.admin.components &&\n 'Cell' in serverField.admin.components &&\n serverField.admin.components.Cell\n\n if (serverField && serverField.type === 'group' && !hasCustomCell) {\n return acc // skip any group without a custom cell\n }\n\n const columnPref = columns?.find(\n (preference) => clientField && 'name' in clientField && preference.accessor === accessor,\n )\n\n const isActive = isColumnActive({\n accessor,\n activeColumnsIndices,\n column: columnPref,\n columns,\n })\n\n if (isActive && !activeColumnsIndices.includes(colIndex)) {\n activeColumnsIndices.push(colIndex)\n }\n\n let CustomLabel = undefined\n\n if (dataType === 'monomorphic') {\n const CustomLabelToRender =\n serverField &&\n 'admin' in serverField &&\n 'components' in serverField.admin &&\n 'Label' in serverField.admin.components &&\n serverField.admin.components.Label !== undefined // let it return `null`\n ? serverField.admin.components.Label\n : undefined\n\n // TODO: customComponent will be optional in v4\n const clientProps: Omit<ClientComponentProps, 'customComponents'> = {\n field: clientField,\n }\n\n const customLabelServerProps: Pick<\n ServerComponentProps,\n 'clientField' | 'collectionSlug' | 'field' | 'i18n' | 'payload'\n > = {\n clientField,\n collectionSlug,\n field: serverField,\n i18n,\n payload,\n }\n\n CustomLabel = CustomLabelToRender\n ? RenderServerComponent({\n clientProps,\n Component: CustomLabelToRender,\n importMap: payload.importMap,\n serverProps: customLabelServerProps,\n })\n : undefined\n }\n\n const fieldAffectsDataSubFields =\n clientField &&\n clientField.type &&\n (clientField.type === 'array' ||\n clientField.type === 'group' ||\n clientField.type === 'blocks')\n\n const label =\n clientField && 'labelWithPrefix' in clientField && clientField.labelWithPrefix !== undefined\n ? clientField.labelWithPrefix\n : 'label' in clientField\n ? clientField.label\n : undefined\n\n // Convert accessor to dot notation specifically for SortColumn sorting behavior\n const dotAccessor = accessor?.replace(/-/g, '.')\n\n const Heading = (\n <SortColumn\n disable={fieldAffectsDataSubFields || fieldIsPresentationalOnly(clientField) || undefined}\n Label={CustomLabel}\n label={label as StaticLabel}\n name={dotAccessor}\n {...(sortColumnProps || {})}\n />\n )\n\n const column: Column = {\n accessor,\n active: isActive,\n CustomLabel,\n field: clientField,\n Heading,\n renderedCells: isActive\n ? docs.map((doc, rowIndex) => {\n return renderCell({\n clientField,\n collectionSlug: dataType === 'monomorphic' ? collectionSlug : doc.relationTo,\n columnIndex: colIndex,\n customCellProps,\n doc: dataType === 'monomorphic' ? doc : doc.value,\n enableRowSelections,\n i18n,\n isLinkedColumn: enableLinkedCell && colIndex === activeColumnsIndices[0],\n payload,\n rowIndex,\n serverField,\n viewType,\n })\n })\n : [],\n }\n\n acc.push(column)\n\n return acc\n }, [])\n\n if (beforeRows) {\n sorted.unshift(...beforeRows)\n }\n\n return sorted\n}\n"],"mappings":";AAkBA,SACEA,uBAAuB,EACvBC,SAAS,EACTC,yBAAyB,EACzBC,qBAAqB,QAChB;AACP,OAAOC,KAAA,MAAW;AAIlB,SAASC,qBAAqB,QAAQ;AACtC,SACEC,UAAU,QAEL;AACP,SAASC,YAAY,QAAQ;AAC7B,SAASC,cAAc,QAAQ;AAC/B,SAASC,UAAU,QAAQ;AAC3B,SAASC,YAAY,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OAAA,CAAQ,MAAM;IAE5C,MAAMC,OAAA,gBACJC,IAAA,CAACzE,UAAA;MACC0E,OAAA,EAASP,yBAAA,IAA6BvE,yBAAA,CAA0B4C,WAAA,KAAgBG,SAAA;MAChFkB,KAAA,EAAOF,WAAA;MACPS,KAAA,EAAOA,KAAA;MACPnC,IAAA,EAAMqC,WAAA;MACL,IAAInD,eAAA,IAAmB,CAAC,CAAC;;IAI9B,MAAMqC,MAAA,GAAiB;MACrBd,QAAA;MACAiC,MAAA,EAAQpB,QAAA;MACRI,WAAA;MACA/B,KAAA,EAAOY,WAAA;MACPgC,OAAA;MACAI,aAAA,EAAerB,QAAA,GACX1C,IAAA,CAAKgE,GAAG,CAAC,CAACC,GAAA,EAAKC,QAAA;QACb,OAAO5E,UAAA,CAAW;UAChBqC,WAAA;UACA/B,cAAA,EAAgBG,QAAA,KAAa,gBAAgBH,cAAA,GAAiBqE,GAAA,CAAIE,UAAU;UAC5EC,WAAA,EAAaxC,QAAA;UACb9B,eAAA;UACAmE,GAAA,EAAKlE,QAAA,KAAa,gBAAgBkE,GAAA,GAAMA,GAAA,CAAII,KAAK;UACjDnE,mBAAA;UACAC,IAAA;UACAmE,cAAA,EAAgBrE,gBAAA,IAAoB2B,QAAA,KAAaL,oBAAoB,CAAC,EAAE;UACxEnB,OAAA;UACA8D,QAAA;UACAnC,WAAA;UACAvB;QACF;MACF,KACA;IACN;IAEAkB,GAAA,CAAImB,IAAI,CAACF,MAAA;IAET,OAAOjB,GAAA;EACT,GAAG,EAAE;EAEL,IAAIhC,UAAA,EAAY;IACd8B,MAAA,CAAON,OAAO,IAAIxB,UAAA;EACpB;EAEA,OAAO8B,MAAA;AACT","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["fieldIsHiddenOrDisabled","fieldIsID","fieldIsPresentationalOnly","flattenTopLevelFields","React","RenderServerComponent","SortColumn","filterFields","isColumnActive","renderCell","sortFieldMap","buildColumnState","args","beforeRows","clientFields","collectionSlug","columns","customCellProps","dataType","docs","enableLinkedCell","enableRowSelections","i18n","payload","req","serverFields","sortColumnProps","useAsTitle","viewType","sortedFieldMap","keepPresentationalFields","moveSubFieldsToTop","_sortedFieldMap","idFieldIndex","findIndex","field","idField","splice","unshift","useAsTitleFieldIndex","name","useAsTitleField","sortTo","activeColumnsIndices","sorted","reduce","acc","clientField","colIndex","accessor","undefined","serverField","find","f","fAccessor","hasCustomCell","admin","components","Cell","type","columnPref","preference","isActive","column","includes","push","CustomLabel","CustomLabelToRender","Label","clientProps","customLabelServerProps","Component","importMap","serverProps","fieldAffectsDataSubFields","label","labelWithPrefix","dotAccessor","replace","Heading","_jsx","disable","active","renderedCells","map","doc","rowIndex","relationTo","columnIndex","value","isLinkedColumn"],"sources":["../../../../src/providers/TableColumns/buildColumnState/index.tsx"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type {\n ClientComponentProps,\n ClientField,\n CollectionPreferences,\n CollectionSlug,\n Column,\n DefaultCellComponentProps,\n Document,\n Field,\n PaginatedDocs,\n Payload,\n PayloadRequest,\n SanitizedCollectionConfig,\n ServerComponentProps,\n StaticLabel,\n ViewTypes,\n} from 'payload'\n\nimport {\n fieldIsHiddenOrDisabled,\n fieldIsID,\n fieldIsPresentationalOnly,\n flattenTopLevelFields,\n} from 'payload/shared'\nimport React from 'react'\n\nimport type { SortColumnProps } from '../../../elements/SortColumn/index.js'\n\nimport { RenderServerComponent } from '../../../elements/RenderServerComponent/index.js'\nimport {\n SortColumn,\n // eslint-disable-next-line payload/no-imports-from-exports-dir -- MUST reference the exports dir: https://github.com/payloadcms/payload/issues/12002#issuecomment-2791493587\n} from '../../../exports/client/index.js'\nimport { filterFields } from './filterFields.js'\nimport { isColumnActive } from './isColumnActive.js'\nimport { renderCell } from './renderCell.js'\nimport { sortFieldMap } from './sortFieldMap.js'\n\nexport type BuildColumnStateArgs = {\n beforeRows?: Column[]\n clientFields: ClientField[]\n columns?: CollectionPreferences['columns']\n customCellProps: DefaultCellComponentProps['customCellProps']\n enableLinkedCell?: boolean\n enableRowSelections: boolean\n enableRowTypes?: boolean\n i18n: I18nClient\n payload: Payload\n req?: PayloadRequest\n serverFields: Field[]\n sortColumnProps?: Partial<SortColumnProps>\n useAsTitle: SanitizedCollectionConfig['admin']['useAsTitle']\n viewType?: ViewTypes\n} & (\n | {\n collectionSlug: CollectionSlug\n dataType: 'monomorphic'\n docs: PaginatedDocs['docs']\n }\n | {\n collectionSlug?: undefined\n dataType: 'polymorphic'\n docs: {\n relationTo: CollectionSlug\n value: Document\n }[]\n }\n)\n\nexport const buildColumnState = (args: BuildColumnStateArgs): Column[] => {\n const {\n beforeRows,\n clientFields,\n collectionSlug,\n columns,\n customCellProps,\n dataType,\n docs,\n enableLinkedCell = true,\n enableRowSelections,\n i18n,\n payload,\n req,\n serverFields,\n sortColumnProps,\n useAsTitle,\n viewType,\n } = args\n\n // clientFields contains the fake `id` column\n let sortedFieldMap = flattenTopLevelFields(filterFields(clientFields), {\n i18n,\n keepPresentationalFields: true,\n moveSubFieldsToTop: true,\n }) as ClientField[]\n\n let _sortedFieldMap = flattenTopLevelFields(filterFields(serverFields), {\n i18n,\n keepPresentationalFields: true,\n moveSubFieldsToTop: true,\n }) as Field[] // TODO: think of a way to avoid this additional flatten\n\n // place the `ID` field first, if it exists\n // do the same for the `useAsTitle` field with precedence over the `ID` field\n // then sort the rest of the fields based on the `defaultColumns` or `columns`\n const idFieldIndex = sortedFieldMap?.findIndex((field) => fieldIsID(field))\n\n if (idFieldIndex > -1) {\n const idField = sortedFieldMap.splice(idFieldIndex, 1)[0]\n sortedFieldMap.unshift(idField)\n }\n\n const useAsTitleFieldIndex = useAsTitle\n ? sortedFieldMap.findIndex((field) => 'name' in field && field.name === useAsTitle)\n : -1\n\n if (useAsTitleFieldIndex > -1) {\n const useAsTitleField = sortedFieldMap.splice(useAsTitleFieldIndex, 1)[0]\n sortedFieldMap.unshift(useAsTitleField)\n }\n\n const sortTo = columns\n\n if (sortTo) {\n // sort the fields to the order of `defaultColumns` or `columns`\n sortedFieldMap = sortFieldMap<ClientField>(sortedFieldMap, sortTo)\n _sortedFieldMap = sortFieldMap<Field>(_sortedFieldMap, sortTo) // TODO: think of a way to avoid this additional sort\n }\n\n const activeColumnsIndices = []\n\n const sorted: Column[] = sortedFieldMap?.reduce((acc, clientField, colIndex) => {\n if (fieldIsHiddenOrDisabled(clientField) && !fieldIsID(clientField)) {\n return acc\n }\n\n const accessor =\n (clientField as any).accessor ?? ('name' in clientField ? clientField.name : undefined)\n\n const serverField = _sortedFieldMap.find((f) => {\n const fAccessor = (f as any).accessor ?? ('name' in f ? f.name : undefined)\n return fAccessor === accessor\n })\n\n const hasCustomCell =\n serverField?.admin &&\n 'components' in serverField.admin &&\n serverField.admin.components &&\n 'Cell' in serverField.admin.components &&\n serverField.admin.components.Cell\n\n if (serverField && serverField.type === 'group' && !hasCustomCell) {\n return acc // skip any group without a custom cell\n }\n\n const columnPref = columns?.find(\n (preference) => clientField && 'name' in clientField && preference.accessor === accessor,\n )\n\n const isActive = isColumnActive({\n accessor,\n activeColumnsIndices,\n column: columnPref,\n columns,\n })\n\n if (isActive && !activeColumnsIndices.includes(colIndex)) {\n activeColumnsIndices.push(colIndex)\n }\n\n let CustomLabel = undefined\n\n if (dataType === 'monomorphic') {\n const CustomLabelToRender =\n serverField &&\n 'admin' in serverField &&\n 'components' in serverField.admin &&\n 'Label' in serverField.admin.components &&\n serverField.admin.components.Label !== undefined // let it return `null`\n ? serverField.admin.components.Label\n : undefined\n\n // TODO: customComponent will be optional in v4\n const clientProps: Omit<ClientComponentProps, 'customComponents'> = {\n field: clientField,\n }\n\n const customLabelServerProps: Pick<\n ServerComponentProps,\n 'clientField' | 'collectionSlug' | 'field' | 'i18n' | 'payload'\n > = {\n clientField,\n collectionSlug,\n field: serverField,\n i18n,\n payload,\n }\n\n CustomLabel = CustomLabelToRender\n ? RenderServerComponent({\n clientProps,\n Component: CustomLabelToRender,\n importMap: payload.importMap,\n serverProps: customLabelServerProps,\n })\n : undefined\n }\n\n const fieldAffectsDataSubFields =\n clientField &&\n clientField.type &&\n (clientField.type === 'array' ||\n clientField.type === 'group' ||\n clientField.type === 'blocks')\n\n const label =\n clientField && 'labelWithPrefix' in clientField && clientField.labelWithPrefix !== undefined\n ? clientField.labelWithPrefix\n : 'label' in clientField\n ? clientField.label\n : undefined\n\n // Convert accessor to dot notation specifically for SortColumn sorting behavior\n const dotAccessor = accessor?.replace(/-/g, '.')\n\n const Heading = (\n <SortColumn\n disable={fieldAffectsDataSubFields || fieldIsPresentationalOnly(clientField) || undefined}\n Label={CustomLabel}\n label={label as StaticLabel}\n name={dotAccessor}\n {...(sortColumnProps || {})}\n />\n )\n\n const column: Column = {\n accessor,\n active: isActive,\n CustomLabel,\n field: clientField,\n Heading,\n renderedCells: isActive\n ? docs.map((doc, rowIndex) => {\n return renderCell({\n clientField,\n collectionSlug: dataType === 'monomorphic' ? collectionSlug : doc.relationTo,\n columnIndex: colIndex,\n customCellProps,\n doc: dataType === 'monomorphic' ? doc : doc.value,\n enableRowSelections,\n i18n,\n isLinkedColumn: enableLinkedCell && colIndex === activeColumnsIndices[0],\n payload,\n req,\n rowIndex,\n serverField,\n viewType,\n })\n })\n : [],\n }\n\n acc.push(column)\n\n return acc\n }, [])\n\n if (beforeRows) {\n sorted.unshift(...beforeRows)\n }\n\n return sorted\n}\n"],"mappings":";AAmBA,SACEA,uBAAuB,EACvBC,SAAS,EACTC,yBAAyB,EACzBC,qBAAqB,QAChB;AACP,OAAOC,KAAA,MAAW;AAIlB,SAASC,qBAAqB,QAAQ;AACtC,SACEC,UAAU,QAEL;AACP,SAASC,YAAY,QAAQ;AAC7B,SAASC,cAAc,QAAQ;AAC/B,SAASC,UAAU,QAAQ;AAC3B,SAASC,YAAY,QAAQ;AAiC7B,OAAO,MAAMC,gBAAA,GAAoBC,IAAA;EAC/B,MAAM;IACJC,UAAU;IACVC,YAAY;IACZC,cAAc;IACdC,OAAO;IACPC,eAAe;IACfC,Q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B6C,WAAA,KAAgBG,SAAA;MAChFkB,KAAA,EAAOF,WAAA;MACPS,KAAA,EAAOA,KAAA;MACPnC,IAAA,EAAMqC,WAAA;MACL,IAAInD,eAAA,IAAmB,CAAC,CAAC;;IAI9B,MAAMqC,MAAA,GAAiB;MACrBd,QAAA;MACAiC,MAAA,EAAQpB,QAAA;MACRI,WAAA;MACA/B,KAAA,EAAOY,WAAA;MACPgC,OAAA;MACAI,aAAA,EAAerB,QAAA,GACX3C,IAAA,CAAKiE,GAAG,CAAC,CAACC,GAAA,EAAKC,QAAA;QACb,OAAO7E,UAAA,CAAW;UAChBsC,WAAA;UACAhC,cAAA,EAAgBG,QAAA,KAAa,gBAAgBH,cAAA,GAAiBsE,GAAA,CAAIE,UAAU;UAC5EC,WAAA,EAAaxC,QAAA;UACb/B,eAAA;UACAoE,GAAA,EAAKnE,QAAA,KAAa,gBAAgBmE,GAAA,GAAMA,GAAA,CAAII,KAAK;UACjDpE,mBAAA;UACAC,IAAA;UACAoE,cAAA,EAAgBtE,gBAAA,IAAoB4B,QAAA,KAAaL,oBAAoB,CAAC,EAAE;UACxEpB,OAAA;UACAC,GAAA;UACA8D,QAAA;UACAnC,WAAA;UACAvB;QACF;MACF,KACA;IACN;IAEAkB,GAAA,CAAImB,IAAI,CAACF,MAAA;IAET,OAAOjB,GAAA;EACT,GAAG,EAAE;EAEL,IAAIjC,UAAA,EAAY;IACd+B,MAAA,CAAON,OAAO,IAAIzB,UAAA;EACpB;EAEA,OAAO+B,MAAA;AACT","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { I18nClient } from '@payloadcms/translations';
|
|
2
|
-
import type { ClientField, DefaultCellComponentProps, Document, Field, Payload, ViewTypes } from 'payload';
|
|
2
|
+
import type { ClientField, DefaultCellComponentProps, Document, Field, Payload, PayloadRequest, ViewTypes } from 'payload';
|
|
3
3
|
type RenderCellArgs = {
|
|
4
4
|
readonly clientField: ClientField;
|
|
5
5
|
readonly collectionSlug: string;
|
|
@@ -10,10 +10,11 @@ type RenderCellArgs = {
|
|
|
10
10
|
readonly i18n: I18nClient;
|
|
11
11
|
readonly isLinkedColumn: boolean;
|
|
12
12
|
readonly payload: Payload;
|
|
13
|
+
readonly req?: PayloadRequest;
|
|
13
14
|
readonly rowIndex: number;
|
|
14
15
|
readonly serverField: Field;
|
|
15
16
|
readonly viewType?: ViewTypes;
|
|
16
17
|
};
|
|
17
|
-
export declare function renderCell({ clientField, collectionSlug, columnIndex, customCellProps, doc, enableRowSelections, i18n, isLinkedColumn, payload, rowIndex, serverField, viewType, }: RenderCellArgs): import("react").JSX.Element;
|
|
18
|
+
export declare function renderCell({ clientField, collectionSlug, columnIndex, customCellProps, doc, enableRowSelections, i18n, isLinkedColumn, payload, req, rowIndex, serverField, viewType, }: RenderCellArgs): import("react").JSX.Element;
|
|
18
19
|
export {};
|
|
19
20
|
//# sourceMappingURL=renderCell.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderCell.d.ts","sourceRoot":"","sources":["../../../../src/providers/TableColumns/buildColumnState/renderCell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EACV,WAAW,EACX,yBAAyB,EAEzB,QAAQ,EACR,KAAK,EACL,OAAO,EACP,SAAS,EACV,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"renderCell.d.ts","sourceRoot":"","sources":["../../../../src/providers/TableColumns/buildColumnState/renderCell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EACV,WAAW,EACX,yBAAyB,EAEzB,QAAQ,EACR,KAAK,EACL,OAAO,EACP,cAAc,EACd,SAAS,EACV,MAAM,SAAS,CAAA;AAehB,KAAK,cAAc,GAAG;IACpB,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAA;IACjC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;IAC/B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,eAAe,EAAE,yBAAyB,CAAC,iBAAiB,CAAC,CAAA;IACtE,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAA;IACtB,QAAQ,CAAC,mBAAmB,EAAE,OAAO,CAAA;IACrC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;IACzB,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAA;IAChC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,GAAG,CAAC,EAAE,cAAc,CAAA;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,WAAW,EAAE,KAAK,CAAA;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAC9B,CAAA;AACD,wBAAgB,UAAU,CAAC,EACzB,WAAW,EACX,cAAc,EACd,WAAW,EACX,eAAe,EACf,GAAG,EACH,mBAAmB,EACnB,IAAI,EACJ,cAAc,EACd,OAAO,EACP,GAAG,EACH,QAAQ,EACR,WAAW,EACX,QAAQ,GACT,EAAE,cAAc,+BAuJhB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { MissingEditorProp } from 'payload';
|
|
3
|
+
import { formatAdminURL } from 'payload/shared';
|
|
3
4
|
import { RenderCustomComponent } from '../../../elements/RenderCustomComponent/index.js';
|
|
4
5
|
import { RenderServerComponent } from '../../../elements/RenderServerComponent/index.js';
|
|
5
6
|
import { DefaultCell, RenderDefaultCell } from '../../../exports/client/index.js';
|
|
@@ -15,6 +16,7 @@ export function renderCell({
|
|
|
15
16
|
i18n,
|
|
16
17
|
isLinkedColumn,
|
|
17
18
|
payload,
|
|
19
|
+
req,
|
|
18
20
|
rowIndex,
|
|
19
21
|
serverField,
|
|
20
22
|
viewType
|
|
@@ -28,10 +30,44 @@ export function renderCell({
|
|
|
28
30
|
viewType
|
|
29
31
|
};
|
|
30
32
|
const accessor = ('accessor' in clientField ? clientField.accessor : undefined) ?? ('name' in clientField ? clientField.name : undefined);
|
|
33
|
+
// Check if there's a custom formatDocURL function for this linked column
|
|
34
|
+
let shouldLink = isLinkedColumn;
|
|
35
|
+
let customLinkURL;
|
|
36
|
+
if (isLinkedColumn && req) {
|
|
37
|
+
const collectionConfig = payload.collections[collectionSlug]?.config;
|
|
38
|
+
const formatDocURL = collectionConfig?.admin?.formatDocURL;
|
|
39
|
+
if (typeof formatDocURL === 'function') {
|
|
40
|
+
// Generate the default URL that would normally be used
|
|
41
|
+
const adminRoute = req.payload.config.routes?.admin || '/admin';
|
|
42
|
+
const defaultURL = formatAdminURL({
|
|
43
|
+
adminRoute,
|
|
44
|
+
path: `/collections/${collectionSlug}${viewType === 'trash' ? '/trash' : ''}/${encodeURIComponent(String(doc.id))}`
|
|
45
|
+
});
|
|
46
|
+
const customURL = formatDocURL({
|
|
47
|
+
collectionSlug,
|
|
48
|
+
defaultURL,
|
|
49
|
+
doc,
|
|
50
|
+
req,
|
|
51
|
+
viewType
|
|
52
|
+
});
|
|
53
|
+
if (customURL === null) {
|
|
54
|
+
// formatDocURL returned null = disable linking entirely
|
|
55
|
+
shouldLink = false;
|
|
56
|
+
} else if (typeof customURL === 'string') {
|
|
57
|
+
// formatDocURL returned a string = use custom URL
|
|
58
|
+
shouldLink = true;
|
|
59
|
+
customLinkURL = customURL;
|
|
60
|
+
} else {
|
|
61
|
+
// formatDocURL returned unexpected type = disable linking for safety
|
|
62
|
+
shouldLink = false;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
31
66
|
const cellClientProps = {
|
|
32
67
|
...baseCellClientProps,
|
|
33
68
|
cellData: 'name' in clientField ? findValueFromPath(doc, accessor) : undefined,
|
|
34
|
-
link:
|
|
69
|
+
link: shouldLink,
|
|
70
|
+
linkURL: customLinkURL,
|
|
35
71
|
rowData: doc
|
|
36
72
|
};
|
|
37
73
|
const cellServerProps = {
|
|
@@ -43,7 +79,8 @@ export function renderCell({
|
|
|
43
79
|
customCellProps: baseCellClientProps.customCellProps,
|
|
44
80
|
field: serverField,
|
|
45
81
|
i18n,
|
|
46
|
-
link:
|
|
82
|
+
link: shouldLink,
|
|
83
|
+
linkURL: customLinkURL,
|
|
47
84
|
onClick: baseCellClientProps.onClick,
|
|
48
85
|
payload,
|
|
49
86
|
rowData: doc
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderCell.js","names":["MissingEditorProp","RenderCustomComponent","RenderServerComponent","DefaultCell","RenderDefaultCell","hasOptionLabelJSXElement","findValueFromPath","renderCell","clientField","collectionSlug","columnIndex","customCellProps","doc","enableRowSelections","i18n","isLinkedColumn","payload","rowIndex","serverField","viewType","baseCellClientProps","cellData","undefined","field","rowData","accessor","name","cellClientProps","link","cellServerProps","className","collectionConfig","collections","config","onClick","CustomCell","type","editor","Error","admin","components","clientProps","Component","CellComponent","importMap","serverProps","CustomCellComponent","Cell","_jsx","CustomComponent","Fallback"],"sources":["../../../../src/providers/TableColumns/buildColumnState/renderCell.tsx"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type {\n ClientField,\n DefaultCellComponentProps,\n DefaultServerCellComponentProps,\n Document,\n Field,\n Payload,\n ViewTypes,\n} from 'payload'\n\nimport { MissingEditorProp } from 'payload'\n\nimport { RenderCustomComponent } from '../../../elements/RenderCustomComponent/index.js'\nimport { RenderServerComponent } from '../../../elements/RenderServerComponent/index.js'\nimport {\n DefaultCell,\n RenderDefaultCell,\n // eslint-disable-next-line payload/no-imports-from-exports-dir -- MUST reference the exports dir: https://github.com/payloadcms/payload/issues/12002#issuecomment-2791493587\n} from '../../../exports/client/index.js'\nimport { hasOptionLabelJSXElement } from '../../../utilities/hasOptionLabelJSXElement.js'\nimport { findValueFromPath } from './findValueFromPath.js'\n\ntype RenderCellArgs = {\n readonly clientField: ClientField\n readonly collectionSlug: string\n readonly columnIndex: number\n readonly customCellProps: DefaultCellComponentProps['customCellProps']\n readonly doc: Document\n readonly enableRowSelections: boolean\n readonly i18n: I18nClient\n readonly isLinkedColumn: boolean\n readonly payload: Payload\n readonly rowIndex: number\n readonly serverField: Field\n readonly viewType?: ViewTypes\n}\nexport function renderCell({\n clientField,\n collectionSlug,\n columnIndex,\n customCellProps,\n doc,\n enableRowSelections,\n i18n,\n isLinkedColumn,\n payload,\n rowIndex,\n serverField,\n viewType,\n}: RenderCellArgs) {\n const baseCellClientProps: DefaultCellComponentProps = {\n cellData: undefined,\n collectionSlug,\n customCellProps,\n field: clientField,\n rowData: undefined,\n viewType,\n }\n\n const accessor: string | undefined =\n ('accessor' in clientField ? (clientField.accessor as string) : undefined) ??\n ('name' in clientField ? clientField.name : undefined)\n\n const cellClientProps: DefaultCellComponentProps = {\n ...baseCellClientProps,\n cellData: 'name' in clientField ? findValueFromPath(doc, accessor) : undefined,\n link: isLinkedColumn,\n rowData: doc,\n }\n\n const cellServerProps: DefaultServerCellComponentProps = {\n cellData: cellClientProps.cellData,\n className: baseCellClientProps.className,\n collectionConfig: payload.collections[collectionSlug].config,\n collectionSlug,\n columnIndex,\n customCellProps: baseCellClientProps.customCellProps,\n field: serverField,\n i18n,\n link: cellClientProps.link,\n onClick: baseCellClientProps.onClick,\n payload,\n rowData: doc,\n }\n\n let CustomCell = null\n\n if (serverField?.type === 'richText') {\n if (!serverField?.editor) {\n throw new MissingEditorProp(serverField) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n\n if (typeof serverField?.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n\n if (!serverField.admin) {\n serverField.admin = {}\n }\n\n if (!serverField.admin.components) {\n serverField.admin.components = {}\n }\n\n CustomCell = RenderServerComponent({\n clientProps: cellClientProps,\n Component: serverField.editor.CellComponent,\n importMap: payload.importMap,\n serverProps: cellServerProps,\n })\n } else {\n const CustomCellComponent = serverField?.admin?.components?.Cell\n\n if (CustomCellComponent) {\n CustomCell = RenderServerComponent({\n clientProps: cellClientProps,\n Component: CustomCellComponent,\n importMap: payload.importMap,\n serverProps: cellServerProps,\n })\n } else if (\n cellClientProps.cellData &&\n cellClientProps.field &&\n hasOptionLabelJSXElement(cellClientProps)\n ) {\n CustomCell = RenderServerComponent({\n clientProps: cellClientProps,\n Component: DefaultCell,\n importMap: payload.importMap,\n })\n } else {\n const CustomCellComponent = serverField?.admin?.components?.Cell\n\n if (CustomCellComponent) {\n CustomCell = RenderServerComponent({\n clientProps: cellClientProps,\n Component: CustomCellComponent,\n importMap: payload.importMap,\n serverProps: cellServerProps,\n })\n } else {\n CustomCell = undefined\n }\n }\n }\n\n return (\n <RenderCustomComponent\n CustomComponent={CustomCell}\n Fallback={\n <RenderDefaultCell\n clientProps={cellClientProps}\n columnIndex={columnIndex}\n enableRowSelections={enableRowSelections}\n isLinkedColumn={isLinkedColumn}\n />\n }\n key={`${rowIndex}-${columnIndex}`}\n />\n )\n}\n"],"mappings":";AAWA,SAASA,iBAAiB,QAAQ;AAElC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,qBAAqB,QAAQ;AACtC,SACEC,WAAW,EACXC,iBAAiB,QAEZ;AACP,SAASC,wBAAwB,QAAQ;AACzC,SAASC,iBAAiB,QAAQ;AAgBlC,OAAO,SAASC,WAAW;EACzBC,WAAW;EACXC,cAAc;EACdC,WAAW;EACXC,eAAe;EACfC,GAAG;EACHC,mBAAmB;EACnBC,IAAI;EACJC,cAAc;EACdC,OAAO;EACPC,QAAQ;EACRC,WAAW;EACXC;AAAQ,CACO;EACf,MAAMC,mBAAA,GAAiD;IACrDC,QAAA,EAAUC,SAAA;IACVb,cAAA;IACAE,eAAA;IACAY,KAAA,EAAOf,WAAA;IACPgB,OAAA,EAASF,SAAA;IACTH;EACF;EAEA,MAAMM,QAAA,GACJ,CAAC,cAAcjB,WAAA,GAAeA,WAAA,CAAYiB,QAAQ,GAA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ell.js","names":["MissingEditorProp","formatAdminURL","RenderCustomComponent","RenderServerComponent","DefaultCell","RenderDefaultCell","hasOptionLabelJSXElement","findValueFromPath","renderCell","clientField","collectionSlug","columnIndex","customCellProps","doc","enableRowSelections","i18n","isLinkedColumn","payload","req","rowIndex","serverField","viewType","baseCellClientProps","cellData","undefined","field","rowData","accessor","name","shouldLink","customLinkURL","collectionConfig","collections","config","formatDocURL","admin","adminRoute","routes","defaultURL","path","encodeURIComponent","String","id","customURL","cellClientProps","link","linkURL","cellServerProps","className","onClick","CustomCell","type","editor","Error","components","clientProps","Component","CellComponent","importMap","serverProps","CustomCellComponent","Cell","_jsx","CustomComponent","Fallback"],"sources":["../../../../src/providers/TableColumns/buildColumnState/renderCell.tsx"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type {\n ClientField,\n DefaultCellComponentProps,\n DefaultServerCellComponentProps,\n Document,\n Field,\n Payload,\n PayloadRequest,\n ViewTypes,\n} from 'payload'\n\nimport { MissingEditorProp } from 'payload'\nimport { formatAdminURL } from 'payload/shared'\n\nimport { RenderCustomComponent } from '../../../elements/RenderCustomComponent/index.js'\nimport { RenderServerComponent } from '../../../elements/RenderServerComponent/index.js'\nimport {\n DefaultCell,\n RenderDefaultCell,\n // eslint-disable-next-line payload/no-imports-from-exports-dir -- MUST reference the exports dir: https://github.com/payloadcms/payload/issues/12002#issuecomment-2791493587\n} from '../../../exports/client/index.js'\nimport { hasOptionLabelJSXElement } from '../../../utilities/hasOptionLabelJSXElement.js'\nimport { findValueFromPath } from './findValueFromPath.js'\n\ntype RenderCellArgs = {\n readonly clientField: ClientField\n readonly collectionSlug: string\n readonly columnIndex: number\n readonly customCellProps: DefaultCellComponentProps['customCellProps']\n readonly doc: Document\n readonly enableRowSelections: boolean\n readonly i18n: I18nClient\n readonly isLinkedColumn: boolean\n readonly payload: Payload\n readonly req?: PayloadRequest\n readonly rowIndex: number\n readonly serverField: Field\n readonly viewType?: ViewTypes\n}\nexport function renderCell({\n clientField,\n collectionSlug,\n columnIndex,\n customCellProps,\n doc,\n enableRowSelections,\n i18n,\n isLinkedColumn,\n payload,\n req,\n rowIndex,\n serverField,\n viewType,\n}: RenderCellArgs) {\n const baseCellClientProps: DefaultCellComponentProps = {\n cellData: undefined,\n collectionSlug,\n customCellProps,\n field: clientField,\n rowData: undefined,\n viewType,\n }\n\n const accessor: string | undefined =\n ('accessor' in clientField ? (clientField.accessor as string) : undefined) ??\n ('name' in clientField ? clientField.name : undefined)\n\n // Check if there's a custom formatDocURL function for this linked column\n let shouldLink = isLinkedColumn\n let customLinkURL: string | undefined\n\n if (isLinkedColumn && req) {\n const collectionConfig = payload.collections[collectionSlug]?.config\n const formatDocURL = collectionConfig?.admin?.formatDocURL\n\n if (typeof formatDocURL === 'function') {\n // Generate the default URL that would normally be used\n const adminRoute = req.payload.config.routes?.admin || '/admin'\n const defaultURL = formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}${viewType === 'trash' ? '/trash' : ''}/${encodeURIComponent(String(doc.id))}`,\n })\n\n const customURL = formatDocURL({\n collectionSlug,\n defaultURL,\n doc,\n req,\n viewType,\n })\n\n if (customURL === null) {\n // formatDocURL returned null = disable linking entirely\n shouldLink = false\n } else if (typeof customURL === 'string') {\n // formatDocURL returned a string = use custom URL\n shouldLink = true\n customLinkURL = customURL\n } else {\n // formatDocURL returned unexpected type = disable linking for safety\n shouldLink = false\n }\n }\n }\n\n const cellClientProps: DefaultCellComponentProps = {\n ...baseCellClientProps,\n cellData: 'name' in clientField ? findValueFromPath(doc, accessor) : undefined,\n link: shouldLink,\n linkURL: customLinkURL,\n rowData: doc,\n }\n\n const cellServerProps: DefaultServerCellComponentProps = {\n cellData: cellClientProps.cellData,\n className: baseCellClientProps.className,\n collectionConfig: payload.collections[collectionSlug].config,\n collectionSlug,\n columnIndex,\n customCellProps: baseCellClientProps.customCellProps,\n field: serverField,\n i18n,\n link: shouldLink,\n linkURL: customLinkURL,\n onClick: baseCellClientProps.onClick,\n payload,\n rowData: doc,\n }\n\n let CustomCell = null\n\n if (serverField?.type === 'richText') {\n if (!serverField?.editor) {\n throw new MissingEditorProp(serverField) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n\n if (typeof serverField?.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n\n if (!serverField.admin) {\n serverField.admin = {}\n }\n\n if (!serverField.admin.components) {\n serverField.admin.components = {}\n }\n\n CustomCell = RenderServerComponent({\n clientProps: cellClientProps,\n Component: serverField.editor.CellComponent,\n importMap: payload.importMap,\n serverProps: cellServerProps,\n })\n } else {\n const CustomCellComponent = serverField?.admin?.components?.Cell\n\n if (CustomCellComponent) {\n CustomCell = RenderServerComponent({\n clientProps: cellClientProps,\n Component: CustomCellComponent,\n importMap: payload.importMap,\n serverProps: cellServerProps,\n })\n } else if (\n cellClientProps.cellData &&\n cellClientProps.field &&\n hasOptionLabelJSXElement(cellClientProps)\n ) {\n CustomCell = RenderServerComponent({\n clientProps: cellClientProps,\n Component: DefaultCell,\n importMap: payload.importMap,\n })\n } else {\n const CustomCellComponent = serverField?.admin?.components?.Cell\n\n if (CustomCellComponent) {\n CustomCell = RenderServerComponent({\n clientProps: cellClientProps,\n Component: CustomCellComponent,\n importMap: payload.importMap,\n serverProps: cellServerProps,\n })\n } else {\n CustomCell = undefined\n }\n }\n }\n\n return (\n <RenderCustomComponent\n CustomComponent={CustomCell}\n Fallback={\n <RenderDefaultCell\n clientProps={cellClientProps}\n columnIndex={columnIndex}\n enableRowSelections={enableRowSelections}\n isLinkedColumn={isLinkedColumn}\n />\n }\n key={`${rowIndex}-${columnIndex}`}\n />\n )\n}\n"],"mappings":";AAYA,SAASA,iBAAiB,QAAQ;AAClC,SAASC,cAAc,QAAQ;AAE/B,SAASC,qBAAqB,QAAQ;AACtC,SAASC,qBAAqB,QAAQ;AACtC,SACEC,WAAW,EACXC,iBAAiB,QAEZ;AACP,SAASC,wBAAwB,QAAQ;AACzC,SAASC,iBAAiB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