medos-sdk 1.0.3 → 1.1.1

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 +80 -8
  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 +13 -2
@@ -1,7 +1,16 @@
1
1
  export { MedosClient } from "./client/MedosClient";
2
+ export * from "./core/theme";
3
+ export { MedosThemeProvider } from "./react/ThemeProvider";
4
+ export type { MedosThemeProviderProps } from "./react/ThemeProvider";
5
+ export { defaultTheme, modernTheme } from "./core/theme/themes";
6
+ export { useTheme, useThemeContext, useCssVar } from "./react/hooks/useTheme";
2
7
  export { AppointmentCalender } from "./components/AppointmentCalender";
8
+ export { EnquiryForm } from "./components/EnquiryForm";
9
+ export type { EnquiryFormProps } from "./components/EnquiryForm";
3
10
  export * from "./appointments/provider";
4
11
  export * from "./appointments/types";
5
12
  export * from "./appointment-calendar/provider";
6
13
  export * from "./appointment-calendar/types";
14
+ export * from "./enquiry-form/provider";
15
+ export * from "./enquiry-form/types";
7
16
  export { PatientService, SendPhoneVerificationOtpPayload, VerifyPhoneVerificationOtpPayload, } from "./services/PatientService";
@@ -1,2 +1,4 @@
1
1
  export * from "../core";
2
- export { AppointmentCalendarWidget, initAppointmentCalendar } from "./AppointmentCalendarWidget";
2
+ export * from "./theme-injector";
3
+ export { AppointmentCalendarWidget, initAppointmentCalendar, } from "./AppointmentCalendarWidget";
4
+ export { EnquiryFormWidget, initEnquiryForm } from "./EnquiryFormWidget";
@@ -0,0 +1,18 @@
1
+ import React from "react";
2
+ import { MedosTheme, PartialTheme } from "../core/theme/types";
3
+ import { ThemeName } from "../core/theme/themes";
4
+ interface ThemeContextValue {
5
+ theme: MedosTheme;
6
+ cssVars: Record<string, string>;
7
+ prefix: string;
8
+ }
9
+ export interface MedosThemeProviderProps {
10
+ children: React.ReactNode;
11
+ theme?: ThemeName | MedosTheme | PartialTheme;
12
+ cssVariablePrefix?: string;
13
+ }
14
+ export declare function MedosThemeProvider({ children, theme, cssVariablePrefix, }: MedosThemeProviderProps): import("react/jsx-runtime").JSX.Element;
15
+ export declare function useThemeContext(): ThemeContextValue;
16
+ export declare function useTheme(): MedosTheme;
17
+ export declare function useCssVar(category: string, key: string, fallback?: string): string;
18
+ export {};
@@ -0,0 +1 @@
1
+ export { useTheme, useThemeContext, useCssVar } from "../ThemeProvider";
@@ -1,2 +1,7 @@
1
1
  export * from "../core";
2
+ export { MedosThemeProvider } from "./ThemeProvider";
3
+ export type { MedosThemeProviderProps } from "./ThemeProvider";
4
+ export { useTheme, useThemeContext, useCssVar } from "./hooks/useTheme";
2
5
  export { AppointmentCalender } from "../components/AppointmentCalender";
