@twintag/twintag-form 0.5.0 → 1.0.0-beta.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/.eslintrc.cjs +6 -1
- package/.turbo/turbo-build.log +15 -10
- package/.turbo/turbo-lint.log +4 -0
- package/CHANGELOG.md +17 -0
- package/README.md +87 -59
- package/dev/index.css +29 -0
- package/dev/main.tsx +163 -0
- package/dist/common/button.d.ts +137 -0
- package/dist/common/checkbox.d.ts +4 -0
- package/dist/common/form.d.ts +24 -0
- package/dist/common/input.d.ts +4 -0
- package/dist/common/label.d.ts +4 -0
- package/dist/common/radiogroup.d.ts +5 -0
- package/dist/common/switch.d.ts +4 -0
- package/dist/common/textarea.d.ts +4 -0
- package/dist/components/Input/checkbox.d.ts +2 -6
- package/dist/components/Input/file.d.ts +2 -6
- package/dist/components/Input/index.d.ts +2 -2
- package/dist/components/Input/radiogroup.d.ts +3 -0
- package/dist/components/Input/simple.d.ts +2 -6
- package/dist/components/Input/submit.d.ts +2 -6
- package/dist/components/Input/textarea.d.ts +2 -6
- package/dist/components/Input/toggle.d.ts +2 -6
- package/dist/components/Render/index.d.ts +7 -0
- package/dist/components/Render/useJson.d.ts +2 -0
- package/dist/components/{Label/index.d.ts → category.d.ts} +3 -4
- package/dist/components/form.d.ts +7 -0
- package/dist/components/index.d.ts +8 -4
- package/dist/index.d.ts +8 -9
- package/dist/provider.d.ts +8 -0
- package/dist/twintag-form.react.js +7961 -8082
- package/dist/twintag-form.webcomponent.js +2003 -1765
- package/dist/types/index.d.ts +33 -0
- package/index.html +13 -0
- package/lib/common/button.tsx +49 -0
- package/lib/common/checkbox.tsx +40 -0
- package/lib/common/form.tsx +192 -0
- package/lib/common/input.tsx +55 -0
- package/lib/common/label.tsx +26 -0
- package/lib/common/radiogroup.tsx +56 -0
- package/lib/common/switch.tsx +39 -0
- package/lib/common/textarea.tsx +53 -0
- package/lib/components/Input/checkbox.tsx +55 -42
- package/lib/components/Input/file.tsx +64 -72
- package/lib/components/Input/index.tsx +15 -15
- package/lib/components/Input/radiogroup.tsx +84 -0
- package/lib/components/Input/simple.tsx +50 -28
- package/lib/components/Input/submit.tsx +4 -13
- package/lib/components/Input/textarea.tsx +49 -27
- package/lib/components/Input/toggle.tsx +54 -45
- package/lib/components/Render/index.tsx +30 -0
- package/lib/components/Render/useJson.ts +76 -0
- package/lib/components/category.tsx +31 -0
- package/lib/components/form.tsx +75 -0
- package/lib/components/index.tsx +27 -4
- package/lib/index.tsx +24 -48
- package/lib/provider.tsx +36 -0
- package/lib/types/index.ts +37 -0
- package/lib/webcomponent.ts +4 -4
- package/package.json +21 -12
- package/prettier.config.mjs +26 -0
- package/tailwind.config.ts +43 -0
- package/tsconfig.json +25 -6
- package/twind.config.ts +4 -21
- package/vite.config.ts +2 -2
- package/dist/components/Category/__styles.d.ts +0 -19
- package/dist/components/Category/index.d.ts +0 -8
- package/dist/components/Form/index.d.ts +0 -12
- package/dist/components/Input/__props.d.ts +0 -10
- package/dist/components/Input/__styles.d.ts +0 -245
- package/dist/styles.d.ts +0 -262
- package/lib/__stories__/Form.stories.tsx +0 -141
- package/lib/components/Category/__styles.ts +0 -12
- package/lib/components/Category/index.tsx +0 -26
- package/lib/components/Form/index.tsx +0 -86
- package/lib/components/Input/__props.ts +0 -10
- package/lib/components/Input/__styles.ts +0 -132
- package/lib/components/Label/index.tsx +0 -24
- package/lib/styles.ts +0 -143
- package/tailwind.config.cjs +0 -8
package/.eslintrc.cjs
CHANGED
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
|
|
2
|
-
> @twintag/twintag-form@0.
|
|
2
|
+
> @twintag/twintag-form@1.0.0-beta.0 build C:\Users\daryl\Desktop\twintag-projects\twintag-admin\packages\twintag-form
|
|
3
3
|
> tsc && vite build
|
|
4
4
|
|
|
5
|
-
[36mvite v4.
|
|
5
|
+
[36mvite v4.4.9 [32mbuilding for production...[36m[39m
|
|
6
6
|
transforming...
|
|
7
|
-
[32m✓[39m
|
|
7
|
+
[32m✓[39m 1358 modules transformed.
|
|
8
8
|
rendering chunks...
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
|
|
10
|
+
[vite:dts] Start generate declaration files...
|
|
11
11
|
computing gzip size...
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
[vite:dts] Outside emitted: C:/Users/daryl/Desktop/twintag-projects/twintag-admin/packages/twintag-form/tailwind.config.d.ts
|
|
13
|
+
[vite:dts] Outside emitted: C:/Users/daryl/Desktop/twintag-projects/twintag-admin/packages/twintag-form/.eslintrc.d.cts
|
|
14
|
+
[vite:dts] Outside emitted: C:/Users/daryl/Desktop/twintag-projects/twintag-admin/packages/twintag-form/prettier.config.d.mts
|
|
15
|
+
[vite:dts] Outside emitted: C:/Users/daryl/Desktop/twintag-projects/twintag-admin/packages/twintag-form/dev/main.d.ts
|
|
16
|
+
[vite:dts] Outside emitted: C:/Users/daryl/Desktop/twintag-projects/twintag-admin/packages/twintag-form/vite.config.d.ts
|
|
17
|
+
[2mdist/[22m[36mtwintag-form.webcomponent.js [39m[1m[2m119.20 kB[22m[1m[22m[2m │ gzip: 33.33 kB[22m
|
|
18
|
+
[2mdist/[22m[36mtwintag-form.react.js [39m[1m[2m247.16 kB[22m[1m[22m[2m │ gzip: 56.86 kB[22m
|
|
19
|
+
[vite:dts] Declaration files built in 3617ms.
|
|
20
|
+
|
|
21
|
+
[32m✓ built in 6.81s[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @twintag/twintag-form
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- d84b6f7: refactor: design system update
|
|
8
|
+
|
|
9
|
+
## 0.6.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 04036a0: fix: styles update and code clean-up
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [04036a0]
|
|
18
|
+
- @twintag/twintag-json-renderer@0.2.0
|
|
19
|
+
|
|
3
20
|
## 0.5.0
|
|
4
21
|
|
|
5
22
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -8,13 +8,8 @@
|
|
|
8
8
|
- [Config](#config)
|
|
9
9
|
- [Options](#options)
|
|
10
10
|
- [Inputs](#inputs)
|
|
11
|
-
- [
|
|
12
|
-
- [
|
|
13
|
-
- [Textarea](#textarea)
|
|
14
|
-
- [File](#file)
|
|
15
|
-
- [Checkbox](#checkbox)
|
|
16
|
-
- [Toggle](#toggle)
|
|
17
|
-
- [Submit](#submit)
|
|
11
|
+
- [Options](#options)
|
|
12
|
+
- [Subtypes](#subtypes)
|
|
18
13
|
- [Event Handling](#event-handling)
|
|
19
14
|
- [CSS](#css)
|
|
20
15
|
|
|
@@ -43,16 +38,18 @@ The form component receives the following parameters:
|
|
|
43
38
|
|
|
44
39
|
The `config` object contains the form structure. It is organized by the index of the items, where each item is an `Input` field represented by an object with the following properties:
|
|
45
40
|
|
|
46
|
-
| Property
|
|
47
|
-
|
|
|
48
|
-
| `
|
|
49
|
-
| `
|
|
50
|
-
| `
|
|
41
|
+
| Property | Type | Description |
|
|
42
|
+
| --------- | -------- | -------------------------------------------------------------------------------- |
|
|
43
|
+
| `type` | `string` | Component type. The subtype is optional as part of the string: `input:<subtype>` |
|
|
44
|
+
| `subtype` | `string` | Component subtype |
|
|
45
|
+
| `label` | `string` | Field label. |
|
|
46
|
+
| `bind` | `string` | Field name. |
|
|
51
47
|
|
|
52
48
|
```json
|
|
53
49
|
[
|
|
54
50
|
{
|
|
55
|
-
"type": "input
|
|
51
|
+
"type": "input",
|
|
52
|
+
"subtype": "simple",
|
|
56
53
|
"label": "Email",
|
|
57
54
|
"bind": "email"
|
|
58
55
|
},
|
|
@@ -62,7 +59,8 @@ The `config` object contains the form structure. It is organized by the index of
|
|
|
62
59
|
"bind": "message"
|
|
63
60
|
},
|
|
64
61
|
{
|
|
65
|
-
"type": "input
|
|
62
|
+
"type": "input",
|
|
63
|
+
"subtype": "submit",
|
|
66
64
|
"label": "Submit"
|
|
67
65
|
}
|
|
68
66
|
]
|
|
@@ -72,103 +70,121 @@ The `config` object contains the form structure. It is organized by the index of
|
|
|
72
70
|
|
|
73
71
|
Twintag Form provides some options to customize the form:
|
|
74
72
|
|
|
75
|
-
| Option | Type
|
|
76
|
-
| --------------- |
|
|
77
|
-
| `variant` | `
|
|
78
|
-
| `resetOnSubmit` | `boolean`
|
|
73
|
+
| Option | Type | Description |
|
|
74
|
+
| --------------- | -------------- | ------------------------------------------------------------------------- |
|
|
75
|
+
| `variant` | `default/beta` | Variant of the form. |
|
|
76
|
+
| `resetOnSubmit` | `boolean` | If `true`, the form will be reset after submitting. (`false` per default) |
|
|
79
77
|
|
|
80
78
|
### **Inputs**
|
|
81
79
|
|
|
82
|
-
#### **
|
|
80
|
+
#### **Options**
|
|
83
81
|
|
|
84
|
-
Each input can be customized with the following options:
|
|
82
|
+
Each input can be customized with the following optional options:
|
|
85
83
|
|
|
86
|
-
| Option | Type
|
|
87
|
-
| --------------- |
|
|
88
|
-
| `
|
|
89
|
-
| `
|
|
90
|
-
| `
|
|
84
|
+
| Option | Type | Description |
|
|
85
|
+
| --------------- | --------- | ------------------------------------------------------------ |
|
|
86
|
+
| `description` | `string` | Description of the input. |
|
|
87
|
+
| `error` | `string` | Error message. |
|
|
88
|
+
| `placeholder` | `string` | Placeholder of the input. |
|
|
89
|
+
| `optionalField` | `boolean` | If `true`, the field will be optional. (`false` per default) |
|
|
91
90
|
|
|
92
91
|
```json
|
|
93
92
|
{
|
|
94
|
-
"type": "input
|
|
93
|
+
"type": "input",
|
|
94
|
+
"subtype": "simple",
|
|
95
95
|
"label": "Email",
|
|
96
96
|
"bind": "email",
|
|
97
97
|
"options": {
|
|
98
|
-
"
|
|
99
|
-
"
|
|
98
|
+
"description": "Please enter you email",
|
|
99
|
+
"error": "The field is empty."
|
|
100
|
+
"placeholder": "Write here...",
|
|
100
101
|
"optionalField": true
|
|
101
102
|
}
|
|
102
103
|
}
|
|
103
104
|
```
|
|
104
105
|
|
|
105
|
-
|
|
106
|
+
### **Subtypes**
|
|
106
107
|
|
|
107
|
-
|
|
108
|
+
- Simple
|
|
108
109
|
|
|
109
110
|
```json
|
|
110
111
|
{
|
|
111
|
-
"type": "input
|
|
112
|
+
"type": "input",
|
|
113
|
+
"subtype": "simple",
|
|
112
114
|
"label": "Email",
|
|
113
115
|
"bind": "email"
|
|
114
116
|
}
|
|
115
117
|
```
|
|
116
118
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
The `textarea` input is a textarea input.
|
|
119
|
+
- Textarea
|
|
120
120
|
|
|
121
121
|
```json
|
|
122
122
|
{
|
|
123
|
-
"type": "input
|
|
123
|
+
"type": "input",
|
|
124
|
+
"subtype": "textarea",
|
|
124
125
|
"label": "Message",
|
|
125
126
|
"bind": "message"
|
|
126
127
|
}
|
|
127
128
|
```
|
|
128
129
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
The `file` input is a file input.
|
|
130
|
+
- File
|
|
132
131
|
|
|
133
132
|
```json
|
|
134
133
|
{
|
|
135
|
-
"type": "input
|
|
134
|
+
"type": "input",
|
|
135
|
+
"subtype": "file",
|
|
136
136
|
"label": "File",
|
|
137
137
|
"bind": "file"
|
|
138
138
|
}
|
|
139
139
|
```
|
|
140
140
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
The `checkbox` input is a checkbox input.
|
|
141
|
+
- Checkbox
|
|
144
142
|
|
|
145
143
|
```json
|
|
146
144
|
{
|
|
147
|
-
"type": "input
|
|
145
|
+
"type": "input",
|
|
146
|
+
"subtype": "checkbox",
|
|
148
147
|
"label": "Checkbox",
|
|
149
148
|
"bind": "checkbox"
|
|
150
149
|
}
|
|
151
150
|
```
|
|
152
151
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
The `toggle` input is a toggle input.
|
|
152
|
+
- Toggle
|
|
156
153
|
|
|
157
154
|
```json
|
|
158
155
|
{
|
|
159
|
-
"type": "input
|
|
156
|
+
"type": "input",
|
|
157
|
+
"subtype": "toggle",
|
|
160
158
|
"label": "Toggle",
|
|
161
159
|
"bind": "toggle"
|
|
162
160
|
}
|
|
163
161
|
```
|
|
164
162
|
|
|
165
|
-
|
|
163
|
+
- Radiogroup
|
|
164
|
+
|
|
165
|
+
```json
|
|
166
|
+
{
|
|
167
|
+
"type": "input",
|
|
168
|
+
"subtype": "radiogroup",
|
|
169
|
+
"label": "Radio Group",
|
|
170
|
+
"bind": "radiogroup",
|
|
171
|
+
"children": [
|
|
172
|
+
{
|
|
173
|
+
"type": "item",
|
|
174
|
+
"label": "First item",
|
|
175
|
+
"bind": "first-item"
|
|
176
|
+
},
|
|
177
|
+
...
|
|
178
|
+
]
|
|
179
|
+
}
|
|
180
|
+
```
|
|
166
181
|
|
|
167
|
-
|
|
182
|
+
- Submit
|
|
168
183
|
|
|
169
184
|
```json
|
|
170
185
|
{
|
|
171
|
-
"type": "input
|
|
186
|
+
"type": "input",
|
|
187
|
+
"subtype": "submit",
|
|
172
188
|
"label": "Submit"
|
|
173
189
|
}
|
|
174
190
|
```
|
|
@@ -210,12 +226,24 @@ The `submit` input is a submit input.
|
|
|
210
226
|
|
|
211
227
|
The form component exposes the following CSS variables:
|
|
212
228
|
|
|
213
|
-
| Variable
|
|
214
|
-
|
|
|
215
|
-
|
|
|
216
|
-
|
|
|
217
|
-
|
|
|
218
|
-
|
|
|
219
|
-
|
|
|
220
|
-
|
|
|
221
|
-
|
|
|
229
|
+
| Variable | Description |
|
|
230
|
+
| ----------------------- | ----------------------------------------------------------------------------------------- |
|
|
231
|
+
| --tf-background | Background color for the input fields. |
|
|
232
|
+
| --tf-foreground | Color used for the `category` labels. |
|
|
233
|
+
| | |
|
|
234
|
+
| --tf-muted | Used for `switch` background when value is false. |
|
|
235
|
+
| --tf-muted-foreground | Color used for `placeholder` text (inputs) and description text. |
|
|
236
|
+
| | |
|
|
237
|
+
| --tf-primary | This color complements `primary-foreground`: `submit` button text |
|
|
238
|
+
| --tf-primary-foreground | This color is used for, `submit` background, `label` text and input value. |
|
|
239
|
+
| | |
|
|
240
|
+
| --tf-accent | The accent color is used for `switch`, `checkbox` and `radiogroup` inputs. |
|
|
241
|
+
| --tf-accent-foreground | This color complements `accent` to show contrast between elements: `checkbox` check icon. |
|
|
242
|
+
| | |
|
|
243
|
+
| --tf-destructive | This color is used for `error` messages and the asterisk to mark a required input. |
|
|
244
|
+
| --tf-input | This color is used by the borders of the inputs. |
|
|
245
|
+
| --tf-ring | This color highlights a focused input. |
|
|
246
|
+
| | |
|
|
247
|
+
| --tf-radius | This value is used for rounded corners of all inputs. |
|
|
248
|
+
| | |
|
|
249
|
+
| --tf-font | Font family for all the form. |
|
package/dev/index.css
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap');
|
|
2
|
+
|
|
3
|
+
@tailwind base;
|
|
4
|
+
@tailwind components;
|
|
5
|
+
@tailwind utilities;
|
|
6
|
+
|
|
7
|
+
:root {
|
|
8
|
+
--tf-background: 0 0% 100%;
|
|
9
|
+
--tf-foreground: 222.2 47.4% 11.2%;
|
|
10
|
+
|
|
11
|
+
--tf-muted: 210 40% 96.1%;
|
|
12
|
+
--tf-muted-foreground: 215.4 16.3% 46.9%;
|
|
13
|
+
|
|
14
|
+
--tf-primary: 210 40% 98%;
|
|
15
|
+
--tf-primary-foreground: 222.2 47.4% 11.2%;
|
|
16
|
+
|
|
17
|
+
--tf-accent: 222.2 47.4% 11.2%;
|
|
18
|
+
--tf-accent-foreground: 210 40% 96.1%;
|
|
19
|
+
|
|
20
|
+
--tf-destructive: 0 100% 50%;
|
|
21
|
+
--tf-destructive-foreground: 210 40% 98%;
|
|
22
|
+
|
|
23
|
+
--tf-input: 214.3 31.8% 91.4%;
|
|
24
|
+
--tf-ring: 215 20.2% 65.1%;
|
|
25
|
+
|
|
26
|
+
--tf-radius: 0.5rem;
|
|
27
|
+
|
|
28
|
+
--tf-font: 'Roboto', sans-serif;
|
|
29
|
+
}
|
package/dev/main.tsx
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import install from '@twind/with-react';
|
|
3
|
+
import ReactDOM from 'react-dom/client';
|
|
4
|
+
|
|
5
|
+
import { Form } from '../lib';
|
|
6
|
+
import tw from '../twind.config';
|
|
7
|
+
|
|
8
|
+
import './index.css';
|
|
9
|
+
|
|
10
|
+
const config = [
|
|
11
|
+
{
|
|
12
|
+
type: 'category',
|
|
13
|
+
props: {
|
|
14
|
+
label: 'Category 1st',
|
|
15
|
+
},
|
|
16
|
+
children: [
|
|
17
|
+
{
|
|
18
|
+
type: 'input',
|
|
19
|
+
props: {
|
|
20
|
+
subtype: 'toggle',
|
|
21
|
+
label: 'Required',
|
|
22
|
+
bind: 'required',
|
|
23
|
+
options: {
|
|
24
|
+
description: 'This field is required',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
type: 'category',
|
|
32
|
+
props: {
|
|
33
|
+
label: 'Category 2nd',
|
|
34
|
+
},
|
|
35
|
+
children: [
|
|
36
|
+
{
|
|
37
|
+
type: 'input',
|
|
38
|
+
props: {
|
|
39
|
+
subtype: 'simple',
|
|
40
|
+
label: 'Email',
|
|
41
|
+
bind: 'email',
|
|
42
|
+
options: {
|
|
43
|
+
description: 'This field is required',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
type: 'input',
|
|
49
|
+
props: {
|
|
50
|
+
subtype: 'radiogroup',
|
|
51
|
+
label: 'Radio Group',
|
|
52
|
+
bind: 'radiogroup',
|
|
53
|
+
options: {
|
|
54
|
+
description: 'This field is required',
|
|
55
|
+
error: 'This field is required',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
children: [
|
|
59
|
+
{
|
|
60
|
+
type: 'item',
|
|
61
|
+
props: {
|
|
62
|
+
label: 'Checkbox',
|
|
63
|
+
bind: 'checkbox',
|
|
64
|
+
options: {
|
|
65
|
+
description: 'This field is required',
|
|
66
|
+
error: 'This field is required',
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
type: 'item',
|
|
72
|
+
props: {
|
|
73
|
+
label: 'Mote',
|
|
74
|
+
bind: 'mote',
|
|
75
|
+
options: {
|
|
76
|
+
description: 'This field is required',
|
|
77
|
+
error: 'This field is required',
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
type: 'category',
|
|
87
|
+
props: {
|
|
88
|
+
label: 'Category 3rd',
|
|
89
|
+
},
|
|
90
|
+
children: [
|
|
91
|
+
{
|
|
92
|
+
type: 'input',
|
|
93
|
+
props: {
|
|
94
|
+
subtype: 'file',
|
|
95
|
+
label: 'File',
|
|
96
|
+
bind: 'file',
|
|
97
|
+
options: {
|
|
98
|
+
description: 'This field is required',
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
type: 'category',
|
|
106
|
+
props: {
|
|
107
|
+
label: 'Category 4th',
|
|
108
|
+
},
|
|
109
|
+
children: [
|
|
110
|
+
{
|
|
111
|
+
type: 'input',
|
|
112
|
+
props: {
|
|
113
|
+
subtype: 'textarea',
|
|
114
|
+
label: 'Textarea',
|
|
115
|
+
bind: 'textarea',
|
|
116
|
+
options: {
|
|
117
|
+
description: 'This field is required',
|
|
118
|
+
error: 'This field is required',
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
type: 'input',
|
|
124
|
+
props: {
|
|
125
|
+
subtype: 'checkbox',
|
|
126
|
+
label: 'Checkbox',
|
|
127
|
+
bind: 'checkbox',
|
|
128
|
+
options: {
|
|
129
|
+
description: 'This field is required',
|
|
130
|
+
error: 'This field is required',
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
type: 'input:submit',
|
|
138
|
+
props: {
|
|
139
|
+
label: 'Submit',
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
] satisfies React.ComponentProps<typeof Form>['config'];
|
|
143
|
+
|
|
144
|
+
const options = {
|
|
145
|
+
variant: 'beta',
|
|
146
|
+
resetOnSubmit: true,
|
|
147
|
+
} as const;
|
|
148
|
+
|
|
149
|
+
const App = () => {
|
|
150
|
+
return (
|
|
151
|
+
<div className='mx-auto max-w-lg bg-background p-8'>
|
|
152
|
+
<Form config={config} options={options} />
|
|
153
|
+
</div>
|
|
154
|
+
);
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
install(tw);
|
|
158
|
+
|
|
159
|
+
ReactDOM.createRoot(document.getElementById('root')!).render(
|
|
160
|
+
<React.StrictMode>
|
|
161
|
+
<App />
|
|
162
|
+
</React.StrictMode>,
|
|
163
|
+
);
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { TVConfig } from 'tailwind-variants/dist/config.js';
|
|
2
|
+
import { TVReturnType, VariantProps } from 'tailwind-variants';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
declare const buttonVariants: TVReturnType<{
|
|
5
|
+
variant: {
|
|
6
|
+
default: string;
|
|
7
|
+
};
|
|
8
|
+
size: {
|
|
9
|
+
default: string;
|
|
10
|
+
sm: string;
|
|
11
|
+
lg: string;
|
|
12
|
+
};
|
|
13
|
+
}, undefined, string[], TVConfig<{
|
|
14
|
+
variant: {
|
|
15
|
+
default: string;
|
|
16
|
+
};
|
|
17
|
+
size: {
|
|
18
|
+
default: string;
|
|
19
|
+
sm: string;
|
|
20
|
+
lg: string;
|
|
21
|
+
};
|
|
22
|
+
}, {
|
|
23
|
+
variant: {
|
|
24
|
+
default: string;
|
|
25
|
+
};
|
|
26
|
+
size: {
|
|
27
|
+
default: string;
|
|
28
|
+
sm: string;
|
|
29
|
+
lg: string;
|
|
30
|
+
};
|
|
31
|
+
}>, {
|
|
32
|
+
variant: {
|
|
33
|
+
default: string;
|
|
34
|
+
};
|
|
35
|
+
size: {
|
|
36
|
+
default: string;
|
|
37
|
+
sm: string;
|
|
38
|
+
lg: string;
|
|
39
|
+
};
|
|
40
|
+
}, undefined, TVReturnType<{
|
|
41
|
+
variant: {
|
|
42
|
+
default: string;
|
|
43
|
+
};
|
|
44
|
+
size: {
|
|
45
|
+
default: string;
|
|
46
|
+
sm: string;
|
|
47
|
+
lg: string;
|
|
48
|
+
};
|
|
49
|
+
}, undefined, string[], TVConfig<{
|
|
50
|
+
variant: {
|
|
51
|
+
default: string;
|
|
52
|
+
};
|
|
53
|
+
size: {
|
|
54
|
+
default: string;
|
|
55
|
+
sm: string;
|
|
56
|
+
lg: string;
|
|
57
|
+
};
|
|
58
|
+
}, {
|
|
59
|
+
variant: {
|
|
60
|
+
default: string;
|
|
61
|
+
};
|
|
62
|
+
size: {
|
|
63
|
+
default: string;
|
|
64
|
+
sm: string;
|
|
65
|
+
lg: string;
|
|
66
|
+
};
|
|
67
|
+
}>, unknown, unknown, undefined>>;
|
|
68
|
+
export type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & VariantProps<typeof buttonVariants> & {
|
|
69
|
+
asChild?: boolean;
|
|
70
|
+
};
|
|
71
|
+
declare const Button: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & VariantProps<TVReturnType<{
|
|
72
|
+
variant: {
|
|
73
|
+
default: string;
|
|
74
|
+
};
|
|
75
|
+
size: {
|
|
76
|
+
default: string;
|
|
77
|
+
sm: string;
|
|
78
|
+
lg: string;
|
|
79
|
+
};
|
|
80
|
+
}, undefined, string[], TVConfig<{
|
|
81
|
+
variant: {
|
|
82
|
+
default: string;
|
|
83
|
+
};
|
|
84
|
+
size: {
|
|
85
|
+
default: string;
|
|
86
|
+
sm: string;
|
|
87
|
+
lg: string;
|
|
88
|
+
};
|
|
89
|
+
}, {
|
|
90
|
+
variant: {
|
|
91
|
+
default: string;
|
|
92
|
+
};
|
|
93
|
+
size: {
|
|
94
|
+
default: string;
|
|
95
|
+
sm: string;
|
|
96
|
+
lg: string;
|
|
97
|
+
};
|
|
98
|
+
}>, {
|
|
99
|
+
variant: {
|
|
100
|
+
default: string;
|
|
101
|
+
};
|
|
102
|
+
size: {
|
|
103
|
+
default: string;
|
|
104
|
+
sm: string;
|
|
105
|
+
lg: string;
|
|
106
|
+
};
|
|
107
|
+
}, undefined, TVReturnType<{
|
|
108
|
+
variant: {
|
|
109
|
+
default: string;
|
|
110
|
+
};
|
|
111
|
+
size: {
|
|
112
|
+
default: string;
|
|
113
|
+
sm: string;
|
|
114
|
+
lg: string;
|
|
115
|
+
};
|
|
116
|
+
}, undefined, string[], TVConfig<{
|
|
117
|
+
variant: {
|
|
118
|
+
default: string;
|
|
119
|
+
};
|
|
120
|
+
size: {
|
|
121
|
+
default: string;
|
|
122
|
+
sm: string;
|
|
123
|
+
lg: string;
|
|
124
|
+
};
|
|
125
|
+
}, {
|
|
126
|
+
variant: {
|
|
127
|
+
default: string;
|
|
128
|
+
};
|
|
129
|
+
size: {
|
|
130
|
+
default: string;
|
|
131
|
+
sm: string;
|
|
132
|
+
lg: string;
|
|
133
|
+
};
|
|
134
|
+
}>, unknown, unknown, undefined>>> & {
|
|
135
|
+
asChild?: boolean | undefined;
|
|
136
|
+
} & React.RefAttributes<HTMLButtonElement>>;
|
|
137
|
+
export { Button, buttonVariants };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
3
|
+
declare const Checkbox: React.ForwardRefExoticComponent<Omit<CheckboxPrimitive.CheckboxProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
4
|
+
export { Checkbox };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SlotProps } from '@radix-ui/react-slot';
|
|
2
|
+
import { JSX } from 'react/jsx-runtime';
|
|
3
|
+
import type * as LabelPrimitive from '@radix-ui/react-label';
|
|
4
|
+
import { FormProviderProps, FieldError, ControllerProps, FieldPath, FieldValues } from 'react-hook-form';
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
declare const Form: <TFieldValues extends FieldValues, TContext = any, TTransformedValues extends FieldValues | undefined = undefined>(props: FormProviderProps<TFieldValues, TContext, TTransformedValues>) => React.JSX.Element;
|
|
7
|
+
declare const FormField: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ ...props }: ControllerProps<TFieldValues, TName>) => JSX.Element;
|
|
8
|
+
declare const useFormField: () => {
|
|
9
|
+
invalid: boolean;
|
|
10
|
+
isDirty: boolean;
|
|
11
|
+
isTouched: boolean;
|
|
12
|
+
error?: FieldError | undefined;
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
formItemId: string;
|
|
16
|
+
formDescriptionId: string;
|
|
17
|
+
formMessageId: string;
|
|
18
|
+
};
|
|
19
|
+
declare const FormItem: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
20
|
+
declare const FormLabel: React.ForwardRefExoticComponent<Omit<LabelPrimitive.LabelProps & React.RefAttributes<HTMLLabelElement>, "ref"> & React.RefAttributes<HTMLLabelElement>>;
|
|
21
|
+
declare const FormControl: React.ForwardRefExoticComponent<Omit<SlotProps & React.RefAttributes<HTMLElement>, "ref"> & React.RefAttributes<HTMLElement>>;
|
|
22
|
+
declare const FormDescription: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>>;
|
|
23
|
+
declare const FormMessage: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>>;
|
|
24
|
+
export { useFormField, Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField, };
|