@ticketmaster/tm-global-address 0.6.0 → 0.7.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.
Files changed (68) hide show
  1. package/dist/components/AddressCard/AddressCard.d.ts +5 -0
  2. package/dist/components/AddressCard/AddressCard.js +45 -46
  3. package/dist/components/AddressForm/AddressForm.d.ts +14 -2
  4. package/dist/components/AddressForm/AddressForm.js +216 -212
  5. package/dist/components/AddressList/AddressList.d.ts +7 -2
  6. package/dist/components/AddressList/AddressList.js +41 -37
  7. package/dist/i18n/defaultLabels.d.ts +2 -0
  8. package/dist/i18n/defaultLabels.js +66 -0
  9. package/dist/i18n/index.d.ts +14 -0
  10. package/dist/i18n/index.js +45 -0
  11. package/dist/i18n/labelResolver.d.ts +24 -0
  12. package/dist/i18n/labelResolver.js +98 -0
  13. package/dist/i18n/locales/ar-sa.json.d.ts +159 -0
  14. package/dist/i18n/locales/ar-sa.json.js +163 -0
  15. package/dist/i18n/locales/ca-es.json.d.ts +159 -0
  16. package/dist/i18n/locales/ca-es.json.js +163 -0
  17. package/dist/i18n/locales/cs-cz.json.d.ts +159 -0
  18. package/dist/i18n/locales/cs-cz.json.js +163 -0
  19. package/dist/i18n/locales/da-dk.json.d.ts +159 -0
  20. package/dist/i18n/locales/da-dk.json.js +163 -0
  21. package/dist/i18n/locales/de-at.json.d.ts +159 -0
  22. package/dist/i18n/locales/de-at.json.js +163 -0
  23. package/dist/i18n/locales/de-ch.json.d.ts +159 -0
  24. package/dist/i18n/locales/de-ch.json.js +163 -0
  25. package/dist/i18n/locales/de-de.json.d.ts +159 -0
  26. package/dist/i18n/locales/de-de.json.js +163 -0
  27. package/dist/i18n/locales/en-au.json.d.ts +159 -0
  28. package/dist/i18n/locales/en-au.json.js +163 -0
  29. package/dist/i18n/locales/en-ca.json.d.ts +159 -0
  30. package/dist/i18n/locales/en-ca.json.js +163 -0
  31. package/dist/i18n/locales/en-gb.json.d.ts +159 -0
  32. package/dist/i18n/locales/en-gb.json.js +163 -0
  33. package/dist/i18n/locales/en-nz.json.d.ts +159 -0
  34. package/dist/i18n/locales/en-nz.json.js +163 -0
  35. package/dist/i18n/locales/en-us.json.d.ts +159 -0
  36. package/dist/i18n/locales/en-us.json.js +163 -0
  37. package/dist/i18n/locales/es-es.json.d.ts +159 -0
  38. package/dist/i18n/locales/es-es.json.js +163 -0
  39. package/dist/i18n/locales/es-mx.json.d.ts +159 -0
  40. package/dist/i18n/locales/es-mx.json.js +163 -0
  41. package/dist/i18n/locales/fi-fi.json.d.ts +159 -0
  42. package/dist/i18n/locales/fi-fi.json.js +163 -0
  43. package/dist/i18n/locales/fr-be.json.d.ts +159 -0
  44. package/dist/i18n/locales/fr-be.json.js +163 -0
  45. package/dist/i18n/locales/fr-ca.json.d.ts +159 -0
  46. package/dist/i18n/locales/fr-ca.json.js +163 -0
  47. package/dist/i18n/locales/fr-ch.json.d.ts +159 -0
  48. package/dist/i18n/locales/fr-ch.json.js +163 -0
  49. package/dist/i18n/locales/fr-fr.json.d.ts +159 -0
  50. package/dist/i18n/locales/fr-fr.json.js +163 -0
  51. package/dist/i18n/locales/it-ch.json.d.ts +159 -0
  52. package/dist/i18n/locales/it-ch.json.js +163 -0
  53. package/dist/i18n/locales/ja-jp.json.d.ts +159 -0
  54. package/dist/i18n/locales/ja-jp.json.js +163 -0
  55. package/dist/i18n/locales/nl-be.json.d.ts +159 -0
  56. package/dist/i18n/locales/nl-be.json.js +163 -0
  57. package/dist/i18n/locales/nl-nl.json.d.ts +159 -0
  58. package/dist/i18n/locales/nl-nl.json.js +163 -0
  59. package/dist/i18n/locales/no-no.json.d.ts +159 -0
  60. package/dist/i18n/locales/no-no.json.js +163 -0
  61. package/dist/i18n/locales/pl-pl.json.d.ts +159 -0
  62. package/dist/i18n/locales/pl-pl.json.js +163 -0
  63. package/dist/i18n/locales/sv-se.json.d.ts +159 -0
  64. package/dist/i18n/locales/sv-se.json.js +163 -0
  65. package/dist/i18n/types.d.ts +67 -0
  66. package/dist/index.d.ts +2 -0
  67. package/dist/index.js +46 -38
  68. package/package.json +1 -1
