Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

chore: migrate remaining old input usages (#45791)

Gildas Garciabcfc66628481
diff --git a/apps/studio/components/interfaces/Database/Triggers/EventTriggersList/EventTriggersList.tsx b/apps/studio/components/interfaces/Database/Triggers/EventTriggersList/EventTriggersList.tsx
index 5f78536a7ea..b275b18b842 100644
--- a/apps/studio/components/interfaces/Database/Triggers/EventTriggersList/EventTriggersList.tsx
+++ b/apps/studio/components/interfaces/Database/Triggers/EventTriggersList/EventTriggersList.tsx
@@ -3,7 +3,18 @@ import { DatabaseZap, Plus, Search } from 'lucide-react'
import { parseAsJson, parseAsString, useQueryState } from 'nuqs'
import { useMemo, useRef, useState } from 'react'
import { toast } from 'sonner'
-import { Button, Card, Input, Table, TableBody, TableHead, TableHeader, TableRow } from 'ui'
+import {
+ Button,
+ Card,
+ InputGroup,
+ InputGroupAddon,
+ InputGroupInput,
+ Table,
+ TableBody,
+ TableHead,
+ TableHeader,
+ TableRow,
+} from 'ui'
import { EmptyStatePresentational } from 'ui-patterns'
import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader'
@@ -181,16 +192,19 @@ export const EventTriggersList = () => {
<div className="space-y-4">
<div className="flex flex-col lg:flex-row lg:items-center justify-between gap-2 flex-wrap">
<div className="flex flex-col lg:flex-row lg:items-center gap-2 flex-wrap">
- <Input
- inputRef={searchInputRef}
- placeholder="Search for an event trigger"
- size="tiny"
- icon={<Search />}
- value={filterString}
- className="w-full lg:w-64"
- onChange={(e) => setFilterString(e.target.value)}
- onKeyDown={onSearchInputEscape(filterString, setFilterString)}
- />
+ <InputGroup className="w-full lg:w-52">
+ <InputGroupInput
+ ref={searchInputRef}
+ size="tiny"
+ placeholder="Search for a trigger"
+ value={filterString}
+ onChange={(e) => setFilterString(e.target.value)}
+ onKeyDown={onSearchInputEscape(filterString, setFilterString)}
+ />
+ <InputGroupAddon>
+ <Search />
+ </InputGroupAddon>
+ </InputGroup>
<ReportsSelectFilter
label="Owner"
options={ownerOptions.map((owner) => ({
diff --git a/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/ResetDbPassword.tsx b/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/ResetDbPassword.tsx
index 404cee75745..ae8f3d56825 100644
--- a/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/ResetDbPassword.tsx
+++ b/apps/studio/components/interfaces/Settings/Database/DatabaseSettings/ResetDbPassword.tsx
@@ -2,7 +2,9 @@ import { PermissionAction } from '@supabase/shared-types/out/constants'
import { useParams } from 'common'
import { useEffect, useState } from 'react'
import { toast } from 'sonner'
-import { Button, Card, CardContent, Input, Modal } from 'ui'
+import { Button, Card, CardContent, Modal } from 'ui'
+import { Input } from 'ui-patterns/DataInputs/Input'
+import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
import {
PageSection,
PageSectionContent,
@@ -142,14 +144,11 @@ const ResetDbPassword = ({ disabled = false }) => {
onCancel={() => setShowResetDbPass(false)}
>
<Modal.Content className="w-full space-y-8">
- <Input
- type="password"
- value={password}
- copy={password.length > 0}
- onChange={onDbPassChange}
+ <FormItemLayout
+ layout="vertical"
+ isReactForm={false}
error={passwordStrengthWarning}
- // @ts-ignore
- descriptionText={
+ description={
<PasswordStrengthBar
passwordStrengthScore={passwordStrengthScore as PasswordStrengthScore}
passwordStrengthMessage={passwordStrengthMessage}
@@ -157,7 +156,17 @@ const ResetDbPassword = ({ disabled = false }) => {
generateStrongPassword={generatePassword}
/>
}
- />
+ >
+ <Input
+ copy={password.length > 0}
+ aria-invalid={!!passwordStrengthWarning}
+ type="password"
+ placeholder="Type in a strong password"
+ value={password}
+ autoComplete="off"
+ onChange={onDbPassChange}
+ />
+ </FormItemLayout>
</Modal.Content>
<Modal.Separator />
<Modal.Content className="flex items-center justify-end space-x-2">
diff --git a/apps/studio/components/interfaces/Settings/Logs/LogsErrorRenderers/ResourcesExceededErrorRenderer.tsx b/apps/studio/components/interfaces/Settings/Logs/LogsErrorRenderers/ResourcesExceededErrorRenderer.tsx
index 5cae01cbb24..9f060183952 100644
--- a/apps/studio/components/interfaces/Settings/Logs/LogsErrorRenderers/ResourcesExceededErrorRenderer.tsx
+++ b/apps/studio/components/interfaces/Settings/Logs/LogsErrorRenderers/ResourcesExceededErrorRenderer.tsx
@@ -1,39 +1,62 @@
-import { Accordion, Input } from 'ui'
+import { useState } from 'react'
+import {
+ Accordion,
+ copyToClipboard,
+ InputGroup,
+ InputGroupAddon,
+ InputGroupButton,
+ InputGroupTextarea,
+} from 'ui'
import { ErrorRendererProps } from './DefaultErrorRenderer'
-const ResourcesExceededErrorRenderer: React.FC<ErrorRendererProps> = ({ error, isCustomQuery }) => (
- <div className="flex flex-col gap-2 text-foreground-light">
- <div className="flex flex-col gap-1 text-sm">
- <p>This query requires too much memory to be executed.</p>
- <p>
- {isCustomQuery
- ? 'Avoid selecting entire objects and instead select specific keys using dot notation.'
- : 'Avoid querying across a large datetime range.'}
- </p>
- {!isCustomQuery && <p>Please contact support if this error persists.</p>}
+const ResourcesExceededErrorRenderer: React.FC<ErrorRendererProps> = ({ error, isCustomQuery }) => {
+ const errorAsJson = JSON.stringify(error, null, 2)
+ const [copied, setCopied] = useState(false)
+ return (
+ <div className="flex flex-col gap-2 text-foreground-light">
+ <div className="flex flex-col gap-1 text-sm">
+ <p>This query requires too much memory to be executed.</p>
+ <p>
+ {isCustomQuery
+ ? 'Avoid selecting entire objects and instead select specific keys using dot notation.'
+ : 'Avoid querying across a large datetime range.'}
+ </p>
+ {!isCustomQuery && <p>Please contact support if this error persists.</p>}
+ </div>
+ <Accordion
+ className="text-sm"
+ justified={false}
+ openBehaviour="multiple"
+ type="default"
+ chevronAlign="left"
+ size="small"
+ iconPosition="left"
+ >
+ <Accordion.Item id="1" header="Full error message">
+ <InputGroup>
+ <InputGroupTextarea value={errorAsJson} className="font-mono" rows={5} />
+ <InputGroupAddon align="block-end">
+ <InputGroupButton
+ size="tiny"
+ type="default"
+ className="ml-auto"
+ onClick={() => {
+ copyToClipboard(errorAsJson)
+ setCopied(true)
+ setTimeout(() => {
+ setCopied(false)
+ }, 3000)
+ }}
+ >
+ {copied ? 'Copied' : 'Copy'}
+ </InputGroupButton>
+ </InputGroupAddon>
+ </InputGroup>
+ </Accordion.Item>
+ </Accordion>
</div>
- <Accordion
- className="text-sm"
- justified={false}
- openBehaviour="multiple"
- type="default"
- chevronAlign="left"
- size="small"
- iconPosition="left"
- >
- <Accordion.Item id="1" header="Full error message">
- <Input.TextArea
- size="tiny"
- value={JSON.stringify(error, null, 2)}
- borderless
- className="mt-4 w-full font-mono"
- copy
- rows={5}
- />
- </Accordion.Item>
- </Accordion>
- </div>
-)
+ )
+}
export default ResourcesExceededErrorRenderer
diff --git a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnType.tsx b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnType.tsx
index 44a7be54788..ac61d5734bb 100644
--- a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnType.tsx
+++ b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnType.tsx
@@ -25,7 +25,10 @@ import {
CommandList_Shadcn_,
CommandSeparator_Shadcn_,
CriticalIcon,
- Input,
+ Input_Shadcn_ as Input,
+ InputGroup,
+ InputGroupAddon,
+ InputGroupInput,
Label_Shadcn_,
Popover_Shadcn_,
PopoverContent_Shadcn_,
@@ -35,6 +38,7 @@ import {
TooltipContent,
TooltipTrigger,
} from 'ui'
+import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
import {
POSTGRES_DATA_TYPE_OPTIONS,
@@ -120,17 +124,19 @@ const ColumnType = ({
return (
<Tooltip>
<TooltipTrigger>
- <Input
- readOnly
- disabled
- label={showLabel ? 'Type' : ''}
+ <FormItemLayout
layout={showLabel ? layout : undefined}
- className="md:gap-x-0 [&>div>div]:text-left"
- size="small"
- icon={inferIcon(POSTGRES_DATA_TYPE_OPTIONS.find((x) => x.name === value)?.type ?? '')}
- value={value}
- descriptionText={showLabel ? unsupportedDataTypeText : undefined}
- />
+ label={showLabel ? 'Type' : ''}
+ description={showLabel ? unsupportedDataTypeText : undefined}
+ isReactForm={false}
+ >
+ <InputGroup>
+ <InputGroupInput readOnly disabled size="small" value={value} />
+ <InputGroupAddon align="inline-start">
+ {inferIcon(POSTGRES_DATA_TYPE_OPTIONS.find((x) => x.name === value)?.type ?? '')}
+ </InputGroupAddon>
+ </InputGroup>
+ </FormItemLayout>
</TooltipTrigger>
{!showLabel && (
<TooltipContent side="bottom" className="w-80">
@@ -145,15 +151,14 @@ const ColumnType = ({
return (
<Tooltip>
<TooltipTrigger>
- <Input
- readOnly
- disabled
+ <FormItemLayout
+ layout={showLabel ? layout : undefined}
label={showLabel ? 'Type' : ''}
- layout={showLabel ? 'horizontal' : undefined}
- className="md:gap-x-0"
- size="small"
- value={value}
- />
+ description={showLabel ? unsupportedDataTypeText : undefined}
+ isReactForm={false}
+ >
+ <Input readOnly disabled size="small" value={value} />
+ </FormItemLayout>
</TooltipTrigger>
{!showLabel && description && (
<TooltipContent side="bottom">
@@ -175,7 +180,10 @@ const ColumnType = ({
size={'small'}
aria-expanded={open}
aria-controls={listboxId}
- className={cn('w-full justify-between', !value && 'text-foreground-lighter')}
+ className={cn(
+ 'w-full bg-foreground/[.026]! justify-between',
+ !value && 'text-foreground-lighter'
+ )}
iconRight={<ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />}
title={value && value.replaceAll('"', '')}
>
diff --git a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/InputWithSuggestions.tsx b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/InputWithSuggestions.tsx
index 6a82f0286f7..29f730702c7 100644
--- a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/InputWithSuggestions.tsx
+++ b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/InputWithSuggestions.tsx
@@ -15,8 +15,11 @@ import {
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
- Input,
+ InputGroup,
+ InputGroupAddon,
+ InputGroupInput,
} from 'ui'
+import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
import type { Suggestion } from './ColumnEditor.types'
import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
@@ -42,13 +45,13 @@ interface InputWithSuggestionsProps {
}
const InputWithSuggestions = ({
+ className,
label,
description,
placeholder,
size,
layout,
disabled = false,
- className = '',
value = '',
suggestions = [],
suggestionsTooltip,
@@ -83,54 +86,53 @@ const InputWithSuggestions = ({
return (
<div ref={ref} className="relative">
- <Input
- label={label}
- aria-label={ariaLabel}
- descriptionText={description}
- placeholder={placeholder}
- size={size}
- layout={layout}
- disabled={disabled}
- className={className}
- inputClassName="pr-10"
- type="text"
- value={value}
- title={value}
- onChange={onInputChange}
- data-testid={dataTestId}
- actions={
- showSuggestions && (
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <ButtonTooltip
- type="default"
- className="px-1! mr-0.5"
- tooltip={{
- content: { text: suggestionsTooltip || 'Suggestions', side: 'bottom' },
- }}
- >
- <List strokeWidth={1.5} size={14} />
- </ButtonTooltip>
- </DropdownMenuTrigger>
-
- <DropdownMenuContent align="end" side="bottom">
- <DropdownMenuLabel>{suggestionsHeader || 'Suggestions'}</DropdownMenuLabel>
- <DropdownMenuSeparator />
- {filteredSuggestions.map((suggestion: Suggestion) => (
- <DropdownMenuItem
- className="space-x-2"
- key={suggestion.name}
- onClick={() => onSelectSuggestion(suggestion)}
+ <FormItemLayout layout={layout} label={label} description={description} isReactForm={false}>
+ <InputGroup>
+ <InputGroupInput
+ className={className}
+ aria-label={ariaLabel}
+ data-testid={dataTestId}
+ disabled={disabled}
+ size={size}
+ value={value}
+ title={value}
+ onChange={onInputChange}
+ placeholder={placeholder}
+ />
+ {showSuggestions && (
+ <InputGroupAddon align="inline-end">
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <ButtonTooltip
+ type="text"
+ size="tiny"
+ tooltip={{
+ content: { text: suggestionsTooltip || 'Suggestions', side: 'bottom' },
+ }}
>
- <div>{suggestion.name}</div>
- <div className="text-foreground-lighter">{suggestion.description}</div>
- </DropdownMenuItem>
- ))}
- </DropdownMenuContent>
- </DropdownMenu>
- )
- }
- />
+ <List strokeWidth={1.5} size={14} />
+ </ButtonTooltip>
+ </DropdownMenuTrigger>
+
+ <DropdownMenuContent align="end" side="bottom">
+ <DropdownMenuLabel>{suggestionsHeader || 'Suggestions'}</DropdownMenuLabel>
+ <DropdownMenuSeparator />
+ {filteredSuggestions.map((suggestion: Suggestion) => (
+ <DropdownMenuItem
+ className="space-x-2"
+ key={suggestion.name}
+ onClick={() => onSelectSuggestion(suggestion)}
+ >
+ <div>{suggestion.name}</div>
+ <div className="text-foreground-lighter">{suggestion.description}</div>
+ </DropdownMenuItem>
+ ))}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </InputGroupAddon>
+ )}
+ </InputGroup>
+ </FormItemLayout>
</div>
)
}
diff --git a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/DateTimeInput/index.tsx b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/DateTimeInput/index.tsx
index 84032262ea4..82fd0734fbf 100644
--- a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/DateTimeInput/index.tsx
+++ b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/DateTimeInput/index.tsx
@@ -2,14 +2,16 @@ import dayjs from 'dayjs'
import { Edit } from 'lucide-react'
import { ReactNode } from 'react'
import {
- Button,
- cn,
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
- Input,
+ InputGroup,
+ InputGroupAddon,
+ InputGroupButton,
+ InputGroupInput,
} from 'ui'
+import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
import { getColumnType } from './DateTimeInput.utils'
@@ -40,11 +42,11 @@ export const DateTimeInput = ({
const inputType = getColumnType(format)
return (
- <Input
+ <FormItemLayout
layout="horizontal"
- className={cn('w-full [&>div>div>div>input]:pr-10')}
label={name}
- descriptionText={
+ labelOptional={format}
+ description={
<div className="space-y-1">
{description}
{format.includes('tz') && (
@@ -52,42 +54,47 @@ export const DateTimeInput = ({
)}
</div>
}
- labelOptional={format}
- size="small"
- value={value}
- type={inputType}
- step={inputType == 'datetime-local' || inputType == 'time' ? '1' : undefined}
- actions={
- !disabled && (
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button type="default" icon={<Edit />} className="px-1.5" />
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end" className="w-28 pointer-events-auto">
- {isNullable && (
- <DropdownMenuItem onClick={() => onChange(null)}>Set to NULL</DropdownMenuItem>
- )}
- <DropdownMenuItem
- onClick={() =>
- onChange(
- dayjs().format(
- format === 'date'
- ? 'YYYY-MM-DD'
- : ['time', 'timetz'].includes(format)
- ? 'HH:mm:ss'
- : 'YYYY-MM-DDTHH:mm:ss'
+ isReactForm={false}
+ >
+ <InputGroup>
+ <InputGroupInput
+ size="small"
+ value={value}
+ type={inputType}
+ step={inputType == 'datetime-local' || inputType == 'time' ? '1' : undefined}
+ onChange={(e) => onChange(e.target.value)}
+ disabled={disabled}
+ />
+ <InputGroupAddon align="inline-end">
+ {!disabled && (
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <InputGroupButton type="default" icon={<Edit />} className="px-1.5" />
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" className="w-28 pointer-events-auto">
+ {isNullable && (
+ <DropdownMenuItem onClick={() => onChange(null)}>Set to NULL</DropdownMenuItem>
+ )}
+ <DropdownMenuItem
+ onClick={() =>
+ onChange(
+ dayjs().format(
+ format === 'date'
+ ? 'YYYY-MM-DD'
+ : ['time', 'timetz'].includes(format)
+ ? 'HH:mm:ss'
+ : 'YYYY-MM-DDTHH:mm:ss'
+ )
)
- )
- }
- >
- Set to now
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- )
- }
- onChange={(e) => onChange(e.target.value)}
- disabled={disabled}
- />
+ }
+ >
+ Set to now
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ )}
+ </InputGroupAddon>
+ </InputGroup>
+ </FormItemLayout>
)
}
diff --git a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/InputField.tsx b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/InputField.tsx
index 300f170d6ed..71172e3305a 100644
--- a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/InputField.tsx
+++ b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/InputField.tsx
@@ -1,19 +1,24 @@
import { includes, noop } from 'lodash'
import { Edit, Eye } from 'lucide-react'
import {
- Button,
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuSeparator,
DropdownMenuTrigger,
- Input,
+ Input_Shadcn_ as Input,
+ InputGroup,
+ InputGroupAddon,
+ InputGroupButton,
+ InputGroupInput,
+ InputGroupTextarea,
Select_Shadcn_,
SelectContent_Shadcn_,
SelectGroup_Shadcn_,
SelectItem_Shadcn_,
SelectTrigger_Shadcn_,
SelectValue_Shadcn_,
+ TextArea_Shadcn_ as TextArea,
} from 'ui'
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
@@ -50,16 +55,19 @@ export const InputField = ({
const isArray = field.format[0] === '_'
if (isArray) {
return (
- <div className="text-area-text-sm">
- <Input.TextArea
+ <FormItemLayout
+ isReactForm={false}
+ layout="horizontal"
+ label={field.name}
+ labelOptional={field.format}
+ description={field.comment}
+ className="[&>div:first-child>span]:text-foreground-lighter"
+ error={errors[field.name]}
+ >
+ <TextArea
data-testid={`${field.name}-input`}
- layout="horizontal"
- label={field.name}
className="text-sm"
- descriptionText={field.comment}
- labelOptional={field.format}
disabled={!isEditable}
- error={errors[field.name]}
rows={5}
value={field.value ?? ''}
placeholder={
@@ -69,9 +77,9 @@ export const InputField = ({
? 'EMPTY'
: `Default: ${field.defaultValue}`
}
- onChange={(event: any) => onUpdateField({ [field.name]: event.target.value })}
+ onChange={(event) => onUpdateField({ [field.name]: event.target.value })}
/>
- </div>
+ </FormItemLayout>
)
} else {
return (
@@ -109,49 +117,58 @@ export const InputField = ({
if (field.foreignKey !== undefined) {
return (
- <Input
- data-testid={`${field.name}-input`}
+ <FormItemLayout
+ isReactForm={false}
layout="horizontal"
- placeholder={field.defaultValue !== null ? `Default: ${field.defaultValue}` : 'NULL'}
label={field.name}
- value={field.value ?? ''}
- descriptionText={
+ labelOptional={field.format}
+ description={
<>
- {field.comment && (
- <span className="text-sm text-foreground-lighter">{field.comment} </span>
- )}
- <span className="text-sm text-foreground-lighter">
- {field.comment && '('}Has a foreign key relation to
- </span>
- <span className="text-code font-mono text-xs text-foreground-lighter">
- {field.foreignKey.target_table_schema}.{field.foreignKey.target_table_name}.
- {field.foreignKey.target_column_name}
- </span>
- {field.comment && <span className="text-sm text-foreground-lighter">{`)`}</span>}
+ <>
+ {field.comment && (
+ <span className="text-sm text-foreground-lighter">{field.comment} </span>
+ )}
+ <span className="text-sm text-foreground-lighter">
+ {field.comment && '('}Has a foreign key relation to
+ </span>
+ <span className="text-code font-mono text-xs text-foreground-lighter">
+ {field.foreignKey.target_table_schema}.{field.foreignKey.target_table_name}.
+ {field.foreignKey.target_column_name}
+ </span>
+ {field.comment && <span className="text-sm text-foreground-lighter">{`)`}</span>}
+ </>
</>
}
- labelOptional={field.format}
- disabled={!isEditable}
+ className="[&>div:first-child>span]:text-foreground-lighter"
error={errors[field.name]}
- onChange={(event: any) => onUpdateField({ [field.name]: event.target.value })}
- actions={
- isEditable && (
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button type="default" icon={<Edit />} className="px-1.5" />
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end" className="w-28">
- {field.isNullable && (
- <DropdownMenuItem onClick={() => onUpdateField({ [field.name]: null })}>
- Set to NULL
- </DropdownMenuItem>
- )}
- <DropdownMenuItem onClick={onSelectForeignKey}>Select record</DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- )
- }
- />
+ >
+ <InputGroup>
+ <InputGroupInput
+ data-testid={`${field.name}-input`}
+ placeholder={field.defaultValue !== null ? `Default: ${field.defaultValue}` : 'NULL'}
+ value={field.value ?? ''}
+ disabled={!isEditable}
+ onChange={(event) => onUpdateField({ [field.name]: event.target.value })}
+ />
+ <InputGroupAddon align="inline-end">
+ {isEditable && (
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <InputGroupButton type="default" icon={<Edit />} className="px-1.5" />
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" className="w-28">
+ {field.isNullable && (
+ <DropdownMenuItem onClick={() => onUpdateField({ [field.name]: null })}>
+ Set to NULL
+ </DropdownMenuItem>
+ )}
+ <DropdownMenuItem onClick={onSelectForeignKey}>Select record</DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ )}
+ </InputGroupAddon>
+ </InputGroup>
+ </FormItemLayout>
)
}
@@ -164,40 +181,44 @@ export const InputField = ({
*/
return (
- <div className="text-area-text-sm">
- <Input.TextArea
- data-testid={`${field.name}-input`}
- layout="horizontal"
- label={field.name}
- className="input-sm"
- descriptionText={
- <>
- {field.comment && <p>{field.comment}</p>}
- {isTruncated && <p>{TRUNCATE_DESCRIPTION}</p>}
- </>
- }
- textAreaClassName="pr-8"
- labelOptional={field.format}
- disabled={!isEditable || isTruncated}
- error={errors[field.name]}
- rows={5}
- value={field.value ?? ''}
- placeholder={
- field.value === null
- ? 'NULL'
- : field.value === '' ||
- (typeof field.defaultValue === 'string' && field.defaultValue.length === 0)
- ? 'EMPTY'
- : `Default: ${field.defaultValue === null ? 'NULL' : field.defaultValue}`
- }
- actions={
+ <FormItemLayout
+ isReactForm={false}
+ layout="horizontal"
+ label={field.name}
+ labelOptional={field.format}
+ description={
+ <>
+ {field.comment && <p>{field.comment}</p>}
+ {isTruncated && <p>{TRUNCATE_DESCRIPTION}</p>}
+ </>
+ }
+ error={errors[field.name]}
+ >
+ <InputGroup>
+ <InputGroupTextarea
+ data-testid={`${field.name}-input`}
+ className="text-sm"
+ disabled={!isEditable || isTruncated}
+ rows={5}
+ value={field.value ?? ''}
+ placeholder={
+ field.value === null
+ ? 'NULL'
+ : field.value === '' ||
+ (typeof field.defaultValue === 'string' && field.defaultValue.length === 0)
+ ? 'EMPTY'
+ : `Default: ${field.defaultValue === null ? 'NULL' : field.defaultValue}`
+ }
+ onChange={(event) => onUpdateField({ [field.name]: event.target.value })}
+ />
+ <InputGroupAddon align="block-end">
<DropdownMenu>
<DropdownMenuTrigger asChild>
- <Button
+ <InputGroupButton
data-testid={`${field.name}-field-actions`}
type="default"
icon={<Edit />}
- className="px-1.5"
+ className="ml-auto px-1.5"
/>
</DropdownMenuTrigger>
<DropdownMenuContent align="end" className="w-28">
@@ -222,10 +243,9 @@ export const InputField = ({
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
- }
- onChange={(event) => onUpdateField({ [field.name]: event.target.value })}
- />
- </div>
+ </InputGroupAddon>
+ </InputGroup>
+ </FormItemLayout>
)
}
@@ -233,33 +253,39 @@ export const InputField = ({
const isTruncated = isValueTruncated(field.value)
return (
- <Input
- data-testid={`${field.name}-input`}
+ <FormItemLayout
+ isReactForm={false}
layout="horizontal"
- value={field.value ?? ''}
label={field.name}
- descriptionText={
+ labelOptional={field.format}
+ description={
<>
{field.comment && <p>{field.comment}</p>}
{isTruncated && <p>{TRUNCATE_DESCRIPTION}</p>}
</>
}
- labelOptional={field.format}
- disabled={!isEditable || isTruncated}
- placeholder={!!field?.defaultValue ? `Default: ${field.defaultValue}` : 'NULL'}
error={errors[field.name]}
- onChange={(event: any) => onUpdateField({ [field.name]: event.target.value })}
- actions={
- <Button
- type="default"
- htmlType="button"
- onClick={() => onEditJson({ column: field.name, value: field.value })}
- icon={isEditable ? <Edit /> : <Eye />}
- >
- {isEditable ? 'Edit' : 'View JSON'}
- </Button>
- }
- />
+ >
+ <InputGroup>
+ <InputGroupInput
+ data-testid={`${field.name}-input`}
+ value={field.value ?? ''}
+ disabled={!isEditable || isTruncated}
+ placeholder={!!field?.defaultValue ? `Default: ${field.defaultValue}` : 'NULL'}
+ onChange={(event) => onUpdateField({ [field.name]: event.target.value })}
+ />
+ <InputGroupAddon align="inline-end">
+ <InputGroupButton
+ type="default"
+ htmlType="button"
+ onClick={() => onEditJson({ column: field.name, value: field.value })}
+ icon={isEditable ? <Edit /> : <Eye />}
+ >
+ {isEditable ? 'Edit' : 'View JSON'}
+ </InputGroupButton>
+ </InputGroupAddon>
+ </InputGroup>
+ </FormItemLayout>
)
}
@@ -276,7 +302,7 @@ export const InputField = ({
{field.comment && <p>{field.comment}</p>}
</>
}
- onChange={(value: string | null) => onUpdateField({ [field.name]: value })}
+ onChange={(value) => onUpdateField({ [field.name]: value })}
disabled={!isEditable}
/>
)
@@ -298,11 +324,10 @@ export const InputField = ({
label={field.name}
labelOptional={field.format}
description={field.comment}
- className="[&>div:first-child>span]:text-foreground-lighter"
>
<Select_Shadcn_
value={defaultValue === null ? 'null' : defaultValue}
- onValueChange={(value: string) => onUpdateField({ [field.name]: value })}
+ onValueChange={(value) => onUpdateField({ [field.name]: value })}
disabled={!isEditable}
>
<SelectTrigger_Shadcn_>
@@ -324,63 +349,73 @@ export const InputField = ({
if (field.format === 'bytea') {
return (
- <Input
- data-testid={`${field.name}-input`}
+ <FormItemLayout
+ isReactForm={false}
layout="horizontal"
label={field.name}
- descriptionText={
+ labelOptional={field.format}
+ description={
<>
{field.comment && <p>{field.comment}</p>}
<p>Bytea columns are edited and displayed as hex in the dashboard</p>
</>
}
- labelOptional={field.format}
error={errors[field.name]}
- value={field.value ?? ''}
- placeholder={`\\x`}
- disabled={!isEditable}
- onChange={(event: any) => onUpdateField({ [field.name]: event.target.value })}
- />
+ >
+ <Input
+ data-testid={`${field.name}-input`}
+ value={field.value ?? ''}
+ placeholder={`\\x`}
+ disabled={!isEditable}
+ onChange={(event) => onUpdateField({ [field.name]: event.target.value })}
+ />
+ </FormItemLayout>
)
}
const isTruncated = isValueTruncated(field.value)
return (
- <Input
- data-testid={`${field.name}-input`}
+ <FormItemLayout
+ isReactForm={false}
layout="horizontal"
label={field.name}
- descriptionText={
+ labelOptional={field.format}
+ description={
<>
{field.comment && <p>{field.comment}</p>}
{isTruncated && <p>{TRUNCATE_DESCRIPTION}</p>}
</>
}
- labelOptional={field.format}
error={errors[field.name]}
- value={field.value ?? ''}
- placeholder={
- field.isIdentity
- ? 'Automatically generated as identity'
- : field.defaultValue !== null
- ? `Default: ${field.defaultValue}`
- : 'NULL'
- }
- disabled={!isEditable || isTruncated}
- onChange={(event: any) => onUpdateField({ [field.name]: event.target.value })}
- actions={
- isTruncated ? (
- <Button
- type="default"
- htmlType="button"
- onClick={() => onEditJson({ column: field.name, value: field.value })}
- icon={isEditable ? <Edit /> : <Eye />}
- >
- {isEditable ? 'Edit' : 'View'}
- </Button>
- ) : undefined
- }
- />
+ >
+ <InputGroup>
+ <InputGroupInput
+ data-testid={`${field.name}-input`}
+ value={field.value ?? ''}
+ placeholder={
+ field.isIdentity
+ ? 'Automatically generated as identity'
+ : field.defaultValue !== null
+ ? `Default: ${field.defaultValue}`
+ : 'NULL'
+ }
+ disabled={!isEditable || isTruncated}
+ onChange={(event) => onUpdateField({ [field.name]: event.target.value })}
+ />
+ <InputGroupAddon align="inline-end">
+ {isTruncated ? (
+ <InputGroupButton
+ type="default"
+ htmlType="button"
+ onClick={() => onEditJson({ column: field.name, value: field.value })}
+ icon={isEditable ? <Edit /> : <Eye />}
+ >
+ {isEditable ? 'Edit' : 'View'}
+ </InputGroupButton>
+ ) : undefined}
+ </InputGroupAddon>
+ </InputGroup>
+ </FormItemLayout>
)
}
diff --git a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/SchemaEditor.tsx b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/SchemaEditor.tsx
index 61a8e2f3803..d320b34e3c8 100644
--- a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/SchemaEditor.tsx
+++ b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/SchemaEditor.tsx
@@ -1,6 +1,7 @@
import { useEffect, useState } from 'react'
import { toast } from 'sonner'
-import { Input, SidePanel } from 'ui'
+import { Input_Shadcn_ as Input, SidePanel } from 'ui'
+import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
import { useSchemaCreateMutation } from '@/data/database/schema-create-mutation'
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
@@ -63,14 +64,18 @@ export const SchemaEditor = ({ visible, onSuccess, closePanel }: SchemaEditorPro
<>
<SidePanel.Content>
<div className="space-y-10 py-6">
- <Input
- label="Schema name"
+ <FormItemLayout
+ isReactForm={false}
layout="vertical"
- type="text"
+ label="Schema name"
error={errors?.name}
- value={name}
- onChange={(event: any) => setName(event.target.value)}
- />
+ >
+ <Input
+ type="text"
+ value={name}
+ onChange={(event: any) => setName(event.target.value)}
+ />
+ </FormItemLayout>
</div>
</SidePanel.Content>
</>
diff --git a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/Column.tsx b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/Column.tsx
index 7d7b55ac065..126f6233b75 100644
--- a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/Column.tsx
+++ b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/Column.tsx
@@ -12,7 +12,7 @@ import {
CommandItem_Shadcn_,
CommandList_Shadcn_,
CommandSeparator_Shadcn_,
- Input,
+ Input_Shadcn_ as Input,
Popover_Shadcn_,
PopoverContent_Shadcn_,
PopoverTrigger_Shadcn_,
@@ -139,7 +139,7 @@ export const Column = ({
disabled={hasImportContent}
placeholder="column_name"
className={cn(
- '[&>div>div>div>input]:py-1.5 [&>div>div>div>input]:border-r-transparent [&>div>div>div>input]:rounded-r-none',
+ 'border-r-transparent rounded-r-none',
hasImportContent ? 'opacity-50' : ''
)}
onChange={(event) => onUpdateColumn({ name: event.target.value })}
@@ -147,7 +147,7 @@ export const Column = ({
{relations.filter((r) => !r.toRemove).length === 0 ? (
<Button
type="dashed"
- className="rounded-l-none h-[30px] py-0 px-2"
+ className="rounded-l-none h-[34px] py-0 px-2"
onClick={() => onEditForeignKey()}
>
<Link size={12} />
@@ -269,9 +269,7 @@ export const Column = ({
size="small"
value={column.defaultValue ?? ''}
disabled={column.format.includes('int') && column.isIdentity}
- className={`rounded-sm bg-surface-100 lg:gap-0 ${
- column.format.includes('int') && column.isIdentity ? 'opacity-50' : ''
- }`}
+ className={column.format.includes('int') && column.isIdentity ? 'opacity-50' : ''}
suggestions={suggestions}
suggestionsHeader="Suggested expressions"
suggestionsTooltip="Suggested expressions"
diff --git a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx
index d8aa4ec444b..8156091cdfb 100644
--- a/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx
+++ b/apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/TableEditor/TableEditor.tsx
@@ -2,9 +2,10 @@ import type { PostgresTable } from '@supabase/postgres-meta'
import { isEmpty, noop } from 'lodash'
import { useContext, useEffect, useMemo, useState } from 'react'
import { toast } from 'sonner'
-import { Badge, Checkbox, Input, SidePanel } from 'ui'
+import { Badge, Checkbox, Input_Shadcn_ as Input, SidePanel } from 'ui'
import { Admonition } from 'ui-patterns'
import { ConfirmationModal } from 'ui-patterns/Dialogs/ConfirmationModal'
+import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
import { ActionBar } from '../ActionBar'
import type { ForeignKey } from '../ForeignKeySelector/ForeignKeySelector.types'
@@ -347,25 +348,35 @@ export const TableEditor = ({
}
>
<SidePanel.Content className="space-y-10 py-6">
- <Input
- data-testid="table-name-input"
- label="Name"
+ <FormItemLayout
id="name"
+ isReactForm={false}
layout="horizontal"
- type="text"
+ label="Name"
error={errors.name ? String(errors.name) : undefined}
- value={tableFields?.name}
- onChange={(event) => onUpdateField({ name: event.target.value })}
- />
- <Input
- label="Description"
+ >
+ <Input
+ data-testid="table-name-input"
+ id="name"
+ type="text"
+ value={tableFields?.name}
+ onChange={(event) => onUpdateField({ name: event.target.value })}
+ />
+ </FormItemLayout>
+ <FormItemLayout
id="description"
- placeholder="Optional"
+ isReactForm={false}
layout="horizontal"
- type="text"
- value={tableFields?.comment ?? ''}
- onChange={(event) => onUpdateField({ comment: event.target.value })}
- />
+ label="Description"
+ >
+ <Input
+ id="description"
+ placeholder="Optional"
+ type="text"
+ value={tableFields?.comment ?? ''}
+ onChange={(event) => onUpdateField({ comment: event.target.value })}
+ />
+ </FormItemLayout>
</SidePanel.Content>
<SidePanel.Separator />
diff --git a/apps/studio/components/ui/ProjectSettings/DisplayConfigSettings.tsx b/apps/studio/components/ui/ProjectSettings/DisplayConfigSettings.tsx
deleted file mode 100644
index 24fcf4cb503..00000000000
--- a/apps/studio/components/ui/ProjectSettings/DisplayConfigSettings.tsx
+++ /dev/null
@@ -1,106 +0,0 @@
-import { JwtSecretUpdateStatus } from '@supabase/shared-types/out/events'
-import { useParams } from 'common'
-import { AlertCircle, Loader } from 'lucide-react'
-import { PropsWithChildren } from 'react'
-import { Input } from 'ui'
-
-import Panel from '@/components/ui/Panel'
-import { useJwtSecretUpdatingStatusQuery } from '@/data/config/jwt-secret-updating-status-query'
-import { useProjectPostgrestConfigQuery } from '@/data/config/project-postgrest-config-query'
-import { useProjectSettingsV2Query } from '@/data/config/project-settings-v2-query'
-
-export const DisplayConfigSettings = () => {
- const { ref: projectRef } = useParams()
- const {
- data: settings,
- isPending: isProjectSettingsLoading,
- isError: isProjectSettingsError,
- } = useProjectSettingsV2Query({
- projectRef,
- })
- const { data: config, isError: isPostgrestError } = useProjectPostgrestConfigQuery({ projectRef })
-
- const {
- data,
- isError: isJwtSecretUpdateStatusError,
- isPending: isJwtSecretUpdateStatusLoading,
- } = useJwtSecretUpdatingStatusQuery({ projectRef })
- const jwtSecretUpdateStatus = data?.jwtSecretUpdateStatus
- const isNotUpdatingJwtSecret =
- jwtSecretUpdateStatus === undefined || jwtSecretUpdateStatus === JwtSecretUpdateStatus.Updated
-
- const jwtSecret = config?.jwt_secret ?? ''
- const protocol = settings?.app_config?.protocol ?? 'https'
- const endpoint = settings?.app_config?.endpoint
- const apiUrl = endpoint ? `${protocol}://${endpoint}` : '-'
-
- return (
- <ConfigContentWrapper>
- {isProjectSettingsError || isPostgrestError || isJwtSecretUpdateStatusError ? (
- <div className="flex items-center justify-center py-8 space-x-2">
- <AlertCircle size={16} strokeWidth={1.5} />
- <p className="text-sm text-foreground-light">
- {isProjectSettingsError || isPostgrestError
- ? 'Failed to retrieve configuration'
- : 'Failed to update JWT secret'}
- </p>
- </div>
- ) : isProjectSettingsLoading || isPostgrestError || isJwtSecretUpdateStatusLoading ? (
- <div className="flex items-center justify-center py-8 space-x-2">
- <Loader className="animate-spin" size={16} strokeWidth={1.5} />
- <p className="text-sm text-foreground-light">
- {isProjectSettingsLoading ? 'Retrieving API keys' : 'JWT secret is being updated'}
- </p>
- </div>
- ) : (
- <>
- <Panel.Content>
- <Input
- label="URL"
- readOnly
- copy
- disabled
- className="input-mono"
- value={apiUrl}
- descriptionText="A RESTful endpoint for querying and managing your database."
- layout="horizontal"
- />
- </Panel.Content>
- <Panel.Content className="border-t border-panel-border-interior-light in-data-[theme*=dark]:border-panel-border-interior-dark">
- <Input
- label="JWT Secret"
- readOnly
- copy={isNotUpdatingJwtSecret}
- reveal={isNotUpdatingJwtSecret}
- disabled
- value={
- jwtSecretUpdateStatus === JwtSecretUpdateStatus.Failed
- ? 'JWT secret update failed'
- : jwtSecretUpdateStatus === JwtSecretUpdateStatus.Updating
- ? 'Updating JWT secret...'
- : jwtSecret
- }
- className="input-mono"
- descriptionText="Used to decode your JWTs. You can also use this to mint your own JWTs."
- layout="horizontal"
- />
- </Panel.Content>
- </>
- )}
- </ConfigContentWrapper>
- )
-}
-
-const ConfigContentWrapper = ({ children }: PropsWithChildren<{}>) => {
- return (
- <Panel
- title={
- <div className="space-y-3">
- <h5 className="text-base">Project Configuration</h5>
- </div>
- }
- >
- {children}
- </Panel>
- )
-}
diff --git a/apps/studio/pages/integrations/vercel/[slug]/deploy-button/new-project.tsx b/apps/studio/pages/integrations/vercel/[slug]/deploy-button/new-project.tsx
index f1032a86d13..7fb4563f1ae 100644
--- a/apps/studio/pages/integrations/vercel/[slug]/deploy-button/new-project.tsx
+++ b/apps/studio/pages/integrations/vercel/[slug]/deploy-button/new-project.tsx
@@ -5,7 +5,7 @@ import { toast } from 'sonner'
import {
Button,
Checkbox,
- Input,
+ Input_Shadcn_ as Input,
Select_Shadcn_,
SelectContent_Shadcn_,
SelectItem_Shadcn_,
@@ -13,6 +13,7 @@ import {
SelectValue_Shadcn_,
} from 'ui'
import { Admonition } from 'ui-patterns/admonition'
+import { Input as PasswordInput } from 'ui-patterns/DataInputs/Input'
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
import { isVercelUrl } from '@/components/interfaces/Integrations/Vercel/VercelIntegration.utils'
@@ -253,27 +254,31 @@ const CreateProject = () => {
<div>
<p className="mb-2">Supabase project details</p>
<div className="py-2">
- <Input
- autoFocus
+ <FormItemLayout
id="projectName"
+ isReactForm={false}
+ layout="vertical"
label="Project name"
- type="text"
- placeholder=""
- descriptionText=""
- value={projectName}
- onChange={onProjectNameChange}
- />
+ size="tiny"
+ >
+ <Input
+ autoFocus
+ id="projectName"
+ type="text"
+ placeholder=""
+ value={projectName}
+ onChange={onProjectNameChange}
+ />
+ </FormItemLayout>
</div>
<div className="py-2">
- <Input
+ <FormItemLayout
id="dbPass"
+ isReactForm={false}
+ layout="vertical"
label="Database password"
- type="password"
- placeholder="Type in a strong password"
- value={dbPass}
- copy={dbPass.length > 0}
- onChange={onDbPassChange}
- descriptionText={
+ size="tiny"
+ description={
<PasswordStrengthBar
passwordStrengthScore={passwordStrengthScore as PasswordStrengthScore}
password={dbPass}
@@ -281,7 +286,17 @@ const CreateProject = () => {
generateStrongPassword={generatePassword}
/>
}
- />
+ >
+ <PasswordInput
+ id="dbPass"
+ type="password"
+ placeholder="Type in a strong password"
+ value={dbPass}
+ reveal
+ copy={dbPass.length > 0}
+ onChange={onDbPassChange}
+ />
+ </FormItemLayout>
</div>
<div className="py-2">
<div className="mt-1">
diff --git a/packages/ui-patterns/src/DataInputs/Input.tsx b/packages/ui-patterns/src/DataInputs/Input.tsx
index 5254b837af8..d24148cc850 100644
--- a/packages/ui-patterns/src/DataInputs/Input.tsx
+++ b/packages/ui-patterns/src/DataInputs/Input.tsx
@@ -15,7 +15,6 @@ import {
InputGroupButton,
InputGroupInput,
} from 'ui'
-import styleHandler from 'ui/src/lib/theme/styleHandler'
export interface Props extends Omit<ComponentProps<typeof Input_Shadcn_>, 'onCopy'> {
copy?: boolean
@@ -50,8 +49,6 @@ const Input = forwardRef<
const [copyLabel, setCopyLabel] = useState('Copy')
const [hidden, setHidden] = useState(true)
- const __styles = styleHandler('input')
-
function _onCopy(value: any) {
copyToClipboard(value, () => {
/* clipboard successfully set */
@@ -67,9 +64,6 @@ const Input = forwardRef<
setHidden(false)
}
- let inputClasses: string[] = []
- if (size) inputClasses.push(__styles.size[size])
-
return (
<InputGroup className={containerClassName}>
<InputGroupInput
@@ -80,7 +74,7 @@ const Input = forwardRef<
onCopy={onCopy}
type={reveal && hidden ? 'password' : props.type}
disabled={props.disabled}
- className={cn(...inputClasses, props.className)}
+ className={props.className}
data-1p-ignore // 1Password
data-lpignore="true" // LastPass
data-form-type="other" // Dashlane
diff --git a/packages/ui-patterns/src/form/Layout/FormLayout.tsx b/packages/ui-patterns/src/form/Layout/FormLayout.tsx
index 044ac568049..1fc0df730db 100644
--- a/packages/ui-patterns/src/form/Layout/FormLayout.tsx
+++ b/packages/ui-patterns/src/form/Layout/FormLayout.tsx
@@ -286,6 +286,7 @@ export const FormLayout = React.forwardRef<
nonBoxInput = !label,
hideMessage = false,
isReactForm,
+ error,
...props
},
ref
@@ -301,6 +302,10 @@ export const FormLayout = React.forwardRef<
)}
data-formlayout-id="message"
/>
+ ) : error && !hideMessage ? (
+ <p className={cn('mt-2 text-sm text-destructive', layout === 'flex-row-reverse' && 'mt-0')}>
+ {error}
+ </p>
) : null
const renderDescription =
diff --git a/packages/ui/src/components/shadcn/ui/input-group.tsx b/packages/ui/src/components/shadcn/ui/input-group.tsx
index cfeea39d653..9b01445d44c 100644
--- a/packages/ui/src/components/shadcn/ui/input-group.tsx
+++ b/packages/ui/src/components/shadcn/ui/input-group.tsx
@@ -127,22 +127,20 @@ const inputGroupButtonVariants = cva('', {
},
})
-function InputGroupButton({
- className,
- type = 'text',
- size = 'tiny',
- ...props
-}: Omit<React.ComponentProps<typeof Button>, 'size'> &
- VariantProps<typeof inputGroupButtonVariants>) {
+const InputGroupButton = React.forwardRef<
+ HTMLButtonElement,
+ Omit<React.ComponentProps<typeof Button>, 'size'> & VariantProps<typeof inputGroupButtonVariants>
+>(function InputGroupButton({ className, type = 'text', size = 'tiny', ...props }, ref) {
return (
<Button
type={type}
size={size}
className={cn(inputGroupButtonVariants({ size }), className)}
+ ref={ref}
{...props}
/>
)
-}
+})
function InputGroupText({ className, ...props }: React.ComponentProps<'span'>) {
return (
@@ -165,11 +163,11 @@ const InputGroupInput = React.forwardRef<HTMLInputElement, InputProps>(
ref={ref}
data-slot="input-group-control"
className={cn(
- 'flex-1 rounded-none border border-transparent -m-px bg-transparent shadow-none',
+ 'flex-1 block rounded-none border border-transparent -m-px bg-transparent shadow-none',
'focus:border-transparent focus-visible:border-transparent focus-visible:ring-0 focus-visible:ring-offset-0',
'read-only:border-transparent',
- 'aria-invalid:border-transparent aria-invalid:bg-transparent',
- 'aria-invalid:focus:border-transparent aria-invalid:focus-visible:border-transparent',
+ 'aria-[invalid=true]:border-transparent aria-[invalid=true]:bg-transparent',
+ 'aria-[invalid=true]:focus:border-transparent aria-[invalid=true]:focus-visible:border-transparent',
className
)}
{...props}