@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.
Files changed (164) hide show
  1. package/CHANGELOG.md +21 -66
  2. package/lib/components/EditMediaFile/EditMediaFile.js +2 -2
  3. package/lib/components/EditMediaFile/EditMediaFile.js.map +1 -1
  4. package/lib/components/EditorAdapter/EditorAdapter.js +12 -1
  5. package/lib/components/EditorAdapter/EditorAdapter.js.map +1 -1
  6. package/lib-es/components/CardMedia/CardMedia.js +233 -0
  7. package/lib-es/components/CardMedia/CardMedia.js.map +1 -0
  8. package/lib-es/components/CardMedia/index.js +3 -0
  9. package/lib-es/components/CardMedia/index.js.map +1 -0
  10. package/lib-es/components/EditMediaFile/EditMediaFile.js +187 -0
  11. package/lib-es/components/EditMediaFile/EditMediaFile.js.map +1 -0
  12. package/lib-es/components/EditMediaFile/EditMediaFilePage.js +109 -0
  13. package/lib-es/components/EditMediaFile/EditMediaFilePage.js.map +1 -0
  14. package/lib-es/components/EditMediaFile/index.js +3 -0
  15. package/lib-es/components/EditMediaFile/index.js.map +1 -0
  16. package/lib-es/components/EditorAdapter/EditorAdapter.js +59 -0
  17. package/lib-es/components/EditorAdapter/EditorAdapter.js.map +1 -0
  18. package/lib-es/components/EditorAdapter/index.js +3 -0
  19. package/lib-es/components/EditorAdapter/index.js.map +1 -0
  20. package/lib-es/components/FileList/FilesListContext/index.js +4 -0
  21. package/lib-es/components/FileList/FilesListContext/index.js.map +1 -0
  22. package/lib-es/components/FileList/FilesListProvider/index.js +36 -0
  23. package/lib-es/components/FileList/FilesListProvider/index.js.map +1 -0
  24. package/lib-es/components/FileList/useFileList/index.js +5 -0
  25. package/lib-es/components/FileList/useFileList/index.js.map +1 -0
  26. package/lib-es/components/FileList/useGetFiles/getFiles.js +179 -0
  27. package/lib-es/components/FileList/useGetFiles/getFiles.js.map +1 -0
  28. package/lib-es/components/FileList/useGetFiles/index.js +3 -0
  29. package/lib-es/components/FileList/useGetFiles/index.js.map +1 -0
  30. package/lib-es/components/FileList/useGetFiles/useGetFiles.js +114 -0
  31. package/lib-es/components/FileList/useGetFiles/useGetFiles.js.map +1 -0
  32. package/lib-es/components/FileList/useGetFilesList/getCounters.js +11 -0
  33. package/lib-es/components/FileList/useGetFilesList/getCounters.js.map +1 -0
  34. package/lib-es/components/FileList/useGetFilesList/index.js +3 -0
  35. package/lib-es/components/FileList/useGetFilesList/index.js.map +1 -0
  36. package/lib-es/components/FileList/useGetFilesList/useGetFilesList.js +172 -0
  37. package/lib-es/components/FileList/useGetFilesList/useGetFilesList.js.map +1 -0
  38. package/lib-es/components/FilePreview/Actions/index.js +38 -0
  39. package/lib-es/components/FilePreview/Actions/index.js.map +1 -0
  40. package/lib-es/components/FilePreview/Image/Image.js +40 -0
  41. package/lib-es/components/FilePreview/Image/Image.js.map +1 -0
  42. package/lib-es/components/FilePreview/Image/RawImage.js +31 -0
  43. package/lib-es/components/FilePreview/Image/RawImage.js.map +1 -0
  44. package/lib-es/components/FilePreview/Image/imageSchema.js +53 -0
  45. package/lib-es/components/FilePreview/Image/imageSchema.js.map +1 -0
  46. package/lib-es/components/FilePreview/Image/index.js +12 -0
  47. package/lib-es/components/FilePreview/Image/index.js.map +1 -0
  48. package/lib-es/components/FilePreview/ModalContext.js +3 -0
  49. package/lib-es/components/FilePreview/ModalContext.js.map +1 -0
  50. package/lib-es/components/FilePreview/PDF/PDF.js +49 -0
  51. package/lib-es/components/FilePreview/PDF/PDF.js.map +1 -0
  52. package/lib-es/components/FilePreview/PDF/RawPDF.js +33 -0
  53. package/lib-es/components/FilePreview/PDF/RawPDF.js.map +1 -0
  54. package/lib-es/components/FilePreview/PDF/index.js +12 -0
  55. package/lib-es/components/FilePreview/PDF/index.js.map +1 -0
  56. package/lib-es/components/FilePreview/PDF/schema.js +21 -0
  57. package/lib-es/components/FilePreview/PDF/schema.js.map +1 -0
  58. package/lib-es/components/FilePreview/get-preview.js +28 -0
  59. package/lib-es/components/FilePreview/get-preview.js.map +1 -0
  60. package/lib-es/components/FilePreview/index.js +104 -0
  61. package/lib-es/components/FilePreview/index.js.map +1 -0
  62. package/lib-es/components/FilePreview/previewDefault/PreviewDefault.js +41 -0
  63. package/lib-es/components/FilePreview/previewDefault/PreviewDefault.js.map +1 -0
  64. package/lib-es/components/FilePreview/previewDefault/RawPreviewDefault.js +39 -0
  65. package/lib-es/components/FilePreview/previewDefault/RawPreviewDefault.js.map +1 -0
  66. package/lib-es/components/FilePreview/previewDefault/icons/DefaultIcon.js +121 -0
  67. package/lib-es/components/FilePreview/previewDefault/icons/DefaultIcon.js.map +1 -0
  68. package/lib-es/components/FilePreview/previewDefault/icons/index.js +3 -0
  69. package/lib-es/components/FilePreview/previewDefault/icons/index.js.map +1 -0
  70. package/lib-es/components/FilePreview/previewDefault/index.js +12 -0
  71. package/lib-es/components/FilePreview/previewDefault/index.js.map +1 -0
  72. package/lib-es/components/FilePreview/previewDefault/previewDefaultSchema.js +25 -0
  73. package/lib-es/components/FilePreview/previewDefault/previewDefaultSchema.js.map +1 -0
  74. package/lib-es/components/FilePreviewReadOnly/FileList.js +18 -0
  75. package/lib-es/components/FilePreviewReadOnly/FileList.js.map +1 -0
  76. package/lib-es/components/FilePreviewReadOnly/FilePreviewList.js +22 -0
  77. package/lib-es/components/FilePreviewReadOnly/FilePreviewList.js.map +1 -0
  78. package/lib-es/components/FilePreviewReadOnly/FilePreviewReadOnly.js +68 -0
  79. package/lib-es/components/FilePreviewReadOnly/FilePreviewReadOnly.js.map +1 -0
  80. package/lib-es/components/FilePreviewReadOnly/index.js +3 -0
  81. package/lib-es/components/FilePreviewReadOnly/index.js.map +1 -0
  82. package/lib-es/components/FilePreviewReadOnly/mappers/format-initial-value.js +11 -0
  83. package/lib-es/components/FilePreviewReadOnly/mappers/format-initial-value.js.map +1 -0
  84. package/lib-es/components/FilePreviewReadOnly/mappers/index.js +3 -0
  85. package/lib-es/components/FilePreviewReadOnly/mappers/index.js.map +1 -0
  86. package/lib-es/components/FileUploadAdapter/FileList.js +52 -0
  87. package/lib-es/components/FileUploadAdapter/FileList.js.map +1 -0
  88. package/lib-es/components/FileUploadAdapter/FilePreviewList.js +22 -0
  89. package/lib-es/components/FileUploadAdapter/FilePreviewList.js.map +1 -0
  90. package/lib-es/components/FileUploadAdapter/FileReorderList.js +32 -0
  91. package/lib-es/components/FileUploadAdapter/FileReorderList.js.map +1 -0
  92. package/lib-es/components/FileUploadAdapter/FileReorderListItem.js +24 -0
  93. package/lib-es/components/FileUploadAdapter/FileReorderListItem.js.map +1 -0
  94. package/lib-es/components/FileUploadAdapter/FileUploadAdapter.js +391 -0
  95. package/lib-es/components/FileUploadAdapter/FileUploadAdapter.js.map +1 -0
  96. package/lib-es/components/FileUploadAdapter/index.js +3 -0
  97. package/lib-es/components/FileUploadAdapter/index.js.map +1 -0
  98. package/lib-es/components/FileUploadAdapter/mappers/format-initial-value.js +11 -0
  99. package/lib-es/components/FileUploadAdapter/mappers/format-initial-value.js.map +1 -0
  100. package/lib-es/components/FileUploadAdapter/mappers/get-button-text.js +11 -0
  101. package/lib-es/components/FileUploadAdapter/mappers/get-button-text.js.map +1 -0
  102. package/lib-es/components/FileUploadAdapter/mappers/get-format.js +12 -0
  103. package/lib-es/components/FileUploadAdapter/mappers/get-format.js.map +1 -0
  104. package/lib-es/components/FileUploadAdapter/mappers/get-number-files-pending-to-fetch.js +7 -0
  105. package/lib-es/components/FileUploadAdapter/mappers/get-number-files-pending-to-fetch.js.map +1 -0
  106. package/lib-es/components/FileUploadAdapter/mappers/index.js +8 -0
  107. package/lib-es/components/FileUploadAdapter/mappers/index.js.map +1 -0
  108. package/lib-es/components/FileUploadAdapter/mappers/is-unselecting.js +2 -0
  109. package/lib-es/components/FileUploadAdapter/mappers/is-unselecting.js.map +1 -0
  110. package/lib-es/components/FileUploadAdapter/mappers/transform-to-array.js +2 -0
  111. package/lib-es/components/FileUploadAdapter/mappers/transform-to-array.js.map +1 -0
  112. package/lib-es/components/FileUploadAdapter/useLimit.js +13 -0
  113. package/lib-es/components/FileUploadAdapter/useLimit.js.map +1 -0
  114. package/lib-es/components/FileUploadModal/FileUploadModal.js +178 -0
  115. package/lib-es/components/FileUploadModal/FileUploadModal.js.map +1 -0
  116. package/lib-es/components/FileUploadModal/index.js +3 -0
  117. package/lib-es/components/FileUploadModal/index.js.map +1 -0
  118. package/lib-es/components/FilterPanel/FilterPanel.js +135 -0
  119. package/lib-es/components/FilterPanel/FilterPanel.js.map +1 -0
  120. package/lib-es/components/FilterPanel/index.js +3 -0
  121. package/lib-es/components/FilterPanel/index.js.map +1 -0
  122. package/lib-es/components/ListingContainer/Listing/Listing.js +70 -0
  123. package/lib-es/components/ListingContainer/Listing/Listing.js.map +1 -0
  124. package/lib-es/components/ListingContainer/Listing/MediaListing/MediaFileList/MediaFileList.js +153 -0
  125. package/lib-es/components/ListingContainer/Listing/MediaListing/MediaFileList/MediaFileList.js.map +1 -0
  126. package/lib-es/components/ListingContainer/Listing/MediaListing/MediaFileList/index.js +3 -0
  127. package/lib-es/components/ListingContainer/Listing/MediaListing/MediaFileList/index.js.map +1 -0
  128. package/lib-es/components/ListingContainer/Listing/MediaListing/MediaListing.js +33 -0
  129. package/lib-es/components/ListingContainer/Listing/MediaListing/MediaListing.js.map +1 -0
  130. package/lib-es/components/ListingContainer/Listing/MediaListing/index.js +3 -0
  131. package/lib-es/components/ListingContainer/Listing/MediaListing/index.js.map +1 -0
  132. package/lib-es/components/ListingContainer/Listing/index.js +3 -0
  133. package/lib-es/components/ListingContainer/Listing/index.js.map +1 -0
  134. package/lib-es/components/ListingContainer/ListingContainer.js +115 -0
  135. package/lib-es/components/ListingContainer/ListingContainer.js.map +1 -0
  136. package/lib-es/components/ListingContainer/index.js +3 -0
  137. package/lib-es/components/ListingContainer/index.js.map +1 -0
  138. package/lib-es/components/ListingContainer/mappers/exist-previous.js +3 -0
  139. package/lib-es/components/ListingContainer/mappers/exist-previous.js.map +1 -0
  140. package/lib-es/components/ListingContainer/mappers/index.js +3 -0
  141. package/lib-es/components/ListingContainer/mappers/index.js.map +1 -0
  142. package/lib-es/components/MediaListing.js +29 -0
  143. package/lib-es/components/MediaListing.js.map +1 -0
  144. package/lib-es/constants.js +36 -0
  145. package/lib-es/constants.js.map +1 -0
  146. package/lib-es/icons/MediaLibraryIcon.js +70 -0
  147. package/lib-es/icons/MediaLibraryIcon.js.map +1 -0
  148. package/lib-es/icons/index.js +3 -0
  149. package/lib-es/icons/index.js.map +1 -0
  150. package/lib-es/index.js +61 -0
  151. package/lib-es/index.js.map +1 -0
  152. package/lib-es/utils/available-filters/available-filters.js +26 -0
  153. package/lib-es/utils/available-filters/available-filters.js.map +1 -0
  154. package/lib-es/utils/bustUrl.js +7 -0
  155. package/lib-es/utils/bustUrl.js.map +1 -0
  156. package/lib-es/utils/media-context/index.js +4 -0
  157. package/lib-es/utils/media-context/index.js.map +1 -0
  158. package/lib-es/utils/media-context/media-context.js +6 -0
  159. package/lib-es/utils/media-context/media-context.js.map +1 -0
  160. package/lib-es/utils/media-context/useMediaContext.js +4 -0
  161. package/lib-es/utils/media-context/useMediaContext.js.map +1 -0
  162. package/package.json +9 -8
  163. package/src/components/EditMediaFile/EditMediaFile.js +3 -1
  164. package/src/components/EditorAdapter/EditorAdapter.js +12 -0
