playbook_ui 14.10.0.pre.alpha.PBNTR662stickyrightcolumnreact5160 → 14.10.0.pre.alpha.PBNTR775formmatingmaskdefaultvalue5137

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 (42) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +19 -32
  3. data/app/pb_kits/playbook/pb_advanced_table/SubKits/TableBody.tsx +1 -3
  4. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +0 -37
  5. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +18 -32
  6. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +0 -2
  7. data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +0 -2
  8. data/app/pb_kits/playbook/pb_circle_icon_button/_circle_icon_button.tsx +0 -3
  9. data/app/pb_kits/playbook/pb_circle_icon_button/circle_icon_button.html.erb +1 -1
  10. data/app/pb_kits/playbook/pb_circle_icon_button/circle_icon_button.rb +0 -1
  11. data/app/pb_kits/playbook/pb_circle_icon_button/docs/_circle_icon_button_link.html.erb +0 -8
  12. data/app/pb_kits/playbook/pb_circle_icon_button/docs/_circle_icon_button_link.jsx +0 -9
  13. data/app/pb_kits/playbook/pb_table/_table.tsx +18 -67
  14. data/app/pb_kits/playbook/pb_table/docs/_table_sticky_left_columns.jsx +1 -1
  15. data/app/pb_kits/playbook/pb_table/docs/_table_sticky_left_columns_rails.md +0 -2
  16. data/app/pb_kits/playbook/pb_table/docs/_table_sticky_left_columns_react.md +1 -4
  17. data/app/pb_kits/playbook/pb_table/index.ts +17 -17
  18. data/app/pb_kits/playbook/pb_table/styles/_scroll.scss +2 -18
  19. data/app/pb_kits/playbook/pb_table/styles/_sticky_columns.scss +3 -17
  20. data/app/pb_kits/playbook/pb_text_input/_text_input.tsx +8 -1
  21. data/app/pb_kits/playbook/pb_text_input/inputMask.ts +23 -0
  22. data/dist/chunks/{_typeahead-aym7Ky_O.js → _typeahead-CoIYBETL.js} +3 -3
  23. data/dist/chunks/_weekday_stacked-Qj3GFYzA.js +45 -0
  24. data/dist/chunks/{lib-B7sgJtGS.js → lib-sMFo2JZy.js} +1 -1
  25. data/dist/chunks/{pb_form_validation-C5Cc0-1v.js → pb_form_validation-CgvjWbOK.js} +1 -1
  26. data/dist/chunks/vendor.js +1 -1
  27. data/dist/playbook-doc.js +1 -1
  28. data/dist/playbook-rails-react-bindings.js +1 -1
  29. data/dist/playbook-rails.js +1 -1
  30. data/dist/playbook.css +1 -1
  31. data/lib/playbook/version.rb +1 -1
  32. metadata +6 -15
  33. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_headers.jsx +0 -60
  34. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_headers.md +0 -1
  35. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_headers_multiple.jsx +0 -74
  36. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_headers_multiple.md +0 -1
  37. data/app/pb_kits/playbook/pb_circle_icon_button/docs/_circle_icon_button_link.md +0 -1
  38. data/app/pb_kits/playbook/pb_table/docs/_table_sticky_columns.jsx +0 -88
  39. data/app/pb_kits/playbook/pb_table/docs/_table_sticky_columns_react.md +0 -3
  40. data/app/pb_kits/playbook/pb_table/docs/_table_sticky_right_columns.jsx +0 -87
  41. data/app/pb_kits/playbook/pb_table/docs/_table_sticky_right_columns_react.md +0 -5
  42. data/dist/chunks/_weekday_stacked-BZj1pop-.js +0 -45
@@ -123,6 +123,13 @@ const TextInput = (props: TextInputProps, ref: React.LegacyRef<HTMLInputElement>
123
123
 
124
124
  const childInput = children ? children.type === "input" : undefined
125
125
 
126
+ let formattedValue;
127
+ if (isMaskedInput && value) {
128
+ formattedValue = INPUTMASKS[mask].formatDefaultValue(value.toString())
129
+ } else {
130
+ formattedValue = value
131
+ }
132
+
126
133
  const textInput = (
127
134
  childInput ? React.cloneElement(children, { className: "text_input" }) :
128
135
  (<input
@@ -138,7 +145,7 @@ const TextInput = (props: TextInputProps, ref: React.LegacyRef<HTMLInputElement>
138
145
  ref={ref}
139
146
  required={required}
140
147
  type={type}
141
- value={value}
148
+ value={formattedValue}
142
149
  />)
143
150
  )
144
151
 
@@ -1,5 +1,6 @@
1
1
  type InputMask = {
2
2
  format: (value: string) => string
3
+ formatDefaultValue: (value: string) => string
3
4
  pattern: string
4
5
  placeholder: string
5
6
  }
@@ -8,6 +9,24 @@ type InputMaskDictionary = {
8
9
  [key in 'currency' | 'zipCode' | 'postalCode' | 'ssn']: InputMask
9
10
  }
10
11
 
12
+ const formatCurrencyDefaultValue = (value: string): string => {
13
+ // Remove non-numeric characters except for the decimal point
14
+ const numericValue = value.replace(/[^0-9.]/g, '')
15
+
16
+ if (!numericValue) return ''
17
+
18
+ // Parse the numeric value as a float to handle decimals
19
+ const dollars = parseFloat(numericValue)
20
+ if (isNaN(dollars) || dollars === 0) return ''
21
+
22
+ // Format as currency
23
+ return new Intl.NumberFormat('en-US', {
24
+ style: 'currency',
25
+ currency: 'USD',
26
+ maximumFractionDigits: 2,
27
+ }).format(dollars)
28
+ }
29
+
11
30
  const formatCurrency = (value: string): string => {
12
31
  const numericValue = value.replace(/[^0-9]/g, '').slice(0, 15)
13
32
 
@@ -42,22 +61,26 @@ const formatSSN = (value: string): string => {
42
61
  export const INPUTMASKS: InputMaskDictionary = {
43
62
  currency: {
44
63
  format: formatCurrency,
64
+ formatDefaultValue: formatCurrencyDefaultValue,
45
65
  // eslint-disable-next-line no-useless-escape
46
66
  pattern: '^\\$\\d{1,3}(?:,\\d{3})*(?:\\.\\d{2})?$',
47
67
  placeholder: '$0.00',
48
68
  },
49
69
  zipCode: {
50
70
  format: formatBasicPostal,
71
+ formatDefaultValue: formatBasicPostal,
51
72
  pattern: '\\d{5}',
52
73
  placeholder: '12345',
53
74
  },
54
75
  postalCode: {
55
76
  format: formatExtendedPostal,
77
+ formatDefaultValue: formatExtendedPostal,
56
78
  pattern: '\\d{5}-\\d{4}',
57
79
  placeholder: '12345-6789',
58
80
  },
59
81
  ssn: {
60
82
  format: formatSSN,
83
+ formatDefaultValue: formatSSN,
61
84
  pattern: '\\d{3}-\\d{2}-\\d{4}',
62
85
  placeholder: '123-45-6789',
63
86
  },