@argusoft/medplat-app-shell 1.0.6 → 1.0.7

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 (263) hide show
  1. package/package.json +139 -141
  2. package/src/GlobalErrorBoundary.jsx +31 -0
  3. package/src/SilentErrorFallback.jsx +68 -0
  4. package/src/TrackingProviderWrapper.jsx +40 -0
  5. package/src/_tests_/__mocks__/MockTranslationProvider.jsx +21 -0
  6. package/src/_tests_/__mocks__/ckeditor.js +45 -0
  7. package/src/_tests_/__mocks__/fileMock.js +1 -0
  8. package/src/_tests_/__mocks__/useranalytics.js +5 -0
  9. package/src/_tests_/views/components/Dashboard/DashboardUI.test.jsx +137 -0
  10. package/src/_tests_/views/components/Dashboard/DashboardUIMock.js +877 -0
  11. package/src/_tests_/views/components/ForgotPassword/ForgotPassword.test.jsx +314 -0
  12. package/src/_tests_/views/components/LocationDirective/LocationDirective.test.jsx.disable +229 -0
  13. package/src/_tests_/views/components/LocationDirective/mockLocationDirective.js +810 -0
  14. package/src/_tests_/views/components/LocationType/MockLocationType.js +42259 -0
  15. package/src/_tests_/views/components/LocationType/addlocationtype.test.jsx.disable +276 -0
  16. package/src/_tests_/views/components/LocationType/editlocationtype.test.jsx.disable +262 -0
  17. package/src/_tests_/views/components/LocationType/locationtype.test.jsx.disable +148 -0
  18. package/src/_tests_/views/components/Profile/UpdateProfileModalData.js +4396 -0
  19. package/src/_tests_/views/components/Profile/updateprofilemodal.test.jsx +282 -0
  20. package/src/_tests_/views/components/SideBar/MockSideBar.js +1379 -0
  21. package/src/_tests_/views/components/SideBar/SideBar.test.jsx +98 -0
  22. package/src/_tests_/views/components/SystemConfig/ManageSystemConfig/AddManageSystemConfig.test.jsx.disable +164 -0
  23. package/src/_tests_/views/components/SystemConfig/ManageSystemConfig/UpdateManageSystemConfig.test.jsx.disable +157 -0
  24. package/src/_tests_/views/components/SystemConfig/MockSystemConfig.js +1280 -0
  25. package/src/_tests_/views/components/SystemConfig/SystemConfig.test.jsx.disable +165 -0
  26. package/src/_tests_/views/components/login/Login.test.jsx +276 -0
  27. package/src/_tests_/views/components/login/MockAuthorise.js +2414 -0
  28. package/src/_tests_/views/components/login/ServiceResponse.js +595 -0
  29. package/src/_tests_/views/components/user/MockManageUser.js +7965 -0
  30. package/src/_tests_/views/components/user/manageuser.test.jsx.disable +989 -0
  31. package/src/_tests_/views/components/user/mockUsersData.js +582 -0
  32. package/src/assets/img/OASISLogin.png +0 -0
  33. package/src/assets/img/bahaarNew.png +0 -0
  34. package/src/assets/img/dnhdd4K.png +0 -0
  35. package/src/assets/img/govtofup.png +0 -0
  36. package/src/assets/img/sewarural4K.png +0 -0
  37. package/src/assets/img/techo4K.png +0 -0
  38. package/src/assets/img/up4K.png +0 -0
  39. package/src/common/HolidayList.jsx +573 -0
  40. package/src/common/MalaciaousInputUtil.js +23 -0
  41. package/src/common/SafeHtml.jsx +17 -0
  42. package/src/common/VersionManager.jsx +109 -0
  43. package/src/common/constants/PerformanceDashboard.js +514 -0
  44. package/src/common/constants/app.constant.js +781 -0
  45. package/src/common/constants/cccVerificationConstants.js +18 -0
  46. package/src/common/constants/fhsrConstant.js +33 -0
  47. package/src/common/constants/gvk-verification.constant.js +76 -0
  48. package/src/common/constants/search.constant.js +23 -0
  49. package/src/common/constants/teleconsulatationConstant.jsx +1339 -0
  50. package/src/common/directives/SearchTemplate.jsx +784 -0
  51. package/src/common/directives/SearchTemplate.scss +14 -0
  52. package/src/common/dynamicView/DynamicView.jsx +353 -0
  53. package/src/common/dynamicView/InputFieldComponent.jsx +1501 -0
  54. package/src/common/dynamicView/InputViewComponent.jsx +298 -0
  55. package/src/common/dynamicView/InputViewComponent.scss +15 -0
  56. package/src/common/env.js +5 -0
  57. package/src/common/filters/locationNameFilter.js +26 -0
  58. package/src/common/fontAwesomeIcons/FontAwesomeIcons.jsx +27 -0
  59. package/src/common/fontAwesomeIcons/FontAwesomeIconsNames.js +1968 -0
  60. package/src/common/fontPreferences/fontSizeProvider.jsx +34 -0
  61. package/src/common/fontPreferences/fontSizeSelector.jsx +116 -0
  62. package/src/common/getAssignedFeature/getAssignedFeature.js +32 -0
  63. package/src/common/interceptors/AxiosInterceptor.js +216 -0
  64. package/src/common/languageTranslator/TranslationContext.js +5 -0
  65. package/src/common/languageTranslator/TranslationProvider.jsx +24 -0
  66. package/src/common/languageTranslator/i18n.js +49 -0
  67. package/src/common/services/AuthenticateService.js +116 -0
  68. package/src/common/services/DownloadFile.js +35 -0
  69. package/src/common/services/ForgotPassword.js +18 -0
  70. package/src/common/services/FormConfiguratorService.js +195 -0
  71. package/src/common/services/GlobalApis.js +84 -0
  72. package/src/common/services/InterceptorNavigationService.js +17 -0
  73. package/src/common/services/LocationService.js +65 -0
  74. package/src/common/services/LocationType.js +11 -0
  75. package/src/common/services/QueryBuilder.js +36 -0
  76. package/src/common/services/Roles.js +28 -0
  77. package/src/common/services/SyncWithServer.js +15 -0
  78. package/src/common/services/SystemConfig.js +15 -0
  79. package/src/common/services/TranslationService.js +70 -0
  80. package/src/common/services/TwoFactorService.js +7 -0
  81. package/src/common/services/Users.js +91 -0
  82. package/src/common/services/Webtasks.js +27 -0
  83. package/src/common/services/util/Convert-pad-data-to-API-format.jsx +167 -0
  84. package/src/common/services/util/Convert-to-UI-format.jsx +82 -0
  85. package/src/common/services/util/EmptyPrescriptionPadData.jsx +11 -0
  86. package/src/common/services/util/GeneralUtil.js +456 -0
  87. package/src/common/services/util/Prescription-pad-util.js +339 -0
  88. package/src/common/services/util/PrescriptionPadData.js +67 -0
  89. package/src/common/services/util/PrescriptionpadCommonUtil.js +96 -0
  90. package/src/common/services/util/ReportFieldUtil.jsx +398 -0
  91. package/src/common/services/util/WebSocketContext.jsx +261 -0
  92. package/src/common/syncWithServer/SyncWithServerDialog.jsx +170 -0
  93. package/src/common/syncWithServer/SyncWithServerDialogSkeleton.jsx +67 -0
  94. package/src/common/tests/CustomWrapper.jsx +49 -0
  95. package/src/common/tests/TranslationWrapper.jsx +38 -0
  96. package/src/common/themeProvider/ColorInputs.jsx +97 -0
  97. package/src/common/themeProvider/EditableColorInput.jsx +128 -0
  98. package/src/common/themeProvider/ThemeEditor.jsx +319 -0
  99. package/src/common/themeProvider/ThemeProvider.jsx +210 -0
  100. package/src/common/themeProvider/themeConfig.js +558 -0
  101. package/src/common/toaster/toaster.jsx +30 -0
  102. package/src/firebaseConfig.js +24 -0
  103. package/src/global.scss +221 -0
  104. package/src/hooks/.gitkeep +0 -0
  105. package/src/hooks/useAESEncryption.js +56 -0
  106. package/src/hooks/useCaching.js +43 -0
  107. package/src/hooks/useDebounce.js +34 -0
  108. package/src/hooks/useDebounceFn.js +50 -0
  109. package/src/hooks/useDownloadPdf.js +358 -0
  110. package/src/hooks/useDownloadXlsx.js +55 -0
  111. package/src/hooks/useListValueFieldValues.js +30 -0
  112. package/src/hooks/useLocationHierarchies.js +63 -0
  113. package/src/hooks/useLocationHierarchyTranslate.js +16 -0
  114. package/src/hooks/useOnline.js +27 -0
  115. package/src/hooks/usePagination.js +63 -0
  116. package/src/hooks/useRefreshToken.js +87 -0
  117. package/src/hooks/useScript.js +25 -0
  118. package/src/hooks/useStopwatch.js +75 -0
  119. package/src/hooks/useTrackEvent.js +22 -0
  120. package/src/hooks/useWebAudioRecorder.js +115 -0
  121. package/src/layout/LoaderComponet.jsx +22 -0
  122. package/src/layout/LoaderContext.jsx +29 -0
  123. package/src/layout/mainLayout/AdaptiveZoom.jsx +27 -0
  124. package/src/layout/mainLayout/Chatbot.jsx +243 -0
  125. package/src/layout/mainLayout/Layout.jsx +445 -0
  126. package/src/layout/mainLayout/Profile/UpdateProfileModal.jsx +684 -0
  127. package/src/layout/mainLayout/header/LogoutModal.jsx +131 -0
  128. package/src/layout/mainLayout/header/Navbar.jsx +1677 -0
  129. package/src/layout/mainLayout/header/Navbar.scss +4 -0
  130. package/src/layout/mainLayout/header/index.js +0 -0
  131. package/src/layout/mainLayout/sidebar/SideBar.jsx +1402 -0
  132. package/src/layout/mainLayout/sidebar/Sidebar.css +159 -0
  133. package/src/layout/mainLayout/sidebar/index.js +0 -0
  134. package/src/logo.svg +1 -0
  135. package/src/reportWebVitals.js +13 -0
  136. package/src/setupFirebaseMessaging.js +28 -0
  137. package/src/setupTests.js +8 -0
  138. package/src/store/actions/AuthenticationActions.js +0 -0
  139. package/src/store/actions/ReportsActions.js +0 -0
  140. package/src/store/actions/TranslationAction.js +0 -0
  141. package/src/store/index.js +8 -0
  142. package/src/store/reducer.js +46 -0
  143. package/src/store/reducers/AuthenticationReducer.js +50 -0
  144. package/src/store/reducers/CalendarEventReducer.js +41 -0
  145. package/src/store/reducers/ConditionClipboardReducer.js +45 -0
  146. package/src/store/reducers/FeatureReducer.js +27 -0
  147. package/src/store/reducers/FormConfiguratorReducer.js +38 -0
  148. package/src/store/reducers/LoadingReducer.js +20 -0
  149. package/src/store/reducers/MembersAuthenticationReducer.js +28 -0
  150. package/src/store/reducers/PrescriptionPadReducer.js +329 -0
  151. package/src/store/reducers/QuestionaireReducer.js +29 -0
  152. package/src/store/reducers/ReportsReducer.js +24 -0
  153. package/src/store/reducers/SkeletonReducer.js +20 -0
  154. package/src/store/reducers/ThemeReducer.js +106 -0
  155. package/src/store/reducers/TranslationReducer.js +126 -0
  156. package/src/store/reducers/dashboardEditorSlice.js +77 -0
  157. package/src/store/reducers/districtHealthDashboardSlice.js +58 -0
  158. package/src/store/reducers/immunizationSlice.js +234 -0
  159. package/src/store/slices/dashboardPagesSlice.js +51 -0
  160. package/src/utils/.gitkeep +0 -0
  161. package/src/utils/FormConstants.js +2629 -0
  162. package/src/utils/GujaratTopoChart.jsx +483 -0
  163. package/src/utils/UUIDgenerator.js +8 -0
  164. package/src/utils/appointment-utils/appointment-utils.js +123 -0
  165. package/src/utils/feature.js +42 -0
  166. package/src/utils/getThemeColor.js +12 -0
  167. package/src/utils/localStorageHelper.js +11 -0
  168. package/src/utils/notifications/enable-push-notifications.js +27 -0
  169. package/src/utils/resolveAppliedStyle.js +11 -0
  170. package/src/utils/themeConfigs.js +1483 -0
  171. package/src/views/custom-components/.gitkeep +0 -0
  172. package/src/views/custom-components/AgIconButton/RIf.jsx +14 -0
  173. package/src/views/custom-components/AgIconButton/button.jsx +108 -0
  174. package/src/views/custom-components/AgIconButton/waterDrop.jsx +95 -0
  175. package/src/views/custom-components/AgIconButton/waterDrop.scss +37 -0
  176. package/src/views/custom-components/AlertPlaceholder.jsx +32 -0
  177. package/src/views/custom-components/AllFaIconsSelector.jsx +56 -0
  178. package/src/views/custom-components/CkEditor/CkEditor.js +102 -0
  179. package/src/views/custom-components/CustomAccordion.jsx +72 -0
  180. package/src/views/custom-components/CustomActionIcons.jsx +118 -0
  181. package/src/views/custom-components/CustomAutoComplete.jsx +188 -0
  182. package/src/views/custom-components/CustomCheckBox.jsx +60 -0
  183. package/src/views/custom-components/CustomConfirmationModal.jsx +118 -0
  184. package/src/views/custom-components/CustomCountrySelect.jsx +129 -0
  185. package/src/views/custom-components/CustomDatePicker.jsx +122 -0
  186. package/src/views/custom-components/CustomDropdown.jsx +191 -0
  187. package/src/views/custom-components/CustomFileUpload.jsx +387 -0
  188. package/src/views/custom-components/CustomFullCalendar.jsx +514 -0
  189. package/src/views/custom-components/CustomInfiniteScroll.jsx +126 -0
  190. package/src/views/custom-components/CustomRadioComponent.jsx +65 -0
  191. package/src/views/custom-components/CustomStatsComponent.jsx +114 -0
  192. package/src/views/custom-components/CustomSvgUpload.jsx +170 -0
  193. package/src/views/custom-components/CustomSwitch.jsx +37 -0
  194. package/src/views/custom-components/CustomTabPanel.jsx +19 -0
  195. package/src/views/custom-components/CustomTextArea.jsx +62 -0
  196. package/src/views/custom-components/CustomTextArea.scss +27 -0
  197. package/src/views/custom-components/CustomTextField.jsx +116 -0
  198. package/src/views/custom-components/CustomToggleSwitch.jsx +138 -0
  199. package/src/views/custom-components/CustomTooltip.jsx +51 -0
  200. package/src/views/custom-components/CustomZoomImage.jsx +134 -0
  201. package/src/views/custom-components/CustomizedTable/CustomizedTableV2.jsx +1407 -0
  202. package/src/views/custom-components/CustomizedTable/VirtualizeTableBody.jsx +295 -0
  203. package/src/views/custom-components/CustomizedTable/helper.jsx +159 -0
  204. package/src/views/custom-components/CustomizedTable.jsx +532 -0
  205. package/src/views/custom-components/EditInputField.jsx +174 -0
  206. package/src/views/custom-components/FieldDescription.jsx +22 -0
  207. package/src/views/custom-components/FileDisplayComponent.jsx +138 -0
  208. package/src/views/custom-components/FormItem.jsx +53 -0
  209. package/src/views/custom-components/GenericChart.jsx +80 -0
  210. package/src/views/custom-components/InfoBadge.jsx +60 -0
  211. package/src/views/custom-components/PostgresEditor.jsx +801 -0
  212. package/src/views/custom-components/ResizableEditAutocompleteField.jsx +249 -0
  213. package/src/views/custom-components/ResizableEditInputField.jsx +215 -0
  214. package/src/views/custom-components/ResizeableEditSelectField.jsx +197 -0
  215. package/src/views/custom-components/SideOverlay.jsx +113 -0
  216. package/src/views/custom-components/SideOverlay.scss +42 -0
  217. package/src/views/custom-components/calendar.scss +571 -0
  218. package/src/views/feature-components/.gitkeep +0 -0
  219. package/src/views/feature-components/Dashboard/DashboardUI.jsx +1043 -0
  220. package/src/views/feature-components/Dashboard/DhnddModal/AshaDataQualityVerificationModal.jsx +278 -0
  221. package/src/views/feature-components/Dashboard/PinFeatureModal.jsx +143 -0
  222. package/src/views/feature-components/Dashboard/QuickLinks.jsx +163 -0
  223. package/src/views/feature-components/Dashboard/Taskbar.jsx +56 -0
  224. package/src/views/feature-components/Dashboard/WebtasksFilterForm.jsx +109 -0
  225. package/src/views/feature-components/Dashboard/WidgetCard.jsx +161 -0
  226. package/src/views/feature-components/Dashboard/actionModal.jsx +263 -0
  227. package/src/views/feature-components/Dashboard/ekavachModal/HealthWorkerIncorrectDetailsModal.jsx +332 -0
  228. package/src/views/feature-components/Dashboard/ekavachModal/MoMaternalDeathVerifcationModal.jsx +275 -0
  229. package/src/views/feature-components/Dashboard/ekavachModal/MoVerficationForChildScreeningMoadal.jsx +566 -0
  230. package/src/views/feature-components/FeatureUsageAnalytics/FeatureUsageAnalytics.jsx +989 -0
  231. package/src/views/feature-components/Features/NewServerManagement.jsx +217 -0
  232. package/src/views/feature-components/Features/ServerManagement.scss +120 -0
  233. package/src/views/feature-components/ForgotPassword/ForgotPassword.jsx +226 -0
  234. package/src/views/feature-components/LocationDirective/LocationDirective.jsx +992 -0
  235. package/src/views/feature-components/LocationDirective/LocationDirectiveV2.jsx +909 -0
  236. package/src/views/feature-components/NotFound.jsx +66 -0
  237. package/src/views/feature-components/Onboarding/Onboarding.jsx +1400 -0
  238. package/src/views/feature-components/Skeletons.js +115 -0
  239. package/src/views/feature-components/Unauthorized.jsx +48 -0
  240. package/src/views/feature-components/VerifyRoute.jsx +88 -0
  241. package/src/views/feature-components/YearlyRecap/YearlyRecap.jsx +357 -0
  242. package/src/views/feature-components/YearlyRecap/components/RecapSlide.jsx +183 -0
  243. package/src/views/feature-components/YearlyRecap/languageTranslator/TranslationContext.js +5 -0
  244. package/src/views/feature-components/YearlyRecap/languageTranslator/TranslationProvider.jsx +26 -0
  245. package/src/views/feature-components/YearlyRecap/languageTranslator/i18n.js +46 -0
  246. package/src/views/feature-components/YearlyRecap/languageTranslator/translations.json +167 -0
  247. package/src/views/feature-components/YearlyRecap/slides/IntroSlide.jsx +233 -0
  248. package/src/views/feature-components/YearlyRecap/slides/MaternalHealthSlide.jsx +146 -0
  249. package/src/views/feature-components/YearlyRecap/slides/MetricSlide.jsx +227 -0
  250. package/src/views/feature-components/YearlyRecap/slides/OutroSlide.jsx +701 -0
  251. package/src/views/feature-components/YearlyRecap/slides/ReachSlide.jsx +273 -0
  252. package/src/views/feature-components/login/Login.jsx +840 -0
  253. package/src/views/feature-components/login/Login.scss +154 -0
  254. package/src/views/feature-components/login/LoginConfigurator.jsx +1149 -0
  255. package/src/views/feature-components/login/TwoFactorSetupModal.jsx +411 -0
  256. package/src/views/feature-components/login/simplifyMenu.js +45 -0
  257. package/src/views/feature-components/system-config/ManageSystemConfigs.jsx +284 -0
  258. package/src/views/feature-components/system-config/SystemConfig.jsx +299 -0
  259. package/src/views/feature-components/users/ChangePasswordModal.jsx +243 -0
  260. package/src/views/feature-components/users/PasswordField.jsx +56 -0
  261. package/dist/index.css +0 -1
  262. package/dist/index.js +0 -32001
  263. package/dist/index.js.map +0 -1
