fontdue-js 1.12.0 → 1.12.2

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 CHANGED
@@ -1,3 +1,20 @@
1
+ ## 1.12.2
2
+
3
+ - Fixes an issue completing checkout with a 100% coupon
4
+
5
+ ## 1.12.1
6
+
7
+ - Fixes issues in the StoreModal router
8
+
9
+ ## 1.12.0
10
+
11
+ - Added `indexExcludeTags` option to `storeModal` config
12
+
13
+ ## 1.11.0
14
+
15
+ - Updated Stripe integration and checkout UX to support payment methods via
16
+ Stripe's Payment Element
17
+
1
18
  ## 1.10.2
2
19
 
3
20
  - Fixed error importing module
@@ -8,6 +8,7 @@ export declare type StoreModalIndexQueryResponse = {
8
8
  readonly rootCollections: {
9
9
  readonly edges: ReadonlyArray<{
10
10
  readonly node: {
11
+ readonly id: string;
11
12
  readonly " $fragmentRefs": FragmentRefs<"StoreModalIndexItem_fontCollection">;
12
13
  } | null;
13
14
  } | null> | null;
@@ -16,8 +16,8 @@ query StoreModalIndexQuery(
16
16
  rootCollections: fontCollections(onlyRoots: true, first: 99, excludeTags: $excludeTags) {
17
17
  edges {
18
18
  node {
19
- ...StoreModalIndexItem_fontCollection
20
19
  id
20
+ ...StoreModalIndexItem_fontCollection
21
21
  }
22
22
  }
23
23
  }
@@ -85,21 +85,21 @@ const node = function () {
85
85
  "alias": null,
86
86
  "args": null,
87
87
  "kind": "ScalarField",
88
- "name": "totalStyles",
88
+ "name": "id",
89
89
  "storageKey": null
90
90
  },
91
91
  v3 = {
92
92
  "alias": null,
93
93
  "args": null,
94
94
  "kind": "ScalarField",
95
- "name": "isVariableFont",
95
+ "name": "totalStyles",
96
96
  "storageKey": null
97
97
  },
98
98
  v4 = {
99
99
  "alias": null,
100
100
  "args": null,
101
101
  "kind": "ScalarField",
102
- "name": "id",
102
+ "name": "isVariableFont",
103
103
  "storageKey": null
104
104
  },
105
105
  v5 = {
@@ -143,7 +143,7 @@ const node = function () {
143
143
  "kind": "LinkedField",
144
144
  "name": "node",
145
145
  "plural": false,
146
- "selections": [{
146
+ "selections": [v2 /*: any*/, {
147
147
  "args": null,
148
148
  "kind": "FragmentSpread",
149
149
  "name": "StoreModalIndexItem_fontCollection"
@@ -192,7 +192,7 @@ const node = function () {
192
192
  "kind": "LinkedField",
193
193
  "name": "node",
194
194
  "plural": false,
195
- "selections": [v2 /*: any*/, {
195
+ "selections": [v2 /*: any*/, v3 /*: any*/, {
196
196
  "alias": null,
197
197
  "args": [{
198
198
  "kind": "Literal",
@@ -203,10 +203,10 @@ const node = function () {
203
203
  "kind": "LinkedField",
204
204
  "name": "children",
205
205
  "plural": true,
206
- "selections": [v3 /*: any*/, v2 /*: any*/, v4 /*: any*/],
206
+ "selections": [v4 /*: any*/, v3 /*: any*/, v2 /*: any*/],
207
207
 
208
208
  "storageKey": "children(collectionTypes:[\"FAMILY\"])"
209
- }, v4 /*: any*/, v5 /*: any*/, v3 /*: any*/, {
209
+ }, v5 /*: any*/, v4 /*: any*/, {
210
210
  "alias": null,
211
211
  "args": null,
212
212
  "kind": "ScalarField",
@@ -238,10 +238,10 @@ const node = function () {
238
238
  "kind": "ScalarField",
239
239
  "name": "cssUrl",
240
240
  "storageKey": null
241
- }, v4 /*: any*/],
241
+ }, v2 /*: any*/],
242
242
 
243
243
  "storageKey": null
244
- }, v4 /*: any*/],
244
+ }, v2 /*: any*/],
245
245
 
246
246
  "storageKey": null
247
247
  }],
@@ -250,21 +250,21 @@ const node = function () {
250
250
  "storageKey": null
251
251
  }],
252
252
  "storageKey": null
253
- }, v4 /*: any*/],
253
+ }, v2 /*: any*/],
254
254
 
255
255
  "storageKey": null
256
256
  }]
257
257
  },
