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
|
@@ -8,16 +8,18 @@ import { commitMutation, graphql, useLazyLoadQuery, useRelayEnvironment } from '
|
|
|
8
8
|
// The script-injecting reCAPTCHA wrapper (loads Google's api.js); see
|
|
9
9
|
// ../Recaptcha for why it isn't the package's named export.
|
|
10
10
|
import { ReCAPTCHA } from '../Recaptcha.js';
|
|
11
|
+
import { useLocale } from '../LocaleContext.js';
|
|
11
12
|
import TextField from '../TextField/index.js';
|
|
12
|
-
import { useRecaptchaTimeout, isRecaptchaScriptLoaded
|
|
13
|
+
import { useRecaptchaTimeout, isRecaptchaScriptLoaded } from '../../hooks/useRecaptchaTimeout.js';
|
|
14
|
+
import { useT } from '../../i18n/useT.js';
|
|
13
15
|
const loginMutation = (_CustomerLoginFormLoginMutation.hash && _CustomerLoginFormLoginMutation.hash !== "975b639fac1e0d88e0f0c9c55acd8b9c" && console.error("The definition of 'CustomerLoginFormLoginMutation' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _CustomerLoginFormLoginMutation);
|
|
14
16
|
const query = (_CustomerLoginFormQuery.hash && _CustomerLoginFormQuery.hash !== "f32c7b0b485a2b2a02ddf2cbc5b87a3c" && console.error("The definition of 'CustomerLoginFormQuery' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _CustomerLoginFormQuery);
|
|
15
17
|
const recaptchaQuery = (_CustomerLoginFormRecaptchaQuery.hash && _CustomerLoginFormRecaptchaQuery.hash !== "fe7289e19bcc08dbad62e72d67c48c97" && console.error("The definition of 'CustomerLoginFormRecaptchaQuery' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _CustomerLoginFormRecaptchaQuery);
|
|
16
|
-
const DEFAULT_SUBMITTED_LABEL = '<p>Submitted!</p><p>Please check your email inbox for a link to log in.</p><p>If you don’t receive an email, please contact us to retrieve your order information.</p>';
|
|
17
18
|
const CustomerLoginForm = _ref => {
|
|
18
19
|
let {
|
|
19
|
-
submitLabel
|
|
20
|
+
submitLabel
|
|
20
21
|
} = _ref;
|
|
22
|
+
const t = useT();
|
|
21
23
|
const [email, setEmail] = useState('');
|
|
22
24
|
const [error, setError] = useState(null);
|
|
23
25
|
const [submitting, setSubmitting] = useState(false);
|
|
@@ -81,8 +83,8 @@ const CustomerLoginForm = _ref => {
|
|
|
81
83
|
recaptchaTimeout.clear();
|
|
82
84
|
setPendingSubmit(false);
|
|
83
85
|
resetRecaptcha();
|
|
84
|
-
setError(
|
|
85
|
-
}, [recaptchaTimeout, resetRecaptcha]);
|
|
86
|
+
setError(t('recaptcha.unavailable'));
|
|
87
|
+
}, [recaptchaTimeout, resetRecaptcha, t]);
|
|
86
88
|
const handleRecaptchaErrored = useCallback(() => {
|
|
87
89
|
if (pendingSubmit) abortRecaptcha();
|
|
88
90
|
}, [pendingSubmit, abortRecaptcha]);
|
|
@@ -123,12 +125,12 @@ const CustomerLoginForm = _ref => {
|
|
|
123
125
|
}, /*#__PURE__*/React.createElement("div", {
|
|
124
126
|
className: "login-form__section"
|
|
125
127
|
}, /*#__PURE__*/React.createElement(TextField, {
|
|
126
|
-
label:
|
|
128
|
+
label: t('customerFields.emailRequired'),
|
|
127
129
|
type: "email",
|
|
128
130
|
value: email,
|
|
129
131
|
onChange: value => setEmail(value),
|
|
130
132
|
autocomplete: "email",
|
|
131
|
-
placeholder:
|
|
133
|
+
placeholder: t('customerFields.emailPlaceholder')
|
|
132
134
|
})), mounted && /*#__PURE__*/React.createElement(Suspense, {
|
|
133
135
|
fallback: null
|
|
134
136
|
}, /*#__PURE__*/React.createElement(LoginRecaptcha, {
|
|
@@ -141,7 +143,7 @@ const CustomerLoginForm = _ref => {
|
|
|
141
143
|
className: "submit-button",
|
|
142
144
|
type: "submit",
|
|
143
145
|
disabled: submitting || pendingSubmit || disabled
|
|
144
|
-
}, submitting || pendingSubmit ? '
|
|
146
|
+
}, submitting || pendingSubmit ? t('common.submittingDots') : submitLabel ?? t('common.submit'), /*#__PURE__*/React.createElement("span", {
|
|
145
147
|
className: "submit-button__arrow"
|
|
146
148
|
}, " \u2192")))));
|
|
147
149
|
};
|
|
@@ -159,6 +161,7 @@ function LoginRecaptcha(_ref3) {
|
|
|
159
161
|
onErrored
|
|
160
162
|
} = _ref3;
|
|
161
163
|
const data = useLazyLoadQuery(recaptchaQuery, {});
|
|
164
|
+
const locale = useLocale();
|
|
162
165
|
const settings = (_data$viewer = data.viewer) === null || _data$viewer === void 0 ? void 0 : _data$viewer.settings;
|
|
163
166
|
const siteKey = settings !== null && settings !== void 0 && settings.recaptchaEnabled ? settings.recaptchaSiteKey ?? null : null;
|
|
164
167
|
useEffect(() => onSiteKey(siteKey), [siteKey, onSiteKey]);
|
|
@@ -166,6 +169,7 @@ function LoginRecaptcha(_ref3) {
|
|
|
166
169
|
return /*#__PURE__*/React.createElement(ReCAPTCHA, {
|
|
167
170
|
ref: widgetRef,
|
|
168
171
|
sitekey: siteKey,
|
|
172
|
+
hl: locale,
|
|
169
173
|
size: "invisible",
|
|
170
174
|
onChange: onChange,
|
|
171
175
|
onExpired: onExpired,
|
|
@@ -180,7 +184,8 @@ function LoginRecaptcha(_ref3) {
|
|
|
180
184
|
function SubmittedMessage() {
|
|
181
185
|
var _data$viewer2, _data$viewer2$setting;
|
|
182
186
|
const data = useLazyLoadQuery(query, {});
|
|
183
|
-
const
|
|
187
|
+
const t = useT();
|
|
188
|
+
const submittedLabel = ((_data$viewer2 = data.viewer) === null || _data$viewer2 === void 0 ? void 0 : (_data$viewer2$setting = _data$viewer2.settings) === null || _data$viewer2$setting === void 0 ? void 0 : _data$viewer2$setting.customerLoginSubmittedLabel) || t('loginForm.submittedHtml');
|
|
184
189
|
return /*#__PURE__*/React.createElement("div", {
|
|
185
190
|
className: "login-form__submitted",
|
|
186
191
|
dangerouslySetInnerHTML: {
|
|
@@ -18,5 +18,5 @@ interface CustomerSignInElement_props extends Omit<CustomerSignIn_props, 'onSign
|
|
|
18
18
|
*
|
|
19
19
|
* Not in the npm package's `exports`: sign-in is script-tag only for now.
|
|
20
20
|
*/
|
|
21
|
-
export default function CustomerSignInElement({ signOutLabel, ...props }: CustomerSignInElement_props): React.JSX.Element;
|
|
21
|
+
export default function CustomerSignInElement({ signOutLabel: signOutLabelProp, ...props }: CustomerSignInElement_props): React.JSX.Element;
|
|
22
22
|
export {};
|
|
@@ -8,6 +8,7 @@ import { graphql, useLazyLoadQuery } from 'react-relay';
|
|
|
8
8
|
import CustomerSignIn from './index.js';
|
|
9
9
|
import { clearTokens, getTokens, subscribeToTokens } from '../../auth/tokenStore.js';
|
|
10
10
|
import { useFontdueUrl } from '../UrlContext.js';
|
|
11
|
+
import { useT } from '../../i18n/useT.js';
|
|
11
12
|
const query = (_CustomerSignInElementQuery.hash && _CustomerSignInElementQuery.hash !== "e7d4a8fb8d19581d6bc36f29090230af" && console.error("The definition of 'CustomerSignInElementQuery' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _CustomerSignInElementQuery);
|
|
12
13
|
|
|
13
14
|
/** Dispatched on `window` once the customer is signed in; `detail.customer`. */
|
|
@@ -26,9 +27,11 @@ export const SIGNED_OUT_EVENT = 'fontdue:customer-signed-out';
|
|
|
26
27
|
*/
|
|
27
28
|
export default function CustomerSignInElement(_ref) {
|
|
28
29
|
let {
|
|
29
|
-
signOutLabel
|
|
30
|
+
signOutLabel: signOutLabelProp,
|
|
30
31
|
...props
|
|
31
32
|
} = _ref;
|
|
33
|
+
const t = useT();
|
|
34
|
+
const signOutLabel = signOutLabelProp ?? t('signIn.signOut');
|
|
32
35
|
const url = useFontdueUrl();
|
|
33
36
|
// The script tag never renders on a server, so reading the store during
|
|
34
37
|
// render can't cause a hydration mismatch – and it means a returning
|
|
@@ -117,12 +120,15 @@ function SignedIn(_ref3) {
|
|
|
117
120
|
signOut,
|
|
118
121
|
signOutLabel
|
|
119
122
|
} = _ref3;
|
|
123
|
+
const t = useT();
|
|
120
124
|
return /*#__PURE__*/React.createElement("div", {
|
|
121
125
|
className: "customer-sign-in",
|
|
122
126
|
"data-step": "signed-in"
|
|
123
127
|
}, /*#__PURE__*/React.createElement("p", {
|
|
124
128
|
className: "customer-sign-in__intro"
|
|
125
|
-
},
|
|
129
|
+
}, t('signIn.signedInAs', {
|
|
130
|
+
name: customer.email ?? customer.name ?? ''
|
|
131
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
126
132
|
className: "customer-sign-in__actions"
|
|
127
133
|
}, /*#__PURE__*/React.createElement("button", {
|
|
128
134
|
className: "customer-sign-in__back",
|
|
@@ -14,6 +14,11 @@ export interface CustomerSignIn_props {
|
|
|
14
14
|
requestLabel?: string;
|
|
15
15
|
/** Label on the button that submits the code. */
|
|
16
16
|
verifyLabel?: string;
|
|
17
|
+
/**
|
|
18
|
+
* The island's language (e.g. `de`), as on `<FontdueProvider locale>`.
|
|
19
|
+
* Inside a provider it defaults to the provider's.
|
|
20
|
+
*/
|
|
21
|
+
locale?: string;
|
|
17
22
|
}
|
|
18
23
|
/**
|
|
19
24
|
* Sign a returning customer in with a one-time code.
|
|
@@ -30,4 +35,4 @@ export interface CustomerSignIn_props {
|
|
|
30
35
|
* Self-wraps in `EnsureFontdueContext`, so it works as a standalone island and
|
|
31
36
|
* no-ops inside an outer `<FontdueProvider>`.
|
|
32
37
|
*/
|
|
33
|
-
export default function CustomerSignIn(props: CustomerSignIn_props): React.JSX.Element;
|
|
38
|
+
export default function CustomerSignIn({ locale, ...props }: CustomerSignIn_props): React.JSX.Element;
|
|
@@ -8,6 +8,7 @@ import TextField from '../TextField/index.js';
|
|
|
8
8
|
import { EnsureFontdueContext } from '../FontdueContextProvider/index.js';
|
|
9
9
|
import { setTokens } from '../../auth/tokenStore.js';
|
|
10
10
|
import { useFontdueUrl } from '../UrlContext.js';
|
|
11
|
+
import { useT } from '../../i18n/useT.js';
|
|
11
12
|
const requestLoginCodeMutation = (_CustomerSignInRequestLoginCodeMutation.hash && _CustomerSignInRequestLoginCodeMutation.hash !== "36fccde5eb4502dcd8d3269bb5713547" && console.error("The definition of 'CustomerSignInRequestLoginCodeMutation' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _CustomerSignInRequestLoginCodeMutation);
|
|
12
13
|
const verifyLoginCodeMutation = (_CustomerSignInVerifyLoginCodeMutation.hash && _CustomerSignInVerifyLoginCodeMutation.hash !== "0342b61905975bf0b0112270e8706435" && console.error("The definition of 'CustomerSignInVerifyLoginCodeMutation' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _CustomerSignInVerifyLoginCodeMutation);
|
|
13
14
|
|
|
@@ -28,16 +29,25 @@ const verifyLoginCodeMutation = (_CustomerSignInVerifyLoginCodeMutation.hash &&
|
|
|
28
29
|
* Self-wraps in `EnsureFontdueContext`, so it works as a standalone island and
|
|
29
30
|
* no-ops inside an outer `<FontdueProvider>`.
|
|
30
31
|
*/
|
|
31
|
-
export default function CustomerSignIn(
|
|
32
|
-
|
|
32
|
+
export default function CustomerSignIn(_ref) {
|
|
33
|
+
let {
|
|
34
|
+
locale,
|
|
35
|
+
...props
|
|
36
|
+
} = _ref;
|
|
37
|
+
return /*#__PURE__*/React.createElement(EnsureFontdueContext, {
|
|
38
|
+
locale: locale
|
|
39
|
+
}, /*#__PURE__*/React.createElement(CustomerSignInFields, props));
|
|
33
40
|
}
|
|
34
|
-
function CustomerSignInFields(
|
|
41
|
+
function CustomerSignInFields(_ref2) {
|
|
35
42
|
let {
|
|
36
43
|
email: initialEmail = '',
|
|
37
44
|
onSignedIn,
|
|
38
|
-
requestLabel
|
|
39
|
-
verifyLabel
|
|
40
|
-
} =
|
|
45
|
+
requestLabel: requestLabelProp,
|
|
46
|
+
verifyLabel: verifyLabelProp
|
|
47
|
+
} = _ref2;
|
|
48
|
+
const t = useT();
|
|
49
|
+
const requestLabel = requestLabelProp ?? t('signIn.request');
|
|
50
|
+
const verifyLabel = verifyLabelProp ?? t('signIn.verify');
|
|
41
51
|
const url = useFontdueUrl();
|
|
42
52
|
const [email, setEmail] = useState(initialEmail);
|
|
43
53
|
const [code, setCode] = useState('');
|
|
@@ -63,7 +73,7 @@ function CustomerSignInFields(_ref) {
|
|
|
63
73
|
} else {
|
|
64
74
|
// The only unsuccessful answer is the rate limit, and it is about the
|
|
65
75
|
// address, not about whether it has an account.
|
|
66
|
-
setError('
|
|
76
|
+
setError(t('signIn.rateLimited'));
|
|
67
77
|
}
|
|
68
78
|
},
|
|
69
79
|
onError: mutationError => setError(mutationError.message)
|
|
@@ -86,7 +96,7 @@ function CustomerSignInFields(_ref) {
|
|
|
86
96
|
return;
|
|
87
97
|
}
|
|
88
98
|
if ((payload === null || payload === void 0 ? void 0 : payload.accessToken) == null || (payload === null || payload === void 0 ? void 0 : payload.refreshToken) == null) {
|
|
89
|
-
setError('
|
|
99
|
+
setError(t('signIn.invalidCode'));
|
|
90
100
|
return;
|
|
91
101
|
}
|
|
92
102
|
|
|
@@ -117,10 +127,12 @@ function CustomerSignInFields(_ref) {
|
|
|
117
127
|
onSubmit: handleVerify
|
|
118
128
|
}, /*#__PURE__*/React.createElement("p", {
|
|
119
129
|
className: "customer-sign-in__intro"
|
|
120
|
-
},
|
|
130
|
+
}, t('signIn.codeSent', {
|
|
131
|
+
email
|
|
132
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
121
133
|
className: "customer-sign-in__section"
|
|
122
134
|
}, /*#__PURE__*/React.createElement(TextField, {
|
|
123
|
-
label:
|
|
135
|
+
label: t('signIn.codeLabel')
|
|
124
136
|
// `one-time-code` is what lets a phone offer the code straight
|
|
125
137
|
// from the notification rather than making people switch apps.
|
|
126
138
|
,
|
|
@@ -135,13 +147,13 @@ function CustomerSignInFields(_ref) {
|
|
|
135
147
|
className: "submit-button",
|
|
136
148
|
type: "submit",
|
|
137
149
|
disabled: verifying || !code
|
|
138
|
-
}, verifying ? '
|
|
150
|
+
}, verifying ? t('signIn.signingIn') : verifyLabel, /*#__PURE__*/React.createElement("span", {
|
|
139
151
|
className: "submit-button__arrow"
|
|
140
152
|
}, " \u2192")), /*#__PURE__*/React.createElement("button", {
|
|
141
153
|
className: "customer-sign-in__back",
|
|
142
154
|
type: "button",
|
|
143
155
|
onClick: handleStartOver
|
|
144
|
-
},
|
|
156
|
+
}, t('signIn.differentEmail')))));
|
|
145
157
|
}
|
|
146
158
|
return /*#__PURE__*/React.createElement("div", {
|
|
147
159
|
className: "customer-sign-in",
|
|
@@ -154,19 +166,19 @@ function CustomerSignInFields(_ref) {
|
|
|
154
166
|
}, /*#__PURE__*/React.createElement("div", {
|
|
155
167
|
className: "customer-sign-in__section"
|
|
156
168
|
}, /*#__PURE__*/React.createElement(TextField, {
|
|
157
|
-
label:
|
|
169
|
+
label: t('customerFields.emailRequired'),
|
|
158
170
|
type: "email",
|
|
159
171
|
value: email,
|
|
160
172
|
onChange: value => setEmail(value),
|
|
161
173
|
autocomplete: "email",
|
|
162
|
-
placeholder:
|
|
174
|
+
placeholder: t('customerFields.emailPlaceholder')
|
|
163
175
|
})), /*#__PURE__*/React.createElement("div", {
|
|
164
176
|
className: "customer-sign-in__actions"
|
|
165
177
|
}, /*#__PURE__*/React.createElement("button", {
|
|
166
178
|
className: "submit-button",
|
|
167
179
|
type: "submit",
|
|
168
180
|
disabled: requesting || !email
|
|
169
|
-
}, requesting ? '
|
|
181
|
+
}, requesting ? t('signIn.sending') : requestLabel, /*#__PURE__*/React.createElement("span", {
|
|
170
182
|
className: "submit-button__arrow"
|
|
171
183
|
}, " \u2192")))));
|
|
172
184
|
}
|
|
@@ -12,13 +12,16 @@ export default function FamilyList(_ref) {
|
|
|
12
12
|
node: nodeKey,
|
|
13
13
|
text
|
|
14
14
|
} = _ref;
|
|
15
|
-
const node = useFragment((_FamilyList_node.hash && _FamilyList_node.hash !== "
|
|
15
|
+
const node = useFragment((_FamilyList_node.hash && _FamilyList_node.hash !== "ffcf9b6c3ef8e62c7be8dc82470bcf48" && console.error("The definition of 'FamilyList_node' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _FamilyList_node), nodeKey);
|
|
16
16
|
return /*#__PURE__*/React.createElement("ul", {
|
|
17
17
|
className: "font-family-block__list",
|
|
18
18
|
style: {
|
|
19
19
|
fontFamily: node.name
|
|
20
20
|
}
|
|
21
|
-
}, (_node$fontStyles = node.fontStyles
|
|
21
|
+
}, (_node$fontStyles = node.fontStyles
|
|
22
|
+
// An unlisted style isn't named here either – the same rule the
|
|
23
|
+
// Store Modal applies to its rows.
|
|
24
|
+
) === null || _node$fontStyles === void 0 ? void 0 : _node$fontStyles.filter(style => style.visibility !== 'UNLISTED').map((style, i) => {
|
|
22
25
|
var _style$variableInstan, _style$variableInstan2;
|
|
23
26
|
return /*#__PURE__*/React.createElement(FontStyle, {
|
|
24
27
|
fontStyle: style,
|
|
@@ -7,13 +7,14 @@ import SKUPrice from '../SKUPrice/index.js';
|
|
|
7
7
|
import { PriceFormat } from '../Price/index.js';
|
|
8
8
|
import FamilyList from './FamilyList.js';
|
|
9
9
|
import { isSelected } from '../../reducer.js';
|
|
10
|
-
import {
|
|
10
|
+
import { useT } from '../../i18n/useT.js';
|
|
11
11
|
export default function Family(_ref) {
|
|
12
|
-
var _node$
|
|
12
|
+
var _node$families;
|
|
13
13
|
let {
|
|
14
14
|
node: nodeKey,
|
|
15
15
|
size
|
|
16
16
|
} = _ref;
|
|
17
|
+
const t = useT();
|
|
17
18
|
const node = useFragment((_Family_node.hash && _Family_node.hash !== "5c49167e8bf2458ab72604ff960636b2" && console.error("The definition of 'Family_node' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _Family_node), nodeKey);
|
|
18
19
|
const precartOpen = useSelector(state => state.precartOpen);
|
|
19
20
|
const selector = node.sku ? isSelected(node.sku.id) : () => false;
|
|
@@ -46,25 +47,33 @@ export default function Family(_ref) {
|
|
|
46
47
|
className: "font-family-block__label"
|
|
47
48
|
}, /*#__PURE__*/React.createElement("h3", {
|
|
48
49
|
className: "font-family-block__name"
|
|
49
|
-
}, isSuperFamily ?
|
|
50
|
+
}, isSuperFamily ? t('family.superFamily', {
|
|
51
|
+
name: node.name
|
|
52
|
+
}) : node.name), /*#__PURE__*/React.createElement("span", {
|
|
50
53
|
className: "font-family-block__separator"
|
|
51
54
|
}), /*#__PURE__*/React.createElement("p", {
|
|
52
55
|
className: "font-family-block__count"
|
|
53
|
-
},
|
|
56
|
+
}, t(node.isVariableFont ? 'common.fontCount' : 'common.styleCount', {
|
|
57
|
+
count: node.totalStyles ?? 0
|
|
58
|
+
})), node.isVariableFont ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
54
59
|
className: "font-family-block__separator"
|
|
55
60
|
}), /*#__PURE__*/React.createElement("p", {
|
|
56
61
|
className: "font-family-block__count"
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
62
|
+
}, t('family.variableAxisCount', {
|
|
63
|
+
count: (node.fontStyles ?? []).reduce((total, style) => {
|
|
64
|
+
var _style$variableAxes;
|
|
65
|
+
return total + (((_style$variableAxes = style.variableAxes) === null || _style$variableAxes === void 0 ? void 0 : _style$variableAxes.length) ?? 0);
|
|
66
|
+
}, 0)
|
|
67
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
61
68
|
className: "font-family-block__separator"
|
|
62
69
|
}), /*#__PURE__*/React.createElement("p", {
|
|
63
70
|
className: "font-family-block__count"
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
71
|
+
}, t('family.namedInstanceCount', {
|
|
72
|
+
count: (node.fontStyles ?? []).reduce((total, style) => {
|
|
73
|
+
var _style$variableInstan;
|
|
74
|
+
return total + (((_style$variableInstan = style.variableInstances) === null || _style$variableInstan === void 0 ? void 0 : _style$variableInstan.length) ?? 0);
|
|
75
|
+
}, 0)
|
|
76
|
+
}))) : null), /*#__PURE__*/React.createElement("div", {
|
|
68
77
|
className: "font-family-block__lists"
|
|
69
78
|
}, isSuperFamily ? (_node$families = node.families) === null || _node$families === void 0 ? void 0 : _node$families.map((family, index) => {
|
|
70
79
|
var _family$featureStyle;
|
|
@@ -26,6 +26,7 @@ export declare function FeatureTestersPreloadedSlugQueryRenderer({ preloadedQuer
|
|
|
26
26
|
} & ListOptions): React.JSX.Element | null;
|
|
27
27
|
export type FeatureTestersProps = {
|
|
28
28
|
config?: Config;
|
|
29
|
+
locale?: string;
|
|
29
30
|
} & ListOptions & ({
|
|
30
31
|
preloadedQuery: FeatureTestersPreloadedQuery;
|
|
31
32
|
collectionId?: never;
|
|
@@ -39,5 +40,5 @@ export type FeatureTestersProps = {
|
|
|
39
40
|
collectionSlug: string;
|
|
40
41
|
collectionId?: never;
|
|
41
42
|
});
|
|
42
|
-
export default function FeatureTesters({ config, ...props }: FeatureTestersProps): React.JSX.Element;
|
|
43
|
+
export default function FeatureTesters({ config, locale, ...props }: FeatureTestersProps): React.JSX.Element;
|
|
43
44
|
export {};
|
|
@@ -130,8 +130,10 @@ function FeatureTestersPreloadedRenderer(_ref6) {
|
|
|
130
130
|
// frontmatter or a manual loader call) or `{collectionId}`/`{collectionSlug}`
|
|
131
131
|
// for lazy fetch.
|
|
132
132
|
export default function FeatureTesters(_ref7) {
|
|
133
|
+
var _props$preloadedQuery;
|
|
133
134
|
let {
|
|
134
135
|
config,
|
|
136
|
+
locale,
|
|
135
137
|
...props
|
|
136
138
|
} = _ref7;
|
|
137
139
|
const {
|
|
@@ -145,7 +147,8 @@ export default function FeatureTesters(_ref7) {
|
|
|
145
147
|
autofit
|
|
146
148
|
};
|
|
147
149
|
return /*#__PURE__*/React.createElement(EnsureFontdueContext, {
|
|
148
|
-
config: config
|
|
150
|
+
config: config,
|
|
151
|
+
locale: locale ?? ('preloadedQuery' in props ? (_props$preloadedQuery = props.preloadedQuery) === null || _props$preloadedQuery === void 0 ? void 0 : _props$preloadedQuery.locale : undefined)
|
|
149
152
|
}, 'preloadedQuery' in props && props.preloadedQuery ? /*#__PURE__*/React.createElement(FeatureTestersPreloadedRenderer, _extends({
|
|
150
153
|
preloadedQuery: props.preloadedQuery
|
|
151
154
|
}, options)) : 'collectionId' in props && props.collectionId ? /*#__PURE__*/React.createElement(LazyQueryBoundary, null, /*#__PURE__*/React.createElement(ById, _extends({
|
|
@@ -23,6 +23,8 @@ export default async function FeatureTesters(_ref) {
|
|
|
23
23
|
if (collectionId) {
|
|
24
24
|
const preloadedQuery = await loadSerializableQuery(FeatureTestersIdQueryNode, {
|
|
25
25
|
id: collectionId
|
|
26
|
+
}, {
|
|
27
|
+
locale: rest.locale
|
|
26
28
|
});
|
|
27
29
|
return /*#__PURE__*/React.createElement(FeatureTestersPreloadedIDQueryRenderer, _extends({
|
|
28
30
|
preloadedQuery: preloadedQuery
|
|
@@ -31,6 +33,8 @@ export default async function FeatureTesters(_ref) {
|
|
|
31
33
|
if (collectionSlug) {
|
|
32
34
|
const preloadedQuery = await loadSerializableQuery(FeatureTestersSlugQueryNode, {
|
|
33
35
|
slug: collectionSlug
|
|
36
|
+
}, {
|
|
37
|
+
locale: rest.locale
|
|
34
38
|
});
|
|
35
39
|
return /*#__PURE__*/React.createElement(FeatureTestersPreloadedSlugQueryRenderer, _extends({
|
|
36
40
|
preloadedQuery: preloadedQuery
|
|
@@ -14,6 +14,7 @@ export declare function FeatureTesterPreloadedRenderer({ preloadedQuery, ...rest
|
|
|
14
14
|
}): React.JSX.Element;
|
|
15
15
|
export type FeatureTesterProps = FeatureTesterCardOptions & {
|
|
16
16
|
config?: Config;
|
|
17
|
+
locale?: string;
|
|
17
18
|
} & ({
|
|
18
19
|
preloadedQuery: FeatureTesterPreloadedQuery;
|
|
19
20
|
familyName?: never;
|
|
@@ -60,7 +60,9 @@ function FeatureTesterLazyRenderer(_ref3) {
|
|
|
60
60
|
// (server-side preload path) or `{familyName, styleName}` (lazy path, used by
|
|
61
61
|
// the CDN custom element and inside an existing `<FontdueProvider>` tree).
|
|
62
62
|
export default function FeatureTester(props) {
|
|
63
|
+
var _props$preloadedQuery;
|
|
63
64
|
return /*#__PURE__*/React.createElement(EnsureFontdueContext, {
|
|
64
|
-
config: props.config
|
|
65
|
+
config: props.config,
|
|
66
|
+
locale: props.locale ?? ((_props$preloadedQuery = props.preloadedQuery) === null || _props$preloadedQuery === void 0 ? void 0 : _props$preloadedQuery.locale)
|
|
65
67
|
}, 'preloadedQuery' in props && props.preloadedQuery ? /*#__PURE__*/React.createElement(FeatureTesterPreloadedRenderer, props) : /*#__PURE__*/React.createElement(LazyQueryBoundary, null, /*#__PURE__*/React.createElement(FeatureTesterLazyRenderer, props)));
|
|
66
68
|
}
|
|
@@ -23,6 +23,8 @@ export default async function FeatureTester(props) {
|
|
|
23
23
|
const preloadedQuery = await loadSerializableQuery(FeatureTesterStandaloneQueryNode, {
|
|
24
24
|
familyName,
|
|
25
25
|
styleName
|
|
26
|
+
}, {
|
|
27
|
+
locale: rest.locale
|
|
26
28
|
});
|
|
27
29
|
return /*#__PURE__*/React.createElement(FeatureTesterPreloadedRenderer, _extends({
|
|
28
30
|
preloadedQuery: preloadedQuery
|
|
@@ -3,9 +3,10 @@ import { Store } from 'redux';
|
|
|
3
3
|
import { Config } from '../ConfigContext.js';
|
|
4
4
|
import { FontdueAction, FontdueState } from '../../reducer.js';
|
|
5
5
|
import { Components } from '../ComponentsContext.js';
|
|
6
|
-
export declare function EnsureFontdueContext({ children, config, }: {
|
|
6
|
+
export declare function EnsureFontdueContext({ children, config, locale, }: {
|
|
7
7
|
children: React.ReactNode;
|
|
8
8
|
config?: Config;
|
|
9
|
+
locale?: string;
|
|
9
10
|
}): React.JSX.Element;
|
|
10
11
|
export declare function LazyQueryBoundary({ children }: {
|
|
11
12
|
children: React.ReactNode;
|
|
@@ -17,5 +18,14 @@ export interface FontdueContextProvider_props {
|
|
|
17
18
|
config?: Config;
|
|
18
19
|
components?: Components;
|
|
19
20
|
store?: Store<FontdueState, FontdueAction>;
|
|
21
|
+
/**
|
|
22
|
+
* The language to show Fontdue content in, e.g. `de`. Sent as the
|
|
23
|
+
* `fontdue-locale` header on every request, used for number formatting,
|
|
24
|
+
* Stripe and reCAPTCHA, and gives the tree its own Relay environment. Unset
|
|
25
|
+
* (the default) asks for the foundry's default language, exactly as before.
|
|
26
|
+
* In the Next App Router, set it per page: a soft navigation re-renders only
|
|
27
|
+
* the page segment, not a provider in a shared layout.
|
|
28
|
+
*/
|
|
29
|
+
locale?: string;
|
|
20
30
|
}
|
|
21
|
-
export default function FontdueContextProvider({ children, url, stripeIntegration, config, components, store, }: FontdueContextProvider_props): React.JSX.Element;
|
|
31
|
+
export default function FontdueContextProvider({ children, url, stripeIntegration, config, components, store, locale: rawLocale, }: FontdueContextProvider_props): React.JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import React, { Suspense, createContext, useContext, useRef } from 'react';
|
|
3
|
+
import React, { Suspense, createContext, useContext, useMemo, useRef } from 'react';
|
|
4
4
|
import { Provider } from 'react-redux';
|
|
5
5
|
import { RelayEnvironmentProvider } from 'react-relay';
|
|
6
6
|
import { useCurrentEnvironment, fontdueBaseUrl } from '../../relay/environment.js';
|
|
@@ -8,9 +8,17 @@ import ConfigContext, { makeConfig, mergeConfig } from '../ConfigContext.js';
|
|
|
8
8
|
import { createDefaultStore } from '../../reducer.js';
|
|
9
9
|
import ComponentsContext from '../ComponentsContext.js';
|
|
10
10
|
import UrlContext from '../UrlContext.js';
|
|
11
|
+
import LocaleContext from '../LocaleContext.js';
|
|
12
|
+
import { normalizeLocale } from '../../locale.js';
|
|
11
13
|
import { setConnectionErrorUiEnabled } from '../../corsError.js';
|
|
12
14
|
import TypeTesterFamiliesProvider from '../TypeTester/TypeTesterFamilies.js';
|
|
13
15
|
|
|
16
|
+
// The options the surrounding provider created its Relay environment with, so
|
|
17
|
+
// a nested locale switch (LocaleOverride) can create its own language's
|
|
18
|
+
// environment against the same endpoint. Internal — do not export.
|
|
19
|
+
|
|
20
|
+
const EnvironmentOptionsContext = /*#__PURE__*/createContext({});
|
|
21
|
+
|
|
14
22
|
// Marker context used by self-wrapping components to detect a parent
|
|
15
23
|
// FontdueContextProvider/FontdueProvider. When the marker is `true`, a
|
|
16
24
|
// self-wrapping component skips its inner FontdueContextProvider so the
|
|
@@ -61,22 +69,67 @@ function ConfigOverride(_ref) {
|
|
|
61
69
|
// still unhydrated a minute after load (a click still works, since React
|
|
62
70
|
// hydrates the target on interaction, but nothing else does). Only the lazy
|
|
63
71
|
// renderers need a boundary; see LazyQueryBoundary.
|
|
72
|
+
//
|
|
73
|
+
// `locale` is the component's language: its own `locale` prop, else the
|
|
74
|
+
// locale its preloaded query was fetched in. Standalone, it picks the
|
|
75
|
+
// environment for that language. Inside a context in another language,
|
|
76
|
+
// LocaleOverride switches to that language's environment for this component
|
|
77
|
+
// only, so its data never lands in the outer language's store. Undefined
|
|
78
|
+
// inherits the surrounding locale.
|
|
64
79
|
export function EnsureFontdueContext(_ref2) {
|
|
65
80
|
let {
|
|
66
81
|
children,
|
|
67
|
-
config
|
|
82
|
+
config,
|
|
83
|
+
locale
|
|
68
84
|
} = _ref2;
|
|
69
85
|
const isInsideContext = useContext(FontdueContextMarker);
|
|
70
86
|
if (isInsideContext) {
|
|
71
|
-
|
|
87
|
+
const configured = config ? /*#__PURE__*/React.createElement(ConfigOverride, {
|
|
72
88
|
config: config
|
|
73
89
|
}, children) : /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
90
|
+
return /*#__PURE__*/React.createElement(LocaleOverride, {
|
|
91
|
+
locale: locale
|
|
92
|
+
}, configured);
|
|
74
93
|
}
|
|
75
94
|
return /*#__PURE__*/React.createElement(FontdueContextProvider, {
|
|
76
|
-
config: config
|
|
95
|
+
config: config,
|
|
96
|
+
locale: locale
|
|
77
97
|
}, children);
|
|
78
98
|
}
|
|
79
99
|
|
|
100
|
+
// Renders `children` against `locale`'s Relay environment when it differs
|
|
101
|
+
// from the surrounding one; otherwise a pass-through. The Redux store, config
|
|
102
|
+
// and everything else are inherited – only the language-specific data store
|
|
103
|
+
// changes.
|
|
104
|
+
function LocaleOverride(_ref3) {
|
|
105
|
+
let {
|
|
106
|
+
locale,
|
|
107
|
+
children
|
|
108
|
+
} = _ref3;
|
|
109
|
+
const current = useContext(LocaleContext);
|
|
110
|
+
const normalized = normalizeLocale(locale);
|
|
111
|
+
if (normalized === undefined || normalized === current) return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
112
|
+
return /*#__PURE__*/React.createElement(LocaleScope, {
|
|
113
|
+
locale: normalized
|
|
114
|
+
}, children);
|
|
115
|
+
}
|
|
116
|
+
function LocaleScope(_ref4) {
|
|
117
|
+
let {
|
|
118
|
+
locale,
|
|
119
|
+
children
|
|
120
|
+
} = _ref4;
|
|
121
|
+
const options = useContext(EnvironmentOptionsContext);
|
|
122
|
+
const environment = useCurrentEnvironment({
|
|
123
|
+
...options,
|
|
124
|
+
locale
|
|
125
|
+
});
|
|
126
|
+
return /*#__PURE__*/React.createElement(RelayEnvironmentProvider, {
|
|
127
|
+
environment: environment
|
|
128
|
+
}, /*#__PURE__*/React.createElement(LocaleContext.Provider, {
|
|
129
|
+
value: locale
|
|
130
|
+
}, children));
|
|
131
|
+
}
|
|
132
|
+
|
|
80
133
|
// The Suspense boundary for a component's *lazy* renderer — the branch taken
|
|
81
134
|
// when it's given an id or slug rather than a preloaded query, so it fetches
|
|
82
135
|
// its own data with useLazyLoadQuery (see the lazy-vs-preloaded guide). That
|
|
@@ -89,10 +142,10 @@ export function EnsureFontdueContext(_ref2) {
|
|
|
89
142
|
// renderers resolve synchronously and get no boundary, so their server HTML
|
|
90
143
|
// hydrates with the page as before. A null fallback keeps server HTML and the
|
|
91
144
|
// first client render identical.
|
|
92
|
-
export function LazyQueryBoundary(
|
|
145
|
+
export function LazyQueryBoundary(_ref5) {
|
|
93
146
|
let {
|
|
94
147
|
children
|
|
95
|
-
} =
|
|
148
|
+
} = _ref5;
|
|
96
149
|
return /*#__PURE__*/React.createElement(Suspense, {
|
|
97
150
|
fallback: null
|
|
98
151
|
}, children);
|
|
@@ -125,6 +178,16 @@ const IS_SERVER = typeof window === typeof undefined;
|
|
|
125
178
|
// follow this pattern. If it's purely deriving from props (no state), a
|
|
126
179
|
// vanilla `Context.Provider` is fine — each island will compute the same
|
|
127
180
|
// value.
|
|
181
|
+
//
|
|
182
|
+
// The Relay environment is a singleton *per locale*: `useCurrentEnvironment`
|
|
183
|
+
// keeps a `Map<locale, Environment>` (key '' for no locale), so every island
|
|
184
|
+
// configured with the same `locale` shares one environment, while a `de` and a
|
|
185
|
+
// default-language tree never share a store – Relay normalises records by id,
|
|
186
|
+
// and a German and an English `FontCollection:1` would overwrite each other.
|
|
187
|
+
// Each environment has its own QueryResponseCache for the same reason. The
|
|
188
|
+
// Redux store stays ONE singleton whatever the locale, so the cart is shared
|
|
189
|
+
// across islands and survives a language switch. The locale itself is plain
|
|
190
|
+
// derived state (LocaleContext, read with `useLocale()`).
|
|
128
191
|
let clientStore = null;
|
|
129
192
|
function useSharedStore(providedStore, config) {
|
|
130
193
|
const ref = useRef(null);
|
|
@@ -149,19 +212,26 @@ function useSharedStore(providedStore, config) {
|
|
|
149
212
|
// with no Location header, error.tsx never rendering (FD-1183 / FD-1074).
|
|
150
213
|
// Components that can suspend carry their own boundary via
|
|
151
214
|
// `EnsureFontdueContext`; the provider's aux UI has one in FontdueProvider.
|
|
152
|
-
export default function FontdueContextProvider(
|
|
215
|
+
export default function FontdueContextProvider(_ref6) {
|
|
153
216
|
let {
|
|
154
217
|
children,
|
|
155
218
|
url,
|
|
156
219
|
stripeIntegration,
|
|
157
220
|
config,
|
|
158
221
|
components,
|
|
159
|
-
store
|
|
160
|
-
|
|
222
|
+
store,
|
|
223
|
+
locale: rawLocale
|
|
224
|
+
} = _ref6;
|
|
225
|
+
const locale = normalizeLocale(rawLocale);
|
|
161
226
|
const environment = useCurrentEnvironment({
|
|
162
227
|
url,
|
|
163
|
-
stripeIntegration
|
|
228
|
+
stripeIntegration,
|
|
229
|
+
locale
|
|
164
230
|
});
|
|
231
|
+
const environmentOptions = useMemo(() => ({
|
|
232
|
+
url,
|
|
233
|
+
stripeIntegration
|
|
234
|
+
}), [url, stripeIntegration]);
|
|
165
235
|
const configValue = makeConfig(config);
|
|
166
236
|
// `corsErrorModal` is the legacy config name; it now gates the toolbar's
|
|
167
237
|
// connection-error status rather than a modal.
|
|
@@ -171,6 +241,10 @@ export default function FontdueContextProvider(_ref4) {
|
|
|
171
241
|
value: true
|
|
172
242
|
}, /*#__PURE__*/React.createElement(RelayEnvironmentProvider, {
|
|
173
243
|
environment: environment
|
|
244
|
+
}, /*#__PURE__*/React.createElement(EnvironmentOptionsContext.Provider, {
|
|
245
|
+
value: environmentOptions
|
|
246
|
+
}, /*#__PURE__*/React.createElement(LocaleContext.Provider, {
|
|
247
|
+
value: locale
|
|
174
248
|
}, /*#__PURE__*/React.createElement(Provider, {
|
|
175
249
|
store: sharedStore
|
|
176
250
|
}, /*#__PURE__*/React.createElement(RawConfigContext.Provider, {
|
|
@@ -181,5 +255,5 @@ export default function FontdueContextProvider(_ref4) {
|
|
|
181
255
|
value: url ?? fontdueBaseUrl() ?? ''
|
|
182
256
|
}, /*#__PURE__*/React.createElement(ComponentsContext.Provider, {
|
|
183
257
|
value: components ?? {}
|
|
184
|
-
}, /*#__PURE__*/React.createElement(TypeTesterFamiliesProvider, null, children))))))));
|
|
258
|
+
}, /*#__PURE__*/React.createElement(TypeTesterFamiliesProvider, null, children))))))))));
|
|
185
259
|
}
|