@@ -14,6 +14,11 @@ export interface AddressCardProps {
14
14
  disabled?: boolean;
15
15
  /** Error message to show inline under this card */
16
16
  errorMessage?: string;
17
+ /**
18
+ * BCP-47 locale tag. Controls button labels and badge text.
19
+ * Defaults to "en-us".
20
+ */
21
+ locale?: string;
17
22
  }
18
23
  /**
19
24
  * Formats an AddressData into a single-line summary string.
@@ -1,17 +1,15 @@
1
- import { jsxs as p, jsx as n } from "react/jsx-runtime";
1
+ import { jsxs as f, jsx as i } from "react/jsx-runtime";
2
2
  import t from "styled-components";
3
3
  import { tokens as o } from "../../styles/tokens.js";
4
- import { getCountryName as m } from "../../data/countryData.js";
5
- function y(e) {
6
- const a = [e.address1], l = [
7
- e.city,
8
- [e.state, e.postal].filter(Boolean).join(" ")
9
- ].filter(Boolean).join(" · ");
10
- l && a.push(l);
11
- const d = m(e.country);
12
- return d && a.push(d), e.phoneNumber && a.push(e.phoneNumber), a.join(" · ");
4
+ import { getCountryName as g } from "../../data/countryData.js";
5
+ import { useLabels as h } from "../../i18n/index.js";
6
+ function b(e) {
7
+ const n = [e.address1], l = [e.city, [e.state, e.postal].filter(Boolean).join(" ")].filter(Boolean).join(" · ");
8
+ l && n.push(l);
9
+ const d = g(e.country);
10
+ return d && n.push(d), e.phoneNumber && n.push(e.phoneNumber), n.join(" · ");
13
11
  }
14
- const h = t.div`
12
+ const x = t.div`
15
13
  padding: ${o.space4};
16
14
  border: ${o.borderWidthInput} solid
17
15
  ${(e) => e.$isSelected ? o.colorInteractivePrimary : o.colorBorderInput};
@@ -23,22 +21,22 @@ const h = t.div`
23
21
  & + & {
24
22
  margin-block-start: ${o.space3};
25
23
  }
26
- `, g = t.div`
24
+ `, B = t.div`
27
25
  display: flex;
28
26
  align-items: flex-start;
29
27
  justify-content: space-between;
30
28
  gap: ${o.space2};
31
29
  flex-wrap: wrap;
32
- `, b = t.div`
30
+ `, v = t.div`
33
31
  display: flex;
34
32
  align-items: center;
35
33
  gap: ${o.space2};
36
34
  flex-wrap: wrap;
37
- `, x = t.span`
35
+ `, w = t.span`
38
36
  font-weight: ${o.fontWeightBold};
39
37
  font-size: ${o.fontSizeBody};
40
38
  color: ${o.colorTextPrimary};
41
- `, v = t.span`
39
+ `, k = t.span`
42
40
  display: inline-block;
43
41
  padding: 2px ${o.space2};
44
42
  border: ${o.borderWidthInput} solid ${o.colorBadgeBorder};
@@ -49,12 +47,12 @@ const h = t.div`
49
47
  color: ${o.colorBadgeText};
50
48
  text-transform: uppercase;
51
49
  white-space: nowrap;
52
- `, w = t.p`
50
+ `, C = t.p`
53
51
  margin: ${o.space1} 0 0;
54
52
  font-size: ${o.fontSizeBody};
55
53
  color: ${o.colorTextSecondary};
56
54
  line-height: ${o.lineHeightBody};
57
- `, B = t.div`
55
+ `, I = t.div`
58
56
  display: flex;
59
57
  align-items: center;
60
58
  gap: ${o.space3};
@@ -87,74 +85,75 @@ const h = t.div`
87
85
  cursor: not-allowed;
88
86
  text-decoration: none;
89
87
  }
90
- `, k = t.p`
88
+ `, z = t.p`
91
89
  margin: ${o.space2} 0 0;
92
90
  font-size: ${o.fontSizeError};
93
91
  color: ${o.colorTextError};
94
- `, j = ({
92
+ `, W = ({
95
93
  address: e,
96
- isSelected: a = !1,
94
+ isSelected: n = !1,
97
95
  onEdit: l,
98
96
  onDelete: d,
99
97
  onSelect: r,
100
98
  disabled: c = !1,
101
- errorMessage: f
99
+ errorMessage: u,
100
+ locale: m = "en-us"
102
101
  }) => {
103
- const u = y(e), s = `${e.firstName} ${e.lastName}`;
104
- return /* @__PURE__ */ p(
105
- h,
102
+ const { form: s } = h(m, e.country), y = b(e), p = `${e.firstName} ${e.lastName}`;
103
+ return /* @__PURE__ */ f(
104
+ x,
106
105
  {
107
- $isSelected: a,
106
+ $isSelected: n,
108
107
  $disabled: c,
109
108
  onClick: r ? () => {
110
109
  !c && r && r(e);
111
110
  } : void 0,
112
- onKeyDown: r ? (i) => {
113
- !c && r && (i.key === "Enter" || i.key === " ") && (i.preventDefault(), r(e));
111
+ onKeyDown: r ? (a) => {
112
+ !c && r && (a.key === "Enter" || a.key === " ") && (a.preventDefault(), r(e));
114
113
  } : void 0,
115
114
  role: r ? "option" : void 0,
116
- "aria-selected": r ? a : void 0,
115
+ "aria-selected": r ? n : void 0,
117
116
  tabIndex: r && !c ? 0 : void 0,
118
117
  "data-testid": `address-card-${e.addressId}`,
119
118
  children: [
120
- /* @__PURE__ */ n(g, { children: /* @__PURE__ */ p(b, { children: [
121
- /* @__PURE__ */ n(x, { children: s }),
122
- e.defaultAddress && /* @__PURE__ */ n(v, { "aria-label": "Default address", children: "Default" })
119
+ /* @__PURE__ */ i(B, { children: /* @__PURE__ */ f(v, { children: [
120
+ /* @__PURE__ */ i(w, { children: p }),
121
+ e.defaultAddress && /* @__PURE__ */ i(k, { "aria-label": "Default address", children: s.defaultBadge })
123
122
  ] }) }),
124
- /* @__PURE__ */ n(w, { children: u }),
125
- (l || d) && /* @__PURE__ */ p(B, { children: [
126
- l && /* @__PURE__ */ n(
123
+ /* @__PURE__ */ i(C, { children: y }),
124
+ (l || d) && /* @__PURE__ */ f(I, { children: [
125
+ l && /* @__PURE__ */ i(
127
126
  $,
128
127
  {
129
128
  type: "button",
130
129
  disabled: c,
131
- onClick: (i) => {
132
- i.stopPropagation(), l(e);
130
+ onClick: (a) => {
131
+ a.stopPropagation(), l(e);
133
132
  },
134
- "aria-label": `Edit address for ${s}`,
135
- children: "Edit"
133
+ "aria-label": `${s.editButton} address for ${p}`,
134
+ children: s.editButton
136
135
  }
137
136
  ),
138
- d && /* @__PURE__ */ n(
137
+ d && /* @__PURE__ */ i(
139
138
  $,
140
139
  {
141
140
  type: "button",
142
141
  $variant: "danger",
143
142
  disabled: c,
144
- onClick: (i) => {
145
- i.stopPropagation(), d(e.addressId);
143
+ onClick: (a) => {
144
+ a.stopPropagation(), d(e.addressId);
146
145
  },
147
- "aria-label": `Delete address for ${s}`,
148
- children: "Delete"
146
+ "aria-label": `${s.deleteButton} address for ${p}`,
147
+ children: s.deleteButton
149
148
  }
150
149
  )
151
150
  ] }),
152
- f && /* @__PURE__ */ n(k, { role: "alert", children: f })
151
+ u && /* @__PURE__ */ i(z, { role: "alert", children: u })
153
152
  ]
154
153
  }
155
154
  );
156
155
  };
157
156
  export {
158
- j as AddressCard,
159
- y as formatAddressSummary
157
+ W as AddressCard,
158
+ b as formatAddressSummary
160
159
  };
@@ -1,5 +1,6 @@
1
1
  import { default as React } from 'react';
2
2
  import { SaveAddressPayload, FieldError, AddressData } from '../../types/AddressData';
3
+ import { ResolvedLabels } from '../../i18n/types';
3
4
  export interface AddressFormProps {
4
5
  /** Mode controls whether form is in add or edit flow */
5
6
  mode: 'create' | 'edit';
@@ -11,8 +12,19 @@ export interface AddressFormProps {
11
12
  showPhoneNumber?: boolean;
12
13
  /** Screen reader prefix for all inputs (GDS requirement) */
13
14
  screenReaderErrorPrefix: string;
14
- /** Section label above the form */
15
- addressLabel: string;
15
+ /** Section label above the form (overrides i18n addressHeading when provided) */
16
+ addressLabel?: string;
17
+ /**
18
+ * BCP-47 locale tag (e.g. "en-us", "fr-fr", "de-de", "ar-sa").
19
+ * Controls field labels, placeholders, validation messages, and RTL layout.
20
+ * Defaults to "en-us".
21
+ */
22
+ locale?: string;
23
+ /**
24
+ * Override labels — merged on top of resolved locale labels.
25
+ * Useful when the consuming app wants to customise specific strings.
26
+ */
27
+ labels?: Partial<ResolvedLabels['form']>;
16
28
  /** Whether the form is in a loading state (submit in flight) */
17
29
  isLoading?: boolean;
18
30
  /** Disable all form interactions */