@glasshome/ui 1.21.1 → 1.22.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 (146) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.js +1 -1
  3. package/dist/lib/use-is-mobile.d.ts +3 -1
  4. package/dist/solid/index.d.ts +9 -9
  5. package/dist/solid/index.js +5431 -5424
  6. package/dist/solid/sonner.d.ts +1 -0
  7. package/dist/{utils-CMk7R3zM.js → utils-D5blHO4O.js} +624 -622
  8. package/package.json +128 -126
  9. package/scripts/check-gallery.ts +142 -142
  10. package/scripts/check-pack.ts +13 -13
  11. package/scripts/check-structural-classes.ts +20 -20
  12. package/scripts/check-tokens.ts +27 -27
  13. package/scripts/check-ui-drift.mjs +103 -103
  14. package/src/index.ts +75 -80
  15. package/src/lib/alert-tones.ts +41 -41
  16. package/src/lib/anchor-placement.ts +21 -21
  17. package/src/lib/button-variants.ts +28 -28
  18. package/src/lib/card-classes.ts +9 -9
  19. package/src/lib/carousel-classes.ts +14 -14
  20. package/src/lib/glass-tone.ts +11 -11
  21. package/src/lib/input-classes.ts +6 -6
  22. package/src/lib/layers.ts +4 -4
  23. package/src/lib/logo-lockup.ts +8 -8
  24. package/src/lib/menu-classes.ts +2 -2
  25. package/src/lib/motion-classes.ts +8 -8
  26. package/src/lib/motion-window.ts +24 -24
  27. package/src/lib/overlay-classes.ts +6 -6
  28. package/src/lib/pill-classes.ts +3 -3
  29. package/src/lib/position-bar-classes.ts +1 -1
  30. package/src/lib/spotlight-geometry.ts +67 -67
  31. package/src/lib/thumb-classes.ts +2 -2
  32. package/src/lib/tier-badge.ts +16 -16
  33. package/src/lib/use-is-mobile.ts +17 -14
  34. package/src/lib/utils.ts +1 -1
  35. package/src/solid/accordion.tsx +41 -41
  36. package/src/solid/alert-dialog.tsx +95 -95
  37. package/src/solid/alert.tsx +88 -88
  38. package/src/solid/area-picker.tsx +204 -204
  39. package/src/solid/aspect-ratio.tsx +13 -13
  40. package/src/solid/avatar.tsx +27 -27
  41. package/src/solid/badge.tsx +49 -49
  42. package/src/solid/bottom-sheet/arbitration.ts +22 -22
  43. package/src/solid/bottom-sheet/bottom-sheet.tsx +394 -394
  44. package/src/solid/bottom-sheet/drag-controller.ts +201 -201
  45. package/src/solid/bottom-sheet/focus-trap.ts +51 -47
  46. package/src/solid/bottom-sheet/index.ts +12 -12
  47. package/src/solid/bottom-sheet/keyboard.ts +25 -25
  48. package/src/solid/bottom-sheet/scroll-lock.ts +46 -46
  49. package/src/solid/bottom-sheet/state-machine.ts +28 -28
  50. package/src/solid/bottom-sheet/velocity.ts +29 -29
  51. package/src/solid/breadcrumb.tsx +76 -76
  52. package/src/solid/button-group.tsx +46 -46
  53. package/src/solid/button.tsx +19 -19
  54. package/src/solid/card.tsx +67 -67
  55. package/src/solid/carousel.tsx +246 -246
  56. package/src/solid/charts.tsx +253 -253
  57. package/src/solid/checkbox.tsx +51 -51
  58. package/src/solid/collapsible.tsx +22 -22
  59. package/src/solid/color-disc.tsx +213 -213
  60. package/src/solid/color-slider.tsx +81 -81
  61. package/src/solid/color-wheel.tsx +61 -61
  62. package/src/solid/context-menu.tsx +63 -63
  63. package/src/solid/copy-button.tsx +31 -31
  64. package/src/solid/count-pill.tsx +11 -11
  65. package/src/solid/dashboard-preview.tsx +104 -104
  66. package/src/solid/data-table.tsx +228 -228
  67. package/src/solid/dialog-parts.tsx +127 -127
  68. package/src/solid/dialog.tsx +113 -113
  69. package/src/solid/dock-paging.ts +9 -9
  70. package/src/solid/dock.tsx +339 -339
  71. package/src/solid/docked-panel.tsx +35 -35
  72. package/src/solid/dropdown-menu.tsx +77 -77
  73. package/src/solid/empty.tsx +70 -70
  74. package/src/solid/entity-data.ts +38 -38
  75. package/src/solid/entity-selector.tsx +634 -634
  76. package/src/solid/field.tsx +205 -205
  77. package/src/solid/form.tsx +159 -159
  78. package/src/solid/hero-action.tsx +85 -85
  79. package/src/solid/hover-card.tsx +11 -11
  80. package/src/solid/icon-picker.tsx +401 -401
  81. package/src/solid/icon.tsx +101 -78
  82. package/src/solid/image-picker.tsx +416 -414
  83. package/src/solid/index.ts +265 -304
  84. package/src/solid/input-group.tsx +123 -123
  85. package/src/solid/input-otp.tsx +143 -143
  86. package/src/solid/input.tsx +4 -4
  87. package/src/solid/item.tsx +130 -130
  88. package/src/solid/kbd.tsx +20 -20
  89. package/src/solid/label.tsx +12 -12
  90. package/src/solid/list-reorder.ts +122 -122
  91. package/src/solid/logo.tsx +60 -60
  92. package/src/solid/media-copy.ts +21 -21
  93. package/src/solid/media-store.ts +56 -56
  94. package/src/solid/media-tile.tsx +85 -85
  95. package/src/solid/menu-parts.tsx +164 -164
  96. package/src/solid/number-field.tsx +56 -56
  97. package/src/solid/option-card.tsx +164 -164
  98. package/src/solid/ornament.tsx +43 -43
  99. package/src/solid/overlay.tsx +4 -4
  100. package/src/solid/page-header.tsx +75 -75
  101. package/src/solid/pagination.tsx +80 -80
  102. package/src/solid/password-input.tsx +51 -51
  103. package/src/solid/picker-row.tsx +83 -83
  104. package/src/solid/picker-search.tsx +65 -63
  105. package/src/solid/picker-trigger.tsx +59 -57
  106. package/src/solid/popover.tsx +54 -54
  107. package/src/solid/preview-tile.tsx +67 -67
  108. package/src/solid/progress.tsx +21 -21
  109. package/src/solid/radio-group.tsx +51 -51
  110. package/src/solid/resizable.tsx +128 -128
  111. package/src/solid/responsive-dialog.tsx +134 -134
  112. package/src/solid/schema-form.tsx +743 -743
  113. package/src/solid/scope-indicator.tsx +5 -5
  114. package/src/solid/scroll-area.tsx +16 -16
  115. package/src/solid/section-card.tsx +281 -281
  116. package/src/solid/select.tsx +101 -101
  117. package/src/solid/separator.tsx +25 -25
  118. package/src/solid/settings-row.tsx +122 -122
  119. package/src/solid/sheet.tsx +96 -96
  120. package/src/solid/skeleton.tsx +8 -8
  121. package/src/solid/slider.tsx +132 -132
  122. package/src/solid/sliding-indicator.tsx +280 -265
  123. package/src/solid/sonner.tsx +165 -164
  124. package/src/solid/spinner.tsx +12 -12
  125. package/src/solid/spotlight.tsx +140 -140
  126. package/src/solid/step-indicator.tsx +18 -18
  127. package/src/solid/swatch-picker.tsx +38 -38
  128. package/src/solid/switch.tsx +52 -52
  129. package/src/solid/table.tsx +63 -63
  130. package/src/solid/tabs.tsx +93 -93
  131. package/src/solid/textarea.tsx +8 -8
  132. package/src/solid/toggle-group.tsx +83 -83
  133. package/src/solid/toggle.tsx +33 -33
  134. package/src/solid/tooltip.tsx +16 -16
  135. package/src/solid/widget-card.tsx +90 -90
  136. package/src/solid/widget-identity.tsx +99 -99
  137. package/src/solid/widget-trust-badge.tsx +20 -20
  138. package/src/styles/globals.css +316 -319
  139. package/src/styles/theme.css +448 -448
  140. package/src/tokens/hex.ts +29 -29
  141. package/src/tokens/material.ts +75 -75
  142. package/src/tokens/presets.ts +303 -303
  143. package/src/tokens/readability.ts +32 -32
  144. package/src/tokens/theme-colors.ts +95 -95
  145. package/src/tokens/theme-css.ts +22 -22
  146. package/src/tokens/theme-recipe.ts +106 -106
