@blips/ui 0.0.1 → 2.0.0

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 (60) hide show
  1. package/dist/index.cjs +4308 -2010
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +435 -411
  4. package/dist/index.d.ts +435 -411
  5. package/dist/index.js +4244 -2008
  6. package/dist/index.js.map +1 -1
  7. package/package.json +18 -4
  8. package/src/components/accordion.tsx +58 -48
  9. package/src/components/alert-dialog.tsx +170 -112
  10. package/src/components/alert.tsx +49 -42
  11. package/src/components/aspect-ratio.tsx +9 -3
  12. package/src/components/avatar.tsx +109 -50
  13. package/src/components/badge.tsx +29 -17
  14. package/src/components/breadcrumb.tsx +81 -87
  15. package/src/components/button-group.tsx +83 -0
  16. package/src/components/button.tsx +40 -32
  17. package/src/components/calendar.tsx +49 -45
  18. package/src/components/card.tsx +77 -71
  19. package/src/components/carousel.tsx +150 -168
  20. package/src/components/chart.tsx +357 -0
  21. package/src/components/checkbox.tsx +28 -24
  22. package/src/components/collapsible.tsx +28 -6
  23. package/src/components/command.tsx +144 -110
  24. package/src/components/context-menu.tsx +220 -166
  25. package/src/components/dialog.tsx +131 -95
  26. package/src/components/drawer.tsx +105 -86
  27. package/src/components/dropdown-menu.tsx +234 -177
  28. package/src/components/form.tsx +167 -0
  29. package/src/components/hover-card.tsx +39 -22
  30. package/src/components/input-group.tsx +175 -0
  31. package/src/components/input-otp.tsx +56 -48
  32. package/src/components/input.tsx +18 -19
  33. package/src/components/kbd.tsx +28 -0
  34. package/src/components/label.tsx +20 -22
  35. package/src/components/menubar.tsx +221 -199
  36. package/src/components/navigation-menu.tsx +144 -102
  37. package/src/components/pagination.tsx +102 -91
  38. package/src/components/popover.tsx +86 -26
  39. package/src/components/progress.tsx +27 -24
  40. package/src/components/radio-group.tsx +28 -25
  41. package/src/components/resizable.tsx +42 -34
  42. package/src/components/scroll-area.tsx +54 -42
  43. package/src/components/select.tsx +165 -135
  44. package/src/components/separator.tsx +16 -17
  45. package/src/components/sheet.tsx +116 -113
  46. package/src/components/sidebar.tsx +726 -0
  47. package/src/components/skeleton.tsx +6 -8
  48. package/src/components/slider.tsx +60 -23
  49. package/src/components/sonner.tsx +25 -30
  50. package/src/components/spinner.tsx +16 -0
  51. package/src/components/switch.tsx +30 -22
  52. package/src/components/table.tsx +96 -97
  53. package/src/components/tabs.tsx +91 -53
  54. package/src/components/textarea.tsx +8 -12
  55. package/src/components/toggle-group.tsx +60 -37
  56. package/src/components/toggle.tsx +28 -24
  57. package/src/components/tooltip.tsx +50 -23
  58. package/src/globals.css +230 -68
  59. package/src/hooks/use-mobile.tsx +19 -0
  60. package/src/index.ts +105 -6
@@ -1,162 +1,147 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
1
4
  import useEmblaCarousel, {
2
5
  type UseEmblaCarouselType,
3
- } from "embla-carousel-react";
4
- import { ArrowLeft, ArrowRight } from "lucide-react";
5
- import * as React from "react";
6
- import { Button } from "./button";
7
- import { cn } from "../lib/utils";
6
+ } from "embla-carousel-react"
7
+ import { ArrowLeft, ArrowRight } from "@phosphor-icons/react"
8
+
9
+ import { cn } from "../lib/utils"
10
+ import { Button } from "./button"
8
11
 
9
- type CarouselApi = UseEmblaCarouselType[1];
10
- type UseCarouselParameters = Parameters<typeof useEmblaCarousel>;
11
- type CarouselOptions = UseCarouselParameters[0];
12
- type CarouselPlugin = UseCarouselParameters[1];
12
+ type CarouselApi = UseEmblaCarouselType[1]
13
+ type UseCarouselParameters = Parameters<typeof useEmblaCarousel>
14
+ type CarouselOptions = UseCarouselParameters[0]
15
+ type CarouselPlugin = UseCarouselParameters[1]
13
16
 
