@cloudscape-design/components 3.0.436 → 3.0.438

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/anchor-navigation/use-scroll-spy.js +1 -1
  2. package/anchor-navigation/use-scroll-spy.js.map +1 -1
  3. package/internal/analytics/components/analytics-funnel.d.ts.map +1 -1
  4. package/internal/analytics/components/analytics-funnel.js +7 -4
  5. package/internal/analytics/components/analytics-funnel.js.map +1 -1
  6. package/internal/analytics/context/analytics-context.d.ts +2 -1
  7. package/internal/analytics/context/analytics-context.d.ts.map +1 -1
  8. package/internal/analytics/context/analytics-context.js +1 -0
  9. package/internal/analytics/context/analytics-context.js.map +1 -1
  10. package/internal/analytics/hooks/use-funnel.d.ts.map +1 -1
  11. package/internal/analytics/hooks/use-funnel.js +7 -2
  12. package/internal/analytics/hooks/use-funnel.js.map +1 -1
  13. package/internal/analytics/interfaces.d.ts +1 -0
  14. package/internal/analytics/interfaces.d.ts.map +1 -1
  15. package/internal/analytics/interfaces.js.map +1 -1
  16. package/internal/environment.js +1 -1
  17. package/internal/environment.json +1 -1
  18. package/internal/manifest.json +1 -1
  19. package/package.json +1 -1
  20. package/popover/utils/positions.js +4 -4
  21. package/popover/utils/positions.js.map +1 -1
  22. package/table/column-widths-utils.d.ts +1 -0
  23. package/table/column-widths-utils.d.ts.map +1 -1
  24. package/table/column-widths-utils.js +18 -0
  25. package/table/column-widths-utils.js.map +1 -1
  26. package/table/internal.d.ts.map +1 -1
  27. package/table/internal.js +5 -4
  28. package/table/internal.js.map +1 -1
  29. package/table/sticky-columns/use-sticky-columns.js +1 -1
  30. package/table/sticky-columns/use-sticky-columns.js.map +1 -1
  31. package/table/thead.d.ts +0 -1
  32. package/table/thead.d.ts.map +1 -1
  33. package/table/thead.js +3 -18
  34. package/table/thead.js.map +1 -1
  35. package/table/use-column-widths.d.ts +5 -3
  36. package/table/use-column-widths.d.ts.map +1 -1
  37. package/table/use-column-widths.js +57 -11
  38. package/table/use-column-widths.js.map +1 -1
  39. package/table/use-sticky-header.d.ts.map +1 -1
  40. package/table/use-sticky-header.js +0 -13
  41. package/table/use-sticky-header.js.map +1 -1
@@ -25,7 +25,7 @@ export default function useScrollSpy({ hrefs, scrollSpyOffset, activeHref, }) {
25
25
  setLastAnchorExists(isBrowser && !!document.getElementById((_a = hrefs[hrefs.length - 1]) === null || _a === void 0 ? void 0 : _a.slice(1)));
26
26
  }, [hrefs]);
27
27
  // Get the bounding rectangle of an element by href
