@payloadcms/ui 3.44.0 → 3.45.0-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/elements/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,30 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { useLivePreviewContext } from '../../../providers/LivePreview/context.js';
|
|
6
|
+
import './index.scss';
|
|
7
|
+
const baseClass = 'live-preview-iframe';
|
|
8
|
+
export const IFrame = props => {
|
|
9
|
+
const {
|
|
10
|
+
ref,
|
|
11
|
+
setIframeHasLoaded,
|
|
12
|
+
url
|
|
13
|
+
} = props;
|
|
14
|
+
const {
|
|
15
|
+
zoom
|
|
16
|
+
} = useLivePreviewContext();
|
|
17
|
+
return /*#__PURE__*/_jsx("iframe", {
|
|
18
|
+
className: baseClass,
|
|
19
|
+
onLoad: () => {
|
|
20
|
+
setIframeHasLoaded(true);
|
|
21
|
+
},
|
|
22
|
+
ref: ref,
|
|
23
|
+
src: url,
|
|
24
|
+
style: {
|
|
25
|
+
transform: typeof zoom === 'number' ? `scale(${zoom}) ` : undefined
|
|
26
|
+
},
|
|
27
|
+
title: url
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useLivePreviewContext","baseClass","IFrame","props","ref","setIframeHasLoaded","url","zoom","_jsx","className","onLoad","src","style","transform","undefined","title"],"sources":["../../../../src/elements/LivePreview/IFrame/index.tsx"],"sourcesContent":["'use client'\nimport React from 'react'\n\nimport { useLivePreviewContext } from '../../../providers/LivePreview/context.js'\nimport './index.scss'\n\nconst baseClass = 'live-preview-iframe'\n\ntype Props = {\n ref: React.RefObject<HTMLIFrameElement>\n setIframeHasLoaded: (value: boolean) => void\n url: string\n}\n\nexport const IFrame: React.FC<Props> = (props) => {\n const { ref, setIframeHasLoaded, url } = props\n\n const { zoom } = useLivePreviewContext()\n\n return (\n <iframe\n className={baseClass}\n onLoad={() => {\n setIframeHasLoaded(true)\n }}\n ref={ref}\n src={url}\n style={{\n transform: typeof zoom === 'number' ? `scale(${zoom}) ` : undefined,\n }}\n title={url}\n />\n )\n}\n"],"mappings":"AAAA;;;AACA,OAAOA,KAAA,MAAW;AAElB,SAASC,qBAAqB,QAAQ;AACtC,OAAO;AAEP,MAAMC,SAAA,GAAY;AAQlB,OAAO,MAAMC,MAAA,GAA2BC,KAAA;EACtC,MAAM;IAAEC,GAAG;IAAEC,kBAAkB;IAAEC;EAAG,CAAE,GAAGH,KAAA;EAEzC,MAAM;IAAEI;EAAI,CAAE,GAAGP,qBAAA;EAEjB,oBACEQ,IAAA,CAAC;IACCC,SAAA,EAAWR,SAAA;IACXS,MAAA,EAAQA,CAAA;MACNL,kBAAA,CAAmB;IACrB;IACAD,GAAA,EAAKA,GAAA;IACLO,GAAA,EAAKL,GAAA;IACLM,KAAA,EAAO;MACLC,SAAA,EAAW,OAAON,IAAA,KAAS,WAAW,SAASA,IAAA,IAAQ,GAAGO;IAC5D;IACAC,KAAA,EAAOT;;AAGb","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/elements/LivePreview/Toggler/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,OAAO,cAAc,CAAA;AAIrB,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAkBtC,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { EyeIcon } from '../../../icons/Eye/index.js';
|
|
4
|
+
import { useLivePreviewContext } from '../../../providers/LivePreview/context.js';
|
|
5
|
+
import { useTranslation } from '../../../providers/Translation/index.js';
|
|
6
|
+
import './index.scss';
|
|
7
|
+
const baseClass = 'live-preview-toggler';
|
|
8
|
+
export const LivePreviewToggler = () => {
|
|
9
|
+
const {
|
|
10
|
+
isLivePreviewing,
|
|
11
|
+
setIsLivePreviewing
|
|
12
|
+
} = useLivePreviewContext();
|
|
13
|
+
const {
|
|
14
|
+
t
|
|
15
|
+
} = useTranslation();
|
|
16
|
+
return /*#__PURE__*/_jsx("button", {
|
|
17
|
+
"aria-label": isLivePreviewing ? t('general:exitLivePreview') : t('general:livePreview'),
|
|
18
|
+
className: [baseClass, isLivePreviewing && `${baseClass}--active`].filter(Boolean).join(' '),
|
|
19
|
+
id: "live-preview-toggler",
|
|
20
|
+
onClick: () => {
|
|
21
|
+
setIsLivePreviewing(!isLivePreviewing);
|
|
22
|
+
},
|
|
23
|
+
title: isLivePreviewing ? t('general:exitLivePreview') : t('general:livePreview'),
|
|
24
|
+
type: "button",
|
|
25
|
+
children: /*#__PURE__*/_jsx(EyeIcon, {
|
|
26
|
+
active: isLivePreviewing
|
|
27
|
+
})
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","EyeIcon","useLivePreviewContext","useTranslation","baseClass","LivePreviewToggler","isLivePreviewing","setIsLivePreviewing","t","_jsx","className","filter","Boolean","join","id","onClick","title","type","active"],"sources":["../../../../src/elements/LivePreview/Toggler/index.tsx"],"sourcesContent":["import React from 'react'\n\nimport { EyeIcon } from '../../../icons/Eye/index.js'\nimport { useLivePreviewContext } from '../../../providers/LivePreview/context.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport './index.scss'\n\nconst baseClass = 'live-preview-toggler'\n\nexport const LivePreviewToggler: React.FC = () => {\n const { isLivePreviewing, setIsLivePreviewing } = useLivePreviewContext()\n const { t } = useTranslation()\n\n return (\n <button\n aria-label={isLivePreviewing ? t('general:exitLivePreview') : t('general:livePreview')}\n className={[baseClass, isLivePreviewing && `${baseClass}--active`].filter(Boolean).join(' ')}\n id=\"live-preview-toggler\"\n onClick={() => {\n setIsLivePreviewing(!isLivePreviewing)\n }}\n title={isLivePreviewing ? t('general:exitLivePreview') : t('general:livePreview')}\n type=\"button\"\n >\n <EyeIcon active={isLivePreviewing} />\n </button>\n )\n}\n"],"mappings":";AAAA,OAAOA,KAAA,MAAW;AAElB,SAASC,OAAO,QAAQ;AACxB,SAASC,qBAAqB,QAAQ;AACtC,SAASC,cAAc,QAAQ;AAC/B,OAAO;AAEP,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,kBAAA,GAA+BA,CAAA;EAC1C,MAAM;IAAEC,gBAAgB;IAAEC;EAAmB,CAAE,GAAGL,qBAAA;EAClD,MAAM;IAAEM;EAAC,CAAE,GAAGL,cAAA;EAEd,oBACEM,IAAA,CAAC;IACC,cAAYH,gBAAA,GAAmBE,CAAA,CAAE,6BAA6BA,CAAA,CAAE;IAChEE,SAAA,EAAW,CAACN,SAAA,EAAWE,gBAAA,IAAoB,GAAGF,SAAA,UAAmB,CAAC,CAACO,MAAM,CAACC,OAAA,EAASC,IAAI,CAAC;IACxFC,EAAA,EAAG;IACHC,OAAA,EAASA,CAAA;MACPR,mBAAA,CAAoB,CAACD,gBAAA;IACvB;IACAU,KAAA,EAAOV,gBAAA,GAAmBE,CAAA,CAAE,6BAA6BA,CAAA,CAAE;IAC3DS,IAAA,EAAK;cAEL,aAAAR,IAAA,CAACR,OAAA;MAAQiB,MAAA,EAAQZ;;;AAGvB","ignoreList":[]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
@import '../../../scss/styles.scss';
|
|
2
|
+
|
|
3
|
+
@layer payload-default {
|
|
4
|
+
.live-preview-toggler {
|
|
5
|
+
background: none;
|
|
6
|
+
border: none;
|
|
7
|
+
border: 1px solid;
|
|
8
|
+
border-color: var(--theme-elevation-100);
|
|
9
|
+
border-radius: var(--style-radius-s);
|
|
10
|
+
line-height: var(--btn-line-height);
|
|
11
|
+
font-size: var(--base-body-size);
|
|
12
|
+
padding: calc(var(--base) * 0.2) calc(var(--base) * 0.4);
|
|
13
|
+
cursor: pointer;
|
|
14
|
+
transition-property: border, color, background;
|
|
15
|
+
transition-duration: 100ms;
|
|
16
|
+
transition-timing-function: cubic-bezier(0, 0.2, 0.2, 1);
|
|
17
|
+
height: calc(var(--base) * 1.6);
|
|
18
|
+
width: calc(var(--base) * 1.6);
|
|
19
|
+
position: relative;
|
|
20
|
+
|
|
21
|
+
.icon {
|
|
22
|
+
position: absolute;
|
|
23
|
+
top: 50%;
|
|
24
|
+
left: 50%;
|
|
25
|
+
transform: translate(-50%, -50%);
|
|
26
|
+
|
|
27
|
+
.stroke {
|
|
28
|
+
transition-property: stroke;
|
|
29
|
+
transition-duration: 100ms;
|
|
30
|
+
transition-timing-function: cubic-bezier(0, 0.2, 0.2, 1);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&:hover {
|
|
35
|
+
border-color: var(--theme-elevation-300);
|
|
36
|
+
background-color: var(--theme-elevation-100);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&--active {
|
|
40
|
+
background-color: var(--theme-elevation-100);
|
|
41
|
+
border-color: var(--theme-elevation-200);
|
|
42
|
+
|
|
43
|
+
&:hover {
|
|
44
|
+
background-color: var(--theme-elevation-200);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/elements/LivePreview/Toolbar/Controls/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE5C,OAAO,KAAK,MAAM,OAAO,CAAA;AASzB,OAAO,cAAc,CAAA;AAKrB,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CA+GnD,CAAA"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { c as _c } from "react/compiler-runtime";
|
|
4
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { ChevronIcon } from '../../../../icons/Chevron/index.js';
|
|
7
|
+
import { ExternalLinkIcon } from '../../../../icons/ExternalLink/index.js';
|
|
8
|
+
import { XIcon } from '../../../../icons/X/index.js';
|
|
9
|
+
import { useLivePreviewContext } from '../../../../providers/LivePreview/context.js';
|
|
10
|
+
import { useTranslation } from '../../../../providers/Translation/index.js';
|
|
11
|
+
import { Popup, PopupList } from '../../../Popup/index.js';
|
|
12
|
+
import { PreviewFrameSizeInput } from '../SizeInput/index.js';
|
|
13
|
+
import './index.scss';
|
|
14
|
+
const baseClass = 'live-preview-toolbar-controls';
|
|
15
|
+
const zoomOptions = [50, 75, 100, 125, 150, 200];
|
|
16
|
+
export const ToolbarControls = () => {
|
|
17
|
+
const $ = _c(14);
|
|
18
|
+
const {
|
|
19
|
+
breakpoint,
|
|
20
|
+
breakpoints,
|
|
21
|
+
setBreakpoint,
|
|
22
|
+
setPreviewWindowType,
|
|
23
|
+
setZoom,
|
|
24
|
+
url,
|
|
25
|
+
zoom
|
|
26
|
+
} = useLivePreviewContext();
|
|
27
|
+
const {
|
|
28
|
+
t
|
|
29
|
+
} = useTranslation();
|
|
30
|
+
let t0;
|
|
31
|
+
if ($[0] !== breakpoint || $[1] !== breakpoints || $[2] !== setBreakpoint || $[3] !== setPreviewWindowType || $[4] !== setZoom || $[5] !== t || $[6] !== url || $[7] !== zoom) {
|
|
32
|
+
const customOption = {
|
|
33
|
+
label: t("general:custom"),
|
|
34
|
+
value: "custom"
|
|
35
|
+
};
|
|
36
|
+
let t2;
|
|
37
|
+
if ($[9] !== setZoom || $[10] !== zoom) {
|
|
38
|
+
t2 = t3 => {
|
|
39
|
+
const {
|
|
40
|
+
close: close_0
|
|
41
|
+
} = t3;
|
|
42
|
+
return _jsx(PopupList.ButtonGroup, {
|
|
43
|
+
children: _jsx(React.Fragment, {
|
|
44
|
+
children: zoomOptions.map(zoomValue => _jsxs(PopupList.Button, {
|
|
45
|
+
active: zoom * 100 == zoomValue,
|
|
46
|
+
onClick: () => {
|
|
47
|
+
setZoom(zoomValue / 100);
|
|
48
|
+
close_0();
|
|
49
|
+
},
|
|
50
|
+
children: [zoomValue, "%"]
|
|
51
|
+
}, zoomValue))
|
|
52
|
+
})
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
$[9] = setZoom;
|
|
56
|
+
$[10] = zoom;
|
|
57
|
+
$[11] = t2;
|
|
58
|
+
} else {
|
|
59
|
+
t2 = $[11];
|
|
60
|
+
}
|
|
61
|
+
let t3;
|
|
62
|
+
if ($[12] !== setPreviewWindowType) {
|
|
63
|
+
t3 = e => {
|
|
64
|
+
e.preventDefault();
|
|
65
|
+
setPreviewWindowType("popup");
|
|
66
|
+
};
|
|
67
|
+
$[12] = setPreviewWindowType;
|
|
68
|
+
$[13] = t3;
|
|
69
|
+
} else {
|
|
70
|
+
t3 = $[13];
|
|
71
|
+
}
|
|
72
|
+
t0 = _jsxs("div", {
|
|
73
|
+
className: baseClass,
|
|
74
|
+
children: [breakpoints?.length > 0 && _jsx(Popup, {
|
|
75
|
+
button: _jsxs(React.Fragment, {
|
|
76
|
+
children: [_jsx("span", {
|
|
77
|
+
children: breakpoints.find(bp => bp.name == breakpoint)?.label ?? customOption.label
|
|
78
|
+
}), _jsx(ChevronIcon, {
|
|
79
|
+
className: `${baseClass}__chevron`
|
|
80
|
+
})]
|
|
81
|
+
}),
|
|
82
|
+
className: `${baseClass}__breakpoint`,
|
|
83
|
+
horizontalAlign: "right",
|
|
84
|
+
render: t1 => {
|
|
85
|
+
const {
|
|
86
|
+
close
|
|
87
|
+
} = t1;
|
|
88
|
+
return _jsx(PopupList.ButtonGroup, {
|
|
89
|
+
children: _jsxs(React.Fragment, {
|
|
90
|
+
children: [breakpoints.map(bp_0 => _jsx(PopupList.Button, {
|
|
91
|
+
active: bp_0.name == breakpoint,
|
|
92
|
+
onClick: () => {
|
|
93
|
+
setBreakpoint(bp_0.name);
|
|
94
|
+
close();
|
|
95
|
+
},
|
|
96
|
+
children: bp_0.label
|
|
97
|
+
}, bp_0.name)), breakpoint === "custom" && _jsx(PopupList.Button, {
|
|
98
|
+
active: breakpoint == customOption.value,
|
|
99
|
+
onClick: () => {
|
|
100
|
+
setBreakpoint(customOption.value);
|
|
101
|
+
close();
|
|
102
|
+
},
|
|
103
|
+
children: customOption.label
|
|
104
|
+
})]
|
|
105
|
+
})
|
|
106
|
+
});
|
|
107
|
+
},
|
|
108
|
+
showScrollbar: true,
|
|
109
|
+
verticalAlign: "bottom"
|
|
110
|
+
}), _jsxs("div", {
|
|
111
|
+
className: `${baseClass}__device-size`,
|
|
112
|
+
children: [_jsx(PreviewFrameSizeInput, {
|
|
113
|
+
axis: "x"
|
|
114
|
+
}), _jsx("span", {
|
|
115
|
+
className: `${baseClass}__size-divider`,
|
|
116
|
+
children: _jsx(XIcon, {})
|
|
117
|
+
}), _jsx(PreviewFrameSizeInput, {
|
|
118
|
+
axis: "y"
|
|
119
|
+
})]
|
|
120
|
+
}), _jsx(Popup, {
|
|
121
|
+
button: _jsxs(React.Fragment, {
|
|
122
|
+
children: [_jsxs("span", {
|
|
123
|
+
children: [zoom * 100, "%"]
|
|
124
|
+
}), _jsx(ChevronIcon, {
|
|
125
|
+
className: `${baseClass}__chevron`
|
|
126
|
+
})]
|
|
127
|
+
}),
|
|
128
|
+
className: `${baseClass}__zoom`,
|
|
129
|
+
horizontalAlign: "right",
|
|
130
|
+
render: t2,
|
|
131
|
+
showScrollbar: true,
|
|
132
|
+
verticalAlign: "bottom"
|
|
133
|
+
}), _jsx("a", {
|
|
134
|
+
className: `${baseClass}__external`,
|
|
135
|
+
href: url,
|
|
136
|
+
onClick: t3,
|
|
137
|
+
target: "_blank",
|
|
138
|
+
title: "Open in new window",
|
|
139
|
+
type: "button",
|
|
140
|
+
children: _jsx(ExternalLinkIcon, {})
|
|
141
|
+
})]
|
|
142
|
+
});
|
|
143
|
+
$[0] = breakpoint;
|
|
144
|
+
$[1] = breakpoints;
|
|
145
|
+
$[2] = setBreakpoint;
|
|
146
|
+
$[3] = setPreviewWindowType;
|
|
147
|
+
$[4] = setZoom;
|
|
148
|
+
$[5] = t;
|
|
149
|
+
$[6] = url;
|
|
150
|
+
$[7] = zoom;
|
|
151
|
+
$[8] = t0;
|
|
152
|
+
} else {
|
|
153
|
+
t0 = $[8];
|
|
154
|
+
}
|
|
155
|
+
return t0;
|
|
156
|
+
};
|
|
157
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","React","ChevronIcon","ExternalLinkIcon","XIcon","useLivePreviewContext","useTranslation","Popup","PopupList","PreviewFrameSizeInput","baseClass","zoomOptions","ToolbarControls","$","breakpoint","breakpoints","setBreakpoint","setPreviewWindowType","setZoom","url","zoom","t","t0","customOption","label","value","t2","t3","close","close_0","_jsx","ButtonGroup","children","Fragment","map","zoomValue","_jsxs","Button","active","onClick","e","preventDefault","className","length","button","find","bp","name","horizontalAlign","render","t1","bp_0","axis","href","target","title","type"],"sources":["../../../../../src/elements/LivePreview/Toolbar/Controls/index.tsx"],"sourcesContent":["'use client'\n\nimport type { EditViewProps } from 'payload'\n\nimport React from 'react'\n\nimport { ChevronIcon } from '../../../../icons/Chevron/index.js'\nimport { ExternalLinkIcon } from '../../../../icons/ExternalLink/index.js'\nimport { XIcon } from '../../../../icons/X/index.js'\nimport { useLivePreviewContext } from '../../../../providers/LivePreview/context.js'\nimport { useTranslation } from '../../../../providers/Translation/index.js'\nimport { Popup, PopupList } from '../../../Popup/index.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\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 <ChevronIcon 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 <XIcon />\n </span>\n <PreviewFrameSizeInput axis=\"y\" />\n </div>\n <Popup\n button={\n <React.Fragment>\n <span>{zoom * 100}%</span>\n <ChevronIcon 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 target=\"_blank\"\n title=\"Open in new window\"\n type=\"button\"\n >\n <ExternalLinkIcon />\n </a>\n </div>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAIA,OAAOC,KAAA,MAAW;AAElB,SAASC,WAAW,QAAQ;AAC5B,SAASC,gBAAgB,QAAQ;AACjC,SAASC,KAAK,QAAQ;AACtB,SAASC,qBAAqB,QAAQ;AACtC,SAASC,cAAc,QAAQ;AAC/B,SAASC,KAAK,EAAEC,SAAS,QAAQ;AACjC,SAASC,qBAAqB,QAAQ;AACtC,OAAO;AAEP,MAAMC,SAAA,GAAY;AAClB,MAAMC,WAAA,GAAc,CAAC,IAAI,IAAI,KAAK,KAAK,KAAK,IAAI;AAEhD,OAAO,MAAMC,eAAA,GAA2CA,CAAA;EAAA,MAAAC,CAAA,GAAAb,EAAA;EACtD;IAAAc,UAAA;IAAAC,WAAA;IAAAC,aAAA;IAAAC,oBAAA;IAAAC,OAAA;IAAAC,GAAA;IAAAC;EAAA,IACEf,qBAAA;EAEF;IAAAgB;EAAA,IAAcf,cAAA;EAAA,IAAAgB,EAAA;EAAA,IAAAT,CAAA,QAAAC,UAAA,IAAAD,CAAA,QAAAE,WAAA,IAAAF,CAAA,QAAAG,aAAA,IAAAH,CAAA,QAAAI,oBAA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A,EAA4B;QAAA,C;UAE9BtB,IAAA,CAAAvB,KAAA;QAAAqC,MAAA,EAEIR,KAAA,CAAAnC,KAAA,CAAAgC,QAAA;UAAAD,QAAA,GACEI,KAAA,CAAC;YAAAJ,QAAA,GAAMZ,IAAA,MAAO,EAAI;UAAA,C,GAClBU,IAAA,CAAA5B,WAAA;YAAAwC,SAAA,EAAwB,GAAAhC,SAAA;UAAuB,C;;mBAGxC,GAAAA,SAAA,QAAoB;QAAAsC,eAAA,EACf;QAAAC,MAAA,EACRvB,E;;uBAmBM;MAAA,C,GAEhBI,IAAA,CAAC;QAAAY,SAAA,EACY,GAAAhC,SAAA,YAAwB;QAAA2C,IAAA,EAC7BlC,GAAA;QAAAoB,OAAA,EACGZ,EAGT;QAAA2B,MAAA,EACO;QAAAC,KAAA,EACD;QAAAC,IAAA,EACD;QAAAxB,QAAA,EAELF,IAAA,CAAA3B,gBAAA,IAAC;MAAA,C;;;;;;;;;;;;;;SA/FLmB,E;CAmGJ","ignoreList":[]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
@import '../../../../scss/styles.scss';
|
|
2
|
+
|
|
3
|
+
@layer payload-default {
|
|
4
|
+
.live-preview-toolbar-controls {
|
|
5
|
+
display: flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
gap: calc(var(--base) / 3);
|
|
8
|
+
|
|
9
|
+
&__breakpoint {
|
|
10
|
+
border: none;
|
|
11
|
+
background: transparent;
|
|
12
|
+
height: var(--base);
|
|
13
|
+
|
|
14
|
+
&:focus {
|
|
15
|
+
outline: none;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&__device-size {
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: center;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&__size {
|
|
25
|
+
width: 50px;
|
|
26
|
+
height: var(--base);
|
|
27
|
+
display: flex;
|
|
28
|
+
align-items: center;
|
|
29
|
+
border: 1px solid var(--theme-elevation-200);
|
|
30
|
+
background: var(--theme-elevation-100);
|
|
31
|
+
border-radius: 2px;
|
|
32
|
+
font-size: small;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&__zoom {
|
|
36
|
+
width: 55px;
|
|
37
|
+
border: none;
|
|
38
|
+
background: transparent;
|
|
39
|
+
height: var(--base);
|
|
40
|
+
|
|
41
|
+
&:focus {
|
|
42
|
+
outline: none;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
&__external {
|
|
47
|
+
flex-shrink: 0;
|
|
48
|
+
display: flex;
|
|
49
|
+
width: var(--base);
|
|
50
|
+
height: var(--base);
|
|
51
|
+
align-items: center;
|
|
52
|
+
justify-content: center;
|
|
53
|
+
padding: 6px 0;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.popup-button {
|
|
57
|
+
display: flex;
|
|
58
|
+
align-items: center;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/elements/LivePreview/Toolbar/SizeInput/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAiC,MAAM,OAAO,CAAA;AAGrD,OAAO,cAAc,CAAA;AAIrB,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC;IAC3C,IAAI,CAAC,EAAE,GAAG,GAAG,GAAG,CAAA;CACjB,CA+DA,CAAA"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { c as _c } from "react/compiler-runtime";
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
import React, { useCallback, useEffect } from 'react';
|
|
6
|
+
import { useLivePreviewContext } from '../../../../providers/LivePreview/context.js';
|
|
7
|
+
import './index.scss';
|
|
8
|
+
const baseClass = 'toolbar-input';
|
|
9
|
+
export const PreviewFrameSizeInput = props => {
|
|
10
|
+
const $ = _c(18);
|
|
11
|
+
const {
|
|
12
|
+
axis
|
|
13
|
+
} = props;
|
|
14
|
+
const {
|
|
15
|
+
breakpoint,
|
|
16
|
+
measuredDeviceSize,
|
|
17
|
+
setBreakpoint,
|
|
18
|
+
setSize,
|
|
19
|
+
size,
|
|
20
|
+
zoom
|
|
21
|
+
} = useLivePreviewContext();
|
|
22
|
+
const [internalState, setInternalState] = React.useState((axis === "x" ? measuredDeviceSize?.width : measuredDeviceSize?.height) || 0);
|
|
23
|
+
let t0;
|
|
24
|
+
if ($[0] !== axis || $[1] !== measuredDeviceSize?.height || $[2] !== measuredDeviceSize?.width || $[3] !== setBreakpoint || $[4] !== setSize || $[5] !== zoom) {
|
|
25
|
+
t0 = e => {
|
|
26
|
+
let newValue = Number(e.target.value);
|
|
27
|
+
if (newValue < 0) {
|
|
28
|
+
newValue = 0;
|
|
29
|
+
}
|
|
30
|
+
setInternalState(newValue);
|
|
31
|
+
setBreakpoint("custom");
|
|
32
|
+
setSize({
|
|
33
|
+
type: "reset",
|
|
34
|
+
value: {
|
|
35
|
+
height: axis === "y" ? newValue : Number(measuredDeviceSize?.height.toFixed(0)) * zoom,
|
|
36
|
+
width: axis === "x" ? newValue : Number(measuredDeviceSize?.width.toFixed(0)) * zoom
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
$[0] = axis;
|
|
41
|
+
$[1] = measuredDeviceSize?.height;
|
|
42
|
+
$[2] = measuredDeviceSize?.width;
|
|
43
|
+
$[3] = setBreakpoint;
|
|
44
|
+
$[4] = setSize;
|
|
45
|
+
$[5] = zoom;
|
|
46
|
+
$[6] = t0;
|
|
47
|
+
} else {
|
|
48
|
+
t0 = $[6];
|
|
49
|
+
}
|
|
50
|
+
const handleChange = t0;
|
|
51
|
+
let t1;
|
|
52
|
+
let t2;
|
|
53
|
+
if ($[7] !== axis || $[8] !== breakpoint || $[9] !== measuredDeviceSize || $[10] !== size || $[11] !== zoom) {
|
|
54
|
+
t1 = () => {
|
|
55
|
+
if (breakpoint === "responsive" && measuredDeviceSize) {
|
|
56
|
+
if (axis === "x") {
|
|
57
|
+
setInternalState(Number(measuredDeviceSize.width.toFixed(0)) * zoom);
|
|
58
|
+
} else {
|
|
59
|
+
setInternalState(Number(measuredDeviceSize.height.toFixed(0)) * zoom);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (breakpoint !== "responsive" && size) {
|
|
63
|
+
setInternalState(axis === "x" ? size.width : size.height);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
t2 = [breakpoint, axis, measuredDeviceSize, size, zoom];
|
|
67
|
+
$[7] = axis;
|
|
68
|
+
$[8] = breakpoint;
|
|
69
|
+
$[9] = measuredDeviceSize;
|
|
70
|
+
$[10] = size;
|
|
71
|
+
$[11] = zoom;
|
|
72
|
+
$[12] = t1;
|
|
73
|
+
$[13] = t2;
|
|
74
|
+
} else {
|
|
75
|
+
t1 = $[12];
|
|
76
|
+
t2 = $[13];
|
|
77
|
+
}
|
|
78
|
+
useEffect(t1, t2);
|
|
79
|
+
const t3 = axis === "x" ? "live-preview-width" : "live-preview-height";
|
|
80
|
+
const t4 = internalState || 0;
|
|
81
|
+
let t5;
|
|
82
|
+
if ($[14] !== handleChange || $[15] !== t3 || $[16] !== t4) {
|
|
83
|
+
t5 = _jsx("input", {
|
|
84
|
+
className: baseClass,
|
|
85
|
+
min: 0,
|
|
86
|
+
name: t3,
|
|
87
|
+
onChange: handleChange,
|
|
88
|
+
step: 1,
|
|
89
|
+
type: "number",
|
|
90
|
+
value: t4
|
|
91
|
+
});
|
|
92
|
+
$[14] = handleChange;
|
|
93
|
+
$[15] = t3;
|
|
94
|
+
$[16] = t4;
|
|
95
|
+
$[17] = t5;
|
|
96
|
+
} else {
|
|
97
|
+
t5 = $[17];
|
|
98
|
+
}
|
|
99
|
+
return t5;
|
|
100
|
+
};
|
|
101
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","React","useCallback","useEffect","useLivePreviewContext","baseClass","PreviewFrameSizeInput","props","$","axis","breakpoint","measuredDeviceSize","setBreakpoint","setSize","size","zoom","internalState","setInternalState","useState","width","height","t0","e","newValue","Number","target","value","type","toFixed","handleChange","t1","t2","t3","t4","t5","_jsx","className","min","name","onChange","step"],"sources":["../../../../../src/elements/LivePreview/Toolbar/SizeInput/index.tsx"],"sourcesContent":["'use client'\nimport React, { useCallback, useEffect } from 'react'\n\nimport { useLivePreviewContext } from '../../../../providers/LivePreview/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) {\n newValue = 0\n }\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') {\n setInternalState(Number(measuredDeviceSize.width.toFixed(0)) * zoom)\n } else {\n setInternalState(Number(measuredDeviceSize.height.toFixed(0)) * zoom)\n }\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"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AACA,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,QAAQ;AAE9C,SAASC,qBAAqB,QAAQ;AACtC,OAAO;AAEP,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,qBAAA,GAERC,KAAA;EAAA,MAAAC,CAAA,GAAAR,EAAA;EACH;IAAAS;EAAA,IAAiBF,KAAA;EAEjB;IAAAG,UAAA;IAAAC,kBAAA;IAAAC,aAAA;IAAAC,OAAA;IAAAC,IAAA;IAAAC;EAAA,IACEX,qBAAA;EAEF,OAAAY,aAAA,EAAAC,gBAAA,IAA0ChB,KAAA,CAAAiB,QAAA,CACxC,CAACT,IAAA,KAAS,MAAME,kBAAA,EAAAQ,KAAA,GAA4BR,kBAAA,EAAAS,MAAyB,MAAM;EAAA,IAAAC,EAAA;EAAA,IAAAb,CAAA,QAAAC,IAAA,IAAAD,CAAA,QAAAG,kBAAA,EAAAS,MAAA,IAAAZ,CAAA,QAAAG,kBAAA,EAAAQ,KAAA,IAAAX,CAAA,QAAAI,aAAA,IAAAJ,CAAA,QAAAK,OAAA,IAAAL,CAAA,QAAAO,IAAA;IAM3EM,EAAA,GAAAC,CAAA;MACE,IAAAC,QAAA,GAAeC,MAAA,CAAOF,CAAA,CAAAG,MAAA,CAAAC,KAAc;MAAA,IAEhCH,QAAA,IAAW;QACbA,QAAA,CAAAA,CAAA,CAAAA,CAAA;MAAA;MAGFN,gBAAA,CAAiBM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AW;MAAA;IAAA;IAEzDW,EAAA,IAACrB,UAAA,EAAYD,IAAA,EAAME,kBAAA,EAAoBG,IAAA,EAAMC,IAAA;IAAKP,CAAA,MAAAC,IAAA;IAAAD,CAAA,MAAAE,UAAA;IAAAF,CAAA,MAAAG,kBAAA;IAAAH,CAAA,OAAAM,IAAA;IAAAN,CAAA,OAAAO,IAAA;IAAAP,CAAA,OAAAsB,EAAA;IAAAtB,CAAA,OAAAuB,EAAA;EAAA;IAAAD,EAAA,GAAAtB,CAAA;IAAAuB,EAAA,GAAAvB,CAAA;EAAA;EAZrDL,SAAA,CAAU2B,EAYV,EAAGC,EAAkD;EAM3C,MAAAC,EAAA,GAAAvB,IAAA,KAAS,MAAM,uBAAuB;EAIrC,MAAAwB,EAAA,GAAAjB,aAAA,KAAiB;EAAA,IAAAkB,EAAA;EAAA,IAAA1B,CAAA,SAAAqB,YAAA,IAAArB,CAAA,SAAAwB,EAAA,IAAAxB,CAAA,SAAAyB,EAAA;IAP1BC,EAAA,GAAAC,IAAA,CAAC;MAAAC,SAAA,EAAA/B,SAAA;MAAAgC,GAAA;MAAAC,IAAA,EAGON,EAAsC;MAAAO,QAAA,EAClCV,YAAA;MAAAW,IAAA;MAAAb,IAAA,EAEL;MAAAD,KAAA,EACEO;IAAiB,C;;;;;;;;SAP1BC,E;CAUJ","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
@layer payload-default {
|
|
2
|
+
.toolbar-input {
|
|
3
|
+
width: 50px;
|
|
4
|
+
height: var(--base);
|
|
5
|
+
display: flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
border: 1px solid var(--theme-elevation-200);
|
|
8
|
+
background: var(--theme-elevation-100);
|
|
9
|
+
border-radius: 2px;
|
|
10
|
+
font-size: small;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/elements/LivePreview/Toolbar/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAG5C,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,OAAO,cAAc,CAAA;AAgDrB,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CACvC;IACE,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB,GAAG,aAAa,CASlB,CAAA"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { c as _c } from "react/compiler-runtime";
|
|
4
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { useDraggable } from '@dnd-kit/core';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { DragHandleIcon } from '../../../icons/DragHandle/index.js';
|
|
8
|
+
import { useLivePreviewContext } from '../../../providers/LivePreview/context.js';
|
|
9
|
+
import { ToolbarControls } from './Controls/index.js';
|
|
10
|
+
import './index.scss';
|
|
11
|
+
const baseClass = 'live-preview-toolbar';
|
|
12
|
+
const DraggableToolbar = props => {
|
|
13
|
+
const $ = _c(10);
|
|
14
|
+
const {
|
|
15
|
+
toolbarPosition
|
|
16
|
+
} = useLivePreviewContext();
|
|
17
|
+
let t0;
|
|
18
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
19
|
+
t0 = {
|
|
20
|
+
id: "live-preview-toolbar"
|
|
21
|
+
};
|
|
22
|
+
$[0] = t0;
|
|
23
|
+
} else {
|
|
24
|
+
t0 = $[0];
|
|
25
|
+
}
|
|
26
|
+
const {
|
|
27
|
+
attributes,
|
|
28
|
+
listeners,
|
|
29
|
+
setNodeRef,
|
|
30
|
+
transform
|
|
31
|
+
} = useDraggable(t0);
|
|
32
|
+
let t1;
|
|
33
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
34
|
+
t1 = [baseClass, `${baseClass}--draggable`];
|
|
35
|
+
$[1] = t1;
|
|
36
|
+
} else {
|
|
37
|
+
t1 = $[1];
|
|
38
|
+
}
|
|
39
|
+
const t2 = `${toolbarPosition.x}px`;
|
|
40
|
+
const t3 = `${toolbarPosition.y}px`;
|
|
41
|
+
let t4;
|
|
42
|
+
if ($[2] !== attributes || $[3] !== listeners || $[4] !== props || $[5] !== setNodeRef || $[6] !== t2 || $[7] !== t3 || $[8] !== transform) {
|
|
43
|
+
t4 = _jsxs("div", {
|
|
44
|
+
className: t1.join(" "),
|
|
45
|
+
style: {
|
|
46
|
+
left: t2,
|
|
47
|
+
top: t3,
|
|
48
|
+
...(transform ? {
|
|
49
|
+
transform: transform ? `translate3d(${transform?.x || 0}px, ${transform?.y || 0}px, 0)` : undefined
|
|
50
|
+
} : {})
|
|
51
|
+
},
|
|
52
|
+
children: [_jsx("button", {
|
|
53
|
+
...listeners,
|
|
54
|
+
...attributes,
|
|
55
|
+
className: `${baseClass}__drag-handle`,
|
|
56
|
+
ref: setNodeRef,
|
|
57
|
+
type: "button",
|
|
58
|
+
children: _jsx(DragHandleIcon, {})
|
|
59
|
+
}), _jsx(ToolbarControls, {
|
|
60
|
+
...props
|
|
61
|
+
})]
|
|
62
|
+
});
|
|
63
|
+
$[2] = attributes;
|
|
64
|
+
$[3] = listeners;
|
|
65
|
+
$[4] = props;
|
|
66
|
+
$[5] = setNodeRef;
|
|
67
|
+
$[6] = t2;
|
|
68
|
+
$[7] = t3;
|
|
69
|
+
$[8] = transform;
|
|
70
|
+
$[9] = t4;
|
|
71
|
+
} else {
|
|
72
|
+
t4 = $[9];
|
|
73
|
+
}
|
|
74
|
+
return t4;
|
|
75
|
+
};
|
|
76
|
+
const StaticToolbar = props => {
|
|
77
|
+
return /*#__PURE__*/_jsx("div", {
|
|
78
|
+
className: [baseClass, `${baseClass}--static`].join(' '),
|
|
79
|
+
children: /*#__PURE__*/_jsx(ToolbarControls, {
|
|
80
|
+
...props
|
|
81
|
+
})
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
export const LivePreviewToolbar = props => {
|
|
85
|
+
const {
|
|
86
|
+
draggable
|
|
87
|
+
} = props;
|
|
88
|
+
if (draggable) {
|
|
89
|
+
return /*#__PURE__*/_jsx(DraggableToolbar, {
|
|
90
|
+
...props
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return /*#__PURE__*/_jsx(StaticToolbar, {
|
|
94
|
+
...props
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","useDraggable","React","DragHandleIcon","useLivePreviewContext","ToolbarControls","baseClass","DraggableToolbar","props","$","toolbarPosition","t0","Symbol","for","id","attributes","listeners","setNodeRef","transform","t1","t2","x","t3","y","t4","_jsxs","className","join","style","left","top","undefined","children","_jsx","ref","type","StaticToolbar","LivePreviewToolbar","draggable"],"sources":["../../../../src/elements/LivePreview/Toolbar/index.tsx"],"sourcesContent":["'use client'\nimport type { EditViewProps } from 'payload'\n\nimport { useDraggable } from '@dnd-kit/core'\nimport React from 'react'\n\nimport { DragHandleIcon } from '../../../icons/DragHandle/index.js'\nimport { useLivePreviewContext } from '../../../providers/LivePreview/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 <DragHandleIcon />\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 {\n draggable?: boolean\n } & EditViewProps\n> = (props) => {\n const { draggable } = props\n\n if (draggable) {\n return <DraggableToolbar {...props} />\n }\n\n return <StaticToolbar {...props} />\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,YAAY,QAAQ;AAC7B,OAAOC,KAAA,MAAW;AAElB,SAASC,cAAc,QAAQ;AAC/B,SAASC,qBAAqB,QAAQ;AACtC,SAASC,eAAe,QAAQ;AAChC,OAAO;AAEP,MAAMC,SAAA,GAAY;AAElB,MAAMC,gBAAA,GAA4CC,KAAA;EAAA,MAAAC,CAAA,GAAAT,EAAA;EAChD;IAAAU;EAAA,IAA4BN,qBAAA;EAAA,IAAAO,EAAA;EAAA,IAAAF,CAAA,QAAAG,MAAA,CAAAC,GAAA;IAE0CF,EAAA;MAAAG,EAAA,EAChE;IAAA;IACNL,CAAA,MAAAE,EAAA;EAAA;IAAAA,EAAA,GAAAF,CAAA;EAAA;EAFA;IAAAM,UAAA;IAAAC,SAAA;IAAAC,UAAA;IAAAC;EAAA,IAAyDjB,YAAA,CAAaU,EAEtE;EAAA,IAAAQ,EAAA;EAAA,IAAAV,CAAA,QAAAG,MAAA,CAAAC,GAAA;IAIeM,EAAA,IAAAb,SAAA,EAAY,GAAAA,SAAA,aAAyB;IAACG,CAAA,MAAAU,EAAA;EAAA;IAAAA,EAAA,GAAAV,CAAA;EAAA;EAEzC,MAAAW,EAAA,MAAGV,eAAA,CAAAW,CAAA,IAAqB;EACzB,MAAAC,EAAA,MAAGZ,eAAA,CAAAa,CAAA,IAAqB;EAAA,IAAAC,EAAA;EAAA,IAAAf,CAAA,QAAAM,UAAA,IAAAN,CAAA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