medos-sdk 1.1.10 → 1.1.12

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 (265) hide show
  1. package/dist/client/MedosClient.d.ts +1 -0
  2. package/dist/client/MedosClient.js +8 -1
  3. package/dist/components/AppointmentCalender.js +19 -22
  4. package/dist/components/AppointmentConfirmationStep.d.ts +1 -0
  5. package/dist/components/AppointmentConfirmationStep.js +34 -42
  6. package/dist/components/AppointmentDateTimeModal.d.ts +1 -0
  7. package/dist/components/AppointmentDateTimeModal.js +201 -168
  8. package/dist/components/AppointmentSummaryStep.d.ts +12 -0
  9. package/dist/components/AppointmentSummaryStep.js +168 -0
  10. package/dist/components/BookingOptionStep.d.ts +14 -0
  11. package/dist/components/BookingOptionStep.js +346 -0
  12. package/dist/components/ContactInformationStep.js +10 -4
  13. package/dist/components/ContactPreferenceStep.js +10 -1
  14. package/dist/components/DoctorSelectModal.js +105 -59
  15. package/dist/components/EnquiryForm.js +81 -69
  16. package/dist/components/Icons/CloseIcon.d.ts +9 -0
  17. package/dist/components/Icons/CloseIcon.js +5 -0
  18. package/dist/components/InquiryDetailsStep.js +5 -1
  19. package/dist/components/PatientDetailsStep.js +17 -12
  20. package/dist/components/PatientSelectionStep.d.ts +12 -0
  21. package/dist/components/PatientSelectionStep.js +254 -0
  22. package/dist/components/PhoneVerificationStep.js +1 -1
  23. package/dist/components/SuccessStep.js +1 -1
  24. package/dist/components/appointment-booking/AppointmentCalender.js +145 -67
  25. package/dist/components/appointment-booking/appointment-modal-styles.d.ts +272 -0
  26. package/dist/components/appointment-booking/appointment-modal-styles.js +419 -0
  27. package/dist/components/appointment-booking/components/AppointmentConfirmationStep.d.ts +28 -0
  28. package/dist/components/appointment-booking/components/AppointmentConfirmationStep.js +107 -0
  29. package/dist/components/appointment-booking/components/AppointmentDateTimeModal.d.ts +18 -0
  30. package/dist/components/appointment-booking/components/AppointmentDateTimeModal.js +306 -0
  31. package/dist/components/appointment-booking/components/AppointmentSummaryStep.d.ts +12 -0
  32. package/dist/components/appointment-booking/components/AppointmentSummaryStep.js +194 -0
  33. package/dist/components/appointment-booking/components/BookingOptionStep.d.ts +14 -0
  34. package/dist/components/appointment-booking/components/BookingOptionStep.js +350 -0
  35. package/dist/components/appointment-booking/components/DoctorSelectModal.d.ts +14 -0
  36. package/dist/components/appointment-booking/components/DoctorSelectModal.js +213 -0
  37. package/dist/components/appointment-booking/components/PatientDetailsStep.d.ts +3 -0
  38. package/dist/components/appointment-booking/components/PatientDetailsStep.js +96 -0
  39. package/dist/components/appointment-booking/components/PatientSelectionStep.d.ts +12 -0
  40. package/dist/components/appointment-booking/components/PatientSelectionStep.js +254 -0
  41. package/dist/components/appointment-booking/components/PhoneVerificationStep.d.ts +3 -0
  42. package/dist/components/appointment-booking/components/PhoneVerificationStep.js +49 -0
  43. package/dist/components/appointment-booking/components/SuccessStep.d.ts +5 -0
  44. package/dist/components/appointment-booking/components/SuccessStep.js +9 -0
  45. package/dist/components/appointment-booking/components/index.d.ts +9 -0
  46. package/dist/components/appointment-booking/components/index.js +9 -0
  47. package/dist/components/appointment-booking/hooks/useAppointmentFlow.d.ts +0 -1
  48. package/dist/components/appointment-booking/hooks/useAppointmentFlow.js +111 -25
  49. package/dist/components/appointment-booking/hooks/useAppointmentState.js +32 -0
  50. package/dist/components/appointment-booking/hooks/useInitializeAddresses.js +0 -1
  51. package/dist/components/appointment-booking/index.d.ts +2 -4
  52. package/dist/components/appointment-booking/index.js +2 -2
  53. package/dist/components/appointment-booking/types.d.ts +167 -0
  54. package/dist/components/appointment-booking/types.js +16 -0
  55. package/dist/components/appointment-modal-styles.d.ts +259 -0
  56. package/dist/components/appointment-modal-styles.js +395 -0
  57. package/dist/components/constant.d.ts +2 -0
  58. package/dist/components/constant.js +15 -0
  59. package/dist/components/constants/constant.d.ts +2 -0
  60. package/dist/components/constants/constant.js +15 -0
  61. package/dist/components/constants/index.d.ts +3 -0
  62. package/dist/components/constants/index.js +24 -0
  63. package/dist/components/constants/options.d.ts +13 -0
  64. package/dist/components/constants/options.js +35 -0
  65. package/dist/components/constants/validation.d.ts +6 -0
  66. package/dist/components/constants/validation.js +16 -0
  67. package/dist/components/custom-calendar.js +20 -11
  68. package/dist/components/enquiry-form/EnquiryForm.d.ts +7 -0
  69. package/dist/components/enquiry-form/EnquiryForm.js +238 -0
  70. package/dist/components/enquiry-form/components/ContactInformationStep.d.ts +13 -0
  71. package/dist/components/enquiry-form/components/ContactInformationStep.js +21 -0
  72. package/dist/components/enquiry-form/components/ContactPreferenceStep.d.ts +9 -0
  73. package/dist/components/enquiry-form/components/ContactPreferenceStep.js +20 -0
  74. package/dist/components/enquiry-form/components/InquiryDetailsStep.d.ts +10 -0
  75. package/dist/components/enquiry-form/components/InquiryDetailsStep.js +20 -0
  76. package/dist/components/enquiry-form/components/index.d.ts +3 -0
  77. package/dist/components/enquiry-form/components/index.js +3 -0
  78. package/dist/components/enquiry-form/index.d.ts +2 -0
  79. package/dist/components/enquiry-form/index.js +2 -0
  80. package/dist/components/index.d.ts +7 -0
  81. package/dist/components/index.js +7 -0
  82. package/dist/components/shared/icons/Check.d.ts +6 -0
  83. package/dist/components/shared/icons/Check.js +2 -0
  84. package/dist/components/shared/icons/ChevronDownIcon.d.ts +4 -0
  85. package/dist/components/shared/icons/ChevronDownIcon.js +2 -0
  86. package/dist/components/shared/icons/ChevronLeft.d.ts +3 -0
  87. package/dist/components/shared/icons/ChevronLeft.js +3 -0
  88. package/dist/components/shared/icons/ChevronRight.d.ts +3 -0
  89. package/dist/components/shared/icons/ChevronRight.js +3 -0
  90. package/dist/components/shared/icons/CloseIcon.d.ts +9 -0
  91. package/dist/components/shared/icons/CloseIcon.js +5 -0
  92. package/dist/components/shared/icons/ConfirmationCheck.d.ts +1 -0
  93. package/dist/components/shared/icons/ConfirmationCheck.js +9 -0
  94. package/dist/components/shared/icons/ConsultationType.d.ts +1 -0
  95. package/dist/components/shared/icons/ConsultationType.js +2 -0
  96. package/dist/components/shared/icons/Date&TimeIcon.d.ts +1 -0
  97. package/dist/components/shared/icons/Date&TimeIcon.js +2 -0
  98. package/dist/components/shared/icons/MapIcon.d.ts +1 -0
  99. package/dist/components/shared/icons/MapIcon.js +2 -0
  100. package/dist/components/shared/icons/MedosLogo.d.ts +3 -0
  101. package/dist/components/shared/icons/MedosLogo.js +3 -0
  102. package/dist/components/shared/icons/PaymentMethodIcon.d.ts +1 -0
  103. package/dist/components/shared/icons/PaymentMethodIcon.js +2 -0
  104. package/dist/components/shared/icons/SuccessIcon.d.ts +8 -0
  105. package/dist/components/shared/icons/SuccessIcon.js +14 -0
  106. package/dist/components/shared/icons/UserIcon.d.ts +1 -0
  107. package/dist/components/shared/icons/UserIcon.js +2 -0
  108. package/dist/components/shared/icons/index.d.ts +13 -0
  109. package/dist/components/shared/icons/index.js +13 -0
  110. package/dist/components/shared/index.d.ts +2 -0
  111. package/dist/components/shared/index.js +2 -0
  112. package/dist/components/shared/ui/Calendar.d.ts +5 -0
  113. package/dist/components/shared/ui/Calendar.js +167 -0
  114. package/dist/components/shared/ui/SelectDropdown.d.ts +41 -0
  115. package/dist/components/shared/ui/SelectDropdown.js +301 -0
  116. package/dist/components/shared/ui/index.d.ts +2 -0
  117. package/dist/components/shared/ui/index.js +2 -0
  118. package/dist/components/styles/appointment.d.ts +4 -0
  119. package/dist/components/styles/appointment.js +220 -0
  120. package/dist/components/styles/enquiry.d.ts +2 -0
  121. package/dist/components/styles/enquiry.js +3 -0
  122. package/dist/components/styles/index.d.ts +2 -0
  123. package/dist/components/styles/index.js +2 -0
  124. package/dist/components/styles/shared.d.ts +3 -0
  125. package/dist/components/styles/shared.js +78 -0
  126. package/dist/components/styles.d.ts +1 -6
  127. package/dist/components/styles.js +1 -257
  128. package/dist/components/theme-styles.d.ts +5 -4
  129. package/dist/components/theme-styles.js +239 -125
  130. package/dist/components/types/appointment.d.ts +42 -0
  131. package/dist/components/types/appointment.js +1 -0
  132. package/dist/components/types/common.d.ts +24 -0
  133. package/dist/components/types/common.js +1 -0
  134. package/dist/components/types/enquiry.d.ts +59 -0
  135. package/dist/components/types/enquiry.js +1 -0
  136. package/dist/components/types/index.d.ts +4 -0
  137. package/dist/components/types/index.js +4 -0
  138. package/dist/components/types.d.ts +1 -52
  139. package/dist/components/types.js +1 -23
  140. package/dist/components/utils/date.d.ts +4 -0
  141. package/dist/components/utils/date.js +65 -0
  142. package/dist/components/utils/formatting.d.ts +4 -0
  143. package/dist/components/utils/formatting.js +9 -0
  144. package/dist/components/utils/index.d.ts +3 -0
  145. package/dist/components/utils/index.js +3 -0
  146. package/dist/components/utils/validation.d.ts +4 -0
  147. package/dist/components/utils/validation.js +37 -0
  148. package/dist/components/utils.d.ts +1 -5
  149. package/dist/components/utils.js +1 -15
  150. package/dist/components/validation.d.ts +1 -2
  151. package/dist/components/validation.js +1 -7
  152. package/dist/constants/index.d.ts +1 -1
  153. package/dist/constants/index.js +1 -1
  154. package/dist/core/theme/index.d.ts +1 -0
  155. package/dist/core/theme/index.js +1 -0
  156. package/dist/core/theme/responsive.d.ts +15 -0
  157. package/dist/core/theme/responsive.js +113 -0
  158. package/dist/core/theme/themes.js +16 -4
  159. package/dist/core/theme/types.d.ts +8 -0
  160. package/dist/index.d.ts +4 -2
  161. package/dist/index.js +2 -1
  162. package/dist/react/ThemeProvider.d.ts +2 -1
  163. package/dist/react/ThemeProvider.js +49 -10
  164. package/dist/react/index.d.ts +3 -3
  165. package/dist/react/index.js +1 -1
  166. package/dist/services/AppointmentService.d.ts +80 -2
  167. package/dist/services/AppointmentService.js +131 -5
  168. package/dist/services/AuthService.js +1 -1
  169. package/dist/services/WorkspaceService.d.ts +58 -3
  170. package/dist/services/WorkspaceService.js +10 -1
  171. package/dist/vanilla/AppointmentCalendarWidget.d.ts +17 -7
  172. package/dist/vanilla/AppointmentCalendarWidget.js +1401 -380
  173. package/dist/vanilla/EnquiryFormWidget.d.ts +1 -0
  174. package/dist/vanilla/EnquiryFormWidget.js +25 -43
  175. package/dist/vanilla/client/MedosClient.d.ts +1 -0
  176. package/dist/vanilla/components/AppointmentConfirmationStep.d.ts +1 -0
  177. package/dist/vanilla/components/AppointmentDateTimeModal.d.ts +1 -0
  178. package/dist/vanilla/components/AppointmentSummaryStep.d.ts +12 -0
  179. package/dist/vanilla/components/BookingOptionStep.d.ts +14 -0
  180. package/dist/vanilla/components/Icons/CloseIcon.d.ts +9 -0
  181. package/dist/vanilla/components/PatientSelectionStep.d.ts +12 -0
  182. package/dist/vanilla/components/VanillaCalendar.js +33 -18
  183. package/dist/vanilla/components/VanillaIcons.d.ts +5 -0
  184. package/dist/vanilla/components/VanillaIcons.js +92 -0
  185. package/dist/vanilla/components/VanillaSelect.d.ts +3 -0
  186. package/dist/vanilla/components/VanillaSelect.js +93 -5
  187. package/dist/vanilla/components/appointment-booking/appointment-modal-styles.d.ts +272 -0
  188. package/dist/vanilla/components/appointment-booking/components/AppointmentConfirmationStep.d.ts +28 -0
  189. package/dist/vanilla/components/appointment-booking/components/AppointmentDateTimeModal.d.ts +18 -0
  190. package/dist/vanilla/components/appointment-booking/components/AppointmentSummaryStep.d.ts +12 -0
  191. package/dist/vanilla/components/appointment-booking/components/BookingOptionStep.d.ts +14 -0
  192. package/dist/vanilla/components/appointment-booking/components/DoctorSelectModal.d.ts +14 -0
  193. package/dist/vanilla/components/appointment-booking/components/PatientDetailsStep.d.ts +3 -0
  194. package/dist/vanilla/components/appointment-booking/components/PatientSelectionStep.d.ts +12 -0
  195. package/dist/vanilla/components/appointment-booking/components/PhoneVerificationStep.d.ts +3 -0
  196. package/dist/vanilla/components/appointment-booking/components/SuccessStep.d.ts +5 -0
  197. package/dist/vanilla/components/appointment-booking/components/index.d.ts +9 -0
  198. package/dist/vanilla/components/appointment-booking/hooks/useAppointmentFlow.d.ts +0 -1
  199. package/dist/vanilla/components/appointment-booking/index.d.ts +2 -4
  200. package/dist/vanilla/components/appointment-booking/types.d.ts +167 -0
  201. package/dist/vanilla/components/appointment-modal-styles.d.ts +259 -0
  202. package/dist/vanilla/components/constant.d.ts +2 -0
  203. package/dist/vanilla/components/constants/constant.d.ts +2 -0
  204. package/dist/vanilla/components/constants/index.d.ts +3 -0
  205. package/dist/vanilla/components/constants/options.d.ts +13 -0
  206. package/dist/vanilla/components/constants/validation.d.ts +6 -0
  207. package/dist/vanilla/components/enquiry-form/EnquiryForm.d.ts +7 -0
  208. package/dist/vanilla/components/enquiry-form/components/ContactInformationStep.d.ts +13 -0
  209. package/dist/vanilla/components/enquiry-form/components/ContactPreferenceStep.d.ts +9 -0
  210. package/dist/vanilla/components/enquiry-form/components/InquiryDetailsStep.d.ts +10 -0
  211. package/dist/vanilla/components/enquiry-form/components/index.d.ts +3 -0
  212. package/dist/vanilla/components/enquiry-form/index.d.ts +2 -0
  213. package/dist/vanilla/components/index.d.ts +7 -3
  214. package/dist/vanilla/components/shared/icons/Check.d.ts +6 -0
  215. package/dist/vanilla/components/shared/icons/ChevronDownIcon.d.ts +4 -0
  216. package/dist/vanilla/components/shared/icons/ChevronLeft.d.ts +3 -0
  217. package/dist/vanilla/components/shared/icons/ChevronRight.d.ts +3 -0
  218. package/dist/vanilla/components/shared/icons/CloseIcon.d.ts +9 -0
  219. package/dist/vanilla/components/shared/icons/ConfirmationCheck.d.ts +1 -0
  220. package/dist/vanilla/components/shared/icons/ConsultationType.d.ts +1 -0
  221. package/dist/vanilla/components/shared/icons/Date&TimeIcon.d.ts +1 -0
  222. package/dist/vanilla/components/shared/icons/MapIcon.d.ts +1 -0
  223. package/dist/vanilla/components/shared/icons/MedosLogo.d.ts +3 -0
  224. package/dist/vanilla/components/shared/icons/PaymentMethodIcon.d.ts +1 -0
  225. package/dist/vanilla/components/shared/icons/SuccessIcon.d.ts +8 -0
  226. package/dist/vanilla/components/shared/icons/UserIcon.d.ts +1 -0
  227. package/dist/vanilla/components/shared/icons/index.d.ts +13 -0
  228. package/dist/vanilla/components/shared/index.d.ts +2 -0
  229. package/dist/vanilla/components/shared/ui/Calendar.d.ts +5 -0
  230. package/dist/vanilla/components/shared/ui/SelectDropdown.d.ts +41 -0
  231. package/dist/vanilla/components/shared/ui/index.d.ts +2 -0
  232. package/dist/vanilla/components/styles/appointment.d.ts +4 -0
  233. package/dist/vanilla/components/styles/enquiry.d.ts +2 -0
  234. package/dist/vanilla/components/styles/index.d.ts +2 -0
  235. package/dist/vanilla/components/styles/shared.d.ts +3 -0
  236. package/dist/vanilla/components/styles.d.ts +1 -6
  237. package/dist/vanilla/components/theme-styles.d.ts +5 -4
  238. package/dist/vanilla/components/types/appointment.d.ts +42 -0
  239. package/dist/vanilla/components/types/common.d.ts +24 -0
  240. package/dist/vanilla/components/types/enquiry.d.ts +59 -0
  241. package/dist/vanilla/components/types/index.d.ts +4 -0
  242. package/dist/vanilla/components/types.d.ts +1 -52
  243. package/dist/vanilla/components/utils/date.d.ts +4 -0
  244. package/dist/vanilla/components/utils/formatting.d.ts +4 -0
  245. package/dist/vanilla/components/utils/index.d.ts +3 -0
  246. package/dist/vanilla/components/utils/validation.d.ts +4 -0
  247. package/dist/vanilla/components/utils.d.ts +1 -5
  248. package/dist/vanilla/components/validation.d.ts +1 -2
  249. package/dist/vanilla/constants/index.d.ts +1 -1
  250. package/dist/vanilla/core/theme/index.d.ts +1 -0
  251. package/dist/vanilla/core/theme/responsive.d.ts +15 -0
  252. package/dist/vanilla/core/theme/types.d.ts +8 -0
  253. package/dist/vanilla/enquiry-widget.js +3632 -90
  254. package/dist/vanilla/index.d.ts +4 -2
  255. package/dist/vanilla/react/ThemeProvider.d.ts +2 -1
  256. package/dist/vanilla/react/index.d.ts +3 -3
  257. package/dist/vanilla/services/AppointmentService.d.ts +80 -2
  258. package/dist/vanilla/services/WorkspaceService.d.ts +58 -3
  259. package/dist/vanilla/vanilla/AppointmentCalendarWidget.d.ts +17 -7
  260. package/dist/vanilla/vanilla/EnquiryFormWidget.d.ts +1 -0
  261. package/dist/vanilla/vanilla/components/VanillaIcons.d.ts +5 -0
  262. package/dist/vanilla/vanilla/components/VanillaSelect.d.ts +3 -0
  263. package/dist/vanilla/widget.css +1045 -205
  264. package/dist/vanilla/widget.js +10365 -5737
  265. package/package.json +2 -2
