@payloadcms/ui 4.0.0-internal.6e89a16 → 4.0.0-internal.71538a3

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.
Files changed (117) hide show
  1. package/dist/elements/ClipboardAction/mergeFormStateFromClipboard.d.ts.map +1 -1
  2. package/dist/elements/ClipboardAction/mergeFormStateFromClipboard.js +2 -0
  3. package/dist/elements/ClipboardAction/mergeFormStateFromClipboard.js.map +1 -1
  4. package/dist/elements/DocumentCard/index.css +1 -1
  5. package/dist/elements/FileDetails/FileMeta/index.d.ts +1 -1
  6. package/dist/elements/FileDetails/FileMeta/index.d.ts.map +1 -1
  7. package/dist/elements/FileDetails/FileMeta/index.js +7 -8
  8. package/dist/elements/FileDetails/FileMeta/index.js.map +1 -1
  9. package/dist/elements/FileManager/FilePreview/index.d.ts.map +1 -1
  10. package/dist/elements/FileManager/FilePreview/index.js +12 -14
  11. package/dist/elements/FileManager/FilePreview/index.js.map +1 -1
  12. package/dist/elements/FileManager/index.d.ts.map +1 -1
  13. package/dist/elements/FileManager/index.js +2 -7
  14. package/dist/elements/FileManager/index.js.map +1 -1
  15. package/dist/elements/Table/index.d.ts +2 -0
  16. package/dist/elements/Table/index.d.ts.map +1 -1
  17. package/dist/elements/Table/index.js +3 -2
  18. package/dist/elements/Table/index.js.map +1 -1
  19. package/dist/elements/Thumbnail/index.d.ts +1 -0
  20. package/dist/elements/Thumbnail/index.d.ts.map +1 -1
  21. package/dist/elements/Thumbnail/index.js +2 -1
  22. package/dist/elements/Thumbnail/index.js.map +1 -1
  23. package/dist/elements/Upload/index.d.ts.map +1 -1
  24. package/dist/elements/Upload/index.js +2 -7
  25. package/dist/elements/Upload/index.js.map +1 -1
  26. package/dist/exports/client/index.d.ts +1 -0
  27. package/dist/exports/client/index.d.ts.map +1 -1
  28. package/dist/exports/client/index.js +27 -27
  29. package/dist/exports/client/index.js.map +4 -4
  30. package/dist/exports/rsc/index.d.ts +1 -0
  31. package/dist/exports/rsc/index.d.ts.map +1 -1
  32. package/dist/exports/rsc/index.js +1 -0
  33. package/dist/exports/rsc/index.js.map +1 -1
  34. package/dist/forms/Form/fieldReducer.d.ts.map +1 -1
  35. package/dist/forms/Form/fieldReducer.js +4 -0
  36. package/dist/forms/Form/fieldReducer.js.map +1 -1
  37. package/dist/forms/Form/mergeServerFormState.d.ts.map +1 -1
  38. package/dist/forms/Form/mergeServerFormState.js +6 -7
  39. package/dist/forms/Form/mergeServerFormState.js.map +1 -1
  40. package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.d.ts.map +1 -1
  41. package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.js +3 -6
  42. package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.js.map +1 -1
  43. package/dist/forms/useField/index.d.ts.map +1 -1
  44. package/dist/forms/useField/index.js +44 -48
  45. package/dist/forms/useField/index.js.map +1 -1
  46. package/dist/forms/useField/types.d.ts +0 -5
  47. package/dist/forms/useField/types.d.ts.map +1 -1
  48. package/dist/forms/useField/types.js.map +1 -1
  49. package/dist/graphics/DocumentPlaceholder/index.d.ts +8 -0
  50. package/dist/graphics/DocumentPlaceholder/index.d.ts.map +1 -0
  51. package/dist/graphics/DocumentPlaceholder/index.js +1079 -0
  52. package/dist/graphics/DocumentPlaceholder/index.js.map +1 -0
  53. package/dist/icons/Upload/index.d.ts +5 -0
  54. package/dist/icons/Upload/index.d.ts.map +1 -0
  55. package/dist/icons/Upload/index.js +21 -0
  56. package/dist/icons/Upload/index.js.map +1 -0
  57. package/dist/styles.css +1 -1
  58. package/dist/utilities/reduceFieldsToValuesWithValidation.d.ts +1 -1
  59. package/dist/utilities/reduceFieldsToValuesWithValidation.d.ts.map +1 -1
  60. package/dist/utilities/reduceFieldsToValuesWithValidation.js +7 -3
  61. package/dist/utilities/reduceFieldsToValuesWithValidation.js.map +1 -1
  62. package/dist/views/Dashboard/Default/ModularDashboard/index.d.ts.map +1 -1
  63. package/dist/views/Dashboard/Default/ModularDashboard/index.js +1 -0
  64. package/dist/views/Dashboard/Default/ModularDashboard/index.js.map +1 -1
  65. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/RenderWidget.d.ts.map +1 -1
  66. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/RenderWidget.js +1 -0
  67. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/RenderWidget.js.map +1 -1
  68. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.d.ts.map +1 -1
  69. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.js +1 -0
  70. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.js.map +1 -1
  71. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.d.ts +2 -0
  72. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.d.ts.map +1 -1
  73. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.js +2 -0
  74. package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.js.map +1 -1
  75. package/dist/views/Dashboard/Default/ModularDashboard/useDashboardLayout.d.ts.map +1 -1
  76. package/dist/views/Dashboard/Default/ModularDashboard/useDashboardLayout.js +27 -5
  77. package/dist/views/Dashboard/Default/ModularDashboard/useDashboardLayout.js.map +1 -1
  78. package/dist/views/List/index.client.js +1 -1
  79. package/dist/views/List/index.client.js.map +1 -1
  80. package/dist/widgets/CollectionPreview/getColumnCount.d.ts +8 -0
  81. package/dist/widgets/CollectionPreview/getColumnCount.d.ts.map +1 -0
  82. package/dist/widgets/CollectionPreview/getColumnCount.js +9 -0
  83. package/dist/widgets/CollectionPreview/getColumnCount.js.map +1 -0
  84. package/dist/widgets/CollectionPreview/getPreviewThumbnailURLs.d.ts +8 -0
  85. package/dist/widgets/CollectionPreview/getPreviewThumbnailURLs.d.ts.map +1 -0
  86. package/dist/widgets/CollectionPreview/getPreviewThumbnailURLs.js +83 -0
  87. package/dist/widgets/CollectionPreview/getPreviewThumbnailURLs.js.map +1 -0
  88. package/dist/widgets/CollectionPreview/hasDraggedFiles.d.ts +9 -0
  89. package/dist/widgets/CollectionPreview/hasDraggedFiles.d.ts.map +1 -0
  90. package/dist/widgets/CollectionPreview/hasDraggedFiles.js +8 -0
  91. package/dist/widgets/CollectionPreview/hasDraggedFiles.js.map +1 -0
  92. package/dist/widgets/CollectionPreview/index.client.d.ts +5 -0
  93. package/dist/widgets/CollectionPreview/index.client.d.ts.map +1 -0
  94. package/dist/widgets/CollectionPreview/index.client.js +314 -0
  95. package/dist/widgets/CollectionPreview/index.client.js.map +1 -0
  96. package/dist/widgets/CollectionPreview/index.css +333 -0
  97. package/dist/widgets/CollectionPreview/index.d.ts +10 -0
  98. package/dist/widgets/CollectionPreview/index.d.ts.map +1 -0
  99. package/dist/widgets/CollectionPreview/index.js +183 -0
  100. package/dist/widgets/CollectionPreview/index.js.map +1 -0
  101. package/dist/widgets/CollectionPreview/preferences.d.ts +12 -0
  102. package/dist/widgets/CollectionPreview/preferences.d.ts.map +1 -0
  103. package/dist/widgets/CollectionPreview/preferences.js +16 -0
  104. package/dist/widgets/CollectionPreview/preferences.js.map +1 -0
  105. package/dist/widgets/CollectionPreview/renderTable.d.ts +14 -0
  106. package/dist/widgets/CollectionPreview/renderTable.d.ts.map +1 -0
  107. package/dist/widgets/CollectionPreview/renderTable.js +160 -0
  108. package/dist/widgets/CollectionPreview/renderTable.js.map +1 -0
  109. package/dist/widgets/CollectionPreview/types.d.ts +28 -0
  110. package/dist/widgets/CollectionPreview/types.d.ts.map +1 -0
  111. package/dist/widgets/CollectionPreview/types.js +2 -0
  112. package/dist/widgets/CollectionPreview/types.js.map +1 -0
  113. package/package.json +4 -4
  114. package/dist/elements/Upload/getInitialCrop.d.ts +0 -26
  115. package/dist/elements/Upload/getInitialCrop.d.ts.map +0 -1
  116. package/dist/elements/Upload/getInitialCrop.js +0 -30
  117. package/dist/elements/Upload/getInitialCrop.js.map +0 -1
