@alexgorbatchev/shadcn 0.0.0-stage → 0.0.12
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/LICENSE +21 -0
- package/README.md +349 -2
- package/THIRD_PARTY_NOTICES.md +105 -0
- package/dist/chunk-1j2hz3w9.js +16 -0
- package/dist/chunk-5wvvqege.js +259 -0
- package/dist/chunk-8a7dn9ps.js +93 -0
- package/dist/chunk-cp2m7y7v.js +26 -0
- package/dist/chunk-jpvw9xqy.js +4 -0
- package/dist/chunk-rajgnfbr.js +24 -0
- package/dist/chunk-rjjwytbx.js +12 -0
- package/dist/chunk-tnktkgvp.js +63 -0
- package/dist/chunk-z1fy613d.js +64 -0
- package/dist/components/Accordion.d.ts +12 -0
- package/dist/components/Alert.d.ts +15 -0
- package/dist/components/AlertDialog.d.ts +28 -0
- package/dist/components/AspectRatio.d.ts +5 -0
- package/dist/components/Attachment.d.ts +36 -0
- package/dist/components/Avatar.d.ts +19 -0
- package/dist/components/Badge.d.ts +15 -0
- package/dist/components/Breadcrumb.d.ts +18 -0
- package/dist/components/Bubble.d.ts +25 -0
- package/dist/components/Button.d.ts +13 -0
- package/dist/components/ButtonGroup.d.ts +14 -0
- package/dist/components/Card.d.ts +19 -0
- package/dist/components/Checkbox.d.ts +6 -0
- package/dist/components/Collapsible.d.ts +6 -0
- package/dist/components/Combobox.d.ts +39 -0
- package/dist/components/ConfirmationDialog.d.ts +11 -0
- package/dist/components/ContextMenu.d.ts +24 -0
- package/dist/components/DensityProvider.d.ts +7 -0
- package/dist/components/Dialog.d.ts +25 -0
- package/dist/components/DirectionProvider.d.ts +1 -0
- package/dist/components/DragDropPreview.d.ts +7 -0
- package/dist/components/DragDropProvider.d.ts +6 -0
- package/dist/components/DragSource.d.ts +10 -0
- package/dist/components/Drawer.d.ts +25 -0
- package/dist/components/DropTarget.d.ts +11 -0
- package/dist/components/DropdownMenu.d.ts +26 -0
- package/dist/components/Empty.d.ts +19 -0
- package/dist/components/EmptyState.d.ts +8 -0
- package/dist/components/Field.d.ts +36 -0
- package/dist/components/HoverCard.d.ts +8 -0
- package/dist/components/ImagePicker.d.ts +11 -0
- package/dist/components/InlineEdit.d.ts +14 -0
- package/dist/components/Input.d.ts +6 -0
- package/dist/components/InputGroup.d.ts +26 -0
- package/dist/components/Item.d.ts +32 -0
- package/dist/components/JsonViewer.d.ts +8 -0
- package/dist/components/Kbd.d.ts +7 -0
- package/dist/components/Label.d.ts +5 -0
- package/dist/components/Marker.d.ts +19 -0
- package/dist/components/Menubar.d.ts +29 -0
- package/dist/components/Message.d.ts +17 -0
- package/dist/components/NativeSelect.d.ts +11 -0
- package/dist/components/NavigationMenu.d.ts +21 -0
- package/dist/components/Pagination.d.ts +21 -0
- package/dist/components/Popover.d.ts +14 -0
- package/dist/components/Progress.d.ts +14 -0
- package/dist/components/RadioGroup.d.ts +9 -0
- package/dist/components/ScrollArea.d.ts +10 -0
- package/dist/components/Select.d.ts +25 -0
- package/dist/components/Separator.d.ts +8 -0
- package/dist/components/Sheet.d.ts +20 -0
- package/dist/components/Sidebar.d.ts +60 -0
- package/dist/components/Skeleton.d.ts +5 -0
- package/dist/components/Slider.d.ts +6 -0
- package/dist/components/Spinner.d.ts +5 -0
- package/dist/components/StarRating.d.ts +10 -0
- package/dist/components/Switch.d.ts +8 -0
- package/dist/components/Table.d.ts +28 -0
- package/dist/components/Tabs.d.ts +16 -0
- package/dist/components/Textarea.d.ts +5 -0
- package/dist/components/ThemeProvider.d.ts +9 -0
- package/dist/components/Toast.d.ts +18 -0
- package/dist/components/Toggle.d.ts +11 -0
- package/dist/components/ToggleGroup.d.ts +12 -0
- package/dist/components/Tooltip.d.ts +9 -0
- package/dist/components/calendar/Calendar.d.ts +6 -0
- package/dist/components/calendar/getCalendarClassNames.d.ts +3 -0
- package/dist/components/calendar/index.d.ts +1 -0
- package/dist/components/calendar/index.js +10 -0
- package/dist/components/calendar/types.d.ts +9 -0
- package/dist/components/carousel/Carousel.d.ts +9 -0
- package/dist/components/carousel/CarouselContext.d.ts +2 -0
- package/dist/components/carousel/hooks/useCarousel.d.ts +2 -0
- package/dist/components/carousel/index.d.ts +3 -0
- package/dist/components/carousel/index.js +207 -0
- package/dist/components/carousel/types.d.ts +23 -0
- package/dist/components/chart/Chart.d.ts +10 -0
- package/dist/components/chart/ChartContext.d.ts +2 -0
- package/dist/components/chart/ChartStyle.d.ts +3 -0
- package/dist/components/chart/getPayloadConfigFromPayload.d.ts +2 -0
- package/dist/components/chart/hooks/useChart.d.ts +2 -0
- package/dist/components/chart/index.d.ts +3 -0
- package/dist/components/chart/index.js +284 -0
- package/dist/components/chart/types.d.ts +50 -0
- package/dist/components/command/Command.d.ts +21 -0
- package/dist/components/command/index.d.ts +1 -0
- package/dist/components/command/index.js +142 -0
- package/dist/components/input-otp/InputOTP.d.ts +12 -0
- package/dist/components/input-otp/index.d.ts +1 -0
- package/dist/components/input-otp/index.js +303 -0
- package/dist/components/message-scroller/MessageScroller.d.ts +16 -0
- package/dist/components/message-scroller/hooks/useMessageScroller.d.ts +1 -0
- package/dist/components/message-scroller/hooks/useMessageScrollerScrollable.d.ts +1 -0
- package/dist/components/message-scroller/hooks/useMessageScrollerVisibility.d.ts +1 -0
- package/dist/components/message-scroller/index.d.ts +5 -0
- package/dist/components/message-scroller/index.js +600 -0
- package/dist/components/persian-calendar/PersianCalendar.d.ts +6 -0
- package/dist/components/persian-calendar/index.d.ts +1 -0
- package/dist/components/persian-calendar/index.js +36 -0
- package/dist/components/questionnaire/Questionnaire.d.ts +20 -0
- package/dist/components/questionnaire/index.d.ts +2 -0
- package/dist/components/questionnaire/index.js +747 -0
- package/dist/components/resizable/Resizable.d.ts +10 -0
- package/dist/components/resizable/SplitView.d.ts +12 -0
- package/dist/components/resizable/index.d.ts +2 -0
- package/dist/components/resizable/index.js +147 -0
- package/dist/components/sonner/Sonner.d.ts +7 -0
- package/dist/components/sonner/hooks/useSonner.d.ts +1 -0
- package/dist/components/sonner/index.d.ts +2 -0
- package/dist/components/sonner/index.js +1273 -0
- package/dist/density/DensityContext.d.ts +2 -0
- package/dist/density/types.d.ts +4 -0
- package/dist/drag-drop/DragDropContext.d.ts +2 -0
- package/dist/drag-drop/types.d.ts +45 -0
- package/dist/drawer/DrawerContext.d.ts +2 -0
- package/dist/drawer/types.d.ts +7 -0
- package/dist/fonts.css +1 -0
- package/dist/hooks/useComboboxAnchor.d.ts +2 -0
- package/dist/hooks/useDensity.d.ts +2 -0
- package/dist/hooks/useDragDrop.d.ts +2 -0
- package/dist/hooks/useDragSource.d.ts +2 -0
- package/dist/hooks/useDrawer.d.ts +2 -0
- package/dist/hooks/useDropTarget.d.ts +2 -0
- package/dist/hooks/useMediaQuery.d.ts +1 -0
- package/dist/hooks/useObjectURL.d.ts +1 -0
- package/dist/hooks/useSidebar.d.ts +2 -0
- package/dist/hooks/useTheme.d.ts +2 -0
- package/dist/hooks/useToastManager.d.ts +2 -0
- package/dist/index.d.ts +82 -0
- package/dist/index.js +4908 -0
- package/dist/menu/types.d.ts +14 -0
- package/dist/message/MessageContext.d.ts +2 -0
- package/dist/message/types.d.ts +7 -0
- package/dist/sidebar/SidebarContext.d.ts +2 -0
- package/dist/sidebar/types.d.ts +32 -0
- package/dist/theme/ThemeContext.d.ts +2 -0
- package/dist/theme/types.d.ts +8 -0
- package/dist/theme.css +454 -0
- package/dist/toggle-group/ToggleGroupContext.d.ts +2 -0
- package/dist/toggle-group/types.d.ts +5 -0
- package/dist/typeset.css +444 -0
- package/dist/utils/cn.d.ts +2 -0
- package/package.json +193 -4
- package/patches/@shadcn%2Freact@0.3.1.patch +35 -0
- package/patches/input-otp@1.5.0.patch +20 -0
- package/patches/sonner@2.0.8.patch +87 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cn2
|
|
3
|
+
} from "../../chunk-cp2m7y7v.js";
|
|
4
|
+
import {
|
|
5
|
+
Button2
|
|
6
|
+
} from "../../chunk-tnktkgvp.js";
|
|
7
|
+
|
|
8
|
+
// src/components/carousel/Carousel.tsx
|
|
9
|
+
import { useCallback, useEffect, useState } from "react";
|
|
10
|
+
import useEmblaCarousel from "embla-carousel-react";
|
|
11
|
+
import { useDirection } from "@base-ui/react/direction-provider";
|
|
12
|
+
import { ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon } from "lucide-react";
|
|
13
|
+
|
|
14
|
+
// src/components/carousel/CarouselContext.ts
|
|
15
|
+
import { createContext } from "react";
|
|
16
|
+
var CarouselContext = createContext(null);
|
|
17
|
+
|
|
18
|
+
// src/components/carousel/hooks/useCarousel.ts
|
|
19
|
+
import { useContext } from "react";
|
|
20
|
+
function useCarousel() {
|
|
21
|
+
const context = useContext(CarouselContext);
|
|
22
|
+
if (!context)
|
|
23
|
+
throw new Error("useCarousel must be used within Carousel.");
|
|
24
|
+
return context;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// src/components/carousel/Carousel.tsx
|
|
28
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
29
|
+
function Carousel({
|
|
30
|
+
density,
|
|
31
|
+
orientation = "horizontal",
|
|
32
|
+
opts,
|
|
33
|
+
setApi,
|
|
34
|
+
plugins,
|
|
35
|
+
className,
|
|
36
|
+
children,
|
|
37
|
+
onKeyDown,
|
|
38
|
+
...props
|
|
39
|
+
}) {
|
|
40
|
+
const inheritedDirection = useDirection();
|
|
41
|
+
const direction = opts?.direction ?? inheritedDirection;
|
|
42
|
+
const [carouselRef, api] = useEmblaCarousel({
|
|
43
|
+
...opts,
|
|
44
|
+
direction,
|
|
45
|
+
axis: orientation === "horizontal" ? "x" : "y",
|
|
46
|
+
breakpoints: {
|
|
47
|
+
...opts?.breakpoints,
|
|
48
|
+
"(prefers-reduced-motion: reduce)": {
|
|
49
|
+
...opts?.breakpoints?.["(prefers-reduced-motion: reduce)"],
|
|
50
|
+
duration: 0
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}, plugins);
|
|
54
|
+
const [canScrollPrev, setCanScrollPrev] = useState(false);
|
|
55
|
+
const [canScrollNext, setCanScrollNext] = useState(false);
|
|
56
|
+
const scrollPrev = useCallback(() => api?.scrollPrev(), [api]);
|
|
57
|
+
const scrollNext = useCallback(() => api?.scrollNext(), [api]);
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
if (!api)
|
|
60
|
+
return;
|
|
61
|
+
const update = () => {
|
|
62
|
+
setCanScrollPrev(api.canScrollPrev());
|
|
63
|
+
setCanScrollNext(api.canScrollNext());
|
|
64
|
+
};
|
|
65
|
+
update();
|
|
66
|
+
api.on("reInit", update);
|
|
67
|
+
api.on("select", update);
|
|
68
|
+
return () => {
|
|
69
|
+
api.off("reInit", update);
|
|
70
|
+
api.off("select", update);
|
|
71
|
+
};
|
|
72
|
+
}, [api]);
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (api)
|
|
75
|
+
setApi?.(api);
|
|
76
|
+
}, [api, setApi]);
|
|
77
|
+
const handleKeyDown = (event) => {
|
|
78
|
+
onKeyDown?.(event);
|
|
79
|
+
if (event.defaultPrevented || event.target !== event.currentTarget)
|
|
80
|
+
return;
|
|
81
|
+
const previousKey = orientation === "vertical" ? "ArrowUp" : direction === "rtl" ? "ArrowRight" : "ArrowLeft";
|
|
82
|
+
const nextKey = orientation === "vertical" ? "ArrowDown" : direction === "rtl" ? "ArrowLeft" : "ArrowRight";
|
|
83
|
+
if (event.key === previousKey) {
|
|
84
|
+
event.preventDefault();
|
|
85
|
+
scrollPrev();
|
|
86
|
+
}
|
|
87
|
+
if (event.key === nextKey) {
|
|
88
|
+
event.preventDefault();
|
|
89
|
+
scrollNext();
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
return /* @__PURE__ */ jsx(CarouselContext.Provider, {
|
|
93
|
+
value: { carouselRef, api, orientation, direction, scrollPrev, scrollNext, canScrollPrev, canScrollNext },
|
|
94
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
95
|
+
"data-slot": "carousel",
|
|
96
|
+
"data-density": density,
|
|
97
|
+
dir: direction,
|
|
98
|
+
role: "region",
|
|
99
|
+
"aria-roledescription": "carousel",
|
|
100
|
+
tabIndex: 0,
|
|
101
|
+
className: cn2("relative outline-none focus-visible:ring-1 focus-visible:ring-ring", className),
|
|
102
|
+
...props,
|
|
103
|
+
onKeyDown: handleKeyDown,
|
|
104
|
+
children
|
|
105
|
+
})
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function CarouselContent({ className, ...props }) {
|
|
109
|
+
const { carouselRef, orientation } = useCarousel();
|
|
110
|
+
return /* @__PURE__ */ jsx("div", {
|
|
111
|
+
ref: carouselRef,
|
|
112
|
+
"data-slot": "carousel-content",
|
|
113
|
+
className: "overflow-hidden",
|
|
114
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
115
|
+
className: cn2("flex", orientation === "horizontal" ? "-ms-panel touch-pan-y touch-pinch-zoom" : "-mt-panel flex-col touch-pan-x touch-pinch-zoom", className),
|
|
116
|
+
...props
|
|
117
|
+
})
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
function CarouselItem({ className, ...props }) {
|
|
121
|
+
const { orientation } = useCarousel();
|
|
122
|
+
return /* @__PURE__ */ jsx("div", {
|
|
123
|
+
role: "group",
|
|
124
|
+
"aria-roledescription": "slide",
|
|
125
|
+
"data-slot": "carousel-item",
|
|
126
|
+
className: cn2("min-h-0 min-w-0 shrink-0 grow-0 basis-full", orientation === "horizontal" ? "ps-panel" : "pt-panel", className),
|
|
127
|
+
...props
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
function CarouselPrevious({
|
|
131
|
+
className,
|
|
132
|
+
variant = "outline",
|
|
133
|
+
size = "icon-sm",
|
|
134
|
+
disabled,
|
|
135
|
+
onClick,
|
|
136
|
+
children,
|
|
137
|
+
...props
|
|
138
|
+
}) {
|
|
139
|
+
const { orientation, scrollPrev, canScrollPrev } = useCarousel();
|
|
140
|
+
return /* @__PURE__ */ jsx(Button2, {
|
|
141
|
+
"data-slot": "carousel-previous",
|
|
142
|
+
variant,
|
|
143
|
+
size,
|
|
144
|
+
className: (state) => cn2("absolute touch-manipulation", orientation === "horizontal" ? "inset-y-0 -start-10 my-auto" : "-top-10 left-1/2 -translate-x-1/2", typeof className === "function" ? className(state) : className),
|
|
145
|
+
disabled: disabled || !canScrollPrev,
|
|
146
|
+
onClick: (event) => {
|
|
147
|
+
onClick?.(event);
|
|
148
|
+
if (!event.defaultPrevented)
|
|
149
|
+
scrollPrev();
|
|
150
|
+
},
|
|
151
|
+
...props,
|
|
152
|
+
children: children ?? /* @__PURE__ */ jsxs(Fragment, {
|
|
153
|
+
children: [
|
|
154
|
+
orientation === "horizontal" ? /* @__PURE__ */ jsx(ChevronLeftIcon, {
|
|
155
|
+
className: "rtl:rotate-180"
|
|
156
|
+
}) : /* @__PURE__ */ jsx(ChevronUpIcon, {}),
|
|
157
|
+
/* @__PURE__ */ jsx("span", {
|
|
158
|
+
className: "sr-only",
|
|
159
|
+
children: "Previous slide"
|
|
160
|
+
})
|
|
161
|
+
]
|
|
162
|
+
})
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
function CarouselNext({
|
|
166
|
+
className,
|
|
167
|
+
variant = "outline",
|
|
168
|
+
size = "icon-sm",
|
|
169
|
+
disabled,
|
|
170
|
+
onClick,
|
|
171
|
+
children,
|
|
172
|
+
...props
|
|
173
|
+
}) {
|
|
174
|
+
const { orientation, scrollNext, canScrollNext } = useCarousel();
|
|
175
|
+
return /* @__PURE__ */ jsx(Button2, {
|
|
176
|
+
"data-slot": "carousel-next",
|
|
177
|
+
variant,
|
|
178
|
+
size,
|
|
179
|
+
className: (state) => cn2("absolute touch-manipulation", orientation === "horizontal" ? "inset-y-0 -end-10 my-auto" : "-bottom-10 left-1/2 -translate-x-1/2", typeof className === "function" ? className(state) : className),
|
|
180
|
+
disabled: disabled || !canScrollNext,
|
|
181
|
+
onClick: (event) => {
|
|
182
|
+
onClick?.(event);
|
|
183
|
+
if (!event.defaultPrevented)
|
|
184
|
+
scrollNext();
|
|
185
|
+
},
|
|
186
|
+
...props,
|
|
187
|
+
children: children ?? /* @__PURE__ */ jsxs(Fragment, {
|
|
188
|
+
children: [
|
|
189
|
+
orientation === "horizontal" ? /* @__PURE__ */ jsx(ChevronRightIcon, {
|
|
190
|
+
className: "rtl:rotate-180"
|
|
191
|
+
}) : /* @__PURE__ */ jsx(ChevronDownIcon, {}),
|
|
192
|
+
/* @__PURE__ */ jsx("span", {
|
|
193
|
+
className: "sr-only",
|
|
194
|
+
children: "Next slide"
|
|
195
|
+
})
|
|
196
|
+
]
|
|
197
|
+
})
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
export {
|
|
201
|
+
Carousel,
|
|
202
|
+
CarouselContent,
|
|
203
|
+
CarouselItem,
|
|
204
|
+
CarouselNext,
|
|
205
|
+
CarouselPrevious,
|
|
206
|
+
useCarousel
|
|
207
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { UseEmblaCarouselType } from "embla-carousel-react";
|
|
2
|
+
import type useEmblaCarousel from "embla-carousel-react";
|
|
3
|
+
import type { ComponentProps } from "react";
|
|
4
|
+
import type { IDensityProps } from "../../density/types.js";
|
|
5
|
+
export type CarouselApi = UseEmblaCarouselType[1];
|
|
6
|
+
export type CarouselOptions = Parameters<typeof useEmblaCarousel>[0];
|
|
7
|
+
export type CarouselPlugins = Parameters<typeof useEmblaCarousel>[1];
|
|
8
|
+
export type CarouselProps = ComponentProps<"div"> & IDensityProps & {
|
|
9
|
+
opts?: CarouselOptions;
|
|
10
|
+
plugins?: CarouselPlugins;
|
|
11
|
+
orientation?: "horizontal" | "vertical";
|
|
12
|
+
setApi?: (api: CarouselApi) => void;
|
|
13
|
+
};
|
|
14
|
+
export interface ICarouselContextValue {
|
|
15
|
+
carouselRef: UseEmblaCarouselType[0];
|
|
16
|
+
api: CarouselApi;
|
|
17
|
+
orientation: "horizontal" | "vertical";
|
|
18
|
+
direction: "ltr" | "rtl";
|
|
19
|
+
scrollPrev: () => void;
|
|
20
|
+
scrollNext: () => void;
|
|
21
|
+
canScrollPrev: boolean;
|
|
22
|
+
canScrollNext: boolean;
|
|
23
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
import type { ChartProps, ChartTooltipContentProps, ChartLegendContentProps } from "./types.js";
|
|
3
|
+
import { Tooltip } from "recharts";
|
|
4
|
+
import { ChartStyle } from "./ChartStyle.js";
|
|
5
|
+
declare function Chart({ id, dir, density, className, children, config, initialDimension, ...props }: ChartProps): ReactElement;
|
|
6
|
+
declare function ChartTooltipContent({ density, active, payload, className, indicator, hideLabel, hideIndicator, label, labelFormatter, labelClassName, formatter, color, nameKey, labelKey, htmlProps, contentStyle, itemStyle, labelStyle, wrapperClassName, itemSorter, }: ChartTooltipContentProps): ReactElement | null;
|
|
7
|
+
declare function ChartLegendContent({ density, className, hideIcon, payload, verticalAlign, nameKey, onClick, onMouseEnter, onMouseLeave, formatter, htmlProps, labelStyle, inactiveColor, }: ChartLegendContentProps): ReactElement | null;
|
|
8
|
+
declare const ChartTooltip: typeof Tooltip;
|
|
9
|
+
declare const ChartLegend: import("react").MemoExoticComponent<(outsideProps: import("recharts").LegendProps) => React.ReactPortal | null>;
|
|
10
|
+
export { Chart, Chart as ChartContainer, ChartTooltip, ChartTooltipContent, ChartLegend, ChartLegendContent, ChartStyle, };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { Chart, ChartContainer, ChartTooltip, ChartTooltipContent, ChartLegend, ChartLegendContent, ChartStyle, } from "./Chart.js";
|
|
2
|
+
export type { ChartConfig, ChartProps, ChartTooltipContentProps, ChartLegendContentProps } from "./types.js";
|
|
3
|
+
export { useChart } from "./hooks/useChart.js";
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useDensity
|
|
3
|
+
} from "../../chunk-rjjwytbx.js";
|
|
4
|
+
import {
|
|
5
|
+
cn2
|
|
6
|
+
} from "../../chunk-cp2m7y7v.js";
|
|
7
|
+
import {
|
|
8
|
+
useDirection2
|
|
9
|
+
} from "../../chunk-jpvw9xqy.js";
|
|
10
|
+
|
|
11
|
+
// src/components/chart/Chart.tsx
|
|
12
|
+
import { useId, useMemo } from "react";
|
|
13
|
+
import { ResponsiveContainer, Tooltip, Legend } from "recharts";
|
|
14
|
+
import sortBy from "es-toolkit/compat/sortBy";
|
|
15
|
+
|
|
16
|
+
// src/components/chart/ChartContext.ts
|
|
17
|
+
import { createContext } from "react";
|
|
18
|
+
var ChartContext = createContext(null);
|
|
19
|
+
|
|
20
|
+
// src/components/chart/getPayloadConfigFromPayload.ts
|
|
21
|
+
function isRecord(value) {
|
|
22
|
+
return typeof value === "object" && value !== null;
|
|
23
|
+
}
|
|
24
|
+
function getPayloadConfigFromPayload(config, payload, key) {
|
|
25
|
+
if (!isRecord(payload))
|
|
26
|
+
return;
|
|
27
|
+
const value = payload[key];
|
|
28
|
+
const nested = isRecord(payload.payload) ? payload.payload[key] : undefined;
|
|
29
|
+
const configLabelKey = typeof value === "string" ? value : typeof nested === "string" ? nested : key;
|
|
30
|
+
return config[configLabelKey] ?? config[key];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// src/components/chart/hooks/useChart.ts
|
|
34
|
+
import { useContext } from "react";
|
|
35
|
+
function useChart() {
|
|
36
|
+
const context = useContext(ChartContext);
|
|
37
|
+
if (!context)
|
|
38
|
+
throw new Error("useChart must be used within a <ChartContainer />");
|
|
39
|
+
return context;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// src/components/chart/ChartStyle.tsx
|
|
43
|
+
import cssesc from "cssesc";
|
|
44
|
+
import { jsx } from "react/jsx-runtime";
|
|
45
|
+
var themes = ["light", "dark"];
|
|
46
|
+
function ChartStyle({ id, config }) {
|
|
47
|
+
const colors = Object.entries(config).filter(([, item]) => item.theme ?? item.color);
|
|
48
|
+
if (!colors.length)
|
|
49
|
+
return null;
|
|
50
|
+
return /* @__PURE__ */ jsx("style", {
|
|
51
|
+
children: themes.map((theme) => `${theme === "dark" ? "[data-theme=dark] " : ""}[data-chart=${cssesc(id, { isIdentifier: true })}] {
|
|
52
|
+
${colors.map(([key, item]) => {
|
|
53
|
+
const color = item.theme?.[theme] ?? item.color;
|
|
54
|
+
return color ? `${cssesc(`--color-${key}`, { isIdentifier: true })}: ${color};` : "";
|
|
55
|
+
}).join(`
|
|
56
|
+
`)}
|
|
57
|
+
}`).join(`
|
|
58
|
+
`)
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// src/components/chart/Chart.tsx
|
|
63
|
+
import { jsx as jsx2, jsxs, Fragment } from "react/jsx-runtime";
|
|
64
|
+
function Chart({
|
|
65
|
+
id,
|
|
66
|
+
dir,
|
|
67
|
+
density,
|
|
68
|
+
className,
|
|
69
|
+
children,
|
|
70
|
+
config,
|
|
71
|
+
initialDimension = { width: 320, height: 200 },
|
|
72
|
+
...props
|
|
73
|
+
}) {
|
|
74
|
+
const uniqueId = useId();
|
|
75
|
+
const resolvedDensity = useDensity(density);
|
|
76
|
+
const inheritedDirection = useDirection2();
|
|
77
|
+
const direction = dir ?? inheritedDirection;
|
|
78
|
+
const chartId = `chart-${id ?? uniqueId}`;
|
|
79
|
+
return /* @__PURE__ */ jsx2(ChartContext.Provider, {
|
|
80
|
+
value: { config, density: resolvedDensity, dir: direction, chartId },
|
|
81
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
82
|
+
id,
|
|
83
|
+
dir: direction,
|
|
84
|
+
"data-density": resolvedDensity,
|
|
85
|
+
"data-slot": "chart",
|
|
86
|
+
"data-chart": chartId,
|
|
87
|
+
className: cn2("flex aspect-video min-w-0 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-hidden [&_.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]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden", className),
|
|
88
|
+
...props,
|
|
89
|
+
children: [
|
|
90
|
+
/* @__PURE__ */ jsx2(ChartStyle, {
|
|
91
|
+
id: chartId,
|
|
92
|
+
config
|
|
93
|
+
}),
|
|
94
|
+
/* @__PURE__ */ jsx2(ResponsiveContainer, {
|
|
95
|
+
initialDimension,
|
|
96
|
+
children
|
|
97
|
+
})
|
|
98
|
+
]
|
|
99
|
+
})
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
function ChartTooltipContent({
|
|
103
|
+
density,
|
|
104
|
+
active,
|
|
105
|
+
payload,
|
|
106
|
+
className,
|
|
107
|
+
indicator = "dot",
|
|
108
|
+
hideLabel = false,
|
|
109
|
+
hideIndicator = false,
|
|
110
|
+
label,
|
|
111
|
+
labelFormatter,
|
|
112
|
+
labelClassName,
|
|
113
|
+
formatter,
|
|
114
|
+
color,
|
|
115
|
+
nameKey,
|
|
116
|
+
labelKey,
|
|
117
|
+
htmlProps,
|
|
118
|
+
contentStyle,
|
|
119
|
+
itemStyle,
|
|
120
|
+
labelStyle,
|
|
121
|
+
wrapperClassName,
|
|
122
|
+
itemSorter
|
|
123
|
+
}) {
|
|
124
|
+
const { config, density: chartDensity, dir, chartId } = useChart();
|
|
125
|
+
const tooltipLabel = useMemo(() => {
|
|
126
|
+
if (hideLabel || !payload?.length)
|
|
127
|
+
return null;
|
|
128
|
+
const [item] = payload;
|
|
129
|
+
const key = `${labelKey ?? item?.dataKey ?? item?.name ?? "value"}`;
|
|
130
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
131
|
+
const value = !labelKey && typeof label === "string" ? config[label]?.label ?? label : itemConfig?.label;
|
|
132
|
+
if (labelFormatter)
|
|
133
|
+
return /* @__PURE__ */ jsx2("div", {
|
|
134
|
+
className: cn2("font-medium", labelClassName),
|
|
135
|
+
style: labelStyle,
|
|
136
|
+
children: labelFormatter(value, payload)
|
|
137
|
+
});
|
|
138
|
+
if (!value)
|
|
139
|
+
return null;
|
|
140
|
+
return /* @__PURE__ */ jsx2("div", {
|
|
141
|
+
className: cn2("font-medium", labelClassName),
|
|
142
|
+
style: labelStyle,
|
|
143
|
+
children: value
|
|
144
|
+
});
|
|
145
|
+
}, [label, labelFormatter, payload, hideLabel, labelClassName, labelStyle, config, labelKey]);
|
|
146
|
+
if (!active || !payload?.length)
|
|
147
|
+
return null;
|
|
148
|
+
const sortedPayload = itemSorter ? sortBy(payload, itemSorter) : payload;
|
|
149
|
+
const nestLabel = payload.length === 1 && indicator !== "dot";
|
|
150
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
151
|
+
role: "status",
|
|
152
|
+
"data-slot": "chart-tooltip",
|
|
153
|
+
"data-chart": chartId,
|
|
154
|
+
dir,
|
|
155
|
+
"data-density": density ?? chartDensity,
|
|
156
|
+
...htmlProps,
|
|
157
|
+
className: cn2("grid min-w-32 items-start gap-control-gap rounded-md border border-frame-edge bg-popover p-panel text-xs text-popover-foreground shadow-frame", className, wrapperClassName, htmlProps?.className),
|
|
158
|
+
style: { ...contentStyle, ...htmlProps?.style },
|
|
159
|
+
children: [
|
|
160
|
+
!nestLabel ? tooltipLabel : null,
|
|
161
|
+
/* @__PURE__ */ jsx2("div", {
|
|
162
|
+
className: "grid gap-control-gap",
|
|
163
|
+
children: sortedPayload.filter((item) => item.type !== "none").map((item, index) => {
|
|
164
|
+
const key = `${nameKey ?? item.name ?? item.dataKey ?? "value"}`;
|
|
165
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
166
|
+
const itemPayload = item.payload;
|
|
167
|
+
const fill = typeof itemPayload === "object" && itemPayload !== null && "fill" in itemPayload ? itemPayload.fill : undefined;
|
|
168
|
+
const indicatorColor = color ?? (typeof fill === "string" ? fill : item.color);
|
|
169
|
+
const indicatorStyle = {
|
|
170
|
+
"--color-bg": indicatorColor,
|
|
171
|
+
"--color-border": indicatorColor
|
|
172
|
+
};
|
|
173
|
+
return /* @__PURE__ */ jsx2("div", {
|
|
174
|
+
className: cn2("flex w-full flex-wrap items-stretch gap-control-gap [&>svg]:size-3 [&>svg]:text-muted-foreground", indicator === "dot" && "items-center"),
|
|
175
|
+
style: itemStyle,
|
|
176
|
+
children: formatter && item.value !== undefined && item.name !== undefined ? formatter(item.value, item.name, item, index, payload) : /* @__PURE__ */ jsxs(Fragment, {
|
|
177
|
+
children: [
|
|
178
|
+
itemConfig?.icon ? /* @__PURE__ */ jsx2(itemConfig.icon, {}) : !hideIndicator && /* @__PURE__ */ jsx2("div", {
|
|
179
|
+
"aria-hidden": "true",
|
|
180
|
+
className: cn2("shrink-0 rounded-sm border-(--color-border) bg-(--color-bg)", {
|
|
181
|
+
"size-2.5": indicator === "dot",
|
|
182
|
+
"w-1": indicator === "line",
|
|
183
|
+
"w-0 border-[1.5px] border-dashed bg-transparent": indicator === "dashed",
|
|
184
|
+
"my-0.5": nestLabel && indicator === "dashed"
|
|
185
|
+
}),
|
|
186
|
+
style: indicatorStyle
|
|
187
|
+
}),
|
|
188
|
+
/* @__PURE__ */ jsxs("div", {
|
|
189
|
+
className: cn2("flex flex-1 justify-between gap-control-gap leading-none", nestLabel ? "items-end" : "items-center"),
|
|
190
|
+
children: [
|
|
191
|
+
/* @__PURE__ */ jsxs("div", {
|
|
192
|
+
className: "grid gap-control-gap",
|
|
193
|
+
children: [
|
|
194
|
+
nestLabel ? tooltipLabel : null,
|
|
195
|
+
/* @__PURE__ */ jsx2("span", {
|
|
196
|
+
className: "text-muted-foreground",
|
|
197
|
+
children: itemConfig?.label ?? item.name
|
|
198
|
+
})
|
|
199
|
+
]
|
|
200
|
+
}),
|
|
201
|
+
item.value != null && /* @__PURE__ */ jsx2("span", {
|
|
202
|
+
className: "font-mono font-medium tabular-nums",
|
|
203
|
+
children: typeof item.value === "number" ? item.value.toLocaleString() : String(item.value)
|
|
204
|
+
})
|
|
205
|
+
]
|
|
206
|
+
})
|
|
207
|
+
]
|
|
208
|
+
})
|
|
209
|
+
}, index);
|
|
210
|
+
})
|
|
211
|
+
})
|
|
212
|
+
]
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
function ChartLegendContent({
|
|
216
|
+
density,
|
|
217
|
+
className,
|
|
218
|
+
hideIcon = false,
|
|
219
|
+
payload,
|
|
220
|
+
verticalAlign = "bottom",
|
|
221
|
+
nameKey,
|
|
222
|
+
onClick,
|
|
223
|
+
onMouseEnter,
|
|
224
|
+
onMouseLeave,
|
|
225
|
+
formatter,
|
|
226
|
+
htmlProps,
|
|
227
|
+
labelStyle,
|
|
228
|
+
inactiveColor
|
|
229
|
+
}) {
|
|
230
|
+
const { config, density: chartDensity, dir, chartId } = useChart();
|
|
231
|
+
if (!payload?.length)
|
|
232
|
+
return null;
|
|
233
|
+
return /* @__PURE__ */ jsx2("div", {
|
|
234
|
+
"data-slot": "chart-legend",
|
|
235
|
+
"data-chart": chartId,
|
|
236
|
+
dir,
|
|
237
|
+
"data-density": density ?? chartDensity,
|
|
238
|
+
...htmlProps,
|
|
239
|
+
className: cn2("flex items-center justify-center gap-panel", verticalAlign === "top" ? "pb-panel" : "pt-panel", className, htmlProps?.className),
|
|
240
|
+
children: payload.filter((item) => item.type !== "none").map((item, index) => {
|
|
241
|
+
const key = `${nameKey ?? item.dataKey ?? "value"}`;
|
|
242
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
243
|
+
const content = /* @__PURE__ */ jsxs(Fragment, {
|
|
244
|
+
children: [
|
|
245
|
+
itemConfig?.icon && !hideIcon ? /* @__PURE__ */ jsx2(itemConfig.icon, {}) : /* @__PURE__ */ jsx2("span", {
|
|
246
|
+
"aria-hidden": "true",
|
|
247
|
+
className: "size-2 shrink-0 rounded-sm",
|
|
248
|
+
style: { backgroundColor: item.inactive ? inactiveColor : item.color }
|
|
249
|
+
}),
|
|
250
|
+
/* @__PURE__ */ jsx2("span", {
|
|
251
|
+
style: labelStyle,
|
|
252
|
+
children: formatter ? formatter(itemConfig?.label ?? item.value, item, index) : itemConfig?.label ?? item.value
|
|
253
|
+
})
|
|
254
|
+
]
|
|
255
|
+
});
|
|
256
|
+
const classes = "flex items-center gap-control-gap [&>svg]:size-3 [&>svg]:text-muted-foreground";
|
|
257
|
+
return onClick ? /* @__PURE__ */ jsx2("button", {
|
|
258
|
+
type: "button",
|
|
259
|
+
className: cn2(classes, "outline-none focus-visible:ring-1 focus-visible:ring-ring"),
|
|
260
|
+
onClick: (event) => onClick(item, index, event),
|
|
261
|
+
onMouseEnter: (event) => onMouseEnter?.(item, index, event),
|
|
262
|
+
onMouseLeave: (event) => onMouseLeave?.(item, index, event),
|
|
263
|
+
children: content
|
|
264
|
+
}, index) : /* @__PURE__ */ jsx2("div", {
|
|
265
|
+
className: classes,
|
|
266
|
+
onMouseEnter: (event) => onMouseEnter?.(item, index, event),
|
|
267
|
+
onMouseLeave: (event) => onMouseLeave?.(item, index, event),
|
|
268
|
+
children: content
|
|
269
|
+
}, index);
|
|
270
|
+
})
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
var ChartTooltip = Tooltip;
|
|
274
|
+
var ChartLegend = Legend;
|
|
275
|
+
export {
|
|
276
|
+
Chart,
|
|
277
|
+
Chart as ChartContainer,
|
|
278
|
+
ChartLegend,
|
|
279
|
+
ChartLegendContent,
|
|
280
|
+
ChartStyle,
|
|
281
|
+
ChartTooltip,
|
|
282
|
+
ChartTooltipContent,
|
|
283
|
+
useChart
|
|
284
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { ComponentProps, ComponentType, CSSProperties, ReactNode } from "react";
|
|
2
|
+
import type { DefaultLegendContentProps, DefaultTooltipContentProps, ResponsiveContainer, TooltipValueType } from "recharts";
|
|
3
|
+
import type { Density, IDensityProps } from "../../density/types.js";
|
|
4
|
+
import type { ResolvedTheme } from "../../theme/types.js";
|
|
5
|
+
export type ChartConfig = Record<string, {
|
|
6
|
+
label?: ReactNode;
|
|
7
|
+
icon?: ComponentType;
|
|
8
|
+
} & ({
|
|
9
|
+
color?: string;
|
|
10
|
+
theme?: never;
|
|
11
|
+
} | {
|
|
12
|
+
color?: never;
|
|
13
|
+
theme: Record<ResolvedTheme, string>;
|
|
14
|
+
})>;
|
|
15
|
+
export interface IChartContextValue {
|
|
16
|
+
config: ChartConfig;
|
|
17
|
+
density: Density;
|
|
18
|
+
dir: string;
|
|
19
|
+
chartId: string;
|
|
20
|
+
}
|
|
21
|
+
export type ChartProps = ComponentProps<"div"> & IDensityProps & {
|
|
22
|
+
config: ChartConfig;
|
|
23
|
+
children: ComponentProps<typeof ResponsiveContainer>["children"];
|
|
24
|
+
initialDimension?: ComponentProps<typeof ResponsiveContainer>["initialDimension"];
|
|
25
|
+
};
|
|
26
|
+
export type ChartStyleProps = {
|
|
27
|
+
id: string;
|
|
28
|
+
config: ChartConfig;
|
|
29
|
+
};
|
|
30
|
+
export type ChartIndicatorStyle = CSSProperties & {
|
|
31
|
+
"--color-bg"?: string;
|
|
32
|
+
"--color-border"?: string;
|
|
33
|
+
};
|
|
34
|
+
export type ChartTooltipContentProps = Omit<DefaultTooltipContentProps<TooltipValueType, number | string>, "accessibilityLayer"> & IDensityProps & {
|
|
35
|
+
className?: string;
|
|
36
|
+
htmlProps?: ComponentProps<"div">;
|
|
37
|
+
active?: boolean;
|
|
38
|
+
hideLabel?: boolean;
|
|
39
|
+
hideIndicator?: boolean;
|
|
40
|
+
indicator?: "line" | "dot" | "dashed";
|
|
41
|
+
nameKey?: string;
|
|
42
|
+
labelKey?: string;
|
|
43
|
+
color?: string;
|
|
44
|
+
};
|
|
45
|
+
export type ChartLegendContentProps = DefaultLegendContentProps & IDensityProps & {
|
|
46
|
+
className?: string;
|
|
47
|
+
htmlProps?: ComponentProps<"div">;
|
|
48
|
+
hideIcon?: boolean;
|
|
49
|
+
nameKey?: string;
|
|
50
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ComponentProps, ReactElement } from "react";
|
|
2
|
+
import type { IDensityProps } from "../../density/types.js";
|
|
3
|
+
import { Command as CommandPrimitive } from "cmdk";
|
|
4
|
+
import { Dialog } from "../Dialog.js";
|
|
5
|
+
type CommandProps = ComponentProps<typeof CommandPrimitive> & IDensityProps;
|
|
6
|
+
declare function Command({ density, className, ...props }: CommandProps): ReactElement;
|
|
7
|
+
type CommandDialogProps<Payload> = ComponentProps<typeof Dialog<Payload>> & IDensityProps & {
|
|
8
|
+
title?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
className?: string;
|
|
11
|
+
showCloseButton?: boolean;
|
|
12
|
+
};
|
|
13
|
+
declare function CommandDialog<Payload>({ title, description, children, density, className, showCloseButton, ...props }: CommandDialogProps<Payload>): ReactElement;
|
|
14
|
+
declare function CommandInput({ className, ...props }: ComponentProps<typeof CommandPrimitive.Input>): ReactElement;
|
|
15
|
+
declare function CommandList({ className, ...props }: ComponentProps<typeof CommandPrimitive.List>): ReactElement;
|
|
16
|
+
declare function CommandEmpty({ className, ...props }: ComponentProps<typeof CommandPrimitive.Empty>): ReactElement;
|
|
17
|
+
declare function CommandGroup({ className, ...props }: ComponentProps<typeof CommandPrimitive.Group>): ReactElement;
|
|
18
|
+
declare function CommandSeparator({ className, ...props }: ComponentProps<typeof CommandPrimitive.Separator>): ReactElement;
|
|
19
|
+
declare function CommandItem({ className, children, ...props }: ComponentProps<typeof CommandPrimitive.Item>): ReactElement;
|
|
20
|
+
declare function CommandShortcut({ className, ...props }: ComponentProps<"span">): ReactElement;
|
|
21
|
+
export { Command, CommandDialog, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem, CommandSeparator, CommandShortcut, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Command, CommandDialog, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem, CommandSeparator, CommandShortcut, } from "./Command.js";
|