fontdue-js 3.14.0 → 3.15.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 +9 -0
- package/dist/__generated__/CartOrderCompleteOrderMutation.graphql.d.ts +1 -1
- package/dist/__generated__/CartOrderCompleteOrderMutation.graphql.js +3 -3
- package/dist/__generated__/CartOrderRemoveDiscountMutation.graphql.d.ts +1 -1
- package/dist/__generated__/CartOrderRemoveDiscountMutation.graphql.js +3 -3
- package/dist/__generated__/CartOrderUpdateMutation.graphql.d.ts +1 -1
- package/dist/__generated__/CartOrderUpdateMutation.graphql.js +3 -3
- package/dist/__generated__/CartQuery.graphql.d.ts +1 -1
- package/dist/__generated__/CartQuery.graphql.js +3 -3
- package/dist/__generated__/CartStateUpdateMutation.graphql.d.ts +5 -1
- package/dist/__generated__/CartStateUpdateMutation.graphql.js +132 -117
- package/dist/__generated__/CartState_order.graphql.d.ts +4 -1
- package/dist/__generated__/CartState_order.graphql.js +11 -2
- package/dist/__generated__/CheckoutUpdateCustomerMutation.graphql.d.ts +1 -1
- package/dist/__generated__/CheckoutUpdateCustomerMutation.graphql.js +3 -3
- package/dist/__generated__/CheckoutUpdateOrderMutation.graphql.d.ts +1 -1
- package/dist/__generated__/CheckoutUpdateOrderMutation.graphql.js +3 -3
- package/dist/__generated__/FamilyList_node.graphql.d.ts +3 -1
- package/dist/__generated__/FamilyList_node.graphql.js +8 -2
- package/dist/__generated__/FontFamiliesQuery.graphql.d.ts +1 -1
- package/dist/__generated__/FontFamiliesQuery.graphql.js +5 -5
- package/dist/__generated__/PrecartAddToCartMutation.graphql.d.ts +1 -1
- package/dist/__generated__/PrecartAddToCartMutation.graphql.js +3 -3
- package/dist/__generated__/StoreModalCartQuery.graphql.d.ts +1 -1
- package/dist/__generated__/StoreModalCartQuery.graphql.js +69 -69
- package/dist/__generated__/StoreModalFamily_collection.graphql.d.ts +2 -1
- package/dist/__generated__/StoreModalFamily_collection.graphql.js +16 -15
- package/dist/__generated__/StoreModalIndexItem_fontCollection.graphql.d.ts +19 -1
- package/dist/__generated__/StoreModalIndexItem_fontCollection.graphql.js +39 -4
- package/dist/__generated__/StoreModalIndexPaginationQuery.graphql.d.ts +1 -1
- package/dist/__generated__/StoreModalIndexPaginationQuery.graphql.js +40 -5
- package/dist/__generated__/StoreModalIndexQuery.graphql.d.ts +1 -1
- package/dist/__generated__/StoreModalIndexQuery.graphql.js +40 -5
- package/dist/__generated__/StoreModalProductContent_collection.graphql.d.ts +19 -1
- package/dist/__generated__/StoreModalProductContent_collection.graphql.js +46 -11
- package/dist/__generated__/StoreModalProductQuery.graphql.d.ts +1 -1
- package/dist/__generated__/StoreModalProductQuery.graphql.js +198 -167
- package/dist/__generated__/StoreModalProductRefetchQuery.graphql.d.ts +1 -1
- package/dist/__generated__/StoreModalProductRefetchQuery.graphql.js +171 -140
- package/dist/__generated__/StoreModalProductSlugQuery.graphql.d.ts +1 -1
- package/dist/__generated__/StoreModalProductSlugQuery.graphql.js +201 -170
- package/dist/__generated__/StripeProviderCreateCheckoutSessionMutation.graphql.d.ts +5 -2
- package/dist/__generated__/StripeProviderCreateCheckoutSessionMutation.graphql.js +41 -22
- package/dist/__generated__/TestFontsFormUpdateCustomerMutation.graphql.d.ts +1 -1
- package/dist/__generated__/TestFontsFormUpdateCustomerMutation.graphql.js +3 -3
- package/dist/__generated__/TypeTesterStandaloneChangedStylesQuery.graphql.d.ts +1 -1
- package/dist/__generated__/TypeTesterStandaloneChangedStylesQuery.graphql.js +9 -3
- package/dist/__generated__/TypeTesterStandaloneQuery.graphql.d.ts +1 -1
- package/dist/__generated__/TypeTesterStandaloneQuery.graphql.js +9 -3
- package/dist/__generated__/TypeTester_fontStyle.graphql.d.ts +3 -1
- package/dist/__generated__/TypeTester_fontStyle.graphql.js +8 -2
- package/dist/__generated__/TypeTestersChangedStylesQuery.graphql.d.ts +1 -1
- package/dist/__generated__/TypeTestersChangedStylesQuery.graphql.js +9 -3
- package/dist/__generated__/TypeTestersIDQuery.graphql.d.ts +1 -1
- package/dist/__generated__/TypeTestersIDQuery.graphql.js +39 -39
- package/dist/__generated__/TypeTestersRefetchQuery.graphql.d.ts +1 -1
- package/dist/__generated__/TypeTestersRefetchQuery.graphql.js +37 -37
- package/dist/__generated__/TypeTestersSlugQuery.graphql.d.ts +1 -1
- package/dist/__generated__/TypeTestersSlugQuery.graphql.js +39 -39
- package/dist/__tests__/cartDiscountRemoved.test.js +195 -0
- package/dist/__tests__/characterViewerCollapse.test.js +199 -0
- package/dist/__tests__/characterViewerStyleSelect.test.js +52 -0
- package/dist/__tests__/checkoutReturn.test.js +66 -0
- package/dist/__tests__/familyStyleCounts.test.js +71 -0
- package/dist/__tests__/i18n.test.js +171 -0
- package/dist/__tests__/i18nComponents.test.js +408 -0
- package/dist/__tests__/localeEnvironments.test.js +275 -0
- package/dist/__tests__/localeMiddleware.test.js +68 -0
- package/dist/__tests__/localeTransport.test.js +209 -0
- package/dist/__tests__/recaptchaLocale.test.js +62 -0
- package/dist/__tests__/serverEntryLocale.test.js +124 -0
- package/dist/__tests__/storeModalIndexUnlisted.test.js +69 -11
- package/dist/__tests__/useSerializablePreloadedQuery.test.js +4 -3
- package/dist/components/AddToCartBanner/index.js +8 -2
- package/dist/components/BuyButton/index.d.ts +1 -0
- package/dist/components/BuyButton/index.js +8 -2
- package/dist/components/BuyButton/index.server.d.ts +1 -0
- package/dist/components/BuyButton/index.server.js +8 -0
- package/dist/components/BuyingOptions/index.js +3 -1
- package/dist/components/Cart/AddressFields.js +5 -3
- package/dist/components/Cart/CartCouponNotice.d.ts +7 -0
- package/dist/components/Cart/CartCouponNotice.js +21 -0
- package/dist/components/Cart/CartItem/CartItemAdditionalLicenses.js +3 -1
- package/dist/components/Cart/CartItem/CartItemLicense.js +3 -1
- package/dist/components/Cart/CartItem/CartItemProduct.js +6 -3
- package/dist/components/Cart/CartItem/VariableTextInput.js +7 -3
- package/dist/components/Cart/CartItem/index.js +5 -1
- package/dist/components/Cart/CartOrder.js +27 -17
- package/dist/components/Cart/CartState.d.ts +1 -0
- package/dist/components/Cart/CartState.js +18 -3
- package/dist/components/Cart/CartTotals.js +17 -9
- package/dist/components/Cart/Checkout.js +18 -15
- package/dist/components/Cart/CouponCodeInput.js +5 -3
- package/dist/components/Cart/CustomerFields.js +6 -4
- package/dist/components/Cart/EmptyCart.js +4 -2
- package/dist/components/Cart/IdentityBox.js +6 -2
- package/dist/components/Cart/ShareCart.js +8 -6
- package/dist/components/Cart/checkoutReturn.d.ts +17 -0
- package/dist/components/Cart/checkoutReturn.js +38 -0
- package/dist/components/CartButton/index.d.ts +2 -1
- package/dist/components/CartButton/index.js +6 -2
- package/dist/components/CharacterViewer/StyleSelect.js +6 -2
- package/dist/components/CharacterViewer/collapse.d.ts +10 -0
- package/dist/components/CharacterViewer/collapse.js +39 -0
- package/dist/components/CharacterViewer/index.d.ts +4 -0
- package/dist/components/CharacterViewer/index.js +78 -24
- package/dist/components/CharacterViewer/index.server.d.ts +1 -0
- package/dist/components/CharacterViewer/index.server.js +4 -0
- package/dist/components/ConfigContext.d.ts +14 -10
- package/dist/components/ConfigContext.js +12 -7
- package/dist/components/ConsentBanner/index.js +6 -5
- package/dist/components/CookieNotification/index.js +11 -5
- package/dist/components/CouponText/index.js +15 -7
- package/dist/components/CustomerLoginForm/index.js +14 -9
- package/dist/components/CustomerSignIn/CustomerSignInElement.d.ts +1 -1
- package/dist/components/CustomerSignIn/CustomerSignInElement.js +8 -2
- package/dist/components/CustomerSignIn/index.d.ts +6 -1
- package/dist/components/CustomerSignIn/index.js +27 -15
- package/dist/components/Family/FamilyList.js +5 -2
- package/dist/components/Family/index.js +21 -12
- package/dist/components/FeatureTester/FeatureTesters.d.ts +2 -1
- package/dist/components/FeatureTester/FeatureTesters.js +4 -1
- package/dist/components/FeatureTester/FeatureTesters.server.js +4 -0
- package/dist/components/FeatureTester/index.d.ts +1 -0
- package/dist/components/FeatureTester/index.js +3 -1
- package/dist/components/FeatureTester/index.server.js +2 -0
- package/dist/components/FontdueContextProvider/index.d.ts +12 -2
- package/dist/components/FontdueContextProvider/index.js +85 -11
- package/dist/components/FontdueProvider/index.js +7 -1
- package/dist/components/FontdueProvider/index.server.js +21 -3
- package/dist/components/LocaleContext.d.ts +9 -0
- package/dist/components/LocaleContext.js +20 -0
- package/dist/components/NewsletterSignup/index.d.ts +2 -1
- package/dist/components/NewsletterSignup/index.js +20 -11
- package/dist/components/NewsletterSignup/index.server.d.ts +1 -0
- package/dist/components/NewsletterSignup/index.server.js +3 -1
- package/dist/components/NodePasswordForm/index.d.ts +6 -1
- package/dist/components/NodePasswordForm/index.js +14 -6
- package/dist/components/OrderVariableSelection/index.js +7 -5
- package/dist/components/Precart/License.js +4 -2
- package/dist/components/Precart/index.js +15 -12
- package/dist/components/Price/index.d.ts +1 -0
- package/dist/components/Price/index.js +15 -5
- package/dist/components/Root/index.js +2 -1
- package/dist/components/Select/index.d.ts +1 -1
- package/dist/components/Select/index.js +4 -1
- package/dist/components/SelectButton/index.js +3 -1
- package/dist/components/SpecimenLink/index.js +3 -1
- package/dist/components/StoreModal/StoreModalCart.js +6 -0
- package/dist/components/StoreModal/StoreModalContainer.js +14 -12
- package/dist/components/StoreModal/StoreModalDownload.js +3 -1
- package/dist/components/StoreModal/StoreModalFamily.js +16 -7
- package/dist/components/StoreModal/StoreModalFamilyButton.js +14 -9
- package/dist/components/StoreModal/StoreModalIndexItem.js +21 -10
- package/dist/components/StoreModal/StoreModalIndexPackItem.js +8 -3
- package/dist/components/StoreModal/StoreModalPackButton.js +5 -2
- package/dist/components/StoreModal/StoreModalProduct.js +14 -5
- package/dist/components/StoreModal/index.d.ts +1 -0
- package/dist/components/StoreModal/index.js +4 -2
- package/dist/components/StoreModal/offered.d.ts +31 -0
- package/dist/components/StoreModal/offered.js +21 -0
- package/dist/components/StoreModal/types.d.ts +9 -0
- package/dist/components/StoreModalProductLicenseSelection/LicenseVariableElement.js +3 -1
- package/dist/components/StoreModalProductLicenseSelection/StoreModalProductLicense.js +5 -1
- package/dist/components/StoreModalProductSummary/index.js +37 -23
- package/dist/components/StripeProvider/index.js +18 -5
- package/dist/components/TestFontsForm/index.d.ts +2 -1
- package/dist/components/TestFontsForm/index.js +28 -16
- package/dist/components/TestFontsForm/index.server.d.ts +1 -0
- package/dist/components/TestFontsForm/index.server.js +3 -1
- package/dist/components/TestModeBanner/index.js +3 -1
- package/dist/components/TypeTester/TypeTesterEditAll.js +3 -1
- package/dist/components/TypeTester/TypeTesterFeaturesButton.js +4 -2
- package/dist/components/TypeTester/TypeTesterStandalone.d.ts +1 -0
- package/dist/components/TypeTester/TypeTesterStandalone.js +6 -2
- package/dist/components/TypeTester/TypeTesterStandalone.server.js +2 -0
- package/dist/components/TypeTester/TypeTesterStyleSelect.js +5 -3
- package/dist/components/TypeTester/TypeTesterStyleSelectData.js +3 -1
- package/dist/components/TypeTester/TypeTesterToolbar.js +12 -6
- package/dist/components/TypeTester/index.js +7 -2
- package/dist/components/TypeTesters/index.d.ts +2 -1
- package/dist/components/TypeTesters/index.js +3 -1
- package/dist/components/TypeTesters/index.server.d.ts +1 -0
- package/dist/components/TypeTesters/index.server.js +4 -0
- package/dist/components/elements/EmptyCart/index.js +4 -2
- package/dist/components/elements/StoreModalCartLayout/index.d.ts +1 -0
- package/dist/components/elements/StoreModalCartLayout/index.js +2 -1
- package/dist/components/elements/StoreModalContainer/index.js +4 -2
- package/dist/components/elements/StoreModalDownloadLayout/index.js +3 -1
- package/dist/components/elements/StoreModalIndexItem/index.js +3 -1
- package/dist/components/elements/StoreModalIndexLoadMore/index.js +3 -1
- package/dist/components/elements/StoreModalLicenseeIsBillingIdentityElement.js +4 -2
- package/dist/components/elements/StoreModalLoadingScreen/index.js +7 -3
- package/dist/components/elements/StoreModalUnifiedCheckout.js +44 -27
- package/dist/fontdue.css +58 -0
- package/dist/hooks/useRecaptchaTimeout.d.ts +1 -1
- package/dist/hooks/useRecaptchaTimeout.js +4 -2
- package/dist/i18n/de.d.ts +3 -0
- package/dist/i18n/de.js +279 -0
- package/dist/i18n/en.d.ts +212 -0
- package/dist/i18n/en.js +261 -0
- package/dist/i18n/index.d.ts +42 -0
- package/dist/i18n/index.js +115 -0
- package/dist/i18n/types.d.ts +28 -0
- package/dist/i18n/types.js +1 -0
- package/dist/i18n/useT.d.ts +15 -0
- package/dist/i18n/useT.js +21 -0
- package/dist/locale.d.ts +20 -0
- package/dist/locale.js +52 -0
- package/dist/next/tenant.d.ts +3 -1
- package/dist/next/tenant.js +11 -2
- package/dist/relay/environment.d.ts +8 -2
- package/dist/relay/environment.js +65 -15
- package/dist/relay/loadSerializableQuery.d.ts +17 -0
- package/dist/relay/loadSerializableQuery.js +14 -2
- package/dist/relay/serverConfig.d.ts +9 -0
- package/dist/relay/serverConfig.js +16 -0
- package/dist/relay/useSerializablePreloadedQuery.js +27 -6
- package/dist/server/index.d.ts +11 -0
- package/dist/server/index.js +7 -0
- package/dist/server/middleware.d.ts +19 -1
- package/dist/server/middleware.js +56 -13
- package/dist/utils.d.ts +0 -1
- package/dist/utils.js +0 -5
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -16,6 +16,7 @@ import { useElements, useStripe } from '@stripe/react-stripe-js';
|
|
|
16
16
|
import ConfigContext from '../ConfigContext.js';
|
|
17
17
|
import { parseCustomProperties } from '../../utils.js';
|
|
18
18
|
import { validateAddressElements } from '../../stripeElements.js';
|
|
19
|
+
import { useT } from '../../i18n/useT.js';
|
|
19
20
|
const MOBILE = 'mobile';
|
|
20
21
|
const DESKTOP = 'desktop';
|
|
21
22
|
|
|
@@ -35,10 +36,12 @@ const Checkout = _ref => {
|
|
|
35
36
|
onScrollToTop,
|
|
36
37
|
onComplete,
|
|
37
38
|
error: errorProp,
|
|
38
|
-
saveText
|
|
39
|
+
saveText,
|
|
39
40
|
onCancel,
|
|
40
41
|
skipPaymentMethod = false
|
|
41
42
|
} = _ref;
|
|
43
|
+
const t = useT();
|
|
44
|
+
const saveLabel = saveText === undefined ? t('common.next') : saveText;
|
|
42
45
|
const orderData = useFragment((_Checkout_order.hash && _Checkout_order.hash !== "693ae9c7f2c7fe9a179bad7b86c16928" && console.error("The definition of 'Checkout_order' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _Checkout_order), order);
|
|
43
46
|
const viewerData = useFragment((_Checkout_viewer.hash && _Checkout_viewer.hash !== "be63ce5562013aa6a1439e6259c80e2f" && console.error("The definition of 'Checkout_viewer' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _Checkout_viewer), viewer);
|
|
44
47
|
const identity = {
|
|
@@ -230,7 +233,7 @@ const Checkout = _ref => {
|
|
|
230
233
|
error
|
|
231
234
|
} = _ref2;
|
|
232
235
|
if (error) {
|
|
233
|
-
setError((error === null || error === void 0 ? void 0 : error.message) ?? '
|
|
236
|
+
setError((error === null || error === void 0 ? void 0 : error.message) ?? t('checkout.unknownStripeError'));
|
|
234
237
|
setSubmitting(false);
|
|
235
238
|
} else {
|
|
236
239
|
if (paymentMethod) {
|
|
@@ -311,7 +314,7 @@ const Checkout = _ref => {
|
|
|
311
314
|
if (errorsObject) {
|
|
312
315
|
return /*#__PURE__*/React.createElement("div", {
|
|
313
316
|
className: "checkout-modal__errors"
|
|
314
|
-
},
|
|
317
|
+
}, t('checkout.correctErrors'));
|
|
315
318
|
}
|
|
316
319
|
if (!error && !errorProp) {
|
|
317
320
|
return null;
|
|
@@ -350,7 +353,7 @@ const Checkout = _ref => {
|
|
|
350
353
|
if (checkoutStep === CheckoutSteps.Customer) {
|
|
351
354
|
var _viewerData$settings2;
|
|
352
355
|
return /*#__PURE__*/React.createElement(CustomerFields, {
|
|
353
|
-
title:
|
|
356
|
+
title: t('cart.contactInformation'),
|
|
354
357
|
value: customer,
|
|
355
358
|
onChange: handleCustomerChange,
|
|
356
359
|
optInLabel: (_viewerData$settings2 = viewerData.settings) === null || _viewerData$settings2 === void 0 ? void 0 : _viewerData$settings2.newsletterOptInLabel,
|
|
@@ -365,7 +368,7 @@ const Checkout = _ref => {
|
|
|
365
368
|
className: "checkout-modal__customer-info__button",
|
|
366
369
|
onClick: () => setCheckoutStep(CheckoutSteps.Customer),
|
|
367
370
|
type: "button"
|
|
368
|
-
}, /*#__PURE__*/React.createElement(User, null), "
|
|
371
|
+
}, /*#__PURE__*/React.createElement(User, null), " ", t('cart.contactInformation'), ' ', /*#__PURE__*/React.createElement("span", {
|
|
369
372
|
className: "checkout-modal__customer-info__check"
|
|
370
373
|
}, /*#__PURE__*/React.createElement(Check, null)))));
|
|
371
374
|
if (checkoutStep === CheckoutSteps.Billing) {
|
|
@@ -375,7 +378,7 @@ const Checkout = _ref => {
|
|
|
375
378
|
className: "checkout-modal__header"
|
|
376
379
|
}, /*#__PURE__*/React.createElement("div", {
|
|
377
380
|
className: "checkout-modal__customer-info-message"
|
|
378
|
-
}, /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement(Receipt, null), "
|
|
381
|
+
}, /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement(Receipt, null), " ", t('cart.billingInformation'))))), /*#__PURE__*/React.createElement(AddressFields, {
|
|
379
382
|
viewer: viewerData,
|
|
380
383
|
value: billingIdentity,
|
|
381
384
|
onChange: handleBillingChange,
|
|
@@ -391,7 +394,7 @@ const Checkout = _ref => {
|
|
|
391
394
|
className: "checkout-modal__customer-info__button",
|
|
392
395
|
onClick: () => setCheckoutStep(CheckoutSteps.Billing),
|
|
393
396
|
type: "button"
|
|
394
|
-
}, /*#__PURE__*/React.createElement(Receipt, null), "
|
|
397
|
+
}, /*#__PURE__*/React.createElement(Receipt, null), " ", t('cart.billingInformation'), ' ', /*#__PURE__*/React.createElement("span", {
|
|
395
398
|
className: "checkout-modal__customer-info__check"
|
|
396
399
|
}, /*#__PURE__*/React.createElement(Check, null)))));
|
|
397
400
|
if (checkoutStep === CheckoutSteps.Licensee) {
|
|
@@ -402,7 +405,7 @@ const Checkout = _ref => {
|
|
|
402
405
|
className: "checkout-modal__header"
|
|
403
406
|
}, /*#__PURE__*/React.createElement("div", {
|
|
404
407
|
className: "checkout-modal__customer-info-message"
|
|
405
|
-
}, /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement(License, null), "
|
|
408
|
+
}, /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement(License, null), " ", t('cart.licenseeInformation'))))), /*#__PURE__*/React.createElement("div", {
|
|
406
409
|
className: "checkout-modal__checkbox-field"
|
|
407
410
|
}, /*#__PURE__*/React.createElement("div", {
|
|
408
411
|
className: "checkbox"
|
|
@@ -415,7 +418,7 @@ const Checkout = _ref => {
|
|
|
415
418
|
className: "checkbox__icon"
|
|
416
419
|
}, ((_config$form = config.form) === null || _config$form === void 0 ? void 0 : _config$form.checkboxStyle) === 'check' ? /*#__PURE__*/React.createElement(Check, null) : /*#__PURE__*/React.createElement(X, null))), /*#__PURE__*/React.createElement("label", {
|
|
417
420
|
htmlFor: "licensee-is-billing-identity"
|
|
418
|
-
},
|
|
421
|
+
}, t('checkout.sameBillingDetailsForLicensee'))), licenseeIsBillingIdentity === false && /*#__PURE__*/React.createElement(AddressFields, {
|
|
419
422
|
viewer: viewerData,
|
|
420
423
|
value: licenseeIdentity,
|
|
421
424
|
onChange: handleLicenseeChange,
|
|
@@ -431,7 +434,7 @@ const Checkout = _ref => {
|
|
|
431
434
|
className: "checkout-modal__customer-info__button",
|
|
432
435
|
onClick: () => setCheckoutStep(CheckoutSteps.Licensee),
|
|
433
436
|
type: "button"
|
|
434
|
-
}, /*#__PURE__*/React.createElement(License, null), "
|
|
437
|
+
}, /*#__PURE__*/React.createElement(License, null), " ", t('cart.licenseeInformation'), ' ', /*#__PURE__*/React.createElement("span", {
|
|
435
438
|
className: "checkout-modal__customer-info__check"
|
|
436
439
|
}, /*#__PURE__*/React.createElement(Check, null)))));
|
|
437
440
|
if (checkoutStep === CheckoutSteps.Payment) {
|
|
@@ -441,15 +444,15 @@ const Checkout = _ref => {
|
|
|
441
444
|
className: "checkout-modal__header"
|
|
442
445
|
}, /*#__PURE__*/React.createElement("div", {
|
|
443
446
|
className: "checkout-modal__customer-info-message"
|
|
444
|
-
}, /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement(CreditCard, null), "
|
|
447
|
+
}, /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement(CreditCard, null), " ", t('cart.payment'))), /*#__PURE__*/React.createElement("div", {
|
|
445
448
|
className: "checkout-modal__credit-card-message"
|
|
446
449
|
}, /*#__PURE__*/React.createElement("div", {
|
|
447
450
|
className: "checkout-modal__credit-card-message__text"
|
|
448
451
|
}, /*#__PURE__*/React.createElement("p", {
|
|
449
452
|
className: "checkout-modal__credit-card-message__primary-text"
|
|
450
|
-
},
|
|
453
|
+
}, t('checkout.enterCard')), /*#__PURE__*/React.createElement("p", {
|
|
451
454
|
className: "checkout-modal__credit-card-message__secondary-text"
|
|
452
|
-
},
|
|
455
|
+
}, t('checkout.securePayments')))))), /*#__PURE__*/React.createElement("div", {
|
|
453
456
|
className: "checkout-modal__section"
|
|
454
457
|
}, /*#__PURE__*/React.createElement(CardElement, {
|
|
455
458
|
options: {
|
|
@@ -481,12 +484,12 @@ const Checkout = _ref => {
|
|
|
481
484
|
onClick: onCancel,
|
|
482
485
|
"data-label": "cancel",
|
|
483
486
|
type: "button"
|
|
484
|
-
},
|
|
487
|
+
}, t('common.cancel')), /*#__PURE__*/React.createElement("button", {
|
|
485
488
|
className: "checkout-modal__button",
|
|
486
489
|
"data-label": "confirm",
|
|
487
490
|
disabled: !isValid() || submitting,
|
|
488
491
|
type: "submit"
|
|
489
|
-
}, submitting ? '
|
|
492
|
+
}, submitting ? t('common.submittingDots') : /*#__PURE__*/React.createElement(Fragment, null, saveLabel, /*#__PURE__*/React.createElement("span", {
|
|
490
493
|
className: "checkout-modal__button__arrow"
|
|
491
494
|
}, " \u2192"))))));
|
|
492
495
|
};
|
|
@@ -2,9 +2,11 @@ import _CouponCodeInputApplyCouponMutation from "../../__generated__/CouponCodeI
|
|
|
2
2
|
import React, { useRef, useState } from 'react';
|
|
3
3
|
import { graphql, commitMutation, useRelayEnvironment } from 'react-relay';
|
|
4
4
|
import { X } from '../Icons/index.js';
|
|
5
|
+
import { useT } from '../../i18n/useT.js';
|
|
5
6
|
const applyCouponMutation = (_CouponCodeInputApplyCouponMutation.hash && _CouponCodeInputApplyCouponMutation.hash !== "c53b64e200d60a461b3f47f15578e34e" && console.error("The definition of 'CouponCodeInputApplyCouponMutation' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _CouponCodeInputApplyCouponMutation);
|
|
6
7
|
function CouponCodeInput() {
|
|
7
8
|
const environment = useRelayEnvironment();
|
|
9
|
+
const t = useT();
|
|
8
10
|
const [submitting, setSubmitting] = useState(false);
|
|
9
11
|
const [expanded, setExpanded] = useState(false);
|
|
10
12
|
const [value, setValue] = useState('');
|
|
@@ -47,7 +49,7 @@ function CouponCodeInput() {
|
|
|
47
49
|
type: "button",
|
|
48
50
|
onClick: () => setExpanded(true),
|
|
49
51
|
className: "cart-additions__expand-button"
|
|
50
|
-
},
|
|
52
|
+
}, t('coupon.add')));
|
|
51
53
|
}
|
|
52
54
|
return /*#__PURE__*/React.createElement("div", {
|
|
53
55
|
className: "cart-additions",
|
|
@@ -65,7 +67,7 @@ function CouponCodeInput() {
|
|
|
65
67
|
setValue(e.target.value);
|
|
66
68
|
setError(null);
|
|
67
69
|
},
|
|
68
|
-
placeholder:
|
|
70
|
+
placeholder: t('coupon.placeholder'),
|
|
69
71
|
size: 21,
|
|
70
72
|
className: "cart-additions__field"
|
|
71
73
|
}), /*#__PURE__*/React.createElement("div", {
|
|
@@ -74,7 +76,7 @@ function CouponCodeInput() {
|
|
|
74
76
|
}, error ? /*#__PURE__*/React.createElement(X, null) : null)), /*#__PURE__*/React.createElement("button", {
|
|
75
77
|
type: "submit",
|
|
76
78
|
className: "cart-additions__button"
|
|
77
|
-
},
|
|
79
|
+
}, t('coupon.apply'))), error && /*#__PURE__*/React.createElement("p", {
|
|
78
80
|
className: "cart-additions__error"
|
|
79
81
|
}, error));
|
|
80
82
|
}
|
|
@@ -4,6 +4,7 @@ import Check from '../Icons/Check.js';
|
|
|
4
4
|
import X from '../Icons/X.js';
|
|
5
5
|
import TextField from '../TextField/index.js';
|
|
6
6
|
import ConfigContext from '../ConfigContext.js';
|
|
7
|
+
import { useT } from '../../i18n/useT.js';
|
|
7
8
|
const notEmpty = value => value != null;
|
|
8
9
|
const CustomerFields = _ref => {
|
|
9
10
|
let {
|
|
@@ -16,6 +17,7 @@ const CustomerFields = _ref => {
|
|
|
16
17
|
const {
|
|
17
18
|
form: config
|
|
18
19
|
} = useContext(ConfigContext);
|
|
20
|
+
const t = useT();
|
|
19
21
|
const getErrors = field => {
|
|
20
22
|
var _errors$field;
|
|
21
23
|
return errors === null || errors === void 0 ? void 0 : (_errors$field = errors[field]) === null || _errors$field === void 0 ? void 0 : _errors$field.filter(notEmpty);
|
|
@@ -29,8 +31,8 @@ const CustomerFields = _ref => {
|
|
|
29
31
|
}, /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement(User, null), " ", title)))) : null, /*#__PURE__*/React.createElement("div", {
|
|
30
32
|
className: "checkout-modal__section"
|
|
31
33
|
}, /*#__PURE__*/React.createElement(TextField, {
|
|
32
|
-
label:
|
|
33
|
-
placeholder:
|
|
34
|
+
label: t('customerFields.nameRequired'),
|
|
35
|
+
placeholder: t('customerFields.namePlaceholder'),
|
|
34
36
|
autocomplete: "name",
|
|
35
37
|
value: value.name || '',
|
|
36
38
|
onChange: v => onChange({
|
|
@@ -40,8 +42,8 @@ const CustomerFields = _ref => {
|
|
|
40
42
|
})), /*#__PURE__*/React.createElement("div", {
|
|
41
43
|
className: "checkout-modal__section"
|
|
42
44
|
}, /*#__PURE__*/React.createElement(TextField, {
|
|
43
|
-
label:
|
|
44
|
-
placeholder:
|
|
45
|
+
label: t('customerFields.emailRequired'),
|
|
46
|
+
placeholder: t('customerFields.emailPlaceholder'),
|
|
45
47
|
type: "email",
|
|
46
48
|
autocomplete: "email",
|
|
47
49
|
value: value.email || '',
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useDispatch } from 'react-redux';
|
|
3
3
|
import { FrowningFace, X } from '../Icons/index.js';
|
|
4
|
+
import { useT } from '../../i18n/useT.js';
|
|
4
5
|
const closeCart = () => ({
|
|
5
6
|
type: 'CLOSE_CART'
|
|
6
7
|
});
|
|
@@ -9,6 +10,7 @@ const EmptyCart = _ref => {
|
|
|
9
10
|
open
|
|
10
11
|
} = _ref;
|
|
11
12
|
const dispatch = useDispatch();
|
|
13
|
+
const t = useT();
|
|
12
14
|
return /*#__PURE__*/React.createElement("div", {
|
|
13
15
|
className: "cart",
|
|
14
16
|
"data-open": open
|
|
@@ -24,11 +26,11 @@ const EmptyCart = _ref => {
|
|
|
24
26
|
onClick: () => dispatch(closeCart())
|
|
25
27
|
}, /*#__PURE__*/React.createElement(X, null)), /*#__PURE__*/React.createElement("div", {
|
|
26
28
|
className: "cart__nav__title"
|
|
27
|
-
},
|
|
29
|
+
}, t('cart.yourCart')))), /*#__PURE__*/React.createElement("div", {
|
|
28
30
|
className: "cart__middle"
|
|
29
31
|
}, /*#__PURE__*/React.createElement("p", {
|
|
30
32
|
className: "cart__message"
|
|
31
|
-
},
|
|
33
|
+
}, t('cart.empty'), /*#__PURE__*/React.createElement("span", {
|
|
32
34
|
className: "cart__message__frowney"
|
|
33
35
|
}, ".\u2002", /*#__PURE__*/React.createElement(FrowningFace, null))))));
|
|
34
36
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _IdentityBox_identity from "../../__generated__/IdentityBox_identity.graphql.js";
|
|
2
2
|
import { graphql, useFragment } from 'react-relay';
|
|
3
3
|
import React from 'react';
|
|
4
|
+
import { useT } from '../../i18n/useT.js';
|
|
4
5
|
export default function IdentityBox(_ref) {
|
|
5
6
|
let {
|
|
6
7
|
identity: identityKey,
|
|
@@ -10,6 +11,7 @@ export default function IdentityBox(_ref) {
|
|
|
10
11
|
icon
|
|
11
12
|
}
|
|
12
13
|
} = _ref;
|
|
14
|
+
const t = useT();
|
|
13
15
|
const identity = useFragment((_IdentityBox_identity.hash && _IdentityBox_identity.hash !== "d93d9cb6f2c86580fb57b4de6782ec9d" && console.error("The definition of 'IdentityBox_identity' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _IdentityBox_identity), identityKey);
|
|
14
16
|
return /*#__PURE__*/React.createElement("button", {
|
|
15
17
|
className: "cart__review__button",
|
|
@@ -19,7 +21,7 @@ export default function IdentityBox(_ref) {
|
|
|
19
21
|
className: "cart__review__label"
|
|
20
22
|
}, icon, title, " ", /*#__PURE__*/React.createElement("span", {
|
|
21
23
|
className: "cart__review__label__text"
|
|
22
|
-
},
|
|
24
|
+
}, t('common.edit'))), /*#__PURE__*/React.createElement("div", {
|
|
23
25
|
className: "cart__review__section"
|
|
24
26
|
}, /*#__PURE__*/React.createElement("pre", null, identity.addressFormatted)), /*#__PURE__*/React.createElement("div", {
|
|
25
27
|
className: "cart__review__section"
|
|
@@ -27,5 +29,7 @@ export default function IdentityBox(_ref) {
|
|
|
27
29
|
className: "cart__review__section"
|
|
28
30
|
}, identity.phoneFormatted), identity.vatNumber && /*#__PURE__*/React.createElement("div", {
|
|
29
31
|
className: "cart__review__section"
|
|
30
|
-
},
|
|
32
|
+
}, t('cart.vatNumber', {
|
|
33
|
+
number: identity.vatNumber
|
|
34
|
+
})));
|
|
31
35
|
}
|
|
@@ -3,8 +3,10 @@ import React from 'react';
|
|
|
3
3
|
import { useEffect, useRef, useState } from 'react';
|
|
4
4
|
import { commitMutation, graphql, useRelayEnvironment } from 'react-relay';
|
|
5
5
|
import { Check } from '../Icons/index.js';
|
|
6
|
+
import { useT } from '../../i18n/useT.js';
|
|
6
7
|
export default function ShareCart() {
|
|
7
8
|
const environment = useRelayEnvironment();
|
|
9
|
+
const t = useT();
|
|
8
10
|
const [isSharing, setIsSharing] = useState(false);
|
|
9
11
|
const [snapshot, setSnapshot] = useState(null);
|
|
10
12
|
const [shareError, setShareError] = useState(null);
|
|
@@ -24,7 +26,7 @@ export default function ShareCart() {
|
|
|
24
26
|
} else if ((_response$createOrder = response.createOrderSnapshot) !== null && _response$createOrder !== void 0 && _response$createOrder.orderSnapshot) {
|
|
25
27
|
setSnapshot(response.createOrderSnapshot.orderSnapshot);
|
|
26
28
|
} else {
|
|
27
|
-
setShareError('
|
|
29
|
+
setShareError(t('shareCart.failed'));
|
|
28
30
|
}
|
|
29
31
|
},
|
|
30
32
|
onError: error => {
|
|
@@ -52,7 +54,7 @@ export default function ShareCart() {
|
|
|
52
54
|
className: "cart__share"
|
|
53
55
|
}, /*#__PURE__*/React.createElement("div", {
|
|
54
56
|
className: "cart__share-title"
|
|
55
|
-
},
|
|
57
|
+
}, t('shareCart.title')), /*#__PURE__*/React.createElement("div", {
|
|
56
58
|
className: "cart__share-url-input-container"
|
|
57
59
|
}, /*#__PURE__*/React.createElement("input", {
|
|
58
60
|
className: "cart__share-url-input",
|
|
@@ -65,17 +67,17 @@ export default function ShareCart() {
|
|
|
65
67
|
className: "cart__share__button cart__share__copy-button",
|
|
66
68
|
onClick: handleCopyToClipboard,
|
|
67
69
|
"data-copied": copied
|
|
68
|
-
}, /*#__PURE__*/React.createElement("span", null,
|
|
70
|
+
}, /*#__PURE__*/React.createElement("span", null, t('shareCart.copy')), /*#__PURE__*/React.createElement(Check, null))), /*#__PURE__*/React.createElement("a", {
|
|
69
71
|
href: snapshot.quotePdfUrl,
|
|
70
72
|
className: "cart__share__button cart__share__pdf-button",
|
|
71
73
|
target: "_blank",
|
|
72
74
|
rel: "noopener noreferrer"
|
|
73
|
-
},
|
|
75
|
+
}, t('shareCart.downloadPdfQuote'))) : /*#__PURE__*/React.createElement("button", {
|
|
74
76
|
type: "button",
|
|
75
77
|
className: "cart__share__button cart__share__share-button",
|
|
76
78
|
onClick: handleShareCart,
|
|
77
79
|
disabled: isSharing
|
|
78
|
-
}, isSharing ? '
|
|
80
|
+
}, isSharing ? t('common.loadingDots') : t('shareCart.share')), shareError && /*#__PURE__*/React.createElement("div", {
|
|
79
81
|
className: "cart__share-error"
|
|
80
|
-
},
|
|
82
|
+
}, t('shareCart.error')));
|
|
81
83
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { StoreModalConfig } from '../StoreModal/types.js';
|
|
2
|
+
type ReturnConfig = Pick<StoreModalConfig, 'returnUrl' | 'returnLabel'> | undefined;
|
|
3
|
+
/**
|
|
4
|
+
* `storeModal.returnUrl` as the server takes it: absolute, resolved against
|
|
5
|
+
* the page the store modal is on, or null when the site sets none.
|
|
6
|
+
*/
|
|
7
|
+
export declare function checkoutReturnParams(config: ReturnConfig, pageUrl: string): {
|
|
8
|
+
returnUrl: string | null;
|
|
9
|
+
returnLabel: string | null;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* The order page URL payment returns to, carrying where that page's link back
|
|
13
|
+
* should go (`return_url`, `return_label`). The server ignores a URL that
|
|
14
|
+
* isn't on the store's allowed origins and links to the foundry's site.
|
|
15
|
+
*/
|
|
16
|
+
export declare function withCheckoutReturn(completeUrl: string, config: ReturnConfig, pageUrl: string): string;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `storeModal.returnUrl` as the server takes it: absolute, resolved against
|
|
3
|
+
* the page the store modal is on, or null when the site sets none.
|
|
4
|
+
*/
|
|
5
|
+
export function checkoutReturnParams(config, pageUrl) {
|
|
6
|
+
if (!(config !== null && config !== void 0 && config.returnUrl)) return {
|
|
7
|
+
returnUrl: null,
|
|
8
|
+
returnLabel: null
|
|
9
|
+
};
|
|
10
|
+
try {
|
|
11
|
+
return {
|
|
12
|
+
returnUrl: new URL(config.returnUrl, pageUrl).href,
|
|
13
|
+
returnLabel: config.returnLabel ?? null
|
|
14
|
+
};
|
|
15
|
+
} catch {
|
|
16
|
+
return {
|
|
17
|
+
returnUrl: null,
|
|
18
|
+
returnLabel: null
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The order page URL payment returns to, carrying where that page's link back
|
|
25
|
+
* should go (`return_url`, `return_label`). The server ignores a URL that
|
|
26
|
+
* isn't on the store's allowed origins and links to the foundry's site.
|
|
27
|
+
*/
|
|
28
|
+
export function withCheckoutReturn(completeUrl, config, pageUrl) {
|
|
29
|
+
const {
|
|
30
|
+
returnUrl,
|
|
31
|
+
returnLabel
|
|
32
|
+
} = checkoutReturnParams(config, pageUrl);
|
|
33
|
+
if (!returnUrl) return completeUrl;
|
|
34
|
+
const url = new URL(completeUrl);
|
|
35
|
+
url.searchParams.set('return_url', returnUrl);
|
|
36
|
+
if (returnLabel) url.searchParams.set('return_label', returnLabel);
|
|
37
|
+
return url.href;
|
|
38
|
+
}
|
|
@@ -8,5 +8,6 @@ export interface CartButton_props {
|
|
|
8
8
|
}
|
|
9
9
|
export type CartButton_unifiedProps = CartButton_props & {
|
|
10
10
|
config?: Config;
|
|
11
|
+
locale?: string;
|
|
11
12
|
};
|
|
12
|
-
export default function CartButton({ config, ...props }: CartButton_unifiedProps): React.JSX.Element;
|
|
13
|
+
export default function CartButton({ config, locale, ...props }: CartButton_unifiedProps): React.JSX.Element;
|
|
@@ -11,6 +11,7 @@ import ConfigContext from '../ConfigContext.js';
|
|
|
11
11
|
import { CartNew } from '../Icons/index.js';
|
|
12
12
|
import Price, { PriceFormat } from '../Price/index.js';
|
|
13
13
|
import { EnsureFontdueContext } from '../FontdueContextProvider/index.js';
|
|
14
|
+
import { useT } from '../../i18n/useT.js';
|
|
14
15
|
function getOrderCount(order) {
|
|
15
16
|
return order.orderItems ? order.orderItems.length : 0;
|
|
16
17
|
}
|
|
@@ -37,6 +38,7 @@ function CartButtonComponent(_ref) {
|
|
|
37
38
|
const {
|
|
38
39
|
storeModal: storeModalConfig
|
|
39
40
|
} = useContext(ConfigContext);
|
|
41
|
+
const t = useT();
|
|
40
42
|
const formatSuffix = useCallback(() => {
|
|
41
43
|
if (!suffix) return null;
|
|
42
44
|
const hasSubstitutions = /\{(count|subtotal)\}/.test(suffix);
|
|
@@ -89,7 +91,7 @@ function CartButtonComponent(_ref) {
|
|
|
89
91
|
"data-button-style": buttonStyle
|
|
90
92
|
}, children ? children : buttonStyle === 'icon' ? /*#__PURE__*/React.createElement(CartNew, null) : /*#__PURE__*/React.createElement("span", {
|
|
91
93
|
className: "cart-button__label"
|
|
92
|
-
}, label || '
|
|
94
|
+
}, label || t('storeModal.cart'), suffixNodes && /*#__PURE__*/React.createElement("span", {
|
|
93
95
|
className: "cart-button__suffix"
|
|
94
96
|
}, suffixNodes))));
|
|
95
97
|
}
|
|
@@ -112,12 +114,14 @@ function CartButtonLazyQueryRenderer(props) {
|
|
|
112
114
|
export default function CartButton(_ref2) {
|
|
113
115
|
let {
|
|
114
116
|
config,
|
|
117
|
+
locale,
|
|
115
118
|
...props
|
|
116
119
|
} = _ref2;
|
|
117
120
|
const [mounted, setMounted] = useState(false);
|
|
118
121
|
useEffect(() => setMounted(true), []);
|
|
119
122
|
return /*#__PURE__*/React.createElement(EnsureFontdueContext, {
|
|
120
|
-
config: config
|
|
123
|
+
config: config,
|
|
124
|
+
locale: locale
|
|
121
125
|
}, mounted ? /*#__PURE__*/React.createElement(Suspense, {
|
|
122
126
|
fallback: /*#__PURE__*/React.createElement(CartButtonComponent, _extends({}, props, {
|
|
123
127
|
order: null,
|
|
@@ -7,12 +7,16 @@ export default function StyleSelect(_ref) {
|
|
|
7
7
|
value,
|
|
8
8
|
onChange
|
|
9
9
|
} = _ref;
|
|
10
|
+
// Flattening once drops the non-null assertions this used to make on each
|
|
11
|
+
// element: `fontStyles` is nullable, and `[null].find((s) => s!.id)` threw
|
|
12
|
+
// for a family whose styles hadn't loaded.
|
|
13
|
+
const styles = collections.flatMap(coll => coll.fontStyles ?? []);
|
|
10
14
|
const handleChange = e => {
|
|
11
15
|
const value = e.target.value;
|
|
12
16
|
if (value.includes(':::')) {
|
|
13
17
|
var _fontStyle$variableIn;
|
|
14
18
|
const [fontStyleId, variableInstanceName] = value.split(':::');
|
|
15
|
-
const fontStyle =
|
|
19
|
+
const fontStyle = styles.find(style => style.id === fontStyleId);
|
|
16
20
|
const instance = fontStyle === null || fontStyle === void 0 ? void 0 : (_fontStyle$variableIn = fontStyle.variableInstances) === null || _fontStyle$variableIn === void 0 ? void 0 : _fontStyle$variableIn.find(_ref2 => {
|
|
17
21
|
let {
|
|
18
22
|
name
|
|
@@ -34,7 +38,7 @@ export default function StyleSelect(_ref) {
|
|
|
34
38
|
let selectValue = value.fontStyleId;
|
|
35
39
|
if (value.variableSettings) {
|
|
36
40
|
var _fontStyle$variableIn2;
|
|
37
|
-
const fontStyle =
|
|
41
|
+
const fontStyle = styles.find(style => style.id === value.fontStyleId);
|
|
38
42
|
const instance = fontStyle === null || fontStyle === void 0 ? void 0 : (_fontStyle$variableIn2 = fontStyle.variableInstances) === null || _fontStyle$variableIn2 === void 0 ? void 0 : _fontStyle$variableIn2.find(instance => compareVariableSettings(instance, value.variableSettings));
|
|
39
43
|
if (instance) {
|
|
40
44
|
selectValue = `${value.fontStyleId}:::${instance.name}`;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type CharacterViewerCollapse = boolean | number | string;
|
|
2
|
+
export type CollapseMode = {
|
|
3
|
+
kind: 'none';
|
|
4
|
+
} | {
|
|
5
|
+
kind: 'first-group';
|
|
6
|
+
} | {
|
|
7
|
+
kind: 'height';
|
|
8
|
+
height: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function parseCollapse(value: CharacterViewerCollapse | null | undefined): CollapseMode;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// How a collapsed CharacterViewer is cut short before its “Load more” button.
|
|
2
|
+
//
|
|
3
|
+
// `collapse` arrives as a React prop (boolean, number or string) or as the
|
|
4
|
+
// `collapse` attribute on <fontdue-character-viewer>, where every value is a
|
|
5
|
+
// string and a bare attribute is the empty string:
|
|
6
|
+
//
|
|
7
|
+
// collapse / collapse="" / collapse="first-group" / collapse={true}
|
|
8
|
+
// → only the first glyph group renders until the visitor loads more
|
|
9
|
+
// collapse="480" / collapse={480} → clipped to 480px
|
|
10
|
+
// collapse="40vh" / collapse="30rem" → clipped to any CSS length
|
|
11
|
+
// collapse="false" / collapse={false} / absent → never collapsed
|
|
12
|
+
|
|
13
|
+
const NONE = {
|
|
14
|
+
kind: 'none'
|
|
15
|
+
};
|
|
16
|
+
const FIRST_GROUP = {
|
|
17
|
+
kind: 'first-group'
|
|
18
|
+
};
|
|
19
|
+
export function parseCollapse(value) {
|
|
20
|
+
if (value === undefined || value === null || value === false) return NONE;
|
|
21
|
+
if (value === true) return FIRST_GROUP;
|
|
22
|
+
if (typeof value === 'number') {
|
|
23
|
+
return value > 0 ? {
|
|
24
|
+
kind: 'height',
|
|
25
|
+
height: `${value}px`
|
|
26
|
+
} : NONE;
|
|
27
|
+
}
|
|
28
|
+
const trimmed = value.trim();
|
|
29
|
+
if (trimmed === '' || trimmed === 'true' || trimmed === 'first-group') return FIRST_GROUP;
|
|
30
|
+
if (trimmed === 'false') return NONE;
|
|
31
|
+
if (/^\d+(\.\d+)?$/.test(trimmed)) return {
|
|
32
|
+
kind: 'height',
|
|
33
|
+
height: `${trimmed}px`
|
|
34
|
+
};
|
|
35
|
+
return {
|
|
36
|
+
kind: 'height',
|
|
37
|
+
height: trimmed
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -3,7 +3,10 @@ import { SerializablePreloadedQuery, type LoadQueryOptions } from '../../relay/l
|
|
|
3
3
|
import { CharacterViewerIDQuery } from '../../__generated__/CharacterViewerIDQuery.graphql.js';
|
|
4
4
|
import { CharacterViewerSlugQuery } from '../../__generated__/CharacterViewerSlugQuery.graphql.js';
|
|
5
5
|
import { Config } from '../ConfigContext.js';
|
|
6
|
+
import { type CharacterViewerCollapse } from './collapse.js';
|
|
6
7
|
export interface CharacterViewer_props {
|
|
8
|
+
collapse?: CharacterViewerCollapse;
|
|
9
|
+
loadMoreLabel?: string;
|
|
7
10
|
}
|
|
8
11
|
export type CharacterViewerPreloadedQuery = SerializablePreloadedQuery<CharacterViewerIDQuery> | SerializablePreloadedQuery<CharacterViewerSlugQuery>;
|
|
9
12
|
export type LoadCharacterViewerQueryVariables = {
|
|
@@ -22,6 +25,7 @@ export declare function CharacterViewerPreloadedSlugQueryRenderer({ preloadedQue
|
|
|
22
25
|
}): React.JSX.Element | null;
|
|
23
26
|
export type CharacterViewer_unifiedProps = CharacterViewer_props & {
|
|
24
27
|
config?: Config;
|
|
28
|
+
locale?: string;
|
|
25
29
|
} & ({
|
|
26
30
|
preloadedQuery: CharacterViewerPreloadedQuery;
|
|
27
31
|
collectionId?: never;
|