@@ -0,0 +1,314 @@
1
+ 'use client';
2
+
3
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
4
+ import { validateMimeType } from 'payload/shared';
5
+ import React, { useEffect, useId, useRef, useState } from 'react';
6
+ import { toast } from 'sonner';
7
+ import { useBulkUpload } from '../../elements/BulkUpload/index.js';
8
+ import { Button } from '../../elements/Button/index.js';
9
+ import { DocumentCard } from '../../elements/DocumentCard/index.js';
10
+ import { LayoutToggle } from '../../elements/LayoutToggle/index.js';
11
+ import { Link } from '../../elements/Link/index.js';
12
+ import { useModal } from '../../elements/Modal/index.js';
13
+ import { RelationshipProvider } from '../../elements/Table/RelationshipProvider/index.js';
14
+ import { TableIdentityProvider } from '../../elements/Table/TableIdentity.js';
15
+ import { DocumentPlaceholder } from '../../graphics/DocumentPlaceholder/index.js';
16
+ import { ChevronIcon } from '../../icons/Chevron/index.js';
17
+ import { UploadIcon } from '../../icons/Upload/index.js';
18
+ import { usePreferences } from '../../providers/Preferences/index.js';
19
+ import { useRouter } from '../../providers/RouterAdapter/index.js';
20
+ import { useTranslation } from '../../providers/Translation/index.js';
21
+ import { getColumnCount } from './getColumnCount.js';
22
+ import { hasDraggedFiles } from './hasDraggedFiles.js';
23
+ import { getCollectionPreviewPreferenceKey } from './preferences.js';
24
+ import './index.css';
25
+ export function CollectionPreviewClient({
26
+ collectionSlug,
27
+ createHref,
28
+ createLabel,
29
+ description,
30
+ documents,
31
+ emptyLabel,
32
+ href,
33
+ initialLayout = 'grid',
34
+ isAuth,
35
+ isBulkUploadEnabled = false,
36
+ label,
37
+ loadError,
38
+ mimeTypes,
39
+ table,
40
+ widgetId
41
+ }) {
42
+ const {
43
+ modalSlug,
44
+ setCollectionSlug,
45
+ setInitialFiles,
46
+ setInitialForms,
47
+ setOnSuccess,
48
+ setParentID,
49
+ setSelectableCollections
50
+ } = useBulkUpload();
51
+ const {
52
+ openModal
53
+ } = useModal();
54
+ const router = useRouter();
55
+ const {
56
+ setPreference
57
+ } = usePreferences();
58
+ const preferenceKey = getCollectionPreviewPreferenceKey({
59
+ collectionSlug,
60
+ widgetId
61
+ });
62
+ const {
63
+ t
64
+ } = useTranslation();
65
+ const dragDepth = useRef(0);
66
+ const [isDraggingFiles, setIsDraggingFiles] = useState(false);
67
+ const canDropFiles = isBulkUploadEnabled && Boolean(createHref);
68
+ const headingID = useId();
69
+ const [layout, setLayout] = useState(initialLayout);
70
+ const previewRef = useRef(null);
71
+ const [columns, setColumns] = useState(1);
72
+ useEffect(() => {
73
+ const preview = previewRef.current;
74
+ if (!preview) {
75
+ return;
76
+ }
77
+ const updateColumns = () => {
78
+ const styles = getComputedStyle(preview);
79
+ setColumns(getColumnCount({
80
+ gap: parseFloat(styles.columnGap) || 0,
81
+ width: preview.clientWidth
82
+ }));
83
+ };
84
+ updateColumns();
85
+ const observer = new ResizeObserver(updateColumns);
86
+ observer.observe(preview);
87
+ return () => observer.disconnect();
88
+ }, []);
89
+ useEffect(() => {
90
+ const resetDrag = () => {
91
+ dragDepth.current = 0;
92
+ setIsDraggingFiles(false);
93
+ };
94
+ if (!canDropFiles) {
95
+ resetDrag();
96
+ return;
97
+ }
98
+ window.addEventListener('dragend', resetDrag);
99
+ window.addEventListener('drop', resetDrag);
100
+ window.addEventListener('blur', resetDrag);
101
+ return () => {
102
+ window.removeEventListener('dragend', resetDrag);
103
+ window.removeEventListener('drop', resetDrag);
104
+ window.removeEventListener('blur', resetDrag);
105
+ };
106
+ }, [canDropFiles]);
107
+ const handleLayoutChange = async nextLayout => {
108
+ setLayout(nextLayout);
109
+ try {
110
+ await setPreference(preferenceKey, preferences => ({
111
+ ...preferences,
112
+ documentLayout: nextLayout
113
+ }));
114
+ } catch {
115
+ toast.error(t('error:unknown'));
116
+ }
117
+ };
118
+ const handleBulkUpload = ({
119
+ files
120
+ } = {}) => {
121
+ setCollectionSlug(collectionSlug);
122
+ setSelectableCollections([collectionSlug]);
123
+ setParentID(undefined);
124
+ setInitialFiles(files);
125
+ setInitialForms(undefined);
126
+ setOnSuccess(() => router.refresh());
127
+ openModal(modalSlug);
128
+ };
129
+ const handleDragEnter = event => {
130
+ if (!canDropFiles || !hasDraggedFiles({
131
+ dataTransfer: event.dataTransfer
132
+ })) {
133
+ return;
134
+ }
135
+ event.preventDefault();
136
+ event.stopPropagation();
137
+ dragDepth.current += 1;
138
+ setIsDraggingFiles(true);
139
+ };
140
+ const handleDragLeave = event_0 => {
141
+ if (!dragDepth.current) {
142
+ return;
143
+ }
144
+ event_0.preventDefault();
145
+ event_0.stopPropagation();
146
+ dragDepth.current = Math.max(0, dragDepth.current - 1);
147
+ if (!dragDepth.current) {
148
+ setIsDraggingFiles(false);
149
+ }
150
+ };
151
+ const handleDragOver = event_1 => {
152
+ if (!canDropFiles || !hasDraggedFiles({
153
+ dataTransfer: event_1.dataTransfer
154
+ })) {
155
+ return;
156
+ }
157
+ event_1.preventDefault();
158
+ event_1.stopPropagation();
159
+ event_1.dataTransfer.dropEffect = 'copy';
160
+ dragDepth.current = Math.max(1, dragDepth.current);
161
+ setIsDraggingFiles(true);
162
+ };
163
+ const handleDrop = event_2 => {
164
+ if (!canDropFiles || !event_2.dataTransfer.files.length) {
165
+ return;
166
+ }
167
+ event_2.preventDefault();
168
+ event_2.stopPropagation();
169
+ dragDepth.current = 0;
170
+ setIsDraggingFiles(false);
171
+ const {
172
+ files: files_0
173
+ } = event_2.dataTransfer;
174
+ if (mimeTypes?.length && !Array.from(files_0).every(file => validateMimeType(file.type, mimeTypes))) {
175
+ toast.error(t('error:invalidFileType'));
176
+ return;
177
+ }
178
+ const transfer = new DataTransfer();
179
+ for (const file_0 of Array.from(files_0)) {
180
+ transfer.items.add(file_0);
181
+ }
182
+ handleBulkUpload({
183
+ files: transfer.files
184
+ });
185
+ };
186
+ const createButton = createHref ? /*#__PURE__*/_jsx(Button, {
187
+ "aria-haspopup": isBulkUploadEnabled ? 'dialog' : undefined,
188
+ "aria-label": `${createLabel}: ${label}`,
189
+ buttonStyle: "secondary",
190
+ className: "collection-preview__create",
191
+ el: isBulkUploadEnabled ? 'button' : 'link',
192
+ icon: isBulkUploadEnabled ? /*#__PURE__*/_jsx(UploadIcon, {}) : 'plus',
193
+ iconPosition: "left",
194
+ margin: false,
195
+ onClick: isBulkUploadEnabled ? () => handleBulkUpload() : undefined,
196
+ to: isBulkUploadEnabled ? undefined : createHref,
197
+ children: createLabel
198
+ }) : null;
199
+ return /*#__PURE__*/_jsxs("section", {
200
+ "aria-labelledby": headingID,
201
+ className: ['collection-preview', isDraggingFiles && 'collection-preview--dragging'].filter(Boolean).join(' '),
202
+ onDragEnterCapture: handleDragEnter,
203
+ onDragLeaveCapture: handleDragLeave,
204
+ onDragOverCapture: handleDragOver,
205
+ onDropCapture: handleDrop,
206
+ ref: previewRef,
207
+ style: {
208
+ '--collection-preview-columns': columns
209
+ },
210
+ children: [/*#__PURE__*/_jsxs("div", {
211
+ className: "collection-preview__header",
212
+ children: [/*#__PURE__*/_jsx("h2", {
213
+ className: "collection-preview__heading",
214
+ id: headingID,
215
+ children: /*#__PURE__*/_jsxs(Link, {
216
+ className: "collection-preview__heading-link",
217
+ href: href,
218
+ children: [label, /*#__PURE__*/_jsx("span", {
219
+ "aria-hidden": "true",
220
+ className: "collection-preview__heading-chevron",
221
+ children: /*#__PURE__*/_jsx(ChevronIcon, {
222
+ direction: "right"
223
+ })
224
+ })]
225
+ })
226
+ }), /*#__PURE__*/_jsxs("div", {
227
+ className: "collection-preview__actions",
228
+ children: [createHref ? /*#__PURE__*/_jsx(Button, {
229
+ "aria-haspopup": isBulkUploadEnabled ? 'dialog' : undefined,
230
+ "aria-label": `${createLabel}: ${label}`,
231
+ buttonStyle: "ghost",
232
+ el: isBulkUploadEnabled ? 'button' : 'link',
233
+ icon: isBulkUploadEnabled ? /*#__PURE__*/_jsx(UploadIcon, {}) : 'plus',
234
+ iconPosition: "left",
235
+ margin: false,
236
+ onClick: isBulkUploadEnabled ? () => handleBulkUpload() : undefined,
237
+ to: isBulkUploadEnabled ? undefined : createHref,
238
+ tooltip: createLabel
239
+ }) : null, /*#__PURE__*/_jsx(LayoutToggle, {
240
+ layout: layout,
241
+ onChange: handleLayoutChange
242
+ })]
243
+ })]
244
+ }), loadError ? /*#__PURE__*/_jsx("p", {
245
+ role: "status",
246
+ children: loadError
247
+ }) : null, !loadError && !documents.length ? /*#__PURE__*/_jsxs("div", {
248
+ className: "collection-preview__empty-card collection-preview__empty-card--full",
249
+ children: [/*#__PURE__*/_jsx("p", {
250
+ children: emptyLabel
251
+ }), createButton]
252
+ }) : null, !loadError && documents.length > 0 && layout === 'table' ? /*#__PURE__*/_jsx("div", {
253
+ className: "collection-preview__table",
254
+ "data-row-count": columns,
255
+ children: /*#__PURE__*/_jsx(TableIdentityProvider, {
256
+ collectionSlug: collectionSlug,
257
+ children: /*#__PURE__*/_jsx(RelationshipProvider, {
258
+ children: table
259
+ })
260
+ })
261
+ }) : null, !loadError && documents.length > 0 && layout === 'grid' ? /*#__PURE__*/_jsx("ul", {
262
+ className: "collection-preview__row",
263
+ children: Array.from({
264
+ length: columns
265
+ }, (_, index) => {
266
+ const doc = documents[index];
267
+ return /*#__PURE__*/_jsx("li", {
268
+ children: doc ? /*#__PURE__*/_jsx(DocumentCard, {
269
+ href: doc.href,
270
+ placeholder: /*#__PURE__*/_jsx(DocumentPlaceholder, {
271
+ variant: isAuth ? 'auth' : 'document'
272
+ }),
273
+ thumbnail: doc.thumbnailURL ? {
274
+ alt: '',
275
+ src: doc.thumbnailURL
276
+ } : undefined,
277
+ title: doc.title,
278
+ children: /*#__PURE__*/_jsxs("div", {
279
+ className: "collection-preview__metadata",
280
+ children: [label, doc.dateLabel ? /*#__PURE__*/_jsxs(_Fragment, {
281
+ children: [' ', "· ", /*#__PURE__*/_jsx("time", {
282
+ dateTime: doc.dateTime,
283
+ children: doc.dateLabel
284
+ })]
285
+ }) : null]
286
+ })
287
+ }) : /*#__PURE__*/_jsxs("div", {
288
+ className: "collection-preview__empty-card",
289
+ children: [/*#__PURE__*/_jsx("div", {
290
+ "aria-hidden": "true",
291
+ className: "collection-preview__thumbnail-sizing"
292
+ }), /*#__PURE__*/_jsx("div", {
293
+ "aria-hidden": "true",
294
+ className: "collection-preview__content-sizing"
295
+ }), /*#__PURE__*/_jsx("div", {
296
+ className: "collection-preview__empty-content",
297
+ children: createHref && index === documents.length ? createButton : null
298
+ })]
299
+ })
300
+ }, doc?.id ?? `empty-${index}`);
301
+ })
302
+ }) : null, description ? /*#__PURE__*/_jsx("div", {
303
+ className: "collection-preview__description",
304
+ children: description
305
+ }) : null, isDraggingFiles ? /*#__PURE__*/_jsxs("div", {
306
+ className: "collection-preview__drop-overlay",
307
+ role: "status",
308
+ children: [/*#__PURE__*/_jsx(UploadIcon, {}), /*#__PURE__*/_jsx("span", {
309
+ children: t('dashboard:widgetDropFilesToUpload')
310
+ })]
311
+ }) : null]
312
+ });
313
+ }
314
+ //# sourceMappingURL=index.client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.client.js","names":["validateMimeType","React","useEffect","useId","useRef","useState","toast","useBulkUpload","Button","DocumentCard","LayoutToggle","Link","useModal","RelationshipProvider","TableIdentityProvider","DocumentPlaceholder","ChevronIcon","UploadIcon","usePreferences","useRouter","useTranslation","getColumnCount","hasDraggedFiles","getCollectionPreviewPreferenceKey","CollectionPreviewClient","collectionSlug","createHref","createLabel","description","documents","emptyLabel","href","initialLayout","isAuth","isBulkUploadEnabled","label","loadError","mimeTypes","table","widgetId","modalSlug","setCollectionSlug","setInitialFiles","setInitialForms","setOnSuccess","setParentID","setSelectableCollections","openModal","router","setPreference","preferenceKey","t","dragDepth","isDraggingFiles","setIsDraggingFiles","canDropFiles","Boolean","headingID","layout","setLayout","previewRef","columns","setColumns","preview","current","updateColumns","styles","getComputedStyle","gap","parseFloat","columnGap","width","clientWidth","observer","ResizeObserver","observe","disconnect","resetDrag","window","addEventListener","removeEventListener","handleLayoutChange","nextLayout","preferences","documentLayout","error","handleBulkUpload","files","undefined","refresh","handleDragEnter","event","dataTransfer","preventDefault","stopPropagation","handleDragLeave","Math","max","handleDragOver","dropEffect","handleDrop","length","Array","from","every","file","type","transfer","DataTransfer","items","add","createButton","_jsx","buttonStyle","className","el","icon","iconPosition","margin","onClick","to","_jsxs","filter","join","onDragEnterCapture","onDragLeaveCapture","onDragOverCapture","onDropCapture","ref","style","id","direction","tooltip","onChange","role","_","index","doc","placeholder","variant","thumbnail","thumbnailURL","alt","src","title","dateLabel","_Fragment","dateTime"],"sources":["../../../src/widgets/CollectionPreview/index.client.tsx"],"sourcesContent":["'use client'\n\nimport { validateMimeType } from 'payload/shared'\nimport React, { useEffect, useId, useRef, useState } from 'react'\nimport { toast } from 'sonner'\n\nimport type { DocumentLayout } from '../../elements/LayoutToggle/index.js'\nimport type { CollectionPreviewPreferences } from './preferences.js'\nimport type { CollectionPreviewProps } from './types.js'\n\nimport { useBulkUpload } from '../../elements/BulkUpload/index.js'\nimport { Button } from '../../elements/Button/index.js'\nimport { DocumentCard } from '../../elements/DocumentCard/index.js'\nimport { LayoutToggle } from '../../elements/LayoutToggle/index.js'\nimport { Link } from '../../elements/Link/index.js'\nimport { useModal } from '../../elements/Modal/index.js'\nimport { RelationshipProvider } from '../../elements/Table/RelationshipProvider/index.js'\nimport { TableIdentityProvider } from '../../elements/Table/TableIdentity.js'\nimport { DocumentPlaceholder } from '../../graphics/DocumentPlaceholder/index.js'\nimport { ChevronIcon } from '../../icons/Chevron/index.js'\nimport { UploadIcon } from '../../icons/Upload/index.js'\nimport { usePreferences } from '../../providers/Preferences/index.js'\nimport { useRouter } from '../../providers/RouterAdapter/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { getColumnCount } from './getColumnCount.js'\nimport { hasDraggedFiles } from './hasDraggedFiles.js'\nimport { getCollectionPreviewPreferenceKey } from './preferences.js'\nimport './index.css'\n\nexport function CollectionPreviewClient({\n collectionSlug,\n createHref,\n createLabel,\n description,\n documents,\n emptyLabel,\n href,\n initialLayout = 'grid',\n isAuth,\n isBulkUploadEnabled = false,\n label,\n loadError,\n mimeTypes,\n table,\n widgetId,\n}: CollectionPreviewProps) {\n const {\n modalSlug,\n setCollectionSlug,\n setInitialFiles,\n setInitialForms,\n setOnSuccess,\n setParentID,\n setSelectableCollections,\n } = useBulkUpload()\n const { openModal } = useModal()\n const router = useRouter()\n const { setPreference } = usePreferences()\n const preferenceKey = getCollectionPreviewPreferenceKey({ collectionSlug, widgetId })\n const { t } = useTranslation()\n const dragDepth = useRef(0)\n const [isDraggingFiles, setIsDraggingFiles] = useState(false)\n const canDropFiles = isBulkUploadEnabled && Boolean(createHref)\n const headingID = useId()\n const [layout, setLayout] = useState<DocumentLayout>(initialLayout)\n const previewRef = useRef<HTMLElement>(null)\n const [columns, setColumns] = useState(1)\n\n useEffect(() => {\n const preview = previewRef.current\n if (!preview) {\n return\n }\n\n const updateColumns = () => {\n const styles = getComputedStyle(preview)\n setColumns(\n getColumnCount({\n gap: parseFloat(styles.columnGap) || 0,\n width: preview.clientWidth,\n }),\n )\n }\n updateColumns()\n const observer = new ResizeObserver(updateColumns)\n observer.observe(preview)\n return () => observer.disconnect()\n }, [])\n\n useEffect(() => {\n const resetDrag = () => {\n dragDepth.current = 0\n setIsDraggingFiles(false)\n }\n\n if (!canDropFiles) {\n resetDrag()\n return\n }\n\n window.addEventListener('dragend', resetDrag)\n window.addEventListener('drop', resetDrag)\n window.addEventListener('blur', resetDrag)\n return () => {\n window.removeEventListener('dragend', resetDrag)\n window.removeEventListener('drop', resetDrag)\n window.removeEventListener('blur', resetDrag)\n }\n }, [canDropFiles])\n\n const handleLayoutChange = async (nextLayout: DocumentLayout) => {\n setLayout(nextLayout)\n try {\n await setPreference<CollectionPreviewPreferences>(preferenceKey, (preferences) => ({\n ...preferences,\n documentLayout: nextLayout,\n }))\n } catch {\n toast.error(t('error:unknown'))\n }\n }\n\n const handleBulkUpload = ({ files }: { files?: FileList } = {}) => {\n setCollectionSlug(collectionSlug)\n setSelectableCollections([collectionSlug])\n setParentID(undefined)\n setInitialFiles(files)\n setInitialForms(undefined)\n setOnSuccess(() => router.refresh())\n openModal(modalSlug)\n }\n\n const handleDragEnter = (event: React.DragEvent<HTMLElement>) => {\n if (!canDropFiles || !hasDraggedFiles({ dataTransfer: event.dataTransfer })) {\n return\n }\n event.preventDefault()\n event.stopPropagation()\n dragDepth.current += 1\n setIsDraggingFiles(true)\n }\n\n const handleDragLeave = (event: React.DragEvent<HTMLElement>) => {\n if (!dragDepth.current) {\n return\n }\n event.preventDefault()\n event.stopPropagation()\n dragDepth.current = Math.max(0, dragDepth.current - 1)\n if (!dragDepth.current) {\n setIsDraggingFiles(false)\n }\n }\n\n const handleDragOver = (event: React.DragEvent<HTMLElement>) => {\n if (!canDropFiles || !hasDraggedFiles({ dataTransfer: event.dataTransfer })) {\n return\n }\n event.preventDefault()\n event.stopPropagation()\n event.dataTransfer.dropEffect = 'copy'\n dragDepth.current = Math.max(1, dragDepth.current)\n setIsDraggingFiles(true)\n }\n\n const handleDrop = (event: React.DragEvent<HTMLElement>) => {\n if (!canDropFiles || !event.dataTransfer.files.length) {\n return\n }\n event.preventDefault()\n event.stopPropagation()\n dragDepth.current = 0\n setIsDraggingFiles(false)\n\n const { files } = event.dataTransfer\n if (\n mimeTypes?.length &&\n !Array.from(files).every((file) => validateMimeType(file.type, mimeTypes))\n ) {\n toast.error(t('error:invalidFileType'))\n return\n }\n const transfer = new DataTransfer()\n for (const file of Array.from(files)) {\n transfer.items.add(file)\n }\n handleBulkUpload({ files: transfer.files })\n }\n\n const createButton = createHref ? (\n <Button\n aria-haspopup={isBulkUploadEnabled ? 'dialog' : undefined}\n aria-label={`${createLabel}: ${label}`}\n buttonStyle=\"secondary\"\n className=\"collection-preview__create\"\n el={isBulkUploadEnabled ? 'button' : 'link'}\n icon={isBulkUploadEnabled ? <UploadIcon /> : 'plus'}\n iconPosition=\"left\"\n margin={false}\n onClick={isBulkUploadEnabled ? () => handleBulkUpload() : undefined}\n to={isBulkUploadEnabled ? undefined : createHref}\n >\n {createLabel}\n </Button>\n ) : null\n\n return (\n <section\n aria-labelledby={headingID}\n className={['collection-preview', isDraggingFiles && 'collection-preview--dragging']\n .filter(Boolean)\n .join(' ')}\n onDragEnterCapture={handleDragEnter}\n onDragLeaveCapture={handleDragLeave}\n onDragOverCapture={handleDragOver}\n onDropCapture={handleDrop}\n ref={previewRef}\n style={{ '--collection-preview-columns': columns } as React.CSSProperties}\n >\n <div className=\"collection-preview__header\">\n <h2 className=\"collection-preview__heading\" id={headingID}>\n <Link className=\"collection-preview__heading-link\" href={href}>\n {label}\n <span aria-hidden=\"true\" className=\"collection-preview__heading-chevron\">\n <ChevronIcon direction=\"right\" />\n </span>\n </Link>\n </h2>\n <div className=\"collection-preview__actions\">\n {createHref ? (\n <Button\n aria-haspopup={isBulkUploadEnabled ? 'dialog' : undefined}\n aria-label={`${createLabel}: ${label}`}\n buttonStyle=\"ghost\"\n el={isBulkUploadEnabled ? 'button' : 'link'}\n icon={isBulkUploadEnabled ? <UploadIcon /> : 'plus'}\n iconPosition=\"left\"\n margin={false}\n onClick={isBulkUploadEnabled ? () => handleBulkUpload() : undefined}\n to={isBulkUploadEnabled ? undefined : createHref}\n tooltip={createLabel}\n />\n ) : null}\n <LayoutToggle layout={layout} onChange={handleLayoutChange} />\n </div>\n </div>\n {loadError ? <p role=\"status\">{loadError}</p> : null}\n {!loadError && !documents.length ? (\n <div className=\"collection-preview__empty-card collection-preview__empty-card--full\">\n <p>{emptyLabel}</p>\n {createButton}\n </div>\n ) : null}\n {!loadError && documents.length > 0 && layout === 'table' ? (\n <div className=\"collection-preview__table\" data-row-count={columns}>\n <TableIdentityProvider collectionSlug={collectionSlug}>\n <RelationshipProvider>{table}</RelationshipProvider>\n </TableIdentityProvider>\n </div>\n ) : null}\n {!loadError && documents.length > 0 && layout === 'grid' ? (\n <ul className=\"collection-preview__row\">\n {Array.from({ length: columns }, (_, index) => {\n const doc = documents[index]\n return (\n <li key={doc?.id ?? `empty-${index}`}>\n {doc ? (\n <DocumentCard\n href={doc.href}\n placeholder={<DocumentPlaceholder variant={isAuth ? 'auth' : 'document'} />}\n thumbnail={doc.thumbnailURL ? { alt: '', src: doc.thumbnailURL } : undefined}\n title={doc.title}\n >\n <div className=\"collection-preview__metadata\">\n {label}\n {doc.dateLabel ? (\n <>\n {' '}\n · <time dateTime={doc.dateTime}>{doc.dateLabel}</time>\n </>\n ) : null}\n </div>\n </DocumentCard>\n ) : (\n <div className=\"collection-preview__empty-card\">\n <div aria-hidden=\"true\" className=\"collection-preview__thumbnail-sizing\" />\n <div aria-hidden=\"true\" className=\"collection-preview__content-sizing\" />\n <div className=\"collection-preview__empty-content\">\n {createHref && index === documents.length ? createButton : null}\n </div>\n </div>\n )}\n </li>\n )\n })}\n </ul>\n ) : null}\n {description ? <div className=\"collection-preview__description\">{description}</div> : null}\n {isDraggingFiles ? (\n <div className=\"collection-preview__drop-overlay\" role=\"status\">\n <UploadIcon />\n <span>{t('dashboard:widgetDropFilesToUpload')}</span>\n </div>\n ) : null}\n </section>\n )\n}\n"],"mappings":"AAAA;;;AAEA,SAASA,gBAAgB,QAAQ;AACjC,OAAOC,KAAA,IAASC,SAAS,EAAEC,KAAK,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAC1D,SAASC,KAAK,QAAQ;AAMtB,SAASC,aAAa,QAAQ;AAC9B,SAASC,MAAM,QAAQ;AACvB,SAASC,YAAY,QAAQ;AAC7B,SAASC,YAAY,QAAQ;AAC7B,SAASC,IAAI,QAAQ;AACrB,SAASC,QAAQ,QAAQ;AACzB,SAASC,oBAAoB,QAAQ;AACrC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,mBAAmB,QAAQ;AACpC,SAASC,WAAW,QAAQ;AAC5B,SAASC,UAAU,QAAQ;AAC3B,SAASC,cAAc,QAAQ;AAC/B,SAASC,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAC/B,SAASC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;;mBAErC;;4BAIRxB,KAAA,CAAC;YAAIP,SAAA,EAAU;oCACbF,IAAA,CAAC;cAAI,eAAY;cAAOE,SAAA,EAAU;6BAClCF,IAAA,CAAC;cAAI,eAAY;cAAOE,SAAA,EAAU;6BAClCF,IAAA,CAAC;cAAIE,SAAA,EAAU;wBACZxF,UAAA,IAAc8G,KAAA,KAAU3G,SAAA,CAAUwE,MAAM,GAAGU,YAAA,GAAe;;;WAvB1D0B,GAAA,EAAKP,EAAA,IAAM,SAASM,KAAA,EAAO;MA6BxC;SAEA,MACH5G,WAAA,gBAAcoF,IAAA,CAAC;MAAIE,SAAA,EAAU;gBAAmCtF;SAAqB,MACrFyB,eAAA,gBACCoE,KAAA,CAAC;MAAIP,SAAA,EAAU;MAAmCoB,IAAA,EAAK;8BACrDtB,IAAA,CAAC/F,UAAA,O,aACD+F,IAAA,CAAC;kBAAM7D,CAAA,CAAE;;SAET;;AAGV","ignoreList":[]}
@@ -0,0 +1,333 @@
1
+ @layer payload-default {
2
+ .collection-preview {
3
+ --collection-preview-max-width: calc(var(--spacer-6) * 6);
4
+ --collection-preview-aspect-ratio: 4 / 3;
5
+ --collection-preview-grid-gap: var(--spacer-4);
6
+ --collection-preview-card-width: min(
7
+ var(--collection-preview-max-width),
8
+ (100cqi - var(--collection-preview-grid-gap) * (var(--collection-preview-columns, 1) - 1)) /
9
+ var(--collection-preview-columns, 1)
10
+ );
11
+ --collection-preview-empty-height: calc(
12
+ (var(--collection-preview-card-width) - var(--stroke-width-small) * 2) /
13
+ (var(--collection-preview-aspect-ratio)) + var(--collection-preview-content-height) +
14
+ var(--stroke-width-small) * 2
15
+ );
16
+ --collection-preview-table-header-height: var(--spacer-6);
17
+ --collection-preview-table-row-height: calc(var(--spacer-4) * 2);
18
+ --collection-preview-content-height: calc(
19
+ var(--spacer-2-5) * 2 + var(--text-body-medium-line-height) * 2 + var(--spacer-1) +
20
+ var(--stroke-width-small)
21
+ );
22
+
23
+ position: relative;
24
+ display: flex;
25
+ flex-direction: column;
26
+ gap: var(--spacer-3);
27
+ column-gap: var(--collection-preview-grid-gap);
28
+ min-inline-size: 0;
29
+ margin-block-start: var(--spacer-2-5);
30
+ container-type: inline-size;
31
+ }
32
+
33
+ .collection-preview--dragging > :not(.collection-preview__drop-overlay) {
34
+ opacity: 0;
35
+ }
36
+
37
+ .collection-preview__drop-overlay {
38
+ position: absolute;
39
+ inset: 0;
40
+ z-index: 1;
41
+ display: flex;
42
+ flex-direction: column;
43
+ align-items: center;
44
+ justify-content: center;
45
+ gap: var(--spacer-2-5);
46
+ padding: var(--spacer-3);
47
+ border: var(--stroke-width-small) dashed var(--color-border-selected);
48
+ border-radius: var(--radius-large);
49
+ background: var(--color-bg-selected);
50
+ color: var(--color-text);
51
+ text-align: center;
52
+ pointer-events: none;
53
+ }
54
+
55
+ .collection-preview__header,
56
+ .collection-preview__actions {
57
+ display: flex;
58
+ align-items: center;
59
+ gap: var(--spacer-3);
60
+ flex-wrap: wrap;
61
+ }
62
+
63
+ .collection-preview__header {
64
+ justify-content: space-between;
65
+ }
66
+
67
+ .collection-preview__actions {
68
+ gap: var(--spacer-2);
69
+ margin-inline-start: auto;
70
+ }
71
+
72
+ .collection-preview__table {
73
+ display: flex;
74
+ flex-direction: column;
75
+ min-inline-size: 0;
76
+ border: var(--stroke-width-small) solid var(--color-border);
77
+ border-radius: var(--radius-large);
78
+ overflow: hidden;
79
+ }
80
+
81
+ /* Keep the server-rendered preview limited to the same documents as the grid. */
82
+ .collection-preview__table[data-row-count='1'] > .table > table > tbody > tr:nth-child(n + 2),
83
+ .collection-preview__table[data-row-count='2'] > .table > table > tbody > tr:nth-child(n + 3),
84
+ .collection-preview__table[data-row-count='3'] > .table > table > tbody > tr:nth-child(n + 4),
85
+ .collection-preview__table[data-row-count='4'] > .table > table > tbody > tr:nth-child(n + 5),
86
+ .collection-preview__table[data-row-count='5'] > .table > table > tbody > tr:nth-child(n + 6),
87
+ .collection-preview__table[data-row-count='6'] > .table > table > tbody > tr:nth-child(n + 7),
88
+ .collection-preview__table[data-row-count='7'] > .table > table > tbody > tr:nth-child(n + 8) {
89
+ display: none;
90
+ }
91
+
92
+ .collection-preview__table .table {
93
+ table {
94
+ inline-size: 100%;
95
+ table-layout: fixed;
96
+ border-collapse: collapse;
97
+ }
98
+
99
+ thead {
100
+ background: var(--color-bg-secondary);
101
+ border-block-end: var(--stroke-width-small) solid var(--color-border);
102
+ }
103
+
104
+ th,
105
+ td {
106
+ padding-inline: var(--spacer-3);
107
+ font-size: var(--text-body-medium-font-size);
108
+ line-height: var(--text-body-medium-line-height);
109
+ overflow-wrap: anywhere;
110
+ }
111
+
112
+ th:first-child,
113
+ td:not(.cell--linked):first-child {
114
+ padding-inline-start: var(--spacer-3);
115
+ }
116
+
117
+ th {
118
+ block-size: var(--collection-preview-table-header-height);
119
+ padding-block: var(--spacer-2-5);
120
+ color: var(--color-text-secondary);
121
+ font-weight: var(--text-body-medium-font-weight);
122
+ }
123
+
124
+ td {
125
+ block-size: var(--collection-preview-table-row-height);
126
+ padding-block: var(--spacer-2-5);
127
+ }
128
+
129
+ td.cell--linked {
130
+ padding: 0;
131
+ }
132
+
133
+ td.cell--linked > :is(a, button, .drawer-link) {
134
+ min-block-size: var(--collection-preview-table-row-height);
135
+ padding-block: var(--spacer-2-5);
136
+ padding-inline: var(--spacer-3);
137
+ text-decoration: none;
138
+ }
139
+
140
+ td.cell--linked > :is(a, button, .drawer-link),
141
+ td.cell--linked:first-child > :is(a, button, .drawer-link) {
142
+ padding-inline-start: calc(var(--spacer-3) + var(--spacer-4) + var(--spacer-2));
143
+ }
144
+
145
+ td.cell--linked .file__thumbnail {
146
+ display: none;
147
+ }
148
+
149
+ td.cell--linked > :is(a, button, .drawer-link):is(:hover, :focus-visible) {
150
+ text-decoration: underline;
151
+ }
152
+ }
153
+
154
+ .collection-preview__table-thumbnail {
155
+ position: absolute;
156
+ inset-block-start: var(--spacer-2-5);
157
+ inset-inline-start: var(--spacer-3);
158
+ inline-size: var(--spacer-4);
159
+ block-size: var(--spacer-4);
160
+ overflow: hidden;
161
+ border-radius: var(--radius-medium);
162
+ background: var(--color-bg-secondary);
163
+ color: var(--color-text-secondary);
164
+ pointer-events: none;
165
+ }
166
+
167
+ .collection-preview__table-thumbnail > .thumbnail {
168
+ display: flex;
169
+ align-items: center;
170
+ justify-content: center;
171
+ inline-size: 100%;
172
+ block-size: 100%;
173
+ }
174
+
175
+ .collection-preview__table-thumbnail > .thumbnail > img {
176
+ display: block;
177
+ inline-size: 100%;
178
+ block-size: 100%;
179
+ object-fit: cover;
180
+ }
181
+
182
+ .collection-preview__heading {
183
+ margin: 0;
184
+ font-size: var(--text-body-xl-font-size);
185
+ font-weight: var(--text-body-xl-bold-font-weight);
186
+ line-height: var(--text-body-xl-line-height);
187
+ letter-spacing: var(--text-body-xl-letter-spacing);
188
+ }
189
+
190
+ .collection-preview__heading-link {
191
+ display: inline-flex;
192
+ align-items: center;
193
+ min-block-size: var(--spacer-4);
194
+ color: var(--color-text);
195
+ text-decoration: none;
196
+ border-radius: var(--radius-medium);
197
+ }
198
+
199
+ .collection-preview__heading-link:focus-visible {
200
+ outline: var(--accessibility-outline);
201
+ outline-offset: var(--spacer-1);
202
+ }
203
+
204
+ .collection-preview__heading-chevron {
205
+ display: inline-flex;
206
+ color: var(--color-text-secondary);
207
+ transition:
208
+ transform 150ms ease,
209
+ color 150ms ease;
210
+ }
211
+
212
+ .collection-preview__heading-link:hover .collection-preview__heading-chevron,
213
+ .collection-preview__heading-link:focus-visible .collection-preview__heading-chevron {
214
+ color: var(--color-text);
215
+ transform: translateX(var(--spacer-1));
216
+ }
217
+
218
+ @media (prefers-reduced-motion: reduce) {
219
+ .collection-preview__heading-chevron {
220
+ transition: none;
221
+ }
222
+ }
223
+
224
+ .collection-preview__row {
225
+ display: grid;
226
+ grid-template-columns: repeat(
227
+ var(--collection-preview-columns, 1),
228
+ minmax(0, var(--collection-preview-max-width))
229
+ );
230
+ gap: var(--collection-preview-grid-gap);
231
+ list-style: none;
232
+ margin: 0;
233
+ padding: 0;
234
+ }
235
+
236
+ .collection-preview__row > li {
237
+ min-inline-size: 0;
238
+ }
239
+
240
+ .collection-preview .document-card__thumbnail,
241
+ .collection-preview__thumbnail-sizing {
242
+ inline-size: 100%;
243
+ min-block-size: 0;
244
+ aspect-ratio: var(--collection-preview-aspect-ratio);
245
+ }
246
+
247
+ .collection-preview .document-card__thumbnail--empty {
248
+ background: linear-gradient(
249
+ var(--color-bg-secondary),
250
+ color-mix(in srgb, var(--color-bg-secondary) 25%, var(--color-bg))
251
+ );
252
+ }
253
+
254
+ .collection-preview .document-card__content,
255
+ .collection-preview__content-sizing {
256
+ min-block-size: var(--collection-preview-content-height);
257
+ border-block-start: var(--stroke-width-small) solid var(--color-border);
258
+ }
259
+
260
+ .collection-preview .document-card__title {
261
+ display: block;
262
+ font-size: var(--text-body-medium-font-size);
263
+ font-weight: var(--text-body-medium-bold-font-weight);
264
+ line-height: var(--text-body-medium-line-height);
265
+ }
266
+
267
+ .collection-preview__metadata,
268
+ .collection-preview__description {
269
+ font-size: var(--text-body-medium-font-size);
270
+ line-height: var(--text-body-medium-line-height);
271
+ color: var(--color-text-secondary);
272
+ }
273
+
274
+ .collection-preview__metadata {
275
+ overflow: hidden;
276
+ white-space: nowrap;
277
+ text-overflow: ellipsis;
278
+ }
279
+
280
+ .collection-preview__empty-card {
281
+ position: relative;
282
+ border: var(--stroke-width-small) dashed var(--color-border);
283
+ border-radius: var(--radius-large);
284
+ overflow: hidden;
285
+ }
286
+
287
+ .collection-preview__empty-card--full {
288
+ display: flex;
289
+ flex-direction: column;
290
+ align-items: center;
291
+ justify-content: center;
292
+ gap: var(--spacer-2-5);
293
+ min-block-size: var(--collection-preview-empty-height);
294
+ padding: var(--spacer-4);
295
+ text-align: center;
296
+ overflow-wrap: anywhere;
297
+ }
298
+
299
+ .collection-preview__empty-card .collection-preview__content-sizing {
300
+ border-color: transparent;
301
+ }
302
+
303
+ .collection-preview__empty-content {
304
+ position: absolute;
305
+ inset: 0;
306
+ display: flex;
307
+ flex-direction: column;
308
+ align-items: center;
309
+ justify-content: center;
310
+ gap: var(--spacer-2-5);
311
+ padding: var(--spacer-2-5);
312
+ text-align: center;
313
+ }
314
+
315
+ .collection-preview__empty-content p,
316
+ .collection-preview__empty-card--full p {
317
+ margin: 0;
318
+ color: var(--color-text-secondary);
319
+ font-size: var(--text-body-medium-font-size);
320
+ line-height: var(--text-body-medium-line-height);
321
+ }
322
+
323
+ .collection-preview__create {
324
+ max-inline-size: 100%;
325
+ block-size: auto;
326
+ min-block-size: var(--spacer-4);
327
+ }
328
+
329
+ .collection-preview__create .btn__label {
330
+ white-space: normal;
331
+ overflow-wrap: anywhere;
332
+ }
333
+ }