14
17
  type CarouselProps = {
15
- opts?: CarouselOptions;
16
- plugins?: CarouselPlugin;
17
- orientation?: "horizontal" | "vertical";
18
- setApi?: (api: CarouselApi) => void;
19
- };
18
+ opts?: CarouselOptions
19
+ plugins?: CarouselPlugin
20
+ orientation?: "horizontal" | "vertical"
21
+ setApi?: (api: CarouselApi) => void
22
+ }
20
23
 
21
24
  type CarouselContextProps = {
22
- carouselRef: ReturnType<typeof useEmblaCarousel>[0];
23
- api: ReturnType<typeof useEmblaCarousel>[1];
24
- scrollPrev: () => void;
25
- scrollNext: () => void;
26
- canScrollPrev: boolean;
27
- canScrollNext: boolean;
28
- } & CarouselProps;
25
+ carouselRef: ReturnType<typeof useEmblaCarousel>[0]
26
+ api: ReturnType<typeof useEmblaCarousel>[1]
27
+ scrollPrev: () => void
28
+ scrollNext: () => void
29
+ canScrollPrev: boolean
30
+ canScrollNext: boolean
31
+ } & CarouselProps
29
32
 
30
- const CarouselContext = React.createContext<CarouselContextProps | null>(null);
33
+ const CarouselContext = React.createContext<CarouselContextProps | null>(null)
31
34
 
32
35
  function useCarousel() {
33
- const context = React.useContext(CarouselContext);
36
+ const context = React.useContext(CarouselContext)
34
37
 
35
38
  if (!context) {
36
- throw new Error("useCarousel must be used within a <Carousel />");
39
+ throw new Error("useCarousel must be used within a <Carousel />")
37
40
  }
38
41
 
39
- return context;
42
+ return context
40
43
  }
41
44
 
