@twintag/twintag-form 0.2.0 → 0.3.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.
Files changed (49) hide show
  1. package/.turbo/turbo-build.log +35 -27
  2. package/CHANGELOG.md +6 -0
  3. package/README.md +90 -87
  4. package/dist/index.es.js +6786 -6803
  5. package/dist/index.umd.js +43 -43
  6. package/dist/lib/__stories__/Form.stories.d.ts +7 -0
  7. package/dist/lib/__stories__/Form.stories.d.ts.map +1 -0
  8. package/dist/lib/components/Input/checkbox.d.ts +2 -2
  9. package/dist/lib/components/Input/checkbox.d.ts.map +1 -1
  10. package/dist/lib/components/Input/file.d.ts +2 -2
  11. package/dist/lib/components/Input/file.d.ts.map +1 -1
  12. package/dist/lib/components/Input/index.d.ts +2 -0
  13. package/dist/lib/components/Input/index.d.ts.map +1 -1
  14. package/dist/lib/components/Input/simple.d.ts +2 -2
  15. package/dist/lib/components/Input/simple.d.ts.map +1 -1
  16. package/dist/lib/components/Input/submit.d.ts +2 -2
  17. package/dist/lib/components/Input/submit.d.ts.map +1 -1
  18. package/dist/lib/components/Input/textarea.d.ts +2 -2
  19. package/dist/lib/components/Input/textarea.d.ts.map +1 -1
  20. package/dist/lib/components/Input/toggle.d.ts +2 -2
  21. package/dist/lib/components/Input/toggle.d.ts.map +1 -1
  22. package/dist/lib/components/Label/index.d.ts +9 -0
  23. package/dist/lib/components/Label/index.d.ts.map +1 -0
  24. package/dist/lib/components/index.d.ts +5 -0
  25. package/dist/lib/components/index.d.ts.map +1 -0
  26. package/dist/lib/index.d.ts +6 -4
  27. package/dist/lib/index.d.ts.map +1 -1
  28. package/dist/lib/styles.d.ts +1 -0
  29. package/dist/lib/styles.d.ts.map +1 -1
  30. package/dist/twind.config.d.ts.map +1 -1
  31. package/dist/webcomponent.es.js +6779 -6793
  32. package/dist/webcomponent.umd.js +43 -43
  33. package/lib/__stories__/Form.stories.tsx +38 -0
  34. package/lib/components/Form/index.tsx +1 -1
  35. package/lib/components/Input/checkbox.tsx +7 -4
  36. package/lib/components/Input/file.tsx +12 -5
  37. package/lib/components/Input/index.tsx +2 -2
  38. package/lib/components/Input/simple.tsx +10 -11
  39. package/lib/components/Input/submit.tsx +7 -5
  40. package/lib/components/Input/textarea.tsx +14 -11
  41. package/lib/components/Input/toggle.tsx +23 -18
  42. package/lib/components/Label/index.tsx +22 -0
  43. package/lib/components/index.tsx +5 -0
  44. package/lib/index.tsx +3 -3
  45. package/lib/styles.ts +12 -8
  46. package/package.json +2 -4
  47. package/scripts/build.js +5 -0
  48. package/tsconfig.json +1 -1
  49. package/twind.config.ts +5 -0
@@ -1,50 +1,58 @@
1
1
 
2
- > @twintag/twintag-form@0.2.0 build /home/runner/work/twintag-templates/twintag-templates/packages/twintag-form
2
+ > @twintag/twintag-form@0.3.0 build /home/runner/work/twintag-templates/twintag-templates/packages/twintag-form
3
3
  > tsc && node ./scripts/build.js
4
4
 
5
- vite v4.1.0 building for production...
6
- vite v4.1.0 building for production...
5
+ vite v4.3.9 building for production...
6
+ vite v4.3.9 building for production...
7
7
  transforming...
8
8
  transforming...
