@payloadcms/ui 3.57.0-canary.6 → 3.57.0-internal.1d2ebbc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/dist/elements/BulkUpload/FileSidebar/index.d.ts.map +1 -1
  2. package/dist/elements/BulkUpload/FileSidebar/index.js +74 -38
  3. package/dist/elements/BulkUpload/FileSidebar/index.js.map +1 -1
  4. package/dist/elements/BulkUpload/FileSidebar/index.scss +14 -1
  5. package/dist/elements/BulkUpload/FormsManager/index.d.ts +6 -1
  6. package/dist/elements/BulkUpload/FormsManager/index.d.ts.map +1 -1
  7. package/dist/elements/BulkUpload/FormsManager/index.js +50 -14
  8. package/dist/elements/BulkUpload/FormsManager/index.js.map +1 -1
  9. package/dist/elements/BulkUpload/FormsManager/reducer.d.ts +2 -2
  10. package/dist/elements/BulkUpload/FormsManager/reducer.d.ts.map +1 -1
  11. package/dist/elements/BulkUpload/FormsManager/reducer.js +5 -5
  12. package/dist/elements/BulkUpload/FormsManager/reducer.js.map +1 -1
  13. package/dist/elements/BulkUpload/index.d.ts +27 -3
  14. package/dist/elements/BulkUpload/index.d.ts.map +1 -1
  15. package/dist/elements/BulkUpload/index.js +117 -28
  16. package/dist/elements/BulkUpload/index.js.map +1 -1
  17. package/dist/elements/LivePreview/IFrame/index.d.ts +7 -1
  18. package/dist/elements/LivePreview/IFrame/index.d.ts.map +1 -1
  19. package/dist/elements/LivePreview/IFrame/index.js +18 -39
  20. package/dist/elements/LivePreview/IFrame/index.js.map +1 -1
  21. package/dist/elements/LivePreview/Window/index.d.ts.map +1 -1
  22. package/dist/elements/LivePreview/Window/index.js +61 -135
  23. package/dist/elements/LivePreview/Window/index.js.map +1 -1
  24. package/dist/elements/SearchBar/index.scss +0 -4
  25. package/dist/elements/Status/index.d.ts.map +1 -1
  26. package/dist/elements/Status/index.js +1 -1
  27. package/dist/elements/Status/index.js.map +1 -1
  28. package/dist/elements/Table/RelationshipProvider/index.d.ts.map +1 -1
  29. package/dist/elements/Table/RelationshipProvider/index.js +28 -44
  30. package/dist/elements/Table/RelationshipProvider/index.js.map +1 -1
  31. package/dist/exports/client/index.js +24 -24
  32. package/dist/exports/client/index.js.map +4 -4
  33. package/dist/exports/rsc/index.d.ts +0 -1
  34. package/dist/exports/rsc/index.d.ts.map +1 -1
  35. package/dist/exports/rsc/index.js +0 -1
  36. package/dist/exports/rsc/index.js.map +1 -1
  37. package/dist/fields/Blocks/index.d.ts.map +1 -1
  38. package/dist/fields/Blocks/index.js +16 -36
  39. package/dist/fields/Blocks/index.js.map +1 -1
  40. package/dist/forms/Form/index.js +2 -1
  41. package/dist/forms/Form/index.js.map +1 -1
  42. package/dist/forms/Form/mergeServerFormState.d.ts.map +1 -1
  43. package/dist/forms/Form/mergeServerFormState.js +0 -8
  44. package/dist/forms/Form/mergeServerFormState.js.map +1 -1
  45. package/dist/forms/Form/types.d.ts +2 -2
  46. package/dist/forms/Form/types.d.ts.map +1 -1
  47. package/dist/forms/Form/types.js.map +1 -1
  48. package/dist/forms/RenderFields/RenderField.js +236 -223
  49. package/dist/forms/RenderFields/RenderField.js.map +1 -1
  50. package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.d.ts.map +1 -1
  51. package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.js +1 -32
  52. package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.js.map +1 -1
  53. package/dist/forms/fieldSchemasToFormState/renderField.d.ts.map +1 -1
  54. package/dist/forms/fieldSchemasToFormState/renderField.js +1 -2
  55. package/dist/forms/fieldSchemasToFormState/renderField.js.map +1 -1
  56. package/dist/forms/fieldSchemasToFormState/serverFunctions/renderFieldServerFn.d.ts.map +1 -1
  57. package/dist/forms/fieldSchemasToFormState/serverFunctions/renderFieldServerFn.js +0 -2
  58. package/dist/forms/fieldSchemasToFormState/serverFunctions/renderFieldServerFn.js.map +1 -1
  59. package/dist/forms/fieldSchemasToFormState/types.d.ts +0 -6
  60. package/dist/forms/fieldSchemasToFormState/types.d.ts.map +1 -1
  61. package/dist/forms/fieldSchemasToFormState/types.js.map +1 -1
  62. package/dist/forms/useField/index.d.ts.map +1 -1
  63. package/dist/forms/useField/index.js +73 -76
  64. package/dist/forms/useField/index.js.map +1 -1
  65. package/dist/forms/useField/types.d.ts +9 -5
  66. package/dist/forms/useField/types.d.ts.map +1 -1
  67. package/dist/forms/useField/types.js.map +1 -1
  68. package/dist/providers/LivePreview/context.d.ts +2 -17
  69. package/dist/providers/LivePreview/context.d.ts.map +1 -1
  70. package/dist/providers/LivePreview/context.js +2 -3
  71. package/dist/providers/LivePreview/context.js.map +1 -1
  72. package/dist/providers/LivePreview/index.d.ts +2 -2
  73. package/dist/providers/LivePreview/index.d.ts.map +1 -1
  74. package/dist/providers/LivePreview/index.js +19 -33
  75. package/dist/providers/LivePreview/index.js.map +1 -1
  76. package/dist/styles.css +1 -1
  77. package/dist/utilities/buildFormState.d.ts +0 -2
  78. package/dist/utilities/buildFormState.d.ts.map +1 -1
  79. package/dist/utilities/buildFormState.js +1 -20
  80. package/dist/utilities/buildFormState.js.map +1 -1
  81. package/dist/views/Edit/index.d.ts.map +1 -1
  82. package/dist/views/Edit/index.js +10 -17
  83. package/dist/views/Edit/index.js.map +1 -1
  84. package/package.json +4 -4
  85. package/dist/utilities/formatAbsoluteURL.d.ts +0 -8
  86. package/dist/utilities/formatAbsoluteURL.d.ts.map +0 -1
  87. package/dist/utilities/formatAbsoluteURL.js +0 -15
  88. package/dist/utilities/formatAbsoluteURL.js.map +0 -1
  89. package/dist/utilities/handleLivePreview.d.ts +0 -58
  90. package/dist/utilities/handleLivePreview.d.ts.map +0 -1
  91. package/dist/utilities/handleLivePreview.js +0 -96
  92. package/dist/utilities/handleLivePreview.js.map +0 -1
