@cloudscape-design/components-themeable 3.0.348 → 3.0.350

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 (213) hide show
  1. package/lib/internal/manifest.json +1 -1
  2. package/lib/internal/scss/app-layout/visual-refresh/drawers.scss +2 -0
  3. package/lib/internal/scss/app-layout/visual-refresh/layout.scss +3 -3
  4. package/lib/internal/scss/app-layout/visual-refresh/navigation.scss +1 -0
  5. package/lib/internal/scss/app-layout/visual-refresh/tools.scss +1 -0
  6. package/lib/internal/scss/button/styles.scss +1 -1
  7. package/lib/internal/scss/button-dropdown/category-elements/styles.scss +2 -3
  8. package/lib/internal/scss/button-dropdown/item-element/styles.scss +2 -2
  9. package/lib/internal/scss/cards/styles.scss +3 -9
  10. package/lib/internal/scss/container/shared.scss +2 -2
  11. package/lib/internal/scss/container/styles.scss +3 -0
  12. package/lib/internal/scss/expandable-section/styles.scss +2 -2
  13. package/lib/internal/scss/header/styles.scss +61 -58
  14. package/lib/internal/scss/modal/styles.scss +1 -1
  15. package/lib/internal/scss/segmented-control/segment.scss +1 -1
  16. package/lib/internal/scss/table/body-cell/styles.scss +27 -8
  17. package/lib/internal/scss/table/styles.scss +6 -14
  18. package/lib/internal/template/alert/index.d.ts.map +1 -1
  19. package/lib/internal/template/alert/index.js +36 -1
  20. package/lib/internal/template/alert/index.js.map +1 -1
  21. package/lib/internal/template/app-layout/styles.css.js +17 -17
  22. package/lib/internal/template/app-layout/styles.scoped.css +21 -21
  23. package/lib/internal/template/app-layout/styles.selectors.js +17 -17
  24. package/lib/internal/template/app-layout/visual-refresh/styles.css.js +69 -69
  25. package/lib/internal/template/app-layout/visual-refresh/styles.scoped.css +173 -169
  26. package/lib/internal/template/app-layout/visual-refresh/styles.selectors.js +69 -69
  27. package/lib/internal/template/area-chart/chart-container.d.ts +2 -2
  28. package/lib/internal/template/area-chart/chart-container.d.ts.map +1 -1
  29. package/lib/internal/template/area-chart/chart-container.js +1 -1
  30. package/lib/internal/template/area-chart/chart-container.js.map +1 -1
  31. package/lib/internal/template/area-chart/interfaces.d.ts +5 -1
  32. package/lib/internal/template/area-chart/interfaces.d.ts.map +1 -1
  33. package/lib/internal/template/area-chart/interfaces.js.map +1 -1
  34. package/lib/internal/template/area-chart/internal.d.ts +1 -1
  35. package/lib/internal/template/area-chart/internal.d.ts.map +1 -1
  36. package/lib/internal/template/area-chart/internal.js +2 -2
  37. package/lib/internal/template/area-chart/internal.js.map +1 -1
  38. package/lib/internal/template/attribute-editor/interfaces.d.ts +7 -0
  39. package/lib/internal/template/attribute-editor/interfaces.d.ts.map +1 -1
  40. package/lib/internal/template/attribute-editor/interfaces.js.map +1 -1
  41. package/lib/internal/template/attribute-editor/internal.d.ts.map +1 -1
  42. package/lib/internal/template/attribute-editor/internal.js +2 -2
  43. package/lib/internal/template/attribute-editor/internal.js.map +1 -1
  44. package/lib/internal/template/attribute-editor/row.d.ts +3 -2
  45. package/lib/internal/template/attribute-editor/row.d.ts.map +1 -1
  46. package/lib/internal/template/attribute-editor/row.js +2 -2
  47. package/lib/internal/template/attribute-editor/row.js.map +1 -1
  48. package/lib/internal/template/box/styles.css.js +189 -189
  49. package/lib/internal/template/box/styles.scoped.css +257 -257
  50. package/lib/internal/template/box/styles.selectors.js +189 -189
  51. package/lib/internal/template/button/styles.css.js +20 -20
  52. package/lib/internal/template/button/styles.scoped.css +154 -154
  53. package/lib/internal/template/button/styles.selectors.js +20 -20
  54. package/lib/internal/template/button-dropdown/category-elements/styles.css.js +13 -13
  55. package/lib/internal/template/button-dropdown/category-elements/styles.scoped.css +25 -25
  56. package/lib/internal/template/button-dropdown/category-elements/styles.selectors.js +13 -13
  57. package/lib/internal/template/button-dropdown/item-element/styles.css.js +14 -14
  58. package/lib/internal/template/button-dropdown/item-element/styles.scoped.css +20 -20
  59. package/lib/internal/template/button-dropdown/item-element/styles.selectors.js +14 -14
  60. package/lib/internal/template/cards/styles.css.js +38 -38
  61. package/lib/internal/template/cards/styles.scoped.css +57 -62
  62. package/lib/internal/template/cards/styles.selectors.js +38 -38
  63. package/lib/internal/template/container/styles.css.js +28 -28
  64. package/lib/internal/template/container/styles.scoped.css +57 -54
  65. package/lib/internal/template/container/styles.selectors.js +28 -28
  66. package/lib/internal/template/content-layout/styles.css.js +7 -7
  67. package/lib/internal/template/content-layout/styles.scoped.css +13 -13
  68. package/lib/internal/template/content-layout/styles.selectors.js +7 -7
  69. package/lib/internal/template/expandable-section/styles.css.js +29 -29
  70. package/lib/internal/template/expandable-section/styles.scoped.css +61 -61
  71. package/lib/internal/template/expandable-section/styles.selectors.js +29 -29
  72. package/lib/internal/template/flashbar/styles.css.js +46 -46
  73. package/lib/internal/template/flashbar/styles.scoped.css +146 -146
  74. package/lib/internal/template/flashbar/styles.selectors.js +46 -46
  75. package/lib/internal/template/form-field/internal.js +3 -2
  76. package/lib/internal/template/form-field/internal.js.map +1 -1
  77. package/lib/internal/template/header/internal.d.ts.map +1 -1
  78. package/lib/internal/template/header/internal.js +5 -5
  79. package/lib/internal/template/header/internal.js.map +1 -1
  80. package/lib/internal/template/header/styles.css.js +33 -44
  81. package/lib/internal/template/header/styles.scoped.css +85 -91
  82. package/lib/internal/template/header/styles.selectors.js +33 -44
  83. package/lib/internal/template/help-panel/styles.css.js +4 -4
  84. package/lib/internal/template/help-panel/styles.scoped.css +80 -80
  85. package/lib/internal/template/help-panel/styles.selectors.js +4 -4
  86. package/lib/internal/template/icon/styles.css.js +21 -21
  87. package/lib/internal/template/icon/styles.scoped.css +54 -54
  88. package/lib/internal/template/icon/styles.selectors.js +21 -21
  89. package/lib/internal/template/internal/analytics/components/analytics-funnel.d.ts.map +1 -1
  90. package/lib/internal/template/internal/analytics/components/analytics-funnel.js +16 -15
  91. package/lib/internal/template/internal/analytics/components/analytics-funnel.js.map +1 -1
  92. package/lib/internal/template/internal/analytics/context/analytics-context.d.ts +6 -7
  93. package/lib/internal/template/internal/analytics/context/analytics-context.d.ts.map +1 -1
  94. package/lib/internal/template/internal/analytics/context/analytics-context.js +2 -6
  95. package/lib/internal/template/internal/analytics/context/analytics-context.js.map +1 -1
  96. package/lib/internal/template/internal/analytics/hooks/use-funnel.d.ts +4 -7
  97. package/lib/internal/template/internal/analytics/hooks/use-funnel.d.ts.map +1 -1
  98. package/lib/internal/template/internal/analytics/hooks/use-funnel.js +10 -8
  99. package/lib/internal/template/internal/analytics/hooks/use-funnel.js.map +1 -1
  100. package/lib/internal/template/internal/base-component/styles.scoped.css +86 -80
  101. package/lib/internal/template/internal/components/button-trigger/index.d.ts +2 -1
  102. package/lib/internal/template/internal/components/button-trigger/index.d.ts.map +1 -1
  103. package/lib/internal/template/internal/components/button-trigger/index.js +2 -2
  104. package/lib/internal/template/internal/components/button-trigger/index.js.map +1 -1
  105. package/lib/internal/template/internal/components/cartesian-chart/interfaces.d.ts +10 -2
  106. package/lib/internal/template/internal/components/cartesian-chart/interfaces.d.ts.map +1 -1
  107. package/lib/internal/template/internal/components/cartesian-chart/interfaces.js.map +1 -1
  108. package/lib/internal/template/internal/components/dropdown/index.d.ts +1 -1
  109. package/lib/internal/template/internal/components/dropdown/index.d.ts.map +1 -1
  110. package/lib/internal/template/internal/components/dropdown/index.js +4 -4
  111. package/lib/internal/template/internal/components/dropdown/index.js.map +1 -1
  112. package/lib/internal/template/internal/components/dropdown/interfaces.d.ts +8 -0
  113. package/lib/internal/template/internal/components/dropdown/interfaces.d.ts.map +1 -1
  114. package/lib/internal/template/internal/components/dropdown/interfaces.js.map +1 -1
  115. package/lib/internal/template/internal/components/menu-dropdown/styles.css.js +7 -7
  116. package/lib/internal/template/internal/components/menu-dropdown/styles.scoped.css +14 -14
  117. package/lib/internal/template/internal/components/menu-dropdown/styles.selectors.js +7 -7
  118. package/lib/internal/template/internal/environment.js +1 -1
  119. package/lib/internal/template/internal/generated/theming/index.cjs +153 -120
  120. package/lib/internal/template/internal/generated/theming/index.js +153 -120
  121. package/lib/internal/template/link/internal.d.ts.map +1 -1
  122. package/lib/internal/template/link/internal.js +3 -2
  123. package/lib/internal/template/link/internal.js.map +1 -1
  124. package/lib/internal/template/link/styles.css.js +20 -20
  125. package/lib/internal/template/link/styles.scoped.css +83 -83
  126. package/lib/internal/template/link/styles.selectors.js +20 -20
  127. package/lib/internal/template/mixed-line-bar-chart/internal.d.ts +1 -1
  128. package/lib/internal/template/mixed-line-bar-chart/internal.d.ts.map +1 -1
  129. package/lib/internal/template/mixed-line-bar-chart/internal.js +2 -2
  130. package/lib/internal/template/mixed-line-bar-chart/internal.js.map +1 -1
  131. package/lib/internal/template/modal/styles.css.js +23 -23
  132. package/lib/internal/template/modal/styles.scoped.css +40 -40
  133. package/lib/internal/template/modal/styles.selectors.js +23 -23
  134. package/lib/internal/template/pagination/styles.css.js +9 -9
  135. package/lib/internal/template/pagination/styles.scoped.css +24 -24
  136. package/lib/internal/template/pagination/styles.selectors.js +9 -9
  137. package/lib/internal/template/popover/styles.css.js +50 -50
  138. package/lib/internal/template/popover/styles.scoped.css +65 -65
  139. package/lib/internal/template/popover/styles.selectors.js +50 -50
  140. package/lib/internal/template/property-filter/index.d.ts.map +1 -1
  141. package/lib/internal/template/property-filter/index.js +4 -3
  142. package/lib/internal/template/property-filter/index.js.map +1 -1
  143. package/lib/internal/template/property-filter/interfaces.d.ts +16 -5
  144. package/lib/internal/template/property-filter/interfaces.d.ts.map +1 -1
  145. package/lib/internal/template/property-filter/interfaces.js.map +1 -1
  146. package/lib/internal/template/s3-resource-selector/index.d.ts.map +1 -1
  147. package/lib/internal/template/s3-resource-selector/index.js +2 -2
  148. package/lib/internal/template/s3-resource-selector/index.js.map +1 -1
  149. package/lib/internal/template/s3-resource-selector/interfaces.d.ts +7 -0
  150. package/lib/internal/template/s3-resource-selector/interfaces.d.ts.map +1 -1
  151. package/lib/internal/template/s3-resource-selector/interfaces.js.map +1 -1
  152. package/lib/internal/template/s3-resource-selector/s3-in-context/index.d.ts +1 -0
  153. package/lib/internal/template/s3-resource-selector/s3-in-context/index.d.ts.map +1 -1
  154. package/lib/internal/template/s3-resource-selector/s3-in-context/index.js +2 -2
  155. package/lib/internal/template/s3-resource-selector/s3-in-context/index.js.map +1 -1
  156. package/lib/internal/template/segmented-control/styles.css.js +14 -14
  157. package/lib/internal/template/segmented-control/styles.scoped.css +35 -35
  158. package/lib/internal/template/segmented-control/styles.selectors.js +14 -14
  159. package/lib/internal/template/select/utils/use-select.d.ts +5 -7
  160. package/lib/internal/template/select/utils/use-select.d.ts.map +1 -1
  161. package/lib/internal/template/select/utils/use-select.js +6 -0
  162. package/lib/internal/template/select/utils/use-select.js.map +1 -1
  163. package/lib/internal/template/side-navigation/styles.css.js +28 -28
  164. package/lib/internal/template/side-navigation/styles.scoped.css +49 -49
  165. package/lib/internal/template/side-navigation/styles.selectors.js +28 -28
  166. package/lib/internal/template/spinner/styles.css.js +13 -13
  167. package/lib/internal/template/spinner/styles.scoped.css +22 -22
  168. package/lib/internal/template/spinner/styles.selectors.js +13 -13
  169. package/lib/internal/template/split-panel/styles.css.js +56 -56
  170. package/lib/internal/template/split-panel/styles.scoped.css +80 -80
  171. package/lib/internal/template/split-panel/styles.selectors.js +56 -56
  172. package/lib/internal/template/table/body-cell/index.d.ts.map +1 -1
  173. package/lib/internal/template/table/body-cell/index.js +22 -3
  174. package/lib/internal/template/table/body-cell/index.js.map +1 -1
  175. package/lib/internal/template/table/body-cell/styles.css.js +28 -28
  176. package/lib/internal/template/table/body-cell/styles.scoped.css +93 -77
  177. package/lib/internal/template/table/body-cell/styles.selectors.js +28 -28
  178. package/lib/internal/template/table/header-cell/styles.css.js +24 -24
  179. package/lib/internal/template/table/header-cell/styles.scoped.css +41 -41
  180. package/lib/internal/template/table/header-cell/styles.selectors.js +24 -24
  181. package/lib/internal/template/table/styles.css.js +34 -34
  182. package/lib/internal/template/table/styles.scoped.css +45 -52
  183. package/lib/internal/template/table/styles.selectors.js +34 -34
  184. package/lib/internal/template/tabs/styles.css.js +21 -21
  185. package/lib/internal/template/tabs/styles.scoped.css +41 -41
  186. package/lib/internal/template/tabs/styles.selectors.js +21 -21
  187. package/lib/internal/template/tag-editor/styles.css.js +3 -3
  188. package/lib/internal/template/tag-editor/styles.scoped.css +11 -11
  189. package/lib/internal/template/tag-editor/styles.selectors.js +3 -3
  190. package/lib/internal/template/text-content/styles.css.js +1 -1
  191. package/lib/internal/template/text-content/styles.scoped.css +71 -71
  192. package/lib/internal/template/text-content/styles.selectors.js +1 -1
  193. package/lib/internal/template/top-navigation/1.0-beta/styles.css.js +25 -25
  194. package/lib/internal/template/top-navigation/1.0-beta/styles.scoped.css +45 -45
  195. package/lib/internal/template/top-navigation/1.0-beta/styles.selectors.js +25 -25
  196. package/lib/internal/template/top-navigation/styles.css.js +47 -47
  197. package/lib/internal/template/top-navigation/styles.scoped.css +74 -74
  198. package/lib/internal/template/top-navigation/styles.selectors.js +47 -47
  199. package/lib/internal/template/tutorial-panel/components/tutorial-detail-view/styles.css.js +20 -20
  200. package/lib/internal/template/tutorial-panel/components/tutorial-detail-view/styles.scoped.css +22 -22
  201. package/lib/internal/template/tutorial-panel/components/tutorial-detail-view/styles.selectors.js +20 -20
  202. package/lib/internal/template/wizard/interfaces.d.ts +10 -3
  203. package/lib/internal/template/wizard/interfaces.d.ts.map +1 -1
  204. package/lib/internal/template/wizard/interfaces.js.map +1 -1
  205. package/lib/internal/template/wizard/internal.d.ts +1 -1
  206. package/lib/internal/template/wizard/internal.d.ts.map +1 -1
  207. package/lib/internal/template/wizard/internal.js +5 -5
  208. package/lib/internal/template/wizard/internal.js.map +1 -1
  209. package/lib/internal/template/wizard/wizard-form.d.ts +2 -1
  210. package/lib/internal/template/wizard/wizard-form.d.ts.map +1 -1
  211. package/lib/internal/template/wizard/wizard-form.js +2 -2
  212. package/lib/internal/template/wizard/wizard-form.js.map +1 -1
  213. package/package.json +1 -1
