@payloadcms/ui 3.59.0-internal.5ab25cf → 3.59.0-internal.6aee982
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/Collapsible/index.d.ts +2 -15
- package/dist/elements/Collapsible/index.d.ts.map +1 -1
- package/dist/elements/Collapsible/index.js +60 -59
- package/dist/elements/Collapsible/index.js.map +1 -1
- package/dist/elements/Collapsible/index.scss +2 -6
- package/dist/elements/DocumentDrawer/Provider.d.ts +1 -1
- package/dist/elements/DocumentDrawer/Provider.js.map +1 -1
- package/dist/elements/Nav/context.d.ts +0 -6
- package/dist/elements/Nav/context.d.ts.map +1 -1
- package/dist/elements/Nav/context.js +0 -6
- package/dist/elements/Nav/context.js.map +1 -1
- package/dist/elements/RelationshipTable/index.d.ts.map +1 -1
- package/dist/elements/RelationshipTable/index.js +3 -2
- package/dist/elements/RelationshipTable/index.js.map +1 -1
- package/dist/elements/Table/index.scss +1 -0
- package/dist/exports/client/{CodeEditor-2AHTKKBE.js → CodeEditor-UTOLPRAV.js} +2 -2
- package/dist/exports/client/{chunk-6UH4KUYK.js → chunk-S2X3JKSP.js} +1 -1
- package/dist/exports/client/{chunk-6UH4KUYK.js.map → chunk-S2X3JKSP.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 +12 -12
- package/dist/exports/client/index.js.map +4 -4
- package/dist/fields/Code/index.d.ts.map +1 -1
- package/dist/fields/Code/index.js +1 -3
- package/dist/fields/Code/index.js.map +1 -1
- package/dist/fields/Slug/index.d.ts +8 -0
- package/dist/fields/Slug/index.d.ts.map +1 -0
- package/dist/fields/Slug/index.js +128 -0
- package/dist/fields/Slug/index.js.map +1 -0
- package/dist/fields/Slug/index.scss +17 -0
- package/dist/fields/Upload/RelationshipContent/index.js +1 -1
- package/dist/fields/Upload/RelationshipContent/index.js.map +1 -1
- package/dist/forms/Form/types.d.ts +2 -2
- package/dist/forms/Form/types.js.map +1 -1
- package/dist/forms/RenderFields/context.d.ts +2 -2
- package/dist/forms/RenderFields/context.js +2 -2
- package/dist/forms/RenderFields/context.js.map +1 -1
- package/dist/providers/Config/index.d.ts +1 -1
- package/dist/providers/Config/index.js +1 -1
- package/dist/providers/Config/index.js.map +1 -1
- package/dist/providers/LivePreview/index.d.ts.map +1 -1
- package/dist/providers/LivePreview/index.js +3 -0
- package/dist/providers/LivePreview/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/utilities/getColumns.js +1 -1
- package/dist/utilities/getColumns.js.map +1 -1
- package/dist/utilities/handleLivePreview.d.ts +1 -1
- package/dist/utilities/handleLivePreview.d.ts.map +1 -1
- package/dist/utilities/handleLivePreview.js +1 -1
- package/dist/utilities/handleLivePreview.js.map +1 -1
- package/package.json +4 -4
- /package/dist/exports/client/{CodeEditor-2AHTKKBE.js.map → CodeEditor-UTOLPRAV.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Code/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAoD,MAAM,OAAO,CAAA;AAWxE,OAAO,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Code/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAoD,MAAM,OAAO,CAAA;AAWxE,OAAO,cAAc,CAAA;AAkIrB,eAAO,MAAM,SAAS;;;;;;;+EAAoC,CAAA"}
|
|
@@ -25,7 +25,6 @@ const CodeFieldComponent = props => {
|
|
|
25
25
|
className,
|
|
26
26
|
description,
|
|
27
27
|
editorOptions,
|
|
28
|
-
editorProps,
|
|
29
28
|
language = 'javascript'
|
|
30
29
|
} = {},
|
|
31
30
|
label,
|
|
@@ -116,8 +115,7 @@ const CodeFieldComponent = props => {
|
|
|
116
115
|
value: stringValueRef.current,
|
|
117
116
|
wrapperProps: {
|
|
118
117
|
id: `field-${path?.replace(/\./g, '__')}`
|
|
119
|
-
}
|
|
120
|
-
...(editorProps || {})
|
|
118
|
+
}
|
|
121
119
|
}), AfterInput]
|
|
122
120
|
}), /*#__PURE__*/_jsx(RenderCustomComponent, {
|
|
123
121
|
CustomComponent: Description,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useCallback","useEffect","useMemo","useState","CodeEditor","RenderCustomComponent","FieldDescription","FieldError","FieldLabel","useField","withCondition","mergeFieldStyles","fieldBaseClass","prismToMonacoLanguageMap","js","ts","baseClass","CodeFieldComponent","props","field","admin","className","description","editorOptions","
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useCallback","useEffect","useMemo","useState","CodeEditor","RenderCustomComponent","FieldDescription","FieldError","FieldLabel","useField","withCondition","mergeFieldStyles","fieldBaseClass","prismToMonacoLanguageMap","js","ts","baseClass","CodeFieldComponent","props","field","admin","className","description","editorOptions","language","label","localized","required","onMount","path","pathFromProps","readOnly","validate","inputChangeFromRef","useRef","recalculatedHeightAt","setRecalculatedHeightAt","Date","now","memoizedValidate","value","options","customComponents","AfterInput","BeforeInput","Description","Error","Label","disabled","initialValue","setValue","showError","potentiallyStalePath","stringValueRef","undefined","handleChange","val","current","e","styles","_jsxs","filter","Boolean","join","style","_jsx","CustomComponent","Fallback","defaultLanguage","onChange","wrapperProps","id","replace","CodeField"],"sources":["../../../src/fields/Code/index.tsx"],"sourcesContent":["'use client'\nimport type { CodeFieldClientComponent } from 'payload'\n\nimport React, { useCallback, useEffect, useMemo, useState } from 'react'\n\nimport { CodeEditor } from '../../elements/CodeEditor/index.js'\nimport { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js'\nimport { FieldDescription } from '../../fields/FieldDescription/index.js'\nimport { FieldError } from '../../fields/FieldError/index.js'\nimport { FieldLabel } from '../../fields/FieldLabel/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { mergeFieldStyles } from '../mergeFieldStyles.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\n\nconst prismToMonacoLanguageMap = {\n js: 'javascript',\n ts: 'typescript',\n}\n\nconst baseClass = 'code-field'\n\nconst CodeFieldComponent: CodeFieldClientComponent = (props) => {\n const {\n field,\n field: {\n admin: { className, description, editorOptions, language = 'javascript' } = {},\n label,\n localized,\n required,\n },\n onMount,\n path: pathFromProps,\n readOnly,\n validate,\n } = props\n\n const inputChangeFromRef = React.useRef<'formState' | 'internalEditor'>('formState')\n const [recalculatedHeightAt, setRecalculatedHeightAt] = useState<number | undefined>(Date.now())\n\n const memoizedValidate = useCallback(\n (value, options) => {\n if (typeof validate === 'function') {\n return validate(value, { ...options, required })\n }\n },\n [validate, required],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n disabled,\n initialValue,\n path,\n setValue,\n showError,\n value,\n } = useField<string>({\n potentiallyStalePath: pathFromProps,\n validate: memoizedValidate,\n })\n\n const stringValueRef = React.useRef<string>(\n (value || initialValue) !== undefined ? (value ?? initialValue) : undefined,\n )\n\n const handleChange = useCallback(\n (val: string) => {\n if (readOnly || disabled) {\n return\n }\n inputChangeFromRef.current = 'internalEditor'\n\n try {\n setValue(val ? val : null)\n stringValueRef.current = val\n } catch (e) {\n setValue(val ? val : null)\n stringValueRef.current = val\n }\n },\n [readOnly, disabled, setValue],\n )\n\n useEffect(() => {\n if (inputChangeFromRef.current === 'formState') {\n stringValueRef.current =\n (value || initialValue) !== undefined ? (value ?? initialValue) : undefined\n setRecalculatedHeightAt(Date.now())\n }\n\n inputChangeFromRef.current = 'formState'\n }, [initialValue, path, value])\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n return (\n <div\n className={[\n fieldBaseClass,\n baseClass,\n className,\n showError && 'error',\n (readOnly || disabled) && 'read-only',\n ]\n .filter(Boolean)\n .join(' ')}\n style={styles}\n >\n <RenderCustomComponent\n CustomComponent={Label}\n Fallback={\n <FieldLabel label={label} localized={localized} path={path} required={required} />\n }\n />\n <div className={`${fieldBaseClass}__wrap`}>\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError path={path} showError={showError} />}\n />\n {BeforeInput}\n <CodeEditor\n defaultLanguage={prismToMonacoLanguageMap[language] || language}\n onChange={handleChange}\n onMount={onMount}\n options={editorOptions}\n readOnly={readOnly || disabled}\n recalculatedHeightAt={recalculatedHeightAt}\n value={stringValueRef.current}\n wrapperProps={{\n id: `field-${path?.replace(/\\./g, '__')}`,\n }}\n />\n {AfterInput}\n </div>\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n )\n}\n\nexport const CodeField = withCondition(CodeFieldComponent)\n"],"mappings":"AAAA;;;AAGA,OAAOA,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ;AAEjE,SAASC,UAAU,QAAQ;AAC3B,SAASC,qBAAqB,QAAQ;AACtC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,UAAU,QAAQ;AAC3B,SAASC,UAAU,QAAQ;AAC3B,SAASC,QAAQ,QAAQ;AACzB,SAASC,aAAa,QAAQ;AAC9B,SAASC,gBAAgB,QAAQ;AACjC,SAASC,cAAc,QAAQ;AAC/B,OAAO;AAEP,MAAMC,wBAAA,GAA2B;EAC/BC,EAAA,EAAI;EACJC,EAAA,EAAI;AACN;AAEA,MAAMC,SAAA,GAAY;AAElB,MAAMC,kBAAA,GAAgDC,KAAA;EACpD,MAAM;IACJC,KAAK;IACLA,KAAA,EAAO;MACLC,KAAA,EAAO;QAAEC,SAAS;QAAEC,WAAW;QAAEC,aAAa;QAAEC,QAAA,GAAW;MAAY,CAAE,GAAG,CAAC,CAAC;MAC9EC,KAAK;MACLC,SAAS;MACTC;IAAQ,CACT;IACDC,OAAO;IACPC,IAAA,EAAMC,aAAa;IACnBC,QAAQ;IACRC;EAAQ,CACT,GAAGd,KAAA;EAEJ,MAA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,QAAA,IAAYiB,QAAA;QACtBb,oBAAA,EAAsBA,oBAAA;QACtBK,KAAA,EAAOa,cAAA,CAAeI,OAAO;QAC7Ba,YAAA,EAAc;UACZC,EAAA,EAAI,SAAS1C,IAAA,EAAM2C,OAAA,CAAQ,OAAO;QACpC;UAED7B,UAAA;qBAEHsB,IAAA,CAAC5D,qBAAA;MACC6D,eAAA,EAAiBrB,WAAA;MACjBsB,QAAA,eAAUF,IAAA,CAAC3D,gBAAA;QAAiBgB,WAAA,EAAaA,WAAA;QAAaO,IAAA,EAAMA;;;;AAIpE;AAEA,OAAO,MAAM4C,SAAA,GAAY/D,aAAA,CAAcO,kBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SlugFieldProps } from 'payload';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import './index.scss';
|
|
4
|
+
/**
|
|
5
|
+
* @experimental This component is experimental and may change or be removed in the future. Use at your own risk.
|
|
6
|
+
*/
|
|
7
|
+
export declare const SlugField: React.FC<SlugFieldProps>;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Slug/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAG7C,OAAO,KAAgC,MAAM,OAAO,CAAA;AAOpD,OAAO,cAAc,CAAA;AAErB;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CA6D9C,CAAA"}
|
|
@@ -0,0 +1,128 @@
|
|
|
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 { slugify } from 'payload/shared';
|
|
6
|
+
import React, { useCallback, useState } from 'react';
|
|
7
|
+
import { Button } from '../../elements/Button/index.js';
|
|
8
|
+
import { useForm } from '../../forms/Form/index.js';
|
|
9
|
+
import { useField } from '../../forms/useField/index.js';
|
|
10
|
+
import { FieldLabel } from '../FieldLabel/index.js';
|
|
11
|
+
import { TextInput } from '../Text/index.js';
|
|
12
|
+
import './index.scss';
|
|
13
|
+
/**
|
|
14
|
+
* @experimental This component is experimental and may change or be removed in the future. Use at your own risk.
|
|
15
|
+
*/
|
|
16
|
+
export const SlugField = t0 => {
|
|
17
|
+
const $ = _c(18);
|
|
18
|
+
const {
|
|
19
|
+
field,
|
|
20
|
+
fieldToUse,
|
|
21
|
+
path,
|
|
22
|
+
readOnly: readOnlyFromProps
|
|
23
|
+
} = t0;
|
|
24
|
+
const {
|
|
25
|
+
label
|
|
26
|
+
} = field;
|
|
27
|
+
const t1 = path || field.name;
|
|
28
|
+
let t2;
|
|
29
|
+
if ($[0] !== t1) {
|
|
30
|
+
t2 = {
|
|
31
|
+
path: t1
|
|
32
|
+
};
|
|
33
|
+
$[0] = t1;
|
|
34
|
+
$[1] = t2;
|
|
35
|
+
} else {
|
|
36
|
+
t2 = $[1];
|
|
37
|
+
}
|
|
38
|
+
const {
|
|
39
|
+
setValue,
|
|
40
|
+
value
|
|
41
|
+
} = useField(t2);
|
|
42
|
+
const {
|
|
43
|
+
getDataByPath
|
|
44
|
+
} = useForm();
|
|
45
|
+
const [isLocked, setIsLocked] = useState(true);
|
|
46
|
+
let t3;
|
|
47
|
+
if ($[2] !== fieldToUse || $[3] !== getDataByPath || $[4] !== setValue || $[5] !== value) {
|
|
48
|
+
t3 = e => {
|
|
49
|
+
e.preventDefault();
|
|
50
|
+
const targetFieldValue = getDataByPath(fieldToUse);
|
|
51
|
+
if (targetFieldValue) {
|
|
52
|
+
const formattedSlug = slugify(targetFieldValue);
|
|
53
|
+
if (value !== formattedSlug) {
|
|
54
|
+
setValue(formattedSlug);
|
|
55
|
+
}
|
|
56
|
+
} else {
|
|
57
|
+
if (value !== "") {
|
|
58
|
+
setValue("");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
$[2] = fieldToUse;
|
|
63
|
+
$[3] = getDataByPath;
|
|
64
|
+
$[4] = setValue;
|
|
65
|
+
$[5] = value;
|
|
66
|
+
$[6] = t3;
|
|
67
|
+
} else {
|
|
68
|
+
t3 = $[6];
|
|
69
|
+
}
|
|
70
|
+
const handleGenerate = t3;
|
|
71
|
+
let t4;
|
|
72
|
+
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
|
|
73
|
+
t4 = e_0 => {
|
|
74
|
+
e_0.preventDefault();
|
|
75
|
+
setIsLocked(_temp);
|
|
76
|
+
};
|
|
77
|
+
$[7] = t4;
|
|
78
|
+
} else {
|
|
79
|
+
t4 = $[7];
|
|
80
|
+
}
|
|
81
|
+
const toggleLock = t4;
|
|
82
|
+
const t5 = `field-${path}`;
|
|
83
|
+
let t6;
|
|
84
|
+
if ($[8] !== field.name || $[9] !== handleGenerate || $[10] !== isLocked || $[11] !== label || $[12] !== path || $[13] !== readOnlyFromProps || $[14] !== setValue || $[15] !== t5 || $[16] !== value) {
|
|
85
|
+
t6 = _jsxs("div", {
|
|
86
|
+
className: "field-type slug-field-component",
|
|
87
|
+
children: [_jsxs("div", {
|
|
88
|
+
className: "label-wrapper",
|
|
89
|
+
children: [_jsx(FieldLabel, {
|
|
90
|
+
htmlFor: t5,
|
|
91
|
+
label
|
|
92
|
+
}), !isLocked && _jsx(Button, {
|
|
93
|
+
buttonStyle: "none",
|
|
94
|
+
className: "lock-button",
|
|
95
|
+
onClick: handleGenerate,
|
|
96
|
+
children: "Generate"
|
|
97
|
+
}), _jsx(Button, {
|
|
98
|
+
buttonStyle: "none",
|
|
99
|
+
className: "lock-button",
|
|
100
|
+
onClick: toggleLock,
|
|
101
|
+
children: isLocked ? "Unlock" : "Lock"
|
|
102
|
+
})]
|
|
103
|
+
}), _jsx(TextInput, {
|
|
104
|
+
onChange: setValue,
|
|
105
|
+
path: path || field.name,
|
|
106
|
+
readOnly: Boolean(readOnlyFromProps || isLocked),
|
|
107
|
+
value
|
|
108
|
+
})]
|
|
109
|
+
});
|
|
110
|
+
$[8] = field.name;
|
|
111
|
+
$[9] = handleGenerate;
|
|
112
|
+
$[10] = isLocked;
|
|
113
|
+
$[11] = label;
|
|
114
|
+
$[12] = path;
|
|
115
|
+
$[13] = readOnlyFromProps;
|
|
116
|
+
$[14] = setValue;
|
|
117
|
+
$[15] = t5;
|
|
118
|
+
$[16] = value;
|
|
119
|
+
$[17] = t6;
|
|
120
|
+
} else {
|
|
121
|
+
t6 = $[17];
|
|
122
|
+
}
|
|
123
|
+
return t6;
|
|
124
|
+
};
|
|
125
|
+
function _temp(prev) {
|
|
126
|
+
return !prev;
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","slugify","React","useCallback","useState","Button","useForm","useField","FieldLabel","TextInput","SlugField","t0","$","field","fieldToUse","path","readOnly","readOnlyFromProps","label","t1","name","t2","setValue","value","getDataByPath","isLocked","setIsLocked","t3","e","preventDefault","targetFieldValue","formattedSlug","handleGenerate","t4","Symbol","for","e_0","_temp","toggleLock","t5","t6","_jsxs","className","children","_jsx","htmlFor","buttonStyle","onClick","onChange","Boolean","prev"],"sources":["../../../src/fields/Slug/index.tsx"],"sourcesContent":["'use client'\nimport type { SlugFieldProps } from 'payload'\n\nimport { slugify } from 'payload/shared'\nimport React, { useCallback, useState } from 'react'\n\nimport { Button } from '../../elements/Button/index.js'\nimport { useForm } from '../../forms/Form/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { FieldLabel } from '../FieldLabel/index.js'\nimport { TextInput } from '../Text/index.js'\nimport './index.scss'\n\n/**\n * @experimental This component is experimental and may change or be removed in the future. Use at your own risk.\n */\nexport const SlugField: React.FC<SlugFieldProps> = ({\n field,\n fieldToUse,\n path,\n readOnly: readOnlyFromProps,\n}) => {\n const { label } = field\n\n const { setValue, value } = useField<string>({ path: path || field.name })\n\n const { getDataByPath } = useForm()\n\n const [isLocked, setIsLocked] = useState(true)\n\n const handleGenerate = useCallback(\n (e: React.MouseEvent<Element>) => {\n e.preventDefault()\n\n const targetFieldValue = getDataByPath(fieldToUse)\n\n if (targetFieldValue) {\n const formattedSlug = slugify(targetFieldValue as string)\n\n if (value !== formattedSlug) {\n setValue(formattedSlug)\n }\n } else {\n if (value !== '') {\n setValue('')\n }\n }\n },\n [setValue, value, fieldToUse, getDataByPath],\n )\n\n const toggleLock = useCallback((e: React.MouseEvent<Element>) => {\n e.preventDefault()\n setIsLocked((prev) => !prev)\n }, [])\n\n return (\n <div className=\"field-type slug-field-component\">\n <div className=\"label-wrapper\">\n <FieldLabel htmlFor={`field-${path}`} label={label} />\n {!isLocked && (\n <Button buttonStyle=\"none\" className=\"lock-button\" onClick={handleGenerate}>\n Generate\n </Button>\n )}\n <Button buttonStyle=\"none\" className=\"lock-button\" onClick={toggleLock}>\n {isLocked ? 'Unlock' : 'Lock'}\n </Button>\n </div>\n <TextInput\n onChange={setValue}\n path={path || field.name}\n readOnly={Boolean(readOnlyFromProps || isLocked)}\n value={value}\n />\n </div>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,OAAO,QAAQ;AACxB,OAAOC,KAAA,IAASC,WAAW,EAAEC,QAAQ,QAAQ;AAE7C,SAASC,MAAM,QAAQ;AACvB,SAASC,OAAO,QAAQ;AACxB,SAASC,QAAQ,QAAQ;AACzB,SAASC,UAAU,QAAQ;AAC3B,SAASC,SAAS,QAAQ;AAC1B,OAAO;AAEP;;;AAGA,OAAO,MAAMC,SAAA,GAAsCC,EAAA;EAAA,MAAAC,CAAA,GAAAZ,EAAA;EAAC;IAAAa,KAAA;IAAAC,UAAA;IAAAC,IAAA;IAAAC,QAAA,EAAAC;EAAA,IAAAN,EAKnD;EACC;IAAAO;EAAA,IAAkBL,KAAA;EAEmC,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|
2
|
+
.slug-field-component {
|
|
3
|
+
width: 100%;
|
|
4
|
+
|
|
5
|
+
.label-wrapper {
|
|
6
|
+
display: flex;
|
|
7
|
+
justify-content: space-between;
|
|
8
|
+
align-items: center;
|
|
9
|
+
gap: calc(var(--base) / 2);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.lock-button {
|
|
13
|
+
margin: 0;
|
|
14
|
+
padding-bottom: 0.3125rem;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -91,7 +91,7 @@ export function RelationshipContent(props) {
|
|
|
91
91
|
}
|
|
92
92
|
const generateMetaText = t5;
|
|
93
93
|
const metaText = withMeta ? generateMetaText(mimeType, byteSize) : "";
|
|
94
|
-
const previewAllowed = displayPreview ?? collectionConfig
|
|
94
|
+
const previewAllowed = displayPreview ?? collectionConfig?.upload?.displayPreview ?? true;
|
|
95
95
|
let t6;
|
|
96
96
|
if ($[9] !== className) {
|
|
97
97
|
t6 = [baseClass, className].filter(Boolean);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","formatFilesize","React","Button","useDocumentDrawer","ThumbnailComponent","useConfig","baseClass","RelationshipContent","props","$","id","allowEdit","allowRemove","alt","byteSize","className","collectionSlug","displayPreview","filename","mimeType","onRemove","reloadDoc","src","thumbnailSrc","withMeta","t0","x","y","undefined","config","collectionConfig","collections","find","collection","slug","t1","t2","DocumentDrawer","t3","openDrawer","t4","t5","doc","onSave","generateMetaText","mimeType_0","size","sections","push","join","metaText","previewAllowed","upload","t6","filter","Boolean","_jsxs","children","_jsx","fileSrc","href","target","buttonStyle","icon","iconStyle","onClick"],"sources":["../../../../src/fields/Upload/RelationshipContent/index.tsx"],"sourcesContent":["'use client'\n\nimport type { TypeWithID } from 'payload'\n\nimport { formatFilesize, isImage } from 'payload/shared'\nimport React from 'react'\n\nimport type { ReloadDoc } from '../types.js'\n\nimport { Button } from '../../../elements/Button/index.js'\nimport { useDocumentDrawer } from '../../../elements/DocumentDrawer/index.js'\nimport { ThumbnailComponent } from '../../../elements/Thumbnail/index.js'\nimport { useConfig } from '../../../providers/Config/index.js'\nimport './index.scss'\n\nconst baseClass = 'upload-relationship-details'\n\ntype Props = {\n readonly allowEdit?: boolean\n readonly allowRemove?: boolean\n readonly alt: string\n readonly byteSize: number\n readonly className?: string\n readonly collectionSlug: string\n readonly displayPreview?: boolean\n readonly filename: string\n readonly id?: number | string\n readonly mimeType: string\n readonly onRemove: () => void\n readonly reloadDoc: ReloadDoc\n readonly src: string\n readonly thumbnailSrc: string\n readonly withMeta?: boolean\n readonly x?: number\n readonly y?: number\n}\nexport function RelationshipContent(props: Props) {\n const {\n id,\n allowEdit,\n allowRemove,\n alt,\n byteSize,\n className,\n collectionSlug,\n displayPreview,\n filename,\n mimeType,\n onRemove,\n reloadDoc,\n src,\n thumbnailSrc,\n withMeta = true,\n x,\n y,\n } = props\n\n const { config } = useConfig()\n const collectionConfig =\n 'collections' in config\n ? config.collections.find((collection) => collection.slug === collectionSlug)\n : undefined\n\n const [DocumentDrawer, _, { openDrawer }] = useDocumentDrawer({\n id: src ? id : undefined,\n collectionSlug,\n })\n\n const onSave = React.useCallback(\n async ({ doc }: { doc: TypeWithID }) => reloadDoc(doc.id, collectionSlug),\n [reloadDoc, collectionSlug],\n )\n\n function generateMetaText(mimeType: string, size: number): string {\n const sections: string[] = []\n if (size) {\n sections.push(formatFilesize(size))\n }\n\n if (x && y) {\n sections.push(`${x}x${y}`)\n }\n\n if (mimeType) {\n sections.push(mimeType)\n }\n\n return sections.join(' — ')\n }\n\n const metaText = withMeta ? generateMetaText(mimeType, byteSize) : ''\n const previewAllowed = displayPreview ?? collectionConfig
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","formatFilesize","React","Button","useDocumentDrawer","ThumbnailComponent","useConfig","baseClass","RelationshipContent","props","$","id","allowEdit","allowRemove","alt","byteSize","className","collectionSlug","displayPreview","filename","mimeType","onRemove","reloadDoc","src","thumbnailSrc","withMeta","t0","x","y","undefined","config","collectionConfig","collections","find","collection","slug","t1","t2","DocumentDrawer","t3","openDrawer","t4","t5","doc","onSave","generateMetaText","mimeType_0","size","sections","push","join","metaText","previewAllowed","upload","t6","filter","Boolean","_jsxs","children","_jsx","fileSrc","href","target","buttonStyle","icon","iconStyle","onClick"],"sources":["../../../../src/fields/Upload/RelationshipContent/index.tsx"],"sourcesContent":["'use client'\n\nimport type { TypeWithID } from 'payload'\n\nimport { formatFilesize, isImage } from 'payload/shared'\nimport React from 'react'\n\nimport type { ReloadDoc } from '../types.js'\n\nimport { Button } from '../../../elements/Button/index.js'\nimport { useDocumentDrawer } from '../../../elements/DocumentDrawer/index.js'\nimport { ThumbnailComponent } from '../../../elements/Thumbnail/index.js'\nimport { useConfig } from '../../../providers/Config/index.js'\nimport './index.scss'\n\nconst baseClass = 'upload-relationship-details'\n\ntype Props = {\n readonly allowEdit?: boolean\n readonly allowRemove?: boolean\n readonly alt: string\n readonly byteSize: number\n readonly className?: string\n readonly collectionSlug: string\n readonly displayPreview?: boolean\n readonly filename: string\n readonly id?: number | string\n readonly mimeType: string\n readonly onRemove: () => void\n readonly reloadDoc: ReloadDoc\n readonly src: string\n readonly thumbnailSrc: string\n readonly withMeta?: boolean\n readonly x?: number\n readonly y?: number\n}\nexport function RelationshipContent(props: Props) {\n const {\n id,\n allowEdit,\n allowRemove,\n alt,\n byteSize,\n className,\n collectionSlug,\n displayPreview,\n filename,\n mimeType,\n onRemove,\n reloadDoc,\n src,\n thumbnailSrc,\n withMeta = true,\n x,\n y,\n } = props\n\n const { config } = useConfig()\n const collectionConfig =\n 'collections' in config\n ? config.collections.find((collection) => collection.slug === collectionSlug)\n : undefined\n\n const [DocumentDrawer, _, { openDrawer }] = useDocumentDrawer({\n id: src ? id : undefined,\n collectionSlug,\n })\n\n const onSave = React.useCallback(\n async ({ doc }: { doc: TypeWithID }) => reloadDoc(doc.id, collectionSlug),\n [reloadDoc, collectionSlug],\n )\n\n function generateMetaText(mimeType: string, size: number): string {\n const sections: string[] = []\n if (size) {\n sections.push(formatFilesize(size))\n }\n\n if (x && y) {\n sections.push(`${x}x${y}`)\n }\n\n if (mimeType) {\n sections.push(mimeType)\n }\n\n return sections.join(' — ')\n }\n\n const metaText = withMeta ? generateMetaText(mimeType, byteSize) : ''\n const previewAllowed = displayPreview ?? collectionConfig?.upload?.displayPreview ?? true\n\n return (\n <div className={[baseClass, className].filter(Boolean).join(' ')}>\n <div className={`${baseClass}__imageAndDetails`}>\n {previewAllowed && (\n <ThumbnailComponent\n alt={alt}\n className={`${baseClass}__thumbnail`}\n filename={filename}\n fileSrc={thumbnailSrc}\n size=\"small\"\n />\n )}\n <div className={`${baseClass}__details`}>\n <p className={`${baseClass}__filename`}>\n {src ? (\n <a href={src} target=\"_blank\">\n {filename}\n </a>\n ) : (\n filename\n )}\n </p>\n {withMeta ? <p className={`${baseClass}__meta`}>{metaText}</p> : null}\n </div>\n </div>\n\n {allowEdit !== false || allowRemove !== false ? (\n <div className={`${baseClass}__actions`}>\n {allowEdit !== false ? (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__edit`}\n icon=\"edit\"\n iconStyle=\"none\"\n onClick={openDrawer}\n />\n ) : null}\n {allowRemove !== false ? (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__remove`}\n icon=\"x\"\n iconStyle=\"none\"\n onClick={() => onRemove()}\n />\n ) : null}\n <DocumentDrawer onSave={onSave} />\n </div>\n ) : null}\n </div>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAIA,SAASC,cAAc,QAAiB;AACxC,OAAOC,KAAA,MAAW;AAIlB,SAASC,MAAM,QAAQ;AACvB,SAASC,iBAAiB,QAAQ;AAClC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,SAAS,QAAQ;AAC1B,OAAO;AAEP,MAAMC,SAAA,GAAY;AAqBlB,OAAO,SAAAC,oBAAAC,KAAA;EAAA,MAAAC,CA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extends Response, C extends Record<string, unknown>>(options?: SubmitOptions<C>, e?: React.FormEvent<HTMLFormElement>) => Promise</**
|
|
98
98
|
* Returns the form state and the response from the server.
|
|
99
99
|
*
|
|
100
|
-
* @experimental - Note: the `{ res: ... }` return type is experimental and may change in the future. Use at your own
|
|
100
|
+
* @experimental - Note: the `{ res: ... }` return type is experimental and may change in the future. Use at your own risk.
|
|
101
101
|
*/ /**
|
|
102
102
|
* Returns the form state and the response from the server.
|
|
103
103
|
*
|
|
104
|
-
* @experimental - Note: the `{ res: ... }` return type is experimental and may change in the future. Use at your own
|
|
104
|
+
* @experimental - Note: the `{ res: ... }` return type is experimental and may change in the future. Use at your own risk.
|
|
105
105
|
*/ {
|
|
106
106
|
formState?: FormState;
|
|
107
107
|
res: T;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../src/forms/Form/types.ts"],"sourcesContent":["import type {\n ClientField,\n Data,\n FormField,\n FormState,\n Row,\n TypedUser,\n ValidationFieldError,\n} from 'payload'\nimport type React from 'react'\nimport type { Dispatch } from 'react'\n\nimport type { AcceptValues } from './mergeServerFormState.js'\n\nexport type Preferences = {\n [key: string]: unknown\n}\n\nexport type FormOnSuccess<T = unknown, C = Record<string, unknown>> = (\n json: T,\n ctx?: {\n /**\n * Arbitrary context passed to the onSuccess callback.\n */\n context?: C\n /**\n * The form state that was sent with the request when retrieving the `json` arg.\n */\n formState?: FormState\n },\n) => Promise<FormState | void> | void\n\nexport type FormProps = {\n beforeSubmit?: ((args: { formState: FormState }) => Promise<FormState>)[]\n children?: React.ReactNode\n className?: string\n disabled?: boolean\n disableSuccessStatus?: boolean\n /**\n * If you would like to solely leverage server-side validation on submit,\n * you can disable checks that the form makes before it submits\n */\n disableValidationOnSubmit?: boolean\n /**\n * If you don't want the form to be a <form> element, you can pass a string here to use as the wrapper element.\n */\n el?: string\n /**\n * By default, the form will get the field schema (not data) from the current document. If you pass this in, you can override that behavior.\n * This is very useful for sub-forms, where the form's field schema is not necessarily the field schema of the current document (e.g. for the Blocks\n * feature of the Lexical Rich Text field)\n */\n fields?: ClientField[]\n handleResponse?: (\n res: Response,\n successToast: (value: string) => void,\n errorToast: (value: string) => void,\n ) => void\n initialState?: FormState\n /**\n * Determines if this Form is the main, top-level Form of a document. If set to true, the\n * Form's children will be wrapped in a DocumentFormContext, which lets you access this document\n * Form's data and fields from any child component - even if that child component is wrapped in a child\n * Form (e.g. a lexical block).\n */\n isDocumentForm?: boolean\n isInitializing?: boolean\n log?: boolean\n onChange?: ((args: { formState: FormState; submitted?: boolean }) => Promise<FormState>)[]\n onSubmit?: (fields: FormState, data: Data) => void\n onSuccess?: FormOnSuccess\n redirect?: string\n submitted?: boolean\n uuid?: string\n validationOperation?: 'create' | 'update'\n waitForAutocomplete?: boolean\n} & (\n | {\n action: (formData: FormData) => Promise<void>\n }\n | {\n action?: string\n method?: 'DELETE' | 'GET' | 'PATCH' | 'POST'\n }\n)\n\nexport type SubmitOptions<C = Record<string, unknown>> = {\n acceptValues?: AcceptValues\n action?: string\n /**\n * If you want to pass additional data to the onSuccess callback, you can use this context object.\n *\n * @experimental This property is experimental and may change in the future.\n */\n context?: C\n /**\n * When true, will disable the form while it is processing.\n * @default true\n */\n disableFormWhileProcessing?: boolean\n /**\n * When true, will disable the success toast after form submission.\n * @default false\n */\n disableSuccessStatus?: boolean\n method?: string\n overrides?: ((formState) => FormData) | Record<string, unknown>\n /**\n * When true, will skip validation before submitting the form.\n * @default false\n */\n skipValidation?: boolean\n}\n\nexport type DispatchFields = React.Dispatch<any>\n\nexport type Submit = <T extends Response, C extends Record<string, unknown>>(\n options?: SubmitOptions<C>,\n e?: React.FormEvent<HTMLFormElement>,\n) => Promise</**\n * Returns the form state and the response from the server.\n *\n * @experimental - Note: the `{ res: ... }` return type is experimental and may change in the future. Use at your own
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/forms/Form/types.ts"],"sourcesContent":["import type {\n ClientField,\n Data,\n FormField,\n FormState,\n Row,\n TypedUser,\n ValidationFieldError,\n} from 'payload'\nimport type React from 'react'\nimport type { Dispatch } from 'react'\n\nimport type { AcceptValues } from './mergeServerFormState.js'\n\nexport type Preferences = {\n [key: string]: unknown\n}\n\nexport type FormOnSuccess<T = unknown, C = Record<string, unknown>> = (\n json: T,\n ctx?: {\n /**\n * Arbitrary context passed to the onSuccess callback.\n */\n context?: C\n /**\n * The form state that was sent with the request when retrieving the `json` arg.\n */\n formState?: FormState\n },\n) => Promise<FormState | void> | void\n\nexport type FormProps = {\n beforeSubmit?: ((args: { formState: FormState }) => Promise<FormState>)[]\n children?: React.ReactNode\n className?: string\n disabled?: boolean\n disableSuccessStatus?: boolean\n /**\n * If you would like to solely leverage server-side validation on submit,\n * you can disable checks that the form makes before it submits\n */\n disableValidationOnSubmit?: boolean\n /**\n * If you don't want the form to be a <form> element, you can pass a string here to use as the wrapper element.\n */\n el?: string\n /**\n * By default, the form will get the field schema (not data) from the current document. If you pass this in, you can override that behavior.\n * This is very useful for sub-forms, where the form's field schema is not necessarily the field schema of the current document (e.g. for the Blocks\n * feature of the Lexical Rich Text field)\n */\n fields?: ClientField[]\n handleResponse?: (\n res: Response,\n successToast: (value: string) => void,\n errorToast: (value: string) => void,\n ) => void\n initialState?: FormState\n /**\n * Determines if this Form is the main, top-level Form of a document. If set to true, the\n * Form's children will be wrapped in a DocumentFormContext, which lets you access this document\n * Form's data and fields from any child component - even if that child component is wrapped in a child\n * Form (e.g. a lexical block).\n */\n isDocumentForm?: boolean\n isInitializing?: boolean\n log?: boolean\n onChange?: ((args: { formState: FormState; submitted?: boolean }) => Promise<FormState>)[]\n onSubmit?: (fields: FormState, data: Data) => void\n onSuccess?: FormOnSuccess\n redirect?: string\n submitted?: boolean\n uuid?: string\n validationOperation?: 'create' | 'update'\n waitForAutocomplete?: boolean\n} & (\n | {\n action: (formData: FormData) => Promise<void>\n }\n | {\n action?: string\n method?: 'DELETE' | 'GET' | 'PATCH' | 'POST'\n }\n)\n\nexport type SubmitOptions<C = Record<string, unknown>> = {\n acceptValues?: AcceptValues\n action?: string\n /**\n * If you want to pass additional data to the onSuccess callback, you can use this context object.\n *\n * @experimental This property is experimental and may change in the future.\n */\n context?: C\n /**\n * When true, will disable the form while it is processing.\n * @default true\n */\n disableFormWhileProcessing?: boolean\n /**\n * When true, will disable the success toast after form submission.\n * @default false\n */\n disableSuccessStatus?: boolean\n method?: string\n overrides?: ((formState) => FormData) | Record<string, unknown>\n /**\n * When true, will skip validation before submitting the form.\n * @default false\n */\n skipValidation?: boolean\n}\n\nexport type DispatchFields = React.Dispatch<any>\n\nexport type Submit = <T extends Response, C extends Record<string, unknown>>(\n options?: SubmitOptions<C>,\n e?: React.FormEvent<HTMLFormElement>,\n) => Promise</**\n * Returns the form state and the response from the server.\n *\n * @experimental - Note: the `{ res: ... }` return type is experimental and may change in the future. Use at your own risk.\n */\n{ formState?: FormState; res: T } | void>\n\nexport type ValidateForm = () => Promise<boolean>\n\nexport type CreateFormData = (\n overrides?: Record<string, unknown>,\n /**\n * If mergeOverrideData true, the data will be merged with the existing data in the form state.\n * @default true\n */\n options?: {\n /**\n * If provided, will use this instead of of derived data from the current form state.\n */\n data?: Data\n mergeOverrideData?: boolean\n },\n) => FormData | Promise<FormData>\n\nexport type GetFields = () => FormState\nexport type GetField = (path: string) => FormField\nexport type GetData = () => Data\nexport type GetSiblingData = (path: string) => Data\nexport type GetDataByPath = <T = unknown>(path: string) => T\nexport type SetModified = (modified: boolean) => void\nexport type SetSubmitted = (submitted: boolean) => void\nexport type SetProcessing = (processing: boolean) => void\n\nexport type Reset = (data: unknown) => Promise<void>\n\nexport type REPLACE_STATE = {\n optimize?: boolean\n /**\n * If `sanitize` is true, default values will be set for form field properties that are not present in the incoming state.\n * For example, `valid` will be set to true if it is not present in the incoming state.\n */\n sanitize?: boolean\n state: FormState\n type: 'REPLACE_STATE'\n}\n\nexport type REMOVE = {\n path: string\n type: 'REMOVE'\n}\n\nexport type MODIFY_CONDITION = {\n path: string\n result: boolean\n type: 'MODIFY_CONDITION'\n user: TypedUser\n}\n\nexport type UPDATE = {\n path: string\n type: 'UPDATE'\n} & Partial<FormField>\n\nexport type UPDATE_MANY = {\n formState: FormState\n type: 'UPDATE_MANY'\n}\n\nexport type REMOVE_ROW = {\n path: string\n rowIndex: number\n type: 'REMOVE_ROW'\n}\n\nexport type ADD_ROW = {\n blockType?: string\n path: string\n rowIndex?: number\n subFieldState?: FormState\n type: 'ADD_ROW'\n}\n\nexport type MERGE_SERVER_STATE = {\n acceptValues?: AcceptValues\n prevStateRef: React.RefObject<FormState>\n serverState: FormState\n type: 'MERGE_SERVER_STATE'\n}\n\nexport type REPLACE_ROW = {\n blockType?: string\n path: string\n rowIndex: number\n subFieldState?: FormState\n type: 'REPLACE_ROW'\n}\n\nexport type DUPLICATE_ROW = {\n path: string\n rowIndex: number\n type: 'DUPLICATE_ROW'\n}\n\nexport type MOVE_ROW = {\n moveFromIndex: number\n moveToIndex: number\n path: string\n type: 'MOVE_ROW'\n}\n\nexport type ADD_SERVER_ERRORS = {\n errors: ValidationFieldError[]\n type: 'ADD_SERVER_ERRORS'\n}\n\nexport type SET_ROW_COLLAPSED = {\n path: string\n type: 'SET_ROW_COLLAPSED'\n updatedRows: Row[]\n}\n\nexport type SET_ALL_ROWS_COLLAPSED = {\n path: string\n type: 'SET_ALL_ROWS_COLLAPSED'\n updatedRows: Row[]\n}\n\nexport type FieldAction =\n | ADD_ROW\n | ADD_SERVER_ERRORS\n | DUPLICATE_ROW\n | MERGE_SERVER_STATE\n | MODIFY_CONDITION\n | MOVE_ROW\n | REMOVE\n | REMOVE_ROW\n | REPLACE_ROW\n | REPLACE_STATE\n | SET_ALL_ROWS_COLLAPSED\n | SET_ROW_COLLAPSED\n | UPDATE\n | UPDATE_MANY\n\nexport type FormFieldsContext = [FormState, Dispatch<FieldAction>]\n\nexport type Context = {\n addFieldRow: ({\n blockType,\n path,\n rowIndex,\n schemaPath,\n subFieldState,\n }: {\n blockType?: string\n path: string\n rowIndex?: number\n schemaPath: string\n subFieldState?: FormState\n }) => void\n buildRowErrors: () => void\n createFormData: CreateFormData\n disabled: boolean\n dispatchFields: Dispatch<FieldAction>\n /**\n * Form context fields may be outdated and should not be relied on. Instead, prefer `useFormFields`.\n */\n fields: FormState\n formRef: React.RefObject<HTMLFormElement>\n getData: GetData\n getDataByPath: GetDataByPath\n getField: GetField\n getFields: GetFields\n getSiblingData: GetSiblingData\n initializing: boolean\n /**\n * Tracks wether the form state passes validation.\n * For example the state could be submitted but invalid as field errors have been returned.\n */\n isValid: boolean\n moveFieldRow: ({\n moveFromIndex,\n moveToIndex,\n path,\n }: {\n moveFromIndex: number\n moveToIndex: number\n path: string\n }) => void\n removeFieldRow: ({ path, rowIndex }: { path: string; rowIndex: number }) => void\n replaceFieldRow: ({\n blockType,\n path,\n rowIndex,\n schemaPath,\n subFieldState,\n }: {\n blockType?: string\n path: string\n rowIndex: number\n schemaPath: string\n subFieldState?: FormState\n }) => void\n replaceState: (state: FormState) => void\n reset: Reset\n /**\n * If the form has started processing in the background (e.g.\n * if autosave is running), this will be true.\n */\n setBackgroundProcessing: SetProcessing\n setDisabled: (disabled: boolean) => void\n setIsValid: (processing: boolean) => void\n setModified: SetModified\n setProcessing: SetProcessing\n setSubmitted: SetSubmitted\n submit: Submit\n uuid?: string\n validateForm: ValidateForm\n}\n"],"mappings":"AAwQA","ignoreList":[]}
|
|
@@ -20,14 +20,14 @@ import React from 'react';
|
|
|
20
20
|
* }
|
|
21
21
|
* ```
|
|
22
22
|
*
|
|
23
|
-
* @experimental This is an experimental API and may change at any time. Use at your own
|
|
23
|
+
* @experimental This is an experimental API and may change at any time. Use at your own risk.
|
|
24
24
|
*/
|
|
25
25
|
export declare const FieldPathContext: React.Context<string>;
|
|
26
26
|
/**
|
|
27
27
|
* Gets the current field path from the nearest `FieldPathContext` provider.
|
|
28
28
|
* All fields are wrapped in this context by default.
|
|
29
29
|
*
|
|
30
|
-
* @experimental This is an experimental API and may change at any time. Use at your own
|
|
30
|
+
* @experimental This is an experimental API and may change at any time. Use at your own risk.
|
|
31
31
|
*/
|
|
32
32
|
export declare const useFieldPath: () => string;
|
|
33
33
|
//# sourceMappingURL=context.d.ts.map
|
|
@@ -20,14 +20,14 @@ import React from 'react';
|
|
|
20
20
|
* }
|
|
21
21
|
* ```
|
|
22
22
|
*
|
|
23
|
-
* @experimental This is an experimental API and may change at any time. Use at your own
|
|
23
|
+
* @experimental This is an experimental API and may change at any time. Use at your own risk.
|
|
24
24
|
*/
|
|
25
25
|
export const FieldPathContext = React.createContext(undefined);
|
|
26
26
|
/**
|
|
27
27
|
* Gets the current field path from the nearest `FieldPathContext` provider.
|
|
28
28
|
* All fields are wrapped in this context by default.
|
|
29
29
|
*
|
|
30
|
-
* @experimental This is an experimental API and may change at any time. Use at your own
|
|
30
|
+
* @experimental This is an experimental API and may change at any time. Use at your own risk.
|
|
31
31
|
*/
|
|
32
32
|
export const useFieldPath = () => {
|
|
33
33
|
const context = React.useContext(FieldPathContext);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","names":["React","FieldPathContext","createContext","undefined","useFieldPath","context","useContext"],"sources":["../../../src/forms/RenderFields/context.ts"],"sourcesContent":["import React from 'react'\n\n/**\n * All fields are wrapped in a `FieldPathContext` provider by default.\n * The `useFieldPath` hook will return this value if it exists, not the path the field was explicitly given.\n * This means if you render a field directly, you will need to wrap it with a new `FieldPathContext` provider.\n * Otherwise, it will return the parent's path, not the path it was explicitly given.\n * @example\n * ```tsx\n * 'use client'\n * import React from 'react'\n * import { TextField, FieldPathContext } from '@payloadcms/ui'\n * import type { TextFieldClientComponent } from 'payload'\n *\n * export const MyCustomField: TextFieldClientComponent = (props) => {\n * return (\n * <FieldPathContext value=\"path.to.some.other.field\">\n * <TextField {...props} />\n * </FieldPathContext>\n * )\n * }\n * ```\n *\n * @experimental This is an experimental API and may change at any time. Use at your own
|
|
1
|
+
{"version":3,"file":"context.js","names":["React","FieldPathContext","createContext","undefined","useFieldPath","context","useContext"],"sources":["../../../src/forms/RenderFields/context.ts"],"sourcesContent":["import React from 'react'\n\n/**\n * All fields are wrapped in a `FieldPathContext` provider by default.\n * The `useFieldPath` hook will return this value if it exists, not the path the field was explicitly given.\n * This means if you render a field directly, you will need to wrap it with a new `FieldPathContext` provider.\n * Otherwise, it will return the parent's path, not the path it was explicitly given.\n * @example\n * ```tsx\n * 'use client'\n * import React from 'react'\n * import { TextField, FieldPathContext } from '@payloadcms/ui'\n * import type { TextFieldClientComponent } from 'payload'\n *\n * export const MyCustomField: TextFieldClientComponent = (props) => {\n * return (\n * <FieldPathContext value=\"path.to.some.other.field\">\n * <TextField {...props} />\n * </FieldPathContext>\n * )\n * }\n * ```\n *\n * @experimental This is an experimental API and may change at any time. Use at your own risk.\n */\nexport const FieldPathContext = React.createContext<string>(undefined)\n\n/**\n * Gets the current field path from the nearest `FieldPathContext` provider.\n * All fields are wrapped in this context by default.\n *\n * @experimental This is an experimental API and may change at any time. Use at your own risk.\n */\nexport const useFieldPath = () => {\n const context = React.useContext(FieldPathContext)\n\n if (!context) {\n // swallow the error, not all fields are wrapped in a FieldPathContext\n return undefined\n }\n\n return context\n}\n"],"mappings":"AAAA,OAAOA,KAAA,MAAW;AAElB;;;;;;;;;;;;;;;;;;;;;;;AAuBA,OAAO,MAAMC,gBAAA,GAAmBD,KAAA,CAAME,aAAa,CAASC,SAAA;AAE5D;;;;;;AAMA,OAAO,MAAMC,YAAA,GAAeA,CAAA;EAC1B,MAAAC,OAAA,GAAgBL,KAAA,CAAAM,UAAA,CAAAL,gBAAiB;EAAA,KAE5BI,OAAA;IAAA;EAAA;EAAA,OAKEA,OAAA;AAAA,CACT","ignoreList":[]}
|
|
@@ -38,7 +38,7 @@ export declare const useConfig: () => ClientConfigContext;
|
|
|
38
38
|
* If the config here has the same reference as the config from the layout, we
|
|
39
39
|
* simply reuse the context from the layout to avoid unnecessary re-renders.
|
|
40
40
|
*
|
|
41
|
-
* @experimental This component is experimental and may change or be removed in future releases. Use at your own
|
|
41
|
+
* @experimental This component is experimental and may change or be removed in future releases. Use at your own risk.
|
|
42
42
|
*/
|
|
43
43
|
export declare const PageConfigProvider: React.FC<{
|
|
44
44
|
readonly children: React.ReactNode;
|
|
@@ -67,7 +67,7 @@ export const useConfig = () => use(RootConfigContext);
|
|
|
67
67
|
* If the config here has the same reference as the config from the layout, we
|
|
68
68
|
* simply reuse the context from the layout to avoid unnecessary re-renders.
|
|
69
69
|
*
|
|
70
|
-
* @experimental This component is experimental and may change or be removed in future releases. Use at your own
|
|
70
|
+
* @experimental This component is experimental and may change or be removed in future releases. Use at your own risk.
|
|
71
71
|
*/
|
|
72
72
|
export const PageConfigProvider = t0 => {
|
|
73
73
|
const $ = _c(7);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","React","createContext","use","useCallback","useEffect","useMemo","useRef","useState","RootConfigContext","undefined","ConfigProvider","children","config","configFromProps","setConfig","isFirstRenderRef","current","collectionsBySlug","globalsBySlug","collection","collections","slug","global","globals","getEntityConfig","args","collectionSlug","globalSlug","value","_jsx","useConfig","PageConfigProvider","t0","$","rootConfig","setRootConfig","t1","t2","unauthenticated","t3"],"sources":["../../../src/providers/Config/index.tsx"],"sourcesContent":["/* eslint-disable perfectionist/sort-object-types */ // Need to disable this rule because the order of the overloads is important\n'use client'\nimport type {\n ClientCollectionConfig,\n ClientConfig,\n ClientGlobalConfig,\n CollectionSlug,\n GlobalSlug,\n} from 'payload'\n\nimport React, { createContext, use, useCallback, useEffect, useMemo, useRef, useState } from 'react'\n\ntype GetEntityConfigFn = {\n // Overload #1: collectionSlug only\n // @todo remove \"{} |\" in 4.0, which would be a breaking change\n (args: { collectionSlug: {} | CollectionSlug; globalSlug?: never }): ClientCollectionConfig\n\n // Overload #2: globalSlug only\n // @todo remove \"{} |\" in 4.0, which would be a breaking change\n (args: { collectionSlug?: never; globalSlug: {} | GlobalSlug }): ClientGlobalConfig\n\n // Overload #3: both/none (fall back to union | null)\n (args: {\n collectionSlug?: {} | CollectionSlug\n globalSlug?: {} | GlobalSlug\n }): ClientCollectionConfig | ClientGlobalConfig | null\n}\n\nexport type ClientConfigContext = {\n config: ClientConfig\n /**\n * Get a collection or global config by its slug. This is preferred over\n * using `config.collections.find` or `config.globals.find`, because\n * getEntityConfig uses a lookup map for O(1) lookups.\n */\n getEntityConfig: GetEntityConfigFn\n setConfig: (config: ClientConfig) => void\n}\n\nconst RootConfigContext = createContext<ClientConfigContext | undefined>(undefined)\n\nexport const ConfigProvider: React.FC<{\n readonly children: React.ReactNode\n readonly config: ClientConfig\n}> = ({ children, config: configFromProps }) => {\n const [config, setConfig] = useState<ClientConfig>(configFromProps)\n\n const isFirstRenderRef = useRef(true)\n\n // Need to update local config state if config from props changes, for HMR.\n // That way, config changes will be updated in the UI immediately without needing a refresh.\n useEffect(() => {\n if (isFirstRenderRef.current) {\n isFirstRenderRef.current = false\n return\n }\n\n setConfig(configFromProps)\n }, [configFromProps, setConfig])\n\n // Build lookup maps for collections and globals so we can do O(1) lookups by slug\n const { collectionsBySlug, globalsBySlug } = useMemo(() => {\n const collectionsBySlug: Record<string, ClientCollectionConfig> = {}\n const globalsBySlug: Record<string, ClientGlobalConfig> = {}\n\n for (const collection of config.collections) {\n collectionsBySlug[collection.slug] = collection\n }\n\n for (const global of config.globals) {\n globalsBySlug[global.slug] = global\n }\n\n return { collectionsBySlug, globalsBySlug }\n }, [config])\n\n const getEntityConfig = useCallback<GetEntityConfigFn>(\n (args) => {\n if ('collectionSlug' in args) {\n return collectionsBySlug[args.collectionSlug] ?? null\n }\n\n if ('globalSlug' in args) {\n return globalsBySlug[args.globalSlug] ?? null\n }\n\n return null as any\n },\n [collectionsBySlug, globalsBySlug],\n )\n\n const value = useMemo(\n () => ({ config, getEntityConfig, setConfig }),\n [config, getEntityConfig, setConfig],\n )\n\n return <RootConfigContext value={value}>{children}</RootConfigContext>\n}\n\nexport const useConfig = (): ClientConfigContext => use(RootConfigContext)\n\n/**\n * This provider shadows the `ConfigProvider` on the _page_ level, allowing us to\n * update the config when needed, e.g. after authentication.\n * The layout `ConfigProvider` is not updated on page navigation / authentication,\n * as the layout does not re-render in those cases.\n *\n * If the config here has the same reference as the config from the layout, we\n * simply reuse the context from the layout to avoid unnecessary re-renders.\n *\n * @experimental This component is experimental and may change or be removed in future releases. Use at your own
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","React","createContext","use","useCallback","useEffect","useMemo","useRef","useState","RootConfigContext","undefined","ConfigProvider","children","config","configFromProps","setConfig","isFirstRenderRef","current","collectionsBySlug","globalsBySlug","collection","collections","slug","global","globals","getEntityConfig","args","collectionSlug","globalSlug","value","_jsx","useConfig","PageConfigProvider","t0","$","rootConfig","setRootConfig","t1","t2","unauthenticated","t3"],"sources":["../../../src/providers/Config/index.tsx"],"sourcesContent":["/* eslint-disable perfectionist/sort-object-types */ // Need to disable this rule because the order of the overloads is important\n'use client'\nimport type {\n ClientCollectionConfig,\n ClientConfig,\n ClientGlobalConfig,\n CollectionSlug,\n GlobalSlug,\n} from 'payload'\n\nimport React, { createContext, use, useCallback, useEffect, useMemo, useRef, useState } from 'react'\n\ntype GetEntityConfigFn = {\n // Overload #1: collectionSlug only\n // @todo remove \"{} |\" in 4.0, which would be a breaking change\n (args: { collectionSlug: {} | CollectionSlug; globalSlug?: never }): ClientCollectionConfig\n\n // Overload #2: globalSlug only\n // @todo remove \"{} |\" in 4.0, which would be a breaking change\n (args: { collectionSlug?: never; globalSlug: {} | GlobalSlug }): ClientGlobalConfig\n\n // Overload #3: both/none (fall back to union | null)\n (args: {\n collectionSlug?: {} | CollectionSlug\n globalSlug?: {} | GlobalSlug\n }): ClientCollectionConfig | ClientGlobalConfig | null\n}\n\nexport type ClientConfigContext = {\n config: ClientConfig\n /**\n * Get a collection or global config by its slug. This is preferred over\n * using `config.collections.find` or `config.globals.find`, because\n * getEntityConfig uses a lookup map for O(1) lookups.\n */\n getEntityConfig: GetEntityConfigFn\n setConfig: (config: ClientConfig) => void\n}\n\nconst RootConfigContext = createContext<ClientConfigContext | undefined>(undefined)\n\nexport const ConfigProvider: React.FC<{\n readonly children: React.ReactNode\n readonly config: ClientConfig\n}> = ({ children, config: configFromProps }) => {\n const [config, setConfig] = useState<ClientConfig>(configFromProps)\n\n const isFirstRenderRef = useRef(true)\n\n // Need to update local config state if config from props changes, for HMR.\n // That way, config changes will be updated in the UI immediately without needing a refresh.\n useEffect(() => {\n if (isFirstRenderRef.current) {\n isFirstRenderRef.current = false\n return\n }\n\n setConfig(configFromProps)\n }, [configFromProps, setConfig])\n\n // Build lookup maps for collections and globals so we can do O(1) lookups by slug\n const { collectionsBySlug, globalsBySlug } = useMemo(() => {\n const collectionsBySlug: Record<string, ClientCollectionConfig> = {}\n const globalsBySlug: Record<string, ClientGlobalConfig> = {}\n\n for (const collection of config.collections) {\n collectionsBySlug[collection.slug] = collection\n }\n\n for (const global of config.globals) {\n globalsBySlug[global.slug] = global\n }\n\n return { collectionsBySlug, globalsBySlug }\n }, [config])\n\n const getEntityConfig = useCallback<GetEntityConfigFn>(\n (args) => {\n if ('collectionSlug' in args) {\n return collectionsBySlug[args.collectionSlug] ?? null\n }\n\n if ('globalSlug' in args) {\n return globalsBySlug[args.globalSlug] ?? null\n }\n\n return null as any\n },\n [collectionsBySlug, globalsBySlug],\n )\n\n const value = useMemo(\n () => ({ config, getEntityConfig, setConfig }),\n [config, getEntityConfig, setConfig],\n )\n\n return <RootConfigContext value={value}>{children}</RootConfigContext>\n}\n\nexport const useConfig = (): ClientConfigContext => use(RootConfigContext)\n\n/**\n * This provider shadows the `ConfigProvider` on the _page_ level, allowing us to\n * update the config when needed, e.g. after authentication.\n * The layout `ConfigProvider` is not updated on page navigation / authentication,\n * as the layout does not re-render in those cases.\n *\n * If the config here has the same reference as the config from the layout, we\n * simply reuse the context from the layout to avoid unnecessary re-renders.\n *\n * @experimental This component is experimental and may change or be removed in future releases. Use at your own risk.\n */\nexport const PageConfigProvider: React.FC<{\n readonly children: React.ReactNode\n readonly config: ClientConfig\n}> = ({ children, config: configFromProps }) => {\n const { config: rootConfig, setConfig: setRootConfig } = useConfig()\n\n /**\n * This `useEffect` is required in order for the _page_ to be able to refresh the client config,\n * which may have been cached on the _layout_ level, where the `ConfigProvider` is managed.\n * Since the layout does not re-render on page navigation / authentication, we need to manually\n * update the config, as the user may have been authenticated in the process, which affects the client config.\n */\n useEffect(() => {\n setRootConfig(configFromProps)\n }, [configFromProps, setRootConfig])\n\n // If this component receives a different config than what is in context from the layout, it is stale.\n // While stale, we instantiate a new context provider that provides the new config until the root context is updated.\n // Unfortunately, referential equality alone does not work bc the reference is lost during server/client serialization,\n // so we need to also compare the `unauthenticated` property.\n if (\n rootConfig !== configFromProps &&\n rootConfig.unauthenticated !== configFromProps.unauthenticated\n ) {\n return <ConfigProvider config={configFromProps}>{children}</ConfigProvider>\n }\n\n return children\n}\n"],"mappings":"AAAA,sDAAsD;AACtD;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AASA,OAAOC,KAAA,IAASC,aAAa,EAAEC,GAAG,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AA6B7F,MAAMC,iBAAA,gBAAoBP,aAAA,CAA+CQ,SAAA;AAEzE,OAAO,MAAMC,cAAA,GAGRA,CAAC;EAAEC,QAAQ;EAAEC,MAAA,EAAQC;AAAe,CAAE;EACzC,MAAM,CAACD,MAAA,EAAQE,SAAA,CAAU,GAAGP,QAAA,CAAuBM,eAAA;EAEnD,MAAME,gBAAA,GAAmBT,MAAA,CAAO;EAEhC;EACA;EACAF,SAAA,CAAU;IACR,IAAIW,gBAAA,CAAiBC,OAAO,EAAE;MAC5BD,gBAAA,CAAiBC,OAAO,GAAG;MAC3B;IACF;IAEAF,SAAA,CAAUD,eAAA;EACZ,GAAG,CAACA,eAAA,EAAiBC,SAAA,CAAU;EAE/B;EACA,MAAM;IAAEG,iBAAi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,CAAC,EAAE;QACX,MAAM,EAAE,MAAM,CAAA;QACd,KAAK,EAAE,MAAM,CAAA;KACd,CAAA;IACD,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,gBAAgB,EAAE,OAAO,CAAA;CAC1B,GAAG,IAAI,CAAC,sBAAsB,EAAE,sBAAsB,GAAG,KAAK,CAAC,CAAA;AAEhE,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/LivePreview/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAyB,iBAAiB,EAAsB,MAAM,SAAS,CAAA;AAG3F,OAAO,KAA4D,MAAM,OAAO,CAAA;AAEhF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAA;AAU1D,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,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,gBAAgB,EAAE,OAAO,CAAA;CAC1B,GAAG,IAAI,CAAC,sBAAsB,EAAE,sBAAsB,GAAG,KAAK,CAAC,CAAA;AAEhE,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CA2PlE,CAAA"}
|
|
@@ -72,6 +72,9 @@ export const LivePreviewProvider = ({
|
|
|
72
72
|
if (typeof _incomingURL === 'string') {
|
|
73
73
|
incomingURL = formatAbsoluteURL(_incomingURL);
|
|
74
74
|
}
|
|
75
|
+
if (!incomingURL) {
|
|
76
|
+
setIsLivePreviewing(false);
|
|
77
|
+
}
|
|
75
78
|
if (incomingURL !== url) {
|
|
76
79
|
setAppIsReady(false);
|
|
77
80
|
setURL(incomingURL);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["DndContext","React","useCallback","useEffect","useMemo","useRef","useState","usePopupWindow","useDocumentInfo","usePreferences","formatAbsoluteURL","customCollisionDetection","LivePreviewContext","sizeReducer","LivePreviewProvider","breakpoints","incomingBreakpoints","children","isLivePreviewEnabled","isLivePreviewing","incomingIsLivePreviewing","typeofLivePreviewURL","url","urlFromProps","previewWindowType","setPreviewWindowType","setIsLivePreviewing","name","height","label","width","setURL","isPopupOpen","openPopupWindow","popupRef","eventType","appIsReady","setAppIsReady","listeningForMessages","setListeningForMessages","collectionSlug","globalSlug","isFirstRender","setPreference","iframeRef","loadedURL","setLoadedURL","zoom","setZoom","position","setPosition","x","y","size","setSize","useReducer","measuredDeviceSize","setMeasuredDeviceSize","breakpoint","setBreakpoint","setLivePreviewURL","_incomingURL","incomingURL","handleDragEnd","ev","over","id","newPos","delta","setWidth","type","value","setHeight","foundBreakpoint","find","bp","handleMessage","event","startsWith","origin","data","ready","window","addEventListener","removeEventListener","handleWindowChange","newPreviewWindowType","current","editViewType","_jsx","setToolbarPosition","toolbarPosition","collisionDetection","onDragEnd"],"sources":["../../../src/providers/LivePreview/index.tsx"],"sourcesContent":["'use client'\nimport type { CollectionPreferences, LivePreviewConfig, LivePreviewURLType } from 'payload'\n\nimport { DndContext } from '@dnd-kit/core'\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'\n\nimport type { LivePreviewContextType } from './context.js'\n\nimport { usePopupWindow } from '../../hooks/usePopupWindow.js'\nimport { useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { usePreferences } from '../../providers/Preferences/index.js'\nimport { formatAbsoluteURL } from '../../utilities/formatAbsoluteURL.js'\nimport { customCollisionDetection } from './collisionDetection.js'\nimport { LivePreviewContext } from './context.js'\nimport { sizeReducer } from './sizeReducer.js'\n\nexport type LivePreviewProviderProps = {\n appIsReady?: boolean\n breakpoints?: LivePreviewConfig['breakpoints']\n children: React.ReactNode\n deviceSize?: {\n height: number\n width: number\n }\n isLivePreviewEnabled?: boolean\n isLivePreviewing: boolean\n} & Pick<LivePreviewContextType, 'typeofLivePreviewURL' | 'url'>\n\nexport const LivePreviewProvider: React.FC<LivePreviewProviderProps> = ({\n breakpoints: incomingBreakpoints,\n children,\n isLivePreviewEnabled,\n isLivePreviewing: incomingIsLivePreviewing,\n typeofLivePreviewURL,\n url: urlFromProps,\n}) => {\n const [previewWindowType, setPreviewWindowType] = useState<'iframe' | 'popup'>('iframe')\n const [isLivePreviewing, setIsLivePreviewing] = useState(incomingIsLivePreviewing)\n\n const breakpoints: LivePreviewConfig['breakpoints'] = useMemo(\n () => [\n ...(incomingBreakpoints || []),\n {\n name: 'responsive',\n height: '100%',\n label: 'Responsive',\n width: '100%',\n },\n ],\n [incomingBreakpoints],\n )\n\n const [url, setURL] = useState<string>('')\n\n const { isPopupOpen, openPopupWindow, popupRef } = usePopupWindow({\n eventType: 'payload-live-preview',\n url,\n })\n\n const [appIsReady, setAppIsReady] = useState(false)\n const [listeningForMessages, setListeningForMessages] = useState(false)\n\n const { collectionSlug, globalSlug } = useDocumentInfo()\n\n const isFirstRender = useRef(true)\n\n const { setPreference } = usePreferences()\n\n const iframeRef = React.useRef<HTMLIFrameElement>(null)\n\n const [loadedURL, setLoadedURL] = useState<string>()\n\n const [zoom, setZoom] = useState(1)\n\n const [position, setPosition] = useState({ x: 0, y: 0 })\n\n const [size, setSize] = React.useReducer(sizeReducer, { height: 0, width: 0 })\n\n const [measuredDeviceSize, setMeasuredDeviceSize] = useState({\n height: 0,\n width: 0,\n })\n\n const [breakpoint, setBreakpoint] =\n React.useState<LivePreviewConfig['breakpoints'][0]['name']>('responsive')\n\n /**\n * A \"middleware\" callback fn that does some additional work before `setURL`.\n * This is what we provide through context, bc it:\n * - ensures the URL is absolute\n * - resets `appIsReady` to `false` while the new URL is loading\n */\n const setLivePreviewURL = useCallback<LivePreviewContextType['setURL']>(\n (_incomingURL) => {\n let incomingURL: LivePreviewURLType\n\n if (typeof _incomingURL === 'string') {\n incomingURL = formatAbsoluteURL(_incomingURL)\n }\n\n if (incomingURL !== url) {\n setAppIsReady(false)\n setURL(incomingURL)\n }\n },\n [url],\n )\n\n /**\n * `url` needs to be relative to the window, which cannot be done on initial render.\n */\n useEffect(() => {\n if (typeof urlFromProps === 'string') {\n setURL(formatAbsoluteURL(urlFromProps))\n }\n }, [urlFromProps])\n\n // The toolbar needs to freely drag and drop around the page\n const handleDragEnd = (ev) => {\n // only update position if the toolbar is completely within the preview area\n // otherwise reset it back to the previous position\n // TODO: reset to the nearest edge of the preview area\n if (ev.over && ev.over.id === 'live-preview-area') {\n const newPos = {\n x: position.x + ev.delta.x,\n y: position.y + ev.delta.y,\n }\n\n setPosition(newPos)\n } else {\n // reset\n }\n }\n\n const setWidth = useCallback(\n (width) => {\n setSize({ type: 'width', value: width })\n },\n [setSize],\n )\n\n const setHeight = useCallback(\n (height) => {\n setSize({ type: 'height', value: height })\n },\n [setSize],\n )\n\n // explicitly set new width and height when as new breakpoints are selected\n // exclude `custom` breakpoint as it is handled by the `setWidth` and `setHeight` directly\n useEffect(() => {\n const foundBreakpoint = breakpoints?.find((bp) => bp.name === breakpoint)\n\n if (\n foundBreakpoint &&\n breakpoint !== 'responsive' &&\n breakpoint !== 'custom' &&\n typeof foundBreakpoint?.width === 'number' &&\n typeof foundBreakpoint?.height === 'number'\n ) {\n setSize({\n type: 'reset',\n value: {\n height: foundBreakpoint.height,\n width: foundBreakpoint.width,\n },\n })\n }\n }, [breakpoint, breakpoints])\n\n /**\n * Receive the `ready` message from the popup window\n * This indicates that the app is ready to receive `window.postMessage` events\n * This is also the only cross-origin way of detecting when a popup window has loaded\n * Unlike iframe elements which have an `onLoad` handler, there is no way to access `window.open` on popups\n */\n useEffect(() => {\n const handleMessage = (event: MessageEvent) => {\n if (\n url?.startsWith(event.origin) &&\n event.data &&\n typeof event.data === 'object' &&\n event.data.type === 'payload-live-preview'\n ) {\n if (event.data.ready) {\n setAppIsReady(true)\n }\n }\n }\n\n window.addEventListener('message', handleMessage)\n\n setListeningForMessages(true)\n\n return () => {\n window.removeEventListener('message', handleMessage)\n }\n }, [url, listeningForMessages])\n\n const handleWindowChange = useCallback(\n (type: 'iframe' | 'popup') => {\n setAppIsReady(false)\n setPreviewWindowType(type)\n if (type === 'popup') {\n openPopupWindow()\n }\n },\n [openPopupWindow],\n )\n\n // when the user closes the popup window, switch back to the iframe\n // the `usePopupWindow` reports the `isPopupOpen` state for us to use here\n useEffect(() => {\n const newPreviewWindowType = isPopupOpen ? 'popup' : 'iframe'\n\n if (newPreviewWindowType !== previewWindowType) {\n handleWindowChange('iframe')\n }\n }, [previewWindowType, isPopupOpen, handleWindowChange])\n\n useEffect(() => {\n if (isFirstRender.current) {\n isFirstRender.current = false\n return\n }\n\n void setPreference<CollectionPreferences>(\n collectionSlug ? `collection-${collectionSlug}` : `global-${globalSlug}`,\n {\n editViewType: isLivePreviewing ? 'live-preview' : 'default',\n },\n true,\n )\n }, [isLivePreviewing, setPreference, collectionSlug, globalSlug])\n\n return (\n <LivePreviewContext\n value={{\n appIsReady,\n breakpoint,\n breakpoints,\n iframeRef,\n isLivePreviewEnabled,\n isLivePreviewing,\n isPopupOpen,\n listeningForMessages,\n loadedURL,\n measuredDeviceSize,\n openPopupWindow,\n popupRef,\n previewWindowType,\n setAppIsReady,\n setBreakpoint,\n setHeight,\n setIsLivePreviewing,\n setLoadedURL,\n setMeasuredDeviceSize,\n setPreviewWindowType: handleWindowChange,\n setSize,\n setToolbarPosition: setPosition,\n setURL: setLivePreviewURL,\n setWidth,\n setZoom,\n size,\n toolbarPosition: position,\n typeofLivePreviewURL,\n url,\n zoom,\n }}\n >\n <DndContext collisionDetection={customCollisionDetection} onDragEnd={handleDragEnd}>\n {children}\n </DndContext>\n </LivePreviewContext>\n )\n}\n"],"mappings":"AAAA;;;AAG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;MACAO,SAAA;MACAW,kBAAA;MACAvB,eAAA;MACAC,QAAA;MACAV,iBAAA;MACAa,aAAA;MACAsB,aAAA;MACAa,SAAA;MACA9C,mBAAA;MACAoB,YAAA;MACAW,qBAAA;MACAhC,oBAAA,EAAsB4D,kBAAA;MACtB/B,OAAA;MACAoC,kBAAA,EAAoBxC,WAAA;MACpBnB,MAAA,EAAQ6B,iBAAA;MACRS,QAAA;MACArB,OAAA;MACAK,IAAA;MACAsC,eAAA,EAAiB1C,QAAA;MACjB5B,oBAAA;MACAC,GAAA;MACAyB;IACF;cAEA,aAAA0C,IAAA,CAACzF,UAAA;MAAW4F,kBAAA,EAAoBjF,wBAAA;MAA0BkF,SAAA,EAAW9B,aAAA;gBAClE9C;;;AAIT","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["DndContext","React","useCallback","useEffect","useMemo","useRef","useState","usePopupWindow","useDocumentInfo","usePreferences","formatAbsoluteURL","customCollisionDetection","LivePreviewContext","sizeReducer","LivePreviewProvider","breakpoints","incomingBreakpoints","children","isLivePreviewEnabled","isLivePreviewing","incomingIsLivePreviewing","typeofLivePreviewURL","url","urlFromProps","previewWindowType","setPreviewWindowType","setIsLivePreviewing","name","height","label","width","setURL","isPopupOpen","openPopupWindow","popupRef","eventType","appIsReady","setAppIsReady","listeningForMessages","setListeningForMessages","collectionSlug","globalSlug","isFirstRender","setPreference","iframeRef","loadedURL","setLoadedURL","zoom","setZoom","position","setPosition","x","y","size","setSize","useReducer","measuredDeviceSize","setMeasuredDeviceSize","breakpoint","setBreakpoint","setLivePreviewURL","_incomingURL","incomingURL","handleDragEnd","ev","over","id","newPos","delta","setWidth","type","value","setHeight","foundBreakpoint","find","bp","handleMessage","event","startsWith","origin","data","ready","window","addEventListener","removeEventListener","handleWindowChange","newPreviewWindowType","current","editViewType","_jsx","setToolbarPosition","toolbarPosition","collisionDetection","onDragEnd"],"sources":["../../../src/providers/LivePreview/index.tsx"],"sourcesContent":["'use client'\nimport type { CollectionPreferences, LivePreviewConfig, LivePreviewURLType } from 'payload'\n\nimport { DndContext } from '@dnd-kit/core'\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'\n\nimport type { LivePreviewContextType } from './context.js'\n\nimport { usePopupWindow } from '../../hooks/usePopupWindow.js'\nimport { useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { usePreferences } from '../../providers/Preferences/index.js'\nimport { formatAbsoluteURL } from '../../utilities/formatAbsoluteURL.js'\nimport { customCollisionDetection } from './collisionDetection.js'\nimport { LivePreviewContext } from './context.js'\nimport { sizeReducer } from './sizeReducer.js'\n\nexport type LivePreviewProviderProps = {\n appIsReady?: boolean\n breakpoints?: LivePreviewConfig['breakpoints']\n children: React.ReactNode\n deviceSize?: {\n height: number\n width: number\n }\n isLivePreviewEnabled?: boolean\n isLivePreviewing: boolean\n} & Pick<LivePreviewContextType, 'typeofLivePreviewURL' | 'url'>\n\nexport const LivePreviewProvider: React.FC<LivePreviewProviderProps> = ({\n breakpoints: incomingBreakpoints,\n children,\n isLivePreviewEnabled,\n isLivePreviewing: incomingIsLivePreviewing,\n typeofLivePreviewURL,\n url: urlFromProps,\n}) => {\n const [previewWindowType, setPreviewWindowType] = useState<'iframe' | 'popup'>('iframe')\n const [isLivePreviewing, setIsLivePreviewing] = useState(incomingIsLivePreviewing)\n\n const breakpoints: LivePreviewConfig['breakpoints'] = useMemo(\n () => [\n ...(incomingBreakpoints || []),\n {\n name: 'responsive',\n height: '100%',\n label: 'Responsive',\n width: '100%',\n },\n ],\n [incomingBreakpoints],\n )\n\n const [url, setURL] = useState<string>('')\n\n const { isPopupOpen, openPopupWindow, popupRef } = usePopupWindow({\n eventType: 'payload-live-preview',\n url,\n })\n\n const [appIsReady, setAppIsReady] = useState(false)\n const [listeningForMessages, setListeningForMessages] = useState(false)\n\n const { collectionSlug, globalSlug } = useDocumentInfo()\n\n const isFirstRender = useRef(true)\n\n const { setPreference } = usePreferences()\n\n const iframeRef = React.useRef<HTMLIFrameElement>(null)\n\n const [loadedURL, setLoadedURL] = useState<string>()\n\n const [zoom, setZoom] = useState(1)\n\n const [position, setPosition] = useState({ x: 0, y: 0 })\n\n const [size, setSize] = React.useReducer(sizeReducer, { height: 0, width: 0 })\n\n const [measuredDeviceSize, setMeasuredDeviceSize] = useState({\n height: 0,\n width: 0,\n })\n\n const [breakpoint, setBreakpoint] =\n React.useState<LivePreviewConfig['breakpoints'][0]['name']>('responsive')\n\n /**\n * A \"middleware\" callback fn that does some additional work before `setURL`.\n * This is what we provide through context, bc it:\n * - ensures the URL is absolute\n * - resets `appIsReady` to `false` while the new URL is loading\n */\n const setLivePreviewURL = useCallback<LivePreviewContextType['setURL']>(\n (_incomingURL) => {\n let incomingURL: LivePreviewURLType\n\n if (typeof _incomingURL === 'string') {\n incomingURL = formatAbsoluteURL(_incomingURL)\n }\n\n if (!incomingURL) {\n setIsLivePreviewing(false)\n }\n\n if (incomingURL !== url) {\n setAppIsReady(false)\n setURL(incomingURL)\n }\n },\n [url],\n )\n\n /**\n * `url` needs to be relative to the window, which cannot be done on initial render.\n */\n useEffect(() => {\n if (typeof urlFromProps === 'string') {\n setURL(formatAbsoluteURL(urlFromProps))\n }\n }, [urlFromProps])\n\n // The toolbar needs to freely drag and drop around the page\n const handleDragEnd = (ev) => {\n // only update position if the toolbar is completely within the preview area\n // otherwise reset it back to the previous position\n // TODO: reset to the nearest edge of the preview area\n if (ev.over && ev.over.id === 'live-preview-area') {\n const newPos = {\n x: position.x + ev.delta.x,\n y: position.y + ev.delta.y,\n }\n\n setPosition(newPos)\n } else {\n // reset\n }\n }\n\n const setWidth = useCallback(\n (width) => {\n setSize({ type: 'width', value: width })\n },\n [setSize],\n )\n\n const setHeight = useCallback(\n (height) => {\n setSize({ type: 'height', value: height })\n },\n [setSize],\n )\n\n // explicitly set new width and height when as new breakpoints are selected\n // exclude `custom` breakpoint as it is handled by the `setWidth` and `setHeight` directly\n useEffect(() => {\n const foundBreakpoint = breakpoints?.find((bp) => bp.name === breakpoint)\n\n if (\n foundBreakpoint &&\n breakpoint !== 'responsive' &&\n breakpoint !== 'custom' &&\n typeof foundBreakpoint?.width === 'number' &&\n typeof foundBreakpoint?.height === 'number'\n ) {\n setSize({\n type: 'reset',\n value: {\n height: foundBreakpoint.height,\n width: foundBreakpoint.width,\n },\n })\n }\n }, [breakpoint, breakpoints])\n\n /**\n * Receive the `ready` message from the popup window\n * This indicates that the app is ready to receive `window.postMessage` events\n * This is also the only cross-origin way of detecting when a popup window has loaded\n * Unlike iframe elements which have an `onLoad` handler, there is no way to access `window.open` on popups\n */\n useEffect(() => {\n const handleMessage = (event: MessageEvent) => {\n if (\n url?.startsWith(event.origin) &&\n event.data &&\n typeof event.data === 'object' &&\n event.data.type === 'payload-live-preview'\n ) {\n if (event.data.ready) {\n setAppIsReady(true)\n }\n }\n }\n\n window.addEventListener('message', handleMessage)\n\n setListeningForMessages(true)\n\n return () => {\n window.removeEventListener('message', handleMessage)\n }\n }, [url, listeningForMessages])\n\n const handleWindowChange = useCallback(\n (type: 'iframe' | 'popup') => {\n setAppIsReady(false)\n setPreviewWindowType(type)\n if (type === 'popup') {\n openPopupWindow()\n }\n },\n [openPopupWindow],\n )\n\n // when the user closes the popup window, switch back to the iframe\n // the `usePopupWindow` reports the `isPopupOpen` state for us to use here\n useEffect(() => {\n const newPreviewWindowType = isPopupOpen ? 'popup' : 'iframe'\n\n if (newPreviewWindowType !== previewWindowType) {\n handleWindowChange('iframe')\n }\n }, [previewWindowType, isPopupOpen, handleWindowChange])\n\n useEffect(() => {\n if (isFirstRender.current) {\n isFirstRender.current = false\n return\n }\n\n void setPreference<CollectionPreferences>(\n collectionSlug ? `collection-${collectionSlug}` : `global-${globalSlug}`,\n {\n editViewType: isLivePreviewing ? 'live-preview' : 'default',\n },\n true,\n )\n }, [isLivePreviewing, setPreference, collectionSlug, globalSlug])\n\n return (\n <LivePreviewContext\n value={{\n appIsReady,\n breakpoint,\n breakpoints,\n iframeRef,\n isLivePreviewEnabled,\n isLivePreviewing,\n isPopupOpen,\n listeningForMessages,\n loadedURL,\n measuredDeviceSize,\n openPopupWindow,\n popupRef,\n previewWindowType,\n setAppIsReady,\n setBreakpoint,\n setHeight,\n setIsLivePreviewing,\n setLoadedURL,\n setMeasuredDeviceSize,\n setPreviewWindowType: handleWindowChange,\n setSize,\n setToolbarPosition: setPosition,\n setURL: setLivePreviewURL,\n setWidth,\n setZoom,\n size,\n toolbarPosition: position,\n typeofLivePreviewURL,\n url,\n zoom,\n }}\n >\n <DndContext collisionDetection={customCollisionDetection} onDragEnd={handleDragEnd}>\n {children}\n </DndContext>\n </LivePreviewContext>\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,UAAU,QAAQ;AAC3B,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAIzE,SAASC,cAAc,QAAQ;AAC/B,SAASC,eAAe,QAAQ;AAChC,SAASC,cAAc,QAAQ;AAC/B,SAASC,iBAAiB,QAAQ;AAClC,SAASC,wBAAwB,QAAQ;AACzC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,WAAW,QAAQ;AAc5B,OAAO,MAAMC,mBAAA,GAA0DA,CAAC;EACtEC,WAAA,EAAaC,mBAAmB;EAChCC,QAAQ;EACRC,oBAAoB;EACpBC,gBAAA,EAAkBC,wBAAwB;EAC1CC,oBAAoB;EACpBC,GAAA,EAAKC;AAAY,CAClB;EACC,MAAM,CAACC,iBAAA,EAAmBC,oBAAA,CAAqB,GAAGnB,QAAA,CAA6B;EAC/E,MAAM,CAACa,gBAAA,EAAkBO,mBAAA,CAAoB,GAAGpB,QAAA,CAASc,wBAAA;EAEzD,MAAML,WAAA,GAAgDX,OAAA,CACpD,MAAM,C,IACAY,mBAAA,IAAuB,EAAE,GAC7B;IACEW,IAAA,EAAM;IACNC,MAAA,EAAQ;IACRC,KAAA,EAAO;IACPC,KAAA,EAAO;EACT,EACD,EACD,CAACd,m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