fontdue-js 3.6.0 → 3.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +5 -4
  3. package/dist/__generated__/AddToCartBannerQuery.graphql.d.ts +1 -1
  4. package/dist/__generated__/AddToCartBannerQuery.graphql.js +16 -10
  5. package/dist/__generated__/AddToCartBanner_item.graphql.d.ts +4 -1
  6. package/dist/__generated__/AddToCartBanner_item.graphql.js +7 -2
  7. package/dist/__generated__/AddToCartBanner_order.graphql.d.ts +4 -1
  8. package/dist/__generated__/AddToCartBanner_order.graphql.js +6 -1
  9. package/dist/__generated__/BuyButtonIDQuery.graphql.d.ts +3 -3
  10. package/dist/__generated__/BuyButtonIDQuery.graphql.js +31 -16
  11. package/dist/__generated__/BuyButtonPackIDQuery.graphql.d.ts +21 -0
  12. package/dist/__generated__/BuyButtonPackIDQuery.graphql.js +129 -0
  13. package/dist/__generated__/BuyButtonPackSlugQuery.graphql.d.ts +25 -0
  14. package/dist/__generated__/BuyButtonPackSlugQuery.graphql.js +167 -0
  15. package/dist/__generated__/BuyButtonSlugQuery.graphql.d.ts +3 -3
  16. package/dist/__generated__/BuyButtonSlugQuery.graphql.js +45 -17
  17. package/dist/__generated__/BuyButton_product.graphql.d.ts +27 -0
  18. package/dist/__generated__/BuyButton_product.graphql.js +72 -0
  19. package/dist/__generated__/CartItemProduct_product.graphql.d.ts +1 -1
  20. package/dist/__generated__/CartItemProduct_product.graphql.js +7 -2
  21. package/dist/__generated__/CartOrderCompleteOrderMutation.graphql.d.ts +1 -1
  22. package/dist/__generated__/CartOrderCompleteOrderMutation.graphql.js +26 -20
  23. package/dist/__generated__/CartOrderRemoveDiscountMutation.graphql.d.ts +1 -1
  24. package/dist/__generated__/CartOrderRemoveDiscountMutation.graphql.js +26 -20
  25. package/dist/__generated__/CartOrderUpdateMutation.graphql.d.ts +1 -1
  26. package/dist/__generated__/CartOrderUpdateMutation.graphql.js +26 -20
  27. package/dist/__generated__/CartQuery.graphql.d.ts +1 -1
  28. package/dist/__generated__/CartQuery.graphql.js +26 -20
  29. package/dist/__generated__/CartStateUpdateMutation.graphql.d.ts +1 -1
  30. package/dist/__generated__/CartStateUpdateMutation.graphql.js +26 -20
  31. package/dist/__generated__/CheckoutUpdateCustomerMutation.graphql.d.ts +1 -1
  32. package/dist/__generated__/CheckoutUpdateCustomerMutation.graphql.js +26 -20
  33. package/dist/__generated__/CheckoutUpdateOrderMutation.graphql.d.ts +1 -1
  34. package/dist/__generated__/CheckoutUpdateOrderMutation.graphql.js +26 -20
  35. package/dist/__generated__/CollectionAa_Query.graphql.d.ts +1 -1
  36. package/dist/__generated__/CollectionAa_Query.graphql.js +20 -14
  37. package/dist/__generated__/CollectionAa_product.graphql.d.ts +7 -1
  38. package/dist/__generated__/CollectionAa_product.graphql.js +22 -16
  39. package/dist/__generated__/FontFamiliesQuery.graphql.d.ts +4 -1
  40. package/dist/__generated__/FontFamiliesQuery.graphql.js +46 -39
  41. package/dist/__generated__/NodePasswordFormElementIDQuery.graphql.d.ts +3 -3
  42. package/dist/__generated__/NodePasswordFormElementIDQuery.graphql.js +9 -9
  43. package/dist/__generated__/NodePasswordFormElementPackSlugQuery.graphql.d.ts +25 -0
  44. package/dist/__generated__/NodePasswordFormElementPackSlugQuery.graphql.js +108 -0
  45. package/dist/__generated__/PrecartAddToCartMutation.graphql.d.ts +1 -1
  46. package/dist/__generated__/PrecartAddToCartMutation.graphql.js +32 -26
  47. package/dist/__generated__/PriceBar_node.graphql.d.ts +4 -1
  48. package/dist/__generated__/PriceBar_node.graphql.js +23 -16
  49. package/dist/__generated__/StoreModalCartQuery.graphql.d.ts +1 -1
  50. package/dist/__generated__/StoreModalCartQuery.graphql.js +37 -31
  51. package/dist/__generated__/StoreModalFamily_collection.graphql.d.ts +3 -2
  52. package/dist/__generated__/StoreModalFamily_collection.graphql.js +3 -3
  53. package/dist/__generated__/StoreModalIndexPackItem_fontPack.graphql.d.ts +23 -0
  54. package/dist/__generated__/StoreModalIndexPackItem_fontPack.graphql.js +58 -0
  55. package/dist/__generated__/StoreModalIndexPaginationQuery.graphql.d.ts +23 -0
  56. package/dist/__generated__/StoreModalIndexPaginationQuery.graphql.js +303 -0
  57. package/dist/__generated__/StoreModalIndexQuery.graphql.d.ts +6 -3
  58. package/dist/__generated__/StoreModalIndexQuery.graphql.js +218 -117
  59. package/dist/__generated__/StoreModalIndex_viewer.graphql.d.ts +24 -0
  60. package/dist/__generated__/StoreModalIndex_viewer.graphql.js +134 -0
  61. package/dist/__generated__/StoreModalPackButton_fontPack.graphql.d.ts +33 -0
  62. package/dist/__generated__/StoreModalPackButton_fontPack.graphql.js +119 -0
  63. package/dist/__generated__/StoreModalPack_fontPack.graphql.d.ts +45 -0
  64. package/dist/__generated__/StoreModalPack_fontPack.graphql.js +150 -0
  65. package/dist/__generated__/StoreModalProductContent_collection.graphql.d.ts +6 -2
  66. package/dist/__generated__/StoreModalProductContent_collection.graphql.js +43 -19
  67. package/dist/__generated__/{StoreModalProductLicenseSelection_collection.graphql.d.ts → StoreModalProductLicenseSelection_licenseable.graphql.d.ts} +7 -6
  68. package/dist/__generated__/StoreModalProductLicenseSelection_licenseable.graphql.js +43 -0
  69. package/dist/__generated__/StoreModalProductQuery.graphql.d.ts +1 -1
  70. package/dist/__generated__/StoreModalProductQuery.graphql.js +199 -142
  71. package/dist/__generated__/StoreModalProductRefetchQuery.graphql.d.ts +1 -1
  72. package/dist/__generated__/StoreModalProductRefetchQuery.graphql.js +190 -133
  73. package/dist/__generated__/StoreModalProductSlugQuery.graphql.d.ts +5 -1
  74. package/dist/__generated__/StoreModalProductSlugQuery.graphql.js +254 -176
  75. package/dist/__generated__/StoreModalProductSummaryRefetchQuery.graphql.d.ts +1 -1
  76. package/dist/__generated__/StoreModalProductSummaryRefetchQuery.graphql.js +9 -4
  77. package/dist/__generated__/StoreModalProductSummary_viewer.graphql.d.ts +7 -1
  78. package/dist/__generated__/StoreModalProductSummary_viewer.graphql.js +7 -2
  79. package/dist/__generated__/TestFontsFormUpdateCustomerMutation.graphql.d.ts +1 -1
  80. package/dist/__generated__/TestFontsFormUpdateCustomerMutation.graphql.js +26 -20
  81. package/dist/__generated__/TypeTestersIDQuery.graphql.d.ts +1 -1
  82. package/dist/__generated__/TypeTestersIDQuery.graphql.js +17 -10
  83. package/dist/__generated__/TypeTestersRefetchQuery.graphql.d.ts +1 -1
  84. package/dist/__generated__/TypeTestersRefetchQuery.graphql.js +17 -10
  85. package/dist/__generated__/TypeTestersSlugQuery.graphql.d.ts +1 -1
  86. package/dist/__generated__/TypeTestersSlugQuery.graphql.js +17 -10
  87. package/dist/__generated__/productState_Query.graphql.d.ts +99 -1
  88. package/dist/__generated__/productState_Query.graphql.js +43 -4
  89. package/dist/__generated__/productState_fontPack.graphql.d.ts +111 -0
  90. package/dist/__generated__/productState_fontPack.graphql.js +117 -0
  91. package/dist/__generated__/storefrontEventsTrackStorefrontEventMutation.graphql.d.ts +41 -0
  92. package/dist/__generated__/storefrontEventsTrackStorefrontEventMutation.graphql.js +65 -0
  93. package/dist/__tests__/bundleSelectionOrder.test.js +94 -0
  94. package/dist/__tests__/collectionBundleSelection.test.js +443 -1446
  95. package/dist/__tests__/fontPackSelection.test.js +435 -0
  96. package/dist/__tests__/infiniteScroll.test.js +180 -0
  97. package/dist/__tests__/licenseExclusions.test.js +4 -1
  98. package/dist/__tests__/storeModalPackButton.test.js +102 -0
  99. package/dist/__tests__/storeModalPackUnlisted.test.js +112 -0
  100. package/dist/__tests__/storeModalRoutes.test.js +9 -0
  101. package/dist/__tests__/storefrontEvents.test.js +167 -0
  102. package/dist/__tests__/typeTesterAutofitFeatures.test.js +138 -0
  103. package/dist/components/AddToCartBanner/index.js +1 -1
  104. package/dist/components/BuyButton/index.d.ts +29 -9
  105. package/dist/components/BuyButton/index.js +123 -26
  106. package/dist/components/BuyButton/index.server.d.ts +4 -2
  107. package/dist/components/BuyButton/index.server.js +24 -3
  108. package/dist/components/Cart/CartItem/CartItemProduct.js +3 -3
  109. package/dist/components/Cart/Checkout.js +11 -1
  110. package/dist/components/Cart/storefrontEvents.d.ts +34 -0
  111. package/dist/components/Cart/storefrontEvents.js +138 -0
  112. package/dist/components/CollectionAa/index.js +2 -2
  113. package/dist/components/FontFamilies/index.js +4 -3
  114. package/dist/components/NodePasswordForm/NodePasswordFormElement.d.ts +1 -1
  115. package/dist/components/NodePasswordForm/NodePasswordFormElement.js +45 -21
  116. package/dist/components/NodePasswordForm/index.d.ts +7 -4
  117. package/dist/components/NodePasswordForm/index.js +6 -6
  118. package/dist/components/Precart/index.js +6 -0
  119. package/dist/components/PriceBar/index.js +5 -3
  120. package/dist/components/Root/productState.d.ts +2 -8
  121. package/dist/components/Root/productState.js +100 -61
  122. package/dist/components/SKUPrice/index.js +7 -8
  123. package/dist/components/StoreModal/StoreModalFamily.d.ts +7 -0
  124. package/dist/components/StoreModal/StoreModalFamily.js +11 -7
  125. package/dist/components/StoreModal/StoreModalIndex.js +58 -7
  126. package/dist/components/StoreModal/StoreModalIndexEntry.d.ts +13 -0
  127. package/dist/components/StoreModal/StoreModalIndexEntry.js +43 -0
  128. package/dist/components/StoreModal/StoreModalIndexItem.js +7 -30
  129. package/dist/components/StoreModal/StoreModalIndexPackItem.d.ts +7 -0
  130. package/dist/components/StoreModal/StoreModalIndexPackItem.js +21 -0
  131. package/dist/components/StoreModal/StoreModalPack.d.ts +9 -0
  132. package/dist/components/StoreModal/StoreModalPack.js +79 -0
  133. package/dist/components/StoreModal/StoreModalPackButton.d.ts +8 -0
  134. package/dist/components/StoreModal/StoreModalPackButton.js +53 -0
  135. package/dist/components/StoreModal/StoreModalProduct.js +49 -19
  136. package/dist/components/StoreModalProductLicenseSelection/StoreModalProductLicense.d.ts +2 -1
  137. package/dist/components/StoreModalProductLicenseSelection/StoreModalProductLicense.js +8 -3
  138. package/dist/components/StoreModalProductLicenseSelection/index.d.ts +3 -3
  139. package/dist/components/StoreModalProductLicenseSelection/index.js +7 -6
  140. package/dist/components/StoreModalProductSummary/index.js +1 -1
  141. package/dist/components/TypeTester/useTypeTesterStyler.js +1 -0
  142. package/dist/components/elements/StoreModalContainer/StoreModalContainerContext.d.ts +1 -0
  143. package/dist/components/elements/StoreModalContainer/index.js +9 -4
  144. package/dist/components/elements/StoreModalFamily/index.d.ts +1 -1
  145. package/dist/components/elements/StoreModalFamily/index.js +1 -1
  146. package/dist/components/elements/StoreModalIndexLoadMore/index.d.ts +8 -0
  147. package/dist/components/elements/StoreModalIndexLoadMore/index.js +21 -0
  148. package/dist/components/elements/StoreModalUnifiedCheckout.js +12 -0
  149. package/dist/components/useInfiniteScroll.d.ts +28 -0
  150. package/dist/components/useInfiniteScroll.js +50 -0
  151. package/dist/fontdue.css +39 -0
  152. package/dist/hooks/useAutofit.d.ts +2 -1
  153. package/dist/hooks/useAutofit.js +10 -4
  154. package/dist/reducer.d.ts +12 -5
  155. package/dist/reducer.js +18 -87
  156. package/dist/selection.d.ts +44 -0
  157. package/dist/selection.js +539 -0
  158. package/dist/storeModalRoutes.js +5 -4
  159. package/dist/utils.d.ts +1 -12
  160. package/dist/utils.js +1 -36
  161. package/dist/version.js +1 -1
  162. package/package.json +1 -1
  163. package/dist/__generated__/BuyButton_collection.graphql.d.ts +0 -25
  164. package/dist/__generated__/BuyButton_collection.graphql.js +0 -49
  165. package/dist/__generated__/StoreModalProductLicenseSelection_collection.graphql.js +0 -40
  166. package/fontdue.css +0 -2733
  167. package/fontdue.css.map +0 -1
