@payloadcms/ui 3.1.1 → 3.1.2-canary.eb1a61e
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/AnimateHeight/index.d.ts +10 -0
- package/dist/elements/AnimateHeight/index.d.ts.map +1 -0
- package/dist/elements/AnimateHeight/index.js +75 -0
- package/dist/elements/AnimateHeight/index.js.map +1 -0
- package/dist/elements/AnimateHeight/index.scss +8 -0
- package/dist/elements/AnimateHeight/usePatchAnimateHeight.d.ts +8 -0
- package/dist/elements/AnimateHeight/usePatchAnimateHeight.d.ts.map +1 -0
- package/dist/elements/AnimateHeight/usePatchAnimateHeight.js +49 -0
- package/dist/elements/AnimateHeight/usePatchAnimateHeight.js.map +1 -0
- package/dist/elements/AppHeader/index.scss +7 -8
- package/dist/elements/BulkUpload/FileSidebar/index.d.ts.map +1 -1
- package/dist/elements/BulkUpload/FileSidebar/index.js +2 -4
- package/dist/elements/BulkUpload/FileSidebar/index.js.map +1 -1
- package/dist/elements/Collapsible/index.d.ts.map +1 -1
- package/dist/elements/Collapsible/index.js +1 -3
- package/dist/elements/Collapsible/index.js.map +1 -1
- package/dist/elements/ListControls/index.d.ts.map +1 -1
- package/dist/elements/ListControls/index.js +2 -3
- package/dist/elements/ListControls/index.js.map +1 -1
- package/dist/elements/NavGroup/index.d.ts.map +1 -1
- package/dist/elements/NavGroup/index.js +1 -2
- package/dist/elements/NavGroup/index.js.map +1 -1
- package/dist/elements/RelationshipTable/index.d.ts.map +1 -1
- package/dist/elements/RelationshipTable/index.js +3 -4
- package/dist/elements/RelationshipTable/index.js.map +1 -1
- package/dist/exports/client/index.js +21 -21
- package/dist/exports/client/index.js.map +4 -4
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.d.ts +2 -1
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.js +10 -0
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/index.d.ts +7 -1
- package/dist/forms/fieldSchemasToFormState/index.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/index.js +5 -0
- package/dist/forms/fieldSchemasToFormState/index.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/iterateFields.d.ts +3 -2
- package/dist/forms/fieldSchemasToFormState/iterateFields.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/iterateFields.js +2 -0
- package/dist/forms/fieldSchemasToFormState/iterateFields.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/renderField.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/renderField.js +4 -3
- package/dist/forms/fieldSchemasToFormState/renderField.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/types.d.ts +2 -1
- package/dist/forms/fieldSchemasToFormState/types.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/types.js.map +1 -1
- package/dist/providers/Locale/index.js +30 -29
- package/dist/providers/Locale/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/utilities/buildClientFieldSchemaMap/index.d.ts +16 -0
- package/dist/utilities/buildClientFieldSchemaMap/index.d.ts.map +1 -0
- package/dist/utilities/buildClientFieldSchemaMap/index.js +70 -0
- package/dist/utilities/buildClientFieldSchemaMap/index.js.map +1 -0
- package/dist/utilities/buildClientFieldSchemaMap/traverseFields.d.ts +15 -0
- package/dist/utilities/buildClientFieldSchemaMap/traverseFields.d.ts.map +1 -0
- package/dist/utilities/buildClientFieldSchemaMap/traverseFields.js +129 -0
- package/dist/utilities/buildClientFieldSchemaMap/traverseFields.js.map +1 -0
- package/dist/utilities/buildFieldSchemaMap/index.d.ts.map +1 -1
- package/dist/utilities/buildFieldSchemaMap/index.js +13 -14
- package/dist/utilities/buildFieldSchemaMap/index.js.map +1 -1
- package/dist/utilities/buildFieldSchemaMap/traverseFields.d.ts.map +1 -1
- package/dist/utilities/buildFieldSchemaMap/traverseFields.js.map +1 -1
- package/dist/utilities/buildFormState.d.ts +1 -8
- package/dist/utilities/buildFormState.d.ts.map +1 -1
- package/dist/utilities/buildFormState.js +19 -41
- package/dist/utilities/buildFormState.js.map +1 -1
- package/dist/utilities/buildTableState.d.ts +1 -7
- package/dist/utilities/buildTableState.d.ts.map +1 -1
- package/dist/utilities/buildTableState.js +2 -21
- package/dist/utilities/buildTableState.js.map +1 -1
- package/dist/utilities/getClientConfig.d.ts +8 -0
- package/dist/utilities/getClientConfig.d.ts.map +1 -0
- package/dist/utilities/getClientConfig.js +25 -0
- package/dist/utilities/getClientConfig.js.map +1 -0
- package/dist/utilities/getClientSchemaMap.d.ts +11 -0
- package/dist/utilities/getClientSchemaMap.d.ts.map +1 -0
- package/dist/utilities/getClientSchemaMap.js +39 -0
- package/dist/utilities/getClientSchemaMap.js.map +1 -0
- package/dist/utilities/getSchemaMap.d.ts +9 -0
- package/dist/utilities/getSchemaMap.d.ts.map +1 -0
- package/dist/utilities/getSchemaMap.js +35 -0
- package/dist/utilities/getSchemaMap.js.map +1 -0
- package/dist/views/Edit/Auth/types.d.ts +2 -2
- package/dist/views/Edit/Auth/types.d.ts.map +1 -1
- package/dist/views/Edit/Auth/types.js.map +1 -1
- package/package.json +5 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildTableState.js","names":["dequal","createClientConfig","formatErrors","renderFilters","renderTable","cachedClientConfig","global","_payload_clientConfig","getClientConfig","args","config","i18n","importMap","process","env","NODE_ENV","buildTableStateHandler","req","res","buildTableState","err","payload","logger","error","msg","message","collectionSlug","columns","docs","docsFromArgs","enableRowSelections","query","renderRowTypes","user","tableAppearance","incomingUserSlug","collection","adminUserSlug","admin","adminAccessFunction","collections","access","canAccessAdmin","Error","hasUsers","find","depth","limit","pagination","length","clientConfig","collectionConfig","clientCollectionConfig","slug","preferencesKey","preferencesResult","where","and","key","equals","id","then","value","newPrefs","preferencesArgs","data","update","create","fields","parseInt","undefined","page","sort","columnState","Table","columnPreferences","useAsTitle","renderedFilters","preferences","state"],"sources":["../../src/utilities/buildTableState.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type {\n BuildTableStateArgs,\n ClientCollectionConfig,\n ClientConfig,\n ErrorResult,\n ImportMap,\n PaginatedDocs,\n SanitizedCollectionConfig,\n SanitizedConfig,\n} from 'payload'\n\nimport { dequal } from 'dequal/lite'\nimport { createClientConfig, formatErrors } from 'payload'\n\nimport type { Column } from '../elements/Table/index.js'\nimport type { ListPreferences } from '../elements/TableColumns/index.js'\n\nimport { renderFilters, renderTable } from './renderTable.js'\n\nlet cachedClientConfig = global._payload_clientConfig\n\nif (!cachedClientConfig) {\n cachedClientConfig = global._payload_clientConfig = null\n}\n\nexport const getClientConfig = (args: {\n config: SanitizedConfig\n i18n: I18nClient\n importMap: ImportMap\n}): ClientConfig => {\n const { config, i18n, importMap } = args\n\n if (cachedClientConfig && process.env.NODE_ENV !== 'development') {\n return cachedClientConfig\n }\n\n cachedClientConfig = createClientConfig({\n config,\n i18n,\n importMap,\n })\n\n return cachedClientConfig\n}\n\ntype BuildTableStateSuccessResult = {\n clientConfig?: ClientConfig\n data: PaginatedDocs\n errors?: never\n preferences: ListPreferences\n renderedFilters: Map<string, React.ReactNode>\n state: Column[]\n Table: React.ReactNode\n}\n\ntype BuildTableStateErrorResult = {\n data?: any\n renderedFilters?: never\n state?: never\n Table?: never\n} & (\n | {\n message: string\n }\n | ErrorResult\n)\n\nexport type BuildTableStateResult = BuildTableStateErrorResult | BuildTableStateSuccessResult\n\nexport const buildTableStateHandler = async (\n args: BuildTableStateArgs,\n): Promise<BuildTableStateResult> => {\n const { req } = args\n\n try {\n const res = await buildTableState(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 return null\n }\n\n return formatErrors(err)\n }\n}\n\nexport const buildTableState = async (\n args: BuildTableStateArgs,\n): Promise<BuildTableStateSuccessResult> => {\n const {\n collectionSlug,\n columns,\n docs: docsFromArgs,\n enableRowSelections,\n query,\n renderRowTypes,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n user,\n },\n tableAppearance,\n } = args\n\n const incomingUserSlug = user?.collection\n\n const adminUserSlug = config.admin.user\n\n // If we have a user slug, test it against the functions\n if (incomingUserSlug) {\n const adminAccessFunction = 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 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 clientConfig = getClientConfig({\n config,\n i18n,\n importMap: payload.importMap,\n })\n\n let collectionConfig: SanitizedCollectionConfig\n let clientCollectionConfig: ClientCollectionConfig\n\n if (req.payload.collections[collectionSlug]) {\n collectionConfig = req.payload.collections[collectionSlug].config\n clientCollectionConfig = clientConfig.collections.find(\n (collection) => collection.slug === collectionSlug,\n )\n }\n\n // get prefs, then set update them using the columns that we just received\n const preferencesKey = `${collectionSlug}-list`\n\n const preferencesResult = await payload\n .find({\n collection: 'payload-preferences',\n depth: 0,\n limit: 1,\n pagination: false,\n where: {\n and: [\n {\n key: {\n equals: preferencesKey,\n },\n },\n {\n 'user.relationTo': {\n equals: user.collection,\n },\n },\n {\n 'user.value': {\n equals: user.id,\n },\n },\n ],\n },\n })\n .then((res) => res.docs[0] ?? { id: null, value: {} })\n\n let newPrefs = preferencesResult.value\n\n if (!preferencesResult.id || !dequal(columns, preferencesResult?.columns)) {\n const preferencesArgs = {\n collection: 'payload-preferences',\n data: {\n key: preferencesKey,\n user: {\n collection: user.collection,\n value: user.id,\n },\n value: {\n ...(preferencesResult?.value || {}),\n columns,\n },\n },\n depth: 0,\n req,\n }\n\n if (preferencesResult.id) {\n newPrefs = await payload\n .update({\n ...preferencesArgs,\n id: preferencesResult.id,\n })\n ?.then((res) => res.value as ListPreferences)\n } else {\n newPrefs = await payload.create(preferencesArgs)?.then((res) => res.value as ListPreferences)\n }\n }\n\n const fields = collectionConfig.fields\n\n let docs = docsFromArgs\n let data: PaginatedDocs\n\n // lookup docs, if desired, i.e. within `join` field which initialize with `depth: 0`\n\n if (!docs || query) {\n data = await payload.find({\n collection: collectionSlug,\n depth: 0,\n limit: query?.limit ? parseInt(query.limit, 10) : undefined,\n page: query?.page ? parseInt(query.page, 10) : undefined,\n sort: query?.sort,\n where: query?.where,\n })\n\n docs = data.docs\n }\n\n const { columnState, Table } = renderTable({\n collectionConfig: clientCollectionConfig,\n columnPreferences: undefined, // TODO, might not be needed\n columns,\n docs,\n enableRowSelections,\n fields,\n i18n: req.i18n,\n payload,\n renderRowTypes,\n tableAppearance,\n useAsTitle: collectionConfig.admin.useAsTitle,\n })\n\n const renderedFilters = renderFilters(fields, req.payload.importMap)\n\n return {\n data,\n preferences: newPrefs,\n renderedFilters,\n state: columnState,\n Table,\n }\n}\n"],"mappings":"AAYA,SAASA,MAAM,QAAQ;AACvB,SAASC,kBAAkB,EAAEC,YAAY,QAAQ;AAKjD,SAASC,aAAa,EAAEC,WAAW,QAAQ;AAE3C,IAAIC,kBAAA,GAAqBC,MAAA,CAAOC,qBAAqB;AAErD,IAAI,CAACF,kBAAA,EAAoB;EACvBA,kBAAA,GAAqBC,MAAA,CAAOC,qBAAqB,GAAG;AACtD;AAEA,OAAO,MAAMC,eAAA,GAAmBC,IAAA;EAK9B,MAAM;IAAEC,MAAM;IAAEC,IAAI;IAAEC;EAAS,CAAE,GAAGH,IAAA;EAEpC,IAAIJ,kBAAA,IAAsBQ,OAAA,CAAQC,GAAG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AO,MAAM5C,OAAA,CAAQwB,IAAI,CAAC;MACxBT,UAAA,EAAYV,cAAA;MACZoB,KAAA,EAAO;MACPC,KAAA,EAAOhB,KAAA,EAAOgB,KAAA,GAAQsB,QAAA,CAAStC,KAAA,CAAMgB,KAAK,EAAE,MAAMuB,SAAA;MAClDC,IAAA,EAAMxC,KAAA,EAAOwC,IAAA,GAAOF,QAAA,CAAStC,KAAA,CAAMwC,IAAI,EAAE,MAAMD,SAAA;MAC/CE,IAAA,EAAMzC,KAAA,EAAOyC,IAAA;MACbhB,KAAA,EAAOzB,KAAA,EAAOyB;IAChB;IAEA5B,IAAA,GAAOqC,IAAA,CAAKrC,IAAI;EAClB;EAEA,MAAM;IAAE6C,WAAW;IAAEC;EAAK,CAAE,GAAGtE,WAAA,CAAY;IACzC+C,gBAAA,EAAkBC,sBAAA;IAClBuB,iBAAA,EAAmBL,SAAA;IACnB3C,OAAA;IACAC,IAAA;IACAE,mBAAA;IACAsC,MAAA;IACAzD,IAAA,EAAMM,GAAA,CAAIN,IAAI;IACdU,OAAA;IACAW,cAAA;IACAE,eAAA;IACA0C,UAAA,EAAYzB,gBAAA,CAAiBb,KAAK,CAACsC;EACrC;EAEA,MAAMC,eAAA,GAAkB1E,aAAA,CAAciE,MAAA,EAAQnD,GAAA,CAAII,OAAO,CAACT,SAAS;EAEnE,OAAO;IACLqD,IAAA;IACAa,WAAA,EAAaf,QAAA;IACbc,eAAA;IACAE,KAAA,EAAON,WAAA;IACPC;EACF;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"buildTableState.js","names":["dequal","formatErrors","getClientConfig","renderFilters","renderTable","buildTableStateHandler","args","req","res","buildTableState","err","payload","logger","error","msg","message","collectionSlug","columns","docs","docsFromArgs","enableRowSelections","query","renderRowTypes","i18n","config","user","tableAppearance","incomingUserSlug","collection","adminUserSlug","admin","adminAccessFunction","collections","access","canAccessAdmin","Error","hasUsers","find","depth","limit","pagination","length","clientConfig","importMap","collectionConfig","clientCollectionConfig","slug","preferencesKey","preferencesResult","where","and","key","equals","id","then","value","newPrefs","preferencesArgs","data","update","create","fields","parseInt","undefined","page","sort","columnState","Table","columnPreferences","useAsTitle","renderedFilters","preferences","state"],"sources":["../../src/utilities/buildTableState.ts"],"sourcesContent":["import type {\n BuildTableStateArgs,\n ClientCollectionConfig,\n ClientConfig,\n ErrorResult,\n PaginatedDocs,\n SanitizedCollectionConfig,\n} from 'payload'\n\nimport { dequal } from 'dequal/lite'\nimport { formatErrors } from 'payload'\n\nimport type { Column } from '../elements/Table/index.js'\nimport type { ListPreferences } from '../elements/TableColumns/index.js'\n\nimport { getClientConfig } from './getClientConfig.js'\nimport { renderFilters, renderTable } from './renderTable.js'\n\ntype BuildTableStateSuccessResult = {\n clientConfig?: ClientConfig\n data: PaginatedDocs\n errors?: never\n preferences: ListPreferences\n renderedFilters: Map<string, React.ReactNode>\n state: Column[]\n Table: React.ReactNode\n}\n\ntype BuildTableStateErrorResult = {\n data?: any\n renderedFilters?: never\n state?: never\n Table?: never\n} & (\n | {\n message: string\n }\n | ErrorResult\n)\n\nexport type BuildTableStateResult = BuildTableStateErrorResult | BuildTableStateSuccessResult\n\nexport const buildTableStateHandler = async (\n args: BuildTableStateArgs,\n): Promise<BuildTableStateResult> => {\n const { req } = args\n\n try {\n const res = await buildTableState(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 return null\n }\n\n return formatErrors(err)\n }\n}\n\nexport const buildTableState = async (\n args: BuildTableStateArgs,\n): Promise<BuildTableStateSuccessResult> => {\n const {\n collectionSlug,\n columns,\n docs: docsFromArgs,\n enableRowSelections,\n query,\n renderRowTypes,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n user,\n },\n tableAppearance,\n } = args\n\n const incomingUserSlug = user?.collection\n\n const adminUserSlug = config.admin.user\n\n // If we have a user slug, test it against the functions\n if (incomingUserSlug) {\n const adminAccessFunction = 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 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 clientConfig = getClientConfig({\n config,\n i18n,\n importMap: payload.importMap,\n })\n\n let collectionConfig: SanitizedCollectionConfig\n let clientCollectionConfig: ClientCollectionConfig\n\n if (req.payload.collections[collectionSlug]) {\n collectionConfig = req.payload.collections[collectionSlug].config\n clientCollectionConfig = clientConfig.collections.find(\n (collection) => collection.slug === collectionSlug,\n )\n }\n\n // get prefs, then set update them using the columns that we just received\n const preferencesKey = `${collectionSlug}-list`\n\n const preferencesResult = await payload\n .find({\n collection: 'payload-preferences',\n depth: 0,\n limit: 1,\n pagination: false,\n where: {\n and: [\n {\n key: {\n equals: preferencesKey,\n },\n },\n {\n 'user.relationTo': {\n equals: user.collection,\n },\n },\n {\n 'user.value': {\n equals: user.id,\n },\n },\n ],\n },\n })\n .then((res) => res.docs[0] ?? { id: null, value: {} })\n\n let newPrefs = preferencesResult.value\n\n if (!preferencesResult.id || !dequal(columns, preferencesResult?.columns)) {\n const preferencesArgs = {\n collection: 'payload-preferences',\n data: {\n key: preferencesKey,\n user: {\n collection: user.collection,\n value: user.id,\n },\n value: {\n ...(preferencesResult?.value || {}),\n columns,\n },\n },\n depth: 0,\n req,\n }\n\n if (preferencesResult.id) {\n newPrefs = await payload\n .update({\n ...preferencesArgs,\n id: preferencesResult.id,\n })\n ?.then((res) => res.value as ListPreferences)\n } else {\n newPrefs = await payload.create(preferencesArgs)?.then((res) => res.value as ListPreferences)\n }\n }\n\n const fields = collectionConfig.fields\n\n let docs = docsFromArgs\n let data: PaginatedDocs\n\n // lookup docs, if desired, i.e. within `join` field which initialize with `depth: 0`\n\n if (!docs || query) {\n data = await payload.find({\n collection: collectionSlug,\n depth: 0,\n limit: query?.limit ? parseInt(query.limit, 10) : undefined,\n page: query?.page ? parseInt(query.page, 10) : undefined,\n sort: query?.sort,\n where: query?.where,\n })\n\n docs = data.docs\n }\n\n const { columnState, Table } = renderTable({\n collectionConfig: clientCollectionConfig,\n columnPreferences: undefined, // TODO, might not be needed\n columns,\n docs,\n enableRowSelections,\n fields,\n i18n: req.i18n,\n payload,\n renderRowTypes,\n tableAppearance,\n useAsTitle: collectionConfig.admin.useAsTitle,\n })\n\n const renderedFilters = renderFilters(fields, req.payload.importMap)\n\n return {\n data,\n preferences: newPrefs,\n renderedFilters,\n state: columnState,\n Table,\n }\n}\n"],"mappings":"AASA,SAASA,MAAM,QAAQ;AACvB,SAASC,YAAY,QAAQ;AAK7B,SAASC,eAAe,QAAQ;AAChC,SAASC,aAAa,EAAEC,WAAW,QAAQ;AA0B3C,OAAO,MAAMC,sBAAA,GAAyB,MACpCC,IAAA;EAEA,MAAM;IAAEC;EAAG,CAAE,GAAGD,IAAA;EAEhB,IAAI;IACF,MAAME,GAAA,GAAM,MAAMC,eAAA,CAAgBH,IAAA;IAClC,OAAOE,GAAA;EACT,EAAE,OAAOE,GAAA,EAAK;IACZH,GAAA,CAAII,OAAO,CAACC,MAAM,CAACC,KAAK,CAAC;MAAEH,GAAA;MAAKI,GAAA,EAAK;IAAyC;IAE9E,IAAIJ,GAAA,CAAIK,OAAO,KAAK,8CAA8C;MAChE,OAAO;QACLA,OAAA,EAASL,GAAA,CAAIK;MACf;IACF;IAEA,IAAIL,GAAA,CAAIK,OAAO,KAAK,gBAAgB;MAClC,OAAO;IACT;IAEA,OAAOd,YAAA,CAAaS,GAAA;EACtB;AACF;AAEA,OAAO,MAAMD,eAAA,GAAkB,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EAAYzB,gBAAA,CAAiBd,KAAK,CAACuC;EACrC;EAEA,MAAMC,eAAA,GAAkBnE,aAAA,CAAc0D,MAAA,EAAQtD,GAAA,CAAII,OAAO,CAACgC,SAAS;EAEnE,OAAO;IACLe,IAAA;IACAa,WAAA,EAAaf,QAAA;IACbc,eAAA;IACAE,KAAA,EAAON,WAAA;IACPC;EACF;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { I18nClient } from '@payloadcms/translations';
|
|
2
|
+
import type { ClientConfig, ImportMap, SanitizedConfig } from 'payload';
|
|
3
|
+
export declare const getClientConfig: (args: {
|
|
4
|
+
config: SanitizedConfig;
|
|
5
|
+
i18n: I18nClient;
|
|
6
|
+
importMap: ImportMap;
|
|
7
|
+
}) => ClientConfig;
|
|
8
|
+
//# sourceMappingURL=getClientConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getClientConfig.d.ts","sourceRoot":"","sources":["../../src/utilities/getClientConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAWvE,eAAO,MAAM,eAAe,SACnB;IAAE,MAAM,EAAE,eAAe,CAAC;IAAC,IAAI,EAAE,UAAU,CAAC;IAAC,SAAS,EAAE,SAAS,CAAA;CAAE,KAAG,YAiB9E,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createClientConfig } from 'payload';
|
|
2
|
+
import { cache } from 'react';
|
|
3
|
+
let cachedClientConfig = global._payload_clientConfig;
|
|
4
|
+
if (!cachedClientConfig) {
|
|
5
|
+
cachedClientConfig = global._payload_clientConfig = null;
|
|
6
|
+
}
|
|
7
|
+
export const getClientConfig = cache(args => {
|
|
8
|
+
if (cachedClientConfig && !global._payload_doNotCacheClientConfig) {
|
|
9
|
+
return cachedClientConfig;
|
|
10
|
+
}
|
|
11
|
+
const {
|
|
12
|
+
config,
|
|
13
|
+
i18n,
|
|
14
|
+
importMap
|
|
15
|
+
} = args;
|
|
16
|
+
cachedClientConfig = createClientConfig({
|
|
17
|
+
config,
|
|
18
|
+
i18n,
|
|
19
|
+
importMap
|
|
20
|
+
});
|
|
21
|
+
global._payload_clientConfig = cachedClientConfig;
|
|
22
|
+
global._payload_doNotCacheClientConfig = false;
|
|
23
|
+
return cachedClientConfig;
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=getClientConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getClientConfig.js","names":["createClientConfig","cache","cachedClientConfig","global","_payload_clientConfig","getClientConfig","args","_payload_doNotCacheClientConfig","config","i18n","importMap"],"sources":["../../src/utilities/getClientConfig.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type { ClientConfig, ImportMap, SanitizedConfig } from 'payload'\n\nimport { createClientConfig } from 'payload'\nimport { cache } from 'react'\n\nlet cachedClientConfig = global._payload_clientConfig\n\nif (!cachedClientConfig) {\n cachedClientConfig = global._payload_clientConfig = null\n}\n\nexport const getClientConfig = cache(\n (args: { config: SanitizedConfig; i18n: I18nClient; importMap: ImportMap }): ClientConfig => {\n if (cachedClientConfig && !global._payload_doNotCacheClientConfig) {\n return cachedClientConfig\n }\n const { config, i18n, importMap } = args\n\n cachedClientConfig = createClientConfig({\n config,\n i18n,\n importMap,\n })\n global._payload_clientConfig = cachedClientConfig\n\n global._payload_doNotCacheClientConfig = false\n\n return cachedClientConfig\n },\n)\n"],"mappings":"AAGA,SAASA,kBAAkB,QAAQ;AACnC,SAASC,KAAK,QAAQ;AAEtB,IAAIC,kBAAA,GAAqBC,MAAA,CAAOC,qBAAqB;AAErD,IAAI,CAACF,kBAAA,EAAoB;EACvBA,kBAAA,GAAqBC,MAAA,CAAOC,qBAAqB,GAAG;AACtD;AAEA,OAAO,MAAMC,eAAA,GAAkBJ,KAAA,CAC5BK,IAAA;EACC,IAAIJ,kBAAA,IAAsB,CAACC,MAAA,CAAOI,+BAA+B,EAAE;IACjE,OAAOL,kBAAA;EACT;EACA,MAAM;IAAEM,MAAM;IAAEC,IAAI;IAAEC;EAAS,CAAE,GAAGJ,IAAA;EAEpCJ,kBAAA,GAAqBF,kBAAA,CAAmB;IACtCQ,MAAA;IACAC,IAAA;IACAC;EACF;EACAP,MAAA,CAAOC,qBAAqB,GAAGF,kBAAA;EAE/BC,MAAA,CAAOI,+BAA+B,GAAG;EAEzC,OAAOL,kBAAA;AACT","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { I18nClient } from '@payloadcms/translations';
|
|
2
|
+
import type { ClientConfig, ClientFieldSchemaMap, FieldSchemaMap, Payload } from 'payload';
|
|
3
|
+
export declare const getClientSchemaMap: (args: {
|
|
4
|
+
collectionSlug?: string;
|
|
5
|
+
config: ClientConfig;
|
|
6
|
+
globalSlug?: string;
|
|
7
|
+
i18n: I18nClient;
|
|
8
|
+
payload: Payload;
|
|
9
|
+
schemaMap: FieldSchemaMap;
|
|
10
|
+
}) => ClientFieldSchemaMap;
|
|
11
|
+
//# sourceMappingURL=getClientSchemaMap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getClientSchemaMap.d.ts","sourceRoot":"","sources":["../../src/utilities/getClientSchemaMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAoB,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAY1F,eAAO,MAAM,kBAAkB,SACtB;IACL,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,YAAY,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,UAAU,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,SAAS,EAAE,cAAc,CAAA;CAC1B,KAAG,oBAgCL,CAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { cache } from 'react';
|
|
2
|
+
import { buildClientFieldSchemaMap } from './buildClientFieldSchemaMap/index.js';
|
|
3
|
+
let cachedClientSchemaMap = global._payload_clientSchemaMap;
|
|
4
|
+
if (!cachedClientSchemaMap) {
|
|
5
|
+
cachedClientSchemaMap = global._payload_clientSchemaMap = null;
|
|
6
|
+
}
|
|
7
|
+
export const getClientSchemaMap = cache(args => {
|
|
8
|
+
const {
|
|
9
|
+
collectionSlug,
|
|
10
|
+
config,
|
|
11
|
+
globalSlug,
|
|
12
|
+
i18n,
|
|
13
|
+
payload,
|
|
14
|
+
schemaMap
|
|
15
|
+
} = args;
|
|
16
|
+
if (!cachedClientSchemaMap || global._payload_doNotCacheClientSchemaMap) {
|
|
17
|
+
cachedClientSchemaMap = new Map();
|
|
18
|
+
}
|
|
19
|
+
let cachedEntityClientFieldMap = cachedClientSchemaMap.get(collectionSlug || globalSlug);
|
|
20
|
+
if (cachedEntityClientFieldMap) {
|
|
21
|
+
return cachedEntityClientFieldMap;
|
|
22
|
+
}
|
|
23
|
+
cachedEntityClientFieldMap = new Map();
|
|
24
|
+
const {
|
|
25
|
+
clientFieldSchemaMap: entityClientFieldMap
|
|
26
|
+
} = buildClientFieldSchemaMap({
|
|
27
|
+
collectionSlug,
|
|
28
|
+
config,
|
|
29
|
+
globalSlug,
|
|
30
|
+
i18n: i18n,
|
|
31
|
+
payload,
|
|
32
|
+
schemaMap
|
|
33
|
+
});
|
|
34
|
+
cachedClientSchemaMap.set(collectionSlug || globalSlug, entityClientFieldMap);
|
|
35
|
+
global._payload_clientSchemaMap = cachedClientSchemaMap;
|
|
36
|
+
global._payload_doNotCacheClientSchemaMap = false;
|
|
37
|
+
return entityClientFieldMap;
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=getClientSchemaMap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getClientSchemaMap.js","names":["cache","buildClientFieldSchemaMap","cachedClientSchemaMap","global","_payload_clientSchemaMap","getClientSchemaMap","args","collectionSlug","config","globalSlug","i18n","payload","schemaMap","_payload_doNotCacheClientSchemaMap","Map","cachedEntityClientFieldMap","get","clientFieldSchemaMap","entityClientFieldMap","set"],"sources":["../../src/utilities/getClientSchemaMap.ts"],"sourcesContent":["import type { I18n, I18nClient } from '@payloadcms/translations'\nimport type { ClientConfig, ClientFieldSchemaMap, FieldSchemaMap, Payload } from 'payload'\n\nimport { cache } from 'react'\n\nimport { buildClientFieldSchemaMap } from './buildClientFieldSchemaMap/index.js'\n\nlet cachedClientSchemaMap = global._payload_clientSchemaMap\n\nif (!cachedClientSchemaMap) {\n cachedClientSchemaMap = global._payload_clientSchemaMap = null\n}\n\nexport const getClientSchemaMap = cache(\n (args: {\n collectionSlug?: string\n config: ClientConfig\n globalSlug?: string\n i18n: I18nClient\n payload: Payload\n schemaMap: FieldSchemaMap\n }): ClientFieldSchemaMap => {\n const { collectionSlug, config, globalSlug, i18n, payload, schemaMap } = args\n\n if (!cachedClientSchemaMap || global._payload_doNotCacheClientSchemaMap) {\n cachedClientSchemaMap = new Map()\n }\n\n let cachedEntityClientFieldMap = cachedClientSchemaMap.get(collectionSlug || globalSlug)\n\n if (cachedEntityClientFieldMap) {\n return cachedEntityClientFieldMap\n }\n\n cachedEntityClientFieldMap = new Map()\n\n const { clientFieldSchemaMap: entityClientFieldMap } = buildClientFieldSchemaMap({\n collectionSlug,\n config,\n globalSlug,\n i18n: i18n as I18n,\n payload,\n schemaMap,\n })\n\n cachedClientSchemaMap.set(collectionSlug || globalSlug, entityClientFieldMap)\n\n global._payload_clientSchemaMap = cachedClientSchemaMap\n\n global._payload_doNotCacheClientSchemaMap = false\n\n return entityClientFieldMap\n },\n)\n"],"mappings":"AAGA,SAASA,KAAK,QAAQ;AAEtB,SAASC,yBAAyB,QAAQ;AAE1C,IAAIC,qBAAA,GAAwBC,MAAA,CAAOC,wBAAwB;AAE3D,IAAI,CAACF,qBAAA,EAAuB;EAC1BA,qBAAA,GAAwBC,MAAA,CAAOC,wBAAwB,GAAG;AAC5D;AAEA,OAAO,MAAMC,kBAAA,GAAqBL,KAAA,CAC/BM,IAAA;EAQC,MAAM;IAAEC,cAAc;IAAEC,MAAM;IAAEC,UAAU;IAAEC,IAAI;IAAEC,OAAO;IAAEC;EAAS,CAAE,GAAGN,IAAA;EAEzE,IAAI,CAACJ,qBAAA,IAAyBC,MAAA,CAAOU,kCAAkC,EAAE;IACvEX,qBAAA,GAAwB,IAAIY,GAAA;EAC9B;EAEA,IAAIC,0BAAA,GAA6Bb,qBAAA,CAAsBc,GAAG,CAACT,cAAA,IAAkBE,UAAA;EAE7E,IAAIM,0BAAA,EAA4B;IAC9B,OAAOA,0BAAA;EACT;EAEAA,0BAAA,GAA6B,IAAID,GAAA;EAEjC,MAAM;IAAEG,oBAAA,EAAsBC;EAAoB,CAAE,GAAGjB,yBAAA,CAA0B;IAC/EM,cAAA;IACAC,MAAA;IACAC,UAAA;IACAC,IAAA,EAAMA,IAAA;IACNC,OAAA;IACAC;EACF;EAEAV,qBAAA,CAAsBiB,GAAG,CAACZ,cAAA,IAAkBE,UAAA,EAAYS,oBAAA;EAExDf,MAAA,CAAOC,wBAAwB,GAAGF,qBAAA;EAElCC,MAAA,CAAOU,kCAAkC,GAAG;EAE5C,OAAOK,oBAAA;AACT","ignoreList":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { I18nClient } from '@payloadcms/translations';
|
|
2
|
+
import type { FieldSchemaMap, SanitizedConfig } from 'payload';
|
|
3
|
+
export declare const getSchemaMap: (args: {
|
|
4
|
+
collectionSlug?: string;
|
|
5
|
+
config: SanitizedConfig;
|
|
6
|
+
globalSlug?: string;
|
|
7
|
+
i18n: I18nClient;
|
|
8
|
+
}) => FieldSchemaMap;
|
|
9
|
+
//# sourceMappingURL=getSchemaMap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSchemaMap.d.ts","sourceRoot":"","sources":["../../src/utilities/getSchemaMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAY9D,eAAO,MAAM,YAAY,SAChB;IACL,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,eAAe,CAAA;IACvB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,UAAU,CAAA;CACjB,KAAG,cA8BL,CAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { cache } from 'react';
|
|
2
|
+
import { buildFieldSchemaMap } from './buildFieldSchemaMap/index.js';
|
|
3
|
+
let cachedSchemaMap = global._payload_schemaMap;
|
|
4
|
+
if (!cachedSchemaMap) {
|
|
5
|
+
cachedSchemaMap = global._payload_schemaMap = null;
|
|
6
|
+
}
|
|
7
|
+
export const getSchemaMap = cache(args => {
|
|
8
|
+
const {
|
|
9
|
+
collectionSlug,
|
|
10
|
+
config,
|
|
11
|
+
globalSlug,
|
|
12
|
+
i18n
|
|
13
|
+
} = args;
|
|
14
|
+
if (!cachedSchemaMap || global._payload_doNotCacheSchemaMap) {
|
|
15
|
+
cachedSchemaMap = new Map();
|
|
16
|
+
}
|
|
17
|
+
let cachedEntityFieldMap = cachedSchemaMap.get(collectionSlug || globalSlug);
|
|
18
|
+
if (cachedEntityFieldMap) {
|
|
19
|
+
return cachedEntityFieldMap;
|
|
20
|
+
}
|
|
21
|
+
cachedEntityFieldMap = new Map();
|
|
22
|
+
const {
|
|
23
|
+
fieldSchemaMap: entityFieldMap
|
|
24
|
+
} = buildFieldSchemaMap({
|
|
25
|
+
collectionSlug,
|
|
26
|
+
config,
|
|
27
|
+
globalSlug,
|
|
28
|
+
i18n: i18n
|
|
29
|
+
});
|
|
30
|
+
cachedSchemaMap.set(collectionSlug || globalSlug, entityFieldMap);
|
|
31
|
+
global._payload_schemaMap = cachedSchemaMap;
|
|
32
|
+
global._payload_doNotCacheSchemaMap = false;
|
|
33
|
+
return entityFieldMap;
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=getSchemaMap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSchemaMap.js","names":["cache","buildFieldSchemaMap","cachedSchemaMap","global","_payload_schemaMap","getSchemaMap","args","collectionSlug","config","globalSlug","i18n","_payload_doNotCacheSchemaMap","Map","cachedEntityFieldMap","get","fieldSchemaMap","entityFieldMap","set"],"sources":["../../src/utilities/getSchemaMap.ts"],"sourcesContent":["import type { I18n, I18nClient } from '@payloadcms/translations'\nimport type { FieldSchemaMap, SanitizedConfig } from 'payload'\n\nimport { cache } from 'react'\n\nimport { buildFieldSchemaMap } from './buildFieldSchemaMap/index.js'\n\nlet cachedSchemaMap = global._payload_schemaMap\n\nif (!cachedSchemaMap) {\n cachedSchemaMap = global._payload_schemaMap = null\n}\n\nexport const getSchemaMap = cache(\n (args: {\n collectionSlug?: string\n config: SanitizedConfig\n globalSlug?: string\n i18n: I18nClient\n }): FieldSchemaMap => {\n const { collectionSlug, config, globalSlug, i18n } = args\n\n if (!cachedSchemaMap || global._payload_doNotCacheSchemaMap) {\n cachedSchemaMap = new Map()\n }\n\n let cachedEntityFieldMap = cachedSchemaMap.get(collectionSlug || globalSlug)\n\n if (cachedEntityFieldMap) {\n return cachedEntityFieldMap\n }\n\n cachedEntityFieldMap = new Map()\n\n const { fieldSchemaMap: entityFieldMap } = buildFieldSchemaMap({\n collectionSlug,\n config,\n globalSlug,\n i18n: i18n as I18n,\n })\n\n cachedSchemaMap.set(collectionSlug || globalSlug, entityFieldMap)\n\n global._payload_schemaMap = cachedSchemaMap\n\n global._payload_doNotCacheSchemaMap = false\n\n return entityFieldMap\n },\n)\n"],"mappings":"AAGA,SAASA,KAAK,QAAQ;AAEtB,SAASC,mBAAmB,QAAQ;AAEpC,IAAIC,eAAA,GAAkBC,MAAA,CAAOC,kBAAkB;AAE/C,IAAI,CAACF,eAAA,EAAiB;EACpBA,eAAA,GAAkBC,MAAA,CAAOC,kBAAkB,GAAG;AAChD;AAEA,OAAO,MAAMC,YAAA,GAAeL,KAAA,CACzBM,IAAA;EAMC,MAAM;IAAEC,cAAc;IAAEC,MAAM;IAAEC,UAAU;IAAEC;EAAI,CAAE,GAAGJ,IAAA;EAErD,IAAI,CAACJ,eAAA,IAAmBC,MAAA,CAAOQ,4BAA4B,EAAE;IAC3DT,eAAA,GAAkB,IAAIU,GAAA;EACxB;EAEA,IAAIC,oBAAA,GAAuBX,eAAA,CAAgBY,GAAG,CAACP,cAAA,IAAkBE,UAAA;EAEjE,IAAII,oBAAA,EAAsB;IACxB,OAAOA,oBAAA;EACT;EAEAA,oBAAA,GAAuB,IAAID,GAAA;EAE3B,MAAM;IAAEG,cAAA,EAAgBC;EAAc,CAAE,GAAGf,mBAAA,CAAoB;IAC7DM,cAAA;IACAC,MAAA;IACAC,UAAA;IACAC,IAAA,EAAMA;EACR;EAEAR,eAAA,CAAgBe,GAAG,CAACV,cAAA,IAAkBE,UAAA,EAAYO,cAAA;EAElDb,MAAA,CAAOC,kBAAkB,GAAGF,eAAA;EAE5BC,MAAA,CAAOQ,4BAA4B,GAAG;EAEtC,OAAOK,cAAA;AACT","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SanitizedCollectionConfig
|
|
1
|
+
import type { SanitizedCollectionConfig } from 'payload';
|
|
2
2
|
export type Props = {
|
|
3
3
|
className?: string;
|
|
4
4
|
collectionSlug: SanitizedCollectionConfig['slug'];
|
|
@@ -12,6 +12,6 @@ export type Props = {
|
|
|
12
12
|
setValidateBeforeSubmit: (validate: boolean) => void;
|
|
13
13
|
useAPIKey?: boolean;
|
|
14
14
|
username: string;
|
|
15
|
-
verify?: boolean
|
|
15
|
+
verify?: boolean;
|
|
16
16
|
};
|
|
17
17
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/views/Edit/Auth/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/views/Edit/Auth/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAExD,MAAM,MAAM,KAAK,GAAG;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,cAAc,EAAE,yBAAyB,CAAC,MAAM,CAAC,CAAA;IACjD,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,KAAK,EAAE,MAAM,CAAA;IACb,iBAAiB,EAAE,yBAAyB,CAAC,MAAM,CAAC,CAAC,mBAAmB,CAAC,CAAA;IACzE,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC9B,QAAQ,EAAE,OAAO,CAAA;IACjB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,qBAAqB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,IAAI,CAAA;IAC/C,uBAAuB,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAA;IACpD,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../../src/views/Edit/Auth/types.ts"],"sourcesContent":["import type { SanitizedCollectionConfig
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../src/views/Edit/Auth/types.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from 'payload'\n\nexport type Props = {\n className?: string\n collectionSlug: SanitizedCollectionConfig['slug']\n disableLocalStrategy?: boolean\n email: string\n loginWithUsername: SanitizedCollectionConfig['auth']['loginWithUsername']\n operation: 'create' | 'update'\n readOnly: boolean\n requirePassword?: boolean\n setSchemaPathSegments: (path: string[]) => void\n setValidateBeforeSubmit: (validate: boolean) => void\n useAPIKey?: boolean\n username: string\n verify?: boolean\n}\n"],"mappings":"AAEA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/ui",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.2-canary.eb1a61e",
|
|
4
4
|
"homepage": "https://payloadcms.com",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -124,7 +124,6 @@
|
|
|
124
124
|
"md5": "2.3.0",
|
|
125
125
|
"object-to-formdata": "4.5.1",
|
|
126
126
|
"qs-esm": "7.0.2",
|
|
127
|
-
"react-animate-height": "2.1.2",
|
|
128
127
|
"react-datepicker": "6.9.0",
|
|
129
128
|
"react-image-crop": "10.1.8",
|
|
130
129
|
"react-select": "5.8.0",
|
|
@@ -133,7 +132,7 @@
|
|
|
133
132
|
"ts-essentials": "10.0.3",
|
|
134
133
|
"use-context-selector": "2.0.0",
|
|
135
134
|
"uuid": "10.0.0",
|
|
136
|
-
"@payloadcms/translations": "3.1.
|
|
135
|
+
"@payloadcms/translations": "3.1.2-canary.eb1a61e"
|
|
137
136
|
},
|
|
138
137
|
"devDependencies": {
|
|
139
138
|
"@babel/cli": "^7.24.5",
|
|
@@ -151,14 +150,14 @@
|
|
|
151
150
|
"esbuild": "0.23.1",
|
|
152
151
|
"esbuild-sass-plugin": "3.3.1",
|
|
153
152
|
"eslint-plugin-react-compiler": "19.0.0-beta-a7bf2bd-20241110",
|
|
154
|
-
"
|
|
155
|
-
"
|
|
153
|
+
"payload": "3.1.2-canary.eb1a61e",
|
|
154
|
+
"@payloadcms/eslint-config": "3.0.0"
|
|
156
155
|
},
|
|
157
156
|
"peerDependencies": {
|
|
158
157
|
"next": "^15.0.0",
|
|
159
158
|
"react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
160
159
|
"react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
161
|
-
"payload": "3.1.
|
|
160
|
+
"payload": "3.1.2-canary.eb1a61e"
|
|
162
161
|
},
|
|
163
162
|
"engines": {
|
|
164
163
|
"node": "^18.20.2 || >=20.9.0"
|