@anker-in/ui 0.3.9 → 0.3.10

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/index.mjs CHANGED
@@ -10913,6 +10913,9 @@ var QuestionnaireForm2 = ({
10913
10913
  questions,
10914
10914
  onSubmit,
10915
10915
  onCancel,
10916
+ onFormStart,
10917
+ onFormFieldChange,
10918
+ onFormSubmit,
10916
10919
  pageData,
10917
10920
  selectedTimeslotId,
10918
10921
  loading = false,
@@ -11024,6 +11027,52 @@ var QuestionnaireForm2 = ({
11024
11027
  const getQuestionId = (question) => {
11025
11028
  return question.key || question.id || "";
11026
11029
  };
11030
+ const hasFormStartedRef = useRef(false);
11031
+ const emitFormStart = () => {
11032
+ if (hasFormStartedRef.current) return;
11033
+ hasFormStartedRef.current = true;
11034
+ onFormStart?.();
11035
+ };
11036
+ const lastReportedValuesRef = useRef({});
11037
+ const totalSteps = visibleQuestions.length + (pageData?.agrees?.length || 0);
11038
+ const stripHtml = (html) => html.replace(/<[^>]+>/g, "").trim();
11039
+ const resolveOptionLabel = (question, rawValue) => {
11040
+ const option = question?.options?.find(
11041
+ (opt) => (opt.value || opt.label) === rawValue
11042
+ );
11043
+ return option?.label || rawValue;
11044
+ };
11045
+ const getStepIndex = (questionId) => {
11046
+ const index = visibleQuestions.findIndex(
11047
+ (q) => getQuestionId(q) === questionId
11048
+ );
11049
+ return index >= 0 ? index + 1 : 0;
11050
+ };
11051
+ const emitFieldChange = (ctx) => {
11052
+ onFormFieldChange?.({
11053
+ stepIndex: getStepIndex(ctx.questionId),
11054
+ totalSteps,
11055
+ fieldId: ctx.questionId,
11056
+ fieldLabel: ctx.fieldLabel,
11057
+ fieldType: ctx.fieldType,
11058
+ value: ctx.value
11059
+ });
11060
+ };
11061
+ const emitBlurFieldChange = (question, rawValue) => {
11062
+ const questionId = getQuestionId(question);
11063
+ const trimmed = rawValue.trim();
11064
+ if (!trimmed || trimmed === lastReportedValuesRef.current[questionId]) {
11065
+ return false;
11066
+ }
11067
+ lastReportedValuesRef.current[questionId] = trimmed;
11068
+ emitFieldChange({
11069
+ questionId,
11070
+ fieldLabel: question.label,
11071
+ fieldType: question.type,
11072
+ value: trimmed
11073
+ });
11074
+ return true;
11075
+ };
11027
11076
  const handleChange = (questionId, value) => {
11028
11077
  setResponses((prev) => ({
11029
11078
  ...prev,
@@ -11057,6 +11106,13 @@ var QuestionnaireForm2 = ({
11057
11106
  ...prev,
11058
11107
  [questionId]: code
11059
11108
  }));
11109
+ const question = visibleQuestions.find(
11110
+ (q) => getQuestionId(q) === questionId
11111
+ );
11112
+ const phoneNumber = String(responses[questionId] || "").trim();
11113
+ if (question && phoneNumber) {
11114
+ emitBlurFieldChange(question, `${code} ${phoneNumber}`);
11115
+ }
11060
11116
  };
11061
11117
  const handleCheckboxChange = (questionId, optionValue, checked) => {
11062
11118
  const currentValues = responses[questionId] || [];
@@ -11064,6 +11120,7 @@ var QuestionnaireForm2 = ({
11064
11120
  handleChange(questionId, newValues);
11065
11121
  };
11066
11122
  const handleAgreementChange = (index, checked) => {
11123
+ emitFormStart();
11067
11124
  setAgreements((prev) => ({
11068
11125
  ...prev,
11069
11126
  [index]: checked
@@ -11071,6 +11128,15 @@ var QuestionnaireForm2 = ({
11071
11128
  if (checked && agreementError) {
11072
11129
  setAgreementError("");
11073
11130
  }
11131
+ const agreeContent = pageData?.agrees?.[index] || "";
11132
+ onFormFieldChange?.({
11133
+ stepIndex: visibleQuestions.length + index + 1,
11134
+ totalSteps,
11135
+ fieldId: `agreement-${index}`,
11136
+ fieldLabel: stripHtml(agreeContent),
11137
+ fieldType: "agreement",
11138
+ value: checked
11139
+ });
11074
11140
  };
11075
11141
  const handleOtherInputChange = (questionId, value) => {
11076
11142
  setOtherInputs((prev) => ({
@@ -11130,6 +11196,7 @@ var QuestionnaireForm2 = ({
11130
11196
  }
11131
11197
  }
11132
11198
  });
11199
+ onFormSubmit?.({ responses: finalResponses });
11133
11200
  onSubmit?.(finalResponses);
11134
11201
  } else {
11135
11202
  setTimeout(() => {
@@ -11156,6 +11223,7 @@ var QuestionnaireForm2 = ({
11156
11223
  type: question.type,
11157
11224
  value: responses[questionId] || "",
11158
11225
  onChange: (e) => handleChange(questionId, e.target.value),
11226
+ onBlur: () => emitBlurFieldChange(question, String(responses[questionId] || "")),
11159
11227
  placeholder: question.placeholder,
11160
11228
  className: cn(
11161
11229
  "w-full px-4 py-3 rounded-lg border text-base bg-white dark:bg-white dark:text-[#080A0F]",
@@ -11171,7 +11239,12 @@ var QuestionnaireForm2 = ({
11171
11239
  type: "email",
11172
11240
  value: responses[questionId] || "",
11173
11241
  onChange: (e) => handleChange(questionId, e.target.value),
11174
- onBlur: (e) => handleEmailBlur(questionId, e.target.value),
11242
+ onBlur: (e) => {
11243
+ handleEmailBlur(questionId, e.target.value);
11244
+ if (e.target.value.trim() && EMAIL_REGEX.test(e.target.value)) {
11245
+ emitBlurFieldChange(question, e.target.value);
11246
+ }
11247
+ },
11175
11248
  placeholder: question.placeholder,
11176
11249
  className: cn(
11177
11250
  "w-full px-4 py-3 rounded-lg border text-base bg-white dark:bg-white dark:text-[#080A0F]",
@@ -11226,6 +11299,13 @@ var QuestionnaireForm2 = ({
11226
11299
  type: "tel",
11227
11300
  value: responses[questionId] || "",
11228
11301
  onChange: (e) => handleChange(questionId, e.target.value),
11302
+ onBlur: () => {
11303
+ const code = phoneCountryCodes[questionId] || "+1";
11304
+ const phoneNumber = String(responses[questionId] || "").trim();
11305
+ if (phoneNumber) {
11306
+ emitBlurFieldChange(question, `${code} ${phoneNumber}`);
11307
+ }
11308
+ },
11229
11309
  placeholder: question.placeholder,
11230
11310
  className: cn(
11231
11311
  "flex-1 px-4 py-3 rounded-lg border text-base bg-white dark:bg-white dark:text-[#080A0F]",
@@ -11241,6 +11321,7 @@ var QuestionnaireForm2 = ({
11241
11321
  {
11242
11322
  value: responses[questionId] || "",
11243
11323
  onChange: (e) => handleChange(questionId, e.target.value),
11324
+ onBlur: () => emitBlurFieldChange(question, String(responses[questionId] || "")),
11244
11325
  placeholder: question.placeholder,
11245
11326
  rows: 4,
11246
11327
  className: cn(
@@ -11264,7 +11345,16 @@ var QuestionnaireForm2 = ({
11264
11345
  name: questionId,
11265
11346
  value: option.value || option.label,
11266
11347
  checked: responses[questionId] === (option.value || option.label),
11267
- onChange: (e) => handleChange(questionId, e.target.value),
11348
+ onChange: (e) => {
11349
+ emitFormStart();
11350
+ handleChange(questionId, e.target.value);
11351
+ emitFieldChange({
11352
+ questionId,
11353
+ fieldLabel: question.label,
11354
+ fieldType: "radio",
11355
+ value: resolveOptionLabel(question, e.target.value)
11356
+ });
11357
+ },
11268
11358
  className: "w-5 h-5 appearance-none cursor-pointer flex-shrink-0",
11269
11359
  style: {
11270
11360
  backgroundImage: responses[questionId] === (option.value || option.label) ? "url(https://cdn.shopify.com/s/files/1/0569/5147/2268/files/SelectBox.png?v=1769507941)" : "url(https://cdn.shopify.com/s/files/1/0569/5147/2268/files/Frame_2121235232_2.png?v=1769507995)",
@@ -11296,15 +11386,23 @@ var QuestionnaireForm2 = ({
11296
11386
  value: optionValue,
11297
11387
  checked: isOtherOption ? isOtherSelected : responses[questionId] === optionValue,
11298
11388
  onChange: (e) => {
11389
+ emitFormStart();
11299
11390
  if (isOtherOption) {
11300
11391
  handleChange(questionId, "__other__");
11301
11392
  setOtherInputs((prev) => ({
11302
11393
  ...prev,
11303
11394
  [questionId]: ""
11304
11395
  }));
11305
- } else {
11306
- handleChange(questionId, e.target.value);
11396
+ return;
11307
11397
  }
11398
+ handleChange(questionId, e.target.value);
11399
+ lastReportedValuesRef.current[questionId] = e.target.value;
11400
+ emitFieldChange({
11401
+ questionId,
11402
+ fieldLabel: question.label,
11403
+ fieldType: "radio_with_other",
11404
+ value: resolveOptionLabel(question, e.target.value)
11405
+ });
11308
11406
  },
11309
11407
  className: "w-5 h-5 appearance-none cursor-pointer flex-shrink-0",
11310
11408
  style: {
@@ -11323,6 +11421,10 @@ var QuestionnaireForm2 = ({
11323
11421
  type: "text",
11324
11422
  value: otherInputs[questionId] || "",
11325
11423
  onChange: (e) => handleOtherInputChange(questionId, e.target.value),
11424
+ onBlur: () => emitBlurFieldChange(
11425
+ question,
11426
+ String(otherInputs[questionId] || "")
11427
+ ),
11326
11428
  placeholder: question.placeholder || "Please specify...",
11327
11429
  className: cn(
11328
11430
  "w-full px-4 py-3 rounded-lg border text-base bg-white dark:bg-white dark:text-[#080A0F]",
@@ -11350,11 +11452,25 @@ var QuestionnaireForm2 = ({
11350
11452
  {
11351
11453
  type: "checkbox",
11352
11454
  checked: isChecked,
11353
- onChange: (e) => handleCheckboxChange(
11354
- questionId,
11355
- optionValue,
11356
- e.target.checked
11357
- ),
11455
+ onChange: (e) => {
11456
+ emitFormStart();
11457
+ handleCheckboxChange(
11458
+ questionId,
11459
+ optionValue,
11460
+ e.target.checked
11461
+ );
11462
+ const newChecked = e.target.checked ? [...responses[questionId] || [], optionValue] : (responses[questionId] || []).filter(
11463
+ (v) => v !== optionValue
11464
+ );
11465
+ emitFieldChange({
11466
+ questionId,
11467
+ fieldLabel: question.label,
11468
+ fieldType: "checkbox",
11469
+ value: newChecked.map(
11470
+ (v) => resolveOptionLabel(question, v)
11471
+ )
11472
+ });
11473
+ },
11358
11474
  className: "w-4 h-4 text-[#fff] rounded",
11359
11475
  style: {
11360
11476
  accentColor: "#080A0F"
@@ -11378,7 +11494,16 @@ var QuestionnaireForm2 = ({
11378
11494
  "select",
11379
11495
  {
11380
11496
  value: defaultValue,
11381
- onChange: (e) => handleChange(questionId, e.target.value),
11497
+ onChange: (e) => {
11498
+ emitFormStart();
11499
+ handleChange(questionId, e.target.value);
11500
+ emitFieldChange({
11501
+ questionId,
11502
+ fieldLabel: question.label,
11503
+ fieldType: "select",
11504
+ value: resolveOptionLabel(question, e.target.value)
11505
+ });
11506
+ },
11382
11507
  className: cn(
11383
11508
  "w-full px-4 py-3 rounded-lg border text-base bg-white dark:bg-white dark:text-[#080A0F]",
11384
11509
  "focus:outline-none focus:ring-2 focus:ring-[#3ADB67] focus:border-transparent",
@@ -11400,118 +11525,130 @@ var QuestionnaireForm2 = ({
11400
11525
  return null;
11401
11526
  }
11402
11527
  };
11403
- return /* @__PURE__ */ jsxs("div", { className: "pb-[80px] light", children: [
11404
- visibleQuestions && visibleQuestions.length > 0 && /* @__PURE__ */ jsx("div", { className: "bg-white rounded-[12px] p-8 dark:bg-white l:p-4", children: /* @__PURE__ */ jsx("form", { onSubmit: handleSubmit, className: cn("space-y-6", className), children: visibleQuestions.map((question) => {
11405
- const questionId = getQuestionId(question);
11406
- const hasError = !!errors[questionId];
11407
- return /* @__PURE__ */ jsxs(
11408
- "div",
11409
- {
11410
- className: "space-y-2",
11411
- "data-has-error": hasError ? "true" : "false",
11412
- children: [
11413
- /* @__PURE__ */ jsxs("label", { className: "block", children: [
11414
- /* @__PURE__ */ jsxs("span", { className: "text-base font-bold text-[#080A0F] dark:text-[#080A0F]", children: [
11415
- question.label,
11416
- question.required && /* @__PURE__ */ jsx("span", { className: "text-red-500 ml-1", children: "*" })
11417
- ] }),
11418
- question.description && /* @__PURE__ */ jsx("span", { className: "block text-sm text-gray-600 dark:text-gray-600 font-bold mt-1", children: question.description }),
11419
- question.type === "email" && questionId === "email" && pageData?.emailDescription && /* @__PURE__ */ jsx("span", { className: "block text-sm text-gray-600 dark:text-gray-600 font-bold mt-1", children: pageData.emailDescription })
11420
- ] }),
11421
- renderQuestion(question),
11422
- question.hint && !errors[questionId] && /* @__PURE__ */ jsx("p", { className: "text-sm text-gray-500 dark:text-gray-500 font-bold", children: question.hint }),
11423
- errors[questionId] && /* @__PURE__ */ jsx(
11424
- "p",
11528
+ return /* @__PURE__ */ jsxs(
11529
+ "div",
11530
+ {
11531
+ className: "pb-[80px] light",
11532
+ onFocusCapture: (e) => {
11533
+ const tag = e.target?.tagName;
11534
+ if (tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT") {
11535
+ emitFormStart();
11536
+ }
11537
+ },
11538
+ children: [
11539
+ visibleQuestions && visibleQuestions.length > 0 && /* @__PURE__ */ jsx("div", { className: "bg-white rounded-[12px] p-8 dark:bg-white l:p-4", children: /* @__PURE__ */ jsx("form", { onSubmit: handleSubmit, className: cn("space-y-6", className), children: visibleQuestions.map((question) => {
11540
+ const questionId = getQuestionId(question);
11541
+ const hasError = !!errors[questionId];
11542
+ return /* @__PURE__ */ jsxs(
11543
+ "div",
11544
+ {
11545
+ className: "space-y-2",
11546
+ "data-has-error": hasError ? "true" : "false",
11547
+ children: [
11548
+ /* @__PURE__ */ jsxs("label", { className: "block", children: [
11549
+ /* @__PURE__ */ jsxs("span", { className: "text-base font-bold text-[#080A0F] dark:text-[#080A0F]", children: [
11550
+ question.label,
11551
+ question.required && /* @__PURE__ */ jsx("span", { className: "text-red-500 ml-1", children: "*" })
11552
+ ] }),
11553
+ question.description && /* @__PURE__ */ jsx("span", { className: "block text-sm text-gray-600 dark:text-gray-600 font-bold mt-1", children: question.description }),
11554
+ question.type === "email" && questionId === "email" && pageData?.emailDescription && /* @__PURE__ */ jsx("span", { className: "block text-sm text-gray-600 dark:text-gray-600 font-bold mt-1", children: pageData.emailDescription })
11555
+ ] }),
11556
+ renderQuestion(question),
11557
+ question.hint && !errors[questionId] && /* @__PURE__ */ jsx("p", { className: "text-sm text-gray-500 dark:text-gray-500 font-bold", children: question.hint }),
11558
+ errors[questionId] && /* @__PURE__ */ jsx(
11559
+ "p",
11560
+ {
11561
+ className: "text-sm font-bold",
11562
+ style: { color: "#FF4D4D" },
11563
+ children: errors[questionId]
11564
+ }
11565
+ )
11566
+ ]
11567
+ },
11568
+ questionId
11569
+ );
11570
+ }) }) }),
11571
+ !!selectedTimeslotId && /* @__PURE__ */ jsxs("div", { className: "flex flex-col justify-center", children: [
11572
+ pageData?.agrees && pageData.agrees.length > 0 && /* @__PURE__ */ jsxs(
11573
+ "div",
11574
+ {
11575
+ className: "space-y-4 mt-8",
11576
+ "data-has-error": agreementError ? "true" : "false",
11577
+ children: [
11578
+ pageData.agrees.map((agreeContent, index) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
11579
+ /* @__PURE__ */ jsx(
11580
+ "input",
11581
+ {
11582
+ type: "checkbox",
11583
+ id: `agreement-${index}`,
11584
+ checked: agreements[index] || false,
11585
+ onChange: (e) => handleAgreementChange(index, e.target.checked),
11586
+ className: "w-4 h-4 border border-[#080A0F] rounded text-[#fff] cursor-pointer flex-shrink-0",
11587
+ style: {
11588
+ accentColor: "#080A0F"
11589
+ }
11590
+ }
11591
+ ),
11592
+ /* @__PURE__ */ jsx(
11593
+ "label",
11594
+ {
11595
+ htmlFor: `agreement-${index}`,
11596
+ className: "text-sm text-gray-700 dark:text-gray-700 font-bold cursor-pointer select-none flex-1 [&_a]:underline [&_a]:text-blue-600 [&_a:hover]:text-blue-700",
11597
+ dangerouslySetInnerHTML: { __html: agreeContent },
11598
+ "aria-label": `Agreement ${index + 1}`
11599
+ }
11600
+ )
11601
+ ] }, index)),
11602
+ agreementError && /* @__PURE__ */ jsx(
11603
+ "p",
11604
+ {
11605
+ className: "text-sm font-bold mt-2",
11606
+ style: { color: "#FF4D4D" },
11607
+ children: agreementError
11608
+ }
11609
+ )
11610
+ ]
11611
+ }
11612
+ ),
11613
+ /* @__PURE__ */ jsxs("div", { className: "flex gap-4", children: [
11614
+ /* @__PURE__ */ jsx(
11615
+ "button",
11425
11616
  {
11426
- className: "text-sm font-bold",
11427
- style: { color: "#FF4D4D" },
11428
- children: errors[questionId]
11617
+ type: "submit",
11618
+ disabled: loading,
11619
+ onClick: handleSubmit,
11620
+ className: cn(
11621
+ "w-fit mt-6 px-6 py-4 rounded-full",
11622
+ "bg-[#080A0F] text-white font-bold text-base",
11623
+ "hover:bg-[#2FC257] hover:text-[#080A0F] transition-colors",
11624
+ "focus:outline-none focus:ring-2 focus:ring-[#3ADB67] focus:ring-offset-2",
11625
+ "disabled:opacity-50 disabled:cursor-not-allowed"
11626
+ ),
11627
+ children: loading ? pageData?.submitting || "Submitting..." : pageData?.submit || "Submit Booking"
11429
11628
  }
11430
- )
11431
- ]
11432
- },
11433
- questionId
11434
- );
11435
- }) }) }),
11436
- !!selectedTimeslotId && /* @__PURE__ */ jsxs("div", { className: "flex flex-col justify-center", children: [
11437
- pageData?.agrees && pageData.agrees.length > 0 && /* @__PURE__ */ jsxs(
11438
- "div",
11439
- {
11440
- className: "space-y-4 mt-8",
11441
- "data-has-error": agreementError ? "true" : "false",
11442
- children: [
11443
- pageData.agrees.map((agreeContent, index) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
11444
- /* @__PURE__ */ jsx(
11445
- "input",
11446
- {
11447
- type: "checkbox",
11448
- id: `agreement-${index}`,
11449
- checked: agreements[index] || false,
11450
- onChange: (e) => handleAgreementChange(index, e.target.checked),
11451
- className: "w-4 h-4 border border-[#080A0F] rounded text-[#fff] cursor-pointer flex-shrink-0",
11452
- style: {
11453
- accentColor: "#080A0F"
11454
- }
11455
- }
11456
- ),
11457
- /* @__PURE__ */ jsx(
11458
- "label",
11459
- {
11460
- htmlFor: `agreement-${index}`,
11461
- className: "text-sm text-gray-700 dark:text-gray-700 font-bold cursor-pointer select-none flex-1 [&_a]:underline [&_a]:text-blue-600 [&_a:hover]:text-blue-700",
11462
- dangerouslySetInnerHTML: { __html: agreeContent },
11463
- "aria-label": `Agreement ${index + 1}`
11464
- }
11465
- )
11466
- ] }, index)),
11467
- agreementError && /* @__PURE__ */ jsx(
11468
- "p",
11629
+ ),
11630
+ pageData?.discardEdit && !!initialResponses && /* @__PURE__ */ jsx(
11631
+ "button",
11469
11632
  {
11470
- className: "text-sm font-bold mt-2",
11471
- style: { color: "#FF4D4D" },
11472
- children: agreementError
11633
+ type: "submit",
11634
+ onClick: () => {
11635
+ onCancel?.();
11636
+ },
11637
+ className: cn(
11638
+ "w-fit mt-6 px-6 py-4 rounded-full",
11639
+ "border-[#080A0F] border-2 text-[#080A0F] font-bold text-base",
11640
+ "transition-colors",
11641
+ "disabled:opacity-50 disabled:cursor-not-allowed"
11642
+ ),
11643
+ children: pageData?.discardEdit
11473
11644
  }
11474
11645
  )
11475
- ]
11476
- }
11477
- ),
11478
- /* @__PURE__ */ jsxs("div", { className: "flex gap-4", children: [
11479
- /* @__PURE__ */ jsx(
11480
- "button",
11481
- {
11482
- type: "submit",
11483
- disabled: loading,
11484
- onClick: handleSubmit,
11485
- className: cn(
11486
- "w-fit mt-6 px-6 py-4 rounded-full",
11487
- "bg-[#080A0F] text-white font-bold text-base",
11488
- "hover:bg-[#2FC257] hover:text-[#080A0F] transition-colors",
11489
- "focus:outline-none focus:ring-2 focus:ring-[#3ADB67] focus:ring-offset-2",
11490
- "disabled:opacity-50 disabled:cursor-not-allowed"
11491
- ),
11492
- children: loading ? pageData?.submitting || "Submitting..." : pageData?.submit || "Submit Booking"
11493
- }
11494
- ),
11495
- pageData?.discardEdit && !!initialResponses && /* @__PURE__ */ jsx(
11496
- "button",
11497
- {
11498
- type: "submit",
11499
- onClick: () => {
11500
- onCancel?.();
11501
- },
11502
- className: cn(
11503
- "w-fit mt-6 px-6 py-4 rounded-full",
11504
- "border-[#080A0F] border-2 text-[#080A0F] font-bold text-base",
11505
- "transition-colors",
11506
- "disabled:opacity-50 disabled:cursor-not-allowed"
11507
- ),
11508
- children: pageData?.discardEdit
11509
- }
11510
- )
11511
- ] }),
11512
- error && /* @__PURE__ */ jsx("div", { className: "text-center w-full p-4", children: /* @__PURE__ */ jsx("p", { className: "text-[#FF4D4D] font-bold", children: pageData?.errorMsg?.[String(error.code)] || pageData?.errorMsg?.[error.code || ""] || error.message }) })
11513
- ] })
11514
- ] });
11646
+ ] }),
11647
+ error && /* @__PURE__ */ jsx("div", { className: "text-center w-full p-4", children: /* @__PURE__ */ jsx("p", { className: "text-[#FF4D4D] font-bold", children: pageData?.errorMsg?.[String(error.code)] || pageData?.errorMsg?.[error.code || ""] || error.message }) })
11648
+ ] })
11649
+ ]
11650
+ }
11651
+ );
11515
11652
  };
11516
11653
  dayjs4.extend(dayLocaleData);
11517
11654
  dayjs4.extend(weekday);
@@ -11531,7 +11668,8 @@ var DateTimePicker2 = ({
11531
11668
  onBookingSuccess,
11532
11669
  onQuestionnaireSubmit,
11533
11670
  selectedPurposeType,
11534
- podDesignId
11671
+ podDesignId,
11672
+ trackCallbacks
11535
11673
  }) => {
11536
11674
  const { token: themeToken } = theme.useToken();
11537
11675
  const [selectedDate, setSelectedDate] = useState(
@@ -11920,9 +12058,14 @@ var DateTimePicker2 = ({
11920
12058
  {
11921
12059
  fullscreen: false,
11922
12060
  value: calendarValue,
11923
- onSelect: (date) => {
12061
+ onSelect: (date, info) => {
11924
12062
  setSelectedDate(date);
11925
12063
  setCalendarValue(date);
12064
+ if (info?.source === "date") {
12065
+ trackCallbacks?.onDateSelect?.({
12066
+ date: date.format("YYYY-MM-DD")
12067
+ });
12068
+ }
11926
12069
  },
11927
12070
  onPanelChange: (date) => {
11928
12071
  setCalendarValue(date);
@@ -12010,6 +12153,10 @@ var DateTimePicker2 = ({
12010
12153
  onClick: () => {
12011
12154
  const newDate = value.subtract(1, "month");
12012
12155
  onChange(newDate);
12156
+ trackCallbacks?.onMonthChange?.({
12157
+ direction: "left",
12158
+ month: newDate.format("YYYY-MM")
12159
+ });
12013
12160
  },
12014
12161
  className: "w-10 h-10 flex items-center justify-center hover:bg-gray-100 rounded-lg transition-colors",
12015
12162
  children: /* @__PURE__ */ jsx(
@@ -12040,6 +12187,10 @@ var DateTimePicker2 = ({
12040
12187
  onClick: () => {
12041
12188
  const newDate = value.add(1, "month");
12042
12189
  onChange(newDate);
12190
+ trackCallbacks?.onMonthChange?.({
12191
+ direction: "right",
12192
+ month: newDate.format("YYYY-MM")
12193
+ });
12043
12194
  },
12044
12195
  className: "w-10 h-10 flex items-center justify-center hover:bg-gray-100 rounded-lg transition-colors",
12045
12196
  children: /* @__PURE__ */ jsx(
@@ -12087,6 +12238,10 @@ var DateTimePicker2 = ({
12087
12238
  if (!newDate.isBefore(dayjs4(), "day")) {
12088
12239
  setSelectedDate(newDate);
12089
12240
  setCalendarValue(newDate);
12241
+ trackCallbacks?.onDateStepClick?.({
12242
+ direction: "left",
12243
+ date: newDate.format("YYYY-MM-DD")
12244
+ });
12090
12245
  }
12091
12246
  }
12092
12247
  },
@@ -12120,6 +12275,10 @@ var DateTimePicker2 = ({
12120
12275
  const newDate = selectedDate.add(1, "day");
12121
12276
  setSelectedDate(newDate);
12122
12277
  setCalendarValue(newDate);
12278
+ trackCallbacks?.onDateStepClick?.({
12279
+ direction: "right",
12280
+ date: newDate.format("YYYY-MM-DD")
12281
+ });
12123
12282
  }
12124
12283
  },
12125
12284
  disabled: !selectedDate,
@@ -12156,6 +12315,10 @@ var DateTimePicker2 = ({
12156
12315
  onClick: () => {
12157
12316
  if (isAvailable) {
12158
12317
  setSelectedTimeslotId(slot.id);
12318
+ trackCallbacks?.onTimeslotSelect?.({
12319
+ slotId: slot.id,
12320
+ label: formatTimeslot(slot)
12321
+ });
12159
12322
  }
12160
12323
  },
12161
12324
  className: `
@@ -12193,6 +12356,9 @@ var DateTimePicker2 = ({
12193
12356
  selectedTimeslotId,
12194
12357
  error: bookingError || editError,
12195
12358
  initialResponses,
12359
+ onFormStart: trackCallbacks?.onFormStart,
12360
+ onFormFieldChange: trackCallbacks?.onFormFieldChange,
12361
+ onFormSubmit: trackCallbacks?.onFormSubmit,
12196
12362
  onCancel: () => {
12197
12363
  onBookingSuccess?.(token || "");
12198
12364
  },
@@ -12275,6 +12441,8 @@ var DemoRoomDetail2 = ({
12275
12441
  openInGoogleMaps: "Open in Google Maps",
12276
12442
  demoRoomImages: "Demo Room Images"
12277
12443
  },
12444
+ onGoogleMapsClick,
12445
+ onImageSlideChange,
12278
12446
  className,
12279
12447
  ...props
12280
12448
  }) => {
@@ -12303,6 +12471,7 @@ var DemoRoomDetail2 = ({
12303
12471
  }
12304
12472
  return "#";
12305
12473
  })();
12474
+ const userSlideTriggerRef = useRef(null);
12306
12475
  const isLoading = isManagedByParent ? !!demoRoomLoading : loading && shouldFetch;
12307
12476
  if (isLoading) {
12308
12477
  return /* @__PURE__ */ jsx("div", { className: cn("w-full pb-4", className), ...props, children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-8 items-start", children: [
@@ -12416,6 +12585,12 @@ var DemoRoomDetail2 = ({
12416
12585
  href: googleMapsLink,
12417
12586
  target: "_blank",
12418
12587
  rel: "noopener noreferrer",
12588
+ onClick: () => {
12589
+ onGoogleMapsClick?.({
12590
+ demoRoomName: title,
12591
+ url: googleMapsLink
12592
+ });
12593
+ },
12419
12594
  className: "inline-flex items-center gap-1 text-sm text-blue-600 hover:text-blue-700 mt-1 underline",
12420
12595
  children: [
12421
12596
  pageData.openInGoogleMaps,
@@ -12445,8 +12620,27 @@ var DemoRoomDetail2 = ({
12445
12620
  ] })
12446
12621
  ] })
12447
12622
  ] }),
12448
- images.length > 0 && /* @__PURE__ */ jsxs("div", { className: "relative l:w-full min-l:h-[400px] rounded-2xl overflow-hidden demo-room-swiper", children: [
12449
- /* @__PURE__ */ jsx("style", { children: `
12623
+ images.length > 0 && /* @__PURE__ */ jsxs(
12624
+ "div",
12625
+ {
12626
+ className: "relative l:w-full min-l:h-[400px] rounded-2xl overflow-hidden demo-room-swiper",
12627
+ onClickCapture: (e) => {
12628
+ const target = e.target;
12629
+ const bullet = target.closest(".swiper-pagination-bullet");
12630
+ if (bullet && !bullet.classList.contains("swiper-pagination-bullet-active")) {
12631
+ userSlideTriggerRef.current = "pagination";
12632
+ return;
12633
+ }
12634
+ if (target.closest(".swiper-button-prev")) {
12635
+ userSlideTriggerRef.current = "prev";
12636
+ return;
12637
+ }
12638
+ if (target.closest(".swiper-button-next")) {
12639
+ userSlideTriggerRef.current = "next";
12640
+ }
12641
+ },
12642
+ children: [
12643
+ /* @__PURE__ */ jsx("style", { children: `
12450
12644
  .demo-room-swiper .swiper-pagination-bullet {
12451
12645
  background-color: rgba(255, 255, 255, 0.5);
12452
12646
  }
@@ -12476,31 +12670,53 @@ var DemoRoomDetail2 = ({
12476
12670
  right: 16px !important;
12477
12671
  }
12478
12672
  ` }),
12479
- /* @__PURE__ */ jsx(
12480
- Swiper2,
12481
- {
12482
- modules: [Navigation, Pagination, Autoplay],
12483
- spaceBetween: 0,
12484
- slidesPerView: 1,
12485
- navigation: images.length > 1,
12486
- pagination: images.length > 1 ? { clickable: true } : false,
12487
- autoplay: images.length > 1 ? {
12488
- delay: 3e3,
12489
- disableOnInteraction: false
12490
- } : false,
12491
- loop: images.length > 1,
12492
- className: "h-full rounded-2xl",
12493
- children: images.map((img, index) => /* @__PURE__ */ jsx(SwiperSlide, { children: /* @__PURE__ */ jsx("div", { className: "relative w-full h-full bg-gray-100", children: /* @__PURE__ */ jsx(
12494
- "img",
12673
+ /* @__PURE__ */ jsx(
12674
+ Swiper2,
12495
12675
  {
12496
- src: img,
12497
- alt: `Demo room view ${index + 1}`,
12498
- className: "w-full h-full object-cover"
12676
+ modules: [Navigation, Pagination, Autoplay],
12677
+ spaceBetween: 0,
12678
+ slidesPerView: 1,
12679
+ navigation: images.length > 1,
12680
+ pagination: images.length > 1 ? { clickable: true } : false,
12681
+ autoplay: images.length > 1 ? {
12682
+ delay: 3e3,
12683
+ disableOnInteraction: false
12684
+ } : false,
12685
+ loop: images.length > 1,
12686
+ className: "h-full rounded-2xl",
12687
+ onSliderFirstMove: () => {
12688
+ userSlideTriggerRef.current = "swipe";
12689
+ },
12690
+ onTouchEnd: () => {
12691
+ setTimeout(() => {
12692
+ if (userSlideTriggerRef.current === "swipe") {
12693
+ userSlideTriggerRef.current = null;
12694
+ }
12695
+ }, 0);
12696
+ },
12697
+ onSlideChange: (swiper) => {
12698
+ const trigger = userSlideTriggerRef.current;
12699
+ if (!trigger) return;
12700
+ userSlideTriggerRef.current = null;
12701
+ onImageSlideChange?.({
12702
+ trigger,
12703
+ activeIndex: swiper.realIndex,
12704
+ imageUrl: images[swiper.realIndex] || ""
12705
+ });
12706
+ },
12707
+ children: images.map((img, index) => /* @__PURE__ */ jsx(SwiperSlide, { children: /* @__PURE__ */ jsx("div", { className: "relative w-full h-full bg-gray-100", children: /* @__PURE__ */ jsx(
12708
+ "img",
12709
+ {
12710
+ src: img,
12711
+ alt: `Demo room view ${index + 1}`,
12712
+ className: "w-full h-full object-cover"
12713
+ }
12714
+ ) }) }, index))
12499
12715
  }
12500
- ) }) }, index))
12501
- }
12502
- )
12503
- ] })
12716
+ )
12717
+ ]
12718
+ }
12719
+ )
12504
12720
  ]
12505
12721
  }
12506
12722
  ) });
@@ -12532,7 +12748,8 @@ function buildMirWelcomeUrl({
12532
12748
  credential,
12533
12749
  currentUrl,
12534
12750
  managerIdParam = "email",
12535
- credentialParam = "credential"
12751
+ credentialParam = "credential",
12752
+ ref
12536
12753
  }) {
12537
12754
  const url = new URL(baseUrl);
12538
12755
  if (language) {
@@ -12541,6 +12758,9 @@ function buildMirWelcomeUrl({
12541
12758
  url.searchParams.set("countrycode", countrycode);
12542
12759
  url.searchParams.set(managerIdParam, managerId);
12543
12760
  url.searchParams.set(credentialParam, credential);
12761
+ if (ref) {
12762
+ url.searchParams.set("ref", ref);
12763
+ }
12544
12764
  const redirectSource = sanitizeRedirectSource(
12545
12765
  currentUrl ?? (typeof window !== "undefined" ? window.location.href : "")
12546
12766
  );
@@ -12676,6 +12896,8 @@ var BookingFormO2O = ({
12676
12896
  timezone: timezone5,
12677
12897
  handleBookingSuccess,
12678
12898
  onQuestionnaireSubmit,
12899
+ podDesignRef,
12900
+ trackCallbacks,
12679
12901
  ...props
12680
12902
  }) => {
12681
12903
  const apiClient = useMemo(
@@ -12773,7 +12995,8 @@ var BookingFormO2O = ({
12773
12995
  managerId: effectiveStoreManagerId,
12774
12996
  credential: effectiveMirSessionId,
12775
12997
  managerIdParam: "store_manager_id",
12776
- credentialParam: "sessionid"
12998
+ credentialParam: "sessionid",
12999
+ ref: podDesignRef
12777
13000
  });
12778
13001
  }
12779
13002
  if (!managerId) return void 0;
@@ -12784,7 +13007,8 @@ var BookingFormO2O = ({
12784
13007
  language: apiConfig?.podLanguage,
12785
13008
  countrycode: apiConfig?.podCountry,
12786
13009
  managerId,
12787
- credential: mirCredential
13010
+ credential: mirCredential,
13011
+ ref: podDesignRef
12788
13012
  });
12789
13013
  }, [
12790
13014
  isPodButtonDisabled,
@@ -12796,7 +13020,8 @@ var BookingFormO2O = ({
12796
13020
  apiConfig?.podCountry,
12797
13021
  mirCredential,
12798
13022
  effectiveStoreManagerId,
12799
- effectiveMirSessionId
13023
+ effectiveMirSessionId,
13024
+ podDesignRef
12800
13025
  ]);
12801
13026
  const dateTimePickerPageData = useMemo(
12802
13027
  () => ({
@@ -12815,7 +13040,9 @@ var BookingFormO2O = ({
12815
13040
  demoRoom,
12816
13041
  demoRoomLoading,
12817
13042
  locale: apiConfig.locale,
12818
- pageData: pageData?.demoRoomDetail
13043
+ pageData: pageData?.demoRoomDetail,
13044
+ onGoogleMapsClick: trackCallbacks?.onGoogleMapsClick,
13045
+ onImageSlideChange: trackCallbacks?.onImageSlideChange
12819
13046
  }
12820
13047
  ) }),
12821
13048
  /* @__PURE__ */ jsxs("div", { className: "bg-[#f5f5f5]", children: [
@@ -12943,7 +13170,15 @@ var BookingFormO2O = ({
12943
13170
  "aria-disabled": isPodButtonDisabled,
12944
13171
  tabIndex: isPodButtonDisabled ? -1 : void 0,
12945
13172
  onClick: (event2) => {
12946
- if (isPodButtonDisabled) event2.preventDefault();
13173
+ if (isPodButtonDisabled) {
13174
+ event2.preventDefault();
13175
+ return;
13176
+ }
13177
+ trackCallbacks?.onPodDesignClick?.({
13178
+ buttonText: selectedPodButtonText || "",
13179
+ url: selectedPodButtonLink || "",
13180
+ isEditMode: isPodDesignEditMode
13181
+ });
12947
13182
  },
12948
13183
  rel: "noopener noreferrer",
12949
13184
  className: cn(
@@ -13001,7 +13236,8 @@ var BookingFormO2O = ({
13001
13236
  onQuestionnaireSubmit,
13002
13237
  pageData: dateTimePickerPageData,
13003
13238
  selectedPurposeType: selectedPurpose?.type,
13004
- podDesignId: mirSessionId
13239
+ podDesignId: mirSessionId,
13240
+ trackCallbacks
13005
13241
  }
13006
13242
  ) })
13007
13243
  ] })