@ticketmaster/tm-global-address 0.4.0 → 0.6.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.
@@ -2,23 +2,24 @@ import { jsxs as s, jsx as a } from "react/jsx-runtime";
2
2
  import { useState as z, useRef as V, useEffect as ee, useCallback as T } from "react";
3
3
  import c from "styled-components";
4
4
  import { tokens as e, atDesktop as re } from "../../styles/tokens.js";
5
- import { getCountryConfig as q, getSubdivisions as oe, COUNTRY_OPTIONS as L } from "../../data/countryData.js";
6
- import { FIELD_CONSTRAINTS as C } from "../../validation/constants.js";
5
+ import { getCountryConfig as q, getSubdivisions as oe, COUNTRY_OPTIONS as A } from "../../data/countryData.js";
6
+ import { FIELD_CONSTRAINTS as x } from "../../validation/constants.js";
7
+ import { PhoneField as te } from "../PhoneField/PhoneField.js";
7
8
  import { validateTextField as S } from "../../validation/validateTextField.js";
8
- import { validatePostalCode as te } from "../../validation/validatePostalCode.js";
9
- import { validateState as ae } from "../../validation/validateState.js";
10
- import { validatePhoneNumber as de } from "../../validation/validatePhoneNumber.js";
11
- import { validateForm as se } from "../../validation/validateForm.js";
12
- const ne = c.form`
9
+ import { validatePostalCode as ae } from "../../validation/validatePostalCode.js";
10
+ import { validateState as de } from "../../validation/validateState.js";
11
+ import { validatePhoneNumber as se } from "../../validation/validatePhoneNumber.js";
12
+ import { validateForm as ne } from "../../validation/validateForm.js";
13
+ const le = c.form`
13
14
  display: flex;
14
15
  flex-direction: column;
15
16
  gap: ${e.space4};
16
- `, le = c.h2`
17
+ `, ie = c.h2`
17
18
  margin: 0 0 ${e.space2};
18
19
  font-size: ${e.fontSizeHeading};
19
20
  font-weight: ${e.fontWeightBold};
20
21
  color: ${e.colorTextPrimary};
21
- `, M = c.div`
22
+ `, _ = c.div`
22
23
  display: grid;
23
24
  grid-template-columns: 1fr;
24
25
  gap: ${e.space4};
@@ -27,7 +28,7 @@ const ne = c.form`
27
28
  display: flex;
28
29
  flex-direction: column;
29
30
  gap: ${e.space1};
30
- `, $ = c.label`
31
+ `, y = c.label`
31
32
  font-size: ${e.fontSizeLabel};
32
33
  font-weight: ${e.fontWeightNormal};
33
34
  color: ${e.colorTextPrimary};
@@ -39,7 +40,7 @@ const ne = c.form`
39
40
  aria-hidden: true;
40
41
  }
41
42
  `}
42
- `, N = c.input`
43
+ `, C = c.input`
43
44
  width: 100%;
44
45
  padding: ${e.space2} ${e.space3};
45
46
  font-size: ${e.fontSizeInput};
@@ -98,18 +99,18 @@ const ne = c.form`
98
99
  border-color: ${e.colorBorderInputDisabled};
99
100
  cursor: not-allowed;
100
101
  }
101
- `, g = c.p`
102
+ `, v = c.p`
102
103
  margin: 0;
103
104
  font-size: ${e.fontSizeError};
104
105
  color: ${e.colorTextError};
105
106
  display: flex;
106
107
  align-items: center;
107
108
  gap: ${e.space1};
108
- `, ie = c.div`
109
+ `, ce = c.div`
109
110
  display: flex;
110
111
  align-items: center;
111
112
  gap: ${e.space2};
112
- `, ce = c.input`
113
+ `, ue = c.input`
113
114
  width: 18px;
114
115
  height: 18px;
115
116
  cursor: pointer;
