@payloadcms/ui 4.0.0-canary.16 → 4.0.0-canary.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/css/app.css +121 -0
- package/dist/css/forms.css +0 -6
- package/dist/css/spacing.css +10 -3
- package/dist/css/z-index.css +1 -0
- package/dist/elements/AddNewRelation/index.css +0 -1
- package/dist/elements/AppHeader/index.css +0 -3
- package/dist/elements/AppHeader/index.d.ts.map +1 -1
- package/dist/elements/AppHeader/index.js +5 -1
- package/dist/elements/AppHeader/index.js.map +1 -1
- package/dist/elements/BulkUpload/EditMany/DrawerContent.js +2 -2
- package/dist/elements/BulkUpload/EditMany/DrawerContent.js.map +1 -1
- package/dist/elements/CodeEditor/index.css +0 -5
- package/dist/elements/CommandPalette/index.css +0 -7
- package/dist/elements/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/elements/DatePicker/DatePicker.js +1 -0
- package/dist/elements/DatePicker/DatePicker.js.map +1 -1
- package/dist/elements/DatePicker/index.css +1 -1
- package/dist/elements/DeleteDocument/index.d.ts.map +1 -1
- package/dist/elements/DeleteDocument/index.js +16 -1
- package/dist/elements/DeleteDocument/index.js.map +1 -1
- package/dist/elements/EditMany/DrawerContent.js +2 -2
- package/dist/elements/EditMany/DrawerContent.js.map +1 -1
- package/dist/elements/FileDetails/StaticFileDetails/index.css +8 -9
- package/dist/elements/FileManager/index.js +1 -0
- package/dist/elements/FileManager/index.js.map +1 -1
- package/dist/elements/Hierarchy/ColumnBrowser/ColumnItem/index.css +0 -1
- package/dist/elements/Hierarchy/Tree/TreeNode/index.css +0 -1
- package/dist/elements/InputStepper/index.css +0 -1
- package/dist/elements/Locked/index.css +0 -8
- package/dist/elements/Locked/index.d.ts.map +1 -1
- package/dist/elements/Locked/index.js +70 -64
- package/dist/elements/Locked/index.js.map +1 -1
- package/dist/elements/Nav/SidebarTabs/index.css +0 -5
- package/dist/elements/NavGroup/index.css +0 -1
- package/dist/elements/PreviewButton/index.d.ts +1 -2
- package/dist/elements/PreviewButton/index.d.ts.map +1 -1
- package/dist/elements/PreviewButton/index.js +11 -5
- package/dist/elements/PreviewButton/index.js.map +1 -1
- package/dist/elements/PreviewSizes/index.css +8 -9
- package/dist/elements/ReactSelect/ClearIndicator/index.css +0 -1
- package/dist/elements/ReactSelect/MultiValue/index.css +0 -1
- package/dist/elements/ReactSelect/index.css +0 -3
- package/dist/elements/RelationshipTable/index.d.ts.map +1 -1
- package/dist/elements/RelationshipTable/index.js +32 -0
- package/dist/elements/RelationshipTable/index.js.map +1 -1
- package/dist/elements/SelectRow/index.d.ts +4 -3
- package/dist/elements/SelectRow/index.d.ts.map +1 -1
- package/dist/elements/SelectRow/index.js +10 -7
- package/dist/elements/SelectRow/index.js.map +1 -1
- package/dist/elements/SidebarToggle/index.css +0 -17
- package/dist/elements/SortColumn/index.d.ts.map +1 -1
- package/dist/elements/SortColumn/index.js +42 -38
- package/dist/elements/SortColumn/index.js.map +1 -1
- package/dist/elements/Tooltip/index.css +15 -34
- package/dist/elements/Tooltip/index.d.ts +11 -3
- package/dist/elements/Tooltip/index.d.ts.map +1 -1
- package/dist/elements/Tooltip/index.js +151 -85
- package/dist/elements/Tooltip/index.js.map +1 -1
- package/dist/elements/Upload/index.css +0 -5
- package/dist/exports/client/index.d.ts +3 -0
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +1 -1
- package/dist/exports/client/index.js.map +3 -3
- package/dist/fields/Checkbox/Input.d.ts +2 -0
- package/dist/fields/Checkbox/Input.d.ts.map +1 -1
- package/dist/fields/Checkbox/Input.js +32 -26
- package/dist/fields/Checkbox/Input.js.map +1 -1
- package/dist/fields/Checkbox/index.css +37 -73
- package/dist/fields/FieldError/index.css +0 -9
- package/dist/fields/FieldError/index.d.ts.map +1 -1
- package/dist/fields/FieldError/index.js +19 -9
- package/dist/fields/FieldError/index.js.map +1 -1
- package/dist/fields/RadioGroup/index.css +0 -7
- package/dist/fields/Relationship/Input.d.ts.map +1 -1
- package/dist/fields/Relationship/Input.js +32 -14
- package/dist/fields/Relationship/Input.js.map +1 -1
- package/dist/fields/Slug/index.css +0 -1
- package/dist/fields/Slug/index.d.ts.map +1 -1
- package/dist/fields/Slug/index.js +80 -125
- package/dist/fields/Slug/index.js.map +1 -1
- package/dist/forms/Form/fieldReducer.d.ts.map +1 -1
- package/dist/forms/Form/fieldReducer.js +3 -1
- package/dist/forms/Form/fieldReducer.js.map +1 -1
- package/dist/forms/Form/index.d.ts.map +1 -1
- package/dist/forms/Form/index.js +6 -1
- package/dist/forms/Form/index.js.map +1 -1
- package/dist/forms/Form/types.d.ts +1 -1
- package/dist/forms/Form/types.d.ts.map +1 -1
- package/dist/forms/Form/types.js.map +1 -1
- package/dist/forms/WatchChildErrors/index.d.ts.map +1 -1
- package/dist/forms/WatchChildErrors/index.js +2 -2
- package/dist/forms/WatchChildErrors/index.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/renderField.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/renderField.js +1 -3
- package/dist/forms/fieldSchemasToFormState/renderField.js.map +1 -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 +8 -2
- package/dist/layouts/Root/index.js.map +1 -1
- package/dist/providers/Embed/index.d.ts +24 -0
- package/dist/providers/Embed/index.d.ts.map +1 -0
- package/dist/providers/Embed/index.js +105 -0
- package/dist/providers/Embed/index.js.map +1 -0
- package/dist/providers/FormErrorHandler/index.d.ts +20 -0
- package/dist/providers/FormErrorHandler/index.d.ts.map +1 -0
- package/dist/providers/FormErrorHandler/index.js +6 -0
- package/dist/providers/FormErrorHandler/index.js.map +1 -0
- package/dist/providers/Root/index.d.ts +1 -0
- package/dist/providers/Root/index.d.ts.map +1 -1
- package/dist/providers/Root/index.js +33 -27
- package/dist/providers/Root/index.js.map +1 -1
- package/dist/providers/Theme/index.d.ts +3 -0
- package/dist/providers/Theme/index.d.ts.map +1 -1
- package/dist/providers/Theme/index.js +107 -95
- package/dist/providers/Theme/index.js.map +1 -1
- package/dist/styles.css +12 -10
- package/dist/utilities/combineFieldLabel.d.ts.map +1 -1
- package/dist/utilities/combineFieldLabel.js +5 -1
- package/dist/utilities/combineFieldLabel.js.map +1 -1
- package/dist/utilities/generateFieldID.d.ts +1 -1
- package/dist/utilities/generateFieldID.d.ts.map +1 -1
- package/dist/utilities/generateFieldID.js +2 -2
- package/dist/utilities/generateFieldID.js.map +1 -1
- package/dist/utilities/getRequestEmbed.d.ts +14 -0
- package/dist/utilities/getRequestEmbed.d.ts.map +1 -0
- package/dist/utilities/getRequestEmbed.js +10 -0
- package/dist/utilities/getRequestEmbed.js.map +1 -0
- package/dist/utilities/renderTable.d.ts.map +1 -1
- package/dist/utilities/renderTable.js +18 -2
- package/dist/utilities/renderTable.js.map +1 -1
- package/dist/utilities/slugify.d.ts.map +1 -1
- package/dist/utilities/slugify.js +49 -6
- package/dist/utilities/slugify.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/index.css +0 -8
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/RenderWidget.js +4 -4
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/RenderWidget.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.js +10 -10
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.js.map +1 -1
- package/dist/views/List/index.d.ts.map +1 -1
- package/dist/views/List/index.js +4 -0
- package/dist/views/List/index.js.map +1 -1
- package/package.json +6 -11
- package/dist/scss/app.scss +0 -183
- package/dist/scss/colors.scss +0 -191
- package/dist/scss/custom.css +0 -1
- package/dist/scss/queries.scss +0 -27
- package/dist/scss/styles.scss +0 -9
- package/dist/scss/svg.scss +0 -10
- package/dist/scss/toastify.scss +0 -61
- package/dist/scss/vars.scss +0 -192
- package/dist/scss/z-index.scss +0 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../src/forms/Form/types.ts"],"sourcesContent":["import type {\n ClientField,\n Data,\n FormField,\n FormState,\n Row,\n User,\n ValidationFieldError,\n} from 'payload'\nimport type React from 'react'\nimport type { Dispatch } from 'react'\n\nimport type { AcceptValues } from './mergeServerFormState.js'\n\nexport type Preferences = {\n [key: string]: unknown\n}\n\nexport type FormOnSuccess<T = unknown, C = Record<string, unknown>> = (\n json: T,\n ctx?: {\n /**\n * Arbitrary context passed to the onSuccess callback.\n */\n context?: C\n /**\n * The form state that was sent with the request when retrieving the `json` arg.\n */\n formState?: FormState\n },\n) => Promise<FormState | void> | void\n\nexport type FormProps = {\n beforeSubmit?: ((args: { formState: FormState }) => Promise<FormState>)[]\n children?: React.ReactNode\n className?: string\n disabled?: boolean\n disableSuccessStatus?: boolean\n /**\n * If you would like to solely leverage server-side validation on submit,\n * you can disable checks that the form makes before it submits\n */\n disableValidationOnSubmit?: boolean\n /**\n * If you don't want the form to be a <form> element, you can pass a string here to use as the wrapper element.\n */\n el?: string\n /**\n * By default, the form will get the field schema (not data) from the current document. If you pass this in, you can override that behavior.\n * This is very useful for sub-forms, where the form's field schema is not necessarily the field schema of the current document (e.g. for the Blocks\n * feature of the Lexical Rich Text field)\n */\n fields?: ClientField[]\n handleResponse?: (\n res: Response,\n successToast: (value: string) => void,\n errorToast: (value: string) => void,\n ) => void\n initialState?: FormState\n /**\n * Determines if this Form is the main, top-level Form of a document. If set to true, the\n * Form's children will be wrapped in a DocumentFormContext, which lets you access this document\n * Form's data and fields from any child component - even if that child component is wrapped in a child\n * Form (e.g. a lexical block).\n */\n isDocumentForm?: boolean\n isInitializing?: boolean\n log?: boolean\n onChange?: ((args: { formState: FormState; submitted?: boolean }) => Promise<FormState>)[]\n onSubmit?: (fields: FormState, data: Data) => void\n onSuccess?: FormOnSuccess\n redirect?: string\n submitted?: boolean\n uuid?: string\n validationOperation?: 'create' | 'update'\n waitForAutocomplete?: boolean\n} & (\n | {\n action: (formData: FormData) => Promise<void>\n }\n | {\n action?: string\n method?: 'DELETE' | 'GET' | 'PATCH' | 'POST'\n }\n)\n\nexport type SubmitOptions<C = Record<string, unknown>> = {\n acceptValues?: AcceptValues\n action?: string\n /**\n * If you want to pass additional data to the onSuccess callback, you can use this context object.\n *\n * @experimental This property is experimental and may change in the future.\n */\n context?: C\n /**\n * When true, will disable the form while it is processing.\n * @default true\n */\n disableFormWhileProcessing?: boolean\n /**\n * When true, will disable the success toast after form submission.\n * @default false\n */\n disableSuccessStatus?: boolean\n method?: string\n overrides?: ((formState) => FormData) | Record<string, unknown>\n /**\n * When true, will skip validation before submitting the form.\n * @default false\n */\n skipValidation?: boolean\n}\n\nexport type DispatchFields = React.Dispatch<any>\n\nexport type Submit = <T extends Response, C extends Record<string, unknown>>(\n options?: SubmitOptions<C>,\n e?: React.FormEvent<HTMLFormElement>,\n) => Promise</**\n * Returns the form state and the response from the server.\n *\n * @experimental - Note: the `{ res: ... }` return type is experimental and may change in the future. Use at your own risk.\n */\n{ formState?: FormState; res: T } | void>\n\nexport type ValidateForm = () => Promise<boolean>\n\nexport type CreateFormData = (\n overrides?: Record<string, unknown>,\n /**\n * If mergeOverrideData true, the data will be merged with the existing data in the form state.\n * @default true\n */\n options?: {\n /**\n * If provided, will use this instead of of derived data from the current form state.\n */\n data?: Data\n mergeOverrideData?: boolean\n },\n) => FormData | Promise<FormData>\n\nexport type GetFields = () => FormState\nexport type GetField = (path: string) => FormField\nexport type GetData = () => Data\nexport type GetSiblingData = (path: string) => Data\nexport type GetDataByPath = <T = unknown>(path: string) => T\nexport type SetModified = (modified: boolean) => void\nexport type SetSubmitted = (submitted: boolean) => void\nexport type SetProcessing = (processing: boolean) => void\n\nexport type Reset = (data: unknown) => Promise<void>\n\nexport type REPLACE_STATE = {\n optimize?: boolean\n /**\n * If `sanitize` is true, default values will be set for form field properties that are not present in the incoming state.\n * For example, `valid` will be set to true if it is not present in the incoming state.\n */\n sanitize?: boolean\n state: FormState\n type: 'REPLACE_STATE'\n}\n\nexport type REMOVE = {\n path: string\n type: 'REMOVE'\n}\n\nexport type MODIFY_CONDITION = {\n path: string\n result: boolean\n type: 'MODIFY_CONDITION'\n user: User\n}\n\nexport type UPDATE = {\n path: string\n type: 'UPDATE'\n} & Partial<FormField>\n\nexport type UPDATE_MANY = {\n formState: FormState\n type: 'UPDATE_MANY'\n}\n\nexport type REMOVE_ROW = {\n path: string\n rowIndex: number\n type: 'REMOVE_ROW'\n}\n\nexport type ADD_ROW = {\n blockType?: string\n path: string\n rowIndex?: number\n subFieldState?: FormState\n type: 'ADD_ROW'\n}\n\nexport type MERGE_SERVER_STATE = {\n acceptValues?: AcceptValues\n prevStateRef
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/forms/Form/types.ts"],"sourcesContent":["import type {\n ClientField,\n Data,\n FormField,\n FormState,\n Row,\n User,\n ValidationFieldError,\n} from 'payload'\nimport type React from 'react'\nimport type { Dispatch } from 'react'\n\nimport type { AcceptValues } from './mergeServerFormState.js'\n\nexport type Preferences = {\n [key: string]: unknown\n}\n\nexport type FormOnSuccess<T = unknown, C = Record<string, unknown>> = (\n json: T,\n ctx?: {\n /**\n * Arbitrary context passed to the onSuccess callback.\n */\n context?: C\n /**\n * The form state that was sent with the request when retrieving the `json` arg.\n */\n formState?: FormState\n },\n) => Promise<FormState | void> | void\n\nexport type FormProps = {\n beforeSubmit?: ((args: { formState: FormState }) => Promise<FormState>)[]\n children?: React.ReactNode\n className?: string\n disabled?: boolean\n disableSuccessStatus?: boolean\n /**\n * If you would like to solely leverage server-side validation on submit,\n * you can disable checks that the form makes before it submits\n */\n disableValidationOnSubmit?: boolean\n /**\n * If you don't want the form to be a <form> element, you can pass a string here to use as the wrapper element.\n */\n el?: string\n /**\n * By default, the form will get the field schema (not data) from the current document. If you pass this in, you can override that behavior.\n * This is very useful for sub-forms, where the form's field schema is not necessarily the field schema of the current document (e.g. for the Blocks\n * feature of the Lexical Rich Text field)\n */\n fields?: ClientField[]\n handleResponse?: (\n res: Response,\n successToast: (value: string) => void,\n errorToast: (value: string) => void,\n ) => void\n initialState?: FormState\n /**\n * Determines if this Form is the main, top-level Form of a document. If set to true, the\n * Form's children will be wrapped in a DocumentFormContext, which lets you access this document\n * Form's data and fields from any child component - even if that child component is wrapped in a child\n * Form (e.g. a lexical block).\n */\n isDocumentForm?: boolean\n isInitializing?: boolean\n log?: boolean\n onChange?: ((args: { formState: FormState; submitted?: boolean }) => Promise<FormState>)[]\n onSubmit?: (fields: FormState, data: Data) => void\n onSuccess?: FormOnSuccess\n redirect?: string\n submitted?: boolean\n uuid?: string\n validationOperation?: 'create' | 'update'\n waitForAutocomplete?: boolean\n} & (\n | {\n action: (formData: FormData) => Promise<void>\n }\n | {\n action?: string\n method?: 'DELETE' | 'GET' | 'PATCH' | 'POST'\n }\n)\n\nexport type SubmitOptions<C = Record<string, unknown>> = {\n acceptValues?: AcceptValues\n action?: string\n /**\n * If you want to pass additional data to the onSuccess callback, you can use this context object.\n *\n * @experimental This property is experimental and may change in the future.\n */\n context?: C\n /**\n * When true, will disable the form while it is processing.\n * @default true\n */\n disableFormWhileProcessing?: boolean\n /**\n * When true, will disable the success toast after form submission.\n * @default false\n */\n disableSuccessStatus?: boolean\n method?: string\n overrides?: ((formState) => FormData) | Record<string, unknown>\n /**\n * When true, will skip validation before submitting the form.\n * @default false\n */\n skipValidation?: boolean\n}\n\nexport type DispatchFields = React.Dispatch<any>\n\nexport type Submit = <T extends Response, C extends Record<string, unknown>>(\n options?: SubmitOptions<C>,\n e?: React.FormEvent<HTMLFormElement>,\n) => Promise</**\n * Returns the form state and the response from the server.\n *\n * @experimental - Note: the `{ res: ... }` return type is experimental and may change in the future. Use at your own risk.\n */\n{ formState?: FormState; res: T } | void>\n\nexport type ValidateForm = () => Promise<boolean>\n\nexport type CreateFormData = (\n overrides?: Record<string, unknown>,\n /**\n * If mergeOverrideData true, the data will be merged with the existing data in the form state.\n * @default true\n */\n options?: {\n /**\n * If provided, will use this instead of of derived data from the current form state.\n */\n data?: Data\n mergeOverrideData?: boolean\n },\n) => FormData | Promise<FormData>\n\nexport type GetFields = () => FormState\nexport type GetField = (path: string) => FormField\nexport type GetData = () => Data\nexport type GetSiblingData = (path: string) => Data\nexport type GetDataByPath = <T = unknown>(path: string) => T\nexport type SetModified = (modified: boolean) => void\nexport type SetSubmitted = (submitted: boolean) => void\nexport type SetProcessing = (processing: boolean) => void\n\nexport type Reset = (data: unknown) => Promise<void>\n\nexport type REPLACE_STATE = {\n optimize?: boolean\n /**\n * If `sanitize` is true, default values will be set for form field properties that are not present in the incoming state.\n * For example, `valid` will be set to true if it is not present in the incoming state.\n */\n sanitize?: boolean\n state: FormState\n type: 'REPLACE_STATE'\n}\n\nexport type REMOVE = {\n path: string\n type: 'REMOVE'\n}\n\nexport type MODIFY_CONDITION = {\n path: string\n result: boolean\n type: 'MODIFY_CONDITION'\n user: User\n}\n\nexport type UPDATE = {\n path: string\n type: 'UPDATE'\n} & Partial<FormField>\n\nexport type UPDATE_MANY = {\n formState: FormState\n type: 'UPDATE_MANY'\n}\n\nexport type REMOVE_ROW = {\n path: string\n rowIndex: number\n type: 'REMOVE_ROW'\n}\n\nexport type ADD_ROW = {\n blockType?: string\n path: string\n rowIndex?: number\n subFieldState?: FormState\n type: 'ADD_ROW'\n}\n\nexport type MERGE_SERVER_STATE = {\n acceptValues?: AcceptValues\n prevStateRef?: React.RefObject<FormState>\n serverState: FormState\n type: 'MERGE_SERVER_STATE'\n}\n\nexport type REPLACE_ROW = {\n blockType?: string\n path: string\n rowIndex: number\n subFieldState?: FormState\n type: 'REPLACE_ROW'\n}\n\nexport type DUPLICATE_ROW = {\n path: string\n rowIndex: number\n type: 'DUPLICATE_ROW'\n}\n\nexport type MOVE_ROW = {\n moveFromIndex: number\n moveToIndex: number\n path: string\n type: 'MOVE_ROW'\n}\n\nexport type ADD_SERVER_ERRORS = {\n errors: ValidationFieldError[]\n type: 'ADD_SERVER_ERRORS'\n}\n\nexport type SET_ROW_COLLAPSED = {\n path: string\n type: 'SET_ROW_COLLAPSED'\n updatedRows: Row[]\n}\n\nexport type SET_ALL_ROWS_COLLAPSED = {\n path: string\n type: 'SET_ALL_ROWS_COLLAPSED'\n updatedRows: Row[]\n}\n\nexport type FieldAction =\n | ADD_ROW\n | ADD_SERVER_ERRORS\n | DUPLICATE_ROW\n | MERGE_SERVER_STATE\n | MODIFY_CONDITION\n | MOVE_ROW\n | REMOVE\n | REMOVE_ROW\n | REPLACE_ROW\n | REPLACE_STATE\n | SET_ALL_ROWS_COLLAPSED\n | SET_ROW_COLLAPSED\n | UPDATE\n | UPDATE_MANY\n\nexport type FormFieldsContext = [FormState, Dispatch<FieldAction>]\n\nexport type Context = {\n addFieldRow: ({\n blockType,\n path,\n rowIndex,\n schemaPath,\n subFieldState,\n }: {\n blockType?: string\n path: string\n rowIndex?: number\n schemaPath: string\n subFieldState?: FormState\n }) => void\n buildRowErrors: () => void\n createFormData: CreateFormData\n disabled: boolean\n dispatchFields: Dispatch<FieldAction>\n /**\n * Form context fields may be outdated and should not be relied on. Instead, prefer `useFormFields`.\n */\n fields: FormState\n formRef: React.RefObject<HTMLFormElement>\n getData: GetData\n getDataByPath: GetDataByPath\n getField: GetField\n getFields: GetFields\n getSiblingData: GetSiblingData\n initializing: boolean\n /**\n * Tracks wether the form state passes validation.\n * For example the state could be submitted but invalid as field errors have been returned.\n */\n isValid: boolean\n moveFieldRow: ({\n moveFromIndex,\n moveToIndex,\n path,\n }: {\n moveFromIndex: number\n moveToIndex: number\n path: string\n }) => void\n removeFieldRow: ({ path, rowIndex }: { path: string; rowIndex: number }) => void\n replaceFieldRow: ({\n blockType,\n path,\n rowIndex,\n schemaPath,\n subFieldState,\n }: {\n blockType?: string\n path: string\n rowIndex: number\n schemaPath: string\n subFieldState?: FormState\n }) => void\n replaceState: (state: FormState) => void\n reset: Reset\n /**\n * If the form has started processing in the background (e.g.\n * if autosave is running), this will be true.\n */\n setBackgroundProcessing: SetProcessing\n setDisabled: (disabled: boolean) => void\n setIsValid: (processing: boolean) => void\n setModified: SetModified\n setProcessing: SetProcessing\n setSubmitted: SetSubmitted\n submit: Submit\n uuid?: string\n validateForm: ValidateForm\n}\n"],"mappings":"AAwQA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/forms/WatchChildErrors/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAM9B,KAAK,6BAA6B,GAAG;IACnC,MAAM,CAAC,EAAE,WAAW,EAAE,CAAA;IACtB;;;;;OAKG;IACH,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;IACzB,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;CACvC,CAAA;AACD,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,6BAA6B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/forms/WatchChildErrors/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAM9B,KAAK,6BAA6B,GAAG;IACnC,MAAM,CAAC,EAAE,WAAW,EAAE,CAAA;IACtB;;;;;OAKG;IACH,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;IACzB,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;CACvC,CAAA;AACD,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,6BAA6B,CAgDpE,CAAA"}
|
|
@@ -25,8 +25,8 @@ export const WatchChildErrors = t0 => {
|
|
|
25
25
|
let t2;
|
|
26
26
|
if ($[2] !== formState || $[3] !== hasSubmitted || $[4] !== parentPath || $[5] !== segmentsToMatch || $[6] !== setErrorCount) {
|
|
27
27
|
t2 = () => {
|
|
28
|
+
let errorCount = 0;
|
|
28
29
|
if (hasSubmitted) {
|
|
29
|
-
let errorCount = 0;
|
|
30
30
|
Object.entries(formState).forEach(t3 => {
|
|
31
31
|
const [key] = t3;
|
|
32
32
|
const matchingSegment = segmentsToMatch?.some(segment => {
|
|
@@ -45,8 +45,8 @@ export const WatchChildErrors = t0 => {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
|
-
setErrorCount(errorCount);
|
|
49
48
|
}
|
|
49
|
+
setErrorCount(errorCount);
|
|
50
50
|
};
|
|
51
51
|
$[2] = formState;
|
|
52
52
|
$[3] = hasSubmitted;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","useThrottledEffect","useAllFormFields","useFormSubmitted","buildPathSegments","WatchChildErrors","t0","$","fields","path","parentPath","setErrorCount","formState","hasSubmitted","t1","segmentsToMatch","t2","errorCount","Object","entries","forEach","t3","key","matchingSegment","some","segment","segmentToMatch","join","endsWith","pathWithoutDot","slice","startsWith","pathState","valid"],"sources":["../../../src/forms/WatchChildErrors/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientField } from 'payload'\nimport type React from 'react'\n\nimport { useThrottledEffect } from '../../hooks/useThrottledEffect.js'\nimport { useAllFormFields, useFormSubmitted } from '../Form/context.js'\nimport { buildPathSegments } from './buildPathSegments.js'\n\ntype TrackSubSchemaErrorCountProps = {\n fields?: ClientField[]\n /**\n * This path should only include path segments that affect data\n * i.e. it should not include _index-0 type segments\n *\n * For collapsibles and tabs you can simply pass their parent path\n */\n path: (number | string)[]\n setErrorCount: (count: number) => void\n}\nexport const WatchChildErrors: React.FC<TrackSubSchemaErrorCountProps> = ({\n fields,\n path: parentPath,\n setErrorCount,\n}) => {\n const [formState] = useAllFormFields()\n const hasSubmitted = useFormSubmitted()\n\n const segmentsToMatch = buildPathSegments(fields)\n\n useThrottledEffect(\n () => {\n
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","useThrottledEffect","useAllFormFields","useFormSubmitted","buildPathSegments","WatchChildErrors","t0","$","fields","path","parentPath","setErrorCount","formState","hasSubmitted","t1","segmentsToMatch","t2","errorCount","Object","entries","forEach","t3","key","matchingSegment","some","segment","segmentToMatch","join","endsWith","pathWithoutDot","slice","startsWith","pathState","valid"],"sources":["../../../src/forms/WatchChildErrors/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientField } from 'payload'\nimport type React from 'react'\n\nimport { useThrottledEffect } from '../../hooks/useThrottledEffect.js'\nimport { useAllFormFields, useFormSubmitted } from '../Form/context.js'\nimport { buildPathSegments } from './buildPathSegments.js'\n\ntype TrackSubSchemaErrorCountProps = {\n fields?: ClientField[]\n /**\n * This path should only include path segments that affect data\n * i.e. it should not include _index-0 type segments\n *\n * For collapsibles and tabs you can simply pass their parent path\n */\n path: (number | string)[]\n setErrorCount: (count: number) => void\n}\nexport const WatchChildErrors: React.FC<TrackSubSchemaErrorCountProps> = ({\n fields,\n path: parentPath,\n setErrorCount,\n}) => {\n const [formState] = useAllFormFields()\n const hasSubmitted = useFormSubmitted()\n\n const segmentsToMatch = buildPathSegments(fields)\n\n useThrottledEffect(\n () => {\n // Errors are only surfaced after a submit attempt. Once the form is no longer\n // submitted (e.g. after a successful save resets the submitted flag), reset the\n // count to 0 so stale error indicators don't linger on the tab.\n let errorCount = 0\n\n if (hasSubmitted) {\n Object.entries(formState).forEach(([key]) => {\n const matchingSegment = segmentsToMatch?.some((segment) => {\n const segmentToMatch = [...parentPath, segment].join('.')\n // match fields with same parent path\n if (segmentToMatch.endsWith('.')) {\n // Match both nested fields (key starts with segmentToMatch)\n // and the field itself (key equals segmentToMatch without trailing dot)\n const pathWithoutDot = segmentToMatch.slice(0, -1)\n return key.startsWith(segmentToMatch) || key === pathWithoutDot\n }\n // match fields with same path\n return key === segmentToMatch\n })\n\n if (matchingSegment) {\n const pathState = formState[key]\n if ('valid' in pathState && !pathState.valid) {\n errorCount += 1\n }\n }\n })\n }\n\n setErrorCount(errorCount)\n },\n 250,\n [formState, hasSubmitted, fields],\n )\n\n return null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAIA,SAASC,kBAAkB,QAAQ;AACnC,SAASC,gBAAgB,EAAEC,gBAAgB,QAAQ;AACnD,SAASC,iBAAiB,QAAQ;AAalC,OAAO,MAAMC,gBAAA,GAA4DC,EAAA;EAAA,MAAAC,CAAA,GAAAP,EAAA;EAAC;IAAAQ,MAAA;IAAAC,IAAA,EAAAC,UAAA;IAAAC;EAAA,IAAAL,EAIzE;EACC,OAAAM,SAAA,IAAoBV,gBAAA;EACpB,MAAAW,YAAA,GAAqBV,gBAAA;EAAA,IAAAW,EAAA;EAAA,IAAAP,CAAA,QAAAC,MAAA;IAEGM,EAAA,GAAAV,iBAAA,CAAkBI,MAAA;IAAAD,CAAA,MAAAC,MAAA;IAAAD,CAAA,MAAAO,EAAA;EAAA;IAAAA,EAAA,GAAAP,CAAA;EAAA;EAA1C,MAAAQ,eAAA,GAAwBD,EAAkB;EAAA,IAAAE,EAAA;EAAA,IAAAT,CAAA,QAAAK,SAAA,IAAAL,CAAA,QAAAM,YAAA,IAAAN,CAAA,QAAAG,UAAA,IAAAH,CAAA,QAAAQ,eAAA,IAAAR,CAAA,QAAAI,aAAA;IAGxCK,EAAA,GAAAA,CAAA;MAIE,IAAAC,UAAA;MAAiB,IAEbJ,YAAA;QACFK,MAAA,CAAAC,OAAA,CAAeP,SAAA,EAAAQ,OAAA,CAAAC,EAAA;UAAoB,OAAAC,GAAA,IAAAD,EAAK;UACtC,MAAAE,eAAA,GAAwBR,eAAA,EAAAS,IAAA,CAAAC,OAAA;YACtB,MAAAC,cAAA,GAAuB,IAAIhB,UAAA,EAAYe,OAAA,EAAAE,IAAA,CAAc;YAAA,IAEjDD,cAAA,CAAAE,QAAA,CAAwB;cAG1B,MAAAC,cAAA,GAAuBH,cAAA,CAAAI,KAAA,MAAyB;cAAA,OACzCR,GAAA,CAAAS,UAAA,CAAeL,cAAA,KAAmBJ,GAAA,KAAQO,cAAA;YAAA;YAAA,OAG5CP,GAAA,KAAQI,cAAA;UAAA;UACjB,IAEIH,eAAA;YACF,MAAAS,SAAA,GAAkBpB,SAAS,CAACU,GAAA;YAAI,IAC5B,WAAWU,SAAA,KAAcA,SAAA,CAAAC,KAAe;cAC1ChB,UAAA,GAAAA,UAAA,IAAc;cAAdA,UAAA;YAAA;UAAA;QAAA,CAGN;MAAA;MAGFN,aAAA,CAAcM,UAAA;IAAA;IAChBV,CAAA,MAAAK,SAAA;IAAAL,CAAA,MAAAM,YAAA;IAAAN,CAAA,MAAAG,UAAA;IAAAH,CAAA,MAAAQ,eAAA;IAAAR,CAAA,MAAAI,aAAA;IAAAJ,CAAA,MAAAS,EAAA;EAAA;IAAAA,EAAA,GAAAT,CAAA;EAAA;EAAA,IAAAc,EAAA;EAAA,IAAAd,CAAA,QAAAC,MAAA,IAAAD,CAAA,QAAAK,SAAA,IAAAL,CAAA,SAAAM,YAAA;IAEAQ,EAAA,IAACT,SAAA,EAAWC,YAAA,EAAcL,MAAA;IAAOD,CAAA,MAAAC,MAAA;IAAAD,CAAA,MAAAK,SAAA;IAAAL,CAAA,OAAAM,YAAA;IAAAN,CAAA,OAAAc,EAAA;EAAA;IAAAA,EAAA,GAAAd,CAAA;EAAA;EAlCnCN,kBAAA,CACEe,EA+BA,OAEAK,EAAiC;EAAA;AAAA,CAIrC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
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;AAcnD,eAAO,MAAM,WAAW,EAAE,
|
|
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;AAcnD,eAAO,MAAM,WAAW,EAAE,iBAsXzB,CAAA"}
|
|
@@ -31,9 +31,7 @@ export const renderField = ({
|
|
|
31
31
|
schemaPath,
|
|
32
32
|
siblingData
|
|
33
33
|
}) => {
|
|
34
|
-
|
|
35
|
-
const hasBeforeOrAfterInput = fieldConfig.admin?.components && ('beforeInput' in fieldConfig.admin.components || 'afterInput' in fieldConfig.admin.components);
|
|
36
|
-
const requiresRender = renderAllFields || !lastRenderedPath || lastRenderedPath !== path || hasBeforeOrAfterInput;
|
|
34
|
+
const requiresRender = renderAllFields || !lastRenderedPath || lastRenderedPath !== path;
|
|
37
35
|
if (!requiresRender && fieldConfig.type !== 'array' && fieldConfig.type !== 'blocks') {
|
|
38
36
|
return;
|
|
39
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderField.js","names":["getTranslation","createClientField","MissingEditorProp","fieldIsHiddenOrDisabled","RenderServerComponent","FieldDescription","WatchCondition","defaultUIFieldComponentKeys","renderField","id","clientFieldSchemaMap","collectionSlug","data","fieldConfig","fieldSchemaMap","fieldState","forceCreateClientField","formState","indexPath","lastRenderedPath","mockRSCs","operation","parentPath","parentSchemaPath","path","permissions","preferences","readOnly","readOnlyFromProps","renderAllFields","req","schemaPath","siblingData","hasBeforeOrAfterInput","admin","components","requiresRender","type","clientField","get","defaultIDType","payload","config","db","field","i18n","importMap","clientProps","customComponents","includes","serverProps","user","value","name","rows","forEach","row","rowIndex","rowLastRenderedPath","rowPath","rowRequiresRender","RowLabel","Component","key","rowLabel","labels","singular","String","padStart","rowNumber","blockTypeToMatch","blockType","blockConfig","blocks","find","block","slug","Label","Object","keys","length","description","editor","Error","Field","_jsx","FieldComponent","sanitizedEditorConfig","editorConfig","undefined","Description","t","AfterInput","afterInput","BeforeInput","beforeInput"],"sources":["../../../src/forms/fieldSchemasToFormState/renderField.tsx"],"sourcesContent":["import type {\n ClientComponentProps,\n ClientField,\n FieldPaths,\n FlattenedBlock,\n ServerComponentProps,\n} from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { createClientField, MissingEditorProp } from 'payload'\nimport { fieldIsHiddenOrDisabled } from 'payload/shared'\n\nimport type { RenderFieldMethod } from './types.js'\n\nimport { RenderServerComponent } from '../../elements/RenderServerComponent/index.js'\n\n// eslint-disable-next-line payload/no-imports-from-exports-dir -- MUST reference the exports dir: https://github.com/payloadcms/payload/issues/12002#issuecomment-2791493587\nimport { FieldDescription, WatchCondition } 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 clientFieldSchemaMap,\n collectionSlug,\n data,\n fieldConfig,\n fieldSchemaMap,\n fieldState,\n forceCreateClientField,\n formState,\n indexPath,\n lastRenderedPath,\n mockRSCs,\n operation,\n parentPath,\n parentSchemaPath,\n path,\n permissions,\n preferences,\n readOnly: readOnlyFromProps,\n renderAllFields,\n req,\n schemaPath,\n siblingData,\n}) => {\n // Fields with beforeInput/afterInput need custom components created, so they require render\n const hasBeforeOrAfterInput =\n fieldConfig.admin?.components &&\n ('beforeInput' in fieldConfig.admin.components || 'afterInput' in fieldConfig.admin.components)\n\n const requiresRender =\n renderAllFields || !lastRenderedPath || lastRenderedPath !== path || hasBeforeOrAfterInput\n\n if (!requiresRender && fieldConfig.type !== 'array' && fieldConfig.type !== 'blocks') {\n return\n }\n\n const clientField =\n clientFieldSchemaMap && !forceCreateClientField\n ? (clientFieldSchemaMap.get(schemaPath) as ClientField)\n : createClientField({\n defaultIDType: req.payload.config.db.defaultIDType,\n field: fieldConfig,\n i18n: req.i18n,\n importMap: req.payload.importMap,\n })\n\n const clientProps: ClientComponentProps & Partial<FieldPaths> = {\n field: clientField,\n path,\n permissions,\n readOnly:\n readOnlyFromProps === true\n ? true\n : typeof permissions === 'boolean'\n ? !permissions\n : !permissions?.[operation],\n schemaPath,\n }\n\n if (fieldState?.customComponents) {\n clientProps.customComponents = fieldState.customComponents\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 clientFieldSchemaMap,\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 value: 'name' in fieldConfig && data?.[fieldConfig.name],\n }\n\n switch (fieldConfig.type) {\n case 'array': {\n fieldState?.rows?.forEach((row, rowIndex) => {\n const rowLastRenderedPath = row.lastRenderedPath\n\n const rowPath = `${path}.${rowIndex}`\n\n const rowRequiresRender =\n renderAllFields || !rowLastRenderedPath || rowLastRenderedPath !== rowPath\n\n if (!rowRequiresRender) {\n return\n }\n\n row.lastRenderedPath = rowPath\n\n if (fieldConfig.admin?.components && 'RowLabel' in fieldConfig.admin.components) {\n if (!row.customComponents) {\n row.customComponents = {}\n }\n\n row.customComponents.RowLabel = !mockRSCs\n ? RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.RowLabel,\n importMap: req.payload.importMap,\n key: `${rowIndex}`,\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 : 'Mock'\n }\n })\n\n break\n }\n\n case 'blocks': {\n fieldState?.rows?.forEach((row, rowIndex) => {\n const rowLastRenderedPath = row.lastRenderedPath\n\n const rowPath = `${path}.${rowIndex}`\n\n const rowRequiresRender =\n renderAllFields || !rowLastRenderedPath || rowLastRenderedPath !== rowPath\n\n if (!rowRequiresRender) {\n return\n }\n\n row.lastRenderedPath = rowPath\n\n const blockTypeToMatch: string = row.blockType\n\n const blockConfig =\n req.payload.blocks[blockTypeToMatch] ??\n (fieldConfig.blocks.find(\n (block) => typeof block !== 'string' && block.slug === blockTypeToMatch,\n ) as FlattenedBlock | undefined)\n\n if (blockConfig.admin?.components && 'Label' in blockConfig.admin.components) {\n if (!fieldState.rows[rowIndex]?.customComponents) {\n fieldState.rows[rowIndex].customComponents = {}\n }\n\n fieldState.rows[rowIndex].customComponents.RowLabel = !mockRSCs\n ? RenderServerComponent({\n clientProps,\n Component: blockConfig.admin.components.Label,\n importMap: req.payload.importMap,\n key: `${rowIndex}`,\n serverProps: {\n ...serverProps,\n blockType: row.blockType,\n rowLabel: `${getTranslation(blockConfig.labels.singular, req.i18n)} ${String(\n rowIndex + 1,\n ).padStart(2, '0')}`,\n rowNumber: rowIndex + 1,\n },\n })\n : 'Mock'\n }\n })\n\n break\n }\n }\n\n if (!requiresRender) {\n return\n }\n\n /**\n * Set the `lastRenderedPath` equal to the new path of the field, this will prevent it from being rendered again\n */\n fieldState.lastRenderedPath = path\n\n if (fieldIsHiddenOrDisabled(clientField)) {\n return\n }\n\n /**\n * Only create the `customComponents` object if needed.\n * This will prevent unnecessary data from being transferred to the client.\n */\n if (fieldConfig.admin) {\n if (\n (Object.keys(fieldConfig.admin.components || {}).length > 0 ||\n fieldConfig.type === 'richText' ||\n ('description' in fieldConfig.admin &&\n typeof fieldConfig.admin.description === 'function')) &&\n !fieldState?.customComponents\n ) {\n fieldState.customComponents = {}\n }\n }\n\n switch (fieldConfig.type) {\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 = !mockRSCs ? (\n <WatchCondition path={path}>\n {RenderServerComponent({\n clientProps,\n Component: fieldConfig.editor.FieldComponent,\n importMap: req.payload.importMap,\n serverProps: {\n ...serverProps,\n // Manually inject lexical-specific `sanitizedEditorConfig` server prop, in order to reduce the size of the field schema.\n // Otherwise, the editorConfig would be included twice - once on the top-level, and once as part of the `FieldComponent` server props.\n sanitizedEditorConfig:\n 'editorConfig' in fieldConfig.editor ? fieldConfig.editor.editorConfig : undefined,\n },\n })}\n </WatchCondition>\n ) : (\n 'Mock'\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\n const Component = fieldConfig.admin.components[key]\n\n fieldState.customComponents[key] = !mockRSCs\n ? RenderServerComponent({\n clientProps,\n Component,\n importMap: req.payload.importMap,\n key: `field.admin.components.${key}`,\n serverProps,\n })\n : 'Mock'\n }\n }\n break\n }\n\n default: {\n break\n }\n }\n\n if (fieldConfig.admin) {\n if (\n 'description' in fieldConfig.admin &&\n typeof fieldConfig.admin?.description === 'function'\n ) {\n fieldState.customComponents.Description = !mockRSCs ? (\n <FieldDescription\n description={fieldConfig.admin?.description({\n i18n: req.i18n,\n t: req.i18n.t,\n })}\n path={path}\n />\n ) : (\n 'Mock'\n )\n }\n\n if (fieldConfig.admin?.components) {\n if ('afterInput' in fieldConfig.admin.components) {\n fieldState.customComponents.AfterInput = !mockRSCs\n ? RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.afterInput,\n importMap: req.payload.importMap,\n key: `field.admin.components.afterInput.${path}`,\n serverProps,\n })\n : 'Mock'\n }\n\n if ('beforeInput' in fieldConfig.admin.components) {\n fieldState.customComponents.BeforeInput = !mockRSCs\n ? RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.beforeInput,\n importMap: req.payload.importMap,\n key: `field.admin.components.beforeInput.${path}`,\n serverProps,\n })\n : 'Mock'\n }\n\n if ('Description' in fieldConfig.admin.components) {\n fieldState.customComponents.Description = !mockRSCs\n ? RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.Description,\n importMap: req.payload.importMap,\n key: 'field.admin.components.Description',\n serverProps,\n })\n : 'Mock'\n }\n\n if ('Error' in fieldConfig.admin.components) {\n fieldState.customComponents.Error = !mockRSCs\n ? RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.Error,\n importMap: req.payload.importMap,\n key: 'field.admin.components.Error',\n serverProps,\n })\n : 'Mock'\n }\n\n if ('Label' in fieldConfig.admin.components) {\n fieldState.customComponents.Label = !mockRSCs\n ? RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.Label,\n importMap: req.payload.importMap,\n key: 'field.admin.components.Label',\n serverProps,\n })\n : 'Mock'\n }\n\n if ('Field' in fieldConfig.admin.components) {\n fieldState.customComponents.Field = !mockRSCs ? (\n <WatchCondition path={path}>\n {RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.Field,\n importMap: req.payload.importMap,\n key: 'field.admin.components.Field',\n serverProps,\n })}\n </WatchCondition>\n ) : (\n 'Mock'\n )\n }\n }\n }\n}\n"],"mappings":";AAQA,SAASA,cAAc,QAAQ;AAC/B,SAASC,iBAAiB,EAAEC,iBAAiB,QAAQ;AACrD,SAASC,uBAAuB,QAAQ;AAIxC,SAASC,qBAAqB,QAAQ;AAEtC;AACA,SAASC,gBAAgB,EAAEC,cAAc,QAAQ;AAEjD,MAAMC,2BAAA,GAAkF,CACtF,QACA,eACA,SACA,SACD;AAED,OAAO,MAAMC,WAAA,GAAiCA,CAAC;EAC7CC,EAAE;EACFC,oBAAoB;EACpBC,cAAc;EACdC,IAAI;EACJC,WAAW;EACXC,cAAc;EACdC,UAAU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KAAK;UAC7C/B,SAAA,EAAWhB,GAAA,CAAIW,OAAO,CAACK,SAAS;UAChCiB,GAAA,EAAK;UACLb;QACF,KACA;MACN;MAEA,IAAI,WAAWrC,WAAA,CAAYqB,KAAK,CAACC,UAAU,EAAE;QAC3CpB,UAAA,CAAWiC,gBAAgB,CAACoC,KAAK,GAAG,CAAChE,QAAA,gBACnCiE,IAAA,CAAC/E,cAAA;UAAekB,IAAA,EAAMA,IAAA;oBACnBpB,qBAAA,CAAsB;YACrB2C,WAAA;YACAe,SAAA,EAAWjD,WAAA,CAAYqB,KAAK,CAACC,UAAU,CAACiD,KAAK;YAC7CtC,SAAA,EAAWhB,GAAA,CAAIW,OAAO,CAACK,SAAS;YAChCiB,GAAA,EAAK;YACLb;UACF;aAGF;MAEJ;IACF;EACF;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"renderField.js","names":["getTranslation","createClientField","MissingEditorProp","fieldIsHiddenOrDisabled","RenderServerComponent","FieldDescription","WatchCondition","defaultUIFieldComponentKeys","renderField","id","clientFieldSchemaMap","collectionSlug","data","fieldConfig","fieldSchemaMap","fieldState","forceCreateClientField","formState","indexPath","lastRenderedPath","mockRSCs","operation","parentPath","parentSchemaPath","path","permissions","preferences","readOnly","readOnlyFromProps","renderAllFields","req","schemaPath","siblingData","requiresRender","type","clientField","get","defaultIDType","payload","config","db","field","i18n","importMap","clientProps","customComponents","includes","serverProps","user","value","name","rows","forEach","row","rowIndex","rowLastRenderedPath","rowPath","rowRequiresRender","admin","components","RowLabel","Component","key","rowLabel","labels","singular","String","padStart","rowNumber","blockTypeToMatch","blockType","blockConfig","blocks","find","block","slug","Label","Object","keys","length","description","editor","Error","Field","_jsx","FieldComponent","sanitizedEditorConfig","editorConfig","undefined","Description","t","AfterInput","afterInput","BeforeInput","beforeInput"],"sources":["../../../src/forms/fieldSchemasToFormState/renderField.tsx"],"sourcesContent":["import type {\n ClientComponentProps,\n ClientField,\n FieldPaths,\n FlattenedBlock,\n ServerComponentProps,\n} from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { createClientField, MissingEditorProp } from 'payload'\nimport { fieldIsHiddenOrDisabled } from 'payload/shared'\n\nimport type { RenderFieldMethod } from './types.js'\n\nimport { RenderServerComponent } from '../../elements/RenderServerComponent/index.js'\n\n// eslint-disable-next-line payload/no-imports-from-exports-dir -- MUST reference the exports dir: https://github.com/payloadcms/payload/issues/12002#issuecomment-2791493587\nimport { FieldDescription, WatchCondition } 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 clientFieldSchemaMap,\n collectionSlug,\n data,\n fieldConfig,\n fieldSchemaMap,\n fieldState,\n forceCreateClientField,\n formState,\n indexPath,\n lastRenderedPath,\n mockRSCs,\n operation,\n parentPath,\n parentSchemaPath,\n path,\n permissions,\n preferences,\n readOnly: readOnlyFromProps,\n renderAllFields,\n req,\n schemaPath,\n siblingData,\n}) => {\n const requiresRender = renderAllFields || !lastRenderedPath || lastRenderedPath !== path\n\n if (!requiresRender && fieldConfig.type !== 'array' && fieldConfig.type !== 'blocks') {\n return\n }\n\n const clientField =\n clientFieldSchemaMap && !forceCreateClientField\n ? (clientFieldSchemaMap.get(schemaPath) as ClientField)\n : createClientField({\n defaultIDType: req.payload.config.db.defaultIDType,\n field: fieldConfig,\n i18n: req.i18n,\n importMap: req.payload.importMap,\n })\n\n const clientProps: ClientComponentProps & Partial<FieldPaths> = {\n field: clientField,\n path,\n permissions,\n readOnly:\n readOnlyFromProps === true\n ? true\n : typeof permissions === 'boolean'\n ? !permissions\n : !permissions?.[operation],\n schemaPath,\n }\n\n if (fieldState?.customComponents) {\n clientProps.customComponents = fieldState.customComponents\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 clientFieldSchemaMap,\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 value: 'name' in fieldConfig && data?.[fieldConfig.name],\n }\n\n switch (fieldConfig.type) {\n case 'array': {\n fieldState?.rows?.forEach((row, rowIndex) => {\n const rowLastRenderedPath = row.lastRenderedPath\n\n const rowPath = `${path}.${rowIndex}`\n\n const rowRequiresRender =\n renderAllFields || !rowLastRenderedPath || rowLastRenderedPath !== rowPath\n\n if (!rowRequiresRender) {\n return\n }\n\n row.lastRenderedPath = rowPath\n\n if (fieldConfig.admin?.components && 'RowLabel' in fieldConfig.admin.components) {\n if (!row.customComponents) {\n row.customComponents = {}\n }\n\n row.customComponents.RowLabel = !mockRSCs\n ? RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.RowLabel,\n importMap: req.payload.importMap,\n key: `${rowIndex}`,\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 : 'Mock'\n }\n })\n\n break\n }\n\n case 'blocks': {\n fieldState?.rows?.forEach((row, rowIndex) => {\n const rowLastRenderedPath = row.lastRenderedPath\n\n const rowPath = `${path}.${rowIndex}`\n\n const rowRequiresRender =\n renderAllFields || !rowLastRenderedPath || rowLastRenderedPath !== rowPath\n\n if (!rowRequiresRender) {\n return\n }\n\n row.lastRenderedPath = rowPath\n\n const blockTypeToMatch: string = row.blockType\n\n const blockConfig =\n req.payload.blocks[blockTypeToMatch] ??\n (fieldConfig.blocks.find(\n (block) => typeof block !== 'string' && block.slug === blockTypeToMatch,\n ) as FlattenedBlock | undefined)\n\n if (blockConfig.admin?.components && 'Label' in blockConfig.admin.components) {\n if (!fieldState.rows[rowIndex]?.customComponents) {\n fieldState.rows[rowIndex].customComponents = {}\n }\n\n fieldState.rows[rowIndex].customComponents.RowLabel = !mockRSCs\n ? RenderServerComponent({\n clientProps,\n Component: blockConfig.admin.components.Label,\n importMap: req.payload.importMap,\n key: `${rowIndex}`,\n serverProps: {\n ...serverProps,\n blockType: row.blockType,\n rowLabel: `${getTranslation(blockConfig.labels.singular, req.i18n)} ${String(\n rowIndex + 1,\n ).padStart(2, '0')}`,\n rowNumber: rowIndex + 1,\n },\n })\n : 'Mock'\n }\n })\n\n break\n }\n }\n\n if (!requiresRender) {\n return\n }\n\n /**\n * Set the `lastRenderedPath` equal to the new path of the field, this will prevent it from being rendered again\n */\n fieldState.lastRenderedPath = path\n\n if (fieldIsHiddenOrDisabled(clientField)) {\n return\n }\n\n /**\n * Only create the `customComponents` object if needed.\n * This will prevent unnecessary data from being transferred to the client.\n */\n if (fieldConfig.admin) {\n if (\n (Object.keys(fieldConfig.admin.components || {}).length > 0 ||\n fieldConfig.type === 'richText' ||\n ('description' in fieldConfig.admin &&\n typeof fieldConfig.admin.description === 'function')) &&\n !fieldState?.customComponents\n ) {\n fieldState.customComponents = {}\n }\n }\n\n switch (fieldConfig.type) {\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 = !mockRSCs ? (\n <WatchCondition path={path}>\n {RenderServerComponent({\n clientProps,\n Component: fieldConfig.editor.FieldComponent,\n importMap: req.payload.importMap,\n serverProps: {\n ...serverProps,\n // Manually inject lexical-specific `sanitizedEditorConfig` server prop, in order to reduce the size of the field schema.\n // Otherwise, the editorConfig would be included twice - once on the top-level, and once as part of the `FieldComponent` server props.\n sanitizedEditorConfig:\n 'editorConfig' in fieldConfig.editor ? fieldConfig.editor.editorConfig : undefined,\n },\n })}\n </WatchCondition>\n ) : (\n 'Mock'\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\n const Component = fieldConfig.admin.components[key]\n\n fieldState.customComponents[key] = !mockRSCs\n ? RenderServerComponent({\n clientProps,\n Component,\n importMap: req.payload.importMap,\n key: `field.admin.components.${key}`,\n serverProps,\n })\n : 'Mock'\n }\n }\n break\n }\n\n default: {\n break\n }\n }\n\n if (fieldConfig.admin) {\n if (\n 'description' in fieldConfig.admin &&\n typeof fieldConfig.admin?.description === 'function'\n ) {\n fieldState.customComponents.Description = !mockRSCs ? (\n <FieldDescription\n description={fieldConfig.admin?.description({\n i18n: req.i18n,\n t: req.i18n.t,\n })}\n path={path}\n />\n ) : (\n 'Mock'\n )\n }\n\n if (fieldConfig.admin?.components) {\n if ('afterInput' in fieldConfig.admin.components) {\n fieldState.customComponents.AfterInput = !mockRSCs\n ? RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.afterInput,\n importMap: req.payload.importMap,\n key: `field.admin.components.afterInput.${path}`,\n serverProps,\n })\n : 'Mock'\n }\n\n if ('beforeInput' in fieldConfig.admin.components) {\n fieldState.customComponents.BeforeInput = !mockRSCs\n ? RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.beforeInput,\n importMap: req.payload.importMap,\n key: `field.admin.components.beforeInput.${path}`,\n serverProps,\n })\n : 'Mock'\n }\n\n if ('Description' in fieldConfig.admin.components) {\n fieldState.customComponents.Description = !mockRSCs\n ? RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.Description,\n importMap: req.payload.importMap,\n key: 'field.admin.components.Description',\n serverProps,\n })\n : 'Mock'\n }\n\n if ('Error' in fieldConfig.admin.components) {\n fieldState.customComponents.Error = !mockRSCs\n ? RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.Error,\n importMap: req.payload.importMap,\n key: 'field.admin.components.Error',\n serverProps,\n })\n : 'Mock'\n }\n\n if ('Label' in fieldConfig.admin.components) {\n fieldState.customComponents.Label = !mockRSCs\n ? RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.Label,\n importMap: req.payload.importMap,\n key: 'field.admin.components.Label',\n serverProps,\n })\n : 'Mock'\n }\n\n if ('Field' in fieldConfig.admin.components) {\n fieldState.customComponents.Field = !mockRSCs ? (\n <WatchCondition path={path}>\n {RenderServerComponent({\n clientProps,\n Component: fieldConfig.admin.components.Field,\n importMap: req.payload.importMap,\n key: 'field.admin.components.Field',\n serverProps,\n })}\n </WatchCondition>\n ) : (\n 'Mock'\n )\n }\n }\n }\n}\n"],"mappings":";AAQA,SAASA,cAAc,QAAQ;AAC/B,SAASC,iBAAiB,EAAEC,iBAAiB,QAAQ;AACrD,SAASC,uBAAuB,QAAQ;AAIxC,SAASC,qBAAqB,QAAQ;AAEtC;AACA,SAASC,gBAAgB,EAAEC,cAAc,QAAQ;AAEjD,MAAMC,2BAAA,GAAkF,CACtF,QACA,eACA,SACA,SACD;AAED,OAAO,MAAMC,WAAA,GAAiCA,CAAC;EAC7CC,EAAE;EACFC,oBAAoB;EACpBC,cAAc;EACdC,IAAI;EACJC,WAAW;EACXC,cAAc;EACdC,UAAU;EACVC,sBAAsB;EACtBC,SAAS;EACTC,SAAS;EACTC,gBAAgB;EAChBC,QAAQ;EACRC,SAAS;EACTC,UAAU;EACVC,gBAAgB;EAChBC,IAAI;EACJC,WAAW;EACXC,WAAW;EACXC,QAAA,EAAUC,iBAAiB;EAC3BC,eAAe;EACfC,GAAG;EACHC,UAAU;EACVC;AAAW,CACZ;EACC,MAAMC,cAAA,GAAiBJ,eAAA,IAAmB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SAAS;YAChCmB,GAAA,EAAK;YACLf;UACF;aAGF;MAEJ;IACF;EACF;AACF","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ImportMap, SanitizedConfig, ServerAdapter, ServerFunctionClient } from 'payload';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { type CheckDependenciesArgs } from '../../utilities/checkDependencies.js';
|
|
4
|
-
import '@payloadcms/ui/
|
|
4
|
+
import '@payloadcms/ui/css/app.css';
|
|
5
5
|
type Font = {
|
|
6
6
|
className?: string;
|
|
7
7
|
variable?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/layouts/Root/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EAET,eAAe,EACf,aAAa,EACb,oBAAoB,EACrB,MAAM,SAAS,CAAA;AAGhB,OAAO,KAAmB,MAAM,OAAO,CAAA;AAKvC,OAAO,EAAqB,KAAK,qBAAqB,EAAE,MAAM,sCAAsC,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/layouts/Root/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EAET,eAAe,EACf,aAAa,EACb,oBAAoB,EACrB,MAAM,SAAS,CAAA;AAGhB,OAAO,KAAmB,MAAM,OAAO,CAAA;AAKvC,OAAO,EAAqB,KAAK,qBAAqB,EAAE,MAAM,sCAAsC,CAAA;AAUpG,OAAO,4BAA4B,CAAA;AAEnC,KAAK,IAAI,GAAG;IACV,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,QAAQ;IACnB,WAAW;IACX,KAAK;CACN,CAAA;AAED,KAAK,eAAe,GAAG;IACrB;;;;OAIG;IACH,QAAQ,CAAC,0BAA0B,CAAC,EAAE,qBAAqB,CAAA;IAC3D,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IAClC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,CAAA;IACzC;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAA;IACvB;;;;;;;;;;;;;;;OAeG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC/B,QAAQ,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAA;IAC9D,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;IAC7B;;;OAGG;IACH,QAAQ,CAAC,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;KAAE,CAAC,CAAA;IAC/D;;;OAGG;IACH,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAA;IACrC,QAAQ,CAAC,cAAc,EAAE,oBAAoB,CAAA;CAC9C,CAAA;AAED,eAAO,MAAM,UAAU,UAAW,eAAe,sBAUhD,CAAA"}
|
|
@@ -7,13 +7,14 @@ import { ProgressBar, RootProvider } from '../../exports/client/index.js';
|
|
|
7
7
|
import { checkDependencies } from '../../utilities/checkDependencies.js';
|
|
8
8
|
import { getClientConfig } from '../../utilities/getClientConfig.js';
|
|
9
9
|
import { getLanguageDir } from '../../utilities/getLanguageDir.js';
|
|
10
|
+
import { getRequestEmbed } from '../../utilities/getRequestEmbed.js';
|
|
10
11
|
import { getRequestHighContrast } from '../../utilities/getRequestHighContrast.js';
|
|
11
12
|
import { getRequestTheme } from '../../utilities/getRequestTheme.js';
|
|
12
13
|
import { initReq } from '../../utilities/initReq.js';
|
|
13
14
|
import { NestProviders } from './NestProviders.js';
|
|
14
15
|
import { getViewportMeta } from './viewport.js';
|
|
15
|
-
// eslint-disable-next-line payload/no-imports-from-self -- Self-import via package path ensures consumer's bundler resolves the full
|
|
16
|
-
import '@payloadcms/ui/
|
|
16
|
+
// eslint-disable-next-line payload/no-imports-from-self -- Self-import via package path ensures consumer's bundler resolves the full CSS chain (design tokens, preflight, etc.) in prod builds
|
|
17
|
+
import '@payloadcms/ui/css/app.css';
|
|
17
18
|
export const metadata = {
|
|
18
19
|
description: 'Generated by Next.js',
|
|
19
20
|
title: 'Next.js'
|
|
@@ -72,6 +73,10 @@ const RootLayoutContent = async ({
|
|
|
72
73
|
const dir = getLanguageDir({
|
|
73
74
|
languageCode
|
|
74
75
|
});
|
|
76
|
+
const embed = getRequestEmbed({
|
|
77
|
+
config,
|
|
78
|
+
cookies
|
|
79
|
+
});
|
|
75
80
|
const languageOptions = Object.entries(config.i18n.supportedLanguages || {}).reduce((acc, [language, languageConfig]) => {
|
|
76
81
|
if (Object.keys(config.i18n.supportedLanguages).includes(language)) {
|
|
77
82
|
acc.push({
|
|
@@ -111,6 +116,7 @@ const RootLayoutContent = async ({
|
|
|
111
116
|
children: [/*#__PURE__*/_jsxs(RootProvider, {
|
|
112
117
|
config: clientConfig,
|
|
113
118
|
dateFNSKey: req.i18n.dateFNSKey,
|
|
119
|
+
embed: embed,
|
|
114
120
|
fallbackLang: config.i18n.fallbackLanguage,
|
|
115
121
|
highContrastMode: highContrastMode,
|
|
116
122
|
isNavOpen: navPrefs?.open ?? true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["applyLocaleFiltering","React","Suspense","getNavPrefs","ProgressBar","RootProvider","checkDependencies","getClientConfig","getLanguageDir","getRequestHighContrast","getRequestTheme","initReq","NestProviders","getViewportMeta","metadata","description","title","RootLayout","props","additionalDependencyChecks","content","_jsx","RootLayoutContent","process","env","PAYLOAD_CACHE_COMPONENTS_ENABLED","fallback","children","config","configPromise","fonts","head","headFromProps","htmlProps","importMap","RouterAdapter","serverAdapter","serverFunction","cookies","headers","languageCode","permissions","req","payload","key","theme","highContrastMode","dir","languageOptions","Object","entries","i18n","supportedLanguages","reduce","acc","language","languageConfig","keys","includes","push","label","translations","general","thisLanguage","value","navPrefs","clientConfig","user","fontClassNames","map","f","variable","className","filter","Boolean","viewportMeta","get","undefined","_jsxs","join","lang","suppressHydrationWarning","admin","dateFNSKey","fallbackLang","fallbackLanguage","isNavOpen","open","locale","Array","isArray","components","providers","length","serverProps","server","id"],"sources":["../../../src/layouts/Root/index.tsx"],"sourcesContent":["import type {\n ImportMap,\n LanguageOptions,\n SanitizedConfig,\n ServerAdapter,\n ServerFunctionClient,\n} from 'payload'\n\nimport { applyLocaleFiltering } from 'payload/shared'\nimport React, { Suspense } from 'react'\n\nimport { getNavPrefs } from '../../elements/Nav/getNavPrefs.js'\n// eslint-disable-next-line payload/no-imports-from-exports-dir -- Server component must reference exports/client bundle for proper client boundary in prod builds\nimport { ProgressBar, RootProvider } from '../../exports/client/index.js'\nimport { checkDependencies, type CheckDependenciesArgs } from '../../utilities/checkDependencies.js'\nimport { getClientConfig } from '../../utilities/getClientConfig.js'\nimport { getLanguageDir } from '../../utilities/getLanguageDir.js'\nimport { getRequestHighContrast } from '../../utilities/getRequestHighContrast.js'\nimport { getRequestTheme } from '../../utilities/getRequestTheme.js'\nimport { initReq } from '../../utilities/initReq.js'\nimport { NestProviders } from './NestProviders.js'\nimport { getViewportMeta } from './viewport.js'\n// eslint-disable-next-line payload/no-imports-from-self -- Self-import via package path ensures consumer's bundler resolves the full SCSS chain (design tokens, preflight, etc.) in prod builds\nimport '@payloadcms/ui/scss/app.scss'\n\ntype Font = {\n className?: string\n variable?: string\n}\n\nexport const metadata = {\n description: 'Generated by Next.js',\n title: 'Next.js',\n}\n\ntype RootLayoutProps = {\n /**\n * Framework-specific peer-dependency version constraints, merged on top of the\n * universal React/react-dom checks. Each framework adapter supplies its own\n * (e.g. Next.js passes `{ dependencyVersions: { next: { version: '>=15.0.0' } } }`).\n */\n readonly additionalDependencyChecks?: CheckDependenciesArgs\n readonly children: React.ReactNode\n readonly config: Promise<SanitizedConfig>\n /**\n * Fonts to apply to the admin `<html>` element. Each entry's\n * `variable ?? className` is appended to the `<html>` class list.\n * Framework-specific font loaders (e.g. `next/font`) are supplied by the caller.\n */\n readonly fonts?: Font[]\n /**\n * Custom content to render inside the admin panel's `<head>` element.\n *\n * Use this to inject scripts, meta tags, or links — for example, analytics\n * snippets via `next/script`, custom favicons, or preconnect hints.\n *\n * @example\n * ```tsx\n * import Script from 'next/script'\n *\n * <RootLayout\n * head={<Script src=\"https://example.com/analytics.js\" strategy=\"afterInteractive\" />}\n * {...rest}\n * />\n * ```\n */\n readonly head?: React.ReactNode\n readonly htmlProps?: React.HtmlHTMLAttributes<HTMLHtmlElement>\n readonly importMap: ImportMap\n /**\n * Client router adapter. Caller supplies a framework-specific provider\n * (for Next.js use the `NextRouterAdapter` exported from `@payloadcms/next`).\n */\n readonly RouterAdapter: React.FC<{ children: React.ReactNode }>\n /**\n * Server adapter providing framework-specific access to headers, cookies, redirects,\n * and other server APIs (for Next.js use `nextServerAdapter` from `@payloadcms/next`).\n */\n readonly serverAdapter: ServerAdapter\n readonly serverFunction: ServerFunctionClient\n}\n\nexport const RootLayout = (props: RootLayoutProps) => {\n checkDependencies(props.additionalDependencyChecks)\n\n const content = <RootLayoutContent {...props} />\n\n if (process.env.PAYLOAD_CACHE_COMPONENTS_ENABLED === 'true') {\n return <Suspense fallback={null}>{content}</Suspense>\n }\n\n return content\n}\n\nconst RootLayoutContent = async ({\n children,\n config: configPromise,\n fonts = [],\n head: headFromProps,\n htmlProps = {},\n importMap,\n RouterAdapter,\n serverAdapter,\n serverFunction,\n}: RootLayoutProps) => {\n const {\n cookies,\n headers,\n languageCode,\n permissions,\n req,\n req: {\n payload: { config },\n },\n } = await initReq({ configPromise, importMap, key: 'RootLayout', serverAdapter })\n\n const theme = getRequestTheme({\n config,\n cookies,\n headers,\n })\n\n const highContrastMode = getRequestHighContrast({\n config,\n cookies,\n headers,\n })\n\n const dir = getLanguageDir({ languageCode })\n\n const languageOptions: LanguageOptions = Object.entries(\n config.i18n.supportedLanguages || {},\n ).reduce((acc, [language, languageConfig]) => {\n if (Object.keys(config.i18n.supportedLanguages).includes(language)) {\n acc.push({\n label: languageConfig.translations.general.thisLanguage,\n value: language,\n })\n }\n\n return acc\n }, [])\n\n const navPrefs = await getNavPrefs(req)\n\n const clientConfig = getClientConfig({\n config,\n i18n: req.i18n,\n importMap,\n user: req.user,\n })\n\n await applyLocaleFiltering({ clientConfig, config, req })\n\n const fontClassNames = fonts.map((f) => f.variable ?? f.className).filter(Boolean)\n const viewportMeta = getViewportMeta(headers.get('user-agent') ?? undefined)\n\n return (\n <html\n {...htmlProps}\n className={[...fontClassNames, htmlProps?.className].filter(Boolean).join(' ')}\n data-enhanced-contrast={highContrastMode ? '' : undefined}\n data-theme={theme}\n dir={dir}\n lang={languageCode}\n suppressHydrationWarning={config?.admin?.suppressHydrationWarning ?? false}\n >\n <head>\n {viewportMeta}\n <style>{`@layer payload-default, payload;`}</style>\n {headFromProps}\n </head>\n <body>\n <RootProvider\n config={clientConfig}\n dateFNSKey={req.i18n.dateFNSKey}\n fallbackLang={config.i18n.fallbackLanguage}\n highContrastMode={highContrastMode}\n isNavOpen={navPrefs?.open ?? true}\n languageCode={languageCode}\n languageOptions={languageOptions}\n locale={req.locale}\n permissions={req.user ? permissions : null}\n RouterAdapter={RouterAdapter}\n serverFunction={serverFunction}\n theme={theme}\n translations={req.i18n.translations}\n user={req.user}\n >\n <ProgressBar />\n {Array.isArray(config.admin?.components?.providers) &&\n config.admin?.components?.providers.length > 0 ? (\n <NestProviders\n importMap={req.payload.importMap}\n providers={config.admin?.components?.providers}\n serverProps={{\n i18n: req.i18n,\n payload: req.payload,\n permissions,\n server: req.server,\n user: req.user,\n }}\n >\n {children}\n </NestProviders>\n ) : (\n children\n )}\n </RootProvider>\n <div id=\"portal\" />\n </body>\n </html>\n )\n}\n"],"mappings":";AAQA,SAASA,oBAAoB,QAAQ;AACrC,OAAOC,KAAA,IAASC,QAAQ,QAAQ;AAEhC,SAASC,WAAW,QAAQ;AAC5B;AAC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A,CAAIC,OAAO;YACpBF,WAAA;YACAsD,MAAA,EAAQrD,GAAA,CAAIqD,MAAM;YAClB5B,IAAA,EAAMzB,GAAA,CAAIyB;UACZ;oBAECxC;aAGHA,QAAA;uBAGJN,IAAA,CAAC;QAAI2E,EAAA,EAAG;;;;AAIhB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["applyLocaleFiltering","React","Suspense","getNavPrefs","ProgressBar","RootProvider","checkDependencies","getClientConfig","getLanguageDir","getRequestEmbed","getRequestHighContrast","getRequestTheme","initReq","NestProviders","getViewportMeta","metadata","description","title","RootLayout","props","additionalDependencyChecks","content","_jsx","RootLayoutContent","process","env","PAYLOAD_CACHE_COMPONENTS_ENABLED","fallback","children","config","configPromise","fonts","head","headFromProps","htmlProps","importMap","RouterAdapter","serverAdapter","serverFunction","cookies","headers","languageCode","permissions","req","payload","key","theme","highContrastMode","dir","embed","languageOptions","Object","entries","i18n","supportedLanguages","reduce","acc","language","languageConfig","keys","includes","push","label","translations","general","thisLanguage","value","navPrefs","clientConfig","user","fontClassNames","map","f","variable","className","filter","Boolean","viewportMeta","get","undefined","_jsxs","join","lang","suppressHydrationWarning","admin","dateFNSKey","fallbackLang","fallbackLanguage","isNavOpen","open","locale","Array","isArray","components","providers","length","serverProps","server","id"],"sources":["../../../src/layouts/Root/index.tsx"],"sourcesContent":["import type {\n ImportMap,\n LanguageOptions,\n SanitizedConfig,\n ServerAdapter,\n ServerFunctionClient,\n} from 'payload'\n\nimport { applyLocaleFiltering } from 'payload/shared'\nimport React, { Suspense } from 'react'\n\nimport { getNavPrefs } from '../../elements/Nav/getNavPrefs.js'\n// eslint-disable-next-line payload/no-imports-from-exports-dir -- Server component must reference exports/client bundle for proper client boundary in prod builds\nimport { ProgressBar, RootProvider } from '../../exports/client/index.js'\nimport { checkDependencies, type CheckDependenciesArgs } from '../../utilities/checkDependencies.js'\nimport { getClientConfig } from '../../utilities/getClientConfig.js'\nimport { getLanguageDir } from '../../utilities/getLanguageDir.js'\nimport { getRequestEmbed } from '../../utilities/getRequestEmbed.js'\nimport { getRequestHighContrast } from '../../utilities/getRequestHighContrast.js'\nimport { getRequestTheme } from '../../utilities/getRequestTheme.js'\nimport { initReq } from '../../utilities/initReq.js'\nimport { NestProviders } from './NestProviders.js'\nimport { getViewportMeta } from './viewport.js'\n// eslint-disable-next-line payload/no-imports-from-self -- Self-import via package path ensures consumer's bundler resolves the full CSS chain (design tokens, preflight, etc.) in prod builds\nimport '@payloadcms/ui/css/app.css'\n\ntype Font = {\n className?: string\n variable?: string\n}\n\nexport const metadata = {\n description: 'Generated by Next.js',\n title: 'Next.js',\n}\n\ntype RootLayoutProps = {\n /**\n * Framework-specific peer-dependency version constraints, merged on top of the\n * universal React/react-dom checks. Each framework adapter supplies its own\n * (e.g. Next.js passes `{ dependencyVersions: { next: { version: '>=15.0.0' } } }`).\n */\n readonly additionalDependencyChecks?: CheckDependenciesArgs\n readonly children: React.ReactNode\n readonly config: Promise<SanitizedConfig>\n /**\n * Fonts to apply to the admin `<html>` element. Each entry's\n * `variable ?? className` is appended to the `<html>` class list.\n * Framework-specific font loaders (e.g. `next/font`) are supplied by the caller.\n */\n readonly fonts?: Font[]\n /**\n * Custom content to render inside the admin panel's `<head>` element.\n *\n * Use this to inject scripts, meta tags, or links — for example, analytics\n * snippets via `next/script`, custom favicons, or preconnect hints.\n *\n * @example\n * ```tsx\n * import Script from 'next/script'\n *\n * <RootLayout\n * head={<Script src=\"https://example.com/analytics.js\" strategy=\"afterInteractive\" />}\n * {...rest}\n * />\n * ```\n */\n readonly head?: React.ReactNode\n readonly htmlProps?: React.HtmlHTMLAttributes<HTMLHtmlElement>\n readonly importMap: ImportMap\n /**\n * Client router adapter. Caller supplies a framework-specific provider\n * (for Next.js use the `NextRouterAdapter` exported from `@payloadcms/next`).\n */\n readonly RouterAdapter: React.FC<{ children: React.ReactNode }>\n /**\n * Server adapter providing framework-specific access to headers, cookies, redirects,\n * and other server APIs (for Next.js use `nextServerAdapter` from `@payloadcms/next`).\n */\n readonly serverAdapter: ServerAdapter\n readonly serverFunction: ServerFunctionClient\n}\n\nexport const RootLayout = (props: RootLayoutProps) => {\n checkDependencies(props.additionalDependencyChecks)\n\n const content = <RootLayoutContent {...props} />\n\n if (process.env.PAYLOAD_CACHE_COMPONENTS_ENABLED === 'true') {\n return <Suspense fallback={null}>{content}</Suspense>\n }\n\n return content\n}\n\nconst RootLayoutContent = async ({\n children,\n config: configPromise,\n fonts = [],\n head: headFromProps,\n htmlProps = {},\n importMap,\n RouterAdapter,\n serverAdapter,\n serverFunction,\n}: RootLayoutProps) => {\n const {\n cookies,\n headers,\n languageCode,\n permissions,\n req,\n req: {\n payload: { config },\n },\n } = await initReq({ configPromise, importMap, key: 'RootLayout', serverAdapter })\n\n const theme = getRequestTheme({\n config,\n cookies,\n headers,\n })\n\n const highContrastMode = getRequestHighContrast({\n config,\n cookies,\n headers,\n })\n\n const dir = getLanguageDir({ languageCode })\n const embed = getRequestEmbed({ config, cookies })\n\n const languageOptions: LanguageOptions = Object.entries(\n config.i18n.supportedLanguages || {},\n ).reduce((acc, [language, languageConfig]) => {\n if (Object.keys(config.i18n.supportedLanguages).includes(language)) {\n acc.push({\n label: languageConfig.translations.general.thisLanguage,\n value: language,\n })\n }\n\n return acc\n }, [])\n\n const navPrefs = await getNavPrefs(req)\n\n const clientConfig = getClientConfig({\n config,\n i18n: req.i18n,\n importMap,\n user: req.user,\n })\n\n await applyLocaleFiltering({ clientConfig, config, req })\n\n const fontClassNames = fonts.map((f) => f.variable ?? f.className).filter(Boolean)\n const viewportMeta = getViewportMeta(headers.get('user-agent') ?? undefined)\n\n return (\n <html\n {...htmlProps}\n className={[...fontClassNames, htmlProps?.className].filter(Boolean).join(' ')}\n data-enhanced-contrast={highContrastMode ? '' : undefined}\n data-theme={theme}\n dir={dir}\n lang={languageCode}\n suppressHydrationWarning={config?.admin?.suppressHydrationWarning ?? false}\n >\n <head>\n {viewportMeta}\n <style>{`@layer payload-default, payload;`}</style>\n {headFromProps}\n </head>\n <body>\n <RootProvider\n config={clientConfig}\n dateFNSKey={req.i18n.dateFNSKey}\n embed={embed}\n fallbackLang={config.i18n.fallbackLanguage}\n highContrastMode={highContrastMode}\n isNavOpen={navPrefs?.open ?? true}\n languageCode={languageCode}\n languageOptions={languageOptions}\n locale={req.locale}\n permissions={req.user ? permissions : null}\n RouterAdapter={RouterAdapter}\n serverFunction={serverFunction}\n theme={theme}\n translations={req.i18n.translations}\n user={req.user}\n >\n <ProgressBar />\n {Array.isArray(config.admin?.components?.providers) &&\n config.admin?.components?.providers.length > 0 ? (\n <NestProviders\n importMap={req.payload.importMap}\n providers={config.admin?.components?.providers}\n serverProps={{\n i18n: req.i18n,\n payload: req.payload,\n permissions,\n server: req.server,\n user: req.user,\n }}\n >\n {children}\n </NestProviders>\n ) : (\n children\n )}\n </RootProvider>\n <div id=\"portal\" />\n </body>\n </html>\n )\n}\n"],"mappings":";AAQA,SAASA,oBAAoB,QAAQ;AACrC,OAAOC,KAAA,IAASC,QAAQ,QAAQ;AAEhC,SAASC,WAAW,QAAQ;AAC5B;AACA,SAASC,WAAW,EAAEC,YAAY,QAAQ;AAC1C,SAASC,iBAAiB,QAAoC;AAC9D,SAASC,eAAe,QAAQ;AAChC,SAASC,cAAc,QAAQ;AAC/B,SAASC,eAAe,QAAQ;AAChC,SAASC,sBAAsB,QAAQ;AACvC,SAASC,eAAe,QAAQ;AAChC,SAASC,OAAO,QAAQ;AACxB,SAASC,aAAa,QAAQ;AAC9B,SAASC,eAAe,QAAQ;AAChC;AACA,OAAO;AAOP,OAAO,MAAMC,QAAA,GAAW;EACtBC,WAAA,EAAa;EACbC,KAAA,EAAO;AACT;AAiDA,OAAO,MAAMC,UAAA,GAAcC,KAAA;EACzBb,iBAAA,CAAkBa,KAAA,CAAMC,0BAA0B;EAElD,MAAMC,OAAA,gBAAUC,IAAA,CAACC,iBAAA;IAAmB,GAAGJ;;EAEvC,IAAIK,OAAA,CAAQC,GAAG,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BA,gBAAA;QAClByC,SAAA,EAAWrB,QAAA,EAAUsB,IAAA,IAAQ;QAC7BhD,YAAA,EAAcA,YAAA;QACdS,eAAA,EAAiBA,eAAA;QACjBwC,MAAA,EAAQ/C,GAAA,CAAI+C,MAAM;QAClBhD,WAAA,EAAaC,GAAA,CAAI0B,IAAI,GAAG3B,WAAA,GAAc;QACtCN,aAAA,EAAeA,aAAA;QACfE,cAAA,EAAgBA,cAAA;QAChBQ,KAAA,EAAOA,KAAA;QACPiB,YAAA,EAAcpB,GAAA,CAAIU,IAAI,CAACU,YAAY;QACnCM,IAAA,EAAM1B,GAAA,CAAI0B,IAAI;gCAEd/C,IAAA,CAAClB,WAAA,OACAuF,KAAA,CAAMC,OAAO,CAAC/D,MAAA,CAAOuD,KAAK,EAAES,UAAA,EAAYC,SAAA,KACzCjE,MAAA,CAAOuD,KAAK,EAAES,UAAA,EAAYC,SAAA,CAAUC,MAAA,GAAS,iBAC3CzE,IAAA,CAACT,aAAA;UACCsB,SAAA,EAAWQ,GAAA,CAAIC,OAAO,CAACT,SAAS;UAChC2D,SAAA,EAAWjE,MAAA,CAAOuD,KAAK,EAAES,UAAA,EAAYC,SAAA;UACrCE,WAAA,EAAa;YACX3C,IAAA,EAAMV,GAAA,CAAIU,IAAI;YACdT,OAAA,EAASD,GAAA,CAAIC,OAAO;YACpBF,WAAA;YACAuD,MAAA,EAAQtD,GAAA,CAAIsD,MAAM;YAClB5B,IAAA,EAAM1B,GAAA,CAAI0B;UACZ;oBAECzC;aAGHA,QAAA;uBAGJN,IAAA,CAAC;QAAI4E,EAAA,EAAG;;;;AAIhB","ignoreList":[]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* @experimental This is an experimental API and may change at any time. Use at your own risk.
|
|
4
|
+
*/
|
|
5
|
+
export type EmbedContext = {
|
|
6
|
+
isEmbedded: boolean;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* @experimental This component is experimental and may change or be removed in future releases. Use at your own risk.
|
|
10
|
+
*/
|
|
11
|
+
export declare const EmbedProvider: React.FC<{
|
|
12
|
+
children?: React.ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* Initial embed value is read from the embed cookie in the root layout. The root layout
|
|
15
|
+
* cannot see search params, so the client reads the `?embed` query parameter below
|
|
16
|
+
* and it takes precedence over the cookie value.
|
|
17
|
+
*/
|
|
18
|
+
embed?: boolean;
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* @experimental This is an experimental API and may change at any time. Use at your own risk.
|
|
22
|
+
*/
|
|
23
|
+
export declare const useEmbed: () => EmbedContext;
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/Embed/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAkD,MAAM,OAAO,CAAA;AAKtE;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,UAAU,EAAE,OAAO,CAAA;CACpB,CAAA;AAyCD;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC;IACnC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,CAoBA,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,QAAO,YAA8C,CAAA"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { c as _c } from "react/compiler-runtime";
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
import React, { createContext, use, useEffect, useState } from 'react';
|
|
6
|
+
import { useConfig } from '../Config/index.js';
|
|
7
|
+
import { useSearchParams } from '../RouterAdapter/index.js';
|
|
8
|
+
const initialContext = {
|
|
9
|
+
isEmbedded: false
|
|
10
|
+
};
|
|
11
|
+
const Context = /*#__PURE__*/createContext(undefined);
|
|
12
|
+
const hasEmbedCookie = cookieKey => document.cookie.split('; ').some(row => row.startsWith(`${cookieKey}=`) && row.split('=')[1] === 'true');
|
|
13
|
+
/**
|
|
14
|
+
* Writes a session-scoped, `Partitioned` (CHIPS) cookie so embed mode persists
|
|
15
|
+
* across navigation within the iframe.
|
|
16
|
+
*
|
|
17
|
+
* The cookie is keyed to both the iframe domain and the embedding top-level domain,
|
|
18
|
+
* so it is readable only on that one top-level domain.
|
|
19
|
+
*
|
|
20
|
+
* No `Expires`/`Max-Age` — it is a session cookie that clears when the browsing session ends.
|
|
21
|
+
*/
|
|
22
|
+
const setEmbedCookie = cookieKey => {
|
|
23
|
+
document.cookie = `${cookieKey}=true; path=/; SameSite=None; Secure; Partitioned`;
|
|
24
|
+
};
|
|
25
|
+
const deleteEmbedCookie = cookieKey => {
|
|
26
|
+
document.cookie = `${cookieKey}=; path=/; SameSite=None; Secure; Partitioned; expires=Thu, 01 Jan 1970 00:00:00 GMT`;
|
|
27
|
+
};
|
|
28
|
+
const resolveEmbedParam = (embedParam, fallback) => {
|
|
29
|
+
switch (embedParam) {
|
|
30
|
+
case 'false':
|
|
31
|
+
return false;
|
|
32
|
+
case 'true':
|
|
33
|
+
return true;
|
|
34
|
+
default:
|
|
35
|
+
return fallback;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* @experimental This component is experimental and may change or be removed in future releases. Use at your own risk.
|
|
40
|
+
*/
|
|
41
|
+
export const EmbedProvider = t0 => {
|
|
42
|
+
const $ = _c(10);
|
|
43
|
+
const {
|
|
44
|
+
children,
|
|
45
|
+
embed
|
|
46
|
+
} = t0;
|
|
47
|
+
const {
|
|
48
|
+
config
|
|
49
|
+
} = useConfig();
|
|
50
|
+
const embedCookieKey = `${config.cookiePrefix || "payload"}-embed`;
|
|
51
|
+
const embedParam = useSearchParams().get("embed")?.toLowerCase();
|
|
52
|
+
let t1;
|
|
53
|
+
if ($[0] !== embed || $[1] !== embedParam) {
|
|
54
|
+
t1 = () => resolveEmbedParam(embedParam, Boolean(embed));
|
|
55
|
+
$[0] = embed;
|
|
56
|
+
$[1] = embedParam;
|
|
57
|
+
$[2] = t1;
|
|
58
|
+
} else {
|
|
59
|
+
t1 = $[2];
|
|
60
|
+
}
|
|
61
|
+
const [isEmbedded, setIsEmbedded] = useState(t1);
|
|
62
|
+
let t2;
|
|
63
|
+
let t3;
|
|
64
|
+
if ($[3] !== embedCookieKey || $[4] !== embedParam) {
|
|
65
|
+
t2 = () => {
|
|
66
|
+
if (embedParam === "true") {
|
|
67
|
+
setEmbedCookie(embedCookieKey);
|
|
68
|
+
} else {
|
|
69
|
+
if (embedParam === "false") {
|
|
70
|
+
deleteEmbedCookie(embedCookieKey);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
setIsEmbedded(hasEmbedCookie(embedCookieKey));
|
|
74
|
+
};
|
|
75
|
+
t3 = [embedParam, embedCookieKey];
|
|
76
|
+
$[3] = embedCookieKey;
|
|
77
|
+
$[4] = embedParam;
|
|
78
|
+
$[5] = t2;
|
|
79
|
+
$[6] = t3;
|
|
80
|
+
} else {
|
|
81
|
+
t2 = $[5];
|
|
82
|
+
t3 = $[6];
|
|
83
|
+
}
|
|
84
|
+
useEffect(t2, t3);
|
|
85
|
+
let t4;
|
|
86
|
+
if ($[7] !== children || $[8] !== isEmbedded) {
|
|
87
|
+
t4 = _jsx(Context, {
|
|
88
|
+
value: {
|
|
89
|
+
isEmbedded
|
|
90
|
+
},
|
|
91
|
+
children
|
|
92
|
+
});
|
|
93
|
+
$[7] = children;
|
|
94
|
+
$[8] = isEmbedded;
|
|
95
|
+
$[9] = t4;
|
|
96
|
+
} else {
|
|
97
|
+
t4 = $[9];
|
|
98
|
+
}
|
|
99
|
+
return t4;
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* @experimental This is an experimental API and may change at any time. Use at your own risk.
|
|
103
|
+
*/
|
|
104
|
+
export const useEmbed = () => use(Context) ?? initialContext;
|
|
105
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","React","createContext","use","useEffect","useState","useConfig","useSearchParams","initialContext","isEmbedded","Context","undefined","hasEmbedCookie","cookieKey","document","cookie","split","some","row","startsWith","setEmbedCookie","deleteEmbedCookie","resolveEmbedParam","embedParam","fallback","EmbedProvider","t0","$","children","embed","config","embedCookieKey","cookiePrefix","get","toLowerCase","t1","Boolean","setIsEmbedded","t2","t3","t4","_jsx","value","useEmbed"],"sources":["../../../src/providers/Embed/index.tsx"],"sourcesContent":["'use client'\nimport React, { createContext, use, useEffect, useState } from 'react'\n\nimport { useConfig } from '../Config/index.js'\nimport { useSearchParams } from '../RouterAdapter/index.js'\n\n/**\n * @experimental This is an experimental API and may change at any time. Use at your own risk.\n */\nexport type EmbedContext = {\n isEmbedded: boolean\n}\n\nconst initialContext: EmbedContext = {\n isEmbedded: false,\n}\n\nconst Context = createContext<EmbedContext | undefined>(undefined)\n\nconst hasEmbedCookie = (cookieKey: string): boolean =>\n document.cookie\n .split('; ')\n .some((row) => row.startsWith(`${cookieKey}=`) && row.split('=')[1] === 'true')\n\n/**\n * Writes a session-scoped, `Partitioned` (CHIPS) cookie so embed mode persists\n * across navigation within the iframe.\n *\n * The cookie is keyed to both the iframe domain and the embedding top-level domain,\n * so it is readable only on that one top-level domain.\n *\n * No `Expires`/`Max-Age` — it is a session cookie that clears when the browsing session ends.\n */\nconst setEmbedCookie = (cookieKey: string): void => {\n document.cookie = `${cookieKey}=true; path=/; SameSite=None; Secure; Partitioned`\n}\n\nconst deleteEmbedCookie = (cookieKey: string): void => {\n document.cookie = `${cookieKey}=; path=/; SameSite=None; Secure; Partitioned; expires=Thu, 01 Jan 1970 00:00:00 GMT`\n}\n\nconst resolveEmbedParam = (embedParam: null | string, fallback: boolean): boolean => {\n switch (embedParam) {\n case 'false':\n return false\n case 'true':\n return true\n default:\n return fallback\n }\n}\n\n/**\n * @experimental This component is experimental and may change or be removed in future releases. Use at your own risk.\n */\nexport const EmbedProvider: React.FC<{\n children?: React.ReactNode\n /**\n * Initial embed value is read from the embed cookie in the root layout. The root layout\n * cannot see search params, so the client reads the `?embed` query parameter below\n * and it takes precedence over the cookie value.\n */\n embed?: boolean\n}> = ({ children, embed }) => {\n const { config } = useConfig()\n const embedCookieKey = `${config.cookiePrefix || 'payload'}-embed`\n const embedParam = useSearchParams().get('embed')?.toLowerCase()\n\n const [isEmbedded, setIsEmbedded] = useState<boolean>(() =>\n resolveEmbedParam(embedParam, Boolean(embed)),\n )\n\n useEffect(() => {\n // The query parameter takes precedence; otherwise fall back to the cookie value\n if (embedParam === 'true') {\n setEmbedCookie(embedCookieKey)\n } else if (embedParam === 'false') {\n deleteEmbedCookie(embedCookieKey)\n }\n setIsEmbedded(hasEmbedCookie(embedCookieKey))\n }, [embedParam, embedCookieKey])\n\n return <Context value={{ isEmbedded }}>{children}</Context>\n}\n\n/**\n * @experimental This is an experimental API and may change at any time. Use at your own risk.\n */\nexport const useEmbed = (): EmbedContext => use(Context) ?? initialContext\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AACA,OAAOC,KAAA,IAASC,aAAa,EAAEC,GAAG,EAAEC,SAAS,EAAEC,QAAQ,QAAQ;AAE/D,SAASC,SAAS,QAAQ;AAC1B,SAASC,eAAe,QAAQ;AAShC,MAAMC,cAAA,GAA+B;EACnCC,UAAA,EAAY;AACd;AAEA,MAAMC,OAAA,gBAAUR,aAAA,CAAwCS,SAAA;AAExD,MAAMC,cAAA,GAAkBC,SAAA,IACtBC,QAAA,CAASC,MAAM,CACZC,KAAK,CAAC,MACNC,IAAI,CAAEC,GAAA,IAAQA,GAAA,CAAIC,UAAU,CAAC,GAAGN,SAAA,GAAY,KAAKK,GAAA,CAAIF,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK;AAE5E;;;;;;;;;A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AA;MAEpBM,aAAA,CAAczB,cAAA,CAAemB,cAAA;IAAA;IAC5BQ,EAAA,IAAChB,UAAA,EAAYQ,cAAA;IAAeJ,CAAA,MAAAI,cAAA;IAAAJ,CAAA,MAAAJ,UAAA;IAAAI,CAAA,MAAAW,EAAA;IAAAX,CAAA,MAAAY,EAAA;EAAA;IAAAD,EAAA,GAAAX,CAAA;IAAAY,EAAA,GAAAZ,CAAA;EAAA;EAR/BvB,SAAA,CAAUkC,EAQV,EAAGC,EAA4B;EAAA,IAAAC,EAAA;EAAA,IAAAb,CAAA,QAAAC,QAAA,IAAAD,CAAA,QAAAlB,UAAA;IAExB+B,EAAA,GAAAC,IAAA,CAAA/B,OAAA;MAAAgC,KAAA;QAAAjC;MAAA;MAAAmB;IAAA,C;;;;;;;SAAAY,E;CACT;AAEA;;;AAGA,OAAO,MAAMG,QAAA,GAAWA,CAAA,KAAoBxC,GAAA,CAAIO,OAAA,KAAYF,cAAA","ignoreList":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type NonFieldError = {
|
|
2
|
+
data?: unknown;
|
|
3
|
+
message: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* A callback that a plugin can provide to intercept non-field form errors before
|
|
7
|
+
* Payload shows its default error toast. Return `true` to claim the error (the
|
|
8
|
+
* default toast is suppressed). Return `false` to let Payload handle it normally.
|
|
9
|
+
*
|
|
10
|
+
* Set via `<FormErrorHandlerContext value={handler}>` inside an
|
|
11
|
+
* `admin.components.providers` entry. The Form reads this automatically — no
|
|
12
|
+
* changes to collection config or the edit view are required.
|
|
13
|
+
*
|
|
14
|
+
* Multiple handlers can be chained by composing providers; the first one to
|
|
15
|
+
* return `true` wins.
|
|
16
|
+
*/
|
|
17
|
+
export type FormErrorHandler = (err: NonFieldError) => boolean;
|
|
18
|
+
export declare const FormErrorHandlerContext: import("react").Context<FormErrorHandler>;
|
|
19
|
+
export declare const useFormErrorHandler: () => FormErrorHandler | undefined;
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/FormErrorHandler/index.tsx"],"names":[],"mappings":"AAGA,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,GAAG,EAAE,aAAa,KAAK,OAAO,CAAA;AAE9D,eAAO,MAAM,uBAAuB,2CAAyD,CAAA;AAE7F,eAAO,MAAM,mBAAmB,QAAO,gBAAgB,GAAG,SAAyC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["createContext","use","FormErrorHandlerContext","undefined","useFormErrorHandler"],"sources":["../../../src/providers/FormErrorHandler/index.tsx"],"sourcesContent":["'use client'\nimport { createContext, use } from 'react'\n\nexport type NonFieldError = {\n data?: unknown\n message: string\n}\n\n/**\n * A callback that a plugin can provide to intercept non-field form errors before\n * Payload shows its default error toast. Return `true` to claim the error (the\n * default toast is suppressed). Return `false` to let Payload handle it normally.\n *\n * Set via `<FormErrorHandlerContext value={handler}>` inside an\n * `admin.components.providers` entry. The Form reads this automatically — no\n * changes to collection config or the edit view are required.\n *\n * Multiple handlers can be chained by composing providers; the first one to\n * return `true` wins.\n */\nexport type FormErrorHandler = (err: NonFieldError) => boolean\n\nexport const FormErrorHandlerContext = createContext<FormErrorHandler | undefined>(undefined)\n\nexport const useFormErrorHandler = (): FormErrorHandler | undefined => use(FormErrorHandlerContext)\n"],"mappings":"AAAA;;AACA,SAASA,aAAa,EAAEC,GAAG,QAAQ;AAqBnC,OAAO,MAAMC,uBAAA,gBAA0BF,aAAA,CAA4CG,SAAA;AAEnF,OAAO,MAAMC,mBAAA,GAAsBA,CAAA,KAAoCH,GAAA,CAAIC,uBAAA","ignoreList":[]}
|
|
@@ -6,6 +6,7 @@ type Props = {
|
|
|
6
6
|
readonly children: React.ReactNode;
|
|
7
7
|
readonly config: ClientConfig;
|
|
8
8
|
readonly dateFNSKey: Language['dateFNSKey'];
|
|
9
|
+
readonly embed?: boolean;
|
|
9
10
|
readonly fallbackLang: I18nOptions['fallbackLanguage'];
|
|
10
11
|
readonly highContrastMode: boolean;
|
|
11
12
|
readonly isNavOpen?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/Root/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AACjF,OAAO,KAAK,EACV,YAAY,EACZ,eAAe,EACf,MAAM,EACN,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,EACpB,IAAI,EACL,MAAM,SAAS,CAAA;AAKhB,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/Root/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AACjF,OAAO,KAAK,EACV,YAAY,EACZ,eAAe,EACf,MAAM,EACN,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,EACpB,IAAI,EACL,MAAM,SAAS,CAAA;AAKhB,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AA0B9C,KAAK,KAAK,GAAG;IACX,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IAClC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAA;IAC7B,QAAQ,CAAC,UAAU,EAAE,QAAQ,CA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