asterui 0.12.31 → 0.12.33
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/components/Badge.d.ts +24 -5
- package/dist/components/Badge.js +209 -122
- package/dist/components/Badge.js.map +1 -1
- package/dist/components/Carousel.d.ts +47 -6
- package/dist/components/Carousel.js +202 -5
- package/dist/components/Carousel.js.map +1 -1
- package/dist/components/Drawer.d.ts +34 -4
- package/dist/components/Drawer.js +240 -169
- package/dist/components/Drawer.js.map +1 -1
- package/dist/components/Layout.d.ts +40 -32
- package/dist/components/Layout.js +178 -130
- package/dist/components/Layout.js.map +1 -1
- package/dist/components/ResponsiveDrawer.d.ts +34 -0
- package/dist/components/ResponsiveDrawer.js +75 -0
- package/dist/components/ResponsiveDrawer.js.map +1 -0
- package/dist/index.d.ts +6 -8
- package/dist/index.js +127 -129
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/components/PageLayout.d.ts +0 -9
- package/dist/components/PageLayout.js +0 -35
- package/dist/components/PageLayout.js.map +0 -1
- package/dist/components/SidebarDrawer.d.ts +0 -21
- package/dist/components/SidebarDrawer.js +0 -44
- package/dist/components/SidebarDrawer.js.map +0 -1
|
@@ -1,8 +1,205 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { jsxs as R, jsx as i, Fragment as ae } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as T, useState as D, useRef as L, Children as re, isValidElement as ne, useCallback as y, useImperativeHandle as ie, useEffect as ce, cloneElement as ue } from "react";
|
|
3
|
+
const z = T(
|
|
4
|
+
({ children: g, className: b = "", "data-testid": w, ...c }, p) => /* @__PURE__ */ i(
|
|
5
|
+
"div",
|
|
6
|
+
{
|
|
7
|
+
ref: p,
|
|
8
|
+
role: "group",
|
|
9
|
+
"aria-roledescription": "slide",
|
|
10
|
+
className: `carousel-item w-full flex-shrink-0 ${b}`,
|
|
11
|
+
"data-testid": w,
|
|
12
|
+
...c,
|
|
13
|
+
children: g
|
|
14
|
+
}
|
|
15
|
+
)
|
|
16
|
+
);
|
|
17
|
+
z.displayName = "Carousel.Item";
|
|
18
|
+
const B = T(
|
|
19
|
+
({
|
|
20
|
+
children: g,
|
|
21
|
+
activeIndex: b,
|
|
22
|
+
defaultActiveIndex: w = 0,
|
|
23
|
+
autoplay: c = !1,
|
|
24
|
+
autoplaySpeed: p = 3e3,
|
|
25
|
+
speed: h = 500,
|
|
26
|
+
arrows: K = !0,
|
|
27
|
+
dots: d = !0,
|
|
28
|
+
dotPlacement: F = "bottom",
|
|
29
|
+
effect: $ = "scrollx",
|
|
30
|
+
infinite: v = !0,
|
|
31
|
+
pauseOnHover: I = !0,
|
|
32
|
+
vertical: a = !1,
|
|
33
|
+
beforeChange: A,
|
|
34
|
+
afterChange: x,
|
|
35
|
+
className: G = "",
|
|
36
|
+
"data-testid": r,
|
|
37
|
+
...U
|
|
38
|
+
}, V) => {
|
|
39
|
+
const C = b !== void 0, [X, Y] = D(w), o = C ? b : X, [S, E] = D(!1), [M, j] = D(!1), _ = L(null), k = L(null), N = re.toArray(g).filter(ne), l = N.length, u = y(
|
|
40
|
+
(e, t = !0) => {
|
|
41
|
+
if (M || l === 0) return;
|
|
42
|
+
let s = e;
|
|
43
|
+
v ? s = (e % l + l) % l : s = Math.max(0, Math.min(e, l - 1)), s !== o && (A?.(o, s), t ? (j(!0), setTimeout(() => {
|
|
44
|
+
j(!1), x?.(s);
|
|
45
|
+
}, h)) : x?.(s), C || Y(s));
|
|
46
|
+
},
|
|
47
|
+
[o, l, v, C, A, x, h, M]
|
|
48
|
+
), n = y(() => {
|
|
49
|
+
u(o + 1);
|
|
50
|
+
}, [u, o]), f = y(() => {
|
|
51
|
+
u(o - 1);
|
|
52
|
+
}, [u, o]);
|
|
53
|
+
ie(V, () => ({
|
|
54
|
+
goTo: (e, t = !0) => u(e, t),
|
|
55
|
+
next: n,
|
|
56
|
+
prev: f
|
|
57
|
+
})), ce(() => (c && !S && l > 1 && (k.current = setInterval(() => {
|
|
58
|
+
n();
|
|
59
|
+
}, p)), () => {
|
|
60
|
+
k.current && clearInterval(k.current);
|
|
61
|
+
}), [c, S, p, n, l]);
|
|
62
|
+
const q = y(
|
|
63
|
+
(e) => {
|
|
64
|
+
a ? e.key === "ArrowUp" ? (e.preventDefault(), f()) : e.key === "ArrowDown" && (e.preventDefault(), n()) : e.key === "ArrowLeft" ? (e.preventDefault(), f()) : e.key === "ArrowRight" && (e.preventDefault(), n());
|
|
65
|
+
},
|
|
66
|
+
[a, f, n]
|
|
67
|
+
), H = () => {
|
|
68
|
+
I && c && E(!0);
|
|
69
|
+
}, J = () => {
|
|
70
|
+
I && c && E(!1);
|
|
71
|
+
}, Q = [
|
|
72
|
+
"carousel",
|
|
73
|
+
a ? "carousel-vertical" : "",
|
|
74
|
+
G
|
|
75
|
+
].filter(Boolean).join(" "), W = (e) => $ === "fade" ? {
|
|
76
|
+
position: e === 0 ? "relative" : "absolute",
|
|
77
|
+
top: 0,
|
|
78
|
+
left: 0,
|
|
79
|
+
opacity: e === o ? 1 : 0,
|
|
80
|
+
transition: `opacity ${h}ms ease-in-out`,
|
|
81
|
+
zIndex: e === o ? 1 : 0
|
|
82
|
+
} : {}, Z = $ === "scrollx" ? {
|
|
83
|
+
display: "flex",
|
|
84
|
+
flexDirection: a ? "column" : "row",
|
|
85
|
+
transform: a ? `translateY(-${o * 100}%)` : `translateX(-${o * 100}%)`,
|
|
86
|
+
transition: `transform ${h}ms ease-in-out`,
|
|
87
|
+
height: a ? "100%" : void 0
|
|
88
|
+
} : {
|
|
89
|
+
position: "relative",
|
|
90
|
+
width: "100%",
|
|
91
|
+
height: "100%"
|
|
92
|
+
}, O = () => a ? { height: "100%", flexShrink: 0 } : {}, ee = {
|
|
93
|
+
top: "top-2 left-1/2 -translate-x-1/2 flex-row",
|
|
94
|
+
bottom: "bottom-2 left-1/2 -translate-x-1/2 flex-row",
|
|
95
|
+
start: "left-2 top-1/2 -translate-y-1/2 flex-col",
|
|
96
|
+
end: "right-2 top-1/2 -translate-y-1/2 flex-col"
|
|
97
|
+
}, te = d === !0 || typeof d == "object" && d !== null, oe = typeof d == "object" ? d.className : "", P = ({
|
|
98
|
+
direction: e,
|
|
99
|
+
onClick: t,
|
|
100
|
+
disabled: s
|
|
101
|
+
}) => {
|
|
102
|
+
const m = e === "prev", le = a ? m ? "top-2 left-1/2 -translate-x-1/2" : "bottom-2 left-1/2 -translate-x-1/2" : m ? "left-2 top-1/2 -translate-y-1/2" : "right-2 top-1/2 -translate-y-1/2", se = a ? m ? "▲" : "▼" : m ? "❮" : "❯";
|
|
103
|
+
return /* @__PURE__ */ i(
|
|
104
|
+
"button",
|
|
105
|
+
{
|
|
106
|
+
type: "button",
|
|
107
|
+
onClick: t,
|
|
108
|
+
disabled: s,
|
|
109
|
+
"aria-label": m ? "Previous slide" : "Next slide",
|
|
110
|
+
className: `absolute ${le} btn btn-circle btn-sm bg-base-100/80 hover:bg-base-100 border-none shadow-md z-10 disabled:opacity-50 disabled:cursor-not-allowed`,
|
|
111
|
+
"data-testid": r ? `${r}-${e}` : void 0,
|
|
112
|
+
children: se
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
};
|
|
116
|
+
return /* @__PURE__ */ R(
|
|
117
|
+
"div",
|
|
118
|
+
{
|
|
119
|
+
ref: _,
|
|
120
|
+
role: "region",
|
|
121
|
+
"aria-roledescription": "carousel",
|
|
122
|
+
"aria-label": "Image carousel",
|
|
123
|
+
tabIndex: 0,
|
|
124
|
+
onKeyDown: q,
|
|
125
|
+
onMouseEnter: H,
|
|
126
|
+
onMouseLeave: J,
|
|
127
|
+
className: `relative overflow-hidden focus:outline-none focus-visible:ring-2 focus-visible:ring-primary ${Q}`,
|
|
128
|
+
"data-testid": r,
|
|
129
|
+
"data-active-index": o,
|
|
130
|
+
...U,
|
|
131
|
+
children: [
|
|
132
|
+
/* @__PURE__ */ i(
|
|
133
|
+
"div",
|
|
134
|
+
{
|
|
135
|
+
className: $ === "fade" ? "relative w-full h-full" : a ? "h-full" : "",
|
|
136
|
+
style: Z,
|
|
137
|
+
"aria-live": "polite",
|
|
138
|
+
children: N.map((e, t) => {
|
|
139
|
+
const s = e;
|
|
140
|
+
return ue(s, {
|
|
141
|
+
key: t,
|
|
142
|
+
"aria-hidden": t !== o,
|
|
143
|
+
"aria-label": `Slide ${t + 1} of ${l}`,
|
|
144
|
+
style: {
|
|
145
|
+
...s.props.style,
|
|
146
|
+
...O(),
|
|
147
|
+
...W(t)
|
|
148
|
+
},
|
|
149
|
+
"data-testid": r ? `${r}-slide-${t}` : void 0
|
|
150
|
+
});
|
|
151
|
+
})
|
|
152
|
+
}
|
|
153
|
+
),
|
|
154
|
+
K && l > 1 && /* @__PURE__ */ R(ae, { children: [
|
|
155
|
+
/* @__PURE__ */ i(
|
|
156
|
+
P,
|
|
157
|
+
{
|
|
158
|
+
direction: "prev",
|
|
159
|
+
onClick: f,
|
|
160
|
+
disabled: !v && o === 0
|
|
161
|
+
}
|
|
162
|
+
),
|
|
163
|
+
/* @__PURE__ */ i(
|
|
164
|
+
P,
|
|
165
|
+
{
|
|
166
|
+
direction: "next",
|
|
167
|
+
onClick: n,
|
|
168
|
+
disabled: !v && o === l - 1
|
|
169
|
+
}
|
|
170
|
+
)
|
|
171
|
+
] }),
|
|
172
|
+
te && l > 1 && /* @__PURE__ */ i(
|
|
173
|
+
"div",
|
|
174
|
+
{
|
|
175
|
+
className: `absolute flex gap-2 ${ee[F]} ${oe || ""}`,
|
|
176
|
+
role: "tablist",
|
|
177
|
+
"aria-label": "Slide indicators",
|
|
178
|
+
"data-testid": r ? `${r}-dots` : void 0,
|
|
179
|
+
children: N.map((e, t) => /* @__PURE__ */ i(
|
|
180
|
+
"button",
|
|
181
|
+
{
|
|
182
|
+
type: "button",
|
|
183
|
+
role: "tab",
|
|
184
|
+
"aria-selected": t === o,
|
|
185
|
+
"aria-label": `Go to slide ${t + 1}`,
|
|
186
|
+
onClick: () => u(t),
|
|
187
|
+
className: `w-2 h-2 rounded-full transition-all ${t === o ? "bg-primary w-4" : "bg-base-content/30 hover:bg-base-content/50"}`,
|
|
188
|
+
"data-testid": r ? `${r}-dot-${t}` : void 0
|
|
189
|
+
},
|
|
190
|
+
t
|
|
191
|
+
))
|
|
192
|
+
}
|
|
193
|
+
)
|
|
194
|
+
]
|
|
195
|
+
}
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
);
|
|
199
|
+
B.displayName = "Carousel";
|
|
200
|
+
const de = B;
|
|
201
|
+
de.Item = z;
|
|
4
202
|
export {
|
|
5
|
-
|
|
6
|
-
o as CarouselItem
|
|
203
|
+
de as Carousel
|
|
7
204
|
};
|
|
8
205
|
//# sourceMappingURL=Carousel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Carousel.js","sources":["../../src/components/Carousel.tsx"],"sourcesContent":["import React from 'react'\n\nexport interface CarouselItemProps extends React.HTMLAttributes<HTMLDivElement> {\n id?: string\n children: React.ReactNode\n}\n\nexport const CarouselItem: React.FC<CarouselItemProps> = ({ id, children, className = '', ...rest }) => {\n return (\n <div id={id} className={`carousel-item ${className}`} {...rest}>\n {children}\n </div>\n )\n}\n\nexport interface CarouselProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode\n snap?: 'start' | 'center' | 'end'\n vertical?: boolean\n}\n\nexport const Carousel: React.FC<CarouselProps> & {\n Item: typeof CarouselItem\n} = ({ children, snap = 'start', vertical = false, className = '', ...rest }) => {\n const snapClass = snap === 'center' ? 'carousel-center' : snap === 'end' ? 'carousel-end' : ''\n const directionClass = vertical ? 'carousel-vertical' : ''\n\n return (\n <div className={`carousel ${snapClass} ${directionClass} ${className}`.trim()} {...rest}>\n {children}\n </div>\n )\n}\n\nCarousel.Item = CarouselItem\n"],"names":["CarouselItem","id","children","className","rest","jsx","Carousel","snap","vertical"],"mappings":";AAOO,MAAMA,IAA4C,CAAC,EAAE,IAAAC,GAAI,UAAAC,GAAU,WAAAC,IAAY,IAAI,GAAGC,QAEzF,gBAAAC,EAAC,SAAI,IAAAJ,GAAQ,WAAW,iBAAiBE,CAAS,IAAK,GAAGC,GACvD,UAAAF,EAAA,CACH,GAUSI,IAET,CAAC,EAAE,UAAAJ,GAAU,MAAAK,IAAO,SAAS,UAAAC,IAAW,IAAO,WAAAL,IAAY,IAAI,GAAGC,EAAA,MAKlE,gBAAAC,EAAC,OAAA,EAAI,WAAW,YAJAE,MAAS,WAAW,oBAAoBA,MAAS,QAAQ,iBAAiB,EAIrD,IAHhBC,IAAW,sBAAsB,EAGC,IAAIL,CAAS,GAAG,KAAA,GAAS,GAAGC,GAChF,UAAAF,GACH;AAIJI,EAAS,OAAON;"}
|
|
1
|
+
{"version":3,"file":"Carousel.js","sources":["../../src/components/Carousel.tsx"],"sourcesContent":["import React, {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n Children,\n cloneElement,\n isValidElement,\n} from 'react'\n\nexport type CarouselEffect = 'scrollx' | 'fade'\nexport type CarouselDotPlacement = 'top' | 'bottom' | 'start' | 'end'\n\nexport interface CarouselRef {\n goTo: (index: number, animate?: boolean) => void\n next: () => void\n prev: () => void\n}\n\nexport interface CarouselItemProps extends React.HTMLAttributes<HTMLDivElement> {\n 'data-testid'?: string\n children: React.ReactNode\n}\n\nconst CarouselItemComponent = forwardRef<HTMLDivElement, CarouselItemProps>(\n ({ children, className = '', 'data-testid': testId, ...rest }, ref) => {\n return (\n <div\n ref={ref}\n role=\"group\"\n aria-roledescription=\"slide\"\n className={`carousel-item w-full flex-shrink-0 ${className}`}\n data-testid={testId}\n {...rest}\n >\n {children}\n </div>\n )\n }\n)\n\nCarouselItemComponent.displayName = 'Carousel.Item'\n\nexport interface CarouselProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {\n /** Carousel slides */\n children: React.ReactNode\n /** Current slide index (controlled mode) */\n activeIndex?: number\n /** Default slide index (uncontrolled mode) */\n defaultActiveIndex?: number\n /** Auto-advance slides */\n autoplay?: boolean\n /** Autoplay interval in milliseconds */\n autoplaySpeed?: number\n /** Animation duration in milliseconds */\n speed?: number\n /** Show prev/next navigation arrows */\n arrows?: boolean\n /** Show slide indicator dots */\n dots?: boolean | { className?: string }\n /** Position of indicator dots */\n dotPlacement?: CarouselDotPlacement\n /** Transition effect */\n effect?: CarouselEffect\n /** Enable infinite looping */\n infinite?: boolean\n /** Pause autoplay on hover */\n pauseOnHover?: boolean\n /** Vertical carousel orientation */\n vertical?: boolean\n /** Callback before slide change */\n beforeChange?: (current: number, next: number) => void\n /** Callback after slide change */\n afterChange?: (current: number) => void\n /** Test ID for testing */\n 'data-testid'?: string\n}\n\nconst CarouselComponent = forwardRef<CarouselRef, CarouselProps>(\n (\n {\n children,\n activeIndex: controlledIndex,\n defaultActiveIndex = 0,\n autoplay = false,\n autoplaySpeed = 3000,\n speed = 500,\n arrows = true,\n dots = true,\n dotPlacement = 'bottom',\n effect = 'scrollx',\n infinite = true,\n pauseOnHover = true,\n vertical = false,\n beforeChange,\n afterChange,\n className = '',\n 'data-testid': testId,\n ...rest\n },\n ref\n ) => {\n const isControlled = controlledIndex !== undefined\n const [internalIndex, setInternalIndex] = useState(defaultActiveIndex)\n const currentIndex = isControlled ? controlledIndex : internalIndex\n\n const [isPaused, setIsPaused] = useState(false)\n const [isAnimating, setIsAnimating] = useState(false)\n const containerRef = useRef<HTMLDivElement>(null)\n const autoplayRef = useRef<NodeJS.Timeout | null>(null)\n\n const slides = Children.toArray(children).filter(isValidElement)\n const slideCount = slides.length\n\n const goTo = useCallback(\n (index: number, animate = true) => {\n if (isAnimating || slideCount === 0) return\n\n let targetIndex = index\n if (infinite) {\n targetIndex = ((index % slideCount) + slideCount) % slideCount\n } else {\n targetIndex = Math.max(0, Math.min(index, slideCount - 1))\n }\n\n if (targetIndex === currentIndex) return\n\n beforeChange?.(currentIndex, targetIndex)\n\n if (animate) {\n setIsAnimating(true)\n setTimeout(() => {\n setIsAnimating(false)\n afterChange?.(targetIndex)\n }, speed)\n } else {\n afterChange?.(targetIndex)\n }\n\n if (!isControlled) {\n setInternalIndex(targetIndex)\n }\n },\n [currentIndex, slideCount, infinite, isControlled, beforeChange, afterChange, speed, isAnimating]\n )\n\n const next = useCallback(() => {\n goTo(currentIndex + 1)\n }, [goTo, currentIndex])\n\n const prev = useCallback(() => {\n goTo(currentIndex - 1)\n }, [goTo, currentIndex])\n\n // Expose methods via ref\n useImperativeHandle(ref, () => ({\n goTo: (index: number, animate = true) => goTo(index, animate),\n next,\n prev,\n }))\n\n // Autoplay\n useEffect(() => {\n if (autoplay && !isPaused && slideCount > 1) {\n autoplayRef.current = setInterval(() => {\n next()\n }, autoplaySpeed)\n }\n\n return () => {\n if (autoplayRef.current) {\n clearInterval(autoplayRef.current)\n }\n }\n }, [autoplay, isPaused, autoplaySpeed, next, slideCount])\n\n // Keyboard navigation\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent) => {\n if (vertical) {\n if (e.key === 'ArrowUp') {\n e.preventDefault()\n prev()\n } else if (e.key === 'ArrowDown') {\n e.preventDefault()\n next()\n }\n } else {\n if (e.key === 'ArrowLeft') {\n e.preventDefault()\n prev()\n } else if (e.key === 'ArrowRight') {\n e.preventDefault()\n next()\n }\n }\n },\n [vertical, prev, next]\n )\n\n const handleMouseEnter = () => {\n if (pauseOnHover && autoplay) {\n setIsPaused(true)\n }\n }\n\n const handleMouseLeave = () => {\n if (pauseOnHover && autoplay) {\n setIsPaused(false)\n }\n }\n\n // Build carousel classes\n const carouselClasses = [\n 'carousel',\n vertical ? 'carousel-vertical' : '',\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n // Slide transform/opacity based on effect\n const getSlideStyle = (index: number): React.CSSProperties => {\n if (effect === 'fade') {\n return {\n position: index === 0 ? 'relative' : 'absolute',\n top: 0,\n left: 0,\n opacity: index === currentIndex ? 1 : 0,\n transition: `opacity ${speed}ms ease-in-out`,\n zIndex: index === currentIndex ? 1 : 0,\n }\n }\n return {}\n }\n\n // Container style for scrollx effect\n const trackStyle: React.CSSProperties =\n effect === 'scrollx'\n ? {\n display: 'flex',\n flexDirection: vertical ? 'column' : 'row',\n transform: vertical\n ? `translateY(-${currentIndex * 100}%)`\n : `translateX(-${currentIndex * 100}%)`,\n transition: `transform ${speed}ms ease-in-out`,\n height: vertical ? '100%' : undefined,\n }\n : {\n position: 'relative',\n width: '100%',\n height: '100%',\n }\n\n // Slide style - ensure proper sizing for vertical/horizontal\n const getSlideContainerStyle = (): React.CSSProperties => {\n if (vertical) {\n return { height: '100%', flexShrink: 0 }\n }\n return {}\n }\n\n // Dots placement classes\n const dotsPlacementClasses: Record<CarouselDotPlacement, string> = {\n top: 'top-2 left-1/2 -translate-x-1/2 flex-row',\n bottom: 'bottom-2 left-1/2 -translate-x-1/2 flex-row',\n start: 'left-2 top-1/2 -translate-y-1/2 flex-col',\n end: 'right-2 top-1/2 -translate-y-1/2 flex-col',\n }\n\n const showDots = dots === true || (typeof dots === 'object' && dots !== null)\n const dotsClassName = typeof dots === 'object' ? dots.className : ''\n\n // Arrow buttons\n const ArrowButton = ({\n direction,\n onClick,\n disabled,\n }: {\n direction: 'prev' | 'next'\n onClick: () => void\n disabled: boolean\n }) => {\n const isPrev = direction === 'prev'\n const positionClass = vertical\n ? isPrev\n ? 'top-2 left-1/2 -translate-x-1/2'\n : 'bottom-2 left-1/2 -translate-x-1/2'\n : isPrev\n ? 'left-2 top-1/2 -translate-y-1/2'\n : 'right-2 top-1/2 -translate-y-1/2'\n\n const arrowIcon = vertical\n ? isPrev\n ? '▲'\n : '▼'\n : isPrev\n ? '❮'\n : '❯'\n\n return (\n <button\n type=\"button\"\n onClick={onClick}\n disabled={disabled}\n aria-label={isPrev ? 'Previous slide' : 'Next slide'}\n className={`absolute ${positionClass} btn btn-circle btn-sm bg-base-100/80 hover:bg-base-100 border-none shadow-md z-10 disabled:opacity-50 disabled:cursor-not-allowed`}\n data-testid={testId ? `${testId}-${direction}` : undefined}\n >\n {arrowIcon}\n </button>\n )\n }\n\n return (\n <div\n ref={containerRef}\n role=\"region\"\n aria-roledescription=\"carousel\"\n aria-label=\"Image carousel\"\n tabIndex={0}\n onKeyDown={handleKeyDown}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n className={`relative overflow-hidden focus:outline-none focus-visible:ring-2 focus-visible:ring-primary ${carouselClasses}`}\n data-testid={testId}\n data-active-index={currentIndex}\n {...rest}\n >\n {/* Slides track */}\n <div\n className={effect === 'fade' ? 'relative w-full h-full' : vertical ? 'h-full' : ''}\n style={trackStyle}\n aria-live=\"polite\"\n >\n {slides.map((slide, index) => {\n const slideElement = slide as React.ReactElement<CarouselItemProps & { style?: React.CSSProperties }>\n return cloneElement(slideElement, {\n key: index,\n 'aria-hidden': index !== currentIndex,\n 'aria-label': `Slide ${index + 1} of ${slideCount}`,\n style: {\n ...slideElement.props.style,\n ...getSlideContainerStyle(),\n ...getSlideStyle(index),\n },\n 'data-testid': testId ? `${testId}-slide-${index}` : undefined,\n })\n })}\n </div>\n\n {/* Navigation arrows */}\n {arrows && slideCount > 1 && (\n <>\n <ArrowButton\n direction=\"prev\"\n onClick={prev}\n disabled={!infinite && currentIndex === 0}\n />\n <ArrowButton\n direction=\"next\"\n onClick={next}\n disabled={!infinite && currentIndex === slideCount - 1}\n />\n </>\n )}\n\n {/* Dot indicators */}\n {showDots && slideCount > 1 && (\n <div\n className={`absolute flex gap-2 ${dotsPlacementClasses[dotPlacement]} ${dotsClassName || ''}`}\n role=\"tablist\"\n aria-label=\"Slide indicators\"\n data-testid={testId ? `${testId}-dots` : undefined}\n >\n {slides.map((_, index) => (\n <button\n key={index}\n type=\"button\"\n role=\"tab\"\n aria-selected={index === currentIndex}\n aria-label={`Go to slide ${index + 1}`}\n onClick={() => goTo(index)}\n className={`w-2 h-2 rounded-full transition-all ${\n index === currentIndex\n ? 'bg-primary w-4'\n : 'bg-base-content/30 hover:bg-base-content/50'\n }`}\n data-testid={testId ? `${testId}-dot-${index}` : undefined}\n />\n ))}\n </div>\n )}\n </div>\n )\n }\n)\n\nCarouselComponent.displayName = 'Carousel'\n\n// Compound component type\ntype CarouselType = typeof CarouselComponent & {\n Item: typeof CarouselItemComponent\n}\n\nexport const Carousel = CarouselComponent as CarouselType\nCarousel.Item = CarouselItemComponent\n"],"names":["CarouselItemComponent","forwardRef","children","className","testId","rest","ref","jsx","CarouselComponent","controlledIndex","defaultActiveIndex","autoplay","autoplaySpeed","speed","arrows","dots","dotPlacement","effect","infinite","pauseOnHover","vertical","beforeChange","afterChange","isControlled","internalIndex","setInternalIndex","useState","currentIndex","isPaused","setIsPaused","isAnimating","setIsAnimating","containerRef","useRef","autoplayRef","slides","Children","isValidElement","slideCount","goTo","useCallback","index","animate","targetIndex","next","prev","useImperativeHandle","useEffect","handleKeyDown","handleMouseEnter","handleMouseLeave","carouselClasses","getSlideStyle","trackStyle","getSlideContainerStyle","dotsPlacementClasses","showDots","dotsClassName","ArrowButton","direction","onClick","disabled","isPrev","positionClass","arrowIcon","jsxs","slide","slideElement","cloneElement","Fragment","_","Carousel"],"mappings":";;AA0BA,MAAMA,IAAwBC;AAAA,EAC5B,CAAC,EAAE,UAAAC,GAAU,WAAAC,IAAY,IAAI,eAAeC,GAAQ,GAAGC,EAAA,GAAQC,MAE3D,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAAD;AAAA,MACA,MAAK;AAAA,MACL,wBAAqB;AAAA,MACrB,WAAW,sCAAsCH,CAAS;AAAA,MAC1D,eAAaC;AAAA,MACZ,GAAGC;AAAA,MAEH,UAAAH;AAAA,IAAA;AAAA,EAAA;AAIT;AAEAF,EAAsB,cAAc;AAqCpC,MAAMQ,IAAoBP;AAAA,EACxB,CACE;AAAA,IACE,UAAAC;AAAA,IACA,aAAaO;AAAA,IACb,oBAAAC,IAAqB;AAAA,IACrB,UAAAC,IAAW;AAAA,IACX,eAAAC,IAAgB;AAAA,IAChB,OAAAC,I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AAYS,MAAiBW,IAAa;AAAA,cAAA;AAAA,YAAA;AAAA,UACvD,GACF;AAAA,UAIDkB,MAAYlB,IAAa,KACxB,gBAAA/B;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAW,uBAAuBgD,GAAqBvC,CAAY,CAAC,IAAIyC,MAAiB,EAAE;AAAA,cAC3F,MAAK;AAAA,cACL,cAAW;AAAA,cACX,eAAarD,IAAS,GAAGA,CAAM,UAAU;AAAA,cAExC,UAAA+B,EAAO,IAAI,CAACmC,GAAG7B,MACd,gBAAAlC;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBAEC,MAAK;AAAA,kBACL,MAAK;AAAA,kBACL,iBAAekC,MAAUd;AAAA,kBACzB,cAAY,eAAec,IAAQ,CAAC;AAAA,kBACpC,SAAS,MAAMF,EAAKE,CAAK;AAAA,kBACzB,WAAW,uCACTA,MAAUd,IACN,mBACA,6CACN;AAAA,kBACA,eAAavB,IAAS,GAAGA,CAAM,QAAQqC,CAAK,KAAK;AAAA,gBAAA;AAAA,gBAX5CA;AAAA,cAAA,CAaR;AAAA,YAAA;AAAA,UAAA;AAAA,QACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEAjC,EAAkB,cAAc;AAOzB,MAAM+D,KAAW/D;AACxB+D,GAAS,OAAOvE;"}
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
export type DrawerPlacement = 'top' | 'right' | 'bottom' | 'left';
|
|
3
3
|
export type DrawerSize = 'default' | 'large' | number;
|
|
4
|
-
export interface
|
|
4
|
+
export interface DrawerPushConfig {
|
|
5
|
+
/** Distance to push parent drawer (default: 180) */
|
|
6
|
+
distance?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface DrawerProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
5
9
|
/** Drawer content */
|
|
6
10
|
children: React.ReactNode;
|
|
7
11
|
/** Whether the drawer is visible */
|
|
8
12
|
open?: boolean;
|
|
9
13
|
/** Callback when drawer is closed */
|
|
10
|
-
onClose?: () => void;
|
|
14
|
+
onClose?: (e?: React.MouseEvent | React.KeyboardEvent) => void;
|
|
15
|
+
/** Callback after open/close animation completes */
|
|
16
|
+
afterOpenChange?: (open: boolean) => void;
|
|
11
17
|
/** Drawer title */
|
|
12
18
|
title?: React.ReactNode;
|
|
13
19
|
/** Direction drawer slides from */
|
|
@@ -36,16 +42,40 @@ export interface DrawerProps {
|
|
|
36
42
|
rootClassName?: string;
|
|
37
43
|
/** Style for drawer panel */
|
|
38
44
|
style?: React.CSSProperties;
|
|
45
|
+
/** Style for drawer header */
|
|
46
|
+
headerStyle?: React.CSSProperties;
|
|
47
|
+
/** Style for drawer body/content area */
|
|
48
|
+
bodyStyle?: React.CSSProperties;
|
|
49
|
+
/** Style for drawer footer */
|
|
50
|
+
footerStyle?: React.CSSProperties;
|
|
51
|
+
/** Style for drawer wrapper (includes mask) */
|
|
52
|
+
rootStyle?: React.CSSProperties;
|
|
53
|
+
/** Style for mask/backdrop */
|
|
54
|
+
maskStyle?: React.CSSProperties;
|
|
39
55
|
/** z-index of drawer */
|
|
40
56
|
zIndex?: number;
|
|
41
57
|
/** Destroy content when closed */
|
|
42
58
|
destroyOnClose?: boolean;
|
|
59
|
+
/** Pre-render drawer content (keep in DOM even when closed) */
|
|
60
|
+
forceRender?: boolean;
|
|
43
61
|
/** Where to place initial focus */
|
|
44
62
|
initialFocus?: 'close' | 'content';
|
|
63
|
+
/** Show loading skeleton */
|
|
64
|
+
loading?: boolean;
|
|
65
|
+
/** Custom container for portal (false to disable portal) */
|
|
66
|
+
getContainer?: HTMLElement | (() => HTMLElement) | false;
|
|
67
|
+
/** Nested drawer push behavior */
|
|
68
|
+
push?: boolean | DrawerPushConfig;
|
|
69
|
+
/** Test ID for testing */
|
|
70
|
+
'data-testid'?: string;
|
|
71
|
+
}
|
|
72
|
+
export interface DrawerRef {
|
|
73
|
+
/** The drawer panel element */
|
|
74
|
+
nativeElement: HTMLDivElement | null;
|
|
45
75
|
}
|
|
46
76
|
/**
|
|
47
77
|
* Drawer - A panel that slides in from the edge of the screen.
|
|
48
78
|
* Use for forms, details, or task panels.
|
|
49
|
-
* For responsive sidebar navigation, use
|
|
79
|
+
* For responsive sidebar navigation, use ResponsiveDrawer instead.
|
|
50
80
|
*/
|
|
51
|
-
export declare
|
|
81
|
+
export declare const Drawer: React.ForwardRefExoticComponent<DrawerProps & React.RefAttributes<DrawerRef>>;
|