create-rykira-app 1.0.0

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.
Files changed (143) hide show
  1. package/README.md +50 -0
  2. package/bin/cli.js +149 -0
  3. package/deployment.md +168 -0
  4. package/how-to-deploy-package.md +132 -0
  5. package/package.json +23 -0
  6. package/starter-usage.md +132 -0
  7. package/template/.dockerignore +11 -0
  8. package/template/.env.example +20 -0
  9. package/template/.eslintrc.js +13 -0
  10. package/template/.github/workflows/ci.yml +60 -0
  11. package/template/.prettierignore +7 -0
  12. package/template/.prettierrc +11 -0
  13. package/template/README.md +21 -0
  14. package/template/apps/admin/app/favicon.ico +0 -0
  15. package/template/apps/admin/app/layout.tsx +30 -0
  16. package/template/apps/admin/app/page.tsx +19 -0
  17. package/template/apps/admin/components/.gitkeep +0 -0
  18. package/template/apps/admin/components/theme-provider.tsx +71 -0
  19. package/template/apps/admin/components.json +23 -0
  20. package/template/apps/admin/eslint.config.js +4 -0
  21. package/template/apps/admin/hooks/.gitkeep +0 -0
  22. package/template/apps/admin/lib/.gitkeep +0 -0
  23. package/template/apps/admin/next-env.d.ts +6 -0
  24. package/template/apps/admin/next.config.mjs +6 -0
  25. package/template/apps/admin/nixpacks.toml +8 -0
  26. package/template/apps/admin/package.json +32 -0
  27. package/template/apps/admin/postcss.config.mjs +1 -0
  28. package/template/apps/admin/tsconfig.json +23 -0
  29. package/template/apps/api/nixpacks.toml +8 -0
  30. package/template/apps/api/package.json +32 -0
  31. package/template/apps/api/src/index.ts +11 -0
  32. package/template/apps/api/src/server.ts +21 -0
  33. package/template/apps/api/tsconfig.json +18 -0
  34. package/template/apps/web/app/favicon.ico +0 -0
  35. package/template/apps/web/app/layout.tsx +30 -0
  36. package/template/apps/web/app/page.tsx +19 -0
  37. package/template/apps/web/components/.gitkeep +0 -0
  38. package/template/apps/web/components/theme-provider.tsx +71 -0
  39. package/template/apps/web/components.json +23 -0
  40. package/template/apps/web/eslint.config.js +4 -0
  41. package/template/apps/web/hooks/.gitkeep +0 -0
  42. package/template/apps/web/lib/.gitkeep +0 -0
  43. package/template/apps/web/next-env.d.ts +6 -0
  44. package/template/apps/web/next.config.mjs +6 -0
  45. package/template/apps/web/nixpacks.toml +8 -0
  46. package/template/apps/web/package.json +32 -0
  47. package/template/apps/web/postcss.config.mjs +1 -0
  48. package/template/apps/web/tsconfig.json +23 -0
  49. package/template/infrastructure/docker/Dockerfile.admin +36 -0
  50. package/template/infrastructure/docker/Dockerfile.api +36 -0
  51. package/template/infrastructure/docker/Dockerfile.web +48 -0
  52. package/template/infrastructure/docker/compose.dev.yml +50 -0
  53. package/template/infrastructure/docker/compose.prod.yml +119 -0
  54. package/template/infrastructure/scripts/deploy.sh +3 -0
  55. package/template/infrastructure/scripts/dev.sh +5 -0
  56. package/template/infrastructure/scripts/init-traefik.sh +10 -0
  57. package/template/infrastructure/scripts/setup-server.sh +25 -0
  58. package/template/infrastructure/scripts/update.sh +7 -0
  59. package/template/infrastructure/traefik/acme.json +0 -0
  60. package/template/infrastructure/traefik/dynamic.yml +23 -0
  61. package/template/infrastructure/traefik/traefik.yml +26 -0
  62. package/template/package.json +25 -0
  63. package/template/packages/eslint-config/README.md +3 -0
  64. package/template/packages/eslint-config/base.js +32 -0
  65. package/template/packages/eslint-config/next.js +51 -0
  66. package/template/packages/eslint-config/package.json +26 -0
  67. package/template/packages/eslint-config/react-internal.js +41 -0
  68. package/template/packages/typescript-config/README.md +3 -0
  69. package/template/packages/typescript-config/base.json +20 -0
  70. package/template/packages/typescript-config/nextjs.json +13 -0
  71. package/template/packages/typescript-config/package.json +9 -0
  72. package/template/packages/typescript-config/react-library.json +8 -0
  73. package/template/packages/ui/components.json +23 -0
  74. package/template/packages/ui/eslint.config.js +4 -0
  75. package/template/packages/ui/package.json +52 -0
  76. package/template/packages/ui/postcss.config.mjs +6 -0
  77. package/template/packages/ui/src/components/.gitkeep +0 -0
  78. package/template/packages/ui/src/components/accordion.tsx +74 -0
  79. package/template/packages/ui/src/components/alert-dialog.tsx +187 -0
  80. package/template/packages/ui/src/components/alert.tsx +76 -0
  81. package/template/packages/ui/src/components/aspect-ratio.tsx +22 -0
  82. package/template/packages/ui/src/components/avatar.tsx +109 -0
  83. package/template/packages/ui/src/components/badge.tsx +52 -0
  84. package/template/packages/ui/src/components/breadcrumb.tsx +125 -0
  85. package/template/packages/ui/src/components/button-group.tsx +87 -0
  86. package/template/packages/ui/src/components/button.tsx +60 -0
  87. package/template/packages/ui/src/components/calendar.tsx +221 -0
  88. package/template/packages/ui/src/components/card.tsx +103 -0
  89. package/template/packages/ui/src/components/carousel.tsx +242 -0
  90. package/template/packages/ui/src/components/chart.tsx +356 -0
  91. package/template/packages/ui/src/components/checkbox.tsx +29 -0
  92. package/template/packages/ui/src/components/collapsible.tsx +21 -0
  93. package/template/packages/ui/src/components/combobox.tsx +297 -0
  94. package/template/packages/ui/src/components/command.tsx +196 -0
  95. package/template/packages/ui/src/components/context-menu.tsx +271 -0
  96. package/template/packages/ui/src/components/dialog.tsx +157 -0
  97. package/template/packages/ui/src/components/direction.tsx +6 -0
  98. package/template/packages/ui/src/components/drawer.tsx +131 -0
  99. package/template/packages/ui/src/components/dropdown-menu.tsx +268 -0
  100. package/template/packages/ui/src/components/empty.tsx +101 -0
  101. package/template/packages/ui/src/components/field.tsx +238 -0
  102. package/template/packages/ui/src/components/hover-card.tsx +51 -0
  103. package/template/packages/ui/src/components/input-group.tsx +158 -0
  104. package/template/packages/ui/src/components/input-otp.tsx +87 -0
  105. package/template/packages/ui/src/components/input.tsx +20 -0
  106. package/template/packages/ui/src/components/item.tsx +201 -0
  107. package/template/packages/ui/src/components/kbd.tsx +26 -0
  108. package/template/packages/ui/src/components/label.tsx +20 -0
  109. package/template/packages/ui/src/components/menubar.tsx +280 -0
  110. package/template/packages/ui/src/components/native-select.tsx +52 -0
  111. package/template/packages/ui/src/components/navigation-menu.tsx +168 -0
  112. package/template/packages/ui/src/components/pagination.tsx +130 -0
  113. package/template/packages/ui/src/components/popover.tsx +90 -0
  114. package/template/packages/ui/src/components/progress.tsx +83 -0
  115. package/template/packages/ui/src/components/radio-group.tsx +38 -0
  116. package/template/packages/ui/src/components/resizable.tsx +50 -0
  117. package/template/packages/ui/src/components/scroll-area.tsx +55 -0
  118. package/template/packages/ui/src/components/select.tsx +201 -0
  119. package/template/packages/ui/src/components/separator.tsx +25 -0
  120. package/template/packages/ui/src/components/sheet.tsx +135 -0
  121. package/template/packages/ui/src/components/sidebar.tsx +723 -0
  122. package/template/packages/ui/src/components/skeleton.tsx +13 -0
  123. package/template/packages/ui/src/components/slider.tsx +59 -0
  124. package/template/packages/ui/src/components/sonner.tsx +49 -0
  125. package/template/packages/ui/src/components/spinner.tsx +10 -0
  126. package/template/packages/ui/src/components/switch.tsx +32 -0
  127. package/template/packages/ui/src/components/table.tsx +116 -0
  128. package/template/packages/ui/src/components/tabs.tsx +82 -0
  129. package/template/packages/ui/src/components/textarea.tsx +18 -0
  130. package/template/packages/ui/src/components/toggle-group.tsx +89 -0
  131. package/template/packages/ui/src/components/toggle.tsx +44 -0
  132. package/template/packages/ui/src/components/tooltip.tsx +66 -0
  133. package/template/packages/ui/src/hooks/.gitkeep +0 -0
  134. package/template/packages/ui/src/hooks/use-mobile.ts +19 -0
  135. package/template/packages/ui/src/lib/.gitkeep +0 -0
  136. package/template/packages/ui/src/lib/utils.ts +6 -0
  137. package/template/packages/ui/src/styles/globals.css +128 -0
  138. package/template/packages/ui/tsconfig.json +11 -0
  139. package/template/packages/ui/tsconfig.lint.json +8 -0
  140. package/template/pnpm-lock.yaml +9103 -0
  141. package/template/pnpm-workspace.yaml +3 -0
  142. package/template/tsconfig.json +4 -0
  143. package/template/turbo.json +24 -0
