mirror of
https://github.com/supabase/supabase.git
synced 2026-10-07 18:35:07 +03:00
* Add lucide-react to docs (to make the autocomplete work). * Migrate the docs app icons. * Migrate the ui-patterns. * Remove the old icons from ui package. * Migrate the www app from react-feather icons. * Migrate all of studio icons. * Migrate the only component in design-system. * Fix an old import in ui package. Revert an import in docs app. * Fix some pages in www. * Remove unneeded files used in generation of icons. * Fix a prettier error. * Fix more issues in www. * Fix an issue in Log Date picker. * Replace all string sizes with number sizes because the icons grew in some cases. * Fix more imports in security page. * Fix an extra import. * Remove the size prop from all icons if they're in a button and they match the button size. * Minor fixes for docs and www. --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
93 lines
2.9 KiB
TypeScript
93 lines
2.9 KiB
TypeScript
import Link from 'next/link'
|
|
import { useState } from 'react'
|
|
import { Button, Input } from 'ui'
|
|
|
|
import type { ServerOption } from './Wrappers.types'
|
|
import { HelpCircle, Loader, Eye, EyeOff } from 'lucide-react'
|
|
|
|
interface InputFieldProps {
|
|
option: ServerOption
|
|
loading: boolean
|
|
error: any
|
|
}
|
|
|
|
const InputField = ({ option, loading, error }: InputFieldProps) => {
|
|
const [showHidden, setShowHidden] = useState(!option.secureEntry)
|
|
if (option.isTextArea) {
|
|
return (
|
|
<div className="text-area-text-sm text-area-resize-none">
|
|
<Input.TextArea
|
|
key={option.name}
|
|
rows={6}
|
|
error={error}
|
|
className="input-mono"
|
|
disabled={loading}
|
|
id={option.name}
|
|
name={option.name}
|
|
label={
|
|
<div className="flex items-center space-x-2">
|
|
<p>{option.label}</p>
|
|
{option.urlHelper !== undefined && (
|
|
<Link href={option.urlHelper} target="_blank" rel="noreferrer">
|
|
<HelpCircle
|
|
strokeWidth={2}
|
|
size={14}
|
|
className="text-foreground-light hover:text-foreground cursor-pointer transition"
|
|
/>
|
|
</Link>
|
|
)}
|
|
</div>
|
|
}
|
|
value={loading ? 'Fetching value from Vault...' : undefined}
|
|
defaultValue={option.defaultValue ?? ''}
|
|
required={option.required ?? false}
|
|
/>
|
|
</div>
|
|
)
|
|
} else {
|
|
return (
|
|
<Input
|
|
key={option.name}
|
|
id={option.name}
|
|
name={option.name}
|
|
label={
|
|
<div className="flex items-center space-x-2">
|
|
<p>{option.label}</p>
|
|
{option.urlHelper !== undefined && (
|
|
<Link href={option.urlHelper} target="_blank" rel="noreferrer">
|
|
<HelpCircle
|
|
strokeWidth={2}
|
|
size={14}
|
|
className="text-foreground-light hover:text-foreground cursor-pointer transition"
|
|
/>
|
|
</Link>
|
|
)}
|
|
</div>
|
|
}
|
|
defaultValue={option.defaultValue ?? ''}
|
|
error={error}
|
|
value={loading ? 'Fetching value from Vault...' : undefined}
|
|
type={!option.secureEntry || loading ? 'text' : showHidden ? 'text' : 'password'}
|
|
disabled={loading}
|
|
actions={
|
|
loading ? (
|
|
<div className="flex items-center justify-center mr-1">
|
|
<Button disabled type="default" icon={<Loader className="animate-spin" />} />
|
|
</div>
|
|
) : option.secureEntry ? (
|
|
<div className="flex items-center justify-center mr-1">
|
|
<Button
|
|
type="default"
|
|
icon={showHidden ? <Eye /> : <EyeOff />}
|
|
onClick={() => setShowHidden(!showHidden)}
|
|
/>
|
|
</div>
|
|
) : null
|
|
}
|
|
/>
|
|
)
|
|
}
|
|
}
|
|
|
|
export default InputField
|