258
258
  "params": {
259
- "cacheID": "6ffce75f636184d17f6e4b3e02d02482",
259
+ "cacheID": "0f5be213b1111b517d42ebde0348dcc4",
260
260
  "id": null,
261
261
  "metadata": {},
262
262
  "name": "StoreModalIndexQuery",
263
263
  "operationKind": "query",
264
- "text": "query StoreModalIndexQuery(\n $excludeTags: [String!]\n) {\n viewer {\n rootCollections: fontCollections(onlyRoots: true, first: 99, excludeTags: $excludeTags) {\n edges {\n node {\n ...StoreModalIndexItem_fontCollection\n id\n }\n }\n }\n id\n }\n}\n\nfragment FontStyle_fontStyle on FontStyle {\n cssFamily\n name\n}\n\nfragment StoreModalIndexItem_fontCollection on FontCollection {\n ...useTotalStyles_fontCollection\n id\n name\n totalStyles\n isVariableFont\n children(collectionTypes: [FAMILY]) {\n isVariableFont\n totalStyles\n id\n }\n collectionType\n featureStyle {\n ...FontStyle_fontStyle\n family {\n cssUrl\n id\n }\n id\n }\n}\n\nfragment useTotalStyles_fontCollection on FontCollection {\n totalStyles\n children(collectionTypes: [FAMILY]) {\n isVariableFont\n totalStyles\n id\n }\n}\n"
264
+ "text": "query StoreModalIndexQuery(\n $excludeTags: [String!]\n) {\n viewer {\n rootCollections: fontCollections(onlyRoots: true, first: 99, excludeTags: $excludeTags) {\n edges {\n node {\n id\n ...StoreModalIndexItem_fontCollection\n }\n }\n }\n id\n }\n}\n\nfragment FontStyle_fontStyle on FontStyle {\n cssFamily\n name\n}\n\nfragment StoreModalIndexItem_fontCollection on FontCollection {\n ...useTotalStyles_fontCollection\n id\n name\n totalStyles\n isVariableFont\n children(collectionTypes: [FAMILY]) {\n isVariableFont\n totalStyles\n id\n }\n collectionType\n featureStyle {\n ...FontStyle_fontStyle\n family {\n cssUrl\n id\n }\n id\n }\n}\n\nfragment useTotalStyles_fontCollection on FontCollection {\n totalStyles\n children(collectionTypes: [FAMILY]) {\n isVariableFont\n totalStyles\n id\n }\n}\n"
265
265
  }
266
266
  };
267
267
  }();
268
- node.hash = 'd1a037f0551211a8f93528d5bb6e39fa';
268
+ node.hash = '5eaa31564579fe1265790984a85d1a12';
269
269
  var _default = node;
270
270
  exports.default = _default;
@@ -39,6 +39,7 @@ const BuyButtonBase = _ref => {
39
39
  }, [dispatch, collection]);
