()
| 203 | } |
| 204 | |
| 205 | export function HTMLFormExample() { |
| 206 | let formRef: HTMLFormElement | undefined; |
| 207 | |
| 208 | const onSubmit = (e: SubmitEvent) => { |
| 209 | e.preventDefault(); |
| 210 | e.stopPropagation(); |
| 211 | |
| 212 | const formData = new FormData(formRef); |
| 213 | |
| 214 | alert(JSON.stringify(Object.fromEntries(formData), null, 2)); |
| 215 | }; |
| 216 | |
| 217 | return ( |
| 218 | <form |
| 219 | ref={formRef} |
| 220 | onSubmit={onSubmit} |
| 221 | class="flex flex-col items-center space-y-6" |
| 222 | > |
| 223 | <Combobox |
| 224 | name="fruit" |
| 225 | options={ALL_STRING_OPTIONS} |
| 226 | placeholder="Search a fruit…" |
| 227 | itemComponent={(props) => ( |
| 228 | <Combobox.Item item={props.item} class={style.combobox__item}> |
| 229 | <Combobox.ItemLabel>{props.item.rawValue}</Combobox.ItemLabel> |
| 230 | <Combobox.ItemIndicator class={style["combobox__item-indicator"]}> |
| 231 | <CheckIcon /> |
| 232 | </Combobox.ItemIndicator> |
| 233 | </Combobox.Item> |
| 234 | )} |
| 235 | > |
| 236 | <Combobox.HiddenSelect /> |
| 237 | <Combobox.Control class={style.combobox__control} aria-label="Fruit"> |
| 238 | <Combobox.Input class={style.combobox__input} /> |
| 239 | <Combobox.Trigger class={style.combobox__trigger}> |
| 240 | <Combobox.Icon class={style.combobox__icon}> |
| 241 | <CaretSortIcon /> |
| 242 | </Combobox.Icon> |
| 243 | </Combobox.Trigger> |
| 244 | </Combobox.Control> |
| 245 | <Combobox.ErrorMessage class={style["combobox__error-message"]}> |
| 246 | Hmm, I prefer apples. |
| 247 | </Combobox.ErrorMessage> |
| 248 | <Combobox.Portal> |
| 249 | <Combobox.Content class={style.combobox__content}> |
| 250 | <Combobox.Listbox class={style.combobox__listbox} /> |
| 251 | </Combobox.Content> |
| 252 | </Combobox.Portal> |
| 253 | </Combobox> |
| 254 | <div class="flex space-x-2"> |
| 255 | <button type="reset" class="kb-button"> |
| 256 | Reset |
| 257 | </button> |
| 258 | <button type="button" class="kb-button-primary"> |
| 259 | Submit |
| 260 | </button> |
| 261 | </div> |
| 262 | </form> |
nothing calls this directly
no outgoing calls
no test coverage detected