buildgrid-ui 1.1.0-alpha.4 → 1.1.0-dev.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/.storybook/main.ts +24 -25
  2. package/CHANGELOG.md +17 -0
  3. package/dist/buildgrid-ui.es.js +5259 -891
  4. package/dist/buildgrid-ui.umd.js +91 -11
  5. package/dist/components/adaptative-input/adaptative-input.d.ts +9 -0
  6. package/dist/components/adaptative-input/index.d.ts +1 -0
  7. package/dist/components/autocomplete/autocomplete.d.ts +14 -0
  8. package/dist/components/autocomplete/index.d.ts +1 -0
  9. package/dist/components/avatar/avatar.d.ts +6 -0
  10. package/dist/components/avatar/index.d.ts +1 -0
  11. package/dist/components/badge/index.d.ts +1 -1
  12. package/dist/components/button/{Button.d.ts → button.d.ts} +4 -3
  13. package/dist/components/button/index.d.ts +1 -1
  14. package/dist/components/card/index.d.ts +1 -1
  15. package/dist/components/checkbox/checkbox.d.ts +4 -0
  16. package/dist/components/checkbox/index.d.ts +1 -0
  17. package/dist/components/dropdown-menu/dropdown-menu.d.ts +27 -0
  18. package/dist/components/dropdown-menu/index.d.ts +1 -0
  19. package/dist/components/index.d.ts +7 -0
  20. package/dist/components/input/index.d.ts +1 -0
  21. package/dist/components/input/input.d.ts +9 -0
  22. package/dist/components/popover/index.d.ts +1 -0
  23. package/dist/components/popover/popover.d.ts +7 -0
  24. package/dist/components/skeleton/index.d.ts +1 -1
  25. package/dist/index.d.ts +7 -0
  26. package/package.json +7 -2
  27. package/src/components/adaptative-input/adaptative-input.stories.tsx +30 -0
  28. package/src/components/adaptative-input/adaptative-input.tsx +66 -0
  29. package/src/components/adaptative-input/index.ts +1 -0
  30. package/src/components/autocomplete/autocomplete.stories.tsx +85 -0
  31. package/src/components/autocomplete/autocomplete.tsx +136 -0
  32. package/src/components/autocomplete/index.ts +1 -0
  33. package/src/components/avatar/avatar.stories.tsx +29 -0
  34. package/src/components/avatar/avatar.tsx +48 -0
  35. package/src/components/avatar/index.ts +1 -0
  36. package/src/components/badge/{Badge.stories.tsx → badge.stories.tsx} +1 -1
  37. package/src/components/badge/index.ts +1 -1
  38. package/src/components/button/button.stories.tsx +62 -0
  39. package/src/components/button/button.tsx +82 -0
  40. package/src/components/button/index.ts +1 -1
  41. package/src/components/card/{Card.stories.tsx → card.stories.tsx} +1 -1
  42. package/src/components/card/index.ts +1 -1
  43. package/src/components/checkbox/checkbox.stories.tsx +36 -0
  44. package/src/components/checkbox/checkbox.tsx +28 -0
  45. package/src/components/checkbox/index.ts +1 -0
  46. package/src/components/dropdown-menu/dropdown-menu.stories.tsx +90 -0
  47. package/src/components/dropdown-menu/dropdown-menu.tsx +192 -0
  48. package/src/components/dropdown-menu/index.ts +1 -0
  49. package/src/components/index.ts +7 -0
  50. package/src/components/input/index.ts +1 -0
  51. package/src/components/input/input.stories.tsx +22 -0
  52. package/src/components/input/input.tsx +41 -0
  53. package/src/components/popover/index.ts +1 -0
  54. package/src/components/popover/popover.stories.tsx +32 -0
  55. package/src/components/popover/popover.tsx +30 -0
  56. package/src/components/skeleton/index.ts +1 -1
  57. package/src/index.ts +7 -0
  58. package/src/components/button/Button.stories.tsx +0 -40
  59. package/src/components/button/Button.tsx +0 -57
  60. /package/dist/components/badge/{Badge.d.ts → badge.d.ts} +0 -0
  61. /package/dist/components/card/{Card.d.ts → card.d.ts} +0 -0
  62. /package/dist/components/skeleton/{Skeleton.d.ts → skeleton.d.ts} +0 -0
  63. /package/src/components/badge/{Badge.tsx → badge.tsx} +0 -0
  64. /package/src/components/card/{Card.tsx → card.tsx} +0 -0
  65. /package/src/components/skeleton/{Skeleton.stories.tsx → skeleton.stories.tsx} +0 -0
  66. /package/src/components/skeleton/{Skeleton.tsx → skeleton.tsx} +0 -0
