medos-sdk 1.1.7 → 1.1.8
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.
- package/dist/components/SuccessStep.js +1 -1
- package/dist/vanilla/AppointmentCalendarWidget.d.ts +8 -0
- package/dist/vanilla/AppointmentCalendarWidget.js +463 -158
- package/dist/vanilla/EnquiryFormWidget.d.ts +2 -0
- package/dist/vanilla/EnquiryFormWidget.js +155 -100
- package/dist/vanilla/components/VanillaCalendar.d.ts +32 -0
- package/dist/vanilla/components/VanillaCalendar.js +366 -0
- package/dist/vanilla/components/VanillaIcons.d.ts +17 -0
- package/dist/vanilla/components/VanillaIcons.js +268 -0
- package/dist/vanilla/components/VanillaSelect.d.ts +46 -0
- package/dist/vanilla/components/VanillaSelect.js +523 -0
- package/dist/vanilla/components/index.d.ts +3 -0
- package/dist/vanilla/components/index.js +3 -0
- package/dist/vanilla/components/theme-injector.d.ts +1 -0
- package/dist/vanilla/components/theme-injector.js +447 -0
- package/dist/vanilla/enquiry-widget.js +1366 -100
- package/dist/vanilla/vanilla/AppointmentCalendarWidget.d.ts +8 -0
- package/dist/vanilla/vanilla/EnquiryFormWidget.d.ts +2 -0
- package/dist/vanilla/vanilla/components/VanillaCalendar.d.ts +32 -0
- package/dist/vanilla/vanilla/components/VanillaIcons.d.ts +17 -0
- package/dist/vanilla/vanilla/components/VanillaSelect.d.ts +46 -0
- package/dist/vanilla/vanilla/components/index.d.ts +3 -0
- package/dist/vanilla/vanilla/components/theme-injector.d.ts +1 -0
- package/dist/vanilla/vanilla/widget.d.ts +2 -0
- package/dist/vanilla/widget.d.ts +2 -0
- package/dist/vanilla/widget.js +2213 -257
- package/package.json +1 -1
|
@@ -12,6 +12,7 @@ declare class EnquiryFormWidget {
|
|
|
12
12
|
private options;
|
|
13
13
|
private mounted;
|
|
14
14
|
private state;
|
|
15
|
+
private countryCodeSelect;
|
|
15
16
|
constructor(container: HTMLElement | string, options: EnquiryFormWidgetOptions);
|
|
16
17
|
private init;
|
|
17
18
|
private validateContactStep;
|
|
@@ -22,6 +23,7 @@ declare class EnquiryFormWidget {
|
|
|
22
23
|
private resetForm;
|
|
23
24
|
private setState;
|
|
24
25
|
private render;
|
|
26
|
+
private initializeCustomComponents;
|
|
25
27
|
private renderStep;
|
|
26
28
|
private renderStep0;
|
|
27
29
|
private renderStep1;
|
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
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
|
+
import { VanillaIcons } from "./components/VanillaIcons";
|
|
5
|
+
import { VanillaSelect } from "./components/VanillaSelect";
|
|
6
|
+
import { injectThemedStyles } from "./components/theme-injector";
|
|
7
|
+
const COUNTRY_CODES_ENQUIRY = [
|
|
8
|
+
{ value: "+91", label: "🇮🇳 +91" },
|
|
9
|
+
{ value: "+1", label: "🇺🇸 +1" },
|
|
10
|
+
{ value: "+44", label: "🇬🇧 +44" },
|
|
11
|
+
{ value: "+86", label: "🇨🇳 +86" },
|
|
12
|
+
{ value: "+81", label: "🇯🇵 +81" },
|
|
13
|
+
];
|
|
4
14
|
class EnquiryFormWidget {
|
|
5
15
|
constructor(container, options) {
|
|
6
16
|
this.mounted = true;
|
|
17
|
+
this.countryCodeSelect = null;
|
|
18
|
+
injectThemedStyles();
|
|
7
19
|
if (typeof container === "string") {
|
|
8
20
|
const el = document.getElementById(container);
|
|
9
21
|
if (!el) {
|
|
@@ -185,6 +197,23 @@ class EnquiryFormWidget {
|
|
|
185
197
|
</div>
|
|
186
198
|
`;
|
|
187
199
|
this.attachEventListeners();
|
|
200
|
+
this.initializeCustomComponents();
|
|
201
|
+
}
|
|
202
|
+
initializeCustomComponents() {
|
|
203
|
+
if (this.state.step === 0) {
|
|
204
|
+
const countryCodeContainer = this.container.querySelector("#medos-enquiry-country-code-container");
|
|
205
|
+
if (countryCodeContainer) {
|
|
206
|
+
this.countryCodeSelect = new VanillaSelect(countryCodeContainer, COUNTRY_CODES_ENQUIRY, {
|
|
207
|
+
placeholder: "Country",
|
|
208
|
+
onValueChange: (value) => {
|
|
209
|
+
this.state.countryCode = value;
|
|
210
|
+
},
|
|
211
|
+
});
|
|
212
|
+
if (this.state.countryCode) {
|
|
213
|
+
this.countryCodeSelect.setValue(this.state.countryCode);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
188
217
|
}
|
|
189
218
|
renderStep() {
|
|
190
219
|
switch (this.state.step) {
|
|
@@ -202,121 +231,147 @@ class EnquiryFormWidget {
|
|
|
202
231
|
}
|
|
203
232
|
renderStep0() {
|
|
204
233
|
return `
|
|
205
|
-
<div class="medos-
|
|
206
|
-
<
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
234
|
+
<div class="medos-section-card">
|
|
235
|
+
<div class="medos-section-header">
|
|
236
|
+
${VanillaIcons.user(14)}
|
|
237
|
+
<span class="medos-section-title">Contact Information</span>
|
|
238
|
+
</div>
|
|
239
|
+
<div class="medos-section-body">
|
|
240
|
+
<div class="medos-form-group">
|
|
241
|
+
<label class="medos-label">Full Name <span class="medos-required">*</span></label>
|
|
242
|
+
<input
|
|
243
|
+
type="text"
|
|
244
|
+
class="medos-input"
|
|
245
|
+
id="medos-enquiry-name"
|
|
246
|
+
placeholder="Enter your full name"
|
|
247
|
+
value="${this.escapeHtml(this.state.patientName)}"
|
|
248
|
+
/>
|
|
249
|
+
</div>
|
|
250
|
+
|
|
251
|
+
<div class="medos-form-group">
|
|
252
|
+
<label class="medos-label">Email Address <span class="medos-required">*</span></label>
|
|
253
|
+
<input
|
|
254
|
+
type="email"
|
|
255
|
+
class="medos-input"
|
|
256
|
+
id="medos-enquiry-email"
|
|
257
|
+
placeholder="your.email@example.com"
|
|
258
|
+
value="${this.escapeHtml(this.state.patientEmail)}"
|
|
259
|
+
/>
|
|
260
|
+
</div>
|
|
261
|
+
|
|
262
|
+
<div class="medos-form-group">
|
|
263
|
+
<label class="medos-label">Phone Number <span class="medos-required">*</span></label>
|
|
264
|
+
<div class="medos-phone-input-row">
|
|
265
|
+
<div class="medos-country-code-wrapper">
|
|
266
|
+
<div id="medos-enquiry-country-code-container"></div>
|
|
267
|
+
</div>
|
|
268
|
+
<div class="medos-phone-wrapper">
|
|
269
|
+
<input
|
|
270
|
+
type="tel"
|
|
271
|
+
class="medos-input"
|
|
272
|
+
id="medos-enquiry-phone"
|
|
273
|
+
placeholder="Enter phone number"
|
|
274
|
+
value="${this.escapeHtml(this.state.patientPhone)}"
|
|
275
|
+
maxlength="15"
|
|
276
|
+
/>
|
|
277
|
+
</div>
|
|
278
|
+
</div>
|
|
279
|
+
</div>
|
|
246
280
|
</div>
|
|
247
281
|
</div>
|
|
282
|
+
|
|
283
|
+
<div class="medos-actions">
|
|
284
|
+
<button class="medos-btn medos-btn-secondary" id="medos-enquiry-btn-cancel">Cancel</button>
|
|
285
|
+
<button class="medos-btn medos-btn-primary" id="medos-enquiry-btn-next">Next</button>
|
|
286
|
+
</div>
|
|
248
287
|
`;
|
|
249
288
|
}
|
|
250
289
|
renderStep1() {
|
|
251
290
|
return `
|
|
252
|
-
<div class="medos-
|
|
253
|
-
<
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
291
|
+
<div class="medos-section-card">
|
|
292
|
+
<div class="medos-section-header">
|
|
293
|
+
${VanillaIcons.mail(14)}
|
|
294
|
+
<span class="medos-section-title">Inquiry Details</span>
|
|
295
|
+
</div>
|
|
296
|
+
<div class="medos-section-body">
|
|
297
|
+
<div class="medos-form-group">
|
|
298
|
+
<label class="medos-label">Subject <span class="medos-required">*</span></label>
|
|
299
|
+
<input
|
|
300
|
+
type="text"
|
|
301
|
+
class="medos-input"
|
|
302
|
+
id="medos-enquiry-subject"
|
|
303
|
+
placeholder="What is your inquiry about?"
|
|
304
|
+
value="${this.escapeHtml(this.state.inquirySubject)}"
|
|
305
|
+
/>
|
|
306
|
+
</div>
|
|
307
|
+
|
|
308
|
+
<div class="medos-form-group">
|
|
309
|
+
<label class="medos-label">Message <span class="medos-required">*</span></label>
|
|
310
|
+
<textarea
|
|
311
|
+
class="medos-textarea"
|
|
312
|
+
id="medos-enquiry-message"
|
|
313
|
+
placeholder="Please describe your inquiry in detail (max 1000 characters)"
|
|
314
|
+
maxlength="1000"
|
|
315
|
+
>${this.escapeHtml(this.state.inquiryMessage)}</textarea>
|
|
316
|
+
<div class="medos-char-count">${this.state.inquiryMessage.length}/1000</div>
|
|
317
|
+
</div>
|
|
274
318
|
</div>
|
|
275
319
|
</div>
|
|
320
|
+
|
|
321
|
+
<div class="medos-actions">
|
|
322
|
+
<button class="medos-btn medos-btn-secondary" id="medos-enquiry-btn-back">Back</button>
|
|
323
|
+
<button class="medos-btn medos-btn-primary" id="medos-enquiry-btn-next">Next</button>
|
|
324
|
+
</div>
|
|
276
325
|
`;
|
|
277
326
|
}
|
|
278
327
|
renderStep2() {
|
|
279
328
|
return `
|
|
280
|
-
<div class="medos-
|
|
281
|
-
<
|
|
282
|
-
|
|
283
|
-
<
|
|
284
|
-
<input
|
|
285
|
-
type="radio"
|
|
286
|
-
name="contact-method"
|
|
287
|
-
value="PHONE"
|
|
288
|
-
${this.state.preferredContactMethod === "PHONE" ? "checked" : ""}
|
|
289
|
-
id="medos-enquiry-contact-phone"
|
|
290
|
-
/>
|
|
291
|
-
<span>Phone</span>
|
|
292
|
-
</label>
|
|
293
|
-
<label class="medos-enquiry-radio-label">
|
|
294
|
-
<input
|
|
295
|
-
type="radio"
|
|
296
|
-
name="contact-method"
|
|
297
|
-
value="EMAIL"
|
|
298
|
-
${this.state.preferredContactMethod === "EMAIL" ? "checked" : ""}
|
|
299
|
-
id="medos-enquiry-contact-email"
|
|
300
|
-
/>
|
|
301
|
-
<span>Email</span>
|
|
302
|
-
</label>
|
|
303
|
-
<label class="medos-enquiry-radio-label">
|
|
304
|
-
<input
|
|
305
|
-
type="radio"
|
|
306
|
-
name="contact-method"
|
|
307
|
-
value="BOTH"
|
|
308
|
-
${this.state.preferredContactMethod === "BOTH" ? "checked" : ""}
|
|
309
|
-
id="medos-enquiry-contact-both"
|
|
310
|
-
/>
|
|
311
|
-
<span>Both</span>
|
|
312
|
-
</label>
|
|
329
|
+
<div class="medos-section-card">
|
|
330
|
+
<div class="medos-section-header">
|
|
331
|
+
${VanillaIcons.phone(14)}
|
|
332
|
+
<span class="medos-section-title">Contact Preference</span>
|
|
313
333
|
</div>
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
<
|
|
317
|
-
|
|
334
|
+
<div class="medos-section-body">
|
|
335
|
+
<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>
|
|
367
|
+
</div>
|
|
318
368
|
</div>
|
|
319
369
|
</div>
|
|
370
|
+
|
|
371
|
+
<div class="medos-actions">
|
|
372
|
+
<button class="medos-btn medos-btn-secondary" id="medos-enquiry-btn-back">Back</button>
|
|
373
|
+
<button class="medos-btn medos-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>
|
|
374
|
+
</div>
|
|
320
375
|
`;
|
|
321
376
|
}
|
|
322
377
|
renderStep3() {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface VanillaCalendarOptions {
|
|
2
|
+
pastDisabled?: boolean;
|
|
3
|
+
onSelect?: (date: Date) => void;
|
|
4
|
+
selectedDate?: Date;
|
|
5
|
+
}
|
|
6
|
+
export declare class VanillaCalendar {
|
|
7
|
+
private container;
|
|
8
|
+
private config;
|
|
9
|
+
private currentMonth;
|
|
10
|
+
private currentYear;
|
|
11
|
+
private selectedDate;
|
|
12
|
+
private today;
|
|
13
|
+
private static readonly DAYS_OF_WEEK;
|
|
14
|
+
private static readonly MONTHS;
|
|
15
|
+
constructor(container: HTMLElement | string, config?: VanillaCalendarOptions);
|
|
16
|
+
private getDaysInMonth;
|
|
17
|
+
private getFirstDayOfMonth;
|
|
18
|
+
private isSameDate;
|
|
19
|
+
private isBeforeToday;
|
|
20
|
+
private render;
|
|
21
|
+
private attachEventListeners;
|
|
22
|
+
private prevMonth;
|
|
23
|
+
private nextMonth;
|
|
24
|
+
private selectDate;
|
|
25
|
+
setSelectedDate(date: Date | null): void;
|
|
26
|
+
getSelectedDate(): Date | null;
|
|
27
|
+
goToDate(date: Date): void;
|
|
28
|
+
goToToday(): void;
|
|
29
|
+
setPastDisabled(disabled: boolean): void;
|
|
30
|
+
destroy(): void;
|
|
31
|
+
}
|
|
32
|
+
export default VanillaCalendar;
|