playbook_ui 14.11.0.pre.rc.12 → 14.11.0.pre.rc.13

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 (39) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.scss +11 -9
  3. data/app/pb_kits/playbook/pb_badge/_badge.scss +4 -2
  4. data/app/pb_kits/playbook/pb_bread_crumbs/_bread_crumbs.scss +3 -1
  5. data/app/pb_kits/playbook/pb_button/_button.scss +3 -1
  6. data/app/pb_kits/playbook/pb_circle_icon_button/_circle_icon_button.scss +4 -2
  7. data/app/pb_kits/playbook/pb_date_picker/sass_partials/_input_styles.scss +3 -1
  8. data/app/pb_kits/playbook/pb_date_picker/sass_partials/_overrides.scss +5 -3
  9. data/app/pb_kits/playbook/pb_date_range_inline/_date_range_inline.scss +6 -4
  10. data/app/pb_kits/playbook/pb_date_time_stacked/_date_time_stacked.scss +4 -2
  11. data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +10 -8
  12. data/app/pb_kits/playbook/pb_form_pill/_form_pill.scss +6 -4
  13. data/app/pb_kits/playbook/pb_icon_circle/_icon_circle.scss +3 -1
  14. data/app/pb_kits/playbook/pb_label_value/_label_value.scss +4 -2
  15. data/app/pb_kits/playbook/pb_message/_message_mixins.scss +3 -1
  16. data/app/pb_kits/playbook/pb_multiple_users/_multiple_users.scss +3 -1
  17. data/app/pb_kits/playbook/pb_passphrase/_passphrase.scss +5 -3
  18. data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.scss +10 -8
  19. data/app/pb_kits/playbook/pb_pill/_pill.scss +4 -2
  20. data/app/pb_kits/playbook/pb_progress_simple/_progress_simple.scss +4 -2
  21. data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.scss +4 -2
  22. data/app/pb_kits/playbook/pb_select/_select.scss +5 -3
  23. data/app/pb_kits/playbook/pb_selectable_card/_selectable_card.scss +5 -3
  24. data/app/pb_kits/playbook/pb_text_input/_text_input.scss +3 -1
  25. data/app/pb_kits/playbook/pb_text_input/docs/_text_input_mask.jsx +18 -0
  26. data/app/pb_kits/playbook/pb_text_input/inputMask.ts +22 -1
  27. data/app/pb_kits/playbook/pb_text_input/text_input.test.js +80 -0
  28. data/app/pb_kits/playbook/pb_textarea/_textarea.scss +3 -1
  29. data/app/pb_kits/playbook/pb_time_range_inline/_time_range_inline.scss +5 -4
  30. data/app/pb_kits/playbook/pb_timeline/_timeline.scss +4 -2
  31. data/app/pb_kits/playbook/pb_toggle/_toggle.scss +5 -3
  32. data/dist/chunks/{_typeahead-DhQHv7TA.js → _typeahead-DPsPSYxe.js} +1 -1
  33. data/dist/chunks/{_weekday_stacked-BImEPKQq.js → _weekday_stacked-KhE_lsdt.js} +1 -1
  34. data/dist/chunks/vendor.js +1 -1
  35. data/dist/playbook-doc.js +1 -1
  36. data/dist/playbook-rails-react-bindings.js +1 -1
  37. data/dist/playbook-rails.js +1 -1
  38. data/lib/playbook/version.rb +1 -1
  39. metadata +3 -3
@@ -6,7 +6,7 @@ type InputMask = {
6
6
  }
7
7
 
8
8
  type InputMaskDictionary = {
9
- [key in 'currency' | 'zipCode' | 'postalCode' | 'ssn']: InputMask
9
+ [key in 'currency' | 'zipCode' | 'postalCode' | 'ssn' | 'creditCard' | 'cvv']: InputMask
10
10
  }
11
11
 
