@payloadcms/ui 4.0.0-canary.35 → 4.0.0-canary.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/css/app.css +1 -0
- package/dist/css/preflight.css +1 -0
- package/dist/css/spacing.css +3 -0
- package/dist/elements/AppHeader/index.css +3 -0
- package/dist/elements/Banner/index.css +4 -0
- package/dist/elements/Banner/index.d.ts.map +1 -1
- package/dist/elements/Banner/index.js +1 -0
- package/dist/elements/Banner/index.js.map +1 -1
- package/dist/elements/BulkUpload/ActionsBar/index.css +1 -0
- package/dist/elements/BulkUpload/AddingFilesView/index.css +2 -4
- package/dist/elements/BulkUpload/FileSidebar/index.css +1 -0
- package/dist/elements/BulkUpload/FormsManager/index.d.ts.map +1 -1
- package/dist/elements/BulkUpload/FormsManager/index.js +12 -7
- package/dist/elements/BulkUpload/FormsManager/index.js.map +1 -1
- package/dist/elements/BulkUpload/index.css +2 -0
- package/dist/elements/Collapsible/index.css +1 -0
- package/dist/elements/DatePicker/index.css +2 -0
- package/dist/elements/Dialog/index.css +1 -0
- package/dist/elements/DocumentControls/index.css +1 -0
- package/dist/elements/DocumentFields/index.css +2 -0
- package/dist/elements/DocumentHeader/Tabs/index.css +1 -0
- package/dist/elements/DocumentHeader/index.css +1 -0
- package/dist/elements/EditUpload/index.css +1 -1
- package/dist/elements/FieldDiffContainer/index.css +1 -0
- package/dist/elements/FieldDiffLabel/index.css +1 -0
- package/dist/elements/FileDetails/StaticFileDetails/index.css +2 -0
- package/dist/elements/HTMLDiff/index.css +1 -0
- package/dist/elements/ItemsDrawer/index.css +3 -0
- package/dist/elements/ListControls/index.css +1 -0
- package/dist/elements/ListControls/index.d.ts.map +1 -1
- package/dist/elements/ListControls/index.js +7 -1
- package/dist/elements/ListControls/index.js.map +1 -1
- package/dist/elements/ListControls/types.d.ts +3 -1
- package/dist/elements/ListControls/types.d.ts.map +1 -1
- package/dist/elements/ListControls/types.js.map +1 -1
- package/dist/elements/ListControlsBar/index.css +1 -0
- package/dist/elements/ListHeader/TitleActions/ListEmptyTrashButton.js +1 -1
- package/dist/elements/ListHeader/TitleActions/ListEmptyTrashButton.js.map +1 -1
- package/dist/elements/LivePreview/Window/index.css +1 -0
- package/dist/elements/Nav/getNavPrefs.d.ts.map +1 -1
- package/dist/elements/Nav/getNavPrefs.js +2 -0
- package/dist/elements/Nav/getNavPrefs.js.map +1 -1
- package/dist/elements/Nav/index.css +2 -0
- package/dist/elements/PageControls/index.css +1 -0
- package/dist/elements/PillSelector/index.css +1 -0
- package/dist/elements/PreviewSizes/index.css +2 -0
- package/dist/elements/PublishButton/index.css +1 -0
- package/dist/elements/PublishButton/index.d.ts.map +1 -1
- package/dist/elements/PublishButton/index.js +11 -25
- package/dist/elements/PublishButton/index.js.map +1 -1
- package/dist/elements/QueryPresets/fields/Heading/index.css +1 -0
- package/dist/elements/RenderTitle/index.css +1 -0
- package/dist/elements/Table/index.css +1 -0
- package/dist/elements/TableSection/index.css +1 -0
- package/dist/elements/Tabs/index.css +1 -0
- package/dist/elements/Thumbnail/index.css +1 -0
- package/dist/elements/TimezonePicker/index.css +1 -0
- package/dist/elements/Tooltip/index.css +7 -0
- package/dist/elements/WhereBuilder/Condition/index.css +1 -0
- package/dist/elements/WhereBuilder/index.css +2 -0
- package/dist/fields/Array/index.css +1 -0
- package/dist/fields/Blocks/index.css +1 -0
- package/dist/fields/Group/index.css +1 -0
- package/dist/fields/Row/index.css +2 -0
- package/dist/fields/Tabs/index.css +1 -0
- package/dist/forms/RenderFields/index.css +1 -0
- package/dist/hooks/useControllableState.js +3 -3
- package/dist/hooks/useControllableState.js.map +1 -1
- package/dist/layouts/Root/index.d.ts +3 -6
- package/dist/layouts/Root/index.d.ts.map +1 -1
- package/dist/layouts/Root/index.js +2 -4
- package/dist/layouts/Root/index.js.map +1 -1
- package/dist/providers/DocumentInfo/index.d.ts.map +1 -1
- package/dist/providers/DocumentInfo/index.js +30 -19
- package/dist/providers/DocumentInfo/index.js.map +1 -1
- package/dist/providers/Locale/index.d.ts.map +1 -1
- package/dist/providers/Locale/index.js +6 -7
- package/dist/providers/Locale/index.js.map +1 -1
- package/dist/styles.css +5 -1
- package/dist/templates/Default/Wrapper/index.css +2 -0
- package/dist/templates/Default/index.css +1 -0
- package/dist/utilities/getDocPreferences.d.ts.map +1 -1
- package/dist/utilities/getDocPreferences.js +1 -0
- package/dist/utilities/getDocPreferences.js.map +1 -1
- package/dist/utilities/getPreferences.d.ts.map +1 -1
- package/dist/utilities/getPreferences.js +1 -0
- package/dist/utilities/getPreferences.js.map +1 -1
- package/dist/utilities/getVersions.d.ts.map +1 -1
- package/dist/utilities/getVersions.js +8 -0
- package/dist/utilities/getVersions.js.map +1 -1
- package/dist/utilities/handleAuthRedirect.d.ts.map +1 -1
- package/dist/utilities/handleAuthRedirect.js +4 -1
- package/dist/utilities/handleAuthRedirect.js.map +1 -1
- package/dist/utilities/isPathMatchingRoute.d.ts.map +1 -1
- package/dist/utilities/isPathMatchingRoute.js +7 -5
- package/dist/utilities/isPathMatchingRoute.js.map +1 -1
- package/dist/utilities/schedulePublishHandler.d.ts.map +1 -1
- package/dist/utilities/schedulePublishHandler.js +2 -0
- package/dist/utilities/schedulePublishHandler.js.map +1 -1
- package/dist/utilities/upsertPreferences.d.ts.map +1 -1
- package/dist/utilities/upsertPreferences.js +3 -0
- package/dist/utilities/upsertPreferences.js.map +1 -1
- package/dist/views/API/index.css +1 -0
- package/dist/views/Dashboard/Default/ModularDashboard/index.css +2 -0
- package/dist/views/Document/handleServerFunction.d.ts.map +1 -1
- package/dist/views/Document/handleServerFunction.js +1 -0
- package/dist/views/Document/handleServerFunction.js.map +1 -1
- package/dist/views/Edit/index.css +1 -0
- package/dist/views/HierarchyList/HierarchyTable/SlotTable.css +1 -0
- package/dist/views/HierarchyList/index.css +1 -0
- package/dist/views/List/ListHeader/index.css +1 -0
- package/dist/views/List/ListHeader/index.d.ts +0 -1
- package/dist/views/List/ListHeader/index.d.ts.map +1 -1
- package/dist/views/List/ListHeader/index.js +2 -6
- package/dist/views/List/ListHeader/index.js.map +1 -1
- package/dist/views/List/enrichDocsWithVersionStatus.d.ts.map +1 -1
- package/dist/views/List/enrichDocsWithVersionStatus.js +1 -0
- package/dist/views/List/enrichDocsWithVersionStatus.js.map +1 -1
- package/dist/views/List/handleServerFunction.d.ts.map +1 -1
- package/dist/views/List/handleServerFunction.js +1 -0
- package/dist/views/List/handleServerFunction.js.map +1 -1
- package/dist/views/List/index.client.d.ts.map +1 -1
- package/dist/views/List/index.client.js +3 -2
- package/dist/views/List/index.client.js.map +1 -1
- package/dist/views/List/index.css +2 -0
- package/dist/views/NotFound/client.d.ts +2 -0
- package/dist/views/NotFound/client.d.ts.map +1 -0
- package/dist/views/NotFound/client.js +4 -0
- package/dist/views/NotFound/client.js.map +1 -0
- package/dist/views/Root/index.d.ts.map +1 -1
- package/dist/views/Root/index.js +26 -19
- package/dist/views/Root/index.js.map +1 -1
- package/dist/views/Version/Default/index.css +2 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Date/index.css +8 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/generateLabelFromValue.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/generateLabelFromValue.js +1 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/generateLabelFromValue.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.css +1 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Upload/index.css +1 -0
- package/dist/views/Version/RenderFieldsToDiff/index.css +2 -0
- package/dist/views/Version/Restore/index.d.ts.map +1 -1
- package/dist/views/Version/Restore/index.js +9 -6
- package/dist/views/Version/Restore/index.js.map +1 -1
- package/dist/views/Versions/VersionPillLabel/index.css +1 -0
- package/dist/views/Versions/index.css +1 -0
- package/dist/widgets/CollectionCards/index.css +4 -0
- package/package.json +11 -6
- package/dist/elements/ClipboardAction/clipboardUtilities.spec.js +0 -120
- package/dist/elements/ClipboardAction/clipboardUtilities.spec.js.map +0 -1
- package/dist/elements/ClipboardAction/isClipboardDataValid.spec.js +0 -144
- package/dist/elements/ClipboardAction/isClipboardDataValid.spec.js.map +0 -1
- package/dist/elements/ClipboardAction/mergeFormStateFromClipboard.spec.js +0 -885
- package/dist/elements/ClipboardAction/mergeFormStateFromClipboard.spec.js.map +0 -1
- package/dist/elements/ColumnSelection/matchesColumnSearch.spec.js +0 -87
- package/dist/elements/ColumnSelection/matchesColumnSearch.spec.js.map +0 -1
- package/dist/elements/CommandPalette/buildActions.spec.js +0 -158
- package/dist/elements/CommandPalette/buildActions.spec.js.map +0 -1
- package/dist/elements/CommandPalette/highlightLabel.spec.js +0 -78
- package/dist/elements/CommandPalette/highlightLabel.spec.js.map +0 -1
- package/dist/elements/FieldSelect/reduceFieldOptions.spec.js +0 -143
- package/dist/elements/FieldSelect/reduceFieldOptions.spec.js.map +0 -1
- package/dist/elements/Toasts/fieldErrors.spec.js +0 -46
- package/dist/elements/Toasts/fieldErrors.spec.js.map +0 -1
- package/dist/elements/WhereBuilder/Condition/Relationship/optionsReducer.spec.js +0 -152
- package/dist/elements/WhereBuilder/Condition/Relationship/optionsReducer.spec.js.map +0 -1
- package/dist/elements/WhereBuilder/conditionValue.spec.js +0 -65
- package/dist/elements/WhereBuilder/conditionValue.spec.js.map +0 -1
- package/dist/fields/Upload/Input.spec.js +0 -242
- package/dist/fields/Upload/Input.spec.js.map +0 -1
- package/dist/forms/fieldSchemasToFormState/fieldSchemasToFormState.spec.d.ts +0 -2
- package/dist/forms/fieldSchemasToFormState/fieldSchemasToFormState.spec.d.ts.map +0 -1
- package/dist/forms/fieldSchemasToFormState/fieldSchemasToFormState.spec.js +0 -67
- package/dist/forms/fieldSchemasToFormState/fieldSchemasToFormState.spec.js.map +0 -1
- package/dist/forms/fieldSchemasToFormState/serverFunctions/renderFieldServerFn.spec.js +0 -150
- package/dist/forms/fieldSchemasToFormState/serverFunctions/renderFieldServerFn.spec.js.map +0 -1
- package/dist/layouts/Root/index.spec.js +0 -20
- package/dist/layouts/Root/index.spec.js.map +0 -1
- package/dist/providers/Auth/authSessionRequests.spec.js +0 -121
- package/dist/providers/Auth/authSessionRequests.spec.js.map +0 -1
- package/dist/providers/Auth/sessionActivity.spec.js +0 -44
- package/dist/providers/Auth/sessionActivity.spec.js.map +0 -1
- package/dist/providers/Auth/tabSessionSync/index.spec.js +0 -463
- package/dist/providers/Auth/tabSessionSync/index.spec.js.map +0 -1
- package/dist/providers/Auth/useAuthSessionTimers.spec.js +0 -311
- package/dist/providers/Auth/useAuthSessionTimers.spec.js.map +0 -1
- package/dist/providers/RouteTransition/ProgressBar/index.spec.js +0 -44
- package/dist/providers/RouteTransition/ProgressBar/index.spec.js.map +0 -1
- package/dist/providers/TableColumns/buildColumnState/index.spec.js +0 -40
- package/dist/providers/TableColumns/buildColumnState/index.spec.js.map +0 -1
- package/dist/utilities/appendCacheTag.spec.js +0 -34
- package/dist/utilities/appendCacheTag.spec.js.map +0 -1
- package/dist/utilities/formatAbsoluteURL.spec.js +0 -27
- package/dist/utilities/formatAbsoluteURL.spec.js.map +0 -1
- package/dist/utilities/formatMetadata.spec.js +0 -83
- package/dist/utilities/formatMetadata.spec.js.map +0 -1
- package/dist/utilities/fuzzyMatch.spec.js +0 -38
- package/dist/utilities/fuzzyMatch.spec.js.map +0 -1
- package/dist/utilities/getRequestLocale.d.ts +0 -7
- package/dist/utilities/getRequestLocale.d.ts.map +0 -1
- package/dist/utilities/getRequestLocale.js +0 -20
- package/dist/utilities/getRequestLocale.js.map +0 -1
- package/dist/utilities/initReq.d.ts +0 -16
- package/dist/utilities/initReq.d.ts.map +0 -1
- package/dist/utilities/initReq.js +0 -146
- package/dist/utilities/initReq.js.map +0 -1
- package/dist/utilities/initReq.spec.js +0 -226
- package/dist/utilities/initReq.spec.js.map +0 -1
- package/dist/utilities/isAbsoluteURL.spec.js +0 -11
- package/dist/utilities/isAbsoluteURL.spec.js.map +0 -1
- package/dist/utilities/isCustomAdminView.spec.js +0 -90
- package/dist/utilities/isCustomAdminView.spec.js.map +0 -1
- package/dist/utilities/isHttpURL.spec.js +0 -25
- package/dist/utilities/isHttpURL.spec.js.map +0 -1
- package/dist/utilities/isPathMatchingRoute.spec.js +0 -178
- package/dist/utilities/isPathMatchingRoute.spec.js.map +0 -1
- package/dist/utilities/isPublicAdminRoute.spec.js +0 -34
- package/dist/utilities/isPublicAdminRoute.spec.js.map +0 -1
- package/dist/utilities/normalizeRelationshipValue.spec.js +0 -373
- package/dist/utilities/normalizeRelationshipValue.spec.js.map +0 -1
- package/dist/utilities/recentlyViewed.spec.js +0 -92
- package/dist/utilities/recentlyViewed.spec.js.map +0 -1
- package/dist/utilities/selectiveCache.d.ts +0 -12
- package/dist/utilities/selectiveCache.d.ts.map +0 -1
- package/dist/utilities/selectiveCache.js +0 -37
- package/dist/utilities/selectiveCache.js.map +0 -1
- package/dist/views/Root/getCustomCollectionViewByRoute.spec.js +0 -168
- package/dist/views/Root/getCustomCollectionViewByRoute.spec.js.map +0 -1
- package/dist/views/Version/RenderFieldsToDiff/buildVersionFields.spec.js +0 -258
- package/dist/views/Version/RenderFieldsToDiff/buildVersionFields.spec.js.map +0 -1
- package/dist/views/Version/RenderFieldsToDiff/utilities/countChangedFields.spec.js +0 -915
- package/dist/views/Version/RenderFieldsToDiff/utilities/countChangedFields.spec.js.map +0 -1
- package/dist/views/Version/RenderFieldsToDiff/utilities/fieldHasChanges.spec.js +0 -47
- package/dist/views/Version/RenderFieldsToDiff/utilities/fieldHasChanges.spec.js.map +0 -1
- package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.spec.js +0 -125
- package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.spec.js.map +0 -1
- package/dist/widgets/CollectionQuery/getCollectionFieldPaths.spec.js +0 -100
- package/dist/widgets/CollectionQuery/getCollectionFieldPaths.spec.js.map +0 -1
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
grid-column: 2 / -1;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
/* stylelint-disable-next-line plugin/no-max-width-media-query -- TODO: pre-existing; migrate to a mobile-first min-width query */
|
|
51
52
|
@media (max-width: 768px) {
|
|
52
53
|
.where-builder__or-filters {
|
|
53
54
|
display: flex;
|
|
@@ -66,6 +67,7 @@
|
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
69
|
|
|
70
|
+
/* stylelint-disable-next-line plugin/no-max-width-media-query -- TODO: pre-existing; migrate to a mobile-first min-width query */
|
|
69
71
|
@media (max-width: 768px) {
|
|
70
72
|
.where-builder {
|
|
71
73
|
padding-top: var(--spacer-2);
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
/* stylelint-disable-next-line plugin/no-max-width-media-query -- TODO: pre-existing; migrate to a mobile-first min-width query */
|
|
32
33
|
@media (max-width: 1024px) {
|
|
33
34
|
.row__fields {
|
|
34
35
|
flex-direction: column;
|
|
@@ -39,6 +40,7 @@
|
|
|
39
40
|
> * {
|
|
40
41
|
margin-left: 0;
|
|
41
42
|
margin-right: 0;
|
|
43
|
+
/* stylelint-disable-next-line plugin/no-important -- TODO: pre-existing; revisit whether specificity can win instead */
|
|
42
44
|
width: 100% !important;
|
|
43
45
|
padding-left: 0;
|
|
44
46
|
padding-right: 0;
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
margin-bottom: var(--spacer-4);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
/* stylelint-disable-next-line plugin/no-max-width-media-query -- TODO: pre-existing; migrate to a mobile-first min-width query */
|
|
68
69
|
@media (max-width: 768px) {
|
|
69
70
|
.tabs-field--within-collapsible {
|
|
70
71
|
margin-left: calc(var(--gutter-h) * -1);
|
|
@@ -5,15 +5,15 @@ import { useEffect, useRef, useState } from 'react';
|
|
|
5
5
|
export function useControllableState(propValue, fallbackValue) {
|
|
6
6
|
const $ = _c(5);
|
|
7
7
|
const [localValue, setLocalValue] = useState(propValue);
|
|
8
|
-
const
|
|
8
|
+
const previousPropValue = useRef(propValue);
|
|
9
9
|
let t0;
|
|
10
10
|
let t1;
|
|
11
11
|
if ($[0] !== propValue) {
|
|
12
12
|
t0 = () => {
|
|
13
|
-
if (
|
|
14
|
-
initialRenderRef.current = false;
|
|
13
|
+
if (Object.is(previousPropValue.current, propValue)) {
|
|
15
14
|
return;
|
|
16
15
|
}
|
|
16
|
+
previousPropValue.current = propValue;
|
|
17
17
|
setLocalValue(propValue);
|
|
18
18
|
};
|
|
19
19
|
t1 = [propValue];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useControllableState.js","names":["c","_c","useEffect","useRef","useState","useControllableState","propValue","fallbackValue","$","localValue","setLocalValue","
|
|
1
|
+
{"version":3,"file":"useControllableState.js","names":["c","_c","useEffect","useRef","useState","useControllableState","propValue","fallbackValue","$","localValue","setLocalValue","previousPropValue","t0","t1","Object","is","current","t2","t3"],"sources":["../../src/hooks/useControllableState.ts"],"sourcesContent":["'use client'\nimport { 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 *\n * @param propValue - The controlled value from props\n * @param fallbackValue - Value to use when propValue is null or undefined\n *\n * @internal - may change or be removed without a major version bump\n */\nexport function useControllableState<T, D>(\n propValue: T,\n fallbackValue: D,\n): [T extends NonNullable<T> ? T : D | NonNullable<T>, (value: ((prev: T) => T) | T) => void]\n\nexport function useControllableState<T>(propValue: T): [T, (value: ((prev: T) => T) | T) => void]\n\nexport function useControllableState<T, D>(\n propValue: T,\n fallbackValue?: D,\n): [T extends NonNullable<T> ? T : D | NonNullable<T>, (value: ((prev: T) => T) | T) => void] {\n const [localValue, setLocalValue] = useState<T>(propValue)\n const previousPropValue = useRef(propValue)\n\n useEffect(() => {\n if (Object.is(previousPropValue.current, propValue)) {\n return\n }\n\n previousPropValue.current = propValue\n setLocalValue(propValue)\n }, [propValue])\n\n return [localValue ?? fallbackValue, setLocalValue] as [\n T extends NonNullable<T> ? T : D | NonNullable<T>,\n (value: ((prev: T) => T) | T) => void,\n ]\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AACA,SAASC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAkB5C,OAAO,SAAAC,qBAAAC,SAAA,EAAAC,aAAA;EAAA,MAAAC,CAAA,GAAAP,EAAA;EAIL,OAAAQ,UAAA,EAAAC,aAAA,IAAoCN,QAAA,CAAYE,SAAA;EAChD,MAAAK,iBAAA,GAA0BR,MAAA,CAAOG,SAAA;EAAA,IAAAM,EAAA;EAAA,IAAAC,EAAA;EAAA,IAAAL,CAAA,QAAAF,SAAA;IAEvBM,EAAA,GAAAA,CAAA;MAAA,IACJE,MAAA,CAAAC,EAAA,CAAUJ,iBAAA,CAAAK,OAAA,EAA2BV,SAAA;QAAA;MAAA;MAIzCK,iBAAA,CAAAK,OAAA,GAA4BV,SAAA;MAC5BI,aAAA,CAAcJ,SAAA;IAAA;IACbO,EAAA,IAACP,SAAA;IAAUE,CAAA,MAAAF,SAAA;IAAAE,CAAA,MAAAI,EAAA;IAAAJ,CAAA,MAAAK,EAAA;EAAA;IAAAD,EAAA,GAAAJ,CAAA;IAAAK,EAAA,GAAAL,CAAA;EAAA;EAPdN,SAAA,CAAUU,EAOV,EAAGC,EAAW;EAEN,MAAAI,EAAA,GAAAR,UAAA,IAAcF,aAAA;EAAA,IAAAW,EAAA;EAAA,IAAAV,CAAA,QAAAS,EAAA;IAAfC,EAAA,IAACD,EAAc,EAAeP,aAAA;IAAcF,CAAA,MAAAS,EAAA;IAAAT,CAAA,MAAAU,EAAA;EAAA;IAAAA,EAAA,GAAAV,CAAA;EAAA;EAAA,OAA5CU,EAA4C;AAAA","ignoreList":[]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { ImportMap,
|
|
1
|
+
import type { ImportMap, InitReqResult, SanitizedConfig, ServerFunctionClient } from 'payload';
|
|
2
|
+
import type { InitReqArgs } from 'payload/internal';
|
|
2
3
|
import React from 'react';
|
|
3
4
|
import { type CheckDependenciesArgs } from '../../utilities/checkDependencies.js';
|
|
4
5
|
import '@payloadcms/ui/css/app.css';
|
|
@@ -44,6 +45,7 @@ type RootLayoutProps = {
|
|
|
44
45
|
readonly head?: React.ReactNode;
|
|
45
46
|
readonly htmlProps?: React.HtmlHTMLAttributes<HTMLHtmlElement>;
|
|
46
47
|
readonly importMap: ImportMap;
|
|
48
|
+
readonly initReq: (args: Omit<InitReqArgs, 'cache' | 'serverAdapter'>) => Promise<InitReqResult>;
|
|
47
49
|
/**
|
|
48
50
|
* Client router adapter. Caller supplies a framework-specific provider
|
|
49
51
|
* (for Next.js use the `NextRouterAdapter` exported from `@payloadcms/next`).
|
|
@@ -51,11 +53,6 @@ type RootLayoutProps = {
|
|
|
51
53
|
readonly RouterAdapter: React.FC<{
|
|
52
54
|
children: React.ReactNode;
|
|
53
55
|
}>;
|
|
54
|
-
/**
|
|
55
|
-
* Server adapter providing framework-specific access to headers, cookies, redirects,
|
|
56
|
-
* and other server APIs (for Next.js use `nextServerAdapter` from `@payloadcms/next`).
|
|
57
|
-
*/
|
|
58
|
-
readonly serverAdapter: ServerAdapter;
|
|
59
56
|
readonly serverFunction: ServerFunctionClient;
|
|
60
57
|
};
|
|
61
58
|
export declare const RootLayout: (props: RootLayoutProps) => React.JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/layouts/Root/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/layouts/Root/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EAEb,eAAe,EACf,oBAAoB,EACrB,MAAM,SAAS,CAAA;AAChB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 +10,6 @@ import { getLanguageDir } from '../../utilities/getLanguageDir.js';
|
|
|
10
10
|
import { getRequestEmbed } from '../../utilities/getRequestEmbed.js';
|
|
11
11
|
import { getRequestHighContrast } from '../../utilities/getRequestHighContrast.js';
|
|
12
12
|
import { getRequestTheme } from '../../utilities/getRequestTheme.js';
|
|
13
|
-
import { initReq } from '../../utilities/initReq.js';
|
|
14
13
|
import { NestProviders } from './NestProviders.js';
|
|
15
14
|
import { getViewportMeta } from './viewport.js';
|
|
16
15
|
// eslint-disable-next-line payload/no-imports-from-self -- Self-import via package path ensures consumer's bundler resolves the full CSS chain (design tokens, preflight, etc.) in prod builds
|
|
@@ -39,8 +38,8 @@ const RootLayoutContent = async ({
|
|
|
39
38
|
head: headFromProps,
|
|
40
39
|
htmlProps = {},
|
|
41
40
|
importMap,
|
|
41
|
+
initReq,
|
|
42
42
|
RouterAdapter,
|
|
43
|
-
serverAdapter,
|
|
44
43
|
serverFunction
|
|
45
44
|
}) => {
|
|
46
45
|
const {
|
|
@@ -58,8 +57,7 @@ const RootLayoutContent = async ({
|
|
|
58
57
|
} = await initReq({
|
|
59
58
|
configPromise,
|
|
60
59
|
importMap,
|
|
61
|
-
key: 'RootLayout'
|
|
62
|
-
serverAdapter
|
|
60
|
+
key: 'RootLayout'
|
|
63
61
|
});
|
|
64
62
|
const theme = getRequestTheme({
|
|
65
63
|
config,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["applyLocaleFiltering","React","Suspense","getNavPrefs","ProgressBar","RootProvider","checkDependencies","getClientConfig","getLanguageDir","getRequestEmbed","getRequestHighContrast","getRequestTheme","initReq","NestProviders","getViewportMeta","metadata","description","title","RootLayout","props","additionalDependencyChecks","content","_jsx","RootLayoutContent","process","env","PAYLOAD_CACHE_COMPONENTS_ENABLED","fallback","children","config","configPromise","fonts","head","headFromProps","htmlProps","importMap","RouterAdapter","serverAdapter","serverFunction","cookies","headers","languageCode","permissions","req","payload","user","key","theme","highContrastMode","dir","embed","languageOptions","Object","entries","i18n","supportedLanguages","reduce","acc","language","languageConfig","keys","includes","push","label","translations","general","thisLanguage","value","navPrefs","clientConfig","fontClassNames","map","f","variable","className","filter","Boolean","viewportMeta","get","undefined","_jsxs","join","lang","suppressHydrationWarning","admin","dateFNSKey","fallbackLang","fallbackLanguage","isNavOpen","open","locale","Array","isArray","components","providers","length","serverProps","server","id"],"sources":["../../../src/layouts/Root/index.tsx"],"sourcesContent":["import type {\n ImportMap,\n LanguageOptions,\n SanitizedConfig,\n ServerAdapter,\n ServerFunctionClient,\n} from 'payload'\n\nimport { applyLocaleFiltering } from 'payload/shared'\nimport React, { Suspense } from 'react'\n\nimport { getNavPrefs } from '../../elements/Nav/getNavPrefs.js'\n// eslint-disable-next-line payload/no-imports-from-exports-dir -- Server component must reference exports/client bundle for proper client boundary in prod builds\nimport { ProgressBar, RootProvider } from '../../exports/client/index.js'\nimport { checkDependencies, type CheckDependenciesArgs } from '../../utilities/checkDependencies.js'\nimport { getClientConfig } from '../../utilities/getClientConfig.js'\nimport { getLanguageDir } from '../../utilities/getLanguageDir.js'\nimport { getRequestEmbed } from '../../utilities/getRequestEmbed.js'\nimport { getRequestHighContrast } from '../../utilities/getRequestHighContrast.js'\nimport { getRequestTheme } from '../../utilities/getRequestTheme.js'\nimport { initReq } from '../../utilities/initReq.js'\nimport { NestProviders } from './NestProviders.js'\nimport { getViewportMeta } from './viewport.js'\n// eslint-disable-next-line payload/no-imports-from-self -- Self-import via package path ensures consumer's bundler resolves the full CSS chain (design tokens, preflight, etc.) in prod builds\nimport '@payloadcms/ui/css/app.css'\n\ntype Font = {\n className?: string\n variable?: string\n}\n\nexport const metadata = {\n description: 'Generated by Next.js',\n title: 'Next.js',\n}\n\ntype RootLayoutProps = {\n /**\n * Framework-specific peer-dependency version constraints, merged on top of the\n * universal React/react-dom checks. Each framework adapter supplies its own\n * (e.g. Next.js passes `{ dependencyVersions: { next: { version: '>=15.0.0' } } }`).\n */\n readonly additionalDependencyChecks?: CheckDependenciesArgs\n readonly children: React.ReactNode\n readonly config: Promise<SanitizedConfig>\n /**\n * Fonts to apply to the admin `<html>` element. Each entry's\n * `variable ?? className` is appended to the `<html>` class list.\n * Framework-specific font loaders (e.g. `next/font`) are supplied by the caller.\n */\n readonly fonts?: Font[]\n /**\n * Custom content to render inside the admin panel's `<head>` element.\n *\n * Use this to inject scripts, meta tags, or links — for example, analytics\n * snippets via `next/script`, custom favicons, or preconnect hints.\n *\n * @example\n * ```tsx\n * import Script from 'next/script'\n *\n * <RootLayout\n * head={<Script src=\"https://example.com/analytics.js\" strategy=\"afterInteractive\" />}\n * {...rest}\n * />\n * ```\n */\n readonly head?: React.ReactNode\n readonly htmlProps?: React.HtmlHTMLAttributes<HTMLHtmlElement>\n readonly importMap: ImportMap\n /**\n * Client router adapter. Caller supplies a framework-specific provider\n * (for Next.js use the `NextRouterAdapter` exported from `@payloadcms/next`).\n */\n readonly RouterAdapter: React.FC<{ children: React.ReactNode }>\n /**\n * Server adapter providing framework-specific access to headers, cookies, redirects,\n * and other server APIs (for Next.js use `nextServerAdapter` from `@payloadcms/next`).\n */\n readonly serverAdapter: ServerAdapter\n readonly serverFunction: ServerFunctionClient\n}\n\nexport const RootLayout = (props: RootLayoutProps) => {\n checkDependencies(props.additionalDependencyChecks)\n\n const content = <RootLayoutContent {...props} />\n\n if (process.env.PAYLOAD_CACHE_COMPONENTS_ENABLED === 'true') {\n return <Suspense fallback={null}>{content}</Suspense>\n }\n\n return content\n}\n\nconst RootLayoutContent = async ({\n children,\n config: configPromise,\n fonts = [],\n head: headFromProps,\n htmlProps = {},\n importMap,\n RouterAdapter,\n serverAdapter,\n serverFunction,\n}: RootLayoutProps) => {\n const {\n cookies,\n headers,\n languageCode,\n permissions,\n req,\n req: {\n payload: { config },\n },\n user,\n } = await initReq({ configPromise, importMap, key: 'RootLayout', serverAdapter })\n\n const theme = getRequestTheme({\n config,\n cookies,\n headers,\n })\n\n const highContrastMode = getRequestHighContrast({\n config,\n cookies,\n headers,\n })\n\n const dir = getLanguageDir({ languageCode })\n const embed = getRequestEmbed({ config, cookies })\n\n const languageOptions: LanguageOptions = Object.entries(\n config.i18n.supportedLanguages || {},\n ).reduce((acc, [language, languageConfig]) => {\n if (Object.keys(config.i18n.supportedLanguages).includes(language)) {\n acc.push({\n label: languageConfig.translations.general.thisLanguage,\n value: language,\n })\n }\n\n return acc\n }, [])\n\n const navPrefs = await getNavPrefs(req)\n\n const clientConfig = getClientConfig({\n config,\n i18n: req.i18n,\n importMap,\n user,\n })\n\n await applyLocaleFiltering({ clientConfig, config, req })\n\n const fontClassNames = fonts.map((f) => f.variable ?? f.className).filter(Boolean)\n const viewportMeta = getViewportMeta(headers.get('user-agent') ?? undefined)\n\n return (\n <html\n {...htmlProps}\n className={[...fontClassNames, htmlProps?.className].filter(Boolean).join(' ')}\n data-enhanced-contrast={highContrastMode ? '' : undefined}\n data-theme={theme}\n dir={dir}\n lang={languageCode}\n suppressHydrationWarning={config?.admin?.suppressHydrationWarning ?? false}\n >\n <head>\n {viewportMeta}\n <style>{`@layer payload-default, payload;`}</style>\n {headFromProps}\n </head>\n <body>\n <RootProvider\n config={clientConfig}\n dateFNSKey={req.i18n.dateFNSKey}\n embed={embed}\n fallbackLang={config.i18n.fallbackLanguage}\n highContrastMode={highContrastMode}\n isNavOpen={navPrefs?.open ?? true}\n languageCode={languageCode}\n languageOptions={languageOptions}\n locale={req.locale}\n permissions={user ? permissions : null}\n RouterAdapter={RouterAdapter}\n serverFunction={serverFunction}\n theme={theme}\n translations={req.i18n.translations}\n user={user}\n >\n <ProgressBar />\n {Array.isArray(config.admin?.components?.providers) &&\n config.admin?.components?.providers.length > 0 ? (\n <NestProviders\n importMap={req.payload.importMap}\n providers={config.admin?.components?.providers}\n serverProps={{\n i18n: req.i18n,\n payload: req.payload,\n permissions,\n server: req.server,\n user,\n }}\n >\n {children}\n </NestProviders>\n ) : (\n children\n )}\n </RootProvider>\n <div id=\"portal\" />\n </body>\n </html>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B,SAAA,EAAWQ,GAAA,CAAIC,OAAO,CAACT,SAAS;UAChC2D,SAAA,EAAWjE,MAAA,CAAOuD,KAAK,EAAES,UAAA,EAAYC,SAAA;UACrCE,WAAA,EAAa;YACX1C,IAAA,EAAMX,GAAA,CAAIW,IAAI;YACdV,OAAA,EAASD,GAAA,CAAIC,OAAO;YACpBF,WAAA;YACAuD,MAAA,EAAQtD,GAAA,CAAIsD,MAAM;YAClBpD;UACF;oBAECjB;aAGHA,QAAA;uBAGJN,IAAA,CAAC;QAAI4E,EAAA,EAAG;;;;AAIhB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["applyLocaleFiltering","React","Suspense","getNavPrefs","ProgressBar","RootProvider","checkDependencies","getClientConfig","getLanguageDir","getRequestEmbed","getRequestHighContrast","getRequestTheme","NestProviders","getViewportMeta","metadata","description","title","RootLayout","props","additionalDependencyChecks","content","_jsx","RootLayoutContent","process","env","PAYLOAD_CACHE_COMPONENTS_ENABLED","fallback","children","config","configPromise","fonts","head","headFromProps","htmlProps","importMap","initReq","RouterAdapter","serverFunction","cookies","headers","languageCode","permissions","req","payload","user","key","theme","highContrastMode","dir","embed","languageOptions","Object","entries","i18n","supportedLanguages","reduce","acc","language","languageConfig","keys","includes","push","label","translations","general","thisLanguage","value","navPrefs","clientConfig","fontClassNames","map","f","variable","className","filter","Boolean","viewportMeta","get","undefined","_jsxs","join","lang","suppressHydrationWarning","admin","dateFNSKey","fallbackLang","fallbackLanguage","isNavOpen","open","locale","Array","isArray","components","providers","length","serverProps","server","id"],"sources":["../../../src/layouts/Root/index.tsx"],"sourcesContent":["import type {\n ImportMap,\n InitReqResult,\n LanguageOptions,\n SanitizedConfig,\n ServerFunctionClient,\n} from 'payload'\nimport type { InitReqArgs } from 'payload/internal'\n\nimport { applyLocaleFiltering } from 'payload/shared'\nimport React, { Suspense } from 'react'\n\nimport { getNavPrefs } from '../../elements/Nav/getNavPrefs.js'\n// eslint-disable-next-line payload/no-imports-from-exports-dir -- Server component must reference exports/client bundle for proper client boundary in prod builds\nimport { ProgressBar, RootProvider } from '../../exports/client/index.js'\nimport { checkDependencies, type CheckDependenciesArgs } from '../../utilities/checkDependencies.js'\nimport { getClientConfig } from '../../utilities/getClientConfig.js'\nimport { getLanguageDir } from '../../utilities/getLanguageDir.js'\nimport { getRequestEmbed } from '../../utilities/getRequestEmbed.js'\nimport { getRequestHighContrast } from '../../utilities/getRequestHighContrast.js'\nimport { getRequestTheme } from '../../utilities/getRequestTheme.js'\nimport { NestProviders } from './NestProviders.js'\nimport { getViewportMeta } from './viewport.js'\n// eslint-disable-next-line payload/no-imports-from-self -- Self-import via package path ensures consumer's bundler resolves the full CSS chain (design tokens, preflight, etc.) in prod builds\nimport '@payloadcms/ui/css/app.css'\n\ntype Font = {\n className?: string\n variable?: string\n}\n\nexport const metadata = {\n description: 'Generated by Next.js',\n title: 'Next.js',\n}\n\ntype RootLayoutProps = {\n /**\n * Framework-specific peer-dependency version constraints, merged on top of the\n * universal React/react-dom checks. Each framework adapter supplies its own\n * (e.g. Next.js passes `{ dependencyVersions: { next: { version: '>=15.0.0' } } }`).\n */\n readonly additionalDependencyChecks?: CheckDependenciesArgs\n readonly children: React.ReactNode\n readonly config: Promise<SanitizedConfig>\n /**\n * Fonts to apply to the admin `<html>` element. Each entry's\n * `variable ?? className` is appended to the `<html>` class list.\n * Framework-specific font loaders (e.g. `next/font`) are supplied by the caller.\n */\n readonly fonts?: Font[]\n /**\n * Custom content to render inside the admin panel's `<head>` element.\n *\n * Use this to inject scripts, meta tags, or links — for example, analytics\n * snippets via `next/script`, custom favicons, or preconnect hints.\n *\n * @example\n * ```tsx\n * import Script from 'next/script'\n *\n * <RootLayout\n * head={<Script src=\"https://example.com/analytics.js\" strategy=\"afterInteractive\" />}\n * {...rest}\n * />\n * ```\n */\n readonly head?: React.ReactNode\n readonly htmlProps?: React.HtmlHTMLAttributes<HTMLHtmlElement>\n readonly importMap: ImportMap\n readonly initReq: (args: Omit<InitReqArgs, 'cache' | 'serverAdapter'>) => Promise<InitReqResult>\n /**\n * Client router adapter. Caller supplies a framework-specific provider\n * (for Next.js use the `NextRouterAdapter` exported from `@payloadcms/next`).\n */\n readonly RouterAdapter: React.FC<{ children: React.ReactNode }>\n readonly serverFunction: ServerFunctionClient\n}\n\nexport const RootLayout = (props: RootLayoutProps) => {\n checkDependencies(props.additionalDependencyChecks)\n\n const content = <RootLayoutContent {...props} />\n\n if (process.env.PAYLOAD_CACHE_COMPONENTS_ENABLED === 'true') {\n return <Suspense fallback={null}>{content}</Suspense>\n }\n\n return content\n}\n\nconst RootLayoutContent = async ({\n children,\n config: configPromise,\n fonts = [],\n head: headFromProps,\n htmlProps = {},\n importMap,\n initReq,\n RouterAdapter,\n serverFunction,\n}: RootLayoutProps) => {\n const {\n cookies,\n headers,\n languageCode,\n permissions,\n req,\n req: {\n payload: { config },\n },\n user,\n } = await initReq({ configPromise, importMap, key: 'RootLayout' })\n\n const theme = getRequestTheme({\n config,\n cookies,\n headers,\n })\n\n const highContrastMode = getRequestHighContrast({\n config,\n cookies,\n headers,\n })\n\n const dir = getLanguageDir({ languageCode })\n const embed = getRequestEmbed({ config, cookies })\n\n const languageOptions: LanguageOptions = Object.entries(\n config.i18n.supportedLanguages || {},\n ).reduce((acc, [language, languageConfig]) => {\n if (Object.keys(config.i18n.supportedLanguages).includes(language)) {\n acc.push({\n label: languageConfig.translations.general.thisLanguage,\n value: language,\n })\n }\n\n return acc\n }, [])\n\n const navPrefs = await getNavPrefs(req)\n\n const clientConfig = getClientConfig({\n config,\n i18n: req.i18n,\n importMap,\n user,\n })\n\n await applyLocaleFiltering({ clientConfig, config, req })\n\n const fontClassNames = fonts.map((f) => f.variable ?? f.className).filter(Boolean)\n const viewportMeta = getViewportMeta(headers.get('user-agent') ?? undefined)\n\n return (\n <html\n {...htmlProps}\n className={[...fontClassNames, htmlProps?.className].filter(Boolean).join(' ')}\n data-enhanced-contrast={highContrastMode ? '' : undefined}\n data-theme={theme}\n dir={dir}\n lang={languageCode}\n suppressHydrationWarning={config?.admin?.suppressHydrationWarning ?? false}\n >\n <head>\n {viewportMeta}\n <style>{`@layer payload-default, payload;`}</style>\n {headFromProps}\n </head>\n <body>\n <RootProvider\n config={clientConfig}\n dateFNSKey={req.i18n.dateFNSKey}\n embed={embed}\n fallbackLang={config.i18n.fallbackLanguage}\n highContrastMode={highContrastMode}\n isNavOpen={navPrefs?.open ?? true}\n languageCode={languageCode}\n languageOptions={languageOptions}\n locale={req.locale}\n permissions={user ? permissions : null}\n RouterAdapter={RouterAdapter}\n serverFunction={serverFunction}\n theme={theme}\n translations={req.i18n.translations}\n user={user}\n >\n <ProgressBar />\n {Array.isArray(config.admin?.components?.providers) &&\n config.admin?.components?.providers.length > 0 ? (\n <NestProviders\n importMap={req.payload.importMap}\n providers={config.admin?.components?.providers}\n serverProps={{\n i18n: req.i18n,\n payload: req.payload,\n permissions,\n server: req.server,\n user,\n }}\n >\n {children}\n </NestProviders>\n ) : (\n children\n )}\n </RootProvider>\n <div id=\"portal\" />\n </body>\n </html>\n )\n}\n"],"mappings":";AASA,SAASA,oBAAoB,QAAQ;AACrC,OAAOC,KAAA,IAASC,QAAQ,QAAQ;AAEhC,SAASC,WAAW,QAAQ;AAC5B;AACA,SAASC,WAAW,EAAEC,YAAY,QAAQ;AAC1C,SAASC,iBAAiB,QAAoC;AAC9D,SAASC,eAAe,QAAQ;AAChC,SAASC,cAAc,QAAQ;AAC/B,SAASC,eAAe,QAAQ;AAChC,SAASC,sBAAsB,QAAQ;AACvC,SAASC,eAAe,QAAQ;AAChC,SAASC,aAAa,QAAQ;AAC9B,SAASC,eAAe,QAAQ;AAChC;AACA,OAAO;AAOP,OAAO,MAAMC,QAAA,GAAW;EACtBC,WAAA,EAAa;EACbC,KAAA,EAAO;AACT;AA6CA,OAAO,MAAMC,UAAA,GAAcC,KAAA;EACzBZ,iBAAA,CAAkBY,KAAA,CAAMC,0BAA0B;EAElD,MAAMC,OAAA,gBAAUC,IAAA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CAACiC,gBAAgB;QAC1CvC,gBAAA,EAAkBA,gBAAA;QAClBwC,SAAA,EAAWpB,QAAA,EAAUqB,IAAA,IAAQ;QAC7BhD,YAAA,EAAcA,YAAA;QACdU,eAAA,EAAiBA,eAAA;QACjBuC,MAAA,EAAQ/C,GAAA,CAAI+C,MAAM;QAClBhD,WAAA,EAAaG,IAAA,GAAOH,WAAA,GAAc;QAClCL,aAAA,EAAeA,aAAA;QACfC,cAAA,EAAgBA,cAAA;QAChBS,KAAA,EAAOA,KAAA;QACPiB,YAAA,EAAcrB,GAAA,CAAIW,IAAI,CAACU,YAAY;QACnCnB,IAAA,EAAMA,IAAA;gCAENvB,IAAA,CAACjB,WAAA,OACAsF,KAAA,CAAMC,OAAO,CAAC/D,MAAA,CAAOuD,KAAK,EAAES,UAAA,EAAYC,SAAA,KACzCjE,MAAA,CAAOuD,KAAK,EAAES,UAAA,EAAYC,SAAA,CAAUC,MAAA,GAAS,iBAC3CzE,IAAA,CAACT,aAAA;UACCsB,SAAA,EAAWQ,GAAA,CAAIC,OAAO,CAACT,SAAS;UAChC2D,SAAA,EAAWjE,MAAA,CAAOuD,KAAK,EAAES,UAAA,EAAYC,SAAA;UACrCE,WAAA,EAAa;YACX1C,IAAA,EAAMX,GAAA,CAAIW,IAAI;YACdV,OAAA,EAASD,GAAA,CAAIC,OAAO;YACpBF,WAAA;YACAuD,MAAA,EAAQtD,GAAA,CAAIsD,MAAM;YAClBpD;UACF;oBAECjB;aAGHA,QAAA;uBAGJN,IAAA,CAAC;QAAI4E,EAAA,EAAG;;;;AAIhB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/DocumentInfo/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAgF,MAAM,OAAO,CAAA;AAEpG,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAexE,mBAAmB,YAAY,CAAA;AAE/B,eAAO,MAAM,eAAe,QAAO,mBAAmC,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/DocumentInfo/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAgF,MAAM,OAAO,CAAA;AAEpG,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAexE,mBAAmB,YAAY,CAAA;AAE/B,eAAO,MAAM,eAAe,QAAO,mBAAmC,CAAA;AAqYtE,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CACzC;IACE,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CACnC,GAAG,iBAAiB,CAOtB,CAAA"}
|
|
@@ -100,10 +100,6 @@ const DocumentInfo = ({
|
|
|
100
100
|
localeIsLoading
|
|
101
101
|
} = useLocaleLoading();
|
|
102
102
|
const isInitializing = useMemo(() => initialState === undefined || initialData === undefined || localeIsLoading, [initialData, initialState, localeIsLoading]);
|
|
103
|
-
const baseAPIPath = formatAdminURL({
|
|
104
|
-
apiRoute: api,
|
|
105
|
-
path: ''
|
|
106
|
-
});
|
|
107
103
|
let slug;
|
|
108
104
|
let pluralType;
|
|
109
105
|
let preferencesKey;
|
|
@@ -126,7 +122,10 @@ const DocumentInfo = ({
|
|
|
126
122
|
}
|
|
127
123
|
try {
|
|
128
124
|
const isGlobal = slug_0 === globalSlug;
|
|
129
|
-
const request = await requests.get(
|
|
125
|
+
const request = await requests.get(formatAdminURL({
|
|
126
|
+
apiRoute: api,
|
|
127
|
+
path: '/payload-locked-documents'
|
|
128
|
+
}), {
|
|
130
129
|
credentials: 'include',
|
|
131
130
|
params: isGlobal ? {
|
|
132
131
|
'where[globalSlug][equals]': slug_0
|
|
@@ -140,7 +139,10 @@ const DocumentInfo = ({
|
|
|
140
139
|
} = await request.json();
|
|
141
140
|
if (docs?.length > 0) {
|
|
142
141
|
const lockID = docs[0].id;
|
|
143
|
-
await requests.delete(
|
|
142
|
+
await requests.delete(formatAdminURL({
|
|
143
|
+
apiRoute: api,
|
|
144
|
+
path: `/payload-locked-documents/${lockID}`
|
|
145
|
+
}), {
|
|
144
146
|
credentials: 'include',
|
|
145
147
|
headers: {
|
|
146
148
|
'Content-Type': 'application/json'
|
|
@@ -152,7 +154,7 @@ const DocumentInfo = ({
|
|
|
152
154
|
// eslint-disable-next-line no-console
|
|
153
155
|
console.error('Failed to unlock the document', error);
|
|
154
156
|
}
|
|
155
|
-
}, [
|
|
157
|
+
}, [api, globalSlug, setDocumentIsLocked, hasLockedDocumentsCollection]);
|
|
156
158
|
const updateDocumentEditor = useCallback(async (docID_0, slug_1, user) => {
|
|
157
159
|
// Check if the locked-documents collection exists before making API calls
|
|
158
160
|
if (!hasLockedDocumentsCollection) {
|
|
@@ -161,7 +163,10 @@ const DocumentInfo = ({
|
|
|
161
163
|
try {
|
|
162
164
|
const isGlobal_0 = slug_1 === globalSlug;
|
|
163
165
|
// Check if the document is already locked
|
|
164
|
-
const request_0 = await requests.get(
|
|
166
|
+
const request_0 = await requests.get(formatAdminURL({
|
|
167
|
+
apiRoute: api,
|
|
168
|
+
path: '/payload-locked-documents'
|
|
169
|
+
}), {
|
|
165
170
|
credentials: 'include',
|
|
166
171
|
params: isGlobal_0 ? {
|
|
167
172
|
'where[globalSlug][equals]': slug_1
|
|
@@ -183,7 +188,10 @@ const DocumentInfo = ({
|
|
|
183
188
|
value: user
|
|
184
189
|
};
|
|
185
190
|
// Send a patch request to update the _lastEdited info
|
|
186
|
-
await requests.patch(
|
|
191
|
+
await requests.patch(formatAdminURL({
|
|
192
|
+
apiRoute: api,
|
|
193
|
+
path: `/payload-locked-documents/${lockID_0}`
|
|
194
|
+
}), {
|
|
187
195
|
body: JSON.stringify({
|
|
188
196
|
user: userData
|
|
189
197
|
}),
|
|
@@ -197,7 +205,7 @@ const DocumentInfo = ({
|
|
|
197
205
|
// eslint-disable-next-line no-console
|
|
198
206
|
console.error('Failed to update the document editor', error_0);
|
|
199
207
|
}
|
|
200
|
-
}, [
|
|
208
|
+
}, [api, globalSlug, hasLockedDocumentsCollection]);
|
|
201
209
|
const getDocPermissions = useGetDocPermissions({
|
|
202
210
|
id: id,
|
|
203
211
|
api,
|
|
@@ -263,15 +271,18 @@ const DocumentInfo = ({
|
|
|
263
271
|
}, []);
|
|
264
272
|
const action = React.useMemo(() => {
|
|
265
273
|
const docPath = `${pluralType === 'globals' ? `/globals` : ''}/${slug}${id ? `/${id}` : ''}`;
|
|
266
|
-
return
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
274
|
+
return formatAdminURL({
|
|
275
|
+
apiRoute: api,
|
|
276
|
+
path: `${docPath}${qs.stringify({
|
|
277
|
+
depth: 0,
|
|
278
|
+
'fallback-locale': 'null',
|
|
279
|
+
locale,
|
|
280
|
+
uploadEdits: uploadEdits || undefined
|
|
281
|
+
}, {
|
|
282
|
+
addQueryPrefix: true
|
|
283
|
+
})}`
|
|
284
|
+
});
|
|
285
|
+
}, [api, locale, pluralType, id, slug, uploadEdits]);
|
|
275
286
|
const value = {
|
|
276
287
|
...props,
|
|
277
288
|
action,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["formatAdminURL","qs","React","createContext","use","useCallback","useEffect","useMemo","useRef","useState","useControllableState","useAuth","requests","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","hasScheduledPublish","hasScheduledPublishFromProps","initialData","initialState","isLocked","isLockedFromProps","lastUpdateTime","lastUpdateTimeFromProps","mostRecentVersionIsAutosaved","mostRecentVersionIsAutosavedFromProps","unpublishedVersionCount","unpublishedVersionCountFromProps","versionCount","versionCountFromProps","setDocPermissions","setHasSavePermission","setHasPublishPermission","permissions","config","admin","dateFormat","collections","routes","api","getEntityConfig","collectionConfig","globalConfig","hasLockedDocumentsCollection","some","collection","slug","abortControllerRef","AbortController","docConfig","i18n","uploadEdits","setMostRecentVersionIsAutosaved","setVersionCount","setHasPublishedDoc","setUnpublishedVersionCount","setHasScheduledPublish","Boolean","documentIsLocked","setDocumentIsLocked","setCurrentEditor","setLastUpdateTime","data","setData","uploadStatus","setUploadStatus","documentLockState","hasShownLockedModal","user","updateUploadStatus","status","getPreference","setPreference","currentLocale","locale","code","localeIsLoading","isInitializing","undefined","baseAPIPath","apiRoute","path","pluralType","preferencesKey","unlockDocument","docID","isGlobal","request","get","credentials","params","docs","json","length","lockID","delete","headers","error","console","updateDocumentEditor","userData","relationTo","value","patch","body","JSON","stringify","getDocPermissions","getDocPreferences","setDocFieldPreferences","fieldPreferences","allPreferences","fields","e","incrementVersionCount","newCount","versions","maxPerDoc","Math","min","max","re1","current","abort","_err","action","docPath","depth","addQueryPrefix","savedDocumentData","updateSavedDocumentData","_jsx","DocumentInfoProvider"],"sources":["../../../src/providers/DocumentInfo/index.tsx"],"sourcesContent":["'use client'\nimport type { DocumentPreferences, User } from 'payload'\n\nimport { formatAdminURL } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport React, { createContext, use, useCallback, useEffect, useMemo, useRef, useState } from 'react'\n\nimport type { DocumentInfoContext, DocumentInfoProps } from './types.js'\n\nimport { useControllableState } from '../../hooks/useControllableState.js'\nimport { useAuth } from '../../providers/Auth/index.js'\nimport { requests } from '../../utilities/api.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 { 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 hasScheduledPublish: hasScheduledPublishFromProps,\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 collections,\n routes: { api },\n },\n getEntityConfig,\n } = useConfig()\n\n const collectionConfig = getEntityConfig({ collectionSlug })\n const globalConfig = getEntityConfig({ globalSlug })\n\n // Check if the locked-documents collection exists in the config\n const hasLockedDocumentsCollection = collections.some(\n (collection) => collection.slug === 'payload-locked-documents',\n )\n\n const abortControllerRef = useRef(new AbortController())\n const docConfig = collectionConfig || globalConfig\n\n const { i18n } = useTranslation()\n\n const { uploadEdits } = useUploadEdits()\n\n const [mostRecentVersionIsAutosaved, setMostRecentVersionIsAutosaved] = useState(\n mostRecentVersionIsAutosavedFromProps,\n )\n\n const [versionCount, setVersionCount] = useState(versionCountFromProps)\n\n const [hasPublishedDoc, setHasPublishedDoc] = useState(hasPublishedDocFromProps)\n\n const [unpublishedVersionCount, setUnpublishedVersionCount] = useState(\n unpublishedVersionCountFromProps,\n )\n\n const [hasScheduledPublish, setHasScheduledPublish] = useState(\n Boolean(hasScheduledPublishFromProps),\n )\n\n const [documentIsLocked, setDocumentIsLocked] = useControllableState<boolean | undefined>(\n isLockedFromProps,\n )\n\n const [currentEditor, setCurrentEditor] = useControllableState<null | User>(\n currentEditorFromProps,\n )\n const [lastUpdateTime, setLastUpdateTime] = useControllableState<number>(lastUpdateTimeFromProps)\n\n const [data, setData] = useControllableState(initialData)\n\n const [uploadStatus, setUploadStatus] = useControllableState<'failed' | 'idle' | 'uploading'>(\n 'idle',\n )\n\n const documentLockState = useRef<{\n hasShownLockedModal: boolean\n isLocked: boolean\n user: number | string | User\n } | null>({\n hasShownLockedModal: false,\n isLocked: false,\n user: null,\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 currentLocale = useLocale()\n const locale = currentLocale?.code\n const { localeIsLoading } = useLocaleLoading()\n\n const isInitializing = useMemo(\n () => initialState === undefined || initialData === undefined || localeIsLoading,\n [initialData, initialState, localeIsLoading],\n )\n\n const baseAPIPath = formatAdminURL({\n apiRoute: api,\n path: '',\n })\n\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 // Check if the locked-documents collection exists before making API calls\n if (!hasLockedDocumentsCollection) {\n return\n }\n\n try {\n const isGlobal = slug === globalSlug\n\n const request = await requests.get(`${baseAPIPath}/payload-locked-documents`, {\n credentials: 'include',\n params: isGlobal\n ? {\n 'where[globalSlug][equals]': slug,\n }\n : {\n 'where[document.relationTo][equals]': slug,\n 'where[document.value][equals]': docID,\n },\n })\n\n const { docs } = await request.json()\n\n if (docs?.length > 0) {\n const lockID = docs[0].id\n await requests.delete(`${baseAPIPath}/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 [baseAPIPath, globalSlug, setDocumentIsLocked, hasLockedDocumentsCollection],\n )\n\n const updateDocumentEditor = useCallback(\n async (docID: number | string, slug: string, user: number | string | User) => {\n // Check if the locked-documents collection exists before making API calls\n if (!hasLockedDocumentsCollection) {\n return\n }\n\n try {\n const isGlobal = slug === globalSlug\n\n // Check if the document is already locked\n const request = await requests.get(`${baseAPIPath}/payload-locked-documents`, {\n credentials: 'include',\n params: isGlobal\n ? {\n 'where[globalSlug][equals]': slug,\n }\n : {\n 'where[document.relationTo][equals]': slug,\n 'where[document.value][equals]': docID,\n },\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(`${baseAPIPath}/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 [baseAPIPath, globalSlug, hasLockedDocumentsCollection],\n )\n\n const getDocPermissions = useGetDocPermissions({\n id: id as string,\n api,\n collectionSlug,\n globalSlug,\n i18n,\n locale,\n permissions,\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 // 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 docPath = `${pluralType === 'globals' ? `/globals` : ''}/${slug}${id ? `/${id}` : ''}`\n\n return `${baseAPIPath}${docPath}${qs.stringify(\n {\n depth: 0,\n 'fallback-locale': 'null',\n locale,\n uploadEdits: uploadEdits || undefined,\n },\n {\n addQueryPrefix: true,\n },\n )}`\n }, [baseAPIPath, locale, pluralType, id, slug, uploadEdits])\n\n const value: DocumentInfoContext = {\n ...props,\n action,\n currentEditor,\n data,\n docConfig,\n docPermissions,\n documentIsLocked,\n documentLockState,\n getDocPermissions,\n getDocPreferences,\n hasPublishedDoc,\n hasPublishPermission,\n hasSavePermission,\n hasScheduledPublish,\n incrementVersionCount,\n initialData,\n initialState,\n isInitializing,\n lastUpdateTime,\n mostRecentVersionIsAutosaved,\n preferencesKey,\n savedDocumentData: data,\n setCurrentEditor,\n setData,\n setDocFieldPreferences,\n setDocumentIsLocked,\n setHasPublishedDoc,\n setHasScheduledPublish,\n setLastUpdateTime,\n setMostRecentVersionIsAutosaved,\n setUnpublishedVersionCount,\n setUploadStatus: updateUploadStatus,\n unlockDocument,\n unpublishedVersionCount,\n updateDocumentEditor,\n updateSavedDocumentData: setData,\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,SAASA,cAAc,QAAQ;AAC/B,YAAYC,EAAA,MAAQ;AACpB,OAAOC,KAAA,IAASC,aAAa,EAAEC,GAAG,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAI7F,SAASC,oBAAoB,QAAQ;AACrC,SAASC,OAAO,QAAQ;AACxB,SAASC,QAAQ,QAAQ;AACzB,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;AACpD,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,sBAAs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AMmD,KAAA,GAA6B;IACjC,GAAGpG,KAAK;IACR2H,MAAA;IACAxH,aAAA;IACAyD,IAAA;IACAb,SAAA;IACA1C,cAAA;IACAmD,gBAAA;IACAQ,iBAAA;IACAyC,iBAAA;IACAC,iBAAA;IACAlG,eAAA;IACAE,oBAAA;IACAE,iBAAA;IACAE,mBAAA;IACAkG,qBAAA;IACAhG,WAAA;IACAC,YAAA;IACA0D,cAAA;IACAvD,cAAA;IACAE,4BAAA;IACA2D,cAAA;IACA8C,iBAAA,EAAmBnE,IAAA;IACnBF,gBAAA;IACAG,OAAA;IACA8C,sBAAA;IACAlD,mBAAA;IACAL,kBAAA;IACAE,sBAAA;IACAK,iBAAA;IACAT,+BAAA;IACAG,0BAAA;IACAU,eAAA,EAAiBI,kBAAA;IACjBe,cAAA;IACA1D,uBAAA;IACAyE,oBAAA;IACA+B,uBAAA,EAAyBnE,OAAA;IACzBC,YAAA;IACApC;EACF;EAEA,oBACEuG,IAAA,CAACrI,OAAA;IAAQwG,KAAA,EAAOA,KAAA;cACd,aAAA6B,IAAA,CAAC7I,qBAAA;gBAAuBW;;;AAG9B;AAEA,OAAO,MAAMmI,oBAAA,GAIRlI,KAAA;EACH,oBACEiI,IAAA,CAACxI,mBAAA;cACC,aAAAwI,IAAA,CAACnI,YAAA;MAAc,GAAGE;;;AAGxB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["formatAdminURL","qs","React","createContext","use","useCallback","useEffect","useMemo","useRef","useState","useControllableState","useAuth","requests","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","hasScheduledPublish","hasScheduledPublishFromProps","initialData","initialState","isLocked","isLockedFromProps","lastUpdateTime","lastUpdateTimeFromProps","mostRecentVersionIsAutosaved","mostRecentVersionIsAutosavedFromProps","unpublishedVersionCount","unpublishedVersionCountFromProps","versionCount","versionCountFromProps","setDocPermissions","setHasSavePermission","setHasPublishPermission","permissions","config","admin","dateFormat","collections","routes","api","getEntityConfig","collectionConfig","globalConfig","hasLockedDocumentsCollection","some","collection","slug","abortControllerRef","AbortController","docConfig","i18n","uploadEdits","setMostRecentVersionIsAutosaved","setVersionCount","setHasPublishedDoc","setUnpublishedVersionCount","setHasScheduledPublish","Boolean","documentIsLocked","setDocumentIsLocked","setCurrentEditor","setLastUpdateTime","data","setData","uploadStatus","setUploadStatus","documentLockState","hasShownLockedModal","user","updateUploadStatus","status","getPreference","setPreference","currentLocale","locale","code","localeIsLoading","isInitializing","undefined","pluralType","preferencesKey","unlockDocument","docID","isGlobal","request","get","apiRoute","path","credentials","params","docs","json","length","lockID","delete","headers","error","console","updateDocumentEditor","userData","relationTo","value","patch","body","JSON","stringify","getDocPermissions","getDocPreferences","setDocFieldPreferences","fieldPreferences","allPreferences","fields","e","incrementVersionCount","newCount","versions","maxPerDoc","Math","min","max","re1","current","abort","_err","action","docPath","depth","addQueryPrefix","savedDocumentData","updateSavedDocumentData","_jsx","DocumentInfoProvider"],"sources":["../../../src/providers/DocumentInfo/index.tsx"],"sourcesContent":["'use client'\nimport type { DocumentPreferences, User } from 'payload'\n\nimport { formatAdminURL } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport React, { createContext, use, useCallback, useEffect, useMemo, useRef, useState } from 'react'\n\nimport type { DocumentInfoContext, DocumentInfoProps } from './types.js'\n\nimport { useControllableState } from '../../hooks/useControllableState.js'\nimport { useAuth } from '../../providers/Auth/index.js'\nimport { requests } from '../../utilities/api.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 { 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 hasScheduledPublish: hasScheduledPublishFromProps,\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 collections,\n routes: { api },\n },\n getEntityConfig,\n } = useConfig()\n\n const collectionConfig = getEntityConfig({ collectionSlug })\n const globalConfig = getEntityConfig({ globalSlug })\n\n // Check if the locked-documents collection exists in the config\n const hasLockedDocumentsCollection = collections.some(\n (collection) => collection.slug === 'payload-locked-documents',\n )\n\n const abortControllerRef = useRef(new AbortController())\n const docConfig = collectionConfig || globalConfig\n\n const { i18n } = useTranslation()\n\n const { uploadEdits } = useUploadEdits()\n\n const [mostRecentVersionIsAutosaved, setMostRecentVersionIsAutosaved] = useState(\n mostRecentVersionIsAutosavedFromProps,\n )\n\n const [versionCount, setVersionCount] = useState(versionCountFromProps)\n\n const [hasPublishedDoc, setHasPublishedDoc] = useState(hasPublishedDocFromProps)\n\n const [unpublishedVersionCount, setUnpublishedVersionCount] = useState(\n unpublishedVersionCountFromProps,\n )\n\n const [hasScheduledPublish, setHasScheduledPublish] = useState(\n Boolean(hasScheduledPublishFromProps),\n )\n\n const [documentIsLocked, setDocumentIsLocked] = useControllableState<boolean | undefined>(\n isLockedFromProps,\n )\n\n const [currentEditor, setCurrentEditor] = useControllableState<null | User>(\n currentEditorFromProps,\n )\n const [lastUpdateTime, setLastUpdateTime] = useControllableState<number>(lastUpdateTimeFromProps)\n\n const [data, setData] = useControllableState(initialData)\n\n const [uploadStatus, setUploadStatus] = useControllableState<'failed' | 'idle' | 'uploading'>(\n 'idle',\n )\n\n const documentLockState = useRef<{\n hasShownLockedModal: boolean\n isLocked: boolean\n user: number | string | User\n } | null>({\n hasShownLockedModal: false,\n isLocked: false,\n user: null,\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 currentLocale = useLocale()\n const locale = currentLocale?.code\n const { localeIsLoading } = useLocaleLoading()\n\n const isInitializing = useMemo(\n () => initialState === undefined || initialData === undefined || localeIsLoading,\n [initialData, initialState, localeIsLoading],\n )\n\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 // Check if the locked-documents collection exists before making API calls\n if (!hasLockedDocumentsCollection) {\n return\n }\n\n try {\n const isGlobal = slug === globalSlug\n\n const request = await requests.get(\n formatAdminURL({ apiRoute: api, path: '/payload-locked-documents' }),\n {\n credentials: 'include',\n params: isGlobal\n ? {\n 'where[globalSlug][equals]': slug,\n }\n : {\n 'where[document.relationTo][equals]': slug,\n 'where[document.value][equals]': docID,\n },\n },\n )\n\n const { docs } = await request.json()\n\n if (docs?.length > 0) {\n const lockID = docs[0].id\n await requests.delete(\n formatAdminURL({\n apiRoute: api,\n path: `/payload-locked-documents/${lockID}`,\n }),\n {\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\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 [api, globalSlug, setDocumentIsLocked, hasLockedDocumentsCollection],\n )\n\n const updateDocumentEditor = useCallback(\n async (docID: number | string, slug: string, user: number | string | User) => {\n // Check if the locked-documents collection exists before making API calls\n if (!hasLockedDocumentsCollection) {\n return\n }\n\n try {\n const isGlobal = slug === globalSlug\n\n // Check if the document is already locked\n const request = await requests.get(\n formatAdminURL({ apiRoute: api, path: '/payload-locked-documents' }),\n {\n credentials: 'include',\n params: isGlobal\n ? {\n 'where[globalSlug][equals]': slug,\n }\n : {\n 'where[document.relationTo][equals]': slug,\n 'where[document.value][equals]': docID,\n },\n },\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(\n formatAdminURL({\n apiRoute: api,\n path: `/payload-locked-documents/${lockID}`,\n }),\n {\n body: JSON.stringify({\n user: userData,\n }),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\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 [api, globalSlug, hasLockedDocumentsCollection],\n )\n\n const getDocPermissions = useGetDocPermissions({\n id: id as string,\n api,\n collectionSlug,\n globalSlug,\n i18n,\n locale,\n permissions,\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 // 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 docPath = `${pluralType === 'globals' ? `/globals` : ''}/${slug}${id ? `/${id}` : ''}`\n\n return formatAdminURL({\n apiRoute: api,\n path: `${docPath}${qs.stringify(\n {\n depth: 0,\n 'fallback-locale': 'null',\n locale,\n uploadEdits: uploadEdits || undefined,\n },\n {\n addQueryPrefix: true,\n },\n )}` as `/${string}`,\n })\n }, [api, locale, pluralType, id, slug, uploadEdits])\n\n const value: DocumentInfoContext = {\n ...props,\n action,\n currentEditor,\n data,\n docConfig,\n docPermissions,\n documentIsLocked,\n documentLockState,\n getDocPermissions,\n getDocPreferences,\n hasPublishedDoc,\n hasPublishPermission,\n hasSavePermission,\n hasScheduledPublish,\n incrementVersionCount,\n initialData,\n initialState,\n isInitializing,\n lastUpdateTime,\n mostRecentVersionIsAutosaved,\n preferencesKey,\n savedDocumentData: data,\n setCurrentEditor,\n setData,\n setDocFieldPreferences,\n setDocumentIsLocked,\n setHasPublishedDoc,\n setHasScheduledPublish,\n setLastUpdateTime,\n setMostRecentVersionIsAutosaved,\n setUnpublishedVersionCount,\n setUploadStatus: updateUploadStatus,\n unlockDocument,\n unpublishedVersionCount,\n updateDocumentEditor,\n updateSavedDocumentData: setData,\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,SAASA,cAAc,QAAQ;AAC/B,YAAYC,EAAA,MAAQ;AACpB,OAAOC,KAAA,IAASC,aAAa,EAAEC,GAAG,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAI7F,SAASC,oBAAoB,QAAQ;AACrC,SAASC,OAAO,QAAQ;AACxB,SAASC,QAAQ,QAAQ;AACzB,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;AACpD,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,QA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AAA,EAAO;QACP,mBAAmB;QACnBpD,MAAA;QACAvB,WAAA,EAAaA,WAAA,IAAe2B;MAC9B,GACA;QACEiD,cAAA,EAAgB;MAClB;IAEJ;EACF,GAAG,CAACxF,GAAA,EAAKmC,MAAA,EAAQK,UAAA,EAAY5E,EAAA,EAAI2C,IAAA,EAAMK,WAAA,CAAY;EAEnD,MAAMkD,KAAA,GAA6B;IACjC,GAAGnG,KAAK;IACR0H,MAAA;IACAvH,aAAA;IACAyD,IAAA;IACAb,SAAA;IACA1C,cAAA;IACAmD,gBAAA;IACAQ,iBAAA;IACAwC,iBAAA;IACAC,iBAAA;IACAjG,eAAA;IACAE,oBAAA;IACAE,iBAAA;IACAE,mBAAA;IACAiG,qBAAA;IACA/F,WAAA;IACAC,YAAA;IACA0D,cAAA;IACAvD,cAAA;IACAE,4BAAA;IACAwD,cAAA;IACAgD,iBAAA,EAAmBlE,IAAA;IACnBF,gBAAA;IACAG,OAAA;IACA6C,sBAAA;IACAjD,mBAAA;IACAL,kBAAA;IACAE,sBAAA;IACAK,iBAAA;IACAT,+BAAA;IACAG,0BAAA;IACAU,eAAA,EAAiBI,kBAAA;IACjBY,cAAA;IACAvD,uBAAA;IACAwE,oBAAA;IACA+B,uBAAA,EAAyBlE,OAAA;IACzBC,YAAA;IACApC;EACF;EAEA,oBACEsG,IAAA,CAACpI,OAAA;IAAQuG,KAAA,EAAOA,KAAA;cACd,aAAA6B,IAAA,CAAC5I,qBAAA;gBAAuBW;;;AAG9B;AAEA,OAAO,MAAMkI,oBAAA,GAIRjI,KAAA;EACH,oBACEgI,IAAA,CAACvI,mBAAA;cACC,aAAAuI,IAAA,CAAClI,YAAA;MAAc,GAAGE;;;AAGxB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/Locale/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAGrC,OAAO,KAA0D,MAAM,OAAO,CAAA;AAU9E,eAAO,MAAM,oBAAoB;;4BAEP,OAAO;EAC/B,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/Locale/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAGrC,OAAO,KAA0D,MAAM,OAAO,CAAA;AAU9E,eAAO,MAAM,oBAAoB;;4BAEP,OAAO;EAC/B,CAAA;AAoBF,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;CAAE,CAiF5F,CAAA;AAED,eAAO,MAAM,gBAAgB;;4BAxGH,OAAO;CAwG8B,CAAA;AAE/D,eAAO,MAAM,SAAS,QAAO,MAAM,GAAG,IAA0B,CAAA"}
|
|
@@ -13,7 +13,10 @@ export const LocaleLoadingContext = /*#__PURE__*/createContext({
|
|
|
13
13
|
localeIsLoading: false,
|
|
14
14
|
setLocaleIsLoading: _ => undefined
|
|
15
15
|
});
|
|
16
|
-
const fetchPreferences = async (key,
|
|
16
|
+
const fetchPreferences = async (key, apiRoute) => await fetch(formatAdminURL({
|
|
17
|
+
apiRoute,
|
|
18
|
+
path: `/payload-preferences/${key}`
|
|
19
|
+
}), {
|
|
17
20
|
credentials: 'include',
|
|
18
21
|
headers: {
|
|
19
22
|
'Content-Type': 'application/json'
|
|
@@ -60,10 +63,6 @@ export const LocaleProvider = ({
|
|
|
60
63
|
prevLocale.current = locale;
|
|
61
64
|
}
|
|
62
65
|
}, [isTransitioning, locale]);
|
|
63
|
-
const fetchURL = formatAdminURL({
|
|
64
|
-
apiRoute,
|
|
65
|
-
path: ''
|
|
66
|
-
});
|
|
67
66
|
useEffect(() => {
|
|
68
67
|
/**
|
|
69
68
|
* This effect should only run when `localeFromParams` changes, i.e. when the user clicks an anchor link
|
|
@@ -72,7 +71,7 @@ export const LocaleProvider = ({
|
|
|
72
71
|
*/
|
|
73
72
|
async function resetLocale() {
|
|
74
73
|
if (localization && user?.id) {
|
|
75
|
-
const localeToUse = localeFromParams || (await fetchPreferences('locale',
|
|
74
|
+
const localeToUse = localeFromParams || (await fetchPreferences('locale', apiRoute)?.then(res => res.value));
|
|
76
75
|
const newLocale = findLocaleFromCode(localization, localeToUse) || findLocaleFromCode(localization, defaultLocale) || findLocaleFromCode(localization, localization?.locales?.[0]?.code);
|
|
77
76
|
if (newLocale) {
|
|
78
77
|
setLocale(newLocale);
|
|
@@ -80,7 +79,7 @@ export const LocaleProvider = ({
|
|
|
80
79
|
}
|
|
81
80
|
}
|
|
82
81
|
void resetLocale();
|
|
83
|
-
}, [defaultLocale, localization,
|
|
82
|
+
}, [apiRoute, defaultLocale, localization, localeFromParams, user?.id]);
|
|
84
83
|
return /*#__PURE__*/_jsx(LocaleContext, {
|
|
85
84
|
value: locale,
|
|
86
85
|
children: /*#__PURE__*/_jsx(LocaleLoadingContext, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["formatAdminURL","React","createContext","use","useEffect","useRef","useState","findLocaleFromCode","useAuth","useConfig","useSearchParams","useRouteTransition","LocaleContext","LocaleLoadingContext","localeIsLoading","setLocaleIsLoading","_","undefined","fetchPreferences","key","
|
|
1
|
+
{"version":3,"file":"index.js","names":["formatAdminURL","React","createContext","use","useEffect","useRef","useState","findLocaleFromCode","useAuth","useConfig","useSearchParams","useRouteTransition","LocaleContext","LocaleLoadingContext","localeIsLoading","setLocaleIsLoading","_","undefined","fetchPreferences","key","apiRoute","fetch","path","credentials","headers","method","then","res","json","LocaleProvider","children","locale","initialLocaleFromPrefs","config","localization","routes","api","user","isTransitioning","defaultLocale","localeFromParams","get","setLocale","locales","length","code","isLoading","prevLocale","current","resetLocale","id","localeToUse","value","newLocale","_jsx","useLocaleLoading","useLocale"],"sources":["../../../src/providers/Locale/index.tsx"],"sourcesContent":["'use client'\n\nimport type { Locale } from 'payload'\n\nimport { formatAdminURL } from 'payload/shared'\nimport React, { createContext, use, useEffect, useRef, useState } from 'react'\n\nimport { findLocaleFromCode } from '../../utilities/findLocaleFromCode.js'\nimport { useAuth } from '../Auth/index.js'\nimport { useConfig } from '../Config/index.js'\nimport { useSearchParams } from '../RouterAdapter/index.js'\nimport { useRouteTransition } from '../RouteTransition/index.js'\n\nconst LocaleContext = createContext<Locale | null>(null)\n\nexport const LocaleLoadingContext = createContext({\n localeIsLoading: false,\n setLocaleIsLoading: (_: boolean) => undefined,\n})\n\nconst fetchPreferences = async <T extends Record<string, unknown> | string>(\n key: string,\n apiRoute: string,\n): Promise<{ id: string; value: T }> =>\n await fetch(\n formatAdminURL({\n apiRoute,\n path: `/payload-preferences/${key}`,\n }),\n {\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'GET',\n },\n )?.then((res) => res.json() as Promise<{ id: string; value: T }>)\n\nexport const LocaleProvider: React.FC<{ children?: React.ReactNode; locale?: Locale['code'] }> = ({\n children,\n /**\n The `locale` prop originates from the root layout, which does not have access to search params\n This component uses the `useSearchParams` hook to get the locale from the URL as precedence over this prop\n This prop does not update as the user navigates the site, because the root layout does not re-render\n */\n locale: initialLocaleFromPrefs,\n}) => {\n const {\n config: {\n localization = false,\n routes: { api: apiRoute },\n },\n } = useConfig()\n\n const { user } = useAuth()\n const { isTransitioning } = useRouteTransition()\n\n const defaultLocale = localization ? localization.defaultLocale : 'en'\n\n const localeFromParams = useSearchParams().get('locale')\n\n const [locale, setLocale] = React.useState<Locale | null>(() => {\n if (!localization || (localization && !localization.locales.length)) {\n return null\n }\n\n return (\n findLocaleFromCode(localization, localeFromParams) ||\n findLocaleFromCode(localization, initialLocaleFromPrefs) ||\n findLocaleFromCode(localization, defaultLocale) ||\n findLocaleFromCode(localization, localization.locales[0].code)\n )\n })\n\n const [isLoading, setLocaleIsLoading] = useState(false)\n\n const prevLocale = useRef<Locale | null>(locale)\n\n useEffect(() => {\n // Keep fields disabled until the new locale's document state finishes loading.\n if (locale?.code !== prevLocale.current?.code && !isTransitioning) {\n setLocaleIsLoading(false)\n prevLocale.current = locale\n }\n }, [isTransitioning, locale])\n\n useEffect(() => {\n /**\n * This effect should only run when `localeFromParams` changes, i.e. when the user clicks an anchor link\n * The root layout, which sends the initial locale from prefs, will not re-render as the user navigates the site\n * For this reason, we need to fetch the locale from prefs if the search params clears the `locale` query param\n */\n async function resetLocale() {\n if (localization && user?.id) {\n const localeToUse =\n localeFromParams ||\n (await fetchPreferences<Locale['code']>('locale', apiRoute)?.then((res) => res.value))\n\n const newLocale =\n findLocaleFromCode(localization, localeToUse) ||\n findLocaleFromCode(localization, defaultLocale) ||\n findLocaleFromCode(localization, localization?.locales?.[0]?.code)\n\n if (newLocale) {\n setLocale(newLocale)\n }\n }\n }\n\n void resetLocale()\n }, [apiRoute, defaultLocale, localization, localeFromParams, user?.id])\n\n return (\n <LocaleContext value={locale}>\n <LocaleLoadingContext value={{ localeIsLoading: isLoading, setLocaleIsLoading }}>\n {children}\n </LocaleLoadingContext>\n </LocaleContext>\n )\n}\n\nexport const useLocaleLoading = () => use(LocaleLoadingContext)\n\nexport const useLocale = (): Locale | null => use(LocaleContext)\n"],"mappings":"AAAA;;;AAIA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,KAAA,IAASC,aAAa,EAAEC,GAAG,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAEvE,SAASC,kBAAkB,QAAQ;AACnC,SAASC,OAAO,QAAQ;AACxB,SAASC,SAAS,QAAQ;AAC1B,SAASC,eAAe,QAAQ;AAChC,SAASC,kBAAkB,QAAQ;AAEnC,MAAMC,aAAA,gBAAgBV,aAAA,CAA6B;AAEnD,OAAO,MAAMW,oBAAA,gBAAuBX,aAAA,CAAc;EAChDY,eAAA,EAAiB;EACjBC,kBAAA,EAAqBC,CAAA,IAAeC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