@codefast/ui 0.3.9 → 0.3.11-canary.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/CHANGELOG.md +30 -0
- package/README.md +277 -167
- package/dist/components/accordion.cjs +97 -1
- package/dist/components/accordion.js +51 -1
- package/dist/components/alert-dialog.cjs +155 -1
- package/dist/components/alert-dialog.d.ts +2 -2
- package/dist/components/alert-dialog.js +94 -1
- package/dist/components/alert.cjs +84 -1
- package/dist/components/alert.d.ts +1 -1
- package/dist/components/alert.js +41 -1
- package/dist/components/aspect-ratio.cjs +43 -1
- package/dist/components/aspect-ratio.js +9 -1
- package/dist/components/avatar.cjs +65 -1
- package/dist/components/avatar.js +25 -1
- package/dist/components/badge.cjs +66 -1
- package/dist/components/badge.d.ts +1 -1
- package/dist/components/badge.js +29 -1
- package/dist/components/breadcrumb.cjs +124 -1
- package/dist/components/breadcrumb.js +72 -1
- package/dist/components/button-group.cjs +86 -1
- package/dist/components/button-group.d.ts +1 -1
- package/dist/components/button-group.js +43 -1
- package/dist/components/button.cjs +92 -1
- package/dist/components/button.d.ts +1 -1
- package/dist/components/button.js +55 -1
- package/dist/components/calendar.cjs +150 -1
- package/dist/components/calendar.d.ts +11 -18
- package/dist/components/calendar.js +113 -1
- package/dist/components/card.cjs +105 -1
- package/dist/components/card.js +53 -1
- package/dist/components/carousel.cjs +210 -1
- package/dist/components/carousel.d.ts +1 -1
- package/dist/components/carousel.js +151 -1
- package/dist/components/chart.cjs +250 -3
- package/dist/components/chart.d.ts +5 -4
- package/dist/components/chart.js +198 -3
- package/dist/components/checkbox-cards.cjs +69 -1
- package/dist/components/checkbox-cards.js +32 -1
- package/dist/components/checkbox-group.cjs +63 -1
- package/dist/components/checkbox-group.js +26 -1
- package/dist/components/checkbox.cjs +53 -1
- package/dist/components/checkbox.js +19 -1
- package/dist/components/collapsible.cjs +61 -1
- package/dist/components/collapsible.js +21 -1
- package/dist/components/command.cjs +167 -1
- package/dist/components/command.js +106 -1
- package/dist/components/context-menu.cjs +218 -1
- package/dist/components/context-menu.js +142 -1
- package/dist/components/dialog.cjs +164 -1
- package/dist/components/dialog.d.ts +2 -2
- package/dist/components/dialog.js +106 -1
- package/dist/components/drawer.cjs +143 -1
- package/dist/components/drawer.d.ts +1 -1
- package/dist/components/drawer.js +85 -1
- package/dist/components/dropdown-menu.cjs +221 -1
- package/dist/components/dropdown-menu.js +145 -1
- package/dist/components/empty.cjs +113 -1
- package/dist/components/empty.d.ts +1 -1
- package/dist/components/empty.js +61 -1
- package/dist/components/field.cjs +193 -1
- package/dist/components/field.d.ts +1 -1
- package/dist/components/field.js +129 -1
- package/dist/components/form.cjs +151 -1
- package/dist/components/form.d.ts +3 -3
- package/dist/components/form.js +96 -1
- package/dist/components/hover-card.cjs +77 -1
- package/dist/components/hover-card.js +34 -1
- package/dist/components/input-group.cjs +155 -1
- package/dist/components/input-group.d.ts +1 -1
- package/dist/components/input-group.js +97 -1
- package/dist/components/input-number.cjs +98 -1
- package/dist/components/input-number.js +64 -1
- package/dist/components/input-otp.cjs +101 -1
- package/dist/components/input-otp.js +49 -1
- package/dist/components/input-password.cjs +71 -1
- package/dist/components/input-password.js +37 -1
- package/dist/components/input-search.cjs +80 -1
- package/dist/components/input-search.js +46 -1
- package/dist/components/input.cjs +45 -1
- package/dist/components/input.js +11 -1
- package/dist/components/item.cjs +186 -1
- package/dist/components/item.d.ts +1 -1
- package/dist/components/item.js +119 -1
- package/dist/components/kbd.cjs +54 -1
- package/dist/components/kbd.js +17 -1
- package/dist/components/label.cjs +45 -1
- package/dist/components/label.js +11 -1
- package/dist/components/menubar.cjs +232 -1
- package/dist/components/menubar.js +153 -1
- package/dist/components/native-select.cjs +75 -1
- package/dist/components/native-select.js +35 -1
- package/dist/components/navigation-menu.cjs +146 -2
- package/dist/components/navigation-menu.js +94 -2
- package/dist/components/pagination.cjs +138 -1
- package/dist/components/pagination.d.ts +1 -1
- package/dist/components/pagination.js +86 -1
- package/dist/components/popover.cjs +86 -1
- package/dist/components/popover.js +40 -1
- package/dist/components/progress-circle.cjs +184 -1
- package/dist/components/progress-circle.d.ts +1 -1
- package/dist/components/progress-circle.js +147 -1
- package/dist/components/progress.cjs +52 -1
- package/dist/components/progress.js +18 -1
- package/dist/components/radio-cards.cjs +66 -1
- package/dist/components/radio-cards.js +29 -1
- package/dist/components/radio-group.cjs +59 -1
- package/dist/components/radio-group.js +22 -1
- package/dist/components/radio.cjs +47 -1
- package/dist/components/radio.js +13 -1
- package/dist/components/resizable.cjs +71 -1
- package/dist/components/resizable.d.ts +6 -6
- package/dist/components/resizable.js +31 -1
- package/dist/components/scroll-area.cjs +140 -1
- package/dist/components/scroll-area.d.ts +1 -1
- package/dist/components/scroll-area.js +100 -1
- package/dist/components/select.cjs +180 -1
- package/dist/components/select.d.ts +2 -2
- package/dist/components/select.js +119 -1
- package/dist/components/separator.cjs +82 -1
- package/dist/components/separator.d.ts +1 -1
- package/dist/components/separator.js +42 -1
- package/dist/components/sheet.cjs +184 -1
- package/dist/components/sheet.d.ts +2 -2
- package/dist/components/sheet.js +123 -1
- package/dist/components/sidebar.cjs +506 -1
- package/dist/components/sidebar.d.ts +1 -1
- package/dist/components/sidebar.js +400 -1
- package/dist/components/skeleton.cjs +44 -1
- package/dist/components/skeleton.js +10 -1
- package/dist/components/slider.cjs +79 -1
- package/dist/components/slider.js +45 -1
- package/dist/components/sonner.cjs +57 -1
- package/dist/components/sonner.js +17 -1
- package/dist/components/spinner.cjs +75 -1
- package/dist/components/spinner.js +41 -1
- package/dist/components/switch.cjs +49 -1
- package/dist/components/switch.js +15 -1
- package/dist/components/table.cjs +118 -1
- package/dist/components/table.js +63 -1
- package/dist/components/tabs.cjs +75 -1
- package/dist/components/tabs.d.ts +1 -1
- package/dist/components/tabs.js +32 -1
- package/dist/components/textarea.cjs +44 -1
- package/dist/components/textarea.js +10 -1
- package/dist/components/toggle-group.cjs +90 -1
- package/dist/components/toggle-group.d.ts +8 -10
- package/dist/components/toggle-group.js +53 -1
- package/dist/components/toggle.cjs +71 -1
- package/dist/components/toggle.d.ts +8 -10
- package/dist/components/toggle.js +34 -1
- package/dist/components/tooltip.cjs +90 -1
- package/dist/components/tooltip.js +44 -1
- package/dist/css/amber.css +95 -1
- package/dist/css/blue.css +95 -1
- package/dist/css/cyan.css +95 -1
- package/dist/css/emerald.css +95 -1
- package/dist/css/fuchsia.css +95 -1
- package/dist/css/gray.css +95 -1
- package/dist/css/green.css +95 -1
- package/dist/css/indigo.css +95 -1
- package/dist/css/lime.css +95 -1
- package/dist/css/neutral.css +95 -1
- package/dist/css/orange.css +95 -1
- package/dist/css/pink.css +95 -1
- package/dist/css/preset.css +118 -1
- package/dist/css/purple.css +95 -1
- package/dist/css/red.css +95 -1
- package/dist/css/rose.css +95 -1
- package/dist/css/sky.css +95 -1
- package/dist/css/slate.css +95 -1
- package/dist/css/stone.css +95 -1
- package/dist/css/style.css +3 -1
- package/dist/css/teal.css +95 -1
- package/dist/css/violet.css +95 -1
- package/dist/css/yellow.css +95 -1
- package/dist/css/zinc.css +95 -1
- package/dist/hooks/use-animated-value.cjs +74 -1
- package/dist/hooks/use-animated-value.d.ts +9 -10
- package/dist/hooks/use-animated-value.js +40 -1
- package/dist/hooks/use-copy-to-clipboard.cjs +57 -1
- package/dist/hooks/use-copy-to-clipboard.d.ts +17 -0
- package/dist/hooks/use-copy-to-clipboard.js +23 -1
- package/dist/hooks/use-is-mobile.cjs +39 -1
- package/dist/hooks/use-is-mobile.d.ts +15 -6
- package/dist/hooks/use-is-mobile.js +5 -1
- package/dist/hooks/use-media-query.cjs +56 -1
- package/dist/hooks/use-media-query.d.ts +11 -3
- package/dist/hooks/use-media-query.js +22 -1
- package/dist/hooks/use-mutation-observer.cjs +56 -1
- package/dist/hooks/use-mutation-observer.d.ts +7 -11
- package/dist/hooks/use-mutation-observer.js +22 -1
- package/dist/hooks/use-pagination.cjs +92 -1
- package/dist/hooks/use-pagination.d.ts +12 -10
- package/dist/hooks/use-pagination.js +55 -1
- package/dist/index.cjs +1081 -1
- package/dist/index.d.ts +4 -5
- package/dist/index.js +69 -1
- package/dist/primitives/checkbox-group.cjs +151 -1
- package/dist/primitives/checkbox-group.d.ts +1 -1
- package/dist/primitives/checkbox-group.js +99 -1
- package/dist/primitives/input-number.cjs +439 -1
- package/dist/primitives/input-number.d.ts +1 -1
- package/dist/primitives/input-number.js +381 -1
- package/dist/primitives/input.cjs +99 -1
- package/dist/primitives/input.d.ts +1 -1
- package/dist/primitives/input.js +53 -1
- package/dist/primitives/progress-circle.cjs +198 -1
- package/dist/primitives/progress-circle.d.ts +1 -1
- package/dist/primitives/progress-circle.js +128 -1
- package/package.json +405 -62
package/dist/components/card.js
CHANGED
|
@@ -1 +1,53 @@
|
|
|
1
|
-
import{jsx
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "@codefast/tailwind-variants";
|
|
3
|
+
function Card({ className, ...props }) {
|
|
4
|
+
return /*#__PURE__*/ jsx("div", {
|
|
5
|
+
className: cn("flex flex-col gap-6 overflow-auto rounded-xl border bg-card py-6 text-card-foreground shadow-sm", className),
|
|
6
|
+
"data-slot": "card",
|
|
7
|
+
...props
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
function CardHeader({ className, ...props }) {
|
|
11
|
+
return /*#__PURE__*/ jsx("div", {
|
|
12
|
+
className: cn("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-[data-slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6", className),
|
|
13
|
+
"data-slot": "card-header",
|
|
14
|
+
...props
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function CardTitle({ children, className, ...props }) {
|
|
18
|
+
return /*#__PURE__*/ jsx("div", {
|
|
19
|
+
className: cn("leading-none font-semibold", className),
|
|
20
|
+
"data-slot": "card-title",
|
|
21
|
+
...props,
|
|
22
|
+
children: children
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function CardDescription({ className, ...props }) {
|
|
26
|
+
return /*#__PURE__*/ jsx("div", {
|
|
27
|
+
className: cn("text-sm text-muted-foreground", className),
|
|
28
|
+
"data-slot": "card-description",
|
|
29
|
+
...props
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function CardContent({ className, ...props }) {
|
|
33
|
+
return /*#__PURE__*/ jsx("div", {
|
|
34
|
+
className: cn("px-6", className),
|
|
35
|
+
"data-slot": "card-content",
|
|
36
|
+
...props
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function CardFooter({ className, ...props }) {
|
|
40
|
+
return /*#__PURE__*/ jsx("div", {
|
|
41
|
+
className: cn("flex items-center px-6 [.border-t]:pt-6", className),
|
|
42
|
+
"data-slot": "card-footer",
|
|
43
|
+
...props
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function CardAction({ className, ...props }) {
|
|
47
|
+
return /*#__PURE__*/ jsx("div", {
|
|
48
|
+
className: cn("col-start-2 row-span-2 row-start-1 self-start justify-self-end", className),
|
|
49
|
+
"data-slot": "card-action",
|
|
50
|
+
...props
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
export { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle };
|
|
@@ -1,2 +1,211 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
"use client";
|
|
2
|
-
|
|
3
|
+
var __webpack_require__ = {};
|
|
4
|
+
(()=>{
|
|
5
|
+
__webpack_require__.n = (module)=>{
|
|
6
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
7
|
+
__webpack_require__.d(getter, {
|
|
8
|
+
a: getter
|
|
9
|
+
});
|
|
10
|
+
return getter;
|
|
11
|
+
};
|
|
12
|
+
})();
|
|
13
|
+
(()=>{
|
|
14
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
15
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: definition[key]
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
})();
|
|
21
|
+
(()=>{
|
|
22
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
23
|
+
})();
|
|
24
|
+
(()=>{
|
|
25
|
+
__webpack_require__.r = (exports1)=>{
|
|
26
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
27
|
+
value: 'Module'
|
|
28
|
+
});
|
|
29
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
30
|
+
value: true
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
})();
|
|
34
|
+
var __webpack_exports__ = {};
|
|
35
|
+
__webpack_require__.r(__webpack_exports__);
|
|
36
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
37
|
+
CarouselPrevious: ()=>CarouselPrevious,
|
|
38
|
+
Carousel: ()=>Carousel,
|
|
39
|
+
createCarouselScope: ()=>createCarouselScope,
|
|
40
|
+
CarouselContent: ()=>CarouselContent,
|
|
41
|
+
CarouselItem: ()=>CarouselItem,
|
|
42
|
+
CarouselNext: ()=>CarouselNext
|
|
43
|
+
});
|
|
44
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
45
|
+
const tailwind_variants_namespaceObject = require("@codefast/tailwind-variants");
|
|
46
|
+
const react_context_namespaceObject = require("@radix-ui/react-context");
|
|
47
|
+
const external_embla_carousel_react_namespaceObject = require("embla-carousel-react");
|
|
48
|
+
var external_embla_carousel_react_default = /*#__PURE__*/ __webpack_require__.n(external_embla_carousel_react_namespaceObject);
|
|
49
|
+
const external_lucide_react_namespaceObject = require("lucide-react");
|
|
50
|
+
const external_react_namespaceObject = require("react");
|
|
51
|
+
const external_button_cjs_namespaceObject = require("./button.cjs");
|
|
52
|
+
const CAROUSEL_NAME = "Carousel";
|
|
53
|
+
const [createCarouselContext, createCarouselScope] = (0, react_context_namespaceObject.createContextScope)(CAROUSEL_NAME);
|
|
54
|
+
const [CarouselContextProvider, useCarouselContext] = createCarouselContext(CAROUSEL_NAME);
|
|
55
|
+
function Carousel({ __scopeCarousel, children, className, opts, orientation, plugins, setApi, ...props }) {
|
|
56
|
+
const [carouselRef, api] = external_embla_carousel_react_default()({
|
|
57
|
+
...opts,
|
|
58
|
+
axis: "vertical" === orientation ? "y" : "x"
|
|
59
|
+
}, plugins);
|
|
60
|
+
const [canScrollPrevious, setCanScrollPrevious] = (0, external_react_namespaceObject.useState)(false);
|
|
61
|
+
const [canScrollNext, setCanScrollNext] = (0, external_react_namespaceObject.useState)(false);
|
|
62
|
+
const onSelect = (0, external_react_namespaceObject.useCallback)((carouselApi)=>{
|
|
63
|
+
if (!carouselApi) return;
|
|
64
|
+
setCanScrollPrevious(carouselApi.canScrollPrev());
|
|
65
|
+
setCanScrollNext(carouselApi.canScrollNext());
|
|
66
|
+
}, []);
|
|
67
|
+
const scrollPrevious = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
68
|
+
api?.scrollPrev();
|
|
69
|
+
}, [
|
|
70
|
+
api
|
|
71
|
+
]);
|
|
72
|
+
const scrollNext = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
73
|
+
api?.scrollNext();
|
|
74
|
+
}, [
|
|
75
|
+
api
|
|
76
|
+
]);
|
|
77
|
+
const handleKeyDown = (0, external_react_namespaceObject.useCallback)((event)=>{
|
|
78
|
+
if ("ArrowLeft" === event.key) {
|
|
79
|
+
event.preventDefault();
|
|
80
|
+
scrollPrevious();
|
|
81
|
+
} else if ("ArrowRight" === event.key) {
|
|
82
|
+
event.preventDefault();
|
|
83
|
+
scrollNext();
|
|
84
|
+
}
|
|
85
|
+
}, [
|
|
86
|
+
scrollPrevious,
|
|
87
|
+
scrollNext
|
|
88
|
+
]);
|
|
89
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
90
|
+
if (!api || !setApi) return;
|
|
91
|
+
setApi(api);
|
|
92
|
+
}, [
|
|
93
|
+
api,
|
|
94
|
+
setApi
|
|
95
|
+
]);
|
|
96
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
97
|
+
if (!api) return;
|
|
98
|
+
queueMicrotask(()=>{
|
|
99
|
+
onSelect(api);
|
|
100
|
+
});
|
|
101
|
+
api.on("reInit", onSelect);
|
|
102
|
+
api.on("select", onSelect);
|
|
103
|
+
return ()=>{
|
|
104
|
+
api.off("select", onSelect);
|
|
105
|
+
};
|
|
106
|
+
}, [
|
|
107
|
+
api,
|
|
108
|
+
onSelect
|
|
109
|
+
]);
|
|
110
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(CarouselContextProvider, {
|
|
111
|
+
api: api,
|
|
112
|
+
canScrollNext: canScrollNext,
|
|
113
|
+
canScrollPrev: canScrollPrevious,
|
|
114
|
+
carouselRef: carouselRef,
|
|
115
|
+
opts: opts,
|
|
116
|
+
orientation: orientation ?? (opts?.axis === "y" ? "vertical" : "horizontal"),
|
|
117
|
+
scope: __scopeCarousel,
|
|
118
|
+
scrollNext: scrollNext,
|
|
119
|
+
scrollPrev: scrollPrevious,
|
|
120
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
121
|
+
className: (0, tailwind_variants_namespaceObject.cn)("relative", className),
|
|
122
|
+
"data-slot": "carousel",
|
|
123
|
+
onKeyDownCapture: handleKeyDown,
|
|
124
|
+
...props,
|
|
125
|
+
children: children
|
|
126
|
+
})
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
const CAROUSEL_CONTENT_NAME = "CarouselContent";
|
|
130
|
+
function CarouselContent({ __scopeCarousel, className, classNames, ...props }) {
|
|
131
|
+
const { carouselRef, orientation } = useCarouselContext(CAROUSEL_CONTENT_NAME, __scopeCarousel);
|
|
132
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
133
|
+
ref: carouselRef,
|
|
134
|
+
className: (0, tailwind_variants_namespaceObject.cn)("overflow-hidden", classNames?.wrapper),
|
|
135
|
+
"data-slot": "carousel-content",
|
|
136
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
137
|
+
className: (0, tailwind_variants_namespaceObject.cn)("flex", "horizontal" === orientation ? "-ml-4" : "-mt-4 flex-col", classNames?.content, className),
|
|
138
|
+
...props
|
|
139
|
+
})
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
const CAROUSEL_ITEM_NAME = "CarouselItem";
|
|
143
|
+
function CarouselItem({ __scopeCarousel, className, ...props }) {
|
|
144
|
+
const { orientation } = useCarouselContext(CAROUSEL_ITEM_NAME, __scopeCarousel);
|
|
145
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
146
|
+
"aria-roledescription": "slide",
|
|
147
|
+
className: (0, tailwind_variants_namespaceObject.cn)("min-w-0 shrink-0 grow-0 basis-full", "horizontal" === orientation ? "pl-4" : "pt-4", className),
|
|
148
|
+
"data-slot": "carousel-item",
|
|
149
|
+
role: "group",
|
|
150
|
+
...props
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
const CAROUSEL_PREVIOUS_NAME = "CarouselPrevious";
|
|
154
|
+
function CarouselPrevious({ __scopeCarousel, className, size = "icon", variant = "outline", ...props }) {
|
|
155
|
+
const { canScrollPrev, orientation, scrollPrev } = useCarouselContext(CAROUSEL_PREVIOUS_NAME, __scopeCarousel);
|
|
156
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_button_cjs_namespaceObject.Button, {
|
|
157
|
+
"aria-label": "Previous slide",
|
|
158
|
+
className: (0, tailwind_variants_namespaceObject.cn)("absolute size-8 shadow-none", "horizontal" === orientation ? "top-1/2 -left-12 -translate-y-1/2" : "-top-12 left-1/2 -translate-x-1/2 rotate-90", className),
|
|
159
|
+
"data-slot": "carousel-previous",
|
|
160
|
+
disabled: !canScrollPrev,
|
|
161
|
+
size: size,
|
|
162
|
+
variant: variant,
|
|
163
|
+
onClick: scrollPrev,
|
|
164
|
+
...props,
|
|
165
|
+
children: [
|
|
166
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.ArrowLeftIcon, {}),
|
|
167
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
168
|
+
className: "sr-only",
|
|
169
|
+
children: "Previous slide"
|
|
170
|
+
})
|
|
171
|
+
]
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
const CAROUSEL_NEXT_NAME = "CarouselNext";
|
|
175
|
+
function CarouselNext({ __scopeCarousel, className, size = "icon", variant = "outline", ...props }) {
|
|
176
|
+
const { canScrollNext, orientation, scrollNext } = useCarouselContext(CAROUSEL_NEXT_NAME, __scopeCarousel);
|
|
177
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_button_cjs_namespaceObject.Button, {
|
|
178
|
+
"aria-label": "Next slide",
|
|
179
|
+
className: (0, tailwind_variants_namespaceObject.cn)("absolute size-8 shadow-none", "horizontal" === orientation ? "top-1/2 -right-12 -translate-y-1/2" : "-bottom-12 left-1/2 -translate-x-1/2 rotate-90", className),
|
|
180
|
+
"data-slot": "carousel-next",
|
|
181
|
+
disabled: !canScrollNext,
|
|
182
|
+
size: size,
|
|
183
|
+
variant: variant,
|
|
184
|
+
onClick: scrollNext,
|
|
185
|
+
...props,
|
|
186
|
+
children: [
|
|
187
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.ArrowRightIcon, {}),
|
|
188
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
189
|
+
className: "sr-only",
|
|
190
|
+
children: "Next slide"
|
|
191
|
+
})
|
|
192
|
+
]
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
exports.Carousel = __webpack_exports__.Carousel;
|
|
196
|
+
exports.CarouselContent = __webpack_exports__.CarouselContent;
|
|
197
|
+
exports.CarouselItem = __webpack_exports__.CarouselItem;
|
|
198
|
+
exports.CarouselNext = __webpack_exports__.CarouselNext;
|
|
199
|
+
exports.CarouselPrevious = __webpack_exports__.CarouselPrevious;
|
|
200
|
+
exports.createCarouselScope = __webpack_exports__.createCarouselScope;
|
|
201
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
202
|
+
"Carousel",
|
|
203
|
+
"CarouselContent",
|
|
204
|
+
"CarouselItem",
|
|
205
|
+
"CarouselNext",
|
|
206
|
+
"CarouselPrevious",
|
|
207
|
+
"createCarouselScope"
|
|
208
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
209
|
+
Object.defineProperty(exports, '__esModule', {
|
|
210
|
+
value: true
|
|
211
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import type { Scope } from "@radix-ui/react-context";
|
|
1
2
|
import type { UseEmblaCarouselType } from "embla-carousel-react";
|
|
2
3
|
import type { ComponentProps, JSX } from "react";
|
|
3
4
|
import useEmblaCarousel from "embla-carousel-react";
|
|
4
|
-
import type { Scope } from "@radix-ui/react-context";
|
|
5
5
|
import { Button } from "./button";
|
|
6
6
|
type ScopedProps<P> = P & {
|
|
7
7
|
__scopeCarousel?: Scope;
|
|
@@ -1,2 +1,152 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "@codefast/tailwind-variants";
|
|
4
|
+
import { createContextScope } from "@radix-ui/react-context";
|
|
5
|
+
import embla_carousel_react from "embla-carousel-react";
|
|
6
|
+
import { ArrowLeftIcon, ArrowRightIcon } from "lucide-react";
|
|
7
|
+
import { useCallback, useEffect, useState } from "react";
|
|
8
|
+
import { Button } from "./button.js";
|
|
9
|
+
const CAROUSEL_NAME = "Carousel";
|
|
10
|
+
const [createCarouselContext, createCarouselScope] = createContextScope(CAROUSEL_NAME);
|
|
11
|
+
const [CarouselContextProvider, useCarouselContext] = createCarouselContext(CAROUSEL_NAME);
|
|
12
|
+
function Carousel({ __scopeCarousel, children, className, opts, orientation, plugins, setApi, ...props }) {
|
|
13
|
+
const [carouselRef, api] = embla_carousel_react({
|
|
14
|
+
...opts,
|
|
15
|
+
axis: "vertical" === orientation ? "y" : "x"
|
|
16
|
+
}, plugins);
|
|
17
|
+
const [canScrollPrevious, setCanScrollPrevious] = useState(false);
|
|
18
|
+
const [canScrollNext, setCanScrollNext] = useState(false);
|
|
19
|
+
const onSelect = useCallback((carouselApi)=>{
|
|
20
|
+
if (!carouselApi) return;
|
|
21
|
+
setCanScrollPrevious(carouselApi.canScrollPrev());
|
|
22
|
+
setCanScrollNext(carouselApi.canScrollNext());
|
|
23
|
+
}, []);
|
|
24
|
+
const scrollPrevious = useCallback(()=>{
|
|
25
|
+
api?.scrollPrev();
|
|
26
|
+
}, [
|
|
27
|
+
api
|
|
28
|
+
]);
|
|
29
|
+
const scrollNext = useCallback(()=>{
|
|
30
|
+
api?.scrollNext();
|
|
31
|
+
}, [
|
|
32
|
+
api
|
|
33
|
+
]);
|
|
34
|
+
const handleKeyDown = useCallback((event)=>{
|
|
35
|
+
if ("ArrowLeft" === event.key) {
|
|
36
|
+
event.preventDefault();
|
|
37
|
+
scrollPrevious();
|
|
38
|
+
} else if ("ArrowRight" === event.key) {
|
|
39
|
+
event.preventDefault();
|
|
40
|
+
scrollNext();
|
|
41
|
+
}
|
|
42
|
+
}, [
|
|
43
|
+
scrollPrevious,
|
|
44
|
+
scrollNext
|
|
45
|
+
]);
|
|
46
|
+
useEffect(()=>{
|
|
47
|
+
if (!api || !setApi) return;
|
|
48
|
+
setApi(api);
|
|
49
|
+
}, [
|
|
50
|
+
api,
|
|
51
|
+
setApi
|
|
52
|
+
]);
|
|
53
|
+
useEffect(()=>{
|
|
54
|
+
if (!api) return;
|
|
55
|
+
queueMicrotask(()=>{
|
|
56
|
+
onSelect(api);
|
|
57
|
+
});
|
|
58
|
+
api.on("reInit", onSelect);
|
|
59
|
+
api.on("select", onSelect);
|
|
60
|
+
return ()=>{
|
|
61
|
+
api.off("select", onSelect);
|
|
62
|
+
};
|
|
63
|
+
}, [
|
|
64
|
+
api,
|
|
65
|
+
onSelect
|
|
66
|
+
]);
|
|
67
|
+
return /*#__PURE__*/ jsx(CarouselContextProvider, {
|
|
68
|
+
api: api,
|
|
69
|
+
canScrollNext: canScrollNext,
|
|
70
|
+
canScrollPrev: canScrollPrevious,
|
|
71
|
+
carouselRef: carouselRef,
|
|
72
|
+
opts: opts,
|
|
73
|
+
orientation: orientation ?? (opts?.axis === "y" ? "vertical" : "horizontal"),
|
|
74
|
+
scope: __scopeCarousel,
|
|
75
|
+
scrollNext: scrollNext,
|
|
76
|
+
scrollPrev: scrollPrevious,
|
|
77
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
78
|
+
className: cn("relative", className),
|
|
79
|
+
"data-slot": "carousel",
|
|
80
|
+
onKeyDownCapture: handleKeyDown,
|
|
81
|
+
...props,
|
|
82
|
+
children: children
|
|
83
|
+
})
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
const CAROUSEL_CONTENT_NAME = "CarouselContent";
|
|
87
|
+
function CarouselContent({ __scopeCarousel, className, classNames, ...props }) {
|
|
88
|
+
const { carouselRef, orientation } = useCarouselContext(CAROUSEL_CONTENT_NAME, __scopeCarousel);
|
|
89
|
+
return /*#__PURE__*/ jsx("div", {
|
|
90
|
+
ref: carouselRef,
|
|
91
|
+
className: cn("overflow-hidden", classNames?.wrapper),
|
|
92
|
+
"data-slot": "carousel-content",
|
|
93
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
94
|
+
className: cn("flex", "horizontal" === orientation ? "-ml-4" : "-mt-4 flex-col", classNames?.content, className),
|
|
95
|
+
...props
|
|
96
|
+
})
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
const CAROUSEL_ITEM_NAME = "CarouselItem";
|
|
100
|
+
function CarouselItem({ __scopeCarousel, className, ...props }) {
|
|
101
|
+
const { orientation } = useCarouselContext(CAROUSEL_ITEM_NAME, __scopeCarousel);
|
|
102
|
+
return /*#__PURE__*/ jsx("div", {
|
|
103
|
+
"aria-roledescription": "slide",
|
|
104
|
+
className: cn("min-w-0 shrink-0 grow-0 basis-full", "horizontal" === orientation ? "pl-4" : "pt-4", className),
|
|
105
|
+
"data-slot": "carousel-item",
|
|
106
|
+
role: "group",
|
|
107
|
+
...props
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
const CAROUSEL_PREVIOUS_NAME = "CarouselPrevious";
|
|
111
|
+
function CarouselPrevious({ __scopeCarousel, className, size = "icon", variant = "outline", ...props }) {
|
|
112
|
+
const { canScrollPrev, orientation, scrollPrev } = useCarouselContext(CAROUSEL_PREVIOUS_NAME, __scopeCarousel);
|
|
113
|
+
return /*#__PURE__*/ jsxs(Button, {
|
|
114
|
+
"aria-label": "Previous slide",
|
|
115
|
+
className: cn("absolute size-8 shadow-none", "horizontal" === orientation ? "top-1/2 -left-12 -translate-y-1/2" : "-top-12 left-1/2 -translate-x-1/2 rotate-90", className),
|
|
116
|
+
"data-slot": "carousel-previous",
|
|
117
|
+
disabled: !canScrollPrev,
|
|
118
|
+
size: size,
|
|
119
|
+
variant: variant,
|
|
120
|
+
onClick: scrollPrev,
|
|
121
|
+
...props,
|
|
122
|
+
children: [
|
|
123
|
+
/*#__PURE__*/ jsx(ArrowLeftIcon, {}),
|
|
124
|
+
/*#__PURE__*/ jsx("span", {
|
|
125
|
+
className: "sr-only",
|
|
126
|
+
children: "Previous slide"
|
|
127
|
+
})
|
|
128
|
+
]
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
const CAROUSEL_NEXT_NAME = "CarouselNext";
|
|
132
|
+
function CarouselNext({ __scopeCarousel, className, size = "icon", variant = "outline", ...props }) {
|
|
133
|
+
const { canScrollNext, orientation, scrollNext } = useCarouselContext(CAROUSEL_NEXT_NAME, __scopeCarousel);
|
|
134
|
+
return /*#__PURE__*/ jsxs(Button, {
|
|
135
|
+
"aria-label": "Next slide",
|
|
136
|
+
className: cn("absolute size-8 shadow-none", "horizontal" === orientation ? "top-1/2 -right-12 -translate-y-1/2" : "-bottom-12 left-1/2 -translate-x-1/2 rotate-90", className),
|
|
137
|
+
"data-slot": "carousel-next",
|
|
138
|
+
disabled: !canScrollNext,
|
|
139
|
+
size: size,
|
|
140
|
+
variant: variant,
|
|
141
|
+
onClick: scrollNext,
|
|
142
|
+
...props,
|
|
143
|
+
children: [
|
|
144
|
+
/*#__PURE__*/ jsx(ArrowRightIcon, {}),
|
|
145
|
+
/*#__PURE__*/ jsx("span", {
|
|
146
|
+
className: "sr-only",
|
|
147
|
+
children: "Next slide"
|
|
148
|
+
})
|
|
149
|
+
]
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
export { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, createCarouselScope };
|