@strapi/upload 5.34.0 → 5.36.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 (141) hide show
  1. package/dist/admin/components/EditAssetDialog/EditAssetContent.js +32 -3
  2. package/dist/admin/components/EditAssetDialog/EditAssetContent.js.map +1 -1
  3. package/dist/admin/components/EditAssetDialog/EditAssetContent.mjs +32 -3
  4. package/dist/admin/components/EditAssetDialog/EditAssetContent.mjs.map +1 -1
  5. package/dist/admin/components/EditAssetDialog/PreviewBox/AssetPreview.js.map +1 -1
  6. package/dist/admin/components/EditAssetDialog/PreviewBox/AssetPreview.mjs.map +1 -1
  7. package/dist/admin/components/EditAssetDialog/PreviewBox/FocalPointActions.js +57 -0
  8. package/dist/admin/components/EditAssetDialog/PreviewBox/FocalPointActions.js.map +1 -0
  9. package/dist/admin/components/EditAssetDialog/PreviewBox/FocalPointActions.mjs +55 -0
  10. package/dist/admin/components/EditAssetDialog/PreviewBox/FocalPointActions.mjs.map +1 -0
  11. package/dist/admin/components/EditAssetDialog/PreviewBox/PreviewBox.js +96 -20
  12. package/dist/admin/components/EditAssetDialog/PreviewBox/PreviewBox.js.map +1 -1
  13. package/dist/admin/components/EditAssetDialog/PreviewBox/PreviewBox.mjs +98 -22
  14. package/dist/admin/components/EditAssetDialog/PreviewBox/PreviewBox.mjs.map +1 -1
  15. package/dist/admin/components/EditAssetDialog/PreviewBox/PreviewComponents.js +47 -0
  16. package/dist/admin/components/EditAssetDialog/PreviewBox/PreviewComponents.js.map +1 -1
  17. package/dist/admin/components/EditAssetDialog/PreviewBox/PreviewComponents.mjs +44 -1
  18. package/dist/admin/components/EditAssetDialog/PreviewBox/PreviewComponents.mjs.map +1 -1
  19. package/dist/admin/future/App.js +6 -11
  20. package/dist/admin/future/App.js.map +1 -1
  21. package/dist/admin/future/App.mjs +6 -11
  22. package/dist/admin/future/App.mjs.map +1 -1
  23. package/dist/admin/future/enums.js +12 -0
  24. package/dist/admin/future/enums.js.map +1 -0
  25. package/dist/admin/future/enums.mjs +10 -0
  26. package/dist/admin/future/enums.mjs.map +1 -0
  27. package/dist/admin/future/pages/Assets/AssetsPage.js +342 -0
  28. package/dist/admin/future/pages/Assets/AssetsPage.js.map +1 -0
  29. package/dist/admin/future/pages/Assets/AssetsPage.mjs +321 -0
  30. package/dist/admin/future/pages/Assets/AssetsPage.mjs.map +1 -0
  31. package/dist/admin/future/pages/Assets/components/AssetsGrid.js +164 -0
  32. package/dist/admin/future/pages/Assets/components/AssetsGrid.js.map +1 -0
  33. package/dist/admin/future/pages/Assets/components/AssetsGrid.mjs +162 -0
  34. package/dist/admin/future/pages/Assets/components/AssetsGrid.mjs.map +1 -0
  35. package/dist/admin/future/pages/Assets/components/AssetsTable.js +198 -0
  36. package/dist/admin/future/pages/Assets/components/AssetsTable.js.map +1 -0
  37. package/dist/admin/future/pages/Assets/components/AssetsTable.mjs +196 -0
  38. package/dist/admin/future/pages/Assets/components/AssetsTable.mjs.map +1 -0
  39. package/dist/admin/future/pages/Assets/components/DropZone/DropZoneWithOverlay.js +33 -0
  40. package/dist/admin/future/pages/Assets/components/DropZone/DropZoneWithOverlay.js.map +1 -0
  41. package/dist/admin/future/pages/Assets/components/DropZone/DropZoneWithOverlay.mjs +31 -0
  42. package/dist/admin/future/pages/Assets/components/DropZone/DropZoneWithOverlay.mjs.map +1 -0
  43. package/dist/admin/future/pages/Assets/components/DropZone/UploadDropZoneContext.js +107 -0
  44. package/dist/admin/future/pages/Assets/components/DropZone/UploadDropZoneContext.js.map +1 -0
  45. package/dist/admin/future/pages/Assets/components/DropZone/UploadDropZoneContext.mjs +104 -0
  46. package/dist/admin/future/pages/Assets/components/DropZone/UploadDropZoneContext.mjs.map +1 -0
  47. package/dist/admin/future/pages/Assets/constants.js +54 -0
  48. package/dist/admin/future/pages/Assets/constants.js.map +1 -0
  49. package/dist/admin/future/pages/Assets/constants.mjs +50 -0
  50. package/dist/admin/future/pages/Assets/constants.mjs.map +1 -0
  51. package/dist/admin/future/services/api.js +28 -0
  52. package/dist/admin/future/services/api.js.map +1 -0
  53. package/dist/admin/future/services/api.mjs +25 -0
  54. package/dist/admin/future/services/api.mjs.map +1 -0
  55. package/dist/admin/future/services/assets.js +37 -0
  56. package/dist/admin/future/services/assets.js.map +1 -0
  57. package/dist/admin/future/services/assets.mjs +35 -0
  58. package/dist/admin/future/services/assets.mjs.map +1 -0
  59. package/dist/admin/future/utils/files.js +23 -0
  60. package/dist/admin/future/utils/files.js.map +1 -0
  61. package/dist/admin/future/utils/files.mjs +19 -0
  62. package/dist/admin/future/utils/files.mjs.map +1 -0
  63. package/dist/admin/future/utils/getAssetIcon.js +28 -0
  64. package/dist/admin/future/utils/getAssetIcon.js.map +1 -0
  65. package/dist/admin/future/utils/getAssetIcon.mjs +26 -0
  66. package/dist/admin/future/utils/getAssetIcon.mjs.map +1 -0
  67. package/dist/admin/future/utils/translations.js +8 -0
  68. package/dist/admin/future/utils/translations.js.map +1 -0
  69. package/dist/admin/future/utils/translations.mjs +6 -0
  70. package/dist/admin/future/utils/translations.mjs.map +1 -0
  71. package/dist/admin/hooks/useEditAsset.js +1 -0
  72. package/dist/admin/hooks/useEditAsset.js.map +1 -1
  73. package/dist/admin/hooks/useEditAsset.mjs +1 -0
  74. package/dist/admin/hooks/useEditAsset.mjs.map +1 -1
  75. package/dist/admin/index.js +1 -1
  76. package/dist/admin/index.js.map +1 -1
  77. package/dist/admin/index.mjs +1 -1
  78. package/dist/admin/index.mjs.map +1 -1
  79. package/dist/admin/package.json.js +7 -6
  80. package/dist/admin/package.json.js.map +1 -1
  81. package/dist/admin/package.json.mjs +7 -6
  82. package/dist/admin/package.json.mjs.map +1 -1
  83. package/dist/admin/src/components/EditAssetDialog/PreviewBox/AssetPreview.d.ts +1 -2
  84. package/dist/admin/src/components/EditAssetDialog/PreviewBox/FocalPointActions.d.ts +7 -0
  85. package/dist/admin/src/components/EditAssetDialog/PreviewBox/PreviewBox.d.ts +6 -2
  86. package/dist/admin/src/components/EditAssetDialog/PreviewBox/PreviewComponents.d.ts +13 -0
  87. package/dist/admin/src/future/App.d.ts +1 -1
  88. package/dist/admin/src/future/enums.d.ts +6 -0
  89. package/dist/admin/src/future/pages/Assets/AssetsPage.d.ts +1 -0
  90. package/dist/admin/src/future/pages/Assets/components/AssetsGrid.d.ts +6 -0
  91. package/dist/admin/src/future/pages/Assets/components/AssetsTable.d.ts +6 -0
  92. package/dist/admin/src/future/pages/Assets/components/DropZone/DropZoneWithOverlay.d.ts +4 -0
  93. package/dist/admin/src/future/pages/Assets/components/DropZone/UploadDropZoneContext.d.ts +11 -0
  94. package/dist/admin/src/future/pages/Assets/constants.d.ts +17 -0
  95. package/dist/admin/src/future/services/api.d.ts +5 -1
  96. package/dist/admin/src/future/services/assets.d.ts +13 -0
  97. package/dist/admin/src/future/utils/files.d.ts +3 -0
  98. package/dist/admin/src/future/utils/getAssetIcon.d.ts +12 -0
  99. package/dist/admin/src/future/utils/translations.d.ts +1 -0
  100. package/dist/admin/translations/en.json.js +11 -0
  101. package/dist/admin/translations/en.json.js.map +1 -1
  102. package/dist/admin/translations/en.json.mjs +11 -0
  103. package/dist/admin/translations/en.json.mjs.map +1 -1
  104. package/dist/server/content-types/file.js +4 -0
  105. package/dist/server/content-types/file.js.map +1 -1
  106. package/dist/server/content-types/file.mjs +4 -0
  107. package/dist/server/content-types/file.mjs.map +1 -1
  108. package/dist/server/controllers/validation/admin/upload.js +5 -0
  109. package/dist/server/controllers/validation/admin/upload.js.map +1 -1
  110. package/dist/server/controllers/validation/admin/upload.mjs +5 -0
  111. package/dist/server/controllers/validation/admin/upload.mjs.map +1 -1
  112. package/dist/server/controllers/validation/content-api/upload.js +6 -1
  113. package/dist/server/controllers/validation/content-api/upload.js.map +1 -1
  114. package/dist/server/controllers/validation/content-api/upload.mjs +6 -1
  115. package/dist/server/controllers/validation/content-api/upload.mjs.map +1 -1
  116. package/dist/server/services/upload.js +3 -1
  117. package/dist/server/services/upload.js.map +1 -1
  118. package/dist/server/services/upload.mjs +3 -1
  119. package/dist/server/services/upload.mjs.map +1 -1
  120. package/dist/server/src/content-types/file.d.ts +4 -0
  121. package/dist/server/src/content-types/file.d.ts.map +1 -1
  122. package/dist/server/src/content-types/index.d.ts +4 -0
  123. package/dist/server/src/content-types/index.d.ts.map +1 -1
  124. package/dist/server/src/controllers/validation/admin/upload.d.ts +240 -0
  125. package/dist/server/src/controllers/validation/admin/upload.d.ts.map +1 -1
  126. package/dist/server/src/controllers/validation/content-api/upload.d.ts +180 -0
  127. package/dist/server/src/controllers/validation/content-api/upload.d.ts.map +1 -1
  128. package/dist/server/src/index.d.ts +5 -1
  129. package/dist/server/src/index.d.ts.map +1 -1
  130. package/dist/server/src/services/index.d.ts +1 -1
  131. package/dist/server/src/services/upload.d.ts +1 -1
  132. package/dist/server/src/services/upload.d.ts.map +1 -1
  133. package/dist/server/src/types.d.ts +6 -0
  134. package/dist/server/src/types.d.ts.map +1 -1
  135. package/dist/shared/contracts/files.d.ts +6 -0
  136. package/package.json +7 -6
  137. package/dist/admin/future/pages/MediaLibraryPage.js +0 -55
  138. package/dist/admin/future/pages/MediaLibraryPage.js.map +0 -1
  139. package/dist/admin/future/pages/MediaLibraryPage.mjs +0 -53
  140. package/dist/admin/future/pages/MediaLibraryPage.mjs.map +0 -1
  141. package/dist/admin/src/future/pages/MediaLibraryPage.d.ts +0 -1
