The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
chore: Fix the types in the `ui` package (#19633)
Ivan Vasilovacdacbadcd74
diff --git a/packages/ui/package.json b/packages/ui/package.jsonindex f72a904d316..dad38427a70 100644--- a/packages/ui/package.json+++ b/packages/ui/package.json@@ -7,7 +7,7 @@"sideEffects": false,"scripts": {"build:icons": "node --experimental-modules internals/populate-icons.js",- "typecheck_CURRENTLY_IGNORED": "tsc --noEmit",+ "typecheck": "tsc --noEmit","generate-demo-tailwind-classes": "node internals/tokens/generate-demo-tailwind-classes.js","cleanse-css-for-tailwind": "node internals/tokens/cleanse-css-for-tailwind.js","transform-tokens": "node ./transformTokens.js",diff --git a/packages/ui/src/components/Avatar/Avatar.module.css b/packages/ui/src/components/Avatar/Avatar.module.cssdeleted file mode 100644index 652b2bd74c2..00000000000--- a/packages/ui/src/components/Avatar/Avatar.module.css+++ /dev/null@@ -1,65 +0,0 @@-.sbui-avatar {- @apply rounded-full;-}--.sbui-avatar-type-rounded {- border-radius: 10%;-}--.sbui-avatar-type-square {- border-radius: 0;-}--.sbui-avatar-image {- object-fit: 'contain';- border-radius: '50%';- height: 3rem;- width: 3rem;-}--.sbui-avatar-children {- @apply flex;- @apply justify-center;- @apply items-center-}--.sbui-avatar-icon {- @apply flex;- @apply justify-center;- @apply items-center;- background-color: cadetblue;- height: 3rem;- width: 3rem;-}--.sbui-avatar-text {- @apply flex;- @apply justify-center;- @apply items-center;- background-color: cadetblue;- float: left;- height: 3rem;- width: 3rem;-}--.sbui-avatar-fallback {- @apply flex;- @apply justify-center;- @apply items-center;- background-color: cadetblue;- height: 3rem;- width: 3rem;-}--.sbui-avatar-single {--}--.sbui-avatar-multiple {--}--.sbui-image-responsive {- width: 100%;- height: auto;-}diff --git a/packages/ui/src/components/Avatar/Avatar.stories.tsx b/packages/ui/src/components/Avatar/Avatar.stories.tsxdeleted file mode 100644index a9c73a60ce0..00000000000--- a/packages/ui/src/components/Avatar/Avatar.stories.tsx+++ /dev/null@@ -1,60 +0,0 @@-import React from 'react'-import { IconAirplay } from '../Icon/icons/IconAirplay'--import Avatar, { AvatarProps } from './Avatar'--export default {- title: 'General/Avatar',- component: Avatar,-}--export const Image = (args: AvatarProps) => {- return (- <>- <Avatar {...args} />- </>- )-}--export const Text = (args: AvatarProps) => {- return (- <>- <Avatar {...args} />- </>- )-}--export const Icon = (args: AvatarProps) => {- return (- <>- <Avatar {...args} />- </>- )-}--export const Fallback = (args: AvatarProps) => {- return (- <>- <Avatar {...args} />- </>- )-}--Image.args = {- active: true,- src: 'https://via.placeholder.com/150',-}--Text.args = {- active: true,- text: 'Shoury',-}--Icon.args = {- active: true,- Icon: IconAirplay,-}--Fallback.args = {- active: true,-}diff --git a/packages/ui/src/components/Avatar/Avatar.tsx b/packages/ui/src/components/Avatar/Avatar.tsxdeleted file mode 100644index 0eec2a12a02..00000000000--- a/packages/ui/src/components/Avatar/Avatar.tsx+++ /dev/null@@ -1,87 +0,0 @@-import React from 'react'-import { Icon } from '../Icon/IconImportHandler'-import { IconUser } from '../Icon/icons/IconUser'-import AvatarStyles from './Avatar.module.css'--export interface AvatarProps {- children?: React.ReactNode- src?: string | undefined- style?: React.CSSProperties- className?: string- alt?: string- text?: string- AvatarIcon?: Icon- size: number-}--export default function Avatar({- src,- style,- className,- alt,- text,- AvatarIcon,- size,- children,-}: AvatarProps) {- const classes = [AvatarStyles['sbui-avatar']]- classes.push(className)- let objectToRender-- const imageExist = () => {- const img = new Image()- img.src = src- if (img.complete) {- return true- } else {- img.onload = () => {- return true- }- img.onerror = () => {- return false- }- }- }-- if (imageExist && src) {- classes.push(AvatarStyles['sbui-avatar-image'])- objectToRender = (- <img- className={classes.join(' ')}- src={src}- alt={alt}- style={{ height: size, width: size, ...style }}- />- )- } else if (AvatarIcon) {- classes.push(AvatarStyles['sbui-avatar-icon'])- objectToRender = (- <div className={classes.join(' ')} style={{ height: size, width: size, ...style }}>- <AvatarIcon />- </div>- )- } else if (text) {- classes.push(AvatarStyles['sbui-avatar-text'])- objectToRender = (- <div className={classes.join(' ')} style={{ height: size, width: size, ...style }}>- <p>{text[0]}</p>- </div>- )- } else if (children) {- classes.push(AvatarStyles['sbui-avatar-children'])- objectToRender = (- <div className={classes.join(' ')} style={{ height: size, width: size, ...style }}>- {children}- </div>- )- } else {- classes.push(AvatarStyles['sbui-avatar-fallback'])- objectToRender = (- <div className={classes.join(' ')} style={{ height: size, width: size, ...style }}>- <IconUser />- </div>- )- }-- return <>{objectToRender}</>-}diff --git a/packages/ui/src/components/Avatar/index.tsx b/packages/ui/src/components/Avatar/index.tsxdeleted file mode 100644index 6383d3a6c94..00000000000--- a/packages/ui/src/components/Avatar/index.tsx+++ /dev/null@@ -1 +0,0 @@-export { default as Image } from './Avatar'diff --git a/packages/ui/src/components/Form/examples/AuthForm.tsx b/packages/ui/src/components/Form/examples/AuthForm.tsxindex 8b69618c365..6d81383a78d 100644--- a/packages/ui/src/components/Form/examples/AuthForm.tsx+++ b/packages/ui/src/components/Form/examples/AuthForm.tsx@@ -112,7 +112,7 @@ const CardForm = () => {setSubmitting(false)}, 400)}}- validate={(values: Values) => {+ validate={(values) => {const errors: any = {}if (!values.jwt_expiry) {errors.jwt_expiry = 'This is required'@@ -185,7 +185,7 @@ AuthFormSchema.map((provider) => {console.log('form initialState', initialState)-function providersReducer(state, action) {+function providersReducer(state: any, action: any) {switch (action.type) {case 'update':return Object.assign(state, action.values)@@ -483,7 +483,7 @@ console.log('form domainInitialState', domainInitialState)// }// }-function domainsReducer(state, action) {+function domainsReducer(state: any, action: any) {let _state = []switch (action.type) {case 'update':@@ -782,7 +782,7 @@ const SmtpForm = () => {setSubmitting(false)}, 400)}}- validate={(values: Values) => {+ validate={(values) => {const errors: any = {}if (!values.jwt_expiry) {errors.jwt_expiry = 'This is required'@@ -923,7 +923,7 @@ const TemplatesForm = () => {setSubmitting(false)}, 400)}}- validate={(values: Values) => {+ validate={(values) => {const errors: any = {}if (!values.jwt_expiry) {errors.jwt_expiry = 'This is required'diff --git a/packages/ui/src/components/Toast/Toast.tsx b/packages/ui/src/components/Toast/Toast.tsxindex 6841327e2a7..2e8d90e5450 100644--- a/packages/ui/src/components/Toast/Toast.tsx+++ b/packages/ui/src/components/Toast/Toast.tsx@@ -1,21 +1,26 @@-import React, { ComponentProps } from 'react'-import { Toaster as HotToaster, toast as hotToast, resolveValue } from 'react-hot-toast'-import { Toast as HotToastProps, ToastType } from 'react-hot-toast/dist/core/types'import * as Portal from '@radix-ui/react-portal'+import React, { ComponentProps } from 'react'+import {+ Toast as HotToastProps,+ Toaster as HotToaster,+ ToastType,+ toast as hotToast,+ resolveValue,+} from 'react-hot-toast'+import { IconAlertCircle } from '../Icon/icons/IconAlertCircle'import { IconCheck } from '../Icon/icons/IconCheck'import { IconLoader } from '../Icon/icons/IconLoader'import { IconX } from '../Icon/icons/IconX'-import { IconAlertCircle } from '../Icon/icons/IconAlertCircle'// @ts-ignore-import ToastStyles from './Toast.module.css'import Typography from '../Typography'+import ToastStyles from './Toast.module.css'const icons: Partial<{ [key in ToastType]: any }> = {error: <IconAlertCircle size="medium" strokeWidth={2} />,success: <IconCheck size="medium" strokeWidth={2} />,}-export interface ToastProps extends Partial<HotToastProps> {+export interface ToastProps extends HotToastProps {description?: stringclosable?: booleanactions?: React.ReactNode@@ -84,7 +89,11 @@ function Toast({}const _message =- typeof message === 'string' ? <Message>{message}</Message> : resolveValue(message, rest)+ typeof message === 'string' ? (+ <Message>{message}</Message>+ ) : (+ resolveValue(message, { id, type, message, visible, ...rest })+ )return (<div className={`${containerClasses.join(' ')} ${visible ? 'animate-enter' : 'animate-leave'}`}>@@ -140,7 +149,7 @@ function Toaster({ children }: ToasterProps) {typeof message === 'string' ? (<Toast message={message} {...t} />) : (- <>{resolveValue(message, t)}</>+ <>{resolveValue(message, { message, ...t })}</>)}</HotToaster>@@ -179,7 +188,7 @@ export function toast(message: string, opts?: ToastOptions) {closable={closable}actions={actions}actionsPosition={actionsPosition}- type={type}+ type={type || 'success'}{...t}/>),diff --git a/packages/ui/src/components/shadcn/stories/DataTable.storiesFIX LATER.tsx b/packages/ui/src/components/shadcn/stories/DataTable.stories.tsxsimilarity index 100%rename from packages/ui/src/components/shadcn/stories/DataTable.storiesFIX LATER.tsxrename to packages/ui/src/components/shadcn/stories/DataTable.stories.tsxdiff --git a/packages/ui/src/components/shadcn/ui/alert-dialog.tsx b/packages/ui/src/components/shadcn/ui/alert-dialog.tsxindex 71c847615fa..176e969a5c1 100644--- a/packages/ui/src/components/shadcn/ui/alert-dialog.tsx+++ b/packages/ui/src/components/shadcn/ui/alert-dialog.tsx@@ -10,12 +10,8 @@ const AlertDialog = AlertDialogPrimitive.Rootconst AlertDialogTrigger = AlertDialogPrimitive.Trigger-const AlertDialogPortal = ({- className,- children,- ...props-}: AlertDialogPrimitive.AlertDialogPortalProps) => (- <AlertDialogPrimitive.Portal className={cn(className)} {...props}>+const AlertDialogPortal = ({ children, ...props }: AlertDialogPrimitive.AlertDialogPortalProps) => (+ <AlertDialogPrimitive.Portal {...props}><div className="fixed inset-0 z-50 flex items-end justify-center sm:items-center">{children}</div>diff --git a/packages/ui/src/lib/Form/Form.utils.ts b/packages/ui/src/lib/Form/Form.utils.tsdeleted file mode 100644index b167d4fac4c..00000000000--- a/packages/ui/src/lib/Form/Form.utils.ts+++ /dev/null@@ -1,4 +0,0 @@-export function validator(value) {- const _validation = validation(_value)- fieldLevelValidation(id, _validation)-}diff --git a/packages/ui/tsconfig.json b/packages/ui/tsconfig.jsonindex da20469057f..7d823d01907 100644--- a/packages/ui/tsconfig.json+++ b/packages/ui/tsconfig.json@@ -8,5 +8,5 @@}},"include": ["."],- "exclude": ["dist", "build", "node_modules"]+ "exclude": ["dist", "build", "node_modules", "**/*.stories.tsx"]}