@@ -1,29 +1,29 @@
1
1
  import EmblaCarousel, {
2
- type EmblaCarouselType,
3
- type EmblaOptionsType,
4
- type EmblaPluginType,
2
+ type EmblaCarouselType,
3
+ type EmblaOptionsType,
4
+ type EmblaPluginType,
5
5
  } from "embla-carousel";
6
6
  import Autoplay from "embla-carousel-autoplay";
7
7
  import Fade from "embla-carousel-fade";
8
8
  import {
9
- type Accessor,
10
- type Component,
11
- type ComponentProps,
12
- createContext,
13
- createEffect,
14
- createSignal,
15
- onCleanup,
16
- type ParentComponent,
17
- splitProps,
18
- useContext,
9
+ type Accessor,
10
+ type Component,
11
+ type ComponentProps,
12
+ createContext,
13
+ createEffect,
14
+ createSignal,
15
+ onCleanup,
16
+ type ParentComponent,
17
+ splitProps,
18
+ useContext,
19
19
  } from "solid-js";
20
20
  import {
21
- CAROUSEL_DOTS,
22
- CAROUSEL_VIEWPORT,
23
- type CarouselTransition,
24
- carouselDot,
25
- carouselItem,
26
- carouselTrack,
21
+ CAROUSEL_DOTS,
22
+ CAROUSEL_VIEWPORT,
23
+ type CarouselTransition,
24
+ carouselDot,
25
+ carouselItem,
26
+ carouselTrack,
27
27
  } from "../lib/carousel-classes.js";
