@payloadcms/ui 3.44.0 → 3.45.0-canary.1
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/Button/index.d.ts.map +1 -1
- package/dist/elements/Button/index.js +2 -1
- package/dist/elements/Button/index.js.map +1 -1
- package/dist/elements/Button/index.scss +2 -2
- package/dist/elements/DocumentControls/index.d.ts +1 -0
- package/dist/elements/DocumentControls/index.d.ts.map +1 -1
- package/dist/elements/DocumentControls/index.js +26 -11
- package/dist/elements/DocumentControls/index.js.map +1 -1
- package/dist/elements/DocumentFields/index.d.ts.map +1 -1
- package/dist/elements/DocumentFields/index.js.map +1 -1
- package/dist/elements/LivePreview/Device/index.d.ts +5 -0
- package/dist/elements/LivePreview/Device/index.d.ts.map +1 -0
- package/dist/elements/LivePreview/Device/index.js +92 -0
- package/dist/elements/LivePreview/Device/index.js.map +1 -0
- package/dist/elements/LivePreview/DeviceContainer/index.d.ts +5 -0
- package/dist/elements/LivePreview/DeviceContainer/index.d.ts.map +1 -0
- package/dist/elements/LivePreview/DeviceContainer/index.js +55 -0
- package/dist/elements/LivePreview/DeviceContainer/index.js.map +1 -0
- package/dist/elements/LivePreview/IFrame/index.d.ts +10 -0
- package/dist/elements/LivePreview/IFrame/index.d.ts.map +1 -0
- package/dist/elements/LivePreview/IFrame/index.js +30 -0
- package/dist/elements/LivePreview/IFrame/index.js.map +1 -0
- package/dist/elements/LivePreview/IFrame/index.scss +9 -0
- package/dist/elements/LivePreview/Toggler/index.d.ts +4 -0
- package/dist/elements/LivePreview/Toggler/index.d.ts.map +1 -0
- package/dist/elements/LivePreview/Toggler/index.js +30 -0
- package/dist/elements/LivePreview/Toggler/index.js.map +1 -0
- package/dist/elements/LivePreview/Toggler/index.scss +48 -0
- package/dist/elements/LivePreview/Toolbar/Controls/index.d.ts +5 -0
- package/dist/elements/LivePreview/Toolbar/Controls/index.d.ts.map +1 -0
- package/dist/elements/LivePreview/Toolbar/Controls/index.js +157 -0
- package/dist/elements/LivePreview/Toolbar/Controls/index.js.map +1 -0
- package/dist/elements/LivePreview/Toolbar/Controls/index.scss +61 -0
- package/dist/elements/LivePreview/Toolbar/SizeInput/index.d.ts +6 -0
- package/dist/elements/LivePreview/Toolbar/SizeInput/index.d.ts.map +1 -0
- package/dist/elements/LivePreview/Toolbar/SizeInput/index.js +101 -0
- package/dist/elements/LivePreview/Toolbar/SizeInput/index.js.map +1 -0
- package/dist/elements/LivePreview/Toolbar/SizeInput/index.scss +12 -0
- package/dist/elements/LivePreview/Toolbar/index.d.ts +7 -0
- package/dist/elements/LivePreview/Toolbar/index.d.ts.map +1 -0
- package/dist/elements/LivePreview/Toolbar/index.js +97 -0
- package/dist/elements/LivePreview/Toolbar/index.js.map +1 -0
- package/dist/elements/LivePreview/Toolbar/index.scss +43 -0
- package/dist/elements/LivePreview/ToolbarArea/index.d.ts +6 -0
- package/dist/elements/LivePreview/ToolbarArea/index.d.ts.map +1 -0
- package/dist/elements/LivePreview/ToolbarArea/index.js +41 -0
- package/dist/elements/LivePreview/ToolbarArea/index.js.map +1 -0
- package/dist/elements/LivePreview/ToolbarArea/index.scss +6 -0
- package/dist/elements/LivePreview/Window/index.d.ts +5 -0
- package/dist/elements/LivePreview/Window/index.d.ts.map +1 -0
- package/dist/elements/LivePreview/Window/index.js +182 -0
- package/dist/elements/LivePreview/Window/index.js.map +1 -0
- package/dist/elements/LivePreview/Window/index.scss +48 -0
- package/dist/elements/PreviewButton/index.d.ts +1 -0
- package/dist/elements/PreviewButton/index.d.ts.map +1 -1
- package/dist/elements/PreviewButton/index.js +13 -10
- package/dist/elements/PreviewButton/index.js.map +1 -1
- package/dist/elements/PreviewButton/index.scss +39 -0
- package/dist/elements/PreviewButton/usePreviewURL.d.ts.map +1 -1
- package/dist/elements/PreviewButton/usePreviewURL.js +1 -1
- package/dist/elements/PreviewButton/usePreviewURL.js.map +1 -1
- package/dist/exports/client/index.d.ts +2 -1
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +22 -22
- package/dist/exports/client/index.js.map +4 -4
- package/dist/exports/shared/index.js +1 -1
- package/dist/exports/shared/index.js.map +2 -2
- package/dist/forms/Form/index.d.ts.map +1 -1
- package/dist/forms/Form/index.js +1 -1
- package/dist/forms/Form/index.js.map +1 -1
- package/dist/forms/Form/mergeServerFormState.js +1 -1
- package/dist/forms/Form/mergeServerFormState.js.map +1 -1
- package/dist/hooks/usePopupWindow.d.ts +20 -0
- package/dist/hooks/usePopupWindow.d.ts.map +1 -0
- package/dist/hooks/usePopupWindow.js +144 -0
- package/dist/hooks/usePopupWindow.js.map +1 -0
- package/dist/icons/ExternalLink/index.d.ts.map +1 -0
- package/dist/icons/ExternalLink/index.js.map +1 -0
- package/dist/icons/Eye/index.d.ts +7 -0
- package/dist/icons/Eye/index.d.ts.map +1 -0
- package/dist/icons/Eye/index.js +28 -0
- package/dist/icons/Eye/index.js.map +1 -0
- package/dist/icons/Eye/index.scss +20 -0
- package/dist/providers/LivePreview/collisionDetection.d.ts +3 -0
- package/dist/providers/LivePreview/collisionDetection.d.ts.map +1 -0
- package/dist/providers/LivePreview/collisionDetection.js +29 -0
- package/dist/providers/LivePreview/collisionDetection.js.map +1 -0
- package/dist/providers/LivePreview/context.d.ts +55 -0
- package/dist/providers/LivePreview/context.d.ts.map +1 -0
- package/dist/providers/LivePreview/context.js +44 -0
- package/dist/providers/LivePreview/context.js.map +1 -0
- package/dist/providers/LivePreview/index.d.ts +16 -0
- package/dist/providers/LivePreview/index.d.ts.map +1 -0
- package/dist/providers/LivePreview/index.js +206 -0
- package/dist/providers/LivePreview/index.js.map +1 -0
- package/dist/providers/LivePreview/index.scss +68 -0
- package/dist/providers/LivePreview/sizeReducer.d.ts +20 -0
- package/dist/providers/LivePreview/sizeReducer.d.ts.map +1 -0
- package/dist/providers/LivePreview/sizeReducer.js +30 -0
- package/dist/providers/LivePreview/sizeReducer.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/utilities/formatDocTitle/index.js +2 -2
- package/dist/utilities/formatDocTitle/index.js.map +1 -1
- package/dist/views/Edit/index.d.ts.map +1 -1
- package/dist/views/Edit/index.js +52 -41
- package/dist/views/Edit/index.js.map +1 -1
- package/dist/views/Edit/index.scss +39 -1
- package/package.json +5 -5
- package/dist/graphics/ExternalLink/index.d.ts.map +0 -1
- package/dist/graphics/ExternalLink/index.js.map +0 -1
- /package/dist/{graphics → icons}/ExternalLink/index.d.ts +0 -0
- /package/dist/{graphics → icons}/ExternalLink/index.js +0 -0
- /package/dist/{graphics → icons}/ExternalLink/index.scss +0 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { LivePreviewConfig } from 'payload';
|
|
2
|
+
import type { fieldSchemaToJSON } from 'payload/shared';
|
|
3
|
+
import type { Dispatch } from 'react';
|
|
4
|
+
import type React from 'react';
|
|
5
|
+
import type { usePopupWindow } from '../../hooks/usePopupWindow.js';
|
|
6
|
+
import type { SizeReducerAction } from './sizeReducer.js';
|
|
7
|
+
export interface LivePreviewContextType {
|
|
8
|
+
appIsReady: boolean;
|
|
9
|
+
breakpoint: LivePreviewConfig['breakpoints'][number]['name'];
|
|
10
|
+
breakpoints: LivePreviewConfig['breakpoints'];
|
|
11
|
+
fieldSchemaJSON?: ReturnType<typeof fieldSchemaToJSON>;
|
|
12
|
+
iframeHasLoaded: boolean;
|
|
13
|
+
iframeRef: React.RefObject<HTMLIFrameElement | null>;
|
|
14
|
+
isLivePreviewEnabled: boolean;
|
|
15
|
+
isLivePreviewing: boolean;
|
|
16
|
+
isPopupOpen: boolean;
|
|
17
|
+
listeningForMessages?: boolean;
|
|
18
|
+
measuredDeviceSize: {
|
|
19
|
+
height: number;
|
|
20
|
+
width: number;
|
|
21
|
+
};
|
|
22
|
+
openPopupWindow: ReturnType<typeof usePopupWindow>['openPopupWindow'];
|
|
23
|
+
popupRef?: React.RefObject<null | Window>;
|
|
24
|
+
previewWindowType: 'iframe' | 'popup';
|
|
25
|
+
setAppIsReady: (appIsReady: boolean) => void;
|
|
26
|
+
setBreakpoint: (breakpoint: LivePreviewConfig['breakpoints'][number]['name']) => void;
|
|
27
|
+
setHeight: (height: number) => void;
|
|
28
|
+
setIframeHasLoaded: (loaded: boolean) => void;
|
|
29
|
+
setIsLivePreviewing: (isLivePreviewing: boolean) => void;
|
|
30
|
+
setMeasuredDeviceSize: (size: {
|
|
31
|
+
height: number;
|
|
32
|
+
width: number;
|
|
33
|
+
}) => void;
|
|
34
|
+
setPreviewWindowType: (previewWindowType: 'iframe' | 'popup') => void;
|
|
35
|
+
setSize: Dispatch<SizeReducerAction>;
|
|
36
|
+
setToolbarPosition: (position: {
|
|
37
|
+
x: number;
|
|
38
|
+
y: number;
|
|
39
|
+
}) => void;
|
|
40
|
+
setWidth: (width: number) => void;
|
|
41
|
+
setZoom: (zoom: number) => void;
|
|
42
|
+
size: {
|
|
43
|
+
height: number;
|
|
44
|
+
width: number;
|
|
45
|
+
};
|
|
46
|
+
toolbarPosition: {
|
|
47
|
+
x: number;
|
|
48
|
+
y: number;
|
|
49
|
+
};
|
|
50
|
+
url: string | undefined;
|
|
51
|
+
zoom: number;
|
|
52
|
+
}
|
|
53
|
+
export declare const LivePreviewContext: React.Context<LivePreviewContextType>;
|
|
54
|
+
export declare const useLivePreviewContext: () => LivePreviewContextType;
|
|
55
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/providers/LivePreview/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAChD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAA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EAAE,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;IACxE,oBAAoB,EAAE,CAAC,iBAAiB,EAAE,QAAQ,GAAG,OAAO,KAAK,IAAI,CAAA;IACrE,OAAO,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAAA;IACpC,kBAAkB,EAAE,CAAC,QAAQ,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;IAChE,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACjC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAC/B,IAAI,EAAE;QACJ,MAAM,EAAE,MAAM,CAAA;QACd,KAAK,EAAE,MAAM,CAAA;KACd,CAAA;IACD,eAAe,EAAE;QACf,CAAC,EAAE,MAAM,CAAA;QACT,CAAC,EAAE,MAAM,CAAA;KACV,CAAA;IACD,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;IACvB,IAAI,EAAE,MAAM,CAAA;CACb;AAED,eAAO,MAAM,kBAAkB,uCAsC7B,CAAA;AAEF,eAAO,MAAM,qBAAqB,8BAAgC,CAAA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { createContext, use } from 'react';
|
|
4
|
+
export const LivePreviewContext = createContext({
|
|
5
|
+
appIsReady: false,
|
|
6
|
+
breakpoint: undefined,
|
|
7
|
+
breakpoints: undefined,
|
|
8
|
+
fieldSchemaJSON: undefined,
|
|
9
|
+
iframeHasLoaded: false,
|
|
10
|
+
iframeRef: undefined,
|
|
11
|
+
isLivePreviewEnabled: undefined,
|
|
12
|
+
isLivePreviewing: false,
|
|
13
|
+
isPopupOpen: false,
|
|
14
|
+
measuredDeviceSize: {
|
|
15
|
+
height: 0,
|
|
16
|
+
width: 0
|
|
17
|
+
},
|
|
18
|
+
openPopupWindow: () => {},
|
|
19
|
+
popupRef: undefined,
|
|
20
|
+
previewWindowType: 'iframe',
|
|
21
|
+
setAppIsReady: () => {},
|
|
22
|
+
setBreakpoint: () => {},
|
|
23
|
+
setHeight: () => {},
|
|
24
|
+
setIframeHasLoaded: () => {},
|
|
25
|
+
setIsLivePreviewing: () => {},
|
|
26
|
+
setMeasuredDeviceSize: () => {},
|
|
27
|
+
setPreviewWindowType: () => {},
|
|
28
|
+
setSize: () => {},
|
|
29
|
+
setToolbarPosition: () => {},
|
|
30
|
+
setWidth: () => {},
|
|
31
|
+
setZoom: () => {},
|
|
32
|
+
size: {
|
|
33
|
+
height: 0,
|
|
34
|
+
width: 0
|
|
35
|
+
},
|
|
36
|
+
toolbarPosition: {
|
|
37
|
+
x: 0,
|
|
38
|
+
y: 0
|
|
39
|
+
},
|
|
40
|
+
url: undefined,
|
|
41
|
+
zoom: 1
|
|
42
|
+
});
|
|
43
|
+
export const useLivePreviewContext = () => use(LivePreviewContext);
|
|
44
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","names":["createContext","use","LivePreviewContext","appIsReady","breakpoint","undefined","breakpoints","fieldSchemaJSON","iframeHasLoaded","iframeRef","isLivePreviewEnabled","isLivePreviewing","isPopupOpen","measuredDeviceSize","height","width","openPopupWindow","popupRef","previewWindowType","setAppIsReady","setBreakpoint","setHeight","setIframeHasLoaded","setIsLivePreviewing","setMeasuredDeviceSize","setPreviewWindowType","setSize","setToolbarPosition","setWidth","setZoom","size","toolbarPosition","x","y","url","zoom","useLivePreviewContext"],"sources":["../../../src/providers/LivePreview/context.ts"],"sourcesContent":["'use client'\nimport type { LivePreviewConfig } from 'payload'\nimport type { fieldSchemaToJSON } from 'payload/shared'\nimport type { Dispatch } from 'react'\nimport type React from 'react'\n\nimport { createContext, use } from 'react'\n\nimport type { usePopupWindow } from '../../hooks/usePopupWindow.js'\nimport type { SizeReducerAction } from './sizeReducer.js'\n\nexport interface LivePreviewContextType {\n appIsReady: boolean\n breakpoint: LivePreviewConfig['breakpoints'][number]['name']\n breakpoints: LivePreviewConfig['breakpoints']\n fieldSchemaJSON?: ReturnType<typeof fieldSchemaToJSON>\n iframeHasLoaded: boolean\n iframeRef: React.RefObject<HTMLIFrameElement | null>\n isLivePreviewEnabled: boolean\n isLivePreviewing: boolean\n isPopupOpen: boolean\n listeningForMessages?: boolean\n measuredDeviceSize: {\n height: number\n width: number\n }\n openPopupWindow: ReturnType<typeof usePopupWindow>['openPopupWindow']\n popupRef?: React.RefObject<null | Window>\n previewWindowType: 'iframe' | 'popup'\n setAppIsReady: (appIsReady: boolean) => void\n setBreakpoint: (breakpoint: LivePreviewConfig['breakpoints'][number]['name']) => void\n setHeight: (height: number) => void\n setIframeHasLoaded: (loaded: boolean) => void\n setIsLivePreviewing: (isLivePreviewing: boolean) => void\n setMeasuredDeviceSize: (size: { height: number; width: number }) => void\n setPreviewWindowType: (previewWindowType: 'iframe' | 'popup') => void\n setSize: Dispatch<SizeReducerAction>\n setToolbarPosition: (position: { x: number; y: number }) => void\n setWidth: (width: number) => void\n setZoom: (zoom: number) => void\n size: {\n height: number\n width: number\n }\n toolbarPosition: {\n x: number\n y: number\n }\n url: string | undefined\n zoom: number\n}\n\nexport const LivePreviewContext = createContext<LivePreviewContextType>({\n appIsReady: false,\n breakpoint: undefined,\n breakpoints: undefined,\n fieldSchemaJSON: undefined,\n iframeHasLoaded: false,\n iframeRef: undefined,\n isLivePreviewEnabled: undefined,\n isLivePreviewing: false,\n isPopupOpen: false,\n measuredDeviceSize: {\n height: 0,\n width: 0,\n },\n openPopupWindow: () => {},\n popupRef: undefined,\n previewWindowType: 'iframe',\n setAppIsReady: () => {},\n setBreakpoint: () => {},\n setHeight: () => {},\n setIframeHasLoaded: () => {},\n setIsLivePreviewing: () => {},\n setMeasuredDeviceSize: () => {},\n setPreviewWindowType: () => {},\n setSize: () => {},\n setToolbarPosition: () => {},\n setWidth: () => {},\n setZoom: () => {},\n size: {\n height: 0,\n width: 0,\n },\n toolbarPosition: {\n x: 0,\n y: 0,\n },\n url: undefined,\n zoom: 1,\n})\n\nexport const useLivePreviewContext = () => use(LivePreviewContext)\n"],"mappings":"AAAA;;AAMA,SAASA,aAAa,EAAEC,GAAG,QAAQ;AA8CnC,OAAO,MAAMC,kBAAA,GAAqBF,aAAA,CAAsC;EACtEG,UAAA,EAAY;EACZC,UAAA,EAAYC,SAAA;EACZC,WAAA,EAAaD,SAAA;EACbE,eAAA,EAAiBF,SAAA;EACjBG,eAAA,EAAiB;EACjBC,SAAA,EAAWJ,SAAA;EACXK,oBAAA,EAAsBL,SAAA;EACtBM,gBAAA,EAAkB;EAClBC,WAAA,EAAa;EACbC,kBAAA,EAAoB;IAClBC,MAAA,EAAQ;IACRC,KAAA,EAAO;EACT;EACAC,eAAA,EAAiBA,CAAA,MAAO;EACxBC,QAAA,EAAUZ,SAAA;EACVa,iBAAA,EAAmB;EACnBC,aAAA,EAAeA,CAAA,MAAO;EACtBC,aAAA,EAAeA,CAAA,MAAO;EACtBC,SAAA,EAAWA,CAAA,MAAO;EAClBC,kBAAA,EAAoBA,CAAA,MAAO;EAC3BC,mBAAA,EAAqBA,CAAA,MAAO;EAC5BC,qBAAA,EAAuBA,CAAA,MAAO;EAC9BC,oBAAA,EAAsBA,CAAA,MAAO;EAC7BC,OAAA,EAASA,CAAA,MAAO;EAChBC,kBAAA,EAAoBA,CAAA,MAAO;EAC3BC,QAAA,EAAUA,CAAA,MAAO;EACjBC,OAAA,EAASA,CAAA,MAAO;EAChBC,IAAA,EAAM;IACJhB,MAAA,EAAQ;IACRC,KAAA,EAAO;EACT;EACAgB,eAAA,EAAiB;IACfC,CAAA,EAAG;IACHC,CAAA,EAAG;EACL;EACAC,GAAA,EAAK7B,SAAA;EACL8B,IAAA,EAAM;AACR;AAEA,OAAO,MAAMC,qBAAA,GAAwBA,CAAA,KAAMnC,GAAA,CAAIC,kBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { LivePreviewConfig } from 'payload';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export type LivePreviewProviderProps = {
|
|
4
|
+
appIsReady?: boolean;
|
|
5
|
+
breakpoints?: LivePreviewConfig['breakpoints'];
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
deviceSize?: {
|
|
8
|
+
height: number;
|
|
9
|
+
width: number;
|
|
10
|
+
};
|
|
11
|
+
isLivePreviewing: boolean;
|
|
12
|
+
operation?: 'create' | 'update';
|
|
13
|
+
url: string;
|
|
14
|
+
};
|
|
15
|
+
export declare const LivePreviewProvider: React.FC<LivePreviewProviderProps>;
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/LivePreview/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAyB,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAIvE,OAAO,KAA4D,MAAM,OAAO,CAAA;AAUhF,MAAM,MAAM,wBAAwB,GAAG;IACrC,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,WAAW,CAAC,EAAE,iBAAiB,CAAC,aAAa,CAAC,CAAA;IAC9C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,UAAU,CAAC,EAAE;QACX,MAAM,EAAE,MAAM,CAAA;QACd,KAAK,EAAE,MAAM,CAAA;KACd,CAAA;IACD,gBAAgB,EAAE,OAAO,CAAA;IACzB,SAAS,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC/B,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAUD,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CA6OlE,CAAA"}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
import { DndContext } from '@dnd-kit/core';
|
|
5
|
+
import { fieldSchemaToJSON } from 'payload/shared';
|
|
6
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
7
|
+
import { usePopupWindow } from '../../hooks/usePopupWindow.js';
|
|
8
|
+
import { useDocumentInfo } from '../../providers/DocumentInfo/index.js';
|
|
9
|
+
import { usePreferences } from '../../providers/Preferences/index.js';
|
|
10
|
+
import { useConfig } from '../Config/index.js';
|
|
11
|
+
import { customCollisionDetection } from './collisionDetection.js';
|
|
12
|
+
import { LivePreviewContext } from './context.js';
|
|
13
|
+
import { sizeReducer } from './sizeReducer.js';
|
|
14
|
+
const getAbsoluteUrl = url => {
|
|
15
|
+
try {
|
|
16
|
+
return new URL(url, window.location.origin).href;
|
|
17
|
+
} catch {
|
|
18
|
+
return url;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
export const LivePreviewProvider = ({
|
|
22
|
+
breakpoints: incomingBreakpoints,
|
|
23
|
+
children,
|
|
24
|
+
isLivePreviewing: incomingIsLivePreviewing,
|
|
25
|
+
operation,
|
|
26
|
+
url: incomingUrl
|
|
27
|
+
}) => {
|
|
28
|
+
const [previewWindowType, setPreviewWindowType] = useState('iframe');
|
|
29
|
+
const [isLivePreviewing, setIsLivePreviewing] = useState(incomingIsLivePreviewing);
|
|
30
|
+
const breakpoints = useMemo(() => [...(incomingBreakpoints || []), {
|
|
31
|
+
name: 'responsive',
|
|
32
|
+
height: '100%',
|
|
33
|
+
label: 'Responsive',
|
|
34
|
+
width: '100%'
|
|
35
|
+
}], [incomingBreakpoints]);
|
|
36
|
+
const [url, setURL] = useState('');
|
|
37
|
+
// This needs to be done in a useEffect to prevent hydration issues
|
|
38
|
+
// as the URL may not be absolute when passed in as a prop,
|
|
39
|
+
// and getAbsoluteUrl requires the window object to be available
|
|
40
|
+
useEffect(() => setURL(incomingUrl?.startsWith('http://') || incomingUrl?.startsWith('https://') ? incomingUrl : getAbsoluteUrl(incomingUrl)), [incomingUrl]);
|
|
41
|
+
const {
|
|
42
|
+
isPopupOpen,
|
|
43
|
+
openPopupWindow,
|
|
44
|
+
popupRef
|
|
45
|
+
} = usePopupWindow({
|
|
46
|
+
eventType: 'payload-live-preview',
|
|
47
|
+
url
|
|
48
|
+
});
|
|
49
|
+
const [appIsReady, setAppIsReady] = useState(false);
|
|
50
|
+
const [listeningForMessages, setListeningForMessages] = useState(false);
|
|
51
|
+
const {
|
|
52
|
+
collectionSlug,
|
|
53
|
+
globalSlug
|
|
54
|
+
} = useDocumentInfo();
|
|
55
|
+
const isFirstRender = useRef(true);
|
|
56
|
+
const {
|
|
57
|
+
setPreference
|
|
58
|
+
} = usePreferences();
|
|
59
|
+
const iframeRef = React.useRef(null);
|
|
60
|
+
const [iframeHasLoaded, setIframeHasLoaded] = useState(false);
|
|
61
|
+
const {
|
|
62
|
+
config,
|
|
63
|
+
getEntityConfig
|
|
64
|
+
} = useConfig();
|
|
65
|
+
const [zoom, setZoom] = useState(1);
|
|
66
|
+
const [position, setPosition] = useState({
|
|
67
|
+
x: 0,
|
|
68
|
+
y: 0
|
|
69
|
+
});
|
|
70
|
+
const [size, setSize] = React.useReducer(sizeReducer, {
|
|
71
|
+
height: 0,
|
|
72
|
+
width: 0
|
|
73
|
+
});
|
|
74
|
+
const [measuredDeviceSize, setMeasuredDeviceSize] = useState({
|
|
75
|
+
height: 0,
|
|
76
|
+
width: 0
|
|
77
|
+
});
|
|
78
|
+
const entityConfig = getEntityConfig({
|
|
79
|
+
collectionSlug,
|
|
80
|
+
globalSlug
|
|
81
|
+
});
|
|
82
|
+
const [breakpoint, setBreakpoint] = React.useState('responsive');
|
|
83
|
+
const [fieldSchemaJSON] = useState(() => fieldSchemaToJSON(entityConfig?.fields || [], config));
|
|
84
|
+
// The toolbar needs to freely drag and drop around the page
|
|
85
|
+
const handleDragEnd = ev => {
|
|
86
|
+
// only update position if the toolbar is completely within the preview area
|
|
87
|
+
// otherwise reset it back to the previous position
|
|
88
|
+
// TODO: reset to the nearest edge of the preview area
|
|
89
|
+
if (ev.over && ev.over.id === 'live-preview-area') {
|
|
90
|
+
const newPos = {
|
|
91
|
+
x: position.x + ev.delta.x,
|
|
92
|
+
y: position.y + ev.delta.y
|
|
93
|
+
};
|
|
94
|
+
setPosition(newPos);
|
|
95
|
+
} else {
|
|
96
|
+
// reset
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
const setWidth = useCallback(width => {
|
|
100
|
+
setSize({
|
|
101
|
+
type: 'width',
|
|
102
|
+
value: width
|
|
103
|
+
});
|
|
104
|
+
}, [setSize]);
|
|
105
|
+
const setHeight = useCallback(height => {
|
|
106
|
+
setSize({
|
|
107
|
+
type: 'height',
|
|
108
|
+
value: height
|
|
109
|
+
});
|
|
110
|
+
}, [setSize]);
|
|
111
|
+
// explicitly set new width and height when as new breakpoints are selected
|
|
112
|
+
// exclude `custom` breakpoint as it is handled by the `setWidth` and `setHeight` directly
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
const foundBreakpoint = breakpoints?.find(bp => bp.name === breakpoint);
|
|
115
|
+
if (foundBreakpoint && breakpoint !== 'responsive' && breakpoint !== 'custom' && typeof foundBreakpoint?.width === 'number' && typeof foundBreakpoint?.height === 'number') {
|
|
116
|
+
setSize({
|
|
117
|
+
type: 'reset',
|
|
118
|
+
value: {
|
|
119
|
+
height: foundBreakpoint.height,
|
|
120
|
+
width: foundBreakpoint.width
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}, [breakpoint, breakpoints]);
|
|
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
|
+
useEffect(() => {
|
|
130
|
+
const handleMessage = event => {
|
|
131
|
+
if (url?.startsWith(event.origin) && event.data && typeof event.data === 'object' && event.data.type === 'payload-live-preview') {
|
|
132
|
+
if (event.data.ready) {
|
|
133
|
+
setAppIsReady(true);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
window.addEventListener('message', handleMessage);
|
|
138
|
+
setListeningForMessages(true);
|
|
139
|
+
return () => {
|
|
140
|
+
window.removeEventListener('message', handleMessage);
|
|
141
|
+
};
|
|
142
|
+
}, [url, listeningForMessages]);
|
|
143
|
+
const handleWindowChange = useCallback(type => {
|
|
144
|
+
setAppIsReady(false);
|
|
145
|
+
setPreviewWindowType(type);
|
|
146
|
+
if (type === 'popup') {
|
|
147
|
+
openPopupWindow();
|
|
148
|
+
}
|
|
149
|
+
}, [openPopupWindow]);
|
|
150
|
+
// when the user closes the popup window, switch back to the iframe
|
|
151
|
+
// the `usePopupWindow` reports the `isPopupOpen` state for us to use here
|
|
152
|
+
useEffect(() => {
|
|
153
|
+
const newPreviewWindowType = isPopupOpen ? 'popup' : 'iframe';
|
|
154
|
+
if (newPreviewWindowType !== previewWindowType) {
|
|
155
|
+
handleWindowChange('iframe');
|
|
156
|
+
}
|
|
157
|
+
}, [previewWindowType, isPopupOpen, handleWindowChange]);
|
|
158
|
+
useEffect(() => {
|
|
159
|
+
if (isFirstRender.current) {
|
|
160
|
+
isFirstRender.current = false;
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
void setPreference(collectionSlug ? `collection-${collectionSlug}` : `global-${globalSlug}`, {
|
|
164
|
+
editViewType: isLivePreviewing ? 'live-preview' : 'default'
|
|
165
|
+
}, true);
|
|
166
|
+
}, [isLivePreviewing, setPreference, collectionSlug, globalSlug]);
|
|
167
|
+
return /*#__PURE__*/_jsx(LivePreviewContext, {
|
|
168
|
+
value: {
|
|
169
|
+
appIsReady,
|
|
170
|
+
breakpoint,
|
|
171
|
+
breakpoints,
|
|
172
|
+
fieldSchemaJSON,
|
|
173
|
+
iframeHasLoaded,
|
|
174
|
+
iframeRef,
|
|
175
|
+
isLivePreviewEnabled: Boolean(operation !== 'create' && collectionSlug && config?.admin?.livePreview?.collections?.includes(collectionSlug) || globalSlug && config.admin?.livePreview?.globals?.includes(globalSlug) || entityConfig?.admin?.livePreview),
|
|
176
|
+
isLivePreviewing,
|
|
177
|
+
isPopupOpen,
|
|
178
|
+
listeningForMessages,
|
|
179
|
+
measuredDeviceSize,
|
|
180
|
+
openPopupWindow,
|
|
181
|
+
popupRef,
|
|
182
|
+
previewWindowType,
|
|
183
|
+
setAppIsReady,
|
|
184
|
+
setBreakpoint,
|
|
185
|
+
setHeight,
|
|
186
|
+
setIframeHasLoaded,
|
|
187
|
+
setIsLivePreviewing,
|
|
188
|
+
setMeasuredDeviceSize,
|
|
189
|
+
setPreviewWindowType: handleWindowChange,
|
|
190
|
+
setSize,
|
|
191
|
+
setToolbarPosition: setPosition,
|
|
192
|
+
setWidth,
|
|
193
|
+
setZoom,
|
|
194
|
+
size,
|
|
195
|
+
toolbarPosition: position,
|
|
196
|
+
url,
|
|
197
|
+
zoom
|
|
198
|
+
},
|
|
199
|
+
children: /*#__PURE__*/_jsx(DndContext, {
|
|
200
|
+
collisionDetection: customCollisionDetection,
|
|
201
|
+
onDragEnd: handleDragEnd,
|
|
202
|
+
children: children
|
|
203
|
+
})
|
|
204
|
+
});
|
|
205
|
+
};
|
|
206
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["DndContext","fieldSchemaToJSON","React","useCallback","useEffect","useMemo","useRef","useState","usePopupWindow","useDocumentInfo","usePreferences","useConfig","customCollisionDetection","LivePreviewContext","sizeReducer","getAbsoluteUrl","url","URL","window","location","origin","href","LivePreviewProvider","breakpoints","incomingBreakpoints","children","isLivePreviewing","incomingIsLivePreviewing","operation","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","config","getEntityConfig","zoom","setZoom","position","setPosition","x","y","size","setSize","useReducer","measuredDeviceSize","setMeasuredDeviceSize","entityConfig","breakpoint","setBreakpoint","fieldSchemaJSON","fields","handleDragEnd","ev","over","id","newPos","delta","setWidth","type","value","setHeight","foundBreakpoint","find","bp","handleMessage","event","data","ready","addEventListener","removeEventListener","handleWindowChange","newPreviewWindowType","current","editViewType","_jsx","isLivePreviewEnabled","Boolean","admin","livePreview","collections","includes","globals","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 { fieldSchemaToJSON } from 'payload/shared'\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 { useConfig } from '../Config/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 isLivePreviewing: boolean\n operation?: 'create' | 'update'\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 isLivePreviewing: incomingIsLivePreviewing,\n operation,\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 { config, getEntityConfig } = useConfig()\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 entityConfig = getEntityConfig({ collectionSlug, globalSlug })\n\n const [breakpoint, setBreakpoint] =\n React.useState<LivePreviewConfig['breakpoints'][0]['name']>('responsive')\n\n const [fieldSchemaJSON] = useState(() => fieldSchemaToJSON(entityConfig?.fields || [], config))\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 fieldSchemaJSON,\n iframeHasLoaded,\n iframeRef,\n isLivePreviewEnabled: Boolean(\n (operation !== 'create' &&\n collectionSlug &&\n config?.admin?.livePreview?.collections?.includes(collectionSlug)) ||\n (globalSlug && config.admin?.livePreview?.globals?.includes(globalSlug)) ||\n entityConfig?.admin?.livePreview,\n ),\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,SAASC,iBAAiB,QAAQ;AAClC,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,SAAS,QAAQ;AAC1B,SAASC,wBAAwB,QAAQ;AACzC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,WAAW,QAAQ;AAe5B,MAAMC,cAAA,GAAkBC,GAAA;EAC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EC,WAAA,EAAaG,OAAA,EAASD,QAAA,CAASrD,UAAA,KAC5DmB,YAAA,EAAc+B,KAAA,EAAOC,WAAA;MAEzBzE,gBAAA;MACAa,WAAA;MACAM,oBAAA;MACAoB,kBAAA;MACAzB,eAAA;MACAC,QAAA;MACAX,iBAAA;MACAc,aAAA;MACAyB,aAAA;MACAY,SAAA;MACA5B,kBAAA;MACArB,mBAAA;MACAkC,qBAAA;MACAnC,oBAAA,EAAsB4D,kBAAA;MACtB5B,OAAA;MACAwC,kBAAA,EAAoB5C,WAAA;MACpBmB,QAAA;MACArB,OAAA;MACAK,IAAA;MACA0C,eAAA,EAAiB9C,QAAA;MACjB1C,GAAA;MACAwC;IACF;cAEA,aAAAuC,IAAA,CAAC/F,UAAA;MAAWyG,kBAAA,EAAoB7F,wBAAA;MAA0B8F,SAAA,EAAWlC,aAAA;gBAClE/C;;;AAIT","ignoreList":[]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
@import '~@payloadcms/ui/scss';
|
|
2
|
+
|
|
3
|
+
@layer payload-default {
|
|
4
|
+
.live-preview {
|
|
5
|
+
width: 100%;
|
|
6
|
+
display: flex;
|
|
7
|
+
--gradient: linear-gradient(to left, rgba(0, 0, 0, 0.04) 0%, transparent 100%);
|
|
8
|
+
|
|
9
|
+
[dir='rtl'] & {
|
|
10
|
+
flex-direction: row-reverse;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
&--popup-open {
|
|
14
|
+
.live-preview {
|
|
15
|
+
&__edit {
|
|
16
|
+
padding-right: var(--gutter-h);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&__main {
|
|
22
|
+
width: 40%;
|
|
23
|
+
display: flex;
|
|
24
|
+
flex-direction: column;
|
|
25
|
+
min-height: 100%;
|
|
26
|
+
position: relative;
|
|
27
|
+
|
|
28
|
+
&--popup-open {
|
|
29
|
+
width: 100%;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&::after {
|
|
33
|
+
content: ' ';
|
|
34
|
+
position: absolute;
|
|
35
|
+
top: 0;
|
|
36
|
+
right: 0;
|
|
37
|
+
width: calc(var(--base) * 2);
|
|
38
|
+
height: 100%;
|
|
39
|
+
background: var(--gradient);
|
|
40
|
+
pointer-events: none;
|
|
41
|
+
z-index: -1;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@include mid-break {
|
|
46
|
+
flex-direction: column;
|
|
47
|
+
|
|
48
|
+
&__main {
|
|
49
|
+
min-height: initial;
|
|
50
|
+
width: 100%;
|
|
51
|
+
|
|
52
|
+
&::after {
|
|
53
|
+
display: none;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
&__form {
|
|
58
|
+
display: block;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
html[data-theme='dark'] {
|
|
64
|
+
.live-preview {
|
|
65
|
+
--gradient: linear-gradient(to left, rgba(0, 0, 0, 0.4) 0%, rgba(0, 0, 0, 0) 100%);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
type SizeReducerState = {
|
|
2
|
+
height: number;
|
|
3
|
+
width: number;
|
|
4
|
+
};
|
|
5
|
+
export type SizeReducerAction = {
|
|
6
|
+
type: 'height' | 'width';
|
|
7
|
+
value: number;
|
|
8
|
+
} | {
|
|
9
|
+
type: 'reset';
|
|
10
|
+
value: {
|
|
11
|
+
height: number;
|
|
12
|
+
width: number;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export declare const sizeReducer: (state: SizeReducerState, action: SizeReducerAction) => {
|
|
16
|
+
height: number;
|
|
17
|
+
width: number;
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=sizeReducer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sizeReducer.d.ts","sourceRoot":"","sources":["../../../src/providers/LivePreview/sizeReducer.ts"],"names":[],"mappings":"AAWA,KAAK,gBAAgB,GAAG;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,MAAM,MAAM,iBAAiB,GACzB;IACE,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAA;IACxB,KAAK,EAAE,MAAM,CAAA;CACd,GACD;IACE,IAAI,EAAE,OAAO,CAAA;IACb,KAAK,EAAE;QACL,MAAM,EAAE,MAAM,CAAA;QACd,KAAK,EAAE,MAAM,CAAA;KACd,CAAA;CACF,CAAA;AAEL,eAAO,MAAM,WAAW,UAAW,gBAAgB,UAAU,iBAAiB;;WAhBrE,MAAM;CAyBd,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// export const sizeReducer: (state, action) => {
|
|
2
|
+
// switch (action.type) {
|
|
3
|
+
// case 'width':
|
|
4
|
+
// return { ...state, width: action.value }
|
|
5
|
+
// case 'height':
|
|
6
|
+
// return { ...state, height: action.value }
|
|
7
|
+
// default:
|
|
8
|
+
// return { ...state, ...(action?.value || {}) }
|
|
9
|
+
// }
|
|
10
|
+
// },
|
|
11
|
+
export const sizeReducer = (state, action) => {
|
|
12
|
+
switch (action.type) {
|
|
13
|
+
case 'height':
|
|
14
|
+
return {
|
|
15
|
+
...state,
|
|
16
|
+
height: action.value
|
|
17
|
+
};
|
|
18
|
+
case 'width':
|
|
19
|
+
return {
|
|
20
|
+
...state,
|
|
21
|
+
width: action.value
|
|
22
|
+
};
|
|
23
|
+
default:
|
|
24
|
+
return {
|
|
25
|
+
...state,
|
|
26
|
+
...(action?.value || {})
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=sizeReducer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sizeReducer.js","names":["sizeReducer","state","action","type","height","value","width"],"sources":["../../../src/providers/LivePreview/sizeReducer.ts"],"sourcesContent":["// export const sizeReducer: (state, action) => {\n// switch (action.type) {\n// case 'width':\n// return { ...state, width: action.value }\n// case 'height':\n// return { ...state, height: action.value }\n// default:\n// return { ...state, ...(action?.value || {}) }\n// }\n// },\n\ntype SizeReducerState = {\n height: number\n width: number\n}\n\nexport type SizeReducerAction =\n | {\n type: 'height' | 'width'\n value: number\n }\n | {\n type: 'reset'\n value: {\n height: number\n width: number\n }\n }\n\nexport const sizeReducer = (state: SizeReducerState, action: SizeReducerAction) => {\n switch (action.type) {\n case 'height':\n return { ...state, height: action.value }\n case 'width':\n return { ...state, width: action.value }\n default:\n return { ...state, ...(action?.value || {}) }\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAoBA,OAAO,MAAMA,WAAA,GAAcA,CAACC,KAAA,EAAyBC,MAAA;EACnD,QAAQA,MAAA,CAAOC,IAAI;IACjB,KAAK;MACH,OAAO;QAAE,GAAGF,KAAK;QAAEG,MAAA,EAAQF,MAAA,CAAOG;MAAM;IAC1C,KAAK;MACH,OAAO;QAAE,GAAGJ,KAAK;QAAEK,KAAA,EAAOJ,MAAA,CAAOG;MAAM;IACzC;MACE,OAAO;QAAE,GAAGJ,KAAK;QAAE,IAAIC,MAAA,EAAQG,KAAA,IAAS,CAAC,CAAC;MAAE;EAChD;AACF","ignoreList":[]}
|