@payloadcms/ui 3.0.0-beta.129 → 3.0.0-beta.130
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/EmailAndUsername/index.d.ts.map +1 -1
- package/dist/elements/EmailAndUsername/index.js +3 -8
- package/dist/elements/EmailAndUsername/index.js.map +1 -1
- package/dist/elements/Nav/NavToggler/index.d.ts.map +1 -1
- package/dist/elements/Nav/NavToggler/index.js +1 -1
- package/dist/elements/Nav/NavToggler/index.js.map +1 -1
- package/dist/elements/NavGroup/index.d.ts +1 -0
- package/dist/elements/NavGroup/index.d.ts.map +1 -1
- package/dist/elements/NavGroup/index.js +69 -90
- package/dist/elements/NavGroup/index.js.map +1 -1
- package/dist/exports/client/index.d.ts +1 -2
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +22 -22
- package/dist/exports/client/index.js.map +4 -4
- package/dist/exports/shared/index.d.ts +1 -1
- package/dist/exports/shared/index.d.ts.map +1 -1
- package/dist/exports/shared/index.js +2 -2
- package/dist/exports/shared/index.js.map +2 -2
- package/dist/fields/Array/index.d.ts +1 -2
- package/dist/fields/Array/index.d.ts.map +1 -1
- package/dist/fields/Array/index.js +1 -2
- package/dist/fields/Array/index.js.map +1 -1
- package/dist/fields/Blocks/index.d.ts +1 -2
- package/dist/fields/Blocks/index.d.ts.map +1 -1
- package/dist/fields/Blocks/index.js +1 -2
- package/dist/fields/Blocks/index.js.map +1 -1
- package/dist/fields/Checkbox/index.d.ts +1 -1
- package/dist/fields/Checkbox/index.d.ts.map +1 -1
- package/dist/fields/Checkbox/index.js +1 -3
- package/dist/fields/Checkbox/index.js.map +1 -1
- package/dist/fields/Code/index.d.ts +1 -1
- package/dist/fields/Code/index.d.ts.map +1 -1
- package/dist/fields/Code/index.js +1 -3
- package/dist/fields/Code/index.js.map +1 -1
- package/dist/fields/Collapsible/index.d.ts +1 -3
- package/dist/fields/Collapsible/index.d.ts.map +1 -1
- package/dist/fields/Collapsible/index.js +65 -69
- package/dist/fields/Collapsible/index.js.map +1 -1
- package/dist/fields/DateTime/index.d.ts +1 -1
- package/dist/fields/DateTime/index.d.ts.map +1 -1
- package/dist/fields/DateTime/index.js +1 -3
- package/dist/fields/DateTime/index.js.map +1 -1
- package/dist/fields/Email/index.d.ts +1 -1
- package/dist/fields/Email/index.d.ts.map +1 -1
- package/dist/fields/Email/index.js +1 -3
- package/dist/fields/Email/index.js.map +1 -1
- package/dist/fields/Group/index.d.ts +1 -3
- package/dist/fields/Group/index.d.ts.map +1 -1
- package/dist/fields/Group/index.js +1 -2
- package/dist/fields/Group/index.js.map +1 -1
- package/dist/fields/JSON/index.d.ts +1 -1
- package/dist/fields/JSON/index.d.ts.map +1 -1
- package/dist/fields/JSON/index.js +1 -2
- package/dist/fields/JSON/index.js.map +1 -1
- package/dist/fields/Join/index.d.ts +3 -1
- package/dist/fields/Join/index.d.ts.map +1 -1
- package/dist/fields/Join/index.js +1 -2
- package/dist/fields/Join/index.js.map +1 -1
- package/dist/fields/Number/index.d.ts +1 -1
- package/dist/fields/Number/index.d.ts.map +1 -1
- package/dist/fields/Number/index.js +1 -3
- package/dist/fields/Number/index.js.map +1 -1
- package/dist/fields/Password/index.d.ts.map +1 -1
- package/dist/fields/Password/index.js +1 -3
- package/dist/fields/Password/index.js.map +1 -1
- package/dist/fields/Password/types.d.ts +1 -1
- package/dist/fields/Password/types.d.ts.map +1 -1
- package/dist/fields/Password/types.js.map +1 -1
- package/dist/fields/Point/index.d.ts +1 -1
- package/dist/fields/Point/index.d.ts.map +1 -1
- package/dist/fields/Point/index.js +1 -3
- package/dist/fields/Point/index.js.map +1 -1
- package/dist/fields/RadioGroup/index.d.ts +1 -1
- package/dist/fields/RadioGroup/index.d.ts.map +1 -1
- package/dist/fields/RadioGroup/index.js +1 -3
- package/dist/fields/RadioGroup/index.js.map +1 -1
- package/dist/fields/Relationship/index.d.ts +1 -1
- package/dist/fields/Relationship/index.d.ts.map +1 -1
- package/dist/fields/Relationship/index.js +1 -2
- package/dist/fields/Relationship/index.js.map +1 -1
- package/dist/fields/Row/index.d.ts +1 -1
- package/dist/fields/Select/index.d.ts +1 -1
- package/dist/fields/Select/index.d.ts.map +1 -1
- package/dist/fields/Select/index.js +1 -2
- package/dist/fields/Select/index.js.map +1 -1
- package/dist/fields/Tabs/index.d.ts +1 -1
- package/dist/fields/Text/index.d.ts +2 -2
- package/dist/fields/Text/index.d.ts.map +1 -1
- package/dist/fields/Text/index.js +2 -4
- package/dist/fields/Text/index.js.map +1 -1
- package/dist/fields/Textarea/index.d.ts +1 -1
- package/dist/fields/Textarea/index.d.ts.map +1 -1
- package/dist/fields/Textarea/index.js +1 -3
- package/dist/fields/Textarea/index.js.map +1 -1
- package/dist/fields/Upload/index.d.ts.map +1 -1
- package/dist/fields/Upload/index.js +1 -3
- package/dist/fields/Upload/index.js.map +1 -1
- package/dist/fields/index.d.ts +4 -1
- package/dist/fields/index.d.ts.map +1 -1
- package/dist/fields/index.js.map +1 -1
- package/dist/forms/NullifyField/index.d.ts.map +1 -1
- package/dist/forms/NullifyField/index.js +0 -3
- package/dist/forms/NullifyField/index.js.map +1 -1
- package/dist/forms/RenderFields/RenderField.d.ts +2 -2
- package/dist/forms/RenderFields/RenderField.d.ts.map +1 -1
- package/dist/forms/RenderFields/RenderField.js +189 -35
- package/dist/forms/RenderFields/RenderField.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/renderField.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/renderField.js +6 -3
- package/dist/forms/fieldSchemasToFormState/renderField.js.map +1 -1
- package/dist/forms/withCondition/index.d.ts +2 -2
- package/dist/forms/withCondition/index.d.ts.map +1 -1
- package/dist/forms/withCondition/index.js.map +1 -1
- package/dist/providers/Preferences/index.d.ts.map +1 -1
- package/dist/providers/Preferences/index.js +2 -4
- package/dist/providers/Preferences/index.js.map +1 -1
- package/dist/providers/Root/index.d.ts.map +1 -1
- package/dist/providers/Root/index.js +37 -42
- package/dist/providers/Root/index.js.map +1 -1
- package/dist/providers/ServerFunctions/index.js +12 -3
- package/dist/providers/ServerFunctions/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/utilities/groupNavItems.d.ts +2 -2
- package/dist/utilities/groupNavItems.d.ts.map +1 -1
- package/dist/utilities/groupNavItems.js.map +1 -1
- package/dist/views/Edit/Auth/index.d.ts.map +1 -1
- package/dist/views/Edit/Auth/index.js +0 -6
- package/dist/views/Edit/Auth/index.js.map +1 -1
- package/dist/views/List/types.d.ts +18 -1
- package/dist/views/List/types.d.ts.map +1 -1
- package/dist/views/List/types.js.map +1 -1
- package/package.json +4 -4
- package/dist/providers/FieldComponents/index.d.ts +0 -9
- package/dist/providers/FieldComponents/index.d.ts.map +0 -1
- package/dist/providers/FieldComponents/index.js +0 -18
- package/dist/providers/FieldComponents/index.js.map +0 -1
|
@@ -11,7 +11,7 @@ export type EntityToGroup = {
|
|
|
11
11
|
entity: SanitizedGlobalConfig;
|
|
12
12
|
type: EntityType.global;
|
|
13
13
|
};
|
|
14
|
-
export type
|
|
14
|
+
export type NavGroupType = {
|
|
15
15
|
entities: {
|
|
16
16
|
label: StaticLabel;
|
|
17
17
|
slug: string;
|
|
@@ -19,5 +19,5 @@ export type Group = {
|
|
|
19
19
|
}[];
|
|
20
20
|
label: string;
|
|
21
21
|
};
|
|
22
|
-
export declare function groupNavItems(entities: EntityToGroup[], permissions: Permissions, i18n: I18nClient):
|
|
22
|
+
export declare function groupNavItems(entities: EntityToGroup[], permissions: Permissions, i18n: I18nClient): NavGroupType[];
|
|
23
23
|
//# sourceMappingURL=groupNavItems.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"groupNavItems.d.ts","sourceRoot":"","sources":["../../src/utilities/groupNavItems.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EACV,WAAW,EACX,yBAAyB,EACzB,qBAAqB,EACrB,WAAW,EACZ,MAAM,SAAS,CAAA;AAIhB,oBAAY,UAAU;IACpB,UAAU,gBAAgB;IAC1B,MAAM,YAAY;CACnB;AAED,MAAM,MAAM,aAAa,GACrB;IACE,MAAM,EAAE,yBAAyB,CAAA;IACjC,IAAI,EAAE,UAAU,CAAC,UAAU,CAAA;CAC5B,GACD;IACE,MAAM,EAAE,qBAAqB,CAAA;IAC7B,IAAI,EAAE,UAAU,CAAC,MAAM,CAAA;CACxB,CAAA;AAEL,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"groupNavItems.d.ts","sourceRoot":"","sources":["../../src/utilities/groupNavItems.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EACV,WAAW,EACX,yBAAyB,EACzB,qBAAqB,EACrB,WAAW,EACZ,MAAM,SAAS,CAAA;AAIhB,oBAAY,UAAU;IACpB,UAAU,gBAAgB;IAC1B,MAAM,YAAY;CACnB;AAED,MAAM,MAAM,aAAa,GACrB;IACE,MAAM,EAAE,yBAAyB,CAAA;IACjC,IAAI,EAAE,UAAU,CAAC,UAAU,CAAA;CAC5B,GACD;IACE,MAAM,EAAE,qBAAqB,CAAA;IAC7B,IAAI,EAAE,UAAU,CAAC,MAAM,CAAA;CACxB,CAAA;AAEL,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE;QACR,KAAK,EAAE,WAAW,CAAA;QAClB,IAAI,EAAE,MAAM,CAAA;QACZ,IAAI,EAAE,UAAU,CAAA;KACjB,EAAE,CAAA;IACH,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,aAAa,EAAE,EACzB,WAAW,EAAE,WAAW,EACxB,IAAI,EAAE,UAAU,GACf,YAAY,EAAE,CA+DhB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"groupNavItems.js","names":["getTranslation","EntityType","groupNavItems","entities","permissions","i18n","result","reduce","groups","entityToGroup","type","toLowerCase","entity","slug","read","permission","translatedGroup","admin","group","existingGroup","find","label","matchedGroup","push","labels","plural","t","defaultGroup","filter","length"],"sources":["../../src/utilities/groupNavItems.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type {\n Permissions,\n SanitizedCollectionConfig,\n SanitizedGlobalConfig,\n StaticLabel,\n} from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\n\nexport enum EntityType {\n collection = 'collections',\n global = 'globals',\n}\n\nexport type EntityToGroup =\n | {\n entity: SanitizedCollectionConfig\n type: EntityType.collection\n }\n | {\n entity: SanitizedGlobalConfig\n type: EntityType.global\n }\n\nexport type
|
|
1
|
+
{"version":3,"file":"groupNavItems.js","names":["getTranslation","EntityType","groupNavItems","entities","permissions","i18n","result","reduce","groups","entityToGroup","type","toLowerCase","entity","slug","read","permission","translatedGroup","admin","group","existingGroup","find","label","matchedGroup","push","labels","plural","t","defaultGroup","filter","length"],"sources":["../../src/utilities/groupNavItems.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type {\n Permissions,\n SanitizedCollectionConfig,\n SanitizedGlobalConfig,\n StaticLabel,\n} from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\n\nexport enum EntityType {\n collection = 'collections',\n global = 'globals',\n}\n\nexport type EntityToGroup =\n | {\n entity: SanitizedCollectionConfig\n type: EntityType.collection\n }\n | {\n entity: SanitizedGlobalConfig\n type: EntityType.global\n }\n\nexport type NavGroupType = {\n entities: {\n label: StaticLabel\n slug: string\n type: EntityType\n }[]\n label: string\n}\n\nexport function groupNavItems(\n entities: EntityToGroup[],\n permissions: Permissions,\n i18n: I18nClient,\n): NavGroupType[] {\n const result = entities.reduce(\n (groups, entityToGroup) => {\n if (\n permissions?.[entityToGroup.type.toLowerCase()]?.[entityToGroup.entity.slug]?.read\n .permission\n ) {\n const translatedGroup = getTranslation(entityToGroup.entity.admin.group, i18n)\n\n if (entityToGroup.entity.admin.group) {\n const existingGroup = groups.find(\n (group) => getTranslation(group.label, i18n) === translatedGroup,\n ) as NavGroupType\n\n let matchedGroup: NavGroupType = existingGroup\n\n if (!existingGroup) {\n matchedGroup = { entities: [], label: translatedGroup }\n groups.push(matchedGroup)\n }\n\n matchedGroup.entities.push({\n slug: entityToGroup.entity.slug,\n type: entityToGroup.type,\n label:\n 'labels' in entityToGroup.entity\n ? typeof entityToGroup.entity.labels.plural === 'function'\n ? entityToGroup.entity.labels.plural({ t: i18n.t })\n : entityToGroup.entity.labels.plural\n : entityToGroup.entity.label,\n })\n } else {\n const defaultGroup = groups.find((group) => {\n return getTranslation(group.label, i18n) === i18n.t(`general:${entityToGroup.type}`)\n }) as NavGroupType\n defaultGroup.entities.push({\n slug: entityToGroup.entity.slug,\n type: entityToGroup.type,\n label:\n 'labels' in entityToGroup.entity\n ? typeof entityToGroup.entity.labels.plural === 'function'\n ? entityToGroup.entity.labels.plural({ t: i18n.t })\n : entityToGroup.entity.labels.plural\n : entityToGroup.entity.label,\n })\n }\n }\n\n return groups\n },\n [\n {\n entities: [],\n label: i18n.t('general:collections'),\n },\n {\n entities: [],\n label: i18n.t('general:globals'),\n },\n ],\n )\n\n return result.filter((group) => group.entities.length > 0)\n}\n"],"mappings":"AAQA,SAASA,cAAc,QAAQ;;WAEnBC,UAAA;;;GAAAA,UAAA,KAAAA,UAAA;AAwBZ,OAAO,SAASC,cACdC,QAAyB,EACzBC,WAAwB,EACxBC,IAAgB;EAEhB,MAAMC,MAAA,GAASH,QAAA,CAASI,MAAM,CAC5B,CAACC,MAAA,EAAQC,aAAA;IACP,IACEL,WAAA,GAAcK,aAAA,CAAcC,IAAI,CAACC,WAAW,GAAG,GAAGF,aAAA,CAAcG,MAAM,CAACC,IAAI,CAAC,EAAEC,IAAA,CAC3EC,UAAA,EACH;MACA,MAAMC,eAAA,GAAkBhB,cAAA,CAAeS,aAAA,CAAcG,MAAM,CAACK,KAAK,CAACC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GAC5B,OAAOH,aAAA,CAAcG,MAAM,CAACY,MAAM,CAACC,MAAM,KAAK,aAC5ChB,aAAA,CAAcG,MAAM,CAACY,MAAM,CAACC,MAAM,CAAC;YAAEC,CAAA,EAAGrB,IAAA,CAAKqB;UAAE,KAC/CjB,aAAA,CAAcG,MAAM,CAACY,MAAM,CAACC,MAAM,GACpChB,aAAA,CAAcG,MAAM,CAACS;QAC7B;MACF;IACF;IAEA,OAAOb,MAAA;EACT,GACA,CACE;IACEL,QAAA,EAAU,EAAE;IACZkB,KAAA,EAAOhB,IAAA,CAAKqB,CAAC,CAAC;EAChB,GACA;IACEvB,QAAA,EAAU,EAAE;IACZkB,KAAA,EAAOhB,IAAA,CAAKqB,CAAC,CAAC;EAChB,EACD;EAGH,OAAOpB,MAAA,CAAOsB,MAAM,CAAEV,KAAA,IAAUA,KAAA,CAAMf,QAAQ,CAAC0B,MAAM,GAAG;AAC1D","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/Edit/Auth/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAoD,MAAM,OAAO,CAAA;AAGxE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAavC,OAAO,cAAc,CAAA;AAIrB,eAAO,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/Edit/Auth/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAoD,MAAM,OAAO,CAAA;AAGxE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAavC,OAAO,cAAc,CAAA;AAIrB,eAAO,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAuNhC,CAAA"}
|
|
@@ -201,9 +201,6 @@ export const Auth = props => {
|
|
|
201
201
|
},
|
|
202
202
|
label: t("authentication:enableAPIKey")
|
|
203
203
|
},
|
|
204
|
-
indexPath: "",
|
|
205
|
-
parentPath: "",
|
|
206
|
-
parentSchemaPath: "",
|
|
207
204
|
path: "enableAPIKey",
|
|
208
205
|
schemaPath: `${collectionSlug}.enableAPIKey`
|
|
209
206
|
}), canReadApiKey && _jsx(APIKey, {
|
|
@@ -235,9 +232,6 @@ export const Auth = props => {
|
|
|
235
232
|
},
|
|
236
233
|
label: t("authentication:verified")
|
|
237
234
|
},
|
|
238
|
-
indexPath: "",
|
|
239
|
-
parentPath: "",
|
|
240
|
-
parentSchemaPath: "",
|
|
241
235
|
path: "_verified",
|
|
242
236
|
schemaPath: `${collectionSlug}._verified`
|
|
243
237
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","React","useCallback","useEffect","useMemo","useState","toast","Button","EmailAndUsernameFields","CheckboxField","ConfirmPasswordField","PasswordField","useFormFields","useFormModified","useAuth","useConfig","useDocumentInfo","useTranslation","APIKey","baseClass","Auth","props","$","className","collectionSlug","disableLocalStrategy","email","loginWithUsername","operation","readOnly","requirePassword","setSchemaPathSegments","setValidateBeforeSubmit","useAPIKey","username","verify","permissions","changingPassword","setChangingPassword","enableAPIKey","_temp","forceOpenChangePassword","_temp2","dispatchFields","_temp3","modified","i18n","t","docPermissions","isInitializing","config","t0","routes","t1","serverURL","api","t2","bb0","collection","collections","unlock","undefined","permission","hasPermissionToUnlock","apiKeyReadOnly","fields","apiKey","update","enableAPIKeyReadOnly","canReadApiKey","read","canReadEnableAPIKey","t3","showPasswordFields","type","errorMessage","path","valid","handleChangePassword","t4","language","url","response","fetch","body","JSON","stringify","credentials","headers","method","status","success","error","unlock_0","t5","t6","disabled","showPasswordFields_0","t7","filter","Boolean","t8","join","t9","t10","_jsxs","children","_jsx","field","name","admin","label","indexPath","parentPath","parentSchemaPath","schemaPath","enabled","value","t11","Fragment","autoComplete","required","buttonStyle","onClick","size","id","fields_0","password","reducer"],"sources":["../../../../src/views/Edit/Auth/index.tsx"],"sourcesContent":["'use client'\n\nimport React, { useCallback, useEffect, useMemo, useState } from 'react'\nimport { toast } from 'sonner'\n\nimport type { Props } from './types.js'\n\nimport { Button } from '../../../elements/Button/index.js'\nimport { EmailAndUsernameFields } from '../../../elements/EmailAndUsername/index.js'\nimport { CheckboxField } from '../../../fields/Checkbox/index.js'\nimport { ConfirmPasswordField } from '../../../fields/ConfirmPassword/index.js'\nimport { PasswordField } from '../../../fields/Password/index.js'\nimport { useFormFields, useFormModified } from '../../../forms/Form/context.js'\nimport { useAuth } from '../../../providers/Auth/index.js'\nimport { useConfig } from '../../../providers/Config/index.js'\nimport { useDocumentInfo } from '../../../providers/DocumentInfo/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { APIKey } from './APIKey.js'\nimport './index.scss'\n\nconst baseClass = 'auth-fields'\n\nexport const Auth: React.FC<Props> = (props) => {\n const {\n className,\n collectionSlug,\n disableLocalStrategy,\n email,\n loginWithUsername,\n operation,\n readOnly,\n requirePassword,\n setSchemaPathSegments,\n setValidateBeforeSubmit,\n useAPIKey,\n username,\n verify,\n } = props\n\n const { permissions } = useAuth()\n const [changingPassword, setChangingPassword] = useState(requirePassword)\n const enableAPIKey = useFormFields(([fields]) => (fields && fields?.enableAPIKey) || null)\n const forceOpenChangePassword = useFormFields(([fields]) => (fields && fields?.password) || null)\n const dispatchFields = useFormFields((reducer) => reducer[1])\n const modified = useFormModified()\n const { i18n, t } = useTranslation()\n const { docPermissions, isInitializing } = useDocumentInfo()\n\n const {\n config: {\n routes: { api },\n serverURL,\n },\n } = useConfig()\n\n const hasPermissionToUnlock: boolean = useMemo(() => {\n const collection = permissions?.collections?.[collectionSlug]\n\n if (collection) {\n const unlock = 'unlock' in collection ? collection.unlock : undefined\n\n if (unlock) {\n // current types for permissions do not include auth permissions, this will be fixed in another branch soon, for now we need to ignore the types\n // @todo: fix types\n // @ts-expect-error\n return unlock.permission\n }\n }\n\n return false\n }, [permissions, collectionSlug])\n\n const apiKeyReadOnly = readOnly || !docPermissions?.fields?.apiKey?.update?.permission\n const enableAPIKeyReadOnly = readOnly || !docPermissions?.fields?.enableAPIKey?.update?.permission\n\n const canReadApiKey = docPermissions?.fields?.apiKey?.read?.permission\n const canReadEnableAPIKey = docPermissions?.fields?.enableAPIKey?.read?.permission\n\n const handleChangePassword = useCallback(\n (showPasswordFields: boolean) => {\n if (showPasswordFields) {\n setValidateBeforeSubmit(true)\n setSchemaPathSegments([`_${collectionSlug}`, 'auth'])\n dispatchFields({\n type: 'UPDATE',\n errorMessage: t('validation:required'),\n path: 'password',\n valid: false,\n })\n dispatchFields({\n type: 'UPDATE',\n errorMessage: t('validation:required'),\n path: 'confirm-password',\n valid: false,\n })\n } else {\n setValidateBeforeSubmit(false)\n setSchemaPathSegments([collectionSlug])\n dispatchFields({ type: 'REMOVE', path: 'password' })\n dispatchFields({ type: 'REMOVE', path: 'confirm-password' })\n }\n\n setChangingPassword(showPasswordFields)\n },\n [dispatchFields, t, collectionSlug, setSchemaPathSegments, setValidateBeforeSubmit],\n )\n\n const unlock = useCallback(async () => {\n const url = `${serverURL}${api}/${collectionSlug}/unlock`\n const response = await fetch(url, {\n body:\n loginWithUsername && username ? JSON.stringify({ username }) : JSON.stringify({ email }),\n credentials: 'include',\n headers: {\n 'Accept-Language': i18n.language,\n 'Content-Type': 'application/json',\n },\n method: 'post',\n })\n\n if (response.status === 200) {\n toast.success(t('authentication:successfullyUnlocked'))\n } else {\n toast.error(t('authentication:failedToUnlock'))\n }\n }, [i18n, serverURL, api, collectionSlug, email, username, t, loginWithUsername])\n\n useEffect(() => {\n if (!modified) {\n setChangingPassword(false)\n }\n }, [modified])\n\n if (disableLocalStrategy && !useAPIKey) {\n return null\n }\n\n const disabled = readOnly || isInitializing\n\n const showPasswordFields = changingPassword || forceOpenChangePassword\n\n return (\n <div className={[baseClass, className].filter(Boolean).join(' ')}>\n {!disableLocalStrategy && (\n <React.Fragment>\n <EmailAndUsernameFields\n loginWithUsername={loginWithUsername}\n operation={operation}\n permissions={docPermissions?.fields}\n readOnly={readOnly}\n t={t}\n />\n {(showPasswordFields || requirePassword) && (\n <div className={`${baseClass}__changing-password`}>\n <PasswordField\n autoComplete=\"new-password\"\n field={{\n name: 'password',\n admin: {\n disabled,\n },\n label: t('authentication:newPassword'),\n required: true,\n }}\n indexPath=\"\"\n parentPath=\"\"\n parentSchemaPath=\"\"\n path=\"password\"\n schemaPath=\"password\"\n />\n <ConfirmPasswordField disabled={readOnly} />\n </div>\n )}\n <div className={`${baseClass}__controls`}>\n {showPasswordFields && !requirePassword && (\n <Button\n buttonStyle=\"secondary\"\n disabled={disabled}\n onClick={() => handleChangePassword(false)}\n size=\"medium\"\n >\n {t('general:cancel')}\n </Button>\n )}\n {!showPasswordFields && !requirePassword && (\n <Button\n buttonStyle=\"secondary\"\n disabled={disabled}\n id=\"change-password\"\n onClick={() => handleChangePassword(true)}\n size=\"medium\"\n >\n {t('authentication:changePassword')}\n </Button>\n )}\n {operation === 'update' && hasPermissionToUnlock && (\n <Button\n buttonStyle=\"secondary\"\n disabled={disabled}\n onClick={() => void unlock()}\n size=\"medium\"\n >\n {t('authentication:forceUnlock')}\n </Button>\n )}\n </div>\n </React.Fragment>\n )}\n {useAPIKey && (\n <div className={`${baseClass}__api-key`}>\n {canReadEnableAPIKey && (\n <CheckboxField\n field={{\n name: 'enableAPIKey',\n admin: { disabled, readOnly: enableAPIKeyReadOnly },\n label: t('authentication:enableAPIKey'),\n }}\n indexPath=\"\"\n parentPath=\"\"\n parentSchemaPath=\"\"\n path=\"enableAPIKey\"\n schemaPath={`${collectionSlug}.enableAPIKey`}\n />\n )}\n {canReadApiKey && <APIKey enabled={!!enableAPIKey?.value} readOnly={apiKeyReadOnly} />}\n </div>\n )}\n {verify && (\n <CheckboxField\n field={{\n name: '_verified',\n admin: { disabled, readOnly },\n label: t('authentication:verified'),\n }}\n indexPath=\"\"\n parentPath=\"\"\n parentSchemaPath=\"\"\n path=\"_verified\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AAnF,OAAAoF,OAAA;EAAA,OAqBeA,OAAO;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","React","useCallback","useEffect","useMemo","useState","toast","Button","EmailAndUsernameFields","CheckboxField","ConfirmPasswordField","PasswordField","useFormFields","useFormModified","useAuth","useConfig","useDocumentInfo","useTranslation","APIKey","baseClass","Auth","props","$","className","collectionSlug","disableLocalStrategy","email","loginWithUsername","operation","readOnly","requirePassword","setSchemaPathSegments","setValidateBeforeSubmit","useAPIKey","username","verify","permissions","changingPassword","setChangingPassword","enableAPIKey","_temp","forceOpenChangePassword","_temp2","dispatchFields","_temp3","modified","i18n","t","docPermissions","isInitializing","config","t0","routes","t1","serverURL","api","t2","bb0","collection","collections","unlock","undefined","permission","hasPermissionToUnlock","apiKeyReadOnly","fields","apiKey","update","enableAPIKeyReadOnly","canReadApiKey","read","canReadEnableAPIKey","t3","showPasswordFields","type","errorMessage","path","valid","handleChangePassword","t4","language","url","response","fetch","body","JSON","stringify","credentials","headers","method","status","success","error","unlock_0","t5","t6","disabled","showPasswordFields_0","t7","filter","Boolean","t8","join","t9","t10","_jsxs","children","_jsx","field","name","admin","label","schemaPath","enabled","value","t11","Fragment","autoComplete","required","indexPath","parentPath","parentSchemaPath","buttonStyle","onClick","size","id","fields_0","password","reducer"],"sources":["../../../../src/views/Edit/Auth/index.tsx"],"sourcesContent":["'use client'\n\nimport React, { useCallback, useEffect, useMemo, useState } from 'react'\nimport { toast } from 'sonner'\n\nimport type { Props } from './types.js'\n\nimport { Button } from '../../../elements/Button/index.js'\nimport { EmailAndUsernameFields } from '../../../elements/EmailAndUsername/index.js'\nimport { CheckboxField } from '../../../fields/Checkbox/index.js'\nimport { ConfirmPasswordField } from '../../../fields/ConfirmPassword/index.js'\nimport { PasswordField } from '../../../fields/Password/index.js'\nimport { useFormFields, useFormModified } from '../../../forms/Form/context.js'\nimport { useAuth } from '../../../providers/Auth/index.js'\nimport { useConfig } from '../../../providers/Config/index.js'\nimport { useDocumentInfo } from '../../../providers/DocumentInfo/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { APIKey } from './APIKey.js'\nimport './index.scss'\n\nconst baseClass = 'auth-fields'\n\nexport const Auth: React.FC<Props> = (props) => {\n const {\n className,\n collectionSlug,\n disableLocalStrategy,\n email,\n loginWithUsername,\n operation,\n readOnly,\n requirePassword,\n setSchemaPathSegments,\n setValidateBeforeSubmit,\n useAPIKey,\n username,\n verify,\n } = props\n\n const { permissions } = useAuth()\n const [changingPassword, setChangingPassword] = useState(requirePassword)\n const enableAPIKey = useFormFields(([fields]) => (fields && fields?.enableAPIKey) || null)\n const forceOpenChangePassword = useFormFields(([fields]) => (fields && fields?.password) || null)\n const dispatchFields = useFormFields((reducer) => reducer[1])\n const modified = useFormModified()\n const { i18n, t } = useTranslation()\n const { docPermissions, isInitializing } = useDocumentInfo()\n\n const {\n config: {\n routes: { api },\n serverURL,\n },\n } = useConfig()\n\n const hasPermissionToUnlock: boolean = useMemo(() => {\n const collection = permissions?.collections?.[collectionSlug]\n\n if (collection) {\n const unlock = 'unlock' in collection ? collection.unlock : undefined\n\n if (unlock) {\n // current types for permissions do not include auth permissions, this will be fixed in another branch soon, for now we need to ignore the types\n // @todo: fix types\n // @ts-expect-error\n return unlock.permission\n }\n }\n\n return false\n }, [permissions, collectionSlug])\n\n const apiKeyReadOnly = readOnly || !docPermissions?.fields?.apiKey?.update?.permission\n const enableAPIKeyReadOnly = readOnly || !docPermissions?.fields?.enableAPIKey?.update?.permission\n\n const canReadApiKey = docPermissions?.fields?.apiKey?.read?.permission\n const canReadEnableAPIKey = docPermissions?.fields?.enableAPIKey?.read?.permission\n\n const handleChangePassword = useCallback(\n (showPasswordFields: boolean) => {\n if (showPasswordFields) {\n setValidateBeforeSubmit(true)\n setSchemaPathSegments([`_${collectionSlug}`, 'auth'])\n dispatchFields({\n type: 'UPDATE',\n errorMessage: t('validation:required'),\n path: 'password',\n valid: false,\n })\n dispatchFields({\n type: 'UPDATE',\n errorMessage: t('validation:required'),\n path: 'confirm-password',\n valid: false,\n })\n } else {\n setValidateBeforeSubmit(false)\n setSchemaPathSegments([collectionSlug])\n dispatchFields({ type: 'REMOVE', path: 'password' })\n dispatchFields({ type: 'REMOVE', path: 'confirm-password' })\n }\n\n setChangingPassword(showPasswordFields)\n },\n [dispatchFields, t, collectionSlug, setSchemaPathSegments, setValidateBeforeSubmit],\n )\n\n const unlock = useCallback(async () => {\n const url = `${serverURL}${api}/${collectionSlug}/unlock`\n const response = await fetch(url, {\n body:\n loginWithUsername && username ? JSON.stringify({ username }) : JSON.stringify({ email }),\n credentials: 'include',\n headers: {\n 'Accept-Language': i18n.language,\n 'Content-Type': 'application/json',\n },\n method: 'post',\n })\n\n if (response.status === 200) {\n toast.success(t('authentication:successfullyUnlocked'))\n } else {\n toast.error(t('authentication:failedToUnlock'))\n }\n }, [i18n, serverURL, api, collectionSlug, email, username, t, loginWithUsername])\n\n useEffect(() => {\n if (!modified) {\n setChangingPassword(false)\n }\n }, [modified])\n\n if (disableLocalStrategy && !useAPIKey) {\n return null\n }\n\n const disabled = readOnly || isInitializing\n\n const showPasswordFields = changingPassword || forceOpenChangePassword\n\n return (\n <div className={[baseClass, className].filter(Boolean).join(' ')}>\n {!disableLocalStrategy && (\n <React.Fragment>\n <EmailAndUsernameFields\n loginWithUsername={loginWithUsername}\n operation={operation}\n permissions={docPermissions?.fields}\n readOnly={readOnly}\n t={t}\n />\n {(showPasswordFields || requirePassword) && (\n <div className={`${baseClass}__changing-password`}>\n <PasswordField\n autoComplete=\"new-password\"\n field={{\n name: 'password',\n admin: {\n disabled,\n },\n label: t('authentication:newPassword'),\n required: true,\n }}\n indexPath=\"\"\n parentPath=\"\"\n parentSchemaPath=\"\"\n path=\"password\"\n schemaPath=\"password\"\n />\n <ConfirmPasswordField disabled={readOnly} />\n </div>\n )}\n <div className={`${baseClass}__controls`}>\n {showPasswordFields && !requirePassword && (\n <Button\n buttonStyle=\"secondary\"\n disabled={disabled}\n onClick={() => handleChangePassword(false)}\n size=\"medium\"\n >\n {t('general:cancel')}\n </Button>\n )}\n {!showPasswordFields && !requirePassword && (\n <Button\n buttonStyle=\"secondary\"\n disabled={disabled}\n id=\"change-password\"\n onClick={() => handleChangePassword(true)}\n size=\"medium\"\n >\n {t('authentication:changePassword')}\n </Button>\n )}\n {operation === 'update' && hasPermissionToUnlock && (\n <Button\n buttonStyle=\"secondary\"\n disabled={disabled}\n onClick={() => void unlock()}\n size=\"medium\"\n >\n {t('authentication:forceUnlock')}\n </Button>\n )}\n </div>\n </React.Fragment>\n )}\n {useAPIKey && (\n <div className={`${baseClass}__api-key`}>\n {canReadEnableAPIKey && (\n <CheckboxField\n field={{\n name: 'enableAPIKey',\n admin: { disabled, readOnly: enableAPIKeyReadOnly },\n label: t('authentication:enableAPIKey'),\n }}\n path=\"enableAPIKey\"\n schemaPath={`${collectionSlug}.enableAPIKey`}\n />\n )}\n {canReadApiKey && <APIKey enabled={!!enableAPIKey?.value} readOnly={apiKeyReadOnly} />}\n </div>\n )}\n {verify && (\n <CheckboxField\n field={{\n name: '_verified',\n admin: { disabled, readOnly },\n label: t('authentication:verified'),\n }}\n path=\"_verified\"\n schemaPath={`${collectionSlug}._verified`}\n />\n )}\n </div>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAEA,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ;AACjE,SAASC,KAAK,QAAQ;AAItB,SAASC,MAAM,QAAQ;AACvB,SAASC,sBAAsB,QAAQ;AACvC,SAASC,aAAa,QAAQ;AAC9B,SAASC,oBAAoB,QAAQ;AACrC,SAASC,aAAa,QAAQ;AAC9B,SAASC,aAAa,EAAEC,eAAe,QAAQ;AAC/C,SAASC,OAAO,QAAQ;AACxB,SAASC,SAAS,QAAQ;AAC1B,SAASC,eAAe,QAAQ;AAChC,SAASC,cAAc,QAAQ;AAC/B,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KACY7C,oBAAA,KAAqB;YAAA8C,IAAA,EAC/B;YAAAlB,QAAA,EAEJ3D,CAAA,CAAE;UAAA,C,GAGNnB,SAAA,KAAc,YAAYmC,qBAAA,IACzB4C,IAAA,CAAApG,MAAA;YAAAmH,WAAA,EACc;YAAA1B,QAAA;YAAA2B,OAAA,EAAAA,CAAA,UAEQ/D,QAAA;YAAAgE,IAAA,EACf;YAAAlB,QAAA,EAEJ3D,CAAA,CAAE;UAAA,C;;UAMZyD,G,EAgBAW,G;;;;;;;;;;;;;;;;;;;;;;;;;;;SAlFHZ,E;CA+FJ;AAvNqC,SAAA/D,MAAAW,EAAA;EAmBC,OAAAc,MAAA,IAAAd,EAAQ;EAAA,OAAKc,MAAC,IAAUA,MAAA,EAAA1B,YAAQ,QAAiB;AAAA;AAnBlD,SAAAG,OAAAS,EAAA;EAoBY,OAAA2E,QAAA,IAAA3E,EAAQ;EAAA,OAAKc,QAAC,IAAUA,QAAA,EAAA8D,QAAQ,QAAa;AAAA;AApBzD,SAAAnF,OAAAoF,OAAA;EAAA,OAqBeA,OAAO;AAAA","ignoreList":[]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { I18n } from '@payloadcms/translations';
|
|
2
|
+
import type { AdminViewProps, Locale, Payload, Permissions, SanitizedCollectionConfig, User } from 'payload';
|
|
2
3
|
import type { ColumnPreferences } from '../../providers/ListQuery/index.js';
|
|
3
4
|
export type DefaultListViewProps = {
|
|
4
5
|
collectionSlug: SanitizedCollectionConfig['slug'];
|
|
@@ -12,4 +13,20 @@ export type ListPreferences = {
|
|
|
12
13
|
limit: number;
|
|
13
14
|
sort: string;
|
|
14
15
|
};
|
|
16
|
+
export type ListComponentClientProps = {
|
|
17
|
+
collectionSlug: SanitizedCollectionConfig['slug'];
|
|
18
|
+
hasCreatePermission: boolean;
|
|
19
|
+
newDocumentURL: string;
|
|
20
|
+
};
|
|
21
|
+
export type ListComponentServerProps = {
|
|
22
|
+
collectionConfig: SanitizedCollectionConfig;
|
|
23
|
+
i18n: I18n;
|
|
24
|
+
limit: number;
|
|
25
|
+
locale: Locale;
|
|
26
|
+
params: AdminViewProps['params'];
|
|
27
|
+
payload: Payload;
|
|
28
|
+
permissions: Permissions;
|
|
29
|
+
searchParams: AdminViewProps['searchParams'];
|
|
30
|
+
user: User;
|
|
31
|
+
};
|
|
15
32
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/views/List/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/views/List/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,KAAK,EACV,cAAc,EACd,MAAM,EACN,OAAO,EACP,WAAW,EACX,yBAAyB,EACzB,IAAI,EACL,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAA;AAE3E,MAAM,MAAM,oBAAoB,GAAG;IACjC,cAAc,EAAE,yBAAyB,CAAC,MAAM,CAAC,CAAA;IACjD,oBAAoB,EAAE,yBAAyB,CAAC,OAAO,CAAC,CAAC,sBAAsB,CAAC,CAAA;CACjF,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,UAAU,EAAE,yBAAyB,CAAA;CACtC,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,iBAAiB,CAAA;IAC1B,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,cAAc,EAAE,yBAAyB,CAAC,MAAM,CAAC,CAAA;IACjD,mBAAmB,EAAE,OAAO,CAAA;IAC5B,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,gBAAgB,EAAE,yBAAyB,CAAA;IAC3C,IAAI,EAAE,IAAI,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAA;IAChC,OAAO,EAAE,OAAO,CAAA;IAChB,WAAW,EAAE,WAAW,CAAA;IACxB,YAAY,EAAE,cAAc,CAAC,cAAc,CAAC,CAAA;IAC5C,IAAI,EAAE,IAAI,CAAA;CACX,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../src/views/List/types.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/views/List/types.ts"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type {\n AdminViewProps,\n Locale,\n Payload,\n Permissions,\n SanitizedCollectionConfig,\n User,\n} from 'payload'\n\nimport type { ColumnPreferences } from '../../providers/ListQuery/index.js'\n\nexport type DefaultListViewProps = {\n collectionSlug: SanitizedCollectionConfig['slug']\n listSearchableFields: SanitizedCollectionConfig['admin']['listSearchableFields']\n}\n\nexport type ListIndexProps = {\n collection: SanitizedCollectionConfig\n}\n\nexport type ListPreferences = {\n columns: ColumnPreferences\n limit: number\n sort: string\n}\n\nexport type ListComponentClientProps = {\n collectionSlug: SanitizedCollectionConfig['slug']\n hasCreatePermission: boolean\n newDocumentURL: string\n}\n\nexport type ListComponentServerProps = {\n collectionConfig: SanitizedCollectionConfig\n i18n: I18n\n limit: number\n locale: Locale\n params: AdminViewProps['params']\n payload: Payload\n permissions: Permissions\n searchParams: AdminViewProps['searchParams']\n user: User\n}\n"],"mappings":"AAiCA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/ui",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.130",
|
|
4
4
|
"homepage": "https://payloadcms.com",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
"ts-essentials": "10.0.3",
|
|
124
124
|
"use-context-selector": "2.0.0",
|
|
125
125
|
"uuid": "10.0.0",
|
|
126
|
-
"@payloadcms/translations": "3.0.0-beta.
|
|
126
|
+
"@payloadcms/translations": "3.0.0-beta.130"
|
|
127
127
|
},
|
|
128
128
|
"devDependencies": {
|
|
129
129
|
"@babel/cli": "^7.24.5",
|
|
@@ -142,13 +142,13 @@
|
|
|
142
142
|
"esbuild-sass-plugin": "3.3.1",
|
|
143
143
|
"eslint-plugin-react-compiler": "19.0.0-beta-a7bf2bd-20241110",
|
|
144
144
|
"@payloadcms/eslint-config": "3.0.0-beta.112",
|
|
145
|
-
"payload": "3.0.0-beta.
|
|
145
|
+
"payload": "3.0.0-beta.130"
|
|
146
146
|
},
|
|
147
147
|
"peerDependencies": {
|
|
148
148
|
"next": "^15.0.0",
|
|
149
149
|
"react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
150
150
|
"react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
151
|
-
"payload": "3.0.0-beta.
|
|
151
|
+
"payload": "3.0.0-beta.130"
|
|
152
152
|
},
|
|
153
153
|
"engines": {
|
|
154
154
|
"node": "^18.20.2 || >=20.9.0"
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { FieldTypesComponents } from '../../fields/index.js';
|
|
3
|
-
export type IFieldComponentsContext = FieldTypesComponents;
|
|
4
|
-
export declare const FieldComponentsProvider: React.FC<{
|
|
5
|
-
readonly children: React.ReactNode;
|
|
6
|
-
readonly fieldComponents: FieldTypesComponents;
|
|
7
|
-
}>;
|
|
8
|
-
export declare const useFieldComponents: () => IFieldComponentsContext;
|
|
9
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/FieldComponents/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAoC,MAAM,OAAO,CAAA;AAExD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAEjE,MAAM,MAAM,uBAAuB,GAAG,oBAAoB,CAAA;AAI1D,eAAO,MAAM,uBAAuB,EAAE,KAAK,CAAC,EAAE,CAAC;IAC7C,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IAClC,QAAQ,CAAC,eAAe,EAAE,oBAAoB,CAAA;CAC/C,CAMA,CAAA;AAED,eAAO,MAAM,kBAAkB,QAAO,uBAA6D,CAAA"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
-
import React, { createContext, useContext } from 'react';
|
|
5
|
-
const FieldComponentsContext = /*#__PURE__*/createContext(null);
|
|
6
|
-
export const FieldComponentsProvider = ({
|
|
7
|
-
children,
|
|
8
|
-
fieldComponents
|
|
9
|
-
}) => {
|
|
10
|
-
return /*#__PURE__*/_jsx(FieldComponentsContext.Provider, {
|
|
11
|
-
value: fieldComponents,
|
|
12
|
-
children: children
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
export const useFieldComponents = () => {
|
|
16
|
-
return useContext(FieldComponentsContext);
|
|
17
|
-
};
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","createContext","useContext","FieldComponentsContext","FieldComponentsProvider","children","fieldComponents","_jsx","Provider","value","useFieldComponents"],"sources":["../../../src/providers/FieldComponents/index.tsx"],"sourcesContent":["'use client'\n\nimport React, { createContext, useContext } from 'react'\n\nimport type { FieldTypesComponents } from '../../fields/index.js'\n\nexport type IFieldComponentsContext = FieldTypesComponents\n\nconst FieldComponentsContext = createContext<IFieldComponentsContext>(null)\n\nexport const FieldComponentsProvider: React.FC<{\n readonly children: React.ReactNode\n readonly fieldComponents: FieldTypesComponents\n}> = ({ children, fieldComponents }) => {\n return (\n <FieldComponentsContext.Provider value={fieldComponents}>\n {children}\n </FieldComponentsContext.Provider>\n )\n}\n\nexport const useFieldComponents = (): IFieldComponentsContext => useContext(FieldComponentsContext)\n"],"mappings":"AAAA;;;AAEA,OAAOA,KAAA,IAASC,aAAa,EAAEC,UAAU,QAAQ;AAMjD,MAAMC,sBAAA,gBAAyBF,aAAA,CAAuC;AAEtE,OAAO,MAAMG,uBAAA,GAGRA,CAAC;EAAEC,QAAQ;EAAEC;AAAe,CAAE;EACjC,oBACEC,IAAA,CAACJ,sBAAA,CAAuBK,QAAQ;IAACC,KAAA,EAAOH,eAAA;cACrCD;;AAGP;AAEA,OAAO,MAAMK,kBAAA,GAAqBA,CAAA;EAAA,OAA+BR,UAAA,CAAAC,sBAAW;AAAA","ignoreList":[]}
|