playbook_ui 14.9.0.pre.alpha.PLAY1731inputmasking4868 → 14.9.0.pre.alpha.PLAY16264818
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_advanced_table/table_header.html.erb +3 -5
- data/app/pb_kits/playbook/pb_avatar/_avatar.scss +2 -0
- data/app/pb_kits/playbook/pb_body/_body.scss +13 -14
- data/app/pb_kits/playbook/pb_body/_body_mixins.scss +16 -22
- data/app/pb_kits/playbook/pb_bread_crumbs/docs/_bread_crumbs_default.jsx +0 -6
- data/app/pb_kits/playbook/pb_caption/_caption_mixin.scss +1 -2
- data/app/pb_kits/playbook/pb_card/_card_mixin.scss +1 -1
- data/app/pb_kits/playbook/pb_file_upload/_file_upload.scss +0 -5
- data/app/pb_kits/playbook/pb_file_upload/_file_upload.tsx +2 -7
- data/app/pb_kits/playbook/pb_file_upload/file_upload.html.erb +2 -8
- data/app/pb_kits/playbook/pb_nav/_bold_mixin.scss +1 -11
- data/app/pb_kits/playbook/pb_nav/_collapsible_nav.scss +2 -16
- data/app/pb_kits/playbook/pb_nav/_vertical_nav.scss +1 -1
- data/app/pb_kits/playbook/pb_select/_select.tsx +19 -14
- data/app/pb_kits/playbook/pb_select/docs/_select_form.jsx +108 -0
- data/app/pb_kits/playbook/pb_select/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_select/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_selectable_card/_selectable_card.scss +4 -4
- data/app/pb_kits/playbook/pb_selectable_card/selectable_card.html.erb +1 -1
- data/app/pb_kits/playbook/pb_stat_change/_stat_change.tsx +36 -44
- data/app/pb_kits/playbook/pb_stat_change/stat_change.html.erb +4 -4
- data/app/pb_kits/playbook/pb_text_input/_text_input.tsx +3 -35
- data/app/pb_kits/playbook/pb_text_input/docs/example.yml +0 -1
- data/app/pb_kits/playbook/pb_text_input/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_text_input/text_input.test.js +2 -139
- data/app/pb_kits/playbook/pb_title/_title.scss +5 -6
- data/app/pb_kits/playbook/pb_title/_title_mixin.scss +0 -13
- data/app/pb_kits/playbook/tokens/_titles.scss +8 -0
- data/app/pb_kits/playbook/utilities/_hover.scss +2 -11
- data/app/pb_kits/playbook/utilities/globalProps.ts +0 -2
- data/app/pb_kits/playbook/utilities/hookFormProps.ts +16 -0
- data/app/pb_kits/playbook/utilities/test/globalProps/hover.test.js +0 -15
- data/dist/chunks/_typeahead-B8fkIeXA.js +22 -0
- data/dist/chunks/_weekday_stacked-DxlPBh55.js +45 -0
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-doc.js +1 -1
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/hover.rb +1 -7
- data/lib/playbook/version.rb +1 -1
- metadata +6 -6
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_mask.jsx +0 -88
- data/app/pb_kits/playbook/pb_text_input/inputMask.ts +0 -64
- data/dist/chunks/_typeahead-Cx7J1O_I.js +0 -22
- data/dist/chunks/_weekday_stacked-Z6CSak-K.js +0 -45
data/lib/playbook/hover.rb
CHANGED
@@ -29,16 +29,12 @@ module Playbook
|
|
29
29
|
[]
|
30
30
|
end
|
31
31
|
|
32
|
-
def hover_underline_values
|
33
|
-
[true, false]
|
34
|
-
end
|
35
|
-
|
36
32
|
def hover_values
|
37
33
|
hover_options.keys.select { |sk| try(sk) }
|
38
34
|
end
|
39
35
|
|
40
36
|
def hover_attributes
|
41
|
-
%w[background shadow scale color
|
37
|
+
%w[background shadow scale color]
|
42
38
|
end
|
43
39
|
|
44
40
|
def hover_props
|
@@ -55,8 +51,6 @@ module Playbook
|
|
55
51
|
value.each do |key, val|
|
56
52
|
if %i[background color].include?(key)
|
57
53
|
css += "#{prefix}_#{key}-#{val} " if hover_attributes.include?(key.to_s)
|
58
|
-
elsif %i[underline].include?(key) && val == true
|
59
|
-
css += "hover_underline "
|
60
54
|
elsif hover_attributes.include?(key.to_s) && send("hover_#{key}_values").include?(val.to_s)
|
61
55
|
css += "#{prefix}_#{key}_#{val} "
|
62
56
|
end
|
data/lib/playbook/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: playbook_ui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 14.9.0.pre.alpha.
|
4
|
+
version: 14.9.0.pre.alpha.PLAY16264818
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Power UX
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-12-
|
12
|
+
date: 2024-12-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionpack
|
@@ -2370,6 +2370,7 @@ files:
|
|
2370
2370
|
- app/pb_kits/playbook/pb_select/docs/_select_error.jsx
|
2371
2371
|
- app/pb_kits/playbook/pb_select/docs/_select_error.md
|
2372
2372
|
- app/pb_kits/playbook/pb_select/docs/_select_error_swift.md
|
2373
|
+
- app/pb_kits/playbook/pb_select/docs/_select_form.jsx
|
2373
2374
|
- app/pb_kits/playbook/pb_select/docs/_select_inline.html.erb
|
2374
2375
|
- app/pb_kits/playbook/pb_select/docs/_select_inline.jsx
|
2375
2376
|
- app/pb_kits/playbook/pb_select/docs/_select_inline_compact.html.erb
|
@@ -2707,14 +2708,12 @@ files:
|
|
2707
2708
|
- app/pb_kits/playbook/pb_text_input/docs/_text_input_error_swift.md
|
2708
2709
|
- app/pb_kits/playbook/pb_text_input/docs/_text_input_inline.html.erb
|
2709
2710
|
- app/pb_kits/playbook/pb_text_input/docs/_text_input_inline.jsx
|
2710
|
-
- app/pb_kits/playbook/pb_text_input/docs/_text_input_mask.jsx
|
2711
2711
|
- app/pb_kits/playbook/pb_text_input/docs/_text_input_no_label.html.erb
|
2712
2712
|
- app/pb_kits/playbook/pb_text_input/docs/_text_input_no_label.jsx
|
2713
2713
|
- app/pb_kits/playbook/pb_text_input/docs/_text_input_options.html.erb
|
2714
2714
|
- app/pb_kits/playbook/pb_text_input/docs/_text_input_props_swift.md
|
2715
2715
|
- app/pb_kits/playbook/pb_text_input/docs/example.yml
|
2716
2716
|
- app/pb_kits/playbook/pb_text_input/docs/index.js
|
2717
|
-
- app/pb_kits/playbook/pb_text_input/inputMask.ts
|
2718
2717
|
- app/pb_kits/playbook/pb_text_input/text_input.html.erb
|
2719
2718
|
- app/pb_kits/playbook/pb_text_input/text_input.rb
|
2720
2719
|
- app/pb_kits/playbook/pb_text_input/text_input.test.js
|
@@ -3166,6 +3165,7 @@ files:
|
|
3166
3165
|
- app/pb_kits/playbook/utilities/flexbox_global_props/_order.scss
|
3167
3166
|
- app/pb_kits/playbook/utilities/globalPropNames.mjs
|
3168
3167
|
- app/pb_kits/playbook/utilities/globalProps.ts
|
3168
|
+
- app/pb_kits/playbook/utilities/hookFormProps.ts
|
3169
3169
|
- app/pb_kits/playbook/utilities/icons/allicons.tsx
|
3170
3170
|
- app/pb_kits/playbook/utilities/icons/angle-down.svg
|
3171
3171
|
- app/pb_kits/playbook/utilities/icons/clock.svg
|
@@ -3191,8 +3191,8 @@ files:
|
|
3191
3191
|
- app/pb_kits/playbook/utilities/test/globalProps/truncate.test.js
|
3192
3192
|
- app/pb_kits/playbook/utilities/text.ts
|
3193
3193
|
- app/pb_kits/playbook/utilities/validEmojiChecker.ts
|
3194
|
-
- dist/chunks/_typeahead-
|
3195
|
-
- dist/chunks/_weekday_stacked-
|
3194
|
+
- dist/chunks/_typeahead-B8fkIeXA.js
|
3195
|
+
- dist/chunks/_weekday_stacked-DxlPBh55.js
|
3196
3196
|
- dist/chunks/lazysizes-B7xYodB-.js
|
3197
3197
|
- dist/chunks/lib-SyD3buPZ.js
|
3198
3198
|
- dist/chunks/pb_form_validation-Dt8UJgrJ.js
|
@@ -1,88 +0,0 @@
|
|
1
|
-
import React, { useState } from 'react'
|
2
|
-
|
3
|
-
import Caption from '../../pb_caption/_caption'
|
4
|
-
import TextInput from '../../pb_text_input/_text_input'
|
5
|
-
import Title from '../../pb_title/_title'
|
6
|
-
|
7
|
-
const TextInputMask = (props) => {
|
8
|
-
const [ssn, setSSN] = useState('')
|
9
|
-
const handleOnChangeSSN = ({ target }) => {
|
10
|
-
setSSN(target.value)
|
11
|
-
}
|
12
|
-
const ref = React.createRef()
|
13
|
-
|
14
|
-
const [formFields, setFormFields] = useState({
|
15
|
-
currency: '',
|
16
|
-
zipCode: '',
|
17
|
-
postalCode: '',
|
18
|
-
ssn: '',
|
19
|
-
})
|
20
|
-
|
21
|
-
const handleOnChangeFormField = ({ target }) => {
|
22
|
-
const { name, value } = target
|
23
|
-
setFormFields({ ...formFields, [name]: value })
|
24
|
-
}
|
25
|
-
|
26
|
-
return (
|
27
|
-
<div>
|
28
|
-
<TextInput
|
29
|
-
label="Currency"
|
30
|
-
mask="currency"
|
31
|
-
name="currency"
|
32
|
-
onChange={handleOnChangeFormField}
|
33
|
-
value={formFields.currency}
|
34
|
-
{...props}
|
35
|
-
/>
|
36
|
-
<TextInput
|
37
|
-
label="Zip Code"
|
38
|
-
mask="zipCode"
|
39
|
-
name="zipCode"
|
40
|
-
onChange={handleOnChangeFormField}
|
41
|
-
value={formFields.zipCode}
|
42
|
-
{...props}
|
43
|
-
/>
|
44
|
-
<TextInput
|
45
|
-
label="Postal Code"
|
46
|
-
mask="postalCode"
|
47
|
-
name="postalCode"
|
48
|
-
onChange={handleOnChangeFormField}
|
49
|
-
value={formFields.postalCode}
|
50
|
-
{...props}
|
51
|
-
/>
|
52
|
-
<TextInput
|
53
|
-
label="SSN"
|
54
|
-
mask="ssn"
|
55
|
-
name="ssn"
|
56
|
-
onChange={handleOnChangeFormField}
|
57
|
-
value={formFields.ssn}
|
58
|
-
{...props}
|
59
|
-
/>
|
60
|
-
|
61
|
-
<br />
|
62
|
-
<br />
|
63
|
-
|
64
|
-
<Title>{'Event Handler Props'}</Title>
|
65
|
-
|
66
|
-
<br />
|
67
|
-
<Caption>{'onChange'}</Caption>
|
68
|
-
|
69
|
-
<br />
|
70
|
-
|
71
|
-
<TextInput
|
72
|
-
label="SSN"
|
73
|
-
mask="ssn"
|
74
|
-
onChange={handleOnChangeSSN}
|
75
|
-
placeholder="Enter SSN"
|
76
|
-
ref={ref}
|
77
|
-
value={ssn}
|
78
|
-
{...props}
|
79
|
-
/>
|
80
|
-
|
81
|
-
{ssn !== '' && (
|
82
|
-
<React.Fragment>{`SSN is: ${ssn}`}</React.Fragment>
|
83
|
-
)}
|
84
|
-
</div>
|
85
|
-
)
|
86
|
-
}
|
87
|
-
|
88
|
-
export default TextInputMask
|
@@ -1,64 +0,0 @@
|
|
1
|
-
type InputMask = {
|
2
|
-
format: (value: string) => string
|
3
|
-
pattern: string
|
4
|
-
placeholder: string
|
5
|
-
}
|
6
|
-
|
7
|
-
type InputMaskDictionary = {
|
8
|
-
[key in 'currency' | 'zipCode' | 'postalCode' | 'ssn']: InputMask
|
9
|
-
}
|
10
|
-
|
11
|
-
const formatCurrency = (value: string): string => {
|
12
|
-
const numericValue = value.replace(/[^0-9]/g, '').slice(0, 15)
|
13
|
-
|
14
|
-
if (!numericValue) return ''
|
15
|
-
|
16
|
-
const dollars = parseFloat((parseInt(numericValue) / 100).toFixed(2))
|
17
|
-
if (dollars === 0) return ''
|
18
|
-
|
19
|
-
return new Intl.NumberFormat('en-US', {
|
20
|
-
style: 'currency',
|
21
|
-
currency: 'USD',
|
22
|
-
maximumFractionDigits: 2,
|
23
|
-
}).format(dollars)
|
24
|
-
}
|
25
|
-
|
26
|
-
const formatBasicPostal = (value: string): string => {
|
27
|
-
return value.replace(/\D/g, '').slice(0, 5)
|
28
|
-
}
|
29
|
-
|
30
|
-
const formatExtendedPostal = (value: string): string => {
|
31
|
-
const cleaned = value.replace(/\D/g, '').slice(0, 9)
|
32
|
-
return cleaned.replace(/(\d{5})(?=\d)/, '$1-')
|
33
|
-
}
|
34
|
-
|
35
|
-
const formatSSN = (value: string): string => {
|
36
|
-
const cleaned = value.replace(/\D/g, '').slice(0, 9)
|
37
|
-
return cleaned
|
38
|
-
.replace(/(\d{5})(?=\d)/, '$1-')
|
39
|
-
.replace(/(\d{3})(?=\d)/, '$1-')
|
40
|
-
}
|
41
|
-
|
42
|
-
export const INPUTMASKS: InputMaskDictionary = {
|
43
|
-
currency: {
|
44
|
-
format: formatCurrency,
|
45
|
-
// eslint-disable-next-line no-useless-escape
|
46
|
-
pattern: '^\$\d{1,3}(?:,\d{3})*(?:\.\d{2})?$',
|
47
|
-
placeholder: '$0.00',
|
48
|
-
},
|
49
|
-
zipCode: {
|
50
|
-
format: formatBasicPostal,
|
51
|
-
pattern: '\\d{5}',
|
52
|
-
placeholder: '12345',
|
53
|
-
},
|
54
|
-
postalCode: {
|
55
|
-
format: formatExtendedPostal,
|
56
|
-
pattern: '\\d{5}-\\d{4}',
|
57
|
-
placeholder: '12345-6789',
|
58
|
-
},
|
59
|
-
ssn: {
|
60
|
-
format: formatSSN,
|
61
|
-
pattern: '\\d{3}-\\d{2}-\\d{4}',
|
62
|
-
placeholder: '123-45-6789',
|
63
|
-
},
|
64
|
-
}
|