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