@payloadcms/ui 3.43.0-canary.6 → 3.43.0-internal.693bd81

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 (111) hide show
  1. package/dist/elements/AddNewRelation/index.js +8 -9
  2. package/dist/elements/AddNewRelation/index.js.map +1 -1
  3. package/dist/elements/BulkUpload/FileSidebar/index.d.ts.map +1 -1
  4. package/dist/elements/BulkUpload/FileSidebar/index.js +0 -1
  5. package/dist/elements/BulkUpload/FileSidebar/index.js.map +1 -1
  6. package/dist/elements/Drawer/index.d.ts.map +1 -1
  7. package/dist/elements/Drawer/index.js +67 -51
  8. package/dist/elements/Drawer/index.js.map +1 -1
  9. package/dist/elements/FolderView/CollectionTypePill/index.d.ts.map +1 -1
  10. package/dist/elements/FolderView/CollectionTypePill/index.js +10 -13
  11. package/dist/elements/FolderView/CollectionTypePill/index.js.map +1 -1
  12. package/dist/elements/FolderView/CurrentFolderActions/index.d.ts.map +1 -1
  13. package/dist/elements/FolderView/CurrentFolderActions/index.js +11 -17
  14. package/dist/elements/FolderView/CurrentFolderActions/index.js.map +1 -1
  15. package/dist/elements/FolderView/Drawers/EditFolderAction/index.d.ts +3 -1
  16. package/dist/elements/FolderView/Drawers/EditFolderAction/index.d.ts.map +1 -1
  17. package/dist/elements/FolderView/Drawers/EditFolderAction/index.js +4 -7
  18. package/dist/elements/FolderView/Drawers/EditFolderAction/index.js.map +1 -1
  19. package/dist/elements/FolderView/Drawers/MoveToFolder/index.d.ts +0 -1
  20. package/dist/elements/FolderView/Drawers/MoveToFolder/index.d.ts.map +1 -1
  21. package/dist/elements/FolderView/Drawers/MoveToFolder/index.js +201 -230
  22. package/dist/elements/FolderView/Drawers/MoveToFolder/index.js.map +1 -1
  23. package/dist/elements/FolderView/FolderFileCard/index.d.ts +0 -8
  24. package/dist/elements/FolderView/FolderFileCard/index.d.ts.map +1 -1
  25. package/dist/elements/FolderView/FolderFileCard/index.js +0 -82
  26. package/dist/elements/FolderView/FolderFileCard/index.js.map +1 -1
  27. package/dist/elements/FolderView/FolderFileTable/index.d.ts +22 -1
  28. package/dist/elements/FolderView/FolderFileTable/index.d.ts.map +1 -1
  29. package/dist/elements/FolderView/FolderFileTable/index.js +163 -245
  30. package/dist/elements/FolderView/FolderFileTable/index.js.map +1 -1
  31. package/dist/elements/FolderView/ItemCardGrid/index.d.ts +8 -2
  32. package/dist/elements/FolderView/ItemCardGrid/index.d.ts.map +1 -1
  33. package/dist/elements/FolderView/ItemCardGrid/index.js +90 -24
  34. package/dist/elements/FolderView/ItemCardGrid/index.js.map +1 -1
  35. package/dist/elements/FolderView/SortByPill/index.d.ts.map +1 -1
  36. package/dist/elements/FolderView/SortByPill/index.js +15 -17
  37. package/dist/elements/FolderView/SortByPill/index.js.map +1 -1
  38. package/dist/elements/ListHeader/DrawerTitleActions/ListDrawerCreateNewDocButton.js +0 -1
  39. package/dist/elements/ListHeader/DrawerTitleActions/ListDrawerCreateNewDocButton.js.map +1 -1
  40. package/dist/elements/ListHeader/TitleActions/ListCreateNewDocInFolderButton.d.ts.map +1 -1
  41. package/dist/elements/ListHeader/TitleActions/ListCreateNewDocInFolderButton.js +10 -8
  42. package/dist/elements/ListHeader/TitleActions/ListCreateNewDocInFolderButton.js.map +1 -1
  43. package/dist/elements/ListHeader/index.scss +1 -1
  44. package/dist/elements/PublishButton/ScheduleDrawer/buildUpcomingColumns.js +0 -1
  45. package/dist/elements/PublishButton/ScheduleDrawer/buildUpcomingColumns.js.map +1 -1
  46. package/dist/elements/QueryPresets/cells/ColumnsCell/index.js +0 -1
  47. package/dist/elements/QueryPresets/cells/ColumnsCell/index.js.map +1 -1
  48. package/dist/elements/QueryPresets/fields/ColumnsField/index.d.ts.map +1 -1
  49. package/dist/elements/QueryPresets/fields/ColumnsField/index.js +0 -1
  50. package/dist/elements/QueryPresets/fields/ColumnsField/index.js.map +1 -1
  51. package/dist/elements/QueryPresets/fields/WhereField/index.js +0 -1
  52. package/dist/elements/QueryPresets/fields/WhereField/index.js.map +1 -1
  53. package/dist/elements/RelationshipTable/index.d.ts +0 -1
  54. package/dist/elements/RelationshipTable/index.d.ts.map +1 -1
  55. package/dist/elements/RelationshipTable/index.js +1 -3
  56. package/dist/elements/RelationshipTable/index.js.map +1 -1
  57. package/dist/elements/SelectMany/index.d.ts.map +1 -1
  58. package/dist/elements/SelectMany/index.js +0 -1
  59. package/dist/elements/SelectMany/index.js.map +1 -1
  60. package/dist/elements/Table/index.js +2 -2
  61. package/dist/elements/Table/index.js.map +1 -1
  62. package/dist/exports/client/index.js +22 -22
  63. package/dist/exports/client/index.js.map +4 -4
  64. package/dist/exports/rsc/index.d.ts +0 -1
  65. package/dist/exports/rsc/index.d.ts.map +1 -1
  66. package/dist/exports/rsc/index.js +0 -1
  67. package/dist/exports/rsc/index.js.map +1 -1
  68. package/dist/fields/FieldLabel/index.d.ts.map +1 -1
  69. package/dist/fields/FieldLabel/index.js +1 -2
  70. package/dist/fields/FieldLabel/index.js.map +1 -1
  71. package/dist/fields/Join/index.d.ts.map +1 -1
  72. package/dist/fields/Join/index.js +0 -1
  73. package/dist/fields/Join/index.js.map +1 -1
  74. package/dist/fields/Relationship/Input.d.ts.map +1 -1
  75. package/dist/fields/Relationship/Input.js +0 -1
  76. package/dist/fields/Relationship/Input.js.map +1 -1
  77. package/dist/providers/Folders/index.d.ts +46 -59
  78. package/dist/providers/Folders/index.d.ts.map +1 -1
  79. package/dist/providers/Folders/index.js +572 -163
  80. package/dist/providers/Folders/index.js.map +1 -1
  81. package/dist/providers/ServerFunctions/index.d.ts +1 -6
  82. package/dist/providers/ServerFunctions/index.d.ts.map +1 -1
  83. package/dist/providers/ServerFunctions/index.js +0 -19
  84. package/dist/providers/ServerFunctions/index.js.map +1 -1
  85. package/dist/providers/TableColumns/buildColumnState/renderCell.d.ts.map +1 -1
  86. package/dist/providers/TableColumns/buildColumnState/renderCell.js +2 -1
  87. package/dist/providers/TableColumns/buildColumnState/renderCell.js.map +1 -1
  88. package/dist/providers/TableColumns/index.js +0 -1
  89. package/dist/providers/TableColumns/index.js.map +1 -1
  90. package/dist/styles.css +1 -1
  91. package/dist/utilities/generateFieldID.d.ts.map +1 -1
  92. package/dist/utilities/generateFieldID.js +1 -4
  93. package/dist/utilities/generateFieldID.js.map +1 -1
  94. package/dist/utilities/renderTable.js +0 -1
  95. package/dist/utilities/renderTable.js.map +1 -1
  96. package/dist/views/BrowseByFolder/index.d.ts +4 -1
  97. package/dist/views/BrowseByFolder/index.d.ts.map +1 -1
  98. package/dist/views/BrowseByFolder/index.js +158 -219
  99. package/dist/views/BrowseByFolder/index.js.map +1 -1
  100. package/dist/views/CollectionFolder/ListSelection/index.d.ts.map +1 -1
  101. package/dist/views/CollectionFolder/ListSelection/index.js +50 -25
  102. package/dist/views/CollectionFolder/ListSelection/index.js.map +1 -1
  103. package/dist/views/CollectionFolder/index.d.ts +1 -1
  104. package/dist/views/CollectionFolder/index.d.ts.map +1 -1
  105. package/dist/views/CollectionFolder/index.js +153 -186
  106. package/dist/views/CollectionFolder/index.js.map +1 -1
  107. package/package.json +4 -4
  108. package/dist/utilities/getFolderResultsComponentAndData.d.ts +0 -29
  109. package/dist/utilities/getFolderResultsComponentAndData.d.ts.map +0 -1
  110. package/dist/utilities/getFolderResultsComponentAndData.js +0 -128
  111. package/dist/utilities/getFolderResultsComponentAndData.js.map +0 -1
