@strapi/upload 5.35.0 → 5.36.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/future/App.js +8 -20
- package/dist/admin/future/App.js.map +1 -1
- package/dist/admin/future/App.mjs +8 -20
- package/dist/admin/future/App.mjs.map +1 -1
- package/dist/admin/future/components/UploadProgressDialog.js +494 -0
- package/dist/admin/future/components/UploadProgressDialog.js.map +1 -0
- package/dist/admin/future/components/UploadProgressDialog.mjs +473 -0
- package/dist/admin/future/components/UploadProgressDialog.mjs.map +1 -0
- package/dist/admin/future/enums.js +12 -0
- package/dist/admin/future/enums.js.map +1 -0
- package/dist/admin/future/enums.mjs +10 -0
- package/dist/admin/future/enums.mjs.map +1 -0
- package/dist/admin/future/pages/Assets/AssetsPage.js +311 -0
- package/dist/admin/future/pages/Assets/AssetsPage.js.map +1 -0
- package/dist/admin/future/pages/Assets/AssetsPage.mjs +290 -0
- package/dist/admin/future/pages/Assets/AssetsPage.mjs.map +1 -0
- package/dist/admin/future/pages/Assets/components/AssetsGrid.js +164 -0
- package/dist/admin/future/pages/Assets/components/AssetsGrid.js.map +1 -0
- package/dist/admin/future/pages/Assets/components/AssetsGrid.mjs +162 -0
- package/dist/admin/future/pages/Assets/components/AssetsGrid.mjs.map +1 -0
- package/dist/admin/future/pages/Assets/components/AssetsTable.js +198 -0
- package/dist/admin/future/pages/Assets/components/AssetsTable.js.map +1 -0
- package/dist/admin/future/pages/Assets/components/AssetsTable.mjs +196 -0
- package/dist/admin/future/pages/Assets/components/AssetsTable.mjs.map +1 -0
- package/dist/admin/future/pages/Assets/components/DropZone/UploadDropZone.js +127 -0
- package/dist/admin/future/pages/Assets/components/DropZone/UploadDropZone.js.map +1 -0
- package/dist/admin/future/pages/Assets/components/DropZone/UploadDropZone.mjs +105 -0
- package/dist/admin/future/pages/Assets/components/DropZone/UploadDropZone.mjs.map +1 -0
- package/dist/admin/future/pages/Assets/components/DropZone/UploadDropZoneContext.js +107 -0
- package/dist/admin/future/pages/Assets/components/DropZone/UploadDropZoneContext.js.map +1 -0
- package/dist/admin/future/pages/Assets/components/DropZone/UploadDropZoneContext.mjs +104 -0
- package/dist/admin/future/pages/Assets/components/DropZone/UploadDropZoneContext.mjs.map +1 -0
- package/dist/admin/future/pages/Assets/constants.js +54 -0
- package/dist/admin/future/pages/Assets/constants.js.map +1 -0
- package/dist/admin/future/pages/Assets/constants.mjs +50 -0
- package/dist/admin/future/pages/Assets/constants.mjs.map +1 -0
- package/dist/admin/future/pages/Assets/hooks/useInfiniteAssets.js +77 -0
- package/dist/admin/future/pages/Assets/hooks/useInfiniteAssets.js.map +1 -0
- package/dist/admin/future/pages/Assets/hooks/useInfiniteAssets.mjs +74 -0
- package/dist/admin/future/pages/Assets/hooks/useInfiniteAssets.mjs.map +1 -0
- package/dist/admin/future/services/api.js +419 -9
- package/dist/admin/future/services/api.js.map +1 -1
- package/dist/admin/future/services/api.mjs +417 -9
- package/dist/admin/future/services/api.mjs.map +1 -1
- package/dist/admin/future/services/assets.js +37 -0
- package/dist/admin/future/services/assets.js.map +1 -0
- package/dist/admin/future/services/assets.mjs +35 -0
- package/dist/admin/future/services/assets.mjs.map +1 -0
- package/dist/admin/future/store/hooks.js +10 -0
- package/dist/admin/future/store/hooks.js.map +1 -0
- package/dist/admin/future/store/hooks.mjs +7 -0
- package/dist/admin/future/store/hooks.mjs.map +1 -0
- package/dist/admin/future/store/uploadProgress.js +156 -0
- package/dist/admin/future/store/uploadProgress.js.map +1 -0
- package/dist/admin/future/store/uploadProgress.mjs +143 -0
- package/dist/admin/future/store/uploadProgress.mjs.map +1 -0
- package/dist/admin/future/utils/files.js +23 -0
- package/dist/admin/future/utils/files.js.map +1 -0
- package/dist/admin/future/utils/files.mjs +19 -0
- package/dist/admin/future/utils/files.mjs.map +1 -0
- package/dist/admin/future/utils/getAssetIcon.js +28 -0
- package/dist/admin/future/utils/getAssetIcon.js.map +1 -0
- package/dist/admin/future/utils/getAssetIcon.mjs +26 -0
- package/dist/admin/future/utils/getAssetIcon.mjs.map +1 -0
- package/dist/admin/index.js +11 -0
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +11 -0
- package/dist/admin/index.mjs.map +1 -1
- package/dist/admin/package.json.js +11 -9
- package/dist/admin/package.json.js.map +1 -1
- package/dist/admin/package.json.mjs +11 -9
- package/dist/admin/package.json.mjs.map +1 -1
- package/dist/admin/src/future/components/UploadProgressDialog.d.ts +1 -0
- package/dist/admin/src/future/enums.d.ts +6 -0
- package/dist/admin/src/future/pages/Assets/AssetsPage.d.ts +1 -0
- package/dist/admin/src/future/pages/Assets/components/AssetsGrid.d.ts +6 -0
- package/dist/admin/src/future/pages/Assets/components/AssetsTable.d.ts +6 -0
- package/dist/admin/src/future/pages/Assets/components/DropZone/UploadDropZone.d.ts +9 -0
- package/dist/admin/src/future/pages/Assets/components/DropZone/UploadDropZoneContext.d.ts +11 -0
- package/dist/admin/src/future/pages/Assets/constants.d.ts +17 -0
- package/dist/admin/src/future/pages/Assets/hooks/useInfiniteAssets.d.ts +17 -0
- package/dist/admin/src/future/services/api.d.ts +21 -3
- package/dist/admin/src/future/services/assets.d.ts +13 -0
- package/dist/admin/src/future/store/hooks.d.ts +6 -0
- package/dist/admin/src/future/store/uploadProgress.d.ts +46 -0
- package/dist/admin/src/future/utils/files.d.ts +3 -0
- package/dist/admin/src/future/utils/getAssetIcon.d.ts +12 -0
- package/dist/admin/translations/en.json.js +25 -0
- package/dist/admin/translations/en.json.js.map +1 -1
- package/dist/admin/translations/en.json.mjs +25 -0
- package/dist/admin/translations/en.json.mjs.map +1 -1
- package/dist/server/controllers/admin-upload.js +151 -2
- package/dist/server/controllers/admin-upload.js.map +1 -1
- package/dist/server/controllers/admin-upload.mjs +151 -2
- package/dist/server/controllers/admin-upload.mjs.map +1 -1
- package/dist/server/controllers/content-api.js +8 -2
- package/dist/server/controllers/content-api.js.map +1 -1
- package/dist/server/controllers/content-api.mjs +9 -3
- package/dist/server/controllers/content-api.mjs.map +1 -1
- package/dist/server/routes/admin.js +10 -0
- package/dist/server/routes/admin.js.map +1 -1
- package/dist/server/routes/admin.mjs +10 -0
- package/dist/server/routes/admin.mjs.map +1 -1
- package/dist/server/src/controllers/admin-upload.d.ts +12 -0
- package/dist/server/src/controllers/admin-upload.d.ts.map +1 -1
- package/dist/server/src/controllers/content-api.d.ts.map +1 -1
- package/dist/server/src/controllers/index.d.ts +1 -0
- package/dist/server/src/controllers/index.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +1 -0
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/routes/admin.d.ts.map +1 -1
- package/dist/server/src/utils/mime-validation.d.ts +5 -0
- package/dist/server/src/utils/mime-validation.d.ts.map +1 -1
- package/dist/server/utils/mime-validation.js +7 -4
- package/dist/server/utils/mime-validation.js.map +1 -1
- package/dist/server/utils/mime-validation.mjs +7 -4
- package/dist/server/utils/mime-validation.mjs.map +1 -1
- package/dist/shared/contracts/files.d.ts +52 -0
- package/dist/shared/contracts/files.d.ts.map +1 -0
- package/package.json +11 -9
- package/dist/admin/future/pages/AIGenerationPage.js +0 -24
- package/dist/admin/future/pages/AIGenerationPage.js.map +0 -1
- package/dist/admin/future/pages/AIGenerationPage.mjs +0 -22
- package/dist/admin/future/pages/AIGenerationPage.mjs.map +0 -1
- package/dist/admin/future/pages/MediaLibraryPage.js +0 -119
- package/dist/admin/future/pages/MediaLibraryPage.js.map +0 -1
- package/dist/admin/future/pages/MediaLibraryPage.mjs +0 -98
- package/dist/admin/future/pages/MediaLibraryPage.mjs.map +0 -1
- package/dist/admin/src/future/pages/AIGenerationPage.d.ts +0 -1
- package/dist/admin/src/future/pages/MediaLibraryPage.d.ts +0 -1
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { useIsMobile } from '@strapi/admin/strapi-admin';
|
|
3
|
+
import { RawTable, RawThead, RawTh, RawTd, RawTr, VisuallyHidden, Typography, RawTbody, Flex, IconButton } from '@strapi/design-system';
|
|
4
|
+
import { More } from '@strapi/icons';
|
|
5
|
+
import { useIntl } from 'react-intl';
|
|
6
|
+
import { styled } from 'styled-components';
|
|
7
|
+
import { formatBytes } from '../../../utils/files.mjs';
|
|
8
|
+
import { getAssetIcon } from '../../../utils/getAssetIcon.mjs';
|
|
9
|
+
import { getTranslationKey } from '../../../utils/translations.mjs';
|
|
10
|
+
import { TABLE_HEADERS } from '../constants.mjs';
|
|
11
|
+
|
|
12
|
+
const StyledTable = styled(RawTable)`
|
|
13
|
+
width: 100%;
|
|
14
|
+
border-collapse: separate;
|
|
15
|
+
border-spacing: 0;
|
|
16
|
+
border: 1px solid ${({ theme })=>theme.colors.neutral150};
|
|
17
|
+
border-radius: 4px;
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
`;
|
|
20
|
+
const StyledThead = styled(RawThead)`
|
|
21
|
+
background: ${({ theme })=>theme.colors.neutral100};
|
|
22
|
+
|
|
23
|
+
tr {
|
|
24
|
+
border-bottom: 1px solid ${({ theme })=>theme.colors.neutral150};
|
|
25
|
+
}
|
|
26
|
+
`;
|
|
27
|
+
const StyledTh = styled(RawTh)`
|
|
28
|
+
height: 40px;
|
|
29
|
+
padding: 0 ${({ theme })=>theme.spaces[4]};
|
|
30
|
+
text-align: left;
|
|
31
|
+
`;
|
|
32
|
+
const StyledTd = styled(RawTd)`
|
|
33
|
+
padding: 0 ${({ theme })=>theme.spaces[4]};
|
|
34
|
+
border-bottom: 1px solid ${({ theme })=>theme.colors.neutral150};
|
|
35
|
+
`;
|
|
36
|
+
const StyledTr = styled(RawTr)`
|
|
37
|
+
height: 48px;
|
|
38
|
+
background: ${({ theme })=>theme.colors.neutral0};
|
|
39
|
+
|
|
40
|
+
&:last-child {
|
|
41
|
+
${StyledTd} {
|
|
42
|
+
border-bottom: 0;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
`;
|
|
46
|
+
const StyledBodyTd = styled(RawTd)`
|
|
47
|
+
padding: ${({ theme })=>theme.spaces[4]};
|
|
48
|
+
border-bottom: 1px solid ${({ theme })=>theme.colors.neutral150};
|
|
49
|
+
`;
|
|
50
|
+
const AssetPreviewCell = ({ asset })=>{
|
|
51
|
+
const { ext, mime } = asset;
|
|
52
|
+
const DocIcon = getAssetIcon(mime, ext);
|
|
53
|
+
return /*#__PURE__*/ jsx(Flex, {
|
|
54
|
+
justifyContent: "center",
|
|
55
|
+
alignItems: "center",
|
|
56
|
+
borderRadius: "4px",
|
|
57
|
+
color: "neutral500",
|
|
58
|
+
width: "3.2rem",
|
|
59
|
+
height: "3.2rem",
|
|
60
|
+
shrink: 0,
|
|
61
|
+
children: /*#__PURE__*/ jsx(DocIcon, {
|
|
62
|
+
width: 16,
|
|
63
|
+
height: 16
|
|
64
|
+
})
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
const AssetRow = ({ asset })=>{
|
|
68
|
+
const isMobile = useIsMobile();
|
|
69
|
+
const { formatDate, formatMessage } = useIntl();
|
|
70
|
+
return /*#__PURE__*/ jsxs(StyledTr, {
|
|
71
|
+
children: [
|
|
72
|
+
/*#__PURE__*/ jsx(StyledTd, {
|
|
73
|
+
children: /*#__PURE__*/ jsxs(Flex, {
|
|
74
|
+
gap: 3,
|
|
75
|
+
alignItems: "center",
|
|
76
|
+
children: [
|
|
77
|
+
/*#__PURE__*/ jsx(AssetPreviewCell, {
|
|
78
|
+
asset: asset
|
|
79
|
+
}),
|
|
80
|
+
/*#__PURE__*/ jsxs(Flex, {
|
|
81
|
+
direction: "column",
|
|
82
|
+
alignItems: "flex-start",
|
|
83
|
+
children: [
|
|
84
|
+
/*#__PURE__*/ jsx(Typography, {
|
|
85
|
+
textColor: "neutral800",
|
|
86
|
+
fontWeight: "semiBold",
|
|
87
|
+
ellipsis: true,
|
|
88
|
+
children: asset.name
|
|
89
|
+
}),
|
|
90
|
+
isMobile && /*#__PURE__*/ jsx(Typography, {
|
|
91
|
+
textColor: "neutral600",
|
|
92
|
+
variant: "pi",
|
|
93
|
+
children: asset.size ? formatBytes(asset.size, 1) : '-'
|
|
94
|
+
})
|
|
95
|
+
]
|
|
96
|
+
})
|
|
97
|
+
]
|
|
98
|
+
})
|
|
99
|
+
}),
|
|
100
|
+
!isMobile && /*#__PURE__*/ jsxs(Fragment, {
|
|
101
|
+
children: [
|
|
102
|
+
/*#__PURE__*/ jsx(StyledTd, {
|
|
103
|
+
children: /*#__PURE__*/ jsx(Typography, {
|
|
104
|
+
textColor: "neutral600",
|
|
105
|
+
children: asset.createdAt ? formatDate(new Date(asset.createdAt), {
|
|
106
|
+
dateStyle: 'long'
|
|
107
|
+
}) : '-'
|
|
108
|
+
})
|
|
109
|
+
}),
|
|
110
|
+
/*#__PURE__*/ jsx(StyledTd, {
|
|
111
|
+
children: /*#__PURE__*/ jsx(Typography, {
|
|
112
|
+
textColor: "neutral600",
|
|
113
|
+
children: asset.updatedAt ? formatDate(new Date(asset.updatedAt), {
|
|
114
|
+
dateStyle: 'long'
|
|
115
|
+
}) : '-'
|
|
116
|
+
})
|
|
117
|
+
}),
|
|
118
|
+
/*#__PURE__*/ jsx(StyledTd, {
|
|
119
|
+
children: /*#__PURE__*/ jsx(Typography, {
|
|
120
|
+
textColor: "neutral600",
|
|
121
|
+
children: asset.size ? formatBytes(asset.size, 1) : '-'
|
|
122
|
+
})
|
|
123
|
+
})
|
|
124
|
+
]
|
|
125
|
+
}),
|
|
126
|
+
/*#__PURE__*/ jsx(StyledTd, {
|
|
127
|
+
children: /*#__PURE__*/ jsx(Flex, {
|
|
128
|
+
justifyContent: "flex-end",
|
|
129
|
+
children: /*#__PURE__*/ jsx(IconButton, {
|
|
130
|
+
label: formatMessage({
|
|
131
|
+
id: getTranslationKey('control-card.more-actions'),
|
|
132
|
+
defaultMessage: 'More actions'
|
|
133
|
+
}),
|
|
134
|
+
variant: "ghost",
|
|
135
|
+
children: /*#__PURE__*/ jsx(More, {})
|
|
136
|
+
})
|
|
137
|
+
})
|
|
138
|
+
})
|
|
139
|
+
]
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
const AssetsTable = ({ assets })=>{
|
|
143
|
+
const isMobile = useIsMobile();
|
|
144
|
+
const { formatMessage } = useIntl();
|
|
145
|
+
const visibleHeaders = isMobile ? TABLE_HEADERS.filter((h)=>h.name === 'name' || h.name === 'actions') : TABLE_HEADERS;
|
|
146
|
+
return /*#__PURE__*/ jsxs(StyledTable, {
|
|
147
|
+
colCount: visibleHeaders.length,
|
|
148
|
+
rowCount: assets.length + 1,
|
|
149
|
+
children: [
|
|
150
|
+
/*#__PURE__*/ jsx(StyledThead, {
|
|
151
|
+
children: /*#__PURE__*/ jsx(RawTr, {
|
|
152
|
+
children: visibleHeaders.map((header)=>{
|
|
153
|
+
const tableHeaderLabel = formatMessage(header.label);
|
|
154
|
+
const isVisuallyHidden = 'isVisuallyHidden' in header && header.isVisuallyHidden;
|
|
155
|
+
if (isVisuallyHidden) {
|
|
156
|
+
return /*#__PURE__*/ jsx(StyledTh, {
|
|
157
|
+
children: /*#__PURE__*/ jsx(VisuallyHidden, {
|
|
158
|
+
children: formatMessage({
|
|
159
|
+
id: getTranslationKey('table.header.actions'),
|
|
160
|
+
defaultMessage: 'actions'
|
|
161
|
+
})
|
|
162
|
+
})
|
|
163
|
+
}, header.name);
|
|
164
|
+
}
|
|
165
|
+
return /*#__PURE__*/ jsx(StyledTh, {
|
|
166
|
+
children: /*#__PURE__*/ jsx(Typography, {
|
|
167
|
+
textColor: "neutral600",
|
|
168
|
+
variant: "sigma",
|
|
169
|
+
children: tableHeaderLabel
|
|
170
|
+
})
|
|
171
|
+
}, header.name);
|
|
172
|
+
})
|
|
173
|
+
})
|
|
174
|
+
}),
|
|
175
|
+
/*#__PURE__*/ jsx(RawTbody, {
|
|
176
|
+
children: assets.length === 0 ? /*#__PURE__*/ jsx(RawTr, {
|
|
177
|
+
children: /*#__PURE__*/ jsx(StyledBodyTd, {
|
|
178
|
+
colSpan: visibleHeaders.length,
|
|
179
|
+
children: /*#__PURE__*/ jsx(Typography, {
|
|
180
|
+
textColor: "neutral600",
|
|
181
|
+
children: formatMessage({
|
|
182
|
+
id: 'app.components.EmptyStateLayout.content-document',
|
|
183
|
+
defaultMessage: 'No content found'
|
|
184
|
+
})
|
|
185
|
+
})
|
|
186
|
+
})
|
|
187
|
+
}) : assets.map((asset)=>/*#__PURE__*/ jsx(AssetRow, {
|
|
188
|
+
asset: asset
|
|
189
|
+
}, asset.id))
|
|
190
|
+
})
|
|
191
|
+
]
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
export { AssetsTable };
|
|
196
|
+
//# sourceMappingURL=AssetsTable.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AssetsTable.mjs","sources":["../../../../../../admin/src/future/pages/Assets/components/AssetsTable.tsx"],"sourcesContent":["import { useIsMobile } from '@strapi/admin/strapi-admin';\nimport {\n Flex,\n IconButton,\n RawTable,\n RawTbody,\n RawTd,\n RawTh,\n RawThead,\n RawTr,\n Typography,\n VisuallyHidden,\n} from '@strapi/design-system';\nimport { More } from '@strapi/icons';\nimport { useIntl } from 'react-intl';\nimport { styled } from 'styled-components';\n\nimport { formatBytes } from '../../../utils/files';\nimport { getAssetIcon } from '../../../utils/getAssetIcon';\nimport { getTranslationKey } from '../../../utils/translations';\nimport { TABLE_HEADERS } from '../constants';\n\nimport type { File } from '../../../../../../shared/contracts/files';\n\nconst StyledTable = styled(RawTable)`\n width: 100%;\n border-collapse: separate;\n border-spacing: 0;\n border: 1px solid ${({ theme }) => theme.colors.neutral150};\n border-radius: 4px;\n overflow: hidden;\n`;\n\nconst StyledThead = styled(RawThead)`\n background: ${({ theme }) => theme.colors.neutral100};\n\n tr {\n border-bottom: 1px solid ${({ theme }) => theme.colors.neutral150};\n }\n`;\n\nconst StyledTh = styled(RawTh)`\n height: 40px;\n padding: 0 ${({ theme }) => theme.spaces[4]};\n text-align: left;\n`;\n\nconst StyledTd = styled(RawTd)`\n padding: 0 ${({ theme }) => theme.spaces[4]};\n border-bottom: 1px solid ${({ theme }) => theme.colors.neutral150};\n`;\n\nconst StyledTr = styled(RawTr)`\n height: 48px;\n background: ${({ theme }) => theme.colors.neutral0};\n\n &:last-child {\n ${StyledTd} {\n border-bottom: 0;\n }\n }\n`;\n\nconst StyledBodyTd = styled(RawTd)`\n padding: ${({ theme }) => theme.spaces[4]};\n border-bottom: 1px solid ${({ theme }) => theme.colors.neutral150};\n`;\n\ninterface AssetPreviewCellProps {\n asset: File;\n}\n\nconst AssetPreviewCell = ({ asset }: AssetPreviewCellProps) => {\n const { ext, mime } = asset;\n\n const DocIcon = getAssetIcon(mime, ext);\n\n return (\n <Flex\n justifyContent=\"center\"\n alignItems=\"center\"\n borderRadius=\"4px\"\n color=\"neutral500\"\n width=\"3.2rem\"\n height=\"3.2rem\"\n shrink={0}\n >\n <DocIcon width={16} height={16} />\n </Flex>\n );\n};\n\ninterface AssetRowProps {\n asset: File;\n}\n\nconst AssetRow = ({ asset }: AssetRowProps) => {\n const isMobile = useIsMobile();\n const { formatDate, formatMessage } = useIntl();\n\n return (\n <StyledTr>\n <StyledTd>\n <Flex gap={3} alignItems=\"center\">\n <AssetPreviewCell asset={asset} />\n <Flex direction=\"column\" alignItems=\"flex-start\">\n <Typography textColor=\"neutral800\" fontWeight=\"semiBold\" ellipsis>\n {asset.name}\n </Typography>\n {isMobile && (\n <Typography textColor=\"neutral600\" variant=\"pi\">\n {asset.size ? formatBytes(asset.size, 1) : '-'}\n </Typography>\n )}\n </Flex>\n </Flex>\n </StyledTd>\n {!isMobile && (\n <>\n <StyledTd>\n <Typography textColor=\"neutral600\">\n {asset.createdAt ? formatDate(new Date(asset.createdAt), { dateStyle: 'long' }) : '-'}\n </Typography>\n </StyledTd>\n <StyledTd>\n <Typography textColor=\"neutral600\">\n {asset.updatedAt ? formatDate(new Date(asset.updatedAt), { dateStyle: 'long' }) : '-'}\n </Typography>\n </StyledTd>\n <StyledTd>\n <Typography textColor=\"neutral600\">\n {asset.size ? formatBytes(asset.size, 1) : '-'}\n </Typography>\n </StyledTd>\n </>\n )}\n <StyledTd>\n <Flex justifyContent=\"flex-end\">\n <IconButton\n label={formatMessage({\n id: getTranslationKey('control-card.more-actions'),\n defaultMessage: 'More actions',\n })}\n variant=\"ghost\"\n >\n <More />\n </IconButton>\n </Flex>\n </StyledTd>\n </StyledTr>\n );\n};\n\ninterface AssetsTableProps {\n assets: File[];\n}\n\nexport const AssetsTable = ({ assets }: AssetsTableProps) => {\n const isMobile = useIsMobile();\n const { formatMessage } = useIntl();\n\n const visibleHeaders = isMobile\n ? TABLE_HEADERS.filter((h) => h.name === 'name' || h.name === 'actions')\n : TABLE_HEADERS;\n\n return (\n <StyledTable colCount={visibleHeaders.length} rowCount={assets.length + 1}>\n <StyledThead>\n <RawTr>\n {visibleHeaders.map((header) => {\n const tableHeaderLabel = formatMessage(header.label);\n const isVisuallyHidden = 'isVisuallyHidden' in header && header.isVisuallyHidden;\n\n if (isVisuallyHidden) {\n return (\n <StyledTh key={header.name}>\n <VisuallyHidden>\n {formatMessage({\n id: getTranslationKey('table.header.actions'),\n defaultMessage: 'actions',\n })}\n </VisuallyHidden>\n </StyledTh>\n );\n }\n\n return (\n <StyledTh key={header.name}>\n <Typography textColor=\"neutral600\" variant=\"sigma\">\n {tableHeaderLabel}\n </Typography>\n </StyledTh>\n );\n })}\n </RawTr>\n </StyledThead>\n <RawTbody>\n {assets.length === 0 ? (\n <RawTr>\n <StyledBodyTd colSpan={visibleHeaders.length}>\n <Typography textColor=\"neutral600\">\n {formatMessage({\n id: 'app.components.EmptyStateLayout.content-document',\n defaultMessage: 'No content found',\n })}\n </Typography>\n </StyledBodyTd>\n </RawTr>\n ) : (\n assets.map((asset) => <AssetRow key={asset.id} asset={asset} />)\n )}\n </RawTbody>\n </StyledTable>\n );\n};\n"],"names":["StyledTable","styled","RawTable","theme","colors","neutral150","StyledThead","RawThead","neutral100","StyledTh","RawTh","spaces","StyledTd","RawTd","StyledTr","RawTr","neutral0","StyledBodyTd","AssetPreviewCell","asset","ext","mime","DocIcon","getAssetIcon","_jsx","Flex","justifyContent","alignItems","borderRadius","color","width","height","shrink","AssetRow","isMobile","useIsMobile","formatDate","formatMessage","useIntl","_jsxs","gap","direction","Typography","textColor","fontWeight","ellipsis","name","variant","size","formatBytes","_Fragment","createdAt","Date","dateStyle","updatedAt","IconButton","label","id","getTranslationKey","defaultMessage","More","AssetsTable","assets","visibleHeaders","TABLE_HEADERS","filter","h","colCount","length","rowCount","map","header","tableHeaderLabel","isVisuallyHidden","VisuallyHidden","RawTbody","colSpan"],"mappings":";;;;;;;;;;;AAwBA,MAAMA,WAAAA,GAAcC,MAAOC,CAAAA,QAAAA,CAAS;;;;oBAIhB,EAAE,CAAC,EAAEC,KAAK,EAAE,GAAKA,KAAMC,CAAAA,MAAM,CAACC,UAAU,CAAC;;;AAG7D,CAAC;AAED,MAAMC,WAAAA,GAAcL,MAAOM,CAAAA,QAAAA,CAAS;cACtB,EAAE,CAAC,EAAEJ,KAAK,EAAE,GAAKA,KAAMC,CAAAA,MAAM,CAACI,UAAU,CAAC;;;6BAG1B,EAAE,CAAC,EAAEL,KAAK,EAAE,GAAKA,KAAMC,CAAAA,MAAM,CAACC,UAAU,CAAC;;AAEtE,CAAC;AAED,MAAMI,QAAAA,GAAWR,MAAOS,CAAAA,KAAAA,CAAM;;aAEjB,EAAE,CAAC,EAAEP,KAAK,EAAE,GAAKA,KAAMQ,CAAAA,MAAM,CAAC,CAAA,CAAE,CAAC;;AAE9C,CAAC;AAED,MAAMC,QAAAA,GAAWX,MAAOY,CAAAA,KAAAA,CAAM;aACjB,EAAE,CAAC,EAAEV,KAAK,EAAE,GAAKA,KAAMQ,CAAAA,MAAM,CAAC,CAAA,CAAE,CAAC;2BACnB,EAAE,CAAC,EAAER,KAAK,EAAE,GAAKA,KAAMC,CAAAA,MAAM,CAACC,UAAU,CAAC;AAC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AAc,CAAA;gCACboB,EAAI,EAAA,kDAAA;gCACJE,cAAgB,EAAA;AAClB,6BAAA;;;AAKNG,iBAAAA,CAAAA,GAAAA,MAAAA,CAAOQ,GAAG,CAAC,CAACnD,KAAAA,iBAAUK,GAACS,CAAAA,QAAAA,EAAAA;wBAAwBd,KAAOA,EAAAA;AAAjBA,qBAAAA,EAAAA,KAAAA,CAAMsC,EAAE,CAAA;;;;AAKvD;;;;"}
|
|
@@ -0,0 +1,127 @@
|
|
|
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 icons = require('@strapi/icons');
|
|
7
|
+
var reactIntl = require('react-intl');
|
|
8
|
+
var styledComponents = require('styled-components');
|
|
9
|
+
var translations = require('../../../../utils/translations.js');
|
|
10
|
+
var UploadDropZoneContext = require('./UploadDropZoneContext.js');
|
|
11
|
+
|
|
12
|
+
function _interopNamespaceDefault(e) {
|
|
13
|
+
var n = Object.create(null);
|
|
14
|
+
if (e) {
|
|
15
|
+
Object.keys(e).forEach(function (k) {
|
|
16
|
+
if (k !== 'default') {
|
|
17
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
18
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () { return e[k]; }
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
n.default = e;
|
|
26
|
+
return Object.freeze(n);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
30
|
+
|
|
31
|
+
/* -------------------------------------------------------------------------------------------------
|
|
32
|
+
* DropZoneOverlay
|
|
33
|
+
* -----------------------------------------------------------------------------------------------*/ const setOpacity = (hex, alpha)=>`${hex}${Math.floor(alpha * 255).toString(16).padStart(2, '0')}`;
|
|
34
|
+
const DropZoneOverlay = styledComponents.styled(designSystem.Box)`
|
|
35
|
+
position: absolute;
|
|
36
|
+
top: 0;
|
|
37
|
+
left: 0;
|
|
38
|
+
right: 0;
|
|
39
|
+
bottom: 0;
|
|
40
|
+
background: ${({ theme })=>setOpacity(theme.colors.primary200, 0.3)};
|
|
41
|
+
border: 1px solid ${({ theme })=>theme.colors.primary700};
|
|
42
|
+
border-radius: ${({ theme })=>theme.borderRadius};
|
|
43
|
+
z-index: 1;
|
|
44
|
+
pointer-events: none;
|
|
45
|
+
`;
|
|
46
|
+
const DropZoneWithOverlay = ({ children })=>{
|
|
47
|
+
const { isDragging } = UploadDropZoneContext.useUploadDropZone();
|
|
48
|
+
return /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Box, {
|
|
49
|
+
position: "relative",
|
|
50
|
+
children: [
|
|
51
|
+
isDragging && /*#__PURE__*/ jsxRuntime.jsx(DropZoneOverlay, {}),
|
|
52
|
+
children
|
|
53
|
+
]
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
/* -------------------------------------------------------------------------------------------------
|
|
57
|
+
* DropZoneMessage
|
|
58
|
+
* -----------------------------------------------------------------------------------------------*/ const DropFilesMessageImpl = styledComponents.styled(designSystem.Box)`
|
|
59
|
+
position: fixed;
|
|
60
|
+
bottom: ${({ theme })=>theme.spaces[8]};
|
|
61
|
+
left: 50%;
|
|
62
|
+
transform: translateX(calc(-50% + ${({ $leftContentWidth })=>$leftContentWidth / 2}px));
|
|
63
|
+
display: flex;
|
|
64
|
+
flex-direction: column;
|
|
65
|
+
align-items: center;
|
|
66
|
+
justify-content: center;
|
|
67
|
+
gap: ${({ theme })=>theme.spaces[2]};
|
|
68
|
+
background: ${({ theme })=>theme.colors.primary600};
|
|
69
|
+
padding: ${({ theme })=>theme.spaces[4]} ${({ theme })=>theme.spaces[6]};
|
|
70
|
+
border-radius: ${({ theme })=>theme.borderRadius};
|
|
71
|
+
z-index: 2;
|
|
72
|
+
`;
|
|
73
|
+
const DropFilesMessage = ({ uploadDropZoneRef })=>{
|
|
74
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
75
|
+
const { isDragging } = UploadDropZoneContext.useUploadDropZone();
|
|
76
|
+
// Dropzone message position (relative to main content)
|
|
77
|
+
const [leftContentWidth, setLeftContentWidth] = React__namespace.useState(0);
|
|
78
|
+
// Calculate the left content width to position the dropzone message correctly
|
|
79
|
+
React__namespace.useEffect(()=>{
|
|
80
|
+
if (!uploadDropZoneRef?.current) return;
|
|
81
|
+
const updateRect = ()=>{
|
|
82
|
+
const rect = uploadDropZoneRef.current?.getBoundingClientRect();
|
|
83
|
+
if (rect) {
|
|
84
|
+
setLeftContentWidth((prev)=>prev !== rect.left ? rect.left : prev);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
updateRect();
|
|
88
|
+
const resizeObserver = new ResizeObserver(updateRect);
|
|
89
|
+
resizeObserver.observe(uploadDropZoneRef.current);
|
|
90
|
+
return ()=>resizeObserver.disconnect();
|
|
91
|
+
}, [
|
|
92
|
+
uploadDropZoneRef
|
|
93
|
+
]);
|
|
94
|
+
if (!isDragging) return null;
|
|
95
|
+
return /*#__PURE__*/ jsxRuntime.jsxs(DropFilesMessageImpl, {
|
|
96
|
+
$leftContentWidth: leftContentWidth,
|
|
97
|
+
children: [
|
|
98
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
|
|
99
|
+
textColor: "neutral0",
|
|
100
|
+
children: formatMessage({
|
|
101
|
+
id: translations.getTranslationKey('dropzone.upload.message'),
|
|
102
|
+
defaultMessage: 'Drop here to upload to'
|
|
103
|
+
})
|
|
104
|
+
}),
|
|
105
|
+
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
|
|
106
|
+
gap: 2,
|
|
107
|
+
alignItems: "center",
|
|
108
|
+
children: [
|
|
109
|
+
/*#__PURE__*/ jsxRuntime.jsx(icons.Folder, {
|
|
110
|
+
width: 20,
|
|
111
|
+
height: 20,
|
|
112
|
+
fill: "neutral0"
|
|
113
|
+
}),
|
|
114
|
+
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
|
|
115
|
+
textColor: "neutral0",
|
|
116
|
+
fontWeight: "semiBold",
|
|
117
|
+
children: "Current folder"
|
|
118
|
+
})
|
|
119
|
+
]
|
|
120
|
+
})
|
|
121
|
+
]
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
exports.DropFilesMessage = DropFilesMessage;
|
|
126
|
+
exports.DropZoneWithOverlay = DropZoneWithOverlay;
|
|
127
|
+
//# sourceMappingURL=UploadDropZone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UploadDropZone.js","sources":["../../../../../../../admin/src/future/pages/Assets/components/DropZone/UploadDropZone.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Box, Flex, Typography } from '@strapi/design-system';\nimport { Folder } from '@strapi/icons';\nimport { useIntl } from 'react-intl';\nimport { styled } from 'styled-components';\n\nimport { getTranslationKey } from '../../../../utils/translations';\n\nimport { useUploadDropZone } from './UploadDropZoneContext';\n\n/* -------------------------------------------------------------------------------------------------\n * DropZoneOverlay\n * -----------------------------------------------------------------------------------------------*/\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\n/* -------------------------------------------------------------------------------------------------\n * DropZoneMessage\n * -----------------------------------------------------------------------------------------------*/\n\nconst DropFilesMessageImpl = styled(Box)<{ $leftContentWidth: number }>`\n position: fixed;\n bottom: ${({ theme }) => theme.spaces[8]};\n left: 50%;\n transform: translateX(calc(-50% + ${({ $leftContentWidth }) => $leftContentWidth / 2}px));\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: ${({ theme }) => theme.spaces[2]};\n background: ${({ theme }) => theme.colors.primary600};\n padding: ${({ theme }) => theme.spaces[4]} ${({ theme }) => theme.spaces[6]};\n border-radius: ${({ theme }) => theme.borderRadius};\n z-index: 2;\n`;\n\ninterface DropFilesMessageProps {\n uploadDropZoneRef?: React.RefObject<HTMLDivElement>;\n}\n\nconst DropFilesMessage = ({ uploadDropZoneRef }: DropFilesMessageProps) => {\n const { formatMessage } = useIntl();\n const { isDragging } = useUploadDropZone();\n\n // Dropzone message position (relative to main content)\n const [leftContentWidth, setLeftContentWidth] = React.useState(0);\n\n // Calculate the left content width to position the dropzone message correctly\n React.useEffect(() => {\n if (!uploadDropZoneRef?.current) return;\n\n const updateRect = () => {\n const rect = uploadDropZoneRef.current?.getBoundingClientRect();\n if (rect) {\n setLeftContentWidth((prev) => (prev !== rect.left ? rect.left : prev));\n }\n };\n\n updateRect();\n const resizeObserver = new ResizeObserver(updateRect);\n resizeObserver.observe(uploadDropZoneRef.current);\n return () => resizeObserver.disconnect();\n }, [uploadDropZoneRef]);\n\n if (!isDragging) return null;\n\n return (\n <DropFilesMessageImpl $leftContentWidth={leftContentWidth}>\n <Typography textColor=\"neutral0\">\n {formatMessage({\n id: getTranslationKey('dropzone.upload.message'),\n defaultMessage: 'Drop here to upload to',\n })}\n </Typography>\n <Flex gap={2} alignItems=\"center\">\n <Folder width={20} height={20} fill=\"neutral0\" />\n <Typography textColor=\"neutral0\" fontWeight=\"semiBold\">\n Current folder{/* TODO: Replace this later with the current folder name */}\n </Typography>\n </Flex>\n </DropFilesMessageImpl>\n );\n};\n\nexport { DropZoneWithOverlay, DropFilesMessage };\n"],"names":["setOpacity","hex","alpha","Math","floor","toString","padStart","DropZoneOverlay","styled","Box","theme","colors","primary200","primary700","borderRadius","DropZoneWithOverlay","children","isDragging","useUploadDropZone","_jsxs","position","_jsx","DropFilesMessageImpl","spaces","$leftContentWidth","primary600","DropFilesMessage","uploadDropZoneRef","formatMessage","useIntl","leftContentWidth","setLeftContentWidth","React","useState","useEffect","current","updateRect","rect","getBoundingClientRect","prev","left","resizeObserver","ResizeObserver","observe","disconnect","Typography","textColor","id","getTranslationKey","defaultMessage","Flex","gap","alignItems","Folder","width","height","fill","fontWeight"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA;;AAEkG,qGAElG,MAAMA,UAAa,GAAA,CAACC,KAAaC,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;AACf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,mBAAoB,CAAA,CAACQ,OAAUA,IAASF,KAAAA,IAAAA,CAAKG,IAAI,GAAGH,IAAAA,CAAKG,IAAI,GAAGD,IAAAA,CAAAA;AAClE;AACF,SAAA;AAEAH,QAAAA,UAAAA,EAAAA;QACA,MAAMK,cAAAA,GAAiB,IAAIC,cAAeN,CAAAA,UAAAA,CAAAA;QAC1CK,cAAeE,CAAAA,OAAO,CAAChB,iBAAAA,CAAkBQ,OAAO,CAAA;QAChD,OAAO,IAAMM,eAAeG,UAAU,EAAA;KACrC,EAAA;AAACjB,QAAAA;AAAkB,KAAA,CAAA;IAEtB,IAAI,CAACV,YAAY,OAAO,IAAA;AAExB,IAAA,qBACEE,eAACG,CAAAA,oBAAAA,EAAAA;QAAqBE,iBAAmBM,EAAAA,gBAAAA;;0BACvCT,cAACwB,CAAAA,uBAAAA,EAAAA;gBAAWC,SAAU,EAAA,UAAA;0BACnBlB,aAAc,CAAA;AACbmB,oBAAAA,EAAAA,EAAIC,8BAAkB,CAAA,yBAAA,CAAA;oBACtBC,cAAgB,EAAA;AAClB,iBAAA;;0BAEF9B,eAAC+B,CAAAA,iBAAAA,EAAAA;gBAAKC,GAAK,EAAA,CAAA;gBAAGC,UAAW,EAAA,QAAA;;kCACvB/B,cAACgC,CAAAA,YAAAA,EAAAA;wBAAOC,KAAO,EAAA,EAAA;wBAAIC,MAAQ,EAAA,EAAA;wBAAIC,IAAK,EAAA;;kCACpCnC,cAACwB,CAAAA,uBAAAA,EAAAA;wBAAWC,SAAU,EAAA,UAAA;wBAAWW,UAAW,EAAA,UAAA;AAAW,wBAAA,QAAA,EAAA;;;;;;AAM/D;;;;;"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Box, Typography, Flex } from '@strapi/design-system';
|
|
4
|
+
import { Folder } from '@strapi/icons';
|
|
5
|
+
import { useIntl } from 'react-intl';
|
|
6
|
+
import { styled } from 'styled-components';
|
|
7
|
+
import { getTranslationKey } from '../../../../utils/translations.mjs';
|
|
8
|
+
import { useUploadDropZone } from './UploadDropZoneContext.mjs';
|
|
9
|
+
|
|
10
|
+
/* -------------------------------------------------------------------------------------------------
|
|
11
|
+
* DropZoneOverlay
|
|
12
|
+
* -----------------------------------------------------------------------------------------------*/ const setOpacity = (hex, alpha)=>`${hex}${Math.floor(alpha * 255).toString(16).padStart(2, '0')}`;
|
|
13
|
+
const DropZoneOverlay = styled(Box)`
|
|
14
|
+
position: absolute;
|
|
15
|
+
top: 0;
|
|
16
|
+
left: 0;
|
|
17
|
+
right: 0;
|
|
18
|
+
bottom: 0;
|
|
19
|
+
background: ${({ theme })=>setOpacity(theme.colors.primary200, 0.3)};
|
|
20
|
+
border: 1px solid ${({ theme })=>theme.colors.primary700};
|
|
21
|
+
border-radius: ${({ theme })=>theme.borderRadius};
|
|
22
|
+
z-index: 1;
|
|
23
|
+
pointer-events: none;
|
|
24
|
+
`;
|
|
25
|
+
const DropZoneWithOverlay = ({ children })=>{
|
|
26
|
+
const { isDragging } = useUploadDropZone();
|
|
27
|
+
return /*#__PURE__*/ jsxs(Box, {
|
|
28
|
+
position: "relative",
|
|
29
|
+
children: [
|
|
30
|
+
isDragging && /*#__PURE__*/ jsx(DropZoneOverlay, {}),
|
|
31
|
+
children
|
|
32
|
+
]
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
/* -------------------------------------------------------------------------------------------------
|
|
36
|
+
* DropZoneMessage
|
|
37
|
+
* -----------------------------------------------------------------------------------------------*/ const DropFilesMessageImpl = styled(Box)`
|
|
38
|
+
position: fixed;
|
|
39
|
+
bottom: ${({ theme })=>theme.spaces[8]};
|
|
40
|
+
left: 50%;
|
|
41
|
+
transform: translateX(calc(-50% + ${({ $leftContentWidth })=>$leftContentWidth / 2}px));
|
|
42
|
+
display: flex;
|
|
43
|
+
flex-direction: column;
|
|
44
|
+
align-items: center;
|
|
45
|
+
justify-content: center;
|
|
46
|
+
gap: ${({ theme })=>theme.spaces[2]};
|
|
47
|
+
background: ${({ theme })=>theme.colors.primary600};
|
|
48
|
+
padding: ${({ theme })=>theme.spaces[4]} ${({ theme })=>theme.spaces[6]};
|
|
49
|
+
border-radius: ${({ theme })=>theme.borderRadius};
|
|
50
|
+
z-index: 2;
|
|
51
|
+
`;
|
|
52
|
+
const DropFilesMessage = ({ uploadDropZoneRef })=>{
|
|
53
|
+
const { formatMessage } = useIntl();
|
|
54
|
+
const { isDragging } = useUploadDropZone();
|
|
55
|
+
// Dropzone message position (relative to main content)
|
|
56
|
+
const [leftContentWidth, setLeftContentWidth] = React.useState(0);
|
|
57
|
+
// Calculate the left content width to position the dropzone message correctly
|
|
58
|
+
React.useEffect(()=>{
|
|
59
|
+
if (!uploadDropZoneRef?.current) return;
|
|
60
|
+
const updateRect = ()=>{
|
|
61
|
+
const rect = uploadDropZoneRef.current?.getBoundingClientRect();
|
|
62
|
+
if (rect) {
|
|
63
|
+
setLeftContentWidth((prev)=>prev !== rect.left ? rect.left : prev);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
updateRect();
|
|
67
|
+
const resizeObserver = new ResizeObserver(updateRect);
|
|
68
|
+
resizeObserver.observe(uploadDropZoneRef.current);
|
|
69
|
+
return ()=>resizeObserver.disconnect();
|
|
70
|
+
}, [
|
|
71
|
+
uploadDropZoneRef
|
|
72
|
+
]);
|
|
73
|
+
if (!isDragging) return null;
|
|
74
|
+
return /*#__PURE__*/ jsxs(DropFilesMessageImpl, {
|
|
75
|
+
$leftContentWidth: leftContentWidth,
|
|
76
|
+
children: [
|
|
77
|
+
/*#__PURE__*/ jsx(Typography, {
|
|
78
|
+
textColor: "neutral0",
|
|
79
|
+
children: formatMessage({
|
|
80
|
+
id: getTranslationKey('dropzone.upload.message'),
|
|
81
|
+
defaultMessage: 'Drop here to upload to'
|
|
82
|
+
})
|
|
83
|
+
}),
|
|
84
|
+
/*#__PURE__*/ jsxs(Flex, {
|
|
85
|
+
gap: 2,
|
|
86
|
+
alignItems: "center",
|
|
87
|
+
children: [
|
|
88
|
+
/*#__PURE__*/ jsx(Folder, {
|
|
89
|
+
width: 20,
|
|
90
|
+
height: 20,
|
|
91
|
+
fill: "neutral0"
|
|
92
|
+
}),
|
|
93
|
+
/*#__PURE__*/ jsx(Typography, {
|
|
94
|
+
textColor: "neutral0",
|
|
95
|
+
fontWeight: "semiBold",
|
|
96
|
+
children: "Current folder"
|
|
97
|
+
})
|
|
98
|
+
]
|
|
99
|
+
})
|
|
100
|
+
]
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export { DropFilesMessage, DropZoneWithOverlay };
|
|
105
|
+
//# sourceMappingURL=UploadDropZone.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UploadDropZone.mjs","sources":["../../../../../../../admin/src/future/pages/Assets/components/DropZone/UploadDropZone.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Box, Flex, Typography } from '@strapi/design-system';\nimport { Folder } from '@strapi/icons';\nimport { useIntl } from 'react-intl';\nimport { styled } from 'styled-components';\n\nimport { getTranslationKey } from '../../../../utils/translations';\n\nimport { useUploadDropZone } from './UploadDropZoneContext';\n\n/* -------------------------------------------------------------------------------------------------\n * DropZoneOverlay\n * -----------------------------------------------------------------------------------------------*/\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\n/* -------------------------------------------------------------------------------------------------\n * DropZoneMessage\n * -----------------------------------------------------------------------------------------------*/\n\nconst DropFilesMessageImpl = styled(Box)<{ $leftContentWidth: number }>`\n position: fixed;\n bottom: ${({ theme }) => theme.spaces[8]};\n left: 50%;\n transform: translateX(calc(-50% + ${({ $leftContentWidth }) => $leftContentWidth / 2}px));\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: ${({ theme }) => theme.spaces[2]};\n background: ${({ theme }) => theme.colors.primary600};\n padding: ${({ theme }) => theme.spaces[4]} ${({ theme }) => theme.spaces[6]};\n border-radius: ${({ theme }) => theme.borderRadius};\n z-index: 2;\n`;\n\ninterface DropFilesMessageProps {\n uploadDropZoneRef?: React.RefObject<HTMLDivElement>;\n}\n\nconst DropFilesMessage = ({ uploadDropZoneRef }: DropFilesMessageProps) => {\n const { formatMessage } = useIntl();\n const { isDragging } = useUploadDropZone();\n\n // Dropzone message position (relative to main content)\n const [leftContentWidth, setLeftContentWidth] = React.useState(0);\n\n // Calculate the left content width to position the dropzone message correctly\n React.useEffect(() => {\n if (!uploadDropZoneRef?.current) return;\n\n const updateRect = () => {\n const rect = uploadDropZoneRef.current?.getBoundingClientRect();\n if (rect) {\n setLeftContentWidth((prev) => (prev !== rect.left ? rect.left : prev));\n }\n };\n\n updateRect();\n const resizeObserver = new ResizeObserver(updateRect);\n resizeObserver.observe(uploadDropZoneRef.current);\n return () => resizeObserver.disconnect();\n }, [uploadDropZoneRef]);\n\n if (!isDragging) return null;\n\n return (\n <DropFilesMessageImpl $leftContentWidth={leftContentWidth}>\n <Typography textColor=\"neutral0\">\n {formatMessage({\n id: getTranslationKey('dropzone.upload.message'),\n defaultMessage: 'Drop here to upload to',\n })}\n </Typography>\n <Flex gap={2} alignItems=\"center\">\n <Folder width={20} height={20} fill=\"neutral0\" />\n <Typography textColor=\"neutral0\" fontWeight=\"semiBold\">\n Current folder{/* TODO: Replace this later with the current folder name */}\n </Typography>\n </Flex>\n </DropFilesMessageImpl>\n );\n};\n\nexport { DropZoneWithOverlay, DropFilesMessage };\n"],"names":["setOpacity","hex","alpha","Math","floor","toString","padStart","DropZoneOverlay","styled","Box","theme","colors","primary200","primary700","borderRadius","DropZoneWithOverlay","children","isDragging","useUploadDropZone","_jsxs","position","_jsx","DropFilesMessageImpl","spaces","$leftContentWidth","primary600","DropFilesMessage","uploadDropZoneRef","formatMessage","useIntl","leftContentWidth","setLeftContentWidth","React","useState","useEffect","current","updateRect","rect","getBoundingClientRect","prev","left","resizeObserver","ResizeObserver","observe","disconnect","Typography","textColor","id","getTranslationKey","defaultMessage","Flex","gap","alignItems","Folder","width","height","fill","fontWeight"],"mappings":";;;;;;;;;AAWA;;AAEkG,qGAElG,MAAMA,UAAa,GAAA,CAACC,KAAaC,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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AAA;AACxC,YAAA,IAAID,IAAM,EAAA;gBACRN,mBAAoB,CAAA,CAACQ,OAAUA,IAASF,KAAAA,IAAAA,CAAKG,IAAI,GAAGH,IAAAA,CAAKG,IAAI,GAAGD,IAAAA,CAAAA;AAClE;AACF,SAAA;AAEAH,QAAAA,UAAAA,EAAAA;QACA,MAAMK,cAAAA,GAAiB,IAAIC,cAAeN,CAAAA,UAAAA,CAAAA;QAC1CK,cAAeE,CAAAA,OAAO,CAAChB,iBAAAA,CAAkBQ,OAAO,CAAA;QAChD,OAAO,IAAMM,eAAeG,UAAU,EAAA;KACrC,EAAA;AAACjB,QAAAA;AAAkB,KAAA,CAAA;IAEtB,IAAI,CAACV,YAAY,OAAO,IAAA;AAExB,IAAA,qBACEE,IAACG,CAAAA,oBAAAA,EAAAA;QAAqBE,iBAAmBM,EAAAA,gBAAAA;;0BACvCT,GAACwB,CAAAA,UAAAA,EAAAA;gBAAWC,SAAU,EAAA,UAAA;0BACnBlB,aAAc,CAAA;AACbmB,oBAAAA,EAAAA,EAAIC,iBAAkB,CAAA,yBAAA,CAAA;oBACtBC,cAAgB,EAAA;AAClB,iBAAA;;0BAEF9B,IAAC+B,CAAAA,IAAAA,EAAAA;gBAAKC,GAAK,EAAA,CAAA;gBAAGC,UAAW,EAAA,QAAA;;kCACvB/B,GAACgC,CAAAA,MAAAA,EAAAA;wBAAOC,KAAO,EAAA,EAAA;wBAAIC,MAAQ,EAAA,EAAA;wBAAIC,IAAK,EAAA;;kCACpCnC,GAACwB,CAAAA,UAAAA,EAAAA;wBAAWC,SAAU,EAAA,UAAA;wBAAWW,UAAW,EAAA,UAAA;AAAW,wBAAA,QAAA,EAAA;;;;;;AAM/D;;;;"}
|
|
@@ -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,CAAAA,aAAa,EAAE;gBACpBV,aAAc,CAAA,KAAA,CAAA;AACdE,gBAAAA,cAAAA,CAAeK,OAAO,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