28
28
  import { cn } from "../lib/utils.js";
29
29
  import { Button } from "./button.js";
@@ -32,271 +32,271 @@ import { Icon } from "./icon.js";
32
32
  type CarouselApi = EmblaCarouselType;
33
33
 
34
34
  interface CarouselContextProps {
35
- viewportRef: (el: HTMLDivElement) => void;
36
- api: Accessor<CarouselApi | undefined>;
37
- scrollPrev: () => void;
38
- scrollNext: () => void;
39
- canScrollPrev: Accessor<boolean>;
40
- canScrollNext: Accessor<boolean>;
41
- orientation: Accessor<"horizontal" | "vertical">;
42
- transition: Accessor<CarouselTransition>;
43
- selected: Accessor<number>;
44
- slideCount: Accessor<number>;
45
- scrollTo: (index: number) => void;
35
+ viewportRef: (el: HTMLDivElement) => void;
36
+ api: Accessor<CarouselApi | undefined>;
37
+ scrollPrev: () => void;
38
+ scrollNext: () => void;
39
+ canScrollPrev: Accessor<boolean>;
40
+ canScrollNext: Accessor<boolean>;
41
+ orientation: Accessor<"horizontal" | "vertical">;
42
+ transition: Accessor<CarouselTransition>;
43
+ selected: Accessor<number>;
44
+ slideCount: Accessor<number>;
45
+ scrollTo: (index: number) => void;
46
46
  }
47
47
 
48
48
  const CarouselContext = createContext<CarouselContextProps>();
49
49
 
50
50
  function useCarousel() {
51
- const context = useContext(CarouselContext);
52
- if (!context) {
53
- throw new Error("useCarousel must be used within a <Carousel />");
54
- }
55
- return context;
51
+ const context = useContext(CarouselContext);
52
+ if (!context) {
53
+ throw new Error("useCarousel must be used within a <Carousel />");
54
+ }
55
+ return context;
56
56
  }
57
57
 
58
58
  const Carousel: ParentComponent<
