create-auto-app 0.1.0 → 0.1.1
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/index.js +182 -85
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/templates/shopping-app/.context/auto-ia-scheme.json +175 -0
- package/templates/shopping-app/.context/design-system.md +118 -0
- package/templates/shopping-app/.context/figma-variables.json +14448 -0
- package/templates/shopping-app/.context/schema.graphql +46 -0
- package/templates/shopping-app/.context/schema.json +583 -0
- package/templates/shopping-app/.context/shadcn-filter.ts +31 -0
- package/templates/shopping-app/.env +8 -0
- package/templates/shopping-app/auto.config.ts +21 -0
- package/templates/shopping-app/client/auto-configure.ts +107 -0
- package/templates/shopping-app/client/codegen.ts +16 -0
- package/templates/shopping-app/client/components.json +20 -0
- package/templates/shopping-app/client/design-system-principles.md +19 -0
- package/templates/shopping-app/client/eslint.config.ts +57 -0
- package/templates/shopping-app/client/index.html +26 -0
- package/templates/shopping-app/client/package.json +100 -0
- package/templates/shopping-app/client/postcss.config.js +6 -0
- package/templates/shopping-app/client/public/favicon.ico +0 -0
- package/templates/shopping-app/client/schema.graphql +46 -0
- package/templates/shopping-app/client/src/App.css +42 -0
- package/templates/shopping-app/client/src/App.tsx +20 -0
- package/templates/shopping-app/client/src/apolloClient.ts +8 -0
- package/templates/shopping-app/client/src/components/atoms/accordion.tsx +51 -0
- package/templates/shopping-app/client/src/components/atoms/alert-dialog.tsx +111 -0
- package/templates/shopping-app/client/src/components/atoms/alert.tsx +49 -0
- package/templates/shopping-app/client/src/components/atoms/aspect-ratio.tsx +7 -0
- package/templates/shopping-app/client/src/components/atoms/avatar.tsx +32 -0
- package/templates/shopping-app/client/src/components/atoms/badge.tsx +36 -0
- package/templates/shopping-app/client/src/components/atoms/breadcrumb.tsx +92 -0
- package/templates/shopping-app/client/src/components/atoms/button.tsx +50 -0
- package/templates/shopping-app/client/src/components/atoms/calendar.tsx +156 -0
- package/templates/shopping-app/client/src/components/atoms/card.tsx +56 -0
- package/templates/shopping-app/client/src/components/atoms/carousel.tsx +214 -0
- package/templates/shopping-app/client/src/components/atoms/chart.tsx +290 -0
- package/templates/shopping-app/client/src/components/atoms/checkbox.tsx +27 -0
- package/templates/shopping-app/client/src/components/atoms/collapsible.tsx +15 -0
- package/templates/shopping-app/client/src/components/atoms/command.tsx +135 -0
- package/templates/shopping-app/client/src/components/atoms/context-menu.tsx +209 -0
- package/templates/shopping-app/client/src/components/atoms/dialog.tsx +123 -0
- package/templates/shopping-app/client/src/components/atoms/drawer.tsx +106 -0
- package/templates/shopping-app/client/src/components/atoms/dropdown-menu.tsx +217 -0
- package/templates/shopping-app/client/src/components/atoms/hover-card.tsx +36 -0
- package/templates/shopping-app/client/src/components/atoms/input-otp.tsx +66 -0
- package/templates/shopping-app/client/src/components/atoms/input.tsx +21 -0
- package/templates/shopping-app/client/src/components/atoms/label.tsx +19 -0
- package/templates/shopping-app/client/src/components/atoms/logo.tsx +33 -0
- package/templates/shopping-app/client/src/components/atoms/menubar.tsx +234 -0
- package/templates/shopping-app/client/src/components/atoms/navigation-menu.tsx +142 -0
- package/templates/shopping-app/client/src/components/atoms/pagination.tsx +100 -0
- package/templates/shopping-app/client/src/components/atoms/popover.tsx +40 -0
- package/templates/shopping-app/client/src/components/atoms/progress.tsx +22 -0
- package/templates/shopping-app/client/src/components/atoms/radio-group.tsx +31 -0
- package/templates/shopping-app/client/src/components/atoms/resizable.tsx +46 -0
- package/templates/shopping-app/client/src/components/atoms/scroll-area.tsx +46 -0
- package/templates/shopping-app/client/src/components/atoms/select.tsx +158 -0
- package/templates/shopping-app/client/src/components/atoms/separator.tsx +26 -0
- package/templates/shopping-app/client/src/components/atoms/sheet.tsx +101 -0
- package/templates/shopping-app/client/src/components/atoms/sidebar.tsx +675 -0
- package/templates/shopping-app/client/src/components/atoms/skeleton.tsx +7 -0
- package/templates/shopping-app/client/src/components/atoms/slider.tsx +54 -0
- package/templates/shopping-app/client/src/components/atoms/sonner.tsx +23 -0
- package/templates/shopping-app/client/src/components/atoms/switch.tsx +26 -0
- package/templates/shopping-app/client/src/components/atoms/table.tsx +73 -0
- package/templates/shopping-app/client/src/components/atoms/tabs.tsx +40 -0
- package/templates/shopping-app/client/src/components/atoms/textarea.tsx +18 -0
- package/templates/shopping-app/client/src/components/atoms/toggle-group.tsx +65 -0
- package/templates/shopping-app/client/src/components/atoms/toggle.tsx +39 -0
- package/templates/shopping-app/client/src/components/atoms/tooltip.tsx +48 -0
- package/templates/shopping-app/client/src/components/molecules/QuantitySelector.tsx +8 -0
- package/templates/shopping-app/client/src/components/molecules/ShoppingCriteriaForm.tsx +8 -0
- package/templates/shopping-app/client/src/components/molecules/SuggestedItemCard.tsx +10 -0
- package/templates/shopping-app/client/src/components/organisms/AssistantChatInterface.tsx +14 -0
- package/templates/shopping-app/client/src/components/organisms/PageHeader.tsx +6 -0
- package/templates/shopping-app/client/src/components/organisms/SuggestedItemsList.tsx +15 -0
- package/templates/shopping-app/client/src/gql/fragment-masking.ts +48 -0
- package/templates/shopping-app/client/src/gql/gql.ts +47 -0
- package/templates/shopping-app/client/src/gql/graphql.ts +106 -0
- package/templates/shopping-app/client/src/gql/index.ts +2 -0
- package/templates/shopping-app/client/src/graphql/mutations.ts +13 -0
- package/templates/shopping-app/client/src/graphql/queries.ts +14 -0
- package/templates/shopping-app/client/src/hooks/use-mobile.tsx +19 -0
- package/templates/shopping-app/client/src/hooks/use-toast.ts +186 -0
- package/templates/shopping-app/client/src/index.css +153 -0
- package/templates/shopping-app/client/src/lib/utils.ts +6 -0
- package/templates/shopping-app/client/src/main.tsx +5 -0
- package/templates/shopping-app/client/src/mockApolloClient.ts +93 -0
- package/templates/shopping-app/client/src/pages/AssistantChatPage.tsx +8 -0
- package/templates/shopping-app/client/src/pages/Index.tsx +10 -0
- package/templates/shopping-app/client/src/pages/NotFound.tsx +22 -0
- package/templates/shopping-app/client/src/pages/SuggestedItemsPage.tsx +8 -0
- package/templates/shopping-app/client/tailwind.config.ts +92 -0
- package/templates/shopping-app/client/tsconfig.json +49 -0
- package/templates/shopping-app/client/vite.config.ts +17 -0
- package/templates/shopping-app/flows/shopping-assistant.flow.ts +369 -0
- package/templates/shopping-app/package.json +25 -0
- package/templates/shopping-app/pnpm-workspace.yaml +2 -0
- package/templates/shopping-app/server/package.json +25 -0
- package/templates/shopping-app/server/scripts/generate-schema.ts +31 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/accepts-items-and-adds-to-their-cart/commands.ts +8 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/accepts-items-and-adds-to-their-cart/decide.specs.ts +46 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/accepts-items-and-adds-to-their-cart/decide.ts +36 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/accepts-items-and-adds-to-their-cart/events.ts +10 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/accepts-items-and-adds-to-their-cart/evolve.ts +28 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/accepts-items-and-adds-to-their-cart/handle.ts +31 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/accepts-items-and-adds-to-their-cart/mutation.resolver.ts +29 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/accepts-items-and-adds-to-their-cart/register.ts +10 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/accepts-items-and-adds-to-their-cart/state.ts +47 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/creates-a-chat-session-/react.specs.ts +63 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/creates-a-chat-session-/react.ts +49 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/creates-a-chat-session-/register.ts +31 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/enters-shopping-criteria-into-assistant/commands.ts +8 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/enters-shopping-criteria-into-assistant/decide.specs.ts +38 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/enters-shopping-criteria-into-assistant/decide.ts +36 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/enters-shopping-criteria-into-assistant/events.ts +10 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/enters-shopping-criteria-into-assistant/evolve.ts +28 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/enters-shopping-criteria-into-assistant/handle.ts +31 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/enters-shopping-criteria-into-assistant/mutation.resolver.ts +30 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/enters-shopping-criteria-into-assistant/register.ts +10 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/enters-shopping-criteria-into-assistant/state.ts +47 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/selects-items-relevant-to-the-shopping-criteria-/commands.ts +8 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/selects-items-relevant-to-the-shopping-criteria-/decide.specs.ts +61 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/selects-items-relevant-to-the-shopping-criteria-/decide.ts +45 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/selects-items-relevant-to-the-shopping-criteria-/events.ts +14 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/selects-items-relevant-to-the-shopping-criteria-/evolve.ts +28 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/selects-items-relevant-to-the-shopping-criteria-/handle.ts +59 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/selects-items-relevant-to-the-shopping-criteria-/mutation.resolver.ts +30 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/selects-items-relevant-to-the-shopping-criteria-/register.ts +10 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/selects-items-relevant-to-the-shopping-criteria-/state.ts +47 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/views-suggested-items/projection.specs.ts +94 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/views-suggested-items/projection.ts +40 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/views-suggested-items/query.resolver.ts +59 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/views-suggested-items/state.ts +9 -0
- package/templates/shopping-app/server/src/domain/shared/ReadModel.d.ts +10 -0
- package/templates/shopping-app/server/src/domain/shared/ReadModel.d.ts.map +1 -0
- package/templates/shopping-app/server/src/domain/shared/ReadModel.js +19 -0
- package/templates/shopping-app/server/src/domain/shared/ReadModel.js.map +1 -0
- package/templates/shopping-app/server/src/domain/shared/ReadModel.ts +26 -0
- package/templates/shopping-app/server/src/domain/shared/index.d.ts +5 -0
- package/templates/shopping-app/server/src/domain/shared/index.d.ts.map +1 -0
- package/templates/shopping-app/server/src/domain/shared/index.js +5 -0
- package/templates/shopping-app/server/src/domain/shared/index.js.map +1 -0
- package/templates/shopping-app/server/src/domain/shared/index.ts +4 -0
- package/templates/shopping-app/server/src/domain/shared/reactorSpecification.d.ts +35 -0
- package/templates/shopping-app/server/src/domain/shared/reactorSpecification.d.ts.map +1 -0
- package/templates/shopping-app/server/src/domain/shared/reactorSpecification.js +155 -0
- package/templates/shopping-app/server/src/domain/shared/reactorSpecification.js.map +1 -0
- package/templates/shopping-app/server/src/domain/shared/reactorSpecification.ts +257 -0
- package/templates/shopping-app/server/src/domain/shared/sendCommand.d.ts +4 -0
- package/templates/shopping-app/server/src/domain/shared/sendCommand.d.ts.map +1 -0
- package/templates/shopping-app/server/src/domain/shared/sendCommand.js +17 -0
- package/templates/shopping-app/server/src/domain/shared/sendCommand.js.map +1 -0
- package/templates/shopping-app/server/src/domain/shared/sendCommand.ts +21 -0
- package/templates/shopping-app/server/src/domain/shared/types.d.ts +19 -0
- package/templates/shopping-app/server/src/domain/shared/types.d.ts.map +1 -0
- package/templates/shopping-app/server/src/domain/shared/types.js +39 -0
- package/templates/shopping-app/server/src/domain/shared/types.js.map +1 -0
- package/templates/shopping-app/server/src/domain/shared/types.ts +31 -0
- package/templates/shopping-app/server/src/integrations/ai-integration.ts +76 -0
- package/templates/shopping-app/server/src/integrations/cart-integration.ts +178 -0
- package/templates/shopping-app/server/src/integrations/index.ts +3 -0
- package/templates/shopping-app/server/src/integrations/product-catalogue-integration.ts +363 -0
- package/templates/shopping-app/server/src/server.ts +43 -0
- package/templates/shopping-app/server/src/utils/index.d.ts +4 -0
- package/templates/shopping-app/server/src/utils/index.d.ts.map +1 -0
- package/templates/shopping-app/server/src/utils/index.js +4 -0
- package/templates/shopping-app/server/src/utils/index.js.map +1 -0
- package/templates/shopping-app/server/src/utils/index.ts +3 -0
- package/templates/shopping-app/server/src/utils/loadProjections.d.ts +3 -0
- package/templates/shopping-app/server/src/utils/loadProjections.d.ts.map +1 -0
- package/templates/shopping-app/server/src/utils/loadProjections.js +23 -0
- package/templates/shopping-app/server/src/utils/loadProjections.js.map +1 -0
- package/templates/shopping-app/server/src/utils/loadProjections.ts +30 -0
- package/templates/shopping-app/server/src/utils/loadRegisterFiles.d.ts +6 -0
- package/templates/shopping-app/server/src/utils/loadRegisterFiles.d.ts.map +1 -0
- package/templates/shopping-app/server/src/utils/loadRegisterFiles.js +28 -0
- package/templates/shopping-app/server/src/utils/loadRegisterFiles.js.map +1 -0
- package/templates/shopping-app/server/src/utils/loadRegisterFiles.ts +41 -0
- package/templates/shopping-app/server/src/utils/loadResolvers.d.ts +5 -0
- package/templates/shopping-app/server/src/utils/loadResolvers.d.ts.map +1 -0
- package/templates/shopping-app/server/src/utils/loadResolvers.js +27 -0
- package/templates/shopping-app/server/src/utils/loadResolvers.js.map +1 -0
- package/templates/shopping-app/server/src/utils/loadResolvers.ts +36 -0
- package/templates/shopping-app/server/tsconfig.json +19 -0
- package/templates/shopping-app/server/vitest.config.ts +7 -0
- package/templates/shopping-app/tsconfig.json +21 -0
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import useEmblaCarousel, { type UseEmblaCarouselType } from 'embla-carousel-react';
|
|
3
|
+
import { ArrowLeft, ArrowRight } from 'lucide-react';
|
|
4
|
+
|
|
5
|
+
import { cn } from '../../lib/utils';
|
|
6
|
+
import { Button } from './button';
|
|
7
|
+
|
|
8
|
+
type CarouselApi = UseEmblaCarouselType[1];
|
|
9
|
+
type UseCarouselParameters = Parameters<typeof useEmblaCarousel>;
|
|
10
|
+
type CarouselOptions = UseCarouselParameters[0];
|
|
11
|
+
type CarouselPlugin = UseCarouselParameters[1];
|
|
12
|
+
|
|
13
|
+
type CarouselProps = {
|
|
14
|
+
opts?: CarouselOptions;
|
|
15
|
+
plugins?: CarouselPlugin;
|
|
16
|
+
orientation?: 'horizontal' | 'vertical';
|
|
17
|
+
setApi?: (api: CarouselApi) => void;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type CarouselContextProps = {
|
|
21
|
+
carouselRef: ReturnType<typeof useEmblaCarousel>[0];
|
|
22
|
+
api: ReturnType<typeof useEmblaCarousel>[1];
|
|
23
|
+
scrollPrev: () => void;
|
|
24
|
+
scrollNext: () => void;
|
|
25
|
+
canScrollPrev: boolean;
|
|
26
|
+
canScrollNext: boolean;
|
|
27
|
+
} & CarouselProps;
|
|
28
|
+
|
|
29
|
+
const CarouselContext = React.createContext<CarouselContextProps | null>(null);
|
|
30
|
+
|
|
31
|
+
function useCarousel() {
|
|
32
|
+
const context = React.useContext(CarouselContext);
|
|
33
|
+
|
|
34
|
+
if (!context) {
|
|
35
|
+
throw new Error('useCarousel must be used within a <Carousel />');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return context;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function Carousel({
|
|
42
|
+
orientation = 'horizontal',
|
|
43
|
+
opts,
|
|
44
|
+
setApi,
|
|
45
|
+
plugins,
|
|
46
|
+
className,
|
|
47
|
+
children,
|
|
48
|
+
...props
|
|
49
|
+
}: React.ComponentProps<'div'> & CarouselProps) {
|
|
50
|
+
const [carouselRef, api] = useEmblaCarousel(
|
|
51
|
+
{
|
|
52
|
+
...opts,
|
|
53
|
+
axis: orientation === 'horizontal' ? 'x' : 'y',
|
|
54
|
+
},
|
|
55
|
+
plugins,
|
|
56
|
+
);
|
|
57
|
+
const [canScrollPrev, setCanScrollPrev] = React.useState(false);
|
|
58
|
+
const [canScrollNext, setCanScrollNext] = React.useState(false);
|
|
59
|
+
|
|
60
|
+
const onSelect = React.useCallback((api: CarouselApi) => {
|
|
61
|
+
if (!api) return;
|
|
62
|
+
setCanScrollPrev(api.canScrollPrev());
|
|
63
|
+
setCanScrollNext(api.canScrollNext());
|
|
64
|
+
}, []);
|
|
65
|
+
|
|
66
|
+
const scrollPrev = React.useCallback(() => {
|
|
67
|
+
api?.scrollPrev();
|
|
68
|
+
}, [api]);
|
|
69
|
+
|
|
70
|
+
const scrollNext = React.useCallback(() => {
|
|
71
|
+
api?.scrollNext();
|
|
72
|
+
}, [api]);
|
|
73
|
+
|
|
74
|
+
const handleKeyDown = React.useCallback(
|
|
75
|
+
(event: React.KeyboardEvent<HTMLDivElement>) => {
|
|
76
|
+
if (event.key === 'ArrowLeft') {
|
|
77
|
+
event.preventDefault();
|
|
78
|
+
scrollPrev();
|
|
79
|
+
} else if (event.key === 'ArrowRight') {
|
|
80
|
+
event.preventDefault();
|
|
81
|
+
scrollNext();
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
[scrollPrev, scrollNext],
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
React.useEffect(() => {
|
|
88
|
+
if (!api || !setApi) return;
|
|
89
|
+
setApi(api);
|
|
90
|
+
}, [api, setApi]);
|
|
91
|
+
|
|
92
|
+
React.useEffect(() => {
|
|
93
|
+
if (!api) return;
|
|
94
|
+
onSelect(api);
|
|
95
|
+
api.on('reInit', onSelect);
|
|
96
|
+
api.on('select', onSelect);
|
|
97
|
+
|
|
98
|
+
return () => {
|
|
99
|
+
api?.off('select', onSelect);
|
|
100
|
+
};
|
|
101
|
+
}, [api, onSelect]);
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<CarouselContext.Provider
|
|
105
|
+
value={{
|
|
106
|
+
carouselRef,
|
|
107
|
+
api: api,
|
|
108
|
+
opts,
|
|
109
|
+
orientation: orientation || (opts?.axis === 'y' ? 'vertical' : 'horizontal'),
|
|
110
|
+
scrollPrev,
|
|
111
|
+
scrollNext,
|
|
112
|
+
canScrollPrev,
|
|
113
|
+
canScrollNext,
|
|
114
|
+
}}
|
|
115
|
+
>
|
|
116
|
+
<div
|
|
117
|
+
onKeyDownCapture={handleKeyDown}
|
|
118
|
+
className={cn('relative', className)}
|
|
119
|
+
role="region"
|
|
120
|
+
aria-roledescription="carousel"
|
|
121
|
+
data-slot="carousel"
|
|
122
|
+
{...props}
|
|
123
|
+
>
|
|
124
|
+
{children}
|
|
125
|
+
</div>
|
|
126
|
+
</CarouselContext.Provider>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function CarouselContent({ className, ...props }: React.ComponentProps<'div'>) {
|
|
131
|
+
const { carouselRef, orientation } = useCarousel();
|
|
132
|
+
|
|
133
|
+
return (
|
|
134
|
+
<div ref={carouselRef} className="overflow-hidden" data-slot="carousel-content">
|
|
135
|
+
<div className={cn('flex', orientation === 'horizontal' ? '-ml-4' : '-mt-4 flex-col', className)} {...props} />
|
|
136
|
+
</div>
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function CarouselItem({ className, ...props }: React.ComponentProps<'div'>) {
|
|
141
|
+
const { orientation } = useCarousel();
|
|
142
|
+
|
|
143
|
+
return (
|
|
144
|
+
<div
|
|
145
|
+
role="group"
|
|
146
|
+
aria-roledescription="slide"
|
|
147
|
+
data-slot="carousel-item"
|
|
148
|
+
className={cn('min-w-0 shrink-0 grow-0 basis-full', orientation === 'horizontal' ? 'pl-4' : 'pt-4', className)}
|
|
149
|
+
{...props}
|
|
150
|
+
/>
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function CarouselPrevious({
|
|
155
|
+
className,
|
|
156
|
+
variant = 'outline',
|
|
157
|
+
size = 'icon',
|
|
158
|
+
...props
|
|
159
|
+
}: React.ComponentProps<typeof Button>) {
|
|
160
|
+
const { orientation, scrollPrev, canScrollPrev } = useCarousel();
|
|
161
|
+
|
|
162
|
+
return (
|
|
163
|
+
<Button
|
|
164
|
+
data-slot="carousel-previous"
|
|
165
|
+
variant={variant}
|
|
166
|
+
size={size}
|
|
167
|
+
className={cn(
|
|
168
|
+
'absolute size-8 rounded-full',
|
|
169
|
+
orientation === 'horizontal'
|
|
170
|
+
? 'top-1/2 -left-12 -translate-y-1/2'
|
|
171
|
+
: '-top-12 left-1/2 -translate-x-1/2 rotate-90',
|
|
172
|
+
className,
|
|
173
|
+
)}
|
|
174
|
+
disabled={!canScrollPrev}
|
|
175
|
+
onClick={scrollPrev}
|
|
176
|
+
{...props}
|
|
177
|
+
>
|
|
178
|
+
<ArrowLeft />
|
|
179
|
+
{/*<span className="sr-only">Previous slide</span>*/}
|
|
180
|
+
</Button>
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function CarouselNext({
|
|
185
|
+
className,
|
|
186
|
+
variant = 'outline',
|
|
187
|
+
size = 'icon',
|
|
188
|
+
...props
|
|
189
|
+
}: React.ComponentProps<typeof Button>) {
|
|
190
|
+
const { orientation, scrollNext, canScrollNext } = useCarousel();
|
|
191
|
+
|
|
192
|
+
return (
|
|
193
|
+
<Button
|
|
194
|
+
data-slot="carousel-next"
|
|
195
|
+
variant={variant}
|
|
196
|
+
size={size}
|
|
197
|
+
className={cn(
|
|
198
|
+
'absolute size-8 rounded-full',
|
|
199
|
+
orientation === 'horizontal'
|
|
200
|
+
? 'top-1/2 -right-12 -translate-y-1/2'
|
|
201
|
+
: '-bottom-12 left-1/2 -translate-x-1/2 rotate-90',
|
|
202
|
+
className,
|
|
203
|
+
)}
|
|
204
|
+
disabled={!canScrollNext}
|
|
205
|
+
onClick={scrollNext}
|
|
206
|
+
{...props}
|
|
207
|
+
>
|
|
208
|
+
<ArrowRight />
|
|
209
|
+
{/*<span className="sr-only">Next slide</span>*/}
|
|
210
|
+
</Button>
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export { type CarouselApi, Carousel, CarouselContent, CarouselItem, CarouselPrevious, CarouselNext };
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as RechartsPrimitive from 'recharts';
|
|
3
|
+
|
|
4
|
+
import { cn } from '../../lib/utils';
|
|
5
|
+
|
|
6
|
+
// Format: { THEME_NAME: CSS_SELECTOR }
|
|
7
|
+
const THEMES = { light: '', dark: '.dark' } as const;
|
|
8
|
+
|
|
9
|
+
export type ChartConfig = {
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
11
|
+
[k in string]: {
|
|
12
|
+
label?: React.ReactNode;
|
|
13
|
+
icon?: React.ComponentType;
|
|
14
|
+
} & ({ color?: string; theme?: never } | { color?: never; theme: Record<keyof typeof THEMES, string> });
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
type ChartContextProps = {
|
|
18
|
+
config: ChartConfig;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const ChartContext = React.createContext<ChartContextProps | null>(null);
|
|
22
|
+
|
|
23
|
+
function useChart() {
|
|
24
|
+
const context = React.useContext(ChartContext);
|
|
25
|
+
|
|
26
|
+
if (!context) {
|
|
27
|
+
throw new Error('useChart must be used within a <ChartContainer />');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return context;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function ChartContainer({
|
|
34
|
+
id,
|
|
35
|
+
className,
|
|
36
|
+
children,
|
|
37
|
+
config,
|
|
38
|
+
...props
|
|
39
|
+
}: React.ComponentProps<'div'> & {
|
|
40
|
+
config: ChartConfig;
|
|
41
|
+
children: React.ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>['children'];
|
|
42
|
+
}) {
|
|
43
|
+
const uniqueId = React.useId();
|
|
44
|
+
const chartId = `chart-${id || uniqueId.replace(/:/g, '')}`;
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<ChartContext.Provider value={{ config }}>
|
|
48
|
+
<div
|
|
49
|
+
data-slot="chart"
|
|
50
|
+
data-chart={chartId}
|
|
51
|
+
className={cn(
|
|
52
|
+
"[&_.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-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 flex aspect-video justify-center text-xs [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
|
|
53
|
+
className,
|
|
54
|
+
)}
|
|
55
|
+
{...props}
|
|
56
|
+
>
|
|
57
|
+
<ChartStyle id={chartId} config={config} />
|
|
58
|
+
<RechartsPrimitive.ResponsiveContainer>{children}</RechartsPrimitive.ResponsiveContainer>
|
|
59
|
+
</div>
|
|
60
|
+
</ChartContext.Provider>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
|
|
65
|
+
const colorConfig = Object.entries(config).filter(([, config]) => config.theme || config.color);
|
|
66
|
+
|
|
67
|
+
if (!colorConfig.length) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<style
|
|
73
|
+
dangerouslySetInnerHTML={{
|
|
74
|
+
__html: Object.entries(THEMES)
|
|
75
|
+
.map(
|
|
76
|
+
([theme, prefix]) => `
|
|
77
|
+
${prefix} [data-chart=${id}] {
|
|
78
|
+
${colorConfig
|
|
79
|
+
.map(([key, itemConfig]) => {
|
|
80
|
+
const color = itemConfig.theme?.[theme as keyof typeof itemConfig.theme] || itemConfig.color;
|
|
81
|
+
return color ? ` --color-${key}: ${color};` : null;
|
|
82
|
+
})
|
|
83
|
+
.join('\n')}
|
|
84
|
+
}
|
|
85
|
+
`,
|
|
86
|
+
)
|
|
87
|
+
.join('\n'),
|
|
88
|
+
}}
|
|
89
|
+
/>
|
|
90
|
+
);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const ChartTooltip = RechartsPrimitive.Tooltip;
|
|
94
|
+
|
|
95
|
+
function ChartTooltipContent({
|
|
96
|
+
active,
|
|
97
|
+
payload,
|
|
98
|
+
className,
|
|
99
|
+
indicator = 'dot',
|
|
100
|
+
hideLabel = false,
|
|
101
|
+
hideIndicator = false,
|
|
102
|
+
label,
|
|
103
|
+
labelFormatter,
|
|
104
|
+
labelClassName,
|
|
105
|
+
formatter,
|
|
106
|
+
color,
|
|
107
|
+
nameKey,
|
|
108
|
+
labelKey,
|
|
109
|
+
}: React.ComponentProps<typeof RechartsPrimitive.Tooltip> &
|
|
110
|
+
React.ComponentProps<'div'> & {
|
|
111
|
+
hideLabel?: boolean;
|
|
112
|
+
hideIndicator?: boolean;
|
|
113
|
+
indicator?: 'line' | 'dot' | 'dashed';
|
|
114
|
+
nameKey?: string;
|
|
115
|
+
labelKey?: string;
|
|
116
|
+
}) {
|
|
117
|
+
const { config } = useChart();
|
|
118
|
+
|
|
119
|
+
const tooltipLabel = React.useMemo(() => {
|
|
120
|
+
if (hideLabel || !payload?.length) {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const [item] = payload;
|
|
125
|
+
const key = `${labelKey || item?.dataKey || item?.name || 'value'}`;
|
|
126
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
127
|
+
const value =
|
|
128
|
+
!labelKey && typeof label === 'string' ? config[label as keyof typeof config]?.label || label : itemConfig?.label;
|
|
129
|
+
|
|
130
|
+
if (labelFormatter) {
|
|
131
|
+
return <div className={cn('font-medium', labelClassName)}>{labelFormatter(value, payload)}</div>;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (!value) {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return <div className={cn('font-medium', labelClassName)}>{value}</div>;
|
|
139
|
+
}, [label, labelFormatter, payload, hideLabel, labelClassName, config, labelKey]);
|
|
140
|
+
|
|
141
|
+
if (!active || !payload?.length) {
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const nestLabel = payload.length === 1 && indicator !== 'dot';
|
|
146
|
+
|
|
147
|
+
return (
|
|
148
|
+
<div
|
|
149
|
+
className={cn(
|
|
150
|
+
'border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl',
|
|
151
|
+
className,
|
|
152
|
+
)}
|
|
153
|
+
>
|
|
154
|
+
{!nestLabel ? tooltipLabel : null}
|
|
155
|
+
<div className="grid gap-1.5">
|
|
156
|
+
{payload.map((item, index) => {
|
|
157
|
+
const key = `${nameKey || item.name || item.dataKey || 'value'}`;
|
|
158
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
159
|
+
const indicatorColor = color || item.payload.fill || item.color;
|
|
160
|
+
|
|
161
|
+
return (
|
|
162
|
+
<div
|
|
163
|
+
key={item.dataKey}
|
|
164
|
+
className={cn(
|
|
165
|
+
'[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5',
|
|
166
|
+
indicator === 'dot' && 'items-center',
|
|
167
|
+
)}
|
|
168
|
+
>
|
|
169
|
+
{formatter && item?.value !== undefined && item.name ? (
|
|
170
|
+
formatter(item.value, item.name, item, index, item.payload)
|
|
171
|
+
) : (
|
|
172
|
+
<>
|
|
173
|
+
{itemConfig?.icon ? (
|
|
174
|
+
<itemConfig.icon />
|
|
175
|
+
) : (
|
|
176
|
+
!hideIndicator && (
|
|
177
|
+
<div
|
|
178
|
+
className={cn('shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)', {
|
|
179
|
+
'h-2.5 w-2.5': indicator === 'dot',
|
|
180
|
+
'w-1': indicator === 'line',
|
|
181
|
+
'w-0 border-[1.5px] border-dashed bg-transparent': indicator === 'dashed',
|
|
182
|
+
'my-0.5': nestLabel && indicator === 'dashed',
|
|
183
|
+
})}
|
|
184
|
+
style={
|
|
185
|
+
{
|
|
186
|
+
'--color-bg': indicatorColor,
|
|
187
|
+
'--color-border': indicatorColor,
|
|
188
|
+
} as React.CSSProperties
|
|
189
|
+
}
|
|
190
|
+
/>
|
|
191
|
+
)
|
|
192
|
+
)}
|
|
193
|
+
<div
|
|
194
|
+
className={cn('flex flex-1 justify-between leading-none', nestLabel ? 'items-end' : 'items-center')}
|
|
195
|
+
>
|
|
196
|
+
<div className="grid gap-1.5">
|
|
197
|
+
{nestLabel ? tooltipLabel : null}
|
|
198
|
+
<span className="text-muted-foreground">{itemConfig?.label || item.name}</span>
|
|
199
|
+
</div>
|
|
200
|
+
{item.value && (
|
|
201
|
+
<span className="text-foreground font-mono font-medium tabular-nums">
|
|
202
|
+
{item.value.toLocaleString()}
|
|
203
|
+
</span>
|
|
204
|
+
)}
|
|
205
|
+
</div>
|
|
206
|
+
</>
|
|
207
|
+
)}
|
|
208
|
+
</div>
|
|
209
|
+
);
|
|
210
|
+
})}
|
|
211
|
+
</div>
|
|
212
|
+
</div>
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const ChartLegend = RechartsPrimitive.Legend;
|
|
217
|
+
|
|
218
|
+
function ChartLegendContent({
|
|
219
|
+
className,
|
|
220
|
+
hideIcon = false,
|
|
221
|
+
payload,
|
|
222
|
+
verticalAlign = 'bottom',
|
|
223
|
+
nameKey,
|
|
224
|
+
}: React.ComponentProps<'div'> &
|
|
225
|
+
Pick<RechartsPrimitive.LegendProps, 'payload' | 'verticalAlign'> & {
|
|
226
|
+
hideIcon?: boolean;
|
|
227
|
+
nameKey?: string;
|
|
228
|
+
}) {
|
|
229
|
+
const { config } = useChart();
|
|
230
|
+
|
|
231
|
+
if (!payload?.length) {
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return (
|
|
236
|
+
<div className={cn('flex items-center justify-center gap-4', verticalAlign === 'top' ? 'pb-3' : 'pt-3', className)}>
|
|
237
|
+
{payload.map((item) => {
|
|
238
|
+
const key = `${nameKey || item.dataKey || 'value'}`;
|
|
239
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
240
|
+
|
|
241
|
+
return (
|
|
242
|
+
<div
|
|
243
|
+
key={item.value}
|
|
244
|
+
className={cn('[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3')}
|
|
245
|
+
>
|
|
246
|
+
{itemConfig?.icon && !hideIcon ? (
|
|
247
|
+
<itemConfig.icon />
|
|
248
|
+
) : (
|
|
249
|
+
<div
|
|
250
|
+
className="h-2 w-2 shrink-0 rounded-[2px]"
|
|
251
|
+
style={{
|
|
252
|
+
backgroundColor: item.color,
|
|
253
|
+
}}
|
|
254
|
+
/>
|
|
255
|
+
)}
|
|
256
|
+
{itemConfig?.label}
|
|
257
|
+
</div>
|
|
258
|
+
);
|
|
259
|
+
})}
|
|
260
|
+
</div>
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// Helper to extract item config from a payload.
|
|
265
|
+
function getPayloadConfigFromPayload(config: ChartConfig, payload: unknown, key: string) {
|
|
266
|
+
if (typeof payload !== 'object' || payload === null) {
|
|
267
|
+
return undefined;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const payloadPayload =
|
|
271
|
+
'payload' in payload && typeof payload.payload === 'object' && payload.payload !== null
|
|
272
|
+
? payload.payload
|
|
273
|
+
: undefined;
|
|
274
|
+
|
|
275
|
+
let configLabelKey: string = key;
|
|
276
|
+
|
|
277
|
+
if (key in payload && typeof payload[key as keyof typeof payload] === 'string') {
|
|
278
|
+
configLabelKey = payload[key as keyof typeof payload] as string;
|
|
279
|
+
} else if (
|
|
280
|
+
payloadPayload &&
|
|
281
|
+
key in payloadPayload &&
|
|
282
|
+
typeof payloadPayload[key as keyof typeof payloadPayload] === 'string'
|
|
283
|
+
) {
|
|
284
|
+
configLabelKey = payloadPayload[key as keyof typeof payloadPayload] as string;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
return configLabelKey in config ? config[configLabelKey] : config[key as keyof typeof config];
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export { ChartContainer, ChartTooltip, ChartTooltipContent, ChartLegend, ChartLegendContent, ChartStyle };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
3
|
+
import { CheckIcon } from 'lucide-react';
|
|
4
|
+
|
|
5
|
+
import { cn } from '../../lib/utils';
|
|
6
|
+
|
|
7
|
+
function Checkbox({ className, ...props }: React.ComponentProps<typeof CheckboxPrimitive.Root>) {
|
|
8
|
+
return (
|
|
9
|
+
<CheckboxPrimitive.Root
|
|
10
|
+
data-slot="checkbox"
|
|
11
|
+
className={cn(
|
|
12
|
+
'peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50',
|
|
13
|
+
className,
|
|
14
|
+
)}
|
|
15
|
+
{...props}
|
|
16
|
+
>
|
|
17
|
+
<CheckboxPrimitive.Indicator
|
|
18
|
+
data-slot="checkbox-indicator"
|
|
19
|
+
className="flex items-center justify-center text-current transition-none"
|
|
20
|
+
>
|
|
21
|
+
<CheckIcon className="size-3.5" />
|
|
22
|
+
</CheckboxPrimitive.Indicator>
|
|
23
|
+
</CheckboxPrimitive.Root>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { Checkbox };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
|
|
2
|
+
|
|
3
|
+
function Collapsible({ ...props }: React.ComponentProps<typeof CollapsiblePrimitive.Root>) {
|
|
4
|
+
return <CollapsiblePrimitive.Root data-slot="collapsible" {...props} />;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function CollapsibleTrigger({ ...props }: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>) {
|
|
8
|
+
return <CollapsiblePrimitive.CollapsibleTrigger data-slot="collapsible-trigger" {...props} />;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function CollapsibleContent({ ...props }: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>) {
|
|
12
|
+
return <CollapsiblePrimitive.CollapsibleContent data-slot="collapsible-content" {...props} />;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { Collapsible, CollapsibleTrigger, CollapsibleContent };
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Command as CommandPrimitive } from 'cmdk';
|
|
3
|
+
import { SearchIcon } from 'lucide-react';
|
|
4
|
+
|
|
5
|
+
import { cn } from '../../lib/utils';
|
|
6
|
+
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from './dialog';
|
|
7
|
+
|
|
8
|
+
function Command({ className, ...props }: React.ComponentProps<typeof CommandPrimitive>) {
|
|
9
|
+
return (
|
|
10
|
+
<CommandPrimitive
|
|
11
|
+
data-slot="command"
|
|
12
|
+
className={cn(
|
|
13
|
+
'bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md',
|
|
14
|
+
className,
|
|
15
|
+
)}
|
|
16
|
+
{...props}
|
|
17
|
+
/>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function CommandDialog({
|
|
22
|
+
title = 'Command Palette',
|
|
23
|
+
description = 'Search for a command to run...',
|
|
24
|
+
children,
|
|
25
|
+
className,
|
|
26
|
+
showCloseButton = true,
|
|
27
|
+
...props
|
|
28
|
+
}: React.ComponentProps<typeof Dialog> & {
|
|
29
|
+
title?: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
className?: string;
|
|
32
|
+
showCloseButton?: boolean;
|
|
33
|
+
}) {
|
|
34
|
+
return (
|
|
35
|
+
<Dialog {...props}>
|
|
36
|
+
<DialogHeader className="sr-only">
|
|
37
|
+
<DialogTitle>{title}</DialogTitle>
|
|
38
|
+
<DialogDescription>{description}</DialogDescription>
|
|
39
|
+
</DialogHeader>
|
|
40
|
+
<DialogContent className={cn('overflow-hidden p-0', className)} showCloseButton={showCloseButton}>
|
|
41
|
+
<Command className="[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">
|
|
42
|
+
{children}
|
|
43
|
+
</Command>
|
|
44
|
+
</DialogContent>
|
|
45
|
+
</Dialog>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function CommandInput({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Input>) {
|
|
50
|
+
return (
|
|
51
|
+
<div data-slot="command-input-wrapper" className="flex h-9 items-center gap-2 border-b px-3">
|
|
52
|
+
<SearchIcon className="size-4 shrink-0 opacity-50" />
|
|
53
|
+
<CommandPrimitive.Input
|
|
54
|
+
data-slot="command-input"
|
|
55
|
+
className={cn(
|
|
56
|
+
'placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50',
|
|
57
|
+
className,
|
|
58
|
+
)}
|
|
59
|
+
{...props}
|
|
60
|
+
/>
|
|
61
|
+
</div>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function CommandList({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.List>) {
|
|
66
|
+
return (
|
|
67
|
+
<CommandPrimitive.List
|
|
68
|
+
data-slot="command-list"
|
|
69
|
+
className={cn('max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto', className)}
|
|
70
|
+
{...props}
|
|
71
|
+
/>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function CommandEmpty({ ...props }: React.ComponentProps<typeof CommandPrimitive.Empty>) {
|
|
76
|
+
return <CommandPrimitive.Empty data-slot="command-empty" className="py-6 text-center text-sm" {...props} />;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function CommandGroup({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Group>) {
|
|
80
|
+
return (
|
|
81
|
+
<CommandPrimitive.Group
|
|
82
|
+
data-slot="command-group"
|
|
83
|
+
className={cn(
|
|
84
|
+
'text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium',
|
|
85
|
+
className,
|
|
86
|
+
)}
|
|
87
|
+
{...props}
|
|
88
|
+
/>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function CommandSeparator({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Separator>) {
|
|
93
|
+
return (
|
|
94
|
+
<CommandPrimitive.Separator
|
|
95
|
+
data-slot="command-separator"
|
|
96
|
+
className={cn('bg-border -mx-1 h-px', className)}
|
|
97
|
+
{...props}
|
|
98
|
+
/>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function CommandItem({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Item>) {
|
|
103
|
+
return (
|
|
104
|
+
<CommandPrimitive.Item
|
|
105
|
+
data-slot="command-item"
|
|
106
|
+
className={cn(
|
|
107
|
+
"data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
108
|
+
className,
|
|
109
|
+
)}
|
|
110
|
+
{...props}
|
|
111
|
+
/>
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function CommandShortcut({ className, ...props }: React.ComponentProps<'span'>) {
|
|
116
|
+
return (
|
|
117
|
+
<span
|
|
118
|
+
data-slot="command-shortcut"
|
|
119
|
+
className={cn('text-muted-foreground ml-auto text-xs tracking-widest', className)}
|
|
120
|
+
{...props}
|
|
121
|
+
/>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export {
|
|
126
|
+
Command,
|
|
127
|
+
CommandDialog,
|
|
128
|
+
CommandInput,
|
|
129
|
+
CommandList,
|
|
130
|
+
CommandEmpty,
|
|
131
|
+
CommandGroup,
|
|
132
|
+
CommandItem,
|
|
133
|
+
CommandShortcut,
|
|
134
|
+
CommandSeparator,
|
|
135
|
+
};
|