@saena-io/create 0.1.0 → 0.2.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 (100) hide show
  1. package/dist/index.js +9 -9
  2. package/package.json +1 -1
  3. package/template/base/package.json +44 -2
  4. package/template/base/scripts/ui-update.ts +83 -0
  5. package/template/base/src/components/ui/accordion.tsx +75 -0
  6. package/template/base/src/components/ui/alert-dialog.tsx +162 -0
  7. package/template/base/src/components/ui/alert.tsx +73 -0
  8. package/template/base/src/components/ui/app-sidebar.tsx +183 -0
  9. package/template/base/src/components/ui/aspect-ratio.tsx +22 -0
  10. package/template/base/src/components/ui/asset-input.tsx +211 -0
  11. package/template/base/src/components/ui/avatar.tsx +91 -0
  12. package/template/base/src/components/ui/badge.tsx +50 -0
  13. package/template/base/src/components/ui/breadcrumb.tsx +104 -0
  14. package/template/base/src/components/ui/button-group.tsx +78 -0
  15. package/template/base/src/components/ui/button.tsx +56 -0
  16. package/template/base/src/components/ui/calendar.tsx +205 -0
  17. package/template/base/src/components/ui/card.tsx +85 -0
  18. package/template/base/src/components/ui/carousel.tsx +232 -0
  19. package/template/base/src/components/ui/chart.tsx +337 -0
  20. package/template/base/src/components/ui/checkbox.tsx +29 -0
  21. package/template/base/src/components/ui/collapsible.tsx +15 -0
  22. package/template/base/src/components/ui/combobox.tsx +276 -0
  23. package/template/base/src/components/ui/command.tsx +190 -0
  24. package/template/base/src/components/ui/context-menu.tsx +243 -0
  25. package/template/base/src/components/ui/dialog.tsx +134 -0
  26. package/template/base/src/components/ui/direction.tsx +4 -0
  27. package/template/base/src/components/ui/drawer.tsx +120 -0
  28. package/template/base/src/components/ui/dropdown-menu.tsx +254 -0
  29. package/template/base/src/components/ui/empty.tsx +94 -0
  30. package/template/base/src/components/ui/field.tsx +222 -0
  31. package/template/base/src/components/ui/focal-point-picker.tsx +175 -0
  32. package/template/base/src/components/ui/hover-card.tsx +46 -0
  33. package/template/base/src/components/ui/input-group.tsx +149 -0
  34. package/template/base/src/components/ui/input-otp.tsx +85 -0
  35. package/template/base/src/components/ui/input.tsx +20 -0
  36. package/template/base/src/components/ui/item.tsx +188 -0
  37. package/template/base/src/components/ui/kbd.tsx +26 -0
  38. package/template/base/src/components/ui/label.tsx +20 -0
  39. package/template/base/src/components/ui/menubar.tsx +268 -0
  40. package/template/base/src/components/ui/native-select.tsx +58 -0
  41. package/template/base/src/components/ui/nav-main.tsx +70 -0
  42. package/template/base/src/components/ui/nav-projects.tsx +97 -0
  43. package/template/base/src/components/ui/nav-secondary.tsx +37 -0
  44. package/template/base/src/components/ui/nav-user.tsx +108 -0
  45. package/template/base/src/components/ui/navigation-menu.tsx +164 -0
  46. package/template/base/src/components/ui/pagination.tsx +123 -0
  47. package/template/base/src/components/ui/popover.tsx +80 -0
  48. package/template/base/src/components/ui/progress.tsx +66 -0
  49. package/template/base/src/components/ui/radio-group.tsx +36 -0
  50. package/template/base/src/components/ui/resizable.tsx +42 -0
  51. package/template/base/src/components/ui/rich-text/ai-chat-editor.tsx +20 -0
  52. package/template/base/src/components/ui/rich-text/ai-command.tsx +90 -0
  53. package/template/base/src/components/ui/rich-text/ai-copilot.tsx +67 -0
  54. package/template/base/src/components/ui/rich-text/ai-menu.tsx +456 -0
  55. package/template/base/src/components/ui/rich-text/ai-node.tsx +42 -0
  56. package/template/base/src/components/ui/rich-text/ai-toolbar-button.tsx +29 -0
  57. package/template/base/src/components/ui/rich-text/block-draggable.tsx +187 -0
  58. package/template/base/src/components/ui/rich-text/block-selection.tsx +17 -0
  59. package/template/base/src/components/ui/rich-text/code-block-node.tsx +204 -0
  60. package/template/base/src/components/ui/rich-text/codec.ts +63 -0
  61. package/template/base/src/components/ui/rich-text/extension.ts +53 -0
  62. package/template/base/src/components/ui/rich-text/ghost-text.tsx +23 -0
  63. package/template/base/src/components/ui/rich-text/import-export-toolbar.tsx +103 -0
  64. package/template/base/src/components/ui/rich-text/link.tsx +18 -0
  65. package/template/base/src/components/ui/rich-text/list-node.tsx +65 -0
  66. package/template/base/src/components/ui/rich-text/nodes.tsx +44 -0
  67. package/template/base/src/components/ui/rich-text/plugins.ts +233 -0
  68. package/template/base/src/components/ui/rich-text/rich-text-editor.tsx +82 -0
  69. package/template/base/src/components/ui/rich-text/static.tsx +117 -0
  70. package/template/base/src/components/ui/rich-text/table-node.tsx +934 -0
  71. package/template/base/src/components/ui/rich-text/table-toolbar.tsx +232 -0
  72. package/template/base/src/components/ui/rich-text/toggle-node.tsx +36 -0
  73. package/template/base/src/components/ui/rich-text/toolbar-slots.ts +41 -0
  74. package/template/base/src/components/ui/rich-text/toolbar.tsx +668 -0
  75. package/template/base/src/components/ui/rich-text/use-ai-chat.ts +35 -0
  76. package/template/base/src/components/ui/rich-text/variable-type.ts +4 -0
  77. package/template/base/src/components/ui/rich-text/variable.tsx +97 -0
  78. package/template/base/src/components/ui/scroll-area.tsx +49 -0
  79. package/template/base/src/components/ui/select.tsx +202 -0
  80. package/template/base/src/components/ui/separator.tsx +19 -0
  81. package/template/base/src/components/ui/sheet.tsx +126 -0
  82. package/template/base/src/components/ui/sidebar.tsx +695 -0
  83. package/template/base/src/components/ui/skeleton.tsx +13 -0
  84. package/template/base/src/components/ui/slider.tsx +52 -0
  85. package/template/base/src/components/ui/sonner.tsx +50 -0
  86. package/template/base/src/components/ui/spinner.tsx +18 -0
  87. package/template/base/src/components/ui/switch.tsx +30 -0
  88. package/template/base/src/components/ui/table.tsx +89 -0
  89. package/template/base/src/components/ui/tabs.tsx +73 -0
  90. package/template/base/src/components/ui/textarea.tsx +18 -0
  91. package/template/base/src/components/ui/toggle-group.tsx +85 -0
  92. package/template/base/src/components/ui/toggle.tsx +45 -0
  93. package/template/base/src/components/ui/toolbar.tsx +451 -0
  94. package/template/base/src/components/ui/tooltip.tsx +52 -0
  95. package/template/base/src/hooks/use-mobile.ts +19 -0
  96. package/template/base/src/lib/utils.ts +6 -0
  97. package/template/base/src/routes/__root.tsx +1 -1
  98. package/template/base/src/server/auth.ts +2 -2
  99. package/template/base/src/styles/globals.css +230 -0
  100. package/template/base/vite.config.ts +15 -1
