@anji-dashing/dam-solution-v2 5.8.173

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 (259) hide show
  1. package/README.md +53 -0
  2. package/build/AssetType/AddFieldProperties.d.ts +10 -0
  3. package/build/AssetType/AddFieldProperties.js +359 -0
  4. package/build/AssetType/AssetTemplatesTable.d.ts +10 -0
  5. package/build/AssetType/AssetTemplatesTable.js +172 -0
  6. package/build/AssetType/CreateAssetTemplate.d.ts +3 -0
  7. package/build/AssetType/CreateAssetTemplate.js +70 -0
  8. package/build/AssetType/CreateOrEditAssetTemplate.d.ts +1 -0
  9. package/build/AssetType/CreateOrEditAssetTemplate.js +100 -0
  10. package/build/AssetType/DraggedField.d.ts +14 -0
  11. package/build/AssetType/DraggedField.js +58 -0
  12. package/build/AssetType/EditAssetTemplate.d.ts +5 -0
  13. package/build/AssetType/EditAssetTemplate.js +257 -0
  14. package/build/AssetType/FieldsSection.d.ts +14 -0
  15. package/build/AssetType/FieldsSection.js +268 -0
  16. package/build/AssetType/assetTemplatesContainer.d.ts +2 -0
  17. package/build/AssetType/assetTemplatesContainer.js +71 -0
  18. package/build/AssetType/fieldProperties/DateField.d.ts +5 -0
  19. package/build/AssetType/fieldProperties/DateField.js +23 -0
  20. package/build/AssetType/fieldProperties/NumberField.d.ts +5 -0
  21. package/build/AssetType/fieldProperties/NumberField.js +91 -0
  22. package/build/AssetType/fieldProperties/OptionsField.d.ts +6 -0
  23. package/build/AssetType/fieldProperties/OptionsField.js +55 -0
  24. package/build/AssetType/fieldProperties/TextField.d.ts +5 -0
  25. package/build/AssetType/fieldProperties/TextField.js +92 -0
  26. package/build/AssetType/index.d.ts +11 -0
  27. package/build/AssetType/index.js +25 -0
  28. package/build/AssetType/routes.d.ts +3 -0
  29. package/build/AssetType/routes.js +17 -0
  30. package/build/BookView/ProductDescription.d.ts +4 -0
  31. package/build/BookView/ProductDescription.js +20 -0
  32. package/build/BookView/bookDetail.d.ts +4 -0
  33. package/build/BookView/bookDetail.js +106 -0
  34. package/build/BookView/bookInfo.d.ts +4 -0
  35. package/build/BookView/bookInfo.js +17 -0
  36. package/build/BookView/description.d.ts +4 -0
  37. package/build/BookView/description.js +5 -0
  38. package/build/BookView/index.d.ts +10 -0
  39. package/build/BookView/index.js +23 -0
  40. package/build/CreateClient/CreateClientBtn.d.ts +14 -0
  41. package/build/CreateClient/CreateClientBtn.js +54 -0
  42. package/build/CreateClient/CreateClientForm.d.ts +15 -0
  43. package/build/CreateClient/CreateClientForm.js +347 -0
  44. package/build/CreateClient/index.d.ts +20 -0
  45. package/build/CreateClient/index.js +18 -0
  46. package/build/ImagePicker/MetaFieldOptions.d.ts +14 -0
  47. package/build/ImagePicker/MetaFieldOptions.js +75 -0
  48. package/build/ImagePicker/TestImagePickerModal.d.ts +8 -0
  49. package/build/ImagePicker/TestImagePickerModal.js +72 -0
  50. package/build/ImagePicker/TestImgFromMetaData.d.ts +7 -0
  51. package/build/ImagePicker/TestImgFromMetaData.js +82 -0
  52. package/build/ImagePicker/imagePickerComponent.d.ts +6 -0
  53. package/build/ImagePicker/imagePickerComponent.js +63 -0
  54. package/build/ImagePicker/index.d.ts +13 -0
  55. package/build/ImagePicker/index.js +24 -0
  56. package/build/ImagePicker/routes.d.ts +6 -0
  57. package/build/ImagePicker/routes.js +17 -0
  58. package/build/ImagePickerFilters/ImagePickerFiltersComponent.d.ts +8 -0
  59. package/build/ImagePickerFilters/ImagePickerFiltersComponent.js +223 -0
  60. package/build/ImagePickerFilters/index.d.ts +12 -0
  61. package/build/ImagePickerFilters/index.js +19 -0
  62. package/build/MyDrive/ActionBar.d.ts +8 -0
  63. package/build/MyDrive/ActionBar.js +190 -0
  64. package/build/MyDrive/AddDrive.d.ts +5 -0
  65. package/build/MyDrive/AddDrive.js +189 -0
  66. package/build/MyDrive/AddFolder.d.ts +11 -0
  67. package/build/MyDrive/AddFolder.js +165 -0
  68. package/build/MyDrive/BreadCrumbList.d.ts +10 -0
  69. package/build/MyDrive/BreadCrumbList.js +81 -0
  70. package/build/MyDrive/BulkUploadModal.d.ts +2 -0
  71. package/build/MyDrive/BulkUploadModal.js +324 -0
  72. package/build/MyDrive/DriveContainer.d.ts +14 -0
  73. package/build/MyDrive/DriveContainer.js +343 -0
  74. package/build/MyDrive/FileDownloadHistory.d.ts +7 -0
  75. package/build/MyDrive/FileDownloadHistory.js +107 -0
  76. package/build/MyDrive/FileMenuOptions.d.ts +11 -0
  77. package/build/MyDrive/FileMenuOptions.js +450 -0
  78. package/build/MyDrive/FilesGridView.d.ts +9 -0
  79. package/build/MyDrive/FilesGridView.js +25 -0
  80. package/build/MyDrive/FolderGridView.d.ts +20 -0
  81. package/build/MyDrive/FolderGridView.js +95 -0
  82. package/build/MyDrive/FolderListView.d.ts +26 -0
  83. package/build/MyDrive/FolderListView.js +226 -0
  84. package/build/MyDrive/FolderMenuOptions.d.ts +5 -0
  85. package/build/MyDrive/FolderMenuOptions.js +350 -0
  86. package/build/MyDrive/FolderTree.d.ts +8 -0
  87. package/build/MyDrive/FolderTree.js +479 -0
  88. package/build/MyDrive/ImageEditor/EditImage.d.ts +6 -0
  89. package/build/MyDrive/ImageEditor/EditImage.js +97 -0
  90. package/build/MyDrive/ImageEditor/EditImageModal.d.ts +8 -0
  91. package/build/MyDrive/ImageEditor/EditImageModal.js +30 -0
  92. package/build/MyDrive/ImageEditor/TuiImageEditor.d.ts +10 -0
  93. package/build/MyDrive/ImageEditor/TuiImageEditor.js +99 -0
  94. package/build/MyDrive/ImagePickerBreadCrumbList.d.ts +8 -0
  95. package/build/MyDrive/ImagePickerBreadCrumbList.js +35 -0
  96. package/build/MyDrive/ImagePickerDrive.d.ts +1 -0
  97. package/build/MyDrive/ImagePickerDrive.js +41 -0
  98. package/build/MyDrive/MyDriveMainContainer.d.ts +6 -0
  99. package/build/MyDrive/MyDriveMainContainer.js +63 -0
  100. package/build/MyDrive/SearchFilter.d.ts +8 -0
  101. package/build/MyDrive/SearchFilter.js +73 -0
  102. package/build/MyDrive/ShareBtn.d.ts +5 -0
  103. package/build/MyDrive/ShareBtn.js +19 -0
  104. package/build/MyDrive/ToggleView.d.ts +4 -0
  105. package/build/MyDrive/ToggleView.js +12 -0
  106. package/build/MyDrive/UploadStatusModal.d.ts +12 -0
  107. package/build/MyDrive/UploadStatusModal.js +52 -0
  108. package/build/MyDrive/fileDetails/CommentEntity.d.ts +8 -0
  109. package/build/MyDrive/fileDetails/CommentEntity.js +102 -0
  110. package/build/MyDrive/fileDetails/Comments.d.ts +6 -0
  111. package/build/MyDrive/fileDetails/Comments.js +65 -0
  112. package/build/MyDrive/fileDetails/Compliance.d.ts +2 -0
  113. package/build/MyDrive/fileDetails/Compliance.js +18 -0
  114. package/build/MyDrive/fileDetails/CreateComment.d.ts +7 -0
  115. package/build/MyDrive/fileDetails/CreateComment.js +48 -0
  116. package/build/MyDrive/fileDetails/Editor.d.ts +6 -0
  117. package/build/MyDrive/fileDetails/Editor.js +55 -0
  118. package/build/MyDrive/fileDetails/EmojiPicker.d.ts +5 -0
  119. package/build/MyDrive/fileDetails/EmojiPicker.js +6 -0
  120. package/build/MyDrive/fileDetails/FileDetails.d.ts +11 -0
  121. package/build/MyDrive/fileDetails/FileDetails.js +125 -0
  122. package/build/MyDrive/fileDetails/FileHeader.d.ts +7 -0
  123. package/build/MyDrive/fileDetails/FileHeader.js +27 -0
  124. package/build/MyDrive/fileDetails/FileViewer.d.ts +10 -0
  125. package/build/MyDrive/fileDetails/FileViewer.js +17 -0
  126. package/build/MyDrive/fileDetails/ImageOptions.d.ts +2 -0
  127. package/build/MyDrive/fileDetails/ImageOptions.js +44 -0
  128. package/build/MyDrive/fileDetails/ImageViewer.d.ts +6 -0
  129. package/build/MyDrive/fileDetails/ImageViewer.js +16 -0
  130. package/build/MyDrive/fileDetails/ManageFile.d.ts +7 -0
  131. package/build/MyDrive/fileDetails/ManageFile.js +34 -0
  132. package/build/MyDrive/fileDetails/MetaForm.d.ts +15 -0
  133. package/build/MyDrive/fileDetails/MetaForm.js +199 -0
  134. package/build/MyDrive/fileDetails/Metadata.d.ts +8 -0
  135. package/build/MyDrive/fileDetails/Metadata.js +52 -0
  136. package/build/MyDrive/fileDetails/PdfOptions.d.ts +9 -0
  137. package/build/MyDrive/fileDetails/PdfOptions.js +35 -0
  138. package/build/MyDrive/fileDetails/PdfViewer.d.ts +8 -0
  139. package/build/MyDrive/fileDetails/PdfViewer.js +18 -0
  140. package/build/MyDrive/fileDetails/Previewdetails.d.ts +10 -0
  141. package/build/MyDrive/fileDetails/Previewdetails.js +53 -0
  142. package/build/MyDrive/fileDetails/VideoPlayer.d.ts +4 -0
  143. package/build/MyDrive/fileDetails/VideoPlayer.js +21 -0
  144. package/build/MyDrive/files/AssetSelectionFormItem.d.ts +7 -0
  145. package/build/MyDrive/files/AssetSelectionFormItem.js +14 -0
  146. package/build/MyDrive/files/FolderTabs.d.ts +6 -0
  147. package/build/MyDrive/files/FolderTabs.js +90 -0
  148. package/build/MyDrive/files/MapFile.d.ts +9 -0
  149. package/build/MyDrive/files/MapFile.js +239 -0
  150. package/build/MyDrive/files/MoveToAnotherFolder.d.ts +9 -0
  151. package/build/MyDrive/files/MoveToAnotherFolder.js +67 -0
  152. package/build/MyDrive/filesListView.d.ts +2 -0
  153. package/build/MyDrive/filesListView.js +57 -0
  154. package/build/MyDrive/index.d.ts +16 -0
  155. package/build/MyDrive/index.js +50 -0
  156. package/build/MyDrive/routes.d.ts +10 -0
  157. package/build/MyDrive/routes.js +12 -0
  158. package/build/PenView/PenDetails.d.ts +4 -0
  159. package/build/PenView/PenDetails.js +114 -0
  160. package/build/PenView/ProductDescription.d.ts +5 -0
  161. package/build/PenView/ProductDescription.js +51 -0
  162. package/build/PenView/index.d.ts +10 -0
  163. package/build/PenView/index.js +23 -0
  164. package/build/RefreshKey/RefreshKeyBtn.d.ts +1 -0
  165. package/build/RefreshKey/RefreshKeyBtn.js +42 -0
  166. package/build/RefreshKey/index.d.ts +9 -0
  167. package/build/RefreshKey/index.js +23 -0
  168. package/build/ShoesView/ProductDescription.d.ts +4 -0
  169. package/build/ShoesView/ProductDescription.js +25 -0
  170. package/build/ShoesView/ShoeDetails.d.ts +4 -0
  171. package/build/ShoesView/ShoeDetails.js +96 -0
  172. package/build/ShoesView/index.d.ts +10 -0
  173. package/build/ShoesView/index.js +23 -0
  174. package/build/common/Button.d.ts +2 -0
  175. package/build/common/Button.js +18 -0
  176. package/build/common/CustomElements.d.ts +98 -0
  177. package/build/common/CustomElements.js +77 -0
  178. package/build/common/LoadMoreItems.d.ts +7 -0
  179. package/build/common/LoadMoreItems.js +33 -0
  180. package/build/common/RenderFormItem.d.ts +42 -0
  181. package/build/common/RenderFormItem.js +98 -0
  182. package/build/common/RenderThumnail.d.ts +7 -0
  183. package/build/common/RenderThumnail.js +6 -0
  184. package/build/common/deleteModal.d.ts +1 -0
  185. package/build/common/deleteModal.js +12 -0
  186. package/build/common/folders/TypeAndDateFilters.d.ts +13 -0
  187. package/build/common/folders/TypeAndDateFilters.js +66 -0
  188. package/build/common/folders/getFolderOrFileIcon.d.ts +2 -0
  189. package/build/common/folders/getFolderOrFileIcon.js +41 -0
  190. package/build/common/loader/CustomLoader.d.ts +7 -0
  191. package/build/common/loader/CustomLoader.js +8 -0
  192. package/build/common/loader/loader.d.ts +1 -0
  193. package/build/common/loader/loader.js +6 -0
  194. package/build/common/notifications.d.ts +2 -0
  195. package/build/common/notifications.js +30 -0
  196. package/build/common/steps.d.ts +4 -0
  197. package/build/common/steps.js +7 -0
  198. package/build/hocs/AppProvider.d.ts +3 -0
  199. package/build/hocs/AppProvider.js +11 -0
  200. package/build/hocs/DamConfigContext.d.ts +2 -0
  201. package/build/hocs/DamConfigContext.js +153 -0
  202. package/build/hocs/ThemeContext.d.ts +15 -0
  203. package/build/hocs/ThemeContext.js +131 -0
  204. package/build/hocs/ToastProvider.d.ts +2 -0
  205. package/build/hocs/ToastProvider.js +6 -0
  206. package/build/hocs/appConstants.d.ts +124 -0
  207. package/build/hocs/appConstants.js +211 -0
  208. package/build/hocs/configureAxios.d.ts +2 -0
  209. package/build/hocs/configureAxios.js +65 -0
  210. package/build/hocs/helpers.d.ts +17 -0
  211. package/build/hocs/helpers.js +201 -0
  212. package/build/index.d.ts +12 -0
  213. package/build/index.js +12 -0
  214. package/build/react-query/hooks/brand-hooks.d.ts +3 -0
  215. package/build/react-query/hooks/brand-hooks.js +10 -0
  216. package/build/react-query/hooks/folder-hooks.d.ts +7 -0
  217. package/build/react-query/hooks/folder-hooks.js +119 -0
  218. package/build/react-query/services/brand-services.d.ts +4 -0
  219. package/build/react-query/services/brand-services.js +41 -0
  220. package/build/react-query/services/file-services.d.ts +43 -0
  221. package/build/react-query/services/file-services.js +69 -0
  222. package/build/react-query/services/folder-services.d.ts +46 -0
  223. package/build/react-query/services/folder-services.js +87 -0
  224. package/build/react-query/services/image-picker-services.d.ts +5 -0
  225. package/build/react-query/services/image-picker-services.js +47 -0
  226. package/build/settings/InviteTeamModal.d.ts +12 -0
  227. package/build/settings/InviteTeamModal.js +174 -0
  228. package/build/settings/UpdateInvitationAccessType.d.ts +9 -0
  229. package/build/settings/UpdateInvitationAccessType.js +96 -0
  230. package/build/settings/getUserAvatar.d.ts +7 -0
  231. package/build/settings/getUserAvatar.js +11 -0
  232. package/build/style.css +1 -0
  233. package/build/types/assetType.d.ts +8 -0
  234. package/build/types/assetType.js +1 -0
  235. package/build/ui/pageTitle.d.ts +3 -0
  236. package/build/ui/pageTitle.js +4 -0
  237. package/build/utilities/FoldersContext.d.ts +16 -0
  238. package/build/utilities/FoldersContext.js +15 -0
  239. package/build/utilities/NavigatorProvider.d.ts +2 -0
  240. package/build/utilities/NavigatorProvider.js +10 -0
  241. package/build/utilities/constants/apiUrls.d.ts +97 -0
  242. package/build/utilities/constants/apiUrls.js +117 -0
  243. package/build/utilities/constants/imageUrls.d.ts +6 -0
  244. package/build/utilities/constants/imageUrls.js +6 -0
  245. package/build/utilities/constants/interface.d.ts +371 -0
  246. package/build/utilities/constants/interface.js +142 -0
  247. package/build/utilities/constants/messages.d.ts +55 -0
  248. package/build/utilities/constants/messages.js +55 -0
  249. package/build/utilities/constants/queryKeys.d.ts +16 -0
  250. package/build/utilities/constants/queryKeys.js +33 -0
  251. package/build/utilities/constants/routes.d.ts +22 -0
  252. package/build/utilities/constants/routes.js +22 -0
  253. package/build/utilities/helpers/validators.d.ts +12 -0
  254. package/build/utilities/helpers/validators.js +89 -0
  255. package/build/utilities/useAppNavigate.d.ts +2 -0
  256. package/build/utilities/useAppNavigate.js +35 -0
  257. package/build/utilities/useAppParams.d.ts +8 -0
  258. package/build/utilities/useAppParams.js +72 -0
  259. package/package.json +93 -0
