playbook_ui 14.25.0.pre.alpha.PLAY2450iconbuttonaccessibility10050 → 14.25.0.pre.alpha.PLAY2467contactkitinternational10238
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.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_contact/_contact.tsx +5 -0
- data/app/pb_kits/playbook/pb_contact/contact.rb +4 -0
- data/app/pb_kits/playbook/pb_contact/contact.test.js +21 -1
- data/app/pb_kits/playbook/pb_contact/docs/_contact_default.html.erb +16 -1
- data/app/pb_kits/playbook/pb_contact/docs/_contact_default.jsx +15 -0
- data/app/pb_kits/playbook/pb_contact/docs/_contact_default.md +5 -0
- data/app/pb_kits/playbook/pb_contact/docs/_contact_with_detail.html.erb +6 -0
- data/app/pb_kits/playbook/pb_contact/docs/_contact_with_detail.jsx +6 -0
- data/app/pb_kits/playbook/pb_icon_button/_icon_button.tsx +0 -1
- data/app/pb_kits/playbook/pb_icon_button/icon_button.html.erb +1 -2
- data/dist/chunks/{_weekday_stacked-Y46PHsPW.js → _weekday_stacked-CCRPiVBv.js} +2 -2
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-doc.js +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 070d8c050710240a666b93b0fc10c4c3eee2eb52d6b71a764314eb7dffdb1607
|
4
|
+
data.tar.gz: 75a9695755bfa7f568c68e12f04e2da3fb4691d6fbf2d19bc1e76fbdab1a8b18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8099640bc4cdd08a3d14375cec05c19642900b07cab98d5c942667c4c0c16641914d2ecd50aa52133456e89c0e6bb11e851d6201fa453e4215f962a12f35bdd5
|
7
|
+
data.tar.gz: 0c01a89ccc4326a2ad87e2b2f14205cb4a5f0c213da84714b16d80e21172c3144d8e2aacc8eec1ff4911f183ed3038daf7d8f46341d8655b28cb7912a935ee21
|
@@ -17,6 +17,7 @@ const contactTypeMap: { [key: string]: string } = {
|
|
17
17
|
'work': 'phone-office',
|
18
18
|
'work-cell': 'phone-laptop',
|
19
19
|
'wrong-phone': 'phone-slash',
|
20
|
+
'international': 'globe',
|
20
21
|
}
|
21
22
|
|
22
23
|
const envelopeIcon = getAllIcons()["envelope"].icon as unknown as { [key: string]: SVGElement }
|
@@ -24,6 +25,10 @@ const envelopeIcon = getAllIcons()["envelope"].icon as unknown as { [key: string
|
|
24
25
|
const formatContact = (contactString: string, contactType: string) => {
|
25
26
|
if (contactType === 'email') return contactString
|
26
27
|
|
28
|
+
// International phone numbers are unformatted
|
29
|
+
if (contactType === 'international') return contactString
|
30
|
+
|
31
|
+
// Format US numbers
|
27
32
|
const cleaned = contactString.replace(/\D/g, '')
|
28
33
|
const phoneNumber = cleaned.match(/^(1|)?(\d{3})(\d{3})(\d{4})$/)
|
29
34
|
|
@@ -29,6 +29,8 @@ module Playbook
|
|
29
29
|
"phone-slash"
|
30
30
|
when "extension"
|
31
31
|
"phone-plus"
|
32
|
+
when "international"
|
33
|
+
"globe"
|
32
34
|
else # "unknown" || "other"
|
33
35
|
"phone"
|
34
36
|
end
|
@@ -39,6 +41,8 @@ module Playbook
|
|
39
41
|
contact_value
|
40
42
|
elsif contact_type == "extension" && contact_value.match(/^\d{4}$/)
|
41
43
|
contact_value
|
44
|
+
elsif contact_type == "international"
|
45
|
+
contact_value
|
42
46
|
else
|
43
47
|
number_to_phone(formatted_value, area_code: true)
|
44
48
|
end
|
@@ -66,6 +66,12 @@ test('returns correct icon', () => {
|
|
66
66
|
contactValue="1234"
|
67
67
|
data={{ testid: 'test-extension' }}
|
68
68
|
/>
|
69
|
+
<Contact
|
70
|
+
contactDetail="International"
|
71
|
+
contactType="international"
|
72
|
+
contactValue="+44 20 7946 0958"
|
73
|
+
data={{ testid: 'test-international' }}
|
74
|
+
/>
|
69
75
|
<Contact
|
70
76
|
contactDetail=""
|
71
77
|
contactType=""
|
@@ -83,10 +89,11 @@ test('returns correct icon', () => {
|
|
83
89
|
expect(screen.getByTestId('test-wrong-phone').querySelector('.pb_custom_icon')).toBeInTheDocument()
|
84
90
|
expect(screen.getByTestId('test-wrong-type').querySelector('.pb_custom_icon')).toBeInTheDocument()
|
85
91
|
expect(screen.getByTestId('test-extension').querySelector('.pb_custom_icon')).toBeInTheDocument()
|
92
|
+
expect(screen.getByTestId('test-international').querySelector('.pb_custom_icon')).toBeInTheDocument()
|
86
93
|
expect(screen.getByTestId('test-empty').querySelector('.pb_custom_icon')).toBeInTheDocument()
|
87
94
|
})
|
88
95
|
|
89
|
-
test("not compliant values return null in phone related contact types", () => {
|
96
|
+
test("not compliant values return null in US phone related contact types", () => {
|
90
97
|
const notCompliantValues = [
|
91
98
|
"349-185-998223",
|
92
99
|
"349-1858",
|
@@ -129,3 +136,16 @@ test("not compliant values return null in phone related contact types", () => {
|
|
129
136
|
)
|
130
137
|
})
|
131
138
|
})
|
139
|
+
|
140
|
+
test('international contact type preserves original format', () => {
|
141
|
+
render(
|
142
|
+
<Contact
|
143
|
+
contactType="international"
|
144
|
+
contactValue="+44 20 7946 0958"
|
145
|
+
data={{ testid: 'test-international-format' }}
|
146
|
+
/>
|
147
|
+
)
|
148
|
+
|
149
|
+
const kit = screen.getByTestId('test-international-format')
|
150
|
+
expect(kit).toHaveTextContent('+44 20 7946 0958')
|
151
|
+
})
|
@@ -13,7 +13,7 @@
|
|
13
13
|
}) %>
|
14
14
|
|
15
15
|
<%= pb_rails("contact", props: {
|
16
|
-
contact_type: "
|
16
|
+
contact_type: "work",
|
17
17
|
contact_value: "3245627482",
|
18
18
|
}) %>
|
19
19
|
|
@@ -21,3 +21,18 @@
|
|
21
21
|
contact_type: "work-cell",
|
22
22
|
contact_value: "349-185-9988",
|
23
23
|
}) %>
|
24
|
+
|
25
|
+
<%= pb_rails("contact", props: {
|
26
|
+
contact_type: "wrong-phone",
|
27
|
+
contact_value: "2124396666",
|
28
|
+
}) %>
|
29
|
+
|
30
|
+
<%= pb_rails("contact", props: {
|
31
|
+
contact_type: "extension",
|
32
|
+
contact_value: "1233",
|
33
|
+
}) %>
|
34
|
+
|
35
|
+
<%= pb_rails("contact", props: {
|
36
|
+
contact_type: "international",
|
37
|
+
contact_value: "+44 7700 900461",
|
38
|
+
}) %>
|
@@ -28,6 +28,21 @@ const ContactDefault = (props) => {
|
|
28
28
|
contactValue="3245627482"
|
29
29
|
{...props}
|
30
30
|
/>
|
31
|
+
<Contact
|
32
|
+
contactType="wrong-phone"
|
33
|
+
contactValue="2124396666"
|
34
|
+
{...props}
|
35
|
+
/>
|
36
|
+
<Contact
|
37
|
+
contactType='extension'
|
38
|
+
contactValue="1234"
|
39
|
+
{...props}
|
40
|
+
/>
|
41
|
+
<Contact
|
42
|
+
contactType="international"
|
43
|
+
contactValue="+44 7700 900461"
|
44
|
+
{...props}
|
45
|
+
/>
|
31
46
|
</div>
|
32
47
|
)
|
33
48
|
}
|
@@ -0,0 +1,5 @@
|
|
1
|
+
The Contact kit automatically formats US phone numbers when the `contactType` / `contact_type` is one of: `home` (default), `work`, `cell`, `work-cell`, `wrong-phone`.
|
2
|
+
|
3
|
+
- Use `email` to display emails.
|
4
|
+
- Use `international` to display International phone numbers exactly as provided (no formatting applied).
|
5
|
+
- Use `extension` to display four digit phone extensions.
|