@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,268 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
11
+ import { ICON_SIZE } from "../hocs/appConstants";
12
+ import { Typography } from "antd";
13
+ import { useMemo, useState } from "react";
14
+ import { DragDropContext, Droppable, Draggable } from "react-beautiful-dnd";
15
+ import DraggedField from "./DraggedField";
16
+ import AddFieldProperties from "./AddFieldProperties";
17
+ import { InputTypes, NotificationStatus, } from "../utilities/constants/interface";
18
+ import { filter, find, first, get, isEqual, map, reduce, toNumber, uniqueId, } from "lodash";
19
+ import { CiCalendarDate, CiLink, CiText } from "react-icons/ci";
20
+ import { BsTextParagraph } from "react-icons/bs";
21
+ import { RiNumbersLine } from "react-icons/ri";
22
+ import { MdOutlineDateRange, MdOutlineGroup } from "react-icons/md";
23
+ import { GoSingleSelect } from "react-icons/go";
24
+ import { IoIosRadioButtonOff } from "react-icons/io";
25
+ import { IoCheckboxOutline } from "react-icons/io5";
26
+ import { FaRegUser } from "react-icons/fa";
27
+ import { showNotification } from "../common/notifications";
28
+ import { DELETE_CONFIRMATION_MESSAGE, DELETE_MESSAGE_DESCRIPTION, DELETE_OK_TEXT, DELETE_SUCCESS, INPUT_SETTINGS_VALIDATION_ERROR, INPUT_SETTINGS_VALIDATION_ERROR_AT_SWITCH_INPUT, SOMETHING_WENT_WRONG, } from "../utilities/constants/messages";
29
+ import { getInputTypeValidationErrors } from "../utilities/helpers/validators";
30
+ import { DELETE_ASSET_FIELD_URL } from "../utilities/constants/apiUrls";
31
+ import { DeleteConfirmationModal } from "../common/CustomElements";
32
+ import { createApiClient } from "../hocs/configureAxios";
33
+ import { useDamConfig } from "../hocs/DamConfigContext";
34
+ import { EMPTY_ASSET_TEMPLATE_WIDGETS_URL } from "../utilities/constants/imageUrls";
35
+ import _ from "lodash";
36
+ import useAppParams from "../utilities/useAppParams";
37
+ export const getWidgetIcon = (defaultName) => {
38
+ if (defaultName === undefined || defaultName === null) {
39
+ return null;
40
+ }
41
+ // Ensure it's a string type
42
+ const nameString = String(defaultName).trim();
43
+ if (!nameString) {
44
+ return null;
45
+ }
46
+ try {
47
+ switch (nameString.toUpperCase()) {
48
+ case InputTypes.TEXT:
49
+ return CiText;
50
+ case InputTypes.PARAGRAPH:
51
+ return BsTextParagraph;
52
+ case InputTypes.NUMBERS:
53
+ return RiNumbersLine;
54
+ case InputTypes.DATE:
55
+ return CiCalendarDate;
56
+ case InputTypes.DATE_RANGE:
57
+ return MdOutlineDateRange;
58
+ case InputTypes.SELECT:
59
+ return GoSingleSelect;
60
+ case InputTypes.LINK:
61
+ return CiLink;
62
+ case InputTypes.RADIO:
63
+ return IoIosRadioButtonOff;
64
+ case InputTypes.CHECKBOX:
65
+ return IoCheckboxOutline;
66
+ case InputTypes.PERSON:
67
+ return FaRegUser;
68
+ case InputTypes.TEAM:
69
+ return MdOutlineGroup;
70
+ default:
71
+ return null;
72
+ }
73
+ }
74
+ catch (error) {
75
+ console.warn('Error in getWidgetIcon:', error, 'defaultName:', defaultName);
76
+ return null;
77
+ }
78
+ };
79
+ export default function FieldsSection({ name, inputTypes, transformInputTypePayload, currentFieldIndex, setCurrentFieldIndex, fields, setState, showOutputFormat, imagePickerOutputFormat, }) {
80
+ const { id } = useAppParams();
81
+ const [fieldState, setFieldState] = useState({
82
+ showConfirmModal: false,
83
+ selectedField: null,
84
+ loading: false,
85
+ });
86
+ const { showConfirmModal, selectedField, loading } = fieldState;
87
+ const damConfig = useDamConfig();
88
+ const api = useMemo(() => createApiClient(damConfig), [damConfig]);
89
+ const toggleConfirmModal = (field = null) => {
90
+ setFieldState((prevState) => (Object.assign(Object.assign({}, prevState), { showConfirmModal: !prevState.showConfirmModal, selectedField: field, loading: false })));
91
+ };
92
+ const onDragEnd = (result) => {
93
+ const source = get(result, "source");
94
+ const destination = get(result, "destination");
95
+ if (!destination)
96
+ return;
97
+ if (get(source, "droppableId") === "droppable1" &&
98
+ get(destination, "droppableId") === "droppable1")
99
+ return;
100
+ if (isEqual(source, "droppable2") && isEqual(destination, "droppable1"))
101
+ return;
102
+ if (get(source, "droppableId") === get(destination, "droppableId") &&
103
+ get(fields, "length", 0) > 0) {
104
+ const reorderedFields = showOutputFormat
105
+ ? [...imagePickerOutputFormat]
106
+ : [...fields];
107
+ const [moved] = reorderedFields.splice(get(source, "index"), 1);
108
+ reorderedFields.splice(get(destination, "index"), 0, moved);
109
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { fields: showOutputFormat ? fields : reorderedFields, imagePickerOutputFormat: showOutputFormat
110
+ ? reorderedFields
111
+ : imagePickerOutputFormat })));
112
+ }
113
+ else {
114
+ const draggedWidget = find(inputTypes, (type) => get(type, "_id") === get(result, "draggableId"));
115
+ if (draggedWidget) {
116
+ const maxIdField = reduce(fields, (prev, curr) => {
117
+ return toNumber(get(curr, "_id")) > toNumber(get(prev, "_id"))
118
+ ? curr
119
+ : prev;
120
+ }, first(fields) || { _id: "0" });
121
+ const newWidget = Object.assign(Object.assign({}, draggedWidget), { label: get(draggedWidget, "name", ""), _id: null, mapId: uniqueId() });
122
+ const reorderedFields = [...fields];
123
+ const imagePickerOutputFormatFields = [...imagePickerOutputFormat];
124
+ reorderedFields.splice(get(destination, "index"), 0, newWidget);
125
+ imagePickerOutputFormatFields.splice(get(destination, "index"), 0, Object.assign(Object.assign({}, newWidget), { required: false, separator: "" }));
126
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { fields: reorderedFields, currentFieldIndex: get(destination, "index", null), imagePickerOutputFormat: imagePickerOutputFormatFields })));
127
+ }
128
+ }
129
+ };
130
+ const onAddLabel = (id, value) => {
131
+ const updatedFields = map(fields, (field) => {
132
+ if (get(field, "_id") === id) {
133
+ return Object.assign(Object.assign({}, field), { label: value });
134
+ }
135
+ return field;
136
+ });
137
+ const updatedImagePickerOutputFormat = map(imagePickerOutputFormat, (field) => {
138
+ if (get(field, "_id") === id) {
139
+ return Object.assign(Object.assign({}, field), { label: value });
140
+ }
141
+ return field;
142
+ });
143
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { fields: updatedFields, imagePickerOutputFormat: updatedImagePickerOutputFormat })));
144
+ };
145
+ const onUpdateOutputFormat = (id, key, value) => {
146
+ // console.log(id, key, value, "onUpdateOutputFormat");
147
+ const updatedImagePickerOutputFormat = map(imagePickerOutputFormat, (field, index) => {
148
+ if (index === id) {
149
+ return Object.assign(Object.assign({}, field), { [key]: value });
150
+ }
151
+ return field;
152
+ });
153
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { imagePickerOutputFormat: updatedImagePickerOutputFormat })));
154
+ };
155
+ // console.log(imagePickerOutputFormat, "imagePickerOutputFormat", fields);
156
+ const onDeleteField = (ind) => {
157
+ const currentField = fields.find((field, index) => index === ind);
158
+ const updatedFields = filter(fields, (field, index) => index !== ind);
159
+ const deleteField = find(fields, (field, index) => index === ind);
160
+ const updatedImagePickerOutputFormat = filter(imagePickerOutputFormat, (field, index) => get(currentField, "mapId") !== get(field, "mapId"));
161
+ if (get(deleteField, "_id")) {
162
+ toggleConfirmModal(deleteField);
163
+ }
164
+ else {
165
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { fields: updatedFields, currentFieldIndex: null, imagePickerOutputFormat: updatedImagePickerOutputFormat })));
166
+ }
167
+ };
168
+ const onDeleteExistedField = () => __awaiter(this, void 0, void 0, function* () {
169
+ setFieldState((prevState) => (Object.assign(Object.assign({}, prevState), { loading: true })));
170
+ try {
171
+ const response = yield api.delete(DELETE_ASSET_FIELD_URL.replace(":assetId", id).replace(":id", get(selectedField, "_id")));
172
+ const updatedFields = filter(fields, (field, index) => get(field, "_id") !== get(selectedField, "_id"));
173
+ const updatedImagePickerOutputFormat = filter(imagePickerOutputFormat, (field, index) => get(field, "mapId") !== get(selectedField, "mapId"));
174
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { fields: updatedFields, currentFieldIndex: null, imagePickerOutputFormat: updatedImagePickerOutputFormat })));
175
+ toggleConfirmModal();
176
+ showNotification(get(response, "data.message", DELETE_SUCCESS), NotificationStatus.SUCCESS);
177
+ }
178
+ catch (error) {
179
+ setFieldState((prevState) => (Object.assign(Object.assign({}, prevState), { loading: false })));
180
+ showNotification(get(error, "message", SOMETHING_WENT_WRONG), NotificationStatus.ERROR);
181
+ }
182
+ });
183
+ const currentField = useMemo(() => {
184
+ return find(fields, (field, index) => index === currentFieldIndex);
185
+ }, [currentFieldIndex, fields]);
186
+ const currentInputType = useMemo(() => {
187
+ return find(inputTypes, (input) => get(currentField, "defaultName") === get(input, "defaultName"));
188
+ }, [inputTypes, currentField]);
189
+ const onUpdateField = (updatedValues, existedField, index) => {
190
+ const currentField = index || index == 0 ? (fields === null || fields === void 0 ? void 0 : fields[index]) || null : null;
191
+ const data = transformInputTypePayload(updatedValues, existedField, get(currentField, "mapId", ""));
192
+ const updatedFields = map(fields, (field, i) => {
193
+ if (i === index) {
194
+ return data;
195
+ }
196
+ return field;
197
+ });
198
+ // console.log("imagepicker", imagePickerOutputFormat);
199
+ const updatedImagePickerOutputFormat = map(imagePickerOutputFormat, (field, i) => {
200
+ if (currentField &&
201
+ get(field, "mapId") &&
202
+ get(currentField, "mapId") === get(field, "mapId")) {
203
+ return Object.assign(Object.assign({}, field), { name: get(data, "name"), label: get(data, "label"), placeholder: get(data, "placeholder"), defaultName: get(data, "defaultName") });
204
+ }
205
+ return field;
206
+ });
207
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { fields: updatedFields, imagePickerOutputFormat: updatedImagePickerOutputFormat })));
208
+ };
209
+ const getFormattedValue = (data) => {
210
+ const sortedData = _.sortBy(data, "order");
211
+ const value = sortedData === null || sortedData === void 0 ? void 0 : sortedData.reduce((acc, field) => {
212
+ if (field === null || field === void 0 ? void 0 : field.required) {
213
+ // if (field?.name !== "File Url") {
214
+ acc = acc + (field === null || field === void 0 ? void 0 : field.name);
215
+ if (field === null || field === void 0 ? void 0 : field.separator) {
216
+ acc = acc + (field === null || field === void 0 ? void 0 : field.separator);
217
+ }
218
+ // }
219
+ }
220
+ return acc;
221
+ }, "");
222
+ return value;
223
+ };
224
+ // console.log("imagepicker output format", imagePickerOutputFormat);
225
+ return (_jsxs(_Fragment, { children: [" ", _jsx(DragDropContext, { onDragEnd: currentFieldIndex === null || showOutputFormat
226
+ ? onDragEnd
227
+ : () => {
228
+ !showOutputFormat &&
229
+ showNotification(INPUT_SETTINGS_VALIDATION_ERROR, NotificationStatus.WARN);
230
+ }, children: _jsxs("div", { className: `md-lib-grid ${showOutputFormat ? "md-lib-grid-cols-1" : "md-lib-grid-cols-4"} ${showOutputFormat ? "md-lib-h-screen" : ""}`, children: [showOutputFormat && (_jsxs("div", { className: "md-lib-p-8", children: [_jsx("p", { className: "md-lib-text-sm md-lib-text-orange-500", children: "Note: Please ensure that all required fields has separators" }), _jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-gap-2", children: [_jsx("p", { className: "md-lib-text-sm md-lib-font-semibold", children: "Sample File Format: " }), _jsx("pre", { children: getFormattedValue(imagePickerOutputFormat) })] })] })), !showOutputFormat && (_jsx(Droppable, { droppableId: "droppable1", children: (provided) => (_jsxs("div", Object.assign({}, provided.droppableProps, { ref: provided.innerRef, children: [_jsxs("div", { className: "md-lib-p-3 md-lib-col-span-1 md-lib-border-r dark:md-lib-border-darkBorderColor dark:md-lib-bg-darkPrimary", children: [_jsx(Typography.Title, { level: 4, children: "Form Widgets" }), _jsx("p", { className: "md-lib-text-sm md-lib-description md-lib-mb-3", children: "Drag and drop form elements in additional section" }), map(inputTypes, (type, index) => {
231
+ const IconComponent = getWidgetIcon(get(type, "defaultName"));
232
+ return (_jsx(Draggable, { draggableId: get(type, "_id"), index: index, children: (provided) => (_jsxs("div", Object.assign({ className: "md-lib-flex md-lib-items-center md-lib-gap-2 md-lib-bg-white dark:md-lib-bg-darkPrimaryHoverColor md-lib-p-3 md-lib-mb-2 md-lib-rounded", ref: provided.innerRef }, provided.draggableProps, provided.dragHandleProps, { children: [IconComponent && (_jsx("div", { className: "md-lib-flex md-lib-items-center md-lib-flex-shrink-0", children: _jsx(IconComponent, { size: ICON_SIZE }) })), _jsx("span", { className: "md-lib-leading-normal md-lib-text-base", children: get(type, "name") })] }))) }, get(type, "_id")));
233
+ })] }), provided.placeholder] }))) })), _jsx("div", { className: `${!!currentField && !showOutputFormat ? "md-lib-col-span-2" : "md-lib-col-span-3"} dark:md-lib-bg-darkPrimary`, children: _jsx(Droppable, { droppableId: "droppable2", children: (provided) => (_jsxs("div", Object.assign({}, provided.droppableProps, { ref: provided.innerRef, className: "md-lib-bg-white dark:md-lib-bg-darkPrimaryHoverColor md-lib-rounded-[20px] md-lib-my-4 md-lib-mx-8", children: [_jsx("p", { className: "md-lib-text-xl md-lib-border-b md-lib-p-3 md-lib-asset-template-title md-lib-truncate", children: name }), _jsx("div", { className: "md-lib-p-4", children: get(fields, "length") === 0 ? (_jsxs("div", { className: "md-lib-flex md-lib-flex-col md-lib-items-center md-lib-justify-center", children: [_jsx("img", { src: EMPTY_ASSET_TEMPLATE_WIDGETS_URL, alt: "Empty Asset Template Widgets", width: 250, height: 250 }), _jsx("p", { className: "md-lib-text-sm md-lib-description md-lib-mt-2", children: "Drag fields to create form" })] })) : (map(showOutputFormat ? imagePickerOutputFormat : fields, (field, index) => (_jsx(Draggable, { draggableId: `${(field === null || field === void 0 ? void 0 : field._id)
234
+ ? `selected-${get(field, "_id")}`
235
+ : `selected-${index}`}`, index: index, children: (provided) => (_jsx("div", Object.assign({ ref: provided.innerRef }, provided.draggableProps, { children: _jsx(DraggedField, { provided: provided, field: field, outputFormatField: imagePickerOutputFormat === null || imagePickerOutputFormat === void 0 ? void 0 : imagePickerOutputFormat[index], onAddLabel: onAddLabel, onDeleteField: onDeleteField, onUpdateOutputFormat: onUpdateOutputFormat, setCurrentFieldIndex: (val) => __awaiter(this, void 0, void 0, function* () {
236
+ if (currentFieldIndex === null) {
237
+ setCurrentFieldIndex(val);
238
+ return;
239
+ }
240
+ const field = currentField;
241
+ const currentInputType = find(inputTypes, (input) => get(field, "defaultName") ===
242
+ get(input, "defaultName"));
243
+ const validationErrors = getInputTypeValidationErrors(field, currentInputType);
244
+ if (validationErrors.length > 0 &&
245
+ !showOutputFormat) {
246
+ showNotification(INPUT_SETTINGS_VALIDATION_ERROR_AT_SWITCH_INPUT, NotificationStatus.WARN);
247
+ return;
248
+ }
249
+ setCurrentFieldIndex(val);
250
+ }), currentFieldIndex: currentFieldIndex, index: index, showOutputFormat: showOutputFormat }) }))) }, `${(field === null || field === void 0 ? void 0 : field._id)
251
+ ? `selected-${get(field, "_id")}`
252
+ : `selected-${index}`}`)))) }), provided.placeholder] }))) }) }), !!currentField && !showOutputFormat && (_jsx("div", { className: "md-lib-col-span-1 md-lib-bg-white dark:md-lib-bg-darkPrimaryHoverColor", children: _jsx(AddFieldProperties, { field: currentField, index: currentFieldIndex, setCurrentFieldIndex: (val) => setCurrentFieldIndex(val), onUpdateField: (updatedValues, field, index) => onUpdateField(updatedValues, field, index), currentInputType: currentInputType, allFields: fields, onCancel: (index) => {
253
+ if (index !== null) {
254
+ const fieldToCancel = fields[index];
255
+ if (!get(fieldToCancel, "_id")) {
256
+ const updatedFields = filter(fields, (field, i) => i !== index);
257
+ const updatedImagePickerOutputFormat = filter(imagePickerOutputFormat, (field) => get(field, "mapId") !== get(fieldToCancel, "mapId"));
258
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { fields: updatedFields, currentFieldIndex: null, imagePickerOutputFormat: updatedImagePickerOutputFormat })));
259
+ }
260
+ else {
261
+ setCurrentFieldIndex(null);
262
+ }
263
+ }
264
+ else {
265
+ setCurrentFieldIndex(null);
266
+ }
267
+ } }) }))] }) }), showConfirmModal && (_jsx(DeleteConfirmationModal, { showDeleteModal: showConfirmModal, toggleDeleteModal: toggleConfirmModal, okText: DELETE_OK_TEXT, onOk: onDeleteExistedField, loading: loading, description: DELETE_CONFIRMATION_MESSAGE.replace(":action", "Delete").replace(":entity", `${get(selectedField, "name", "this field")}`), subHeading: DELETE_MESSAGE_DESCRIPTION }))] }));
268
+ }
@@ -0,0 +1,2 @@
1
+ declare function AssetTemplatesContainer(): JSX.Element;
2
+ export default AssetTemplatesContainer;
@@ -0,0 +1,71 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
11
+ import { useEffect, useMemo, useState } from "react";
12
+ import { get, includes } from "lodash";
13
+ import { DEFAULT_PAGE } from "../hocs/appConstants";
14
+ import AssetTemplatesTable from "./AssetTemplatesTable";
15
+ import { NotificationStatus, SortOrders, } from "../utilities/constants/interface";
16
+ import { showNotification } from "../common/notifications";
17
+ import { SOMETHING_WENT_WRONG } from "../utilities/constants/messages";
18
+ import { FETCH_ASSETS_URL } from "../utilities/constants/apiUrls";
19
+ import { useDamConfig } from "../hocs/DamConfigContext";
20
+ import PageTitle from "../ui/pageTitle";
21
+ import CreateAssetTemplate from "./CreateAssetTemplate";
22
+ import { NOT_FOUND_IMAGE_URL } from "../utilities/constants/imageUrls";
23
+ import { createApiClient } from "../hocs/configureAxios";
24
+ import { addQueryParams } from "../hocs/helpers";
25
+ import Loader from "../common/loader/loader";
26
+ function AssetTemplatesContainer() {
27
+ const damConfig = useDamConfig();
28
+ const api = useMemo(() => createApiClient(damConfig), [damConfig]);
29
+ const [state, setState] = useState({
30
+ loading: false,
31
+ totalCount: 0,
32
+ totalPages: 0,
33
+ assetTemplates: [],
34
+ filters: {
35
+ sortBy: "createdAt",
36
+ sortOrder: SortOrders.DESCEND,
37
+ page: DEFAULT_PAGE,
38
+ name: "",
39
+ },
40
+ });
41
+ const { loading, totalCount, totalPages, assetTemplates, filters } = state;
42
+ const { brand } = damConfig;
43
+ useEffect(() => {
44
+ if (brand) {
45
+ onFetchAssetTemplates({});
46
+ }
47
+ }, [brand]);
48
+ const onFetchAssetTemplates = (...args_1) => __awaiter(this, [...args_1], void 0, function* (params = {}) {
49
+ setState((prev) => (Object.assign(Object.assign({}, prev), { loading: true })));
50
+ Object.keys(params).forEach((key) => {
51
+ if (includes(["name"], key) && params[key] && params[key].length > 2) {
52
+ return;
53
+ }
54
+ if (params[key] === undefined ||
55
+ params[key] === "" ||
56
+ params[key] === null) {
57
+ delete params[key];
58
+ }
59
+ });
60
+ try {
61
+ const response = yield api.get(`${FETCH_ASSETS_URL.replace(":brandId", get(brand, "_id"))}?${addQueryParams(params)}`);
62
+ setState((prev) => (Object.assign(Object.assign({}, prev), { assetTemplates: get(response, "data.data", []), totalCount: get(response, "data.total"), totalPages: get(response, "data.totalPages"), filters: params, loading: false })));
63
+ }
64
+ catch (error) {
65
+ showNotification(get(error, "message", SOMETHING_WENT_WRONG), NotificationStatus.ERROR);
66
+ setState((prev) => (Object.assign(Object.assign({}, prev), { loading: false })));
67
+ }
68
+ });
69
+ return (_jsx("div", { className: "md-lib-p-4", children: loading ? (_jsx(Loader, {})) : (_jsxs(_Fragment, { children: [_jsxs("div", { className: "md-lib-flex md-lib-items-center", children: [_jsx(PageTitle, { label: "Assets Templates" }), get(assetTemplates, "length") > 0 && (_jsx("div", { className: "md-lib-ml-auto md-lib-hidden md:md-lib-block", children: _jsx(CreateAssetTemplate, { label: "Create" }) }))] }), (get(assetTemplates, "length") > 0 || Object.keys(filters).length > 0) ? (_jsx("div", { className: "md-lib-mt-4", children: _jsx(AssetTemplatesTable, { assetTemplates: assetTemplates, totalCount: totalCount, totalPages: totalPages, onFetchAssetTemplates: onFetchAssetTemplates, filters: filters, loading: loading }) })) : (_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: "No ticket template has been created yet" }), _jsx("div", { className: "md-lib-mt-4 md-lib-hidden md:md-lib-block", children: _jsx(CreateAssetTemplate, { label: "Add Template" }) })] }))] })) }));
70
+ }
71
+ export default AssetTemplatesContainer;
@@ -0,0 +1,5 @@
1
+ import { InputTypeEntity, InputTypeSupportedTypeEntity } from "../../utilities/constants/interface";
2
+ export default function DateField({ field, supportedTypes, }: {
3
+ field: InputTypeEntity;
4
+ supportedTypes: InputTypeSupportedTypeEntity[];
5
+ }): JSX.Element;
@@ -0,0 +1,23 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { InputSupportedTypes, } from "../../utilities/constants/interface";
3
+ import { Col, Form, Row, Switch } from "antd";
4
+ import { get, isEqual, find, map } from "lodash";
5
+ import { useEffect, useState } from "react";
6
+ export default function DateField({ field, supportedTypes, }) {
7
+ const [allowTimeEnabled, setAllowTimeEnabled] = useState(false);
8
+ useEffect(() => {
9
+ const timeSupport = find(supportedTypes, (s) => get(s, "defaultName") === InputSupportedTypes.ALLOW_TIME);
10
+ setAllowTimeEnabled(!!timeSupport);
11
+ }, [supportedTypes]);
12
+ return (_jsx(_Fragment, { children: map(supportedTypes, (type) => {
13
+ const defaultName = get(type, "defaultName");
14
+ const name = get(type, "name");
15
+ const valueType = get(type, "valueType");
16
+ const id = get(type, "_id");
17
+ if (isEqual(defaultName, InputSupportedTypes.ALLOW_TIME) &&
18
+ isEqual(valueType, "boolean")) {
19
+ return (_jsxs(Row, { className: "md-lib-flex md-lib-items-center", children: [_jsx(Col, { span: 12, children: name }), _jsx(Col, { span: 12, push: 8, children: _jsx(Form.Item, { name: ["inputTypeSettings", defaultName, "allow"], className: "md-lib-mb-0", valuePropName: "checked", children: _jsx(Switch, { onChange: (val) => setAllowTimeEnabled(val) }) }) })] }, id));
20
+ }
21
+ return null;
22
+ }) }));
23
+ }
@@ -0,0 +1,5 @@
1
+ import { InputTypeEntity, InputTypeSupportedTypeEntity } from "../../utilities/constants/interface";
2
+ export default function NumberField({ field, supportedTypes, }: {
3
+ field: InputTypeEntity;
4
+ supportedTypes: InputTypeSupportedTypeEntity[];
5
+ }): JSX.Element;
@@ -0,0 +1,91 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
11
+ import { InputSupportedTypes, } from "../../utilities/constants/interface";
12
+ import { Col, Form, InputNumber, Row, Switch } from "antd";
13
+ import useFormInstance from "antd/es/form/hooks/useFormInstance";
14
+ import { get, isEqual, map } from "lodash";
15
+ import { useEffect, useState } from "react";
16
+ export default function NumberField({ field, supportedTypes, }) {
17
+ const form = useFormInstance();
18
+ const initialRangeEnabled = !!get(field, [
19
+ "inputTypeSettings",
20
+ InputSupportedTypes.VALUE_RANGE,
21
+ "allow",
22
+ ]);
23
+ const [rangeEnabled, setRangeEnabled] = useState(initialRangeEnabled);
24
+ useEffect(() => {
25
+ form.setFieldValue(["inputTypeSettings", InputSupportedTypes.VALUE_RANGE, "allow"], initialRangeEnabled);
26
+ }, [initialRangeEnabled, form]);
27
+ return (_jsx(_Fragment, { children: map(supportedTypes, (type) => {
28
+ const defaultName = get(type, "defaultName");
29
+ const name = get(type, "name");
30
+ const valueType = get(type, "valueType");
31
+ const id = get(type, "_id");
32
+ if (isEqual(defaultName, InputSupportedTypes.VALUE_RANGE)) {
33
+ return (_jsxs("div", { children: [_jsxs(Row, { className: "md-lib-flex md-lib-items-center", children: [_jsx(Col, { span: 12, children: name }), _jsx(Col, { span: 12, push: 8, children: _jsx(Form.Item, { name: ["inputTypeSettings", defaultName, "allow"], className: "md-lib-mb-0", valuePropName: "checked", children: _jsx(Switch, { checked: rangeEnabled, onChange: (val) => setRangeEnabled(val) }) }) })] }), rangeEnabled && (_jsxs(_Fragment, { children: [_jsx(Form.Item, { name: ["inputTypeSettings", defaultName, "minValue"], label: "Minimum Value", rules: [
34
+ {
35
+ validator: (_, value) => __awaiter(this, void 0, void 0, function* () {
36
+ if (!rangeEnabled)
37
+ return Promise.resolve(); // skip validation if toggle is off
38
+ const max = form.getFieldValue([
39
+ "inputTypeSettings",
40
+ defaultName,
41
+ "maxValue",
42
+ ]);
43
+ // Require at least one
44
+ if ((value === undefined || value === null) &&
45
+ (max === undefined || max === null)) {
46
+ return Promise.reject(new Error("Please enter either Minimum or Maximum value"));
47
+ }
48
+ // If both provided → min <= max
49
+ if (value !== undefined &&
50
+ value !== null &&
51
+ max !== undefined &&
52
+ max !== null) {
53
+ if (value > max) {
54
+ return Promise.reject(new Error("Minimum must be less than or equal to Maximum"));
55
+ }
56
+ }
57
+ return Promise.resolve();
58
+ }),
59
+ },
60
+ ], children: _jsx(InputNumber, { placeholder: "Min", style: { width: "100%" } }) }), _jsx(Form.Item, { name: ["inputTypeSettings", defaultName, "maxValue"], label: "Maximum Value", rules: [
61
+ {
62
+ validator: (_, value) => __awaiter(this, void 0, void 0, function* () {
63
+ if (!rangeEnabled)
64
+ return Promise.resolve(); // skip validation if toggle is off
65
+ const min = form.getFieldValue([
66
+ "inputTypeSettings",
67
+ defaultName,
68
+ "minValue",
69
+ ]);
70
+ // Require at least one
71
+ if ((value === undefined || value === null) &&
72
+ (min === undefined || min === null)) {
73
+ return Promise.reject(new Error("Please enter either Minimum or Maximum value"));
74
+ }
75
+ // If both provided → max >= min
76
+ if (value !== undefined &&
77
+ value !== null &&
78
+ min !== undefined &&
79
+ min !== null) {
80
+ if (value < min) {
81
+ return Promise.reject(new Error("Maximum must be greater than or equal to Minimum"));
82
+ }
83
+ }
84
+ return Promise.resolve();
85
+ }),
86
+ },
87
+ ], children: _jsx(InputNumber, { placeholder: "Max", style: { width: "100%" } }) })] }))] }, id));
88
+ }
89
+ return null;
90
+ }) }));
91
+ }
@@ -0,0 +1,6 @@
1
+ import { InputTypeEntity, InputTypeSupportedTypeEntity } from "../../utilities/constants/interface";
2
+ export default function OptionsField({ field, supportedTypes, currentInputType, }: {
3
+ field: InputTypeEntity;
4
+ supportedTypes: InputTypeSupportedTypeEntity[];
5
+ currentInputType: InputTypeEntity;
6
+ }): JSX.Element;
@@ -0,0 +1,55 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
13
+ import { InputTypes, } from "../../utilities/constants/interface";
14
+ import { Button, Col, Form, Input, Row, Switch } from "antd";
15
+ import { useEffect, useState } from "react";
16
+ import { TiDeleteOutline } from "react-icons/ti";
17
+ import { FaPlus } from "react-icons/fa6";
18
+ // import variables from "../../../styles/variables.module.scss";
19
+ import { get, isEqual, map, find, includes } from "lodash";
20
+ import { ICON_SIZE } from "../../hocs/appConstants";
21
+ import { useTheme } from "../../hocs/ThemeContext";
22
+ const TiDeleteOutlineIcon = TiDeleteOutline;
23
+ const FaPlusIcon = FaPlus;
24
+ export default function OptionsField({ field, supportedTypes, currentInputType, }) {
25
+ const [allowMultiSelect, setAllowMultiSelect] = useState(false);
26
+ const theme = useTheme();
27
+ useEffect(() => {
28
+ const multi = find(supportedTypes, (s) => isEqual(get(s, "defaultName"), "ALLOW_MULTIPLE"));
29
+ setAllowMultiSelect(!!multi);
30
+ }, [supportedTypes]);
31
+ return (_jsxs(_Fragment, { children: [map(supportedTypes, (type) => {
32
+ const defaultName = get(type, "defaultName");
33
+ const name = get(type, "name");
34
+ const valueType = get(type, "valueType");
35
+ const id = get(type, "_id");
36
+ if (isEqual(valueType, "boolean")) {
37
+ return (_jsxs(Row, { className: "md-lib-flex md-lib-items-center", children: [_jsx(Col, { span: 16, children: name }), _jsx(Col, { span: 8, push: 4, children: _jsx(Form.Item, { name: ["inputTypeSettings", defaultName], className: "md-lib-mb-0", valuePropName: "checked", children: _jsx(Switch, {}) }) })] }, id));
38
+ }
39
+ return null;
40
+ }), includes([InputTypes.SELECT, InputTypes.CHECKBOX, InputTypes.RADIO], get(currentInputType, "defaultName")) && (_jsxs(_Fragment, { children: [_jsx("h3", { className: "md-lib-text-md md-lib-font-semibold md-lib-mt-4 md-lib-mb-2", children: "List of Options" }), _jsx(Form.Item, { label: "", name: "options", rules: [
41
+ {
42
+ required: true,
43
+ type: "array",
44
+ min: 1,
45
+ message: "At least one option is required",
46
+ },
47
+ ], children: _jsx(Form.List, { name: "options", children: (fields, { add, remove }) => (_jsxs(_Fragment, { children: [fields.map((_a) => {
48
+ var { key, name } = _a, restField = __rest(_a, ["key", "name"]);
49
+ return (_jsxs(Row, { gutter: 8, className: "md-lib-items-center", children: [_jsx(Col, { span: 10, children: _jsx(Form.Item, Object.assign({}, restField, { name: [name, "label"], label: "Label", rules: [
50
+ { required: true, message: "Label is required" },
51
+ ], children: _jsx(Input, { placeholder: "Enter Label", className: "md-lib-h-12" }) })) }), _jsx(Col, { span: 10, children: _jsx(Form.Item, Object.assign({}, restField, { name: [name, "value"], label: "Value", rules: [
52
+ { required: true, message: "Value is required" },
53
+ ], children: _jsx(Input, { placeholder: "Enter Value", className: "md-lib-h-12" }) })) }), _jsx(Col, { span: 4, className: "md-lib-flex md-lib-items-end", children: _jsx(TiDeleteOutlineIcon, { size: ICON_SIZE, className: "md-lib-cursor-pointer", color: theme === null || theme === void 0 ? void 0 : theme.primaryColor, onClick: () => remove(name) }) })] }, key));
54
+ }), _jsx(Form.Item, { children: _jsx(Button, { icon: _jsx(FaPlusIcon, {}), onClick: () => add(), children: "Add Option" }) })] })) }) })] }))] }));
55
+ }
@@ -0,0 +1,5 @@
1
+ import { InputTypeEntity, InputTypeSupportedTypeEntity } from "../../utilities/constants/interface";
2
+ export default function TextField({ field, supportedTypes, }: {
3
+ field: InputTypeEntity;
4
+ supportedTypes: InputTypeSupportedTypeEntity[];
5
+ }): JSX.Element;