fontdue-js 2.18.1 → 2.18.3

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 (57) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/__generated__/CartItemProduct_product.graphql.d.ts +1 -1
  3. package/dist/__generated__/CartItemProduct_product.graphql.js +16 -10
  4. package/dist/__generated__/CartOrderCompleteOrderMutation.graphql.d.ts +1 -1
  5. package/dist/__generated__/CartOrderCompleteOrderMutation.graphql.js +16 -10
  6. package/dist/__generated__/CartOrderRemoveDiscountMutation.graphql.d.ts +1 -1
  7. package/dist/__generated__/CartOrderRemoveDiscountMutation.graphql.js +16 -10
  8. package/dist/__generated__/CartOrderUpdateMutation.graphql.d.ts +1 -1
  9. package/dist/__generated__/CartOrderUpdateMutation.graphql.js +16 -10
  10. package/dist/__generated__/CartQuery.graphql.d.ts +1 -1
  11. package/dist/__generated__/CartQuery.graphql.js +16 -10
  12. package/dist/__generated__/CartStateRemoveDiscountMutation.graphql.d.ts +1 -1
  13. package/dist/__generated__/CartStateRemoveDiscountMutation.graphql.js +37 -29
  14. package/dist/__generated__/CartStateUpdateMutation.graphql.d.ts +1 -1
  15. package/dist/__generated__/CartStateUpdateMutation.graphql.js +79 -66
  16. package/dist/__generated__/CheckoutUpdateCustomerMutation.graphql.d.ts +1 -1
  17. package/dist/__generated__/CheckoutUpdateCustomerMutation.graphql.js +16 -10
  18. package/dist/__generated__/CheckoutUpdateOrderMutation.graphql.d.ts +1 -1
  19. package/dist/__generated__/CheckoutUpdateOrderMutation.graphql.js +16 -10
  20. package/dist/__generated__/CouponCodeInputApplyCouponMutation.graphql.d.ts +1 -1
  21. package/dist/__generated__/CouponCodeInputApplyCouponMutation.graphql.js +37 -29
  22. package/dist/__generated__/PrecartAddToCartMutation.graphql.d.ts +1 -1
  23. package/dist/__generated__/PrecartAddToCartMutation.graphql.js +21 -15
  24. package/dist/__generated__/StoreModalCartQuery.graphql.d.ts +1 -1
  25. package/dist/__generated__/StoreModalCartQuery.graphql.js +39 -21
  26. package/dist/__generated__/StoreModalProductQuery.graphql.d.ts +1 -1
  27. package/dist/__generated__/StoreModalProductQuery.graphql.js +8 -3
  28. package/dist/__generated__/StoreModalProductSummaryRefetchQuery.graphql.d.ts +1 -1
  29. package/dist/__generated__/StoreModalProductSummaryRefetchQuery.graphql.js +9 -4
  30. package/dist/__generated__/StoreModalProductSummary_viewer.graphql.d.ts +7 -1
  31. package/dist/__generated__/StoreModalProductSummary_viewer.graphql.js +7 -2
  32. package/dist/__generated__/StoreModalUnifiedCheckoutCompleteOrderMutation.graphql.d.ts +1 -1
  33. package/dist/__generated__/StoreModalUnifiedCheckoutCompleteOrderMutation.graphql.js +10 -4
  34. package/dist/__generated__/StoreModalUnifiedCheckoutUpdateCustomerMutation.graphql.d.ts +1 -1
  35. package/dist/__generated__/StoreModalUnifiedCheckoutUpdateCustomerMutation.graphql.js +10 -4
  36. package/dist/__generated__/StoreModalUnifiedCheckoutUpdateOrderMutation.graphql.d.ts +1 -1
  37. package/dist/__generated__/StoreModalUnifiedCheckoutUpdateOrderMutation.graphql.js +36 -28
  38. package/dist/__generated__/StoreModalUnifiedCheckout_order.graphql.d.ts +2 -1
  39. package/dist/__generated__/StoreModalUnifiedCheckout_order.graphql.js +9 -3
  40. package/dist/__generated__/StoreModalUnifiedCheckout_viewer.graphql.d.ts +3 -1
  41. package/dist/__generated__/StoreModalUnifiedCheckout_viewer.graphql.js +14 -2
  42. package/dist/__generated__/TestFontsFormUpdateCustomerMutation.graphql.d.ts +1 -1
  43. package/dist/__generated__/TestFontsFormUpdateCustomerMutation.graphql.js +16 -10
  44. package/dist/__generated__/productState_Query.graphql.d.ts +29 -1
  45. package/dist/__generated__/productState_Query.graphql.js +24 -5
  46. package/dist/__generated__/productState_collectionBundle.graphql.d.ts +41 -0
  47. package/dist/__generated__/productState_collectionBundle.graphql.js +88 -0
  48. package/dist/__generated__/productState_node.graphql.d.ts +29 -1
  49. package/dist/__generated__/productState_node.graphql.js +20 -2
  50. package/dist/components/Cart/CartItem/CartItemProduct.js +3 -3
  51. package/dist/components/Root/productState.js +35 -7
  52. package/dist/components/StoreModal/StoreModalCart.js +2 -3
  53. package/dist/components/StoreModalProductSummary/index.js +1 -1
  54. package/dist/components/StripeProvider/index.d.ts +1 -2
  55. package/dist/components/StripeProvider/index.js +7 -10
  56. package/dist/components/elements/StoreModalUnifiedCheckout.js +64 -16
  57. package/package.json +1 -1
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ /**
8
+ * @generated SignedSource<<c1a8446af3677d58e3851338c54cf16e>>
9
+ * @lightSyntaxTransform
10
+ * @nogrep
11
+ */
12
+
13
+ /* tslint:disable */
14
+ /* eslint-disable */
15
+ // @ts-nocheck
16
+
17
+ const node = function () {
18
+ var v0 = {
19
+ "alias": null,
20
+ "args": null,
21
+ "kind": "ScalarField",
22
+ "name": "id",
23
+ "storageKey": null
24
+ },
25
+ v1 = {
26
+ "alias": null,
27
+ "args": null,
28
+ "concreteType": "Sku",
29
+ "kind": "LinkedField",
30
+ "name": "sku",
31
+ "plural": false,
32
+ "selections": [v0 /*: any*/, {
33
+ "alias": null,
34
+ "args": null,
35
+ "concreteType": "Money",
36
+ "kind": "LinkedField",
37
+ "name": "price",
38
+ "plural": false,
39
+ "selections": [{
40
+ "alias": null,
41
+ "args": null,
42
+ "kind": "ScalarField",
43
+ "name": "amount",
44
+ "storageKey": null
45
+ }],
46
+ "storageKey": null
47
+ }],
48
+ "storageKey": null
49
+ };
50
+ return {
51
+ "argumentDefinitions": [],
52
+ "kind": "Fragment",
53
+ "metadata": {
54
+ "mask": false
55
+ },
56
+ "name": "productState_collectionBundle",
57
+ "selections": [v0 /*: any*/, {
58
+ "alias": null,
59
+ "args": null,
60
+ "kind": "ScalarField",
61
+ "name": "name",
62
+ "storageKey": null
63
+ }, v1 /*: any*/, {
64
+ "alias": null,
65
+ "args": null,
66
+ "concreteType": "FontCollection",
67
+ "kind": "LinkedField",
68
+ "name": "memberCollections",
69
+ "plural": true,
70
+ "selections": [v0 /*: any*/, v1 /*: any*/, {
71
+ "alias": null,
72
+ "args": null,
73
+ "concreteType": "FontStyle",
74
+ "kind": "LinkedField",
75
+ "name": "fontStyles",
76
+ "plural": true,
77
+ "selections": [v0 /*: any*/, v1 /*: any*/],
78
+ "storageKey": null
79
+ }],
80
+ "storageKey": null
81
+ }],
82
+ "type": "CollectionBundle",
83
+ "abstractKey": null
84
+ };
85
+ }();
86
+ node.hash = "6744aa8f57d14b0111a0c49f488d7b03";
87
+ var _default = node;
88
+ exports.default = _default;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @generated SignedSource<<516d3d7a123f16a93143726e2a11f81d>>
2
+ * @generated SignedSource<<89ccca0787788a2ceb37d58b6ab5340a>>
3
3
  * @lightSyntaxTransform