42
- const Carousel = React.forwardRef<
43
- HTMLDivElement,
44
- React.HTMLAttributes<HTMLDivElement> & CarouselProps
45
- >(
46
- (
45
+ function Carousel({
46
+ orientation = "horizontal",
47
+ opts,
48
+ setApi,
49
+ plugins,
50
+ className,
51
+ children,
52
+ ...props
53
+ }: React.ComponentProps<"div"> & CarouselProps) {
54
+ const [carouselRef, api] = useEmblaCarousel(
47
55
  {
48
- orientation = "horizontal",
49
- opts,
50
- setApi,
51
- plugins,
52
- className,
53
- children,
54
- ...props
56
+ ...opts,
57
+ axis: orientation === "horizontal" ? "x" : "y",
55
58
  },
56
- ref
57
- ) => {
58
- const [carouselRef, api] = useEmblaCarousel(
59
- {
60
- ...opts,
61
- axis: orientation === "horizontal" ? "x" : "y",
62
- },
63
- plugins
64
- );
65
- const [canScrollPrev, setCanScrollPrev] = React.useState(false);
66
- const [canScrollNext, setCanScrollNext] = React.useState(false);
67
-
68
- const onSelect = React.useCallback((api: CarouselApi) => {
69
- if (!api) {
70
- return;
59
+ plugins
60
+ )
61
+ const [canScrollPrev, setCanScrollPrev] = React.useState(false)
62
+ const [canScrollNext, setCanScrollNext] = React.useState(false)
63
+
64
+ const onSelect = React.useCallback((api: CarouselApi) => {
65
+ if (!api) return
66
+ setCanScrollPrev(api.canScrollPrev())
67
+ setCanScrollNext(api.canScrollNext())
68
+ }, [])
69
+
70
+ const scrollPrev = React.useCallback(() => {
71
+ api?.scrollPrev()
72
+ }, [api])
73
+
74
+ const scrollNext = React.useCallback(() => {
75
+ api?.scrollNext()
76
+ }, [api])
77
+
78
+ const handleKeyDown = React.useCallback(
79
+ (event: React.KeyboardEvent<HTMLDivElement>) => {
80
+ if (event.key === "ArrowLeft") {
81
+ event.preventDefault()
82
+ scrollPrev()
83
+ } else if (event.key === "ArrowRight") {
84
+ event.preventDefault()
85
+ scrollNext()
71
86
  }
87
+ },
88
+ [scrollPrev, scrollNext]
89
+ )
72
90
 
73
- setCanScrollPrev(api.canScrollPrev());
74
- setCanScrollNext(api.canScrollNext());
75
- }, []);
76
-
77
- const scrollPrev = React.useCallback(() => {
78
- api?.scrollPrev();
79
- }, [api]);
80
-
81
- const scrollNext = React.useCallback(() => {
82
- api?.scrollNext();
83
- }, [api]);
84
-
85
- const handleKeyDown = React.useCallback(
86
- (event: React.KeyboardEvent<HTMLDivElement>) => {
87
- if (event.key === "ArrowLeft") {
88
- event.preventDefault();
89
- scrollPrev();
90
- } else if (event.key === "ArrowRight") {
91
- event.preventDefault();
92
- scrollNext();
93
- }
94
- },
95
- [scrollPrev, scrollNext]
96
- );
97
-
98
- React.useEffect(() => {
99
- if (!api || !setApi) {
100
- return;
101
- }
102
-
103
- setApi(api);
104
- }, [api, setApi]);
105
-
106
- React.useEffect(() => {
107
- if (!api) {
108
- return;
109
- }
91
+ React.useEffect(() => {
92
+ if (!api || !setApi) return
93
+ setApi(api)
94
+ }, [api, setApi])
110
95
 
111
- onSelect(api);
112
- api.on("reInit", onSelect);
113
- api.on("select", onSelect);
96
+ React.useEffect(() => {
97
+ if (!api) return
98
+ onSelect(api)
99
+ api.on("reInit", onSelect)
100
+ api.on("select", onSelect)
114
101
 
115
- return () => {
116
- api?.off("select", onSelect);
117
- };
118
- }, [api, onSelect]);
102
+ return () => {
103
+ api?.off("select", onSelect)
104
+ }
105
+ }, [api, onSelect])
119
106
 
120
- return (
121
- <CarouselContext.Provider
122
- value={{
123
- carouselRef,
124
- api: api,
125
- opts,
126
- orientation:
127
- orientation || (opts?.axis === "y" ? "vertical" : "horizontal"),
128
- scrollPrev,
129
- scrollNext,
130
- canScrollPrev,
131
- canScrollNext,
132
- }}
107
+ return (
108
+ <CarouselContext.Provider
109
+ value={{
110
+ carouselRef,
111
+ api: api,
112
+ opts,
113
+ orientation:
114
+ orientation || (opts?.axis === "y" ? "vertical" : "horizontal"),
115
+ scrollPrev,
116
+ scrollNext,
117
+ canScrollPrev,
118
+ canScrollNext,
119
+ }}
120
+ >
121
+ <div
122
+ onKeyDownCapture={handleKeyDown}
123
+ className={cn("relative", className)}
124
+ role="region"
125
+ aria-roledescription="carousel"
126
+ data-slot="carousel"
127
+ {...props}
133
128
  >
134
- <div
135
- ref={ref}
136
- onKeyDownCapture={handleKeyDown}
137
- className={cn("relative", className)}
138
- role="region"
139
- aria-roledescription="carousel"
140
- {...props}
141
- >
142
- {children}
143
- </div>
144
- </CarouselContext.Provider>
145
- );
146
- }
147
- );
148
- Carousel.displayName = "Carousel";
129
+ {children}
130
+ </div>
131
+ </CarouselContext.Provider>
132
+ )
133
+ }
149
134
 
150
- const CarouselContent = React.forwardRef<
151
- HTMLDivElement,
152
- React.HTMLAttributes<HTMLDivElement>
153
- >(({ className, ...props }, ref) => {
154
- const { carouselRef, orientation } = useCarousel();
135
+ function CarouselContent({ className, ...props }: React.ComponentProps<"div">) {
136
+ const { carouselRef, orientation } = useCarousel()
155
137
 
156
138
  return (
157
- <div ref={carouselRef} className="overflow-hidden">
139
+ <div
140
+ ref={carouselRef}
141
+ className="overflow-hidden"
142
+ data-slot="carousel-content"
143
+ >
158
144
  <div
159
- ref={ref}
160
145
  className={cn(
161
146
  "flex",
162
147
  orientation === "horizontal" ? "-ml-4" : "-mt-4 flex-col",
@@ -165,21 +150,17 @@ const CarouselContent = React.forwardRef<
165
150
  {...props}
166
151
  />
167
152
  </div>
168
- );
169
- });
170
- CarouselContent.displayName = "CarouselContent";
153
+ )
154
+ }
171
155
 
172
- const CarouselItem = React.forwardRef<
173
- HTMLDivElement,
174
- React.HTMLAttributes<HTMLDivElement>
175
- >(({ className, ...props }, ref) => {
176
- const { orientation } = useCarousel();
156
+ function CarouselItem({ className, ...props }: React.ComponentProps<"div">) {
157
+ const { orientation } = useCarousel()
177
158
 
178
159
  return (
179
160
  <div
180
- ref={ref}
181
161
  role="group"
182
162
  aria-roledescription="slide"
163
+ data-slot="carousel-item"
183
164
  className={cn(
184
165
  "min-w-0 shrink-0 grow-0 basis-full",
185
166
  orientation === "horizontal" ? "pl-4" : "pt-4",
@@ -187,25 +168,26 @@ const CarouselItem = React.forwardRef<
187
168
  )}
188
169
  {...props}
189
170
  />
190
- );
191
- });
192
- CarouselItem.displayName = "CarouselItem";
171
+ )
172
+ }
193
173
 
194
- const CarouselPrevious = React.forwardRef<
195
- HTMLButtonElement,
196
- React.ComponentProps<typeof Button>
197
- >(({ className, variant = "outline", size = "icon", ...props }, ref) => {
198
- const { orientation, scrollPrev, canScrollPrev } = useCarousel();
174
+ function CarouselPrevious({
175
+ className,
176
+ variant = "outline",
177
+ size = "icon",
178
+ ...props
179
+ }: React.ComponentProps<typeof Button>) {
180
+ const { orientation, scrollPrev, canScrollPrev } = useCarousel()
199
181
 
200
182
  return (
201
183
  <Button
202
- ref={ref}
184
+ data-slot="carousel-previous"
203
185
  variant={variant}
204
186
  size={size}
205
187
  className={cn(
206
- "absolute h-8 w-8 rounded-full",
188
+ "absolute size-8 rounded-full",
207
189
  orientation === "horizontal"
208
- ? "-left-12 top-1/2 -translate-y-1/2"
190
+ ? "top-1/2 -left-12 -translate-y-1/2"
209
191
  : "-top-12 left-1/2 -translate-x-1/2 rotate-90",
210
192
  className
211
193
  )}
@@ -213,28 +195,29 @@ const CarouselPrevious = React.forwardRef<
213
195
  onClick={scrollPrev}
214
196
  {...props}
215
197
  >
216
- <ArrowLeft className="h-4 w-4" />
198
+ <ArrowLeft />
217
199
  <span className="sr-only">Previous slide</span>
218
200
  </Button>
219
- );
220
- });
221
- CarouselPrevious.displayName = "CarouselPrevious";
201
+ )
202
+ }
222
203
 
