@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.
- package/dist/components/AddressCard/AddressCard.d.ts +5 -0
- package/dist/components/AddressCard/AddressCard.js +45 -46
- package/dist/components/AddressForm/AddressForm.d.ts +14 -2
- package/dist/components/AddressForm/AddressForm.js +216 -212
- package/dist/components/AddressList/AddressList.d.ts +7 -2
- package/dist/components/AddressList/AddressList.js +41 -37
- package/dist/i18n/defaultLabels.d.ts +2 -0
- package/dist/i18n/defaultLabels.js +66 -0
- package/dist/i18n/index.d.ts +14 -0
- package/dist/i18n/index.js +45 -0
- package/dist/i18n/labelResolver.d.ts +24 -0
- package/dist/i18n/labelResolver.js +98 -0
- package/dist/i18n/locales/ar-sa.json.d.ts +159 -0
- package/dist/i18n/locales/ar-sa.json.js +163 -0
- package/dist/i18n/locales/ca-es.json.d.ts +159 -0
- package/dist/i18n/locales/ca-es.json.js +163 -0
- package/dist/i18n/locales/cs-cz.json.d.ts +159 -0
- package/dist/i18n/locales/cs-cz.json.js +163 -0
- package/dist/i18n/locales/da-dk.json.d.ts +159 -0
- package/dist/i18n/locales/da-dk.json.js +163 -0
- package/dist/i18n/locales/de-at.json.d.ts +159 -0
- package/dist/i18n/locales/de-at.json.js +163 -0
- package/dist/i18n/locales/de-ch.json.d.ts +159 -0
- package/dist/i18n/locales/de-ch.json.js +163 -0
- package/dist/i18n/locales/de-de.json.d.ts +159 -0
- package/dist/i18n/locales/de-de.json.js +163 -0
- package/dist/i18n/locales/en-au.json.d.ts +159 -0
- package/dist/i18n/locales/en-au.json.js +163 -0
- package/dist/i18n/locales/en-ca.json.d.ts +159 -0
- package/dist/i18n/locales/en-ca.json.js +163 -0
- package/dist/i18n/locales/en-gb.json.d.ts +159 -0
- package/dist/i18n/locales/en-gb.json.js +163 -0
- package/dist/i18n/locales/en-nz.json.d.ts +159 -0
- package/dist/i18n/locales/en-nz.json.js +163 -0
- package/dist/i18n/locales/en-us.json.d.ts +159 -0
- package/dist/i18n/locales/en-us.json.js +163 -0
- package/dist/i18n/locales/es-es.json.d.ts +159 -0
- package/dist/i18n/locales/es-es.json.js +163 -0
- package/dist/i18n/locales/es-mx.json.d.ts +159 -0
- package/dist/i18n/locales/es-mx.json.js +163 -0
- package/dist/i18n/locales/fi-fi.json.d.ts +159 -0
- package/dist/i18n/locales/fi-fi.json.js +163 -0
- package/dist/i18n/locales/fr-be.json.d.ts +159 -0
- package/dist/i18n/locales/fr-be.json.js +163 -0
- package/dist/i18n/locales/fr-ca.json.d.ts +159 -0
- package/dist/i18n/locales/fr-ca.json.js +163 -0
- package/dist/i18n/locales/fr-ch.json.d.ts +159 -0
- package/dist/i18n/locales/fr-ch.json.js +163 -0
- package/dist/i18n/locales/fr-fr.json.d.ts +159 -0
- package/dist/i18n/locales/fr-fr.json.js +163 -0
- package/dist/i18n/locales/it-ch.json.d.ts +159 -0
- package/dist/i18n/locales/it-ch.json.js +163 -0
- package/dist/i18n/locales/ja-jp.json.d.ts +159 -0
- package/dist/i18n/locales/ja-jp.json.js +163 -0
- package/dist/i18n/locales/nl-be.json.d.ts +159 -0
- package/dist/i18n/locales/nl-be.json.js +163 -0
- package/dist/i18n/locales/nl-nl.json.d.ts +159 -0
- package/dist/i18n/locales/nl-nl.json.js +163 -0
- package/dist/i18n/locales/no-no.json.d.ts +159 -0
- package/dist/i18n/locales/no-no.json.js +163 -0
- package/dist/i18n/locales/pl-pl.json.d.ts +159 -0
- package/dist/i18n/locales/pl-pl.json.js +163 -0
- package/dist/i18n/locales/sv-se.json.d.ts +159 -0
- package/dist/i18n/locales/sv-se.json.js +163 -0
- package/dist/i18n/types.d.ts +67 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +46 -38
- 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
|
|
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
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
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
|
-
`,
|
|
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
|
-
`,
|
|
30
|
+
`, v = t.div`
|
|
33
31
|
display: flex;
|
|
34
32
|
align-items: center;
|
|
35
33
|
gap: ${o.space2};
|
|
36
34
|
flex-wrap: wrap;
|
|
37
|
-
`,
|
|
35
|
+
`, w = t.span`
|
|
38
36
|
font-weight: ${o.fontWeightBold};
|
|
39
37
|
font-size: ${o.fontSizeBody};
|
|
40
38
|
color: ${o.colorTextPrimary};
|
|
41
|
-
`,
|
|
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
|
-
`,
|
|
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
|
-
`,
|
|
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
|
-
`,
|
|
88
|
+
`, z = t.p`
|
|
91
89
|
margin: ${o.space2} 0 0;
|
|
92
90
|
font-size: ${o.fontSizeError};
|
|
93
91
|
color: ${o.colorTextError};
|
|
94
|
-
`,
|
|
92
|
+
`, W = ({
|
|
95
93
|
address: e,
|
|
96
|
-
isSelected:
|
|
94
|
+
isSelected: n = !1,
|
|
97
95
|
onEdit: l,
|
|
98
96
|
onDelete: d,
|
|
99
97
|
onSelect: r,
|
|
100
98
|
disabled: c = !1,
|
|
101
|
-
errorMessage:
|
|
99
|
+
errorMessage: u,
|
|
100
|
+
locale: m = "en-us"
|
|
102
101
|
}) => {
|
|
103
|
-
const
|
|
104
|
-
return /* @__PURE__ */
|
|
105
|
-
|
|
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:
|
|
106
|
+
$isSelected: n,
|
|
108
107
|
$disabled: c,
|
|
109
108
|
onClick: r ? () => {
|
|
110
109
|
!c && r && r(e);
|
|
111
110
|
} : void 0,
|
|
112
|
-
onKeyDown: r ? (
|
|
113
|
-
!c && r && (
|
|
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 ?
|
|
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__ */
|
|
121
|
-
/* @__PURE__ */
|
|
122
|
-
e.defaultAddress && /* @__PURE__ */
|
|
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__ */
|
|
125
|
-
(l || d) && /* @__PURE__ */
|
|
126
|
-
l && /* @__PURE__ */
|
|
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: (
|
|
132
|
-
|
|
130
|
+
onClick: (a) => {
|
|
131
|
+
a.stopPropagation(), l(e);
|
|
133
132
|
},
|
|
134
|
-
"aria-label":
|
|
135
|
-
children:
|
|
133
|
+
"aria-label": `${s.editButton} address for ${p}`,
|
|
134
|
+
children: s.editButton
|
|
136
135
|
}
|
|
137
136
|
),
|
|
138
|
-
d && /* @__PURE__ */
|
|
137
|
+
d && /* @__PURE__ */ i(
|
|
139
138
|
$,
|
|
140
139
|
{
|
|
141
140
|
type: "button",
|
|
142
141
|
$variant: "danger",
|
|
143
142
|
disabled: c,
|
|
144
|
-
onClick: (
|
|
145
|
-
|
|
143
|
+
onClick: (a) => {
|
|
144
|
+
a.stopPropagation(), d(e.addressId);
|
|
146
145
|
},
|
|
147
|
-
"aria-label":
|
|
148
|
-
children:
|
|
146
|
+
"aria-label": `${s.deleteButton} address for ${p}`,
|
|
147
|
+
children: s.deleteButton
|
|
149
148
|
}
|
|
150
149
|
)
|
|
151
150
|
] }),
|
|
152
|
-
|
|
151
|
+
u && /* @__PURE__ */ i(z, { role: "alert", children: u })
|
|
153
152
|
]
|
|
154
153
|
}
|
|
155
154
|
);
|
|
156
155
|
};
|
|
157
156
|
export {
|
|
158
|
-
|
|
159
|
-
|
|
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
|
|
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 */
|