28
- const getRectByHref = useCallback(href => {
28
+ const getRectByHref = useCallback((href) => {
29
29
  var _a;
30
30
  return (_a = document.getElementById(href.slice(1))) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
31
31
  }, []);
@@ -1 +1 @@
1
- {"version":3,"file":"use-scroll-spy.js","sourceRoot":"lib/default/","sources":["anchor-navigation/use-scroll-spy.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzD,MAAM,SAAS,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC;AAEhD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,KAAK,EACL,eAAe,EACf,UAAU,GAKX;IACC,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAqB,UAAU,CAAC,CAAC;IAC/E,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEhE,SAAS,CAAC,GAAG,EAAE;QACb,cAAc,CAAC,UAAU,CAAC,CAAC;IAC7B,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAEjB,SAAS,CAAC,GAAG,EAAE;;QACb,mBAAmB,CAAC,SAAS,IAAI,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC,MAAA,KAAK,CAA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C,OAAO,IAAI,IAAI,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,WAAW,CAAC;QACnD,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC,CAAC;IAE3B,uBAAuB;IACvB,MAAM,YAAY,GAAG,WAAW,CAAC,GAAG,EAAE;QACpC,IAAI,UAAU,IAAI,CAAC,SAAS,EAAE;YAC5B,OAAO;SACR;QAED,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;QAE3B,IAAI,QAAQ,CAAC,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,WAAW,IAAI,YAAY,EAAE,EAAE;YACrE,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;SACzC;aAAM;YACL,cAAc,CAAC,cAAc,EAAE,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;SACtF;IACH,CAAC,EAAE,CAAC,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,kBAAkB,EAAE,KAAK,CAAC,CAAC,CAAC;IAE1E,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,SAAS,EAAE;YACb,YAAY,EAAE,CAAC;YACf,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;YACnE,OAAO,GAAG,EAAE;gBACV,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;YACrD,CAAC,CAAC;SACH;IACH,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IAEnB,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { useCallback, useEffect, useState } from 'react';\n\nconst isBrowser = typeof window !== 'undefined';\n\n/**\n * Hook to implement scroll-spy functionality.\n *\n * @param hrefs An array of href strings that correspond to the IDs of the target elements on the page.\n * The hrefs should be sorted in the order they appear on the page for accurate scroll-spy behavior.\n * @param scrollSpyOffset The number of pixels to offset from the top of the document when activating anchors.\n * Useful for accommodating fixed or sticky headers.\n * @param activeHref The currently active href. If provided, the hook will operate in a controlled manner,\n * and the scroll-spy logic will be disabled.\n *\n * @returns {string | undefined} - The href of the currently active element as per scroll position, or undefined if none is active.\n */\nexport default function useScrollSpy({\n hrefs,\n scrollSpyOffset,\n activeHref,\n}: {\n hrefs: string[];\n scrollSpyOffset: number;\n activeHref?: string;\n}): string | undefined {\n const [currentHref, setCurrentHref] = useState<string | undefined>(activeHref);\n const [lastAnchorExists, setLastAnchorExists] = useState(false);\n\n useEffect(() => {\n setCurrentHref(activeHref);\n }, [activeHref]);\n\n useEffect(() => {\n setLastAnchorExists(isBrowser && !!document.getElementById(hrefs[hrefs.length - 1]?.slice(1)));\n }, [hrefs]);\n\n // Get the bounding rectangle of an element by href\n const getRectByHref = useCallback(href => {\n return document.getElementById(href.slice(1))?.getBoundingClientRect();\n }, []);\n\n // Check if we're scrolled to the bottom of the page\n const isPageBottom = useCallback(() => {\n return lastAnchorExists && Math.ceil(window.scrollY) >= Math.floor(document.body.scrollHeight - window.innerHeight);\n }, [lastAnchorExists]);\n\n // Find the first href for which the element is within the viewport\n const findHrefInView = useCallback(() => {\n return hrefs.find(href => {\n const rect = getRectByHref(href);\n return rect && rect.bottom <= window.innerHeight && rect.top >= scrollSpyOffset;\n });\n }, [getRectByHref, scrollSpyOffset, hrefs]);\n\n // Find the last href where its element is above or within the viewport\n const findLastHrefInView = useCallback(() => {\n return [...hrefs].reverse().find(href => {\n const rect = getRectByHref(href);\n return rect && rect.bottom <= window.innerHeight;\n });\n }, [getRectByHref, hrefs]);\n\n // Scroll event handler\n const handleScroll = useCallback(() => {\n if (activeHref || !isBrowser) {\n return;\n }\n\n const { scrollY } = window;\n\n if (document.body.scrollHeight > window.innerHeight && isPageBottom()) {\n setCurrentHref(hrefs[hrefs.length - 1]);\n } else {\n setCurrentHref(findHrefInView() || (scrollY > 0 ? findLastHrefInView() : undefined));\n }\n }, [activeHref, isPageBottom, findHrefInView, findLastHrefInView, hrefs]);\n\n useEffect(() => {\n if (isBrowser) {\n handleScroll();\n window.addEventListener('scroll', handleScroll, { passive: true });\n return () => {\n window.removeEventListener('scroll', handleScroll);\n };\n }\n }, [handleScroll]);\n\n return currentHref;\n}\n"]}
1
+ {"version":3,"file":"use-scroll-spy.js","sourceRoot":"lib/default/","sources":["anchor-navigation/use-scroll-spy.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzD,MAAM,SAAS,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC;AAEhD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,KAAK,EACL,eAAe,EACf,UAAU,GAKX;IACC,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAqB,UAAU,CAAC,CAAC;IAC/E,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEhE,SAAS,CAAC,GAAG,EAAE;QACb,cAAc,CAAC,UAAU,CAAC,CAAC;IAC7B,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAEjB,SAAS,CAAC,GAAG,EAAE;;QACb,mBAAmB,CAAC,SAAS,IAAI,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC,MAAA,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,0CAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACjG,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,mDAAmD;IACn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C;IAE3B,uBAAuB;IACvB,MAAM,YAAY,GAAG,WAAW,CAAC,GAAG,EAAE;QACpC,IAAI,UAAU,IAAI,CAAC,SAAS,EAAE;YAC5B,OAAO;SACR;QAED,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;QAE3B,IAAI,QAAQ,CAAC,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,WAAW,IAAI,YAAY,EAAE,EAAE;YACrE,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;SACzC;aAAM;YACL,cAAc,CAAC,cAAc,EAAE,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;SACtF;IACH,CAAC,EAAE,CAAC,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,kBAAkB,EAAE,KAAK,CAAC,CAAC,CAAC;IAE1E,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,SAAS,EAAE;YACb,YAAY,EAAE,CAAC;YACf,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;YACnE,OAAO,GAAG,EAAE;gBACV,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;YACrD,CAAC,CAAC;SACH;IACH,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IAEnB,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { useCallback, useEffect, useState } from 'react';\n\nconst isBrowser = typeof window !== 'undefined';\n\n/**\n * Hook to implement scroll-spy functionality.\n *\n * @param hrefs An array of href strings that correspond to the IDs of the target elements on the page.\n * The hrefs should be sorted in the order they appear on the page for accurate scroll-spy behavior.\n * @param scrollSpyOffset The number of pixels to offset from the top of the document when activating anchors.\n * Useful for accommodating fixed or sticky headers.\n * @param activeHref The currently active href. If provided, the hook will operate in a controlled manner,\n * and the scroll-spy logic will be disabled.\n *\n * @returns {string | undefined} - The href of the currently active element as per scroll position, or undefined if none is active.\n */\nexport default function useScrollSpy({\n hrefs,\n scrollSpyOffset,\n activeHref,\n}: {\n hrefs: string[];\n scrollSpyOffset: number;\n activeHref?: string;\n}): string | undefined {\n const [currentHref, setCurrentHref] = useState<string | undefined>(activeHref);\n const [lastAnchorExists, setLastAnchorExists] = useState(false);\n\n useEffect(() => {\n setCurrentHref(activeHref);\n }, [activeHref]);\n\n useEffect(() => {\n setLastAnchorExists(isBrowser && !!document.getElementById(hrefs[hrefs.length - 1]?.slice(1)));\n }, [hrefs]);\n\n // Get the bounding rectangle of an element by href\n const getRectByHref = useCallback((href: string) => {\n return document.getElementById(href.slice(1))?.getBoundingClientRect();\n }, []);\n\n // Check if we're scrolled to the bottom of the page\n const isPageBottom = useCallback(() => {\n return lastAnchorExists && Math.ceil(window.scrollY) >= Math.floor(document.body.scrollHeight - window.innerHeight);\n }, [lastAnchorExists]);\n\n // Find the first href for which the element is within the viewport\n const findHrefInView = useCallback(() => {\n return hrefs.find(href => {\n const rect = getRectByHref(href);\n return rect && rect.bottom <= window.innerHeight && rect.top >= scrollSpyOffset;\n });\n }, [getRectByHref, scrollSpyOffset, hrefs]);\n\n // Find the last href where its element is above or within the viewport\n const findLastHrefInView = useCallback(() => {\n return [...hrefs].reverse().find(href => {\n const rect = getRectByHref(href);\n return rect && rect.bottom <= window.innerHeight;\n });\n }, [getRectByHref, hrefs]);\n\n // Scroll event handler\n const handleScroll = useCallback(() => {\n if (activeHref || !isBrowser) {\n return;\n }\n\n const { scrollY } = window;\n\n if (document.body.scrollHeight > window.innerHeight && isPageBottom()) {\n setCurrentHref(hrefs[hrefs.length - 1]);\n } else {\n setCurrentHref(findHrefInView() || (scrollY > 0 ? findLastHrefInView() : undefined));\n }\n }, [activeHref, isPageBottom, findHrefInView, findLastHrefInView, hrefs]);\n\n useEffect(() => {\n if (isBrowser) {\n handleScroll();\n window.addEventListener('scroll', handleScroll, { passive: true });\n return () => {\n window.removeEventListener('scroll', handleScroll);\n };\n }\n }, [handleScroll]);\n\n return currentHref;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"analytics-funnel.d.ts","sourceRoot":"lib/default/","sources":["internal/analytics/components/analytics-funnel.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAkD,MAAM,OAAO,CAAC;AAEvE,OAAO,EAKL,sBAAsB,EAEtB,yBAAyB,EAC1B,MAAM,8BAA8B,CAAC;AAQtC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,iBAAiB,EAAwB,MAAM,eAAe,CAAC;AAatG,eAAO,MAAM,cAAc,QAAQ,CAAC;AAEpC,UAAU,oBAAoB;IAC5B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,iBAAiB,CAAC,EAAE,iBAAiB,EAAE,CAAC;IACxC,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B,UAAU,EAAE,WAAW,CAAC,YAAY,CAAC,CAAC;IACtC,mBAAmB,EAAE,WAAW,CAAC,qBAAqB,CAAC,CAAC;IACxD,gBAAgB,EAAE,WAAW,CAAC,kBAAkB,CAAC,CAAC;CACnD;AAED,eAAO,MAAM,eAAe,UAAW,oBAAoB,gBAa1D,CAAC;AACF,eAAO,MAAM,kCAAkC,kCAAkC,CAAC;AA0KlF,UAAU,wBAAwB;IAChC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,KAAK,EAAE,sBAAsB,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC;IAClF,gBAAgB,CAAC,EAAE,eAAe,CAAC,kBAAkB,CAAC,CAAC;IACvD,UAAU,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;CAC3C;AAED,eAAO,MAAM,mBAAmB,UAAW,wBAAwB,gBAMlE,CA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AAwB,gBAMlE,CAAC;AA8JF,UAAU,2BAA2B;IACnC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,KAAK,EAAE,yBAAyB,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC;CACtF;AAED,eAAO,MAAM,sBAAsB,iBAAkB,2BAA2B,gBAiG/E,CAAC"}
@@ -193,7 +193,8 @@ function getSubStepConfiguration() {
193
193
  });
194
194
  return subStepConfiguration;
195
195
  }
196
- function useStepChangeListener(handler) {
196
+ function useStepChangeListener(stepNumber, handler) {
197
+ const subStepConfiguration = useRef({});
197
198
  /*
198
199
  Chosen so that it's hopefully shorter than a user interaction, but gives enough time for the
199
200
  amount of containers to stabilise.
@@ -211,13 +212,14 @@ function useStepChangeListener(handler) {
211
212
  /* We debounce this handler, so that multiple containers can change at once without causing
212
213
  too many events. */
213
214
  const stepChangeCallback = useDebounceCallback(() => {
215
+ subStepConfiguration.current[stepNumber] = getSubStepConfiguration();
214
216
  // We don't want to emit the event after the component has been unmounted.
215
217
  if (!listenForSubStepChanges.current) {
216
218
  return;
217
219
  }
218
- handler(getSubStepConfiguration());
220
+ handler(subStepConfiguration.current[stepNumber]);
219
221
  }, SUBSTEP_CHANGE_DEBOUNCE);
220
- return stepChangeCallback;
222
+ return { onStepChange: stepChangeCallback, subStepConfiguration };
221
223
  }
222
224
  const InnerAnalyticsFunnelStep = (_a) => {
223
225
  var { children, stepNumber } = _a, rest = __rest(_a, ["children", "stepNumber"]);
@@ -228,7 +230,7 @@ const InnerAnalyticsFunnelStep = (_a) => {
228
230
  const funnelStepProps = { [DATA_ATTR_FUNNEL_STEP]: stepNumber };
229
231
  const subStepCount = useRef(0);
230
232
  const stepNameSelector = rest.stepNameSelector || funnelNameSelector;
231
- const onStepChange = useStepChangeListener(subStepConfiguration => {
233
+ const { onStepChange, subStepConfiguration } = useStepChangeListener(stepNumber, subStepConfiguration => {
232
234
  var _a;
233
235
  if (!funnelInteractionId) {
234
236
  return;
@@ -304,6 +306,7 @@ const InnerAnalyticsFunnelStep = (_a) => {
304
306
  isInStep: true,
305
307
  funnelInteractionId,
306
308
  onStepChange,
309
+ subStepConfiguration,
307
310
  };
308
311
  /*
309
312
  If this step is inside another step which already reports events as part of an active
@@ -1 +1 @@
1
- {"version":3,"file":"analytics-funnel.js","sourceRoot":"lib/default/","sources":["internal/analytics/components/analytics-funnel.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEvE,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,aAAa,GAKd,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAC;AAWpC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAA2B,EAAE,EAAE;IAC7D,MAAM,EAAE,UAAU,EAAE,GAAG,SAAS,EAAE,CAAC;IACnC;;;;;MAKE;IACF,IAAI,UAAU,IAAI,KAAK,CAAC,UAAU,KAAK,aAAa,EAAE;QACpD,OAAO,0CAAG,KAAK,CA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AmB;QACnB,WAAW;QACX,gBAAgB;QAChB,UAAU;QACV,mBAAmB;QACnB,eAAe;QACf,oBAAoB;QACpB,QAAQ;QACR,UAAU;KACX,CAAC,CAAC;IAEH,OAAO,CACL,oBAAC,oBAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,OAAO,IAC1C,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAChC,CACjC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useContext, useEffect, useRef, useState } from 'react';\n\nimport {\n FunnelStepContext,\n FunnelSubStepContext,\n FunnelContext,\n FunnelContextValue,\n FunnelStepContextValue,\n FunnelState,\n FunnelSubStepContextValue,\n} from '../context/analytics-context';\nimport { useFunnel, useFunnelStep } from '../hooks/use-funnel';\nimport { useUniqueId } from '../../hooks/use-unique-id';\nimport { useVisualRefresh } from '../../hooks/use-visual-mode';\n\nimport { PACKAGE_VERSION } from '../../environment';\n\nimport { FunnelMetrics } from '../index';\nimport { FunnelProps, FunnelStepProps, StepConfiguration, SubStepConfiguration } from '../interfaces';\n\nimport {\n DATA_ATTR_FUNNEL_STEP,\n getFunnelNameSelector,\n getNameFromSelector,\n getSubStepAllSelector,\n getSubStepNameSelector,\n getSubStepSelector,\n} from '../selectors';\nimport { useDebounceCallback } from '../../hooks/use-debounce-callback';\nimport { nodeBelongs } from '../../utils/node-belongs';\n\nexport const FUNNEL_VERSION = '1.4';\n\ninterface AnalyticsFunnelProps {\n children?: React.ReactNode;\n stepConfiguration?: StepConfiguration[];\n funnelNameSelectors?: string[];\n funnelType: FunnelProps['funnelType'];\n optionalStepNumbers: FunnelProps['optionalStepNumbers'];\n totalFunnelSteps: FunnelProps['totalFunnelSteps'];\n}\n\nexport const AnalyticsFunnel = (props: AnalyticsFunnelProps) => {\n const { isInFunnel } = useFunnel();\n /*\n If the current funnel component is a Form (i.e. single-page funnel), it should\n defer its funnel-handling to a parent Form element, if present.\n Wizards (i.e. multi-page funnels) always take highest precedence for handling funnels,\n and do not defer to any other element.\n */\n if (isInFunnel && props.funnelType === 'single-page') {\n return <>{props.children}</>;\n }\n\n return <InnerAnalyticsFunnel {...props} />;\n};\nexport const CREATION_EDIT_FLOW_DONE_EVENT_NAME = 'awsui-creation-edit-flow-done';\n\nconst onFunnelCancelled = ({ funnelInteractionId }: { funnelInteractionId: string }) => {\n FunnelMetrics.funnelCancelled({ funnelInteractionId });\n document.dispatchEvent(new Event(CREATION_EDIT_FLOW_DONE_EVENT_NAME));\n};\n\nconst onFunnelComplete = ({ funnelInteractionId }: { funnelInteractionId: string }) => {\n FunnelMetrics.funnelComplete({ funnelInteractionId });\n document.dispatchEvent(new Event(CREATION_EDIT_FLOW_DONE_EVENT_NAME));\n};\n\nfunction evaluateSelectors(selectors: string[], defaultSelector: string) {\n for (const selector of selectors) {\n const element = document.querySelector(selector);\n if (element) {\n return selector;\n }\n }\n\n return defaultSelector;\n}\n\nconst InnerAnalyticsFunnel = ({ children, stepConfiguration, ...props }: AnalyticsFunnelProps) => {\n const [funnelInteractionId, setFunnelInteractionId] = useState<string>('');\n const [submissionAttempt, setSubmissionAttempt] = useState(0);\n const isVisualRefresh = useVisualRefresh();\n const funnelState = useRef<FunnelState>('default');\n const funnelNameSelector = useRef<string>(getFunnelNameSelector());\n const errorCount = useRef<number>(0);\n const loadingButtonCount = useRef<number>(0);\n const wizardCount = useRef<number>(0);\n const latestFocusCleanupFunction = useRef<undefined | (() => void)>(undefined);\n\n // This useEffect hook is run once on component mount to initiate the funnel analytics.\n // It first calls the 'funnelStart' method from FunnelMetrics, providing all necessary details\n // about the funnel, and receives a unique interaction id.\n // This unique interaction id is then stored in the state for further use.\n //\n // On component unmount, it checks whether the funnel was successfully completed.\n // Based on this, it either calls 'funnelComplete' or 'funnelCancelled' method from FunnelMetrics.\n //\n // The eslint-disable is required as we deliberately want this effect to run only once on mount and unmount,\n // hence we do not provide any dependencies.\n useEffect(() => {\n /*\n We run this effect with a delay, in order to detect whether this funnel contains a Wizard.\n If it does contain a Wizard, that Wizard should take precedence for handling the funnel, and\n this current funnel component should do nothing.\n */\n let funnelInteractionId: string;\n const handle = setTimeout(() => {\n funnelNameSelector.current = evaluateSelectors(props.funnelNameSelectors || [], getFunnelNameSelector());\n\n if (props.funnelType === 'single-page' && wizardCount.current > 0) {\n return;\n }\n\n // Reset the state, in case the component was re-mounted.\n funnelState.current = 'default';\n\n const singleStepFlowStepConfiguration = [\n { number: 1, isOptional: false, name: getNameFromSelector(funnelNameSelector.current) ?? '' },\n ];\n\n funnelInteractionId = FunnelMetrics.funnelStart({\n funnelNameSelector: funnelNameSelector.current,\n optionalStepNumbers: props.optionalStepNumbers,\n funnelType: props.funnelType,\n totalFunnelSteps: props.totalFunnelSteps,\n componentVersion: PACKAGE_VERSION,\n theme: isVisualRefresh ? 'vr' : 'classic',\n funnelVersion: FUNNEL_VERSION,\n stepConfiguration: stepConfiguration ?? singleStepFlowStepConfiguration,\n });\n\n setFunnelInteractionId(funnelInteractionId);\n }, 1);\n\n /*\n A funnel counts as \"successful\" if it is unmounted after being \"complete\".\n */\n /* eslint-disable react-hooks/exhaustive-deps */\n return () => {\n clearTimeout(handle);\n if (props.funnelType === 'single-page' && wizardCount.current > 0) {\n return;\n }\n\n if (funnelState.current === 'validating') {\n // Finish the validation phase early.\n onFunnelComplete({ funnelInteractionId });\n funnelState.current = 'complete';\n }\n\n if (funnelState.current === 'complete') {\n FunnelMetrics.funnelSuccessful({ funnelInteractionId });\n } else {\n onFunnelCancelled({ funnelInteractionId });\n funnelState.current = 'cancelled';\n }\n };\n }, []);\n /* eslint-enable react-hooks/exhaustive-deps */\n\n const funnelSubmit = () => {\n funnelState.current = 'validating';\n\n /*\n When the user attempts to submit the form, we wait for 50 milliseconds before checking\n if any form validation errors are present. This value was chosen to give enough time\n for validation and rerendering to occur, but be low enough that the user will not\n be able to take further action in the meantime.\n */\n const VALIDATION_WAIT_DELAY = 50;\n /*\n Loading is expected to take longer than validation, so we can keep the pressure on the CPU low.\n */\n const LOADING_WAIT_DELAY = 100;\n\n const checkForCompleteness = () => {\n if (funnelState.current === 'complete') {\n return;\n }\n\n if (loadingButtonCount.current > 0) {\n setTimeout(checkForCompleteness, LOADING_WAIT_DELAY);\n return;\n }\n\n if (errorCount.current === 0) {\n /*\n If no validation errors are rendered, we treat the funnel as complete.\n */\n onFunnelComplete({ funnelInteractionId });\n funnelState.current = 'complete';\n } else {\n funnelState.current = 'default';\n }\n };\n\n setTimeout(checkForCompleteness, VALIDATION_WAIT_DELAY);\n };\n\n const funnelNextOrSubmitAttempt = () => setSubmissionAttempt(i => i + 1);\n\n const funnelCancel = () => {};\n\n const funnelContextValue: FunnelContextValue = {\n funnelInteractionId,\n setFunnelInteractionId,\n funnelType: props.funnelType,\n optionalStepNumbers: props.optionalStepNumbers,\n totalFunnelSteps: props.totalFunnelSteps,\n funnelNameSelector: funnelNameSelector.current,\n funnelSubmit,\n funnelCancel,\n submissionAttempt,\n funnelNextOrSubmitAttempt,\n funnelState,\n errorCount,\n loadingButtonCount,\n latestFocusCleanupFunction,\n isInFunnel: true,\n wizardCount,\n };\n\n return <FunnelContext.Provider value={funnelContextValue}>{children}</FunnelContext.Provider>;\n};\n\ninterface AnalyticsFunnelStepProps {\n children?: React.ReactNode | ((props: FunnelStepContextValue) => React.ReactNode);\n stepNameSelector?: FunnelStepProps['stepNameSelector'];\n stepNumber: FunnelStepProps['stepNumber'];\n}\n\nexport const AnalyticsFunnelStep = (props: AnalyticsFunnelStepProps) => {\n /*\n This wrapper is used to apply a `key` property to the actual (inner) AnalyticsFunnelStep\n element. This allows us to keep the state and effects separate per step.\n */\n return <InnerAnalyticsFunnelStep {...props} key={props.stepNumber} />;\n};\n\nfunction getSubStepConfiguration() {\n const subSteps = Array.from(document.querySelectorAll<HTMLElement>(getSubStepAllSelector()));\n\n const subStepConfiguration = subSteps.map((substep, index) => {\n const name = substep.querySelector<HTMLElement>(getSubStepNameSelector())?.innerText?.trim() ?? '';\n return {\n name,\n number: index + 1,\n };\n });\n return subStepConfiguration;\n}\n\nfunction useStepChangeListener(handler: (stepConfiguration: SubStepConfiguration[]) => void) {\n /*\n Chosen so that it's hopefully shorter than a user interaction, but gives enough time for the\n amount of containers to stabilise.\n */\n const SUBSTEP_CHANGE_DEBOUNCE = 50;\n\n const listenForSubStepChanges = useRef(false);\n useEffect(() => {\n // We prevent emitting the event on the first render.\n const handle = setTimeout(() => (listenForSubStepChanges.current = true), SUBSTEP_CHANGE_DEBOUNCE);\n\n return () => {\n clearTimeout(handle);\n listenForSubStepChanges.current = false;\n };\n }, []);\n\n /* We debounce this handler, so that multiple containers can change at once without causing \n too many events. */\n const stepChangeCallback = useDebounceCallback(() => {\n // We don't want to emit the event after the component has been unmounted.\n if (!listenForSubStepChanges.current) {\n return;\n }\n\n handler(getSubStepConfiguration());\n }, SUBSTEP_CHANGE_DEBOUNCE);\n\n return stepChangeCallback;\n}\n\nconst InnerAnalyticsFunnelStep = ({ children, stepNumber, ...rest }: AnalyticsFunnelStepProps) => {\n const { funnelInteractionId, funnelNameSelector, funnelState, funnelType } = useFunnel();\n const parentStep = useFunnelStep();\n const parentStepExists = parentStep.isInStep;\n const parentStepFunnelInteractionId = parentStep.funnelInteractionId;\n\n const funnelStepProps = { [DATA_ATTR_FUNNEL_STEP]: stepNumber };\n\n const subStepCount = useRef<number>(0);\n\n const stepNameSelector = rest.stepNameSelector || funnelNameSelector;\n const onStepChange = useStepChangeListener(subStepConfiguration => {\n if (!funnelInteractionId) {\n return;\n }\n const stepName = getNameFromSelector(stepNameSelector) ?? '';\n\n FunnelMetrics.funnelStepChange({\n funnelInteractionId,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n totalSubSteps: subStepCount.current,\n subStepConfiguration,\n });\n });\n\n // This useEffect hook is used to track the start and completion of interaction with the step.\n // On mount, if there is a valid funnel interaction id, it calls the 'funnelStepStart' method from FunnelMetrics\n // to record the beginning of the interaction with the current step.\n // On unmount, it does a similar thing but this time calling 'funnelStepComplete' to record the completion of the interaction.\n useEffect(() => {\n if (!funnelInteractionId) {\n // This step is not inside an active funnel.\n return;\n }\n if (parentStepExists && parentStepFunnelInteractionId) {\n /*\n This step is inside another step, which already reports events as\n part of an active funnel (i.e. that step is not a parent of a Wizard).\n Thus, this current step does not need to report any events.\n */\n return;\n }\n\n const stepName = getNameFromSelector(stepNameSelector);\n\n if (funnelState.current === 'default') {\n FunnelMetrics.funnelStepStart({\n funnelInteractionId,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n totalSubSteps: subStepCount.current,\n subStepConfiguration: getSubStepConfiguration(),\n });\n }\n\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n if (funnelState.current !== 'cancelled') {\n FunnelMetrics.funnelStepComplete({\n funnelInteractionId,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n totalSubSteps: subStepCount.current,\n });\n }\n };\n }, [\n funnelInteractionId,\n stepNumber,\n stepNameSelector,\n funnelState,\n parentStepExists,\n funnelType,\n parentStepFunnelInteractionId,\n ]);\n\n const contextValue: FunnelStepContextValue = {\n stepNumber,\n stepNameSelector,\n funnelStepProps,\n subStepCount,\n isInStep: true,\n funnelInteractionId,\n onStepChange,\n };\n\n /*\n If this step is inside another step which already reports events as part of an active\n funnel (i.e. that step is not a parent of a Wizard), the current step becomes invisible\n in the hierarchy by passing the context of its parent through.\n */\n const effectiveContextValue = parentStepExists && parentStepFunnelInteractionId ? parentStep : contextValue;\n\n return (\n <FunnelStepContext.Provider value={effectiveContextValue}>\n {typeof children === 'function' ? children(effectiveContextValue) : children}\n </FunnelStepContext.Provider>\n );\n};\ninterface AnalyticsFunnelSubStepProps {\n children?: React.ReactNode | ((props: FunnelSubStepContextValue) => React.ReactNode);\n}\n\nexport const AnalyticsFunnelSubStep = ({ children }: AnalyticsFunnelSubStepProps) => {\n const subStepId = useUniqueId('substep');\n const subStepSelector = getSubStepSelector(subStepId);\n const subStepNameSelector = getSubStepNameSelector(subStepId);\n const subStepRef = useRef<HTMLDivElement | null>(null);\n const { subStepCount, onStepChange } = useFunnelStep();\n const mousePressed = useRef<boolean>(false);\n const isFocusedSubStep = useRef<boolean>(false);\n const focusCleanupFunction = useRef<undefined | (() => void)>(undefined);\n const { funnelState, funnelInteractionId } = useFunnel();\n const { stepNumber, stepNameSelector } = useFunnelStep();\n\n const newContext: FunnelSubStepContextValue = {\n subStepSelector,\n subStepNameSelector,\n subStepId,\n subStepRef,\n mousePressed,\n isFocusedSubStep,\n focusCleanupFunction,\n isNestedSubStep: false,\n };\n\n const inheritedContext = { ...useContext(FunnelSubStepContext), isNestedSubStep: true };\n\n const isNested = Boolean(inheritedContext.subStepId);\n\n useEffect(() => {\n if (!isNested) {\n subStepCount.current++;\n onStepChange();\n\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n subStepCount.current--;\n onStepChange();\n };\n }\n }, [isNested, subStepCount, onStepChange]);\n\n const context = isNested ? inheritedContext : newContext;\n\n useEffect(() => {\n if (isNested || !subStepRef.current) {\n return;\n }\n\n const onMouseDown = () => (mousePressed.current = true);\n\n const onMouseUp = async () => {\n mousePressed.current = false;\n\n if (!isFocusedSubStep.current) {\n return;\n }\n\n /*\n Some mouse events result in an element being focused. However,\n this happens only _after_ the onMouseUp event. We yield the\n event loop here, so that `document.activeElement` has the\n correct new value. \n */\n await new Promise(r => setTimeout(r, 1));\n\n if (!subStepRef.current || !document.activeElement || !nodeBelongs(subStepRef.current, document.activeElement)) {\n isFocusedSubStep.current = false;\n\n /*\n Run this substep's own focus cleanup function if another substep\n hasn't already done it for us.\n */\n focusCleanupFunction.current?.();\n }\n };\n window.addEventListener('mousedown', onMouseDown);\n window.addEventListener('mouseup', onMouseUp);\n return () => {\n window.removeEventListener('mousedown', onMouseDown);\n window.removeEventListener('mouseup', onMouseUp);\n };\n }, [\n funnelInteractionId,\n funnelState,\n stepNameSelector,\n stepNumber,\n subStepNameSelector,\n subStepSelector,\n focusCleanupFunction,\n isNested,\n subStepRef,\n ]);\n\n return (\n <FunnelSubStepContext.Provider value={context}>\n {typeof children === 'function' ? children(context) : children}\n </FunnelSubStepContext.Provider>\n );\n};\n"]}
1
+ {"version":3,"file":"analytics-funnel.js","sourceRoot":"lib/default/","sources":["internal/analytics/components/analytics-funnel.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEvE,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,aAAa,GAKd,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAC;AAWpC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAA2B,EAAE,EAAE;IAC7D,MAAM,EAAE,UAAU,EAAE,GAAG,SAAS,E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B,CAAC,OAAO,oEAAI,CAAC;aAClC;QACH,CAAC,CAAA,CAAC;QACF,MAAM,CAAC,gBAAgB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;QAClD,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAC9C,OAAO,GAAG,EAAE;YACV,MAAM,CAAC,mBAAmB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;YACrD,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACnD,CAAC,CAAC;IACJ,CAAC,EAAE;QACD,mBAAmB;QACnB,WAAW;QACX,gBAAgB;QAChB,UAAU;QACV,mBAAmB;QACnB,eAAe;QACf,oBAAoB;QACpB,QAAQ;QACR,UAAU;KACX,CAAC,CAAC;IAEH,OAAO,CACL,oBAAC,oBAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,OAAO,IAC1C,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAChC,CACjC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useContext, useEffect, useRef, useState } from 'react';\n\nimport {\n FunnelStepContext,\n FunnelSubStepContext,\n FunnelContext,\n FunnelContextValue,\n FunnelStepContextValue,\n FunnelState,\n FunnelSubStepContextValue,\n} from '../context/analytics-context';\nimport { useFunnel, useFunnelStep } from '../hooks/use-funnel';\nimport { useUniqueId } from '../../hooks/use-unique-id';\nimport { useVisualRefresh } from '../../hooks/use-visual-mode';\n\nimport { PACKAGE_VERSION } from '../../environment';\n\nimport { FunnelMetrics } from '../index';\nimport { FunnelProps, FunnelStepProps, StepConfiguration, SubStepConfiguration } from '../interfaces';\n\nimport {\n DATA_ATTR_FUNNEL_STEP,\n getFunnelNameSelector,\n getNameFromSelector,\n getSubStepAllSelector,\n getSubStepNameSelector,\n getSubStepSelector,\n} from '../selectors';\nimport { useDebounceCallback } from '../../hooks/use-debounce-callback';\nimport { nodeBelongs } from '../../utils/node-belongs';\n\nexport const FUNNEL_VERSION = '1.4';\n\ninterface AnalyticsFunnelProps {\n children?: React.ReactNode;\n stepConfiguration?: StepConfiguration[];\n funnelNameSelectors?: string[];\n funnelType: FunnelProps['funnelType'];\n optionalStepNumbers: FunnelProps['optionalStepNumbers'];\n totalFunnelSteps: FunnelProps['totalFunnelSteps'];\n}\n\nexport const AnalyticsFunnel = (props: AnalyticsFunnelProps) => {\n const { isInFunnel } = useFunnel();\n /*\n If the current funnel component is a Form (i.e. single-page funnel), it should\n defer its funnel-handling to a parent Form element, if present.\n Wizards (i.e. multi-page funnels) always take highest precedence for handling funnels,\n and do not defer to any other element.\n */\n if (isInFunnel && props.funnelType === 'single-page') {\n return <>{props.children}</>;\n }\n\n return <InnerAnalyticsFunnel {...props} />;\n};\nexport const CREATION_EDIT_FLOW_DONE_EVENT_NAME = 'awsui-creation-edit-flow-done';\n\nconst onFunnelCancelled = ({ funnelInteractionId }: { funnelInteractionId: string }) => {\n FunnelMetrics.funnelCancelled({ funnelInteractionId });\n document.dispatchEvent(new Event(CREATION_EDIT_FLOW_DONE_EVENT_NAME));\n};\n\nconst onFunnelComplete = ({ funnelInteractionId }: { funnelInteractionId: string }) => {\n FunnelMetrics.funnelComplete({ funnelInteractionId });\n document.dispatchEvent(new Event(CREATION_EDIT_FLOW_DONE_EVENT_NAME));\n};\n\nfunction evaluateSelectors(selectors: string[], defaultSelector: string) {\n for (const selector of selectors) {\n const element = document.querySelector(selector);\n if (element) {\n return selector;\n }\n }\n\n return defaultSelector;\n}\n\nconst InnerAnalyticsFunnel = ({ children, stepConfiguration, ...props }: AnalyticsFunnelProps) => {\n const [funnelInteractionId, setFunnelInteractionId] = useState<string>('');\n const [submissionAttempt, setSubmissionAttempt] = useState(0);\n const isVisualRefresh = useVisualRefresh();\n const funnelState = useRef<FunnelState>('default');\n const funnelNameSelector = useRef<string>(getFunnelNameSelector());\n const errorCount = useRef<number>(0);\n const loadingButtonCount = useRef<number>(0);\n const wizardCount = useRef<number>(0);\n const latestFocusCleanupFunction = useRef<undefined | (() => void)>(undefined);\n\n // This useEffect hook is run once on component mount to initiate the funnel analytics.\n // It first calls the 'funnelStart' method from FunnelMetrics, providing all necessary details\n // about the funnel, and receives a unique interaction id.\n // This unique interaction id is then stored in the state for further use.\n //\n // On component unmount, it checks whether the funnel was successfully completed.\n // Based on this, it either calls 'funnelComplete' or 'funnelCancelled' method from FunnelMetrics.\n //\n // The eslint-disable is required as we deliberately want this effect to run only once on mount and unmount,\n // hence we do not provide any dependencies.\n useEffect(() => {\n /*\n We run this effect with a delay, in order to detect whether this funnel contains a Wizard.\n If it does contain a Wizard, that Wizard should take precedence for handling the funnel, and\n this current funnel component should do nothing.\n */\n let funnelInteractionId: string;\n const handle = setTimeout(() => {\n funnelNameSelector.current = evaluateSelectors(props.funnelNameSelectors || [], getFunnelNameSelector());\n\n if (props.funnelType === 'single-page' && wizardCount.current > 0) {\n return;\n }\n\n // Reset the state, in case the component was re-mounted.\n funnelState.current = 'default';\n\n const singleStepFlowStepConfiguration = [\n { number: 1, isOptional: false, name: getNameFromSelector(funnelNameSelector.current) ?? '' },\n ];\n\n funnelInteractionId = FunnelMetrics.funnelStart({\n funnelNameSelector: funnelNameSelector.current,\n optionalStepNumbers: props.optionalStepNumbers,\n funnelType: props.funnelType,\n totalFunnelSteps: props.totalFunnelSteps,\n componentVersion: PACKAGE_VERSION,\n theme: isVisualRefresh ? 'vr' : 'classic',\n funnelVersion: FUNNEL_VERSION,\n stepConfiguration: stepConfiguration ?? singleStepFlowStepConfiguration,\n });\n\n setFunnelInteractionId(funnelInteractionId);\n }, 1);\n\n /*\n A funnel counts as \"successful\" if it is unmounted after being \"complete\".\n */\n /* eslint-disable react-hooks/exhaustive-deps */\n return () => {\n clearTimeout(handle);\n if (props.funnelType === 'single-page' && wizardCount.current > 0) {\n return;\n }\n\n if (funnelState.current === 'validating') {\n // Finish the validation phase early.\n onFunnelComplete({ funnelInteractionId });\n funnelState.current = 'complete';\n }\n\n if (funnelState.current === 'complete') {\n FunnelMetrics.funnelSuccessful({ funnelInteractionId });\n } else {\n onFunnelCancelled({ funnelInteractionId });\n funnelState.current = 'cancelled';\n }\n };\n }, []);\n /* eslint-enable react-hooks/exhaustive-deps */\n\n const funnelSubmit = () => {\n funnelState.current = 'validating';\n\n /*\n When the user attempts to submit the form, we wait for 50 milliseconds before checking\n if any form validation errors are present. This value was chosen to give enough time\n for validation and rerendering to occur, but be low enough that the user will not\n be able to take further action in the meantime.\n */\n const VALIDATION_WAIT_DELAY = 50;\n /*\n Loading is expected to take longer than validation, so we can keep the pressure on the CPU low.\n */\n const LOADING_WAIT_DELAY = 100;\n\n const checkForCompleteness = () => {\n if (funnelState.current === 'complete') {\n return;\n }\n\n if (loadingButtonCount.current > 0) {\n setTimeout(checkForCompleteness, LOADING_WAIT_DELAY);\n return;\n }\n\n if (errorCount.current === 0) {\n /*\n If no validation errors are rendered, we treat the funnel as complete.\n */\n onFunnelComplete({ funnelInteractionId });\n funnelState.current = 'complete';\n } else {\n funnelState.current = 'default';\n }\n };\n\n setTimeout(checkForCompleteness, VALIDATION_WAIT_DELAY);\n };\n\n const funnelNextOrSubmitAttempt = () => setSubmissionAttempt(i => i + 1);\n\n const funnelCancel = () => {};\n\n const funnelContextValue: FunnelContextValue = {\n funnelInteractionId,\n setFunnelInteractionId,\n funnelType: props.funnelType,\n optionalStepNumbers: props.optionalStepNumbers,\n totalFunnelSteps: props.totalFunnelSteps,\n funnelNameSelector: funnelNameSelector.current,\n funnelSubmit,\n funnelCancel,\n submissionAttempt,\n funnelNextOrSubmitAttempt,\n funnelState,\n errorCount,\n loadingButtonCount,\n latestFocusCleanupFunction,\n isInFunnel: true,\n wizardCount,\n };\n\n return <FunnelContext.Provider value={funnelContextValue}>{children}</FunnelContext.Provider>;\n};\n\ninterface AnalyticsFunnelStepProps {\n children?: React.ReactNode | ((props: FunnelStepContextValue) => React.ReactNode);\n stepNameSelector?: FunnelStepProps['stepNameSelector'];\n stepNumber: FunnelStepProps['stepNumber'];\n}\n\nexport const AnalyticsFunnelStep = (props: AnalyticsFunnelStepProps) => {\n /*\n This wrapper is used to apply a `key` property to the actual (inner) AnalyticsFunnelStep\n element. This allows us to keep the state and effects separate per step.\n */\n return <InnerAnalyticsFunnelStep {...props} key={props.stepNumber} />;\n};\n\nfunction getSubStepConfiguration(): SubStepConfiguration[] {\n const subSteps = Array.from(document.querySelectorAll<HTMLElement>(getSubStepAllSelector()));\n\n const subStepConfiguration = subSteps.map((substep, index) => {\n const name = substep.querySelector<HTMLElement>(getSubStepNameSelector())?.innerText?.trim() ?? '';\n return {\n name,\n number: index + 1,\n };\n });\n return subStepConfiguration;\n}\n\nfunction useStepChangeListener(stepNumber: number, handler: (stepConfiguration: SubStepConfiguration[]) => void) {\n const subStepConfiguration = useRef<Record<number, SubStepConfiguration[] | undefined>>({});\n /*\n Chosen so that it's hopefully shorter than a user interaction, but gives enough time for the\n amount of containers to stabilise.\n */\n const SUBSTEP_CHANGE_DEBOUNCE = 50;\n\n const listenForSubStepChanges = useRef(false);\n useEffect(() => {\n // We prevent emitting the event on the first render.\n const handle = setTimeout(() => (listenForSubStepChanges.current = true), SUBSTEP_CHANGE_DEBOUNCE);\n\n return () => {\n clearTimeout(handle);\n listenForSubStepChanges.current = false;\n };\n }, []);\n\n /* We debounce this handler, so that multiple containers can change at once without causing \n too many events. */\n const stepChangeCallback = useDebounceCallback(() => {\n subStepConfiguration.current[stepNumber] = getSubStepConfiguration();\n\n // We don't want to emit the event after the component has been unmounted.\n if (!listenForSubStepChanges.current) {\n return;\n }\n\n handler(subStepConfiguration.current[stepNumber]!);\n }, SUBSTEP_CHANGE_DEBOUNCE);\n\n return { onStepChange: stepChangeCallback, subStepConfiguration };\n}\n\nconst InnerAnalyticsFunnelStep = ({ children, stepNumber, ...rest }: AnalyticsFunnelStepProps) => {\n const { funnelInteractionId, funnelNameSelector, funnelState, funnelType } = useFunnel();\n const parentStep = useFunnelStep();\n const parentStepExists = parentStep.isInStep;\n const parentStepFunnelInteractionId = parentStep.funnelInteractionId;\n\n const funnelStepProps = { [DATA_ATTR_FUNNEL_STEP]: stepNumber };\n\n const subStepCount = useRef<number>(0);\n\n const stepNameSelector = rest.stepNameSelector || funnelNameSelector;\n const { onStepChange, subStepConfiguration } = useStepChangeListener(stepNumber, subStepConfiguration => {\n if (!funnelInteractionId) {\n return;\n }\n const stepName = getNameFromSelector(stepNameSelector) ?? '';\n\n FunnelMetrics.funnelStepChange({\n funnelInteractionId,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n totalSubSteps: subStepCount.current,\n subStepConfiguration,\n });\n });\n\n // This useEffect hook is used to track the start and completion of interaction with the step.\n // On mount, if there is a valid funnel interaction id, it calls the 'funnelStepStart' method from FunnelMetrics\n // to record the beginning of the interaction with the current step.\n // On unmount, it does a similar thing but this time calling 'funnelStepComplete' to record the completion of the interaction.\n useEffect(() => {\n if (!funnelInteractionId) {\n // This step is not inside an active funnel.\n return;\n }\n if (parentStepExists && parentStepFunnelInteractionId) {\n /*\n This step is inside another step, which already reports events as\n part of an active funnel (i.e. that step is not a parent of a Wizard).\n Thus, this current step does not need to report any events.\n */\n return;\n }\n\n const stepName = getNameFromSelector(stepNameSelector);\n\n if (funnelState.current === 'default') {\n FunnelMetrics.funnelStepStart({\n funnelInteractionId,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n totalSubSteps: subStepCount.current,\n subStepConfiguration: getSubStepConfiguration(),\n });\n }\n\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n if (funnelState.current !== 'cancelled') {\n FunnelMetrics.funnelStepComplete({\n funnelInteractionId,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n totalSubSteps: subStepCount.current,\n });\n }\n };\n }, [\n funnelInteractionId,\n stepNumber,\n stepNameSelector,\n funnelState,\n parentStepExists,\n funnelType,\n parentStepFunnelInteractionId,\n ]);\n\n const contextValue: FunnelStepContextValue = {\n stepNumber,\n stepNameSelector,\n funnelStepProps,\n subStepCount,\n isInStep: true,\n funnelInteractionId,\n onStepChange,\n subStepConfiguration,\n };\n\n /*\n If this step is inside another step which already reports events as part of an active\n funnel (i.e. that step is not a parent of a Wizard), the current step becomes invisible\n in the hierarchy by passing the context of its parent through.\n */\n const effectiveContextValue = parentStepExists && parentStepFunnelInteractionId ? parentStep : contextValue;\n\n return (\n <FunnelStepContext.Provider value={effectiveContextValue}>\n {typeof children === 'function' ? children(effectiveContextValue) : children}\n </FunnelStepContext.Provider>\n );\n};\ninterface AnalyticsFunnelSubStepProps {\n children?: React.ReactNode | ((props: FunnelSubStepContextValue) => React.ReactNode);\n}\n\nexport const AnalyticsFunnelSubStep = ({ children }: AnalyticsFunnelSubStepProps) => {\n const subStepId = useUniqueId('substep');\n const subStepSelector = getSubStepSelector(subStepId);\n const subStepNameSelector = getSubStepNameSelector(subStepId);\n const subStepRef = useRef<HTMLDivElement | null>(null);\n const { subStepCount, onStepChange } = useFunnelStep();\n const mousePressed = useRef<boolean>(false);\n const isFocusedSubStep = useRef<boolean>(false);\n const focusCleanupFunction = useRef<undefined | (() => void)>(undefined);\n const { funnelState, funnelInteractionId } = useFunnel();\n const { stepNumber, stepNameSelector } = useFunnelStep();\n\n const newContext: FunnelSubStepContextValue = {\n subStepSelector,\n subStepNameSelector,\n subStepId,\n subStepRef,\n mousePressed,\n isFocusedSubStep,\n focusCleanupFunction,\n isNestedSubStep: false,\n };\n\n const inheritedContext = { ...useContext(FunnelSubStepContext), isNestedSubStep: true };\n\n const isNested = Boolean(inheritedContext.subStepId);\n\n useEffect(() => {\n if (!isNested) {\n subStepCount.current++;\n onStepChange();\n\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n subStepCount.current--;\n onStepChange();\n };\n }\n }, [isNested, subStepCount, onStepChange]);\n\n const context = isNested ? inheritedContext : newContext;\n\n useEffect(() => {\n if (isNested || !subStepRef.current) {\n return;\n }\n\n const onMouseDown = () => (mousePressed.current = true);\n\n const onMouseUp = async () => {\n mousePressed.current = false;\n\n if (!isFocusedSubStep.current) {\n return;\n }\n\n /*\n Some mouse events result in an element being focused. However,\n this happens only _after_ the onMouseUp event. We yield the\n event loop here, so that `document.activeElement` has the\n correct new value. \n */\n await new Promise(r => setTimeout(r, 1));\n\n if (!subStepRef.current || !document.activeElement || !nodeBelongs(subStepRef.current, document.activeElement)) {\n isFocusedSubStep.current = false;\n\n /*\n Run this substep's own focus cleanup function if another substep\n hasn't already done it for us.\n */\n focusCleanupFunction.current?.();\n }\n };\n window.addEventListener('mousedown', onMouseDown);\n window.addEventListener('mouseup', onMouseUp);\n return () => {\n window.removeEventListener('mousedown', onMouseDown);\n window.removeEventListener('mouseup', onMouseUp);\n };\n }, [\n funnelInteractionId,\n funnelState,\n stepNameSelector,\n stepNumber,\n subStepNameSelector,\n subStepSelector,\n focusCleanupFunction,\n isNested,\n subStepRef,\n ]);\n\n return (\n <FunnelSubStepContext.Provider value={context}>\n {typeof children === 'function' ? children(context) : children}\n </FunnelSubStepContext.Provider>\n );\n};\n"]}
@@ -1,5 +1,5 @@
1
1
  import { MutableRefObject, RefObject } from 'react';
2
- import { FunnelType } from '../interfaces';
2
+ import { FunnelType, SubStepConfiguration } from '../interfaces';
3
3
  export type FunnelState = 'default' | 'validating' | 'complete' | 'cancelled';
4
4
  export interface FunnelContextValue {
5
5
  funnelInteractionId: string | undefined;
@@ -28,6 +28,7 @@ export interface FunnelStepContextValue {
28
28
  funnelInteractionId: string | undefined;
29
29
  /** This function is called when the list of substeps in this step changes. */
30
30
  onStepChange: () => void;
31
+ subStepConfiguration: MutableRefObject<Record<number, SubStepConfiguration[] | undefined> | undefined>;
31
32
  }
32
33
  export interface FunnelSubStepContextValue {
33
34
  subStepId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"analytics-context.d.ts","sourceRoot":"lib/default/","sources":["internal/analytics/context/analytics-context.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAiB,MAAM,OAAO,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,YAAY,GAAG,UAAU,GAAG,WAAW,CAAC;AAE9E,MAAM,WAAW,kBAAkB;IACjC,mBAAmB,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,UAAU,EAAE,UAAU,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,sBAAsB,EAAE,CAAC,mBAAmB,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9D,iBAAiB,EAAE,MAAM,CAAC;IAC1B,yBAAyB,EAAE,MAAM,IAAI,CAAC;IACtC,WAAW,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;IACpC,UAAU,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACrC,kBAAkB,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAC7C,0BAA0B,EAAE,gBAAgB,CAAC,SAAS,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;IACvE,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,sBAAsB;IACrC,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;IACxE,YAAY,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACvC,QAAQ,EAAE,OAAO,CAAC;IAClB,mBAAmB,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,+EAA+E;IAC/E,YAAY,EAAE,MAAM,IAAI,CAAC;CAC1B;AAED,MAAM,WAAW,yBAAyB;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,UAAU,EAAE,gBAAgB,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACpD,YAAY,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACxC;;;;;OAKG;IACH,gBAAgB,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAE5C;;OAEG;IACH,oBAAoB,EAAE,gBAAgB,CAAC,SAAS,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;IACjE,eAAe,EAAE,OAAO,CAAC;IACzB,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;CAC5E;AAGD,eAAO,MAAM,aAAa,6CAiBxB,CAAC;AAEH,eAAO,MAAM,iBAAiB,iDAO5B,CAAC;AAEH,eAAO,MAAM,oBAAoB,oDAS/B,CAAC;AAEH,eAAO,MAAM,yBAAyB,6CAA+C,CAAC"}
1
+ {"version":3,"file":"analytics-context.d.ts","sourceRoot":"lib/default/","sources":["internal/analytics/context/analytics-context.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAiB,MAAM,OAAO,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAGjE,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,YAAY,GAAG,UAAU,GAAG,WAAW,CAAC;AAE9E,MAAM,WAAW,kBAAkB;I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,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,UAAU,EAAE,gBAAgB,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACpD,YAAY,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACxC;;;;;OAKG;IACH,gBAAgB,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAE5C;;OAEG;IACH,oBAAoB,EAAE,gBAAgB,CAAC,SAAS,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;IACjE,eAAe,EAAE,OAAO,CAAC;IACzB,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;CAC5E;AAGD,eAAO,MAAM,aAAa,6CAiBxB,CAAC;AAEH,eAAO,MAAM,iBAAiB,iDAQ5B,CAAC;AAEH,eAAO,MAAM,oBAAoB,oDAS/B,CAAC;AAEH,eAAO,MAAM,yBAAyB,6CAA+C,CAAC"}
@@ -28,6 +28,7 @@ export const FunnelStepContext = createContext({
28
28
  isInStep: false,
29
29
  funnelInteractionId: undefined,
30
30
  onStepChange: () => { },
31
+ subStepConfiguration: { current: [] },
31
32
  });
32
33
  export const FunnelSubStepContext = createContext({
33
34
  subStepId: '',
@@ -1 +1 @@
1
- {"version":3,"file":"analytics-context.js","sourceRoot":"lib/default/","sources":["internal/analytics/context/analytics-context.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAA+B,aAAa,EAAE,MAAM,OAAO,CAAC;AAEnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAwDrD,0BAA0B;AAC1B,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAqB;IAC7D,mBAAmB,EAAE,SAAS;IAC9B,kBAAkB,EAAE,qBAAqB,EAAE;IAC3C,sBAAsB,EAAE,GAAG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AC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { MutableRefObject, RefObject, createContext } from 'react';\nimport { FunnelType } from '../interfaces';\nimport { getFunnelNameSelector } from '../selectors';\n\nexport type FunnelState = 'default' | 'validating' | 'complete' | 'cancelled';\n\nexport interface FunnelContextValue {\n funnelInteractionId: string | undefined;\n funnelType: FunnelType;\n funnelNameSelector: string;\n optionalStepNumbers: number[];\n totalFunnelSteps: number;\n funnelSubmit: () => void;\n funnelCancel: () => void;\n setFunnelInteractionId: (funnelInteractionId: string) => void;\n submissionAttempt: number;\n funnelNextOrSubmitAttempt: () => void;\n funnelState: RefObject<FunnelState>;\n errorCount: MutableRefObject<number>;\n loadingButtonCount: MutableRefObject<number>;\n latestFocusCleanupFunction: MutableRefObject<undefined | (() => void)>;\n isInFunnel: boolean;\n wizardCount: MutableRefObject<number>;\n}\n\nexport interface FunnelStepContextValue {\n stepNameSelector: string;\n stepNumber: number;\n funnelStepProps?: Record<string, string | number | boolean | undefined>;\n subStepCount: MutableRefObject<number>;\n isInStep: boolean;\n funnelInteractionId: string | undefined;\n /** This function is called when the list of substeps in this step changes. */\n onStepChange: () => void;\n}\n\nexport interface FunnelSubStepContextValue {\n subStepId: string;\n subStepSelector: string;\n subStepNameSelector: string;\n subStepRef: MutableRefObject<HTMLDivElement | null>;\n mousePressed: MutableRefObject<boolean>;\n /**\n * `isFocusedSubStep` is almost the same as checking if document.activeElement\n * is a child of the curren substep. However, `isFocusedSubStep` stays true\n * while the mouse button is pressed down, even though some browsers move the focus\n * to the body element during that time.\n */\n isFocusedSubStep: MutableRefObject<boolean>;\n\n /**\n * The focus cleanup function should be run when the user leaves the substep.\n */\n focusCleanupFunction: MutableRefObject<undefined | (() => void)>;\n isNestedSubStep: boolean;\n funnelSubStepProps?: Record<string, string | number | boolean | undefined>;\n}\n\n/* istanbul ignore next */\nexport const FunnelContext = createContext<FunnelContextValue>({\n funnelInteractionId: undefined,\n funnelNameSelector: getFunnelNameSelector(),\n setFunnelInteractionId: () => {},\n funnelType: 'single-page',\n optionalStepNumbers: [],\n totalFunnelSteps: 0,\n funnelSubmit: () => {},\n funnelCancel: () => {},\n submissionAttempt: 0,\n funnelNextOrSubmitAttempt: () => {},\n funnelState: { current: 'default' },\n errorCount: { current: 0 },\n loadingButtonCount: { current: 0 },\n latestFocusCleanupFunction: { current: undefined },\n isInFunnel: false,\n wizardCount: { current: 0 },\n});\n\nexport const FunnelStepContext = createContext<FunnelStepContextValue>({\n stepNameSelector: '',\n stepNumber: 0,\n subStepCount: { current: 0 },\n isInStep: false,\n funnelInteractionId: undefined,\n onStepChange: () => {},\n});\n\nexport const FunnelSubStepContext = createContext<FunnelSubStepContextValue>({\n subStepId: '',\n subStepSelector: '',\n subStepNameSelector: '',\n subStepRef: { current: null },\n isNestedSubStep: false,\n mousePressed: { current: false },\n isFocusedSubStep: { current: false },\n focusCleanupFunction: { current: undefined },\n});\n\nexport const FunnelNameSelectorContext = createContext<string | undefined>(undefined);\n"]}
1
+ {"version":3,"file":"analytics-context.js","sourceRoot":"lib/default/","sources":["internal/analytics/context/analytics-context.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAA+B,aAAa,EAAE,MAAM,OAAO,CAAC;AAEnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAyDrD,0BAA0B;AAC1B,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAqB;IAC7D,mBAAmB,EAAE,SAAS;IAC9B,kBAAkB,EAAE,qBAAqB,EAAE;IAC3C,sBAAsB,EAAE,GAAG,EAAE,GAAE,CAAC;IAChC,UAAU,EAAE,aAAa;IACzB,mBAAmB,EAAE,EAAE;IACvB,gBAAgB,EAAE,CAAC;IACnB,YAAY,EAAE,GAAG,EAAE,GAAE,CAAC;IACtB,YAAY,EAAE,GAAG,EAAE,GAAE,CAAC;IACtB,iBAAiB,EAAE,CAAC;IACpB,yBAAyB,EAAE,GAAG,EAAE,GAAE,CAAC;IACnC,WAAW,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;IACnC,UAAU,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE;IAC1B,kBAAkB,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE;IAClC,0BAA0B,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;IAClD,UAAU,EAAE,KAAK;IACjB,WAAW,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE;CAC5B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAAyB;IACrE,gBAAgB,EAAE,EAAE;IACpB,UAAU,EAAE,CAAC;IACb,YAAY,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE;IAC5B,QAAQ,EAAE,KAAK;IACf,mBAAmB,EAAE,SAAS;IAC9B,YAAY,EAAE,GAAG,EAAE,GAAE,CAAC;IACtB,oBAAoB,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;CACtC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAa,CAA4B;IAC3E,SAAS,EAAE,EAAE;IACb,eAAe,EAAE,EAAE;IACnB,mBAAmB,EAAE,EAAE;IACvB,UAAU,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;IAC7B,eAAe,EAAE,KAAK;IACtB,YAAY,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE;IAChC,gBAAgB,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE;IACpC,oBAAoB,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;CAC7C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,yBAAyB,GAAG,aAAa,CAAqB,SAAS,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { MutableRefObject, RefObject, createContext } from 'react';\nimport { FunnelType, SubStepConfiguration } from '../interfaces';\nimport { getFunnelNameSelector } from '../selectors';\n\nexport type FunnelState = 'default' | 'validating' | 'complete' | 'cancelled';\n\nexport interface FunnelContextValue {\n funnelInteractionId: string | undefined;\n funnelType: FunnelType;\n funnelNameSelector: string;\n optionalStepNumbers: number[];\n totalFunnelSteps: number;\n funnelSubmit: () => void;\n funnelCancel: () => void;\n setFunnelInteractionId: (funnelInteractionId: string) => void;\n submissionAttempt: number;\n funnelNextOrSubmitAttempt: () => void;\n funnelState: RefObject<FunnelState>;\n errorCount: MutableRefObject<number>;\n loadingButtonCount: MutableRefObject<number>;\n latestFocusCleanupFunction: MutableRefObject<undefined | (() => void)>;\n isInFunnel: boolean;\n wizardCount: MutableRefObject<number>;\n}\n\nexport interface FunnelStepContextValue {\n stepNameSelector: string;\n stepNumber: number;\n funnelStepProps?: Record<string, string | number | boolean | undefined>;\n subStepCount: MutableRefObject<number>;\n isInStep: boolean;\n funnelInteractionId: string | undefined;\n /** This function is called when the list of substeps in this step changes. */\n onStepChange: () => void;\n subStepConfiguration: MutableRefObject<Record<number, SubStepConfiguration[] | undefined> | undefined>;\n}\n\nexport interface FunnelSubStepContextValue {\n subStepId: string;\n subStepSelector: string;\n subStepNameSelector: string;\n subStepRef: MutableRefObject<HTMLDivElement | null>;\n mousePressed: MutableRefObject<boolean>;\n /**\n * `isFocusedSubStep` is almost the same as checking if document.activeElement\n * is a child of the curren substep. However, `isFocusedSubStep` stays true\n * while the mouse button is pressed down, even though some browsers move the focus\n * to the body element during that time.\n */\n isFocusedSubStep: MutableRefObject<boolean>;\n\n /**\n * The focus cleanup function should be run when the user leaves the substep.\n */\n focusCleanupFunction: MutableRefObject<undefined | (() => void)>;\n isNestedSubStep: boolean;\n funnelSubStepProps?: Record<string, string | number | boolean | undefined>;\n}\n\n/* istanbul ignore next */\nexport const FunnelContext = createContext<FunnelContextValue>({\n funnelInteractionId: undefined,\n funnelNameSelector: getFunnelNameSelector(),\n setFunnelInteractionId: () => {},\n funnelType: 'single-page',\n optionalStepNumbers: [],\n totalFunnelSteps: 0,\n funnelSubmit: () => {},\n funnelCancel: () => {},\n submissionAttempt: 0,\n funnelNextOrSubmitAttempt: () => {},\n funnelState: { current: 'default' },\n errorCount: { current: 0 },\n loadingButtonCount: { current: 0 },\n latestFocusCleanupFunction: { current: undefined },\n isInFunnel: false,\n wizardCount: { current: 0 },\n});\n\nexport const FunnelStepContext = createContext<FunnelStepContextValue>({\n stepNameSelector: '',\n stepNumber: 0,\n subStepCount: { current: 0 },\n isInStep: false,\n funnelInteractionId: undefined,\n onStepChange: () => {},\n subStepConfiguration: { current: [] },\n});\n\nexport const FunnelSubStepContext = createContext<FunnelSubStepContextValue>({\n subStepId: '',\n subStepSelector: '',\n subStepNameSelector: '',\n subStepRef: { current: null },\n isNestedSubStep: false,\n mousePressed: { current: false },\n isFocusedSubStep: { current: false },\n focusCleanupFunction: { current: undefined },\n});\n\nexport const FunnelNameSelectorContext = createContext<string | undefined>(undefined);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"use-funnel.d.ts","sourceRoot":"lib/default/","sources":["internal/analytics/hooks/use-funnel.ts"],"names":[],"mappings":";AAmBA;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;CA0H5B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,qEAGzB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;CASrB,CAAC;AAEF,eAAO,MAAM,qBAAqB,0BAGjC,CAAC"}
1
+ {"version":3,"file":"use-funnel.d.ts","sourceRoot":"lib/default/","sources":["internal/analytics/hooks/use-funnel.ts"],"names":[],"mappings":";AAmBA;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;CA8H5B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,qEAGzB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;CASrB,CAAC;AAEF,eAAO,MAAM,qBAAqB,0BAGjC,CAAC"}
@@ -19,13 +19,13 @@ import { nodeBelongs } from '../../utils/node-belongs';
19
19
  export const useFunnelSubStep = () => {
20
20
  const context = useContext(FunnelSubStepContext);
21
21
  const { funnelInteractionId, funnelState, latestFocusCleanupFunction } = useFunnel();
22
- const { stepNumber, stepNameSelector } = useFunnelStep();
22
+ const { stepNumber, stepNameSelector, subStepConfiguration } = useFunnelStep();
23
23
  const { subStepId, subStepSelector, subStepNameSelector, subStepRef, isNestedSubStep, mousePressed, isFocusedSubStep, focusCleanupFunction, } = context;
24
24
  if (isNestedSubStep) {
25
25
  return context;
26
26
  }
27
27
  const onFocus = (event) => __awaiter(void 0, void 0, void 0, function* () {
28
- var _a;
28
+ var _a, _b, _c, _d;
29
29
  const element = event.target;
30
30
  // Ignore spurious focus events, such as when the browser window is focused again.
31
31
  yield new Promise(r => setTimeout(r, 1));
@@ -44,11 +44,13 @@ export const useFunnelSubStep = () => {
44
44
  (_a = latestFocusCleanupFunction.current) === null || _a === void 0 ? void 0 : _a.call(latestFocusCleanupFunction);
45
45
  const subStepName = getNameFromSelector(subStepNameSelector);
46
46
  const stepName = getNameFromSelector(stepNameSelector);
47
+ const subStepNumber = (_d = (_c = (_b = subStepConfiguration.current) === null || _b === void 0 ? void 0 : _b[stepNumber]) === null || _c === void 0 ? void 0 : _c.find(step => step.name === subStepName)) === null || _d === void 0 ? void 0 : _d.number;
47
48
  FunnelMetrics.funnelSubStepStart({
48
49
  funnelInteractionId,
49
50
  subStepSelector,
50
51
  subStepNameSelector,
51
52
  subStepName,
53
+ subStepNumber,
52
54
  stepNumber,
53
55
  stepName,
54
56
  stepNameSelector,
@@ -66,16 +68,19 @@ export const useFunnelSubStep = () => {
66
68
  */
67
69
  let cleanupFunctionHasBeenRun = false;
68
70
  focusCleanupFunction.current = () => {
71
+ var _a, _b, _c;
69
72
  if (cleanupFunctionHasBeenRun) {
70
73
  return;
71
74
  }
72
75
  cleanupFunctionHasBeenRun = true;
76
+ const subStepNumber = (_c = (_b = (_a = subStepConfiguration.current) === null || _a === void 0 ? void 0 : _a[stepNumber]) === null || _b === void 0 ? void 0 : _b.find(s => s.name === subStepName)) === null || _c === void 0 ? void 0 : _c.number;
73
77
  if (funnelState.current !== 'cancelled') {
74
78
  FunnelMetrics.funnelSubStepComplete({
75
79
  funnelInteractionId,
76
80
  subStepSelector,
77
81
  subStepNameSelector,
78
82
  subStepName,
83
+ subStepNumber,
79
84
  stepNumber,
80
85
  stepName,
81
86
  stepNameSelector,
@@ -1 +1 @@
1
- {"version":3,"file":"use-funnel.js","sourceRoot":"lib/default/","sources":["internal/analytics/hooks/use-funnel.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EACL,aAAa,EACb,yBAAyB,EACzB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,+BAA+B,EAC/B,wBAAwB,EACxB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,EAAE;IACnC,MAAM,OAAO,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACjD,MAAM,EAAE,mBAAmB,EAAE,WAAW,EAAE,0BAA0B,EAAE,GAAG,SAAS,EAAE,CAAC;IACrF,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,GAAG,aAAa,EAAE,CAAC;IAEzD,MAAM,EACJ,SAAS,EACT,eAAe,EACf,mBAAmB,EACnB,UAAU,EACV,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,oBAAoB,GACrB,GAAG,OAAO,CAAC;IAEZ,IA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C,CAAC,EAAE,CAAC;IAEP,uBAAS,WAAW,IAAK,OAAO,EAAG;AACrC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,EAAE;IACxC,MAAM,OAAO,GAAG,UAAU,CAAC,yBAAyB,CAAC,CAAC;IACtD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useContext } from 'react';\nimport {\n FunnelContext,\n FunnelNameSelectorContext,\n FunnelStepContext,\n FunnelSubStepContext,\n} from '../context/analytics-context';\nimport {\n DATA_ATTR_FUNNEL_INTERACTION_ID,\n DATA_ATTR_FUNNEL_SUBSTEP,\n getNameFromSelector,\n getSubStepAllSelector,\n} from '../selectors';\nimport { FunnelMetrics } from '../';\nimport { nodeBelongs } from '../../utils/node-belongs';\n\n/**\n * Custom React Hook to manage and interact with FunnelSubStep.\n * This hook will provide necessary properties and methods required\n * to track and manage interactions with a FunnelSubStep component.\n *\n * The `onFocus` method is used to track the beginning of interaction with the FunnelSubStep.\n * The `onBlur` method is used to track the completion of interaction with the FunnelSubStep.\n * The subStepId is a unique identifier for the funnel sub-step.\n * The subStepRef is a reference to the DOM element of the funnel sub-step.\n */\nexport const useFunnelSubStep = () => {\n const context = useContext(FunnelSubStepContext);\n const { funnelInteractionId, funnelState, latestFocusCleanupFunction } = useFunnel();\n const { stepNumber, stepNameSelector } = useFunnelStep();\n\n const {\n subStepId,\n subStepSelector,\n subStepNameSelector,\n subStepRef,\n isNestedSubStep,\n mousePressed,\n isFocusedSubStep,\n focusCleanupFunction,\n } = context;\n\n if (isNestedSubStep) {\n return context;\n }\n\n const onFocus = async (event: React.FocusEvent<HTMLDivElement>) => {\n const element = event.target;\n // Ignore spurious focus events, such as when the browser window is focused again.\n await new Promise(r => setTimeout(r, 1));\n if (document.activeElement !== element) {\n return;\n }\n\n if (isFocusedSubStep.current) {\n return;\n }\n isFocusedSubStep.current = true;\n\n if (funnelInteractionId && subStepId) {\n /*\n If the previously focused substep has provided a cleanup function, we\n call it here on behalf of the previously focused substep.\n */\n latestFocusCleanupFunction.current?.();\n\n const subStepName = getNameFromSelector(subStepNameSelector);\n const stepName = getNameFromSelector(stepNameSelector);\n\n FunnelMetrics.funnelSubStepStart({\n funnelInteractionId,\n subStepSelector,\n subStepNameSelector,\n subStepName,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n });\n\n /*\n This cleanup function will be called when the user leaves this substep.\n The function might be called either:\n\n - by the next focused substep as `latestFocusCleanupFunction`\n (through a separate instance of the function we're currently in), or\n\n - by the same substep as `focusCleanupFunction`\n (through the `onMouseUp` handler or the `onBlur` handler).\n */\n let cleanupFunctionHasBeenRun = false;\n focusCleanupFunction.current = () => {\n if (cleanupFunctionHasBeenRun) {\n return;\n }\n cleanupFunctionHasBeenRun = true;\n\n if (funnelState.current !== 'cancelled') {\n FunnelMetrics.funnelSubStepComplete({\n funnelInteractionId,\n subStepSelector,\n subStepNameSelector,\n subStepName,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n });\n }\n };\n latestFocusCleanupFunction.current = focusCleanupFunction.current;\n }\n };\n\n const onBlur = (event: React.FocusEvent<HTMLDivElement>) => {\n if (mousePressed.current) {\n /*\n Ignore blur events that are caused by mouse interaction, because these events don't\n always reflect user intention. For example, clicking the label of an interactive form\n element will briefly blur it.\n The mouse-caused events are handled in the global `onMouseUp` handler of the substep\n context instead.\n */\n return;\n }\n\n if (!subStepRef.current || !event.relatedTarget || !nodeBelongs(subStepRef.current, event.relatedTarget)) {\n isFocusedSubStep.current = false;\n\n if (funnelInteractionId && subStepId && funnelState.current !== 'cancelled') {\n /*\n Run this substep's own focus cleanup function if another substep\n hasn't already done it for us.\n */\n focusCleanupFunction.current?.();\n }\n }\n };\n\n const funnelSubStepProps: Record<string, any> = funnelInteractionId\n ? {\n [DATA_ATTR_FUNNEL_SUBSTEP]: subStepId,\n onFocus,\n onBlur,\n }\n : {};\n\n return { funnelSubStepProps, ...context };\n};\n\n/**\n * Custom React Hook to manage and interact with FunnelStep.\n * This hook will provide necessary properties required to track\n * and manage interactions with a FunnelStep component.\n *\n * The 'data-analytics-funnel-step' property of funnelStepProps is used to track the index of the current step in the funnel.\n * The context contains additional properties of the FunnelStep.\n */\nexport const useFunnelStep = () => {\n const context = useContext(FunnelStepContext);\n return context;\n};\n\n/**\n * Custom React Hook to manage and interact with Funnel.\n * This hook will provide necessary properties required to track\n * and manage interactions with a Funnel component.\n *\n * The 'data-analytics-funnel-interaction-id' property of funnelProps is used to track the unique identifier of the current interaction with the funnel.\n */\nexport const useFunnel = () => {\n const context = useContext(FunnelContext);\n const funnelProps: Record<string, string | number | boolean | undefined> = context.funnelInteractionId\n ? {\n [DATA_ATTR_FUNNEL_INTERACTION_ID]: context.funnelInteractionId,\n }\n : {};\n\n return { funnelProps, ...context };\n};\n\nexport const useFunnelNameSelector = () => {\n const context = useContext(FunnelNameSelectorContext);\n return context;\n};\n"]}
1
+ {"version":3,"file":"use-funnel.js","sourceRoot":"lib/default/","sources":["internal/analytics/hooks/use-funnel.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EACL,aAAa,EACb,yBAAyB,EACzB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,+BAA+B,EAC/B,wBAAwB,EACxB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,EAAE;IACnC,MAAM,OAAO,GAAG,UAA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AAW,EAAE;gBAC3E;;;mBAGG;gBACH,MAAA,oBAAoB,CAAC,OAAO,oEAAI,CAAC;aAClC;SACF;IACH,CAAC,CAAC;IAEF,MAAM,kBAAkB,GAAwB,mBAAmB;QACjE,CAAC,CAAC;YACE,CAAC,wBAAwB,CAAC,EAAE,SAAS;YACrC,OAAO;YACP,MAAM;SACP;QACH,CAAC,CAAC,EAAE,CAAC;IAEP,uBAAS,kBAAkB,IAAK,OAAO,EAAG;AAC5C,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE;IAChC,MAAM,OAAO,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAC9C,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,EAAE;IAC5B,MAAM,OAAO,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;IAC1C,MAAM,WAAW,GAA0D,OAAO,CAAC,mBAAmB;QACpG,CAAC,CAAC;YACE,CAAC,+BAA+B,CAAC,EAAE,OAAO,CAAC,mBAAmB;SAC/D;QACH,CAAC,CAAC,EAAE,CAAC;IAEP,uBAAS,WAAW,IAAK,OAAO,EAAG;AACrC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,EAAE;IACxC,MAAM,OAAO,GAAG,UAAU,CAAC,yBAAyB,CAAC,CAAC;IACtD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useContext } from 'react';\nimport {\n FunnelContext,\n FunnelNameSelectorContext,\n FunnelStepContext,\n FunnelSubStepContext,\n} from '../context/analytics-context';\nimport {\n DATA_ATTR_FUNNEL_INTERACTION_ID,\n DATA_ATTR_FUNNEL_SUBSTEP,\n getNameFromSelector,\n getSubStepAllSelector,\n} from '../selectors';\nimport { FunnelMetrics } from '../';\nimport { nodeBelongs } from '../../utils/node-belongs';\n\n/**\n * Custom React Hook to manage and interact with FunnelSubStep.\n * This hook will provide necessary properties and methods required\n * to track and manage interactions with a FunnelSubStep component.\n *\n * The `onFocus` method is used to track the beginning of interaction with the FunnelSubStep.\n * The `onBlur` method is used to track the completion of interaction with the FunnelSubStep.\n * The subStepId is a unique identifier for the funnel sub-step.\n * The subStepRef is a reference to the DOM element of the funnel sub-step.\n */\nexport const useFunnelSubStep = () => {\n const context = useContext(FunnelSubStepContext);\n const { funnelInteractionId, funnelState, latestFocusCleanupFunction } = useFunnel();\n const { stepNumber, stepNameSelector, subStepConfiguration } = useFunnelStep();\n\n const {\n subStepId,\n subStepSelector,\n subStepNameSelector,\n subStepRef,\n isNestedSubStep,\n mousePressed,\n isFocusedSubStep,\n focusCleanupFunction,\n } = context;\n\n if (isNestedSubStep) {\n return context;\n }\n\n const onFocus = async (event: React.FocusEvent<HTMLDivElement>) => {\n const element = event.target;\n // Ignore spurious focus events, such as when the browser window is focused again.\n await new Promise(r => setTimeout(r, 1));\n if (document.activeElement !== element) {\n return;\n }\n\n if (isFocusedSubStep.current) {\n return;\n }\n isFocusedSubStep.current = true;\n\n if (funnelInteractionId && subStepId) {\n /*\n If the previously focused substep has provided a cleanup function, we\n call it here on behalf of the previously focused substep.\n */\n latestFocusCleanupFunction.current?.();\n\n const subStepName = getNameFromSelector(subStepNameSelector);\n const stepName = getNameFromSelector(stepNameSelector);\n const subStepNumber = subStepConfiguration.current?.[stepNumber]?.find(step => step.name === subStepName)?.number;\n FunnelMetrics.funnelSubStepStart({\n funnelInteractionId,\n subStepSelector,\n subStepNameSelector,\n subStepName,\n subStepNumber,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n });\n\n /*\n This cleanup function will be called when the user leaves this substep.\n The function might be called either:\n\n - by the next focused substep as `latestFocusCleanupFunction`\n (through a separate instance of the function we're currently in), or\n\n - by the same substep as `focusCleanupFunction`\n (through the `onMouseUp` handler or the `onBlur` handler).\n */\n let cleanupFunctionHasBeenRun = false;\n focusCleanupFunction.current = () => {\n if (cleanupFunctionHasBeenRun) {\n return;\n }\n cleanupFunctionHasBeenRun = true;\n\n const subStepNumber = subStepConfiguration.current?.[stepNumber]?.find(s => s.name === subStepName)?.number;\n\n if (funnelState.current !== 'cancelled') {\n FunnelMetrics.funnelSubStepComplete({\n funnelInteractionId,\n subStepSelector,\n subStepNameSelector,\n subStepName,\n subStepNumber,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n });\n }\n };\n latestFocusCleanupFunction.current = focusCleanupFunction.current;\n }\n };\n\n const onBlur = (event: React.FocusEvent<HTMLDivElement>) => {\n if (mousePressed.current) {\n /*\n Ignore blur events that are caused by mouse interaction, because these events don't\n always reflect user intention. For example, clicking the label of an interactive form\n element will briefly blur it.\n The mouse-caused events are handled in the global `onMouseUp` handler of the substep\n context instead.\n */\n return;\n }\n\n if (!subStepRef.current || !event.relatedTarget || !nodeBelongs(subStepRef.current, event.relatedTarget)) {\n isFocusedSubStep.current = false;\n\n if (funnelInteractionId && subStepId && funnelState.current !== 'cancelled') {\n /*\n Run this substep's own focus cleanup function if another substep\n hasn't already done it for us.\n */\n focusCleanupFunction.current?.();\n }\n }\n };\n\n const funnelSubStepProps: Record<string, any> = funnelInteractionId\n ? {\n [DATA_ATTR_FUNNEL_SUBSTEP]: subStepId,\n onFocus,\n onBlur,\n }\n : {};\n\n return { funnelSubStepProps, ...context };\n};\n\n/**\n * Custom React Hook to manage and interact with FunnelStep.\n * This hook will provide necessary properties required to track\n * and manage interactions with a FunnelStep component.\n *\n * The 'data-analytics-funnel-step' property of funnelStepProps is used to track the index of the current step in the funnel.\n * The context contains additional properties of the FunnelStep.\n */\nexport const useFunnelStep = () => {\n const context = useContext(FunnelStepContext);\n return context;\n};\n\n/**\n * Custom React Hook to manage and interact with Funnel.\n * This hook will provide necessary properties required to track\n * and manage interactions with a Funnel component.\n *\n * The 'data-analytics-funnel-interaction-id' property of funnelProps is used to track the unique identifier of the current interaction with the funnel.\n */\nexport const useFunnel = () => {\n const context = useContext(FunnelContext);\n const funnelProps: Record<string, string | number | boolean | undefined> = context.funnelInteractionId\n ? {\n [DATA_ATTR_FUNNEL_INTERACTION_ID]: context.funnelInteractionId,\n }\n : {};\n\n return { funnelProps, ...context };\n};\n\nexport const useFunnelNameSelector = () => {\n const context = useContext(FunnelNameSelectorContext);\n return context;\n};\n"]}
@@ -45,6 +45,7 @@ export interface FunnelSubStepProps extends FunnelStepProps {
45
45
  subStepSelector: string;
46
46
  subStepName?: string | undefined;
47
47
  subStepNameSelector: string;
48
+ subStepNumber?: number;
48
49
  }
49
50
  export interface FunnelSubStepErrorProps extends FunnelSubStepProps {
50
51
  fieldLabelSelector: string;
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"lib/default/","sources":["internal/analytics/interfaces.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,UAAU,GAAG,aAAa,GAAG,YAAY,CAAC;AAGtD,MAAM,WAAW,eAAe;IAC9B,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,WAAY,SAAQ,eAAe;IAClD,gBAAgB,EAAE,MAAM,CAAC;IACzB,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,UAAU,EAAE,UAAU,CAAC;IACvB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,gBAAgB;IAC/B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,gBAAgB,EAAE,MAAM,CAAC;IACzB,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,iBAAiB,CAAC,EAAE,iBAAiB,EAAE,CAAC;IACxC,UAAU,EAAE,UAAU,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;CAC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AqE;AACrE,sCAAsC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nexport type FunnelType = 'single-page' | 'multi-page';\n\n// Common properties for all funnels\nexport interface BaseFunnelProps {\n funnelInteractionId: string;\n}\n\nexport interface FunnelProps extends BaseFunnelProps {\n totalFunnelSteps: number;\n optionalStepNumbers: number[];\n funnelType: FunnelType;\n funnelNameSelector?: string;\n}\n\nexport interface FunnelStartProps {\n funnelNameSelector: string;\n totalFunnelSteps: number;\n optionalStepNumbers: number[];\n stepConfiguration?: StepConfiguration[];\n funnelType: FunnelType;\n funnelVersion: string;\n componentVersion: string;\n theme: string;\n}\n\n// A function type for a generic funnel method\nexport type FunnelMethod<T extends BaseFunnelProps> = (props: T) => void;\n\n// A function type specifically for funnelStart\nexport type FunnelStartMethod = (props: FunnelStartProps) => string;\n\n// Define individual method props by extending the base\nexport interface FunnelStepProps extends BaseFunnelProps {\n stepNumber: number;\n stepName?: string | undefined;\n stepNameSelector: string;\n subStepAllSelector: string;\n}\n\nexport interface FunnelStepStartProps extends FunnelStepProps {\n totalSubSteps?: number;\n subStepConfiguration?: SubStepConfiguration[];\n}\nexport interface FunnelStepCompleteProps extends FunnelStepProps {\n totalSubSteps?: number;\n}\n\nexport interface FunnelStepNavigationProps extends FunnelStepProps {\n destinationStepNumber: number;\n navigationType: string;\n totalSubSteps?: number;\n}\n\nexport interface FunnelStepErrorProps extends FunnelStepProps {\n stepErrorSelector: string;\n}\n\nexport interface FunnelSubStepProps extends FunnelStepProps {\n subStepSelector: string;\n subStepName?: string | undefined;\n subStepNameSelector: string;\n}\n\nexport interface FunnelSubStepErrorProps extends FunnelSubStepProps {\n fieldLabelSelector: string;\n fieldErrorSelector: string;\n}\n\nexport interface OptionalFunnelSubStepErrorProps extends FunnelSubStepProps {\n fieldLabelSelector?: string;\n fieldErrorSelector?: string;\n}\n\nexport interface FunnelLinkInteractionProps extends FunnelSubStepProps {\n elementSelector: string;\n}\n\nexport interface FunnelChangeProps extends BaseFunnelProps {\n stepConfiguration: StepConfiguration[];\n}\n\nexport interface FunnelStepChangeProps extends BaseFunnelProps {\n stepNumber: number;\n stepName: string;\n stepNameSelector: string;\n subStepAllSelector: string;\n totalSubSteps: number;\n subStepConfiguration: SubStepConfiguration[];\n}\n\nexport interface StepConfiguration {\n number: number;\n name: string;\n isOptional: boolean;\n}\n\nexport interface SubStepConfiguration {\n number: number;\n name: string;\n}\n\n// Define the interface using the method type\nexport interface IFunnelMetrics {\n funnelStart: FunnelStartMethod;\n funnelError: FunnelMethod<BaseFunnelProps>;\n funnelComplete: FunnelMethod<BaseFunnelProps>;\n funnelSuccessful: FunnelMethod<BaseFunnelProps>;\n funnelCancelled: FunnelMethod<BaseFunnelProps>;\n funnelChange: FunnelMethod<FunnelChangeProps>;\n\n funnelStepStart: FunnelMethod<FunnelStepStartProps>;\n funnelStepComplete: FunnelMethod<FunnelStepCompleteProps>;\n funnelStepNavigation: FunnelMethod<FunnelStepNavigationProps>;\n funnelStepError: FunnelMethod<FunnelStepErrorProps>;\n funnelStepChange: FunnelMethod<FunnelStepChangeProps>;\n\n funnelSubStepStart: FunnelMethod<FunnelSubStepProps>;\n funnelSubStepComplete: FunnelMethod<FunnelSubStepProps>;\n funnelSubStepError: FunnelMethod<OptionalFunnelSubStepErrorProps>;\n\n helpPanelInteracted: FunnelMethod<FunnelLinkInteractionProps>;\n externalLinkInteracted: FunnelMethod<FunnelLinkInteractionProps>;\n}\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"lib/default/","sources":["internal/analytics/interfaces.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nexport type FunnelType = 'single-page' | 'multi-page';\n\n// Common properties for all funnels\nexport interface BaseFunnelProps {\n funnelInteractionId: string;\n}\n\nexport interface FunnelProps extends BaseFunnelProps {\n totalFunnelSteps: number;\n optionalStepNumbers: number[];\n funnelType: FunnelType;\n funnelNameSelector?: string;\n}\n\nexport interface FunnelStartProps {\n funnelNameSelector: string;\n totalFunnelSteps: number;\n optionalStepNumbers: number[];\n stepConfiguration?: StepConfiguration[];\n funnelType: FunnelType;\n funnelVersion: string;\n componentVersion: string;\n theme: string;\n}\n\n// A function type for a generic funnel method\nexport type FunnelMethod<T extends BaseFunnelProps> = (props: T) => void;\n\n// A function type specifically for funnelStart\nexport type FunnelStartMethod = (props: FunnelStartProps) => string;\n\n// Define individual method props by extending the base\nexport interface FunnelStepProps extends BaseFunnelProps {\n stepNumber: number;\n stepName?: string | undefined;\n stepNameSelector: string;\n subStepAllSelector: string;\n}\n\nexport interface FunnelStepStartProps extends FunnelStepProps {\n totalSubSteps?: number;\n subStepConfiguration?: SubStepConfiguration[];\n}\nexport interface FunnelStepCompleteProps extends FunnelStepProps {\n totalSubSteps?: number;\n}\n\nexport interface FunnelStepNavigationProps extends FunnelStepProps {\n destinationStepNumber: number;\n navigationType: string;\n totalSubSteps?: number;\n}\n\nexport interface FunnelStepErrorProps extends FunnelStepProps {\n stepErrorSelector: string;\n}\n\nexport interface FunnelSubStepProps extends FunnelStepProps {\n subStepSelector: string;\n subStepName?: string | undefined;\n subStepNameSelector: string;\n subStepNumber?: number;\n}\n\nexport interface FunnelSubStepErrorProps extends FunnelSubStepProps {\n fieldLabelSelector: string;\n fieldErrorSelector: string;\n}\n\nexport interface OptionalFunnelSubStepErrorProps extends FunnelSubStepProps {\n fieldLabelSelector?: string;\n fieldErrorSelector?: string;\n}\n\nexport interface FunnelLinkInteractionProps extends FunnelSubStepProps {\n elementSelector: string;\n}\n\nexport interface FunnelChangeProps extends BaseFunnelProps {\n stepConfiguration: StepConfiguration[];\n}\n\nexport interface FunnelStepChangeProps extends BaseFunnelProps {\n stepNumber: number;\n stepName: string;\n stepNameSelector: string;\n subStepAllSelector: string;\n totalSubSteps: number;\n subStepConfiguration: SubStepConfiguration[];\n}\n\nexport interface StepConfiguration {\n number: number;\n name: string;\n isOptional: boolean;\n}\n\nexport interface SubStepConfiguration {\n number: number;\n name: string;\n}\n\n// Define the interface using the method type\nexport interface IFunnelMetrics {\n funnelStart: FunnelStartMethod;\n funnelError: FunnelMethod<BaseFunnelProps>;\n funnelComplete: FunnelMethod<BaseFunnelProps>;\n funnelSuccessful: FunnelMethod<BaseFunnelProps>;\n funnelCancelled: FunnelMethod<BaseFunnelProps>;\n funnelChange: FunnelMethod<FunnelChangeProps>;\n\n funnelStepStart: FunnelMethod<FunnelStepStartProps>;\n funnelStepComplete: FunnelMethod<FunnelStepCompleteProps>;\n funnelStepNavigation: FunnelMethod<FunnelStepNavigationProps>;\n funnelStepError: FunnelMethod<FunnelStepErrorProps>;\n funnelStepChange: FunnelMethod<FunnelStepChangeProps>;\n\n funnelSubStepStart: FunnelMethod<FunnelSubStepProps>;\n funnelSubStepComplete: FunnelMethod<FunnelSubStepProps>;\n funnelSubStepError: FunnelMethod<OptionalFunnelSubStepErrorProps>;\n\n helpPanelInteracted: FunnelMethod<FunnelLinkInteractionProps>;\n externalLinkInteracted: FunnelMethod<FunnelLinkInteractionProps>;\n}\n"]}
@@ -1,4 +1,4 @@
1
1
  export var PACKAGE_SOURCE = "components";
2
- export var PACKAGE_VERSION = "3.0.0 (57626990)";
2
+ export var PACKAGE_VERSION = "3.0.0 (f9b0d9bd)";
3
3
  export var THEME = "open-source-visual-refresh";
4
4
  export var ALWAYS_VISUAL_REFRESH = true;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "PACKAGE_SOURCE": "components",
3
- "PACKAGE_VERSION": "3.0.0 (57626990)",
3
+ "PACKAGE_VERSION": "3.0.0 (f9b0d9bd)",
4
4
  "THEME": "default",
5
5
  "ALWAYS_VISUAL_REFRESH": false
6
6
  }
@@ -1,3 +1,3 @@
1
1
  {
2
- "commit": "5762699079e4a8b29d8104c36a4d06ce226b0275"
2
+ "commit": "f9b0d9bd4b00c85d8cb782ac23fe8ba7ae55db54"
3
3
  }
package/package.json CHANGED
@@ -113,7 +113,7 @@
113
113
  "./internal/base-component/index.js",
114
114
  "./internal/base-component/styles.css.js"
115
115
  ],
116
- "version": "3.0.436",
116
+ "version": "3.0.438",
117
117
  "repository": {
118
118
  "type": "git",
119
119
  "url": "https://github.com/cloudscape-design/components.git"
@@ -61,7 +61,7 @@ const RECTANGLE_CALCULATIONS = {
61
61
  'top-right': ({ body, trigger, arrow }) => {
62
62
  return {
63
63
  top: trigger.top - body.height - arrow.height,
64
- left: trigger.left,
64
+ left: trigger.left + trigger.width / 2 - ARROW_OFFSET - arrow.width / 2,
65
65
  width: body.width,
66
66
  height: body.height,
67
67
  };
@@ -69,7 +69,7 @@ const RECTANGLE_CALCULATIONS = {
69
69
  'top-left': ({ body, trigger, arrow }) => {
70
70
  return {
71
71
  top: trigger.top - body.height - arrow.height,
72
- left: trigger.left + trigger.width - body.width,
72
+ left: trigger.left + trigger.width / 2 + ARROW_OFFSET + arrow.width / 2 - body.width,
73
73
  width: body.width,
74
74
  height: body.height,
75
75
  };
@@ -85,7 +85,7 @@ const RECTANGLE_CALCULATIONS = {
85
85
  'bottom-right': ({ body, trigger, arrow }) => {
86
86
  return {
87
87
  top: trigger.top + trigger.height + arrow.height,
88
- left: trigger.left,
88
+ left: trigger.left + trigger.width / 2 - ARROW_OFFSET - arrow.width / 2,
89
89
  width: body.width,
90
90
  height: body.height,
91
91
  };
@@ -93,7 +93,7 @@ const RECTANGLE_CALCULATIONS = {
93
93
  'bottom-left': ({ body, trigger, arrow }) => {
94
94
  return {
95
95
  top: trigger.top + trigger.height + arrow.height,
96
- left: trigger.left + trigger.width - body.width,
96
+ left: trigger.left + trigger.width / 2 + ARROW_OFFSET + arrow.width / 2 - body.width,
97
97
  width: body.width,
98
98
  height: body.height,
99
99
  };