@@ -1,13 +1,9 @@
1
- 'use client';
2
-
3
- import { c as _c } from "react/compiler-runtime";
4
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
2
  import { getTranslation } from '@payloadcms/translations';
6
3
  import { extractID } from 'payload/shared';
7
4
  import React from 'react';
8
5
  import { DocumentIcon } from '../../../icons/Document/index.js';
9
6
  import { useConfig } from '../../../providers/Config/index.js';
10
- import { useFolder } from '../../../providers/Folders/index.js';
11
7
  import { useTranslation } from '../../../providers/Translation/index.js';
12
8
  import { formatDate } from '../../../utilities/formatDocTitle/formatDateTitle.js';
13
9
  import { ColoredFolderIcon } from '../ColoredFolderIcon/index.js';
@@ -15,257 +11,179 @@ import { DraggableTableRow } from '../DraggableTableRow/index.js';
15
11
  import { SimpleTable, TableHeader } from '../SimpleTable/index.js';
16
12
  import './index.scss';
17
13
  const baseClass = 'folder-file-table';
18
- export function FolderFileTable(t0) {
19
- const $ = _c(39);
20
- const {
21
- showRelationCell: t1
22
- } = t0;
23
- const showRelationCell = t1 === undefined ? true : t1;
24
- const {
25
- documents,
26
- focusedRowIndex,
27
- isDragging,
28
- onItemClick,
29
- onItemKeyPress,
30
- selectedItemKeys,
31
- subfolders
32
- } = useFolder();
14
+ export function FolderFileTable({
15
+ dateFormat,
16
+ disabledItems = new Set(),
17
+ documents,
18
+ focusedRowIndex,
19
+ i18n,
20
+ isMovingItems,
21
+ onRowClick,
22
+ onRowPress,
23
+ selectedItems,
24
+ showRelationCell = true,
25
+ subfolders
26
+ }) {
33
27
  const {
34
28
  config
35
29
  } = useConfig();
36
30
  const {
37
- i18n,
38
31
  t
39
32
  } = useTranslation();
40
- let t2;
41
- if ($[0] !== config || $[1] !== i18n) {
42
- t2 = () => {
43
- const map = {};
44
- config.collections.forEach(collection => {
45
- map[collection.slug] = getTranslation(collection.labels?.singular, i18n);
33
+ const [relationToMap] = React.useState(() => {
34
+ const map = {};
35
+ config.collections.forEach(collection => {
36
+ map[collection.slug] = getTranslation(collection.labels?.singular, i18n);
37
+ });
38
+ return map;
39
+ });
40
+ const [columns] = React.useState(() => {
41
+ const columnsToShow = [{
42
+ name: 'name',
43
+ label: t('general:name')
44
+ }, {
45
+ name: 'createdAt',
46
+ label: t('general:createdAt')
47
+ }, {
48
+ name: 'updatedAt',
49
+ label: t('general:updatedAt')
50
+ }];
51
+ if (showRelationCell) {
52
+ columnsToShow.push({
53
+ name: 'type',
54
+ label: t('version:type')
46
55
  });
47
- return map;
48
- };
49
- $[0] = config;
50
- $[1] = i18n;
51
- $[2] = t2;
52
- } else {
53
- t2 = $[2];
54
- }
55
- const [relationToMap] = React.useState(t2);
56
- let t3;
57
- if ($[3] !== showRelationCell || $[4] !== t) {
58
- t3 = () => {
59
- const columnsToShow = [{
60
- name: "name",
61
- label: t("general:name")
62
- }, {
63
- name: "createdAt",
64
- label: t("general:createdAt")
65
- }, {
66
- name: "updatedAt",
67
- label: t("general:updatedAt")
68
- }];
69
- if (showRelationCell) {
70
- columnsToShow.push({
71
- name: "type",
72
- label: t("version:type")
73
- });
74
- }
75
- return columnsToShow;
76
- };
77
- $[3] = showRelationCell;
78
- $[4] = t;
79
- $[5] = t3;
80
- } else {
81
- t3 = $[5];
82
- }
83
- const [columns] = React.useState(t3);
84
- let t4;
85
- if ($[6] !== columns || $[7] !== config || $[8] !== documents || $[9] !== focusedRowIndex || $[10] !== i18n || $[11] !== isDragging || $[12] !== onItemClick || $[13] !== onItemKeyPress || $[14] !== relationToMap || $[15] !== selectedItemKeys || $[16] !== subfolders) {
86
- let t5;
87
- if ($[18] !== columns || $[19] !== config || $[20] !== focusedRowIndex || $[21] !== i18n || $[22] !== isDragging || $[23] !== onItemClick || $[24] !== onItemKeyPress || $[25] !== relationToMap || $[26] !== selectedItemKeys) {
88
- t5 = (subfolder, rowIndex) => {
89
- const {
90
- itemKey,
91
- relationTo,
92
- value
93
- } = subfolder;
94
- const subfolderID = extractID(value);
95
- return _jsx(DraggableTableRow, {
96
- columns: columns.map((t6, index) => {
97
- const {
98
- name: name_0
99
- } = t6;
100
- let cellValue = "\u2014";
101
- if (name_0 === "name" && value._folderOrDocumentTitle !== undefined) {
102
- cellValue = value._folderOrDocumentTitle;
103
- }
104
- if ((name_0 === "createdAt" || name_0 === "updatedAt") && value[name_0]) {
105
- cellValue = formatDate({
106
- date: value[name_0],
107
- i18n,
108
- pattern: config.admin.dateFormat
109
- });
110
- }
111
- if (name_0 === "type") {
112
- cellValue = relationToMap[relationTo] || relationTo;
113
- }
114
- if (index === 0) {
115
- return _jsxs("span", {
116
- className: `${baseClass}__cell-with-icon`,
117
- children: [_jsx(ColoredFolderIcon, {}), cellValue]
118
- }, `${itemKey}-${name_0}`);
119
- } else {
120
- return cellValue;
121
- }
122
- }),
123
- disabled: isDragging && selectedItemKeys?.has(itemKey),
124
- dragData: {
125
- id: subfolderID,
126
- type: "folder"
127
- },
128
- id: subfolderID,
129
- isDroppable: true,
130
- isFocused: focusedRowIndex === rowIndex,
131
- isSelected: selectedItemKeys.has(itemKey),
132
- isSelecting: selectedItemKeys.size > 0,
133
- itemKey,
134
- onClick: event => {
135
- onItemClick({
136
- event,
137
- index: rowIndex,
138
- item: subfolder
139
- });
140
- },
141
- onKeyDown: event_0 => {
142
- onItemKeyPress({
143
- event: event_0,
144
- index: rowIndex,
145
- item: subfolder
146
- });
147
- }
148
- }, `${rowIndex}-${itemKey}`);
149
- };
150
- $[18] = columns;
151
- $[19] = config;
152
- $[20] = focusedRowIndex;
153
- $[21] = i18n;
154
- $[22] = isDragging;
155
- $[23] = onItemClick;
156
- $[24] = onItemKeyPress;
157
- $[25] = relationToMap;
158
- $[26] = selectedItemKeys;
159
- $[27] = t5;
160
- } else {
161
- t5 = $[27];
162
56
  }
163
- let t6;
164
- if ($[28] !== columns || $[29] !== config || $[30] !== focusedRowIndex || $[31] !== i18n || $[32] !== isDragging || $[33] !== onItemClick || $[34] !== onItemKeyPress || $[35] !== relationToMap || $[36] !== selectedItemKeys || $[37] !== subfolders.length) {
165
- t6 = (document, unadjustedIndex) => {
166
- const {
167
- itemKey: itemKey_0,
168
- relationTo: relationTo_0,
169
- value: value_0
170
- } = document;
171
- const documentID = extractID(value_0);
172
- const rowIndex_0 = unadjustedIndex + subfolders.length;
173
- return _jsx(DraggableTableRow, {
174
- columns: columns.map((t7, index_0) => {
175
- const {
176
- name: name_1
177
- } = t7;
178
- let cellValue_0 = "\u2014";
179
- if (name_1 === "name" && value_0._folderOrDocumentTitle !== undefined) {
180
- cellValue_0 = value_0._folderOrDocumentTitle;
181
- }
182
- if ((name_1 === "createdAt" || name_1 === "updatedAt") && value_0[name_1]) {
183
- cellValue_0 = formatDate({
184
- date: value_0[name_1],
185
- i18n,
186
- pattern: config.admin.dateFormat
187
- });
188
- }
189
- if (name_1 === "type") {
190
- cellValue_0 = relationToMap[relationTo_0] || relationTo_0;
191
- }
192
- if (index_0 === 0) {
193
- return _jsxs("span", {
194
- className: `${baseClass}__cell-with-icon`,
195
- children: [_jsx(DocumentIcon, {}), cellValue_0]
196
- }, `${itemKey_0}-${name_1}`);
197
- } else {
198
- return cellValue_0;
199
- }
200
- }),
201
- disabled: isDragging || selectedItemKeys?.has(itemKey_0),
202
- dragData: {
203
- id: documentID,
204
- type: "document"
205
- },
206
- id: documentID,
207
- isFocused: focusedRowIndex === rowIndex_0,
208
- isSelected: selectedItemKeys.has(itemKey_0),
209
- isSelecting: selectedItemKeys.size > 0,
210
- itemKey: itemKey_0,
211
- onClick: event_1 => {
212
- onItemClick({
213
- event: event_1,
214
- index: rowIndex_0,
215
- item: document
57
+ return columnsToShow;
58
+ });
59
+ return /*#__PURE__*/_jsx(SimpleTable, {
60
+ headerCells: columns.map(({
61
+ name,
62
+ label
63
+ }) => /*#__PURE__*/_jsx(TableHeader, {
64
+ children: label
65
+ }, name)),
66
+ tableRows: [...subfolders.map((subfolder, rowIndex) => {
67
+ const {
68
+ itemKey,
69
+ relationTo,
70
+ value
71
+ } = subfolder;
72
+ const subfolderID = extractID(value);
73
+ return /*#__PURE__*/_jsx(DraggableTableRow, {
74
+ columns: columns.map(({
75
+ name
76
+ }, index) => {
77
+ let cellValue = '—';
78
+ if (name === 'name' && value._folderOrDocumentTitle !== undefined) {
79
+ cellValue = value._folderOrDocumentTitle;
80
+ }
81
+ if ((name === 'createdAt' || name === 'updatedAt') && value[name]) {
82
+ cellValue = formatDate({
83
+ date: value[name],
84
+ i18n,
85
+ pattern: dateFormat
216
86
  });
217
- },
218
- onKeyDown: event_2 => {
219
- onItemKeyPress({
220
- event: event_2,
221
- index: rowIndex_0,
222
- item: document
87
+ }
88
+ if (name === 'type') {
89
+ cellValue = relationToMap[relationTo] || relationTo;
90
+ }
91
+ if (index === 0) {
92
+ return /*#__PURE__*/_jsxs("span", {
93
+ className: `${baseClass}__cell-with-icon`,
94
+ children: [/*#__PURE__*/_jsx(ColoredFolderIcon, {}), cellValue]
95
+ }, `${itemKey}-${name}`);
96
+ } else {
97
+ return cellValue;
98
+ }
99
+ }),
100
+ disabled: isMovingItems && selectedItems?.has(itemKey) || disabledItems?.has(itemKey),
101
+ dragData: {
102
+ id: subfolderID,
103
+ type: 'folder'
104
+ },
105
+ id: subfolderID,
106
+ isDroppable: true,
107
+ isFocused: focusedRowIndex === rowIndex,
108
+ isSelected: selectedItems.has(itemKey),
109
+ isSelecting: selectedItems.size > 0,
110
+ itemKey: itemKey,
111
+ onClick: event => {
112
+ void onRowClick({
113
+ event,
114
+ index: rowIndex,
115
+ item: subfolder
116
+ });
117
+ },
118
+ onKeyDown: event => {
119
+ void onRowPress({
120
+ event,
121
+ index: rowIndex,
122
+ item: subfolder
123
+ });
124
+ }
125
+ }, `${rowIndex}-${itemKey}`);
126
+ }), ...documents.map((document, unadjustedIndex) => {
127
+ const {
128
+ itemKey,
129
+ relationTo,
130
+ value
131
+ } = document;
132
+ const documentID = extractID(value);
133
+ const rowIndex = unadjustedIndex + subfolders.length;
134
+ return /*#__PURE__*/_jsx(DraggableTableRow, {
135
+ columns: columns.map(({
136
+ name
137
+ }, index) => {
138
+ let cellValue = '—';
139
+ if (name === 'name' && value._folderOrDocumentTitle !== undefined) {
140
+ cellValue = value._folderOrDocumentTitle;
141
+ }
142
+ if ((name === 'createdAt' || name === 'updatedAt') && value[name]) {
143
+ cellValue = formatDate({
144
+ date: value[name],
145
+ i18n,
146
+ pattern: dateFormat
223
147
  });
224
148
  }
225
- }, `${rowIndex_0}-${itemKey_0}`);
226
- };
227
- $[28] = columns;
228
- $[29] = config;
229
- $[30] = focusedRowIndex;
230
- $[31] = i18n;
231
- $[32] = isDragging;
232
- $[33] = onItemClick;
233
- $[34] = onItemKeyPress;
234
- $[35] = relationToMap;
235
- $[36] = selectedItemKeys;
236
- $[37] = subfolders.length;
237
- $[38] = t6;
238
- } else {
239
- t6 = $[38];
240
- }
241
- t4 = _jsx(SimpleTable, {
242
- headerCells: columns.map(_temp),
243
- tableRows: [...subfolders.map(t5), ...documents.map(t6)]
244
- });
245
- $[6] = columns;
246
- $[7] = config;
247
- $[8] = documents;
248
- $[9] = focusedRowIndex;
249
- $[10] = i18n;
250
- $[11] = isDragging;
251
- $[12] = onItemClick;
252
- $[13] = onItemKeyPress;
253
- $[14] = relationToMap;
254
- $[15] = selectedItemKeys;
255
- $[16] = subfolders;
256
- $[17] = t4;
257
- } else {
258
- t4 = $[17];
259
- }
260
- return t4;
261
- }
262
- function _temp(t0) {
263
- const {
264
- name,
265
- label
266
- } = t0;
267
- return _jsx(TableHeader, {
268
- children: label
269
- }, name);
149
+ if (name === 'type') {
150
+ cellValue = relationToMap[relationTo] || relationTo;
151
+ }
152
+ if (index === 0) {
153
+ return /*#__PURE__*/_jsxs("span", {
154
+ className: `${baseClass}__cell-with-icon`,
155
+ children: [/*#__PURE__*/_jsx(DocumentIcon, {}), cellValue]
156
+ }, `${itemKey}-${name}`);
157
+ } else {
158
+ return cellValue;
159
+ }
160
+ }),
161
+ disabled: isMovingItems || disabledItems?.has(itemKey),
162
+ dragData: {
163
+ id: documentID,
164
+ type: 'document'
165
+ },
166
+ id: documentID,
167
+ isFocused: focusedRowIndex === rowIndex,
168
+ isSelected: selectedItems.has(itemKey),
169
+ isSelecting: selectedItems.size > 0,
170
+ itemKey: itemKey,
171
+ onClick: event => {
172
+ void onRowClick({
173
+ event,
174
+ index: rowIndex,
175
+ item: document
176
+ });
177
+ },
178
+ onKeyDown: event => {
179
+ void onRowPress({
180
+ event,
181
+ index: rowIndex,
182
+ item: document
183
+ });
184
+ }
185
+ }, `${rowIndex}-${itemKey}`);
186
+ })]
187
+ });
270
188
  }
271
189
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["c","_c","getTranslation","extractID","React","DocumentIcon","useConfig","useFolder","useTranslation","formatDate","ColoredFolderIcon","DraggableTableRow","SimpleTable","TableHeader","baseClass","FolderFileTable","t0","$","showRelationCell","t1","undefined","documents","focusedRowIndex","isDragging","onItemClick","onItemKeyPress","selectedItemKeys","subfolders","config","i18n","t","t2","map","collections","forEach","collection","slug","labels","singular","relationToMap","useState","t3","columnsToShow","name","label","push","columns","t4","t5","subfolder","rowIndex","itemKey","relationTo","value","subfolderID","_jsx","t6","index","name_0","cellValue","_folderOrDocumentTitle","pattern","admin","dateFormat","_jsxs","className","children","disabled","has","dragData","id","type","isDroppable","isFocused","isSelected","isSelecting","size","onClick","event","item","onKeyDown","event_0","length","document","unadjustedIndex","itemKey_0","relationTo_0","value_0","documentID","rowIndex_0","t7","index_0","name_1","cellValue_0","event_1","event_2","headerCells","_temp","tableRows"],"sources":["../../../../src/elements/FolderView/FolderFileTable/index.tsx"],"sourcesContent":["'use client'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { extractID } from 'payload/shared'\nimport React from 'react'\n\nimport { DocumentIcon } from '../../../icons/Document/index.js'\nimport { useConfig } from '../../../providers/Config/index.js'\nimport { useFolder } from '../../../providers/Folders/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { formatDate } from '../../../utilities/formatDocTitle/formatDateTitle.js'\nimport { ColoredFolderIcon } from '../ColoredFolderIcon/index.js'\nimport { DraggableTableRow } from '../DraggableTableRow/index.js'\nimport { SimpleTable, TableHeader } from '../SimpleTable/index.js'\nimport './index.scss'\n\nconst baseClass = 'folder-file-table'\n\ntype Props = {\n showRelationCell?: boolean\n}\n\nexport function FolderFileTable({ showRelationCell = true }: Props) {\n const {\n documents,\n focusedRowIndex,\n isDragging,\n onItemClick,\n onItemKeyPress,\n selectedItemKeys,\n subfolders,\n } = useFolder()\n const { config } = useConfig()\n const { i18n, t } = useTranslation()\n\n const [relationToMap] = React.useState(() => {\n const map: Record<string, string> = {}\n config.collections.forEach((collection) => {\n map[collection.slug] = getTranslation(collection.labels?.singular, i18n)\n })\n return map\n })\n\n const [columns] = React.useState(() => {\n const columnsToShow = [\n {\n name: 'name',\n label: t('general:name'),\n },\n {\n name: 'createdAt',\n label: t('general:createdAt'),\n },\n {\n name: 'updatedAt',\n label: t('general:updatedAt'),\n },\n ]\n\n if (showRelationCell) {\n columnsToShow.push({\n name: 'type',\n label: t('version:type'),\n })\n }\n\n return columnsToShow\n })\n\n return (\n <SimpleTable\n headerCells={columns.map(({ name, label }) => (\n <TableHeader key={name}>{label}</TableHeader>\n ))}\n tableRows={[\n ...subfolders.map((subfolder, rowIndex) => {\n const { itemKey, relationTo, value } = subfolder\n const subfolderID = extractID(value)\n\n return (\n <DraggableTableRow\n columns={columns.map(({ name }, index) => {\n let cellValue: React.ReactNode = '—'\n if (name === 'name' && value._folderOrDocumentTitle !== undefined) {\n cellValue = value._folderOrDocumentTitle\n }\n\n if ((name === 'createdAt' || name === 'updatedAt') && value[name]) {\n cellValue = formatDate({\n date: value[name],\n i18n,\n pattern: config.admin.dateFormat,\n })\n }\n\n if (name === 'type') {\n cellValue = relationToMap[relationTo] || relationTo\n }\n\n if (index === 0) {\n return (\n <span className={`${baseClass}__cell-with-icon`} key={`${itemKey}-${name}`}>\n <ColoredFolderIcon />\n {cellValue}\n </span>\n )\n } else {\n return cellValue\n }\n })}\n disabled={isDragging && selectedItemKeys?.has(itemKey)}\n dragData={{\n id: subfolderID,\n type: 'folder',\n }}\n id={subfolderID}\n isDroppable\n isFocused={focusedRowIndex === rowIndex}\n isSelected={selectedItemKeys.has(itemKey)}\n isSelecting={selectedItemKeys.size > 0}\n itemKey={itemKey}\n key={`${rowIndex}-${itemKey}`}\n onClick={(event) => {\n void onItemClick({\n event,\n index: rowIndex,\n item: subfolder,\n })\n }}\n onKeyDown={(event) => {\n void onItemKeyPress({\n event,\n index: rowIndex,\n item: subfolder,\n })\n }}\n />\n )\n }),\n\n ...documents.map((document, unadjustedIndex) => {\n const { itemKey, relationTo, value } = document\n const documentID = extractID(value)\n const rowIndex = unadjustedIndex + subfolders.length\n\n return (\n <DraggableTableRow\n columns={columns.map(({ name }, index) => {\n let cellValue: React.ReactNode = '—'\n if (name === 'name' && value._folderOrDocumentTitle !== undefined) {\n cellValue = value._folderOrDocumentTitle\n }\n\n if ((name === 'createdAt' || name === 'updatedAt') && value[name]) {\n cellValue = formatDate({\n date: value[name],\n i18n,\n pattern: config.admin.dateFormat,\n })\n }\n\n if (name === 'type') {\n cellValue = relationToMap[relationTo] || relationTo\n }\n\n if (index === 0) {\n return (\n <span className={`${baseClass}__cell-with-icon`} key={`${itemKey}-${name}`}>\n <DocumentIcon />\n {cellValue}\n </span>\n )\n } else {\n return cellValue\n }\n })}\n disabled={isDragging || selectedItemKeys?.has(itemKey)}\n dragData={{\n id: documentID,\n type: 'document',\n }}\n id={documentID}\n isFocused={focusedRowIndex === rowIndex}\n isSelected={selectedItemKeys.has(itemKey)}\n isSelecting={selectedItemKeys.size > 0}\n itemKey={itemKey}\n key={`${rowIndex}-${itemKey}`}\n onClick={(event) => {\n void onItemClick({\n event,\n index: rowIndex,\n item: document,\n })\n }}\n onKeyDown={(event) => {\n void onItemKeyPress({\n event,\n index: rowIndex,\n item: document,\n })\n }}\n />\n )\n }),\n ]}\n />\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAEA,SAASC,cAAc,QAAQ;AAC/B,SAASC,SAAS,QAAQ;AAC1B,OAAOC,KAAA,MAAW;AAElB,SAASC,YAAY,QAAQ;AAC7B,SAASC,SAAS,QAAQ;AAC1B,SAASC,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAC/B,SAASC,UAAU,QAAQ;AAC3B,SAASC,iBAAiB,QAAQ;AAClC,SAASC,iBAAiB,QAAQ;AAClC,SAASC,WAAW,EAAEC,WAAW,QAAQ;AACzC,OAAO;AAEP,MAAMC,SAAA,GAAY;AAMlB,OAAO,SAAAC,gBAA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AAAqD,KAAA,EACHA,OAAA;cAAArB,KAAA,EACOP,UAAA;cAAA6B,IAAA,EACDI;YAAA,CACR;UAAA;QAAA,GAbG,GAAGjC,UAAA,IAAYC,SAAA,EAAS;MAAA;MAiBnClC,CAAA,OAAA6B,OAAA;MAAA7B,CAAA,OAAAW,MAAA;MAAAX,CAAA,OAAAK,eAAA;MAAAL,CAAA,OAAAY,IAAA;MAAAZ,CAAA,OAAAM,UAAA;MAAAN,CAAA,OAAAO,WAAA;MAAAP,CAAA,OAAAQ,cAAA;MAAAR,CAAA,OAAAsB,aAAA;MAAAtB,CAAA,OAAAS,gBAAA;MAAAT,CAAA,OAAAU,UAAA,CAAAuD,MAAA;MAAAjE,CAAA,OAAAuC,EAAA;IAAA;MAAAA,EAAA,GAAAvC,CAAA;IAAA;IArIJ8B,EAAA,GAAAQ,IAAA,CAAA3C,WAAA;MAAAoF,WAAA,EACelD,OAAA,CAAAd,GAAA,CAAAiE,KACO;MAAAC,SAAA,MAGfvE,UAAA,CAAAK,GAAA,CAAegB,EA+DlB,MAEG3B,SAAA,CAAAW,GAAA,CAAcwB,EA+DjB;IAAA,C;;;;;;;;;;;;;;;;SArIJT,E;;AAhDG,SAAAkD,MAAAjF,EAAA;EAiDyB;IAAA2B,IAAA;IAAAC;EAAA,IAAA5B,EAAe;EAAA,OACvCuC,IAAA,CAAA1C,WAAA;IAAAqD,QAAA,EAAyBtB;EAAA,GAAPD,IAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["getTranslation","extractID","React","DocumentIcon","useConfig","useTranslation","formatDate","ColoredFolderIcon","DraggableTableRow","SimpleTable","TableHeader","baseClass","FolderFileTable","dateFormat","disabledItems","Set","documents","focusedRowIndex","i18n","isMovingItems","onRowClick","onRowPress","selectedItems","showRelationCell","subfolders","config","t","relationToMap","useState","map","collections","forEach","collection","slug","labels","singular","columns","columnsToShow","name","label","push","_jsx","headerCells","tableRows","subfolder","rowIndex","itemKey","relationTo","value","subfolderID","index","cellValue","_folderOrDocumentTitle","undefined","date","pattern","_jsxs","className","disabled","has","dragData","id","type","isDroppable","isFocused","isSelected","isSelecting","size","onClick","event","item","onKeyDown","document","unadjustedIndex","documentID","length"],"sources":["../../../../src/elements/FolderView/FolderFileTable/index.tsx"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type { FolderDocumentItemKey, FolderOrDocument } from 'payload/shared'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { extractID } from 'payload/shared'\nimport React from 'react'\n\nimport type { FormatDateArgs } from '../../../utilities/formatDocTitle/formatDateTitle.js'\n\nimport { DocumentIcon } from '../../../icons/Document/index.js'\nimport { useConfig } from '../../../providers/Config/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { formatDate } from '../../../utilities/formatDocTitle/formatDateTitle.js'\nimport { ColoredFolderIcon } from '../ColoredFolderIcon/index.js'\nimport { DraggableTableRow } from '../DraggableTableRow/index.js'\nimport { SimpleTable, TableHeader } from '../SimpleTable/index.js'\nimport './index.scss'\n\nconst baseClass = 'folder-file-table'\n\ntype Props = {\n dateFormat: FormatDateArgs['pattern']\n disabledItems?: Set<FolderDocumentItemKey>\n documents: FolderOrDocument[]\n focusedRowIndex: number\n i18n: I18nClient\n isMovingItems: boolean\n onRowClick: (args: {\n event: React.MouseEvent<Element>\n index: number\n item: FolderOrDocument\n }) => void\n onRowPress: (args: {\n event: React.KeyboardEvent<Element>\n index: number\n item: FolderOrDocument\n }) => void\n selectedItems: Set<FolderDocumentItemKey>\n showRelationCell?: boolean\n subfolders: FolderOrDocument[]\n}\n\nexport function FolderFileTable({\n dateFormat,\n disabledItems = new Set(),\n documents,\n focusedRowIndex,\n i18n,\n isMovingItems,\n onRowClick,\n onRowPress,\n selectedItems,\n showRelationCell = true,\n subfolders,\n}: Props) {\n const { config } = useConfig()\n const { t } = useTranslation()\n\n const [relationToMap] = React.useState(() => {\n const map: Record<string, string> = {}\n config.collections.forEach((collection) => {\n map[collection.slug] = getTranslation(collection.labels?.singular, i18n)\n })\n return map\n })\n\n const [columns] = React.useState(() => {\n const columnsToShow = [\n {\n name: 'name',\n label: t('general:name'),\n },\n {\n name: 'createdAt',\n label: t('general:createdAt'),\n },\n {\n name: 'updatedAt',\n label: t('general:updatedAt'),\n },\n ]\n\n if (showRelationCell) {\n columnsToShow.push({\n name: 'type',\n label: t('version:type'),\n })\n }\n\n return columnsToShow\n })\n\n return (\n <SimpleTable\n headerCells={columns.map(({ name, label }) => (\n <TableHeader key={name}>{label}</TableHeader>\n ))}\n tableRows={[\n ...subfolders.map((subfolder, rowIndex) => {\n const { itemKey, relationTo, value } = subfolder\n const subfolderID = extractID(value)\n\n return (\n <DraggableTableRow\n columns={columns.map(({ name }, index) => {\n let cellValue: React.ReactNode = '—'\n if (name === 'name' && value._folderOrDocumentTitle !== undefined) {\n cellValue = value._folderOrDocumentTitle\n }\n\n if ((name === 'createdAt' || name === 'updatedAt') && value[name]) {\n cellValue = formatDate({ date: value[name], i18n, pattern: dateFormat })\n }\n\n if (name === 'type') {\n cellValue = relationToMap[relationTo] || relationTo\n }\n\n if (index === 0) {\n return (\n <span className={`${baseClass}__cell-with-icon`} key={`${itemKey}-${name}`}>\n <ColoredFolderIcon />\n {cellValue}\n </span>\n )\n } else {\n return cellValue\n }\n })}\n disabled={\n (isMovingItems && selectedItems?.has(itemKey)) || disabledItems?.has(itemKey)\n }\n dragData={{\n id: subfolderID,\n type: 'folder',\n }}\n id={subfolderID}\n isDroppable\n isFocused={focusedRowIndex === rowIndex}\n isSelected={selectedItems.has(itemKey)}\n isSelecting={selectedItems.size > 0}\n itemKey={itemKey}\n key={`${rowIndex}-${itemKey}`}\n onClick={(event) => {\n void onRowClick({\n event,\n index: rowIndex,\n item: subfolder,\n })\n }}\n onKeyDown={(event) => {\n void onRowPress({\n event,\n index: rowIndex,\n item: subfolder,\n })\n }}\n />\n )\n }),\n\n ...documents.map((document, unadjustedIndex) => {\n const { itemKey, relationTo, value } = document\n const documentID = extractID(value)\n const rowIndex = unadjustedIndex + subfolders.length\n\n return (\n <DraggableTableRow\n columns={columns.map(({ name }, index) => {\n let cellValue: React.ReactNode = '—'\n if (name === 'name' && value._folderOrDocumentTitle !== undefined) {\n cellValue = value._folderOrDocumentTitle\n }\n\n if ((name === 'createdAt' || name === 'updatedAt') && value[name]) {\n cellValue = formatDate({ date: value[name], i18n, pattern: dateFormat })\n }\n\n if (name === 'type') {\n cellValue = relationToMap[relationTo] || relationTo\n }\n\n if (index === 0) {\n return (\n <span className={`${baseClass}__cell-with-icon`} key={`${itemKey}-${name}`}>\n <DocumentIcon />\n {cellValue}\n </span>\n )\n } else {\n return cellValue\n }\n })}\n disabled={isMovingItems || disabledItems?.has(itemKey)}\n dragData={{\n id: documentID,\n type: 'document',\n }}\n id={documentID}\n isFocused={focusedRowIndex === rowIndex}\n isSelected={selectedItems.has(itemKey)}\n isSelecting={selectedItems.size > 0}\n itemKey={itemKey}\n key={`${rowIndex}-${itemKey}`}\n onClick={(event) => {\n void onRowClick({\n event,\n index: rowIndex,\n item: document,\n })\n }}\n onKeyDown={(event) => {\n void onRowPress({\n event,\n index: rowIndex,\n item: document,\n })\n }}\n />\n )\n }),\n ]}\n />\n )\n}\n"],"mappings":";AAGA,SAASA,cAAc,QAAQ;AAC/B,SAASC,SAAS,QAAQ;AAC1B,OAAOC,KAAA,MAAW;AAIlB,SAASC,YAAY,QAAQ;AAC7B,SAASC,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAC/B,SAASC,UAAU,QAAQ;AAC3B,SAASC,iBAAiB,QAAQ;AAClC,SAASC,iBAAiB,QAAQ;AAClC,SAASC,WAAW,EAAEC,WAAW,QAAQ;AACzC,OAAO;AAEP,MAAMC,SAAA,GAAY;AAwBlB,OAAO,SAASC,gBAAgB;EAC9BC,UAAU;EACVC,aAAA,GAAgB,IAAIC,GAAA,EAAK;EACzBC,SAAS;EACTC,eAAe;EACfC,IAAI;EACJC,aAAa;EACbC,UAAU;EACVC,UAAU;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A,OACAgD,SAAA;eAFmD,GAAGL,OAAA,IAAWR,IAAA,EAAM;UAK9E,OAAO;YACL,OAAOa,SAAA;UACT;QACF;QACAO,QAAA,EAAUvC,aAAA,IAAiBL,aAAA,EAAe6C,GAAA,CAAIb,OAAA;QAC9Cc,QAAA,EAAU;UACRC,EAAA,EAAIa,UAAA;UACJZ,IAAA,EAAM;QACR;QACAD,EAAA,EAAIa,UAAA;QACJV,SAAA,EAAW/C,eAAA,KAAoB4B,QAAA;QAC/BoB,UAAA,EAAY3C,aAAA,CAAcqC,GAAG,CAACb,OAAA;QAC9BoB,WAAA,EAAa5C,aAAA,CAAc6C,IAAI,GAAG;QAClCrB,OAAA,EAASA,OAAA;QAETsB,OAAA,EAAUC,KAAA;UACR,KAAKjD,UAAA,CAAW;YACdiD,KAAA;YACAnB,KAAA,EAAOL,QAAA;YACPyB,IAAA,EAAME;UACR;QACF;QACAD,SAAA,EAAYF,KAAA;UACV,KAAKhD,UAAA,CAAW;YACdgD,KAAA;YACAnB,KAAA,EAAOL,QAAA;YACPyB,IAAA,EAAME;UACR;QACF;SAdK,GAAG3B,QAAA,IAAYC,OAAA,EAAS;IAiBnC;;AAIR","ignoreList":[]}
@@ -1,8 +1,14 @@
1
- import type { FolderOrDocument } from 'payload/shared';
1
+ import type { FolderDocumentItemKey, FolderOrDocument } from 'payload/shared';
2
2
  import React from 'react';
3
3
  import './index.scss';
4
4
  type ItemCardGridProps = {
5
+ disabledItemKeys?: Set<FolderDocumentItemKey>;
5
6
  items: FolderOrDocument[];
7
+ RenderActionGroup?: (args: {
8
+ index: number;
9
+ item: FolderOrDocument;
10
+ }) => React.ReactNode;
11
+ selectedItemKeys: Set<FolderDocumentItemKey>;
6
12
  title?: string;
7
13
  } & ({
8
14
  subfolderCount: number;
@@ -11,6 +17,6 @@ type ItemCardGridProps = {
11
17
  subfolderCount?: never;
12
18
  type: 'folder';
13
19
  });
14
- export declare function ItemCardGrid({ type, items, subfolderCount, title }: ItemCardGridProps): React.JSX.Element;
20
+ export declare function ItemCardGrid({ type, disabledItemKeys, items, RenderActionGroup, selectedItemKeys, subfolderCount, title, }: ItemCardGridProps): React.JSX.Element;
15
21
  export {};
16
22
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/elements/FolderView/ItemCardGrid/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAEtD,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,cAAc,CAAA;AAIrB,KAAK,iBAAiB,GAAG;IACvB,KAAK,EAAE,gBAAgB,EAAE,CAAA;IACzB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,GAAG,CACA;IACE,cAAc,EAAE,MAAM,CAAA;IACtB,IAAI,EAAE,MAAM,CAAA;CACb,GACD;IACE,cAAc,CAAC,EAAE,KAAK,CAAA;IACtB,IAAI,EAAE,QAAQ,CAAA;CACf,CACJ,CAAA;AACD,wBAAgB,YAAY,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,EAAE,iBAAiB,qBAgBrF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/elements/FolderView/ItemCardGrid/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAE7E,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,cAAc,CAAA;AAIrB,KAAK,iBAAiB,GAAG;IACvB,gBAAgB,CAAC,EAAE,GAAG,CAAC,qBAAqB,CAAC,CAAA;IAC7C,KAAK,EAAE,gBAAgB,EAAE,CAAA;IACzB,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,gBAAgB,CAAA;KAAE,KAAK,KAAK,CAAC,SAAS,CAAA;IACxF,gBAAgB,EAAE,GAAG,CAAC,qBAAqB,CAAC,CAAA;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,GAAG,CACA;IACE,cAAc,EAAE,MAAM,CAAA;IACtB,IAAI,EAAE,MAAM,CAAA;CACb,GACD;IACE,cAAc,CAAC,EAAE,KAAK,CAAA;IACtB,IAAI,EAAE,QAAQ,CAAA;CACf,CACJ,CAAA;AACD,wBAAgB,YAAY,CAAC,EAC3B,IAAI,EACJ,gBAAgB,EAChB,KAAK,EACL,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,KAAK,GACN,EAAE,iBAAiB,qBA+CnB"}
@@ -1,34 +1,100 @@
1
1
  'use client';
2
2
 
3
+ import { c as _c } from "react/compiler-runtime";
3
4
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
4
5
  import React from 'react';
5
- import { ContextFolderFileCard } from '../FolderFileCard/index.js';
6
+ import { useFolder } from '../../../providers/Folders/index.js';
7
+ import { FolderFileCard } from '../FolderFileCard/index.js';
6
8
  import './index.scss';
7
9
  const baseClass = 'item-card-grid';
8
- export function ItemCardGrid({
9
- type,
10
- items,
11
- subfolderCount,
12
- title
13
- }) {
14
- return /*#__PURE__*/_jsxs(_Fragment, {
15
- children: [title && /*#__PURE__*/_jsx("p", {
10
+ export function ItemCardGrid(t0) {
11
+ const $ = _c(15);
12
+ const {
13
+ type,
14
+ disabledItemKeys,
15
+ items,
16
+ RenderActionGroup,
17
+ selectedItemKeys,
18
+ subfolderCount,
19
+ title
20
+ } = t0;
21
+ const {
22
+ focusedRowIndex,
23
+ isDragging,
24
+ onItemClick,
25
+ onItemKeyPress,
26
+ selectedIndexes
27
+ } = useFolder();
28
+ let t1;
29
+ if ($[0] !== title) {
30
+ t1 = title && _jsx("p", {
16
31
  className: `${baseClass}__title`,
17
32
  children: title
18
- }), /*#__PURE__*/_jsx("div", {
19
- className: baseClass,
20
- children: !items || items?.length === 0 ? null : items.map((item, _index) => {
21
- const index = _index + (subfolderCount || 0);
22
- const {
23
- itemKey
24
- } = item;
25
- return /*#__PURE__*/_jsx(ContextFolderFileCard, {
26
- index: index,
27
- item: item,
28
- type: type
29
- }, itemKey);
30
- })
31
- })]
32
- });
33
+ });
34
+ $[0] = title;
35
+ $[1] = t1;
36
+ } else {
37
+ t1 = $[1];
38
+ }
39
+ let t2;
40
+ if ($[2] !== RenderActionGroup || $[3] !== disabledItemKeys || $[4] !== focusedRowIndex || $[5] !== isDragging || $[6] !== items || $[7] !== onItemClick || $[8] !== onItemKeyPress || $[9] !== selectedIndexes || $[10] !== selectedItemKeys || $[11] !== subfolderCount || $[12] !== t1 || $[13] !== type) {
41
+ t2 = _jsxs(_Fragment, {
42
+ children: [t1, _jsx("div", {
43
+ className: baseClass,
44
+ children: !items || items?.length === 0 ? null : items.map((item, _index) => {
45
+ const index = _index + (subfolderCount || 0);
46
+ const {
47
+ itemKey,
48
+ value
49
+ } = item;
50
+ return _jsx(FolderFileCard, {
51
+ disabled: isDragging && selectedItemKeys.has(itemKey) || disabledItemKeys?.has(itemKey),
52
+ id: value.id,
53
+ isFocused: focusedRowIndex === index,
54
+ isSelected: selectedItemKeys.has(itemKey),
55
+ itemKey,
56
+ onClick: event => {
57
+ onItemClick({
58
+ event,
59
+ index,
60
+ item
61
+ });
62
+ },
63
+ onKeyDown: event_0 => {
64
+ onItemKeyPress({
65
+ event: event_0,
66
+ index,
67
+ item
68
+ });
69
+ },
70
+ PopupActions: RenderActionGroup ? RenderActionGroup({
71
+ index,
72
+ item
73
+ }) : null,
74
+ previewUrl: value?.url,
75
+ selectedCount: selectedIndexes.size,
76
+ title: value._folderOrDocumentTitle,
77
+ type
78
+ }, itemKey);
79
+ })
80
+ })]
81
+ });
82
+ $[2] = RenderActionGroup;
83
+ $[3] = disabledItemKeys;
84
+ $[4] = focusedRowIndex;
85
+ $[5] = isDragging;
86
+ $[6] = items;
87
+ $[7] = onItemClick;
88
+ $[8] = onItemKeyPress;
89
+ $[9] = selectedIndexes;
90
+ $[10] = selectedItemKeys;
91
+ $[11] = subfolderCount;
92
+ $[12] = t1;
93
+ $[13] = type;
94
+ $[14] = t2;
95
+ } else {
96
+ t2 = $[14];
97
+ }
98
+ return t2;
33
99
  }
34
100
  //# sourceMappingURL=index.js.map