@@ -0,0 +1,199 @@
1
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useEffect, useMemo } from "react";
3
+ import { Form, Input, InputNumber, DatePicker, Select, Checkbox, Radio, } from "antd";
4
+ import { find, first, get, includes, isArray, isNumber, map, mapValues, nth, } from "lodash";
5
+ import dayjs from "dayjs";
6
+ import { InputSupportedTypes, InputTypes, } from "../../utilities/constants/interface";
7
+ import { INVALID_URL } from "../../utilities/constants/messages";
8
+ import { useQueryClient } from "react-query";
9
+ import { getCurrentBrandUsers } from "../../react-query/hooks/brand-hooks";
10
+ import { getUserAvatar } from "../../settings/getUserAvatar";
11
+ import { useDamConfig } from "../../hocs/DamConfigContext";
12
+ const { RangePicker } = DatePicker;
13
+ export const buildInitialValues = (formData, metaFields, isEditMode) => {
14
+ const dataWithDefaultValues = metaFields.reduce((acc, field) => {
15
+ const id = get(field, "_id");
16
+ const defaultValue = get(field, "defaultValue");
17
+ if (defaultValue) {
18
+ acc[id] = defaultValue;
19
+ }
20
+ return acc;
21
+ }, {});
22
+ return mapValues(isEditMode ? formData : dataWithDefaultValues, (value, key) => {
23
+ const field = find(metaFields, { _id: key });
24
+ if (!field)
25
+ return value;
26
+ const defaultName = get(field, "defaultName");
27
+ const inputTypeSettings = get(field, "inputTypeSettings", {});
28
+ const allowMultiple = get(inputTypeSettings, `${InputSupportedTypes.ALLOW_MULTIPLE}`, false);
29
+ switch (defaultName) {
30
+ case InputTypes.DATE:
31
+ return value ? dayjs(value) : undefined;
32
+ case InputTypes.DATE_RANGE:
33
+ return isArray(value) && get(value, "length") === 2
34
+ ? [dayjs(first(value)), dayjs(nth(value, 1))]
35
+ : undefined;
36
+ case InputTypes.SELECT:
37
+ return allowMultiple ? value || [] : value !== null && value !== void 0 ? value : undefined;
38
+ case InputTypes.CHECKBOX:
39
+ return value || [];
40
+ default:
41
+ return value;
42
+ }
43
+ });
44
+ };
45
+ export const getFormItem = (item, fromDefaultValue, userOptions) => {
46
+ const name = get(item, "_id");
47
+ const label = get(item, "name");
48
+ const placeholder = get(item, "placeholder", "");
49
+ const defaultName = get(item, "defaultName");
50
+ const settings = get(item, "inputTypeSettings", {});
51
+ const options = get(item, "options", []);
52
+ const itemName = fromDefaultValue ? name : ["metadata", name];
53
+ const rules = fromDefaultValue
54
+ ? [...get(item, "additionalRules", [])]
55
+ : [];
56
+ if (get(item, "isMandatory")) {
57
+ rules.push({
58
+ required: true,
59
+ message: `${label} is required.`,
60
+ });
61
+ }
62
+ // NUMERIC_VALUE
63
+ if (get(settings, "NUMERIC_VALUE", null) === false) {
64
+ rules.push({
65
+ pattern: /^[^0-9]*$/,
66
+ message: "Numbers are not allowed.",
67
+ });
68
+ }
69
+ // SPECIAL_CHARACTERS
70
+ if (get(settings, "SPECIAL_CHARACTERS", null) === false) {
71
+ rules.push({
72
+ pattern: /^[a-zA-Z0-9\s]*$/,
73
+ message: "Special characters are not allowed.",
74
+ });
75
+ }
76
+ // CHARACTER_LIMIT
77
+ let maxLength = 255; // Default to 255 characters
78
+ if (get(settings, "CHARACTER_LIMIT.allow", null) === true) {
79
+ const min = get(settings, "CHARACTER_LIMIT.minValue");
80
+ const max = get(settings, "CHARACTER_LIMIT.maxValue");
81
+ let message = "";
82
+ const hasMin = isNumber(min);
83
+ const hasMax = isNumber(max);
84
+ if (hasMin && hasMax) {
85
+ message = `Must be between ${min} and ${max} characters.`;
86
+ }
87
+ else if (hasMin && !hasMax) {
88
+ message = `Minimum ${min} characters required.`;
89
+ }
90
+ else if (!hasMin && hasMax) {
91
+ message = `Maximum ${max} characters allowed.`;
92
+ }
93
+ rules.push(Object.assign(Object.assign(Object.assign({}, (hasMin ? { min } : {})), (hasMax ? { max } : {})), { message }));
94
+ if (hasMax && isNumber(max)) {
95
+ maxLength = max;
96
+ }
97
+ }
98
+ // REGEX
99
+ if (get(settings, "REGEX.allow") && get(settings, "REGEX.value")) {
100
+ const rawRegex = get(settings, "REGEX.value", "/.*/");
101
+ try {
102
+ const regex = new RegExp(rawRegex.replace(/\//g, ""));
103
+ rules.push({
104
+ pattern: regex,
105
+ message: `Must match pattern ${rawRegex}`,
106
+ });
107
+ }
108
+ catch (err) {
109
+ console.warn("Invalid regex: ", rawRegex);
110
+ }
111
+ }
112
+ // VALUE_RANGE
113
+ if (defaultName === InputTypes.NUMBERS &&
114
+ get(settings, "VALUE_RANGE.allow")) {
115
+ const min = get(settings, "VALUE_RANGE.minValue");
116
+ const max = get(settings, "VALUE_RANGE.maxValue");
117
+ const hasMin = isNumber(min);
118
+ const hasMax = isNumber(max);
119
+ let message = "";
120
+ if (hasMin && hasMax) {
121
+ message = `Must be between ${min} and ${max}.`;
122
+ }
123
+ else if (hasMin && !hasMax) {
124
+ message = `Minimum value is ${min}.`;
125
+ }
126
+ else if (!hasMin && hasMax) {
127
+ message = `Maximum value is ${max}.`;
128
+ }
129
+ rules.push(Object.assign(Object.assign(Object.assign({ type: "number" }, (hasMin ? { min } : {})), (hasMax ? { max } : {})), { message }));
130
+ }
131
+ switch (defaultName) {
132
+ case InputTypes.TEXT:
133
+ return (_jsx(Form.Item, { name: itemName, label: label, rules: rules, children: _jsx(Input, { placeholder: placeholder, maxLength: maxLength, showCount: true }) }, name));
134
+ case InputTypes.PARAGRAPH:
135
+ return (_jsx(Form.Item, { name: itemName, label: label, rules: rules, children: _jsx(Input.TextArea, { rows: 4, placeholder: placeholder, maxLength: maxLength, showCount: true }) }, name));
136
+ case InputTypes.DATE_RANGE:
137
+ return (_jsx(Form.Item, { name: itemName, label: label, rules: rules, children: _jsx(RangePicker, { showTime: !!get(settings, `${InputSupportedTypes.ALLOW_TIME}.allow`), style: { width: "100%" }, placeholder: ["Start", "End"], placement: "bottomLeft" }) }, name));
138
+ case InputTypes.LINK:
139
+ rules.push({
140
+ type: "url",
141
+ message: INVALID_URL,
142
+ });
143
+ return (_jsx(Form.Item, { name: itemName, label: label, rules: rules, children: _jsx(Input, { placeholder: placeholder, maxLength: maxLength, showCount: true }) }, name));
144
+ case InputTypes.CHECKBOX:
145
+ return (_jsx(Form.Item, { name: itemName, label: label, children: _jsx(Checkbox.Group, { options: map(options, (opt) => ({
146
+ label: get(opt, "label"),
147
+ value: get(opt, "value"),
148
+ })) }) }, name));
149
+ case InputTypes.NUMBERS:
150
+ return (_jsx(Form.Item, { name: itemName, label: label, rules: rules, children: _jsx(InputNumber, { style: { width: "100%" }, placeholder: placeholder }) }, name));
151
+ case InputTypes.DATE:
152
+ return (_jsx(Form.Item, { name: itemName, label: label, rules: rules, children: _jsx(DatePicker, { showTime: !!get(settings, `${InputSupportedTypes.ALLOW_TIME}.allow`), style: { width: "100%" }, placeholder: placeholder }) }, name));
153
+ case InputTypes.PERSON:
154
+ return (_jsx(Form.Item, { name: itemName, label: label, rules: rules, children: _jsx(Select, { mode: get(settings, InputSupportedTypes.ALLOW_MULTIPLE)
155
+ ? "multiple"
156
+ : undefined, allowClear: !!get(settings, InputSupportedTypes.ALLOW_CLEAR), showSearch: !!get(settings, InputSupportedTypes.SEARCHABLE), filterOption: (inputValue, option) => {
157
+ const name = get(option, "name") || "";
158
+ const email = get(option, "email") || "";
159
+ if (includes(name.toLowerCase(), inputValue.toLowerCase()) ||
160
+ includes(email.toLowerCase(), inputValue.toLowerCase())) {
161
+ return true;
162
+ }
163
+ return false;
164
+ }, placeholder: placeholder, options: userOptions, optionFilterProp: "children" }) }, name));
165
+ case InputTypes.TEAM:
166
+ case InputTypes.SELECT:
167
+ return (_jsx(Form.Item, { name: itemName, label: label, rules: rules, children: _jsx(Select, { mode: get(settings, InputSupportedTypes.ALLOW_MULTIPLE)
168
+ ? "multiple"
169
+ : undefined, allowClear: !!get(settings, InputSupportedTypes.ALLOW_CLEAR), showSearch: !!get(settings, InputSupportedTypes.SEARCHABLE), filterOption: (input, option) => { var _a; return ((_a = option === null || option === void 0 ? void 0 : option.label) === null || _a === void 0 ? void 0 : _a.toLowerCase().indexOf(input.toLowerCase())) >= 0; }, placeholder: placeholder, options: map(options, (opt) => ({
170
+ label: get(opt, "label"),
171
+ value: get(opt, "value"),
172
+ })) }) }, name));
173
+ case InputTypes.RADIO:
174
+ return (_jsx(Form.Item, { name: itemName, label: label, children: _jsx(Radio.Group, { options: map(options, (opt) => ({
175
+ label: get(opt, "label"),
176
+ value: get(opt, "value"),
177
+ })) }) }, name));
178
+ default:
179
+ return null;
180
+ }
181
+ };
182
+ const MetaForm = ({ metaFields, metaData, form, isEditMode, }) => {
183
+ const damConfig = useDamConfig();
184
+ const { brand, teams } = damConfig;
185
+ const brandId = get(brand, "_id");
186
+ const queryClient = useQueryClient();
187
+ const brandUsers = getCurrentBrandUsers(queryClient, brandId);
188
+ useEffect(() => {
189
+ const formData = {
190
+ metadata: buildInitialValues(metaData, metaFields, isEditMode),
191
+ };
192
+ form.setFieldsValue(formData);
193
+ }, [metaData, metaFields]);
194
+ const userOptions = useMemo(() => {
195
+ return map(brandUsers, (user) => getUserAvatar(user));
196
+ }, [brandUsers, brandId]);
197
+ return (_jsx(_Fragment, { children: metaFields.map((item) => getFormItem(item, false, userOptions)) }));
198
+ };
199
+ export default MetaForm;
@@ -0,0 +1,8 @@
1
+ import { FormInstance } from "antd";
2
+ import { AssetTemplateEntity, FileEntity } from "../../utilities/constants/interface";
3
+ declare const Metadata: ({ file, asset, form, }: {
4
+ file?: FileEntity;
5
+ asset: AssetTemplateEntity;
6
+ form: FormInstance;
7
+ }) => JSX.Element;
8
+ export default Metadata;
@@ -0,0 +1,52 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useMemo, useState } from "react";
3
+ import { get, isEmpty } from "lodash";
4
+ import Loader from "../../common/loader/loader";
5
+ import MetaForm from "./MetaForm";
6
+ import { useDamConfig } from "../../hocs/DamConfigContext";
7
+ import { createApiClient } from "../../hocs/configureAxios";
8
+ import { META_DATA_EMPTY_URL } from "../../utilities/constants/imageUrls";
9
+ const Metadata = ({ file, asset, form, }) => {
10
+ const damConfig = useDamConfig();
11
+ const api = useMemo(() => createApiClient(damConfig), [damConfig]);
12
+ const [state, setState] = useState({
13
+ assetsLoading: false,
14
+ assets: [],
15
+ loading: false,
16
+ templateLoading: false,
17
+ });
18
+ const { templateLoading } = state;
19
+ // useEffect(() => {
20
+ // if (assetId) {
21
+ // fetchTemplate();
22
+ // }
23
+ // }, [assetId]);
24
+ // const fetchTemplate = async () => {
25
+ // setState((prevState) => ({ ...prevState, templateLoading: true }));
26
+ // try {
27
+ // const response = await api.get(
28
+ // `${FETCH_ASSET_URL.replace(":assetId", assetId)}`
29
+ // );
30
+ // setState((prevState) => ({
31
+ // ...prevState,
32
+ // assetTemplate: get(response, "data", {}),
33
+ // templateLoading: false,
34
+ // }));
35
+ // setMetaFields(get(response, "data.metadataFields", []));
36
+ // } catch (error) {
37
+ // setState((prevState) => ({
38
+ // ...prevState,
39
+ // assetTemplate: {},
40
+ // templateLoading: false,
41
+ // }));
42
+ // showNotification(
43
+ // get(error, "message", SOMETHING_WENT_WRONG),
44
+ // NotificationStatus.ERROR
45
+ // );
46
+ // }
47
+ // };
48
+ const metaFields = useMemo(() => get(asset, "metadataFields", []), [asset]);
49
+ const metaData = useMemo(() => get(file, "metadata", {}), [file]);
50
+ return (_jsx("div", { className: "", children: templateLoading ? (_jsx(Loader, {})) : (_jsx(_Fragment, { children: isEmpty(metaFields) ? (_jsxs("div", { className: `md-lib-flex md-lib-flex-col md-lib-items-center md-lib-justify-center md-lib-min-h-[calc(100vh-127px)]`, children: [_jsx("img", { src: META_DATA_EMPTY_URL, alt: "No comments", width: 182, height: 114 }), _jsx("p", { className: "md-lib-pt-3 md-lib-font-semibold md-lib-text-textColor dark:md-lib-text-darkTextColor", children: "No metadata has been added yet" })] })) : (_jsx(MetaForm, { metaFields: metaFields, metaData: metaData, form: form, isEditMode: (file === null || file === void 0 ? void 0 : file._id) ? true : false })) })) }));
51
+ };
52
+ export default Metadata;
@@ -0,0 +1,9 @@
1
+ import { FileEntity, FolderEntity } from "../../utilities/constants/interface";
2
+ declare const PdfOptions: ({ zoom, setZoom, currentPage, totalPages, file, }: {
3
+ zoom: number;
4
+ setZoom: (z: number) => void;
5
+ currentPage: number;
6
+ totalPages: number;
7
+ file: FileEntity & FolderEntity;
8
+ }) => JSX.Element;
9
+ export default PdfOptions;
@@ -0,0 +1,35 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { AiOutlineInfoCircle, AiOutlineZoomIn, AiOutlineZoomOut, } from "react-icons/ai";
4
+ import { FiChevronDown } from "react-icons/fi";
5
+ import { Dropdown, Popover } from "antd";
6
+ import { FileInfoContent } from "../../common/CustomElements";
7
+ import ManageFile from "./ManageFile";
8
+ const AiOutlineInfoCircleIcon = AiOutlineInfoCircle;
9
+ const AiOutlineZoomOutIcon = AiOutlineZoomOut;
10
+ const FiChevronDownIcon = FiChevronDown;
11
+ const AiOutlineZoomInIcon = AiOutlineZoomIn;
12
+ const zoomLevels = [0.1, 0.25, 0.5, 0.75, 1.0];
13
+ const PdfOptions = ({ zoom, setZoom, currentPage, totalPages, file, }) => {
14
+ const [state, setState] = useState({
15
+ showFileAccess: false,
16
+ });
17
+ const { showFileAccess } = state;
18
+ const handleZoomChange = ({ key }) => {
19
+ setZoom(parseFloat(key));
20
+ };
21
+ const items = zoomLevels.map((z) => ({
22
+ key: z.toString(),
23
+ label: `${Math.round(z * 100)}%`,
24
+ }));
25
+ const toggleFileAccess = () => {
26
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { showFileAccess: !prevState.showFileAccess })));
27
+ };
28
+ return (_jsxs("div", { className: "md-lib-fixed md-lib-bottom-10 md-lib-left-1/2 -md-lib-translate-x-1/2 md-lib-bg-white dark:md-lib-bg-darkPrimary md-lib-rounded-xl md-lib-shadow-md md-lib-px-4 md-lib-py-2 md-lib-flex md-lib-items-center md-lib-gap-4 md-lib-border md-lib-border-borderColor dark:md-lib-border-darkBorderColor md-lib-z-50", children: [_jsx(Popover, { content: _jsx(FileInfoContent, { file: file }), title: "File Info", placement: "top", children: _jsx("button", { className: "md-lib-p-2 hover:md-lib-bg-secondaryColor hover:dark:md-lib-bg-darkPrimaryHoverColor md-lib-rounded-lg", onClick: toggleFileAccess, children: _jsx(AiOutlineInfoCircleIcon, { className: "md-lib-text-[20px]" }) }) }), _jsx("p", { className: "md-lib-h-10 md-lib-w-10 md-lib-flex md-lib-items-center md-lib-justify-center md-lib-text-base md-lib-text-secondaryTextColor dark:md-lib-text-darkSecondaryTextColor md-lib-border-borderColor md-lib-border md-lib-rounded-lg", children: currentPage + 1 }), _jsx("p", { className: "md-lib-text-textColor dark:md-lib-text-darkTextColor", children: "/" }), _jsx("p", { className: "md-lib-h-10 md-lib-w-10 md-lib-flex md-lib-items-center md-lib-justify-center md-lib-bg-secondaryColor dark:md-lib-bg-darkPrimaryHoverColor md-lib-rounded-lg", children: totalPages }), _jsx("div", { className: "md-lib-w-[1px] md-lib-h-5 md-lib-bg-borderColor dark:md-lib-bg-darkBorderColor" }), _jsx("button", { className: "md-lib-h-10 md-lib-w-10 md-lib-flex md-lib-items-center md-lib-justify-center hover:md-lib-bg-secondaryColor hover:dark:md-lib-bg-darkPrimaryHoverColor md-lib-rounded-lg", onClick: () => setZoom(Math.max(0.5, zoom - 0.1)), disabled: zoom <= 0.1, children: _jsx(AiOutlineZoomOutIcon, { className: "md-lib-text-[20px]" }) }), _jsx(Dropdown, { menu: {
29
+ items: items,
30
+ onClick: handleZoomChange,
31
+ selectable: true,
32
+ selectedKeys: [`${Math.round(zoom * 100)}%`],
33
+ }, trigger: ["click"], placement: "top", children: _jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-gap-1 md-lib-px-3 md-lib-py-1 md-lib-bg-secondaryColor dark:md-lib-bg-darkPrimaryHoverColor md-lib-rounded-md md-lib-cursor-pointer md-lib-text-sm md-lib-text-textColor dark:md-lib-text-darkTextColor", children: [`${Math.round(zoom * 100)}%`, _jsx(FiChevronDownIcon, { className: "md-lib-text-[16px]" })] }) }), _jsx("button", { className: "md-lib-h-10 md-lib-w-10 md-lib-flex md-lib-items-center md-lib-justify-center hover:md-lib-bg-secondaryColor hover:dark:md-lib-bg-darkPrimaryHoverColor md-lib-rounded-lg", onClick: () => setZoom(Math.min(1.5, zoom + 0.1)), disabled: zoom >= 1.5, children: _jsx(AiOutlineZoomInIcon, { className: "md-lib-text-[20px]" }) }), showFileAccess && (_jsx(ManageFile, { file: file, onClose: toggleFileAccess, open: showFileAccess }))] }));
34
+ };
35
+ export default PdfOptions;
@@ -0,0 +1,8 @@
1
+ import "@react-pdf-viewer/core/lib/styles/index.css";
2
+ import "@react-pdf-viewer/zoom/lib/styles/index.css";
3
+ import { FileEntity } from "../../utilities/constants/interface";
4
+ declare const PDFViewer: ({ fileUrl, file, }: {
5
+ fileUrl: string;
6
+ file: FileEntity;
7
+ }) => JSX.Element;
8
+ export default PDFViewer;
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useState } from "react";
3
+ import { Worker, Viewer, ScrollMode } from "@react-pdf-viewer/core";
4
+ import { zoomPlugin } from "@react-pdf-viewer/zoom";
5
+ import "@react-pdf-viewer/core/lib/styles/index.css";
6
+ import "@react-pdf-viewer/zoom/lib/styles/index.css";
7
+ import PdfOptions from "./PdfOptions";
8
+ const PDFViewer = ({ fileUrl, file, }) => {
9
+ const [currentPage, setCurrentPage] = useState(0);
10
+ const [totalPages, setTotalPages] = useState(0);
11
+ const [zoom, setZoom] = useState(1.0);
12
+ const zoomPluginInstance = zoomPlugin();
13
+ useEffect(() => {
14
+ zoomPluginInstance.zoomTo(zoom);
15
+ }, [zoom]);
16
+ return (_jsxs("div", { className: "md-lib-relative md-lib-w-full", children: [_jsx(Worker, { workerUrl: `https://unpkg.com/pdfjs-dist@3.11.174/build/pdf.worker.min.js`, children: _jsx("div", { style: { height: "calc(100vh - 80px)" }, children: _jsx(Viewer, { fileUrl: fileUrl, scrollMode: ScrollMode.Vertical, plugins: [zoomPluginInstance], onPageChange: (e) => setCurrentPage(e.currentPage), onDocumentLoad: (e) => setTotalPages(e.doc.numPages), initialPage: currentPage, defaultScale: zoom }) }) }), _jsx(PdfOptions, { zoom: zoom, setZoom: setZoom, currentPage: currentPage, totalPages: totalPages, file: file })] }));
17
+ };
18
+ export default PDFViewer;
@@ -0,0 +1,10 @@
1
+ import { FileEntity } from "../../utilities/constants/interface";
2
+ declare const PreviewDetails: ({ file, hasPrev, hasNext, onPrev, onNext, showFilePreview, }: {
3
+ file: FileEntity;
4
+ hasPrev: boolean;
5
+ hasNext: boolean;
6
+ onPrev: () => void;
7
+ onNext: () => void;
8
+ showFilePreview?: boolean;
9
+ }) => JSX.Element;
10
+ export default PreviewDetails;
@@ -0,0 +1,53 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { Button } from "antd";
3
+ import { GoArrowLeft, GoArrowRight } from "react-icons/go";
4
+ import { get, startsWith } from "lodash";
5
+ import ImageViewer from "./ImageViewer";
6
+ import { useMemo } from "react";
7
+ import VideoPlayer from "./VideoPlayer";
8
+ import useAppParams from "../../utilities/useAppParams";
9
+ // const PDFViewer = lazy(() => import("./PdfViewer"));
10
+ const GoArrowLeftIcon = GoArrowLeft;
11
+ const GoArrowRightIcon = GoArrowRight;
12
+ const PreviewDetails = ({ file, hasPrev, hasNext, onPrev, onNext, showFilePreview, }) => {
13
+ const { id } = useAppParams();
14
+ const mimetype = get(file, "mimetype", "");
15
+ const fileComponent = useMemo(() => {
16
+ if (startsWith(mimetype, "image/")) {
17
+ return _jsx(ImageViewer, { file: file, showFilePreview: showFilePreview });
18
+ }
19
+ else if (startsWith(mimetype, "video/")) {
20
+ return _jsx(VideoPlayer, { src: get(file, "s3Url") || get(file, "downloadUrl") || get(file, "thumbnailUrl", "") });
21
+ }
22
+ // else if (mimetype === "application/pdf") {
23
+ // // return <PDFViewer fileUrl={get(file, "s3Url")} file={file} />;
24
+ // } else if (
25
+ // includes(
26
+ // [
27
+ // "text/csv",
28
+ // "application/vnd.ms-excel",
29
+ // "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
30
+ // ],
31
+ // mimetype
32
+ // )
33
+ // ) {
34
+ // return (
35
+ // <div className="p-4 text-center text-lg text-textColor dark:text-darkTextColor">
36
+ // Preview not supported for this file type.{" "}
37
+ // <a href={get(file, "s3Url")} className="underline ml-1">
38
+ // Download File
39
+ // </a>
40
+ // </div>
41
+ // );
42
+ // }
43
+ else {
44
+ return (_jsxs("div", { className: "p-4 text-center text-lg text-textColor dark:text-darkTextColor", children: ["Preview not supported for this file type.", " ", _jsx("a", { href: get(file, "s3Url"), download: true, className: "underline ml-1", children: "Download File" })] })
45
+ // <div className="p-4 text-center text-lg text-textColor dark:text-darkTextColor">
46
+ // Unsupported file type.
47
+ // </div>
48
+ );
49
+ }
50
+ }, [mimetype, file]);
51
+ return (_jsxs(_Fragment, { children: [fileComponent, !id && (_jsxs(_Fragment, { children: [_jsx(Button, { icon: _jsx(GoArrowLeftIcon, { size: 24 }), className: "md-lib-h-11 md-lib-bg-white !md-lib-w-12 md-lib-rounded-lg md-lib-text-textColor dark:md-lib-text-darkTextColor dark:md-lib-bg-darkPrimary md-lib-absolute md-lib-left-6 md-lib-top-1/2 -md-lib-translate-y-1/2", onClick: onPrev, disabled: !hasPrev }), _jsx(Button, { icon: _jsx(GoArrowRightIcon, { size: 24 }), className: "md-lib-h-11 md-lib-bg-white !md-lib-w-12 md-lib-rounded-lg md-lib-text-textColor dark:md-lib-text-darkTextColor dark:md-lib-bg-darkPrimary md-lib-absolute md-lib-right-6 md-lib-top-1/2 -md-lib-translate-y-1/2", onClick: onNext, disabled: !hasNext })] }))] }));
52
+ };
53
+ export default PreviewDetails;
@@ -0,0 +1,4 @@
1
+ declare const VideoPlayer: ({ src }: {
2
+ src: string;
3
+ }) => JSX.Element;
4
+ export default VideoPlayer;
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useRef, useState } from "react";
3
+ const VideoPlayer = ({ src }) => {
4
+ const videoRef = useRef(null);
5
+ const [isPlaying, setIsPlaying] = useState(false);
6
+ const togglePlay = () => {
7
+ const video = videoRef.current;
8
+ if (!video)
9
+ return;
10
+ if (video.paused) {
11
+ video.play();
12
+ setIsPlaying(true);
13
+ }
14
+ else {
15
+ video.pause();
16
+ setIsPlaying(false);
17
+ }
18
+ };
19
+ return (_jsxs(_Fragment, { children: [" ", _jsx("div", { className: "md-lib-relative md-lib-max-w-4xl md-lib-w-full md-lib-aspect-video md-lib-mx-auto md-lib-rounded-xl md-lib-overflow-hidden md-lib-bg-black md-lib-shadow-lg", children: _jsx("video", { ref: videoRef, className: "md-lib-w-full md-lib-h-full", src: src, controls: true }) })] }));
20
+ };
21
+ export default VideoPlayer;
@@ -0,0 +1,7 @@
1
+ import { AntOptionType } from "../../utilities/constants/interface";
2
+ declare function AssetSelectionFormItem({ handleAssetTemplateChange, assetOptions, assetsLoading, }: {
3
+ handleAssetTemplateChange: (value: any) => void;
4
+ assetOptions: AntOptionType[];
5
+ assetsLoading: boolean;
6
+ }): JSX.Element;
7
+ export default AssetSelectionFormItem;
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { ENTITY_REQUIRED } from "../../utilities/constants/messages";
3
+ import { Form, Select } from "antd";
4
+ function AssetSelectionFormItem({ handleAssetTemplateChange, assetOptions, assetsLoading, }) {
5
+ return (_jsx(Form.Item, { name: "assetId", label: "Choose a template for metadata", rules: [
6
+ {
7
+ required: true,
8
+ message: ENTITY_REQUIRED.replace(":entity", "Asset"),
9
+ },
10
+ ], children: _jsx(Select, { placeholder: "Select template", size: "large", showSearch: true, options: assetOptions, allowClear: true, loading: assetsLoading, optionFilterProp: "label", onChange: (val) => {
11
+ handleAssetTemplateChange(val);
12
+ } }) }));
13
+ }
14
+ export default AssetSelectionFormItem;
@@ -0,0 +1,6 @@
1
+ declare function FolderTabs({ folderIds, selectedFolderId, setSelectedFolderId, }: {
2
+ folderIds?: string[];
3
+ selectedFolderId: string;
4
+ setSelectedFolderId: (value: string) => void;
5
+ }): JSX.Element;
6
+ export default FolderTabs;
@@ -0,0 +1,90 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { capitalize, filter, first, flatMap, get, includes, initial, isEmpty, last, map, nth, } from "lodash";
3
+ import { useEffect, useMemo, useRef, useState } from "react";
4
+ import { FaArrowLeftLong } from "react-icons/fa6";
5
+ import LoadMoreItems from "../../common/LoadMoreItems";
6
+ import { useFolders } from "../../react-query/services/folder-services";
7
+ import { generateFoldersQueryKey, QueryKeys, } from "../../utilities/constants/queryKeys";
8
+ import { DriveModes } from "../../utilities/constants/interface";
9
+ import { DEFAULT_PAGE } from "../../hocs/appConstants";
10
+ import Loader from "../../common/loader/loader";
11
+ import { SOMETHING_WENT_WRONG } from "../../utilities/constants/messages";
12
+ import AddFolder from "../AddFolder";
13
+ import { FaFolder } from "react-icons/fa";
14
+ import { FiChevronRight } from "react-icons/fi";
15
+ import { Tabs } from "antd";
16
+ import { useDamConfig } from "../../hocs/DamConfigContext";
17
+ import { createApiClient } from "../../hocs/configureAxios";
18
+ import { NOT_FOUND_IMAGE_URL } from "../../utilities/constants/imageUrls";
19
+ const FaFolderIcon = FaFolder;
20
+ const FiChevronRightIcon = FiChevronRight;
21
+ const FaArrowLeftLongIcon = FaArrowLeftLong;
22
+ function FolderTabs({ folderIds = [], selectedFolderId, setSelectedFolderId, }) {
23
+ const damConfig = useDamConfig();
24
+ const { rootFolderId } = damConfig;
25
+ const api = useMemo(() => createApiClient(damConfig), [damConfig]);
26
+ const [state, setState] = useState({
27
+ activeTabKey: DriveModes.RECENTS,
28
+ parentFoldersList: [],
29
+ openAddFolder: false,
30
+ });
31
+ const { activeTabKey, parentFoldersList, openAddFolder } = state;
32
+ const toggleAddFolder = () => {
33
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { openAddFolder: !prevState.openAddFolder })));
34
+ };
35
+ const { data: foldersPaginatedData, isLoading, hasNextPage, fetchNextPage, refetch, isFetching, error, } = useFolders(api, generateFoldersQueryKey(activeTabKey), Object.assign(Object.assign({ page: DEFAULT_PAGE }, (activeTabKey
36
+ ? {
37
+ category: activeTabKey && isEmpty(parentFoldersList)
38
+ ? activeTabKey
39
+ : QueryKeys.ALL,
40
+ }
41
+ : {})), { includeFiles: false, includeSubFoldersCount: true, fetchMainFolders: true }), last(parentFoldersList) ? last(parentFoldersList) : rootFolderId);
42
+ const folders = useMemo(() => {
43
+ return !!foldersPaginatedData
44
+ ? flatMap(get(foldersPaginatedData, "pages"), "folders")
45
+ : [];
46
+ }, [foldersPaginatedData]);
47
+ const prevActiveKeyRef = useRef();
48
+ useEffect(() => {
49
+ const prevActiveKeyState = prevActiveKeyRef.current;
50
+ const shouldRefetch = activeTabKey !== prevActiveKeyState;
51
+ if (shouldRefetch) {
52
+ refetch();
53
+ }
54
+ prevActiveKeyRef.current = activeTabKey;
55
+ }, [activeTabKey, prevActiveKeyRef]);
56
+ function RenderTabContent() {
57
+ return (_jsx(_Fragment, { children: isLoading ? (_jsx(Loader, {})) : isEmpty(folders) ? (_jsxs("div", { className: "md-lib-flex md-lib-flex-col md-lib-items-center md-lib-justify-center ", children: [_jsx("img", { src: NOT_FOUND_IMAGE_URL, alt: "Not Found", width: 300, height: 300 }), _jsx("p", { className: "md-lib-mt-3 md-lib-text-sm md-lib-font-semibold", children: error
58
+ ? get(error, "message", SOMETHING_WENT_WRONG)
59
+ : includes(Object.values(DriveModes), activeTabKey)
60
+ ? "No data found"
61
+ : "No files has been created yet" }), includes(Object.values(DriveModes), activeTabKey) && (_jsx(AddFolder, { open: openAddFolder, handleCancel: toggleAddFolder }))] })) : (_jsxs("div", { className: "md-lib-h-[300px] md-lib-overflow-y-auto", children: [map(isEmpty(folderIds)
62
+ ? folders
63
+ : filter(folders, (fol) => !includes(folderIds, get(fol, "_id"))), (folder) => (_jsxs("div", { role: "button", tabIndex: 0, className: `md-lib-flex md-lib-justify-between md-lib-items-center md-lib-px-6 md-lib-py-3 md-lib-rounded-md hover:md-lib-bg-secondaryHoverColor dark:hover:md-lib-bg-darkSecondaryColor md-lib-cursor-pointer md-lib-w-full ${selectedFolderId === get(folder, "_id")
64
+ ? "md-lib-bg-secondaryHoverColor dark:md-lib-bg-darkSecondaryColor"
65
+ : ""}`, onClick: () => {
66
+ setSelectedFolderId(get(folder, "_id") || "");
67
+ }, onKeyDown: (e) => {
68
+ if (e.key === "Enter" || e.key === " ") {
69
+ e.preventDefault();
70
+ setSelectedFolderId(get(folder, "_id") || "");
71
+ }
72
+ }, children: [_jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-gap-2 md-lib-text-textColor dark:md-lib-text-darkTextColor md-lib-truncate md-lib-max-w-64 md-lib-min-w-0", title: get(folder, "name", "N/A"), children: [_jsx(FaFolderIcon, { className: "md-lib-text-primaryColor md-lib-shrink-0" }), _jsx("span", { className: "md-lib-truncate", children: get(folder, "name", "N/A") })] }), !!get(folder, "subFoldersCount") && (_jsx(FiChevronRightIcon, { size: 20, className: "md-lib-shrink-0", onClick: (e) => {
73
+ e.stopPropagation();
74
+ const folderId = get(folder, "_id");
75
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { parentFoldersList: [
76
+ ...prevState.parentFoldersList,
77
+ folderId,
78
+ ] })));
79
+ setSelectedFolderId(folderId || "");
80
+ } }))] }, get(folder, "_id")))), _jsx(LoadMoreItems, { hasNextPage: !!hasNextPage, fetchNextPage: fetchNextPage, isItemsFetching: isFetching })] })) }));
81
+ }
82
+ const currentFolder = useMemo(() => {
83
+ return get(first(get(foldersPaginatedData, "pages", [])), "folder", {});
84
+ }, [foldersPaginatedData]);
85
+ return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "md-lib-text-sm md-lib-mb-4 md-lib-text-secondaryTextColor", children: ["Current location:", " ", _jsx("span", { className: "font-semibold truncate ", title: get(currentFolder, "name", capitalize(activeTabKey)), children: get(currentFolder, "name", capitalize(activeTabKey)) })] }), get(parentFoldersList, "length") ? (_jsxs("div", { className: "md-lib-flex md-lib-flex-col md-lib-gap-3", children: [_jsxs("div", { className: "md-lib-flex md-lib-gap-4 md-lib-cursor-pointer md-lib-items-center", onClick: () => {
86
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { parentFoldersList: initial(prevState.parentFoldersList) })));
87
+ setSelectedFolderId("");
88
+ }, children: [_jsx(FaArrowLeftLongIcon, {}), _jsx("span", { className: "md-lib-font-semibold md-lib-truncate md-lib-max-w-7xl", title: get(nth(get(currentFolder, "tree", []), get(currentFolder, "tree.length") - 1), "name", capitalize(activeTabKey)), children: get(nth(get(currentFolder, "tree", []), get(currentFolder, "tree.length") - 1), "name", capitalize(activeTabKey)) })] }), _jsx(RenderTabContent, {})] })) : (_jsxs(Tabs, { activeKey: activeTabKey, onChange: (key) => setState((prev) => (Object.assign(Object.assign({}, prev), { activeTabKey: key }))), children: [_jsx(Tabs.TabPane, { tab: "Suggested", children: _jsx(RenderTabContent, {}) }, DriveModes.RECENTS), _jsx(Tabs.TabPane, { tab: "All locations", children: _jsx(RenderTabContent, {}) }, "all")] }))] }));
89
+ }
90
+ export default FolderTabs;
@@ -0,0 +1,9 @@
1
+ import { FileEntity, ResponseFile } from "../../utilities/constants/interface";
2
+ declare function MapFile({ open, handleCancel, filesList, fromUpload, parentFolderId, }: {
3
+ open?: boolean;
4
+ handleCancel?: (shouldDelete?: boolean) => void;
5
+ filesList: ResponseFile[] | FileEntity[];
6
+ fromUpload?: boolean;
7
+ parentFolderId?: string;
8
+ }): JSX.Element;
9
+ export default MapFile;