@@ -0,0 +1,9 @@
1
+ import * as React from 'react';
2
+ import { InputProps } from '../input';
3
+ export interface AdaptiveInputProps extends InputProps {
4
+ leftIcon?: React.ReactNode;
5
+ rightIcon?: React.ReactNode;
6
+ mask?: string;
7
+ }
8
+ declare const AdaptiveInput: React.ForwardRefExoticComponent<AdaptiveInputProps & React.RefAttributes<HTMLInputElement>>;
9
+ export { AdaptiveInput };
@@ -0,0 +1 @@
1
+ export * from './adaptative-input';
@@ -0,0 +1,14 @@
1
+ interface Option {
2
+ value: string;
3
+ label: string;
4
+ }
5
+ interface AutoCompleteProps {
6
+ value?: string;
7
+ onChange?: (value: string) => void;
8
+ options: Option[];
9
+ className?: string;
10
+ placeholder?: string;
11
+ emptyMessage?: string;
12
+ }
13
+ export declare function Autocomplete(props: AutoCompleteProps): import("react/jsx-runtime").JSX.Element;
14
+ export {};
@@ -0,0 +1 @@
1
+ export * from './autocomplete';
@@ -0,0 +1,6 @@
1
+ import * as AvatarPrimitive from '@radix-ui/react-avatar';
2
+ import * as React from 'react';
3
+ declare const Avatar: React.ForwardRefExoticComponent<Omit<AvatarPrimitive.AvatarProps & React.RefAttributes<HTMLSpanElement>, "ref"> & React.RefAttributes<HTMLSpanElement>>;
4
+ declare const AvatarImage: React.ForwardRefExoticComponent<Omit<AvatarPrimitive.AvatarImageProps & React.RefAttributes<HTMLImageElement>, "ref"> & React.RefAttributes<HTMLImageElement>>;
5
+ declare const AvatarFallback: React.ForwardRefExoticComponent<Omit<AvatarPrimitive.AvatarFallbackProps & React.RefAttributes<HTMLSpanElement>, "ref"> & React.RefAttributes<HTMLSpanElement>>;
6
+ export { Avatar, AvatarFallback, AvatarImage };
@@ -0,0 +1 @@
1
+ export * from './avatar';
@@ -1 +1 @@
1
- export * from "./Badge";
1
+ export * from './badge';
@@ -1,10 +1,11 @@
1
- import { type VariantProps } from "class-variance-authority";
2
- import * as React from "react";
1
+ import { type VariantProps } from 'class-variance-authority';
2
+ import * as React from 'react';
3
3
  declare const buttonVariants: (props?: ({
4
- variant?: "default" | "secondary" | "destructive" | "outline" | "link" | "ghost" | null | undefined;
4
+ variant?: "default" | "link" | "secondary" | "destructive" | "outline" | "ghost" | null | undefined;
5
5
  size?: "default" | "sm" | "lg" | "xl" | "icon" | null | undefined;
6
6
  } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
7
7
  export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
8
+ isLoading?: boolean;
8
9
  asChild?: boolean;
9
10
  }
10
11
  declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
@@ -1 +1 @@
1
- export * from "./Button";
1
+ export * from './button';
@@ -1 +1 @@
1
- export * from './Card';
1
+ export * from './card';
@@ -0,0 +1,4 @@
1
+ import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
2
+ import * as React from 'react';
3
+ declare const Checkbox: React.ForwardRefExoticComponent<Omit<CheckboxPrimitive.CheckboxProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
4
+ export { Checkbox };
@@ -0,0 +1 @@
1
+ export * from './checkbox';
@@ -0,0 +1,27 @@
1
+ import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
2
+ import * as React from 'react';
3
+ declare const DropdownMenu: React.FC<DropdownMenuPrimitive.DropdownMenuProps>;
4
+ declare const DropdownMenuTrigger: React.ForwardRefExoticComponent<DropdownMenuPrimitive.DropdownMenuTriggerProps & React.RefAttributes<HTMLButtonElement>>;
5
+ declare const DropdownMenuGroup: React.ForwardRefExoticComponent<DropdownMenuPrimitive.DropdownMenuGroupProps & React.RefAttributes<HTMLDivElement>>;
6
+ declare const DropdownMenuPortal: React.FC<DropdownMenuPrimitive.DropdownMenuPortalProps>;
7
+ declare const DropdownMenuSub: React.FC<DropdownMenuPrimitive.DropdownMenuSubProps>;
8
+ declare const DropdownMenuRadioGroup: React.ForwardRefExoticComponent<DropdownMenuPrimitive.DropdownMenuRadioGroupProps & React.RefAttributes<HTMLDivElement>>;
9
+ declare const DropdownMenuSubTrigger: React.ForwardRefExoticComponent<Omit<DropdownMenuPrimitive.DropdownMenuSubTriggerProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
10
+ inset?: boolean;
11
+ } & React.RefAttributes<HTMLDivElement>>;
12
+ declare const DropdownMenuSubContent: React.ForwardRefExoticComponent<Omit<DropdownMenuPrimitive.DropdownMenuSubContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
13
+ declare const DropdownMenuContent: React.ForwardRefExoticComponent<Omit<DropdownMenuPrimitive.DropdownMenuContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
14
+ declare const DropdownMenuItem: React.ForwardRefExoticComponent<Omit<DropdownMenuPrimitive.DropdownMenuItemProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
15
+ inset?: boolean;
16
+ } & React.RefAttributes<HTMLDivElement>>;
17
+ declare const DropdownMenuCheckboxItem: React.ForwardRefExoticComponent<Omit<DropdownMenuPrimitive.DropdownMenuCheckboxItemProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
18
+ declare const DropdownMenuRadioItem: React.ForwardRefExoticComponent<Omit<DropdownMenuPrimitive.DropdownMenuRadioItemProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
19
+ declare const DropdownMenuLabel: React.ForwardRefExoticComponent<Omit<DropdownMenuPrimitive.DropdownMenuLabelProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
20
+ inset?: boolean;
21
+ } & React.RefAttributes<HTMLDivElement>>;
22
+ declare const DropdownMenuSeparator: React.ForwardRefExoticComponent<Omit<DropdownMenuPrimitive.DropdownMenuSeparatorProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
23
+ declare const DropdownMenuShortcut: {
24
+ ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>): import("react/jsx-runtime").JSX.Element;
25
+ displayName: string;
26
+ };
27
+ export { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, };
@@ -0,0 +1 @@
1
+ export * from './dropdown-menu';
@@ -1,4 +1,11 @@
1
+ export * from './adaptative-input';
2
+ export * from './autocomplete';
3
+ export * from './avatar';
1
4
  export * from './badge';