@@ -118,17 +119,17 @@ const ne = c.form`
118
119
  &:disabled {
119
120
  cursor: not-allowed;
120
121
  }
121
- `, ue = c.label`
122
+ `, pe = c.label`
122
123
  font-size: ${e.fontSizeBody};
123
124
  color: ${e.colorTextPrimary};
124
125
  cursor: pointer;
125
- `, pe = c.div`
126
+ `, me = c.div`
126
127
  display: flex;
127
128
  justify-content: flex-end;
128
129
  gap: ${e.space3};
129
130
  flex-wrap: wrap;
130
131
  margin-block-start: ${e.space2};
131
- `, me = c.button`
132
+ `, fe = c.button`
132
133
  appearance: none;
133
134
  padding: ${e.space2} ${e.space6};
134
135
  font-size: ${e.fontSizeBody};
@@ -154,7 +155,7 @@ const ne = c.form`
154
155
  opacity: 0.6;
155
156
  cursor: not-allowed;
156
157
  }
157
- `, fe = c.button`
158
+ `, he = c.button`
158
159
  appearance: none;
159
160
  padding: ${e.space2} ${e.space6};
160
161
  font-size: ${e.fontSizeBody};
@@ -183,29 +184,14 @@ const ne = c.form`
183
184
  opacity: 0.6;
184
185
  cursor: not-allowed;
185
186
  }
186
- `, he = c.div`
187
- display: flex;
188
- gap: ${e.space2};
189
187
  `, be = c.div`
190
- display: flex;
191
- align-items: center;
192
- gap: ${e.space1};
193
- padding: ${e.space2} ${e.space3};
194
- background: ${e.colorSurfaceSecondary};
195
- border: ${e.borderWidthInput} solid ${e.colorBorderInput};
196
- border-radius: ${e.borderRadiusInput};
197
- font-size: ${e.fontSizeBody};
198
- color: ${e.colorTextPrimary};
199
- white-space: nowrap;
200
- flex-shrink: 0;
201
- `, ye = c.div`
202
188
  padding: ${e.space3} ${e.space4};
203
189
  background: ${e.colorFeedbackErrorSurface};
204
190
  border: ${e.borderWidthInput} solid ${e.colorFeedbackErrorBorder};
205
191
  border-radius: ${e.borderRadiusInput};
206
192
  font-size: ${e.fontSizeBody};
207
193
  color: ${e.colorTextError};
208
- `, $e = c.span`
194
+ `, ye = c.span`
209
195
  display: inline-block;
210
196
  width: 16px;
211
197
  height: 16px;
@@ -220,13 +206,13 @@ const ne = c.form`
220
206
  }
221
207
  }
