@payloadcms/ui 4.0.0-beta.1 → 4.0.0-beta.3
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/preflight.css +21 -2
- package/dist/elements/BulkUpload/FormsManager/index.d.ts.map +1 -1
- package/dist/elements/BulkUpload/FormsManager/index.js +1 -34
- package/dist/elements/BulkUpload/FormsManager/index.js.map +1 -1
- package/dist/elements/CloseModalOnRouteChange/index.d.ts.map +1 -1
- package/dist/elements/CloseModalOnRouteChange/index.js +27 -19
- package/dist/elements/CloseModalOnRouteChange/index.js.map +1 -1
- package/dist/elements/DatePicker/DatePicker.js +6 -2
- package/dist/elements/DatePicker/DatePicker.js.map +1 -1
- package/dist/elements/DatePicker/index.css +35 -25
- package/dist/elements/DocumentControls/index.js.map +1 -1
- package/dist/elements/DocumentFields/index.css +2 -2
- package/dist/elements/DocumentHeader/Tabs/tabs/index.js.map +1 -1
- package/dist/elements/FieldSelect/reduceFieldOptions.js.map +1 -1
- package/dist/elements/ListDrawer/Provider.d.ts.map +1 -1
- package/dist/elements/ListDrawer/Provider.js.map +1 -1
- package/dist/elements/LivePreview/Window/index.css +7 -1
- package/dist/elements/Nav/SidebarTabs/index.client.js +1 -1
- package/dist/elements/Nav/SidebarTabs/index.client.js.map +1 -1
- package/dist/elements/PublishButton/index.js.map +1 -1
- package/dist/elements/SchedulePublishButton/index.js.map +1 -1
- package/dist/elements/SegmentedControl/index.css +50 -7
- package/dist/elements/Table/DefaultCell/fields/File/index.d.ts.map +1 -1
- package/dist/elements/Table/DefaultCell/fields/File/index.js.map +1 -1
- package/dist/elements/Table/DefaultCell/index.d.ts.map +1 -1
- package/dist/elements/Table/DefaultCell/index.js +6 -1
- package/dist/elements/Table/DefaultCell/index.js.map +1 -1
- package/dist/elements/Table/index.js.map +1 -1
- package/dist/exports/client/{CodeEditor-S7MOGZSR.js → CodeEditor-I6PL55BF.js} +2 -2
- package/dist/exports/client/{DatePicker-POZJVQP4.js → DatePicker-RFCB5VGD.js} +2 -2
- package/dist/exports/client/{chunk-2AY67NFV.js → chunk-O2RR6XEH.js} +2 -2
- package/dist/exports/client/chunk-O2RR6XEH.js.map +7 -0
- package/dist/exports/client/{chunk-Z42OBP5U.js → chunk-R7M6BG75.js} +1 -1
- package/dist/exports/client/{chunk-Z42OBP5U.js.map → chunk-R7M6BG75.js.map} +1 -1
- package/dist/exports/client/index.js +15 -15
- package/dist/exports/client/index.js.map +4 -4
- package/dist/exports/shared/index.js +2 -2
- package/dist/exports/shared/index.js.map +3 -3
- package/dist/fields/Upload/Input.d.ts.map +1 -1
- package/dist/fields/Upload/Input.js +3 -1
- package/dist/fields/Upload/Input.js.map +1 -1
- package/dist/forms/Form/reduceToSerializableFields.d.ts +9 -4
- package/dist/forms/Form/reduceToSerializableFields.d.ts.map +1 -1
- package/dist/forms/Form/reduceToSerializableFields.js +34 -7
- package/dist/forms/Form/reduceToSerializableFields.js.map +1 -1
- package/dist/icons/Table/index.css +5 -1
- package/dist/layouts/Root/index.d.ts +1 -1
- package/dist/layouts/Root/index.d.ts.map +1 -1
- package/dist/layouts/Root/index.js +4 -15
- package/dist/layouts/Root/index.js.map +1 -1
- package/dist/providers/RouteCache/index.d.ts.map +1 -1
- package/dist/providers/RouteCache/index.js +37 -25
- package/dist/providers/RouteCache/index.js.map +1 -1
- package/dist/providers/ServerFunctions/index.d.ts.map +1 -1
- package/dist/providers/ServerFunctions/index.js +34 -23
- package/dist/providers/ServerFunctions/index.js.map +1 -1
- package/dist/styles.css +22 -3
- package/dist/templates/Default/index.css +0 -1
- package/dist/utilities/buildClientFieldSchemaMap/traverseFields.d.ts.map +1 -1
- package/dist/utilities/buildClientFieldSchemaMap/traverseFields.js +32 -6
- package/dist/utilities/buildClientFieldSchemaMap/traverseFields.js.map +1 -1
- package/dist/utilities/getDisplayedFieldValue.d.ts +8 -2
- package/dist/utilities/getDisplayedFieldValue.d.ts.map +1 -1
- package/dist/utilities/getDisplayedFieldValue.js +11 -1
- package/dist/utilities/getDisplayedFieldValue.js.map +1 -1
- package/dist/utilities/getHasScheduledPublish.js.map +1 -1
- package/dist/utilities/handleLivePreview.js.map +1 -1
- package/dist/utilities/handleServerFunctions.d.ts +2 -10
- package/dist/utilities/handleServerFunctions.d.ts.map +1 -1
- package/dist/utilities/handleServerFunctions.js +3 -7
- package/dist/utilities/handleServerFunctions.js.map +1 -1
- package/dist/utilities/hasSavePermission.js.map +1 -1
- package/dist/utilities/schedulePublishHandler.js.map +1 -1
- package/dist/utilities/serverFunctionRegistry.d.ts +2 -7
- package/dist/utilities/serverFunctionRegistry.d.ts.map +1 -1
- package/dist/utilities/serverFunctionRegistry.js +2 -7
- package/dist/utilities/serverFunctionRegistry.js.map +1 -1
- package/dist/views/Edit/index.js.map +1 -1
- package/dist/widgets/RecentlyViewed/getDocuments.d.ts.map +1 -1
- package/dist/widgets/RecentlyViewed/getDocuments.js +4 -1
- package/dist/widgets/RecentlyViewed/getDocuments.js.map +1 -1
- package/dist/widgets/RecentlyViewed/index.client.d.ts.map +1 -1
- package/dist/widgets/RecentlyViewed/index.client.js +7 -2
- package/dist/widgets/RecentlyViewed/index.client.js.map +1 -1
- package/package.json +16 -16
- package/dist/exports/client/chunk-2AY67NFV.js.map +0 -7
- /package/dist/exports/client/{CodeEditor-S7MOGZSR.js.map → CodeEditor-I6PL55BF.js.map} +0 -0
- /package/dist/exports/client/{DatePicker-POZJVQP4.js.map → DatePicker-RFCB5VGD.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/ServerFunctions/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,kBAAkB,EAClB,mBAAmB,EACnB,IAAI,EACJ,mBAAmB,EACnB,aAAa,EACb,SAAS,EACT,MAAM,EACN,gCAAgC,EAChC,cAAc,EACd,oBAAoB,EACpB,yBAAyB,EAC1B,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAE7C,OAAO,KAAqC,MAAM,OAAO,CAAA;AAEzD,OAAO,KAAK,EACV,uBAAuB,EACvB,6BAA6B,EAC9B,MAAM,4EAA4E,CAAA;AACnF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAA;AAC9E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAA;AAChF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAA;AACnF,OAAO,KAAK,EACV,kCAAkC,EAClC,sCAAsC,EACtC,sBAAsB,EACtB,0BAA0B,EAC3B,MAAM,2CAA2C,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/ServerFunctions/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,kBAAkB,EAClB,mBAAmB,EACnB,IAAI,EACJ,mBAAmB,EACnB,aAAa,EACb,SAAS,EACT,MAAM,EACN,gCAAgC,EAChC,cAAc,EACd,oBAAoB,EACpB,yBAAyB,EAC1B,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAE7C,OAAO,KAAqC,MAAM,OAAO,CAAA;AAEzD,OAAO,KAAK,EACV,uBAAuB,EACvB,6BAA6B,EAC9B,MAAM,4EAA4E,CAAA;AACnF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAA;AAC9E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAA;AAChF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAA;AACnF,OAAO,KAAK,EACV,kCAAkC,EAClC,sCAAsC,EACtC,sBAAsB,EACtB,0BAA0B,EAC3B,MAAM,2CAA2C,CAAA;AAIlD,KAAK,kBAAkB,GAAG,CACxB,IAAI,E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M,0BAA0B,GAAG;IACvC,qBAAqB,EAAE,iBAAiB,CAAA;IACxC,kBAAkB,EAAE,wBAAwB,CAAA;IAC5C,gBAAgB,EAAE,gBAAgB,CAAA;IAClC,YAAY,EAAE,kBAAkB,CAAA;IAChC,aAAa,EAAE,mBAAmB,CAAA;IAClC,2BAA2B,EAAE,iCAAiC,CAAA;IAC9D,cAAc,EAAE,kCAAkC,CAAA;IAClD,eAAe,EAAE,qBAAqB,CAAA;IACtC,cAAc,EAAE,oBAAoB,CAAA;IACpC,OAAO,EAAE,aAAa,CAAA;IACtB,cAAc,EAAE,oBAAoB,CAAA;CACrC,CAAA;AAED,eAAO,MAAM,sBAAsB,2CAElC,CAAA;AAED,eAAO,MAAM,kBAAkB,kCAM9B,CAAA;AAED,eAAO,MAAM,uBAAuB,EAAE,KAAK,CAAC,EAAE,CAAC;IAC7C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,cAAc,EAAE,oBAAoB,CAAA;CACrC,CAoOA,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import React, { createContext, useCallback } from 'react';
|
|
3
|
+
import { reduceToSerializableFields } from '../../forms/Form/reduceToSerializableFields.js';
|
|
3
4
|
export const ServerFunctionsContext = /*#__PURE__*/createContext(undefined);
|
|
4
5
|
export const useServerFunctions = () => {
|
|
5
6
|
const context = React.use(ServerFunctionsContext);
|
|
@@ -15,7 +16,10 @@ export const ServerFunctionsProvider = ({
|
|
|
15
16
|
if (!serverFunction) {
|
|
16
17
|
throw new Error('ServerFunctionsProvider requires a serverFunction prop');
|
|
17
18
|
}
|
|
18
|
-
const getDocumentSlots = useCallback(async
|
|
19
|
+
const getDocumentSlots = useCallback(async ({
|
|
20
|
+
signal: _signal,
|
|
21
|
+
...args
|
|
22
|
+
}) => await serverFunction({
|
|
19
23
|
name: 'render-document-slots',
|
|
20
24
|
args
|
|
21
25
|
}), [serverFunction]);
|
|
@@ -29,7 +33,8 @@ export const ServerFunctionsProvider = ({
|
|
|
29
33
|
const result = await serverFunction({
|
|
30
34
|
name: 'schedule-publish',
|
|
31
35
|
args: {
|
|
32
|
-
...rest
|
|
36
|
+
...rest,
|
|
37
|
+
date: rest.date ? new Date(rest.date.getTime()) : rest.date
|
|
33
38
|
}
|
|
34
39
|
});
|
|
35
40
|
if (!remoteSignal?.aborted) {
|
|
@@ -65,18 +70,29 @@ export const ServerFunctionsProvider = ({
|
|
|
65
70
|
const {
|
|
66
71
|
signal: remoteSignal,
|
|
67
72
|
...rest
|
|
68
|
-
} = args
|
|
73
|
+
} = args;
|
|
69
74
|
try {
|
|
70
75
|
if (!remoteSignal?.aborted) {
|
|
71
76
|
const result = await serverFunction({
|
|
72
77
|
name: 'form-state',
|
|
73
78
|
args: {
|
|
74
|
-
|
|
75
|
-
|
|
79
|
+
...rest,
|
|
80
|
+
documentFormState: reduceToSerializableFields(rest.documentFormState),
|
|
81
|
+
formState: reduceToSerializableFields(rest.formState),
|
|
82
|
+
initialBlockFormState: reduceToSerializableFields(rest.initialBlockFormState)
|
|
76
83
|
}
|
|
77
84
|
});
|
|
78
85
|
// TODO: infer this type when `strictNullChecks` is enabled
|
|
79
86
|
if (!remoteSignal?.aborted) {
|
|
87
|
+
const file = rest.formState?.file;
|
|
88
|
+
if (typeof File !== 'undefined' && result.state?.file) {
|
|
89
|
+
if (file?.initialValue instanceof File) {
|
|
90
|
+
result.state.file.initialValue = file.initialValue;
|
|
91
|
+
}
|
|
92
|
+
if (file?.value instanceof File) {
|
|
93
|
+
result.state.file.value = file.value;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
80
96
|
return result;
|
|
81
97
|
}
|
|
82
98
|
}
|
|
@@ -91,15 +107,12 @@ export const ServerFunctionsProvider = ({
|
|
|
91
107
|
const {
|
|
92
108
|
signal: remoteSignal,
|
|
93
109
|
...rest
|
|
94
|
-
} = args
|
|
110
|
+
} = args;
|
|
95
111
|
try {
|
|
96
112
|
if (!remoteSignal?.aborted) {
|
|
97
113
|
const result = await serverFunction({
|
|
98
114
|
name: 'table-state',
|
|
99
|
-
args:
|
|
100
|
-
fallbackLocale: false,
|
|
101
|
-
...rest
|
|
102
|
-
}
|
|
115
|
+
args: rest
|
|
103
116
|
});
|
|
104
117
|
// TODO: infer this type when `strictNullChecks` is enabled
|
|
105
118
|
if (!remoteSignal?.aborted) {
|
|
@@ -111,17 +124,16 @@ export const ServerFunctionsProvider = ({
|
|
|
111
124
|
}
|
|
112
125
|
// return { state: args.formState }
|
|
113
126
|
}, [serverFunction]);
|
|
114
|
-
const renderDocument = useCallback(async
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
} = args || {};
|
|
127
|
+
const renderDocument = useCallback(async ({
|
|
128
|
+
signal: _signal,
|
|
129
|
+
...rest
|
|
130
|
+
}) => {
|
|
119
131
|
try {
|
|
120
132
|
const result = await serverFunction({
|
|
121
133
|
name: 'render-document',
|
|
122
134
|
args: {
|
|
123
|
-
|
|
124
|
-
|
|
135
|
+
...rest,
|
|
136
|
+
initialState: reduceToSerializableFields(rest.initialState)
|
|
125
137
|
}
|
|
126
138
|
});
|
|
127
139
|
// TODO: infer this type when `strictNullChecks` is enabled
|
|
@@ -134,7 +146,7 @@ export const ServerFunctionsProvider = ({
|
|
|
134
146
|
const {
|
|
135
147
|
signal: remoteSignal,
|
|
136
148
|
...rest
|
|
137
|
-
} = args
|
|
149
|
+
} = args;
|
|
138
150
|
const result = await serverFunction({
|
|
139
151
|
name: 'copy-data-from-locale',
|
|
140
152
|
args: rest
|
|
@@ -156,11 +168,10 @@ export const ServerFunctionsProvider = ({
|
|
|
156
168
|
console.error(_err); // eslint-disable-line no-console
|
|
157
169
|
}
|
|
158
170
|
}, [serverFunction]);
|
|
159
|
-
const slugify = useCallback(async
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
} = args || {};
|
|
171
|
+
const slugify = useCallback(async ({
|
|
172
|
+
signal: _signal,
|
|
173
|
+
...rest
|
|
174
|
+
}) => {
|
|
164
175
|
try {
|
|
165
176
|
const result = await serverFunction({
|
|
166
177
|
name: 'slugify',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","createContext","useCallback","ServerFunctionsContext","undefined","useServerFunctions","context","use","Error","ServerFunctionsProvider","children","serverFunction","getDocumentSlots","args","name","schedulePublish","signal","remoteSignal","rest","aborted","result","_err","console","error","type","doc","value","relationTo","getUpcomingScheduledPublish","getFormState","fallbackLocale","state","getTableState","renderDocument","copyDataFromLocale","data","_internal_renderField","slugify","switchLanguage","lang","_jsx"],"sources":["../../../src/providers/ServerFunctions/index.tsx"],"sourcesContent":["import type {\n AdminViewServerPropsOnly,\n BuildFormStateArgs,\n BuildTableStateArgs,\n Data,\n DocumentPreferences,\n DocumentSlots,\n FormState,\n Params,\n RenderDocumentVersionsProperties,\n ServerFunction,\n ServerFunctionClient,\n SlugifyServerFunctionArgs,\n} from 'payload'\nimport type { Slugify } from 'payload/shared'\n\nimport React, { createContext, useCallback } from 'react'\n\nimport type {\n RenderFieldServerFnArgs,\n RenderFieldServerFnReturnType,\n} from '../../forms/fieldSchemasToFormState/serverFunctions/renderFieldServerFn.js'\nimport type { buildFormStateHandler } from '../../utilities/buildFormState.js'\nimport type { buildTableStateHandler } from '../../utilities/buildTableState.js'\nimport type { CopyDataFromLocaleArgs } from '../../utilities/copyDataFromLocale.js'\nimport type {\n getUpcomingScheduledPublishHandler,\n GetUpcomingScheduledPublishHandlerArgs,\n schedulePublishHandler,\n SchedulePublishHandlerArgs,\n} from '../../utilities/schedulePublishHandler.js'\n\ntype GetFormStateClient = (\n args: {\n signal?: AbortSignal\n } & Omit<BuildFormStateArgs, 'clientConfig' | 'req'>,\n) => ReturnType<typeof buildFormStateHandler>\n\ntype SchedulePublishClient = (\n args: {\n signal?: AbortSignal\n } & Omit<SchedulePublishHandlerArgs, 'clientConfig' | 'req'>,\n) => ReturnType<typeof schedulePublishHandler>\n\ntype GetUpcomingScheduledPublishClient = (\n args: {\n signal?: AbortSignal\n } & Omit<GetUpcomingScheduledPublishHandlerArgs, 'clientConfig' | 'req'>,\n) => ReturnType<typeof getUpcomingScheduledPublishHandler>\n\ntype GetTableStateClient = (\n args: {\n signal?: AbortSignal\n } & Omit<BuildTableStateArgs, 'clientConfig' | 'req'>,\n) => ReturnType<typeof buildTableStateHandler>\n\ntype SlugifyClient = (\n args: {\n signal?: AbortSignal\n } & Omit<SlugifyServerFunctionArgs, 'clientConfig' | 'req'>,\n) => ReturnType<Slugify>\n\nexport type RenderDocumentResult = {\n data: any\n Document: React.ReactNode\n preferences: DocumentPreferences\n}\n\ntype RenderDocumentBaseArgs = {\n collectionSlug: string\n disableActions?: boolean\n docID: number | string\n drawerSlug?: string\n initialData?: Data\n initialState?: FormState\n overrideEntityVisibility?: boolean\n paramsOverride?: AdminViewServerPropsOnly['params']\n redirectAfterCreate?: boolean\n redirectAfterDelete: boolean\n redirectAfterDuplicate: boolean\n redirectAfterRestore?: boolean\n searchParams?: Params\n /**\n * Properties specific to the versions view\n */\n versions?: RenderDocumentVersionsProperties\n}\n\nexport type RenderDocumentServerFunction = ServerFunction<\n RenderDocumentBaseArgs,\n Promise<RenderDocumentResult>\n>\n\ntype RenderDocumentServerFunctionHookFn = (\n // No req or importMap - those are augmented by handleServerFunctions\n args: {\n signal?: AbortSignal\n } & RenderDocumentBaseArgs,\n) => Promise<RenderDocumentResult>\n\ntype CopyDataFromLocaleClient = (\n args: {\n signal?: AbortSignal\n } & Omit<CopyDataFromLocaleArgs, 'req'>,\n) => Promise<{ data: Data }>\n\ntype GetDocumentSlots = (args: {\n collectionSlug: string\n id?: number | string\n signal?: AbortSignal\n}) => Promise<DocumentSlots>\n\ntype RenderFieldClient = (args: RenderFieldServerFnArgs) => Promise<RenderFieldServerFnReturnType>\n\ntype SwitchLanguageClient = (lang: string) => Promise<void>\n\nexport type ServerFunctionsContextType = {\n _internal_renderField: RenderFieldClient\n copyDataFromLocale: CopyDataFromLocaleClient\n getDocumentSlots: GetDocumentSlots\n getFormState: GetFormStateClient\n getTableState: GetTableStateClient\n getUpcomingScheduledPublish: GetUpcomingScheduledPublishClient\n renderDocument: RenderDocumentServerFunctionHookFn\n schedulePublish: SchedulePublishClient\n serverFunction: ServerFunctionClient\n slugify: SlugifyClient\n switchLanguage: SwitchLanguageClient\n}\n\nexport const ServerFunctionsContext = createContext<ServerFunctionsContextType | undefined>(\n undefined,\n)\n\nexport const useServerFunctions = () => {\n const context = React.use(ServerFunctionsContext)\n if (context === undefined) {\n throw new Error('useServerFunctions must be used within a ServerFunctionsProvider')\n }\n return context\n}\n\nexport const ServerFunctionsProvider: React.FC<{\n children: React.ReactNode\n serverFunction: ServerFunctionClient\n}> = ({ children, serverFunction }) => {\n if (!serverFunction) {\n throw new Error('ServerFunctionsProvider requires a serverFunction prop')\n }\n\n const getDocumentSlots = useCallback<GetDocumentSlots>(\n async (args) =>\n await serverFunction({\n name: 'render-document-slots',\n args,\n }),\n [serverFunction],\n )\n\n const schedulePublish = useCallback<SchedulePublishClient>(\n async (args) => {\n const { signal: remoteSignal, ...rest } = args\n\n try {\n if (!remoteSignal?.aborted) {\n const result = await serverFunction({\n name: 'schedule-publish',\n args: { ...rest },\n })\n\n if (!remoteSignal?.aborted) {\n return result\n }\n }\n } catch (_err) {\n console.error(_err) // eslint-disable-line no-console\n }\n\n let error = `Error scheduling ${rest.type}`\n\n if (rest.doc) {\n error += ` for document with ID ${rest.doc.value} in collection ${rest.doc.relationTo}`\n }\n\n return { error }\n },\n [serverFunction],\n )\n\n const getUpcomingScheduledPublish = useCallback<GetUpcomingScheduledPublishClient>(\n async (args) => {\n const { signal: remoteSignal, ...rest } = args\n\n if (remoteSignal?.aborted) {\n return []\n }\n\n const result = (await serverFunction({\n name: 'get-upcoming-scheduled-publish',\n args: rest,\n })) as Awaited<ReturnType<typeof getUpcomingScheduledPublishHandler>>\n\n return remoteSignal?.aborted ? [] : result\n },\n [serverFunction],\n )\n\n const getFormState = useCallback<GetFormStateClient>(\n async (args) => {\n const { signal: remoteSignal, ...rest } = args || {}\n\n try {\n if (!remoteSignal?.aborted) {\n const result = (await serverFunction({\n name: 'form-state',\n args: { fallbackLocale: false, ...rest },\n })) as Awaited<ReturnType<typeof buildFormStateHandler>> // TODO: infer this type when `strictNullChecks` is enabled\n\n if (!remoteSignal?.aborted) {\n return result\n }\n }\n } catch (_err) {\n console.error(_err) // eslint-disable-line no-console\n }\n\n return { state: null }\n },\n [serverFunction],\n )\n\n const getTableState = useCallback<GetTableStateClient>(\n async (args) => {\n const { signal: remoteSignal, ...rest } = args || {}\n\n try {\n if (!remoteSignal?.aborted) {\n const result = (await serverFunction({\n name: 'table-state',\n args: { fallbackLocale: false, ...rest },\n })) as Awaited<ReturnType<typeof buildTableStateHandler>> // TODO: infer this type when `strictNullChecks` is enabled\n\n if (!remoteSignal?.aborted) {\n return result\n }\n }\n } catch (_err) {\n console.error(_err) // eslint-disable-line no-console\n }\n\n // return { state: args.formState }\n },\n [serverFunction],\n )\n\n const renderDocument = useCallback<RenderDocumentServerFunctionHookFn>(\n async (args) => {\n const { signal: remoteSignal, ...rest } = args || {}\n try {\n const result = (await serverFunction({\n name: 'render-document',\n args: {\n fallbackLocale: false,\n ...rest,\n } as Parameters<RenderDocumentServerFunctionHookFn>[0],\n })) as Awaited<ReturnType<RenderDocumentServerFunctionHookFn>> // TODO: infer this type when `strictNullChecks` is enabled\n\n return result\n } catch (_err) {\n console.error(_err) // eslint-disable-line no-console\n }\n },\n [serverFunction],\n )\n\n const copyDataFromLocale = useCallback<CopyDataFromLocaleClient>(\n async (args) => {\n const { signal: remoteSignal, ...rest } = args || {}\n\n const result = (await serverFunction({\n name: 'copy-data-from-locale',\n args: rest,\n })) as Data\n\n if (!remoteSignal?.aborted) {\n return { data: result }\n }\n },\n [serverFunction],\n )\n\n const _internal_renderField = useCallback<RenderFieldClient>(\n async (args) => {\n try {\n const result = (await serverFunction({\n name: 'render-field',\n args,\n })) as RenderFieldServerFnReturnType\n\n return result\n } catch (_err) {\n console.error(_err) // eslint-disable-line no-console\n }\n },\n [serverFunction],\n )\n\n const slugify = useCallback<SlugifyClient>(\n async (args) => {\n const { signal: remoteSignal, ...rest } = args || {}\n\n try {\n const result = (await serverFunction({\n name: 'slugify',\n args: { ...rest },\n })) as Awaited<ReturnType<Slugify>> // TODO: infer this type when `strictNullChecks` is enabled\n\n return result\n } catch (_err) {\n console.error(_err) // eslint-disable-line no-console\n }\n },\n [serverFunction],\n )\n\n const switchLanguage = useCallback<SwitchLanguageClient>(\n async (lang) => {\n await serverFunction({\n name: 'switch-language',\n args: { lang },\n })\n },\n [serverFunction],\n )\n\n return (\n <ServerFunctionsContext\n value={{\n _internal_renderField,\n copyDataFromLocale,\n getDocumentSlots,\n getFormState,\n getTableState,\n getUpcomingScheduledPublish,\n renderDocument,\n schedulePublish,\n serverFunction,\n slugify,\n switchLanguage,\n }}\n >\n {children}\n </ServerFunctionsContext>\n )\n}\n"],"mappings":";AAgBA,OAAOA,KAAA,IAASC,aAAa,EAAEC,WAAW,QAAQ;AAkHlD,OAAO,MAAMC,sBAAA,gBAAyBF,aAAA,CACpCG,SAAA;AAGF,OAAO,MAAMC,kBAAA,GAAqBA,CAAA;EAChC,MAAMC,OAAA,GAAUN,KAAA,CAAMO,GAAG,CAACJ,sBAAA;EAC1B,IAAIG,OAAA,KAAYF,SAAA,EAAW;IACzB,MAAM,IAAII,KAAA,CAAM;EAClB;EACA,OAAOF,OAAA;AACT;AAEA,OAAO,MAAMG,uBAAA,GAGRA,CAAC;EAAEC,QAAQ;EAAEC;AAAc,CAAE;EAChC,IAAI,CAACA,cAAA,EAAgB;IACnB,MAAM,IAAIH,KAAA,CAAM;EAClB;EAEA,MAAMI,gBAAA,GAAmBV,WAAA,CACvB,MAAOW,IAAA,IACL,MAAMF,cAAA,CAAe;IACnBG,IAAA,EAAM;IACND;EACF,IACF,CAACF,cAAA,CAAe;EAGlB,MAAMI,e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,EAAM;QAAE0B;MAAK;IACf;EACF,GACA,CAAC5B,cAAA,CAAe;EAGlB,oBACE6B,IAAA,CAACrC,sBAAA;IACCuB,KAAA,EAAO;MACLU,qBAAA;MACAF,kBAAA;MACAtB,gBAAA;MACAiB,YAAA;MACAG,aAAA;MACAJ,2BAAA;MACAK,cAAA;MACAlB,eAAA;MACAJ,cAAA;MACA0B,OAAA;MACAC;IACF;cAEC5B;;AAGP","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","createContext","useCallback","reduceToSerializableFields","ServerFunctionsContext","undefined","useServerFunctions","context","use","Error","ServerFunctionsProvider","children","serverFunction","getDocumentSlots","signal","_signal","args","name","schedulePublish","remoteSignal","rest","aborted","result","date","Date","getTime","_err","console","error","type","doc","value","relationTo","getUpcomingScheduledPublish","getFormState","documentFormState","formState","initialBlockFormState","file","File","state","initialValue","getTableState","renderDocument","initialState","copyDataFromLocale","data","_internal_renderField","slugify","switchLanguage","lang","_jsx"],"sources":["../../../src/providers/ServerFunctions/index.tsx"],"sourcesContent":["import type {\n AdminViewServerPropsOnly,\n BuildFormStateArgs,\n BuildTableStateArgs,\n Data,\n DocumentPreferences,\n DocumentSlots,\n FormState,\n Params,\n RenderDocumentVersionsProperties,\n ServerFunction,\n ServerFunctionClient,\n SlugifyServerFunctionArgs,\n} from 'payload'\nimport type { Slugify } from 'payload/shared'\n\nimport React, { createContext, useCallback } from 'react'\n\nimport type {\n RenderFieldServerFnArgs,\n RenderFieldServerFnReturnType,\n} from '../../forms/fieldSchemasToFormState/serverFunctions/renderFieldServerFn.js'\nimport type { buildFormStateHandler } from '../../utilities/buildFormState.js'\nimport type { buildTableStateHandler } from '../../utilities/buildTableState.js'\nimport type { CopyDataFromLocaleArgs } from '../../utilities/copyDataFromLocale.js'\nimport type {\n getUpcomingScheduledPublishHandler,\n GetUpcomingScheduledPublishHandlerArgs,\n schedulePublishHandler,\n SchedulePublishHandlerArgs,\n} from '../../utilities/schedulePublishHandler.js'\n\nimport { reduceToSerializableFields } from '../../forms/Form/reduceToSerializableFields.js'\n\ntype GetFormStateClient = (\n args: {\n signal?: AbortSignal\n } & Omit<BuildFormStateArgs, 'clientConfig' | 'req'>,\n) => ReturnType<typeof buildFormStateHandler>\n\ntype SchedulePublishClient = (\n args: {\n signal?: AbortSignal\n } & Omit<SchedulePublishHandlerArgs, 'clientConfig' | 'req'>,\n) => ReturnType<typeof schedulePublishHandler>\n\ntype GetUpcomingScheduledPublishClient = (\n args: {\n signal?: AbortSignal\n } & Omit<GetUpcomingScheduledPublishHandlerArgs, 'clientConfig' | 'req'>,\n) => ReturnType<typeof getUpcomingScheduledPublishHandler>\n\ntype GetTableStateClient = (\n args: {\n signal?: AbortSignal\n } & Omit<BuildTableStateArgs, 'clientConfig' | 'req'>,\n) => ReturnType<typeof buildTableStateHandler>\n\ntype SlugifyClient = (\n args: {\n signal?: AbortSignal\n } & Omit<SlugifyServerFunctionArgs, 'clientConfig' | 'req'>,\n) => ReturnType<Slugify>\n\nexport type RenderDocumentResult = {\n data: any\n Document: React.ReactNode\n preferences: DocumentPreferences\n}\n\ntype RenderDocumentBaseArgs = {\n collectionSlug: string\n disableActions?: boolean\n docID: number | string\n drawerSlug?: string\n initialData?: Data\n initialState?: FormState\n overrideEntityVisibility?: boolean\n paramsOverride?: AdminViewServerPropsOnly['params']\n redirectAfterCreate?: boolean\n redirectAfterDelete: boolean\n redirectAfterDuplicate: boolean\n redirectAfterRestore?: boolean\n searchParams?: Params\n /**\n * Properties specific to the versions view\n */\n versions?: RenderDocumentVersionsProperties\n}\n\nexport type RenderDocumentServerFunction = ServerFunction<\n RenderDocumentBaseArgs,\n Promise<RenderDocumentResult>\n>\n\ntype RenderDocumentServerFunctionHookFn = (\n // No req or importMap - those are augmented by handleServerFunctions\n args: {\n signal?: AbortSignal\n } & RenderDocumentBaseArgs,\n) => Promise<RenderDocumentResult>\n\ntype CopyDataFromLocaleClient = (\n args: {\n signal?: AbortSignal\n } & Omit<CopyDataFromLocaleArgs, 'req'>,\n) => Promise<{ data: Data }>\n\ntype GetDocumentSlots = (args: {\n collectionSlug: string\n id?: number | string\n signal?: AbortSignal\n}) => Promise<DocumentSlots>\n\ntype RenderFieldClient = (args: RenderFieldServerFnArgs) => Promise<RenderFieldServerFnReturnType>\n\ntype SwitchLanguageClient = (lang: string) => Promise<void>\n\nexport type ServerFunctionsContextType = {\n _internal_renderField: RenderFieldClient\n copyDataFromLocale: CopyDataFromLocaleClient\n getDocumentSlots: GetDocumentSlots\n getFormState: GetFormStateClient\n getTableState: GetTableStateClient\n getUpcomingScheduledPublish: GetUpcomingScheduledPublishClient\n renderDocument: RenderDocumentServerFunctionHookFn\n schedulePublish: SchedulePublishClient\n serverFunction: ServerFunctionClient\n slugify: SlugifyClient\n switchLanguage: SwitchLanguageClient\n}\n\nexport const ServerFunctionsContext = createContext<ServerFunctionsContextType | undefined>(\n undefined,\n)\n\nexport const useServerFunctions = () => {\n const context = React.use(ServerFunctionsContext)\n if (context === undefined) {\n throw new Error('useServerFunctions must be used within a ServerFunctionsProvider')\n }\n return context\n}\n\nexport const ServerFunctionsProvider: React.FC<{\n children: React.ReactNode\n serverFunction: ServerFunctionClient\n}> = ({ children, serverFunction }) => {\n if (!serverFunction) {\n throw new Error('ServerFunctionsProvider requires a serverFunction prop')\n }\n\n const getDocumentSlots = useCallback<GetDocumentSlots>(\n async ({ signal: _signal, ...args }) =>\n await serverFunction({\n name: 'render-document-slots',\n args,\n }),\n [serverFunction],\n )\n\n const schedulePublish = useCallback<SchedulePublishClient>(\n async (args) => {\n const { signal: remoteSignal, ...rest } = args\n\n try {\n if (!remoteSignal?.aborted) {\n const result = await serverFunction({\n name: 'schedule-publish',\n args: {\n ...rest,\n date: rest.date ? new Date(rest.date.getTime()) : rest.date,\n } satisfies SchedulePublishHandlerArgs,\n })\n\n if (!remoteSignal?.aborted) {\n return result\n }\n }\n } catch (_err) {\n console.error(_err) // eslint-disable-line no-console\n }\n\n let error = `Error scheduling ${rest.type}`\n\n if (rest.doc) {\n error += ` for document with ID ${rest.doc.value} in collection ${rest.doc.relationTo}`\n }\n\n return { error }\n },\n [serverFunction],\n )\n\n const getUpcomingScheduledPublish = useCallback<GetUpcomingScheduledPublishClient>(\n async (args) => {\n const { signal: remoteSignal, ...rest } = args\n\n if (remoteSignal?.aborted) {\n return []\n }\n\n const result = (await serverFunction({\n name: 'get-upcoming-scheduled-publish',\n args: rest,\n })) as Awaited<ReturnType<typeof getUpcomingScheduledPublishHandler>>\n\n return remoteSignal?.aborted ? [] : result\n },\n [serverFunction],\n )\n\n const getFormState = useCallback<GetFormStateClient>(\n async (args) => {\n const { signal: remoteSignal, ...rest } = args\n\n try {\n if (!remoteSignal?.aborted) {\n const result = (await serverFunction({\n name: 'form-state',\n args: {\n ...rest,\n documentFormState: reduceToSerializableFields(rest.documentFormState),\n formState: reduceToSerializableFields(rest.formState),\n initialBlockFormState: reduceToSerializableFields(rest.initialBlockFormState),\n } satisfies Parameters<GetFormStateClient>[0],\n })) as Awaited<ReturnType<typeof buildFormStateHandler>> // TODO: infer this type when `strictNullChecks` is enabled\n\n if (!remoteSignal?.aborted) {\n const file = rest.formState?.file\n\n if (typeof File !== 'undefined' && result.state?.file) {\n if (file?.initialValue instanceof File) {\n result.state.file.initialValue = file.initialValue\n }\n\n if (file?.value instanceof File) {\n result.state.file.value = file.value\n }\n }\n\n return result\n }\n }\n } catch (_err) {\n console.error(_err) // eslint-disable-line no-console\n }\n\n return { state: null }\n },\n [serverFunction],\n )\n\n const getTableState = useCallback<GetTableStateClient>(\n async (args) => {\n const { signal: remoteSignal, ...rest } = args\n\n try {\n if (!remoteSignal?.aborted) {\n const result = (await serverFunction({\n name: 'table-state',\n args: rest,\n })) as Awaited<ReturnType<typeof buildTableStateHandler>> // TODO: infer this type when `strictNullChecks` is enabled\n\n if (!remoteSignal?.aborted) {\n return result\n }\n }\n } catch (_err) {\n console.error(_err) // eslint-disable-line no-console\n }\n\n // return { state: args.formState }\n },\n [serverFunction],\n )\n\n const renderDocument = useCallback<RenderDocumentServerFunctionHookFn>(\n async ({ signal: _signal, ...rest }) => {\n try {\n const result = (await serverFunction({\n name: 'render-document',\n args: {\n ...rest,\n initialState: reduceToSerializableFields(rest.initialState),\n } satisfies RenderDocumentBaseArgs,\n })) as Awaited<ReturnType<RenderDocumentServerFunctionHookFn>> // TODO: infer this type when `strictNullChecks` is enabled\n\n return result\n } catch (_err) {\n console.error(_err) // eslint-disable-line no-console\n }\n },\n [serverFunction],\n )\n\n const copyDataFromLocale = useCallback<CopyDataFromLocaleClient>(\n async (args) => {\n const { signal: remoteSignal, ...rest } = args\n\n const result = (await serverFunction({\n name: 'copy-data-from-locale',\n args: rest,\n })) as Data\n\n if (!remoteSignal?.aborted) {\n return { data: result }\n }\n },\n [serverFunction],\n )\n\n const _internal_renderField = useCallback<RenderFieldClient>(\n async (args) => {\n try {\n const result = (await serverFunction({\n name: 'render-field',\n args,\n })) as RenderFieldServerFnReturnType\n\n return result\n } catch (_err) {\n console.error(_err) // eslint-disable-line no-console\n }\n },\n [serverFunction],\n )\n\n const slugify = useCallback<SlugifyClient>(\n async ({ signal: _signal, ...rest }) => {\n try {\n const result = (await serverFunction({\n name: 'slugify',\n args: {\n ...rest,\n } satisfies SlugifyServerFunctionArgs,\n })) as Awaited<ReturnType<Slugify>> // TODO: infer this type when `strictNullChecks` is enabled\n\n return result\n } catch (_err) {\n console.error(_err) // eslint-disable-line no-console\n }\n },\n [serverFunction],\n )\n\n const switchLanguage = useCallback<SwitchLanguageClient>(\n async (lang) => {\n await serverFunction({\n name: 'switch-language',\n args: { lang },\n })\n },\n [serverFunction],\n )\n\n return (\n <ServerFunctionsContext\n value={{\n _internal_renderField,\n copyDataFromLocale,\n getDocumentSlots,\n getFormState,\n getTableState,\n getUpcomingScheduledPublish,\n renderDocument,\n schedulePublish,\n serverFunction,\n slugify,\n switchLanguage,\n }}\n >\n {children}\n </ServerFunctionsContext>\n )\n}\n"],"mappings":";AAgBA,OAAOA,K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