@@ -2,7 +2,7 @@ import React from "react";
22import { useForm } from "./useForm" ;
33import { Card } from "../card/Card" ;
44import { Button } from "../button/Button" ;
5- import { IconKey , IconLogin , IconMail } from "@tabler/icons-react" ;
5+ import { IconChevronDown , IconKey , IconLogin , IconMail , IconVariable , IconX } from "@tabler/icons-react" ;
66import { Text } from "../text/Text" ;
77import { PasswordInput , passwordValidation } from "./PasswordInput" ;
88import { TextInput } from "./TextInput" ;
@@ -14,6 +14,18 @@ import {CheckboxInput} from "./CheckboxInput";
1414import { RadioGroup } from "./RadioGroup" ;
1515import { RadioInput } from "./RadioInput" ;
1616import { TextAreaInput } from "./TextAreaInput" ;
17+ import {
18+ SelectContent ,
19+ SelectInput ,
20+ SelectItem ,
21+ SelectItemText ,
22+ SelectPortal ,
23+ SelectTrigger ,
24+ SelectValue ,
25+ SelectViewport
26+ } from "./SelectInput" ;
27+ import { Flex } from "../flex/Flex" ;
28+ import { ButtonGroup } from "../button-group/ButtonGroup" ;
1729
1830export default {
1931 title : "Form"
@@ -164,7 +176,6 @@ export const RadioExample = () => {
164176
165177}
166178
167-
168179export const Checkbox = ( ) => {
169180
170181 const [ inputs , validate ] = useForm ( {
@@ -208,7 +219,6 @@ export const Checkbox = () => {
208219
209220}
210221
211-
212222export const Switch = ( ) => {
213223
214224 const [ inputs , validate ] = useForm ( {
@@ -248,7 +258,6 @@ export const Switch = () => {
248258
249259}
250260
251-
252261export const PinInputExample = ( ) => {
253262
254263 const [ inputs , validate ] = useForm ( {
@@ -305,4 +314,70 @@ export const TextAreaExample = () => {
305314 leftType = { "placeholder" }
306315 />
307316 </ Card >
317+ }
318+
319+ export const Select = ( ) => {
320+
321+ const [ inputs , validate ] = useForm ( {
322+ initialValues : {
323+ select : undefined
324+ } ,
325+ validate : {
326+ select : ( value ) => {
327+ if ( ! value ) return "Please select an option"
328+ return null
329+ }
330+ } ,
331+ onSubmit : ( values ) => {
332+ console . log ( values )
333+ }
334+ } )
335+
336+ return < Card color = { "secondary" } w = { "400px" } >
337+ < SelectInput title = { "HTTP Method" }
338+ onValueChange = { ( ) => validate ( ) }
339+ description = { "You can choose between the standard http methods like GET, POST, etc." } right = {
340+ < ButtonGroup color = { "primary" } >
341+ < Button paddingSize = { "xxs" } >
342+ < IconVariable size = { 13 } />
343+ </ Button >
344+ < Button paddingSize = { "xxs" } >
345+ < IconX size = { 13 } />
346+ </ Button >
347+ </ ButtonGroup >
348+ } rightType = { "action" } { ...inputs . getInputProps ( "select" ) } >
349+ < SelectTrigger asChild >
350+ < Flex justify = { "space-between" } align = { "center" } >
351+ < SelectValue placeholder = { "Select..." } />
352+ < IconChevronDown size = { 13 } />
353+ </ Flex >
354+ </ SelectTrigger >
355+ < SelectPortal >
356+ < SelectContent position = { "item-aligned" } >
357+ < SelectViewport >
358+ < SelectItem value = { "1" } >
359+ < SelectItemText >
360+ Option 1
361+ </ SelectItemText >
362+ </ SelectItem >
363+ < SelectItem value = { "2" } >
364+ < SelectItemText >
365+ Option 2
366+ </ SelectItemText >
367+ </ SelectItem >
368+ < SelectItem value = { "3" } >
369+ < SelectItemText >
370+ Option 3
371+ </ SelectItemText >
372+ </ SelectItem >
373+ < SelectItem value = { "4" } >
374+ < SelectItemText >
375+ Option 4
376+ </ SelectItemText >
377+ </ SelectItem >
378+ </ SelectViewport >
379+ </ SelectContent >
380+ </ SelectPortal >
381+ </ SelectInput >
382+ </ Card >
308383}
0 commit comments