fontdue-js 3.7.0 → 3.9.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 +11 -0
- package/README.md +8 -5
- 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__/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__/StoreModalCartQuery.graphql.d.ts +1 -1
- package/dist/__generated__/StoreModalCartQuery.graphql.js +37 -31
- package/dist/__generated__/StoreModalIndexPackItem_fontPack.graphql.d.ts +23 -0
- package/dist/__generated__/StoreModalIndexPackItem_fontPack.graphql.js +58 -0
- package/dist/__generated__/StoreModalIndexQuery.graphql.d.ts +9 -1
- package/dist/__generated__/StoreModalIndexQuery.graphql.js +174 -110
- 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 +3 -2
- package/dist/__generated__/StoreModalProductContent_collection.graphql.js +36 -19
- package/dist/__generated__/{StoreModalProductLicenseSelection_collection.graphql.d.ts → StoreModalProductLicenseSelection_licenseable.graphql.d.ts} +6 -6
- package/dist/__generated__/{StoreModalProductLicenseSelection_collection.graphql.js → StoreModalProductLicenseSelection_licenseable.graphql.js} +5 -5
- package/dist/__generated__/StoreModalProductQuery.graphql.d.ts +1 -1
- package/dist/__generated__/StoreModalProductQuery.graphql.js +159 -103
- package/dist/__generated__/StoreModalProductRefetchQuery.graphql.d.ts +1 -1
- package/dist/__generated__/StoreModalProductRefetchQuery.graphql.js +184 -128
- package/dist/__generated__/StoreModalProductSlugQuery.graphql.d.ts +5 -1
- package/dist/__generated__/StoreModalProductSlugQuery.graphql.js +248 -171
- 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__/TestFontsForm_Query.graphql.d.ts +14 -2
- package/dist/__generated__/TestFontsForm_Query.graphql.js +76 -18
- 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/__tests__/bundleSelectionOrder.test.js +2 -0
- package/dist/__tests__/collectionBundleSelection.test.js +2 -0
- package/dist/__tests__/fontPackSelection.test.js +435 -0
- package/dist/__tests__/licenseExclusions.test.js +2 -0
- 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__/testFontsFamilyChoice.test.js +150 -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/CollectionAa/index.js +2 -2
- package/dist/components/ConfigContext.d.ts +11 -0
- package/dist/components/ConfigContext.js +7 -1
- 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/Root/productState.js +57 -7
- package/dist/components/StoreModal/StoreModalFamily.d.ts +7 -0
- package/dist/components/StoreModal/StoreModalFamily.js +7 -5
- package/dist/components/StoreModal/StoreModalIndex.js +13 -3
- 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 +38 -15
- package/dist/components/StoreModalProductLicenseSelection/index.d.ts +3 -3
- package/dist/components/StoreModalProductLicenseSelection/index.js +6 -6
- package/dist/components/StoreModalProductSummary/index.js +1 -1
- package/dist/components/TestFontsForm/TestFontsFormElement.d.ts +4 -1
- package/dist/components/TestFontsForm/TestFontsFormElement.js +11 -3
- package/dist/components/TestFontsForm/index.d.ts +6 -3
- package/dist/components/TestFontsForm/index.js +82 -13
- package/dist/components/TestFontsForm/index.server.js +2 -1
- package/dist/components/TestFontsForm/variables.d.ts +8 -0
- package/dist/components/TestFontsForm/variables.js +22 -0
- package/dist/components/elements/StoreModalFamily/index.d.ts +1 -1
- package/dist/components/elements/StoreModalFamily/index.js +1 -1
- package/dist/fontdue.css +13 -0
- package/dist/reducer.d.ts +7 -0
- package/dist/reducer.js +9 -0
- package/dist/selection.d.ts +5 -1
- package/dist/selection.js +61 -16
- package/dist/storeModalRoutes.js +5 -4
- 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/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
|
}
|
|
@@ -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;
|
|
@@ -28,8 +28,13 @@ interface PreviewConfig {
|
|
|
28
28
|
revalidateEndpoint?: string;
|
|
29
29
|
clientSide?: boolean;
|
|
30
30
|
}
|
|
31
|
+
export type TestFontsFamilySelection = 'all' | 'choice';
|
|
32
|
+
interface TestFontsConfig {
|
|
33
|
+
familySelection?: TestFontsFamilySelection;
|
|
34
|
+
}
|
|
31
35
|
export interface Config {
|
|
32
36
|
form?: FormConfig;
|
|
37
|
+
testFonts?: TestFontsConfig;
|
|
33
38
|
storeModal?: StoreModalConfig;
|
|
34
39
|
typeTester?: TypeTesterConfig;
|
|
35
40
|
stripe?: StripeConfig;
|
|
@@ -94,6 +99,9 @@ export declare const makeConfig: (config?: Config) => {
|
|
|
94
99
|
form: {
|
|
95
100
|
checkboxStyle: "check" | "cross";
|
|
96
101
|
};
|
|
102
|
+
testFonts: {
|
|
103
|
+
familySelection: TestFontsFamilySelection | undefined;
|
|
104
|
+
};
|
|
97
105
|
storeModal: {
|
|
98
106
|
indexLayout: "styled-aa" | "styled-font-names";
|
|
99
107
|
indexExcludeTags: string[] | undefined;
|
|
@@ -172,6 +180,9 @@ declare const _default: React.Context<{
|
|
|
172
180
|
form: {
|
|
173
181
|
checkboxStyle: "check" | "cross";
|
|
174
182
|
};
|
|
183
|
+
testFonts: {
|
|
184
|
+
familySelection: TestFontsFamilySelection | undefined;
|
|
185
|
+
};
|
|
175
186
|
storeModal: {
|
|
176
187
|
indexLayout: "styled-aa" | "styled-font-names";
|
|
177
188
|
indexExcludeTags: string[] | undefined;
|
|
@@ -88,12 +88,18 @@ export const mergeConfig = (base, override) => {
|
|
|
88
88
|
return deepMerge(base, override);
|
|
89
89
|
};
|
|
90
90
|
export const makeConfig = config => {
|
|
91
|
-
var _config$form, _config$storeModal, _config$storeModal2, _config$storeModal3, _config$storeModal4, _config$stripe, _config$tracking, _config$tracking2, _config$tracking3, _config$tracking4, _config$preview, _config$preview2, _config$preview3;
|
|
91
|
+
var _config$form, _config$testFonts, _config$storeModal, _config$storeModal2, _config$storeModal3, _config$storeModal4, _config$stripe, _config$tracking, _config$tracking2, _config$tracking3, _config$tracking4, _config$preview, _config$preview2, _config$preview3;
|
|
92
92
|
return {
|
|
93
93
|
typeTester: makeTypeTesterConfig(config === null || config === void 0 ? void 0 : config.typeTester),
|
|
94
94
|
form: {
|
|
95
95
|
checkboxStyle: (config === null || config === void 0 ? void 0 : (_config$form = config.form) === null || _config$form === void 0 ? void 0 : _config$form.checkboxStyle) ?? 'check'
|
|
96
96
|
},
|
|
97
|
+
testFonts: {
|
|
98
|
+
// Deliberately no default: the form falls back to the dashboard setting
|
|
99
|
+
// it reads in its own query (the npm path never merges server config
|
|
100
|
+
// into `children`'s context – see ServerConfigProvider).
|
|
101
|
+
familySelection: config === null || config === void 0 ? void 0 : (_config$testFonts = config.testFonts) === null || _config$testFonts === void 0 ? void 0 : _config$testFonts.familySelection
|
|
102
|
+
},
|
|
97
103
|
storeModal: {
|
|
98
104
|
indexLayout: (config === null || config === void 0 ? void 0 : (_config$storeModal = config.storeModal) === null || _config$storeModal === void 0 ? void 0 : _config$storeModal.indexLayout) ?? 'styled-aa',
|
|
99
105
|
indexExcludeTags: config === null || config === void 0 ? void 0 : (_config$storeModal2 = config.storeModal) === null || _config$storeModal2 === void 0 ? void 0 : _config$storeModal2.indexExcludeTags,
|
|
@@ -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;
|
|
@@ -1,6 +1,7 @@
|
|
|
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 _NodePasswordFormElementPackSlugQuery from "../../__generated__/NodePasswordFormElementPackSlugQuery.graphql.js";
|
|
4
5
|
import _NodePasswordFormElementSlugQuery from "../../__generated__/NodePasswordFormElementSlugQuery.graphql.js";
|
|
5
6
|
import _NodePasswordFormElementIDQuery from "../../__generated__/NodePasswordFormElementIDQuery.graphql.js";
|
|
6
7
|
import React from 'react';
|
|
@@ -8,25 +9,25 @@ import { graphql, useLazyLoadQuery } from 'react-relay';
|
|
|
8
9
|
import NodePasswordForm from './index.js';
|
|
9
10
|
// Auto-detecting wrapper behind the <fontdue-node-password-form> custom element.
|
|
10
11
|
// Unlike the presentational React component (the default export of ./index, used
|
|
11
|
-
// when the server has already detected the lock), this queries the
|
|
12
|
-
//
|
|
13
|
-
// onto any page, hiding itself for a visitor who
|
|
12
|
+
// when the server has already detected the lock), this queries the product itself
|
|
13
|
+
// – a collection or a font pack – and renders the form only when access is
|
|
14
|
+
// denied, so it works dropped onto any page, hiding itself for a visitor who
|
|
15
|
+
// already has access.
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
// `node(id:)` resolves a collection and a pack alike, so one query serves both.
|
|
18
|
+
const idQuery = (_NodePasswordFormElementIDQuery.hash && _NodePasswordFormElementIDQuery.hash !== "fa35f237c6ea919a7afbe22c86ca19b5" && console.error("The definition of 'NodePasswordFormElementIDQuery' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _NodePasswordFormElementIDQuery);
|
|
16
19
|
function NodePasswordFormIDQueryRenderer(_ref) {
|
|
17
20
|
let {
|
|
18
|
-
|
|
19
|
-
...
|
|
21
|
+
nodeId,
|
|
22
|
+
...props
|
|
20
23
|
} = _ref;
|
|
21
24
|
const data = useLazyLoadQuery(idQuery, {
|
|
22
|
-
|
|
25
|
+
nodeId
|
|
23
26
|
});
|
|
24
27
|
// The @catch directive surfaces the password-protection error as ok:false; the
|
|
25
28
|
// node is only locked then, so only then do we render the form (we don't want
|
|
26
29
|
// to show it to a visitor who already has access).
|
|
27
|
-
if (data.
|
|
28
|
-
collectionId: collectionId
|
|
29
|
-
}));
|
|
30
|
+
if (data.node.ok === false) return /*#__PURE__*/React.createElement(NodePasswordForm, props);
|
|
30
31
|
return null;
|
|
31
32
|
}
|
|
32
33
|
const slugQuery = (_NodePasswordFormElementSlugQuery.hash && _NodePasswordFormElementSlugQuery.hash !== "200a33ca6a1f9e4e7e95b7100bbdd261" && console.error("The definition of 'NodePasswordFormElementSlugQuery' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _NodePasswordFormElementSlugQuery);
|
|
@@ -34,32 +35,55 @@ function NodePasswordFormSlugQueryRenderer(_ref2) {
|
|
|
34
35
|
var _data$viewer$slug;
|
|
35
36
|
let {
|
|
36
37
|
collectionSlug,
|
|
37
|
-
...
|
|
38
|
+
...props
|
|
38
39
|
} = _ref2;
|
|
39
40
|
const data = useLazyLoadQuery(slugQuery, {
|
|
40
41
|
collectionSlug
|
|
41
42
|
});
|
|
42
43
|
// see note in NodePasswordFormIDQueryRenderer
|
|
43
|
-
if (((_data$viewer$slug = data.viewer.slug) === null || _data$viewer$slug === void 0 ? void 0 : _data$viewer$slug.collection.ok) === false) return /*#__PURE__*/React.createElement(NodePasswordForm, _extends({},
|
|
44
|
+
if (((_data$viewer$slug = data.viewer.slug) === null || _data$viewer$slug === void 0 ? void 0 : _data$viewer$slug.collection.ok) === false) return /*#__PURE__*/React.createElement(NodePasswordForm, _extends({}, props, {
|
|
44
45
|
collectionSlug: collectionSlug
|
|
45
46
|
}));
|
|
46
47
|
return null;
|
|
47
48
|
}
|
|
48
|
-
|
|
49
|
+
const packSlugQuery = (_NodePasswordFormElementPackSlugQuery.hash && _NodePasswordFormElementPackSlugQuery.hash !== "3186720cb9ad751d233e995a102efcd1" && console.error("The definition of 'NodePasswordFormElementPackSlugQuery' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _NodePasswordFormElementPackSlugQuery);
|
|
50
|
+
function NodePasswordFormPackSlugQueryRenderer(_ref3) {
|
|
51
|
+
var _data$viewer$slug2;
|
|
49
52
|
let {
|
|
53
|
+
fontPackSlug,
|
|
54
|
+
...props
|
|
55
|
+
} = _ref3;
|
|
56
|
+
const data = useLazyLoadQuery(packSlugQuery, {
|
|
57
|
+
fontPackSlug
|
|
58
|
+
});
|
|
59
|
+
// see note in NodePasswordFormIDQueryRenderer
|
|
60
|
+
if (((_data$viewer$slug2 = data.viewer.slug) === null || _data$viewer$slug2 === void 0 ? void 0 : _data$viewer$slug2.pack.ok) === false) return /*#__PURE__*/React.createElement(NodePasswordForm, _extends({}, props, {
|
|
61
|
+
fontPackSlug: fontPackSlug
|
|
62
|
+
}));
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
export default function NodePasswordFormElement(props) {
|
|
66
|
+
const {
|
|
50
67
|
collectionId,
|
|
51
68
|
collectionSlug,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
69
|
+
fontPackId,
|
|
70
|
+
fontPackSlug
|
|
71
|
+
} = props;
|
|
72
|
+
const nodeId = collectionId || fontPackId;
|
|
73
|
+
if (nodeId) {
|
|
55
74
|
return /*#__PURE__*/React.createElement(NodePasswordFormIDQueryRenderer, _extends({
|
|
56
|
-
|
|
57
|
-
},
|
|
75
|
+
nodeId: nodeId
|
|
76
|
+
}, props));
|
|
58
77
|
}
|
|
59
78
|
if (collectionSlug) {
|
|
60
|
-
return /*#__PURE__*/React.createElement(NodePasswordFormSlugQueryRenderer, _extends({
|
|
79
|
+
return /*#__PURE__*/React.createElement(NodePasswordFormSlugQueryRenderer, _extends({}, props, {
|
|
61
80
|
collectionSlug: collectionSlug
|
|
62
|
-
}
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
if (fontPackSlug) {
|
|
84
|
+
return /*#__PURE__*/React.createElement(NodePasswordFormPackSlugQueryRenderer, _extends({}, props, {
|
|
85
|
+
fontPackSlug: fontPackSlug
|
|
86
|
+
}));
|
|
63
87
|
}
|
|
64
|
-
throw new Error('NodePasswordForm expected
|
|
88
|
+
throw new Error('NodePasswordForm expected a collectionId, collectionSlug, fontPackId or fontPackSlug prop');
|
|
65
89
|
}
|
|
@@ -2,6 +2,9 @@ import React from 'react';
|
|
|
2
2
|
export interface NodePasswordForm_props {
|
|
3
3
|
collectionId?: string | null;
|
|
4
4
|
collectionSlug?: string | null;
|
|
5
|
+
/** A font pack's identifiers, in place of the collection ones. */
|
|
6
|
+
fontPackId?: string | null;
|
|
7
|
+
fontPackSlug?: string | null;
|
|
5
8
|
/**
|
|
6
9
|
* Path of the storefront's unlock route (see fontdue-js/next/unlock), e.g.
|
|
7
10
|
* "/api/unlock". On a successful unlock the form POSTs `{ token }` there
|
|
@@ -15,10 +18,10 @@ export interface NodePasswordForm_props {
|
|
|
15
18
|
unlockEndpoint?: string | null;
|
|
16
19
|
}
|
|
17
20
|
/**
|
|
18
|
-
* Password form for a collection you already know is locked.
|
|
19
|
-
*
|
|
20
|
-
* commits the `accessNode` mutation, remembers the
|
|
21
|
-
* reloads so the now-unlocked
|
|
21
|
+
* Password form for a collection or font pack you already know is locked.
|
|
22
|
+
* Render it when the product comes back password-protected (see the
|
|
23
|
+
* per-framework guides): it commits the `accessNode` mutation, remembers the
|
|
24
|
+
* returned access token, and reloads so the now-unlocked product renders.
|
|
22
25
|
*
|
|
23
26
|
* Unlike the `<fontdue-node-password-form>` custom element (which detects the
|
|
24
27
|
* locked state itself), this does no data fetching of its own, so it renders
|
|
@@ -8,10 +8,10 @@ import { EnsureFontdueContext } from '../FontdueContextProvider/index.js';
|
|
|
8
8
|
import { rememberNodeAccessToken } from '../../nodeAccess.js';
|
|
9
9
|
const accessNodeMutation = (_NodePasswordFormAccessNodeMutation.hash && _NodePasswordFormAccessNodeMutation.hash !== "eb0d3828d65a52c727ef60caa67709a1" && console.error("The definition of 'NodePasswordFormAccessNodeMutation' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _NodePasswordFormAccessNodeMutation);
|
|
10
10
|
/**
|
|
11
|
-
* Password form for a collection you already know is locked.
|
|
12
|
-
*
|
|
13
|
-
* commits the `accessNode` mutation, remembers the
|
|
14
|
-
* reloads so the now-unlocked
|
|
11
|
+
* Password form for a collection or font pack you already know is locked.
|
|
12
|
+
* Render it when the product comes back password-protected (see the
|
|
13
|
+
* per-framework guides): it commits the `accessNode` mutation, remembers the
|
|
14
|
+
* returned access token, and reloads so the now-unlocked product renders.
|
|
15
15
|
*
|
|
16
16
|
* Unlike the `<fontdue-node-password-form>` custom element (which detects the
|
|
17
17
|
* locked state itself), this does no data fetching of its own, so it renders
|
|
@@ -65,8 +65,8 @@ function NodePasswordFormFields(props) {
|
|
|
65
65
|
variables: {
|
|
66
66
|
input: {
|
|
67
67
|
password,
|
|
68
|
-
id: props.collectionId,
|
|
69
|
-
slug: props.collectionSlug
|
|
68
|
+
id: props.collectionId || props.fontPackId || undefined,
|
|
69
|
+
slug: props.collectionSlug || props.fontPackSlug || undefined
|
|
70
70
|
}
|
|
71
71
|
},
|
|
72
72
|
onCompleted: res => {
|