playbook_ui_docs 14.9.0.pre.alpha.PLAY1731inputmasking4927 → 14.9.0.pre.alpha.PLAY16264952
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_checkbox/docs/_checkbox_form.jsx +138 -0
- data/app/pb_kits/playbook/pb_checkbox/docs/example.yml +7 -6
- data/app/pb_kits/playbook/pb_checkbox/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_select/docs/_select_form.jsx +109 -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_text_input/docs/example.yml +0 -1
- data/app/pb_kits/playbook/pb_text_input/docs/index.js +0 -1
- data/dist/playbook-doc.js +1 -1
- metadata +4 -3
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_mask.jsx +0 -88
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b467fbcae42be9e319abfbe8598c7faac4e81b90c8b0e9e917f2e10cc80e88a3
|
4
|
+
data.tar.gz: 509c4072db236dfab4715bcab6a0b781b01bd72521366a0f57389fa847d9df32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0b6b3151f01ea063e24f2bad4c8358fcdb9e9f7b2339bed8dc8767c15bfdccbe37c8fd5607e2dc64aa7fadfa8d5438e598efb0b582e2b84525521a13c04edc8
|
7
|
+
data.tar.gz: a1798e5a109c940e7133ac624b9a22bf3a93267d4fead3b7647ab9849c3b97327d510c4f1664b1b31683e288ada514679bb506c1dfff047854d0bb8ee360094a
|
@@ -0,0 +1,138 @@
|
|
1
|
+
import React from "react"
|
2
|
+
import { useForm } from "react-hook-form"
|
3
|
+
import { Checkbox, Card, Body, Button } from "playbook-ui"
|
4
|
+
|
5
|
+
const CheckboxForm = () => {
|
6
|
+
const {
|
7
|
+
register,
|
8
|
+
handleSubmit,
|
9
|
+
formState: { errors },
|
10
|
+
watch,
|
11
|
+
} = useForm({
|
12
|
+
defaultValues: {
|
13
|
+
termsAccepted: false,
|
14
|
+
newsletter: false,
|
15
|
+
interests: [],
|
16
|
+
preferences: {
|
17
|
+
emailUpdates: false,
|
18
|
+
smsUpdates: false,
|
19
|
+
pushNotifications: false,
|
20
|
+
},
|
21
|
+
},
|
22
|
+
})
|
23
|
+
|
24
|
+
const onSubmit = (data) => {
|
25
|
+
console.log("Form submitted:", data)
|
26
|
+
}
|
27
|
+
|
28
|
+
const formValues = watch()
|
29
|
+
|
30
|
+
return (
|
31
|
+
<div>
|
32
|
+
<Card padding='md'>
|
33
|
+
<form onSubmit={handleSubmit(onSubmit)}>
|
34
|
+
<div>
|
35
|
+
<Body marginBottom='xs'
|
36
|
+
text='Terms and Conditions'
|
37
|
+
/>
|
38
|
+
<Checkbox
|
39
|
+
error={errors.termsAccepted?.message}
|
40
|
+
name='termsAccepted'
|
41
|
+
register={register}
|
42
|
+
rules={{
|
43
|
+
required: "You must accept the terms and conditions",
|
44
|
+
}}
|
45
|
+
text='I accept the terms and conditions'
|
46
|
+
/>
|
47
|
+
</div>
|
48
|
+
<div className='mt-4'>
|
49
|
+
<Body marginBottom='xs'
|
50
|
+
text='Newsletter Subscription'
|
51
|
+
/>
|
52
|
+
<Checkbox
|
53
|
+
name='newsletter'
|
54
|
+
register={register}
|
55
|
+
text='Subscribe to our newsletter'
|
56
|
+
/>
|
57
|
+
</div>
|
58
|
+
<div className='mt-4'>
|
59
|
+
<Body marginBottom='xs'
|
60
|
+
text='Your Interests'
|
61
|
+
/>
|
62
|
+
<Checkbox
|
63
|
+
error={errors.interests?.message}
|
64
|
+
name='interests'
|
65
|
+
register={register}
|
66
|
+
rules={{
|
67
|
+
validate: (value) => {
|
68
|
+
const selectedInterests = Object.values(value).filter(Boolean)
|
69
|
+
return (
|
70
|
+
selectedInterests.length >= 1 ||
|
71
|
+
"Please select at least one interest"
|
72
|
+
)
|
73
|
+
},
|
74
|
+
}}
|
75
|
+
text='Technology'
|
76
|
+
value='technology'
|
77
|
+
/>
|
78
|
+
<Checkbox
|
79
|
+
name='interests'
|
80
|
+
register={register}
|
81
|
+
text='Design'
|
82
|
+
value='design'
|
83
|
+
/>
|
84
|
+
<Checkbox
|
85
|
+
name='interests'
|
86
|
+
register={register}
|
87
|
+
text='Business'
|
88
|
+
value='business'
|
89
|
+
/>
|
90
|
+
<Checkbox
|
91
|
+
name='interests'
|
92
|
+
register={register}
|
93
|
+
text='Marketing'
|
94
|
+
value='marketing'
|
95
|
+
/>
|
96
|
+
</div>
|
97
|
+
<div className='mt-4'>
|
98
|
+
<Body marginBottom='xs'
|
99
|
+
text='Communication Preferences'
|
100
|
+
/>
|
101
|
+
<Checkbox
|
102
|
+
name='preferences.emailUpdates'
|
103
|
+
register={register}
|
104
|
+
text='Email Updates'
|
105
|
+
/>
|
106
|
+
<Checkbox
|
107
|
+
name='preferences.smsUpdates'
|
108
|
+
register={register}
|
109
|
+
text='SMS Updates'
|
110
|
+
/>
|
111
|
+
<Checkbox
|
112
|
+
name='preferences.pushNotifications'
|
113
|
+
register={register}
|
114
|
+
text='Push Notifications'
|
115
|
+
/>
|
116
|
+
</div>
|
117
|
+
<Button
|
118
|
+
htmlType="submit"
|
119
|
+
marginTop='lg'
|
120
|
+
text='Submit'
|
121
|
+
type='submit'
|
122
|
+
variant='primary'
|
123
|
+
/>
|
124
|
+
</form>
|
125
|
+
<Card marginTop='lg'>
|
126
|
+
<Body text='Current Form Values:'
|
127
|
+
variant='bold'
|
128
|
+
/>
|
129
|
+
<pre style={{ marginTop: "8px", color: "white" }}>
|
130
|
+
{JSON.stringify(formValues, null, 2)}
|
131
|
+
</pre>
|
132
|
+
</Card>
|
133
|
+
</Card>
|
134
|
+
</div>
|
135
|
+
)
|
136
|
+
}
|
137
|
+
|
138
|
+
export default CheckboxForm
|
@@ -9,12 +9,13 @@ examples:
|
|
9
9
|
- checkbox_disabled: Disabled Checkbox
|
10
10
|
|
11
11
|
react:
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
- checkbox_default: Default
|
13
|
+
- checkbox_checked: Load as checked
|
14
|
+
- checkbox_custom: Custom Checkbox
|
15
|
+
- checkbox_error: Default w/ Error
|
16
|
+
- checkbox_indeterminate: Indeterminate Checkbox
|
17
|
+
- checkbox_disabled: Disabled Checkbox
|
18
|
+
- checkbox_form: Checkbox Form
|
18
19
|
|
19
20
|
swift:
|
20
21
|
- checkbox_default_swift: Default
|
@@ -4,3 +4,4 @@ export { default as CheckboxError } from './_checkbox_error.jsx'
|
|
4
4
|
export { default as CheckboxChecked } from './_checkbox_checked.jsx'
|
5
5
|
export { default as CheckboxIndeterminate } from './_checkbox_indeterminate.jsx'
|
6
6
|
export { default as CheckboxDisabled } from './_checkbox_disabled.jsx'
|
7
|
+
export { default as CheckboxForm } from './_checkbox_form.jsx'
|
@@ -0,0 +1,109 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { useForm } from 'react-hook-form'
|
3
|
+
import { Select, Card, Body, Button } from 'playbook-ui'
|
4
|
+
|
5
|
+
const SelectForm = (props) => {
|
6
|
+
const {
|
7
|
+
register,
|
8
|
+
handleSubmit,
|
9
|
+
formState: { errors },
|
10
|
+
watch,
|
11
|
+
} = useForm({
|
12
|
+
defaultValues: {
|
13
|
+
favoriteFood: '',
|
14
|
+
mealType: '',
|
15
|
+
dietaryRestrictions: '',
|
16
|
+
}
|
17
|
+
})
|
18
|
+
|
19
|
+
const onSubmit = (data) => {
|
20
|
+
console.log('Form submitted:', data)
|
21
|
+
}
|
22
|
+
|
23
|
+
// Watch form values for real-time display
|
24
|
+
const formValues = watch()
|
25
|
+
|
26
|
+
const foodOptions = [
|
27
|
+
{ value: 'pizza', text: 'Pizza' },
|
28
|
+
{ value: 'burger', text: 'Burger' },
|
29
|
+
{ value: 'sushi', text: 'Sushi' },
|
30
|
+
{ value: 'salad', text: 'Salad' },
|
31
|
+
]
|
32
|
+
|
33
|
+
const mealTypes = [
|
34
|
+
{ value: 'breakfast', text: 'Breakfast' },
|
35
|
+
{ value: 'lunch', text: 'Lunch' },
|
36
|
+
{ value: 'dinner', text: 'Dinner' },
|
37
|
+
]
|
38
|
+
|
39
|
+
const dietaryOptions = [
|
40
|
+
{ value: 'none', text: 'No Restrictions' },
|
41
|
+
{ value: 'vegetarian', text: 'Vegetarian' },
|
42
|
+
{ value: 'vegan', text: 'Vegan' },
|
43
|
+
{ value: 'glutenFree', text: 'Gluten Free' },
|
44
|
+
]
|
45
|
+
|
46
|
+
return (
|
47
|
+
<div>
|
48
|
+
<Card>
|
49
|
+
<form onSubmit={handleSubmit(onSubmit)}>
|
50
|
+
<Select
|
51
|
+
error={errors.favoriteFood?.message}
|
52
|
+
label="What's your favorite food?"
|
53
|
+
name="favoriteFood"
|
54
|
+
options={foodOptions}
|
55
|
+
register={register}
|
56
|
+
rules={{
|
57
|
+
required: 'Please select your favorite food',
|
58
|
+
}}
|
59
|
+
{...props}
|
60
|
+
/>
|
61
|
+
<Select
|
62
|
+
blankSelection="Choose a meal type..."
|
63
|
+
error={errors.mealType?.message}
|
64
|
+
label="Preferred meal time"
|
65
|
+
marginTop="md"
|
66
|
+
name="mealType"
|
67
|
+
options={mealTypes}
|
68
|
+
register={register}
|
69
|
+
rules={{
|
70
|
+
required: 'Please select a meal type',
|
71
|
+
}}
|
72
|
+
{...props}
|
73
|
+
/>
|
74
|
+
<Select
|
75
|
+
label="Dietary Restrictions"
|
76
|
+
marginTop="md"
|
77
|
+
name="dietaryRestrictions"
|
78
|
+
options={dietaryOptions}
|
79
|
+
register={register}
|
80
|
+
{...props}
|
81
|
+
/>
|
82
|
+
|
83
|
+
<Button
|
84
|
+
htmlType="submit"
|
85
|
+
marginTop="lg"
|
86
|
+
text="Submit"
|
87
|
+
type="submit"
|
88
|
+
variant="primary"
|
89
|
+
|
90
|
+
/>
|
91
|
+
</form>
|
92
|
+
<Card marginTop="lg">
|
93
|
+
<Body
|
94
|
+
text="Current Form Values:"
|
95
|
+
variant="bold"
|
96
|
+
/>
|
97
|
+
<pre style={{ marginTop: '8px', color: "white" }}>
|
98
|
+
{JSON.stringify(formValues, null, 2)}
|
99
|
+
</pre>
|
100
|
+
</Card>
|
101
|
+
</Card>
|
102
|
+
</div>
|
103
|
+
)
|
104
|
+
}
|
105
|
+
|
106
|
+
export default SelectForm
|
107
|
+
|
108
|
+
|
109
|
+
|
@@ -10,3 +10,4 @@ export { default as SelectInline } from './_select_inline.jsx'
|
|
10
10
|
export { default as SelectInlineShowArrow } from './_select_inline_show_arrow.jsx'
|
11
11
|
export { default as SelectInlineCompact } from './_select_inline_compact.jsx'
|
12
12
|
export { default as SelectMultiple } from './_select_multiple.jsx'
|
13
|
+
export { default as SelectForm } from './_select_form.jsx'
|
@@ -5,4 +5,3 @@ export { default as TextInputDisabled } from './_text_input_disabled.jsx'
|
|
5
5
|
export { default as TextInputAddOn } from './_text_input_add_on.jsx'
|
6
6
|
export { default as TextInputInline } from './_text_input_inline.jsx'
|
7
7
|
export { default as TextInputNoLabel } from './_text_input_no_label.jsx'
|
8
|
-
export { default as TextInputMask } from './_text_input_mask.jsx'
|