@@ -2,26 +2,26 @@
2
2
  // es-module interop with Babel and Typescript
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  module.exports.default = {
5
- "icon": "awsui_icon_h11ix_19747_98",
6
- "icon-flex-height": "awsui_icon-flex-height_h11ix_19747_104",
7
- "size-small": "awsui_size-small_h11ix_19747_129",
8
- "size-small-mapped-height": "awsui_size-small-mapped-height_h11ix_19747_133",
9
- "size-normal": "awsui_size-normal_h11ix_19747_147",
10
- "size-normal-mapped-height": "awsui_size-normal-mapped-height_h11ix_19747_151",
11
- "size-medium": "awsui_size-medium_h11ix_19747_165",
12
- "size-medium-mapped-height": "awsui_size-medium-mapped-height_h11ix_19747_169",
13
- "size-big": "awsui_size-big_h11ix_19747_183",
14
- "size-big-mapped-height": "awsui_size-big-mapped-height_h11ix_19747_187",
15
- "size-large": "awsui_size-large_h11ix_19747_201",
16
- "size-large-mapped-height": "awsui_size-large-mapped-height_h11ix_19747_205",
17
- "variant-normal": "awsui_variant-normal_h11ix_19747_219",
18
- "variant-disabled": "awsui_variant-disabled_h11ix_19747_222",
19
- "variant-inverted": "awsui_variant-inverted_h11ix_19747_225",
20
- "variant-subtle": "awsui_variant-subtle_h11ix_19747_228",
21
- "variant-warning": "awsui_variant-warning_h11ix_19747_231",
22
- "variant-error": "awsui_variant-error_h11ix_19747_234",
23
- "variant-success": "awsui_variant-success_h11ix_19747_237",
24
- "variant-link": "awsui_variant-link_h11ix_19747_240",
25
- "badge": "awsui_badge_h11ix_19747_244"
5
+ "icon": "awsui_icon_h11ix_15zph_98",
6
+ "icon-flex-height": "awsui_icon-flex-height_h11ix_15zph_104",
7
+ "size-small": "awsui_size-small_h11ix_15zph_129",
8
+ "size-small-mapped-height": "awsui_size-small-mapped-height_h11ix_15zph_133",
9
+ "size-normal": "awsui_size-normal_h11ix_15zph_147",
10
+ "size-normal-mapped-height": "awsui_size-normal-mapped-height_h11ix_15zph_151",
11
+ "size-medium": "awsui_size-medium_h11ix_15zph_165",
12
+ "size-medium-mapped-height": "awsui_size-medium-mapped-height_h11ix_15zph_169",
13
+ "size-big": "awsui_size-big_h11ix_15zph_183",
14
+ "size-big-mapped-height": "awsui_size-big-mapped-height_h11ix_15zph_187",
15
+ "size-large": "awsui_size-large_h11ix_15zph_201",
16
+ "size-large-mapped-height": "awsui_size-large-mapped-height_h11ix_15zph_205",
17
+ "variant-normal": "awsui_variant-normal_h11ix_15zph_219",
18
+ "variant-disabled": "awsui_variant-disabled_h11ix_15zph_222",
19
+ "variant-inverted": "awsui_variant-inverted_h11ix_15zph_225",
20
+ "variant-subtle": "awsui_variant-subtle_h11ix_15zph_228",
21
+ "variant-warning": "awsui_variant-warning_h11ix_15zph_231",
22
+ "variant-error": "awsui_variant-error_h11ix_15zph_234",
23
+ "variant-success": "awsui_variant-success_h11ix_15zph_237",
24
+ "variant-link": "awsui_variant-link_h11ix_15zph_240",
25
+ "badge": "awsui_badge_h11ix_15zph_244"
26
26
  };
