The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
move all new components out
Jonathan Summers-Muir9745cdcb971f
diff --git a/apps/docs/components/Navigation/Footer.tsx b/apps/docs/components/Navigation/Footer.tsxindex e14892a8f39..c9347b74647 100644--- a/apps/docs/components/Navigation/Footer.tsx+++ b/apps/docs/components/Navigation/Footer.tsx@@ -55,105 +55,85 @@ const Footer = () => ())}</div><div className="flex items-center gap-2">- <Button- type="text"- as="a"- // @ts-ignore- href="https://github.com/supabase/supabase"- target="_blank"- rel="noreferrer noopener"- >- <svg- width="17"- height="17"- viewBox="0 0 17 17"- fill="none"- xmlns="http://www.w3.org/2000/svg"- >- <path- fillRule="evenodd"- clipRule="evenodd"- d="M8.66832 1.55469C4.98649 1.55469 2.00195 4.54402 2.00195 8.23269C2.00195 11.1827 3.91187 13.686 6.56108 14.5687C6.8944 14.63 7.01573 14.424 7.01573 14.2467C7.01573 14.0887 7.0104 13.668 7.00706 13.1114C5.15248 13.5147 4.76116 12.216 4.76116 12.216C4.45851 11.444 4.0212 11.2387 4.0212 11.2387C3.41589 10.8254 4.06719 10.8334 4.06719 10.8334C4.73583 10.88 5.08782 11.5214 5.08782 11.5214C5.68246 12.5414 6.64841 12.2467 7.02773 12.076C7.08906 11.6447 7.26105 11.3507 7.45171 11.184C5.97178 11.0154 4.41518 10.442 4.41518 7.88335C4.41518 7.15469 4.67517 6.55802 5.10115 6.09135C5.03248 5.92269 4.80383 5.24335 5.16648 4.32469C5.16648 4.32469 5.72645 4.14469 6.99973 5.00869C7.54355 4.86036 8.10464 4.78482 8.66832 4.78402C9.23496 4.78669 9.80494 4.86069 10.3376 5.00869C11.6102 4.14469 12.1688 4.32402 12.1688 4.32402C12.5328 5.24335 12.3035 5.92269 12.2355 6.09135C12.6621 6.55802 12.9208 7.15469 12.9208 7.88335C12.9208 10.4487 11.3615 11.0134 9.87694 11.1787C10.1163 11.3847 10.3289 11.792 10.3289 12.4154C10.3289 13.3074 10.3209 14.028 10.3209 14.2467C10.3209 14.4254 10.4409 14.6334 10.7796 14.568C12.107 14.1228 13.261 13.2716 14.0784 12.1347C14.8958 10.9979 15.3353 9.6329 15.3347 8.23269C15.3347 4.54402 12.3495 1.55469 8.66832 1.55469Z"- fill="var(--colors-scale9)"- />- </svg>- </Button>- <Button- type="text"- as="a"- // @ts-ignore- href="https://youtube.com/c/supabase"- target="_blank"- rel="noreferrer noopener"- >- <svg- width="16"- height="17"- viewBox="0 0 16 17"- fill="none"- xmlns="http://www.w3.org/2000/svg"- >- <path- d="M15.665 4.35595C15.481 3.66308 14.9388 3.11739 14.2505 2.93221C13.0028 2.5957 7.99964 2.5957 7.99964 2.5957C7.99964 2.5957 2.99655 2.5957 1.74883 2.93221C1.06047 3.11742 0.518326 3.66308 0.334321 4.35595C0 5.61181 0 8.23207 0 8.23207C0 8.23207 0 10.8523 0.334321 12.1082C0.518326 12.8011 1.06047 13.324 1.74883 13.5092C2.99655 13.8457 7.99964 13.8457 7.99964 13.8457C7.99964 13.8457 13.0027 13.8457 14.2505 13.5092C14.9388 13.324 15.481 12.8011 15.665 12.1082C15.9993 10.8523 15.9993 8.23207 15.9993 8.23207C15.9993 8.23207 15.9993 5.61181 15.665 4.35595ZM6.36334 10.6111V5.85307L10.545 8.23212L6.36334 10.6111Z"- fill="var(--colors-scale9)"- />- </svg>- </Button>- <Button- type="text"- as="a"- // @ts-ignore- href="https://twitter.com/supabase"- target="_blank"- rel="noreferrer noopener"- >- <svg- width="17"- height="17"- viewBox="0 0 17 17"- fill="none"- xmlns="http://www.w3.org/2000/svg"- >- <path- d="M5.52713 13.7223C10.5582 13.7223 13.3101 9.55365 13.3101 5.93898C13.3101 5.82032 13.3101 5.70232 13.3021 5.58565C13.8375 5.198 14.2996 4.71806 14.6667 4.16832C14.1675 4.38965 13.6378 4.53483 13.0955 4.59898C13.6665 4.25702 14.0939 3.71922 14.2981 3.08565C13.7612 3.40424 13.1739 3.6288 12.5615 3.74965C12.1491 3.31083 11.6035 3.02021 11.0093 2.92279C10.4151 2.82537 9.80528 2.92658 9.27438 3.21076C8.74347 3.49494 8.32106 3.94623 8.07255 4.49476C7.82403 5.04328 7.76328 5.65844 7.89969 6.24498C6.81213 6.19048 5.74819 5.90787 4.77693 5.4155C3.80567 4.92313 2.9488 4.232 2.26194 3.38698C1.91217 3.98912 1.80502 4.70193 1.96231 5.38029C2.1196 6.05866 2.52951 6.65157 3.10857 7.03832C2.67343 7.02572 2.2477 6.90865 1.86729 6.69698V6.73165C1.86755 7.36318 2.08621 7.97519 2.4862 8.46389C2.88618 8.95259 3.44287 9.28791 4.06186 9.41298C3.65909 9.52279 3.2365 9.53876 2.82658 9.45965C3.00135 10.0033 3.34168 10.4787 3.79996 10.8194C4.25824 11.1601 4.81154 11.349 5.38247 11.3597C4.81524 11.8054 4.16572 12.1349 3.47104 12.3293C2.77636 12.5238 2.05017 12.5794 1.33398 12.493C2.585 13.2959 4.04066 13.7217 5.52713 13.7197"- fill="var(--colors-scale9)"- />- </svg>- </Button>- <Button- type="text"- as="a"- // @ts-ignore- href="https://discord.supabase.com/"- target="_blank"- rel="noreferrer noopener"- >- <svg- width="17"- height="17"- viewBox="0 0 17 17"- fill="none"- xmlns="http://www.w3.org/2000/svg"- >- <g clipPath="url(#clip0_1182_99731)">+ <Button type="text" asChild>+ <a href="https://github.com/supabase/supabase" target="_blank" rel="noreferrer noopener">+ <svg+ width="17"+ height="17"+ viewBox="0 0 17 17"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+ ><pathfillRule="evenodd"clipRule="evenodd"- d="M13.8781 3.13594C12.8583 2.66802 11.7648 2.32328 10.6215 2.12583C10.6006 2.12202 10.5798 2.13154 10.5691 2.15059C10.4285 2.40073 10.2727 2.72706 10.1636 2.98356C8.93387 2.79945 7.71044 2.79945 6.50592 2.98356C6.39681 2.72136 6.23538 2.40073 6.09411 2.15059C6.08339 2.13218 6.06259 2.12265 6.04176 2.12583C4.89905 2.32265 3.80554 2.66739 2.78517 3.13594C2.77633 3.13975 2.76876 3.14611 2.76374 3.15435C0.689563 6.25326 0.12136 9.276 0.400102 12.2613C0.401363 12.2759 0.409561 12.2898 0.420913 12.2987C1.78939 13.3037 3.115 13.9139 4.41599 14.3183C4.43681 14.3247 4.45887 14.317 4.47212 14.2999C4.77987 13.8796 5.0542 13.4364 5.28941 12.9704C5.3033 12.9431 5.29005 12.9107 5.26167 12.9C4.82654 12.7349 4.4122 12.5336 4.01364 12.3051C3.98212 12.2867 3.97959 12.2416 4.00859 12.22C4.09247 12.1571 4.17636 12.0917 4.25645 12.0257C4.27094 12.0136 4.29113 12.0111 4.30816 12.0187C6.92655 13.2142 9.76126 13.2142 12.3488 12.0187C12.3658 12.0105 12.386 12.013 12.4011 12.0251C12.4812 12.0911 12.5651 12.1571 12.6496 12.22C12.6786 12.2416 12.6767 12.2867 12.6452 12.3051C12.2466 12.5381 11.8323 12.7349 11.3965 12.8993C11.3681 12.9101 11.3555 12.9431 11.3694 12.9704C11.6097 13.4358 11.884 13.879 12.1861 14.2993C12.1987 14.317 12.2214 14.3247 12.2422 14.3183C13.5495 13.9139 14.8751 13.3037 16.2436 12.2987C16.2556 12.2898 16.2631 12.2765 16.2644 12.2619C16.598 8.8106 15.7056 5.81265 13.8989 3.15498C13.8944 3.14611 13.8869 3.13975 13.8781 3.13594ZM5.68043 10.4435C4.89211 10.4435 4.24257 9.71978 4.24257 8.83093C4.24257 7.94207 4.87952 7.21831 5.68043 7.21831C6.48763 7.21831 7.13089 7.94843 7.11827 8.83093C7.11827 9.71978 6.48132 10.4435 5.68043 10.4435ZM10.9967 10.4435C10.2084 10.4435 9.55884 9.71978 9.55884 8.83093C9.55884 7.94207 10.1958 7.21831 10.9967 7.21831C11.8039 7.21831 12.4471 7.94843 12.4345 8.83093C12.4345 9.71978 11.8039 10.4435 10.9967 10.4435Z"+ d="M8.66832 1.55469C4.98649 1.55469 2.00195 4.54402 2.00195 8.23269C2.00195 11.1827 3.91187 13.686 6.56108 14.5687C6.8944 14.63 7.01573 14.424 7.01573 14.2467C7.01573 14.0887 7.0104 13.668 7.00706 13.1114C5.15248 13.5147 4.76116 12.216 4.76116 12.216C4.45851 11.444 4.0212 11.2387 4.0212 11.2387C3.41589 10.8254 4.06719 10.8334 4.06719 10.8334C4.73583 10.88 5.08782 11.5214 5.08782 11.5214C5.68246 12.5414 6.64841 12.2467 7.02773 12.076C7.08906 11.6447 7.26105 11.3507 7.45171 11.184C5.97178 11.0154 4.41518 10.442 4.41518 7.88335C4.41518 7.15469 4.67517 6.55802 5.10115 6.09135C5.03248 5.92269 4.80383 5.24335 5.16648 4.32469C5.16648 4.32469 5.72645 4.14469 6.99973 5.00869C7.54355 4.86036 8.10464 4.78482 8.66832 4.78402C9.23496 4.78669 9.80494 4.86069 10.3376 5.00869C11.6102 4.14469 12.1688 4.32402 12.1688 4.32402C12.5328 5.24335 12.3035 5.92269 12.2355 6.09135C12.6621 6.55802 12.9208 7.15469 12.9208 7.88335C12.9208 10.4487 11.3615 11.0134 9.87694 11.1787C10.1163 11.3847 10.3289 11.792 10.3289 12.4154C10.3289 13.3074 10.3209 14.028 10.3209 14.2467C10.3209 14.4254 10.4409 14.6334 10.7796 14.568C12.107 14.1228 13.261 13.2716 14.0784 12.1347C14.8958 10.9979 15.3353 9.6329 15.3347 8.23269C15.3347 4.54402 12.3495 1.55469 8.66832 1.55469Z"+ fill="var(--colors-scale9)"+ />+ </svg>+ </a>+ </Button>+ <Button type="text" asChild>+ <a href="https://youtube.com/c/supabase" target="_blank" rel="noreferrer noopener">+ <svg+ width="16"+ height="17"+ viewBox="0 0 16 17"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+ >+ <path+ d="M15.665 4.35595C15.481 3.66308 14.9388 3.11739 14.2505 2.93221C13.0028 2.5957 7.99964 2.5957 7.99964 2.5957C7.99964 2.5957 2.99655 2.5957 1.74883 2.93221C1.06047 3.11742 0.518326 3.66308 0.334321 4.35595C0 5.61181 0 8.23207 0 8.23207C0 8.23207 0 10.8523 0.334321 12.1082C0.518326 12.8011 1.06047 13.324 1.74883 13.5092C2.99655 13.8457 7.99964 13.8457 7.99964 13.8457C7.99964 13.8457 13.0027 13.8457 14.2505 13.5092C14.9388 13.324 15.481 12.8011 15.665 12.1082C15.9993 10.8523 15.9993 8.23207 15.9993 8.23207C15.9993 8.23207 15.9993 5.61181 15.665 4.35595ZM6.36334 10.6111V5.85307L10.545 8.23212L6.36334 10.6111Z"fill="var(--colors-scale9)"/>- </g>- <defs>- <clipPath id="clip0_1182_99731">- <rect- width="15.9993"- height="16"- fill="white"- transform="translate(0.333984 0.222656)"+ </svg>+ </a>+ </Button>+ <Button type="text" asChild>+ <a href="https://twitter.com/supabase" target="_blank" rel="noreferrer noopener">+ <svg+ width="17"+ height="17"+ viewBox="0 0 17 17"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+ >+ <path+ d="M5.52713 13.7223C10.5582 13.7223 13.3101 9.55365 13.3101 5.93898C13.3101 5.82032 13.3101 5.70232 13.3021 5.58565C13.8375 5.198 14.2996 4.71806 14.6667 4.16832C14.1675 4.38965 13.6378 4.53483 13.0955 4.59898C13.6665 4.25702 14.0939 3.71922 14.2981 3.08565C13.7612 3.40424 13.1739 3.6288 12.5615 3.74965C12.1491 3.31083 11.6035 3.02021 11.0093 2.92279C10.4151 2.82537 9.80528 2.92658 9.27438 3.21076C8.74347 3.49494 8.32106 3.94623 8.07255 4.49476C7.82403 5.04328 7.76328 5.65844 7.89969 6.24498C6.81213 6.19048 5.74819 5.90787 4.77693 5.4155C3.80567 4.92313 2.9488 4.232 2.26194 3.38698C1.91217 3.98912 1.80502 4.70193 1.96231 5.38029C2.1196 6.05866 2.52951 6.65157 3.10857 7.03832C2.67343 7.02572 2.2477 6.90865 1.86729 6.69698V6.73165C1.86755 7.36318 2.08621 7.97519 2.4862 8.46389C2.88618 8.95259 3.44287 9.28791 4.06186 9.41298C3.65909 9.52279 3.2365 9.53876 2.82658 9.45965C3.00135 10.0033 3.34168 10.4787 3.79996 10.8194C4.25824 11.1601 4.81154 11.349 5.38247 11.3597C4.81524 11.8054 4.16572 12.1349 3.47104 12.3293C2.77636 12.5238 2.05017 12.5794 1.33398 12.493C2.585 13.2959 4.04066 13.7217 5.52713 13.7197"+ fill="var(--colors-scale9)"+ />+ </svg>+ </a>+ </Button>+ <Button type="text" asChild>+ <a href="https://discord.supabase.com/" target="_blank" rel="noreferrer noopener">+ <svg+ width="17"+ height="17"+ viewBox="0 0 17 17"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+ >+ <g clipPath="url(#clip0_1182_99731)">+ <path+ fillRule="evenodd"+ clipRule="evenodd"+ d="M13.8781 3.13594C12.8583 2.66802 11.7648 2.32328 10.6215 2.12583C10.6006 2.12202 10.5798 2.13154 10.5691 2.15059C10.4285 2.40073 10.2727 2.72706 10.1636 2.98356C8.93387 2.79945 7.71044 2.79945 6.50592 2.98356C6.39681 2.72136 6.23538 2.40073 6.09411 2.15059C6.08339 2.13218 6.06259 2.12265 6.04176 2.12583C4.89905 2.32265 3.80554 2.66739 2.78517 3.13594C2.77633 3.13975 2.76876 3.14611 2.76374 3.15435C0.689563 6.25326 0.12136 9.276 0.400102 12.2613C0.401363 12.2759 0.409561 12.2898 0.420913 12.2987C1.78939 13.3037 3.115 13.9139 4.41599 14.3183C4.43681 14.3247 4.45887 14.317 4.47212 14.2999C4.77987 13.8796 5.0542 13.4364 5.28941 12.9704C5.3033 12.9431 5.29005 12.9107 5.26167 12.9C4.82654 12.7349 4.4122 12.5336 4.01364 12.3051C3.98212 12.2867 3.97959 12.2416 4.00859 12.22C4.09247 12.1571 4.17636 12.0917 4.25645 12.0257C4.27094 12.0136 4.29113 12.0111 4.30816 12.0187C6.92655 13.2142 9.76126 13.2142 12.3488 12.0187C12.3658 12.0105 12.386 12.013 12.4011 12.0251C12.4812 12.0911 12.5651 12.1571 12.6496 12.22C12.6786 12.2416 12.6767 12.2867 12.6452 12.3051C12.2466 12.5381 11.8323 12.7349 11.3965 12.8993C11.3681 12.9101 11.3555 12.9431 11.3694 12.9704C11.6097 13.4358 11.884 13.879 12.1861 14.2993C12.1987 14.317 12.2214 14.3247 12.2422 14.3183C13.5495 13.9139 14.8751 13.3037 16.2436 12.2987C16.2556 12.2898 16.2631 12.2765 16.2644 12.2619C16.598 8.8106 15.7056 5.81265 13.8989 3.15498C13.8944 3.14611 13.8869 3.13975 13.8781 3.13594ZM5.68043 10.4435C4.89211 10.4435 4.24257 9.71978 4.24257 8.83093C4.24257 7.94207 4.87952 7.21831 5.68043 7.21831C6.48763 7.21831 7.13089 7.94843 7.11827 8.83093C7.11827 9.71978 6.48132 10.4435 5.68043 10.4435ZM10.9967 10.4435C10.2084 10.4435 9.55884 9.71978 9.55884 8.83093C9.55884 7.94207 10.1958 7.21831 10.9967 7.21831C11.8039 7.21831 12.4471 7.94843 12.4345 8.83093C12.4345 9.71978 11.8039 10.4435 10.9967 10.4435Z"+ fill="var(--colors-scale9)"/>- </clipPath>- </defs>- </svg>+ </g>+ <defs>+ <clipPath id="clip0_1182_99731">+ <rect+ width="15.9993"+ height="16"+ fill="white"+ transform="translate(0.333984 0.222656)"+ />+ </clipPath>+ </defs>+ </svg>+ </a></Button></div></div>diff --git a/apps/docs/components/Navigation/NavigationMenu/HomeMenu.tsx b/apps/docs/components/Navigation/NavigationMenu/HomeMenu.tsxindex fb51bb98ba7..761d23a317c 100644--- a/apps/docs/components/Navigation/NavigationMenu/HomeMenu.tsx+++ b/apps/docs/components/Navigation/NavigationMenu/HomeMenu.tsx@@ -1,12 +1,10 @@import { useTheme } from 'common/Providers'-import Image from 'next/image'import Link from 'next/link'import { useRouter } from 'next/router'import { Fragment } from 'react'-import { Badge } from '~/../../packages/ui'-import { cn } from 'ui/src/utils/cn'-import { HOMEPAGE_MENU_ITEMS } from './NavigationMenu.constants'+import { Badge, cn } from 'ui'import HomeMenuIconPicker from './HomeMenuIconPicker'+import { HOMEPAGE_MENU_ITEMS } from './NavigationMenu.constants'const NavigationMenuHome = () => {const router = useRouter()diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenuRefListItems.tsx b/apps/docs/components/Navigation/NavigationMenu/NavigationMenuRefListItems.tsxindex 0069b311827..59c0cca96e6 100644--- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenuRefListItems.tsx+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenuRefListItems.tsx@@ -1,18 +1,14 @@import * as Accordion from '@radix-ui/react-accordion'+import Image from 'next/image'import Link from 'next/link'import { useRouter } from 'next/router'-import { IconChevronLeft, IconChevronUp } from 'ui'-import * as NavItems from './NavigationMenu.constants'--import Image from 'next/image'--import RevVersionDropdown from '~/components/RefVersionDropdown'-import { useMenuActiveRefId } from '~/hooks/useMenuState'-import React, { Fragment } from 'react'-import { cn } from 'ui/src/utils/cn'+import { IconChevronLeft, IconChevronUp, cn } from 'ui'+import RevVersionDropdown from '~/components/RefVersionDropdown'import { ICommonItem, ICommonSection } from '~/components/reference/Reference.types'+import { useMenuActiveRefId } from '~/hooks/useMenuState'import HomeMenuIconPicker from './HomeMenuIconPicker'+import * as NavItems from './NavigationMenu.constants'import { deepFilterSections } from './NavigationMenu.utils'const HeaderLink = React.memo(function HeaderLink(props: any) {diff --git a/packages/ui/src/components/Accordion/Accordion-old.stories.tsx b/packages/ui/src/components/Accordion/Accordion-old.stories.tsxdeleted file mode 100644index e11fc9edc0c..00000000000--- a/packages/ui/src/components/Accordion/Accordion-old.stories.tsx+++ /dev/null@@ -1,166 +0,0 @@-import React from 'react'--import Accordion, { AccordionProps } from './Accordion'-import { Badge } from '../Badge'--export default {- title: 'Displays/Accordion',- component: Accordion,-}--export const OneItem = (args: AccordionProps) => (- <Accordion {...args} justified={false}>- <Accordion.Item- header={- <>- <span className="text-scale-900 group-hover:text-scale-1200">Title of the thing</span>- <Badge>Test badge</Badge>- </>- }- id="first"- >- <span className="text-scale-900">- Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.- </span>- </Accordion.Item>- </Accordion>-)--export const MultipleItems = (args: AccordionProps) => (- <Accordion {...args} openBehaviour="multiple">- <Accordion.Item- header={- <span className="text-scale-900 group-hover:text-scale-1200">Title of the thing</span>- }- id={'1'}- >- <span className="text-scale-900">- Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.- </span>- </Accordion.Item>- <Accordion.Item- header={- <span className="text-scale-900 group-hover:text-scale-1200">Title of the thing</span>- }- id={'2'}- >- <span className="text-scale-900">- Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.- </span>- </Accordion.Item>- <Accordion.Item- header={- <span className="text-scale-900 group-hover:text-scale-1200">Title of the thing</span>- }- id={'3'}- >- <span className="text-scale-900">- Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.- </span>- </Accordion.Item>- <Accordion.Item- header={- <span className="text-scale-900 group-hover:text-scale-1200">Title of the thing</span>- }- id={'4'}- >- <span className="text-scale-900">- Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.- </span>- </Accordion.Item>- </Accordion>-)--export const Bordered = (args: AccordionProps) => (- <Accordion {...args}>- <Accordion.Item- header={- <span className="text-scale-900 group-hover:text-scale-1200">Title of the thing</span>- }- id={'1'}- >- <span className="text-scale-900">- Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.- </span>- </Accordion.Item>- <Accordion.Item- header={- <span className="text-scale-900 group-hover:text-scale-1200">Title of the thing</span>- }- id={'2'}- >- <span className="text-scale-900">- Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.- </span>- </Accordion.Item>- <Accordion.Item- header={- <span className="text-scale-900 group-hover:text-scale-1200">Title of the thing</span>- }- id={'3'}- >- <span className="text-scale-900">- Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.- </span>- </Accordion.Item>- <Accordion.Item- header={- <span className="text-scale-900 group-hover:text-scale-1200">Title of the thing</span>- }- id={'4'}- >- <span className="text-scale-900">- Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.- </span>- </Accordion.Item>- </Accordion>-)--Bordered.args = {- type: 'bordered',-}--export const LeftAlignedChevron = (args: AccordionProps) => (- <Accordion {...args} justified={false} chevronAlign="left">- <Accordion.Item- header={- <>- <span className="text-scale-900 group-hover:text-scale-1200">First item</span>- <Badge>Test badge</Badge>- </>- }- id="first"- >- <span className="text-scale-900">- Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.- </span>- </Accordion.Item>- <Accordion.Item- header={- <>- <span className="text-scale-900 group-hover:text-scale-1200">Second item</span>- </>- }- id="second"- >- <span className="text-scale-900">- Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.- </span>- </Accordion.Item>- </Accordion>-)--// export const withDefaultActive = Multiple.bind({})-// withDefaultActive.args = {-// defaultActiveId: [1],-// }--// export const withIconLeft = Multiple.bind({})-// withIconLeft.args = {-// iconPosition: 'left',-// }--// export const withCustomIcon = Multiple.bind({})-// withCustomIcon.args = {-// icon: <IconArrowUp />,-// }diff --git a/packages/ui/src/components/Accordion/Accordion-old.tsx b/packages/ui/src/components/Accordion/Accordion-old.tsxdeleted file mode 100644index 524bf7b9de9..00000000000--- a/packages/ui/src/components/Accordion/Accordion-old.tsx+++ /dev/null@@ -1,137 +0,0 @@-import React, { createContext, useContext, useState } from 'react'--import styleHandler from '../../lib/theme/styleHandler'--import * as RadixAccordion from '@radix-ui/react-accordion'-import { IconChevronDown } from '../Icon/icons/IconChevronDown'-import { IconChevronUp } from '../Icon/icons/IconChevronUp'--type Type = 'default' | 'bordered'-type Size = 'tiny' | 'small' | 'medium' | 'large' | 'xlarge'-type Align = 'left' | 'right'--interface ContextValue {- bordered?: boolean- type: Type- justified: Boolean- chevronAlign: Align-}--const AccordionContext = createContext<ContextValue>({- chevronAlign: 'left',- justified: true,- type: 'default',-})--export interface AccordionProps {- children?: React.ReactNode- className?: string-- onChange?: (item: string | string[]) => void- openBehaviour: 'single' | 'multiple'- type?: Type- defaultValue?: string | string[] | undefined- justified?: Boolean- chevronAlign?: Align-}--function Accordion({- children,- className,- onChange,- openBehaviour = 'multiple',- type = 'default',- defaultValue = undefined,- justified = false,- chevronAlign = 'left',-}: AccordionProps) {- const __styles = styleHandler('accordion')-- let containerClasses = [__styles.variants[type].base]-- if (className) {- containerClasses.push(className)- }-- const contextValue = {- chevronAlign,- justified,- type,- defaultValue,- }-- function handleOnChange(e: string | string[]) {- if (onChange) onChange(e)- const value = e == typeof String ? e.split(' ') : e- // setCurrentItems(e)- // console.log('about to change state')- // currentItems = e- // console.log('currentItems', currentItems)- }-- return (- <>- <RadixAccordion.Root- type={openBehaviour}- onValueChange={handleOnChange}- defaultValue={defaultValue}- className={containerClasses.join(' ')}- children={- <AccordionContext.Provider value={{ ...contextValue }}>- <div>{children}</div>- </AccordionContext.Provider>- }- ></RadixAccordion.Root>- </>- )-}--interface ItemProps {- children?: React.ReactNode- className?: string- header: React.ReactNode- id: string- icon?: React.ReactNode- disabled?: boolean-}--export function Item({ children, className, header, id, disabled }: ItemProps) {- const __styles = styleHandler('accordion')- const [open, setOpen] = useState(false)-- const { type, justified, chevronAlign } = useContext(AccordionContext)-- let triggerClasses = [__styles.variants[type].trigger]- if (justified) triggerClasses.push(__styles.justified)- if (className) triggerClasses.push(className)-- let chevronClasses = [__styles.chevron.base, __styles.chevron.align[chevronAlign]]-- if (open && !disabled) {- chevronClasses.unshift('!rotate-180')- }-- return (- <RadixAccordion.Item- value={id}- className={__styles.variants[type].container}- disabled={disabled}- onClick={() => {- setOpen(!open)- }}- >- <RadixAccordion.Trigger className={triggerClasses.join(' ')}>- {header}- {!disabled && (- <IconChevronDown aria-hidden className={chevronClasses.join(' ')} strokeWidth={2} />- )}- </RadixAccordion.Trigger>- <RadixAccordion.Content className={__styles.variants[type].content}>- <div className={__styles.variants[type].panel}>{children}</div>- </RadixAccordion.Content>- </RadixAccordion.Item>- )-}--Accordion.Item = Item-export default Accordiondiff --git a/packages/ui/src/components/Accordion/Accordion.stories.tsx b/packages/ui/src/components/Accordion/Accordion.stories.tsxindex 25886206394..e11fc9edc0c 100644--- a/packages/ui/src/components/Accordion/Accordion.stories.tsx+++ b/packages/ui/src/components/Accordion/Accordion.stories.tsx@@ -1,79 +1,166 @@-// Button.stories.ts|tsx+import React from 'react'-import type { Meta, StoryObj } from '@storybook/react'--import { Accordion, AccordionItem } from './Accordion'+import Accordion, { AccordionProps } from './Accordion'import { Badge } from '../Badge'-const meta: Meta<typeof Accordion> = {- /* π The title prop is optional.- * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading- * to learn how to generate automatic titles- */- title: 'General/Accordion',+export default {+ title: 'Displays/Accordion',component: Accordion,}-export default meta+export const OneItem = (args: AccordionProps) => (+ <Accordion {...args} justified={false}>+ <Accordion.Item+ header={+ <>+ <span className="text-scale-900 group-hover:text-scale-1200">Title of the thing</span>+ <Badge>Test badge</Badge>+ </>+ }+ id="first"+ >+ <span className="text-scale-900">+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.+ </span>+ </Accordion.Item>+ </Accordion>+)-type Story = StoryObj<typeof Accordion>+export const MultipleItems = (args: AccordionProps) => (+ <Accordion {...args} openBehaviour="multiple">+ <Accordion.Item+ header={+ <span className="text-scale-900 group-hover:text-scale-1200">Title of the thing</span>+ }+ id={'1'}+ >+ <span className="text-scale-900">+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.+ </span>+ </Accordion.Item>+ <Accordion.Item+ header={+ <span className="text-scale-900 group-hover:text-scale-1200">Title of the thing</span>+ }+ id={'2'}+ >+ <span className="text-scale-900">+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.+ </span>+ </Accordion.Item>+ <Accordion.Item+ header={+ <span className="text-scale-900 group-hover:text-scale-1200">Title of the thing</span>+ }+ id={'3'}+ >+ <span className="text-scale-900">+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.+ </span>+ </Accordion.Item>+ <Accordion.Item+ header={+ <span className="text-scale-900 group-hover:text-scale-1200">Title of the thing</span>+ }+ id={'4'}+ >+ <span className="text-scale-900">+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.+ </span>+ </Accordion.Item>+ </Accordion>+)-/*- *π Render functions are a framework specific feature to allow you control on how the component renders.- * See https://storybook.js.org/docs/react/api/csf- * to learn how to use render functions.- */+export const Bordered = (args: AccordionProps) => (+ <Accordion {...args}>+ <Accordion.Item+ header={+ <span className="text-scale-900 group-hover:text-scale-1200">Title of the thing</span>+ }+ id={'1'}+ >+ <span className="text-scale-900">+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.+ </span>+ </Accordion.Item>+ <Accordion.Item+ header={+ <span className="text-scale-900 group-hover:text-scale-1200">Title of the thing</span>+ }+ id={'2'}+ >+ <span className="text-scale-900">+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.+ </span>+ </Accordion.Item>+ <Accordion.Item+ header={+ <span className="text-scale-900 group-hover:text-scale-1200">Title of the thing</span>+ }+ id={'3'}+ >+ <span className="text-scale-900">+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.+ </span>+ </Accordion.Item>+ <Accordion.Item+ header={+ <span className="text-scale-900 group-hover:text-scale-1200">Title of the thing</span>+ }+ id={'4'}+ >+ <span className="text-scale-900">+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.+ </span>+ </Accordion.Item>+ </Accordion>+)-export const Default = {- args: {- type: 'default',- },- render: ({ children, type }: any) => (- <Accordion type={type} openBehaviour="single" collapsible className="w-full">- <Accordion.Item value="item-1">- <Accordion.Trigger>- <span className="text-scale-900 group-hover:text-scale-1200">Title of the thing</span>- </Accordion.Trigger>- <Accordion.Content>Yes. It adheres to the WAI-ARIA design pattern.</Accordion.Content>- </Accordion.Item>- <Accordion.Item value="item-2">- <Accordion.Trigger>Is it styled?</Accordion.Trigger>- <Accordion.Content>- Yes. It comes with default styles that matches the other components' aesthetic.- </Accordion.Content>- </Accordion.Item>- <Accordion.Item value="item-3">- <Accordion.Trigger>Is it animated?</Accordion.Trigger>- <Accordion.Content>- Yes. It's animated by default, but you can disable it if you prefer.- </Accordion.Content>- </Accordion.Item>- </Accordion>- ),+Bordered.args = {+ type: 'bordered',}-export const Bordered = {- args: {- type: 'bordered',- },- render: ({ children, type }: any) => (- <Accordion type={type} openBehaviour="single" collapsible className="w-full">- <Accordion.Item value="item-1">- <Accordion.Trigger>Is it accessible?</Accordion.Trigger>- <Accordion.Content>Yes. It adheres to the WAI-ARIA design pattern.</Accordion.Content>- </Accordion.Item>- <Accordion.Item value="item-2">- <Accordion.Trigger>Is it styled?</Accordion.Trigger>- <Accordion.Content>- Yes. It comes with default styles that matches the other components' aesthetic.- </Accordion.Content>- </Accordion.Item>- <Accordion.Item value="item-3">- <Accordion.Trigger>Is it animated?</Accordion.Trigger>- <Accordion.Content>- Yes. It's animated by default, but you can disable it if you prefer.- </Accordion.Content>- </Accordion.Item>- </Accordion>- ),-}+export const LeftAlignedChevron = (args: AccordionProps) => (+ <Accordion {...args} justified={false} chevronAlign="left">+ <Accordion.Item+ header={+ <>+ <span className="text-scale-900 group-hover:text-scale-1200">First item</span>+ <Badge>Test badge</Badge>+ </>+ }+ id="first"+ >+ <span className="text-scale-900">+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.+ </span>+ </Accordion.Item>+ <Accordion.Item+ header={+ <>+ <span className="text-scale-900 group-hover:text-scale-1200">Second item</span>+ </>+ }+ id="second"+ >+ <span className="text-scale-900">+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.+ </span>+ </Accordion.Item>+ </Accordion>+)++// export const withDefaultActive = Multiple.bind({})+// withDefaultActive.args = {+// defaultActiveId: [1],+// }++// export const withIconLeft = Multiple.bind({})+// withIconLeft.args = {+// iconPosition: 'left',+// }++// export const withCustomIcon = Multiple.bind({})+// withCustomIcon.args = {+// icon: <IconArrowUp />,+// }diff --git a/packages/ui/src/components/Accordion/Accordion.tsx b/packages/ui/src/components/Accordion/Accordion.tsxindex 80a8cbd7d3e..524bf7b9de9 100644--- a/packages/ui/src/components/Accordion/Accordion.tsx+++ b/packages/ui/src/components/Accordion/Accordion.tsx@@ -1,234 +1,137 @@-import * as AccordionPrimitive from '@radix-ui/react-accordion'-import { cn } from '@ui/lib/utils'-import { VariantProps, cva, cx } from 'class-variance-authority'-import { ChevronDown } from 'lucide-react'import React, { createContext, useContext, useState } from 'react'-export type AccordionRootVariantsProps = VariantProps<typeof accordionRootVariants>-const accordionRootVariants = cva('flex flex-col', {- variants: {- type: {- default: 'space-y-3',- bordered: '-space-y-px',- },- defaultVariants: {- type: 'default',- },- },-})+import styleHandler from '../../lib/theme/styleHandler'-export type AccordionItemVariantsProps = VariantProps<typeof accordionItemVariants>-const accordionItemVariants = cva(- 'group first:rounded-tl-md first:rounded-tr-md last:rounded-bl-md last:rounded-br-md',- {- variants: {- type: {- default: 'overflow-hidden',- bordered: 'border border-scale-700',- },- justified: {- true: 'justify-between',- false: '',- },- },- }-)--const accordionTriggerVariants = cva(- `flex flex-row items-center w-full text-left cursor-pointer focus-visible:ring-1 focus-visible:z-10 ring-scale-1100- justify-between transition-all hover:underline [&[data-state=open]>svg]:rotate-180`,- {- variants: {- type: {- default: 'gap-3',- bordered: `- px-6 py-4- font-medium text-base bg-transparent- transition-colors hover:bg-scale-200- overflow-hidden- group-first:rounded-tl-md group-first:rounded-tr-md- group-last:rounded-bl-md group-last:rounded-br-md`,- },- },- }-)--const accordionContentVariants = cva('pb-4 pt-0', {- variants: {- type: {- default: '',- bordered: 'px-6',- },- },-})+import * as RadixAccordion from '@radix-ui/react-accordion'+import { IconChevronDown } from '../Icon/icons/IconChevronDown'+import { IconChevronUp } from '../Icon/icons/IconChevronUp'-type Type = AccordionRootVariantsProps['type']-type Align = 'left' | 'right' | undefined+type Type = 'default' | 'bordered'+type Size = 'tiny' | 'small' | 'medium' | 'large' | 'xlarge'+type Align = 'left' | 'right'interface ContextValue {- chevronAlign: Align- justified: boolean+ bordered?: booleantype: Type- defaultValue: AccordionPrimitive.AccordionImplSingleProps['defaultValue']+ justified: Boolean+ chevronAlign: Align}-interface AdditionalProps {- openBehaviour: 'single' | 'multiple'- variant?: Type- // Add other additional props here+const AccordionContext = createContext<ContextValue>({+ chevronAlign: 'left',+ justified: true,+ type: 'default',+})++export interface AccordionProps {+ children?: React.ReactNode+ className?: string+onChange?: (item: string | string[]) => void+ openBehaviour: 'single' | 'multiple'type?: Type- justified?: AccordionItemVariantsProps['justified']+ defaultValue?: string | string[] | undefined+ justified?: BooleanchevronAlign?: Align}-interface AccordionComponent- extends React.ForwardRefExoticComponent<- ExtendedAccordionProps & React.RefAttributes<HTMLDivElement>- > {- Item: typeof AccordionItem- Content: typeof AccordionContent- Trigger: typeof AccordionTrigger-}+function Accordion({+ children,+ className,+ onChange,+ openBehaviour = 'multiple',+ type = 'default',+ defaultValue = undefined,+ justified = false,+ chevronAlign = 'left',+}: AccordionProps) {+ const __styles = styleHandler('accordion')++ let containerClasses = [__styles.variants[type].base]++ if (className) {+ containerClasses.push(className)+ }-export interface AccordionSingleProps extends AccordionPrimitive.AccordionImplSingleProps {- openBehaviour: 'single'- value?: string- // Add other props specific to single accordion-}+ const contextValue = {+ chevronAlign,+ justified,+ type,+ defaultValue,+ }-export interface AccordionMultipleProps extends AccordionPrimitive.AccordionImplMultipleProps {- openBehaviour: 'multiple'- value?: string[]- // Add other props specific to multiple accordion+ function handleOnChange(e: string | string[]) {+ if (onChange) onChange(e)+ const value = e == typeof String ? e.split(' ') : e+ // setCurrentItems(e)+ // console.log('about to change state')+ // currentItems = e+ // console.log('currentItems', currentItems)+ }++ return (+ <>+ <RadixAccordion.Root+ type={openBehaviour}+ onValueChange={handleOnChange}+ defaultValue={defaultValue}+ className={containerClasses.join(' ')}+ children={+ <AccordionContext.Provider value={{ ...contextValue }}>+ <div>{children}</div>+ </AccordionContext.Provider>+ }+ ></RadixAccordion.Root>+ </>+ )}-type ExtendedAccordionProps = (AccordionSingleProps | AccordionMultipleProps) & AdditionalProps+interface ItemProps {+ children?: React.ReactNode+ className?: string+ header: React.ReactNode+ id: string+ icon?: React.ReactNode+ disabled?: boolean+}-const AccordionContext = createContext<ContextValue>({- chevronAlign: 'left',- justified: false, // Set the default value to false- type: undefined,- defaultValue: undefined,-})+export function Item({ children, className, header, id, disabled }: ItemProps) {+ const __styles = styleHandler('accordion')+ const [open, setOpen] = useState(false)-const Accordion: AccordionComponent = React.forwardRef(- ({ openBehaviour, type, chevronAlign, justified, defaultValue, ...props }, ref) => {- function handleOnChange(e: string | string[]) {- if (props.onChange) props.onChange(e)- }-- const contextValue = {- chevronAlign,- justified: justified || false, // Provide a default value of false- type: type || 'default', // Provide a default value for the type- defaultValue: Array.isArray(defaultValue) ? defaultValue.join('') : defaultValue, // Convert array to string- }-- if (openBehaviour === 'single') {- const { value, children, className, ...singleProps } = props as AccordionSingleProps- return (- <AccordionPrimitive.Root- ref={ref}- type="single"- onValueChange={handleOnChange}- value={value}- defaultValue={defaultValue}- className={cn(accordionRootVariants({ type }), className)}- children={- <AccordionContext.Provider value={{ ...contextValue }}>- {children}- </AccordionContext.Provider>- }- {...singleProps}- />- )- } else {- const { value, children, className, ...multipleProps } = props as AccordionMultipleProps- return (- <AccordionPrimitive.Root- ref={ref}- type="multiple"- onValueChange={handleOnChange}- value={value}- className={cn(accordionRootVariants({ type }), className)}- children={- <AccordionContext.Provider value={{ ...contextValue }}>- <div>{props.children}</div>- </AccordionContext.Provider>- }- {...multipleProps}- />- )- }- }-) as AccordionComponent+ const { type, justified, chevronAlign } = useContext(AccordionContext)-export interface ItemAdditionalProps- extends React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item> {}+ let triggerClasses = [__styles.variants[type].trigger]+ if (justified) triggerClasses.push(__styles.justified)+ if (className) triggerClasses.push(className)-export const AccordionItem = React.forwardRef<- React.ElementRef<typeof AccordionPrimitive.Item>,- React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>->(({ className, ...props }, ref) => {- const [open, setOpen] = useState(false)+ let chevronClasses = [__styles.chevron.base, __styles.chevron.align[chevronAlign]]- let { type, justified } = useContext(AccordionContext)+ if (open && !disabled) {+ chevronClasses.unshift('!rotate-180')+ }return (- <AccordionPrimitive.Item- ref={ref}- className={cn(accordionItemVariants({ type, justified }), className)}+ <RadixAccordion.Item+ value={id}+ className={__styles.variants[type].container}+ disabled={disabled}onClick={() => {setOpen(!open)}}- {...props}- />- )-})-AccordionItem.displayName = AccordionPrimitive.Item.displayName--export const AccordionTrigger = React.forwardRef<- React.ElementRef<typeof AccordionPrimitive.Trigger>,- React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger>->(({ className, children, ...props }, ref) => {- const { type } = useContext(AccordionContext)- return (- <AccordionPrimitive.Header className="flex">- <AccordionPrimitive.Trigger- ref={ref}- className={cn(accordionTriggerVariants({ type }), className)}- {...props}- >- {children}- <ChevronDown className="h-4 w-4 transition-transform duration-200" />- </AccordionPrimitive.Trigger>- </AccordionPrimitive.Header>- )-})-AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName--export const AccordionContent = React.forwardRef<- React.ElementRef<typeof AccordionPrimitive.Content>,- React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Content>->(({ className, children, ...props }, ref) => {- const { type } = useContext(AccordionContext)- return (- <AccordionPrimitive.Content- ref={ref}- className={cn(- 'overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down',- className- )}- {...props}>- <div className={cx(accordionContentVariants({ type }))}>{children}</div>- </AccordionPrimitive.Content>+ <RadixAccordion.Trigger className={triggerClasses.join(' ')}>+ {header}+ {!disabled && (+ <IconChevronDown aria-hidden className={chevronClasses.join(' ')} strokeWidth={2} />+ )}+ </RadixAccordion.Trigger>+ <RadixAccordion.Content className={__styles.variants[type].content}>+ <div className={__styles.variants[type].panel}>{children}</div>+ </RadixAccordion.Content>+ </RadixAccordion.Item>)-})-AccordionContent.displayName = AccordionPrimitive.Content.displayName+}-Accordion.Item = AccordionItem-Accordion.Content = AccordionContent-Accordion.Trigger = AccordionTrigger-export { Accordion }+Accordion.Item = Item+export default Accordiondiff --git a/packages/ui/src/components/Alert/Alert-old.stories.tsx b/packages/ui/src/components/Alert/Alert-old.stories.tsxdeleted file mode 100644index 915e408018b..00000000000--- a/packages/ui/src/components/Alert/Alert-old.stories.tsx+++ /dev/null@@ -1,135 +0,0 @@-import React from 'react'--import Alert, { AlertProps } from './Alert'--export default {- title: 'Displays/Alerts',- component: Alert,-}--export const Neutral = (args: AlertProps) => (- <Alert {...args}>- Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.- </Alert>-)--export const Success = (args: AlertProps) => (- <Alert {...args}>- Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.- </Alert>-)--export const SuccessWithIcon = (args: AlertProps) => (- <Alert {...args}>- Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.- </Alert>-)--export const Danger = (args: AlertProps) => (- <Alert {...args}>- Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.- </Alert>-)--export const DangerWithIcon = (args: AlertProps) => (- <Alert {...args}>- Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.- </Alert>-)--export const Info = (args: AlertProps) => (- <Alert {...args}>- Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.- </Alert>-)--export const InfoWithIcon = (args: AlertProps) => (- <Alert {...args}>- Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.- </Alert>-)--export const Warning = (args: AlertProps) => (- <Alert {...args}>- Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.- </Alert>-)--export const WarningWithIcon = (args: AlertProps) => (- <Alert {...args}>- Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.- </Alert>-)--export const Closable = (args: AlertProps) => (- <Alert {...args}>- Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.- </Alert>-)--export const WithAction = (args: AlertProps) => (- <Alert {...args}>- Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.- </Alert>-)--Neutral.args = {- title: 'Success alert with icon',- withIcon: true,-}--Success.args = {- title: 'Success alert',- variant: 'success',-}--SuccessWithIcon.args = {- title: 'Success alert with icon',- variant: 'success',- withIcon: true,-}--Danger.args = {- title: 'Danger alert',- variant: 'danger',-}--DangerWithIcon.args = {- title: 'Danger alert with icon',- variant: 'danger',- withIcon: true,-}--Info.args = {- title: 'Info alert',- variant: 'info',-}--InfoWithIcon.args = {- title: 'Info alert with icon',- variant: 'info',- withIcon: true,-}--Warning.args = {- title: 'Warning alert',- variant: 'warning',-}--WarningWithIcon.args = {- title: 'Warning alert with icon',- variant: 'warning',- withIcon: true,-}--Closable.args = {- title: 'Closable alert',- closable: true,-}--WithAction.args = {- title: 'Alert with action',- variant: 'warning',- withIcon: true,- actions: <div>Hello</div>,-}diff --git a/packages/ui/src/components/Alert/Alert-old.tsx b/packages/ui/src/components/Alert/Alert-old.tsxdeleted file mode 100644index cf0b96fe810..00000000000--- a/packages/ui/src/components/Alert/Alert-old.tsx+++ /dev/null@@ -1,84 +0,0 @@-import React, { useState } from 'react'-import { IconAlertTriangle } from '../Icon/icons/IconAlertTriangle'--import { IconInfo } from '../Icon/icons/IconInfo'-import { IconX } from '../Icon/icons/IconX'--import styleHandler from '../../lib/theme/styleHandler'-import { IconAlertOctagon } from '../Icon/icons/IconAlertOctagon'-import { IconCheckCircle } from '../Icon/icons/IconCheckCircle'--export interface AlertProps {- variant?: 'success' | 'danger' | 'warning' | 'info' | 'neutral'- className?: string- title: string | React.ReactNode- withIcon?: boolean- closable?: boolean- children?: React.ReactNode- icon?: React.ReactNode- actions?: React.ReactNode-}--const icons: Record<'success' | 'danger' | 'warning' | 'info' | 'neutral', React.ReactElement> = {- danger: <IconAlertOctagon strokeWidth={1.5} size={18} />,- success: <IconCheckCircle strokeWidth={1.5} size={18} />,- warning: <IconAlertTriangle strokeWidth={1.5} size={18} />,- info: <IconInfo strokeWidth={1.5} size={18} />,- neutral: <></>,-}--function Alert({- variant = 'neutral',- className,- title,- withIcon,- closable,- children,- icon,- actions,-}: AlertProps) {- let __styles = styleHandler('alert')-- const [visible, setVisible] = useState(true)-- let containerClasses = [__styles.base]- containerClasses.push(__styles.variant[variant].base)-- if (className) containerClasses.push(className)-- let descriptionClasses = [__styles.description, __styles.variant[variant].description]- let closeButtonClasses = [__styles.close]-- return (- <>- {visible && (- <div className={containerClasses.join(' ')}>- {withIcon ? (- <div className={__styles.variant[variant].icon}>{withIcon && icons[variant]}</div>- ) : null}- {icon && icon}- <div className="flex flex-1 items-center justify-between">- <div>- <h3 className={[__styles.variant[variant].header, __styles.header].join(' ')}>- {title}- </h3>- <div className={descriptionClasses.join(' ')}>{children}</div>- </div>- {actions}- </div>- {closable && (- <button- aria-label="Close alert"- onClick={() => setVisible(false)}- className={closeButtonClasses.join(' ')}- >- <IconX strokeWidth={2} size={16} />- </button>- )}- </div>- )}- </>- )-}--export default Alertdiff --git a/packages/ui/src/components/Alert/Alert.stories.tsx b/packages/ui/src/components/Alert/Alert.stories.tsxindex de5cf016871..611c47ee072 100644--- a/packages/ui/src/components/Alert/Alert.stories.tsx+++ b/packages/ui/src/components/Alert/Alert.stories.tsx@@ -1,92 +1,135 @@-// Button.stories.ts|tsx+import React from 'react'-import type { Meta, StoryObj } from '@storybook/react'+import Alert, { AlertProps } from '../shadcn/updated/Alert/Alert'-import { Alert, AlertProps } from './Alert'+export default {+ title: 'Displays/Alerts',+ component: Alert,+}-import { IconAirplay } from '../Icon/icons/IconAirplay'-import { Terminal } from 'lucide-react'+export const Neutral = (args: AlertProps) => (+ <Alert {...args}>+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.+ </Alert>+)-const meta: Meta<typeof Alert> = {- /* π The title prop is optional.- * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading- * to learn how to generate automatic titles- */- title: 'General/Alert',- component: Alert,+export const Success = (args: AlertProps) => (+ <Alert {...args}>+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.+ </Alert>+)++export const SuccessWithIcon = (args: AlertProps) => (+ <Alert {...args}>+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.+ </Alert>+)++export const Danger = (args: AlertProps) => (+ <Alert {...args}>+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.+ </Alert>+)++export const DangerWithIcon = (args: AlertProps) => (+ <Alert {...args}>+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.+ </Alert>+)++export const Info = (args: AlertProps) => (+ <Alert {...args}>+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.+ </Alert>+)++export const InfoWithIcon = (args: AlertProps) => (+ <Alert {...args}>+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.+ </Alert>+)++export const Warning = (args: AlertProps) => (+ <Alert {...args}>+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.+ </Alert>+)++export const WarningWithIcon = (args: AlertProps) => (+ <Alert {...args}>+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.+ </Alert>+)++export const Closable = (args: AlertProps) => (+ <Alert {...args}>+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.+ </Alert>+)++export const WithAction = (args: AlertProps) => (+ <Alert {...args}>+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.+ </Alert>+)++Neutral.args = {+ title: 'Success alert with icon',+ withIcon: true,+}++Success.args = {+ title: 'Success alert',+ variant: 'success',+}++SuccessWithIcon.args = {+ title: 'Success alert with icon',+ variant: 'success',+ withIcon: true,+}++Danger.args = {+ title: 'Danger alert',+ variant: 'danger',+}++DangerWithIcon.args = {+ title: 'Danger alert with icon',+ variant: 'danger',+ withIcon: true,+}++Info.args = {+ title: 'Info alert',+ variant: 'info',}-export default meta--type Story = StoryObj<typeof Alert>--/*- *π Render functions are a framework specific feature to allow you control on how the component renders.- * See https://storybook.js.org/docs/react/api/csf- * to learn how to use render functions.- */--export const Info = {- args: {- variant: 'info',- withIcon: true,- },- render: ({ withIcon, variant }: AlertProps) => (- <Alert variant={variant} withIcon={withIcon}>- <Alert.Title>Info Alert</Alert.Title>- <Alert.Description>This is an informative message for your application.</Alert.Description>- </Alert>- ),+InfoWithIcon.args = {+ title: 'Info alert with icon',+ variant: 'info',+ withIcon: true,}-export const Danger = {- args: {- variant: 'danger',- withIcon: true,- },- render: ({ withIcon, variant }: AlertProps) => (- <Alert variant={variant} withIcon={withIcon}>- <Alert.Title>Danger Alert</Alert.Title>- <Alert.Description>This is a dangerous warning for your application.</Alert.Description>- </Alert>- ),+Warning.args = {+ title: 'Warning alert',+ variant: 'warning',}-export const Warning = {- args: {- variant: 'warning',- withIcon: true,- },- render: ({ withIcon, variant }: AlertProps) => (- <Alert variant={variant} withIcon={withIcon}>- <Alert.Title>Warning Alert</Alert.Title>- <Alert.Description>This is a warning message for your application.</Alert.Description>- </Alert>- ),+WarningWithIcon.args = {+ title: 'Warning alert with icon',+ variant: 'warning',+ withIcon: true,}-export const Success = {- args: {- variant: 'success',- withIcon: true,- },- render: ({ withIcon, variant }: AlertProps) => (- <Alert variant={variant} withIcon={withIcon}>- <Alert.Title>Success Alert</Alert.Title>- <Alert.Description>This is a successful notification for your application.</Alert.Description>- </Alert>- ),+Closable.args = {+ title: 'Closable alert',+ closable: true,}-export const Neutral = {- args: {- variant: 'neutral',- withIcon: true,- },- render: ({ withIcon, variant }: AlertProps) => (- <Alert variant={variant} withIcon={withIcon}>- <Alert.Title>Neutral Alert</Alert.Title>- <Alert.Description>This is a neutral message for your application.</Alert.Description>- </Alert>- ),+WithAction.args = {+ title: 'Alert with action',+ variant: 'warning',+ withIcon: true,+ actions: <div>Hello</div>,}diff --git a/packages/ui/src/components/Alert/Alert.tsx b/packages/ui/src/components/Alert/Alert.tsxindex a89ea6ce8d2..cf0b96fe810 100644--- a/packages/ui/src/components/Alert/Alert.tsx+++ b/packages/ui/src/components/Alert/Alert.tsx@@ -1,145 +1,84 @@-import { cn } from '@ui/lib/utils'-import { VariantProps, cva } from 'class-variance-authority'-import { AlertOctagon, AlertTriangle, Check, Info } from 'lucide-react'-import * as React from 'react'--export type AlertRootVariantsProps = VariantProps<typeof alertRootVariants>-const alertRootVariants = cva(- `relative w-full- rounded-lg border- py-4 px-6- [&>svg]:absolute [&>svg]:text-foreground [&>svg]:left-4 [&>svg]:top-4 [&>svg+div]:translate-y-[-3px] [&:has(svg)]:pl-11`,- {- variants: {- variant: {- danger: `bg-red-200 dark:bg-red-100 text-red-1200 border-red-700 [&>svg]:text-red-1200`,- warning: `bg-amber-200 dark:bg-amber-100 border-amber-700 [&>svg]:text-amber-1200`,- info: `bg-scale-400 border-scale-500 dark:bg-scale-100 dark:border-scale-300 [&>svg]:text-scale-1200`,- success: `bg-brand-300 dark:bg-brand-100 border-brand-700 [&>svg]:text-brand-900`,- neutral: `bg-scale-300 dark:bg-scale-300 border-scale-500 [&>svg]:text-scale-900`,- },- },- defaultVariants: {- variant: 'info',- },- }-)--const alertTitleVariants = cva('mb-1 font-medium leading-none tracking-tight', {- variants: {- variant: {- danger: `text-red-1200`,- warning: `text-amber-1200`,- info: `text-scale-1200`,- success: `text-brand-1200`,- neutral: `text-scale-1200`,- },- defaultVariants: {- variant: 'info',- },- },-})--const alertDescriptionVariants = cva('text-sm [&_p]:leading-relaxed', {- variants: {- variant: {- danger: 'text-red-1100',- warning: 'text-amber-1100',- info: 'text-scale-1100',- success: 'text-brand-1100',- neutral: 'text-scale-1100',- },- defaultVariants: {- variant: 'info',- },- },-})--interface ContextValue {- variant: AlertRootVariantsProps['variant']-}--const AlertContext = React.createContext<ContextValue>({- variant: undefined,-})--// Define the Alert component-interface AlertProps- extends React.HTMLAttributes<HTMLDivElement>,- VariantProps<typeof alertRootVariants> {- withIcon: boolean+import React, { useState } from 'react'+import { IconAlertTriangle } from '../Icon/icons/IconAlertTriangle'++import { IconInfo } from '../Icon/icons/IconInfo'+import { IconX } from '../Icon/icons/IconX'++import styleHandler from '../../lib/theme/styleHandler'+import { IconAlertOctagon } from '../Icon/icons/IconAlertOctagon'+import { IconCheckCircle } from '../Icon/icons/IconCheckCircle'++export interface AlertProps {+ variant?: 'success' | 'danger' | 'warning' | 'info' | 'neutral'+ className?: string+ title: string | React.ReactNode+ withIcon?: boolean+ closable?: boolean+ children?: React.ReactNode+ icon?: React.ReactNode+ actions?: React.ReactNode}-interface AlertComponent- extends React.ForwardRefExoticComponent<AlertProps & React.RefAttributes<HTMLDivElement>> {- Title: typeof AlertTitle- Description: typeof AlertDescription-}--type AlertIconVariant = Exclude<AlertRootVariantsProps['variant'], null | undefined>-const icons: Record<AlertIconVariant, React.ReactElement> = {- danger: <AlertOctagon strokeWidth={1.5} size={18} />,- success: <Check strokeWidth={1.5} size={18} />,- warning: <AlertTriangle strokeWidth={1.5} size={18} />,- info: <Info strokeWidth={1.5} size={18} />,+const icons: Record<'success' | 'danger' | 'warning' | 'info' | 'neutral', React.ReactElement> = {+ danger: <IconAlertOctagon strokeWidth={1.5} size={18} />,+ success: <IconCheckCircle strokeWidth={1.5} size={18} />,+ warning: <IconAlertTriangle strokeWidth={1.5} size={18} />,+ info: <IconInfo strokeWidth={1.5} size={18} />,neutral: <></>,}-const Alert = React.forwardRef<HTMLDivElement, AlertProps>(- ({ className, withIcon, variant = 'info', children, ...props }, ref) => {- const contextValue = {- variant,- }-- return (- <div- ref={ref}- role="alert"- className={cn(alertRootVariants({ variant }), className)}- {...props}- children={- <AlertContext.Provider value={{ ...contextValue }}>- {withIcon && icons[variant as AlertIconVariant]}- {children}- </AlertContext.Provider>- }- />- )- }-) as AlertComponent--Alert.displayName = 'Alert'--// Define the AlertTitle component as a subcomponent of Alert-interface AlertTitleProps extends React.HTMLAttributes<HTMLHeadingElement> {}--const AlertTitle = React.forwardRef<HTMLHeadingElement, AlertTitleProps>(- ({ className, ...props }, ref) => {- const { variant } = React.useContext(AlertContext)- console.log('variant', variant)- return <h5 ref={ref} className={cn(alertTitleVariants({ variant }), className)} {...props} />- }-)--AlertTitle.displayName = 'AlertTitle'--// Define the AlertDescription component as a subcomponent of Alert-interface AlertDescriptionProps extends React.HTMLAttributes<HTMLParagraphElement> {}--const AlertDescription = React.forwardRef<HTMLParagraphElement, AlertDescriptionProps>(- ({ className, ...props }, ref) => {- const { variant } = React.useContext(AlertContext)- return (- <div ref={ref} className={cn(alertDescriptionVariants({ variant }), className)} {...props} />- )- }-)--AlertDescription.displayName = 'AlertDescription'--// Attach the subcomponents to the Alert component-Alert.Title = AlertTitle-Alert.Description = AlertDescription+function Alert({+ variant = 'neutral',+ className,+ title,+ withIcon,+ closable,+ children,+ icon,+ actions,+}: AlertProps) {+ let __styles = styleHandler('alert')++ const [visible, setVisible] = useState(true)++ let containerClasses = [__styles.base]+ containerClasses.push(__styles.variant[variant].base)++ if (className) containerClasses.push(className)++ let descriptionClasses = [__styles.description, __styles.variant[variant].description]+ let closeButtonClasses = [__styles.close]++ return (+ <>+ {visible && (+ <div className={containerClasses.join(' ')}>+ {withIcon ? (+ <div className={__styles.variant[variant].icon}>{withIcon && icons[variant]}</div>+ ) : null}+ {icon && icon}+ <div className="flex flex-1 items-center justify-between">+ <div>+ <h3 className={[__styles.variant[variant].header, __styles.header].join(' ')}>+ {title}+ </h3>+ <div className={descriptionClasses.join(' ')}>{children}</div>+ </div>+ {actions}+ </div>+ {closable && (+ <button+ aria-label="Close alert"+ onClick={() => setVisible(false)}+ className={closeButtonClasses.join(' ')}+ >+ <IconX strokeWidth={2} size={16} />+ </button>+ )}+ </div>+ )}+ </>+ )+}-// Export the Alert component-export { Alert }+export default Alertdiff --git a/packages/ui/src/components/Alert/index.tsx b/packages/ui/src/components/Alert/index.tsxindex fd2a1266021..545a13bde4d 100644--- a/packages/ui/src/components/Alert/index.tsx+++ b/packages/ui/src/components/Alert/index.tsx@@ -1 +1 @@-export { default as Alert } from './Alert'+export { default as Alert } from '../shadcn/updated/Alert/Alert'diff --git a/packages/ui/src/components/Badge/Badge.tsx b/packages/ui/src/components/Badge/Badge.tsxindex 199d771d0f3..c7096715f21 100644--- a/packages/ui/src/components/Badge/Badge.tsx+++ b/packages/ui/src/components/Badge/Badge.tsx@@ -1,7 +1,7 @@import * as React from 'react'import { VariantProps, cva } from 'class-variance-authority'-import { cn } from '@ui/lib/utils'+import { cn } from './../../lib/utils'const badgeVariants = cva('inline-flex items-center border rounded-full px-2.5 py-0.5 text-xs font-normal transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2',diff --git a/packages/ui/src/components/Button/Button-old.tsx b/packages/ui/src/components/Button/Button-old.tsxdeleted file mode 100644index 145a9333ebb..00000000000--- a/packages/ui/src/components/Button/Button-old.tsx+++ /dev/null@@ -1,159 +0,0 @@-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.stories-old.tsx b/packages/ui/src/components/Button/Button.stories-old.tsxdeleted file mode 100644index 57c0e956cc7..00000000000--- a/packages/ui/src/components/Button/Button.stories-old.tsx+++ /dev/null@@ -1,234 +0,0 @@-import { Button } from './'-import { IconPackage } from './../Icon/icons/IconPackage'-import { IconChevronRight } from './../Icon/icons/IconChevronRight'--export default {- title: 'General/Button',- component: Button,-}--export const Neutral = (args: any) => <Button {...args}>Button text</Button>-export const Success = (args: any) => <Button {...args}>Button text</Button>-export const withStyles = (args: any) => <Button {...args}>Button text</Button>-export const withIcon = (args: any) => <Button {...args}>Button text</Button>-export const withIconRight = (args: any) => <Button {...args}>Button text</Button>-export const withBlock = (args: any) => <Button {...args}>Button text</Button>-export const withOnlyIcon = (args: any) => <Button {...args} />-export const withOnlyLoading = (args: any) => <Button {...args} />-export const withLoadingCentered = (args: any) => (- <Button {...args}>Loading icon is centered</Button>-)--export const allButtons = (args: any) => (- <>- <div className="flex flex-col space-y-4">- <div className="flex space-x-4">- <Button {...args} size="tiny">- Button text- </Button>- <Button {...args} size="tiny" type="default">- Button text- </Button>- <Button {...args} size="tiny" type="secondary">- Button text- </Button>- <Button {...args} size="tiny" type="alternative">- Button text- </Button>- <Button {...args} size="tiny" type="link">- Button text- </Button>- <Button {...args} size="tiny" type="text">- Button text- </Button>- <Button {...args} size="tiny" type="dashed">- Button text- </Button>- <Button {...args} size="tiny" type="outline">- Button text- </Button>- <Button {...args} size="tiny" type="danger">- Button text- </Button>- <Button {...args} size="tiny" type="warning">- Button text- </Button>- </div>-- <div className="flex space-x-4">- <Button {...args} size="small">- Button text- </Button>- <Button {...args} size="small" type="default">- Button text- </Button>- <Button {...args} size="small" type="secondary">- Button text- </Button>- <Button {...args} size="small" type="alternative">- Button text- </Button>- <Button {...args} size="small" type="link">- Button text- </Button>- <Button {...args} size="small" type="text">- Button text- </Button>- <Button {...args} size="small" type="dashed">- Button text- </Button>- <Button {...args} size="small" type="outline">- Button text- </Button>- <Button {...args} size="small" type="danger">- Button text- </Button>- <Button {...args} size="small" type="warning">- Button text- </Button>- </div>- <div className="flex space-x-4">- <Button {...args} size="medium">- Button text- </Button>- <Button {...args} size="medium" type="default">- Button text- </Button>- <Button {...args} size="medium" type="secondary">- Button text- </Button>- <Button {...args} size="medium" type="alternative">- Button text- </Button>- <Button {...args} size="medium" type="link">- Button text- </Button>- <Button {...args} size="medium" type="text">- Button text- </Button>- <Button {...args} size="medium" type="dashed">- Button text- </Button>- <Button {...args} size="medium" type="outline">- Button text- </Button>- <Button {...args} size="medium" type="danger">- Button text- </Button>- <Button {...args} size="medium" type="warning">- Button text- </Button>- </div>- <div className="flex space-x-4">- <Button {...args} size="large">- Button text- </Button>- <Button {...args} size="large" type="default">- Button text- </Button>- <Button {...args} size="large" type="secondary">- Button text- </Button>- <Button {...args} size="large" type="alternative">- Button text- </Button>- <Button {...args} size="large" type="link">- Button text- </Button>- <Button {...args} size="large" type="text">- Button text- </Button>- <Button {...args} size="large" type="dashed">- Button text- </Button>- <Button {...args} size="large" type="outline">- Button text- </Button>- <Button {...args} size="large" type="danger">- Button text- </Button>- <Button {...args} size="large" type="warning">- Button text- </Button>- </div>- <div className="flex space-x-4">- <Button {...args} size="xlarge">- Button text- </Button>- <Button {...args} size="xlarge" type="default">- Button text- </Button>- <Button {...args} size="xlarge" type="secondary">- Button text- </Button>- <Button {...args} size="xlarge" type="alternative">- Button text- </Button>- <Button {...args} size="xlarge" type="link">- Button text- </Button>- <Button {...args} size="xlarge" type="text">- Button text- </Button>- <Button {...args} size="xlarge" type="dashed">- Button text- </Button>- <Button {...args} size="xlarge" type="outline">- Button text- </Button>- <Button {...args} size="xlarge" type="danger">- Button text- </Button>- <Button {...args} size="xlarge" type="warning">- Button text- </Button>- </div>- </div>- </>-)--export const withCustomTag = (args: any) => <Button {...args}>Button text</Button>--const icon = <IconPackage />--withIcon.args = {- type: 'primary',- icon: icon,-}--withIconRight.args = {- type: 'primary',- iconRight: <IconChevronRight strokeWidth={2} />,-}--withStyles.args = {- type: 'primary',- style: { backgroundColor: 'red', color: 'yellow' },-}--withBlock.args = {- type: 'primary',- block: true,-}--withOnlyIcon.args = {- icon: icon,-}--withOnlyLoading.args = {- loading: true,-}--withLoadingCentered.args = {- loading: true,- loadingCentered: true,-}--allButtons.args = {- loading: false,- danger: false,-}--withCustomTag.args = {- as: 'span',-}diff --git a/packages/ui/src/components/Button/Button.stories.tsx b/packages/ui/src/components/Button/Button.stories.tsxindex 3827669916e..cc821725f15 100644--- a/packages/ui/src/components/Button/Button.stories.tsx+++ b/packages/ui/src/components/Button/Button.stories.tsx@@ -1,175 +1,234 @@-// Button.stories.ts|tsx+import { Button } from '.'+import { IconPackage } from '../Icon/icons/IconPackage'+import { IconChevronRight } from '../Icon/icons/IconChevronRight'-import type { Meta, StoryObj } from '@storybook/react'--import { Button, ButtonProps } from './Button'--import { IconAirplay } from '../Icon/icons/IconAirplay'--const meta: Meta<typeof Button> = {- /* π The title prop is optional.- * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading- * to learn how to generate automatic titles- */+export default {title: 'General/Button',component: Button,}-export default meta--type Story = StoryObj<typeof Button>--/*- *π Render functions are a framework specific feature to allow you control on how the component renders.- * See https://storybook.js.org/docs/react/api/csf- * to learn how to use render functions.- */--export const Primary = {- args: {- children: 'Hello world',- type: 'primary',- },- render: ({ children, type }: ButtonProps) => <Button type={type}>{children}</Button>,-}-export const Default = {- args: {- children: 'Hello world',- type: 'default',- },- render: ({ children, type }: ButtonProps) => <Button type={type}>{children}</Button>,-}--export const Alternative = {- args: {- children: 'Hello world',- type: 'alternative',- },- render: ({ children, type }: ButtonProps) => <Button type={type}>{children}</Button>,-}--export const Outline = {- args: {- children: 'Hello world',- type: 'outline',- },- render: ({ children, type }: ButtonProps) => <Button type={type}>{children}</Button>,-}--export const Secondary = {- args: {- children: 'Hello world',- type: 'secondary',- },- render: ({ children, type }: ButtonProps) => <Button type={type}>{children}</Button>,-}--export const Dashed = {- args: {- children: 'Hello world',- type: 'dashed',- },- render: ({ children, type }: ButtonProps) => <Button type={type}>{children}</Button>,-}--export const Link = {- args: {- children: 'Hello world',- type: 'link',- },- render: ({ children, type }: ButtonProps) => <Button type={type}>{children}</Button>,-}--export const Text = {- args: {- children: 'Hello world',- type: 'text',- },- render: ({ children, type }: ButtonProps) => <Button type={type}>{children}</Button>,-}--export const Danger = {- args: {- children: 'Hello world',- type: 'danger',- },- render: ({ children, type }: ButtonProps) => <Button type={type}>{children}</Button>,-}--export const Block = {- args: {- children: 'Hello world',- type: 'primary',- block: true,- },- render: ({ children, type, block }: ButtonProps) => (- <Button block type={type}>- {children}- </Button>- ),-}--export const Disabled = {- args: {- children: 'Hello world',- type: 'primary',- disabled: true,- },- render: ({ children, type, disabled }: ButtonProps) => (- <Button disabled type={type}>- {children}- </Button>- ),-}--export const Sizes = {- args: {- children: 'Change the size below',- type: 'primary',- size: 'large',- },- render: ({ children, type, size }: ButtonProps) => (- <Button size={size} type={type}>- {children}- </Button>- ),-}--export const LeftIcon = {- args: {- children: 'Change the size below',- type: 'primary',- iconLeft: <IconAirplay />,- },- render: ({ children, type, iconLeft }: ButtonProps) => (- <Button iconLeft={iconLeft} type={type}>- {children}- </Button>- ),-}--export const RightIcon = {- args: {- children: 'Change the size below',- type: 'primary',- iconRight: <IconAirplay />,- },- render: ({ children, type, iconRight }: ButtonProps) => (- <Button iconRight={iconRight} type={type}>- {children}- </Button>- ),-}--export const Loading = {- args: {- children: 'Change the size below',- type: 'primary',- loading: true,- },- render: ({ children, type, loading }: ButtonProps) => (- <Button loading={loading} type={type}>- {children}- </Button>- ),+export const Neutral = (args: any) => <Button {...args}>Button text</Button>+export const Success = (args: any) => <Button {...args}>Button text</Button>+export const withStyles = (args: any) => <Button {...args}>Button text</Button>+export const withIcon = (args: any) => <Button {...args}>Button text</Button>+export const withIconRight = (args: any) => <Button {...args}>Button text</Button>+export const withBlock = (args: any) => <Button {...args}>Button text</Button>+export const withOnlyIcon = (args: any) => <Button {...args} />+export const withOnlyLoading = (args: any) => <Button {...args} />+export const withLoadingCentered = (args: any) => (+ <Button {...args}>Loading icon is centered</Button>+)++export const allButtons = (args: any) => (+ <>+ <div className="flex flex-col space-y-4">+ <div className="flex space-x-4">+ <Button {...args} size="tiny">+ Button text+ </Button>+ <Button {...args} size="tiny" type="default">+ Button text+ </Button>+ <Button {...args} size="tiny" type="secondary">+ Button text+ </Button>+ <Button {...args} size="tiny" type="alternative">+ Button text+ </Button>+ <Button {...args} size="tiny" type="link">+ Button text+ </Button>+ <Button {...args} size="tiny" type="text">+ Button text+ </Button>+ <Button {...args} size="tiny" type="dashed">+ Button text+ </Button>+ <Button {...args} size="tiny" type="outline">+ Button text+ </Button>+ <Button {...args} size="tiny" type="danger">+ Button text+ </Button>+ <Button {...args} size="tiny" type="warning">+ Button text+ </Button>+ </div>++ <div className="flex space-x-4">+ <Button {...args} size="small">+ Button text+ </Button>+ <Button {...args} size="small" type="default">+ Button text+ </Button>+ <Button {...args} size="small" type="secondary">+ Button text+ </Button>+ <Button {...args} size="small" type="alternative">+ Button text+ </Button>+ <Button {...args} size="small" type="link">+ Button text+ </Button>+ <Button {...args} size="small" type="text">+ Button text+ </Button>+ <Button {...args} size="small" type="dashed">+ Button text+ </Button>+ <Button {...args} size="small" type="outline">+ Button text+ </Button>+ <Button {...args} size="small" type="danger">+ Button text+ </Button>+ <Button {...args} size="small" type="warning">+ Button text+ </Button>+ </div>+ <div className="flex space-x-4">+ <Button {...args} size="medium">+ Button text+ </Button>+ <Button {...args} size="medium" type="default">+ Button text+ </Button>+ <Button {...args} size="medium" type="secondary">+ Button text+ </Button>+ <Button {...args} size="medium" type="alternative">+ Button text+ </Button>+ <Button {...args} size="medium" type="link">+ Button text+ </Button>+ <Button {...args} size="medium" type="text">+ Button text+ </Button>+ <Button {...args} size="medium" type="dashed">+ Button text+ </Button>+ <Button {...args} size="medium" type="outline">+ Button text+ </Button>+ <Button {...args} size="medium" type="danger">+ Button text+ </Button>+ <Button {...args} size="medium" type="warning">+ Button text+ </Button>+ </div>+ <div className="flex space-x-4">+ <Button {...args} size="large">+ Button text+ </Button>+ <Button {...args} size="large" type="default">+ Button text+ </Button>+ <Button {...args} size="large" type="secondary">+ Button text+ </Button>+ <Button {...args} size="large" type="alternative">+ Button text+ </Button>+ <Button {...args} size="large" type="link">+ Button text+ </Button>+ <Button {...args} size="large" type="text">+ Button text+ </Button>+ <Button {...args} size="large" type="dashed">+ Button text+ </Button>+ <Button {...args} size="large" type="outline">+ Button text+ </Button>+ <Button {...args} size="large" type="danger">+ Button text+ </Button>+ <Button {...args} size="large" type="warning">+ Button text+ </Button>+ </div>+ <div className="flex space-x-4">+ <Button {...args} size="xlarge">+ Button text+ </Button>+ <Button {...args} size="xlarge" type="default">+ Button text+ </Button>+ <Button {...args} size="xlarge" type="secondary">+ Button text+ </Button>+ <Button {...args} size="xlarge" type="alternative">+ Button text+ </Button>+ <Button {...args} size="xlarge" type="link">+ Button text+ </Button>+ <Button {...args} size="xlarge" type="text">+ Button text+ </Button>+ <Button {...args} size="xlarge" type="dashed">+ Button text+ </Button>+ <Button {...args} size="xlarge" type="outline">+ Button text+ </Button>+ <Button {...args} size="xlarge" type="danger">+ Button text+ </Button>+ <Button {...args} size="xlarge" type="warning">+ Button text+ </Button>+ </div>+ </div>+ </>+)++export const withCustomTag = (args: any) => <Button {...args}>Button text</Button>++const icon = <IconPackage />++withIcon.args = {+ type: 'primary',+ icon: icon,+}++withIconRight.args = {+ type: 'primary',+ iconRight: <IconChevronRight strokeWidth={2} />,+}++withStyles.args = {+ type: 'primary',+ style: { backgroundColor: 'red', color: 'yellow' },+}++withBlock.args = {+ type: 'primary',+ block: true,+}++withOnlyIcon.args = {+ icon: icon,+}++withOnlyLoading.args = {+ loading: true,+}++withLoadingCentered.args = {+ loading: true,+ loadingCentered: true,+}++allButtons.args = {+ loading: false,+ danger: false,+}++withCustomTag.args = {+ as: 'span',}diff --git a/packages/ui/src/components/Button/Button.test.tsx b/packages/ui/src/components/Button/Button.test.tsxindex 93e88e8650c..bc2cede9768 100644--- a/packages/ui/src/components/Button/Button.test.tsx+++ b/packages/ui/src/components/Button/Button.test.tsx@@ -1,6 +1,6 @@import React from 'react'import { render, screen, fireEvent } from '@testing-library/react'-import { Button, ButtonSize, ButtonType } from './Button'+import { Button, ButtonSize, ButtonType } from '../shadcn/updated/Button/Button'import defaultTheme from '../../lib/theme/defaultTheme'import Link from 'next/link'diff --git a/packages/ui/src/components/Button/Button.tsx b/packages/ui/src/components/Button/Button.tsxindex 24546fb28e6..a0fb3267c11 100644--- a/packages/ui/src/components/Button/Button.tsx+++ b/packages/ui/src/components/Button/Button.tsx@@ -1,192 +1,159 @@-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 { cn } from '@ui/lib/utils'-import { sizes } from '@ui/lib/commonCva'--export type ButtonVariantProps = VariantProps<typeof buttonVariants>-const buttonVariants = 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: {- true: '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',- },- },- }-)+import React, { forwardRef } from 'react'+import { IconContext } from '../Icon/IconContext'+import { IconLoader } from '../Icon/icons/IconLoader'-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']+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- 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}-const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(- ({ asChild = false, size = 'small', type = 'primary', ...props }, ref) => {- const Comp = asChild ? Slot : 'button'+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> {}- const { className, disabled, 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- // decrecating 'showIcon' for rightIcon- const _iconLeft: React.ReactNode = icon ?? iconLeft+ 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={cn(loadingVariants({ loading }))} />- ) : _iconLeft ? (- <IconContext.Provider value={{ contextSize: size }}>{_iconLeft}</IconContext.Provider>+ <IconLoader size={size} className={iconLoaderClasses.join(' ')} />+ ) : icon ? (+ <IconContext.Provider value={{ contextSize: size }}>{icon}</IconContext.Provider>) : null)}- {props.children && <span className={'truncate'}>{props.children}</span>}+ {children && <span className={__styles.label}>{children}</span>}{iconRight && !loading && (<IconContext.Provider value={{ contextSize: size }}>{iconRight}</IconContext.Provider>)}</>)- return (- <Comp- className={cn(buttonVariants({ type, size, disabled }), className)}- ref={ref}- type={props.htmlType}- {...props}- >- {buttonContent}- </Comp>- )+ 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>+ )+ }})--Button.displayName = 'Button'--export { Button, buttonVariants }diff --git a/packages/ui/src/components/Button/index.tsx b/packages/ui/src/components/Button/index.tsxindex 8486fd6d62d..7b8c48cb4b6 100644--- a/packages/ui/src/components/Button/index.tsx+++ b/packages/ui/src/components/Button/index.tsx@@ -1 +1 @@-export * from './Button'+export * from '../shadcn/updated/Button/Button'diff --git a/packages/ui/src/components/shadcn/updated/Accordion/Accordion.stories.tsx b/packages/ui/src/components/shadcn/updated/Accordion/Accordion.stories.tsxnew file mode 100644index 00000000000..229ab104714--- /dev/null+++ b/packages/ui/src/components/shadcn/updated/Accordion/Accordion.stories.tsx@@ -0,0 +1,79 @@+// Button.stories.ts|tsx++import type { Meta, StoryObj } from '@storybook/react'++import { Accordion, AccordionItem } from './Accordion'+import { Badge } from '../../../Badge'++const meta: Meta<typeof Accordion> = {+ /* π The title prop is optional.+ * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading+ * to learn how to generate automatic titles+ */+ title: 'General/Accordion',+ component: Accordion,+}++export default meta++type Story = StoryObj<typeof Accordion>++/*+ *π Render functions are a framework specific feature to allow you control on how the component renders.+ * See https://storybook.js.org/docs/react/api/csf+ * to learn how to use render functions.+ */++export const Default = {+ args: {+ type: 'default',+ },+ render: ({ children, type }: any) => (+ <Accordion type={type} openBehaviour="single" collapsible className="w-full">+ <Accordion.Item value="item-1">+ <Accordion.Trigger>+ <span className="text-scale-900 group-hover:text-scale-1200">Title of the thing</span>+ </Accordion.Trigger>+ <Accordion.Content>Yes. It adheres to the WAI-ARIA design pattern.</Accordion.Content>+ </Accordion.Item>+ <Accordion.Item value="item-2">+ <Accordion.Trigger>Is it styled?</Accordion.Trigger>+ <Accordion.Content>+ Yes. It comes with default styles that matches the other components' aesthetic.+ </Accordion.Content>+ </Accordion.Item>+ <Accordion.Item value="item-3">+ <Accordion.Trigger>Is it animated?</Accordion.Trigger>+ <Accordion.Content>+ Yes. It's animated by default, but you can disable it if you prefer.+ </Accordion.Content>+ </Accordion.Item>+ </Accordion>+ ),+}++export const Bordered = {+ args: {+ type: 'bordered',+ },+ render: ({ children, type }: any) => (+ <Accordion type={type} openBehaviour="single" collapsible className="w-full">+ <Accordion.Item value="item-1">+ <Accordion.Trigger>Is it accessible?</Accordion.Trigger>+ <Accordion.Content>Yes. It adheres to the WAI-ARIA design pattern.</Accordion.Content>+ </Accordion.Item>+ <Accordion.Item value="item-2">+ <Accordion.Trigger>Is it styled?</Accordion.Trigger>+ <Accordion.Content>+ Yes. It comes with default styles that matches the other components' aesthetic.+ </Accordion.Content>+ </Accordion.Item>+ <Accordion.Item value="item-3">+ <Accordion.Trigger>Is it animated?</Accordion.Trigger>+ <Accordion.Content>+ Yes. It's animated by default, but you can disable it if you prefer.+ </Accordion.Content>+ </Accordion.Item>+ </Accordion>+ ),+}diff --git a/packages/ui/src/components/shadcn/updated/Accordion/Accordion.tsx b/packages/ui/src/components/shadcn/updated/Accordion/Accordion.tsxnew file mode 100644index 00000000000..1e28737c64a--- /dev/null+++ b/packages/ui/src/components/shadcn/updated/Accordion/Accordion.tsx@@ -0,0 +1,235 @@+import * as AccordionPrimitive from '@radix-ui/react-accordion'+import { cn } from './../../lib/utils'++import { VariantProps, cva, cx } from 'class-variance-authority'+import { ChevronDown } from 'lucide-react'+import React, { createContext, useContext, useState } from 'react'++export type AccordionRootVariantsProps = VariantProps<typeof accordionRootVariants>+const accordionRootVariants = cva('flex flex-col', {+ variants: {+ type: {+ default: 'space-y-3',+ bordered: '-space-y-px',+ },+ defaultVariants: {+ type: 'default',+ },+ },+})++export type AccordionItemVariantsProps = VariantProps<typeof accordionItemVariants>+const accordionItemVariants = cva(+ 'group first:rounded-tl-md first:rounded-tr-md last:rounded-bl-md last:rounded-br-md',+ {+ variants: {+ type: {+ default: 'overflow-hidden',+ bordered: 'border border-scale-700',+ },+ justified: {+ true: 'justify-between',+ false: '',+ },+ },+ }+)++const accordionTriggerVariants = cva(+ `flex flex-row items-center w-full text-left cursor-pointer focus-visible:ring-1 focus-visible:z-10 ring-scale-1100+ justify-between transition-all hover:underline [&[data-state=open]>svg]:rotate-180`,+ {+ variants: {+ type: {+ default: 'gap-3',+ bordered: `+ px-6 py-4+ font-medium text-base bg-transparent+ transition-colors hover:bg-scale-200+ overflow-hidden+ group-first:rounded-tl-md group-first:rounded-tr-md+ group-last:rounded-bl-md group-last:rounded-br-md`,+ },+ },+ }+)++const accordionContentVariants = cva('pb-4 pt-0', {+ variants: {+ type: {+ default: '',+ bordered: 'px-6',+ },+ },+})++type Type = AccordionRootVariantsProps['type']+type Align = 'left' | 'right' | undefined++interface ContextValue {+ chevronAlign: Align+ justified: boolean+ type: Type+ defaultValue: AccordionPrimitive.AccordionImplSingleProps['defaultValue']+}++interface AdditionalProps {+ openBehaviour: 'single' | 'multiple'+ variant?: Type+ // Add other additional props here+ onChange?: (item: string | string[]) => void+ type?: Type+ justified?: AccordionItemVariantsProps['justified']+ chevronAlign?: Align+}++interface AccordionComponent+ extends React.ForwardRefExoticComponent<+ ExtendedAccordionProps & React.RefAttributes<HTMLDivElement>+ > {+ Item: typeof AccordionItem+ Content: typeof AccordionContent+ Trigger: typeof AccordionTrigger+}++export interface AccordionSingleProps extends AccordionPrimitive.AccordionImplSingleProps {+ openBehaviour: 'single'+ value?: string+ // Add other props specific to single accordion+}++export interface AccordionMultipleProps extends AccordionPrimitive.AccordionImplMultipleProps {+ openBehaviour: 'multiple'+ value?: string[]+ // Add other props specific to multiple accordion+}++type ExtendedAccordionProps = (AccordionSingleProps | AccordionMultipleProps) & AdditionalProps++const AccordionContext = createContext<ContextValue>({+ chevronAlign: 'left',+ justified: false, // Set the default value to false+ type: undefined,+ defaultValue: undefined,+})++const Accordion: AccordionComponent = React.forwardRef(+ ({ openBehaviour, type, chevronAlign, justified, defaultValue, ...props }, ref) => {+ function handleOnChange(e: string | string[]) {+ if (props.onChange) props.onChange(e)+ }++ const contextValue = {+ chevronAlign,+ justified: justified || false, // Provide a default value of false+ type: type || 'default', // Provide a default value for the type+ defaultValue: Array.isArray(defaultValue) ? defaultValue.join('') : defaultValue, // Convert array to string+ }++ if (openBehaviour === 'single') {+ const { value, children, className, ...singleProps } = props as AccordionSingleProps+ return (+ <AccordionPrimitive.Root+ ref={ref}+ type="single"+ onValueChange={handleOnChange}+ value={value}+ defaultValue={defaultValue}+ className={cn(accordionRootVariants({ type }), className)}+ children={+ <AccordionContext.Provider value={{ ...contextValue }}>+ {children}+ </AccordionContext.Provider>+ }+ {...singleProps}+ />+ )+ } else {+ const { value, children, className, ...multipleProps } = props as AccordionMultipleProps+ return (+ <AccordionPrimitive.Root+ ref={ref}+ type="multiple"+ onValueChange={handleOnChange}+ value={value}+ className={cn(accordionRootVariants({ type }), className)}+ children={+ <AccordionContext.Provider value={{ ...contextValue }}>+ <div>{props.children}</div>+ </AccordionContext.Provider>+ }+ {...multipleProps}+ />+ )+ }+ }+) as AccordionComponent++export interface ItemAdditionalProps+ extends React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item> {}++export const AccordionItem = React.forwardRef<+ React.ElementRef<typeof AccordionPrimitive.Item>,+ React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>+>(({ className, ...props }, ref) => {+ const [open, setOpen] = useState(false)++ let { type, justified } = useContext(AccordionContext)++ return (+ <AccordionPrimitive.Item+ ref={ref}+ className={cn(accordionItemVariants({ type, justified }), className)}+ onClick={() => {+ setOpen(!open)+ }}+ {...props}+ />+ )+})+AccordionItem.displayName = AccordionPrimitive.Item.displayName++export const AccordionTrigger = React.forwardRef<+ React.ElementRef<typeof AccordionPrimitive.Trigger>,+ React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger>+>(({ className, children, ...props }, ref) => {+ const { type } = useContext(AccordionContext)+ return (+ <AccordionPrimitive.Header className="flex">+ <AccordionPrimitive.Trigger+ ref={ref}+ className={cn(accordionTriggerVariants({ type }), className)}+ {...props}+ >+ {children}+ <ChevronDown className="h-4 w-4 transition-transform duration-200" />+ </AccordionPrimitive.Trigger>+ </AccordionPrimitive.Header>+ )+})+AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName++export const AccordionContent = React.forwardRef<+ React.ElementRef<typeof AccordionPrimitive.Content>,+ React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Content>+>(({ className, children, ...props }, ref) => {+ const { type } = useContext(AccordionContext)+ return (+ <AccordionPrimitive.Content+ ref={ref}+ className={cn(+ 'overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down',+ className+ )}+ {...props}+ >+ <div className={cx(accordionContentVariants({ type }))}>{children}</div>+ </AccordionPrimitive.Content>+ )+})+AccordionContent.displayName = AccordionPrimitive.Content.displayName++Accordion.Item = AccordionItem+Accordion.Content = AccordionContent+Accordion.Trigger = AccordionTrigger+export { Accordion }diff --git a/packages/ui/src/components/shadcn/updated/Alert/Alert.stories.tsx b/packages/ui/src/components/shadcn/updated/Alert/Alert.stories.tsxnew file mode 100644index 00000000000..de5cf016871--- /dev/null+++ b/packages/ui/src/components/shadcn/updated/Alert/Alert.stories.tsx@@ -0,0 +1,92 @@+// Button.stories.ts|tsx++import type { Meta, StoryObj } from '@storybook/react'++import { Alert, AlertProps } from './Alert'++import { IconAirplay } from '../Icon/icons/IconAirplay'+import { Terminal } from 'lucide-react'++const meta: Meta<typeof Alert> = {+ /* π The title prop is optional.+ * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading+ * to learn how to generate automatic titles+ */+ title: 'General/Alert',+ component: Alert,+}++export default meta++type Story = StoryObj<typeof Alert>++/*+ *π Render functions are a framework specific feature to allow you control on how the component renders.+ * See https://storybook.js.org/docs/react/api/csf+ * to learn how to use render functions.+ */++export const Info = {+ args: {+ variant: 'info',+ withIcon: true,+ },+ render: ({ withIcon, variant }: AlertProps) => (+ <Alert variant={variant} withIcon={withIcon}>+ <Alert.Title>Info Alert</Alert.Title>+ <Alert.Description>This is an informative message for your application.</Alert.Description>+ </Alert>+ ),+}++export const Danger = {+ args: {+ variant: 'danger',+ withIcon: true,+ },+ render: ({ withIcon, variant }: AlertProps) => (+ <Alert variant={variant} withIcon={withIcon}>+ <Alert.Title>Danger Alert</Alert.Title>+ <Alert.Description>This is a dangerous warning for your application.</Alert.Description>+ </Alert>+ ),+}++export const Warning = {+ args: {+ variant: 'warning',+ withIcon: true,+ },+ render: ({ withIcon, variant }: AlertProps) => (+ <Alert variant={variant} withIcon={withIcon}>+ <Alert.Title>Warning Alert</Alert.Title>+ <Alert.Description>This is a warning message for your application.</Alert.Description>+ </Alert>+ ),+}++export const Success = {+ args: {+ variant: 'success',+ withIcon: true,+ },+ render: ({ withIcon, variant }: AlertProps) => (+ <Alert variant={variant} withIcon={withIcon}>+ <Alert.Title>Success Alert</Alert.Title>+ <Alert.Description>This is a successful notification for your application.</Alert.Description>+ </Alert>+ ),+}++export const Neutral = {+ args: {+ variant: 'neutral',+ withIcon: true,+ },+ render: ({ withIcon, variant }: AlertProps) => (+ <Alert variant={variant} withIcon={withIcon}>+ <Alert.Title>Neutral Alert</Alert.Title>+ <Alert.Description>This is a neutral message for your application.</Alert.Description>+ </Alert>+ ),+}diff --git a/packages/ui/src/components/shadcn/updated/Alert/Alert.tsx b/packages/ui/src/components/shadcn/updated/Alert/Alert.tsxnew file mode 100644index 00000000000..c555727ee9e--- /dev/null+++ b/packages/ui/src/components/shadcn/updated/Alert/Alert.tsx@@ -0,0 +1,145 @@+import { cn } from '../../../../lib/utils'+import { VariantProps, cva } from 'class-variance-authority'+import { AlertOctagon, AlertTriangle, Check, Info } from 'lucide-react'+import * as React from 'react'++export type AlertRootVariantsProps = VariantProps<typeof alertRootVariants>+const alertRootVariants = cva(+ `relative w-full+ rounded-lg border+ py-4 px-6+ [&>svg]:absolute [&>svg]:text-foreground [&>svg]:left-4 [&>svg]:top-4 [&>svg+div]:translate-y-[-3px] [&:has(svg)]:pl-11`,+ {+ variants: {+ variant: {+ danger: `bg-red-200 dark:bg-red-100 text-red-1200 border-red-700 [&>svg]:text-red-1200`,+ warning: `bg-amber-200 dark:bg-amber-100 border-amber-700 [&>svg]:text-amber-1200`,+ info: `bg-scale-400 border-scale-500 dark:bg-scale-100 dark:border-scale-300 [&>svg]:text-scale-1200`,+ success: `bg-brand-300 dark:bg-brand-100 border-brand-700 [&>svg]:text-brand-900`,+ neutral: `bg-scale-300 dark:bg-scale-300 border-scale-500 [&>svg]:text-scale-900`,+ },+ },+ defaultVariants: {+ variant: 'info',+ },+ }+)++const alertTitleVariants = cva('mb-1 font-medium leading-none tracking-tight', {+ variants: {+ variant: {+ danger: `text-red-1200`,+ warning: `text-amber-1200`,+ info: `text-scale-1200`,+ success: `text-brand-1200`,+ neutral: `text-scale-1200`,+ },+ defaultVariants: {+ variant: 'info',+ },+ },+})++const alertDescriptionVariants = cva('text-sm [&_p]:leading-relaxed', {+ variants: {+ variant: {+ danger: 'text-red-1100',+ warning: 'text-amber-1100',+ info: 'text-scale-1100',+ success: 'text-brand-1100',+ neutral: 'text-scale-1100',+ },+ defaultVariants: {+ variant: 'info',+ },+ },+})++interface ContextValue {+ variant: AlertRootVariantsProps['variant']+}++const AlertContext = React.createContext<ContextValue>({+ variant: undefined,+})++// Define the Alert component+interface AlertProps+ extends React.HTMLAttributes<HTMLDivElement>,+ VariantProps<typeof alertRootVariants> {+ withIcon: boolean+}++interface AlertComponent+ extends React.ForwardRefExoticComponent<AlertProps & React.RefAttributes<HTMLDivElement>> {+ Title: typeof AlertTitle+ Description: typeof AlertDescription+}++type AlertIconVariant = Exclude<AlertRootVariantsProps['variant'], null | undefined>+const icons: Record<AlertIconVariant, React.ReactElement> = {+ danger: <AlertOctagon strokeWidth={1.5} size={18} />,+ success: <Check strokeWidth={1.5} size={18} />,+ warning: <AlertTriangle strokeWidth={1.5} size={18} />,+ info: <Info strokeWidth={1.5} size={18} />,+ neutral: <></>,+}++const Alert = React.forwardRef<HTMLDivElement, AlertProps>(+ ({ className, withIcon, variant = 'info', children, ...props }, ref) => {+ const contextValue = {+ variant,+ }++ return (+ <div+ ref={ref}+ role="alert"+ className={cn(alertRootVariants({ variant }), className)}+ {...props}+ children={+ <AlertContext.Provider value={{ ...contextValue }}>+ {withIcon && icons[variant as AlertIconVariant]}+ {children}+ </AlertContext.Provider>+ }+ />+ )+ }+) as AlertComponent++Alert.displayName = 'Alert'++// Define the AlertTitle component as a subcomponent of Alert+interface AlertTitleProps extends React.HTMLAttributes<HTMLHeadingElement> {}++const AlertTitle = React.forwardRef<HTMLHeadingElement, AlertTitleProps>(+ ({ className, ...props }, ref) => {+ const { variant } = React.useContext(AlertContext)+ console.log('variant', variant)+ return <h5 ref={ref} className={cn(alertTitleVariants({ variant }), className)} {...props} />+ }+)++AlertTitle.displayName = 'AlertTitle'++// Define the AlertDescription component as a subcomponent of Alert+interface AlertDescriptionProps extends React.HTMLAttributes<HTMLParagraphElement> {}++const AlertDescription = React.forwardRef<HTMLParagraphElement, AlertDescriptionProps>(+ ({ className, ...props }, ref) => {+ const { variant } = React.useContext(AlertContext)+ return (+ <div ref={ref} className={cn(alertDescriptionVariants({ variant }), className)} {...props} />+ )+ }+)++AlertDescription.displayName = 'AlertDescription'++// Attach the subcomponents to the Alert component+Alert.Title = AlertTitle+Alert.Description = AlertDescription++// Export the Alert component+export { Alert }diff --git a/packages/ui/src/components/shadcn/updated/Button/Button.stories.tsx b/packages/ui/src/components/shadcn/updated/Button/Button.stories.tsxnew file mode 100644index 00000000000..3827669916e--- /dev/null+++ b/packages/ui/src/components/shadcn/updated/Button/Button.stories.tsx@@ -0,0 +1,175 @@+// Button.stories.ts|tsx++import type { Meta, StoryObj } from '@storybook/react'++import { Button, ButtonProps } from './Button'++import { IconAirplay } from '../Icon/icons/IconAirplay'++const meta: Meta<typeof Button> = {+ /* π The title prop is optional.+ * See https://storybook.js.org/docs/react/configure/overview#configure-story-loading+ * to learn how to generate automatic titles+ */+ title: 'General/Button',+ component: Button,+}++export default meta++type Story = StoryObj<typeof Button>++/*+ *π Render functions are a framework specific feature to allow you control on how the component renders.+ * See https://storybook.js.org/docs/react/api/csf+ * to learn how to use render functions.+ */++export const Primary = {+ args: {+ children: 'Hello world',+ type: 'primary',+ },+ render: ({ children, type }: ButtonProps) => <Button type={type}>{children}</Button>,+}+export const Default = {+ args: {+ children: 'Hello world',+ type: 'default',+ },+ render: ({ children, type }: ButtonProps) => <Button type={type}>{children}</Button>,+}++export const Alternative = {+ args: {+ children: 'Hello world',+ type: 'alternative',+ },+ render: ({ children, type }: ButtonProps) => <Button type={type}>{children}</Button>,+}++export const Outline = {+ args: {+ children: 'Hello world',+ type: 'outline',+ },+ render: ({ children, type }: ButtonProps) => <Button type={type}>{children}</Button>,+}++export const Secondary = {+ args: {+ children: 'Hello world',+ type: 'secondary',+ },+ render: ({ children, type }: ButtonProps) => <Button type={type}>{children}</Button>,+}++export const Dashed = {+ args: {+ children: 'Hello world',+ type: 'dashed',+ },+ render: ({ children, type }: ButtonProps) => <Button type={type}>{children}</Button>,+}++export const Link = {+ args: {+ children: 'Hello world',+ type: 'link',+ },+ render: ({ children, type }: ButtonProps) => <Button type={type}>{children}</Button>,+}++export const Text = {+ args: {+ children: 'Hello world',+ type: 'text',+ },+ render: ({ children, type }: ButtonProps) => <Button type={type}>{children}</Button>,+}++export const Danger = {+ args: {+ children: 'Hello world',+ type: 'danger',+ },+ render: ({ children, type }: ButtonProps) => <Button type={type}>{children}</Button>,+}++export const Block = {+ args: {+ children: 'Hello world',+ type: 'primary',+ block: true,+ },+ render: ({ children, type, block }: ButtonProps) => (+ <Button block type={type}>+ {children}+ </Button>+ ),+}++export const Disabled = {+ args: {+ children: 'Hello world',+ type: 'primary',+ disabled: true,+ },+ render: ({ children, type, disabled }: ButtonProps) => (+ <Button disabled type={type}>+ {children}+ </Button>+ ),+}++export const Sizes = {+ args: {+ children: 'Change the size below',+ type: 'primary',+ size: 'large',+ },+ render: ({ children, type, size }: ButtonProps) => (+ <Button size={size} type={type}>+ {children}+ </Button>+ ),+}++export const LeftIcon = {+ args: {+ children: 'Change the size below',+ type: 'primary',+ iconLeft: <IconAirplay />,+ },+ render: ({ children, type, iconLeft }: ButtonProps) => (+ <Button iconLeft={iconLeft} type={type}>+ {children}+ </Button>+ ),+}++export const RightIcon = {+ args: {+ children: 'Change the size below',+ type: 'primary',+ iconRight: <IconAirplay />,+ },+ render: ({ children, type, iconRight }: ButtonProps) => (+ <Button iconRight={iconRight} type={type}>+ {children}+ </Button>+ ),+}++export const Loading = {+ args: {+ children: 'Change the size below',+ type: 'primary',+ loading: true,+ },+ render: ({ children, type, loading }: ButtonProps) => (+ <Button loading={loading} type={type}>+ {children}+ </Button>+ ),+}diff --git a/packages/ui/src/components/shadcn/updated/Button/Button.tsx b/packages/ui/src/components/shadcn/updated/Button/Button.tsxnew file mode 100644index 00000000000..4b13fb9cf83--- /dev/null+++ b/packages/ui/src/components/shadcn/updated/Button/Button.tsx@@ -0,0 +1,192 @@+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 { cn } from '../../../../lib/utils'+import { sizes } from '../../../../lib/commonCva'++export type ButtonVariantProps = VariantProps<typeof buttonVariants>+const buttonVariants = 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: {+ true: '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 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.ReactNode+ iconRight?: React.ReactNode+}++const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(+ ({ asChild = false, size = 'small', type = 'primary', ...props }, ref) => {+ const Comp = asChild ? Slot : 'button'++ const { className, disabled, loading, icon, iconLeft, iconRight } = props++ const showIcon = loading || icon++ // decrecating 'showIcon' for rightIcon+ const _iconLeft: React.ReactNode = icon ?? iconLeft++ const buttonContent = (+ <>+ {showIcon &&+ (loading ? (+ <IconLoader size={size} className={cn(loadingVariants({ loading }))} />+ ) : _iconLeft ? (+ <IconContext.Provider value={{ contextSize: size }}>{_iconLeft}</IconContext.Provider>+ ) : null)}+ {props.children && <span className={'truncate'}>{props.children}</span>}+ {iconRight && !loading && (+ <IconContext.Provider value={{ contextSize: size }}>{iconRight}</IconContext.Provider>+ )}+ </>+ )++ return (+ <Comp+ className={cn(buttonVariants({ type, size, disabled }), className)}+ ref={ref}+ type={props.htmlType}+ {...props}+ >+ {buttonContent}+ </Comp>+ )+ }+)++Button.displayName = 'Button'++export { Button, buttonVariants }