40
40
  (0, _react.useEffect)(() => {
41
41
  if (!collection) return;
42
+ console.log(`Populating ${collection.id}`);
42
43
  // populate as soon as BuyButton mounts. this prepares the StoreModal
43
44
  // to be able to apply discounts as soon as the user clicks "BUY" on
44
45
  // a style. (this is necessary if the bundle price is <= single style price)
@@ -15,16 +15,15 @@ const StoreModalIndex = _ref => {
15
15
  let {
16
16
  prepared
17
17
  } = _ref;
18
- const data = (0, _reactRelay.usePreloadedQuery)(_StoreModalIndexQuery !== void 0 ? _StoreModalIndexQuery : (_StoreModalIndexQuery = require("../../__generated__/StoreModalIndexQuery.graphql"), _StoreModalIndexQuery.hash && _StoreModalIndexQuery.hash !== "d1a037f0551211a8f93528d5bb6e39fa" && 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);
18
+ const data = (0, _reactRelay.usePreloadedQuery)(_StoreModalIndexQuery !== void 0 ? _StoreModalIndexQuery : (_StoreModalIndexQuery = require("../../__generated__/StoreModalIndexQuery.graphql"), _StoreModalIndexQuery.hash && _StoreModalIndexQuery.hash !== "5eaa31564579fe1265790984a85d1a12" && 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);
19
19
  const viewer = data.viewer;
20
20
  const edges = (viewer === null || viewer === void 0 ? void 0 : (_viewer$rootCollectio = viewer.rootCollections) === null || _viewer$rootCollectio === void 0 ? void 0 : _viewer$rootCollectio.edges) ?? [];
21
21
  return /*#__PURE__*/_react.default.createElement(_StoreModalPageContainer.default, null, {
22
22
  title: 'All collections',
23
- body: edges.map(edge => {
24
- return /*#__PURE__*/_react.default.createElement(_StoreModalIndexItem.default, {
25
- collection: edge.node
26
- });
27
- })
23
+ body: edges.map(edge => /*#__PURE__*/_react.default.createElement(_StoreModalIndexItem.default, {
24
+ collection: edge.node,
25
+ key: edge.node.id
26
+ }))
28
27
  });
29
28
  };
30
29
  var _default = StoreModalIndex;
@@ -63,15 +63,9 @@ const StoreModalReview = _ref => {
63
63
  stripe = (0, _reactStripeJs.useStripe)();
64
64
  elements = (0, _reactStripeJs.useElements)();
65
65
  }
66
- if (!order) return null;
67
- if (order.completedWithCoupon) {
68
- return /*#__PURE__*/_react.default.createElement(_StoreModalDownload.default, {
69
- order: order
70
- });
71
- }
72
- const billingIdentity = order.billingIdentity;
73
- const lastShownTotal = (0, _react.useRef)((_order$total = order.total) === null || _order$total === void 0 ? void 0 : _order$total.amount);
66
+ const lastShownTotal = (0, _react.useRef)(order === null || order === void 0 ? void 0 : (_order$total = order.total) === null || _order$total === void 0 ? void 0 : _order$total.amount);
74
67
  const handleSubmit = () => {
68
+ if (!order) return;
75
69
  if (!billingIdentity) {
76
70
  console.error('No billing identity, required for payment');
77
71
  return;
@@ -159,6 +153,13 @@ const StoreModalReview = _ref => {
159
153
  route: 'checkout'
160
154
  });
161
155
  };
156
+ if (!order) return null;
157
+ if (order.completedWithCoupon) {
158
+ return /*#__PURE__*/_react.default.createElement(_StoreModalDownload.default, {
159
+ order: order
160
+ });
161
+ }
162
+ const billingIdentity = order.billingIdentity;
162
163
  return /*#__PURE__*/_react.default.createElement(_StoreModalPageContainer.default, null, {
163
164
  title: 'Review & pay',
164
165
  body: /*#__PURE__*/_react.default.createElement(_StoreModalReviewLayout.default, {
@@ -1,6 +1,3 @@
1
1
  import React from 'react';
2
- export interface RouteState {
3
- prepared: any;
4
- }
5
2
  declare const StoreModalRouter: React.FunctionComponent<{}>;
6
3
  export default StoreModalRouter;
@@ -5,26 +5,23 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
- var _StoreModalRouterContext = _interopRequireDefault(require("./StoreModalRouterContext"));
8
+ var _reactRedux = require("react-redux");
9
+ var _reactRelay = require("react-relay");
10
+ var _routes = _interopRequireDefault(require("./routes"));
9
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
12
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
11
13
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
12
14
  const StoreModalRouter = () => {
13
- const router = (0, _react.useContext)(_StoreModalRouterContext.default);
14
- const [routeEntry, setRouteEntry] = (0, _react.useState)(router.get());
15
- (0, _react.useEffect)(() => {
16
- const currentEntry = router.get();
17
- if (currentEntry !== routeEntry) {
18
- setRouteEntry(currentEntry);
19
- return;
20
- }
21
- const dispose = router.subscribe(entry => {
22
- setRouteEntry(entry);
23
- });
24
- return () => dispose();
25
- }, [router]);
26
- return /*#__PURE__*/_react.default.createElement(routeEntry.Component, {
27
- prepared: routeEntry.prepared
15
+ const environment = (0, _reactRelay.useRelayEnvironment)();
16
+ const currentRoute = (0, _reactRedux.useSelector)(state => state.storeModalRoute);
17
+ const route = _routes.default[currentRoute.name];
18
+ (0, _react.useEffect)(() => {}, [currentRoute]);
19
+ const prepared = (0, _react.useMemo)(() => {
20
+ // @ts-ignore
21
+ return _routes.default[currentRoute.name].prepare(currentRoute.variables, environment);
22
+ }, [currentRoute, environment]);
23
+ return /*#__PURE__*/_react.default.createElement(route.Component, {
24
+ prepared: prepared
28
25
  });
29
26
  };
30
27
  var _default = StoreModalRouter;
@@ -5,25 +5,16 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
- var _reactRedux = require("react-redux");
9
- var _reactRelay = require("react-relay");
10
8
  var _StoreModalLoader = _interopRequireDefault(require("./StoreModalLoader"));
11
9
  var _StoreModalContainer = _interopRequireDefault(require("./StoreModalContainer"));
12
10
  var _StoreModalRouter = _interopRequireDefault(require("./StoreModalRouter"));
13
- var _createRouter = _interopRequireDefault(require("./createRouter"));
14
- var _StoreModalRouterContext = _interopRequireDefault(require("./StoreModalRouterContext"));
15
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
12
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
13
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
18
14
  const StoreModal = () => {
19
- const store = (0, _reactRedux.useStore)();
20
- const environment = (0, _reactRelay.useRelayEnvironment)();
21
- const router = (0, _react.useRef)((0, _createRouter.default)(store, environment));
22
- return /*#__PURE__*/_react.default.createElement(_StoreModalLoader.default, null, /*#__PURE__*/_react.default.createElement(_StoreModalRouterContext.default.Provider, {
23
- value: router.current
24
- }, /*#__PURE__*/_react.default.createElement(_react.Suspense, {
15
+ return /*#__PURE__*/_react.default.createElement(_StoreModalLoader.default, null, /*#__PURE__*/_react.default.createElement(_react.Suspense, {
25
16
  fallback: null
26
- }, /*#__PURE__*/_react.default.createElement(_StoreModalContainer.default, null, /*#__PURE__*/_react.default.createElement(_StoreModalRouter.default, null)))));
17
+ }, /*#__PURE__*/_react.default.createElement(_StoreModalContainer.default, null, /*#__PURE__*/_react.default.createElement(_StoreModalRouter.default, null))));
27
18
  };
28
19
  var _default = StoreModal;
29
20
  exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fontdue-js",
3
- "version": "1.12.0",
3
+ "version": "1.12.2",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "build": "npm run relay && run-p build-js build-css build-ts-declarations",