|
18 | 18 | import { html, render } from "lit";
|
19 | 19 | import "../../dist/components/form/index.js";
|
20 | 20 |
|
21 |
| - const fields = [ |
22 |
| - { |
23 |
| - key: "name", |
24 |
| - label: "Name", |
25 |
| - type: "text", |
26 |
| - fieldOptions: { |
27 |
| - required: true, |
28 |
| - tooltip: "Your name", |
29 |
| - }, |
30 |
| - }, |
31 |
| - { |
32 |
| - key: "email", |
33 |
| - label: "Email", |
34 |
| - type: "email", |
35 |
| - fieldOptions: { |
36 |
| - tooltip: "Your email address", |
37 |
| - }, |
38 |
| - }, |
39 |
| - { |
40 |
| - key: "18+", |
41 |
| - label: "18+", |
42 |
| - type: "switch", |
43 |
| - fieldOptions: { |
44 |
| - tooltip: "Are you over 18 years old?", |
45 |
| - }, |
46 |
| - }, |
47 |
| - { |
48 |
| - key: "id", |
49 |
| - label: "ID", |
50 |
| - type: "file", |
51 |
| - fieldOptions: { |
52 |
| - required: true, |
53 |
| - tooltip: "Your ID document", |
54 |
| - }, |
55 |
| - }, |
56 |
| - { |
57 |
| - key: "id2", |
58 |
| - label: "ID", |
59 |
| - type: "file", |
60 |
| - fileOptions: { |
61 |
| - protocol: "tus", |
62 |
| - tusOptions: { |
63 |
| - endpoint: "https://tusd.tusdemo.net/files/", |
64 |
| - }, |
65 |
| - }, |
66 |
| - }, |
67 |
| - { |
68 |
| - key: "gender", |
69 |
| - label: "Gender", |
70 |
| - type: "select", |
71 |
| - fieldOptions: { |
72 |
| - required: true, |
73 |
| - }, |
74 |
| - selectOptions: [ |
75 |
| - { label: "Male", value: "1" }, |
76 |
| - { label: "Female", value: "2" }, |
77 |
| - { label: "Don't want to disclose", value: "3" }, |
78 |
| - ], |
79 |
| - }, |
80 |
| - { |
81 |
| - key: "address", |
82 |
| - label: "Address", |
83 |
| - type: "group", |
84 |
| - groupOptions: { |
85 |
| - collapsible: true, |
86 |
| - tooltip: "Your address", |
87 |
| - }, |
88 |
| - fieldOptions: { |
89 |
| - tooltip: "Group for address", |
90 |
| - }, |
91 |
| - arrayOptions: { |
92 |
| - defaultInstances: 1, |
93 |
| - max: 4, |
94 |
| - min: 1, |
95 |
| - }, |
96 |
| - children: [ |
97 |
| - { |
98 |
| - key: "Details", |
99 |
| - label: "Details", |
100 |
| - type: "array", |
101 |
| - fieldOptions: { |
102 |
| - tooltip: "Details for address", |
103 |
| - }, |
104 |
| - arrayOptions: { |
105 |
| - defaultInstances: 0, |
106 |
| - max: 2, |
107 |
| - }, |
108 |
| - children: [ |
109 |
| - { |
110 |
| - key: "houseNumber", |
111 |
| - label: "House Number", |
112 |
| - type: "text", |
113 |
| - fieldOptions: { |
114 |
| - required: true, |
115 |
| - tooltip: "Your house number", |
116 |
| - }, |
117 |
| - }, |
118 |
| - { |
119 |
| - key: "street", |
120 |
| - label: "Street", |
121 |
| - type: "text", |
122 |
| - fieldOptions: { |
123 |
| - default: "1601 Harrier Ln", |
124 |
| - required: false, |
125 |
| - tooltip: "Your street name", |
126 |
| - }, |
127 |
| - }, |
128 |
| - { |
129 |
| - key: "city", |
130 |
| - label: "City", |
131 |
| - type: "text", |
132 |
| - fieldOptions: { |
133 |
| - required: true, |
134 |
| - tooltip: "Your city name", |
135 |
| - }, |
136 |
| - }, |
137 |
| - { |
138 |
| - key: "isPrimary", |
139 |
| - label: "Primary", |
140 |
| - type: "switch", |
141 |
| - fieldOptions: { |
142 |
| - default: true, |
143 |
| - tooltip: "Is this your primary residence?", |
144 |
| - }, |
145 |
| - }, |
146 |
| - ], |
147 |
| - }, |
148 |
| - { |
149 |
| - key: "country", |
150 |
| - label: "Country", |
151 |
| - type: "text", |
152 |
| - fieldOptions: { |
153 |
| - required: true, |
154 |
| - tooltip: "Your country name", |
155 |
| - }, |
156 |
| - }, |
157 |
| - ], |
158 |
| - }, |
159 |
| - ]; |
160 |
| - |
161 | 21 | render(
|
162 | 22 | html`<ecc-d-form
|
163 |
| - .fields=${fields} |
164 | 23 | @ecc-utils-submit=${async (e) => {
|
165 | 24 | try {
|
166 | 25 | console.log("form - submitted", e.detail);
|
|
177 | 36 | }}
|
178 | 37 | >
|
179 | 38 | <ecc-d-form-input
|
| 39 | + key="name" |
| 40 | + label="Name" |
180 | 41 | required
|
181 |
| - label="On" |
| 42 | + tooltip="Enter name" |
| 43 | + ></ecc-d-form-input> |
| 44 | +
|
| 45 | + <ecc-d-form-input |
| 46 | + key="email" |
| 47 | + label="Email" |
| 48 | + tooltip="Enter your email address" |
| 49 | + ></ecc-d-form-input> |
| 50 | +
|
| 51 | + <ecc-d-form-input |
| 52 | + key="18+" |
| 53 | + label="18+" |
182 | 54 | type="switch"
|
| 55 | + tooltip="Are you over 18 years old?" |
183 | 56 | ></ecc-d-form-input>
|
184 | 57 |
|
185 | 58 | <ecc-d-form-input
|
| 59 | + key="id" |
| 60 | + label="ID" |
| 61 | + type="file" |
186 | 62 | required
|
187 |
| - type="text" |
188 |
| - label="name" |
189 |
| - key="name" |
190 |
| - value="different" |
191 |
| - placeholder="enter a name" |
| 63 | + tooltip="Your ID document" |
192 | 64 | ></ecc-d-form-input>
|
193 | 65 |
|
194 | 66 | <ecc-d-form-input
|
195 |
| - multiple |
| 67 | + key="id2" |
| 68 | + label="TUS ID" |
196 | 69 | type="file"
|
197 |
| - label="file" |
198 | 70 | protocol="tus"
|
199 |
| - tooltip="select a file" |
200 |
| - placeholder="enter a name" |
201 |
| - tus-endpoint="https://tusd.tusdemo.net/files/" |
| 71 | + endpoint="https://tusd.tusdemo.net/files/" |
| 72 | + tooltip="Your ID document" |
202 | 73 | ></ecc-d-form-input>
|
203 | 74 |
|
204 |
| - <ecc-d-form-group |
205 |
| - type="array" |
206 |
| - label="first group" |
207 |
| - instances="2" |
208 |
| - max-instances="3" |
209 |
| - > |
210 |
| - <ecc-d-form-input |
211 |
| - multiple |
212 |
| - type="select" |
213 |
| - required="true" |
214 |
| - label="Binary Gender" |
215 |
| - tooltip="Do not select" |
216 |
| - placeholder="enter a name" |
217 |
| - > |
218 |
| - <option ecc-option label="male">Male</option> |
219 |
| - <option ecc-option label="female">Female</option> |
220 |
| - </ecc-d-form-input> |
221 |
| -
|
222 |
| - <ecc-d-form-input |
223 |
| - required |
224 |
| - type="text" |
225 |
| - label="name" |
226 |
| - value="John doe" |
227 |
| - placeholder="enter a name" |
228 |
| - ></ecc-d-form-input> |
| 75 | + <ecc-d-form-input required type="select" label="Gender"> |
| 76 | + <option ecc-option value="female">Female</option> |
| 77 | + <option ecc-option value="male">Male</option> |
| 78 | + <option ecc-option value="none">Do not want to Disclose</option> |
| 79 | + </ecc-d-form-input> |
229 | 80 |
|
| 81 | + <ecc-d-form-group type="group" label="Address" key="address"> |
230 | 82 | <ecc-d-form-group
|
| 83 | + required |
231 | 84 | type="array"
|
| 85 | + label="Details" |
232 | 86 | instances="1"
|
233 |
| - label="nested group" |
234 |
| - max-instances="3" |
235 |
| - collapsible="true" |
| 87 | + max="2" |
| 88 | + min="1" |
236 | 89 | >
|
237 | 90 | <ecc-d-form-input
|
238 |
| - required |
239 |
| - type="text" |
240 |
| - label="name" |
241 |
| - value="John star" |
242 |
| - placeholder="enter a name" |
243 |
| - ></ecc-d-form-input> |
244 |
| - </ecc-d-form-group> |
245 |
| - </ecc-d-form-group> |
| 91 | + type="switch" |
| 92 | + key="isPrimary" |
| 93 | + label="Primary Address" |
| 94 | + > |
| 95 | + </ecc-d-form-input> |
| 96 | + <ecc-d-form-input |
| 97 | + key="houseNumber" |
| 98 | + label="House Number" |
| 99 | + tooltip="Your house number" |
| 100 | + > |
| 101 | + </ecc-d-form-input> |
| 102 | + <ecc-d-form-input required key="street" label="Street"> |
| 103 | + </ecc-d-form-input> |
| 104 | + <ecc-d-form-input required key="city" label="City"> |
| 105 | + </ecc-d-form-input> |
246 | 106 |
|
247 |
| - <ecc-d-form-group |
248 |
| - type="group" |
249 |
| - label="second group" |
250 |
| - max-instances="3" |
251 |
| - collapsible="true" |
252 |
| - > |
253 |
| - <ecc-d-form-input |
254 |
| - required |
255 |
| - type="text" |
256 |
| - key="username" |
257 |
| - label="username" |
258 |
| - value="John star" |
259 |
| - placeholder="enter a name" |
260 |
| - ></ecc-d-form-input> |
| 107 | + <ecc-d-form-input required key="country" label="Country"> |
| 108 | + </ecc-d-form-input> |
| 109 | + </ecc-d-form-group> |
261 | 110 | </ecc-d-form-group>
|
262 | 111 | </ecc-d-form> `,
|
263 | 112 | document.querySelector("#demo")
|
|
0 commit comments