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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd227aa3cf1f1d1cbd711c79950fb9ca64c9d87e4dffb1024c57573e21cb44f8
4
- data.tar.gz: 8da9eccfa3f32b5289bb746aa4062d10caa4f97da8d2a8b423a7dacf0b7c2393
3
+ metadata.gz: 070d8c050710240a666b93b0fc10c4c3eee2eb52d6b71a764314eb7dffdb1607
4
+ data.tar.gz: 75a9695755bfa7f568c68e12f04e2da3fb4691d6fbf2d19bc1e76fbdab1a8b18
5
5
  SHA512:
6
- metadata.gz: 7df6f55ba47742e8bf1cc9e9c07a9c8669eb461b979423f6ba8cc9272d589fb8000b47ed9cbbf1fac3f76c30a278615705abcc0115a6ab0d2f03956221d7a9b0
7
- data.tar.gz: dc98d1d465c56dfa04713dcb8b6833032a0a34d73c4370d42e272ade458b55ca510cb9d21cd161fe65b07be5bab249fa1cce104d0e305301eed8de5e9dd11340
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: "wrong number",
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.
@@ -26,3 +26,9 @@
26
26
  contact_value: "1233",
27
27
  contact_detail: "Ext",
28
28
  }) %>
29
+
30
+ <%= pb_rails("contact", props: {
31
+ contact_type: "international",
32
+ contact_value: "+44 7700 900461",
33
+ contact_detail: "International",
34
+ }) %>
@@ -33,6 +33,12 @@ const ContactDefault = (props) => {
33
33
  contactValue="1234"
34
34
  {...props}
35
35
  />
36
+ <Contact
37
+ contactDetail="International"
38
+ contactType="international"
39
+ contactValue="+44 7700 900461"
40
+ {...props}
41
+ />
36
42
  </div>
37
43
  )
38
44
  }
@@ -51,7 +51,6 @@ const IconButton = (props: IconButtonProps) => {
51
51
  id={id}
52
52
  >
53
53
  <Button
54
- aria={aria}
55
54
  borderRadius="xs"
56
55
  htmlType={htmlType}
57
56
  link={link}
@@ -1,6 +1,5 @@
1
1
  <%= pb_content_tag do %>
2
- <%= pb_rails("button", props: { aria: object.aria,
3
- type: object.type,
2
+ <%= pb_rails("button", props: { type: object.type,
4
3
  link: object.link,
5
4
  new_window:object.new_window,
6
5
  target: object.target,