orbital-ds 0.1.1 → 0.2.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.
- package/contract.json +38 -0
- package/dist/styles.css +89 -9
- package/dist/themes/zyro.css +189 -0
- package/dist/ui/accordion.d.ts +9 -0
- package/dist/ui/accordion.js +79 -0
- package/dist/ui/alert-dialog.d.ts +23 -0
- package/dist/ui/alert-dialog.js +173 -0
- package/dist/ui/alert.d.ts +13 -0
- package/dist/ui/alert.js +77 -0
- package/dist/ui/aspect-ratio.d.ts +7 -0
- package/dist/ui/aspect-ratio.js +22 -0
- package/dist/ui/attachment.d.ts +26 -0
- package/dist/ui/attachment.js +197 -0
- package/dist/ui/avatar.js +1 -1
- package/dist/ui/badge.d.ts +1 -1
- package/dist/ui/badge.js +1 -1
- package/dist/ui/bubble.d.ts +19 -0
- package/dist/ui/bubble.js +115 -0
- package/dist/ui/button-group.d.ts +15 -0
- package/dist/ui/button-group.js +82 -0
- package/dist/ui/button.d.ts +5 -3
- package/dist/ui/button.js +9 -6
- package/dist/ui/calendar.d.ts +15 -0
- package/dist/ui/calendar.js +190 -0
- package/dist/ui/card.js +4 -4
- package/dist/ui/carousel.d.ts +33 -0
- package/dist/ui/carousel.js +199 -0
- package/dist/ui/checkbox.js +1 -1
- package/dist/ui/combobox.d.ts +26 -0
- package/dist/ui/combobox.js +281 -0
- package/dist/ui/command.d.ts +22 -0
- package/dist/ui/command.js +183 -0
- package/dist/ui/context-menu.d.ts +31 -0
- package/dist/ui/context-menu.js +242 -0
- package/dist/ui/dialog.js +2 -2
- package/dist/ui/direction.d.ts +1 -0
- package/dist/ui/direction.js +8 -0
- package/dist/ui/drawer.d.ts +18 -0
- package/dist/ui/drawer.js +208 -0
- package/dist/ui/dropdown-menu.d.ts +1 -1
- package/dist/ui/dropdown-menu.js +13 -9
- package/dist/ui/empty.d.ts +15 -0
- package/dist/ui/empty.js +102 -0
- package/dist/ui/field.d.ts +28 -0
- package/dist/ui/field.js +217 -0
- package/dist/ui/hover-card.d.ts +8 -0
- package/dist/ui/hover-card.js +45 -0
- package/dist/ui/input-group.d.ts +22 -0
- package/dist/ui/input-group.js +145 -0
- package/dist/ui/input-otp.d.ts +13 -0
- package/dist/ui/input-otp.js +82 -0
- package/dist/ui/input.js +1 -1
- package/dist/ui/item.d.ts +26 -0
- package/dist/ui/item.js +195 -0
- package/dist/ui/kbd.d.ts +6 -0
- package/dist/ui/kbd.js +29 -0
- package/dist/ui/marker.d.ts +13 -0
- package/dist/ui/marker.js +71 -0
- package/dist/ui/menubar.d.ts +31 -0
- package/dist/ui/menubar.js +259 -0
- package/dist/ui/message-scroller.d.ts +16 -0
- package/dist/ui/message-scroller.js +120 -0
- package/dist/ui/message.d.ts +12 -0
- package/dist/ui/message.js +90 -0
- package/dist/ui/native-select.d.ts +10 -0
- package/dist/ui/native-select.js +63 -0
- package/dist/ui/navigation-menu.d.ts +15 -0
- package/dist/ui/navigation-menu.js +162 -0
- package/dist/ui/pagination.d.ts +22 -0
- package/dist/ui/pagination.js +128 -0
- package/dist/ui/popover.js +2 -2
- package/dist/ui/questionnaire.d.ts +24 -0
- package/dist/ui/questionnaire.js +331 -0
- package/dist/ui/radio-group.d.ts +8 -0
- package/dist/ui/radio-group.js +39 -0
- package/dist/ui/resizable.d.ts +10 -0
- package/dist/ui/resizable.js +46 -0
- package/dist/ui/scroll-area.js +1 -1
- package/dist/ui/select.js +5 -5
- package/dist/ui/sheet.js +4 -4
- package/dist/ui/sidebar.js +4 -4
- package/dist/ui/slider.d.ts +6 -0
- package/dist/ui/slider.js +53 -0
- package/dist/ui/spinner.d.ts +5 -0
- package/dist/ui/spinner.js +9 -0
- package/dist/ui/switch.d.ts +8 -0
- package/dist/ui/switch.js +32 -0
- package/dist/ui/table.js +2 -2
- package/dist/ui/tabs.js +1 -1
- package/dist/ui/textarea.js +1 -1
- package/dist/ui/toast.d.ts +19 -0
- package/dist/ui/toast.js +193 -0
- package/dist/ui/toggle-group.d.ts +14 -0
- package/dist/ui/toggle-group.js +77 -0
- package/dist/ui/toggle.d.ts +12 -0
- package/dist/ui/toggle.js +43 -0
- package/dist/ui/tooltip.js +3 -3
- package/docs/CONTRACT.md +113 -0
- package/package.json +133 -95
- package/scripts/doctor.mjs +142 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { DayPicker, DayButton, Locale } from 'react-day-picker';
|
|
3
|
+
import { Button } from './button.js';
|
|
4
|
+
import 'class-variance-authority/types';
|
|
5
|
+
import '@base-ui/react/use-render';
|
|
6
|
+
import 'class-variance-authority';
|
|
7
|
+
|
|
8
|
+
declare function Calendar({ className, classNames, showOutsideDays, captionLayout, buttonVariant, locale, formatters, components, ...props }: React.ComponentProps<typeof DayPicker> & {
|
|
9
|
+
buttonVariant?: React.ComponentProps<typeof Button>["variant"];
|
|
10
|
+
}): React.JSX.Element;
|
|
11
|
+
declare function CalendarDayButton({ className, day, modifiers, locale, ...props }: React.ComponentProps<typeof DayButton> & {
|
|
12
|
+
locale?: Partial<Locale>;
|
|
13
|
+
}): React.JSX.Element;
|
|
14
|
+
|
|
15
|
+
export { Calendar, CalendarDayButton };
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { cn } from "../lib/utils";
|
|
5
|
+
import {
|
|
6
|
+
DayPicker,
|
|
7
|
+
getDefaultClassNames
|
|
8
|
+
} from "react-day-picker";
|
|
9
|
+
import { Button, buttonVariants } from "./button";
|
|
10
|
+
import { ChevronLeftIcon, ChevronRightIcon, ChevronDownIcon } from "lucide-react";
|
|
11
|
+
function Calendar({
|
|
12
|
+
className,
|
|
13
|
+
classNames,
|
|
14
|
+
showOutsideDays = true,
|
|
15
|
+
captionLayout = "label",
|
|
16
|
+
buttonVariant = "ghost",
|
|
17
|
+
locale,
|
|
18
|
+
formatters,
|
|
19
|
+
components,
|
|
20
|
+
...props
|
|
21
|
+
}) {
|
|
22
|
+
const defaultClassNames = getDefaultClassNames();
|
|
23
|
+
return /* @__PURE__ */ jsx(
|
|
24
|
+
DayPicker,
|
|
25
|
+
{
|
|
26
|
+
showOutsideDays,
|
|
27
|
+
className: cn(
|
|
28
|
+
"group/calendar bg-background p-3 [--cell-radius:var(--radius-4xl)] [--cell-size:--spacing(8)] in-data-[slot=card-content]:bg-transparent in-data-[slot=popover-content]:bg-transparent",
|
|
29
|
+
String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
|
|
30
|
+
String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
|
|
31
|
+
className
|
|
32
|
+
),
|
|
33
|
+
captionLayout,
|
|
34
|
+
locale,
|
|
35
|
+
formatters: {
|
|
36
|
+
formatMonthDropdown: (date) => date.toLocaleString(locale?.code, { month: "short" }),
|
|
37
|
+
...formatters
|
|
38
|
+
},
|
|
39
|
+
classNames: {
|
|
40
|
+
root: cn("w-fit", defaultClassNames.root),
|
|
41
|
+
months: cn(
|
|
42
|
+
"relative flex flex-col gap-4 md:flex-row",
|
|
43
|
+
defaultClassNames.months
|
|
44
|
+
),
|
|
45
|
+
month: cn("flex w-full flex-col gap-4", defaultClassNames.month),
|
|
46
|
+
nav: cn(
|
|
47
|
+
"absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",
|
|
48
|
+
defaultClassNames.nav
|
|
49
|
+
),
|
|
50
|
+
button_previous: cn(
|
|
51
|
+
buttonVariants({ variant: buttonVariant }),
|
|
52
|
+
"size-(--cell-size) p-0 select-none aria-disabled:opacity-50",
|
|
53
|
+
defaultClassNames.button_previous
|
|
54
|
+
),
|
|
55
|
+
button_next: cn(
|
|
56
|
+
buttonVariants({ variant: buttonVariant }),
|
|
57
|
+
"size-(--cell-size) p-0 select-none aria-disabled:opacity-50",
|
|
58
|
+
defaultClassNames.button_next
|
|
59
|
+
),
|
|
60
|
+
month_caption: cn(
|
|
61
|
+
"flex h-(--cell-size) w-full items-center justify-center px-(--cell-size)",
|
|
62
|
+
defaultClassNames.month_caption
|
|
63
|
+
),
|
|
64
|
+
dropdowns: cn(
|
|
65
|
+
"flex h-(--cell-size) w-full items-center justify-center gap-1.5 text-sm font-medium",
|
|
66
|
+
defaultClassNames.dropdowns
|
|
67
|
+
),
|
|
68
|
+
dropdown_root: cn(
|
|
69
|
+
"relative rounded-(--cell-radius)",
|
|
70
|
+
defaultClassNames.dropdown_root
|
|
71
|
+
),
|
|
72
|
+
dropdown: cn(
|
|
73
|
+
"absolute inset-0 bg-popover opacity-0",
|
|
74
|
+
defaultClassNames.dropdown
|
|
75
|
+
),
|
|
76
|
+
caption_label: cn(
|
|
77
|
+
"font-medium select-none",
|
|
78
|
+
captionLayout === "label" ? "text-sm" : "flex items-center gap-1 rounded-(--cell-radius) text-sm [&>svg]:size-3.5 [&>svg]:text-muted-foreground",
|
|
79
|
+
defaultClassNames.caption_label
|
|
80
|
+
),
|
|
81
|
+
month_grid: cn("w-full border-collapse", defaultClassNames.month_grid),
|
|
82
|
+
weekdays: cn("flex", defaultClassNames.weekdays),
|
|
83
|
+
weekday: cn(
|
|
84
|
+
"flex-1 rounded-(--cell-radius) text-[0.8rem] font-normal text-muted-foreground select-none",
|
|
85
|
+
defaultClassNames.weekday
|
|
86
|
+
),
|
|
87
|
+
week: cn("mt-2 flex w-full", defaultClassNames.week),
|
|
88
|
+
week_number_header: cn(
|
|
89
|
+
"w-(--cell-size) select-none",
|
|
90
|
+
defaultClassNames.week_number_header
|
|
91
|
+
),
|
|
92
|
+
week_number: cn(
|
|
93
|
+
"text-[0.8rem] text-muted-foreground select-none",
|
|
94
|
+
defaultClassNames.week_number
|
|
95
|
+
),
|
|
96
|
+
day: cn(
|
|
97
|
+
"group/day relative aspect-square h-full w-full rounded-(--cell-radius) p-0 text-center select-none [&:last-child[data-selected=true]_button]:rounded-r-(--cell-radius)",
|
|
98
|
+
props.showWeekNumber ? "[&:nth-child(2)[data-selected=true]_button]:rounded-l-(--cell-radius)" : "[&:first-child[data-selected=true]_button]:rounded-l-(--cell-radius)",
|
|
99
|
+
defaultClassNames.day
|
|
100
|
+
),
|
|
101
|
+
range_start: cn(
|
|
102
|
+
"relative isolate z-0 rounded-l-(--cell-radius) bg-muted after:absolute after:inset-y-0 after:right-0 after:w-4 after:bg-muted",
|
|
103
|
+
defaultClassNames.range_start
|
|
104
|
+
),
|
|
105
|
+
range_middle: cn("rounded-none", defaultClassNames.range_middle),
|
|
106
|
+
range_end: cn(
|
|
107
|
+
"relative isolate z-0 rounded-r-(--cell-radius) bg-muted after:absolute after:inset-y-0 after:left-0 after:w-4 after:bg-muted",
|
|
108
|
+
defaultClassNames.range_end
|
|
109
|
+
),
|
|
110
|
+
today: cn(
|
|
111
|
+
"rounded-(--cell-radius) bg-muted text-foreground data-[selected=true]:rounded-none",
|
|
112
|
+
defaultClassNames.today
|
|
113
|
+
),
|
|
114
|
+
outside: cn(
|
|
115
|
+
"text-muted-foreground aria-selected:text-muted-foreground",
|
|
116
|
+
defaultClassNames.outside
|
|
117
|
+
),
|
|
118
|
+
disabled: cn(
|
|
119
|
+
"text-muted-foreground opacity-50",
|
|
120
|
+
defaultClassNames.disabled
|
|
121
|
+
),
|
|
122
|
+
hidden: cn("invisible", defaultClassNames.hidden),
|
|
123
|
+
...classNames
|
|
124
|
+
},
|
|
125
|
+
components: {
|
|
126
|
+
Root: ({ className: className2, rootRef, ...props2 }) => {
|
|
127
|
+
return /* @__PURE__ */ jsx(
|
|
128
|
+
"div",
|
|
129
|
+
{
|
|
130
|
+
"data-slot": "calendar",
|
|
131
|
+
ref: rootRef,
|
|
132
|
+
className: cn(className2),
|
|
133
|
+
...props2
|
|
134
|
+
}
|
|
135
|
+
);
|
|
136
|
+
},
|
|
137
|
+
Chevron: ({ className: className2, orientation, ...props2 }) => {
|
|
138
|
+
if (orientation === "left") {
|
|
139
|
+
return /* @__PURE__ */ jsx(ChevronLeftIcon, { className: cn("size-4", className2), ...props2 });
|
|
140
|
+
}
|
|
141
|
+
if (orientation === "right") {
|
|
142
|
+
return /* @__PURE__ */ jsx(ChevronRightIcon, { className: cn("size-4", className2), ...props2 });
|
|
143
|
+
}
|
|
144
|
+
return /* @__PURE__ */ jsx(ChevronDownIcon, { className: cn("size-4", className2), ...props2 });
|
|
145
|
+
},
|
|
146
|
+
DayButton: ({ ...props2 }) => /* @__PURE__ */ jsx(CalendarDayButton, { locale, ...props2 }),
|
|
147
|
+
WeekNumber: ({ children, ...props2 }) => {
|
|
148
|
+
return /* @__PURE__ */ jsx("td", { ...props2, children: /* @__PURE__ */ jsx("div", { className: "flex size-(--cell-size) items-center justify-center text-center", children }) });
|
|
149
|
+
},
|
|
150
|
+
...components
|
|
151
|
+
},
|
|
152
|
+
...props
|
|
153
|
+
}
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
function CalendarDayButton({
|
|
157
|
+
className,
|
|
158
|
+
day,
|
|
159
|
+
modifiers,
|
|
160
|
+
locale,
|
|
161
|
+
...props
|
|
162
|
+
}) {
|
|
163
|
+
const defaultClassNames = getDefaultClassNames();
|
|
164
|
+
const ref = React.useRef(null);
|
|
165
|
+
React.useEffect(() => {
|
|
166
|
+
if (modifiers.focused) ref.current?.focus();
|
|
167
|
+
}, [modifiers.focused]);
|
|
168
|
+
return /* @__PURE__ */ jsx(
|
|
169
|
+
Button,
|
|
170
|
+
{
|
|
171
|
+
variant: "ghost",
|
|
172
|
+
size: "icon",
|
|
173
|
+
"data-day": day.date.toLocaleDateString(locale?.code),
|
|
174
|
+
"data-selected-single": modifiers.selected && !modifiers.range_start && !modifiers.range_end && !modifiers.range_middle,
|
|
175
|
+
"data-range-start": modifiers.range_start,
|
|
176
|
+
"data-range-end": modifiers.range_end,
|
|
177
|
+
"data-range-middle": modifiers.range_middle,
|
|
178
|
+
className: cn(
|
|
179
|
+
"relative isolate z-(--ds-z-raised) flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 border-0 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-(--ds-z-raised) group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-(length:--ds-ring-width) group-data-[focused=true]/day:ring-ring/50 data-[range-end=true]:rounded-(--cell-radius) data-[range-end=true]:rounded-r-(--cell-radius) data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground data-[range-middle=true]:rounded-none data-[range-middle=true]:bg-muted data-[range-middle=true]:text-foreground data-[range-start=true]:rounded-(--cell-radius) data-[range-start=true]:rounded-l-(--cell-radius) data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground dark:hover:text-foreground [&>span]:text-xs [&>span]:opacity-70",
|
|
180
|
+
defaultClassNames.day,
|
|
181
|
+
className
|
|
182
|
+
),
|
|
183
|
+
...props
|
|
184
|
+
}
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
export {
|
|
188
|
+
Calendar,
|
|
189
|
+
CalendarDayButton
|
|
190
|
+
};
|
package/dist/ui/card.js
CHANGED
|
@@ -11,7 +11,7 @@ function Card({
|
|
|
11
11
|
"data-slot": "card",
|
|
12
12
|
"data-size": size,
|
|
13
13
|
className: cn(
|
|
14
|
-
"group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl border bg-card py-(--card-spacing) text-sm text-card-foreground shadow-card transition-shadow hover:shadow-card-hover
|
|
14
|
+
"group/card flex flex-col gap-(--ds-card-spacing) overflow-hidden rounded-xl border bg-card py-(--ds-card-spacing) text-sm text-card-foreground shadow-card transition-shadow hover:shadow-card-hover has-[>img:first-child]:pt-0 data-[size=sm]:[--ds-card-spacing:var(--ds-card-spacing-sm)] *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",
|
|
15
15
|
className
|
|
16
16
|
),
|
|
17
17
|
...props
|
|
@@ -24,7 +24,7 @@ function CardHeader({ className, ...props }) {
|
|
|
24
24
|
{
|
|
25
25
|
"data-slot": "card-header",
|
|
26
26
|
className: cn(
|
|
27
|
-
"group/card-header @container/card-header grid auto-rows-min items-start gap-2 rounded-t-xl px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)",
|
|
27
|
+
"group/card-header @container/card-header grid auto-rows-min items-start gap-2 rounded-t-xl px-(--ds-card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--ds-card-spacing)",
|
|
28
28
|
className
|
|
29
29
|
),
|
|
30
30
|
...props
|
|
@@ -69,7 +69,7 @@ function CardContent({ className, ...props }) {
|
|
|
69
69
|
"div",
|
|
70
70
|
{
|
|
71
71
|
"data-slot": "card-content",
|
|
72
|
-
className: cn("px-(--card-spacing)", className),
|
|
72
|
+
className: cn("px-(--ds-card-spacing)", className),
|
|
73
73
|
...props
|
|
74
74
|
}
|
|
75
75
|
);
|
|
@@ -80,7 +80,7 @@ function CardFooter({ className, ...props }) {
|
|
|
80
80
|
{
|
|
81
81
|
"data-slot": "card-footer",
|
|
82
82
|
className: cn(
|
|
83
|
-
"flex items-center rounded-b-xl px-(--card-spacing) [.border-t]:pt-(--card-spacing)",
|
|
83
|
+
"flex items-center rounded-b-xl px-(--ds-card-spacing) [.border-t]:pt-(--ds-card-spacing)",
|
|
84
84
|
className
|
|
85
85
|
),
|
|
86
86
|
...props
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import useEmblaCarousel, { UseEmblaCarouselType } from 'embla-carousel-react';
|
|
3
|
+
import { Button } from './button.js';
|
|
4
|
+
import 'class-variance-authority/types';
|
|
5
|
+
import '@base-ui/react/use-render';
|
|
6
|
+
import 'class-variance-authority';
|
|
7
|
+
|
|
8
|
+
type CarouselApi = UseEmblaCarouselType[1];
|
|
9
|
+
type UseCarouselParameters = Parameters<typeof useEmblaCarousel>;
|
|
10
|
+
type CarouselOptions = UseCarouselParameters[0];
|
|
11
|
+
type CarouselPlugin = UseCarouselParameters[1];
|
|
12
|
+
type CarouselProps = {
|
|
13
|
+
opts?: CarouselOptions;
|
|
14
|
+
plugins?: CarouselPlugin;
|
|
15
|
+
orientation?: "horizontal" | "vertical";
|
|
16
|
+
setApi?: (api: CarouselApi) => void;
|
|
17
|
+
};
|
|
18
|
+
type CarouselContextProps = {
|
|
19
|
+
carouselRef: ReturnType<typeof useEmblaCarousel>[0];
|
|
20
|
+
api: ReturnType<typeof useEmblaCarousel>[1];
|
|
21
|
+
scrollPrev: () => void;
|
|
22
|
+
scrollNext: () => void;
|
|
23
|
+
canScrollPrev: boolean;
|
|
24
|
+
canScrollNext: boolean;
|
|
25
|
+
} & CarouselProps;
|
|
26
|
+
declare function useCarousel(): CarouselContextProps;
|
|
27
|
+
declare function Carousel({ orientation, opts, setApi, plugins, className, children, ...props }: React.ComponentProps<"div"> & CarouselProps): React.JSX.Element;
|
|
28
|
+
declare function CarouselContent({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
29
|
+
declare function CarouselItem({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
30
|
+
declare function CarouselPrevious({ className, variant, size, ...props }: React.ComponentProps<typeof Button>): React.JSX.Element;
|
|
31
|
+
declare function CarouselNext({ className, variant, size, ...props }: React.ComponentProps<typeof Button>): React.JSX.Element;
|
|
32
|
+
|
|
33
|
+
export { Carousel, type CarouselApi, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, useCarousel };
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { cn } from "../lib/utils";
|
|
4
|
+
import useEmblaCarousel from "embla-carousel-react";
|
|
5
|
+
import { Button } from "./button";
|
|
6
|
+
import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
|
|
7
|
+
const CarouselContext = React.createContext(null);
|
|
8
|
+
function useCarousel() {
|
|
9
|
+
const context = React.useContext(CarouselContext);
|
|
10
|
+
if (!context) {
|
|
11
|
+
throw new Error("useCarousel must be used within a <Carousel />");
|
|
12
|
+
}
|
|
13
|
+
return context;
|
|
14
|
+
}
|
|
15
|
+
function Carousel({
|
|
16
|
+
orientation = "horizontal",
|
|
17
|
+
opts,
|
|
18
|
+
setApi,
|
|
19
|
+
plugins,
|
|
20
|
+
className,
|
|
21
|
+
children,
|
|
22
|
+
...props
|
|
23
|
+
}) {
|
|
24
|
+
const [carouselRef, api] = useEmblaCarousel(
|
|
25
|
+
{
|
|
26
|
+
...opts,
|
|
27
|
+
axis: orientation === "horizontal" ? "x" : "y"
|
|
28
|
+
},
|
|
29
|
+
plugins
|
|
30
|
+
);
|
|
31
|
+
const [canScrollPrev, setCanScrollPrev] = React.useState(false);
|
|
32
|
+
const [canScrollNext, setCanScrollNext] = React.useState(false);
|
|
33
|
+
const onSelect = React.useCallback((api2) => {
|
|
34
|
+
if (!api2) return;
|
|
35
|
+
setCanScrollPrev(api2.canScrollPrev());
|
|
36
|
+
setCanScrollNext(api2.canScrollNext());
|
|
37
|
+
}, []);
|
|
38
|
+
const scrollPrev = React.useCallback(() => {
|
|
39
|
+
api?.scrollPrev();
|
|
40
|
+
}, [api]);
|
|
41
|
+
const scrollNext = React.useCallback(() => {
|
|
42
|
+
api?.scrollNext();
|
|
43
|
+
}, [api]);
|
|
44
|
+
const handleKeyDown = React.useCallback(
|
|
45
|
+
(event) => {
|
|
46
|
+
if (event.key === "ArrowLeft") {
|
|
47
|
+
event.preventDefault();
|
|
48
|
+
scrollPrev();
|
|
49
|
+
} else if (event.key === "ArrowRight") {
|
|
50
|
+
event.preventDefault();
|
|
51
|
+
scrollNext();
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
[scrollPrev, scrollNext]
|
|
55
|
+
);
|
|
56
|
+
React.useEffect(() => {
|
|
57
|
+
if (!api || !setApi) return;
|
|
58
|
+
setApi(api);
|
|
59
|
+
}, [api, setApi]);
|
|
60
|
+
React.useEffect(() => {
|
|
61
|
+
if (!api) return;
|
|
62
|
+
onSelect(api);
|
|
63
|
+
api.on("reInit", onSelect);
|
|
64
|
+
api.on("select", onSelect);
|
|
65
|
+
return () => {
|
|
66
|
+
api?.off("select", onSelect);
|
|
67
|
+
};
|
|
68
|
+
}, [api, onSelect]);
|
|
69
|
+
return /* @__PURE__ */ jsx(
|
|
70
|
+
CarouselContext.Provider,
|
|
71
|
+
{
|
|
72
|
+
value: {
|
|
73
|
+
carouselRef,
|
|
74
|
+
api,
|
|
75
|
+
opts,
|
|
76
|
+
orientation: orientation || (opts?.axis === "y" ? "vertical" : "horizontal"),
|
|
77
|
+
scrollPrev,
|
|
78
|
+
scrollNext,
|
|
79
|
+
canScrollPrev,
|
|
80
|
+
canScrollNext
|
|
81
|
+
},
|
|
82
|
+
children: /* @__PURE__ */ jsx(
|
|
83
|
+
"div",
|
|
84
|
+
{
|
|
85
|
+
onKeyDownCapture: handleKeyDown,
|
|
86
|
+
className: cn("relative", className),
|
|
87
|
+
role: "region",
|
|
88
|
+
"aria-roledescription": "carousel",
|
|
89
|
+
"data-slot": "carousel",
|
|
90
|
+
...props,
|
|
91
|
+
children
|
|
92
|
+
}
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
function CarouselContent({ className, ...props }) {
|
|
98
|
+
const { carouselRef, orientation } = useCarousel();
|
|
99
|
+
return /* @__PURE__ */ jsx(
|
|
100
|
+
"div",
|
|
101
|
+
{
|
|
102
|
+
ref: carouselRef,
|
|
103
|
+
className: "overflow-hidden",
|
|
104
|
+
"data-slot": "carousel-content",
|
|
105
|
+
children: /* @__PURE__ */ jsx(
|
|
106
|
+
"div",
|
|
107
|
+
{
|
|
108
|
+
className: cn(
|
|
109
|
+
"flex",
|
|
110
|
+
orientation === "horizontal" ? "-ml-4" : "-mt-4 flex-col",
|
|
111
|
+
className
|
|
112
|
+
),
|
|
113
|
+
...props
|
|
114
|
+
}
|
|
115
|
+
)
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
function CarouselItem({ className, ...props }) {
|
|
120
|
+
const { orientation } = useCarousel();
|
|
121
|
+
return /* @__PURE__ */ jsx(
|
|
122
|
+
"div",
|
|
123
|
+
{
|
|
124
|
+
role: "group",
|
|
125
|
+
"aria-roledescription": "slide",
|
|
126
|
+
"data-slot": "carousel-item",
|
|
127
|
+
className: cn(
|
|
128
|
+
"min-w-0 shrink-0 grow-0 basis-full",
|
|
129
|
+
orientation === "horizontal" ? "pl-4" : "pt-4",
|
|
130
|
+
className
|
|
131
|
+
),
|
|
132
|
+
...props
|
|
133
|
+
}
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
function CarouselPrevious({
|
|
137
|
+
className,
|
|
138
|
+
variant = "outline",
|
|
139
|
+
size = "icon-sm",
|
|
140
|
+
...props
|
|
141
|
+
}) {
|
|
142
|
+
const { orientation, scrollPrev, canScrollPrev } = useCarousel();
|
|
143
|
+
return /* @__PURE__ */ jsxs(
|
|
144
|
+
Button,
|
|
145
|
+
{
|
|
146
|
+
"data-slot": "carousel-previous",
|
|
147
|
+
variant,
|
|
148
|
+
size,
|
|
149
|
+
className: cn(
|
|
150
|
+
"absolute touch-manipulation rounded-full",
|
|
151
|
+
orientation === "horizontal" ? "inset-y-0 -left-12 my-auto" : "-top-12 left-1/2 -translate-x-1/2 rotate-90",
|
|
152
|
+
className
|
|
153
|
+
),
|
|
154
|
+
disabled: !canScrollPrev,
|
|
155
|
+
onClick: scrollPrev,
|
|
156
|
+
...props,
|
|
157
|
+
children: [
|
|
158
|
+
/* @__PURE__ */ jsx(ChevronLeftIcon, {}),
|
|
159
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Previous slide" })
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
function CarouselNext({
|
|
165
|
+
className,
|
|
166
|
+
variant = "outline",
|
|
167
|
+
size = "icon-sm",
|
|
168
|
+
...props
|
|
169
|
+
}) {
|
|
170
|
+
const { orientation, scrollNext, canScrollNext } = useCarousel();
|
|
171
|
+
return /* @__PURE__ */ jsxs(
|
|
172
|
+
Button,
|
|
173
|
+
{
|
|
174
|
+
"data-slot": "carousel-next",
|
|
175
|
+
variant,
|
|
176
|
+
size,
|
|
177
|
+
className: cn(
|
|
178
|
+
"absolute touch-manipulation rounded-full",
|
|
179
|
+
orientation === "horizontal" ? "inset-y-0 -right-12 my-auto" : "-bottom-12 left-1/2 -translate-x-1/2 rotate-90",
|
|
180
|
+
className
|
|
181
|
+
),
|
|
182
|
+
disabled: !canScrollNext,
|
|
183
|
+
onClick: scrollNext,
|
|
184
|
+
...props,
|
|
185
|
+
children: [
|
|
186
|
+
/* @__PURE__ */ jsx(ChevronRightIcon, {}),
|
|
187
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Next slide" })
|
|
188
|
+
]
|
|
189
|
+
}
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
export {
|
|
193
|
+
Carousel,
|
|
194
|
+
CarouselContent,
|
|
195
|
+
CarouselItem,
|
|
196
|
+
CarouselNext,
|
|
197
|
+
CarouselPrevious,
|
|
198
|
+
useCarousel
|
|
199
|
+
};
|
package/dist/ui/checkbox.js
CHANGED
|
@@ -9,7 +9,7 @@ function Checkbox({ className, ...props }) {
|
|
|
9
9
|
{
|
|
10
10
|
"data-slot": "checkbox",
|
|
11
11
|
className: cn(
|
|
12
|
-
"peer relative flex size-4 shrink-0 items-center justify-center rounded-[6px] border border-input transition-shadow outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-(length:--ring-width) focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-(length:--ring-width) aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary",
|
|
12
|
+
"peer relative flex size-4 shrink-0 items-center justify-center rounded-[6px] border border-input transition-shadow outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-(length:--ds-ring-width) focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-(length:--ds-ring-width) aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary",
|
|
13
13
|
className
|
|
14
14
|
),
|
|
15
15
|
...props,
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Combobox as Combobox$1 } from '@base-ui/react';
|
|
3
|
+
|
|
4
|
+
declare const Combobox: typeof Combobox$1.Root;
|
|
5
|
+
declare function ComboboxValue({ ...props }: Combobox$1.Value.Props): React.JSX.Element;
|
|
6
|
+
declare function ComboboxTrigger({ className, children, ...props }: Combobox$1.Trigger.Props): React.JSX.Element;
|
|
7
|
+
declare function ComboboxInput({ className, children, disabled, showTrigger, showClear, ...props }: Combobox$1.Input.Props & {
|
|
8
|
+
showTrigger?: boolean;
|
|
9
|
+
showClear?: boolean;
|
|
10
|
+
}): React.JSX.Element;
|
|
11
|
+
declare function ComboboxContent({ className, side, sideOffset, align, alignOffset, anchor, ...props }: Combobox$1.Popup.Props & Pick<Combobox$1.Positioner.Props, "side" | "align" | "sideOffset" | "alignOffset" | "anchor">): React.JSX.Element;
|
|
12
|
+
declare function ComboboxList({ className, ...props }: Combobox$1.List.Props): React.JSX.Element;
|
|
13
|
+
declare function ComboboxItem({ className, children, ...props }: Combobox$1.Item.Props): React.JSX.Element;
|
|
14
|
+
declare function ComboboxGroup({ className, ...props }: Combobox$1.Group.Props): React.JSX.Element;
|
|
15
|
+
declare function ComboboxLabel({ className, ...props }: Combobox$1.GroupLabel.Props): React.JSX.Element;
|
|
16
|
+
declare function ComboboxCollection({ ...props }: Combobox$1.Collection.Props): React.JSX.Element;
|
|
17
|
+
declare function ComboboxEmpty({ className, ...props }: Combobox$1.Empty.Props): React.JSX.Element;
|
|
18
|
+
declare function ComboboxSeparator({ className, ...props }: Combobox$1.Separator.Props): React.JSX.Element;
|
|
19
|
+
declare function ComboboxChips({ className, ...props }: React.ComponentPropsWithRef<typeof Combobox$1.Chips> & Combobox$1.Chips.Props): React.JSX.Element;
|
|
20
|
+
declare function ComboboxChip({ className, children, showRemove, ...props }: Combobox$1.Chip.Props & {
|
|
21
|
+
showRemove?: boolean;
|
|
22
|
+
}): React.JSX.Element;
|
|
23
|
+
declare function ComboboxChipsInput({ className, ...props }: Combobox$1.Input.Props): React.JSX.Element;
|
|
24
|
+
declare function useComboboxAnchor(): React.RefObject<HTMLDivElement | null>;
|
|
25
|
+
|
|
26
|
+
export { Combobox, ComboboxChip, ComboboxChips, ComboboxChipsInput, ComboboxCollection, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxLabel, ComboboxList, ComboboxSeparator, ComboboxTrigger, ComboboxValue, useComboboxAnchor };
|