medos-sdk 1.0.3 → 1.1.0

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 (95) hide show
  1. package/README.md +39 -0
  2. package/dist/client/MedosClient.d.ts +2 -4
  3. package/dist/client/MedosClient.js +4 -4
  4. package/dist/components/AppointmentCalender.js +43 -2
  5. package/dist/components/AppointmentDateTimeModal.js +45 -31
  6. package/dist/components/ContactInformationStep.d.ts +13 -0
  7. package/dist/components/ContactInformationStep.js +14 -0
  8. package/dist/components/ContactPreferenceStep.d.ts +9 -0
  9. package/dist/components/ContactPreferenceStep.js +16 -0
  10. package/dist/components/DoctorSelectModal.js +30 -17
  11. package/dist/components/EnquiryForm.d.ts +7 -0
  12. package/dist/components/EnquiryForm.js +212 -0
  13. package/dist/components/Icons/ConsultationType.js +1 -1
  14. package/dist/components/Icons/Date&TimeIcon.js +1 -1
  15. package/dist/components/Icons/MapIcon.js +1 -1
  16. package/dist/components/Icons/PaymentMethodIcon.js +1 -1
  17. package/dist/components/Icons/UserIcon.js +1 -1
  18. package/dist/components/InquiryDetailsStep.d.ts +10 -0
  19. package/dist/components/InquiryDetailsStep.js +15 -0
  20. package/dist/components/PatientDetailsStep.js +9 -1
  21. package/dist/components/PhoneVerificationStep.js +22 -12
  22. package/dist/components/SuccessStep.d.ts +3 -1
  23. package/dist/components/SuccessStep.js +7 -15
  24. package/dist/components/custom-calendar.js +42 -24
  25. package/dist/components/theme-styles.d.ts +12 -0
  26. package/dist/components/theme-styles.js +319 -0
  27. package/dist/components/types.d.ts +0 -1
  28. package/dist/core/index.d.ts +4 -0
  29. package/dist/core/index.js +4 -0
  30. package/dist/core/theme/index.d.ts +3 -0
  31. package/dist/core/theme/index.js +3 -0
  32. package/dist/core/theme/themes.d.ts +8 -0
  33. package/dist/core/theme/themes.js +178 -0
  34. package/dist/core/theme/types.d.ts +106 -0
  35. package/dist/core/theme/types.js +1 -0
  36. package/dist/core/theme/utils.d.ts +8 -0
  37. package/dist/core/theme/utils.js +135 -0
  38. package/dist/enquiry-form/index.d.ts +4 -0
  39. package/dist/enquiry-form/index.js +4 -0
  40. package/dist/enquiry-form/provider.d.ts +3 -0
  41. package/dist/enquiry-form/provider.js +9 -0
  42. package/dist/enquiry-form/serialization.d.ts +4 -0
  43. package/dist/enquiry-form/serialization.js +57 -0
  44. package/dist/enquiry-form/types.d.ts +38 -0
  45. package/dist/enquiry-form/types.js +1 -0
  46. package/dist/enquiry-form/validation.d.ts +6 -0
  47. package/dist/enquiry-form/validation.js +21 -0
  48. package/dist/index.d.ts +9 -0
  49. package/dist/index.js +7 -0
  50. package/dist/react/ThemeProvider.d.ts +18 -0
  51. package/dist/react/ThemeProvider.js +45 -0
  52. package/dist/react/hooks/useTheme.d.ts +1 -0
  53. package/dist/react/hooks/useTheme.js +1 -0
  54. package/dist/react/index.d.ts +5 -0
  55. package/dist/react/index.js +3 -0
  56. package/dist/services/EnquiryService.d.ts +5 -0
  57. package/dist/services/EnquiryService.js +30 -0
  58. package/dist/vanilla/AppointmentCalendarWidget.js +0 -2
  59. package/dist/vanilla/EnquiryFormWidget.d.ts +35 -0
  60. package/dist/vanilla/EnquiryFormWidget.js +425 -0
  61. package/dist/vanilla/client/MedosClient.d.ts +2 -4
  62. package/dist/vanilla/components/ContactInformationStep.d.ts +13 -0
  63. package/dist/vanilla/components/ContactPreferenceStep.d.ts +9 -0
  64. package/dist/vanilla/components/EnquiryForm.d.ts +7 -0
  65. package/dist/vanilla/components/InquiryDetailsStep.d.ts +10 -0
  66. package/dist/vanilla/components/SuccessStep.d.ts +3 -1
  67. package/dist/vanilla/components/theme-styles.d.ts +12 -0
  68. package/dist/vanilla/components/types.d.ts +0 -1
  69. package/dist/vanilla/core/index.d.ts +4 -0
  70. package/dist/vanilla/core/theme/index.d.ts +3 -0
  71. package/dist/vanilla/core/theme/themes.d.ts +8 -0
  72. package/dist/vanilla/core/theme/types.d.ts +106 -0
  73. package/dist/vanilla/core/theme/utils.d.ts +8 -0
  74. package/dist/vanilla/enquiry-form/index.d.ts +4 -0
  75. package/dist/vanilla/enquiry-form/provider.d.ts +3 -0
  76. package/dist/vanilla/enquiry-form/serialization.d.ts +4 -0
  77. package/dist/vanilla/enquiry-form/types.d.ts +38 -0
  78. package/dist/vanilla/enquiry-form/validation.d.ts +6 -0
  79. package/dist/vanilla/enquiry-widget.js +4650 -0
  80. package/dist/vanilla/index.d.ts +9 -0
  81. package/dist/vanilla/index.js +3 -1
  82. package/dist/vanilla/react/ThemeProvider.d.ts +18 -0
  83. package/dist/vanilla/react/hooks/useTheme.d.ts +1 -0
  84. package/dist/vanilla/react/index.d.ts +5 -0
  85. package/dist/vanilla/services/EnquiryService.d.ts +5 -0
  86. package/dist/vanilla/theme-injector.d.ts +6 -0
  87. package/dist/vanilla/theme-injector.js +44 -0
  88. package/dist/vanilla/vanilla/EnquiryFormWidget.d.ts +35 -0
  89. package/dist/vanilla/vanilla/index.d.ts +3 -1
  90. package/dist/vanilla/vanilla/theme-injector.d.ts +6 -0
  91. package/dist/vanilla/vanilla/widget.d.ts +6 -1
  92. package/dist/vanilla/widget.css +173 -0
  93. package/dist/vanilla/widget.d.ts +6 -1
  94. package/dist/vanilla/widget.js +489 -12
  95. package/package.json +1 -1
