@payloadcms/ui 3.0.0 → 3.0.1-canary.d608962
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/elements/RenderServerComponent/index.d.ts +8 -5
- package/dist/elements/RenderServerComponent/index.d.ts.map +1 -1
- package/dist/elements/RenderServerComponent/index.js +14 -11
- package/dist/elements/RenderServerComponent/index.js.map +1 -1
- package/dist/elements/TableColumns/buildColumnState.d.ts.map +1 -1
- package/dist/elements/TableColumns/buildColumnState.js +6 -20
- package/dist/elements/TableColumns/buildColumnState.js.map +1 -1
- package/dist/elements/WithServerSideProps/index.js +1 -3
- package/dist/elements/WithServerSideProps/index.js.map +1 -1
- package/dist/exports/client/index.js +10 -10
- package/dist/exports/client/index.js.map +4 -4
- package/dist/exports/shared/index.js +2 -2
- package/dist/exports/shared/index.js.map +2 -2
- package/dist/fields/Array/index.d.ts.map +1 -1
- package/dist/fields/Array/index.js +53 -55
- package/dist/fields/Array/index.js.map +1 -1
- package/dist/fields/Blocks/index.d.ts.map +1 -1
- package/dist/fields/Blocks/index.js +53 -55
- package/dist/fields/Blocks/index.js.map +1 -1
- package/dist/forms/Form/index.d.ts.map +1 -1
- package/dist/forms/Form/index.js +2 -0
- package/dist/forms/Form/index.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/renderField.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/renderField.js +42 -50
- package/dist/forms/fieldSchemasToFormState/renderField.js.map +1 -1
- package/dist/utilities/renderTable.js +2 -2
- package/dist/utilities/renderTable.js.map +1 -1
- package/dist/views/List/index.d.ts.map +1 -1
- package/dist/views/List/index.js +25 -5
- package/dist/views/List/index.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["dequal","useRouter","serialize","deepCopyObjectSimpleWithoutReactComponents","getDataByPath","getDataByPathFunc","getSiblingData","getSiblingDataFunc","reduceFieldsToValues","wait","React","useCallback","useEffect","useReducer","useRef","useState","toast","useIgnoredEffectDebounced","useThrottledEffect","useAuth","useConfig","useDocumentInfo","useLocale","useOperation","useServerFunctions","useTranslation","abortAndIgnore","requests","FormContext","FormFieldsContext","FormWatchContext","InitializingContext","ModifiedContext","ProcessingContext","SubmittedContext","errorMessages","fieldReducer","initContextState","mergeServerFormState","baseClass","Form","props","id","collectionSlug","docPermissions","getDocPreferences","globalSlug","action","beforeSubmit","children","className","disabled","disabledFromProps","disableSuccessStatus","disableValidationOnSubmit","handleResponse","initialState","isInitializing","initializingFromProps","onChange","onSubmit","onSuccess","redirect","submitted","submittedFromProps","uuid","waitForAutocomplete","method","undefined","router","code","locale","i18n","t","refreshCookie","user","operation","getFormState","config","setDisabled","isMounted","setIsMounted","modified","setModified","initializing","setInitializing","processing","setProcessing","setSubmitted","formRef","contextRef","resetFormStateAbortControllerRef","fieldsReducer","fields","dispatchFields","current","validateForm","validatedFieldState","isValid","dataFromContext","getData","data","validationPromises","Object","entries","map","path","field","validatedField","passesCondition","validationResult","valid","validate","valueToValidate","value","rows","Array","isArray","preferences","req","payload","siblingData","errorMessage","Promise","all","type","state","submit","options","e","actionArg","methodToUse","overrides","skipValidation","preventDefault","errorToast","successToast","promise","resolve","reject","hasFormSubmitAction","success","error","loading","stopPropagation","revalidatedFormState","serializableFields","reduce","priorOnChange","beforeSubmitFn","result","formState","every","key","formData","createFormData","res","toLowerCase","body","headers","language","contentType","get","isJSON","indexOf","json","status","push","message","errors","fieldErrors","nonFieldErrors","fieldErrs","nonFieldErrs","err","newFieldErrs","newNonFieldErrs","forEach","dataError","statusText","console","getFields","getField","file","dataWithOverrides","dataToSerialize","_payload","JSON","stringify","indices","nullsAsUndefineds","reset","controller","AbortController","docPreferences","newState","renderAllFields","schemaPath","signal","replaceState","addFieldRow","blockType","rowIndex","rowIndexArg","subFieldState","newRows","length","removeFieldRow","replaceFieldRow","currentRows","optimize","classes","filter","Boolean","join","executeOnChange","onChangeFn","changed","delay","_jsx","noValidate","ref","Provider","useAllFormFields","useForm","useFormFields","useFormModified","useFormProcessing","useFormSubmitted","useWatchForm"],"sources":["../../../src/forms/Form/index.tsx"],"sourcesContent":["'use client'\nimport { dequal } from 'dequal/lite' // lite: no need for Map and Set support\nimport { useRouter } from 'next/navigation.js'\nimport { serialize } from 'object-to-formdata'\nimport { type FormState, type PayloadRequest } from 'payload'\nimport {\n deepCopyObjectSimpleWithoutReactComponents,\n getDataByPath as getDataByPathFunc,\n getSiblingData as getSiblingDataFunc,\n reduceFieldsToValues,\n wait,\n} from 'payload/shared'\nimport React, { useCallback, useEffect, useReducer, useRef, useState } from 'react'\nimport { toast } from 'sonner'\n\nimport type {\n Context as FormContextType,\n FormProps,\n GetDataByPath,\n SubmitOptions,\n} from './types.js'\n\nimport { useIgnoredEffectDebounced } from '../../hooks/useIgnoredEffect.js'\nimport { useThrottledEffect } from '../../hooks/useThrottledEffect.js'\nimport { useAuth } from '../../providers/Auth/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { useLocale } from '../../providers/Locale/index.js'\nimport { useOperation } from '../../providers/Operation/index.js'\nimport { useServerFunctions } from '../../providers/ServerFunctions/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { abortAndIgnore } from '../../utilities/abortAndIgnore.js'\nimport { requests } from '../../utilities/api.js'\nimport {\n FormContext,\n FormFieldsContext,\n FormWatchContext,\n InitializingContext,\n ModifiedContext,\n ProcessingContext,\n SubmittedContext,\n} from './context.js'\nimport { errorMessages } from './errorMessages.js'\nimport { fieldReducer } from './fieldReducer.js'\nimport { initContextState } from './initContextState.js'\nimport { mergeServerFormState } from './mergeServerFormState.js'\n\nconst baseClass = 'form'\n\nexport const Form: React.FC<FormProps> = (props) => {\n const { id, collectionSlug, docPermissions, getDocPreferences, globalSlug } = useDocumentInfo()\n\n const {\n action,\n beforeSubmit,\n children,\n className,\n disabled: disabledFromProps,\n disableSuccessStatus,\n disableValidationOnSubmit,\n // fields: fieldsFromProps = collection?.fields || global?.fields,\n handleResponse,\n initialState, // fully formed initial field state\n isInitializing: initializingFromProps,\n onChange,\n onSubmit,\n onSuccess,\n redirect,\n submitted: submittedFromProps,\n uuid,\n waitForAutocomplete,\n } = props\n\n const method = 'method' in props ? props?.method : undefined\n\n const router = useRouter()\n\n const { code: locale } = useLocale()\n const { i18n, t } = useTranslation()\n const { refreshCookie, user } = useAuth()\n const operation = useOperation()\n\n const { getFormState } = useServerFunctions()\n\n const { config } = useConfig()\n\n const [disabled, setDisabled] = useState(disabledFromProps || false)\n const [isMounted, setIsMounted] = useState(false)\n const [modified, setModified] = useState(false)\n const [initializing, setInitializing] = useState(initializingFromProps)\n const [processing, setProcessing] = useState(false)\n const [submitted, setSubmitted] = useState(false)\n const formRef = useRef<HTMLFormElement>(null)\n const contextRef = useRef({} as FormContextType)\n const resetFormStateAbortControllerRef = useRef<AbortController>(null)\n\n const fieldsReducer = useReducer(fieldReducer, {}, () => initialState)\n\n /**\n * `fields` is the current, up-to-date state/data of all fields in the form. It can be modified by using dispatchFields,\n * which calls the fieldReducer, which then updates the state.\n */\n const [fields, dispatchFields] = fieldsReducer\n\n contextRef.current.fields = fields\n\n const validateForm = useCallback(async () => {\n const validatedFieldState = {}\n let isValid = true\n\n const dataFromContext = contextRef.current.getData()\n const data = dataFromContext\n\n const validationPromises = Object.entries(contextRef.current.fields).map(\n async ([path, field]) => {\n const validatedField = field\n\n if (field.passesCondition !== false) {\n let validationResult: boolean | string = validatedField.valid\n\n if ('validate' in field && typeof field.validate === 'function') {\n let valueToValidate = field.value\n\n if (field?.rows && Array.isArray(field.rows)) {\n valueToValidate = contextRef.current.getDataByPath(path)\n }\n\n validationResult = await field.validate(valueToValidate, {\n ...field,\n id,\n collectionSlug,\n data,\n operation,\n preferences: {} as any,\n req: {\n payload: {\n config,\n },\n t,\n user,\n } as unknown as PayloadRequest,\n siblingData: contextRef.current.getSiblingData(path),\n })\n\n if (typeof validationResult === 'string') {\n validatedField.errorMessage = validationResult\n validatedField.valid = false\n } else {\n validatedField.valid = true\n validatedField.errorMessage = undefined\n }\n }\n\n if (validatedField.valid === false) {\n isValid = false\n }\n }\n\n validatedFieldState[path] = validatedField\n },\n )\n\n await Promise.all(validationPromises)\n\n if (!dequal(contextRef.current.fields, validatedFieldState)) {\n dispatchFields({ type: 'REPLACE_STATE', state: validatedFieldState })\n }\n\n return isValid\n }, [collectionSlug, config, dispatchFields, id, operation, t, user])\n\n const submit = useCallback(\n async (options: SubmitOptions = {}, e): Promise<void> => {\n const {\n action: actionArg = action,\n method: methodToUse = method,\n overrides = {},\n skipValidation,\n } = options\n\n if (disabled) {\n if (e) {\n e.preventDefault()\n }\n return\n }\n\n // create new toast promise which will resolve manually later\n let errorToast, successToast\n const promise = new Promise((resolve, reject) => {\n successToast = resolve\n errorToast = reject\n })\n\n const hasFormSubmitAction =\n actionArg || typeof action === 'string' || typeof action === 'function'\n\n if (redirect || disableSuccessStatus || !hasFormSubmitAction) {\n // Do not show submitting toast, as the promise toast may never disappear under these conditions.\n // Instead, make successToast() or errorToast() throw toast.success / toast.error\n successToast = (data) => toast.success(data)\n errorToast = (data) => toast.error(data)\n } else {\n toast.promise(promise, {\n error: (data) => {\n return data as string\n },\n loading: t('general:submitting'),\n success: (data) => {\n return data as string\n },\n })\n }\n\n if (e) {\n e.stopPropagation()\n e.preventDefault()\n }\n\n setProcessing(true)\n setDisabled(true)\n\n if (waitForAutocomplete) {\n await wait(100)\n }\n\n // Execute server side validations\n if (Array.isArray(beforeSubmit)) {\n let revalidatedFormState: FormState\n const serializableFields = deepCopyObjectSimpleWithoutReactComponents(\n contextRef.current.fields,\n )\n\n await beforeSubmit.reduce(async (priorOnChange, beforeSubmitFn) => {\n await priorOnChange\n\n const result = await beforeSubmitFn({\n formState: serializableFields,\n })\n\n revalidatedFormState = result\n }, Promise.resolve())\n\n const isValid = Object.entries(revalidatedFormState).every(([, field]) => field.valid)\n\n if (!isValid) {\n setProcessing(false)\n setSubmitted(true)\n setDisabled(false)\n return dispatchFields({ type: 'REPLACE_STATE', state: revalidatedFormState })\n }\n }\n\n const isValid =\n skipValidation || disableValidationOnSubmit ? true : await contextRef.current.validateForm()\n\n // If not valid, prevent submission\n if (!isValid) {\n errorToast(t('error:correctInvalidFields'))\n setProcessing(false)\n setSubmitted(true)\n setDisabled(false)\n return\n }\n\n // If submit handler comes through via props, run that\n if (onSubmit) {\n const serializableFields = deepCopyObjectSimpleWithoutReactComponents(\n contextRef.current.fields,\n )\n const data = reduceFieldsToValues(serializableFields, true)\n\n if (overrides) {\n for (const [key, value] of Object.entries(overrides)) {\n data[key] = value\n }\n }\n\n onSubmit(serializableFields, data)\n }\n\n if (!hasFormSubmitAction) {\n // No action provided, so we should return. An example where this happens are lexical link drawers. Upon submitting the drawer, we\n // want to close it without submitting the form. Stuff like validation would be handled by lexical before this, through beforeSubmit\n setProcessing(false)\n setSubmitted(true)\n setDisabled(false)\n return\n }\n\n const formData = contextRef.current.createFormData(overrides)\n\n try {\n let res\n\n if (typeof actionArg === 'string') {\n res = await requests[methodToUse.toLowerCase()](actionArg, {\n body: formData,\n headers: {\n 'Accept-Language': i18n.language,\n },\n })\n } else if (typeof action === 'function') {\n res = await action(formData)\n }\n\n setModified(false)\n setDisabled(false)\n\n if (typeof handleResponse === 'function') {\n handleResponse(res, successToast, errorToast)\n return\n }\n\n const contentType = res.headers.get('content-type')\n const isJSON = contentType && contentType.indexOf('application/json') !== -1\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let json: Record<string, any> = {}\n\n if (isJSON) {\n json = await res.json()\n }\n if (res.status < 400) {\n if (typeof onSuccess === 'function') {\n await onSuccess(json)\n }\n setSubmitted(false)\n setProcessing(false)\n\n if (redirect) {\n router.push(redirect)\n } else if (!disableSuccessStatus) {\n successToast(json.message || t('general:submissionSuccessful'))\n }\n } else {\n setProcessing(false)\n setSubmitted(true)\n\n contextRef.current = { ...contextRef.current } // triggers rerender of all components that subscribe to form\n if (json.message) {\n errorToast(json.message)\n\n return\n }\n\n if (Array.isArray(json.errors)) {\n const [fieldErrors, nonFieldErrors] = json.errors.reduce(\n ([fieldErrs, nonFieldErrs], err) => {\n const newFieldErrs = []\n const newNonFieldErrs = []\n\n if (err?.message) {\n newNonFieldErrs.push(err)\n }\n\n if (Array.isArray(err?.data?.errors)) {\n err.data?.errors.forEach((dataError) => {\n if (dataError?.path) {\n newFieldErrs.push(dataError)\n } else {\n newNonFieldErrs.push(dataError)\n }\n })\n }\n\n return [\n [...fieldErrs, ...newFieldErrs],\n [...nonFieldErrs, ...newNonFieldErrs],\n ]\n },\n [[], []],\n )\n\n dispatchFields({\n type: 'ADD_SERVER_ERRORS',\n errors: fieldErrors,\n })\n\n nonFieldErrors.forEach((err) => {\n errorToast(err.message || t('error:unknown'))\n })\n\n return\n }\n\n const message = errorMessages?.[res.status] || res?.statusText || t('error:unknown')\n\n errorToast(message)\n }\n } catch (err) {\n console.error('Error submitting form', err) // eslint-disable-line no-console\n setProcessing(false)\n setSubmitted(true)\n setDisabled(false)\n errorToast(err.message)\n }\n },\n [\n beforeSubmit,\n action,\n disableSuccessStatus,\n disableValidationOnSubmit,\n disabled,\n dispatchFields,\n handleResponse,\n method,\n onSubmit,\n onSuccess,\n redirect,\n router,\n t,\n i18n,\n waitForAutocomplete,\n ],\n )\n\n const getFields = useCallback(() => contextRef.current.fields, [])\n\n const getField = useCallback((path: string) => contextRef.current.fields[path], [])\n\n const getData = useCallback(() => reduceFieldsToValues(contextRef.current.fields, true), [])\n\n const getSiblingData = useCallback(\n (path: string) => getSiblingDataFunc(contextRef.current.fields, path),\n [],\n )\n\n const getDataByPath = useCallback<GetDataByPath>(\n (path: string) => getDataByPathFunc(contextRef.current.fields, path),\n [],\n )\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const createFormData = useCallback((overrides: any = {}) => {\n const data = reduceFieldsToValues(contextRef.current.fields, true)\n\n const file = data?.file\n\n if (file) {\n delete data.file\n }\n\n const dataWithOverrides = {\n ...data,\n ...overrides,\n }\n\n const dataToSerialize = {\n _payload: JSON.stringify(dataWithOverrides),\n file,\n }\n\n // nullAsUndefineds is important to allow uploads and relationship fields to clear themselves\n const formData = serialize(dataToSerialize, { indices: true, nullsAsUndefineds: false })\n\n return formData\n }, [])\n\n const reset = useCallback(\n async (data: unknown) => {\n abortAndIgnore(resetFormStateAbortControllerRef.current)\n\n const controller = new AbortController()\n resetFormStateAbortControllerRef.current = controller\n\n const docPreferences = await getDocPreferences()\n\n const { state: newState } = await getFormState({\n id,\n collectionSlug,\n data,\n docPermissions,\n docPreferences,\n globalSlug,\n operation,\n renderAllFields: true,\n schemaPath: collectionSlug ? collectionSlug : globalSlug,\n signal: controller.signal,\n })\n\n contextRef.current = { ...initContextState } as FormContextType\n setModified(false)\n dispatchFields({ type: 'REPLACE_STATE', state: newState })\n },\n [\n collectionSlug,\n dispatchFields,\n globalSlug,\n id,\n operation,\n getFormState,\n docPermissions,\n getDocPreferences,\n ],\n )\n\n const replaceState = useCallback(\n (state: FormState) => {\n contextRef.current = { ...initContextState } as FormContextType\n setModified(false)\n dispatchFields({ type: 'REPLACE_STATE', state })\n },\n [dispatchFields],\n )\n\n const addFieldRow: FormContextType['addFieldRow'] = useCallback(\n ({ blockType, path, rowIndex: rowIndexArg, subFieldState }) => {\n const newRows: unknown[] = getDataByPath(path) || []\n const rowIndex = rowIndexArg === undefined ? newRows.length : rowIndexArg\n\n // dispatch ADD_ROW that sets requiresRender: true and adds a blank row to local form state.\n // This performs no form state request, as the debounced onChange effect will do that for us.\n dispatchFields({\n type: 'ADD_ROW',\n blockType,\n path,\n rowIndex,\n subFieldState,\n })\n },\n [dispatchFields, getDataByPath],\n )\n\n const removeFieldRow: FormContextType['removeFieldRow'] = useCallback(\n ({ path, rowIndex }) => {\n dispatchFields({ type: 'REMOVE_ROW', path, rowIndex })\n },\n [dispatchFields],\n )\n\n const replaceFieldRow: FormContextType['replaceFieldRow'] = useCallback(\n ({ blockType, path, rowIndex: rowIndexArg, subFieldState }) => {\n const currentRows: unknown[] = getDataByPath(path)\n const rowIndex = rowIndexArg === undefined ? currentRows.length : rowIndexArg\n\n dispatchFields({\n type: 'REPLACE_ROW',\n blockType,\n path,\n rowIndex,\n subFieldState,\n })\n },\n [dispatchFields, getDataByPath],\n )\n\n useEffect(() => {\n return () => {\n abortAndIgnore(resetFormStateAbortControllerRef.current)\n }\n }, [])\n\n useEffect(() => {\n if (initializingFromProps !== undefined) {\n setInitializing(initializingFromProps)\n }\n }, [initializingFromProps])\n\n contextRef.current.submit = submit\n contextRef.current.getFields = getFields\n contextRef.current.getField = getField\n contextRef.current.getData = getData\n contextRef.current.getSiblingData = getSiblingData\n contextRef.current.getDataByPath = getDataByPath\n contextRef.current.validateForm = validateForm\n contextRef.current.createFormData = createFormData\n contextRef.current.setModified = setModified\n contextRef.current.setProcessing = setProcessing\n contextRef.current.setSubmitted = setSubmitted\n contextRef.current.disabled = disabled\n contextRef.current.setDisabled = setDisabled\n contextRef.current.formRef = formRef\n contextRef.current.reset = reset\n contextRef.current.replaceState = replaceState\n contextRef.current.dispatchFields = dispatchFields\n contextRef.current.addFieldRow = addFieldRow\n contextRef.current.removeFieldRow = removeFieldRow\n contextRef.current.replaceFieldRow = replaceFieldRow\n contextRef.current.uuid = uuid\n contextRef.current.initializing = initializing\n\n useEffect(() => {\n setIsMounted(true)\n }, [])\n\n useEffect(() => {\n if (typeof disabledFromProps === 'boolean') {\n setDisabled(disabledFromProps)\n }\n }, [disabledFromProps])\n\n useEffect(() => {\n if (typeof submittedFromProps === 'boolean') {\n setSubmitted(submittedFromProps)\n }\n }, [submittedFromProps])\n\n useEffect(() => {\n if (initialState) {\n contextRef.current = { ...initContextState } as FormContextType\n dispatchFields({ type: 'REPLACE_STATE', optimize: false, state: initialState })\n }\n }, [initialState, dispatchFields])\n\n useThrottledEffect(\n () => {\n refreshCookie()\n },\n 15000,\n [fields],\n )\n\n useEffect(() => {\n contextRef.current = { ...contextRef.current } // triggers rerender of all components that subscribe to form\n setModified(false)\n }, [locale])\n\n const classes = [className, baseClass].filter(Boolean).join(' ')\n\n useIgnoredEffectDebounced(\n () => {\n const executeOnChange = async () => {\n if (Array.isArray(onChange)) {\n let revalidatedFormState: FormState = contextRef.current.fields\n\n for (const onChangeFn of onChange) {\n // Edit view default onChange is in packages/ui/src/views/Edit/index.tsx. This onChange usually sends a form state request\n revalidatedFormState = await onChangeFn({\n formState: deepCopyObjectSimpleWithoutReactComponents(contextRef.current.fields),\n })\n }\n\n if (!revalidatedFormState) {\n return\n }\n\n const { changed, newState } = mergeServerFormState(\n contextRef.current.fields || {},\n revalidatedFormState,\n )\n\n if (changed) {\n dispatchFields({\n type: 'REPLACE_STATE',\n optimize: false,\n state: newState,\n })\n }\n }\n }\n\n if (modified) {\n void executeOnChange()\n }\n },\n /*\n Make sure we trigger this whenever modified changes (not just when `fields` changes),\n otherwise we will miss merging server form state for the first form update/onChange.\n\n Here's why:\n `fields` updates before `modified`, because setModified is in a setTimeout.\n So on the first change, modified is false, so we don't trigger the effect even though we should.\n **/\n [contextRef.current.fields, modified],\n [dispatchFields, onChange],\n {\n delay: 250,\n },\n )\n\n return (\n <form\n action={typeof action === 'function' ? void action : action}\n className={classes}\n method={method}\n noValidate\n onSubmit={(e) => void contextRef.current.submit({}, e)}\n ref={formRef}\n >\n <FormContext.Provider value={contextRef.current}>\n <FormWatchContext.Provider\n value={{\n fields,\n ...contextRef.current,\n }}\n >\n <SubmittedContext.Provider value={submitted}>\n <InitializingContext.Provider value={!isMounted || (isMounted && initializing)}>\n <ProcessingContext.Provider value={processing}>\n <ModifiedContext.Provider value={modified}>\n <FormFieldsContext.Provider value={fieldsReducer}>\n {children}\n </FormFieldsContext.Provider>\n </ModifiedContext.Provider>\n </ProcessingContext.Provider>\n </InitializingContext.Provider>\n </SubmittedContext.Provider>\n </FormWatchContext.Provider>\n </FormContext.Provider>\n </form>\n )\n}\n\nexport {\n FormContext,\n FormFieldsContext,\n FormWatchContext,\n ModifiedContext,\n ProcessingContext,\n SubmittedContext,\n useAllFormFields,\n useForm,\n useFormFields,\n useFormModified,\n useFormProcessing,\n useFormSubmitted,\n useWatchForm,\n} from './context.js'\n\nexport { FormProps }\n"],"mappings":"AAAA;;;AACA,SAASA,MAAM,QAAQ,cAAa,CAAC;AACrC,SAASC,SAAS,QAAQ;AAC1B,SAASC,SAAS,QAAQ;AAE1B,SACEC,0CAA0C,EAC1CC,aAAA,IAAiBC,iBAAiB,EAClCC,cAAA,IAAkBC,kBAAkB,EACpCC,oBAAoB,EACpBC,IAAI,QACC;AACP,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,UAAU,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAC5E,SAASC,KAAK,QAAQ;AAStB,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,kBAAkB,QAAQ;AACnC,SAASC,OAAO,QAAQ;AACxB,SAASC,SAAS,QAAQ;AAC1B,SAASC,eAAe,QAAQ;AAChC,SAASC,SAAS,QAAQ;AAC1B,SAASC,YAAY,QAAQ;AAC7B,SAASC,kBAAkB,QAAQ;AACnC,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,QAAQ;AACzB,SACEC,WAAW,EACXC,iBAAiB,EACjBC,gBAAgB,EAChBC,mBAAmB,EACnBC,eAAe,EACfC,iBAAiB,EACjBC,gBAAgB,QACX;AACP,SAASC,aAAa,QAAQ;AAC9B,SAASC,YAAY,QAAQ;AAC7B,SAASC,gBAAgB,QAAQ;AACjC,SAASC,oBAAoB,QAAQ;AAErC,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,IAAA,GAA6BC,KAAA;EACxC,MAAM;IAAEC,EAAE;IAAEC,cAAc;IAAEC,cAAc;IAAEC,iBAAiB;IAAEC;EAAU,CAAE,GAAGzB,eAAA;EAE9E,MAAM;IACJ0B,MAAM;IACNC,YAAY;IACZC,QAAQ;IACRC,SAAS;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,CAAC1L,iBAAA,CAAkB6L,QAAQ;cAAC5G,KAAA,EAAO5B,UAAA;wBACjC,aAAAqI,IAAA,CAAC3L,eAAA,CAAgB8L,QAAQ;gBAAC5G,KAAA,EAAOhC,QAAA;0BAC/B,aAAAyI,IAAA,CAAC9L,iBAAA,CAAkBiM,QAAQ;kBAAC5G,KAAA,EAAOtB,aAAA;4BAChC3C;;;;;;;;;AAUrB;AAEA,SACErB,WAAW,EACXC,iBAAiB,EACjBC,gBAAgB,EAChBE,eAAe,EACfC,iBAAiB,EACjBC,gBAAgB,EAChB6L,gBAAgB,EAChBC,OAAO,EACPC,aAAa,EACbC,eAAe,EACfC,iBAAiB,EACjBC,gBAAgB,EAChBC,YAAY,QACP","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["dequal","useRouter","serialize","deepCopyObjectSimpleWithoutReactComponents","getDataByPath","getDataByPathFunc","getSiblingData","getSiblingDataFunc","reduceFieldsToValues","wait","React","useCallback","useEffect","useReducer","useRef","useState","toast","useIgnoredEffectDebounced","useThrottledEffect","useAuth","useConfig","useDocumentInfo","useLocale","useOperation","useServerFunctions","useTranslation","abortAndIgnore","requests","FormContext","FormFieldsContext","FormWatchContext","InitializingContext","ModifiedContext","ProcessingContext","SubmittedContext","errorMessages","fieldReducer","initContextState","mergeServerFormState","baseClass","Form","props","id","collectionSlug","docPermissions","getDocPreferences","globalSlug","action","beforeSubmit","children","className","disabled","disabledFromProps","disableSuccessStatus","disableValidationOnSubmit","handleResponse","initialState","isInitializing","initializingFromProps","onChange","onSubmit","onSuccess","redirect","submitted","submittedFromProps","uuid","waitForAutocomplete","method","undefined","router","code","locale","i18n","t","refreshCookie","user","operation","getFormState","config","setDisabled","isMounted","setIsMounted","modified","setModified","initializing","setInitializing","processing","setProcessing","setSubmitted","formRef","contextRef","resetFormStateAbortControllerRef","fieldsReducer","fields","dispatchFields","current","validateForm","validatedFieldState","isValid","dataFromContext","getData","data","validationPromises","Object","entries","map","path","field","validatedField","passesCondition","validationResult","valid","validate","valueToValidate","value","rows","Array","isArray","preferences","req","payload","siblingData","errorMessage","Promise","all","type","state","submit","options","e","actionArg","methodToUse","overrides","skipValidation","preventDefault","errorToast","successToast","promise","resolve","reject","hasFormSubmitAction","success","error","loading","stopPropagation","revalidatedFormState","serializableFields","reduce","priorOnChange","beforeSubmitFn","result","formState","every","key","formData","createFormData","res","toLowerCase","body","headers","language","contentType","get","isJSON","indexOf","json","status","push","message","errors","fieldErrors","nonFieldErrors","fieldErrs","nonFieldErrs","err","newFieldErrs","newNonFieldErrs","forEach","dataError","statusText","console","getFields","getField","file","dataWithOverrides","dataToSerialize","_payload","JSON","stringify","indices","nullsAsUndefineds","reset","controller","AbortController","docPreferences","newState","renderAllFields","schemaPath","signal","replaceState","addFieldRow","blockType","rowIndex","rowIndexArg","subFieldState","newRows","length","removeFieldRow","replaceFieldRow","currentRows","optimize","classes","filter","Boolean","join","executeOnChange","onChangeFn","changed","delay","_jsx","noValidate","ref","Provider","useAllFormFields","useForm","useFormFields","useFormModified","useFormProcessing","useFormSubmitted","useWatchForm"],"sources":["../../../src/forms/Form/index.tsx"],"sourcesContent":["'use client'\nimport { dequal } from 'dequal/lite' // lite: no need for Map and Set support\nimport { useRouter } from 'next/navigation.js'\nimport { serialize } from 'object-to-formdata'\nimport { type FormState, type PayloadRequest } from 'payload'\nimport {\n deepCopyObjectSimpleWithoutReactComponents,\n getDataByPath as getDataByPathFunc,\n getSiblingData as getSiblingDataFunc,\n reduceFieldsToValues,\n wait,\n} from 'payload/shared'\nimport React, { useCallback, useEffect, useReducer, useRef, useState } from 'react'\nimport { toast } from 'sonner'\n\nimport type {\n Context as FormContextType,\n FormProps,\n GetDataByPath,\n SubmitOptions,\n} from './types.js'\n\nimport { useIgnoredEffectDebounced } from '../../hooks/useIgnoredEffect.js'\nimport { useThrottledEffect } from '../../hooks/useThrottledEffect.js'\nimport { useAuth } from '../../providers/Auth/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { useLocale } from '../../providers/Locale/index.js'\nimport { useOperation } from '../../providers/Operation/index.js'\nimport { useServerFunctions } from '../../providers/ServerFunctions/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { abortAndIgnore } from '../../utilities/abortAndIgnore.js'\nimport { requests } from '../../utilities/api.js'\nimport {\n FormContext,\n FormFieldsContext,\n FormWatchContext,\n InitializingContext,\n ModifiedContext,\n ProcessingContext,\n SubmittedContext,\n} from './context.js'\nimport { errorMessages } from './errorMessages.js'\nimport { fieldReducer } from './fieldReducer.js'\nimport { initContextState } from './initContextState.js'\nimport { mergeServerFormState } from './mergeServerFormState.js'\n\nconst baseClass = 'form'\n\nexport const Form: React.FC<FormProps> = (props) => {\n const { id, collectionSlug, docPermissions, getDocPreferences, globalSlug } = useDocumentInfo()\n\n const {\n action,\n beforeSubmit,\n children,\n className,\n disabled: disabledFromProps,\n disableSuccessStatus,\n disableValidationOnSubmit,\n // fields: fieldsFromProps = collection?.fields || global?.fields,\n handleResponse,\n initialState, // fully formed initial field state\n isInitializing: initializingFromProps,\n onChange,\n onSubmit,\n onSuccess,\n redirect,\n submitted: submittedFromProps,\n uuid,\n waitForAutocomplete,\n } = props\n\n const method = 'method' in props ? props?.method : undefined\n\n const router = useRouter()\n\n const { code: locale } = useLocale()\n const { i18n, t } = useTranslation()\n const { refreshCookie, user } = useAuth()\n const operation = useOperation()\n\n const { getFormState } = useServerFunctions()\n\n const { config } = useConfig()\n\n const [disabled, setDisabled] = useState(disabledFromProps || false)\n const [isMounted, setIsMounted] = useState(false)\n const [modified, setModified] = useState(false)\n const [initializing, setInitializing] = useState(initializingFromProps)\n const [processing, setProcessing] = useState(false)\n const [submitted, setSubmitted] = useState(false)\n const formRef = useRef<HTMLFormElement>(null)\n const contextRef = useRef({} as FormContextType)\n const resetFormStateAbortControllerRef = useRef<AbortController>(null)\n\n const fieldsReducer = useReducer(fieldReducer, {}, () => initialState)\n\n /**\n * `fields` is the current, up-to-date state/data of all fields in the form. It can be modified by using dispatchFields,\n * which calls the fieldReducer, which then updates the state.\n */\n const [fields, dispatchFields] = fieldsReducer\n\n contextRef.current.fields = fields\n\n const validateForm = useCallback(async () => {\n const validatedFieldState = {}\n let isValid = true\n\n const dataFromContext = contextRef.current.getData()\n const data = dataFromContext\n\n const validationPromises = Object.entries(contextRef.current.fields).map(\n async ([path, field]) => {\n const validatedField = field\n\n if (field.passesCondition !== false) {\n let validationResult: boolean | string = validatedField.valid\n\n if ('validate' in field && typeof field.validate === 'function') {\n let valueToValidate = field.value\n\n if (field?.rows && Array.isArray(field.rows)) {\n valueToValidate = contextRef.current.getDataByPath(path)\n }\n\n validationResult = await field.validate(valueToValidate, {\n ...field,\n id,\n collectionSlug,\n data,\n operation,\n preferences: {} as any,\n req: {\n payload: {\n config,\n },\n t,\n user,\n } as unknown as PayloadRequest,\n siblingData: contextRef.current.getSiblingData(path),\n })\n\n if (typeof validationResult === 'string') {\n validatedField.errorMessage = validationResult\n validatedField.valid = false\n } else {\n validatedField.valid = true\n validatedField.errorMessage = undefined\n }\n }\n\n if (validatedField.valid === false) {\n isValid = false\n }\n }\n\n validatedFieldState[path] = validatedField\n },\n )\n\n await Promise.all(validationPromises)\n\n if (!dequal(contextRef.current.fields, validatedFieldState)) {\n dispatchFields({ type: 'REPLACE_STATE', state: validatedFieldState })\n }\n\n return isValid\n }, [collectionSlug, config, dispatchFields, id, operation, t, user])\n\n const submit = useCallback(\n async (options: SubmitOptions = {}, e): Promise<void> => {\n const {\n action: actionArg = action,\n method: methodToUse = method,\n overrides = {},\n skipValidation,\n } = options\n\n if (disabled) {\n if (e) {\n e.preventDefault()\n }\n return\n }\n\n // create new toast promise which will resolve manually later\n let errorToast, successToast\n const promise = new Promise((resolve, reject) => {\n successToast = resolve\n errorToast = reject\n })\n\n const hasFormSubmitAction =\n actionArg || typeof action === 'string' || typeof action === 'function'\n\n if (redirect || disableSuccessStatus || !hasFormSubmitAction) {\n // Do not show submitting toast, as the promise toast may never disappear under these conditions.\n // Instead, make successToast() or errorToast() throw toast.success / toast.error\n successToast = (data) => toast.success(data)\n errorToast = (data) => toast.error(data)\n } else {\n toast.promise(promise, {\n error: (data) => {\n return data as string\n },\n loading: t('general:submitting'),\n success: (data) => {\n return data as string\n },\n })\n }\n\n if (e) {\n e.stopPropagation()\n e.preventDefault()\n }\n\n setProcessing(true)\n setDisabled(true)\n\n if (waitForAutocomplete) {\n await wait(100)\n }\n\n // Execute server side validations\n if (Array.isArray(beforeSubmit)) {\n let revalidatedFormState: FormState\n const serializableFields = deepCopyObjectSimpleWithoutReactComponents(\n contextRef.current.fields,\n )\n\n await beforeSubmit.reduce(async (priorOnChange, beforeSubmitFn) => {\n await priorOnChange\n\n const result = await beforeSubmitFn({\n formState: serializableFields,\n })\n\n revalidatedFormState = result\n }, Promise.resolve())\n\n const isValid = Object.entries(revalidatedFormState).every(([, field]) => field.valid)\n\n if (!isValid) {\n setProcessing(false)\n setSubmitted(true)\n setDisabled(false)\n return dispatchFields({ type: 'REPLACE_STATE', state: revalidatedFormState })\n }\n }\n\n const isValid =\n skipValidation || disableValidationOnSubmit ? true : await contextRef.current.validateForm()\n\n // If not valid, prevent submission\n if (!isValid) {\n errorToast(t('error:correctInvalidFields'))\n setProcessing(false)\n setSubmitted(true)\n setDisabled(false)\n return\n }\n\n // If submit handler comes through via props, run that\n if (onSubmit) {\n const serializableFields = deepCopyObjectSimpleWithoutReactComponents(\n contextRef.current.fields,\n )\n const data = reduceFieldsToValues(serializableFields, true)\n\n if (overrides) {\n for (const [key, value] of Object.entries(overrides)) {\n data[key] = value\n }\n }\n\n onSubmit(serializableFields, data)\n }\n\n if (!hasFormSubmitAction) {\n // No action provided, so we should return. An example where this happens are lexical link drawers. Upon submitting the drawer, we\n // want to close it without submitting the form. Stuff like validation would be handled by lexical before this, through beforeSubmit\n setProcessing(false)\n setSubmitted(true)\n setDisabled(false)\n return\n }\n\n const formData = contextRef.current.createFormData(overrides)\n\n try {\n let res\n\n if (typeof actionArg === 'string') {\n res = await requests[methodToUse.toLowerCase()](actionArg, {\n body: formData,\n headers: {\n 'Accept-Language': i18n.language,\n },\n })\n } else if (typeof action === 'function') {\n res = await action(formData)\n }\n\n setModified(false)\n setDisabled(false)\n\n if (typeof handleResponse === 'function') {\n handleResponse(res, successToast, errorToast)\n return\n }\n\n const contentType = res.headers.get('content-type')\n const isJSON = contentType && contentType.indexOf('application/json') !== -1\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let json: Record<string, any> = {}\n\n if (isJSON) {\n json = await res.json()\n }\n if (res.status < 400) {\n if (typeof onSuccess === 'function') {\n await onSuccess(json)\n }\n setSubmitted(false)\n setProcessing(false)\n\n if (redirect) {\n router.push(redirect)\n } else if (!disableSuccessStatus) {\n successToast(json.message || t('general:submissionSuccessful'))\n }\n } else {\n setProcessing(false)\n setSubmitted(true)\n\n contextRef.current = { ...contextRef.current } // triggers rerender of all components that subscribe to form\n if (json.message) {\n errorToast(json.message)\n\n return\n }\n\n if (Array.isArray(json.errors)) {\n const [fieldErrors, nonFieldErrors] = json.errors.reduce(\n ([fieldErrs, nonFieldErrs], err) => {\n const newFieldErrs = []\n const newNonFieldErrs = []\n\n if (err?.message) {\n newNonFieldErrs.push(err)\n }\n\n if (Array.isArray(err?.data?.errors)) {\n err.data?.errors.forEach((dataError) => {\n if (dataError?.path) {\n newFieldErrs.push(dataError)\n } else {\n newNonFieldErrs.push(dataError)\n }\n })\n }\n\n return [\n [...fieldErrs, ...newFieldErrs],\n [...nonFieldErrs, ...newNonFieldErrs],\n ]\n },\n [[], []],\n )\n\n dispatchFields({\n type: 'ADD_SERVER_ERRORS',\n errors: fieldErrors,\n })\n\n nonFieldErrors.forEach((err) => {\n errorToast(err.message || t('error:unknown'))\n })\n\n return\n }\n\n const message = errorMessages?.[res.status] || res?.statusText || t('error:unknown')\n\n errorToast(message)\n }\n } catch (err) {\n console.error('Error submitting form', err) // eslint-disable-line no-console\n setProcessing(false)\n setSubmitted(true)\n setDisabled(false)\n errorToast(err.message)\n }\n },\n [\n beforeSubmit,\n action,\n disableSuccessStatus,\n disableValidationOnSubmit,\n disabled,\n dispatchFields,\n handleResponse,\n method,\n onSubmit,\n onSuccess,\n redirect,\n router,\n t,\n i18n,\n waitForAutocomplete,\n ],\n )\n\n const getFields = useCallback(() => contextRef.current.fields, [])\n\n const getField = useCallback((path: string) => contextRef.current.fields[path], [])\n\n const getData = useCallback(() => reduceFieldsToValues(contextRef.current.fields, true), [])\n\n const getSiblingData = useCallback(\n (path: string) => getSiblingDataFunc(contextRef.current.fields, path),\n [],\n )\n\n const getDataByPath = useCallback<GetDataByPath>(\n (path: string) => getDataByPathFunc(contextRef.current.fields, path),\n [],\n )\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const createFormData = useCallback((overrides: any = {}) => {\n const data = reduceFieldsToValues(contextRef.current.fields, true)\n\n const file = data?.file\n\n if (file) {\n delete data.file\n }\n\n const dataWithOverrides = {\n ...data,\n ...overrides,\n }\n\n const dataToSerialize = {\n _payload: JSON.stringify(dataWithOverrides),\n file,\n }\n\n // nullAsUndefineds is important to allow uploads and relationship fields to clear themselves\n const formData = serialize(dataToSerialize, { indices: true, nullsAsUndefineds: false })\n\n return formData\n }, [])\n\n const reset = useCallback(\n async (data: unknown) => {\n abortAndIgnore(resetFormStateAbortControllerRef.current)\n\n const controller = new AbortController()\n resetFormStateAbortControllerRef.current = controller\n\n const docPreferences = await getDocPreferences()\n\n const { state: newState } = await getFormState({\n id,\n collectionSlug,\n data,\n docPermissions,\n docPreferences,\n globalSlug,\n operation,\n renderAllFields: true,\n schemaPath: collectionSlug ? collectionSlug : globalSlug,\n signal: controller.signal,\n })\n\n contextRef.current = { ...initContextState } as FormContextType\n setModified(false)\n dispatchFields({ type: 'REPLACE_STATE', state: newState })\n },\n [\n collectionSlug,\n dispatchFields,\n globalSlug,\n id,\n operation,\n getFormState,\n docPermissions,\n getDocPreferences,\n ],\n )\n\n const replaceState = useCallback(\n (state: FormState) => {\n contextRef.current = { ...initContextState } as FormContextType\n setModified(false)\n dispatchFields({ type: 'REPLACE_STATE', state })\n },\n [dispatchFields],\n )\n\n const addFieldRow: FormContextType['addFieldRow'] = useCallback(\n ({ blockType, path, rowIndex: rowIndexArg, subFieldState }) => {\n const newRows: unknown[] = getDataByPath(path) || []\n const rowIndex = rowIndexArg === undefined ? newRows.length : rowIndexArg\n\n // dispatch ADD_ROW that sets requiresRender: true and adds a blank row to local form state.\n // This performs no form state request, as the debounced onChange effect will do that for us.\n dispatchFields({\n type: 'ADD_ROW',\n blockType,\n path,\n rowIndex,\n subFieldState,\n })\n\n setModified(true)\n },\n [dispatchFields, getDataByPath],\n )\n\n const removeFieldRow: FormContextType['removeFieldRow'] = useCallback(\n ({ path, rowIndex }) => {\n dispatchFields({ type: 'REMOVE_ROW', path, rowIndex })\n },\n [dispatchFields],\n )\n\n const replaceFieldRow: FormContextType['replaceFieldRow'] = useCallback(\n ({ blockType, path, rowIndex: rowIndexArg, subFieldState }) => {\n const currentRows: unknown[] = getDataByPath(path)\n const rowIndex = rowIndexArg === undefined ? currentRows.length : rowIndexArg\n\n dispatchFields({\n type: 'REPLACE_ROW',\n blockType,\n path,\n rowIndex,\n subFieldState,\n })\n\n setModified(true)\n },\n [dispatchFields, getDataByPath],\n )\n\n useEffect(() => {\n return () => {\n abortAndIgnore(resetFormStateAbortControllerRef.current)\n }\n }, [])\n\n useEffect(() => {\n if (initializingFromProps !== undefined) {\n setInitializing(initializingFromProps)\n }\n }, [initializingFromProps])\n\n contextRef.current.submit = submit\n contextRef.current.getFields = getFields\n contextRef.current.getField = getField\n contextRef.current.getData = getData\n contextRef.current.getSiblingData = getSiblingData\n contextRef.current.getDataByPath = getDataByPath\n contextRef.current.validateForm = validateForm\n contextRef.current.createFormData = createFormData\n contextRef.current.setModified = setModified\n contextRef.current.setProcessing = setProcessing\n contextRef.current.setSubmitted = setSubmitted\n contextRef.current.disabled = disabled\n contextRef.current.setDisabled = setDisabled\n contextRef.current.formRef = formRef\n contextRef.current.reset = reset\n contextRef.current.replaceState = replaceState\n contextRef.current.dispatchFields = dispatchFields\n contextRef.current.addFieldRow = addFieldRow\n contextRef.current.removeFieldRow = removeFieldRow\n contextRef.current.replaceFieldRow = replaceFieldRow\n contextRef.current.uuid = uuid\n contextRef.current.initializing = initializing\n\n useEffect(() => {\n setIsMounted(true)\n }, [])\n\n useEffect(() => {\n if (typeof disabledFromProps === 'boolean') {\n setDisabled(disabledFromProps)\n }\n }, [disabledFromProps])\n\n useEffect(() => {\n if (typeof submittedFromProps === 'boolean') {\n setSubmitted(submittedFromProps)\n }\n }, [submittedFromProps])\n\n useEffect(() => {\n if (initialState) {\n contextRef.current = { ...initContextState } as FormContextType\n dispatchFields({ type: 'REPLACE_STATE', optimize: false, state: initialState })\n }\n }, [initialState, dispatchFields])\n\n useThrottledEffect(\n () => {\n refreshCookie()\n },\n 15000,\n [fields],\n )\n\n useEffect(() => {\n contextRef.current = { ...contextRef.current } // triggers rerender of all components that subscribe to form\n setModified(false)\n }, [locale])\n\n const classes = [className, baseClass].filter(Boolean).join(' ')\n\n useIgnoredEffectDebounced(\n () => {\n const executeOnChange = async () => {\n if (Array.isArray(onChange)) {\n let revalidatedFormState: FormState = contextRef.current.fields\n\n for (const onChangeFn of onChange) {\n // Edit view default onChange is in packages/ui/src/views/Edit/index.tsx. This onChange usually sends a form state request\n revalidatedFormState = await onChangeFn({\n formState: deepCopyObjectSimpleWithoutReactComponents(contextRef.current.fields),\n })\n }\n\n if (!revalidatedFormState) {\n return\n }\n\n const { changed, newState } = mergeServerFormState(\n contextRef.current.fields || {},\n revalidatedFormState,\n )\n\n if (changed) {\n dispatchFields({\n type: 'REPLACE_STATE',\n optimize: false,\n state: newState,\n })\n }\n }\n }\n\n if (modified) {\n void executeOnChange()\n }\n },\n /*\n Make sure we trigger this whenever modified changes (not just when `fields` changes),\n otherwise we will miss merging server form state for the first form update/onChange.\n\n Here's why:\n `fields` updates before `modified`, because setModified is in a setTimeout.\n So on the first change, modified is false, so we don't trigger the effect even though we should.\n **/\n [contextRef.current.fields, modified],\n [dispatchFields, onChange],\n {\n delay: 250,\n },\n )\n\n return (\n <form\n action={typeof action === 'function' ? void action : action}\n className={classes}\n method={method}\n noValidate\n onSubmit={(e) => void contextRef.current.submit({}, e)}\n ref={formRef}\n >\n <FormContext.Provider value={contextRef.current}>\n <FormWatchContext.Provider\n value={{\n fields,\n ...contextRef.current,\n }}\n >\n <SubmittedContext.Provider value={submitted}>\n <InitializingContext.Provider value={!isMounted || (isMounted && initializing)}>\n <ProcessingContext.Provider value={processing}>\n <ModifiedContext.Provider value={modified}>\n <FormFieldsContext.Provider value={fieldsReducer}>\n {children}\n </FormFieldsContext.Provider>\n </ModifiedContext.Provider>\n </ProcessingContext.Provider>\n </InitializingContext.Provider>\n </SubmittedContext.Provider>\n </FormWatchContext.Provider>\n </FormContext.Provider>\n </form>\n )\n}\n\nexport {\n FormContext,\n FormFieldsContext,\n FormWatchContext,\n ModifiedContext,\n ProcessingContext,\n SubmittedContext,\n useAllFormFields,\n useForm,\n useFormFields,\n useFormModified,\n useFormProcessing,\n useFormSubmitted,\n useWatchForm,\n} from './context.js'\n\nexport { FormProps }\n"],"mappings":"AAAA;;;AACA,SAASA,MAAM,QAAQ,cAAa,CAAC;AACrC,SAASC,SAAS,QAAQ;AAC1B,SAASC,SAAS,QAAQ;AAE1B,SACEC,0CAA0C,EAC1CC,aAAA,IAAiBC,iBAAiB,EAClCC,cAAA,IAAkBC,kBAAkB,EACpCC,oBAAoB,EACpBC,IAAI,QACC;AACP,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,UAAU,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAC5E,SAASC,KAAK,QAAQ;AAStB,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,kBAAkB,QAAQ;AACnC,SAASC,OAAO,QAAQ;AACxB,SAASC,SAAS,QAAQ;AAC1B,SAASC,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":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"renderField.d.ts","sourceRoot":"","sources":["../../../src/forms/fieldSchemasToFormState/renderField.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAanD,eAAO,MAAM,WAAW,EAAE,iBAuOzB,CAAA"}
|
|
@@ -80,8 +80,8 @@ export const renderField = ({
|
|
|
80
80
|
if (!fieldState.customComponents.RowLabels) {
|
|
81
81
|
fieldState.customComponents.RowLabels = [];
|
|
82
82
|
}
|
|
83
|
-
fieldState.customComponents.RowLabels[rowIndex] =
|
|
84
|
-
clientProps
|
|
83
|
+
fieldState.customComponents.RowLabels[rowIndex] = RenderServerComponent({
|
|
84
|
+
clientProps,
|
|
85
85
|
Component: fieldConfig.admin.components.RowLabel,
|
|
86
86
|
importMap: req.payload.importMap,
|
|
87
87
|
serverProps: {
|
|
@@ -109,26 +109,11 @@ export const renderField = ({
|
|
|
109
109
|
if (!fieldConfig.admin.components) {
|
|
110
110
|
fieldConfig.admin.components = {};
|
|
111
111
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
*
|
|
116
|
-
* If we send the same object reference to the client twice (e.g. through some configurations where 2 or more fields
|
|
117
|
-
* reference the same editor object, like the root editor), the admin panel may hang indefinitely. This has been happening since
|
|
118
|
-
* a newer Next.js update that made it break when sending the same object reference to the client twice.
|
|
119
|
-
*
|
|
120
|
-
* We can use deepCopyObjectSimple as client props should be JSON-serializable.
|
|
121
|
-
*/
|
|
122
|
-
const FieldComponent = fieldConfig.editor.FieldComponent;
|
|
123
|
-
if (typeof FieldComponent === 'object' && FieldComponent.clientProps) {
|
|
124
|
-
FieldComponent.clientProps = deepCopyObjectSimple(FieldComponent.clientProps);
|
|
125
|
-
}
|
|
126
|
-
fieldState.customComponents.Field = /*#__PURE__*/_jsx(RenderServerComponent, {
|
|
127
|
-
clientProps: clientProps,
|
|
128
|
-
Component: FieldComponent,
|
|
129
|
-
Fallback: undefined,
|
|
112
|
+
fieldState.customComponents.Field = RenderServerComponent({
|
|
113
|
+
clientProps,
|
|
114
|
+
Component: fieldConfig.editor.FieldComponent,
|
|
130
115
|
importMap: req.payload.importMap,
|
|
131
|
-
serverProps
|
|
116
|
+
serverProps
|
|
132
117
|
});
|
|
133
118
|
break;
|
|
134
119
|
}
|
|
@@ -141,12 +126,13 @@ export const renderField = ({
|
|
|
141
126
|
continue;
|
|
142
127
|
}
|
|
143
128
|
const Component = fieldConfig.admin.components[key];
|
|
144
|
-
fieldState.customComponents[key] =
|
|
145
|
-
clientProps
|
|
146
|
-
Component
|
|
129
|
+
fieldState.customComponents[key] = RenderServerComponent({
|
|
130
|
+
clientProps,
|
|
131
|
+
Component,
|
|
147
132
|
importMap: req.payload.importMap,
|
|
148
|
-
|
|
149
|
-
|
|
133
|
+
key: `field.admin.components.${key}`,
|
|
134
|
+
serverProps
|
|
135
|
+
});
|
|
150
136
|
}
|
|
151
137
|
}
|
|
152
138
|
break;
|
|
@@ -169,52 +155,58 @@ export const renderField = ({
|
|
|
169
155
|
}
|
|
170
156
|
if (fieldConfig.admin?.components) {
|
|
171
157
|
if ('afterInput' in fieldConfig.admin.components) {
|
|
172
|
-
fieldState.customComponents.AfterInput =
|
|
173
|
-
clientProps
|
|
158
|
+
fieldState.customComponents.AfterInput = RenderServerComponent({
|
|
159
|
+
clientProps,
|
|
174
160
|
Component: fieldConfig.admin.components.afterInput,
|
|
175
161
|
importMap: req.payload.importMap,
|
|
176
|
-
|
|
177
|
-
|
|
162
|
+
key: 'field.admin.components.afterInput',
|
|
163
|
+
serverProps
|
|
164
|
+
});
|
|
178
165
|
}
|
|
179
166
|
if ('beforeInput' in fieldConfig.admin.components) {
|
|
180
|
-
fieldState.customComponents.BeforeInput =
|
|
181
|
-
clientProps
|
|
167
|
+
fieldState.customComponents.BeforeInput = RenderServerComponent({
|
|
168
|
+
clientProps,
|
|
182
169
|
Component: fieldConfig.admin.components.beforeInput,
|
|
183
170
|
importMap: req.payload.importMap,
|
|
184
|
-
|
|
185
|
-
|
|
171
|
+
key: 'field.admin.components.beforeInput',
|
|
172
|
+
serverProps
|
|
173
|
+
});
|
|
186
174
|
}
|
|
187
175
|
if ('Description' in fieldConfig.admin.components) {
|
|
188
|
-
fieldState.customComponents.Description =
|
|
189
|
-
clientProps
|
|
176
|
+
fieldState.customComponents.Description = RenderServerComponent({
|
|
177
|
+
clientProps,
|
|
190
178
|
Component: fieldConfig.admin.components.Description,
|
|
191
179
|
importMap: req.payload.importMap,
|
|
192
|
-
|
|
193
|
-
|
|
180
|
+
key: 'field.admin.components.Description',
|
|
181
|
+
serverProps
|
|
182
|
+
});
|
|
194
183
|
}
|
|
195
184
|
if ('Error' in fieldConfig.admin.components) {
|
|
196
|
-
fieldState.customComponents.Error =
|
|
197
|
-
clientProps
|
|
185
|
+
fieldState.customComponents.Error = RenderServerComponent({
|
|
186
|
+
clientProps,
|
|
198
187
|
Component: fieldConfig.admin.components.Error,
|
|
199
188
|
importMap: req.payload.importMap,
|
|
200
|
-
|
|
201
|
-
|
|
189
|
+
key: 'field.admin.components.Error',
|
|
190
|
+
serverProps
|
|
191
|
+
});
|
|
202
192
|
}
|
|
203
193
|
if ('Label' in fieldConfig.admin.components) {
|
|
204
|
-
fieldState.customComponents.Label =
|
|
205
|
-
clientProps
|
|
194
|
+
fieldState.customComponents.Label = RenderServerComponent({
|
|
195
|
+
clientProps,
|
|
206
196
|
Component: fieldConfig.admin.components.Label,
|
|
207
197
|
importMap: req.payload.importMap,
|
|
208
|
-
|
|
209
|
-
|
|
198
|
+
key: 'field.admin.components.Label',
|
|
199
|
+
serverProps
|
|
200
|
+
});
|
|
210
201
|
}
|
|
211
202
|
if ('Field' in fieldConfig.admin.components) {
|
|
212
|
-
fieldState.customComponents.Field =
|
|
213
|
-
clientProps
|
|
203
|
+
fieldState.customComponents.Field = RenderServerComponent({
|
|
204
|
+
clientProps,
|
|
214
205
|
Component: fieldConfig.admin.components.Field,
|
|
215
206
|
importMap: req.payload.importMap,
|
|
216
|
-
|
|
217
|
-
|
|
207
|
+
key: 'field.admin.components.Field',
|
|
208
|
+
serverProps
|
|
209
|
+
});
|
|
218
210
|
}
|
|
219
211
|
}
|
|
220
212
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderField.js","names":["getTranslation","createClientField","deepCopyObjectSimple","MissingEditorProp","fieldAffectsData","RenderServerComponent","FieldDescription","defaultUIFieldComponentKeys","renderField","id","collectionSlug","data","fieldConfig","fieldSchemaMap","fieldState","formState","indexPath","operation","parentPath","parentSchemaPath","path","permissions","incomingPermissions","preferences","req","schemaPath","siblingData","clientField","defaultIDType","payload","config","db","field","i18n","importMap","name","clientProps","customComponents","readOnly","includes","type","serverProps","user","rows","forEach","row","rowIndex","admin","components","RowLabels","_jsx","Component","RowLabel","rowLabel","labels","singular","String","padStart","rowNumber","editor","Error","FieldComponent","Field","Fallback","undefined","key","description","Description","t","AfterInput","afterInput","BeforeInput","beforeInput","Label"],"sources":["../../../src/forms/fieldSchemasToFormState/renderField.tsx"],"sourcesContent":["import type {\n ClientComponentProps,\n ClientField,\n FieldPaths,\n PayloadComponent,\n SanitizedFieldPermissions,\n ServerComponentProps,\n} from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { createClientField, deepCopyObjectSimple, MissingEditorProp } from 'payload'\nimport { fieldAffectsData } from 'payload/shared'\n\nimport type { RenderFieldMethod } from './types.js'\n\nimport { RenderServerComponent } from '../../elements/RenderServerComponent/index.js'\n// eslint-disable-next-line payload/no-imports-from-exports-dir -- need this to reference already existing bundle. Otherwise, bundle size increases., payload/no-imports-from-exports-dir\nimport { FieldDescription } from '../../exports/client/index.js'\n\nconst defaultUIFieldComponentKeys: Array<'Cell' | 'Description' | 'Field' | 'Filter'> = [\n 'Cell',\n 'Description',\n 'Field',\n 'Filter',\n]\n\nexport const renderField: RenderFieldMethod = ({\n id,\n collectionSlug,\n data,\n fieldConfig,\n fieldSchemaMap,\n fieldState,\n formState,\n indexPath,\n operation,\n parentPath,\n parentSchemaPath,\n path,\n permissions: incomingPermissions,\n preferences,\n req,\n schemaPath,\n siblingData,\n}) => {\n // TODO (ALESSIO): why are we passing the fieldConfig twice?\n // and especially, why are we deepCopyObject -here- instead of inside the createClientField func,\n // so no one screws this up in the future?\n const clientField = createClientField({\n clientField: deepCopyObjectSimple(fieldConfig) as ClientField,\n defaultIDType: req.payload.config.db.defaultIDType,\n field: fieldConfig,\n i18n: req.i18n,\n importMap: req.payload.importMap,\n })\n\n const permissions =\n incomingPermissions === true\n ? true\n : fieldAffectsData(fieldConfig)\n ? incomingPermissions?.[fieldConfig.name]\n : ({} as SanitizedFieldPermissions)\n\n const clientProps: ClientComponentProps & Partial<FieldPaths> = {\n customComponents: fieldState?.customComponents || {},\n field: clientField,\n path,\n readOnly: permissions !== true && !permissions?.[operation],\n schemaPath,\n }\n\n // fields with subfields\n if (['array', 'blocks', 'collapsible', 'group', 'row', 'tabs'].includes(fieldConfig.type)) {\n clientProps.indexPath = indexPath\n clientProps.parentPath = parentPath\n clientProps.parentSchemaPath = parentSchemaPath\n }\n\n const serverProps: ServerComponentProps = {\n id,\n clientField,\n data,\n field: fieldConfig,\n fieldSchemaMap,\n permissions,\n // TODO: Should we pass explicit values? initialValue, value, valid\n // value and initialValue should be typed\n collectionSlug,\n formState,\n i18n: req.i18n,\n operation,\n payload: req.payload,\n preferences,\n req,\n siblingData,\n user: req.user,\n }\n\n if (!fieldState?.customComponents) {\n fieldState.customComponents = {}\n }\n\n switch (fieldConfig.type) {\n // TODO: handle block row labels as well in a similar fashion\n case 'array': {\n fieldState?.rows?.forEach((row, rowIndex) => {\n if (fieldConfig.admin?.components && 'RowLabel' in fieldConfig.admin.components) {\n if (!fieldState.customComponents.RowLabels) {\n fieldState.customComponents.RowLabels = []\n }\n\n fieldState.customComponents.RowLabels[rowIndex] = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={fieldConfig.admin.components.RowLabel}\n importMap={req.payload.importMap}\n serverProps={{\n ...serverProps,\n rowLabel: `${getTranslation(fieldConfig.labels.singular, req.i18n)} ${String(\n rowIndex + 1,\n ).padStart(2, '0')}`,\n rowNumber: rowIndex + 1,\n }}\n />\n )\n }\n })\n\n break\n }\n\n case 'richText': {\n if (!fieldConfig?.editor) {\n throw new MissingEditorProp(fieldConfig) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n\n if (typeof fieldConfig?.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n\n if (!fieldConfig.admin) {\n fieldConfig.admin = {}\n }\n\n if (!fieldConfig.admin.components) {\n fieldConfig.admin.components = {}\n }\n\n /**\n * We have to deep copy all the props we send to the client (= FieldComponent.clientProps).\n * That way, every editor's field / cell props we send to the client have their own object references.\n *\n * If we send the same object reference to the client twice (e.g. through some configurations where 2 or more fields\n * reference the same editor object, like the root editor), the admin panel may hang indefinitely. This has been happening since\n * a newer Next.js update that made it break when sending the same object reference to the client twice.\n *\n * We can use deepCopyObjectSimple as client props should be JSON-serializable.\n */\n const FieldComponent: PayloadComponent = fieldConfig.editor.FieldComponent\n if (typeof FieldComponent === 'object' && FieldComponent.clientProps) {\n FieldComponent.clientProps = deepCopyObjectSimple(FieldComponent.clientProps)\n }\n\n fieldState.customComponents.Field = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={FieldComponent}\n Fallback={undefined}\n importMap={req.payload.importMap}\n serverProps={serverProps}\n />\n )\n\n break\n }\n\n case 'ui': {\n if (fieldConfig?.admin?.components) {\n // Render any extra, untyped components\n for (const key in fieldConfig.admin.components) {\n if (key in defaultUIFieldComponentKeys) {\n continue\n }\n const Component = fieldConfig.admin.components[key]\n fieldState.customComponents[key] = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={Component}\n importMap={req.payload.importMap}\n key={`field.admin.components.${key}`}\n serverProps={serverProps}\n />\n )\n }\n }\n break\n }\n\n default: {\n break\n }\n }\n\n if (fieldConfig.admin) {\n if ('description' in fieldConfig.admin) {\n if (typeof fieldConfig.admin?.description === 'function') {\n fieldState.customComponents.Description = (\n <FieldDescription\n description={fieldConfig.admin?.description({\n t: req.i18n.t,\n })}\n path={path}\n />\n )\n }\n }\n\n if (fieldConfig.admin?.components) {\n if ('afterInput' in fieldConfig.admin.components) {\n fieldState.customComponents.AfterInput = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={fieldConfig.admin.components.afterInput}\n importMap={req.payload.importMap}\n key=\"field.admin.components.afterInput\"\n serverProps={serverProps}\n />\n )\n }\n\n if ('beforeInput' in fieldConfig.admin.components) {\n fieldState.customComponents.BeforeInput = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={fieldConfig.admin.components.beforeInput}\n importMap={req.payload.importMap}\n key=\"field.admin.components.beforeInput\"\n serverProps={serverProps}\n />\n )\n }\n\n if ('Description' in fieldConfig.admin.components) {\n fieldState.customComponents.Description = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={fieldConfig.admin.components.Description}\n importMap={req.payload.importMap}\n key=\"field.admin.components.Description\"\n serverProps={serverProps}\n />\n )\n }\n\n if ('Error' in fieldConfig.admin.components) {\n fieldState.customComponents.Error = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={fieldConfig.admin.components.Error}\n importMap={req.payload.importMap}\n key=\"field.admin.components.Error\"\n serverProps={serverProps}\n />\n )\n }\n\n if ('Label' in fieldConfig.admin.components) {\n fieldState.customComponents.Label = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={fieldConfig.admin.components.Label}\n importMap={req.payload.importMap}\n key=\"field.admin.components.Label\"\n serverProps={serverProps}\n />\n )\n }\n\n if ('Field' in fieldConfig.admin.components) {\n fieldState.customComponents.Field = (\n <RenderServerComponent\n clientProps={clientProps}\n Component={fieldConfig.admin.components.Field}\n importMap={req.payload.importMap}\n key=\"field.admin.components.Field\"\n serverProps={serverProps}\n />\n )\n }\n }\n }\n}\n"],"mappings":";AASA,SAASA,cAAc,QAAQ;AAC/B,SAASC,iB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U,EAAE;QAC3ClC,UAAA,CAAWuB,gBAAgB,CAACyB,KAAK,gBAC/BZ,IAAA,CAAC7C,qBAAA;UACC+B,WAAA,EAAaA,WAAA;UACbe,SAAA,EAAWvC,WAAA,CAAYmC,KAAK,CAACC,UAAU,CAACc,KAAK;UAC7C5B,SAAA,EAAWV,GAAA,CAAIK,OAAO,CAACK,SAAS;UAEhCO,WAAA,EAAaA;WADT;MAIV;IACF;EACF;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"renderField.js","names":["getTranslation","createClientField","deepCopyObjectSimple","MissingEditorProp","fieldAffectsData","RenderServerComponent","FieldDescription","defaultUIFieldComponentKeys","renderField","id","collectionSlug","data","fieldConfig","fieldSchemaMap","fieldState","formState","indexPath","operation","parentPath","parentSchemaPath","path","permissions","incomingPermissions","preferences","req","schemaPath","siblingData","clientField","defaultIDType","payload","config","db","field","i18n","importMap","name","clientProps","customComponents","readOnly","includes","type","serverProps","user","rows","forEach","row","rowIndex","admin","components","RowLabels","Component","RowLabel","rowLabel","labels","singular","String","padStart","rowNumber","editor","Error","Field","FieldComponent","key","description","Description","_jsx","t","AfterInput","afterInput","BeforeInput","beforeInput","Label"],"sources":["../../../src/forms/fieldSchemasToFormState/renderField.tsx"],"sourcesContent":["import type {\n ClientComponentProps,\n ClientField,\n FieldPaths,\n SanitizedFieldPermissions,\n ServerComponentProps,\n} from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { createClientField, deepCopyObjectSimple, MissingEditorProp } from 'payload'\nimport { fieldAffectsData } from 'payload/shared'\n\nimport type { RenderFieldMethod } from './types.js'\n\nimport { RenderServerComponent } from '../../elements/RenderServerComponent/index.js'\n// eslint-disable-next-line payload/no-imports-from-exports-dir -- need this to reference already existing bundle. Otherwise, bundle size increases., payload/no-imports-from-exports-dir\nimport { FieldDescription } from '../../exports/client/index.js'\n\nconst defaultUIFieldComponentKeys: Array<'Cell' | 'Description' | 'Field' | 'Filter'> = [\n 'Cell',\n 'Description',\n 'Field',\n 'Filter',\n]\n\nexport const renderField: RenderFieldMethod = ({\n id,\n collectionSlug,\n data,\n fieldConfig,\n fieldSchemaMap,\n fieldState,\n formState,\n indexPath,\n operation,\n parentPath,\n parentSchemaPath,\n path,\n permissions: incomingPermissions,\n preferences,\n req,\n schemaPath,\n siblingData,\n}) => {\n // TODO (ALESSIO): why are we passing the fieldConfig twice?\n // and especially, why are we deepCopyObject -here- instead of inside the createClientField func,\n // so no one screws this up in the future?\n const clientField = createClientField({\n clientField: deepCopyObjectSimple(fieldConfig) as ClientField,\n defaultIDType: req.payload.config.db.defaultIDType,\n field: fieldConfig,\n i18n: req.i18n,\n importMap: req.payload.importMap,\n })\n\n const permissions =\n incomingPermissions === true\n ? true\n : fieldAffectsData(fieldConfig)\n ? incomingPermissions?.[fieldConfig.name]\n : ({} as SanitizedFieldPermissions)\n\n const clientProps: ClientComponentProps & Partial<FieldPaths> = {\n customComponents: fieldState?.customComponents || {},\n field: clientField,\n path,\n readOnly: permissions !== true && !permissions?.[operation],\n schemaPath,\n }\n\n // fields with subfields\n if (['array', 'blocks', 'collapsible', 'group', 'row', 'tabs'].includes(fieldConfig.type)) {\n clientProps.indexPath = indexPath\n clientProps.parentPath = parentPath\n clientProps.parentSchemaPath = parentSchemaPath\n }\n\n const serverProps: ServerComponentProps = {\n id,\n clientField,\n data,\n field: fieldConfig,\n fieldSchemaMap,\n permissions,\n // TODO: Should we pass explicit values? initialValue, value, valid\n // value and initialValue should be typed\n collectionSlug,\n formState,\n i18n: req.i18n,\n operation,\n payload: req.payload,\n preferences,\n req,\n siblingData,\n user: req.user,\n }\n\n if (!fieldState?.customComponents) {\n fieldState.customComponents = {}\n }\n\n switch (fieldConfig.type) {\n // TODO: handle block row labels as well in a similar fashion\n case 'array': {\n fieldState?.rows?.forEach((row, rowIndex) => {\n if (fieldConfig.admin?.components && 'RowLabel' in fieldConfig.admin.components) {\n if (!fieldState.customComponents.RowLabels) {\n fieldState.customComponents.RowLabels = []\n }\n\n fieldState.customComponents.RowLabels[rowIndex] = RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.RowLabel,\n importMap: req.payload.importMap,\n serverProps: {\n ...serverProps,\n rowLabel: `${getTranslation(fieldConfig.labels.singular, req.i18n)} ${String(\n rowIndex + 1,\n ).padStart(2, '0')}`,\n rowNumber: rowIndex + 1,\n },\n })\n }\n })\n\n break\n }\n\n case 'richText': {\n if (!fieldConfig?.editor) {\n throw new MissingEditorProp(fieldConfig) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n\n if (typeof fieldConfig?.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n\n if (!fieldConfig.admin) {\n fieldConfig.admin = {}\n }\n\n if (!fieldConfig.admin.components) {\n fieldConfig.admin.components = {}\n }\n\n fieldState.customComponents.Field = RenderServerComponent({\n clientProps,\n Component: fieldConfig.editor.FieldComponent,\n importMap: req.payload.importMap,\n serverProps,\n })\n\n break\n }\n\n case 'ui': {\n if (fieldConfig?.admin?.components) {\n // Render any extra, untyped components\n for (const key in fieldConfig.admin.components) {\n if (key in defaultUIFieldComponentKeys) {\n continue\n }\n const Component = fieldConfig.admin.components[key]\n fieldState.customComponents[key] = RenderServerComponent({\n clientProps,\n Component,\n importMap: req.payload.importMap,\n key: `field.admin.components.${key}`,\n serverProps,\n })\n }\n }\n break\n }\n\n default: {\n break\n }\n }\n\n if (fieldConfig.admin) {\n if ('description' in fieldConfig.admin) {\n if (typeof fieldConfig.admin?.description === 'function') {\n fieldState.customComponents.Description = (\n <FieldDescription\n description={fieldConfig.admin?.description({\n t: req.i18n.t,\n })}\n path={path}\n />\n )\n }\n }\n\n if (fieldConfig.admin?.components) {\n if ('afterInput' in fieldConfig.admin.components) {\n fieldState.customComponents.AfterInput = RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.afterInput,\n importMap: req.payload.importMap,\n key: 'field.admin.components.afterInput',\n serverProps,\n })\n }\n\n if ('beforeInput' in fieldConfig.admin.components) {\n fieldState.customComponents.BeforeInput = RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.beforeInput,\n importMap: req.payload.importMap,\n key: 'field.admin.components.beforeInput',\n serverProps,\n })\n }\n\n if ('Description' in fieldConfig.admin.components) {\n fieldState.customComponents.Description = RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.Description,\n importMap: req.payload.importMap,\n key: 'field.admin.components.Description',\n serverProps,\n })\n }\n\n if ('Error' in fieldConfig.admin.components) {\n fieldState.customComponents.Error = RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.Error,\n importMap: req.payload.importMap,\n key: 'field.admin.components.Error',\n serverProps,\n })\n }\n\n if ('Label' in fieldConfig.admin.components) {\n fieldState.customComponents.Label = RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.Label,\n importMap: req.payload.importMap,\n key: 'field.admin.components.Label',\n serverProps,\n })\n }\n\n if ('Field' in fieldConfig.admin.components) {\n fieldState.customComponents.Field = RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.Field,\n importMap: req.payload.importMap,\n key: 'field.admin.components.Field',\n serverProps,\n })\n }\n }\n }\n}\n"],"mappings":";AAQA,SAASA,cAAc,QAAQ;AAC/B,SAASC,iBAAiB,EAAEC,oBAAoB,EAAEC,iBAAiB,QAAQ;AAC3E,SAASC,gBAAgB,QAAQ;AAIjC,SAASC,qBAAqB,QAAQ;AACtC;AACA,SAASC,gBAAgB,QAAQ;AAEjC,MAAMC,2BAAA,GAAkF,CACtF,QACA,eACA,SACA,SACD;AAED,OAAO,MAAMC,WAAA,GAAiCA,CAAC;EAC7CC,EAAE;EACFC,cAAc;EACdC,IAAI;EACJC,WAAW;EACXC,cAAc;EACdC,UAAU;EACVC,SAAS;EACTC,SAAS;EACTC,SAAS;EACTC,UAAU;EACVC,gBAAgB;EAChBC,IAAI;EACJC,WAAA,EAAaC,mBAAmB;EAChCC,WAAW;EACXC,GAAG;EACHC,UAAU;EACVC;AAAW,CACZ;EAC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AChC4B,GAAA,EAAK;UACLrB;QACF;MACF;MAEA,IAAI,WAAW7B,WAAA,CAAYmC,KAAK,CAACC,UAAU,EAAE;QAC3ClC,UAAA,CAAWuB,gBAAgB,CAACkC,KAAK,GAAGlE,qBAAA,CAAsB;UACxD+B,WAAA;UACAc,SAAA,EAAWtC,WAAA,CAAYmC,KAAK,CAACC,UAAU,CAACuB,KAAK;UAC7CrC,SAAA,EAAWV,GAAA,CAAIK,OAAO,CAACK,SAAS;UAChC4B,GAAA,EAAK;UACLrB;QACF;MACF;MAEA,IAAI,WAAW7B,WAAA,CAAYmC,KAAK,CAACC,UAAU,EAAE;QAC3ClC,UAAA,CAAWuB,gBAAgB,CAACuB,KAAK,GAAGvD,qBAAA,CAAsB;UACxD+B,WAAA;UACAc,SAAA,EAAWtC,WAAA,CAAYmC,KAAK,CAACC,UAAU,CAACY,KAAK;UAC7C1B,SAAA,EAAWV,GAAA,CAAIK,OAAO,CAACK,SAAS;UAChC4B,GAAA,EAAK;UACLrB;QACF;MACF;IACF;EACF;AACF","ignoreList":[]}
|
|
@@ -8,9 +8,9 @@ import { getInitialColumns } from '../elements/TableColumns/getInitialColumns.js
|
|
|
8
8
|
import { Pill, Table } from '../exports/client/index.js';
|
|
9
9
|
export const renderFilters = (fields, importMap) => fields.reduce((acc, field) => {
|
|
10
10
|
if ('name' in field && field.admin?.components?.Filter) {
|
|
11
|
-
acc.set(field.name,
|
|
11
|
+
acc.set(field.name, RenderServerComponent({
|
|
12
12
|
Component: field.admin.components?.Filter,
|
|
13
|
-
importMap
|
|
13
|
+
importMap
|
|
14
14
|
}));
|
|
15
15
|
}
|
|
16
16
|
return acc;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderTable.js","names":["getTranslation","RenderServerComponent","buildColumnState","filterFields","getInitialColumns","Pill","Table","renderFilters","fields","importMap","reduce","acc","field","admin","components","Filter","set","name","
|
|
1
|
+
{"version":3,"file":"renderTable.js","names":["getTranslation","RenderServerComponent","buildColumnState","filterFields","getInitialColumns","Pill","Table","renderFilters","fields","importMap","reduce","acc","field","admin","components","Filter","set","name","Component","Map","renderTable","collectionConfig","columnPreferences","columns","columnsFromArgs","customCellProps","docs","enableRowSelections","i18n","payload","renderRowTypes","tableAppearance","useAsTitle","defaultColumns","columnState","beforeRows","accessor","active","Heading","t","renderedCells","map","_","i","_jsx","labels","singular","undefined","appearance","data"],"sources":["../../src/utilities/renderTable.tsx"],"sourcesContent":["import type {\n ClientCollectionConfig,\n CollectionConfig,\n Field,\n ImportMap,\n PaginatedDocs,\n Payload,\n} from 'payload'\n\nimport { getTranslation, type I18nClient } from '@payloadcms/translations'\n\n// eslint-disable-next-line payload/no-imports-from-exports-dir\nimport type { Column } from '../exports/client/index.js'\nimport type { ColumnPreferences } from '../providers/ListQuery/index.js'\n\nimport { RenderServerComponent } from '../elements/RenderServerComponent/index.js'\nimport { buildColumnState } from '../elements/TableColumns/buildColumnState.js'\nimport { filterFields } from '../elements/TableColumns/filterFields.js'\nimport { getInitialColumns } from '../elements/TableColumns/getInitialColumns.js'\n// eslint-disable-next-line payload/no-imports-from-exports-dir\nimport { Pill, Table } from '../exports/client/index.js'\n\nexport const renderFilters = (\n fields: Field[],\n importMap: ImportMap,\n): Map<string, React.ReactNode> =>\n fields.reduce(\n (acc, field) => {\n if ('name' in field && field.admin?.components?.Filter) {\n acc.set(\n field.name,\n RenderServerComponent({\n Component: field.admin.components?.Filter,\n importMap,\n }),\n )\n }\n\n return acc\n },\n new Map() as Map<string, React.ReactNode>,\n )\n\nexport const renderTable = ({\n collectionConfig,\n columnPreferences,\n columns: columnsFromArgs,\n customCellProps,\n docs,\n enableRowSelections,\n fields,\n i18n,\n payload,\n renderRowTypes,\n tableAppearance,\n useAsTitle,\n}: {\n collectionConfig: ClientCollectionConfig\n columnPreferences: ColumnPreferences\n columns?: ColumnPreferences\n customCellProps?: Record<string, any>\n docs: PaginatedDocs['docs']\n drawerSlug?: string\n enableRowSelections: boolean\n fields: Field[]\n i18n: I18nClient\n payload: Payload\n renderRowTypes?: boolean\n tableAppearance?: 'condensed' | 'default'\n useAsTitle: CollectionConfig['admin']['useAsTitle']\n}): {\n columnState: Column[]\n Table: React.ReactNode\n} => {\n const columns =\n columnsFromArgs ||\n getInitialColumns(filterFields(fields), useAsTitle, collectionConfig?.admin?.defaultColumns)\n\n const columnState = buildColumnState({\n beforeRows: renderRowTypes\n ? [\n {\n accessor: 'collection',\n active: true,\n field: null,\n Heading: i18n.t('version:type'),\n renderedCells: docs.map((_, i) => (\n <Pill key={i}>{getTranslation(collectionConfig.labels.singular, i18n)}</Pill>\n )),\n },\n ]\n : undefined,\n collectionConfig,\n columnPreferences,\n columns,\n enableRowSelections,\n fields,\n i18n,\n // sortColumnProps,\n customCellProps,\n docs,\n payload,\n useAsTitle,\n })\n\n return {\n columnState,\n Table: <Table appearance={tableAppearance} columns={columnState} data={docs} />,\n }\n}\n"],"mappings":";AASA,SAASA,cAAc,QAAyB;AAMhD,SAASC,qBAAqB,QAAQ;AACtC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,YAAY,QAAQ;AAC7B,SAASC,iBAAiB,QAAQ;AAClC;AACA,SAASC,IAAI,EAAEC,KAAK,QAAQ;AAE5B,OAAO,MAAMC,aAAA,GAAgBA,CAC3BC,MAAA,EACAC,SAAA,KAEAD,MAAA,CAAOE,MAAM,CACX,CAACC,GAAA,EAAKC,KAAA;EACJ,IAAI,UAAUA,KAAA,IAASA,KAAA,CAAMC,KAAK,EAAEC,UAAA,EAAYC,MAAA,EAAQ;IACtDJ,GAAA,CAAIK,GAAG,CACLJ,KAAA,CAAMK,IAAI,EACVhB,qBAAA,CAAsB;MACpBiB,SAAA,EAAWN,KAAA,CAAMC,KAAK,CAACC,UAAU,EAAEC,MAAA;MACnCN;IACF;EAEJ;EAEA,OAAOE,GAAA;AACT,GACA,IAAIQ,GAAA;AAGR,OAAO,MAAMC,WAAA,GAAcA,CAAC;EAC1BC,gBAAgB;EAChBC,iBAAiB;EACjBC,OAAA,EAASC,eAAe;EACxBC,eAAe;EACfC,IAAI;EACJC,mBAAmB;EACnBnB,MAAM;EACNoB,IAAI;EACJC,OAAO;EACPC,cAAc;EACdC,eAAe;EACfC;AAAU,CAeX;EAIC,MAAMT,OAAA,GACJC,eAAA,IACApB,iBAAA,CAAkBD,YAAA,CAAaK,MAAA,GAASwB,UAAA,EAAYX,gBAAA,EAAkBR,KAAA,EAAOoB,cAAA;EAE/E,MAAMC,WAAA,GAAchC,gBAAA,CAAiB;IACnCiC,UAAA,EAAYL,cAAA,GACR,CACE;MACEM,QAAA,EAAU;MACVC,MAAA,EAAQ;MACRzB,KAAA,EAAO;MACP0B,OAAA,EAASV,IAAA,CAAKW,CAAC,CAAC;MAChBC,aAAA,EAAed,IAAA,CAAKe,GAAG,CAAC,CAACC,CAAA,EAAGC,CAAA,kBAC1BC,IAAA,CAACvC,IAAA;kBAAcL,cAAA,CAAeqB,gBAAA,CAAiBwB,MAAM,CAACC,QAAQ,EAAElB,IAAA;SAArDe,CAAA;IAEf,EACD,GACDI,SAAA;IACJ1B,gBAAA;IACAC,iBAAA;IACAC,OAAA;IACAI,mBAAA;IACAnB,MAAA;IACAoB,IAAA;IACA;IACAH,eAAA;IACAC,IAAA;IACAG,OAAA;IACAG;EACF;EAEA,OAAO;IACLE,WAAA;IACA5B,KAAA,eAAOsC,IAAA,CAACtC,KAAA;MAAM0C,UAAA,EAAYjB,eAAA;MAAiBR,OAAA,EAASW,WAAA;MAAae,IAAA,EAAMvB;;EACzE;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/List/index.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAwC,MAAM,OAAO,CAAA;AAE5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAA;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/List/index.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAwC,MAAM,OAAO,CAAA;AAE5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAA;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AA6BjD,OAAO,cAAc,CAAA;AAKrB,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC3B,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAChC,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC5B,eAAe,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACjC,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC7B,KAAK,EAAE,KAAK,CAAC,SAAS,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,aAAa,CAAC,EAAE,KAAK,CAAC,SAAS,EAAE,CAAA;IACjC,cAAc,EAAE,MAAM,CAAA;IACtB,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,mBAAmB,EAAE,OAAO,CAAA;IAC5B,eAAe,CAAC,EAAE,eAAe,CAAA;IACjC,cAAc,EAAE,MAAM,CAAA;IACtB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,CAAA;CAC/C,GAAG,aAAa,CAAA;AAEjB,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CA4OzD,CAAA"}
|
package/dist/views/List/index.js
CHANGED
|
@@ -20,6 +20,7 @@ import { Pagination } from '../../elements/Pagination/index.js';
|
|
|
20
20
|
import { PerPage } from '../../elements/PerPage/index.js';
|
|
21
21
|
import { PublishMany } from '../../elements/PublishMany/index.js';
|
|
22
22
|
import { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js';
|
|
23
|
+
import { SelectMany } from '../../elements/SelectMany/index.js';
|
|
23
24
|
import { useStepNav } from '../../elements/StepNav/index.js';
|
|
24
25
|
import { RelationshipProvider } from '../../elements/Table/RelationshipProvider/index.js';
|
|
25
26
|
import { TableColumnsProvider } from '../../elements/TableColumns/index.js';
|
|
@@ -32,12 +33,12 @@ import { useListQuery } from '../../providers/ListQuery/index.js';
|
|
|
32
33
|
import { SelectionProvider } from '../../providers/Selection/index.js';
|
|
33
34
|
import { useTranslation } from '../../providers/Translation/index.js';
|
|
34
35
|
import { useWindowInfo } from '../../providers/WindowInfo/index.js';
|
|
35
|
-
import './index.scss';
|
|
36
36
|
import { ListHeader } from './ListHeader/index.js';
|
|
37
|
+
import './index.scss';
|
|
37
38
|
const baseClass = 'collection-list';
|
|
38
39
|
const Link = LinkImport.default || LinkImport;
|
|
39
40
|
export const DefaultListView = props => {
|
|
40
|
-
const $ = _c(
|
|
41
|
+
const $ = _c(17);
|
|
41
42
|
const {
|
|
42
43
|
AfterList,
|
|
43
44
|
AfterListTable,
|
|
@@ -60,7 +61,8 @@ export const DefaultListView = props => {
|
|
|
60
61
|
const [Table, setTable] = useState(InitialTable);
|
|
61
62
|
const {
|
|
62
63
|
createNewDrawerSlug,
|
|
63
|
-
drawerSlug: listDrawerSlug
|
|
64
|
+
drawerSlug: listDrawerSlug,
|
|
65
|
+
onBulkSelect
|
|
64
66
|
} = useListDrawerContext();
|
|
65
67
|
let t0;
|
|
66
68
|
let t1;
|
|
@@ -177,6 +179,20 @@ export const DefaultListView = props => {
|
|
|
177
179
|
}]);
|
|
178
180
|
}
|
|
179
181
|
}, [setStepNav, labels, drawerDepth]);
|
|
182
|
+
let t5;
|
|
183
|
+
if ($[13] !== enableRowSelections || $[14] !== onBulkSelect || $[15] !== beforeActions) {
|
|
184
|
+
t5 = enableRowSelections && typeof onBulkSelect === "function" ? beforeActions ? [...beforeActions, _jsx(SelectMany, {
|
|
185
|
+
onClick: onBulkSelect
|
|
186
|
+
}, "select-many")] : [_jsx(SelectMany, {
|
|
187
|
+
onClick: onBulkSelect
|
|
188
|
+
}, "select-many")] : beforeActions;
|
|
189
|
+
$[13] = enableRowSelections;
|
|
190
|
+
$[14] = onBulkSelect;
|
|
191
|
+
$[15] = beforeActions;
|
|
192
|
+
$[16] = t5;
|
|
193
|
+
} else {
|
|
194
|
+
t5 = $[16];
|
|
195
|
+
}
|
|
180
196
|
return _jsx(Fragment, {
|
|
181
197
|
children: _jsx(TableColumnsProvider, {
|
|
182
198
|
collectionSlug,
|
|
@@ -213,7 +229,7 @@ export const DefaultListView = props => {
|
|
|
213
229
|
smallBreak,
|
|
214
230
|
t
|
|
215
231
|
}), _jsx(ListControls, {
|
|
216
|
-
beforeActions,
|
|
232
|
+
beforeActions: t5,
|
|
217
233
|
collectionConfig,
|
|
218
234
|
collectionSlug,
|
|
219
235
|
disableBulkDelete,
|
|
@@ -270,7 +286,11 @@ export const DefaultListView = props => {
|
|
|
270
286
|
label: getTranslation(collectionConfig.labels.plural, i18n)
|
|
271
287
|
}), _jsxs("div", {
|
|
272
288
|
className: `${baseClass}__list-selection-actions`,
|
|
273
|
-
children: [
|
|
289
|
+
children: [enableRowSelections && typeof onBulkSelect === "function" ? beforeActions ? [...beforeActions, _jsx(SelectMany, {
|
|
290
|
+
onClick: onBulkSelect
|
|
291
|
+
}, "select-many")] : [_jsx(SelectMany, {
|
|
292
|
+
onClick: onBulkSelect
|
|
293
|
+
}, "select-many")] : beforeActions, !disableBulkEdit && _jsxs(Fragment, {
|
|
274
294
|
children: [_jsx(EditMany, {
|
|
275
295
|
collection: collectionConfig
|
|
276
296
|
}), _jsx(PublishMany, {
|