@strapi/upload 5.1.1 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/dist/_chunks/{index-BCVXHM2B.js → index-BM9Ayh_r.js} +2 -2
  2. package/dist/_chunks/{index-BCVXHM2B.js.map → index-BM9Ayh_r.js.map} +1 -1
  3. package/dist/_chunks/{index-BVvzCEIn.mjs → index-BWIqjWzC.mjs} +2 -2
  4. package/dist/_chunks/{index-BVvzCEIn.mjs.map → index-BWIqjWzC.mjs.map} +1 -1
  5. package/dist/_chunks/{index-CuoYgn99.js → index-Bl2-6oC8.js} +21 -22
  6. package/dist/_chunks/index-Bl2-6oC8.js.map +1 -0
  7. package/dist/_chunks/{index-LM-DLJqd.mjs → index-BwEfHu6y.mjs} +1079 -1595
  8. package/dist/_chunks/index-BwEfHu6y.mjs.map +1 -0
  9. package/dist/_chunks/{index-Cu0crkx4.js → index-C1MSWEyZ.js} +2 -2
  10. package/dist/_chunks/{index-Cu0crkx4.js.map → index-C1MSWEyZ.js.map} +1 -1
  11. package/dist/_chunks/{index-CAg5RL9X.mjs → index-C_cWV2yS.mjs} +2 -2
  12. package/dist/_chunks/{index-CAg5RL9X.mjs.map → index-C_cWV2yS.mjs.map} +1 -1
  13. package/dist/_chunks/{index-24xAAxoi.mjs → index-DCAQ4hHN.mjs} +21 -22
  14. package/dist/_chunks/index-DCAQ4hHN.mjs.map +1 -0
  15. package/dist/_chunks/{index-Cni0ouV8.js → index-YwynuEzj.js} +1077 -1593
  16. package/dist/_chunks/index-YwynuEzj.js.map +1 -0
  17. package/dist/admin/index.js +1 -1
  18. package/dist/admin/index.mjs +1 -1
  19. package/dist/admin/src/components/AssetCard/AssetCard.d.ts +18 -0
  20. package/dist/admin/src/components/AssetCard/AssetCardBase.d.ts +14 -0
  21. package/dist/admin/src/components/AssetCard/AudioAssetCard.d.ts +7 -0
  22. package/dist/admin/src/components/AssetCard/AudioPreview.d.ts +6 -0
  23. package/dist/admin/src/components/AssetCard/DocAssetCard.d.ts +7 -0
  24. package/dist/admin/src/components/AssetCard/ImageAssetCard.d.ts +12 -0
  25. package/dist/admin/src/components/AssetCard/UploadingAssetCard.d.ts +17 -0
  26. package/dist/admin/src/components/AssetCard/VideoAssetCard.d.ts +8 -0
  27. package/dist/admin/src/components/AssetCard/VideoPreview.d.ts +9 -0
  28. package/dist/admin/src/components/AssetDialog/BrowseStep/Filters.d.ts +23 -0
  29. package/dist/admin/src/components/AssetDialog/BrowseStep/PageSize.d.ts +6 -0
  30. package/dist/admin/src/components/AssetDialog/BrowseStep/PaginationFooter/Pagination.d.ts +9 -0
  31. package/dist/admin/src/components/AssetDialog/BrowseStep/PaginationFooter/PaginationContext.d.ts +9 -0
  32. package/dist/admin/src/components/AssetDialog/BrowseStep/PaginationFooter/components.d.ts +15 -0
  33. package/dist/admin/src/components/AssetDialog/BrowseStep/PaginationFooter/index.d.ts +9 -0
  34. package/dist/admin/src/components/AssetDialog/BrowseStep/SearchAsset/index.d.ts +7 -0
  35. package/dist/admin/src/components/AssetDialog/BrowseStep/index.d.ts +63 -0
  36. package/dist/admin/src/components/AssetDialog/BrowseStep/utils/isSelectable.d.ts +1 -0
  37. package/dist/admin/src/components/AssetDialog/DialogFooter.d.ts +6 -0
  38. package/dist/admin/src/components/AssetDialog/SelectedStep/index.d.ts +8 -0
  39. package/dist/admin/src/components/AssetDialog/index.d.ts +39 -0
  40. package/dist/admin/src/components/AssetGridList/Draggable.d.ts +9 -0
  41. package/dist/admin/src/components/AssetGridList/index.d.ts +14 -0
  42. package/dist/admin/src/components/Breadcrumbs/Breadcrumbs.d.ts +15 -0
  43. package/dist/admin/src/components/Breadcrumbs/CrumbSimpleMenuAsync.d.ts +7 -0
  44. package/dist/admin/src/components/Breadcrumbs/index.d.ts +1 -0
  45. package/dist/admin/src/components/BulkMoveDialog/BulkMoveDialog.d.ts +15 -0
  46. package/dist/admin/src/components/BulkMoveDialog/index.d.ts +1 -0
  47. package/dist/admin/src/components/ContextInfo/ContextInfo.d.ts +8 -0
  48. package/dist/admin/src/components/ContextInfo/index.d.ts +1 -0
  49. package/dist/admin/src/components/CopyLinkButton/index.d.ts +3 -0
  50. package/dist/admin/src/components/EditAssetDialog/DialogHeader.d.ts +1 -0
  51. package/dist/admin/src/components/EditAssetDialog/PreviewBox/AssetPreview.d.ts +9 -0
  52. package/dist/admin/src/components/EditAssetDialog/PreviewBox/CroppingActions.d.ts +7 -0
  53. package/dist/admin/src/components/EditAssetDialog/PreviewBox/components.d.ts +17 -0
  54. package/dist/admin/src/components/EditAssetDialog/PreviewBox/index.d.ts +23 -0
  55. package/dist/admin/src/components/EditAssetDialog/RemoveAssetDialog.d.ts +8 -0
  56. package/dist/admin/src/components/EditAssetDialog/ReplaceMediaButton.d.ts +8 -0
  57. package/dist/admin/src/components/EditAssetDialog/index.d.ts +28 -0
  58. package/dist/admin/src/components/EditFolderDialog/EditFolderDialog.d.ts +10 -0
  59. package/dist/admin/src/components/EditFolderDialog/ModalHeader/ModalHeader.d.ts +5 -0
  60. package/dist/admin/src/components/EditFolderDialog/ModalHeader/index.d.ts +2 -0
  61. package/dist/admin/src/components/EditFolderDialog/RemoveFolderDialog.d.ts +7 -0
  62. package/dist/admin/src/components/EditFolderDialog/index.d.ts +1 -0
  63. package/dist/admin/src/components/EmptyAssets/EmptyAssetGrid.d.ts +6 -0
  64. package/dist/admin/src/components/EmptyAssets/index.d.ts +10 -0
  65. package/dist/admin/src/components/FilterList/FilterTag.d.ts +23 -0
  66. package/dist/admin/src/components/FilterList/index.d.ts +33 -0
  67. package/dist/admin/src/components/FilterPopover/FilterValueInput.d.ts +12 -0
  68. package/dist/admin/src/components/FilterPopover/index.d.ts +31 -0
  69. package/dist/admin/src/components/FilterPopover/utils/getFilterList.d.ts +21 -0
  70. package/dist/admin/src/components/FolderCard/FolderCard/FolderCard.d.ts +13 -0
  71. package/dist/admin/src/components/FolderCard/FolderCard/index.d.ts +1 -0
  72. package/dist/admin/src/components/FolderCard/FolderCardBody/FolderCardBody.d.ts +2 -0
  73. package/dist/admin/src/components/FolderCard/FolderCardBody/index.d.ts +1 -0
  74. package/dist/admin/src/components/FolderCard/FolderCardBodyAction/index.d.ts +7 -0
  75. package/dist/admin/src/components/FolderCard/FolderCardCheckbox/FolderCardCheckbox.d.ts +2 -0
  76. package/dist/admin/src/components/FolderCard/FolderCardCheckbox/index.d.ts +1 -0
  77. package/dist/admin/src/components/FolderCard/contexts/FolderCard.d.ts +7 -0
  78. package/dist/admin/src/components/FolderCard/index.d.ts +4 -0
  79. package/dist/admin/src/components/FolderGridList/FolderGridList.d.ts +7 -0
  80. package/dist/admin/src/components/FolderGridList/index.d.ts +1 -0
  81. package/dist/admin/src/components/MediaLibraryDialog/index.d.ts +9 -0
  82. package/dist/admin/src/components/MediaLibraryInput/Carousel/CarouselAsset.d.ts +4 -0
  83. package/dist/admin/src/components/MediaLibraryInput/Carousel/CarouselAssetActions.d.ts +9 -0
  84. package/dist/admin/src/components/MediaLibraryInput/Carousel/CarouselAssets.d.ts +22 -0
  85. package/dist/admin/src/components/MediaLibraryInput/Carousel/EmptyStateAsset.d.ts +10 -0
  86. package/dist/admin/src/components/MediaLibraryInput/index.d.ts +17 -0
  87. package/dist/admin/src/components/SelectTree/Option.d.ts +16 -0
  88. package/dist/admin/src/components/SelectTree/SelectTree.d.ts +23 -0
  89. package/dist/admin/src/components/SelectTree/index.d.ts +2 -0
  90. package/dist/admin/src/components/SelectTree/utils/getOpenValues.d.ts +9 -0
  91. package/dist/admin/src/components/SelectTree/utils/getValuesToClose.d.ts +6 -0
  92. package/dist/admin/src/components/SortPicker/index.d.ts +7 -0
  93. package/dist/admin/src/components/TableList/CellContent.d.ts +8 -0
  94. package/dist/admin/src/components/TableList/PreviewCell.d.ts +7 -0
  95. package/dist/admin/src/components/TableList/TableRows.d.ts +22 -0
  96. package/dist/admin/src/components/TableList/index.d.ts +31 -0
  97. package/dist/admin/src/components/UploadAssetDialog/AddAssetStep/AddAssetStep.d.ts +13 -0
  98. package/dist/admin/src/components/UploadAssetDialog/AddAssetStep/FromComputerForm.d.ts +8 -0
  99. package/dist/admin/src/components/UploadAssetDialog/AddAssetStep/FromUrlForm.d.ts +8 -0
  100. package/dist/admin/src/components/UploadAssetDialog/PendingAssetStep/PendingAssetStep.d.ts +22 -0
  101. package/dist/admin/src/components/UploadAssetDialog/UploadAssetDialog.d.ts +21 -0
  102. package/dist/admin/src/components/UploadProgress/index.d.ts +7 -0
  103. package/dist/admin/src/hooks/useBulkMove.d.ts +5 -5
  104. package/dist/admin/src/hooks/useBulkRemove.d.ts +17 -20
  105. package/dist/admin/src/hooks/useEditAsset.d.ts +4 -4
  106. package/dist/admin/src/hooks/useEditFolder.d.ts +4 -4
  107. package/dist/admin/src/hooks/useFolder.d.ts +1 -1
  108. package/dist/admin/src/hooks/useFolderStructure.d.ts +7 -1
  109. package/dist/admin/src/hooks/useMediaLibraryPermissions.d.ts +5 -1
  110. package/dist/admin/src/hooks/useModalQueryParams.d.ts +1 -1
  111. package/dist/admin/src/hooks/useUpload.d.ts +7 -4
  112. package/dist/admin/src/newConstants.d.ts +24 -0
  113. package/dist/admin/src/utils/findRecursiveFolderByValue.d.ts +3 -2
  114. package/dist/admin/src/utils/getAllowedFiles.d.ts +1 -2
  115. package/dist/admin/src/utils/getBreadcrumbDataCM.d.ts +1 -1
  116. package/dist/admin/src/utils/getFolderParents.d.ts +4 -3
  117. package/dist/admin/src/utils/moveElement.d.ts +1 -1
  118. package/dist/admin/src/utils/urlsToAssets.d.ts +1 -1
  119. package/dist/shared/contracts/files.d.ts +10 -6
  120. package/dist/shared/contracts/folders.d.ts +23 -2
  121. package/package.json +8 -8
  122. package/dist/_chunks/index-24xAAxoi.mjs.map +0 -1
  123. package/dist/_chunks/index-Cni0ouV8.js.map +0 -1
  124. package/dist/_chunks/index-CuoYgn99.js.map +0 -1
  125. package/dist/_chunks/index-LM-DLJqd.mjs.map +0 -1
@@ -1,17 +1,16 @@
1
1
  import { ChevronUp, ChevronDown, Cross, CaretDown, Link, FilePdf, File as File$1, Check, Trash, Download, Crop, Pencil, Folder, Eye, CaretUp, Plus, Filter, ChevronLeft, ChevronRight, Search, List, GridFour, PlusCircle, Images } from "@strapi/icons";
2
2
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
- import { useMemo, useState, useEffect, forwardRef, useRef, createElement, createContext, useContext, useLayoutEffect } from "react";
5
- import PropTypes from "prop-types";
6
- import { translatedErrors, useNotification, useFetchClient, useRBAC, useTracking, useClipboard, ConfirmDialog, useQueryParams, Layouts, Page, useField } from "@strapi/admin/strapi-admin";
4
+ import { useState, useEffect, createContext, useContext } from "react";
5
+ import { useNotification, useFetchClient, translatedErrors, useRBAC, useTracking, useClipboard, ConfirmDialog, useQueryParams, Layouts, Page, useField } from "@strapi/admin/strapi-admin";
7
6
  import { useNotifyAT, Box, Grid, Flex, Typography, Modal, IconButton, ProgressBar, Dialog, Badge, Menu, FocusTrap, Button, VisuallyHidden, Loader, Field, TextInput, CardAction, Card as Card$1, CardHeader, CardCheckbox, CardBody, CardContent, CardTitle, CardSubtitle, CardBadge, CardAsset as CardAsset$2, CardTimer, KeyboardNavigable, CrumbSimpleMenu, MenuItem, Breadcrumbs as Breadcrumbs$1, CrumbLink, Crumb, SingleSelect, SingleSelectOption, Avatar, Tbody, Tr, Td, Checkbox, Table, Thead, Th, Tooltip, Tag, DateTimePicker, Popover, SearchForm, Searchbar, Divider, Tabs, Textarea, CarouselActions, CarouselInput, CarouselSlide } from "@strapi/design-system";
8
7
  import { useIntl } from "react-intl";
9
- import { styled, useTheme } from "styled-components";
8
+ import { styled, useTheme, css } from "styled-components";
9
+ import { useQuery, useMutation, useQueryClient } from "react-query";
10
+ import { stringify } from "qs";
10
11
  import byteSize from "byte-size";
11
12
  import { intervalToDuration } from "date-fns";
12
- import { stringify } from "qs";
13
13
  import * as yup from "yup";
14
- import { useQuery, useMutation, useQueryClient } from "react-query";
15
14
  import { Formik, Form } from "formik";
16
15
  import isEqual from "lodash/isEqual";
17
16
  import ReactSelect, { components } from "react-select";
@@ -22,6 +21,7 @@ import { useDrop, useDrag } from "react-dnd";
22
21
  import { useLocation, NavLink, Link as Link$1 } from "react-router-dom";
23
22
  import { EmptyDocuments } from "@strapi/icons/symbols";
24
23
  import parseISO from "date-fns/parseISO";
24
+ import PropTypes from "prop-types";
25
25
  const __variableDynamicImportRuntimeHelper = (glob, path) => {
26
26
  const v = glob[path];
27
27
  if (v) {
@@ -32,7 +32,7 @@ const __variableDynamicImportRuntimeHelper = (glob, path) => {
32
32
  });
33
33
  };
34
34
  const name$1 = "@strapi/upload";
35
- const version = "5.1.0";
35
+ const version = "5.2.0";
36
36
  const description = "Makes it easy to upload images and files to your Strapi Application.";
37
37
  const license = "SEE LICENSE IN LICENSE";
