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