@@ -13,6 +13,7 @@ declare class EnquiryFormWidget {
13
13
  private mounted;
14
14
  private state;
15
15
  private countryCodeSelect;
16
+ private contactMethodSelect;
16
17
  constructor(container: HTMLElement | string, options: EnquiryFormWidgetOptions);
17
18
  private init;
18
19
  private validateContactStep;
@@ -2,7 +2,7 @@ import { EnquiryService } from "../services/EnquiryService";
2
2
  import { MedosClient } from "../client/MedosClient";
3
3
  import { validateName, validateEmail, validatePhoneNumber, validateSubject, validateMessage, validateCountryCode, } from "../enquiry-form/validation";
4
4
  import { VanillaIcons } from "./components/VanillaIcons";
5
- import { VanillaSelect } from "./components/VanillaSelect";
5
+ import { VanillaSelect, createContactMethodSelect, } from "./components/VanillaSelect";
6
6
  import { injectThemedStyles } from "./components/theme-injector";
7
7
  const COUNTRY_CODES_ENQUIRY = [
8
8
  { value: "+91", label: "🇮🇳 +91" },
@@ -15,6 +15,7 @@ class EnquiryFormWidget {
15
15
  constructor(container, options) {
16
16
  this.mounted = true;
17
17
  this.countryCodeSelect = null;
18
+ this.contactMethodSelect = null;
18
19
  injectThemedStyles();
19
20
  if (typeof container === "string") {
20
21
  const el = document.getElementById(container);
@@ -64,7 +65,7 @@ class EnquiryFormWidget {
64
65
  this.setState({ error: "Please enter a valid name." });
65
66
  return false;
66
67
  }
67
- if (!validateEmail(this.state.patientEmail)) {
68
+ if (this.state.patientEmail && !validateEmail(this.state.patientEmail)) {
68
69
  this.setState({ error: "Please enter a valid email address." });
69
70
  return false;
70
71
  }
@@ -180,7 +181,7 @@ class EnquiryFormWidget {
180
181
  ? `
181
182
  <div class="medos-enquiry-header">
182
183
  <h2 class="medos-enquiry-title">Submit Inquiry</h2>
183
- <p class="medos-enquiry-step-indicator">Step ${this.state.step + 1} of 4</p>
184
+ <p class="medos-enquiry-step-indicator">Step ${this.state.step + 1} of 3</p>
184
185
  </div>
185
186
 
186
187
  ${this.state.loading
@@ -214,6 +215,14 @@ class EnquiryFormWidget {
214
215
  }
215
216
  }
216
217
  }
218
+ if (this.state.step === 2) {
219
+ const contactMethodContainer = this.container.querySelector("#medos-enquiry-contact-method-container");
220
+ if (contactMethodContainer) {
221
+ this.contactMethodSelect = createContactMethodSelect(contactMethodContainer, this.state.preferredContactMethod, (value) => {
222
+ this.state.preferredContactMethod = value;
223
+ });
224
+ }
225
+ }
217
226
  }
218
227
  renderStep() {
219
228
  switch (this.state.step) {
@@ -249,7 +258,7 @@ class EnquiryFormWidget {
249
258
  </div>
250
259
 
251
260
  <div class="medos-form-group">
252
- <label class="medos-label">Email Address <span class="medos-required">*</span></label>
261
+ <label class="medos-label">Email Address</label>
253
262
  <input
254
263
  type="email"
255
264
  class="medos-input"
@@ -333,37 +342,9 @@ class EnquiryFormWidget {
333
342
  </div>
334
343
  <div class="medos-section-body">
335
344
  <p class="medos-section-description">How would you prefer to be contacted?</p>
336
- <div class="medos-contact-options">
337
- <label class="medos-radio-option ${this.state.preferredContactMethod === "PHONE" ? "selected" : ""}">
338
- <input
339
- type="radio"
340
- name="contact-method"
341
- value="PHONE"
342
- ${this.state.preferredContactMethod === "PHONE" ? "checked" : ""}
343
- class="medos-radio-input"
344
- />
345
- <span class="medos-radio-label">Phone</span>
346
- </label>
347
- <label class="medos-radio-option ${this.state.preferredContactMethod === "EMAIL" ? "selected" : ""}">
348
- <input
349
- type="radio"
350
- name="contact-method"
351
- value="EMAIL"
352
- ${this.state.preferredContactMethod === "EMAIL" ? "checked" : ""}
353
- class="medos-radio-input"
354
- />
355
- <span class="medos-radio-label">Email</span>
356
- </label>
357
- <label class="medos-radio-option ${this.state.preferredContactMethod === "BOTH" ? "selected" : ""}">
358
- <input
359
- type="radio"
360
- name="contact-method"
361
- value="BOTH"
362
- ${this.state.preferredContactMethod === "BOTH" ? "checked" : ""}
363
- class="medos-radio-input"
364
- />
365
- <span class="medos-radio-label">Both</span>
366
- </label>
345
+ <div class="medos-form-group">
346
+ <label class="medos-label">Preferred Contact Method</label>
347
+ <div class="medos-contact-method-container" id="medos-enquiry-contact-method-container"></div>
367
348
  </div>
368
349
  </div>
369
350
  </div>
@@ -426,7 +407,7 @@ class EnquiryFormWidget {
426
407
  <div style="position: relative; display: inline-block;">
427
408
  <svg width="64" height="64" viewBox="0 0 41 41" fill="none">
428
409
  <path
429
- d="M31.1309 4.90254C32.388 4.98797 33.0166 5.03069 33.5247 5.25288C34.2598 5.57438 34.8467 6.16126 35.1682 6.8964C35.3904 7.40445 35.4331 8.03302 35.5185 9.29016L35.7135 12.159C35.748 12.6674 35.7653 12.9217 35.8206 13.1645C35.9004 13.5154 36.0391 13.8503 36.2308 14.1549C36.3634 14.3657 36.531 14.5576 36.8661 14.9416L38.7568 17.108C39.5853 18.0574 39.9996 18.532 40.2017 19.0484C40.4942 19.7955 40.4942 20.6255 40.2017 21.3727C39.9996 21.889 39.5853 22.3637 38.7568 23.313L36.8661 25.4795C36.531 25.8634 36.3634 26.0554 36.2308 26.2662C36.0391 26.5708 35.9004 26.9056 35.8206 27.2566C35.7653 27.4994 35.748 27.7536 35.7135 28.2621L35.5185 31.1309C35.4331 32.388 35.3904 33.0166 35.1682 33.5247C34.8467 34.2598 34.2598 34.8467 33.5247 35.1682C33.0166 35.3904 32.388 35.4331 31.1309 35.5185L28.2621 35.7135C27.7536 35.748 27.4994 35.7653 27.2566 35.8206C26.9056 35.9004 26.5708 36.0391 26.2662 36.2308C26.0554 36.3634 25.8634 36.531 25.4795 36.8661L23.313 38.7568C22.3637 39.5853 21.889 39.9996 21.3727 40.2017C20.6255 40.4942 19.7955 40.4942 19.0484 40.2017C18.532 39.9996 18.0574 39.5853 17.108 38.7568L14.9416 36.8661C14.5576 36.531 14.3657 36.3634 14.1549 36.2308C13.8503 36.0391 13.5154 35.9004 13.1645 35.8206C12.9217 35.7653 12.6674 35.748 12.159 35.7135L9.29016 35.5185C8.03302 35.4331 7.40445 35.3904 6.8964 35.1682C6.16126 34.8467 5.57438 34.2598 5.25288 33.5247C5.03069 33.0166 4.98797 32.388 4.90254 31.1309L4.70759 28.2621C4.67304 27.7536 4.65576 27.4994 4.60049 27.2566C4.52063 26.9056 4.38193 26.5708 4.19028 26.2662C4.05764 26.0554 3.89009 25.8634 3.555 25.4795L1.66428 23.313C0.83576 22.3637 0.421499 21.889 0.219363 21.3727C-0.073121 20.6255 -0.0731209 19.7955 0.219363 19.0484C0.421499 18.532 0.83576 18.0574 1.66428 17.108L3.555 14.9416C3.89009 14.5576 4.05764 14.3657 4.19027 14.1549C4.38193 13.8503 4.52063 13.5154 4.60049 13.1645C4.65576 12.9217 4.67304 12.6674 4.70759 12.159L4.90254 9.29016C4.98797 8.03302 5.03069 7.40445 5.25288 6.8964C5.57438 6.16126 6.16126 5.57438 6.8964 5.25288C7.40445 5.03069 8.03302 4.98797 9.29016 4.90254L12.159 4.70759C12.6674 4.67304 12.9217 4.65577 13.1645 4.6005C13.5154 4.52063 13.8503 4.38193 14.1549 4.19028C14.3657 4.05764 14.5576 3.89009 14.9416 3.555L17.108 1.66428C18.0574 0.83576 18.532 0.421499 19.0484 0.219363C19.7955 -0.073121 20.6255 -0.073121 21.3727 0.219363C21.889 0.421499 22.3637 0.83576 23.313 1.66428L25.4795 3.555C25.8634 3.89009 26.0554 4.05764 26.2662 4.19028C26.5708 4.38193 26.9056 4.52063 27.2566 4.6005C27.4994 4.65577 27.7536 4.67304 28.2621 4.70759L31.1309 4.90254Z"
410
+ d="M31.1309 4.90254C32.388 4.98797 33.0166 5.03069 33.5247 5.25288 C34.2598 5.57438 34.8467 6.16126 35.1682 6.8964C35.3904 7.40445 35.4331 8.03302 35.5185 9.29016L35.7135 12.159C35.748 12.6674 35.7653 12.9217 35.8206 13.1645C35.9004 13.5154 36.0391 13.8503 36.2308 14.1549C36.3634 14.3657 36.531 14.5576 36.8661 14.9416L38.7568 17.108C39.5853 18.0574 39.9996 18.532 40.2017 19.0484C40.4942 19.7955 40.4942 20.6255 40.2017 21.3727C39.9996 21.889 39.5853 22.3637 38.7568 23.313L36.8661 25.4795C36.531 25.8634 36.3634 26.0554 36.2308 26.2662C36.0391 26.5708 35.9004 26.9056 35.8206 27.2566C35.7653 27.4994 35.748 27.7536 35.7135 28.2621L35.5185 31.1309C35.4331 32.388 35.3904 33.0166 35.1682 33.5247C34.8467 34.2598 34.2598 34.8467 33.5247 35.1682C33.0166 35.3904 32.388 35.4331 31.1309 35.5185L28.2621 35.7135C27.7536 35.748 27.4994 35.7653 27.2566 35.8206C26.9056 35.9004 26.5708 36.0391 26.2662 36.2308C26.0554 36.3634 25.8634 36.531 25.4795 36.8661L23.313 38.7568C22.3637 39.5853 21.889 39.9996 21.3727 40.2017C20.6255 40.4942 19.7955 40.4942 19.0484 40.2017C18.532 39.9996 18.0574 39.5853 17.108 38.7568L14.9416 36.8661C14.5576 36.531 14.3657 36.3634 14.1549 36.2308C13.8503 36.0391 13.5154 35.9004 13.1645 35.8206C12.9217 35.7653 12.6674 35.748 12.159 35.7135L9.29016 35.5185C8.03302 35.4331 7.40445 35.3904 6.8964 35.1682C6.16126 34.8467 5.57438 34.2598 5.25288 33.5247C5.03069 33.0166 4.98797 32.388 4.90254 31.1309L4.70759 28.2621C4.67304 27.7536 4.65576 27.4994 4.60049 27.2566C4.52063 26.9056 4.38193 26.5708 4.19028 26.2662C4.05764 26.0554 3.89009 25.8634 3.555 25.4795L1.66428 23.313C0.83576 22.3637 0.421499 21.889 0.219363 21.3727C-0.073121 20.6255 -0.0731209 19.7955 0.219363 19.0484C0.421499 18.532 0.83576 18.0574 1.66428 17.108L3.555 14.9416C3.89009 14.5576 4.05764 14.3657 4.19027 14.1549C4.38193 13.8503 4.52063 13.5154 4.60049 13.1645C4.65576 12.9217 4.67304 12.6674 4.70759 12.159L4.90254 9.29016C4.98797 8.03302 5.03069 7.40445 5.25288 6.8964C5.57438 6.16126 6.16126 5.57438 6.8964 5.25288C7.40445 5.03069 8.03302 4.98797 9.29016 4.90254L12.159 4.70759C12.6674 4.67304 12.9217 4.65577 13.1645 4.6005C13.5154 4.52063 13.8503 4.38193 14.1549 4.19028C14.3657 4.05764 14.5576 3.89009 14.9416 3.555L17.108 1.66428C18.0574 0.83576 18.532 0.421499 19.0484 0.219363C19.7955 -0.073121 20.6255 -0.073121 21.3727 0.219363C21.889 0.421499 22.3637 0.83576 23.313 1.66428L25.4795 3.555C25.8634 3.89009 26.0554 4.05764 26.2662 4.19028C26.5708 4.38193 26.9056 4.52063 27.2566 4.6005C27.4994 4.65577 27.7536 4.67304 28.2621 4.70759L31.1309 4.90254Z"
430
411
  fill="#006E0F"
431
412
  />
432
413
  </svg>
@@ -490,13 +471,6 @@ class EnquiryFormWidget {
490
471
  this.render();
491
472
  });
492
473
  }
493
- const contactMethodRadios = this.container.querySelectorAll('input[name="contact-method"]');
494
- contactMethodRadios.forEach((radio) => {
495
- radio.addEventListener("change", (e) => {
496
- const target = e.target;
497
- this.state.preferredContactMethod = target.value;
498
- });
499
- });
500
474
  const nextBtn = this.container.querySelector("#medos-enquiry-btn-next");
501
475
  if (nextBtn) {
502
476
  nextBtn.addEventListener("click", () => this.goToNext());
@@ -521,6 +495,14 @@ class EnquiryFormWidget {
521
495
  }
522
496
  destroy() {
523
497
  this.mounted = false;
498
+ if (this.countryCodeSelect) {
499
+ this.countryCodeSelect.destroy();
500
+ this.countryCodeSelect = null;
501
+ }
502
+ if (this.contactMethodSelect) {
503
+ this.contactMethodSelect.destroy();
504
+ this.contactMethodSelect = null;
505
+ }
524
506
  this.container.innerHTML = "";
525
507
  }
526
508
  }
@@ -21,6 +21,7 @@ declare class MedosClient {
21
21
  static fetchAppointments(workspaceId: number, addressId: number, doctorId: number, appointmentDate: string): Promise<any[]>;
22
22
  static sendPhoneVerificationOtp(payload: SendPhoneVerificationOtpPayload): Promise<any>;
23
23
  static verifyPhoneVerificationOtp(payload: VerifyPhoneVerificationOtpPayload): Promise<any>;
24
+ static fetchTheme(): Promise<string | undefined>;
24
25
  static get client(): AxiosInstance;
25
26
  static ensureInitialized(): Promise<AxiosInstance>;
26
27
  static isInitialized(): boolean;
@@ -22,6 +22,7 @@ interface AppointmentConfirmationStepProps {
22
22
  selectedDoctor?: Doctor | null;
23
23
  selectedAddress?: AddressItem | null;
24
24
  onClose: () => void;
25
+ onGoBackToSlots?: () => void;
25
26
  }
26
27
  declare const AppointmentConfirmationStep: React.FC<AppointmentConfirmationStepProps>;
27
28
  export default AppointmentConfirmationStep;
@@ -12,6 +12,7 @@ type AppointmentModalProps = {
12
12
  onCancel: () => void;
13
13
  onContinue: (mode: AppointmentMode, date: Date, slot: Slot, charge: string, paymentMode: PaymentMode) => void;
14
14
  onDateChange?: (date: Date) => void;
15
+ initialStep?: "consultation" | "datetime";
15
16
  };
16
17
  export declare const AppointmentDateTimeModal: React.FC<AppointmentModalProps>;
17
18
  export {};
@@ -0,0 +1,12 @@
1
+ import React from "react";
2
+ import { AppointmentState } from "./appointment-booking/types";
3
+ import { Doctor, AddressItem } from "../services/AppointmentService";
4
+ export interface AppointmentSummaryStepProps {
5
+ state: AppointmentState;
6
+ selectedDoctor: Doctor | null;
7
+ selectedAddress: AddressItem | null;
8
+ onBack: () => void;
9
+ onConfirm: () => void;
10
+ }
11
+ export declare const AppointmentSummaryStep: React.FC<AppointmentSummaryStepProps>;
12
+ export default AppointmentSummaryStep;
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ import { SessionPack, AvailablePackage } from "./appointment-booking/types";
3
+ export interface BookingOptionStepProps {
4
+ userSessionPacks: SessionPack[];
5
+ availablePackages: AvailablePackage[];
6
+ showPackageExplorer: boolean;
7
+ selectedSessionPack: SessionPack | null;
8
+ selectedNewPackage: AvailablePackage | null;
9
+ onSelectOption: (optionType: "session-pack" | "new-appointment" | "explore-packages", sessionPack?: SessionPack, newPackage?: AvailablePackage) => void;
10
+ onSelectPackage: (pkg: AvailablePackage) => void;
11
+ onBack: () => void;
12
+ }
13
+ export declare const BookingOptionStep: React.FC<BookingOptionStepProps>;
14
+ export default BookingOptionStep;
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ interface CloseIconProps {
3
+ size?: number;
4
+ color?: string;
5
+ className?: string;
6
+ style?: React.CSSProperties;
7
+ }
8
+ export declare const CloseIcon: React.FC<CloseIconProps>;
9
+ export default CloseIcon;
@@ -0,0 +1,12 @@
1
+ import React from "react";
2
+ import { Patient } from "./appointment-booking/types";
3
+ interface PatientSelectionStepProps {
4
+ verifiedPatients: Patient[];
5
+ selectedPatient: Patient | null;
6
+ onSelectPatient: (patient: Patient) => void;
7
+ onProceedAsNewPatient: () => void;
8
+ onBack: () => void;
9
+ isFirstStep?: boolean;
10
+ }
11
+ export declare const PatientSelectionStep: React.FC<PatientSelectionStepProps>;
12
+ export {};
@@ -8,6 +8,12 @@ function injectCalendarStyles() {
8
8
  const styleElement = document.createElement("style");
9
9
  styleElement.id = styleId;
10
10
  styleElement.innerHTML = `
11
+ .medos-calendar-wrapper {
12
+ overflow-x: auto;
13
+ overflow-y: visible;
14
+ -webkit-overflow-scrolling: touch;
15
+ }
16
+
11
17
  .medos-calendar {
12
18
  width: 340px;
13
19
  background-color: var(--medos-color-background, #ffffff);
@@ -19,6 +25,13 @@ function injectCalendarStyles() {
19
25
  box-sizing: border-box;
20
26
  }
21
27
 
28
+ @media (max-width: 767px) {
29
+ .medos-calendar {
30
+ width: 320px;
31
+ min-width: 320px;
32
+ }
33
+ }
34
+
22
35
  .medos-calendar-header {
23
36
  display: flex;
24
37
  justify-content: space-between;
@@ -226,26 +239,28 @@ export class VanillaCalendar {
226
239
  })
227
240
  .join("");
228
241
  this.container.innerHTML = `
229
- <div class="medos-calendar">
230
- <div class="medos-calendar-header">
231
- <button class="medos-calendar-nav" data-action="prev" type="button">
232
- ${VanillaIcons.chevronLeft(20)}
233
- </button>
234
- <p class="medos-calendar-month">
235
- ${VanillaCalendar.MONTHS[this.currentMonth]} ${this.currentYear}
236
- </p>
237
- <button class="medos-calendar-nav" data-action="next" type="button">
238
- ${VanillaIcons.chevronRight(20)}
239
- </button>
240
- </div>
242
+ <div class="medos-calendar-wrapper">
243
+ <div class="medos-calendar">
244
+ <div class="medos-calendar-header">
245
+ <button class="medos-calendar-nav" data-action="prev" type="button">
246
+ ${VanillaIcons.chevronLeft(20)}
247
+ </button>
248
+ <p class="medos-calendar-month">
249
+ ${VanillaCalendar.MONTHS[this.currentMonth]} ${this.currentYear}
250
+ </p>
251
+ <button class="medos-calendar-nav" data-action="next" type="button">
252
+ ${VanillaIcons.chevronRight(20)}
253
+ </button>
254
+ </div>
241
255
 
242
- <div class="medos-calendar-days-header">
243
- ${VanillaCalendar.DAYS_OF_WEEK.map((d) => `<div class="medos-calendar-day-name">${d}</div>`).join("")}
244
- </div>
256
+ <div class="medos-calendar-days-header">
257
+ ${VanillaCalendar.DAYS_OF_WEEK.map((d) => `<div class="medos-calendar-day-name">${d}</div>`).join("")}
258
+ </div>
245
259
 
246
- <div class="medos-calendar-grid">
247
- ${emptyCells}
248
- ${dayCells}
260
+ <div class="medos-calendar-grid">
261
+ ${emptyCells}
262
+ ${dayCells}
263
+ </div>
249
264
  </div>
250
265
  </div>
251
266
  `;
@@ -12,6 +12,11 @@ export declare const VanillaIcons: {
12
12
  phone: (size?: number) => string;
13
13
  mail: (size?: number) => string;
14
14
  clock: (size?: number) => string;
15
+ calendar: (size?: number) => string;
16
+ giftBox: (size?: number) => string;
17
+ arrowLeft: (size?: number) => string;
18
+ users: (size?: number) => string;
19
+ plus: (size?: number) => string;
15
20
  medosLogo: (width?: number, height?: number) => string;
16
21
  };
17
22
  export default VanillaIcons;
@@ -203,6 +203,98 @@ export const VanillaIcons = {
203
203
  <circle cx="12" cy="12" r="10"></circle>
204
204
  <polyline points="12 6 12 12 16 14"></polyline>
205
205
  </svg>
206
+ `,
207
+ calendar: (size = 20) => `
208
+ <svg
209
+ xmlns="http://www.w3.org/2000/svg"
210
+ width="${size}"
211
+ height="${size}"
212
+ viewBox="0 0 24 24"
213
+ fill="none"
214
+ stroke="currentColor"
215
+ stroke-width="2"
216
+ stroke-linecap="round"
217
+ stroke-linejoin="round"
218
+ class="medos-icon medos-icon-calendar"
219
+ >
220
+ <rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect>
221
+ <line x1="16" y1="2" x2="16" y2="6"></line>
222
+ <line x1="8" y1="2" x2="8" y2="6"></line>
223
+ <line x1="3" y1="10" x2="21" y2="10"></line>
224
+ </svg>
225
+ `,
226
+ giftBox: (size = 20) => `
227
+ <svg
228
+ xmlns="http://www.w3.org/2000/svg"
229
+ width="${size}"
230
+ height="${size}"
231
+ viewBox="0 0 24 24"
232
+ fill="none"
233
+ stroke="currentColor"
234
+ stroke-width="2"
235
+ stroke-linecap="round"
236
+ stroke-linejoin="round"
237
+ class="medos-icon medos-icon-gift"
238
+ >
239
+ <polyline points="20 12 20 22 4 22 4 12"></polyline>
240
+ <rect x="2" y="7" width="20" height="5"></rect>
241
+ <line x1="12" y1="22" x2="12" y2="7"></line>
242
+ <path d="M12 7H7.5a2.5 2.5 0 0 1 0-5C11 2 12 7 12 7z"></path>
243
+ <path d="M12 7h4.5a2.5 2.5 0 0 0 0-5C13 2 12 7 12 7z"></path>
244
+ </svg>
245
+ `,
246
+ arrowLeft: (size = 20) => `
247
+ <svg
248
+ xmlns="http://www.w3.org/2000/svg"
249
+ width="${size}"
250
+ height="${size}"
251
+ viewBox="0 0 24 24"
252
+ fill="none"
253
+ stroke="currentColor"
254
+ stroke-width="2"
255
+ stroke-linecap="round"
256
+ stroke-linejoin="round"
257
+ class="medos-icon medos-icon-arrow-left"
258
+ >
259
+ <line x1="19" y1="12" x2="5" y2="12"></line>
260
+ <polyline points="12 19 5 12 12 5"></polyline>
261
+ </svg>
262
+ `,
263
+ users: (size = 20) => `
264
+ <svg
265
+ xmlns="http://www.w3.org/2000/svg"
266
+ width="${size}"
267
+ height="${size}"
268
+ viewBox="0 0 24 24"
269
+ fill="none"
270
+ stroke="currentColor"
271
+ stroke-width="2"
272
+ stroke-linecap="round"
273
+ stroke-linejoin="round"
274
+ class="medos-icon medos-icon-users"
275
+ >
276
+ <path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path>
277
+ <circle cx="9" cy="7" r="4"></circle>
278
+ <path d="M23 21v-2a4 4 0 0 0-3-3.87"></path>
279
+ <path d="M16 3.13a4 4 0 0 1 0 7.75"></path>
280
+ </svg>
281
+ `,
282
+ plus: (size = 20) => `
283
+ <svg
284
+ xmlns="http://www.w3.org/2000/svg"
285
+ width="${size}"
286
+ height="${size}"
287
+ viewBox="0 0 24 24"
288
+ fill="none"
289
+ stroke="currentColor"
290
+ stroke-width="2"
291
+ stroke-linecap="round"
292
+ stroke-linejoin="round"
293
+ class="medos-icon medos-icon-plus"
294
+ >
295
+ <line x1="12" y1="5" x2="12" y2="19"></line>
296
+ <line x1="5" y1="12" x2="19" y2="12"></line>
297
+ </svg>
206
298
  `,
207
299
  medosLogo: (width = 120, height = 114) => `
208
300
  <svg
@@ -33,6 +33,8 @@ export declare class VanillaSelect {
33
33
  private attachPortalEvents;
34
34
  private detachPortalEvents;
35
35
  private focusNextItem;
36
+ private focusFirstItem;
37
+ private focusLastItem;
36
38
  private selectValue;
37
39
  setValue(value: string): void;
38
40
  getValue(): string;
@@ -42,5 +44,6 @@ export declare class VanillaSelect {
42
44
  destroy(): void;
43
45
  private escapeHtml;
44
46
  }
47
+ export declare function createContactMethodSelect(container: HTMLElement | string, currentValue?: "PHONE" | "EMAIL" | "BOTH", onValueChange?: (value: "PHONE" | "EMAIL" | "BOTH") => void): VanillaSelect;
45
48
  export declare function upgradeNativeSelect(selectElement: HTMLSelectElement, config?: VanillaSelectOptions): VanillaSelect;
46
49
  export default VanillaSelect;
@@ -36,10 +36,12 @@ function injectSelectStyles() {
36
36
  text-align: left;
37
37
  box-sizing: border-box;
38
38
  color: var(--medos-color-text, #111827);
39
+ min-height: 40px;
39
40
  }
40
41
 
41
42
  .medos-select-trigger:hover:not(:disabled) {
42
43
  border-color: var(--medos-color-border-hover, #d1d5db);
44
+ background-color: #f8fafc;
43
45
  }
44
46
 
45
47
  .medos-select-trigger:focus:not(:disabled) {
@@ -73,6 +75,8 @@ function injectSelectStyles() {
73
75
  overflow: hidden;
74
76
  text-overflow: ellipsis;
75
77
  white-space: nowrap;
78
+ display: flex;
79
+ align-items: center;
76
80
  }
77
81
 
78
82
  .medos-select-placeholder {
@@ -112,6 +116,7 @@ function injectSelectStyles() {
112
116
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
113
117
  animation: medos-select-show 0.15s ease-out;
114
118
  box-sizing: border-box;
119
+ min-width: 180px;
115
120
  }
116
121
 
117
122
  @keyframes medos-select-show {
@@ -147,6 +152,7 @@ function injectSelectStyles() {
147
152
  transition: background-color 0.1s ease;
148
153
  box-sizing: border-box;
149
154
  color: #1e293b;
155
+ min-height: 36px;
150
156
  }
151
157
 
152
158
  .medos-select-item:hover:not(.medos-select-item-disabled) {
@@ -159,6 +165,7 @@ function injectSelectStyles() {
159
165
 
160
166
  .medos-select-item-selected {
161
167
  background-color: #f3f4f6;
168
+ font-weight: 500;
162
169
  }
163
170
 
164
171
  .medos-select-item-disabled {
@@ -182,6 +189,8 @@ function injectSelectStyles() {
182
189
  /* Item Text */
183
190
  .medos-select-item-text {
184
191
  flex: 1;
192
+ display: flex;
193
+ align-items: center;
185
194
  }
186
195
 
187
196
  /* Scrollbar styling */
@@ -202,6 +211,24 @@ function injectSelectStyles() {
202
211
  .medos-select-viewport::-webkit-scrollbar-thumb:hover {
203
212
  background: #94a3b8;
204
213
  }
214
+
215
+ /* Label styling for forms */
216
+ .medos-form-label {
217
+ display: block;
218
+ font-size: 14px;
219
+ font-weight: 500;
220
+ margin-bottom: 6px;
221
+ color: #374151;
222
+ }
223
+
224
+ .medos-form-group {
225
+ margin-bottom: 16px;
226
+ }
227
+
228
+ /* Contact method specific styling */
229
+ .medos-contact-method-container {
230
+ margin-top: 8px;
231
+ }
205
232
  `;
206
233
  document.head.appendChild(styleElement);
207
234
  }
@@ -245,6 +272,7 @@ export class VanillaSelect {
245
272
  button.className = `medos-select-trigger ${this.config.error ? "medos-select-trigger-error" : ""}`;
246
273
  button.setAttribute("aria-expanded", this.isOpen.toString());
247
274
  button.setAttribute("aria-haspopup", "listbox");
275
+ button.setAttribute("aria-label", "Select option");
248
276
  if (this.config.disabled) {
249
277
  button.disabled = true;
250
278
  }
@@ -276,6 +304,10 @@ export class VanillaSelect {
276
304
  e.preventDefault();
277
305
  this.open();
278
306
  }
307
+ else if (e.key === "ArrowUp") {
308
+ e.preventDefault();
309
+ this.open();
310
+ }
279
311
  });
280
312
  }
281
313
  toggleOpen() {
@@ -323,9 +355,17 @@ export class VanillaSelect {
323
355
  this.contentElement = document.createElement("div");
324
356
  this.contentElement.className = "medos-select-content";
325
357
  this.contentElement.setAttribute("role", "listbox");
326
- this.contentElement.style.top = `${rect.bottom + scrollTop + 4}px`;
358
+ this.contentElement.setAttribute("aria-label", "Options");
359
+ const spaceBelow = window.innerHeight - rect.bottom;
360
+ const spaceAbove = rect.top;
361
+ const dropdownHeight = Math.min(256, this.options.length * 36 + 8);
362
+ let top = rect.bottom + scrollTop + 4;
363
+ if (spaceBelow < dropdownHeight && spaceAbove > dropdownHeight) {
364
+ top = rect.top + scrollTop - dropdownHeight - 4;
365
+ }
366
+ this.contentElement.style.top = `${top}px`;
327
367
  this.contentElement.style.left = `${rect.left + scrollLeft}px`;
328
- this.contentElement.style.width = `${rect.width}px`;
368
+ this.contentElement.style.width = `${Math.max(rect.width, 180)}px`;
329
369
  this.contentElement.innerHTML = `
330
370
  <div class="medos-select-viewport">
331
371
  ${this.options
@@ -340,6 +380,7 @@ export class VanillaSelect {
340
380
  data-label="${this.escapeHtml(option.label)}"
341
381
  ${option.disabled ? 'data-disabled="true"' : ""}
342
382
  tabindex="${option.disabled ? "-1" : "0"}"
383
+ aria-label="${this.escapeHtml(option.label)}"
343
384
  >
344
385
  ${this.selectedValue === option.value
345
386
  ? `
@@ -366,9 +407,16 @@ export class VanillaSelect {
366
407
  const rect = this.triggerElement.getBoundingClientRect();
367
408
  const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
368
409
  const scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
369
- this.contentElement.style.top = `${rect.bottom + scrollTop + 4}px`;
410
+ const spaceBelow = window.innerHeight - rect.bottom;
411
+ const spaceAbove = rect.top;
412
+ const dropdownHeight = Math.min(256, this.options.length * 36 + 8);
413
+ let top = rect.bottom + scrollTop + 4;
414
+ if (spaceBelow < dropdownHeight && spaceAbove > dropdownHeight) {
415
+ top = rect.top + scrollTop - dropdownHeight - 4;
416
+ }
417
+ this.contentElement.style.top = `${top}px`;
370
418
  this.contentElement.style.left = `${rect.left + scrollLeft}px`;
371
- this.contentElement.style.width = `${rect.width}px`;
419
+ this.contentElement.style.width = `${Math.max(rect.width, 180)}px`;
372
420
  }
373
421
  attachPortalEvents() {
374
422
  this.handleDocumentClick = (e) => {
@@ -419,6 +467,14 @@ export class VanillaSelect {
419
467
  this.selectValue(value, label);
420
468
  }
421
469
  }
470
+ else if (e.key === "Home") {
471
+ e.preventDefault();
472
+ this.focusFirstItem();
473
+ }
474
+ else if (e.key === "End") {
475
+ e.preventDefault();
476
+ this.focusLastItem();
477
+ }
422
478
  });
423
479
  }
424
480
  }
@@ -444,6 +500,11 @@ export class VanillaSelect {
444
500
  return;
445
501
  const currentFocused = document.activeElement;
446
502
  let currentIndex = items.indexOf(currentFocused);
503
+ if (currentIndex === -1) {
504
+ const targetIndex = direction > 0 ? 0 : items.length - 1;
505
+ items[targetIndex]?.focus();
506
+ return;
507
+ }
447
508
  let nextIndex = currentIndex + direction;
448
509
  if (nextIndex < 0)
449
510
  nextIndex = items.length - 1;
@@ -451,6 +512,19 @@ export class VanillaSelect {
451
512
  nextIndex = 0;
452
513
  items[nextIndex]?.focus();
453
514
  }
515
+ focusFirstItem() {
516
+ if (!this.contentElement)
517
+ return;
518
+ const firstItem = this.contentElement.querySelector(".medos-select-item:not(.medos-select-item-disabled)");
519
+ firstItem?.focus();
520
+ }
521
+ focusLastItem() {
522
+ if (!this.contentElement)
523
+ return;
524
+ const items = this.contentElement.querySelectorAll(".medos-select-item:not(.medos-select-item-disabled)");
525
+ const lastItem = items[items.length - 1];
526
+ lastItem?.focus();
527
+ }
454
528
  selectValue(value, label) {
455
529
  this.selectedValue = value;
456
530
  this.selectedLabel = label;
@@ -480,7 +554,6 @@ export class VanillaSelect {
480
554
  setDisabled(disabled) {
481
555
  this.config.disabled = disabled;
482
556
  this.renderTrigger();
483
- this.attachTriggerEvents();
484
557
  }
485
558
  setError(error) {
486
559
  this.config.error = error;
@@ -496,6 +569,21 @@ export class VanillaSelect {
496
569
  return div.innerHTML;
497
570
  }
498
571
  }
572
+ export function createContactMethodSelect(container, currentValue = "PHONE", onValueChange) {
573
+ const contactOptions = [
574
+ { value: "PHONE", label: "Phone" },
575
+ { value: "EMAIL", label: "Email" },
576
+ { value: "BOTH", label: "Both" },
577
+ ];
578
+ const select = new VanillaSelect(container, contactOptions, {
579
+ placeholder: "Select contact method",
580
+ onValueChange: (value) => {
581
+ onValueChange?.(value);
582
+ },
583
+ });
584
+ select.setValue(currentValue);
585
+ return select;
586
+ }
499
587
  export function upgradeNativeSelect(selectElement, config = {}) {
500
588
  const options = Array.from(selectElement.options).map((opt) => ({
501
589
  value: opt.value,