@expcat/tigercat-react 0.2.0 → 0.2.27
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/README.md +59 -0
- package/dist/{chunk-6DYS4PJT.mjs → chunk-2UVQIL26.mjs} +1 -1
- package/dist/chunk-4MMT4EJJ.mjs +78 -0
- package/dist/chunk-67EK62HG.mjs +65 -0
- package/dist/{chunk-VXHBQTZS.js → chunk-GY6D4XS3.js} +13 -5
- package/dist/chunk-GZPMLPRW.js +107 -0
- package/dist/{chunk-7JQ7LURS.mjs → chunk-H36CWHUP.mjs} +9 -4
- package/dist/chunk-HUZVBDHV.js +81 -0
- package/dist/chunk-JOHKSMJM.mjs +266 -0
- package/dist/{chunk-WEGU7O4J.mjs → chunk-KOLLAGRK.mjs} +1 -1
- package/dist/{chunk-IS7YOBR7.mjs → chunk-NDOYQK2R.mjs} +13 -5
- package/dist/{chunk-2DOPHSZP.js → chunk-OWUGXP6K.js} +8 -3
- package/dist/chunk-Q2GPRAF4.js +66 -0
- package/dist/{chunk-6PUSRC6S.js → chunk-T3GSXTDU.js} +2 -2
- package/dist/{chunk-UG3I4PCY.js → chunk-VR5OP4MO.js} +2 -2
- package/dist/chunk-X4F6NSI5.mjs +104 -0
- package/dist/chunk-Y6557RWE.mjs +62 -0
- package/dist/chunk-YIF5VX7K.mjs +158 -0
- package/dist/chunk-Z5DDULTA.js +72 -0
- package/dist/chunk-Z6G4HABF.js +272 -0
- package/dist/chunk-ZPWDDAFE.js +162 -0
- package/dist/components/Anchor.d.mts +38 -0
- package/dist/components/Anchor.d.ts +38 -0
- package/dist/components/Anchor.js +20 -0
- package/dist/components/Anchor.mjs +1 -0
- package/dist/components/AnchorLink.d.mts +23 -0
- package/dist/components/AnchorLink.d.ts +23 -0
- package/dist/components/AnchorLink.js +17 -0
- package/dist/components/AnchorLink.mjs +2 -0
- package/dist/components/AreaChart.js +5 -5
- package/dist/components/AreaChart.mjs +3 -3
- package/dist/components/BackTop.d.mts +21 -0
- package/dist/components/BackTop.d.ts +21 -0
- package/dist/components/BackTop.js +16 -0
- package/dist/components/BackTop.mjs +1 -0
- package/dist/components/BarChart.js +5 -5
- package/dist/components/BarChart.mjs +3 -3
- package/dist/components/Breadcrumb.d.mts +4 -0
- package/dist/components/Breadcrumb.d.ts +4 -0
- package/dist/components/Breadcrumb.js +3 -3
- package/dist/components/Breadcrumb.mjs +1 -1
- package/dist/components/BreadcrumbItem.js +3 -3
- package/dist/components/BreadcrumbItem.mjs +2 -2
- package/dist/components/Carousel.d.mts +26 -0
- package/dist/components/Carousel.d.ts +26 -0
- package/dist/components/Carousel.js +10 -0
- package/dist/components/Carousel.mjs +1 -0
- package/dist/components/Collapse.d.mts +29 -0
- package/dist/components/Collapse.d.ts +29 -0
- package/dist/components/Collapse.js +20 -0
- package/dist/components/Collapse.mjs +1 -0
- package/dist/components/CollapsePanel.d.mts +24 -0
- package/dist/components/CollapsePanel.d.ts +24 -0
- package/dist/components/CollapsePanel.js +17 -0
- package/dist/components/CollapsePanel.mjs +2 -0
- package/dist/components/DonutChart.js +5 -5
- package/dist/components/DonutChart.mjs +3 -3
- package/dist/components/LineChart.js +5 -5
- package/dist/components/LineChart.mjs +3 -3
- package/dist/components/Pagination.js +3 -3
- package/dist/components/Pagination.mjs +1 -1
- package/dist/components/PieChart.js +4 -4
- package/dist/components/PieChart.mjs +2 -2
- package/dist/components/RadarChart.js +4 -4
- package/dist/components/RadarChart.mjs +2 -2
- package/dist/components/ScatterChart.js +5 -5
- package/dist/components/ScatterChart.mjs +3 -3
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +142 -104
- package/dist/index.mjs +34 -28
- package/package.json +6 -2
- package/dist/{chunk-N32MAX4A.js → chunk-2VXA4YOP.js} +1 -1
- package/dist/{chunk-VBSK4TGO.mjs → chunk-2WLSB7K2.mjs} +2 -2
- package/dist/{chunk-CBALIFPW.mjs → chunk-324UKFG2.mjs} +2 -2
- package/dist/{chunk-YER7IQF4.mjs → chunk-5QKBBGIA.mjs} +1 -1
- package/dist/{chunk-OONM7FO7.js → chunk-67WZRMD6.js} +2 -2
- package/dist/{chunk-QI6WAP6Y.js → chunk-7SOL3UJ2.js} +2 -2
- package/dist/{chunk-KBGURVTD.mjs → chunk-AFFSBNYB.mjs} +2 -2
- package/dist/{chunk-LZNG2HGC.mjs → chunk-E6GLWHRL.mjs} +1 -1
- package/dist/{chunk-ZUUG3WOL.js → chunk-KKHKQP6Z.js} +1 -1
- package/dist/{chunk-EJLJYOO7.js → chunk-LWW2LXCP.js} +2 -2
- package/dist/{chunk-A2UW5OKX.mjs → chunk-RKBNIEGF.mjs} +2 -2
- package/dist/{chunk-42UKIFFQ.js → chunk-ZYF5GI2Q.js} +2 -2
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import React, { forwardRef, useState, useRef, useMemo, useCallback, useImperativeHandle, useEffect } from 'react';
|
|
2
|
+
import { classNames, getCarouselContainerClasses, carouselTrackFadeClasses, carouselTrackScrollClasses, getScrollTransform, carouselSlideBaseClasses, getCarouselDotsClasses, clampSlideIndex, getNextSlideIndex, getPrevSlideIndex, isPrevDisabled, isNextDisabled, getCarouselArrowClasses, carouselPrevArrowPath, carouselNextArrowPath, getCarouselDotClasses } from '@expcat/tigercat-core';
|
|
3
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
// src/components/Carousel.tsx
|
|
6
|
+
var Carousel = forwardRef(
|
|
7
|
+
({
|
|
8
|
+
autoplay = false,
|
|
9
|
+
autoplaySpeed = 3e3,
|
|
10
|
+
dots = true,
|
|
11
|
+
dotPosition = "bottom",
|
|
12
|
+
effect = "scroll",
|
|
13
|
+
arrows = false,
|
|
14
|
+
infinite = true,
|
|
15
|
+
speed = 500,
|
|
16
|
+
initialSlide = 0,
|
|
17
|
+
pauseOnHover = true,
|
|
18
|
+
pauseOnFocus = true,
|
|
19
|
+
className,
|
|
20
|
+
style,
|
|
21
|
+
onChange,
|
|
22
|
+
onBeforeChange,
|
|
23
|
+
children
|
|
24
|
+
}, ref) => {
|
|
25
|
+
const [currentIndex, setCurrentIndex] = useState(initialSlide);
|
|
26
|
+
const [isPaused, setIsPaused] = useState(false);
|
|
27
|
+
const autoplayTimerRef = useRef(null);
|
|
28
|
+
const slides = useMemo(() => {
|
|
29
|
+
return React.Children.toArray(children).filter((child) => React.isValidElement(child));
|
|
30
|
+
}, [children]);
|
|
31
|
+
const slideCount = slides.length;
|
|
32
|
+
const containerClasses = useMemo(
|
|
33
|
+
() => classNames(getCarouselContainerClasses(className)),
|
|
34
|
+
[className]
|
|
35
|
+
);
|
|
36
|
+
const trackClasses = useMemo(() => {
|
|
37
|
+
if (effect === "fade") {
|
|
38
|
+
return carouselTrackFadeClasses;
|
|
39
|
+
}
|
|
40
|
+
return carouselTrackScrollClasses;
|
|
41
|
+
}, [effect]);
|
|
42
|
+
const trackStyle = useMemo(() => {
|
|
43
|
+
if (effect === "scroll") {
|
|
44
|
+
return {
|
|
45
|
+
transform: getScrollTransform(currentIndex),
|
|
46
|
+
transitionDuration: `${speed}ms`
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return {};
|
|
50
|
+
}, [effect, currentIndex, speed]);
|
|
51
|
+
const getSlideClasses = useCallback(
|
|
52
|
+
(index) => {
|
|
53
|
+
const isActive = index === currentIndex;
|
|
54
|
+
if (effect === "fade") {
|
|
55
|
+
const positionClass = index === 0 ? "relative" : "absolute inset-0";
|
|
56
|
+
return classNames(
|
|
57
|
+
positionClass,
|
|
58
|
+
"w-full transition-opacity ease-in-out",
|
|
59
|
+
isActive ? "opacity-100 z-10" : "opacity-0 z-0"
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
return carouselSlideBaseClasses;
|
|
63
|
+
},
|
|
64
|
+
[effect, currentIndex]
|
|
65
|
+
);
|
|
66
|
+
const getSlideStyle = useCallback(() => {
|
|
67
|
+
return {
|
|
68
|
+
transitionDuration: `${speed}ms`
|
|
69
|
+
};
|
|
70
|
+
}, [speed]);
|
|
71
|
+
const dotsClasses = useMemo(() => {
|
|
72
|
+
return getCarouselDotsClasses(dotPosition);
|
|
73
|
+
}, [dotPosition]);
|
|
74
|
+
const goTo = useCallback(
|
|
75
|
+
(index) => {
|
|
76
|
+
const clampedIndex = clampSlideIndex(index, slideCount);
|
|
77
|
+
if (clampedIndex === currentIndex) return;
|
|
78
|
+
onBeforeChange?.(currentIndex, clampedIndex);
|
|
79
|
+
const prevIndex = currentIndex;
|
|
80
|
+
setCurrentIndex(clampedIndex);
|
|
81
|
+
onChange?.(clampedIndex, prevIndex);
|
|
82
|
+
},
|
|
83
|
+
[currentIndex, slideCount, onBeforeChange, onChange]
|
|
84
|
+
);
|
|
85
|
+
const next = useCallback(() => {
|
|
86
|
+
const nextIdx = getNextSlideIndex(currentIndex, slideCount, infinite);
|
|
87
|
+
if (nextIdx !== currentIndex) {
|
|
88
|
+
goTo(nextIdx);
|
|
89
|
+
}
|
|
90
|
+
}, [currentIndex, slideCount, infinite, goTo]);
|
|
91
|
+
const prev = useCallback(() => {
|
|
92
|
+
const prevIdx = getPrevSlideIndex(currentIndex, slideCount, infinite);
|
|
93
|
+
if (prevIdx !== currentIndex) {
|
|
94
|
+
goTo(prevIdx);
|
|
95
|
+
}
|
|
96
|
+
}, [currentIndex, slideCount, infinite, goTo]);
|
|
97
|
+
useImperativeHandle(
|
|
98
|
+
ref,
|
|
99
|
+
() => ({
|
|
100
|
+
next,
|
|
101
|
+
prev,
|
|
102
|
+
goTo
|
|
103
|
+
}),
|
|
104
|
+
[next, prev, goTo]
|
|
105
|
+
);
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
if (autoplay && !isPaused) {
|
|
108
|
+
if (autoplayTimerRef.current) {
|
|
109
|
+
clearInterval(autoplayTimerRef.current);
|
|
110
|
+
}
|
|
111
|
+
autoplayTimerRef.current = setInterval(() => {
|
|
112
|
+
setCurrentIndex((prevIndex) => {
|
|
113
|
+
const nextIdx = getNextSlideIndex(prevIndex, slideCount, infinite);
|
|
114
|
+
if (nextIdx !== prevIndex) {
|
|
115
|
+
onBeforeChange?.(prevIndex, nextIdx);
|
|
116
|
+
onChange?.(nextIdx, prevIndex);
|
|
117
|
+
}
|
|
118
|
+
return nextIdx;
|
|
119
|
+
});
|
|
120
|
+
}, autoplaySpeed);
|
|
121
|
+
}
|
|
122
|
+
return () => {
|
|
123
|
+
if (autoplayTimerRef.current) {
|
|
124
|
+
clearInterval(autoplayTimerRef.current);
|
|
125
|
+
autoplayTimerRef.current = null;
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
}, [autoplay, autoplaySpeed, isPaused, slideCount, infinite, onChange, onBeforeChange]);
|
|
129
|
+
const handleMouseEnter = useCallback(() => {
|
|
130
|
+
if (pauseOnHover && autoplay) {
|
|
131
|
+
setIsPaused(true);
|
|
132
|
+
}
|
|
133
|
+
}, [pauseOnHover, autoplay]);
|
|
134
|
+
const handleMouseLeave = useCallback(() => {
|
|
135
|
+
if (pauseOnHover && autoplay) {
|
|
136
|
+
setIsPaused(false);
|
|
137
|
+
}
|
|
138
|
+
}, [pauseOnHover, autoplay]);
|
|
139
|
+
const handleFocus = useCallback(() => {
|
|
140
|
+
if (pauseOnFocus && autoplay) {
|
|
141
|
+
setIsPaused(true);
|
|
142
|
+
}
|
|
143
|
+
}, [pauseOnFocus, autoplay]);
|
|
144
|
+
const handleBlur = useCallback(() => {
|
|
145
|
+
if (pauseOnFocus && autoplay) {
|
|
146
|
+
setIsPaused(false);
|
|
147
|
+
}
|
|
148
|
+
}, [pauseOnFocus, autoplay]);
|
|
149
|
+
const isPrevArrowDisabled = useMemo(
|
|
150
|
+
() => isPrevDisabled(currentIndex, slideCount, infinite),
|
|
151
|
+
[currentIndex, slideCount, infinite]
|
|
152
|
+
);
|
|
153
|
+
const isNextArrowDisabled = useMemo(
|
|
154
|
+
() => isNextDisabled(currentIndex, slideCount, infinite),
|
|
155
|
+
[currentIndex, slideCount, infinite]
|
|
156
|
+
);
|
|
157
|
+
const renderArrows = () => {
|
|
158
|
+
if (!arrows) return null;
|
|
159
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
160
|
+
/* @__PURE__ */ jsx(
|
|
161
|
+
"button",
|
|
162
|
+
{
|
|
163
|
+
type: "button",
|
|
164
|
+
className: getCarouselArrowClasses("prev", isPrevArrowDisabled),
|
|
165
|
+
onClick: prev,
|
|
166
|
+
disabled: isPrevArrowDisabled,
|
|
167
|
+
"aria-label": "Previous slide",
|
|
168
|
+
children: /* @__PURE__ */ jsx(
|
|
169
|
+
"svg",
|
|
170
|
+
{
|
|
171
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
172
|
+
viewBox: "0 0 24 24",
|
|
173
|
+
fill: "none",
|
|
174
|
+
stroke: "currentColor",
|
|
175
|
+
strokeWidth: "2",
|
|
176
|
+
strokeLinecap: "round",
|
|
177
|
+
strokeLinejoin: "round",
|
|
178
|
+
className: "w-6 h-6",
|
|
179
|
+
children: /* @__PURE__ */ jsx("path", { d: carouselPrevArrowPath })
|
|
180
|
+
}
|
|
181
|
+
)
|
|
182
|
+
}
|
|
183
|
+
),
|
|
184
|
+
/* @__PURE__ */ jsx(
|
|
185
|
+
"button",
|
|
186
|
+
{
|
|
187
|
+
type: "button",
|
|
188
|
+
className: getCarouselArrowClasses("next", isNextArrowDisabled),
|
|
189
|
+
onClick: next,
|
|
190
|
+
disabled: isNextArrowDisabled,
|
|
191
|
+
"aria-label": "Next slide",
|
|
192
|
+
children: /* @__PURE__ */ jsx(
|
|
193
|
+
"svg",
|
|
194
|
+
{
|
|
195
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
196
|
+
viewBox: "0 0 24 24",
|
|
197
|
+
fill: "none",
|
|
198
|
+
stroke: "currentColor",
|
|
199
|
+
strokeWidth: "2",
|
|
200
|
+
strokeLinecap: "round",
|
|
201
|
+
strokeLinejoin: "round",
|
|
202
|
+
className: "w-6 h-6",
|
|
203
|
+
children: /* @__PURE__ */ jsx("path", { d: carouselNextArrowPath })
|
|
204
|
+
}
|
|
205
|
+
)
|
|
206
|
+
}
|
|
207
|
+
)
|
|
208
|
+
] });
|
|
209
|
+
};
|
|
210
|
+
const renderDots = () => {
|
|
211
|
+
if (!dots || slideCount <= 1) return null;
|
|
212
|
+
return /* @__PURE__ */ jsx("div", { className: dotsClasses, role: "tablist", "aria-label": "Carousel navigation", children: slides.map((_, index) => /* @__PURE__ */ jsx(
|
|
213
|
+
"button",
|
|
214
|
+
{
|
|
215
|
+
type: "button",
|
|
216
|
+
className: getCarouselDotClasses(index === currentIndex),
|
|
217
|
+
onClick: () => goTo(index),
|
|
218
|
+
"aria-label": `Go to slide ${index + 1}`,
|
|
219
|
+
"aria-current": index === currentIndex ? "true" : "false"
|
|
220
|
+
},
|
|
221
|
+
index
|
|
222
|
+
)) });
|
|
223
|
+
};
|
|
224
|
+
const renderSlides = () => {
|
|
225
|
+
const slideElements = slides.map((slide, index) => /* @__PURE__ */ jsx(
|
|
226
|
+
"div",
|
|
227
|
+
{
|
|
228
|
+
className: getSlideClasses(index),
|
|
229
|
+
style: effect === "fade" ? getSlideStyle() : void 0,
|
|
230
|
+
role: "group",
|
|
231
|
+
"aria-roledescription": "slide",
|
|
232
|
+
"aria-label": `Slide ${index + 1} of ${slideCount}`,
|
|
233
|
+
"aria-hidden": index !== currentIndex,
|
|
234
|
+
children: slide
|
|
235
|
+
},
|
|
236
|
+
index
|
|
237
|
+
));
|
|
238
|
+
if (effect === "fade") {
|
|
239
|
+
return /* @__PURE__ */ jsx("div", { className: classNames(trackClasses, "h-full"), children: slideElements });
|
|
240
|
+
}
|
|
241
|
+
return /* @__PURE__ */ jsx("div", { className: trackClasses, style: trackStyle, children: slideElements });
|
|
242
|
+
};
|
|
243
|
+
return /* @__PURE__ */ jsxs(
|
|
244
|
+
"div",
|
|
245
|
+
{
|
|
246
|
+
className: containerClasses,
|
|
247
|
+
style,
|
|
248
|
+
role: "region",
|
|
249
|
+
"aria-roledescription": "carousel",
|
|
250
|
+
"aria-label": "Image carousel",
|
|
251
|
+
onMouseEnter: handleMouseEnter,
|
|
252
|
+
onMouseLeave: handleMouseLeave,
|
|
253
|
+
onFocus: handleFocus,
|
|
254
|
+
onBlur: handleBlur,
|
|
255
|
+
children: [
|
|
256
|
+
renderSlides(),
|
|
257
|
+
renderArrows(),
|
|
258
|
+
renderDots()
|
|
259
|
+
]
|
|
260
|
+
}
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
);
|
|
264
|
+
Carousel.displayName = "Carousel";
|
|
265
|
+
|
|
266
|
+
export { Carousel };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useBreadcrumbContext } from './chunk-
|
|
1
|
+
import { useBreadcrumbContext } from './chunk-H36CWHUP.mjs';
|
|
2
2
|
import { useMemo, useCallback } from 'react';
|
|
3
3
|
import { getBreadcrumbItemClasses, getBreadcrumbLinkClasses, getBreadcrumbSeparatorClasses, getSeparatorContent } from '@expcat/tigercat-core';
|
|
4
4
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
@@ -96,6 +96,18 @@ var Pagination = ({
|
|
|
96
96
|
},
|
|
97
97
|
[handleQuickJumperSubmit]
|
|
98
98
|
);
|
|
99
|
+
const normalizedPageSizeOptions = useMemo(() => {
|
|
100
|
+
return pageSizeOptions.map((option) => {
|
|
101
|
+
if (typeof option === "number") {
|
|
102
|
+
return {
|
|
103
|
+
value: option,
|
|
104
|
+
label: `${option} ${labels.itemsPerPageText}`
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
const label = option.label ?? `${option.value} ${labels.itemsPerPageText}`;
|
|
108
|
+
return { value: option.value, label };
|
|
109
|
+
});
|
|
110
|
+
}, [pageSizeOptions, labels.itemsPerPageText]);
|
|
99
111
|
const containerClasses = getPaginationContainerClasses(align, className);
|
|
100
112
|
const elements = [];
|
|
101
113
|
if (showTotal) {
|
|
@@ -231,11 +243,7 @@ var Pagination = ({
|
|
|
231
243
|
value: currentPageSize,
|
|
232
244
|
onChange: (e) => handlePageSizeChange(parseInt(e.target.value, 10)),
|
|
233
245
|
"aria-label": labels.itemsPerPageText,
|
|
234
|
-
children:
|
|
235
|
-
sizeOption,
|
|
236
|
-
" ",
|
|
237
|
-
labels.itemsPerPageText
|
|
238
|
-
] }, sizeOption))
|
|
246
|
+
children: normalizedPageSizeOptions.map((sizeOption) => /* @__PURE__ */ jsx("option", { value: sizeOption.value, children: sizeOption.label }, sizeOption.value))
|
|
239
247
|
},
|
|
240
248
|
"size-changer"
|
|
241
249
|
)
|
|
@@ -17,15 +17,20 @@ var Breadcrumb = ({
|
|
|
17
17
|
separator = "/",
|
|
18
18
|
className,
|
|
19
19
|
style,
|
|
20
|
+
extra,
|
|
20
21
|
children,
|
|
21
22
|
...props
|
|
22
23
|
}) => {
|
|
24
|
+
const hasExtra = Boolean(extra);
|
|
23
25
|
const containerClasses = React__default.default.useMemo(
|
|
24
|
-
() => tigercatCore.classNames(tigercatCore.breadcrumbContainerClasses, className),
|
|
25
|
-
[className]
|
|
26
|
+
() => tigercatCore.classNames(tigercatCore.breadcrumbContainerClasses, hasExtra && "w-full", className),
|
|
27
|
+
[className, hasExtra]
|
|
26
28
|
);
|
|
27
29
|
const contextValue = React__default.default.useMemo(() => ({ separator }), [separator]);
|
|
28
|
-
return /* @__PURE__ */ jsxRuntime.jsx(BreadcrumbContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.
|
|
30
|
+
return /* @__PURE__ */ jsxRuntime.jsx(BreadcrumbContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsxs("nav", { className: containerClasses, "aria-label": "Breadcrumb", style, ...props, children: [
|
|
31
|
+
/* @__PURE__ */ jsxRuntime.jsx("ol", { className: "flex items-center flex-wrap gap-2", children }),
|
|
32
|
+
hasExtra && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-auto flex items-center", children: extra })
|
|
33
|
+
] }) });
|
|
29
34
|
};
|
|
30
35
|
|
|
31
36
|
exports.Breadcrumb = Breadcrumb;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
var tigercatCore = require('@expcat/tigercat-core');
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
|
|
7
|
+
// src/components/Collapse.tsx
|
|
8
|
+
var CollapseContext = react.createContext(null);
|
|
9
|
+
function useCollapseContext() {
|
|
10
|
+
return react.useContext(CollapseContext);
|
|
11
|
+
}
|
|
12
|
+
var Collapse = ({
|
|
13
|
+
activeKey: controlledActiveKey,
|
|
14
|
+
defaultActiveKey,
|
|
15
|
+
accordion = false,
|
|
16
|
+
bordered = true,
|
|
17
|
+
expandIconPosition = "start",
|
|
18
|
+
ghost = false,
|
|
19
|
+
className,
|
|
20
|
+
style,
|
|
21
|
+
onChange,
|
|
22
|
+
children
|
|
23
|
+
}) => {
|
|
24
|
+
const [internalActiveKeys, setInternalActiveKeys] = react.useState(
|
|
25
|
+
tigercatCore.normalizeActiveKeys(defaultActiveKey)
|
|
26
|
+
);
|
|
27
|
+
const activeKeys = react.useMemo(() => {
|
|
28
|
+
return controlledActiveKey !== void 0 ? tigercatCore.normalizeActiveKeys(controlledActiveKey) : internalActiveKeys;
|
|
29
|
+
}, [controlledActiveKey, internalActiveKeys]);
|
|
30
|
+
const handlePanelClick = react.useCallback(
|
|
31
|
+
(key) => {
|
|
32
|
+
const newKeys = tigercatCore.togglePanelKey(key, activeKeys, accordion);
|
|
33
|
+
if (controlledActiveKey === void 0) {
|
|
34
|
+
setInternalActiveKeys(newKeys);
|
|
35
|
+
}
|
|
36
|
+
if (onChange) {
|
|
37
|
+
if (accordion) {
|
|
38
|
+
onChange(newKeys.length > 0 ? newKeys[0] : void 0);
|
|
39
|
+
} else {
|
|
40
|
+
onChange(newKeys);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
[activeKeys, accordion, controlledActiveKey, onChange]
|
|
45
|
+
);
|
|
46
|
+
const containerClasses = react.useMemo(() => {
|
|
47
|
+
return tigercatCore.classNames(tigercatCore.getCollapseContainerClasses(bordered, ghost, className));
|
|
48
|
+
}, [bordered, ghost, className]);
|
|
49
|
+
const contextValue = react.useMemo(
|
|
50
|
+
() => ({
|
|
51
|
+
activeKeys,
|
|
52
|
+
accordion,
|
|
53
|
+
expandIconPosition,
|
|
54
|
+
bordered,
|
|
55
|
+
ghost,
|
|
56
|
+
handlePanelClick
|
|
57
|
+
}),
|
|
58
|
+
[activeKeys, accordion, expandIconPosition, bordered, ghost, handlePanelClick]
|
|
59
|
+
);
|
|
60
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CollapseContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: containerClasses, style, role: "region", children }) });
|
|
61
|
+
};
|
|
62
|
+
var Collapse_default = Collapse;
|
|
63
|
+
|
|
64
|
+
exports.Collapse = Collapse;
|
|
65
|
+
exports.Collapse_default = Collapse_default;
|
|
66
|
+
exports.useCollapseContext = useCollapseContext;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkOWUGXP6K_js = require('./chunk-OWUGXP6K.js');
|
|
4
4
|
var react = require('react');
|
|
5
5
|
var tigercatCore = require('@expcat/tigercat-core');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
@@ -17,7 +17,7 @@ var BreadcrumbItem = ({
|
|
|
17
17
|
icon,
|
|
18
18
|
...props
|
|
19
19
|
}) => {
|
|
20
|
-
const breadcrumbContext =
|
|
20
|
+
const breadcrumbContext = chunkOWUGXP6K_js.useBreadcrumbContext();
|
|
21
21
|
const itemClasses = react.useMemo(
|
|
22
22
|
() => tigercatCore.getBreadcrumbItemClasses(current, className),
|
|
23
23
|
[current, className]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk2VXA4YOP_js = require('./chunk-2VXA4YOP.js');
|
|
4
4
|
var react = require('react');
|
|
5
5
|
var tigercatCore = require('@expcat/tigercat-core');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
@@ -60,7 +60,7 @@ var DonutChart = ({
|
|
|
60
60
|
return resolvedOuterRadius * ratio;
|
|
61
61
|
}, [innerRadius, innerRadiusRatio, resolvedOuterRadius]);
|
|
62
62
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
63
|
-
|
|
63
|
+
chunk2VXA4YOP_js.PieChart,
|
|
64
64
|
{
|
|
65
65
|
width,
|
|
66
66
|
height,
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { useCollapseContext } from './chunk-Y6557RWE.mjs';
|
|
2
|
+
import { useMemo, useCallback } from 'react';
|
|
3
|
+
import { isPanelActive, classNames, getCollapsePanelClasses, getCollapsePanelHeaderClasses, getCollapseIconClasses, collapseHeaderTextClasses, collapsePanelContentWrapperClasses, collapsePanelContentBaseClasses } from '@expcat/tigercat-core';
|
|
4
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
var CollapsePanel = ({
|
|
7
|
+
panelKey,
|
|
8
|
+
header,
|
|
9
|
+
disabled = false,
|
|
10
|
+
showArrow = true,
|
|
11
|
+
className,
|
|
12
|
+
style,
|
|
13
|
+
extra,
|
|
14
|
+
children
|
|
15
|
+
}) => {
|
|
16
|
+
const collapseContext = useCollapseContext();
|
|
17
|
+
if (!collapseContext) {
|
|
18
|
+
throw new Error("CollapsePanel must be used within a Collapse component");
|
|
19
|
+
}
|
|
20
|
+
const isActive = useMemo(() => {
|
|
21
|
+
return isPanelActive(panelKey, collapseContext.activeKeys);
|
|
22
|
+
}, [panelKey, collapseContext.activeKeys]);
|
|
23
|
+
const panelClasses = useMemo(() => {
|
|
24
|
+
return classNames(getCollapsePanelClasses(collapseContext.ghost, className));
|
|
25
|
+
}, [collapseContext.ghost, className]);
|
|
26
|
+
const headerClasses = useMemo(() => {
|
|
27
|
+
return getCollapsePanelHeaderClasses(isActive, disabled);
|
|
28
|
+
}, [isActive, disabled]);
|
|
29
|
+
const iconClasses = useMemo(() => {
|
|
30
|
+
return getCollapseIconClasses(isActive, collapseContext.expandIconPosition);
|
|
31
|
+
}, [isActive, collapseContext.expandIconPosition]);
|
|
32
|
+
const handleClick = useCallback(() => {
|
|
33
|
+
if (!disabled) {
|
|
34
|
+
collapseContext.handlePanelClick(panelKey);
|
|
35
|
+
}
|
|
36
|
+
}, [disabled, collapseContext, panelKey]);
|
|
37
|
+
const handleKeyDown = useCallback(
|
|
38
|
+
(event) => {
|
|
39
|
+
if (disabled) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
43
|
+
event.preventDefault();
|
|
44
|
+
collapseContext.handlePanelClick(panelKey);
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
[disabled, collapseContext, panelKey]
|
|
48
|
+
);
|
|
49
|
+
const arrowIcon = /* @__PURE__ */ jsx(
|
|
50
|
+
"svg",
|
|
51
|
+
{
|
|
52
|
+
className: iconClasses,
|
|
53
|
+
width: "16",
|
|
54
|
+
height: "16",
|
|
55
|
+
viewBox: "0 0 16 16",
|
|
56
|
+
fill: "none",
|
|
57
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
58
|
+
children: /* @__PURE__ */ jsx(
|
|
59
|
+
"path",
|
|
60
|
+
{
|
|
61
|
+
d: "M6 12L10 8L6 4",
|
|
62
|
+
stroke: "currentColor",
|
|
63
|
+
strokeWidth: "2",
|
|
64
|
+
strokeLinecap: "round",
|
|
65
|
+
strokeLinejoin: "round"
|
|
66
|
+
}
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
return /* @__PURE__ */ jsxs("div", { className: panelClasses, style, children: [
|
|
71
|
+
/* @__PURE__ */ jsxs(
|
|
72
|
+
"div",
|
|
73
|
+
{
|
|
74
|
+
className: headerClasses,
|
|
75
|
+
role: "button",
|
|
76
|
+
tabIndex: disabled ? -1 : 0,
|
|
77
|
+
"aria-expanded": isActive,
|
|
78
|
+
"aria-disabled": disabled,
|
|
79
|
+
onClick: handleClick,
|
|
80
|
+
onKeyDown: handleKeyDown,
|
|
81
|
+
children: [
|
|
82
|
+
showArrow && collapseContext.expandIconPosition === "start" && arrowIcon,
|
|
83
|
+
/* @__PURE__ */ jsx("span", { className: collapseHeaderTextClasses, children: header }),
|
|
84
|
+
extra && /* @__PURE__ */ jsx("span", { className: "ml-auto", children: extra }),
|
|
85
|
+
showArrow && collapseContext.expandIconPosition === "end" && arrowIcon
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
),
|
|
89
|
+
/* @__PURE__ */ jsx(
|
|
90
|
+
"div",
|
|
91
|
+
{
|
|
92
|
+
className: collapsePanelContentWrapperClasses,
|
|
93
|
+
style: {
|
|
94
|
+
maxHeight: isActive ? "none" : "0",
|
|
95
|
+
opacity: isActive ? "1" : "0"
|
|
96
|
+
},
|
|
97
|
+
children: /* @__PURE__ */ jsx("div", { className: collapsePanelContentBaseClasses, children })
|
|
98
|
+
}
|
|
99
|
+
)
|
|
100
|
+
] });
|
|
101
|
+
};
|
|
102
|
+
var CollapsePanel_default = CollapsePanel;
|
|
103
|
+
|
|
104
|
+
export { CollapsePanel, CollapsePanel_default };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { createContext, useContext, useState, useMemo, useCallback } from 'react';
|
|
2
|
+
import { normalizeActiveKeys, togglePanelKey, classNames, getCollapseContainerClasses } from '@expcat/tigercat-core';
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
// src/components/Collapse.tsx
|
|
6
|
+
var CollapseContext = createContext(null);
|
|
7
|
+
function useCollapseContext() {
|
|
8
|
+
return useContext(CollapseContext);
|
|
9
|
+
}
|
|
10
|
+
var Collapse = ({
|
|
11
|
+
activeKey: controlledActiveKey,
|
|
12
|
+
defaultActiveKey,
|
|
13
|
+
accordion = false,
|
|
14
|
+
bordered = true,
|
|
15
|
+
expandIconPosition = "start",
|
|
16
|
+
ghost = false,
|
|
17
|
+
className,
|
|
18
|
+
style,
|
|
19
|
+
onChange,
|
|
20
|
+
children
|
|
21
|
+
}) => {
|
|
22
|
+
const [internalActiveKeys, setInternalActiveKeys] = useState(
|
|
23
|
+
normalizeActiveKeys(defaultActiveKey)
|
|
24
|
+
);
|
|
25
|
+
const activeKeys = useMemo(() => {
|
|
26
|
+
return controlledActiveKey !== void 0 ? normalizeActiveKeys(controlledActiveKey) : internalActiveKeys;
|
|
27
|
+
}, [controlledActiveKey, internalActiveKeys]);
|
|
28
|
+
const handlePanelClick = useCallback(
|
|
29
|
+
(key) => {
|
|
30
|
+
const newKeys = togglePanelKey(key, activeKeys, accordion);
|
|
31
|
+
if (controlledActiveKey === void 0) {
|
|
32
|
+
setInternalActiveKeys(newKeys);
|
|
33
|
+
}
|
|
34
|
+
if (onChange) {
|
|
35
|
+
if (accordion) {
|
|
36
|
+
onChange(newKeys.length > 0 ? newKeys[0] : void 0);
|
|
37
|
+
} else {
|
|
38
|
+
onChange(newKeys);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
[activeKeys, accordion, controlledActiveKey, onChange]
|
|
43
|
+
);
|
|
44
|
+
const containerClasses = useMemo(() => {
|
|
45
|
+
return classNames(getCollapseContainerClasses(bordered, ghost, className));
|
|
46
|
+
}, [bordered, ghost, className]);
|
|
47
|
+
const contextValue = useMemo(
|
|
48
|
+
() => ({
|
|
49
|
+
activeKeys,
|
|
50
|
+
accordion,
|
|
51
|
+
expandIconPosition,
|
|
52
|
+
bordered,
|
|
53
|
+
ghost,
|
|
54
|
+
handlePanelClick
|
|
55
|
+
}),
|
|
56
|
+
[activeKeys, accordion, expandIconPosition, bordered, ghost, handlePanelClick]
|
|
57
|
+
);
|
|
58
|
+
return /* @__PURE__ */ jsx(CollapseContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx("div", { className: containerClasses, style, role: "region", children }) });
|
|
59
|
+
};
|
|
60
|
+
var Collapse_default = Collapse;
|
|
61
|
+
|
|
62
|
+
export { Collapse, Collapse_default, useCollapseContext };
|