import type { VariantProps } from 'class-variance-authority'; import { inputRootVariants } from "@consensys/ds3/src/components/input/styles"; // Extract actual types from the input component type InputVariant = NonNullable['variant']>; type InputColor = NonNullable['color']>; type InputSize = NonNullable['size']>; // Get the actual variant, color, and size values from the component const variants: InputVariant[] = ['soft', 'outline', 'underline', 'ghost']; const colors: InputColor[] = ['neutral', 'primary', 'secondary', 'error', 'warning', 'success']; const sizes: InputSize[] = ['sm', 'md', 'lg']; // Helper function to generate JSX for a single input const generateInputJSX = (variant: InputVariant, color?: InputColor, size?: InputSize, props: any = {}) => { const colorProp = color && color !== 'neutral' ? ` color="${color}"` : ''; const sizeProp = size && size !== 'md' ? ` size="${size}"` : ''; const propsStr = Object.entries(props).map(([key, value]) => ` ${key}="${value}"`).join(''); return ``; }; // Helper function to generate JSX for multiline input const generateMultilineInputJSX = (variant: InputVariant, color?: InputColor, props: any = {}) => { const colorProp = color && color !== 'neutral' ? ` color="${color}"` : ''; const propsStr = Object.entries(props).map(([key, value]) => ` ${key}="${value}"`).join(''); return ``; }; // Helper function to generate JSX for input with icon const generateInputWithIconJSX = (variant: InputVariant, iconPosition: 'start' | 'end' | 'both', color?: InputColor, size?: InputSize, props: any = {}) => { const colorProp = color && color !== 'neutral' ? ` color="${color}"` : ''; const sizeProp = size && size !== 'md' ? ` size="${size}"` : ''; const propsStr = Object.entries(props).map(([key, value]) => ` ${key}="${value}"`).join(''); let iconJSX = ''; if (iconPosition === 'start' || iconPosition === 'both') { iconJSX += ` \n`; } iconJSX += ` \n`; if (iconPosition === 'end' || iconPosition === 'both') { iconJSX += ` \n`; } return ` ${iconJSX}`; }; // Helper function to generate JSX for input with text const generateInputWithTextJSX = (variant: InputVariant, textPosition: 'start' | 'end' | 'both', color?: InputColor, text = '*') => { const colorProp = color && color !== 'neutral' ? ` color="${color}"` : ''; const placeholder = `placeholder="${variant}"`; let textJSX = ''; if (textPosition === 'start' || textPosition === 'both') { textJSX += ` ${text}\n`; } textJSX += ` \n`; if (textPosition === 'end' || textPosition === 'both') { textJSX += ` ${text}\n`; } return ` ${textJSX}`; }; // Helper function to generate JSX for input with size const generateInputWithSizeJSX = (variant: InputVariant, size: InputSize, color?: InputColor) => { const colorProp = color && color !== 'neutral' ? ` color="${color}"` : ''; const placeholder = `placeholder="${variant}"`; return ` * `; }; // Helper function to generate common input examples const generateCommonInputJSX = (name: string, variant: InputVariant, color?: InputColor) => { const colorProp = color && color !== 'neutral' ? ` color="${color}"` : ''; const examples: { [key: string]: string } = { 'Search Input': ` `, 'Password Input': ` `, 'Email Input': ` `, 'Currency Input': ` $ `, 'Username Input': ` @ `, 'Measurement Input': ` cm `, 'Phone Input': ` +1 ` }; return examples[name] || ''; }; export const inputExamples = { "variants": { name: "Variants", jsx: ` ${variants.map(variant => ` ${generateInputJSX(variant, undefined, undefined, { placeholder: variant.charAt(0).toUpperCase() + variant.slice(1) })}`).join('\n')} ` }, "colors": { name: "Colors", jsx: ` ${colors.map(color => ` ${color.charAt(0).toUpperCase() + color.slice(1)} ${variants.map(variant => ` ${generateInputJSX(variant, color, undefined, { placeholder: variant.charAt(0).toUpperCase() + variant.slice(1) })}`).join('\n')} `).join('\n')} ` }, "accent-colors": { name: "Accent Colors", jsx: ` ` }, "sizes": { name: "Sizes", jsx: ` ${sizes.map(size => ` ${size.charAt(0).toUpperCase() + size.slice(1)} ${variants.map((variant, index) => ` ${generateInputJSX(variant, colors[index], size, { placeholder: variant.charAt(0).toUpperCase() + variant.slice(1) })}`).join('\n')} `).join('\n')} ` }, "icons": { name: "Icons", jsx: ` Prefix ${variants.map((variant, index) => ` ${generateInputWithIconJSX(variant, 'start', colors[index], undefined, { placeholder: variant.charAt(0).toUpperCase() + variant.slice(1) })}`).join('\n')} Suffix ${variants.map((variant, index) => ` ${generateInputWithIconJSX(variant, 'end', colors[index], undefined, { placeholder: variant.charAt(0).toUpperCase() + variant.slice(1) })}`).join('\n')} Both ${variants.map((variant, index) => ` ${generateInputWithIconJSX(variant, 'both', colors[index], undefined, { placeholder: variant.charAt(0).toUpperCase() + variant.slice(1) })}`).join('\n')} ` }, "multiline": { name: "Multiline Input", jsx: ` ${variants.map((variant, index) => ` ${variant.charAt(0).toUpperCase() + variant.slice(1)} ${colors.map(color => ` ${generateMultilineInputJSX(variant, color, { placeholder: variant.charAt(0).toUpperCase() + variant.slice(1) })}`).join('\n')} `).join('\n')} ` }, "loading": { name: "Loading", jsx: ` ` }, "disabled": { name: "Disabled", jsx: ` Regular Inputs ${variants.map((variant, index) => ` `).join('\n')} Multiline Inputs ${variants.map((variant, index) => ` `).join('\n')} ` } };