223
- const CarouselNext = React.forwardRef<
224
- HTMLButtonElement,
225
- React.ComponentProps<typeof Button>
226
- >(({ className, variant = "outline", size = "icon", ...props }, ref) => {
227
- const { orientation, scrollNext, canScrollNext } = useCarousel();
204
+ function CarouselNext({
205
+ className,
206
+ variant = "outline",
207
+ size = "icon",
208
+ ...props
209
+ }: React.ComponentProps<typeof Button>) {
210
+ const { orientation, scrollNext, canScrollNext } = useCarousel()
228
211
 
229
212
  return (
230
213
  <Button
231
- ref={ref}
214
+ data-slot="carousel-next"
232
215
  variant={variant}
233
216
  size={size}
234
217
  className={cn(
235
- "absolute h-8 w-8 rounded-full",
218
+ "absolute size-8 rounded-full",
236
219
  orientation === "horizontal"
237
- ? "-right-12 top-1/2 -translate-y-1/2"
220
+ ? "top-1/2 -right-12 -translate-y-1/2"
238
221
  : "-bottom-12 left-1/2 -translate-x-1/2 rotate-90",
239
222
  className
240
223
  )}
@@ -242,12 +225,11 @@ const CarouselNext = React.forwardRef<
242
225
  onClick={scrollNext}
243
226
  {...props}
244
227
  >
245
- <ArrowRight className="h-4 w-4" />
228
+ <ArrowRight />
246
229
  <span className="sr-only">Next slide</span>
247
230
  </Button>
248
- );
249
- });
250
- CarouselNext.displayName = "CarouselNext";
231
+ )
232
+ }
251
233
 
252
234
  export {
253
235
  type CarouselApi,
@@ -256,4 +238,4 @@ export {
256
238
  CarouselItem,
257
239
  CarouselPrevious,
258
240
  CarouselNext,
259
- };
241
+ }