@asteby/storefront-react 0.16.1 → 0.17.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 +58 -1
- package/dist/checkout.cjs +54 -17
- package/dist/checkout.cjs.map +1 -1
- package/dist/checkout.d.cts +8 -1
- package/dist/checkout.d.ts +8 -1
- package/dist/checkout.js +53 -18
- package/dist/checkout.js.map +1 -1
- package/dist/{chunk-ISEOCKIR.js → chunk-MNLROALF.js} +96 -8
- package/dist/chunk-MNLROALF.js.map +1 -0
- package/dist/{choices-DEPE9KRq.d.cts → csp-DZPuExzu.d.cts} +93 -55
- package/dist/{choices-DEPE9KRq.d.ts → csp-DZPuExzu.d.ts} +93 -55
- package/dist/payments-server.cjs +159 -12
- package/dist/payments-server.cjs.map +1 -1
- package/dist/payments-server.d.cts +23 -3
- package/dist/payments-server.d.ts +23 -3
- package/dist/payments-server.js +70 -13
- package/dist/payments-server.js.map +1 -1
- package/dist/payments.cjs +722 -150
- package/dist/payments.cjs.map +1 -1
- package/dist/payments.css +19 -0
- package/dist/payments.d.cts +207 -6
- package/dist/payments.d.ts +207 -6
- package/dist/payments.js +566 -92
- package/dist/payments.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-ISEOCKIR.js.map +0 -1
package/dist/checkout.d.cts
CHANGED
|
@@ -88,6 +88,13 @@ type AddressFieldsProps = Common & {
|
|
|
88
88
|
/** Rendered after the fields (e.g. "save this address"). */
|
|
89
89
|
children?: ReactNode;
|
|
90
90
|
};
|
|
91
|
+
/** Name of the property set to `true` on every event the lookup dispatches when it fills a field. */
|
|
92
|
+
declare const ADDRESS_FILL_EVENT_FLAG = "sfSynthetic";
|
|
93
|
+
/**
|
|
94
|
+
* Was this `input` event dispatched by `AddressFields` itself (a postal-code fill) and not typed by the buyer? The shop's
|
|
95
|
+
* own listeners (validation, autosave, delivery re-quote...) can ignore these. Real typing has `isTrusted: true`.
|
|
96
|
+
*/
|
|
97
|
+
declare function isAddressFillEvent(event: Event): boolean;
|
|
91
98
|
declare function AddressFields(props: AddressFieldsProps): react.JSX.Element;
|
|
92
99
|
|
|
93
100
|
type OrderSummaryMessages = {
|
|
@@ -452,4 +459,4 @@ type FlatRatesOptions = {
|
|
|
452
459
|
*/
|
|
453
460
|
declare function flatRates<R extends ShippingRate>(input: readonly R[], options?: FlatRatesOptions): RecommendedRate<R>[];
|
|
454
461
|
|
|
455
|
-
export { type AddressFieldKey, AddressFields, type AddressFieldsMessages, type AddressFieldsProps, type Brand, type BrandKind, BrandMark, type BrandMarkProps, type BrandMarkSource, CheckoutFieldClassNames, type ContactFieldKey, ContactFields, type ContactFieldsProps, type DeliveryMessages, DeliveryOptions, type DeliveryOptionsClassNames, type DeliveryOptionsProps, FieldErrors, type FieldLayoutClassNames, FieldMessages, type FlatRatesOptions, OrderSummary, type OrderSummaryClassNames, OrderSummaryDisclosure, type OrderSummaryDisclosureProps, type OrderSummaryMessages, type OrderSummaryProps, type PostalCodeInfo, type QuoteNote, type RateBadge, type RateGroup, type RateTag, type RecommendRatesOptions, type RecommendedRate, type RecommendedRates, addressFieldsMessages, brandKey, brandLogo, brandName, dedupeRates, deliveryMessages, findBrand, flatRates, isQuoteChange, listBrands, matchRate, orderSummaryMessages, quoteDeadline, quoteNote, rateBadges, rateCarrier, rateEta, rateService, recommendRates };
|
|
462
|
+
export { ADDRESS_FILL_EVENT_FLAG, type AddressFieldKey, AddressFields, type AddressFieldsMessages, type AddressFieldsProps, type Brand, type BrandKind, BrandMark, type BrandMarkProps, type BrandMarkSource, CheckoutFieldClassNames, type ContactFieldKey, ContactFields, type ContactFieldsProps, type DeliveryMessages, DeliveryOptions, type DeliveryOptionsClassNames, type DeliveryOptionsProps, FieldErrors, type FieldLayoutClassNames, FieldMessages, type FlatRatesOptions, OrderSummary, type OrderSummaryClassNames, OrderSummaryDisclosure, type OrderSummaryDisclosureProps, type OrderSummaryMessages, type OrderSummaryProps, type PostalCodeInfo, type QuoteNote, type RateBadge, type RateGroup, type RateTag, type RecommendRatesOptions, type RecommendedRate, type RecommendedRates, addressFieldsMessages, brandKey, brandLogo, brandName, dedupeRates, deliveryMessages, findBrand, flatRates, isAddressFillEvent, isQuoteChange, listBrands, matchRate, orderSummaryMessages, quoteDeadline, quoteNote, rateBadges, rateCarrier, rateEta, rateService, recommendRates };
|
package/dist/checkout.d.ts
CHANGED
|
@@ -88,6 +88,13 @@ type AddressFieldsProps = Common & {
|
|
|
88
88
|
/** Rendered after the fields (e.g. "save this address"). */
|
|
89
89
|
children?: ReactNode;
|
|
90
90
|
};
|
|
91
|
+
/** Name of the property set to `true` on every event the lookup dispatches when it fills a field. */
|
|
92
|
+
declare const ADDRESS_FILL_EVENT_FLAG = "sfSynthetic";
|
|
93
|
+
/**
|
|
94
|
+
* Was this `input` event dispatched by `AddressFields` itself (a postal-code fill) and not typed by the buyer? The shop's
|
|
95
|
+
* own listeners (validation, autosave, delivery re-quote...) can ignore these. Real typing has `isTrusted: true`.
|
|
96
|
+
*/
|
|
97
|
+
declare function isAddressFillEvent(event: Event): boolean;
|
|
91
98
|
declare function AddressFields(props: AddressFieldsProps): react.JSX.Element;
|
|
92
99
|
|
|
93
100
|
type OrderSummaryMessages = {
|
|
@@ -452,4 +459,4 @@ type FlatRatesOptions = {
|
|
|
452
459
|
*/
|
|
453
460
|
declare function flatRates<R extends ShippingRate>(input: readonly R[], options?: FlatRatesOptions): RecommendedRate<R>[];
|
|
454
461
|
|
|
455
|
-
export { type AddressFieldKey, AddressFields, type AddressFieldsMessages, type AddressFieldsProps, type Brand, type BrandKind, BrandMark, type BrandMarkProps, type BrandMarkSource, CheckoutFieldClassNames, type ContactFieldKey, ContactFields, type ContactFieldsProps, type DeliveryMessages, DeliveryOptions, type DeliveryOptionsClassNames, type DeliveryOptionsProps, FieldErrors, type FieldLayoutClassNames, FieldMessages, type FlatRatesOptions, OrderSummary, type OrderSummaryClassNames, OrderSummaryDisclosure, type OrderSummaryDisclosureProps, type OrderSummaryMessages, type OrderSummaryProps, type PostalCodeInfo, type QuoteNote, type RateBadge, type RateGroup, type RateTag, type RecommendRatesOptions, type RecommendedRate, type RecommendedRates, addressFieldsMessages, brandKey, brandLogo, brandName, dedupeRates, deliveryMessages, findBrand, flatRates, isQuoteChange, listBrands, matchRate, orderSummaryMessages, quoteDeadline, quoteNote, rateBadges, rateCarrier, rateEta, rateService, recommendRates };
|
|
462
|
+
export { ADDRESS_FILL_EVENT_FLAG, type AddressFieldKey, AddressFields, type AddressFieldsMessages, type AddressFieldsProps, type Brand, type BrandKind, BrandMark, type BrandMarkProps, type BrandMarkSource, CheckoutFieldClassNames, type ContactFieldKey, ContactFields, type ContactFieldsProps, type DeliveryMessages, DeliveryOptions, type DeliveryOptionsClassNames, type DeliveryOptionsProps, FieldErrors, type FieldLayoutClassNames, FieldMessages, type FlatRatesOptions, OrderSummary, type OrderSummaryClassNames, OrderSummaryDisclosure, type OrderSummaryDisclosureProps, type OrderSummaryMessages, type OrderSummaryProps, type PostalCodeInfo, type QuoteNote, type RateBadge, type RateGroup, type RateTag, type RecommendRatesOptions, type RecommendedRate, type RecommendedRates, addressFieldsMessages, brandKey, brandLogo, brandName, dedupeRates, deliveryMessages, findBrand, flatRates, isAddressFillEvent, isQuoteChange, listBrands, matchRate, orderSummaryMessages, quoteDeadline, quoteNote, rateBadges, rateCarrier, rateEta, rateService, recommendRates };
|
package/dist/checkout.js
CHANGED
|
@@ -82,6 +82,10 @@ function lockField(el) {
|
|
|
82
82
|
el.readOnly = true;
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
+
var ADDRESS_FILL_EVENT_FLAG = "sfSynthetic";
|
|
86
|
+
function isAddressFillEvent(event) {
|
|
87
|
+
return event[ADDRESS_FILL_EVENT_FLAG] === true;
|
|
88
|
+
}
|
|
85
89
|
function AddressFields(props) {
|
|
86
90
|
const { defaults, names = {}, errors = {}, countryCode, provinces, postalCode, lookupPostalCode, lockProvinceOnFill, locale, messages, fieldMessages: fm, classNames: cx = {}, children } = props;
|
|
87
91
|
const showNeighborhood = props.neighborhood ?? true;
|
|
@@ -96,6 +100,29 @@ function AddressFields(props) {
|
|
|
96
100
|
const zipRef = useRef(null);
|
|
97
101
|
const lookupRef = useRef(lookupPostalCode);
|
|
98
102
|
lookupRef.current = lookupPostalCode;
|
|
103
|
+
const writer = useRef(Promise.resolve());
|
|
104
|
+
const enqueue = (task) => {
|
|
105
|
+
writer.current = writer.current.then(task).catch(() => {
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
const form = zipRef.current?.closest("form");
|
|
110
|
+
if (!form) return;
|
|
111
|
+
const mark = (e) => {
|
|
112
|
+
if (!e.isTrusted) return;
|
|
113
|
+
const el = e.target;
|
|
114
|
+
if (el instanceof HTMLInputElement || el instanceof HTMLSelectElement) {
|
|
115
|
+
el.dataset.sfUserEdited = "1";
|
|
116
|
+
delete el.dataset.sfAutofilled;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
form.addEventListener("input", mark, true);
|
|
120
|
+
form.addEventListener("change", mark, true);
|
|
121
|
+
return () => {
|
|
122
|
+
form.removeEventListener("input", mark, true);
|
|
123
|
+
form.removeEventListener("change", mark, true);
|
|
124
|
+
};
|
|
125
|
+
}, []);
|
|
99
126
|
const runLookup = (zip) => {
|
|
100
127
|
const lookup = lookupRef.current;
|
|
101
128
|
if (!lookup || !zip || zip === lastZip.current) return;
|
|
@@ -104,23 +131,31 @@ function AddressFields(props) {
|
|
|
104
131
|
const form = zipRef.current?.closest("form");
|
|
105
132
|
void lookup(zip).then(
|
|
106
133
|
(info) => {
|
|
107
|
-
if (!info
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
134
|
+
if (!info) return;
|
|
135
|
+
enqueue(() => {
|
|
136
|
+
if (lastZip.current !== zip) return;
|
|
137
|
+
const fill2 = (name, value, lock) => {
|
|
138
|
+
const el = form?.elements.namedItem(name);
|
|
139
|
+
if (!el || !value || "length" in el && !(el instanceof HTMLSelectElement)) return false;
|
|
140
|
+
if (el.dataset.sfLocked === "1") return false;
|
|
141
|
+
if (el.dataset.sfUserEdited === "1" || el.ownerDocument.activeElement === el && el.value) return false;
|
|
142
|
+
if (el.value && el.dataset.sfAutofilled !== "1") return false;
|
|
143
|
+
if (el instanceof HTMLSelectElement && ![...el.options].some((o) => o.value === value)) return false;
|
|
144
|
+
el.value = value;
|
|
145
|
+
el.dataset.sfAutofilled = "1";
|
|
146
|
+
const event = new Event("input", { bubbles: true });
|
|
147
|
+
Object.defineProperty(event, ADDRESS_FILL_EVENT_FLAG, { value: true });
|
|
148
|
+
el.dispatchEvent(event);
|
|
149
|
+
if (lock) lockField(el);
|
|
150
|
+
return true;
|
|
151
|
+
};
|
|
152
|
+
const a = fill2(n("province"), info.province, lockProvinceOnFill);
|
|
153
|
+
const b = fill2(n("city"), info.city);
|
|
154
|
+
const only = info.neighborhoods?.length === 1 ? info.neighborhoods[0] : null;
|
|
155
|
+
const c = showNeighborhood ? fill2(n("neighborhood"), only) : false;
|
|
156
|
+
setColonias(info.neighborhoods ?? []);
|
|
157
|
+
setFilled(a || b || c);
|
|
158
|
+
});
|
|
124
159
|
},
|
|
125
160
|
() => {
|
|
126
161
|
}
|
|
@@ -667,6 +702,6 @@ function DeliveryOptions(props) {
|
|
|
667
702
|
] });
|
|
668
703
|
}
|
|
669
704
|
|
|
670
|
-
export { AddressFields, ContactFields, DeliveryOptions, OrderSummary, OrderSummaryDisclosure, addressFieldsMessages, dedupeRates, deliveryMessages, flatRates, isQuoteChange, matchRate, orderSummaryMessages, quoteDeadline, quoteNote, rateBadges, rateCarrier, rateEta, rateService, recommendRates };
|
|
705
|
+
export { ADDRESS_FILL_EVENT_FLAG, AddressFields, ContactFields, DeliveryOptions, OrderSummary, OrderSummaryDisclosure, addressFieldsMessages, dedupeRates, deliveryMessages, flatRates, isAddressFillEvent, isQuoteChange, matchRate, orderSummaryMessages, quoteDeadline, quoteNote, rateBadges, rateCarrier, rateEta, rateService, recommendRates };
|
|
671
706
|
//# sourceMappingURL=checkout.js.map
|
|
672
707
|
//# sourceMappingURL=checkout.js.map
|