59
- ComponentProps<"div"> & {
60
- opts?: EmblaOptionsType;
61
- plugins?: EmblaPluginType[];
62
- orientation?: "horizontal" | "vertical";
63
- transition?: CarouselTransition;
64
- /** Advance every N ms. Ignored under prefers-reduced-motion. */
65
- autoplay?: number;
66
- setApi?: (api: CarouselApi) => void;
67
- }
59
+ ComponentProps<"div"> & {
60
+ opts?: EmblaOptionsType;
61
+ plugins?: EmblaPluginType[];
62
+ orientation?: "horizontal" | "vertical";
63
+ transition?: CarouselTransition;
64
+ /** Advance every N ms. Ignored under prefers-reduced-motion. */
65
+ autoplay?: number;
66
+ setApi?: (api: CarouselApi) => void;
67
+ }
68
68
  > = (props) => {
69
- const [local, rest] = splitProps(props, [
70
- "class",
71
- "children",
72
- "opts",
73
- "plugins",
74
- "orientation",
75
- "transition",
76
- "autoplay",
77
- "setApi",
78
- ]);
79
- const orientation = () => local.orientation ?? "horizontal";
80
- const transition = () => local.transition ?? "slide";
81
- let viewportEl: HTMLDivElement | undefined;
82
- const [api, setApi] = createSignal<CarouselApi>();
83
- const [canScrollPrev, setCanScrollPrev] = createSignal(false);
84
- const [canScrollNext, setCanScrollNext] = createSignal(false);
85
- const [selected, setSelected] = createSignal(0);
86
- const [slideCount, setSlideCount] = createSignal(0);
69
+ const [local, rest] = splitProps(props, [
70
+ "class",
71
+ "children",
72
+ "opts",
73
+ "plugins",
74
+ "orientation",
75
+ "transition",
76
+ "autoplay",
77
+ "setApi",
78
+ ]);
79
+ const orientation = () => local.orientation ?? "horizontal";
80
+ const transition = () => local.transition ?? "slide";
81
+ let viewportEl: HTMLDivElement | undefined;
82
+ const [api, setApi] = createSignal<CarouselApi>();
83
+ const [canScrollPrev, setCanScrollPrev] = createSignal(false);
84
+ const [canScrollNext, setCanScrollNext] = createSignal(false);
85
+ const [selected, setSelected] = createSignal(0);
86
+ const [slideCount, setSlideCount] = createSignal(0);
87
87
 
88
- const viewportRef = (el: HTMLDivElement) => {
89
- viewportEl = el;
90
- };
88
+ const viewportRef = (el: HTMLDivElement) => {
89
+ viewportEl = el;
90
+ };
91
91
 
92
- // Tracks autoplay: a widget whose config changes the interval (or supplies one
93
- // after the first mount) gets a re-initialised engine, old timers destroyed.
94
- createEffect(() => {
95
- const delay = local.autoplay;
96
- if (!viewportEl) return;
97
- // Reduced motion keeps the carousel usable but stops it moving on its own.
98
- const reduced = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
99
- const plugins = [...(local.plugins ?? [])];
100
- if (transition() !== "slide") plugins.push(Fade());
101
- if (delay && !reduced) {
102
- // Manual nav should not kill autoplay for good; hover/focus pauses it.
103
- plugins.push(
104
- Autoplay({
105
- delay,
106
- stopOnInteraction: false,
107
- stopOnMouseEnter: true,
108
- stopOnFocusIn: true,
109
- }),
110
- );
111
- }
112
- const embla = EmblaCarousel(
113
- viewportEl,
114
- { axis: orientation() === "horizontal" ? "x" : "y", ...local.opts },
115
- plugins,
116
- );
117
- setApi(embla);
118
- local.setApi?.(embla);
92
+ // Tracks autoplay: a widget whose config changes the interval (or supplies one
93
+ // after the first mount) gets a re-initialised engine, old timers destroyed.
94
+ createEffect(() => {
95
+ const delay = local.autoplay;
96
+ if (!viewportEl) return;
97
+ // Reduced motion keeps the carousel usable but stops it moving on its own.
98
+ const reduced = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
99
+ const plugins = [...(local.plugins ?? [])];
100
+ if (transition() !== "slide") plugins.push(Fade());
101
+ if (delay && !reduced) {
102
+ // Manual nav should not kill autoplay for good; hover/focus pauses it.
103
+ plugins.push(
104
+ Autoplay({
105
+ delay,
106
+ stopOnInteraction: false,
107
+ stopOnMouseEnter: true,
108
+ stopOnFocusIn: true,
109
+ }),
110
+ );
111
+ }
112
+ const embla = EmblaCarousel(
113
+ viewportEl,
114
+ { axis: orientation() === "horizontal" ? "x" : "y", ...local.opts },
115
+ plugins,
116
+ );
117
+ setApi(embla);
118
+ local.setApi?.(embla);
119
119
 
120
- let previous = -1;
121
- const onSelect = () => {
122
- setCanScrollPrev(embla.canScrollPrev());
123
- setCanScrollNext(embla.canScrollNext());
124
- setSelected(embla.selectedScrollSnap());
125
- setSlideCount(embla.scrollSnapList().length);
126
- // Slides carry their own selected state so CSS (wipe) can key off it;
127
- // embla itself only drives transform and opacity. data-prev keeps the
128
- // outgoing slide one layer down until the sweep lands.
129
- const active = embla.selectedScrollSnap();
130
- embla.slideNodes().forEach((node, i) => {
131
- node.toggleAttribute("data-selected", i === active);
132
- node.toggleAttribute("data-prev", i === previous && i !== active);
133
- });
134
- previous = active;
135
- };
136
- onSelect();
137
- embla.on("reInit", onSelect);
138
- embla.on("select", onSelect);
120
+ let previous = -1;
121
+ const onSelect = () => {
122
+ setCanScrollPrev(embla.canScrollPrev());
123
+ setCanScrollNext(embla.canScrollNext());
124
+ setSelected(embla.selectedScrollSnap());
125
+ setSlideCount(embla.scrollSnapList().length);
126
+ // Slides carry their own selected state so CSS (wipe) can key off it;
127
+ // embla itself only drives transform and opacity. data-prev keeps the
128
+ // outgoing slide one layer down until the sweep lands.
129
+ const active = embla.selectedScrollSnap();
130
+ embla.slideNodes().forEach((node, i) => {
131
+ node.toggleAttribute("data-selected", i === active);
132
+ node.toggleAttribute("data-prev", i === previous && i !== active);
133
+ });
134
+ previous = active;
135
+ };
136
+ onSelect();
137
+ embla.on("reInit", onSelect);
138
+ embla.on("select", onSelect);
139
139
 
140
- onCleanup(() => embla.destroy());
141
- });
140
+ onCleanup(() => embla.destroy());
141
+ });
142
142
 
143
- const scrollPrev = () => api()?.scrollPrev();
144
- const scrollNext = () => api()?.scrollNext();
145
- const scrollTo = (index: number) => api()?.scrollTo(index);
143
+ const scrollPrev = () => api()?.scrollPrev();
144
+ const scrollNext = () => api()?.scrollNext();
145
+ const scrollTo = (index: number) => api()?.scrollTo(index);
146
146
 
147
- const handleKeyDown = (e: KeyboardEvent) => {
148
- if (e.key === "ArrowLeft") {
149
- e.preventDefault();
150
- scrollPrev();
151
- } else if (e.key === "ArrowRight") {
152
- e.preventDefault();
153
- scrollNext();
154
- }
155
- };
147
+ const handleKeyDown = (e: KeyboardEvent) => {
148
+ if (e.key === "ArrowLeft") {
149
+ e.preventDefault();
150
+ scrollPrev();
151
+ } else if (e.key === "ArrowRight") {
152
+ e.preventDefault();
153
+ scrollNext();
154
+ }
155
+ };
156
156
 
157
- return (
158
- <CarouselContext.Provider
159
- value={{
160
- viewportRef,
161
- api,
162
- scrollPrev,
163
- scrollNext,
164
- canScrollPrev,
165
- canScrollNext,
166
- orientation,
167
- transition,
168
- selected,
169
- slideCount,
170
- scrollTo,
171
- }}
172
- >
173
- {/* biome-ignore lint/a11y/useSemanticElements: role=region + aria-roledescription is the canonical ARIA carousel pattern; section would change document outline semantics. */}
174
- <div
175
- onKeyDown={handleKeyDown}
176
- class={cn("relative", local.class)}
177
- role="region"
178
- aria-roledescription="carousel"
179
- data-slot="carousel"
180
- {...rest}
181
- >
182
- {local.children}
183
- </div>
184
- </CarouselContext.Provider>
185
- );
157
+ return (
158
+ <CarouselContext.Provider
159
+ value={{
160
+ viewportRef,
161
+ api,
162
+ scrollPrev,
163
+ scrollNext,
164
+ canScrollPrev,
165
+ canScrollNext,
166
+ orientation,
167
+ transition,
168
+ selected,
169
+ slideCount,
170
+ scrollTo,
171
+ }}
172
+ >
173
+ {/* biome-ignore lint/a11y/useSemanticElements: role=region + aria-roledescription is the canonical ARIA carousel pattern; section would change document outline semantics. */}
174
+ <div
175
+ onKeyDown={handleKeyDown}
176
+ class={cn("relative", local.class)}
177
+ role="region"
178
+ aria-roledescription="carousel"
179
+ data-slot="carousel"
180
+ {...rest}
181
+ >
182
+ {local.children}
183
+ </div>
184
+ </CarouselContext.Provider>
185
+ );
186
186
  };