@@ -1,20 +1,71 @@
1
+ import _StoreModalIndex_viewer from "../../__generated__/StoreModalIndex_viewer.graphql.js";
1
2
  import _StoreModalIndexQuery from "../../__generated__/StoreModalIndexQuery.graphql.js";
2
- import React from 'react';
3
- import { graphql, usePreloadedQuery } from 'react-relay';
3
+ import React, { useCallback, useContext } from 'react';
4
+ import { graphql, usePaginationFragment, usePreloadedQuery } from 'react-relay';
4
5
  import StoreModalPageContainer from '../elements/StoreModalPageContainer/index.js';
6
+ import StoreModalIndexLoadMore from '../elements/StoreModalIndexLoadMore/index.js';
7
+ import StoreModalContainerContext from '../elements/StoreModalContainer/StoreModalContainerContext.js';
5
8
  import StoreModalIndexItem from './StoreModalIndexItem.js';
9
+ import StoreModalIndexPackItem from './StoreModalIndexPackItem.js';
10
+ import useInfiniteScroll from '../useInfiniteScroll.js';
11
+
12
+ // How many collections arrive at a time. Enough that a typical catalogue is one
13
+ // request, few enough that a large one doesn't make the visitor wait for every
14
+ // collection's feature style before anything renders. The GraphQL below can't
15
+ // interpolate, so the same number is written into the query's `$count` default
16
+ // and the fragment's argument definitions — keep the three in step.
17
+ const PAGE_SIZE = 25;
18
+
19
+ // Start the next page while the sentinel is still this far below the modal's
20
+ // visible area, so the pages join up without the visitor reaching a dead end.
21
+ const LOAD_MORE_MARGIN = '0px 0px 600px 0px';
22
+ // Font packs come first: they're the curated, cross-catalog offers, and there
23
+ // are few of them next to the families – so they arrive whole, with the first
24
+ // page of collections, rather than paginated. Both lists honour the same
25
+ // `indexExcludeTags`, and the backend already leaves out hidden, unlisted and
26
+ // still-locked password-protected packs, as it does for collections.
6
27
  const StoreModalIndex = _ref => {
7
- var _viewer$rootCollectio;
28
+ var _queryData$viewer, _queryData$viewer$fon, _data$rootCollections;
8
29
  let {
9
30
  prepared
10
31
  } = _ref;
11
- const data = usePreloadedQuery((_StoreModalIndexQuery.hash && _StoreModalIndexQuery.hash !== "099c77808b41054885365ebe3eda03c8" && console.error("The definition of 'StoreModalIndexQuery' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _StoreModalIndexQuery), prepared.indexQuery);
12
- const viewer = data.viewer;
13
- const edges = (viewer === null || viewer === void 0 ? void 0 : (_viewer$rootCollectio = viewer.rootCollections) === null || _viewer$rootCollectio === void 0 ? void 0 : _viewer$rootCollectio.edges) ?? [];
32
+ const queryData = usePreloadedQuery((_StoreModalIndexQuery.hash && _StoreModalIndexQuery.hash !== "cea53722e4ce3c40a68997218f7e979f" && console.error("The definition of 'StoreModalIndexQuery' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _StoreModalIndexQuery), prepared.indexQuery);
33
+
34
+ // The query type only carries the fragment spread, not its data type, so
35
+ // both sides are named explicitly for `data` to be typed.
36
+ const {
37
+ data,
38
+ loadNext,
39
+ hasNext,
40
+ isLoadingNext
41
+ } = usePaginationFragment((_StoreModalIndex_viewer.hash && _StoreModalIndex_viewer.hash !== "f4bd120deb8eea66de4257529cbb022e" && console.error("The definition of 'StoreModalIndex_viewer' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _StoreModalIndex_viewer), queryData.viewer);
42
+ const {
43
+ scrollContainer
44
+ } = useContext(StoreModalContainerContext);
45
+ const handleLoadMore = useCallback(() => {
46
+ // Relay ignores this while a page is already in flight, so the observer
47
+ // firing repeatedly on the way down costs nothing.
48
+ loadNext(PAGE_SIZE);
49
+ }, [loadNext]);
50
+ const sentinelRef = useInfiniteScroll({
51
+ enabled: hasNext && !isLoadingNext,
52
+ onLoadMore: handleLoadMore,
53
+ rootRef: scrollContainer,
54
+ rootMargin: LOAD_MORE_MARGIN
55
+ });
56
+ const packEdges = ((_queryData$viewer = queryData.viewer) === null || _queryData$viewer === void 0 ? void 0 : (_queryData$viewer$fon = _queryData$viewer.fontPacks) === null || _queryData$viewer$fon === void 0 ? void 0 : _queryData$viewer$fon.edges) ?? [];
57
+ const edges = (data === null || data === void 0 ? void 0 : (_data$rootCollections = data.rootCollections) === null || _data$rootCollections === void 0 ? void 0 : _data$rootCollections.edges) ?? [];
14
58
  return /*#__PURE__*/React.createElement(StoreModalPageContainer, null, {
15
- body: edges.map(edge => /*#__PURE__*/React.createElement(StoreModalIndexItem, {
59
+ body: /*#__PURE__*/React.createElement(React.Fragment, null, packEdges.map(edge => /*#__PURE__*/React.createElement(StoreModalIndexPackItem, {
60
+ pack: edge.node,
61
+ key: edge.node.id
62
+ })), edges.map(edge => /*#__PURE__*/React.createElement(StoreModalIndexItem, {
16
63
  collection: edge.node,
17
64
  key: edge.node.id
65
+ })), hasNext && /*#__PURE__*/React.createElement(StoreModalIndexLoadMore, {
66
+ sentinelRef: sentinelRef,
67
+ onClick: handleLoadMore,
68
+ loading: isLoadingNext
18
69
  }))
19
70
  });
20
71
  };
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { FontStyle_fontStyle$key } from '__generated__/FontStyle_fontStyle.graphql.js';
3
+ type FeatureStyle = FontStyle_fontStyle$key & {
4
+ readonly supportedLanguages: readonly string[] | null | undefined;
5
+ };
6
+ interface StoreModalIndexEntryProps {
7
+ productId: string;
8
+ name: string;
9
+ featureStyle: FeatureStyle | null | undefined;
10
+ label: string;
11
+ }
12
+ declare const StoreModalIndexEntry: ({ productId, name, featureStyle, label, }: StoreModalIndexEntryProps) => React.JSX.Element;
13
+ export default StoreModalIndexEntry;
@@ -0,0 +1,43 @@
1
+ import React, { useContext } from 'react';
2
+ import { useDispatch } from 'react-redux';
3
+ import StoreModalIndexItemElement from '../elements/StoreModalIndexItem/index.js';
4
+ import ConfigContext from '../ConfigContext.js';
5
+ import FontStyle from '../FontStyle/index.js';
6
+ import { getFeatureGlyphs } from '../../utils.js';
7
+ // One row of the store modal's index page. Collections and packs share this
8
+ // – the `indexLayout` config decides whether the feature style draws an "Aa"
9
+ // beside the name or the name itself – and only differ in what they say
10
+ // under the name.
11
+ const StoreModalIndexEntry = _ref => {
12
+ let {
13
+ productId,
14
+ name,
15
+ featureStyle,
16
+ label
17
+ } = _ref;
18
+ const {
19
+ storeModal: config
20
+ } = useContext(ConfigContext);
21
+ const dispatch = useDispatch();
22
+ const handleClick = () => {
23
+ dispatch({
24
+ type: 'STORE_MODAL_NAVIGATE',
25
+ route: 'product',
26
+ variables: {
27
+ productId
28
+ }
29
+ });
30
+ };
31
+ return /*#__PURE__*/React.createElement(StoreModalIndexItemElement, {
32
+ onClick: handleClick
33
+ }, {
34
+ aa: config.indexLayout === 'styled-aa' && (featureStyle ? /*#__PURE__*/React.createElement(FontStyle, {
35
+ fontStyle: featureStyle
36
+ }, getFeatureGlyphs(featureStyle.supportedLanguages ?? null)) : null),
37
+ name: config.indexLayout === 'styled-font-names' ? featureStyle && /*#__PURE__*/React.createElement(FontStyle, {
38
+ fontStyle: featureStyle
39
+ }, name) : name,
40
+ label
41
+ });
42
+ };
43
+ export default StoreModalIndexEntry;
@@ -1,31 +1,14 @@
1
1
  import _StoreModalIndexItem_fontCollection from "../../__generated__/StoreModalIndexItem_fontCollection.graphql.js";
2
- import React, { useContext } from 'react';
3
- import { useDispatch } from 'react-redux';
2
+ import React from 'react';
4
3
  import { graphql, useFragment } from 'react-relay';
5
- import StoreModalIndexItemElement from '../elements/StoreModalIndexItem/index.js';
6
- import ConfigContext from '../ConfigContext.js';
7
- import FontStyle from '../FontStyle/index.js';
4
+ import StoreModalIndexEntry from './StoreModalIndexEntry.js';
8
5
  import useTotalStyles from '../useTotalStyles.js';
9
- import { getFeatureGlyphs, pluralize } from '../../utils.js';
6
+ import { pluralize } from '../../utils.js';
10
7
  const StoreModalIndexItem = _ref => {
11
- var _data$featureStyle;
12
8
  let {
13
9
  collection
14
10
  } = _ref;
15
- const {
16
- storeModal: config
17
- } = useContext(ConfigContext);
18
11
  const data = useFragment((_StoreModalIndexItem_fontCollection.hash && _StoreModalIndexItem_fontCollection.hash !== "8a990fad8dc50c9f00b391902e9bc482" && console.error("The definition of 'StoreModalIndexItem_fontCollection' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _StoreModalIndexItem_fontCollection), collection);
19
- const dispatch = useDispatch();
20
- const handleClickProduct = productId => {
21
- dispatch({
22
- type: 'STORE_MODAL_NAVIGATE',
23
- route: 'product',
24
- variables: {
25
- productId
26
- }
27
- });
28
- };
29
12
  const {
30
13
  totalStyles,
31
14
  variableFonts
@@ -39,16 +22,10 @@ const StoreModalIndexItem = _ref => {
39
22
  if (variableFonts > 0) {
40
23
  label.push(pluralize(variableFonts, 'variable font'));
41
24
  }
42
- return /*#__PURE__*/React.createElement(StoreModalIndexItemElement, {
43
- key: data.id,
44
- onClick: handleClickProduct.bind(null, data.id)
45
- }, {
46
- aa: config.indexLayout === 'styled-aa' && (data.featureStyle ? /*#__PURE__*/React.createElement(FontStyle, {
47
- fontStyle: data.featureStyle
48
- }, getFeatureGlyphs((_data$featureStyle = data.featureStyle) === null || _data$featureStyle === void 0 ? void 0 : _data$featureStyle.supportedLanguages)) : null),
49
- name: config.indexLayout === 'styled-font-names' ? data.featureStyle && /*#__PURE__*/React.createElement(FontStyle, {
50
- fontStyle: data.featureStyle
51
- }, data.name) : data.name,
25
+ return /*#__PURE__*/React.createElement(StoreModalIndexEntry, {
26
+ productId: data.id,
27
+ name: data.name,
28
+ featureStyle: data.featureStyle,
52
29
  label: label.join(', ')
53
30
  });
54
31
  };
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { StoreModalIndexPackItem_fontPack$key } from '__generated__/StoreModalIndexPackItem_fontPack.graphql.js';
3
+ interface StoreModalIndexPackItemProps {
4
+ pack: StoreModalIndexPackItem_fontPack$key;
5
+ }
6
+ declare const StoreModalIndexPackItem: ({ pack }: StoreModalIndexPackItemProps) => React.JSX.Element;
7
+ export default StoreModalIndexPackItem;
@@ -0,0 +1,21 @@
1
+ import _StoreModalIndexPackItem_fontPack from "../../__generated__/StoreModalIndexPackItem_fontPack.graphql.js";
2
+ import React from 'react';
3
+ import { graphql, useFragment } from 'react-relay';
4
+ import StoreModalIndexEntry from './StoreModalIndexEntry.js';
5
+ import { pluralize } from '../../utils.js';
6
+ // A pack's name alone ("Anniversary Pack") doesn't tell a visitor it spans
7
+ // families, so its subhead says what it is before the style count.
8
+ const packIndexLabel = totalStyles => totalStyles ? `Font pack • ${pluralize(totalStyles, 'style')}` : 'Font pack';
9
+ const StoreModalIndexPackItem = _ref => {
10
+ let {
11
+ pack
12
+ } = _ref;
13
+ const data = useFragment((_StoreModalIndexPackItem_fontPack.hash && _StoreModalIndexPackItem_fontPack.hash !== "47273d9e96f713344a4e62f4c5517161" && console.error("The definition of 'StoreModalIndexPackItem_fontPack' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _StoreModalIndexPackItem_fontPack), pack);
14
+ return /*#__PURE__*/React.createElement(StoreModalIndexEntry, {
15
+ productId: data.id,
16
+ name: data.name,
17
+ featureStyle: data.featureStyle,
18
+ label: packIndexLabel(data.totalStyles)
19
+ });
20
+ };
21
+ export default StoreModalIndexPackItem;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { StoreModalPack_fontPack$key } from '../../__generated__/StoreModalPack_fontPack.graphql.js';
3
+ interface StoreModalPackProps {
4
+ pack: StoreModalPack_fontPack$key;
5
+ onSelect: (skuId: string, selected: boolean) => void;
6
+ title?: React.ReactNode;
7
+ }
8
+ export default function StoreModalPack({ pack: packKey, onSelect, title }: StoreModalPackProps): React.JSX.Element;
9
+ export {};
@@ -0,0 +1,79 @@
1
+ import _StoreModalPack_fontPack from "../../__generated__/StoreModalPack_fontPack.graphql.js";
2
+ import React, { Fragment, useMemo } from 'react';
3
+ import { graphql, useFragment } from 'react-relay';
4
+ import StoreModalFamily, { stylesGrouped } from './StoreModalFamily.js';
5
+ import StoreModalPackButton from './StoreModalPackButton.js';
6
+ import StyleButton from './StoreModalStyleButton.js';
7
+ import FamilyElement from '../elements/StoreModalFamily/index.js';
8
+
9
+ // A pack's members render as family blocks: a collection member is the whole
10
+ // family (or superfamily) as it appears on its own product page; style
11
+ // members are gathered under their family, in the order the first of them
12
+ // appears, as a partial block of just those styles.
13
+
14
+ // An unlisted collection has no block anywhere in the Store Modal – no family
15
+ // button, bundles or styles (see StoreModalProduct). A pack still grants it,
16
+ // and the pack button still sells it, but it isn't offered on its own here.
17
+ const memberBlocks = members => members.reduce((blocks, member) => {
18
+ var _member$family, _member$family2, _member$family3, _member$family4;
19
+ if (member.__typename === 'FontCollection') {
20
+ if (member.visibility === 'UNLISTED') return blocks;
21
+ return blocks.concat({
22
+ kind: 'collection',
23
+ collection: member
24
+ });
25
+ }
26
+ if (member.__typename !== 'FontStyle') return blocks;
27
+ if (((_member$family = member.family) === null || _member$family === void 0 ? void 0 : _member$family.visibility) === 'UNLISTED') return blocks;
28
+ const familyId = ((_member$family2 = member.family) === null || _member$family2 === void 0 ? void 0 : _member$family2.id) ?? member.id;
29
+ const existing = blocks.find(block => block.kind === 'styles' && block.familyId === familyId);
30
+ if ((existing === null || existing === void 0 ? void 0 : existing.kind) === 'styles') {
31
+ existing.styles.push(member);
32
+ return blocks;
33
+ }
34
+ return blocks.concat({
35
+ kind: 'styles',
36
+ familyId,
37
+ familyName: ((_member$family3 = member.family) === null || _member$family3 === void 0 ? void 0 : _member$family3.name) ?? '',
38
+ isVariableFont: ((_member$family4 = member.family) === null || _member$family4 === void 0 ? void 0 : _member$family4.isVariableFont) ?? false,
39
+ styles: [member]
40
+ });
41
+ }, []);
42
+ export default function StoreModalPack(_ref) {
43
+ let {
44
+ pack: packKey,
45
+ onSelect,
46
+ title
47
+ } = _ref;
48
+ const pack = useFragment((_StoreModalPack_fontPack.hash && _StoreModalPack_fontPack.hash !== "5bbb13828a56279be2b22df22ad4aae0" && console.error("The definition of 'StoreModalPack_fontPack' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _StoreModalPack_fontPack), packKey);
49
+ const blocks = useMemo(() => memberBlocks(pack.members), [pack.members]);
50
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FamilyElement, null, {
51
+ title,
52
+ familyButton: /*#__PURE__*/React.createElement(StoreModalPackButton, {
53
+ pack: pack,
54
+ onSelectSku: onSelect
55
+ })
56
+ }), blocks.map(block => {
57
+ var _block$collection$chi;
58
+ return block.kind === 'collection' ? /*#__PURE__*/React.createElement(Fragment, {
59
+ key: `collection:${block.collection.id}`
60
+ }, /*#__PURE__*/React.createElement(StoreModalFamily, {
61
+ collection: block.collection,
62
+ onSelect: onSelect
63
+ }), (_block$collection$chi = block.collection.children) === null || _block$collection$chi === void 0 ? void 0 : _block$collection$chi.filter(child => child.visibility !== 'UNLISTED').map(child => /*#__PURE__*/React.createElement(StoreModalFamily, {
64
+ key: child.id,
65
+ collection: child,
66
+ onSelect: onSelect
67
+ }))) : /*#__PURE__*/React.createElement(FamilyElement, {
68
+ key: `styles:${block.familyId}`
69
+ }, {
70
+ title: block.familyName,
71
+ styleGroups: stylesGrouped(block.styles).map(group => group.map(fontStyle => /*#__PURE__*/React.createElement(StyleButton, {
72
+ key: fontStyle.id,
73
+ fontStyle: fontStyle,
74
+ onSelectSku: onSelect,
75
+ isVariableFont: block.isVariableFont
76
+ })))
77
+ });
78
+ }));
79
+ }
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { StoreModalPackButton_fontPack$key } from '../../__generated__/StoreModalPackButton_fontPack.graphql.js';
3
+ interface PackButtonProps {
4
+ pack: StoreModalPackButton_fontPack$key;
5
+ onSelectSku: (skuId: string, selected: boolean) => void;
6
+ }
7
+ export default function StoreModalPackButton({ pack: packKey, onSelectSku, ...rest }: PackButtonProps): React.JSX.Element;
8
+ export {};
@@ -0,0 +1,53 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
+ import _StoreModalPackButton_fontPack from "../../__generated__/StoreModalPackButton_fontPack.graphql.js";
3
+ import React from 'react';
4
+ import { graphql, useFragment } from 'react-relay';
5
+ import { useSelector } from 'react-redux';
6
+ import SKUPrice from '../SKUPrice/index.js';
7
+ import RelayPrice, { PriceFormat } from '../Price/index.js';
8
+ import { isSelected } from '../../reducer.js';
9
+ import StoreModalFamilyButtonElement from '../elements/StoreModalFamilyButton/index.js';
10
+ import FontStyle from '../FontStyle/index.js';
11
+ import { pluralize } from '../../utils.js';
12
+ // The pack's own row at the top of the product page — the family button's
13
+ // markup, buying the whole pack at its one fixed price, under the pack's name
14
+ // exactly as the admin entered it (the index, cart and BuyButton show the
15
+ // same). Beside the price it strikes through what the styles would cost one
16
+ // by one.
17
+ export default function StoreModalPackButton(_ref) {
18
+ var _pack$featureStyle, _pack$featureStyle$su, _pack$sku;
19
+ let {
20
+ pack: packKey,
21
+ onSelectSku,
22
+ ...rest
23
+ } = _ref;
24
+ const pack = useFragment((_StoreModalPackButton_fontPack.hash && _StoreModalPackButton_fontPack.hash !== "9075ef7d1f8c2ce1fa8beba0884713cb" && console.error("The definition of 'StoreModalPackButton_fontPack' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _StoreModalPackButton_fontPack), packKey);
25
+ const selector = pack.sku ? isSelected(pack.sku.id) : () => false;
26
+ const selected = useSelector(selector);
27
+ const handleClick = () => {
28
+ if (!pack.sku) return;
29
+ onSelectSku(pack.sku.id, !selected);
30
+ };
31
+ const supportsEnglish = (_pack$featureStyle = pack.featureStyle) === null || _pack$featureStyle === void 0 ? void 0 : (_pack$featureStyle$su = _pack$featureStyle.supportedLanguages) === null || _pack$featureStyle$su === void 0 ? void 0 : _pack$featureStyle$su.includes('en');
32
+ const showsSaving = ((_pack$sku = pack.sku) === null || _pack$sku === void 0 ? void 0 : _pack$sku.price) && pack.totalStylesPrice && pack.totalStylesPrice.amount > pack.sku.price.amount;
33
+ return /*#__PURE__*/React.createElement(StoreModalFamilyButtonElement, _extends({
34
+ selected: selected,
35
+ onClick: pack.sku ? handleClick : undefined,
36
+ supportsEnglish: supportsEnglish ?? true
37
+ }, rest), {
38
+ name: pack.featureStyle && supportsEnglish ? /*#__PURE__*/React.createElement(FontStyle, {
39
+ Component: "span",
40
+ fontStyle: pack.featureStyle
41
+ }, pack.name) : /*#__PURE__*/React.createElement("span", null, pack.name),
42
+ label: pack.totalStyles ? pluralize(pack.totalStyles, 'style') : '',
43
+ price: pack.sku && /*#__PURE__*/React.createElement(React.Fragment, null, showsSaving && /*#__PURE__*/React.createElement("s", {
44
+ className: "store-modal__family-button__styles-price"
45
+ }, /*#__PURE__*/React.createElement(RelayPrice, {
46
+ price: pack.totalStylesPrice,
47
+ format: PriceFormat.Truncated
48
+ })), /*#__PURE__*/React.createElement(SKUPrice, {
49
+ sku: pack.sku,
50
+ format: PriceFormat.Truncated
51
+ }))
52
+ });
53
+ }
@@ -6,6 +6,7 @@ import React, { Fragment, useCallback, useContext, useEffect, useMemo } from 're
6
6
  import { graphql, useRelayEnvironment, useFragment, usePreloadedQuery, useRefetchableFragment } from 'react-relay';
7
7
  import { shallowEqual, useDispatch, useSelector, useStore } from 'react-redux';
8
8
  import StoreModalFamily from './StoreModalFamily.js';
9
+ import StoreModalPack from './StoreModalPack.js';
9
10
  import StoreModalProductSummary from '../StoreModalProductSummary/index.js';
10
11
  import StoreModalPageContainer from '../elements/StoreModalPageContainer/index.js';
11
12
  import StoreModalProductLicenseSelection from '../StoreModalProductLicenseSelection/index.js';
@@ -16,20 +17,21 @@ import ConfigContext from '../ConfigContext.js';
16
17
  import { useRefetchOnLicenseChanges } from '../../hooks/useRefetchOnLicenseChanges.js';
17
18
  import StoreModalLicenseeIsBillingSelection from './StoreModalLicenseeIsBillingSelection.js';
18
19
  import { useLicenseAndOrderVariables } from '../../hooks/useLicenseAndOrderVariables.js';
20
+ import { trackProductViewed } from '../Cart/storefrontEvents.js';
19
21
 
20
- // A product is addressed by collection id or by slug — the same two
21
- // identifiers `BuyButton` takes. Two queries rather than one with `@skip`,
22
+ // A product – a collection or a font pack – is addressed by id or by slug,
23
+ // the same two identifiers `BuyButton` takes. Two queries rather than one with `@skip`,
22
24
  // so each carries only the selection it needs; both hand the same collection
23
25
  // and viewer to `StoreModalProductContent` below.
24
26
  export const productIdQuery = (_StoreModalProductQuery.hash && _StoreModalProductQuery.hash !== "e3ca6ec04f2df35aa68baf439c70cf42" && console.error("The definition of 'StoreModalProductQuery' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _StoreModalProductQuery);
25
27
 
26
- // No `@required` on `fontCollection` here, unlike BuyButton: a slug naming
27
- // nothing — or naming an article rather than a collection — should land on
28
- // StoreModalProductContent's "Collection not found", not throw.
29
- export const productSlugQuery = (_StoreModalProductSlugQuery.hash && _StoreModalProductSlugQuery.hash !== "f0bb35ed9f88ad214b40fd1f3b92fed0" && console.error("The definition of 'StoreModalProductSlugQuery' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _StoreModalProductSlugQuery);
28
+ // No `@required` on `fontCollection` / `fontPack` here, unlike BuyButton: a
29
+ // slug naming nothing — or naming an article rather than a product — should
30
+ // land on StoreModalProductContent's "Product not found", not throw.
31
+ export const productSlugQuery = (_StoreModalProductSlugQuery.hash && _StoreModalProductSlugQuery.hash !== "bd2c1bf7b7b154501ea47213af58725e" && console.error("The definition of 'StoreModalProductSlugQuery' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _StoreModalProductSlugQuery);
30
32
  const productViewerFragment = (_StoreModalProductViewer.hash && _StoreModalProductViewer.hash !== "3d2fc7da461822a44bb26e9b3f1715fb" && console.error("The definition of 'StoreModalProductViewer' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _StoreModalProductViewer);
31
33
  const StoreModalProductContent = _ref => {
32
- var _config$storeModal, _viewer$orderVariable, _viewer$settings, _viewer$settings2, _viewer$settings3, _viewer$settings4, _viewer$settings5, _viewer$settings6, _viewer$settings7, _viewer$settings8, _collection$children;
34
+ var _config$storeModal, _viewer$orderVariable, _viewer$settings, _viewer$settings2, _viewer$settings3, _viewer$settings4, _viewer$settings5, _viewer$settings6, _viewer$settings7, _viewer$settings8;
33
35
  let {
34
36
  collection: collectionRef,
35
37
  viewer: viewerRef
@@ -37,8 +39,11 @@ const StoreModalProductContent = _ref => {
37
39
  const config = useContext(ConfigContext);
38
40
  const environment = useRelayEnvironment();
39
41
  const viewer = useFragment(productViewerFragment, viewerRef);
40
- const [data, refetch] = useRefetchableFragment((_StoreModalProductContent_collection.hash && _StoreModalProductContent_collection.hash !== "0684ec2633ccc5d4d0866e7780df28cc" && console.error("The definition of 'StoreModalProductContent_collection' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _StoreModalProductContent_collection), collectionRef ?? null);
41
- const collection = data;
42
+ const [data, refetch] = useRefetchableFragment((_StoreModalProductContent_collection.hash && _StoreModalProductContent_collection.hash !== "c8ce87bca2032637d922f535fc168f56" && console.error("The definition of 'StoreModalProductContent_collection' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _StoreModalProductContent_collection), collectionRef ?? null);
43
+
44
+ // The product page sells a collection or a font pack; anything else the id
45
+ // resolves to is not a product.
46
+ const collection = (data === null || data === void 0 ? void 0 : data.__typename) === 'FontCollection' || (data === null || data === void 0 ? void 0 : data.__typename) === 'FontPack' ? data : null;
42
47
  const refetchVariables = useMemo(() => collection !== null && collection !== void 0 && collection.id ? {
43
48
  id: collection.id
44
49
  } : undefined, [collection === null || collection === void 0 ? void 0 : collection.id]);
@@ -60,6 +65,24 @@ const StoreModalProductContent = _ref => {
60
65
  useEffect(() => {
61
66
  if (collection !== null && collection !== void 0 && collection.id) populateProductState(store, environment, collection.id);
62
67
  }, [collection === null || collection === void 0 ? void 0 : collection.id]);
68
+
69
+ // The page reports the product it shows, whether the route named it by id or
70
+ // by slug, so a selection made on it stays within what it shows
71
+ // (selection.ts).
72
+ useEffect(() => {
73
+ if (!(collection !== null && collection !== void 0 && collection.id)) return;
74
+ dispatch({
75
+ type: 'STORE_MODAL_VIEW_PRODUCT',
76
+ productId: collection.id
77
+ });
78
+ return () => dispatch({
79
+ type: 'STORE_MODAL_VIEW_PRODUCT',
80
+ productId: null
81
+ });
82
+ }, [collection === null || collection === void 0 ? void 0 : collection.id]);
83
+ useEffect(() => {
84
+ if (collection !== null && collection !== void 0 && collection.id) trackProductViewed(environment, collection.id);
85
+ }, [collection === null || collection === void 0 ? void 0 : collection.id]);
63
86
  useEffect(() => {
64
87
  return () => {
65
88
  // unselect the skus when this component unmounts,
@@ -83,7 +106,7 @@ const StoreModalProductContent = _ref => {
83
106
  const requiredOrderVariablesNotYetSelected = (_viewer$orderVariable = viewer.orderVariables) === null || _viewer$orderVariable === void 0 ? void 0 : _viewer$orderVariable.filter(variable => variable.variableType === 'select').find(variable => !orderVariableSelections.find(selection => selection.orderVariableId === variable.id));
84
107
  if (!collection) {
85
108
  return /*#__PURE__*/React.createElement(StoreModalPageContainer, null, {
86
- body: 'Collection not found'
109
+ body: 'Product not found'
87
110
  });
88
111
  }
89
112
  const selectLicenseeLabel = /*#__PURE__*/React.createElement("div", {
@@ -126,6 +149,12 @@ const StoreModalProductContent = _ref => {
126
149
  __html: ((_viewer$settings8 = viewer.settings) === null || _viewer$settings8 === void 0 ? void 0 : _viewer$settings8.storeModalSelectFontsLabel) ?? ''
127
150
  }
128
151
  });
152
+
153
+ // An unlisted collection gets no block – no family button, bundles or
154
+ // styles – but stays in the product state, so selecting its siblings can
155
+ // still upgrade to it (an unlisted superfamily) or to a collection bundle
156
+ // containing it (an unlisted variable family).
157
+ const selectableFamilies = collection.__typename === 'FontCollection' ? [collection, ...(collection.children ?? [])].filter(family => family.visibility !== 'UNLISTED') : [];
129
158
  return /*#__PURE__*/React.createElement(StoreModalPageContainer, null, {
130
159
  body: /*#__PURE__*/React.createElement(Fragment, null, licensesPosition === 'top' && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(StoreModalLicenseeIsBillingSelection, {
131
160
  disabled: false
@@ -141,20 +170,21 @@ const StoreModalProductContent = _ref => {
141
170
  }, {
142
171
  label: selectOrderVariablesLabel
143
172
  }), /*#__PURE__*/React.createElement(StoreModalProductLicenseSelection, {
144
- collection: collection,
173
+ licenseable: collection,
145
174
  disabled: !hasSelectionForLicenseeIsBillingIdentity || Boolean(requiredOrderVariablesNotYetSelected)
146
175
  }, {
147
176
  label: selectLicensesLabel
148
177
  })), /*#__PURE__*/React.createElement("div", {
149
178
  className: "store-modal__families",
150
179
  "data-disabled": licensesPosition === 'top' ? !anyLicenseOptionsSelected || !hasSelectionForLicenseeIsBillingIdentity || !!requiredOrderVariablesNotYetSelected : false
151
- }, /*#__PURE__*/React.createElement(StoreModalFamily, {
180
+ }, collection.__typename === 'FontPack' ? /*#__PURE__*/React.createElement(StoreModalPack, {
152
181
  title: selectFontsLabel,
153
- collection: collection,
182
+ pack: collection,
154
183
  onSelect: handleSelectProduct
155
- }), (_collection$children = collection.children) === null || _collection$children === void 0 ? void 0 : _collection$children.map(child => /*#__PURE__*/React.createElement(StoreModalFamily, {
156
- key: child.id,
157
- collection: child,
184
+ }) : selectableFamilies.map((family, index) => /*#__PURE__*/React.createElement(StoreModalFamily, {
185
+ key: family.id,
186
+ title: index === 0 ? selectFontsLabel : undefined,
187
+ collection: family,
158
188
  onSelect: handleSelectProduct
159
189
  }))), licensesPosition === 'bottom' && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(StoreModalLicenseeIsBillingSelection, {
160
190
  disabled: !anySkusSelected
@@ -170,7 +200,7 @@ const StoreModalProductContent = _ref => {
170
200
  }, {
171
201
  label: selectOrderVariablesLabel
172
202
  }), /*#__PURE__*/React.createElement(StoreModalProductLicenseSelection, {
173
- collection: collection,
203
+ licenseable: collection,
174
204
  disabled: !anySkusSelected || !hasSelectionForLicenseeIsBillingIdentity || Boolean(requiredOrderVariablesNotYetSelected)
175
205
  }, {
176
206
  label: selectLicensesLabel
@@ -194,13 +224,13 @@ function StoreModalProductByIdRenderer(_ref2) {
194
224
  });
195
225
  }
196
226
  function StoreModalProductBySlugRenderer(_ref3) {
197
- var _data$viewer, _data$viewer$slug;
227
+ var _data$viewer, _data$viewer$slug, _data$viewer2, _data$viewer2$slug;
198
228
  let {
199
229
  prepared
200
230
  } = _ref3;
201
231
  const data = usePreloadedQuery(productSlugQuery, prepared.productQuery);
202
232
  return /*#__PURE__*/React.createElement(StoreModalProductContent, {
203
- collection: (_data$viewer = data.viewer) === null || _data$viewer === void 0 ? void 0 : (_data$viewer$slug = _data$viewer.slug) === null || _data$viewer$slug === void 0 ? void 0 : _data$viewer$slug.collection,
233
+ collection: ((_data$viewer = data.viewer) === null || _data$viewer === void 0 ? void 0 : (_data$viewer$slug = _data$viewer.slug) === null || _data$viewer$slug === void 0 ? void 0 : _data$viewer$slug.collection) ?? ((_data$viewer2 = data.viewer) === null || _data$viewer2 === void 0 ? void 0 : (_data$viewer2$slug = _data$viewer2.slug) === null || _data$viewer2$slug === void 0 ? void 0 : _data$viewer2$slug.pack),
204
234
  viewer: data.viewer
205
235
  });
206
236
  }
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import { StoreModalProductLicense_license$key } from '../../__generated__/StoreModalProductLicense_license.graphql.js';
3
3
  interface StoreModalProductLicenseProps {
4
4
  license: StoreModalProductLicense_license$key;
5
+ collectionId?: string;
5
6
  }
6
- export default function StoreModalProduceLicense({ license: licenseKey, }: StoreModalProductLicenseProps): React.JSX.Element;
7
+ export default function StoreModalProduceLicense({ license: licenseKey, collectionId, }: StoreModalProductLicenseProps): React.JSX.Element;
7
8
  export {};
@@ -6,6 +6,7 @@ import LicenseElement from './LicenseElement.js';
6
6
  import LicenseVariableElement from './LicenseVariableElement.js';
7
7
  import VariableTableAmounts from '../VariableTableAmounts/index.js';
8
8
  import LicenseVariableRadioElement from './LicenseVariableRadioElement.js';
9
+ import { useTrackProductCustomized } from '../Cart/storefrontEvents.js';
9
10
  const specFromLicense = license => {
10
11
  let licenseOptionSpec = {
11
12
  licenseId: license.id
@@ -31,7 +32,8 @@ const specFromLicense = license => {
31
32
  export default function StoreModalProduceLicense(_ref) {
32
33
  var _license$variables;
33
34
  let {
34
- license: licenseKey
35
+ license: licenseKey,
36
+ collectionId
35
37
  } = _ref;
36
38
  const license = useFragment((_StoreModalProductLicense_license.hash && _StoreModalProductLicense_license.hash !== "87cd41e76dcd8952d7096940a383b9f3" && console.error("The definition of 'StoreModalProductLicense_license' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _StoreModalProductLicense_license), licenseKey);
37
39
  const licenseOptions = useSelector(state => state.licenseOptions);
@@ -43,6 +45,7 @@ export default function StoreModalProduceLicense(_ref) {
43
45
  });
44
46
  const isSelected = Boolean(selectedOptions);
45
47
  const dispatch = useDispatch();
48
+ const trackCustomized = useTrackProductCustomized(collectionId);
46
49
  const handleSelectLicense = useCallback(() => {
47
50
  var _license$excludedLice;
48
51
  dispatch({
@@ -52,7 +55,8 @@ export default function StoreModalProduceLicense(_ref) {
52
55
  licenseOptionSpec: specFromLicense(license),
53
56
  excludedLicenseIds: (_license$excludedLice = license.excludedLicenses) === null || _license$excludedLice === void 0 ? void 0 : _license$excludedLice.map(l => l.id)
54
57
  });
55
- }, [dispatch, license, isSelected]);
58
+ trackCustomized();
59
+ }, [dispatch, license, isSelected, trackCustomized]);
56
60
  const handleLicenseOptionChange = useCallback(_ref3 => {
57
61
  let {
58
62
  variableId,
@@ -72,7 +76,8 @@ export default function StoreModalProduceLicense(_ref) {
72
76
  variableId,
73
77
  optionId
74
78
  });
75
- }, [dispatch, license, isSelected]);
79
+ trackCustomized();
80
+ }, [dispatch, license, isSelected, trackCustomized]);
76
81
  useEffect(() => {
77
82
  if (license.defaultSelected) {
78
83
  var _license$excludedLice3;
@@ -1,11 +1,11 @@
1
1
  import React from 'react';
2
- import { StoreModalProductLicenseSelection_collection$key } from '__generated__/StoreModalProductLicenseSelection_collection.graphql.js';
2
+ import { StoreModalProductLicenseSelection_licenseable$key } from '__generated__/StoreModalProductLicenseSelection_licenseable.graphql.js';
3
3
  interface StoreModalProductLicenseSelectionProps {
4
- collection: StoreModalProductLicenseSelection_collection$key;
4
+ licenseable: StoreModalProductLicenseSelection_licenseable$key;
5
5
  disabled: boolean;
6
6
  children: {
7
7
  label: React.ReactNode;
8
8
  };
9
9
  }
10
- export default function StoreModalProductLicenseSelection({ collection: collectionKey, disabled, children: { label }, }: StoreModalProductLicenseSelectionProps): React.JSX.Element;
10
+ export default function StoreModalProductLicenseSelection({ licenseable: licenseableKey, disabled, children: { label }, }: StoreModalProductLicenseSelectionProps): React.JSX.Element;
11
11
  export {};