playbook_ui_docs 14.9.0.pre.alpha.PBNTR702stickyleftcolrails4806 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1b016405881ed19fca483e3361be7dcaa01afd51449cceb34ee0ca7c76c82e31
4
- data.tar.gz: 77db664eefe03b5284a4e17c9c596f43d89d6ecc7d266b4cc543d6f771782885
3
+ metadata.gz: 5db0c76bd6ac888d211e3b5213e5f6926669edaf064d364c236c52e8286e4326
4
+ data.tar.gz: 7b63bdcb87aaaf41211b0bd254350da776161d453504ac3e82e55ee79243b0bb
5
5
  SHA512:
6
- metadata.gz: 686b0ba7893ef53043369be569ce726bd3ff356df26e3c5b62294244f302115d06c84c35a386c16ec9ff0f75a03fde2fd224dbec0e718b0baf12ada263a5be99
7
- data.tar.gz: 9fb9acfb439bb19afdd4ac20f21afe7e5b318c2f2114b8ea60b3fb606b2484e645403c6129993e1c817f9aeb89d2e741c669cbb09ea605b9acf1a658bf1bbe28
6
+ metadata.gz: 6042b450ad6db13c1206d7e42babf09c7989db65b91048e1e12c9b9eb1a5c0e3b33044107ac903a69b61490695cc3891a1bfaff578773f5a034b980ff06b5f50
7
+ data.tar.gz: b4c8cd83fc92a4f9b016be33e6606396202f4ed3941ee16ee60726b63d1599d96c1cddcc766a47b746d47d302858a246144760376ce2291067b25861418a3ecc
@@ -0,0 +1,108 @@
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
+ marginTop="lg"
85
+ text="Submit"
86
+ type="submit"
87
+ variant="primary"
88
+
89
+ />
90
+ </form>
91
+ <Card marginTop="lg">
92
+ <Body
93
+ text="Current Form Values:"
94
+ variant="bold"
95
+ />
96
+ <pre style={{ marginTop: '8px', color: "white" }}>
97
+ {JSON.stringify(formValues, null, 2)}
98
+ </pre>
99
+ </Card>
100
+ </Card>
101
+ </div>
102
+ )
103
+ }
104
+
105
+ export default SelectForm
106
+
107
+
108
+
@@ -30,6 +30,7 @@ examples:
30
30
  - select_inline_show_arrow: Select Inline (Always Show Arrow)
31
31
  - select_inline_compact: Select Inline Compact
32
32
  - select_multiple: Select Multiple
33
+ - select_form: Form
33
34
 
34
35
  swift:
35
36
  - select_default_swift: Default
@@ -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'