187
187
 
188
188
  const CarouselContent: Component<ComponentProps<"div">> = (props) => {
189
- const [local, rest] = splitProps(props, ["class"]);
190
- const { viewportRef, orientation, transition } = useCarousel();
189
+ const [local, rest] = splitProps(props, ["class"]);
190
+ const { viewportRef, orientation, transition } = useCarousel();
191
191
 
192
- return (
193
- <div ref={viewportRef} class={CAROUSEL_VIEWPORT} data-slot="carousel-content">
194
- <div
195
- class={cn(carouselTrack(transition(), orientation()), local.class)}
196
- data-transition={transition()}
197
- {...rest}
198
- />
199
- </div>
200
- );
192
+ return (
193
+ <div ref={viewportRef} class={CAROUSEL_VIEWPORT} data-slot="carousel-content">
194
+ <div
195
+ class={cn(carouselTrack(transition(), orientation()), local.class)}
196
+ data-transition={transition()}
197
+ {...rest}
198
+ />
199
+ </div>
200
+ );
201
201
  };
202
202
 
203
203
  const CarouselItem: Component<ComponentProps<"div">> = (props) => {
204
- const [local, rest] = splitProps(props, ["class"]);
205
- const { orientation, transition } = useCarousel();
204
+ const [local, rest] = splitProps(props, ["class"]);
205
+ const { orientation, transition } = useCarousel();
206
206
 
207
- return (
208
- // biome-ignore lint/a11y/useSemanticElements: role=group + aria-roledescription=slide is the canonical ARIA carousel slide; no HTML element maps to group.
209
- <div
210
- role="group"
211
- aria-roledescription="slide"
212
- data-slot="carousel-item"
213
- class={cn(carouselItem(transition(), orientation()), local.class)}
214
- {...rest}
215
- />
216
- );
207
+ return (
208
+ // biome-ignore lint/a11y/useSemanticElements: role=group + aria-roledescription=slide is the canonical ARIA carousel slide; no HTML element maps to group.
209
+ <div
210
+ role="group"
211
+ aria-roledescription="slide"
212
+ data-slot="carousel-item"
213
+ class={cn(carouselItem(transition(), orientation()), local.class)}
214
+ {...rest}
215
+ />
216
+ );
217
217
  };