222
208
  `;
223
- function ge(r) {
209
+ function $e(r) {
224
210
  const m = {};
225
- for (const x of r)
226
- m[x.field] || (m[x.field] = x.message);
211
+ for (const N of r)
212
+ m[N.field] || (m[N.field] = N.message);
227
213
  return m;
228
214
  }
229
- function ve(r) {
215
+ function ge(r) {
230
216
  return {
231
217
  firstName: (r == null ? void 0 : r.firstName) ?? "",
232
218
  lastName: (r == null ? void 0 : r.lastName) ?? "",
@@ -243,18 +229,18 @@ function ve(r) {
243
229
  const Te = ({
244
230
  mode: r,
245
231
  initialValues: m,
246
- countryWhitelist: x,
232
+ countryWhitelist: N,
247
233
  showPhoneNumber: F = !1,
248
234
  screenReaderErrorPrefix: f,
249
- addressLabel: A,
235
+ addressLabel: L,
250
236
  isLoading: P = !1,
251
237
  disabled: j = !1,
252
238
  serverErrors: E = [],
253
239
  onCancel: G,
254
240
  onSubmit: H
255
241
  }) => {
256
- var _;
257
- const [d, D] = z(() => ve(m)), [K, I] = z({}), [W, R] = z(""), U = V(null), h = q(d.country), Y = oe(d.country), J = h.stateCodes.length > 0 || h.stateRequired, Q = x ? L.filter((t) => x.includes(t.code)) : L;
242
+ var M;
243
+ const [d, W] = z(() => ge(m)), [K, I] = z({}), [D, R] = z(""), U = V(null), $ = q(d.country), Y = oe(d.country), J = $.stateCodes.length > 0 || $.stateRequired, Q = N ? A.filter((t) => N.includes(t.code)) : A;
258
244
  ee(() => {
259
245
  if (E.length === 0) return;
260
246
  const t = {};
@@ -265,34 +251,34 @@ const Te = ({
265
251
  }, [E]);
266
252
  const X = T((t) => {
267
253
  const n = t.target.value;
268
- D((i) => ({ ...i, country: n, state: "" })), I((i) => {
269
- const { country: l, state: v, ...B } = i;
254
+ W((i) => ({ ...i, country: n, state: "" })), I((i) => {
255
+ const { country: l, state: g, ...B } = i;
270
256
  return B;
271
257
  });
272
- }, []), b = T(
258
+ }, []), h = T(
273
259
  (t) => (n) => {
274
260
  const i = n.target.type === "checkbox" ? n.target.checked : n.target.value;
275
- D((l) => ({ ...l, [t]: i })), I((l) => {
276
- const { [t]: v, ...B } = l;
261
+ W((l) => ({ ...l, [t]: i })), I((l) => {
262
+ const { [t]: g, ...B } = l;
277
263
  return B;
278
264
  });
279
265
  },
280
266
  []
281
- ), y = T(
267
+ ), b = T(
282
268
  (t) => () => {
283
269
  const n = d[t];
284
270
  if (typeof n != "string") return;
285
271
  const i = q(d.country);
286
272
  let l = null;
287
- t === "firstName" ? l = S("firstName", n, C.firstName) : t === "lastName" ? l = S("lastName", n, C.lastName) : t === "address1" ? l = S("address1", n, C.address1) : t === "address2" && n !== "" ? l = S("address2", n, C.address2) : t === "city" ? l = S("city", n, C.city) : t === "postal" && n !== "" ? l = te(n, C.postal, i) : t === "state" ? l = ae(n || void 0, i) : t === "phoneNumber" && n !== "" && F ? l = de(n, i) : t === "country" && n === "" && (l = { message: "Please select your country" }), I((v) => {
288
- if (l) return { ...v, [t]: l.message };
289
- const { [t]: B, ...k } = v;
273
+ t === "firstName" ? l = S("firstName", n, x.firstName) : t === "lastName" ? l = S("lastName", n, x.lastName) : t === "address1" ? l = S("address1", n, x.address1) : t === "address2" && n !== "" ? l = S("address2", n, x.address2) : t === "city" ? l = S("city", n, x.city) : t === "postal" && n !== "" ? l = ae(n, x.postal, i) : t === "state" ? l = de(n || void 0, i) : t === "phoneNumber" && n !== "" && F ? l = se(n, i) : t === "country" && n === "" && (l = { message: "Please select your country" }), I((g) => {
274
+ if (l) return { ...g, [t]: l.message };
275
+ const { [t]: B, ...k } = g;
290
276
  return k;
291
277
  });
292
278
  },
293
279
  [d, F]
294
280
  ), Z = (t) => {
295
- var v;
281
+ var g;
296
282
  t.preventDefault(), R("");
297
283
  const n = {
298
284
  mode: r,
@@ -307,11 +293,11 @@ const Te = ({
307
293
  country: d.country,
308
294
  ...d.state ? { state: d.state } : {},
309
295
  ...F && d.phoneNumber ? { phoneNumber: d.phoneNumber.trim() } : {}
310
- }, i = q(d.country), l = se(n, i, { showPhoneNumber: F });
296
+ }, i = q(d.country), l = ne(n, i, { showPhoneNumber: F });
311
297
  if (!l.valid) {
312
- const B = ge(l.errors);
298
+ const B = $e(l.errors);
313
299
  I(B);
314
- const k = (v = l.errors[0]) == null ? void 0 : v.field;
300
+ const k = (g = l.errors[0]) == null ? void 0 : g.field;
315
301
  if (k) {
316
302
  const w = document.getElementById(`field-${k}`);
317
303
  w && (w.focus(), U.current = w);
@@ -320,25 +306,25 @@ const Te = ({
320
306
  }
321
307
  H(n);
322
308
  }, u = j || P, o = (t) => K[t] ?? "";
323
- return /* @__PURE__ */ s(ne, { onSubmit: Z, noValidate: !0, "aria-label": A, children: [
324
- /* @__PURE__ */ a(le, { children: A }),
325
- W && /* @__PURE__ */ s(ye, { role: "alert", children: [
309
+ return /* @__PURE__ */ s(le, { onSubmit: Z, noValidate: !0, "aria-label": L, children: [
310
+ /* @__PURE__ */ a(ie, { children: L }),
311
+ D && /* @__PURE__ */ s(be, { role: "alert", children: [
326
312
  f,
327
313
  " ",
328
- W
314
+ D
329
315
  ] }),
330
- /* @__PURE__ */ s(M, { children: [
316
+ /* @__PURE__ */ s(_, { children: [
331
317
  /* @__PURE__ */ s(p, { children: [
332
- /* @__PURE__ */ a($, { htmlFor: "field-firstName", $required: !0, children: "First Name" }),
318
+ /* @__PURE__ */ a(y, { htmlFor: "field-firstName", $required: !0, children: "First Name" }),
333
319
  /* @__PURE__ */ a(
334
- N,
320
+ C,
335
321
  {
336
322
  id: "field-firstName",
337
323
  type: "text",
338
324
  autoComplete: "given-name",
339
325
  value: d.firstName,
340
- onChange: b("firstName"),
341
- onBlur: y("firstName"),
326
+ onChange: h("firstName"),
327
+ onBlur: b("firstName"),
342
328
  maxLength: 30,
343
329
  disabled: u,
344
330
  $hasError: !!o("firstName"),
@@ -347,7 +333,7 @@ const Te = ({
347
333
  "aria-describedby": o("firstName") ? "err-firstName" : void 0
348
334
  }
349
335
  ),
350
- o("firstName") && /* @__PURE__ */ s(g, { id: "err-firstName", role: "alert", children: [
336
+ o("firstName") && /* @__PURE__ */ s(v, { id: "err-firstName", role: "alert", children: [
351
337
  /* @__PURE__ */ a("span", { "aria-hidden": "true", children: "⚠" }),
352
338
  f,
353
339
  " ",
@@ -355,16 +341,16 @@ const Te = ({
355
341
  ] })
356
342
  ] }),
357
343
  /* @__PURE__ */ s(p, { children: [
358
- /* @__PURE__ */ a($, { htmlFor: "field-lastName", $required: !0, children: "Last Name" }),
344
+ /* @__PURE__ */ a(y, { htmlFor: "field-lastName", $required: !0, children: "Last Name" }),
359
345
  /* @__PURE__ */ a(
360
- N,
346
+ C,
361
347
  {
362
348
  id: "field-lastName",
363
349
  type: "text",
364
350
  autoComplete: "family-name",
365
351
  value: d.lastName,
366
- onChange: b("lastName"),
367
- onBlur: y("lastName"),
352
+ onChange: h("lastName"),
353
+ onBlur: b("lastName"),
368
354
  maxLength: 40,
369
355
  disabled: u,
370
356
  $hasError: !!o("lastName"),
@@ -373,7 +359,7 @@ const Te = ({
373
359
  "aria-describedby": o("lastName") ? "err-lastName" : void 0
374
360
  }
375
361
  ),
376
- o("lastName") && /* @__PURE__ */ s(g, { id: "err-lastName", role: "alert", children: [
362
+ o("lastName") && /* @__PURE__ */ s(v, { id: "err-lastName", role: "alert", children: [
377
363
  /* @__PURE__ */ a("span", { "aria-hidden": "true", children: "⚠" }),
378
364
  f,
379
365
  " ",
@@ -382,14 +368,14 @@ const Te = ({
382
368
  ] })
383
369
  ] }),
384
370
  /* @__PURE__ */ s(p, { children: [
385
- /* @__PURE__ */ a($, { htmlFor: "field-country", $required: !0, children: "Country" }),
371
+ /* @__PURE__ */ a(y, { htmlFor: "field-country", $required: !0, children: "Country" }),
386
372
  /* @__PURE__ */ s(
387
373
  O,
388
374
  {
389
375
  id: "field-country",
390
376
  value: d.country,
391
377
  onChange: X,
392
- onBlur: y("country"),
378
+ onBlur: b("country"),
393
379
  disabled: u,
394
380
  $hasError: !!o("country"),
395
381
  "aria-required": "true",
@@ -406,7 +392,7 @@ const Te = ({
406
392
  ]
407
393
  }
408
394
  ),
409
- o("country") && /* @__PURE__ */ s(g, { id: "err-country", role: "alert", children: [
395
+ o("country") && /* @__PURE__ */ s(v, { id: "err-country", role: "alert", children: [
410
396
  /* @__PURE__ */ a("span", { "aria-hidden": "true", children: "⚠" }),
411
397
  f,
412
398
  " ",
@@ -414,16 +400,16 @@ const Te = ({
414
400
  ] })
415
401
  ] }),
416
402
  /* @__PURE__ */ s(p, { children: [
417
- /* @__PURE__ */ a($, { htmlFor: "field-address1", $required: !0, children: "Address Line 1" }),
403
+ /* @__PURE__ */ a(y, { htmlFor: "field-address1", $required: !0, children: "Address Line 1" }),
418
404
  /* @__PURE__ */ a(
419
- N,
405
+ C,
420
406
  {
421
407
  id: "field-address1",
422
408
  type: "text",
423
409
  autoComplete: "address-line1",
424
410
  value: d.address1,
425
- onChange: b("address1"),
426
- onBlur: y("address1"),
411
+ onChange: h("address1"),
412
+ onBlur: b("address1"),
427
413
  maxLength: 50,
428
414
  disabled: u,
429
415
  $hasError: !!o("address1"),
@@ -432,7 +418,7 @@ const Te = ({
432
418
  "aria-describedby": o("address1") ? "err-address1" : void 0
433
419
  }
434
420
  ),
435
- o("address1") && /* @__PURE__ */ s(g, { id: "err-address1", role: "alert", children: [
421
+ o("address1") && /* @__PURE__ */ s(v, { id: "err-address1", role: "alert", children: [
436
422
  /* @__PURE__ */ a("span", { "aria-hidden": "true", children: "⚠" }),
437
423
  f,
438
424
  " ",
@@ -440,34 +426,34 @@ const Te = ({
440
426
  ] })
441
427
  ] }),
442
428
  /* @__PURE__ */ s(p, { children: [
443
- /* @__PURE__ */ a($, { htmlFor: "field-address2", children: "Address Line 2 (Optional)" }),
429
+ /* @__PURE__ */ a(y, { htmlFor: "field-address2", children: "Address Line 2 (Optional)" }),
444
430
  /* @__PURE__ */ a(
445
- N,
431
+ C,
446
432
  {
447
433
  id: "field-address2",
448
434
  type: "text",
449
435
  autoComplete: "address-line2",
450
436
  value: d.address2,
451
- onChange: b("address2"),
452
- onBlur: y("address2"),
437
+ onChange: h("address2"),
438
+ onBlur: b("address2"),
453
439
  maxLength: 50,
454
440
  disabled: u,
455
441
  $hasError: !1
456
442
  }
457
443
  )
458
444
  ] }),
459
- /* @__PURE__ */ s(M, { children: [
445
+ /* @__PURE__ */ s(_, { children: [
460
446
  /* @__PURE__ */ s(p, { children: [
461
- /* @__PURE__ */ a($, { htmlFor: "field-city", $required: !0, children: "City" }),
447
+ /* @__PURE__ */ a(y, { htmlFor: "field-city", $required: !0, children: "City" }),
462
448
  /* @__PURE__ */ a(
463
- N,
449
+ C,
464
450
  {
465
451
  id: "field-city",
466
452
  type: "text",
467
453
  autoComplete: "address-level2",
468
454
  value: d.city,
469
- onChange: b("city"),
470
- onBlur: y("city"),
455
+ onChange: h("city"),
456
+ onBlur: b("city"),
471
457
  maxLength: 30,
472
458
  disabled: u,
473
459
  $hasError: !!o("city"),
@@ -476,7 +462,7 @@ const Te = ({
476
462
  "aria-describedby": o("city") ? "err-city" : void 0
477
463
  }
478
464
  ),
479
- o("city") && /* @__PURE__ */ s(g, { id: "err-city", role: "alert", children: [
465
+ o("city") && /* @__PURE__ */ s(v, { id: "err-city", role: "alert", children: [
480
466
  /* @__PURE__ */ a("span", { "aria-hidden": "true", children: "⚠" }),
481
467
  f,
482
468
  " ",
@@ -484,18 +470,18 @@ const Te = ({
484
470
  ] })
485
471
  ] }),
486
472
  /* @__PURE__ */ s(p, { children: [
487
- /* @__PURE__ */ a($, { htmlFor: "field-postal", $required: !0, children: "Postal Code" }),
473
+ /* @__PURE__ */ a(y, { htmlFor: "field-postal", $required: !0, children: "Postal Code" }),
488
474
  /* @__PURE__ */ a(
489
- N,
475
+ C,
490
476
  {
491
477
  id: "field-postal",
492
478
  type: "text",
493
479
  autoComplete: "postal-code",
494
- inputMode: h.postalInputMode,
495
- placeholder: h.postalExamples,
480
+ inputMode: $.postalInputMode,
481
+ placeholder: $.postalExamples,
496
482
  value: d.postal,
497
- onChange: b("postal"),
498
- onBlur: y("postal"),
483
+ onChange: h("postal"),
484
+ onBlur: b("postal"),
499
485
  maxLength: 10,
500
486
  disabled: u,
501
487
  $hasError: !!o("postal"),
@@ -504,7 +490,7 @@ const Te = ({
504
490
  "aria-describedby": o("postal") ? "err-postal" : void 0
505
491
  }
506
492
  ),
507
- o("postal") && /* @__PURE__ */ s(g, { id: "err-postal", role: "alert", children: [
493
+ o("postal") && /* @__PURE__ */ s(v, { id: "err-postal", role: "alert", children: [
508
494
  /* @__PURE__ */ a("span", { "aria-hidden": "true", children: "⚠" }),
509
495
  f,
510
496
  " ",
@@ -513,17 +499,17 @@ const Te = ({
513
499
  ] })
514
500
  ] }),
515
501
  J && /* @__PURE__ */ s(p, { children: [
516
- /* @__PURE__ */ a($, { htmlFor: "field-state", $required: h.stateRequired, children: "State / Province" }),
502
+ /* @__PURE__ */ a(y, { htmlFor: "field-state", $required: $.stateRequired, children: "State / Province" }),
517
503
  /* @__PURE__ */ s(
518
504
  O,
519
505
  {
520
506
  id: "field-state",
521
507
  value: d.state,
522
- onChange: b("state"),
523
- onBlur: y("state"),
508
+ onChange: h("state"),
509
+ onBlur: b("state"),
524
510
  disabled: u,
525
511
  $hasError: !!o("state"),
526
- "aria-required": h.stateRequired,
512
+ "aria-required": $.stateRequired,
527
513
  "aria-invalid": !!o("state"),
528
514
  "aria-describedby": o("state") ? "err-state" : void 0,
529
515
  autoComplete: "address-level1",
@@ -533,7 +519,7 @@ const Te = ({
533
519
  ]
534
520
  }
535
521
  ),
536
- o("state") && /* @__PURE__ */ s(g, { id: "err-state", role: "alert", children: [
522
+ o("state") && /* @__PURE__ */ s(v, { id: "err-state", role: "alert", children: [
537
523
  /* @__PURE__ */ a("span", { "aria-hidden": "true", children: "⚠" }),
538
524
  f,
539
525
  " ",
@@ -541,54 +527,41 @@ const Te = ({
541
527
  ] })
542
528
  ] }),
543
529
  F && /* @__PURE__ */ s(p, { children: [
544
- /* @__PURE__ */ a($, { htmlFor: "field-phoneNumber", children: "Phone Number" }),
545
- /* @__PURE__ */ s(he, { children: [
546
- h.dialCode && /* @__PURE__ */ s(be, { "aria-label": `Dial code ${h.dialCode}`, children: [
547
- ((_ = L.find((t) => t.code === d.country)) == null ? void 0 : _.flag) ?? "",
548
- " ",
549
- h.dialCode
550
- ] }),
551
- /* @__PURE__ */ a(
552
- N,
553
- {
554
- id: "field-phoneNumber",
555
- type: "tel",
556
- autoComplete: "tel",
557
- value: d.phoneNumber,
558
- onChange: b("phoneNumber"),
559
- onBlur: y("phoneNumber"),
560
- maxLength: 20,
561
- disabled: u,
562
- $hasError: !!o("phoneNumber"),
563
- "aria-invalid": !!o("phoneNumber"),
564
- "aria-describedby": o("phoneNumber") ? "err-phoneNumber" : void 0
565
- }
566
- )
567
- ] }),
568
- o("phoneNumber") && /* @__PURE__ */ s(g, { id: "err-phoneNumber", role: "alert", children: [
569
- /* @__PURE__ */ a("span", { "aria-hidden": "true", children: "⚠" }),
570
- f,
571
- " ",
572
- o("phoneNumber")
573
- ] })
530
+ /* @__PURE__ */ a(y, { htmlFor: "field-phoneNumber", children: "Phone Number" }),
531
+ /* @__PURE__ */ a(
532
+ te,
533
+ {
534
+ id: "field-phoneNumber",
535
+ value: d.phoneNumber,
536
+ dialCode: $.dialCode,
537
+ flagEmoji: ((M = A.find((t) => t.code === d.country)) == null ? void 0 : M.flag) ?? "",
538
+ countryCode: d.country,
539
+ onChange: h("phoneNumber"),
540
+ onBlur: b("phoneNumber"),
541
+ disabled: u,
542
+ hasError: !!o("phoneNumber"),
543
+ errorMessage: o("phoneNumber") || void 0,
544
+ screenReaderErrorPrefix: f
545
+ }
546
+ )
574
547
  ] }),
575
- /* @__PURE__ */ a(p, { children: /* @__PURE__ */ s(ie, { children: [
548
+ /* @__PURE__ */ a(p, { children: /* @__PURE__ */ s(ce, { children: [
576
549
  /* @__PURE__ */ a(
577
- ce,
550
+ ue,
578
551
  {
579
552
  id: "field-defaultAddress",
580
553
  type: "checkbox",
581
554
  checked: d.defaultAddress,
582
- onChange: b("defaultAddress"),
555
+ onChange: h("defaultAddress"),
583
556
  disabled: u
584
557
  }
585
558
  ),
586
- /* @__PURE__ */ a(ue, { htmlFor: "field-defaultAddress", children: "Make this my default address." })
559
+ /* @__PURE__ */ a(pe, { htmlFor: "field-defaultAddress", children: "Make this my default address." })
587
560
  ] }) }),
588
- /* @__PURE__ */ s(pe, { children: [
589
- /* @__PURE__ */ a(me, { type: "button", disabled: u, onClick: G, children: "Cancel" }),
590
- /* @__PURE__ */ s(fe, { type: "submit", disabled: u, children: [
591
- P && /* @__PURE__ */ a($e, { "aria-hidden": "true" }),
561
+ /* @__PURE__ */ s(me, { children: [
562
+ /* @__PURE__ */ a(fe, { type: "button", disabled: u, onClick: G, children: "Cancel" }),
563
+ /* @__PURE__ */ s(he, { type: "submit", disabled: u, children: [
564
+ P && /* @__PURE__ */ a(ye, { "aria-hidden": "true" }),
592
565
  "Confirm Address"
593
566
  ] })
594
567
  ] })
@@ -0,0 +1,57 @@
1
+ import { default as React } from 'react';
2
+ export interface PhoneFieldProps {
3
+ /** Current phone number value (local number, without dial code) */
4
+ value: string;
5
+ /** Dial code to display as non-editable prefix (e.g. '+1', '+44') */
6
+ dialCode: string;
7
+ /** Flag emoji for the selected country (e.g. '🇺🇸') */
8
+ flagEmoji: string;
9
+ /** ISO 3166-1 alpha-2 code used for aria-label on the dial code prefix */
10
+ countryCode: string;
11
+ /** Called when the input value changes */
12
+ onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
13
+ /** Called when the input loses focus */
14
+ onBlur: () => void;
15
+ /** Disable all interaction */
16
+ disabled?: boolean;
17
+ /** Whether the field is in an error state (red border) */
18
+ hasError?: boolean;
19
+ /** Error message to render below the field */
20
+ errorMessage?: string;
21
+ /** Screen reader prefix prepended to error messages (GDS requirement) */
22
+ screenReaderErrorPrefix?: string;
23
+ /** id attribute for the underlying <input> — used for label association */
24
+ id?: string;
25
+ }
26
+ /**
27
+ * PhoneField — a phone number input with a non-interactive country dial code prefix.
28
+ *
29
+ * The dial code is derived from the country selected in the parent `AddressForm` and
30
+ * is read-only — the fan selects their country in the country dropdown, which updates
31
+ * the dial code automatically. The fan only types the local number portion here.
32
+ *
33
+ * Phone is optional — empty value does not trigger validation. Validation occurs on
34
+ * blur when the field is non-empty, using `validatePhoneNumber` (libphonenumber-js/max).
35
+ *
36
+ * Usage in AddressForm:
37
+ * ```tsx
38
+ * <PhoneField
39
+ * id="field-phoneNumber"
40
+ * value={values.phoneNumber}
41
+ * dialCode={countryConfig.dialCode}
42
+ * flagEmoji={flag}
43
+ * countryCode={values.country}
44
+ * onChange={handleChange('phoneNumber')}
45
+ * onBlur={handleBlur('phoneNumber')}
46
+ * disabled={isDisabled}
47
+ * hasError={Boolean(getFieldError('phoneNumber'))}
48
+ * errorMessage={getFieldError('phoneNumber')}
49
+ * screenReaderErrorPrefix={screenReaderErrorPrefix}
50
+ * />
51
+ * ```
52
+ *
53
+ * TODO(GDS swap): Replace with GDS PhoneNumber component. The GDS PhoneNumber
54
+ * component provides built-in dial code selection integrated with the CountryPicker.
55
+ */
56
+ export declare const PhoneField: React.FC<PhoneFieldProps>;
57
+ export default PhoneField;