27
27
 
@@ -1 +1 @@
1
- {"version":3,"file":"analytics-funnel.d.ts","sourceRoot":"lib/default/","sources":["internal/analytics/components/analytics-funnel.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAE3D,OAAO,EAKL,sBAAsB,EAEvB,MAAM,8BAA8B,CAAC;AAQtC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAW7D,eAAO,MAAM,cAAc,QAAQ,CAAC;AAEpC,KAAK,oBAAoB,GAAG;IAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,GAAG,IAAI,CAC/D,WAAW,EACX,YAAY,GAAG,qBAAqB,GAAG,kBAAkB,CAC1D,CAAC;AAEF,eAAO,MAAM,eAAe,2BAA4B,oBAAoB,gBAkH3E,CAAC;AAEF,KAAK,wBAAwB,GAAG;IAC9B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,KAAK,EAAE,sBAAsB,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC;CACnF,GAAG,IAAI,CAAC,eAAe,EAAE,YAAY,GAAG,kBAAkB,CAAC,CAAC;AAE7D,eAAO,MAAM,mBAAmB,+CAAgD,wBAAwB,gBA2CvG,CAAC;AACF,UAAU,2BAA2B;IACnC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,eAAO,MAAM,sBAAsB,iBAAkB,2BAA2B,gBAsB/E,CAAC"}
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,EAGvB,MAAM,8BAA8B,CAAC;AAQtC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAW7D,eAAO,MAAM,cAAc,QAAQ,CAAC;AAEpC,KAAK,oBAAoB,GAAG;IAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,GAAG,IAAI,CAC/D,WAAW,EACX,YAAY,GAAG,qBAAqB,GAAG,kBAAkB,CAC1D,CAAC;AAEF,eAAO,MAAM,eAAe,2BAA4B,oBAAoB,gBAkH3E,CAAC;AAEF,KAAK,wBAAwB,GAAG;IAC9B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,KAAK,EAAE,sBAAsB,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC;CACnF,GAAG,IAAI,CAAC,eAAe,EAAE,YAAY,GAAG,kBAAkB,CAAC,CAAC;AAE7D,eAAO,MAAM,mBAAmB,+CAAgD,wBAAwB,gBA2CvG,CAAC;AACF,UAAU,2BAA2B;IACnC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,eAAO,MAAM,sBAAsB,iBAAkB,2BAA2B,gBAmB/E,CAAC"}
@@ -1,9 +1,9 @@
1
1
  import { __rest } from "tslib";
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- import React, { useEffect, useRef, useState } from 'react';
4
+ import React, { useContext, useEffect, useRef, useState } from 'react';
5
5
  import { FunnelStepContext, FunnelSubStepContext, FunnelContext, } from '../context/analytics-context';
6
- import { useFunnel, useFunnelStep } from '../hooks/use-funnel';
6
+ import { useFunnel } from '../hooks/use-funnel';
7
7
  import { useUniqueId } from '../../hooks/use-unique-id';
8
8
  import { useVisualRefresh } from '../../hooks/use-visual-mode';
9
9
  import { PACKAGE_VERSION } from '../../environment';
@@ -56,7 +56,7 @@ export const AnalyticsFunnel = (_a) => {
56
56
  }
57
57
  else {
58
58
  FunnelMetrics.funnelCancelled({ funnelInteractionId });
59
- funnelState.current === 'cancelled';
59
+ funnelState.current = 'cancelled';
60
60
  }
61
61
  };
