()
| 182 | } |
| 183 | |
| 184 | export function HTMLFormExample() { |
| 185 | let formRef: HTMLFormElement | undefined; |
| 186 | |
| 187 | const onSubmit = (e: SubmitEvent) => { |
| 188 | e.preventDefault(); |
| 189 | e.stopPropagation(); |
| 190 | |
| 191 | const formData = new FormData(formRef); |
| 192 | |
| 193 | alert(JSON.stringify(Object.fromEntries(formData), null, 2)); |
| 194 | }; |
| 195 | |
| 196 | return ( |
| 197 | <form |
| 198 | ref={formRef} |
| 199 | onSubmit={onSubmit} |
| 200 | class="flex flex-col items-center space-y-6" |
| 201 | > |
| 202 | <Select |
| 203 | name="fruit" |
| 204 | options={STRING_OPTIONS} |
| 205 | placeholder="Select a fruit…" |
| 206 | itemComponent={(props) => ( |
| 207 | <Select.Item item={props.item} class={style.select__item}> |
| 208 | <Select.ItemLabel>{props.item.rawValue}</Select.ItemLabel> |
| 209 | <Select.ItemIndicator class={style["select__item-indicator"]}> |
| 210 | <CheckIcon /> |
| 211 | </Select.ItemIndicator> |
| 212 | </Select.Item> |
| 213 | )} |
| 214 | > |
| 215 | <Select.HiddenSelect /> |
| 216 | <Select.Trigger class={style.select__trigger} aria-label="Fruit"> |
| 217 | <Select.Value<string> class={style.select__value}> |
| 218 | {(state) => state.selectedOption()} |
| 219 | </Select.Value> |
| 220 | <Select.Icon class={style.select__icon}> |
| 221 | <CaretSortIcon /> |
| 222 | </Select.Icon> |
| 223 | </Select.Trigger> |
| 224 | <Select.Portal> |
| 225 | <Select.Content class={style.select__content}> |
| 226 | <Select.Listbox class={style.select__listbox} /> |
| 227 | </Select.Content> |
| 228 | </Select.Portal> |
| 229 | </Select> |
| 230 | <div class="flex space-x-2"> |
| 231 | <button type="reset" class="kb-button"> |
| 232 | Reset |
| 233 | </button> |
| 234 | <button type="button" class="kb-button-primary"> |
| 235 | Submit |
| 236 | </button> |
| 237 | </div> |
| 238 | </form> |
| 239 | ); |
| 240 | } |
| 241 |
nothing calls this directly
no outgoing calls
no test coverage detected