@payloadcms/ui 3.45.0-internal.2f73d3c → 3.45.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/Autosave/index.d.ts.map +1 -1
- package/dist/elements/Autosave/index.js +20 -30
- package/dist/elements/Autosave/index.js.map +1 -1
- package/dist/elements/BulkUpload/EditForm/index.d.ts.map +1 -1
- package/dist/elements/BulkUpload/EditForm/index.js +36 -63
- package/dist/elements/BulkUpload/EditForm/index.js.map +1 -1
- package/dist/elements/BulkUpload/EditMany/DrawerContent.d.ts +1 -1
- package/dist/elements/BulkUpload/EditMany/DrawerContent.d.ts.map +1 -1
- package/dist/elements/BulkUpload/EditMany/DrawerContent.js +20 -16
- package/dist/elements/BulkUpload/EditMany/DrawerContent.js.map +1 -1
- package/dist/elements/BulkUpload/FormsManager/index.d.ts.map +1 -1
- package/dist/elements/BulkUpload/FormsManager/index.js +6 -5
- package/dist/elements/BulkUpload/FormsManager/index.js.map +1 -1
- package/dist/elements/BulkUpload/index.d.ts +3 -4
- package/dist/elements/BulkUpload/index.d.ts.map +1 -1
- package/dist/elements/BulkUpload/index.js +26 -33
- package/dist/elements/BulkUpload/index.js.map +1 -1
- package/dist/elements/DocumentDrawer/DrawerContent.d.ts.map +1 -1
- package/dist/elements/DocumentDrawer/DrawerContent.js +9 -7
- package/dist/elements/DocumentDrawer/DrawerContent.js.map +1 -1
- package/dist/elements/FileDetails/StaticFileDetails/index.js +1 -1
- package/dist/elements/FileDetails/StaticFileDetails/index.js.map +1 -1
- package/dist/elements/ListHeader/TitleActions/ListBulkUploadButton.d.ts.map +1 -1
- package/dist/elements/ListHeader/TitleActions/ListBulkUploadButton.js +11 -14
- package/dist/elements/ListHeader/TitleActions/ListBulkUploadButton.js.map +1 -1
- package/dist/elements/Upload/index.d.ts.map +1 -1
- package/dist/elements/Upload/index.js +1 -1
- package/dist/elements/Upload/index.js.map +1 -1
- package/dist/elements/WhereBuilder/index.js +2 -2
- package/dist/elements/WhereBuilder/index.js.map +1 -1
- package/dist/exports/client/index.js +22 -22
- package/dist/exports/client/index.js.map +4 -4
- package/dist/fields/Upload/Input.d.ts.map +1 -1
- package/dist/fields/Upload/Input.js +2 -4
- package/dist/fields/Upload/Input.js.map +1 -1
- package/dist/fields/Upload/index.d.ts.map +1 -1
- package/dist/fields/Upload/index.js +31 -27
- package/dist/fields/Upload/index.js.map +1 -1
- package/dist/forms/Form/fieldReducer.d.ts.map +1 -1
- package/dist/forms/Form/fieldReducer.js +0 -1
- package/dist/forms/Form/fieldReducer.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.js +19 -23
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/isRowCollapsed.d.ts +8 -0
- package/dist/forms/fieldSchemasToFormState/isRowCollapsed.d.ts.map +1 -0
- package/dist/forms/fieldSchemasToFormState/isRowCollapsed.js +18 -0
- package/dist/forms/fieldSchemasToFormState/isRowCollapsed.js.map +1 -0
- package/dist/forms/useField/index.d.ts.map +1 -1
- package/dist/forms/useField/index.js +68 -75
- package/dist/forms/useField/index.js.map +1 -1
- package/dist/hooks/useControllableState.d.ts +6 -0
- package/dist/hooks/useControllableState.d.ts.map +1 -0
- package/dist/hooks/useControllableState.js +21 -0
- package/dist/hooks/useControllableState.js.map +1 -0
- package/dist/hooks/useQueues.d.ts +1 -1
- package/dist/hooks/useQueues.d.ts.map +1 -1
- package/dist/hooks/useQueues.js.map +1 -1
- package/dist/providers/DocumentInfo/index.d.ts.map +1 -1
- package/dist/providers/DocumentInfo/index.js +12 -11
- package/dist/providers/DocumentInfo/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/views/List/index.d.ts.map +1 -1
- package/dist/views/List/index.js +12 -15
- package/dist/views/List/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A hook for managing state that can be controlled by props but also overridden locally.
|
|
4
|
+
* Props always take precedence if they change, but local state can override them temporarily.
|
|
5
|
+
*/
|
|
6
|
+
export function useControllableState(propValue, defaultValue) {
|
|
7
|
+
const [localValue, setLocalValue] = useState(propValue ?? defaultValue);
|
|
8
|
+
const initialRenderRef = useRef(true);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (initialRenderRef.current) {
|
|
11
|
+
initialRenderRef.current = false;
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
setLocalValue(propValue);
|
|
15
|
+
}, [propValue]);
|
|
16
|
+
const setValue = useCallback(value => {
|
|
17
|
+
setLocalValue(value);
|
|
18
|
+
}, []);
|
|
19
|
+
return [localValue, setValue];
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=useControllableState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useControllableState.js","names":["useCallback","useEffect","useRef","useState","useControllableState","propValue","defaultValue","localValue","setLocalValue","initialRenderRef","current","setValue","value"],"sources":["../../src/hooks/useControllableState.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react'\n\n/**\n * A hook for managing state that can be controlled by props but also overridden locally.\n * Props always take precedence if they change, but local state can override them temporarily.\n */\nexport function useControllableState<T>(\n propValue: T,\n defaultValue?: T,\n): [T, (value: ((prev: T) => T) | T) => void] {\n const [localValue, setLocalValue] = useState<T>(propValue ?? defaultValue)\n const initialRenderRef = useRef(true)\n\n useEffect(() => {\n if (initialRenderRef.current) {\n initialRenderRef.current = false\n return\n }\n\n setLocalValue(propValue)\n }, [propValue])\n\n const setValue = useCallback((value: ((prev: T) => T) | T) => {\n setLocalValue(value)\n }, [])\n\n return [localValue, setValue]\n}\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAEzD;;;;AAIA,OAAO,SAASC,qBACdC,SAAY,EACZC,YAAgB;EAEhB,MAAM,CAACC,UAAA,EAAYC,aAAA,CAAc,GAAGL,QAAA,CAAYE,SAAA,IAAaC,YAAA;EAC7D,MAAMG,gBAAA,GAAmBP,MAAA,CAAO;EAEhCD,SAAA,CAAU;IACR,IAAIQ,gBAAA,CAAiBC,OAAO,EAAE;MAC5BD,gBAAA,CAAiBC,OAAO,GAAG;MAC3B;IACF;IAEAF,aAAA,CAAcH,SAAA;EAChB,GAAG,CAACA,SAAA,CAAU;EAEd,MAAMM,QAAA,GAAWX,WAAA,CAAaY,KAAA;IAC5BJ,aAAA,CAAcI,KAAA;EAChB,GAAG,EAAE;EAEL,OAAO,CAACL,UAAA,EAAYI,QAAA,CAAS;AAC/B","ignoreList":[]}
|
|
@@ -11,7 +11,7 @@ type QueuedTaskOptions = {
|
|
|
11
11
|
* Can also be used to perform side effects before processing the queue
|
|
12
12
|
* @returns {boolean} If `false`, the queue will not process
|
|
13
13
|
*/
|
|
14
|
-
beforeProcess?: () => boolean;
|
|
14
|
+
beforeProcess?: () => boolean | void;
|
|
15
15
|
};
|
|
16
16
|
type QueueTask = (fn: QueuedFunction, options?: QueuedTaskOptions) => void;
|
|
17
17
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQueues.d.ts","sourceRoot":"","sources":["../../src/hooks/useQueues.ts"],"names":[],"mappings":"AAEA,KAAK,cAAc,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;AAEzC,KAAK,iBAAiB,GAAG;IACvB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,IAAI,CAAA;IACzB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"useQueues.d.ts","sourceRoot":"","sources":["../../src/hooks/useQueues.ts"],"names":[],"mappings":"AAEA,KAAK,cAAc,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;AAEzC,KAAK,iBAAiB,GAAG;IACvB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,IAAI,CAAA;IACzB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,OAAO,GAAG,IAAI,CAAA;CACrC,CAAA;AAED,KAAK,SAAS,GAAG,CAAC,EAAE,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,iBAAiB,KAAK,IAAI,CAAA;AAE1E;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,SAAS,IAAI;IAC3B,SAAS,EAAE,SAAS,CAAA;CACrB,CA8CA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQueues.js","names":["useCallback","useRef","useQueues","queue","isProcessing","queueTask","fn","options","current","push","processQueue","beforeProcess","shouldContinue","length","latestTask","pop","err","console","error","afterProcess"],"sources":["../../src/hooks/useQueues.ts"],"sourcesContent":["import { useCallback, useRef } from 'react'\n\ntype QueuedFunction = () => Promise<void>\n\ntype QueuedTaskOptions = {\n /**\n * A function that is called after the queue has processed a function\n * Used to perform side effects after processing the queue\n * @returns {void}\n */\n afterProcess?: () => void\n /**\n * A function that can be used to prevent the queue from processing under certain conditions\n * Can also be used to perform side effects before processing the queue\n * @returns {boolean} If `false`, the queue will not process\n */\n beforeProcess?: () => boolean\n}\n\ntype QueueTask = (fn: QueuedFunction, options?: QueuedTaskOptions) => void\n\n/**\n * A React hook that allows you to queue up functions to be executed in order.\n * This is useful when you need to ensure long running networks requests are processed sequentially.\n * Builds up a \"queue\" of functions to be executed in order, only ever processing the last function in the queue.\n * This ensures that a long queue of tasks doesn't cause a backlog of tasks to be processed.\n * E.g. if you queue a task and it begins running, then you queue 9 more tasks:\n * 1. The currently task will finish\n * 2. The next task in the queue will run\n * 3. All remaining tasks will be discarded\n * @returns {queueTask} A function used to queue a function.\n * @example\n * const { queueTask } = useQueues()\n * queueTask(async () => {\n * await fetch('https://api.example.com')\n * })\n */\nexport function useQueues(): {\n queueTask: QueueTask\n} {\n const queue = useRef<QueuedFunction[]>([])\n\n const isProcessing = useRef(false)\n\n const queueTask = useCallback<QueueTask>((fn, options) => {\n queue.current.push(fn)\n\n async function processQueue() {\n if (isProcessing.current) {\n return\n }\n\n // Allow the consumer to prevent the queue from processing under certain conditions\n if (typeof options?.beforeProcess === 'function') {\n const shouldContinue = options.beforeProcess()\n\n if (shouldContinue === false) {\n return\n }\n }\n\n while (queue.current.length > 0) {\n const latestTask = queue.current.pop() // Only process the last task in the queue\n queue.current = [] // Discard all other tasks\n\n isProcessing.current = true\n\n try {\n await latestTask()\n } catch (err) {\n console.error('Error in queued function:', err) // eslint-disable-line no-console\n } finally {\n isProcessing.current = false\n\n if (typeof options?.afterProcess === 'function') {\n options.afterProcess()\n }\n }\n }\n }\n\n void processQueue()\n }, [])\n\n return { queueTask }\n}\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,MAAM,QAAQ;AAqBpC;;;;;;;;;;;;;;;;AAgBA,OAAO,SAASC,UAAA;EAGd,MAAMC,KAAA,GAAQF,MAAA,CAAyB,EAAE;EAEzC,MAAMG,YAAA,GAAeH,MAAA,CAAO;EAE5B,MAAMI,SAAA,GAAYL,WAAA,CAAuB,CAACM,EAAA,EAAIC,OAAA;IAC5CJ,KAAA,CAAMK,OAAO,CAACC,IAAI,CAACH,EAAA;IAEnB,eAAeI,aAAA;MACb,IAAIN,YAAA,CAAaI,OAAO,EAAE;QACxB;MACF;MAEA;MACA,IAAI,OAAOD,OAAA,EAASI,aAAA,KAAkB,YAAY;QAChD,MAAMC,cAAA,GAAiBL,OAAA,CAAQI,aAAa;QAE5C,IAAIC,cAAA,KAAmB,OAAO;UAC5B;QACF;MACF;MAEA,OAAOT,KAAA,CAAMK,OAAO,CAACK,MAAM,GAAG,GAAG;QAC/B,MAAMC,UAAA,GAAaX,KAAA,CAAMK,OAAO,CAACO,GAAG,GAAG;QAAA;QACvCZ,KAAA,CAAMK,OAAO,GAAG,EAAE,CAAC;QAAA;QAEnBJ,YAAA,CAAaI,OAAO,GAAG;QAEvB,IAAI;UACF,MAAMM,UAAA;QACR,EAAE,OAAOE,GAAA,EAAK;UACZC,OAAA,CAAQC,KAAK,CAAC,6BAA6BF,GAAA,EAAK;UAAA;QAClD,UAAU;UACRZ,YAAA,CAAaI,OAAO,GAAG;UAEvB,IAAI,OAAOD,OAAA,EAASY,YAAA,KAAiB,YAAY;YAC/CZ,OAAA,CAAQY,YAAY;UACtB;QACF;MACF;IACF;IAEA,KAAKT,YAAA;EACP,GAAG,EAAE;EAEL,OAAO;IAAEL;EAAU;AACrB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"useQueues.js","names":["useCallback","useRef","useQueues","queue","isProcessing","queueTask","fn","options","current","push","processQueue","beforeProcess","shouldContinue","length","latestTask","pop","err","console","error","afterProcess"],"sources":["../../src/hooks/useQueues.ts"],"sourcesContent":["import { useCallback, useRef } from 'react'\n\ntype QueuedFunction = () => Promise<void>\n\ntype QueuedTaskOptions = {\n /**\n * A function that is called after the queue has processed a function\n * Used to perform side effects after processing the queue\n * @returns {void}\n */\n afterProcess?: () => void\n /**\n * A function that can be used to prevent the queue from processing under certain conditions\n * Can also be used to perform side effects before processing the queue\n * @returns {boolean} If `false`, the queue will not process\n */\n beforeProcess?: () => boolean | void\n}\n\ntype QueueTask = (fn: QueuedFunction, options?: QueuedTaskOptions) => void\n\n/**\n * A React hook that allows you to queue up functions to be executed in order.\n * This is useful when you need to ensure long running networks requests are processed sequentially.\n * Builds up a \"queue\" of functions to be executed in order, only ever processing the last function in the queue.\n * This ensures that a long queue of tasks doesn't cause a backlog of tasks to be processed.\n * E.g. if you queue a task and it begins running, then you queue 9 more tasks:\n * 1. The currently task will finish\n * 2. The next task in the queue will run\n * 3. All remaining tasks will be discarded\n * @returns {queueTask} A function used to queue a function.\n * @example\n * const { queueTask } = useQueues()\n * queueTask(async () => {\n * await fetch('https://api.example.com')\n * })\n */\nexport function useQueues(): {\n queueTask: QueueTask\n} {\n const queue = useRef<QueuedFunction[]>([])\n\n const isProcessing = useRef(false)\n\n const queueTask = useCallback<QueueTask>((fn, options) => {\n queue.current.push(fn)\n\n async function processQueue() {\n if (isProcessing.current) {\n return\n }\n\n // Allow the consumer to prevent the queue from processing under certain conditions\n if (typeof options?.beforeProcess === 'function') {\n const shouldContinue = options.beforeProcess()\n\n if (shouldContinue === false) {\n return\n }\n }\n\n while (queue.current.length > 0) {\n const latestTask = queue.current.pop() // Only process the last task in the queue\n queue.current = [] // Discard all other tasks\n\n isProcessing.current = true\n\n try {\n await latestTask()\n } catch (err) {\n console.error('Error in queued function:', err) // eslint-disable-line no-console\n } finally {\n isProcessing.current = false\n\n if (typeof options?.afterProcess === 'function') {\n options.afterProcess()\n }\n }\n }\n }\n\n void processQueue()\n }, [])\n\n return { queueTask }\n}\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,MAAM,QAAQ;AAqBpC;;;;;;;;;;;;;;;;AAgBA,OAAO,SAASC,UAAA;EAGd,MAAMC,KAAA,GAAQF,MAAA,CAAyB,EAAE;EAEzC,MAAMG,YAAA,GAAeH,MAAA,CAAO;EAE5B,MAAMI,SAAA,GAAYL,WAAA,CAAuB,CAACM,EAAA,EAAIC,OAAA;IAC5CJ,KAAA,CAAMK,OAAO,CAACC,IAAI,CAACH,EAAA;IAEnB,eAAeI,aAAA;MACb,IAAIN,YAAA,CAAaI,OAAO,EAAE;QACxB;MACF;MAEA;MACA,IAAI,OAAOD,OAAA,EAASI,aAAA,KAAkB,YAAY;QAChD,MAAMC,cAAA,GAAiBL,OAAA,CAAQI,aAAa;QAE5C,IAAIC,cAAA,KAAmB,OAAO;UAC5B;QACF;MACF;MAEA,OAAOT,KAAA,CAAMK,OAAO,CAACK,MAAM,GAAG,GAAG;QAC/B,MAAMC,UAAA,GAAaX,KAAA,CAAMK,OAAO,CAACO,GAAG,GAAG;QAAA;QACvCZ,KAAA,CAAMK,OAAO,GAAG,EAAE,CAAC;QAAA;QAEnBJ,YAAA,CAAaI,OAAO,GAAG;QAEvB,IAAI;UACF,MAAMM,UAAA;QACR,EAAE,OAAOE,GAAA,EAAK;UACZC,OAAA,CAAQC,KAAK,CAAC,6BAA6BF,GAAA,EAAK;UAAA;QAClD,UAAU;UACRZ,YAAA,CAAaI,OAAO,GAAG;UAEvB,IAAI,OAAOD,OAAA,EAASY,YAAA,KAAiB,YAAY;YAC/CZ,OAAA,CAAQY,YAAY;UACtB;QACF;MACF;IACF;IAEA,KAAKT,YAAA;EACP,GAAG,EAAE;EAEL,OAAO;IAAEL;EAAU;AACrB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/DocumentInfo/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAgF,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/DocumentInfo/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAgF,MAAM,OAAO,CAAA;AAYpG,OAAO,EAAE,KAAK,mBAAmB,EAAE,KAAK,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAK7E,mBAAmB,YAAY,CAAA;AAE/B,eAAO,MAAM,eAAe,QAAO,mBAAmC,CAAA;AAyWtE,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CACzC;IACE,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CACnC,GAAG,iBAAiB,CAOtB,CAAA"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
import * as qs from 'qs-esm';
|
|
5
5
|
import React, { createContext, use, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
6
|
+
import { useControllableState } from '../../hooks/useControllableState.js';
|
|
6
7
|
import { useAuth } from '../../providers/Auth/index.js';
|
|
7
8
|
import { requests } from '../../utilities/api.js';
|
|
8
9
|
import { formatDocTitle } from '../../utilities/formatDocTitle/index.js';
|
|
@@ -36,9 +37,9 @@ const DocumentInfo = ({
|
|
|
36
37
|
unpublishedVersionCount: unpublishedVersionCountFromProps,
|
|
37
38
|
versionCount: versionCountFromProps
|
|
38
39
|
} = props;
|
|
39
|
-
const [docPermissions, setDocPermissions] =
|
|
40
|
-
const [hasSavePermission, setHasSavePermission] =
|
|
41
|
-
const [hasPublishPermission, setHasPublishPermission] =
|
|
40
|
+
const [docPermissions, setDocPermissions] = useControllableState(docPermissionsFromProps);
|
|
41
|
+
const [hasSavePermission, setHasSavePermission] = useControllableState(hasSavePermissionFromProps);
|
|
42
|
+
const [hasPublishPermission, setHasPublishPermission] = useControllableState(hasPublishPermissionFromProps);
|
|
42
43
|
const {
|
|
43
44
|
permissions
|
|
44
45
|
} = useAuth();
|
|
@@ -87,14 +88,14 @@ const DocumentInfo = ({
|
|
|
87
88
|
const [versionCount, setVersionCount] = useState(versionCountFromProps);
|
|
88
89
|
const [hasPublishedDoc, setHasPublishedDoc] = useState(hasPublishedDocFromProps);
|
|
89
90
|
const [unpublishedVersionCount, setUnpublishedVersionCount] = useState(unpublishedVersionCountFromProps);
|
|
90
|
-
const [documentIsLocked, setDocumentIsLocked] =
|
|
91
|
-
const [currentEditor, setCurrentEditor] =
|
|
92
|
-
const [lastUpdateTime, setLastUpdateTime] =
|
|
93
|
-
const [savedDocumentData, setSavedDocumentData] =
|
|
94
|
-
const [uploadStatus, setUploadStatus] =
|
|
91
|
+
const [documentIsLocked, setDocumentIsLocked] = useControllableState(isLockedFromProps);
|
|
92
|
+
const [currentEditor, setCurrentEditor] = useControllableState(currentEditorFromProps);
|
|
93
|
+
const [lastUpdateTime, setLastUpdateTime] = useControllableState(lastUpdateTimeFromProps);
|
|
94
|
+
const [savedDocumentData, setSavedDocumentData] = useControllableState(initialData);
|
|
95
|
+
const [uploadStatus, setUploadStatus] = useControllableState('idle');
|
|
95
96
|
const updateUploadStatus = useCallback(status => {
|
|
96
97
|
setUploadStatus(status);
|
|
97
|
-
}, []);
|
|
98
|
+
}, [setUploadStatus]);
|
|
98
99
|
const {
|
|
99
100
|
getPreference,
|
|
100
101
|
setPreference
|
|
@@ -146,7 +147,7 @@ const DocumentInfo = ({
|
|
|
146
147
|
// eslint-disable-next-line no-console
|
|
147
148
|
console.error('Failed to unlock the document', error);
|
|
148
149
|
}
|
|
149
|
-
}, [serverURL, api, globalSlug]);
|
|
150
|
+
}, [serverURL, api, globalSlug, setDocumentIsLocked]);
|
|
150
151
|
const updateDocumentEditor = useCallback(async (docID_0, slug_1, user) => {
|
|
151
152
|
try {
|
|
152
153
|
const isGlobal_0 = slug_1 === globalSlug;
|
|
@@ -237,7 +238,7 @@ const DocumentInfo = ({
|
|
|
237
238
|
}, [collectionConfig, globalConfig, versionCount]);
|
|
238
239
|
const updateSavedDocumentData = React.useCallback(json => {
|
|
239
240
|
setSavedDocumentData(json);
|
|
240
|
-
}, []);
|
|
241
|
+
}, [setSavedDocumentData]);
|
|
241
242
|
/**
|
|
242
243
|
* @todo: Remove this in v4
|
|
243
244
|
* Users should use the `DocumentTitleContext` instead.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["qs","React","createContext","use","useCallback","useEffect","useMemo","useRef","useState","useAuth","requests","formatDocTitle","useConfig","DocumentTitleProvider","useLocale","useLocaleLoading","usePreferences","useTranslation","UploadEditsProvider","useUploadEdits","useGetDocPermissions","Context","useDocumentInfo","DocumentInfo","children","props","id","collectionSlug","currentEditor","currentEditorFromProps","docPermissions","docPermissionsFromProps","globalSlug","hasPublishedDoc","hasPublishedDocFromProps","hasPublishPermission","hasPublishPermissionFromProps","hasSavePermission","hasSavePermissionFromProps","initialData","initialState","isLocked","isLockedFromProps","lastUpdateTime","lastUpdateTimeFromProps","mostRecentVersionIsAutosaved","mostRecentVersionIsAutosavedFromProps","unpublishedVersionCount","unpublishedVersionCountFromProps","versionCount","versionCountFromProps","setDocPermissions","setHasSavePermission","setHasPublishPermission","permissions","config","admin","dateFormat","routes","api","serverURL","getEntityConfig","collectionConfig","globalConfig","abortControllerRef","AbortController","docConfig","i18n","uploadEdits","title","setDocumentTitle","data","fallback","toString","setMostRecentVersionIsAutosaved","setVersionCount","setHasPublishedDoc","setUnpublishedVersionCount","documentIsLocked","setDocumentIsLocked","setCurrentEditor","setLastUpdateTime","savedDocumentData","setSavedDocumentData","uploadStatus","setUploadStatus","updateUploadStatus","status","getPreference","setPreference","code","locale","localeIsLoading","isInitializing","undefined","baseURL","slug","pluralType","preferencesKey","unlockDocument","docID","isGlobal","query","request","get","credentials","docs","json","length","lockID","delete","headers","error","console","updateDocumentEditor","user","userData","relationTo","collection","value","patch","body","JSON","stringify","getDocPermissions","getDocPreferences","setDocFieldPreferences","path","fieldPreferences","allPreferences","fields","e","incrementVersionCount","newCount","versions","maxPerDoc","Math","min","max","updateSavedDocumentData","re1","current","abort","_err","action","docURL","params","depth","addQueryPrefix","_jsx","DocumentInfoProvider"],"sources":["../../../src/providers/DocumentInfo/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientUser, DocumentPreferences, SanitizedDocumentPermissions } from 'payload'\n\nimport * as qs from 'qs-esm'\nimport React, { createContext, use, useCallback, useEffect, useMemo, useRef, useState } from 'react'\n\nimport { useAuth } from '../../providers/Auth/index.js'\nimport { requests } from '../../utilities/api.js'\nimport { formatDocTitle } from '../../utilities/formatDocTitle/index.js'\nimport { useConfig } from '../Config/index.js'\nimport { DocumentTitleProvider } from '../DocumentTitle/index.js'\nimport { useLocale, useLocaleLoading } from '../Locale/index.js'\nimport { usePreferences } from '../Preferences/index.js'\nimport { useTranslation } from '../Translation/index.js'\nimport { UploadEditsProvider, useUploadEdits } from '../UploadEdits/index.js'\nimport { type DocumentInfoContext, type DocumentInfoProps } from './types.js'\nimport { useGetDocPermissions } from './useGetDocPermissions.js'\n\nconst Context = createContext({} as DocumentInfoContext)\n\nexport type * from './types.js'\n\nexport const useDocumentInfo = (): DocumentInfoContext => use(Context)\n\nconst DocumentInfo: React.FC<\n {\n readonly children: React.ReactNode\n } & DocumentInfoProps\n> = ({ children, ...props }) => {\n const {\n id,\n collectionSlug,\n currentEditor: currentEditorFromProps,\n docPermissions: docPermissionsFromProps,\n globalSlug,\n hasPublishedDoc: hasPublishedDocFromProps,\n hasPublishPermission: hasPublishPermissionFromProps,\n hasSavePermission: hasSavePermissionFromProps,\n initialData,\n initialState,\n isLocked: isLockedFromProps,\n lastUpdateTime: lastUpdateTimeFromProps,\n mostRecentVersionIsAutosaved: mostRecentVersionIsAutosavedFromProps,\n unpublishedVersionCount: unpublishedVersionCountFromProps,\n versionCount: versionCountFromProps,\n } = props\n\n const [docPermissions, setDocPermissions] =\n useState<SanitizedDocumentPermissions>(docPermissionsFromProps)\n\n const [hasSavePermission, setHasSavePermission] = useState<boolean>(hasSavePermissionFromProps)\n\n const [hasPublishPermission, setHasPublishPermission] = useState<boolean>(\n hasPublishPermissionFromProps,\n )\n\n const { permissions } = useAuth()\n\n const {\n config: {\n admin: { dateFormat },\n routes: { api },\n serverURL,\n },\n getEntityConfig,\n } = useConfig()\n\n const collectionConfig = getEntityConfig({ collectionSlug })\n const globalConfig = getEntityConfig({ globalSlug })\n\n const abortControllerRef = useRef(new AbortController())\n const docConfig = collectionConfig || globalConfig\n\n const { i18n } = useTranslation()\n\n const { uploadEdits } = useUploadEdits()\n\n /**\n * @deprecated This state will be removed in v4.\n * This is for performance reasons. Use the `DocumentTitleContext` instead.\n */\n const [title, setDocumentTitle] = useState(() =>\n formatDocTitle({\n collectionConfig,\n data: { ...(initialData || {}), id },\n dateFormat,\n fallback: id?.toString(),\n globalConfig,\n i18n,\n }),\n )\n\n const [mostRecentVersionIsAutosaved, setMostRecentVersionIsAutosaved] = useState(\n mostRecentVersionIsAutosavedFromProps,\n )\n\n const [versionCount, setVersionCount] = useState(versionCountFromProps)\n\n const [hasPublishedDoc, setHasPublishedDoc] = useState(hasPublishedDocFromProps)\n const [unpublishedVersionCount, setUnpublishedVersionCount] = useState(\n unpublishedVersionCountFromProps,\n )\n\n const [documentIsLocked, setDocumentIsLocked] = useState<boolean | undefined>(isLockedFromProps)\n const [currentEditor, setCurrentEditor] = useState<ClientUser | null>(currentEditorFromProps)\n const [lastUpdateTime, setLastUpdateTime] = useState<number>(lastUpdateTimeFromProps)\n const [savedDocumentData, setSavedDocumentData] = useState(initialData)\n const [uploadStatus, setUploadStatus] = useState<'failed' | 'idle' | 'uploading'>('idle')\n\n const updateUploadStatus = useCallback((status: 'failed' | 'idle' | 'uploading') => {\n setUploadStatus(status)\n }, [])\n\n const { getPreference, setPreference } = usePreferences()\n const { code: locale } = useLocale()\n const { localeIsLoading } = useLocaleLoading()\n\n const isInitializing = useMemo(\n () => initialState === undefined || initialData === undefined || localeIsLoading,\n [initialData, initialState, localeIsLoading],\n )\n\n const baseURL = `${serverURL}${api}`\n let slug: string\n let pluralType: 'collections' | 'globals'\n let preferencesKey: string\n\n if (globalSlug) {\n slug = globalSlug\n pluralType = 'globals'\n preferencesKey = `global-${slug}`\n }\n\n if (collectionSlug) {\n slug = collectionSlug\n pluralType = 'collections'\n\n if (id) {\n preferencesKey = `collection-${slug}-${id}`\n }\n }\n\n const unlockDocument = useCallback(\n async (docID: number | string, slug: string) => {\n try {\n const isGlobal = slug === globalSlug\n\n const query = isGlobal\n ? `where[globalSlug][equals]=${slug}`\n : `where[document.value][equals]=${docID}&where[document.relationTo][equals]=${slug}`\n\n const request = await requests.get(`${serverURL}${api}/payload-locked-documents?${query}`, {\n credentials: 'include',\n })\n\n const { docs } = await request.json()\n\n if (docs?.length > 0) {\n const lockID = docs[0].id\n await requests.delete(`${serverURL}${api}/payload-locked-documents/${lockID}`, {\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n })\n setDocumentIsLocked(false)\n }\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Failed to unlock the document', error)\n }\n },\n [serverURL, api, globalSlug],\n )\n\n const updateDocumentEditor = useCallback(\n async (docID: number | string, slug: string, user: ClientUser | number | string) => {\n try {\n const isGlobal = slug === globalSlug\n\n const query = isGlobal\n ? `where[globalSlug][equals]=${slug}`\n : `where[document.value][equals]=${docID}&where[document.relationTo][equals]=${slug}`\n\n // Check if the document is already locked\n const request = await requests.get(`${serverURL}${api}/payload-locked-documents?${query}`, {\n credentials: 'include',\n })\n\n const { docs } = await request.json()\n\n if (docs?.length > 0) {\n const lockID = docs[0].id\n\n const userData =\n typeof user === 'object'\n ? { relationTo: user.collection, value: user.id }\n : { relationTo: 'users', value: user }\n\n // Send a patch request to update the _lastEdited info\n await requests.patch(`${serverURL}${api}/payload-locked-documents/${lockID}`, {\n body: JSON.stringify({\n user: userData,\n }),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n })\n }\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Failed to update the document editor', error)\n }\n },\n [serverURL, api, globalSlug],\n )\n\n const getDocPermissions = useGetDocPermissions({\n id: id as string,\n api,\n collectionSlug,\n globalSlug,\n i18n,\n locale,\n permissions,\n serverURL,\n setDocPermissions,\n setHasPublishPermission,\n setHasSavePermission,\n })\n\n const getDocPreferences = useCallback(() => {\n return getPreference<DocumentPreferences>(preferencesKey)\n }, [getPreference, preferencesKey])\n\n const setDocFieldPreferences = useCallback<DocumentInfoContext['setDocFieldPreferences']>(\n async (path, fieldPreferences) => {\n const allPreferences = await getDocPreferences()\n\n if (preferencesKey) {\n try {\n await setPreference(preferencesKey, {\n ...allPreferences,\n fields: {\n ...(allPreferences?.fields || {}),\n [path]: {\n ...allPreferences?.fields?.[path],\n ...fieldPreferences,\n },\n },\n })\n } catch (e) {\n console.error(e) // eslint-disable-line no-console\n }\n }\n },\n [setPreference, preferencesKey, getDocPreferences],\n )\n\n const incrementVersionCount = useCallback(() => {\n const newCount = versionCount + 1\n if (collectionConfig && collectionConfig.versions) {\n if (collectionConfig.versions.maxPerDoc > 0) {\n setVersionCount(Math.min(newCount, collectionConfig.versions.maxPerDoc))\n } else {\n setVersionCount(newCount)\n }\n } else if (globalConfig && globalConfig.versions) {\n if (globalConfig.versions.max > 0) {\n setVersionCount(Math.min(newCount, globalConfig.versions.max))\n } else {\n setVersionCount(newCount)\n }\n }\n }, [collectionConfig, globalConfig, versionCount])\n\n const updateSavedDocumentData = React.useCallback<DocumentInfoContext['updateSavedDocumentData']>(\n (json) => {\n setSavedDocumentData(json)\n },\n [],\n )\n\n /**\n * @todo: Remove this in v4\n * Users should use the `DocumentTitleContext` instead.\n */\n useEffect(() => {\n setDocumentTitle(\n formatDocTitle({\n collectionConfig,\n data: { ...savedDocumentData, id },\n dateFormat,\n fallback: id?.toString(),\n globalConfig,\n i18n,\n }),\n )\n }, [collectionConfig, globalConfig, savedDocumentData, dateFormat, i18n, id])\n\n // clean on unmount\n useEffect(() => {\n const re1 = abortControllerRef.current\n\n return () => {\n if (re1) {\n try {\n re1.abort()\n } catch (_err) {\n // swallow error\n }\n }\n }\n }, [])\n\n const action: string = React.useMemo(() => {\n const docURL = `${baseURL}${pluralType === 'globals' ? `/globals` : ''}/${slug}${id ? `/${id}` : ''}`\n const params = {\n depth: 0,\n 'fallback-locale': 'null',\n locale,\n uploadEdits: uploadEdits || undefined,\n }\n\n return `${docURL}${qs.stringify(params, {\n addQueryPrefix: true,\n })}`\n }, [baseURL, locale, pluralType, id, slug, uploadEdits])\n\n const value: DocumentInfoContext = {\n ...props,\n action,\n currentEditor,\n docConfig,\n docPermissions,\n documentIsLocked,\n getDocPermissions,\n getDocPreferences,\n hasPublishedDoc,\n hasPublishPermission,\n hasSavePermission,\n incrementVersionCount,\n initialData,\n initialState,\n isInitializing,\n lastUpdateTime,\n mostRecentVersionIsAutosaved,\n preferencesKey,\n savedDocumentData,\n setCurrentEditor,\n setDocFieldPreferences,\n setDocumentIsLocked,\n setDocumentTitle,\n setHasPublishedDoc,\n setLastUpdateTime,\n setMostRecentVersionIsAutosaved,\n setUnpublishedVersionCount,\n setUploadStatus: updateUploadStatus,\n title,\n unlockDocument,\n unpublishedVersionCount,\n updateDocumentEditor,\n updateSavedDocumentData,\n uploadStatus,\n versionCount,\n }\n\n return (\n <Context value={value}>\n <DocumentTitleProvider>{children}</DocumentTitleProvider>\n </Context>\n )\n}\n\nexport const DocumentInfoProvider: React.FC<\n {\n readonly children: React.ReactNode\n } & DocumentInfoProps\n> = (props) => {\n return (\n <UploadEditsProvider>\n <DocumentInfo {...props} />\n </UploadEditsProvider>\n )\n}\n"],"mappings":"AAAA;;;AAGA,YAAYA,EAAA,MAAQ;AACpB,OAAOC,KAAA,IAASC,aAAa,EAAEC,GAAG,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAE7F,SAASC,OAAO,QAAQ;AACxB,SAASC,QAAQ,QAAQ;AACzB,SAASC,cAAc,QAAQ;AAC/B,SAASC,SAAS,QAAQ;AAC1B,SAASC,qBAAqB,QAAQ;AACtC,SAASC,SAAS,EAAEC,gBAAgB,QAAQ;AAC5C,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,SAASC,mBAAmB,EAAEC,cAAc,QAAQ;AAEpD,SAASC,oBAAoB,QAAQ;AAErC,MAAMC,OAAA,gBAAUnB,aAAA,CAAc,CAAC;AAI/B,OAAO,MAAMoB,eAAA,GAAkBA,CAAA,KAA2BnB,GAAA,CAAIkB,OAAA;AAE9D,MAAME,YAAA,GAIFA,CAAC;EAAEC,QAAQ;EAAE,GAAGC;AAAA,CAAO;EACzB,MAAM;IACJC,EAAE;IACFC,cAAc;IACdC,aAAA,EAAeC,sBAAsB;IACrCC,cAAA,EAAgBC,uBAAuB;IACvCC,UAAU;IACVC,eAAA,EAAiBC,wBAAwB;IACzCC,oBAAA,EAAsBC,6BAA6B;IACnDC,iBAAA,EAAmBC,0BAA0B;IAC7CC,WAAW;IACXC,YAAY;IACZC,QAAA,EAAUC,iBAAiB;IAC3BC,cAAA,EAAgBC,uBAAuB;IACvCC,4BAAA,EAA8BC,qCAAqC;IACnEC,uBA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AMmD,KAAA,GAA6B;IACjC,GAAG9F,KAAK;IACRuH,MAAA;IACApH,aAAA;IACAsC,SAAA;IACApC,cAAA;IACAgD,gBAAA;IACA8C,iBAAA;IACAC,iBAAA;IACA5F,eAAA;IACAE,oBAAA;IACAE,iBAAA;IACA+F,qBAAA;IACA7F,WAAA;IACAC,YAAA;IACAqD,cAAA;IACAlD,cAAA;IACAE,4BAAA;IACAqD,cAAA;IACAhB,iBAAA;IACAF,gBAAA;IACA8C,sBAAA;IACA/C,mBAAA;IACAT,gBAAA;IACAM,kBAAA;IACAK,iBAAA;IACAP,+BAAA;IACAG,0BAAA;IACAQ,eAAA,EAAiBC,kBAAA;IACjBjB,KAAA;IACA8B,cAAA;IACApD,uBAAA;IACAmE,oBAAA;IACAyB,uBAAA;IACAvD,YAAA;IACAnC;EACF;EAEA,oBACEoG,IAAA,CAAChI,OAAA;IAAQkG,KAAA,EAAOA,KAAA;cACd,aAAA8B,IAAA,CAACxI,qBAAA;gBAAuBW;;;AAG9B;AAEA,OAAO,MAAM8H,oBAAA,GAIR7H,KAAA;EACH,oBACE4H,IAAA,CAACnI,mBAAA;cACC,aAAAmI,IAAA,CAAC9H,YAAA;MAAc,GAAGE;;;AAGxB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["qs","React","createContext","use","useCallback","useEffect","useMemo","useRef","useState","useControllableState","useAuth","requests","formatDocTitle","useConfig","DocumentTitleProvider","useLocale","useLocaleLoading","usePreferences","useTranslation","UploadEditsProvider","useUploadEdits","useGetDocPermissions","Context","useDocumentInfo","DocumentInfo","children","props","id","collectionSlug","currentEditor","currentEditorFromProps","docPermissions","docPermissionsFromProps","globalSlug","hasPublishedDoc","hasPublishedDocFromProps","hasPublishPermission","hasPublishPermissionFromProps","hasSavePermission","hasSavePermissionFromProps","initialData","initialState","isLocked","isLockedFromProps","lastUpdateTime","lastUpdateTimeFromProps","mostRecentVersionIsAutosaved","mostRecentVersionIsAutosavedFromProps","unpublishedVersionCount","unpublishedVersionCountFromProps","versionCount","versionCountFromProps","setDocPermissions","setHasSavePermission","setHasPublishPermission","permissions","config","admin","dateFormat","routes","api","serverURL","getEntityConfig","collectionConfig","globalConfig","abortControllerRef","AbortController","docConfig","i18n","uploadEdits","title","setDocumentTitle","data","fallback","toString","setMostRecentVersionIsAutosaved","setVersionCount","setHasPublishedDoc","setUnpublishedVersionCount","documentIsLocked","setDocumentIsLocked","setCurrentEditor","setLastUpdateTime","savedDocumentData","setSavedDocumentData","uploadStatus","setUploadStatus","updateUploadStatus","status","getPreference","setPreference","code","locale","localeIsLoading","isInitializing","undefined","baseURL","slug","pluralType","preferencesKey","unlockDocument","docID","isGlobal","query","request","get","credentials","docs","json","length","lockID","delete","headers","error","console","updateDocumentEditor","user","userData","relationTo","collection","value","patch","body","JSON","stringify","getDocPermissions","getDocPreferences","setDocFieldPreferences","path","fieldPreferences","allPreferences","fields","e","incrementVersionCount","newCount","versions","maxPerDoc","Math","min","max","updateSavedDocumentData","re1","current","abort","_err","action","docURL","params","depth","addQueryPrefix","_jsx","DocumentInfoProvider"],"sources":["../../../src/providers/DocumentInfo/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientUser, DocumentPreferences } from 'payload'\n\nimport * as qs from 'qs-esm'\nimport React, { createContext, use, useCallback, useEffect, useMemo, useRef, useState } from 'react'\n\nimport { useControllableState } from '../../hooks/useControllableState.js'\nimport { useAuth } from '../../providers/Auth/index.js'\nimport { requests } from '../../utilities/api.js'\nimport { formatDocTitle } from '../../utilities/formatDocTitle/index.js'\nimport { useConfig } from '../Config/index.js'\nimport { DocumentTitleProvider } from '../DocumentTitle/index.js'\nimport { useLocale, useLocaleLoading } from '../Locale/index.js'\nimport { usePreferences } from '../Preferences/index.js'\nimport { useTranslation } from '../Translation/index.js'\nimport { UploadEditsProvider, useUploadEdits } from '../UploadEdits/index.js'\nimport { type DocumentInfoContext, type DocumentInfoProps } from './types.js'\nimport { useGetDocPermissions } from './useGetDocPermissions.js'\n\nconst Context = createContext({} as DocumentInfoContext)\n\nexport type * from './types.js'\n\nexport const useDocumentInfo = (): DocumentInfoContext => use(Context)\n\nconst DocumentInfo: React.FC<\n {\n readonly children: React.ReactNode\n } & DocumentInfoProps\n> = ({ children, ...props }) => {\n const {\n id,\n collectionSlug,\n currentEditor: currentEditorFromProps,\n docPermissions: docPermissionsFromProps,\n globalSlug,\n hasPublishedDoc: hasPublishedDocFromProps,\n hasPublishPermission: hasPublishPermissionFromProps,\n hasSavePermission: hasSavePermissionFromProps,\n initialData,\n initialState,\n isLocked: isLockedFromProps,\n lastUpdateTime: lastUpdateTimeFromProps,\n mostRecentVersionIsAutosaved: mostRecentVersionIsAutosavedFromProps,\n unpublishedVersionCount: unpublishedVersionCountFromProps,\n versionCount: versionCountFromProps,\n } = props\n\n const [docPermissions, setDocPermissions] = useControllableState(docPermissionsFromProps)\n\n const [hasSavePermission, setHasSavePermission] = useControllableState(hasSavePermissionFromProps)\n\n const [hasPublishPermission, setHasPublishPermission] = useControllableState(\n hasPublishPermissionFromProps,\n )\n\n const { permissions } = useAuth()\n\n const {\n config: {\n admin: { dateFormat },\n routes: { api },\n serverURL,\n },\n getEntityConfig,\n } = useConfig()\n\n const collectionConfig = getEntityConfig({ collectionSlug })\n const globalConfig = getEntityConfig({ globalSlug })\n\n const abortControllerRef = useRef(new AbortController())\n const docConfig = collectionConfig || globalConfig\n\n const { i18n } = useTranslation()\n\n const { uploadEdits } = useUploadEdits()\n\n /**\n * @deprecated This state will be removed in v4.\n * This is for performance reasons. Use the `DocumentTitleContext` instead.\n */\n const [title, setDocumentTitle] = useState(() =>\n formatDocTitle({\n collectionConfig,\n data: { ...(initialData || {}), id },\n dateFormat,\n fallback: id?.toString(),\n globalConfig,\n i18n,\n }),\n )\n\n const [mostRecentVersionIsAutosaved, setMostRecentVersionIsAutosaved] = useState(\n mostRecentVersionIsAutosavedFromProps,\n )\n\n const [versionCount, setVersionCount] = useState(versionCountFromProps)\n\n const [hasPublishedDoc, setHasPublishedDoc] = useState(hasPublishedDocFromProps)\n const [unpublishedVersionCount, setUnpublishedVersionCount] = useState(\n unpublishedVersionCountFromProps,\n )\n\n const [documentIsLocked, setDocumentIsLocked] = useControllableState<boolean | undefined>(\n isLockedFromProps,\n )\n const [currentEditor, setCurrentEditor] = useControllableState<ClientUser | null>(\n currentEditorFromProps,\n )\n const [lastUpdateTime, setLastUpdateTime] = useControllableState<number>(lastUpdateTimeFromProps)\n const [savedDocumentData, setSavedDocumentData] = useControllableState(initialData)\n const [uploadStatus, setUploadStatus] = useControllableState<'failed' | 'idle' | 'uploading'>(\n 'idle',\n )\n\n const updateUploadStatus = useCallback(\n (status: 'failed' | 'idle' | 'uploading') => {\n setUploadStatus(status)\n },\n [setUploadStatus],\n )\n\n const { getPreference, setPreference } = usePreferences()\n const { code: locale } = useLocale()\n const { localeIsLoading } = useLocaleLoading()\n\n const isInitializing = useMemo(\n () => initialState === undefined || initialData === undefined || localeIsLoading,\n [initialData, initialState, localeIsLoading],\n )\n\n const baseURL = `${serverURL}${api}`\n let slug: string\n let pluralType: 'collections' | 'globals'\n let preferencesKey: string\n\n if (globalSlug) {\n slug = globalSlug\n pluralType = 'globals'\n preferencesKey = `global-${slug}`\n }\n\n if (collectionSlug) {\n slug = collectionSlug\n pluralType = 'collections'\n\n if (id) {\n preferencesKey = `collection-${slug}-${id}`\n }\n }\n\n const unlockDocument = useCallback(\n async (docID: number | string, slug: string) => {\n try {\n const isGlobal = slug === globalSlug\n\n const query = isGlobal\n ? `where[globalSlug][equals]=${slug}`\n : `where[document.value][equals]=${docID}&where[document.relationTo][equals]=${slug}`\n\n const request = await requests.get(`${serverURL}${api}/payload-locked-documents?${query}`, {\n credentials: 'include',\n })\n\n const { docs } = await request.json()\n\n if (docs?.length > 0) {\n const lockID = docs[0].id\n await requests.delete(`${serverURL}${api}/payload-locked-documents/${lockID}`, {\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n })\n setDocumentIsLocked(false)\n }\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Failed to unlock the document', error)\n }\n },\n [serverURL, api, globalSlug, setDocumentIsLocked],\n )\n\n const updateDocumentEditor = useCallback(\n async (docID: number | string, slug: string, user: ClientUser | number | string) => {\n try {\n const isGlobal = slug === globalSlug\n\n const query = isGlobal\n ? `where[globalSlug][equals]=${slug}`\n : `where[document.value][equals]=${docID}&where[document.relationTo][equals]=${slug}`\n\n // Check if the document is already locked\n const request = await requests.get(`${serverURL}${api}/payload-locked-documents?${query}`, {\n credentials: 'include',\n })\n\n const { docs } = await request.json()\n\n if (docs?.length > 0) {\n const lockID = docs[0].id\n\n const userData =\n typeof user === 'object'\n ? { relationTo: user.collection, value: user.id }\n : { relationTo: 'users', value: user }\n\n // Send a patch request to update the _lastEdited info\n await requests.patch(`${serverURL}${api}/payload-locked-documents/${lockID}`, {\n body: JSON.stringify({\n user: userData,\n }),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n })\n }\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Failed to update the document editor', error)\n }\n },\n [serverURL, api, globalSlug],\n )\n\n const getDocPermissions = useGetDocPermissions({\n id: id as string,\n api,\n collectionSlug,\n globalSlug,\n i18n,\n locale,\n permissions,\n serverURL,\n setDocPermissions,\n setHasPublishPermission,\n setHasSavePermission,\n })\n\n const getDocPreferences = useCallback(() => {\n return getPreference<DocumentPreferences>(preferencesKey)\n }, [getPreference, preferencesKey])\n\n const setDocFieldPreferences = useCallback<DocumentInfoContext['setDocFieldPreferences']>(\n async (path, fieldPreferences) => {\n const allPreferences = await getDocPreferences()\n\n if (preferencesKey) {\n try {\n await setPreference(preferencesKey, {\n ...allPreferences,\n fields: {\n ...(allPreferences?.fields || {}),\n [path]: {\n ...allPreferences?.fields?.[path],\n ...fieldPreferences,\n },\n },\n })\n } catch (e) {\n console.error(e) // eslint-disable-line no-console\n }\n }\n },\n [setPreference, preferencesKey, getDocPreferences],\n )\n\n const incrementVersionCount = useCallback(() => {\n const newCount = versionCount + 1\n if (collectionConfig && collectionConfig.versions) {\n if (collectionConfig.versions.maxPerDoc > 0) {\n setVersionCount(Math.min(newCount, collectionConfig.versions.maxPerDoc))\n } else {\n setVersionCount(newCount)\n }\n } else if (globalConfig && globalConfig.versions) {\n if (globalConfig.versions.max > 0) {\n setVersionCount(Math.min(newCount, globalConfig.versions.max))\n } else {\n setVersionCount(newCount)\n }\n }\n }, [collectionConfig, globalConfig, versionCount])\n\n const updateSavedDocumentData = React.useCallback<DocumentInfoContext['updateSavedDocumentData']>(\n (json) => {\n setSavedDocumentData(json)\n },\n [setSavedDocumentData],\n )\n\n /**\n * @todo: Remove this in v4\n * Users should use the `DocumentTitleContext` instead.\n */\n useEffect(() => {\n setDocumentTitle(\n formatDocTitle({\n collectionConfig,\n data: { ...savedDocumentData, id },\n dateFormat,\n fallback: id?.toString(),\n globalConfig,\n i18n,\n }),\n )\n }, [collectionConfig, globalConfig, savedDocumentData, dateFormat, i18n, id])\n\n // clean on unmount\n useEffect(() => {\n const re1 = abortControllerRef.current\n\n return () => {\n if (re1) {\n try {\n re1.abort()\n } catch (_err) {\n // swallow error\n }\n }\n }\n }, [])\n\n const action: string = React.useMemo(() => {\n const docURL = `${baseURL}${pluralType === 'globals' ? `/globals` : ''}/${slug}${id ? `/${id}` : ''}`\n const params = {\n depth: 0,\n 'fallback-locale': 'null',\n locale,\n uploadEdits: uploadEdits || undefined,\n }\n\n return `${docURL}${qs.stringify(params, {\n addQueryPrefix: true,\n })}`\n }, [baseURL, locale, pluralType, id, slug, uploadEdits])\n\n const value: DocumentInfoContext = {\n ...props,\n action,\n currentEditor,\n docConfig,\n docPermissions,\n documentIsLocked,\n getDocPermissions,\n getDocPreferences,\n hasPublishedDoc,\n hasPublishPermission,\n hasSavePermission,\n incrementVersionCount,\n initialData,\n initialState,\n isInitializing,\n lastUpdateTime,\n mostRecentVersionIsAutosaved,\n preferencesKey,\n savedDocumentData,\n setCurrentEditor,\n setDocFieldPreferences,\n setDocumentIsLocked,\n setDocumentTitle,\n setHasPublishedDoc,\n setLastUpdateTime,\n setMostRecentVersionIsAutosaved,\n setUnpublishedVersionCount,\n setUploadStatus: updateUploadStatus,\n title,\n unlockDocument,\n unpublishedVersionCount,\n updateDocumentEditor,\n updateSavedDocumentData,\n uploadStatus,\n versionCount,\n }\n\n return (\n <Context value={value}>\n <DocumentTitleProvider>{children}</DocumentTitleProvider>\n </Context>\n )\n}\n\nexport const DocumentInfoProvider: React.FC<\n {\n readonly children: React.ReactNode\n } & DocumentInfoProps\n> = (props) => {\n return (\n <UploadEditsProvider>\n <DocumentInfo {...props} />\n </UploadEditsProvider>\n )\n}\n"],"mappings":"AAAA;;;AAGA,YAAYA,EAAA,MAAQ;AACpB,OAAOC,KAAA,IAASC,aAAa,EAAEC,GAAG,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAE7F,SAASC,oBAAoB,QAAQ;AACrC,SAASC,OAAO,QAAQ;AACxB,SAASC,QAAQ,QAAQ;AACzB,SAASC,cAAc,QAAQ;AAC/B,SAASC,SAAS,QAAQ;AAC1B,SAASC,qBAAqB,QAAQ;AACtC,SAASC,SAAS,EAAEC,gBAAgB,QAAQ;AAC5C,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,SAASC,mBAAmB,EAAEC,cAAc,QAAQ;AAEpD,SAASC,oBAAoB,QAAQ;AAErC,MAAMC,OAAA,gBAAUpB,aAAA,CAAc,CAAC;AAI/B,OAAO,MAAMqB,eAAA,GAAkBA,CAAA,KAA2BpB,GAAA,CAAImB,OAAA;AAE9D,MAAME,YAAA,GAIFA,CAAC;EAAEC,QAAQ;EAAE,GAAGC;AAAA,CAAO;EACzB,MAAM;IACJC,EAAE;IACFC,cAAc;IACdC,aAAA,EAAeC,sBAAsB;IACrCC,cAAA,EAAgBC,uBAAuB;IACvCC,UAAU;IACVC,eAAA,EAAiBC,wBAAwB;IACzCC,oBAAA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