The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
started moving Button over
Jonathan Summers-Muirb68f1de1b311
diff --git a/package-lock.json b/package-lock.jsonindex 52b222b705b..f17479dc837 100644--- a/package-lock.json+++ b/package-lock.json@@ -18803,6 +18803,33 @@"node": ">=0.10.0"}},+ "node_modules/class-variance-authority": {+ "version": "0.6.0",+ "resolved": "https://registry.npmjs.org/class-variance-authority/-/class-variance-authority-0.6.0.tgz",+ "integrity": "sha512-qdRDgfjx3GRb9fpwpSvn+YaidnT7IUJNe4wt5/SWwM+PmUwJUhQRk/8zAyNro0PmVfmen2635UboTjIBXXxy5A==",+ "dependencies": {+ "clsx": "1.2.1"+ },+ "funding": {+ "url": "https://joebell.co.uk"+ },+ "peerDependencies": {+ "typescript": ">= 4.5.5 < 6"+ },+ "peerDependenciesMeta": {+ "typescript": {+ "optional": true+ }+ }+ },+ "node_modules/class-variance-authority/node_modules/clsx": {+ "version": "1.2.1",+ "resolved": "https://registry.npmjs.org/clsx/-/clsx-1.2.1.tgz",+ "integrity": "sha512-EcR6r5a8bj6pu3ycsa/E/cKVGuTgZJZdsyUYHOksG/UHIiKfjxzRxYJpyVBwYaQeOvghal9fcc4PidlgzugAQg==",+ "engines": {+ "node": ">=6"+ }+ },"node_modules/classnames": {"version": "2.3.2","resolved": "https://registry.npmjs.org/classnames/-/classnames-2.3.2.tgz",@@ -45507,6 +45534,7 @@"@tailwindcss/forms": "^0.4.0","@tailwindcss/typography": "^0.5.0","autoprefixer": "^10.4.14",+ "class-variance-authority": "^0.6.0","clsx": "^1.2.1","cmdk-supabase": "^0.2.2","color": "^4.2.3",@@ -60387,6 +60415,21 @@}}},+ "class-variance-authority": {+ "version": "0.6.0",+ "resolved": "https://registry.npmjs.org/class-variance-authority/-/class-variance-authority-0.6.0.tgz",+ "integrity": "sha512-qdRDgfjx3GRb9fpwpSvn+YaidnT7IUJNe4wt5/SWwM+PmUwJUhQRk/8zAyNro0PmVfmen2635UboTjIBXXxy5A==",+ "requires": {+ "clsx": "1.2.1"+ },+ "dependencies": {+ "clsx": {+ "version": "1.2.1",+ "resolved": "https://registry.npmjs.org/clsx/-/clsx-1.2.1.tgz",+ "integrity": "sha512-EcR6r5a8bj6pu3ycsa/E/cKVGuTgZJZdsyUYHOksG/UHIiKfjxzRxYJpyVBwYaQeOvghal9fcc4PidlgzugAQg=="+ }+ }+ },"classnames": {"version": "2.3.2","resolved": "https://registry.npmjs.org/classnames/-/classnames-2.3.2.tgz",@@ -80001,6 +80044,7 @@"@types/react-dom": "^17.0.11","@types/react-syntax-highlighter": "^15.5.6","autoprefixer": "^10.4.14",+ "class-variance-authority": "*","clsx": "^1.2.1","cmdk-supabase": "^0.2.2","color": "^4.2.3",diff --git a/packages/ui/package.json b/packages/ui/package.jsonindex ce7073b768d..d3e425d8f3d 100644--- a/packages/ui/package.json+++ b/packages/ui/package.json@@ -30,6 +30,7 @@"@tailwindcss/forms": "^0.4.0","@tailwindcss/typography": "^0.5.0","autoprefixer": "^10.4.14",+ "class-variance-authority": "^0.6.0","clsx": "^1.2.1","cmdk-supabase": "^0.2.2","color": "^4.2.3",@@ -53,7 +54,6 @@"tailwindcss-radix": "^1.6.0"},"devDependencies": {- "config": "*","@babel/preset-env": "^7.21.4","@babel/preset-react": "^7.18.6","@babel/preset-typescript": "^7.21.4",@@ -62,13 +62,14 @@"@storybook/addon-styling": "^1.0.1","@storybook/react": "^7.0.5","@storybook/react-webpack5": "^7.0.5",- "@tokens-studio/sd-transforms": "^0.8.5","@testing-library/jest-dom": "^5.16.5",+ "@tokens-studio/sd-transforms": "^0.8.5","@types/common-tags": "^1.8.1","@types/react": "^17.0.37","@types/react-copy-to-clipboard": "^5.0.4","@types/react-dom": "^17.0.11","@types/react-syntax-highlighter": "^15.5.6",+ "config": "*","copyfiles": "^2.4.1","glob": "^8.1.0","sql-formatter": "^12.2.0",diff --git a/packages/ui/src/components/Button/Button-old.tsx b/packages/ui/src/components/Button/Button-old.tsxnew file mode 100644index 00000000000..145a9333ebb--- /dev/null+++ b/packages/ui/src/components/Button/Button-old.tsx@@ -0,0 +1,159 @@+import React, { forwardRef } from 'react'+import { IconContext } from './../Icon/IconContext'+import { IconLoader } from './../Icon/icons/IconLoader'++import styleHandler from '../../lib/theme/styleHandler'++export interface ButtonProps extends React.HTMLAttributes<HTMLButtonElement> {+ block?: boolean+ className?: string+ children?: React.ReactNode+ disabled?: boolean+ onClick?: React.MouseEventHandler<HTMLButtonElement>+ icon?: React.ReactNode+ iconRight?: React.ReactNode+ loading?: boolean+ loadingCentered?: boolean+ shadow?: boolean+ size?: ButtonSize+ style?: React.CSSProperties+ type?: ButtonType+ danger?: boolean+ htmlType?: 'button' | 'submit' | 'reset'+ ref?: any+ ariaSelected?: boolean+ ariaControls?: string+ tabIndex?: 0 | -1+ role?: string+ textAlign?: 'left' | 'center' | 'right'+ as?: keyof JSX.IntrinsicElements+ form?: string+}++export type ButtonSize = 'tiny' | 'small' | 'medium' | 'large' | 'xlarge'+export type ButtonType =+ | 'primary'+ | 'default'+ | 'secondary'+ | 'alternative'+ | 'outline'+ | 'dashed'+ | 'link'+ | 'text'+ | 'danger'+ | 'warning'++interface CustomButtonProps extends React.HTMLAttributes<HTMLButtonElement> {}++export const Button = forwardRef<HTMLButtonElement, ButtonProps>(+ (+ {+ block,+ className,+ children,+ danger,+ disabled = false,+ onClick,+ icon,+ iconRight,+ loading = false,+ loadingCentered = false,+ shadow = true,+ size = 'tiny',+ style,+ type = 'primary',+ htmlType = 'button',+ ariaSelected,+ ariaControls,+ tabIndex,+ role,+ as,+ textAlign = 'center',+ ...props+ }: ButtonProps,+ ref+ ) => {+ let __styles = styleHandler('button')++ // styles+ const showIcon = loading || icon++ let classes = [__styles.base]+ let containerClasses = [__styles.container]++ classes.push(__styles.type[type])++ if (block) {+ containerClasses.push(__styles.block)+ classes.push(__styles.block)+ }++ if (shadow && type !== 'link' && type !== 'text') {+ classes.push(__styles.shadow)+ }++ if (size) {+ classes.push(__styles.size[size])+ }++ if (className) {+ classes.push(className)+ }++ if (disabled) {+ classes.push(__styles.disabled)+ }++ const iconLoaderClasses = [__styles.loading]++ // custom button tag+ const CustomButton = ({ ...props }) => {+ const Tag = as as keyof JSX.IntrinsicElements+ return <Tag {...props} />+ }++ const buttonContent = (+ <>+ {showIcon &&+ (loading ? (+ <IconLoader size={size} className={iconLoaderClasses.join(' ')} />+ ) : icon ? (+ <IconContext.Provider value={{ contextSize: size }}>{icon}</IconContext.Provider>+ ) : null)}+ {children && <span className={__styles.label}>{children}</span>}+ {iconRight && !loading && (+ <IconContext.Provider value={{ contextSize: size }}>{iconRight}</IconContext.Provider>+ )}+ </>+ )++ if (as) {+ return (+ <CustomButton {...props} className={classes.join(' ')} onClick={onClick} style={style}>+ {buttonContent}+ </CustomButton>+ )+ } else {+ return (+ // <span ref={containerRef} className={containerClasses.join(' ')}>+ <button+ {...props}+ ref={ref}+ className={classes.join(' ')}+ disabled={loading || (disabled && true)}+ onClick={onClick}+ style={style}+ type={htmlType}+ aria-selected={ariaSelected}+ aria-controls={ariaControls}+ tabIndex={tabIndex}+ role={role}+ form={props.form}+ >+ {buttonContent}+ </button>+ // </span>+ )+ }+ }+)diff --git a/packages/ui/src/components/Button/Button.tsx b/packages/ui/src/components/Button/Button.tsxindex 145a9333ebb..ba48a5d2463 100644--- a/packages/ui/src/components/Button/Button.tsx+++ b/packages/ui/src/components/Button/Button.tsx@@ -1,159 +1,196 @@-import React, { forwardRef } from 'react'+import * as React from 'react'+import { Slot } from '@radix-ui/react-slot'+import { VariantProps, cva } from 'class-variance-authority'+import { IconContext } from './../Icon/IconContext'import { IconLoader } from './../Icon/icons/IconLoader'-import styleHandler from '../../lib/theme/styleHandler'+import { cn } from '@ui/lib/utils'+import { sizes } from '@ui/lib/commonCva'++export type ButtonVariantProps = VariantProps<typeof buttonVariantsNew>+const buttonVariantsNew = cva(+ `relative+ cursor-pointer+ inline-flex+ items-center+ space-x-2+ text-center+ font-regular+ ease-out+ duration-200+ rounded+ outline-none+ transition-all+ outline-0+ focus-visible:outline-4+ focus-visible:outline-offset-1`,+ {+ variants: {+ type: {+ primary: `+ bg-brand-fixed-1100 hover:bg-brand-fixed-1000+ text-white+ bordershadow-brand-fixed-1000 hover:bordershadow-brand-fixed-900 dark:bordershadow-brand-fixed-1000 dark:hover:bordershadow-brand-fixed-1000+ focus-visible:outline-brand-600+ shadow-sm`,+ secondary: `+ bg-scale-1200+ text-scale-100 hover:text-scale-800+ focus-visible:text-scale-600+ bordershadow-scale-1100 hover:bordershadow-scale-900+ focus-visible:outline-scale-700+ shadow-sm`,+ default: `+ text-scale-1200+ bg-scale-100 hover:bg-scale-300+ bordershadow-scale-600 hover:bordershadow-scale-700+ dark:bordershadow-scale-700 hover:dark:bordershadow-scale-800+ dark:bg-scale-500 dark:hover:bg-scale-600+ focus-visible:outline-brand-600+ shadow-sm`,+ alternative: `+ text-brand-1100+ bg-brand-200 hover:bg-brand-400+ bordershadow-brand-600 hover:bordershadow-brand-800+ dark:bordershadow-brand-700 hover:dark:bordershadow-brand-800+ focus-visible:border-brand-800+ focus-visible:outline-brand-600+ shadow-sm`,+ outline: `+ text-scale-1200+ bg-transparent+ bordershadow-scale-600 hover:bordershadow-scale-700+ dark:bordershadow-scale-800 hover:dark:bordershadow-scale-900+ focus-visible:outline-scale-700`,+ dashed: `+ text-scale-1200+ border+ border-dashed+ border-scale-700 hover:border-scale-900+ bg-transparent+ focus-visible:outline-scale-700+ shadow-sm`,+ link: `+ text-brand-1100+ border+ border-transparent+ hover:bg-brand-400+ border-opacity-0+ bg-opacity-0 dark:bg-opacity-0+ shadow-none+ focus-visible:outline-scale-700`,+ text: `+ text-scale-1200+ hover:bg-scale-500+ shadow-none+ focus-visible:outline-scale-700`,+ danger: `+ text-red-1100+ bg-red-200+ bordershadow-red-700 hover:bordershadow-red-900+ hover:bg-red-900+ hover:text-lo-contrast+ focus-visible:outline-red-700+ shadow-sm`,+ warning: `+ text-amber-1100+ bg-amber-200+ bordershadow-amber-700 hover:bordershadow-amber-900+ hover:bg-amber-900+ hover:text-hi-contrast+ focus-visible:outline-amber-700+ shadow-sm`,+ },+ block: {+ default: 'w-full flex items-center justify-center',+ },+ size: {+ ...sizes,+ },+ overlay: {+ base: `absolute inset-0 bg-scale-200 opacity-50`,+ container: `fixed inset-0 transition-opacity`,+ },+ disabled: {+ true: 'opacity-50 cursor-not-allowed pointer-events-none',+ },+ defaultVariants: {+ // variant: 'default',+ // size: 'default',+ },+ },+ }+)-export interface ButtonProps extends React.HTMLAttributes<HTMLButtonElement> {- block?: boolean- className?: string- children?: React.ReactNode- disabled?: boolean- onClick?: React.MouseEventHandler<HTMLButtonElement>+export type LoadingVariantProps = VariantProps<typeof loadingVariants>+const loadingVariants = cva('', {+ variants: {+ loading: {+ default: '',+ true: `animate-spin`,+ },+ },+})++export interface ButtonProps+ // omit `type` as we use it to change type of button+ // replaced with `htmlType`+ extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'type'>,+ // omit 'disabled' as it is included in HTMLButtonElement+ Omit<ButtonVariantProps, 'disabled'>,+ LoadingVariantProps {+ asChild?: boolean+ type?: ButtonVariantProps['type']+ htmlType?: React.ButtonHTMLAttributes<HTMLButtonElement>['type']icon?: React.ReactNode+ iconLeft?: React.ReactNodeiconRight?: React.ReactNode- loading?: boolean- loadingCentered?: boolean- shadow?: boolean- size?: ButtonSize- style?: React.CSSProperties- type?: ButtonType- danger?: boolean- htmlType?: 'button' | 'submit' | 'reset'- ref?: any- ariaSelected?: boolean- ariaControls?: string- tabIndex?: 0 | -1- role?: string- textAlign?: 'left' | 'center' | 'right'- as?: keyof JSX.IntrinsicElements- form?: string}-export type ButtonSize = 'tiny' | 'small' | 'medium' | 'large' | 'xlarge'-export type ButtonType =- | 'primary'- | 'default'- | 'secondary'- | 'alternative'- | 'outline'- | 'dashed'- | 'link'- | 'text'- | 'danger'- | 'warning'+const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(+ ({ asChild = false, ...props }, ref) => {+ const Comp = asChild ? Slot : 'button'-interface CustomButtonProps extends React.HTMLAttributes<HTMLButtonElement> {}+ const { className, type, disabled, size, loading, icon, iconLeft, iconRight } = props-export const Button = forwardRef<HTMLButtonElement, ButtonProps>(- (- {- block,- className,- children,- danger,- disabled = false,- onClick,- icon,- iconRight,- loading = false,- loadingCentered = false,- shadow = true,- size = 'tiny',- style,- type = 'primary',- htmlType = 'button',- ariaSelected,- ariaControls,- tabIndex,- role,- as,- textAlign = 'center',- ...props- }: ButtonProps,- ref- ) => {- let __styles = styleHandler('button')-- // stylesconst showIcon = loading || icon- let classes = [__styles.base]- let containerClasses = [__styles.container]-- classes.push(__styles.type[type])-- if (block) {- containerClasses.push(__styles.block)- classes.push(__styles.block)- }-- if (shadow && type !== 'link' && type !== 'text') {- classes.push(__styles.shadow)- }-- if (size) {- classes.push(__styles.size[size])- }-- if (className) {- classes.push(className)- }-- if (disabled) {- classes.push(__styles.disabled)- }-- const iconLoaderClasses = [__styles.loading]-- // custom button tag- const CustomButton = ({ ...props }) => {- const Tag = as as keyof JSX.IntrinsicElements- return <Tag {...props} />- }+ // decrecating 'showIcon' for rightIcon+ const _iconLeft: React.ReactNode = icon ?? iconLeftconst buttonContent = (<>{showIcon &&(loading ? (- <IconLoader size={size} className={iconLoaderClasses.join(' ')} />- ) : icon ? (- <IconContext.Provider value={{ contextSize: size }}>{icon}</IconContext.Provider>+ <IconLoader size={size} className={cn(loadingVariants({ loading }))} />+ ) : _iconLeft ? (+ <IconContext.Provider value={{ contextSize: size }}>{_iconLeft}</IconContext.Provider>) : null)}- {children && <span className={__styles.label}>{children}</span>}+ {props.children && <span className={'truncate'}>{props.children}</span>}{iconRight && !loading && (<IconContext.Provider value={{ contextSize: size }}>{iconRight}</IconContext.Provider>)}</>)- if (as) {- return (- <CustomButton {...props} className={classes.join(' ')} onClick={onClick} style={style}>- {buttonContent}- </CustomButton>- )- } else {- return (- // <span ref={containerRef} className={containerClasses.join(' ')}>- <button- {...props}- ref={ref}- className={classes.join(' ')}- disabled={loading || (disabled && true)}- onClick={onClick}- style={style}- type={htmlType}- aria-selected={ariaSelected}- aria-controls={ariaControls}- tabIndex={tabIndex}- role={role}- form={props.form}- >- {buttonContent}- </button>- // </span>- )- }+ return (+ <Comp+ className={cn(buttonVariantsNew({ type, size, disabled, className }))}+ ref={ref}+ type={props.htmlType}+ {...props}+ >+ {buttonContent}+ </Comp>+ )})++Button.displayName = 'Button'++function Test() {+ return <Button as={'input'}></Button>+}++export { Button, buttonVariantsNew }diff --git a/packages/ui/src/components/Command/AiCommand.tsx b/packages/ui/src/components/Command/AiCommand.tsxindex 48a35a8c788..509b7c13d91 100644--- a/packages/ui/src/components/Command/AiCommand.tsx+++ b/packages/ui/src/components/Command/AiCommand.tsx@@ -30,7 +30,7 @@ import { AiWarning } from './Command.alerts'import { useCommandMenu } from './CommandMenuProvider'import ReactMarkdown from 'react-markdown'-import { cn } from './../../utils/cn'+import { cn } from '../../lib/utils/cn'import remarkGfm from 'remark-gfm'const questions = [diff --git a/packages/ui/src/components/Command/Command.utils.tsx b/packages/ui/src/components/Command/Command.utils.tsxindex f7796e4a9b1..e183ad76b2d 100644--- a/packages/ui/src/components/Command/Command.utils.tsx+++ b/packages/ui/src/components/Command/Command.utils.tsx@@ -1,7 +1,7 @@import { Command as CommandPrimitive } from 'cmdk-supabase'import * as React from 'react'-import { cn } from './../../utils/cn'+import { cn } from '../../lib/utils/cn'import { DetailedHTMLProps, HTMLAttributes, KeyboardEventHandler } from 'react'import { Modal } from '../Modal'diff --git a/packages/ui/src/components/Command/GenerateSQL/GenerateSQL.tsx b/packages/ui/src/components/Command/GenerateSQL/GenerateSQL.tsxindex f25aec4fcbb..5ccc7ca988e 100644--- a/packages/ui/src/components/Command/GenerateSQL/GenerateSQL.tsx+++ b/packages/ui/src/components/Command/GenerateSQL/GenerateSQL.tsx@@ -16,7 +16,7 @@ import {UseAiChatOptions,} from 'ui'-import { cn } from '../../../utils/cn'+import { cn } from '../../../lib/utils/cn'import { AiIcon, AiIconChat } from '../Command.icons'import { CommandItem, useAutoInputFocus, useHistoryKeys } from '../Command.utils'import { useCommandMenu } from '../CommandMenuProvider'diff --git a/packages/ui/src/components/Command/LoadingLine.tsx b/packages/ui/src/components/Command/LoadingLine.tsxindex 6e2c172c579..529ae689e94 100644--- a/packages/ui/src/components/Command/LoadingLine.tsx+++ b/packages/ui/src/components/Command/LoadingLine.tsx@@ -1,5 +1,5 @@import React from 'react'-import { cn } from '../../utils/cn'+import { cn } from '../../lib/utils/cn'export const LoadingLine = ({ loading }: { loading: boolean }) => {return (diff --git a/packages/ui/src/components/Dropdown/Dropdown.tsx b/packages/ui/src/components/Dropdown/Dropdown.tsxindex 760197c5919..32fd4af3814 100644--- a/packages/ui/src/components/Dropdown/Dropdown.tsx+++ b/packages/ui/src/components/Dropdown/Dropdown.tsx@@ -7,7 +7,7 @@ import type * as RadixDropdownTypes from '@radix-ui/react-dropdown-menu/'import styleHandler from '../../lib/theme/styleHandler'import { IconTarget } from '../Icon/icons/IconTarget'-import { cn } from '../../utils/cn'+import { cn } from '../../lib/utils/cn'interface RootProps extends RadixDropdownTypes.DropdownMenuProps {open?: booleandiff --git a/packages/ui/src/components/Icon/IconContext.tsx b/packages/ui/src/components/Icon/IconContext.tsxindex 4d2198bdfe7..58c731dcf8c 100644--- a/packages/ui/src/components/Icon/IconContext.tsx+++ b/packages/ui/src/components/Icon/IconContext.tsx@@ -1,10 +1,11 @@+import { SizeVariantProps } from '@ui/lib/commonCva'import { createContext } from 'react'-type ContextValue = { contextSize?: string; className?: string }+type ContextValue = { contextSize?: SizeVariantProps; className?: string }// Make sure the shape of the default value passed to// createContext matches the shape that the consumers expect!export const IconContext = createContext<ContextValue>({- contextSize: '',+ contextSize: 'small',className: '',})diff --git a/packages/ui/src/components/Radio/Radio.tsx b/packages/ui/src/components/Radio/Radio.tsxindex 72ad375ec43..715637eee8b 100644--- a/packages/ui/src/components/Radio/Radio.tsx+++ b/packages/ui/src/components/Radio/Radio.tsx@@ -7,7 +7,7 @@ import { useFormContext } from '../Form/FormContext'import defaultTheme from '../../lib/theme/defaultTheme'import styleHandler from '../../lib/theme/styleHandler'-import randomIdGenerator from './../../utils/randomIdGenerator'+import randomIdGenerator from '../../lib/utils/randomIdGenerator'interface GroupProps {allowedValues?: anydiff --git a/packages/ui/src/components/ThemeProvider/ThemeProvider.tsx b/packages/ui/src/components/ThemeProvider/ThemeProvider.tsxindex 334587987f1..524f2e718b3 100644--- a/packages/ui/src/components/ThemeProvider/ThemeProvider.tsx+++ b/packages/ui/src/components/ThemeProvider/ThemeProvider.tsx@@ -3,7 +3,7 @@ import { createContext } from 'react'import defaultTheme from '../../lib/theme/defaultTheme'-import { mergeDeep } from '../../utils/mergeDeep'+import { mergeDeep } from '../../lib/utils/mergeDeep'// import useDarkMode from './utils/useDarkMode'interface ThemeContextInterface {diff --git a/packages/ui/src/lib/commonCva.ts b/packages/ui/src/lib/commonCva.tsnew file mode 100644index 00000000000..fdf863e24c9--- /dev/null+++ b/packages/ui/src/lib/commonCva.ts@@ -0,0 +1,71 @@+import { VariantProps, cva } from 'class-variance-authority'++const defaults = {+ bg: {+ brand: {+ primary: 'bg-purple-600',+ secondary: 'bg-purple-200',+ },+ },+ text: {+ brand: 'text-purple-600',+ body: 'text-scale-600 dark:text-scaleDark-200',+ title: 'text-scale-700 dark:text-scaleDark-100',+ },+ border: {+ brand: 'border-brand-600',+ primary: 'border-scale-700',+ secondary: 'border-scale-400',+ alternative: 'border-scale-600 dark:border-scaleDark-200',+ },+ placeholder: 'placeholder-scale-800',+ focus: `+ outline-none+ focus:ring-current focus:ring-2+ `,+ 'focus-visible': `+ outline-none+ transition-all+ outline-0+ focus-visible:outline-4+ focus-visible:outline-offset-1+ `,+ size: {+ // buttons, inputs, input labels use these sizes+ text: {+ tiny: 'text-xs',+ small: 'text-sm leading-4',+ medium: 'text-sm',+ large: 'text-base',+ xlarge: 'text-base',+ },+ // buttons, inputs, input labels use these sizes+ padding: {+ tiny: 'px-2.5 py-1',+ small: 'px-3 py-2',+ medium: 'px-4 py-2',+ large: 'px-4 py-2',+ xlarge: 'px-6 py-3',+ },+ },+ overlay: {+ base: `absolute inset-0 bg-scale-200 opacity-50`,+ container: `fixed inset-0 transition-opacity`,+ },+}++export const sizes = {+ tiny: `${defaults.size.text.tiny} ${defaults.size.padding.tiny}`,+ small: `${defaults.size.text.small} ${defaults.size.padding.small}`,+ medium: `${defaults.size.text.medium} ${defaults.size.padding.medium}`,+ large: `${defaults.size.text.large} ${defaults.size.padding.large}`,+ xlarge: `${defaults.size.text.xlarge} ${defaults.size.padding.xlarge}`,+}+export type SizeVariantProps = VariantProps<typeof sizeVariants>['size']+export const sizeVariants = cva('', {+ variants: {+ size: {+ ...sizes,+ },+ },+})diff --git a/packages/ui/src/lib/theme/themeContext.tsx b/packages/ui/src/lib/theme/themeContext.tsxindex 3e0fbcfc011..c5264812354 100644--- a/packages/ui/src/lib/theme/themeContext.tsx+++ b/packages/ui/src/lib/theme/themeContext.tsx@@ -2,7 +2,7 @@ import React, { useLayoutEffect, useMemo } from 'react'import { createContext } from 'react'import defaultTheme from './defaultTheme'-import { mergeDeep } from '../../utils/mergeDeep'+import { mergeDeep } from '../utils/mergeDeep'// import useDarkMode from './utils/useDarkMode'interface ThemeContextInterface {diff --git a/packages/ui/src/lib/utilities.tsx b/packages/ui/src/lib/utilities.tsxdeleted file mode 100644index 89cc8a5a1c4..00000000000--- a/packages/ui/src/lib/utilities.tsx+++ /dev/null@@ -1,78 +0,0 @@-import React from 'react'--// export const FormLayout = (props: any) => {-// const {-// align,-// direction,-// size,-// label,-// labelOptional,-// layout,-// children,-// id,-// error,-// descriptionText,-// className,-// responsive-// } = props--// const spacingClass =-// 'space-' + (direction === 'vertical' ? 'y' : 'x') + '-' + size--// const responsiveClasses = responsive ? ' md:grid-cols-12' : ' grid-cols-12'--// return (-// <div className={"grid gap-2 " + className + responsiveClasses}>-// <Space direction={layout && layout === 'horizontal' ? 'vertical' : 'horizontal'}-// className={"" + (layout !== 'horizontal' ? ' justify-between col-span-12' : ' col-span-5')}-// >-// {label && (-// <label-// className="block text-sm font-sml text-gray-700 dark:text-gray-200 font-medium"-// htmlFor={id}-// >-// {label}-// </label>-// )}-// {labelOptional && (-// <span className="text-sm text-gray-400 dark:text-gray-300" id={id + '-optional'}>-// {labelOptional}-// </span>-// )}-// </Space>-// <div className={layout !== 'horizontal' ? 'col-span-12' : 'col-span-7' + (align === 'right' ? ' text-right' : '')}>-// {children}-// {error && (-// <p className="mt-2 text-sm text-red-500" id="email-error">-// {error}-// </p>-// )}-// {descriptionText && (-// <p className="mt-2 text-sm text-gray-400 dark:text-gray-300" id={id + '-description'}>-// {descriptionText}-// </p>-// )}-// </div>-// </div>-// )-// }--// export const Space = (props: any) => {-// const { direction, size, className } = props--// const spacingClass =-// 'space-' + (direction === 'vertical' ? 'y' : 'x') + '-' + size--// return (-// <div-// className={-// 'flex' +-// (className ? ' ' + className : '') +-// (spacingClass ? ' ' + spacingClass : '') +-// (direction === 'vertical' ? ' flex-col' : ' flex-row')-// }-// >-// {props.children}-// </div>-// )-// }diff --git a/packages/ui/src/utils/cn.ts b/packages/ui/src/lib/utils/cn.tssimilarity index 100%rename from packages/ui/src/utils/cn.tsrename to packages/ui/src/lib/utils/cn.tsdiff --git a/packages/ui/src/lib/utils/index.ts b/packages/ui/src/lib/utils/index.tsnew file mode 100644index 00000000000..524b85fccef--- /dev/null+++ b/packages/ui/src/lib/utils/index.ts@@ -0,0 +1,3 @@+export * from './cn'+export * from './mergeDeep'+export * from './randomIdGenerator'diff --git a/packages/ui/src/utils/mergeDeep.ts b/packages/ui/src/lib/utils/mergeDeep.tssimilarity index 100%rename from packages/ui/src/utils/mergeDeep.tsrename to packages/ui/src/lib/utils/mergeDeep.tsdiff --git a/packages/ui/src/utils/randomIdGenerator.ts b/packages/ui/src/lib/utils/randomIdGenerator.tssimilarity index 92%rename from packages/ui/src/utils/randomIdGenerator.tsrename to packages/ui/src/lib/utils/randomIdGenerator.tsindex be7c8071b9a..e3043cbd938 100644--- a/packages/ui/src/utils/randomIdGenerator.ts+++ b/packages/ui/src/lib/utils/randomIdGenerator.ts@@ -3,7 +3,7 @@// return randomNumber.toString()// }-export default function generateUID() {+export function generateUID() {// I generate the UID from two parts here// to ensure the random number provide enough bits.var firstPart = (Math.random() * 46656) | 0diff --git a/packages/ui/src/utils/useDarkMode.ts b/packages/ui/src/utils/useDarkMode.tsdeleted file mode 100644index 8db60d6b634..00000000000--- a/packages/ui/src/utils/useDarkMode.ts+++ /dev/null@@ -1,46 +0,0 @@-// import { useEffect, useState } from 'react'--// export const useDarkMode = (-// usePreferences: boolean-// ): [Mode, React.Dispatch<React.SetStateAction<Mode>> | null,-// (() => void) | null-// ] => {-// if (!usePreferences) return [null, null, null]--// const [mode, setMode] = useState<Mode>(null)--// const toggleMode = () => {-// if (mode === 'light') {-// document.documentElement.className = ''-// document.documentElement.classList.add('dark')-// setMode('dark')-// } else {-// document.documentElement.className = ''-// document.documentElement.classList.add('light')-// setMode('light')-// }-// }--// useEffect(() => {-// const userPreference =-// !!window.matchMedia &&-// window.matchMedia('(prefers-color-scheme: dark)').matches--// setMode(-// // use stored theme; fallback to user preference-// window.localStorage.getItem('theme') ||-// (userPreference ? 'dark' : 'light')-// )-// }, [])--// useEffect(() => {-// if (mode) {-// window.localStorage.setItem('theme', mode)-// document.documentElement.classList.add(mode)-// }-// }, [mode])--// return [mode, setMode, toggleMode]-// }--// export default useDarkModediff --git a/packages/ui/tsconfig.json b/packages/ui/tsconfig.jsonindex 8637a0ecaf7..da20469057f 100644--- a/packages/ui/tsconfig.json+++ b/packages/ui/tsconfig.json@@ -1,14 +1,12 @@{"extends": "tsconfig/react-library.json","compilerOptions": {- "resolveJsonModule": true+ "resolveJsonModule": true,+ "baseUrl": ".",+ "paths": {+ "@ui/*": ["./src/*"] // no other project in the monorepo uses this alias+ }},- "include": [- "."- ],- "exclude": [- "dist",- "build",- "node_modules"- ]-}\ No newline at end of file+ "include": ["."],+ "exclude": ["dist", "build", "node_modules"]+}