@blaze-cms/plugin-media-ui 0.146.0-node18-core-styles-tooltips.45 → 0.146.0-node18-tooltips.38
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/CHANGELOG.md +21 -66
- package/lib/components/EditMediaFile/EditMediaFile.js +2 -2
- package/lib/components/EditMediaFile/EditMediaFile.js.map +1 -1
- package/lib/components/EditorAdapter/EditorAdapter.js +12 -1
- package/lib/components/EditorAdapter/EditorAdapter.js.map +1 -1
- package/lib-es/components/CardMedia/CardMedia.js +233 -0
- package/lib-es/components/CardMedia/CardMedia.js.map +1 -0
- package/lib-es/components/CardMedia/index.js +3 -0
- package/lib-es/components/CardMedia/index.js.map +1 -0
- package/lib-es/components/EditMediaFile/EditMediaFile.js +187 -0
- package/lib-es/components/EditMediaFile/EditMediaFile.js.map +1 -0
- package/lib-es/components/EditMediaFile/EditMediaFilePage.js +109 -0
- package/lib-es/components/EditMediaFile/EditMediaFilePage.js.map +1 -0
- package/lib-es/components/EditMediaFile/index.js +3 -0
- package/lib-es/components/EditMediaFile/index.js.map +1 -0
- package/lib-es/components/EditorAdapter/EditorAdapter.js +59 -0
- package/lib-es/components/EditorAdapter/EditorAdapter.js.map +1 -0
- package/lib-es/components/EditorAdapter/index.js +3 -0
- package/lib-es/components/EditorAdapter/index.js.map +1 -0
- package/lib-es/components/FileList/FilesListContext/index.js +4 -0
- package/lib-es/components/FileList/FilesListContext/index.js.map +1 -0
- package/lib-es/components/FileList/FilesListProvider/index.js +36 -0
- package/lib-es/components/FileList/FilesListProvider/index.js.map +1 -0
- package/lib-es/components/FileList/useFileList/index.js +5 -0
- package/lib-es/components/FileList/useFileList/index.js.map +1 -0
- package/lib-es/components/FileList/useGetFiles/getFiles.js +179 -0
- package/lib-es/components/FileList/useGetFiles/getFiles.js.map +1 -0
- package/lib-es/components/FileList/useGetFiles/index.js +3 -0
- package/lib-es/components/FileList/useGetFiles/index.js.map +1 -0
- package/lib-es/components/FileList/useGetFiles/useGetFiles.js +114 -0
- package/lib-es/components/FileList/useGetFiles/useGetFiles.js.map +1 -0
- package/lib-es/components/FileList/useGetFilesList/getCounters.js +11 -0
- package/lib-es/components/FileList/useGetFilesList/getCounters.js.map +1 -0
- package/lib-es/components/FileList/useGetFilesList/index.js +3 -0
- package/lib-es/components/FileList/useGetFilesList/index.js.map +1 -0
- package/lib-es/components/FileList/useGetFilesList/useGetFilesList.js +172 -0
- package/lib-es/components/FileList/useGetFilesList/useGetFilesList.js.map +1 -0
- package/lib-es/components/FilePreview/Actions/index.js +38 -0
- package/lib-es/components/FilePreview/Actions/index.js.map +1 -0
- package/lib-es/components/FilePreview/Image/Image.js +40 -0
- package/lib-es/components/FilePreview/Image/Image.js.map +1 -0
- package/lib-es/components/FilePreview/Image/RawImage.js +31 -0
- package/lib-es/components/FilePreview/Image/RawImage.js.map +1 -0
- package/lib-es/components/FilePreview/Image/imageSchema.js +53 -0
- package/lib-es/components/FilePreview/Image/imageSchema.js.map +1 -0
- package/lib-es/components/FilePreview/Image/index.js +12 -0
- package/lib-es/components/FilePreview/Image/index.js.map +1 -0
- package/lib-es/components/FilePreview/ModalContext.js +3 -0
- package/lib-es/components/FilePreview/ModalContext.js.map +1 -0
- package/lib-es/components/FilePreview/PDF/PDF.js +49 -0
- package/lib-es/components/FilePreview/PDF/PDF.js.map +1 -0
- package/lib-es/components/FilePreview/PDF/RawPDF.js +33 -0
- package/lib-es/components/FilePreview/PDF/RawPDF.js.map +1 -0
- package/lib-es/components/FilePreview/PDF/index.js +12 -0
- package/lib-es/components/FilePreview/PDF/index.js.map +1 -0
- package/lib-es/components/FilePreview/PDF/schema.js +21 -0
- package/lib-es/components/FilePreview/PDF/schema.js.map +1 -0
- package/lib-es/components/FilePreview/get-preview.js +28 -0
- package/lib-es/components/FilePreview/get-preview.js.map +1 -0
- package/lib-es/components/FilePreview/index.js +104 -0
- package/lib-es/components/FilePreview/index.js.map +1 -0
- package/lib-es/components/FilePreview/previewDefault/PreviewDefault.js +41 -0
- package/lib-es/components/FilePreview/previewDefault/PreviewDefault.js.map +1 -0
- package/lib-es/components/FilePreview/previewDefault/RawPreviewDefault.js +39 -0
- package/lib-es/components/FilePreview/previewDefault/RawPreviewDefault.js.map +1 -0
- package/lib-es/components/FilePreview/previewDefault/icons/DefaultIcon.js +121 -0
- package/lib-es/components/FilePreview/previewDefault/icons/DefaultIcon.js.map +1 -0
- package/lib-es/components/FilePreview/previewDefault/icons/index.js +3 -0
- package/lib-es/components/FilePreview/previewDefault/icons/index.js.map +1 -0
- package/lib-es/components/FilePreview/previewDefault/index.js +12 -0
- package/lib-es/components/FilePreview/previewDefault/index.js.map +1 -0
- package/lib-es/components/FilePreview/previewDefault/previewDefaultSchema.js +25 -0
- package/lib-es/components/FilePreview/previewDefault/previewDefaultSchema.js.map +1 -0
- package/lib-es/components/FilePreviewReadOnly/FileList.js +18 -0
- package/lib-es/components/FilePreviewReadOnly/FileList.js.map +1 -0
- package/lib-es/components/FilePreviewReadOnly/FilePreviewList.js +22 -0
- package/lib-es/components/FilePreviewReadOnly/FilePreviewList.js.map +1 -0
- package/lib-es/components/FilePreviewReadOnly/FilePreviewReadOnly.js +68 -0
- package/lib-es/components/FilePreviewReadOnly/FilePreviewReadOnly.js.map +1 -0
- package/lib-es/components/FilePreviewReadOnly/index.js +3 -0
- package/lib-es/components/FilePreviewReadOnly/index.js.map +1 -0
- package/lib-es/components/FilePreviewReadOnly/mappers/format-initial-value.js +11 -0
- package/lib-es/components/FilePreviewReadOnly/mappers/format-initial-value.js.map +1 -0
- package/lib-es/components/FilePreviewReadOnly/mappers/index.js +3 -0
- package/lib-es/components/FilePreviewReadOnly/mappers/index.js.map +1 -0
- package/lib-es/components/FileUploadAdapter/FileList.js +52 -0
- package/lib-es/components/FileUploadAdapter/FileList.js.map +1 -0
- package/lib-es/components/FileUploadAdapter/FilePreviewList.js +22 -0
- package/lib-es/components/FileUploadAdapter/FilePreviewList.js.map +1 -0
- package/lib-es/components/FileUploadAdapter/FileReorderList.js +32 -0
- package/lib-es/components/FileUploadAdapter/FileReorderList.js.map +1 -0
- package/lib-es/components/FileUploadAdapter/FileReorderListItem.js +24 -0
- package/lib-es/components/FileUploadAdapter/FileReorderListItem.js.map +1 -0
- package/lib-es/components/FileUploadAdapter/FileUploadAdapter.js +391 -0
- package/lib-es/components/FileUploadAdapter/FileUploadAdapter.js.map +1 -0
- package/lib-es/components/FileUploadAdapter/index.js +3 -0
- package/lib-es/components/FileUploadAdapter/index.js.map +1 -0
- package/lib-es/components/FileUploadAdapter/mappers/format-initial-value.js +11 -0
- package/lib-es/components/FileUploadAdapter/mappers/format-initial-value.js.map +1 -0
- package/lib-es/components/FileUploadAdapter/mappers/get-button-text.js +11 -0
- package/lib-es/components/FileUploadAdapter/mappers/get-button-text.js.map +1 -0
- package/lib-es/components/FileUploadAdapter/mappers/get-format.js +12 -0
- package/lib-es/components/FileUploadAdapter/mappers/get-format.js.map +1 -0
- package/lib-es/components/FileUploadAdapter/mappers/get-number-files-pending-to-fetch.js +7 -0
- package/lib-es/components/FileUploadAdapter/mappers/get-number-files-pending-to-fetch.js.map +1 -0
- package/lib-es/components/FileUploadAdapter/mappers/index.js +8 -0
- package/lib-es/components/FileUploadAdapter/mappers/index.js.map +1 -0
- package/lib-es/components/FileUploadAdapter/mappers/is-unselecting.js +2 -0
- package/lib-es/components/FileUploadAdapter/mappers/is-unselecting.js.map +1 -0
- package/lib-es/components/FileUploadAdapter/mappers/transform-to-array.js +2 -0
- package/lib-es/components/FileUploadAdapter/mappers/transform-to-array.js.map +1 -0
- package/lib-es/components/FileUploadAdapter/useLimit.js +13 -0
- package/lib-es/components/FileUploadAdapter/useLimit.js.map +1 -0
- package/lib-es/components/FileUploadModal/FileUploadModal.js +178 -0
- package/lib-es/components/FileUploadModal/FileUploadModal.js.map +1 -0
- package/lib-es/components/FileUploadModal/index.js +3 -0
- package/lib-es/components/FileUploadModal/index.js.map +1 -0
- package/lib-es/components/FilterPanel/FilterPanel.js +135 -0
- package/lib-es/components/FilterPanel/FilterPanel.js.map +1 -0
- package/lib-es/components/FilterPanel/index.js +3 -0
- package/lib-es/components/FilterPanel/index.js.map +1 -0
- package/lib-es/components/ListingContainer/Listing/Listing.js +70 -0
- package/lib-es/components/ListingContainer/Listing/Listing.js.map +1 -0
- package/lib-es/components/ListingContainer/Listing/MediaListing/MediaFileList/MediaFileList.js +153 -0
- package/lib-es/components/ListingContainer/Listing/MediaListing/MediaFileList/MediaFileList.js.map +1 -0
- package/lib-es/components/ListingContainer/Listing/MediaListing/MediaFileList/index.js +3 -0
- package/lib-es/components/ListingContainer/Listing/MediaListing/MediaFileList/index.js.map +1 -0
- package/lib-es/components/ListingContainer/Listing/MediaListing/MediaListing.js +33 -0
- package/lib-es/components/ListingContainer/Listing/MediaListing/MediaListing.js.map +1 -0
- package/lib-es/components/ListingContainer/Listing/MediaListing/index.js +3 -0
- package/lib-es/components/ListingContainer/Listing/MediaListing/index.js.map +1 -0
- package/lib-es/components/ListingContainer/Listing/index.js +3 -0
- package/lib-es/components/ListingContainer/Listing/index.js.map +1 -0
- package/lib-es/components/ListingContainer/ListingContainer.js +115 -0
- package/lib-es/components/ListingContainer/ListingContainer.js.map +1 -0
- package/lib-es/components/ListingContainer/index.js +3 -0
- package/lib-es/components/ListingContainer/index.js.map +1 -0
- package/lib-es/components/ListingContainer/mappers/exist-previous.js +3 -0
- package/lib-es/components/ListingContainer/mappers/exist-previous.js.map +1 -0
- package/lib-es/components/ListingContainer/mappers/index.js +3 -0
- package/lib-es/components/ListingContainer/mappers/index.js.map +1 -0
- package/lib-es/components/MediaListing.js +29 -0
- package/lib-es/components/MediaListing.js.map +1 -0
- package/lib-es/constants.js +36 -0
- package/lib-es/constants.js.map +1 -0
- package/lib-es/icons/MediaLibraryIcon.js +70 -0
- package/lib-es/icons/MediaLibraryIcon.js.map +1 -0
- package/lib-es/icons/index.js +3 -0
- package/lib-es/icons/index.js.map +1 -0
- package/lib-es/index.js +61 -0
- package/lib-es/index.js.map +1 -0
- package/lib-es/utils/available-filters/available-filters.js +26 -0
- package/lib-es/utils/available-filters/available-filters.js.map +1 -0
- package/lib-es/utils/bustUrl.js +7 -0
- package/lib-es/utils/bustUrl.js.map +1 -0
- package/lib-es/utils/media-context/index.js +4 -0
- package/lib-es/utils/media-context/index.js.map +1 -0
- package/lib-es/utils/media-context/media-context.js +6 -0
- package/lib-es/utils/media-context/media-context.js.map +1 -0
- package/lib-es/utils/media-context/useMediaContext.js +4 -0
- package/lib-es/utils/media-context/useMediaContext.js.map +1 -0
- package/package.json +9 -8
- package/src/components/EditMediaFile/EditMediaFile.js +3 -1
- package/src/components/EditorAdapter/EditorAdapter.js +12 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFiles.js","names":["getQuery","ALL","INVALID_STORE_KEY_VALUES","getFromSearch","searchTerm","offset","limit","where","client","fileStores","allTypesMatches","match","type","matchSpecificType","mustMatch","push","simple_query_string","query","analyze_wildcard","fields","storeKeys","includes","storeKey","map","key","bool","should","minimum_should_match","data","files","results","all","image","video","text","fetchPolicy","variables","sort","rawQuery","must","rawQueryAllResults","rawQueryImages","rawQueryVideos","rawQueryDocs","getFiles"],"sources":["../../../../src/components/FileList/useGetFiles/getFiles.js"],"sourcesContent":["import { getQuery } from '@blaze-cms/admin-ui-utils';\nimport { ALL, INVALID_STORE_KEY_VALUES } from '../../../constants';\n\nconst getFromSearch = async ({ searchTerm, offset, limit, where, client, fileStores = [] }) => {\n const allTypesMatches = [\n {\n match: { type: 'image' }\n },\n {\n match: { type: 'video' }\n },\n {\n match: { type: 'text' }\n }\n ];\n const matchSpecificType = [\n {\n match: { type: where.type }\n }\n ];\n const match = !where.type || where.type === ALL ? allTypesMatches : matchSpecificType;\n const mustMatch = [];\n\n if (searchTerm) {\n mustMatch.push({\n simple_query_string: {\n query: `${searchTerm}*`,\n analyze_wildcard: true,\n fields: ['name', 'filename', 'data.altText', 'data.caption', 'data.title', 'data.credits']\n }\n });\n }\n\n const storeKeys = [];\n if (INVALID_STORE_KEY_VALUES.includes(where.storeKey)) {\n storeKeys.push(...fileStores.map(({ key }) => key));\n } else if (where.storeKey) {\n storeKeys.push(where.storeKey);\n }\n\n mustMatch.push({\n bool: {\n should: storeKeys.map(storeKey => ({\n match: { storeKey }\n })),\n minimum_should_match: 1\n }\n });\n\n const {\n data: {\n files: { results: files },\n all,\n image,\n video,\n text\n }\n } = await client.query({\n query: getQuery('SEARCH_ADMIN_MEDIA'),\n fetchPolicy: 'network-only',\n variables: {\n offset,\n limit,\n sort: searchTerm ? null : 'updated:desc',\n rawQuery: {\n query: {\n bool: {\n must: [\n ...mustMatch,\n {\n bool: {\n should: match\n }\n }\n ]\n }\n }\n },\n rawQueryAllResults: {\n query: {\n bool: {\n must: [\n ...mustMatch,\n {\n bool: {\n should: [\n {\n match: { type: 'image' }\n },\n {\n match: { type: 'video' }\n },\n {\n match: { type: 'text' }\n }\n ]\n }\n }\n ]\n }\n }\n },\n rawQueryImages: {\n query: {\n bool: {\n must: [\n ...mustMatch,\n {\n bool: {\n should: [\n {\n match: { type: 'image' }\n }\n ]\n }\n }\n ]\n }\n }\n },\n rawQueryVideos: {\n query: {\n bool: {\n must: [\n ...mustMatch,\n {\n bool: {\n should: [\n {\n match: { type: 'video' }\n }\n ]\n }\n }\n ]\n }\n }\n },\n rawQueryDocs: {\n query: {\n bool: {\n must: [\n ...mustMatch,\n {\n bool: {\n should: [\n {\n match: { type: 'text' }\n }\n ]\n }\n }\n ]\n }\n }\n }\n }\n });\n\n return { files, all, image, video, text };\n};\n\nconst getFiles = ({ offset, limit, where, searchTerm, fileStores }, client) =>\n getFromSearch({ searchTerm, offset, limit, where, client, fileStores });\n\nexport default getFiles;\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,2BAA2B;AACpD,SAASC,GAAG,EAAEC,wBAAwB,QAAQ,oBAAoB;AAElE,MAAMC,aAAa,GAAG,MAAAA,CAAO;EAAEC,UAAU;EAAEC,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AC;cAEL;YACF,CAAC;UAEL;QACF;MACF,CAAC;MACD8B,cAAc,EAAE;QACdzB,KAAK,EAAE;UACLQ,IAAI,EAAE;YACJc,IAAI,EAAE,CACJ,GAAGzB,SAAS,EACZ;cACEW,IAAI,EAAE;gBACJC,MAAM,EAAE,CACN;kBACEf,KAAK,EAAE;oBAAEC,IAAI,EAAE;kBAAQ;gBACzB,CAAC;cAEL;YACF,CAAC;UAEL;QACF;MACF,CAAC;MACD+B,YAAY,EAAE;QACZ1B,KAAK,EAAE;UACLQ,IAAI,EAAE;YACJc,IAAI,EAAE,CACJ,GAAGzB,SAAS,EACZ;cACEW,IAAI,EAAE;gBACJC,MAAM,EAAE,CACN;kBACEf,KAAK,EAAE;oBAAEC,IAAI,EAAE;kBAAO;gBACxB,CAAC;cAEL;YACF,CAAC;UAEL;QACF;MACF;IACF;EACF,CAAC,CAAC;EAEF,OAAO;IAAEiB,KAAK;IAAEE,GAAG;IAAEC,KAAK;IAAEC,KAAK;IAAEC;EAAK,CAAC;AAC3C,CAAC;AAED,MAAMU,QAAQ,GAAGA,CAAC;EAAEvC,MAAM;EAAEC,KAAK;EAAEC,KAAK;EAAEH,UAAU;EAAEK;AAAW,CAAC,EAAED,MAAM,KACxEL,aAAa,CAAC;EAAEC,UAAU;EAAEC,MAAM;EAAEC,KAAK;EAAEC,KAAK;EAAEC,MAAM;EAAEC;AAAW,CAAC,CAAC;AAEzE,eAAemC,QAAQ","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["useGetFiles"],"sources":["../../../../src/components/FileList/useGetFiles/index.js"],"sourcesContent":["import useGetFiles from './useGetFiles';\n\nexport default useGetFiles;\n"],"mappings":"AAAA,OAAOA,WAAW,MAAM,eAAe;AAEvC,eAAeA,WAAW","ignoreList":[]}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
import { useState, useEffect, useContext } from 'react';
|
|
5
|
+
import { useApolloClient } from '@apollo/client';
|
|
6
|
+
import getFiles from './getFiles';
|
|
7
|
+
import { MediaContext } from '../../../utils/media-context';
|
|
8
|
+
function useGetFiles() {
|
|
9
|
+
const [queryParams, setQueryParams] = useState({
|
|
10
|
+
limit: 20,
|
|
11
|
+
offset: 0,
|
|
12
|
+
where: null,
|
|
13
|
+
sort: [{
|
|
14
|
+
property: 'updated',
|
|
15
|
+
direction: 'desc'
|
|
16
|
+
}]
|
|
17
|
+
});
|
|
18
|
+
const {
|
|
19
|
+
fileStores
|
|
20
|
+
} = useContext(MediaContext) || {};
|
|
21
|
+
const [previousFilter, setPreviousFilter] = useState(null);
|
|
22
|
+
const [previousOffset, setPreviousOffset] = useState(null);
|
|
23
|
+
const [previousSearchTerm, setPreviousSearchTerm] = useState(null);
|
|
24
|
+
const [data, setData] = useState({
|
|
25
|
+
files: [],
|
|
26
|
+
total: 0
|
|
27
|
+
});
|
|
28
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
29
|
+
const client = useApolloClient();
|
|
30
|
+
const setParams = newQueryParams => {
|
|
31
|
+
setQueryParams(_objectSpread(_objectSpread({}, queryParams), newQueryParams));
|
|
32
|
+
};
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
const {
|
|
35
|
+
offset,
|
|
36
|
+
limit,
|
|
37
|
+
where,
|
|
38
|
+
sort,
|
|
39
|
+
searchTerm,
|
|
40
|
+
isSearch
|
|
41
|
+
} = queryParams;
|
|
42
|
+
const newFilter = JSON.stringify(where);
|
|
43
|
+
const isNewFilterSet = newFilter !== previousFilter;
|
|
44
|
+
const isNewOffsetSet = previousOffset !== null && offset !== previousOffset;
|
|
45
|
+
const isNewSearchTermSet = searchTerm && previousSearchTerm !== searchTerm;
|
|
46
|
+
const isResetSearch = searchTerm === null && !isSearch && previousFilter;
|
|
47
|
+
const shouldRequest = where && (isNewOffsetSet || isNewFilterSet || isNewSearchTermSet || isResetSearch);
|
|
48
|
+
async function fetchData() {
|
|
49
|
+
if (data.files.length) {
|
|
50
|
+
setData({
|
|
51
|
+
files: []
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
const {
|
|
55
|
+
files,
|
|
56
|
+
total,
|
|
57
|
+
all,
|
|
58
|
+
image,
|
|
59
|
+
video,
|
|
60
|
+
text
|
|
61
|
+
} = await getFiles({
|
|
62
|
+
offset,
|
|
63
|
+
limit,
|
|
64
|
+
where,
|
|
65
|
+
sort,
|
|
66
|
+
searchTerm,
|
|
67
|
+
isSearch,
|
|
68
|
+
fileStores
|
|
69
|
+
}, client);
|
|
70
|
+
setData({
|
|
71
|
+
files,
|
|
72
|
+
total,
|
|
73
|
+
all,
|
|
74
|
+
image,
|
|
75
|
+
video,
|
|
76
|
+
text
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
if (shouldRequest) {
|
|
80
|
+
setIsLoading(true);
|
|
81
|
+
fetchData().then(() => {
|
|
82
|
+
setIsLoading(false);
|
|
83
|
+
});
|
|
84
|
+
setPreviousFilter(newFilter);
|
|
85
|
+
setPreviousOffset(offset);
|
|
86
|
+
setPreviousSearchTerm(searchTerm);
|
|
87
|
+
}
|
|
88
|
+
}, [queryParams, previousOffset, previousFilter] //eslint-disable-line
|
|
89
|
+
);
|
|
90
|
+
const {
|
|
91
|
+
files,
|
|
92
|
+
total,
|
|
93
|
+
all,
|
|
94
|
+
image,
|
|
95
|
+
video,
|
|
96
|
+
text
|
|
97
|
+
} = data;
|
|
98
|
+
return [{
|
|
99
|
+
queryParams,
|
|
100
|
+
previousFilter,
|
|
101
|
+
previousSearchTerm,
|
|
102
|
+
loading: isLoading,
|
|
103
|
+
data: {
|
|
104
|
+
files,
|
|
105
|
+
total,
|
|
106
|
+
all,
|
|
107
|
+
image,
|
|
108
|
+
video,
|
|
109
|
+
text
|
|
110
|
+
}
|
|
111
|
+
}, setParams];
|
|
112
|
+
}
|
|
113
|
+
export default useGetFiles;
|
|
114
|
+
//# sourceMappingURL=useGetFiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGetFiles.js","names":["useState","useEffect","useContext","useApolloClient","getFiles","MediaContext","useGetFiles","queryParams","setQueryParams","limit","offset","where","sort","property","direction","fileStores","previousFilter","setPreviousFilter","previousOffset","setPreviousOffset","previousSearchTerm","setPreviousSearchTerm","data","setData","files","total","isLoading","setIsLoading","client","setParams","newQueryParams","_objectSpread","searchTerm","isSearch","newFilter","JSON","stringify","isNewFilterSet","isNewOffsetSet","isNewSearchTermSet","isResetSearch","shouldRequest","fetchData","length","all","image","video","text","then","loading"],"sources":["../../../../src/components/FileList/useGetFiles/useGetFiles.js"],"sourcesContent":["import { useState, useEffect, useContext } from 'react';\nimport { useApolloClient } from '@apollo/client';\nimport getFiles from './getFiles';\nimport { MediaContext } from '../../../utils/media-context';\n\nfunction useGetFiles() {\n const [queryParams, setQueryParams] = useState({\n limit: 20,\n offset: 0,\n where: null,\n sort: [\n {\n property: 'updated',\n direction: 'desc'\n }\n ]\n });\n const { fileStores } = useContext(MediaContext) || {};\n const [previousFilter, setPreviousFilter] = useState(null);\n const [previousOffset, setPreviousOffset] = useState(null);\n const [previousSearchTerm, setPreviousSearchTerm] = useState(null);\n const [data, setData] = useState({ files: [], total: 0 });\n const [isLoading, setIsLoading] = useState(true);\n const client = useApolloClient();\n\n const setParams = newQueryParams => {\n setQueryParams({ ...queryParams, ...newQueryParams });\n };\n\n useEffect(\n () => {\n const { offset, limit, where, sort, searchTerm, isSearch } = queryParams;\n const newFilter = JSON.stringify(where);\n const isNewFilterSet = newFilter !== previousFilter;\n const isNewOffsetSet = previousOffset !== null && offset !== previousOffset;\n const isNewSearchTermSet = searchTerm && previousSearchTerm !== searchTerm;\n const isResetSearch = searchTerm === null && !isSearch && previousFilter;\n const shouldRequest =\n where && (isNewOffsetSet || isNewFilterSet || isNewSearchTermSet || isResetSearch);\n async function fetchData() {\n if (data.files.length) {\n setData({ files: [] });\n }\n\n const { files, total, all, image, video, text } = await getFiles(\n { offset, limit, where, sort, searchTerm, isSearch, fileStores },\n client\n );\n setData({ files, total, all, image, video, text });\n }\n\n if (shouldRequest) {\n setIsLoading(true);\n fetchData().then(() => {\n setIsLoading(false);\n });\n setPreviousFilter(newFilter);\n setPreviousOffset(offset);\n setPreviousSearchTerm(searchTerm);\n }\n },\n [queryParams, previousOffset, previousFilter] //eslint-disable-line\n );\n\n const { files, total, all, image, video, text } = data;\n return [\n {\n queryParams,\n previousFilter,\n previousSearchTerm,\n loading: isLoading,\n data: { files, total, all, image, video, text }\n },\n setParams\n ];\n}\n\nexport default useGetFiles;\n"],"mappings":";;;AAAA,SAASA,QAAQ,EAAEC,SAAS,EAAEC,UAAU,QAAQ,OAAO;AACvD,SAASC,eAAe,QAAQ,gBAAgB;AAChD,OAAOC,QAAQ,MAAM,YAAY;AACjC,SAASC,YAAY,QAAQ,8BAA8B;AAE3D,SAASC,WAAWA,CAAA,EAAG;EACrB,MAAM,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAGR,QAAQ,CAAC;IAC7CS,KAAK,EAAE,EAAE;IACTC,MAAM,EAAE,CAAC;IACTC,KAAK,EAAE,IAAI;IACXC,IAAI,EAAE,CACJ;MACEC,QAAQ,EAAE,SAAS;MACnBC,SAAS,EAAE;IACb,CAAC;EAEL,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,SAAS,CACV;AACH;AAEA,eAAevB,WAAW","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { getQuery } from '@blaze-cms/admin-ui-utils';
|
|
2
|
+
const getCounters = async client => {
|
|
3
|
+
const {
|
|
4
|
+
data
|
|
5
|
+
} = await client.query({
|
|
6
|
+
query: getQuery('GET_COUNT_ALL_FILES')
|
|
7
|
+
});
|
|
8
|
+
return data;
|
|
9
|
+
};
|
|
10
|
+
export default getCounters;
|
|
11
|
+
//# sourceMappingURL=getCounters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCounters.js","names":["getQuery","getCounters","client","data","query"],"sources":["../../../../src/components/FileList/useGetFilesList/getCounters.js"],"sourcesContent":["import { getQuery } from '@blaze-cms/admin-ui-utils';\n\nconst getCounters = async client => {\n const { data } = await client.query({ query: getQuery('GET_COUNT_ALL_FILES') });\n return data;\n};\n\nexport default getCounters;\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,2BAA2B;AAEpD,MAAMC,WAAW,GAAG,MAAMC,MAAM,IAAI;EAClC,MAAM;IAAEC;EAAK,CAAC,GAAG,MAAMD,MAAM,CAACE,KAAK,CAAC;IAAEA,KAAK,EAAEJ,QAAQ,CAAC,qBAAqB;EAAE,CAAC,CAAC;EAC/E,OAAOG,IAAI;AACb,CAAC;AAED,eAAeF,WAAW","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["useGetFilesList"],"sources":["../../../../src/components/FileList/useGetFilesList/index.js"],"sourcesContent":["import useGetFilesList from './useGetFilesList';\n\nexport default useGetFilesList;\n"],"mappings":"AAAA,OAAOA,eAAe,MAAM,mBAAmB;AAE/C,eAAeA,eAAe","ignoreList":[]}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
import { useState, useEffect } from 'react';
|
|
5
|
+
import differenceWith from 'lodash.differencewith';
|
|
6
|
+
import isEqual from 'lodash.isequal';
|
|
7
|
+
import useGetFiles from '../useGetFiles';
|
|
8
|
+
function useGetFilesList() {
|
|
9
|
+
const [{
|
|
10
|
+
queryParams,
|
|
11
|
+
previousFilter,
|
|
12
|
+
previousSearchTerm,
|
|
13
|
+
loading,
|
|
14
|
+
data: {
|
|
15
|
+
files: results,
|
|
16
|
+
all,
|
|
17
|
+
image,
|
|
18
|
+
video,
|
|
19
|
+
text
|
|
20
|
+
}
|
|
21
|
+
}, setParams] = useGetFiles();
|
|
22
|
+
const [currentResults, setCurrentResults] = useState([]);
|
|
23
|
+
const [allResults, setAllResults] = useState([]);
|
|
24
|
+
const [currentFilter, setCurrentFilter] = useState(null);
|
|
25
|
+
const [allFilesCounter, setAllFilesCounter] = useState({
|
|
26
|
+
all: 0,
|
|
27
|
+
text: 0,
|
|
28
|
+
image: 0,
|
|
29
|
+
video: 0
|
|
30
|
+
});
|
|
31
|
+
const [counters, setCounters] = useState(null);
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (all && image && video && text) {
|
|
34
|
+
setCounters({
|
|
35
|
+
all: all.total,
|
|
36
|
+
image: image.total,
|
|
37
|
+
video: video.total,
|
|
38
|
+
text: text.total
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}, [all, image, video, text]);
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (!currentFilter && previousFilter) {
|
|
44
|
+
setCurrentFilter(previousFilter);
|
|
45
|
+
}
|
|
46
|
+
if (currentFilter !== previousFilter) {
|
|
47
|
+
setAllResults([]);
|
|
48
|
+
setCurrentResults([]);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const isContentDifferent = !!differenceWith(results, currentResults, isEqual).length;
|
|
52
|
+
if (isContentDifferent) {
|
|
53
|
+
setAllResults([...allResults, ...results]);
|
|
54
|
+
setCurrentResults(results);
|
|
55
|
+
}
|
|
56
|
+
const shouldSetContentIfListIsVoid = !isContentDifferent && !allResults.length && results.length;
|
|
57
|
+
if (shouldSetContentIfListIsVoid) {
|
|
58
|
+
setAllResults(results);
|
|
59
|
+
setCurrentResults(results);
|
|
60
|
+
}
|
|
61
|
+
}, [currentFilter, currentResults, currentResults.length, previousFilter, results] //eslint-disable-line
|
|
62
|
+
);
|
|
63
|
+
const removeFile = ({
|
|
64
|
+
index
|
|
65
|
+
}) => {
|
|
66
|
+
const resultsToUpdate = [...allResults];
|
|
67
|
+
resultsToUpdate.splice(index, 1);
|
|
68
|
+
const currentFileType = resultsToUpdate[index].type;
|
|
69
|
+
const updatedFileTypeCounterValue = allFilesCounter[currentFileType] - 1;
|
|
70
|
+
const updateAllFilesCounter = allFilesCounter.all - 1;
|
|
71
|
+
if (queryParams.isSearch) {
|
|
72
|
+
setCounters(_objectSpread(_objectSpread({}, counters), {}, {
|
|
73
|
+
[currentFileType]: counters[currentFileType] - 1,
|
|
74
|
+
all: counters.all - 1
|
|
75
|
+
}));
|
|
76
|
+
setAllFilesCounter(_objectSpread(_objectSpread({}, allFilesCounter), {}, {
|
|
77
|
+
[currentFileType]: updatedFileTypeCounterValue,
|
|
78
|
+
all: updateAllFilesCounter
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
if (!queryParams.isSearch) {
|
|
82
|
+
const updatedCounters = _objectSpread(_objectSpread({}, allFilesCounter), {}, {
|
|
83
|
+
[currentFileType]: updatedFileTypeCounterValue,
|
|
84
|
+
all: updateAllFilesCounter
|
|
85
|
+
});
|
|
86
|
+
setCounters(updatedCounters);
|
|
87
|
+
setAllFilesCounter(updatedCounters);
|
|
88
|
+
}
|
|
89
|
+
setAllResults(resultsToUpdate);
|
|
90
|
+
};
|
|
91
|
+
const updateFile = ({
|
|
92
|
+
file,
|
|
93
|
+
index
|
|
94
|
+
}) => {
|
|
95
|
+
const resultsToUpdate = [...allResults];
|
|
96
|
+
resultsToUpdate[index] = file;
|
|
97
|
+
setAllResults(resultsToUpdate);
|
|
98
|
+
};
|
|
99
|
+
const addNewFile = newFiles => {
|
|
100
|
+
const {
|
|
101
|
+
image: _image,
|
|
102
|
+
video: _video,
|
|
103
|
+
text: _text
|
|
104
|
+
} = newFiles.reduce((acc, {
|
|
105
|
+
type
|
|
106
|
+
}) => {
|
|
107
|
+
acc[type] += 1;
|
|
108
|
+
return acc;
|
|
109
|
+
}, {
|
|
110
|
+
image: 0,
|
|
111
|
+
video: 0,
|
|
112
|
+
text: 0
|
|
113
|
+
});
|
|
114
|
+
if (queryParams.isSearch) {
|
|
115
|
+
setAllResults([]);
|
|
116
|
+
setParams({
|
|
117
|
+
queryParams,
|
|
118
|
+
isSearch: false,
|
|
119
|
+
searchTerm: null
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
const updatedCounters = {
|
|
123
|
+
all: allFilesCounter.all + _image + _video + _text,
|
|
124
|
+
image: allFilesCounter.image + _image,
|
|
125
|
+
video: allFilesCounter.video + _video,
|
|
126
|
+
text: allFilesCounter.text + _text
|
|
127
|
+
};
|
|
128
|
+
setCounters(updatedCounters);
|
|
129
|
+
setAllFilesCounter(updatedCounters);
|
|
130
|
+
setAllResults([...newFiles, ...allResults]);
|
|
131
|
+
};
|
|
132
|
+
const clearList = params => {
|
|
133
|
+
setAllResults([]);
|
|
134
|
+
setParams(_objectSpread(_objectSpread({}, params), {}, {
|
|
135
|
+
offset: 0
|
|
136
|
+
}));
|
|
137
|
+
setCounters(allFilesCounter);
|
|
138
|
+
};
|
|
139
|
+
const setQueryParams = params => {
|
|
140
|
+
const isNewSearchTerm = params.isSearch && previousSearchTerm !== params.searchTerm;
|
|
141
|
+
const hasDeletedSearchTerm = previousSearchTerm && params.searchTerm === null;
|
|
142
|
+
const newFilter = JSON.stringify(params.where);
|
|
143
|
+
const isNewFilter = newFilter !== previousFilter;
|
|
144
|
+
const shouldClearList = hasDeletedSearchTerm || isNewFilter || isNewSearchTerm;
|
|
145
|
+
shouldClearList ? clearList(params) : setParams(params);
|
|
146
|
+
setCurrentFilter(newFilter);
|
|
147
|
+
};
|
|
148
|
+
const parsedQueryParams = _objectSpread(_objectSpread({}, queryParams), {}, {
|
|
149
|
+
where: _objectSpread({}, queryParams.where)
|
|
150
|
+
});
|
|
151
|
+
if (parsedQueryParams.where.type === 'all') delete parsedQueryParams.where.type;
|
|
152
|
+
return [{
|
|
153
|
+
queryParams: parsedQueryParams,
|
|
154
|
+
loading,
|
|
155
|
+
data: {
|
|
156
|
+
files: allResults,
|
|
157
|
+
all: counters ? formatCounterNumber(counters.all) : 0,
|
|
158
|
+
images: counters ? formatCounterNumber(counters.image) : 0,
|
|
159
|
+
videos: counters ? formatCounterNumber(counters.video) : 0,
|
|
160
|
+
documents: counters ? formatCounterNumber(counters.text) : 0
|
|
161
|
+
}
|
|
162
|
+
}, {
|
|
163
|
+
setQueryParams,
|
|
164
|
+
clearList,
|
|
165
|
+
removeFile,
|
|
166
|
+
addNewFile,
|
|
167
|
+
updateFile
|
|
168
|
+
}];
|
|
169
|
+
}
|
|
170
|
+
const formatCounterNumber = n => n === 10000 ? '10000+' : n;
|
|
171
|
+
export default useGetFilesList;
|
|
172
|
+
//# sourceMappingURL=useGetFilesList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGetFilesList.js","names":["useState","useEffect","differenceWith","isEqual","useGetFiles","useGetFilesList","queryParams","previousFilter","previousSearchTerm","loading","data","files","results","all","image","video","text","setParams","currentResults","setCurrentResults","allResults","setAllResults","currentFilter","setCurrentFilter","allFilesCounter","setAllFilesCounter","counters","setCounters","total","isContentDifferent","length","shouldSetContentIfListIsVoid","removeFile","index","resultsToUpdate","splice","currentFileType","type","updatedFileTypeCounterValue","updateAllFilesCounter","isSearch","_objectSpread","updatedCounters","updateFile","file","addNewFile","newFiles","_image","_video","_text","reduce","acc","searchTerm","clearList","params","offset","setQueryParams","isNewSearchTerm","hasDeletedSearchTerm","newFilter","JSON","stringify","where","isNewFilter","shouldClearList","parsedQueryParams","formatCounterNumber","images","videos","documents","n"],"sources":["../../../../src/components/FileList/useGetFilesList/useGetFilesList.js"],"sourcesContent":["import { useState, useEffect } from 'react';\nimport differenceWith from 'lodash.differencewith';\nimport isEqual from 'lodash.isequal';\nimport useGetFiles from '../useGetFiles';\n\nfunction useGetFilesList() {\n const [\n {\n queryParams,\n previousFilter,\n previousSearchTerm,\n loading,\n data: { files: results, all, image, video, text }\n },\n setParams\n ] = useGetFiles();\n const [currentResults, setCurrentResults] = useState([]);\n const [allResults, setAllResults] = useState([]);\n const [currentFilter, setCurrentFilter] = useState(null);\n const [allFilesCounter, setAllFilesCounter] = useState({ all: 0, text: 0, image: 0, video: 0 });\n const [counters, setCounters] = useState(null);\n\n useEffect(() => {\n if (all && image && video && text) {\n setCounters({\n all: all.total,\n image: image.total,\n video: video.total,\n text: text.total\n });\n }\n }, [all, image, video, text]);\n\n useEffect(\n () => {\n if (!currentFilter && previousFilter) {\n setCurrentFilter(previousFilter);\n }\n\n if (currentFilter !== previousFilter) {\n setAllResults([]);\n setCurrentResults([]);\n return;\n }\n\n const isContentDifferent = !!differenceWith(results, currentResults, isEqual).length;\n if (isContentDifferent) {\n setAllResults([...allResults, ...results]);\n setCurrentResults(results);\n }\n\n const shouldSetContentIfListIsVoid =\n !isContentDifferent && !allResults.length && results.length;\n\n if (shouldSetContentIfListIsVoid) {\n setAllResults(results);\n setCurrentResults(results);\n }\n },\n [currentFilter, currentResults, currentResults.length, previousFilter, results] //eslint-disable-line\n );\n\n const removeFile = ({ index }) => {\n const resultsToUpdate = [...allResults];\n resultsToUpdate.splice(index, 1);\n const currentFileType = resultsToUpdate[index].type;\n const updatedFileTypeCounterValue = allFilesCounter[currentFileType] - 1;\n const updateAllFilesCounter = allFilesCounter.all - 1;\n if (queryParams.isSearch) {\n setCounters({\n ...counters,\n [currentFileType]: counters[currentFileType] - 1,\n all: counters.all - 1\n });\n setAllFilesCounter({\n ...allFilesCounter,\n [currentFileType]: updatedFileTypeCounterValue,\n all: updateAllFilesCounter\n });\n }\n\n if (!queryParams.isSearch) {\n const updatedCounters = {\n ...allFilesCounter,\n [currentFileType]: updatedFileTypeCounterValue,\n all: updateAllFilesCounter\n };\n\n setCounters(updatedCounters);\n setAllFilesCounter(updatedCounters);\n }\n setAllResults(resultsToUpdate);\n };\n\n const updateFile = ({ file, index }) => {\n const resultsToUpdate = [...allResults];\n resultsToUpdate[index] = file;\n setAllResults(resultsToUpdate);\n };\n\n const addNewFile = newFiles => {\n const {\n image: _image,\n video: _video,\n text: _text\n } = newFiles.reduce(\n (acc, { type }) => {\n acc[type] += 1;\n return acc;\n },\n { image: 0, video: 0, text: 0 }\n );\n\n if (queryParams.isSearch) {\n setAllResults([]);\n setParams({ queryParams, isSearch: false, searchTerm: null });\n }\n\n const updatedCounters = {\n all: allFilesCounter.all + _image + _video + _text,\n image: allFilesCounter.image + _image,\n video: allFilesCounter.video + _video,\n text: allFilesCounter.text + _text\n };\n\n setCounters(updatedCounters);\n setAllFilesCounter(updatedCounters);\n setAllResults([...newFiles, ...allResults]);\n };\n\n const clearList = params => {\n setAllResults([]);\n setParams({ ...params, offset: 0 });\n setCounters(allFilesCounter);\n };\n\n const setQueryParams = params => {\n const isNewSearchTerm = params.isSearch && previousSearchTerm !== params.searchTerm;\n const hasDeletedSearchTerm = previousSearchTerm && params.searchTerm === null;\n const newFilter = JSON.stringify(params.where);\n const isNewFilter = newFilter !== previousFilter;\n const shouldClearList = hasDeletedSearchTerm || isNewFilter || isNewSearchTerm;\n shouldClearList ? clearList(params) : setParams(params);\n setCurrentFilter(newFilter);\n };\n\n const parsedQueryParams = {\n ...queryParams,\n where: { ...queryParams.where }\n };\n\n if (parsedQueryParams.where.type === 'all') delete parsedQueryParams.where.type;\n\n return [\n {\n queryParams: parsedQueryParams,\n loading,\n data: {\n files: allResults,\n all: counters ? formatCounterNumber(counters.all) : 0,\n images: counters ? formatCounterNumber(counters.image) : 0,\n videos: counters ? formatCounterNumber(counters.video) : 0,\n documents: counters ? formatCounterNumber(counters.text) : 0\n }\n },\n { setQueryParams, clearList, removeFile, addNewFile, updateFile }\n ];\n}\n\nconst formatCounterNumber = n => (n === 10000 ? '10000+' : n);\n\nexport default useGetFilesList;\n"],"mappings":";;;AAAA,SAASA,QAAQ,EAAEC,SAAS,QAAQ,OAAO;AAC3C,OAAOC,cAAc,MAAM,uBAAuB;AAClD,OAAOC,OAAO,MAAM,gBAAgB;AACpC,OAAOC,WAAW,MAAM,gBAAgB;AAExC,SAASC,eAAeA,CAAA,EAAG;EACzB,MAAM,CACJ;IACEC,WAAW;IACXC,cAAc;IACdC,kBAAkB;IAClBC,OAAO;IACPC,IAAI,EAAE;MAAEC,KAAK,EAAEC,OAAO;MAAEC,GAAG;MAAEC,KAAK;MAAEC,KAAK;MAAEC;IAAK;EAClD,CAAC,EACDC,SAAS,CACV,GAAGb,WAAW,CAAC,CAAC;EACjB,MAAM,CAACc,cAAc,EAAEC,iBAAiB,CAAC,GAAGnB,QAAQ,CAAC,EAAE,CAAC;EACxD,MAAM,CAACoB,UAAU,EAAEC,aAAa,CAAC,GAAGrB,QAAQ,CAAC,EAAE,CAAC;EAChD,MAAM,CAACsB,aAAa,EAAEC,gBAAgB,CAAC,GAAGvB,QAAQ,CAAC,IAAI,CAAC;EACxD,MAAM,CAACwB,eAAe,EAAEC,kBAAkB,CAAC,G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SAAS,EAAE3C,QAAQ,GAAGwC,mBAAmB,CAACxC,QAAQ,CAACV,IAAI,CAAC,GAAG;IAC7D;EACF,CAAC,EACD;IAAEwC,cAAc;IAAEH,SAAS;IAAErB,UAAU;IAAEa,UAAU;IAAEF;EAAW,CAAC,CAClE;AACH;AAEA,MAAMuB,mBAAmB,GAAGI,CAAC,IAAKA,CAAC,KAAK,KAAK,GAAG,QAAQ,GAAGA,CAAE;AAE7D,eAAejE,eAAe","ignoreList":[]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { MediaContext } from '../../../utils/media-context';
|
|
4
|
+
const Actions = ({
|
|
5
|
+
file
|
|
6
|
+
}) => {
|
|
7
|
+
const {
|
|
8
|
+
handleEditModal,
|
|
9
|
+
onUnselectFile
|
|
10
|
+
} = useContext(MediaContext);
|
|
11
|
+
const [, extension] = file.mimetype.split('/');
|
|
12
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
13
|
+
className: "FilePreviewItem__info__actions"
|
|
14
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
15
|
+
className: "FilePreviewItem__info__actions FilePreviewItem__info__actions--media-type"
|
|
16
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
17
|
+
className: "FilePreviewItem__info__actionsIcon material-icons"
|
|
18
|
+
}, "insert_photo"), ' ', /*#__PURE__*/React.createElement("span", null, extension)), /*#__PURE__*/React.createElement("div", null, handleEditModal && /*#__PURE__*/React.createElement("div", {
|
|
19
|
+
"data-testid": `open-media-library-${file.id}`,
|
|
20
|
+
className: "FilePreviewItem__info__actionsIcon material-icons edit",
|
|
21
|
+
"aria-hidden": "true",
|
|
22
|
+
onClick: () => handleEditModal(file)
|
|
23
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
24
|
+
className: "fas fa-pen fa-xs"
|
|
25
|
+
})), onUnselectFile && /*#__PURE__*/React.createElement("div", {
|
|
26
|
+
"data-testid": `unselect-${file.id}`,
|
|
27
|
+
className: "FilePreviewItem__info__actionsIcon material-icons delete",
|
|
28
|
+
"aria-hidden": "true",
|
|
29
|
+
onClick: () => onUnselectFile([file.id])
|
|
30
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
31
|
+
className: "fas fa-trash fa-xs"
|
|
32
|
+
}))));
|
|
33
|
+
};
|
|
34
|
+
Actions.propTypes = {
|
|
35
|
+
file: PropTypes.object.isRequired
|
|
36
|
+
};
|
|
37
|
+
export default Actions;
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useContext","PropTypes","MediaContext","Actions","file","handleEditModal","onUnselectFile","extension","mimetype","split","createElement","className","id","onClick","propTypes","object","isRequired"],"sources":["../../../../src/components/FilePreview/Actions/index.js"],"sourcesContent":["import React, { useContext } from 'react';\nimport PropTypes from 'prop-types';\nimport { MediaContext } from '../../../utils/media-context';\n\nconst Actions = ({ file }) => {\n const { handleEditModal, onUnselectFile } = useContext(MediaContext);\n const [, extension] = file.mimetype.split('/');\n\n return (\n <div className=\"FilePreviewItem__info__actions\">\n <div className=\"FilePreviewItem__info__actions FilePreviewItem__info__actions--media-type\">\n <i className=\"FilePreviewItem__info__actionsIcon material-icons\">insert_photo</i>{' '}\n <span>{extension}</span>\n </div>\n <div>\n {handleEditModal && (\n <div\n data-testid={`open-media-library-${file.id}`}\n className=\"FilePreviewItem__info__actionsIcon material-icons edit\"\n aria-hidden=\"true\"\n onClick={() => handleEditModal(file)}>\n <i className=\"fas fa-pen fa-xs\" />\n </div>\n )}\n {onUnselectFile && (\n <div\n data-testid={`unselect-${file.id}`}\n className=\"FilePreviewItem__info__actionsIcon material-icons delete\"\n aria-hidden=\"true\"\n onClick={() => onUnselectFile([file.id])}>\n <i className=\"fas fa-trash fa-xs\" />\n </div>\n )}\n </div>\n </div>\n );\n};\n\nActions.propTypes = {\n file: PropTypes.object.isRequired\n};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S,GAAG;EAClBV,IAAI,EAAEH,SAAS,CAACc,MAAM,CAACC;AACzB,CAAC;AAED,eAAeb,OAAO","ignoreList":[]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import Button from '@blaze-react/button';
|
|
4
|
+
const Image = ({
|
|
5
|
+
url,
|
|
6
|
+
name,
|
|
7
|
+
children,
|
|
8
|
+
handleChangeFile,
|
|
9
|
+
showChangeButton
|
|
10
|
+
}) => /*#__PURE__*/React.createElement("div", {
|
|
11
|
+
className: "preview"
|
|
12
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
13
|
+
className: "preview__file preview__file--image"
|
|
14
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
15
|
+
src: url,
|
|
16
|
+
alt: name
|
|
17
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
18
|
+
className: "preview__details preview__details--file"
|
|
19
|
+
}, /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("strong", null, "File details"), /*#__PURE__*/React.createElement("a", {
|
|
20
|
+
href: url,
|
|
21
|
+
rel: "noopener noreferrer",
|
|
22
|
+
target: "_blank"
|
|
23
|
+
}, "Original")), showChangeButton && /*#__PURE__*/React.createElement("div", {
|
|
24
|
+
className: "preview__change-button"
|
|
25
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
26
|
+
onClick: handleChangeFile
|
|
27
|
+
}, "Change file")))), children);
|
|
28
|
+
Image.propTypes = {
|
|
29
|
+
url: PropTypes.string.isRequired,
|
|
30
|
+
name: PropTypes.string.isRequired,
|
|
31
|
+
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
|
|
32
|
+
handleChangeFile: PropTypes.func,
|
|
33
|
+
showChangeButton: PropTypes.bool
|
|
34
|
+
};
|
|
35
|
+
Image.defaultProps = {
|
|
36
|
+
handleChangeFile: () => {},
|
|
37
|
+
showChangeButton: false
|
|
38
|
+
};
|
|
39
|
+
export { Image };
|
|
40
|
+
//# sourceMappingURL=Image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Image.js","names":["React","PropTypes","Button","Image","url","name","children","handleChangeFile","showChangeButton","createElement","className","src","alt","href","rel","target","onClick","propTypes","string","isRequired","oneOfType","arrayOf","node","func","bool","defaultProps"],"sources":["../../../../src/components/FilePreview/Image/Image.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport Button from '@blaze-react/button';\n\nconst Image = ({ url, name, children, handleChangeFile, showChangeButton }) => (\n <div className=\"preview\">\n <div className=\"preview__file preview__file--image\">\n <img src={url} alt={name} />\n <div className=\"preview__details preview__details--file\">\n <p>\n <strong>File details</strong>\n <a href={url} rel=\"noopener noreferrer\" target=\"_blank\">\n Original\n </a>\n </p>\n {showChangeButton && (\n <div className=\"preview__change-button\">\n <Button onClick={handleChangeFile}>Change file</Button>\n </div>\n )}\n </div>\n </div>\n {children}\n </div>\n);\n\nImage.propTypes = {\n url: PropTypes.string.isRequired,\n name: PropTypes.string.isRequired,\n children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,\n handleChangeFile: PropTypes.func,\n showChangeButton: PropTypes.bool\n};\n\nImage.defaultProps = {\n handleChangeFile: () => {},\n showChangeButton: false\n};\n\nexport { Image };\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,MAAM,MAAM,qBAAqB;AAExC,MAAMC,KAAK,GAAGA,CAAC;EAAEC,GAAG;EAAEC,IAAI;EAAEC,QAAQ;EAAEC,gBAAgB;EAAEC;AAAiB,CAAC,kBACxER,KAAA,CAAAS,aAAA;EAAKC,SAAS,EAAC;AAAS,gBACtBV,KAAA,CAAAS,aAAA;EAAKC,SAAS,EAAC;AAAoC,gBACjDV,KAAA,CAAAS,aAAA;EAAKE,GAAG,EAAEP,GAAI;EAACQ,GAAG,EAAEP;AAAK,CAAE,CAAC,eAC5BL,KAAA,CAAAS,aAAA;EAAKC,SAAS,EAAC;AAAyC,gBACtDV,KAAA,CAAAS,aAAA,yBACET,KAAA,CAAAS,aAAA,iBAAQ,cAAoB,CAAC,eAC7BT,KAAA,CAAAS,aAAA;EAAGI,IAAI,EAAET,GAAI;EAACU,GAAG,EAAC,qBAAqB;EAACC,MAAM,EAAC;AAAQ,GAAC,UAErD,CACF,CAAC,EACHP,gBAAgB,iBACfR,KAAA,CAAAS,aAAA;EAAKC,SAAS,EAAC;AAAwB,gBACrCV,KAAA,CAAAS,aAAA,CAACP,MAAM;EAACc,OAAO,EAAET;AAAiB,GAAC,aAAmB,CACnD,CAEJ,CACF,CAAC,EACLD,QACE,CACN;AAEDH,KAAK,CAACc,SAAS,GAAG;EAChBb,GAAG,EAAEH,SAAS,CAACiB,MAAM,CAACC,UAAU;EAChCd,IAAI,EAAEJ,SAAS,CAACiB,MAAM,CAACC,UAAU;EACjCb,QAAQ,EAAEL,SAAS,CAACmB,SAAS,CAAC,CAACnB,SAAS,CAACoB,OAAO,CAACpB,SAAS,CAACqB,IAAI,CAAC,EAAErB,SAAS,CAACqB,IAAI,CAAC,CAAC,CAACH,UAAU;EAC7FZ,gBAAgB,EAAEN,SAAS,CAACsB,IAAI;EAChCf,gBAAgB,EAAEP,SAAS,CAACuB;AAC9B,CAAC;AAEDrB,KAAK,CAACsB,YAAY,GAAG;EACnBlB,gBAAgB,EAAEA,CAAA,KAAM,CAAC,CAAC;EAC1BC,gBAAgB,EAAE;AACpB,CAAC;AAED,SAASL,KAAK","ignoreList":[]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import Actions from '../Actions';
|
|
4
|
+
const RawImage = ({
|
|
5
|
+
url,
|
|
6
|
+
name,
|
|
7
|
+
file
|
|
8
|
+
}) => /*#__PURE__*/React.createElement("div", {
|
|
9
|
+
className: "FilePreview"
|
|
10
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
11
|
+
className: "FilePreviewItem"
|
|
12
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
13
|
+
className: "FilePreviewItem__wrapper"
|
|
14
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
15
|
+
className: "FilePreviewItem__wrapper__image",
|
|
16
|
+
src: url,
|
|
17
|
+
alt: name
|
|
18
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
19
|
+
className: "FilePreviewItem__info"
|
|
20
|
+
}, /*#__PURE__*/React.createElement("p", {
|
|
21
|
+
className: "FilePreviewItem__info__fileName"
|
|
22
|
+
}, name), /*#__PURE__*/React.createElement(Actions, {
|
|
23
|
+
file: file
|
|
24
|
+
}))));
|
|
25
|
+
RawImage.propTypes = {
|
|
26
|
+
url: PropTypes.string.isRequired,
|
|
27
|
+
name: PropTypes.string.isRequired,
|
|
28
|
+
file: PropTypes.object.isRequired
|
|
29
|
+
};
|
|
30
|
+
export { RawImage };
|
|
31
|
+
//# sourceMappingURL=RawImage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RawImage.js","names":["React","PropTypes","Actions","RawImage","url","name","file","createElement","className","src","alt","propTypes","string","isRequired","object"],"sources":["../../../../src/components/FilePreview/Image/RawImage.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport Actions from '../Actions';\n\nconst RawImage = ({ url, name, file }) => (\n <div className=\"FilePreview\">\n <div className=\"FilePreviewItem\">\n <div className=\"FilePreviewItem__wrapper\">\n <img className=\"FilePreviewItem__wrapper__image\" src={url} alt={name} />\n </div>\n <div className=\"FilePreviewItem__info\">\n <p className=\"FilePreviewItem__info__fileName\">{name}</p>\n <Actions file={file} />\n </div>\n </div>\n </div>\n);\n\nRawImage.propTypes = {\n url: PropTypes.string.isRequired,\n name: PropTypes.string.isRequired,\n file: PropTypes.object.isRequired\n};\n\nexport { RawImage };\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,OAAO,MAAM,YAAY;AAEhC,MAAMC,QAAQ,GAAGA,CAAC;EAAEC,GAAG;EAAEC,IAAI;EAAEC;AAAK,CAAC,kBACnCN,KAAA,CAAAO,aAAA;EAAKC,SAAS,EAAC;AAAa,gBAC1BR,KAAA,CAAAO,aAAA;EAAKC,SAAS,EAAC;AAAiB,gBAC9BR,KAAA,CAAAO,aAAA;EAAKC,SAAS,EAAC;AAA0B,gBACvCR,KAAA,CAAAO,aAAA;EAAKC,SAAS,EAAC,iCAAiC;EAACC,GAAG,EAAEL,GAAI;EAACM,GAAG,EAAEL;AAAK,CAAE,CACpE,CAAC,eACNL,KAAA,CAAAO,aAAA;EAAKC,SAAS,EAAC;AAAuB,gBACpCR,KAAA,CAAAO,aAAA;EAAGC,SAAS,EAAC;AAAiC,GAAEH,IAAQ,CAAC,eACzDL,KAAA,CAAAO,aAAA,CAACL,OAAO;EAACI,IAAI,EAAEA;AAAK,CAAE,CACnB,CACF,CACF,CACN;AAEDH,QAAQ,CAACQ,SAAS,GAAG;EACnBP,GAAG,EAAEH,SAAS,CAACW,MAAM,CAACC,UAAU;EAChCR,IAAI,EAAEJ,SAAS,CAACW,MAAM,CAACC,UAAU;EACjCP,IAAI,EAAEL,SAAS,CAACa,MAAM,CAACD;AACzB,CAAC;AAED,SAASV,QAAQ","ignoreList":[]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const imageSchema = {
|
|
2
|
+
settings: {},
|
|
3
|
+
formSchema: {
|
|
4
|
+
properties: {
|
|
5
|
+
name: {
|
|
6
|
+
type: 'string',
|
|
7
|
+
showInForm: true,
|
|
8
|
+
label: 'File name',
|
|
9
|
+
formFieldType: 'text',
|
|
10
|
+
formPriority: 1.0
|
|
11
|
+
},
|
|
12
|
+
storeKey: {
|
|
13
|
+
type: 'string',
|
|
14
|
+
showInForm: true,
|
|
15
|
+
label: 'Store type',
|
|
16
|
+
formFieldType: 'select',
|
|
17
|
+
formPriority: 2.0,
|
|
18
|
+
description: 'Please select store type',
|
|
19
|
+
options: []
|
|
20
|
+
},
|
|
21
|
+
altText: {
|
|
22
|
+
type: 'string',
|
|
23
|
+
showInForm: true,
|
|
24
|
+
label: 'Alt text',
|
|
25
|
+
formFieldType: 'text',
|
|
26
|
+
formPriority: 3.0
|
|
27
|
+
},
|
|
28
|
+
caption: {
|
|
29
|
+
type: 'string',
|
|
30
|
+
showInForm: true,
|
|
31
|
+
formFieldType: 'text',
|
|
32
|
+
formPriority: 4.0
|
|
33
|
+
},
|
|
34
|
+
credits: {
|
|
35
|
+
type: 'string',
|
|
36
|
+
showInForm: true,
|
|
37
|
+
formFieldType: 'text',
|
|
38
|
+
formPriority: 5.0
|
|
39
|
+
},
|
|
40
|
+
hrefUrl: {
|
|
41
|
+
type: 'string',
|
|
42
|
+
format: 'uri-template',
|
|
43
|
+
label: 'Image hyperlink',
|
|
44
|
+
showInForm: true,
|
|
45
|
+
formFieldType: 'text',
|
|
46
|
+
description: 'Url format is not valid'
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
required: ['name']
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
export { imageSchema };
|
|
53
|
+
//# sourceMappingURL=imageSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imageSchema.js","names":["imageSchema","settings","formSchema","properties","name","type","showInForm","label","formFieldType","formPriority","storeKey","description","options","altText","caption","credits","hrefUrl","format","required"],"sources":["../../../../src/components/FilePreview/Image/imageSchema.js"],"sourcesContent":["const imageSchema = {\n settings: {},\n formSchema: {\n properties: {\n name: {\n type: 'string',\n showInForm: true,\n label: 'File name',\n formFieldType: 'text',\n formPriority: 1.0\n },\n storeKey: {\n type: 'string',\n showInForm: true,\n label: 'Store type',\n formFieldType: 'select',\n formPriority: 2.0,\n description: 'Please select store type',\n options: []\n },\n altText: {\n type: 'string',\n showInForm: true,\n label: 'Alt text',\n formFieldType: 'text',\n formPriority: 3.0\n },\n caption: {\n type: 'string',\n showInForm: true,\n formFieldType: 'text',\n formPriority: 4.0\n },\n credits: {\n type: 'string',\n showInForm: true,\n formFieldType: 'text',\n formPriority: 5.0\n },\n hrefUrl: {\n type: 'string',\n format: 'uri-template',\n label: 'Image hyperlink',\n showInForm: true,\n formFieldType: 'text',\n description: 'Url format is not valid'\n }\n },\n required: ['name']\n }\n};\n\nexport { imageSchema };\n"],"mappings":"AAAA,MAAMA,WAAW,GAAG;EAClBC,QAAQ,EAAE,CAAC,CAAC;EACZC,UAAU,EAAE;IACVC,UAAU,EAAE;MACVC,IAAI,EAAE;QACJC,IAAI,EAAE,QAAQ;QACdC,UAAU,EAAE,IAAI;QAChBC,KAAK,EAAE,WAAW;QAClBC,aAAa,EAAE,MAAM;QACrBC,YAAY,EAAE;MAChB,CAAC;MACDC,QAAQ,EAAE;QACRL,IAAI,EAAE,QAAQ;QACdC,UAAU,EAAE,IAAI;QAChBC,KAAK,EAAE,YAAY;QACnBC,aAAa,EAAE,QAAQ;QACvBC,YAAY,EAAE,GAAG;QACjBE,WAAW,EAAE,0BAA0B;QACvCC,OAAO,EAAE;MACX,CAAC;MACDC,OAAO,EAAE;QACPR,IAAI,EAAE,QAAQ;QACdC,UAAU,EAAE,IAAI;QAChBC,KAAK,EAAE,UAAU;QACjBC,aAAa,EAAE,MAAM;QACrBC,YAAY,EAAE;MAChB,CAAC;MACDK,OAAO,EAAE;QACPT,IAAI,EAAE,QAAQ;QACdC,UAAU,EAAE,IAAI;QAChBE,aAAa,EAAE,MAAM;QACrBC,YAAY,EAAE;MAChB,CAAC;MACDM,OAAO,EAAE;QACPV,IAAI,EAAE,QAAQ;QACdC,UAAU,EAAE,IAAI;QAChBE,aAAa,EAAE,MAAM;QACrBC,YAAY,EAAE;MAChB,CAAC;MACDO,OAAO,EAAE;QACPX,IAAI,EAAE,QAAQ;QACdY,MAAM,EAAE,cAAc;QACtBV,KAAK,EAAE,iBAAiB;QACxBD,UAAU,EAAE,IAAI;QAChBE,aAAa,EAAE,MAAM;QACrBG,WAAW,EAAE;MACf;IACF,CAAC;IACDO,QAAQ,EAAE,CAAC,MAAM;EACnB;AACF,CAAC;AAED,SAASlB,WAAW","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RawImage } from './RawImage';
|
|
2
|
+
import { Image } from './Image';
|
|
3
|
+
import { imageSchema } from './imageSchema';
|
|
4
|
+
const image = {
|
|
5
|
+
component: {
|
|
6
|
+
card: Image,
|
|
7
|
+
raw: RawImage
|
|
8
|
+
},
|
|
9
|
+
schema: imageSchema
|
|
10
|
+
};
|
|
11
|
+
export { image };
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["RawImage","Image","imageSchema","image","component","card","raw","schema"],"sources":["../../../../src/components/FilePreview/Image/index.js"],"sourcesContent":["import { RawImage } from './RawImage';\nimport { Image } from './Image';\nimport { imageSchema } from './imageSchema';\n\nconst image = {\n component: {\n card: Image,\n raw: RawImage\n },\n schema: imageSchema\n};\nexport { image };\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,YAAY;AACrC,SAASC,KAAK,QAAQ,SAAS;AAC/B,SAASC,WAAW,QAAQ,eAAe;AAE3C,MAAMC,KAAK,GAAG;EACZC,SAAS,EAAE;IACTC,IAAI,EAAEJ,KAAK;IACXK,GAAG,EAAEN;EACP,CAAC;EACDO,MAAM,EAAEL;AACV,CAAC;AACD,SAASC,KAAK","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModalContext.js","names":["createContext","ModalContext"],"sources":["../../../src/components/FilePreview/ModalContext.js"],"sourcesContent":["import { createContext } from 'react';\n\nexport const ModalContext = createContext(false);\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,OAAO;AAErC,OAAO,MAAMC,YAAY,GAAGD,aAAa,CAAC,KAAK,CAAC","ignoreList":[]}
|