()
| 208 | } |
| 209 | |
| 210 | export function HTMLFormExample() { |
| 211 | let formRef: HTMLFormElement | undefined; |
| 212 | |
| 213 | const onSubmit = (e: SubmitEvent) => { |
| 214 | e.preventDefault(); |
| 215 | e.stopPropagation(); |
| 216 | |
| 217 | const formData = new FormData(formRef); |
| 218 | |
| 219 | alert(JSON.stringify(Object.fromEntries(formData), null, 2)); |
| 220 | }; |
| 221 | |
| 222 | return ( |
| 223 | <form |
| 224 | ref={formRef} |
| 225 | onSubmit={onSubmit} |
| 226 | class="flex flex-col items-center space-y-6" |
| 227 | > |
| 228 | <SegmentedControl |
| 229 | class={style["segmented-control"]} |
| 230 | name="favorite-fruit" |
| 231 | defaultValue="Orange" |
| 232 | > |
| 233 | <SegmentedControl.Label class={style["segmented-control__label"]}> |
| 234 | Favorite fruit |
| 235 | </SegmentedControl.Label> |
| 236 | <div class={style["segmented-control__wrapper"]} role="presentation"> |
| 237 | <SegmentedControl.Indicator |
| 238 | class={style["segmented-control__indicator"]} |
| 239 | /> |
| 240 | |
| 241 | <div class={style["segmented-control__items"]} role="presentation"> |
| 242 | <For each={["Apple", "Orange", "Watermelon"]}> |
| 243 | {(fruit) => ( |
| 244 | <SegmentedControl.Item |
| 245 | value={fruit} |
| 246 | class={style["segmented-control__item"]} |
| 247 | > |
| 248 | <SegmentedControl.ItemInput |
| 249 | class={style["segmented-control__item-input"]} |
| 250 | /> |
| 251 | <SegmentedControl.ItemLabel |
| 252 | class={style["segmented-control__item-label"]} |
| 253 | > |
| 254 | {fruit} |
| 255 | </SegmentedControl.ItemLabel> |
| 256 | </SegmentedControl.Item> |
| 257 | )} |
| 258 | </For> |
| 259 | </div> |
| 260 | </div> |
| 261 | </SegmentedControl> |
| 262 | <div class="flex space-x-2"> |
| 263 | <button type="reset" class="kb-button"> |
| 264 | Reset |
| 265 | </button> |
| 266 | <button type="submit" class="kb-button-primary"> |
| 267 | Submit |
nothing calls this directly
no outgoing calls
no test coverage detected