@payloadcms/ui 3.2.2 → 3.2.3-canary.3e78927
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/AddNewRelation/index.js +40 -40
- package/dist/elements/AddNewRelation/index.js.map +1 -1
- package/dist/elements/AddNewRelation/useRelatedCollections.js +3 -3
- package/dist/elements/AddNewRelation/useRelatedCollections.js.map +1 -1
- package/dist/elements/AnimateHeight/index.d.ts.map +1 -1
- package/dist/elements/AnimateHeight/index.js +4 -1
- package/dist/elements/AnimateHeight/index.js.map +1 -1
- package/dist/elements/AnimateHeight/usePatchAnimateHeight.d.ts +2 -1
- package/dist/elements/AnimateHeight/usePatchAnimateHeight.d.ts.map +1 -1
- package/dist/elements/AnimateHeight/usePatchAnimateHeight.js +67 -79
- package/dist/elements/AnimateHeight/usePatchAnimateHeight.js.map +1 -1
- package/dist/elements/ArrayAction/index.js +10 -10
- package/dist/elements/ArrayAction/index.js.map +1 -1
- package/dist/elements/BulkUpload/ActionsBar/index.js +13 -13
- package/dist/elements/BulkUpload/ActionsBar/index.js.map +1 -1
- package/dist/elements/BulkUpload/AddingFilesView/index.js +14 -14
- package/dist/elements/BulkUpload/AddingFilesView/index.js.map +1 -1
- package/dist/elements/BulkUpload/DiscardWithoutSaving/index.js +4 -4
- package/dist/elements/BulkUpload/DiscardWithoutSaving/index.js.map +1 -1
- package/dist/elements/BulkUpload/DrawerCloseButton/index.js +3 -3
- package/dist/elements/BulkUpload/DrawerCloseButton/index.js.map +1 -1
- package/dist/elements/BulkUpload/FileSidebar/index.js +29 -26
- package/dist/elements/BulkUpload/FileSidebar/index.js.map +1 -1
- package/dist/elements/BulkUpload/FormsManager/index.js +2 -0
- package/dist/elements/BulkUpload/FormsManager/index.js.map +1 -1
- package/dist/elements/BulkUpload/index.js +8 -8
- package/dist/elements/BulkUpload/index.js.map +1 -1
- package/dist/elements/CodeEditor/CodeEditor.js +28 -32
- package/dist/elements/CodeEditor/CodeEditor.js.map +1 -1
- package/dist/elements/Collapsible/index.js +13 -13
- package/dist/elements/Collapsible/index.js.map +1 -1
- package/dist/elements/ColumnSelector/index.js +10 -10
- package/dist/elements/ColumnSelector/index.js.map +1 -1
- package/dist/elements/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/elements/DatePicker/DatePicker.js +4 -4
- package/dist/elements/DatePicker/DatePicker.js.map +1 -1
- package/dist/elements/DeleteMany/index.d.ts.map +1 -1
- package/dist/elements/DeleteMany/index.js +10 -14
- package/dist/elements/DeleteMany/index.js.map +1 -1
- package/dist/elements/DocumentControls/index.js +9 -9
- package/dist/elements/DocumentControls/index.js.map +1 -1
- package/dist/elements/DocumentDrawer/DrawerHeader/index.js +4 -4
- package/dist/elements/DocumentDrawer/DrawerHeader/index.js.map +1 -1
- package/dist/elements/DocumentDrawer/index.js +47 -47
- package/dist/elements/DocumentDrawer/index.js.map +1 -1
- package/dist/elements/DocumentLocked/index.js +21 -21
- package/dist/elements/DocumentLocked/index.js.map +1 -1
- package/dist/elements/DocumentTakeOver/index.js +10 -10
- package/dist/elements/DocumentTakeOver/index.js.map +1 -1
- package/dist/elements/DraggableSortable/DraggableSortableItem/index.js +9 -9
- package/dist/elements/DraggableSortable/DraggableSortableItem/index.js.map +1 -1
- package/dist/elements/DraggableSortable/index.js +11 -11
- package/dist/elements/DraggableSortable/index.js.map +1 -1
- package/dist/elements/DraggableSortable/useDraggableSortable/index.js +8 -8
- package/dist/elements/DraggableSortable/useDraggableSortable/index.js.map +1 -1
- package/dist/elements/Drawer/index.js +38 -38
- package/dist/elements/Drawer/index.js.map +1 -1
- package/dist/elements/Drawer/useDrawerSlug.js +3 -3
- package/dist/elements/Drawer/useDrawerSlug.js.map +1 -1
- package/dist/elements/EditMany/index.d.ts.map +1 -1
- package/dist/elements/EditMany/index.js +32 -33
- package/dist/elements/EditMany/index.js.map +1 -1
- package/dist/elements/FieldSelect/index.js +17 -16
- package/dist/elements/FieldSelect/index.js.map +1 -1
- package/dist/elements/FileDetails/DraggableFileDetails/index.js +15 -15
- package/dist/elements/FileDetails/DraggableFileDetails/index.js.map +1 -1
- package/dist/elements/FileDetails/FileMeta/index.js +15 -15
- package/dist/elements/FileDetails/FileMeta/index.js.map +1 -1
- package/dist/elements/FullscreenModal/index.js +4 -4
- package/dist/elements/FullscreenModal/index.js.map +1 -1
- package/dist/elements/Hamburger/index.js +4 -4
- package/dist/elements/Hamburger/index.js.map +1 -1
- package/dist/elements/HydrateAuthProvider/index.js +3 -3
- package/dist/elements/HydrateAuthProvider/index.js.map +1 -1
- package/dist/elements/LeaveWithoutSaving/index.js +11 -11
- package/dist/elements/LeaveWithoutSaving/index.js.map +1 -1
- package/dist/elements/ListDrawer/index.js +19 -18
- package/dist/elements/ListDrawer/index.js.map +1 -1
- package/dist/elements/ListSelection/index.js +3 -3
- package/dist/elements/ListSelection/index.js.map +1 -1
- package/dist/elements/Loading/index.js +15 -15
- package/dist/elements/Loading/index.js.map +1 -1
- package/dist/elements/LoadingOverlay/index.js +18 -16
- package/dist/elements/LoadingOverlay/index.js.map +1 -1
- package/dist/elements/Localizer/LocalizerLabel/index.js +5 -5
- package/dist/elements/Localizer/LocalizerLabel/index.js.map +1 -1
- package/dist/elements/Localizer/index.d.ts.map +1 -1
- package/dist/elements/Localizer/index.js +20 -19
- package/dist/elements/Localizer/index.js.map +1 -1
- package/dist/elements/Locked/index.js +3 -3
- package/dist/elements/Locked/index.js.map +1 -1
- package/dist/elements/Logout/index.js +7 -7
- package/dist/elements/Logout/index.js.map +1 -1
- package/dist/elements/Nav/NavToggler/index.js +13 -13
- package/dist/elements/Nav/NavToggler/index.js.map +1 -1
- package/dist/elements/NavGroup/index.js +12 -12
- package/dist/elements/NavGroup/index.js.map +1 -1
- package/dist/elements/PerPage/index.js +7 -7
- package/dist/elements/PerPage/index.js.map +1 -1
- package/dist/elements/Pill/index.js +8 -8
- package/dist/elements/Pill/index.js.map +1 -1
- package/dist/elements/Popup/index.js +1 -0
- package/dist/elements/Popup/index.js.map +1 -1
- package/dist/elements/PreviewButton/index.js +3 -3
- package/dist/elements/PreviewButton/index.js.map +1 -1
- package/dist/elements/PublishButton/index.js +28 -28
- package/dist/elements/PublishButton/index.js.map +1 -1
- package/dist/elements/PublishMany/index.d.ts.map +1 -1
- package/dist/elements/PublishMany/index.js +10 -10
- package/dist/elements/PublishMany/index.js.map +1 -1
- package/dist/elements/ReactSelect/Input/index.d.ts +2 -2
- package/dist/elements/ReactSelect/Input/index.d.ts.map +1 -1
- package/dist/elements/ReactSelect/Input/index.js.map +1 -1
- package/dist/elements/ReactSelect/MultiValue/index.js +10 -10
- package/dist/elements/ReactSelect/MultiValue/index.js.map +1 -1
- package/dist/elements/ReactSelect/MultiValueRemove/index.js +5 -5
- package/dist/elements/ReactSelect/MultiValueRemove/index.js.map +1 -1
- package/dist/elements/ReactSelect/index.js.map +1 -1
- package/dist/elements/RelationshipTable/cells/DrawerLink/index.js +4 -4
- package/dist/elements/RelationshipTable/cells/DrawerLink/index.js.map +1 -1
- package/dist/elements/RelationshipTable/index.js +278 -142
- package/dist/elements/RelationshipTable/index.js.map +1 -1
- package/dist/elements/RenderIfInViewport/index.js +3 -3
- package/dist/elements/RenderIfInViewport/index.js.map +1 -1
- package/dist/elements/RenderTitle/index.js +6 -6
- package/dist/elements/RenderTitle/index.js.map +1 -1
- package/dist/elements/SelectAll/index.js +3 -3
- package/dist/elements/SelectAll/index.js.map +1 -1
- package/dist/elements/SelectRow/index.js +6 -6
- package/dist/elements/SelectRow/index.js.map +1 -1
- package/dist/elements/ShimmerEffect/index.js +7 -7
- package/dist/elements/ShimmerEffect/index.js.map +1 -1
- package/dist/elements/SortColumn/index.js +16 -16
- package/dist/elements/SortColumn/index.js.map +1 -1
- package/dist/elements/SortComplex/index.d.ts.map +1 -1
- package/dist/elements/SortComplex/index.js +38 -51
- package/dist/elements/SortComplex/index.js.map +1 -1
- package/dist/elements/Status/index.js +38 -35
- package/dist/elements/Status/index.js.map +1 -1
- package/dist/elements/StayLoggedIn/index.js +12 -12
- package/dist/elements/StayLoggedIn/index.js.map +1 -1
- package/dist/elements/StepNav/SetStepNav.js +3 -3
- package/dist/elements/StepNav/SetStepNav.js.map +1 -1
- package/dist/elements/StepNav/context.js +3 -3
- package/dist/elements/StepNav/context.js.map +1 -1
- package/dist/elements/StepNav/index.js +9 -9
- package/dist/elements/StepNav/index.js.map +1 -1
- package/dist/elements/Table/DefaultCell/fields/Date/index.js +3 -3
- package/dist/elements/Table/DefaultCell/fields/Date/index.js.map +1 -1
- package/dist/elements/Table/DefaultCell/fields/Relationship/index.js +31 -31
- package/dist/elements/Table/DefaultCell/fields/Relationship/index.js.map +1 -1
- package/dist/elements/Table/DefaultCell/fields/Select/index.js +3 -3
- package/dist/elements/Table/DefaultCell/fields/Select/index.js.map +1 -1
- package/dist/elements/Table/DefaultCell/index.js +15 -15
- package/dist/elements/Table/DefaultCell/index.js.map +1 -1
- package/dist/elements/Table/RelationshipProvider/index.js +12 -9
- package/dist/elements/Table/RelationshipProvider/index.js.map +1 -1
- package/dist/elements/TableColumns/RenderDefaultCell/index.js +6 -6
- package/dist/elements/TableColumns/RenderDefaultCell/index.js.map +1 -1
- package/dist/elements/Thumbnail/index.js +27 -27
- package/dist/elements/Thumbnail/index.js.map +1 -1
- package/dist/elements/ThumbnailCard/index.js +10 -10
- package/dist/elements/ThumbnailCard/index.js.map +1 -1
- package/dist/elements/Tooltip/index.js +29 -24
- package/dist/elements/Tooltip/index.js.map +1 -1
- package/dist/elements/UnpublishMany/index.d.ts.map +1 -1
- package/dist/elements/UnpublishMany/index.js +11 -11
- package/dist/elements/UnpublishMany/index.js.map +1 -1
- package/dist/elements/Upload/index.js +5 -5
- package/dist/elements/Upload/index.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/Number/index.js +3 -3
- package/dist/elements/WhereBuilder/Condition/Number/index.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/Select/index.js +13 -10
- package/dist/elements/WhereBuilder/Condition/Select/index.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/Text/index.js +5 -5
- package/dist/elements/WhereBuilder/Condition/Text/index.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/index.js +45 -45
- package/dist/elements/WhereBuilder/Condition/index.js.map +1 -1
- package/dist/elements/WhereBuilder/index.js +11 -11
- package/dist/elements/WhereBuilder/index.js.map +1 -1
- package/dist/exports/client/{DatePicker-QST7QHAX.js → CodeEditor-RZ32B2QF.js} +2 -2
- package/dist/exports/client/DatePicker-QW5V4BQV.js +14 -0
- package/dist/exports/client/DatePicker-QW5V4BQV.js.map +8 -0
- package/dist/exports/client/chunk-CKHKQPOO.js +26 -0
- package/dist/exports/client/{CodeEditor-5MCGR4GL.js.map → chunk-CKHKQPOO.js.map} +4 -4
- package/dist/exports/client/chunk-KZPVHMBR.js +29 -0
- package/dist/exports/client/chunk-KZPVHMBR.js.map +8 -0
- package/dist/exports/client/index.d.ts +8 -1
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +16 -16
- package/dist/exports/client/index.js.map +4 -4
- package/dist/fields/Array/ArrayRow.js +38 -38
- package/dist/fields/Array/ArrayRow.js.map +1 -1
- package/dist/fields/Array/index.d.ts.map +1 -1
- package/dist/fields/Array/index.js +27 -25
- package/dist/fields/Array/index.js.map +1 -1
- package/dist/fields/Blocks/BlockRow.js +51 -49
- package/dist/fields/Blocks/BlockRow.js.map +1 -1
- package/dist/fields/Blocks/BlocksDrawer/BlockSearch/index.js +3 -3
- package/dist/fields/Blocks/BlocksDrawer/BlockSearch/index.js.map +1 -1
- package/dist/fields/Blocks/BlocksDrawer/index.js +13 -13
- package/dist/fields/Blocks/BlocksDrawer/index.js.map +1 -1
- package/dist/fields/Blocks/RowActions.js +25 -25
- package/dist/fields/Blocks/RowActions.js.map +1 -1
- package/dist/fields/Blocks/SectionTitle/index.js +8 -8
- package/dist/fields/Blocks/SectionTitle/index.js.map +1 -1
- package/dist/fields/Blocks/index.d.ts.map +1 -1
- package/dist/fields/Blocks/index.js +26 -24
- package/dist/fields/Blocks/index.js.map +1 -1
- package/dist/fields/Collapsible/index.d.ts.map +1 -1
- package/dist/fields/Collapsible/index.js +4 -2
- package/dist/fields/Collapsible/index.js.map +1 -1
- package/dist/fields/ConfirmPassword/index.js +6 -6
- package/dist/fields/ConfirmPassword/index.js.map +1 -1
- package/dist/fields/FieldLabel/index.js +18 -18
- package/dist/fields/FieldLabel/index.js.map +1 -1
- package/dist/fields/Group/index.d.ts.map +1 -1
- package/dist/fields/Group/index.js +6 -4
- package/dist/fields/Group/index.js.map +1 -1
- package/dist/fields/Hidden/index.js +7 -7
- package/dist/fields/Hidden/index.js.map +1 -1
- package/dist/fields/Number/index.js +5 -5
- package/dist/fields/Number/index.js.map +1 -1
- package/dist/fields/Password/input.js +24 -24
- package/dist/fields/Password/input.js.map +1 -1
- package/dist/fields/RadioGroup/Radio/index.js +9 -9
- package/dist/fields/RadioGroup/Radio/index.js.map +1 -1
- package/dist/fields/RadioGroup/index.d.ts.map +1 -1
- package/dist/fields/RadioGroup/index.js +4 -2
- package/dist/fields/RadioGroup/index.js.map +1 -1
- package/dist/fields/Relationship/index.d.ts.map +1 -1
- package/dist/fields/Relationship/index.js +4 -2
- package/dist/fields/Relationship/index.js.map +1 -1
- package/dist/fields/Relationship/select-components/MultiValueLabel/index.js +18 -18
- package/dist/fields/Relationship/select-components/MultiValueLabel/index.js.map +1 -1
- package/dist/fields/Relationship/select-components/SingleValue/index.js +18 -18
- package/dist/fields/Relationship/select-components/SingleValue/index.js.map +1 -1
- package/dist/fields/Select/Input.js +28 -28
- package/dist/fields/Select/Input.js.map +1 -1
- package/dist/fields/Tabs/Tab/index.js +10 -10
- package/dist/fields/Tabs/Tab/index.js.map +1 -1
- package/dist/fields/Tabs/index.d.ts +15 -0
- package/dist/fields/Tabs/index.d.ts.map +1 -1
- package/dist/fields/Tabs/index.js +71 -71
- package/dist/fields/Tabs/index.js.map +1 -1
- package/dist/fields/Text/Input.js +24 -24
- package/dist/fields/Text/Input.js.map +1 -1
- package/dist/fields/Textarea/Input.js +19 -19
- package/dist/fields/Textarea/Input.js.map +1 -1
- package/dist/fields/Upload/HasMany/index.js +11 -11
- package/dist/fields/Upload/HasMany/index.js.map +1 -1
- package/dist/fields/Upload/Input.js +109 -104
- package/dist/fields/Upload/Input.js.map +1 -1
- package/dist/fields/Upload/RelationshipContent/index.js +20 -20
- package/dist/fields/Upload/RelationshipContent/index.js.map +1 -1
- package/dist/forms/NullifyField/index.js +3 -3
- package/dist/forms/NullifyField/index.js.map +1 -1
- package/dist/forms/RenderFields/RenderField.js +9 -9
- package/dist/forms/RenderFields/RenderField.js.map +1 -1
- package/dist/forms/RenderFields/index.js +16 -16
- package/dist/forms/RenderFields/index.js.map +1 -1
- package/dist/forms/WatchChildErrors/index.js +10 -10
- package/dist/forms/WatchChildErrors/index.js.map +1 -1
- package/dist/forms/useField/index.js +44 -44
- package/dist/forms/useField/index.js.map +1 -1
- package/dist/hooks/useDebounce.js +3 -3
- package/dist/hooks/useDebounce.js.map +1 -1
- package/dist/hooks/useDebouncedEffect.js +6 -6
- package/dist/hooks/useDebouncedEffect.js.map +1 -1
- package/dist/hooks/useDelay.js +3 -3
- package/dist/hooks/useDelay.js.map +1 -1
- package/dist/hooks/useHotkey.js +18 -14
- package/dist/hooks/useHotkey.js.map +1 -1
- package/dist/hooks/usePayloadAPI.js +13 -13
- package/dist/hooks/usePayloadAPI.js.map +1 -1
- package/dist/hooks/useThrottledEffect.js +3 -3
- package/dist/hooks/useThrottledEffect.js.map +1 -1
- package/dist/providers/Actions/index.js +4 -4
- package/dist/providers/Actions/index.js.map +1 -1
- package/dist/providers/ClientFunction/index.js +3 -3
- package/dist/providers/ClientFunction/index.js.map +1 -1
- package/dist/providers/Config/index.js +9 -10
- package/dist/providers/Config/index.js.map +1 -1
- package/dist/providers/DocumentEvents/index.js +3 -3
- package/dist/providers/DocumentEvents/index.js.map +1 -1
- package/dist/providers/EditDepth/index.js +3 -3
- package/dist/providers/EditDepth/index.js.map +1 -1
- package/dist/providers/EntityVisibility/index.js +9 -10
- package/dist/providers/EntityVisibility/index.js.map +1 -1
- package/dist/providers/ListQuery/index.js +2 -2
- package/dist/providers/ListQuery/index.js.map +1 -1
- package/dist/providers/Locale/index.d.ts.map +1 -1
- package/dist/providers/Locale/index.js +65 -59
- package/dist/providers/Locale/index.js.map +1 -1
- package/dist/providers/Params/index.d.ts +16 -0
- package/dist/providers/Params/index.d.ts.map +1 -1
- package/dist/providers/Params/index.js +19 -4
- package/dist/providers/Params/index.js.map +1 -1
- package/dist/providers/RouteCache/index.js +6 -6
- package/dist/providers/RouteCache/index.js.map +1 -1
- package/dist/providers/SearchParams/index.d.ts +22 -4
- package/dist/providers/SearchParams/index.d.ts.map +1 -1
- package/dist/providers/SearchParams/index.js +28 -14
- package/dist/providers/SearchParams/index.js.map +1 -1
- package/dist/providers/Selection/index.d.ts.map +1 -1
- package/dist/providers/Selection/index.js +7 -8
- package/dist/providers/Selection/index.js.map +1 -1
- package/dist/providers/Theme/index.js +7 -7
- package/dist/providers/Theme/index.js.map +1 -1
- package/dist/providers/Translation/index.js +12 -12
- package/dist/providers/Translation/index.js.map +1 -1
- package/dist/providers/UploadEdits/index.js +3 -3
- package/dist/providers/UploadEdits/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/utilities/buildClientFieldSchemaMap/index.js +2 -0
- package/dist/utilities/buildClientFieldSchemaMap/index.js.map +1 -1
- package/dist/utilities/buildFieldSchemaMap/index.js +2 -0
- package/dist/utilities/buildFieldSchemaMap/index.js.map +1 -1
- package/dist/utilities/groupNavItems.js +3 -3
- package/dist/utilities/groupNavItems.js.map +1 -1
- package/dist/utilities/parseSearchParams.d.ts +4 -0
- package/dist/utilities/parseSearchParams.d.ts.map +1 -0
- package/dist/utilities/parseSearchParams.js +9 -0
- package/dist/utilities/parseSearchParams.js.map +1 -0
- package/dist/views/Edit/Auth/index.js +47 -47
- package/dist/views/Edit/Auth/index.js.map +1 -1
- package/dist/views/Edit/SetDocumentStepNav/index.d.ts.map +1 -1
- package/dist/views/Edit/SetDocumentStepNav/index.js +16 -14
- package/dist/views/Edit/SetDocumentStepNav/index.js.map +1 -1
- package/dist/views/Edit/SetDocumentTitle/index.js +5 -5
- package/dist/views/Edit/SetDocumentTitle/index.js.map +1 -1
- package/dist/views/List/index.js +20 -24
- package/dist/views/List/index.js.map +1 -1
- package/package.json +16 -17
- package/dist/exports/client/CodeEditor-5MCGR4GL.js +0 -26
- package/dist/exports/client/chunk-4SO5UCQD.js +0 -14
- package/dist/exports/client/chunk-4SO5UCQD.js.map +0 -8
- package/dist/exports/client/chunk-5LUHGAPX.js +0 -30
- package/dist/exports/client/chunk-5LUHGAPX.js.map +0 -8
- /package/dist/exports/client/{DatePicker-QST7QHAX.js.map → CodeEditor-RZ32B2QF.js.map} +0 -0
|
@@ -25,6 +25,8 @@ export const buildClientFieldSchemaMap = args => {
|
|
|
25
25
|
const matchedCollection = config.collections.find(collection => collection.slug === collectionSlug);
|
|
26
26
|
if (matchedCollection) {
|
|
27
27
|
if (matchedCollection.auth && !matchedCollection.auth.disableLocalStrategy) {
|
|
28
|
+
// register schema with auth schemaPath
|
|
29
|
+
;
|
|
28
30
|
baseAuthFields[0].label = i18n.t('general:password');
|
|
29
31
|
baseAuthFields[1].label = i18n.t('authentication:confirmPassword');
|
|
30
32
|
clientSchemaMap.set(`_${matchedCollection.slug}.auth`, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["traverseFields","baseAuthFields","name","type","required","buildClientFieldSchemaMap","args","collectionSlug","config","globalSlug","i18n","payload","schemaMap","clientSchemaMap","Map","matchedCollection","collections","find","collection","slug","auth","disableLocalStrategy","label","t","set","fields","parentIndexPath","parentSchemaPath","matchedGlobal","globals","global","clientFieldSchemaMap"],"sources":["../../../src/utilities/buildClientFieldSchemaMap/index.ts"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type {\n ClientConfig,\n ClientField,\n ClientFieldSchemaMap,\n FieldSchemaMap,\n Payload,\n TextFieldClient,\n} from 'payload'\n\nimport { traverseFields } from './traverseFields.js'\n\nconst baseAuthFields: ClientField[] = [\n {\n name: 'password',\n type: 'text',\n required: true,\n },\n {\n name: 'confirm-password',\n type: 'text',\n required: true,\n },\n]\n\n/**\n * Flattens the config fields into a map of field schemas\n */\nexport const buildClientFieldSchemaMap = (args: {\n collectionSlug?: string\n config: ClientConfig\n globalSlug?: string\n i18n: I18n\n payload: Payload\n schemaMap: FieldSchemaMap\n}): { clientFieldSchemaMap: ClientFieldSchemaMap } => {\n const { collectionSlug, config, globalSlug, i18n, payload, schemaMap } = args\n\n const clientSchemaMap: ClientFieldSchemaMap = new Map()\n\n if (collectionSlug) {\n const matchedCollection = config.collections.find(\n (collection) => collection.slug === collectionSlug,\n )\n\n if (matchedCollection) {\n if (matchedCollection.auth && !matchedCollection.auth.disableLocalStrategy) {\n // register schema with auth schemaPath\n ;(baseAuthFields[0] as TextFieldClient).label = i18n.t('general:password')\n ;(baseAuthFields[1] as TextFieldClient).label = i18n.t('authentication:confirmPassword')\n\n clientSchemaMap.set(`_${matchedCollection.slug}.auth`, {\n fields: [...baseAuthFields, ...matchedCollection.fields],\n })\n }\n\n clientSchemaMap.set(collectionSlug, {\n fields: matchedCollection.fields,\n })\n\n traverseFields({\n clientSchemaMap,\n config,\n fields: matchedCollection.fields,\n i18n,\n parentIndexPath: '',\n parentSchemaPath: collectionSlug,\n payload,\n schemaMap,\n })\n }\n } else if (globalSlug) {\n const matchedGlobal = config.globals.find((global) => global.slug === globalSlug)\n\n if (matchedGlobal) {\n clientSchemaMap.set(globalSlug, {\n fields: matchedGlobal.fields,\n })\n\n traverseFields({\n clientSchemaMap,\n config,\n fields: matchedGlobal.fields,\n i18n,\n parentIndexPath: '',\n parentSchemaPath: globalSlug,\n payload,\n schemaMap,\n })\n }\n }\n\n return { clientFieldSchemaMap: clientSchemaMap }\n}\n"],"mappings":"AAUA,SAASA,cAAc,QAAQ;AAE/B,MAAMC,cAAA,GAAgC,CACpC;EACEC,IAAA,EAAM;EACNC,IAAA,EAAM;EACNC,QAAA,EAAU;AACZ,GACA;EACEF,IAAA,EAAM;EACNC,IAAA,EAAM;EACNC,QAAA,EAAU;AACZ,EACD;AAED;;;AAGA,OAAO,MAAMC,yBAAA,GAA6BC,IAAA;EAQxC,MAAM;IAAEC,cAAc;IAAEC,MAAM;IAAEC,UAAU;IAAEC,IAAI;IAAEC,OAAO;IAAEC;EAAS,CAAE,GAAGN,IAAA;EAEzE,MAAMO,eAAA,GAAwC,IAAIC,GAAA;EAElD,IAAIP,cAAA,EAAgB;IAClB,MAAMQ,iBAAA,GAAoBP,MAAA,CAAOQ,WAAW,CAACC,IAAI,CAC9CC,UAAA,IAAeA,UAAA,CAAWC,IAAI,KAAKZ,cAAA;IAGtC,IAAIQ,iBAAA,EAAmB;MACrB,IAAIA,iBAAA,CAAkBK,IAAI,IAAI,CAACL,iBAAA,CAAkBK,IAAI,CAACC,oBAAoB,EAAE;
|
|
1
|
+
{"version":3,"file":"index.js","names":["traverseFields","baseAuthFields","name","type","required","buildClientFieldSchemaMap","args","collectionSlug","config","globalSlug","i18n","payload","schemaMap","clientSchemaMap","Map","matchedCollection","collections","find","collection","slug","auth","disableLocalStrategy","label","t","set","fields","parentIndexPath","parentSchemaPath","matchedGlobal","globals","global","clientFieldSchemaMap"],"sources":["../../../src/utilities/buildClientFieldSchemaMap/index.ts"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type {\n ClientConfig,\n ClientField,\n ClientFieldSchemaMap,\n FieldSchemaMap,\n Payload,\n TextFieldClient,\n} from 'payload'\n\nimport { traverseFields } from './traverseFields.js'\n\nconst baseAuthFields: ClientField[] = [\n {\n name: 'password',\n type: 'text',\n required: true,\n },\n {\n name: 'confirm-password',\n type: 'text',\n required: true,\n },\n]\n\n/**\n * Flattens the config fields into a map of field schemas\n */\nexport const buildClientFieldSchemaMap = (args: {\n collectionSlug?: string\n config: ClientConfig\n globalSlug?: string\n i18n: I18n\n payload: Payload\n schemaMap: FieldSchemaMap\n}): { clientFieldSchemaMap: ClientFieldSchemaMap } => {\n const { collectionSlug, config, globalSlug, i18n, payload, schemaMap } = args\n\n const clientSchemaMap: ClientFieldSchemaMap = new Map()\n\n if (collectionSlug) {\n const matchedCollection = config.collections.find(\n (collection) => collection.slug === collectionSlug,\n )\n\n if (matchedCollection) {\n if (matchedCollection.auth && !matchedCollection.auth.disableLocalStrategy) {\n // register schema with auth schemaPath\n ;(baseAuthFields[0] as TextFieldClient).label = i18n.t('general:password')\n ;(baseAuthFields[1] as TextFieldClient).label = i18n.t('authentication:confirmPassword')\n\n clientSchemaMap.set(`_${matchedCollection.slug}.auth`, {\n fields: [...baseAuthFields, ...matchedCollection.fields],\n })\n }\n\n clientSchemaMap.set(collectionSlug, {\n fields: matchedCollection.fields,\n })\n\n traverseFields({\n clientSchemaMap,\n config,\n fields: matchedCollection.fields,\n i18n,\n parentIndexPath: '',\n parentSchemaPath: collectionSlug,\n payload,\n schemaMap,\n })\n }\n } else if (globalSlug) {\n const matchedGlobal = config.globals.find((global) => global.slug === globalSlug)\n\n if (matchedGlobal) {\n clientSchemaMap.set(globalSlug, {\n fields: matchedGlobal.fields,\n })\n\n traverseFields({\n clientSchemaMap,\n config,\n fields: matchedGlobal.fields,\n i18n,\n parentIndexPath: '',\n parentSchemaPath: globalSlug,\n payload,\n schemaMap,\n })\n }\n }\n\n return { clientFieldSchemaMap: clientSchemaMap }\n}\n"],"mappings":"AAUA,SAASA,cAAc,QAAQ;AAE/B,MAAMC,cAAA,GAAgC,CACpC;EACEC,IAAA,EAAM;EACNC,IAAA,EAAM;EACNC,QAAA,EAAU;AACZ,GACA;EACEF,IAAA,EAAM;EACNC,IAAA,EAAM;EACNC,QAAA,EAAU;AACZ,EACD;AAED;;;AAGA,OAAO,MAAMC,yBAAA,GAA6BC,IAAA;EAQxC,MAAM;IAAEC,cAAc;IAAEC,MAAM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B,cAAA,CAAe;QACba,eAAA;QACAL,MAAA;QACAiB,MAAA,EAAQG,aAAA,CAAcH,MAAM;QAC5Bf,IAAA;QACAgB,eAAA,EAAiB;QACjBC,gBAAA,EAAkBlB,UAAA;QAClBE,OAAA;QACAC;MACF;IACF;EACF;EAEA,OAAO;IAAEmB,oBAAA,EAAsBlB;EAAgB;AACjD","ignoreList":[]}
|
|
@@ -26,6 +26,8 @@ export const buildFieldSchemaMap = args => {
|
|
|
26
26
|
const matchedCollection = config.collections.find(collection => collection.slug === collectionSlug);
|
|
27
27
|
if (matchedCollection) {
|
|
28
28
|
if (matchedCollection.auth && !matchedCollection.auth.disableLocalStrategy) {
|
|
29
|
+
// register schema with auth schemaPath
|
|
30
|
+
;
|
|
29
31
|
baseAuthFields[0].label = i18n.t('general:password');
|
|
30
32
|
baseAuthFields[1].label = i18n.t('authentication:confirmPassword');
|
|
31
33
|
schemaMap.set(`_${matchedCollection.slug}.auth`, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["confirmPassword","password","traverseFields","baseAuthFields","name","type","required","validate","buildFieldSchemaMap","args","collectionSlug","config","globalSlug","i18n","schemaMap","Map","matchedCollection","collections","find","collection","slug","auth","disableLocalStrategy","label","t","set","fields","parentIndexPath","parentSchemaPath","matchedGlobal","globals","global","fieldSchemaMap"],"sources":["../../../src/utilities/buildFieldSchemaMap/index.ts"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { Field, FieldSchemaMap, SanitizedConfig, TextField } from 'payload'\n\nimport { confirmPassword, password } from 'payload/shared'\n\nimport { traverseFields } from './traverseFields.js'\n\nconst baseAuthFields: Field[] = [\n {\n name: 'password',\n type: 'text',\n required: true,\n validate: password,\n },\n {\n name: 'confirm-password',\n type: 'text',\n required: true,\n validate: confirmPassword,\n },\n]\n\n/**\n * Flattens the config fields into a map of field schemas\n */\nexport const buildFieldSchemaMap = (args: {\n collectionSlug?: string\n config: SanitizedConfig\n globalSlug?: string\n i18n: I18n\n}): { fieldSchemaMap: FieldSchemaMap } => {\n const { collectionSlug, config, globalSlug, i18n } = args\n\n const schemaMap: FieldSchemaMap = new Map()\n\n if (collectionSlug) {\n const matchedCollection = config.collections.find(\n (collection) => collection.slug === collectionSlug,\n )\n\n if (matchedCollection) {\n if (matchedCollection.auth && !matchedCollection.auth.disableLocalStrategy) {\n // register schema with auth schemaPath\n ;(baseAuthFields[0] as TextField).label = i18n.t('general:password')\n ;(baseAuthFields[1] as TextField).label = i18n.t('authentication:confirmPassword')\n\n schemaMap.set(`_${matchedCollection.slug}.auth`, {\n fields: [...baseAuthFields, ...matchedCollection.fields],\n })\n }\n\n schemaMap.set(collectionSlug, {\n fields: matchedCollection.fields,\n })\n\n traverseFields({\n config,\n fields: matchedCollection.fields,\n i18n,\n parentIndexPath: '',\n parentSchemaPath: collectionSlug,\n schemaMap,\n })\n }\n } else if (globalSlug) {\n const matchedGlobal = config.globals.find((global) => global.slug === globalSlug)\n\n if (matchedGlobal) {\n schemaMap.set(globalSlug, {\n fields: matchedGlobal.fields,\n })\n\n traverseFields({\n config,\n fields: matchedGlobal.fields,\n i18n,\n parentIndexPath: '',\n parentSchemaPath: globalSlug,\n schemaMap,\n })\n }\n }\n\n return { fieldSchemaMap: schemaMap }\n}\n"],"mappings":"AAGA,SAASA,eAAe,EAAEC,QAAQ,QAAQ;AAE1C,SAASC,cAAc,QAAQ;AAE/B,MAAMC,cAAA,GAA0B,CAC9B;EACEC,IAAA,EAAM;EACNC,IAAA,EAAM;EACNC,QAAA,EAAU;EACVC,QAAA,EAAUN;AACZ,GACA;EACEG,IAAA,EAAM;EACNC,IAAA,EAAM;EACNC,QAAA,EAAU;EACVC,QAAA,EAAUP;AACZ,EACD;AAED;;;AAGA,OAAO,MAAMQ,mBAAA,GAAuBC,IAAA;EAMlC,MAAM;IAAEC,cAAc;IAAEC,MAAM;IAAEC,UAAU;IAAEC;EAAI,CAAE,GAAGJ,IAAA;EAErD,MAAMK,SAAA,GAA4B,IAAIC,GAAA;EAEtC,IAAIL,cAAA,EAAgB;IAClB,MAAMM,iBAAA,GAAoBL,MAAA,CAAOM,WAAW,CAACC,IAAI,CAC9CC,UAAA,IAAeA,UAAA,CAAWC,IAAI,KAAKV,cAAA;IAGtC,IAAIM,iBAAA,EAAmB;MACrB,IAAIA,iBAAA,CAAkBK,IAAI,IAAI,CAACL,iBAAA,CAAkBK,IAAI,CAACC,oBAAoB,EAAE;
|
|
1
|
+
{"version":3,"file":"index.js","names":["confirmPassword","password","traverseFields","baseAuthFields","name","type","required","validate","buildFieldSchemaMap","args","collectionSlug","config","globalSlug","i18n","schemaMap","Map","matchedCollection","collections","find","collection","slug","auth","disableLocalStrategy","label","t","set","fields","parentIndexPath","parentSchemaPath","matchedGlobal","globals","global","fieldSchemaMap"],"sources":["../../../src/utilities/buildFieldSchemaMap/index.ts"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { Field, FieldSchemaMap, SanitizedConfig, TextField } from 'payload'\n\nimport { confirmPassword, password } from 'payload/shared'\n\nimport { traverseFields } from './traverseFields.js'\n\nconst baseAuthFields: Field[] = [\n {\n name: 'password',\n type: 'text',\n required: true,\n validate: password,\n },\n {\n name: 'confirm-password',\n type: 'text',\n required: true,\n validate: confirmPassword,\n },\n]\n\n/**\n * Flattens the config fields into a map of field schemas\n */\nexport const buildFieldSchemaMap = (args: {\n collectionSlug?: string\n config: SanitizedConfig\n globalSlug?: string\n i18n: I18n\n}): { fieldSchemaMap: FieldSchemaMap } => {\n const { collectionSlug, config, globalSlug, i18n } = args\n\n const schemaMap: FieldSchemaMap = new Map()\n\n if (collectionSlug) {\n const matchedCollection = config.collections.find(\n (collection) => collection.slug === collectionSlug,\n )\n\n if (matchedCollection) {\n if (matchedCollection.auth && !matchedCollection.auth.disableLocalStrategy) {\n // register schema with auth schemaPath\n ;(baseAuthFields[0] as TextField).label = i18n.t('general:password')\n ;(baseAuthFields[1] as TextField).label = i18n.t('authentication:confirmPassword')\n\n schemaMap.set(`_${matchedCollection.slug}.auth`, {\n fields: [...baseAuthFields, ...matchedCollection.fields],\n })\n }\n\n schemaMap.set(collectionSlug, {\n fields: matchedCollection.fields,\n })\n\n traverseFields({\n config,\n fields: matchedCollection.fields,\n i18n,\n parentIndexPath: '',\n parentSchemaPath: collectionSlug,\n schemaMap,\n })\n }\n } else if (globalSlug) {\n const matchedGlobal = config.globals.find((global) => global.slug === globalSlug)\n\n if (matchedGlobal) {\n schemaMap.set(globalSlug, {\n fields: matchedGlobal.fields,\n })\n\n traverseFields({\n config,\n fields: matchedGlobal.fields,\n i18n,\n parentIndexPath: '',\n parentSchemaPath: globalSlug,\n schemaMap,\n })\n }\n }\n\n return { fieldSchemaMap: schemaMap }\n}\n"],"mappings":"AAGA,SAASA,eAAe,EAAEC,QAAQ,QAAQ;AAE1C,SAASC,cAAc,QAAQ;AAE/B,MAAMC,cAAA,GAA0B,CAC9B;EACEC,IAAA,EAAM;EACNC,IAAA,EAAM;EACNC,QAAA,EAAU;EACVC,QAAA,EAAUN;AACZ,GACA;EACEG,IAAA,EAAM;EACNC,IAAA,EAAM;EACNC,QAAA,EAAU;EACVC,QAAA,EAAUP;AACZ,EACD;AAED;;;AAGA,OAAO,MAAMQ,mBAAA,GAAuBC,IAAA;EAMlC,MAAM;IAAEC,cAAc;IAAEC,MAAM;IAAEC,UAAU;IAAEC;EAAI,CAAE,GAAGJ,IAAA;EAErD,MAAMK,SAAA,GAA4B,IAAIC,GAAA;EAEtC,IAAIL,cAAA,EAAgB;IAClB,MAAMM,iBAAA,GAAoBL,MAAA,CAAOM,WAAW,CAACC,IAAI,CAC9CC,UAAA,IAAeA,UAAA,CAAWC,IAAI,KAAKV,cAAA;IAGtC,IAAIM,iBAAA,EAAmB;MACrB,IAAIA,iBAAA,CAAkBK,IAAI,IAAI,CAACL,iBAAA,CAAkBK,IAAI,CAACC,oBAAoB,EAAE;QAC1E;;QACEnB,cAAc,CAAC,EAAE,CAAeoB,KAAK,GAAGV,IAAA,CAAKW,CAAC,CAAC;QAC/CrB,cAAc,CAAC,EAAE,CAAeoB,KAAK,GAAGV,IAAA,CAAKW,CAAC,CAAC;QAEjDV,SAAA,CAAUW,GAAG,CAAC,IAAIT,iBAAA,CAAkBI,IAAI,OAAO,EAAE;UAC/CM,MAAA,EAAQ,C,GAAIvB,cAAA,E,GAAmBa,iBAAA,CAAkBU,MAAM;QACzD;MACF;MAEAZ,SAAA,CAAUW,GAAG,CAACf,cAAA,EAAgB;QAC5BgB,MAAA,EAAQV,iBAAA,CAAkBU;MAC5B;MAEAxB,cAAA,CAAe;QACbS,MAAA;QACAe,MAAA,EAAQV,iBAAA,CAAkBU,MAAM;QAChCb,IAAA;QACAc,eAAA,EAAiB;QACjBC,gBAAA,EAAkBlB,cAAA;QAClBI;MACF;IACF;EACF,OAAO,IAAIF,UAAA,EAAY;IACrB,MAAMiB,aAAA,GAAgBlB,MAAA,CAAOmB,OAAO,CAACZ,IAAI,CAAEa,MAAA,IAAWA,MAAA,CAAOX,IAAI,KAAKR,UAAA;IAEtE,IAAIiB,aAAA,EAAe;MACjBf,SAAA,CAAUW,GAAG,CAACb,UAAA,EAAY;QACxBc,MAAA,EAAQG,aAAA,CAAcH;MACxB;MAEAxB,cAAA,CAAe;QACbS,MAAA;QACAe,MAAA,EAAQG,aAAA,CAAcH,MAAM;QAC5Bb,IAAA;QACAc,eAAA,EAAiB;QACjBC,gBAAA,EAAkBhB,UAAA;QAClBE;MACF;IACF;EACF;EAEA,OAAO;IAAEkB,cAAA,EAAgBlB;EAAU;AACrC","ignoreList":[]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { getTranslation } from '@payloadcms/translations';
|
|
2
|
-
export var EntityType
|
|
3
|
-
(function (EntityType) {
|
|
2
|
+
export var EntityType = /*#__PURE__*/function (EntityType) {
|
|
4
3
|
EntityType["collection"] = "collections";
|
|
5
4
|
EntityType["global"] = "globals";
|
|
6
|
-
|
|
5
|
+
return EntityType;
|
|
6
|
+
}({});
|
|
7
7
|
export function groupNavItems(entities, permissions, i18n) {
|
|
8
8
|
const result = entities.reduce((groups, entityToGroup) => {
|
|
9
9
|
if (permissions?.[entityToGroup.type.toLowerCase()]?.[entityToGroup.entity.slug]?.read) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"groupNavItems.js","names":["getTranslation","EntityType","groupNavItems","entities","permissions","i18n","result","reduce","groups","entityToGroup","type","toLowerCase","entity","slug","read","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 SanitizedCollectionConfig,\n SanitizedGlobalConfig,\n SanitizedPermissions,\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: SanitizedPermissions,\n i18n: I18nClient,\n): NavGroupType[] {\n const result = entities.reduce(\n (groups, entityToGroup) => {\n if (permissions?.[entityToGroup.type.toLowerCase()]?.[entityToGroup.entity.slug]?.read) {\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
|
|
1
|
+
{"version":3,"file":"groupNavItems.js","names":["getTranslation","EntityType","groupNavItems","entities","permissions","i18n","result","reduce","groups","entityToGroup","type","toLowerCase","entity","slug","read","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 SanitizedCollectionConfig,\n SanitizedGlobalConfig,\n SanitizedPermissions,\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: SanitizedPermissions,\n i18n: I18nClient,\n): NavGroupType[] {\n const result = entities.reduce(\n (groups, entityToGroup) => {\n if (permissions?.[entityToGroup.type.toLowerCase()]?.[entityToGroup.entity.slug]?.read) {\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;AAE/B,OAAO,IAAAC,UAAK,0BAAAA,UAAA;;;SAAAA,UAAA;;AAwBZ,OAAO,SAASC,cACdC,QAAyB,EACzBC,WAAiC,EACjCC,IAAgB;EAEhB,MAAMC,MAAA,GAASH,QAAA,CAASI,MAAM,CAC5B,CAACC,MAAA,EAAQC,aAAA;IACP,IAAIL,WAAA,GAAcK,aAAA,CAAcC,IAAI,CAACC,WAAW,GAAG,GAAGF,aAAA,CAAcG,MAAM,CAACC,IAAI,CAAC,EAAEC,IAAA,E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H,IAAA,EAAMD,aAAA,CAAcC,IAAI;UACxBU,KAAA,EACE,YAAYX,aAAA,CAAcG,MAAM,GAC5B,OAAOH,aAAA,CAAcG,MAAM,CAACW,MAAM,CAACC,MAAM,KAAK,aAC5Cf,aAAA,CAAcG,MAAM,CAACW,MAAM,CAACC,MAAM,CAAC;YAAEC,CAAA,EAAGpB,IAAA,CAAKoB;UAAE,KAC/ChB,aAAA,CAAcG,MAAM,CAACW,MAAM,CAACC,MAAM,GACpCf,aAAA,CAAcG,MAAM,CAACQ;QAC7B;MACF;IACF;IAEA,OAAOZ,MAAA;EACT,GACA,CACE;IACEL,QAAA,EAAU,EAAE;IACZiB,KAAA,EAAOf,IAAA,CAAKoB,CAAC,CAAC;EAChB,GACA;IACEtB,QAAA,EAAU,EAAE;IACZiB,KAAA,EAAOf,IAAA,CAAKoB,CAAC,CAAC;EAChB,EACD;EAGH,OAAOnB,MAAA,CAAOqB,MAAM,CAAEV,KAAA,IAAUA,KAAA,CAAMd,QAAQ,CAACyB,MAAM,GAAG;AAC1D","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseSearchParams.d.ts","sourceRoot":"","sources":["../../src/utilities/parseSearchParams.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAA;AAEjE,OAAO,KAAK,EAAE,MAAM,QAAQ,CAAA;AAE5B,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,uBAAuB,GAAG,EAAE,CAAC,QAAQ,CAO9E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseSearchParams.js","names":["qs","parseSearchParams","params","search","toString","parse","depth","ignoreQueryPrefix"],"sources":["../../src/utilities/parseSearchParams.ts"],"sourcesContent":["import type { ReadonlyURLSearchParams } from 'next/navigation.js'\n\nimport * as qs from 'qs-esm'\n\nexport function parseSearchParams(params: ReadonlyURLSearchParams): qs.ParsedQs {\n const search = params.toString()\n\n return qs.parse(search, {\n depth: 10,\n ignoreQueryPrefix: true,\n })\n}\n"],"mappings":"AAEA,YAAYA,EAAA,MAAQ;AAEpB,OAAO,SAASC,kBAAkBC,MAA+B;EAC/D,MAAMC,MAAA,GAASD,MAAA,CAAOE,QAAQ;EAE9B,OAAOJ,EAAA,CAAGK,KAAK,CAACF,MAAA,EAAQ;IACtBG,KAAA,EAAO;IACPC,iBAAA,EAAmB;EACrB;AACF","ignoreList":[]}
|
|
@@ -76,7 +76,7 @@ export const Auth = props => {
|
|
|
76
76
|
const canReadApiKey = apiKeyPermissions === true || apiKeyPermissions?.read;
|
|
77
77
|
const canReadEnableAPIKey = apiKeyPermissions === true || apiKeyPermissions?.read;
|
|
78
78
|
let t3;
|
|
79
|
-
if ($[0] !==
|
|
79
|
+
if ($[0] !== collectionSlug || $[1] !== dispatchFields || $[2] !== setSchemaPathSegments || $[3] !== setValidateBeforeSubmit || $[4] !== t) {
|
|
80
80
|
t3 = showPasswordFields => {
|
|
81
81
|
if (showPasswordFields) {
|
|
82
82
|
setValidateBeforeSubmit(true);
|
|
@@ -107,10 +107,10 @@ export const Auth = props => {
|
|
|
107
107
|
}
|
|
108
108
|
setChangingPassword(showPasswordFields);
|
|
109
109
|
};
|
|
110
|
-
$[0] =
|
|
111
|
-
$[1] =
|
|
112
|
-
$[2] =
|
|
113
|
-
$[3] =
|
|
110
|
+
$[0] = collectionSlug;
|
|
111
|
+
$[1] = dispatchFields;
|
|
112
|
+
$[2] = setSchemaPathSegments;
|
|
113
|
+
$[3] = setValidateBeforeSubmit;
|
|
114
114
|
$[4] = t;
|
|
115
115
|
$[5] = t3;
|
|
116
116
|
} else {
|
|
@@ -118,7 +118,7 @@ export const Auth = props => {
|
|
|
118
118
|
}
|
|
119
119
|
const handleChangePassword = t3;
|
|
120
120
|
let t4;
|
|
121
|
-
if ($[6] !==
|
|
121
|
+
if ($[6] !== api || $[7] !== collectionSlug || $[8] !== email || $[9] !== i18n.language || $[10] !== loginWithUsername || $[11] !== serverURL || $[12] !== t || $[13] !== username) {
|
|
122
122
|
t4 = async () => {
|
|
123
123
|
const url = `${serverURL}${api}/${collectionSlug}/unlock`;
|
|
124
124
|
const response = await fetch(url, {
|
|
@@ -140,14 +140,14 @@ export const Auth = props => {
|
|
|
140
140
|
toast.error(t("authentication:failedToUnlock"));
|
|
141
141
|
}
|
|
142
142
|
};
|
|
143
|
-
$[6] =
|
|
144
|
-
$[7] =
|
|
145
|
-
$[8] =
|
|
146
|
-
$[9] =
|
|
147
|
-
$[10] =
|
|
148
|
-
$[11] =
|
|
149
|
-
$[12] =
|
|
150
|
-
$[13] =
|
|
143
|
+
$[6] = api;
|
|
144
|
+
$[7] = collectionSlug;
|
|
145
|
+
$[8] = email;
|
|
146
|
+
$[9] = i18n.language;
|
|
147
|
+
$[10] = loginWithUsername;
|
|
148
|
+
$[11] = serverURL;
|
|
149
|
+
$[12] = t;
|
|
150
|
+
$[13] = username;
|
|
151
151
|
$[14] = t4;
|
|
152
152
|
} else {
|
|
153
153
|
t4 = $[14];
|
|
@@ -185,9 +185,9 @@ export const Auth = props => {
|
|
|
185
185
|
}
|
|
186
186
|
const t8 = t7.join(" ");
|
|
187
187
|
let t9;
|
|
188
|
-
if ($[20] !==
|
|
188
|
+
if ($[20] !== apiKeyReadOnly || $[21] !== canReadApiKey || $[22] !== canReadEnableAPIKey || $[23] !== collectionSlug || $[24] !== disableLocalStrategy || $[25] !== disabled || $[26] !== docPermissions?.fields || $[27] !== enableAPIKey?.value || $[28] !== enableAPIKeyReadOnly || $[29] !== handleChangePassword || $[30] !== hasPermissionToUnlock || $[31] !== loginWithUsername || $[32] !== operation || $[33] !== readOnly || $[34] !== requirePassword || $[35] !== showPasswordFields_0 || $[36] !== t || $[37] !== t8 || $[38] !== unlock || $[39] !== useAPIKey || $[40] !== verify) {
|
|
189
189
|
let t10;
|
|
190
|
-
if ($[42] !==
|
|
190
|
+
if ($[42] !== apiKeyReadOnly || $[43] !== canReadApiKey || $[44] !== canReadEnableAPIKey || $[45] !== collectionSlug || $[46] !== disabled || $[47] !== enableAPIKey?.value || $[48] !== enableAPIKeyReadOnly || $[49] !== t || $[50] !== useAPIKey) {
|
|
191
191
|
t10 = useAPIKey && _jsxs("div", {
|
|
192
192
|
className: `${baseClass}__api-key`,
|
|
193
193
|
children: [canReadEnableAPIKey && _jsx(CheckboxField, {
|
|
@@ -206,21 +206,21 @@ export const Auth = props => {
|
|
|
206
206
|
readOnly: apiKeyReadOnly
|
|
207
207
|
})]
|
|
208
208
|
});
|
|
209
|
-
$[42] =
|
|
210
|
-
$[43] =
|
|
211
|
-
$[44] =
|
|
212
|
-
$[45] =
|
|
213
|
-
$[46] =
|
|
214
|
-
$[47] =
|
|
215
|
-
$[48] =
|
|
216
|
-
$[49] =
|
|
217
|
-
$[50] =
|
|
209
|
+
$[42] = apiKeyReadOnly;
|
|
210
|
+
$[43] = canReadApiKey;
|
|
211
|
+
$[44] = canReadEnableAPIKey;
|
|
212
|
+
$[45] = collectionSlug;
|
|
213
|
+
$[46] = disabled;
|
|
214
|
+
$[47] = enableAPIKey?.value;
|
|
215
|
+
$[48] = enableAPIKeyReadOnly;
|
|
216
|
+
$[49] = t;
|
|
217
|
+
$[50] = useAPIKey;
|
|
218
218
|
$[51] = t10;
|
|
219
219
|
} else {
|
|
220
220
|
t10 = $[51];
|
|
221
221
|
}
|
|
222
222
|
let t11;
|
|
223
|
-
if ($[52] !==
|
|
223
|
+
if ($[52] !== collectionSlug || $[53] !== disabled || $[54] !== readOnly || $[55] !== t || $[56] !== verify) {
|
|
224
224
|
t11 = verify && _jsx(CheckboxField, {
|
|
225
225
|
field: {
|
|
226
226
|
name: "_verified",
|
|
@@ -233,11 +233,11 @@ export const Auth = props => {
|
|
|
233
233
|
path: "_verified",
|
|
234
234
|
schemaPath: `${collectionSlug}._verified`
|
|
235
235
|
});
|
|
236
|
-
$[52] =
|
|
236
|
+
$[52] = collectionSlug;
|
|
237
237
|
$[53] = disabled;
|
|
238
238
|
$[54] = readOnly;
|
|
239
239
|
$[55] = t;
|
|
240
|
-
$[56] =
|
|
240
|
+
$[56] = verify;
|
|
241
241
|
$[57] = t11;
|
|
242
242
|
} else {
|
|
243
243
|
t11 = $[57];
|
|
@@ -296,27 +296,27 @@ export const Auth = props => {
|
|
|
296
296
|
})]
|
|
297
297
|
}), t10, t11]
|
|
298
298
|
});
|
|
299
|
-
$[20] =
|
|
300
|
-
$[21] =
|
|
301
|
-
$[22] =
|
|
302
|
-
$[23] =
|
|
303
|
-
$[24] =
|
|
304
|
-
$[25] =
|
|
305
|
-
$[26] =
|
|
306
|
-
$[27] =
|
|
307
|
-
$[28] =
|
|
299
|
+
$[20] = apiKeyReadOnly;
|
|
300
|
+
$[21] = canReadApiKey;
|
|
301
|
+
$[22] = canReadEnableAPIKey;
|
|
302
|
+
$[23] = collectionSlug;
|
|
303
|
+
$[24] = disableLocalStrategy;
|
|
304
|
+
$[25] = disabled;
|
|
305
|
+
$[26] = docPermissions?.fields;
|
|
306
|
+
$[27] = enableAPIKey?.value;
|
|
307
|
+
$[28] = enableAPIKeyReadOnly;
|
|
308
308
|
$[29] = handleChangePassword;
|
|
309
309
|
$[30] = hasPermissionToUnlock;
|
|
310
|
-
$[31] =
|
|
311
|
-
$[32] =
|
|
312
|
-
$[33] =
|
|
313
|
-
$[34] =
|
|
314
|
-
$[35] =
|
|
315
|
-
$[36] =
|
|
316
|
-
$[37] =
|
|
317
|
-
$[38] =
|
|
318
|
-
$[39] =
|
|
319
|
-
$[40] =
|
|
310
|
+
$[31] = loginWithUsername;
|
|
311
|
+
$[32] = operation;
|
|
312
|
+
$[33] = readOnly;
|
|
313
|
+
$[34] = requirePassword;
|
|
314
|
+
$[35] = showPasswordFields_0;
|
|
315
|
+
$[36] = t;
|
|
316
|
+
$[37] = t8;
|
|
317
|
+
$[38] = unlock;
|
|
318
|
+
$[39] = useAPIKey;
|
|
319
|
+
$[40] = verify;
|
|
320
320
|
$[41] = t9;
|
|
321
321
|
} else {
|
|
322
322
|
t9 = $[41];
|
|
@@ -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","Boolean","unlock","undefined","hasPermissionToUnlock","apiKeyPermissions","fields","apiKeyReadOnly","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","t5","t6","disabled","showPasswordFields_0","t7","filter","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 return Boolean('unlock' in collection ? collection.unlock : undefined)\n }\n\n return false\n }, [permissions, collectionSlug])\n\n const apiKeyPermissions =\n docPermissions?.fields === true ? true : docPermissions?.fields?.enableAPIKey\n\n const apiKeyReadOnly =\n readOnly ||\n apiKeyPermissions === true ||\n (apiKeyPermissions && typeof apiKeyPermissions === 'object' && !apiKeyPermissions?.update)\n\n const enableAPIKeyReadOnly =\n readOnly || (apiKeyPermissions !== true && !apiKeyPermissions?.update)\n\n const canReadApiKey = apiKeyPermissions === true || apiKeyPermissions?.read\n const canReadEnableAPIKey = apiKeyPermissions === true || apiKeyPermissions?.read\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,S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,CAAA,KACY3C,oBAAA,KAAqB;YAAA4C,IAAA,EAC/B;YAAAlB,QAAA,EAEJzD,CAAA,CAAE;UAAA,C,GAGNnB,SAAA,KAAc,YAAYmC,qBAAA,IACzB0C,IAAA,CAAAlG,MAAA;YAAAiH,WAAA,EACc;YAAAzB,QAAA;YAAA0B,OAAA,EAAAA,CAAA,UAEQ5D,MAAA;YAAA6D,IAAA,EACf;YAAAlB,QAAA,EAEJzD,CAAA,CAAE;UAAA,C;;UAMZuD,G,EAgBAW,G;;;;;;;;;;;;;;;;;;;;;;;;;;;SAlFHZ,E;CA+FJ;AAxNqC,SAAA7D,MAAAW,EAAA;EAmBC,OAAAc,MAAA,IAAAd,EAAQ;EAAA,OAAKc,MAAC,IAAUA,MAAA,EAAA1B,YAAQ,QAAiB;AAAA;AAnBlD,SAAAG,OAAAS,EAAA;EAoBY,OAAAyE,QAAA,IAAAzE,EAAQ;EAAA,OAAKc,QAAC,IAAUA,QAAA,EAAA4D,QAAQ,QAAa;AAAA;AApBzD,SAAAjF,OAAAkF,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","Boolean","unlock","undefined","hasPermissionToUnlock","apiKeyPermissions","fields","apiKeyReadOnly","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","t5","t6","disabled","showPasswordFields_0","t7","filter","t8","join","t9","value","t10","_jsxs","children","_jsx","field","name","admin","label","schemaPath","enabled","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 return Boolean('unlock' in collection ? collection.unlock : undefined)\n }\n\n return false\n }, [permissions, collectionSlug])\n\n const apiKeyPermissions =\n docPermissions?.fields === true ? true : docPermissions?.fields?.enableAPIKey\n\n const apiKeyReadOnly =\n readOnly ||\n apiKeyPermissions === true ||\n (apiKeyPermissions && typeof apiKeyPermissions === 'object' && !apiKeyPermissions?.update)\n\n const enableAPIKeyReadOnly =\n readOnly || (apiKeyPermissions !== true && !apiKeyPermissions?.update)\n\n const canReadApiKey = apiKeyPermissions === true || apiKeyPermissions?.read\n const canReadEnableAPIKey = apiKeyPermissions === true || apiKeyPermissions?.read\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,SAASC,MAAM,QAAQ;AACvB,OAAO;AAEP,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,IAAA,GAAwBC,KAAA;EAAA,MAAAC,CAAA,GAAAtB,EAAA;EACnC;IAAAuB,SAAA;IAAAC,cAAA;IAAAC,oBAAA;IAAAC,KAAA;IAAAC,iBAAA;IAAAC,SAAA;IAAAC,QAAA;IAAAC,eAAA;IAAAC,qBAAA;IAAAC,uBAAA;IAAAC,SAAA;IAAAC,QAAA;IAAAC;EAAA,IAcId,KAAA;EAEJ;IAAAe;EAAA,IAAwBtB,OAAA;EACxB,OAAAuB,gBAAA,EAAAC,mBAAA,IAAgDjC,QAAA,CAASyB,eAAA;EACzD,MAAAS,YAAA,GAAqB3B,aAAA,CAAA4B,KAAgE;EACrF,MAAAC,uBAAA,GAAgC7B,aAAA,CAAA8B,MAA4D;EAC5F,MAAAC,cAAA,GAAuB/B,aAAA,CAAAgC,MAAqC;EAC5D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AAyE,QAAA,IAAAzE,EAAQ;EAAA,OAAKc,QAAC,IAAUA,QAAA,EAAA4D,QAAQ,QAAa;AAAA;AApBzD,SAAAjF,OAAAkF,OAAA;EAAA,OAqBeA,OAAO;AAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/Edit/SetDocumentStepNav/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAe/E,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC;IACxC,cAAc,CAAC,EAAE,yBAAyB,CAAC,MAAM,CAAC,CAAA;IAClD,WAAW,CAAC,EAAE,qBAAqB,CAAC,OAAO,CAAC,CAAA;IAC5C,UAAU,CAAC,EAAE,qBAAqB,CAAC,MAAM,CAAC,CAAA;IAC1C,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,WAAW,CAAC,EAAE,yBAAyB,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAA;IAC3D,UAAU,CAAC,EAAE,yBAAyB,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,CAAA;IAC7D,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/Edit/SetDocumentStepNav/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAe/E,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC;IACxC,cAAc,CAAC,EAAE,yBAAyB,CAAC,MAAM,CAAC,CAAA;IAClD,WAAW,CAAC,EAAE,qBAAqB,CAAC,OAAO,CAAC,CAAA;IAC5C,UAAU,CAAC,EAAE,qBAAqB,CAAC,MAAM,CAAC,CAAA;IAC1C,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,WAAW,CAAC,EAAE,yBAAyB,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAA;IAC3D,UAAU,CAAC,EAAE,yBAAyB,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,CAAA;IAC7D,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CA8FA,CAAA"}
|
|
@@ -61,7 +61,7 @@ export const SetDocumentStepNav = props => {
|
|
|
61
61
|
const drawerDepth = useEditDepth();
|
|
62
62
|
let t3;
|
|
63
63
|
let t4;
|
|
64
|
-
if ($[4] !==
|
|
64
|
+
if ($[4] !== adminRoute || $[5] !== collectionSlug || $[6] !== drawerDepth || $[7] !== globalSlug || $[8] !== i18n || $[9] !== id || $[10] !== isEditing || $[11] !== isInitializing || $[12] !== isVisible || $[13] !== pluralLabel || $[14] !== setStepNav || $[15] !== t || $[16] !== title || $[17] !== useAsTitle || $[18] !== view) {
|
|
65
65
|
t3 = () => {
|
|
66
66
|
const nav = [];
|
|
67
67
|
if (!isInitializing) {
|
|
@@ -86,6 +86,7 @@ export const SetDocumentStepNav = props => {
|
|
|
86
86
|
label: t("general:createNew")
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
|
+
console.log("nav", nav);
|
|
89
90
|
} else {
|
|
90
91
|
if (globalSlug) {
|
|
91
92
|
nav.push({
|
|
@@ -103,26 +104,27 @@ export const SetDocumentStepNav = props => {
|
|
|
103
104
|
});
|
|
104
105
|
}
|
|
105
106
|
if (drawerDepth <= 1) {
|
|
107
|
+
console.log("setStepNav", nav);
|
|
106
108
|
setStepNav(nav);
|
|
107
109
|
}
|
|
108
110
|
}
|
|
109
111
|
};
|
|
110
112
|
t4 = [setStepNav, isInitializing, isEditing, pluralLabel, id, useAsTitle, adminRoute, t, i18n, title, collectionSlug, globalSlug, view, drawerDepth, isVisible];
|
|
111
|
-
$[4] =
|
|
113
|
+
$[4] = adminRoute;
|
|
112
114
|
$[5] = collectionSlug;
|
|
113
|
-
$[6] =
|
|
114
|
-
$[7] =
|
|
115
|
-
$[8] =
|
|
116
|
-
$[9] =
|
|
115
|
+
$[6] = drawerDepth;
|
|
116
|
+
$[7] = globalSlug;
|
|
117
|
+
$[8] = i18n;
|
|
118
|
+
$[9] = id;
|
|
117
119
|
$[10] = isEditing;
|
|
118
|
-
$[11] =
|
|
119
|
-
$[12] =
|
|
120
|
-
$[13] =
|
|
121
|
-
$[14] =
|
|
122
|
-
$[15] =
|
|
123
|
-
$[16] =
|
|
124
|
-
$[17] =
|
|
125
|
-
$[18] =
|
|
120
|
+
$[11] = isInitializing;
|
|
121
|
+
$[12] = isVisible;
|
|
122
|
+
$[13] = pluralLabel;
|
|
123
|
+
$[14] = setStepNav;
|
|
124
|
+
$[15] = t;
|
|
125
|
+
$[16] = title;
|
|
126
|
+
$[17] = useAsTitle;
|
|
127
|
+
$[18] = view;
|
|
126
128
|
$[19] = t3;
|
|
127
129
|
$[20] = t4;
|
|
128
130
|
} else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","getTranslation","useEffect","useStepNav","useConfig","useDocumentInfo","useEditDepth","useEntityVisibility","useTranslation","formatAdminURL","SetDocumentStepNav","props","$","id","collectionSlug","globalSlug","pluralLabel","useAsTitle","view","undefined","isEditing","isInitializing","title","isEntityVisible","t0","isVisible","setStepNav","i18n","t","config","t1","routes","t2","admin","adminRoute","drawerDepth","t3","t4","nav","push","label","url","path"],"sources":["../../../../src/views/Edit/SetDocumentStepNav/index.tsx"],"sourcesContent":["'use client'\nimport type { SanitizedCollectionConfig, SanitizedGlobalConfig } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { useEffect } from 'react'\n\nimport type { StepNavItem } from '../../../elements/StepNav/index.js'\n\nimport { useStepNav } from '../../../elements/StepNav/index.js'\nimport { useConfig } from '../../../providers/Config/index.js'\nimport { useDocumentInfo } from '../../../providers/DocumentInfo/index.js'\nimport { useEditDepth } from '../../../providers/EditDepth/index.js'\nimport { useEntityVisibility } from '../../../providers/EntityVisibility/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { formatAdminURL } from '../../../utilities/formatAdminURL.js'\n\nexport const SetDocumentStepNav: React.FC<{\n collectionSlug?: SanitizedCollectionConfig['slug']\n globalLabel?: SanitizedGlobalConfig['label']\n globalSlug?: SanitizedGlobalConfig['slug']\n id?: number | string\n pluralLabel?: SanitizedCollectionConfig['labels']['plural']\n useAsTitle?: SanitizedCollectionConfig['admin']['useAsTitle']\n view?: string\n}> = (props) => {\n const { id, collectionSlug, globalSlug, pluralLabel, useAsTitle } = props\n\n const view: string | undefined = props?.view || undefined\n\n const { isEditing, isInitializing, title } = useDocumentInfo()\n const { isEntityVisible } = useEntityVisibility()\n const isVisible = isEntityVisible({ collectionSlug, globalSlug })\n\n const { setStepNav } = useStepNav()\n\n const { i18n, t } = useTranslation()\n\n const {\n config: {\n routes: { admin: adminRoute },\n },\n } = useConfig()\n\n const drawerDepth = useEditDepth()\n\n useEffect(() => {\n const nav: StepNavItem[] = []\n\n if (!isInitializing) {\n if (collectionSlug) {\n nav.push({\n label: getTranslation(pluralLabel, i18n),\n url: isVisible\n ? formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}`,\n })\n : undefined,\n })\n\n if (isEditing) {\n nav.push({\n label: (useAsTitle && useAsTitle !== 'id' && title) || `${id}`,\n url: isVisible\n ? formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}/${id}`,\n })\n : undefined,\n })\n } else {\n nav.push({\n label: t('general:createNew'),\n })\n }\n } else if (globalSlug) {\n nav.push({\n label: title,\n url: isVisible\n ? formatAdminURL({\n adminRoute,\n path: `/globals/${globalSlug}`,\n })\n : undefined,\n })\n }\n\n if (view) {\n nav.push({\n label: view,\n })\n }\n\n if (drawerDepth <= 1) {\n setStepNav(nav)\n }\n }\n }, [\n setStepNav,\n isInitializing,\n isEditing,\n pluralLabel,\n id,\n useAsTitle,\n adminRoute,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AA,EAAAC;EAAA,IAAAF,EAAqB;EAIjC,MAAAG,WAAA,GAAoB7B,YAAA;EAAA,IAAA8B,EAAA;EAAA,IAAAC,EAAA;EAAA,IAAAzB,CAAA,
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","getTranslation","useEffect","useStepNav","useConfig","useDocumentInfo","useEditDepth","useEntityVisibility","useTranslation","formatAdminURL","SetDocumentStepNav","props","$","id","collectionSlug","globalSlug","pluralLabel","useAsTitle","view","undefined","isEditing","isInitializing","title","isEntityVisible","t0","isVisible","setStepNav","i18n","t","config","t1","routes","t2","admin","adminRoute","drawerDepth","t3","t4","nav","push","label","url","path","console","log"],"sources":["../../../../src/views/Edit/SetDocumentStepNav/index.tsx"],"sourcesContent":["'use client'\nimport type { SanitizedCollectionConfig, SanitizedGlobalConfig } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { useEffect } from 'react'\n\nimport type { StepNavItem } from '../../../elements/StepNav/index.js'\n\nimport { useStepNav } from '../../../elements/StepNav/index.js'\nimport { useConfig } from '../../../providers/Config/index.js'\nimport { useDocumentInfo } from '../../../providers/DocumentInfo/index.js'\nimport { useEditDepth } from '../../../providers/EditDepth/index.js'\nimport { useEntityVisibility } from '../../../providers/EntityVisibility/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { formatAdminURL } from '../../../utilities/formatAdminURL.js'\n\nexport const SetDocumentStepNav: React.FC<{\n collectionSlug?: SanitizedCollectionConfig['slug']\n globalLabel?: SanitizedGlobalConfig['label']\n globalSlug?: SanitizedGlobalConfig['slug']\n id?: number | string\n pluralLabel?: SanitizedCollectionConfig['labels']['plural']\n useAsTitle?: SanitizedCollectionConfig['admin']['useAsTitle']\n view?: string\n}> = (props) => {\n const { id, collectionSlug, globalSlug, pluralLabel, useAsTitle } = props\n\n const view: string | undefined = props?.view || undefined\n\n const { isEditing, isInitializing, title } = useDocumentInfo()\n const { isEntityVisible } = useEntityVisibility()\n const isVisible = isEntityVisible({ collectionSlug, globalSlug })\n\n const { setStepNav } = useStepNav()\n\n const { i18n, t } = useTranslation()\n\n const {\n config: {\n routes: { admin: adminRoute },\n },\n } = useConfig()\n\n const drawerDepth = useEditDepth()\n\n useEffect(() => {\n const nav: StepNavItem[] = []\n\n if (!isInitializing) {\n if (collectionSlug) {\n nav.push({\n label: getTranslation(pluralLabel, i18n),\n url: isVisible\n ? formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}`,\n })\n : undefined,\n })\n\n if (isEditing) {\n nav.push({\n label: (useAsTitle && useAsTitle !== 'id' && title) || `${id}`,\n url: isVisible\n ? formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}/${id}`,\n })\n : undefined,\n })\n } else {\n nav.push({\n label: t('general:createNew'),\n })\n }\n console.log('nav', nav)\n } else if (globalSlug) {\n nav.push({\n label: title,\n url: isVisible\n ? formatAdminURL({\n adminRoute,\n path: `/globals/${globalSlug}`,\n })\n : undefined,\n })\n }\n\n if (view) {\n nav.push({\n label: view,\n })\n }\n\n if (drawerDepth <= 1) {\n console.log('setStepNav', nav)\n setStepNav(nav)\n }\n }\n }, [\n setStepNav,\n isInitializing,\n isEditing,\n pluralLabel,\n id,\n useAsTitle,\n adminRoute,\n t,\n i18n,\n title,\n collectionSlug,\n globalSlug,\n view,\n drawerDepth,\n isVisible,\n ])\n\n return null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAGA,SAASC,cAAc,QAAQ;AAC/B,SAASC,SAAS,QAAQ;AAI1B,SAASC,UAAU,QAAQ;AAC3B,SAASC,SAAS,QAAQ;AAC1B,SAASC,eAAe,QAAQ;AAChC,SAASC,YAAY,QAAQ;AAC7B,SAASC,mBAAmB,QAAQ;AACpC,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAE/B,OAAO,MAAMC,kBAAA,GAQRC,KAAA;EAAA,MAAAC,CAAA,GAAAZ,EAAA;EACH;IAAAa,EAAA;IAAAC,cAAA;I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AAA,EACAiB,UAAA,EACAN,CAAA,EACAD,IAAA,EACAL,KAAA,EACAR,cAAA,EACAC,UAAA,EACAG,IAAA,EACAiB,WAAA,EACAV,SAAA;IACDb,CAAA,MAAAsB,UAAA;IAAAtB,CAAA,MAAAE,cAAA;IAAAF,CAAA,MAAAuB,WAAA;IAAAvB,CAAA,MAAAG,UAAA;IAAAH,CAAA,MAAAe,IAAA;IAAAf,CAAA,MAAAC,EAAA;IAAAD,CAAA,OAAAQ,SAAA;IAAAR,CAAA,OAAAS,cAAA;IAAAT,CAAA,OAAAa,SAAA;IAAAb,CAAA,OAAAI,WAAA;IAAAJ,CAAA,OAAAc,UAAA;IAAAd,CAAA,OAAAgB,CAAA;IAAAhB,CAAA,OAAAU,KAAA;IAAAV,CAAA,OAAAK,UAAA;IAAAL,CAAA,OAAAM,IAAA;IAAAN,CAAA,OAAAwB,EAAA;IAAAxB,CAAA,OAAAyB,EAAA;EAAA;IAAAD,EAAA,GAAAxB,CAAA;IAAAyB,EAAA,GAAAzB,CAAA;EAAA;EAtEDV,SAAA,CAAUkC,EAsDV,EAAGC,EAgBF;EAAA;AAAA,CAGH","ignoreList":[]}
|
|
@@ -36,7 +36,7 @@ export const SetDocumentTitle = props => {
|
|
|
36
36
|
} = useDocumentInfo();
|
|
37
37
|
const dateFormatFromConfig = config?.admin?.dateFormat;
|
|
38
38
|
let t1;
|
|
39
|
-
if ($[2] !==
|
|
39
|
+
if ($[2] !== collectionConfig || $[3] !== dateFormatFromConfig || $[4] !== fallback || $[5] !== field || $[6] !== globalConfig || $[7] !== i18n) {
|
|
40
40
|
t1 = formatDocTitle({
|
|
41
41
|
collectionConfig,
|
|
42
42
|
data: {
|
|
@@ -47,10 +47,10 @@ export const SetDocumentTitle = props => {
|
|
|
47
47
|
globalConfig,
|
|
48
48
|
i18n
|
|
49
49
|
});
|
|
50
|
-
$[2] =
|
|
51
|
-
$[3] =
|
|
52
|
-
$[4] =
|
|
53
|
-
$[5] =
|
|
50
|
+
$[2] = collectionConfig;
|
|
51
|
+
$[3] = dateFormatFromConfig;
|
|
52
|
+
$[4] = fallback;
|
|
53
|
+
$[5] = field;
|
|
54
54
|
$[6] = globalConfig;
|
|
55
55
|
$[7] = i18n;
|
|
56
56
|
$[8] = t1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","useEffect","useRef","useFormFields","useDocumentInfo","useTranslation","formatDocTitle","SetDocumentTitle","props","$","collectionConfig","config","fallback","globalConfig","useAsTitle","admin","t0","t1","fields","field","hasInitialized","i18n","setDocumentTitle","dateFormatFromConfig","dateFormat","data","id","String","value","title","t2","t3","current"],"sources":["../../../../src/views/Edit/SetDocumentTitle/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientCollectionConfig, ClientConfig, ClientGlobalConfig } from 'payload'\n\nimport { useEffect, useRef } from 'react'\n\nimport { useFormFields } from '../../../forms/Form/context.js'\nimport { useDocumentInfo } from '../../../providers/DocumentInfo/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { formatDocTitle } from '../../../utilities/formatDocTitle.js'\n\nexport const SetDocumentTitle: React.FC<{\n collectionConfig?: ClientCollectionConfig\n config?: ClientConfig\n fallback: string\n globalConfig?: ClientGlobalConfig\n}> = (props) => {\n const { collectionConfig, config, fallback, globalConfig } = props\n\n const useAsTitle = collectionConfig?.admin?.useAsTitle\n\n const field = useFormFields(([fields]) => (useAsTitle && fields && fields?.[useAsTitle]) || null)\n\n const hasInitialized = useRef(false)\n\n const { i18n } = useTranslation()\n\n const { setDocumentTitle } = useDocumentInfo()\n\n const dateFormatFromConfig = config?.admin?.dateFormat\n\n const title = formatDocTitle({\n collectionConfig,\n data: { id: '' },\n dateFormat: dateFormatFromConfig,\n fallback:\n typeof field === 'string'\n ? field\n : typeof field === 'number'\n ? String(field)\n : (field?.value as string) || fallback,\n globalConfig,\n i18n,\n })\n\n useEffect(() => {\n if (!hasInitialized.current) {\n hasInitialized.current = true\n return\n }\n\n setDocumentTitle(title)\n }, [setDocumentTitle, title])\n\n return null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAGA,SAASC,SAAS,EAAEC,MAAM,QAAQ;AAElC,SAASC,aAAa,QAAQ;AAC9B,SAASC,eAAe,QAAQ;AAChC,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAE/B,OAAO,MAAMC,gBAAA,GAKRC,KAAA;EAAA,MAAAC,CAAA,GAAAT,EAAA;EACH;IAAAU,gBAAA;IAAAC,MAAA;IAAAC,QAAA;IAAAC;EAAA,IAA6DL,KAAA;EAE7D,MAAAM,UAAA,GAAmBJ,gBAAA,EAAAK,KAAA,EAAAD,UAAA;EAAyB,IAAAE,EAAA;EAAA,IAAAP,CAAA,QAAAK,UAAA;IAEhBE,EAAA,GAAAC,EAAA;MAAC,OAAAC,MAAA,IAAAD,EAAQ;MAAA,OAAKH,UAAC,IAAcI,MAAA,IAAUA,MAAA,GAASJ,UAAA,CAAW,QAAK;IAAA;IAAAL,CAAA,MAAAK,UAAA;IAAAL,CAAA,MAAAO,EAAA;EAAA;IAAAA,EAAA,GAAAP,CAAA;EAAA;EAA5F,MAAAU,KAAA,GAAchB,aAAA,CAAca,EAAgE;EAE5F,MAAAI,cAAA,GAAuBlB,MAAA,MAAO;EAE9B;IAAAmB;EAAA,IAAiBhB,cAAA;EAEjB;IAAAiB;EAAA,IAA6BlB,eAAA;EAE7B,MAAAmB,oBAAA,GAA6BZ,MAAA,EAAAI,KAAA,EAAAS,UAAA;EAAe,IAAAP,EAAA;EAAA,IAAAR,CAAA,
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","useEffect","useRef","useFormFields","useDocumentInfo","useTranslation","formatDocTitle","SetDocumentTitle","props","$","collectionConfig","config","fallback","globalConfig","useAsTitle","admin","t0","t1","fields","field","hasInitialized","i18n","setDocumentTitle","dateFormatFromConfig","dateFormat","data","id","String","value","title","t2","t3","current"],"sources":["../../../../src/views/Edit/SetDocumentTitle/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientCollectionConfig, ClientConfig, ClientGlobalConfig } from 'payload'\n\nimport { useEffect, useRef } from 'react'\n\nimport { useFormFields } from '../../../forms/Form/context.js'\nimport { useDocumentInfo } from '../../../providers/DocumentInfo/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { formatDocTitle } from '../../../utilities/formatDocTitle.js'\n\nexport const SetDocumentTitle: React.FC<{\n collectionConfig?: ClientCollectionConfig\n config?: ClientConfig\n fallback: string\n globalConfig?: ClientGlobalConfig\n}> = (props) => {\n const { collectionConfig, config, fallback, globalConfig } = props\n\n const useAsTitle = collectionConfig?.admin?.useAsTitle\n\n const field = useFormFields(([fields]) => (useAsTitle && fields && fields?.[useAsTitle]) || null)\n\n const hasInitialized = useRef(false)\n\n const { i18n } = useTranslation()\n\n const { setDocumentTitle } = useDocumentInfo()\n\n const dateFormatFromConfig = config?.admin?.dateFormat\n\n const title = formatDocTitle({\n collectionConfig,\n data: { id: '' },\n dateFormat: dateFormatFromConfig,\n fallback:\n typeof field === 'string'\n ? field\n : typeof field === 'number'\n ? String(field)\n : (field?.value as string) || fallback,\n globalConfig,\n i18n,\n })\n\n useEffect(() => {\n if (!hasInitialized.current) {\n hasInitialized.current = true\n return\n }\n\n setDocumentTitle(title)\n }, [setDocumentTitle, title])\n\n return null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAGA,SAASC,SAAS,EAAEC,MAAM,QAAQ;AAElC,SAASC,aAAa,QAAQ;AAC9B,SAASC,eAAe,QAAQ;AAChC,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAE/B,OAAO,MAAMC,gBAAA,GAKRC,KAAA;EAAA,MAAAC,CAAA,GAAAT,EAAA;EACH;IAAAU,gBAAA;IAAAC,MAAA;IAAAC,QAAA;IAAAC;EAAA,IAA6DL,KAAA;EAE7D,MAAAM,UAAA,GAAmBJ,gBAAA,EAAA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