62
62
  }, []);
@@ -133,7 +133,7 @@ export const AnalyticsFunnelStep = ({ children, stepNumber, stepNameSelector })
133
133
  }
134
134
  return () => {
135
135
  //eslint-disable-next-line react-hooks/exhaustive-deps
136
- if (funnelInteractionId && funnelState.current === 'default') {
136
+ if (funnelInteractionId && funnelState.current !== 'cancelled') {
137
137
  FunnelMetrics.funnelStepComplete({
138
138
  funnelInteractionId,
139
139
  stepNumber,
@@ -145,22 +145,23 @@ export const AnalyticsFunnelStep = ({ children, stepNumber, stepNameSelector })
145
145
  };
146
146
  //eslint-disable-next-line react-hooks/exhaustive-deps
147
147
  }, [funnelInteractionId, stepNumber, stepNameSelector]);
148
- const contextValue = { funnelInteractionId, stepNumber, stepNameSelector, funnelStepProps };
148
+ const contextValue = { stepNumber, stepNameSelector, funnelStepProps };
149
149
  return (React.createElement(FunnelStepContext.Provider, { value: contextValue }, typeof children === 'function' ? children(contextValue) : children));
150
150
  };
151
151
  export const AnalyticsFunnelSubStep = ({ children }) => {
152
- const { funnelInteractionId } = useFunnel();
153
- const { stepNumber, stepNameSelector } = useFunnelStep();
154
152
  const subStepId = useUniqueId('substep');
155
153
  const subStepSelector = getSubStepSelector(subStepId);
156
154
  const subStepNameSelector = getSubStepNameSelector(subStepId);
157
- return (React.createElement(FunnelSubStepContext.Provider, { value: {
158
- funnelInteractionId,
159
- stepNumber,
160
- stepNameSelector,
161
- subStepSelector,
162
- subStepNameSelector,
163
- subStepId,
164
- } }, children));
155
+ const subStepRef = useRef(null);
156
+ const newContext = {
157
+ subStepSelector,
158
+ subStepNameSelector,
159
+ subStepId,
160
+ subStepRef,
161
+ isNestedSubStep: false,
162
+ };
163
+ const inheritedContext = Object.assign(Object.assign({}, useContext(FunnelSubStepContext)), { isNestedSubStep: true });
164
+ const context = inheritedContext.subStepId ? inheritedContext : newContext;
165
+ return React.createElement(FunnelSubStepContext.Provider, { value: context }, children);
165
166
  };
166
167
  //# sourceMappingURL=analytics-funnel.js.map
@@ -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,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE3D,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,aAAa,GAId,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,KAAK,CAAC;AAGpC,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AAEtB,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAC;AAOpC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAA4C,EAAE,EAAE;QA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BAAkB,EAAE,qBAAqB,EAAE;iBAC5C,CAAC,CAAC;aACJ;QACH,CAAC,CAAC;QACF,sDAAsD;IACxD,CAAC,EAAE,CAAC,mBAAmB,EAAE,UAAU,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAExD,MAAM,YAAY,GAA2B,EAAE,mBAAmB,EAAE,UAAU,EAAE,gBAAgB,EAAE,eAAe,EAAE,CAAC;IACpH,OAAO,CACL,oBAAC,iBAAiB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,IAC5C,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,QAAQ,CACxC,CAC9B,CAAC;AACJ,CAAC,CAAC;AAKF,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,EAAE,QAAQ,EAA+B,EAAE,EAAE;IAClF,MAAM,EAAE,mBAAmB,EAAE,GAAG,SAAS,EAAE,CAAC;IAC5C,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,GAAG,aAAa,EAAE,CAAC;IAEzD,MAAM,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;IACzC,MAAM,eAAe,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;IACtD,MAAM,mBAAmB,GAAG,sBAAsB,CAAC,SAAS,CAAC,CAAC;IAE9D,OAAO,CACL,oBAAC,oBAAoB,CAAC,QAAQ,IAC5B,KAAK,EAAE;YACL,mBAAmB;YACnB,UAAU;YACV,gBAAgB;YAChB,eAAe;YACf,mBAAmB;YACnB,SAAS;SACV,IAEA,QAAQ,CACqB,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, { useEffect, useRef, useState } from 'react';\n\nimport {\n FunnelStepContext,\n FunnelSubStepContext,\n FunnelContext,\n FunnelContextValue,\n FunnelStepContextValue,\n FunnelState,\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 '../';\nimport { FunnelProps, FunnelStepProps } from '../interfaces';\n\nimport {\n DATA_ATTR_FUNNEL_STEP,\n getFunnelNameSelector,\n getNameFromSelector,\n getSubStepAllSelector,\n getSubStepNameSelector,\n getSubStepSelector,\n} from '../selectors';\n\nexport const FUNNEL_VERSION = '1.0';\n\ntype AnalyticsFunnelProps = { children?: React.ReactNode } & Pick<\n FunnelProps,\n 'funnelType' | 'optionalStepNumbers' | 'totalFunnelSteps'\n>;\n\nexport const AnalyticsFunnel = ({ children, ...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 errorCount = useRef<number>(0);\n const loadingButtonCount = useRef<number>(0);\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 // Reset the state, in case the component was re-mounted.\n funnelState.current = 'default';\n\n const funnelInteractionId = FunnelMetrics.funnelStart({\n funnelNameSelector: getFunnelNameSelector(),\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 });\n\n setFunnelInteractionId(funnelInteractionId);\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 if (funnelState.current === 'validating') {\n // Finish the validation phase early.\n FunnelMetrics.funnelComplete({ funnelInteractionId });\n funnelState.current = 'complete';\n }\n\n if (funnelState.current === 'complete') {\n FunnelMetrics.funnelSuccessful({ funnelInteractionId });\n } else {\n FunnelMetrics.funnelCancelled({ 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 FunnelMetrics.funnelComplete({ 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 funnelSubmit,\n funnelCancel,\n submissionAttempt,\n funnelNextOrSubmitAttempt,\n funnelState,\n errorCount,\n loadingButtonCount,\n };\n\n return <FunnelContext.Provider value={funnelContextValue}>{children}</FunnelContext.Provider>;\n};\n\ntype AnalyticsFunnelStepProps = {\n children?: React.ReactNode | ((props: FunnelStepContextValue) => React.ReactNode);\n} & Pick<FunnelStepProps, 'stepNumber' | 'stepNameSelector'>;\n\nexport const AnalyticsFunnelStep = ({ children, stepNumber, stepNameSelector }: AnalyticsFunnelStepProps) => {\n const { funnelInteractionId, funnelState } = useFunnel();\n\n const funnelStepProps = { [DATA_ATTR_FUNNEL_STEP]: stepNumber };\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 const stepName = getNameFromSelector(stepNameSelector);\n\n if (funnelInteractionId && funnelState.current === 'default') {\n FunnelMetrics.funnelStepStart({\n funnelInteractionId,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n });\n }\n\n return () => {\n //eslint-disable-next-line react-hooks/exhaustive-deps\n if (funnelInteractionId && funnelState.current === 'default') {\n FunnelMetrics.funnelStepComplete({\n funnelInteractionId,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n });\n }\n };\n //eslint-disable-next-line react-hooks/exhaustive-deps\n }, [funnelInteractionId, stepNumber, stepNameSelector]);\n\n const contextValue: FunnelStepContextValue = { funnelInteractionId, stepNumber, stepNameSelector, funnelStepProps };\n return (\n <FunnelStepContext.Provider value={contextValue}>\n {typeof children === 'function' ? children(contextValue) : children}\n </FunnelStepContext.Provider>\n );\n};\ninterface AnalyticsFunnelSubStepProps {\n children?: React.ReactNode;\n}\n\nexport const AnalyticsFunnelSubStep = ({ children }: AnalyticsFunnelSubStepProps) => {\n const { funnelInteractionId } = useFunnel();\n const { stepNumber, stepNameSelector } = useFunnelStep();\n\n const subStepId = useUniqueId('substep');\n const subStepSelector = getSubStepSelector(subStepId);\n const subStepNameSelector = getSubStepNameSelector(subStepId);\n\n return (\n <FunnelSubStepContext.Provider\n value={{\n funnelInteractionId,\n stepNumber,\n stepNameSelector,\n subStepSelector,\n subStepNameSelector,\n subStepId,\n }}\n >\n {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,MAAM,qBAAqB,CAAC;AAChD,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,KAAK,CAAC;AAGpC,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AAEtB,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAC;AAOpC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAA4C,EAAE,EAAE;QAAhD,EAAE,QAAQ,OAAkC,EAA7B,KAAK,cAApB,YAAsB,CAAF;IAClD,MAAM,CAAC,mBAAmB,EAAE,sBAAsB,CAAC,GAAG,QAAQ,CAAS,EAAE,CAAC,CAAC;IAC3E,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC9D,MAAM,eAAe,GA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,CACL,oBAAC,iBAAiB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,IAC5C,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,QAAQ,CACxC,CAC9B,CAAC;AACJ,CAAC,CAAC;AAKF,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,EAAE,QAAQ,EAA+B,EAAE,EAAE;IAClF,MAAM,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;IACzC,MAAM,eAAe,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;IACtD,MAAM,mBAAmB,GAAG,sBAAsB,CAAC,SAAS,CAAC,CAAC;IAC9D,MAAM,UAAU,GAAG,MAAM,CAAwB,IAAI,CAAC,CAAC;IAEvD,MAAM,UAAU,GAA8B;QAC5C,eAAe;QACf,mBAAmB;QACnB,SAAS;QACT,UAAU;QACV,eAAe,EAAE,KAAK;KACvB,CAAC;IAEF,MAAM,gBAAgB,mCAAQ,UAAU,CAAC,oBAAoB,CAAC,KAAE,eAAe,EAAE,IAAI,GAAE,CAAC;IAExF,MAAM,OAAO,GAAG,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,UAAU,CAAC;IAE3E,OAAO,oBAAC,oBAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,OAAO,IAAG,QAAQ,CAAiC,CAAC;AACnG,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 } 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 '../';\nimport { FunnelProps, FunnelStepProps } from '../interfaces';\n\nimport {\n DATA_ATTR_FUNNEL_STEP,\n getFunnelNameSelector,\n getNameFromSelector,\n getSubStepAllSelector,\n getSubStepNameSelector,\n getSubStepSelector,\n} from '../selectors';\n\nexport const FUNNEL_VERSION = '1.0';\n\ntype AnalyticsFunnelProps = { children?: React.ReactNode } & Pick<\n FunnelProps,\n 'funnelType' | 'optionalStepNumbers' | 'totalFunnelSteps'\n>;\n\nexport const AnalyticsFunnel = ({ children, ...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 errorCount = useRef<number>(0);\n const loadingButtonCount = useRef<number>(0);\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 // Reset the state, in case the component was re-mounted.\n funnelState.current = 'default';\n\n const funnelInteractionId = FunnelMetrics.funnelStart({\n funnelNameSelector: getFunnelNameSelector(),\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 });\n\n setFunnelInteractionId(funnelInteractionId);\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 if (funnelState.current === 'validating') {\n // Finish the validation phase early.\n FunnelMetrics.funnelComplete({ funnelInteractionId });\n funnelState.current = 'complete';\n }\n\n if (funnelState.current === 'complete') {\n FunnelMetrics.funnelSuccessful({ funnelInteractionId });\n } else {\n FunnelMetrics.funnelCancelled({ 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 FunnelMetrics.funnelComplete({ 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 funnelSubmit,\n funnelCancel,\n submissionAttempt,\n funnelNextOrSubmitAttempt,\n funnelState,\n errorCount,\n loadingButtonCount,\n };\n\n return <FunnelContext.Provider value={funnelContextValue}>{children}</FunnelContext.Provider>;\n};\n\ntype AnalyticsFunnelStepProps = {\n children?: React.ReactNode | ((props: FunnelStepContextValue) => React.ReactNode);\n} & Pick<FunnelStepProps, 'stepNumber' | 'stepNameSelector'>;\n\nexport const AnalyticsFunnelStep = ({ children, stepNumber, stepNameSelector }: AnalyticsFunnelStepProps) => {\n const { funnelInteractionId, funnelState } = useFunnel();\n\n const funnelStepProps = { [DATA_ATTR_FUNNEL_STEP]: stepNumber };\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 const stepName = getNameFromSelector(stepNameSelector);\n\n if (funnelInteractionId && funnelState.current === 'default') {\n FunnelMetrics.funnelStepStart({\n funnelInteractionId,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n });\n }\n\n return () => {\n //eslint-disable-next-line react-hooks/exhaustive-deps\n if (funnelInteractionId && funnelState.current !== 'cancelled') {\n FunnelMetrics.funnelStepComplete({\n funnelInteractionId,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n });\n }\n };\n //eslint-disable-next-line react-hooks/exhaustive-deps\n }, [funnelInteractionId, stepNumber, stepNameSelector]);\n\n const contextValue: FunnelStepContextValue = { stepNumber, stepNameSelector, funnelStepProps };\n return (\n <FunnelStepContext.Provider value={contextValue}>\n {typeof children === 'function' ? children(contextValue) : children}\n </FunnelStepContext.Provider>\n );\n};\ninterface AnalyticsFunnelSubStepProps {\n children?: 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\n const newContext: FunnelSubStepContextValue = {\n subStepSelector,\n subStepNameSelector,\n subStepId,\n subStepRef,\n isNestedSubStep: false,\n };\n\n const inheritedContext = { ...useContext(FunnelSubStepContext), isNestedSubStep: true };\n\n const context = inheritedContext.subStepId ? inheritedContext : newContext;\n\n return <FunnelSubStepContext.Provider value={context}>{children}</FunnelSubStepContext.Provider>;\n};\n"]}
@@ -1,10 +1,8 @@
1
1
  import { MutableRefObject, RefObject } from 'react';
2
2
  import { FunnelType } from '../interfaces';
3
- export interface BaseContextProps {
4
- funnelInteractionId: string | undefined;
5
- }
6
3
  export type FunnelState = 'default' | 'validating' | 'complete' | 'cancelled';
7
- export interface FunnelContextValue extends BaseContextProps {
4
+ export interface FunnelContextValue {
5
+ funnelInteractionId: string | undefined;
8
6
  funnelType: FunnelType;
9
7
  optionalStepNumbers: number[];
10
8
  totalFunnelSteps: number;
@@ -17,16 +15,17 @@ export interface FunnelContextValue extends BaseContextProps {
17
15
  errorCount: MutableRefObject<number>;
18
16
  loadingButtonCount: MutableRefObject<number>;
19
17
  }
20
- export interface FunnelStepContextValue extends BaseContextProps {
18
+ export interface FunnelStepContextValue {
21
19
  stepNameSelector: string;
22
20
  stepNumber: number;
23
21
  funnelStepProps?: Record<string, string | number | boolean | undefined>;
24
22
  }
25
- export interface FunnelSubStepContextValue extends FunnelStepContextValue {
23
+ export interface FunnelSubStepContextValue {
26
24
  subStepId: string;
27
25
  subStepSelector: string;
28
26
  subStepNameSelector: string;
29
- stepNumber: number;
27
+ subStepRef: MutableRefObject<HTMLDivElement | null>;
28
+ isNestedSubStep: boolean;
30
29
  funnelSubStepProps?: Record<string, string | number | boolean | undefined>;
31
30
  }
32
31
  export declare const FunnelContext: import("react").Context<FunnelContextValue>;
@@ -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;AAE3C,MAAM,WAAW,gBAAgB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,oBAAoB,oDAQ/B,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,MAAM,eAAe,CAAC;AAE3C,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,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;CAC9C;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;CACzE;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,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,6CAaxB,CAAC;AAEH,eAAO,MAAM,iBAAiB,iDAG5B,CAAC;AAEH,eAAO,MAAM,oBAAoB,oDAM/B,CAAC"}
@@ -17,18 +17,14 @@ export const FunnelContext = createContext({
17
17
  loadingButtonCount: { current: 0 },
18
18
  });
19
19
  export const FunnelStepContext = createContext({
20
- funnelInteractionId: undefined,
21
20
  stepNameSelector: '',
22
21
  stepNumber: 0,
23
- funnelStepProps: {},
24
22
  });
25
23
  export const FunnelSubStepContext = createContext({
26
- funnelInteractionId: undefined,
27
24
  subStepId: '',
28
- stepNumber: 0,
29
- stepNameSelector: '',
30
25
  subStepSelector: '',
31
26
  subStepNameSelector: '',
32
- funnelStepProps: {},
27
+ subStepRef: { current: null },
28
+ isNestedSubStep: false,
33
29
  });
34
30
  //# sourceMappingURL=analytics-context.js.map
@@ -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;AAqCnE,0BAA0B;AAC1B,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAqB;IAC7D,mBAAmB,EAAE,SAAS;IAC9B,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;CACnC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAAyB;IACrE,mBAAmB,EAAE,SAAS;IAC9B,gBAAgB,EAAE,EAAE;IACpB,UAAU,EAAE,CAAC;IACb,eAAe,EAAE,EAAE;CACpB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAa,CAA4B;IAC3E,mBAAmB,EAAE,SAAS;IAC9B,SAAS,EAAE,EAAE;IACb,UAAU,EAAE,CAAC;IACb,gBAAgB,EAAE,EAAE;IACpB,eAAe,EAAE,EAAE;IACnB,mBAAmB,EAAE,EAAE;IACvB,eAAe,EAAE,EAAE;CACpB,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 } from '../interfaces';\n\nexport interface BaseContextProps {\n funnelInteractionId: string | undefined;\n}\n\nexport type FunnelState = 'default' | 'validating' | 'complete' | 'cancelled';\n\nexport interface FunnelContextValue extends BaseContextProps {\n funnelType: FunnelType;\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}\n\nexport interface FunnelStepContextValue extends BaseContextProps {\n stepNameSelector: string;\n stepNumber: number;\n funnelStepProps?: Record<string, string | number | boolean | undefined>;\n}\n\nexport interface FunnelSubStepContextValue extends FunnelStepContextValue {\n subStepId: string;\n subStepSelector: string;\n subStepNameSelector: string;\n stepNumber: number;\n funnelSubStepProps?: Record<string, string | number | boolean | undefined>;\n}\n\n/* istanbul ignore next */\nexport const FunnelContext = createContext<FunnelContextValue>({\n funnelInteractionId: undefined,\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});\n\nexport const FunnelStepContext = createContext<FunnelStepContextValue>({\n funnelInteractionId: undefined,\n stepNameSelector: '',\n stepNumber: 0,\n funnelStepProps: {},\n});\n\nexport const FunnelSubStepContext = createContext<FunnelSubStepContextValue>({\n funnelInteractionId: undefined,\n subStepId: '',\n stepNumber: 0,\n stepNameSelector: '',\n subStepSelector: '',\n subStepNameSelector: '',\n funnelStepProps: {},\n});\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;AAmCnE,0BAA0B;AAC1B,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAqB;IAC7D,mBAAmB,EAAE,SAAS;IAC9B,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;CACnC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAAyB;IACrE,gBAAgB,EAAE,EAAE;IACpB,UAAU,EAAE,CAAC;CACd,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;CACvB,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 } from '../interfaces';\n\nexport type FunnelState = 'default' | 'validating' | 'complete' | 'cancelled';\n\nexport interface FunnelContextValue {\n funnelInteractionId: string | undefined;\n funnelType: FunnelType;\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}\n\nexport interface FunnelStepContextValue {\n stepNameSelector: string;\n stepNumber: number;\n funnelStepProps?: Record<string, string | number | boolean | undefined>;\n}\n\nexport interface FunnelSubStepContextValue {\n subStepId: string;\n subStepSelector: string;\n subStepNameSelector: string;\n subStepRef: MutableRefObject<HTMLDivElement | null>;\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 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});\n\nexport const FunnelStepContext = createContext<FunnelStepContextValue>({\n stepNameSelector: '',\n stepNumber: 0,\n});\n\nexport const FunnelSubStepContext = createContext<FunnelSubStepContextValue>({\n subStepId: '',\n subStepSelector: '',\n subStepNameSelector: '',\n subStepRef: { current: null },\n isNestedSubStep: false,\n});\n"]}
@@ -9,16 +9,13 @@
9
9
  * The subStepId is a unique identifier for the funnel sub-step.
10
10
  * The subStepRef is a reference to the DOM element of the funnel sub-step.
11
11
  */
12
- export declare const useFunnelSubStep: () => {
12
+ export declare const useFunnelSubStep: () => import("../context/analytics-context").FunnelSubStepContextValue | {
13
13
  subStepId: string;
14
14
  subStepSelector: string;
15
15
  subStepNameSelector: string;
16
- stepNumber: number;
17
- funnelSubStepProps: Record<string, any>;
18
- stepNameSelector: string;
19
- funnelStepProps?: Record<string, string | number | boolean | undefined> | undefined;
20
- funnelInteractionId: string | undefined;
21
16
  subStepRef: import("react").MutableRefObject<HTMLDivElement | null>;
17
+ isNestedSubStep: boolean;
18
+ funnelSubStepProps: Record<string, any>;
22
19
  };
23
20
  /**
24
21
  * Custom React Hook to manage and interact with FunnelStep.
@@ -37,6 +34,7 @@ export declare const useFunnelStep: () => import("../context/analytics-context")
37
34
  * The 'data-analytics-funnel-interaction-id' property of funnelProps is used to track the unique identifier of the current interaction with the funnel.
38
35
  */
39
36
  export declare const useFunnel: () => {
37
+ funnelInteractionId: string | undefined;
40
38
  funnelType: import("../interfaces").FunnelType;
41
39
  optionalStepNumbers: number[];
42
40
  totalFunnelSteps: number;
@@ -48,7 +46,6 @@ export declare const useFunnel: () => {
48
46
  funnelState: import("react").RefObject<import("../context/analytics-context").FunnelState>;
49
47
  errorCount: import("react").MutableRefObject<number>;
50
48
  loadingButtonCount: import("react").MutableRefObject<number>;
51
- funnelInteractionId: string | undefined;
52
49
  funnelProps: Record<string, string | number | boolean | undefined>;
53
50
  };
54
51
  //# sourceMappingURL=use-funnel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-funnel.d.ts","sourceRoot":"lib/default/","sources":["internal/analytics/hooks/use-funnel.ts"],"names":[],"mappings":";AAQA;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;CAqD5B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,qEAGzB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;CASrB,CAAC"}
1
+ {"version":3,"file":"use-funnel.d.ts","sourceRoot":"lib/default/","sources":["internal/analytics/hooks/use-funnel.ts"],"names":[],"mappings":";AAQA;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB;;;;;;;CAuD5B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,qEAGzB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;CASrB,CAAC"}
@@ -1,6 +1,6 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import { useContext, useRef } from 'react';
3
+ import { useContext } from 'react';
4
4
  import { FunnelContext, FunnelStepContext, FunnelSubStepContext } from '../context/analytics-context';
5
5
  import { DATA_ATTR_FUNNEL_INTERACTION_ID, DATA_ATTR_FUNNEL_SUBSTEP, getSubStepAllSelector } from '../selectors';
6
6
  import { FunnelMetrics } from '../';
@@ -15,15 +15,17 @@ import { FunnelMetrics } from '../';
15
15
  * The subStepRef is a reference to the DOM element of the funnel sub-step.
16
16
  */
17
17
  export const useFunnelSubStep = () => {
18
- const subStepRef = useRef(null);
19
18
  const context = useContext(FunnelSubStepContext);
20
- const { funnelInteractionId, subStepId, subStepSelector, subStepNameSelector, stepNumber, stepNameSelector } = context;
21
- const { funnelState } = useFunnel();
19
+ const { funnelInteractionId, funnelState } = useFunnel();
20
+ const { stepNumber, stepNameSelector } = useFunnelStep();
21
+ const { subStepId, subStepSelector, subStepNameSelector, subStepRef, isNestedSubStep } = context;
22
+ if (isNestedSubStep) {
23
+ return context;
24
+ }
22
25
  const onFocus = (event) => {
23
26
  if (funnelInteractionId &&
24
27
  subStepRef.current &&
25
- (!event.relatedTarget || !subStepRef.current.contains(event.relatedTarget)) &&
26
- funnelState.current === 'default') {
28
+ (!event.relatedTarget || !subStepRef.current.contains(event.relatedTarget))) {
27
29
  FunnelMetrics.funnelSubStepStart({
28
30
  funnelInteractionId,
29
31
  subStepSelector,
@@ -38,7 +40,7 @@ export const useFunnelSubStep = () => {
38
40
  if (funnelInteractionId &&
39
41
  subStepRef.current &&
40
42
  !subStepRef.current.contains(event.relatedTarget) &&
41
- funnelState.current === 'default') {
43
+ funnelState.current !== 'cancelled') {
42
44
  FunnelMetrics.funnelSubStepComplete({
43
45
  funnelInteractionId,
44
46
  subStepSelector,
@@ -56,7 +58,7 @@ export const useFunnelSubStep = () => {
56
58
  onBlur,
57
59
  }
58
60
  : {};
59
- return Object.assign({ funnelSubStepProps, subStepRef }, context);
61
+ return Object.assign({ funnelSubStepProps }, context);
60
62
  };
61
63
  /**
62
64
  * Custom React Hook to manage and interact with FunnelStep.
@@ -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,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACtG,OAAO,EAAE,+BAA+B,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAChH,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC;;;;;;;;;GASG;AAC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,EAAE,SAAS;YACrC,OAAO;YACP,MAAM;SACP;QACH,CAAC,CAAC,EAAE,CAAC;IAEP,uBAAS,kBAAkB,EAAE,UAAU,IAAK,OAAO,EAAG;AACxD,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","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useContext, useRef } from 'react';\nimport { FunnelContext, FunnelStepContext, FunnelSubStepContext } from '../context/analytics-context';\nimport { DATA_ATTR_FUNNEL_INTERACTION_ID, DATA_ATTR_FUNNEL_SUBSTEP, getSubStepAllSelector } from '../selectors';\nimport { FunnelMetrics } from '../';\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 subStepRef = useRef<HTMLDivElement | null>(null);\n const context = useContext(FunnelSubStepContext);\n const { funnelInteractionId, subStepId, subStepSelector, subStepNameSelector, stepNumber, stepNameSelector } =\n context;\n\n const { funnelState } = useFunnel();\n\n const onFocus = (event: React.FocusEvent<HTMLDivElement>) => {\n if (\n funnelInteractionId &&\n subStepRef.current &&\n (!event.relatedTarget || !subStepRef.current.contains(event.relatedTarget as Node)) &&\n funnelState.current === 'default'\n ) {\n FunnelMetrics.funnelSubStepStart({\n funnelInteractionId,\n subStepSelector,\n subStepNameSelector,\n stepNumber,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n });\n }\n };\n\n const onBlur = (event: React.FocusEvent<HTMLDivElement>) => {\n if (\n funnelInteractionId &&\n subStepRef.current &&\n !subStepRef.current.contains(event.relatedTarget) &&\n funnelState.current === 'default'\n ) {\n FunnelMetrics.funnelSubStepComplete({\n funnelInteractionId,\n subStepSelector,\n subStepNameSelector,\n stepNumber,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\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, subStepRef, ...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"]}
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,EAAE,aAAa,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACtG,OAAO,EAAE,+BAA+B,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAChH,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC;;;;;;;;;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,GAAG,SAAS,EAAE,CAAC;IACzD,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,GAAG,aAAa,EAAE,CAAC;IAEzD,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,mBAAmB,EAAE,UAAU,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;IAEjG,IAAI,eAAe,EAAE;QACnB,OAAO,OAAO,CAAC;KAChB;IAED,MAAM,OAAO,GAAG,CAAC,KAAuC,EAAE,EAAE;QAC1D,IACE,mBAAmB;YACnB,UAAU,CAAC,OAAO;YAClB,CAAC,CAAC,KAAK,CAAC,aAAa,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,aAAqB,CAAC,CAAC,EACnF;YACA,aAAa,CAAC,kBAAkB,CAAC;gBAC/B,mBAAmB;gBACnB,eAAe;gBACf,mBAAmB;gBACnB,UAAU;gBACV,gBAAgB;gBAChB,kBAAkB,EAAE,qBAAqB,EAAE;aAC5C,CAAC,CAAC;SACJ;IACH,CAAC,CAAC;IAEF,MAAM,MAAM,GAAG,CAAC,KAAuC,EAAE,EAAE;QACzD,IACE,mBAAmB;YACnB,UAAU,CAAC,OAAO;YAClB,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC;YACjD,WAAW,CAAC,OAAO,KAAK,WAAW,EACnC;YACA,aAAa,CAAC,qBAAqB,CAAC;gBAClC,mBAAmB;gBACnB,eAAe;gBACf,mBAAmB;gBACnB,UAAU;gBACV,gBAAgB;gBAChB,kBAAkB,EAAE,qBAAqB,EAAE;aAC5C,CAAC,CAAC;SACJ;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","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useContext } from 'react';\nimport { FunnelContext, FunnelStepContext, FunnelSubStepContext } from '../context/analytics-context';\nimport { DATA_ATTR_FUNNEL_INTERACTION_ID, DATA_ATTR_FUNNEL_SUBSTEP, getSubStepAllSelector } from '../selectors';\nimport { FunnelMetrics } from '../';\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 } = useFunnel();\n const { stepNumber, stepNameSelector } = useFunnelStep();\n\n const { subStepId, subStepSelector, subStepNameSelector, subStepRef, isNestedSubStep } = context;\n\n if (isNestedSubStep) {\n return context;\n }\n\n const onFocus = (event: React.FocusEvent<HTMLDivElement>) => {\n if (\n funnelInteractionId &&\n subStepRef.current &&\n (!event.relatedTarget || !subStepRef.current.contains(event.relatedTarget as Node))\n ) {\n FunnelMetrics.funnelSubStepStart({\n funnelInteractionId,\n subStepSelector,\n subStepNameSelector,\n stepNumber,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n });\n }\n };\n\n const onBlur = (event: React.FocusEvent<HTMLDivElement>) => {\n if (\n funnelInteractionId &&\n subStepRef.current &&\n !subStepRef.current.contains(event.relatedTarget) &&\n funnelState.current !== 'cancelled'\n ) {\n FunnelMetrics.funnelSubStepComplete({\n funnelInteractionId,\n subStepSelector,\n subStepNameSelector,\n stepNumber,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\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"]}