@@ -0,0 +1,242 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import useEmblaCarousel, {
5
+ type UseEmblaCarouselType,
6
+ } from "embla-carousel-react"
7
+
8
+ import { cn } from "@workspace/ui/lib/utils"
9
+ import { Button } from "@workspace/ui/components/button"
10
+ import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react"
11
+
12
+ type CarouselApi = UseEmblaCarouselType[1]
13
+ type UseCarouselParameters = Parameters<typeof useEmblaCarousel>
14
+ type CarouselOptions = UseCarouselParameters[0]
15
+ type CarouselPlugin = UseCarouselParameters[1]
16
+
17
+ type CarouselProps = {
18
+ opts?: CarouselOptions
19
+ plugins?: CarouselPlugin
20
+ orientation?: "horizontal" | "vertical"
21
+ setApi?: (api: CarouselApi) => void
22
+ }
23
+
24
+ type CarouselContextProps = {
25
+ carouselRef: ReturnType<typeof useEmblaCarousel>[0]
26
+ api: ReturnType<typeof useEmblaCarousel>[1]
27
+ scrollPrev: () => void
28
+ scrollNext: () => void
29
+ canScrollPrev: boolean
30
+ canScrollNext: boolean
31
+ } & CarouselProps
32
+
33
+ const CarouselContext = React.createContext<CarouselContextProps | null>(null)
34
+
35
+ function useCarousel() {
36
+ const context = React.useContext(CarouselContext)
37
+
38
+ if (!context) {
39
+ throw new Error("useCarousel must be used within a <Carousel />")
40
+ }
41
+
42
+ return context
43
+ }
44
+
45
+ function Carousel({
46
+ orientation = "horizontal",
47
+ opts,
48
+ setApi,
49
+ plugins,
50
+ className,
51
+ children,
52
+ ...props
53
+ }: React.ComponentProps<"div"> & CarouselProps) {
54
+ const [carouselRef, api] = useEmblaCarousel(
55
+ {
56
+ ...opts,
57
+ axis: orientation === "horizontal" ? "x" : "y",
58
+ },
59
+ plugins
60
+ )
61
+ const [canScrollPrev, setCanScrollPrev] = React.useState(false)
62
+ const [canScrollNext, setCanScrollNext] = React.useState(false)
63
+
64
+ const onSelect = React.useCallback((api: CarouselApi) => {
65
+ if (!api) return
66
+ setCanScrollPrev(api.canScrollPrev())
67
+ setCanScrollNext(api.canScrollNext())
68
+ }, [])
69
+
70
+ const scrollPrev = React.useCallback(() => {
71
+ api?.scrollPrev()
72
+ }, [api])
73
+
74
+ const scrollNext = React.useCallback(() => {
75
+ api?.scrollNext()
76
+ }, [api])
77
+
78
+ const handleKeyDown = React.useCallback(
79
+ (event: React.KeyboardEvent<HTMLDivElement>) => {
80
+ if (event.key === "ArrowLeft") {
81
+ event.preventDefault()
82
+ scrollPrev()
83
+ } else if (event.key === "ArrowRight") {
84
+ event.preventDefault()
85
+ scrollNext()
86
+ }
87
+ },
88
+ [scrollPrev, scrollNext]
89
+ )
90
+
91
+ React.useEffect(() => {
92
+ if (!api || !setApi) return
93
+ setApi(api)
94
+ }, [api, setApi])
95
+
96
+ React.useEffect(() => {
97
+ if (!api) return
98
+ onSelect(api)
99
+ api.on("reInit", onSelect)
100
+ api.on("select", onSelect)
101
+
102
+ return () => {
103
+ api?.off("select", onSelect)
104
+ }
105
+ }, [api, onSelect])
106
+
107
+ return (
108
+ <CarouselContext.Provider
109
+ value={{
110
+ carouselRef,
111
+ api: api,
112
+ opts,
113
+ orientation:
114
+ orientation || (opts?.axis === "y" ? "vertical" : "horizontal"),
115
+ scrollPrev,
116
+ scrollNext,
117
+ canScrollPrev,
118
+ canScrollNext,
119
+ }}
120
+ >
121
+ <div
122
+ onKeyDownCapture={handleKeyDown}
123
+ className={cn("relative", className)}
124
+ role="region"
125
+ aria-roledescription="carousel"
126
+ data-slot="carousel"
127
+ {...props}
128
+ >
129
+ {children}
130
+ </div>
131
+ </CarouselContext.Provider>
132
+ )
133
+ }
134
+
135
+ function CarouselContent({ className, ...props }: React.ComponentProps<"div">) {
136
+ const { carouselRef, orientation } = useCarousel()
137
+
138
+ return (
139
+ <div
140
+ ref={carouselRef}
141
+ className="overflow-hidden"
142
+ data-slot="carousel-content"
143
+ >
144
+ <div
145
+ className={cn(
146
+ "flex",
147
+ orientation === "horizontal" ? "-ml-4" : "-mt-4 flex-col",
148
+ className
149
+ )}
150
+ {...props}
151
+ />
152
+ </div>
153
+ )
154
+ }
155
+
156
+ function CarouselItem({ className, ...props }: React.ComponentProps<"div">) {
157
+ const { orientation } = useCarousel()
158
+
159
+ return (
160
+ <div
161
+ role="group"
162
+ aria-roledescription="slide"
163
+ data-slot="carousel-item"
164
+ className={cn(
165
+ "min-w-0 shrink-0 grow-0 basis-full",
166
+ orientation === "horizontal" ? "pl-4" : "pt-4",
167
+ className
168
+ )}
169
+ {...props}
170
+ />
171
+ )
172
+ }
173
+
174
+ function CarouselPrevious({
175
+ className,
176
+ variant = "outline",
177
+ size = "icon-sm",
178
+ ...props
179
+ }: React.ComponentProps<typeof Button>) {
180
+ const { orientation, scrollPrev, canScrollPrev } = useCarousel()
181
+
182
+ return (
183
+ <Button
184
+ data-slot="carousel-previous"
185
+ variant={variant}
186
+ size={size}
187
+ className={cn(
188
+ "absolute touch-manipulation rounded-full",
189
+ orientation === "horizontal"
190
+ ? "top-1/2 -left-12 -translate-y-1/2"
191
+ : "-top-12 left-1/2 -translate-x-1/2 rotate-90",
192
+ className
193
+ )}
194
+ disabled={!canScrollPrev}
195
+ onClick={scrollPrev}
196
+ {...props}
197
+ >
198
+ <ChevronLeftIcon />
199
+ <span className="sr-only">Previous slide</span>
200
+ </Button>
201
+ )
202
+ }
203
+
204
+ function CarouselNext({
205
+ className,
206
+ variant = "outline",
207
+ size = "icon-sm",
208
+ ...props
209
+ }: React.ComponentProps<typeof Button>) {
210
+ const { orientation, scrollNext, canScrollNext } = useCarousel()
211
+
212
+ return (
213
+ <Button
214
+ data-slot="carousel-next"
215
+ variant={variant}
216
+ size={size}
217
+ className={cn(
218
+ "absolute touch-manipulation rounded-full",
219
+ orientation === "horizontal"
220
+ ? "top-1/2 -right-12 -translate-y-1/2"
221
+ : "-bottom-12 left-1/2 -translate-x-1/2 rotate-90",
222
+ className
223
+ )}
224
+ disabled={!canScrollNext}
225
+ onClick={scrollNext}
226
+ {...props}
227
+ >
228
+ <ChevronRightIcon />
229
+ <span className="sr-only">Next slide</span>
230
+ </Button>
231
+ )
232
+ }
233
+
234
+ export {
235
+ type CarouselApi,
236
+ Carousel,
237
+ CarouselContent,
238
+ CarouselItem,
239
+ CarouselPrevious,
240
+ CarouselNext,
241
+ useCarousel,
242
+ }
@@ -0,0 +1,356 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import * as RechartsPrimitive from "recharts"
5
+
6
+ import { cn } from "@workspace/ui/lib/utils"
7
+
8
+ // Format: { THEME_NAME: CSS_SELECTOR }
9
+ const THEMES = { light: "", dark: ".dark" } as const
10
+
11
+ export type ChartConfig = {
12
+ [k in string]: {
13
+ label?: React.ReactNode
14
+ icon?: React.ComponentType
15
+ } & (
16
+ | { color?: string; theme?: never }
17
+ | { color?: never; theme: Record<keyof typeof THEMES, string> }
18
+ )
19
+ }
20
+
21
+ type ChartContextProps = {
22
+ config: ChartConfig
23
+ }
24
+
25
+ const ChartContext = React.createContext<ChartContextProps | null>(null)
26
+
27
+ function useChart() {
28
+ const context = React.useContext(ChartContext)
29
+
30
+ if (!context) {
31
+ throw new Error("useChart must be used within a <ChartContainer />")
32
+ }
33
+
34
+ return context
35
+ }
36
+
37
+ function ChartContainer({
38
+ id,
39
+ className,
40
+ children,
41
+ config,
42
+ ...props
43
+ }: React.ComponentProps<"div"> & {
44
+ config: ChartConfig
45
+ children: React.ComponentProps<
46
+ typeof RechartsPrimitive.ResponsiveContainer
47
+ >["children"]
48
+ }) {
49
+ const uniqueId = React.useId()
50
+ const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`
51
+
52
+ return (
53
+ <ChartContext.Provider value={{ config }}>
54
+ <div
55
+ data-slot="chart"
56
+ data-chart={chartId}
57
+ className={cn(
58
+ "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-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",
59
+ className
60
+ )}
61
+ {...props}
62
+ >
63
+ <ChartStyle id={chartId} config={config} />
64
+ <RechartsPrimitive.ResponsiveContainer>
65
+ {children}
66
+ </RechartsPrimitive.ResponsiveContainer>
67
+ </div>
68
+ </ChartContext.Provider>
69
+ )
70
+ }
71
+
72
+ const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
73
+ const colorConfig = Object.entries(config).filter(
74
+ ([, config]) => config.theme || config.color
75
+ )
76
+
77
+ if (!colorConfig.length) {
78
+ return null
79
+ }
80
+
81
+ return (
82
+ <style
83
+ dangerouslySetInnerHTML={{
84
+ __html: Object.entries(THEMES)
85
+ .map(
86
+ ([theme, prefix]) => `
87
+ ${prefix} [data-chart=${id}] {
88
+ ${colorConfig
89
+ .map(([key, itemConfig]) => {
90
+ const color =
91
+ itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ||
92
+ itemConfig.color
93
+ return color ? ` --color-${key}: ${color};` : null
94
+ })
95
+ .join("\n")}
96
+ }
97
+ `
98
+ )
99
+ .join("\n"),
100
+ }}
101
+ />
102
+ )
103
+ }
104
+
105
+ const ChartTooltip = RechartsPrimitive.Tooltip
106
+
107
+ function ChartTooltipContent({
108
+ active,
109
+ payload,
110
+ className,
111
+ indicator = "dot",
112
+ hideLabel = false,
113
+ hideIndicator = false,
114
+ label,
115
+ labelFormatter,
116
+ labelClassName,
117
+ formatter,
118
+ color,
119
+ nameKey,
120
+ labelKey,
121
+ }: React.ComponentProps<typeof RechartsPrimitive.Tooltip> &
122
+ React.ComponentProps<"div"> & {
123
+ hideLabel?: boolean
124
+ hideIndicator?: boolean
125
+ indicator?: "line" | "dot" | "dashed"
126
+ nameKey?: string
127
+ labelKey?: string
128
+ }) {
129
+ const { config } = useChart()
130
+
131
+ const tooltipLabel = React.useMemo(() => {
132
+ if (hideLabel || !payload?.length) {
133
+ return null
134
+ }
135
+
136
+ const [item] = payload
137
+ const key = `${labelKey || item?.dataKey || item?.name || "value"}`
138
+ const itemConfig = getPayloadConfigFromPayload(config, item, key)
139
+ const value =
140
+ !labelKey && typeof label === "string"
141
+ ? config[label as keyof typeof config]?.label || label
142
+ : itemConfig?.label
143
+
144
+ if (labelFormatter) {
145
+ return (
146
+ <div className={cn("font-medium", labelClassName)}>
147
+ {labelFormatter(value, payload)}
148
+ </div>
149
+ )
150
+ }
151
+
152
+ if (!value) {
153
+ return null
154
+ }
155
+
156
+ return <div className={cn("font-medium", labelClassName)}>{value}</div>
157
+ }, [
158
+ label,
159
+ labelFormatter,
160
+ payload,
161
+ hideLabel,
162
+ labelClassName,
163
+ config,
164
+ labelKey,
165
+ ])
166
+
167
+ if (!active || !payload?.length) {
168
+ return null
169
+ }
170
+
171
+ const nestLabel = payload.length === 1 && indicator !== "dot"
172
+
173
+ return (
174
+ <div
175
+ className={cn(
176
+ "grid min-w-32 items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",
177
+ className
178
+ )}
179
+ >
180
+ {!nestLabel ? tooltipLabel : null}
181
+ <div className="grid gap-1.5">
182
+ {payload
183
+ .filter((item) => item.type !== "none")
184
+ .map((item, index) => {
185
+ const key = `${nameKey || item.name || item.dataKey || "value"}`
186
+ const itemConfig = getPayloadConfigFromPayload(config, item, key)
187
+ const indicatorColor = color || item.payload.fill || item.color
188
+
189
+ return (
190
+ <div
191
+ key={item.dataKey}
192
+ className={cn(
193
+ "flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",
194
+ indicator === "dot" && "items-center"
195
+ )}
196
+ >
197
+ {formatter && item?.value !== undefined && item.name ? (
198
+ formatter(item.value, item.name, item, index, item.payload)
199
+ ) : (
200
+ <>
201
+ {itemConfig?.icon ? (
202
+ <itemConfig.icon />
203
+ ) : (
204
+ !hideIndicator && (
205
+ <div
206
+ className={cn(
207
+ "shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",
208
+ {
209
+ "h-2.5 w-2.5": indicator === "dot",
210
+ "w-1": indicator === "line",
211
+ "w-0 border-[1.5px] border-dashed bg-transparent":
212
+ indicator === "dashed",
213
+ "my-0.5": nestLabel && indicator === "dashed",
214
+ }
215
+ )}
216
+ style={
217
+ {
218
+ "--color-bg": indicatorColor,
219
+ "--color-border": indicatorColor,
220
+ } as React.CSSProperties
221
+ }
222
+ />
223
+ )
224
+ )}
225
+ <div
226
+ className={cn(
227
+ "flex flex-1 justify-between leading-none",
228
+ nestLabel ? "items-end" : "items-center"
229
+ )}
230
+ >
231
+ <div className="grid gap-1.5">
232
+ {nestLabel ? tooltipLabel : null}
233
+ <span className="text-muted-foreground">
234
+ {itemConfig?.label || item.name}
235
+ </span>
236
+ </div>
237
+ {item.value && (
238
+ <span className="font-mono font-medium text-foreground tabular-nums">
239
+ {item.value.toLocaleString()}
240
+ </span>
241
+ )}
242
+ </div>
243
+ </>
244
+ )}
245
+ </div>
246
+ )
247
+ })}
248
+ </div>
249
+ </div>
250
+ )
251
+ }
252
+
253
+ const ChartLegend = RechartsPrimitive.Legend
254
+
255
+ function ChartLegendContent({
256
+ className,
257
+ hideIcon = false,
258
+ payload,
259
+ verticalAlign = "bottom",
260
+ nameKey,
261
+ }: React.ComponentProps<"div"> &
262
+ Pick<RechartsPrimitive.LegendProps, "payload" | "verticalAlign"> & {
263
+ hideIcon?: boolean
264
+ nameKey?: string
265
+ }) {
266
+ const { config } = useChart()
267
+
268
+ if (!payload?.length) {
269
+ return null
270
+ }
271
+
272
+ return (
273
+ <div
274
+ className={cn(
275
+ "flex items-center justify-center gap-4",
276
+ verticalAlign === "top" ? "pb-3" : "pt-3",
277
+ className
278
+ )}
279
+ >
280
+ {payload
281
+ .filter((item) => item.type !== "none")
282
+ .map((item) => {
283
+ const key = `${nameKey || item.dataKey || "value"}`
284
+ const itemConfig = getPayloadConfigFromPayload(config, item, key)
285
+
286
+ return (
287
+ <div
288
+ key={item.value}
289
+ className={cn(
290
+ "flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"
291
+ )}
292
+ >
293
+ {itemConfig?.icon && !hideIcon ? (
294
+ <itemConfig.icon />
295
+ ) : (
296
+ <div
297
+ className="h-2 w-2 shrink-0 rounded-[2px]"
298
+ style={{
299
+ backgroundColor: item.color,
300
+ }}
301
+ />
302
+ )}
303
+ {itemConfig?.label}
304
+ </div>
305
+ )
306
+ })}
307
+ </div>
308
+ )
309
+ }
310
+
311
+ function getPayloadConfigFromPayload(
312
+ config: ChartConfig,
313
+ payload: unknown,
314
+ key: string
315
+ ) {
316
+ if (typeof payload !== "object" || payload === null) {
317
+ return undefined
318
+ }
319
+
320
+ const payloadPayload =
321
+ "payload" in payload &&
322
+ typeof payload.payload === "object" &&
323
+ payload.payload !== null
324
+ ? payload.payload
325
+ : undefined
326
+
327
+ let configLabelKey: string = key
328
+
329
+ if (
330
+ key in payload &&
331
+ typeof payload[key as keyof typeof payload] === "string"
332
+ ) {
333
+ configLabelKey = payload[key as keyof typeof payload] as string
334
+ } else if (
335
+ payloadPayload &&
336
+ key in payloadPayload &&
337
+ typeof payloadPayload[key as keyof typeof payloadPayload] === "string"
338
+ ) {
339
+ configLabelKey = payloadPayload[
340
+ key as keyof typeof payloadPayload
341
+ ] as string
342
+ }
343
+
344
+ return configLabelKey in config
345
+ ? config[configLabelKey]
346
+ : config[key as keyof typeof config]
347
+ }
348
+
349
+ export {
350
+ ChartContainer,
351
+ ChartTooltip,
352
+ ChartTooltipContent,
353
+ ChartLegend,
354
+ ChartLegendContent,
355
+ ChartStyle,
356
+ }
@@ -0,0 +1,29 @@
1
+ "use client"
2
+
3
+ import { Checkbox as CheckboxPrimitive } from "@base-ui/react/checkbox"
4
+
5
+ import { cn } from "@workspace/ui/lib/utils"
6
+ import { CheckIcon } from "lucide-react"
7
+
8
+ function Checkbox({ className, ...props }: CheckboxPrimitive.Root.Props) {
9
+ return (
10
+ <CheckboxPrimitive.Root
11
+ data-slot="checkbox"
12
+ className={cn(
13
+ "peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input shadow-xs transition-shadow outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary",
14
+ className
15
+ )}
16
+ {...props}
17
+ >
18
+ <CheckboxPrimitive.Indicator
19
+ data-slot="checkbox-indicator"
20
+ className="grid place-content-center text-current transition-none [&>svg]:size-3.5"
21
+ >
22
+ <CheckIcon
23
+ />
24
+ </CheckboxPrimitive.Indicator>
25
+ </CheckboxPrimitive.Root>
26
+ )
27
+ }
28
+
29
+ export { Checkbox }
@@ -0,0 +1,21 @@
1
+ "use client"
2
+
3
+ import { Collapsible as CollapsiblePrimitive } from "@base-ui/react/collapsible"
4
+
5
+ function Collapsible({ ...props }: CollapsiblePrimitive.Root.Props) {
6
+ return <CollapsiblePrimitive.Root data-slot="collapsible" {...props} />
7
+ }
8
+
9
+ function CollapsibleTrigger({ ...props }: CollapsiblePrimitive.Trigger.Props) {
10
+ return (
11
+ <CollapsiblePrimitive.Trigger data-slot="collapsible-trigger" {...props} />
12
+ )
13
+ }
14
+
15
+ function CollapsibleContent({ ...props }: CollapsiblePrimitive.Panel.Props) {
16
+ return (
17
+ <CollapsiblePrimitive.Panel data-slot="collapsible-content" {...props} />
18
+ )
19
+ }
20
+
21
+ export { Collapsible, CollapsibleTrigger, CollapsibleContent }