@payloadcms/ui 4.0.0-canary.4 → 4.0.0-canary.5
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/ArrayAction/index.d.ts.map +1 -1
- package/dist/elements/ArrayAction/index.js +1 -0
- package/dist/elements/ArrayAction/index.js.map +1 -1
- package/dist/elements/Button/index.d.ts.map +1 -1
- package/dist/elements/Button/index.js +5 -0
- package/dist/elements/Button/index.js.map +1 -1
- package/dist/elements/ClipboardAction/index.d.ts.map +1 -1
- package/dist/elements/ClipboardAction/index.js +1 -0
- package/dist/elements/ClipboardAction/index.js.map +1 -1
- package/dist/elements/Collapsible/index.d.ts.map +1 -1
- package/dist/elements/Collapsible/index.js +2 -0
- package/dist/elements/Collapsible/index.js.map +1 -1
- package/dist/elements/DocumentControls/index.d.ts.map +1 -1
- package/dist/elements/DocumentControls/index.js +1 -0
- package/dist/elements/DocumentControls/index.js.map +1 -1
- package/dist/elements/Popup/PopupTrigger/index.d.ts +1 -0
- package/dist/elements/Popup/PopupTrigger/index.d.ts.map +1 -1
- package/dist/elements/Popup/PopupTrigger/index.js +3 -0
- package/dist/elements/Popup/PopupTrigger/index.js.map +1 -1
- package/dist/elements/Popup/index.d.ts +6 -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/ReactSelect/DropdownIndicator/index.d.ts.map +1 -1
- package/dist/elements/ReactSelect/DropdownIndicator/index.js +19 -12
- package/dist/elements/ReactSelect/DropdownIndicator/index.js.map +1 -1
- package/dist/elements/ReactSelect/types.d.ts +1 -0
- package/dist/elements/ReactSelect/types.d.ts.map +1 -1
- package/dist/elements/ReactSelect/types.js.map +1 -1
- package/dist/exports/client/index.d.ts +1 -0
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +13 -13
- package/dist/exports/client/index.js.map +4 -4
- package/dist/exports/rsc/index.d.ts +1 -0
- package/dist/exports/rsc/index.d.ts.map +1 -1
- package/dist/exports/rsc/index.js +1 -0
- package/dist/exports/rsc/index.js.map +1 -1
- package/dist/fields/Blocks/SectionTitle/index.d.ts.map +1 -1
- package/dist/fields/Blocks/SectionTitle/index.js +1 -0
- package/dist/fields/Blocks/SectionTitle/index.js.map +1 -1
- package/dist/fields/Relationship/Input.d.ts.map +1 -1
- package/dist/fields/Relationship/Input.js +2 -0
- package/dist/fields/Relationship/Input.js.map +1 -1
- package/dist/fields/Select/Input.d.ts.map +1 -1
- package/dist/fields/Select/Input.js +1 -0
- package/dist/fields/Select/Input.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/WidgetConfigDrawer.d.ts.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/WidgetConfigDrawer.js +27 -23
- package/dist/views/Dashboard/Default/ModularDashboard/WidgetConfigDrawer.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/index.css +2 -0
- package/dist/views/Version/SelectComparison/index.d.ts.map +1 -1
- package/dist/views/Version/SelectComparison/index.js +1 -0
- package/dist/views/Version/SelectComparison/index.js.map +1 -1
- package/dist/widgets/CollectionQuery/SortField/index.d.ts +3 -0
- package/dist/widgets/CollectionQuery/SortField/index.d.ts.map +1 -0
- package/dist/widgets/CollectionQuery/SortField/index.js +118 -0
- package/dist/widgets/CollectionQuery/SortField/index.js.map +1 -0
- package/dist/widgets/CollectionQuery/getCollectionFieldPaths.d.ts +18 -0
- package/dist/widgets/CollectionQuery/getCollectionFieldPaths.d.ts.map +1 -0
- package/dist/widgets/CollectionQuery/getCollectionFieldPaths.js +91 -0
- package/dist/widgets/CollectionQuery/getCollectionFieldPaths.js.map +1 -0
- package/dist/widgets/CollectionQuery/getCollectionFieldPaths.spec.js +100 -0
- package/dist/widgets/CollectionQuery/getCollectionFieldPaths.spec.js.map +1 -0
- package/dist/widgets/CollectionQuery/index.css +206 -0
- package/dist/widgets/CollectionQuery/index.d.ts +17 -0
- package/dist/widgets/CollectionQuery/index.d.ts.map +1 -0
- package/dist/widgets/CollectionQuery/index.js +399 -0
- package/dist/widgets/CollectionQuery/index.js.map +1 -0
- package/package.json +5 -5
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { getTranslation } from '@payloadcms/translations';
|
|
3
|
+
import { formatAdminURL } from 'payload/shared';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import '../../elements/Card/index.css';
|
|
6
|
+
import './index.css';
|
|
7
|
+
import { getCollectionFieldPaths } from './getCollectionFieldPaths.js';
|
|
8
|
+
const minLimit = 1;
|
|
9
|
+
const maxLimit = 25;
|
|
10
|
+
const emptyFieldPaths = {
|
|
11
|
+
filterableFieldPaths: new Set(),
|
|
12
|
+
relationshipFieldPaths: new Set(),
|
|
13
|
+
sortableFieldPaths: new Set()
|
|
14
|
+
};
|
|
15
|
+
export async function CollectionQueryWidget({
|
|
16
|
+
req,
|
|
17
|
+
widgetData
|
|
18
|
+
}) {
|
|
19
|
+
const {
|
|
20
|
+
i18n,
|
|
21
|
+
payload,
|
|
22
|
+
user
|
|
23
|
+
} = req;
|
|
24
|
+
const {
|
|
25
|
+
relatedCollection,
|
|
26
|
+
sortDirection = 'desc',
|
|
27
|
+
sortField,
|
|
28
|
+
title: titleFromData,
|
|
29
|
+
where
|
|
30
|
+
} = widgetData ?? {};
|
|
31
|
+
const limit = clampLimit(widgetData?.limit);
|
|
32
|
+
const collectionConfig = relatedCollection ? payload.collections[relatedCollection]?.config : undefined;
|
|
33
|
+
const title = titleFromData || (collectionConfig ? getTranslation(collectionConfig.labels.plural, i18n) : i18n.t('dashboard:widgetTitleFallback'));
|
|
34
|
+
const fieldPaths = collectionConfig ? getCollectionFieldPaths(collectionConfig.fields) : emptyFieldPaths;
|
|
35
|
+
const validationErrors = getValidationErrors({
|
|
36
|
+
collectionConfig,
|
|
37
|
+
fieldPaths,
|
|
38
|
+
i18n,
|
|
39
|
+
relatedCollection,
|
|
40
|
+
sortField,
|
|
41
|
+
where
|
|
42
|
+
});
|
|
43
|
+
if (validationErrors.length > 0 || !relatedCollection || !collectionConfig) {
|
|
44
|
+
return /*#__PURE__*/_jsx(CollectionQueryError, {
|
|
45
|
+
errors: validationErrors,
|
|
46
|
+
i18n: i18n,
|
|
47
|
+
title: title
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
const sort = sortField ? `${sortDirection === 'desc' ? '-' : ''}${sortField}` : undefined;
|
|
51
|
+
const adminRoute = payload.config.routes.admin;
|
|
52
|
+
let docs;
|
|
53
|
+
try {
|
|
54
|
+
const result = await payload.find({
|
|
55
|
+
collection: relatedCollection,
|
|
56
|
+
depth: 0,
|
|
57
|
+
limit,
|
|
58
|
+
overrideAccess: false,
|
|
59
|
+
sort,
|
|
60
|
+
user,
|
|
61
|
+
where
|
|
62
|
+
});
|
|
63
|
+
docs = result.docs;
|
|
64
|
+
} catch (err) {
|
|
65
|
+
payload.logger.error({
|
|
66
|
+
err,
|
|
67
|
+
msg: `CollectionQueryWidget: failed to query collection "${relatedCollection}"`
|
|
68
|
+
});
|
|
69
|
+
return /*#__PURE__*/_jsx(CollectionQueryError, {
|
|
70
|
+
errors: [i18n.t('dashboard:widgetQueryError')],
|
|
71
|
+
i18n: i18n,
|
|
72
|
+
title: title
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
const documentLabelPath = getCollectionDocumentLabelPath(collectionConfig.admin);
|
|
76
|
+
const relativeTimeFormat = getRelativeTimeFormat(i18n.language);
|
|
77
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
78
|
+
className: "card collection-query-widget",
|
|
79
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
80
|
+
className: "collection-query-widget__header",
|
|
81
|
+
children: /*#__PURE__*/_jsx("h3", {
|
|
82
|
+
className: "collection-query-widget__title",
|
|
83
|
+
children: title
|
|
84
|
+
})
|
|
85
|
+
}), docs.length > 0 ? /*#__PURE__*/_jsx("ul", {
|
|
86
|
+
className: "collection-query-widget__rows",
|
|
87
|
+
children: docs.map(doc => {
|
|
88
|
+
const sortMeta = getDocSortMeta({
|
|
89
|
+
doc,
|
|
90
|
+
i18n,
|
|
91
|
+
relativeTimeFormat,
|
|
92
|
+
sortField
|
|
93
|
+
});
|
|
94
|
+
return /*#__PURE__*/_jsx("li", {
|
|
95
|
+
className: "collection-query-widget__row",
|
|
96
|
+
children: /*#__PURE__*/_jsxs("a", {
|
|
97
|
+
className: "collection-query-widget__row-link",
|
|
98
|
+
href: getDocumentHref({
|
|
99
|
+
id: doc.id,
|
|
100
|
+
adminRoute,
|
|
101
|
+
collectionSlug: relatedCollection
|
|
102
|
+
}),
|
|
103
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
104
|
+
className: "collection-query-widget__row-main",
|
|
105
|
+
children: /*#__PURE__*/_jsx("span", {
|
|
106
|
+
className: "collection-query-widget__row-title",
|
|
107
|
+
children: getDocLabel({
|
|
108
|
+
doc,
|
|
109
|
+
documentLabelPath
|
|
110
|
+
})
|
|
111
|
+
})
|
|
112
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
113
|
+
className: "collection-query-widget__row-meta",
|
|
114
|
+
children: sortMeta ? sortMeta.dateTime ? /*#__PURE__*/_jsx("time", {
|
|
115
|
+
dateTime: sortMeta.dateTime,
|
|
116
|
+
children: sortMeta.label
|
|
117
|
+
}) : sortMeta.label : null
|
|
118
|
+
})]
|
|
119
|
+
})
|
|
120
|
+
}, doc.id);
|
|
121
|
+
})
|
|
122
|
+
}) : /*#__PURE__*/_jsx("p", {
|
|
123
|
+
className: "collection-query-widget__empty",
|
|
124
|
+
children: i18n.t('general:noResultsFound')
|
|
125
|
+
})]
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
function CollectionQueryError({
|
|
129
|
+
errors,
|
|
130
|
+
i18n,
|
|
131
|
+
title
|
|
132
|
+
}) {
|
|
133
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
134
|
+
className: "card collection-query-widget collection-query-widget--error",
|
|
135
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
136
|
+
className: "collection-query-widget__header",
|
|
137
|
+
children: /*#__PURE__*/_jsx("h3", {
|
|
138
|
+
className: "collection-query-widget__title",
|
|
139
|
+
children: title
|
|
140
|
+
})
|
|
141
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
142
|
+
className: "collection-query-widget__error",
|
|
143
|
+
children: [/*#__PURE__*/_jsx("p", {
|
|
144
|
+
className: "collection-query-widget__error-title",
|
|
145
|
+
children: i18n.t('dashboard:widgetConfigurationError')
|
|
146
|
+
}), /*#__PURE__*/_jsx("ul", {
|
|
147
|
+
className: "collection-query-widget__error-list",
|
|
148
|
+
children: errors.map(error => /*#__PURE__*/_jsx("li", {
|
|
149
|
+
children: error
|
|
150
|
+
}, error))
|
|
151
|
+
})]
|
|
152
|
+
})]
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
function clampLimit(limit) {
|
|
156
|
+
if (typeof limit !== 'number' || Number.isNaN(limit)) {
|
|
157
|
+
return 5;
|
|
158
|
+
}
|
|
159
|
+
return Math.min(Math.max(Math.floor(limit), minLimit), maxLimit);
|
|
160
|
+
}
|
|
161
|
+
function getCollectionDocumentLabelPath(adminConfig) {
|
|
162
|
+
return adminConfig.useAsTitle || 'id';
|
|
163
|
+
}
|
|
164
|
+
function getDocSortMeta({
|
|
165
|
+
doc,
|
|
166
|
+
i18n,
|
|
167
|
+
relativeTimeFormat,
|
|
168
|
+
sortField
|
|
169
|
+
}) {
|
|
170
|
+
const value = sortField ? getValueByPath({
|
|
171
|
+
object: doc,
|
|
172
|
+
path: sortField
|
|
173
|
+
}) : doc.updatedAt || doc.createdAt;
|
|
174
|
+
if (value === null || typeof value === 'undefined' || value === '') {
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
if (value instanceof Date) {
|
|
178
|
+
const dateTime = value.toISOString();
|
|
179
|
+
return {
|
|
180
|
+
dateTime,
|
|
181
|
+
label: formatRelativeDate({
|
|
182
|
+
relativeTimeFormat,
|
|
183
|
+
value: dateTime
|
|
184
|
+
})
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
if (typeof value === 'string') {
|
|
188
|
+
if (isDateString(value)) {
|
|
189
|
+
return {
|
|
190
|
+
dateTime: value,
|
|
191
|
+
label: formatRelativeDate({
|
|
192
|
+
relativeTimeFormat,
|
|
193
|
+
value
|
|
194
|
+
})
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
return {
|
|
198
|
+
label: value
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
if (typeof value === 'number') {
|
|
202
|
+
return {
|
|
203
|
+
label: value.toLocaleString(i18n.language)
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
if (typeof value === 'boolean') {
|
|
207
|
+
return {
|
|
208
|
+
label: value ? i18n.t('general:true') : i18n.t('general:false')
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
function getDocLabel({
|
|
214
|
+
doc,
|
|
215
|
+
documentLabelPath
|
|
216
|
+
}) {
|
|
217
|
+
const title = getValueByPath({
|
|
218
|
+
object: doc,
|
|
219
|
+
path: documentLabelPath
|
|
220
|
+
});
|
|
221
|
+
return typeof title === 'string' && title ? title : String(doc.id);
|
|
222
|
+
}
|
|
223
|
+
function getValidationErrors({
|
|
224
|
+
collectionConfig,
|
|
225
|
+
fieldPaths,
|
|
226
|
+
i18n,
|
|
227
|
+
relatedCollection,
|
|
228
|
+
sortField,
|
|
229
|
+
where
|
|
230
|
+
}) {
|
|
231
|
+
const errors = [];
|
|
232
|
+
if (!relatedCollection) {
|
|
233
|
+
errors.push(i18n.t('dashboard:widgetCollectionRequired'));
|
|
234
|
+
return errors;
|
|
235
|
+
}
|
|
236
|
+
if (!collectionConfig) {
|
|
237
|
+
errors.push(i18n.t('dashboard:widgetInvalidCollection', {
|
|
238
|
+
collection: relatedCollection
|
|
239
|
+
}));
|
|
240
|
+
return errors;
|
|
241
|
+
}
|
|
242
|
+
if (sortField) {
|
|
243
|
+
if (!fieldPaths.filterableFieldPaths.has(sortField)) {
|
|
244
|
+
errors.push(i18n.t('dashboard:widgetInvalidSortField', {
|
|
245
|
+
collection: relatedCollection,
|
|
246
|
+
field: sortField
|
|
247
|
+
}));
|
|
248
|
+
} else if (!fieldPaths.sortableFieldPaths.has(sortField)) {
|
|
249
|
+
errors.push(i18n.t('dashboard:widgetNonSortableSortField', {
|
|
250
|
+
collection: relatedCollection,
|
|
251
|
+
field: sortField
|
|
252
|
+
}));
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
for (const fieldPath of getWhereFieldPaths(where)) {
|
|
256
|
+
if (fieldPaths.filterableFieldPaths.has(fieldPath) || hasRelationshipAncestor({
|
|
257
|
+
path: fieldPath,
|
|
258
|
+
relationshipFieldPaths: fieldPaths.relationshipFieldPaths
|
|
259
|
+
})) {
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
errors.push(i18n.t('dashboard:widgetInvalidFilterField', {
|
|
263
|
+
collection: relatedCollection,
|
|
264
|
+
field: fieldPath
|
|
265
|
+
}));
|
|
266
|
+
}
|
|
267
|
+
return errors;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* A `where` path that traverses into a relationship (e.g. `category.name`) cannot be validated
|
|
271
|
+
* against this collection's fields because it targets another collection, so accept it when any
|
|
272
|
+
* ancestor segment is a relationship.
|
|
273
|
+
*/
|
|
274
|
+
function hasRelationshipAncestor({
|
|
275
|
+
path,
|
|
276
|
+
relationshipFieldPaths
|
|
277
|
+
}) {
|
|
278
|
+
const segments = path.split('.');
|
|
279
|
+
let prefix = '';
|
|
280
|
+
for (const segment of segments) {
|
|
281
|
+
prefix = prefix ? `${prefix}.${segment}` : segment;
|
|
282
|
+
if (relationshipFieldPaths.has(prefix)) {
|
|
283
|
+
return true;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return false;
|
|
287
|
+
}
|
|
288
|
+
function getWhereFieldPaths(where) {
|
|
289
|
+
const fieldPaths = new Set();
|
|
290
|
+
collectWhereFieldPaths({
|
|
291
|
+
fieldPaths,
|
|
292
|
+
value: where
|
|
293
|
+
});
|
|
294
|
+
return fieldPaths;
|
|
295
|
+
}
|
|
296
|
+
function collectWhereFieldPaths({
|
|
297
|
+
fieldPaths,
|
|
298
|
+
value
|
|
299
|
+
}) {
|
|
300
|
+
if (!value || typeof value !== 'object') {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
if (Array.isArray(value)) {
|
|
304
|
+
for (const item of value) {
|
|
305
|
+
collectWhereFieldPaths({
|
|
306
|
+
fieldPaths,
|
|
307
|
+
value: item
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
for (const [key, childValue] of Object.entries(value)) {
|
|
313
|
+
if (key === 'and' || key === 'or') {
|
|
314
|
+
collectWhereFieldPaths({
|
|
315
|
+
fieldPaths,
|
|
316
|
+
value: childValue
|
|
317
|
+
});
|
|
318
|
+
continue;
|
|
319
|
+
}
|
|
320
|
+
fieldPaths.add(key);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
function getDocumentHref({
|
|
324
|
+
id,
|
|
325
|
+
adminRoute,
|
|
326
|
+
collectionSlug
|
|
327
|
+
}) {
|
|
328
|
+
return formatAdminURL({
|
|
329
|
+
adminRoute,
|
|
330
|
+
path: `/collections/${collectionSlug}/${id}`
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
function getValueByPath({
|
|
334
|
+
object,
|
|
335
|
+
path
|
|
336
|
+
}) {
|
|
337
|
+
return path.split('.').reduce((value, segment) => {
|
|
338
|
+
if (!value || typeof value !== 'object') {
|
|
339
|
+
return undefined;
|
|
340
|
+
}
|
|
341
|
+
return value[segment];
|
|
342
|
+
}, object);
|
|
343
|
+
}
|
|
344
|
+
function getRelativeTimeFormat(language) {
|
|
345
|
+
try {
|
|
346
|
+
return new Intl.RelativeTimeFormat(language, {
|
|
347
|
+
numeric: 'auto',
|
|
348
|
+
style: 'narrow'
|
|
349
|
+
});
|
|
350
|
+
} catch {
|
|
351
|
+
return new Intl.RelativeTimeFormat('en', {
|
|
352
|
+
numeric: 'auto',
|
|
353
|
+
style: 'narrow'
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
const relativeTimeDivisions = [{
|
|
358
|
+
amount: 60,
|
|
359
|
+
unit: 'seconds'
|
|
360
|
+
}, {
|
|
361
|
+
amount: 60,
|
|
362
|
+
unit: 'minutes'
|
|
363
|
+
}, {
|
|
364
|
+
amount: 24,
|
|
365
|
+
unit: 'hours'
|
|
366
|
+
}, {
|
|
367
|
+
amount: 7,
|
|
368
|
+
unit: 'days'
|
|
369
|
+
}, {
|
|
370
|
+
amount: 4.34524,
|
|
371
|
+
unit: 'weeks'
|
|
372
|
+
}, {
|
|
373
|
+
amount: 12,
|
|
374
|
+
unit: 'months'
|
|
375
|
+
}, {
|
|
376
|
+
amount: Number.POSITIVE_INFINITY,
|
|
377
|
+
unit: 'years'
|
|
378
|
+
}];
|
|
379
|
+
function formatRelativeDate({
|
|
380
|
+
relativeTimeFormat,
|
|
381
|
+
value
|
|
382
|
+
}) {
|
|
383
|
+
const date = new Date(value);
|
|
384
|
+
if (Number.isNaN(date.getTime())) {
|
|
385
|
+
return value;
|
|
386
|
+
}
|
|
387
|
+
let duration = (date.getTime() - Date.now()) / 1000;
|
|
388
|
+
for (const division of relativeTimeDivisions) {
|
|
389
|
+
if (Math.abs(duration) < division.amount) {
|
|
390
|
+
return relativeTimeFormat.format(Math.round(duration), division.unit);
|
|
391
|
+
}
|
|
392
|
+
duration /= division.amount;
|
|
393
|
+
}
|
|
394
|
+
return relativeTimeFormat.format(Math.round(duration), 'years');
|
|
395
|
+
}
|
|
396
|
+
function isDateString(value) {
|
|
397
|
+
return /^\d{4}-\d{2}-\d{2}/.test(value) && !Number.isNaN(new Date(value).getTime());
|
|
398
|
+
}
|
|
399
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["getTranslation","formatAdminURL","React","getCollectionFieldPaths","minLimit","maxLimit","emptyFieldPaths","filterableFieldPaths","Set","relationshipFieldPaths","sortableFieldPaths","CollectionQueryWidget","req","widgetData","i18n","payload","user","relatedCollection","sortDirection","sortField","title","titleFromData","where","limit","clampLimit","collectionConfig","collections","config","undefined","labels","plural","t","fieldPaths","fields","validationErrors","getValidationErrors","length","_jsx","CollectionQueryError","errors","sort","adminRoute","routes","admin","docs","result","find","collection","depth","overrideAccess","err","logger","error","msg","documentLabelPath","getCollectionDocumentLabelPath","relativeTimeFormat","getRelativeTimeFormat","language","_jsxs","className","map","doc","sortMeta","getDocSortMeta","href","getDocumentHref","id","collectionSlug","getDocLabel","dateTime","label","Number","isNaN","Math","min","max","floor","adminConfig","useAsTitle","value","getValueByPath","object","path","updatedAt","createdAt","Date","toISOString","formatRelativeDate","isDateString","toLocaleString","String","push","has","field","fieldPath","getWhereFieldPaths","hasRelationshipAncestor","segments","split","prefix","segment","collectWhereFieldPaths","Array","isArray","item","key","childValue","Object","entries","add","reduce","Intl","RelativeTimeFormat","numeric","style","relativeTimeDivisions","amount","unit","POSITIVE_INFINITY","date","getTime","duration","now","division","abs","format","round","test"],"sources":["../../../src/widgets/CollectionQuery/index.tsx"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { CollectionSlug, Where, WidgetServerProps } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { formatAdminURL } from 'payload/shared'\nimport React from 'react'\n\nimport type { CollectionFieldPaths } from './getCollectionFieldPaths.js'\n\nimport '../../elements/Card/index.css'\nimport './index.css'\nimport { getCollectionFieldPaths } from './getCollectionFieldPaths.js'\n\ntype CollectionQueryWidgetData = {\n limit?: number\n relatedCollection?: CollectionSlug\n sortDirection?: 'asc' | 'desc'\n sortField?: string\n title?: string\n where?: Where\n}\n\ntype QueryDoc = {\n createdAt?: string\n id: number | string\n updatedAt?: string\n} & Record<string, unknown>\n\nconst minLimit = 1\nconst maxLimit = 25\n\nconst emptyFieldPaths: CollectionFieldPaths = {\n filterableFieldPaths: new Set<string>(),\n relationshipFieldPaths: new Set<string>(),\n sortableFieldPaths: new Set<string>(),\n}\n\nexport async function CollectionQueryWidget({\n req,\n widgetData,\n}: WidgetServerProps<{ data?: CollectionQueryWidgetData }>) {\n const { i18n, payload, user } = req\n const {\n relatedCollection,\n sortDirection = 'desc',\n sortField,\n title: titleFromData,\n where,\n } = widgetData ?? {}\n const limit = clampLimit(widgetData?.limit)\n const collectionConfig = relatedCollection\n ? payload.collections[relatedCollection]?.config\n : undefined\n\n const title =\n titleFromData ||\n (collectionConfig\n ? getTranslation(collectionConfig.labels.plural, i18n)\n : i18n.t('dashboard:widgetTitleFallback'))\n\n const fieldPaths = collectionConfig\n ? getCollectionFieldPaths(collectionConfig.fields)\n : emptyFieldPaths\n const validationErrors = getValidationErrors({\n collectionConfig,\n fieldPaths,\n i18n,\n relatedCollection,\n sortField,\n where,\n })\n\n if (validationErrors.length > 0 || !relatedCollection || !collectionConfig) {\n return <CollectionQueryError errors={validationErrors} i18n={i18n} title={title} />\n }\n\n const sort = sortField ? `${sortDirection === 'desc' ? '-' : ''}${sortField}` : undefined\n const adminRoute = payload.config.routes.admin\n\n let docs: QueryDoc[]\n\n try {\n const result = await payload.find({\n collection: relatedCollection,\n depth: 0,\n limit,\n overrideAccess: false,\n sort,\n user,\n where,\n })\n\n docs = result.docs as QueryDoc[]\n } catch (err) {\n payload.logger.error({\n err,\n msg: `CollectionQueryWidget: failed to query collection \"${relatedCollection}\"`,\n })\n\n return (\n <CollectionQueryError\n errors={[i18n.t('dashboard:widgetQueryError')]}\n i18n={i18n}\n title={title}\n />\n )\n }\n\n const documentLabelPath = getCollectionDocumentLabelPath(collectionConfig.admin)\n const relativeTimeFormat = getRelativeTimeFormat(i18n.language)\n\n return (\n <div className=\"card collection-query-widget\">\n <div className=\"collection-query-widget__header\">\n <h3 className=\"collection-query-widget__title\">{title}</h3>\n </div>\n {docs.length > 0 ? (\n <ul className=\"collection-query-widget__rows\">\n {docs.map((doc) => {\n const sortMeta = getDocSortMeta({ doc, i18n, relativeTimeFormat, sortField })\n\n return (\n <li className=\"collection-query-widget__row\" key={doc.id}>\n <a\n className=\"collection-query-widget__row-link\"\n href={getDocumentHref({\n id: doc.id,\n adminRoute,\n collectionSlug: relatedCollection,\n })}\n >\n <span className=\"collection-query-widget__row-main\">\n <span className=\"collection-query-widget__row-title\">\n {getDocLabel({ doc, documentLabelPath })}\n </span>\n </span>\n <span className=\"collection-query-widget__row-meta\">\n {sortMeta ? (\n sortMeta.dateTime ? (\n <time dateTime={sortMeta.dateTime}>{sortMeta.label}</time>\n ) : (\n sortMeta.label\n )\n ) : null}\n </span>\n </a>\n </li>\n )\n })}\n </ul>\n ) : (\n <p className=\"collection-query-widget__empty\">{i18n.t('general:noResultsFound')}</p>\n )}\n </div>\n )\n}\n\nfunction CollectionQueryError({\n errors,\n i18n,\n title,\n}: {\n errors: string[]\n i18n: I18n\n title: string\n}) {\n return (\n <div className=\"card collection-query-widget collection-query-widget--error\">\n <div className=\"collection-query-widget__header\">\n <h3 className=\"collection-query-widget__title\">{title}</h3>\n </div>\n <div className=\"collection-query-widget__error\">\n <p className=\"collection-query-widget__error-title\">\n {i18n.t('dashboard:widgetConfigurationError')}\n </p>\n <ul className=\"collection-query-widget__error-list\">\n {errors.map((error) => (\n <li key={error}>{error}</li>\n ))}\n </ul>\n </div>\n </div>\n )\n}\n\nfunction clampLimit(limit: number | undefined) {\n if (typeof limit !== 'number' || Number.isNaN(limit)) {\n return 5\n }\n\n return Math.min(Math.max(Math.floor(limit), minLimit), maxLimit)\n}\n\nfunction getCollectionDocumentLabelPath(adminConfig: { useAsTitle?: string }) {\n return adminConfig.useAsTitle || 'id'\n}\n\nfunction getDocSortMeta({\n doc,\n i18n,\n relativeTimeFormat,\n sortField,\n}: {\n doc: QueryDoc\n i18n: I18n\n relativeTimeFormat: Intl.RelativeTimeFormat\n sortField?: string\n}) {\n const value = sortField\n ? getValueByPath({ object: doc, path: sortField })\n : doc.updatedAt || doc.createdAt\n\n if (value === null || typeof value === 'undefined' || value === '') {\n return null\n }\n\n if (value instanceof Date) {\n const dateTime = value.toISOString()\n\n return {\n dateTime,\n label: formatRelativeDate({ relativeTimeFormat, value: dateTime }),\n }\n }\n\n if (typeof value === 'string') {\n if (isDateString(value)) {\n return {\n dateTime: value,\n label: formatRelativeDate({ relativeTimeFormat, value }),\n }\n }\n\n return { label: value }\n }\n\n if (typeof value === 'number') {\n return { label: value.toLocaleString(i18n.language) }\n }\n\n if (typeof value === 'boolean') {\n return { label: value ? i18n.t('general:true') : i18n.t('general:false') }\n }\n\n return null\n}\n\nfunction getDocLabel({ doc, documentLabelPath }: { doc: QueryDoc; documentLabelPath: string }) {\n const title = getValueByPath({ object: doc, path: documentLabelPath })\n\n return typeof title === 'string' && title ? title : String(doc.id)\n}\n\nfunction getValidationErrors({\n collectionConfig,\n fieldPaths,\n i18n,\n relatedCollection,\n sortField,\n where,\n}: {\n collectionConfig: unknown\n fieldPaths: CollectionFieldPaths\n i18n: I18n\n relatedCollection?: CollectionSlug\n sortField?: string\n where?: Where\n}) {\n const errors: string[] = []\n\n if (!relatedCollection) {\n errors.push(i18n.t('dashboard:widgetCollectionRequired'))\n\n return errors\n }\n\n if (!collectionConfig) {\n errors.push(i18n.t('dashboard:widgetInvalidCollection', { collection: relatedCollection }))\n\n return errors\n }\n\n if (sortField) {\n if (!fieldPaths.filterableFieldPaths.has(sortField)) {\n errors.push(\n i18n.t('dashboard:widgetInvalidSortField', {\n collection: relatedCollection,\n field: sortField,\n }),\n )\n } else if (!fieldPaths.sortableFieldPaths.has(sortField)) {\n errors.push(\n i18n.t('dashboard:widgetNonSortableSortField', {\n collection: relatedCollection,\n field: sortField,\n }),\n )\n }\n }\n\n for (const fieldPath of getWhereFieldPaths(where)) {\n if (\n fieldPaths.filterableFieldPaths.has(fieldPath) ||\n hasRelationshipAncestor({\n path: fieldPath,\n relationshipFieldPaths: fieldPaths.relationshipFieldPaths,\n })\n ) {\n continue\n }\n\n errors.push(\n i18n.t('dashboard:widgetInvalidFilterField', {\n collection: relatedCollection,\n field: fieldPath,\n }),\n )\n }\n\n return errors\n}\n\n/**\n * A `where` path that traverses into a relationship (e.g. `category.name`) cannot be validated\n * against this collection's fields because it targets another collection, so accept it when any\n * ancestor segment is a relationship.\n */\nfunction hasRelationshipAncestor({\n path,\n relationshipFieldPaths,\n}: {\n path: string\n relationshipFieldPaths: Set<string>\n}) {\n const segments = path.split('.')\n let prefix = ''\n\n for (const segment of segments) {\n prefix = prefix ? `${prefix}.${segment}` : segment\n\n if (relationshipFieldPaths.has(prefix)) {\n return true\n }\n }\n\n return false\n}\n\nfunction getWhereFieldPaths(where: undefined | Where) {\n const fieldPaths = new Set<string>()\n\n collectWhereFieldPaths({ fieldPaths, value: where })\n\n return fieldPaths\n}\n\nfunction collectWhereFieldPaths({\n fieldPaths,\n value,\n}: {\n fieldPaths: Set<string>\n value: unknown\n}) {\n if (!value || typeof value !== 'object') {\n return\n }\n\n if (Array.isArray(value)) {\n for (const item of value) {\n collectWhereFieldPaths({ fieldPaths, value: item })\n }\n\n return\n }\n\n for (const [key, childValue] of Object.entries(value)) {\n if (key === 'and' || key === 'or') {\n collectWhereFieldPaths({ fieldPaths, value: childValue })\n\n continue\n }\n\n fieldPaths.add(key)\n }\n}\n\nfunction getDocumentHref({\n id,\n adminRoute,\n collectionSlug,\n}: {\n adminRoute: string\n collectionSlug: CollectionSlug\n id: number | string\n}) {\n return formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}/${id}`,\n })\n}\n\nfunction getValueByPath({ object, path }: { object: Record<string, unknown>; path: string }) {\n return path.split('.').reduce<unknown>((value, segment) => {\n if (!value || typeof value !== 'object') {\n return undefined\n }\n\n return (value as Record<string, unknown>)[segment]\n }, object)\n}\n\nfunction getRelativeTimeFormat(language: string) {\n try {\n return new Intl.RelativeTimeFormat(language, { numeric: 'auto', style: 'narrow' })\n } catch {\n return new Intl.RelativeTimeFormat('en', { numeric: 'auto', style: 'narrow' })\n }\n}\n\nconst relativeTimeDivisions: { amount: number; unit: Intl.RelativeTimeFormatUnit }[] = [\n { amount: 60, unit: 'seconds' },\n { amount: 60, unit: 'minutes' },\n { amount: 24, unit: 'hours' },\n { amount: 7, unit: 'days' },\n { amount: 4.34524, unit: 'weeks' },\n { amount: 12, unit: 'months' },\n { amount: Number.POSITIVE_INFINITY, unit: 'years' },\n]\n\nfunction formatRelativeDate({\n relativeTimeFormat,\n value,\n}: {\n relativeTimeFormat: Intl.RelativeTimeFormat\n value: string\n}) {\n const date = new Date(value)\n\n if (Number.isNaN(date.getTime())) {\n return value\n }\n\n let duration = (date.getTime() - Date.now()) / 1000\n\n for (const division of relativeTimeDivisions) {\n if (Math.abs(duration) < division.amount) {\n return relativeTimeFormat.format(Math.round(duration), division.unit)\n }\n\n duration /= division.amount\n }\n\n return relativeTimeFormat.format(Math.round(duration), 'years')\n}\n\nfunction isDateString(value: string) {\n return /^\\d{4}-\\d{2}-\\d{2}/.test(value) && !Number.isNaN(new Date(value).getTime())\n}\n"],"mappings":";AAGA,SAASA,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,OAAOC,KAAA,MAAW;AAIlB,OAAO;AACP,OAAO;AACP,SAASC,uBAAuB,QAAQ;AAiBxC,MAAMC,QAAA,GAAW;AACjB,MAAMC,QAAA,GAAW;AAEjB,MAAMC,eAAA,GAAwC;EAC5CC,oBAAA,EAAsB,IAAIC,GAAA;EAC1BC,sBAAA,EAAwB,IAAID,GAAA;EAC5BE,kBAAA,EAAoB,IAAIF,GAAA;AAC1B;AAEA,OAAO,eAAeG,sBAAsB;EAC1CC,GAAG;EACHC;AAAU,CAC8C;EACxD,MAAM;IAAEC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,IAAA,CAAKN,KAAA;EAEtB,IAAIR,MAAA,CAAOC,KAAK,CAAC+C,IAAA,CAAKC,OAAO,KAAK;IAChC,OAAOzC,KAAA;EACT;EAEA,IAAI0C,QAAA,GAAW,CAACF,IAAA,CAAKC,OAAO,KAAKnC,IAAA,CAAKqC,GAAG,EAAC,IAAK;EAE/C,KAAK,MAAMC,QAAA,IAAYR,qBAAA,EAAuB;IAC5C,IAAI1C,IAAA,CAAKmD,GAAG,CAACH,QAAA,IAAYE,QAAA,CAASP,MAAM,EAAE;MACxC,OAAO7D,kBAAA,CAAmBsE,MAAM,CAACpD,IAAA,CAAKqD,KAAK,CAACL,QAAA,GAAWE,QAAA,CAASN,IAAI;IACtE;IAEAI,QAAA,IAAYE,QAAA,CAASP,MAAM;EAC7B;EAEA,OAAO7D,kBAAA,CAAmBsE,MAAM,CAACpD,IAAA,CAAKqD,KAAK,CAACL,QAAA,GAAW;AACzD;AAEA,SAASjC,aAAaT,KAAa;EACjC,OAAO,qBAAqBgD,IAAI,CAAChD,KAAA,KAAU,CAACR,MAAA,CAAOC,KAAK,CAAC,IAAIa,IAAA,CAAKN,KAAA,EAAOyC,OAAO;AAClF","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/ui",
|
|
3
|
-
"version": "4.0.0-canary.
|
|
3
|
+
"version": "4.0.0-canary.5",
|
|
4
4
|
"homepage": "https://payloadcms.com",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -243,7 +243,7 @@
|
|
|
243
243
|
"ts-essentials": "10.0.3",
|
|
244
244
|
"use-context-selector": "2.0.0",
|
|
245
245
|
"uuid": "14.0.0",
|
|
246
|
-
"@payloadcms/translations": "4.0.0-canary.
|
|
246
|
+
"@payloadcms/translations": "4.0.0-canary.5"
|
|
247
247
|
},
|
|
248
248
|
"devDependencies": {
|
|
249
249
|
"@babel/cli": "7.27.2",
|
|
@@ -257,13 +257,13 @@
|
|
|
257
257
|
"babel-plugin-react-compiler": "19.1.0-rc.3",
|
|
258
258
|
"esbuild": "0.27.1",
|
|
259
259
|
"esbuild-sass-plugin": "3.3.1",
|
|
260
|
-
"
|
|
261
|
-
"
|
|
260
|
+
"@payloadcms/eslint-config": "3.28.0",
|
|
261
|
+
"payload": "4.0.0-canary.5"
|
|
262
262
|
},
|
|
263
263
|
"peerDependencies": {
|
|
264
264
|
"react": "^19.0.1 || ^19.1.2 || ^19.2.1",
|
|
265
265
|
"react-dom": "^19.0.1 || ^19.1.2 || ^19.2.1",
|
|
266
|
-
"payload": "4.0.0-canary.
|
|
266
|
+
"payload": "4.0.0-canary.5"
|
|
267
267
|
},
|
|
268
268
|
"engines": {
|
|
269
269
|
"node": ">=24.15.0"
|