@twintag/twintag-form 1.6.1 → 1.6.2-beta.1
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.
- package/.turbo/turbo-build.log +11 -11
- package/CHANGELOG.md +221 -209
- package/README.md +407 -370
- package/dev/index.css +32 -32
- package/dev/main.tsx +460 -459
- package/dist/components/fields/date-picker.d.ts +1 -1
- package/dist/components/fields/file.d.ts +1 -1
- package/dist/components/fields/input.d.ts +1 -1
- package/dist/components/fields/textarea.d.ts +1 -1
- package/dist/components/provider.d.ts +1 -6
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +152 -143
- package/dist/types/index.d.ts +16 -6
- package/dist/webcomponent.cjs +1 -1
- package/dist/webcomponent.d.ts +1 -1
- package/dist/webcomponent.js +3 -0
- package/lib/components/fields/date-picker.tsx +154 -154
- package/lib/components/fields/file.tsx +84 -83
- package/lib/components/fields/input.tsx +70 -70
- package/lib/components/fields/textarea.tsx +72 -68
- package/lib/components/provider.tsx +162 -163
- package/lib/index.tsx +45 -41
- package/lib/types/index.ts +102 -82
- package/lib/webcomponent.ts +2 -2
- package/package.json +1 -1
- package/vite.config.ts +2 -1
package/dev/main.tsx
CHANGED
|
@@ -1,459 +1,460 @@
|
|
|
1
|
-
import type { ComponentProps } from 'react';
|
|
2
|
-
import type { Form } from '../lib';
|
|
3
|
-
|
|
4
|
-
import '../
|
|
5
|
-
import './index.css';
|
|
6
|
-
|
|
7
|
-
const config = [
|
|
8
|
-
{
|
|
9
|
-
type: 'label',
|
|
10
|
-
props: {
|
|
11
|
-
label: 'Custom label',
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
type: 'category',
|
|
16
|
-
props: {
|
|
17
|
-
label: 'Category 1st',
|
|
18
|
-
},
|
|
19
|
-
children: [
|
|
20
|
-
{
|
|
21
|
-
type: 'input',
|
|
22
|
-
props: {
|
|
23
|
-
subtype: 'toggle',
|
|
24
|
-
label: 'Switch',
|
|
25
|
-
bind: 'switch',
|
|
26
|
-
options: {
|
|
27
|
-
description: 'this field is required',
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
type: 'input',
|
|
33
|
-
props: {
|
|
34
|
-
subtype: 'tri-toggle',
|
|
35
|
-
label: 'Tri-toggle',
|
|
36
|
-
bind: 'tri-toggle-bind',
|
|
37
|
-
options: {
|
|
38
|
-
description: 'this field is never required',
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
type: 'input',
|
|
44
|
-
props: {
|
|
45
|
-
subtype: 'datepicker',
|
|
46
|
-
label: 'Date picker',
|
|
47
|
-
bind: 'datepicker',
|
|
48
|
-
options: {
|
|
49
|
-
description: 'this field is required',
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
type: 'accordion',
|
|
55
|
-
props: {
|
|
56
|
-
defaultValue: 'required2',
|
|
57
|
-
},
|
|
58
|
-
children: [
|
|
59
|
-
{
|
|
60
|
-
type: 'accordion',
|
|
61
|
-
props: {
|
|
62
|
-
subtype: 'item',
|
|
63
|
-
label: 'Required 1',
|
|
64
|
-
value: 'required1',
|
|
65
|
-
icon: 'archive-box-x-mark',
|
|
66
|
-
},
|
|
67
|
-
children: [
|
|
68
|
-
{
|
|
69
|
-
type: 'input',
|
|
70
|
-
props: {
|
|
71
|
-
subtype: 'toggle',
|
|
72
|
-
label: 'Required',
|
|
73
|
-
bind: 'required',
|
|
74
|
-
options: {
|
|
75
|
-
description: 'this field is required',
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
],
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
type: 'accordion',
|
|
83
|
-
props: {
|
|
84
|
-
subtype: 'item',
|
|
85
|
-
label: 'Required 2',
|
|
86
|
-
value: 'required2',
|
|
87
|
-
icon: 'archive-box-x-mark',
|
|
88
|
-
},
|
|
89
|
-
children: [
|
|
90
|
-
{
|
|
91
|
-
type: 'input',
|
|
92
|
-
props: {
|
|
93
|
-
subtype: 'toggle',
|
|
94
|
-
label: 'Required',
|
|
95
|
-
bind: 'required',
|
|
96
|
-
options: {
|
|
97
|
-
description: 'this field is required',
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
],
|
|
102
|
-
},
|
|
103
|
-
],
|
|
104
|
-
},
|
|
105
|
-
],
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
type: 'category',
|
|
109
|
-
props: {
|
|
110
|
-
label: 'Category 2nd',
|
|
111
|
-
},
|
|
112
|
-
children: [
|
|
113
|
-
{
|
|
114
|
-
type: 'input',
|
|
115
|
-
props: {
|
|
116
|
-
subtype: 'simple',
|
|
117
|
-
label: 'Email',
|
|
118
|
-
bind: 'email',
|
|
119
|
-
options: {
|
|
120
|
-
error: 'This field is required',
|
|
121
|
-
description: 'This field is required',
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
type: 'input',
|
|
127
|
-
props: {
|
|
128
|
-
subtype: 'radiogroup',
|
|
129
|
-
label: 'Radio Group',
|
|
130
|
-
bind: 'radiogroup',
|
|
131
|
-
options: {
|
|
132
|
-
description: 'This field is required',
|
|
133
|
-
error: 'This field is required',
|
|
134
|
-
},
|
|
135
|
-
},
|
|
136
|
-
children: [
|
|
137
|
-
{
|
|
138
|
-
type: 'item',
|
|
139
|
-
props: {
|
|
140
|
-
label: 'Checkbox',
|
|
141
|
-
bind: 'checkbox',
|
|
142
|
-
options: {
|
|
143
|
-
description: 'This field is required',
|
|
144
|
-
error: 'This field is required',
|
|
145
|
-
},
|
|
146
|
-
},
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
type: 'item',
|
|
150
|
-
props: {
|
|
151
|
-
label: 'Mote',
|
|
152
|
-
bind: 'mote',
|
|
153
|
-
options: {
|
|
154
|
-
description: 'This field is required',
|
|
155
|
-
error: 'This field is required',
|
|
156
|
-
},
|
|
157
|
-
},
|
|
158
|
-
},
|
|
159
|
-
],
|
|
160
|
-
},
|
|
161
|
-
],
|
|
162
|
-
},
|
|
163
|
-
{
|
|
164
|
-
type: 'category',
|
|
165
|
-
props: {
|
|
166
|
-
label: 'Category 3rd',
|
|
167
|
-
},
|
|
168
|
-
children: [
|
|
169
|
-
{
|
|
170
|
-
type: 'input',
|
|
171
|
-
props: {
|
|
172
|
-
subtype: 'file',
|
|
173
|
-
label: 'File',
|
|
174
|
-
bind: 'file',
|
|
175
|
-
options: {
|
|
176
|
-
error: 'This field is required',
|
|
177
|
-
description: 'This field is required',
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
form?.setAttribute('
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
getValues
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
?.
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
submit
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
?.
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
setConfig
|
|
458
|
-
|
|
459
|
-
|
|
1
|
+
import type { ComponentProps } from 'react';
|
|
2
|
+
import type { Form } from '../lib';
|
|
3
|
+
|
|
4
|
+
import '../dist/webcomponent';
|
|
5
|
+
import './index.css';
|
|
6
|
+
|
|
7
|
+
const config = [
|
|
8
|
+
{
|
|
9
|
+
type: 'label',
|
|
10
|
+
props: {
|
|
11
|
+
label: 'Custom label',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
type: 'category',
|
|
16
|
+
props: {
|
|
17
|
+
label: 'Category 1st',
|
|
18
|
+
},
|
|
19
|
+
children: [
|
|
20
|
+
{
|
|
21
|
+
type: 'input',
|
|
22
|
+
props: {
|
|
23
|
+
subtype: 'toggle',
|
|
24
|
+
label: 'Switch',
|
|
25
|
+
bind: 'switch',
|
|
26
|
+
options: {
|
|
27
|
+
description: 'this field is required',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
type: 'input',
|
|
33
|
+
props: {
|
|
34
|
+
subtype: 'tri-toggle',
|
|
35
|
+
label: 'Tri-toggle',
|
|
36
|
+
bind: 'tri-toggle-bind',
|
|
37
|
+
options: {
|
|
38
|
+
description: 'this field is never required',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
type: 'input',
|
|
44
|
+
props: {
|
|
45
|
+
subtype: 'datepicker',
|
|
46
|
+
label: 'Date picker',
|
|
47
|
+
bind: 'datepicker',
|
|
48
|
+
options: {
|
|
49
|
+
description: 'this field is required',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
type: 'accordion',
|
|
55
|
+
props: {
|
|
56
|
+
defaultValue: 'required2',
|
|
57
|
+
},
|
|
58
|
+
children: [
|
|
59
|
+
{
|
|
60
|
+
type: 'accordion',
|
|
61
|
+
props: {
|
|
62
|
+
subtype: 'item',
|
|
63
|
+
label: 'Required 1',
|
|
64
|
+
value: 'required1',
|
|
65
|
+
icon: 'archive-box-x-mark',
|
|
66
|
+
},
|
|
67
|
+
children: [
|
|
68
|
+
{
|
|
69
|
+
type: 'input',
|
|
70
|
+
props: {
|
|
71
|
+
subtype: 'toggle',
|
|
72
|
+
label: 'Required',
|
|
73
|
+
bind: 'required',
|
|
74
|
+
options: {
|
|
75
|
+
description: 'this field is required',
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
type: 'accordion',
|
|
83
|
+
props: {
|
|
84
|
+
subtype: 'item',
|
|
85
|
+
label: 'Required 2',
|
|
86
|
+
value: 'required2',
|
|
87
|
+
icon: 'archive-box-x-mark',
|
|
88
|
+
},
|
|
89
|
+
children: [
|
|
90
|
+
{
|
|
91
|
+
type: 'input',
|
|
92
|
+
props: {
|
|
93
|
+
subtype: 'toggle',
|
|
94
|
+
label: 'Required',
|
|
95
|
+
bind: 'required',
|
|
96
|
+
options: {
|
|
97
|
+
description: 'this field is required',
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
type: 'category',
|
|
109
|
+
props: {
|
|
110
|
+
label: 'Category 2nd',
|
|
111
|
+
},
|
|
112
|
+
children: [
|
|
113
|
+
{
|
|
114
|
+
type: 'input',
|
|
115
|
+
props: {
|
|
116
|
+
subtype: 'simple',
|
|
117
|
+
label: 'Email',
|
|
118
|
+
bind: 'email',
|
|
119
|
+
options: {
|
|
120
|
+
error: 'This field is required',
|
|
121
|
+
description: 'This field is required',
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
type: 'input',
|
|
127
|
+
props: {
|
|
128
|
+
subtype: 'radiogroup',
|
|
129
|
+
label: 'Radio Group',
|
|
130
|
+
bind: 'radiogroup',
|
|
131
|
+
options: {
|
|
132
|
+
description: 'This field is required',
|
|
133
|
+
error: 'This field is required',
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
children: [
|
|
137
|
+
{
|
|
138
|
+
type: 'item',
|
|
139
|
+
props: {
|
|
140
|
+
label: 'Checkbox',
|
|
141
|
+
bind: 'checkbox',
|
|
142
|
+
options: {
|
|
143
|
+
description: 'This field is required',
|
|
144
|
+
error: 'This field is required',
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
type: 'item',
|
|
150
|
+
props: {
|
|
151
|
+
label: 'Mote',
|
|
152
|
+
bind: 'mote',
|
|
153
|
+
options: {
|
|
154
|
+
description: 'This field is required',
|
|
155
|
+
error: 'This field is required',
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
},
|
|
161
|
+
],
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
type: 'category',
|
|
165
|
+
props: {
|
|
166
|
+
label: 'Category 3rd',
|
|
167
|
+
},
|
|
168
|
+
children: [
|
|
169
|
+
{
|
|
170
|
+
type: 'input',
|
|
171
|
+
props: {
|
|
172
|
+
subtype: 'file',
|
|
173
|
+
label: 'File',
|
|
174
|
+
bind: 'file',
|
|
175
|
+
options: {
|
|
176
|
+
error: 'This field is required',
|
|
177
|
+
description: 'This field is required',
|
|
178
|
+
accept: 'image/*',
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
],
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
type: 'category',
|
|
186
|
+
props: {
|
|
187
|
+
label: 'Category 4th',
|
|
188
|
+
},
|
|
189
|
+
children: [
|
|
190
|
+
{
|
|
191
|
+
type: 'input',
|
|
192
|
+
props: {
|
|
193
|
+
subtype: 'textarea',
|
|
194
|
+
label: 'Textarea',
|
|
195
|
+
bind: 'textarea',
|
|
196
|
+
options: {
|
|
197
|
+
description: 'This field is required',
|
|
198
|
+
error: 'This field is required',
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
type: 'input',
|
|
204
|
+
props: {
|
|
205
|
+
subtype: 'checkbox',
|
|
206
|
+
label: 'Checkbox',
|
|
207
|
+
bind: 'checkbox',
|
|
208
|
+
options: {
|
|
209
|
+
description: 'This field is required',
|
|
210
|
+
error: 'This field is required',
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
],
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
type: 'input',
|
|
218
|
+
props: {
|
|
219
|
+
subtype: 'submit',
|
|
220
|
+
label: 'Submit',
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
] as React.ComponentProps<typeof Form>['config'];
|
|
224
|
+
|
|
225
|
+
const config2 = [
|
|
226
|
+
{
|
|
227
|
+
type: 'category',
|
|
228
|
+
props: {
|
|
229
|
+
label: 'Category 1st',
|
|
230
|
+
},
|
|
231
|
+
children: [
|
|
232
|
+
{
|
|
233
|
+
type: 'input',
|
|
234
|
+
props: {
|
|
235
|
+
subtype: 'toggle',
|
|
236
|
+
label: 'Switch',
|
|
237
|
+
bind: 'switch',
|
|
238
|
+
options: {
|
|
239
|
+
description: 'this field is required',
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
type: 'accordion',
|
|
245
|
+
props: {
|
|
246
|
+
defaultValue: 'required2',
|
|
247
|
+
},
|
|
248
|
+
children: [
|
|
249
|
+
{
|
|
250
|
+
type: 'accordion',
|
|
251
|
+
props: {
|
|
252
|
+
subtype: 'item',
|
|
253
|
+
label: 'Required 2',
|
|
254
|
+
value: 'required2',
|
|
255
|
+
icon: 'archive-box-x-mark',
|
|
256
|
+
},
|
|
257
|
+
children: [
|
|
258
|
+
{
|
|
259
|
+
type: 'input',
|
|
260
|
+
props: {
|
|
261
|
+
subtype: 'toggle',
|
|
262
|
+
label: 'Required',
|
|
263
|
+
bind: 'required',
|
|
264
|
+
options: {
|
|
265
|
+
description: 'this field is required',
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
},
|
|
269
|
+
],
|
|
270
|
+
},
|
|
271
|
+
],
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
type: 'input',
|
|
275
|
+
props: {
|
|
276
|
+
subtype: 'tri-toggle',
|
|
277
|
+
label: 'Tri-toggle',
|
|
278
|
+
bind: 'tri-toggle-bind',
|
|
279
|
+
options: {
|
|
280
|
+
description: 'this field is never required',
|
|
281
|
+
},
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
type: 'input',
|
|
286
|
+
props: {
|
|
287
|
+
subtype: 'datepicker',
|
|
288
|
+
label: 'Date picker',
|
|
289
|
+
bind: 'datepicker',
|
|
290
|
+
options: {
|
|
291
|
+
description: 'this field is required',
|
|
292
|
+
},
|
|
293
|
+
},
|
|
294
|
+
},
|
|
295
|
+
],
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
type: 'category',
|
|
299
|
+
props: {
|
|
300
|
+
label: 'Category 2nd',
|
|
301
|
+
},
|
|
302
|
+
children: [
|
|
303
|
+
{
|
|
304
|
+
type: 'input',
|
|
305
|
+
props: {
|
|
306
|
+
subtype: 'simple',
|
|
307
|
+
label: 'Email',
|
|
308
|
+
bind: 'email',
|
|
309
|
+
options: {
|
|
310
|
+
error: 'This field is required',
|
|
311
|
+
description: 'This field is required',
|
|
312
|
+
},
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
type: 'input',
|
|
317
|
+
props: {
|
|
318
|
+
subtype: 'radiogroup',
|
|
319
|
+
label: 'Radio Group',
|
|
320
|
+
bind: 'radiogroup',
|
|
321
|
+
options: {
|
|
322
|
+
description: 'This field is required',
|
|
323
|
+
error: 'This field is required',
|
|
324
|
+
},
|
|
325
|
+
},
|
|
326
|
+
children: [
|
|
327
|
+
{
|
|
328
|
+
type: 'item',
|
|
329
|
+
props: {
|
|
330
|
+
label: 'Checkbox',
|
|
331
|
+
bind: 'checkbox',
|
|
332
|
+
options: {
|
|
333
|
+
description: 'This field is required',
|
|
334
|
+
error: 'This field is required',
|
|
335
|
+
},
|
|
336
|
+
},
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
type: 'item',
|
|
340
|
+
props: {
|
|
341
|
+
label: 'Mote',
|
|
342
|
+
bind: 'mote',
|
|
343
|
+
options: {
|
|
344
|
+
description: 'This field is required',
|
|
345
|
+
error: 'This field is required',
|
|
346
|
+
},
|
|
347
|
+
},
|
|
348
|
+
},
|
|
349
|
+
],
|
|
350
|
+
},
|
|
351
|
+
],
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
type: 'category',
|
|
355
|
+
props: {
|
|
356
|
+
label: 'Category 3rd',
|
|
357
|
+
},
|
|
358
|
+
children: [
|
|
359
|
+
{
|
|
360
|
+
type: 'input',
|
|
361
|
+
props: {
|
|
362
|
+
subtype: 'file',
|
|
363
|
+
label: 'File',
|
|
364
|
+
bind: 'file',
|
|
365
|
+
options: {
|
|
366
|
+
error: 'This field is required',
|
|
367
|
+
description: 'This field is required',
|
|
368
|
+
},
|
|
369
|
+
},
|
|
370
|
+
},
|
|
371
|
+
],
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
type: 'category',
|
|
375
|
+
props: {
|
|
376
|
+
label: 'Category 4th',
|
|
377
|
+
},
|
|
378
|
+
children: [
|
|
379
|
+
{
|
|
380
|
+
type: 'input',
|
|
381
|
+
props: {
|
|
382
|
+
subtype: 'textarea',
|
|
383
|
+
label: 'Textarea',
|
|
384
|
+
bind: 'textarea',
|
|
385
|
+
options: {
|
|
386
|
+
description: 'This field is required',
|
|
387
|
+
error: 'This field is required',
|
|
388
|
+
},
|
|
389
|
+
},
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
type: 'input',
|
|
393
|
+
props: {
|
|
394
|
+
subtype: 'checkbox',
|
|
395
|
+
label: 'Checkbox',
|
|
396
|
+
bind: 'checkbox',
|
|
397
|
+
options: {
|
|
398
|
+
description: 'This field is required',
|
|
399
|
+
error: 'This field is required',
|
|
400
|
+
},
|
|
401
|
+
},
|
|
402
|
+
},
|
|
403
|
+
],
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
type: 'input',
|
|
407
|
+
props: {
|
|
408
|
+
subtype: 'submit',
|
|
409
|
+
label: 'Submit',
|
|
410
|
+
},
|
|
411
|
+
},
|
|
412
|
+
] as React.ComponentProps<typeof Form>['config'];
|
|
413
|
+
|
|
414
|
+
const options = {
|
|
415
|
+
defaultValues: {
|
|
416
|
+
'tri-toggle-bind': null,
|
|
417
|
+
required: true,
|
|
418
|
+
email: 'This should work',
|
|
419
|
+
radiogroup: 'mote',
|
|
420
|
+
checkbox: true,
|
|
421
|
+
textarea: 'This is a textarea',
|
|
422
|
+
},
|
|
423
|
+
variant: 'outline',
|
|
424
|
+
resetOnSubmit: true,
|
|
425
|
+
} as ComponentProps<typeof Form>['options'];
|
|
426
|
+
|
|
427
|
+
// the key properties for the defaultValues object are the same as the bind properties
|
|
428
|
+
const form = document.querySelector('twintag-form');
|
|
429
|
+
|
|
430
|
+
form?.setAttribute('config', JSON.stringify(config));
|
|
431
|
+
form?.setAttribute('options', JSON.stringify(options));
|
|
432
|
+
|
|
433
|
+
form?.addEventListener('twintag-form-values', (event) => {
|
|
434
|
+
console.log('form values', (event as CustomEvent).detail);
|
|
435
|
+
});
|
|
436
|
+
form?.addEventListener('twintag-form-valid', (e) => {
|
|
437
|
+
console.log('form valid', (e as CustomEvent).detail);
|
|
438
|
+
});
|
|
439
|
+
form?.addEventListener('twintag-form-invalid', (e) => {
|
|
440
|
+
console.log('form invalid', (e as CustomEvent).detail);
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
const getValues = document.getElementById('get-values');
|
|
444
|
+
getValues?.addEventListener('click', () => {
|
|
445
|
+
form?.shadowRoot
|
|
446
|
+
?.querySelector('form')
|
|
447
|
+
?.dispatchEvent(new CustomEvent('twintag-form-get_values'));
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
const submit = document.getElementById('submit');
|
|
451
|
+
submit?.addEventListener('click', () => {
|
|
452
|
+
form?.shadowRoot
|
|
453
|
+
?.querySelector('form')
|
|
454
|
+
?.dispatchEvent(new CustomEvent('twintag-form-validate'));
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
const setConfig = document.getElementById('set-config');
|
|
458
|
+
setConfig?.addEventListener('click', () => {
|
|
459
|
+
form?.setAttribute('config', JSON.stringify(config2));
|
|
460
|
+
});
|