@heycater/qualification-funnel 1.8.2 → 1.10.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_v9_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_v9_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_v9_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_v9_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_v9_started", properties);
10151
10151
  }
10152
10152
  const TrackingContext = createContext(null);
10153
10153
  function TrackingProvider({
@@ -10156,50 +10156,60 @@ function TrackingProvider({
10156
10156
  currentStepId,
10157
10157
  children
10158
10158
  }) {
10159
- const { state } = useQualification();
10160
- const trackAnswer = useCallback(
10161
- (questionId, value) => {
10162
- if (!("qualification" in state)) return;
10163
- const qual = state.qualification;
10164
- if (!("step" in qual)) return;
10165
- const step2 = qual.step;
10166
- const stepIndex = qual.stepIndex;
10167
- const schemaStep = SCHEMA_STEPS[step2.id];
10168
- const questions2 = (schemaStep == null ? void 0 : schemaStep.questions) || [];
10169
- const questionIndex = questions2.findIndex((q2) => q2.id === questionId);
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_v9_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);
10170
10178
  const isLastQuestion = questionIndex === questions2.length - 1;
10171
- const sessionKey = `qf_v7_started_${funnelContextRef.current.session_id}`;
10172
- if (typeof sessionStorage !== "undefined") {
10173
- const hasStarted = sessionStorage.getItem(sessionKey);
10174
- if (!hasStarted) {
10175
- sessionStorage.setItem(sessionKey, "true");
10176
- trackStarted(funnelContextRef.current, currentStepId);
10177
- }
10178
- }
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
- }
10189
- } else if (questionId === "city") {
10190
- updateContext({ city: value });
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 });
10191
10187
  }
10192
10188
  trackAnswerSelected(funnelContextRef.current, {
10193
10189
  step_id: step2.id,
10194
10190
  step_index: stepIndex,
10195
- question_id: questionId,
10196
- answer_value: value,
10191
+ question_id: question.id,
10192
+ answer_value: currentValue ?? null,
10197
10193
  is_last_question: isLastQuestion
10198
10194
  });
10195
+ });
10196
+ }, [funnelContextRef, currentStepId, state, updateContext, answerOf]);
10197
+ const trackAnswer = useCallback(
10198
+ (questionId, value) => {
10199
+ if (questionId === "service_type" && isValidServiceType(value)) {
10200
+ const stepOrder = getStepOrderForServiceType(value);
10201
+ delete funnelContextRef.current.city;
10202
+ updateContext({
10203
+ service_type: value,
10204
+ total_steps: stepOrder.length
10205
+ });
10206
+ } else if (questionId === "city") {
10207
+ updateContext({ city: value });
10208
+ }
10199
10209
  },
10200
- [funnelContextRef, currentStepId, state, updateContext]
10210
+ [funnelContextRef, updateContext]
10201
10211
  );
10202
- return /* @__PURE__ */ jsx(TrackingContext.Provider, { value: { funnelContextRef, currentStepId, trackAnswer }, children });
10212
+ return /* @__PURE__ */ jsx(TrackingContext.Provider, { value: { funnelContextRef, currentStepId, trackAnswer, trackStepCompletion }, children });
10203
10213
  }
10204
10214
  function useTracking() {
10205
10215
  const context = useContext(TrackingContext);
@@ -10216,6 +10226,8 @@ function useTracking() {
10216
10226
  funnelContextRef: defaultRef,
10217
10227
  currentStepId: "",
10218
10228
  trackAnswer: () => {
10229
+ },
10230
+ trackStepCompletion: () => {
10219
10231
  }
10220
10232
  };
10221
10233
  }
@@ -12303,7 +12315,7 @@ var objectInspect = function inspect_(obj, options, depth, seen) {
12303
12315
  var ys = arrObjKeys(obj, inspect2);
12304
12316
  var isPlainObject2 = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object;
12305
12317
  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" : "";
12318
+ var stringTag2 = !isPlainObject2 && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr(obj), 8, -1) : protoTag ? "Object" : "";
12307
12319
  var constructorTag = isPlainObject2 || typeof obj.constructor !== "function" ? "" : obj.constructor.name ? obj.constructor.name + " " : "";
