@cupcodev/ui 1.0.0 → 1.0.2
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 +10 -10
- package/dist/charts 2.cjs +500 -0
- package/dist/charts 2.js +454 -0
- package/dist/charts-KwYmX5He.d 2.cts +97 -0
- package/dist/charts-KwYmX5He.d 2.ts +97 -0
- package/dist/charts.cjs 2.map +1 -0
- package/dist/charts.d 2.cts +11 -0
- package/dist/charts.d 2.ts +11 -0
- package/dist/charts.js 2.map +1 -0
- package/dist/index 2.cjs +6568 -0
- package/dist/index 2.js +6207 -0
- package/dist/index.cjs 2.map +1 -0
- package/dist/index.d 2.cts +1019 -0
- package/dist/index.d 2.ts +1019 -0
- package/dist/index.js 2.map +1 -0
- package/package.json +2 -1
- package/styles/dock.css +130 -73
- package/styles/global.css +10 -9
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
## @
|
|
1
|
+
## @cupcodev/ui
|
|
2
2
|
|
|
3
3
|
Design system Cupcode pronto para uso (componentes React + estilos + presets Tailwind).
|
|
4
4
|
|
|
5
5
|
### Instalação
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install @
|
|
8
|
+
npm install @cupcodev/ui
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
Além do pacote, instale as peer dependencies listadas em `peerDependencies` (React 18, Tailwind 3, Radix UI, etc.). Um comando típico:
|
|
@@ -29,10 +29,10 @@ Use o preset disponibilizado pelo pacote:
|
|
|
29
29
|
```js
|
|
30
30
|
// tailwind.config.js
|
|
31
31
|
module.exports = {
|
|
32
|
-
presets: [require("@
|
|
32
|
+
presets: [require("@cupcodev/ui/tailwind-preset.cjs")],
|
|
33
33
|
content: [
|
|
34
34
|
"./src/**/*.{ts,tsx}", // ajuste para o seu projeto
|
|
35
|
-
"./node_modules/@
|
|
35
|
+
"./node_modules/@cupcodev/ui/dist/**/*.{js,jsx}", // necessário para as classes dos componentes
|
|
36
36
|
],
|
|
37
37
|
};
|
|
38
38
|
```
|
|
@@ -40,26 +40,26 @@ module.exports = {
|
|
|
40
40
|
E importe os estilos globais (tokens + reset):
|
|
41
41
|
|
|
42
42
|
```ts
|
|
43
|
-
import "@
|
|
43
|
+
import "@cupcodev/ui/styles/global.css";
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
### Uso básico
|
|
47
47
|
|
|
48
48
|
```tsx
|
|
49
|
-
import { Button } from "@
|
|
49
|
+
import { Button } from "@cupcodev/ui";
|
|
50
50
|
|
|
51
51
|
export default function Example() {
|
|
52
52
|
return <Button variant="default">Oi Cupcode</Button>;
|
|
53
53
|
}
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
-
Todos os componentes Cupcode e shadcn/ui base são reexportados de `@
|
|
56
|
+
Todos os componentes Cupcode e shadcn/ui base são reexportados de `@cupcodev/ui`. Exemplo:
|
|
57
57
|
|
|
58
58
|
```ts
|
|
59
|
-
import { NavbarCupcode, ThemeToggle, Card } from "@
|
|
59
|
+
import { NavbarCupcode, ThemeToggle, Card } from "@cupcodev/ui";
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
Para importações segmentadas, há submódulos como `@
|
|
62
|
+
Para importações segmentadas, há submódulos como `@cupcodev/ui/charts`, que expõe apenas os componentes de gráficos/carrossel.
|
|
63
63
|
|
|
64
64
|
### Tema / Dark mode
|
|
65
65
|
|
|
@@ -96,4 +96,4 @@ Consulte `peerDependencies` para a lista completa ao instalar.
|
|
|
96
96
|
|
|
97
97
|
### Tipos e superfícies
|
|
98
98
|
|
|
99
|
-
Os componentes são exportados via `export { Component }` (ex.: `export { default as DockWrapper }`). Importe sempre de `@
|
|
99
|
+
Os componentes são exportados via `export { Component }` (ex.: `export { default as DockWrapper }`). Importe sempre de `@cupcodev/ui` para garantir que os tipos e estilos correspondentes estejam alinhados.
|
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/charts.ts
|
|
30
|
+
var charts_exports = {};
|
|
31
|
+
__export(charts_exports, {
|
|
32
|
+
Carousel: () => Carousel,
|
|
33
|
+
CarouselContent: () => CarouselContent,
|
|
34
|
+
CarouselItem: () => CarouselItem,
|
|
35
|
+
CarouselNext: () => CarouselNext,
|
|
36
|
+
CarouselPrevious: () => CarouselPrevious,
|
|
37
|
+
ChartContainer: () => ChartContainer,
|
|
38
|
+
ChartLegend: () => ChartLegend,
|
|
39
|
+
ChartLegendContent: () => ChartLegendContent,
|
|
40
|
+
ChartStyle: () => ChartStyle,
|
|
41
|
+
ChartTooltip: () => ChartTooltip,
|
|
42
|
+
ChartTooltipContent: () => ChartTooltipContent
|
|
43
|
+
});
|
|
44
|
+
module.exports = __toCommonJS(charts_exports);
|
|
45
|
+
|
|
46
|
+
// src/components/ui/chart.tsx
|
|
47
|
+
var React = __toESM(require("react"), 1);
|
|
48
|
+
var RechartsPrimitive = __toESM(require("recharts"), 1);
|
|
49
|
+
|
|
50
|
+
// src/lib/utils.ts
|
|
51
|
+
var import_clsx = require("clsx");
|
|
52
|
+
var import_tailwind_merge = require("tailwind-merge");
|
|
53
|
+
function cn(...inputs) {
|
|
54
|
+
return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// src/components/ui/chart.tsx
|
|
58
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
59
|
+
var THEMES = { light: "", dark: ".dark" };
|
|
60
|
+
var ChartContext = React.createContext(null);
|
|
61
|
+
function useChart() {
|
|
62
|
+
const context = React.useContext(ChartContext);
|
|
63
|
+
if (!context) {
|
|
64
|
+
throw new Error("useChart must be used within a <ChartContainer />");
|
|
65
|
+
}
|
|
66
|
+
return context;
|
|
67
|
+
}
|
|
68
|
+
var ChartContainer = React.forwardRef(({ id, className, children, config, ...props }, ref) => {
|
|
69
|
+
const uniqueId = React.useId();
|
|
70
|
+
const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
|
|
71
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChartContext.Provider, { value: { config }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
72
|
+
"div",
|
|
73
|
+
{
|
|
74
|
+
"data-chart": chartId,
|
|
75
|
+
ref,
|
|
76
|
+
className: cn(
|
|
77
|
+
"flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",
|
|
78
|
+
className
|
|
79
|
+
),
|
|
80
|
+
...props,
|
|
81
|
+
children: [
|
|
82
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChartStyle, { id: chartId, config }),
|
|
83
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(RechartsPrimitive.ResponsiveContainer, { children })
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
) });
|
|
87
|
+
});
|
|
88
|
+
ChartContainer.displayName = "Chart";
|
|
89
|
+
var ChartStyle = ({ id, config }) => {
|
|
90
|
+
const colorConfig = Object.entries(config).filter(([_, config2]) => config2.theme || config2.color);
|
|
91
|
+
if (!colorConfig.length) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
95
|
+
"style",
|
|
96
|
+
{
|
|
97
|
+
dangerouslySetInnerHTML: {
|
|
98
|
+
__html: Object.entries(THEMES).map(
|
|
99
|
+
([theme, prefix]) => `
|
|
100
|
+
${prefix} [data-chart=${id}] {
|
|
101
|
+
${colorConfig.map(([key, itemConfig]) => {
|
|
102
|
+
var _a;
|
|
103
|
+
const color = ((_a = itemConfig.theme) == null ? void 0 : _a[theme]) || itemConfig.color;
|
|
104
|
+
return color ? ` --color-${key}: ${color};` : null;
|
|
105
|
+
}).join("\n")}
|
|
106
|
+
}
|
|
107
|
+
`
|
|
108
|
+
).join("\n")
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
var ChartTooltip = RechartsPrimitive.Tooltip;
|
|
114
|
+
var ChartTooltipContent = React.forwardRef(
|
|
115
|
+
({
|
|
116
|
+
active,
|
|
117
|
+
payload,
|
|
118
|
+
className,
|
|
119
|
+
indicator = "dot",
|
|
120
|
+
hideLabel = false,
|
|
121
|
+
hideIndicator = false,
|
|
122
|
+
label,
|
|
123
|
+
labelFormatter,
|
|
124
|
+
labelClassName,
|
|
125
|
+
formatter,
|
|
126
|
+
color,
|
|
127
|
+
nameKey,
|
|
128
|
+
labelKey
|
|
129
|
+
}, ref) => {
|
|
130
|
+
const { config } = useChart();
|
|
131
|
+
const tooltipLabel = React.useMemo(() => {
|
|
132
|
+
var _a;
|
|
133
|
+
if (hideLabel || !(payload == null ? void 0 : payload.length)) {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
const [item] = payload;
|
|
137
|
+
const key = `${labelKey || item.dataKey || item.name || "value"}`;
|
|
138
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
139
|
+
const value = !labelKey && typeof label === "string" ? ((_a = config[label]) == null ? void 0 : _a.label) || label : itemConfig == null ? void 0 : itemConfig.label;
|
|
140
|
+
if (labelFormatter) {
|
|
141
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: cn("font-medium", labelClassName), children: labelFormatter(value, payload) });
|
|
142
|
+
}
|
|
143
|
+
if (!value) {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: cn("font-medium", labelClassName), children: value });
|
|
147
|
+
}, [label, labelFormatter, payload, hideLabel, labelClassName, config, labelKey]);
|
|
148
|
+
if (!active || !(payload == null ? void 0 : payload.length)) {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
const nestLabel = payload.length === 1 && indicator !== "dot";
|
|
152
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
153
|
+
"div",
|
|
154
|
+
{
|
|
155
|
+
ref,
|
|
156
|
+
className: cn(
|
|
157
|
+
"grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",
|
|
158
|
+
className
|
|
159
|
+
),
|
|
160
|
+
children: [
|
|
161
|
+
!nestLabel ? tooltipLabel : null,
|
|
162
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "grid gap-1.5", children: payload.map((item, index) => {
|
|
163
|
+
const key = `${nameKey || item.name || item.dataKey || "value"}`;
|
|
164
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
165
|
+
const indicatorColor = color || item.payload.fill || item.color;
|
|
166
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
167
|
+
"div",
|
|
168
|
+
{
|
|
169
|
+
className: cn(
|
|
170
|
+
"flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",
|
|
171
|
+
indicator === "dot" && "items-center"
|
|
172
|
+
),
|
|
173
|
+
children: formatter && (item == null ? void 0 : item.value) !== void 0 && item.name ? formatter(item.value, item.name, item, index, item.payload) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
174
|
+
(itemConfig == null ? void 0 : itemConfig.icon) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(itemConfig.icon, {}) : !hideIndicator && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
175
|
+
"div",
|
|
176
|
+
{
|
|
177
|
+
className: cn("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]", {
|
|
178
|
+
"h-2.5 w-2.5": indicator === "dot",
|
|
179
|
+
"w-1": indicator === "line",
|
|
180
|
+
"w-0 border-[1.5px] border-dashed bg-transparent": indicator === "dashed",
|
|
181
|
+
"my-0.5": nestLabel && indicator === "dashed"
|
|
182
|
+
}),
|
|
183
|
+
style: {
|
|
184
|
+
"--color-bg": indicatorColor,
|
|
185
|
+
"--color-border": indicatorColor
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
),
|
|
189
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
190
|
+
"div",
|
|
191
|
+
{
|
|
192
|
+
className: cn(
|
|
193
|
+
"flex flex-1 justify-between leading-none",
|
|
194
|
+
nestLabel ? "items-end" : "items-center"
|
|
195
|
+
),
|
|
196
|
+
children: [
|
|
197
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "grid gap-1.5", children: [
|
|
198
|
+
nestLabel ? tooltipLabel : null,
|
|
199
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-muted-foreground", children: (itemConfig == null ? void 0 : itemConfig.label) || item.name })
|
|
200
|
+
] }),
|
|
201
|
+
item.value && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "font-mono font-medium tabular-nums text-foreground", children: item.value.toLocaleString() })
|
|
202
|
+
]
|
|
203
|
+
}
|
|
204
|
+
)
|
|
205
|
+
] })
|
|
206
|
+
},
|
|
207
|
+
item.dataKey
|
|
208
|
+
);
|
|
209
|
+
}) })
|
|
210
|
+
]
|
|
211
|
+
}
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
);
|
|
215
|
+
ChartTooltipContent.displayName = "ChartTooltip";
|
|
216
|
+
var ChartLegend = RechartsPrimitive.Legend;
|
|
217
|
+
var ChartLegendContent = React.forwardRef(({ className, hideIcon = false, payload, verticalAlign = "bottom", nameKey }, ref) => {
|
|
218
|
+
const { config } = useChart();
|
|
219
|
+
if (!(payload == null ? void 0 : payload.length)) {
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
223
|
+
"div",
|
|
224
|
+
{
|
|
225
|
+
ref,
|
|
226
|
+
className: cn("flex items-center justify-center gap-4", verticalAlign === "top" ? "pb-3" : "pt-3", className),
|
|
227
|
+
children: payload.map((item) => {
|
|
228
|
+
const key = `${nameKey || item.dataKey || "value"}`;
|
|
229
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
230
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
231
|
+
"div",
|
|
232
|
+
{
|
|
233
|
+
className: cn("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),
|
|
234
|
+
children: [
|
|
235
|
+
(itemConfig == null ? void 0 : itemConfig.icon) && !hideIcon ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(itemConfig.icon, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
236
|
+
"div",
|
|
237
|
+
{
|
|
238
|
+
className: "h-2 w-2 shrink-0 rounded-[2px]",
|
|
239
|
+
style: {
|
|
240
|
+
backgroundColor: item.color
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
),
|
|
244
|
+
itemConfig == null ? void 0 : itemConfig.label
|
|
245
|
+
]
|
|
246
|
+
},
|
|
247
|
+
item.value
|
|
248
|
+
);
|
|
249
|
+
})
|
|
250
|
+
}
|
|
251
|
+
);
|
|
252
|
+
});
|
|
253
|
+
ChartLegendContent.displayName = "ChartLegend";
|
|
254
|
+
function getPayloadConfigFromPayload(config, payload, key) {
|
|
255
|
+
if (typeof payload !== "object" || payload === null) {
|
|
256
|
+
return void 0;
|
|
257
|
+
}
|
|
258
|
+
const payloadPayload = "payload" in payload && typeof payload.payload === "object" && payload.payload !== null ? payload.payload : void 0;
|
|
259
|
+
let configLabelKey = key;
|
|
260
|
+
if (key in payload && typeof payload[key] === "string") {
|
|
261
|
+
configLabelKey = payload[key];
|
|
262
|
+
} else if (payloadPayload && key in payloadPayload && typeof payloadPayload[key] === "string") {
|
|
263
|
+
configLabelKey = payloadPayload[key];
|
|
264
|
+
}
|
|
265
|
+
return configLabelKey in config ? config[configLabelKey] : config[key];
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// src/components/ui/carousel.tsx
|
|
269
|
+
var React3 = __toESM(require("react"), 1);
|
|
270
|
+
var import_embla_carousel_react = __toESM(require("embla-carousel-react"), 1);
|
|
271
|
+
var import_lucide_react = require("lucide-react");
|
|
272
|
+
|
|
273
|
+
// src/components/ui/button.tsx
|
|
274
|
+
var React2 = __toESM(require("react"), 1);
|
|
275
|
+
var import_react_slot = require("@radix-ui/react-slot");
|
|
276
|
+
var import_class_variance_authority = require("class-variance-authority");
|
|
277
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
278
|
+
var buttonVariants = (0, import_class_variance_authority.cva)(
|
|
279
|
+
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
|
280
|
+
{
|
|
281
|
+
variants: {
|
|
282
|
+
variant: {
|
|
283
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
284
|
+
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
285
|
+
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
|
286
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
287
|
+
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
288
|
+
link: "text-primary underline-offset-4 hover:underline"
|
|
289
|
+
},
|
|
290
|
+
size: {
|
|
291
|
+
default: "h-10 px-4 py-2",
|
|
292
|
+
sm: "h-9 rounded-md px-3",
|
|
293
|
+
lg: "h-11 rounded-md px-8",
|
|
294
|
+
icon: "h-10 w-10"
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
defaultVariants: {
|
|
298
|
+
variant: "default",
|
|
299
|
+
size: "default"
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
);
|
|
303
|
+
var Button = React2.forwardRef(
|
|
304
|
+
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
305
|
+
const Comp = asChild ? import_react_slot.Slot : "button";
|
|
306
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Comp, { className: cn(buttonVariants({ variant, size, className })), ref, ...props });
|
|
307
|
+
}
|
|
308
|
+
);
|
|
309
|
+
Button.displayName = "Button";
|
|
310
|
+
|
|
311
|
+
// src/components/ui/carousel.tsx
|
|
312
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
313
|
+
var CarouselContext = React3.createContext(null);
|
|
314
|
+
function useCarousel() {
|
|
315
|
+
const context = React3.useContext(CarouselContext);
|
|
316
|
+
if (!context) {
|
|
317
|
+
throw new Error("useCarousel must be used within a <Carousel />");
|
|
318
|
+
}
|
|
319
|
+
return context;
|
|
320
|
+
}
|
|
321
|
+
var Carousel = React3.forwardRef(
|
|
322
|
+
({ orientation = "horizontal", opts, setApi, plugins, className, children, ...props }, ref) => {
|
|
323
|
+
const [carouselRef, api] = (0, import_embla_carousel_react.default)(
|
|
324
|
+
{
|
|
325
|
+
...opts,
|
|
326
|
+
axis: orientation === "horizontal" ? "x" : "y"
|
|
327
|
+
},
|
|
328
|
+
plugins
|
|
329
|
+
);
|
|
330
|
+
const [canScrollPrev, setCanScrollPrev] = React3.useState(false);
|
|
331
|
+
const [canScrollNext, setCanScrollNext] = React3.useState(false);
|
|
332
|
+
const onSelect = React3.useCallback((api2) => {
|
|
333
|
+
if (!api2) {
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
setCanScrollPrev(api2.canScrollPrev());
|
|
337
|
+
setCanScrollNext(api2.canScrollNext());
|
|
338
|
+
}, []);
|
|
339
|
+
const scrollPrev = React3.useCallback(() => {
|
|
340
|
+
api == null ? void 0 : api.scrollPrev();
|
|
341
|
+
}, [api]);
|
|
342
|
+
const scrollNext = React3.useCallback(() => {
|
|
343
|
+
api == null ? void 0 : api.scrollNext();
|
|
344
|
+
}, [api]);
|
|
345
|
+
const handleKeyDown = React3.useCallback(
|
|
346
|
+
(event) => {
|
|
347
|
+
if (event.key === "ArrowLeft") {
|
|
348
|
+
event.preventDefault();
|
|
349
|
+
scrollPrev();
|
|
350
|
+
} else if (event.key === "ArrowRight") {
|
|
351
|
+
event.preventDefault();
|
|
352
|
+
scrollNext();
|
|
353
|
+
}
|
|
354
|
+
},
|
|
355
|
+
[scrollPrev, scrollNext]
|
|
356
|
+
);
|
|
357
|
+
React3.useEffect(() => {
|
|
358
|
+
if (!api || !setApi) {
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
setApi(api);
|
|
362
|
+
}, [api, setApi]);
|
|
363
|
+
React3.useEffect(() => {
|
|
364
|
+
if (!api) {
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
onSelect(api);
|
|
368
|
+
api.on("reInit", onSelect);
|
|
369
|
+
api.on("select", onSelect);
|
|
370
|
+
return () => {
|
|
371
|
+
api == null ? void 0 : api.off("select", onSelect);
|
|
372
|
+
};
|
|
373
|
+
}, [api, onSelect]);
|
|
374
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
375
|
+
CarouselContext.Provider,
|
|
376
|
+
{
|
|
377
|
+
value: {
|
|
378
|
+
carouselRef,
|
|
379
|
+
api,
|
|
380
|
+
opts,
|
|
381
|
+
orientation: orientation || ((opts == null ? void 0 : opts.axis) === "y" ? "vertical" : "horizontal"),
|
|
382
|
+
scrollPrev,
|
|
383
|
+
scrollNext,
|
|
384
|
+
canScrollPrev,
|
|
385
|
+
canScrollNext
|
|
386
|
+
},
|
|
387
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
388
|
+
"div",
|
|
389
|
+
{
|
|
390
|
+
ref,
|
|
391
|
+
onKeyDownCapture: handleKeyDown,
|
|
392
|
+
className: cn("relative", className),
|
|
393
|
+
role: "region",
|
|
394
|
+
"aria-roledescription": "carousel",
|
|
395
|
+
...props,
|
|
396
|
+
children
|
|
397
|
+
}
|
|
398
|
+
)
|
|
399
|
+
}
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
);
|
|
403
|
+
Carousel.displayName = "Carousel";
|
|
404
|
+
var CarouselContent = React3.forwardRef(
|
|
405
|
+
({ className, ...props }, ref) => {
|
|
406
|
+
const { carouselRef, orientation } = useCarousel();
|
|
407
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { ref: carouselRef, className: "overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
408
|
+
"div",
|
|
409
|
+
{
|
|
410
|
+
ref,
|
|
411
|
+
className: cn("flex", orientation === "horizontal" ? "-ml-4" : "-mt-4 flex-col", className),
|
|
412
|
+
...props
|
|
413
|
+
}
|
|
414
|
+
) });
|
|
415
|
+
}
|
|
416
|
+
);
|
|
417
|
+
CarouselContent.displayName = "CarouselContent";
|
|
418
|
+
var CarouselItem = React3.forwardRef(
|
|
419
|
+
({ className, ...props }, ref) => {
|
|
420
|
+
const { orientation } = useCarousel();
|
|
421
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
422
|
+
"div",
|
|
423
|
+
{
|
|
424
|
+
ref,
|
|
425
|
+
role: "group",
|
|
426
|
+
"aria-roledescription": "slide",
|
|
427
|
+
className: cn("min-w-0 shrink-0 grow-0 basis-full", orientation === "horizontal" ? "pl-4" : "pt-4", className),
|
|
428
|
+
...props
|
|
429
|
+
}
|
|
430
|
+
);
|
|
431
|
+
}
|
|
432
|
+
);
|
|
433
|
+
CarouselItem.displayName = "CarouselItem";
|
|
434
|
+
var CarouselPrevious = React3.forwardRef(
|
|
435
|
+
({ className, variant = "outline", size = "icon", ...props }, ref) => {
|
|
436
|
+
const { orientation, scrollPrev, canScrollPrev } = useCarousel();
|
|
437
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
438
|
+
Button,
|
|
439
|
+
{
|
|
440
|
+
ref,
|
|
441
|
+
variant,
|
|
442
|
+
size,
|
|
443
|
+
className: cn(
|
|
444
|
+
"absolute h-8 w-8 rounded-full",
|
|
445
|
+
orientation === "horizontal" ? "-left-12 top-1/2 -translate-y-1/2" : "-top-12 left-1/2 -translate-x-1/2 rotate-90",
|
|
446
|
+
className
|
|
447
|
+
),
|
|
448
|
+
disabled: !canScrollPrev,
|
|
449
|
+
onClick: scrollPrev,
|
|
450
|
+
...props,
|
|
451
|
+
children: [
|
|
452
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react.ArrowLeft, { className: "h-4 w-4" }),
|
|
453
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "sr-only", children: "Previous slide" })
|
|
454
|
+
]
|
|
455
|
+
}
|
|
456
|
+
);
|
|
457
|
+
}
|
|
458
|
+
);
|
|
459
|
+
CarouselPrevious.displayName = "CarouselPrevious";
|
|
460
|
+
var CarouselNext = React3.forwardRef(
|
|
461
|
+
({ className, variant = "outline", size = "icon", ...props }, ref) => {
|
|
462
|
+
const { orientation, scrollNext, canScrollNext } = useCarousel();
|
|
463
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
464
|
+
Button,
|
|
465
|
+
{
|
|
466
|
+
ref,
|
|
467
|
+
variant,
|
|
468
|
+
size,
|
|
469
|
+
className: cn(
|
|
470
|
+
"absolute h-8 w-8 rounded-full",
|
|
471
|
+
orientation === "horizontal" ? "-right-12 top-1/2 -translate-y-1/2" : "-bottom-12 left-1/2 -translate-x-1/2 rotate-90",
|
|
472
|
+
className
|
|
473
|
+
),
|
|
474
|
+
disabled: !canScrollNext,
|
|
475
|
+
onClick: scrollNext,
|
|
476
|
+
...props,
|
|
477
|
+
children: [
|
|
478
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react.ArrowRight, { className: "h-4 w-4" }),
|
|
479
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "sr-only", children: "Next slide" })
|
|
480
|
+
]
|
|
481
|
+
}
|
|
482
|
+
);
|
|
483
|
+
}
|
|
484
|
+
);
|
|
485
|
+
CarouselNext.displayName = "CarouselNext";
|
|
486
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
487
|
+
0 && (module.exports = {
|
|
488
|
+
Carousel,
|
|
489
|
+
CarouselContent,
|
|
490
|
+
CarouselItem,
|
|
491
|
+
CarouselNext,
|
|
492
|
+
CarouselPrevious,
|
|
493
|
+
ChartContainer,
|
|
494
|
+
ChartLegend,
|
|
495
|
+
ChartLegendContent,
|
|
496
|
+
ChartStyle,
|
|
497
|
+
ChartTooltip,
|
|
498
|
+
ChartTooltipContent
|
|
499
|
+
});
|
|
500
|
+
//# sourceMappingURL=charts.cjs.map
|