@twintag/twintag-form 1.4.0-beta.1 → 1.4.0-beta.2
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 +4 -4
- package/CHANGELOG.md +6 -0
- package/README.md +2 -2
- package/dev/main.tsx +222 -2
- package/dist/components/config.d.ts +2 -2
- package/dist/components/containers/accordion.d.ts +2 -4
- package/dist/components/fields/checkbox.d.ts +1 -1
- 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/radiogroup.d.ts +3 -1
- package/dist/components/fields/textarea.d.ts +1 -1
- package/dist/components/fields/toggle.d.ts +1 -1
- package/dist/components/fields/tri-toggle.d.ts +1 -1
- package/dist/components/provider.d.ts +3 -3
- package/dist/twintag-form.react.js +1634 -1625
- package/dist/types/index.d.ts +37 -22
- package/dist/utils/data.d.ts +5 -1
- package/index.html +1 -0
- package/lib/components/config.tsx +2 -2
- package/lib/components/containers/accordion.tsx +32 -17
- package/lib/components/fields/checkbox.tsx +1 -1
- package/lib/components/fields/date-picker.tsx +5 -1
- package/lib/components/fields/file.tsx +83 -83
- package/lib/components/fields/input.tsx +1 -1
- package/lib/components/fields/radiogroup.tsx +5 -1
- package/lib/components/fields/textarea.tsx +1 -1
- package/lib/components/fields/toggle.tsx +1 -1
- package/lib/components/fields/tri-toggle.tsx +1 -1
- package/lib/components/provider.tsx +8 -4
- package/lib/types/index.ts +80 -49
- package/lib/utils/data.ts +5 -2
- package/package.json +3 -3
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @twintag/twintag-form@1.4.0-beta.
|
|
2
|
+
> @twintag/twintag-form@1.4.0-beta.2 build C:\Users\daryl\Desktop\twintag-projects\twintag-admin\packages\twintag-form
|
|
3
3
|
> tsc && vite build
|
|
4
4
|
|
|
5
5
|
[36mvite v5.2.11 [32mbuilding for production...[36m[39m
|
|
@@ -14,8 +14,8 @@ computing gzip size...
|
|
|
14
14
|
[vite:dts] Outside emitted: C:/Users/daryl/Desktop/twintag-projects/twintag-admin/packages/twintag-form/prettier.config.d.mts
|
|
15
15
|
[vite:dts] Outside emitted: C:/Users/daryl/Desktop/twintag-projects/twintag-admin/packages/twintag-form/dev/main.d.ts
|
|
16
16
|
[vite:dts] Outside emitted: C:/Users/daryl/Desktop/twintag-projects/twintag-admin/packages/twintag-form/vite.config.d.ts
|
|
17
|
-
[vite:dts] Declaration files built in
|
|
17
|
+
[vite:dts] Declaration files built in 5207ms.
|
|
18
18
|
|
|
19
19
|
[2mdist/[22m[36mtwintag-form.webcomponent.js [39m[1m[2m119.76 kB[22m[1m[22m[2m │ gzip: 33.52 kB[22m
|
|
20
|
-
[2mdist/[22m[36mtwintag-form.react.js [39m[1m[33m706.
|
|
21
|
-
[32m✓ built in
|
|
20
|
+
[2mdist/[22m[36mtwintag-form.react.js [39m[1m[33m706.32 kB[39m[22m[2m │ gzip: 144.27 kB[22m
|
|
21
|
+
[32m✓ built in 9.63s[39m
|
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -348,13 +348,13 @@ The form component exposes the following CSS variables:
|
|
|
348
348
|
| --tf-background | Background color for the input fields. |
|
|
349
349
|
| --tf-foreground | Text color for the input fields. |
|
|
350
350
|
| | |
|
|
351
|
-
| --tf-muted | Used for `toggle` and `tri-toggle` background when value is false.
|
|
351
|
+
| --tf-muted | Used for `toggle` and `tri-toggle` background when value is false. |
|
|
352
352
|
| --tf-muted-foreground | Color used for `placeholder` text (inputs) and description text. |
|
|
353
353
|
| | |
|
|
354
354
|
| --tf-primary | This color complements `primary-foreground`: `submit` button text |
|
|
355
355
|
| --tf-primary-foreground | This color is used for, `submit` background, `label` text and input value. |
|
|
356
356
|
| | |
|
|
357
|
-
| --tf-accent | The accent color is used for `toggle`, `tri-toggle`, `checkbox` and `radiogroup` inputs.
|
|
357
|
+
| --tf-accent | The accent color is used for `toggle`, `tri-toggle`, `checkbox` and `radiogroup` inputs. |
|
|
358
358
|
| --tf-accent-foreground | This color complements `accent` to show contrast between elements: `checkbox` check icon. |
|
|
359
359
|
| | |
|
|
360
360
|
| --tf-destructive | This color is used for `error` messages and the asterisk to mark a required input. |
|
package/dev/main.tsx
CHANGED
|
@@ -46,12 +46,205 @@ const config = [
|
|
|
46
46
|
},
|
|
47
47
|
{
|
|
48
48
|
type: 'accordion',
|
|
49
|
+
props: {
|
|
50
|
+
defaultValue: 'required2',
|
|
51
|
+
},
|
|
52
|
+
children: [
|
|
53
|
+
{
|
|
54
|
+
type: 'accordion',
|
|
55
|
+
props: {
|
|
56
|
+
subtype: 'item',
|
|
57
|
+
label: 'Required 1',
|
|
58
|
+
value: 'required1',
|
|
59
|
+
icon: 'archive-box-x-mark',
|
|
60
|
+
},
|
|
61
|
+
children: [
|
|
62
|
+
{
|
|
63
|
+
type: 'input',
|
|
64
|
+
props: {
|
|
65
|
+
subtype: 'toggle',
|
|
66
|
+
label: 'Required',
|
|
67
|
+
bind: 'required',
|
|
68
|
+
options: {
|
|
69
|
+
description: 'this field is required',
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
type: 'accordion',
|
|
77
|
+
props: {
|
|
78
|
+
subtype: 'item',
|
|
79
|
+
label: 'Required 2',
|
|
80
|
+
value: 'required2',
|
|
81
|
+
icon: 'archive-box-x-mark',
|
|
82
|
+
},
|
|
83
|
+
children: [
|
|
84
|
+
{
|
|
85
|
+
type: 'input',
|
|
86
|
+
props: {
|
|
87
|
+
subtype: 'toggle',
|
|
88
|
+
label: 'Required',
|
|
89
|
+
bind: 'required',
|
|
90
|
+
options: {
|
|
91
|
+
description: 'this field is required',
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
type: 'category',
|
|
103
|
+
props: {
|
|
104
|
+
label: 'Category 2nd',
|
|
105
|
+
},
|
|
106
|
+
children: [
|
|
107
|
+
{
|
|
108
|
+
type: 'input',
|
|
109
|
+
props: {
|
|
110
|
+
subtype: 'simple',
|
|
111
|
+
label: 'Email',
|
|
112
|
+
bind: 'email',
|
|
113
|
+
options: {
|
|
114
|
+
error: 'This field is required',
|
|
115
|
+
description: 'This field is required',
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
type: 'input',
|
|
121
|
+
props: {
|
|
122
|
+
subtype: 'radiogroup',
|
|
123
|
+
label: 'Radio Group',
|
|
124
|
+
bind: 'radiogroup',
|
|
125
|
+
options: {
|
|
126
|
+
description: 'This field is required',
|
|
127
|
+
error: 'This field is required',
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
children: [
|
|
131
|
+
{
|
|
132
|
+
type: 'item',
|
|
133
|
+
props: {
|
|
134
|
+
label: 'Checkbox',
|
|
135
|
+
bind: 'checkbox',
|
|
136
|
+
options: {
|
|
137
|
+
description: 'This field is required',
|
|
138
|
+
error: 'This field is required',
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
type: 'item',
|
|
144
|
+
props: {
|
|
145
|
+
label: 'Mote',
|
|
146
|
+
bind: 'mote',
|
|
147
|
+
options: {
|
|
148
|
+
description: 'This field is required',
|
|
149
|
+
error: 'This field is required',
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
type: 'category',
|
|
159
|
+
props: {
|
|
160
|
+
label: 'Category 3rd',
|
|
161
|
+
},
|
|
162
|
+
children: [
|
|
163
|
+
{
|
|
164
|
+
type: 'input',
|
|
165
|
+
props: {
|
|
166
|
+
subtype: 'file',
|
|
167
|
+
label: 'File',
|
|
168
|
+
bind: 'file',
|
|
169
|
+
options: {
|
|
170
|
+
error: 'This field is required',
|
|
171
|
+
description: 'This field is required',
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
],
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
type: 'category',
|
|
179
|
+
props: {
|
|
180
|
+
label: 'Category 4th',
|
|
181
|
+
},
|
|
182
|
+
children: [
|
|
183
|
+
{
|
|
184
|
+
type: 'input',
|
|
185
|
+
props: {
|
|
186
|
+
subtype: 'textarea',
|
|
187
|
+
label: 'Textarea',
|
|
188
|
+
bind: 'textarea',
|
|
189
|
+
options: {
|
|
190
|
+
description: 'This field is required',
|
|
191
|
+
error: 'This field is required',
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
type: 'input',
|
|
197
|
+
props: {
|
|
198
|
+
subtype: 'checkbox',
|
|
199
|
+
label: 'Checkbox',
|
|
200
|
+
bind: 'checkbox',
|
|
201
|
+
options: {
|
|
202
|
+
description: 'This field is required',
|
|
203
|
+
error: 'This field is required',
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
],
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
type: 'input',
|
|
211
|
+
props: {
|
|
212
|
+
subtype: 'submit',
|
|
213
|
+
label: 'Submit',
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
] as React.ComponentProps<typeof Form>['config'];
|
|
217
|
+
|
|
218
|
+
const config2 = [
|
|
219
|
+
{
|
|
220
|
+
type: 'category',
|
|
221
|
+
props: {
|
|
222
|
+
label: 'Category 1st',
|
|
223
|
+
},
|
|
224
|
+
children: [
|
|
225
|
+
{
|
|
226
|
+
type: 'input',
|
|
227
|
+
props: {
|
|
228
|
+
subtype: 'toggle',
|
|
229
|
+
label: 'Switch',
|
|
230
|
+
bind: 'switch',
|
|
231
|
+
options: {
|
|
232
|
+
description: 'this field is required',
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
type: 'accordion',
|
|
238
|
+
props: {
|
|
239
|
+
defaultValue: 'required2',
|
|
240
|
+
},
|
|
49
241
|
children: [
|
|
50
242
|
{
|
|
51
243
|
type: 'accordion',
|
|
52
244
|
props: {
|
|
53
245
|
subtype: 'item',
|
|
54
|
-
label: 'Required',
|
|
246
|
+
label: 'Required 2',
|
|
247
|
+
value: 'required2',
|
|
55
248
|
icon: 'archive-box-x-mark',
|
|
56
249
|
},
|
|
57
250
|
children: [
|
|
@@ -70,6 +263,28 @@ const config = [
|
|
|
70
263
|
},
|
|
71
264
|
],
|
|
72
265
|
},
|
|
266
|
+
{
|
|
267
|
+
type: 'input',
|
|
268
|
+
props: {
|
|
269
|
+
subtype: 'tri-toggle',
|
|
270
|
+
label: 'Tri-toggle',
|
|
271
|
+
bind: 'tri-toggle-bind',
|
|
272
|
+
options: {
|
|
273
|
+
description: 'this field is never required',
|
|
274
|
+
},
|
|
275
|
+
},
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
type: 'input',
|
|
279
|
+
props: {
|
|
280
|
+
subtype: 'datepicker',
|
|
281
|
+
label: 'Date picker',
|
|
282
|
+
bind: 'datepicker',
|
|
283
|
+
options: {
|
|
284
|
+
description: 'this field is required',
|
|
285
|
+
},
|
|
286
|
+
},
|
|
287
|
+
},
|
|
73
288
|
],
|
|
74
289
|
},
|
|
75
290
|
{
|
|
@@ -187,7 +402,7 @@ const config = [
|
|
|
187
402
|
label: 'Submit',
|
|
188
403
|
},
|
|
189
404
|
},
|
|
190
|
-
]
|
|
405
|
+
] as React.ComponentProps<typeof Form>['config'];
|
|
191
406
|
|
|
192
407
|
const options = {
|
|
193
408
|
defaultValues: {
|
|
@@ -231,3 +446,8 @@ submit?.addEventListener('click', () => {
|
|
|
231
446
|
?.querySelector('form')
|
|
232
447
|
?.dispatchEvent(new CustomEvent('twintag-form-validate'));
|
|
233
448
|
});
|
|
449
|
+
|
|
450
|
+
const setConfig = document.getElementById('set-config');
|
|
451
|
+
setConfig?.addEventListener('click', () => {
|
|
452
|
+
form?.setAttribute('config', JSON.stringify(config2));
|
|
453
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ElementType } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { InputCompConfig } from '../types';
|
|
3
3
|
|
|
4
|
-
export declare const Inputs: Map<string,
|
|
4
|
+
export declare const Inputs: Map<string, InputCompConfig>;
|
|
5
5
|
export declare const Containers: Map<string, ElementType>;
|
|
6
6
|
export declare const components: Map<string, ElementType>;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
+
import { Props } from '../../types';
|
|
1
2
|
import { WithChildren } from 'twintag-types/dom';
|
|
2
3
|
import { FC } from 'react';
|
|
3
4
|
|
|
4
|
-
type AccordionProps =
|
|
5
|
-
subtype?: 'item' | 'multiple' | 'single';
|
|
6
|
-
label?: string;
|
|
7
|
-
} & WithChildren;
|
|
5
|
+
type AccordionProps = Props<'accordion', 'item' | 'multiple' | 'single'> & WithChildren;
|
|
8
6
|
declare const Accordion: FC<AccordionProps>;
|
|
9
7
|
export { Accordion };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RawJsonComponent, TwintagFormContext,
|
|
1
|
+
import { ParsedJsonComponent, RawJsonComponent, TwintagFormContext, InputCompConfig } from '../types';
|
|
2
2
|
import { WithChildren } from 'twintag-types/dom';
|
|
3
3
|
import { Context, ElementType, ReactNode } from 'react';
|
|
4
4
|
|
|
@@ -6,14 +6,14 @@ export declare const twintagFormContext: Context<TwintagFormContext>;
|
|
|
6
6
|
export declare const useTwintagForm: () => TwintagFormContext;
|
|
7
7
|
type Components = TwintagFormContext['components'];
|
|
8
8
|
type Inputs = TwintagFormContext['inputs'];
|
|
9
|
-
export declare const getResetValues: (config:
|
|
9
|
+
export declare const getResetValues: (config: ParsedJsonComponent | ParsedJsonComponent[], inputs: Map<string, InputCompConfig>) => {
|
|
10
10
|
[k: string]: unknown;
|
|
11
11
|
};
|
|
12
12
|
export declare const TwintagFormProvider: ({ variant, size, inputs, components, config, children, }: {
|
|
13
13
|
config: RawJsonComponent | RawJsonComponent[];
|
|
14
14
|
variant: TwintagFormContext['variant'];
|
|
15
15
|
size: TwintagFormContext['size'];
|
|
16
|
-
inputs: Map<string,
|
|
16
|
+
inputs: Map<string, InputCompConfig>;
|
|
17
17
|
components: Map<string, ElementType>;
|
|
18
18
|
} & {
|
|
19
19
|
children?: ReactNode;
|