218
218
 
219
219
  /** Slide indicators. Stays in sync with drag, autoplay, and prev/next alike. */
220
220
  const CarouselDots: Component<ComponentProps<"div">> = (props) => {
221
- const [local, rest] = splitProps(props, ["class"]);
222
- const { selected, slideCount, scrollTo } = useCarousel();
221
+ const [local, rest] = splitProps(props, ["class"]);
222
+ const { selected, slideCount, scrollTo } = useCarousel();
223
223
 
224
- return (
225
- <div class={cn(CAROUSEL_DOTS, local.class)} data-slot="carousel-dots" {...rest}>
226
- {Array.from({ length: slideCount() }, (_, i) => (
227
- <button
228
- type="button"
229
- data-slot="carousel-dot"
230
- data-active={selected() === i ? "" : undefined}
231
- aria-label={`Go to slide ${i + 1}`}
232
- aria-current={selected() === i}
233
- class={carouselDot(selected() === i)}
234
- onClick={() => scrollTo(i)}
235
- />
236
- ))}
237
- </div>
238
- );
224
+ return (
225
+ <div class={cn(CAROUSEL_DOTS, local.class)} data-slot="carousel-dots" {...rest}>
226
+ {Array.from({ length: slideCount() }, (_, i) => (
227
+ <button
228
+ type="button"
229
+ data-slot="carousel-dot"
230
+ data-active={selected() === i ? "" : undefined}
231
+ aria-label={`Go to slide ${i + 1}`}
232
+ aria-current={selected() === i}
233
+ class={carouselDot(selected() === i)}
234
+ onClick={() => scrollTo(i)}
235
+ />
236
+ ))}
237
+ </div>
238
+ );
239
239
  };
240
240
 