12
12
  const formatCurrencyDefaultValue = (value: string): string => {
@@ -58,6 +58,15 @@ const formatSSN = (value: string): string => {
58
58
  .replace(/(\d{3})(?=\d)/, '$1-')
59
59
  }
60
60
 
61
+ const formatCreditCard = (value: string): string => {
62
+ const cleaned = value.replace(/\D/g, '').slice(0, 16)
63
+ return cleaned.replace(/(\d{4})(?=\d)/g, '$1 ')
64
+ }
65
+
66
+ const formatCVV = (value: string): string => {
67
+ return value.replace(/\D/g, '').slice(0, 4)
68
+ }
69
+
61
70
  export const INPUTMASKS: InputMaskDictionary = {
62
71
  currency: {
63
72
  format: formatCurrency,
@@ -84,4 +93,16 @@ export const INPUTMASKS: InputMaskDictionary = {
84
93
  pattern: '\\d{3}-\\d{2}-\\d{4}',
85
94
  placeholder: '123-45-6789',
86
95
  },
96
+ creditCard: {
97
+ format: formatCreditCard,
98
+ formatDefaultValue: formatCreditCard,
99
+ pattern: '\\d{4} \\d{4} \\d{4} \\d{4}',
100
+ placeholder: '1234 5678 9012 3456',
101
+ },
102
+ cvv: {
103
+ format: formatCVV,
104
+ formatDefaultValue: formatCVV,
105
+ pattern: '\\d{3,4}',
106
+ placeholder: '123',
107
+ },
87
108
  }
@@ -226,3 +226,83 @@ test('returns masked ssn value', () => {
226
226
 
227
227
  expect(input.value).toBe('123-45-6789')
228
228
  })
229
+
230
+ const TextInputCreditCardMask = (props) => {
231
+ const [creditCard, setValue] = useState('')
232
+ const handleOnChange = ({ target }) => {
233
+ setValue(target.value)
234
+ }
235
+
236
+ return (
237
+ <TextInput
238
+ mask="creditCard"
239
+ onChange={handleOnChange}
240
+ value={creditCard}
241
+ {...props}
242
+ />
243
+ )
244
+ }
245
+
246
+ test('returns masked credit card value', () => {
247
+ render(
248
+ <TextInputCreditCardMask
249
+ data={{ testid: testId }}
250
+ />
251
+ )
252
+
253
+ const kit = screen.getByTestId(testId)
254
+
255
+ const input = within(kit).getByRole('textbox')
256
+
257
+ fireEvent.change(input, { target: { value: '1234567890123456' } })
258
+
259
+ expect(input.value).toBe('1234 5678 9012 3456')
260
+
261
+ fireEvent.change(input, { target: { value: '1234' } })
262
+
263
+ expect(input.value).toBe('1234')
264
+
265
+ fireEvent.change(input, { target: { value: '' } })
266
+
267
+ expect(input.value).toBe('')
268
+ })
269
+
270
+ const TextInputCVVMask = (props) => {
271
+ const [cvv, setValue] = useState('')
272
+ const handleOnChange = ({ target }) => {
273
+ setValue(target.value)
274
+ }
275
+
276
+ return (
277
+ <TextInput
278
+ mask="cvv"
279
+ onChange={handleOnChange}
280
+ value={cvv}
281
+ {...props}
282
+ />
283
+ )
284
+ }
285
+
286
+ test('returns masked CVV value', () => {
287
+ render(
288
+ <TextInputCVVMask
289
+ data={{ testid: testId }}
290
+ />
291
+ )
292
+
293
+ const kit = screen.getByTestId(testId)
294
+
295
+ const input = within(kit).getByRole('textbox')
296
+
297
+ fireEvent.change(input, { target: { value: '1234' } })
298
+
299
+ expect(input.value).toBe('1234')
300
+
301
+ fireEvent.change(input, { target: { value: '123' } })
302
+
303
+ expect(input.value).toBe('123')
304
+
305
+ fireEvent.change(input, { target: { value: '' } })
306
+
307
+ expect(input.value).toBe('')
308
+ })
@@ -1,3 +1,5 @@
1
+ @use "sass:math";
2
+
1
3
  @import "../pb_body/body_mixins";
2
4
  @import "./textarea_mixin";
3
5
  @import "../tokens/spacing";
@@ -60,7 +62,7 @@
60
62
 
61
63
  &.error {
62
64
  [class*=pb_body_kit] {
63
- margin-top: $space_xs / 2;
65
+ margin-top: math.div($space_xs, 2);
64
66
  }
65
67
  textarea {
66
68
  border-color: $error;
@@ -1,3 +1,4 @@
1
+ @use "sass:math";
1
2
 
2
3
  [class^=pb_time_range_inline_kit] {
3
4
  &[class*=_center] {
@@ -22,14 +23,14 @@
22
23
  display: flex;
23
24
  align-items: center;
24
25
  [class*=pb_time_range_inline_arrow] {
25
- margin-left: $space_xs/2;
26
- margin-right: $space_xs/2;
26
+ margin-left: math.div($space_xs, 2);
27
+ margin-right:math.div($space_xs, 2);
27
28
  }
28
29
  [class*=pb_time_range_inline_timezone] {
29
- margin-left: $space_xs/2;
30
+ margin-left: math.div($space_xs, 2);
30
31
  }
31
32
  [class*=pb_time_range_inline_icon] {
32
- margin-right: $space_xs/2;
33
+ margin-right: math.div($space_xs, 2);
33
34
  }
34
35
  }
35
36
  }
@@ -1,12 +1,14 @@
1
+ @use "sass:math";
2
+
1
3
  @import "../tokens/colors";
2
4
  @import "../tokens/spacing";
3
5
  @import "../tokens/opacity";
4
6
  @import "../tokens/typography";
5
7
 
6
8
  $connector_width: 2px;
7
- $icon_margin: $space_xs/2;
9
+ $icon_margin: math.div($space_xs, 2);
8
10
  $icon_height: 28px;
9
- $height_from_top: $icon_height/2 - $connector_width/2;
11
+ $height_from_top: (math.div($icon_height, 2)) - (math.div($connector_width, 2));
10
12
 
11
13
  // Add gap variables
12
14
  $gap_xs: $height_from_top + $space_xs;
@@ -1,3 +1,5 @@
1
+ @use "sass:math";
2
+
1
3
  @import "../tokens/colors";
2
4
 
3
5
  $color_checkbox_success: $data_1;
@@ -8,7 +10,7 @@ $transition: .2s ease-in-out;
8
10
  [class^=pb_toggle_kit] {
9
11
  position: relative;
10
12
  $width: 44px;
11
- $height: $width / 2;
13
+ $height: math.div($width, 2);
12
14
  $border_success: 3px solid $color_checkbox_success;
13
15
  $border_default: 3px solid $color_checkbox_default;
14
16
 
@@ -27,7 +29,7 @@ $transition: .2s ease-in-out;
27
29
  &:after {
28
30
  transition: $transition;
29
31
  content: "";
30
- width: $width / 2 - 4px;
32
+ width: math.div($width, 2) - 4px;
31
33
  height: $height - 4px;
32
34
  background-color: $color_checkbox_default;
33
35
  border-radius: 50%;
@@ -68,7 +70,7 @@ $transition: .2s ease-in-out;
68
70
  background-color: $color_checkbox_success;
69
71
 
70
72
  &:after {
71
- left: $width / 2 + 2px;
73
+ left: math.div($width, 2) + 2px;
72
74
  background-color: $white;
73
75
  }
74
76
  }