@payloadcms/ui 3.56.0-internal.299316b → 3.56.0-internal.33536e7
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/ConfirmationModal/index.d.ts.map +1 -1
- package/dist/elements/ConfirmationModal/index.js +1 -0
- package/dist/elements/ConfirmationModal/index.js.map +1 -1
- package/dist/elements/DocumentLocked/index.d.ts.map +1 -1
- package/dist/elements/DocumentLocked/index.js +1 -0
- package/dist/elements/DocumentLocked/index.js.map +1 -1
- package/dist/elements/DocumentTakeOver/index.d.ts.map +1 -1
- package/dist/elements/DocumentTakeOver/index.js +1 -0
- package/dist/elements/DocumentTakeOver/index.js.map +1 -1
- package/dist/elements/Drawer/index.d.ts.map +1 -1
- package/dist/elements/Drawer/index.js +1 -0
- package/dist/elements/Drawer/index.js.map +1 -1
- package/dist/elements/EmailAndUsername/index.d.ts.map +1 -1
- package/dist/elements/EmailAndUsername/index.js +31 -24
- package/dist/elements/EmailAndUsername/index.js.map +1 -1
- package/dist/elements/FullscreenModal/index.d.ts.map +1 -1
- package/dist/elements/FullscreenModal/index.js +1 -0
- package/dist/elements/FullscreenModal/index.js.map +1 -1
- package/dist/elements/ListControls/getTextFieldsToBeSearched.d.ts.map +1 -1
- package/dist/elements/ListControls/getTextFieldsToBeSearched.js +9 -1
- package/dist/elements/ListControls/getTextFieldsToBeSearched.js.map +1 -1
- package/dist/elements/LivePreview/Window/index.js +37 -35
- package/dist/elements/LivePreview/Window/index.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/index.d.ts +1 -1
- package/dist/elements/WhereBuilder/Condition/index.js +2 -2
- package/dist/elements/WhereBuilder/Condition/index.js.map +1 -1
- package/dist/elements/WhereBuilder/index.js +6 -6
- package/dist/elements/WhereBuilder/index.js.map +1 -1
- package/dist/exports/client/{CodeEditor-URFJPG6I.js → CodeEditor-4J4OH4TD.js} +2 -2
- package/dist/exports/client/chunk-HBCG32CP.js +26 -0
- package/dist/exports/client/{chunk-KPQQ5IUL.js.map → chunk-HBCG32CP.js.map} +3 -3
- package/dist/exports/client/index.d.ts +2 -1
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +12 -12
- package/dist/exports/client/index.js.map +3 -3
- package/dist/fields/Relationship/Input.d.ts.map +1 -1
- package/dist/fields/Relationship/Input.js +9 -5
- package/dist/fields/Relationship/Input.js.map +1 -1
- package/dist/forms/Form/createNestedClientFieldPath.js +1 -1
- package/dist/forms/Form/createNestedClientFieldPath.js.map +1 -1
- package/dist/forms/Form/index.d.ts.map +1 -1
- package/dist/forms/Form/index.js +8 -1
- package/dist/forms/Form/index.js.map +1 -1
- package/dist/forms/RenderFields/context.d.ts +29 -0
- package/dist/forms/RenderFields/context.d.ts.map +1 -1
- package/dist/forms/RenderFields/context.js +30 -2
- package/dist/forms/RenderFields/context.js.map +1 -1
- package/dist/providers/Config/index.d.ts +17 -2
- package/dist/providers/Config/index.d.ts.map +1 -1
- package/dist/providers/Config/index.js +57 -20
- package/dist/providers/Config/index.js.map +1 -1
- package/dist/utilities/buildFormState.d.ts.map +1 -1
- package/dist/utilities/buildFormState.js +2 -1
- package/dist/utilities/buildFormState.js.map +1 -1
- package/dist/utilities/reduceFieldsToOptions.d.ts +3 -3
- package/dist/utilities/reduceFieldsToOptions.d.ts.map +1 -1
- package/dist/utilities/reduceFieldsToOptions.js +9 -14
- package/dist/utilities/reduceFieldsToOptions.js.map +1 -1
- package/package.json +5 -5
- package/dist/exports/client/chunk-KPQQ5IUL.js +0 -26
- /package/dist/exports/client/{CodeEditor-URFJPG6I.js.map → CodeEditor-4J4OH4TD.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildFormState.js","names":["formatErrors","getSelectMode","reduceFieldsToValues","fieldSchemasToFormState","renderField","getClientConfig","getClientSchemaMap","getSchemaMap","handleFormStateLocking","buildFormStateHandler","args","req","incomingUserSlug","user","collection","adminUserSlug","payload","config","admin","adminAccessFunction","collections","access","canAccessAdmin","Error","hasUsers","find","depth","limit","pagination","docs","length","res","buildFormState","err","logger","error","msg","message","id","idFromArgs","collectionSlug","data","incomingData","docPermissions","docPreferences","documentFormState","formState","globalSlug","initialBlockData","initialBlockFormState","mockRSCs","operation","readOnly","renderAllFields","i18n","returnLockStatus","schemaPath","select","skipValidation","updateLastEdited","selectMode","undefined","schemaMap","clientSchemaMap","importMap","fieldOrEntityConfig","get","fields","type","documentData","blockData","Array","isArray","formStateResult","clientFieldSchemaMap","fieldSchemaMap","permissions","preferences","previousFormState","renderFieldFn","upload","file","lockedStateResult","lockedState","state"],"sources":["../../src/utilities/buildFormState.ts"],"sourcesContent":["import type {\n BuildFormStateArgs,\n ClientConfig,\n ClientUser,\n ErrorResult,\n FormState,\n ServerFunction,\n} from 'payload'\n\nimport { formatErrors } from 'payload'\nimport { getSelectMode, reduceFieldsToValues } from 'payload/shared'\n\nimport { fieldSchemasToFormState } from '../forms/fieldSchemasToFormState/index.js'\nimport { renderField } from '../forms/fieldSchemasToFormState/renderField.js'\nimport { getClientConfig } from './getClientConfig.js'\nimport { getClientSchemaMap } from './getClientSchemaMap.js'\nimport { getSchemaMap } from './getSchemaMap.js'\nimport { handleFormStateLocking } from './handleFormStateLocking.js'\n\nexport type LockedState = {\n isLocked: boolean\n lastEditedAt: string\n user: ClientUser | number | string\n}\n\ntype BuildFormStateSuccessResult = {\n clientConfig?: ClientConfig\n errors?: never\n indexPath?: string\n lockedState?: LockedState\n state: FormState\n}\n\ntype BuildFormStateErrorResult = {\n lockedState?: never\n state?: never\n} & (\n | {\n message: string\n }\n | ErrorResult\n)\n\nexport type BuildFormStateResult = BuildFormStateErrorResult | BuildFormStateSuccessResult\n\nexport const buildFormStateHandler: ServerFunction<\n BuildFormStateArgs,\n Promise<BuildFormStateResult>\n> = async (args) => {\n const { req } = args\n\n const incomingUserSlug = req.user?.collection\n const adminUserSlug = req.payload.config.admin.user\n\n try {\n // If we have a user slug, test it against the functions\n if (incomingUserSlug) {\n const adminAccessFunction = req.payload.collections[incomingUserSlug].config.access?.admin\n\n // Run the admin access function from the config if it exists\n if (adminAccessFunction) {\n const canAccessAdmin = await adminAccessFunction({ req })\n\n if (!canAccessAdmin) {\n throw new Error('Unauthorized')\n }\n // Match the user collection to the global admin config\n } else if (adminUserSlug !== incomingUserSlug) {\n throw new Error('Unauthorized')\n }\n } else {\n const hasUsers = await req.payload.find({\n collection: adminUserSlug,\n depth: 0,\n limit: 1,\n pagination: false,\n })\n\n // If there are users, we should not allow access because of /create-first-user\n if (hasUsers.docs.length) {\n throw new Error('Unauthorized')\n }\n }\n\n const res = await buildFormState(args)\n return res\n } catch (err) {\n req.payload.logger.error({ err, msg: `There was an error building form state` })\n\n if (err.message === 'Could not find field schema for given path') {\n return {\n message: err.message,\n }\n }\n\n if (err.message === 'Unauthorized') {\n throw new Error('Unauthorized')\n }\n\n return formatErrors(err)\n }\n}\n\nexport const buildFormState = async (\n args: BuildFormStateArgs,\n): Promise<BuildFormStateSuccessResult> => {\n const {\n id: idFromArgs,\n collectionSlug,\n data: incomingData,\n docPermissions,\n docPreferences,\n documentFormState,\n formState,\n globalSlug,\n initialBlockData,\n initialBlockFormState,\n mockRSCs,\n operation,\n readOnly,\n renderAllFields,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n },\n returnLockStatus,\n schemaPath = collectionSlug || globalSlug,\n select,\n skipValidation,\n updateLastEdited,\n } = args\n\n const selectMode = select ? getSelectMode(select) : undefined\n\n if (!collectionSlug && !globalSlug) {\n throw new Error('Either collectionSlug or globalSlug must be provided')\n }\n\n const schemaMap = getSchemaMap({\n collectionSlug,\n config,\n globalSlug,\n i18n,\n })\n\n const clientSchemaMap = getClientSchemaMap({\n collectionSlug,\n config: getClientConfig({ config, i18n, importMap: req.payload.importMap, user: req.user }),\n globalSlug,\n i18n,\n payload,\n schemaMap,\n })\n\n const id = collectionSlug ? idFromArgs : undefined\n const fieldOrEntityConfig = schemaMap.get(schemaPath)\n\n if (!fieldOrEntityConfig) {\n throw new Error(`Could not find \"${schemaPath}\" in the fieldSchemaMap`)\n }\n\n if (\n (!('fields' in fieldOrEntityConfig) ||\n !fieldOrEntityConfig.fields ||\n !fieldOrEntityConfig.fields.length) &&\n 'type' in fieldOrEntityConfig &&\n fieldOrEntityConfig.type !== 'blocks'\n ) {\n throw new Error(\n `The field found in fieldSchemaMap for \"${schemaPath}\" does not contain any subfields.`,\n )\n }\n\n // If there is form state but no data, deduce data from that form state, e.g. on initial load\n // Otherwise, use the incoming data as the source of truth, e.g. on subsequent saves\n const data = incomingData || reduceFieldsToValues(formState, true)\n\n let documentData = undefined\n\n if (documentFormState) {\n documentData = reduceFieldsToValues(documentFormState, true)\n }\n\n let blockData = initialBlockData\n\n if (initialBlockFormState) {\n blockData = reduceFieldsToValues(initialBlockFormState, true)\n }\n\n /**\n * When building state for sub schemas we need to adjust:\n * - `fields`\n * - `parentSchemaPath`\n * - `parentPath`\n *\n * Type assertion is fine because we wrap sub schemas in an array\n * so we can safely map over them within `fieldSchemasToFormState`\n */\n const fields = Array.isArray(fieldOrEntityConfig)\n ? fieldOrEntityConfig\n : 'fields' in fieldOrEntityConfig\n ? fieldOrEntityConfig.fields\n : [fieldOrEntityConfig]\n\n // Ensure data.id is present during form state requests, where the data\n // is passed from the client as an argument, without the ID\n if (!data.id && id) {\n data.id = id\n }\n\n const formStateResult = await fieldSchemasToFormState({\n id,\n clientFieldSchemaMap: clientSchemaMap,\n collectionSlug,\n data,\n documentData,\n fields,\n fieldSchemaMap: schemaMap,\n initialBlockData: blockData,\n mockRSCs,\n operation,\n permissions: docPermissions?.fields || {},\n preferences: docPreferences || { fields: {} },\n previousFormState: formState,\n readOnly,\n renderAllFields,\n renderFieldFn: renderField,\n req,\n schemaPath,\n select,\n selectMode,\n skipValidation,\n })\n\n // Maintain form state of auth / upload fields\n if (collectionSlug && formState) {\n if (payload.collections[collectionSlug]?.config?.upload && formState.file) {\n formStateResult.file = formState.file\n }\n }\n\n let lockedStateResult\n\n if (returnLockStatus) {\n lockedStateResult = await handleFormStateLocking({\n id,\n collectionSlug,\n globalSlug,\n req,\n updateLastEdited,\n })\n }\n\n return {\n lockedState: lockedStateResult,\n state: formStateResult,\n }\n}\n"],"mappings":"AASA,SAASA,YAAY,QAAQ;AAC7B,SAASC,aAAa,EAAEC,oBAAoB,QAAQ;AAEpD,SAASC,uBAAuB,QAAQ;AACxC,SAASC,WAAW,QAAQ;AAC5B,SAASC,eAAe,QAAQ;AAChC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,YAAY,QAAQ;AAC7B,SAASC,sBAAsB,QAAQ;AA4BvC,OAAO,MAAMC,qBAAA,GAGT,MAAOC,IAAA;EACT,MAAM;IAAEC;EAAG,CAAE,GAAGD,IAAA;EAEhB,MAAME,gBAAA,GAAmBD,GAAA,CAAIE,IAAI,EAAEC,UAAA;EACnC,MAAMC,aAAA,GAAgBJ,GAAA,CAAIK,OAAO,CAACC,MAAM,CAACC,KAAK,CAACL,IAAI;EAEnD,IAAI;IACF;IACA,IAAID,gBAAA,EAAkB;MACpB,MAAMO,mBAAA,GAAsBR,GAAA,CAAIK,OAAO,CAACI,WAAW,CAACR,gBAAA,CAAiB,CAACK,MAAM,CAACI,MAAM,EAAEH,KAAA;MAErF;MACA,IAAIC,mBAAA,EAAqB;QACvB,MAAMG,cAAA,GAAiB,MAAMH,mBAAA,CAAoB;UAAER;QAAI;QAEvD,IAAI,CAACW,cAAA,EAAgB;UACnB,MAAM,IAAIC,KAAA,CAAM;QAClB;QACA;MACF,OAAO,IAAIR,aAAA,KAAkBH,gBAAA,EAAkB;QAC7C,MAAM,IAAIW,KAAA,CAAM;MAClB;IACF,OAAO;MACL,MAAMC,QAAA,GAAW,MAAMb,GAAA,CAAIK,OAAO,CAACS,IAAI,CAAC;QACtCX,UAAA,EAAYC,aAAA;QACZW,KAAA,EAAO;QACPC,KAAA,EAAO;QACPC,UAAA,EAAY;MACd;MAEA;MACA,IAAIJ,QAAA,CAASK,IA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oB;EAE3B;EACA;EACA,IAAI,CAACxB,IAAA,CAAKH,EAAE,IAAIA,EAAA,EAAI;IAClBG,IAAA,CAAKH,EAAE,GAAGA,EAAA;EACZ;EAEA,MAAMmC,eAAA,GAAkB,MAAMtE,uBAAA,CAAwB;IACpDmC,EAAA;IACAoC,oBAAA,EAAsBX,eAAA;IACtBvB,cAAA;IACAC,IAAA;IACA4B,YAAA;IACAF,MAAA;IACAQ,cAAA,EAAgBb,SAAA;IAChBd,gBAAA,EAAkBsB,SAAA;IAClBpB,QAAA;IACAC,SAAA;IACAyB,WAAA,EAAajC,cAAA,EAAgBwB,MAAA,IAAU,CAAC;IACxCU,WAAA,EAAajC,cAAA,IAAkB;MAAEuB,MAAA,EAAQ,CAAC;IAAE;IAC5CW,iBAAA,EAAmBhC,SAAA;IACnBM,QAAA;IACAC,eAAA;IACA0B,aAAA,EAAe3E,WAAA;IACfO,GAAA;IACA6C,UAAA;IACAC,MAAA;IACAG,UAAA;IACAF;EACF;EAEA;EACA,IAAIlB,cAAA,IAAkBM,SAAA,EAAW;IAC/B,IAAI9B,OAAA,CAAQI,WAAW,CAACoB,cAAA,CAAe,EAAEvB,MAAA,EAAQ+D,MAAA,IAAUlC,SAAA,CAAUmC,IAAI,EAAE;MACzER,eAAA,CAAgBQ,IAAI,GAAGnC,SAAA,CAAUmC,IAAI;IACvC;EACF;EAEA,IAAIC,iBAAA;EAEJ,IAAI3B,gBAAA,EAAkB;IACpB2B,iBAAA,GAAoB,MAAM1E,sBAAA,CAAuB;MAC/C8B,EAAA;MACAE,cAAA;MACAO,UAAA;MACApC,GAAA;MACAgD;IACF;EACF;EAEA,OAAO;IACLwB,WAAA,EAAaD,iBAAA;IACbE,KAAA,EAAOX;EACT;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"buildFormState.js","names":["formatErrors","getSelectMode","reduceFieldsToValues","fieldSchemasToFormState","renderField","getClientConfig","getClientSchemaMap","getSchemaMap","handleFormStateLocking","buildFormStateHandler","args","req","incomingUserSlug","user","collection","adminUserSlug","payload","config","admin","adminAccessFunction","collections","access","canAccessAdmin","Error","hasUsers","find","depth","limit","pagination","docs","length","res","buildFormState","err","logger","error","msg","message","id","idFromArgs","collectionSlug","data","incomingData","docPermissions","docPreferences","documentFormState","formState","globalSlug","initialBlockData","initialBlockFormState","mockRSCs","operation","readOnly","renderAllFields","i18n","returnLockStatus","schemaPath","select","skipClientConfigAuth","skipValidation","updateLastEdited","selectMode","undefined","schemaMap","clientSchemaMap","importMap","fieldOrEntityConfig","get","fields","type","documentData","blockData","Array","isArray","formStateResult","clientFieldSchemaMap","fieldSchemaMap","permissions","preferences","previousFormState","renderFieldFn","upload","file","lockedStateResult","lockedState","state"],"sources":["../../src/utilities/buildFormState.ts"],"sourcesContent":["import type {\n BuildFormStateArgs,\n ClientConfig,\n ClientUser,\n ErrorResult,\n FormState,\n ServerFunction,\n} from 'payload'\n\nimport { formatErrors } from 'payload'\nimport { getSelectMode, reduceFieldsToValues } from 'payload/shared'\n\nimport { fieldSchemasToFormState } from '../forms/fieldSchemasToFormState/index.js'\nimport { renderField } from '../forms/fieldSchemasToFormState/renderField.js'\nimport { getClientConfig } from './getClientConfig.js'\nimport { getClientSchemaMap } from './getClientSchemaMap.js'\nimport { getSchemaMap } from './getSchemaMap.js'\nimport { handleFormStateLocking } from './handleFormStateLocking.js'\n\nexport type LockedState = {\n isLocked: boolean\n lastEditedAt: string\n user: ClientUser | number | string\n}\n\ntype BuildFormStateSuccessResult = {\n clientConfig?: ClientConfig\n errors?: never\n indexPath?: string\n lockedState?: LockedState\n state: FormState\n}\n\ntype BuildFormStateErrorResult = {\n lockedState?: never\n state?: never\n} & (\n | {\n message: string\n }\n | ErrorResult\n)\n\nexport type BuildFormStateResult = BuildFormStateErrorResult | BuildFormStateSuccessResult\n\nexport const buildFormStateHandler: ServerFunction<\n BuildFormStateArgs,\n Promise<BuildFormStateResult>\n> = async (args) => {\n const { req } = args\n\n const incomingUserSlug = req.user?.collection\n const adminUserSlug = req.payload.config.admin.user\n\n try {\n // If we have a user slug, test it against the functions\n if (incomingUserSlug) {\n const adminAccessFunction = req.payload.collections[incomingUserSlug].config.access?.admin\n\n // Run the admin access function from the config if it exists\n if (adminAccessFunction) {\n const canAccessAdmin = await adminAccessFunction({ req })\n\n if (!canAccessAdmin) {\n throw new Error('Unauthorized')\n }\n // Match the user collection to the global admin config\n } else if (adminUserSlug !== incomingUserSlug) {\n throw new Error('Unauthorized')\n }\n } else {\n const hasUsers = await req.payload.find({\n collection: adminUserSlug,\n depth: 0,\n limit: 1,\n pagination: false,\n })\n\n // If there are users, we should not allow access because of /create-first-user\n if (hasUsers.docs.length) {\n throw new Error('Unauthorized')\n }\n }\n\n const res = await buildFormState(args)\n return res\n } catch (err) {\n req.payload.logger.error({ err, msg: `There was an error building form state` })\n\n if (err.message === 'Could not find field schema for given path') {\n return {\n message: err.message,\n }\n }\n\n if (err.message === 'Unauthorized') {\n throw new Error('Unauthorized')\n }\n\n return formatErrors(err)\n }\n}\n\nexport const buildFormState = async (\n args: BuildFormStateArgs,\n): Promise<BuildFormStateSuccessResult> => {\n const {\n id: idFromArgs,\n collectionSlug,\n data: incomingData,\n docPermissions,\n docPreferences,\n documentFormState,\n formState,\n globalSlug,\n initialBlockData,\n initialBlockFormState,\n mockRSCs,\n operation,\n readOnly,\n renderAllFields,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n },\n returnLockStatus,\n schemaPath = collectionSlug || globalSlug,\n select,\n skipClientConfigAuth,\n skipValidation,\n updateLastEdited,\n } = args\n\n const selectMode = select ? getSelectMode(select) : undefined\n\n if (!collectionSlug && !globalSlug) {\n throw new Error('Either collectionSlug or globalSlug must be provided')\n }\n\n const schemaMap = getSchemaMap({\n collectionSlug,\n config,\n globalSlug,\n i18n,\n })\n\n const clientSchemaMap = getClientSchemaMap({\n collectionSlug,\n config: getClientConfig({\n config,\n i18n,\n importMap: req.payload.importMap,\n user: skipClientConfigAuth ? true : req.user,\n }),\n globalSlug,\n i18n,\n payload,\n schemaMap,\n })\n\n const id = collectionSlug ? idFromArgs : undefined\n const fieldOrEntityConfig = schemaMap.get(schemaPath)\n\n if (!fieldOrEntityConfig) {\n throw new Error(`Could not find \"${schemaPath}\" in the fieldSchemaMap`)\n }\n\n if (\n (!('fields' in fieldOrEntityConfig) ||\n !fieldOrEntityConfig.fields ||\n !fieldOrEntityConfig.fields.length) &&\n 'type' in fieldOrEntityConfig &&\n fieldOrEntityConfig.type !== 'blocks'\n ) {\n throw new Error(\n `The field found in fieldSchemaMap for \"${schemaPath}\" does not contain any subfields.`,\n )\n }\n\n // If there is form state but no data, deduce data from that form state, e.g. on initial load\n // Otherwise, use the incoming data as the source of truth, e.g. on subsequent saves\n const data = incomingData || reduceFieldsToValues(formState, true)\n\n let documentData = undefined\n\n if (documentFormState) {\n documentData = reduceFieldsToValues(documentFormState, true)\n }\n\n let blockData = initialBlockData\n\n if (initialBlockFormState) {\n blockData = reduceFieldsToValues(initialBlockFormState, true)\n }\n\n /**\n * When building state for sub schemas we need to adjust:\n * - `fields`\n * - `parentSchemaPath`\n * - `parentPath`\n *\n * Type assertion is fine because we wrap sub schemas in an array\n * so we can safely map over them within `fieldSchemasToFormState`\n */\n const fields = Array.isArray(fieldOrEntityConfig)\n ? fieldOrEntityConfig\n : 'fields' in fieldOrEntityConfig\n ? fieldOrEntityConfig.fields\n : [fieldOrEntityConfig]\n\n // Ensure data.id is present during form state requests, where the data\n // is passed from the client as an argument, without the ID\n if (!data.id && id) {\n data.id = id\n }\n\n const formStateResult = await fieldSchemasToFormState({\n id,\n clientFieldSchemaMap: clientSchemaMap,\n collectionSlug,\n data,\n documentData,\n fields,\n fieldSchemaMap: schemaMap,\n initialBlockData: blockData,\n mockRSCs,\n operation,\n permissions: docPermissions?.fields || {},\n preferences: docPreferences || { fields: {} },\n previousFormState: formState,\n readOnly,\n renderAllFields,\n renderFieldFn: renderField,\n req,\n schemaPath,\n select,\n selectMode,\n skipValidation,\n })\n\n // Maintain form state of auth / upload fields\n if (collectionSlug && formState) {\n if (payload.collections[collectionSlug]?.config?.upload && formState.file) {\n formStateResult.file = formState.file\n }\n }\n\n let lockedStateResult\n\n if (returnLockStatus) {\n lockedStateResult = await handleFormStateLocking({\n id,\n collectionSlug,\n globalSlug,\n req,\n updateLastEdited,\n })\n }\n\n return {\n lockedState: lockedStateResult,\n state: formStateResult,\n }\n}\n"],"mappings":"AASA,SAASA,YAAY,QAAQ;AAC7B,SAASC,aAAa,EAAEC,oBAAoB,QAAQ;AAEpD,SAASC,uBAAuB,QAAQ;AACxC,SAASC,WAAW,QAAQ;AAC5B,SAASC,eAAe,QAAQ;AAChC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,YAAY,QAAQ;AAC7B,SAASC,sBAAsB,QAAQ;AA4BvC,OAAO,MAAMC,qBAAA,GAGT,MAAOC,IAAA;EACT,MAAM;IAAEC;EAAG,CAAE,GAAGD,IAAA;EAEhB,MAAME,gBAAA,GAAmBD,GAAA,CAAIE,IAAI,EAAEC,UAAA;EACnC,MAAMC,aAAA,GAAgBJ,GAAA,CAAIK,OAAO,CAACC,MAAM,CAACC,KAAK,CAACL,IAAI;EAEnD,IAAI;IACF;IACA,IAAID,gBAAA,EAAkB;MACpB,MAAMO,mBAAA,GAAsBR,GAAA,CAAIK,OAAO,CAACI,WAAW,CAACR,gBAAA,CAAiB,CAACK,MAAM,CAACI,MAAM,EAAEH,KAAA;MAErF;MACA,IAAIC,mBAAA,EAAqB;QACvB,MAAMG,cAAA,GAAiB,MAAMH,mBAAA,CAAoB;UAAER;QAAI;QAEvD,IAAI,CAACW,cAAA,EAAgB;UACnB,MAAM,IAAIC,KAAA,CAAM;QAClB;QACA;MACF,OAAO,IAAIR,aAAA,KAAkBH,gBAAA,EAAkB;QAC7C,MAAM,IAAIW,KAAA,CAAM;MAClB;IACF,OAAO;MACL,MAAMC,QAAA,GAAW,MAAMb,GAAA,CAAIK,OAAO,CAACS,IAAI,CAAC;QACtCX,UAAA,EAAY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@ -8,9 +8,9 @@ type ReduceFieldOptionsArgs = {
|
|
|
8
8
|
pathPrefix?: string;
|
|
9
9
|
};
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
* Used in the WhereBuilder component to render the fields in the dropdown.
|
|
11
|
+
* Transforms a fields schema into a flattened array of fields with labels and values.
|
|
12
|
+
* Used in the `WhereBuilder` component to render the fields in the dropdown.
|
|
13
13
|
*/
|
|
14
|
-
export declare const reduceFieldsToOptions: ({ fields, i18n, labelPrefix, pathPrefix, }: ReduceFieldOptionsArgs) => ReducedField[];
|
|
14
|
+
export declare const reduceFieldsToOptions: ({ fields, i18n, labelPrefix, pathPrefix: pathPrefixFromArgs, }: ReduceFieldOptionsArgs) => ReducedField[];
|
|
15
15
|
export {};
|
|
16
16
|
//# sourceMappingURL=reduceFieldsToOptions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reduceFieldsToOptions.d.ts","sourceRoot":"","sources":["../../src/utilities/reduceFieldsToOptions.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAyB,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACjF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAK1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAA;AAMrE,KAAK,sBAAsB,GAAG;IAC5B,MAAM,EAAE,WAAW,EAAE,CAAA;IACrB,IAAI,EAAE,UAAU,CAAA;IAChB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB
|
|
1
|
+
{"version":3,"file":"reduceFieldsToOptions.d.ts","sourceRoot":"","sources":["../../src/utilities/reduceFieldsToOptions.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAyB,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACjF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAK1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAA;AAMrE,KAAK,sBAAsB,GAAG;IAC5B,MAAM,EAAE,WAAW,EAAE,CAAA;IACrB,IAAI,EAAE,UAAU,CAAA;IAChB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB,mEAK/B,sBAAsB,KAAG,YAAY,EAqMvC,CAAA"}
|
|
@@ -6,16 +6,17 @@ import fieldTypes, { arrayOperators } from '../elements/WhereBuilder/field-types
|
|
|
6
6
|
import { createNestedClientFieldPath } from '../forms/Form/createNestedClientFieldPath.js';
|
|
7
7
|
import { combineFieldLabel } from './combineFieldLabel.js';
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
* Used in the WhereBuilder component to render the fields in the dropdown.
|
|
9
|
+
* Transforms a fields schema into a flattened array of fields with labels and values.
|
|
10
|
+
* Used in the `WhereBuilder` component to render the fields in the dropdown.
|
|
11
11
|
*/
|
|
12
12
|
export const reduceFieldsToOptions = ({
|
|
13
13
|
fields,
|
|
14
14
|
i18n,
|
|
15
15
|
labelPrefix,
|
|
16
|
-
pathPrefix
|
|
16
|
+
pathPrefix: pathPrefixFromArgs
|
|
17
17
|
}) => {
|
|
18
18
|
return fields.reduce((reduced, field) => {
|
|
19
|
+
let pathPrefix = pathPrefixFromArgs;
|
|
19
20
|
// Do not filter out `field.admin.disableListFilter` fields here, as these should still render as disabled if they appear in the URL query
|
|
20
21
|
// Filter out `virtual: true` fields since they are regular virtuals and not backed by a DB field
|
|
21
22
|
if (fieldIsHiddenOrDisabled(field) && !fieldIsID(field) || 'virtual' in field && field.virtual === true) {
|
|
@@ -23,17 +24,11 @@ export const reduceFieldsToOptions = ({
|
|
|
23
24
|
}
|
|
24
25
|
// Handle virtual:string fields (virtual relationships, e.g. "post.title")
|
|
25
26
|
if ('virtual' in field && typeof field.virtual === 'string') {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
value: field.virtual,
|
|
32
|
-
...fieldTypes[field.type],
|
|
33
|
-
field,
|
|
34
|
-
operators: fieldTypes[field.type].operators
|
|
35
|
-
});
|
|
36
|
-
return reduced;
|
|
27
|
+
pathPrefix = pathPrefix ? pathPrefix + '.' + field.virtual : field.virtual;
|
|
28
|
+
if (fieldAffectsData(field)) {
|
|
29
|
+
// ignore virtual field names
|
|
30
|
+
field.name = '';
|
|
31
|
+
}
|
|
37
32
|
}
|
|
38
33
|
if (field.type === 'tabs' && 'tabs' in field) {
|
|
39
34
|
const tabs = field.tabs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reduceFieldsToOptions.js","names":["getTranslation","fieldAffectsData","fieldIsHiddenOrDisabled","fieldIsID","tabHasName","fieldTypes","arrayOperators","createNestedClientFieldPath","combineFieldLabel","reduceFieldsToOptions","fields","i18n","labelPrefix","pathPrefix","reduce","reduced","field","virtual","baseLabel","label","name","localizedLabel","push","plainTextLabel","value","type","operators","tabs","forEach","tab","localizedTabLabel","labelWithPrefix","tabPathPrefix","translatedLabel","pathWithPrefix","operatorKeys","Set","fieldOperators","hasMany","acc","operator","has","add","operatorKey","t","formattedLabel","prefix","fieldPath","formattedField"],"sources":["../../src/utilities/reduceFieldsToOptions.tsx"],"sourcesContent":["'use client'\nimport type { ClientTranslationKeys, I18nClient } from '@payloadcms/translations'\nimport type { ClientField } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { fieldAffectsData, fieldIsHiddenOrDisabled, fieldIsID, tabHasName } from 'payload/shared'\n\nimport type { ReducedField } from '../elements/WhereBuilder/types.js'\n\nimport fieldTypes, { arrayOperators } from '../elements/WhereBuilder/field-types.js'\nimport { createNestedClientFieldPath } from '../forms/Form/createNestedClientFieldPath.js'\nimport { combineFieldLabel } from './combineFieldLabel.js'\n\ntype ReduceFieldOptionsArgs = {\n fields: ClientField[]\n i18n: I18nClient\n labelPrefix?: string\n pathPrefix?: string\n}\n\n/**\n * Reduces a field map to a flat array of fields with labels and values.\n * Used in the WhereBuilder component to render the fields in the dropdown.\n */\nexport const reduceFieldsToOptions = ({\n fields,\n i18n,\n labelPrefix,\n pathPrefix,\n}: ReduceFieldOptionsArgs): ReducedField[] => {\n return fields.reduce((reduced, field) => {\n // Do not filter out `field.admin.disableListFilter` fields here, as these should still render as disabled if they appear in the URL query\n // Filter out `virtual: true` fields since they are regular virtuals and not backed by a DB field\n if (\n (fieldIsHiddenOrDisabled(field) && !fieldIsID(field)) ||\n ('virtual' in field && field.virtual === true)\n ) {\n return reduced\n }\n\n // Handle virtual:string fields (virtual relationships, e.g. \"post.title\")\n if ('virtual' in field && typeof field.virtual === 'string') {\n const baseLabel = ('label' in field && field.label) || ('name' in field && field.name) || ''\n const localizedLabel = getTranslation(baseLabel, i18n)\n\n reduced.push({\n label: localizedLabel,\n plainTextLabel: localizedLabel,\n value: field.virtual, // e.g. \"post.title\"\n ...fieldTypes[field.type],\n field,\n operators: fieldTypes[field.type].operators,\n })\n return reduced\n }\n\n if (field.type === 'tabs' && 'tabs' in field) {\n const tabs = field.tabs\n\n tabs.forEach((tab) => {\n if (typeof tab.label !== 'boolean') {\n const localizedTabLabel = getTranslation(tab.label, i18n)\n\n const labelWithPrefix = labelPrefix\n ? labelPrefix + ' > ' + localizedTabLabel\n : localizedTabLabel\n\n // Make sure we handle nested tabs\n const tabPathPrefix =\n tabHasName(tab) && tab.name\n ? pathPrefix\n ? pathPrefix + '.' + tab.name\n : tab.name\n : pathPrefix\n\n if (typeof localizedTabLabel === 'string') {\n reduced.push(\n ...reduceFieldsToOptions({\n fields: tab.fields,\n i18n,\n labelPrefix: labelWithPrefix,\n pathPrefix: tabPathPrefix,\n }),\n )\n }\n }\n })\n return reduced\n }\n\n // Rows cant have labels, so we need to handle them differently\n if (field.type === 'row' && 'fields' in field) {\n reduced.push(\n ...reduceFieldsToOptions({\n fields: field.fields,\n i18n,\n labelPrefix,\n pathPrefix,\n }),\n )\n return reduced\n }\n\n if (field.type === 'collapsible' && 'fields' in field) {\n const localizedTabLabel = getTranslation(field.label || '', i18n)\n\n const labelWithPrefix = labelPrefix\n ? labelPrefix + ' > ' + localizedTabLabel\n : localizedTabLabel\n\n reduced.push(\n ...reduceFieldsToOptions({\n fields: field.fields,\n i18n,\n labelPrefix: labelWithPrefix,\n pathPrefix,\n }),\n )\n return reduced\n }\n\n if (field.type === 'group' && 'fields' in field) {\n const translatedLabel = getTranslation(field.label || '', i18n)\n\n const labelWithPrefix = labelPrefix\n ? translatedLabel\n ? labelPrefix + ' > ' + translatedLabel\n : labelPrefix\n : translatedLabel\n\n if (fieldAffectsData(field)) {\n // Make sure we handle deeply nested groups\n const pathWithPrefix = field.name\n ? pathPrefix\n ? pathPrefix + '.' + field.name\n : field.name\n : pathPrefix\n\n reduced.push(\n ...reduceFieldsToOptions({\n fields: field.fields,\n i18n,\n labelPrefix: labelWithPrefix,\n pathPrefix: pathWithPrefix,\n }),\n )\n } else {\n reduced.push(\n ...reduceFieldsToOptions({\n fields: field.fields,\n i18n,\n labelPrefix: labelWithPrefix,\n pathPrefix,\n }),\n )\n }\n\n return reduced\n }\n\n if (field.type === 'array' && 'fields' in field) {\n const translatedLabel = getTranslation(field.label || '', i18n)\n\n const labelWithPrefix = labelPrefix\n ? translatedLabel\n ? labelPrefix + ' > ' + translatedLabel\n : labelPrefix\n : translatedLabel\n\n // Make sure we handle deeply nested groups\n const pathWithPrefix = field.name\n ? pathPrefix\n ? pathPrefix + '.' + field.name\n : field.name\n : pathPrefix\n\n reduced.push(\n ...reduceFieldsToOptions({\n fields: field.fields,\n i18n,\n labelPrefix: labelWithPrefix,\n pathPrefix: pathWithPrefix,\n }),\n )\n\n return reduced\n }\n\n if (typeof fieldTypes[field.type] === 'object') {\n const operatorKeys = new Set()\n\n const fieldOperators =\n 'hasMany' in field && field.hasMany ? arrayOperators : fieldTypes[field.type].operators\n\n const operators = fieldOperators.reduce((acc, operator) => {\n if (!operatorKeys.has(operator.value)) {\n operatorKeys.add(operator.value)\n const operatorKey = `operators:${operator.label}` as ClientTranslationKeys\n acc.push({\n ...operator,\n label: i18n.t(operatorKey),\n })\n }\n\n return acc\n }, [])\n\n const localizedLabel = getTranslation(field.label || '', i18n)\n\n const formattedLabel = labelPrefix\n ? combineFieldLabel({\n field,\n prefix: labelPrefix,\n })\n : localizedLabel\n\n const fieldPath = pathPrefix ? createNestedClientFieldPath(pathPrefix, field) : field.name\n\n const formattedField: ReducedField = {\n label: formattedLabel,\n plainTextLabel: `${labelPrefix ? labelPrefix + ' > ' : ''}${localizedLabel}`,\n value: fieldPath,\n ...fieldTypes[field.type],\n field,\n operators,\n }\n\n reduced.push(formattedField)\n return reduced\n }\n return reduced\n }, [])\n}\n"],"mappings":"AAAA;;AAIA,SAASA,cAAc,QAAQ;AAC/B,SAASC,gBAAgB,EAAEC,uBAAuB,EAAEC,SAAS,EAAEC,UAAU,QAAQ;AAIjF,OAAOC,UAAA,IAAcC,cAAc,QAAQ;AAC3C,SAASC,2BAA2B,QAAQ;AAC5C,SAASC,iBAAiB,QAAQ;AASlC;;;;AAIA,OAAO,MAAMC,qBAAA,GAAwBA,CAAC;EACpCC,MAAM;EACNC,IAAI;EACJC,WAAW;EACXC;AAAU,CACa;EACvB,OAAOH,MAAA,CAAOI,MAAM,CAAC,CAACC,OAAA,EAASC,KAAA;IAC7B;IACA;IACA,IACEd,uBAAC,CAAwBc,KAAA,KAAU,CAACb,SAAA,CAAUa,KAAA,KAC7C,aAAaA,KAAA,IAASA,KAAA,CAAMC,OAAO,KAAK,MACzC;MACA,OAAOF,OAAA;IACT;IAEA;IACA,IAAI,aAAaC,KAAA,IAAS,OAAOA,KAAA,CAAMC,OAAO,KAAK,UAAU;MAC3D,MAAMC,SAAA,GAAY,OAAC,IAAWF,KAAA,IAASA,KAAA,CAAMG,KAAK,IAAM,UAAUH,KAAA,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,QAAQ;YACXrB,KAAA,EAAOR,IAAA,CAAKiC,CAAC,CAACD,WAAA;UAChB;QACF;QAEA,OAAOJ,GAAA;MACT,GAAG,EAAE;MAEL,MAAMlB,cAAA,GAAiBrB,cAAA,CAAegB,KAAA,CAAMG,KAAK,IAAI,IAAIR,IAAA;MAEzD,MAAMkC,cAAA,GAAiBjC,WAAA,GACnBJ,iBAAA,CAAkB;QAChBQ,KAAA;QACA8B,MAAA,EAAQlC;MACV,KACAS,cAAA;MAEJ,MAAM0B,SAAA,GAAYlC,UAAA,GAAaN,2BAAA,CAA4BM,UAAA,EAAYG,KAAA,IAASA,KAAA,CAAMI,IAAI;MAE1F,MAAM4B,cAAA,GAA+B;QACnC7B,KAAA,EAAO0B,cAAA;QACPtB,cAAA,EAAgB,GAAGX,WAAA,GAAcA,WAAA,GAAc,QAAQ,KAAKS,cAAA,EAAgB;QAC5EG,KAAA,EAAOuB,SAAA;QACP,GAAG1C,UAAU,CAACW,KAAA,CAAMS,IAAI,CAAC;QACzBT,KAAA;QACAU;MACF;MAEAX,OAAA,CAAQO,IAAI,CAAC0B,cAAA;MACb,OAAOjC,OAAA;IACT;IACA,OAAOA,OAAA;EACT,GAAG,EAAE;AACP","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"reduceFieldsToOptions.js","names":["getTranslation","fieldAffectsData","fieldIsHiddenOrDisabled","fieldIsID","tabHasName","fieldTypes","arrayOperators","createNestedClientFieldPath","combineFieldLabel","reduceFieldsToOptions","fields","i18n","labelPrefix","pathPrefix","pathPrefixFromArgs","reduce","reduced","field","virtual","name","type","tabs","forEach","tab","label","localizedTabLabel","labelWithPrefix","tabPathPrefix","push","translatedLabel","pathWithPrefix","operatorKeys","Set","fieldOperators","hasMany","operators","acc","operator","has","value","add","operatorKey","t","localizedLabel","formattedLabel","prefix","fieldPath","formattedField","plainTextLabel"],"sources":["../../src/utilities/reduceFieldsToOptions.tsx"],"sourcesContent":["'use client'\nimport type { ClientTranslationKeys, I18nClient } from '@payloadcms/translations'\nimport type { ClientField } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { fieldAffectsData, fieldIsHiddenOrDisabled, fieldIsID, tabHasName } from 'payload/shared'\n\nimport type { ReducedField } from '../elements/WhereBuilder/types.js'\n\nimport fieldTypes, { arrayOperators } from '../elements/WhereBuilder/field-types.js'\nimport { createNestedClientFieldPath } from '../forms/Form/createNestedClientFieldPath.js'\nimport { combineFieldLabel } from './combineFieldLabel.js'\n\ntype ReduceFieldOptionsArgs = {\n fields: ClientField[]\n i18n: I18nClient\n labelPrefix?: string\n pathPrefix?: string\n}\n\n/**\n * Transforms a fields schema into a flattened array of fields with labels and values.\n * Used in the `WhereBuilder` component to render the fields in the dropdown.\n */\nexport const reduceFieldsToOptions = ({\n fields,\n i18n,\n labelPrefix,\n pathPrefix: pathPrefixFromArgs,\n}: ReduceFieldOptionsArgs): ReducedField[] => {\n return fields.reduce((reduced, field) => {\n let pathPrefix = pathPrefixFromArgs\n // Do not filter out `field.admin.disableListFilter` fields here, as these should still render as disabled if they appear in the URL query\n // Filter out `virtual: true` fields since they are regular virtuals and not backed by a DB field\n if (\n (fieldIsHiddenOrDisabled(field) && !fieldIsID(field)) ||\n ('virtual' in field && field.virtual === true)\n ) {\n return reduced\n }\n\n // Handle virtual:string fields (virtual relationships, e.g. \"post.title\")\n if ('virtual' in field && typeof field.virtual === 'string') {\n pathPrefix = pathPrefix ? pathPrefix + '.' + field.virtual : field.virtual\n if (fieldAffectsData(field)) {\n // ignore virtual field names\n field.name = ''\n }\n }\n\n if (field.type === 'tabs' && 'tabs' in field) {\n const tabs = field.tabs\n\n tabs.forEach((tab) => {\n if (typeof tab.label !== 'boolean') {\n const localizedTabLabel = getTranslation(tab.label, i18n)\n\n const labelWithPrefix = labelPrefix\n ? labelPrefix + ' > ' + localizedTabLabel\n : localizedTabLabel\n\n // Make sure we handle nested tabs\n const tabPathPrefix =\n tabHasName(tab) && tab.name\n ? pathPrefix\n ? pathPrefix + '.' + tab.name\n : tab.name\n : pathPrefix\n\n if (typeof localizedTabLabel === 'string') {\n reduced.push(\n ...reduceFieldsToOptions({\n fields: tab.fields,\n i18n,\n labelPrefix: labelWithPrefix,\n pathPrefix: tabPathPrefix,\n }),\n )\n }\n }\n })\n return reduced\n }\n\n // Rows cant have labels, so we need to handle them differently\n if (field.type === 'row' && 'fields' in field) {\n reduced.push(\n ...reduceFieldsToOptions({\n fields: field.fields,\n i18n,\n labelPrefix,\n pathPrefix,\n }),\n )\n return reduced\n }\n\n if (field.type === 'collapsible' && 'fields' in field) {\n const localizedTabLabel = getTranslation(field.label || '', i18n)\n\n const labelWithPrefix = labelPrefix\n ? labelPrefix + ' > ' + localizedTabLabel\n : localizedTabLabel\n\n reduced.push(\n ...reduceFieldsToOptions({\n fields: field.fields,\n i18n,\n labelPrefix: labelWithPrefix,\n pathPrefix,\n }),\n )\n return reduced\n }\n\n if (field.type === 'group' && 'fields' in field) {\n const translatedLabel = getTranslation(field.label || '', i18n)\n\n const labelWithPrefix = labelPrefix\n ? translatedLabel\n ? labelPrefix + ' > ' + translatedLabel\n : labelPrefix\n : translatedLabel\n\n if (fieldAffectsData(field)) {\n // Make sure we handle deeply nested groups\n const pathWithPrefix = field.name\n ? pathPrefix\n ? pathPrefix + '.' + field.name\n : field.name\n : pathPrefix\n\n reduced.push(\n ...reduceFieldsToOptions({\n fields: field.fields,\n i18n,\n labelPrefix: labelWithPrefix,\n pathPrefix: pathWithPrefix,\n }),\n )\n } else {\n reduced.push(\n ...reduceFieldsToOptions({\n fields: field.fields,\n i18n,\n labelPrefix: labelWithPrefix,\n pathPrefix,\n }),\n )\n }\n\n return reduced\n }\n\n if (field.type === 'array' && 'fields' in field) {\n const translatedLabel = getTranslation(field.label || '', i18n)\n\n const labelWithPrefix = labelPrefix\n ? translatedLabel\n ? labelPrefix + ' > ' + translatedLabel\n : labelPrefix\n : translatedLabel\n\n // Make sure we handle deeply nested groups\n const pathWithPrefix = field.name\n ? pathPrefix\n ? pathPrefix + '.' + field.name\n : field.name\n : pathPrefix\n\n reduced.push(\n ...reduceFieldsToOptions({\n fields: field.fields,\n i18n,\n labelPrefix: labelWithPrefix,\n pathPrefix: pathWithPrefix,\n }),\n )\n\n return reduced\n }\n\n if (typeof fieldTypes[field.type] === 'object') {\n const operatorKeys = new Set()\n\n const fieldOperators =\n 'hasMany' in field && field.hasMany ? arrayOperators : fieldTypes[field.type].operators\n\n const operators = fieldOperators.reduce((acc, operator) => {\n if (!operatorKeys.has(operator.value)) {\n operatorKeys.add(operator.value)\n const operatorKey = `operators:${operator.label}` as ClientTranslationKeys\n acc.push({\n ...operator,\n label: i18n.t(operatorKey),\n })\n }\n\n return acc\n }, [])\n\n const localizedLabel = getTranslation(field.label || '', i18n)\n\n const formattedLabel = labelPrefix\n ? combineFieldLabel({\n field,\n prefix: labelPrefix,\n })\n : localizedLabel\n\n const fieldPath = pathPrefix ? createNestedClientFieldPath(pathPrefix, field) : field.name\n\n const formattedField: ReducedField = {\n label: formattedLabel,\n plainTextLabel: `${labelPrefix ? labelPrefix + ' > ' : ''}${localizedLabel}`,\n value: fieldPath,\n ...fieldTypes[field.type],\n field,\n operators,\n }\n\n reduced.push(formattedField)\n return reduced\n }\n return reduced\n }, [])\n}\n"],"mappings":"AAAA;;AAIA,SAASA,cAAc,QAAQ;AAC/B,SAASC,gBAAgB,EAAEC,uBAAuB,EAAEC,SAAS,EAAEC,UAAU,QAAQ;AAIjF,OAAOC,UAAA,IAAcC,cAAc,QAAQ;AAC3C,SAASC,2BAA2B,QAAQ;AAC5C,SAASC,iBAAiB,QAAQ;AASlC;;;;AAIA,OAAO,MAAMC,qBAAA,GAAwBA,CAAC;EACpCC,MAAM;EACNC,IAAI;EACJC,WAAW;EACXC,UAAA,EAAYC;AAAkB,CACP;EACvB,OAAOJ,MAAA,CAAOK,MAAM,CAAC,CAACC,OAAA,EAASC,KAAA;IAC7B,IAAIJ,UAAA,GAAaC,kBAAA;IACjB;IACA;IACA,IACEZ,uB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YACXb,KAAA,EAAOb,IAAA,CAAK+B,CAAC,CAACD,WAAA;UAChB;QACF;QAEA,OAAOL,GAAA;MACT,GAAG,EAAE;MAEL,MAAMO,cAAA,GAAiB3C,cAAA,CAAeiB,KAAA,CAAMO,KAAK,IAAI,IAAIb,IAAA;MAEzD,MAAMiC,cAAA,GAAiBhC,WAAA,GACnBJ,iBAAA,CAAkB;QAChBS,KAAA;QACA4B,MAAA,EAAQjC;MACV,KACA+B,cAAA;MAEJ,MAAMG,SAAA,GAAYjC,UAAA,GAAaN,2BAAA,CAA4BM,UAAA,EAAYI,KAAA,IAASA,KAAA,CAAME,IAAI;MAE1F,MAAM4B,cAAA,GAA+B;QACnCvB,KAAA,EAAOoB,cAAA;QACPI,cAAA,EAAgB,GAAGpC,WAAA,GAAcA,WAAA,GAAc,QAAQ,KAAK+B,cAAA,EAAgB;QAC5EJ,KAAA,EAAOO,SAAA;QACP,GAAGzC,UAAU,CAACY,KAAA,CAAMG,IAAI,CAAC;QACzBH,KAAA;QACAkB;MACF;MAEAnB,OAAA,CAAQY,IAAI,CAACmB,cAAA;MACb,OAAO/B,OAAA;IACT;IACA,OAAOA,OAAA;EACT,GAAG,EAAE;AACP","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/ui",
|
|
3
|
-
"version": "3.56.0-internal.
|
|
3
|
+
"version": "3.56.0-internal.33536e7",
|
|
4
4
|
"homepage": "https://payloadcms.com",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -136,7 +136,7 @@
|
|
|
136
136
|
"ts-essentials": "10.0.3",
|
|
137
137
|
"use-context-selector": "2.0.0",
|
|
138
138
|
"uuid": "10.0.0",
|
|
139
|
-
"@payloadcms/translations": "3.56.0-internal.
|
|
139
|
+
"@payloadcms/translations": "3.56.0-internal.33536e7"
|
|
140
140
|
},
|
|
141
141
|
"devDependencies": {
|
|
142
142
|
"@babel/cli": "7.27.2",
|
|
@@ -151,14 +151,14 @@
|
|
|
151
151
|
"babel-plugin-react-compiler": "19.1.0-rc.2",
|
|
152
152
|
"esbuild": "0.25.5",
|
|
153
153
|
"esbuild-sass-plugin": "3.3.1",
|
|
154
|
-
"
|
|
155
|
-
"
|
|
154
|
+
"@payloadcms/eslint-config": "3.28.0",
|
|
155
|
+
"payload": "3.56.0-internal.33536e7"
|
|
156
156
|
},
|
|
157
157
|
"peerDependencies": {
|
|
158
158
|
"next": "^15.2.3",
|
|
159
159
|
"react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
160
160
|
"react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
161
|
-
"payload": "3.56.0-internal.
|
|
161
|
+
"payload": "3.56.0-internal.33536e7"
|
|
162
162
|
},
|
|
163
163
|
"engines": {
|
|
164
164
|
"node": "^18.20.2 || >=20.9.0"
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
// Workaround for react-datepicker and other cjs dependencies potentially inserting require("react") statements
|
|
3
|
-
import * as requireReact from 'react';
|
|
4
|
-
import * as requireReactDom from 'react-dom';
|
|
5
|
-
|
|
6
|
-
function require(m) {
|
|
7
|
-
if (m === 'react') return requireReact;
|
|
8
|
-
if (m === 'react-dom') return requireReactDom;
|
|
9
|
-
throw new Error(`Unknown module ${m}`);
|
|
10
|
-
}
|
|
11
|
-
// Workaround end
|
|
12
|
-
|
|
13
|
-
import{c as Er}from"react/compiler-runtime";import{jsx as qe}from"react/jsx-runtime";function Ke(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function le(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),r.push.apply(r,n)}return r}function ne(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?le(Object(r),!0).forEach(function(n){Ke(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):le(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Ge(t,e){if(t==null)return{};var r={},n=Object.keys(t),o,i;for(i=0;i<n.length;i++)o=n[i],!(e.indexOf(o)>=0)&&(r[o]=t[o]);return r}function de(t,e){if(t==null)return{};var r=Ge(t,e),n,o;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(o=0;o<i.length;o++)n=i[o],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function me(t,e){return Ye(t)||Je(t,e)||Qe(t,e)||Xe()}function Ye(t){if(Array.isArray(t))return t}function Je(t,e){if(!(typeof Symbol>"u"||!(Symbol.iterator in Object(t)))){var r=[],n=!0,o=!1,i=void 0;try{for(var a=t[Symbol.iterator](),c;!(n=(c=a.next()).done)&&(r.push(c.value),!(e&&r.length===e));n=!0);}catch(u){o=!0,i=u}finally{try{!n&&a.return!=null&&a.return()}finally{if(o)throw i}}return r}}function Qe(t,e){if(t){if(typeof t=="string")return fe(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return fe(t,e)}}function fe(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function Xe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
14
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ze(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function pe(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),r.push.apply(r,n)}return r}function ge(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?pe(Object(r),!0).forEach(function(n){Ze(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):pe(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function et(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return function(n){return e.reduceRight(function(o,i){return i(o)},n)}}function V(t){return function e(){for(var r=this,n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return o.length>=t.length?t.apply(this,o):function(){for(var a=arguments.length,c=new Array(a),u=0;u<a;u++)c[u]=arguments[u];return e.apply(r,[].concat(o,c))}}}function G(t){return{}.toString.call(t).includes("Object")}function tt(t){return!Object.keys(t).length}function B(t){return typeof t=="function"}function rt(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function nt(t,e){return G(e)||k("changeType"),Object.keys(e).some(function(r){return!rt(t,r)})&&k("changeField"),e}function ot(t){B(t)||k("selectorType")}function it(t){B(t)||G(t)||k("handlerType"),G(t)&&Object.values(t).some(function(e){return!B(e)})&&k("handlersType")}function at(t){t||k("initialIsRequired"),G(t)||k("initialType"),tt(t)&&k("initialContent")}function ct(t,e){throw new Error(t[e]||t.default)}var ut={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},k=V(ct)(ut),K={changes:nt,selector:ot,handler:it,initial:at};function st(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};K.initial(t),K.handler(e);var r={current:t},n=V(dt)(r,e),o=V(ft)(r),i=V(K.changes)(t),a=V(lt)(r);function c(){var f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(s){return s};return K.selector(f),f(r.current)}function u(f){et(n,o,i,a)(f)}return[c,u]}function lt(t,e){return B(e)?e(t.current):e}function ft(t,e){return t.current=ge(ge({},t.current),e),e}function dt(t,e,r){return B(e)?e(t.current):Object.keys(r).forEach(function(n){var o;return(o=e[n])===null||o===void 0?void 0:o.call(e,t.current[n])}),r}var mt={create:st},he=mt;var pt={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.52.2/min/vs"}},ve=pt;function gt(t){return function e(){for(var r=this,n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return o.length>=t.length?t.apply(this,o):function(){for(var a=arguments.length,c=new Array(a),u=0;u<a;u++)c[u]=arguments[u];return e.apply(r,[].concat(o,c))}}}var be=gt;function ht(t){return{}.toString.call(t).includes("Object")}var ye=ht;function vt(t){return t||we("configIsRequired"),ye(t)||we("configType"),t.urls?(bt(),{paths:{vs:t.urls.monacoBase}}):t}function bt(){console.warn(Oe.deprecation)}function yt(t,e){throw new Error(t[e]||t.default)}var Oe={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
|
|
15
|
-
You are using deprecated way of configuration.
|
|
16
|
-
|
|
17
|
-
Instead of using
|
|
18
|
-
monaco.config({ urls: { monacoBase: '...' } })
|
|
19
|
-
use
|
|
20
|
-
monaco.config({ paths: { vs: '...' } })
|
|
21
|
-
|
|
22
|
-
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
|
23
|
-
`},we=be(yt)(Oe),wt={config:vt},je=wt;var Ot=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return function(o){return r.reduceRight(function(i,a){return a(i)},o)}},Me=Ot;function Se(t,e){return Object.keys(e).forEach(function(r){e[r]instanceof Object&&t[r]&&Object.assign(e[r],Se(t[r],e[r]))}),ne(ne({},t),e)}var xe=Se;var jt={type:"cancelation",msg:"operation is manually canceled"};function Mt(t){var e=!1,r=new Promise(function(n,o){t.then(function(i){return e?o(jt):n(i)}),t.catch(o)});return r.cancel=function(){return e=!0},r}var Y=Mt;var St=he.create({config:ve,isInitialized:!1,resolve:null,reject:null,monaco:null}),Ee=me(St,2),H=Ee[0],J=Ee[1];function xt(t){var e=je.config(t),r=e.monaco,n=de(e,["monaco"]);J(function(o){return{config:xe(o.config,n),monaco:r}})}function Et(){var t=H(function(e){var r=e.monaco,n=e.isInitialized,o=e.resolve;return{monaco:r,isInitialized:n,resolve:o}});if(!t.isInitialized){if(J({isInitialized:!0}),t.monaco)return t.resolve(t.monaco),Y(oe);if(window.monaco&&window.monaco.editor)return Ce(window.monaco),t.resolve(window.monaco),Y(oe);Me(Ct,Tt)(It)}return Y(oe)}function Ct(t){return document.body.appendChild(t)}function Pt(t){var e=document.createElement("script");return t&&(e.src=t),e}function Tt(t){var e=H(function(n){var o=n.config,i=n.reject;return{config:o,reject:i}}),r=Pt("".concat(e.config.paths.vs,"/loader.js"));return r.onload=function(){return t()},r.onerror=e.reject,r}function It(){var t=H(function(r){var n=r.config,o=r.resolve,i=r.reject;return{config:n,resolve:o,reject:i}}),e=window.require;e.config(t.config),e(["vs/editor/editor.main"],function(r){Ce(r),t.resolve(r)},function(r){t.reject(r)})}function Ce(t){H().monaco||J({monaco:t})}function Rt(){return H(function(t){var e=t.monaco;return e})}var oe=new Promise(function(t,e){return J({resolve:t,reject:e})}),At={config:xt,init:Et,__getMonacoInstance:Rt},L=At;import{memo as Dt}from"react";import kt,{useState as Pe,useRef as _,useCallback as Te,useEffect as Ie}from"react";import{memo as Lt}from"react";import ie from"react";import $t from"react";import{useEffect as qt}from"react";import{useEffect as Kt,useRef as Gt}from"react";import{useState as mn}from"react";import{memo as er}from"react";import tr,{useState as Re,useEffect as Q,useRef as A,useCallback as rr}from"react";import{useEffect as nr,useRef as or}from"react";var _t={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},ae=_t,Wt={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Nt=Wt;function Vt({children:t}){return $t.createElement("div",{style:Nt.container},t)}var Bt=Vt,Ht=Bt;function Ft({width:t,height:e,isEditorReady:r,loading:n,_ref:o,className:i,wrapperProps:a}){return ie.createElement("section",{style:{...ae.wrapper,width:t,height:e},...a},!r&&ie.createElement(Ht,null,n),ie.createElement("div",{ref:o,style:{...ae.fullWidth,...!r&&ae.hide},className:i}))}var Ut=Ft,Ae=Lt(Ut);function zt(t){qt(t,[])}var De=zt;function Yt(t,e,r=!0){let n=Gt(!0);Kt(n.current||!r?()=>{n.current=!1}:t,e)}var E=Yt;function F(){}function $(t,e,r,n){return Jt(t,n)||Qt(t,e,r,n)}function Jt(t,e){return t.editor.getModel(ke(t,e))}function Qt(t,e,r,n){return t.editor.createModel(e,r,n?ke(t,n):void 0)}function ke(t,e){return t.Uri.parse(e)}function Xt({original:t,modified:e,language:r,originalLanguage:n,modifiedLanguage:o,originalModelPath:i,modifiedModelPath:a,keepCurrentOriginalModel:c=!1,keepCurrentModifiedModel:u=!1,theme:f="light",loading:s="Loading...",options:l={},height:m="100%",width:h="100%",className:O,wrapperProps:j={},beforeMount:M=F,onMount:C=F}){let[w,I]=Pe(!1),[P,b]=Pe(!0),y=_(null),p=_(null),T=_(null),v=_(C),d=_(M),R=_(!1);De(()=>{let g=L.init();return g.then(S=>(p.current=S)&&b(!1)).catch(S=>S?.type!=="cancelation"&&console.error("Monaco initialization: error:",S)),()=>y.current?N():g.cancel()}),E(()=>{if(y.current&&p.current){let g=y.current.getOriginalEditor(),S=$(p.current,t||"",n||r||"text",i||"");S!==g.getModel()&&g.setModel(S)}},[i],w),E(()=>{if(y.current&&p.current){let g=y.current.getModifiedEditor(),S=$(p.current,e||"",o||r||"text",a||"");S!==g.getModel()&&g.setModel(S)}},[a],w),E(()=>{let g=y.current.getModifiedEditor();g.getOption(p.current.editor.EditorOption.readOnly)?g.setValue(e||""):e!==g.getValue()&&(g.executeEdits("",[{range:g.getModel().getFullModelRange(),text:e||"",forceMoveMarkers:!0}]),g.pushUndoStop())},[e],w),E(()=>{y.current?.getModel()?.original.setValue(t||"")},[t],w),E(()=>{let{original:g,modified:S}=y.current.getModel();p.current.editor.setModelLanguage(g,n||r||"text"),p.current.editor.setModelLanguage(S,o||r||"text")},[r,n,o],w),E(()=>{p.current?.editor.setTheme(f)},[f],w),E(()=>{y.current?.updateOptions(l)},[l],w);let q=Te(()=>{if(!p.current)return;d.current(p.current);let g=$(p.current,t||"",n||r||"text",i||""),S=$(p.current,e||"",o||r||"text",a||"");y.current?.setModel({original:g,modified:S})},[r,e,o,t,n,i,a]),z=Te(()=>{!R.current&&T.current&&(y.current=p.current.editor.createDiffEditor(T.current,{automaticLayout:!0,...l}),q(),p.current?.editor.setTheme(f),I(!0),R.current=!0)},[l,f,q]);Ie(()=>{w&&v.current(y.current,p.current)},[w]),Ie(()=>{!P&&!w&&z()},[P,w,z]);function N(){let g=y.current?.getModel();c||g?.original?.dispose(),u||g?.modified?.dispose(),y.current?.dispose()}return kt.createElement(Ae,{width:h,height:m,isEditorReady:w,loading:s,_ref:T,className:O,wrapperProps:j})}var Zt=Xt,fn=Dt(Zt);function ir(t){let e=or();return nr(()=>{e.current=t},[t]),e.current}var ar=ir,X=new Map;function cr({defaultValue:t,defaultLanguage:e,defaultPath:r,value:n,language:o,path:i,theme:a="light",line:c,loading:u="Loading...",options:f={},overrideServices:s={},saveViewState:l=!0,keepCurrentModel:m=!1,width:h="100%",height:O="100%",className:j,wrapperProps:M={},beforeMount:C=F,onMount:w=F,onChange:I,onValidate:P=F}){let[b,y]=Re(!1),[p,T]=Re(!0),v=A(null),d=A(null),R=A(null),q=A(w),z=A(C),N=A(),g=A(n),S=ar(i),ue=A(!1),ee=A(!1);De(()=>{let x=L.init();return x.then(D=>(v.current=D)&&T(!1)).catch(D=>D?.type!=="cancelation"&&console.error("Monaco initialization: error:",D)),()=>d.current?ze():x.cancel()}),E(()=>{let x=$(v.current,t||n||"",e||o||"",i||r||"");x!==d.current?.getModel()&&(l&&X.set(S,d.current?.saveViewState()),d.current?.setModel(x),l&&d.current?.restoreViewState(X.get(i)))},[i],b),E(()=>{d.current?.updateOptions(f)},[f],b),E(()=>{!d.current||n===void 0||(d.current.getOption(v.current.editor.EditorOption.readOnly)?d.current.setValue(n):n!==d.current.getValue()&&(ee.current=!0,d.current.executeEdits("",[{range:d.current.getModel().getFullModelRange(),text:n,forceMoveMarkers:!0}]),d.current.pushUndoStop(),ee.current=!1))},[n],b),E(()=>{let x=d.current?.getModel();x&&o&&v.current?.editor.setModelLanguage(x,o)},[o],b),E(()=>{c!==void 0&&d.current?.revealLine(c)},[c],b),E(()=>{v.current?.editor.setTheme(a)},[a],b);let se=rr(()=>{if(!(!R.current||!v.current)&&!ue.current){z.current(v.current);let x=i||r,D=$(v.current,n||t||"",e||o||"",x||"");d.current=v.current?.editor.create(R.current,{model:D,automaticLayout:!0,...f},s),l&&d.current.restoreViewState(X.get(x)),v.current.editor.setTheme(a),c!==void 0&&d.current.revealLine(c),y(!0),ue.current=!0}},[t,e,r,n,o,i,f,s,l,a,c]);Q(()=>{b&&q.current(d.current,v.current)},[b]),Q(()=>{!p&&!b&&se()},[p,b,se]),g.current=n,Q(()=>{b&&I&&(N.current?.dispose(),N.current=d.current?.onDidChangeModelContent(x=>{ee.current||I(d.current.getValue(),x)}))},[b,I]),Q(()=>{if(b){let x=v.current.editor.onDidChangeMarkers(D=>{let te=d.current.getModel()?.uri;if(te&&D.find(re=>re.path===te.path)){let re=v.current.editor.getModelMarkers({resource:te});P?.(re)}});return()=>{x?.dispose()}}return()=>{}},[b,P]);function ze(){N.current?.dispose(),m?l&&X.set(i,d.current.saveViewState()):d.current.getModel()?.dispose(),d.current.dispose()}return tr.createElement(Ae,{width:h,height:O,isEditorReady:b,loading:u,_ref:R,className:j,wrapperProps:M})}var ur=cr,sr=er(ur),Z=sr;import{useState as Cr}from"react";import{c as hr}from"react/compiler-runtime";import{jsx as vr}from"react/jsx-runtime";import{createContext as br,use as yr,useEffect as wr,useState as Ve}from"react";import{jsx as lr}from"react/jsx-runtime";import{createContext as fr,use as dr,useCallback as Le,useEffect as mr,useMemo as _e,useRef as pr,useState as gr}from"react";var We=fr(void 0);function $e(t){if(!t?.blocks?.length||t.blocksMap)return t.blocksMap={},t;let e={...t};e.blocksMap={};for(let r of t.blocks)e.blocksMap[r.slug]=r;return e}var Mn=({children:t,config:e})=>{let[r,n]=gr(()=>$e(e)),o=pr(!0),i=Le(s=>{n($e(s))},[]);mr(()=>{if(o.current){o.current=!1;return}i(e)},[e,i]);let{collectionsBySlug:a,globalsBySlug:c}=_e(()=>{let s={},l={};for(let m of r.collections)s[m.slug]=m;for(let m of r.globals)l[m.slug]=m;return{collectionsBySlug:s,globalsBySlug:l}},[r]),u=Le(s=>"collectionSlug"in s?a[s.collectionSlug]??null:"globalSlug"in s?c[s.globalSlug]??null:null,[a,c]),f=_e(()=>({config:r,getEntityConfig:u,setConfig:i}),[r,u]);return lr(We,{value:f,children:t})},Ne=()=>dr(We);var Or={autoMode:!0,setTheme:()=>null,theme:"light"},He=br(Or);function Be(t,e,r){let n=new Date;n.setTime(n.getTime()+r*24*60*60*1e3);let o="expires="+n.toUTCString();document.cookie=t+"="+e+";"+o+";path=/"}var jr=t=>{let e,r=window.document.cookie.split("; ").find(n=>n.startsWith(`${t}=`))?.split("=")[1];return r==="light"||r==="dark"?e=r:e=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",document.documentElement.setAttribute("data-theme",e),{theme:e,themeFromCookies:r}},Mr="light",Rn=t=>{let e=hr(11),{children:r,theme:n}=t,{config:o}=Ne(),i=o.admin.theme,a=`${o.cookiePrefix||"payload"}-theme`,[c,u]=Ve(n||Mr),[f,s]=Ve(),l,m;e[0]!==a||e[1]!==i?(l=()=>{if(i!=="all")return;let{theme:M,themeFromCookies:C}=jr(a);u(M),s(!C)},m=[i,a],e[0]=a,e[1]=i,e[2]=l,e[3]=m):(l=e[2],m=e[3]),wr(l,m);let h;e[4]!==a?(h=M=>{if(M==="light"||M==="dark")u(M),s(!1),Be(a,M,365),document.documentElement.setAttribute("data-theme",M);else if(M==="auto"){Be(a,M,-1);let C=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";document.documentElement.setAttribute("data-theme",C),s(!0),u(C)}},e[4]=a,e[5]=h):h=e[5];let O=h,j;return e[6]!==f||e[7]!==r||e[8]!==O||e[9]!==c?(j=vr(He,{value:{autoMode:f,setTheme:O,theme:c},children:r}),e[6]=f,e[7]=r,e[8]=O,e[9]=c,e[10]=j):j=e[10],j},Fe=()=>yr(He);import{c as xr}from"react/compiler-runtime";import{jsx as U}from"react/jsx-runtime";import"react";import{c as Sr}from"react/compiler-runtime";import*as W from"react";var Ue=(t,e)=>{let r=Sr(9),n=e===void 0?!1:e,[o,i]=W.useState(!1),a=W.useRef(void 0),c;r[0]!==t?(c=()=>(i(!1),clearTimeout(a.current),a.current=setTimeout(()=>{i(!0)},t),()=>{clearTimeout(a.current)}),r[0]=t,r[1]=c):c=r[1];let u=c,f,s;r[2]!==u||r[3]!==n?(f=()=>{n&&u()},s=[u,n],r[2]=u,r[3]=n,r[4]=f,r[5]=s):(f=r[4],s=r[5]),W.useEffect(f,s);let l;return r[6]!==o||r[7]!==u?(l=[o,u],r[6]=o,r[7]=u,r[8]=l):l=r[8],l};var ce=({animationDelay:t="0ms",className:e,disableInlineStyles:r=!1,height:n="60px",width:o="100%"})=>U("div",{className:["shimmer-effect",e].filter(Boolean).join(" "),style:{height:!r&&(typeof n=="number"?`${n}px`:n),width:!r&&(typeof o=="number"?`${o}px`:o)},children:U("div",{className:"shimmer-effect__shine",style:{animationDelay:t}})}),Nn=t=>{let e=xr(7),{className:r,count:n,height:o,renderDelay:i,shimmerDelay:a,shimmerItemClassName:c,width:u}=t,f=i===void 0?500:i,s=a===void 0?25:a,l=typeof s=="number"?`${s}ms`:s,[m]=Ue(f,!0);if(!m)return null;let h;return e[0]!==r||e[1]!==n||e[2]!==o||e[3]!==l||e[4]!==c||e[5]!==u?(h=U("div",{className:r,children:[...Array(n)].map((O,j)=>U("div",{className:c,children:U(ce,{animationDelay:`calc(${j} * ${l})`,height:o,width:u})},j))}),e[0]=r,e[1]=n,e[2]=o,e[3]=l,e[4]=c,e[5]=u,e[6]=h):h=e[6],h};var Pr="default"in Z?Z.default:Z,Tr="code-editor",Ir=t=>{let e=Er(42),r,n,o,i,a,c;e[0]!==t?({className:r,maxHeight:n,minHeight:o,options:i,readOnly:a,...c}=t,e[0]=t,e[1]=r,e[2]=n,e[3]=o,e[4]=i,e[5]=a,e[6]=c):(r=e[1],n=e[2],o=e[3],i=e[4],a=e[5],c=e[6]);let u=o??56,f;e[7]!==i?(f=i||{},e[7]=i,e[8]=f):f=e[8];let s,l,m,h;e[9]!==f?({insertSpaces:l,tabSize:m,trimAutoWhitespace:h,...s}=f,e[9]=f,e[10]=s,e[11]=l,e[12]=m,e[13]=h):(s=e[10],l=e[11],m=e[12],h=e[13]);let O=i?.padding?(i.padding.top||0)+(i.padding?.bottom||0):0,[j,M]=Cr(u),{theme:C}=Fe(),w=c?.defaultLanguage?`language--${c.defaultLanguage}`:"",I=a&&"read-only",P;e[14]!==r||e[15]!==w||e[16]!==I?(P=[Tr,r,w,I].filter(Boolean),e[14]=r,e[15]=w,e[16]=I,e[17]=P):P=e[17];let b=P.join(" "),y;if(e[18]!==u||e[19]!==b||e[20]!==j||e[21]!==s||e[22]!==l||e[23]!==n||e[24]!==O||e[25]!==a||e[26]!==c||e[27]!==m||e[28]!==C||e[29]!==h){let p;e[31]!==u||e[32]!==O||e[33]!==c?(p=(v,d)=>{c.onChange?.(v,d),M(Math.max(u,v.split(`
|
|
24
|
-
`).length*18+2+O))},e[31]=u,e[32]=O,e[33]=c,e[34]=p):p=e[34];let T;e[35]!==u||e[36]!==l||e[37]!==O||e[38]!==c||e[39]!==m||e[40]!==h?(T=(v,d)=>{c.onMount?.(v,d);let R=v.getModel();R&&R.updateOptions({insertSpaces:l??!0,tabSize:m??4,trimAutoWhitespace:h??!0}),M(Math.max(u,v.getValue().split(`
|
|
25
|
-
`).length*18+2+O))},e[35]=u,e[36]=l,e[37]=O,e[38]=c,e[39]=m,e[40]=h,e[41]=T):T=e[41],y=qe(Pr,{className:b,loading:qe(ce,{height:j}),options:{detectIndentation:!1,hideCursorInOverviewRuler:!0,insertSpaces:!1,minimap:{enabled:!1},overviewRulerBorder:!1,readOnly:!!a,scrollbar:{alwaysConsumeMouseWheel:!1},scrollBeyondLastLine:!1,trimAutoWhitespace:!1,wordWrap:"on",...s},theme:C==="dark"?"vs-dark":"vs",...c,height:n?Math.min(j,n):j,onChange:p,onMount:T}),e[18]=u,e[19]=b,e[20]=j,e[21]=s,e[22]=l,e[23]=n,e[24]=O,e[25]=a,e[26]=c,e[27]=m,e[28]=C,e[29]=h,e[30]=y}else y=e[30];return y},Gn=Ir;export{Mn as a,Ne as b,Ue as c,ce as d,Nn as e,Mr as f,Rn as g,Fe as h,Gn as i};
|
|
26
|
-
//# sourceMappingURL=chunk-KPQQ5IUL.js.map
|
|
File without changes
|