9
- ✓ 679 modules transformed.
9
+ ✓ 681 modules transformed.
10
10
  [plugin:typescript] @rollup/plugin-typescript: Rollup 'sourcemap' option must be set to generate source maps.
11
- ✓ 660 modules transformed.
11
+ ✓ 662 modules transformed.
12
12
  [plugin:typescript] @rollup/plugin-typescript: Rollup 'sourcemap' option must be set to generate source maps.
13
13
  rendering chunks...
14
14
  computing gzip size...
15
15
  dist/lib/webcomponent.d.ts  0.05 kB
16
- dist/lib/components/Input/index.d.ts  0.24 kB
16
+ dist/lib/components/index.d.ts  0.15 kB
17
+ dist/lib/components/Input/index.d.ts  0.28 kB
18
+ dist/lib/__stories__/Form.stories.d.ts  0.28 kB
17
19
  dist/twind.config.d.ts  0.29 kB
18
20
  dist/lib/components/Form/index.d.ts  0.30 kB
19
- dist/lib/components/Input/submit.d.ts  0.37 kB
20
- dist/lib/components/Input/file.d.ts  0.37 kB
21
- dist/lib/components/Input/simple.d.ts  0.38 kB
22
- dist/lib/components/Input/toggle.d.ts  0.38 kB
23
- dist/lib/components/Input/textarea.d.ts  0.39 kB
24
- dist/lib/components/Input/checkbox.d.ts  0.39 kB
21
+ dist/lib/components/Label/index.d.ts  0.31 kB
22
+ dist/lib/components/Input/submit.d.ts  0.39 kB
23
+ dist/lib/components/Input/file.d.ts  0.40 kB
24
+ dist/lib/components/Input/simple.d.ts  0.41 kB
25
+ dist/lib/components/Input/toggle.d.ts  0.41 kB
26
+ dist/lib/components/Input/textarea.d.ts  0.41 kB
27
+ dist/lib/components/Input/checkbox.d.ts  0.42 kB
25
28
  dist/lib/components/Form/register.d.ts  0.42 kB
26
- dist/lib/index.d.ts  0.44 kB
27
29
  dist/lib/types/index.d.ts  0.45 kB
28
- dist/lib/styles.d.ts  2.87 kB
29
- dist/webcomponent.es.js 1,009.24 kB │ gzip: 240.07 kB
30
+ dist/lib/index.d.ts  0.46 kB
31
+ dist/lib/styles.d.ts  3.24 kB
32
+ dist/webcomponent.es.js 1,009.45 kB │ gzip: 240.03 kB
30
33
  [plugin:typescript] @rollup/plugin-typescript: Rollup 'sourcemap' option must be set to generate source maps.
31
34
  rendering chunks...
32
35
  computing gzip size...
33
- dist/index.es.js 892.99 kB │ gzip: 208.25 kB
36
+ dist/index.es.js 893.03 kB │ gzip: 208.16 kB
34
37
  [plugin:typescript] @rollup/plugin-typescript: Rollup 'sourcemap' option must be set to generate source maps.
35
38
  dist/lib/webcomponent.d.ts  0.05 kB
36
- dist/lib/components/Input/index.d.ts  0.24 kB
39
+ dist/lib/components/index.d.ts  0.15 kB
40
+ dist/lib/components/Input/index.d.ts  0.28 kB
41
+ dist/lib/__stories__/Form.stories.d.ts  0.28 kB
37
42
  dist/twind.config.d.ts  0.29 kB
38
43
  dist/lib/components/Form/index.d.ts  0.30 kB