4
4
  * @nogrep
5
5
  */
@@ -63,6 +63,34 @@ export type productState_node$data = {
63
63
  };
64
64
  } | null;
65
65
  }> | null;
66
+ readonly collectionBundles: ReadonlyArray<{
67
+ readonly id: string;
68
+ readonly memberCollections: ReadonlyArray<{
69
+ readonly fontStyles: ReadonlyArray<{
70
+ readonly id: string;
71
+ readonly sku: {
72
+ readonly id: string;
73
+ readonly price: {
74
+ readonly amount: number;
75
+ };
76
+ } | null;
77
+ }>;
78
+ readonly id: string;
79
+ readonly sku: {
80
+ readonly id: string;
81
+ readonly price: {
82
+ readonly amount: number;
83
+ };
84
+ } | null;
85
+ }> | null;
86
+ readonly name: string;
87
+ readonly sku: {
88
+ readonly id: string;
89
+ readonly price: {
90
+ readonly amount: number;
91
+ };
92
+ } | null;
93
+ }> | null;
66
94
  readonly fontStyles: ReadonlyArray<{
67
95
  readonly id: string;
68
96
  readonly sku: {
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  /**
8
- * @generated SignedSource<<516d3d7a123f16a93143726e2a11f81d>>
8
+ * @generated SignedSource<<89ccca0787788a2ceb37d58b6ab5340a>>
9
9
  * @lightSyntaxTransform
10
10
  * @nogrep
11
11
  */
@@ -82,6 +82,24 @@ const node = function () {
82
82
  },
83
83
  "name": "productState_node",
84
84
  "selections": [v0 /*: any*/, v1 /*: any*/, v2 /*: any*/, v3 /*: any*/, v4 /*: any*/, {
85
+ "alias": null,
86
+ "args": null,
87
+ "concreteType": "CollectionBundle",
88
+ "kind": "LinkedField",
89
+ "name": "collectionBundles",
90
+ "plural": true,
91
+ "selections": [v0 /*: any*/, v1 /*: any*/, v2 /*: any*/, {
92
+ "alias": null,
93
+ "args": null,
94
+ "concreteType": "FontCollection",
95
+ "kind": "LinkedField",
96
+ "name": "memberCollections",
97
+ "plural": true,
98
+ "selections": [v0 /*: any*/, v2 /*: any*/, v3 /*: any*/],
99
+ "storageKey": null
100
+ }],
101
+ "storageKey": null
102
+ }, {
85
103
  "alias": null,
86
104
  "args": [{
87
105
  "kind": "Literal",
@@ -99,6 +117,6 @@ const node = function () {
99
117
  "abstractKey": null
100
118
  };
101
119
  }();
102
- node.hash = "aab1ef07e0192a0d22a4c300084d9d05";
120
+ node.hash = "a1e172db45ca550a254819d877497d12";
103
121
  var _default = node;
104
122
  exports.default = _default;
@@ -17,7 +17,7 @@ function CartItemProduct(_ref) {
17
17
  let {
18
18
  product: productKey
19
19
  } = _ref;
20
- const product = (0, _reactRelay.useFragment)((_CartItemProduct_product2.default.hash && _CartItemProduct_product2.default.hash !== "93463fc6e5eab6e2f910904bf0c2393e" && 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_product2.default), productKey);
20
+ const product = (0, _reactRelay.useFragment)((_CartItemProduct_product2.default.hash && _CartItemProduct_product2.default.hash !== "22f49bcb8a461d2d3eefc4f8ba1e575c" && 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_product2.default), productKey);
21
21
  let productCss;
22
22
  if ((product === null || product === void 0 ? void 0 : product.__typename) === 'FontStyle') productCss = (_product$family = product.family) === null || _product$family === void 0 ? void 0 : _product$family.cssUrl;
23
23
  if ((product === null || product === void 0 ? void 0 : product.__typename) === 'FontCollection') productCss = (_product$featureStyle = product.featureStyle) === null || _product$featureStyle === void 0 ? void 0 : (_product$featureStyle2 = _product$featureStyle.family) === null || _product$featureStyle2 === void 0 ? void 0 : _product$featureStyle2.cssUrl;
@@ -27,7 +27,7 @@ function CartItemProduct(_ref) {
27
27
  className: "cart-item__aa"
28
28
  }, product ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Stylesheet.default, {
29
29
  href: productCss
30
- }), ['FontCollection', 'Bundle'].indexOf(product.__typename) >= 0 ? /*#__PURE__*/_react.default.createElement(_CollectionAa.CollectionAa, {
30
+ }), ['FontCollection', 'Bundle', 'CollectionBundle'].indexOf(product.__typename) >= 0 ? /*#__PURE__*/_react.default.createElement(_CollectionAa.CollectionAa, {
31
31
  product: product
32
32
  }) : /*#__PURE__*/_react.default.createElement(_FontStyle.default, {
33
33
  fontStyle: product
@@ -37,7 +37,7 @@ function CartItemProduct(_ref) {
37
37
  className: "cart-item__name"
38
38
  }, 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.default.createElement("div", {
39
39
  className: "cart-item__label"
40
- }, "Variable font") : (product === null || product === void 0 ? void 0 : product.__typename) === 'FontCollection' && /*#__PURE__*/_react.default.createElement("div", {
40
+ }, "Variable font") : ((product === null || product === void 0 ? void 0 : product.__typename) === 'FontCollection' || (product === null || product === void 0 ? void 0 : product.__typename) === 'CollectionBundle') && /*#__PURE__*/_react.default.createElement("div", {
41
41
  className: "cart-item__label"
42
42
  }, "(", (0, _utils.pluralize)(product.totalStyles ?? 0, 'style'), ")")));
43
43
  }
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.populateProductStateReducer = exports.populateProductState = void 0;
7
7
  var _productState_Query2 = _interopRequireDefault(require("../../__generated__/productState_Query.graphql"));
8
8
  var _productState_node2 = _interopRequireDefault(require("../../__generated__/productState_node.graphql"));
9
+ var _productState_collectionBundle2 = _interopRequireDefault(require("../../__generated__/productState_collectionBundle.graphql"));
9
10
  var _productState_bundle2 = _interopRequireDefault(require("../../__generated__/productState_bundle.graphql"));
10
11
  var _productState_collection2 = _interopRequireDefault(require("../../__generated__/productState_collection.graphql"));
11
12
  var _productState_sku2 = _interopRequireDefault(require("../../__generated__/productState_sku.graphql"));
@@ -15,7 +16,8 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
15
16
  _productState_sku2.default.hash && _productState_sku2.default.hash !== "2cee6ddddc85699f0c90e2607c0634ef" && console.error("The definition of 'productState_sku' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _productState_sku2.default;
16
17
  _productState_collection2.default.hash && _productState_collection2.default.hash !== "90e56933f956c6773c0958284de81884" && console.error("The definition of 'productState_collection' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _productState_collection2.default;
17
18
  _productState_bundle2.default.hash && _productState_bundle2.default.hash !== "fa38bbc9f2062a727da4f5062b362054" && console.error("The definition of 'productState_bundle' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _productState_bundle2.default;
18
- _productState_node2.default.hash && _productState_node2.default.hash !== "aab1ef07e0192a0d22a4c300084d9d05" && console.error("The definition of 'productState_node' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _productState_node2.default;
19
+ _productState_collectionBundle2.default.hash && _productState_collectionBundle2.default.hash !== "6744aa8f57d14b0111a0c49f488d7b03" && console.error("The definition of 'productState_collectionBundle' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _productState_collectionBundle2.default;
20
+ _productState_node2.default.hash && _productState_node2.default.hash !== "a1e172db45ca550a254819d877497d12" && console.error("The definition of 'productState_node' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _productState_node2.default;
19
21
  const query = (_productState_Query2.default.hash && _productState_Query2.default.hash !== "ac3292bae9a274139d5a525fd0162711" && console.error("The definition of 'productState_Query' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _productState_Query2.default);
20
22
  const populateProductState = (store, environment, id) => {
21
23
  const existingState = store.getState().fetchedCollectionIds;
@@ -39,12 +41,25 @@ const allSkus = function (collection) {
39
41
  var _collection$bundles;
40
42
  bundleSkus = (collection === null || collection === void 0 ? void 0 : (_collection$bundles = collection.bundles) === null || _collection$bundles === void 0 ? void 0 : _collection$bundles.flatMap(bundle => allSkus(bundle, includeCollections, includeFontStyles))) ?? [];
41
43
  }
44
+ let collectionBundleSkus = [];
45
+ if ('collectionBundles' in collection && collection.collectionBundles) {
46
+ collectionBundleSkus = collection.collectionBundles.flatMap(collBundle => allSkus(collBundle, includeCollections, includeFontStyles));
47
+ }
48
+
49
+ // For collection bundles, get SKUs from member collections
50
+ let memberCollectionSkus = [];
51
+ if ('memberCollections' in collection && collection.memberCollections) {
52
+ memberCollectionSkus = collection.memberCollections.flatMap(member => {
53
+ var _member$fontStyles;
54
+ return [includeCollections ? member.sku : null, ...(includeFontStyles ? ((_member$fontStyles = member.fontStyles) === null || _member$fontStyles === void 0 ? void 0 : _member$fontStyles.map(style => style.sku)) ?? [] : [])];
55
+ }).filter(_utils.notEmpty);
56
+ }
42
57
  let childrenSkus = [];
43
58
  if ('children' in collection) {
44
59
  var _collection$children;
45
60
  childrenSkus = ((_collection$children = collection.children) === null || _collection$children === void 0 ? void 0 : _collection$children.flatMap(child => allSkus(child, includeCollections, includeFontStyles))) ?? [];
46
61
  }
47
- return [includeCollections ? collection === null || collection === void 0 ? void 0 : collection.sku : null, ...(includeFontStyles ? (collection === null || collection === void 0 ? void 0 : (_collection$fontStyle = collection.fontStyles) === null || _collection$fontStyle === void 0 ? void 0 : _collection$fontStyle.map(style => style.sku)) ?? [] : []), ...bundleSkus, ...childrenSkus].filter(_utils.notEmpty);
62
+ return [includeCollections ? collection === null || collection === void 0 ? void 0 : collection.sku : null, ...(includeFontStyles && 'fontStyles' in collection ? (collection === null || collection === void 0 ? void 0 : (_collection$fontStyle = collection.fontStyles) === null || _collection$fontStyle === void 0 ? void 0 : _collection$fontStyle.map(style => style.sku)) ?? [] : []), ...bundleSkus, ...collectionBundleSkus, ...memberCollectionSkus, ...childrenSkus].filter(_utils.notEmpty);
48
63
  };
49
64
  const flattenSkuData = collection => {
50
65
  let bundles = {};
@@ -54,6 +69,13 @@ const flattenSkuData = collection => {
54
69
  ...flattenSkuData(bundle)
55
70
  }), {});
56
71
  }
72
+ let collectionBundles = {};
73
+ if ('collectionBundles' in collection && collection.collectionBundles) {
74
+ collectionBundles = collection.collectionBundles.reduce((res, collBundle) => ({
75
+ ...res,
76
+ ...flattenSkuData(collBundle)
77
+ }), {});
78
+ }
57
79
  let children = {};
58
80
  if ('children' in collection && collection.children) {
59
81
  children = collection.children.reduce((res, child) => ({
@@ -64,12 +86,17 @@ const flattenSkuData = collection => {
64
86
  let collectionData = {};
65
87
  if (collection.sku) {
66
88
  var _collection$fontStyle2, _collection$children2;
89
+ // For collection bundles, get font style IDs from member collections
90
+ const fontStyleIds = 'memberCollections' in collection && collection.memberCollections ? collection.memberCollections.flatMap(member => {
91
+ var _member$fontStyles2;
92
+ return ((_member$fontStyles2 = member.fontStyles) === null || _member$fontStyles2 === void 0 ? void 0 : _member$fontStyles2.map(style => style.id)) ?? [];
93
+ }) : 'fontStyles' in collection ? (((_collection$fontStyle2 = collection.fontStyles) === null || _collection$fontStyle2 === void 0 ? void 0 : _collection$fontStyle2.map(style => style.id)) ?? []).concat('children' in collection ? ((_collection$children2 = collection.children) === null || _collection$children2 === void 0 ? void 0 : _collection$children2.flatMap(child => {
94
+ var _child$fontStyles;
95
+ return ((_child$fontStyles = child.fontStyles) === null || _child$fontStyles === void 0 ? void 0 : _child$fontStyles.map(style => style.id)) ?? [];
96
+ })) ?? [] : []) : [];
67
97
  collectionData = {
68
98
  [collection.sku.id]: {
69
- fontStyleIds: (((_collection$fontStyle2 = collection.fontStyles) === null || _collection$fontStyle2 === void 0 ? void 0 : _collection$fontStyle2.map(style => style.id)) ?? []).concat('children' in collection ? ((_collection$children2 = collection.children) === null || _collection$children2 === void 0 ? void 0 : _collection$children2.flatMap(child => {
70
- var _child$fontStyles;
71
- return ((_child$fontStyles = child.fontStyles) === null || _child$fontStyles === void 0 ? void 0 : _child$fontStyles.map(style => style.id)) ?? [];
72
- })) ?? [] : []),
99
+ fontStyleIds,
73
100
  fontStyleSkuIds: allSkus(collection, false, true).map(sku => sku.id),
74
101
  childrenSkuIds: allSkus(collection, true, false).map(sku => sku.id).filter(skuId => {
75
102
  var _collection$sku;
@@ -83,7 +110,8 @@ const flattenSkuData = collection => {
83
110
  return {
84
111
  ...collectionData,
85
112
  ...children,
86
- ...bundles
113
+ ...bundles,
114
+ ...collectionBundles
87
115
  };
88
116
  };
89
117
  const flattenSkuPrices = collection => {
@@ -35,7 +35,7 @@ const StoreModalCart = _ref => {
35
35
  body: order && orderHasItems ? /*#__PURE__*/_react.default.createElement(_CartState.default, {
36
36
  order: order
37
37
  }, _ref2 => {
38
- var _data$viewer, _data$viewer$currentO, _data$viewer$currentO2, _order$orderItems2, _order$total, _data$viewer2, _data$viewer2$setting, _data$viewer3, _data$viewer3$setting;
38
+ var _data$viewer, _data$viewer$currentO, _data$viewer$currentO2, _order$orderItems2, _order$total, _data$viewer2, _data$viewer2$setting;
39
39
  let {
40
40
  onUpdateOrderVariableSelections,
41
41
  onRemoveDiscount,
@@ -71,8 +71,7 @@ const StoreModalCart = _ref => {
71
71
  }),
72
72
  checkout: /*#__PURE__*/_react.default.createElement(_StripeProvider.default, {
73
73
  viewer: data.viewer,
74
- providerType: "elements",
75
- requireClientSecret: ((_data$viewer3 = data.viewer) === null || _data$viewer3 === void 0 ? void 0 : (_data$viewer3$setting = _data$viewer3.settings) === null || _data$viewer3$setting === void 0 ? void 0 : _data$viewer3$setting.taxSystem) === 'fontdue'
74
+ providerType: "elements"
76
75
  }, /*#__PURE__*/_react.default.createElement(_StoreModalUnifiedCheckout.default, {
77
76
  viewer: data.viewer,
78
77
  order: order,
@@ -63,7 +63,7 @@ const StoreModalProductSummary = _ref => {
63
63
  const refetchVariables = (0, _react.useMemo)(() => ({
64
64
  selectedSkuIds: selectedSkuIdsArray
65
65
  }), [selectedSkuIdsArray]);
66
- const [viewer, refetch] = (0, _reactRelay.useRefetchableFragment)((_StoreModalProductSummary_viewer2.default.hash && _StoreModalProductSummary_viewer2.default.hash !== "d95602902697c0bb7ca4be2089649198" && console.error("The definition of 'StoreModalProductSummary_viewer' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _StoreModalProductSummary_viewer2.default), viewerKey);
66
+ const [viewer, refetch] = (0, _reactRelay.useRefetchableFragment)((_StoreModalProductSummary_viewer2.default.hash && _StoreModalProductSummary_viewer2.default.hash !== "81a5f120d76cbb84753d158a7ff38c19" && console.error("The definition of 'StoreModalProductSummary_viewer' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _StoreModalProductSummary_viewer2.default), viewerKey);
67
67
  (0, _useRefetchOnLicenseChanges.useRefetchOnLicenseChanges)({
68
68
  environment,
69
69
  refetch,
@@ -4,7 +4,6 @@ interface StripeProvider_props {
4
4
  viewer: StripeProvider_viewer$key;
5
5
  children: JSX.Element;
6
6
  providerType: 'checkout' | 'elements';
7
- requireClientSecret?: boolean;
8
7
  }
9
- declare const StripeProvider: ({ viewer, providerType, children, requireClientSecret, }: StripeProvider_props) => JSX.Element | null;
8
+ declare const StripeProvider: ({ viewer, providerType, children, }: StripeProvider_props) => JSX.Element | null;
10
9
  export default StripeProvider;
@@ -20,8 +20,7 @@ const StripeProvider = _ref => {
20
20
  let {
21
21
  viewer,
22
22
  providerType,
23
- children,
24
- requireClientSecret
23
+ children
25
24
  } = _ref;
26
25
  const data = (0, _reactRelay.useFragment)((_StripeProvider_viewer2.default.hash && _StripeProvider_viewer2.default.hash !== "dd5fd4cdd75d727050b8d1d6f4269fa8" && console.error("The definition of 'StripeProvider_viewer' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _StripeProvider_viewer2.default), viewer);
27
26
  const stripeKey = data.stripePublishableKey;
@@ -29,6 +28,12 @@ const StripeProvider = _ref => {
29
28
  const stripePromiseRef = (0, _react.useRef)(stripeKey && stripeAccount ? (0, _stripeJs.loadStripe)(stripeKey, {
30
29
  stripeAccount
31
30
  }) : null);
31
+
32
+ // All hooks must be called before any conditional returns (React rules of hooks)
33
+ const environment = (0, _reactRelay.useRelayEnvironment)();
34
+ const {
35
+ stripe: config
36
+ } = (0, _react.useContext)(_ConfigContext.default);
32
37
  let customFontSource;
33
38
  const woffSrc = (_data$settings = data.settings) === null || _data$settings === void 0 ? void 0 : (_data$settings$uiFont = _data$settings.uiFontStyle) === null || _data$settings$uiFont === void 0 ? void 0 : (_data$settings$uiFont2 = _data$settings$uiFont.webfontSources) === null || _data$settings$uiFont2 === void 0 ? void 0 : (_data$settings$uiFont3 = _data$settings$uiFont2.find(source => (source === null || source === void 0 ? void 0 : source.format) === 'woff2')) === null || _data$settings$uiFont3 === void 0 ? void 0 : _data$settings$uiFont3.url;
34
39
  let fontFamily = (_data$settings2 = data.settings) !== null && _data$settings2 !== void 0 && _data$settings2.uiFontStyle ? `${data.settings.uiFontStyle.cssFamily} ${data.settings.uiFontStyle.name}` : undefined;
@@ -46,13 +51,8 @@ const StripeProvider = _ref => {
46
51
  weight: '400'
47
52
  };
48
53
  }
49
-
50
- // the stripe provider may not be rendered, so we have to conditonally call
51
- // useStripe down in the children
52
54
  const clientSecret = ((_data$currentOrder = data.currentOrder) === null || _data$currentOrder === void 0 ? void 0 : (_data$currentOrder$st = _data$currentOrder.stripePaymentIntent) === null || _data$currentOrder$st === void 0 ? void 0 : _data$currentOrder$st.clientSecret) ?? undefined;
53
- if (requireClientSecret && !clientSecret) return children;
54
55
  const customProperties = (0, _utils.parseCustomProperties)((_data$themeConfig = data.themeConfig) === null || _data$themeConfig === void 0 ? void 0 : _data$themeConfig.customProperties);
55
- const environment = (0, _reactRelay.useRelayEnvironment)();
56
56
  const fetchClientSecret = (0, _react.useCallback)(() => {
57
57
  return new Promise((resolve, reject) => {
58
58
  (0, _reactRelay.commitMutation)(environment, {
@@ -73,9 +73,6 @@ const StripeProvider = _ref => {
73
73
  });
74
74
  });
75
75
  }, [environment]);
76
- const {
77
- stripe: config
78
- } = (0, _react.useContext)(_ConfigContext.default);
79
76
  const options = {
80
77
  appearance: config.appearance ?? {
81
78
  theme: 'flat',
@@ -10,6 +10,7 @@ var _StoreModalUnifiedCheckoutUpdateCustomerMutation2 = _interopRequireDefault(r
10
10
  var _StoreModalUnifiedCheckout_order2 = _interopRequireDefault(require("../../__generated__/StoreModalUnifiedCheckout_order.graphql"));
11
11
  var _StoreModalUnifiedCheckout_viewer2 = _interopRequireDefault(require("../../__generated__/StoreModalUnifiedCheckout_viewer.graphql"));
12
12
  var _react = _interopRequireWildcard(require("react"));
13
+ var _reactGoogleRecaptcha = _interopRequireDefault(require("react-google-recaptcha"));
13
14
  var Sentry = _interopRequireWildcard(require("@sentry/react"));
14
15
  var _reactRelay = require("react-relay");
15
16
  var _AddressFields = _interopRequireDefault(require("../Cart/AddressFields"));
@@ -168,15 +169,15 @@ function EditableSection(_ref) {
168
169
  }, "Change")));
169
170
  }
170
171
  function StoreModalUnifiedCheckout(_ref2) {
171
- var _order$orderVariableS, _viewer$settings, _viewer$settings2, _viewer$settings3, _order$stripePaymentI, _order$stripePaymentI2;
172
+ var _order$orderVariableS, _viewer$settings, _viewer$settings2, _viewer$settings3, _viewer$settings4, _order$stripePaymentI, _viewer$settings5, _order$stripePaymentI2, _order$stripePaymentI3;
172
173
  let {
173
174
  order: orderKey,
174
175
  viewer: viewerKey,
175
176
  onScrollToTop,
176
177
  onUpdateOrderVariableSelections
177
178
  } = _ref2;
178
- const viewer = (0, _reactRelay.useFragment)((_StoreModalUnifiedCheckout_viewer2.default.hash && _StoreModalUnifiedCheckout_viewer2.default.hash !== "83cc5e6f8d508fb1c2356a72b040f9b0" && console.error("The definition of 'StoreModalUnifiedCheckout_viewer' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _StoreModalUnifiedCheckout_viewer2.default), viewerKey);
179
- const order = (0, _reactRelay.useFragment)((_StoreModalUnifiedCheckout_order2.default.hash && _StoreModalUnifiedCheckout_order2.default.hash !== "ea43fb766c4dd1183b46ddf449aa85bd" && console.error("The definition of 'StoreModalUnifiedCheckout_order' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _StoreModalUnifiedCheckout_order2.default), orderKey);
179
+ const viewer = (0, _reactRelay.useFragment)((_StoreModalUnifiedCheckout_viewer2.default.hash && _StoreModalUnifiedCheckout_viewer2.default.hash !== "048ce405742611f6684cb5306d28478b" && console.error("The definition of 'StoreModalUnifiedCheckout_viewer' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _StoreModalUnifiedCheckout_viewer2.default), viewerKey);
180
+ const order = (0, _reactRelay.useFragment)((_StoreModalUnifiedCheckout_order2.default.hash && _StoreModalUnifiedCheckout_order2.default.hash !== "7c5503876a562732ebaead9b2ae97180" && console.error("The definition of 'StoreModalUnifiedCheckout_order' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _StoreModalUnifiedCheckout_order2.default), orderKey);
180
181
 
181
182
  // Check if order has a country-type order variable with a different country than detected
182
183
  // This is important for order snapshot/quote functionality where a quote was created for
@@ -292,6 +293,13 @@ function StoreModalUnifiedCheckout(_ref2) {
292
293
  const {
293
294
  form: config
294
295
  } = (0, _react.useContext)(_ConfigContext.default);
296
+
297
+ // reCAPTCHA state
298
+ const [recaptchaToken, setRecaptchaToken] = (0, _react.useState)(null);
299
+ const [pendingCustomerSubmit, setPendingCustomerSubmit] = (0, _react.useState)(null);
300
+ const recaptchaRef = (0, _react.useRef)(null);
301
+ const recaptchaEnabled = ((_viewer$settings = viewer.settings) === null || _viewer$settings === void 0 ? void 0 : _viewer$settings.recaptchaEnabled) ?? false;
302
+ const recaptchaSiteKey = (_viewer$settings2 = viewer.settings) === null || _viewer$settings2 === void 0 ? void 0 : _viewer$settings2.recaptchaSiteKey;
295
303
  const onCompleted = (res, errors, onSuccess, onError) => {
296
304
  var _res$updateCustomer, _res$updateOrder;
297
305
  if (errors && errors.length > 0) {
@@ -402,11 +410,10 @@ function StoreModalUnifiedCheckout(_ref2) {
402
410
  // set initial state depending on if checkout is already in progress
403
411
  if (!order.customer) initialEditingState = 'customer';
404
412
  const [editing, setEditing] = (0, _react.useState)(initialEditingState);
405
- const handleCustomerSubmit = _ref3 => {
406
- let {
407
- onSuccess,
408
- onError
409
- } = _ref3;
413
+
414
+ // Submit customer data with optional reCAPTCHA token
415
+ const submitCustomer = (0, _react.useCallback)((token, callbacks) => {
416
+ setPendingCustomerSubmit(null);
410
417
  if (!billingIdentity.name && !billingIdentity.email) {
411
418
  setBillingIdentity({
412
419
  ...billingIdentity,
@@ -415,11 +422,46 @@ function StoreModalUnifiedCheckout(_ref2) {
415
422
  });
416
423
  }
417
424
  updateCustomer({
418
- input: customer
425
+ input: {
426
+ ...customer,
427
+ recaptchaToken: token ?? undefined
428
+ }
419
429
  }, () => {
420
- onSuccess();
430
+ var _recaptchaRef$current;
431
+ callbacks.onSuccess();
421
432
  setEditing(null);
422
- }, onError);
433
+ // Reset reCAPTCHA after successful submission
434
+ (_recaptchaRef$current = recaptchaRef.current) === null || _recaptchaRef$current === void 0 ? void 0 : _recaptchaRef$current.reset();
435
+ setRecaptchaToken(null);
436
+ }, () => {
437
+ var _recaptchaRef$current2;
438
+ callbacks.onError();
439
+ // Reset reCAPTCHA on error so user can retry
440
+ (_recaptchaRef$current2 = recaptchaRef.current) === null || _recaptchaRef$current2 === void 0 ? void 0 : _recaptchaRef$current2.reset();
441
+ setRecaptchaToken(null);
442
+ });
443
+ }, [customer, billingIdentity, updateCustomer]);
444
+ const handleRecaptchaChange = (0, _react.useCallback)(token => {
445
+ setRecaptchaToken(token);
446
+ // If we were waiting for a token to submit, do it now
447
+ if (token && pendingCustomerSubmit) {
448
+ submitCustomer(token, pendingCustomerSubmit.callbacks);
449
+ }
450
+ }, [pendingCustomerSubmit, submitCustomer]);
451
+ const handleRecaptchaExpired = (0, _react.useCallback)(() => {
452
+ setRecaptchaToken(null);
453
+ }, []);
454
+ const handleCustomerSubmit = callbacks => {
455
+ // If reCAPTCHA is enabled but no token, execute it and wait for callback
456
+ if (recaptchaEnabled && recaptchaSiteKey && !recaptchaToken) {
457
+ var _recaptchaRef$current3;
458
+ setPendingCustomerSubmit({
459
+ callbacks
460
+ });
461
+ (_recaptchaRef$current3 = recaptchaRef.current) === null || _recaptchaRef$current3 === void 0 ? void 0 : _recaptchaRef$current3.execute();
462
+ return;
463
+ }
464
+ submitCustomer(recaptchaToken, callbacks);
423
465
  };
424
466
  const handleLicenseeIsBillingIdentityChange = (0, _react.useCallback)(value => {
425
467
  updateOrder({
@@ -613,8 +655,14 @@ function StoreModalUnifiedCheckout(_ref2) {
613
655
  }, "Contact information"), /*#__PURE__*/_react.default.createElement(_CustomerFields.default, {
614
656
  value: customer,
615
657
  onChange: handleCustomerChange,
616
- optInLabel: (_viewer$settings = viewer.settings) === null || _viewer$settings === void 0 ? void 0 : _viewer$settings.newsletterOptInLabel,
658
+ optInLabel: (_viewer$settings3 = viewer.settings) === null || _viewer$settings3 === void 0 ? void 0 : _viewer$settings3.newsletterOptInLabel,
617
659
  errors: customerErrorsObject
660
+ }), recaptchaEnabled && recaptchaSiteKey && /*#__PURE__*/_react.default.createElement(_reactGoogleRecaptcha.default, {
661
+ ref: recaptchaRef,
662
+ sitekey: recaptchaSiteKey,
663
+ size: "invisible",
664
+ onChange: handleRecaptchaChange,
665
+ onExpired: handleRecaptchaExpired
618
666
  }))
619
667
  }), order.customer && !hasCountryMismatch ? /*#__PURE__*/_react.default.createElement(_StoreModalLicenseeIsBillingIdentityElement.default, {
620
668
  disabled: false,
@@ -623,7 +671,7 @@ function StoreModalUnifiedCheckout(_ref2) {
623
671
  }, {
624
672
  label: /*#__PURE__*/_react.default.createElement("div", {
625
673
  dangerouslySetInnerHTML: {
626
- __html: ((_viewer$settings2 = viewer.settings) === null || _viewer$settings2 === void 0 ? void 0 : _viewer$settings2.storeModalSelectLicenseeLabel) ?? ''
674
+ __html: ((_viewer$settings4 = viewer.settings) === null || _viewer$settings4 === void 0 ? void 0 : _viewer$settings4.storeModalSelectLicenseeLabel) ?? ''
627
675
  }
628
676
  })
629
677
  }) : null, showLicenseeSection ? /*#__PURE__*/_react.default.createElement("div", {
@@ -664,7 +712,7 @@ function StoreModalUnifiedCheckout(_ref2) {
664
712
  "data-disabled": false
665
713
  }, /*#__PURE__*/_react.default.createElement("form", {
666
714
  onSubmit: handleComplete
667
- }, !zeroOrder && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("h3", {
715
+ }, !zeroOrder && ((_order$stripePaymentI = order.stripePaymentIntent) === null || _order$stripePaymentI === void 0 ? void 0 : _order$stripePaymentI.clientSecret) && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("h3", {
668
716
  className: "store-modal__cart__checkout-section-title"
669
717
  }, "Payment information", /*#__PURE__*/_react.default.createElement("span", {
670
718
  className: "store-modal__cart__checkout-section-subtitle"
@@ -702,13 +750,13 @@ function StoreModalUnifiedCheckout(_ref2) {
702
750
  htmlFor: "eula-agreement"
703
751
  }, /*#__PURE__*/_react.default.createElement("div", {
704
752
  dangerouslySetInnerHTML: {
705
- __html: ((_viewer$settings3 = viewer.settings) === null || _viewer$settings3 === void 0 ? void 0 : _viewer$settings3.eulaAgreementLabel) ?? ''
753
+ __html: ((_viewer$settings5 = viewer.settings) === null || _viewer$settings5 === void 0 ? void 0 : _viewer$settings5.eulaAgreementLabel) ?? ''
706
754
  }
707
755
  }))), /*#__PURE__*/_react.default.createElement("button", {
708
756
  type: "submit",
709
757
  className: "store-modal__cart__button",
710
758
  disabled: completing || !acceptedEULA
711
- }, completing ? 'Submitting...' : zeroOrder ? 'Complete order' : /*#__PURE__*/_react.default.createElement("span", null, "Pay", ' ', (_order$stripePaymentI = order.stripePaymentIntent) !== null && _order$stripePaymentI !== void 0 && _order$stripePaymentI.amount && (_order$stripePaymentI2 = order.stripePaymentIntent) !== null && _order$stripePaymentI2 !== void 0 && _order$stripePaymentI2.currency ? /*#__PURE__*/_react.default.createElement(_Price.Price, {
759
+ }, completing ? 'Submitting...' : zeroOrder ? 'Complete order' : /*#__PURE__*/_react.default.createElement("span", null, "Pay", ' ', (_order$stripePaymentI2 = order.stripePaymentIntent) !== null && _order$stripePaymentI2 !== void 0 && _order$stripePaymentI2.amount && (_order$stripePaymentI3 = order.stripePaymentIntent) !== null && _order$stripePaymentI3 !== void 0 && _order$stripePaymentI3.currency ? /*#__PURE__*/_react.default.createElement(_Price.Price, {
712
760
  price: {
713
761
  amount: order.stripePaymentIntent.amount,
714
762
  currency: order.stripePaymentIntent.currency
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fontdue-js",
3
- "version": "2.18.1",
3
+ "version": "2.18.3",
4
4
  "scripts": {
5
5
  "build": "npm run relay && run-p build-js build-css build-ts",
6
6
  "build-js": "babel src --out-dir dist --extensions .ts,.tsx,.js,.jsx",