6
+ export { EnquiryForm } from "../components/EnquiryForm";
7
+ export type { EnquiryFormProps } from "../components/EnquiryForm";
@@ -0,0 +1,5 @@
1
+ import { EnquirySubmission } from "../enquiry-form/types";
2
+ declare const EnquiryService: {
3
+ submitEnquiry(payload: EnquirySubmission): Promise<any>;
4
+ };
5
+ export { EnquiryService };
@@ -0,0 +1,6 @@
1
+ import { MedosTheme, PartialTheme } from "../core/theme/types";
2
+ import { ThemeName } from "../core/theme/themes";
3
+ export declare function resolveTheme(theme?: ThemeName | MedosTheme | PartialTheme): MedosTheme;
4
+ export declare function injectThemeIntoContainer(container: HTMLElement, theme?: ThemeName | MedosTheme | PartialTheme, prefix?: string): void;
5
+ export declare function createWidgetStyleTag(containerId: string, theme?: ThemeName | MedosTheme | PartialTheme, prefix?: string): HTMLStyleElement;
6
+ export declare function updateWidgetTheme(container: HTMLElement, theme: ThemeName | MedosTheme | PartialTheme, prefix?: string): void;
@@ -0,0 +1,44 @@
1
+ import { defaultTheme, themes } from "../core/theme/themes";
2
+ import { mergeTheme, generateCssVariablesObject } from "../core/theme/utils";
3
+ export function resolveTheme(theme) {
4
+ if (!theme) {
5
+ return defaultTheme;
6
+ }
7
+ if (typeof theme === "string") {
8
+ return themes[theme] || defaultTheme;
9
+ }
10
+ if ("name" in theme && "colors" in theme && "typography" in theme) {
11
+ return theme;
12
+ }
13
+ return mergeTheme(theme);
14
+ }
15
+ export function injectThemeIntoContainer(container, theme, prefix = "medos") {
16
+ const resolvedTheme = resolveTheme(theme);
17
+ const cssVars = generateCssVariablesObject(resolvedTheme, prefix);
18
+ Object.entries(cssVars).forEach(([key, value]) => {
19
+ container.style.setProperty(key, value);
20
+ });
21
+ }
22
+ export function createWidgetStyleTag(containerId, theme, prefix = "medos") {
23
+ const resolvedTheme = resolveTheme(theme);
24
+ const cssVars = generateCssVariablesObject(resolvedTheme, prefix);
25
+ const styleId = `${prefix}-widget-theme-${containerId}`;
26
+ const existingStyle = document.getElementById(styleId);
27
+ if (existingStyle) {
28
+ existingStyle.remove();
29
+ }
30
+ const styleElement = document.createElement("style");
31
+ styleElement.id = styleId;
32
+ const cssVarDeclarations = Object.entries(cssVars)
33
+ .map(([key, value]) => ` ${key}: ${value};`)
34
+ .join("\n");
35
+ styleElement.innerHTML = `
36
+ #${containerId} {
37
+ ${cssVarDeclarations}
38
+ }
39
+ `.trim();
40
+ return styleElement;
41
+ }
42
+ export function updateWidgetTheme(container, theme, prefix = "medos") {
43
+ injectThemeIntoContainer(container, theme, prefix);
44
+ }
@@ -0,0 +1,35 @@
1
+ import { EnquirySubmission } from "../enquiry-form/types";
2
+ interface EnquiryFormWidgetOptions {
3
+ containerId: string;
4
+ apiKey?: string;
5
+ sessionToken?: string;
6
+ baseURL?: string;
7
+ onError?: (err: Error) => void;
8
+ onSuccess?: (enquiry: EnquirySubmission) => void;
9
+ }
10
+ declare class EnquiryFormWidget {
11
+ private container;
12
+ private options;
13
+ private mounted;
14
+ private state;
15
+ constructor(container: HTMLElement | string, options: EnquiryFormWidgetOptions);
16
+ private init;
17
+ private validateContactStep;
18
+ private validateInquiryStep;
19
+ private goToNext;
20
+ private goBack;
21
+ private submitEnquiry;
22
+ private resetForm;
23
+ private setState;
24
+ private render;
25
+ private renderStep;
26
+ private renderStep0;
27
+ private renderStep1;
28
+ private renderStep2;
29
+ private renderStep3;
30
+ private attachEventListeners;
31
+ private escapeHtml;
32
+ destroy(): void;
33
+ }
34
+ export declare function initEnquiryForm(options: EnquiryFormWidgetOptions): EnquiryFormWidget;
35
+ export { EnquiryFormWidget };
@@ -1,2 +1,4 @@
1
1
  export * from "../core";
