@usethrottle/checkout-react 2.1.1 → 2.2.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/README.md +7 -0
- package/dist/index.cjs +26 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -6
- package/dist/index.d.ts +14 -6
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { CSSProperties, RefObject, ReactNode } from 'react';
|
|
3
|
+
import { CurrencyCode } from '@usethrottle/money';
|
|
4
|
+
import * as money from '@usethrottle/money';
|
|
5
|
+
export { money };
|
|
6
|
+
export { CURRENCIES, CurrencyCode, MoneyValue, UnknownCurrencyError, currencySymbol, formatMoney, isKnownCurrency, minorUnitsOf, moneyValue, parseMoney, toDecimalString, toMinor } from '@usethrottle/money';
|
|
3
7
|
import { CartSessionCart, AddLineItemInput, UpdateLineItemInput, SelectShippingInput, CheckoutHandoffInput, CheckoutHandoff, SelectedShipping } from '@usethrottle/cart';
|
|
4
8
|
|
|
5
9
|
/**
|
|
@@ -42,7 +46,7 @@ type ThrottleEvent = {
|
|
|
42
46
|
subscriptionIds?: string[];
|
|
43
47
|
/** v1.4 additive — order total in minor units, for analytics purchase events. */
|
|
44
48
|
total?: number;
|
|
45
|
-
currency?:
|
|
49
|
+
currency?: CurrencyCode;
|
|
46
50
|
lineItems?: ThrottleCompletedLineItem[];
|
|
47
51
|
} | {
|
|
48
52
|
type: 'throttle.cancelled';
|
|
@@ -151,9 +155,13 @@ interface ThrottleEmbedProps {
|
|
|
151
155
|
subscriptionId?: string;
|
|
152
156
|
/** Every subscription the checkout created, in line order. `subscriptionId` is set only when there is exactly one. */
|
|
153
157
|
subscriptionIds?: string[];
|
|
154
|
-
/**
|
|
158
|
+
/**
|
|
159
|
+
* Order total in minor units — fire `gtag`/`fbq` purchase events with
|
|
160
|
+
* value = `toDecimalString(total, currency)` (the currency's own exponent:
|
|
161
|
+
* JPY has none, KWD has three).
|
|
162
|
+
*/
|
|
155
163
|
total?: number;
|
|
156
|
-
currency?:
|
|
164
|
+
currency?: CurrencyCode;
|
|
157
165
|
lineItems?: ThrottleCompletedLineItem[];
|
|
158
166
|
}) => void;
|
|
159
167
|
onFailed?: (evt: {
|
|
@@ -289,7 +297,7 @@ declare function useCartSession(options: UseCartSessionOptions): UseCartSessionR
|
|
|
289
297
|
*/
|
|
290
298
|
type ThrottleCheckoutStatus = 'idle' | 'loading' | 'recovering' | 'ready' | 'error';
|
|
291
299
|
interface CheckoutTotals {
|
|
292
|
-
currency:
|
|
300
|
+
currency: CurrencyCode;
|
|
293
301
|
subtotal: number;
|
|
294
302
|
discountTotal: number;
|
|
295
303
|
shippingTotal: number;
|
|
@@ -566,9 +574,9 @@ interface SecureCardCompleteResult {
|
|
|
566
574
|
orderId: string;
|
|
567
575
|
orderNumber: string;
|
|
568
576
|
paymentId: string;
|
|
569
|
-
/** Minor units
|
|
577
|
+
/** Minor units of `currency`. */
|
|
570
578
|
total: number;
|
|
571
|
-
currency:
|
|
579
|
+
currency: CurrencyCode;
|
|
572
580
|
status: string;
|
|
573
581
|
paymentStatus: string;
|
|
574
582
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { CSSProperties, RefObject, ReactNode } from 'react';
|
|
3
|
+
import { CurrencyCode } from '@usethrottle/money';
|
|
4
|
+
import * as money from '@usethrottle/money';
|
|
5
|
+
export { money };
|
|
6
|
+
export { CURRENCIES, CurrencyCode, MoneyValue, UnknownCurrencyError, currencySymbol, formatMoney, isKnownCurrency, minorUnitsOf, moneyValue, parseMoney, toDecimalString, toMinor } from '@usethrottle/money';
|
|
3
7
|
import { CartSessionCart, AddLineItemInput, UpdateLineItemInput, SelectShippingInput, CheckoutHandoffInput, CheckoutHandoff, SelectedShipping } from '@usethrottle/cart';
|
|
4
8
|
|
|
5
9
|
/**
|
|
@@ -42,7 +46,7 @@ type ThrottleEvent = {
|
|
|
42
46
|
subscriptionIds?: string[];
|
|
43
47
|
/** v1.4 additive — order total in minor units, for analytics purchase events. */
|
|
44
48
|
total?: number;
|
|
45
|
-
currency?:
|
|
49
|
+
currency?: CurrencyCode;
|
|
46
50
|
lineItems?: ThrottleCompletedLineItem[];
|
|
47
51
|
} | {
|
|
48
52
|
type: 'throttle.cancelled';
|
|
@@ -151,9 +155,13 @@ interface ThrottleEmbedProps {
|
|
|
151
155
|
subscriptionId?: string;
|
|
152
156
|
/** Every subscription the checkout created, in line order. `subscriptionId` is set only when there is exactly one. */
|
|
153
157
|
subscriptionIds?: string[];
|
|
154
|
-
/**
|
|
158
|
+
/**
|
|
159
|
+
* Order total in minor units — fire `gtag`/`fbq` purchase events with
|
|
160
|
+
* value = `toDecimalString(total, currency)` (the currency's own exponent:
|
|
161
|
+
* JPY has none, KWD has three).
|
|
162
|
+
*/
|
|
155
163
|
total?: number;
|
|
156
|
-
currency?:
|
|
164
|
+
currency?: CurrencyCode;
|
|
157
165
|
lineItems?: ThrottleCompletedLineItem[];
|
|
158
166
|
}) => void;
|
|
159
167
|
onFailed?: (evt: {
|
|
@@ -289,7 +297,7 @@ declare function useCartSession(options: UseCartSessionOptions): UseCartSessionR
|
|
|
289
297
|
*/
|
|
290
298
|
type ThrottleCheckoutStatus = 'idle' | 'loading' | 'recovering' | 'ready' | 'error';
|
|
291
299
|
interface CheckoutTotals {
|
|
292
|
-
currency:
|
|
300
|
+
currency: CurrencyCode;
|
|
293
301
|
subtotal: number;
|
|
294
302
|
discountTotal: number;
|
|
295
303
|
shippingTotal: number;
|
|
@@ -566,9 +574,9 @@ interface SecureCardCompleteResult {
|
|
|
566
574
|
orderId: string;
|
|
567
575
|
orderNumber: string;
|
|
568
576
|
paymentId: string;
|
|
569
|
-
/** Minor units
|
|
577
|
+
/** Minor units of `currency`. */
|
|
570
578
|
total: number;
|
|
571
|
-
currency:
|
|
579
|
+
currency: CurrencyCode;
|
|
572
580
|
status: string;
|
|
573
581
|
paymentStatus: string;
|
|
574
582
|
}
|
package/dist/index.js
CHANGED
|
@@ -1956,7 +1956,23 @@ function SecurityCodeField({ className, style, options }) {
|
|
|
1956
1956
|
function PostalCodeField({ className, style, options }) {
|
|
1957
1957
|
return /* @__PURE__ */ jsx4("div", { ref: useField("postalCode", options), className, style });
|
|
1958
1958
|
}
|
|
1959
|
+
|
|
1960
|
+
// src/index.tsx
|
|
1961
|
+
import * as money from "@usethrottle/money";
|
|
1962
|
+
import {
|
|
1963
|
+
formatMoney,
|
|
1964
|
+
currencySymbol,
|
|
1965
|
+
minorUnitsOf,
|
|
1966
|
+
toDecimalString,
|
|
1967
|
+
toMinor,
|
|
1968
|
+
parseMoney,
|
|
1969
|
+
moneyValue,
|
|
1970
|
+
CURRENCIES,
|
|
1971
|
+
isKnownCurrency,
|
|
1972
|
+
UnknownCurrencyError
|
|
1973
|
+
} from "@usethrottle/money";
|
|
1959
1974
|
export {
|
|
1975
|
+
CURRENCIES,
|
|
1960
1976
|
CardNumberField,
|
|
1961
1977
|
CheckoutEmbed,
|
|
1962
1978
|
ExpiryField,
|
|
@@ -1965,6 +1981,16 @@ export {
|
|
|
1965
1981
|
SecureCardProvider,
|
|
1966
1982
|
SecurityCodeField,
|
|
1967
1983
|
CheckoutEmbed as ThrottleCheckout,
|
|
1984
|
+
UnknownCurrencyError,
|
|
1985
|
+
currencySymbol,
|
|
1986
|
+
formatMoney,
|
|
1987
|
+
isKnownCurrency,
|
|
1988
|
+
minorUnitsOf,
|
|
1989
|
+
money,
|
|
1990
|
+
moneyValue,
|
|
1991
|
+
parseMoney,
|
|
1992
|
+
toDecimalString,
|
|
1993
|
+
toMinor,
|
|
1968
1994
|
useCartSession,
|
|
1969
1995
|
useSecureCard,
|
|
1970
1996
|
useThrottleCheckout,
|