241
241
  const CarouselPrevious: Component<ComponentProps<typeof Button>> = (props) => {
242
- const [local, rest] = splitProps(props, ["class", "variant", "size"]);
243
- const { orientation, scrollPrev, canScrollPrev } = useCarousel();
242
+ const [local, rest] = splitProps(props, ["class", "variant", "size"]);
243
+ const { orientation, scrollPrev, canScrollPrev } = useCarousel();
244
244
 
245
- return (
246
- <Button
247
- data-slot="carousel-previous"
248
- variant={local.variant ?? "outline"}
249
- size={local.size ?? "icon"}
250
- class={cn(
251
- "absolute size-8",
252
- orientation() === "horizontal"
253
- ? "top-1/2 -left-12 -translate-y-1/2"
254
- : "-top-12 left-1/2 -translate-x-1/2 rotate-90",
255
- local.class,
256
- )}
257
- disabled={!canScrollPrev()}
258
- onClick={scrollPrev}
259
- {...rest}
260
- >
261
- <Icon icon="lucide:arrow-left" width={16} height={16} />
262
- <span class="sr-only">Previous slide</span>
263
- </Button>
264
- );
245
+ return (
246
+ <Button
247
+ data-slot="carousel-previous"
248
+ variant={local.variant ?? "outline"}
249
+ size={local.size ?? "icon"}
250
+ class={cn(
251
+ "absolute size-8",
252
+ orientation() === "horizontal"
253
+ ? "top-1/2 -left-12 -translate-y-1/2"
254
+ : "-top-12 left-1/2 -translate-x-1/2 rotate-90",
255
+ local.class,
256
+ )}
257
+ disabled={!canScrollPrev()}
258
+ onClick={scrollPrev}
259
+ {...rest}
260
+ >
261
+ <Icon icon="lucide:arrow-left" width={16} height={16} />
262
+ <span class="sr-only">Previous slide</span>
263
+ </Button>
264
+ );
265
265
  };
266
266
 
267
267
  const CarouselNext: Component<ComponentProps<typeof Button>> = (props) => {
268
- const [local, rest] = splitProps(props, ["class", "variant", "size"]);
269
- const { orientation, scrollNext, canScrollNext } = useCarousel();
268
+ const [local, rest] = splitProps(props, ["class", "variant", "size"]);
269
+ const { orientation, scrollNext, canScrollNext } = useCarousel();
270
270
 
271
- return (
272
- <Button
273
- data-slot="carousel-next"
274
- variant={local.variant ?? "outline"}
275
- size={local.size ?? "icon"}
276
- class={cn(
277
- "absolute size-8",
278
- orientation() === "horizontal"
279
- ? "top-1/2 -right-12 -translate-y-1/2"
280
- : "-bottom-12 left-1/2 -translate-x-1/2 rotate-90",
281
- local.class,
282
- )}
283
- disabled={!canScrollNext()}
284
- onClick={scrollNext}
285
- {...rest}
286
- >
287
- <Icon icon="lucide:arrow-right" width={16} height={16} />
288
- <span class="sr-only">Next slide</span>
289
- </Button>
290
- );
271
+ return (
272
+ <Button
273
+ data-slot="carousel-next"
274
+ variant={local.variant ?? "outline"}
275
+ size={local.size ?? "icon"}
276
+ class={cn(
277
+ "absolute size-8",
278
+ orientation() === "horizontal"
279
+ ? "top-1/2 -right-12 -translate-y-1/2"
280
+ : "-bottom-12 left-1/2 -translate-x-1/2 rotate-90",
281
+ local.class,
282
+ )}
283
+ disabled={!canScrollNext()}
284
+ onClick={scrollNext}
285
+ {...rest}
286
+ >
287
+ <Icon icon="lucide:arrow-right" width={16} height={16} />
288
+ <span class="sr-only">Next slide</span>
289
+ </Button>
290
+ );
291
291
  };
292
292
 
293
293
  export {
294
- Carousel,
295
- type CarouselApi,
296
- CarouselContent,
297
- CarouselDots,
298
- CarouselItem,
299
- CarouselNext,
300
- CarouselPrevious,
301
- type CarouselTransition,
294
+ Carousel,
295
+ type CarouselApi,
296
+ CarouselContent,
297
+ CarouselDots,
298
+ CarouselItem,
299
+ CarouselNext,
300
+ CarouselPrevious,
301
+ type CarouselTransition,
302
302
  };