@asteby/storefront-react 0.26.1 → 0.28.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 -2
- package/dist/account-server.cjs +533 -83
- package/dist/account-server.cjs.map +1 -1
- package/dist/account-server.d.cts +13 -2
- package/dist/account-server.d.ts +13 -2
- package/dist/account-server.js +23 -6
- package/dist/account-server.js.map +1 -1
- package/dist/account.cjs +572 -96
- package/dist/account.cjs.map +1 -1
- package/dist/account.d.cts +82 -45
- package/dist/account.d.ts +82 -45
- package/dist/account.js +53 -14
- package/dist/account.js.map +1 -1
- package/dist/checkout.cjs +114 -38
- package/dist/checkout.cjs.map +1 -1
- package/dist/checkout.d.cts +24 -1
- package/dist/checkout.d.ts +24 -1
- package/dist/checkout.js +114 -38
- package/dist/checkout.js.map +1 -1
- package/dist/chunk-BXKV2KWZ.js +291 -0
- package/dist/chunk-BXKV2KWZ.js.map +1 -0
- package/dist/chunk-LIUEQENV.js +156 -0
- package/dist/chunk-LIUEQENV.js.map +1 -0
- package/dist/voucher-document-FWH4DQ5N.js +72 -0
- package/dist/voucher-document-FWH4DQ5N.js.map +1 -0
- package/dist/voucher-pdf-LQC333AB.js +213 -0
- package/dist/voucher-pdf-LQC333AB.js.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-TXEYBDFG.js +0 -182
- package/dist/chunk-TXEYBDFG.js.map +0 -1
- package/dist/voucher-document-SFWJCLTN.js +0 -124
- package/dist/voucher-document-SFWJCLTN.js.map +0 -1
package/dist/checkout.d.cts
CHANGED
|
@@ -18,6 +18,8 @@ type AddressFieldsMessages = Record<AddressFieldKey | ContactFieldKey, string> &
|
|
|
18
18
|
provinceLocked: string;
|
|
19
19
|
/** Discreet action that releases the locked state so the buyer can fix the postal code. */
|
|
20
20
|
changePostalCode: string;
|
|
21
|
+
/** Visually hidden prefix of the one-line place summary (what a screen reader hears before "Miguel Hidalgo, Ciudad de México"). */
|
|
22
|
+
resolvedPlace: string;
|
|
21
23
|
};
|
|
22
24
|
declare function addressFieldsMessages(locale?: string | null, overrides?: Partial<AddressFieldsMessages> | null): AddressFieldsMessages;
|
|
23
25
|
type FieldLayoutClassNames = CheckoutFieldClassNames & {
|
|
@@ -54,11 +56,21 @@ type PostalCodeInfo = {
|
|
|
54
56
|
province?: string | null;
|
|
55
57
|
city?: string | null;
|
|
56
58
|
neighborhoods?: readonly string[] | null;
|
|
59
|
+
/**
|
|
60
|
+
* Every municipality the code covers, when the catalog knows more than one. With two or more the code is ambiguous:
|
|
61
|
+
* `hideResolvedFields` keeps the city field editable instead of choosing for the buyer.
|
|
62
|
+
*/
|
|
63
|
+
cities?: readonly string[] | null;
|
|
64
|
+
/**
|
|
65
|
+
* Municipality to SHOW in the one-line summary (`hideResolvedFields`) when it differs from `city`, the value that is
|
|
66
|
+
* submitted (and may feed the delivery quote). Display only: never sent.
|
|
67
|
+
*/
|
|
68
|
+
municipality?: string | null;
|
|
57
69
|
};
|
|
58
70
|
type AddressFieldsProps = Common & {
|
|
59
71
|
defaults?: Partial<Pick<Address, 'zip' | 'province' | 'city' | 'neighborhood' | 'address1' | 'address2' | 'reference'>> | null;
|
|
60
72
|
/** Form names. Default: the keys (the `AddressInput` fields of the Storefront API). */
|
|
61
|
-
names?: Partial<Record<AddressFieldKey, string>>;
|
|
73
|
+
names?: Partial<Record<AddressFieldKey | 'province_code', string>>;
|
|
62
74
|
/** ISO country of the address (hidden field `country_code`). */
|
|
63
75
|
countryCode: string;
|
|
64
76
|
/** States of the country (from the region config). With them, "State" is a `<select>`; the value sent is `name`. */
|
|
@@ -99,6 +111,17 @@ type AddressFieldsProps = Common & {
|
|
|
99
111
|
* `data-sf-locked="1"` for the shop's own styling.
|
|
100
112
|
*/
|
|
101
113
|
lockProvinceOnFill?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* When the postal-code lookup resolves BOTH state and city/municipality (and the catalog does not return several
|
|
116
|
+
* municipalities), they are not shown as inputs: one read-only line under the postal code ("Miguel Hidalgo, Ciudad de
|
|
117
|
+
* México" plus a discreet `changePostalCode` link) and the values travel in hidden fields with the usual names
|
|
118
|
+
* (`province`, `province_code` when the `provinces` list knows it, `city`), so the server still validates state against
|
|
119
|
+
* postal code. If the code resolves nothing, is unknown, the lookup fails, the municipality is ambiguous, the state is
|
|
120
|
+
* not in `provinces`, the buyer already typed a different value, or the server reports an error on state/city, the
|
|
121
|
+
* inputs are shown editable (the buyer can always complete the address). Without JavaScript the form is the plain
|
|
122
|
+
* inputs. Default TRUE; `false` keeps the previous behavior (inputs filled, state locked per `lockProvinceOnFill`).
|
|
123
|
+
*/
|
|
124
|
+
hideResolvedFields?: boolean;
|
|
102
125
|
/** Rendered after the fields (e.g. "save this address"). */
|
|
103
126
|
children?: ReactNode;
|
|
104
127
|
};
|
package/dist/checkout.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ type AddressFieldsMessages = Record<AddressFieldKey | ContactFieldKey, string> &
|
|
|
18
18
|
provinceLocked: string;
|
|
19
19
|
/** Discreet action that releases the locked state so the buyer can fix the postal code. */
|
|
20
20
|
changePostalCode: string;
|
|
21
|
+
/** Visually hidden prefix of the one-line place summary (what a screen reader hears before "Miguel Hidalgo, Ciudad de México"). */
|
|
22
|
+
resolvedPlace: string;
|
|
21
23
|
};
|
|
22
24
|
declare function addressFieldsMessages(locale?: string | null, overrides?: Partial<AddressFieldsMessages> | null): AddressFieldsMessages;
|
|
23
25
|
type FieldLayoutClassNames = CheckoutFieldClassNames & {
|
|
@@ -54,11 +56,21 @@ type PostalCodeInfo = {
|
|
|
54
56
|
province?: string | null;
|
|
55
57
|
city?: string | null;
|
|
56
58
|
neighborhoods?: readonly string[] | null;
|
|
59
|
+
/**
|
|
60
|
+
* Every municipality the code covers, when the catalog knows more than one. With two or more the code is ambiguous:
|
|
61
|
+
* `hideResolvedFields` keeps the city field editable instead of choosing for the buyer.
|
|
62
|
+
*/
|
|
63
|
+
cities?: readonly string[] | null;
|
|
64
|
+
/**
|
|
65
|
+
* Municipality to SHOW in the one-line summary (`hideResolvedFields`) when it differs from `city`, the value that is
|
|
66
|
+
* submitted (and may feed the delivery quote). Display only: never sent.
|
|
67
|
+
*/
|
|
68
|
+
municipality?: string | null;
|
|
57
69
|
};
|
|
58
70
|
type AddressFieldsProps = Common & {
|
|
59
71
|
defaults?: Partial<Pick<Address, 'zip' | 'province' | 'city' | 'neighborhood' | 'address1' | 'address2' | 'reference'>> | null;
|
|
60
72
|
/** Form names. Default: the keys (the `AddressInput` fields of the Storefront API). */
|
|
61
|
-
names?: Partial<Record<AddressFieldKey, string>>;
|
|
73
|
+
names?: Partial<Record<AddressFieldKey | 'province_code', string>>;
|
|
62
74
|
/** ISO country of the address (hidden field `country_code`). */
|
|
63
75
|
countryCode: string;
|
|
64
76
|
/** States of the country (from the region config). With them, "State" is a `<select>`; the value sent is `name`. */
|
|
@@ -99,6 +111,17 @@ type AddressFieldsProps = Common & {
|
|
|
99
111
|
* `data-sf-locked="1"` for the shop's own styling.
|
|
100
112
|
*/
|
|
101
113
|
lockProvinceOnFill?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* When the postal-code lookup resolves BOTH state and city/municipality (and the catalog does not return several
|
|
116
|
+
* municipalities), they are not shown as inputs: one read-only line under the postal code ("Miguel Hidalgo, Ciudad de
|
|
117
|
+
* México" plus a discreet `changePostalCode` link) and the values travel in hidden fields with the usual names
|
|
118
|
+
* (`province`, `province_code` when the `provinces` list knows it, `city`), so the server still validates state against
|
|
119
|
+
* postal code. If the code resolves nothing, is unknown, the lookup fails, the municipality is ambiguous, the state is
|
|
120
|
+
* not in `provinces`, the buyer already typed a different value, or the server reports an error on state/city, the
|
|
121
|
+
* inputs are shown editable (the buyer can always complete the address). Without JavaScript the form is the plain
|
|
122
|
+
* inputs. Default TRUE; `false` keeps the previous behavior (inputs filled, state locked per `lockProvinceOnFill`).
|
|
123
|
+
*/
|
|
124
|
+
hideResolvedFields?: boolean;
|
|
102
125
|
/** Rendered after the fields (e.g. "save this address"). */
|
|
103
126
|
children?: ReactNode;
|
|
104
127
|
};
|
package/dist/checkout.js
CHANGED
|
@@ -30,7 +30,8 @@ var ES = {
|
|
|
30
30
|
phoneHint: "Solo para la paqueter\xEDa, por si necesita contactarte.",
|
|
31
31
|
lookupFilled: "Completamos estado y ciudad con tu c\xF3digo postal.",
|
|
32
32
|
provinceLocked: "Definido por tu c\xF3digo postal",
|
|
33
|
-
changePostalCode: "Cambiar c\xF3digo postal"
|
|
33
|
+
changePostalCode: "Cambiar c\xF3digo postal",
|
|
34
|
+
resolvedPlace: "Entrega en"
|
|
34
35
|
};
|
|
35
36
|
var EN = {
|
|
36
37
|
email: "Email",
|
|
@@ -52,7 +53,8 @@ var EN = {
|
|
|
52
53
|
phoneHint: "Only for the carrier, in case they need to reach you.",
|
|
53
54
|
lookupFilled: "We filled in state and city from your postal code.",
|
|
54
55
|
provinceLocked: "Set by your postal code",
|
|
55
|
-
changePostalCode: "Change postal code"
|
|
56
|
+
changePostalCode: "Change postal code",
|
|
57
|
+
resolvedPlace: "Delivering to"
|
|
56
58
|
};
|
|
57
59
|
function addressFieldsMessages(locale, overrides) {
|
|
58
60
|
const base = (locale ?? "es-MX").toLowerCase().startsWith("en") ? EN : ES;
|
|
@@ -111,8 +113,11 @@ var ADDRESS_FILL_EVENT_FLAG = "sfSynthetic";
|
|
|
111
113
|
function isAddressFillEvent(event) {
|
|
112
114
|
return event[ADDRESS_FILL_EVENT_FLAG] === true;
|
|
113
115
|
}
|
|
116
|
+
var SR_ONLY = { position: "absolute", width: 1, height: 1, overflow: "hidden", clip: "rect(0 0 0 0)", whiteSpace: "nowrap" };
|
|
117
|
+
var sameText = (a, b) => fold(a) === fold(b);
|
|
118
|
+
var fold = (v) => v.normalize("NFD").replace(/[\u0300-\u036f]/g, "").trim().toLowerCase();
|
|
114
119
|
function AddressFields(props) {
|
|
115
|
-
const { defaults, names = {}, errors = {}, countryCode, provinces, postalCode, lookupPostalCode, lockProvinceOnFill = true, locale, messages, fieldMessages: fm, classNames: cx = {}, children } = props;
|
|
120
|
+
const { defaults, names = {}, errors = {}, countryCode, provinces, postalCode, lookupPostalCode, lockProvinceOnFill = true, hideResolvedFields = true, locale, messages, fieldMessages: fm, classNames: cx = {}, children } = props;
|
|
116
121
|
const showNeighborhood = props.neighborhood ?? true;
|
|
117
122
|
const showReference = props.reference ?? true;
|
|
118
123
|
const m = addressFieldsMessages(locale, messages);
|
|
@@ -123,6 +128,9 @@ function AddressFields(props) {
|
|
|
123
128
|
const [filled, setFilled] = useState(false);
|
|
124
129
|
const [provinceLocked, setProvinceLocked] = useState(false);
|
|
125
130
|
const [coloniaSelect, setColoniaSelect] = useState(false);
|
|
131
|
+
const [resolved, setResolved] = useState(null);
|
|
132
|
+
const resolvedRef = useRef(false);
|
|
133
|
+
const [defaultsStale, setDefaultsStale] = useState(false);
|
|
126
134
|
const coloniaSelectRef = useRef(false);
|
|
127
135
|
const coloniaCarry = useRef(null);
|
|
128
136
|
const lastZip = useRef(null);
|
|
@@ -157,6 +165,7 @@ function AddressFields(props) {
|
|
|
157
165
|
if (!form) return;
|
|
158
166
|
const locked = form.querySelector('[data-sf-locked="1"]');
|
|
159
167
|
const touched = [];
|
|
168
|
+
if (resolvedRef.current) setDefaultsStale(true);
|
|
160
169
|
if (locked) {
|
|
161
170
|
unlockField(locked);
|
|
162
171
|
touched.push(locked);
|
|
@@ -174,9 +183,32 @@ function AddressFields(props) {
|
|
|
174
183
|
el.dispatchEvent(event);
|
|
175
184
|
}
|
|
176
185
|
lastZip.current = null;
|
|
186
|
+
resolvedRef.current = false;
|
|
187
|
+
setResolved(null);
|
|
177
188
|
setProvinceLocked(false);
|
|
178
189
|
setFilled(false);
|
|
179
190
|
};
|
|
191
|
+
const resolveHidden = (info, form) => {
|
|
192
|
+
if (!form || !info.province || !info.city) return null;
|
|
193
|
+
if ((info.cities?.length ?? 0) > 1) return null;
|
|
194
|
+
let province = info.province.trim();
|
|
195
|
+
let provinceCode = null;
|
|
196
|
+
if (provinces && provinces.length) {
|
|
197
|
+
const hit = provinces.find((p) => sameText(p.name, province) || !!p.code && sameText(p.code, province));
|
|
198
|
+
if (!hit) return null;
|
|
199
|
+
province = hit.name;
|
|
200
|
+
provinceCode = hit.code ?? null;
|
|
201
|
+
}
|
|
202
|
+
const city = info.city.trim();
|
|
203
|
+
if (!province || !city) return null;
|
|
204
|
+
const theirs = (name, value) => {
|
|
205
|
+
const el = form.elements.namedItem(name);
|
|
206
|
+
if (!el || "length" in el && !(el instanceof HTMLSelectElement)) return false;
|
|
207
|
+
return !!el.value && el.dataset.sfAutofilled !== "1" && !sameText(el.value, value);
|
|
208
|
+
};
|
|
209
|
+
if (theirs(n("province"), province) || theirs(n("city"), city)) return null;
|
|
210
|
+
return { province, provinceCode, city, place: info.municipality?.trim() || city };
|
|
211
|
+
};
|
|
180
212
|
const runLookup = (zip) => {
|
|
181
213
|
const lookup = lookupRef.current;
|
|
182
214
|
if (!lookup || !zip || zip === lastZip.current) return;
|
|
@@ -207,8 +239,14 @@ function AddressFields(props) {
|
|
|
207
239
|
}
|
|
208
240
|
return true;
|
|
209
241
|
};
|
|
210
|
-
const
|
|
211
|
-
|
|
242
|
+
const resolution = hideResolvedFields ? resolveHidden(info, form) : null;
|
|
243
|
+
if (resolution) {
|
|
244
|
+
resolvedRef.current = true;
|
|
245
|
+
setDefaultsStale(true);
|
|
246
|
+
setResolved(resolution);
|
|
247
|
+
}
|
|
248
|
+
const a = resolution ? false : fill2(n("province"), info.province, lockProvinceOnFill);
|
|
249
|
+
const b = resolution ? false : fill2(n("city"), info.city);
|
|
212
250
|
const only = info.neighborhoods?.length === 1 ? info.neighborhoods[0] : null;
|
|
213
251
|
const c = showNeighborhood ? fill2(n("neighborhood"), only) : false;
|
|
214
252
|
setColonias(info.neighborhoods ?? []);
|
|
@@ -226,7 +264,7 @@ function AddressFields(props) {
|
|
|
226
264
|
}
|
|
227
265
|
coloniaSelectRef.current = wantSelect;
|
|
228
266
|
setColoniaSelect(wantSelect);
|
|
229
|
-
setFilled(a || b || c || carried);
|
|
267
|
+
setFilled(!resolution && (a || b || c || carried));
|
|
230
268
|
});
|
|
231
269
|
},
|
|
232
270
|
() => {
|
|
@@ -252,7 +290,20 @@ function AddressFields(props) {
|
|
|
252
290
|
const zip = defaults?.zip;
|
|
253
291
|
if (zip) runLookup(zip);
|
|
254
292
|
}, []);
|
|
255
|
-
const
|
|
293
|
+
const firstRender = useRef(true);
|
|
294
|
+
useEffect(() => {
|
|
295
|
+
if (firstRender.current) {
|
|
296
|
+
firstRender.current = false;
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
const form = zipRef.current?.closest("form");
|
|
300
|
+
const el = (resolved ? form?.querySelector('input[type="hidden"][data-sf-resolved-field="city"]') : null) ?? zipRef.current?.querySelector("input");
|
|
301
|
+
if (!el) return;
|
|
302
|
+
const event = new Event("input", { bubbles: true });
|
|
303
|
+
Object.defineProperty(event, ADDRESS_FILL_EVENT_FLAG, { value: true });
|
|
304
|
+
el.dispatchEvent(event);
|
|
305
|
+
}, [resolved]);
|
|
306
|
+
const hasLock = (root) => resolvedRef.current || !!root?.closest("form")?.querySelector('[data-sf-locked="1"]');
|
|
256
307
|
const changeZip = () => {
|
|
257
308
|
releaseLookup();
|
|
258
309
|
const zipEl = zipRef.current?.querySelector("input");
|
|
@@ -269,35 +320,61 @@ function AddressFields(props) {
|
|
|
269
320
|
/* @__PURE__ */ jsx("button", { type: "button", "data-sf-change-zip": "", onClick: changeZip, style: { background: "none", border: 0, padding: 0, font: "inherit", color: "inherit", textDecoration: "underline", cursor: "pointer" }, children: m.changePostalCode })
|
|
270
321
|
] }) : void 0;
|
|
271
322
|
const numericZip = postalCode?.inputMode === "numeric";
|
|
323
|
+
const showResolved = !!resolved && !errors[n("province")] && !errors[n("city")];
|
|
324
|
+
const startOf = (key) => resolved ? resolved[key] : defaultsStale ? "" : defaults?.[key] ?? "";
|
|
272
325
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
273
|
-
/* @__PURE__ */
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
326
|
+
/* @__PURE__ */ jsxs("div", { ref: zipRef, className: join(cx.half), "data-sf-zip": true, children: [
|
|
327
|
+
/* @__PURE__ */ jsx(
|
|
328
|
+
CheckoutField,
|
|
329
|
+
{
|
|
330
|
+
...common,
|
|
331
|
+
name: n("zip"),
|
|
332
|
+
label: m.zip,
|
|
333
|
+
autoComplete: "postal-code",
|
|
334
|
+
inputMode: postalCode?.inputMode ?? "text",
|
|
335
|
+
...postalCode?.pattern ? { pattern: postalCode.pattern } : {},
|
|
336
|
+
...postalCode?.maxLength ? { maxLength: postalCode.maxLength } : {},
|
|
337
|
+
...postalCode?.title ? { title: postalCode.title } : {},
|
|
338
|
+
...numericZip ? { autoCapitalize: "none" } : {},
|
|
339
|
+
defaultValue: defaults?.zip ?? "",
|
|
340
|
+
error: errors[n("zip")] ?? null,
|
|
341
|
+
classNames: { ...cx, root: cx.root },
|
|
342
|
+
onInput: (e) => {
|
|
343
|
+
const v = e.currentTarget.value.trim();
|
|
344
|
+
if (v !== lastZip.current && hasLock(zipRef.current)) releaseLookup();
|
|
345
|
+
if (postalCode?.maxLength && v.length === postalCode.maxLength) runLookup(v);
|
|
346
|
+
},
|
|
347
|
+
onBlur: (e) => runLookup(e.currentTarget.value.trim())
|
|
348
|
+
}
|
|
349
|
+
),
|
|
350
|
+
/* @__PURE__ */ jsxs("div", { "data-sf-resolved": showResolved ? "" : void 0, className: showResolved || filled ? join(cx.hint) : void 0, children: [
|
|
351
|
+
/* @__PURE__ */ jsx("p", { role: "status", "aria-live": "polite", "data-sf-zip-status": true, style: showResolved || filled ? showResolved ? { display: "inline", margin: 0 } : void 0 : SR_ONLY, children: showResolved && resolved ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
352
|
+
/* @__PURE__ */ jsxs("span", { style: SR_ONLY, children: [
|
|
353
|
+
m.resolvedPlace,
|
|
354
|
+
" "
|
|
355
|
+
] }),
|
|
356
|
+
/* @__PURE__ */ jsxs("span", { "data-sf-resolved-place": true, children: [
|
|
357
|
+
resolved.place,
|
|
358
|
+
", ",
|
|
359
|
+
resolved.province
|
|
360
|
+
] })
|
|
361
|
+
] }) : filled ? m.lookupFilled : "" }),
|
|
362
|
+
showResolved ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
363
|
+
" \xB7 ",
|
|
364
|
+
/* @__PURE__ */ jsx("button", { type: "button", "data-sf-change-zip": "", onClick: changeZip, style: { background: "none", border: 0, padding: 0, font: "inherit", color: "inherit", textDecoration: "underline", cursor: "pointer" }, children: m.changePostalCode })
|
|
365
|
+
] }) : null
|
|
366
|
+
] })
|
|
367
|
+
] }),
|
|
368
|
+
showResolved && resolved ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
369
|
+
/* @__PURE__ */ jsx("input", { type: "hidden", name: n("province"), value: resolved.province, "data-sf-resolved-field": "province" }),
|
|
370
|
+
resolved.provinceCode ? /* @__PURE__ */ jsx("input", { type: "hidden", name: n("province_code"), value: resolved.provinceCode, "data-sf-resolved-field": "province_code" }) : null,
|
|
371
|
+
/* @__PURE__ */ jsx("input", { type: "hidden", name: n("city"), value: resolved.city, "data-sf-resolved-field": "city" })
|
|
372
|
+
] }) : null,
|
|
373
|
+
showResolved ? null : provinces && provinces.length ? /* @__PURE__ */ jsxs(CheckoutField, { ...common, as: "select", name: n("province"), label: m.province, autoComplete: "address-level1", defaultValue: startOf("province"), error: errors[n("province")] ?? null, classNames: field(cx, "half"), hint: provinceHint, children: [
|
|
297
374
|
/* @__PURE__ */ jsx("option", { value: "", disabled: true, children: m.provincePlaceholder }),
|
|
298
375
|
provinces.map((p) => /* @__PURE__ */ jsx("option", { value: p.name, children: p.name }, p.code ?? p.name))
|
|
299
|
-
] }) : /* @__PURE__ */ jsx(CheckoutField, { ...common, name: n("province"), label: m.province, autoComplete: "address-level1", defaultValue:
|
|
300
|
-
/* @__PURE__ */ jsx(CheckoutField, { ...common, name: n("city"), label: m.city, autoComplete: "address-level2", defaultValue:
|
|
376
|
+
] }) : /* @__PURE__ */ jsx(CheckoutField, { ...common, name: n("province"), label: m.province, autoComplete: "address-level1", defaultValue: startOf("province"), error: errors[n("province")] ?? null, classNames: field(cx, "half"), hint: provinceHint }),
|
|
377
|
+
showResolved ? null : /* @__PURE__ */ jsx(CheckoutField, { ...common, name: n("city"), label: m.city, autoComplete: "address-level2", defaultValue: startOf("city"), error: errors[n("city")] ?? null, classNames: field(cx, "half") }),
|
|
301
378
|
showNeighborhood && coloniaSelect ? /* @__PURE__ */ jsxs(
|
|
302
379
|
CheckoutField,
|
|
303
380
|
{
|
|
@@ -330,7 +407,6 @@ function AddressFields(props) {
|
|
|
330
407
|
}
|
|
331
408
|
) : null,
|
|
332
409
|
colonias.length && !coloniaSelect ? /* @__PURE__ */ jsx("datalist", { id: listId, children: colonias.map((c) => /* @__PURE__ */ jsx("option", { value: c }, c)) }) : null,
|
|
333
|
-
/* @__PURE__ */ jsx("p", { role: "status", "aria-live": "polite", "data-sf-zip-status": true, style: filled ? void 0 : { position: "absolute", width: 1, height: 1, overflow: "hidden", clip: "rect(0 0 0 0)", whiteSpace: "nowrap" }, className: filled ? join(cx.hint, cx.wide) : void 0, children: filled ? m.lookupFilled : "" }),
|
|
334
410
|
/* @__PURE__ */ jsx(CheckoutField, { ...common, name: n("address1"), label: m.address1, autoComplete: "address-line1", defaultValue: defaults?.address1 ?? "", error: errors[n("address1")] ?? null, hint: m.address1Hint, classNames: field(cx, "wide") }),
|
|
335
411
|
/* @__PURE__ */ jsx(CheckoutField, { ...common, name: n("address2"), label: m.address2, autoComplete: "address-line2", optional: true, defaultValue: defaults?.address2 ?? "", error: errors[n("address2")] ?? null, classNames: field(cx, "half") }),
|
|
336
412
|
showReference ? /* @__PURE__ */ jsx(CheckoutField, { ...common, name: n("reference"), label: m.reference, optional: true, defaultValue: defaults?.reference ?? "", error: errors[n("reference")] ?? null, hint: m.referenceHint, classNames: field(cx, "wide"), maxLength: 200 }) : null,
|
|
@@ -693,7 +769,7 @@ function matchRate(previous, rates) {
|
|
|
693
769
|
}
|
|
694
770
|
return rates.find((r) => sameCarrier(r) && norm3(r.title) === norm3(previous.title)) ?? null;
|
|
695
771
|
}
|
|
696
|
-
var
|
|
772
|
+
var SR_ONLY2 = { position: "absolute", width: 1, height: 1, overflow: "hidden", clip: "rect(0 0 0 0)", whiteSpace: "nowrap" };
|
|
697
773
|
var useHydrated = () => useSyncExternalStore(
|
|
698
774
|
() => () => {
|
|
699
775
|
},
|
|
@@ -780,7 +856,7 @@ function DeliveryOptions(props) {
|
|
|
780
856
|
) : null,
|
|
781
857
|
/* @__PURE__ */ jsxs("span", { className: cx.body, "data-sf-delivery-body": true, children: [
|
|
782
858
|
/* @__PURE__ */ jsx("span", { className: cx.title, "data-sf-delivery-title": true, children: carrier ? opts.grouped ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
783
|
-
/* @__PURE__ */ jsxs("span", { style:
|
|
859
|
+
/* @__PURE__ */ jsxs("span", { style: SR_ONLY2, children: [
|
|
784
860
|
carrier,
|
|
785
861
|
" "
|
|
786
862
|
] }),
|
|
@@ -801,8 +877,8 @@ function DeliveryOptions(props) {
|
|
|
801
877
|
return /* @__PURE__ */ jsxs("div", { className: cx.root, "data-sf-delivery": true, "data-layout": layout, "aria-busy": loading || void 0, children: [
|
|
802
878
|
partial && !errorText ? /* @__PURE__ */ jsx("p", { role: "status", className: cx.partial, "data-sf-delivery-partial": true, children: m.partial }) : null,
|
|
803
879
|
requoted ? /* @__PURE__ */ jsx("p", { role: "status", className: cx.partial, "data-sf-delivery-requoted": true, children: m.requoted }) : null,
|
|
804
|
-
loading ? /* @__PURE__ */ jsx("span", { style:
|
|
805
|
-
props.announceReady && !loading && rates.length > 0 ? /* @__PURE__ */ jsx("span", { style:
|
|
880
|
+
loading ? /* @__PURE__ */ jsx("span", { style: SR_ONLY2, role: "status", "data-sf-delivery-loading": true, children: m.loading }) : null,
|
|
881
|
+
props.announceReady && !loading && rates.length > 0 ? /* @__PURE__ */ jsx("span", { style: SR_ONLY2, role: "status", "data-sf-delivery-ready": true, children: freeRate ? m.freeShipping : m.ratesReady.replace("{n}", String(rates.length)) }) : null,
|
|
806
882
|
errorText && rates.length === 0 && !loading ? /* @__PURE__ */ jsxs("div", { role: "alert", className: cx.error, "data-sf-delivery-error": true, children: [
|
|
807
883
|
/* @__PURE__ */ jsx("p", { children: errorText }),
|
|
808
884
|
onRetry ? /* @__PURE__ */ jsx("button", { type: "button", className: cx.retry, onClick: onRetry, "data-sf-delivery-retry": true, children: m.retry }) : null
|