@@ -0,0 +1,33 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var designSystem = require('@strapi/design-system');
5
+ var styledComponents = require('styled-components');
6
+ var UploadDropZoneContext = require('./UploadDropZoneContext.js');
7
+
8
+ const setOpacity = (hex, alpha)=>`${hex}${Math.floor(alpha * 255).toString(16).padStart(2, '0')}`;
9
+ const DropZoneOverlay = styledComponents.styled(designSystem.Box)`
10
+ position: absolute;
11
+ top: 0;
12
+ left: 0;
13
+ right: 0;
14
+ bottom: 0;
15
+ background: ${({ theme })=>setOpacity(theme.colors.primary200, 0.3)};
16
+ border: 1px solid ${({ theme })=>theme.colors.primary700};
17
+ border-radius: ${({ theme })=>theme.borderRadius};
18
+ z-index: 1;
19
+ pointer-events: none;
20
+ `;
21
+ const DropZoneWithOverlay = ({ children })=>{
22
+ const { isDragging } = UploadDropZoneContext.useUploadDropZone();
23
+ return /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Box, {
24
+ position: "relative",
25
+ children: [
26
+ isDragging && /*#__PURE__*/ jsxRuntime.jsx(DropZoneOverlay, {}),
27
+ children
28
+ ]
29
+ });
30
+ };
31
+
32
+ exports.DropZoneWithOverlay = DropZoneWithOverlay;
33
+ //# sourceMappingURL=DropZoneWithOverlay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DropZoneWithOverlay.js","sources":["../../../../../../../admin/src/future/pages/Assets/components/DropZone/DropZoneWithOverlay.tsx"],"sourcesContent":["import { Box } from '@strapi/design-system';\nimport { styled } from 'styled-components';\n\nimport { useUploadDropZone } from './UploadDropZoneContext';\n\nconst setOpacity = (hex: string, alpha: number) =>\n `${hex}${Math.floor(alpha * 255)\n .toString(16)\n .padStart(2, '0')}`;\n\nconst DropZoneOverlay = styled(Box)`\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: ${({ theme }) => setOpacity(theme.colors.primary200, 0.3)};\n border: 1px solid ${({ theme }) => theme.colors.primary700};\n border-radius: ${({ theme }) => theme.borderRadius};\n z-index: 1;\n pointer-events: none;\n`;\n\nconst DropZoneWithOverlay = ({ children }: { children: React.ReactNode }) => {\n const { isDragging } = useUploadDropZone();\n return (\n <Box position=\"relative\">\n {isDragging && <DropZoneOverlay />}\n {children}\n </Box>\n );\n};\n\nexport { DropZoneWithOverlay };\n"],"names":["setOpacity","hex","alpha","Math","floor","toString","padStart","DropZoneOverlay","styled","Box","theme","colors","primary200","primary700","borderRadius","DropZoneWithOverlay","children","isDragging","useUploadDropZone","_jsxs","position","_jsx"],"mappings":";;;;;;;AAKA,MAAMA,aAAa,CAACC,GAAAA,EAAaC,KAC/B,GAAA,CAAA,EAAGD,MAAME,IAAKC,CAAAA,KAAK,CAACF,KAAAA,GAAQ,KACzBG,QAAQ,CAAC,IACTC,QAAQ,CAAC,GAAG,GAAM,CAAA,CAAA,CAAA;AAEvB,MAAMC,eAAAA,GAAkBC,uBAAOC,CAAAA,gBAAAA,CAAI;;;;;;cAMrB,EAAE,CAAC,EAAEC,KAAK,EAAE,GAAKV,UAAWU,CAAAA,KAAAA,CAAMC,MAAM,CAACC,UAAU,EAAE,GAAK,CAAA,CAAA;oBACpD,EAAE,CAAC,EAAEF,KAAK,EAAE,GAAKA,KAAMC,CAAAA,MAAM,CAACE,UAAU,CAAC;AAC5C,iBAAA,EAAE,CAAC,EAAEH,KAAK,EAAE,GAAKA,KAAAA,CAAMI,YAAY,CAAC;;;AAGrD,CAAC;AAED,MAAMC,mBAAsB,GAAA,CAAC,EAAEC,QAAQ,EAAiC,GAAA;IACtE,MAAM,EAAEC,UAAU,EAAE,GAAGC,uCAAAA,EAAAA;AACvB,IAAA,qBACEC,eAACV,CAAAA,gBAAAA,EAAAA;QAAIW,QAAS,EAAA,UAAA;;AACXH,YAAAA,UAAAA,kBAAcI,cAACd,CAAAA,eAAAA,EAAAA,EAAAA,CAAAA;AACfS,YAAAA;;;AAGP;;;;"}
@@ -0,0 +1,31 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { Box } from '@strapi/design-system';
3
+ import { styled } from 'styled-components';
4
+ import { useUploadDropZone } from './UploadDropZoneContext.mjs';
5
+
6
+ const setOpacity = (hex, alpha)=>`${hex}${Math.floor(alpha * 255).toString(16).padStart(2, '0')}`;
7
+ const DropZoneOverlay = styled(Box)`
8
+ position: absolute;
9
+ top: 0;
10
+ left: 0;
11
+ right: 0;
12
+ bottom: 0;
13
+ background: ${({ theme })=>setOpacity(theme.colors.primary200, 0.3)};
14
+ border: 1px solid ${({ theme })=>theme.colors.primary700};
15
+ border-radius: ${({ theme })=>theme.borderRadius};
16
+ z-index: 1;
17
+ pointer-events: none;
18
+ `;
19
+ const DropZoneWithOverlay = ({ children })=>{
20
+ const { isDragging } = useUploadDropZone();
21
+ return /*#__PURE__*/ jsxs(Box, {
22
+ position: "relative",
23
+ children: [
24
+ isDragging && /*#__PURE__*/ jsx(DropZoneOverlay, {}),
25
+ children
26
+ ]
27
+ });
28
+ };
29
+
30
+ export { DropZoneWithOverlay };
31
+ //# sourceMappingURL=DropZoneWithOverlay.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DropZoneWithOverlay.mjs","sources":["../../../../../../../admin/src/future/pages/Assets/components/DropZone/DropZoneWithOverlay.tsx"],"sourcesContent":["import { Box } from '@strapi/design-system';\nimport { styled } from 'styled-components';\n\nimport { useUploadDropZone } from './UploadDropZoneContext';\n\nconst setOpacity = (hex: string, alpha: number) =>\n `${hex}${Math.floor(alpha * 255)\n .toString(16)\n .padStart(2, '0')}`;\n\nconst DropZoneOverlay = styled(Box)`\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: ${({ theme }) => setOpacity(theme.colors.primary200, 0.3)};\n border: 1px solid ${({ theme }) => theme.colors.primary700};\n border-radius: ${({ theme }) => theme.borderRadius};\n z-index: 1;\n pointer-events: none;\n`;\n\nconst DropZoneWithOverlay = ({ children }: { children: React.ReactNode }) => {\n const { isDragging } = useUploadDropZone();\n return (\n <Box position=\"relative\">\n {isDragging && <DropZoneOverlay />}\n {children}\n </Box>\n );\n};\n\nexport { DropZoneWithOverlay };\n"],"names":["setOpacity","hex","alpha","Math","floor","toString","padStart","DropZoneOverlay","styled","Box","theme","colors","primary200","primary700","borderRadius","DropZoneWithOverlay","children","isDragging","useUploadDropZone","_jsxs","position","_jsx"],"mappings":";;;;;AAKA,MAAMA,aAAa,CAACC,GAAAA,EAAaC,KAC/B,GAAA,CAAA,EAAGD,MAAME,IAAKC,CAAAA,KAAK,CAACF,KAAAA,GAAQ,KACzBG,QAAQ,CAAC,IACTC,QAAQ,CAAC,GAAG,GAAM,CAAA,CAAA,CAAA;AAEvB,MAAMC,eAAAA,GAAkBC,MAAOC,CAAAA,GAAAA,CAAI;;;;;;cAMrB,EAAE,CAAC,EAAEC,KAAK,EAAE,GAAKV,UAAWU,CAAAA,KAAAA,CAAMC,MAAM,CAACC,UAAU,EAAE,GAAK,CAAA,CAAA;oBACpD,EAAE,CAAC,EAAEF,KAAK,EAAE,GAAKA,KAAMC,CAAAA,MAAM,CAACE,UAAU,CAAC;AAC5C,iBAAA,EAAE,CAAC,EAAEH,KAAK,EAAE,GAAKA,KAAAA,CAAMI,YAAY,CAAC;;;AAGrD,CAAC;AAED,MAAMC,mBAAsB,GAAA,CAAC,EAAEC,QAAQ,EAAiC,GAAA;IACtE,MAAM,EAAEC,UAAU,EAAE,GAAGC,iBAAAA,EAAAA;AACvB,IAAA,qBACEC,IAACV,CAAAA,GAAAA,EAAAA;QAAIW,QAAS,EAAA,UAAA;;AACXH,YAAAA,UAAAA,kBAAcI,GAACd,CAAAA,eAAAA,EAAAA,EAAAA,CAAAA;AACfS,YAAAA;;;AAGP;;;;"}
@@ -0,0 +1,107 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var React = require('react');
5
+ var designSystem = require('@strapi/design-system');
6
+ var styledComponents = require('styled-components');
7
+
8
+ /* -------------------------------------------------------------------------------------------------
9
+ * Context
10
+ * -----------------------------------------------------------------------------------------------*/ const UploadDropZoneContext = /*#__PURE__*/ React.createContext(null);
11
+ /* -------------------------------------------------------------------------------------------------
12
+ * Components
13
+ * -----------------------------------------------------------------------------------------------*/ const DropZoneWrapper = styledComponents.styled(designSystem.Box)`
14
+ position: relative;
15
+ display: flex;
16
+ flex-direction: column;
17
+ min-height: 100%;
18
+ `;
19
+ const UploadDropZoneProvider = ({ children, onDrop })=>{
20
+ const [isDragging, setIsDragging] = React.useState(false);
21
+ const dragCounterRef = React.useRef(0);
22
+ const contextValue = {
23
+ isDragging
24
+ };
25
+ React.useEffect(()=>{
26
+ const handleDragEnd = ()=>{
27
+ setIsDragging(false);
28
+ dragCounterRef.current = 0;
29
+ };
30
+ // Handle drag leaving the entire document/window
31
+ const handleDocumentDragLeave = (e)=>{
32
+ // When relatedTarget is null, we're leaving the document entirely
33
+ if (!e.relatedTarget) {
34
+ setIsDragging(false);
35
+ dragCounterRef.current = 0;
36
+ }
37
+ };
38
+ document.addEventListener('dragend', handleDragEnd);
39
+ document.addEventListener('dragleave', handleDocumentDragLeave);
40
+ return ()=>{
41
+ document.removeEventListener('dragend', handleDragEnd);
42
+ document.removeEventListener('dragleave', handleDocumentDragLeave);
43
+ };
44
+ }, []);
45
+ const handleDragEnter = React.useCallback((e)=>{
46
+ e.preventDefault();
47
+ e.stopPropagation();
48
+ dragCounterRef.current += 1;
49
+ if (e.dataTransfer.types.includes('Files')) {
50
+ setIsDragging(true);
51
+ }
52
+ }, []);
53
+ const handleDragLeave = React.useCallback((e)=>{
54
+ e.preventDefault();
55
+ e.stopPropagation();
56
+ dragCounterRef.current -= 1;
57
+ // Only set dragging to false if we've left the dropzone completely
58
+ // (counter reaches 0 or negative)
59
+ if (dragCounterRef.current <= 0) {
60
+ setIsDragging(false);
61
+ dragCounterRef.current = 0;
62
+ }
63
+ }, []);
64
+ const handleDragOver = React.useCallback((e)=>{
65
+ e.preventDefault();
66
+ e.stopPropagation();
67
+ e.dataTransfer.dropEffect = 'copy';
68
+ }, []);
69
+ const handleDrop = React.useCallback((e)=>{
70
+ e.preventDefault();
71
+ e.stopPropagation();
72
+ setIsDragging(false);
73
+ dragCounterRef.current = 0;
74
+ const { files } = e.dataTransfer;
75
+ if (files?.length && onDrop) {
76
+ onDrop(Array.from(files));
77
+ }
78
+ }, [
79
+ onDrop
80
+ ]);
81
+ return /*#__PURE__*/ jsxRuntime.jsx(UploadDropZoneContext.Provider, {
82
+ value: contextValue,
83
+ children: /*#__PURE__*/ jsxRuntime.jsx(DropZoneWrapper, {
84
+ "data-testid": "assets-dropzone",
85
+ onDragEnter: handleDragEnter,
86
+ onDragLeave: handleDragLeave,
87
+ onDragOver: handleDragOver,
88
+ onDrop: handleDrop,
89
+ children: children
90
+ })
91
+ });
92
+ };
93
+ /* -------------------------------------------------------------------------------------------------
94
+ * Hook
95
+ * -----------------------------------------------------------------------------------------------*/ const useUploadDropZone = ()=>{
96
+ const context = React.useContext(UploadDropZoneContext);
97
+ if (!context) {
98
+ throw new Error('useUploadDropZone must be used within UploadDropZone');
99
+ }
100
+ return {
101
+ isDragging: context.isDragging
102
+ };
103
+ };
104
+
105
+ exports.UploadDropZoneProvider = UploadDropZoneProvider;
106
+ exports.useUploadDropZone = useUploadDropZone;
107
+ //# sourceMappingURL=UploadDropZoneContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UploadDropZoneContext.js","sources":["../../../../../../../admin/src/future/pages/Assets/components/DropZone/UploadDropZoneContext.tsx"],"sourcesContent":["import {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n type DragEvent,\n type ReactNode,\n} from 'react';\n\nimport { Box } from '@strapi/design-system';\nimport { styled } from 'styled-components';\n\n/* -------------------------------------------------------------------------------------------------\n * Types\n * -----------------------------------------------------------------------------------------------*/\n\ntype DropHandler = (files: File[]) => void | Promise<void>;\n\ninterface UploadDropZoneContextValue {\n isDragging: boolean;\n}\n\n/* -------------------------------------------------------------------------------------------------\n * Context\n * -----------------------------------------------------------------------------------------------*/\n\nconst UploadDropZoneContext = createContext<UploadDropZoneContextValue | null>(null);\n\n/* -------------------------------------------------------------------------------------------------\n * Components\n * -----------------------------------------------------------------------------------------------*/\n\nconst DropZoneWrapper = styled(Box)`\n position: relative;\n display: flex;\n flex-direction: column;\n min-height: 100%;\n`;\n\n/* -------------------------------------------------------------------------------------------------\n * Provider\n * -----------------------------------------------------------------------------------------------*/\n\ninterface UploadDropZoneProps {\n children: ReactNode;\n onDrop?: DropHandler;\n}\n\nexport const UploadDropZoneProvider = ({ children, onDrop }: UploadDropZoneProps) => {\n const [isDragging, setIsDragging] = useState(false);\n const dragCounterRef = useRef(0);\n\n const contextValue: UploadDropZoneContextValue = {\n isDragging,\n };\n\n useEffect(() => {\n const handleDragEnd = () => {\n setIsDragging(false);\n dragCounterRef.current = 0;\n };\n\n // Handle drag leaving the entire document/window\n const handleDocumentDragLeave = (e: globalThis.DragEvent) => {\n // When relatedTarget is null, we're leaving the document entirely\n if (!e.relatedTarget) {\n setIsDragging(false);\n dragCounterRef.current = 0;\n }\n };\n\n document.addEventListener('dragend', handleDragEnd);\n document.addEventListener('dragleave', handleDocumentDragLeave);\n\n return () => {\n document.removeEventListener('dragend', handleDragEnd);\n document.removeEventListener('dragleave', handleDocumentDragLeave);\n };\n }, []);\n\n const handleDragEnter = useCallback((e: DragEvent<HTMLElement>) => {\n e.preventDefault();\n e.stopPropagation();\n\n dragCounterRef.current += 1;\n\n if (e.dataTransfer.types.includes('Files')) {\n setIsDragging(true);\n }\n }, []);\n\n const handleDragLeave = useCallback((e: DragEvent<HTMLElement>) => {\n e.preventDefault();\n e.stopPropagation();\n\n dragCounterRef.current -= 1;\n\n // Only set dragging to false if we've left the dropzone completely\n // (counter reaches 0 or negative)\n if (dragCounterRef.current <= 0) {\n setIsDragging(false);\n dragCounterRef.current = 0;\n }\n }, []);\n\n const handleDragOver = useCallback((e: DragEvent<HTMLElement>) => {\n e.preventDefault();\n e.stopPropagation();\n e.dataTransfer.dropEffect = 'copy';\n }, []);\n\n const handleDrop = useCallback(\n (e: DragEvent<HTMLElement>) => {\n e.preventDefault();\n e.stopPropagation();\n setIsDragging(false);\n dragCounterRef.current = 0;\n\n const { files } = e.dataTransfer;\n if (files?.length && onDrop) {\n onDrop(Array.from(files));\n }\n },\n [onDrop]\n );\n\n return (\n <UploadDropZoneContext.Provider value={contextValue}>\n <DropZoneWrapper\n data-testid=\"assets-dropzone\"\n onDragEnter={handleDragEnter}\n onDragLeave={handleDragLeave}\n onDragOver={handleDragOver}\n onDrop={handleDrop}\n >\n {children}\n </DropZoneWrapper>\n </UploadDropZoneContext.Provider>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Hook\n * -----------------------------------------------------------------------------------------------*/\n\nexport const useUploadDropZone = () => {\n const context = useContext(UploadDropZoneContext);\n\n if (!context) {\n throw new Error('useUploadDropZone must be used within UploadDropZone');\n }\n\n return {\n isDragging: context.isDragging,\n };\n};\n"],"names":["UploadDropZoneContext","createContext","DropZoneWrapper","styled","Box","UploadDropZoneProvider","children","onDrop","isDragging","setIsDragging","useState","dragCounterRef","useRef","contextValue","useEffect","handleDragEnd","current","handleDocumentDragLeave","e","relatedTarget","document","addEventListener","removeEventListener","handleDragEnter","useCallback","preventDefault","stopPropagation","dataTransfer","types","includes","handleDragLeave","handleDragOver","dropEffect","handleDrop","files","length","Array","from","_jsx","Provider","value","data-testid","onDragEnter","onDragLeave","onDragOver","useUploadDropZone","context","useContext","Error"],"mappings":";;;;;;;AAwBA;;qGAIA,MAAMA,sCAAwBC,mBAAiD,CAAA,IAAA,CAAA;AAE/E;;AAEkG,qGAElG,MAAMC,eAAAA,GAAkBC,uBAAOC,CAAAA,gBAAAA,CAAI;;;;;AAKnC,CAAC;MAWYC,sBAAyB,GAAA,CAAC,EAAEC,QAAQ,EAAEC,MAAM,EAAuB,GAAA;AAC9E,IAAA,MAAM,CAACC,UAAAA,EAAYC,aAAc,CAAA,GAAGC,cAAS,CAAA,KAAA,CAAA;AAC7C,IAAA,MAAMC,iBAAiBC,YAAO,CAAA,CAAA,CAAA;AAE9B,IAAA,MAAMC,YAA2C,GAAA;AAC/CL,QAAAA;AACF,KAAA;IAEAM,eAAU,CAAA,IAAA;AACR,QAAA,MAAMC,aAAgB,GAAA,IAAA;YACpBN,aAAc,CAAA,KAAA,CAAA;AACdE,YAAAA,cAAAA,CAAeK,OAAO,GAAG,CAAA;AAC3B,SAAA;;AAGA,QAAA,MAAMC,0BAA0B,CAACC,CAAAA,GAAAA;;YAE/B,IAAI,CAACA,CAAEC,CAAA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ext } from 'react';
3
+ import { Box } from '@strapi/design-system';
4
+ import { styled } from 'styled-components';
5
+
6
+ /* -------------------------------------------------------------------------------------------------
7
+ * Context
8
+ * -----------------------------------------------------------------------------------------------*/ const UploadDropZoneContext = /*#__PURE__*/ createContext(null);
9
+ /* -------------------------------------------------------------------------------------------------
10
+ * Components
11
+ * -----------------------------------------------------------------------------------------------*/ const DropZoneWrapper = styled(Box)`
12
+ position: relative;
13
+ display: flex;
14
+ flex-direction: column;
15
+ min-height: 100%;
16
+ `;
17
+ const UploadDropZoneProvider = ({ children, onDrop })=>{
18
+ const [isDragging, setIsDragging] = useState(false);
19
+ const dragCounterRef = useRef(0);
20
+ const contextValue = {
21
+ isDragging
22
+ };
23
+ useEffect(()=>{
24
+ const handleDragEnd = ()=>{
25
+ setIsDragging(false);
26
+ dragCounterRef.current = 0;
27
+ };
28
+ // Handle drag leaving the entire document/window
29
+ const handleDocumentDragLeave = (e)=>{
30
+ // When relatedTarget is null, we're leaving the document entirely
31
+ if (!e.relatedTarget) {
32
+ setIsDragging(false);
33
+ dragCounterRef.current = 0;
34
+ }
35
+ };
36
+ document.addEventListener('dragend', handleDragEnd);
37
+ document.addEventListener('dragleave', handleDocumentDragLeave);
38
+ return ()=>{
39
+ document.removeEventListener('dragend', handleDragEnd);
40
+ document.removeEventListener('dragleave', handleDocumentDragLeave);
41
+ };
42
+ }, []);
43
+ const handleDragEnter = useCallback((e)=>{
44
+ e.preventDefault();
45
+ e.stopPropagation();
46
+ dragCounterRef.current += 1;
47
+ if (e.dataTransfer.types.includes('Files')) {
48
+ setIsDragging(true);
49
+ }
50
+ }, []);
51
+ const handleDragLeave = useCallback((e)=>{
52
+ e.preventDefault();
53
+ e.stopPropagation();
54
+ dragCounterRef.current -= 1;
55
+ // Only set dragging to false if we've left the dropzone completely
56
+ // (counter reaches 0 or negative)
57
+ if (dragCounterRef.current <= 0) {
58
+ setIsDragging(false);
59
+ dragCounterRef.current = 0;
60
+ }
61
+ }, []);
62
+ const handleDragOver = useCallback((e)=>{
63
+ e.preventDefault();
64
+ e.stopPropagation();
65
+ e.dataTransfer.dropEffect = 'copy';
66
+ }, []);
67
+ const handleDrop = useCallback((e)=>{
68
+ e.preventDefault();
69
+ e.stopPropagation();
70
+ setIsDragging(false);
71
+ dragCounterRef.current = 0;
72
+ const { files } = e.dataTransfer;
73
+ if (files?.length && onDrop) {
74
+ onDrop(Array.from(files));
75
+ }
76
+ }, [
77
+ onDrop
78
+ ]);
79
+ return /*#__PURE__*/ jsx(UploadDropZoneContext.Provider, {
80
+ value: contextValue,
81
+ children: /*#__PURE__*/ jsx(DropZoneWrapper, {
82
+ "data-testid": "assets-dropzone",
83
+ onDragEnter: handleDragEnter,
84
+ onDragLeave: handleDragLeave,
85
+ onDragOver: handleDragOver,
86
+ onDrop: handleDrop,
87
+ children: children
88
+ })
89
+ });
90
+ };
91
+ /* -------------------------------------------------------------------------------------------------
92
+ * Hook
93
+ * -----------------------------------------------------------------------------------------------*/ const useUploadDropZone = ()=>{
94
+ const context = useContext(UploadDropZoneContext);
95
+ if (!context) {
96
+ throw new Error('useUploadDropZone must be used within UploadDropZone');
97
+ }
98
+ return {
99
+ isDragging: context.isDragging
100
+ };
101
+ };
102
+
103
+ export { UploadDropZoneProvider, useUploadDropZone };
104
+ //# sourceMappingURL=UploadDropZoneContext.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UploadDropZoneContext.mjs","sources":["../../../../../../../admin/src/future/pages/Assets/components/DropZone/UploadDropZoneContext.tsx"],"sourcesContent":["import {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n type DragEvent,\n type ReactNode,\n} from 'react';\n\nimport { Box } from '@strapi/design-system';\nimport { styled } from 'styled-components';\n\n/* -------------------------------------------------------------------------------------------------\n * Types\n * -----------------------------------------------------------------------------------------------*/\n\ntype DropHandler = (files: File[]) => void | Promise<void>;\n\ninterface UploadDropZoneContextValue {\n isDragging: boolean;\n}\n\n/* -------------------------------------------------------------------------------------------------\n * Context\n * -----------------------------------------------------------------------------------------------*/\n\nconst UploadDropZoneContext = createContext<UploadDropZoneContextValue | null>(null);\n\n/* -------------------------------------------------------------------------------------------------\n * Components\n * -----------------------------------------------------------------------------------------------*/\n\nconst DropZoneWrapper = styled(Box)`\n position: relative;\n display: flex;\n flex-direction: column;\n min-height: 100%;\n`;\n\n/* -------------------------------------------------------------------------------------------------\n * Provider\n * -----------------------------------------------------------------------------------------------*/\n\ninterface UploadDropZoneProps {\n children: ReactNode;\n onDrop?: DropHandler;\n}\n\nexport const UploadDropZoneProvider = ({ children, onDrop }: UploadDropZoneProps) => {\n const [isDragging, setIsDragging] = useState(false);\n const dragCounterRef = useRef(0);\n\n const contextValue: UploadDropZoneContextValue = {\n isDragging,\n };\n\n useEffect(() => {\n const handleDragEnd = () => {\n setIsDragging(false);\n dragCounterRef.current = 0;\n };\n\n // Handle drag leaving the entire document/window\n const handleDocumentDragLeave = (e: globalThis.DragEvent) => {\n // When relatedTarget is null, we're leaving the document entirely\n if (!e.relatedTarget) {\n setIsDragging(false);\n dragCounterRef.current = 0;\n }\n };\n\n document.addEventListener('dragend', handleDragEnd);\n document.addEventListener('dragleave', handleDocumentDragLeave);\n\n return () => {\n document.removeEventListener('dragend', handleDragEnd);\n document.removeEventListener('dragleave', handleDocumentDragLeave);\n };\n }, []);\n\n const handleDragEnter = useCallback((e: DragEvent<HTMLElement>) => {\n e.preventDefault();\n e.stopPropagation();\n\n dragCounterRef.current += 1;\n\n if (e.dataTransfer.types.includes('Files')) {\n setIsDragging(true);\n }\n }, []);\n\n const handleDragLeave = useCallback((e: DragEvent<HTMLElement>) => {\n e.preventDefault();\n e.stopPropagation();\n\n dragCounterRef.current -= 1;\n\n // Only set dragging to false if we've left the dropzone completely\n // (counter reaches 0 or negative)\n if (dragCounterRef.current <= 0) {\n setIsDragging(false);\n dragCounterRef.current = 0;\n }\n }, []);\n\n const handleDragOver = useCallback((e: DragEvent<HTMLElement>) => {\n e.preventDefault();\n e.stopPropagation();\n e.dataTransfer.dropEffect = 'copy';\n }, []);\n\n const handleDrop = useCallback(\n (e: DragEvent<HTMLElement>) => {\n e.preventDefault();\n e.stopPropagation();\n setIsDragging(false);\n dragCounterRef.current = 0;\n\n const { files } = e.dataTransfer;\n if (files?.length && onDrop) {\n onDrop(Array.from(files));\n }\n },\n [onDrop]\n );\n\n return (\n <UploadDropZoneContext.Provider value={contextValue}>\n <DropZoneWrapper\n data-testid=\"assets-dropzone\"\n onDragEnter={handleDragEnter}\n onDragLeave={handleDragLeave}\n onDragOver={handleDragOver}\n onDrop={handleDrop}\n >\n {children}\n </DropZoneWrapper>\n </UploadDropZoneContext.Provider>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Hook\n * -----------------------------------------------------------------------------------------------*/\n\nexport const useUploadDropZone = () => {\n const context = useContext(UploadDropZoneContext);\n\n if (!context) {\n throw new Error('useUploadDropZone must be used within UploadDropZone');\n }\n\n return {\n isDragging: context.isDragging,\n };\n};\n"],"names":["UploadDropZoneContext","createContext","DropZoneWrapper","styled","Box","UploadDropZoneProvider","children","onDrop","isDragging","setIsDragging","useState","dragCounterRef","useRef","contextValue","useEffect","handleDragEnd","current","handleDocumentDragLeave","e","relatedTarget","document","addEventListener","removeEventListener","handleDragEnter","useCallback","preventDefault","stopPropagation","dataTransfer","types","includes","handleDragLeave","handleDragOver","dropEffect","handleDrop","files","length","Array","from","_jsx","Provider","value","data-testid","onDragEnter","onDragLeave","onDragOver","useUploadDropZone","context","useContext","Error"],"mappings":";;;;;AAwBA;;qGAIA,MAAMA,sCAAwBC,aAAiD,CAAA,IAAA,CAAA;AAE/E;;AAEkG,qGAElG,MAAMC,eAAAA,GAAkBC,MAAOC,CAAAA,GAAAA,CAAI;;;;;AAKnC,CAAC;MAWYC,sBAAyB,GAAA,CAAC,EAAEC,QAAQ,EAAEC,MAAM,EAAuB,GAAA;AAC9E,IAAA,MAAM,CAACC,UAAAA,EAAYC,aAAc,CAAA,GAAGC,QAAS,C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;;;AAIT;AAEA;;2GAIauC,iBAAoB,GAAA,IAAA;AAC/B,IAAA,MAAMC,UAAUC,UAAW/C,CAAAA,qBAAAA,CAAAA;AAE3B,IAAA,IAAI,CAAC8C,OAAS,EAAA;AACZ,QAAA,MAAM,IAAIE,KAAM,CAAA,sDAAA,CAAA;AAClB;IAEA,OAAO;AACLxC,QAAAA,UAAAA,EAAYsC,QAAQtC;AACtB,KAAA;AACF;;;;"}
@@ -0,0 +1,54 @@
1
+ 'use strict';
2
+
3
+ var translations = require('../../utils/translations.js');
4
+
5
+ const localStorageKeys = {
6
+ view: `STRAPI_UPLOAD_LIBRARY_VIEW`
7
+ };
8
+ const viewOptions = {
9
+ GRID: 0,
10
+ TABLE: 1
11
+ };
12
+ const TABLE_HEADERS = [
13
+ {
14
+ name: 'name',
15
+ label: {
16
+ id: translations.getTranslationKey('list.table.header.name'),
17
+ defaultMessage: 'name'
18
+ }
19
+ },
20
+ {
21
+ name: 'createdAt',
22
+ label: {
23
+ id: translations.getTranslationKey('list.table.header.creationDate'),
24
+ defaultMessage: 'creation date'
25
+ }
26
+ },
27
+ {
28
+ name: 'updatedAt',
29
+ label: {
30
+ id: translations.getTranslationKey('list.table.header.lastModified'),
31
+ defaultMessage: 'last modified'
32
+ }
33
+ },
34
+ {
35
+ name: 'size',
36
+ label: {
37
+ id: translations.getTranslationKey('list.table.header.size'),
38
+ defaultMessage: 'size'
39
+ }
40
+ },
41
+ {
42
+ name: 'actions',
43
+ label: {
44
+ id: translations.getTranslationKey('list.table.header.actions'),
45
+ defaultMessage: 'actions'
46
+ },
47
+ isVisuallyHidden: true
48
+ }
49
+ ];
50
+
51
+ exports.TABLE_HEADERS = TABLE_HEADERS;
52
+ exports.localStorageKeys = localStorageKeys;
53
+ exports.viewOptions = viewOptions;
54
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sources":["../../../../../admin/src/future/pages/Assets/constants.ts"],"sourcesContent":["import { getTranslationKey } from '../../utils/translations';\n\nexport const localStorageKeys = {\n view: `STRAPI_UPLOAD_LIBRARY_VIEW`,\n};\n\nexport const viewOptions = {\n GRID: 0,\n TABLE: 1,\n};\n\ninterface TableHeader {\n name: string;\n label: { id: string; defaultMessage: string };\n isVisuallyHidden?: boolean;\n}\n\nexport const TABLE_HEADERS: TableHeader[] = [\n {\n name: 'name',\n label: { id: getTranslationKey('list.table.header.name'), defaultMessage: 'name' },\n },\n {\n name: 'createdAt',\n label: {\n id: getTranslationKey('list.table.header.creationDate'),\n defaultMessage: 'creation date',\n },\n },\n {\n name: 'updatedAt',\n label: {\n id: getTranslationKey('list.table.header.lastModified'),\n defaultMessage: 'last modified',\n },\n },\n {\n name: 'size',\n label: { id: getTranslationKey('list.table.header.size'), defaultMessage: 'size' },\n },\n {\n name: 'actions',\n label: { id: getTranslationKey('list.table.header.actions'), defaultMessage: 'actions' },\n isVisuallyHidden: true,\n },\n];\n"],"names":["localStorageKeys","view","viewOptions","GRID","TABLE","TABLE_HEADERS","name","label","id","getTranslationKey","defaultMessage","isVisuallyHidden"],"mappings":";;;;MAEaA,gBAAmB,GAAA;IAC9BC,IAAM,EAAA,CAAC,0BAA0B;AACnC;MAEaC,WAAc,GAAA;IACzBC,IAAM,EAAA,CAAA;IACNC,KAAO,EAAA;AACT;MAQaC,aAA+B,GAAA;AAC1C,IAAA;QACEC,IAAM,EAAA,MAAA;QACNC,KAAO,EAAA;AAAEC,YAAAA,EAAAA,EAAIC,8BAAkB,CAAA,wBAAA,CAAA;YAA2BC,cAAgB,EAAA;AAAO;AACnF,KAAA;AACA,IAAA;QACEJ,IAAM,EAAA,WAAA;QACNC,KAAO,EAAA;AACLC,YAAAA,EAAAA,EAAIC,8BAAkB,CAAA,gCAAA,CAAA;YACtBC,cAAgB,EAAA;AAClB;AACF,KAAA;AACA,IAAA;QACEJ,IAAM,EAAA,WAAA;QACNC,KAAO,EAAA;AACLC,YAAAA,EAAAA,EAAIC,8BAAkB,CAAA,gCAAA,CAAA;YACtBC,cAAgB,EAAA;AAClB;AACF,KAAA;AACA,IAAA;QACEJ,IAAM,EAAA,MAAA;QACNC,KAAO,EAAA;AAAEC,YAAAA,EAAAA,EAAIC,8BAAkB,CAAA,wBAAA,CAAA;YAA2BC,cAAgB,EAAA;AAAO;AACnF,KAAA;AACA,IAAA;QACEJ,IAAM,EAAA,SAAA;QACNC,KAAO,EAAA;AAAEC,YAAAA,EAAAA,EAAIC,8BAAkB,CAAA,2BAAA,CAAA;YAA8BC,cAAgB,EAAA;AAAU,SAAA;QACvFC,gBAAkB,EAAA;AACpB;;;;;;;"}
@@ -0,0 +1,50 @@
1
+ import { getTranslationKey } from '../../utils/translations.mjs';
2
+
3
+ const localStorageKeys = {
4
+ view: `STRAPI_UPLOAD_LIBRARY_VIEW`
5
+ };
6
+ const viewOptions = {
7
+ GRID: 0,
8
+ TABLE: 1
9
+ };
10
+ const TABLE_HEADERS = [
11
+ {
12
+ name: 'name',
13
+ label: {
14
+ id: getTranslationKey('list.table.header.name'),
15
+ defaultMessage: 'name'
16
+ }
17
+ },
18
+ {
19
+ name: 'createdAt',
20
+ label: {
21
+ id: getTranslationKey('list.table.header.creationDate'),
22
+ defaultMessage: 'creation date'
23
+ }
24
+ },
25
+ {
26
+ name: 'updatedAt',
27
+ label: {
28
+ id: getTranslationKey('list.table.header.lastModified'),
29
+ defaultMessage: 'last modified'
30
+ }
31
+ },
32
+ {
33
+ name: 'size',
34
+ label: {
35
+ id: getTranslationKey('list.table.header.size'),
36
+ defaultMessage: 'size'
37
+ }
38
+ },
39
+ {
40
+ name: 'actions',
41
+ label: {
42
+ id: getTranslationKey('list.table.header.actions'),
43
+ defaultMessage: 'actions'
44
+ },
45
+ isVisuallyHidden: true
46
+ }
47
+ ];
48
+
49
+ export { TABLE_HEADERS, localStorageKeys, viewOptions };
50
+ //# sourceMappingURL=constants.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.mjs","sources":["../../../../../admin/src/future/pages/Assets/constants.ts"],"sourcesContent":["import { getTranslationKey } from '../../utils/translations';\n\nexport const localStorageKeys = {\n view: `STRAPI_UPLOAD_LIBRARY_VIEW`,\n};\n\nexport const viewOptions = {\n GRID: 0,\n TABLE: 1,\n};\n\ninterface TableHeader {\n name: string;\n label: { id: string; defaultMessage: string };\n isVisuallyHidden?: boolean;\n}\n\nexport const TABLE_HEADERS: TableHeader[] = [\n {\n name: 'name',\n label: { id: getTranslationKey('list.table.header.name'), defaultMessage: 'name' },\n },\n {\n name: 'createdAt',\n label: {\n id: getTranslationKey('list.table.header.creationDate'),\n defaultMessage: 'creation date',\n },\n },\n {\n name: 'updatedAt',\n label: {\n id: getTranslationKey('list.table.header.lastModified'),\n defaultMessage: 'last modified',\n },\n },\n {\n name: 'size',\n label: { id: getTranslationKey('list.table.header.size'), defaultMessage: 'size' },\n },\n {\n name: 'actions',\n label: { id: getTranslationKey('list.table.header.actions'), defaultMessage: 'actions' },\n isVisuallyHidden: true,\n },\n];\n"],"names":["localStorageKeys","view","viewOptions","GRID","TABLE","TABLE_HEADERS","name","label","id","getTranslationKey","defaultMessage","isVisuallyHidden"],"mappings":";;MAEaA,gBAAmB,GAAA;IAC9BC,IAAM,EAAA,CAAC,0BAA0B;AACnC;MAEaC,WAAc,GAAA;IACzBC,IAAM,EAAA,CAAA;IACNC,KAAO,EAAA;AACT;MAQaC,aAA+B,GAAA;AAC1C,IAAA;QACEC,IAAM,EAAA,MAAA;QACNC,KAAO,EAAA;AAAEC,YAAAA,EAAAA,EAAIC,iBAAkB,CAAA,wBAAA,CAAA;YAA2BC,cAAgB,EAAA;AAAO;AACnF,KAAA;AACA,IAAA;QACEJ,IAAM,EAAA,WAAA;QACNC,KAAO,EAAA;AACLC,YAAAA,EAAAA,EAAIC,iBAAkB,CAAA,gCAAA,CAAA;YACtBC,cAAgB,EAAA;AAClB;AACF,KAAA;AACA,IAAA;QACEJ,IAAM,EAAA,WAAA;QACNC,KAAO,EAAA;AACLC,YAAAA,EAAAA,EAAIC,iBAAkB,CAAA,gCAAA,CAAA;YACtBC,cAAgB,EAAA;AAClB;AACF,KAAA;AACA,IAAA;QACEJ,IAAM,EAAA,MAAA;QACNC,KAAO,EAAA;AAAEC,YAAAA,EAAAA,EAAIC,iBAAkB,CAAA,wBAAA,CAAA;YAA2BC,cAAgB,EAAA;AAAO;AACnF,KAAA;AACA,IAAA;QACEJ,IAAM,EAAA,SAAA;QACNC,KAAO,EAAA;AAAEC,YAAAA,EAAAA,EAAIC,iBAAkB,CAAA,2BAAA,CAAA;YAA8BC,cAAgB,EAAA;AAAU,SAAA;QACvFC,gBAAkB,EAAA;AACpB;;;;;"}
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ var strapiAdmin = require('@strapi/admin/strapi-admin');
4
+
5
+ const uploadApi = strapiAdmin.adminApi.enhanceEndpoints({
6
+ addTagTypes: [
7
+ 'Asset',
8
+ 'Folder'
9
+ ]
10
+ }).injectEndpoints({
11
+ endpoints: (builder)=>({
12
+ uploadFiles: builder.mutation({
13
+ query: (formData)=>({
14
+ url: '/upload',
15
+ method: 'POST',
16
+ data: formData
17
+ }),
18
+ invalidatesTags: [
19
+ 'Asset'
20
+ ]
21
+ })
22
+ })
23
+ });
24
+ const { useUploadFilesMutation } = uploadApi;
25
+
26
+ exports.uploadApi = uploadApi;
27
+ exports.useUploadFilesMutation = useUploadFilesMutation;
28
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sources":["../../../../admin/src/future/services/api.ts"],"sourcesContent":["import { adminApi } from '@strapi/admin/strapi-admin';\n\nimport type { CreateFile } from '../../../../shared/contracts/files';\n\nconst uploadApi = adminApi\n .enhanceEndpoints({\n addTagTypes: ['Asset', 'Folder'],\n })\n .injectEndpoints({\n endpoints: (builder) => ({\n uploadFiles: builder.mutation<CreateFile.Response, FormData>({\n query: (formData) => ({\n url: '/upload',\n method: 'POST',\n data: formData,\n }),\n invalidatesTags: ['Asset'],\n }),\n }),\n });\n\nexport const { useUploadFilesMutation } = uploadApi;\nexport { uploadApi };\n"],"names":["uploadApi","adminApi","enhanceEndpoints","addTagTypes","injectEndpoints","endpoints","builder","uploadFiles","mutation","query","formData","url","method","data","invalidatesTags","useUploadFilesMutation"],"mappings":";;;;AAIMA,MAAAA,SAAAA,GAAYC,oBACfC,CAAAA,gBAAgB,CAAC;IAChBC,WAAa,EAAA;AAAC,QAAA,OAAA;AAAS,QAAA;AAAS;AAClC,CAAA,CAAA,CACCC,eAAe,CAAC;IACfC,SAAW,EAAA,CAACC,WAAa;YACvBC,WAAaD,EAAAA,OAAAA,CAAQE,QAAQ,CAAgC;gBAC3DC,KAAO,EAAA,CAACC,YAAc;wBACpBC,GAAK,EAAA,SAAA;wBACLC,MAAQ,EAAA,MAAA;wBACRC,IAAMH,EAAAA;qBACR,CAAA;gBACAI,eAAiB,EAAA;AAAC,oBAAA;AAAQ;AAC5B,aAAA;SACF;AACF,CAAA;AAEW,MAAA,EAAEC,sBAAsB,EAAE,GAAGf;;;;;"}
@@ -0,0 +1,25 @@
1
+ import { adminApi } from '@strapi/admin/strapi-admin';
2
+
3
+ const uploadApi = adminApi.enhanceEndpoints({
4
+ addTagTypes: [
5
+ 'Asset',
6
+ 'Folder'
7
+ ]
8
+ }).injectEndpoints({
9
+ endpoints: (builder)=>({
10
+ uploadFiles: builder.mutation({
11
+ query: (formData)=>({
12
+ url: '/upload',
13
+ method: 'POST',
14
+ data: formData
15
+ }),
16
+ invalidatesTags: [
17
+ 'Asset'
18
+ ]
19
+ })
20
+ })
21
+ });
22
+ const { useUploadFilesMutation } = uploadApi;
23
+
24
+ export { uploadApi, useUploadFilesMutation };
25
+ //# sourceMappingURL=api.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.mjs","sources":["../../../../admin/src/future/services/api.ts"],"sourcesContent":["import { adminApi } from '@strapi/admin/strapi-admin';\n\nimport type { CreateFile } from '../../../../shared/contracts/files';\n\nconst uploadApi = adminApi\n .enhanceEndpoints({\n addTagTypes: ['Asset', 'Folder'],\n })\n .injectEndpoints({\n endpoints: (builder) => ({\n uploadFiles: builder.mutation<CreateFile.Response, FormData>({\n query: (formData) => ({\n url: '/upload',\n method: 'POST',\n data: formData,\n }),\n invalidatesTags: ['Asset'],\n }),\n }),\n });\n\nexport const { useUploadFilesMutation } = uploadApi;\nexport { uploadApi };\n"],"names":["uploadApi","adminApi","enhanceEndpoints","addTagTypes","injectEndpoints","endpoints","builder","uploadFiles","mutation","query","formData","url","method","data","invalidatesTags","useUploadFilesMutation"],"mappings":";;AAIMA,MAAAA,SAAAA,GAAYC,QACfC,CAAAA,gBAAgB,CAAC;IAChBC,WAAa,EAAA;AAAC,QAAA,OAAA;AAAS,QAAA;AAAS;AAClC,CAAA,CAAA,CACCC,eAAe,CAAC;IACfC,SAAW,EAAA,CAACC,WAAa;YACvBC,WAAaD,EAAAA,OAAAA,CAAQE,QAAQ,CAAgC;gBAC3DC,KAAO,EAAA,CAACC,YAAc;wBACpBC,GAAK,EAAA,SAAA;wBACLC,MAAQ,EAAA,MAAA;wBACRC,IAAMH,EAAAA;qBACR,CAAA;gBACAI,eAAiB,EAAA;AAAC,oBAAA;AAAQ;AAC5B,aAAA;SACF;AACF,CAAA;AAEW,MAAA,EAAEC,sBAAsB,EAAE,GAAGf;;;;"}
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+
3
+ var api = require('./api.js');
4
+
5
+ const assetsApi = api.uploadApi.injectEndpoints({
6
+ endpoints: (builder)=>({
7
+ getAssets: builder.query({
8
+ query: (params = {})=>({
9
+ url: '/upload/files',
10
+ method: 'GET',
11
+ config: {
12
+ params
13
+ }
14
+ }),
15
+ transformResponse: (response)=>response,
16
+ providesTags: (result)=>result ? [
17
+ ...result.results.map(({ id })=>({
18
+ type: 'Asset',
19
+ id
20
+ })),
21
+ {
22
+ type: 'Asset',
23
+ id: 'LIST'
24
+ }
25
+ ] : [
26
+ {
27
+ type: 'Asset',
28
+ id: 'LIST'
29
+ }
30
+ ]
31
+ })
32
+ })
33
+ });
34
+ const { useGetAssetsQuery } = assetsApi;
35
+
36
+ exports.useGetAssetsQuery = useGetAssetsQuery;
37
+ //# sourceMappingURL=assets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assets.js","sources":["../../../../admin/src/future/services/assets.ts"],"sourcesContent":["import { uploadApi } from './api';\n\nimport type { GetFiles, File, Pagination } from '../../../../shared/contracts/files';\n\ninterface GetAssetsParams {\n page?: number;\n pageSize?: number;\n folder?: number | null;\n sort?: string;\n}\n\ninterface GetAssetsResponse {\n results: File[];\n pagination: Pagination;\n}\n\nconst assetsApi = uploadApi.injectEndpoints({\n endpoints: (builder) => ({\n getAssets: builder.query<GetAssetsResponse, GetAssetsParams | void>({\n query: (params = {}) => ({\n url: '/upload/files',\n method: 'GET',\n config: { params },\n }),\n transformResponse: (response: GetFiles.Response['data']) => response,\n providesTags: (result) =>\n result\n ? [\n ...result.results.map(({ id }) => ({ type: 'Asset' as const, id })),\n { type: 'Asset', id: 'LIST' },\n ]\n : [{ type: 'Asset', id: 'LIST' }],\n }),\n }),\n});\n\nexport const { useGetAssetsQuery } = assetsApi;\n"],"names":["assetsApi","uploadApi","injectEndpoints","endpoints","builder","getAssets","query","params","url","method","config","transformResponse","response","providesTags","result","results","map","id","type","useGetAssetsQuery"],"mappings":";;;;AAgBA,MAAMA,SAAAA,GAAYC,aAAUC,CAAAA,eAAe,CAAC;IAC1CC,SAAW,EAAA,CAACC,WAAa;YACvBC,SAAWD,EAAAA,OAAAA,CAAQE,KAAK,CAA4C;AAClEA,gBAAAA,KAAAA,EAAO,CAACC,MAAAA,GAAS,EAAE,IAAM;wBACvBC,GAAK,EAAA,eAAA;wBACLC,MAAQ,EAAA,KAAA;wBACRC,MAAQ,EAAA;AAAEH,4BAAAA;AAAO;qBACnB,CAAA;AACAI,gBAAAA,iBAAAA,EAAmB,CAACC,QAAwCA,GAAAA,QAAAA;gBAC5DC,YAAc,EAAA,CAACC,SACbA,MACI,GAAA;2BACKA,MAAOC,CAAAA,OAAO,CAACC,GAAG,CAAC,CAAC,EAAEC,EAAE,EAAE,IAAM;gCAAEC,IAAM,EAAA,OAAA;AAAkBD,gCAAAA;6BAAG,CAAA,CAAA;AAChE,wBAAA;4BAAEC,IAAM,EAAA,OAAA;4BAASD,EAAI,EAAA;AAAO;qBAC7B,GACD;AAAC,wBAAA;4BAAEC,IAAM,EAAA,OAAA;4BAASD,EAAI,EAAA;AAAO;AAAE;AACvC,aAAA;SACF;AACF,CAAA,CAAA;AAEa,MAAA,EAAEE,iBAAiB,EAAE,GAAGnB;;;;"}
@@ -0,0 +1,35 @@
1
+ import { uploadApi } from './api.mjs';
2
+
3
+ const assetsApi = uploadApi.injectEndpoints({
4
+ endpoints: (builder)=>({
5
+ getAssets: builder.query({
6
+ query: (params = {})=>({
7
+ url: '/upload/files',
8
+ method: 'GET',
9
+ config: {
10
+ params
11
+ }
12
+ }),
13
+ transformResponse: (response)=>response,
14
+ providesTags: (result)=>result ? [
15
+ ...result.results.map(({ id })=>({
16
+ type: 'Asset',
17
+ id
18
+ })),
19
+ {
20
+ type: 'Asset',
21
+ id: 'LIST'
22
+ }
23
+ ] : [
24
+ {
25
+ type: 'Asset',
26
+ id: 'LIST'
27
+ }
28
+ ]
29
+ })
30
+ })
31
+ });
32
+ const { useGetAssetsQuery } = assetsApi;
33
+
34
+ export { useGetAssetsQuery };
35
+ //# sourceMappingURL=assets.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assets.mjs","sources":["../../../../admin/src/future/services/assets.ts"],"sourcesContent":["import { uploadApi } from './api';\n\nimport type { GetFiles, File, Pagination } from '../../../../shared/contracts/files';\n\ninterface GetAssetsParams {\n page?: number;\n pageSize?: number;\n folder?: number | null;\n sort?: string;\n}\n\ninterface GetAssetsResponse {\n results: File[];\n pagination: Pagination;\n}\n\nconst assetsApi = uploadApi.injectEndpoints({\n endpoints: (builder) => ({\n getAssets: builder.query<GetAssetsResponse, GetAssetsParams | void>({\n query: (params = {}) => ({\n url: '/upload/files',\n method: 'GET',\n config: { params },\n }),\n transformResponse: (response: GetFiles.Response['data']) => response,\n providesTags: (result) =>\n result\n ? [\n ...result.results.map(({ id }) => ({ type: 'Asset' as const, id })),\n { type: 'Asset', id: 'LIST' },\n ]\n : [{ type: 'Asset', id: 'LIST' }],\n }),\n }),\n});\n\nexport const { useGetAssetsQuery } = assetsApi;\n"],"names":["assetsApi","uploadApi","injectEndpoints","endpoints","builder","getAssets","query","params","url","method","config","transformResponse","response","providesTags","result","results","map","id","type","useGetAssetsQuery"],"mappings":";;AAgBA,MAAMA,SAAAA,GAAYC,SAAUC,CAAAA,eAAe,CAAC;IAC1CC,SAAW,EAAA,CAACC,WAAa;YACvBC,SAAWD,EAAAA,OAAAA,CAAQE,KAAK,CAA4C;AAClEA,gBAAAA,KAAAA,EAAO,CAACC,MAAAA,GAAS,EAAE,IAAM;wBACvBC,GAAK,EAAA,eAAA;wBACLC,MAAQ,EAAA,KAAA;wBACRC,MAAQ,EAAA;AAAEH,4BAAAA;AAAO;qBACnB,CAAA;AACAI,gBAAAA,iBAAAA,EAAmB,CAACC,QAAwCA,GAAAA,QAAAA;gBAC5DC,YAAc,EAAA,CAACC,SACbA,MACI,GAAA;2BACKA,MAAOC,CAAAA,OAAO,CAACC,GAAG,CAAC,CAAC,EAAEC,EAAE,EAAE,IAAM;gCAAEC,IAAM,EAAA,OAAA;AAAkBD,gCAAAA;6BAAG,CAAA,CAAA;AAChE,wBAAA;4BAAEC,IAAM,EAAA,OAAA;4BAASD,EAAI,EAAA;AAAO;qBAC7B,GACD;AAAC,wBAAA;4BAAEC,IAAM,EAAA,OAAA;4BAASD,EAAI,EAAA;AAAO;AAAE;AACvC,aAAA;SACF;AACF,CAAA,CAAA;AAEa,MAAA,EAAEE,iBAAiB,EAAE,GAAGnB;;;;"}
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ var byteSize = require('byte-size');
4
+
5
+ function formatBytes(receivedBytes, decimals = 0) {
6
+ const realBytes = typeof receivedBytes === 'string' ? Number(receivedBytes) : receivedBytes;
7
+ const { value, unit } = byteSize(realBytes * 1000, {
8
+ precision: decimals
9
+ });
10
+ if (!unit) {
11
+ return '0B';
12
+ }
13
+ return `${value}${unit.toUpperCase()}`;
14
+ }
15
+ const getFileExtension = (ext)=>ext && ext[0] === '.' ? ext.substring(1) : ext;
16
+ const prefixFileUrlWithBackendUrl = (fileURL)=>{
17
+ return !!fileURL && fileURL.startsWith('/') ? `${window.strapi.backendURL}${fileURL}` : fileURL;
18
+ };
19
+
20
+ exports.formatBytes = formatBytes;
21
+ exports.getFileExtension = getFileExtension;
22
+ exports.prefixFileUrlWithBackendUrl = prefixFileUrlWithBackendUrl;
23
+ //# sourceMappingURL=files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.js","sources":["../../../../admin/src/future/utils/files.ts"],"sourcesContent":["import byteSize from 'byte-size';\n\nexport function formatBytes(receivedBytes: number | string, decimals = 0) {\n const realBytes = typeof receivedBytes === 'string' ? Number(receivedBytes) : receivedBytes;\n const { value, unit } = byteSize(realBytes * 1000, { precision: decimals });\n\n if (!unit) {\n return '0B';\n }\n\n return `${value}${unit.toUpperCase()}`;\n}\n\nexport const getFileExtension = (ext?: string | null) =>\n ext && ext[0] === '.' ? ext.substring(1) : ext;\n\nexport const prefixFileUrlWithBackendUrl = (fileURL?: string) => {\n return !!fileURL && fileURL.startsWith('/') ? `${window.strapi.backendURL}${fileURL}` : fileURL;\n};\n"],"names":["formatBytes","receivedBytes","decimals","realBytes","Number","value","unit","byteSize","precision","toUpperCase","getFileExtension","ext","substring","prefixFileUrlWithBackendUrl","fileURL","startsWith","window","strapi","backendURL"],"mappings":";;;;AAEO,SAASA,WAAAA,CAAYC,aAA8B,EAAEC,WAAW,CAAC,EAAA;AACtE,IAAA,MAAMC,SAAY,GAAA,OAAOF,aAAkB,KAAA,QAAA,GAAWG,OAAOH,aAAiBA,CAAAA,GAAAA,aAAAA;IAC9E,MAAM,EAAEI,KAAK,EAAEC,IAAI,EAAE,GAAGC,QAAAA,CAASJ,YAAY,IAAM,EAAA;QAAEK,SAAWN,EAAAA;AAAS,KAAA,CAAA;AAEzE,IAAA,IAAI,CAACI,IAAM,EAAA;QACT,OAAO,IAAA;AACT;AAEA,IAAA,OAAO,CAAGD,EAAAA,KAAAA,CAAAA,EAAQC,IAAKG,CAAAA,WAAW,EAAI,CAAA,CAAA;AACxC;AAEaC,MAAAA,gBAAAA,GAAmB,CAACC,GAAAA,GAC/BA,OAAOA,GAAG,CAAC,CAAE,CAAA,KAAK,GAAMA,GAAAA,GAAAA,CAAIC,SAAS,CAAC,KAAKD;AAEtC,MAAME,8BAA8B,CAACC,OAAAA,GAAAA;AAC1C,IAAA,OAAO,CAAC,CAACA,OAAWA,IAAAA,OAAAA,CAAQC,UAAU,CAAC,GAAA,CAAA,GAAO,CAAGC,EAAAA,MAAAA,CAAOC,MAAM,CAACC,UAAU,CAAA,EAAGJ,SAAS,GAAGA,OAAAA;AAC1F;;;;;;"}