@payloadcms/ui 3.24.0-canary.f229d8d → 3.24.0
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/Autosave/index.d.ts.map +1 -1
- package/dist/elements/Autosave/index.js +143 -108
- package/dist/elements/Autosave/index.js.map +1 -1
- package/dist/elements/BulkUpload/EditMany/DrawerContent.d.ts.map +1 -1
- package/dist/elements/BulkUpload/EditMany/DrawerContent.js +22 -20
- package/dist/elements/BulkUpload/EditMany/DrawerContent.js.map +1 -1
- package/dist/elements/Button/index.d.ts.map +1 -1
- package/dist/elements/Button/index.js +1 -0
- package/dist/elements/Button/index.js.map +1 -1
- package/dist/elements/Button/index.scss +21 -5
- package/dist/elements/ConfirmationModal/index.d.ts +16 -0
- package/dist/elements/ConfirmationModal/index.d.ts.map +1 -0
- package/dist/elements/ConfirmationModal/index.js +158 -0
- package/dist/elements/ConfirmationModal/index.js.map +1 -0
- package/dist/elements/{GenerateConfirmation → ConfirmationModal}/index.scss +1 -1
- package/dist/elements/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/elements/DatePicker/DatePicker.js +2 -0
- package/dist/elements/DatePicker/DatePicker.js.map +1 -1
- package/dist/elements/DatePicker/types.d.ts +1 -0
- package/dist/elements/DatePicker/types.d.ts.map +1 -1
- package/dist/elements/DatePicker/types.js.map +1 -1
- package/dist/elements/DeleteDocument/index.d.ts.map +1 -1
- package/dist/elements/DeleteDocument/index.js +31 -79
- package/dist/elements/DeleteDocument/index.js.map +1 -1
- package/dist/elements/DeleteDocument/index.scss +0 -29
- package/dist/elements/DeleteMany/index.d.ts.map +1 -1
- package/dist/elements/DeleteMany/index.js +16 -43
- package/dist/elements/DeleteMany/index.js.map +1 -1
- package/dist/elements/DeleteMany/index.scss +0 -29
- package/dist/elements/DocumentControls/index.d.ts.map +1 -1
- package/dist/elements/DocumentControls/index.js.map +1 -1
- package/dist/elements/DuplicateDocument/index.d.ts +0 -1
- package/dist/elements/DuplicateDocument/index.d.ts.map +1 -1
- package/dist/elements/DuplicateDocument/index.js +25 -54
- package/dist/elements/DuplicateDocument/index.js.map +1 -1
- package/dist/elements/EditMany/DrawerContent.d.ts.map +1 -1
- package/dist/elements/EditMany/DrawerContent.js +3 -2
- package/dist/elements/EditMany/DrawerContent.js.map +1 -1
- package/dist/elements/FileDetails/DraggableFileDetails/index.d.ts +1 -0
- package/dist/elements/FileDetails/DraggableFileDetails/index.d.ts.map +1 -1
- package/dist/elements/FileDetails/DraggableFileDetails/index.js +19 -17
- package/dist/elements/FileDetails/DraggableFileDetails/index.js.map +1 -1
- package/dist/elements/FileDetails/StaticFileDetails/index.d.ts +1 -0
- package/dist/elements/FileDetails/StaticFileDetails/index.d.ts.map +1 -1
- package/dist/elements/FileDetails/StaticFileDetails/index.js +2 -1
- package/dist/elements/FileDetails/StaticFileDetails/index.js.map +1 -1
- package/dist/elements/FileDetails/index.d.ts +1 -0
- package/dist/elements/FileDetails/index.d.ts.map +1 -1
- package/dist/elements/FileDetails/index.js.map +1 -1
- package/dist/elements/GenerateConfirmation/index.d.ts +1 -2
- package/dist/elements/GenerateConfirmation/index.d.ts.map +1 -1
- package/dist/elements/GenerateConfirmation/index.js +23 -47
- package/dist/elements/GenerateConfirmation/index.js.map +1 -1
- package/dist/elements/LeaveWithoutSaving/index.d.ts +0 -1
- package/dist/elements/LeaveWithoutSaving/index.d.ts.map +1 -1
- package/dist/elements/LeaveWithoutSaving/index.js +56 -113
- package/dist/elements/LeaveWithoutSaving/index.js.map +1 -1
- package/dist/elements/ListControls/index.d.ts +1 -0
- package/dist/elements/ListControls/index.d.ts.map +1 -1
- package/dist/elements/ListControls/index.js +14 -0
- package/dist/elements/ListControls/index.js.map +1 -1
- package/dist/elements/ListControls/index.scss +5 -0
- package/dist/elements/Localizer/LocalizerLabel/index.d.ts.map +1 -1
- package/dist/elements/Localizer/LocalizerLabel/index.js +11 -8
- 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 +2 -0
- package/dist/elements/Localizer/index.js.map +1 -1
- package/dist/elements/Popup/index.d.ts +1 -0
- package/dist/elements/Popup/index.d.ts.map +1 -1
- package/dist/elements/Popup/index.js +2 -0
- package/dist/elements/Popup/index.js.map +1 -1
- package/dist/elements/PreviewButton/index.d.ts +2 -1
- package/dist/elements/PreviewButton/index.d.ts.map +1 -1
- package/dist/elements/PreviewButton/index.js +2 -2
- package/dist/elements/PreviewButton/index.js.map +1 -1
- package/dist/elements/PublishButton/ScheduleDrawer/buildUpcomingColumns.d.ts +1 -2
- package/dist/elements/PublishButton/ScheduleDrawer/buildUpcomingColumns.d.ts.map +1 -1
- package/dist/elements/PublishButton/ScheduleDrawer/buildUpcomingColumns.js.map +1 -1
- package/dist/elements/PublishButton/ScheduleDrawer/index.d.ts +2 -0
- package/dist/elements/PublishButton/ScheduleDrawer/index.d.ts.map +1 -1
- package/dist/elements/PublishButton/ScheduleDrawer/index.js +6 -2
- package/dist/elements/PublishButton/ScheduleDrawer/index.js.map +1 -1
- package/dist/elements/PublishButton/index.d.ts +2 -3
- package/dist/elements/PublishButton/index.d.ts.map +1 -1
- package/dist/elements/PublishButton/index.js +20 -17
- package/dist/elements/PublishButton/index.js.map +1 -1
- package/dist/elements/PublishMany/index.d.ts +0 -1
- package/dist/elements/PublishMany/index.d.ts.map +1 -1
- package/dist/elements/PublishMany/index.js +19 -45
- package/dist/elements/PublishMany/index.js.map +1 -1
- package/dist/elements/RelationshipTable/index.d.ts +7 -2
- package/dist/elements/RelationshipTable/index.d.ts.map +1 -1
- package/dist/elements/RelationshipTable/index.js +69 -23
- package/dist/elements/RelationshipTable/index.js.map +1 -1
- package/dist/elements/RelationshipTable/index.scss +6 -0
- package/dist/elements/SaveButton/index.d.ts +2 -3
- package/dist/elements/SaveButton/index.d.ts.map +1 -1
- package/dist/elements/SaveButton/index.js +3 -3
- package/dist/elements/SaveButton/index.js.map +1 -1
- package/dist/elements/SaveDraftButton/index.d.ts +2 -1
- package/dist/elements/SaveDraftButton/index.d.ts.map +1 -1
- package/dist/elements/SaveDraftButton/index.js +2 -2
- package/dist/elements/SaveDraftButton/index.js.map +1 -1
- package/dist/elements/Status/index.d.ts.map +1 -1
- package/dist/elements/Status/index.js +173 -154
- package/dist/elements/Status/index.js.map +1 -1
- package/dist/elements/Status/index.scss +0 -41
- package/dist/elements/StayLoggedIn/index.d.ts +0 -1
- package/dist/elements/StayLoggedIn/index.d.ts.map +1 -1
- package/dist/elements/StayLoggedIn/index.js +45 -77
- package/dist/elements/StayLoggedIn/index.js.map +1 -1
- package/dist/elements/Table/index.d.ts +1 -9
- package/dist/elements/Table/index.d.ts.map +1 -1
- package/dist/elements/Table/index.js.map +1 -1
- package/dist/elements/TableColumns/buildColumnState.d.ts +1 -2
- package/dist/elements/TableColumns/buildColumnState.d.ts.map +1 -1
- package/dist/elements/TableColumns/buildColumnState.js.map +1 -1
- package/dist/elements/TableColumns/buildPolymorphicColumnState.d.ts +20 -0
- package/dist/elements/TableColumns/buildPolymorphicColumnState.d.ts.map +1 -0
- package/dist/elements/TableColumns/buildPolymorphicColumnState.js +200 -0
- package/dist/elements/TableColumns/buildPolymorphicColumnState.js.map +1 -0
- package/dist/elements/TableColumns/index.d.ts +2 -3
- package/dist/elements/TableColumns/index.d.ts.map +1 -1
- package/dist/elements/TableColumns/index.js +4 -3
- package/dist/elements/TableColumns/index.js.map +1 -1
- package/dist/elements/UnpublishMany/index.d.ts +1 -2
- package/dist/elements/UnpublishMany/index.d.ts.map +1 -1
- package/dist/elements/UnpublishMany/index.js +14 -42
- package/dist/elements/UnpublishMany/index.js.map +1 -1
- package/dist/elements/Upload/index.d.ts.map +1 -1
- package/dist/elements/Upload/index.js +5 -1
- package/dist/elements/Upload/index.js.map +1 -1
- package/dist/elements/ViewDescription/index.d.ts +2 -5
- package/dist/elements/ViewDescription/index.d.ts.map +1 -1
- package/dist/elements/ViewDescription/index.js +2 -2
- package/dist/elements/ViewDescription/index.js.map +1 -1
- package/dist/exports/client/CodeEditor-L6GW2VQ6.js.map +0 -1
- package/dist/exports/client/{DatePicker-THCU4KZJ.js → DatePicker-HHQ6TPOW.js} +2 -2
- package/dist/exports/client/{DatePicker-THCU4KZJ.js.map → DatePicker-HHQ6TPOW.js.map} +0 -1
- package/dist/exports/client/chunk-5LKBKI4T.js.map +0 -1
- package/dist/exports/client/{chunk-EG3ZOHFS.js → chunk-IMEQ6NKQ.js} +2 -2
- package/dist/exports/client/{chunk-EG3ZOHFS.js.map → chunk-IMEQ6NKQ.js.map} +3 -4
- package/dist/exports/client/chunk-ZZDNSFEW.js.map +0 -1
- package/dist/exports/client/index.d.ts +46 -4
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +23 -23
- package/dist/exports/client/index.js.map +4 -5
- package/dist/fields/DateTime/index.d.ts.map +1 -1
- package/dist/fields/DateTime/index.js +24 -6
- package/dist/fields/DateTime/index.js.map +1 -1
- package/dist/fields/Join/index.d.ts.map +1 -1
- package/dist/fields/Join/index.js +8 -3
- package/dist/fields/Join/index.js.map +1 -1
- package/dist/fields/Select/Input.d.ts.map +1 -1
- package/dist/fields/Select/Input.js +2 -0
- package/dist/fields/Select/Input.js.map +1 -1
- package/dist/fields/Tabs/Tab/index.scss +2 -1
- package/dist/fields/Upload/Input.d.ts +1 -0
- package/dist/fields/Upload/Input.d.ts.map +1 -1
- package/dist/fields/Upload/Input.js.map +1 -1
- package/dist/forms/Form/index.d.ts.map +1 -1
- package/dist/forms/Form/index.js +19 -8
- package/dist/forms/Form/index.js.map +1 -1
- package/dist/forms/Form/initContextState.d.ts.map +1 -1
- package/dist/forms/Form/initContextState.js +2 -0
- package/dist/forms/Form/initContextState.js.map +1 -1
- package/dist/forms/Form/types.d.ts +6 -0
- package/dist/forms/Form/types.d.ts.map +1 -1
- package/dist/forms/Form/types.js.map +1 -1
- package/dist/icons/Dots/index.d.ts +7 -0
- package/dist/icons/Dots/index.d.ts.map +1 -0
- package/dist/icons/Dots/index.js +12 -0
- package/dist/icons/Dots/index.js.map +1 -0
- package/dist/icons/Dots/index.scss +27 -0
- package/dist/providers/Selection/index.d.ts.map +1 -1
- package/dist/providers/Selection/index.js +5 -6
- package/dist/providers/Selection/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/utilities/buildTableState.d.ts +1 -2
- package/dist/utilities/buildTableState.d.ts.map +1 -1
- package/dist/utilities/buildTableState.js +72 -20
- package/dist/utilities/buildTableState.js.map +1 -1
- package/dist/utilities/copyDataFromLocale.d.ts.map +1 -1
- package/dist/utilities/copyDataFromLocale.js +20 -14
- package/dist/utilities/copyDataFromLocale.js.map +1 -1
- package/dist/utilities/handleFormStateLocking.d.ts.map +1 -1
- package/dist/utilities/handleFormStateLocking.js +3 -6
- package/dist/utilities/handleFormStateLocking.js.map +1 -1
- package/dist/utilities/renderTable.d.ts +6 -4
- package/dist/utilities/renderTable.d.ts.map +1 -1
- package/dist/utilities/renderTable.js +49 -17
- package/dist/utilities/renderTable.js.map +1 -1
- package/dist/views/Edit/Auth/index.d.ts.map +1 -1
- package/dist/views/Edit/Auth/index.js +56 -55
- package/dist/views/Edit/Auth/index.js.map +1 -1
- package/dist/views/Edit/index.d.ts +2 -2
- package/dist/views/Edit/index.d.ts.map +1 -1
- package/dist/views/Edit/index.js +3 -3
- package/dist/views/Edit/index.js.map +1 -1
- package/dist/views/List/index.d.ts +2 -25
- package/dist/views/List/index.d.ts.map +1 -1
- package/dist/views/List/index.js +6 -3
- package/dist/views/List/index.js.map +1 -1
- package/dist/views/List/types.d.ts +1 -18
- 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/elements/DuplicateDocument/index.scss +0 -42
- package/dist/elements/LeaveWithoutSaving/index.scss +0 -39
- package/dist/elements/PublishMany/index.scss +0 -39
- package/dist/elements/StayLoggedIn/index.scss +0 -40
- package/dist/elements/UnpublishMany/index.scss +0 -39
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { c as _c } from "react/compiler-runtime";
|
|
4
|
-
import { jsx as _jsx
|
|
5
|
-
import { Modal, useModal } from '@faceless-ui/modal';
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
5
|
import { useRouter } from 'next/navigation.js';
|
|
7
|
-
import React from 'react';
|
|
8
|
-
import { Button } from '../../elements/Button/index.js';
|
|
6
|
+
import React, { useCallback } from 'react';
|
|
9
7
|
import { useAuth } from '../../providers/Auth/index.js';
|
|
10
8
|
import { useConfig } from '../../providers/Config/index.js';
|
|
11
9
|
import { useRouteTransition } from '../../providers/RouteTransition/index.js';
|
|
12
10
|
import { useTranslation } from '../../providers/Translation/index.js';
|
|
13
11
|
import { formatAdminURL } from '../../utilities/formatAdminURL.js';
|
|
14
|
-
import '
|
|
15
|
-
const baseClass = 'stay-logged-in';
|
|
12
|
+
import { ConfirmationModal } from '../ConfirmationModal/index.js';
|
|
16
13
|
export const stayLoggedInModalSlug = 'stay-logged-in';
|
|
17
14
|
export const StayLoggedInModal = () => {
|
|
18
|
-
const $ = _c(
|
|
15
|
+
const $ = _c(11);
|
|
19
16
|
const {
|
|
20
17
|
refreshCookie
|
|
21
18
|
} = useAuth();
|
|
@@ -36,9 +33,6 @@ export const StayLoggedInModal = () => {
|
|
|
36
33
|
const {
|
|
37
34
|
admin: adminRoute
|
|
38
35
|
} = t1;
|
|
39
|
-
const {
|
|
40
|
-
closeModal
|
|
41
|
-
} = useModal();
|
|
42
36
|
const {
|
|
43
37
|
t
|
|
44
38
|
} = useTranslation();
|
|
@@ -46,75 +40,49 @@ export const StayLoggedInModal = () => {
|
|
|
46
40
|
startRouteTransition
|
|
47
41
|
} = useRouteTransition();
|
|
48
42
|
let t3;
|
|
49
|
-
if ($[0] !== adminRoute || $[1] !==
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
startRouteTransition(() => router.push(formatAdminURL({
|
|
55
|
-
adminRoute,
|
|
56
|
-
path: logoutRoute
|
|
57
|
-
})));
|
|
58
|
-
};
|
|
59
|
-
$[8] = adminRoute;
|
|
60
|
-
$[9] = closeModal;
|
|
61
|
-
$[10] = logoutRoute;
|
|
62
|
-
$[11] = router;
|
|
63
|
-
$[12] = startRouteTransition;
|
|
64
|
-
$[13] = t4;
|
|
65
|
-
} else {
|
|
66
|
-
t4 = $[13];
|
|
67
|
-
}
|
|
68
|
-
let t5;
|
|
69
|
-
if ($[14] !== closeModal || $[15] !== refreshCookie) {
|
|
70
|
-
t5 = () => {
|
|
71
|
-
refreshCookie();
|
|
72
|
-
closeModal(stayLoggedInModalSlug);
|
|
73
|
-
};
|
|
74
|
-
$[14] = closeModal;
|
|
75
|
-
$[15] = refreshCookie;
|
|
76
|
-
$[16] = t5;
|
|
77
|
-
} else {
|
|
78
|
-
t5 = $[16];
|
|
79
|
-
}
|
|
80
|
-
t3 = _jsx(Modal, {
|
|
81
|
-
className: baseClass,
|
|
82
|
-
slug: stayLoggedInModalSlug,
|
|
83
|
-
children: _jsxs("div", {
|
|
84
|
-
className: `${baseClass}__wrapper`,
|
|
85
|
-
children: [_jsxs("div", {
|
|
86
|
-
className: `${baseClass}__content`,
|
|
87
|
-
children: [_jsx("h1", {
|
|
88
|
-
children: t("authentication:stayLoggedIn")
|
|
89
|
-
}), _jsx("p", {
|
|
90
|
-
children: t("authentication:youAreInactive")
|
|
91
|
-
})]
|
|
92
|
-
}), _jsxs("div", {
|
|
93
|
-
className: `${baseClass}__controls`,
|
|
94
|
-
children: [_jsx(Button, {
|
|
95
|
-
buttonStyle: "secondary",
|
|
96
|
-
onClick: t4,
|
|
97
|
-
size: "large",
|
|
98
|
-
children: t("authentication:logOut")
|
|
99
|
-
}), _jsx(Button, {
|
|
100
|
-
onClick: t5,
|
|
101
|
-
size: "large",
|
|
102
|
-
children: t("authentication:stayLoggedIn")
|
|
103
|
-
})]
|
|
104
|
-
})]
|
|
105
|
-
})
|
|
106
|
-
});
|
|
43
|
+
if ($[0] !== adminRoute || $[1] !== logoutRoute || $[2] !== router || $[3] !== startRouteTransition) {
|
|
44
|
+
t3 = () => startRouteTransition(() => router.push(formatAdminURL({
|
|
45
|
+
adminRoute,
|
|
46
|
+
path: logoutRoute
|
|
47
|
+
})));
|
|
107
48
|
$[0] = adminRoute;
|
|
108
|
-
$[1] =
|
|
109
|
-
$[2] =
|
|
110
|
-
$[3] =
|
|
111
|
-
$[4] =
|
|
112
|
-
|
|
113
|
-
$[
|
|
114
|
-
|
|
49
|
+
$[1] = logoutRoute;
|
|
50
|
+
$[2] = router;
|
|
51
|
+
$[3] = startRouteTransition;
|
|
52
|
+
$[4] = t3;
|
|
53
|
+
} else {
|
|
54
|
+
t3 = $[4];
|
|
55
|
+
}
|
|
56
|
+
const onConfirm = t3;
|
|
57
|
+
let t4;
|
|
58
|
+
if ($[5] !== refreshCookie) {
|
|
59
|
+
t4 = () => {
|
|
60
|
+
refreshCookie();
|
|
61
|
+
};
|
|
62
|
+
$[5] = refreshCookie;
|
|
63
|
+
$[6] = t4;
|
|
64
|
+
} else {
|
|
65
|
+
t4 = $[6];
|
|
66
|
+
}
|
|
67
|
+
const onCancel = t4;
|
|
68
|
+
let t5;
|
|
69
|
+
if ($[7] !== onCancel || $[8] !== onConfirm || $[9] !== t) {
|
|
70
|
+
t5 = _jsx(ConfirmationModal, {
|
|
71
|
+
body: t("authentication:youAreInactive"),
|
|
72
|
+
cancelLabel: t("authentication:stayLoggedIn"),
|
|
73
|
+
confirmLabel: t("authentication:logOut"),
|
|
74
|
+
heading: t("authentication:stayLoggedIn"),
|
|
75
|
+
modalSlug: stayLoggedInModalSlug,
|
|
76
|
+
onCancel,
|
|
77
|
+
onConfirm
|
|
78
|
+
});
|
|
79
|
+
$[7] = onCancel;
|
|
80
|
+
$[8] = onConfirm;
|
|
81
|
+
$[9] = t;
|
|
82
|
+
$[10] = t5;
|
|
115
83
|
} else {
|
|
116
|
-
|
|
84
|
+
t5 = $[10];
|
|
117
85
|
}
|
|
118
|
-
return
|
|
86
|
+
return t5;
|
|
119
87
|
};
|
|
120
88
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","useRouter","React","useCallback","useAuth","useConfig","useRouteTransition","useTranslation","formatAdminURL","ConfirmationModal","stayLoggedInModalSlug","StayLoggedInModal","$","refreshCookie","router","config","admin","t0","routes","t1","t2","logout","logoutRoute","adminRoute","t","startRouteTransition","t3","push","path","onConfirm","t4","onCancel","t5","_jsx","body","cancelLabel","confirmLabel","heading","modalSlug"],"sources":["../../../src/elements/StayLoggedIn/index.tsx"],"sourcesContent":["'use client'\nimport { useRouter } from 'next/navigation.js'\nimport React, { useCallback } from 'react'\n\nimport type { OnCancel } from '../ConfirmationModal/index.js'\n\nimport { useAuth } from '../../providers/Auth/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useRouteTransition } from '../../providers/RouteTransition/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { formatAdminURL } from '../../utilities/formatAdminURL.js'\nimport { ConfirmationModal } from '../ConfirmationModal/index.js'\n\nexport const stayLoggedInModalSlug = 'stay-logged-in'\n\nexport const StayLoggedInModal: React.FC = () => {\n const { refreshCookie } = useAuth()\n\n const router = useRouter()\n const { config } = useConfig()\n\n const {\n admin: {\n routes: { logout: logoutRoute },\n },\n routes: { admin: adminRoute },\n } = config\n\n const { t } = useTranslation()\n const { startRouteTransition } = useRouteTransition()\n\n const onConfirm = useCallback(() => {\n return startRouteTransition(() =>\n router.push(\n formatAdminURL({\n adminRoute,\n path: logoutRoute,\n }),\n ),\n )\n }, [router, startRouteTransition, adminRoute, logoutRoute])\n\n const onCancel: OnCancel = useCallback(() => {\n refreshCookie()\n }, [refreshCookie])\n\n return (\n <ConfirmationModal\n body={t('authentication:youAreInactive')}\n cancelLabel={t('authentication:stayLoggedIn')}\n confirmLabel={t('authentication:logOut')}\n heading={t('authentication:stayLoggedIn')}\n modalSlug={stayLoggedInModalSlug}\n onCancel={onCancel}\n onConfirm={onConfirm}\n />\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AACA,SAASC,SAAS,QAAQ;AAC1B,OAAOC,KAAA,IAASC,WAAW,QAAQ;AAInC,SAASC,OAAO,QAAQ;AACxB,SAASC,SAAS,QAAQ;AAC1B,SAASC,kBAAkB,QAAQ;AACnC,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,SAASC,iBAAiB,QAAQ;AAElC,OAAO,MAAMC,qBAAA,GAAwB;AAErC,OAAO,MAAMC,iBAAA,GAA8BA,CAAA;EAAA,MAAAC,CAAA,GAAAZ,EAAA;EACzC;IAAAa;EAAA,IAA0BT,OAAA;EAE1B,MAAAU,MAAA,GAAeb,SAAA;EACf;IAAAc;EAAA,IAAmBV,SAAA;EAEnB;IAAAW,KAAA,EAAAC,EAAA;IAAAC,MAAA,EAAAC;EAAA,IAKIJ,MAAA;EAJK;IAAAG,MAAA,EAAAE;EAAA,IAAAH,EAEN;EADS;IAAAI,MAAA,EAAAC;EAAA,IAAAF,EAAuB;EAEzB;IAAAJ,KAAA,EAAAO;EAAA,IAAAJ,EAAqB;EAG/B;IAAAK;EAAA,IAAcjB,cAAA;EACd;IAAAkB;EAAA,IAAiCnB,kBAAA;EAAA,IAAAoB,EAAA;EAAA,IAAAd,CAAA,QAAAW,UAAA,IAAAX,CAAA,QAAAU,WAAA,IAAAV,CAAA,QAAAE,MAAA,IAAAF,CAAA,QAAAa,oBAAA;IAEHC,EAAA,GAAAA,CAAA,KACrBD,oBAAA,OACLX,MAAA,CAAAa,IAAA,CACEnB,cAAA;MAAAe,UAAA;MAAAK,IAAA,EAEQN;IAAA,CACR;IAGNV,CAAA,MAAAW,UAAA;IAAAX,CAAA,MAAAU,WAAA;IAAAV,CAAA,MAAAE,MAAA;IAAAF,CAAA,MAAAa,oBAAA;IAAAb,CAAA,MAAAc,EAAA;EAAA;IAAAA,EAAA,GAAAd,CAAA;EAAA;EATA,MAAAiB,SAAA,GAAkBH,EASwC;EAAA,IAAAI,EAAA;EAAA,IAAAlB,CAAA,QAAAC,aAAA;IAEnBiB,EAAA,GAAAA,CAAA;MACrCjB,aAAA;IAAA;IACFD,CAAA,MAAAC,aAAA;IAAAD,CAAA,MAAAkB,EAAA;EAAA;IAAAA,EAAA,GAAAlB,CAAA;EAAA;EAFA,MAAAmB,QAAA,GAA2BD,EAET;EAAA,IAAAE,EAAA;EAAA,IAAApB,CAAA,QAAAmB,QAAA,IAAAnB,CAAA,QAAAiB,SAAA,IAAAjB,CAAA,QAAAY,CAAA;IAGhBQ,EAAA,GAAAC,IAAA,CAAAxB,iBAAA;MAAAyB,IAAA,EACQV,CAAA,CAAE;MAAAW,WAAA,EACKX,CAAA,CAAE;MAAAY,YAAA,EACDZ,CAAA,CAAE;MAAAa,OAAA,EACPb,CAAA,CAAE;MAAAc,SAAA,EAAA5B,qBAAA;MAAAqB,QAAA;MAAAF;IAAA,C;;;;;;;;SAJbG,E;CAUJ","ignoreList":[]}
|
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Column } from 'payload';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import './index.scss';
|
|
4
|
-
export type Column = {
|
|
5
|
-
readonly accessor: string;
|
|
6
|
-
readonly active: boolean;
|
|
7
|
-
readonly CustomLabel?: React.ReactNode;
|
|
8
|
-
readonly field: ClientField;
|
|
9
|
-
readonly Heading: React.ReactNode;
|
|
10
|
-
readonly renderedCells: React.ReactNode[];
|
|
11
|
-
};
|
|
12
4
|
export type Props = {
|
|
13
5
|
readonly appearance?: 'condensed' | 'default';
|
|
14
6
|
readonly columns?: Column[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/Table/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/Table/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAErC,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,cAAc,CAAA;AAIrB,MAAM,MAAM,KAAK,GAAG;IAClB,QAAQ,CAAC,UAAU,CAAC,EAAE,WAAW,GAAG,SAAS,CAAA;IAC7C,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;CACzC,CAAA;AAED,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA0CjC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","baseClass","Table","appearance","columns","data","activeColumns","filter","col","active","length","_jsx","className","Boolean","join","_jsxs","cellPadding","cellSpacing","map","i","id","accessor","Heading","row","rowIndex","colIndex","renderedCells"],"sources":["../../../src/elements/Table/index.tsx"],"sourcesContent":["'use client'\n\nimport type {
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","baseClass","Table","appearance","columns","data","activeColumns","filter","col","active","length","_jsx","className","Boolean","join","_jsxs","cellPadding","cellSpacing","map","i","id","accessor","Heading","row","rowIndex","colIndex","renderedCells"],"sources":["../../../src/elements/Table/index.tsx"],"sourcesContent":["'use client'\n\nimport type { Column } from 'payload'\n\nimport React from 'react'\n\nimport './index.scss'\n\nconst baseClass = 'table'\n\nexport type Props = {\n readonly appearance?: 'condensed' | 'default'\n readonly columns?: Column[]\n readonly data: Record<string, unknown>[]\n}\n\nexport const Table: React.FC<Props> = ({ appearance, columns, data }) => {\n const activeColumns = columns?.filter((col) => col?.active)\n\n if (!activeColumns || activeColumns.length === 0) {\n return <div>No columns selected</div>\n }\n\n return (\n <div\n className={[baseClass, appearance && `${baseClass}--appearance-${appearance}`]\n .filter(Boolean)\n .join(' ')}\n >\n <table cellPadding=\"0\" cellSpacing=\"0\">\n <thead>\n <tr>\n {activeColumns.map((col, i) => (\n <th id={`heading-${col.accessor}`} key={i}>\n {col.Heading}\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {data &&\n data.map((row, rowIndex) => (\n <tr className={`row-${rowIndex + 1}`} key={rowIndex}>\n {activeColumns.map((col, colIndex) => {\n const { accessor } = col\n\n return (\n <td className={`cell-${accessor}`} key={colIndex}>\n {col.renderedCells[rowIndex]}\n </td>\n )\n })}\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAIA,OAAOA,KAAA,MAAW;AAElB,OAAO;AAEP,MAAMC,SAAA,GAAY;AAQlB,OAAO,MAAMC,KAAA,GAAyBA,CAAC;EAAEC,UAAU;EAAEC,OAAO;EAAEC;AAAI,CAAE;EAClE,MAAMC,aAAA,GAAgBF,OAAA,EAASG,MAAA,CAAQC,GAAA,IAAQA,GAAA,EAAKC,MAAA;EAEpD,IAAI,CAACH,aAAA,IAAiBA,aAAA,CAAcI,MAAM,KAAK,GAAG;IAChD,oBAAOC,IAAA,CAAC;gBAAI;;EACd;EAEA,oBACEA,IAAA,CAAC;IACCC,SAAA,EAAW,CAACX,SAAA,EAAWE,UAAA,IAAc,GAAGF,SAAA,gBAAyBE,UAAA,EAAY,CAAC,CAC3EI,MAAM,CAACM,OAAA,EACPC,IAAI,CAAC;cAER,aAAAC,KAAA,CAAC;MAAMC,WAAA,EAAY;MAAIC,WAAA,EAAY;8BACjCN,IAAA,CAAC;kBACC,aAAAA,IAAA,CAAC;oBACEL,aAAA,CAAcY,GAAG,CAAC,CAACV,GAAA,EAAKW,CAAA,kBACvBR,IAAA,CAAC;YAAGS,EAAA,EAAI,WAAWZ,GAAA,CAAIa,QAAQ,EAAE;sBAC9Bb,GAAA,CAAIc;aADiCH,CAAA;;uBAM9CR,IAAA,CAAC;kBACEN,IAAA,IACCA,IAAA,CAAKa,GAAG,CAAC,CAACK,GAAA,EAAKC,QAAA,kBACbb,IAAA,CAAC;UAAGC,SAAA,EAAW,OAAOY,QAAA,GAAW,GAAG;oBACjClB,aAAA,CAAcY,GAAG,CAAC,CAACV,GAAA,EAAKiB,QAAA;YACvB,MAAM;cAAEJ;YAAQ,CAAE,GAAGb,GAAA;YAErB,oBACEG,IAAA,CAAC;cAAGC,SAAA,EAAW,QAAQS,QAAA,EAAU;wBAC9Bb,GAAA,CAAIkB,aAAa,CAACF,QAAA;eADmBC,QAAA;UAI5C;WATyCD,QAAA;;;;AAgBzD","ignoreList":[]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { I18nClient } from '@payloadcms/translations';
|
|
2
|
-
import type { ClientCollectionConfig, DefaultCellComponentProps, ListPreferences, PaginatedDocs, Payload, SanitizedCollectionConfig } from 'payload';
|
|
2
|
+
import type { ClientCollectionConfig, Column, DefaultCellComponentProps, ListPreferences, PaginatedDocs, Payload, SanitizedCollectionConfig } from 'payload';
|
|
3
3
|
import type { SortColumnProps } from '../SortColumn/index.js';
|
|
4
|
-
import type { Column } from '../Table/index.js';
|
|
5
4
|
type Args = {
|
|
6
5
|
beforeRows?: Column[];
|
|
7
6
|
clientCollectionConfig: ClientCollectionConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildColumnState.d.ts","sourceRoot":"","sources":["../../../src/elements/TableColumns/buildColumnState.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EACV,sBAAsB,EAGtB,yBAAyB,EAGzB,eAAe,EACf,aAAa,EACb,OAAO,EACP,yBAAyB,EAG1B,MAAM,SAAS,CAAA;AAWhB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"buildColumnState.d.ts","sourceRoot":"","sources":["../../../src/elements/TableColumns/buildColumnState.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EACV,sBAAsB,EAGtB,MAAM,EACN,yBAAyB,EAGzB,eAAe,EACf,aAAa,EACb,OAAO,EACP,yBAAyB,EAG1B,MAAM,SAAS,CAAA;AAWhB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAW7D,KAAK,IAAI,GAAG;IACV,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IACrB,sBAAsB,EAAE,sBAAsB,CAAA;IAC9C,gBAAgB,EAAE,yBAAyB,CAAA;IAC3C,iBAAiB,EAAE,eAAe,CAAC,SAAS,CAAC,CAAA;IAC7C,OAAO,CAAC,EAAE,eAAe,CAAC,SAAS,CAAC,CAAA;IACpC,eAAe,EAAE,yBAAyB,CAAC,iBAAiB,CAAC,CAAA;IAC7D,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IAC3B,mBAAmB,EAAE,OAAO,CAAA;IAC5B,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,IAAI,EAAE,UAAU,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,eAAe,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAA;IAC1C,UAAU,EAAE,yBAAyB,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,CAAA;CAC7D,CAAA;AAED,eAAO,MAAM,gBAAgB,SAAU,IAAI,KAAG,MAAM,EAsQnD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildColumnState.js","names":["MissingEditorProp","fieldIsHiddenOrDisabled","fieldIsID","fieldIsPresentationalOnly","flattenTopLevelFields","React","RenderCustomComponent","RenderDefaultCell","SortColumn","RenderServerComponent","filterFields","buildColumnState","args","beforeRows","clientCollectionConfig","collectionConfig","columnPreferences","columns","customCellProps","docs","enableRowSelections","i18n","payload","sortColumnProps","useAsTitle","sortedFieldMap","fields","_sortedFieldMap","idFieldIndex","findIndex","field","idField","splice","unshift","useAsTitleFieldIndex","name","useAsTitleField","sortTo","sortFieldMap","fieldMap","sort","a","b","aIndex","column","accessor","bIndex","activeColumnsIndices","sorted","reduce","acc","index","_field","find","f","columnPreference","preference","active","Array","isArray","length","includes","push","CustomLabelToRender","admin","components","Label","undefined","clientProps","customLabelServerProps","clientField","collectionSlug","slug","CustomLabel","Component","importMap","serverProps","fieldAffectsDataSubFields","type","Heading","_jsx","disable","label","baseCellClientProps","cellData","rowData","renderedCells","map","doc","i","isLinkedColumn","cellClientProps","link","cellServerProps","className","columnIndex","onClick","CustomCell","editor","Error","CellComponent","CustomCellComponent","Cell","CustomComponent","Fallback"],"sources":["../../../src/elements/TableColumns/buildColumnState.tsx"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type {\n ClientCollectionConfig,\n ClientComponentProps,\n ClientField,\n DefaultCellComponentProps,\n DefaultServerCellComponentProps,\n Field,\n ListPreferences,\n PaginatedDocs,\n Payload,\n SanitizedCollectionConfig,\n ServerComponentProps,\n StaticLabel,\n} from 'payload'\n\nimport { MissingEditorProp } from 'payload'\nimport {\n fieldIsHiddenOrDisabled,\n fieldIsID,\n fieldIsPresentationalOnly,\n flattenTopLevelFields,\n} from 'payload/shared'\nimport React from 'react'\n\nimport type { SortColumnProps } from '../SortColumn/index.js'\nimport type { Column } from '../Table/index.js'\n\nimport {\n RenderCustomComponent,\n RenderDefaultCell,\n SortColumn,\n // eslint-disable-next-line payload/no-imports-from-exports-dir\n} from '../../exports/client/index.js'\nimport { RenderServerComponent } from '../RenderServerComponent/index.js'\nimport { filterFields } from './filterFields.js'\n\ntype Args = {\n beforeRows?: Column[]\n clientCollectionConfig: ClientCollectionConfig\n collectionConfig: SanitizedCollectionConfig\n columnPreferences: ListPreferences['columns']\n columns?: ListPreferences['columns']\n customCellProps: DefaultCellComponentProps['customCellProps']\n docs: PaginatedDocs['docs']\n enableRowSelections: boolean\n enableRowTypes?: boolean\n i18n: I18nClient\n payload: Payload\n sortColumnProps?: Partial<SortColumnProps>\n useAsTitle: SanitizedCollectionConfig['admin']['useAsTitle']\n}\n\nexport const buildColumnState = (args: Args): Column[] => {\n const {\n beforeRows,\n clientCollectionConfig,\n collectionConfig,\n columnPreferences,\n columns,\n customCellProps,\n docs,\n enableRowSelections,\n i18n,\n payload,\n sortColumnProps,\n useAsTitle,\n } = args\n\n // clientFields contains the fake `id` column\n let sortedFieldMap = flattenTopLevelFields(\n filterFields(clientCollectionConfig.fields),\n true,\n ) as ClientField[]\n\n let _sortedFieldMap = flattenTopLevelFields(\n filterFields(collectionConfig.fields),\n true,\n ) as Field[] // TODO: think of a way to avoid this additional flatten\n\n // place the `ID` field first, if it exists\n // do the same for the `useAsTitle` field with precedence over the `ID` field\n // then sort the rest of the fields based on the `defaultColumns` or `columnPreferences`\n const idFieldIndex = sortedFieldMap?.findIndex((field) => fieldIsID(field))\n\n if (idFieldIndex > -1) {\n const idField = sortedFieldMap.splice(idFieldIndex, 1)[0]\n sortedFieldMap.unshift(idField)\n }\n\n const useAsTitleFieldIndex = useAsTitle\n ? sortedFieldMap.findIndex((field) => 'name' in field && field.name === useAsTitle)\n : -1\n\n if (useAsTitleFieldIndex > -1) {\n const useAsTitleField = sortedFieldMap.splice(useAsTitleFieldIndex, 1)[0]\n sortedFieldMap.unshift(useAsTitleField)\n }\n\n const sortTo = columnPreferences || columns\n\n const sortFieldMap = (fieldMap, sortTo) =>\n fieldMap?.sort((a, b) => {\n const aIndex = sortTo.findIndex((column) => 'name' in a && column.accessor === a.name)\n const bIndex = sortTo.findIndex((column) => 'name' in b && column.accessor === b.name)\n\n if (aIndex === -1 && bIndex === -1) {\n return 0\n }\n\n if (aIndex === -1) {\n return 1\n }\n\n if (bIndex === -1) {\n return -1\n }\n\n return aIndex - bIndex\n })\n\n if (sortTo) {\n // sort the fields to the order of `defaultColumns` or `columnPreferences`\n sortedFieldMap = sortFieldMap(sortedFieldMap, sortTo)\n _sortedFieldMap = sortFieldMap(_sortedFieldMap, sortTo) // TODO: think of a way to avoid this additional sort\n }\n\n const activeColumnsIndices = []\n\n const sorted: Column[] = sortedFieldMap?.reduce((acc, field, index) => {\n if (fieldIsHiddenOrDisabled(field) && !fieldIsID(field)) {\n return acc\n }\n\n const _field = _sortedFieldMap.find(\n (f) => 'name' in field && 'name' in f && f.name === field.name,\n )\n\n const columnPreference = columnPreferences?.find(\n (preference) => field && 'name' in field && preference.accessor === field.name,\n )\n\n let active = false\n\n if (columnPreference) {\n active = columnPreference.active\n } else if (columns && Array.isArray(columns) && columns.length > 0) {\n active = columns.find(\n (column) => field && 'name' in field && column.accessor === field.name,\n )?.active\n } else if (activeColumnsIndices.length < 4) {\n active = true\n }\n\n if (active && !activeColumnsIndices.includes(index)) {\n activeColumnsIndices.push(index)\n }\n\n const CustomLabelToRender =\n _field &&\n 'admin' in _field &&\n 'components' in _field.admin &&\n 'Label' in _field.admin.components &&\n _field.admin.components.Label !== undefined // let it return `null`\n ? _field.admin.components.Label\n : undefined\n\n // TODO: customComponent will be optional in v4\n const clientProps: Omit<ClientComponentProps, 'customComponents'> = {\n field,\n }\n\n const customLabelServerProps: Pick<\n ServerComponentProps,\n 'clientField' | 'collectionSlug' | 'field' | 'i18n' | 'payload'\n > = {\n clientField: field,\n collectionSlug: collectionConfig.slug,\n field: _field,\n i18n,\n payload,\n }\n\n const CustomLabel = CustomLabelToRender\n ? RenderServerComponent({\n clientProps,\n Component: CustomLabelToRender,\n importMap: payload.importMap,\n serverProps: customLabelServerProps,\n })\n : undefined\n\n const fieldAffectsDataSubFields =\n field &&\n field.type &&\n (field.type === 'array' || field.type === 'group' || field.type === 'blocks')\n\n const Heading = (\n <SortColumn\n disable={fieldAffectsDataSubFields || fieldIsPresentationalOnly(field) || undefined}\n Label={CustomLabel}\n label={field && 'label' in field ? (field.label as StaticLabel) : undefined}\n name={'name' in field ? field.name : undefined}\n {...(sortColumnProps || {})}\n />\n )\n\n const baseCellClientProps: DefaultCellComponentProps = {\n cellData: undefined,\n collectionSlug: clientCollectionConfig.slug,\n customCellProps,\n field,\n rowData: undefined,\n }\n\n const column: Column = {\n accessor: 'name' in field ? field.name : undefined,\n active,\n CustomLabel,\n field,\n Heading,\n renderedCells: active\n ? docs.map((doc, i) => {\n const isLinkedColumn = index === activeColumnsIndices[0]\n\n const cellClientProps: DefaultCellComponentProps = {\n ...baseCellClientProps,\n cellData: 'name' in field ? doc[field.name] : undefined,\n link: isLinkedColumn,\n rowData: doc,\n }\n\n const cellServerProps: DefaultServerCellComponentProps = {\n cellData: cellClientProps.cellData,\n className: baseCellClientProps.className,\n collectionConfig,\n collectionSlug: collectionConfig.slug,\n columnIndex: baseCellClientProps.columnIndex,\n customCellProps: baseCellClientProps.customCellProps,\n field: _field,\n i18n,\n link: cellClientProps.link,\n onClick: baseCellClientProps.onClick,\n payload,\n rowData: doc,\n }\n\n let CustomCell = null\n\n if (_field?.type === 'richText') {\n if (!_field?.editor) {\n throw new MissingEditorProp(_field) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n\n if (typeof _field?.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n\n if (!_field.admin) {\n _field.admin = {}\n }\n\n if (!_field.admin.components) {\n _field.admin.components = {}\n }\n\n CustomCell = RenderServerComponent({\n clientProps: cellClientProps,\n Component: _field.editor.CellComponent,\n importMap: payload.importMap,\n serverProps: cellServerProps,\n })\n } else {\n const CustomCellComponent = _field?.admin?.components?.Cell\n\n if (CustomCellComponent) {\n CustomCell = RenderServerComponent({\n clientProps: cellClientProps,\n Component: CustomCellComponent,\n importMap: payload.importMap,\n serverProps: cellServerProps,\n })\n } else {\n CustomCell = undefined\n }\n }\n\n return (\n <RenderCustomComponent\n CustomComponent={CustomCell}\n Fallback={\n <RenderDefaultCell\n clientProps={cellClientProps}\n columnIndex={index}\n enableRowSelections={enableRowSelections}\n isLinkedColumn={isLinkedColumn}\n />\n }\n key={`${i}-${index}`}\n />\n )\n })\n : [],\n }\n\n acc.push(column)\n\n return acc\n }, [])\n\n if (beforeRows) {\n sorted.unshift(...beforeRows)\n }\n\n return sorted\n}\n"],"mappings":";AAgBA,SAASA,iBAAiB,QAAQ;AAClC,SACEC,uBAAuB,EACvBC,SAAS,EACTC,yBAAyB,EACzBC,qBAAqB,QAChB;AACP,OAAOC,KAAA,MAAW;AAKlB,SACEC,qBAAqB,EACrBC,iBAAiB,EACjBC,UAAU,QAEL;AACP,SAASC,qBAAqB,QAAQ;AACtC,SAASC,YAAY,QAAQ;AAkB7B,OAAO,MAAMC,gBAAA,GAAoBC,IAAA;EAC/B,MAAM;IACJC,UAAU;IACVC,sBAAsB;IACtBC,gBAAgB;IAChBC,iBAAiB;IACjBC,OAAO;IACPC,eAAe;IACfC,IAAI;IACJC,mBAAmB;IACnBC,IAAI;IACJC,OAAO;IACPC,eAAe;IACfC;EAAU,CACX,GAAGZ,IAAA;EAEJ;EACA,IAAIa,cAAA,GAAiBrB,qBAAA,CACnBM,YAAA,CAAaI,sBAAA,CAAuBY,MAAM,GAC1C;EAGF,IAAIC,eAAA,GAAkBvB,qBAAA,CACpBM,YAAA,CAAaK,gBAAA,CAAiBW,MAAM,GACpC,KACW;EAAA;EAEb;EACA;EACA;EACA,MAAME,YAAA,GAAeH,cAAA,EAAgBI,SAAA,CAAWC,KAAA,IAAU5B,SAAA,CAAU4B,KAAA;EAEpE,IAAIF,YAAA,GAAe,CAAC,GAAG;IACrB,MAAMG,OAAA,GAAUN,cAAA,CAAeO,MAAM,CAACJ,YAAA,EAAc,EAAE,CAAC,EAAE;IACzDH,cAAA,CAAeQ,OAAO,CAACF,OAAA;EACzB;EAEA,MAAMG,oBAAA,GAAuBV,UAAA,GACzBC,cAAA,CAAeI,SAAS,CAAEC,KAAA,IAAU,UAAUA,KAAA,IAASA,KAAA,CAAMK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AAA;YACbjB,SAAA,EAAWtB,MAAA,CAAO8C,MAAM,CAACE,aAAa;YACtCzB,SAAA,EAAWrD,OAAA,CAAQqD,SAAS;YAC5BC,WAAA,EAAaiB;UACf;QACF,OAAO;UACL,MAAMQ,mBAAA,GAAsBjD,MAAA,EAAQY,KAAA,EAAOC,UAAA,EAAYqC,IAAA;UAEvD,IAAID,mBAAA,EAAqB;YACvBJ,UAAA,GAAaxF,qBAAA,CAAsB;cACjC2D,WAAA,EAAauB,eAAA;cACbjB,SAAA,EAAW2B,mBAAA;cACX1B,SAAA,EAAWrD,OAAA,CAAQqD,SAAS;cAC5BC,WAAA,EAAaiB;YACf;UACF,OAAO;YACLI,UAAA,GAAa9B,SAAA;UACf;QACF;QAEA,oBACEa,IAAA,CAAC1E,qBAAA;UACCiG,eAAA,EAAiBN,UAAA;UACjBO,QAAA,eACExB,IAAA,CAACzE,iBAAA;YACC6D,WAAA,EAAauB,eAAA;YACbI,WAAA,EAAa5C,KAAA;YACb/B,mBAAA,EAAqBA,mBAAA;YACrBsE,cAAA,EAAgBA;;WAGf,GAAGD,CAAA,IAAKtC,KAAA,EAAO;MAG1B,KACA;IACN;IAEAD,GAAA,CAAIY,IAAI,CAAClB,MAAA;IAET,OAAOM,GAAA;EACT,GAAG,EAAE;EAEL,IAAIrC,UAAA,EAAY;IACdmC,MAAA,CAAOf,OAAO,IAAIpB,UAAA;EACpB;EAEA,OAAOmC,MAAA;AACT","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"buildColumnState.js","names":["MissingEditorProp","fieldIsHiddenOrDisabled","fieldIsID","fieldIsPresentationalOnly","flattenTopLevelFields","React","RenderCustomComponent","RenderDefaultCell","SortColumn","RenderServerComponent","filterFields","buildColumnState","args","beforeRows","clientCollectionConfig","collectionConfig","columnPreferences","columns","customCellProps","docs","enableRowSelections","i18n","payload","sortColumnProps","useAsTitle","sortedFieldMap","fields","_sortedFieldMap","idFieldIndex","findIndex","field","idField","splice","unshift","useAsTitleFieldIndex","name","useAsTitleField","sortTo","sortFieldMap","fieldMap","sort","a","b","aIndex","column","accessor","bIndex","activeColumnsIndices","sorted","reduce","acc","index","_field","find","f","columnPreference","preference","active","Array","isArray","length","includes","push","CustomLabelToRender","admin","components","Label","undefined","clientProps","customLabelServerProps","clientField","collectionSlug","slug","CustomLabel","Component","importMap","serverProps","fieldAffectsDataSubFields","type","Heading","_jsx","disable","label","baseCellClientProps","cellData","rowData","renderedCells","map","doc","i","isLinkedColumn","cellClientProps","link","cellServerProps","className","columnIndex","onClick","CustomCell","editor","Error","CellComponent","CustomCellComponent","Cell","CustomComponent","Fallback"],"sources":["../../../src/elements/TableColumns/buildColumnState.tsx"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type {\n ClientCollectionConfig,\n ClientComponentProps,\n ClientField,\n Column,\n DefaultCellComponentProps,\n DefaultServerCellComponentProps,\n Field,\n ListPreferences,\n PaginatedDocs,\n Payload,\n SanitizedCollectionConfig,\n ServerComponentProps,\n StaticLabel,\n} from 'payload'\n\nimport { MissingEditorProp } from 'payload'\nimport {\n fieldIsHiddenOrDisabled,\n fieldIsID,\n fieldIsPresentationalOnly,\n flattenTopLevelFields,\n} from 'payload/shared'\nimport React from 'react'\n\nimport type { SortColumnProps } from '../SortColumn/index.js'\n\nimport {\n RenderCustomComponent,\n RenderDefaultCell,\n SortColumn,\n // eslint-disable-next-line payload/no-imports-from-exports-dir\n} from '../../exports/client/index.js'\nimport { RenderServerComponent } from '../RenderServerComponent/index.js'\nimport { filterFields } from './filterFields.js'\n\ntype Args = {\n beforeRows?: Column[]\n clientCollectionConfig: ClientCollectionConfig\n collectionConfig: SanitizedCollectionConfig\n columnPreferences: ListPreferences['columns']\n columns?: ListPreferences['columns']\n customCellProps: DefaultCellComponentProps['customCellProps']\n docs: PaginatedDocs['docs']\n enableRowSelections: boolean\n enableRowTypes?: boolean\n i18n: I18nClient\n payload: Payload\n sortColumnProps?: Partial<SortColumnProps>\n useAsTitle: SanitizedCollectionConfig['admin']['useAsTitle']\n}\n\nexport const buildColumnState = (args: Args): Column[] => {\n const {\n beforeRows,\n clientCollectionConfig,\n collectionConfig,\n columnPreferences,\n columns,\n customCellProps,\n docs,\n enableRowSelections,\n i18n,\n payload,\n sortColumnProps,\n useAsTitle,\n } = args\n\n // clientFields contains the fake `id` column\n let sortedFieldMap = flattenTopLevelFields(\n filterFields(clientCollectionConfig.fields),\n true,\n ) as ClientField[]\n\n let _sortedFieldMap = flattenTopLevelFields(\n filterFields(collectionConfig.fields),\n true,\n ) as Field[] // TODO: think of a way to avoid this additional flatten\n\n // place the `ID` field first, if it exists\n // do the same for the `useAsTitle` field with precedence over the `ID` field\n // then sort the rest of the fields based on the `defaultColumns` or `columnPreferences`\n const idFieldIndex = sortedFieldMap?.findIndex((field) => fieldIsID(field))\n\n if (idFieldIndex > -1) {\n const idField = sortedFieldMap.splice(idFieldIndex, 1)[0]\n sortedFieldMap.unshift(idField)\n }\n\n const useAsTitleFieldIndex = useAsTitle\n ? sortedFieldMap.findIndex((field) => 'name' in field && field.name === useAsTitle)\n : -1\n\n if (useAsTitleFieldIndex > -1) {\n const useAsTitleField = sortedFieldMap.splice(useAsTitleFieldIndex, 1)[0]\n sortedFieldMap.unshift(useAsTitleField)\n }\n\n const sortTo = columnPreferences || columns\n\n const sortFieldMap = (fieldMap, sortTo) =>\n fieldMap?.sort((a, b) => {\n const aIndex = sortTo.findIndex((column) => 'name' in a && column.accessor === a.name)\n const bIndex = sortTo.findIndex((column) => 'name' in b && column.accessor === b.name)\n\n if (aIndex === -1 && bIndex === -1) {\n return 0\n }\n\n if (aIndex === -1) {\n return 1\n }\n\n if (bIndex === -1) {\n return -1\n }\n\n return aIndex - bIndex\n })\n\n if (sortTo) {\n // sort the fields to the order of `defaultColumns` or `columnPreferences`\n sortedFieldMap = sortFieldMap(sortedFieldMap, sortTo)\n _sortedFieldMap = sortFieldMap(_sortedFieldMap, sortTo) // TODO: think of a way to avoid this additional sort\n }\n\n const activeColumnsIndices = []\n\n const sorted: Column[] = sortedFieldMap?.reduce((acc, field, index) => {\n if (fieldIsHiddenOrDisabled(field) && !fieldIsID(field)) {\n return acc\n }\n\n const _field = _sortedFieldMap.find(\n (f) => 'name' in field && 'name' in f && f.name === field.name,\n )\n\n const columnPreference = columnPreferences?.find(\n (preference) => field && 'name' in field && preference.accessor === field.name,\n )\n\n let active = false\n\n if (columnPreference) {\n active = columnPreference.active\n } else if (columns && Array.isArray(columns) && columns.length > 0) {\n active = columns.find(\n (column) => field && 'name' in field && column.accessor === field.name,\n )?.active\n } else if (activeColumnsIndices.length < 4) {\n active = true\n }\n\n if (active && !activeColumnsIndices.includes(index)) {\n activeColumnsIndices.push(index)\n }\n\n const CustomLabelToRender =\n _field &&\n 'admin' in _field &&\n 'components' in _field.admin &&\n 'Label' in _field.admin.components &&\n _field.admin.components.Label !== undefined // let it return `null`\n ? _field.admin.components.Label\n : undefined\n\n // TODO: customComponent will be optional in v4\n const clientProps: Omit<ClientComponentProps, 'customComponents'> = {\n field,\n }\n\n const customLabelServerProps: Pick<\n ServerComponentProps,\n 'clientField' | 'collectionSlug' | 'field' | 'i18n' | 'payload'\n > = {\n clientField: field,\n collectionSlug: collectionConfig.slug,\n field: _field,\n i18n,\n payload,\n }\n\n const CustomLabel = CustomLabelToRender\n ? RenderServerComponent({\n clientProps,\n Component: CustomLabelToRender,\n importMap: payload.importMap,\n serverProps: customLabelServerProps,\n })\n : undefined\n\n const fieldAffectsDataSubFields =\n field &&\n field.type &&\n (field.type === 'array' || field.type === 'group' || field.type === 'blocks')\n\n const Heading = (\n <SortColumn\n disable={fieldAffectsDataSubFields || fieldIsPresentationalOnly(field) || undefined}\n Label={CustomLabel}\n label={field && 'label' in field ? (field.label as StaticLabel) : undefined}\n name={'name' in field ? field.name : undefined}\n {...(sortColumnProps || {})}\n />\n )\n\n const baseCellClientProps: DefaultCellComponentProps = {\n cellData: undefined,\n collectionSlug: clientCollectionConfig.slug,\n customCellProps,\n field,\n rowData: undefined,\n }\n\n const column: Column = {\n accessor: 'name' in field ? field.name : undefined,\n active,\n CustomLabel,\n field,\n Heading,\n renderedCells: active\n ? docs.map((doc, i) => {\n const isLinkedColumn = index === activeColumnsIndices[0]\n\n const cellClientProps: DefaultCellComponentProps = {\n ...baseCellClientProps,\n cellData: 'name' in field ? doc[field.name] : undefined,\n link: isLinkedColumn,\n rowData: doc,\n }\n\n const cellServerProps: DefaultServerCellComponentProps = {\n cellData: cellClientProps.cellData,\n className: baseCellClientProps.className,\n collectionConfig,\n collectionSlug: collectionConfig.slug,\n columnIndex: baseCellClientProps.columnIndex,\n customCellProps: baseCellClientProps.customCellProps,\n field: _field,\n i18n,\n link: cellClientProps.link,\n onClick: baseCellClientProps.onClick,\n payload,\n rowData: doc,\n }\n\n let CustomCell = null\n\n if (_field?.type === 'richText') {\n if (!_field?.editor) {\n throw new MissingEditorProp(_field) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n\n if (typeof _field?.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n\n if (!_field.admin) {\n _field.admin = {}\n }\n\n if (!_field.admin.components) {\n _field.admin.components = {}\n }\n\n CustomCell = RenderServerComponent({\n clientProps: cellClientProps,\n Component: _field.editor.CellComponent,\n importMap: payload.importMap,\n serverProps: cellServerProps,\n })\n } else {\n const CustomCellComponent = _field?.admin?.components?.Cell\n\n if (CustomCellComponent) {\n CustomCell = RenderServerComponent({\n clientProps: cellClientProps,\n Component: CustomCellComponent,\n importMap: payload.importMap,\n serverProps: cellServerProps,\n })\n } else {\n CustomCell = undefined\n }\n }\n\n return (\n <RenderCustomComponent\n CustomComponent={CustomCell}\n Fallback={\n <RenderDefaultCell\n clientProps={cellClientProps}\n columnIndex={index}\n enableRowSelections={enableRowSelections}\n isLinkedColumn={isLinkedColumn}\n />\n }\n key={`${i}-${index}`}\n />\n )\n })\n : [],\n }\n\n acc.push(column)\n\n return acc\n }, [])\n\n if (beforeRows) {\n sorted.unshift(...befor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sBjD,MAAA,EAAQY,KAAA,EAAOC,UAAA,EAAYqC,IAAA;UAEvD,IAAID,mBAAA,EAAqB;YACvBJ,UAAA,GAAaxF,qBAAA,CAAsB;cACjC2D,WAAA,EAAauB,eAAA;cACbjB,SAAA,EAAW2B,mBAAA;cACX1B,SAAA,EAAWrD,OAAA,CAAQqD,SAAS;cAC5BC,WAAA,EAAaiB;YACf;UACF,OAAO;YACLI,UAAA,GAAa9B,SAAA;UACf;QACF;QAEA,oBACEa,IAAA,CAAC1E,qBAAA;UACCiG,eAAA,EAAiBN,UAAA;UACjBO,QAAA,eACExB,IAAA,CAACzE,iBAAA;YACC6D,WAAA,EAAauB,eAAA;YACbI,WAAA,EAAa5C,KAAA;YACb/B,mBAAA,EAAqBA,mBAAA;YACrBsE,cAAA,EAAgBA;;WAGf,GAAGD,CAAA,IAAKtC,KAAA,EAAO;MAG1B,KACA;IACN;IAEAD,GAAA,CAAIY,IAAI,CAAClB,MAAA;IAET,OAAOM,GAAA;EACT,GAAG,EAAE;EAEL,IAAIrC,UAAA,EAAY;IACdmC,MAAA,CAAOf,OAAO,IAAIpB,UAAA;EACpB;EAEA,OAAOmC,MAAA;AACT","ignoreList":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { I18nClient } from '@payloadcms/translations';
|
|
2
|
+
import type { ClientField, Column, DefaultCellComponentProps, ListPreferences, PaginatedDocs, Payload, SanitizedCollectionConfig } from 'payload';
|
|
3
|
+
import type { SortColumnProps } from '../SortColumn/index.js';
|
|
4
|
+
type Args = {
|
|
5
|
+
beforeRows?: Column[];
|
|
6
|
+
columnPreferences: ListPreferences['columns'];
|
|
7
|
+
columns?: ListPreferences['columns'];
|
|
8
|
+
customCellProps: DefaultCellComponentProps['customCellProps'];
|
|
9
|
+
docs: PaginatedDocs['docs'];
|
|
10
|
+
enableRowSelections: boolean;
|
|
11
|
+
enableRowTypes?: boolean;
|
|
12
|
+
fields: ClientField[];
|
|
13
|
+
i18n: I18nClient;
|
|
14
|
+
payload: Payload;
|
|
15
|
+
sortColumnProps?: Partial<SortColumnProps>;
|
|
16
|
+
useAsTitle: SanitizedCollectionConfig['admin']['useAsTitle'];
|
|
17
|
+
};
|
|
18
|
+
export declare const buildPolymorphicColumnState: (args: Args) => Column[];
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=buildPolymorphicColumnState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildPolymorphicColumnState.d.ts","sourceRoot":"","sources":["../../../src/elements/TableColumns/buildPolymorphicColumnState.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EACV,WAAW,EACX,MAAM,EACN,yBAAyB,EAGzB,eAAe,EACf,aAAa,EACb,OAAO,EACP,yBAAyB,EAE1B,MAAM,SAAS,CAAA;AAWhB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAW7D,KAAK,IAAI,GAAG;IACV,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IACrB,iBAAiB,EAAE,eAAe,CAAC,SAAS,CAAC,CAAA;IAC7C,OAAO,CAAC,EAAE,eAAe,CAAC,SAAS,CAAC,CAAA;IACpC,eAAe,EAAE,yBAAyB,CAAC,iBAAiB,CAAC,CAAA;IAC7D,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IAC3B,mBAAmB,EAAE,OAAO,CAAA;IAC5B,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,MAAM,EAAE,WAAW,EAAE,CAAA;IACrB,IAAI,EAAE,UAAU,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,eAAe,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAA;IAC1C,UAAU,EAAE,yBAAyB,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,CAAA;CAC7D,CAAA;AAED,eAAO,MAAM,2BAA2B,SAAU,IAAI,KAAG,MAAM,EA2P9D,CAAA"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
// Dirty copy of buildColumnState.tsx with some changes to not break things
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { MissingEditorProp } from 'payload';
|
|
4
|
+
import { fieldIsHiddenOrDisabled, fieldIsID, fieldIsPresentationalOnly, flattenTopLevelFields } from 'payload/shared';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { RenderCustomComponent, RenderDefaultCell, SortColumn } from '../../exports/client/index.js';
|
|
7
|
+
import { RenderServerComponent } from '../RenderServerComponent/index.js';
|
|
8
|
+
import { filterFields } from './filterFields.js';
|
|
9
|
+
export const buildPolymorphicColumnState = args => {
|
|
10
|
+
const {
|
|
11
|
+
beforeRows,
|
|
12
|
+
columnPreferences,
|
|
13
|
+
columns,
|
|
14
|
+
customCellProps,
|
|
15
|
+
docs,
|
|
16
|
+
enableRowSelections,
|
|
17
|
+
fields,
|
|
18
|
+
i18n,
|
|
19
|
+
payload,
|
|
20
|
+
sortColumnProps,
|
|
21
|
+
useAsTitle
|
|
22
|
+
} = args;
|
|
23
|
+
// clientFields contains the fake `id` column
|
|
24
|
+
let sortedFieldMap = flattenTopLevelFields(filterFields(fields), true);
|
|
25
|
+
let _sortedFieldMap = flattenTopLevelFields(filterFields(fields), true) // TODO: think of a way to avoid this additional flatten
|
|
26
|
+
;
|
|
27
|
+
// place the `ID` field first, if it exists
|
|
28
|
+
// do the same for the `useAsTitle` field with precedence over the `ID` field
|
|
29
|
+
// then sort the rest of the fields based on the `defaultColumns` or `columnPreferences`
|
|
30
|
+
const idFieldIndex = sortedFieldMap?.findIndex(field => fieldIsID(field));
|
|
31
|
+
if (idFieldIndex > -1) {
|
|
32
|
+
const idField = sortedFieldMap.splice(idFieldIndex, 1)[0];
|
|
33
|
+
sortedFieldMap.unshift(idField);
|
|
34
|
+
}
|
|
35
|
+
const useAsTitleFieldIndex = useAsTitle ? sortedFieldMap.findIndex(field => 'name' in field && field.name === useAsTitle) : -1;
|
|
36
|
+
if (useAsTitleFieldIndex > -1) {
|
|
37
|
+
const useAsTitleField = sortedFieldMap.splice(useAsTitleFieldIndex, 1)[0];
|
|
38
|
+
sortedFieldMap.unshift(useAsTitleField);
|
|
39
|
+
}
|
|
40
|
+
const sortTo = columnPreferences || columns;
|
|
41
|
+
const sortFieldMap = (fieldMap, sortTo) => fieldMap?.sort((a, b) => {
|
|
42
|
+
const aIndex = sortTo.findIndex(column => 'name' in a && column.accessor === a.name);
|
|
43
|
+
const bIndex = sortTo.findIndex(column => 'name' in b && column.accessor === b.name);
|
|
44
|
+
if (aIndex === -1 && bIndex === -1) {
|
|
45
|
+
return 0;
|
|
46
|
+
}
|
|
47
|
+
if (aIndex === -1) {
|
|
48
|
+
return 1;
|
|
49
|
+
}
|
|
50
|
+
if (bIndex === -1) {
|
|
51
|
+
return -1;
|
|
52
|
+
}
|
|
53
|
+
return aIndex - bIndex;
|
|
54
|
+
});
|
|
55
|
+
if (sortTo) {
|
|
56
|
+
// sort the fields to the order of `defaultColumns` or `columnPreferences`
|
|
57
|
+
sortedFieldMap = sortFieldMap(sortedFieldMap, sortTo);
|
|
58
|
+
_sortedFieldMap = sortFieldMap(_sortedFieldMap, sortTo) // TODO: think of a way to avoid this additional sort
|
|
59
|
+
;
|
|
60
|
+
}
|
|
61
|
+
const activeColumnsIndices = [];
|
|
62
|
+
const sorted = sortedFieldMap?.reduce((acc, field, index) => {
|
|
63
|
+
if (fieldIsHiddenOrDisabled(field) && !fieldIsID(field)) {
|
|
64
|
+
return acc;
|
|
65
|
+
}
|
|
66
|
+
const _field = _sortedFieldMap.find(f => 'name' in field && 'name' in f && f.name === field.name);
|
|
67
|
+
const columnPreference = columnPreferences?.find(preference => field && 'name' in field && preference.accessor === field.name);
|
|
68
|
+
let active = false;
|
|
69
|
+
if (columnPreference) {
|
|
70
|
+
active = columnPreference.active;
|
|
71
|
+
} else if (columns && Array.isArray(columns) && columns.length > 0) {
|
|
72
|
+
active = columns.find(column => field && 'name' in field && column.accessor === field.name)?.active;
|
|
73
|
+
} else if (activeColumnsIndices.length < 4) {
|
|
74
|
+
active = true;
|
|
75
|
+
}
|
|
76
|
+
if (active && !activeColumnsIndices.includes(index)) {
|
|
77
|
+
activeColumnsIndices.push(index);
|
|
78
|
+
}
|
|
79
|
+
// const CustomLabelToRender =
|
|
80
|
+
// _field &&
|
|
81
|
+
// 'admin' in _field &&
|
|
82
|
+
// 'components' in _field.admin &&
|
|
83
|
+
// 'Label' in _field.admin.components &&
|
|
84
|
+
// _field.admin.components.Label !== undefined // let it return `null`
|
|
85
|
+
// ? _field.admin.components.Label
|
|
86
|
+
// : undefined
|
|
87
|
+
// // TODO: customComponent will be optional in v4
|
|
88
|
+
// const clientProps: Omit<ClientComponentProps, 'customComponents'> = {
|
|
89
|
+
// field,
|
|
90
|
+
// }
|
|
91
|
+
// const customLabelServerProps: Pick<
|
|
92
|
+
// ServerComponentProps,
|
|
93
|
+
// 'clientField' | 'collectionSlug' | 'field' | 'i18n' | 'payload'
|
|
94
|
+
// > = {
|
|
95
|
+
// clientField: field,
|
|
96
|
+
// collectionSlug: collectionConfig.slug,
|
|
97
|
+
// field: _field,
|
|
98
|
+
// i18n,
|
|
99
|
+
// payload,
|
|
100
|
+
// }
|
|
101
|
+
const CustomLabel = undefined;
|
|
102
|
+
const fieldAffectsDataSubFields = field && field.type && (field.type === 'array' || field.type === 'group' || field.type === 'blocks');
|
|
103
|
+
const Heading = /*#__PURE__*/_jsx(SortColumn, {
|
|
104
|
+
disable: fieldAffectsDataSubFields || fieldIsPresentationalOnly(field) || undefined,
|
|
105
|
+
Label: CustomLabel,
|
|
106
|
+
label: field && 'label' in field ? field.label : undefined,
|
|
107
|
+
name: 'name' in field ? field.name : undefined,
|
|
108
|
+
...(sortColumnProps || {})
|
|
109
|
+
});
|
|
110
|
+
const column = {
|
|
111
|
+
accessor: 'name' in field ? field.name : undefined,
|
|
112
|
+
active,
|
|
113
|
+
CustomLabel,
|
|
114
|
+
field,
|
|
115
|
+
Heading,
|
|
116
|
+
renderedCells: active ? docs.map((doc, i) => {
|
|
117
|
+
const isLinkedColumn = index === activeColumnsIndices[0];
|
|
118
|
+
const collectionSlug = doc.relationTo;
|
|
119
|
+
doc = doc.value;
|
|
120
|
+
const baseCellClientProps = {
|
|
121
|
+
cellData: undefined,
|
|
122
|
+
collectionSlug,
|
|
123
|
+
customCellProps,
|
|
124
|
+
field,
|
|
125
|
+
rowData: undefined
|
|
126
|
+
};
|
|
127
|
+
const cellClientProps = {
|
|
128
|
+
...baseCellClientProps,
|
|
129
|
+
cellData: 'name' in field ? doc[field.name] : undefined,
|
|
130
|
+
link: isLinkedColumn,
|
|
131
|
+
rowData: doc
|
|
132
|
+
};
|
|
133
|
+
const cellServerProps = {
|
|
134
|
+
cellData: cellClientProps.cellData,
|
|
135
|
+
className: baseCellClientProps.className,
|
|
136
|
+
collectionConfig: payload.collections[collectionSlug].config,
|
|
137
|
+
collectionSlug,
|
|
138
|
+
columnIndex: baseCellClientProps.columnIndex,
|
|
139
|
+
customCellProps: baseCellClientProps.customCellProps,
|
|
140
|
+
field: _field,
|
|
141
|
+
i18n,
|
|
142
|
+
link: cellClientProps.link,
|
|
143
|
+
onClick: baseCellClientProps.onClick,
|
|
144
|
+
payload,
|
|
145
|
+
rowData: doc
|
|
146
|
+
};
|
|
147
|
+
let CustomCell = null;
|
|
148
|
+
if (_field?.type === 'richText') {
|
|
149
|
+
if (!_field?.editor) {
|
|
150
|
+
throw new MissingEditorProp(_field) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor
|
|
151
|
+
;
|
|
152
|
+
}
|
|
153
|
+
if (typeof _field?.editor === 'function') {
|
|
154
|
+
throw new Error('Attempted to access unsanitized rich text editor.');
|
|
155
|
+
}
|
|
156
|
+
if (!_field.admin) {
|
|
157
|
+
_field.admin = {};
|
|
158
|
+
}
|
|
159
|
+
if (!_field.admin.components) {
|
|
160
|
+
_field.admin.components = {};
|
|
161
|
+
}
|
|
162
|
+
CustomCell = RenderServerComponent({
|
|
163
|
+
clientProps: cellClientProps,
|
|
164
|
+
Component: _field.editor.CellComponent,
|
|
165
|
+
importMap: payload.importMap,
|
|
166
|
+
serverProps: cellServerProps
|
|
167
|
+
});
|
|
168
|
+
} else {
|
|
169
|
+
const CustomCellComponent = _field?.admin?.components?.Cell;
|
|
170
|
+
if (CustomCellComponent) {
|
|
171
|
+
CustomCell = RenderServerComponent({
|
|
172
|
+
clientProps: cellClientProps,
|
|
173
|
+
Component: CustomCellComponent,
|
|
174
|
+
importMap: payload.importMap,
|
|
175
|
+
serverProps: cellServerProps
|
|
176
|
+
});
|
|
177
|
+
} else {
|
|
178
|
+
CustomCell = undefined;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return /*#__PURE__*/_jsx(RenderCustomComponent, {
|
|
182
|
+
CustomComponent: CustomCell,
|
|
183
|
+
Fallback: /*#__PURE__*/_jsx(RenderDefaultCell, {
|
|
184
|
+
clientProps: cellClientProps,
|
|
185
|
+
columnIndex: index,
|
|
186
|
+
enableRowSelections: enableRowSelections,
|
|
187
|
+
isLinkedColumn: isLinkedColumn
|
|
188
|
+
})
|
|
189
|
+
}, `${i}-${index}`);
|
|
190
|
+
}) : []
|
|
191
|
+
};
|
|
192
|
+
acc.push(column);
|
|
193
|
+
return acc;
|
|
194
|
+
}, []);
|
|
195
|
+
if (beforeRows) {
|
|
196
|
+
sorted.unshift(...beforeRows);
|
|
197
|
+
}
|
|
198
|
+
return sorted;
|
|
199
|
+
};
|
|
200
|
+
//# sourceMappingURL=buildPolymorphicColumnState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildPolymorphicColumnState.js","names":["MissingEditorProp","fieldIsHiddenOrDisabled","fieldIsID","fieldIsPresentationalOnly","flattenTopLevelFields","React","RenderCustomComponent","RenderDefaultCell","SortColumn","RenderServerComponent","filterFields","buildPolymorphicColumnState","args","beforeRows","columnPreferences","columns","customCellProps","docs","enableRowSelections","fields","i18n","payload","sortColumnProps","useAsTitle","sortedFieldMap","_sortedFieldMap","idFieldIndex","findIndex","field","idField","splice","unshift","useAsTitleFieldIndex","name","useAsTitleField","sortTo","sortFieldMap","fieldMap","sort","a","b","aIndex","column","accessor","bIndex","activeColumnsIndices","sorted","reduce","acc","index","_field","find","f","columnPreference","preference","active","Array","isArray","length","includes","push","CustomLabel","undefined","fieldAffectsDataSubFields","type","Heading","_jsx","disable","Label","label","renderedCells","map","doc","i","isLinkedColumn","collectionSlug","relationTo","value","baseCellClientProps","cellData","rowData","cellClientProps","link","cellServerProps","className","collectionConfig","collections","config","columnIndex","onClick","CustomCell","editor","Error","admin","components","clientProps","Component","CellComponent","importMap","serverProps","CustomCellComponent","Cell","CustomComponent","Fallback"],"sources":["../../../src/elements/TableColumns/buildPolymorphicColumnState.tsx"],"sourcesContent":["// Dirty copy of buildColumnState.tsx with some changes to not break things\n\nimport type { I18nClient } from '@payloadcms/translations'\nimport type {\n ClientField,\n Column,\n DefaultCellComponentProps,\n DefaultServerCellComponentProps,\n Field,\n ListPreferences,\n PaginatedDocs,\n Payload,\n SanitizedCollectionConfig,\n StaticLabel,\n} from 'payload'\n\nimport { MissingEditorProp } from 'payload'\nimport {\n fieldIsHiddenOrDisabled,\n fieldIsID,\n fieldIsPresentationalOnly,\n flattenTopLevelFields,\n} from 'payload/shared'\nimport React from 'react'\n\nimport type { SortColumnProps } from '../SortColumn/index.js'\n\nimport {\n RenderCustomComponent,\n RenderDefaultCell,\n SortColumn,\n // eslint-disable-next-line payload/no-imports-from-exports-dir\n} from '../../exports/client/index.js'\nimport { RenderServerComponent } from '../RenderServerComponent/index.js'\nimport { filterFields } from './filterFields.js'\n\ntype Args = {\n beforeRows?: Column[]\n columnPreferences: ListPreferences['columns']\n columns?: ListPreferences['columns']\n customCellProps: DefaultCellComponentProps['customCellProps']\n docs: PaginatedDocs['docs']\n enableRowSelections: boolean\n enableRowTypes?: boolean\n fields: ClientField[]\n i18n: I18nClient\n payload: Payload\n sortColumnProps?: Partial<SortColumnProps>\n useAsTitle: SanitizedCollectionConfig['admin']['useAsTitle']\n}\n\nexport const buildPolymorphicColumnState = (args: Args): Column[] => {\n const {\n beforeRows,\n columnPreferences,\n columns,\n customCellProps,\n docs,\n enableRowSelections,\n fields,\n i18n,\n payload,\n sortColumnProps,\n useAsTitle,\n } = args\n\n // clientFields contains the fake `id` column\n let sortedFieldMap = flattenTopLevelFields(filterFields(fields), true) as ClientField[]\n\n let _sortedFieldMap = flattenTopLevelFields(filterFields(fields), true) as Field[] // TODO: think of a way to avoid this additional flatten\n\n // place the `ID` field first, if it exists\n // do the same for the `useAsTitle` field with precedence over the `ID` field\n // then sort the rest of the fields based on the `defaultColumns` or `columnPreferences`\n const idFieldIndex = sortedFieldMap?.findIndex((field) => fieldIsID(field))\n\n if (idFieldIndex > -1) {\n const idField = sortedFieldMap.splice(idFieldIndex, 1)[0]\n sortedFieldMap.unshift(idField)\n }\n\n const useAsTitleFieldIndex = useAsTitle\n ? sortedFieldMap.findIndex((field) => 'name' in field && field.name === useAsTitle)\n : -1\n\n if (useAsTitleFieldIndex > -1) {\n const useAsTitleField = sortedFieldMap.splice(useAsTitleFieldIndex, 1)[0]\n sortedFieldMap.unshift(useAsTitleField)\n }\n\n const sortTo = columnPreferences || columns\n\n const sortFieldMap = (fieldMap, sortTo) =>\n fieldMap?.sort((a, b) => {\n const aIndex = sortTo.findIndex((column) => 'name' in a && column.accessor === a.name)\n const bIndex = sortTo.findIndex((column) => 'name' in b && column.accessor === b.name)\n\n if (aIndex === -1 && bIndex === -1) {\n return 0\n }\n\n if (aIndex === -1) {\n return 1\n }\n\n if (bIndex === -1) {\n return -1\n }\n\n return aIndex - bIndex\n })\n\n if (sortTo) {\n // sort the fields to the order of `defaultColumns` or `columnPreferences`\n sortedFieldMap = sortFieldMap(sortedFieldMap, sortTo)\n _sortedFieldMap = sortFieldMap(_sortedFieldMap, sortTo) // TODO: think of a way to avoid this additional sort\n }\n\n const activeColumnsIndices = []\n\n const sorted: Column[] = sortedFieldMap?.reduce((acc, field, index) => {\n if (fieldIsHiddenOrDisabled(field) && !fieldIsID(field)) {\n return acc\n }\n\n const _field = _sortedFieldMap.find(\n (f) => 'name' in field && 'name' in f && f.name === field.name,\n )\n\n const columnPreference = columnPreferences?.find(\n (preference) => field && 'name' in field && preference.accessor === field.name,\n )\n\n let active = false\n\n if (columnPreference) {\n active = columnPreference.active\n } else if (columns && Array.isArray(columns) && columns.length > 0) {\n active = columns.find(\n (column) => field && 'name' in field && column.accessor === field.name,\n )?.active\n } else if (activeColumnsIndices.length < 4) {\n active = true\n }\n\n if (active && !activeColumnsIndices.includes(index)) {\n activeColumnsIndices.push(index)\n }\n\n // const CustomLabelToRender =\n // _field &&\n // 'admin' in _field &&\n // 'components' in _field.admin &&\n // 'Label' in _field.admin.components &&\n // _field.admin.components.Label !== undefined // let it return `null`\n // ? _field.admin.components.Label\n // : undefined\n\n // // TODO: customComponent will be optional in v4\n // const clientProps: Omit<ClientComponentProps, 'customComponents'> = {\n // field,\n // }\n\n // const customLabelServerProps: Pick<\n // ServerComponentProps,\n // 'clientField' | 'collectionSlug' | 'field' | 'i18n' | 'payload'\n // > = {\n // clientField: field,\n // collectionSlug: collectionConfig.slug,\n // field: _field,\n // i18n,\n // payload,\n // }\n\n const CustomLabel = undefined\n\n const fieldAffectsDataSubFields =\n field &&\n field.type &&\n (field.type === 'array' || field.type === 'group' || field.type === 'blocks')\n\n const Heading = (\n <SortColumn\n disable={fieldAffectsDataSubFields || fieldIsPresentationalOnly(field) || undefined}\n Label={CustomLabel}\n label={field && 'label' in field ? (field.label as StaticLabel) : undefined}\n name={'name' in field ? field.name : undefined}\n {...(sortColumnProps || {})}\n />\n )\n\n const column: Column = {\n accessor: 'name' in field ? field.name : undefined,\n active,\n CustomLabel,\n field,\n Heading,\n renderedCells: active\n ? docs.map((doc, i) => {\n const isLinkedColumn = index === activeColumnsIndices[0]\n\n const collectionSlug = doc.relationTo\n doc = doc.value\n\n const baseCellClientProps: DefaultCellComponentProps = {\n cellData: undefined,\n collectionSlug,\n customCellProps,\n field,\n rowData: undefined,\n }\n\n const cellClientProps: DefaultCellComponentProps = {\n ...baseCellClientProps,\n cellData: 'name' in field ? doc[field.name] : undefined,\n link: isLinkedColumn,\n rowData: doc,\n }\n\n const cellServerProps: DefaultServerCellComponentProps = {\n cellData: cellClientProps.cellData,\n className: baseCellClientProps.className,\n collectionConfig: payload.collections[collectionSlug].config,\n collectionSlug,\n columnIndex: baseCellClientProps.columnIndex,\n customCellProps: baseCellClientProps.customCellProps,\n field: _field,\n i18n,\n link: cellClientProps.link,\n onClick: baseCellClientProps.onClick,\n payload,\n rowData: doc,\n }\n\n let CustomCell = null\n\n if (_field?.type === 'richText') {\n if (!_field?.editor) {\n throw new MissingEditorProp(_field) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n\n if (typeof _field?.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n\n if (!_field.admin) {\n _field.admin = {}\n }\n\n if (!_field.admin.components) {\n _field.admin.components = {}\n }\n\n CustomCell = RenderServerComponent({\n clientProps: cellClientProps,\n Component: _field.editor.CellComponent,\n importMap: payload.importMap,\n serverProps: cellServerProps,\n })\n } else {\n const CustomCellComponent = _field?.admin?.components?.Cell\n\n if (CustomCellComponent) {\n CustomCell = RenderServerComponent({\n clientProps: cellClientProps,\n Component: CustomCellComponent,\n importMap: payload.importMap,\n serverProps: cellServerProps,\n })\n } else {\n CustomCell = undefined\n }\n }\n\n return (\n <RenderCustomComponent\n CustomComponent={CustomCell}\n Fallback={\n <RenderDefaultCell\n clientProps={cellClientProps}\n columnIndex={index}\n enableRowSelections={enableRowSelections}\n isLinkedColumn={isLinkedColumn}\n />\n }\n key={`${i}-${index}`}\n />\n )\n })\n : [],\n }\n\n acc.push(column)\n\n return acc\n }, [])\n\n if (beforeRows) {\n sorted.unshift(...beforeRows)\n }\n\n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A,EAAgBA;;WAGf,GAAGD,CAAA,IAAKxB,KAAA,EAAO;MAG1B,KACA;IACN;IAEAD,GAAA,CAAIY,IAAI,CAAClB,MAAA;IAET,OAAOM,GAAA;EACT,GAAG,EAAE;EAEL,IAAInC,UAAA,EAAY;IACdiC,MAAA,CAAOf,OAAO,IAAIlB,UAAA;EACpB;EAEA,OAAOiC,MAAA;AACT","ignoreList":[]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { ListPreferences } from 'payload';
|
|
1
|
+
import type { Column, ListPreferences } from 'payload';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import type { SortColumnProps } from '../SortColumn/index.js';
|
|
4
|
-
import type { Column } from '../Table/index.js';
|
|
5
4
|
export interface ITableColumns {
|
|
6
5
|
columns: Column[];
|
|
7
6
|
LinkedCellOverride?: React.ReactNode;
|
|
@@ -17,7 +16,7 @@ export declare const TableColumnContext: React.Context<ITableColumns>;
|
|
|
17
16
|
export declare const useTableColumns: () => ITableColumns;
|
|
18
17
|
type Props = {
|
|
19
18
|
readonly children: React.ReactNode;
|
|
20
|
-
readonly collectionSlug: string;
|
|
19
|
+
readonly collectionSlug: string | string[];
|
|
21
20
|
readonly columnState: Column[];
|
|
22
21
|
readonly docs: any[];
|
|
23
22
|
readonly enableRowSelections?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/TableColumns/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/TableColumns/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAA6B,MAAM,SAAS,CAAA;AAEjF,OAAO,KAA4D,MAAM,OAAO,CAAA;AAEhF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAO7D,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,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