@web-my-money/primitives 1.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.
- package/dist/accordion/index.d.mts +9 -0
- package/dist/accordion/index.d.ts +9 -0
- package/dist/accordion/index.js +99 -0
- package/dist/accordion/index.mjs +14 -0
- package/dist/alert-dialog/index.d.mts +22 -0
- package/dist/alert-dialog/index.d.ts +22 -0
- package/dist/alert-dialog/index.js +206 -0
- package/dist/alert-dialog/index.mjs +29 -0
- package/dist/avatar/index.d.mts +23 -0
- package/dist/avatar/index.d.ts +23 -0
- package/dist/avatar/index.js +133 -0
- package/dist/avatar/index.mjs +10 -0
- package/dist/badge/index.d.mts +15 -0
- package/dist/badge/index.d.ts +15 -0
- package/dist/badge/index.js +96 -0
- package/dist/badge/index.mjs +10 -0
- package/dist/breadcrumb/index.d.mts +20 -0
- package/dist/breadcrumb/index.d.ts +20 -0
- package/dist/breadcrumb/index.js +126 -0
- package/dist/breadcrumb/index.mjs +20 -0
- package/dist/button/index.d.mts +12 -0
- package/dist/button/index.d.ts +12 -0
- package/dist/button/index.js +88 -0
- package/dist/button/index.mjs +10 -0
- package/dist/calendar/index.d.mts +29 -0
- package/dist/calendar/index.d.ts +29 -0
- package/dist/calendar/index.js +191 -0
- package/dist/calendar/index.mjs +9 -0
- package/dist/card/index.d.mts +13 -0
- package/dist/card/index.d.ts +13 -0
- package/dist/card/index.js +141 -0
- package/dist/card/index.mjs +19 -0
- package/dist/carousel/index.d.mts +20 -0
- package/dist/carousel/index.d.ts +20 -0
- package/dist/carousel/index.js +236 -0
- package/dist/carousel/index.mjs +19 -0
- package/dist/checkbox/index.d.mts +6 -0
- package/dist/checkbox/index.d.ts +6 -0
- package/dist/checkbox/index.js +63 -0
- package/dist/checkbox/index.mjs +8 -0
- package/dist/chunk-32LEHNCH.mjs +155 -0
- package/dist/chunk-3ZJ4L43B.mjs +92 -0
- package/dist/chunk-4KQNZMKT.mjs +47 -0
- package/dist/chunk-4W6U222X.mjs +113 -0
- package/dist/chunk-556SM2PJ.mjs +40 -0
- package/dist/chunk-5LYTCNI6.mjs +127 -0
- package/dist/chunk-5N7LGYZK.mjs +137 -0
- package/dist/chunk-6OG237U6.mjs +54 -0
- package/dist/chunk-7TMIJ7HZ.mjs +149 -0
- package/dist/chunk-DTENOVQN.mjs +44 -0
- package/dist/chunk-DUGW62XX.mjs +143 -0
- package/dist/chunk-DWLKKYIU.mjs +156 -0
- package/dist/chunk-DYCSGLM5.mjs +32 -0
- package/dist/chunk-DZPJV6MN.mjs +66 -0
- package/dist/chunk-FT72MNAV.mjs +25 -0
- package/dist/chunk-FV6JTZAK.mjs +30 -0
- package/dist/chunk-GLD4KQD3.mjs +90 -0
- package/dist/chunk-GWVW5OI6.mjs +106 -0
- package/dist/chunk-JWCA4M7E.mjs +160 -0
- package/dist/chunk-K4UYYX45.mjs +199 -0
- package/dist/chunk-KVQKOJNU.mjs +52 -0
- package/dist/chunk-LPMRBQLR.mjs +120 -0
- package/dist/chunk-M6HSM6GV.mjs +68 -0
- package/dist/chunk-NE5LEVMC.mjs +201 -0
- package/dist/chunk-NGWDLZ6E.mjs +33 -0
- package/dist/chunk-NH5ZVHAV.mjs +36 -0
- package/dist/chunk-PFXSPRVI.mjs +65 -0
- package/dist/chunk-PJO7WJ4G.mjs +10 -0
- package/dist/chunk-PTXZWR7Y.mjs +76 -0
- package/dist/chunk-SG747CBC.mjs +34 -0
- package/dist/chunk-UDQDW22Y.mjs +71 -0
- package/dist/chunk-UGOA6M4S.mjs +120 -0
- package/dist/chunk-UXU54FBX.mjs +63 -0
- package/dist/chunk-WYBX5VJ4.mjs +49 -0
- package/dist/chunk-Y7DNVOKO.mjs +57 -0
- package/dist/chunk-YNOS3JA2.mjs +29 -0
- package/dist/chunk-YPTARV3T.mjs +57 -0
- package/dist/chunk-YYFQVSPV.mjs +17 -0
- package/dist/chunk-ZR3J34NX.mjs +85 -0
- package/dist/collapsible/index.d.mts +8 -0
- package/dist/collapsible/index.d.ts +8 -0
- package/dist/collapsible/index.js +64 -0
- package/dist/collapsible/index.mjs +12 -0
- package/dist/combobox/index.d.mts +18 -0
- package/dist/combobox/index.d.ts +18 -0
- package/dist/combobox/index.js +198 -0
- package/dist/combobox/index.mjs +32 -0
- package/dist/context-menu/index.d.mts +16 -0
- package/dist/context-menu/index.d.ts +16 -0
- package/dist/context-menu/index.js +177 -0
- package/dist/context-menu/index.mjs +28 -0
- package/dist/date-range-input/index.d.mts +17 -0
- package/dist/date-range-input/index.d.ts +17 -0
- package/dist/date-range-input/index.js +284 -0
- package/dist/date-range-input/index.mjs +11 -0
- package/dist/dialog/index.d.mts +19 -0
- package/dist/dialog/index.d.ts +19 -0
- package/dist/dialog/index.js +240 -0
- package/dist/dialog/index.mjs +27 -0
- package/dist/dropdown-menu/index.d.mts +16 -0
- package/dist/dropdown-menu/index.d.ts +16 -0
- package/dist/dropdown-menu/index.js +189 -0
- package/dist/dropdown-menu/index.mjs +28 -0
- package/dist/field/index.d.mts +24 -0
- package/dist/field/index.d.ts +24 -0
- package/dist/field/index.js +88 -0
- package/dist/field/index.mjs +16 -0
- package/dist/hover-card/index.d.mts +8 -0
- package/dist/hover-card/index.d.ts +8 -0
- package/dist/hover-card/index.js +79 -0
- package/dist/hover-card/index.mjs +12 -0
- package/dist/index.d.mts +73 -0
- package/dist/index.d.ts +73 -0
- package/dist/index.js +3167 -0
- package/dist/index.mjs +452 -0
- package/dist/input/index.d.mts +5 -0
- package/dist/input/index.d.ts +5 -0
- package/dist/input/index.js +54 -0
- package/dist/input/index.mjs +7 -0
- package/dist/kbd/index.d.mts +8 -0
- package/dist/kbd/index.d.ts +8 -0
- package/dist/kbd/index.js +64 -0
- package/dist/kbd/index.mjs +9 -0
- package/dist/lightbox/index.d.mts +17 -0
- package/dist/lightbox/index.d.ts +17 -0
- package/dist/lightbox/index.js +151 -0
- package/dist/lightbox/index.mjs +24 -0
- package/dist/pagination/index.d.mts +33 -0
- package/dist/pagination/index.d.ts +33 -0
- package/dist/pagination/index.js +212 -0
- package/dist/pagination/index.mjs +25 -0
- package/dist/popover/index.d.mts +11 -0
- package/dist/popover/index.d.ts +11 -0
- package/dist/popover/index.js +120 -0
- package/dist/popover/index.mjs +18 -0
- package/dist/progress/index.d.mts +6 -0
- package/dist/progress/index.d.ts +6 -0
- package/dist/progress/index.js +60 -0
- package/dist/progress/index.mjs +8 -0
- package/dist/radio-group/index.d.mts +8 -0
- package/dist/radio-group/index.d.ts +8 -0
- package/dist/radio-group/index.js +71 -0
- package/dist/radio-group/index.mjs +10 -0
- package/dist/resizable/index.d.mts +10 -0
- package/dist/resizable/index.d.ts +10 -0
- package/dist/resizable/index.js +80 -0
- package/dist/resizable/index.mjs +12 -0
- package/dist/scroll-area/index.d.mts +6 -0
- package/dist/scroll-area/index.d.ts +6 -0
- package/dist/scroll-area/index.js +74 -0
- package/dist/scroll-area/index.mjs +8 -0
- package/dist/select/index.d.mts +17 -0
- package/dist/select/index.d.ts +17 -0
- package/dist/select/index.js +238 -0
- package/dist/select/index.mjs +26 -0
- package/dist/separator/index.d.mts +6 -0
- package/dist/separator/index.d.ts +6 -0
- package/dist/separator/index.js +59 -0
- package/dist/separator/index.mjs +8 -0
- package/dist/sheet/index.d.mts +38 -0
- package/dist/sheet/index.d.ts +38 -0
- package/dist/sheet/index.js +212 -0
- package/dist/sheet/index.mjs +27 -0
- package/dist/skeleton/index.d.mts +17 -0
- package/dist/skeleton/index.d.ts +17 -0
- package/dist/skeleton/index.js +80 -0
- package/dist/skeleton/index.mjs +11 -0
- package/dist/slide-over/index.d.mts +92 -0
- package/dist/slide-over/index.d.ts +92 -0
- package/dist/slide-over/index.js +298 -0
- package/dist/slide-over/index.mjs +31 -0
- package/dist/slider/index.d.mts +6 -0
- package/dist/slider/index.d.ts +6 -0
- package/dist/slider/index.js +47 -0
- package/dist/slider/index.mjs +8 -0
- package/dist/switch/index.d.mts +8 -0
- package/dist/switch/index.d.ts +8 -0
- package/dist/switch/index.js +66 -0
- package/dist/switch/index.mjs +8 -0
- package/dist/tabs/index.d.mts +9 -0
- package/dist/tabs/index.d.ts +9 -0
- package/dist/tabs/index.js +96 -0
- package/dist/tabs/index.mjs +14 -0
- package/dist/toast/index.d.mts +19 -0
- package/dist/toast/index.d.ts +19 -0
- package/dist/toast/index.js +107 -0
- package/dist/toast/index.mjs +10 -0
- package/dist/toggle/index.d.mts +14 -0
- package/dist/toggle/index.d.ts +14 -0
- package/dist/toggle/index.js +89 -0
- package/dist/toggle/index.mjs +12 -0
- package/dist/tooltip/index.d.mts +9 -0
- package/dist/tooltip/index.d.ts +9 -0
- package/dist/tooltip/index.js +101 -0
- package/dist/tooltip/index.mjs +14 -0
- package/package.json +235 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// src/calendar/index.tsx
|
|
32
|
+
var calendar_exports = {};
|
|
33
|
+
__export(calendar_exports, {
|
|
34
|
+
Calendar: () => Calendar
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(calendar_exports);
|
|
37
|
+
var React = __toESM(require("react"));
|
|
38
|
+
var import_lucide_react = require("lucide-react");
|
|
39
|
+
|
|
40
|
+
// src/utils.ts
|
|
41
|
+
var import_clsx = require("clsx");
|
|
42
|
+
var import_tailwind_merge = require("tailwind-merge");
|
|
43
|
+
function cn(...inputs) {
|
|
44
|
+
return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// src/button/index.tsx
|
|
48
|
+
var import_button = require("@base-ui/react/button");
|
|
49
|
+
var import_class_variance_authority = require("class-variance-authority");
|
|
50
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
51
|
+
var buttonVariants = (0, import_class_variance_authority.cva)(
|
|
52
|
+
"group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
53
|
+
{
|
|
54
|
+
variants: {
|
|
55
|
+
variant: {
|
|
56
|
+
default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
|
|
57
|
+
outline: "border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
|
|
58
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
|
|
59
|
+
ghost: "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
|
|
60
|
+
destructive: "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
|
|
61
|
+
link: "text-primary underline-offset-4 hover:underline"
|
|
62
|
+
},
|
|
63
|
+
size: {
|
|
64
|
+
default: "h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
65
|
+
xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
|
|
66
|
+
sm: "h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
|
|
67
|
+
lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3",
|
|
68
|
+
icon: "size-8",
|
|
69
|
+
"icon-xs": "size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
|
|
70
|
+
"icon-sm": "size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",
|
|
71
|
+
"icon-lg": "size-9"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
defaultVariants: {
|
|
75
|
+
variant: "default",
|
|
76
|
+
size: "default"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
// src/calendar/index.tsx
|
|
82
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
83
|
+
var WEEKDAY_LABELS = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
|
|
84
|
+
function startOfDay(d) {
|
|
85
|
+
return new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
|
86
|
+
}
|
|
87
|
+
function isSameDay(a, b) {
|
|
88
|
+
return !!a && !!b && startOfDay(a).getTime() === startOfDay(b).getTime();
|
|
89
|
+
}
|
|
90
|
+
function isBetween(d, from, to) {
|
|
91
|
+
if (!from || !to) return false;
|
|
92
|
+
const t = startOfDay(d).getTime();
|
|
93
|
+
return t > startOfDay(from).getTime() && t < startOfDay(to).getTime();
|
|
94
|
+
}
|
|
95
|
+
function getMonthGrid(year, month) {
|
|
96
|
+
const first = new Date(year, month, 1);
|
|
97
|
+
const gridStart = new Date(year, month, 1 - first.getDay());
|
|
98
|
+
return Array.from({ length: 42 }, (_, i) => {
|
|
99
|
+
const d = new Date(gridStart);
|
|
100
|
+
d.setDate(gridStart.getDate() + i);
|
|
101
|
+
return d;
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
function Calendar(props) {
|
|
105
|
+
const { className, minDate, maxDate, disabled } = props;
|
|
106
|
+
const [uncontrolledMonth, setUncontrolledMonth] = React.useState(
|
|
107
|
+
() => props.defaultMonth ?? props.month ?? /* @__PURE__ */ new Date()
|
|
108
|
+
);
|
|
109
|
+
const month = props.month ?? uncontrolledMonth;
|
|
110
|
+
const setMonth = (next) => {
|
|
111
|
+
setUncontrolledMonth(next);
|
|
112
|
+
props.onMonthChange?.(next);
|
|
113
|
+
};
|
|
114
|
+
const isDisabled = (d) => {
|
|
115
|
+
if (minDate && startOfDay(d) < startOfDay(minDate)) return true;
|
|
116
|
+
if (maxDate && startOfDay(d) > startOfDay(maxDate)) return true;
|
|
117
|
+
return disabled?.(d) ?? false;
|
|
118
|
+
};
|
|
119
|
+
const handleSelect = (d) => {
|
|
120
|
+
if (isDisabled(d)) return;
|
|
121
|
+
if (props.mode === "range") {
|
|
122
|
+
const current = props.selected;
|
|
123
|
+
if (!current?.from || current.from && current.to) {
|
|
124
|
+
props.onSelect?.({ from: d, to: void 0 });
|
|
125
|
+
} else if (startOfDay(d) < startOfDay(current.from)) {
|
|
126
|
+
props.onSelect?.({ from: d, to: current.from });
|
|
127
|
+
} else {
|
|
128
|
+
props.onSelect?.({ from: current.from, to: d });
|
|
129
|
+
}
|
|
130
|
+
} else {
|
|
131
|
+
props.onSelect?.(isSameDay(props.selected, d) ? void 0 : d);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
const grid = getMonthGrid(month.getFullYear(), month.getMonth());
|
|
135
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { "data-slot": "calendar", className: cn("w-fit p-2", className), children: [
|
|
136
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { "data-slot": "calendar-header", className: "flex items-center justify-between px-1 pb-2", children: [
|
|
137
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
138
|
+
"button",
|
|
139
|
+
{
|
|
140
|
+
type: "button",
|
|
141
|
+
"aria-label": "Previous month",
|
|
142
|
+
onClick: () => setMonth(new Date(month.getFullYear(), month.getMonth() - 1, 1)),
|
|
143
|
+
className: cn(buttonVariants({ variant: "ghost", size: "icon-sm" })),
|
|
144
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.ChevronLeft, { className: "size-4" })
|
|
145
|
+
}
|
|
146
|
+
),
|
|
147
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { "data-slot": "calendar-label", className: "text-sm font-medium", children: month.toLocaleDateString(void 0, { month: "long", year: "numeric" }) }),
|
|
148
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
149
|
+
"button",
|
|
150
|
+
{
|
|
151
|
+
type: "button",
|
|
152
|
+
"aria-label": "Next month",
|
|
153
|
+
onClick: () => setMonth(new Date(month.getFullYear(), month.getMonth() + 1, 1)),
|
|
154
|
+
className: cn(buttonVariants({ variant: "ghost", size: "icon-sm" })),
|
|
155
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.ChevronRight, { className: "size-4" })
|
|
156
|
+
}
|
|
157
|
+
)
|
|
158
|
+
] }),
|
|
159
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { "data-slot": "calendar-weekdays", className: "grid grid-cols-7 gap-0.5 px-1", children: WEEKDAY_LABELS.map((w) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex h-8 items-center justify-center text-xs font-medium text-muted-foreground", children: w }, w)) }),
|
|
160
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { "data-slot": "calendar-grid", className: "grid grid-cols-7 gap-0.5 px-1", children: grid.map((d) => {
|
|
161
|
+
const outsideMonth = d.getMonth() !== month.getMonth();
|
|
162
|
+
const isSelected = props.mode === "range" ? isSameDay(d, props.selected?.from) || isSameDay(d, props.selected?.to) : isSameDay(d, props.selected);
|
|
163
|
+
const inRange = props.mode === "range" && isBetween(d, props.selected?.from, props.selected?.to);
|
|
164
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
165
|
+
"button",
|
|
166
|
+
{
|
|
167
|
+
type: "button",
|
|
168
|
+
"data-slot": "calendar-day",
|
|
169
|
+
"data-selected": isSelected || void 0,
|
|
170
|
+
"data-outside-month": outsideMonth || void 0,
|
|
171
|
+
disabled: isDisabled(d),
|
|
172
|
+
"aria-label": d.toDateString(),
|
|
173
|
+
"aria-current": isSameDay(d, /* @__PURE__ */ new Date()) ? "date" : void 0,
|
|
174
|
+
onClick: () => handleSelect(d),
|
|
175
|
+
className: cn(
|
|
176
|
+
"flex h-8 w-8 items-center justify-center rounded-md text-sm transition-colors hover:bg-muted disabled:pointer-events-none disabled:opacity-40",
|
|
177
|
+
outsideMonth && "text-muted-foreground/50",
|
|
178
|
+
inRange && "rounded-none bg-primary/10",
|
|
179
|
+
isSelected && "bg-primary text-primary-foreground hover:bg-primary/90"
|
|
180
|
+
),
|
|
181
|
+
children: d.getDate()
|
|
182
|
+
},
|
|
183
|
+
d.toISOString()
|
|
184
|
+
);
|
|
185
|
+
}) })
|
|
186
|
+
] });
|
|
187
|
+
}
|
|
188
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
189
|
+
0 && (module.exports = {
|
|
190
|
+
Calendar
|
|
191
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
declare function Card({ className, size, ...props }: React.ComponentProps<"div"> & {
|
|
4
|
+
size?: "default" | "sm";
|
|
5
|
+
}): React.JSX.Element;
|
|
6
|
+
declare function CardHeader({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
7
|
+
declare function CardTitle({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
8
|
+
declare function CardDescription({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
9
|
+
declare function CardAction({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
10
|
+
declare function CardContent({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
11
|
+
declare function CardFooter({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
12
|
+
|
|
13
|
+
export { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
declare function Card({ className, size, ...props }: React.ComponentProps<"div"> & {
|
|
4
|
+
size?: "default" | "sm";
|
|
5
|
+
}): React.JSX.Element;
|
|
6
|
+
declare function CardHeader({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
7
|
+
declare function CardTitle({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
8
|
+
declare function CardDescription({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
9
|
+
declare function CardAction({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
10
|
+
declare function CardContent({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
11
|
+
declare function CardFooter({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
12
|
+
|
|
13
|
+
export { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle };
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/card/index.tsx
|
|
21
|
+
var card_exports = {};
|
|
22
|
+
__export(card_exports, {
|
|
23
|
+
Card: () => Card,
|
|
24
|
+
CardAction: () => CardAction,
|
|
25
|
+
CardContent: () => CardContent,
|
|
26
|
+
CardDescription: () => CardDescription,
|
|
27
|
+
CardFooter: () => CardFooter,
|
|
28
|
+
CardHeader: () => CardHeader,
|
|
29
|
+
CardTitle: () => CardTitle
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(card_exports);
|
|
32
|
+
|
|
33
|
+
// src/utils.ts
|
|
34
|
+
var import_clsx = require("clsx");
|
|
35
|
+
var import_tailwind_merge = require("tailwind-merge");
|
|
36
|
+
function cn(...inputs) {
|
|
37
|
+
return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// src/card/index.tsx
|
|
41
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
42
|
+
function Card({
|
|
43
|
+
className,
|
|
44
|
+
size = "default",
|
|
45
|
+
...props
|
|
46
|
+
}) {
|
|
47
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
48
|
+
"div",
|
|
49
|
+
{
|
|
50
|
+
"data-slot": "card",
|
|
51
|
+
"data-size": size,
|
|
52
|
+
className: cn(
|
|
53
|
+
"group/card flex flex-col gap-4 overflow-hidden rounded-xl bg-card py-4 text-sm text-card-foreground ring-1 ring-foreground/10 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",
|
|
54
|
+
className
|
|
55
|
+
),
|
|
56
|
+
...props
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
function CardHeader({ className, ...props }) {
|
|
61
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
62
|
+
"div",
|
|
63
|
+
{
|
|
64
|
+
"data-slot": "card-header",
|
|
65
|
+
className: cn(
|
|
66
|
+
"group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3",
|
|
67
|
+
className
|
|
68
|
+
),
|
|
69
|
+
...props
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
function CardTitle({ className, ...props }) {
|
|
74
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
75
|
+
"div",
|
|
76
|
+
{
|
|
77
|
+
"data-slot": "card-title",
|
|
78
|
+
className: cn(
|
|
79
|
+
"font-heading text-base leading-snug font-medium group-data-[size=sm]/card:text-sm",
|
|
80
|
+
className
|
|
81
|
+
),
|
|
82
|
+
...props
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
function CardDescription({ className, ...props }) {
|
|
87
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
88
|
+
"div",
|
|
89
|
+
{
|
|
90
|
+
"data-slot": "card-description",
|
|
91
|
+
className: cn("text-sm text-muted-foreground", className),
|
|
92
|
+
...props
|
|
93
|
+
}
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
function CardAction({ className, ...props }) {
|
|
97
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
98
|
+
"div",
|
|
99
|
+
{
|
|
100
|
+
"data-slot": "card-action",
|
|
101
|
+
className: cn(
|
|
102
|
+
"col-start-2 row-span-2 row-start-1 self-start justify-self-end",
|
|
103
|
+
className
|
|
104
|
+
),
|
|
105
|
+
...props
|
|
106
|
+
}
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
function CardContent({ className, ...props }) {
|
|
110
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
111
|
+
"div",
|
|
112
|
+
{
|
|
113
|
+
"data-slot": "card-content",
|
|
114
|
+
className: cn("px-4 group-data-[size=sm]/card:px-3", className),
|
|
115
|
+
...props
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
function CardFooter({ className, ...props }) {
|
|
120
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
121
|
+
"div",
|
|
122
|
+
{
|
|
123
|
+
"data-slot": "card-footer",
|
|
124
|
+
className: cn(
|
|
125
|
+
"flex items-center rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/card:p-3",
|
|
126
|
+
className
|
|
127
|
+
),
|
|
128
|
+
...props
|
|
129
|
+
}
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
133
|
+
0 && (module.exports = {
|
|
134
|
+
Card,
|
|
135
|
+
CardAction,
|
|
136
|
+
CardContent,
|
|
137
|
+
CardDescription,
|
|
138
|
+
CardFooter,
|
|
139
|
+
CardHeader,
|
|
140
|
+
CardTitle
|
|
141
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Card,
|
|
3
|
+
CardAction,
|
|
4
|
+
CardContent,
|
|
5
|
+
CardDescription,
|
|
6
|
+
CardFooter,
|
|
7
|
+
CardHeader,
|
|
8
|
+
CardTitle
|
|
9
|
+
} from "../chunk-GWVW5OI6.mjs";
|
|
10
|
+
import "../chunk-PJO7WJ4G.mjs";
|
|
11
|
+
export {
|
|
12
|
+
Card,
|
|
13
|
+
CardAction,
|
|
14
|
+
CardContent,
|
|
15
|
+
CardDescription,
|
|
16
|
+
CardFooter,
|
|
17
|
+
CardHeader,
|
|
18
|
+
CardTitle
|
|
19
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
interface CarouselContextValue {
|
|
4
|
+
trackRef: React.RefObject<HTMLDivElement | null>;
|
|
5
|
+
orientation: "horizontal" | "vertical";
|
|
6
|
+
scrollByAmount: (dir: 1 | -1) => void;
|
|
7
|
+
canScrollPrev: boolean;
|
|
8
|
+
canScrollNext: boolean;
|
|
9
|
+
}
|
|
10
|
+
declare function useCarousel(): CarouselContextValue;
|
|
11
|
+
interface CarouselProps extends React.ComponentProps<"div"> {
|
|
12
|
+
orientation?: "horizontal" | "vertical";
|
|
13
|
+
}
|
|
14
|
+
declare function Carousel({ orientation, className, children, ...props }: CarouselProps): React.JSX.Element;
|
|
15
|
+
declare function CarouselContent({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
16
|
+
declare function CarouselItem({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
17
|
+
declare function CarouselPrevious({ className, ...props }: React.ComponentProps<"button">): React.JSX.Element;
|
|
18
|
+
declare function CarouselNext({ className, ...props }: React.ComponentProps<"button">): React.JSX.Element;
|
|
19
|
+
|
|
20
|
+
export { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, type CarouselProps, useCarousel };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
interface CarouselContextValue {
|
|
4
|
+
trackRef: React.RefObject<HTMLDivElement | null>;
|
|
5
|
+
orientation: "horizontal" | "vertical";
|
|
6
|
+
scrollByAmount: (dir: 1 | -1) => void;
|
|
7
|
+
canScrollPrev: boolean;
|
|
8
|
+
canScrollNext: boolean;
|
|
9
|
+
}
|
|
10
|
+
declare function useCarousel(): CarouselContextValue;
|
|
11
|
+
interface CarouselProps extends React.ComponentProps<"div"> {
|
|
12
|
+
orientation?: "horizontal" | "vertical";
|
|
13
|
+
}
|
|
14
|
+
declare function Carousel({ orientation, className, children, ...props }: CarouselProps): React.JSX.Element;
|
|
15
|
+
declare function CarouselContent({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
16
|
+
declare function CarouselItem({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
17
|
+
declare function CarouselPrevious({ className, ...props }: React.ComponentProps<"button">): React.JSX.Element;
|
|
18
|
+
declare function CarouselNext({ className, ...props }: React.ComponentProps<"button">): React.JSX.Element;
|
|
19
|
+
|
|
20
|
+
export { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, type CarouselProps, useCarousel };
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// src/carousel/index.tsx
|
|
32
|
+
var carousel_exports = {};
|
|
33
|
+
__export(carousel_exports, {
|
|
34
|
+
Carousel: () => Carousel,
|
|
35
|
+
CarouselContent: () => CarouselContent,
|
|
36
|
+
CarouselItem: () => CarouselItem,
|
|
37
|
+
CarouselNext: () => CarouselNext,
|
|
38
|
+
CarouselPrevious: () => CarouselPrevious,
|
|
39
|
+
useCarousel: () => useCarousel
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(carousel_exports);
|
|
42
|
+
var React = __toESM(require("react"));
|
|
43
|
+
var import_lucide_react = require("lucide-react");
|
|
44
|
+
|
|
45
|
+
// src/utils.ts
|
|
46
|
+
var import_clsx = require("clsx");
|
|
47
|
+
var import_tailwind_merge = require("tailwind-merge");
|
|
48
|
+
function cn(...inputs) {
|
|
49
|
+
return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// src/button/index.tsx
|
|
53
|
+
var import_button = require("@base-ui/react/button");
|
|
54
|
+
var import_class_variance_authority = require("class-variance-authority");
|
|
55
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
56
|
+
var buttonVariants = (0, import_class_variance_authority.cva)(
|
|
57
|
+
"group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
58
|
+
{
|
|
59
|
+
variants: {
|
|
60
|
+
variant: {
|
|
61
|
+
default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
|
|
62
|
+
outline: "border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
|
|
63
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
|
|
64
|
+
ghost: "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
|
|
65
|
+
destructive: "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
|
|
66
|
+
link: "text-primary underline-offset-4 hover:underline"
|
|
67
|
+
},
|
|
68
|
+
size: {
|
|
69
|
+
default: "h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
70
|
+
xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
|
|
71
|
+
sm: "h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
|
|
72
|
+
lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3",
|
|
73
|
+
icon: "size-8",
|
|
74
|
+
"icon-xs": "size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
|
|
75
|
+
"icon-sm": "size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",
|
|
76
|
+
"icon-lg": "size-9"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
defaultVariants: {
|
|
80
|
+
variant: "default",
|
|
81
|
+
size: "default"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
// src/carousel/index.tsx
|
|
87
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
88
|
+
var CarouselContext = React.createContext(null);
|
|
89
|
+
function useCarousel() {
|
|
90
|
+
const ctx = React.useContext(CarouselContext);
|
|
91
|
+
if (!ctx) throw new Error("Carousel parts must be used within <Carousel>");
|
|
92
|
+
return ctx;
|
|
93
|
+
}
|
|
94
|
+
function Carousel({ orientation = "horizontal", className, children, ...props }) {
|
|
95
|
+
const trackRef = React.useRef(null);
|
|
96
|
+
const [canScrollPrev, setCanScrollPrev] = React.useState(false);
|
|
97
|
+
const [canScrollNext, setCanScrollNext] = React.useState(false);
|
|
98
|
+
const updateScrollState = React.useCallback(() => {
|
|
99
|
+
const el = trackRef.current;
|
|
100
|
+
if (!el) return;
|
|
101
|
+
if (orientation === "horizontal") {
|
|
102
|
+
setCanScrollPrev(el.scrollLeft > 4);
|
|
103
|
+
setCanScrollNext(el.scrollLeft < el.scrollWidth - el.clientWidth - 4);
|
|
104
|
+
} else {
|
|
105
|
+
setCanScrollPrev(el.scrollTop > 4);
|
|
106
|
+
setCanScrollNext(el.scrollTop < el.scrollHeight - el.clientHeight - 4);
|
|
107
|
+
}
|
|
108
|
+
}, [orientation]);
|
|
109
|
+
React.useEffect(() => {
|
|
110
|
+
const el = trackRef.current;
|
|
111
|
+
if (!el) return;
|
|
112
|
+
updateScrollState();
|
|
113
|
+
el.addEventListener("scroll", updateScrollState, { passive: true });
|
|
114
|
+
const ro = new ResizeObserver(updateScrollState);
|
|
115
|
+
ro.observe(el);
|
|
116
|
+
return () => {
|
|
117
|
+
el.removeEventListener("scroll", updateScrollState);
|
|
118
|
+
ro.disconnect();
|
|
119
|
+
};
|
|
120
|
+
}, [updateScrollState]);
|
|
121
|
+
const scrollByAmount = React.useCallback(
|
|
122
|
+
(dir) => {
|
|
123
|
+
const el = trackRef.current;
|
|
124
|
+
if (!el) return;
|
|
125
|
+
const amount = (orientation === "horizontal" ? el.clientWidth : el.clientHeight) * 0.9 * dir;
|
|
126
|
+
el.scrollBy(
|
|
127
|
+
orientation === "horizontal" ? { left: amount, behavior: "smooth" } : { top: amount, behavior: "smooth" }
|
|
128
|
+
);
|
|
129
|
+
},
|
|
130
|
+
[orientation]
|
|
131
|
+
);
|
|
132
|
+
const onKeyDown = (e) => {
|
|
133
|
+
if (orientation === "horizontal" && e.key === "ArrowLeft") scrollByAmount(-1);
|
|
134
|
+
else if (orientation === "horizontal" && e.key === "ArrowRight") scrollByAmount(1);
|
|
135
|
+
else if (orientation === "vertical" && e.key === "ArrowUp") scrollByAmount(-1);
|
|
136
|
+
else if (orientation === "vertical" && e.key === "ArrowDown") scrollByAmount(1);
|
|
137
|
+
else return;
|
|
138
|
+
e.preventDefault();
|
|
139
|
+
};
|
|
140
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CarouselContext.Provider, { value: { trackRef, orientation, scrollByAmount, canScrollPrev, canScrollNext }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
141
|
+
"div",
|
|
142
|
+
{
|
|
143
|
+
"data-slot": "carousel",
|
|
144
|
+
role: "region",
|
|
145
|
+
"aria-roledescription": "carousel",
|
|
146
|
+
className: cn("relative", className),
|
|
147
|
+
onKeyDownCapture: onKeyDown,
|
|
148
|
+
...props,
|
|
149
|
+
children
|
|
150
|
+
}
|
|
151
|
+
) });
|
|
152
|
+
}
|
|
153
|
+
function CarouselContent({ className, ...props }) {
|
|
154
|
+
const { trackRef, orientation } = useCarousel();
|
|
155
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
156
|
+
"div",
|
|
157
|
+
{
|
|
158
|
+
ref: trackRef,
|
|
159
|
+
"data-slot": "carousel-content",
|
|
160
|
+
className: cn(
|
|
161
|
+
"flex snap-x snap-mandatory overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
|
|
162
|
+
orientation === "vertical" && "snap-y flex-col overflow-y-auto",
|
|
163
|
+
className
|
|
164
|
+
),
|
|
165
|
+
...props
|
|
166
|
+
}
|
|
167
|
+
) });
|
|
168
|
+
}
|
|
169
|
+
function CarouselItem({ className, ...props }) {
|
|
170
|
+
const { orientation } = useCarousel();
|
|
171
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
172
|
+
"div",
|
|
173
|
+
{
|
|
174
|
+
"data-slot": "carousel-item",
|
|
175
|
+
role: "group",
|
|
176
|
+
"aria-roledescription": "slide",
|
|
177
|
+
className: cn(
|
|
178
|
+
"min-w-0 shrink-0 grow-0 snap-start basis-full",
|
|
179
|
+
orientation === "vertical" && "basis-auto",
|
|
180
|
+
className
|
|
181
|
+
),
|
|
182
|
+
...props
|
|
183
|
+
}
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
function CarouselPrevious({ className, ...props }) {
|
|
187
|
+
const { scrollByAmount, canScrollPrev, orientation } = useCarousel();
|
|
188
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
189
|
+
"button",
|
|
190
|
+
{
|
|
191
|
+
type: "button",
|
|
192
|
+
"data-slot": "carousel-previous",
|
|
193
|
+
"aria-label": "Previous slide",
|
|
194
|
+
disabled: !canScrollPrev,
|
|
195
|
+
onClick: () => scrollByAmount(-1),
|
|
196
|
+
className: cn(
|
|
197
|
+
buttonVariants({ variant: "outline", size: "icon-sm" }),
|
|
198
|
+
"absolute rounded-full",
|
|
199
|
+
orientation === "horizontal" ? "top-1/2 left-2 -translate-y-1/2" : "top-2 left-1/2 -translate-x-1/2 rotate-90",
|
|
200
|
+
className
|
|
201
|
+
),
|
|
202
|
+
...props,
|
|
203
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.ChevronLeft, { className: "size-4" })
|
|
204
|
+
}
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
function CarouselNext({ className, ...props }) {
|
|
208
|
+
const { scrollByAmount, canScrollNext, orientation } = useCarousel();
|
|
209
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
210
|
+
"button",
|
|
211
|
+
{
|
|
212
|
+
type: "button",
|
|
213
|
+
"data-slot": "carousel-next",
|
|
214
|
+
"aria-label": "Next slide",
|
|
215
|
+
disabled: !canScrollNext,
|
|
216
|
+
onClick: () => scrollByAmount(1),
|
|
217
|
+
className: cn(
|
|
218
|
+
buttonVariants({ variant: "outline", size: "icon-sm" }),
|
|
219
|
+
"absolute rounded-full",
|
|
220
|
+
orientation === "horizontal" ? "top-1/2 right-2 -translate-y-1/2" : "bottom-2 left-1/2 -translate-x-1/2 rotate-90",
|
|
221
|
+
className
|
|
222
|
+
),
|
|
223
|
+
...props,
|
|
224
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.ChevronRight, { className: "size-4" })
|
|
225
|
+
}
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
229
|
+
0 && (module.exports = {
|
|
230
|
+
Carousel,
|
|
231
|
+
CarouselContent,
|
|
232
|
+
CarouselItem,
|
|
233
|
+
CarouselNext,
|
|
234
|
+
CarouselPrevious,
|
|
235
|
+
useCarousel
|
|
236
|
+
});
|