'use client'; import { useMemo } from 'react'; import { Calendar, Clock, Mail, Search } from 'lucide-react'; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from '@kit/ui/card'; import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, } from '@kit/ui/input-group'; import { Kbd, KbdGroup } from '@kit/ui/kbd'; import { Label } from '@kit/ui/label'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '@kit/ui/select'; import { Separator } from '@kit/ui/separator'; import { Switch } from '@kit/ui/switch'; import { formatCodeBlock, generatePropsString, useStoryControls, } from '../lib/story-utils'; import { ComponentStoryLayout } from './story-layout'; import { SimpleStorySelect } from './story-select'; interface InputGroupControls { prefixAlign: 'inline-start' | 'inline-end' | 'block-start' | 'block-end'; showPrefix: boolean; showSuffix: boolean; showKeyboardHint: boolean; showPrimaryAction: boolean; useTextarea: boolean; } const alignmentOptions = [ { value: 'inline-start', label: 'Inline Start', description: 'Display prefix before the input', }, { value: 'inline-end', label: 'Inline End', description: 'Display prefix after the input', }, { value: 'block-start', label: 'Block Start', description: 'Stack prefix above the control', }, { value: 'block-end', label: 'Block End', description: 'Stack prefix below the control', }, ] as const; export function InputGroupStory() { const { controls, updateControl } = useStoryControls({ prefixAlign: 'inline-start', showPrefix: true, showSuffix: true, showKeyboardHint: true, showPrimaryAction: true, useTextarea: false, }); const inputGroupPropsString = useMemo(() => generatePropsString({}, {}), []); const generatedCode = useMemo(() => { const lines: string[] = []; lines.push(``); if (controls.showPrefix) { lines.push( ` `, ` `, ` `, ` Search`, ' ', ' ', ); } if (controls.useTextarea) { lines.push( ' ', ); } else { lines.push( ' ', ); } if (controls.showKeyboardHint) { lines.push( ' ', ' ', ' ', ' K', ' ', ' ', ); } if (controls.showSuffix) { lines.push( ' ', ' ', ' ', ' Recent', ' ', ' ', ); } if (controls.showPrimaryAction) { lines.push( ' ', ' Search', ' ', ); } lines.push(''); return formatCodeBlock(lines.join('\n'), [ "import { Calendar, Clock, Mail, Search } from 'lucide-react';", `import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea } from '@kit/ui/input-group';`, "import { Kbd, KbdGroup } from '@kit/ui/kbd';", "import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@kit/ui/select';", ]); }, [controls, inputGroupPropsString]); const preview = (
{controls.showPrefix && ( Search )} {controls.useTextarea ? ( ) : ( )} {controls.showKeyboardHint && ( K )} {controls.showSuffix && ( Recent )} {controls.showPrimaryAction && ( Search )} Invite Send invite Availability window
); const controlsPanel = ( <>
updateControl('prefixAlign', value)} options={alignmentOptions} />
updateControl('showPrefix', checked)} />
updateControl('showSuffix', checked)} />
updateControl('showKeyboardHint', checked) } />
updateControl('showPrimaryAction', checked) } />
updateControl('useTextarea', checked)} />
); const examples = (
Search with hotkey Combine keyboard shortcuts and actions within the group wrapper. Quick search K Comment composer Switch to a textarea while keeping prefixes and suffixes aligned. Comment Post
); return ( ); } export default InputGroupStory;