2
- export { AppointmentCalendarWidget, initAppointmentCalendar } from "./AppointmentCalendarWidget";
2
+ export * from "./theme-injector";
3
+ export { AppointmentCalendarWidget, initAppointmentCalendar, } from "./AppointmentCalendarWidget";
4
+ export { EnquiryFormWidget, initEnquiryForm } from "./EnquiryFormWidget";
@@ -0,0 +1,6 @@
1
+ import { MedosTheme, PartialTheme } from "../core/theme/types";
2
+ import { ThemeName } from "../core/theme/themes";
3
+ export declare function resolveTheme(theme?: ThemeName | MedosTheme | PartialTheme): MedosTheme;
4
+ export declare function injectThemeIntoContainer(container: HTMLElement, theme?: ThemeName | MedosTheme | PartialTheme, prefix?: string): void;
5
+ export declare function createWidgetStyleTag(containerId: string, theme?: ThemeName | MedosTheme | PartialTheme, prefix?: string): HTMLStyleElement;
6
+ export declare function updateWidgetTheme(container: HTMLElement, theme: ThemeName | MedosTheme | PartialTheme, prefix?: string): void;
@@ -1,10 +1,15 @@
1
1
  import { initAppointmentCalendar, AppointmentCalendarWidget } from "./AppointmentCalendarWidget";
2
+ import { initEnquiryForm, EnquiryFormWidget } from "./EnquiryFormWidget";
2
3
  declare global {
3
4
  interface Window {
4
5
  MedosAppointmentCalendar: {
5
6
  init: typeof initAppointmentCalendar;
6
7
  Widget: typeof AppointmentCalendarWidget;
7
8
  };
9
+ MedosEnquiryForm: {
10
+ init: typeof initEnquiryForm;
11
+ Widget: typeof EnquiryFormWidget;
12
+ };
8
13
  }
9
14
  }
10
- export { initAppointmentCalendar, AppointmentCalendarWidget };
15
+ export { initAppointmentCalendar, AppointmentCalendarWidget, initEnquiryForm, EnquiryFormWidget, };
@@ -215,3 +215,176 @@
215
215
  color: #6b7280;
216
216
  }
217
217
 
