@payloadcms/next 3.0.0-beta.35 → 3.0.0-beta.37
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/cjs/withPayload.cjs +23 -0
- package/dist/cjs/withPayload.cjs.map +1 -1
- package/dist/elements/LeaveWithoutSaving/index.js +35 -15
- package/dist/elements/LeaveWithoutSaving/index.js.map +1 -1
- package/dist/layouts/Root/index.d.ts.map +1 -1
- package/dist/layouts/Root/index.js +31 -15
- package/dist/layouts/Root/index.js.map +1 -1
- package/dist/prod/styles.css +1 -1
- package/dist/routes/rest/auth/access.d.ts.map +1 -1
- package/dist/routes/rest/auth/access.js +17 -7
- package/dist/routes/rest/auth/access.js.map +1 -1
- package/dist/routes/rest/og/image.js +64 -50
- package/dist/routes/rest/og/image.js.map +1 -1
- package/dist/routes/rest/og/index.js +2 -1
- package/dist/routes/rest/og/index.js.map +1 -1
- package/dist/utilities/getPayloadHMR.d.ts.map +1 -1
- package/dist/utilities/getPayloadHMR.js +5 -3
- package/dist/utilities/getPayloadHMR.js.map +1 -1
- package/dist/utilities/getRequestLanguage.d.ts.map +1 -1
- package/dist/utilities/getRequestLanguage.js +1 -1
- package/dist/utilities/getRequestLanguage.js.map +1 -1
- package/dist/utilities/getRequestTheme.d.ts +11 -0
- package/dist/utilities/getRequestTheme.d.ts.map +1 -0
- package/dist/utilities/getRequestTheme.js +19 -0
- package/dist/utilities/getRequestTheme.js.map +1 -0
- package/dist/utilities/initPage/index.d.ts.map +1 -1
- package/dist/utilities/initPage/index.js +1 -0
- package/dist/utilities/initPage/index.js.map +1 -1
- package/dist/views/API/RenderJSON/index.js +99 -70
- package/dist/views/API/RenderJSON/index.js.map +1 -1
- package/dist/views/API/index.client.js +128 -91
- package/dist/views/API/index.client.js.map +1 -1
- package/dist/views/API/index.js +2 -1
- package/dist/views/API/index.js.map +1 -1
- package/dist/views/Account/Settings/index.js +27 -15
- package/dist/views/Account/Settings/index.js.map +1 -1
- package/dist/views/Account/ToggleTheme/index.js +2 -1
- package/dist/views/Account/ToggleTheme/index.js.map +1 -1
- package/dist/views/Account/index.d.ts.map +1 -1
- package/dist/views/Account/index.js +54 -40
- package/dist/views/Account/index.js.map +1 -1
- package/dist/views/CreateFirstUser/index.client.js +29 -19
- package/dist/views/CreateFirstUser/index.client.js.map +1 -1
- package/dist/views/CreateFirstUser/index.js +16 -6
- package/dist/views/CreateFirstUser/index.js.map +1 -1
- package/dist/views/Dashboard/Default/index.client.js +67 -56
- package/dist/views/Dashboard/Default/index.client.js.map +1 -1
- package/dist/views/Dashboard/Default/index.js +28 -19
- package/dist/views/Dashboard/Default/index.js.map +1 -1
- package/dist/views/Dashboard/index.js +23 -17
- package/dist/views/Dashboard/index.js.map +1 -1
- package/dist/views/Document/getDocumentData.d.ts +10 -0
- package/dist/views/Document/getDocumentData.d.ts.map +1 -0
- package/dist/views/Document/getDocumentData.js +24 -0
- package/dist/views/Document/getDocumentData.js.map +1 -0
- package/dist/views/Document/getDocumentPermissions.d.ts +14 -0
- package/dist/views/Document/getDocumentPermissions.d.ts.map +1 -0
- package/dist/views/Document/getDocumentPermissions.js +83 -0
- package/dist/views/Document/getDocumentPermissions.js.map +1 -0
- package/dist/views/Document/index.d.ts.map +1 -1
- package/dist/views/Document/index.js +63 -64
- package/dist/views/Document/index.js.map +1 -1
- package/dist/views/Edit/Default/Auth/APIKey.js +41 -25
- package/dist/views/Edit/Default/Auth/APIKey.js.map +1 -1
- package/dist/views/Edit/Default/Auth/index.js +78 -50
- package/dist/views/Edit/Default/Auth/index.js.map +1 -1
- package/dist/views/Edit/Default/index.d.ts.map +1 -1
- package/dist/views/Edit/Default/index.js +84 -65
- package/dist/views/Edit/Default/index.js.map +1 -1
- package/dist/views/Edit/index.client.js +10 -4
- package/dist/views/Edit/index.client.js.map +1 -1
- package/dist/views/Edit/index.js +2 -1
- package/dist/views/Edit/index.js.map +1 -1
- package/dist/views/ForgotPassword/ForgotPasswordForm/index.js +42 -20
- package/dist/views/ForgotPassword/ForgotPasswordForm/index.js.map +1 -1
- package/dist/views/ForgotPassword/index.js +37 -17
- package/dist/views/ForgotPassword/index.js.map +1 -1
- package/dist/views/List/Default/index.js +151 -81
- package/dist/views/List/Default/index.js.map +1 -1
- package/dist/views/List/index.js +52 -43
- package/dist/views/List/index.js.map +1 -1
- package/dist/views/LivePreview/Context/context.d.ts +1 -1
- package/dist/views/LivePreview/Context/context.d.ts.map +1 -1
- package/dist/views/LivePreview/Context/context.js.map +1 -1
- package/dist/views/LivePreview/Context/index.js +9 -6
- package/dist/views/LivePreview/Context/index.js.map +1 -1
- package/dist/views/LivePreview/Device/index.js +5 -3
- package/dist/views/LivePreview/Device/index.js.map +1 -1
- package/dist/views/LivePreview/DeviceContainer/index.js +5 -3
- package/dist/views/LivePreview/DeviceContainer/index.js.map +1 -1
- package/dist/views/LivePreview/IFrame/index.js +2 -1
- package/dist/views/LivePreview/IFrame/index.js.map +1 -1
- package/dist/views/LivePreview/Preview/index.js +25 -14
- package/dist/views/LivePreview/Preview/index.js.map +1 -1
- package/dist/views/LivePreview/Toolbar/Controls/index.js +105 -57
- package/dist/views/LivePreview/Toolbar/Controls/index.js.map +1 -1
- package/dist/views/LivePreview/Toolbar/SizeInput/index.js +2 -1
- package/dist/views/LivePreview/Toolbar/SizeInput/index.js.map +1 -1
- package/dist/views/LivePreview/Toolbar/index.js +29 -14
- package/dist/views/LivePreview/Toolbar/index.js.map +1 -1
- package/dist/views/LivePreview/ToolbarArea/index.js +5 -3
- package/dist/views/LivePreview/ToolbarArea/index.js.map +1 -1
- package/dist/views/LivePreview/index.client.d.ts.map +1 -1
- package/dist/views/LivePreview/index.client.js +103 -76
- package/dist/views/LivePreview/index.client.js.map +1 -1
- package/dist/views/LivePreview/index.js +2 -1
- package/dist/views/LivePreview/index.js.map +1 -1
- package/dist/views/Login/LoginForm/index.js +62 -48
- package/dist/views/Login/LoginForm/index.js.map +1 -1
- package/dist/views/Login/index.js +26 -19
- package/dist/views/Login/index.js.map +1 -1
- package/dist/views/Logout/LogoutClient.js +21 -7
- package/dist/views/Logout/LogoutClient.js.map +1 -1
- package/dist/views/Logout/index.js +13 -10
- package/dist/views/Logout/index.js.map +1 -1
- package/dist/views/NotFound/index.client.js +22 -10
- package/dist/views/NotFound/index.client.js.map +1 -1
- package/dist/views/NotFound/index.js +21 -14
- package/dist/views/NotFound/index.js.map +1 -1
- package/dist/views/ResetPassword/index.client.js +17 -8
- package/dist/views/ResetPassword/index.client.js.map +1 -1
- package/dist/views/ResetPassword/index.js +46 -25
- package/dist/views/ResetPassword/index.js.map +1 -1
- package/dist/views/Root/index.d.ts.map +1 -1
- package/dist/views/Root/index.js +36 -16
- package/dist/views/Root/index.js.map +1 -1
- package/dist/views/Unauthorized/index.js +19 -8
- package/dist/views/Unauthorized/index.js.map +1 -1
- package/dist/views/Verify/index.js +20 -11
- package/dist/views/Verify/index.js.map +1 -1
- package/dist/views/Version/Default/index.js +83 -57
- package/dist/views/Version/Default/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/Label/index.js +5 -3
- package/dist/views/Version/RenderFieldsToDiff/Label/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.js +65 -50
- package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Nested/index.js +30 -18
- package/dist/views/Version/RenderFieldsToDiff/fields/Nested/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.js +23 -12
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Select/DiffViewer/index.js +2 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Select/DiffViewer/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.js +22 -11
- package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.js +31 -30
- package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Text/DiffViewer/index.js +2 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Text/DiffViewer/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Text/index.js +22 -11
- package/dist/views/Version/RenderFieldsToDiff/fields/Text/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/index.js +90 -87
- package/dist/views/Version/RenderFieldsToDiff/index.js.map +1 -1
- package/dist/views/Version/Restore/index.js +38 -18
- package/dist/views/Version/Restore/index.js.map +1 -1
- package/dist/views/Version/SelectComparison/index.js +32 -24
- package/dist/views/Version/SelectComparison/index.js.map +1 -1
- package/dist/views/Version/SelectLocales/index.js +17 -11
- package/dist/views/Version/SelectLocales/index.js.map +1 -1
- package/dist/views/Version/index.js +2 -1
- package/dist/views/Version/index.js.map +1 -1
- package/dist/views/Versions/buildColumns.js +7 -6
- package/dist/views/Versions/buildColumns.js.map +1 -1
- package/dist/views/Versions/cells/AutosaveCell/index.js +25 -3
- package/dist/views/Versions/cells/AutosaveCell/index.js.map +1 -1
- package/dist/views/Versions/cells/CreatedAt/index.js +9 -7
- package/dist/views/Versions/cells/CreatedAt/index.js.map +1 -1
- package/dist/views/Versions/cells/ID/index.js +4 -1
- package/dist/views/Versions/cells/ID/index.js.map +1 -1
- package/dist/views/Versions/index.client.js +61 -29
- package/dist/views/Versions/index.client.js.map +1 -1
- package/dist/views/Versions/index.js +31 -22
- package/dist/views/Versions/index.js.map +1 -1
- package/dist/withPayload.d.ts.map +1 -1
- package/dist/withPayload.js +23 -0
- package/dist/withPayload.js.map +1 -1
- package/package.json +15 -11
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
3
|
import { Popup, PopupList } from '@payloadcms/ui/elements/Popup';
|
|
3
4
|
import { Chevron } from '@payloadcms/ui/icons/Chevron';
|
|
4
5
|
import { LinkIcon } from '@payloadcms/ui/icons/Link';
|
|
@@ -23,63 +24,110 @@ export const ToolbarControls = ()=>{
|
|
|
23
24
|
label: t('general:custom'),
|
|
24
25
|
value: 'custom'
|
|
25
26
|
};
|
|
26
|
-
return /*#__PURE__*/
|
|
27
|
-
className: baseClass
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
27
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
28
|
+
className: baseClass,
|
|
29
|
+
children: [
|
|
30
|
+
breakpoints?.length > 0 && /*#__PURE__*/ _jsx(Popup, {
|
|
31
|
+
button: /*#__PURE__*/ _jsxs(React.Fragment, {
|
|
32
|
+
children: [
|
|
33
|
+
/*#__PURE__*/ _jsx("span", {
|
|
34
|
+
children: breakpoints.find((bp)=>bp.name == breakpoint)?.label ?? customOption.label
|
|
35
|
+
}),
|
|
36
|
+
" ",
|
|
37
|
+
/*#__PURE__*/ _jsx(Chevron, {
|
|
38
|
+
className: `${baseClass}__chevron`
|
|
39
|
+
})
|
|
40
|
+
]
|
|
41
|
+
}),
|
|
42
|
+
className: `${baseClass}__breakpoint`,
|
|
43
|
+
horizontalAlign: "right",
|
|
44
|
+
render: ({ close })=>/*#__PURE__*/ _jsx(PopupList.ButtonGroup, {
|
|
45
|
+
children: /*#__PURE__*/ _jsxs(React.Fragment, {
|
|
46
|
+
children: [
|
|
47
|
+
breakpoints.map((bp)=>/*#__PURE__*/ _jsx(PopupList.Button, {
|
|
48
|
+
active: bp.name == breakpoint,
|
|
49
|
+
onClick: ()=>{
|
|
50
|
+
setBreakpoint(bp.name);
|
|
51
|
+
close();
|
|
52
|
+
},
|
|
53
|
+
children: bp.label
|
|
54
|
+
}, bp.name)),
|
|
55
|
+
breakpoint === 'custom' && /*#__PURE__*/ _jsx(PopupList.Button, {
|
|
56
|
+
active: breakpoint == customOption.value,
|
|
57
|
+
onClick: ()=>{
|
|
58
|
+
setBreakpoint(customOption.value);
|
|
59
|
+
close();
|
|
60
|
+
},
|
|
61
|
+
children: customOption.label
|
|
62
|
+
})
|
|
63
|
+
]
|
|
64
|
+
})
|
|
65
|
+
}),
|
|
66
|
+
showScrollbar: true,
|
|
67
|
+
verticalAlign: "bottom"
|
|
68
|
+
}),
|
|
69
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
70
|
+
className: `${baseClass}__device-size`,
|
|
71
|
+
children: [
|
|
72
|
+
/*#__PURE__*/ _jsx(PreviewFrameSizeInput, {
|
|
73
|
+
axis: "x"
|
|
74
|
+
}),
|
|
75
|
+
/*#__PURE__*/ _jsx("span", {
|
|
76
|
+
className: `${baseClass}__size-divider`,
|
|
77
|
+
children: /*#__PURE__*/ _jsx(X, {})
|
|
78
|
+
}),
|
|
79
|
+
/*#__PURE__*/ _jsx(PreviewFrameSizeInput, {
|
|
80
|
+
axis: "y"
|
|
81
|
+
})
|
|
82
|
+
]
|
|
83
|
+
}),
|
|
84
|
+
/*#__PURE__*/ _jsx(Popup, {
|
|
85
|
+
button: /*#__PURE__*/ _jsxs(React.Fragment, {
|
|
86
|
+
children: [
|
|
87
|
+
/*#__PURE__*/ _jsxs("span", {
|
|
88
|
+
children: [
|
|
89
|
+
zoom * 100,
|
|
90
|
+
"%"
|
|
91
|
+
]
|
|
92
|
+
}),
|
|
93
|
+
" ",
|
|
94
|
+
/*#__PURE__*/ _jsx(Chevron, {
|
|
95
|
+
className: `${baseClass}__chevron`
|
|
96
|
+
})
|
|
97
|
+
]
|
|
98
|
+
}),
|
|
99
|
+
className: `${baseClass}__zoom`,
|
|
100
|
+
horizontalAlign: "right",
|
|
101
|
+
render: ({ close })=>/*#__PURE__*/ _jsx(PopupList.ButtonGroup, {
|
|
102
|
+
children: /*#__PURE__*/ _jsx(React.Fragment, {
|
|
103
|
+
children: zoomOptions.map((zoomValue)=>/*#__PURE__*/ _jsxs(PopupList.Button, {
|
|
104
|
+
active: zoom * 100 == zoomValue,
|
|
105
|
+
onClick: ()=>{
|
|
106
|
+
setZoom(zoomValue / 100);
|
|
107
|
+
close();
|
|
108
|
+
},
|
|
109
|
+
children: [
|
|
110
|
+
zoomValue,
|
|
111
|
+
"%"
|
|
112
|
+
]
|
|
113
|
+
}, zoomValue))
|
|
114
|
+
})
|
|
115
|
+
}),
|
|
116
|
+
showScrollbar: true,
|
|
117
|
+
verticalAlign: "bottom"
|
|
118
|
+
}),
|
|
119
|
+
/*#__PURE__*/ _jsx("a", {
|
|
120
|
+
className: `${baseClass}__external`,
|
|
121
|
+
href: url,
|
|
122
|
+
onClick: (e)=>{
|
|
123
|
+
e.preventDefault();
|
|
124
|
+
setPreviewWindowType('popup');
|
|
125
|
+
},
|
|
126
|
+
type: "button",
|
|
127
|
+
children: /*#__PURE__*/ _jsx(LinkIcon, {})
|
|
128
|
+
})
|
|
129
|
+
]
|
|
130
|
+
});
|
|
83
131
|
};
|
|
84
132
|
|
|
85
133
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/views/LivePreview/Toolbar/Controls/index.tsx"],"sourcesContent":["'use client'\n\nimport type { EditViewProps } from 'payload/types'\n\nimport { Popup, PopupList } from '@payloadcms/ui/elements/Popup'\nimport { Chevron } from '@payloadcms/ui/icons/Chevron'\nimport { LinkIcon } from '@payloadcms/ui/icons/Link'\nimport { X } from '@payloadcms/ui/icons/X'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport React from 'react'\n\nimport { useLivePreviewContext } from '../../Context/context.js'\nimport { PreviewFrameSizeInput } from '../SizeInput/index.js'\nimport './index.scss'\n\nconst baseClass = 'live-preview-toolbar-controls'\nconst zoomOptions = [50, 75, 100, 125, 150, 200]\n\nexport const ToolbarControls: React.FC<EditViewProps> = () => {\n const { breakpoint, breakpoints, setBreakpoint, setPreviewWindowType, setZoom, url, zoom } =\n useLivePreviewContext()\n const { t } = useTranslation()\n\n const customOption = {\n label: t('general:custom'),\n value: 'custom',\n }\n\n return (\n <div className={baseClass}>\n {breakpoints?.length > 0 && (\n <Popup\n button={\n <React.Fragment>\n <span>\n {breakpoints.find((bp) => bp.name == breakpoint)?.label ?? customOption.label}\n </span>\n \n <Chevron className={`${baseClass}__chevron`} />\n </React.Fragment>\n }\n className={`${baseClass}__breakpoint`}\n horizontalAlign=\"right\"\n render={({ close }) => (\n <PopupList.ButtonGroup>\n <React.Fragment>\n {breakpoints.map((bp) => (\n <PopupList.Button\n active={bp.name == breakpoint}\n key={bp.name}\n onClick={() => {\n setBreakpoint(bp.name)\n close()\n }}\n >\n {bp.label}\n </PopupList.Button>\n ))}\n {/* Dynamically add this option so that it only appears when the width and height inputs are explicitly changed */}\n {breakpoint === 'custom' && (\n <PopupList.Button\n active={breakpoint == customOption.value}\n onClick={() => {\n setBreakpoint(customOption.value)\n close()\n }}\n >\n {customOption.label}\n </PopupList.Button>\n )}\n </React.Fragment>\n </PopupList.ButtonGroup>\n )}\n showScrollbar\n verticalAlign=\"bottom\"\n />\n )}\n <div className={`${baseClass}__device-size`}>\n <PreviewFrameSizeInput axis=\"x\" />\n <span className={`${baseClass}__size-divider`}>\n <X />\n </span>\n <PreviewFrameSizeInput axis=\"y\" />\n </div>\n <Popup\n button={\n <React.Fragment>\n <span>{zoom * 100}%</span>\n \n <Chevron className={`${baseClass}__chevron`} />\n </React.Fragment>\n }\n className={`${baseClass}__zoom`}\n horizontalAlign=\"right\"\n render={({ close }) => (\n <PopupList.ButtonGroup>\n <React.Fragment>\n {zoomOptions.map((zoomValue) => (\n <PopupList.Button\n active={zoom * 100 == zoomValue}\n key={zoomValue}\n onClick={() => {\n setZoom(zoomValue / 100)\n close()\n }}\n >\n {zoomValue}%\n </PopupList.Button>\n ))}\n </React.Fragment>\n </PopupList.ButtonGroup>\n )}\n showScrollbar\n verticalAlign=\"bottom\"\n />\n <a\n className={`${baseClass}__external`}\n href={url}\n onClick={(e) => {\n e.preventDefault()\n setPreviewWindowType('popup')\n }}\n type=\"button\"\n >\n <LinkIcon />\n </a>\n </div>\n )\n}\n"],"names":["Popup","PopupList","Chevron","LinkIcon","X","useTranslation","React","useLivePreviewContext","PreviewFrameSizeInput","baseClass","zoomOptions","ToolbarControls","breakpoint","breakpoints","setBreakpoint","setPreviewWindowType","setZoom","url","zoom","t","customOption","label","value","div","className","length","button","Fragment","span","find","bp","name","horizontalAlign","render","close","ButtonGroup","map","Button","active","
|
|
1
|
+
{"version":3,"sources":["../../../../../src/views/LivePreview/Toolbar/Controls/index.tsx"],"sourcesContent":["'use client'\n\nimport type { EditViewProps } from 'payload/types'\n\nimport { Popup, PopupList } from '@payloadcms/ui/elements/Popup'\nimport { Chevron } from '@payloadcms/ui/icons/Chevron'\nimport { LinkIcon } from '@payloadcms/ui/icons/Link'\nimport { X } from '@payloadcms/ui/icons/X'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport React from 'react'\n\nimport { useLivePreviewContext } from '../../Context/context.js'\nimport { PreviewFrameSizeInput } from '../SizeInput/index.js'\nimport './index.scss'\n\nconst baseClass = 'live-preview-toolbar-controls'\nconst zoomOptions = [50, 75, 100, 125, 150, 200]\n\nexport const ToolbarControls: React.FC<EditViewProps> = () => {\n const { breakpoint, breakpoints, setBreakpoint, setPreviewWindowType, setZoom, url, zoom } =\n useLivePreviewContext()\n const { t } = useTranslation()\n\n const customOption = {\n label: t('general:custom'),\n value: 'custom',\n }\n\n return (\n <div className={baseClass}>\n {breakpoints?.length > 0 && (\n <Popup\n button={\n <React.Fragment>\n <span>\n {breakpoints.find((bp) => bp.name == breakpoint)?.label ?? customOption.label}\n </span>\n \n <Chevron className={`${baseClass}__chevron`} />\n </React.Fragment>\n }\n className={`${baseClass}__breakpoint`}\n horizontalAlign=\"right\"\n render={({ close }) => (\n <PopupList.ButtonGroup>\n <React.Fragment>\n {breakpoints.map((bp) => (\n <PopupList.Button\n active={bp.name == breakpoint}\n key={bp.name}\n onClick={() => {\n setBreakpoint(bp.name)\n close()\n }}\n >\n {bp.label}\n </PopupList.Button>\n ))}\n {/* Dynamically add this option so that it only appears when the width and height inputs are explicitly changed */}\n {breakpoint === 'custom' && (\n <PopupList.Button\n active={breakpoint == customOption.value}\n onClick={() => {\n setBreakpoint(customOption.value)\n close()\n }}\n >\n {customOption.label}\n </PopupList.Button>\n )}\n </React.Fragment>\n </PopupList.ButtonGroup>\n )}\n showScrollbar\n verticalAlign=\"bottom\"\n />\n )}\n <div className={`${baseClass}__device-size`}>\n <PreviewFrameSizeInput axis=\"x\" />\n <span className={`${baseClass}__size-divider`}>\n <X />\n </span>\n <PreviewFrameSizeInput axis=\"y\" />\n </div>\n <Popup\n button={\n <React.Fragment>\n <span>{zoom * 100}%</span>\n \n <Chevron className={`${baseClass}__chevron`} />\n </React.Fragment>\n }\n className={`${baseClass}__zoom`}\n horizontalAlign=\"right\"\n render={({ close }) => (\n <PopupList.ButtonGroup>\n <React.Fragment>\n {zoomOptions.map((zoomValue) => (\n <PopupList.Button\n active={zoom * 100 == zoomValue}\n key={zoomValue}\n onClick={() => {\n setZoom(zoomValue / 100)\n close()\n }}\n >\n {zoomValue}%\n </PopupList.Button>\n ))}\n </React.Fragment>\n </PopupList.ButtonGroup>\n )}\n showScrollbar\n verticalAlign=\"bottom\"\n />\n <a\n className={`${baseClass}__external`}\n href={url}\n onClick={(e) => {\n e.preventDefault()\n setPreviewWindowType('popup')\n }}\n type=\"button\"\n >\n <LinkIcon />\n </a>\n </div>\n )\n}\n"],"names":["Popup","PopupList","Chevron","LinkIcon","X","useTranslation","React","useLivePreviewContext","PreviewFrameSizeInput","baseClass","zoomOptions","ToolbarControls","breakpoint","breakpoints","setBreakpoint","setPreviewWindowType","setZoom","url","zoom","t","customOption","label","value","div","className","length","button","Fragment","span","find","bp","name","horizontalAlign","render","close","ButtonGroup","map","Button","active","onClick","showScrollbar","verticalAlign","axis","zoomValue","a","href","e","preventDefault","type"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"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"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
3
|
import React, { useCallback, useEffect } from 'react';
|
|
3
4
|
import { useLivePreviewContext } from '../../Context/context.js';
|
|
4
5
|
const baseClass = 'toolbar-input';
|
|
@@ -46,7 +47,7 @@ export const PreviewFrameSizeInput = (props)=>{
|
|
|
46
47
|
size,
|
|
47
48
|
zoom
|
|
48
49
|
]);
|
|
49
|
-
return /*#__PURE__*/
|
|
50
|
+
return /*#__PURE__*/ _jsx("input", {
|
|
50
51
|
className: baseClass,
|
|
51
52
|
min: 0,
|
|
52
53
|
name: axis === 'x' ? 'live-preview-width' : 'live-preview-height',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/views/LivePreview/Toolbar/SizeInput/index.tsx"],"sourcesContent":["'use client'\nimport React, { useCallback, useEffect } from 'react'\n\nimport { useLivePreviewContext } from '../../Context/context.js'\nimport './index.scss'\n\nconst baseClass = 'toolbar-input'\n\nexport const PreviewFrameSizeInput: React.FC<{\n axis?: 'x' | 'y'\n}> = (props) => {\n const { axis } = props\n\n const { breakpoint, measuredDeviceSize, setBreakpoint, setSize, size, zoom } =\n useLivePreviewContext()\n\n const [internalState, setInternalState] = React.useState<number>(\n (axis === 'x' ? measuredDeviceSize?.width : measuredDeviceSize?.height) || 0,\n )\n\n // when the input is changed manually, we need to set the breakpoint as `custom`\n // this will then allow us to set an explicit width and height\n const handleChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n let newValue = Number(e.target.value)\n\n if (newValue < 0) newValue = 0\n\n setInternalState(newValue)\n setBreakpoint('custom')\n\n // be sure to set _both_ axis values to so that the other axis doesn't fallback to 0 on initial change\n // this is because the `responsive` size is '100%' in CSS, and `0` in initial state\n setSize({\n type: 'reset',\n value: {\n height: axis === 'y' ? newValue : Number(measuredDeviceSize?.height.toFixed(0)) * zoom,\n width: axis === 'x' ? newValue : Number(measuredDeviceSize?.width.toFixed(0)) * zoom,\n },\n })\n },\n [axis, setBreakpoint, measuredDeviceSize, setSize, zoom],\n )\n\n // if the breakpoint is `responsive` then the device's div will have `100%` width and height\n // so we need to take the measurements provided by `actualDeviceSize` and sync internal state\n useEffect(() => {\n if (breakpoint === 'responsive' && measuredDeviceSize) {\n if (axis === 'x') setInternalState(Number(measuredDeviceSize.width.toFixed(0)) * zoom)\n else setInternalState(Number(measuredDeviceSize.height.toFixed(0)) * zoom)\n }\n\n if (breakpoint !== 'responsive' && size) {\n setInternalState(axis === 'x' ? size.width : size.height)\n }\n }, [breakpoint, axis, measuredDeviceSize, size, zoom])\n\n return (\n <input\n className={baseClass}\n min={0}\n name={axis === 'x' ? 'live-preview-width' : 'live-preview-height'}\n onChange={handleChange}\n step={1}\n type=\"number\"\n value={internalState || 0}\n />\n )\n}\n"],"names":["React","useCallback","useEffect","useLivePreviewContext","baseClass","PreviewFrameSizeInput","props","axis","breakpoint","measuredDeviceSize","setBreakpoint","setSize","size","zoom","internalState","setInternalState","useState","width","height","handleChange","e","newValue","Number","target","value","type","toFixed","input","className","min","name","onChange","step"],"rangeMappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../../src/views/LivePreview/Toolbar/SizeInput/index.tsx"],"sourcesContent":["'use client'\nimport React, { useCallback, useEffect } from 'react'\n\nimport { useLivePreviewContext } from '../../Context/context.js'\nimport './index.scss'\n\nconst baseClass = 'toolbar-input'\n\nexport const PreviewFrameSizeInput: React.FC<{\n axis?: 'x' | 'y'\n}> = (props) => {\n const { axis } = props\n\n const { breakpoint, measuredDeviceSize, setBreakpoint, setSize, size, zoom } =\n useLivePreviewContext()\n\n const [internalState, setInternalState] = React.useState<number>(\n (axis === 'x' ? measuredDeviceSize?.width : measuredDeviceSize?.height) || 0,\n )\n\n // when the input is changed manually, we need to set the breakpoint as `custom`\n // this will then allow us to set an explicit width and height\n const handleChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n let newValue = Number(e.target.value)\n\n if (newValue < 0) newValue = 0\n\n setInternalState(newValue)\n setBreakpoint('custom')\n\n // be sure to set _both_ axis values to so that the other axis doesn't fallback to 0 on initial change\n // this is because the `responsive` size is '100%' in CSS, and `0` in initial state\n setSize({\n type: 'reset',\n value: {\n height: axis === 'y' ? newValue : Number(measuredDeviceSize?.height.toFixed(0)) * zoom,\n width: axis === 'x' ? newValue : Number(measuredDeviceSize?.width.toFixed(0)) * zoom,\n },\n })\n },\n [axis, setBreakpoint, measuredDeviceSize, setSize, zoom],\n )\n\n // if the breakpoint is `responsive` then the device's div will have `100%` width and height\n // so we need to take the measurements provided by `actualDeviceSize` and sync internal state\n useEffect(() => {\n if (breakpoint === 'responsive' && measuredDeviceSize) {\n if (axis === 'x') setInternalState(Number(measuredDeviceSize.width.toFixed(0)) * zoom)\n else setInternalState(Number(measuredDeviceSize.height.toFixed(0)) * zoom)\n }\n\n if (breakpoint !== 'responsive' && size) {\n setInternalState(axis === 'x' ? size.width : size.height)\n }\n }, [breakpoint, axis, measuredDeviceSize, size, zoom])\n\n return (\n <input\n className={baseClass}\n min={0}\n name={axis === 'x' ? 'live-preview-width' : 'live-preview-height'}\n onChange={handleChange}\n step={1}\n type=\"number\"\n value={internalState || 0}\n />\n )\n}\n"],"names":["React","useCallback","useEffect","useLivePreviewContext","baseClass","PreviewFrameSizeInput","props","axis","breakpoint","measuredDeviceSize","setBreakpoint","setSize","size","zoom","internalState","setInternalState","useState","width","height","handleChange","e","newValue","Number","target","value","type","toFixed","input","className","min","name","onChange","step"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AACA,OAAOA,SAASC,WAAW,EAAEC,SAAS,QAAQ,QAAO;AAErD,SAASC,qBAAqB,QAAQ,2BAA0B;AAGhE,MAAMC,YAAY;AAElB,OAAO,MAAMC,wBAER,CAACC;IACJ,MAAM,EAAEC,IAAI,EAAE,GAAGD;IAEjB,MAAM,EAAEE,UAAU,EAAEC,kBAAkB,EAAEC,aAAa,EAAEC,OAAO,EAAEC,IAAI,EAAEC,IAAI,EAAE,GAC1EV;IAEF,MAAM,CAACW,eAAeC,iBAAiB,GAAGf,MAAMgB,QAAQ,CACtD,AAACT,CAAAA,SAAS,MAAME,oBAAoBQ,QAAQR,oBAAoBS,MAAK,KAAM;IAG7E,gFAAgF;IAChF,8DAA8D;IAC9D,MAAMC,eAAelB,YACnB,CAACmB;QACC,IAAIC,WAAWC,OAAOF,EAAEG,MAAM,CAACC,KAAK;QAEpC,IAAIH,WAAW,GAAGA,WAAW;QAE7BN,iBAAiBM;QACjBX,cAAc;QAEd,sGAAsG;QACtG,mFAAmF;QACnFC,QAAQ;YACNc,MAAM;YACND,OAAO;gBACLN,QAAQX,SAAS,MAAMc,WAAWC,OAAOb,oBAAoBS,OAAOQ,QAAQ,MAAMb;gBAClFI,OAAOV,SAAS,MAAMc,WAAWC,OAAOb,oBAAoBQ,MAAMS,QAAQ,MAAMb;YAClF;QACF;IACF,GACA;QAACN;QAAMG;QAAeD;QAAoBE;QAASE;KAAK;IAG1D,4FAA4F;IAC5F,6FAA6F;IAC7FX,UAAU;QACR,IAAIM,eAAe,gBAAgBC,oBAAoB;YACrD,IAAIF,SAAS,KAAKQ,iBAAiBO,OAAOb,mBAAmBQ,KAAK,CAACS,OAAO,CAAC,MAAMb;iBAC5EE,iBAAiBO,OAAOb,mBAAmBS,MAAM,CAACQ,OAAO,CAAC,MAAMb;QACvE;QAEA,IAAIL,eAAe,gBAAgBI,MAAM;YACvCG,iBAAiBR,SAAS,MAAMK,KAAKK,KAAK,GAAGL,KAAKM,MAAM;QAC1D;IACF,GAAG;QAACV;QAAYD;QAAME;QAAoBG;QAAMC;KAAK;IAErD,qBACE,KAACc;QACCC,WAAWxB;QACXyB,KAAK;QACLC,MAAMvB,SAAS,MAAM,uBAAuB;QAC5CwB,UAAUZ;QACVa,MAAM;QACNP,MAAK;QACLD,OAAOV,iBAAiB;;AAG9B,EAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
3
|
import { useDraggable } from '@dnd-kit/core';
|
|
3
4
|
import { DragHandle } from '@payloadcms/ui/icons/DragHandle';
|
|
4
5
|
import React from 'react';
|
|
@@ -10,7 +11,7 @@ const DraggableToolbar = (props)=>{
|
|
|
10
11
|
const { attributes, listeners, setNodeRef, transform } = useDraggable({
|
|
11
12
|
id: 'live-preview-toolbar'
|
|
12
13
|
});
|
|
13
|
-
return /*#__PURE__*/
|
|
14
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
14
15
|
className: [
|
|
15
16
|
baseClass,
|
|
16
17
|
`${baseClass}--draggable`
|
|
@@ -21,29 +22,43 @@ const DraggableToolbar = (props)=>{
|
|
|
21
22
|
...transform ? {
|
|
22
23
|
transform: transform ? `translate3d(${transform?.x || 0}px, ${transform?.y || 0}px, 0)` : undefined
|
|
23
24
|
} : {}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
},
|
|
26
|
+
children: [
|
|
27
|
+
/*#__PURE__*/ _jsx("button", {
|
|
28
|
+
...listeners,
|
|
29
|
+
...attributes,
|
|
30
|
+
className: `${baseClass}__drag-handle`,
|
|
31
|
+
ref: setNodeRef,
|
|
32
|
+
type: "button",
|
|
33
|
+
children: /*#__PURE__*/ _jsx(DragHandle, {})
|
|
34
|
+
}),
|
|
35
|
+
/*#__PURE__*/ _jsx(ToolbarControls, {
|
|
36
|
+
...props
|
|
37
|
+
})
|
|
38
|
+
]
|
|
39
|
+
});
|
|
32
40
|
};
|
|
33
41
|
const StaticToolbar = (props)=>{
|
|
34
|
-
return /*#__PURE__*/
|
|
42
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
35
43
|
className: [
|
|
36
44
|
baseClass,
|
|
37
45
|
`${baseClass}--static`
|
|
38
|
-
].join(' ')
|
|
39
|
-
|
|
46
|
+
].join(' '),
|
|
47
|
+
children: /*#__PURE__*/ _jsx(ToolbarControls, {
|
|
48
|
+
...props
|
|
49
|
+
})
|
|
50
|
+
});
|
|
40
51
|
};
|
|
41
52
|
export const LivePreviewToolbar = (props)=>{
|
|
42
53
|
const { draggable } = props;
|
|
43
54
|
if (draggable) {
|
|
44
|
-
return /*#__PURE__*/
|
|
55
|
+
return /*#__PURE__*/ _jsx(DraggableToolbar, {
|
|
56
|
+
...props
|
|
57
|
+
});
|
|
45
58
|
}
|
|
46
|
-
return /*#__PURE__*/
|
|
59
|
+
return /*#__PURE__*/ _jsx(StaticToolbar, {
|
|
60
|
+
...props
|
|
61
|
+
});
|
|
47
62
|
};
|
|
48
63
|
|
|
49
64
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/views/LivePreview/Toolbar/index.tsx"],"sourcesContent":["'use client'\nimport type { EditViewProps } from 'payload/types'\n\nimport { useDraggable } from '@dnd-kit/core'\nimport { DragHandle } from '@payloadcms/ui/icons/DragHandle'\nimport React from 'react'\n\nimport { useLivePreviewContext } from '../Context/context.js'\nimport { ToolbarControls } from './Controls/index.js'\nimport './index.scss'\n\nconst baseClass = 'live-preview-toolbar'\n\nconst DraggableToolbar: React.FC<EditViewProps> = (props) => {\n const { toolbarPosition } = useLivePreviewContext()\n\n const { attributes, listeners, setNodeRef, transform } = useDraggable({\n id: 'live-preview-toolbar',\n })\n\n return (\n <div\n className={[baseClass, `${baseClass}--draggable`].join(' ')}\n style={{\n left: `${toolbarPosition.x}px`,\n top: `${toolbarPosition.y}px`,\n ...(transform\n ? {\n transform: transform\n ? `translate3d(${transform?.x || 0}px, ${transform?.y || 0}px, 0)`\n : undefined,\n }\n : {}),\n }}\n >\n <button\n {...listeners}\n {...attributes}\n className={`${baseClass}__drag-handle`}\n ref={setNodeRef}\n type=\"button\"\n >\n <DragHandle />\n </button>\n <ToolbarControls {...props} />\n </div>\n )\n}\n\nconst StaticToolbar: React.FC<EditViewProps> = (props) => {\n return (\n <div className={[baseClass, `${baseClass}--static`].join(' ')}>\n <ToolbarControls {...props} />\n </div>\n )\n}\n\nexport const LivePreviewToolbar: React.FC<\n EditViewProps & {\n draggable?: boolean\n }\n> = (props) => {\n const { draggable } = props\n\n if (draggable) {\n return <DraggableToolbar {...props} />\n }\n\n return <StaticToolbar {...props} />\n}\n"],"names":["useDraggable","DragHandle","React","useLivePreviewContext","ToolbarControls","baseClass","DraggableToolbar","props","toolbarPosition","attributes","listeners","setNodeRef","transform","id","div","className","join","style","left","x","top","y","undefined","button","ref","type","StaticToolbar","LivePreviewToolbar","draggable"],"rangeMappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/views/LivePreview/Toolbar/index.tsx"],"sourcesContent":["'use client'\nimport type { EditViewProps } from 'payload/types'\n\nimport { useDraggable } from '@dnd-kit/core'\nimport { DragHandle } from '@payloadcms/ui/icons/DragHandle'\nimport React from 'react'\n\nimport { useLivePreviewContext } from '../Context/context.js'\nimport { ToolbarControls } from './Controls/index.js'\nimport './index.scss'\n\nconst baseClass = 'live-preview-toolbar'\n\nconst DraggableToolbar: React.FC<EditViewProps> = (props) => {\n const { toolbarPosition } = useLivePreviewContext()\n\n const { attributes, listeners, setNodeRef, transform } = useDraggable({\n id: 'live-preview-toolbar',\n })\n\n return (\n <div\n className={[baseClass, `${baseClass}--draggable`].join(' ')}\n style={{\n left: `${toolbarPosition.x}px`,\n top: `${toolbarPosition.y}px`,\n ...(transform\n ? {\n transform: transform\n ? `translate3d(${transform?.x || 0}px, ${transform?.y || 0}px, 0)`\n : undefined,\n }\n : {}),\n }}\n >\n <button\n {...listeners}\n {...attributes}\n className={`${baseClass}__drag-handle`}\n ref={setNodeRef}\n type=\"button\"\n >\n <DragHandle />\n </button>\n <ToolbarControls {...props} />\n </div>\n )\n}\n\nconst StaticToolbar: React.FC<EditViewProps> = (props) => {\n return (\n <div className={[baseClass, `${baseClass}--static`].join(' ')}>\n <ToolbarControls {...props} />\n </div>\n )\n}\n\nexport const LivePreviewToolbar: React.FC<\n EditViewProps & {\n draggable?: boolean\n }\n> = (props) => {\n const { draggable } = props\n\n if (draggable) {\n return <DraggableToolbar {...props} />\n }\n\n return <StaticToolbar {...props} />\n}\n"],"names":["useDraggable","DragHandle","React","useLivePreviewContext","ToolbarControls","baseClass","DraggableToolbar","props","toolbarPosition","attributes","listeners","setNodeRef","transform","id","div","className","join","style","left","x","top","y","undefined","button","ref","type","StaticToolbar","LivePreviewToolbar","draggable"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AAGA,SAASA,YAAY,QAAQ,gBAAe;AAC5C,SAASC,UAAU,QAAQ,kCAAiC;AAC5D,OAAOC,WAAW,QAAO;AAEzB,SAASC,qBAAqB,QAAQ,wBAAuB;AAC7D,SAASC,eAAe,QAAQ,sBAAqB;AAGrD,MAAMC,YAAY;AAElB,MAAMC,mBAA4C,CAACC;IACjD,MAAM,EAAEC,eAAe,EAAE,GAAGL;IAE5B,MAAM,EAAEM,UAAU,EAAEC,SAAS,EAAEC,UAAU,EAAEC,SAAS,EAAE,GAAGZ,aAAa;QACpEa,IAAI;IACN;IAEA,qBACE,MAACC;QACCC,WAAW;YAACV;YAAW,CAAC,EAAEA,UAAU,WAAW,CAAC;SAAC,CAACW,IAAI,CAAC;QACvDC,OAAO;YACLC,MAAM,CAAC,EAAEV,gBAAgBW,CAAC,CAAC,EAAE,CAAC;YAC9BC,KAAK,CAAC,EAAEZ,gBAAgBa,CAAC,CAAC,EAAE,CAAC;YAC7B,GAAIT,YACA;gBACEA,WAAWA,YACP,CAAC,YAAY,EAAEA,WAAWO,KAAK,EAAE,IAAI,EAAEP,WAAWS,KAAK,EAAE,MAAM,CAAC,GAChEC;YACN,IACA,CAAC,CAAC;QACR;;0BAEA,KAACC;gBACE,GAAGb,SAAS;gBACZ,GAAGD,UAAU;gBACdM,WAAW,CAAC,EAAEV,UAAU,aAAa,CAAC;gBACtCmB,KAAKb;gBACLc,MAAK;0BAEL,cAAA,KAACxB;;0BAEH,KAACG;gBAAiB,GAAGG,KAAK;;;;AAGhC;AAEA,MAAMmB,gBAAyC,CAACnB;IAC9C,qBACE,KAACO;QAAIC,WAAW;YAACV;YAAW,CAAC,EAAEA,UAAU,QAAQ,CAAC;SAAC,CAACW,IAAI,CAAC;kBACvD,cAAA,KAACZ;YAAiB,GAAGG,KAAK;;;AAGhC;AAEA,OAAO,MAAMoB,qBAIT,CAACpB;IACH,MAAM,EAAEqB,SAAS,EAAE,GAAGrB;IAEtB,IAAIqB,WAAW;QACb,qBAAO,KAACtB;YAAkB,GAAGC,KAAK;;IACpC;IAEA,qBAAO,KAACmB;QAAe,GAAGnB,KAAK;;AACjC,EAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
3
|
import { useDroppable } from '@dnd-kit/core';
|
|
3
4
|
import React from 'react';
|
|
4
5
|
const baseClass = 'toolbar-area';
|
|
@@ -7,10 +8,11 @@ export const ToolbarArea = (props)=>{
|
|
|
7
8
|
const { setNodeRef } = useDroppable({
|
|
8
9
|
id: 'live-preview-area'
|
|
9
10
|
});
|
|
10
|
-
return /*#__PURE__*/
|
|
11
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
11
12
|
className: baseClass,
|
|
12
|
-
ref: setNodeRef
|
|
13
|
-
|
|
13
|
+
ref: setNodeRef,
|
|
14
|
+
children: children
|
|
15
|
+
});
|
|
14
16
|
};
|
|
15
17
|
|
|
16
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/views/LivePreview/ToolbarArea/index.tsx"],"sourcesContent":["'use client'\nimport { useDroppable } from '@dnd-kit/core'\nimport React from 'react'\n\nimport './index.scss'\n\nconst baseClass = 'toolbar-area'\n\nexport const ToolbarArea: React.FC<{\n children: React.ReactNode\n}> = (props) => {\n const { children } = props\n\n const { setNodeRef } = useDroppable({\n id: 'live-preview-area',\n })\n\n return (\n <div className={baseClass} ref={setNodeRef}>\n {children}\n </div>\n )\n}\n"],"names":["useDroppable","React","baseClass","ToolbarArea","props","children","setNodeRef","id","div","className","ref"],"rangeMappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/views/LivePreview/ToolbarArea/index.tsx"],"sourcesContent":["'use client'\nimport { useDroppable } from '@dnd-kit/core'\nimport React from 'react'\n\nimport './index.scss'\n\nconst baseClass = 'toolbar-area'\n\nexport const ToolbarArea: React.FC<{\n children: React.ReactNode\n}> = (props) => {\n const { children } = props\n\n const { setNodeRef } = useDroppable({\n id: 'live-preview-area',\n })\n\n return (\n <div className={baseClass} ref={setNodeRef}>\n {children}\n </div>\n )\n}\n"],"names":["useDroppable","React","baseClass","ToolbarArea","props","children","setNodeRef","id","div","className","ref"],"rangeMappings":";;;;;;;;;;;;;;;","mappings":"AAAA;;AACA,SAASA,YAAY,QAAQ,gBAAe;AAC5C,OAAOC,WAAW,QAAO;AAIzB,MAAMC,YAAY;AAElB,OAAO,MAAMC,cAER,CAACC;IACJ,MAAM,EAAEC,QAAQ,EAAE,GAAGD;IAErB,MAAM,EAAEE,UAAU,EAAE,GAAGN,aAAa;QAClCO,IAAI;IACN;IAEA,qBACE,KAACC;QAAIC,WAAWP;QAAWQ,KAAKJ;kBAC7BD;;AAGP,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.client.d.ts","sourceRoot":"","sources":["../../../src/views/LivePreview/index.client.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,KAAK,EAA4D,IAAI,EAAE,MAAM,eAAe,CAAA;AAanG,OAAO,KAAgC,MAAM,OAAO,CAAA;AAQpD,OAAO,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"index.client.d.ts","sourceRoot":"","sources":["../../../src/views/LivePreview/index.client.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,KAAK,EAA4D,IAAI,EAAE,MAAM,eAAe,CAAA;AAanG,OAAO,KAAgC,MAAM,OAAO,CAAA;AAQpD,OAAO,cAAc,CAAA;AAkLrB,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC;IACvC,WAAW,EAAE,iBAAiB,CAAC,aAAa,CAAC,CAAA;IAC7C,WAAW,EAAE,IAAI,CAAA;IACjB,GAAG,EAAE,MAAM,CAAA;CACZ,CA2DA,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
3
|
import { DocumentControls } from '@payloadcms/ui/elements/DocumentControls';
|
|
3
4
|
import { DocumentFields } from '@payloadcms/ui/elements/DocumentFields';
|
|
4
5
|
import { LoadingOverlay } from '@payloadcms/ui/elements/Loading';
|
|
@@ -20,7 +21,7 @@ import { LivePreview } from './Preview/index.js';
|
|
|
20
21
|
import { usePopupWindow } from './usePopupWindow.js';
|
|
21
22
|
const baseClass = 'live-preview';
|
|
22
23
|
const PreviewView = ({ apiRoute, collectionConfig, config, fieldMap, globalConfig, schemaPath, serverURL })=>{
|
|
23
|
-
const { id, AfterDocument, AfterFields, BeforeDocument, BeforeFields, action, apiURL, collectionSlug, disableActions, disableLeaveWithoutSaving, docPermissions, getDocPreferences, globalSlug, hasSavePermission, initialData, initialState, isEditing, onSave: onSaveFromProps } = useDocumentInfo();
|
|
24
|
+
const { id, AfterDocument, AfterFields, BeforeDocument, BeforeFields, action, apiURL, collectionSlug, disableActions, disableLeaveWithoutSaving, docPermissions, getDocPreferences, globalSlug, hasPublishPermission, hasSavePermission, initialData, initialState, isEditing, onSave: onSaveFromProps } = useDocumentInfo();
|
|
24
25
|
const operation = id ? 'update' : 'create';
|
|
25
26
|
const { t } = useTranslation();
|
|
26
27
|
const { previewWindowType } = useLivePreviewContext();
|
|
@@ -66,64 +67,84 @@ const PreviewView = ({ apiRoute, collectionConfig, config, fieldMap, globalConfi
|
|
|
66
67
|
]);
|
|
67
68
|
// Allow the `DocumentInfoProvider` to hydrate
|
|
68
69
|
if (!collectionSlug && !globalSlug) {
|
|
69
|
-
return /*#__PURE__*/
|
|
70
|
+
return /*#__PURE__*/ _jsx(LoadingOverlay, {});
|
|
70
71
|
}
|
|
71
|
-
return /*#__PURE__*/
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
72
|
+
return /*#__PURE__*/ _jsx(Fragment, {
|
|
73
|
+
children: /*#__PURE__*/ _jsx(OperationProvider, {
|
|
74
|
+
operation: operation,
|
|
75
|
+
children: /*#__PURE__*/ _jsxs(Form, {
|
|
76
|
+
action: action,
|
|
77
|
+
className: `${baseClass}__form`,
|
|
78
|
+
disabled: !hasSavePermission,
|
|
79
|
+
initialState: initialState,
|
|
80
|
+
method: id ? 'PATCH' : 'POST',
|
|
81
|
+
onChange: [
|
|
82
|
+
onChange
|
|
83
|
+
],
|
|
84
|
+
onSuccess: onSave,
|
|
85
|
+
children: [
|
|
86
|
+
(collectionConfig && !(collectionConfig.versions?.drafts && collectionConfig.versions?.drafts?.autosave) || globalConfig && !(globalConfig.versions?.drafts && globalConfig.versions?.drafts?.autosave)) && !disableLeaveWithoutSaving && /*#__PURE__*/ _jsx(LeaveWithoutSaving, {}),
|
|
87
|
+
/*#__PURE__*/ _jsx(SetDocumentStepNav, {
|
|
88
|
+
collectionSlug: collectionSlug,
|
|
89
|
+
globalLabel: globalConfig?.label,
|
|
90
|
+
globalSlug: globalSlug,
|
|
91
|
+
id: id,
|
|
92
|
+
pluralLabel: collectionConfig ? collectionConfig?.labels?.plural : undefined,
|
|
93
|
+
useAsTitle: collectionConfig ? collectionConfig?.admin?.useAsTitle : undefined,
|
|
94
|
+
view: t('general:livePreview')
|
|
95
|
+
}),
|
|
96
|
+
/*#__PURE__*/ _jsx(SetDocumentTitle, {
|
|
97
|
+
collectionConfig: collectionConfig,
|
|
98
|
+
config: config,
|
|
99
|
+
fallback: id?.toString() || '',
|
|
100
|
+
globalConfig: globalConfig
|
|
101
|
+
}),
|
|
102
|
+
/*#__PURE__*/ _jsx(DocumentControls, {
|
|
103
|
+
apiURL: apiURL,
|
|
104
|
+
data: initialData,
|
|
105
|
+
disableActions: disableActions,
|
|
106
|
+
hasPublishPermission: hasPublishPermission,
|
|
107
|
+
hasSavePermission: hasSavePermission,
|
|
108
|
+
id: id,
|
|
109
|
+
isEditing: isEditing,
|
|
110
|
+
permissions: docPermissions,
|
|
111
|
+
slug: collectionConfig?.slug || globalConfig?.slug
|
|
112
|
+
}),
|
|
113
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
114
|
+
className: [
|
|
115
|
+
baseClass,
|
|
116
|
+
previewWindowType === 'popup' && `${baseClass}--detached`
|
|
117
|
+
].filter(Boolean).join(' '),
|
|
118
|
+
children: [
|
|
119
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
120
|
+
className: [
|
|
121
|
+
`${baseClass}__main`,
|
|
122
|
+
previewWindowType === 'popup' && `${baseClass}__main--popup-open`
|
|
123
|
+
].filter(Boolean).join(' '),
|
|
124
|
+
children: [
|
|
125
|
+
BeforeDocument,
|
|
126
|
+
/*#__PURE__*/ _jsx(DocumentFields, {
|
|
127
|
+
AfterFields: AfterFields,
|
|
128
|
+
BeforeFields: BeforeFields,
|
|
129
|
+
docPermissions: docPermissions,
|
|
130
|
+
fieldMap: fieldMap,
|
|
131
|
+
forceSidebarWrap: true,
|
|
132
|
+
readOnly: !hasSavePermission,
|
|
133
|
+
schemaPath: collectionSlug || globalSlug
|
|
134
|
+
}),
|
|
135
|
+
AfterDocument
|
|
136
|
+
]
|
|
137
|
+
}),
|
|
138
|
+
/*#__PURE__*/ _jsx(LivePreview, {
|
|
139
|
+
collectionSlug: collectionSlug,
|
|
140
|
+
globalSlug: globalSlug
|
|
141
|
+
})
|
|
142
|
+
]
|
|
143
|
+
})
|
|
144
|
+
]
|
|
145
|
+
})
|
|
146
|
+
})
|
|
147
|
+
});
|
|
127
148
|
};
|
|
128
149
|
export const LivePreviewClient = (props)=>{
|
|
129
150
|
const { breakpoints, url } = props;
|
|
@@ -147,24 +168,30 @@ export const LivePreviewClient = (props)=>{
|
|
|
147
168
|
collectionSlug: collectionConfig?.slug,
|
|
148
169
|
globalSlug: globalConfig?.slug
|
|
149
170
|
});
|
|
150
|
-
return /*#__PURE__*/
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
171
|
+
return /*#__PURE__*/ _jsxs(Fragment, {
|
|
172
|
+
children: [
|
|
173
|
+
/*#__PURE__*/ _jsx(SetViewActions, {
|
|
174
|
+
actions: componentMap?.actionsMap?.Edit?.LivePreview
|
|
175
|
+
}),
|
|
176
|
+
/*#__PURE__*/ _jsx(LivePreviewProvider, {
|
|
177
|
+
breakpoints: breakpoints,
|
|
178
|
+
fieldSchema: collectionConfig?.fields || globalConfig?.fields,
|
|
179
|
+
isPopupOpen: isPopupOpen,
|
|
180
|
+
openPopupWindow: openPopupWindow,
|
|
181
|
+
popupRef: popupRef,
|
|
182
|
+
url: url,
|
|
183
|
+
children: /*#__PURE__*/ _jsx(PreviewView, {
|
|
184
|
+
apiRoute: apiRoute,
|
|
185
|
+
collectionConfig: collectionConfig,
|
|
186
|
+
config: config,
|
|
187
|
+
fieldMap: fieldMap,
|
|
188
|
+
globalConfig: globalConfig,
|
|
189
|
+
schemaPath: schemaPath,
|
|
190
|
+
serverURL: serverURL
|
|
191
|
+
})
|
|
192
|
+
})
|
|
193
|
+
]
|
|
194
|
+
});
|
|
168
195
|
};
|
|
169
196
|
|
|
170
197
|
//# sourceMappingURL=index.client.js.map
|