39
- dist/lib/components/Input/submit.d.ts  0.37 kB
40
- dist/lib/components/Input/file.d.ts  0.37 kB
41
- dist/lib/components/Input/simple.d.ts  0.38 kB
42
- dist/lib/components/Input/toggle.d.ts  0.38 kB
43
- dist/lib/components/Input/textarea.d.ts  0.39 kB
44
- dist/lib/components/Input/checkbox.d.ts  0.39 kB
44
+ dist/lib/components/Label/index.d.ts  0.31 kB
45
+ dist/lib/components/Input/submit.d.ts  0.39 kB
46
+ dist/lib/components/Input/file.d.ts  0.40 kB
47
+ dist/lib/components/Input/simple.d.ts  0.41 kB
48
+ dist/lib/components/Input/toggle.d.ts  0.41 kB
49
+ dist/lib/components/Input/textarea.d.ts  0.41 kB
50
+ dist/lib/components/Input/checkbox.d.ts  0.42 kB
45
51
  dist/lib/components/Form/register.d.ts  0.42 kB
46
- dist/lib/index.d.ts  0.44 kB
47
52
  dist/lib/types/index.d.ts  0.45 kB
48
- dist/lib/styles.d.ts  2.87 kB
49
- dist/webcomponent.umd.js 622.14 kB │ gzip: 194.59 kB
50
- dist/index.umd.js 556.21 kB │ gzip: 172.27 kB
53
+ dist/lib/index.d.ts  0.46 kB
54
+ dist/lib/styles.d.ts  3.24 kB
55
+ dist/webcomponent.umd.js 622.35 kB │ gzip: 194.56 kB
56
+ ✓ built in 17.53s
57
+ dist/index.umd.js 556.28 kB │ gzip: 172.27 kB
58
+ ✓ built in 17.66s
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @twintag/twintag-form
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 41c444d: Enable CSS customization (custom properties).
8
+
3
9
  ## 0.2.0
4
10
 
5
11
  ### Minor Changes