218
+ /* Medos Enquiry Form Widget Styles */
219
+
220
+ .medos-enquiry-container {
221
+ display: flex;
222
+ justify-content: center;
223
+ padding: 20px;
224
+ font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
225
+ background: #f6f8fa;
226
+ }
227
+
228
+ .medos-enquiry-card {
229
+ width: 100%;
230
+ max-width: 720px;
231
+ background: #fff;
232
+ border-radius: 12px;
233
+ box-shadow: 0 8px 24px rgba(16, 24, 40, 0.08);
234
+ padding: 24px;
235
+ box-sizing: border-box;
236
+ }
237
+
238
+ .medos-enquiry-header {
239
+ display: flex;
240
+ align-items: center;
241
+ justify-content: space-between;
242
+ margin-bottom: 16px;
243
+ }
244
+
245
+ .medos-enquiry-title {
246
+ margin: 0;
247
+ font-size: 20px;
248
+ font-weight: 600;
249
+ }
250
+
251
+ .medos-enquiry-step-indicator {
252
+ margin: 0;
253
+ font-size: 12px;
254
+ color: #6b7280;
255
+ font-weight: 500;
256
+ }
257
+
258
+ .medos-enquiry-section {
259
+ margin-top: 12px;
260
+ }
261
+
262
+ .medos-enquiry-label {
263
+ display: block;
264
+ font-size: 13px;
265
+ margin-bottom: 6px;
266
+ color: #374151;
267
+ font-weight: 500;
268
+ }
269
+
270
+ .medos-enquiry-input,
271
+ .medos-enquiry-textarea {
272
+ width: 100%;
273
+ padding: 10px 12px;
274
+ border-radius: 8px;
275
+ border: 1px solid #e6e9ef;
276
+ outline: none;
277
+ font-size: 14px;
278
+ box-sizing: border-box;
279
+ font-family: inherit;
280
+ }
281
+
282
+ .medos-enquiry-textarea {
283
+ min-height: 100px;
284
+ resize: vertical;
285
+ }
286
+
287
+ .medos-enquiry-char-count {
288
+ margin-top: 4px;
289
+ font-size: 12px;
290
+ color: #6b7280;
291
+ text-align: right;
292
+ }
293
+
294
+ .medos-enquiry-radio-group {
295
+ display: flex;
296
+ flex-direction: column;
297
+ gap: 12px;
298
+ margin-top: 12px;
299
+ }
300
+
301
+ .medos-enquiry-radio-label {
302
+ display: flex;
303
+ align-items: center;
304
+ gap: 8px;
305
+ cursor: pointer;
306
+ font-size: 14px;
307
+ }
308
+
309
+ .medos-enquiry-radio-label input[type="radio"] {
310
+ cursor: pointer;
311
+ width: 16px;
312
+ height: 16px;
313
+ }
314
+
315
+ .medos-enquiry-actions {
316
+ display: flex;
317
+ gap: 8px;
318
+ margin-top: 16px;
319
+ justify-content: flex-end;
320
+ }
321
+
322
+ .medos-enquiry-btn {
323
+ padding: 10px 14px;
324
+ border-radius: 8px;
325
+ cursor: pointer;
326
+ font-weight: 600;
327
+ font-size: 14px;
328
+ border: none;
329
+ font-family: inherit;
330
+ }
331
+
332
+ .medos-enquiry-btn-primary {
333
+ background: #0b79f7;
334
+ color: #fff;
335
+ }
336
+
337
+ .medos-enquiry-btn-primary:disabled {
338
+ opacity: 0.6;
339
+ cursor: not-allowed;
340
+ }
341
+
342
+ .medos-enquiry-btn-secondary {
343
+ background: #fff;
344
+ color: #0b254a;
345
+ border: 1px solid #e6e9ef;
346
+ }
347
+
348
+ .medos-enquiry-loading {
349
+ margin-bottom: 12px;
350
+ padding: 12px;
351
+ border-radius: 8px;
352
+ background: #fef3c7;
353
+ color: #92400e;
354
+ font-weight: 600;
355
+ text-align: center;
356
+ }
357
+
358
+ .medos-enquiry-error {
359
+ margin-bottom: 12px;
360
+ padding: 12px;
361
+ border-radius: 8px;
362
+ background: #fee2e2;
363
+ color: #991b1b;
364
+ font-weight: 600;
365
+ }
366
+
367
+ .medos-enquiry-success-card {
368
+ padding: 20px;
369
+ border-radius: 12px;
370
+ background: linear-gradient(90deg, #ecfdf5, #eff6ff);
371
+ text-align: center;
372
+ }
373
+
374
+ .medos-enquiry-success-icon {
375
+ font-size: 32px;
376
+ color: #10b981;
377
+ margin-bottom: 8px;
378
+ }
379
+
380
+ .medos-enquiry-success-title {
381
+ font-weight: 700;
382
+ font-size: 16px;
383
+ margin-bottom: 6px;
384
+ }
385
+
386
+ .medos-enquiry-success-message {
387
+ font-size: 14px;
388
+ color: #374151;
389
+ }
390
+
@@ -1,10 +1,15 @@
1
1
  import { initAppointmentCalendar, AppointmentCalendarWidget } from "./AppointmentCalendarWidget";
2
+ import { initEnquiryForm, EnquiryFormWidget } from "./EnquiryFormWidget";
2
3
  declare global {
3
4
  interface Window {
4
5
  MedosAppointmentCalendar: {
5
6
  init: typeof initAppointmentCalendar;
6
7
  Widget: typeof AppointmentCalendarWidget;
7
8
  };
9
+ MedosEnquiryForm: {
10
+ init: typeof initEnquiryForm;
11
+ Widget: typeof EnquiryFormWidget;
12
+ };
8
13
  }
9
14
  }
10
- export { initAppointmentCalendar, AppointmentCalendarWidget };
15
+ export { initAppointmentCalendar, AppointmentCalendarWidget, initEnquiryForm, EnquiryFormWidget, };