Skip to content

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

chore: remove old `Input` component (#47259)

Gildas Garcia968fa3f052c9
diff --git a/apps/studio/components/interfaces/Reports/ReportFilterPopover.tsx b/apps/studio/components/interfaces/Reports/ReportFilterPopover.tsx
deleted file mode 100644
index cf658389bac..00000000000
--- a/apps/studio/components/interfaces/Reports/ReportFilterPopover.tsx
+++ /dev/null
@@ -1,387 +0,0 @@
-import { isEqual } from 'lodash'
-import { ChevronDown, Filter as FilterIcon, Plus, X } from 'lucide-react'
-import { KeyboardEvent, useCallback, useEffect, useMemo, useState } from 'react'
-import {
- Button,
- cn,
- Command,
- CommandEmpty,
- CommandGroup,
- CommandInput,
- CommandItem,
- CommandList,
- Input,
- Popover,
- PopoverContent,
- PopoverSeparator,
- PopoverTrigger,
-} from 'ui'
-import { sizes } from 'ui/src/lib/commonCva'
-import defaultTheme from 'ui/src/lib/theme/defaultTheme'
-
-import type { ReportFilter, ReportFilterProperty } from './Reports.types'
-import { DropdownControl } from '@/components/grid/components/common/DropdownControl'
-
-const FilterableInput = ({
- value,
- onChange,
- onKeyDown,
- placeholder,
- availableOptions = [],
-}: {
- value: string | number
- onChange: (value: string | number) => void
- onKeyDown: (event: KeyboardEvent<HTMLInputElement>) => void
- placeholder?: string
- type?: string
- availableOptions?: string[]
-}) => {
- const [isOpen, setIsOpen] = useState(false)
- const [inputValue, setInputValue] = useState(String(value || ''))
-
- // Ensure we always have a valid array
- const safeOptions = Array.isArray(availableOptions) ? availableOptions : []
-
- useEffect(() => {
- setInputValue(String(value || ''))
- }, [value])
-
- const handleInputChange = (newValue: string) => {
- setInputValue(newValue)
- onChange(newValue)
- }
-
- const handleOptionSelect = (option: string) => {
- setInputValue(option)
- onChange(option)
- setIsOpen(false)
- }
-
- const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {
- if (event.key === 'Escape') {
- setIsOpen(false)
- return
- }
-
- // When dropdown is open, let Command component handle Enter for selection
- if (event.key === 'Enter' && isOpen) {
- // Don't call onKeyDown to prevent interference with Command's selection
- return
- }
-
- // When dropdown is closed, allow custom input
- if (event.key === 'Enter' && !isOpen) {
- return
- }
-
- onKeyDown(event)
- }
-
- return (
- <div className="relative flex-1">
- <Command className="relative overflow-visible bg-transparent">
- <CommandInput
- placeholder={placeholder}
- value={inputValue}
- onValueChange={handleInputChange}
- onFocus={() => setIsOpen(true)}
- onKeyDown={handleKeyDown}
- className={cn('h-6 text-sm', defaultTheme.input.variants.standard, sizes.tiny)}
- wrapperClassName="p-0! border! border-control! rounded-md"
- showSearchIcon={false}
- />
- <div
- className={cn(
- 'absolute top-full left-0 right-0 z-50 mt-1 opacity-0 transition-opacity pointer-events-none',
- isOpen && safeOptions.length > 0 && 'opacity-100 pointer-events-auto'
- )}
- >
- <CommandList className="max-h-60 overflow-auto bg-surface-100 border border-border rounded-md shadow-lg">
- <CommandEmpty className="py-2 px-3 text-sm text-foreground-lighter">
- No matching options found. Press Enter to use "{inputValue}"
- </CommandEmpty>
- <CommandGroup>
- {safeOptions.map((option, index) => (
- <CommandItem
- key={`${option}-${index}`}
- value={option}
- onSelect={() => handleOptionSelect(option)}
- className="px-3 py-2 text-sm cursor-pointer"
- >
- {option}
- </CommandItem>
- ))}
- </CommandGroup>
- </CommandList>
- </div>
- </Command>
- {isOpen && <div className="fixed inset-0 z-40" onClick={() => setIsOpen(false)} />}
- </div>
- )
-}
-
-export interface ReportFilterPopoverProps {
- buttonText?: string
- filters: ReportFilter[]
- filterProperties: ReportFilterProperty[]
- onFiltersChange: (filters: ReportFilter[]) => void
- disabled?: boolean
-}
-
-const ReportFilterRow = ({
- filter,
- filterIdx,
- filterProperties,
- onChange,
- onDelete,
- onKeyDown,
-}: {
- filter: ReportFilter
- filterIdx: number
- filterProperties: ReportFilterProperty[]
- onChange: (index: number, filter: ReportFilter) => void
- onDelete: (index: number) => void
- onKeyDown: (event: KeyboardEvent<HTMLInputElement>) => void
-}) => {
- const property = filterProperties.find((p) => p.name === filter.propertyName)
-
- const propertyOptions = filterProperties.map((prop) => ({
- value: prop.name,
- label: prop.label,
- postLabel: prop.type,
- }))
-
- const operatorOptions =
- property?.operators.map((op) => ({
- value: op,
- label: op,
- })) || []
-
- const valueOptions = property?.options || []
-
- const handlePropertyChange = (newPropertyName: string | number) => {
- const newProperty = filterProperties.find((p) => p.name === newPropertyName)
- if (newProperty) {
- onChange(filterIdx, {
- propertyName: newPropertyName,
- operator: newProperty.operators[0] || '=',
- value: '',
- })
- }
- }
-
- const handleOperatorChange = (newOperator: string | number) => {
- onChange(filterIdx, {
- ...filter,
- operator: newOperator,
- })
- }
-
- const handleValueChange = (value: string | number) => {
- onChange(filterIdx, {
- ...filter,
- value,
- })
- }
-
- return (
- <div className="flex flex-col px-3">
- {filterIdx > 0 && (
- <div className="flex items-center gap-2 p-1 w-full">
- <div className="w-auto flex-1 bg-border h-px" />
- <span className="text-xs font-mono text-foreground-lighter">AND</span>
- <div className="w-auto flex-1 bg-border h-px" />
- </div>
- )}
- <div className="flex w-full items-center justify-between gap-x-2">
- <DropdownControl align="start" options={propertyOptions} onSelect={handlePropertyChange}>
- <Button
- asChild
- variant="outline"
- icon={
- <div className="text-foreground-lighter">
- <ChevronDown strokeWidth={1.5} />
- </div>
- }
- className="w-32 justify-start"
- >
- <span>{property?.label ?? 'Select property'}</span>
- </Button>
- </DropdownControl>
-
- <DropdownControl align="start" options={operatorOptions} onSelect={handleOperatorChange}>
- <Button
- asChild
- variant="outline"
- icon={
- <div className="text-foreground-lighter">
- <ChevronDown strokeWidth={1.5} />
- </div>
- }
- className="w-20 justify-start"
- >
- <span>{filter.operator}</span>
- </Button>
- </DropdownControl>
-
- {valueOptions?.length > 0 ? (
- <FilterableInput
- value={filter.value}
- onChange={handleValueChange}
- onKeyDown={onKeyDown}
- placeholder={
- property?.placeholder || `Enter ${property?.type === 'number' ? 'number' : 'text'}`
- }
- availableOptions={valueOptions?.map((option) => String(option.value)) || []}
- />
- ) : (
- <Input
- size="tiny"
- className="flex-1"
- placeholder={
- property?.placeholder || `Enter ${property?.type === 'number' ? 'number' : 'text'}`
- }
- value={filter.value}
- type={property?.type === 'number' ? 'number' : 'text'}
- onChange={(event) => handleValueChange(event.target.value)}
- onKeyDown={onKeyDown}
- />
- )}
- <Button
- variant="text"
- size="tiny"
- className="px-1"
- icon={<X strokeWidth={1.5} />}
- onClick={() => onDelete(filterIdx)}
- />
- </div>
- </div>
- )
-}
-
-export const ReportFilterPopover = ({
- buttonText,
- filters,
- filterProperties,
- onFiltersChange,
- disabled = false,
-}: ReportFilterPopoverProps) => {
- const [open, setOpen] = useState(false)
- const [localFilters, setLocalFilters] = useState<ReportFilter[]>(filters)
-
- // Update local state when filters prop changes
- useMemo(() => {
- setLocalFilters(filters)
- }, [filters])
-
- const displayButtonText =
- buttonText ??
- (filters.length > 0
- ? `Filtered by ${filters.length} rule${filters.length > 1 ? 's' : ''}`
- : 'Filter')
-
- const onAddFilter = () => {
- const firstProperty = filterProperties[0]
- if (firstProperty) {
- setLocalFilters([
- ...localFilters,
- {
- propertyName: firstProperty.name,
- operator: firstProperty.operators[0] || '=',
- value: '',
- },
- ])
- }
- }
-
- const onChangeFilter = useCallback((index: number, filter: ReportFilter) => {
- setLocalFilters((currentFilters) => [
- ...currentFilters.slice(0, index),
- filter,
- ...currentFilters.slice(index + 1),
- ])
- }, [])
-
- const onDeleteFilter = useCallback((index: number) => {
- setLocalFilters((currentFilters) => [
- ...currentFilters.slice(0, index),
- ...currentFilters.slice(index + 1),
- ])
- }, [])
-
- const onApplyFilters = () => {
- // Filter out empty values
- const validFilters = localFilters.filter(
- (f) => f.value !== null && f.value !== undefined && f.value !== ''
- )
- onFiltersChange(validFilters)
- setOpen(false)
- }
-
- const onResetFilters = () => {
- setLocalFilters([])
- onFiltersChange([])
- setOpen(false)
- }
-
- function handleEnterKeyDown(event: KeyboardEvent<HTMLInputElement>) {
- if (event.key === 'Enter') onApplyFilters()
- }
-
- const hasChanges = !isEqual(localFilters, filters)
-
- return (
- <Popover open={open} onOpenChange={setOpen} modal={false}>
- <PopoverTrigger asChild>
- <Button
- variant={filters.length > 0 ? 'link' : 'text'}
- icon={<FilterIcon />}
- disabled={disabled}
- >
- {displayButtonText}
- </Button>
- </PopoverTrigger>
- <PopoverContent className="p-0 w-[500px]" side="bottom" align="start">
- <div className="space-y-2 py-2">
- <div>
- {localFilters.map((filter, index) => (
- <ReportFilterRow
- key={`filter-${filter.propertyName}-${index}`}
- filter={filter}
- filterIdx={index}
- filterProperties={filterProperties}
- onChange={onChangeFilter}
- onDelete={onDeleteFilter}
- onKeyDown={handleEnterKeyDown}
- />
- ))}
- {localFilters.length === 0 && (
- <div className="space-y-1 px-3">
- <h5 className="text-sm text-foreground-light">No filters applied</h5>
- <p className="text-xs text-foreground-lighter">
- Add a filter below to narrow down the report data
- </p>
- </div>
- )}
- </div>
- <PopoverSeparator />
- <div className="px-3 flex flex-row justify-between">
- <div className="flex gap-2">
- <Button icon={<Plus />} variant="text" onClick={onAddFilter}>
- Add filter
- </Button>
- {filters.length > 0 && (
- <Button variant="text" onClick={onResetFilters}>
- Clear all
- </Button>
- )}
- </div>
- <Button disabled={!hasChanges} variant="default" onClick={onApplyFilters}>
- Apply filters
- </Button>
- </div>
- </div>
- </PopoverContent>
- </Popover>
- )
-}
diff --git a/apps/studio/components/interfaces/Reports/useReportFilters.ts b/apps/studio/components/interfaces/Reports/useReportFilters.ts
deleted file mode 100644
index a913df57453..00000000000
--- a/apps/studio/components/interfaces/Reports/useReportFilters.ts
+++ /dev/null
@@ -1,328 +0,0 @@
-import { parseAsString, useQueryStates } from 'nuqs'
-import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
-
-import type { ReportFilter, ReportFilterItem, ReportFilterProperty } from './Reports.types'
-
-export enum ReportFilterKeys {
- PATH = 'request.path',
- SEARCH = 'request.search',
- X_CLIENT_INFO = 'request.headers.x_client_info',
- USER_AGENT = 'request.headers.user_agent',
- STATUS_CODE = 'response.status_code',
-}
-
-export const REPORT_FILTER_PARAMS_PARSER = {
- [ReportFilterKeys.PATH]: parseAsString,
- [ReportFilterKeys.SEARCH]: parseAsString,
- [ReportFilterKeys.X_CLIENT_INFO]: parseAsString,
- [ReportFilterKeys.USER_AGENT]: parseAsString,
- [ReportFilterKeys.STATUS_CODE]: parseAsString,
-}
-
-interface UseReportFiltersProps {
- onAddFilter: (filter: ReportFilterItem) => void
- onRemoveFilters: (filters: ReportFilterItem[]) => void
- filters: ReportFilterItem[]
-}
-
-export const useReportFilters = ({
- onAddFilter,
- onRemoveFilters,
- filters,
-}: UseReportFiltersProps) => {
- // URL-safe operator mappings
- const URL_OPERATOR_MAP = {
- '=': 'eq',
- '!=': 'neq',
- '>=': 'gte',
- '<=': 'lte',
- '>': 'gt',
- '<': 'lt',
- CONTAINS: 'contains',
- 'STARTS WITH': 'startswith',
- 'ENDS WITH': 'endswith',
- }
-
- const REVERSE_URL_OPERATOR_MAP = Object.fromEntries(
- Object.entries(URL_OPERATOR_MAP).map(([k, v]) => [v, k])
- )
-
- // Parse encoded filter value (e.g., "gte:300" -> { operator: ">=", value: "300" })
- const parseFilterValue = useCallback((encodedValue: string | number | null) => {
- if (!encodedValue || typeof encodedValue !== 'string') {
- return { operator: '=', value: encodedValue?.toString() || '' }
- }
-
- const parts = encodedValue.split(':')
- if (parts.length === 2) {
- const [urlOperator, value] = parts
- const operator = REVERSE_URL_OPERATOR_MAP[urlOperator] || '='
- return { operator, value }
- }
-
- return { operator: '=', value: encodedValue }
- }, [])
-
- const encodeFilterValue = useCallback((operator: string | number, value: string | number) => {
- const urlOperator = URL_OPERATOR_MAP[operator as keyof typeof URL_OPERATOR_MAP] || 'eq'
- return `${urlOperator}:${value}`
- }, [])
-
- // Convert query filters to ReportFilter format
- const convertQueryFiltersToReportFilters = useCallback(
- (queryState: Record<string, string | number | null>): ReportFilter[] => {
- const filters: ReportFilter[] = []
-
- Object.entries(queryState).forEach(([key, value]) => {
- if (value !== null && value !== undefined && value !== '') {
- const { operator, value: filterValue } = parseFilterValue(value)
- filters.push({
- propertyName: key,
- value: filterValue,
- operator: operator,
- })
- }
- })
-
- return filters
- },
- [parseFilterValue]
- )
-
- // Convert operator from FilterBar format to ReportFilterItem format
- const getCompareOperator = useCallback(
- (operator: string | number): 'matches' | 'is' | '>=' | '<=' | '>' | '<' | '!=' => {
- switch (operator) {
- case '=':
- return 'is'
- case '!=':
- return '!='
- case '>=':
- return '>='
- case '<=':
- return '<='
- case '>':
- return '>'
- case '<':
- return '<'
- case 'CONTAINS':
- case 'STARTS WITH':
- case 'ENDS WITH':
- return 'matches'
- default:
- return 'matches'
- }
- },
- []
- )
-
- // Convert ReportFilter to ReportFilterItem format for the report system
- const convertReportFiltersToReportFilterItems = useMemo(
- () =>
- (reportFilters: ReportFilter[]): ReportFilterItem[] => {
- const reportFilterItems: ReportFilterItem[] = []
-
- reportFilters.forEach((filter) => {
- if (filter.value !== null && filter.value !== '' && filter.value !== undefined) {
- reportFilterItems.push({
- key: filter.propertyName.toString(),
- value: filter.value.toString(),
- compare: getCompareOperator(filter.operator),
- })
- }
- })
-
- return reportFilterItems
- },
- [getCompareOperator]
- )
-
- // Convert ReportFilter back to query filters format
- const convertReportFiltersToQueryFilters = useMemo(
- () => (reportFilters: ReportFilter[]) => {
- const queryUpdate: Record<string, string | number | null> = {}
-
- // Clear all existing filters first
- Object.keys(REPORT_FILTER_PARAMS_PARSER).forEach((key) => {
- queryUpdate[key] = null
- })
-
- // Add new filters with encoded operator+value
- reportFilters.forEach((filter) => {
- if (filter.propertyName in REPORT_FILTER_PARAMS_PARSER) {
- const encodedValue = encodeFilterValue(filter.operator, filter.value as string | number)
- queryUpdate[filter.propertyName] = encodedValue
- }
- })
-
- return queryUpdate
- },
- [encodeFilterValue]
- )
-
- const [queryFilters, setQueryFilters] = useQueryStates(REPORT_FILTER_PARAMS_PARSER)
- const [localFilters, setLocalFilters] = useState<ReportFilter[]>([])
-
- const [isInitialized, setIsInitialized] = useState(false)
- const lastAppliedFilterState = useRef<string>('')
- const preventUrlSync = useRef(false)
-
- // Initialize local state from URL params (only once on mount)
- useEffect(() => {
- if (!isInitialized) {
- const initialFilters = convertQueryFiltersToReportFilters(queryFilters)
- setLocalFilters(initialFilters)
- setIsInitialized(true)
- }
- }, [isInitialized, convertQueryFiltersToReportFilters, queryFilters])
-
- // Sync URL changes back to local state (when URL changes externally)
- useEffect(() => {
- if (!isInitialized || preventUrlSync.current) return
-
- const filtersFromUrl = convertQueryFiltersToReportFilters(queryFilters)
- const currentFilterJson = JSON.stringify(localFilters)
- const urlFilterJson = JSON.stringify(filtersFromUrl)
-
- if (currentFilterJson !== urlFilterJson) {
- console.log('Syncing local filters from URL change:', { filtersFromUrl, localFilters })
- setLocalFilters(filtersFromUrl)
- }
- }, [queryFilters, isInitialized, convertQueryFiltersToReportFilters])
-
- // Sync local filter changes back to URL state (only after initialization)
- useEffect(() => {
- if (!isInitialized) return
-
- const queryUpdate = convertReportFiltersToQueryFilters(localFilters)
-
- // Prevent feedback loop during URL updates
- preventUrlSync.current = true
- setQueryFilters(queryUpdate).finally(() => {
- preventUrlSync.current = false
- })
- }, [localFilters, isInitialized, setQueryFilters, convertReportFiltersToQueryFilters])
-
- // Separate effect for report filter updates (only for filters with values)
- useEffect(() => {
- if (!isInitialized) return
-
- const reportFilterItems = convertReportFiltersToReportFilterItems(localFilters)
-
- // Create a state string for comparison (only for the filters we manage)
- const newFilterState = reportFilterItems
- .map((filter) => `${filter.key}:${filter.value}:${filter.compare}`)
- .sort()
- .join('|')
-
- if (lastAppliedFilterState.current !== newFilterState) {
- lastAppliedFilterState.current = newFilterState
-
- // Separate product filters (managed by dropdown) from other filters (managed by ReportFilterPopover)
- const PRODUCT_FILTER_KEYS = ['request.path']
- const PRODUCT_FILTER_VALUES = ['/rest', '/auth', '/storage', '/realtime', '/graphql']
-
- const productFilters = filters.filter(
- (f) =>
- PRODUCT_FILTER_KEYS.includes(f.key) && PRODUCT_FILTER_VALUES.includes(f.value.toString())
- )
- const otherFilters = filters.filter(
- (f) =>
- !(
- PRODUCT_FILTER_KEYS.includes(f.key) &&
- PRODUCT_FILTER_VALUES.includes(f.value.toString())
- )
- )
-
- console.log('Filter Update:', {
- localFilters,
- reportFilterItems,
- productFilters,
- otherFilters,
- newFilterState,
- })
-
- // Remove only the non-product filters that we manage
- if (otherFilters.length > 0) {
- onRemoveFilters(otherFilters)
- }
-
- // Add all the new filters from the popover
- reportFilterItems.forEach((filter) => onAddFilter(filter))
- }
- }, [localFilters, isInitialized])
-
- const handleFilterChange = (newFilters: ReportFilter[]) => {
- console.log('handleFilterChange called with:', newFilters)
- setLocalFilters(newFilters)
- }
-
- // Get filter properties based on product type
- const getFilterProperties = (): ReportFilterProperty[] => {
- const baseProperties: ReportFilterProperty[] = [
- {
- label: 'Status Code',
- name: ReportFilterKeys.STATUS_CODE,
- type: 'number' as const,
- options: [
- { label: '200', value: '200' },
- { label: '300', value: '300' },
- { label: '400', value: '400' },
- { label: '401', value: '401' },
- { label: '403', value: '403' },
- { label: '404', value: '404' },
- { label: '409', value: '409' },
- { label: '411', value: '411' },
- { label: '413', value: '413' },
- { label: '416', value: '416' },
- { label: '423', value: '423' },
- { label: '500', value: '500' },
- { label: '503', value: '503' },
- { label: '504', value: '504' },
- ],
- operators: ['=', '!=', '>', '<', '>=', '<='],
- placeholder: '200',
- },
- {
- label: 'User Agent',
- name: ReportFilterKeys.USER_AGENT,
- type: 'string' as const,
- operators: ['=', '!=', 'CONTAINS', 'STARTS WITH', 'ENDS WITH'],
- placeholder:
- 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36',
- },
- {
- label: 'Search Params',
- name: ReportFilterKeys.SEARCH,
- type: 'string' as const,
- operators: ['=', '!=', 'CONTAINS', 'STARTS WITH', 'ENDS WITH'],
- placeholder: '?foo=bar',
- },
- {
- label: 'Client Info',
- name: ReportFilterKeys.X_CLIENT_INFO,
- type: 'string' as const,
- operators: ['=', '!=', 'CONTAINS', 'STARTS WITH', 'ENDS WITH'],
- placeholder: 'supabase-js/1.0.0',
- },
- ]
-
- return [
- {
- label: 'Path',
- name: ReportFilterKeys.PATH,
- type: 'string' as const,
- operators: ['=', '!=', 'CONTAINS', 'STARTS WITH', 'ENDS WITH'],
- placeholder: '/rest/v1/tablename',
- },
- ...baseProperties,
- ]
- }
-
- return {
- localFilters,
- filterProperties: getFilterProperties(),
- handleFilterChange,
- ReportFilterKeys,
- }
-}
diff --git a/packages/ui/src/components/Input/Input.module.css b/packages/ui/src/components/Input/Input.module.css
deleted file mode 100644
index 7469c5600a5..00000000000
--- a/packages/ui/src/components/Input/Input.module.css
+++ /dev/null
@@ -1,68 +0,0 @@
-/* .sbui-input-container {
- @apply relative;
-} */
-
-/* .sbui-input {
- @apply block box-border pl-3 pr-3 py-2 w-full rounded-md shadow-xs text-sm border border-solid transition-all;
- @apply bg-white text-input-value-light border-input-border-light;
- @apply focus:ring-input-border-focus-light focus:border-input-border-focus-light focus:outline-hidden;
-
- @apply dark:bg-transparent dark:text-input-value-dark dark:border-input-border-dark;
- @apply dark:focus:border-input-border-focus-dark dark:focus:ring-input-border-focus-dark;
-
-
- font-family: inherit;
- transition: box-shadow 0.3s ease-in-out;
-} */
-
-/* .sbui-input:focus {
- box-shadow: 0 0 0 2px rgba(62, 207, 142, 0.1);
-} */
-
-/* .sbui-input--error {
- @apply border-red-500 dark:border-red-500;
-}
-
-.sbui-input--borderless {
- @apply border-transparent shadow-none;
-}
-
-.sbui-input-actions-container {
- @apply absolute inset-y-0 right-0 pl-3 pr-1 flex items-center;
-} */
-
-.sbui-textarea-actions-container {
- @apply absolute inset-y-1 right-0 pl-3 pr-1 flex items-start;
-}
-
-.sbui-textarea-actions-container__items {
- @apply flex items-center;
-}
-
-/*
- Input sizes
-*/
-
-/* .sbui-input--tiny {
- @apply px-2.5 py-1.5 text-xs;
-}
-.sbui-input--small {
- @apply px-3 py-2 text-sm leading-4;
-}
-.sbui-input--medium {
- @apply px-4 py-2 text-sm;
-}
-.sbui-input--large {
- @apply px-4 py-2 text-base;
-}
-.sbui-input--xlarge {
- @apply px-6 py-3 text-base;
-} */
-
-/*
- Input icon
-*/
-
-/* .sbui-input--with-icon {
- @apply pl-7;
-} */
diff --git a/packages/ui/src/components/Input/Input.tsx b/packages/ui/src/components/Input/Input.tsx
deleted file mode 100644
index c8b4568ee1a..00000000000
--- a/packages/ui/src/components/Input/Input.tsx
+++ /dev/null
@@ -1,287 +0,0 @@
-'use client'
-
-import { Copy } from 'lucide-react'
-import React, { useState } from 'react'
-
-import { HIDDEN_PLACEHOLDER } from '../../lib/constants'
-import { FormLayout } from '../../lib/Layout/FormLayout/FormLayout'
-import InputErrorIcon from '../../lib/Layout/InputErrorIcon'
-import InputIconContainer from '../../lib/Layout/InputIconContainer'
-import styleHandler from '../../lib/theme/styleHandler'
-import { copyToClipboard } from '../../lib/utils'
-import { cn } from '../../lib/utils/cn'
-import { Button } from '../Button'
-
-export interface Props extends Omit<
- React.InputHTMLAttributes<HTMLInputElement>,
- 'size' | 'onCopy'
-> {
- inputClassName?: string
- iconContainerClassName?: string
- copy?: boolean
- onCopy?: () => void
- defaultValue?: string | number
- descriptionText?: string | React.ReactNode | undefined
- disabled?: boolean
- error?: string
- icon?: any
- inputRef?: React.LegacyRef<HTMLInputElement>
- label?: string | React.ReactNode
- afterLabel?: string
- beforeLabel?: string
- labelOptional?: string | React.ReactNode
- layout?: 'horizontal' | 'vertical'
- reveal?: boolean
- actions?: React.ReactNode
- size?: 'tiny' | 'small' | 'medium' | 'large' | 'xlarge'
- borderless?: boolean
- validation?: (x: any) => void
-}
-
-/**
- * @deprecated Use `import { Input } from 'ui'` instead or `import { Input } from 'ui-patterns/DataInputs/Input'`
- */
-function Input({
- autoComplete,
- autoFocus,
- className,
- inputClassName,
- iconContainerClassName,
- copy,
- defaultValue,
- descriptionText,
- disabled,
- error,
- icon,
- id = '',
- name = '',
- inputRef,
- label,
- afterLabel,
- beforeLabel,
- labelOptional,
- layout,
- onCopy,
- placeholder,
- type = 'text',
- value = undefined,
- style,
- reveal = false,
- actions,
- size = 'medium',
- borderless = false,
- validation,
- ...props
-}: Props) {
- const [copyLabel, setCopyLabel] = useState('Copy')
- const [hidden, setHidden] = useState(true)
-
- const __styles = styleHandler('input')
-
- function _onCopy(value: any) {
- copyToClipboard(value, () => {
- setCopyLabel('Copied')
- setTimeout(() => {
- setCopyLabel('Copy')
- }, 3000)
- onCopy?.()
- })
- }
-
- function onReveal() {
- setHidden(false)
- }
-
- let inputClasses = ['peer/input', __styles.base]
-
- if (error) inputClasses.push(__styles.variants.error)
- if (!error) inputClasses.push(__styles.variants.standard)
- if (size) inputClasses.push(__styles.size[size])
- if (icon) inputClasses.push(__styles.with_icon[size])
- if (disabled) inputClasses.push(__styles.disabled)
- if (inputClassName) inputClasses.push(inputClassName)
-
- return (
- <FormLayout
- label={label}
- afterLabel={afterLabel}
- beforeLabel={beforeLabel}
- labelOptional={labelOptional}
- layout={layout}
- id={id}
- error={error}
- descriptionText={descriptionText}
- style={style}
- size={size}
- className={className}
- >
- <div className={__styles.container}>
- <input
- data-size={size}
- autoComplete={autoComplete}
- autoFocus={autoFocus}
- defaultValue={defaultValue}
- disabled={disabled}
- id={id}
- name={name}
- onCopy={onCopy}
- placeholder={placeholder}
- ref={inputRef}
- type={type}
- value={reveal && hidden ? HIDDEN_PLACEHOLDER : value}
- className={cn(inputClasses)}
- {...props}
- />
- {icon && <InputIconContainer size={size} icon={icon} className={iconContainerClassName} />}
- {copy || error || actions ? (
- <div className={__styles.actions_container}>
- {error && <InputErrorIcon size={size} />}
- {copy && !(reveal && hidden) ? (
- <Button size="tiny" variant="default" icon={<Copy />} onClick={() => _onCopy(value)}>
- {copyLabel}
- </Button>
- ) : null}
- {reveal && hidden ? (
- <Button size="tiny" variant="default" onClick={onReveal}>
- Reveal
- </Button>
- ) : null}
- {actions && actions}
- </div>
- ) : null}
- </div>
- </FormLayout>
- )
-}
-
-/**
- * @deprecated Use ./TextArea_Shadcn_ instead
- */
-export interface TextAreaProps extends Omit<
- React.InputHTMLAttributes<HTMLTextAreaElement>,
- 'size' | 'onCopy'
-> {
- textAreaClassName?: string
- descriptionText?: string | React.ReactNode | undefined
- error?: string
- icon?: any
- label?: string | React.ReactNode
- afterLabel?: string
- beforeLabel?: string
- labelOptional?: string | React.ReactNode
- layout?: 'horizontal' | 'vertical'
- rows?: number
- limit?: number
- size?: 'tiny' | 'small' | 'medium' | 'large' | 'xlarge'
- borderless?: boolean
- validation?: (x: any) => void
- copy?: boolean
- onCopy?: () => void
- actions?: React.ReactNode
-}
-
-function TextArea({
- className,
- textAreaClassName,
- descriptionText,
- disabled,
- error,
- icon,
- id = '',
- name = '',
- label,
- afterLabel,
- beforeLabel,
- labelOptional,
- layout,
- placeholder,
- value,
- style,
- rows = 4,
- limit,
- size = 'medium',
- borderless = false,
- validation,
- copy = false,
- onCopy,
- actions,
- ...props
-}: TextAreaProps) {
- const [copyLabel, setCopyLabel] = useState('Copy')
-
- function _onCopy(value: any) {
- copyToClipboard(value, () => {
- /* clipboard successfully set */
- setCopyLabel('Copied')
- setTimeout(() => {
- setCopyLabel('Copy')
- }, 3000)
- onCopy?.()
- })
- }
-
- const __styles = styleHandler('input')
-
- let classes = [__styles.base]
-
- if (error) classes.push(__styles.variants.error)
- if (!error) classes.push(__styles.variants.standard)
- if (icon) classes.push(__styles.with_icon[size])
- if (size) classes.push(__styles.size[size])
- if (disabled) classes.push(__styles.disabled)
- if (textAreaClassName) classes.push(textAreaClassName)
-
- return (
- <FormLayout
- className={className}
- label={label}
- afterLabel={afterLabel}
- beforeLabel={beforeLabel}
- labelOptional={labelOptional}
- layout={layout}
- id={id}
- error={error}
- descriptionText={descriptionText}
- style={style}
- size={size}
- >
- <div className={__styles.container}>
- <textarea
- disabled={disabled}
- id={id}
- name={name}
- rows={rows}
- cols={100}
- placeholder={placeholder}
- onCopy={onCopy}
- value={value}
- className={classes.join(' ')}
- maxLength={limit}
- {...props}
- />
- {copy || error || actions ? (
- <div className={__styles['textarea_actions_container']}>
- <div className={__styles['textarea_actions_container_items']}>
- {error && <InputErrorIcon size={size} />}
- {copy && (
- <Button
- size="tiny"
- variant="default"
- onClick={() => _onCopy(value)}
- icon={<Copy />}
- >
- {copyLabel}
- </Button>
- )}
- {actions && actions}
- </div>
- </div>
- ) : null}
- </div>
- </FormLayout>
- )
-}
-
-Input.TextArea = TextArea
-
-export default Input
diff --git a/packages/ui/src/components/Input/index.tsx b/packages/ui/src/components/Input/index.tsx
deleted file mode 100644
index ae5c54e5bfb..00000000000
--- a/packages/ui/src/components/Input/index.tsx
+++ /dev/null
@@ -1 +0,0 @@
-export { default as Input } from './Input'
diff --git a/packages/ui/src/lib/theme/defaultTheme.ts b/packages/ui/src/lib/theme/defaultTheme.ts
index eed1660ab06..b6d98ec90ed 100644
--- a/packages/ui/src/lib/theme/defaultTheme.ts
+++ b/packages/ui/src/lib/theme/defaultTheme.ts
@@ -66,14 +66,6 @@ const default__padding_and_text = {
xlarge: `${defaults.size.text.xlarge} ${defaults.size.padding.xlarge}`,
}
-const with_icon_spacing_sizes = {
- tiny: 'pl-7',
- small: 'pl-8',
- medium: 'pl-8',
- large: 'pl-10',
- xlarge: 'pl-11',
-}
-
/*
* Main tailwind utility classes output
*
@@ -200,50 +192,6 @@ export default {
content: `focus:outline-hidden transition-height`,
},
- /*
- * Input
- */
-
- input: {
- base: `
- block
- box-border
- w-full
- rounded-md
- shadow-xs
- transition-all
- text-foreground
- border
- focus-visible:shadow-md
- ${defaults.focus}
- focus-visible:border-foreground-muted
- focus-visible:ring-background-control
- ${defaults.placeholder}
- group
- `,
- variants: {
- standard: `
- bg-foreground/[.026]
- border border-control
- `,
- error: `
- bg-destructive-200
- border border-destructive-500
- focus:ring-destructive-400
- placeholder:text-destructive-400
- `,
- },
- container: 'relative',
- with_icon: with_icon_spacing_sizes,
- size: {
- ...default__padding_and_text,
- },
- disabled: 'opacity-50',
- actions_container: 'absolute inset-y-0 right-0 pl-3 pr-1 flex space-x-1 items-center',
- textarea_actions_container: 'absolute inset-y-1.5 right-0 pl-3 pr-1 flex space-x-1 items-start',
- textarea_actions_container_items: 'flex items-center',
- },
-
sidepanel: {
base: `
z-50