38
38
  const author = {
@@ -88,8 +88,8 @@ const scripts = {
88
88
  watch: "pack-up watch"
89
89
  };
90
90
  const dependencies = {
91
- "@strapi/design-system": "2.0.0-rc.11",
92
- "@strapi/icons": "2.0.0-rc.11",
91
+ "@strapi/design-system": "2.0.0-rc.12",
92
+ "@strapi/icons": "2.0.0-rc.12",
93
93
  "@strapi/provider-upload-local": "workspace:*",
94
94
  "@strapi/utils": "workspace:*",
95
95
  "byte-size": "8.1.1",
@@ -167,6 +167,148 @@ const pluginPkg = {
167
167
  engines,
168
168
  strapi
169
169
  };
170
+ const pluginId = pluginPkg.name.replace(/^@strapi\//i, "");
171
+ const useAssets = ({ skipWhen = false, query = {} } = {}) => {
172
+ const { formatMessage } = useIntl();
173
+ const { toggleNotification } = useNotification();
174
+ const { notifyStatus } = useNotifyAT();
175
+ const { get } = useFetchClient();
176
+ const { folderPath, _q, ...paramsExceptFolderAndQ } = query;
177
+ let params;
178
+ if (_q) {
179
+ params = {
180
+ ...paramsExceptFolderAndQ,
181
+ _q: encodeURIComponent(_q)
182
+ };
183
+ } else {
184
+ params = {
185
+ ...paramsExceptFolderAndQ,
186
+ filters: {
187
+ $and: [
188
+ ...paramsExceptFolderAndQ?.filters?.$and ?? [],
189
+ {
190
+ folderPath: { $eq: folderPath ?? "/" }
191
+ }
192
+ ]
193
+ }
194
+ };
195
+ }
196
+ const { data, error, isLoading } = useQuery(
197
+ [pluginId, "assets", params],
198
+ async () => {
199
+ const { data: data2 } = await get("/upload/files", { params });
200
+ return data2;
201
+ },
202
+ {
203
+ enabled: !skipWhen,
204
+ staleTime: 0,
205
+ cacheTime: 0,
206
+ select(data2) {
207
+ if (data2?.results && Array.isArray(data2.results)) {
208
+ return {
209
+ ...data2,
210
+ results: data2.results.filter((asset) => asset.name).map((asset) => ({
211
+ ...asset,
212
+ /**
213
+ * Mime and ext cannot be null in the front-end because
214
+ * we expect them to be strings and use the `includes` method.
215
+ */
216
+ mime: asset.mime ?? "",
217
+ ext: asset.ext ?? ""
218
+ }))
219
+ };
220
+ }
221
+ return data2;
222
+ }
223
+ }
224
+ );
225
+ React.useEffect(() => {
226
+ if (data) {
227
+ notifyStatus(
228
+ formatMessage({
229
+ id: "list.asset.at.finished",
230
+ defaultMessage: "The assets have finished loading."
231
+ })
232
+ );
233
+ }
234
+ }, [data, formatMessage, notifyStatus]);
235
+ React.useEffect(() => {
236
+ if (error) {
237
+ toggleNotification({
238
+ type: "danger",
239
+ message: formatMessage({ id: "notification.error" })
240
+ });
241
+ }
242
+ }, [error, formatMessage, toggleNotification]);
243
+ return { data, error, isLoading };
244
+ };
245
+ const useFolders = ({ enabled = true, query = {} } = {}) => {
246
+ const { formatMessage } = useIntl();
247
+ const { toggleNotification } = useNotification();
248
+ const { notifyStatus } = useNotifyAT();
249
+ const { folder, _q, ...paramsExceptFolderAndQ } = query;
250
+ const { get } = useFetchClient();
251
+ let params;
252
+ if (_q) {
253
+ params = {
254
+ ...paramsExceptFolderAndQ,
255
+ pagination: {
256
+ pageSize: -1
257
+ },
258
+ _q
259
+ };
260
+ } else {
261
+ params = {
262
+ ...paramsExceptFolderAndQ,
263
+ pagination: {
264
+ pageSize: -1
265
+ },
266
+ filters: {
267
+ $and: [
268
+ ...paramsExceptFolderAndQ?.filters?.$and ?? [],
269
+ {
270
+ parent: {
271
+ id: folder ?? {
272
+ $null: true
273
+ }
274
+ }
275
+ }
276
+ ]
277
+ }
278
+ };
279
+ }
280
+ const { data, error, isLoading } = useQuery(
281
+ [pluginId, "folders", stringify(params)],
282
+ async () => {
283
+ const {
284
+ data: { data: data2 }
285
+ } = await get("/upload/folders", { params });
286
+ return data2;
287
+ },
288
+ {
289
+ enabled,
290
+ staleTime: 0,
291
+ cacheTime: 0,
292
+ onError() {
293
+ toggleNotification({
294
+ type: "danger",
295
+ message: formatMessage({ id: "notification.error" })
296
+ });
297
+ }
298
+ }
299
+ );
300
+ React.useEffect(() => {
301
+ if (data) {
302
+ notifyStatus(
303
+ formatMessage({
304
+ id: "list.asset.at.finished",
305
+ defaultMessage: "The folders have finished loading."
306
+ })
307
+ );
308
+ }
309
+ }, [data, formatMessage, notifyStatus]);
310
+ return { data, error, isLoading };
311
+ };
170
312
  const appendSearchParamsToUrl = ({ url, params }) => {
171
313
  if (url === void 0 || typeof params !== "object") {
172
314
  return url;
@@ -336,8 +478,7 @@ function getAPIInnerErrors(error, { getTrad: getTrad2 }) {
336
478
  }
337
479
  return normalizedError?.defaultMessage;
338
480
  }
339
- const pluginId = pluginPkg.name.replace(/^@strapi\//i, "");
340
- const getTrad = (id2) => `${pluginId}.${id2}`;
481
+ const getTrad = (id) => `${pluginId}.${id}`;
341
482
  const getBreadcrumbDataCM = (folder) => {
342
483
  let data = [
343
484
  {
@@ -417,68 +558,17 @@ const prefixPluginTranslations = (trad, pluginId2) => {
417
558
  return acc;
418
559
  }, {});
419
560
  };
420
- var AssetType$1 = /* @__PURE__ */ ((AssetType2) => {
421
- AssetType2["Video"] = "video";
422
- AssetType2["Image"] = "image";
423
- AssetType2["Document"] = "doc";
424
- AssetType2["Audio"] = "audio";
425
- return AssetType2;
426
- })(AssetType$1 || {});
427
- var AssetSource$1 = /* @__PURE__ */ ((AssetSource2) => {
428
- AssetSource2["Url"] = "url";
429
- AssetSource2["Computer"] = "computer";
430
- return AssetSource2;
431
- })(AssetSource$1 || {});
432
- const PERMISSIONS$1 = {
433
- // This permission regards the main component (App) and is used to tell
434
- // If the plugin link should be displayed in the menu
435
- // And also if the plugin is accessible. This use case is found when a user types the url of the
436
- // plugin directly in the browser
437
- main: [
438
- { action: "plugin::upload.read", subject: null },
439
- {
440
- action: "plugin::upload.assets.create",
441
- subject: null
442
- },
443
- {
444
- action: "plugin::upload.assets.update",
445
- subject: null
446
- }
447
- ],
448
- copyLink: [
449
- {
450
- action: "plugin::upload.assets.copy-link",
451
- subject: null
452
- }
453
- ],
454
- create: [
455
- {
456
- action: "plugin::upload.assets.create",
457
- subject: null
458
- }
459
- ],
460
- download: [
461
- {
462
- action: "plugin::upload.assets.download",
463
- subject: null
464
- }
465
- ],
466
- read: [{ action: "plugin::upload.read", subject: null }],
467
- configureView: [{ action: "plugin::upload.configure-view", subject: null }],
468
- settings: [{ action: "plugin::upload.settings.read", subject: null }],
469
- update: [{ action: "plugin::upload.assets.update", subject: null, fields: null }]
470
- };
471
561
  const typeFromMime = (mime) => {
472
- if (mime.includes(AssetType$1.Image)) {
473
- return AssetType$1.Image;
562
+ if (mime.includes(AssetType.Image)) {
563
+ return AssetType.Image;
474
564
  }
475
- if (mime.includes(AssetType$1.Video)) {
476
- return AssetType$1.Video;
565
+ if (mime.includes(AssetType.Video)) {
566
+ return AssetType.Video;
477
567
  }
478
- if (mime.includes(AssetType$1.Audio)) {
479
- return AssetType$1.Audio;
568
+ if (mime.includes(AssetType.Audio)) {
569
+ return AssetType.Audio;
480
570
  }
481
- return AssetType$1.Document;
571
+ return AssetType.Document;
482
572
  };
483
573
  const rawFileToAsset = (rawFile, assetSource) => {
484
574
  return {
@@ -514,12 +604,12 @@ const urlsToAssets = async (urls) => {
514
604
  );
515
605
  const assetsResults = await Promise.all(assetPromises);
516
606
  const assets = assetsResults.map((fullFilledAsset) => ({
517
- source: AssetSource$1.Url,
607
+ source: AssetSource.Url,
518
608
  name: fullFilledAsset.name,
519
609
  type: typeFromMime(fullFilledAsset.mime),
520
610
  url: fullFilledAsset.url,
521
611
  ext: fullFilledAsset.url.split(".").pop(),
522
- mime: fullFilledAsset.mime,
612
+ mime: fullFilledAsset.mime ? fullFilledAsset.mime : void 0,
523
613
  rawFile: fullFilledAsset.rawFile
524
614
  }));
525
615
  return assets;
@@ -564,91 +654,56 @@ const urlSchema = yup.object().shape({
564
654
  }
565
655
  })
566
656
  });
567
- const AssetType = {
568
- Video: "video",
569
- Image: "image",
570
- Document: "doc",
571
- Audio: "audio"
572
- };
573
- const AssetSource = {
574
- Url: "url",
575
- Computer: "computer"
576
- };
577
- const ParentFolderShape = {
578
- id: PropTypes.number.isRequired,
579
- createdAt: PropTypes.string.isRequired,
580
- name: PropTypes.string.isRequired,
581
- updatedAt: PropTypes.string.isRequired,
582
- pathId: PropTypes.number.isRequired,
583
- path: PropTypes.string.isRequired
584
- };
585
- ParentFolderShape.parent = PropTypes.shape(ParentFolderShape);
586
- const FolderShape = {
587
- id: PropTypes.number,
588
- children: PropTypes.shape({
589
- count: PropTypes.number.isRequired
590
- }),
591
- createdAt: PropTypes.string,
592
- createdBy: PropTypes.shape(),
593
- files: PropTypes.shape({
594
- count: PropTypes.number.isRequired
595
- }),
596
- name: PropTypes.string,
597
- updatedAt: PropTypes.string,
598
- updatedBy: PropTypes.shape(),
599
- pathId: PropTypes.number,
600
- path: PropTypes.string
601
- };
602
- FolderShape.parent = PropTypes.shape(ParentFolderShape);
603
- const FolderDefinition = PropTypes.shape(FolderShape);
604
- const FolderStructure = PropTypes.shape({
605
- value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
606
- label: PropTypes.string.isRequired,
607
- children: PropTypes.array
608
- });
609
- FolderStructure.children = PropTypes.arrayOf(PropTypes.shape(FolderStructure));
610
- FolderStructure.defaultProps = {
611
- children: void 0
612
- };
613
- PropTypes.arrayOf(FolderStructure);
614
- const AssetDefinition = PropTypes.shape({
615
- id: PropTypes.number,
616
- height: PropTypes.number,
617
- width: PropTypes.number,
618
- size: PropTypes.number,
619
- createdAt: PropTypes.string,
620
- ext: PropTypes.string,
621
- mime: PropTypes.string,
622
- name: PropTypes.string,
623
- url: PropTypes.string,
624
- updatedAt: PropTypes.string,
625
- alternativeText: PropTypes.string,
626
- caption: PropTypes.string,
627
- folder: PropTypes.shape(FolderDefinition),
628
- formats: PropTypes.shape({
629
- thumbnail: PropTypes.shape({
630
- url: PropTypes.string
631
- })
632
- })
633
- });
634
- const CrumbDefinition = PropTypes.shape({
635
- id: PropTypes.number,
636
- label: PropTypes.oneOfType([
637
- PropTypes.string,
638
- PropTypes.shape({
639
- id: PropTypes.string.isRequired,
640
- defaultMessage: PropTypes.string.isRequired
641
- })
642
- ]).isRequired,
643
- href: PropTypes.string
644
- });
645
- const CrumbMenuDefinition = PropTypes.arrayOf(CrumbDefinition);
646
- const BreadcrumbsDefinition = PropTypes.arrayOf(
647
- PropTypes.oneOfType([CrumbDefinition, CrumbMenuDefinition])
648
- );
649
- const viewOptions = {
650
- GRID: 0,
651
- LIST: 1
657
+ var AssetType = /* @__PURE__ */ ((AssetType2) => {
658
+ AssetType2["Video"] = "video";
659
+ AssetType2["Image"] = "image";
660
+ AssetType2["Document"] = "doc";
661
+ AssetType2["Audio"] = "audio";
662
+ return AssetType2;
663
+ })(AssetType || {});
664
+ var AssetSource = /* @__PURE__ */ ((AssetSource2) => {
665
+ AssetSource2["Url"] = "url";
666
+ AssetSource2["Computer"] = "computer";
667
+ return AssetSource2;
668
+ })(AssetSource || {});
669
+ const PERMISSIONS$1 = {
670
+ // This permission regards the main component (App) and is used to tell
671
+ // If the plugin link should be displayed in the menu
672
+ // And also if the plugin is accessible. This use case is found when a user types the url of the
673
+ // plugin directly in the browser
674
+ main: [
675
+ { action: "plugin::upload.read", subject: null },
676
+ {
677
+ action: "plugin::upload.assets.create",
678
+ subject: null
679
+ },
680
+ {
681
+ action: "plugin::upload.assets.update",
682
+ subject: null
683
+ }
684
+ ],
685
+ copyLink: [
686
+ {
687
+ action: "plugin::upload.assets.copy-link",
688
+ subject: null
689
+ }
690
+ ],
691
+ create: [
692
+ {
693
+ action: "plugin::upload.assets.create",
694
+ subject: null
695
+ }
696
+ ],
697
+ download: [
698
+ {
699
+ action: "plugin::upload.assets.download",
700
+ subject: null
701
+ }
702
+ ],
703
+ read: [{ action: "plugin::upload.read", subject: null }],
704
+ configureView: [{ action: "plugin::upload.configure-view", subject: null }],
705
+ settings: [{ action: "plugin::upload.settings.read", subject: null }],
706
+ update: [{ action: "plugin::upload.assets.update", subject: null, fields: null }]
652
707
  };
653
708
  const tableHeaders = [
654
709
  {
@@ -694,210 +749,33 @@ const tableHeaders = [
694
749
  label: { id: getTrad("list.table.header.createdAt"), defaultMessage: "created" },
695
750
  isSortable: true
696
751
  },
697
- type: "date"
698
- },
699
- {
700
- name: "updatedAt",
701
- key: "updatedAt",
702
- metadatas: {
703
- label: { id: getTrad("list.table.header.updatedAt"), defaultMessage: "last update" },
704
- isSortable: true
705
- },
706
- type: "date"
707
- }
708
- ];
709
- const pageSizes = [10, 20, 50, 100];
710
- const sortOptions = [
711
- { key: "sort.created_at_desc", value: "createdAt:DESC" },
712
- { key: "sort.created_at_asc", value: "createdAt:ASC" },
713
- { key: "sort.name_asc", value: "name:ASC" },
714
- { key: "sort.name_desc", value: "name:DESC" },
715
- { key: "sort.updated_at_desc", value: "updatedAt:DESC" },
716
- { key: "sort.updated_at_asc", value: "updatedAt:ASC" }
717
- ];
718
- const localStorageKeys = {
719
- modalView: `STRAPI_UPLOAD_MODAL_VIEW`,
720
- view: `STRAPI_UPLOAD_LIBRARY_VIEW`
721
- };
722
- const PERMISSIONS = {
723
- // This permission regards the main component (App) and is used to tell
724
- // If the plugin link should be displayed in the menu
725
- // And also if the plugin is accessible. This use case is found when a user types the url of the
726
- // plugin directly in the browser
727
- main: [
728
- { action: "plugin::upload.read", subject: null },
729
- {
730
- action: "plugin::upload.assets.create",
731
- subject: null
732
- },
733
- {
734
- action: "plugin::upload.assets.update",
735
- subject: null
736
- }
737
- ],
738
- copyLink: [
739
- {
740
- action: "plugin::upload.assets.copy-link",
741
- subject: null
742
- }
743
- ],
744
- create: [
745
- {
746
- action: "plugin::upload.assets.create",
747
- subject: null
748
- }
749
- ],
750
- download: [
751
- {
752
- action: "plugin::upload.assets.download",
753
- subject: null
754
- }
755
- ],
756
- read: [{ action: "plugin::upload.read", subject: null }],
757
- configureView: [{ action: "plugin::upload.configure-view", subject: null }],
758
- settings: [{ action: "plugin::upload.settings.read", subject: null }],
759
- update: [{ action: "plugin::upload.assets.update", subject: null, fields: null }]
760
- };
761
- const useAssets = ({ skipWhen = false, query = {} } = {}) => {
762
- const { formatMessage } = useIntl();
763
- const { toggleNotification } = useNotification();
764
- const { notifyStatus } = useNotifyAT();
765
- const { get } = useFetchClient();
766
- const { folderPath, _q, ...paramsExceptFolderAndQ } = query;
767
- let params;
768
- if (_q) {
769
- params = {
770
- ...paramsExceptFolderAndQ,
771
- _q: encodeURIComponent(_q)
772
- };
773
- } else {
774
- params = {
775
- ...paramsExceptFolderAndQ,
776
- filters: {
777
- $and: [
778
- ...paramsExceptFolderAndQ?.filters?.$and ?? [],
779
- {
780
- folderPath: { $eq: folderPath ?? "/" }
781
- }
782
- ]
783
- }
784
- };
785
- }
786
- const { data, error, isLoading } = useQuery(
787
- [pluginId, "assets", params],
788
- async () => {
789
- const { data: data2 } = await get("/upload/files", { params });
790
- return data2;
791
- },
792
- {
793
- enabled: !skipWhen,
794
- staleTime: 0,
795
- cacheTime: 0,
796
- select(data2) {
797
- if (data2?.results && Array.isArray(data2.results)) {
798
- return {
799
- ...data2,
800
- results: data2.results.filter((asset) => asset.name).map((asset) => ({
801
- ...asset,
802
- /**
803
- * Mime and ext cannot be null in the front-end because
804
- * we expect them to be strings and use the `includes` method.
805
- */
806
- mime: asset.mime ?? "",
807
- ext: asset.ext ?? ""
808
- }))
809
- };
810
- }
811
- return data2;
812
- }
813
- }
814
- );
815
- React.useEffect(() => {
816
- if (data) {
817
- notifyStatus(
818
- formatMessage({
819
- id: "list.asset.at.finished",
820
- defaultMessage: "The assets have finished loading."
821
- })
822
- );
823
- }
824
- }, [data, formatMessage, notifyStatus]);
825
- React.useEffect(() => {
826
- if (error) {
827
- toggleNotification({
828
- type: "danger",
829
- message: formatMessage({ id: "notification.error" })
830
- });
831
- }
832
- }, [error, formatMessage, toggleNotification]);
833
- return { data, error, isLoading };
834
- };
835
- const useFolders = ({ enabled = true, query = {} } = {}) => {
836
- const { formatMessage } = useIntl();
837
- const { toggleNotification } = useNotification();
838
- const { notifyStatus } = useNotifyAT();
839
- const { folder, _q, ...paramsExceptFolderAndQ } = query;
840
- const { get } = useFetchClient();
841
- let params;
842
- if (_q) {
843
- params = {
844
- ...paramsExceptFolderAndQ,
845
- pagination: {
846
- pageSize: -1
847
- },
848
- _q
849
- };
850
- } else {
851
- params = {
852
- ...paramsExceptFolderAndQ,
853
- pagination: {
854
- pageSize: -1
855
- },
856
- filters: {
857
- $and: [
858
- ...paramsExceptFolderAndQ?.filters?.$and ?? [],
859
- {
860
- parent: {
861
- id: folder ?? {
862
- $null: true
863
- }
864
- }
865
- }
866
- ]
867
- }
868
- };
869
- }
870
- const { data, error, isLoading } = useQuery(
871
- [pluginId, "folders", stringify(params)],
872
- async () => {
873
- const {
874
- data: { data: data2 }
875
- } = await get("/upload/folders", { params });
876
- return data2;
877
- },
878
- {
879
- enabled,
880
- staleTime: 0,
881
- cacheTime: 0,
882
- onError() {
883
- toggleNotification({
884
- type: "danger",
885
- message: formatMessage({ id: "notification.error" })
886
- });
887
- }
888
- }
889
- );
890
- React.useEffect(() => {
891
- if (data) {
892
- notifyStatus(
893
- formatMessage({
894
- id: "list.asset.at.finished",
895
- defaultMessage: "The folders have finished loading."
896
- })
897
- );
898
- }
899
- }, [data, formatMessage, notifyStatus]);
900
- return { data, error, isLoading };
752
+ type: "date"
753
+ },
754
+ {
755
+ name: "updatedAt",
756
+ key: "updatedAt",
757
+ metadatas: {
758
+ label: { id: getTrad("list.table.header.updatedAt"), defaultMessage: "last update" },
759
+ isSortable: true
760
+ },
761
+ type: "date"
762
+ }
763
+ ];
764
+ const sortOptions$1 = [
765
+ { key: "sort.created_at_desc", value: "createdAt:DESC" },
766
+ { key: "sort.created_at_asc", value: "createdAt:ASC" },
767
+ { key: "sort.name_asc", value: "name:ASC" },
768
+ { key: "sort.name_desc", value: "name:DESC" },
769
+ { key: "sort.updated_at_desc", value: "updatedAt:DESC" },
770
+ { key: "sort.updated_at_asc", value: "updatedAt:ASC" }
771
+ ];
772
+ const localStorageKeys$1 = {
773
+ modalView: `STRAPI_UPLOAD_MODAL_VIEW`,
774
+ view: `STRAPI_UPLOAD_LIBRARY_VIEW`
775
+ };
776
+ const viewOptions$1 = {
777
+ GRID: 0,
778
+ LIST: 1
901
779
  };
902
780
  const { main, ...restPermissions } = PERMISSIONS$1;
903
781
  const useMediaLibraryPermissions = () => {
@@ -1197,14 +1075,6 @@ const ContextInfo = ({ blocks }) => {
1197
1075
  }
1198
1076
  );
1199
1077
  };
1200
- ContextInfo.propTypes = {
1201
- blocks: PropTypes.arrayOf(
1202
- PropTypes.shape({
1203
- label: PropTypes.string,
1204
- value: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
1205
- })
1206
- ).isRequired
1207
- };
1208
1078
  const ToggleButton = styled(Flex)`
1209
1079
  align-self: flex-end;
1210
1080
  height: 2.2rem;
@@ -1221,9 +1091,9 @@ const Option = ({ children, data, selectProps, ...props }) => {
1221
1091
  const { maxDisplayDepth, openValues, onOptionToggle } = selectProps;
1222
1092
  const isOpen = openValues.includes(value);
1223
1093
  const Icon = isOpen ? ChevronUp : ChevronDown;
1224
- return /* @__PURE__ */ jsx(components.Option, { ...props, children: /* @__PURE__ */ jsxs(Flex, { alignItems: "start", children: [
1094
+ return /* @__PURE__ */ jsx(components.Option, { data, selectProps, ...props, children: /* @__PURE__ */ jsxs(Flex, { alignItems: "start", children: [
1225
1095
  /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", ellipsis: true, children: /* @__PURE__ */ jsx("span", { style: { paddingLeft: `${Math.min(depth, maxDisplayDepth) * 14}px` }, children }) }),
1226
- options?.length > 0 && /* @__PURE__ */ jsx(
1096
+ options && options?.length > 0 && /* @__PURE__ */ jsx(
1227
1097
  ToggleButton,
1228
1098
  {
1229
1099
  "aria-label": formatMessage({
@@ -1245,16 +1115,6 @@ const Option = ({ children, data, selectProps, ...props }) => {
1245
1115
  )
1246
1116
  ] }) });
1247
1117
  };
1248
- Option.propTypes = {
1249
- children: PropTypes.node.isRequired,
1250
- data: PropTypes.object.isRequired,
1251
- onToggle: PropTypes.func.isRequired,
1252
- selectProps: PropTypes.shape({
1253
- maxDisplayDepth: PropTypes.number,
1254
- openValues: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])),
1255
- onOptionToggle: PropTypes.func
1256
- }).isRequired
1257
- };
1258
1118
  function getOpenValues(options, defaultValue = {}) {
1259
1119
  let values = [];
1260
1120
  const { value } = defaultValue;
@@ -1266,6 +1126,9 @@ function getOpenValues(options, defaultValue = {}) {
1266
1126
  let { parent } = option;
1267
1127
  while (parent !== void 0) {
1268
1128
  const option2 = options.find(({ value: value2 }) => value2 === parent);
1129
+ if (!option2) {
1130
+ break;
1131
+ }
1269
1132
  values.push(option2.value);
1270
1133
  parent = option2.parent;
1271
1134
  }
@@ -1273,15 +1136,28 @@ function getOpenValues(options, defaultValue = {}) {
1273
1136
  }
1274
1137
  function getValuesToClose(options, value) {
1275
1138
  const optionForValue = options.find((option) => option.value === value);
1139
+ if (!optionForValue) {
1140
+ return [];
1141
+ }
1276
1142
  return options.filter((option) => option.depth >= optionForValue.depth).map((option) => option.value);
1277
1143
  }
1278
1144
  const hasParent = (option) => !option.parent;
1279
- const SelectTree = ({ options: defaultOptions, maxDisplayDepth, defaultValue, ...props }) => {
1280
- const flatDefaultOptions = useMemo(() => flattenTree(defaultOptions), [defaultOptions]);
1281
- const optionsFiltered = useMemo(() => flatDefaultOptions.filter(hasParent), [flatDefaultOptions]);
1282
- const [options, setOptions] = useState(optionsFiltered);
1283
- const [openValues, setOpenValues] = useState(getOpenValues(flatDefaultOptions, defaultValue));
1284
- useEffect(() => {
1145
+ const SelectTree = ({
1146
+ options: defaultOptions,
1147
+ maxDisplayDepth = 5,
1148
+ defaultValue,
1149
+ ...props
1150
+ }) => {
1151
+ const flatDefaultOptions = React.useMemo(() => flattenTree(defaultOptions), [defaultOptions]);
1152
+ const optionsFiltered = React.useMemo(
1153
+ () => flatDefaultOptions.filter(hasParent),
1154
+ [flatDefaultOptions]
1155
+ );
1156
+ const [options, setOptions] = React.useState(optionsFiltered);
1157
+ const [openValues, setOpenValues] = React.useState(
1158
+ getOpenValues(flatDefaultOptions, defaultValue)
1159
+ );
1160
+ React.useEffect(() => {
1285
1161
  if (openValues.length === 0) {
1286
1162
  setOptions(flatDefaultOptions.filter((option) => option.parent === void 0));
1287
1163
  } else {
@@ -1323,7 +1199,13 @@ const SelectTree = ({ options: defaultOptions, maxDisplayDepth, defaultValue, ..
1323
1199
  }
1324
1200
  );
1325
1201
  };
1326
- const Select = ({ components: components2, styles, error, ariaErrorMessage, ...props }) => {
1202
+ const Select = ({
1203
+ components: components2 = {},
1204
+ styles = {},
1205
+ error,
1206
+ ariaErrorMessage,
1207
+ ...props
1208
+ }) => {
1327
1209
  const theme = useTheme();
1328
1210
  const customStyles = getSelectStyles(theme, error);
1329
1211
  return /* @__PURE__ */ jsx(
@@ -1331,11 +1213,11 @@ const Select = ({ components: components2, styles, error, ariaErrorMessage, ...p
1331
1213
  {
1332
1214
  menuPosition: "fixed",
1333
1215
  components: {
1216
+ ...components2,
1334
1217
  ClearIndicator,
1335
1218
  DropdownIndicator,
1336
1219
  IndicatorSeparator: () => null,
1337
- LoadingIndicator: () => null,
1338
- ...components2
1220
+ LoadingIndicator: () => null
1339
1221
  },
1340
1222
  "aria-errormessage": error && ariaErrorMessage,
1341
1223
  "aria-invalid": !!error,
@@ -1344,18 +1226,6 @@ const Select = ({ components: components2, styles, error, ariaErrorMessage, ...p
1344
1226
  }
1345
1227
  );
1346
1228
  };
1347
- Select.defaultProps = {
1348
- ariaErrorMessage: "",
1349
- components: {},
1350
- error: void 0,
1351
- styles: {}
1352
- };
1353
- Select.propTypes = {
1354
- components: PropTypes.object,
1355
- styles: PropTypes.object,
1356
- error: PropTypes.string,
1357
- ariaErrorMessage: PropTypes.string
1358
- };
1359
1229
  const IconBox = styled(Box)`
1360
1230
  background: transparent;
1361
1231
  border: none;
@@ -1385,13 +1255,7 @@ const CarretBox = styled(IconBox)`
1385
1255
  }
1386
1256
  `;
1387
1257
  const DropdownIndicator = ({ innerProps }) => {
1388
- return (
1389
- // @ts-expect-error – issue with the ref attached to `innerProps`
1390
- /* @__PURE__ */ jsx(CarretBox, { paddingRight: 3, ...innerProps, children: /* @__PURE__ */ jsx(CaretDown, {}) })
1391
- );
1392
- };
1393
- DropdownIndicator.propTypes = {
1394
- innerProps: PropTypes.object.isRequired
1258
+ return /* @__PURE__ */ jsx(CarretBox, { paddingRight: 3, ...innerProps, children: /* @__PURE__ */ jsx(CaretDown, {}) });
1395
1259
  };
1396
1260
  const getSelectStyles = (theme, error) => {
1397
1261
  return {
@@ -1403,8 +1267,8 @@ const getSelectStyles = (theme, error) => {
1403
1267
  }),
1404
1268
  control(base, state) {
1405
1269
  let borderColor = theme.colors.neutral200;
1406
- let boxShadowColor;
1407
- let backgroundColor;
1270
+ let boxShadowColor = void 0;
1271
+ let backgroundColor = void 0;
1408
1272
  if (state.isFocused) {
1409
1273
  borderColor = theme.colors.primary600;
1410
1274
  boxShadowColor = theme.colors.primary600;
@@ -1460,7 +1324,7 @@ const getSelectStyles = (theme, error) => {
1460
1324
  paddingBottom: theme.spaces[1]
1461
1325
  }),
1462
1326
  option(base, state) {
1463
- let backgroundColor = base.backgroundColor;
1327
+ let backgroundColor = base?.backgroundColor;
1464
1328
  if (state.isFocused || state.isSelected) {
1465
1329
  backgroundColor = theme.colors.primary100;
1466
1330
  }
@@ -1501,26 +1365,6 @@ const getSelectStyles = (theme, error) => {
1501
1365
  })
1502
1366
  };
1503
1367
  };
1504
- const OptionShape = PropTypes.shape({
1505
- value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
1506
- label: PropTypes.string.isRequired,
1507
- children: PropTypes.array
1508
- });
1509
- OptionShape.children = PropTypes.arrayOf(PropTypes.shape(OptionShape));
1510
- OptionShape.defaultProps = {
1511
- children: void 0
1512
- };
1513
- SelectTree.defaultProps = {
1514
- defaultValue: void 0,
1515
- maxDisplayDepth: 5
1516
- };
1517
- SelectTree.propTypes = {
1518
- defaultValue: PropTypes.shape({
1519
- value: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
1520
- }),
1521
- maxDisplayDepth: PropTypes.number,
1522
- options: PropTypes.arrayOf(OptionShape).isRequired
1523
- };
1524
1368
  const DialogHeader = () => {
1525
1369
  const { formatMessage } = useIntl();
1526
1370
  return /* @__PURE__ */ jsx(Modal.Header, { children: /* @__PURE__ */ jsx(Modal.Title, { children: formatMessage({ id: "global.details", defaultMessage: "Details" }) }) });
@@ -1634,6 +1478,7 @@ const useUpload = () => {
1634
1478
  const cancel = () => abortController.abort();
1635
1479
  return {
1636
1480
  upload,
1481
+ isLoading: mutation.isLoading,
1637
1482
  cancel,
1638
1483
  error: mutation.error,
1639
1484
  progress,
@@ -1668,9 +1513,6 @@ const CopyLinkButton = ({ url }) => {
1668
1513
  }
1669
1514
  );
1670
1515
  };
1671
- CopyLinkButton.propTypes = {
1672
- url: PropTypes.string.isRequired
1673
- };
1674
1516
  const BoxWrapper = styled(Flex)`
1675
1517
  border-radius: ${({ theme }) => `${theme.borderRadius} ${theme.borderRadius} 0 0`};
1676
1518
  width: 100%;
@@ -1702,10 +1544,11 @@ const CancelButton = styled.button`
1702
1544
  }
1703
1545
  }
1704
1546
  `;
1705
- const UploadProgress = ({ onCancel, progress, error }) => {
1547
+ const UploadProgress = ({ onCancel, progress = 0, error }) => {
1706
1548
  const { formatMessage } = useIntl();
1707
1549
  return /* @__PURE__ */ jsx(BoxWrapper, { alignItems: "center", background: error ? "danger100" : "neutral150", error, children: error ? /* @__PURE__ */ jsx(Cross, { "aria-label": error?.message }) : /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "center", gap: 2, width: "100%", children: [
1708
- /* @__PURE__ */ jsx(ProgressBar, { value: progress, children: `${progress}/100%` }),
1550
+ /* @__PURE__ */ jsx(ProgressBar, { value: progress }),
1551
+ /* @__PURE__ */ jsx(Typography, { children: `${progress}/100%` }),
1709
1552
  /* @__PURE__ */ jsx(CancelButton, { type: "button", onClick: onCancel, children: /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
1710
1553
  /* @__PURE__ */ jsx(Typography, { variant: "pi", tag: "span", textColor: "inherit", children: formatMessage({
1711
1554
  id: "app.components.Button.cancel",
@@ -1715,15 +1558,6 @@ const UploadProgress = ({ onCancel, progress, error }) => {
1715
1558
  ] }) })
1716
1559
  ] }) });
1717
1560
  };
1718
- UploadProgress.defaultProps = {
1719
- error: void 0,
1720
- progress: 0
1721
- };
1722
- UploadProgress.propTypes = {
1723
- error: PropTypes.instanceOf(Error),
1724
- onCancel: PropTypes.func.isRequired,
1725
- progress: PropTypes.number
1726
- };
1727
1561
  const useRemoveAsset = (onSuccess) => {
1728
1562
  const { toggleNotification } = useNotification();
1729
1563
  const { formatMessage } = useIntl();
@@ -1759,25 +1593,11 @@ const RemoveAssetDialog = ({ open, onClose, asset }) => {
1759
1593
  onClose(null);
1760
1594
  });
1761
1595
  const handleConfirm = async (event) => {
1762
- event.preventDefault();
1596
+ event?.preventDefault();
1763
1597
  await removeAsset(asset.id);
1764
1598
  };
1765
1599
  return /* @__PURE__ */ jsx(Dialog.Root, { open, onOpenChange: onClose, children: /* @__PURE__ */ jsx(ConfirmDialog, { onConfirm: handleConfirm }) });
1766
1600
  };
1767
- RemoveAssetDialog.propTypes = {
1768
- onClose: PropTypes.func.isRequired,
1769
- open: PropTypes.bool.isRequired,
1770
- asset: PropTypes.shape({
1771
- id: PropTypes.number,
1772
- height: PropTypes.number,
1773
- width: PropTypes.number,
1774
- size: PropTypes.number,
1775
- createdAt: PropTypes.string,
1776
- ext: PropTypes.string,
1777
- name: PropTypes.string,
1778
- url: PropTypes.string
1779
- }).isRequired
1780
- };
1781
1601
  const usePersistentState = (key, defaultValue) => {
1782
1602
  const [value, setValue] = useState(() => {
1783
1603
  const stickyValue = window.localStorage.getItem(key);
@@ -1799,7 +1619,7 @@ const CardAsset$1 = styled(Flex)`
1799
1619
  border-radius: ${({ theme }) => theme.borderRadius} ${({ theme }) => theme.borderRadius} 0 0;
1800
1620
  background: linear-gradient(180deg, #ffffff 0%, #f6f6f9 121.48%);
1801
1621
  `;
1802
- const AssetPreview = forwardRef(({ mime, url, name: name2, ...props }, ref) => {
1622
+ const AssetPreview = React.forwardRef(({ mime, url, name: name2, ...props }, ref) => {
1803
1623
  const [lang] = usePersistentState("strapi-admin-language", "en");
1804
1624
  if (mime.includes(AssetType.Image)) {
1805
1625
  return /* @__PURE__ */ jsx("img", { ref, src: url, alt: name2, ...props });
@@ -1816,11 +1636,6 @@ const AssetPreview = forwardRef(({ mime, url, name: name2, ...props }, ref) => {
1816
1636
  return /* @__PURE__ */ jsx(CardAsset$1, { justifyContent: "center", ...props, children: /* @__PURE__ */ jsx(File$1, { "aria-label": name2 }) });
1817
1637
  });
1818
1638
  AssetPreview.displayName = "AssetPreview";
1819
- AssetPreview.propTypes = {
1820
- mime: PropTypes.string.isRequired,
1821
- name: PropTypes.string.isRequired,
1822
- url: PropTypes.string.isRequired
1823
- };
1824
1639
  const RelativeBox = styled(Box)`
1825
1640
  position: relative;
1826
1641
  `;
@@ -1947,14 +1762,6 @@ const Trigger = styled(Menu.Trigger)`
1947
1762
  }
1948
1763
  }
1949
1764
  `;
1950
- CroppingActions.defaultProps = {
1951
- onDuplicate: void 0
1952
- };
1953
- CroppingActions.propTypes = {
1954
- onCancel: PropTypes.func.isRequired,
1955
- onDuplicate: PropTypes.func,
1956
- onValidate: PropTypes.func.isRequired
1957
- };
1958
1765
  const PreviewBox = ({
1959
1766
  asset,
1960
1767
  canUpdate,
@@ -1968,13 +1775,13 @@ const PreviewBox = ({
1968
1775
  trackedLocation
1969
1776
  }) => {
1970
1777
  const { trackUsage } = useTracking();
1971
- const previewRef = useRef(null);
1972
- const [isCropImageReady, setIsCropImageReady] = useState(false);
1973
- const [hasCropIntent, setHasCropIntent] = useState(null);
1974
- const [assetUrl, setAssetUrl] = useState(createAssetUrl(asset, false));
1975
- const [thumbnailUrl, setThumbnailUrl] = useState(createAssetUrl(asset, true));
1778
+ const previewRef = React.useRef(null);
1779
+ const [isCropImageReady, setIsCropImageReady] = React.useState(false);
1780
+ const [hasCropIntent, setHasCropIntent] = React.useState(null);
1781
+ const [assetUrl, setAssetUrl] = React.useState(createAssetUrl(asset, false));
1782
+ const [thumbnailUrl, setThumbnailUrl] = React.useState(createAssetUrl(asset, true));
1976
1783
  const { formatMessage } = useIntl();
1977
- const [showConfirmDialog, setShowConfirmDialog] = useState(false);
1784
+ const [showConfirmDialog, setShowConfirmDialog] = React.useState(false);
1978
1785
  const { crop, produceFile, stopCropping, isCropping, isCropperReady, width, height } = useCropImg();
1979
1786
  const { editAsset, error, isLoading, progress, cancel } = useEditAsset();
1980
1787
  const {
@@ -1984,7 +1791,7 @@ const PreviewBox = ({
1984
1791
  error: uploadError,
1985
1792
  progress: progressUpload
1986
1793
  } = useUpload();
1987
- useEffect(() => {
1794
+ React.useEffect(() => {
1988
1795
  if (replacementFile) {
1989
1796
  const fileLocalUrl = URL.createObjectURL(replacementFile);
1990
1797
  if (asset.isLocal) {
@@ -1994,13 +1801,13 @@ const PreviewBox = ({
1994
1801
  setThumbnailUrl(fileLocalUrl);
1995
1802
  }
1996
1803
  }, [replacementFile, asset]);
1997
- useEffect(() => {
1804
+ React.useEffect(() => {
1998
1805
  if (hasCropIntent === false) {
1999
1806
  stopCropping();
2000
1807
  onCropCancel();
2001
1808
  }
2002
1809
  }, [hasCropIntent, stopCropping, onCropCancel, onCropFinish]);
2003
- useEffect(() => {
1810
+ React.useEffect(() => {
2004
1811
  if (hasCropIntent && isCropImageReady) {
2005
1812
  crop(previewRef.current);
2006
1813
  onCropStart();
@@ -2030,7 +1837,11 @@ const PreviewBox = ({
2030
1837
  const isInCroppingMode = isCropping && !isLoading;
2031
1838
  const handleDuplication = async () => {
2032
1839
  const nextAsset = { ...asset, width, height };
2033
- const file = await produceFile(nextAsset.name, nextAsset.mime, nextAsset.updatedAt);
1840
+ const file = await produceFile(
1841
+ nextAsset.name,
1842
+ nextAsset.mime,
1843
+ nextAsset.updatedAt
1844
+ );
2034
1845
  await upload({ name: file.name, rawFile: file }, asset.folder?.id);
2035
1846
  trackUsage("didCropFile", { duplicatedFile: true, location: trackedLocation });
2036
1847
  setHasCropIntent(false);
@@ -2076,7 +1887,7 @@ const PreviewBox = ({
2076
1887
  }
2077
1888
  ),
2078
1889
  canCopyLink && /* @__PURE__ */ jsx(CopyLinkButton, { url: assetUrl }),
2079
- canUpdate && asset.mime.includes(AssetType.Image) && /* @__PURE__ */ jsx(
1890
+ canUpdate && asset.mime?.includes(AssetType.Image) && /* @__PURE__ */ jsx(
2080
1891
  IconButton,
2081
1892
  {
2082
1893
  label: formatMessage({ id: getTrad("control-card.crop"), defaultMessage: "Crop" }),
@@ -2134,35 +1945,24 @@ const PreviewBox = ({
2134
1945
  )
2135
1946
  ] });
2136
1947
  };
2137
- PreviewBox.defaultProps = {
2138
- replacementFile: void 0,
2139
- trackedLocation: void 0
2140
- };
2141
- PreviewBox.propTypes = {
2142
- canUpdate: PropTypes.bool.isRequired,
2143
- canCopyLink: PropTypes.bool.isRequired,
2144
- canDownload: PropTypes.bool.isRequired,
2145
- replacementFile: PropTypes.instanceOf(File),
2146
- asset: AssetDefinition.isRequired,
2147
- onDelete: PropTypes.func.isRequired,
2148
- onCropFinish: PropTypes.func.isRequired,
2149
- onCropStart: PropTypes.func.isRequired,
2150
- onCropCancel: PropTypes.func.isRequired,
2151
- trackedLocation: PropTypes.string
2152
- };
2153
- const ReplaceMediaButton = ({ onSelectMedia, acceptedMime, trackedLocation, ...props }) => {
1948
+ const ReplaceMediaButton = ({
1949
+ onSelectMedia,
1950
+ acceptedMime,
1951
+ trackedLocation,
1952
+ ...props
1953
+ }) => {
2154
1954
  const { formatMessage } = useIntl();
2155
- const inputRef = useRef(null);
1955
+ const inputRef = React.useRef(null);
2156
1956
  const { trackUsage } = useTracking();
2157
1957
  const handleClick = (e) => {
2158
1958
  e.preventDefault();
2159
1959
  if (trackedLocation) {
2160
1960
  trackUsage("didReplaceMedia", { location: trackedLocation });
2161
1961
  }
2162
- inputRef.current.click();
1962
+ inputRef.current?.click();
2163
1963
  };
2164
1964
  const handleChange = () => {
2165
- const file = inputRef.current.files[0];
1965
+ const file = inputRef.current?.files?.[0];
2166
1966
  onSelectMedia(file);
2167
1967
  };
2168
1968
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -2184,14 +1984,6 @@ const ReplaceMediaButton = ({ onSelectMedia, acceptedMime, trackedLocation, ...p
2184
1984
  ) })
2185
1985
  ] });
2186
1986
  };
2187
- ReplaceMediaButton.defaultProps = {
2188
- trackedLocation: void 0
2189
- };
2190
- ReplaceMediaButton.propTypes = {
2191
- acceptedMime: PropTypes.string.isRequired,
2192
- onSelectMedia: PropTypes.func.isRequired,
2193
- trackedLocation: PropTypes.string
2194
- };
2195
1987
  const LoadingBody$1 = styled(Flex)`
2196
1988
  /* 80px are coming from the Tabs component that is not included in the ModalBody */
2197
1989
  min-height: ${() => `calc(60vh + 8rem)`};
@@ -2205,28 +1997,28 @@ const fileInfoSchema = yup.object({
2205
1997
  const EditAssetContent = ({
2206
1998
  onClose,
2207
1999
  asset,
2208
- canUpdate,
2209
- canCopyLink,
2210
- canDownload,
2000
+ canUpdate = false,
2001
+ canCopyLink = false,
2002
+ canDownload = false,
2211
2003
  trackedLocation
2212
2004
  }) => {
2213
2005
  const { formatMessage, formatDate } = useIntl();
2214
2006
  const { trackUsage } = useTracking();
2215
- const submitButtonRef = useRef(null);
2216
- const [isCropping, setIsCropping] = useState(false);
2217
- const [replacementFile, setReplacementFile] = useState();
2007
+ const submitButtonRef = React.useRef(null);
2008
+ const [isCropping, setIsCropping] = React.useState(false);
2009
+ const [replacementFile, setReplacementFile] = React.useState();
2218
2010
  const { editAsset, isLoading } = useEditAsset();
2219
2011
  const { data: folderStructure, isLoading: folderStructureIsLoading } = useFolderStructure({
2220
2012
  enabled: true
2221
2013
  });
2222
2014
  const handleSubmit = async (values) => {
2223
- const nextAsset = { ...asset, ...values, folder: values.parent.value };
2224
- if (asset.isLocal) {
2015
+ const nextAsset = { ...asset, ...values, folder: values.parent?.value };
2016
+ if (asset?.isLocal) {
2225
2017
  onClose(nextAsset);
2226
2018
  } else {
2227
2019
  const editedAsset = await editAsset(nextAsset, replacementFile);
2228
- const assetType = asset?.mime.split("/")[0];
2229
- const didChangeLocation = asset?.folder?.id ? asset.folder.id !== values.parent.value : asset.folder === null && !!values.parent.value;
2020
+ const assetType = asset?.mime?.split("/")[0];
2021
+ const didChangeLocation = asset?.folder?.id ? asset.folder.id !== values.parent?.value : asset?.folder === null && !!values.parent?.value;
2230
2022
  trackUsage("didEditMediaLibraryElements", {
2231
2023
  location: trackedLocation,
2232
2024
  type: assetType,
@@ -2259,9 +2051,9 @@ const EditAssetContent = ({
2259
2051
  };
2260
2052
  const activeFolderId = asset?.folder?.id;
2261
2053
  const initialFormData = !folderStructureIsLoading && {
2262
- name: asset.name,
2263
- alternativeText: asset.alternativeText ?? void 0,
2264
- caption: asset.caption ?? void 0,
2054
+ name: asset?.name,
2055
+ alternativeText: asset?.alternativeText ?? void 0,
2056
+ caption: asset?.caption ?? void 0,
2265
2057
  parent: {
2266
2058
  value: activeFolderId ?? void 0,
2267
2059
  label: findRecursiveFolderByValue(folderStructure, activeFolderId)?.label ?? folderStructure[0].label
@@ -2320,35 +2112,35 @@ const EditAssetContent = ({
2320
2112
  id: getTrad("modal.file-details.size"),
2321
2113
  defaultMessage: "Size"
2322
2114
  }),
2323
- value: formatBytes(asset.size)
2115
+ value: formatBytes(asset?.size)
2324
2116
  },
2325
2117
  {
2326
2118
  label: formatMessage({
2327
2119
  id: getTrad("modal.file-details.dimensions"),
2328
2120
  defaultMessage: "Dimensions"
2329
2121
  }),
2330
- value: asset.height && asset.width ? `${asset.width}✕${asset.height}` : null
2122
+ value: asset?.height && asset.width ? `${asset.width}✕${asset.height}` : null
2331
2123
  },
2332
2124
  {
2333
2125
  label: formatMessage({
2334
2126
  id: getTrad("modal.file-details.date"),
2335
2127
  defaultMessage: "Date"
2336
2128
  }),
2337
- value: formatDate(new Date(asset.createdAt))
2129
+ value: formatDate(new Date(asset?.createdAt))
2338
2130
  },
2339
2131
  {
2340
2132
  label: formatMessage({
2341
2133
  id: getTrad("modal.file-details.extension"),
2342
2134
  defaultMessage: "Extension"
2343
2135
  }),
2344
- value: getFileExtension(asset.ext)
2136
+ value: getFileExtension(asset?.ext)
2345
2137
  },
2346
2138
  {
2347
2139
  label: formatMessage({
2348
2140
  id: getTrad("modal.file-details.id"),
2349
2141
  defaultMessage: "Asset ID"
2350
2142
  }),
2351
- value: asset.id
2143
+ value: asset?.id
2352
2144
  }
2353
2145
  ]
2354
2146
  }
@@ -2451,7 +2243,7 @@ const EditAssetContent = ({
2451
2243
  ReplaceMediaButton,
2452
2244
  {
2453
2245
  onSelectMedia: setReplacementFile,
2454
- acceptedMime: asset.mime,
2246
+ acceptedMime: asset?.mime,
2455
2247
  disabled: formDisabled,
2456
2248
  trackedLocation
2457
2249
  }
@@ -2459,7 +2251,7 @@ const EditAssetContent = ({
2459
2251
  /* @__PURE__ */ jsx(
2460
2252
  Button,
2461
2253
  {
2462
- onClick: () => submitButtonRef.current.click(),
2254
+ onClick: () => submitButtonRef.current?.click(),
2463
2255
  loading: isLoading,
2464
2256
  disabled: formDisabled,
2465
2257
  children: formatMessage({ id: "global.finish", defaultMessage: "Finish" })
@@ -2471,39 +2263,24 @@ const EditAssetContent = ({
2471
2263
  }
2472
2264
  );
2473
2265
  };
2474
- EditAssetContent.defaultProps = {
2475
- asset: {},
2476
- trackedLocation: void 0,
2477
- canUpdate: false,
2478
- canCopyLink: false,
2479
- canDownload: false
2480
- };
2481
- EditAssetContent.propTypes = {
2482
- asset: AssetDefinition,
2483
- canUpdate: PropTypes.bool,
2484
- canCopyLink: PropTypes.bool,
2485
- canDownload: PropTypes.bool,
2486
- onClose: PropTypes.func.isRequired,
2487
- trackedLocation: PropTypes.string
2488
- };
2489
- const EditAssetDialog = ({ open, onClose, ...restProps }) => {
2490
- return /* @__PURE__ */ jsx(Modal.Root, { open, onOpenChange: onClose, children: /* @__PURE__ */ jsx(Modal.Content, { children: /* @__PURE__ */ jsx(EditAssetContent, { onClose, ...restProps }) }) });
2491
- };
2492
- EditAssetDialog.defaultProps = {
2493
- asset: {},
2494
- trackedLocation: void 0,
2495
- canUpdate: false,
2496
- canCopyLink: false,
2497
- canDownload: false
2498
- };
2499
- EditAssetDialog.propTypes = {
2500
- asset: AssetDefinition,
2501
- canUpdate: PropTypes.bool,
2502
- canCopyLink: PropTypes.bool,
2503
- canDownload: PropTypes.bool,
2504
- open: PropTypes.bool.isRequired,
2505
- onClose: PropTypes.func.isRequired,
2506
- trackedLocation: PropTypes.string
2266
+ const EditAssetDialog = ({
2267
+ open,
2268
+ onClose,
2269
+ canUpdate = false,
2270
+ canCopyLink = false,
2271
+ canDownload = false,
2272
+ ...restProps
2273
+ }) => {
2274
+ return /* @__PURE__ */ jsx(Modal.Root, { open, onOpenChange: onClose, children: /* @__PURE__ */ jsx(Modal.Content, { children: /* @__PURE__ */ jsx(
2275
+ EditAssetContent,
2276
+ {
2277
+ onClose,
2278
+ canUpdate,
2279
+ canCopyLink,
2280
+ canDownload,
2281
+ ...restProps
2282
+ }
2283
+ ) }) });
2507
2284
  };
2508
2285
  const useBulkRemove = () => {
2509
2286
  const { toggleNotification } = useNotification();
@@ -2512,12 +2289,12 @@ const useBulkRemove = () => {
2512
2289
  const { post } = useFetchClient();
2513
2290
  const bulkRemoveQuery = (filesAndFolders) => {
2514
2291
  const payload = filesAndFolders.reduce((acc, selected) => {
2515
- const { id: id2, type } = selected;
2292
+ const { id, type } = selected;
2516
2293
  const key = type === "asset" ? "fileIds" : "folderIds";
2517
2294
  if (!acc[key]) {
2518
2295
  acc[key] = [];
2519
2296
  }
2520
- acc[key].push(id2);
2297
+ acc[key].push(id);
2521
2298
  return acc;
2522
2299
  }, {});
2523
2300
  return post("/upload/actions/bulk-delete", payload);
@@ -2549,10 +2326,10 @@ const useBulkRemove = () => {
2549
2326
  const remove = (...args) => mutation.mutateAsync(...args);
2550
2327
  return { ...mutation, remove };
2551
2328
  };
2552
- const editFolderRequest = (put, post, { attrs, id: id2 }) => {
2553
- const isEditing = !!id2;
2329
+ const editFolderRequest = (put, post, { attrs, id }) => {
2330
+ const isEditing = !!id;
2554
2331
  const method = isEditing ? put : post;
2555
- return method(`/upload/folders/${id2 ?? ""}`, attrs).then((res) => res.data);
2332
+ return method(`/upload/folders/${id ?? ""}`, attrs).then((res) => res.data);
2556
2333
  };
2557
2334
  const useEditFolder = () => {
2558
2335
  const queryClient = useQueryClient();
@@ -2563,10 +2340,10 @@ const useEditFolder = () => {
2563
2340
  queryClient.refetchQueries([pluginId, "folder", "structure"], { active: true });
2564
2341
  }
2565
2342
  });
2566
- const editFolder = (attrs, id2) => mutation.mutateAsync({ attrs, id: id2 });
2343
+ const editFolder = (attrs, id) => mutation.mutateAsync({ attrs, id });
2567
2344
  return { ...mutation, editFolder, status: mutation.status };
2568
2345
  };
2569
- const EditFolderModalHeader = ({ isEditing }) => {
2346
+ const EditFolderModalHeader = ({ isEditing = false }) => {
2570
2347
  const { formatMessage } = useIntl();
2571
2348
  return /* @__PURE__ */ jsx(Modal.Header, { children: /* @__PURE__ */ jsx(Modal.Title, { children: formatMessage(
2572
2349
  isEditing ? {
@@ -2578,20 +2355,9 @@ const EditFolderModalHeader = ({ isEditing }) => {
2578
2355
  }
2579
2356
  ) }) });
2580
2357
  };
2581
- EditFolderModalHeader.defaultProps = {
2582
- isEditing: false
2583
- };
2584
- EditFolderModalHeader.propTypes = {
2585
- isEditing: PropTypes.bool
2586
- };
2587
2358
  const RemoveFolderDialog = ({ onClose, onConfirm, open }) => {
2588
2359
  return /* @__PURE__ */ jsx(Dialog.Root, { open, onOpenChange: onClose, children: /* @__PURE__ */ jsx(ConfirmDialog, { onConfirm }) });
2589
2360
  };
2590
- RemoveFolderDialog.propTypes = {
2591
- onClose: PropTypes.func.isRequired,
2592
- open: PropTypes.bool.isRequired,
2593
- onConfirm: PropTypes.func.isRequired
2594
- };
2595
2361
  const folderSchema = yup.object({
2596
2362
  name: yup.string().required(),
2597
2363
  parent: yup.object({
@@ -2599,12 +2365,17 @@ const folderSchema = yup.object({
2599
2365
  value: yup.number().nullable(true)
2600
2366
  }).nullable(true)
2601
2367
  });
2602
- const EditFolderContent = ({ onClose, folder, location, parentFolderId }) => {
2368
+ const EditFolderContent = ({
2369
+ onClose,
2370
+ folder,
2371
+ location,
2372
+ parentFolderId
2373
+ }) => {
2603
2374
  const { data: folderStructure, isLoading: folderStructureIsLoading } = useFolderStructure({
2604
2375
  enabled: true
2605
2376
  });
2606
2377
  const { canCreate, isLoading: isLoadingPermissions, canUpdate } = useMediaLibraryPermissions();
2607
- const [showConfirmDialog, setShowConfirmDialog] = useState(false);
2378
+ const [showConfirmDialog, setShowConfirmDialog] = React.useState(false);
2608
2379
  const { formatMessage, formatDate } = useIntl();
2609
2380
  const { trackUsage } = useTracking();
2610
2381
  const { editFolder, isLoading: isEditFolderLoading } = useEditFolder();
@@ -2613,21 +2384,24 @@ const EditFolderContent = ({ onClose, folder, location, parentFolderId }) => {
2613
2384
  const isLoading = isLoadingPermissions || folderStructureIsLoading;
2614
2385
  const isEditing = !!folder;
2615
2386
  const formDisabled = folder && !canUpdate || !folder && !canCreate;
2616
- const initialFormData = !folderStructureIsLoading && {
2387
+ const initialFormData = !folderStructureIsLoading ? {
2617
2388
  name: folder?.name ?? "",
2618
2389
  parent: {
2619
2390
  /* ideally we would use folderStructure[0].value, but since it is null
2620
- react complains about rendering null as field value */
2621
- value: parentFolderId ? parseInt(parentFolderId, 10) : void 0,
2622
- label: parentFolderId ? findRecursiveFolderByValue(folderStructure, parseInt(parentFolderId, 10))?.label : folderStructure[0].label
2391
+ react complains about rendering null as field value */
2392
+ value: parentFolderId ? parseInt(parentFolderId.toString(), 10) : void 0,
2393
+ label: parentFolderId ? folderStructure && findRecursiveFolderByValue(folderStructure, parseInt(parentFolderId.toString(), 10))?.label : folderStructure?.[0].label
2623
2394
  }
2395
+ } : {
2396
+ name: "",
2397
+ parent: null
2624
2398
  };
2625
2399
  const handleSubmit = async (values, { setErrors }) => {
2626
2400
  try {
2627
2401
  await editFolder(
2628
2402
  {
2629
2403
  ...values,
2630
- parent: values.parent.value ?? null
2404
+ parent: values.parent?.value ?? null
2631
2405
  },
2632
2406
  folder?.id
2633
2407
  );
@@ -2642,7 +2416,7 @@ const EditFolderContent = ({ onClose, folder, location, parentFolderId }) => {
2642
2416
  })
2643
2417
  });
2644
2418
  if (isEditing) {
2645
- const didChangeLocation = parentFolderId ? parseInt(parentFolderId, 10) !== values.parent.value : parentFolderId === null && !!values.parent.value;
2419
+ const didChangeLocation = parentFolderId ? parseInt(parentFolderId.toString(), 10) !== values.parent?.value : parentFolderId === null && !!values.parent?.value;
2646
2420
  trackUsage("didEditMediaLibraryElements", {
2647
2421
  location,
2648
2422
  type: "folder",
@@ -2654,17 +2428,22 @@ const EditFolderContent = ({ onClose, folder, location, parentFolderId }) => {
2654
2428
  onClose({ created: true });
2655
2429
  } catch (err) {
2656
2430
  const errors = getAPIInnerErrors(err, { getTrad });
2657
- const formikErrors = Object.entries(errors).reduce((acc, [key, error]) => {
2658
- acc[key] = error.defaultMessage;
2659
- return acc;
2660
- }, {});
2431
+ const formikErrors = Object.entries(errors).reduce(
2432
+ (acc, [key, error]) => {
2433
+ acc[key] = error.defaultMessage;
2434
+ return acc;
2435
+ },
2436
+ {}
2437
+ );
2661
2438
  if (!isEmpty(formikErrors)) {
2662
2439
  setErrors(formikErrors);
2663
2440
  }
2664
2441
  }
2665
2442
  };
2666
2443
  const handleDelete = async () => {
2667
- await remove([folder]);
2444
+ if (folder) {
2445
+ await remove([folder]);
2446
+ }
2668
2447
  setShowConfirmDialog(false);
2669
2448
  onClose();
2670
2449
  };
@@ -2718,21 +2497,28 @@ const EditFolderContent = ({ onClose, folder, location, parentFolderId }) => {
2718
2497
  ]
2719
2498
  }
2720
2499
  ) }),
2721
- /* @__PURE__ */ jsx(Grid.Item, { xs: 12, col: 6, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsxs(Field.Root, { name: "name", error: errors.name, children: [
2722
- /* @__PURE__ */ jsx(Field.Label, { children: formatMessage({
2723
- id: getTrad("form.input.label.folder-name"),
2724
- defaultMessage: "Name"
2725
- }) }),
2726
- /* @__PURE__ */ jsx(
2727
- TextInput,
2728
- {
2729
- value: values.name,
2730
- onChange: handleChange,
2731
- disabled: formDisabled
2732
- }
2733
- ),
2734
- /* @__PURE__ */ jsx(Field.Error, {})
2735
- ] }) }),
2500
+ /* @__PURE__ */ jsx(Grid.Item, { xs: 12, col: 6, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsxs(
2501
+ Field.Root,
2502
+ {
2503
+ name: "name",
2504
+ error: typeof errors.name === "string" ? errors.name : void 0,
2505
+ children: [
2506
+ /* @__PURE__ */ jsx(Field.Label, { children: formatMessage({
2507
+ id: getTrad("form.input.label.folder-name"),
2508
+ defaultMessage: "Name"
2509
+ }) }),
2510
+ /* @__PURE__ */ jsx(
2511
+ TextInput,
2512
+ {
2513
+ value: values.name,
2514
+ onChange: handleChange,
2515
+ disabled: formDisabled
2516
+ }
2517
+ ),
2518
+ /* @__PURE__ */ jsx(Field.Error, {})
2519
+ ]
2520
+ }
2521
+ ) }),
2736
2522
  /* @__PURE__ */ jsx(Grid.Item, { xs: 12, col: 6, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsxs(Field.Root, { id: "folder-parent", children: [
2737
2523
  /* @__PURE__ */ jsx(Field.Label, { children: formatMessage({
2738
2524
  id: getTrad("form.input.label.folder-location"),
@@ -2751,7 +2537,7 @@ const EditFolderContent = ({ onClose, folder, location, parentFolderId }) => {
2751
2537
  menuPortalTarget: document.querySelector("body"),
2752
2538
  inputId: "folder-parent",
2753
2539
  disabled: formDisabled,
2754
- error: errors?.parent,
2540
+ error: typeof errors.parent === "string" ? errors.parent : void 0,
2755
2541
  ariaErrorMessage: "folder-parent-error"
2756
2542
  }
2757
2543
  ),
@@ -2762,7 +2548,7 @@ const EditFolderContent = ({ onClose, folder, location, parentFolderId }) => {
2762
2548
  tag: "p",
2763
2549
  id: "folder-parent-error",
2764
2550
  textColor: "danger600",
2765
- children: errors.parent
2551
+ children: typeof errors.parent === "string" ? errors.parent : void 0
2766
2552
  }
2767
2553
  )
2768
2554
  ] }) })
@@ -2811,42 +2597,19 @@ const EditFolderContent = ({ onClose, folder, location, parentFolderId }) => {
2811
2597
  )
2812
2598
  ] });
2813
2599
  };
2814
- EditFolderContent.defaultProps = {
2815
- folder: void 0,
2816
- location: void 0,
2817
- parentFolderId: null
2818
- };
2819
- EditFolderContent.propTypes = {
2820
- folder: FolderDefinition,
2821
- location: PropTypes.string,
2822
- onClose: PropTypes.func.isRequired,
2823
- parentFolderId: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
2824
- };
2825
2600
  const EditFolderDialog = ({ open, onClose, ...restProps }) => {
2826
- return /* @__PURE__ */ jsx(Modal.Root, { open, onOpenChange: onClose, children: /* @__PURE__ */ jsx(Modal.Content, { children: /* @__PURE__ */ jsx(EditFolderContent, { ...restProps, onClose }) }) });
2601
+ return /* @__PURE__ */ jsx(Modal.Root, { open, onOpenChange: onClose, children: /* @__PURE__ */ jsx(Modal.Content, { children: /* @__PURE__ */ jsx(EditFolderContent, { ...restProps, onClose, open }) }) });
2827
2602
  };
2828
- EditFolderDialog.defaultProps = {
2829
- folder: void 0,
2830
- location: void 0,
2831
- parentFolderId: null
2832
- };
2833
- EditFolderDialog.propTypes = {
2834
- folder: FolderDefinition,
2835
- location: PropTypes.string,
2836
- open: PropTypes.bool.isRequired,
2837
- onClose: PropTypes.func.isRequired,
2838
- parentFolderId: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
2839
- };
2840
- const useFolder = (id2, { enabled = true } = {}) => {
2603
+ const useFolder = (id, { enabled = true } = {}) => {
2841
2604
  const { toggleNotification } = useNotification();
2842
2605
  const { get } = useFetchClient();
2843
2606
  const { formatMessage } = useIntl();
2844
2607
  const { data, error, isLoading } = useQuery(
2845
- [pluginId, "folder", id2],
2608
+ [pluginId, "folder", id],
2846
2609
  async () => {
2847
2610
  const {
2848
2611
  data: { data: data2 }
2849
- } = await get(`/upload/folders/${id2}`, {
2612
+ } = await get(`/upload/folders/${id}`, {
2850
2613
  params: {
2851
2614
  populate: {
2852
2615
  parent: {
@@ -2899,14 +2662,14 @@ const CardContainer = styled(Card$1)`
2899
2662
  const AssetCardBase = ({
2900
2663
  children,
2901
2664
  extension,
2902
- isSelectable: isSelectable2,
2665
+ isSelectable: isSelectable2 = true,
2903
2666
  name: name2,
2904
2667
  onSelect,
2905
2668
  onRemove,
2906
2669
  onEdit,
2907
- selected,
2908
- subtitle,
2909
- variant
2670
+ selected = false,
2671
+ subtitle = "",
2672
+ variant = "Image"
2910
2673
  }) => {
2911
2674
  const { formatMessage } = useIntl();
2912
2675
  const handleClick = (e) => {
@@ -2919,8 +2682,7 @@ const AssetCardBase = ({
2919
2682
  };
2920
2683
  return /* @__PURE__ */ jsxs(CardContainer, { role: "button", height: "100%", tabIndex: -1, onClick: handleClick, children: [
2921
2684
  /* @__PURE__ */ jsxs(CardHeader, { children: [
2922
- isSelectable2 && // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
2923
- /* @__PURE__ */ jsx("div", { onClick: handlePropagationClick, children: /* @__PURE__ */ jsx(CardCheckbox, { checked: selected, onCheckedChange: onSelect }) }),
2685
+ isSelectable2 && /* @__PURE__ */ jsx("div", { onClick: handlePropagationClick, children: /* @__PURE__ */ jsx(CardCheckbox, { checked: selected, onCheckedChange: onSelect }) }),
2924
2686
  (onRemove || onEdit) && /* @__PURE__ */ jsxs(CardActionsContainer, { onClick: handlePropagationClick, position: "end", children: [
2925
2687
  onRemove && /* @__PURE__ */ jsx(
2926
2688
  IconButton,
@@ -2946,7 +2708,7 @@ const AssetCardBase = ({
2946
2708
  ] }),
2947
2709
  /* @__PURE__ */ jsxs(CardBody, { children: [
2948
2710
  /* @__PURE__ */ jsxs(CardContent, { children: [
2949
- /* @__PURE__ */ jsx(Box, { paddingTop: 1, children: /* @__PURE__ */ jsx(CardTitle, { tag: "h2", children: name2 }) }),
2711
+ /* @__PURE__ */ jsx(Box, { paddingTop: 1, children: /* @__PURE__ */ jsx(Typography, { tag: "h2", children: /* @__PURE__ */ jsx(CardTitle, { tag: "span", children: name2 }) }) }),
2950
2712
  /* @__PURE__ */ jsxs(CardSubtitle, { children: [
2951
2713
  /* @__PURE__ */ jsx(Extension$1, { children: extension }),
2952
2714
  subtitle
@@ -2959,36 +2721,9 @@ const AssetCardBase = ({
2959
2721
  ] })
2960
2722
  ] });
2961
2723
  };
2962
- AssetCardBase.defaultProps = {
2963
- children: void 0,
2964
- isSelectable: true,
2965
- onEdit: void 0,
2966
- onSelect: void 0,
2967
- onRemove: void 0,
2968
- selected: false,
2969
- subtitle: "",
2970
- variant: "Image"
2971
- };
2972
- AssetCardBase.propTypes = {
2973
- children: PropTypes.node,
2974
- extension: PropTypes.string.isRequired,
2975
- isSelectable: PropTypes.bool,
2976
- name: PropTypes.string.isRequired,
2977
- onEdit: PropTypes.func,
2978
- onSelect: PropTypes.func,
2979
- onRemove: PropTypes.func,
2980
- selected: PropTypes.bool,
2981
- subtitle: PropTypes.string,
2982
- variant: PropTypes.oneOf(["Image", "Video", "Audio", "Doc"])
2983
- };
2984
2724
  const AudioPreview = ({ url, alt }) => {
2985
2725
  return /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx("audio", { controls: true, src: url, children: alt }) });
2986
2726
  };
2987
- AudioPreview.defaultProps = {};
2988
- AudioPreview.propTypes = {
2989
- alt: PropTypes.string.isRequired,
2990
- url: PropTypes.string.isRequired
2991
- };
2992
2727
  const AudioPreviewWrapper$1 = styled(Box)`
2993
2728
  canvas,
2994
2729
  audio {
@@ -2997,25 +2732,14 @@ const AudioPreviewWrapper$1 = styled(Box)`
2997
2732
  max-height: ${({ size }) => size === "M" ? 16.4 : 8.8}rem;
2998
2733
  }
2999
2734
  `;
3000
- const AudioAssetCard = ({ name: name2, url, size, ...restProps }) => {
3001
- return /* @__PURE__ */ jsx(AssetCardBase, { name: name2, ...restProps, variant: "Audio", children: /* @__PURE__ */ jsx(CardAsset$2, { size, children: /* @__PURE__ */ jsx(AudioPreviewWrapper$1, { size, children: /* @__PURE__ */ jsx(AudioPreview, { url, alt: name2 }) }) }) });
3002
- };
3003
- AudioAssetCard.defaultProps = {
3004
- onSelect: void 0,
3005
- onEdit: void 0,
3006
- onRemove: void 0,
3007
- selected: false,
3008
- size: "M"
3009
- };
3010
- AudioAssetCard.propTypes = {
3011
- extension: PropTypes.string.isRequired,
3012
- name: PropTypes.string.isRequired,
3013
- onSelect: PropTypes.func,
3014
- onEdit: PropTypes.func,
3015
- onRemove: PropTypes.func,
3016
- url: PropTypes.string.isRequired,
3017
- selected: PropTypes.bool,
3018
- size: PropTypes.oneOf(["S", "M"])
2735
+ const AudioAssetCard = ({
2736
+ name: name2,
2737
+ url,
2738
+ size = "M",
2739
+ selected = false,
2740
+ ...restProps
2741
+ }) => {
2742
+ return /* @__PURE__ */ jsx(AssetCardBase, { name: name2, selected, ...restProps, variant: "Audio", children: /* @__PURE__ */ jsx(CardAsset$2, { size, children: /* @__PURE__ */ jsx(AudioPreviewWrapper$1, { size, children: /* @__PURE__ */ jsx(AudioPreview, { url, alt: name2 }) }) }) });
3019
2743
  };
3020
2744
  const IconWrapper$1 = styled.span`
3021
2745
  svg {
@@ -3026,99 +2750,83 @@ const CardAsset = styled(Flex)`
3026
2750
  border-radius: ${({ theme }) => theme.borderRadius} ${({ theme }) => theme.borderRadius} 0 0;
3027
2751
  background: linear-gradient(180deg, #ffffff 0%, #f6f6f9 121.48%);
3028
2752
  `;
3029
- const DocAssetCard = ({ name: name2, extension, size, ...restProps }) => {
3030
- return /* @__PURE__ */ jsx(AssetCardBase, { name: name2, extension, ...restProps, variant: "Doc", children: /* @__PURE__ */ jsx(CardAsset, { width: "100%", height: size === "S" ? `8.8rem` : `16.4rem`, justifyContent: "center", children: /* @__PURE__ */ jsx(IconWrapper$1, { children: extension === "pdf" ? /* @__PURE__ */ jsx(FilePdf, { "aria-label": name2 }) : /* @__PURE__ */ jsx(File$1, { "aria-label": name2 }) }) }) });
3031
- };
3032
- DocAssetCard.defaultProps = {
3033
- selected: false,
3034
- onEdit: void 0,
3035
- onSelect: void 0,
3036
- onRemove: void 0,
3037
- size: "M"
3038
- };
3039
- DocAssetCard.propTypes = {
3040
- extension: PropTypes.string.isRequired,
3041
- onEdit: PropTypes.func,
3042
- onSelect: PropTypes.func,
3043
- onRemove: PropTypes.func,
3044
- selected: PropTypes.bool,
3045
- name: PropTypes.string.isRequired,
3046
- size: PropTypes.oneOf(["S", "M"])
2753
+ const DocAssetCard = ({
2754
+ name: name2,
2755
+ extension,
2756
+ size = "M",
2757
+ selected = false,
2758
+ ...restProps
2759
+ }) => {
2760
+ return /* @__PURE__ */ jsx(
2761
+ AssetCardBase,
2762
+ {
2763
+ name: name2,
2764
+ extension,
2765
+ selected,
2766
+ ...restProps,
2767
+ variant: "Doc",
2768
+ children: /* @__PURE__ */ jsx(CardAsset, { width: "100%", height: size === "S" ? `8.8rem` : `16.4rem`, justifyContent: "center", children: /* @__PURE__ */ jsx(IconWrapper$1, { children: extension === "pdf" ? /* @__PURE__ */ jsx(FilePdf, { "aria-label": name2 }) : /* @__PURE__ */ jsx(File$1, { "aria-label": name2 }) }) })
2769
+ }
2770
+ );
3047
2771
  };
3048
- const ImageAssetCard = ({ height, width, thumbnail, size, alt, isUrlSigned, ...props }) => {
2772
+ const ImageAssetCard = ({
2773
+ height,
2774
+ width,
2775
+ thumbnail,
2776
+ size = "M",
2777
+ alt,
2778
+ isUrlSigned,
2779
+ selected = false,
2780
+ ...props
2781
+ }) => {
3049
2782
  const thumbnailUrl = isUrlSigned ? thumbnail : appendSearchParamsToUrl({
3050
2783
  url: thumbnail,
3051
2784
  params: { updatedAt: props.updatedAt }
3052
2785
  });
3053
- return /* @__PURE__ */ jsx(AssetCardBase, { ...props, subtitle: height && width && ` - ${width}✕${height}`, variant: "Image", children: /* @__PURE__ */ jsx(CardAsset$2, { src: thumbnailUrl, size, alt }) });
3054
- };
3055
- ImageAssetCard.defaultProps = {
3056
- height: void 0,
3057
- width: void 0,
3058
- selected: false,
3059
- onEdit: void 0,
3060
- onSelect: void 0,
3061
- onRemove: void 0,
3062
- size: "M",
3063
- updatedAt: void 0
3064
- };
3065
- ImageAssetCard.propTypes = {
3066
- alt: PropTypes.string.isRequired,
3067
- extension: PropTypes.string.isRequired,
3068
- height: PropTypes.number,
3069
- name: PropTypes.string.isRequired,
3070
- onEdit: PropTypes.func,
3071
- onSelect: PropTypes.func,
3072
- onRemove: PropTypes.func,
3073
- width: PropTypes.number,
3074
- thumbnail: PropTypes.string.isRequired,
3075
- selected: PropTypes.bool,
3076
- size: PropTypes.oneOf(["S", "M"]),
3077
- updatedAt: PropTypes.string,
3078
- isUrlSigned: PropTypes.bool.isRequired
2786
+ const subtitle = height && width ? ` - ${width}✕${height}` : void 0;
2787
+ return /* @__PURE__ */ jsx(AssetCardBase, { ...props, selected, subtitle, variant: "Image", children: /* @__PURE__ */ jsx(CardAsset$2, { src: thumbnailUrl, size, alt }) });
3079
2788
  };
3080
2789
  const HAVE_FUTURE_DATA = 3;
3081
- const VideoPreview = ({ url, mime, onLoadDuration, alt, ...props }) => {
2790
+ const VideoPreview = ({
2791
+ url,
2792
+ mime,
2793
+ onLoadDuration = () => {
2794
+ },
2795
+ alt,
2796
+ size = "M",
2797
+ ...props
2798
+ }) => {
3082
2799
  const handleTimeUpdate = (e) => {
3083
- if (e.target.currentTime > 0) {
3084
- const video = e.target;
2800
+ if (e.currentTarget.currentTime > 0) {
2801
+ const video = e.currentTarget;
3085
2802
  const canvas = document.createElement("canvas");
3086
2803
  canvas.height = video.videoHeight;
3087
2804
  canvas.width = video.videoWidth;
3088
- canvas.getContext("2d").drawImage(video, 0, 0, video.videoWidth, video.videoHeight);
2805
+ canvas.getContext("2d")?.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);
3089
2806
  video.replaceWith(canvas);
3090
- onLoadDuration(video.duration);
2807
+ onLoadDuration && onLoadDuration(video.duration);
3091
2808
  }
3092
2809
  };
3093
2810
  const handleThumbnailVisibility = (e) => {
3094
- const video = e.target;
2811
+ const video = e.currentTarget;
3095
2812
  if (video.readyState < HAVE_FUTURE_DATA)
3096
2813
  return;
3097
2814
  video.play();
3098
2815
  };
3099
- return /* @__PURE__ */ createElement(Box, { tag: "figure", ...props, key: url }, /* @__PURE__ */ jsx(
3100
- "video",
3101
- {
3102
- muted: true,
3103
- onLoadedData: handleThumbnailVisibility,
3104
- src: url,
3105
- crossOrigin: "anonymous",
3106
- onTimeUpdate: handleTimeUpdate,
3107
- children: /* @__PURE__ */ jsx("source", { type: mime })
3108
- }
3109
- ), /* @__PURE__ */ jsx(VisuallyHidden, { tag: "figcaption", children: alt }));
3110
- };
3111
- VideoPreview.defaultProps = {
3112
- onLoadDuration() {
3113
- },
3114
- size: "M"
3115
- };
3116
- VideoPreview.propTypes = {
3117
- alt: PropTypes.string.isRequired,
3118
- url: PropTypes.string.isRequired,
3119
- mime: PropTypes.string.isRequired,
3120
- onLoadDuration: PropTypes.func,
3121
- size: PropTypes.oneOf(["S", "M"])
2816
+ return /* @__PURE__ */ jsxs(Box, { tag: "figure", ...props, children: [
2817
+ /* @__PURE__ */ jsx(
2818
+ "video",
2819
+ {
2820
+ muted: true,
2821
+ onLoadedData: handleThumbnailVisibility,
2822
+ src: url,
2823
+ crossOrigin: "anonymous",
2824
+ onTimeUpdate: handleTimeUpdate,
2825
+ children: /* @__PURE__ */ jsx("source", { type: mime })
2826
+ }
2827
+ ),
2828
+ /* @__PURE__ */ jsx(VisuallyHidden, { tag: "figcaption", children: alt })
2829
+ ] }, url);
3122
2830
  };
3123
2831
  const VideoPreviewWrapper$2 = styled(Box)`
3124
2832
  canvas,
@@ -3129,39 +2837,35 @@ const VideoPreviewWrapper$2 = styled(Box)`
3129
2837
  max-height: ${({ size }) => size === "M" ? 16.4 : 8.8}rem;
3130
2838
  }
3131
2839
  `;
3132
- const VideoAssetCard = ({ name: name2, url, mime, size, ...props }) => {
3133
- const [duration, setDuration] = useState();
2840
+ const VideoAssetCard = ({
2841
+ name: name2,
2842
+ url,
2843
+ mime,
2844
+ size = "M",
2845
+ selected = false,
2846
+ ...props
2847
+ }) => {
2848
+ const [duration, setDuration] = React.useState();
3134
2849
  const formattedDuration = duration && formatDuration(duration);
3135
- return /* @__PURE__ */ jsxs(AssetCardBase, { name: name2, ...props, variant: "Video", children: [
2850
+ return /* @__PURE__ */ jsxs(AssetCardBase, { selected, name: name2, ...props, variant: "Video", children: [
3136
2851
  /* @__PURE__ */ jsx(CardAsset$2, { size, children: /* @__PURE__ */ jsx(VideoPreviewWrapper$2, { size, children: /* @__PURE__ */ jsx(VideoPreview, { url, mime, onLoadDuration: setDuration, alt: name2 }) }) }),
3137
2852
  /* @__PURE__ */ jsx(CardTimer, { children: formattedDuration || "..." })
3138
2853
  ] });
3139
2854
  };
3140
- VideoAssetCard.defaultProps = {
3141
- onSelect: void 0,
3142
- onEdit: void 0,
3143
- onRemove: void 0,
3144
- selected: false,
3145
- size: "M"
3146
- };
3147
- VideoAssetCard.propTypes = {
3148
- extension: PropTypes.string.isRequired,
3149
- mime: PropTypes.string.isRequired,
3150
- name: PropTypes.string.isRequired,
3151
- onSelect: PropTypes.func,
3152
- onEdit: PropTypes.func,
3153
- onRemove: PropTypes.func,
3154
- url: PropTypes.string.isRequired,
3155
- selected: PropTypes.bool,
3156
- size: PropTypes.oneOf(["S", "M"])
3157
- };
3158
- const AssetCard = ({ asset, isSelected, onSelect, onEdit, onRemove, size, local }) => {
2855
+ const AssetCard = ({
2856
+ asset,
2857
+ isSelected = false,
2858
+ onSelect,
2859
+ onEdit,
2860
+ onRemove,
2861
+ size = "M",
2862
+ local = false
2863
+ }) => {
3159
2864
  const handleSelect = onSelect ? () => onSelect(asset) : void 0;
3160
2865
  const commonAssetCardProps = {
3161
2866
  id: asset.id,
3162
2867
  isSelectable: asset.isSelectable,
3163
2868
  extension: getFileExtension(asset.ext),
3164
- key: asset.id,
3165
2869
  name: asset.name,
3166
2870
  url: local ? asset.url : createAssetUrl(asset, true),
3167
2871
  mime: asset.mime,
@@ -3171,55 +2875,37 @@ const AssetCard = ({ asset, isSelected, onSelect, onEdit, onRemove, size, local
3171
2875
  selected: isSelected,
3172
2876
  size
3173
2877
  };
3174
- if (asset.mime.includes(AssetType.Video)) {
2878
+ if (asset.mime?.includes(AssetType.Video)) {
3175
2879
  return /* @__PURE__ */ jsx(VideoAssetCard, { ...commonAssetCardProps });
3176
2880
  }
3177
- if (asset.mime.includes(AssetType.Image)) {
2881
+ if (asset.mime?.includes(AssetType.Image)) {
3178
2882
  return /* @__PURE__ */ jsx(
3179
2883
  ImageAssetCard,
3180
2884
  {
3181
- ...commonAssetCardProps,
3182
2885
  alt: asset.alternativeText || asset.name,
3183
2886
  height: asset.height,
3184
2887
  thumbnail: prefixFileUrlWithBackendUrl(asset?.formats?.thumbnail?.url || asset.url),
3185
2888
  width: asset.width,
3186
2889
  updatedAt: asset.updatedAt,
3187
- isUrlSigned: asset?.isUrlSigned || false
2890
+ isUrlSigned: asset?.isUrlSigned || false,
2891
+ ...commonAssetCardProps
3188
2892
  }
3189
2893
  );
3190
2894
  }
3191
- if (asset.mime.includes(AssetType.Audio)) {
2895
+ if (asset.mime?.includes(AssetType.Audio)) {
3192
2896
  return /* @__PURE__ */ jsx(AudioAssetCard, { ...commonAssetCardProps });
3193
2897
  }
3194
2898
  return /* @__PURE__ */ jsx(DocAssetCard, { ...commonAssetCardProps });
3195
2899
  };
3196
- AssetCard.defaultProps = {
3197
- isSelected: false,
3198
- // Determine if the asset is loaded locally or from a remote resource
3199
- local: false,
3200
- onSelect: void 0,
3201
- onEdit: void 0,
3202
- onRemove: void 0,
3203
- size: "M"
3204
- };
3205
- AssetCard.propTypes = {
3206
- asset: AssetDefinition.isRequired,
3207
- local: PropTypes.bool,
3208
- onSelect: PropTypes.func,
3209
- onEdit: PropTypes.func,
3210
- onRemove: PropTypes.func,
3211
- isSelected: PropTypes.bool,
3212
- size: PropTypes.oneOf(["S", "M"])
3213
- };
3214
- const Draggable = ({ children, id: id2, index: index2, moveItem }) => {
3215
- const ref = useRef(null);
2900
+ const Draggable = ({ children, id, index: index2, moveItem }) => {
2901
+ const ref = React.useRef(null);
3216
2902
  const [, drop] = useDrop({
3217
2903
  accept: "draggable",
3218
2904
  hover(hoveredOverItem) {
3219
2905
  if (!ref.current) {
3220
2906
  return;
3221
2907
  }
3222
- if (hoveredOverItem.id !== id2) {
2908
+ if (hoveredOverItem.id !== id) {
3223
2909
  moveItem(hoveredOverItem.index, index2);
3224
2910
  hoveredOverItem.index = index2;
3225
2911
  }
@@ -3228,7 +2914,7 @@ const Draggable = ({ children, id: id2, index: index2, moveItem }) => {
3228
2914
  const [{ isDragging }, drag] = useDrag({
3229
2915
  type: "draggable",
3230
2916
  item() {
3231
- return { index: index2, id: id2 };
2917
+ return { index: index2, id };
3232
2918
  },
3233
2919
  collect: (monitor) => ({
3234
2920
  isDragging: monitor.isDragging()
@@ -3238,21 +2924,15 @@ const Draggable = ({ children, id: id2, index: index2, moveItem }) => {
3238
2924
  drag(drop(ref));
3239
2925
  return /* @__PURE__ */ jsx("div", { ref, style: { opacity, cursor: "move" }, children });
3240
2926
  };
3241
- Draggable.propTypes = {
3242
- id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
3243
- index: PropTypes.number.isRequired,
3244
- children: PropTypes.node.isRequired,
3245
- moveItem: PropTypes.func.isRequired
3246
- };
3247
2927
  const AssetGridList = ({
3248
- allowedTypes,
2928
+ allowedTypes = ["files", "images", "videos", "audios"],
3249
2929
  assets,
3250
2930
  onEditAsset,
3251
2931
  onSelectAsset,
3252
2932
  selectedAssets,
3253
- size,
2933
+ size = "M",
3254
2934
  onReorderAsset,
3255
- title
2935
+ title = null
3256
2936
  }) => {
3257
2937
  return /* @__PURE__ */ jsxs(KeyboardNavigable, { tagName: "article", children: [
3258
2938
  title && /* @__PURE__ */ jsx(Box, { paddingTop: 2, paddingBottom: 2, children: /* @__PURE__ */ jsx(Typography, { tag: "h2", variant: "delta", fontWeight: "semiBold", children: title }) }),
@@ -3286,32 +2966,19 @@ const AssetGridList = ({
3286
2966
  }) })
3287
2967
  ] });
3288
2968
  };
3289
- AssetGridList.defaultProps = {
3290
- allowedTypes: ["images", "files", "videos", "audios"],
3291
- onEditAsset: void 0,
3292
- size: "M",
3293
- onReorderAsset: void 0,
3294
- title: null
3295
- };
3296
- AssetGridList.propTypes = {
3297
- allowedTypes: PropTypes.arrayOf(PropTypes.string),
3298
- assets: PropTypes.arrayOf(PropTypes.shape({})).isRequired,
3299
- onEditAsset: PropTypes.func,
3300
- onSelectAsset: PropTypes.func.isRequired,
3301
- selectedAssets: PropTypes.arrayOf(PropTypes.shape({})).isRequired,
3302
- size: PropTypes.oneOf(["S", "M"]),
3303
- onReorderAsset: PropTypes.func,
3304
- title: PropTypes.string
3305
- };
3306
- const CrumbSimpleMenuAsync = ({ parentsToOmit, currentFolderId, onChangeFolder }) => {
3307
- const [shouldFetch, setShouldFetch] = useState(false);
2969
+ const CrumbSimpleMenuAsync = ({
2970
+ parentsToOmit = [],
2971
+ currentFolderId,
2972
+ onChangeFolder
2973
+ }) => {
2974
+ const [shouldFetch, setShouldFetch] = React.useState(false);
3308
2975
  const { data, isLoading } = useFolderStructure({ enabled: shouldFetch });
3309
2976
  const { pathname } = useLocation();
3310
2977
  const [{ query }] = useQueryParams();
3311
2978
  const { formatMessage } = useIntl();
3312
2979
  const allAscendants = data && getFolderParents(data, currentFolderId);
3313
2980
  const filteredAscendants = allAscendants && allAscendants.filter(
3314
- (ascendant) => !parentsToOmit.includes(ascendant.id) && ascendant.id !== null
2981
+ (ascendant) => typeof ascendant.id === "number" && !parentsToOmit.includes(ascendant.id) && ascendant.id !== null
3315
2982
  );
3316
2983
  return /* @__PURE__ */ jsxs(
3317
2984
  CrumbSimpleMenu,
@@ -3335,33 +3002,28 @@ const CrumbSimpleMenuAsync = ({ parentsToOmit, currentFolderId, onChangeFolder }
3335
3002
  {
3336
3003
  tag: "button",
3337
3004
  type: "button",
3338
- onClick: () => onChangeFolder(ascendant.id, ascendant.path),
3005
+ onClick: () => onChangeFolder(Number(ascendant.id), ascendant.path),
3339
3006
  children: ascendant.label
3340
3007
  },
3341
3008
  ascendant.id
3342
3009
  );
3343
3010
  }
3344
3011
  const url = getFolderURL(pathname, query, {
3345
- folder: ascendant?.id,
3012
+ folder: typeof ascendant?.id === "string" ? ascendant.id : void 0,
3346
3013
  folderPath: ascendant?.path
3347
3014
  });
3348
- return /* @__PURE__ */ jsx(MenuItem, { isLink: true, tag: NavLink, to: url, children: ascendant.label }, ascendant.id);
3015
+ return /* @__PURE__ */ jsx(MenuItem, { isLink: true, href: url, children: ascendant.label }, ascendant.id);
3349
3016
  })
3350
3017
  ]
3351
3018
  }
3352
3019
  );
3353
3020
  };
3354
- CrumbSimpleMenuAsync.defaultProps = {
3355
- currentFolderId: void 0,
3356
- onChangeFolder: void 0,
3357
- parentsToOmit: []
3358
- };
3359
- CrumbSimpleMenuAsync.propTypes = {
3360
- currentFolderId: PropTypes.number,
3361
- onChangeFolder: PropTypes.func,
3362
- parentsToOmit: PropTypes.arrayOf(PropTypes.number)
3363
- };
3364
- const Breadcrumbs = ({ breadcrumbs, onChangeFolder, currentFolderId, ...props }) => {
3021
+ const Breadcrumbs = ({
3022
+ breadcrumbs,
3023
+ onChangeFolder,
3024
+ currentFolderId,
3025
+ ...props
3026
+ }) => {
3365
3027
  const { formatMessage } = useIntl();
3366
3028
  return /* @__PURE__ */ jsx(Breadcrumbs$1, { ...props, children: breadcrumbs.map((crumb, index2) => {
3367
3029
  if (Array.isArray(crumb)) {
@@ -3377,14 +3039,24 @@ const Breadcrumbs = ({ breadcrumbs, onChangeFolder, currentFolderId, ...props })
3377
3039
  }
3378
3040
  const isCurrentFolderMediaLibrary = crumb.id === null && currentFolderId === void 0;
3379
3041
  if (currentFolderId !== crumb.id && !isCurrentFolderMediaLibrary) {
3042
+ if (onChangeFolder) {
3043
+ return /* @__PURE__ */ jsx(
3044
+ CrumbLink,
3045
+ {
3046
+ tag: "button",
3047
+ type: "button",
3048
+ onClick: () => onChangeFolder(crumb.id, crumb.path),
3049
+ children: typeof crumb.label !== "string" && crumb.label?.id ? formatMessage(crumb.label) : crumb.label
3050
+ },
3051
+ `breadcrumb-${crumb?.id ?? "root"}`
3052
+ );
3053
+ }
3380
3054
  return /* @__PURE__ */ jsx(
3381
3055
  CrumbLink,
3382
3056
  {
3383
- tag: onChangeFolder ? "button" : NavLink,
3384
- type: onChangeFolder && "button",
3385
- to: onChangeFolder ? void 0 : crumb.href,
3386
- onClick: onChangeFolder && (() => onChangeFolder(crumb.id, crumb.path)),
3387
- children: crumb.label?.id ? formatMessage(crumb.label) : crumb.label
3057
+ tag: NavLink,
3058
+ href: crumb.href,
3059
+ children: typeof crumb.label !== "string" && crumb.label?.id ? formatMessage(crumb.label) : crumb.label
3388
3060
  },
3389
3061
  `breadcrumb-${crumb?.id ?? "root"}`
3390
3062
  );
@@ -3393,21 +3065,12 @@ const Breadcrumbs = ({ breadcrumbs, onChangeFolder, currentFolderId, ...props })
3393
3065
  Crumb,
3394
3066
  {
3395
3067
  isCurrent: index2 + 1 === breadcrumbs.length,
3396
- children: crumb.label?.id ? formatMessage(crumb.label) : crumb.label
3068
+ children: typeof crumb.label !== "string" && crumb.label?.id ? formatMessage(crumb.label) : crumb.label
3397
3069
  },
3398
3070
  `breadcrumb-${crumb?.id ?? "root"}`
3399
3071
  );
3400
3072
  }) });
3401
3073
  };
3402
- Breadcrumbs.defaultProps = {
3403
- currentFolderId: void 0,
3404
- onChangeFolder: void 0
3405
- };
3406
- Breadcrumbs.propTypes = {
3407
- breadcrumbs: BreadcrumbsDefinition.isRequired,
3408
- currentFolderId: PropTypes.number,
3409
- onChangeFolder: PropTypes.func
3410
- };
3411
3074
  const EmptyAssetCard = styled(Box)`
3412
3075
  background: linear-gradient(
3413
3076
  180deg,
@@ -3430,11 +3093,13 @@ const EmptyAssetGrid = ({ count, size }) => {
3430
3093
  `empty-asset-card-${idx}`
3431
3094
  )) });
3432
3095
  };
3433
- EmptyAssetGrid.propTypes = {
3434
- count: PropTypes.number.isRequired,
3435
- size: PropTypes.string.isRequired
3436
- };
3437
- const EmptyAssets = ({ icon: Icon = EmptyDocuments, content, action, size, count }) => {
3096
+ const EmptyAssets = ({
3097
+ icon: Icon = EmptyDocuments,
3098
+ content,
3099
+ action,
3100
+ size = "M",
3101
+ count = 12
3102
+ }) => {
3438
3103
  return /* @__PURE__ */ jsxs(Box, { position: "relative", children: [
3439
3104
  /* @__PURE__ */ jsx(EmptyAssetGrid, { size, count }),
3440
3105
  /* @__PURE__ */ jsx(Box, { position: "absolute", top: 11, width: "100%", children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "center", gap: 4, textAlign: "center", children: [
@@ -3446,29 +3111,10 @@ const EmptyAssets = ({ icon: Icon = EmptyDocuments, content, action, size, count
3446
3111
  ] }) })
3447
3112
  ] });
3448
3113
  };
3449
- EmptyAssets.defaultProps = {
3450
- action: void 0,
3451
- icon: void 0,
3452
- size: "M",
3453
- count: 12
3454
- };
3455
- EmptyAssets.propTypes = {
3456
- action: PropTypes.node,
3457
- icon: PropTypes.elementType,
3458
- content: PropTypes.string.isRequired,
3459
- size: PropTypes.string,
3460
- count: PropTypes.number
3461
- };
3462
3114
  const FolderCardContext = createContext({});
3463
3115
  function useFolderCard() {
3464
3116
  return useContext(FolderCardContext);
3465
3117
  }
3466
- let id = 0;
3467
- const genId = () => ++id;
3468
- const useId = (initialId) => {
3469
- const idRef = useRef(`${initialId}-${genId()}`);
3470
- return idRef.current;
3471
- };
3472
3118
  const FauxClickWrapper = styled.button`
3473
3119
  height: 100%;
3474
3120
  left: 0;
@@ -3498,16 +3144,25 @@ const Card = styled(Box)`
3498
3144
  }
3499
3145
  }
3500
3146
  `;
3501
- const FolderCard = forwardRef(
3502
- ({ children, id: id2, startAction, cardActions, ariaLabel, onClick, to, ...props }, ref) => {
3503
- const generatedId = useId(id2);
3504
- const fodlerCtxValue = useMemo(() => ({ id: generatedId }), [generatedId]);
3147
+ const FolderCard = React.forwardRef(
3148
+ ({
3149
+ children,
3150
+ id,
3151
+ startAction = null,
3152
+ cardActions = null,
3153
+ ariaLabel,
3154
+ onClick,
3155
+ to,
3156
+ ...props
3157
+ }, ref) => {
3158
+ const generatedId = React.useId();
3159
+ const fodlerCtxValue = React.useMemo(() => ({ id: generatedId }), [generatedId]);
3505
3160
  return /* @__PURE__ */ jsx(FolderCardContext.Provider, { value: fodlerCtxValue, children: /* @__PURE__ */ jsxs(Card, { position: "relative", tabIndex: 0, $isCardActions: !!cardActions, ref, ...props, children: [
3506
3161
  /* @__PURE__ */ jsx(
3507
3162
  FauxClickWrapper,
3508
3163
  {
3509
3164
  to: to || void 0,
3510
- tag: to ? NavLink : "button",
3165
+ as: to ? NavLink : "button",
3511
3166
  type: to ? void 0 : "button",
3512
3167
  onClick,
3513
3168
  tabIndex: -1,
@@ -3543,39 +3198,23 @@ const FolderCard = forwardRef(
3543
3198
  }
3544
3199
  ),
3545
3200
  children,
3546
- /* @__PURE__ */ jsx(CardActionDisplay, { children: /* @__PURE__ */ jsx(CardAction, { right: 4, children: cardActions }) })
3201
+ /* @__PURE__ */ jsx(CardActionDisplay, { children: /* @__PURE__ */ jsx(CardAction, { right: 4, position: "end", children: cardActions }) })
3547
3202
  ]
3548
3203
  }
3549
3204
  )
3550
3205
  ] }) });
3551
3206
  }
3552
3207
  );
3553
- FolderCard.defaultProps = {
3554
- id: void 0,
3555
- cardActions: null,
3556
- startAction: null,
3557
- to: void 0,
3558
- onClick: void 0
3559
- };
3560
- FolderCard.propTypes = {
3561
- ariaLabel: PropTypes.string.isRequired,
3562
- children: PropTypes.node.isRequired,
3563
- id: PropTypes.string,
3564
- onClick: PropTypes.func,
3565
- startAction: PropTypes.element,
3566
- cardActions: PropTypes.element,
3567
- to: PropTypes.string
3568
- };
3569
3208
  const StyledBox = styled(Flex)`
3570
3209
  user-select: none;
3571
3210
  `;
3572
3211
  const FolderCardBody = (props) => {
3573
- const { id: id2 } = useFolderCard();
3212
+ const { id } = useFolderCard();
3574
3213
  return /* @__PURE__ */ jsx(
3575
3214
  StyledBox,
3576
3215
  {
3577
3216
  ...props,
3578
- id: `${id2}-title`,
3217
+ id: `${id}-title`,
3579
3218
  alignItems: "flex-start",
3580
3219
  direction: "column",
3581
3220
  maxWidth: "100%",
@@ -3608,25 +3247,12 @@ const FolderCardBodyAction = ({ to, ...props }) => {
3608
3247
  }
3609
3248
  return /* @__PURE__ */ jsx(BoxOutline, { padding: 1, tag: "button", type: "button", maxWidth: "100%", ...props });
3610
3249
  };
3611
- FolderCardBodyAction.defaultProps = {
3612
- to: void 0
3613
- };
3614
- FolderCardBodyAction.propTypes = {
3615
- to: PropTypes.string
3616
- };
3617
- const FolderGridList = ({ title, children }) => {
3250
+ const FolderGridList = ({ title = null, children }) => {
3618
3251
  return /* @__PURE__ */ jsxs(KeyboardNavigable, { tagName: "article", children: [
3619
3252
  title && /* @__PURE__ */ jsx(Box, { paddingBottom: 2, children: /* @__PURE__ */ jsx(Typography, { tag: "h2", variant: "delta", fontWeight: "semiBold", children: title }) }),
3620
3253
  /* @__PURE__ */ jsx(Grid.Root, { gap: 4, children })
3621
3254
  ] });
3622
3255
  };
3623
- FolderGridList.defaultProps = {
3624
- title: null
3625
- };
3626
- FolderGridList.propTypes = {
3627
- children: PropTypes.node.isRequired,
3628
- title: PropTypes.string
3629
- };
3630
3256
  const SortPicker = ({ onChangeSort, value }) => {
3631
3257
  const { formatMessage } = useIntl();
3632
3258
  return /* @__PURE__ */ jsx(
@@ -3634,7 +3260,7 @@ const SortPicker = ({ onChangeSort, value }) => {
3634
3260
  {
3635
3261
  size: "S",
3636
3262
  value,
3637
- onChange: (value2) => onChangeSort(value2),
3263
+ onChange: (value2) => onChangeSort(value2.toString()),
3638
3264
  "aria-label": formatMessage({
3639
3265
  id: getTrad("sort.label"),
3640
3266
  defaultMessage: "Sort by"
@@ -3643,17 +3269,10 @@ const SortPicker = ({ onChangeSort, value }) => {
3643
3269
  id: getTrad("sort.label"),
3644
3270
  defaultMessage: "Sort by"
3645
3271
  }),
3646
- children: sortOptions.map((filter) => /* @__PURE__ */ jsx(SingleSelectOption, { value: filter.value, children: formatMessage({ id: getTrad(filter.key), defaultMessage: `${filter.value}` }) }, filter.key))
3272
+ children: sortOptions$1.map((filter) => /* @__PURE__ */ jsx(SingleSelectOption, { value: filter.value, children: formatMessage({ id: getTrad(filter.key), defaultMessage: `${filter.value}` }) }, filter.key))
3647
3273
  }
3648
3274
  );
3649
3275
  };
3650
- SortPicker.defaultProps = {
3651
- value: void 0
3652
- };
3653
- SortPicker.propTypes = {
3654
- onChangeSort: PropTypes.func.isRequired,
3655
- value: PropTypes.string
3656
- };
3657
3276
  const VideoPreviewWrapper$1 = styled(Box)`
3658
3277
  figure {
3659
3278
  width: ${({ theme }) => theme.spaces[7]};
@@ -3683,15 +3302,23 @@ const PreviewCell = ({ type, content }) => {
3683
3302
  );
3684
3303
  }
3685
3304
  const { alternativeText, ext, formats, mime, name: name2, url } = content;
3686
- if (mime.includes(AssetType.Image)) {
3305
+ if (mime?.includes(AssetType.Image)) {
3687
3306
  const mediaURL = prefixFileUrlWithBackendUrl(formats?.thumbnail?.url) ?? prefixFileUrlWithBackendUrl(url);
3688
- return /* @__PURE__ */ jsx(Avatar.Item, { src: mediaURL, alt: alternativeText, preview: true });
3307
+ return /* @__PURE__ */ jsx(
3308
+ Avatar.Item,
3309
+ {
3310
+ src: mediaURL,
3311
+ alt: alternativeText || void 0,
3312
+ preview: true,
3313
+ fallback: alternativeText
3314
+ }
3315
+ );
3689
3316
  }
3690
- if (mime.includes(AssetType.Video)) {
3317
+ if (mime?.includes(AssetType.Video)) {
3691
3318
  return /* @__PURE__ */ jsx(VideoPreviewWrapper$1, { children: /* @__PURE__ */ jsx(
3692
3319
  VideoPreview,
3693
3320
  {
3694
- url: createAssetUrl(content, true),
3321
+ url: createAssetUrl(content, true) || "",
3695
3322
  mime,
3696
3323
  alt: alternativeText ?? name2
3697
3324
  }
@@ -3699,28 +3326,16 @@ const PreviewCell = ({ type, content }) => {
3699
3326
  }
3700
3327
  return /* @__PURE__ */ jsx(Box, { background: "secondary100", color: "secondary600", width: "3.2rem", height: "3.2rem", children: getFileExtension(ext) });
3701
3328
  };
3702
- PreviewCell.propTypes = {
3703
- content: PropTypes.shape({
3704
- alternativeText: PropTypes.string,
3705
- ext: PropTypes.string,
3706
- formats: PropTypes.shape({
3707
- thumbnail: PropTypes.shape({
3708
- url: PropTypes.string
3709
- })
3710
- }),
3711
- mime: PropTypes.string,
3712
- name: PropTypes.string,
3713
- url: PropTypes.string
3714
- }).isRequired,
3715
- type: PropTypes.string.isRequired
3716
- };
3717
3329
  const CellContent = ({ cellType, contentType, content, name: name2 }) => {
3718
3330
  const { formatDate, formatMessage } = useIntl();
3331
+ const contentValue = content[name2];
3719
3332
  switch (cellType) {
3720
3333
  case "image":
3721
3334
  return /* @__PURE__ */ jsx(PreviewCell, { type: contentType, content });
3722
3335
  case "date":
3723
- return /* @__PURE__ */ jsx(Typography, { children: formatDate(parseISO(content[name2]), { dateStyle: "full" }) });
3336
+ if (typeof contentValue === "string") {
3337
+ return /* @__PURE__ */ jsx(Typography, { children: formatDate(parseISO(contentValue), { dateStyle: "full" }) });
3338
+ }
3724
3339
  case "size":
3725
3340
  if (contentType === "folder")
3726
3341
  return /* @__PURE__ */ jsx(
@@ -3733,7 +3348,9 @@ const CellContent = ({ cellType, contentType, content, name: name2 }) => {
3733
3348
  children: "-"
3734
3349
  }
3735
3350
  );
3736
- return /* @__PURE__ */ jsx(Typography, { children: formatBytes(content[name2]) });
3351
+ if (typeof contentValue === "string" || typeof contentValue === "number") {
3352
+ return /* @__PURE__ */ jsx(Typography, { children: formatBytes(contentValue) });
3353
+ }
3737
3354
  case "ext":
3738
3355
  if (contentType === "folder")
3739
3356
  return /* @__PURE__ */ jsx(
@@ -3746,9 +3363,13 @@ const CellContent = ({ cellType, contentType, content, name: name2 }) => {
3746
3363
  children: "-"
3747
3364
  }
3748
3365
  );
3749
- return /* @__PURE__ */ jsx(Typography, { children: getFileExtension(content[name2]).toUpperCase() });
3366
+ if (typeof contentValue === "string") {
3367
+ return /* @__PURE__ */ jsx(Typography, { children: getFileExtension(contentValue)?.toUpperCase() });
3368
+ }
3750
3369
  case "text":
3751
- return /* @__PURE__ */ jsx(Typography, { children: content[name2] });
3370
+ if (typeof contentValue === "string") {
3371
+ return /* @__PURE__ */ jsx(Typography, { children: contentValue });
3372
+ }
3752
3373
  default:
3753
3374
  return /* @__PURE__ */ jsx(
3754
3375
  Typography,
@@ -3762,135 +3383,126 @@ const CellContent = ({ cellType, contentType, content, name: name2 }) => {
3762
3383
  );
3763
3384
  }
3764
3385
  };
3765
- CellContent.propTypes = {
3766
- cellType: PropTypes.string.isRequired,
3767
- contentType: PropTypes.string.isRequired,
3768
- content: PropTypes.shape({
3769
- alternativeText: PropTypes.string,
3770
- ext: PropTypes.string,
3771
- formats: PropTypes.shape({
3772
- thumbnail: PropTypes.shape({
3773
- url: PropTypes.string
3774
- })
3775
- }),
3776
- mime: PropTypes.string,
3777
- url: PropTypes.string
3778
- }).isRequired,
3779
- name: PropTypes.string.isRequired
3780
- };
3781
3386
  const TableRows = ({
3782
- onChangeFolder,
3387
+ onChangeFolder = null,
3783
3388
  onEditAsset,
3784
3389
  onEditFolder,
3785
3390
  onSelectOne,
3786
- rows,
3787
- selected
3391
+ rows = [],
3392
+ selected = []
3788
3393
  }) => {
3789
3394
  const { formatMessage } = useIntl();
3790
- const handleRowClickFn = (element, elementType, id2, path) => {
3395
+ const handleRowClickFn = (element, id, path, elementType) => {
3791
3396
  if (elementType === "asset") {
3792
3397
  onEditAsset(element);
3793
3398
  } else {
3794
- onChangeFolder(id2, path);
3399
+ if (onChangeFolder) {
3400
+ onChangeFolder(id, path);
3401
+ }
3795
3402
  }
3796
3403
  };
3797
3404
  return /* @__PURE__ */ jsx(Tbody, { children: rows.map((element) => {
3798
- const { path, id: id2, isSelectable: isSelectable2, name: name2, folderURL, type: contentType } = element;
3405
+ const { path, id, isSelectable: isSelectable2, name: name2, folderURL, type: contentType } = element;
3799
3406
  const isSelected = !!selected.find(
3800
- (currentRow) => currentRow.id === id2 && currentRow.type === contentType
3407
+ (currentRow) => currentRow.id === id && currentRow.type === contentType
3801
3408
  );
3802
- return /* @__PURE__ */ jsxs(Tr, { onClick: () => handleRowClickFn(element, contentType, id2, path), children: [
3803
- /* @__PURE__ */ jsx(Td, { onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsx(
3804
- Checkbox,
3805
- {
3806
- "aria-label": formatMessage(
3409
+ return /* @__PURE__ */ jsxs(
3410
+ Tr,
3411
+ {
3412
+ onClick: () => handleRowClickFn(element, id, path || void 0, contentType),
3413
+ children: [
3414
+ /* @__PURE__ */ jsx(Td, { onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsx(
3415
+ Checkbox,
3807
3416
  {
3808
- id: contentType === "asset" ? "list-assets-select" : "list.folder.select",
3809
- defaultMessage: contentType === "asset" ? "Select {name} asset" : "Select {name} folder"
3810
- },
3811
- { name: name2 }
3812
- ),
3813
- disabled: !isSelectable2,
3814
- onCheckedChange: () => onSelectOne(element),
3815
- checked: isSelected
3816
- }
3817
- ) }),
3818
- tableHeaders.map(({ name: name22, type: cellType }) => {
3819
- return /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(
3820
- CellContent,
3821
- {
3822
- content: element,
3823
- cellType,
3824
- contentType,
3825
- name: name22
3826
- }
3827
- ) }, name22);
3828
- }),
3829
- /* @__PURE__ */ jsx(Td, { onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsxs(Flex, { justifyContent: "flex-end", children: [
3830
- contentType === "folder" && /* @__PURE__ */ jsx(
3831
- IconButton,
3832
- {
3833
- tag: folderURL ? Link$1 : "button",
3834
- label: formatMessage({
3835
- id: getTrad("list.folders.link-label"),
3836
- defaultMessage: "Access folder"
3837
- }),
3838
- to: folderURL,
3839
- onClick: () => !folderURL && onChangeFolder(id2),
3840
- variant: "ghost",
3841
- children: /* @__PURE__ */ jsx(Eye, {})
3842
- }
3843
- ),
3844
- /* @__PURE__ */ jsx(
3845
- IconButton,
3846
- {
3847
- label: formatMessage({
3848
- id: getTrad("control-card.edit"),
3849
- defaultMessage: "Edit"
3850
- }),
3851
- onClick: () => contentType === "asset" ? onEditAsset(element) : onEditFolder(element),
3852
- variant: "ghost",
3853
- children: /* @__PURE__ */ jsx(Pencil, {})
3854
- }
3855
- )
3856
- ] }) })
3857
- ] }, id2);
3417
+ "aria-label": formatMessage(
3418
+ {
3419
+ id: contentType === "asset" ? "list-assets-select" : "list.folder.select",
3420
+ defaultMessage: contentType === "asset" ? "Select {name} asset" : "Select {name} folder"
3421
+ },
3422
+ { name: name2 }
3423
+ ),
3424
+ disabled: !isSelectable2,
3425
+ onCheckedChange: () => onSelectOne(element),
3426
+ checked: isSelected
3427
+ }
3428
+ ) }),
3429
+ tableHeaders.map(({ name: name22, type: cellType }) => {
3430
+ return /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(
3431
+ CellContent,
3432
+ {
3433
+ content: element,
3434
+ cellType,
3435
+ contentType,
3436
+ name: name22
3437
+ }
3438
+ ) }, name22);
3439
+ }),
3440
+ /* @__PURE__ */ jsx(Td, { onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsxs(Flex, { justifyContent: "flex-end", children: [
3441
+ contentType === "folder" && (folderURL ? /* @__PURE__ */ jsx(
3442
+ IconButton,
3443
+ {
3444
+ tag: Link$1,
3445
+ label: formatMessage({
3446
+ id: getTrad("list.folders.link-label"),
3447
+ defaultMessage: "Access folder"
3448
+ }),
3449
+ to: folderURL,
3450
+ variant: "ghost",
3451
+ children: /* @__PURE__ */ jsx(Eye, {})
3452
+ }
3453
+ ) : /* @__PURE__ */ jsx(
3454
+ IconButton,
3455
+ {
3456
+ tag: "button",
3457
+ label: formatMessage({
3458
+ id: getTrad("list.folders.link-label"),
3459
+ defaultMessage: "Access folder"
3460
+ }),
3461
+ onClick: () => onChangeFolder && onChangeFolder(id),
3462
+ variant: "ghost",
3463
+ children: /* @__PURE__ */ jsx(Eye, {})
3464
+ }
3465
+ )),
3466
+ /* @__PURE__ */ jsx(
3467
+ IconButton,
3468
+ {
3469
+ label: formatMessage({
3470
+ id: getTrad("control-card.edit"),
3471
+ defaultMessage: "Edit"
3472
+ }),
3473
+ onClick: () => contentType === "asset" ? onEditAsset(element) : onEditFolder(element),
3474
+ variant: "ghost",
3475
+ children: /* @__PURE__ */ jsx(Pencil, {})
3476
+ }
3477
+ )
3478
+ ] }) })
3479
+ ]
3480
+ },
3481
+ id
3482
+ );
3858
3483
  }) });
3859
3484
  };
3860
- TableRows.defaultProps = {
3861
- onChangeFolder: null,
3862
- rows: [],
3863
- selected: []
3864
- };
3865
- TableRows.propTypes = {
3866
- onChangeFolder: PropTypes.func,
3867
- onEditAsset: PropTypes.func.isRequired,
3868
- onEditFolder: PropTypes.func.isRequired,
3869
- onSelectOne: PropTypes.func.isRequired,
3870
- rows: PropTypes.arrayOf(AssetDefinition, FolderDefinition),
3871
- selected: PropTypes.arrayOf(AssetDefinition, FolderDefinition)
3872
- };
3873
- const TableList = ({
3874
- assetCount,
3875
- folderCount,
3876
- indeterminate,
3877
- onChangeSort,
3878
- onChangeFolder,
3879
- onEditAsset,
3880
- onEditFolder,
3485
+ const TableList = ({
3486
+ assetCount = 0,
3487
+ folderCount = 0,
3488
+ indeterminate = false,
3489
+ onChangeSort = null,
3490
+ onChangeFolder = null,
3491
+ onEditAsset = null,
3492
+ onEditFolder = null,
3881
3493
  onSelectAll,
3882
3494
  onSelectOne,
3883
- rows,
3884
- selected,
3885
- shouldDisableBulkSelect,
3886
- sortQuery
3495
+ rows = [],
3496
+ selected = [],
3497
+ shouldDisableBulkSelect = false,
3498
+ sortQuery = ""
3887
3499
  }) => {
3888
3500
  const { formatMessage } = useIntl();
3889
3501
  const [sortBy, sortOrder] = sortQuery.split(":");
3890
3502
  const handleClickSort = (isSorted, name2) => {
3891
3503
  const nextSortOrder = isSorted && sortOrder === "ASC" ? "DESC" : "ASC";
3892
3504
  const nextSort = `${name2}:${nextSortOrder}`;
3893
- onChangeSort(nextSort);
3505
+ onChangeSort && onChangeSort(nextSort);
3894
3506
  };
3895
3507
  return /* @__PURE__ */ jsxs(Table, { colCount: tableHeaders.length + 2, rowCount: assetCount + folderCount + 1, children: [
3896
3508
  /* @__PURE__ */ jsx(Thead, { children: /* @__PURE__ */ jsxs(Tr, { children: [
@@ -3931,7 +3543,6 @@ const TableList = ({
3931
3543
  {
3932
3544
  onClick: () => handleClickSort(isSorted, name2),
3933
3545
  tag: isSorted ? "span" : "button",
3934
- label: !isSorted ? sortLabel : "",
3935
3546
  textColor: "neutral600",
3936
3547
  variant: "sigma",
3937
3548
  children: tableHeaderLabel
@@ -3959,41 +3570,13 @@ const TableList = ({
3959
3570
  )
3960
3571
  ] });
3961
3572
  };
3962
- TableList.defaultProps = {
3963
- assetCount: 0,
3964
- folderCount: 0,
3965
- indeterminate: false,
3966
- onChangeSort: null,
3967
- onChangeFolder: null,
3968
- onEditAsset: null,
3969
- onEditFolder: null,
3970
- rows: [],
3971
- selected: [],
3972
- shouldDisableBulkSelect: false,
3973
- sortQuery: ""
3974
- };
3975
- TableList.propTypes = {
3976
- assetCount: PropTypes.number,
3977
- folderCount: PropTypes.number,
3978
- indeterminate: PropTypes.bool,
3979
- onChangeSort: PropTypes.func,
3980
- onChangeFolder: PropTypes.func,
3981
- onEditAsset: PropTypes.func,
3982
- onEditFolder: PropTypes.func,
3983
- onSelectAll: PropTypes.func.isRequired,
3984
- onSelectOne: PropTypes.func.isRequired,
3985
- rows: PropTypes.arrayOf(AssetDefinition, FolderDefinition),
3986
- selected: PropTypes.arrayOf(AssetDefinition, FolderDefinition),
3987
- shouldDisableBulkSelect: PropTypes.bool,
3988
- sortQuery: PropTypes.string
3989
- };
3990
3573
  const FilterTag = ({ attribute, filter, onClick, operator, value }) => {
3991
3574
  const { formatMessage, formatDate, formatTime } = useIntl();
3992
3575
  const handleClick = () => {
3993
3576
  onClick(filter);
3994
3577
  };
3995
3578
  const { fieldSchema } = attribute;
3996
- const type = fieldSchema.type;
3579
+ const type = fieldSchema?.type;
3997
3580
  let formattedValue = value;
3998
3581
  if (type === "date") {
3999
3582
  formattedValue = formatDate(value, { dateStyle: "full" });
@@ -4004,43 +3587,42 @@ const FilterTag = ({ attribute, filter, onClick, operator, value }) => {
4004
3587
  if (type === "time") {
4005
3588
  const [hour, minute] = value.split(":");
4006
3589
  const date = /* @__PURE__ */ new Date();
4007
- date.setHours(hour);
4008
- date.setMinutes(minute);
3590
+ date.setHours(Number(hour));
3591
+ date.setMinutes(Number(minute));
4009
3592
  formattedValue = formatTime(date, {
4010
- numeric: "auto",
4011
- style: "short"
3593
+ hour: "numeric",
3594
+ minute: "numeric"
4012
3595
  });
4013
3596
  }
4014
- const content = `${attribute.metadatas.label} ${formatMessage({
3597
+ const content = `${attribute.metadatas?.label} ${formatMessage({
4015
3598
  id: `components.FilterOptions.FILTER_TYPES.${operator}`,
4016
3599
  defaultMessage: operator
4017
3600
  })} ${formattedValue}`;
4018
3601
  return /* @__PURE__ */ jsx(Tag, { onClick: handleClick, icon: /* @__PURE__ */ jsx(Cross, {}), padding: 1, children: content });
4019
3602
  };
4020
- FilterTag.propTypes = {
4021
- attribute: PropTypes.shape({
4022
- name: PropTypes.string.isRequired,
4023
- fieldSchema: PropTypes.object.isRequired,
4024
- metadatas: PropTypes.shape({ label: PropTypes.string.isRequired }).isRequired
4025
- }).isRequired,
4026
- filter: PropTypes.object.isRequired,
4027
- onClick: PropTypes.func.isRequired,
4028
- operator: PropTypes.string.isRequired,
4029
- value: PropTypes.string.isRequired
4030
- };
4031
3603
  const FilterList = ({ appliedFilters, filtersSchema, onRemoveFilter }) => {
4032
3604
  const handleClick = (filter) => {
4033
3605
  const nextFilters = appliedFilters.filter((prevFilter) => {
4034
3606
  const name2 = Object.keys(filter)[0];
4035
- const filterType = Object.keys(filter[name2])[0];
4036
- const value = decodeURIComponent(filter[name2][filterType]);
4037
- return prevFilter[name2]?.[filterType] !== value;
3607
+ const filterName = filter[name2];
3608
+ if (filterName !== void 0) {
3609
+ const filterType = Object.keys(filterName)[0];
3610
+ const filterValue = filterName[filterType];
3611
+ if (typeof filterValue === "string") {
3612
+ const decodedValue = decodeURIComponent(filterValue);
3613
+ return prevFilter[name2]?.[filterType] !== decodedValue;
3614
+ }
3615
+ }
3616
+ return true;
4038
3617
  });
4039
3618
  onRemoveFilter(nextFilters);
4040
3619
  };
4041
3620
  return appliedFilters.map((filter, i) => {
4042
3621
  const attributeName = Object.keys(filter)[0];
4043
3622
  const attribute = filtersSchema.find(({ name: name2 }) => name2 === attributeName);
3623
+ if (!attribute) {
3624
+ return null;
3625
+ }
4044
3626
  const filterObj = filter[attributeName];
4045
3627
  const operator = Object.keys(filterObj)[0];
4046
3628
  let value = filterObj[operator];
@@ -4052,7 +3634,7 @@ const FilterList = ({ appliedFilters, filtersSchema, onRemoveFilter }) => {
4052
3634
  value = Array.isArray(value) || typeof value === "object" ? Object.values(value).join(", ") : decodeURIComponent(value);
4053
3635
  }
4054
3636
  let displayedOperator = operator;
4055
- if (attribute.name === "mime") {
3637
+ if (attribute?.name === "mime") {
4056
3638
  displayedOperator = operator === "$contains" ? "$eq" : "$ne";
4057
3639
  if (operator === "$not") {
4058
3640
  value = "file";
@@ -4076,63 +3658,41 @@ const FilterList = ({ appliedFilters, filtersSchema, onRemoveFilter }) => {
4076
3658
  );
4077
3659
  });
4078
3660
  };
4079
- FilterList.defaultProps = {
4080
- filtersSchema: []
4081
- };
4082
- FilterList.propTypes = {
4083
- appliedFilters: PropTypes.array.isRequired,
4084
- filtersSchema: PropTypes.arrayOf(
4085
- PropTypes.shape({
4086
- name: PropTypes.string.isRequired,
4087
- metadatas: PropTypes.shape({ label: PropTypes.string }),
4088
- fieldSchema: PropTypes.shape({
4089
- type: PropTypes.string,
4090
- mainField: PropTypes.shape({
4091
- name: PropTypes.string,
4092
- type: PropTypes.string
4093
- })
4094
- })
4095
- })
4096
- ),
4097
- onRemoveFilter: PropTypes.func.isRequired
4098
- };
4099
- const FilterValueInput = ({ label, onChange, options, type, value }) => {
3661
+ const FilterValueInput = ({
3662
+ label = "",
3663
+ onChange,
3664
+ options = [],
3665
+ type,
3666
+ value = ""
3667
+ }) => {
4100
3668
  const { formatMessage } = useIntl();
4101
3669
  if (type === "date") {
4102
3670
  return /* @__PURE__ */ jsx(
4103
3671
  DateTimePicker,
4104
3672
  {
4105
3673
  clearLabel: formatMessage({ id: "clearLabel", defaultMessage: "Clear" }),
4106
- ariaLabel: label,
3674
+ "aria-label": label,
4107
3675
  name: "datetimepicker",
4108
3676
  onChange: (date) => {
4109
3677
  const formattedDate = date ? new Date(date).toISOString() : "";
4110
3678
  onChange(formattedDate);
4111
3679
  },
4112
3680
  onClear: () => onChange(""),
4113
- value: value ? new Date(value) : void 0,
4114
- selectedDateLabel: (formattedDate) => `Date picker, current is ${formattedDate}`,
4115
- selectButtonTitle: formatMessage({ id: "selectButtonTitle", defaultMessage: "Select" })
3681
+ value: value ? new Date(value) : void 0
4116
3682
  }
4117
3683
  );
4118
3684
  }
4119
- return /* @__PURE__ */ jsx(SingleSelect, { "aria-label": label, onChange, value, children: options.map((option) => {
4120
- return /* @__PURE__ */ jsx(SingleSelectOption, { value: option.value, children: option.label }, option.value);
4121
- }) });
4122
- };
4123
- FilterValueInput.defaultProps = {
4124
- label: "",
4125
- options: [],
4126
- value: ""
4127
- };
4128
- FilterValueInput.propTypes = {
4129
- label: PropTypes.string,
4130
- onChange: PropTypes.func.isRequired,
4131
- options: PropTypes.arrayOf(
4132
- PropTypes.shape({ label: PropTypes.string.isRequired, value: PropTypes.string.isRequired })
4133
- ),
4134
- type: PropTypes.string.isRequired,
4135
- value: PropTypes.any
3685
+ return /* @__PURE__ */ jsx(
3686
+ SingleSelect,
3687
+ {
3688
+ "aria-label": label,
3689
+ onChange: (value2) => onChange(value2.toString()),
3690
+ value,
3691
+ children: options?.map((option) => {
3692
+ return /* @__PURE__ */ jsx(SingleSelectOption, { value: option.value, children: option.label }, option.value);
3693
+ })
3694
+ }
3695
+ );
4136
3696
  };
4137
3697
  const getFilterList = ({ fieldSchema: { type: fieldType, mainField } }) => {
4138
3698
  const type = mainField?.schema.type ? mainField.schema.type : fieldType;
@@ -4231,28 +3791,31 @@ const getFilterList = ({ fieldSchema: { type: fieldType, mainField } }) => {
4231
3791
  };
4232
3792
  const FilterPopover = ({ displayedFilters: displayedFilters2, filters, onSubmit, onToggle }) => {
4233
3793
  const { formatMessage } = useIntl();
4234
- const [modifiedData, setModifiedData] = useState({
3794
+ const [modifiedData, setModifiedData] = React.useState({
4235
3795
  name: "createdAt",
4236
3796
  filter: "$eq",
4237
3797
  value: ""
4238
3798
  });
4239
3799
  const handleChangeFilterField = (value) => {
4240
3800
  const nextField = displayedFilters2.find((f) => f.name === value);
3801
+ if (!nextField) {
3802
+ return;
3803
+ }
4241
3804
  const {
4242
3805
  fieldSchema: { type, options }
4243
3806
  } = nextField;
4244
3807
  let filterValue = "";
4245
3808
  if (type === "enumeration") {
4246
- filterValue = options[0].value;
3809
+ filterValue = options?.[0].value || "";
4247
3810
  }
4248
3811
  const filter = getFilterList(nextField)[0].value;
4249
- setModifiedData({ name: value, filter, value: filterValue });
3812
+ setModifiedData({ name: value.toString(), filter, value: filterValue });
4250
3813
  };
4251
3814
  const handleChangeOperator = (operator) => {
4252
3815
  if (modifiedData.name === "mime") {
4253
- setModifiedData((prev) => ({ ...prev, filter: operator, value: "image" }));
3816
+ setModifiedData((prev) => ({ ...prev, filter: operator.toString(), value: "image" }));
4254
3817
  } else {
4255
- setModifiedData((prev) => ({ ...prev, filter: operator, value: "" }));
3818
+ setModifiedData((prev) => ({ ...prev, filter: operator.toString(), value: "" }));
4256
3819
  }
4257
3820
  };
4258
3821
  const handleSubmit = (e) => {
@@ -4272,7 +3835,9 @@ const FilterPopover = ({ displayedFilters: displayedFilters2, filters, onSubmit,
4272
3835
  let filterToAdd2;
4273
3836
  if (modifiedData.filter === "$contains") {
4274
3837
  hasCurrentFilter = alreadyAppliedFilters.find((filter) => {
4275
- return filter.mime?.$not?.$contains !== void 0;
3838
+ if (typeof filter.mime?.$not !== "string" && !Array.isArray(filter.mime?.$not)) {
3839
+ return filter.mime?.$not?.$contains !== void 0;
3840
+ }
4276
3841
  }) !== void 0;
4277
3842
  filterToAdd2 = {
4278
3843
  mime: {
@@ -4301,7 +3866,8 @@ const FilterPopover = ({ displayedFilters: displayedFilters2, filters, onSubmit,
4301
3866
  return;
4302
3867
  }
4303
3868
  const hasFilter2 = alreadyAppliedFilters.find((filter) => {
4304
- return filter.mime[modifiedData.filter] === modifiedData.value;
3869
+ const modifiedDataFilter = modifiedData.filter;
3870
+ return filter.mime && filter.mime[modifiedDataFilter] === modifiedData.value;
4305
3871
  }) !== void 0;
4306
3872
  if (hasFilter2) {
4307
3873
  onToggle();
@@ -4312,7 +3878,7 @@ const FilterPopover = ({ displayedFilters: displayedFilters2, filters, onSubmit,
4312
3878
  if (filterType !== "mime") {
4313
3879
  return true;
4314
3880
  }
4315
- if (filter.mime?.$not?.$contains !== void 0) {
3881
+ if (typeof filter.mime?.$not !== "string" && !Array.isArray(filter.mime?.$not) && filter.mime?.$not?.$contains !== void 0) {
4316
3882
  return false;
4317
3883
  }
4318
3884
  if (Array.isArray(filter?.mime?.$contains)) {
@@ -4341,7 +3907,8 @@ const FilterPopover = ({ displayedFilters: displayedFilters2, filters, onSubmit,
4341
3907
  return;
4342
3908
  }
4343
3909
  const hasFilter = filters.find((filter) => {
4344
- return filter[modifiedData.name] && filter[modifiedData.name]?.[modifiedData.filter] === encodedValue;
3910
+ const modifiedDataName = modifiedData.name;
3911
+ return filter[modifiedDataName] && filter[modifiedDataName]?.[modifiedDataName] === encodedValue;
4345
3912
  }) !== void 0;
4346
3913
  if (!hasFilter) {
4347
3914
  let filterToAdd = { [modifiedData.name]: { [modifiedData.filter]: encodedValue } };
@@ -4365,7 +3932,7 @@ const FilterPopover = ({ displayedFilters: displayedFilters2, filters, onSubmit,
4365
3932
  onChange: handleChangeFilterField,
4366
3933
  value: modifiedData.name,
4367
3934
  children: displayedFilters2.map((filter) => {
4368
- return /* @__PURE__ */ jsx(SingleSelectOption, { value: filter.name, children: filter.metadatas.label }, filter.name);
3935
+ return /* @__PURE__ */ jsx(SingleSelectOption, { value: filter.name, children: filter.metadatas?.label }, filter.name);
4369
3936
  })
4370
3937
  }
4371
3938
  ) }),
@@ -4388,8 +3955,8 @@ const FilterPopover = ({ displayedFilters: displayedFilters2, filters, onSubmit,
4388
3955
  /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
4389
3956
  FilterValueInput,
4390
3957
  {
4391
- ...appliedFilter.metadatas,
4392
- ...appliedFilter.fieldSchema,
3958
+ ...appliedFilter?.metadatas,
3959
+ ...appliedFilter?.fieldSchema,
4393
3960
  value: modifiedData.value,
4394
3961
  onChange: (value) => setModifiedData((prev) => ({ ...prev, value }))
4395
3962
  }
@@ -4397,18 +3964,6 @@ const FilterPopover = ({ displayedFilters: displayedFilters2, filters, onSubmit,
4397
3964
  /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Button, { size: "L", variant: "secondary", startIcon: /* @__PURE__ */ jsx(Plus, {}), type: "submit", fullWidth: true, children: formatMessage({ id: "app.utils.add-filter", defaultMessage: "Add filter" }) }) })
4398
3965
  ] }) }) });
4399
3966
  };
4400
- FilterPopover.propTypes = {
4401
- displayedFilters: PropTypes.arrayOf(
4402
- PropTypes.shape({
4403
- name: PropTypes.string.isRequired,
4404
- metadatas: PropTypes.shape({ label: PropTypes.string }),
4405
- fieldSchema: PropTypes.shape({ type: PropTypes.string })
4406
- })
4407
- ).isRequired,
4408
- filters: PropTypes.array.isRequired,
4409
- onSubmit: PropTypes.func.isRequired,
4410
- onToggle: PropTypes.func.isRequired
4411
- };
4412
3967
  const Filters = ({ appliedFilters, onChangeFilters }) => {
4413
3968
  const [open, setOpen] = React.useState(false);
4414
3969
  const { formatMessage } = useIntl();
@@ -4417,7 +3972,7 @@ const Filters = ({ appliedFilters, onChangeFilters }) => {
4417
3972
  /* @__PURE__ */ jsx(
4418
3973
  FilterPopover,
4419
3974
  {
4420
- onToggle: setOpen,
3975
+ onToggle: () => setOpen((prev) => !prev),
4421
3976
  displayedFilters,
4422
3977
  filters: appliedFilters,
4423
3978
  onSubmit: onChangeFilters
@@ -4433,14 +3988,10 @@ const Filters = ({ appliedFilters, onChangeFilters }) => {
4433
3988
  )
4434
3989
  ] });
4435
3990
  };
4436
- Filters.propTypes = {
4437
- appliedFilters: PropTypes.array.isRequired,
4438
- onChangeFilters: PropTypes.func.isRequired
4439
- };
4440
3991
  const PageSize = ({ onChangePageSize, pageSize }) => {
4441
3992
  const { formatMessage } = useIntl();
4442
3993
  const handleChange = (value) => {
4443
- onChangePageSize(value);
3994
+ onChangePageSize(Number(value));
4444
3995
  };
4445
3996
  return /* @__PURE__ */ jsxs(Flex, { children: [
4446
3997
  /* @__PURE__ */ jsxs(
@@ -4467,16 +4018,12 @@ const PageSize = ({ onChangePageSize, pageSize }) => {
4467
4018
  }) }) })
4468
4019
  ] });
4469
4020
  };
4470
- PageSize.propTypes = {
4471
- onChangePageSize: PropTypes.func.isRequired,
4472
- pageSize: PropTypes.number.isRequired
4473
- };
4474
- const PaginationContext = createContext({ activePage: 1, pageCount: 1 });
4475
- const usePagination = () => useContext(PaginationContext);
4021
+ const PaginationContext = React.createContext({ activePage: 1, pageCount: 1 });
4022
+ const usePagination = () => React.useContext(PaginationContext);
4476
4023
  const PaginationText = styled(Typography)`
4477
4024
  line-height: revert;
4478
4025
  `;
4479
- const LinkWrapper = styled.button`
4026
+ const linkWrapperStyles = css`
4480
4027
  padding: ${({ theme }) => theme.spaces[3]};
4481
4028
  border-radius: ${({ theme }) => theme.borderRadius};
4482
4029
  box-shadow: ${({ $active, theme }) => $active ? theme.shadows.filterShadow : void 0};
@@ -4513,8 +4060,14 @@ const LinkWrapper = styled.button`
4513
4060
  }
4514
4061
  }
4515
4062
  `;
4516
- LinkWrapper.defaultProps = { type: "button" };
4517
- const PageLinkWrapper = styled(LinkWrapper)`
4063
+ const LinkWrapperButton = styled.button`
4064
+ ${linkWrapperStyles}
4065
+ `;
4066
+ const LinkWrapperDiv = styled.div`
4067
+ ${linkWrapperStyles}
4068
+ `;
4069
+ LinkWrapperButton.defaultProps = { type: "button" };
4070
+ const PageLinkWrapper = styled(LinkWrapperButton)`
4518
4071
  color: ${({ theme, $active }) => $active ? theme.colors.primary700 : theme.colors.neutral800};
4519
4072
  background: ${({ theme, $active }) => $active ? theme.colors.neutral0 : void 0};
4520
4073
 
@@ -4522,7 +4075,7 @@ const PageLinkWrapper = styled(LinkWrapper)`
4522
4075
  box-shadow: ${({ theme }) => theme.shadows.filterShadow};
4523
4076
  }
4524
4077
  `;
4525
- const ActionLinkWrapper = styled(LinkWrapper)`
4078
+ const ActionLinkWrapper = styled(LinkWrapperButton)`
4526
4079
  font-size: 1.1rem;
4527
4080
  svg path {
4528
4081
  fill: ${(p) => p["aria-disabled"] ? p.theme.colors.neutral300 : p.theme.colors.neutral600};
@@ -4539,7 +4092,7 @@ const ActionLinkWrapper = styled(LinkWrapper)`
4539
4092
  pointer-events: none;
4540
4093
  ` : void 0}
4541
4094
  `;
4542
- const DotsWrapper = styled(LinkWrapper)`
4095
+ const DotsWrapper = styled(LinkWrapperDiv)`
4543
4096
  color: ${({ theme }) => theme.colors.neutral800};
4544
4097
  `;
4545
4098
  const PreviousLink = ({ children, ...props }) => {
@@ -4566,36 +4119,24 @@ const PageLink = ({ number, children, ...props }) => {
4566
4119
  /* @__PURE__ */ jsx(PaginationText, { "aria-hidden": true, variant: "pi", fontWeight: isActive ? "bold" : "", children: number })
4567
4120
  ] }) });
4568
4121
  };
4569
- const Dots = ({ children, ...props }) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(DotsWrapper, { ...props, tag: "div", children: [
4122
+ const Dots = ({ children, ...props }) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(DotsWrapper, { ...props, as: "div", children: [
4570
4123
  /* @__PURE__ */ jsx(VisuallyHidden, { children }),
4571
4124
  /* @__PURE__ */ jsx(PaginationText, { "aria-hidden": true, small: true, children: "…" })
4572
4125
  ] }) });
4573
- PageLink.propTypes = {
4574
- children: PropTypes.node.isRequired,
4575
- number: PropTypes.number.isRequired
4576
- };
4577
- const sharedPropTypes = {
4578
- children: PropTypes.node.isRequired
4579
- };
4580
- NextLink.propTypes = sharedPropTypes;
4581
- PreviousLink.propTypes = sharedPropTypes;
4582
- Dots.propTypes = {
4583
- children: PropTypes.node.isRequired
4584
- };
4585
- const Pagination = ({ children, label, activePage, pageCount }) => {
4586
- const paginationValue = useMemo(() => ({ activePage, pageCount }), [activePage, pageCount]);
4126
+ const Pagination = ({
4127
+ children,
4128
+ activePage,
4129
+ pageCount,
4130
+ label = "pagination"
4131
+ }) => {
4132
+ const paginationValue = React.useMemo(() => ({ activePage, pageCount }), [activePage, pageCount]);
4587
4133
  return /* @__PURE__ */ jsx(PaginationContext.Provider, { value: paginationValue, children: /* @__PURE__ */ jsx(Box, { tag: "nav", "aria-label": label, children: /* @__PURE__ */ jsx(Flex, { tag: "ul", gap: 1, children }) }) });
4588
4134
  };
4589
- Pagination.defaultProps = {
4590
- label: "pagination"
4591
- };
4592
- Pagination.propTypes = {
4593
- activePage: PropTypes.number.isRequired,
4594
- children: PropTypes.node.isRequired,
4595
- label: PropTypes.string,
4596
- pageCount: PropTypes.number.isRequired
4597
- };
4598
- const PaginationFooter = ({ activePage, onChangePage, pagination: { pageCount } }) => {
4135
+ const PaginationFooter = ({
4136
+ activePage,
4137
+ onChangePage,
4138
+ pagination: { pageCount }
4139
+ }) => {
4599
4140
  const { formatMessage } = useIntl();
4600
4141
  const previousActivePage = activePage - 1;
4601
4142
  const nextActivePage = activePage + 1;
@@ -4732,21 +4273,16 @@ const PaginationFooter = ({ activePage, onChangePage, pagination: { pageCount }
4732
4273
  }) })
4733
4274
  ] });
4734
4275
  };
4735
- PaginationFooter.propTypes = {
4736
- activePage: PropTypes.number.isRequired,
4737
- onChangePage: PropTypes.func.isRequired,
4738
- pagination: PropTypes.shape({ pageCount: PropTypes.number.isRequired }).isRequired
4739
- };
4740
- const SearchAsset = ({ onChangeSearch, queryValue }) => {
4276
+ const SearchAsset = ({ onChangeSearch, queryValue = null }) => {
4741
4277
  const { formatMessage } = useIntl();
4742
4278
  const { trackUsage } = useTracking();
4743
- const [isOpen, setIsOpen] = useState(!!queryValue);
4744
- const [value, setValue] = useState(queryValue || "");
4745
- const wrapperRef = useRef(null);
4746
- useLayoutEffect(() => {
4279
+ const [isOpen, setIsOpen] = React.useState(!!queryValue);
4280
+ const [value, setValue] = React.useState(queryValue || "");
4281
+ const wrapperRef = React.useRef(null);
4282
+ React.useLayoutEffect(() => {
4747
4283
  if (isOpen) {
4748
4284
  setTimeout(() => {
4749
- wrapperRef.current.querySelector("input").focus();
4285
+ wrapperRef.current?.querySelector("input")?.focus();
4750
4286
  }, 0);
4751
4287
  }
4752
4288
  }, [isOpen]);
@@ -4786,13 +4322,6 @@ const SearchAsset = ({ onChangeSearch, queryValue }) => {
4786
4322
  }
4787
4323
  return /* @__PURE__ */ jsx(IconButton, { label: "Search", onClick: handleToggle, children: /* @__PURE__ */ jsx(Search, {}) });
4788
4324
  };
4789
- SearchAsset.defaultProps = {
4790
- queryValue: null
4791
- };
4792
- SearchAsset.propTypes = {
4793
- onChangeSearch: PropTypes.func.isRequired,
4794
- queryValue: PropTypes.string
4795
- };
4796
4325
  const isSelectable = (allowedTypes, mime = "") => {
4797
4326
  if (!mime)
4798
4327
  return false;
@@ -4810,12 +4339,12 @@ const ActionContainer = styled(Box)`
4810
4339
  }
4811
4340
  `;
4812
4341
  const BrowseStep = ({
4813
- allowedTypes,
4342
+ allowedTypes = [],
4814
4343
  assets: rawAssets,
4815
4344
  canCreate,
4816
4345
  canRead,
4817
- folders,
4818
- multiple,
4346
+ folders = [],
4347
+ multiple = false,
4819
4348
  onAddAsset,
4820
4349
  onChangeFilters,
4821
4350
  onChangePage,
@@ -4832,8 +4361,8 @@ const BrowseStep = ({
4832
4361
  selectedAssets
4833
4362
  }) => {
4834
4363
  const { formatMessage } = useIntl();
4835
- const [view, setView] = usePersistentState(localStorageKeys.modalView, viewOptions.GRID);
4836
- const isGridView = view === viewOptions.GRID;
4364
+ const [view, setView] = usePersistentState(localStorageKeys$1.modalView, viewOptions$1.GRID);
4365
+ const isGridView = view === viewOptions$1.GRID;
4837
4366
  const { data: currentFolder, isLoading: isCurrentFolderLoading } = useFolder(
4838
4367
  queryObject?.folder,
4839
4368
  {
@@ -4846,7 +4375,7 @@ const BrowseStep = ({
4846
4375
  isSelectable: isSelectable(singularTypes, asset?.mime),
4847
4376
  type: "asset"
4848
4377
  }));
4849
- const breadcrumbs = !isCurrentFolderLoading && getBreadcrumbDataCM(currentFolder);
4378
+ const breadcrumbs = !isCurrentFolderLoading ? getBreadcrumbDataCM(currentFolder) : void 0;
4850
4379
  const allAllowedAsset = getAllowedFiles(allowedTypes, assets);
4851
4380
  const areAllAssetSelected = allAllowedAsset.length > 0 && selectedAssets.length > 0 && allAllowedAsset.every(
4852
4381
  (asset) => selectedAssets.findIndex((currAsset) => currAsset.id === asset.id) !== -1
@@ -4908,7 +4437,7 @@ const BrowseStep = ({
4908
4437
  id: "view-switch.grid",
4909
4438
  defaultMessage: "Grid View"
4910
4439
  }),
4911
- onClick: () => setView(isGridView ? viewOptions.LIST : viewOptions.GRID),
4440
+ onClick: () => setView(isGridView ? viewOptions$1.LIST : viewOptions$1.GRID),
4912
4441
  children: isGridView ? /* @__PURE__ */ jsx(List, {}) : /* @__PURE__ */ jsx(GridFour, {})
4913
4442
  }
4914
4443
  ) }),
@@ -5038,8 +4567,8 @@ const BrowseStep = ({
5038
4567
  defaultMessage: "{folderCount, plural, =0 {# folder} one {# folder} other {# folders}}, {filesCount, plural, =0 {# asset} one {# asset} other {# assets}}"
5039
4568
  },
5040
4569
  {
5041
- folderCount: folder.children.count,
5042
- filesCount: folder.files.count
4570
+ folderCount: folder.children?.count,
4571
+ filesCount: folder.files?.count
5043
4572
  }
5044
4573
  )
5045
4574
  }
@@ -5076,7 +4605,13 @@ const BrowseStep = ({
5076
4605
  ) })
5077
4606
  ] }),
5078
4607
  pagination.pageCount > 0 && /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", paddingTop: 4, children: [
5079
- /* @__PURE__ */ jsx(PageSize, { pageSize: queryObject.pageSize, onChangePageSize }),
4608
+ /* @__PURE__ */ jsx(
4609
+ PageSize,
4610
+ {
4611
+ pageSize: queryObject.pageSize,
4612
+ onChangePageSize
4613
+ }
4614
+ ),
5080
4615
  /* @__PURE__ */ jsx(
5081
4616
  PaginationFooter,
5082
4617
  {
@@ -5088,41 +4623,6 @@ const BrowseStep = ({
5088
4623
  ] })
5089
4624
  ] });
5090
4625
  };
5091
- BrowseStep.defaultProps = {
5092
- allowedTypes: [],
5093
- folders: [],
5094
- multiple: false,
5095
- onSelectAllAsset: void 0
5096
- };
5097
- BrowseStep.propTypes = {
5098
- allowedTypes: PropTypes.arrayOf(PropTypes.string),
5099
- assets: PropTypes.arrayOf(AssetDefinition).isRequired,
5100
- canCreate: PropTypes.bool.isRequired,
5101
- canRead: PropTypes.bool.isRequired,
5102
- folders: PropTypes.arrayOf(FolderDefinition),
5103
- multiple: PropTypes.bool,
5104
- onAddAsset: PropTypes.func.isRequired,
5105
- onChangeFilters: PropTypes.func.isRequired,
5106
- onChangeFolder: PropTypes.func.isRequired,
5107
- onChangePage: PropTypes.func.isRequired,
5108
- onChangePageSize: PropTypes.func.isRequired,
5109
- onChangeSort: PropTypes.func.isRequired,
5110
- onChangeSearch: PropTypes.func.isRequired,
5111
- onEditAsset: PropTypes.func.isRequired,
5112
- onEditFolder: PropTypes.func.isRequired,
5113
- onSelectAsset: PropTypes.func.isRequired,
5114
- onSelectAllAsset: PropTypes.func,
5115
- queryObject: PropTypes.shape({
5116
- filters: PropTypes.object,
5117
- page: PropTypes.number.isRequired,
5118
- pageSize: PropTypes.number.isRequired,
5119
- _q: PropTypes.string,
5120
- sort: PropTypes.string,
5121
- folder: PropTypes.number
5122
- }).isRequired,
5123
- pagination: PropTypes.shape({ pageCount: PropTypes.number.isRequired }).isRequired,
5124
- selectedAssets: PropTypes.arrayOf(PropTypes.shape({})).isRequired
5125
- };
5126
4626
  const DialogFooter = ({ onClose, onValidate }) => {
5127
4627
  const { formatMessage } = useIntl();
5128
4628
  return /* @__PURE__ */ jsxs(Modal.Footer, { children: [
@@ -5130,14 +4630,11 @@ const DialogFooter = ({ onClose, onValidate }) => {
5130
4630
  onValidate && /* @__PURE__ */ jsx(Button, { onClick: onValidate, children: formatMessage({ id: "global.finish", defaultMessage: "Finish" }) })
5131
4631
  ] });
5132
4632
  };
5133
- DialogFooter.defaultProps = {
5134
- onValidate: void 0
5135
- };
5136
- DialogFooter.propTypes = {
5137
- onClose: PropTypes.func.isRequired,
5138
- onValidate: PropTypes.func
5139
- };
5140
- const SelectedStep = ({ selectedAssets, onSelectAsset, onReorderAsset }) => {
4633
+ const SelectedStep = ({
4634
+ selectedAssets,
4635
+ onSelectAsset,
4636
+ onReorderAsset
4637
+ }) => {
5141
4638
  const { formatMessage } = useIntl();
5142
4639
  return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 4, children: [
5143
4640
  /* @__PURE__ */ jsxs(Flex, { gap: 0, children: [
@@ -5165,32 +4662,24 @@ const SelectedStep = ({ selectedAssets, onSelectAsset, onReorderAsset }) => {
5165
4662
  )
5166
4663
  ] });
5167
4664
  };
5168
- SelectedStep.defaultProps = {
5169
- onReorderAsset: void 0
5170
- };
5171
- SelectedStep.propTypes = {
5172
- onSelectAsset: PropTypes.func.isRequired,
5173
- selectedAssets: PropTypes.arrayOf(PropTypes.shape({})).isRequired,
5174
- onReorderAsset: PropTypes.func
5175
- };
5176
4665
  const LoadingBody = styled(Flex)`
5177
4666
  /* 80px are coming from the Tabs component that is not included in the ModalBody */
5178
4667
  min-height: ${() => `calc(60vh + 8rem)`};
5179
4668
  `;
5180
4669
  const AssetContent = ({
5181
- allowedTypes,
5182
- folderId,
4670
+ allowedTypes = [],
4671
+ folderId = null,
5183
4672
  onClose,
5184
4673
  onAddAsset,
5185
4674
  onAddFolder,
5186
4675
  onChangeFolder,
5187
4676
  onValidate,
5188
- multiple,
5189
- initiallySelectedAssets,
4677
+ multiple = false,
4678
+ initiallySelectedAssets = [],
5190
4679
  trackedLocation
5191
4680
  }) => {
5192
- const [assetToEdit, setAssetToEdit] = useState(void 0);
5193
- const [folderToEdit, setFolderToEdit] = useState(void 0);
4681
+ const [assetToEdit, setAssetToEdit] = React.useState(void 0);
4682
+ const [folderToEdit, setFolderToEdit] = React.useState(void 0);
5194
4683
  const { formatMessage } = useIntl();
5195
4684
  const {
5196
4685
  canRead,
@@ -5312,7 +4801,9 @@ const AssetContent = ({
5312
4801
  };
5313
4802
  const handleFolderChange = (folderId2, folderPath) => {
5314
4803
  onChangeFolder(folderId2);
5315
- onChangeFolderParam(folderId2, folderPath);
4804
+ if (onChangeFolderParam) {
4805
+ onChangeFolderParam(folderId2, folderPath);
4806
+ }
5316
4807
  };
5317
4808
  return /* @__PURE__ */ jsxs(Fragment, { children: [
5318
4809
  /* @__PURE__ */ jsx(Modal.Header, { children: /* @__PURE__ */ jsx(Modal.Title, { children: formatMessage({
@@ -5371,11 +4862,11 @@ const AssetContent = ({
5371
4862
  pagination,
5372
4863
  queryObject,
5373
4864
  onAddAsset,
5374
- onChangeFilters,
4865
+ onChangeFilters: (filters) => onChangeFilters(filters),
5375
4866
  onChangeFolder: handleFolderChange,
5376
4867
  onChangePage,
5377
4868
  onChangePageSize,
5378
- onChangeSort,
4869
+ onChangeSort: (sort) => onChangeSort(sort),
5379
4870
  onChangeSearch
5380
4871
  }
5381
4872
  ) }),
@@ -5392,49 +4883,9 @@ const AssetContent = ({
5392
4883
  /* @__PURE__ */ jsx(DialogFooter, { onClose, onValidate: () => onValidate(selectedAssets) })
5393
4884
  ] });
5394
4885
  };
5395
- AssetContent.defaultProps = {
5396
- allowedTypes: [],
5397
- folderId: null,
5398
- initiallySelectedAssets: [],
5399
- multiple: false,
5400
- trackedLocation: void 0
5401
- };
5402
- AssetContent.propTypes = {
5403
- allowedTypes: PropTypes.arrayOf(PropTypes.string),
5404
- folderId: PropTypes.number,
5405
- initiallySelectedAssets: PropTypes.arrayOf(AssetDefinition),
5406
- multiple: PropTypes.bool,
5407
- onAddAsset: PropTypes.func.isRequired,
5408
- onAddFolder: PropTypes.func.isRequired,
5409
- onChangeFolder: PropTypes.func.isRequired,
5410
- onClose: PropTypes.func.isRequired,
5411
- onValidate: PropTypes.func.isRequired,
5412
- trackedLocation: PropTypes.string
5413
- };
5414
- const AssetDialog = ({ open, onClose, ...restProps }) => {
4886
+ const AssetDialog = ({ open = false, onClose, ...restProps }) => {
5415
4887
  return /* @__PURE__ */ jsx(Modal.Root, { open, onOpenChange: onClose, children: /* @__PURE__ */ jsx(Modal.Content, { children: /* @__PURE__ */ jsx(AssetContent, { onClose, ...restProps }) }) });
5416
4888
  };
5417
- AssetDialog.defaultProps = {
5418
- allowedTypes: [],
5419
- folderId: null,
5420
- initiallySelectedAssets: [],
5421
- multiple: false,
5422
- open: false,
5423
- trackedLocation: void 0
5424
- };
5425
- AssetDialog.propTypes = {
5426
- allowedTypes: PropTypes.arrayOf(PropTypes.string),
5427
- folderId: PropTypes.number,
5428
- initiallySelectedAssets: PropTypes.arrayOf(AssetDefinition),
5429
- multiple: PropTypes.bool,
5430
- onAddAsset: PropTypes.func.isRequired,
5431
- onAddFolder: PropTypes.func.isRequired,
5432
- onChangeFolder: PropTypes.func.isRequired,
5433
- open: PropTypes.bool,
5434
- onClose: PropTypes.func.isRequired,
5435
- onValidate: PropTypes.func.isRequired,
5436
- trackedLocation: PropTypes.string
5437
- };
5438
4889
  const TabsRoot = styled(Tabs.Root)`
5439
4890
  display: flex;
5440
4891
  flex-direction: column;
@@ -5457,10 +4908,14 @@ const OpaqueBox = styled(Box)`
5457
4908
  opacity: 0;
5458
4909
  cursor: pointer;
5459
4910
  `;
5460
- const FromComputerForm = ({ onClose, onAddAssets, trackedLocation }) => {
4911
+ const FromComputerForm = ({
4912
+ onClose,
4913
+ onAddAssets,
4914
+ trackedLocation
4915
+ }) => {
5461
4916
  const { formatMessage } = useIntl();
5462
- const [dragOver, setDragOver] = useState(false);
5463
- const inputRef = useRef(null);
4917
+ const [dragOver, setDragOver] = React.useState(false);
4918
+ const inputRef = React.useRef(null);
5464
4919
  const { trackUsage } = useTracking();
5465
4920
  const handleDragOver = (event) => {
5466
4921
  event.preventDefault();
@@ -5472,15 +4927,19 @@ const FromComputerForm = ({ onClose, onAddAssets, trackedLocation }) => {
5472
4927
  const handleDragLeave = () => setDragOver(false);
5473
4928
  const handleClick = (e) => {
5474
4929
  e.preventDefault();
5475
- inputRef.current.click();
4930
+ inputRef.current?.click();
5476
4931
  };
5477
4932
  const handleChange = () => {
5478
- const files2 = inputRef.current.files;
4933
+ const files2 = inputRef.current?.files;
5479
4934
  const assets = [];
5480
- for (let i = 0; i < files2.length; i++) {
5481
- const file = files2.item(i);
5482
- const asset = rawFileToAsset(file, AssetSource.Computer);
5483
- assets.push(asset);
4935
+ if (files2) {
4936
+ for (let i = 0; i < files2.length; i++) {
4937
+ const file = files2.item(i);
4938
+ if (file) {
4939
+ const asset = rawFileToAsset(file, AssetSource.Computer);
4940
+ assets.push(asset);
4941
+ }
4942
+ }
5484
4943
  }
5485
4944
  if (trackedLocation) {
5486
4945
  trackUsage("didSelectFile", { source: "computer", location: trackedLocation });
@@ -5494,8 +4953,10 @@ const FromComputerForm = ({ onClose, onAddAssets, trackedLocation }) => {
5494
4953
  const assets = [];
5495
4954
  for (let i = 0; i < files2.length; i++) {
5496
4955
  const file = files2.item(i);
5497
- const asset = rawFileToAsset(file, AssetSource.Computer);
5498
- assets.push(asset);
4956
+ if (file) {
4957
+ const asset = rawFileToAsset(file, AssetSource.Computer);
4958
+ assets.push(asset);
4959
+ }
5499
4960
  }
5500
4961
  onAddAssets(assets);
5501
4962
  }
@@ -5554,17 +5015,9 @@ const FromComputerForm = ({ onClose, onAddAssets, trackedLocation }) => {
5554
5015
  }) }) })
5555
5016
  ] });
5556
5017
  };
5557
- FromComputerForm.defaultProps = {
5558
- trackedLocation: void 0
5559
- };
5560
- FromComputerForm.propTypes = {
5561
- onClose: PropTypes.func.isRequired,
5562
- onAddAssets: PropTypes.func.isRequired,
5563
- trackedLocation: PropTypes.string
5564
- };
5565
5018
  const FromUrlForm = ({ onClose, onAddAsset, trackedLocation }) => {
5566
- const [loading, setLoading] = useState(false);
5567
- const [error, setError] = useState(void 0);
5019
+ const [loading, setLoading] = React.useState(false);
5020
+ const [error, setError] = React.useState(void 0);
5568
5021
  const { formatMessage } = useIntl();
5569
5022
  const { trackUsage } = useTracking();
5570
5023
  const handleSubmit = async ({ urls }) => {
@@ -5619,14 +5072,6 @@ const FromUrlForm = ({ onClose, onAddAsset, trackedLocation }) => {
5619
5072
  }
5620
5073
  );
5621
5074
  };
5622
- FromUrlForm.defaultProps = {
5623
- trackedLocation: void 0
5624
- };
5625
- FromUrlForm.propTypes = {
5626
- onClose: PropTypes.func.isRequired,
5627
- onAddAsset: PropTypes.func.isRequired,
5628
- trackedLocation: PropTypes.string
5629
- };
5630
5075
  const AddAssetStep = ({ onClose, onAddAsset, trackedLocation }) => {
5631
5076
  const { formatMessage } = useIntl();
5632
5077
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -5676,14 +5121,6 @@ const AddAssetStep = ({ onClose, onAddAsset, trackedLocation }) => {
5676
5121
  ] })
5677
5122
  ] });
5678
5123
  };
5679
- AddAssetStep.defaultProps = {
5680
- trackedLocation: void 0
5681
- };
5682
- AddAssetStep.propTypes = {
5683
- onClose: PropTypes.func.isRequired,
5684
- onAddAsset: PropTypes.func.isRequired,
5685
- trackedLocation: PropTypes.string
5686
- };
5687
5124
  const UploadProgressWrapper = styled.div`
5688
5125
  height: 8.8rem;
5689
5126
  width: 100%;
@@ -5696,7 +5133,7 @@ const UploadingAssetCard = ({
5696
5133
  onCancel,
5697
5134
  onStatusChange,
5698
5135
  addUploadedFiles,
5699
- folderId
5136
+ folderId = null
5700
5137
  }) => {
5701
5138
  const { upload, cancel, error, progress, status } = useUpload();
5702
5139
  const { formatMessage } = useIntl();
@@ -5720,16 +5157,16 @@ const UploadingAssetCard = ({
5720
5157
  defaultMessage: "Audio"
5721
5158
  });
5722
5159
  }
5723
- useEffect(() => {
5160
+ React.useEffect(() => {
5724
5161
  const uploadFile = async () => {
5725
- const files2 = await upload(asset, folderId);
5162
+ const files2 = await upload(asset, folderId ? Number(folderId) : null);
5726
5163
  if (addUploadedFiles) {
5727
5164
  addUploadedFiles(files2);
5728
5165
  }
5729
5166
  };
5730
5167
  uploadFile();
5731
5168
  }, []);
5732
- useEffect(() => {
5169
+ React.useEffect(() => {
5733
5170
  onStatusChange(status);
5734
5171
  }, [status, onStatusChange]);
5735
5172
  const handleCancel = () => {
@@ -5738,19 +5175,26 @@ const UploadingAssetCard = ({
5738
5175
  };
5739
5176
  return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 1, children: [
5740
5177
  /* @__PURE__ */ jsxs(Card$1, { borderColor: error ? "danger600" : "neutral150", children: [
5741
- /* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(UploadProgressWrapper, { children: /* @__PURE__ */ jsx(UploadProgress, { error, onCancel: handleCancel, progress }) }) }),
5178
+ /* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(UploadProgressWrapper, { children: /* @__PURE__ */ jsx(
5179
+ UploadProgress,
5180
+ {
5181
+ error: error || void 0,
5182
+ onCancel: handleCancel,
5183
+ progress
5184
+ }
5185
+ ) }) }),
5742
5186
  /* @__PURE__ */ jsxs(CardBody, { children: [
5743
5187
  /* @__PURE__ */ jsxs(CardContent, { children: [
5744
- /* @__PURE__ */ jsx(Box, { paddingTop: 1, children: /* @__PURE__ */ jsx(CardTitle, { tag: "h2", children: asset.name }) }),
5188
+ /* @__PURE__ */ jsx(Box, { paddingTop: 1, children: /* @__PURE__ */ jsx(Typography, { tag: "h2", children: /* @__PURE__ */ jsx(CardTitle, { tag: "span", children: asset.name }) }) }),
5745
5189
  /* @__PURE__ */ jsx(CardSubtitle, { children: /* @__PURE__ */ jsx(Extension, { children: asset.ext }) })
5746
5190
  ] }),
5747
5191
  /* @__PURE__ */ jsx(Flex, { paddingTop: 1, grow: 1, children: /* @__PURE__ */ jsx(CardBadge, { children: badgeContent }) })
5748
5192
  ] })
5749
5193
  ] }),
5750
5194
  error ? /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", textColor: "danger600", children: formatMessage(
5751
- error?.response?.data?.error?.message ? {
5752
- id: getTrad(`apiError.${error.response.data.error.message}`),
5753
- defaultMessage: error.response.data.error.message
5195
+ error?.message ? {
5196
+ id: getTrad(`apiError.${error.message}`),
5197
+ defaultMessage: error.message
5754
5198
  /* See issue: https://github.com/strapi/strapi/issues/13867
5755
5199
  A proxy might return an error, before the request reaches Strapi
5756
5200
  and therefore we need to handle errors gracefully.
@@ -5762,22 +5206,6 @@ const UploadingAssetCard = ({
5762
5206
  ) }) : void 0
5763
5207
  ] });
5764
5208
  };
5765
- UploadingAssetCard.defaultProps = {
5766
- addUploadedFiles: void 0,
5767
- folderId: null
5768
- };
5769
- UploadingAssetCard.propTypes = {
5770
- addUploadedFiles: PropTypes.func,
5771
- asset: PropTypes.shape({
5772
- name: PropTypes.string,
5773
- ext: PropTypes.string,
5774
- rawFile: PropTypes.instanceOf(File),
5775
- type: PropTypes.oneOf(Object.values(AssetType))
5776
- }).isRequired,
5777
- folderId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
5778
- onCancel: PropTypes.func.isRequired,
5779
- onStatusChange: PropTypes.func.isRequired
5780
- };
5781
5209
  const Status = {
5782
5210
  Idle: "IDLE",
5783
5211
  Uploading: "UPLOADING",
@@ -5795,21 +5223,28 @@ const PendingAssetStep = ({
5795
5223
  onUploadSucceed,
5796
5224
  trackedLocation
5797
5225
  }) => {
5798
- const assetCountRef = useRef(0);
5226
+ const assetCountRef = React.useRef(0);
5799
5227
  const { formatMessage } = useIntl();
5800
5228
  const { trackUsage } = useTracking();
5801
- const [uploadStatus, setUploadStatus] = useState(Status.Idle);
5229
+ const [uploadStatus, setUploadStatus] = React.useState(Status.Idle);
5802
5230
  const handleSubmit = async (e) => {
5803
5231
  e.preventDefault();
5804
5232
  e.stopPropagation();
5805
- const assetsCountByType = assets.reduce((acc, asset) => {
5806
- const { type } = asset;
5807
- if (!acc[type]) {
5808
- acc[type] = 0;
5809
- }
5810
- acc[type] = `${parseInt(acc[type], 10) + 1}`;
5811
- return acc;
5812
- }, {});
5233
+ const assetsCountByType = assets.reduce(
5234
+ (acc, asset) => {
5235
+ const { type } = asset;
5236
+ if (type !== void 0 && !acc[type]) {
5237
+ acc[type] = 0;
5238
+ }
5239
+ if (type !== void 0) {
5240
+ const accType = acc[type];
5241
+ const currentCount = typeof accType === "string" ? accType : accType.toString();
5242
+ acc[type] = `${parseInt(currentCount, 10) + 1}`;
5243
+ }
5244
+ return acc;
5245
+ },
5246
+ {}
5247
+ );
5813
5248
  trackUsage("willAddMediaLibraryAssets", {
5814
5249
  location: trackedLocation,
5815
5250
  ...assetsCountByType
@@ -5895,40 +5330,24 @@ const PendingAssetStep = ({
5895
5330
  ] })
5896
5331
  ] });
5897
5332
  };
5898
- PendingAssetStep.defaultProps = {
5899
- addUploadedFiles: void 0,
5900
- folderId: null,
5901
- trackedLocation: void 0
5902
- };
5903
- PendingAssetStep.propTypes = {
5904
- addUploadedFiles: PropTypes.func,
5905
- assets: PropTypes.arrayOf(AssetDefinition).isRequired,
5906
- folderId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
5907
- onClose: PropTypes.func.isRequired,
5908
- onEditAsset: PropTypes.func.isRequired,
5909
- onRemoveAsset: PropTypes.func.isRequired,
5910
- onClickAddAsset: PropTypes.func.isRequired,
5911
- onUploadSucceed: PropTypes.func.isRequired,
5912
- onCancelUpload: PropTypes.func.isRequired,
5913
- trackedLocation: PropTypes.string
5914
- };
5915
5333
  const Steps = {
5916
5334
  AddAsset: "AddAsset",
5917
5335
  PendingAsset: "PendingAsset"
5918
5336
  };
5919
5337
  const UploadAssetDialog = ({
5920
5338
  initialAssetsToAdd,
5921
- folderId,
5922
- onClose,
5339
+ folderId = null,
5340
+ onClose = () => {
5341
+ },
5923
5342
  addUploadedFiles,
5924
5343
  trackedLocation,
5925
5344
  open,
5926
5345
  validateAssetsTypes = (_, cb) => cb()
5927
5346
  }) => {
5928
5347
  const { formatMessage } = useIntl();
5929
- const [step, setStep] = useState(initialAssetsToAdd ? Steps.PendingAsset : Steps.AddAsset);
5930
- const [assets, setAssets] = useState(initialAssetsToAdd || []);
5931
- const [assetToEdit, setAssetToEdit] = useState(void 0);
5348
+ const [step, setStep] = React.useState(initialAssetsToAdd ? Steps.PendingAsset : Steps.AddAsset);
5349
+ const [assets, setAssets] = React.useState(initialAssetsToAdd || []);
5350
+ const [assetToEdit, setAssetToEdit] = React.useState(void 0);
5932
5351
  const handleAddToPendingAssets = (nextAssets) => {
5933
5352
  validateAssetsTypes(nextAssets, () => {
5934
5353
  setAssets((prevAssets) => prevAssets.concat(nextAssets));
@@ -5953,7 +5372,7 @@ const UploadAssetDialog = ({
5953
5372
  }
5954
5373
  };
5955
5374
  const handleAssetEditValidation = (nextAsset) => {
5956
- if (nextAsset) {
5375
+ if (nextAsset && typeof nextAsset !== "boolean") {
5957
5376
  const nextAssets = assets.map((asset) => asset === assetToEdit ? nextAsset : asset);
5958
5377
  setAssets(nextAssets);
5959
5378
  }
@@ -5983,7 +5402,7 @@ const UploadAssetDialog = ({
5983
5402
  AddAssetStep,
5984
5403
  {
5985
5404
  onClose,
5986
- onAddAsset: handleAddToPendingAssets,
5405
+ onAddAsset: (assets2) => handleAddToPendingAssets(assets2),
5987
5406
  trackedLocation
5988
5407
  }
5989
5408
  ) }),
@@ -6016,32 +5435,18 @@ const UploadAssetDialog = ({
6016
5435
  ) })
6017
5436
  ] });
6018
5437
  };
6019
- UploadAssetDialog.defaultProps = {
6020
- addUploadedFiles: void 0,
6021
- folderId: null,
6022
- initialAssetsToAdd: void 0,
6023
- onClose() {
6024
- },
6025
- trackedLocation: void 0,
6026
- validateAssetsTypes: void 0
6027
- };
6028
- UploadAssetDialog.propTypes = {
6029
- addUploadedFiles: PropTypes.func,
6030
- folderId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
6031
- initialAssetsToAdd: PropTypes.arrayOf(AssetDefinition),
6032
- open: PropTypes.bool.isRequired,
6033
- onClose: PropTypes.func,
6034
- trackedLocation: PropTypes.string,
6035
- validateAssetsTypes: PropTypes.func
6036
- };
6037
5438
  const STEPS$1 = {
6038
5439
  AssetSelect: "SelectAsset",
6039
5440
  AssetUpload: "UploadAsset",
6040
5441
  FolderCreate: "FolderCreate"
6041
5442
  };
6042
- const MediaLibraryDialog = ({ onClose, onSelectAssets, allowedTypes }) => {
6043
- const [step, setStep] = useState(STEPS$1.AssetSelect);
6044
- const [folderId, setFolderId] = useState(null);
5443
+ const MediaLibraryDialog = ({
5444
+ onClose,
5445
+ onSelectAssets,
5446
+ allowedTypes = ["files", "images", "videos", "audios"]
5447
+ }) => {
5448
+ const [step, setStep] = React.useState(STEPS$1.AssetSelect);
5449
+ const [folderId, setFolderId] = React.useState(null);
6045
5450
  switch (step) {
6046
5451
  case STEPS$1.AssetSelect:
6047
5452
  return /* @__PURE__ */ jsx(
@@ -6071,14 +5476,6 @@ const MediaLibraryDialog = ({ onClose, onSelectAssets, allowedTypes }) => {
6071
5476
  return /* @__PURE__ */ jsx(UploadAssetDialog, { open: true, onClose: () => setStep(STEPS$1.AssetSelect), folderId });
6072
5477
  }
6073
5478
  };
6074
- MediaLibraryDialog.defaultProps = {
6075
- allowedTypes: ["files", "images", "videos", "audios"]
6076
- };
6077
- MediaLibraryDialog.propTypes = {
6078
- allowedTypes: PropTypes.arrayOf(PropTypes.string),
6079
- onClose: PropTypes.func.isRequired,
6080
- onSelectAssets: PropTypes.func.isRequired
6081
- };
6082
5479
  const DocAsset = styled(Flex)`
6083
5480
  background: linear-gradient(180deg, #ffffff 0%, #f6f6f9 121.48%);
6084
5481
  `;
@@ -6096,7 +5493,7 @@ const AudioPreviewWrapper = styled(Box)`
6096
5493
  }
6097
5494
  `;
6098
5495
  const CarouselAsset = ({ asset }) => {
6099
- if (asset.mime.includes(AssetType.Video)) {
5496
+ if (asset.mime?.includes(AssetType.Video)) {
6100
5497
  return /* @__PURE__ */ jsx(VideoPreviewWrapper, { height: "100%", children: /* @__PURE__ */ jsx(
6101
5498
  VideoPreview,
6102
5499
  {
@@ -6106,10 +5503,16 @@ const CarouselAsset = ({ asset }) => {
6106
5503
  }
6107
5504
  ) });
6108
5505
  }
6109
- if (asset.mime.includes(AssetType.Audio)) {
6110
- return /* @__PURE__ */ jsx(AudioPreviewWrapper, { children: /* @__PURE__ */ jsx(AudioPreview, { url: createAssetUrl(asset, true), alt: asset.alternativeText || asset.name }) });
5506
+ if (asset.mime?.includes(AssetType.Audio)) {
5507
+ return /* @__PURE__ */ jsx(AudioPreviewWrapper, { children: /* @__PURE__ */ jsx(
5508
+ AudioPreview,
5509
+ {
5510
+ url: createAssetUrl(asset, true),
5511
+ alt: asset.alternativeText || asset.name
5512
+ }
5513
+ ) });
6111
5514
  }
6112
- if (asset.mime.includes(AssetType.Image)) {
5515
+ if (asset.mime?.includes(AssetType.Image)) {
6113
5516
  return /* @__PURE__ */ jsx(
6114
5517
  Box,
6115
5518
  {
@@ -6121,12 +5524,14 @@ const CarouselAsset = ({ asset }) => {
6121
5524
  }
6122
5525
  );
6123
5526
  }
6124
- return /* @__PURE__ */ jsx(DocAsset, { width: "100%", height: "100%", justifyContent: "center", hasRadius: true, children: asset.ext.includes("pdf") ? /* @__PURE__ */ jsx(FilePdf, { "aria-label": asset.alternativeText || asset.name, width: "24px", height: "32px" }) : /* @__PURE__ */ jsx(File$1, { "aria-label": asset.alternativeText || asset.name, width: "24px", height: "32px" }) });
6125
- };
6126
- CarouselAsset.propTypes = {
6127
- asset: AssetDefinition.isRequired
5527
+ return /* @__PURE__ */ jsx(DocAsset, { width: "100%", height: "100%", justifyContent: "center", hasRadius: true, children: asset.ext?.includes("pdf") ? /* @__PURE__ */ jsx(FilePdf, { "aria-label": asset.alternativeText || asset.name, width: "24px", height: "32px" }) : /* @__PURE__ */ jsx(File$1, { "aria-label": asset.alternativeText || asset.name, width: "24px", height: "32px" }) });
6128
5528
  };
6129
- const CarouselAssetActions = ({ asset, onDeleteAsset, onAddAsset, onEditAsset }) => {
5529
+ const CarouselAssetActions = ({
5530
+ asset,
5531
+ onDeleteAsset,
5532
+ onAddAsset,
5533
+ onEditAsset
5534
+ }) => {
6130
5535
  const { formatMessage } = useIntl();
6131
5536
  return /* @__PURE__ */ jsxs(CarouselActions, { children: [
6132
5537
  onAddAsset && /* @__PURE__ */ jsx(
@@ -6165,23 +5570,16 @@ const CarouselAssetActions = ({ asset, onDeleteAsset, onAddAsset, onEditAsset })
6165
5570
  )
6166
5571
  ] });
6167
5572
  };
6168
- CarouselAssetActions.defaultProps = {
6169
- onAddAsset: void 0,
6170
- onDeleteAsset: void 0,
6171
- onEditAsset: void 0
6172
- };
6173
- CarouselAssetActions.propTypes = {
6174
- asset: AssetDefinition.isRequired,
6175
- onAddAsset: PropTypes.func,
6176
- onEditAsset: PropTypes.func,
6177
- onDeleteAsset: PropTypes.func
6178
- };
6179
5573
  const TextAlignTypography = styled(Typography)`
6180
5574
  align-items: center;
6181
5575
  `;
6182
- const EmptyStateAsset = ({ disabled, onClick, onDropAsset }) => {
5576
+ const EmptyStateAsset = ({
5577
+ disabled = false,
5578
+ onClick,
5579
+ onDropAsset
5580
+ }) => {
6183
5581
  const { formatMessage } = useIntl();
6184
- const [dragOver, setDragOver] = useState(false);
5582
+ const [dragOver, setDragOver] = React.useState(false);
6185
5583
  const handleDragEnter = (e) => {
6186
5584
  e.preventDefault();
6187
5585
  setDragOver(true);
@@ -6201,8 +5599,10 @@ const EmptyStateAsset = ({ disabled, onClick, onDropAsset }) => {
6201
5599
  const assets = [];
6202
5600
  for (let i = 0; i < files2.length; i++) {
6203
5601
  const file = files2.item(i);
6204
- const asset = rawFileToAsset(file, AssetSource.Computer);
6205
- assets.push(asset);
5602
+ if (file) {
5603
+ const asset = rawFileToAsset(file, AssetSource.Computer);
5604
+ assets.push(asset);
5605
+ }
6206
5606
  }
6207
5607
  onDropAsset(assets);
6208
5608
  }
@@ -6257,19 +5657,10 @@ const EmptyStateAsset = ({ disabled, onClick, onDropAsset }) => {
6257
5657
  }
6258
5658
  );
6259
5659
  };
6260
- EmptyStateAsset.defaultProps = {
6261
- disabled: false,
6262
- onDropAsset: void 0
6263
- };
6264
- EmptyStateAsset.propTypes = {
6265
- disabled: PropTypes.bool,
6266
- onClick: PropTypes.func.isRequired,
6267
- onDropAsset: PropTypes.func
6268
- };
6269
- const CarouselAssets = forwardRef(
5660
+ const CarouselAssets = React.forwardRef(
6270
5661
  ({
6271
5662
  assets,
6272
- disabled,
5663
+ disabled = false,
6273
5664
  error,
6274
5665
  hint,
6275
5666
  label,
@@ -6281,12 +5672,12 @@ const CarouselAssets = forwardRef(
6281
5672
  onEditAsset,
6282
5673
  onNext,
6283
5674
  onPrevious,
6284
- required,
5675
+ required = false,
6285
5676
  selectedAssetIndex,
6286
5677
  trackedLocation
6287
5678
  }, forwardedRef) => {
6288
5679
  const { formatMessage } = useIntl();
6289
- const [isEditingAsset, setIsEditingAsset] = useState(false);
5680
+ const [isEditingAsset, setIsEditingAsset] = React.useState(false);
6290
5681
  const currentAsset = assets[selectedAssetIndex];
6291
5682
  return /* @__PURE__ */ jsxs(Fragment, { children: [
6292
5683
  /* @__PURE__ */ jsx(
@@ -6329,7 +5720,14 @@ const CarouselAssets = forwardRef(
6329
5720
  },
6330
5721
  { n: 1, m: 1 }
6331
5722
  ),
6332
- children: /* @__PURE__ */ jsx(EmptyStateAsset, { disabled, onClick: onAddAsset, onDropAsset })
5723
+ children: /* @__PURE__ */ jsx(
5724
+ EmptyStateAsset,
5725
+ {
5726
+ disabled,
5727
+ onClick: onAddAsset,
5728
+ onDropAsset
5729
+ }
5730
+ )
6333
5731
  }
6334
5732
  ) : assets.map((asset, index2) => /* @__PURE__ */ jsx(
6335
5733
  CarouselSlide,
@@ -6356,8 +5754,8 @@ const CarouselAssets = forwardRef(
6356
5754
  if (editedAsset === null) {
6357
5755
  onDeleteAssetFromMediaLibrary();
6358
5756
  }
6359
- if (editedAsset) {
6360
- onEditAsset(editedAsset);
5757
+ if (editedAsset && typeof editedAsset !== "boolean") {
5758
+ onEditAsset?.(editedAsset);
6361
5759
  }
6362
5760
  },
6363
5761
  asset: currentAsset,
@@ -6370,50 +5768,31 @@ const CarouselAssets = forwardRef(
6370
5768
  ] });
6371
5769
  }
6372
5770
  );
6373
- CarouselAssets.defaultProps = {
6374
- disabled: false,
6375
- error: void 0,
6376
- hint: void 0,
6377
- labelAction: void 0,
6378
- onDropAsset: void 0,
6379
- required: false,
6380
- trackedLocation: void 0
6381
- };
6382
- CarouselAssets.propTypes = {
6383
- assets: PropTypes.arrayOf(AssetDefinition).isRequired,
6384
- disabled: PropTypes.bool,
6385
- error: PropTypes.string,
6386
- hint: PropTypes.string,
6387
- label: PropTypes.string.isRequired,
6388
- labelAction: PropTypes.node,
6389
- onAddAsset: PropTypes.func.isRequired,
6390
- onDeleteAsset: PropTypes.func.isRequired,
6391
- onDeleteAssetFromMediaLibrary: PropTypes.func.isRequired,
6392
- onDropAsset: PropTypes.func,
6393
- onEditAsset: PropTypes.func.isRequired,
6394
- onNext: PropTypes.func.isRequired,
6395
- onPrevious: PropTypes.func.isRequired,
6396
- required: PropTypes.bool,
6397
- selectedAssetIndex: PropTypes.number.isRequired,
6398
- trackedLocation: PropTypes.string
6399
- };
6400
5771
  const STEPS = {
6401
5772
  AssetSelect: "SelectAsset",
6402
5773
  AssetUpload: "UploadAsset",
6403
5774
  FolderCreate: "FolderCreate"
6404
5775
  };
6405
- const MediaLibraryInput = forwardRef(
6406
- ({ attribute: { allowedTypes, multiple }, label, hint, disabled, labelAction, name: name2, required }, forwardedRef) => {
5776
+ const MediaLibraryInput = React.forwardRef(
5777
+ ({
5778
+ attribute: { allowedTypes = ["videos", "files", "images", "audios"], multiple = false },
5779
+ label,
5780
+ hint,
5781
+ disabled = false,
5782
+ labelAction = void 0,
5783
+ name: name2,
5784
+ required = false
5785
+ }, forwardedRef) => {
6407
5786
  const { formatMessage } = useIntl();
6408
5787
  const { onChange, value, error } = useField(name2);
6409
5788
  const fieldAllowedTypes = allowedTypes || ["files", "images", "videos", "audios"];
6410
- const [uploadedFiles, setUploadedFiles] = useState([]);
6411
- const [step, setStep] = useState(void 0);
6412
- const [selectedIndex, setSelectedIndex] = useState(0);
6413
- const [droppedAssets, setDroppedAssets] = useState();
6414
- const [folderId, setFolderId] = useState(null);
5789
+ const [uploadedFiles, setUploadedFiles] = React.useState([]);
5790
+ const [step, setStep] = React.useState(void 0);
5791
+ const [selectedIndex, setSelectedIndex] = React.useState(0);
5792
+ const [droppedAssets, setDroppedAssets] = React.useState();
5793
+ const [folderId, setFolderId] = React.useState(null);
6415
5794
  const { toggleNotification } = useNotification();
6416
- useEffect(() => {
5795
+ React.useEffect(() => {
6417
5796
  if (step === void 0) {
6418
5797
  setUploadedFiles([]);
6419
5798
  }
@@ -6425,9 +5804,8 @@ const MediaLibraryInput = forwardRef(
6425
5804
  selectedAssets = [value];
6426
5805
  }
6427
5806
  const handleValidation = (nextSelectedAssets) => {
6428
- onChange({
6429
- target: { name: name2, value: multiple ? nextSelectedAssets : nextSelectedAssets[0] }
6430
- });
5807
+ const value2 = multiple ? nextSelectedAssets : nextSelectedAssets[0];
5808
+ onChange(name2, value2);
6431
5809
  setStep(void 0);
6432
5810
  };
6433
5811
  const handleDeleteAssetFromMediaLibrary = () => {
@@ -6440,9 +5818,8 @@ const MediaLibraryInput = forwardRef(
6440
5818
  } else {
6441
5819
  nextValue = null;
6442
5820
  }
6443
- onChange({
6444
- target: { name: name2, value: nextValue }
6445
- });
5821
+ const value2 = nextValue;
5822
+ onChange(name2, value2);
6446
5823
  setSelectedIndex(0);
6447
5824
  };
6448
5825
  const handleDeleteAsset = (asset) => {
@@ -6453,18 +5830,14 @@ const MediaLibraryInput = forwardRef(
6453
5830
  } else {
6454
5831
  nextValue = null;
6455
5832
  }
6456
- onChange({
6457
- target: { name: name2, value: nextValue }
6458
- });
5833
+ onChange(name2, nextValue);
6459
5834
  setSelectedIndex(0);
6460
5835
  };
6461
5836
  const handleAssetEdit = (asset) => {
6462
5837
  const nextSelectedAssets = selectedAssets.map(
6463
5838
  (prevAsset) => prevAsset.id === asset.id ? asset : prevAsset
6464
5839
  );
6465
- onChange({
6466
- target: { name: name2, value: multiple ? nextSelectedAssets : nextSelectedAssets[0] }
6467
- });
5840
+ onChange(name2, multiple ? nextSelectedAssets : nextSelectedAssets[0]);
6468
5841
  };
6469
5842
  const validateAssetsTypes = (assets, callback) => {
6470
5843
  const allowedAssets = getAllowedFiles(fieldAllowedTypes, assets);
@@ -6506,7 +5879,10 @@ const MediaLibraryInput = forwardRef(
6506
5879
  };
6507
5880
  let initiallySelectedAssets = selectedAssets;
6508
5881
  if (uploadedFiles.length > 0) {
6509
- const allowedUploadedFiles = getAllowedFiles(fieldAllowedTypes, uploadedFiles);
5882
+ const allowedUploadedFiles = getAllowedFiles(
5883
+ fieldAllowedTypes,
5884
+ uploadedFiles
5885
+ );
6510
5886
  initiallySelectedAssets = multiple ? [...allowedUploadedFiles, ...selectedAssets] : [allowedUploadedFiles[0]];
6511
5887
  }
6512
5888
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -6574,25 +5950,133 @@ const MediaLibraryInput = forwardRef(
6574
5950
  ] });
6575
5951
  }
6576
5952
  );
6577
- MediaLibraryInput.defaultProps = {
6578
- attribute: { allowedTypes: ["videos", "files", "images", "audios"], multiple: false },
6579
- disabled: false,
6580
- hint: void 0,
6581
- label: void 0,
6582
- labelAction: void 0,
6583
- required: false
6584
- };
6585
- MediaLibraryInput.propTypes = {
6586
- attribute: PropTypes.shape({
6587
- allowedTypes: PropTypes.arrayOf(PropTypes.string),
6588
- multiple: PropTypes.bool
6589
- }),
6590
- disabled: PropTypes.bool,
6591
- hint: PropTypes.string,
6592
- label: PropTypes.string,
6593
- labelAction: PropTypes.node,
5953
+ const ParentFolderShape = {
5954
+ id: PropTypes.number.isRequired,
5955
+ createdAt: PropTypes.string.isRequired,
6594
5956
  name: PropTypes.string.isRequired,
6595
- required: PropTypes.bool
5957
+ updatedAt: PropTypes.string.isRequired,
5958
+ pathId: PropTypes.number.isRequired,
5959
+ path: PropTypes.string.isRequired
5960
+ };
5961
+ ParentFolderShape.parent = PropTypes.shape(ParentFolderShape);
5962
+ const FolderShape = {
5963
+ id: PropTypes.number,
5964
+ children: PropTypes.shape({
5965
+ count: PropTypes.number.isRequired
5966
+ }),
5967
+ createdAt: PropTypes.string,
5968
+ createdBy: PropTypes.shape(),
5969
+ files: PropTypes.shape({
5970
+ count: PropTypes.number.isRequired
5971
+ }),
5972
+ name: PropTypes.string,
5973
+ updatedAt: PropTypes.string,
5974
+ updatedBy: PropTypes.shape(),
5975
+ pathId: PropTypes.number,
5976
+ path: PropTypes.string
5977
+ };
5978
+ FolderShape.parent = PropTypes.shape(ParentFolderShape);
5979
+ const FolderDefinition = PropTypes.shape(FolderShape);
5980
+ const FolderStructure = PropTypes.shape({
5981
+ value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
5982
+ label: PropTypes.string.isRequired,
5983
+ children: PropTypes.array
5984
+ });
5985
+ FolderStructure.children = PropTypes.arrayOf(PropTypes.shape(FolderStructure));
5986
+ FolderStructure.defaultProps = {
5987
+ children: void 0
5988
+ };
5989
+ PropTypes.arrayOf(FolderStructure);
5990
+ const AssetDefinition = PropTypes.shape({
5991
+ id: PropTypes.number,
5992
+ height: PropTypes.number,
5993
+ width: PropTypes.number,
5994
+ size: PropTypes.number,
5995
+ createdAt: PropTypes.string,
5996
+ ext: PropTypes.string,
5997
+ mime: PropTypes.string,
5998
+ name: PropTypes.string,
5999
+ url: PropTypes.string,
6000
+ updatedAt: PropTypes.string,
6001
+ alternativeText: PropTypes.string,
6002
+ caption: PropTypes.string,
6003
+ folder: PropTypes.shape(FolderDefinition),
6004
+ formats: PropTypes.shape({
6005
+ thumbnail: PropTypes.shape({
6006
+ url: PropTypes.string
6007
+ })
6008
+ })
6009
+ });
6010
+ const CrumbDefinition = PropTypes.shape({
6011
+ id: PropTypes.number,
6012
+ label: PropTypes.oneOfType([
6013
+ PropTypes.string,
6014
+ PropTypes.shape({
6015
+ id: PropTypes.string.isRequired,
6016
+ defaultMessage: PropTypes.string.isRequired
6017
+ })
6018
+ ]).isRequired,
6019
+ href: PropTypes.string
6020
+ });
6021
+ const CrumbMenuDefinition = PropTypes.arrayOf(CrumbDefinition);
6022
+ const BreadcrumbsDefinition = PropTypes.arrayOf(
6023
+ PropTypes.oneOfType([CrumbDefinition, CrumbMenuDefinition])
6024
+ );
6025
+ const viewOptions = {
6026
+ GRID: 0,
6027
+ LIST: 1
6028
+ };
6029
+ const pageSizes = [10, 20, 50, 100];
6030
+ const sortOptions = [
6031
+ { key: "sort.created_at_desc", value: "createdAt:DESC" },
6032
+ { key: "sort.created_at_asc", value: "createdAt:ASC" },
6033
+ { key: "sort.name_asc", value: "name:ASC" },
6034
+ { key: "sort.name_desc", value: "name:DESC" },
6035
+ { key: "sort.updated_at_desc", value: "updatedAt:DESC" },
6036
+ { key: "sort.updated_at_asc", value: "updatedAt:ASC" }
6037
+ ];
6038
+ const localStorageKeys = {
6039
+ modalView: `STRAPI_UPLOAD_MODAL_VIEW`,
6040
+ view: `STRAPI_UPLOAD_LIBRARY_VIEW`
6041
+ };
6042
+ const PERMISSIONS = {
6043
+ // This permission regards the main component (App) and is used to tell
6044
+ // If the plugin link should be displayed in the menu
6045
+ // And also if the plugin is accessible. This use case is found when a user types the url of the
6046
+ // plugin directly in the browser
6047
+ main: [
6048
+ { action: "plugin::upload.read", subject: null },
6049
+ {
6050
+ action: "plugin::upload.assets.create",
6051
+ subject: null
6052
+ },
6053
+ {
6054
+ action: "plugin::upload.assets.update",
6055
+ subject: null
6056
+ }
6057
+ ],
6058
+ copyLink: [
6059
+ {
6060
+ action: "plugin::upload.assets.copy-link",
6061
+ subject: null
6062
+ }
6063
+ ],
6064
+ create: [
6065
+ {
6066
+ action: "plugin::upload.assets.create",
6067
+ subject: null
6068
+ }
6069
+ ],
6070
+ download: [
6071
+ {
6072
+ action: "plugin::upload.assets.download",
6073
+ subject: null
6074
+ }
6075
+ ],
6076
+ read: [{ action: "plugin::upload.read", subject: null }],
6077
+ configureView: [{ action: "plugin::upload.configure-view", subject: null }],
6078
+ settings: [{ action: "plugin::upload.settings.read", subject: null }],
6079
+ update: [{ action: "plugin::upload.assets.update", subject: null, fields: null }]
6596
6080
  };
6597
6081
  const name = pluginPkg.strapi.name;
6598
6082
  const index = {
@@ -6605,7 +6089,7 @@ const index = {
6605
6089
  defaultMessage: "Media Library"
6606
6090
  },
6607
6091
  permissions: PERMISSIONS.main,
6608
- Component: () => import("./index-24xAAxoi.mjs"),
6092
+ Component: () => import("./index-DCAQ4hHN.mjs"),
6609
6093
  position: 4
6610
6094
  });
6611
6095
  app.addSettingsLink("global", {
@@ -6615,7 +6099,7 @@ const index = {
6615
6099
  defaultMessage: "Media Library"
6616
6100
  },
6617
6101
  to: "media-library",
6618
- Component: () => import("./index-BVvzCEIn.mjs"),
6102
+ Component: () => import("./index-BWIqjWzC.mjs"),
6619
6103
  permissions: PERMISSIONS.settings
6620
6104
  });
6621
6105
  app.addFields({ type: "media", Component: MediaLibraryInput });
@@ -6686,4 +6170,4 @@ export {
6686
6170
  FolderCardBodyAction as y,
6687
6171
  AssetGridList as z
6688
6172
  };
6689
- //# sourceMappingURL=index-LM-DLJqd.mjs.map
6173
+ //# sourceMappingURL=index-BwEfHu6y.mjs.map