@blaze-cms/plugin-media-ui 0.146.0-core-styles.66 → 0.146.0-core-styles.67
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 +13 -0
- package/lib/components/CardMedia/CardMedia.js +28 -28
- package/lib/components/CardMedia/CardMedia.js.map +1 -1
- package/lib/components/EditMediaFile/EditMediaFile.js +8 -6
- package/lib/components/EditMediaFile/EditMediaFile.js.map +1 -1
- package/lib/components/EditMediaFile/EditMediaFilePage.js +14 -14
- package/lib/components/EditMediaFile/EditMediaFilePage.js.map +1 -1
- package/lib/components/FileList/useGetFiles/getFiles.js +5 -6
- package/lib/components/FileList/useGetFiles/getFiles.js.map +1 -1
- package/lib/components/FileList/useGetFiles/useGetFiles.js +12 -13
- package/lib/components/FileList/useGetFiles/useGetFiles.js.map +1 -1
- package/lib/components/FileList/useGetFilesList/getCounters.js +5 -5
- package/lib/components/FileList/useGetFilesList/getCounters.js.map +1 -1
- package/lib/components/FileList/useGetFilesList/useGetFilesList.js +3 -4
- package/lib/components/FileList/useGetFilesList/useGetFilesList.js.map +1 -1
- package/lib/components/FilePreview/Actions/index.js +2 -1
- package/lib/components/FilePreview/Actions/index.js.map +1 -1
- package/lib/components/FilePreview/Image/Image.js.map +1 -1
- package/lib/components/FilePreview/Image/imageSchema.js +1 -1
- package/lib/components/FilePreview/Image/imageSchema.js.map +1 -1
- package/lib/components/FilePreview/index.js.map +1 -1
- package/lib/components/FilePreviewReadOnly/FilePreviewList.js +0 -1
- package/lib/components/FilePreviewReadOnly/FilePreviewList.js.map +1 -1
- package/lib/components/FilePreviewReadOnly/FilePreviewReadOnly.js +12 -11
- package/lib/components/FilePreviewReadOnly/FilePreviewReadOnly.js.map +1 -1
- package/lib/components/FileUploadAdapter/FileList.js +2 -1
- package/lib/components/FileUploadAdapter/FileList.js.map +1 -1
- package/lib/components/FileUploadAdapter/FilePreviewList.js +0 -1
- package/lib/components/FileUploadAdapter/FilePreviewList.js.map +1 -1
- package/lib/components/FileUploadAdapter/FileReorderList.js.map +1 -1
- package/lib/components/FileUploadAdapter/FileUploadAdapter.js +67 -59
- package/lib/components/FileUploadAdapter/FileUploadAdapter.js.map +1 -1
- package/lib/components/FileUploadAdapter/mappers/get-number-files-pending-to-fetch.js +5 -4
- package/lib/components/FileUploadAdapter/mappers/get-number-files-pending-to-fetch.js.map +1 -1
- package/lib/components/FileUploadModal/FileUploadModal.js +15 -14
- package/lib/components/FileUploadModal/FileUploadModal.js.map +1 -1
- package/lib/components/FilterPanel/FilterPanel.js +2 -1
- package/lib/components/FilterPanel/FilterPanel.js.map +1 -1
- package/lib/components/ListingContainer/Listing/Listing.js.map +1 -1
- package/lib/components/ListingContainer/Listing/MediaListing/MediaFileList/MediaFileList.js +2 -1
- package/lib/components/ListingContainer/Listing/MediaListing/MediaFileList/MediaFileList.js.map +1 -1
- package/lib/components/ListingContainer/Listing/MediaListing/MediaListing.js +2 -1
- package/lib/components/ListingContainer/Listing/MediaListing/MediaListing.js.map +1 -1
- package/lib/components/ListingContainer/ListingContainer.js +2 -1
- package/lib/components/ListingContainer/ListingContainer.js.map +1 -1
- package/lib/components/MediaListing.js +2 -1
- package/lib/components/MediaListing.js.map +1 -1
- package/lib/index.js +8 -7
- package/lib/index.js.map +1 -1
- package/lib-es/components/CardMedia/CardMedia.js +2 -2
- package/lib-es/components/CardMedia/CardMedia.js.map +1 -1
- package/lib-es/components/EditMediaFile/EditMediaFilePage.js.map +1 -1
- package/lib-es/components/FileList/useGetFiles/getFiles.js.map +1 -1
- package/lib-es/components/FilePreview/Actions/index.js.map +1 -1
- package/lib-es/components/FilePreview/Image/imageSchema.js +1 -1
- package/lib-es/components/FilePreview/Image/imageSchema.js.map +1 -1
- package/lib-es/components/FileUploadAdapter/FileList.js.map +1 -1
- package/lib-es/components/FileUploadAdapter/FileUploadAdapter.js +13 -11
- package/lib-es/components/FileUploadAdapter/FileUploadAdapter.js.map +1 -1
- package/lib-es/components/FileUploadAdapter/mappers/get-button-text.js.map +1 -1
- package/lib-es/components/FileUploadAdapter/mappers/get-number-files-pending-to-fetch.js +5 -4
- package/lib-es/components/FileUploadAdapter/mappers/get-number-files-pending-to-fetch.js.map +1 -1
- package/lib-es/components/FileUploadModal/FileUploadModal.js.map +1 -1
- package/lib-es/components/FilterPanel/FilterPanel.js.map +1 -1
- package/lib-es/components/ListingContainer/Listing/MediaListing/MediaFileList/MediaFileList.js.map +1 -1
- package/lib-es/index.js +3 -3
- package/lib-es/index.js.map +1 -1
- package/package.json +5 -5
- package/src/components/FilePreview/Image/imageSchema.js +1 -1
- package/src/components/FileUploadAdapter/FileUploadAdapter.js +14 -11
- package/src/components/FileUploadAdapter/mappers/get-number-files-pending-to-fetch.js +6 -4
package/lib-es/components/ListingContainer/Listing/MediaListing/MediaFileList/MediaFileList.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MediaFileList.js","names":["React","useState","useEffect","PropTypes","CardPrompt","Button","VirtualList","useMediaContext","MediaContext","CardMedia","existPrevious","useFileList","MEDIA_LIST_ITEM_SIZE","MEDIA_OVER_SCAN_COUNT","AVAILABLE_FILTER_TYPES","MediaFileList","displayCardPrompt","setDisplayCardPrompt","displayLayout","wrapperRef","modalTargetRef","openEditInModal","currentListIndex","setCurrentListIndex","verifiedRanges","setVerifiedRanges","listHeight","setListHeight","queryParams","data","loading","setQueryParams","clearList","removeFile","updateFile","onClickPrompt","getSelectedFiles","selectedFiles","selectedFilter","hasFiles","files","length","where","_objectSpread","filter","storeKey","isSearch","searchTerm","handleRenderedItems","startIndex","rowsLength","loadIndex","Math","floor","includes","offset","handleListHeight","current","clientHeight","window","addEventListener","removeEventListener","searchedTerm","createElement","Fragment","className","width","height","itemCount","itemSize","overscanCount","scrollToIndex","onItemsRendered","renderItem","index","style","name","url","mimetype","id","isSelected","key","latestQueryToRefetchParams","onSelected","selected","onClick","propTypes","func","isRequired","bool","string","object","defaultProps"],"sources":["../../../../../../src/components/ListingContainer/Listing/MediaListing/MediaFileList/MediaFileList.js"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport PropTypes from 'prop-types';\nimport { CardPrompt } from '@blaze-cms/admin';\nimport Button from '@blaze-react/button';\nimport VirtualList from 'react-tiny-virtual-list';\nimport { useMediaContext, MediaContext } from '../../../../../utils/media-context';\nimport CardMedia from '../../../../CardMedia';\nimport { existPrevious } from '../../../mappers';\nimport useFileList from '../../../../FileList/useFileList';\nimport {\n MEDIA_LIST_ITEM_SIZE,\n MEDIA_OVER_SCAN_COUNT,\n AVAILABLE_FILTER_TYPES\n} from '../../../../../constants';\n\nconst MediaFileList = ({\n displayCardPrompt,\n setDisplayCardPrompt,\n displayLayout,\n wrapperRef,\n modalTargetRef,\n openEditInModal\n}) => {\n const [currentListIndex, setCurrentListIndex] = useState(1);\n const [verifiedRanges, setVerifiedRanges] = useState([]);\n const [listHeight, setListHeight] = useState(null);\n const {\n queryParams,\n data,\n loading,\n setQueryParams,\n clearList,\n removeFile,\n updateFile\n } = useFileList();\n\n const { onClickPrompt, getSelectedFiles, selectedFiles, selectedFilter } = useMediaContext(\n MediaContext\n );\n\n const hasFiles = !!data.files && !!data.files.length;\n\n useEffect(\n () => {\n if (!loading && !hasFiles) setDisplayCardPrompt(true);\n },\n [loading, hasFiles, setDisplayCardPrompt]\n );\n\n useEffect(\n () => {\n setVerifiedRanges([]);\n setCurrentListIndex(0);\n setQueryParams({\n where: {\n ...AVAILABLE_FILTER_TYPES[selectedFilter.filter],\n storeKey: selectedFilter.storeKey\n },\n isSearch: selectedFilter.isSearch,\n searchTerm: selectedFilter.searchTerm\n });\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [\n selectedFilter.filter,\n selectedFilter.storeKey,\n selectedFilter.isSearch,\n selectedFilter.searchTerm\n ]\n );\n\n const handleRenderedItems = ({ startIndex }) => {\n const rowsLength = data.files.length;\n const loadIndex = Math.floor(rowsLength / 3) - MEDIA_OVER_SCAN_COUNT;\n\n if (loadIndex > 0 && loadIndex < startIndex && !verifiedRanges.includes(loadIndex)) {\n setQueryParams({\n offset: data.files.length,\n where: {\n ...AVAILABLE_FILTER_TYPES[selectedFilter.filter],\n storeKey: selectedFilter.storeKey\n },\n isSearch: selectedFilter.isSearch,\n searchTerm: selectedFilter.searchTerm\n });\n setVerifiedRanges([...verifiedRanges, loadIndex]);\n setCurrentListIndex(startIndex + MEDIA_OVER_SCAN_COUNT);\n }\n };\n\n useEffect(\n () => {\n const handleListHeight = () => {\n setListHeight(wrapperRef.current.clientHeight - 40);\n };\n\n if (wrapperRef.current) {\n handleListHeight();\n window.addEventListener('resize', handleListHeight);\n }\n return () => {\n window.removeEventListener('resize', handleListHeight);\n };\n },\n [listHeight, wrapperRef]\n );\n\n const searchedTerm = queryParams.searchTerm && `${queryParams.searchTerm} -`;\n\n return (\n <>\n {hasFiles && (\n <>\n <p className=\"media__fileList-counter\">\n {searchedTerm} {data[selectedFilter.filter]} items\n </p>\n <VirtualList\n width=\"100%\"\n height={listHeight}\n itemCount={data.files.length}\n itemSize={MEDIA_LIST_ITEM_SIZE}\n overscanCount={MEDIA_OVER_SCAN_COUNT}\n scrollToIndex={currentListIndex}\n onItemsRendered={handleRenderedItems}\n renderItem={({ index, style }) => {\n const { name, url, mimetype, id } = data.files[index];\n const isSelected = existPrevious(selectedFiles, id);\n return (\n <div key={index} style={style} className=\"list__item--resultWrapper\">\n <CardMedia\n updateFile={updateFile}\n clearList={clearList}\n latestQueryToRefetchParams={queryParams}\n modalTargetRef={modalTargetRef}\n onSelected={getSelectedFiles}\n key={id}\n displayLayout={displayLayout}\n selected={!!isSelected}\n name={name}\n url={url}\n mimetype={mimetype}\n id={id}\n index={index}\n removeFile={removeFile}\n openEditInModal={openEditInModal}\n />\n </div>\n );\n }}\n />\n </>\n )}\n {displayCardPrompt && (\n <CardPrompt>\n <Button onClick={onClickPrompt} className=\"button button--rounded button--cta\">\n Upload\n </Button>\n </CardPrompt>\n )}\n </>\n );\n};\n\nMediaFileList.propTypes = {\n setDisplayCardPrompt: PropTypes.func.isRequired,\n displayCardPrompt: PropTypes.bool,\n displayLayout: PropTypes.string.isRequired,\n wrapperRef: PropTypes.object.isRequired,\n modalTargetRef: PropTypes.object.isRequired,\n openEditInModal: PropTypes.bool\n};\n\nMediaFileList.defaultProps = {\n displayCardPrompt: true,\n openEditInModal: false\n};\n\nexport default MediaFileList;\n"],"mappings":";;;AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,SAAS,QAAQ,OAAO;AAClD,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,UAAU,QAAQ,kBAAkB;AAC7C,OAAOC,MAAM,MAAM,qBAAqB;AACxC,OAAOC,WAAW,MAAM,yBAAyB;AACjD,SAASC,eAAe,EAAEC,YAAY,QAAQ,oCAAoC;AAClF,OAAOC,SAAS,MAAM,uBAAuB;AAC7C,SAASC,aAAa,QAAQ,kBAAkB;AAChD,OAAOC,WAAW,MAAM,kCAAkC;AAC1D,SACEC,oBAAoB,EACpBC,qBAAqB,EACrBC,sBAAsB,QACjB,0BAA0B;AAEjC,MAAMC,aAAa,GAAGA,CAAC;EACrBC,iBAAiB;EACjBC,oBAAoB;EACpBC,aAAa;EACbC,UAAU;EACVC,cAAc;EACdC;AACF,CAAC,KAAK;EACJ,MAAM,CAACC,gBAAgB,EAAEC,mBAAmB,CAAC,GAAGtB,QAAQ,CAAC,CAAC,CAAC;EAC3D,MAAM,CAACuB,cAAc,EAAEC,iBAAiB,CAAC,GAAGxB,QAAQ,CAAC,EAAE,CAAC;EACxD,MAAM,CAACyB,UAAU,EAAEC,aAAa,CAAC,GAAG1B,QAAQ,CAAC,IAAI,CAAC;EAClD,MAAM;IACJ2B,WAAW;IACXC,IAAI;IACJC,OAAO;IACPC,cAAc;IACdC,SAAS;IACTC,UAAU;IACVC;EACF,CAAC,GAAGvB,WAAW,CAAC,CAAC;EAEjB,MAAM;IAAEwB,aAAa;IAAEC,gBAAgB;IAAEC,aAAa;I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AEd,CAAC;AAEP,CAAC;AAEDlD,aAAa,CAACuE,SAAS,GAAG;EACxBrE,oBAAoB,EAAEd,SAAS,CAACoF,IAAI,CAACC,UAAU;EAC/CxE,iBAAiB,EAAEb,SAAS,CAACsF,IAAI;EACjCvE,aAAa,EAAEf,SAAS,CAACuF,MAAM,CAACF,UAAU;EAC1CrE,UAAU,EAAEhB,SAAS,CAACwF,MAAM,CAACH,UAAU;EACvCpE,cAAc,EAAEjB,SAAS,CAACwF,MAAM,CAACH,UAAU;EAC3CnE,eAAe,EAAElB,SAAS,CAACsF;AAC7B,CAAC;AAED1E,aAAa,CAAC6E,YAAY,GAAG;EAC3B5E,iBAAiB,EAAE,IAAI;EACvBK,eAAe,EAAE;AACnB,CAAC;AAED,eAAeN,aAAa","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"MediaFileList.js","names":["React","useState","useEffect","PropTypes","CardPrompt","Button","VirtualList","useMediaContext","MediaContext","CardMedia","existPrevious","useFileList","MEDIA_LIST_ITEM_SIZE","MEDIA_OVER_SCAN_COUNT","AVAILABLE_FILTER_TYPES","MediaFileList","displayCardPrompt","setDisplayCardPrompt","displayLayout","wrapperRef","modalTargetRef","openEditInModal","currentListIndex","setCurrentListIndex","verifiedRanges","setVerifiedRanges","listHeight","setListHeight","queryParams","data","loading","setQueryParams","clearList","removeFile","updateFile","onClickPrompt","getSelectedFiles","selectedFiles","selectedFilter","hasFiles","files","length","where","_objectSpread","filter","storeKey","isSearch","searchTerm","handleRenderedItems","startIndex","rowsLength","loadIndex","Math","floor","includes","offset","handleListHeight","current","clientHeight","window","addEventListener","removeEventListener","searchedTerm","createElement","Fragment","className","width","height","itemCount","itemSize","overscanCount","scrollToIndex","onItemsRendered","renderItem","index","style","name","url","mimetype","id","isSelected","key","latestQueryToRefetchParams","onSelected","selected","onClick","propTypes","func","isRequired","bool","string","object","defaultProps"],"sources":["../../../../../../src/components/ListingContainer/Listing/MediaListing/MediaFileList/MediaFileList.js"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport PropTypes from 'prop-types';\nimport { CardPrompt } from '@blaze-cms/admin';\nimport Button from '@blaze-react/button';\nimport VirtualList from 'react-tiny-virtual-list';\nimport { useMediaContext, MediaContext } from '../../../../../utils/media-context';\nimport CardMedia from '../../../../CardMedia';\nimport { existPrevious } from '../../../mappers';\nimport useFileList from '../../../../FileList/useFileList';\nimport {\n MEDIA_LIST_ITEM_SIZE,\n MEDIA_OVER_SCAN_COUNT,\n AVAILABLE_FILTER_TYPES\n} from '../../../../../constants';\n\nconst MediaFileList = ({\n displayCardPrompt,\n setDisplayCardPrompt,\n displayLayout,\n wrapperRef,\n modalTargetRef,\n openEditInModal\n}) => {\n const [currentListIndex, setCurrentListIndex] = useState(1);\n const [verifiedRanges, setVerifiedRanges] = useState([]);\n const [listHeight, setListHeight] = useState(null);\n const {\n queryParams,\n data,\n loading,\n setQueryParams,\n clearList,\n removeFile,\n updateFile\n } = useFileList();\n\n const { onClickPrompt, getSelectedFiles, selectedFiles, selectedFilter } = useMediaContext(\n MediaContext\n );\n\n const hasFiles = !!data.files && !!data.files.length;\n\n useEffect(\n () => {\n if (!loading && !hasFiles) setDisplayCardPrompt(true);\n },\n [loading, hasFiles, setDisplayCardPrompt]\n );\n\n useEffect(\n () => {\n setVerifiedRanges([]);\n setCurrentListIndex(0);\n setQueryParams({\n where: {\n ...AVAILABLE_FILTER_TYPES[selectedFilter.filter],\n storeKey: selectedFilter.storeKey\n },\n isSearch: selectedFilter.isSearch,\n searchTerm: selectedFilter.searchTerm\n });\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [\n selectedFilter.filter,\n selectedFilter.storeKey,\n selectedFilter.isSearch,\n selectedFilter.searchTerm\n ]\n );\n\n const handleRenderedItems = ({ startIndex }) => {\n const rowsLength = data.files.length;\n const loadIndex = Math.floor(rowsLength / 3) - MEDIA_OVER_SCAN_COUNT;\n\n if (loadIndex > 0 && loadIndex < startIndex && !verifiedRanges.includes(loadIndex)) {\n setQueryParams({\n offset: data.files.length,\n where: {\n ...AVAILABLE_FILTER_TYPES[selectedFilter.filter],\n storeKey: selectedFilter.storeKey\n },\n isSearch: selectedFilter.isSearch,\n searchTerm: selectedFilter.searchTerm\n });\n setVerifiedRanges([...verifiedRanges, loadIndex]);\n setCurrentListIndex(startIndex + MEDIA_OVER_SCAN_COUNT);\n }\n };\n\n useEffect(\n () => {\n const handleListHeight = () => {\n setListHeight(wrapperRef.current.clientHeight - 40);\n };\n\n if (wrapperRef.current) {\n handleListHeight();\n window.addEventListener('resize', handleListHeight);\n }\n return () => {\n window.removeEventListener('resize', handleListHeight);\n };\n },\n [listHeight, wrapperRef]\n );\n\n const searchedTerm = queryParams.searchTerm && `${queryParams.searchTerm} -`;\n\n return (\n <>\n {hasFiles && (\n <>\n <p className=\"media__fileList-counter\">\n {searchedTerm} {data[selectedFilter.filter]} items\n </p>\n <VirtualList\n width=\"100%\"\n height={listHeight}\n itemCount={data.files.length}\n itemSize={MEDIA_LIST_ITEM_SIZE}\n overscanCount={MEDIA_OVER_SCAN_COUNT}\n scrollToIndex={currentListIndex}\n onItemsRendered={handleRenderedItems}\n renderItem={({ index, style }) => {\n const { name, url, mimetype, id } = data.files[index];\n const isSelected = existPrevious(selectedFiles, id);\n return (\n <div key={index} style={style} className=\"list__item--resultWrapper\">\n <CardMedia\n updateFile={updateFile}\n clearList={clearList}\n latestQueryToRefetchParams={queryParams}\n modalTargetRef={modalTargetRef}\n onSelected={getSelectedFiles}\n key={id}\n displayLayout={displayLayout}\n selected={!!isSelected}\n name={name}\n url={url}\n mimetype={mimetype}\n id={id}\n index={index}\n removeFile={removeFile}\n openEditInModal={openEditInModal}\n />\n </div>\n );\n }}\n />\n </>\n )}\n {displayCardPrompt && (\n <CardPrompt>\n <Button onClick={onClickPrompt} className=\"button button--rounded button--cta\">\n Upload\n </Button>\n </CardPrompt>\n )}\n </>\n );\n};\n\nMediaFileList.propTypes = {\n setDisplayCardPrompt: PropTypes.func.isRequired,\n displayCardPrompt: PropTypes.bool,\n displayLayout: PropTypes.string.isRequired,\n wrapperRef: PropTypes.object.isRequired,\n modalTargetRef: PropTypes.object.isRequired,\n openEditInModal: PropTypes.bool\n};\n\nMediaFileList.defaultProps = {\n displayCardPrompt: true,\n openEditInModal: false\n};\n\nexport default MediaFileList;\n"],"mappings":";;;AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,SAAS,QAAQ,OAAO;AAClD,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,UAAU,QAAQ,kBAAkB;AAC7C,OAAOC,MAAM,MAAM,qBAAqB;AACxC,OAAOC,WAAW,MAAM,yBAAyB;AACjD,SAASC,eAAe,EAAEC,YAAY,QAAQ,oCAAoC;AAClF,OAAOC,SAAS,MAAM,uBAAuB;AAC7C,SAASC,aAAa,QAAQ,kBAAkB;AAChD,OAAOC,WAAW,MAAM,kCAAkC;AAC1D,SACEC,oBAAoB,EACpBC,qBAAqB,EACrBC,sBAAsB,QACjB,0BAA0B;AAEjC,MAAMC,aAAa,GAAGA,CAAC;EACrBC,iBAAiB;EACjBC,oBAAoB;EACpBC,aAAa;EACbC,UAAU;EACVC,cAAc;EACdC;AACF,CAAC,KAAK;EACJ,MAAM,CAACC,gBAAgB,EAAEC,mBAAmB,CAAC,GAAGtB,QAAQ,CAAC,CAAC,CAAC;EAC3D,MAAM,CAACuB,cAAc,EAAEC,iBAAiB,CAAC,GAAGxB,QAAQ,CAAC,EAAE,CAAC;EACxD,MAAM,CAACyB,UAAU,EAAEC,aAAa,CAAC,GAAG1B,QAAQ,CAAC,IAAI,CAAC;EAClD,MAAM;IACJ2B,WAAW;IACXC,IAAI;IACJC,OAAO;IACPC,cAAc;IACdC,SAAS;IACTC,UAAU;IACVC;EACF,CAAC,GAAGvB,WAAW,CAAC,CAAC;EAEjB,MAAM;IAAEwB,aAAa;IAAEC,gBAAgB;IAAEC,aAAa;IAAEC;EAAe,CAAC,GAAG/B,eAAe,CACxFC,YACF,CAAC;EAED,MAAM+B,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,oBAAoB,EAAEd,SAAS,CAACoF,IAAI,CAACC,UAAU;EAC/CxE,iBAAiB,EAAEb,SAAS,CAACsF,IAAI;EACjCvE,aAAa,EAAEf,SAAS,CAACuF,MAAM,CAACF,UAAU;EAC1CrE,UAAU,EAAEhB,SAAS,CAACwF,MAAM,CAACH,UAAU;EACvCpE,cAAc,EAAEjB,SAAS,CAACwF,MAAM,CAACH,UAAU;EAC3CnE,eAAe,EAAElB,SAAS,CAACsF;AAC7B,CAAC;AAED1E,aAAa,CAAC6E,YAAY,GAAG;EAC3B5E,iBAAiB,EAAE,IAAI;EACvBK,eAAe,EAAE;AACnB,CAAC;AAED,eAAeN,aAAa","ignoreList":[]}
|
package/lib-es/index.js
CHANGED
|
@@ -4,9 +4,9 @@ import EditorAdapter from './components/EditorAdapter';
|
|
|
4
4
|
import { MediaLibraryIcon } from './icons';
|
|
5
5
|
import pkg from '../package.json';
|
|
6
6
|
import { PLUGIN_NAME } from './constants';
|
|
7
|
-
export const FilePreviewReadOnly = React.lazy(() => import(/* webpackChunkName: 'MediaFilePreviewReadOnly' */'./components/FilePreviewReadOnly'));
|
|
8
|
-
const MediaListing = React.lazy(() => import(/* webpackChunkName: 'MediaListingContainer' */'./components/MediaListing'));
|
|
9
|
-
const EditMediaFilePage = React.lazy(() => import(/* webpackChunkName: 'EditMediaFilePage' */'./components/EditMediaFile/EditMediaFilePage'));
|
|
7
|
+
export const FilePreviewReadOnly = React.lazy(() => import( /* webpackChunkName: 'MediaFilePreviewReadOnly' */'./components/FilePreviewReadOnly'));
|
|
8
|
+
const MediaListing = React.lazy(() => import( /* webpackChunkName: 'MediaListingContainer' */'./components/MediaListing'));
|
|
9
|
+
const EditMediaFilePage = React.lazy(() => import( /* webpackChunkName: 'EditMediaFilePage' */'./components/EditMediaFile/EditMediaFilePage'));
|
|
10
10
|
export default async function load(app) {
|
|
11
11
|
app.events.once('admin:menu:config:load', ({
|
|
12
12
|
addConfig
|
package/lib-es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","FileUploadAdapter","EditorAdapter","MediaLibraryIcon","pkg","PLUGIN_NAME","FilePreviewReadOnly","lazy","MediaListing","EditMediaFilePage","load","app","events","once","addConfig","main","items","media","label","uri","icon","order","addFieldType","type","component","mediaRoute","path","key","exact","editMediaFileRoute","addRoute","name","version","pluginName"],"sources":["../src/index.js"],"sourcesContent":["import React from 'react';\nimport FileUploadAdapter from './components/FileUploadAdapter';\nimport EditorAdapter from './components/EditorAdapter';\nimport { MediaLibraryIcon } from './icons';\nimport pkg from '../package.json';\nimport { PLUGIN_NAME } from './constants';\n\nexport const FilePreviewReadOnly = React.lazy(() =>\n import(/* webpackChunkName: 'MediaFilePreviewReadOnly' */ './components/FilePreviewReadOnly')\n);\n\nconst MediaListing = React.lazy(() =>\n import(/* webpackChunkName: 'MediaListingContainer' */ './components/MediaListing')\n);\n\nconst EditMediaFilePage = React.lazy(() =>\n import(/* webpackChunkName: 'EditMediaFilePage' */ './components/EditMediaFile/EditMediaFilePage')\n);\nexport default async function load(app) {\n app.events.once('admin:menu:config:load', ({ addConfig }) => {\n addConfig({\n main: {\n items: {\n media: {\n label: 'Media',\n uri: '/media',\n icon: MediaLibraryIcon,\n order: 30\n }\n }\n }\n });\n });\n\n app.events.once('load:custom:field:type', addFieldType => {\n addFieldType({ type: 'fileUpload', component: FileUploadAdapter });\n addFieldType({ type: 'filePreview', component: FilePreviewReadOnly });\n addFieldType({ type: 'editor', component: EditorAdapter });\n });\n\n const mediaRoute = {\n path: '/media',\n key: 'media',\n component: MediaListing,\n exact: true\n };\n\n const editMediaFileRoute = {\n path: '/media/edit/:fileId',\n key: 'editMedia',\n component: EditMediaFilePage,\n exact: true\n };\n\n app.addRoute(mediaRoute);\n app.addRoute(editMediaFileRoute);\n\n return {\n name: PLUGIN_NAME,\n version: pkg.version\n };\n}\n\nload.pluginName = PLUGIN_NAME;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,iBAAiB,MAAM,gCAAgC;AAC9D,OAAOC,aAAa,MAAM,4BAA4B;AACtD,SAASC,gBAAgB,QAAQ,SAAS;AAC1C,OAAOC,GAAG,MAAM,iBAAiB;AACjC,SAASC,WAAW,QAAQ,aAAa;AAEzC,OAAO,MAAMC,mBAAmB,GAAGN,KAAK,CAACO,IAAI,CAAC,MAC5C,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","FileUploadAdapter","EditorAdapter","MediaLibraryIcon","pkg","PLUGIN_NAME","FilePreviewReadOnly","lazy","MediaListing","EditMediaFilePage","load","app","events","once","addConfig","main","items","media","label","uri","icon","order","addFieldType","type","component","mediaRoute","path","key","exact","editMediaFileRoute","addRoute","name","version","pluginName"],"sources":["../src/index.js"],"sourcesContent":["import React from 'react';\nimport FileUploadAdapter from './components/FileUploadAdapter';\nimport EditorAdapter from './components/EditorAdapter';\nimport { MediaLibraryIcon } from './icons';\nimport pkg from '../package.json';\nimport { PLUGIN_NAME } from './constants';\n\nexport const FilePreviewReadOnly = React.lazy(() =>\n import(/* webpackChunkName: 'MediaFilePreviewReadOnly' */ './components/FilePreviewReadOnly')\n);\n\nconst MediaListing = React.lazy(() =>\n import(/* webpackChunkName: 'MediaListingContainer' */ './components/MediaListing')\n);\n\nconst EditMediaFilePage = React.lazy(() =>\n import(/* webpackChunkName: 'EditMediaFilePage' */ './components/EditMediaFile/EditMediaFilePage')\n);\nexport default async function load(app) {\n app.events.once('admin:menu:config:load', ({ addConfig }) => {\n addConfig({\n main: {\n items: {\n media: {\n label: 'Media',\n uri: '/media',\n icon: MediaLibraryIcon,\n order: 30\n }\n }\n }\n });\n });\n\n app.events.once('load:custom:field:type', addFieldType => {\n addFieldType({ type: 'fileUpload', component: FileUploadAdapter });\n addFieldType({ type: 'filePreview', component: FilePreviewReadOnly });\n addFieldType({ type: 'editor', component: EditorAdapter });\n });\n\n const mediaRoute = {\n path: '/media',\n key: 'media',\n component: MediaListing,\n exact: true\n };\n\n const editMediaFileRoute = {\n path: '/media/edit/:fileId',\n key: 'editMedia',\n component: EditMediaFilePage,\n exact: true\n };\n\n app.addRoute(mediaRoute);\n app.addRoute(editMediaFileRoute);\n\n return {\n name: PLUGIN_NAME,\n version: pkg.version\n };\n}\n\nload.pluginName = PLUGIN_NAME;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,iBAAiB,MAAM,gCAAgC;AAC9D,OAAOC,aAAa,MAAM,4BAA4B;AACtD,SAASC,gBAAgB,QAAQ,SAAS;AAC1C,OAAOC,GAAG,MAAM,iBAAiB;AACjC,SAASC,WAAW,QAAQ,aAAa;AAEzC,OAAO,MAAMC,mBAAmB,GAAGN,KAAK,CAACO,IAAI,CAAC,MAC5C,MAAM,EAAC,kDAAmD,kCAAkC,CAC9F,CAAC;AAED,MAAMC,YAAY,GAAGR,KAAK,CAACO,IAAI,CAAC,MAC9B,MAAM,EAAC,+CAAgD,2BAA2B,CACpF,CAAC;AAED,MAAME,iBAAiB,GAAGT,KAAK,CAACO,IAAI,CAAC,MACnC,MAAM,EAAC,2CAA4C,8CAA8C,CACnG,CAAC;AACD,eAAe,eAAeG,IAAIA,CAACC,GAAG,EAAE;EACtCA,GAAG,CAACC,MAAM,CAACC,IAAI,CAAC,wBAAwB,EAAE,CAAC;IAAEC;EAAU,CAAC,KAAK;IAC3DA,SAAS,CAAC;MACRC,IAAI,EAAE;QACJC,KAAK,EAAE;UACLC,KAAK,EAAE;YACLC,KAAK,EAAE,OAAO;YACdC,GAAG,EAAE,QAAQ;YACbC,IAAI,EAAEjB,gBAAgB;YACtBkB,KAAK,EAAE;UACT;QACF;MACF;IACF,CAAC,CAAC;EACJ,CAAC,CAAC;EAEFV,GAAG,CAACC,MAAM,CAACC,IAAI,CAAC,wBAAwB,EAAES,YAAY,IAAI;IACxDA,YAAY,CAAC;MAAEC,IAAI,EAAE,YAAY;MAAEC,SAAS,EAAEvB;IAAkB,CAAC,CAAC;IAClEqB,YAAY,CAAC;MAAEC,IAAI,EAAE,aAAa;MAAEC,SAAS,EAAElB;IAAoB,CAAC,CAAC;IACrEgB,YAAY,CAAC;MAAEC,IAAI,EAAE,QAAQ;MAAEC,SAAS,EAAEtB;IAAc,CAAC,CAAC;EAC5D,CAAC,CAAC;EAEF,MAAMuB,UAAU,GAAG;IACjBC,IAAI,EAAE,QAAQ;IACdC,GAAG,EAAE,OAAO;IACZH,SAAS,EAAEhB,YAAY;IACvBoB,KAAK,EAAE;EACT,CAAC;EAED,MAAMC,kBAAkB,GAAG;IACzBH,IAAI,EAAE,qBAAqB;IAC3BC,GAAG,EAAE,WAAW;IAChBH,SAAS,EAAEf,iBAAiB;IAC5BmB,KAAK,EAAE;EACT,CAAC;EAEDjB,GAAG,CAACmB,QAAQ,CAACL,UAAU,CAAC;EACxBd,GAAG,CAACmB,QAAQ,CAACD,kBAAkB,CAAC;EAEhC,OAAO;IACLE,IAAI,EAAE1B,WAAW;IACjB2B,OAAO,EAAE5B,GAAG,CAAC4B;EACf,CAAC;AACH;AAEAtB,IAAI,CAACuB,UAAU,GAAG5B,WAAW","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blaze-cms/plugin-media-ui",
|
|
3
|
-
"version": "0.146.0-core-styles.
|
|
3
|
+
"version": "0.146.0-core-styles.67",
|
|
4
4
|
"description": "Blaze plugin media ui",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-es/index.js",
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@blaze-cms/admin-ui-utils": "0.146.0-core-styles.63",
|
|
31
31
|
"@blaze-cms/core-errors": "0.146.0-core-styles.52",
|
|
32
|
-
"@blaze-cms/plugin-search-ui": "0.146.0-core-styles.
|
|
33
|
-
"@blaze-cms/react-form-builder": "0.146.0-core-styles.
|
|
32
|
+
"@blaze-cms/plugin-search-ui": "0.146.0-core-styles.67",
|
|
33
|
+
"@blaze-cms/react-form-builder": "0.146.0-core-styles.67",
|
|
34
34
|
"@blaze-cms/setup-ui": "0.145.1-core-styles.0",
|
|
35
35
|
"@blaze-react/button": "0.8.0-alpha.82",
|
|
36
36
|
"@blaze-react/drafteditor": "0.7.0",
|
|
37
|
-
"@blaze-react/file-upload": "0.8.0-alpha.
|
|
37
|
+
"@blaze-react/file-upload": "0.8.0-alpha.105",
|
|
38
38
|
"@blaze-react/modal": "0.5.19",
|
|
39
39
|
"@blaze-react/more": "0.5.19",
|
|
40
40
|
"@blaze-react/toaster": "0.5.17",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"lib/*",
|
|
58
58
|
"lib-es/*"
|
|
59
59
|
],
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "87928531793cff6366d97a6f30ef46bfc358b083"
|
|
61
61
|
}
|
|
@@ -41,9 +41,9 @@ const FileUploadAdapter = ({
|
|
|
41
41
|
const [displayFileUploadModal, setDisplayFileUploadModal] = useState(false);
|
|
42
42
|
const initialValue = formatInitialValue({ value, type });
|
|
43
43
|
const [currentValue, setCurrentValue] = useState(initialValue);
|
|
44
|
-
const [currentOffset, setCurrentOffset] = useState(0);
|
|
45
44
|
const [selectedFiles, setSelectedFiles] = useState([]);
|
|
46
45
|
const [editFile, setEditFile] = useState(null);
|
|
46
|
+
const [allFilesLoaded, setAllFilesLoaded] = useState(false);
|
|
47
47
|
const client = useApolloClient();
|
|
48
48
|
const { addToast } = useToasts();
|
|
49
49
|
|
|
@@ -70,6 +70,13 @@ const FileUploadAdapter = ({
|
|
|
70
70
|
useEffect(
|
|
71
71
|
() => {
|
|
72
72
|
(async () => {
|
|
73
|
+
if (allFilesLoaded) {
|
|
74
|
+
const loadedFiles = await getFiles(0, currentValue, true);
|
|
75
|
+
const loadedOrderedFiles = orderFiles(loadedFiles, currentValue);
|
|
76
|
+
setSelectedFiles(loadedOrderedFiles);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
73
80
|
const initialFiles =
|
|
74
81
|
!selectedFiles.length && !previewAllFiles
|
|
75
82
|
? currentValue.filter((_, i) => i <= 3)
|
|
@@ -77,8 +84,8 @@ const FileUploadAdapter = ({
|
|
|
77
84
|
|
|
78
85
|
const files = await getFiles(0, initialFiles);
|
|
79
86
|
const orderedFiles = orderFiles(files, currentValue);
|
|
80
|
-
setCurrentOffset(0);
|
|
81
87
|
setSelectedFiles(orderedFiles);
|
|
88
|
+
setAllFilesLoaded(false);
|
|
82
89
|
})();
|
|
83
90
|
},
|
|
84
91
|
[currentValue] //eslint-disable-line
|
|
@@ -86,14 +93,10 @@ const FileUploadAdapter = ({
|
|
|
86
93
|
|
|
87
94
|
const fetchMore = async shouldFetchAll => {
|
|
88
95
|
if (selectedFiles.length === currentValue.length) return;
|
|
89
|
-
const
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const newFiles = [...selectedFiles, ...files];
|
|
94
|
-
const orderedFiles = orderFiles(newFiles, currentValue);
|
|
95
|
-
setSelectedFiles(orderedFiles);
|
|
96
|
-
setCurrentOffset(newOffset);
|
|
96
|
+
const newFiles = await getFiles(0, currentValue, true);
|
|
97
|
+
const newOrderedFiles = orderFiles(newFiles, currentValue);
|
|
98
|
+
setSelectedFiles(newOrderedFiles);
|
|
99
|
+
setAllFilesLoaded(true);
|
|
97
100
|
};
|
|
98
101
|
|
|
99
102
|
const handleSelectedFiles = (files, checkIsUnselecting = true) => {
|
|
@@ -162,7 +165,7 @@ const FileUploadAdapter = ({
|
|
|
162
165
|
|
|
163
166
|
const filesPending = previewAllFiles
|
|
164
167
|
? 0
|
|
165
|
-
: getNumberFilesPendingToFetch(
|
|
168
|
+
: getNumberFilesPendingToFetch(selectedFiles.length, currentValue);
|
|
166
169
|
const onOpenLibrary = () => setDisplayModal(true);
|
|
167
170
|
const handleEditModal = file => {
|
|
168
171
|
const selectedEditFile = selectedFiles.find(({ id: _id }) => _id === file.id);
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export const getNumberFilesPendingToFetch = (
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export const getNumberFilesPendingToFetch = (loadedFilesCount, currentValue) => {
|
|
2
|
+
if (loadedFilesCount >= currentValue.length) {
|
|
3
|
+
return 0;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
return currentValue.length - loadedFilesCount;
|
|
5
7
|
};
|