()
| 104 | } |
| 105 | |
| 106 | export function HTMLFormExample() { |
| 107 | let formRef: HTMLFormElement | undefined; |
| 108 | |
| 109 | const onSubmit = (e: SubmitEvent) => { |
| 110 | e.preventDefault(); |
| 111 | e.stopPropagation(); |
| 112 | |
| 113 | const formData = new FormData(formRef); |
| 114 | |
| 115 | alert(JSON.stringify(Object.fromEntries(formData), null, 2)); |
| 116 | }; |
| 117 | |
| 118 | return ( |
| 119 | <form |
| 120 | ref={formRef} |
| 121 | onSubmit={onSubmit} |
| 122 | class="flex flex-col items-center space-y-6" |
| 123 | > |
| 124 | <Checkbox class={style.checkbox} name="newsletter" value="subscribe"> |
| 125 | <Checkbox.Input class={style.checkbox__input} /> |
| 126 | <Checkbox.Control class={style.checkbox__control}> |
| 127 | <Checkbox.Indicator> |
| 128 | <CheckIcon /> |
| 129 | </Checkbox.Indicator> |
| 130 | </Checkbox.Control> |
| 131 | <Checkbox.Label class={style.checkbox__label}>Subscribe</Checkbox.Label> |
| 132 | </Checkbox> |
| 133 | <div class="flex space-x-2"> |
| 134 | <button type="reset" class="kb-button"> |
| 135 | Reset |
| 136 | </button> |
| 137 | <button type="submit" class="kb-button-primary"> |
| 138 | Submit |
| 139 | </button> |
| 140 | </div> |
| 141 | </form> |
| 142 | ); |
| 143 | } |
nothing calls this directly
no outgoing calls
no test coverage detected