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.
- package/CHANGELOG.md +14 -0
- package/README.md +5 -4
- package/dist/__generated__/AddToCartBannerQuery.graphql.d.ts +1 -1
- package/dist/__generated__/AddToCartBannerQuery.graphql.js +16 -10
- package/dist/__generated__/AddToCartBanner_item.graphql.d.ts +4 -1
- package/dist/__generated__/AddToCartBanner_item.graphql.js +7 -2
- package/dist/__generated__/AddToCartBanner_order.graphql.d.ts +4 -1
- package/dist/__generated__/AddToCartBanner_order.graphql.js +6 -1
- package/dist/__generated__/BuyButtonIDQuery.graphql.d.ts +3 -3
- package/dist/__generated__/BuyButtonIDQuery.graphql.js +31 -16
- package/dist/__generated__/BuyButtonPackIDQuery.graphql.d.ts +21 -0
- package/dist/__generated__/BuyButtonPackIDQuery.graphql.js +129 -0
- package/dist/__generated__/BuyButtonPackSlugQuery.graphql.d.ts +25 -0
- package/dist/__generated__/BuyButtonPackSlugQuery.graphql.js +167 -0
- package/dist/__generated__/BuyButtonSlugQuery.graphql.d.ts +3 -3
- package/dist/__generated__/BuyButtonSlugQuery.graphql.js +45 -17
- package/dist/__generated__/BuyButton_product.graphql.d.ts +27 -0
- package/dist/__generated__/BuyButton_product.graphql.js +72 -0
- package/dist/__generated__/CartItemProduct_product.graphql.d.ts +1 -1
- package/dist/__generated__/CartItemProduct_product.graphql.js +7 -2
- package/dist/__generated__/CartOrderCompleteOrderMutation.graphql.d.ts +1 -1
- package/dist/__generated__/CartOrderCompleteOrderMutation.graphql.js +26 -20
- package/dist/__generated__/CartOrderRemoveDiscountMutation.graphql.d.ts +1 -1
- package/dist/__generated__/CartOrderRemoveDiscountMutation.graphql.js +26 -20
- package/dist/__generated__/CartOrderUpdateMutation.graphql.d.ts +1 -1
- package/dist/__generated__/CartOrderUpdateMutation.graphql.js +26 -20
- package/dist/__generated__/CartQuery.graphql.d.ts +1 -1
- package/dist/__generated__/CartQuery.graphql.js +26 -20
- package/dist/__generated__/CartStateUpdateMutation.graphql.d.ts +1 -1
- package/dist/__generated__/CartStateUpdateMutation.graphql.js +26 -20
- package/dist/__generated__/CheckoutUpdateCustomerMutation.graphql.d.ts +1 -1
- package/dist/__generated__/CheckoutUpdateCustomerMutation.graphql.js +26 -20
- package/dist/__generated__/CheckoutUpdateOrderMutation.graphql.d.ts +1 -1
- package/dist/__generated__/CheckoutUpdateOrderMutation.graphql.js +26 -20
- package/dist/__generated__/CollectionAa_Query.graphql.d.ts +1 -1
- package/dist/__generated__/CollectionAa_Query.graphql.js +20 -14
- package/dist/__generated__/CollectionAa_product.graphql.d.ts +7 -1
- package/dist/__generated__/CollectionAa_product.graphql.js +22 -16
- package/dist/__generated__/FontFamiliesQuery.graphql.d.ts +4 -1
- package/dist/__generated__/FontFamiliesQuery.graphql.js +46 -39
- package/dist/__generated__/NodePasswordFormElementIDQuery.graphql.d.ts +3 -3
- package/dist/__generated__/NodePasswordFormElementIDQuery.graphql.js +9 -9
- package/dist/__generated__/NodePasswordFormElementPackSlugQuery.graphql.d.ts +25 -0
- package/dist/__generated__/NodePasswordFormElementPackSlugQuery.graphql.js +108 -0
- package/dist/__generated__/PrecartAddToCartMutation.graphql.d.ts +1 -1
- package/dist/__generated__/PrecartAddToCartMutation.graphql.js +32 -26
- package/dist/__generated__/PriceBar_node.graphql.d.ts +4 -1
- package/dist/__generated__/PriceBar_node.graphql.js +23 -16
- package/dist/__generated__/StoreModalCartQuery.graphql.d.ts +1 -1
- package/dist/__generated__/StoreModalCartQuery.graphql.js +37 -31
- package/dist/__generated__/StoreModalFamily_collection.graphql.d.ts +3 -2
- package/dist/__generated__/StoreModalFamily_collection.graphql.js +3 -3
- package/dist/__generated__/StoreModalIndexPackItem_fontPack.graphql.d.ts +23 -0
- package/dist/__generated__/StoreModalIndexPackItem_fontPack.graphql.js +58 -0
- package/dist/__generated__/StoreModalIndexPaginationQuery.graphql.d.ts +23 -0
- package/dist/__generated__/StoreModalIndexPaginationQuery.graphql.js +303 -0
- package/dist/__generated__/StoreModalIndexQuery.graphql.d.ts +6 -3
- package/dist/__generated__/StoreModalIndexQuery.graphql.js +218 -117
- package/dist/__generated__/StoreModalIndex_viewer.graphql.d.ts +24 -0
- package/dist/__generated__/StoreModalIndex_viewer.graphql.js +134 -0
- package/dist/__generated__/StoreModalPackButton_fontPack.graphql.d.ts +33 -0
- package/dist/__generated__/StoreModalPackButton_fontPack.graphql.js +119 -0
- package/dist/__generated__/StoreModalPack_fontPack.graphql.d.ts +45 -0
- package/dist/__generated__/StoreModalPack_fontPack.graphql.js +150 -0
- package/dist/__generated__/StoreModalProductContent_collection.graphql.d.ts +6 -2
- package/dist/__generated__/StoreModalProductContent_collection.graphql.js +43 -19
- package/dist/__generated__/{StoreModalProductLicenseSelection_collection.graphql.d.ts → StoreModalProductLicenseSelection_licenseable.graphql.d.ts} +7 -6
- package/dist/__generated__/StoreModalProductLicenseSelection_licenseable.graphql.js +43 -0
- package/dist/__generated__/StoreModalProductQuery.graphql.d.ts +1 -1
- package/dist/__generated__/StoreModalProductQuery.graphql.js +199 -142
- package/dist/__generated__/StoreModalProductRefetchQuery.graphql.d.ts +1 -1
- package/dist/__generated__/StoreModalProductRefetchQuery.graphql.js +190 -133
- package/dist/__generated__/StoreModalProductSlugQuery.graphql.d.ts +5 -1
- package/dist/__generated__/StoreModalProductSlugQuery.graphql.js +254 -176
- package/dist/__generated__/StoreModalProductSummaryRefetchQuery.graphql.d.ts +1 -1
- package/dist/__generated__/StoreModalProductSummaryRefetchQuery.graphql.js +9 -4
- package/dist/__generated__/StoreModalProductSummary_viewer.graphql.d.ts +7 -1
- package/dist/__generated__/StoreModalProductSummary_viewer.graphql.js +7 -2
- package/dist/__generated__/TestFontsFormUpdateCustomerMutation.graphql.d.ts +1 -1
- package/dist/__generated__/TestFontsFormUpdateCustomerMutation.graphql.js +26 -20
- package/dist/__generated__/TypeTestersIDQuery.graphql.d.ts +1 -1
- package/dist/__generated__/TypeTestersIDQuery.graphql.js +17 -10
- package/dist/__generated__/TypeTestersRefetchQuery.graphql.d.ts +1 -1
- package/dist/__generated__/TypeTestersRefetchQuery.graphql.js +17 -10
- package/dist/__generated__/TypeTestersSlugQuery.graphql.d.ts +1 -1
- package/dist/__generated__/TypeTestersSlugQuery.graphql.js +17 -10
- package/dist/__generated__/productState_Query.graphql.d.ts +99 -1
- package/dist/__generated__/productState_Query.graphql.js +43 -4
- package/dist/__generated__/productState_fontPack.graphql.d.ts +111 -0
- package/dist/__generated__/productState_fontPack.graphql.js +117 -0
- package/dist/__generated__/storefrontEventsTrackStorefrontEventMutation.graphql.d.ts +41 -0
- package/dist/__generated__/storefrontEventsTrackStorefrontEventMutation.graphql.js +65 -0
- package/dist/__tests__/bundleSelectionOrder.test.js +94 -0
- package/dist/__tests__/collectionBundleSelection.test.js +443 -1446
- package/dist/__tests__/fontPackSelection.test.js +435 -0
- package/dist/__tests__/infiniteScroll.test.js +180 -0
- package/dist/__tests__/licenseExclusions.test.js +4 -1
- package/dist/__tests__/storeModalPackButton.test.js +102 -0
- package/dist/__tests__/storeModalPackUnlisted.test.js +112 -0
- package/dist/__tests__/storeModalRoutes.test.js +9 -0
- package/dist/__tests__/storefrontEvents.test.js +167 -0
- package/dist/__tests__/typeTesterAutofitFeatures.test.js +138 -0
- package/dist/components/AddToCartBanner/index.js +1 -1
- package/dist/components/BuyButton/index.d.ts +29 -9
- package/dist/components/BuyButton/index.js +123 -26
- package/dist/components/BuyButton/index.server.d.ts +4 -2
- package/dist/components/BuyButton/index.server.js +24 -3
- package/dist/components/Cart/CartItem/CartItemProduct.js +3 -3
- package/dist/components/Cart/Checkout.js +11 -1
- package/dist/components/Cart/storefrontEvents.d.ts +34 -0
- package/dist/components/Cart/storefrontEvents.js +138 -0
- package/dist/components/CollectionAa/index.js +2 -2
- package/dist/components/FontFamilies/index.js +4 -3
- package/dist/components/NodePasswordForm/NodePasswordFormElement.d.ts +1 -1
- package/dist/components/NodePasswordForm/NodePasswordFormElement.js +45 -21
- package/dist/components/NodePasswordForm/index.d.ts +7 -4
- package/dist/components/NodePasswordForm/index.js +6 -6
- package/dist/components/Precart/index.js +6 -0
- package/dist/components/PriceBar/index.js +5 -3
- package/dist/components/Root/productState.d.ts +2 -8
- package/dist/components/Root/productState.js +100 -61
- package/dist/components/SKUPrice/index.js +7 -8
- package/dist/components/StoreModal/StoreModalFamily.d.ts +7 -0
- package/dist/components/StoreModal/StoreModalFamily.js +11 -7
- package/dist/components/StoreModal/StoreModalIndex.js +58 -7
- package/dist/components/StoreModal/StoreModalIndexEntry.d.ts +13 -0
- package/dist/components/StoreModal/StoreModalIndexEntry.js +43 -0
- package/dist/components/StoreModal/StoreModalIndexItem.js +7 -30
- package/dist/components/StoreModal/StoreModalIndexPackItem.d.ts +7 -0
- package/dist/components/StoreModal/StoreModalIndexPackItem.js +21 -0
- package/dist/components/StoreModal/StoreModalPack.d.ts +9 -0
- package/dist/components/StoreModal/StoreModalPack.js +79 -0
- package/dist/components/StoreModal/StoreModalPackButton.d.ts +8 -0
- package/dist/components/StoreModal/StoreModalPackButton.js +53 -0
- package/dist/components/StoreModal/StoreModalProduct.js +49 -19
- package/dist/components/StoreModalProductLicenseSelection/StoreModalProductLicense.d.ts +2 -1
- package/dist/components/StoreModalProductLicenseSelection/StoreModalProductLicense.js +8 -3
- package/dist/components/StoreModalProductLicenseSelection/index.d.ts +3 -3
- package/dist/components/StoreModalProductLicenseSelection/index.js +7 -6
- package/dist/components/StoreModalProductSummary/index.js +1 -1
- package/dist/components/TypeTester/useTypeTesterStyler.js +1 -0
- package/dist/components/elements/StoreModalContainer/StoreModalContainerContext.d.ts +1 -0
- package/dist/components/elements/StoreModalContainer/index.js +9 -4
- package/dist/components/elements/StoreModalFamily/index.d.ts +1 -1
- package/dist/components/elements/StoreModalFamily/index.js +1 -1
- package/dist/components/elements/StoreModalIndexLoadMore/index.d.ts +8 -0
- package/dist/components/elements/StoreModalIndexLoadMore/index.js +21 -0
- package/dist/components/elements/StoreModalUnifiedCheckout.js +12 -0
- package/dist/components/useInfiniteScroll.d.ts +28 -0
- package/dist/components/useInfiniteScroll.js +50 -0
- package/dist/fontdue.css +39 -0
- package/dist/hooks/useAutofit.d.ts +2 -1
- package/dist/hooks/useAutofit.js +10 -4
- package/dist/reducer.d.ts +12 -5
- package/dist/reducer.js +18 -87
- package/dist/selection.d.ts +44 -0
- package/dist/selection.js +539 -0
- package/dist/storeModalRoutes.js +5 -4
- package/dist/utils.d.ts +1 -12
- package/dist/utils.js +1 -36
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/dist/__generated__/BuyButton_collection.graphql.d.ts +0 -25
- package/dist/__generated__/BuyButton_collection.graphql.js +0 -49
- package/dist/__generated__/StoreModalProductLicenseSelection_collection.graphql.js +0 -40
- package/fontdue.css +0 -2733
- package/fontdue.css.map +0 -1
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
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); }
|
|
4
|
+
import _BuyButtonPackSlugQuery from "../../__generated__/BuyButtonPackSlugQuery.graphql.js";
|
|
5
|
+
import _BuyButtonPackIDQuery from "../../__generated__/BuyButtonPackIDQuery.graphql.js";
|
|
4
6
|
import _BuyButtonSlugQuery from "../../__generated__/BuyButtonSlugQuery.graphql.js";
|
|
5
7
|
import _BuyButtonIDQuery from "../../__generated__/BuyButtonIDQuery.graphql.js";
|
|
6
|
-
import
|
|
8
|
+
import _BuyButton_product from "../../__generated__/BuyButton_product.graphql.js";
|
|
7
9
|
import React, { useCallback, useContext, useEffect } from 'react';
|
|
8
10
|
import { graphql, useRelayEnvironment, useLazyLoadQuery, useFragment, usePreloadedQuery } from 'react-relay';
|
|
9
11
|
import { useDispatch, useStore } from 'react-redux';
|
|
@@ -11,37 +13,41 @@ import ComponentsContext from '../ComponentsContext.js';
|
|
|
11
13
|
import { populateProductState } from '../Root/productState.js';
|
|
12
14
|
import BuyButtonIDQueryNode from '../../__generated__/BuyButtonIDQuery.graphql.js';
|
|
13
15
|
import BuyButtonSlugQueryNode from '../../__generated__/BuyButtonSlugQuery.graphql.js';
|
|
16
|
+
import BuyButtonPackIDQueryNode from '../../__generated__/BuyButtonPackIDQuery.graphql.js';
|
|
17
|
+
import BuyButtonPackSlugQueryNode from '../../__generated__/BuyButtonPackSlugQuery.graphql.js';
|
|
14
18
|
import loadSerializableQuery from '../../relay/loadSerializableQuery.js';
|
|
15
19
|
import useSerializablePreloadedQuery from '../../relay/useSerializablePreloadedQuery.js';
|
|
16
20
|
import { EnsureFontdueContext, LazyQueryBoundary } from '../FontdueContextProvider/index.js';
|
|
17
21
|
function BuyButtonComponent(_ref) {
|
|
18
22
|
let {
|
|
19
|
-
|
|
23
|
+
product: productKey,
|
|
20
24
|
label,
|
|
21
25
|
collectionName
|
|
22
26
|
} = _ref;
|
|
23
|
-
|
|
27
|
+
// A collection or a font pack — both open the store modal's product page,
|
|
28
|
+
// which renders whichever it is given.
|
|
29
|
+
const product = useFragment((_BuyButton_product.hash && _BuyButton_product.hash !== "007b16f72407229f0f743958a541c39a" && console.error("The definition of 'BuyButton_product' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _BuyButton_product), productKey);
|
|
24
30
|
const store = useStore();
|
|
25
31
|
const components = useContext(ComponentsContext);
|
|
26
32
|
const dispatch = useDispatch();
|
|
27
33
|
const environment = useRelayEnvironment();
|
|
28
34
|
const handleClick = useCallback(() => {
|
|
29
|
-
if (!
|
|
35
|
+
if (!product) return;
|
|
30
36
|
dispatch({
|
|
31
37
|
type: 'STORE_MODAL_NAVIGATE',
|
|
32
38
|
route: 'product',
|
|
33
39
|
variables: {
|
|
34
|
-
productId:
|
|
40
|
+
productId: product.id
|
|
35
41
|
}
|
|
36
42
|
});
|
|
37
43
|
dispatch({
|
|
38
44
|
type: 'OPEN_CART'
|
|
39
45
|
});
|
|
40
|
-
}, [dispatch,
|
|
46
|
+
}, [dispatch, product]);
|
|
41
47
|
useEffect(() => {
|
|
42
|
-
if (!
|
|
43
|
-
populateProductState(store, environment,
|
|
44
|
-
}, [
|
|
48
|
+
if (!product) return;
|
|
49
|
+
populateProductState(store, environment, product.id);
|
|
50
|
+
}, [product === null || product === void 0 ? void 0 : product.id]);
|
|
45
51
|
if (components.BuyButton) {
|
|
46
52
|
return /*#__PURE__*/React.createElement(components.BuyButton, {
|
|
47
53
|
innerProps: {
|
|
@@ -49,14 +55,21 @@ function BuyButtonComponent(_ref) {
|
|
|
49
55
|
}
|
|
50
56
|
});
|
|
51
57
|
}
|
|
58
|
+
|
|
59
|
+
// Collections keep their historical label (the fragment never fetched the
|
|
60
|
+
// collection's name, so `collectionName` fills it in); a pack's name comes
|
|
61
|
+
// from the query.
|
|
62
|
+
const productName = collectionName ?? ((product === null || product === void 0 ? void 0 : product.__typename) === 'FontPack' ? product.name : '');
|
|
52
63
|
return /*#__PURE__*/React.createElement("button", {
|
|
53
64
|
className: "buy-button",
|
|
54
65
|
onClick: handleClick,
|
|
55
66
|
type: "button"
|
|
56
|
-
}, label ? label : `Buy ${
|
|
67
|
+
}, label ? label : `Buy ${productName}`);
|
|
57
68
|
}
|
|
58
|
-
const idQuery = (_BuyButtonIDQuery.hash && _BuyButtonIDQuery.hash !== "
|
|
59
|
-
const slugQuery = (_BuyButtonSlugQuery.hash && _BuyButtonSlugQuery.hash !== "
|
|
69
|
+
const idQuery = (_BuyButtonIDQuery.hash && _BuyButtonIDQuery.hash !== "602547ee927b734b5fa2d6d1f2c93765" && console.error("The definition of 'BuyButtonIDQuery' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _BuyButtonIDQuery);
|
|
70
|
+
const slugQuery = (_BuyButtonSlugQuery.hash && _BuyButtonSlugQuery.hash !== "14c9d7a1ef98d03b73b22374983b5fb4" && console.error("The definition of 'BuyButtonSlugQuery' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _BuyButtonSlugQuery);
|
|
71
|
+
const packIdQuery = (_BuyButtonPackIDQuery.hash && _BuyButtonPackIDQuery.hash !== "7c9a7e75de7c428c5a3aec1235d0516e" && console.error("The definition of 'BuyButtonPackIDQuery' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _BuyButtonPackIDQuery);
|
|
72
|
+
const packSlugQuery = (_BuyButtonPackSlugQuery.hash && _BuyButtonPackSlugQuery.hash !== "7d9d7c6c7343fe13ccb1e79b6696e416" && console.error("The definition of 'BuyButtonPackSlugQuery' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _BuyButtonPackSlugQuery);
|
|
60
73
|
export async function loadBuyButtonQuery(variables, options) {
|
|
61
74
|
if (variables.collectionId) {
|
|
62
75
|
return loadSerializableQuery(BuyButtonIDQueryNode, {
|
|
@@ -68,7 +81,17 @@ export async function loadBuyButtonQuery(variables, options) {
|
|
|
68
81
|
collectionSlug: variables.collectionSlug
|
|
69
82
|
}, options);
|
|
70
83
|
}
|
|
71
|
-
|
|
84
|
+
if (variables.fontPackId) {
|
|
85
|
+
return loadSerializableQuery(BuyButtonPackIDQueryNode, {
|
|
86
|
+
fontPackId: variables.fontPackId
|
|
87
|
+
}, options);
|
|
88
|
+
}
|
|
89
|
+
if (variables.fontPackSlug) {
|
|
90
|
+
return loadSerializableQuery(BuyButtonPackSlugQueryNode, {
|
|
91
|
+
fontPackSlug: variables.fontPackSlug
|
|
92
|
+
}, options);
|
|
93
|
+
}
|
|
94
|
+
throw new Error('loadBuyButtonQuery expected one of collectionId, collectionSlug, fontPackId or fontPackSlug');
|
|
72
95
|
}
|
|
73
96
|
function BuyButtonIDQueryRenderer(_ref2) {
|
|
74
97
|
let {
|
|
@@ -102,7 +125,7 @@ function BuyButtonSlugQueryRenderer(_ref4) {
|
|
|
102
125
|
collectionSlug
|
|
103
126
|
});
|
|
104
127
|
return /*#__PURE__*/React.createElement(BuyButtonComponent, _extends({}, rest, {
|
|
105
|
-
|
|
128
|
+
product: ((_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.product) ?? null
|
|
106
129
|
}));
|
|
107
130
|
}
|
|
108
131
|
export function BuyButtonPreloadedSlugQueryRenderer(_ref5) {
|
|
@@ -117,25 +140,83 @@ export function BuyButtonPreloadedSlugQueryRenderer(_ref5) {
|
|
|
117
140
|
const queryRef = useSerializablePreloadedQuery(preloadedQuery, 'store-or-network', slugQuery);
|
|
118
141
|
const data = usePreloadedQuery(slugQuery, queryRef);
|
|
119
142
|
return /*#__PURE__*/React.createElement(BuyButtonComponent, _extends({}, rest, {
|
|
120
|
-
|
|
143
|
+
product: ((_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.product) ?? null
|
|
121
144
|
}));
|
|
122
145
|
}
|
|
123
|
-
function
|
|
146
|
+
function BuyButtonPackIDQueryRenderer(_ref6) {
|
|
124
147
|
let {
|
|
125
|
-
|
|
148
|
+
fontPackId,
|
|
126
149
|
...rest
|
|
127
150
|
} = _ref6;
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
151
|
+
const data = useLazyLoadQuery(packIdQuery, {
|
|
152
|
+
fontPackId
|
|
153
|
+
});
|
|
154
|
+
return /*#__PURE__*/React.createElement(BuyButtonComponent, _extends({}, rest, data));
|
|
155
|
+
}
|
|
156
|
+
export function BuyButtonPreloadedPackIDQueryRenderer(_ref7) {
|
|
157
|
+
let {
|
|
158
|
+
preloadedQuery,
|
|
159
|
+
...rest
|
|
160
|
+
} = _ref7;
|
|
161
|
+
const queryRef = useSerializablePreloadedQuery(preloadedQuery, 'store-or-network', packIdQuery);
|
|
162
|
+
const data = usePreloadedQuery(packIdQuery, queryRef);
|
|
163
|
+
return /*#__PURE__*/React.createElement(BuyButtonComponent, _extends({}, rest, data));
|
|
164
|
+
}
|
|
165
|
+
function BuyButtonPackSlugQueryRenderer(_ref8) {
|
|
166
|
+
var _data$viewer3, _data$viewer3$slug;
|
|
167
|
+
let {
|
|
168
|
+
fontPackSlug,
|
|
169
|
+
...rest
|
|
170
|
+
} = _ref8;
|
|
171
|
+
const data = useLazyLoadQuery(packSlugQuery, {
|
|
172
|
+
fontPackSlug
|
|
173
|
+
});
|
|
174
|
+
return /*#__PURE__*/React.createElement(BuyButtonComponent, _extends({}, rest, {
|
|
175
|
+
product: ((_data$viewer3 = data.viewer) === null || _data$viewer3 === void 0 ? void 0 : (_data$viewer3$slug = _data$viewer3.slug) === null || _data$viewer3$slug === void 0 ? void 0 : _data$viewer3$slug.product) ?? null
|
|
176
|
+
}));
|
|
177
|
+
}
|
|
178
|
+
export function BuyButtonPreloadedPackSlugQueryRenderer(_ref9) {
|
|
179
|
+
var _data$viewer4, _data$viewer4$slug;
|
|
180
|
+
let {
|
|
181
|
+
preloadedQuery,
|
|
182
|
+
...rest
|
|
183
|
+
} = _ref9;
|
|
184
|
+
const queryRef = useSerializablePreloadedQuery(preloadedQuery, 'store-or-network', packSlugQuery);
|
|
185
|
+
const data = usePreloadedQuery(packSlugQuery, queryRef);
|
|
186
|
+
return /*#__PURE__*/React.createElement(BuyButtonComponent, _extends({}, rest, {
|
|
187
|
+
product: ((_data$viewer4 = data.viewer) === null || _data$viewer4 === void 0 ? void 0 : (_data$viewer4$slug = _data$viewer4.slug) === null || _data$viewer4$slug === void 0 ? void 0 : _data$viewer4$slug.product) ?? null
|
|
188
|
+
}));
|
|
189
|
+
}
|
|
190
|
+
function BuyButtonPreloadedRenderer(_ref10) {
|
|
191
|
+
let {
|
|
192
|
+
preloadedQuery,
|
|
193
|
+
...rest
|
|
194
|
+
} = _ref10;
|
|
195
|
+
switch (preloadedQuery.params.name) {
|
|
196
|
+
case 'BuyButtonIDQuery':
|
|
197
|
+
return /*#__PURE__*/React.createElement(BuyButtonPreloadedIDQueryRenderer, _extends({
|
|
198
|
+
preloadedQuery: preloadedQuery
|
|
199
|
+
}, rest));
|
|
200
|
+
case 'BuyButtonPackIDQuery':
|
|
201
|
+
return /*#__PURE__*/React.createElement(BuyButtonPreloadedPackIDQueryRenderer, _extends({
|
|
202
|
+
preloadedQuery: preloadedQuery
|
|
203
|
+
}, rest));
|
|
204
|
+
case 'BuyButtonPackSlugQuery':
|
|
205
|
+
return /*#__PURE__*/React.createElement(BuyButtonPreloadedPackSlugQueryRenderer, _extends({
|
|
206
|
+
preloadedQuery: preloadedQuery
|
|
207
|
+
}, rest));
|
|
208
|
+
default:
|
|
209
|
+
return /*#__PURE__*/React.createElement(BuyButtonPreloadedSlugQueryRenderer, _extends({
|
|
210
|
+
preloadedQuery: preloadedQuery
|
|
211
|
+
}, rest));
|
|
132
212
|
}
|
|
133
|
-
return /*#__PURE__*/React.createElement(BuyButtonPreloadedSlugQueryRenderer, _extends({
|
|
134
|
-
preloadedQuery: preloadedQuery
|
|
135
|
-
}, rest));
|
|
136
213
|
}
|
|
214
|
+
|
|
215
|
+
// A lazy button identifies its product the same way `loadBuyButtonQuery` does.
|
|
216
|
+
|
|
137
217
|
// Unified BuyButton entry. Accepts a preloaded query (server-side preload
|
|
138
|
-
// path) or `{collectionId}`/`{collectionSlug}
|
|
218
|
+
// path) or one of `{collectionId}`/`{collectionSlug}`/`{fontPackId}`/
|
|
219
|
+
// `{fontPackSlug}` for lazy fetch.
|
|
139
220
|
// `EnsureFontdueContext` only self-wraps with `FontdueContextProvider` when
|
|
140
221
|
// no parent Fontdue context is present, seeding it with `config`.
|
|
141
222
|
export default function BuyButton(props) {
|
|
@@ -164,8 +245,24 @@ export default function BuyButton(props) {
|
|
|
164
245
|
inner = /*#__PURE__*/React.createElement(LazyQueryBoundary, null, /*#__PURE__*/React.createElement(BuyButtonSlugQueryRenderer, _extends({
|
|
165
246
|
collectionSlug: collectionSlug
|
|
166
247
|
}, rest)));
|
|
248
|
+
} else if ('fontPackId' in props && props.fontPackId) {
|
|
249
|
+
const {
|
|
250
|
+
fontPackId,
|
|
251
|
+
...rest
|
|
252
|
+
} = props;
|
|
253
|
+
inner = /*#__PURE__*/React.createElement(LazyQueryBoundary, null, /*#__PURE__*/React.createElement(BuyButtonPackIDQueryRenderer, _extends({
|
|
254
|
+
fontPackId: fontPackId
|
|
255
|
+
}, rest)));
|
|
256
|
+
} else if ('fontPackSlug' in props && props.fontPackSlug) {
|
|
257
|
+
const {
|
|
258
|
+
fontPackSlug,
|
|
259
|
+
...rest
|
|
260
|
+
} = props;
|
|
261
|
+
inner = /*#__PURE__*/React.createElement(LazyQueryBoundary, null, /*#__PURE__*/React.createElement(BuyButtonPackSlugQueryRenderer, _extends({
|
|
262
|
+
fontPackSlug: fontPackSlug
|
|
263
|
+
}, rest)));
|
|
167
264
|
} else {
|
|
168
|
-
throw new Error('BuyButton expected one of preloadedQuery, collectionId, or
|
|
265
|
+
throw new Error('BuyButton expected one of preloadedQuery, collectionId, collectionSlug, fontPackId, or fontPackSlug');
|
|
169
266
|
}
|
|
170
267
|
return /*#__PURE__*/React.createElement(EnsureFontdueContext, {
|
|
171
268
|
config: props.config
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { BuyButton_props } from './index.js';
|
|
3
3
|
import { Config } from '../ConfigContext.js';
|
|
4
|
-
export type { BuyButtonPreloadedQuery } from './index.js';
|
|
4
|
+
export type { BuyButtonPreloadedQuery, LoadBuyButtonQueryVariables } from './index.js';
|
|
5
5
|
export declare function loadBuyButtonQuery(): never;
|
|
6
|
-
export default function BuyButton({ collectionId, collectionSlug, ...rest }: BuyButton_props & {
|
|
6
|
+
export default function BuyButton({ collectionId, collectionSlug, fontPackId, fontPackSlug, ...rest }: BuyButton_props & {
|
|
7
7
|
collectionId?: string | null;
|
|
8
8
|
collectionSlug?: string | null;
|
|
9
|
+
fontPackId?: string | null;
|
|
10
|
+
fontPackSlug?: string | null;
|
|
9
11
|
config?: Config;
|
|
10
12
|
}): Promise<React.JSX.Element | null>;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
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
2
|
import React from 'react';
|
|
3
3
|
import loadSerializableQuery from '../../relay/loadSerializableQuery.js';
|
|
4
|
-
import { BuyButtonPreloadedIDQueryRenderer, BuyButtonPreloadedSlugQueryRenderer } from './index.js';
|
|
4
|
+
import { BuyButtonPreloadedIDQueryRenderer, BuyButtonPreloadedSlugQueryRenderer, BuyButtonPreloadedPackIDQueryRenderer, BuyButtonPreloadedPackSlugQueryRenderer } from './index.js';
|
|
5
5
|
import BuyButtonIDQueryNode from '../../__generated__/BuyButtonIDQuery.graphql.js';
|
|
6
6
|
import BuyButtonSlugQueryNode from '../../__generated__/BuyButtonSlugQuery.graphql.js';
|
|
7
|
+
import BuyButtonPackIDQueryNode from '../../__generated__/BuyButtonPackIDQuery.graphql.js';
|
|
8
|
+
import BuyButtonPackSlugQueryNode from '../../__generated__/BuyButtonPackSlugQuery.graphql.js';
|
|
7
9
|
// Stub for the RSC export condition. See FontdueProvider/index.server.tsx
|
|
8
10
|
// for the rationale.
|
|
9
11
|
export function loadBuyButtonQuery() {
|
|
@@ -12,12 +14,15 @@ export function loadBuyButtonQuery() {
|
|
|
12
14
|
|
|
13
15
|
// Next RSC variant: awaits the query on the server and hands the response to
|
|
14
16
|
// the client `*PreloadedQueryRenderer`. Lets pages just write
|
|
15
|
-
// `<BuyButton collectionId={id} />` in an RSC without
|
|
16
|
-
// `loadBuyButtonQuery` + threading `preloadedQuery` through
|
|
17
|
+
// `<BuyButton collectionId={id} />` (or `fontPackId`) in an RSC without
|
|
18
|
+
// manually invoking `loadBuyButtonQuery` + threading `preloadedQuery` through
|
|
19
|
+
// props.
|
|
17
20
|
export default async function BuyButton(_ref) {
|
|
18
21
|
let {
|
|
19
22
|
collectionId,
|
|
20
23
|
collectionSlug,
|
|
24
|
+
fontPackId,
|
|
25
|
+
fontPackSlug,
|
|
21
26
|
...rest
|
|
22
27
|
} = _ref;
|
|
23
28
|
if (collectionId) {
|
|
@@ -36,5 +41,21 @@ export default async function BuyButton(_ref) {
|
|
|
36
41
|
preloadedQuery: preloadedQuery
|
|
37
42
|
}, rest));
|
|
38
43
|
}
|
|
44
|
+
if (fontPackId) {
|
|
45
|
+
const preloadedQuery = await loadSerializableQuery(BuyButtonPackIDQueryNode, {
|
|
46
|
+
fontPackId
|
|
47
|
+
});
|
|
48
|
+
return /*#__PURE__*/React.createElement(BuyButtonPreloadedPackIDQueryRenderer, _extends({
|
|
49
|
+
preloadedQuery: preloadedQuery
|
|
50
|
+
}, rest));
|
|
51
|
+
}
|
|
52
|
+
if (fontPackSlug) {
|
|
53
|
+
const preloadedQuery = await loadSerializableQuery(BuyButtonPackSlugQueryNode, {
|
|
54
|
+
fontPackSlug
|
|
55
|
+
});
|
|
56
|
+
return /*#__PURE__*/React.createElement(BuyButtonPreloadedPackSlugQueryRenderer, _extends({
|
|
57
|
+
preloadedQuery: preloadedQuery
|
|
58
|
+
}, rest));
|
|
59
|
+
}
|
|
39
60
|
return null;
|
|
40
61
|
}
|
|
@@ -9,13 +9,13 @@ export default function CartItemProduct(_ref) {
|
|
|
9
9
|
let {
|
|
10
10
|
product: productKey
|
|
11
11
|
} = _ref;
|
|
12
|
-
const product = useFragment((_CartItemProduct_product.hash && _CartItemProduct_product.hash !== "
|
|
12
|
+
const product = useFragment((_CartItemProduct_product.hash && _CartItemProduct_product.hash !== "15b269b9bb33a3bfa7b10486e99da183" && console.error("The definition of 'CartItemProduct_product' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _CartItemProduct_product), productKey);
|
|
13
13
|
let productName = (product === null || product === void 0 ? void 0 : product.name) ?? '??';
|
|
14
14
|
if ((product === null || product === void 0 ? void 0 : product.__typename) === 'FontStyle' && product.family) productName = `${product.family.name} ${product.name}`;
|
|
15
15
|
if (((product === null || product === void 0 ? void 0 : product.__typename) === 'Bundle' || (product === null || product === void 0 ? void 0 : product.__typename) === 'CollectionBundle') && product.fontCollection && !((_product$name = product.name) !== null && _product$name !== void 0 && _product$name.startsWith(product.fontCollection.name))) productName = `${product.fontCollection.name} ${product.name}`;
|
|
16
16
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
17
17
|
className: "cart-item__aa"
|
|
18
|
-
}, product ? /*#__PURE__*/React.createElement(React.Fragment, null, ['FontCollection', 'Bundle', 'CollectionBundle'].indexOf(product.__typename) >= 0 ? /*#__PURE__*/React.createElement(CollectionAa, {
|
|
18
|
+
}, product ? /*#__PURE__*/React.createElement(React.Fragment, null, ['FontCollection', 'Bundle', 'CollectionBundle', 'FontPack'].indexOf(product.__typename) >= 0 ? /*#__PURE__*/React.createElement(CollectionAa, {
|
|
19
19
|
product: product
|
|
20
20
|
}) : /*#__PURE__*/React.createElement(FontStyle, {
|
|
21
21
|
fontStyle: product
|
|
@@ -25,7 +25,7 @@ export default function CartItemProduct(_ref) {
|
|
|
25
25
|
className: "cart-item__name"
|
|
26
26
|
}, productName), product !== null && product !== void 0 && product.isVariableFont || product !== null && product !== void 0 && (_product$variableInst = product.variableInstances) !== null && _product$variableInst !== void 0 && _product$variableInst.length ? /*#__PURE__*/React.createElement("div", {
|
|
27
27
|
className: "cart-item__label"
|
|
28
|
-
}, "Variable font") : ((product === null || product === void 0 ? void 0 : product.__typename) === 'FontCollection' || (product === null || product === void 0 ? void 0 : product.__typename) === 'CollectionBundle') && /*#__PURE__*/React.createElement("div", {
|
|
28
|
+
}, "Variable font") : ((product === null || product === void 0 ? void 0 : product.__typename) === 'FontCollection' || (product === null || product === void 0 ? void 0 : product.__typename) === 'CollectionBundle' || (product === null || product === void 0 ? void 0 : product.__typename) === 'FontPack') && /*#__PURE__*/React.createElement("div", {
|
|
29
29
|
className: "cart-item__label"
|
|
30
30
|
}, "(", pluralize(product.totalStyles ?? 0, 'style'), ")")));
|
|
31
31
|
}
|
|
@@ -4,9 +4,10 @@ import _CheckoutUpdateOrderMutation from "../../__generated__/CheckoutUpdateOrde
|
|
|
4
4
|
import _Checkout_UpdateOrderErrors from "../../__generated__/Checkout_UpdateOrderErrors.graphql.js";
|
|
5
5
|
import _CheckoutUpdateCustomerMutation from "../../__generated__/CheckoutUpdateCustomerMutation.graphql.js";
|
|
6
6
|
import _Checkout_identity from "../../__generated__/Checkout_identity.graphql.js";
|
|
7
|
-
import React, { Fragment, useContext, useEffect, useState } from 'react';
|
|
7
|
+
import React, { Fragment, useContext, useEffect, useRef, useState } from 'react';
|
|
8
8
|
import { commitMutation, graphql, useFragment, useRelayEnvironment } from 'react-relay';
|
|
9
9
|
import { CardElement } from '@stripe/react-stripe-js';
|
|
10
|
+
import { trackPaymentInfoEntered } from './storefrontEvents.js';
|
|
10
11
|
import { CreditCard, User, Check, License, Receipt, X } from '../Icons/index.js';
|
|
11
12
|
import AddressFields from './AddressFields.js';
|
|
12
13
|
import CustomerFields from './CustomerFields.js';
|
|
@@ -99,6 +100,7 @@ const Checkout = _ref => {
|
|
|
99
100
|
onScrollToTop();
|
|
100
101
|
}, [checkoutStep]);
|
|
101
102
|
const environment = useRelayEnvironment();
|
|
103
|
+
const paymentInfoTracked = useRef(false);
|
|
102
104
|
const [errorsObject, setErrorsObject] = useState(null);
|
|
103
105
|
const [customerErrorsObject, setCustomerErrorsObject] = useState(null);
|
|
104
106
|
const onCompleted = (res, errors, onSuccess) => {
|
|
@@ -454,6 +456,14 @@ const Checkout = _ref => {
|
|
|
454
456
|
style: inputStyles,
|
|
455
457
|
hidePostalCode: true
|
|
456
458
|
}
|
|
459
|
+
// The first time the card details are complete. The server
|
|
460
|
+
// keeps it to one per order; the ref only saves requests.
|
|
461
|
+
,
|
|
462
|
+
onChange: event => {
|
|
463
|
+
if (!event.complete || paymentInfoTracked.current) return;
|
|
464
|
+
paymentInfoTracked.current = true;
|
|
465
|
+
trackPaymentInfoEntered(environment);
|
|
466
|
+
}
|
|
457
467
|
})), errorsObject && errorsObject.stripePaymentMethodId && errorsObject.stripePaymentMethodId.length > 0 && /*#__PURE__*/React.createElement("p", {
|
|
458
468
|
className: "checkout-modal__section__errors"
|
|
459
469
|
}, errorsObject.stripePaymentMethodId[0]));
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Environment } from 'relay-runtime';
|
|
2
|
+
import type { FontdueState } from '../../reducer.js';
|
|
3
|
+
import type { LicenseSelectionInput } from '__generated__/storefrontEventsTrackStorefrontEventMutation.graphql.js';
|
|
4
|
+
/** Reports the store modal opening on a collection. */
|
|
5
|
+
export declare function trackProductViewed(environment: Environment, collectionId: string): void;
|
|
6
|
+
type LicenseOptions = FontdueState['licenseOptions'];
|
|
7
|
+
/**
|
|
8
|
+
* The licence choices in the store's state, in the shape `createOrderItems`
|
|
9
|
+
* takes them – one selection per licence variable, or one bare selection for a
|
|
10
|
+
* licence without variables. Sorted, so the same configuration reached in a
|
|
11
|
+
* different order reads the same.
|
|
12
|
+
*/
|
|
13
|
+
export declare function licenseSelectionsFromOptions(licenseOptions: LicenseOptions): LicenseSelectionInput[];
|
|
14
|
+
/**
|
|
15
|
+
* Reports the buyer changing their licence choices for a collection, once the
|
|
16
|
+
* choices settle. Call it from the handler of the buyer's own click, never from
|
|
17
|
+
* an effect: licences a foundry marks as selected by default are applied on
|
|
18
|
+
* mount, and that isn't the buyer customizing anything.
|
|
19
|
+
*
|
|
20
|
+
* `currentLicenseOptions` is read when the report fires, so it sees the
|
|
21
|
+
* configuration the buyer settled on.
|
|
22
|
+
*/
|
|
23
|
+
export declare function trackProductCustomized(environment: Environment, collectionId: string, currentLicenseOptions: () => LicenseOptions): void;
|
|
24
|
+
/**
|
|
25
|
+
* `trackProductCustomized` bound to the store and Relay environment in
|
|
26
|
+
* context, for a licence control's click handlers.
|
|
27
|
+
*/
|
|
28
|
+
export declare function useTrackProductCustomized(collectionId: string | null | undefined): () => void;
|
|
29
|
+
/**
|
|
30
|
+
* Reports the checkout's payment details as complete. The server records it
|
|
31
|
+
* once per order, however often this is called.
|
|
32
|
+
*/
|
|
33
|
+
export declare function trackPaymentInfoEntered(environment: Environment): void;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import _storefrontEventsTrackStorefrontEventMutation from "../../__generated__/storefrontEventsTrackStorefrontEventMutation.graphql.js";
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import { commitMutation, graphql, useRelayEnvironment } from 'react-relay';
|
|
4
|
+
import { useStore } from 'react-redux';
|
|
5
|
+
import { orderTrackingInput } from './orderTracking.js';
|
|
6
|
+
/**
|
|
7
|
+
* The storefront moments that happen entirely in the browser – a collection
|
|
8
|
+
* opened in the store modal, its licences changed, the payment details
|
|
9
|
+
* completed. Nothing reaches the server at those moments on its own, so they
|
|
10
|
+
* are reported through `trackStorefrontEvent`, which records them as "Product
|
|
11
|
+
* Viewed", "Product Customized" and "Payment Info Entered" with the same
|
|
12
|
+
* consent and identifiers as the order events around them (Meta reads them as
|
|
13
|
+
* ViewContent, CustomizeProduct and AddPaymentInfo).
|
|
14
|
+
*
|
|
15
|
+
* Every call is fire-and-forget: tracking must never break the store.
|
|
16
|
+
*/
|
|
17
|
+
function track(environment, input) {
|
|
18
|
+
const tracking = orderTrackingInput();
|
|
19
|
+
// Outside a browser there is no moment to report.
|
|
20
|
+
if (!tracking) return;
|
|
21
|
+
try {
|
|
22
|
+
commitMutation(environment, {
|
|
23
|
+
mutation: (_storefrontEventsTrackStorefrontEventMutation.hash && _storefrontEventsTrackStorefrontEventMutation.hash !== "340cc13477a15b926e2307d36c644053" && console.error("The definition of 'storefrontEventsTrackStorefrontEventMutation' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _storefrontEventsTrackStorefrontEventMutation),
|
|
24
|
+
variables: {
|
|
25
|
+
input: {
|
|
26
|
+
...input,
|
|
27
|
+
tracking
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
onCompleted: () => undefined,
|
|
31
|
+
onError: () => undefined
|
|
32
|
+
});
|
|
33
|
+
} catch {
|
|
34
|
+
// Ignore — see above.
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// React can run an effect twice for one mount – StrictMode in development, a
|
|
39
|
+
// Suspense retry – and each run would count as a second look.
|
|
40
|
+
const VIEW_REPEAT_MS = 2000;
|
|
41
|
+
let lastView = null;
|
|
42
|
+
|
|
43
|
+
/** Reports the store modal opening on a collection. */
|
|
44
|
+
export function trackProductViewed(environment, collectionId) {
|
|
45
|
+
var _lastView;
|
|
46
|
+
const now = Date.now();
|
|
47
|
+
if (((_lastView = lastView) === null || _lastView === void 0 ? void 0 : _lastView.collectionId) === collectionId && now - lastView.at < VIEW_REPEAT_MS) return;
|
|
48
|
+
lastView = {
|
|
49
|
+
collectionId,
|
|
50
|
+
at: now
|
|
51
|
+
};
|
|
52
|
+
track(environment, {
|
|
53
|
+
event: 'PRODUCT_VIEWED',
|
|
54
|
+
collectionId
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The licence choices in the store's state, in the shape `createOrderItems`
|
|
59
|
+
* takes them – one selection per licence variable, or one bare selection for a
|
|
60
|
+
* licence without variables. Sorted, so the same configuration reached in a
|
|
61
|
+
* different order reads the same.
|
|
62
|
+
*/
|
|
63
|
+
export function licenseSelectionsFromOptions(licenseOptions) {
|
|
64
|
+
const selections = licenseOptions.flatMap(_ref => {
|
|
65
|
+
let {
|
|
66
|
+
licenseId,
|
|
67
|
+
licenseOptions: options
|
|
68
|
+
} = _ref;
|
|
69
|
+
const variableIds = Object.keys(options ?? {});
|
|
70
|
+
if (variableIds.length === 0) return [{
|
|
71
|
+
licenseId
|
|
72
|
+
}];
|
|
73
|
+
return variableIds.map(licenseVariableId => ({
|
|
74
|
+
licenseId,
|
|
75
|
+
licenseVariableId,
|
|
76
|
+
licenseOptionId: options[licenseVariableId]
|
|
77
|
+
}));
|
|
78
|
+
});
|
|
79
|
+
const key = s => `${s.licenseId}:${s.licenseVariableId ?? ''}`;
|
|
80
|
+
return selections.sort((a, b) => key(a).localeCompare(key(b)));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// A buyer clicks through a few licences and sizes before settling. Report the
|
|
84
|
+
// configuration they settle on rather than every step on the way, and only
|
|
85
|
+
// when it differs from the last one reported for that collection.
|
|
86
|
+
const CUSTOMIZE_SETTLE_MS = 1500;
|
|
87
|
+
const pendingCustomizations = new Map();
|
|
88
|
+
const reportedConfigurations = new Map();
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Reports the buyer changing their licence choices for a collection, once the
|
|
92
|
+
* choices settle. Call it from the handler of the buyer's own click, never from
|
|
93
|
+
* an effect: licences a foundry marks as selected by default are applied on
|
|
94
|
+
* mount, and that isn't the buyer customizing anything.
|
|
95
|
+
*
|
|
96
|
+
* `currentLicenseOptions` is read when the report fires, so it sees the
|
|
97
|
+
* configuration the buyer settled on.
|
|
98
|
+
*/
|
|
99
|
+
export function trackProductCustomized(environment, collectionId, currentLicenseOptions) {
|
|
100
|
+
clearTimeout(pendingCustomizations.get(collectionId));
|
|
101
|
+
pendingCustomizations.set(collectionId, setTimeout(() => {
|
|
102
|
+
pendingCustomizations.delete(collectionId);
|
|
103
|
+
const licenseSelections = licenseSelectionsFromOptions(currentLicenseOptions());
|
|
104
|
+
// Unticking everything configures nothing.
|
|
105
|
+
if (licenseSelections.length === 0) return;
|
|
106
|
+
const configuration = JSON.stringify(licenseSelections);
|
|
107
|
+
if (reportedConfigurations.get(collectionId) === configuration) return;
|
|
108
|
+
reportedConfigurations.set(collectionId, configuration);
|
|
109
|
+
track(environment, {
|
|
110
|
+
event: 'PRODUCT_CUSTOMIZED',
|
|
111
|
+
collectionId,
|
|
112
|
+
licenseSelections
|
|
113
|
+
});
|
|
114
|
+
}, CUSTOMIZE_SETTLE_MS));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* `trackProductCustomized` bound to the store and Relay environment in
|
|
119
|
+
* context, for a licence control's click handlers.
|
|
120
|
+
*/
|
|
121
|
+
export function useTrackProductCustomized(collectionId) {
|
|
122
|
+
const environment = useRelayEnvironment();
|
|
123
|
+
const store = useStore();
|
|
124
|
+
return useCallback(() => {
|
|
125
|
+
if (!collectionId) return;
|
|
126
|
+
trackProductCustomized(environment, collectionId, () => store.getState().licenseOptions);
|
|
127
|
+
}, [environment, store, collectionId]);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Reports the checkout's payment details as complete. The server records it
|
|
132
|
+
* once per order, however often this is called.
|
|
133
|
+
*/
|
|
134
|
+
export function trackPaymentInfoEntered(environment) {
|
|
135
|
+
track(environment, {
|
|
136
|
+
event: 'PAYMENT_INFO_ENTERED'
|
|
137
|
+
});
|
|
138
|
+
}
|
|
@@ -7,12 +7,12 @@ export const CollectionAa = _ref => {
|
|
|
7
7
|
let {
|
|
8
8
|
product: productKey
|
|
9
9
|
} = _ref;
|
|
10
|
-
const product = useFragment((_CollectionAa_product.hash && _CollectionAa_product.hash !== "
|
|
10
|
+
const product = useFragment((_CollectionAa_product.hash && _CollectionAa_product.hash !== "a3ee4dc4f6eb38b9c24a21cdc2cb6bc0" && console.error("The definition of 'CollectionAa_product' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _CollectionAa_product), productKey);
|
|
11
11
|
let fontStyle;
|
|
12
12
|
if ((product === null || product === void 0 ? void 0 : product.__typename) === 'Bundle') {
|
|
13
13
|
var _product$fontStyles;
|
|
14
14
|
fontStyle = (_product$fontStyles = product.fontStyles) === null || _product$fontStyles === void 0 ? void 0 : _product$fontStyles[0];
|
|
15
|
-
} else if ((product === null || product === void 0 ? void 0 : product.__typename) === 'FontCollection') {
|
|
15
|
+
} else if ((product === null || product === void 0 ? void 0 : product.__typename) === 'FontCollection' || (product === null || product === void 0 ? void 0 : product.__typename) === 'FontPack') {
|
|
16
16
|
fontStyle = product.featureStyle;
|
|
17
17
|
}
|
|
18
18
|
if (!fontStyle) return null;
|
|
@@ -24,20 +24,21 @@ function FontFamilies(_ref) {
|
|
|
24
24
|
} = useLicenseAndOrderVariables();
|
|
25
25
|
const {
|
|
26
26
|
node
|
|
27
|
-
} = useLazyLoadQuery((_FontFamiliesQuery.hash && _FontFamiliesQuery.hash !== "
|
|
27
|
+
} = useLazyLoadQuery((_FontFamiliesQuery.hash && _FontFamiliesQuery.hash !== "1ccff8f69fae99e65e6007bf25e4f8a3" && console.error("The definition of 'FontFamiliesQuery' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _FontFamiliesQuery), {
|
|
28
28
|
collectionId,
|
|
29
29
|
licenseOptions: licenseOptionsSpecs,
|
|
30
30
|
orderVariables: orderVariableSelections
|
|
31
31
|
});
|
|
32
32
|
if (!node) return null;
|
|
33
|
+
// Unlisted collections are only sold through an upgrade – see StoreModalProduct.
|
|
33
34
|
return /*#__PURE__*/React.createElement("div", {
|
|
34
35
|
className: "font-families"
|
|
35
36
|
}, /*#__PURE__*/React.createElement("div", {
|
|
36
37
|
className: "font-families__items"
|
|
37
|
-
}, /*#__PURE__*/React.createElement(Family, {
|
|
38
|
+
}, node.visibility !== 'UNLISTED' && /*#__PURE__*/React.createElement(Family, {
|
|
38
39
|
node: node,
|
|
39
40
|
size: "wide"
|
|
40
|
-
}), (_node$families = node.families) === null || _node$families === void 0 ? void 0 : _node$families.map((family, index) => /*#__PURE__*/React.createElement(Family, {
|
|
41
|
+
}), (_node$families = node.families) === null || _node$families === void 0 ? void 0 : _node$families.filter(family => family.visibility !== 'UNLISTED').map((family, index) => /*#__PURE__*/React.createElement(Family, {
|
|
41
42
|
key: index,
|
|
42
43
|
node: family
|
|
43
44
|
}))));
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { NodePasswordForm_props } from './index.js';
|
|
3
|
-
export default function NodePasswordFormElement(
|
|
3
|
+
export default function NodePasswordFormElement(props: NodePasswordForm_props): React.JSX.Element;
|