@@ -6,17 +6,22 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
6
6
  import { usePopupWindow } from '../../hooks/usePopupWindow.js';
7
7
  import { useDocumentInfo } from '../../providers/DocumentInfo/index.js';
8
8
  import { usePreferences } from '../../providers/Preferences/index.js';
9
- import { formatAbsoluteURL } from '../../utilities/formatAbsoluteURL.js';
10
9
  import { customCollisionDetection } from './collisionDetection.js';
11
10
  import { LivePreviewContext } from './context.js';
12
11
  import { sizeReducer } from './sizeReducer.js';
12
+ const getAbsoluteUrl = url => {
13
+ try {
14
+ return new URL(url, window.location.origin).href;
15
+ } catch {
16
+ return url;
17
+ }
18
+ };
13
19
  export const LivePreviewProvider = ({
14
20
  breakpoints: incomingBreakpoints,
15
21
  children,
16
22
  isLivePreviewEnabled,
17
23
  isLivePreviewing: incomingIsLivePreviewing,
18
- typeofLivePreviewURL,
19
- url: urlFromProps
24
+ url: incomingUrl
20
25
  }) => {
21
26
  const [previewWindowType, setPreviewWindowType] = useState('iframe');
22
27
  const [isLivePreviewing, setIsLivePreviewing] = useState(incomingIsLivePreviewing);
@@ -27,6 +32,10 @@ export const LivePreviewProvider = ({
27
32
  width: '100%'
28
33
  }], [incomingBreakpoints]);
29
34
  const [url, setURL] = useState('');