@@ -0,0 +1,249 @@
1
+ import React, { useState, useEffect, useRef } from "react";
2
+ import { FormControl, Autocomplete, TextField, FormHelperText } from "@mui/material";
3
+ import { styled } from "@mui/material/styles";
4
+ import PropTypes from "prop-types";
5
+
6
+ // Styled span for read-only display
7
+ const StyledSpan = styled("span")(() => ({
8
+ backgroundColor: "transparent",
9
+ borderRadius: "0px",
10
+ padding: "0px",
11
+ paddingTop: "5px !important",
12
+ paddingBottom: "5px !important",
13
+ fontFamily: '"IBM Plex Mono"',
14
+ lineHeight: "18px",
15
+ border: "none",
16
+ cursor: "pointer",
17
+ fontSize: "14px",
18
+ "@media (max-width: 1536px)": {
19
+ fontSize: "13px",
20
+ },
21
+ "@media (max-width: 1200px)": {
22
+ fontSize: "12px",
23
+ },
24
+ }));
25
+
26
+
27
+
28
+ const ResizableEditAutocompleteField = ({
29
+ name,
30
+ menuItems,
31
+ error,
32
+ style,
33
+ // size = "big",
34
+ isEditable,
35
+ errorText,
36
+ initialValue,
37
+ index,
38
+ field,
39
+ showBrackets = false,
40
+ handleUpdate,
41
+ isTeleconsultation = false,
42
+ placeholder,
43
+ enteredInputTexts,
44
+ setEnteredInputText,
45
+ ...restProps
46
+ }) => {
47
+ const [readOnly, setReadOnly] = useState(true);
48
+ const [background, setBackground] = useState("transparent");
49
+ const [value, setValue] = useState({
50
+ value: initialValue,
51
+ menuLabel: initialValue,
52
+ });
53
+ const [inputText, setInputText] = useState(value?.menuLabel || "");
54
+
55
+ const inputRef = useRef(null);
56
+ const spanRef = useRef(null);
57
+
58
+ useEffect(() => {
59
+ setBackground(readOnly ? "transparent" : "#e3e3e3");
60
+ }, [readOnly]);
61
+
62
+ useEffect(() => {
63
+ if (spanRef.current && value?.menuLabel) {
64
+ spanRef.current.style.width = `${value.menuLabel.length + 2}ch`;
65
+ }
66
+ }, [value, readOnly]);
67
+
68
+ const handleDoubleClick = () => {
69
+ isEditable && setReadOnly(false);
70
+ };
71
+
72
+ useEffect(() => {
73
+ if (!readOnly && inputRef.current) {
74
+ setTimeout(() => {
75
+ inputRef.current?.focus();
76
+ }, 100);
77
+ }
78
+ }, [readOnly]);
79
+
80
+ const handleChange = async (
81
+ event,
82
+ selectedItem
83
+ ) => {
84
+ let finalValue;
85
+
86
+ // Handle custom input
87
+ if (typeof selectedItem === "string") {
88
+ finalValue = { value: selectedItem, menuLabel: selectedItem };
89
+ } else if (selectedItem && typeof selectedItem === "object") {
90
+ finalValue = {
91
+ value: selectedItem.value ?? "",
92
+ menuLabel: selectedItem.menuLabel ?? "",
93
+ };
94
+ } else {
95
+ finalValue = { value: "", menuLabel: "" };
96
+ }
97
+
98
+ setValue(finalValue);
99
+ if (setEnteredInputText) {
100
+ const updated = [...(enteredInputTexts || [])];
101
+ updated[index] = finalValue.menuLabel;
102
+ setEnteredInputText(updated);
103
+ }
104
+ setInputText(finalValue.menuLabel);
105
+ await handleUpdate(index, field, finalValue.value);
106
+ setReadOnly(true);
107
+ };
108
+
109
+ const displayText = value?.menuLabel || "";
110
+
111
+ return readOnly ? (
112
+ <StyledSpan
113
+ onDoubleClick={handleDoubleClick}
114
+ ref={spanRef}
115
+ style={{
116
+ marginLeft: "4px",
117
+ cursor: isEditable ? "pointer" : "default",
118
+ color: isTeleconsultation ? "#ffffff" : "#485772",
119
+ }}
120
+ >
121
+ {displayText === "" && isEditable ? (
122
+ <i
123
+ className="ri-add-line"
124
+ style={{ color: isTeleconsultation ? "#1aff1a" : "green" }}
125
+ onClick={handleDoubleClick}
126
+ >
127
+ {placeholder}
128
+ </i>
129
+ ) : showBrackets && displayText !== "" ? (
130
+ `(${displayText})`
131
+ ) : (
132
+ `${displayText}`
133
+ )}
134
+ </StyledSpan>
135
+ ) : (
136
+ <div>
137
+ <FormControl error={error} sx={style}>
138
+ <Autocomplete
139
+ fullWidth
140
+ disableClearable
141
+ options={menuItems}
142
+ getOptionLabel={(option) =>
143
+ typeof option === "string" ? option : option?.menuLabel || ""
144
+ }
145
+ isOptionEqualToValue={(option, val) => option.value === val.value}
146
+ value={value}
147
+ freeSolo
148
+ inputValue={inputText}
149
+ onInputChange={(event, newInputValue) => {
150
+ setInputText(newInputValue);
151
+ if (setEnteredInputText) {
152
+ const updated = [...(enteredInputTexts || [])];
153
+ updated[index] = newInputValue;
154
+ setEnteredInputText(updated);
155
+ }
156
+ }}
157
+ onChange={async (event, selectedValue) => {
158
+ await handleChange(event, selectedValue);
159
+ }}
160
+ onBlur={() => setReadOnly(true)}
161
+ renderInput={(params) => (
162
+ <TextField
163
+ {...params}
164
+ inputRef={inputRef}
165
+ placeholder={placeholder}
166
+ variant="outlined"
167
+ sx={{
168
+ "& .MuiOutlinedInput-root": {
169
+ padding: "3.5px 0px",
170
+ fontSize: "13px",
171
+ lineHeight: "18px",
172
+ background: background,
173
+ borderRadius: "0px",
174
+ width: `${inputText?.length + 2}ch`,
175
+ minWidth: `${(inputText?.length || 8) + 2}ch`,
176
+ },
177
+ "& .MuiOutlinedInput-input": {
178
+ backgroundColor: "#e3e3e3",
179
+ color: "#485772",
180
+ py: "0px !important",
181
+ },
182
+ "& .MuiOutlinedInput-notchedOutline": {
183
+ border: "none",
184
+ },
185
+ }}
186
+ error={error}
187
+ />
188
+ )}
189
+ slotProps={{
190
+ popper: { style: { minWidth: "150px" } },
191
+ paper: {
192
+ sx: {
193
+ boxShadow: "0px 4px 20px rgba(0, 0, 0, 0.1)",
194
+ maxHeight: "200px",
195
+ overflowY: "auto",
196
+ },
197
+ },
198
+ listbox: {
199
+ sx: {
200
+ maxHeight: "200px",
201
+ borderRadius: "4px",
202
+ overflowY: "auto",
203
+ "&::-webkit-scrollbar": {
204
+ width: "4px",
205
+ },
206
+ "&::-webkit-scrollbar-thumb": {
207
+ backgroundColor: "#398bb2",
208
+ borderRadius: "8px",
209
+ },
210
+ "&::-webkit-scrollbar-track": {
211
+ backgroundColor: "#f1f1f1",
212
+ },
213
+ },
214
+ },
215
+ }}
216
+ openOnFocus
217
+ {...restProps}
218
+ />
219
+ {error && (
220
+ <FormHelperText error id={`standard-weight-helper-text-${name}`}>
221
+ {errorText}
222
+ </FormHelperText>
223
+ )}
224
+ </FormControl>
225
+ </div>
226
+ );
227
+ };
228
+
229
+ export default ResizableEditAutocompleteField;
230
+
231
+
232
+ ResizableEditAutocompleteField.propTypes = {
233
+ name: PropTypes.any,
234
+ menuItems: PropTypes.any,
235
+ error: PropTypes.any,
236
+ style: PropTypes.any,
237
+ size: PropTypes.any,
238
+ isEditable: PropTypes.any,
239
+ errorText: PropTypes.any,
240
+ initialValue: PropTypes.any,
241
+ index: PropTypes.any,
242
+ field: PropTypes.any,
243
+ showBrackets: PropTypes.any,
244
+ handleUpdate: PropTypes.any,
245
+ isTeleconsultation: PropTypes.any,
246
+ placeholder: PropTypes.any,
247
+ enteredInputTexts: PropTypes.any,
248
+ setEnteredInputText: PropTypes.any,
249
+ };
@@ -0,0 +1,215 @@
1
+ import React from 'react';
2
+ import { useState } from 'react';
3
+ import { useEffect } from 'react';
4
+ import { useRef } from 'react';
5
+ import { styled } from '@mui/material/styles';
6
+ import PropTypes from 'prop-types';
7
+
8
+ const StyledTextField = styled('input')(() => ({
9
+ backgroundColor: '#e3e3e3',
10
+ borderRadius: '0px',
11
+ padding: '0px 5px',
12
+ paddingTop: '2px !important',
13
+ paddingBottom: '2px !important',
14
+ fontFamily: 'IBM Plex Mono',
15
+ fontSize: '14px',
16
+ lineHeight: '18px',
17
+ fontWeight: 500,
18
+ border: 'none',
19
+ '&:focus-visible': {
20
+ outline: 'none !important',
21
+ },
22
+ '&::placeholder': {
23
+ color: '#939393',
24
+ },
25
+ }));
26
+
27
+ const StyledSpan = styled('span')(() => ({
28
+ backgroundColor: 'transparent',
29
+ borderRadius: '0px',
30
+ padding: '0px',
31
+ paddingTop: '5px !important',
32
+ paddingBottom: '5px !important',
33
+ fontFamily: '"IBM Plex Mono"',
34
+ lineHeight: '18px',
35
+ color: '#485772',
36
+ fontWeight: 500,
37
+ border: 'none',
38
+ width: 'auto',
39
+
40
+ fontSize: '14px',
41
+ '@media (max-width: 1536px)': {
42
+ fontSize: '13px',
43
+ },
44
+ '@media (max-width: 1200px)': {
45
+ fontSize: '12px',
46
+ },
47
+ }));
48
+
49
+ const ResizableEditInputField = ({
50
+ // name,
51
+ // error,
52
+ // style,
53
+ // errorText,
54
+ initialValue = '',
55
+ handleUpdate,
56
+ index,
57
+ field,
58
+ maxLength,
59
+ // textLimitations,
60
+ isTeleconsultation = false,
61
+ showBrackets = false,
62
+ placeholder = 'Add Text',
63
+ isEditable = false,
64
+ InputProps,
65
+ ...restProps
66
+ }) => {
67
+ const [readOnly, setReadOnly] = useState(true);
68
+ const [value, setValue] = useState(initialValue);
69
+ const inputRef = useRef(null);
70
+
71
+ useEffect(() => {
72
+ if (inputRef.current) {
73
+ inputRef.current.focus();
74
+ inputRef.current.setSelectionRange(value?.length, value?.length);
75
+ }
76
+ }, [readOnly]);
77
+
78
+ const handleDoubleClick = () => {
79
+ isEditable && setReadOnly(false);
80
+ };
81
+
82
+ const formatDuration = (input) => {
83
+ // Regular expression to match numeric part
84
+ const matchNumeric = input?.match(/\d+/);
85
+ const numericPart = matchNumeric ? parseInt(matchNumeric[0]) : null;
86
+ if (numericPart === null) {
87
+ return '';
88
+ }
89
+
90
+ // Regular expression to match string part
91
+ const matchString = input?.match(/([^0-9]+)\b/);
92
+ const stringPart = matchString ? matchString[0].trim() : '';
93
+
94
+ let durationUnit;
95
+ switch (stringPart.toLowerCase().charAt(0)) {
96
+ case 'm':
97
+ durationUnit = 'Month';
98
+ break;
99
+ case 'w':
100
+ durationUnit = 'Week';
101
+ break;
102
+ case 'y':
103
+ durationUnit = 'Year';
104
+ break;
105
+ default:
106
+ durationUnit = 'Day';
107
+ break;
108
+ }
109
+
110
+ return `${numericPart} ${durationUnit}${numericPart > 1 ? 's' : ''}`;
111
+ };
112
+
113
+ const handleChange = (event) => {
114
+ setValue(event.target.value);
115
+ if (inputRef.current) {
116
+ inputRef.current.style.width = `${event.target.value?.length + 2}ch`;
117
+ }
118
+ };
119
+
120
+ const handleBlur = async () => {
121
+ if (field === 'duration' || field === 'since') {
122
+ const formattedDuration = formatDuration(value);
123
+ setValue(formattedDuration);
124
+ await handleUpdate(index, field, formattedDuration);
125
+ } else {
126
+ await handleUpdate(index, field, value);
127
+ }
128
+ setReadOnly(true);
129
+ };
130
+
131
+ const handleKeyPress = async (event) => {
132
+ if (event.key === 'Enter') {
133
+ if (field === 'duration' || field === 'since') {
134
+ const formattedDuration = formatDuration(event.target.value);
135
+ setValue(formattedDuration);
136
+ await handleUpdate(index, field, formattedDuration);
137
+ } else {
138
+ await handleUpdate(index, field, event.target.value);
139
+ }
140
+ setReadOnly(true);
141
+ }
142
+ };
143
+
144
+ return readOnly ? (
145
+ <StyledSpan
146
+ onDoubleClick={handleDoubleClick}
147
+ style={{
148
+ width: `${value?.length}ch`,
149
+ marginLeft: showBrackets ? '4px' : '0px',
150
+ cursor: isEditable ? 'pointer' : 'default',
151
+ color: isTeleconsultation ? '#ffffff' : '#485772',
152
+ }}
153
+ >
154
+ {value
155
+ ? showBrackets
156
+ ? `(${value})`
157
+ : value
158
+ : isEditable && (
159
+ <i
160
+ className="ri-add-line"
161
+ style={{ color: isTeleconsultation ? '#1aff1a' : 'green' }}
162
+ onClick={handleDoubleClick}
163
+ >
164
+ {placeholder}
165
+ </i>
166
+ )}
167
+ </StyledSpan>
168
+ ) : (
169
+ <StyledTextField
170
+ ref={inputRef}
171
+ type="text"
172
+ value={value || ''}
173
+ placeholder={placeholder}
174
+ onChange={handleChange}
175
+ onKeyDown={async (e) => {
176
+ await handleKeyPress(e);
177
+ }}
178
+ onBlur={async () => {
179
+ await handleBlur();
180
+ }}
181
+ readOnly={readOnly}
182
+ maxLength={maxLength}
183
+ style={{
184
+ width: value ? `${value?.length + 2}ch` : `${placeholder.length + 2}ch`,
185
+ marginLeft: '3px',
186
+ color: isTeleconsultation ? '#ffffff' : '#485772',
187
+ backgroundColor: isTeleconsultation ? 'rgba(0, 0, 0, 0.6)' : '',
188
+ borderRadius: isTeleconsultation ? '5px' : '',
189
+ }}
190
+ {...InputProps}
191
+ {...restProps}
192
+ />
193
+ );
194
+ };
195
+
196
+ export default ResizableEditInputField;
197
+
198
+
199
+ ResizableEditInputField.propTypes = {
200
+ name: PropTypes.any,
201
+ error: PropTypes.any,
202
+ style: PropTypes.any,
203
+ errorText: PropTypes.any,
204
+ initialValue: PropTypes.any,
205
+ handleUpdate: PropTypes.any,
206
+ index: PropTypes.any,
207
+ field: PropTypes.any,
208
+ maxLength: PropTypes.any,
209
+ textLimitations: PropTypes.any,
210
+ isTeleconsultation: PropTypes.any,
211
+ showBrackets: PropTypes.any,
212
+ placeholder: PropTypes.any,
213
+ isEditable: PropTypes.any,
214
+ InputProps: PropTypes.any,
215
+ };
@@ -0,0 +1,197 @@
1
+ import React, { useState, useEffect, useRef } from 'react';
2
+ import { FormControl, Select, MenuItem, FormHelperText } from '@mui/material';
3
+ import { styled } from '@mui/material/styles';
4
+ import PropTypes from 'prop-types';
5
+
6
+ // Styled components for read-only mode (span) and editable mode (Select)
7
+ const StyledSpan = styled('span')(() => ({
8
+ backgroundColor: 'transparent',
9
+ borderRadius: '0px',
10
+ padding: '0px',
11
+ paddingTop: '5px !important',
12
+ paddingBottom: '5px !important',
13
+ lineHeight: '18px',
14
+ border: 'none',
15
+ cursor: 'pointer',
16
+ fontSize: '14px',
17
+ '@media (max-width: 1536px)': {
18
+ fontSize: '13px',
19
+ },
20
+ '@media (max-width: 1200px)': {
21
+ fontSize: '12px',
22
+ },
23
+ }));
24
+
25
+ const ResizableEditSelectField = ({
26
+ name,
27
+ menuItems,
28
+ error,
29
+ style,
30
+ // size = 'big',
31
+ isEditable,
32
+ errorText,
33
+ initialValue,
34
+ index,
35
+ field,
36
+ showBrackets = false,
37
+ handleUpdate,
38
+ isTeleconsultation = false,
39
+ placeholder,
40
+ ...restProps
41
+ }) => {
42
+ const [readOnly, setReadOnly] = useState(true);
43
+ const [background, setBackground] = useState('transparent');
44
+ const [value, setValue] = useState(initialValue === null ? menuItems[0].value : initialValue);
45
+ const selectRef = useRef(null);
46
+ const inputRef = useRef(null);
47
+ const spanRef = useRef(null);
48
+ const [forceOpen, setForceOpen] = useState(false);
49
+
50
+ useEffect(() => {
51
+ setBackground(readOnly ? 'transparent' : '#e3e3e3');
52
+ }, [readOnly]);
53
+
54
+ useEffect(() => {
55
+ if (selectRef.current && value !== undefined) {
56
+ selectRef.current.style.width = `${value.length + 5}ch`;
57
+ }
58
+ if (spanRef.current && value !== undefined) {
59
+ spanRef.current.style.width = `${value.length + 2}ch`;
60
+ }
61
+ }, [value, readOnly]);
62
+
63
+ const handleDoubleClick = () => {
64
+ if (isEditable) {
65
+ setReadOnly(false);
66
+ setForceOpen(true);
67
+ }
68
+ };
69
+
70
+ useEffect(() => {
71
+ if (!readOnly && inputRef.current) {
72
+ setTimeout(() => {
73
+ inputRef.current?.focus();
74
+ }, 100);
75
+ }
76
+ }, [readOnly]);
77
+
78
+ const handleChange = async (event) => {
79
+ const selectedValue = event.target.value;
80
+ setValue(selectedValue);
81
+ // Switch back to readOnly mode when an option is selected
82
+ setReadOnly(true);
83
+ await handleUpdate(index, field, selectedValue);
84
+ };
85
+
86
+ const handleKeyPress = (event) => {
87
+ if (event.key === 'Enter') {
88
+ setReadOnly(true);
89
+ handleUpdate(index, field, value ?? '');
90
+ }
91
+ };
92
+
93
+ return readOnly ? (
94
+ <StyledSpan
95
+ onDoubleClick={handleDoubleClick}
96
+ ref={spanRef}
97
+ style={{
98
+ width: `${(value ?? '').length + 2}ch`,
99
+ marginLeft: '4px',
100
+ cursor: isEditable ? 'pointer' : 'default',
101
+ color: isTeleconsultation ? '#ffffff' : '#485772',
102
+ }}
103
+ >
104
+ {value === '' && isEditable ? (
105
+ <i
106
+ className="ri-add-line"
107
+ style={{ color: isTeleconsultation ? '#1aff1a' : 'green' }}
108
+ onClick={handleDoubleClick}
109
+ >
110
+ {placeholder}
111
+ </i>
112
+ ) : showBrackets && value !== '' ? (
113
+ `(${menuItems.find((item) => item.value === value)?.menuLabel || ''})`
114
+ ) : (
115
+ `${menuItems.find((item) => item.value === value)?.menuLabel || ''}`
116
+ )}
117
+ </StyledSpan>
118
+ ) : (
119
+ <div>
120
+ <FormControl error={error} sx={style}>
121
+ <Select
122
+ onClose={() => setReadOnly(true)}
123
+ open={forceOpen}
124
+ ref={selectRef}
125
+ sx={{
126
+ '& .MuiSelect-select': {
127
+ paddingTop: readOnly ? '0px' : '5px',
128
+ paddingBottom: readOnly ? '10px' : '5px',
129
+ paddingLeft: readOnly ? '0px' : '10px',
130
+ paddingRight: '0px !important',
131
+ fontSize: '14px',
132
+ lineHeight: '18px',
133
+ color: isTeleconsultation ? (readOnly ? '#ffffff' : '#485772') : '#485772',
134
+ fontWeight: '500',
135
+ borderRadius: '0px',
136
+ },
137
+ '& .MuiOutlinedInput-notchedOutline': {
138
+ border: 'none',
139
+ },
140
+ '& .MuiSelect-icon': {
141
+ display: readOnly ? 'none' : undefined,
142
+ },
143
+ background: background,
144
+ }}
145
+ MenuProps={{ MenuListProps: { disablePadding: true } }}
146
+ inputProps={{
147
+ sx: {
148
+ background: background,
149
+ },
150
+ ref: inputRef,
151
+ }}
152
+ value={value}
153
+ onChange={async (e) => {
154
+ await handleChange(e);
155
+ }}
156
+ onKeyDownCapture={handleKeyPress}
157
+ onBlur={() => {
158
+ setReadOnly(true);
159
+ }}
160
+ {...restProps}
161
+ >
162
+ {menuItems.map((row, index) => (
163
+ <MenuItem key={index} value={row.value}>
164
+ {row.menuLabel}
165
+ </MenuItem>
166
+ ))}
167
+ </Select>
168
+ {error && (
169
+ <FormHelperText error id={`standard-weight-helper-text-${name}`}>
170
+ {errorText}
171
+ </FormHelperText>
172
+ )}
173
+ </FormControl>
174
+ </div>
175
+ );
176
+ };
177
+
178
+ export default ResizableEditSelectField;
179
+
180
+
181
+
182
+ ResizableEditSelectField.propTypes = {
183
+ name: PropTypes.any,
184
+ menuItems: PropTypes.any,
185
+ error: PropTypes.any,
186
+ style: PropTypes.any,
187
+ size: PropTypes.any,
188
+ isEditable: PropTypes.any,
189
+ errorText: PropTypes.any,
190
+ initialValue: PropTypes.any,
191
+ index: PropTypes.any,
192
+ field: PropTypes.any,
193
+ showBrackets: PropTypes.any,
194
+ handleUpdate: PropTypes.any,
195
+ isTeleconsultation: PropTypes.any,
196
+ placeholder: PropTypes.any,
197
+ };