@@ -0,0 +1,391 @@
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 React, { useState, useContext, useEffect } from 'react';
5
+ import FileUpload from '@blaze-react/file-upload';
6
+ import PropTypes from 'prop-types';
7
+ import { useApolloClient } from '@apollo/client';
8
+ import { getQuery, getMutation, ModalAdapter as Modal } from '@blaze-cms/admin-ui-utils';
9
+ import { parseFormValues } from '@blaze-cms/react-form-builder';
10
+ import { useToasts } from '@blaze-react/toaster';
11
+ import Tooltip from '@blaze-react/tooltip';
12
+ import { MORE } from '../../constants';
13
+ import ListingContainer from '../ListingContainer';
14
+ import { MediaContextProvider } from '../../utils/media-context';
15
+ import FileList from './FileList';
16
+ import useLimit from './useLimit';
17
+ import { getFormat, formatInitialValue, transformToArray, isUnselecting, getButtonText, getNumberFilesPendingToFetch } from './mappers';
18
+ import FilePreview from '../FilePreview';
19
+ const FileUploadAdapter = ({
20
+ onChange,
21
+ label,
22
+ id,
23
+ type,
24
+ value,
25
+ maxItems,
26
+ shouldRenderInPreview,
27
+ canDragAndDrop,
28
+ simpleLayout,
29
+ tooltip,
30
+ previewAllFiles,
31
+ disableFilePreview,
32
+ fileType,
33
+ storeKey
34
+ }) => {
35
+ const {
36
+ InjectPreview
37
+ } = useContext(FileUploadAdapter.FormContext);
38
+ const [currentLimit] = useLimit(maxItems);
39
+ const [displayModal, setDisplayModal] = useState(false);
40
+ const [displayFileUploadModal, setDisplayFileUploadModal] = useState(false);
41
+ const initialValue = formatInitialValue({
42
+ value,
43
+ type
44
+ });
45
+ const [currentValue, setCurrentValue] = useState(initialValue);
46
+ const [selectedFiles, setSelectedFiles] = useState([]);
47
+ const [editFile, setEditFile] = useState(null);
48
+ const [allFilesLoaded, setAllFilesLoaded] = useState(false);
49
+ const client = useApolloClient();
50
+ const {
51
+ addToast
52
+ } = useToasts();
53
+ const getFiles = async (offset, ids, fetchAll = previewAllFiles) => {
54
+ const {
55
+ data: {
56
+ files: newFiles
57
+ }
58
+ } = await client.query({
59
+ query: getQuery('GET_FILES'),
60
+ variables: {
61
+ limit: fetchAll ? 0 : 4,
62
+ offset,
63
+ where: {
64
+ id: {
65
+ _in: ids
66
+ }
67
+ }
68
+ },
69
+ skip: !currentValue.length,
70
+ fetchPolicy: 'network-only'
71
+ });
72
+ return newFiles;
73
+ };
74
+ useEffect(() => {
75
+ (async () => {
76
+ if (allFilesLoaded) {
77
+ const loadedFiles = await getFiles(0, currentValue, true);
78
+ const loadedOrderedFiles = orderFiles(loadedFiles, currentValue);
79
+ setSelectedFiles(loadedOrderedFiles);
80
+ return;
81
+ }
82
+ const initialFiles = !selectedFiles.length && !previewAllFiles ? currentValue.filter((_, i) => i <= 3) : currentValue;
83
+ const files = await getFiles(0, initialFiles);
84
+ const orderedFiles = orderFiles(files, currentValue);
85
+ setSelectedFiles(orderedFiles);
86
+ setAllFilesLoaded(false);
87
+ })();
88
+ }, [currentValue] //eslint-disable-line
89
+ );
90
+ const fetchMore = async shouldFetchAll => {
91
+ if (selectedFiles.length === currentValue.length) return;
92
+ const newFiles = await getFiles(0, currentValue, true);
93
+ const newOrderedFiles = orderFiles(newFiles, currentValue);
94
+ setSelectedFiles(newOrderedFiles);
95
+ setAllFilesLoaded(true);
96
+ };
97
+ const handleSelectedFiles = (files, checkIsUnselecting = true) => {
98
+ const isUnselectingFile = isUnselecting(value, checkIsUnselecting, files);
99
+ if (isUnselectingFile) {
100
+ const valueArray = transformToArray(value);
101
+ const selectedFilesIds = valueArray.filter(valueId => !files.includes(valueId));
102
+ const parsedValue = getFormat(type, {
103
+ filesIds: selectedFilesIds
104
+ });
105
+ setCurrentValue(selectedFilesIds);
106
+ return onChange({
107
+ event: {
108
+ target: {
109
+ value: parsedValue,
110
+ name: id,
111
+ type,
112
+ fileData: selectedFilesIds.length ? selectedFilesIds : null
113
+ }
114
+ },
115
+ value: parsedValue
116
+ });
117
+ }
118
+ setCurrentValue(files);
119
+ };
120
+ const handleReorderFiles = files => {
121
+ const filesIds = files.map(({
122
+ id: fileId
123
+ }) => fileId);
124
+ const parsedValue = getFormat(type, {
125
+ filesIds
126
+ });
127
+ setSelectedFiles(files);
128
+ return onChange({
129
+ event: {
130
+ target: {
131
+ value: parsedValue,
132
+ name: id,
133
+ type,
134
+ fileData: filesIds
135
+ }
136
+ },
137
+ value: parsedValue
138
+ });
139
+ };
140
+ const closeModalAndSetValue = (isSaving, values, toastMessage) => {
141
+ if (toastMessage) {
142
+ addToast(toastMessage, {
143
+ appearance: 'success',
144
+ autoDismiss: true
145
+ });
146
+ }
147
+ if (isSaving) {
148
+ const parsedValue = getFormat(type, {
149
+ filesIds: simpleLayout ? values : currentValue
150
+ });
151
+ setDisplayModal(false);
152
+ return onChange({
153
+ event: {
154
+ target: {
155
+ value: parsedValue,
156
+ name: id,
157
+ type,
158
+ currentValue
159
+ }
160
+ },
161
+ value: parsedValue
162
+ });
163
+ }
164
+ setCurrentValue(initialValue);
165
+ setDisplayModal(false);
166
+ };
167
+ const fileUploadButtonText = getButtonText({
168
+ maxItems,
169
+ value: initialValue,
170
+ fileType
171
+ });
172
+ const filesPending = previewAllFiles ? 0 : getNumberFilesPendingToFetch(selectedFiles.length, currentValue);
173
+ const onOpenLibrary = () => setDisplayModal(true);
174
+ const handleEditModal = file => {
175
+ const selectedEditFile = selectedFiles.find(({
176
+ id: _id
177
+ }) => _id === file.id);
178
+ setEditFile(selectedEditFile);
179
+ };
180
+ const handleEditFileForm = editedFile => {
181
+ const values = parseFormValues(editedFile.valuesChecked);
182
+ const {
183
+ altText,
184
+ caption,
185
+ credits,
186
+ hrefUrl,
187
+ name
188
+ } = values;
189
+ setEditFile(_objectSpread(_objectSpread({}, editFile), {}, {
190
+ name,
191
+ data: {
192
+ altText,
193
+ caption,
194
+ credits,
195
+ hrefUrl
196
+ }
197
+ }));
198
+ };
199
+ const orderFiles = (files, ids) => ids.map(currentId => files.find(({
200
+ id: fileId
201
+ }) => fileId === currentId)).filter(Boolean);
202
+ const modalActions = [{
203
+ textButton: 'Cancel',
204
+ callback: () => {
205
+ closeModalAndSetValue();
206
+ },
207
+ modifiers: ['cancel']
208
+ }, {
209
+ textButton: 'Apply',
210
+ callback: () => {
211
+ closeModalAndSetValue(true);
212
+ },
213
+ modifiers: []
214
+ }];
215
+ const editModalActions = [{
216
+ textButton: 'Cancel',
217
+ callback: () => {
218
+ setEditFile(null);
219
+ },
220
+ modifiers: ['cancel']
221
+ }, {
222
+ textButton: 'Apply',
223
+ callback: async () => {
224
+ const {
225
+ name,
226
+ id: editedFileId,
227
+ data
228
+ } = editFile;
229
+ const updatedSelectedFiles = selectedFiles.map(selectedFile => {
230
+ if (selectedFile.id === editedFileId) {
231
+ return _objectSpread(_objectSpread({}, selectedFile), {}, {
232
+ name,
233
+ data
234
+ });
235
+ }
236
+ return selectedFile;
237
+ });
238
+ setSelectedFiles(updatedSelectedFiles);
239
+ try {
240
+ await client.mutate({
241
+ mutation: getMutation('UPDATE_FILE'),
242
+ variables: {
243
+ input: {
244
+ name,
245
+ data,
246
+ id: editedFileId
247
+ }
248
+ },
249
+ update(cache, {
250
+ data: {
251
+ updateFile: fileUpdated
252
+ }
253
+ }) {
254
+ cache.writeQuery({
255
+ query: getQuery('GET_FILE_BY_ID'),
256
+ variables: {
257
+ id
258
+ },
259
+ data: {
260
+ file: fileUpdated.result
261
+ }
262
+ });
263
+ }
264
+ });
265
+ addToast(`File: ${editFile.name} has been updated`, {
266
+ appearance: 'success',
267
+ autoDismiss: true
268
+ });
269
+ closeModalAndSetValue(true);
270
+ setEditFile(null);
271
+ } catch (e) {
272
+ addToast(`File: ${editFile.name} has not been updated`, {
273
+ appearance: 'error',
274
+ autoDismiss: true
275
+ });
276
+ console.error(e); //eslint-disable-line
277
+ }
278
+ },
279
+ modifiers: []
280
+ }];
281
+ const filesPendingString = `${filesPending} ${MORE}`;
282
+ const fileListSpan = filesPending ?
283
+ /*#__PURE__*/
284
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
285
+ React.createElement("span", {
286
+ className: "FileUploadAdapter__preview-link button button--link",
287
+ onClick: fetchMore
288
+ }, "+ ", filesPendingString) : null;
289
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
290
+ className: "form-field form-field--button"
291
+ }, /*#__PURE__*/React.createElement("label", null, label, " ", /*#__PURE__*/React.createElement(Tooltip, {
292
+ tooltipContent: tooltip
293
+ })), selectedFiles && /*#__PURE__*/React.createElement(MediaContextProvider, {
294
+ value: {
295
+ handleEditModal,
296
+ onUnselectFile: handleSelectedFiles
297
+ }
298
+ }, shouldRenderInPreview ? /*#__PURE__*/React.createElement(InjectPreview, {
299
+ selector: FileUploadAdapter.previewerId
300
+ }, /*#__PURE__*/React.createElement(FileList, {
301
+ selectedFiles: selectedFiles,
302
+ allFiles: currentValue,
303
+ handleReorderFiles: handleReorderFiles,
304
+ canDragAndDrop: canDragAndDrop,
305
+ fetchMore: fetchMore
306
+ }, fileListSpan)) : /*#__PURE__*/React.createElement(FileList, {
307
+ selectedFiles: selectedFiles,
308
+ handleReorderFiles: handleReorderFiles,
309
+ fetchMore: fetchMore
310
+ })), /*#__PURE__*/React.createElement(FileUpload, {
311
+ actionText: fileUploadButtonText,
312
+ storeKey: storeKey,
313
+ handleLibraryClick: () => {
314
+ if (simpleLayout) {
315
+ setDisplayFileUploadModal(true);
316
+ } else {
317
+ onOpenLibrary();
318
+ }
319
+ },
320
+ enableDragAndDrop: false
321
+ })), editFile && /*#__PURE__*/React.createElement(Modal, {
322
+ actions: editModalActions,
323
+ title: "Edit File",
324
+ onClose: () => setEditFile(null)
325
+ }, /*#__PURE__*/React.createElement(FilePreview, {
326
+ file: editFile,
327
+ fileName: editFile.fileName,
328
+ handleFormChange: handleEditFileForm,
329
+ displayForm: true,
330
+ previewType: "card",
331
+ disableFilePreview: disableFilePreview
332
+ })), displayFileUploadModal && simpleLayout && /*#__PURE__*/React.createElement("div", {
333
+ className: "file-upload-modal-wrapper"
334
+ }, /*#__PURE__*/React.createElement(ListingContainer, {
335
+ displayFileUploadModal: displayFileUploadModal,
336
+ closeModalAndSetValue: closeModalAndSetValue,
337
+ setDisplayFileUploadModal: setDisplayFileUploadModal,
338
+ handleSelectedFiles: handleSelectedFiles,
339
+ maxItems: currentLimit,
340
+ simpleLayout: simpleLayout,
341
+ filesSelected: currentValue.length > 1 ? currentValue : [],
342
+ openEditInModal: true,
343
+ storeKey: storeKey
344
+ })), displayModal && !simpleLayout && /*#__PURE__*/React.createElement("div", {
345
+ className: "file-upload-modal-wrapper"
346
+ }, /*#__PURE__*/React.createElement(Modal, {
347
+ actions: modalActions,
348
+ className: "file-upload-modal",
349
+ title: "Media library",
350
+ onClose: () => closeModalAndSetValue()
351
+ }, /*#__PURE__*/React.createElement(ListingContainer, {
352
+ closeModalAndSetValue: closeModalAndSetValue,
353
+ displayFileUploadModal: displayFileUploadModal,
354
+ setDisplayFileUploadModal: setDisplayFileUploadModal,
355
+ handleSelectedFiles: handleSelectedFiles,
356
+ maxItems: currentLimit,
357
+ filesSelected: currentValue.length > 1 ? currentValue : [],
358
+ openEditInModal: true,
359
+ storeKey: storeKey
360
+ }))));
361
+ };
362
+ FileUploadAdapter.propTypes = {
363
+ onChange: PropTypes.func.isRequired,
364
+ label: PropTypes.string.isRequired,
365
+ id: PropTypes.string.isRequired,
366
+ type: PropTypes.string.isRequired,
367
+ value: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
368
+ maxItems: PropTypes.oneOfType([PropTypes.number, PropTypes.bool]),
369
+ shouldRenderInPreview: PropTypes.bool,
370
+ canDragAndDrop: PropTypes.bool,
371
+ simpleLayout: PropTypes.bool,
372
+ previewAllFiles: PropTypes.bool,
373
+ tooltip: PropTypes.string,
374
+ fileType: PropTypes.string,
375
+ disableFilePreview: PropTypes.bool,
376
+ storeKey: PropTypes.string
377
+ };
378
+ FileUploadAdapter.defaultProps = {
379
+ value: '',
380
+ maxItems: false,
381
+ shouldRenderInPreview: false,
382
+ canDragAndDrop: false,
383
+ simpleLayout: false,
384
+ previewAllFiles: false,
385
+ tooltip: '',
386
+ fileType: 'file',
387
+ disableFilePreview: true,
388
+ storeKey: null
389
+ };
390
+ export default FileUploadAdapter;
391
+ //# sourceMappingURL=FileUploadAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileUploadAdapter.js","names":["React","useState","useContext","useEffect","FileUpload","PropTypes","useApolloClient","getQuery","getMutation","ModalAdapter","Modal","parseFormValues","useToasts","Tooltip","MORE","ListingContainer","MediaContextProvider","FileList","useLimit","getFormat","formatInitialValue","transformToArray","isUnselecting","getButtonText","getNumberFilesPendingToFetch","FilePreview","FileUploadAdapter","onChange","label","id","type","value","maxItems","shouldRenderInPreview","canDragAndDrop","simpleLayout","tooltip","previewAllFiles","disableFilePreview","fileType","storeKey","InjectPreview","FormContext","currentLimit","displayModal","setDisplayModal","displayFileUploadModal","setDisplayFileUploadModal","initialValue","currentValue","setCurrentValue","selectedFiles","setSelectedFiles","editFile","setEditFile","allFilesLoaded","setAllFilesLoaded","client","addToast","getFiles","offset","ids","fetchAll","data","files","newFiles","query","variables","limit","where","_in","skip","length","fetchPolicy","loadedFiles","loadedOrderedFiles","orderFiles","initialFiles","filter","_","i","orderedFiles","fetchMore","shouldFetchAll","newOrderedFiles","handleSelectedFiles","checkIsUnselecting","isUnselectingFile","valueArray","selectedFilesIds","valueId","includes","parsedValue","filesIds","event","target","name","fileData","handleReorderFiles","map","fileId","closeModalAndSetValue","isSaving","values","toastMessage","appearance","autoDismiss","fileUploadButtonText","filesPending","onOpenLibrary","handleEditModal","file","selectedEditFile","find","_id","handleEditFileForm","editedFile","valuesChecked","altText","caption","credits","hrefUrl","_objectSpread","currentId","Boolean","modalActions","textButton","callback","modifiers","editModalActions","editedFileId","updatedSelectedFiles","selectedFile","mutate","mutation","input","update","cache","updateFile","fileUpdated","writeQuery","result","e","console","error","filesPendingString","fileListSpan","createElement","className","onClick","Fragment","tooltipContent","onUnselectFile","selector","previewerId","allFiles","actionText","handleLibraryClick","enableDragAndDrop","actions","title","onClose","fileName","handleFormChange","displayForm","previewType","filesSelected","openEditInModal","propTypes","func","isRequired","string","oneOfType","array","number","bool","defaultProps"],"sources":["../../../src/components/FileUploadAdapter/FileUploadAdapter.js"],"sourcesContent":["import React, { useState, useContext, useEffect } from 'react';\nimport FileUpload from '@blaze-react/file-upload';\nimport PropTypes from 'prop-types';\nimport { useApolloClient } from '@apollo/client';\nimport { getQuery, getMutation, ModalAdapter as Modal } from '@blaze-cms/admin-ui-utils';\nimport { parseFormValues } from '@blaze-cms/react-form-builder';\nimport { useToasts } from '@blaze-react/toaster';\nimport Tooltip from '@blaze-react/tooltip';\nimport { MORE } from '../../constants';\nimport ListingContainer from '../ListingContainer';\nimport { MediaContextProvider } from '../../utils/media-context';\nimport FileList from './FileList';\nimport useLimit from './useLimit';\nimport {\n getFormat,\n formatInitialValue,\n transformToArray,\n isUnselecting,\n getButtonText,\n getNumberFilesPendingToFetch\n} from './mappers';\nimport FilePreview from '../FilePreview';\n\nconst FileUploadAdapter = ({\n onChange,\n label,\n id,\n type,\n value,\n maxItems,\n shouldRenderInPreview,\n canDragAndDrop,\n simpleLayout,\n tooltip,\n previewAllFiles,\n disableFilePreview,\n fileType,\n storeKey\n}) => {\n const { InjectPreview } = useContext(FileUploadAdapter.FormContext);\n const [currentLimit] = useLimit(maxItems);\n const [displayModal, setDisplayModal] = useState(false);\n const [displayFileUploadModal, setDisplayFileUploadModal] = useState(false);\n const initialValue = formatInitialValue({ value, type });\n const [currentValue, setCurrentValue] = useState(initialValue);\n const [selectedFiles, setSelectedFiles] = useState([]);\n const [editFile, setEditFile] = useState(null);\n const [allFilesLoaded, setAllFilesLoaded] = useState(false);\n const client = useApolloClient();\n const { addToast } = useToasts();\n\n const getFiles = async (offset, ids, fetchAll = previewAllFiles) => {\n const {\n data: { files: newFiles }\n } = await client.query({\n query: getQuery('GET_FILES'),\n variables: {\n limit: fetchAll ? 0 : 4,\n offset,\n where: {\n id: {\n _in: ids\n }\n }\n },\n skip: !currentValue.length,\n fetchPolicy: 'network-only'\n });\n return newFiles;\n };\n\n useEffect(\n () => {\n (async () => {\n if (allFilesLoaded) {\n const loadedFiles = await getFiles(0, currentValue, true);\n const loadedOrderedFiles = orderFiles(loadedFiles, currentValue);\n setSelectedFiles(loadedOrderedFiles);\n return;\n }\n\n const initialFiles =\n !selectedFiles.length && !previewAllFiles\n ? currentValue.filter((_, i) => i <= 3)\n : currentValue;\n\n const files = await getFiles(0, initialFiles);\n const orderedFiles = orderFiles(files, currentValue);\n setSelectedFiles(orderedFiles);\n setAllFilesLoaded(false);\n })();\n },\n [currentValue] //eslint-disable-line\n );\n\n const fetchMore = async shouldFetchAll => {\n if (selectedFiles.length === currentValue.length) return;\n const newFiles = await getFiles(0, currentValue, true);\n const newOrderedFiles = orderFiles(newFiles, currentValue);\n setSelectedFiles(newOrderedFiles);\n setAllFilesLoaded(true);\n };\n\n const handleSelectedFiles = (files, checkIsUnselecting = true) => {\n const isUnselectingFile = isUnselecting(value, checkIsUnselecting, files);\n if (isUnselectingFile) {\n const valueArray = transformToArray(value);\n const selectedFilesIds = valueArray.filter(valueId => !files.includes(valueId));\n const parsedValue = getFormat(type, { filesIds: selectedFilesIds });\n setCurrentValue(selectedFilesIds);\n return onChange({\n event: {\n target: {\n value: parsedValue,\n name: id,\n type,\n fileData: selectedFilesIds.length ? selectedFilesIds : null\n }\n },\n value: parsedValue\n });\n }\n\n setCurrentValue(files);\n };\n\n const handleReorderFiles = files => {\n const filesIds = files.map(({ id: fileId }) => fileId);\n const parsedValue = getFormat(type, { filesIds });\n setSelectedFiles(files);\n\n return onChange({\n event: {\n target: {\n value: parsedValue,\n name: id,\n type,\n fileData: filesIds\n }\n },\n value: parsedValue\n });\n };\n\n const closeModalAndSetValue = (isSaving, values, toastMessage) => {\n if (toastMessage) {\n addToast(toastMessage, {\n appearance: 'success',\n autoDismiss: true\n });\n }\n\n if (isSaving) {\n const parsedValue = getFormat(type, { filesIds: simpleLayout ? values : currentValue });\n setDisplayModal(false);\n return onChange({\n event: { target: { value: parsedValue, name: id, type, currentValue } },\n value: parsedValue\n });\n }\n\n setCurrentValue(initialValue);\n setDisplayModal(false);\n };\n\n const fileUploadButtonText = getButtonText({ maxItems, value: initialValue, fileType });\n\n const filesPending = previewAllFiles\n ? 0\n : getNumberFilesPendingToFetch(selectedFiles.length, currentValue);\n const onOpenLibrary = () => setDisplayModal(true);\n const handleEditModal = file => {\n const selectedEditFile = selectedFiles.find(({ id: _id }) => _id === file.id);\n setEditFile(selectedEditFile);\n };\n\n const handleEditFileForm = editedFile => {\n const values = parseFormValues(editedFile.valuesChecked);\n\n const { altText, caption, credits, hrefUrl, name } = values;\n setEditFile({\n ...editFile,\n name,\n data: {\n altText,\n caption,\n credits,\n hrefUrl\n }\n });\n };\n\n const orderFiles = (files, ids) =>\n ids.map(currentId => files.find(({ id: fileId }) => fileId === currentId)).filter(Boolean);\n\n const modalActions = [\n {\n textButton: 'Cancel',\n callback: () => {\n closeModalAndSetValue();\n },\n modifiers: ['cancel']\n },\n {\n textButton: 'Apply',\n callback: () => {\n closeModalAndSetValue(true);\n },\n modifiers: []\n }\n ];\n\n const editModalActions = [\n {\n textButton: 'Cancel',\n callback: () => {\n setEditFile(null);\n },\n modifiers: ['cancel']\n },\n {\n textButton: 'Apply',\n callback: async () => {\n const { name, id: editedFileId, data } = editFile;\n const updatedSelectedFiles = selectedFiles.map(selectedFile => {\n if (selectedFile.id === editedFileId) {\n return { ...selectedFile, name, data };\n }\n return selectedFile;\n });\n setSelectedFiles(updatedSelectedFiles);\n\n try {\n await client.mutate({\n mutation: getMutation('UPDATE_FILE'),\n variables: {\n input: {\n name,\n data,\n id: editedFileId\n }\n },\n update(cache, { data: { updateFile: fileUpdated } }) {\n cache.writeQuery({\n query: getQuery('GET_FILE_BY_ID'),\n variables: { id },\n data: { file: fileUpdated.result }\n });\n }\n });\n\n addToast(`File: ${editFile.name} has been updated`, {\n appearance: 'success',\n autoDismiss: true\n });\n closeModalAndSetValue(true);\n setEditFile(null);\n } catch (e) {\n addToast(`File: ${editFile.name} has not been updated`, {\n appearance: 'error',\n autoDismiss: true\n });\n console.error(e); //eslint-disable-line\n }\n },\n modifiers: []\n }\n ];\n const filesPendingString = `${filesPending} ${MORE}`;\n const fileListSpan = filesPending ? (\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions\n <span className=\"FileUploadAdapter__preview-link button button--link\" onClick={fetchMore}>\n + {filesPendingString}\n </span>\n ) : null;\n\n return (\n <>\n <div className=\"form-field form-field--button\">\n <label>\n {label} <Tooltip tooltipContent={tooltip} />\n </label>\n {selectedFiles && (\n <MediaContextProvider value={{ handleEditModal, onUnselectFile: handleSelectedFiles }}>\n {shouldRenderInPreview ? (\n <InjectPreview selector={FileUploadAdapter.previewerId}>\n <FileList\n selectedFiles={selectedFiles}\n allFiles={currentValue}\n handleReorderFiles={handleReorderFiles}\n canDragAndDrop={canDragAndDrop}\n fetchMore={fetchMore}>\n {fileListSpan}\n </FileList>\n </InjectPreview>\n ) : (\n <FileList\n selectedFiles={selectedFiles}\n handleReorderFiles={handleReorderFiles}\n fetchMore={fetchMore}\n />\n )}\n </MediaContextProvider>\n )}\n <FileUpload\n actionText={fileUploadButtonText}\n storeKey={storeKey}\n handleLibraryClick={() => {\n if (simpleLayout) {\n setDisplayFileUploadModal(true);\n } else {\n onOpenLibrary();\n }\n }}\n enableDragAndDrop={false}\n />\n </div>\n {editFile && (\n <Modal actions={editModalActions} title=\"Edit File\" onClose={() => setEditFile(null)}>\n <FilePreview\n file={editFile}\n fileName={editFile.fileName}\n handleFormChange={handleEditFileForm}\n displayForm\n previewType=\"card\"\n disableFilePreview={disableFilePreview}\n />\n </Modal>\n )}\n\n {displayFileUploadModal && simpleLayout && (\n <div className=\"file-upload-modal-wrapper\">\n <ListingContainer\n displayFileUploadModal={displayFileUploadModal}\n closeModalAndSetValue={closeModalAndSetValue}\n setDisplayFileUploadModal={setDisplayFileUploadModal}\n handleSelectedFiles={handleSelectedFiles}\n maxItems={currentLimit}\n simpleLayout={simpleLayout}\n filesSelected={currentValue.length > 1 ? currentValue : []}\n openEditInModal\n storeKey={storeKey}\n />\n </div>\n )}\n\n {displayModal && !simpleLayout && (\n <div className=\"file-upload-modal-wrapper\">\n <Modal\n actions={modalActions}\n className=\"file-upload-modal\"\n title=\"Media library\"\n onClose={() => closeModalAndSetValue()}>\n <ListingContainer\n closeModalAndSetValue={closeModalAndSetValue}\n displayFileUploadModal={displayFileUploadModal}\n setDisplayFileUploadModal={setDisplayFileUploadModal}\n handleSelectedFiles={handleSelectedFiles}\n maxItems={currentLimit}\n filesSelected={currentValue.length > 1 ? currentValue : []}\n openEditInModal\n storeKey={storeKey}\n />\n </Modal>\n </div>\n )}\n </>\n );\n};\n\nFileUploadAdapter.propTypes = {\n onChange: PropTypes.func.isRequired,\n label: PropTypes.string.isRequired,\n id: PropTypes.string.isRequired,\n type: PropTypes.string.isRequired,\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),\n maxItems: PropTypes.oneOfType([PropTypes.number, PropTypes.bool]),\n shouldRenderInPreview: PropTypes.bool,\n canDragAndDrop: PropTypes.bool,\n simpleLayout: PropTypes.bool,\n previewAllFiles: PropTypes.bool,\n tooltip: PropTypes.string,\n fileType: PropTypes.string,\n disableFilePreview: PropTypes.bool,\n storeKey: PropTypes.string\n};\n\nFileUploadAdapter.defaultProps = {\n value: '',\n maxItems: false,\n shouldRenderInPreview: false,\n canDragAndDrop: false,\n simpleLayout: false,\n previewAllFiles: false,\n tooltip: '',\n fileType: 'file',\n disableFilePreview: true,\n storeKey: null\n};\n\nexport default FileUploadAdapter;\n"],"mappings":";;;AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,UAAU,EAAEC,SAAS,QAAQ,OAAO;AAC9D,OAAOC,UAAU,MAAM,0BAA0B;AACjD,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,eAAe,QAAQ,gBAAgB;AAChD,SAASC,QA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default FileUploadAdapter;
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["FileUploadAdapter"],"sources":["../../../src/components/FileUploadAdapter/index.js"],"sourcesContent":["import FileUploadAdapter from './FileUploadAdapter';\n\nexport default FileUploadAdapter;\n"],"mappings":"AAAA,OAAOA,iBAAiB,MAAM,qBAAqB;AAEnD,eAAeA,iBAAiB","ignoreList":[]}
@@ -0,0 +1,11 @@
1
+ const formatInitialValue = ({
2
+ value,
3
+ type
4
+ }) => {
5
+ const parsedValue = value && type === 'array' ? value : [value];
6
+ const existValue = parsedValue.filter(Boolean).length;
7
+ if (!parsedValue || !existValue) return [];
8
+ return parsedValue;
9
+ };
10
+ export { formatInitialValue };
11
+ //# sourceMappingURL=format-initial-value.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-initial-value.js","names":["formatInitialValue","value","type","parsedValue","existValue","filter","Boolean","length"],"sources":["../../../../src/components/FileUploadAdapter/mappers/format-initial-value.js"],"sourcesContent":["const formatInitialValue = ({ value, type }) => {\n const parsedValue = value && type === 'array' ? value : [value];\n const existValue = parsedValue.filter(Boolean).length;\n if (!parsedValue || !existValue) return [];\n return parsedValue;\n};\n\nexport { formatInitialValue };\n"],"mappings":"AAAA,MAAMA,kBAAkB,GAAGA,CAAC;EAAEC,KAAK;EAAEC;AAAK,CAAC,KAAK;EAC9C,MAAMC,WAAW,GAAGF,KAAK,IAAIC,IAAI,KAAK,OAAO,GAAGD,KAAK,GAAG,CAACA,KAAK,CAAC;EAC/D,MAAMG,UAAU,GAAGD,WAAW,CAACE,MAAM,CAACC,OAAO,CAAC,CAACC,MAAM;EACrD,IAAI,CAACJ,WAAW,IAAI,CAACC,UAAU,EAAE,OAAO,EAAE;EAC1C,OAAOD,WAAW;AACpB,CAAC;AAED,SAASH,kBAAkB","ignoreList":[]}
@@ -0,0 +1,11 @@
1
+ const getButtonText = ({
2
+ maxItems,
3
+ value,
4
+ fileType = 'file'
5
+ }) => {
6
+ const pluralSuffix = maxItems > 1 ? 's' : '';
7
+ const fileLabel = `Add ${fileType}${pluralSuffix}`;
8
+ return value && value.length > 0 ? `Change ${fileType}${pluralSuffix}` : fileLabel;
9
+ };
10
+ export { getButtonText };
11
+ //# sourceMappingURL=get-button-text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-button-text.js","names":["getButtonText","maxItems","value","fileType","pluralSuffix","fileLabel","length"],"sources":["../../../../src/components/FileUploadAdapter/mappers/get-button-text.js"],"sourcesContent":["const getButtonText = ({ maxItems, value, fileType = 'file' }) => {\n const pluralSuffix = maxItems > 1 ? 's' : '';\n const fileLabel = `Add ${fileType}${pluralSuffix}`;\n return value && value.length > 0 ? `Change ${fileType}${pluralSuffix}` : fileLabel;\n};\n\nexport { getButtonText };\n"],"mappings":"AAAA,MAAMA,aAAa,GAAGA,CAAC;EAAEC,QAAQ;EAAEC,KAAK;EAAEC,QAAQ,GAAG;AAAO,CAAC,KAAK;EAChE,MAAMC,YAAY,GAAGH,QAAQ,GAAG,CAAC,GAAG,GAAG,GAAG,EAAE;EAC5C,MAAMI,SAAS,GAAG,OAAOF,QAAQ,GAAGC,YAAY,EAAE;EAClD,OAAOF,KAAK,IAAIA,KAAK,CAACI,MAAM,GAAG,CAAC,GAAG,UAAUH,QAAQ,GAAGC,YAAY,EAAE,GAAGC,SAAS;AACpF,CAAC;AAED,SAASL,aAAa","ignoreList":[]}
@@ -0,0 +1,12 @@
1
+ const getFormat = (type, {
2
+ filesIds
3
+ } = {
4
+ filesIds: []
5
+ }) => {
6
+ if (!filesIds || !filesIds.length) return null;
7
+ const [primaryType] = Array.isArray(type) ? type : [type];
8
+ if (primaryType === 'array') return filesIds || [];
9
+ if (primaryType === 'string') return filesIds.join() || '';
10
+ };
11
+ export { getFormat };
12
+ //# sourceMappingURL=get-format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-format.js","names":["getFormat","type","filesIds","length","primaryType","Array","isArray","join"],"sources":["../../../../src/components/FileUploadAdapter/mappers/get-format.js"],"sourcesContent":["const getFormat = (type, { filesIds } = { filesIds: [] }) => {\n if (!filesIds || !filesIds.length) return null;\n\n const [primaryType] = Array.isArray(type) ? type : [type];\n if (primaryType === 'array') return filesIds || [];\n if (primaryType === 'string') return filesIds.join() || '';\n};\n\nexport { getFormat };\n"],"mappings":"AAAA,MAAMA,SAAS,GAAGA,CAACC,IAAI,EAAE;EAAEC;AAAS,CAAC,GAAG;EAAEA,QAAQ,EAAE;AAAG,CAAC,KAAK;EAC3D,IAAI,CAACA,QAAQ,IAAI,CAACA,QAAQ,CAACC,MAAM,EAAE,OAAO,IAAI;EAE9C,MAAM,CAACC,WAAW,CAAC,GAAGC,KAAK,CAACC,OAAO,CAACL,IAAI,CAAC,GAAGA,IAAI,GAAG,CAACA,IAAI,CAAC;EACzD,IAAIG,WAAW,KAAK,OAAO,EAAE,OAAOF,QAAQ,IAAI,EAAE;EAClD,IAAIE,WAAW,KAAK,QAAQ,EAAE,OAAOF,QAAQ,CAACK,IAAI,CAAC,CAAC,IAAI,EAAE;AAC5D,CAAC;AAED,SAASP,SAAS","ignoreList":[]}
@@ -0,0 +1,7 @@
1
+ export const getNumberFilesPendingToFetch = (loadedFilesCount, currentValue) => {
2
+ if (loadedFilesCount >= currentValue.length) {
3
+ return 0;
4
+ }
5
+ return currentValue.length - loadedFilesCount;
6
+ };
7
+ //# sourceMappingURL=get-number-files-pending-to-fetch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-number-files-pending-to-fetch.js","names":["getNumberFilesPendingToFetch","loadedFilesCount","currentValue","length"],"sources":["../../../../src/components/FileUploadAdapter/mappers/get-number-files-pending-to-fetch.js"],"sourcesContent":["export const getNumberFilesPendingToFetch = (loadedFilesCount, currentValue) => {\n if (loadedFilesCount >= currentValue.length) {\n return 0;\n }\n\n return currentValue.length - loadedFilesCount;\n};\n"],"mappings":"AAAA,OAAO,MAAMA,4BAA4B,GAAGA,CAACC,gBAAgB,EAAEC,YAAY,KAAK;EAC9E,IAAID,gBAAgB,IAAIC,YAAY,CAACC,MAAM,EAAE;IAC3C,OAAO,CAAC;EACV;EAEA,OAAOD,YAAY,CAACC,MAAM,GAAGF,gBAAgB;AAC/C,CAAC","ignoreList":[]}
@@ -0,0 +1,8 @@
1
+ import { isUnselecting } from './is-unselecting';
2
+ import { transformToArray } from './transform-to-array';
3
+ import { getFormat } from './get-format';
4
+ import { getButtonText } from './get-button-text';
5
+ import { formatInitialValue } from './format-initial-value';
6
+ import { getNumberFilesPendingToFetch } from './get-number-files-pending-to-fetch';
7
+ export { isUnselecting, transformToArray, getFormat, getButtonText, formatInitialValue, getNumberFilesPendingToFetch };
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["isUnselecting","transformToArray","getFormat","getButtonText","formatInitialValue","getNumberFilesPendingToFetch"],"sources":["../../../../src/components/FileUploadAdapter/mappers/index.js"],"sourcesContent":["import { isUnselecting } from './is-unselecting';\nimport { transformToArray } from './transform-to-array';\nimport { getFormat } from './get-format';\nimport { getButtonText } from './get-button-text';\nimport { formatInitialValue } from './format-initial-value';\nimport { getNumberFilesPendingToFetch } from './get-number-files-pending-to-fetch';\n\nexport {\n isUnselecting,\n transformToArray,\n getFormat,\n getButtonText,\n formatInitialValue,\n getNumberFilesPendingToFetch\n};\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,kBAAkB;AAChD,SAASC,gBAAgB,QAAQ,sBAAsB;AACvD,SAASC,SAAS,QAAQ,cAAc;AACxC,SAASC,aAAa,QAAQ,mBAAmB;AACjD,SAASC,kBAAkB,QAAQ,wBAAwB;AAC3D,SAASC,4BAA4B,QAAQ,qCAAqC;AAElF,SACEL,aAAa,EACbC,gBAAgB,EAChBC,SAAS,EACTC,aAAa,EACbC,kBAAkB,EAClBC,4BAA4B","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export const isUnselecting = (value, checkIsUnselecting, files) => value && checkIsUnselecting && files.some(fileId => value.includes(fileId));
2
+ //# sourceMappingURL=is-unselecting.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-unselecting.js","names":["isUnselecting","value","checkIsUnselecting","files","some","fileId","includes"],"sources":["../../../../src/components/FileUploadAdapter/mappers/is-unselecting.js"],"sourcesContent":["export const isUnselecting = (value, checkIsUnselecting, files) =>\n value && checkIsUnselecting && files.some(fileId => value.includes(fileId));\n"],"mappings":"AAAA,OAAO,MAAMA,aAAa,GAAGA,CAACC,KAAK,EAAEC,kBAAkB,EAAEC,KAAK,KAC5DF,KAAK,IAAIC,kBAAkB,IAAIC,KAAK,CAACC,IAAI,CAACC,MAAM,IAAIJ,KAAK,CAACK,QAAQ,CAACD,MAAM,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export const transformToArray = value => Array.isArray(value) ? value : [value];
2
+ //# sourceMappingURL=transform-to-array.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform-to-array.js","names":["transformToArray","value","Array","isArray"],"sources":["../../../../src/components/FileUploadAdapter/mappers/transform-to-array.js"],"sourcesContent":["export const transformToArray = value => (Array.isArray(value) ? value : [value]);\n"],"mappings":"AAAA,OAAO,MAAMA,gBAAgB,GAAGC,KAAK,IAAKC,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC,GAAGA,KAAK,GAAG,CAACA,KAAK,CAAE","ignoreList":[]}
@@ -0,0 +1,13 @@
1
+ import { useEffect, useState } from 'react';
2
+ import { ONE_FILE_AS_LIMIT } from '../../constants';
3
+ function useLimit(initialLimit) {
4
+ const [currentLimit, setCurrentLimit] = useState(initialLimit);
5
+ useEffect(() => {
6
+ if (initialLimit && currentLimit !== ONE_FILE_AS_LIMIT) {
7
+ setCurrentLimit(ONE_FILE_AS_LIMIT);
8
+ }
9
+ }, [currentLimit, initialLimit]);
10
+ return [currentLimit, setCurrentLimit];
11
+ }
12
+ export default useLimit;
13
+ //# sourceMappingURL=useLimit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLimit.js","names":["useEffect","useState","ONE_FILE_AS_LIMIT","useLimit","initialLimit","currentLimit","setCurrentLimit"],"sources":["../../../src/components/FileUploadAdapter/useLimit.js"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport { ONE_FILE_AS_LIMIT } from '../../constants';\n\nfunction useLimit(initialLimit) {\n const [currentLimit, setCurrentLimit] = useState(initialLimit);\n useEffect(() => {\n if (initialLimit && currentLimit !== ONE_FILE_AS_LIMIT) {\n setCurrentLimit(ONE_FILE_AS_LIMIT);\n }\n }, [currentLimit, initialLimit]);\n\n return [currentLimit, setCurrentLimit];\n}\n\nexport default useLimit;\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,iBAAiB,QAAQ,iBAAiB;AAEnD,SAASC,QAAQA,CAACC,YAAY,EAAE;EAC9B,MAAM,CAACC,YAAY,EAAEC,eAAe,CAAC,GAAGL,QAAQ,CAACG,YAAY,CAAC;EAC9DJ,SAAS,CAAC,MAAM;IACd,IAAII,YAAY,IAAIC,YAAY,KAAKH,iBAAiB,EAAE;MACtDI,eAAe,CAACJ,iBAAiB,CAAC;IACpC;EACF,CAAC,EAAE,CAACG,YAAY,EAAED,YAAY,CAAC,CAAC;EAEhC,OAAO,CAACC,YAAY,EAAEC,eAAe,CAAC;AACxC;AAEA,eAAeH,QAAQ","ignoreList":[]}