@@ -3885,7 +3885,7 @@
3885
3885
  };
3886
3886
 
3887
3887
  class MedosClient {
3888
- static async init({ apiKey, baseURL = "https://api.medos.one", }) {
3888
+ static async init({ apiKey }) {
3889
3889
  if (!apiKey) {
3890
3890
  throw new Error("MedosClient.init() requires 'apiKey'");
3891
3891
  }
@@ -3895,7 +3895,7 @@
3895
3895
  this.initPromise = (async () => {
3896
3896
  try {
3897
3897
  const sessionToken = await AuthService.init(apiKey);
3898
- this.initializeAxiosInstance(sessionToken, baseURL);
3898
+ this.initializeAxiosInstance(sessionToken, "https://api.medos.one");
3899
3899
  }
3900
3900
  catch (e) {
3901
3901
  this.initPromise = null;
@@ -3904,7 +3904,7 @@
3904
3904
  })();
3905
3905
  return this.initPromise;
3906
3906
  }
3907
- static async initWithSession({ sessionToken, baseURL = "https://api-dev.medapi.in/v1", }) {
3907
+ static async initWithSession({ sessionToken }) {
3908
3908
  if (!sessionToken) {
3909
3909
  throw new Error("MedosClient.initWithSession() requires 'sessionToken'");
3910
3910
  }
@@ -3913,7 +3913,7 @@
3913
3913
  }
3914
3914
  this.initPromise = (async () => {
3915
3915
  try {
3916
- this.initializeAxiosInstance(sessionToken, baseURL);
3916
+ this.initializeAxiosInstance(sessionToken, "https://api.medos.one");
3917
3917
  }
3918
3918
  catch (e) {
3919
3919
  this.initPromise = null;
@@ -4205,11 +4205,11 @@
4205
4205
  otpVerifying: false,
4206
4206
  };
4207
4207
 
4208
- const validatePhoneNumber = (phone) => {
4208
+ const validatePhoneNumber$1 = (phone) => {
4209
4209
  const cleaned = phone.replace(/\D/g, "");
4210
4210
  return cleaned.length >= 7 && cleaned.length <= 15;
4211
4211
  };
4212
- const validateCountryCode = (code) => {
4212
+ const validateCountryCode$1 = (code) => {
4213
4213
  return /^\+[1-9]\d{0,3}$/.test(code);
4214
4214
  };
4215
4215
 
@@ -4251,13 +4251,11 @@
4251
4251
  if (this.options.apiKey) {
4252
4252
  await MedosClient.init({
4253
4253
  apiKey: this.options.apiKey,
4254
- baseURL: this.options.baseURL,
4255
4254
  });
4256
4255
  }
4257
4256
  else if (this.options.sessionToken) {
4258
4257
  await MedosClient.initWithSession({
4259
4258
  sessionToken: this.options.sessionToken,
4260
- baseURL: this.options.baseURL,
4261
4259
  });
4262
4260
  }
4263
4261
  else {
@@ -4428,7 +4426,7 @@
4428
4426
  this.setState({ error: "Please enter country code." });
4429
4427
  return;
4430
4428
  }
4431
- if (!validateCountryCode(this.state.countryCode)) {
4429
+ if (!validateCountryCode$1(this.state.countryCode)) {
4432
4430
  this.setState({
4433
4431
  error: "Please enter a valid country code (e.g., +91, +1).",
4434
4432
  });
@@ -4438,7 +4436,7 @@
4438
4436
  this.setState({ error: "Please enter phone number." });
4439
4437
  return;
4440
4438
  }
4441
- if (!validatePhoneNumber(this.state.patientPhone)) {
4439
+ if (!validatePhoneNumber$1(this.state.patientPhone)) {
4442
4440
  this.setState({
4443
4441
  error: "Please enter a valid phone number (7-15 digits).",
4444
4442
  });
@@ -4762,8 +4760,8 @@
4762
4760
  `;
4763
4761
  }
4764
4762
  renderStep3() {
4765
- const countryCodeValid = this.state.countryCode && validateCountryCode(this.state.countryCode);
4766
- const phoneValid = this.state.patientPhone && validatePhoneNumber(this.state.patientPhone);
4763
+ const countryCodeValid = this.state.countryCode && validateCountryCode$1(this.state.countryCode);
4764
+ const phoneValid = this.state.patientPhone && validatePhoneNumber$1(this.state.patientPhone);
4767
4765
  const canSendOtp = countryCodeValid && phoneValid && !this.state.otpSending;
4768
4766
  if (!this.state.otpSent) {
4769
4767
  return `
@@ -5071,14 +5069,493 @@
5071
5069
  return new AppointmentCalendarWidget(container, options);
5072
5070
  }
5073
5071
 
5072
+ const EnquiryService = {
5073
+ async submitEnquiry(payload) {
5074
+ try {
5075
+ const client = await MedosClient.ensureInitialized();
5076
+ const enquiryData = {
5077
+ patientName: payload.patientName,
5078
+ patientEmail: payload.patientEmail,
5079
+ countryCode: payload.countryCode,
5080
+ patientPhone: payload.patientPhone,
5081
+ inquirySubject: payload.inquirySubject,
5082
+ inquiryMessage: payload.inquiryMessage,
5083
+ preferredContactMethod: payload.preferredContactMethod,
5084
+ };
5085
+ const res = await client.post("/enquiries/submit", enquiryData, {
5086
+ headers: {
5087
+ "Content-Type": "application/json",
5088
+ },
5089
+ });
5090
+ return res.data;
5091
+ }
5092
+ catch (error) {
5093
+ if (error instanceof Error) {
5094
+ throw new Error(`Failed to submit enquiry: ${error.message}`);
5095
+ }
5096
+ throw new Error("Failed to submit enquiry: Unknown error");
5097
+ }
5098
+ },
5099
+ };
5100
+
5101
+ const validateName = (name) => {
5102
+ return name.trim().length > 0;
5103
+ };
5104
+ const validateEmail = (email) => {
5105
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
5106
+ return emailRegex.test(email);
5107
+ };
5108
+ const validatePhoneNumber = (phone) => {
5109
+ const cleaned = phone.replace(/\D/g, "");
5110
+ return cleaned.length >= 7 && cleaned.length <= 15;
5111
+ };
5112
+ const validateSubject = (subject) => {
5113
+ return subject.trim().length > 0;
5114
+ };
5115
+ const validateMessage = (message) => {
5116
+ const trimmed = message.trim();
5117
+ return trimmed.length > 0 && trimmed.length <= 1000;
5118
+ };
5119
+ const validateCountryCode = (code) => {
5120
+ return /^\+[1-9]\d{0,3}$/.test(code);
5121
+ };
5122
+
5123
+ class EnquiryFormWidget {
5124
+ constructor(container, options) {
5125
+ this.mounted = true;
5126
+ if (typeof container === "string") {
5127
+ const el = document.getElementById(container);
5128
+ if (!el) {
5129
+ throw new Error(`Container element with id "${container}" not found`);
5130
+ }
5131
+ this.container = el;
5132
+ }
5133
+ else {
5134
+ this.container = container;
5135
+ }
5136
+ this.options = options;
5137
+ this.state = {
5138
+ step: 0,
5139
+ loading: false,
5140
+ error: null,
5141
+ patientName: "",
5142
+ patientEmail: "",
5143
+ countryCode: "+91",
5144
+ patientPhone: "",
5145
+ inquirySubject: "",
5146
+ inquiryMessage: "",
5147
+ preferredContactMethod: "EMAIL",
5148
+ submitted: false,
5149
+ };
5150
+ this.init();
5151
+ }
5152
+ async init() {
5153
+ if (this.options.apiKey) {
5154
+ await MedosClient.init({
5155
+ apiKey: this.options.apiKey,
5156
+ });
5157
+ }
5158
+ else if (this.options.sessionToken) {
5159
+ await MedosClient.initWithSession({
5160
+ sessionToken: this.options.sessionToken,
5161
+ });
5162
+ }
5163
+ else {
5164
+ throw new Error("Either apiKey or sessionToken must be provided");
5165
+ }
5166
+ this.render();
5167
+ }
5168
+ validateContactStep() {
5169
+ this.setState({ error: null });
5170
+ if (!validateName(this.state.patientName)) {
5171
+ this.setState({ error: "Please enter a valid name." });
5172
+ return false;
5173
+ }
5174
+ if (!validateEmail(this.state.patientEmail)) {
5175
+ this.setState({ error: "Please enter a valid email address." });
5176
+ return false;
5177
+ }
5178
+ if (!validateCountryCode(this.state.countryCode)) {
5179
+ this.setState({
5180
+ error: "Please enter a valid country code (e.g., +91, +1).",
5181
+ });
5182
+ return false;
5183
+ }
5184
+ if (!validatePhoneNumber(this.state.patientPhone)) {
5185
+ this.setState({
5186
+ error: "Please enter a valid phone number (7-15 digits).",
5187
+ });
5188
+ return false;
5189
+ }
5190
+ return true;
5191
+ }
5192
+ validateInquiryStep() {
5193
+ this.setState({ error: null });
5194
+ if (!validateSubject(this.state.inquirySubject)) {
5195
+ this.setState({ error: "Please enter a valid subject." });
5196
+ return false;
5197
+ }
5198
+ if (!validateMessage(this.state.inquiryMessage)) {
5199
+ this.setState({
5200
+ error: "Please enter a valid message (max 1000 characters).",
5201
+ });
5202
+ return false;
5203
+ }
5204
+ return true;
5205
+ }
5206
+ goToNext() {
5207
+ if (this.state.step === 0) {
5208
+ if (!this.validateContactStep()) {
5209
+ this.render();
5210
+ return;
5211
+ }
5212
+ }
5213
+ else if (this.state.step === 1) {
5214
+ if (!this.validateInquiryStep()) {
5215
+ this.render();
5216
+ return;
5217
+ }
5218
+ }
5219
+ this.state.step = Math.min(3, this.state.step + 1);
5220
+ this.render();
5221
+ }
5222
+ goBack() {
5223
+ this.state.step = Math.max(0, this.state.step - 1);
5224
+ this.render();
5225
+ }
5226
+ async submitEnquiry() {
5227
+ this.setState({ error: null });
5228
+ if (!this.validateContactStep() || !this.validateInquiryStep()) {
5229
+ this.render();
5230
+ return;
5231
+ }
5232
+ this.setState({ loading: true });
5233
+ this.render();
5234
+ try {
5235
+ const payload = {
5236
+ patientName: this.state.patientName,
5237
+ patientEmail: this.state.patientEmail,
5238
+ countryCode: this.state.countryCode,
5239
+ patientPhone: this.state.patientPhone,
5240
+ inquirySubject: this.state.inquirySubject,
5241
+ inquiryMessage: this.state.inquiryMessage,
5242
+ preferredContactMethod: this.state.preferredContactMethod,
5243
+ };
5244
+ await EnquiryService.submitEnquiry(payload);
5245
+ this.state.step = 3;
5246
+ this.options.onSuccess?.(payload);
5247
+ }
5248
+ catch (e) {
5249
+ const msg = e.message || "Failed to submit enquiry";
5250
+ this.setState({ error: msg });
5251
+ this.options.onError?.(e);
5252
+ }
5253
+ finally {
5254
+ this.setState({ loading: false });
5255
+ this.render();
5256
+ }
5257
+ }
5258
+ resetForm() {
5259
+ this.state = {
5260
+ step: 0,
5261
+ loading: false,
5262
+ error: null,
5263
+ patientName: "",
5264
+ patientEmail: "",
5265
+ countryCode: "+91",
5266
+ patientPhone: "",
5267
+ inquirySubject: "",
5268
+ inquiryMessage: "",
5269
+ preferredContactMethod: "EMAIL",
5270
+ submitted: false,
5271
+ };
5272
+ this.render();
5273
+ }
5274
+ setState(updates) {
5275
+ this.state = { ...this.state, ...updates };
5276
+ }
5277
+ render() {
5278
+ if (!this.mounted)
5279
+ return;
5280
+ this.container.innerHTML = `
5281
+ <div class="medos-enquiry-container">
5282
+ <div class="medos-enquiry-card">
5283
+ <div class="medos-enquiry-header">
5284
+ <h2 class="medos-enquiry-title">Submit Inquiry</h2>
5285
+ <p class="medos-enquiry-step-indicator">Step ${this.state.step + 1} of 4</p>
5286
+ </div>
5287
+
5288
+ ${this.state.loading
5289
+ ? '<div class="medos-enquiry-loading">Loading...</div>'
5290
+ : ""}
5291
+ ${this.state.error
5292
+ ? `<div class="medos-enquiry-error">${this.escapeHtml(this.state.error)}</div>`
5293
+ : ""}
5294
+
5295
+ ${this.renderStep()}
5296
+ </div>
5297
+ </div>
5298
+ `;
5299
+ this.attachEventListeners();
5300
+ }
5301
+ renderStep() {
5302
+ switch (this.state.step) {
5303
+ case 0:
5304
+ return this.renderStep0();
5305
+ case 1:
5306
+ return this.renderStep1();
5307
+ case 2:
5308
+ return this.renderStep2();
5309
+ case 3:
5310
+ return this.renderStep3();
5311
+ default:
5312
+ return "";
5313
+ }
5314
+ }
5315
+ renderStep0() {
5316
+ return `
5317
+ <div class="medos-enquiry-section">
5318
+ <label class="medos-enquiry-label">Full Name *</label>
5319
+ <input
5320
+ type="text"
5321
+ class="medos-enquiry-input"
5322
+ id="medos-enquiry-name"
5323
+ placeholder="Enter your full name"
5324
+ value="${this.escapeHtml(this.state.patientName)}"
5325
+ />
5326
+
5327
+ <label class="medos-enquiry-label" style="margin-top: 12px">Email Address *</label>
5328
+ <input
5329
+ type="email"
5330
+ class="medos-enquiry-input"
5331
+ id="medos-enquiry-email"
5332
+ placeholder="your.email@example.com"
5333
+ value="${this.escapeHtml(this.state.patientEmail)}"
5334
+ />
5335
+
5336
+ <label class="medos-enquiry-label" style="margin-top: 12px">Country Code *</label>
5337
+ <input
5338
+ type="text"
5339
+ class="medos-enquiry-input"
5340
+ id="medos-enquiry-country-code"
5341
+ placeholder="+91"
5342
+ value="${this.escapeHtml(this.state.countryCode)}"
5343
+ />
5344
+
5345
+ <label class="medos-enquiry-label" style="margin-top: 12px">Phone Number *</label>
5346
+ <input
5347
+ type="tel"
5348
+ class="medos-enquiry-input"
5349
+ id="medos-enquiry-phone"
5350
+ placeholder="9876543210"
5351
+ value="${this.escapeHtml(this.state.patientPhone)}"
5352
+ maxlength="15"
5353
+ />
5354
+
5355
+ <div class="medos-enquiry-actions">
5356
+ <button class="medos-enquiry-btn medos-enquiry-btn-secondary" id="medos-enquiry-btn-cancel">Cancel</button>
5357
+ <button class="medos-enquiry-btn medos-enquiry-btn-primary" id="medos-enquiry-btn-next">Next</button>
5358
+ </div>
5359
+ </div>
5360
+ `;
5361
+ }
5362
+ renderStep1() {
5363
+ return `
5364
+ <div class="medos-enquiry-section">
5365
+ <label class="medos-enquiry-label">Subject *</label>
5366
+ <input
5367
+ type="text"
5368
+ class="medos-enquiry-input"
5369
+ id="medos-enquiry-subject"
5370
+ placeholder="What is your inquiry about?"
5371
+ value="${this.escapeHtml(this.state.inquirySubject)}"
5372
+ />
5373
+
5374
+ <label class="medos-enquiry-label" style="margin-top: 12px">Message *</label>
5375
+ <textarea
5376
+ class="medos-enquiry-textarea"
5377
+ id="medos-enquiry-message"
5378
+ placeholder="Please describe your inquiry in detail (max 1000 characters)"
5379
+ maxlength="1000"
5380
+ >${this.escapeHtml(this.state.inquiryMessage)}</textarea>
5381
+ <div class="medos-enquiry-char-count">${this.state.inquiryMessage.length}/1000</div>
5382
+
5383
+ <div class="medos-enquiry-actions">
5384
+ <button class="medos-enquiry-btn medos-enquiry-btn-secondary" id="medos-enquiry-btn-back">Back</button>
5385
+ <button class="medos-enquiry-btn medos-enquiry-btn-primary" id="medos-enquiry-btn-next">Next</button>
5386
+ </div>
5387
+ </div>
5388
+ `;
5389
+ }
5390
+ renderStep2() {
5391
+ return `
5392
+ <div class="medos-enquiry-section">
5393
+ <label class="medos-enquiry-label">Preferred Contact Method *</label>
5394
+ <div class="medos-enquiry-radio-group">
5395
+ <label class="medos-enquiry-radio-label">
5396
+ <input
5397
+ type="radio"
5398
+ name="contact-method"
5399
+ value="PHONE"
5400
+ ${this.state.preferredContactMethod === "PHONE" ? "checked" : ""}
5401
+ id="medos-enquiry-contact-phone"
5402
+ />
5403
+ <span>Phone</span>
5404
+ </label>
5405
+ <label class="medos-enquiry-radio-label">
5406
+ <input
5407
+ type="radio"
5408
+ name="contact-method"
5409
+ value="EMAIL"
5410
+ ${this.state.preferredContactMethod === "EMAIL" ? "checked" : ""}
5411
+ id="medos-enquiry-contact-email"
5412
+ />
5413
+ <span>Email</span>
5414
+ </label>
5415
+ <label class="medos-enquiry-radio-label">
5416
+ <input
5417
+ type="radio"
5418
+ name="contact-method"
5419
+ value="BOTH"
5420
+ ${this.state.preferredContactMethod === "BOTH" ? "checked" : ""}
5421
+ id="medos-enquiry-contact-both"
5422
+ />
5423
+ <span>Both</span>
5424
+ </label>
5425
+ </div>
5426
+
5427
+ <div class="medos-enquiry-actions">
5428
+ <button class="medos-enquiry-btn medos-enquiry-btn-secondary" id="medos-enquiry-btn-back">Back</button>
5429
+ <button class="medos-enquiry-btn medos-enquiry-btn-primary" id="medos-enquiry-btn-submit" ${this.state.loading ? "disabled" : ""} style="opacity: ${this.state.loading ? 0.6 : 1}">${this.state.loading ? "Submitting..." : "Submit Inquiry"}</button>
5430
+ </div>
5431
+ </div>
5432
+ `;
5433
+ }
5434
+ renderStep3() {
5435
+ return `
5436
+ <div class="medos-enquiry-section" style="text-align: center">
5437
+ <div class="medos-enquiry-success-card">
5438
+ <div class="medos-enquiry-success-icon">✓</div>
5439
+ <div class="medos-enquiry-success-title">Inquiry Submitted Successfully</div>
5440
+ <div class="medos-enquiry-success-message">Thank you, ${this.escapeHtml(this.state.patientName || "Patient")}. We have received your inquiry and will get back to you soon.</div>
5441
+ </div>
5442
+ <div style="margin-top: 14px; display: flex; justify-content: center">
5443
+ <button class="medos-enquiry-btn medos-enquiry-btn-primary" id="medos-enquiry-btn-submit-another" style="width: 160px">Submit Another</button>
5444
+ </div>
5445
+ </div>
5446
+ `;
5447
+ }
5448
+ attachEventListeners() {
5449
+ const nameInput = this.container.querySelector("#medos-enquiry-name");
5450
+ if (nameInput) {
5451
+ nameInput.addEventListener("input", (e) => {
5452
+ const target = e.target;
5453
+ this.state.patientName = target.value;
5454
+ });
5455
+ }
5456
+ const emailInput = this.container.querySelector("#medos-enquiry-email");
5457
+ if (emailInput) {
5458
+ emailInput.addEventListener("input", (e) => {
5459
+ const target = e.target;
5460
+ this.state.patientEmail = target.value;
5461
+ });
5462
+ }
5463
+ const countryCodeInput = this.container.querySelector("#medos-enquiry-country-code");
5464
+ if (countryCodeInput) {
5465
+ countryCodeInput.addEventListener("input", (e) => {
5466
+ const target = e.target;
5467
+ let value = target.value;
5468
+ if (value && !value.startsWith("+")) {
5469
+ value = "+" + value;
5470
+ }
5471
+ value = value.replace(/[^\d+]/g, "");
5472
+ this.state.countryCode = value;
5473
+ target.value = value;
5474
+ });
5475
+ }
5476
+ const phoneInput = this.container.querySelector("#medos-enquiry-phone");
5477
+ if (phoneInput) {
5478
+ phoneInput.addEventListener("input", (e) => {
5479
+ const target = e.target;
5480
+ this.state.patientPhone = target.value.replace(/\D/g, "");
5481
+ target.value = this.state.patientPhone;
5482
+ });
5483
+ }
5484
+ const subjectInput = this.container.querySelector("#medos-enquiry-subject");
5485
+ if (subjectInput) {
5486
+ subjectInput.addEventListener("input", (e) => {
5487
+ const target = e.target;
5488
+ this.state.inquirySubject = target.value;
5489
+ });
5490
+ }
5491
+ const messageInput = this.container.querySelector("#medos-enquiry-message");
5492
+ if (messageInput) {
5493
+ messageInput.addEventListener("input", (e) => {
5494
+ const target = e.target;
5495
+ this.state.inquiryMessage = target.value;
5496
+ this.render();
5497
+ });
5498
+ }
5499
+ const contactMethodRadios = this.container.querySelectorAll('input[name="contact-method"]');
5500
+ contactMethodRadios.forEach((radio) => {
5501
+ radio.addEventListener("change", (e) => {
5502
+ const target = e.target;
5503
+ this.state.preferredContactMethod = target.value;
5504
+ });
5505
+ });
5506
+ const nextBtn = this.container.querySelector("#medos-enquiry-btn-next");
5507
+ if (nextBtn) {
5508
+ nextBtn.addEventListener("click", () => this.goToNext());
5509
+ }
5510
+ const backBtn = this.container.querySelector("#medos-enquiry-btn-back");
5511
+ if (backBtn) {
5512
+ backBtn.addEventListener("click", () => this.goBack());
5513
+ }
5514
+ const submitBtn = this.container.querySelector("#medos-enquiry-btn-submit");
5515
+ if (submitBtn) {
5516
+ submitBtn.addEventListener("click", () => this.submitEnquiry());
5517
+ }
5518
+ const cancelBtn = this.container.querySelector("#medos-enquiry-btn-cancel");
5519
+ if (cancelBtn) {
5520
+ cancelBtn.addEventListener("click", () => this.resetForm());
5521
+ }
5522
+ const submitAnotherBtn = this.container.querySelector("#medos-enquiry-btn-submit-another");
5523
+ if (submitAnotherBtn) {
5524
+ submitAnotherBtn.addEventListener("click", () => this.resetForm());
5525
+ }
5526
+ }
5527
+ escapeHtml(text) {
5528
+ const div = document.createElement("div");
5529
+ div.textContent = text;
5530
+ return div.innerHTML;
5531
+ }
5532
+ destroy() {
5533
+ this.mounted = false;
5534
+ this.container.innerHTML = "";
5535
+ }
5536
+ }
5537
+ function initEnquiryForm(options) {
5538
+ const container = document.getElementById(options.containerId);
5539
+ if (!container) {
5540
+ throw new Error(`Container element with id "${options.containerId}" not found`);
5541
+ }
5542
+ return new EnquiryFormWidget(container, options);
5543
+ }
5544
+
5074
5545
  if (typeof window !== "undefined") {
5075
5546
  window.MedosAppointmentCalendar = {
5076
5547
  init: initAppointmentCalendar,
5077
5548
  Widget: AppointmentCalendarWidget,
5078
5549
  };
5550
+ window.MedosEnquiryForm = {
5551
+ init: initEnquiryForm,
5552
+ Widget: EnquiryFormWidget,
5553
+ };
5079
5554
  }
5080
5555
 
5081
5556
  exports.AppointmentCalendarWidget = AppointmentCalendarWidget;
5557
+ exports.EnquiryFormWidget = EnquiryFormWidget;
5082
5558
  exports.initAppointmentCalendar = initAppointmentCalendar;
5559
+ exports.initEnquiryForm = initEnquiryForm;
5083
5560
 
5084
5561
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "medos-sdk",
3
- "version": "1.0.3",
3
+ "version": "1.1.0",
4
4
  "description": "Medos SDK for managing appointments, meetings, and calendars in apps",
5
5
  "homepage": "https://github.com/MediLaunch/medos-sdk-react#readme",
6
6
  "bugs": {