@doswiftly/storefront-sdk 15.1.0 → 16.0.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 +239 -0
- package/README.md +28 -0
- package/dist/core/cart/types.d.ts +1 -1
- package/dist/core/cart/types.d.ts.map +1 -1
- package/dist/core/format.d.ts +81 -46
- package/dist/core/format.d.ts.map +1 -1
- package/dist/core/format.js +116 -94
- package/dist/core/generated/operation-types.d.ts +75 -17
- package/dist/core/generated/operation-types.d.ts.map +1 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/operations/cart.d.ts.map +1 -1
- package/dist/core/operations/cart.js +11 -0
- package/dist/react/components/Money.d.ts +22 -8
- package/dist/react/components/Money.d.ts.map +1 -1
- package/dist/react/components/Money.js +16 -9
- package/dist/react/hooks/use-format.d.ts +85 -0
- package/dist/react/hooks/use-format.d.ts.map +1 -0
- package/dist/react/hooks/use-format.js +141 -0
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +2 -0
- package/package.json +1 -1
package/dist/core/index.d.ts
CHANGED
|
@@ -50,13 +50,13 @@ export { CartClient } from './cart/cart-client';
|
|
|
50
50
|
export type { CartMutationOutcome, CartCompleteOutcome } from './cart/cart-client';
|
|
51
51
|
export { CART_RECOVERABLE_ERROR_CODES, isCartRecoverableError, executeWithCartRecovery, createCartRecoveryRunner, CartRecoveryNotPossibleError, recreateWithInput, recreateWithLines, } from './cart/cart-recovery';
|
|
52
52
|
export type { CartRecoverableErrorCode, CartCookieStore, CartRecoveryOperation, CartRecoveryFailureReason, CartExpiredEvent, CartRecoveryRunner, CreateCartRecoveryRunnerOptions, ExecuteWithCartRecoveryOptions, } from './cart/cart-recovery';
|
|
53
|
-
export type { Cart, CartLine, CartLineConnection, ProductVariant, ProductVariantWeight, ImageThumbnail, PageInfo, AttributeSelection, CartLineCost, CartCost, CartBuyerIdentity, CartDiscountCode, CartDiscountAllocation, SelectedOption, Money, CartWarning, CartShippingMethod, CartAppliedGiftCard, CartSelectedPaymentMethod, Order, PaymentSession, CartLineInput, CartLineUpdateInput, CartCreateInput, CartBuyerIdentityInput, CartAttributeSelectionInput, CartAddressInput, CartSetShippingAddressInput, CartSetBillingAddressInput, CartSelectShippingMethodInput, CartSelectPaymentMethodInput, CartApplyGiftCardInput, CartRemoveGiftCardInput, CartUpdateGiftCardRecipientInput, CartCompleteInput, PaymentCreateInput, PaymentMethodType, PaymentInitiationFlow, PaymentErrorCode, CurrencyCode, CountryCode, LanguageCode, ProductTypeEnum, WeightUnit, CartWarningCode, AttributeType, AttributeFillingMode, AttributeBillingMode, AttributeOptionSurchargeType, StorefrontOrderStatus, OrderPaymentStatus, OrderFulfillmentStatus, DiscountValidationResult, DiscountInfo, DiscountValidationError, DiscountErrorCode, DiscountApplicationType, } from './cart/types';
|
|
53
|
+
export type { Cart, CartLine, CartLineConnection, ProductVariant, ProductVariantWeight, ImageThumbnail, PageInfo, AttributeSelection, CartLineCost, CartCost, CartBuyerIdentity, CartDiscountCode, CartDiscountAllocation, SelectedOption, Money, CartWarning, CartShippingMethod, CartAppliedGiftCard, CartSelectedPaymentMethod, Order, PaymentSession, PaymentMethod, AvailablePaymentMethods, AvailableShippingMethod, AvailableShippingMethodsPayload, DeliveryEstimate, ShippingCarrier, FreeShippingProgress, PickupPoint, CartLineInput, CartLineUpdateInput, CartCreateInput, CartBuyerIdentityInput, CartAttributeInput, CartAttributeSelectionInput, CartAddressInput, CartSetShippingAddressInput, CartSetBillingAddressInput, CartSelectShippingMethodInput, CartSelectPaymentMethodInput, CartApplyGiftCardInput, CartRemoveGiftCardInput, CartUpdateGiftCardRecipientInput, CartCompleteInput, PaymentCreateInput, ShippingAddressInput, PickupPointInput, DeliveryType, PaymentMethodType, PaymentInitiationFlow, PaymentErrorCode, CurrencyCode, CountryCode, LanguageCode, ProductTypeEnum, WeightUnit, CartWarningCode, AttributeType, AttributeFillingMode, AttributeBillingMode, AttributeOptionSurchargeType, StorefrontOrderStatus, OrderPaymentStatus, OrderFulfillmentStatus, DiscountValidationResult, DiscountInfo, DiscountValidationError, DiscountErrorCode, DiscountApplicationType, } from './cart/types';
|
|
54
54
|
export { AuthClient } from './auth/auth-client';
|
|
55
55
|
export type { Customer, CustomerAccessToken, MailingAddress, AuthResult, CustomerCreateInput, EmailMarketingState, MarketingOptInLevel, } from './auth/types';
|
|
56
56
|
export { assertNoUserErrors } from './helpers/assert-no-user-errors';
|
|
57
57
|
export { sanitizeHtml } from './helpers/sanitize-html';
|
|
58
58
|
export { normalizeConnection, type Connection, type ConnectionEdge, type ConnectionPageInfo, type NormalizedConnection, } from './helpers/normalize-connection';
|
|
59
|
-
export { formatPrice, formatPriceRange, formatAmount, formatDate, formatDateTime, formatNumber, formatPercentage, getCurrencySymbol,
|
|
59
|
+
export { formatPrice, formatPriceRange, formatAmount, formatDate, formatDateTime, formatNumber, formatPercentage, getCurrencySymbol, type PriceMoney, } from './format';
|
|
60
60
|
export { AUTH_COOKIE_NAME, AUTH_COOKIE_DEFAULTS, type AuthCookieConfig, } from './auth/cookie-config';
|
|
61
61
|
export { LANGUAGE_COOKIE_NAME, LANGUAGE_COOKIE_MAX_AGE, LANGUAGE_HEADER_NAME } from './language/cookie-config';
|
|
62
62
|
export { CURRENCY_COOKIE_NAME, CURRENCY_COOKIE_MAX_AGE, CURRENCY_HEADER_NAME } from './currency/cookie-config';
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAGH,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAGhE,YAAY,EACV,gBAAgB,EAChB,sBAAsB,EACtB,UAAU,EACV,SAAS,EACT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0B,CAAC;AAG/G,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAG/G,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAG7E,OAAO,EAAE,YAAY,EAAE,KAAK,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAGzE,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,EACnB,wBAAwB,EACxB,6BAA6B,GAC9B,MAAM,iBAAiB,CAAC;AAGzB,YAAY,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAG/E,OAAO,EAAE,qBAAqB,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGlF,OAAO,EAAE,KAAK,SAAS,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAG7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/core/index.js
CHANGED
|
@@ -61,7 +61,7 @@ export { assertNoUserErrors } from './helpers/assert-no-user-errors';
|
|
|
61
61
|
export { sanitizeHtml } from './helpers/sanitize-html';
|
|
62
62
|
export { normalizeConnection, } from './helpers/normalize-connection';
|
|
63
63
|
// Format utilities
|
|
64
|
-
export { formatPrice, formatPriceRange, formatAmount, formatDate, formatDateTime, formatNumber, formatPercentage, getCurrencySymbol,
|
|
64
|
+
export { formatPrice, formatPriceRange, formatAmount, formatDate, formatDateTime, formatNumber, formatPercentage, getCurrencySymbol, } from './format';
|
|
65
65
|
// Auth cookie config (platform contract)
|
|
66
66
|
export { AUTH_COOKIE_NAME, AUTH_COOKIE_DEFAULTS, } from './auth/cookie-config';
|
|
67
67
|
// Language config
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cart.d.ts","sourceRoot":"","sources":["../../../src/core/operations/cart.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;
|
|
1
|
+
{"version":3,"file":"cart.d.ts","sourceRoot":"","sources":["../../../src/core/operations/cart.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAqYH,eAAO,MAAM,UAAU,QAOrB,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,qCAAqC,QAehD,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,QAO1C,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,QAO/B,CAAC;AAMH,eAAO,MAAM,WAAW,QAWtB,CAAC;AAEH,eAAO,MAAM,cAAc,QAWzB,CAAC;AAEH,eAAO,MAAM,iBAAiB,QAW5B,CAAC;AAEH,eAAO,MAAM,iBAAiB,QAW5B,CAAC;AAEH,eAAO,MAAM,0BAA0B,QAWrC,CAAC;AAEH,eAAO,MAAM,gBAAgB,QAW3B,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,QAWjC,CAAC;AAEH,eAAO,MAAM,0BAA0B,QAWrC,CAAC;AAMH,eAAO,MAAM,yBAAyB,QAWpC,CAAC;AAEH,eAAO,MAAM,wBAAwB,QAWnC,CAAC;AAEH,eAAO,MAAM,2BAA2B,QAWtC,CAAC;AAEH,eAAO,MAAM,0BAA0B,QAWrC,CAAC;AAEH,eAAO,MAAM,oBAAoB,QAW/B,CAAC;AAEH,eAAO,MAAM,qBAAqB,QAWhC,CAAC;AAEH,eAAO,MAAM,+BAA+B,QAW1C,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,QAWxB,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,cAAc,QASzB,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,2BAA2B,QAoBtC,CAAC"}
|
|
@@ -74,6 +74,8 @@ const CART_COST_FRAGMENT = `
|
|
|
74
74
|
totalTax { ...Money }
|
|
75
75
|
totalDuty { ...Money }
|
|
76
76
|
checkoutCharge { ...Money }
|
|
77
|
+
totalDiscount { ...Money }
|
|
78
|
+
totalShipping { ...Money }
|
|
77
79
|
}
|
|
78
80
|
`;
|
|
79
81
|
const CART_LINE_COST_FRAGMENT = `
|
|
@@ -224,6 +226,15 @@ const CART_FRAGMENT = `
|
|
|
224
226
|
requiresShipping
|
|
225
227
|
createdAt
|
|
226
228
|
updatedAt
|
|
229
|
+
status
|
|
230
|
+
completedOrder {
|
|
231
|
+
id
|
|
232
|
+
orderNumber
|
|
233
|
+
accessToken
|
|
234
|
+
status
|
|
235
|
+
paymentStatus
|
|
236
|
+
fulfillmentStatus
|
|
237
|
+
}
|
|
227
238
|
}
|
|
228
239
|
${CART_COST_FRAGMENT}
|
|
229
240
|
${CART_LINE_FRAGMENT}
|
|
@@ -3,16 +3,23 @@
|
|
|
3
3
|
* formatted string. Wraps `formatPrice` from core so consumers don't need to
|
|
4
4
|
* import the formatter manually.
|
|
5
5
|
*
|
|
6
|
-
* Headless: no styling, no
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* (
|
|
6
|
+
* Headless: no styling, no Context dependency. `currency` is required —
|
|
7
|
+
* render explicitly from your cart/product/shop data. `locale` is optional;
|
|
8
|
+
* pass it for deterministic output, or omit it to let the component fall
|
|
9
|
+
* back to the runtime default (`navigator.language` in browsers, `LANG` in
|
|
10
|
+
* Node). This keeps the component usable both inside `<StorefrontProvider>`
|
|
11
|
+
* and in isolated rendering (server components, e-mail templates, PDFs).
|
|
12
|
+
*
|
|
13
|
+
* Need the locale to follow the storefront's i18n state without passing it
|
|
14
|
+
* to every `<Money>`? Use `useFormatPrice()` from `@doswiftly/storefront-sdk/react`
|
|
15
|
+
* — it pulls the active language from `useLanguageStore` and returns a
|
|
16
|
+
* memoised `formatPrice` function.
|
|
10
17
|
*
|
|
11
18
|
* @example
|
|
12
19
|
* ```tsx
|
|
13
|
-
* <Money amount={9990} currency="PLN" />
|
|
14
|
-
* <Money amount={1295} currency="USD" />
|
|
15
|
-
* <Money amount={0} currency="EUR" />
|
|
20
|
+
* <Money amount={9990} currency="PLN" locale="pl-PL" /> // → "99,90 zł"
|
|
21
|
+
* <Money amount={1295} currency="USD" locale="en-US" /> // → "$12.95"
|
|
22
|
+
* <Money amount={0} currency="EUR" locale="de-DE" /> // → "0,00 €"
|
|
16
23
|
* ```
|
|
17
24
|
*/
|
|
18
25
|
export interface MoneyProps {
|
|
@@ -20,6 +27,13 @@ export interface MoneyProps {
|
|
|
20
27
|
amount: number;
|
|
21
28
|
/** ISO 4217 currency code (PLN, EUR, USD, …). Required — no implicit default. */
|
|
22
29
|
currency: string;
|
|
30
|
+
/**
|
|
31
|
+
* BCP 47 locale tag (`'pl-PL'`, `'en-US'`, `'de-DE'`, …). Drives the symbol
|
|
32
|
+
* placement, decimal mark, and grouping separator. When omitted, the runtime
|
|
33
|
+
* default is used (`navigator.language` in browsers, `LANG` in Node) — pass
|
|
34
|
+
* an explicit locale for deterministic output.
|
|
35
|
+
*/
|
|
36
|
+
locale?: string;
|
|
23
37
|
/** Optional class for styling — keeps the component headless. */
|
|
24
38
|
className?: string;
|
|
25
39
|
/**
|
|
@@ -28,5 +42,5 @@ export interface MoneyProps {
|
|
|
28
42
|
*/
|
|
29
43
|
as?: 'span' | 'div' | 'p' | 'strong' | 'em' | 'output';
|
|
30
44
|
}
|
|
31
|
-
export declare function Money({ amount, currency, className, as: As }: MoneyProps): import("react/jsx-runtime").JSX.Element;
|
|
45
|
+
export declare function Money({ amount, currency, locale, className, as: As }: MoneyProps): import("react/jsx-runtime").JSX.Element;
|
|
32
46
|
//# sourceMappingURL=Money.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Money.d.ts","sourceRoot":"","sources":["../../../src/react/components/Money.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"Money.d.ts","sourceRoot":"","sources":["../../../src/react/components/Money.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAMH,MAAM,WAAW,UAAU;IACzB,+DAA+D;IAC/D,MAAM,EAAE,MAAM,CAAC;IACf,iFAAiF;IACjF,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,EAAE,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,GAAG,GAAG,QAAQ,GAAG,IAAI,GAAG,QAAQ,CAAC;CACxD;AAED,wBAAgB,KAAK,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE,EAAW,EAAE,EAAE,UAAU,2CASzF"}
|
|
@@ -3,25 +3,32 @@
|
|
|
3
3
|
* formatted string. Wraps `formatPrice` from core so consumers don't need to
|
|
4
4
|
* import the formatter manually.
|
|
5
5
|
*
|
|
6
|
-
* Headless: no styling, no
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* (
|
|
6
|
+
* Headless: no styling, no Context dependency. `currency` is required —
|
|
7
|
+
* render explicitly from your cart/product/shop data. `locale` is optional;
|
|
8
|
+
* pass it for deterministic output, or omit it to let the component fall
|
|
9
|
+
* back to the runtime default (`navigator.language` in browsers, `LANG` in
|
|
10
|
+
* Node). This keeps the component usable both inside `<StorefrontProvider>`
|
|
11
|
+
* and in isolated rendering (server components, e-mail templates, PDFs).
|
|
12
|
+
*
|
|
13
|
+
* Need the locale to follow the storefront's i18n state without passing it
|
|
14
|
+
* to every `<Money>`? Use `useFormatPrice()` from `@doswiftly/storefront-sdk/react`
|
|
15
|
+
* — it pulls the active language from `useLanguageStore` and returns a
|
|
16
|
+
* memoised `formatPrice` function.
|
|
10
17
|
*
|
|
11
18
|
* @example
|
|
12
19
|
* ```tsx
|
|
13
|
-
* <Money amount={9990} currency="PLN" />
|
|
14
|
-
* <Money amount={1295} currency="USD" />
|
|
15
|
-
* <Money amount={0} currency="EUR" />
|
|
20
|
+
* <Money amount={9990} currency="PLN" locale="pl-PL" /> // → "99,90 zł"
|
|
21
|
+
* <Money amount={1295} currency="USD" locale="en-US" /> // → "$12.95"
|
|
22
|
+
* <Money amount={0} currency="EUR" locale="de-DE" /> // → "0,00 €"
|
|
16
23
|
* ```
|
|
17
24
|
*/
|
|
18
25
|
'use client';
|
|
19
26
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
20
27
|
import { formatPrice } from '../../core/format';
|
|
21
|
-
export function Money({ amount, currency, className, as: As = 'span' }) {
|
|
28
|
+
export function Money({ amount, currency, locale, className, as: As = 'span' }) {
|
|
22
29
|
const formatted = formatPrice({
|
|
23
30
|
amount: (amount / 100).toString(),
|
|
24
31
|
currencyCode: currency,
|
|
25
|
-
});
|
|
32
|
+
}, locale);
|
|
26
33
|
return _jsx(As, { className: className, children: formatted });
|
|
27
34
|
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convenience hooks that pull the active language from `<StorefrontProvider>`
|
|
3
|
+
* and forward it to the core format utilities. Use these inside the provider
|
|
4
|
+
* tree for boilerplate-free locale-aware formatting; outside the provider,
|
|
5
|
+
* fall back to the vanilla `formatPrice` / `formatDate` / etc. from
|
|
6
|
+
* `@doswiftly/storefront-sdk` with an explicit `locale` argument.
|
|
7
|
+
*
|
|
8
|
+
* Each hook returns a memoised function so it's safe to use directly in
|
|
9
|
+
* render. The function accepts an optional final `localeOverride` argument
|
|
10
|
+
* that wins over the store value — handy for per-call overrides (e.g. a
|
|
11
|
+
* "show in US format" toggle on one element while the rest of the UI stays
|
|
12
|
+
* in Polish).
|
|
13
|
+
*
|
|
14
|
+
* Resolution order per call:
|
|
15
|
+
* 1. `localeOverride` argument (highest)
|
|
16
|
+
* 2. `useLanguageStore().language` from `<StorefrontProvider>`
|
|
17
|
+
* 3. Runtime default (`Intl.NumberFormat().resolvedOptions().locale`)
|
|
18
|
+
*/
|
|
19
|
+
import { type PriceMoney } from '../../core/format';
|
|
20
|
+
/**
|
|
21
|
+
* Memoised `formatPrice` bound to the active language from `<StorefrontProvider>`.
|
|
22
|
+
* Pass `localeOverride` as the second argument to override the store value for
|
|
23
|
+
* a single call.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* const formatPrice = useFormatPrice();
|
|
27
|
+
* return <span>{formatPrice(item.price)}</span>;
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* // Per-call override:
|
|
31
|
+
* const formatPrice = useFormatPrice();
|
|
32
|
+
* <span>{formatPrice(item.price, 'en-US')}</span>
|
|
33
|
+
*/
|
|
34
|
+
export declare function useFormatPrice(): (price: PriceMoney | null | undefined, localeOverride?: string) => string;
|
|
35
|
+
/**
|
|
36
|
+
* Memoised `formatAmount` bound to the active language from `<StorefrontProvider>`.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* const formatAmount = useFormatAmount();
|
|
40
|
+
* return <span>{formatAmount(item.totalPrice.amount, item.totalPrice.currencyCode)}</span>;
|
|
41
|
+
*/
|
|
42
|
+
export declare function useFormatAmount(): (amount: string | number, currencyCode: string, localeOverride?: string) => string;
|
|
43
|
+
/**
|
|
44
|
+
* Memoised `formatPriceRange` bound to the active language from `<StorefrontProvider>`.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* const formatPriceRange = useFormatPriceRange();
|
|
48
|
+
* return <span>{formatPriceRange(min, max)}</span>;
|
|
49
|
+
*/
|
|
50
|
+
export declare function useFormatPriceRange(): (minPrice: PriceMoney, maxPrice: PriceMoney, localeOverride?: string) => string;
|
|
51
|
+
/**
|
|
52
|
+
* Memoised `formatDate` bound to the active language from `<StorefrontProvider>`.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* const formatDate = useFormatDate();
|
|
56
|
+
* return <span>{formatDate(order.processedAt)}</span>;
|
|
57
|
+
*/
|
|
58
|
+
export declare function useFormatDate(): (date: Date | string, localeOverride?: string) => string;
|
|
59
|
+
/**
|
|
60
|
+
* Memoised `formatDateTime` bound to the active language from `<StorefrontProvider>`.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* const formatDateTime = useFormatDateTime();
|
|
64
|
+
* return <span>{formatDateTime(event.timestamp)}</span>;
|
|
65
|
+
*/
|
|
66
|
+
export declare function useFormatDateTime(): (date: Date | string, localeOverride?: string) => string;
|
|
67
|
+
/**
|
|
68
|
+
* Memoised `formatNumber` bound to the active language from `<StorefrontProvider>`.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* const formatNumber = useFormatNumber();
|
|
72
|
+
* return <span>{formatNumber(points.balance)}</span>;
|
|
73
|
+
*/
|
|
74
|
+
export declare function useFormatNumber(): (num: number, localeOverride?: string) => string;
|
|
75
|
+
/**
|
|
76
|
+
* Memoised `getCurrencySymbol` bound to the active language from
|
|
77
|
+
* `<StorefrontProvider>`. The returned symbol is locale-dependent — see
|
|
78
|
+
* `getCurrencySymbol` in core for examples.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* const getCurrencySymbol = useGetCurrencySymbol();
|
|
82
|
+
* return <span>{getCurrencySymbol(shop.currencyCode)}</span>;
|
|
83
|
+
*/
|
|
84
|
+
export declare function useGetCurrencySymbol(): (code: string, localeOverride?: string) => string;
|
|
85
|
+
//# sourceMappingURL=use-format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-format.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/use-format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAMH,OAAO,EAQL,KAAK,UAAU,EAChB,MAAM,mBAAmB,CAAC;AA8B3B;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,IAAI,CAChC,KAAK,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,EACpC,cAAc,CAAC,EAAE,MAAM,KACpB,MAAM,CAMV;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,IAAI,CACjC,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,YAAY,EAAE,MAAM,EACpB,cAAc,CAAC,EAAE,MAAM,KACpB,MAAM,CAOV;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,IAAI,CACrC,QAAQ,EAAE,UAAU,EACpB,QAAQ,EAAE,UAAU,EACpB,cAAc,CAAC,EAAE,MAAM,KACpB,MAAM,CAOV;AAMD;;;;;;GAMG;AACH,wBAAgB,aAAa,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,KAAK,MAAM,CAMxF;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,IAAI,CACnC,IAAI,EAAE,IAAI,GAAG,MAAM,EACnB,cAAc,CAAC,EAAE,MAAM,KACpB,MAAM,CAMV;AAMD;;;;;;GAMG;AACH,wBAAgB,eAAe,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,KAAK,MAAM,CAMlF;AAMD;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,KAAK,MAAM,CAMxF"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convenience hooks that pull the active language from `<StorefrontProvider>`
|
|
3
|
+
* and forward it to the core format utilities. Use these inside the provider
|
|
4
|
+
* tree for boilerplate-free locale-aware formatting; outside the provider,
|
|
5
|
+
* fall back to the vanilla `formatPrice` / `formatDate` / etc. from
|
|
6
|
+
* `@doswiftly/storefront-sdk` with an explicit `locale` argument.
|
|
7
|
+
*
|
|
8
|
+
* Each hook returns a memoised function so it's safe to use directly in
|
|
9
|
+
* render. The function accepts an optional final `localeOverride` argument
|
|
10
|
+
* that wins over the store value — handy for per-call overrides (e.g. a
|
|
11
|
+
* "show in US format" toggle on one element while the rest of the UI stays
|
|
12
|
+
* in Polish).
|
|
13
|
+
*
|
|
14
|
+
* Resolution order per call:
|
|
15
|
+
* 1. `localeOverride` argument (highest)
|
|
16
|
+
* 2. `useLanguageStore().language` from `<StorefrontProvider>`
|
|
17
|
+
* 3. Runtime default (`Intl.NumberFormat().resolvedOptions().locale`)
|
|
18
|
+
*/
|
|
19
|
+
'use client';
|
|
20
|
+
import { useCallback } from 'react';
|
|
21
|
+
import { useLanguageStore } from '../stores/store-context';
|
|
22
|
+
import { formatPrice as coreFormatPrice, formatAmount as coreFormatAmount, formatPriceRange as coreFormatPriceRange, formatDate as coreFormatDate, formatDateTime as coreFormatDateTime, formatNumber as coreFormatNumber, getCurrencySymbol as coreGetCurrencySymbol, } from '../../core/format';
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
// Locale resolution
|
|
25
|
+
// ---------------------------------------------------------------------------
|
|
26
|
+
let runtimeLocaleCache;
|
|
27
|
+
function getRuntimeLocale() {
|
|
28
|
+
if (runtimeLocaleCache === undefined) {
|
|
29
|
+
runtimeLocaleCache = new Intl.NumberFormat().resolvedOptions().locale;
|
|
30
|
+
}
|
|
31
|
+
return runtimeLocaleCache;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Read the active language from `useLanguageStore` and fall back to the
|
|
35
|
+
* runtime default when the store hasn't been initialised yet (e.g. before the
|
|
36
|
+
* first Shop query has resolved). Internal helper for every convenience hook
|
|
37
|
+
* in this file — the selector-based subscription means consumers only
|
|
38
|
+
* re-render when the language actually changes.
|
|
39
|
+
*/
|
|
40
|
+
function useResolvedLocale() {
|
|
41
|
+
const language = useLanguageStore((s) => s.language);
|
|
42
|
+
return language ?? getRuntimeLocale();
|
|
43
|
+
}
|
|
44
|
+
// ---------------------------------------------------------------------------
|
|
45
|
+
// Price formatters
|
|
46
|
+
// ---------------------------------------------------------------------------
|
|
47
|
+
/**
|
|
48
|
+
* Memoised `formatPrice` bound to the active language from `<StorefrontProvider>`.
|
|
49
|
+
* Pass `localeOverride` as the second argument to override the store value for
|
|
50
|
+
* a single call.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* const formatPrice = useFormatPrice();
|
|
54
|
+
* return <span>{formatPrice(item.price)}</span>;
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* // Per-call override:
|
|
58
|
+
* const formatPrice = useFormatPrice();
|
|
59
|
+
* <span>{formatPrice(item.price, 'en-US')}</span>
|
|
60
|
+
*/
|
|
61
|
+
export function useFormatPrice() {
|
|
62
|
+
const locale = useResolvedLocale();
|
|
63
|
+
return useCallback((price, localeOverride) => coreFormatPrice(price, localeOverride ?? locale), [locale]);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Memoised `formatAmount` bound to the active language from `<StorefrontProvider>`.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* const formatAmount = useFormatAmount();
|
|
70
|
+
* return <span>{formatAmount(item.totalPrice.amount, item.totalPrice.currencyCode)}</span>;
|
|
71
|
+
*/
|
|
72
|
+
export function useFormatAmount() {
|
|
73
|
+
const locale = useResolvedLocale();
|
|
74
|
+
return useCallback((amount, currencyCode, localeOverride) => coreFormatAmount(amount, currencyCode, localeOverride ?? locale), [locale]);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Memoised `formatPriceRange` bound to the active language from `<StorefrontProvider>`.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* const formatPriceRange = useFormatPriceRange();
|
|
81
|
+
* return <span>{formatPriceRange(min, max)}</span>;
|
|
82
|
+
*/
|
|
83
|
+
export function useFormatPriceRange() {
|
|
84
|
+
const locale = useResolvedLocale();
|
|
85
|
+
return useCallback((minPrice, maxPrice, localeOverride) => coreFormatPriceRange(minPrice, maxPrice, localeOverride ?? locale), [locale]);
|
|
86
|
+
}
|
|
87
|
+
// ---------------------------------------------------------------------------
|
|
88
|
+
// Date formatters
|
|
89
|
+
// ---------------------------------------------------------------------------
|
|
90
|
+
/**
|
|
91
|
+
* Memoised `formatDate` bound to the active language from `<StorefrontProvider>`.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* const formatDate = useFormatDate();
|
|
95
|
+
* return <span>{formatDate(order.processedAt)}</span>;
|
|
96
|
+
*/
|
|
97
|
+
export function useFormatDate() {
|
|
98
|
+
const locale = useResolvedLocale();
|
|
99
|
+
return useCallback((date, localeOverride) => coreFormatDate(date, localeOverride ?? locale), [locale]);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Memoised `formatDateTime` bound to the active language from `<StorefrontProvider>`.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* const formatDateTime = useFormatDateTime();
|
|
106
|
+
* return <span>{formatDateTime(event.timestamp)}</span>;
|
|
107
|
+
*/
|
|
108
|
+
export function useFormatDateTime() {
|
|
109
|
+
const locale = useResolvedLocale();
|
|
110
|
+
return useCallback((date, localeOverride) => coreFormatDateTime(date, localeOverride ?? locale), [locale]);
|
|
111
|
+
}
|
|
112
|
+
// ---------------------------------------------------------------------------
|
|
113
|
+
// Number formatters
|
|
114
|
+
// ---------------------------------------------------------------------------
|
|
115
|
+
/**
|
|
116
|
+
* Memoised `formatNumber` bound to the active language from `<StorefrontProvider>`.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* const formatNumber = useFormatNumber();
|
|
120
|
+
* return <span>{formatNumber(points.balance)}</span>;
|
|
121
|
+
*/
|
|
122
|
+
export function useFormatNumber() {
|
|
123
|
+
const locale = useResolvedLocale();
|
|
124
|
+
return useCallback((num, localeOverride) => coreFormatNumber(num, localeOverride ?? locale), [locale]);
|
|
125
|
+
}
|
|
126
|
+
// ---------------------------------------------------------------------------
|
|
127
|
+
// Currency symbol
|
|
128
|
+
// ---------------------------------------------------------------------------
|
|
129
|
+
/**
|
|
130
|
+
* Memoised `getCurrencySymbol` bound to the active language from
|
|
131
|
+
* `<StorefrontProvider>`. The returned symbol is locale-dependent — see
|
|
132
|
+
* `getCurrencySymbol` in core for examples.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* const getCurrencySymbol = useGetCurrencySymbol();
|
|
136
|
+
* return <span>{getCurrencySymbol(shop.currencyCode)}</span>;
|
|
137
|
+
*/
|
|
138
|
+
export function useGetCurrencySymbol() {
|
|
139
|
+
const locale = useResolvedLocale();
|
|
140
|
+
return useCallback((code, localeOverride) => coreGetCurrencySymbol(code, localeOverride ?? locale), [locale]);
|
|
141
|
+
}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export { getCookie, setCookie, deleteCookie, getCurrencyFromCookieAsync, getCart
|
|
|
36
36
|
export { useBotProtection } from './hooks/use-bot-protection';
|
|
37
37
|
export { useHydrated } from './hooks/use-hydrated';
|
|
38
38
|
export { useDebouncedValue } from './hooks/use-debounced-value';
|
|
39
|
+
export { useFormatPrice, useFormatAmount, useFormatPriceRange, useFormatDate, useFormatDateTime, useFormatNumber, useGetCurrencySymbol, } from './hooks/use-format';
|
|
39
40
|
export { createCartStore, selectCartId, selectIsCartOpen, selectCartIsLoading, } from './stores/cart.store';
|
|
40
41
|
export type { CartState, CartStoreConfig, CartActions, CartData, CartMutationAction, CartLineInput, CartLineUpdateInput, } from './stores/cart.store';
|
|
41
42
|
export { CartProvider, useCartStore, useCartStoreApi } from './stores/cart.context';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,kBAAkB,EAAE,KAAK,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AACnG,OAAO,EAAE,wBAAwB,EAAE,KAAK,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AACtH,OAAO,EAAE,gBAAgB,EAAE,KAAK,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAC7F,OAAO,EAAE,gBAAgB,EAAE,KAAK,qBAAqB,EAAE,MAAM,+BAA+B,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cAAc,CAAC"}
|
package/dist/react/index.js
CHANGED
|
@@ -39,6 +39,8 @@ export { useBotProtection } from './hooks/use-bot-protection';
|
|
|
39
39
|
// Generic hooks
|
|
40
40
|
export { useHydrated } from './hooks/use-hydrated';
|
|
41
41
|
export { useDebouncedValue } from './hooks/use-debounced-value';
|
|
42
|
+
// Format hooks (Context-driven — pull locale from `useLanguageStore`)
|
|
43
|
+
export { useFormatPrice, useFormatAmount, useFormatPriceRange, useFormatDate, useFormatDateTime, useFormatNumber, useGetCurrencySymbol, } from './hooks/use-format';
|
|
42
44
|
// Cart store (DI-based)
|
|
43
45
|
export { createCartStore, selectCartId, selectIsCartOpen, selectCartIsLoading, } from './stores/cart.store';
|
|
44
46
|
export { CartProvider, useCartStore, useCartStoreApi } from './stores/cart.context';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@doswiftly/storefront-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "16.0.0",
|
|
4
4
|
"description": "Storefront runtime SDK for DoSwiftly Commerce — layered transport, middleware pipeline, React providers, Zustand stores, cache strategies. 0 runtime dependencies in core.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|