1
1
import { Story } from '@storybook/web-components' ;
2
2
import { html } from 'lit-html' ;
3
+ import '@umbraco-ui/uui-form/lib/index' ;
3
4
import '@umbraco-ui/uui-checkbox/lib' ;
4
5
import '@umbraco-ui/uui-slider/lib' ;
5
6
import '@umbraco-ui/uui-radio/lib' ;
6
7
import '@umbraco-ui/uui-toggle/lib' ;
7
8
import { UUIRadioGroupEvent } from '@umbraco-ui/uui-radio/lib/UUIRadioGroupEvent' ;
8
9
9
10
export default {
10
- id : 'form' ,
11
- title : 'Inputs/Form/Overview' ,
11
+ id : 'uui-form' ,
12
+ title : 'Inputs/Form/Form' ,
13
+ component : 'uui-form' ,
12
14
} ;
13
15
14
16
const _onRadioGroupChanged = ( e : UUIRadioGroupEvent ) => {
@@ -17,6 +19,7 @@ const _onRadioGroupChanged = (e: UUIRadioGroupEvent) => {
17
19
18
20
const _onSubmit = ( e : SubmitEvent ) => {
19
21
e . preventDefault ( ) ;
22
+ console . log ( 'SUBMIT' , e ) ;
20
23
21
24
const form = e . target as HTMLFormElement ;
22
25
const isValid = form . checkValidity ( ) ;
@@ -33,11 +36,8 @@ const _onSubmit = (e: SubmitEvent) => {
33
36
} ;
34
37
35
38
export const Overview : Story = ( ) => {
36
- return html `< form
37
- id ="MyForm "
38
- novalidate
39
- @submit ="${ _onSubmit } "
40
- style ="max-width: 800px; ">
39
+ return html ` < uui-form >
40
+ < form @submit ="${ _onSubmit } ">
41
41
< uui-form-layout-item >
42
42
< uui-label slot ="label "> Checkbox</ uui-label >
43
43
< uui-checkbox
@@ -120,63 +120,47 @@ export const Overview: Story = () => {
120
120
</ uui-button >
121
121
</ div >
122
122
</ form >
123
-
124
- <!-- Submit Handler
125
- const form = document.getElementById('MyForm');
126
-
127
- form.addEventHandler('submit', (e) => {
128
- e.preventDefault();
129
-
130
- const isValid = form.checkValidity();
131
-
132
- if (!isValid) {
133
- return;
134
- }
135
-
136
- const formData = new FormData(form);
137
-
138
- for (const value of formData.values()) {
139
- console.log(value);
140
- }
141
- });
142
- --> `;
123
+ </ uui-form > ` ;
143
124
} ;
144
125
145
126
/*
146
- <uui-form-layout-item>
147
- <uui-label slot="label">Native Checkbox</uui-label>
148
- <input
149
- name="nativeCheckbox"
150
- label="Native input text"
151
- type="checkbox"
152
- value="NativeCheckboxValue"
153
- placeholder="native text input"
154
- required />
155
- </uui-form-layout-item>
156
-
157
- <uui-form-layout-item>
158
- <uui-label slot="label">Native Input</uui-label>
159
- <input
160
- name="nativeInput"
161
- label="Native input text"
162
- type="text"
163
- default-value="default test value"
164
- value="test value"
165
- placeholder="native text input"
166
- required />
167
- </uui-form-layout-item>
168
-
169
- <uui-form-layout-item>
170
- <uui-label slot="label">Native Input</uui-label>
171
- <input
172
- style="width: 100%;"
173
- name="nativeInputNumber"
174
- label="Native input number"
175
- type="number"
176
- value=""
177
- placeholder="native number input"
178
- min="0"
179
- max="10"
180
- required />
181
- </uui-form-layout-item>
127
+
128
+
129
+ <uui-form-layout-item>
130
+ <uui-label slot="label">Native Checkbox</uui-label>
131
+ <input
132
+ name="nativeCheckbox"
133
+ label="Native input text"
134
+ type="checkbox"
135
+ value="NativeCheckboxValue"
136
+ placeholder="native text input"
137
+ required />
138
+ </uui-form-layout-item>
139
+
140
+ <uui-form-layout-item>
141
+ <uui-label slot="label">Native Input</uui-label>
142
+ <input
143
+ name="nativeInput"
144
+ label="Native input text"
145
+ type="text"
146
+ default-value="default test value"
147
+ value="test value"
148
+ placeholder="native text input"
149
+ required />
150
+ </uui-form-layout-item>
151
+
152
+ <uui-form-layout-item>
153
+ <uui-label slot="label">Native Input</uui-label>
154
+ <input
155
+ style="width: 100%;"
156
+ name="nativeInputNumber"
157
+ label="Native input number"
158
+ type="number"
159
+ value=""
160
+ placeholder="native number input"
161
+ min="0"
162
+ max="10"
163
+ required />
164
+ </uui-form-layout-item>
165
+
182
166
*/
0 commit comments