2
5
  export * from './button';
3
6
  export * from './card';
7
+ export * from './checkbox';
8
+ export * from './dropdown-menu';
9
+ export * from './input';
10
+ export * from './popover';
4
11
  export * from './skeleton';
@@ -0,0 +1 @@
1
+ export * from './input';
@@ -0,0 +1,9 @@
1
+ import { VariantProps } from 'class-variance-authority';
2
+ import * as React from 'react';
3
+ declare const inputVariants: (props?: ({
4
+ sizing?: "sm" | "md" | "lg" | "xl" | "2xl" | null | undefined;
5
+ } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
6
+ export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement>, VariantProps<typeof inputVariants> {
7
+ }
8
+ declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
9
+ export { Input };
@@ -0,0 +1 @@
1
+ export * from './popover';
@@ -0,0 +1,7 @@
1
+ import * as PopoverPrimitive from '@radix-ui/react-popover';
2
+ import * as React from 'react';
3
+ declare const Popover: React.FC<PopoverPrimitive.PopoverProps>;
4
+ declare const PopoverTrigger: React.ForwardRefExoticComponent<PopoverPrimitive.PopoverTriggerProps & React.RefAttributes<HTMLButtonElement>>;
5
+ declare const PopoverAnchor: React.ForwardRefExoticComponent<PopoverPrimitive.PopoverAnchorProps & React.RefAttributes<HTMLDivElement>>;
6
+ declare const PopoverContent: React.ForwardRefExoticComponent<Omit<PopoverPrimitive.PopoverContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
7
+ export { Popover, PopoverAnchor, PopoverContent, PopoverTrigger };
@@ -1 +1 @@
1
- export * from './Skeleton';
1
+ export * from './skeleton';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,12 @@
1
+ export * from './components/adaptative-input';
2
+ export * from './components/autocomplete';
3
+ export * from './components/avatar';
1
4
  export * from './components/badge';
2
5
  export * from './components/button';
3
6
  export * from './components/card';
7
+ export * from './components/checkbox';
8
+ export * from './components/dropdown-menu';
9
+ export * from './components/input';
10
+ export * from './components/popover';
4
11
  export * from './components/skeleton';
5
12
  export * from './lib/utils/cn';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "buildgrid-ui",
3
- "version": "1.1.0-alpha.4",
3
+ "version": "1.1.0-dev.5",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -15,13 +15,18 @@
15
15
  "storybook": "storybook dev -p 6006",
16
16
  "build-storybook": "storybook build",
17
17
  "release": "semantic-release",
18
- "prepublishOnly": "npm run build"
18
+ "prepublishOnly": "npm run build",
19
+ "build:publish": "npm run build && npm publish"
19
20
  },
20
21
  "keywords": [],
21
22
  "author": "",
22
23
  "license": "ISC",
23
24
  "description": "",
24
25
  "dependencies": {
26
+ "@radix-ui/react-avatar": "^1.1.2",
27
+ "@radix-ui/react-checkbox": "^1.1.3",
28
+ "@radix-ui/react-dropdown-menu": "^2.1.4",
29
+ "@radix-ui/react-popover": "^1.1.4",
25
30
  "@radix-ui/react-slot": "^1.1.1",
26
31
  "@shadcn/ui": "^0.0.4",
27
32
  "class-variance-authority": "^0.7.1",
@@ -0,0 +1,30 @@
1
+ // organize-imports-ignore
2
+ import React from 'react'
3
+ import type { Meta, StoryObj } from '@storybook/react'
4
+
5
+ import { AdaptiveInput } from './adaptative-input'
6
+ import { HelpCircle, Phone, User } from 'lucide-react'
7
+
8
+ const meta: Meta<typeof AdaptiveInput> = {
9
+ title: 'Components/Input/AdaptiveInput',
10
+ component: AdaptiveInput,
11
+ }
12
+
13
+ export default meta
14
+ type Story = StoryObj<typeof AdaptiveInput>
15
+
16
+ const Template = () => {
17
+ return (
18
+ <AdaptiveInput
19
+ className="w-64"
20
+ leftIcon={<Phone className="w-4 h-4" />}
21
+ rightIcon={<HelpCircle className="w-4 h-4" />}
22
+ mask="+00 0000-0000"
23
+ />
24
+ )
25
+ }
26
+
27
+ export const Default: Story = {
28
+ render: Template.bind({}),
29
+ args: {},
30
+ }
@@ -0,0 +1,66 @@
1
+ import { cn } from '@/lib'
2
+ import * as React from 'react'
3
+ import { Input, InputProps } from '../input'
4
+
5
+ export interface AdaptiveInputProps extends InputProps {
6
+ leftIcon?: React.ReactNode
7
+ rightIcon?: React.ReactNode
8
+ mask?: string // New prop for the mask
9
+ }
10
+
11
+ const applyMask = (value: string, mask: string): string => {
12
+ const cleanValue = value.replace(/\D/g, '')
13
+ let maskedValue = ''
14
+ let maskIndex = 0
15
+ let valueIndex = 0
16
+
17
+ while (maskIndex < mask.length && valueIndex < cleanValue.length) {
18
+ if (mask[maskIndex] === '0') {
19
+ maskedValue += cleanValue[valueIndex]
20
+ valueIndex++
21
+ } else {
22
+ maskedValue += mask[maskIndex]
23
+ }
24
+ maskIndex++
25
+ }
26
+
27
+ return maskedValue
28
+ }
29
+
30
+ const AdaptiveInput = React.forwardRef<HTMLInputElement, AdaptiveInputProps>(
31
+ ({ className, leftIcon, rightIcon, mask, onChange, ...props }, ref) => {
32
+ const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
33
+ const input = e.target
34
+ if (mask) {
35
+ const maskedValue = applyMask(input.value, mask)
36
+ input.value = maskedValue
37
+ }
38
+ onChange?.(e) // Call the original onChange if provided
39
+ }
40
+
41
+ return (
42
+ <div className="relative w-fit">
43
+ {leftIcon && (
44
+ <div className="absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground">
45
+ {leftIcon}
46
+ </div>
47
+ )}
48
+ <Input
49
+ className={cn(leftIcon && 'pl-8', rightIcon && 'pr-8', className)}
50
+ ref={ref}
51
+ onInput={handleInputChange} // Attach the input handler
52
+ {...props}
53
+ />
54
+ {rightIcon && (
55
+ <div className="absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground">
56
+ {rightIcon}
57
+ </div>
58
+ )}
59
+ </div>
60
+ )
61
+ },
62
+ )
63
+
64
+ AdaptiveInput.displayName = 'AdaptiveInput'
65
+
66
+ export { AdaptiveInput }
@@ -0,0 +1 @@
1
+ export * from './adaptative-input'
@@ -0,0 +1,85 @@
1
+ // organize-imports-ignore
2
+ import React from 'react'
3
+ import type { Meta, StoryObj } from '@storybook/react'
4
+
5
+ import { Autocomplete } from './autocomplete'
6
+
7
+ const meta: Meta<typeof Autocomplete> = {
8
+ title: 'Components/Input/Autocomplete',
9
+ component: Autocomplete,
10
+ }
11
+
12
+ export default meta
13
+ type Story = StoryObj<typeof Autocomplete>
14
+
15
+ // list of 50 names of countries
16
+ const options = [
17
+ 'United States',
18
+ 'Canada',
19
+ 'Argentina',
20
+ 'Brazil',
21
+ 'Chile',
22
+ 'Colombia',
23
+ 'Ecuador',
24
+ 'Peru',
25
+ 'Uruguay',
26
+ 'Venezuela',
27
+ 'Australia',
28
+ 'China',
29
+ 'India',
30
+ 'Indonesia',
31
+ 'Japan',
32
+ 'Korea',
33
+ 'Malaysia',
34
+ 'Philippines',
35
+ 'Singapore',
36
+ 'Thailand',
37
+ 'Vietnam',
38
+ 'Austria',
39
+ 'Belgium',
40
+ 'Croatia',
41
+ 'Denmark',
42
+ 'Finland',
43
+ 'France',
44
+ 'Germany',
45
+ 'Greece',
46
+ 'Hungary',
47
+ 'Ireland',
48
+ 'Italy',
49
+ 'Netherlands',
50
+ 'Norway',
51
+ 'Poland',
52
+ 'Portugal',
53
+ 'Romania',
54
+ 'Russia',
55
+ 'Spain',
56
+ 'Sweden',
57
+ 'Switzerland',
58
+ 'Turkey',
59
+ 'Ukraine',
60
+ 'United Kingdom',
61
+ 'Egypt',
62
+ 'Nigeria',
63
+ 'South Africa',
64
+ 'Kenya',
65
+ ]
66
+
67
+ const Template = () => {
68
+ const [value, setValue] = React.useState('')
69
+ return (
70
+ <>
71
+ <Autocomplete
72
+ value={value}
73
+ onChange={(value) => setValue(value)}
74
+ className="w-80"
75
+ options={options.map((option) => ({ value: option, label: option }))}
76
+ />
77
+ <p className="mt-4">Selected value: {value}</p>
78
+ </>
79
+ )
80
+ }
81
+
82
+ export const Default: Story = {
83
+ render: Template.bind({}),
84
+ args: {},
85
+ }
@@ -0,0 +1,136 @@
1
+ import { Search } from 'lucide-react'
2
+ import { useState } from 'react'
3
+
4
+ import { cn } from '@/lib'
5
+ import { AdaptiveInput } from '../adaptative-input'
6
+ import { Popover, PopoverContent, PopoverTrigger } from '../popover'
7
+
8
+ interface Option {
9
+ value: string
10
+ label: string
11
+ }
12
+
13
+ interface AutoCompleteProps {
14
+ value?: string
15
+ onChange?: (value: string) => void
16
+ options: Option[]
17
+ className?: string
18
+ placeholder?: string
19
+ emptyMessage?: string
20
+ }
21
+
22
+ export function Autocomplete(props: AutoCompleteProps) {
23
+ const {
24
+ value = '',
25
+ onChange,
26
+ options: staticOptions,
27
+ className,
28
+ placeholder = 'Search...',
29
+ emptyMessage = 'Nothing found',
30
+ } = props
31
+
32
+ const [query, setQuery] = useState(value)
33
+ const [suggestions, setSuggestions] = useState<Option[]>(staticOptions)
34
+ const [selectedIndex, setSelectedIndex] = useState(-1)
35
+ const [isFocused, setIsFocused] = useState(false)
36
+
37
+ const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
38
+ const newValue = e.target.value
39
+ setQuery(newValue)
40
+ onChange?.(newValue)
41
+ setSelectedIndex(-1)
42
+ setIsFocused(true)
43
+
44
+ if (newValue.trim() === '') {
45
+ setSuggestions(staticOptions)
46
+ } else {
47
+ setSuggestions(
48
+ staticOptions.filter((option) =>
49
+ option.label.toLowerCase().includes(newValue.toLowerCase()),
50
+ ),
51
+ )
52
+ }
53
+ }
54
+
55
+ const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
56
+ if (e.key === 'ArrowDown') {
57
+ e.preventDefault()
58
+ setSelectedIndex((prev) => (prev < suggestions.length - 1 ? prev + 1 : prev))
59
+ } else if (e.key === 'ArrowUp') {
60
+ e.preventDefault()
61
+ setSelectedIndex((prev) => (prev > 0 ? prev - 1 : -1))
62
+ } else if (e.key === 'Enter' && selectedIndex >= 0) {
63
+ const selectedOption = suggestions[selectedIndex]
64
+ setQuery(selectedOption.label)
65
+ onChange?.(selectedOption.value)
66
+ setSuggestions([])
67
+ setSelectedIndex(-1)
68
+ setIsFocused(false)
69
+ } else if (e.key === 'Escape') {
70
+ setSuggestions([])
71
+ setSelectedIndex(-1)
72
+ }
73
+ }
74
+
75
+ const handleSuggestionClick = (option: Option) => {
76
+ setIsFocused(false)
77
+ setQuery(option.label)
78
+ onChange?.(option.value)
79
+ setSuggestions(staticOptions)
80
+ setSelectedIndex(-1)
81
+ }
82
+
83
+ const handleFocus = () => {
84
+ setIsFocused(true)
85
+ }
86
+
87
+ const handleBlur = () => {
88
+ setIsFocused(false)
89
+ }
90
+
91
+ return (
92
+ <Popover open={isFocused}>
93
+ <PopoverTrigger asChild>
94
+ <div className="relative w-fit">
95
+ <AdaptiveInput
96
+ type="text"
97
+ placeholder={placeholder}
98
+ value={query}
99
+ onChange={handleInputChange}
100
+ onKeyDown={handleKeyDown}
101
+ onClick={handleFocus}
102
+ onFocus={handleFocus}
103
+ onBlur={handleBlur}
104
+ className={cn('pr-10', className)}
105
+ aria-label="Search field"
106
+ aria-autocomplete="list"
107
+ aria-controls="suggestions-list"
108
+ aria-expanded={suggestions.length > 0}
109
+ leftIcon={<Search className="w-4 h-4" />}
110
+ />
111
+ </div>
112
+ </PopoverTrigger>
113
+ <PopoverContent className="p-0 w-[var(--radix-popover-trigger-width)] max-h-96 overflow-y-auto">
114
+ {suggestions.length > 0 ? (
115
+ <ul id="suggestions-list" role="listbox">
116
+ {suggestions.map((option, index) => (
117
+ <li
118
+ key={option.value}
119
+ className={`px-4 py-2 cursor-pointer hover:bg-muted ${
120
+ index === selectedIndex ? 'bg-muted' : ''
121
+ }`}
122
+ onClick={() => handleSuggestionClick(option)}
123
+ role="option"
124
+ aria-selected={index === selectedIndex}
125
+ >
126
+ {option.label}
127
+ </li>
128
+ ))}
129
+ </ul>
130
+ ) : (
131
+ <span className="px-4 py-2 block">{emptyMessage}</span>
132
+ )}
133
+ </PopoverContent>
134
+ </Popover>
135
+ )
136
+ }
@@ -0,0 +1 @@
1
+ export * from './autocomplete'
@@ -0,0 +1,29 @@
1
+ // organize-imports-ignore
2
+ import React from 'react'
3
+ import type { Meta, StoryObj } from '@storybook/react'
4
+
5
+ import { Avatar, AvatarFallback, AvatarImage } from './avatar'
6
+
7
+ const meta: Meta<typeof Avatar> = {
8
+ component: Avatar,
9
+ }
10
+
11
+ export default meta
12
+ type Story = StoryObj<typeof Avatar>
13
+
14
+ const Template = () => {
15
+ return (
16
+ <Avatar className="w-24 h-24">
17
+ <AvatarImage
18
+ src="https://upload.wikimedia.org/wikipedia/commons/7/7c/Profile_avatar_placeholder_large.png?20150327203541"
19
+ alt="User avatar"
20
+ />
21
+ <AvatarFallback>NS</AvatarFallback>
22
+ </Avatar>
23
+ )
24
+ }
25
+
26
+ export const Default: Story = {
27
+ render: Template.bind({}),
28
+ args: {},
29
+ }
@@ -0,0 +1,48 @@
1
+ import * as AvatarPrimitive from '@radix-ui/react-avatar'
2
+ import * as React from 'react'
3
+
4
+ import { cn } from '@/lib/utils/cn'
5
+
6
+ const Avatar = React.forwardRef<
7
+ React.ElementRef<typeof AvatarPrimitive.Root>,
8
+ React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>
9
+ >(({ className, ...props }, ref) => (
10
+ <AvatarPrimitive.Root
11
+ ref={ref}
12
+ className={cn(
13
+ 'relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full',
14
+ className,
15
+ )}
16
+ {...props}
17
+ />
18
+ ))
19
+ Avatar.displayName = AvatarPrimitive.Root.displayName
20
+
21
+ const AvatarImage = React.forwardRef<
22
+ React.ElementRef<typeof AvatarPrimitive.Image>,
23
+ React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>
24
+ >(({ className, ...props }, ref) => (
25
+ <AvatarPrimitive.Image
26
+ ref={ref}
27
+ className={cn('aspect-square h-full w-full', className)}
28
+ {...props}
29
+ />
30
+ ))
31
+ AvatarImage.displayName = AvatarPrimitive.Image.displayName
32
+
33
+ const AvatarFallback = React.forwardRef<
34
+ React.ElementRef<typeof AvatarPrimitive.Fallback>,
35
+ React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>
36
+ >(({ className, ...props }, ref) => (
37
+ <AvatarPrimitive.Fallback
38
+ ref={ref}
39
+ className={cn(
40
+ 'flex h-full w-full items-center justify-center rounded-full bg-muted',
41
+ className,
42
+ )}
43
+ {...props}
44
+ />
45
+ ))
46
+ AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName
47
+
48
+ export { Avatar, AvatarFallback, AvatarImage }
@@ -0,0 +1 @@
1
+ export * from './avatar'
@@ -2,7 +2,7 @@
2
2
  import React from 'react'
3
3
  import type { Meta, StoryObj } from '@storybook/react'
4
4
 
5
- import { Badge, BadgeProps, badgeVariants } from './Badge'
5
+ import { Badge, BadgeProps, badgeVariants } from './badge'
6
6
 
7
7
  const meta: Meta<typeof Badge> = {
8
8
  component: Badge,
@@ -1 +1 @@
1
- export * from "./Badge";
1
+ export * from './badge'