12308
12320
  var tag = constructorTag + (stringTag2 || protoTag ? "[" + $join.call($concat$1.call([], stringTag2 || [], protoTag || []), ": ") + "] " : "");
12309
12321
  if (ys.length === 0) {
@@ -12328,25 +12340,25 @@ function canTrustToString(obj) {
12328
12340
  return !toStringTag || !(typeof obj === "object" && (toStringTag in obj || typeof obj[toStringTag] !== "undefined"));
12329
12341
  }
12330
12342
  function isArray$3(obj) {
12331
- return toStr$1(obj) === "[object Array]" && canTrustToString(obj);
12343
+ return toStr(obj) === "[object Array]" && canTrustToString(obj);
12332
12344
  }
12333
12345
  function isDate(obj) {
12334
- return toStr$1(obj) === "[object Date]" && canTrustToString(obj);
12346
+ return toStr(obj) === "[object Date]" && canTrustToString(obj);
12335
12347
  }
12336
12348
  function isRegExp$1(obj) {
12337
- return toStr$1(obj) === "[object RegExp]" && canTrustToString(obj);
12349
+ return toStr(obj) === "[object RegExp]" && canTrustToString(obj);
12338
12350
  }
12339
12351
  function isError(obj) {
12340
- return toStr$1(obj) === "[object Error]" && canTrustToString(obj);
12352
+ return toStr(obj) === "[object Error]" && canTrustToString(obj);
12341
12353
  }
12342
12354
  function isString(obj) {
12343
- return toStr$1(obj) === "[object String]" && canTrustToString(obj);
12355
+ return toStr(obj) === "[object String]" && canTrustToString(obj);
12344
12356
  }
12345
12357
  function isNumber(obj) {
12346
- return toStr$1(obj) === "[object Number]" && canTrustToString(obj);
12358
+ return toStr(obj) === "[object Number]" && canTrustToString(obj);
12347
12359
  }
12348
12360
  function isBoolean(obj) {
12349
- return toStr$1(obj) === "[object Boolean]" && canTrustToString(obj);
12361
+ return toStr(obj) === "[object Boolean]" && canTrustToString(obj);
12350
12362
  }
12351
12363
  function isSymbol(obj) {
12352
12364
  if (hasShammedSymbols) {
@@ -12382,7 +12394,7 @@ var hasOwn$1 = Object.prototype.hasOwnProperty || function(key) {
12382
12394
  function has$4(obj, key) {
12383
12395
  return hasOwn$1.call(obj, key);
12384
12396
  }
12385
- function toStr$1(obj) {
12397
+ function toStr(obj) {
12386
12398
  return objectToString.call(obj);
12387
12399
  }
12388
12400
  function nameOf(f) {
@@ -12691,7 +12703,7 @@ var syntax = SyntaxError;
12691
12703
  var uri = URIError;
12692
12704
  var abs$1 = Math.abs;
12693
12705
  var floor$1 = Math.floor;
12694
- var max$2 = Math.max;
12706
+ var max$1 = Math.max;
12695
12707
  var min$1 = Math.min;
12696
12708
  var pow$1 = Math.pow;
12697
12709
  var round$2 = Math.round;
@@ -12820,78 +12832,99 @@ function requireObject_getPrototypeOf() {
12820
12832
  Object_getPrototypeOf = $Object2.getPrototypeOf || null;
12821
12833
  return Object_getPrototypeOf;
12822
12834
  }
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;
12835
+ var implementation;
12836
+ var hasRequiredImplementation;
12837
+ function requireImplementation() {
12838
+ if (hasRequiredImplementation) return implementation;
12839
+ hasRequiredImplementation = 1;
12840
+ var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
12841
+ var toStr2 = Object.prototype.toString;
12842
+ var max2 = Math.max;
12843
+ var funcType = "[object Function]";
12844
+ var concatty = function concatty2(a3, b2) {
12845
+ var arr = [];
12846
+ for (var i2 = 0; i2 < a3.length; i2 += 1) {
12847
+ arr[i2] = a3[i2];
12850
12848
  }
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;
12849
+ for (var j = 0; j < b2.length; j += 1) {
12850
+ arr[j + a3.length] = b2[j];
12851
+ }
12852
+ return arr;
12853
+ };
12854
+ var slicy = function slicy2(arrLike, offset2) {
12855
+ var arr = [];
12856
+ for (var i2 = offset2, j = 0; i2 < arrLike.length; i2 += 1, j += 1) {
12857
+ arr[j] = arrLike[i2];
12858
+ }
12859
+ return arr;
12860
+ };
12861
+ var joiny = function(arr, joiner) {
12862
+ var str = "";
12863
+ for (var i2 = 0; i2 < arr.length; i2 += 1) {
12864
+ str += arr[i2];
12865
+ if (i2 + 1 < arr.length) {
12866
+ str += joiner;
12869
12867
  }
12870
- return this;
12871
12868
  }
12872
- return target.apply(
12873
- that,
12874
- concatty(args, arguments)
12875
- );
12869
+ return str;
12876
12870
  };
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() {
12871
+ implementation = function bind2(that) {
12872
+ var target = this;
12873
+ if (typeof target !== "function" || toStr2.apply(target) !== funcType) {
12874
+ throw new TypeError(ERROR_MESSAGE + target);
12875
+ }
12876
+ var args = slicy(arguments, 1);
12877
+ var bound;
12878
+ var binder = function() {
12879
+ if (this instanceof bound) {
12880
+ var result = target.apply(
12881
+ this,
12882
+ concatty(args, arguments)
12883
+ );
12884
+ if (Object(result) === result) {
12885
+ return result;
12886
+ }
12887
+ return this;
12888
+ }
12889
+ return target.apply(
12890
+ that,
12891
+ concatty(args, arguments)
12892
+ );
12885
12893
  };
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;
12894
+ var boundLength = max2(0, target.length - args.length);
12895
+ var boundArgs = [];
12896
+ for (var i2 = 0; i2 < boundLength; i2++) {
12897
+ boundArgs[i2] = "$" + i2;
12898
+ }
12899
+ bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
12900
+ if (target.prototype) {
12901
+ var Empty = function Empty2() {
12902
+ };
12903
+ Empty.prototype = target.prototype;
12904
+ bound.prototype = new Empty();
12905
+ Empty.prototype = null;
12906
+ }
12907
+ return bound;
12908
+ };
12909
+ return implementation;
12910
+ }
12911
+ var functionBind;
12912
+ var hasRequiredFunctionBind;
12913
+ function requireFunctionBind() {
12914
+ if (hasRequiredFunctionBind) return functionBind;
12915
+ hasRequiredFunctionBind = 1;
12916
+ var implementation2 = requireImplementation();
12917
+ functionBind = Function.prototype.bind || implementation2;
12918
+ return functionBind;
12919
+ }
12920
+ var functionCall;
12921
+ var hasRequiredFunctionCall;
12922
+ function requireFunctionCall() {
12923
+ if (hasRequiredFunctionCall) return functionCall;
12924
+ hasRequiredFunctionCall = 1;
12925
+ functionCall = Function.prototype.call;
12926
+ return functionCall;
12927
+ }
12895
12928
  var functionApply;
12896
12929
  var hasRequiredFunctionApply;
12897
12930
  function requireFunctionApply() {
@@ -12901,14 +12934,14 @@ function requireFunctionApply() {
12901
12934
  return functionApply;
12902
12935
  }
12903
12936
  var reflectApply = typeof Reflect !== "undefined" && Reflect && Reflect.apply;
12904
- var bind$2 = functionBind;
12937
+ var bind$2 = requireFunctionBind();
12905
12938
  var $apply$1 = requireFunctionApply();
12906
- var $call$2 = functionCall;
12939
+ var $call$2 = requireFunctionCall();
12907
12940
  var $reflectApply = reflectApply;
12908
12941
  var actualApply = $reflectApply || bind$2.call($call$2, $apply$1);
12909
- var bind$1 = functionBind;
12942
+ var bind$1 = requireFunctionBind();
12910
12943
  var $TypeError$4 = type;
12911
- var $call$1 = functionCall;
12944
+ var $call$1 = requireFunctionCall();
12912
12945
  var $actualApply = actualApply;
12913
12946
  var callBindApplyHelpers = function callBindBasic(args) {
12914
12947
  if (args.length < 1 || typeof args[0] !== "function") {
@@ -12974,8 +13007,8 @@ function requireHasown() {
12974
13007
  hasRequiredHasown = 1;
12975
13008
  var call = Function.prototype.call;
12976
13009
  var $hasOwn = Object.prototype.hasOwnProperty;
12977
- var bind3 = functionBind;
12978
- hasown = bind3.call(call, $hasOwn);
13010
+ var bind2 = requireFunctionBind();
13011
+ hasown = bind2.call(call, $hasOwn);
12979
13012
  return hasown;
12980
13013
  }
12981
13014
  var undefined$1;
@@ -12989,7 +13022,7 @@ var $TypeError$3 = type;
12989
13022
  var $URIError = uri;
12990
13023
  var abs = abs$1;
12991
13024
  var floor = floor$1;
12992
- var max = max$2;
13025
+ var max = max$1;
12993
13026
  var min = min$1;
12994
13027
  var pow = pow$1;
12995
13028
  var round$1 = round$2;
@@ -13023,7 +13056,7 @@ var getProto = requireGetProto();
13023
13056
  var $ObjectGPO = requireObject_getPrototypeOf();
13024
13057
  var $ReflectGPO = requireReflect_getPrototypeOf();
13025
13058
  var $apply = requireFunctionApply();
13026
- var $call = functionCall;
13059
+ var $call = requireFunctionCall();
13027
13060
  var needsEval = {};
13028
13061
  var TypedArray = typeof Uint8Array === "undefined" || !getProto ? undefined$1 : getProto(Uint8Array);
13029
13062
  var INTRINSICS = {
@@ -13194,13 +13227,13 @@ var LEGACY_ALIASES = {
13194
13227
  "%WeakMapPrototype%": ["WeakMap", "prototype"],
13195
13228
  "%WeakSetPrototype%": ["WeakSet", "prototype"]
13196
13229
  };
13197
- var bind2 = functionBind;
13230
+ var bind = requireFunctionBind();
13198
13231
  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);
13232
+ var $concat = bind.call($call, Array.prototype.concat);
13233
+ var $spliceApply = bind.call($apply, Array.prototype.splice);
13234
+ var $replace = bind.call($call, String.prototype.replace);
13235
+ var $strSlice = bind.call($call, String.prototype.slice);
13236
+ var $exec = bind.call($call, RegExp.prototype.exec);
13204
13237
  var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
13205
13238
  var reEscapeChar = /\\(\\)?/g;
13206
13239
  var stringToPath = function stringToPath2(string2) {
@@ -29947,8 +29980,13 @@ const EmbeddedFunnel = React__default.forwardRef(
29947
29980
  }
29948
29981
  }, [state.status]);
29949
29982
  useAbandonmentTracking(funnelContext, state);
29983
+ const toNextStepRef = useRef(null);
29950
29984
  const toNextStep2 = useCallback(() => {
29951
- actions.nextStep();
29985
+ if (toNextStepRef.current) {
29986
+ toNextStepRef.current();
29987
+ } else {
29988
+ actions.nextStep();
29989
+ }
29952
29990
  }, [actions]);
29953
29991
  useEffect(() => {
29954
29992
  if (state.status === QUALIFICATION_STATUS.qualifiedForMarketplace) {
@@ -30003,69 +30041,85 @@ const EmbeddedFunnel = React__default.forwardRef(
30003
30041
  const isFullscreen = mode === "fullscreen";
30004
30042
  const enabledSteps = state.qualification.steps.filter((q2) => !q2.disabled);
30005
30043
  const handleCancel = onCancel || (() => window.history.back());
30006
- return /* @__PURE__ */ jsx(
30044
+ return /* @__PURE__ */ jsxs(
30007
30045
  TrackingProvider,
30008
30046
  {
30009
30047
  funnelContextRef: funnelContext,
30010
30048
  updateContext,
30011
30049
  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,
30050
+ children: [
30051
+ /* @__PURE__ */ jsx(StepTransitionHandler, { toNextStepRef, nextStep: actions.nextStep }),
30052
+ /* @__PURE__ */ jsxs(
30053
+ FormWrapper,
30054
+ {
30055
+ $textColor: textColor,
30056
+ $mode: mode,
30057
+ tabIndex: 0,
30058
+ ref: ref2,
30059
+ "data-embedded-funnel": true,
30060
+ "data-ph-capture-attribute-funnel-step": stepId || void 0,
30061
+ "data-ph-capture-attribute-funnel-mode": mode,
30062
+ name: "step" in state.qualification ? state.qualification.step.id : state.status,
30063
+ onSubmit: (e2) => {
30064
+ e2.preventDefault();
30065
+ toNextStep2();
30066
+ },
30067
+ onKeyPressCapture: onKeyPress,
30068
+ children: [
30069
+ isFullscreen && state.status === QUALIFICATION_STATUS.answering && /* @__PURE__ */ jsx(
30070
+ FullscreenHeader,
30041
30071
  {
30042
- slides,
30043
- step: state.qualification.step,
30044
- highlightColor,
30045
- ratings,
30046
- renderTitle,
30047
- LayoutComponent,
30048
- titleTranslationKeys,
30049
- mode
30072
+ currentStep: state.qualification.stepIndex + 1,
30073
+ stepCount: enabledSteps.length,
30074
+ onCancel: handleCancel
30050
30075
  }
30051
30076
  ),
30052
- state.status === QUALIFICATION_STATUS.answered && /* @__PURE__ */ jsxs(Fragment, { children: [
30053
- /* @__PURE__ */ jsx(
30054
- LoadingIndicator,
30077
+ /* @__PURE__ */ jsx(Box, { position: "absolute", top: "-120px", ref: scrollHelperRef }),
30078
+ /* @__PURE__ */ jsxs(Box, { width: "100%", pb: isFullscreen ? 0 : 6, flexGrow: 1, display: "flex", flexDirection: "column", children: [
30079
+ state.status === QUALIFICATION_STATUS.answering && /* @__PURE__ */ jsx(
30080
+ EmbeddedQuestion,
30055
30081
  {
30056
- variant: onBackground === "dark" ? "light" : "dark"
30082
+ slides,
30083
+ step: state.qualification.step,
30084
+ highlightColor,
30085
+ ratings,
30086
+ renderTitle,
30087
+ LayoutComponent,
30088
+ titleTranslationKeys,
30089
+ mode
30057
30090
  }
30058
30091
  ),
30059
- /* @__PURE__ */ jsx(Box, { display: "none", children: /* @__PURE__ */ jsx(EmbeddedRequestPage, { ratings }) })
30092
+ state.status === QUALIFICATION_STATUS.answered && /* @__PURE__ */ jsxs(Fragment, { children: [
30093
+ /* @__PURE__ */ jsx(
30094
+ LoadingIndicator,
30095
+ {
30096
+ variant: onBackground === "dark" ? "light" : "dark"
30097
+ }
30098
+ ),
30099
+ /* @__PURE__ */ jsx(Box, { display: "none", children: /* @__PURE__ */ jsx(EmbeddedRequestPage, { ratings }) })
30100
+ ] })
30060
30101
  ] })
30061
- ] })
30062
- ]
30063
- }
30064
- )
30102
+ ]
30103
+ }
30104
+ )
30105
+ ]
30065
30106
  }
30066
30107
  );
30067
30108
  }
30068
30109
  );
30110
+ function StepTransitionHandler({ toNextStepRef, nextStep }) {
30111
+ const { trackStepCompletion } = useTracking();
30112
+ useLayoutEffect(() => {
30113
+ toNextStepRef.current = () => {
30114
+ trackStepCompletion();
30115
+ nextStep();
30116
+ };
30117
+ return () => {
30118
+ toNextStepRef.current = null;
30119
+ };
30120
+ }, [toNextStepRef, trackStepCompletion, nextStep]);
30121
+ return null;
30122
+ }
30069
30123
  const FormWrapper = styled.form`
30070
30124
  --embedded-text-color: ${({ $textColor }) => $textColor === "light" ? "white" : "rgb(60, 67, 64)"};
30071
30125
  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.10.0",
4
4
  "type": "module",
5
5
  "description": "Heycater embedded qualification funnel widget",
6
6
  "main": "dist/index.cjs.js",