'use client'; import React, { forwardRef } from 'react'; import classNames from 'classnames'; import dynamic from 'next/dynamic'; import { CircleHelp } from 'lucide-react'; import { getDoc } from '@/docs'; import { openDoc } from '@/components/DocModal'; import { ConfigDoc, GroupedSelectOption, SelectOption } from '@/types'; const Select = dynamic(() => import('react-select'), { ssr: false }); const labelClasses = 'block text-xs mb-1 mt-2 text-gray-300'; const inputClasses = 'w-full text-sm px-3 py-1 bg-gray-950 dark:bg-gray-800 border border-gray-700 rounded-sm text-gray-100 placeholder:text-gray-500 focus:ring-2 focus:ring-gray-600 focus:border-transparent'; export interface InputProps { label?: string; docKey?: string | null; doc?: ConfigDoc | null; className?: string; placeholder?: string; required?: boolean; } export interface TextInputProps extends InputProps { value: string; onChange: (value: string) => void; type?: 'text' | 'password'; disabled?: boolean; suffix?: React.ReactNode; } export const TextInput = forwardRef((props: TextInputProps, ref) => { const { label, value, onChange, placeholder, required, disabled, type = 'text', className, docKey = null, suffix, } = props; let { doc } = props; if (!doc && docKey) { doc = getDoc(docKey); } return (
{label && ( )} {suffix ? (
{ if (!disabled) onChange(e.target.value); }} className="flex-1 min-w-0 bg-transparent text-sm px-3 py-1 text-gray-100 placeholder:text-gray-500 focus:outline-none" placeholder={placeholder} required={required} disabled={disabled} /> {suffix}
) : ( { if (!disabled) onChange(e.target.value); }} className={`${inputClasses} ${disabled ? 'opacity-30 cursor-not-allowed' : ''}`} placeholder={placeholder} required={required} disabled={disabled} /> )}
); }); // 👇 Helpful for debugging TextInput.displayName = 'TextInput'; export interface TextAreaInputProps extends InputProps { value: string; onChange: (value: string) => void; disabled?: boolean; rows?: number; } export const TextAreaInput = forwardRef((props: TextAreaInputProps, ref) => { const { label, value, onChange, placeholder, required, disabled, rows = 4, className, docKey = null } = props; let { doc } = props; if (!doc && docKey) { doc = getDoc(docKey); } return (
{label && ( )}