@heycater/qualification-funnel 1.8.2 → 1.9.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.
package/dist/index.esm.js CHANGED
@@ -10085,7 +10085,7 @@ function trackAnswerSelected(context, answer) {
10085
10085
  if (context.city) {
10086
10086
  properties.city = context.city;
10087
10087
  }
10088
- captureEvent("qf_v7_answer_selected", properties);
10088
+ captureEvent("qf_v8_answer_selected", properties);
10089
10089
  }
10090
10090
  function trackFormSubmitted(context, metadata) {
10091
10091
  if (!context.session_id) {
@@ -10103,7 +10103,7 @@ function trackFormSubmitted(context, metadata) {
10103
10103
  if (context.city) {
10104
10104
  properties.city = context.city;
10105
10105
  }
10106
- captureEvent("qf_v7_form_submitted", properties);
10106
+ captureEvent("qf_v8_form_submitted", properties);
10107
10107
  }
10108
10108
  function trackCompleted(context) {
10109
10109
  if (!context.session_id) {
@@ -10120,7 +10120,7 @@ function trackCompleted(context) {
10120
10120
  if (context.city) {
10121
10121
  properties.city = context.city;
10122
10122
  }
10123
- captureEvent("qf_v7_completed", properties);
10123
+ captureEvent("qf_v8_completed", properties);
10124
10124
  }
10125
10125
  function trackAbandoned(context, lastStep) {
10126
10126
  if (!context.session_id) {
@@ -10139,7 +10139,7 @@ function trackAbandoned(context, lastStep) {
10139
10139
  if (context.city) {
10140
10140
  properties.city = context.city;
10141
10141
  }
10142
- captureEvent("qf_v7_abandoned", properties);
10142
+ captureEvent("qf_v8_abandoned", properties);
10143
10143
  }
10144
10144
  function trackStarted(context, initialStepId) {
10145
10145
  const properties = {
@@ -10147,7 +10147,7 @@ function trackStarted(context, initialStepId) {
10147
10147
  session_id: context.session_id,
10148
10148
  initial_step: initialStepId
10149
10149
  };
10150
- captureEvent("qf_v7_started", properties);
10150
+ captureEvent("qf_v8_started", properties);
10151
10151
  }
10152
10152
  const TrackingContext = createContext(null);
10153
10153
  function TrackingProvider({
@@ -10156,7 +10156,44 @@ function TrackingProvider({
10156
10156
  currentStepId,
10157
10157
  children
10158
10158
  }) {
10159
- const { state } = useQualification();
10159
+ const { state, answerOf } = useQualification();
10160
+ const trackStepCompletion = useCallback(() => {
10161
+ if (!("qualification" in state)) return;
10162
+ const qual = state.qualification;
10163
+ if (!("step" in qual)) return;
10164
+ const step2 = qual.step;
10165
+ const stepIndex = qual.stepIndex;
10166
+ const schemaStep = SCHEMA_STEPS[step2.id];
10167
+ const questions2 = (schemaStep == null ? void 0 : schemaStep.questions) || [];
10168
+ const sessionKey = `qf_v8_started_${funnelContextRef.current.session_id}`;
10169
+ if (typeof sessionStorage !== "undefined") {
10170
+ const hasStarted = sessionStorage.getItem(sessionKey);
10171
+ if (!hasStarted) {
10172
+ sessionStorage.setItem(sessionKey, "true");
10173
+ trackStarted(funnelContextRef.current, currentStepId);
10174
+ }
10175
+ }
10176
+ questions2.forEach((question, questionIndex) => {
10177
+ const currentValue = answerOf(question.id);
10178
+ const isLastQuestion = questionIndex === questions2.length - 1;
10179
+ if (question.id === "service_type" && isValidServiceType(currentValue)) {
10180
+ const stepOrder = getStepOrderForServiceType(currentValue);
10181
+ updateContext({
10182
+ service_type: currentValue,
10183
+ total_steps: stepOrder.length
10184
+ });
10185
+ } else if (question.id === "city" && currentValue) {
10186
+ updateContext({ city: currentValue });
10187
+ }
10188
+ trackAnswerSelected(funnelContextRef.current, {
10189
+ step_id: step2.id,
10190
+ step_index: stepIndex,
10191
+ question_id: question.id,
10192
+ answer_value: currentValue ?? null,
10193
+ is_last_question: isLastQuestion
10194
+ });
10195
+ });
10196
+ }, [funnelContextRef, currentStepId, state, updateContext, answerOf]);
10160
10197
  const trackAnswer = useCallback(
10161
10198
  (questionId, value) => {
10162
10199
  if (!("qualification" in state)) return;
@@ -10168,7 +10205,7 @@ function TrackingProvider({
10168
10205
  const questions2 = (schemaStep == null ? void 0 : schemaStep.questions) || [];
10169
10206
  const questionIndex = questions2.findIndex((q2) => q2.id === questionId);
10170
10207
  const isLastQuestion = questionIndex === questions2.length - 1;
10171
- const sessionKey = `qf_v7_started_${funnelContextRef.current.session_id}`;
10208
+ const sessionKey = `qf_v8_started_${funnelContextRef.current.session_id}`;
10172
10209
  if (typeof sessionStorage !== "undefined") {
10173
10210
  const hasStarted = sessionStorage.getItem(sessionKey);
10174
10211
  if (!hasStarted) {
@@ -10176,16 +10213,13 @@ function TrackingProvider({
10176
10213
  trackStarted(funnelContextRef.current, currentStepId);
10177
10214
  }
10178
10215
  }
10179
- if (questionId === "service_type") {
10180
- const serviceType = value;
10181
- if (serviceType) {
10182
- const stepOrder = getStepOrderForServiceType(serviceType);
10183
- delete funnelContextRef.current.city;
10184
- updateContext({
10185
- service_type: serviceType,
10186
- total_steps: stepOrder.length
10187
- });
10188
- }
10216
+ if (questionId === "service_type" && isValidServiceType(value)) {
10217
+ const stepOrder = getStepOrderForServiceType(value);
10218
+ delete funnelContextRef.current.city;
10219
+ updateContext({
10220
+ service_type: value,
10221
+ total_steps: stepOrder.length
10222
+ });
10189
10223
  } else if (questionId === "city") {
10190
10224
  updateContext({ city: value });
10191
10225
  }
@@ -10199,7 +10233,7 @@ function TrackingProvider({
10199
10233
  },
10200
10234
  [funnelContextRef, currentStepId, state, updateContext]
10201
10235
  );
10202
- return /* @__PURE__ */ jsx(TrackingContext.Provider, { value: { funnelContextRef, currentStepId, trackAnswer }, children });
10236
+ return /* @__PURE__ */ jsx(TrackingContext.Provider, { value: { funnelContextRef, currentStepId, trackAnswer, trackStepCompletion }, children });
10203
10237
  }
10204
10238
  function useTracking() {
10205
10239
  const context = useContext(TrackingContext);
@@ -10216,6 +10250,8 @@ function useTracking() {
10216
10250
  funnelContextRef: defaultRef,
10217
10251
  currentStepId: "",
10218
10252
  trackAnswer: () => {
10253
+ },
10254
+ trackStepCompletion: () => {
10219
10255
  }
10220
10256
  };
10221
10257
  }
@@ -12303,7 +12339,7 @@ var objectInspect = function inspect_(obj, options, depth, seen) {
12303
12339
  var ys = arrObjKeys(obj, inspect2);
12304
12340
  var isPlainObject2 = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object;
12305
12341
  var protoTag = obj instanceof Object ? "" : "null prototype";
12306
- var stringTag2 = !isPlainObject2 && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr$1(obj), 8, -1) : protoTag ? "Object" : "";
12342
+ var stringTag2 = !isPlainObject2 && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr(obj), 8, -1) : protoTag ? "Object" : "";
12307
12343
  var constructorTag = isPlainObject2 || typeof obj.constructor !== "function" ? "" : obj.constructor.name ? obj.constructor.name + " " : "";
12308
12344
  var tag = constructorTag + (stringTag2 || protoTag ? "[" + $join.call($concat$1.call([], stringTag2 || [], protoTag || []), ": ") + "] " : "");
12309
12345
  if (ys.length === 0) {
@@ -12328,25 +12364,25 @@ function canTrustToString(obj) {
12328
12364
  return !toStringTag || !(typeof obj === "object" && (toStringTag in obj || typeof obj[toStringTag] !== "undefined"));
12329
12365
  }
12330
12366
  function isArray$3(obj) {
12331
- return toStr$1(obj) === "[object Array]" && canTrustToString(obj);
12367
+ return toStr(obj) === "[object Array]" && canTrustToString(obj);
12332
12368
  }
12333
12369
  function isDate(obj) {
12334
- return toStr$1(obj) === "[object Date]" && canTrustToString(obj);
12370
+ return toStr(obj) === "[object Date]" && canTrustToString(obj);
12335
12371
  }
12336
12372
  function isRegExp$1(obj) {
12337
- return toStr$1(obj) === "[object RegExp]" && canTrustToString(obj);
12373
+ return toStr(obj) === "[object RegExp]" && canTrustToString(obj);
12338
12374
  }
12339
12375
  function isError(obj) {
12340
- return toStr$1(obj) === "[object Error]" && canTrustToString(obj);
12376
+ return toStr(obj) === "[object Error]" && canTrustToString(obj);
12341
12377
  }
12342
12378
  function isString(obj) {
12343
- return toStr$1(obj) === "[object String]" && canTrustToString(obj);
12379
+ return toStr(obj) === "[object String]" && canTrustToString(obj);
12344
12380
  }
12345
12381
  function isNumber(obj) {
12346
- return toStr$1(obj) === "[object Number]" && canTrustToString(obj);
12382
+ return toStr(obj) === "[object Number]" && canTrustToString(obj);
12347
12383
  }
12348
12384
  function isBoolean(obj) {
12349
- return toStr$1(obj) === "[object Boolean]" && canTrustToString(obj);
12385
+ return toStr(obj) === "[object Boolean]" && canTrustToString(obj);
12350
12386
  }
12351
12387
  function isSymbol(obj) {
12352
12388
  if (hasShammedSymbols) {
@@ -12382,7 +12418,7 @@ var hasOwn$1 = Object.prototype.hasOwnProperty || function(key) {
12382
12418
  function has$4(obj, key) {
12383
12419
  return hasOwn$1.call(obj, key);
12384
12420
  }
12385
- function toStr$1(obj) {
12421
+ function toStr(obj) {
12386
12422
  return objectToString.call(obj);
12387
12423
  }
12388
12424
  function nameOf(f) {
@@ -12691,7 +12727,7 @@ var syntax = SyntaxError;
12691
12727
  var uri = URIError;
12692
12728
  var abs$1 = Math.abs;
12693
12729
  var floor$1 = Math.floor;
12694
- var max$2 = Math.max;
12730
+ var max$1 = Math.max;
12695
12731
  var min$1 = Math.min;
12696
12732
  var pow$1 = Math.pow;
12697
12733
  var round$2 = Math.round;
@@ -12820,78 +12856,99 @@ function requireObject_getPrototypeOf() {
12820
12856
  Object_getPrototypeOf = $Object2.getPrototypeOf || null;
12821
12857
  return Object_getPrototypeOf;
12822
12858
  }
12823
- var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
12824
- var toStr = Object.prototype.toString;
12825
- var max$1 = Math.max;
12826
- var funcType = "[object Function]";
12827
- var concatty = function concatty2(a3, b2) {
12828
- var arr = [];
12829
- for (var i2 = 0; i2 < a3.length; i2 += 1) {
12830
- arr[i2] = a3[i2];
12831
- }
12832
- for (var j = 0; j < b2.length; j += 1) {
12833
- arr[j + a3.length] = b2[j];
12834
- }
12835
- return arr;
12836
- };
12837
- var slicy = function slicy2(arrLike, offset2) {
12838
- var arr = [];
12839
- for (var i2 = offset2, j = 0; i2 < arrLike.length; i2 += 1, j += 1) {
12840
- arr[j] = arrLike[i2];
12841
- }
12842
- return arr;
12843
- };
12844
- var joiny = function(arr, joiner) {
12845
- var str = "";
12846
- for (var i2 = 0; i2 < arr.length; i2 += 1) {
12847
- str += arr[i2];
12848
- if (i2 + 1 < arr.length) {
12849
- str += joiner;
12859
+ var implementation;
12860
+ var hasRequiredImplementation;
12861
+ function requireImplementation() {
12862
+ if (hasRequiredImplementation) return implementation;
12863
+ hasRequiredImplementation = 1;
12864
+ var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
12865
+ var toStr2 = Object.prototype.toString;
12866
+ var max2 = Math.max;
12867
+ var funcType = "[object Function]";
12868
+ var concatty = function concatty2(a3, b2) {
12869
+ var arr = [];
12870
+ for (var i2 = 0; i2 < a3.length; i2 += 1) {
12871
+ arr[i2] = a3[i2];
12850
12872
  }
12851
- }
12852
- return str;
12853
- };
12854
- var implementation$1 = function bind(that) {
12855
- var target = this;
12856
- if (typeof target !== "function" || toStr.apply(target) !== funcType) {
12857
- throw new TypeError(ERROR_MESSAGE + target);
12858
- }
12859
- var args = slicy(arguments, 1);
12860
- var bound;
12861
- var binder = function() {
12862
- if (this instanceof bound) {
12863
- var result = target.apply(
12864
- this,
12865
- concatty(args, arguments)
12866
- );
12867
- if (Object(result) === result) {
12868
- return result;
12873
+ for (var j = 0; j < b2.length; j += 1) {
12874
+ arr[j + a3.length] = b2[j];
12875
+ }
12876
+ return arr;
12877
+ };
12878
+ var slicy = function slicy2(arrLike, offset2) {
12879
+ var arr = [];
12880
+ for (var i2 = offset2, j = 0; i2 < arrLike.length; i2 += 1, j += 1) {
12881
+ arr[j] = arrLike[i2];
12882
+ }
12883
+ return arr;
12884
+ };
12885
+ var joiny = function(arr, joiner) {
12886
+ var str = "";
12887
+ for (var i2 = 0; i2 < arr.length; i2 += 1) {
12888
+ str += arr[i2];
12889
+ if (i2 + 1 < arr.length) {
12890
+ str += joiner;
12869
12891
  }
12870
- return this;
12871
12892
  }
12872
- return target.apply(
12873
- that,
12874
- concatty(args, arguments)
12875
- );
12893
+ return str;
12876
12894
  };
12877
- var boundLength = max$1(0, target.length - args.length);
12878
- var boundArgs = [];
12879
- for (var i2 = 0; i2 < boundLength; i2++) {
12880
- boundArgs[i2] = "$" + i2;
12881
- }
12882
- bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
12883
- if (target.prototype) {
12884
- var Empty = function Empty2() {
12895
+ implementation = function bind2(that) {
12896
+ var target = this;
12897
+ if (typeof target !== "function" || toStr2.apply(target) !== funcType) {
12898
+ throw new TypeError(ERROR_MESSAGE + target);
12899
+ }
12900
+ var args = slicy(arguments, 1);
12901
+ var bound;
12902
+ var binder = function() {
12903
+ if (this instanceof bound) {
12904
+ var result = target.apply(
12905
+ this,
12906
+ concatty(args, arguments)
12907
+ );
12908
+ if (Object(result) === result) {
12909
+ return result;
12910
+ }
12911
+ return this;
12912
+ }
12913
+ return target.apply(
12914
+ that,
12915
+ concatty(args, arguments)
12916
+ );
12885
12917
  };
12886
- Empty.prototype = target.prototype;
12887
- bound.prototype = new Empty();
12888
- Empty.prototype = null;
12889
- }
12890
- return bound;
12891
- };
12892
- var implementation = implementation$1;
12893
- var functionBind = Function.prototype.bind || implementation;
12894
- var functionCall = Function.prototype.call;
12918
+ var boundLength = max2(0, target.length - args.length);
12919
+ var boundArgs = [];
12920
+ for (var i2 = 0; i2 < boundLength; i2++) {
12921
+ boundArgs[i2] = "$" + i2;
12922
+ }
12923
+ bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
12924
+ if (target.prototype) {
12925
+ var Empty = function Empty2() {
12926
+ };
12927
+ Empty.prototype = target.prototype;
12928
+ bound.prototype = new Empty();
12929
+ Empty.prototype = null;
12930
+ }
12931
+ return bound;
12932
+ };
12933
+ return implementation;
12934
+ }
12935
+ var functionBind;
12936
+ var hasRequiredFunctionBind;
12937
+ function requireFunctionBind() {
12938
+ if (hasRequiredFunctionBind) return functionBind;
12939
+ hasRequiredFunctionBind = 1;
12940
+ var implementation2 = requireImplementation();
12941
+ functionBind = Function.prototype.bind || implementation2;
12942
+ return functionBind;
12943
+ }
12944
+ var functionCall;
12945
+ var hasRequiredFunctionCall;
12946
+ function requireFunctionCall() {
12947
+ if (hasRequiredFunctionCall) return functionCall;
12948
+ hasRequiredFunctionCall = 1;
12949
+ functionCall = Function.prototype.call;
12950
+ return functionCall;
12951
+ }
12895
12952
  var functionApply;
12896
12953
  var hasRequiredFunctionApply;
12897
12954
  function requireFunctionApply() {
@@ -12901,14 +12958,14 @@ function requireFunctionApply() {
12901
12958
  return functionApply;
12902
12959
  }
12903
12960
  var reflectApply = typeof Reflect !== "undefined" && Reflect && Reflect.apply;
12904
- var bind$2 = functionBind;
12961
+ var bind$2 = requireFunctionBind();
12905
12962
  var $apply$1 = requireFunctionApply();
12906
- var $call$2 = functionCall;
12963
+ var $call$2 = requireFunctionCall();
12907
12964
  var $reflectApply = reflectApply;
12908
12965
  var actualApply = $reflectApply || bind$2.call($call$2, $apply$1);
12909
- var bind$1 = functionBind;
12966
+ var bind$1 = requireFunctionBind();
12910
12967
  var $TypeError$4 = type;
12911
- var $call$1 = functionCall;
12968
+ var $call$1 = requireFunctionCall();
12912
12969
  var $actualApply = actualApply;
12913
12970
  var callBindApplyHelpers = function callBindBasic(args) {
12914
12971
  if (args.length < 1 || typeof args[0] !== "function") {
@@ -12974,8 +13031,8 @@ function requireHasown() {
12974
13031
  hasRequiredHasown = 1;
12975
13032
  var call = Function.prototype.call;
12976
13033
  var $hasOwn = Object.prototype.hasOwnProperty;
12977
- var bind3 = functionBind;
12978
- hasown = bind3.call(call, $hasOwn);
13034
+ var bind2 = requireFunctionBind();
13035
+ hasown = bind2.call(call, $hasOwn);
12979
13036
  return hasown;
12980
13037
  }
12981
13038
  var undefined$1;
@@ -12989,7 +13046,7 @@ var $TypeError$3 = type;
12989
13046
  var $URIError = uri;
12990
13047
  var abs = abs$1;
12991
13048
  var floor = floor$1;
12992
- var max = max$2;
13049
+ var max = max$1;
12993
13050
  var min = min$1;
12994
13051
  var pow = pow$1;
12995
13052
  var round$1 = round$2;
@@ -13023,7 +13080,7 @@ var getProto = requireGetProto();
13023
13080
  var $ObjectGPO = requireObject_getPrototypeOf();
13024
13081
  var $ReflectGPO = requireReflect_getPrototypeOf();
13025
13082
  var $apply = requireFunctionApply();
13026
- var $call = functionCall;
13083
+ var $call = requireFunctionCall();
13027
13084
  var needsEval = {};
13028
13085
  var TypedArray = typeof Uint8Array === "undefined" || !getProto ? undefined$1 : getProto(Uint8Array);
13029
13086
  var INTRINSICS = {
@@ -13194,13 +13251,13 @@ var LEGACY_ALIASES = {
13194
13251
  "%WeakMapPrototype%": ["WeakMap", "prototype"],
13195
13252
  "%WeakSetPrototype%": ["WeakSet", "prototype"]
13196
13253
  };
13197
- var bind2 = functionBind;
13254
+ var bind = requireFunctionBind();
13198
13255
  var hasOwn = requireHasown();
13199
- var $concat = bind2.call($call, Array.prototype.concat);
13200
- var $spliceApply = bind2.call($apply, Array.prototype.splice);
13201
- var $replace = bind2.call($call, String.prototype.replace);
13202
- var $strSlice = bind2.call($call, String.prototype.slice);
13203
- var $exec = bind2.call($call, RegExp.prototype.exec);
13256
+ var $concat = bind.call($call, Array.prototype.concat);
13257
+ var $spliceApply = bind.call($apply, Array.prototype.splice);
13258
+ var $replace = bind.call($call, String.prototype.replace);
13259
+ var $strSlice = bind.call($call, String.prototype.slice);
13260
+ var $exec = bind.call($call, RegExp.prototype.exec);
13204
13261
  var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
13205
13262
  var reEscapeChar = /\\(\\)?/g;
13206
13263
  var stringToPath = function stringToPath2(string2) {
@@ -29947,8 +30004,13 @@ const EmbeddedFunnel = React__default.forwardRef(
29947
30004
  }
29948
30005
  }, [state.status]);
29949
30006
  useAbandonmentTracking(funnelContext, state);
30007
+ const toNextStepRef = useRef(null);
29950
30008
  const toNextStep2 = useCallback(() => {
29951
- actions.nextStep();
30009
+ if (toNextStepRef.current) {
30010
+ toNextStepRef.current();
30011
+ } else {
30012
+ actions.nextStep();
30013
+ }
29952
30014
  }, [actions]);
29953
30015
  useEffect(() => {
29954
30016
  if (state.status === QUALIFICATION_STATUS.qualifiedForMarketplace) {
@@ -30003,69 +30065,85 @@ const EmbeddedFunnel = React__default.forwardRef(
30003
30065
  const isFullscreen = mode === "fullscreen";
30004
30066
  const enabledSteps = state.qualification.steps.filter((q2) => !q2.disabled);
30005
30067
  const handleCancel = onCancel || (() => window.history.back());
30006
- return /* @__PURE__ */ jsx(
30068
+ return /* @__PURE__ */ jsxs(
30007
30069
  TrackingProvider,
30008
30070
  {
30009
30071
  funnelContextRef: funnelContext,
30010
30072
  updateContext,
30011
30073
  currentStepId: stepId,
30012
- children: /* @__PURE__ */ jsxs(
30013
- FormWrapper,
30014
- {
30015
- $textColor: textColor,
30016
- $mode: mode,
30017
- tabIndex: 0,
30018
- ref: ref2,
30019
- "data-embedded-funnel": true,
30020
- "data-ph-capture-attribute-funnel-step": stepId || void 0,
30021
- "data-ph-capture-attribute-funnel-mode": mode,
30022
- name: "step" in state.qualification ? state.qualification.step.id : state.status,
30023
- onSubmit: (e2) => {
30024
- e2.preventDefault();
30025
- toNextStep2();
30026
- },
30027
- onKeyPressCapture: onKeyPress,
30028
- children: [
30029
- isFullscreen && state.status === QUALIFICATION_STATUS.answering && /* @__PURE__ */ jsx(
30030
- FullscreenHeader,
30031
- {
30032
- currentStep: state.qualification.stepIndex + 1,
30033
- stepCount: enabledSteps.length,
30034
- onCancel: handleCancel
30035
- }
30036
- ),
30037
- /* @__PURE__ */ jsx(Box, { position: "absolute", top: "-120px", ref: scrollHelperRef }),
30038
- /* @__PURE__ */ jsxs(Box, { width: "100%", pb: isFullscreen ? 0 : 6, flexGrow: 1, display: "flex", flexDirection: "column", children: [
30039
- state.status === QUALIFICATION_STATUS.answering && /* @__PURE__ */ jsx(
30040
- EmbeddedQuestion,
30074
+ children: [
30075
+ /* @__PURE__ */ jsx(StepTransitionHandler, { toNextStepRef, nextStep: actions.nextStep }),
30076
+ /* @__PURE__ */ jsxs(
30077
+ FormWrapper,
30078
+ {
30079
+ $textColor: textColor,
30080
+ $mode: mode,
30081
+ tabIndex: 0,
30082
+ ref: ref2,
30083
+ "data-embedded-funnel": true,
30084
+ "data-ph-capture-attribute-funnel-step": stepId || void 0,
30085
+ "data-ph-capture-attribute-funnel-mode": mode,
30086
+ name: "step" in state.qualification ? state.qualification.step.id : state.status,
30087
+ onSubmit: (e2) => {
30088
+ e2.preventDefault();
30089
+ toNextStep2();
30090
+ },
30091
+ onKeyPressCapture: onKeyPress,
30092
+ children: [
30093
+ isFullscreen && state.status === QUALIFICATION_STATUS.answering && /* @__PURE__ */ jsx(
30094
+ FullscreenHeader,
30041
30095
  {
30042
- slides,
30043
- step: state.qualification.step,
30044
- highlightColor,
30045
- ratings,
30046
- renderTitle,
30047
- LayoutComponent,
30048
- titleTranslationKeys,
30049
- mode
30096
+ currentStep: state.qualification.stepIndex + 1,
30097
+ stepCount: enabledSteps.length,
30098
+ onCancel: handleCancel
30050
30099
  }
30051
30100
  ),
30052
- state.status === QUALIFICATION_STATUS.answered && /* @__PURE__ */ jsxs(Fragment, { children: [
30053
- /* @__PURE__ */ jsx(
30054
- LoadingIndicator,
30101
+ /* @__PURE__ */ jsx(Box, { position: "absolute", top: "-120px", ref: scrollHelperRef }),
30102
+ /* @__PURE__ */ jsxs(Box, { width: "100%", pb: isFullscreen ? 0 : 6, flexGrow: 1, display: "flex", flexDirection: "column", children: [
30103
+ state.status === QUALIFICATION_STATUS.answering && /* @__PURE__ */ jsx(
30104
+ EmbeddedQuestion,
30055
30105
  {
30056
- variant: onBackground === "dark" ? "light" : "dark"
30106
+ slides,
30107
+ step: state.qualification.step,
30108
+ highlightColor,
30109
+ ratings,
30110
+ renderTitle,
30111
+ LayoutComponent,
30112
+ titleTranslationKeys,
30113
+ mode
30057
30114
  }
30058
30115
  ),
30059
- /* @__PURE__ */ jsx(Box, { display: "none", children: /* @__PURE__ */ jsx(EmbeddedRequestPage, { ratings }) })
30116
+ state.status === QUALIFICATION_STATUS.answered && /* @__PURE__ */ jsxs(Fragment, { children: [
30117
+ /* @__PURE__ */ jsx(
30118
+ LoadingIndicator,
30119
+ {
30120
+ variant: onBackground === "dark" ? "light" : "dark"
30121
+ }
30122
+ ),
30123
+ /* @__PURE__ */ jsx(Box, { display: "none", children: /* @__PURE__ */ jsx(EmbeddedRequestPage, { ratings }) })
30124
+ ] })
30060
30125
  ] })
30061
- ] })
30062
- ]
30063
- }
30064
- )
30126
+ ]
30127
+ }
30128
+ )
30129
+ ]
30065
30130
  }
30066
30131
  );
30067
30132
  }
30068
30133
  );
30134
+ function StepTransitionHandler({ toNextStepRef, nextStep }) {
30135
+ const { trackStepCompletion } = useTracking();
30136
+ useLayoutEffect(() => {
30137
+ toNextStepRef.current = () => {
30138
+ trackStepCompletion();
30139
+ nextStep();
30140
+ };
30141
+ return () => {
30142
+ toNextStepRef.current = null;
30143
+ };
30144
+ }, [toNextStepRef, trackStepCompletion, nextStep]);
30145
+ return null;
30146
+ }
30069
30147
  const FormWrapper = styled.form`
30070
30148
  --embedded-text-color: ${({ $textColor }) => $textColor === "light" ? "white" : "rgb(60, 67, 64)"};
30071
30149
  width: 100%;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycater/qualification-funnel",
3
- "version": "1.8.2",
3
+ "version": "1.9.0",
4
4
  "type": "module",
5
5
  "description": "Heycater embedded qualification funnel widget",
6
6
  "main": "dist/index.cjs.js",