package/README.md CHANGED
@@ -5,16 +5,16 @@
5
5
  - [Introduction](#introduction)
6
6
  - [Framework Agnostic](#framework-agnostic)
7
7
  - [Parameters](#parameters)
8
- - [Config](#config)
9
- - [Options](#options)
10
- - [Inputs](#inputs)
11
- - [Input Options](#input-options)
12
- - [Simple](#simple)
13
- - [Textarea](#textarea)
14
- - [File](#file)
15
- - [Checkbox](#checkbox)
16
- - [Toggle](#toggle)
17
- - [Submit](#submit)
8
+ - [Config](#config)
9
+ - [Options](#options)
10
+ - [Inputs](#inputs)
11
+ - [Input Options](#input-options)
12
+ - [Simple](#simple)
13
+ - [Textarea](#textarea)
14
+ - [File](#file)
15
+ - [Checkbox](#checkbox)
16
+ - [Toggle](#toggle)
17
+ - [Submit](#submit)
18
18
  - [Event Handling](#event-handling)
19
19
 
20
20
  ## **Introduction**
@@ -26,44 +26,44 @@ Twintag Form provides a web component that allows you to create a form based on
26
26
  Twintag Form exposes a web component that can be used in any framework or vanilla JS.
27
27
 
28
28
  ```html
29
- <twintag-form options='...' config='[...]'></twintag-form>
29
+ <twintag-form options="..." config="[...]"></twintag-form>
30
30
  ```
31
31
 
32
32
  ## **Parameters**
33
33
 
34
34
  The form component receives the following parameters:
35
35
 
36
- | Parameter | Type | Description |
37
- | --- | --- | --- |
38
- | `config` | `array` | Array that contains the form structure. |
39
- | `options` | `object` | Options to customize the form |
36
+ | Parameter | Type | Description |
37
+ | --------- | -------- | --------------------------------------- |
38
+ | `config` | `array` | Array that contains the form structure. |
39
+ | `options` | `object` | Options to customize the form |
40
40
 
41
41
  ### **Config**
42
42
 
43
43
  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:
44
44
 
45
- | Property | Type | Description |
46
- | --- | --- | --- |
47
- | `input:<subtype>` | `string` | Type of the input. |
48
- | `label` | `string` | Name of the form. |
49
- | `bind` | `string` | Unique identifier for the form. (Optional for `Submit` inputs) |
45
+ | Property | Type | Description |
46
+ | ----------------- | -------- | -------------------------------------------------------------- |
47
+ | `input:<subtype>` | `string` | Type of the input. |
48
+ | `label` | `string` | Name of the form. |
49
+ | `bind` | `string` | Unique identifier for the form. (Optional for `Submit` inputs) |
50
50
 
51
51
  ```json
52
52
  [
53
- {
54
- "type": "input:simple",
55
- "label": "Email",
56
- "bind": "email"
57
- },
58
- {
59
- "type": "input:textarea",
60
- "label": "Message",
61
- "bind": "message"
62
- },
63
- {
64
- "type": "input:submit",
65
- "label": "Submit"
66
- }
53
+ {
54
+ "type": "input:simple",
55
+ "label": "Email",
56
+ "bind": "email"
57
+ },
58
+ {
59
+ "type": "input:textarea",
60
+ "label": "Message",
61
+ "bind": "message"
62
+ },
63
+ {
64
+ "type": "input:submit",
65
+ "label": "Submit"
66
+ }
67
67
  ]
68
68
  ```
69
69
 
@@ -71,9 +71,9 @@ The `config` object contains the form structure. It is organized by the index of
71
71
 
72
72
  Twintag Form provides some options to customize the form:
73
73
 
74
- | Option | Type | Description |
75
- | --- | --- | --- |
76
- | `variant` | `alpha | beta` | Variant of the form. |
74
+ | Option | Type | Description |
75
+ | --------------- | --------- | ------------------------------------------------------------------------- | -------------------- |
76
+ | `variant` | `alpha | beta` | Variant of the form. |
77
77
  | `resetOnSubmit` | `boolean` | If `true`, the form will be reset after submitting. (`false` per default) |
78
78
 
79
79
  ### **Inputs**
@@ -82,22 +82,22 @@ Twintag Form provides some options to customize the form:
82
82
 
83
83
  Each input can be customized with the following options:
84
84
 
85
- | Option | Type | Description |
86
- | --- | --- | --- |
87
- | `variant` | `alpha | beta` | Variant of the input. |
88
- | `placeholder` | `string` | Placeholder of the input. |
85
+ | Option | Type | Description |
86
+ | --------------- | --------- | ------------------------------------------------------------ | --------------------- |
87
+ | `variant` | `alpha | beta` | Variant of the input. |
88
+ | `placeholder` | `string` | Placeholder of the input. |
89
89
  | `optionalField` | `boolean` | If `true`, the field will be optional. (`false` per default) |
90
90
 
91
91
  ```json
92
92
  {
93
- "type": "input:simple",
94
- "label": "Email",
95
- "bind": "email",
96
- "options": {
97
- "variant": "alpha",
98
- "placeholder": "Enter your email",
99
- "optionalField": true
100
- }
93
+ "type": "input:simple",
94
+ "label": "Email",
95
+ "bind": "email",
96
+ "options": {
97
+ "variant": "alpha",
98
+ "placeholder": "Enter your email",
99
+ "optionalField": true
100
+ }
101
101
  }
102
102
  ```
103
103
 
@@ -107,9 +107,9 @@ The `simple` input is a simple text input.
107
107
 
108
108
  ```json
109
109
  {
110
- "type": "input:simple",
111
- "label": "Email",
112
- "bind": "email"
110
+ "type": "input:simple",
111
+ "label": "Email",
112
+ "bind": "email"
113
113
  }
114
114
  ```
115
115
 
@@ -119,9 +119,9 @@ The `textarea` input is a textarea input.
119
119
 
120
120
  ```json
121
121
  {
122
- "type": "input:textarea",
123
- "label": "Message",
124
- "bind": "message"
122
+ "type": "input:textarea",
123
+ "label": "Message",
124
+ "bind": "message"
125
125
  }
126
126
  ```
127
127
 
@@ -131,9 +131,9 @@ The `file` input is a file input.
131
131
 
132
132
  ```json
133
133
  {
134
- "type": "input:file",
135
- "label": "File",
136
- "bind": "file"
134
+ "type": "input:file",
135
+ "label": "File",
136
+ "bind": "file"
137
137
  }
138
138
  ```
139
139
 
@@ -143,9 +143,9 @@ The `checkbox` input is a checkbox input.
143
143
 
144
144
  ```json
145
145
  {
146
- "type": "input:checkbox",
147
- "label": "Checkbox",
148
- "bind": "checkbox"
146
+ "type": "input:checkbox",
147
+ "label": "Checkbox",
148
+ "bind": "checkbox"
149
149
  }
150
150
  ```
151
151
 
@@ -155,9 +155,9 @@ The `toggle` input is a toggle input.
155
155
 
156
156
  ```json
157
157
  {
158
- "type": "input:toggle",
159
- "label": "Toggle",
160
- "bind": "toggle"
158
+ "type": "input:toggle",
159
+ "label": "Toggle",
160
+ "bind": "toggle"
161
161
  }
162
162
  ```
163
163
 
@@ -167,37 +167,40 @@ The `submit` input is a submit input.
167
167
 
168
168
  ```json
169
169
  {
170
- "type": "input:submit",
171
- "label": "Submit"
170
+ "type": "input:submit",
171
+ "label": "Submit"
172
172
  }
173
173
  ```
174
174
 
175
175
  ## **Event Handling**
176
176
 
177
177
  ```html
178
-
179
- <twintag-form id="yourform" options='{"variant":"beta","resetOnSubmit":true}' config='[{"type":"input:toggle","label":"Test","bind":"test","options":{"optionalField":true}},{"type":"input:submit","label":"Submit"}]'></twintag-form>
178
+ <twintag-form
179
+ id="yourform"
180
+ options='{"variant":"beta","resetOnSubmit":true}'
181
+ config='[{"type":"input:toggle","label":"Test","bind":"test","options":{"optionalField":true}},{"type":"input:submit","label":"Submit"}]'
182
+ ></twintag-form>
180
183
 
181
184
  <button id="btn">Submit</button>
182
185
 
183
186
  <script>
184
- const form = document.getElementById('yourform');
185
- const btn = document.getElementById('btn');
186
-
187
- // If there are no errors, the form will emit a custom event with the data on submit
188
- form.addEventListener('twintag-form-valid', (e) => {
189
- console.log(e.detail); // { test: true }
190
- });
191
-
192
- // If there are errors, the form will emit a custom event with the errors
193
- form.addEventListener('twintag-form-invalid', (e) => {
194
- console.log(e.detail); // { test: 'Test is required' }
195
- });
196
-
197
- // You can validate the form outside the component:
198
- btn.addEventListener('click', () => {
199
- const submitEvent = new Event('twintag-form-validate');
200
- form.shadowRoot.querySelector('form').dispatchEvent(submitEvent);
201
- });
187
+ const form = document.getElementById('yourform');
188
+ const btn = document.getElementById('btn');
189
+
190
+ // If there are no errors, the form will emit a custom event with the data on submit
191
+ form.addEventListener('twintag-form-valid', (e) => {
192
+ console.log(e.detail); // { test: true }
193
+ });
194
+
195
+ // If there are errors, the form will emit a custom event with the errors
196
+ form.addEventListener('twintag-form-invalid', (e) => {
197
+ console.log(e.detail); // { test: 'Test is required' }
198
+ });
199
+
200
+ // You can validate the form outside the component:
201
+ btn.addEventListener('click', () => {
202
+ const submitEvent = new Event('twintag-form-validate');
203
+ form.shadowRoot.querySelector('form').dispatchEvent(submitEvent);
204
+ });
202
205
  </script>
203
- ```
206
+ ```