@@ -0,0 +1,337 @@
1
+ import * as React from 'react';
2
+ import * as RechartsPrimitive from 'recharts';
3
+ import type { TooltipValueType } from 'recharts';
4
+
5
+ import { cn } from '@saena-io/ui/lib/utils';
6
+
7
+ // Format: { THEME_NAME: CSS_SELECTOR }
8
+ const THEMES = { light: '', dark: '.dark' } as const;
9
+
10
+ const INITIAL_DIMENSION = { width: 320, height: 200 } as const;
11
+ type TooltipNameType = number | string;
12
+
13
+ export type ChartConfig = Record<
14
+ string,
15
+ {
16
+ label?: React.ReactNode;
17
+ icon?: React.ComponentType;
18
+ } & (
19
+ | { color?: string; theme?: never }
20
+ | { color?: never; theme: Record<keyof typeof THEMES, string> }
21
+ )
22
+ >;
23
+
24
+ type ChartContextProps = {
25
+ config: ChartConfig;
26
+ };
27
+
28
+ const ChartContext = React.createContext<ChartContextProps | null>(null);
29
+
30
+ function useChart() {
31
+ const context = React.useContext(ChartContext);
32
+
33
+ if (!context) {
34
+ throw new Error('useChart must be used within a <ChartContainer />');
35
+ }
36
+
37
+ return context;
38
+ }
39
+
40
+ function ChartContainer({
41
+ id,
42
+ className,
43
+ children,
44
+ config,
45
+ initialDimension = INITIAL_DIMENSION,
46
+ ...props
47
+ }: React.ComponentProps<'div'> & {
48
+ config: ChartConfig;
49
+ children: React.ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>['children'];
50
+ initialDimension?: {
51
+ width: number;
52
+ height: number;
53
+ };
54
+ }) {
55
+ const uniqueId = React.useId();
56
+ const chartId = `chart-${id ?? uniqueId.replace(/:/g, '')}`;
57
+
58
+ return (
59
+ <ChartContext.Provider value={{ config }}>
60
+ <div
61
+ data-slot="chart"
62
+ data-chart={chartId}
63
+ className={cn(
64
+ "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",
65
+ className,
66
+ )}
67
+ {...props}
68
+ >
69
+ <ChartStyle id={chartId} config={config} />
70
+ <RechartsPrimitive.ResponsiveContainer initialDimension={initialDimension}>
71
+ {children}
72
+ </RechartsPrimitive.ResponsiveContainer>
73
+ </div>
74
+ </ChartContext.Provider>
75
+ );
76
+ }
77
+
78
+ const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
79
+ const colorConfig = Object.entries(config).filter(([, config]) => config.theme ?? config.color);
80
+
81
+ if (!colorConfig.length) {
82
+ return null;
83
+ }
84
+
85
+ return (
86
+ <style
87
+ dangerouslySetInnerHTML={{
88
+ __html: Object.entries(THEMES)
89
+ .map(
90
+ ([theme, prefix]) => `
91
+ ${prefix} [data-chart=${id}] {
92
+ ${colorConfig
93
+ .map(([key, itemConfig]) => {
94
+ const color = itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ?? itemConfig.color;
95
+ return color ? ` --color-${key}: ${color};` : null;
96
+ })
97
+ .join('\n')}
98
+ }
99
+ `,
100
+ )
101
+ .join('\n'),
102
+ }}
103
+ />
104
+ );
105
+ };
106
+
107
+ const ChartTooltip = RechartsPrimitive.Tooltip;
108
+
109
+ function ChartTooltipContent({
110
+ active,
111
+ payload,
112
+ className,
113
+ indicator = 'dot',
114
+ hideLabel = false,
115
+ hideIndicator = false,
116
+ label,
117
+ labelFormatter,
118
+ labelClassName,
119
+ formatter,
120
+ color,
121
+ nameKey,
122
+ labelKey,
123
+ }: React.ComponentProps<typeof RechartsPrimitive.Tooltip> &
124
+ React.ComponentProps<'div'> & {
125
+ hideLabel?: boolean;
126
+ hideIndicator?: boolean;
127
+ indicator?: 'line' | 'dot' | 'dashed';
128
+ nameKey?: string;
129
+ labelKey?: string;
130
+ } & Omit<
131
+ RechartsPrimitive.DefaultTooltipContentProps<TooltipValueType, TooltipNameType>,
132
+ 'accessibilityLayer'
133
+ >) {
134
+ const { config } = useChart();
135
+
136
+ const tooltipLabel = React.useMemo(() => {
137
+ if (hideLabel || !payload?.length) {
138
+ return null;
139
+ }
140
+
141
+ const [item] = payload;
142
+ const key = `${labelKey ?? item?.dataKey ?? item?.name ?? 'value'}`;
143
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
144
+ const value =
145
+ !labelKey && typeof label === 'string' ? (config[label]?.label ?? label) : itemConfig?.label;
146
+
147
+ if (labelFormatter) {
148
+ return (
149
+ <div className={cn('font-medium', labelClassName)}>{labelFormatter(value, payload)}</div>
150
+ );
151
+ }
152
+
153
+ if (!value) {
154
+ return null;
155
+ }
156
+
157
+ return <div className={cn('font-medium', labelClassName)}>{value}</div>;
158
+ }, [label, labelFormatter, payload, hideLabel, labelClassName, config, labelKey]);
159
+
160
+ if (!active || !payload?.length) {
161
+ return null;
162
+ }
163
+
164
+ const nestLabel = payload.length === 1 && indicator !== 'dot';
165
+
166
+ return (
167
+ <div
168
+ className={cn(
169
+ '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/relaxed shadow-xl',
170
+ className,
171
+ )}
172
+ >
173
+ {!nestLabel ? tooltipLabel : null}
174
+ <div className="grid gap-1.5">
175
+ {payload
176
+ .filter((item) => item.type !== 'none')
177
+ .map((item, index) => {
178
+ const key = `${nameKey ?? item.name ?? item.dataKey ?? 'value'}`;
179
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
180
+ const indicatorColor = color ?? item.payload?.fill ?? item.color;
181
+
182
+ return (
183
+ <div
184
+ key={index}
185
+ className={cn(
186
+ 'flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground',
187
+ indicator === 'dot' && 'items-center',
188
+ )}
189
+ >
190
+ {formatter && item?.value !== undefined && item.name ? (
191
+ formatter(item.value, item.name, item, index, item.payload)
192
+ ) : (
193
+ <>
194
+ {itemConfig?.icon ? (
195
+ <itemConfig.icon />
196
+ ) : (
197
+ !hideIndicator && (
198
+ <div
199
+ className={cn(
200
+ 'shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)',
201
+ {
202
+ 'h-2.5 w-2.5': indicator === 'dot',
203
+ 'w-1': indicator === 'line',
204
+ 'w-0 border-[1.5px] border-dashed bg-transparent':
205
+ indicator === 'dashed',
206
+ 'my-0.5': nestLabel && indicator === 'dashed',
207
+ },
208
+ )}
209
+ style={
210
+ {
211
+ '--color-bg': indicatorColor,
212
+ '--color-border': indicatorColor,
213
+ } as React.CSSProperties
214
+ }
215
+ />
216
+ )
217
+ )}
218
+ <div
219
+ className={cn(
220
+ 'flex flex-1 justify-between leading-none',
221
+ nestLabel ? 'items-end' : 'items-center',
222
+ )}
223
+ >
224
+ <div className="grid gap-1.5">
225
+ {nestLabel ? tooltipLabel : null}
226
+ <span className="text-muted-foreground">
227
+ {itemConfig?.label ?? item.name}
228
+ </span>
229
+ </div>
230
+ {item.value != null && (
231
+ <span className="font-mono font-medium text-foreground tabular-nums">
232
+ {typeof item.value === 'number'
233
+ ? item.value.toLocaleString()
234
+ : String(item.value)}
235
+ </span>
236
+ )}
237
+ </div>
238
+ </>
239
+ )}
240
+ </div>
241
+ );
242
+ })}
243
+ </div>
244
+ </div>
245
+ );
246
+ }
247
+
248
+ const ChartLegend = RechartsPrimitive.Legend;
249
+
250
+ function ChartLegendContent({
251
+ className,
252
+ hideIcon = false,
253
+ payload,
254
+ verticalAlign = 'bottom',
255
+ nameKey,
256
+ }: React.ComponentProps<'div'> & {
257
+ hideIcon?: boolean;
258
+ nameKey?: string;
259
+ } & RechartsPrimitive.DefaultLegendContentProps) {
260
+ const { config } = useChart();
261
+
262
+ if (!payload?.length) {
263
+ return null;
264
+ }
265
+
266
+ return (
267
+ <div
268
+ className={cn(
269
+ 'flex items-center justify-center gap-4',
270
+ verticalAlign === 'top' ? 'pb-3' : 'pt-3',
271
+ className,
272
+ )}
273
+ >
274
+ {payload
275
+ .filter((item) => item.type !== 'none')
276
+ .map((item, index) => {
277
+ const key = `${nameKey ?? item.dataKey ?? 'value'}`;
278
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
279
+
280
+ return (
281
+ <div
282
+ key={index}
283
+ className={cn(
284
+ 'flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground',
285
+ )}
286
+ >
287
+ {itemConfig?.icon && !hideIcon ? (
288
+ <itemConfig.icon />
289
+ ) : (
290
+ <div
291
+ className="h-2 w-2 shrink-0 rounded-[2px]"
292
+ style={{
293
+ backgroundColor: item.color,
294
+ }}
295
+ />
296
+ )}
297
+ {itemConfig?.label}
298
+ </div>
299
+ );
300
+ })}
301
+ </div>
302
+ );
303
+ }
304
+
305
+ function getPayloadConfigFromPayload(config: ChartConfig, payload: unknown, key: string) {
306
+ if (typeof payload !== 'object' || payload === null) {
307
+ return undefined;
308
+ }
309
+
310
+ const payloadPayload =
311
+ 'payload' in payload && typeof payload.payload === 'object' && payload.payload !== null
312
+ ? payload.payload
313
+ : undefined;
314
+
315
+ let configLabelKey: string = key;
316
+
317
+ if (key in payload && typeof payload[key as keyof typeof payload] === 'string') {
318
+ configLabelKey = payload[key as keyof typeof payload] as string;
319
+ } else if (
320
+ payloadPayload &&
321
+ key in payloadPayload &&
322
+ typeof payloadPayload[key as keyof typeof payloadPayload] === 'string'
323
+ ) {
324
+ configLabelKey = payloadPayload[key as keyof typeof payloadPayload] as string;
325
+ }
326
+
327
+ return configLabelKey in config ? config[configLabelKey] : config[key];
328
+ }
329
+
330
+ export {
331
+ ChartContainer,
332
+ ChartTooltip,
333
+ ChartTooltipContent,
334
+ ChartLegend,
335
+ ChartLegendContent,
336
+ ChartStyle,
337
+ };
@@ -0,0 +1,29 @@
1
+ 'use client';
2
+
3
+ import { Checkbox as CheckboxPrimitive } from '@base-ui/react/checkbox';
4
+
5
+ import { Tick02Icon } from '@hugeicons/core-free-icons';
6
+ import { HugeiconsIcon } from '@hugeicons/react';
7
+ import { cn } from '@saena-io/ui/lib/utils';
8
+
9
+ function Checkbox({ className, ...props }: CheckboxPrimitive.Root.Props) {
10
+ return (
11
+ <CheckboxPrimitive.Root
12
+ data-slot="checkbox"
13
+ className={cn(
14
+ 'peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input 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-2 focus-visible:ring-ring/30 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 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',
15
+ className,
16
+ )}
17
+ {...props}
18
+ >
19
+ <CheckboxPrimitive.Indicator
20
+ data-slot="checkbox-indicator"
21
+ className="grid place-content-center text-current transition-none [&>svg]:size-3.5"
22
+ >
23
+ <HugeiconsIcon icon={Tick02Icon} strokeWidth={2} />
24
+ </CheckboxPrimitive.Indicator>
25
+ </CheckboxPrimitive.Root>
26
+ );
27
+ }
28
+
29
+ export { Checkbox };
@@ -0,0 +1,15 @@
1
+ import { Collapsible as CollapsiblePrimitive } from '@base-ui/react/collapsible';
2
+
3
+ function Collapsible({ ...props }: CollapsiblePrimitive.Root.Props) {
4
+ return <CollapsiblePrimitive.Root data-slot="collapsible" {...props} />;
5
+ }
6
+
7
+ function CollapsibleTrigger({ ...props }: CollapsiblePrimitive.Trigger.Props) {
8
+ return <CollapsiblePrimitive.Trigger data-slot="collapsible-trigger" {...props} />;
9
+ }
10
+
11
+ function CollapsibleContent({ ...props }: CollapsiblePrimitive.Panel.Props) {
12
+ return <CollapsiblePrimitive.Panel data-slot="collapsible-content" {...props} />;
13
+ }
14
+
15
+ export { Collapsible, CollapsibleTrigger, CollapsibleContent };
@@ -0,0 +1,276 @@
1
+ import { Combobox as ComboboxPrimitive } from '@base-ui/react';
2
+ import * as React from 'react';
3
+
4
+ import { ArrowDown01Icon, Cancel01Icon, Tick02Icon } from '@hugeicons/core-free-icons';
5
+ import { HugeiconsIcon } from '@hugeicons/react';
6
+ import { Button } from '@saena-io/ui/components/button';
7
+ import {
8
+ InputGroup,
9
+ InputGroupAddon,
10
+ InputGroupButton,
11
+ InputGroupInput,
12
+ } from '@saena-io/ui/components/input-group';
13
+ import { cn } from '@saena-io/ui/lib/utils';
14
+
15
+ const Combobox = ComboboxPrimitive.Root;
16
+
17
+ function ComboboxValue({ ...props }: ComboboxPrimitive.Value.Props) {
18
+ return <ComboboxPrimitive.Value data-slot="combobox-value" {...props} />;
19
+ }
20
+
21
+ function ComboboxTrigger({ className, children, ...props }: ComboboxPrimitive.Trigger.Props) {
22
+ return (
23
+ <ComboboxPrimitive.Trigger
24
+ data-slot="combobox-trigger"
25
+ className={cn("[&_svg:not([class*='size-'])]:size-3.5", className)}
26
+ {...props}
27
+ >
28
+ {children}
29
+ <HugeiconsIcon
30
+ icon={ArrowDown01Icon}
31
+ strokeWidth={2}
32
+ className="pointer-events-none size-3.5 text-muted-foreground"
33
+ />
34
+ </ComboboxPrimitive.Trigger>
35
+ );
36
+ }
37
+
38
+ function ComboboxClear({ className, ...props }: ComboboxPrimitive.Clear.Props) {
39
+ return (
40
+ <ComboboxPrimitive.Clear
41
+ data-slot="combobox-clear"
42
+ render={<InputGroupButton variant="ghost" size="icon-xs" />}
43
+ className={cn(className)}
44
+ {...props}
45
+ >
46
+ <HugeiconsIcon icon={Cancel01Icon} strokeWidth={2} className="pointer-events-none" />
47
+ </ComboboxPrimitive.Clear>
48
+ );
49
+ }
50
+
51
+ function ComboboxInput({
52
+ className,
53
+ children,
54
+ disabled = false,
55
+ showTrigger = true,
56
+ showClear = false,
57
+ ...props
58
+ }: ComboboxPrimitive.Input.Props & {
59
+ showTrigger?: boolean;
60
+ showClear?: boolean;
61
+ }) {
62
+ return (
63
+ <InputGroup className={cn('w-auto', className)}>
64
+ <ComboboxPrimitive.Input render={<InputGroupInput disabled={disabled} />} {...props} />
65
+ <InputGroupAddon align="inline-end">
66
+ {showTrigger && (
67
+ <InputGroupButton
68
+ size="icon-xs"
69
+ variant="ghost"
70
+ render={<ComboboxTrigger />}
71
+ data-slot="input-group-button"
72
+ className="group-has-data-[slot=combobox-clear]/input-group:hidden data-pressed:bg-transparent"
73
+ disabled={disabled}
74
+ />
75
+ )}
76
+ {showClear && <ComboboxClear disabled={disabled} />}
77
+ </InputGroupAddon>
78
+ {children}
79
+ </InputGroup>
80
+ );
81
+ }
82
+
83
+ function ComboboxContent({
84
+ className,
85
+ side = 'bottom',
86
+ sideOffset = 6,
87
+ align = 'start',
88
+ alignOffset = 0,
89
+ anchor,
90
+ ...props
91
+ }: ComboboxPrimitive.Popup.Props &
92
+ Pick<
93
+ ComboboxPrimitive.Positioner.Props,
94
+ 'side' | 'align' | 'sideOffset' | 'alignOffset' | 'anchor'
95
+ >) {
96
+ return (
97
+ <ComboboxPrimitive.Portal>
98
+ <ComboboxPrimitive.Positioner
99
+ side={side}
100
+ sideOffset={sideOffset}
101
+ align={align}
102
+ alignOffset={alignOffset}
103
+ anchor={anchor}
104
+ className="isolate z-50"
105
+ >
106
+ <ComboboxPrimitive.Popup
107
+ data-slot="combobox-content"
108
+ data-chips={!!anchor}
109
+ className={cn(
110
+ 'group/combobox-content relative max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-[calc(var(--anchor-width)+--spacing(7))] origin-(--transform-origin) overflow-hidden rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[chips=true]:min-w-(--anchor-width) data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 *:data-[slot=input-group]:m-1 *:data-[slot=input-group]:mb-0 *:data-[slot=input-group]:h-7 *:data-[slot=input-group]:border-none *:data-[slot=input-group]:bg-input/20 *:data-[slot=input-group]:shadow-none dark:bg-popover data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
111
+ className,
112
+ )}
113
+ {...props}
114
+ />
115
+ </ComboboxPrimitive.Positioner>
116
+ </ComboboxPrimitive.Portal>
117
+ );
118
+ }
119
+
120
+ function ComboboxList({ className, ...props }: ComboboxPrimitive.List.Props) {
121
+ return (
122
+ <ComboboxPrimitive.List
123
+ data-slot="combobox-list"
124
+ className={cn(
125
+ 'no-scrollbar max-h-[min(calc(--spacing(72)---spacing(9)),calc(var(--available-height)---spacing(9)))] scroll-py-1 overflow-y-auto overscroll-contain p-1 data-empty:p-0',
126
+ className,
127
+ )}
128
+ {...props}
129
+ />
130
+ );
131
+ }
132
+
133
+ function ComboboxItem({ className, children, ...props }: ComboboxPrimitive.Item.Props) {
134
+ return (
135
+ <ComboboxPrimitive.Item
136
+ data-slot="combobox-item"
137
+ className={cn(
138
+ "relative flex min-h-7 w-full cursor-default items-center gap-2 rounded-md px-2 py-1 text-xs/relaxed outline-hidden select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground not-data-[variant=destructive]:data-highlighted:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5",
139
+ className,
140
+ )}
141
+ {...props}
142
+ >
143
+ {children}
144
+ <ComboboxPrimitive.ItemIndicator
145
+ render={
146
+ <span className="pointer-events-none absolute right-2 flex items-center justify-center" />
147
+ }
148
+ >
149
+ <HugeiconsIcon icon={Tick02Icon} strokeWidth={2} className="pointer-events-none" />
150
+ </ComboboxPrimitive.ItemIndicator>
151
+ </ComboboxPrimitive.Item>
152
+ );
153
+ }
154
+
155
+ function ComboboxGroup({ className, ...props }: ComboboxPrimitive.Group.Props) {
156
+ return (
157
+ <ComboboxPrimitive.Group data-slot="combobox-group" className={cn(className)} {...props} />
158
+ );
159
+ }
160
+
161
+ function ComboboxLabel({ className, ...props }: ComboboxPrimitive.GroupLabel.Props) {
162
+ return (
163
+ <ComboboxPrimitive.GroupLabel
164
+ data-slot="combobox-label"
165
+ className={cn('px-2 py-1.5 text-xs text-muted-foreground', className)}
166
+ {...props}
167
+ />
168
+ );
169
+ }
170
+
171
+ function ComboboxCollection({ ...props }: ComboboxPrimitive.Collection.Props) {
172
+ return <ComboboxPrimitive.Collection data-slot="combobox-collection" {...props} />;
173
+ }
174
+
175
+ function ComboboxEmpty({ className, ...props }: ComboboxPrimitive.Empty.Props) {
176
+ return (
177
+ <ComboboxPrimitive.Empty
178
+ data-slot="combobox-empty"
179
+ className={cn(
180
+ 'hidden w-full justify-center py-2 text-center text-xs/relaxed text-muted-foreground group-data-empty/combobox-content:flex',
181
+ className,
182
+ )}
183
+ {...props}
184
+ />
185
+ );
186
+ }
187
+
188
+ function ComboboxSeparator({ className, ...props }: ComboboxPrimitive.Separator.Props) {
189
+ return (
190
+ <ComboboxPrimitive.Separator
191
+ data-slot="combobox-separator"
192
+ className={cn('-mx-1 my-1 h-px bg-border/50', className)}
193
+ {...props}
194
+ />
195
+ );
196
+ }
197
+
198
+ function ComboboxChips({
199
+ className,
200
+ ...props
201
+ }: React.ComponentPropsWithRef<typeof ComboboxPrimitive.Chips> & ComboboxPrimitive.Chips.Props) {
202
+ return (
203
+ <ComboboxPrimitive.Chips
204
+ data-slot="combobox-chips"
205
+ className={cn(
206
+ 'flex min-h-7 flex-wrap items-center gap-1 rounded-md border border-input bg-input/20 bg-clip-padding px-2 py-0.5 text-xs/relaxed transition-colors focus-within:border-ring focus-within:ring-2 focus-within:ring-ring/30 has-aria-invalid:border-destructive has-aria-invalid:ring-2 has-aria-invalid:ring-destructive/20 has-data-[slot=combobox-chip]:px-1 dark:bg-input/30 dark:has-aria-invalid:border-destructive/50 dark:has-aria-invalid:ring-destructive/40',
207
+ className,
208
+ )}
209
+ {...props}
210
+ />
211
+ );
212
+ }
213
+
214
+ function ComboboxChip({
215
+ className,
216
+ children,
217
+ showRemove = true,
218
+ ...props
219
+ }: ComboboxPrimitive.Chip.Props & {
220
+ showRemove?: boolean;
221
+ }) {
222
+ return (
223
+ <ComboboxPrimitive.Chip
224
+ data-slot="combobox-chip"
225
+ className={cn(
226
+ 'flex h-[calc(--spacing(4.75))] w-fit items-center justify-center gap-1 rounded-[calc(var(--radius-sm)-2px)] bg-muted-foreground/10 px-1.5 text-xs/relaxed font-medium whitespace-nowrap text-foreground has-disabled:pointer-events-none has-disabled:cursor-not-allowed has-disabled:opacity-50 has-data-[slot=combobox-chip-remove]:pr-0',
227
+ className,
228
+ )}
229
+ {...props}
230
+ >
231
+ {children}
232
+ {showRemove && (
233
+ <ComboboxPrimitive.ChipRemove
234
+ render={<Button variant="ghost" size="icon-xs" />}
235
+ className="-ml-1 opacity-50 hover:opacity-100"
236
+ data-slot="combobox-chip-remove"
237
+ >
238
+ <HugeiconsIcon icon={Cancel01Icon} strokeWidth={2} className="pointer-events-none" />
239
+ </ComboboxPrimitive.ChipRemove>
240
+ )}
241
+ </ComboboxPrimitive.Chip>
242
+ );
243
+ }
244
+
245
+ function ComboboxChipsInput({ className, ...props }: ComboboxPrimitive.Input.Props) {
246
+ return (
247
+ <ComboboxPrimitive.Input
248
+ data-slot="combobox-chip-input"
249
+ className={cn('min-w-16 flex-1 outline-none', className)}
250
+ {...props}
251
+ />
252
+ );
253
+ }
254
+
255
+ function useComboboxAnchor() {
256
+ return React.useRef<HTMLDivElement | null>(null);
257
+ }
258
+
259
+ export {
260
+ Combobox,
261
+ ComboboxInput,
262
+ ComboboxContent,
263
+ ComboboxList,
264
+ ComboboxItem,
265
+ ComboboxGroup,
266
+ ComboboxLabel,
267
+ ComboboxCollection,
268
+ ComboboxEmpty,
269
+ ComboboxSeparator,
270
+ ComboboxChips,
271
+ ComboboxChip,
272
+ ComboboxChipsInput,
273
+ ComboboxTrigger,
274
+ ComboboxValue,
275
+ useComboboxAnchor,
276
+ };