35
+ // This needs to be done in a useEffect to prevent hydration issues
36
+ // as the URL may not be absolute when passed in as a prop,
37
+ // and getAbsoluteUrl requires the window object to be available
38
+ useEffect(() => setURL(incomingUrl?.startsWith('http://') || incomingUrl?.startsWith('https://') ? incomingUrl : getAbsoluteUrl(incomingUrl)), [incomingUrl]);
30
39
  const {
31
40
  isPopupOpen,
32
41
  openPopupWindow,
@@ -46,7 +55,7 @@ export const LivePreviewProvider = ({
46
55
  setPreference
47
56
  } = usePreferences();
48
57
  const iframeRef = React.useRef(null);
49
- const [loadedURL, setLoadedURL] = useState();
58
+ const [iframeHasLoaded, setIframeHasLoaded] = useState(false);
50
59
  const [zoom, setZoom] = useState(1);
51
60
  const [position, setPosition] = useState({
52
61
  x: 0,
@@ -61,25 +70,6 @@ export const LivePreviewProvider = ({
61
70
  width: 0
62
71
  });
63
72
  const [breakpoint, setBreakpoint] = React.useState('responsive');
64
- /**
65
- * A "middleware" callback fn that does some additional work before `setURL`.
66
- * This is what we provide through context, bc it:
67
- * - ensures the URL is absolute
68
- * - resets `appIsReady` to `false` while the new URL is loading
69
- */
70
- const setLivePreviewURL = useCallback(_incomingURL => {
71
- const incomingURL = formatAbsoluteURL(_incomingURL);
72
- if (incomingURL !== url) {
73
- setAppIsReady(false);
74
- setURL(incomingURL);
75
- }
76
- }, [url]);
77
- /**
78
- * `url` needs to be relative to the window, which cannot be done on initial render.
79
- */
80
- useEffect(() => {
81
- setURL(formatAbsoluteURL(urlFromProps));
82
- }, [urlFromProps]);
83
73
  // The toolbar needs to freely drag and drop around the page
84
74
  const handleDragEnd = ev => {
85
75
  // only update position if the toolbar is completely within the preview area
@@ -121,12 +111,10 @@ export const LivePreviewProvider = ({
121
111
  });
122
112
  }
123
113
  }, [breakpoint, breakpoints]);
124
- /**
125
- * Receive the `ready` message from the popup window
126
- * This indicates that the app is ready to receive `window.postMessage` events
127
- * This is also the only cross-origin way of detecting when a popup window has loaded
128
- * Unlike iframe elements which have an `onLoad` handler, there is no way to access `window.open` on popups
129
- */
114
+ // Receive the `ready` message from the popup window
115
+ // This indicates that the app is ready to receive `window.postMessage` events
116
+ // This is also the only cross-origin way of detecting when a popup window has loaded
117
+ // Unlike iframe elements which have an `onLoad` handler, there is no way to access `window.open` on popups
130
118
  useEffect(() => {
131
119
  const handleMessage = event => {
132
120
  if (url?.startsWith(event.origin) && event.data && typeof event.data === 'object' && event.data.type === 'payload-live-preview') {
@@ -170,12 +158,12 @@ export const LivePreviewProvider = ({
170
158
  appIsReady,
171
159
  breakpoint,
172
160
  breakpoints,
161
+ iframeHasLoaded,
173
162
  iframeRef,
174
163
  isLivePreviewEnabled,
175
164
  isLivePreviewing,
176
165
  isPopupOpen,
177
166
  listeningForMessages,
178
- loadedURL,
179
167
  measuredDeviceSize,
180
168
  openPopupWindow,
181
169
  popupRef,
@@ -183,18 +171,16 @@ export const LivePreviewProvider = ({
183
171
  setAppIsReady,
184
172
  setBreakpoint,
185
173
  setHeight,
174
+ setIframeHasLoaded,
186
175
  setIsLivePreviewing,
187
- setLoadedURL,
188
176
  setMeasuredDeviceSize,
189
177
  setPreviewWindowType: handleWindowChange,
190
178
  setSize,
191
179
  setToolbarPosition: setPosition,
192
- setURL: setLivePreviewURL,
193
180
  setWidth,
194
181
  setZoom,
195
182
  size,
196
183
  toolbarPosition: position,
197
- typeofLivePreviewURL,
198
184
  url,
199
185
  zoom
200
186
  },
@@ -1 +1 @@
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,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAIzE,SAASC,cAAc,QAAQ;AAC/B,SAASC,eAAe,QAAQ;AAChC,SAASC,cAAc,QAAQ;AAC/B,SAASC,iBAAiB,QAAQ;AAClC,SAASC,wBAAwB,QAAQ;AACzC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,WAAW,QAAQ;AAc5B,OAAO,MAAMC,mBAAA,GAA0DA,CAAC;EACtEC,WAAA,EAAaC,mBAAmB;EAChCC,QAAQ;EACRC,oBAAoB;EACpBC,gBAAA,EAAkBC,wBAAwB;EAC1CC,oBAAoB;EACpBC,GAAA,EAAKC;AAAY,CAClB;EACC,MAAM,CAACC,iBAAA,EAAmBC,oBAAA,CAAqB,GAAGnB,QAAA,CAA6B;EAC/E,MAAM,CAACa,gBAAA,EAAkBO,mBAAA,CAAoB,GAAGpB,QAAA,CAASc,wBAAA;EAEzD,MAAML,WAAA,GAAgDX,OAAA,CACpD,MAAM,C,IACAY,mBAAA,IAAuB,EAAE,GAC7B;IACEW,IAAA,EAAM;IACNC,MAAA,EAAQ;IACRC,KAAA,EAAO;IACPC,KAAA,EAAO;EACT,EACD,EACD,CAACd,mBAAA,CAAoB;EAGvB,MAAM,CAACM,GAAA,EAAKS,MAAA,CAAO,GAAGzB,QAAA,CAAiB;EAEvC,MAAM;IAAE0B,WAAW;IAAEC,eAAe;IAAEC;EAAQ,CAAE,GAAG3B,cAAA,CAAe;IAChE4B,SAAA,EAAW;IACXb;EACF;EAEA,MAAM,CAACc,UAAA,EAAYC,aAAA,CAAc,GAAG/B,QAAA,CAAS;EAC7C,MAAM,CAACgC,oBAAA,EAAsBC,uBAAA,CAAwB,GAAGjC,QAAA,CAA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MACAO,SAAA;MACAW,kBAAA;MACAvB,eAAA;MACAC,QAAA;MACAV,iBAAA;MACAa,aAAA;MACAsB,aAAA;MACAa,SAAA;MACA9C,mBAAA;MACAoB,YAAA;MACAW,qBAAA;MACAhC,oBAAA,EAAsB4D,kBAAA;MACtB/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
+ {"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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