@leitware/composables 0.1.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.
- package/LICENSE +21 -0
- package/README.md +387 -0
- package/dist/presets/brutalist.css +298 -0
- package/dist/presets/default.css +298 -0
- package/dist/presets/signal-pop.css +369 -0
- package/dist/styles.css +2 -0
- package/package.json +216 -0
- package/rules/composables.md +244 -0
- package/src/_internal/accordion.tsx +93 -0
- package/src/_internal/ai-elements/attachments.tsx +385 -0
- package/src/_internal/ai-elements/chain-of-thought.tsx +197 -0
- package/src/_internal/ai-elements/code-block.tsx +516 -0
- package/src/_internal/ai-elements/confirmation.tsx +150 -0
- package/src/_internal/ai-elements/conversation.tsx +148 -0
- package/src/_internal/ai-elements/inline-citation.tsx +248 -0
- package/src/_internal/ai-elements/message.tsx +292 -0
- package/src/_internal/ai-elements/plan.tsx +126 -0
- package/src/_internal/ai-elements/prompt-input.tsx +1285 -0
- package/src/_internal/ai-elements/reasoning.tsx +208 -0
- package/src/_internal/ai-elements/shimmer.tsx +72 -0
- package/src/_internal/ai-elements/sources.tsx +53 -0
- package/src/_internal/ai-elements/suggestion.tsx +48 -0
- package/src/_internal/ai-elements/task.tsx +64 -0
- package/src/_internal/ai-elements/tool.tsx +156 -0
- package/src/_internal/alert-dialog.tsx +159 -0
- package/src/_internal/alert.tsx +88 -0
- package/src/_internal/aspect-ratio.tsx +23 -0
- package/src/_internal/avatar.tsx +58 -0
- package/src/_internal/badge.tsx +60 -0
- package/src/_internal/breadcrumb.tsx +104 -0
- package/src/_internal/bubble.tsx +125 -0
- package/src/_internal/button-group.tsx +78 -0
- package/src/_internal/button.tsx +62 -0
- package/src/_internal/calendar.tsx +179 -0
- package/src/_internal/card.tsx +83 -0
- package/src/_internal/carousel.tsx +215 -0
- package/src/_internal/checkbox.tsx +26 -0
- package/src/_internal/code-block.tsx +53 -0
- package/src/_internal/collapsible.tsx +15 -0
- package/src/_internal/combobox.tsx +264 -0
- package/src/_internal/command.tsx +155 -0
- package/src/_internal/container.tsx +35 -0
- package/src/_internal/dialog.tsx +132 -0
- package/src/_internal/direction.tsx +12 -0
- package/src/_internal/divider.tsx +162 -0
- package/src/_internal/dropdown-menu.tsx +247 -0
- package/src/_internal/dropzone.tsx +481 -0
- package/src/_internal/empty.tsx +94 -0
- package/src/_internal/field.tsx +221 -0
- package/src/_internal/grid-overlay.tsx +48 -0
- package/src/_internal/grid.tsx +109 -0
- package/src/_internal/hover-card.tsx +47 -0
- package/src/_internal/icon.tsx +45 -0
- package/src/_internal/input-group.tsx +146 -0
- package/src/_internal/input.tsx +24 -0
- package/src/_internal/item.tsx +187 -0
- package/src/_internal/kbd.tsx +28 -0
- package/src/_internal/label.tsx +18 -0
- package/src/_internal/layout-bento.tsx +386 -0
- package/src/_internal/layout.tsx +174 -0
- package/src/_internal/marker.tsx +66 -0
- package/src/_internal/message.tsx +85 -0
- package/src/_internal/native-select.tsx +50 -0
- package/src/_internal/pagination.tsx +108 -0
- package/src/_internal/popover.tsx +83 -0
- package/src/_internal/progress.tsx +59 -0
- package/src/_internal/radio-group.tsx +36 -0
- package/src/_internal/resizable.tsx +44 -0
- package/src/_internal/scroll-area.tsx +48 -0
- package/src/_internal/select.tsx +187 -0
- package/src/_internal/separator.tsx +19 -0
- package/src/_internal/sheet.tsx +122 -0
- package/src/_internal/sidebar.tsx +687 -0
- package/src/_internal/skeleton.tsx +13 -0
- package/src/_internal/slider.tsx +60 -0
- package/src/_internal/sonner.tsx +51 -0
- package/src/_internal/spacer.tsx +42 -0
- package/src/_internal/spinner.tsx +16 -0
- package/src/_internal/stack.tsx +78 -0
- package/src/_internal/switch.tsx +31 -0
- package/src/_internal/table.tsx +84 -0
- package/src/_internal/tabs.tsx +74 -0
- package/src/_internal/textarea.tsx +19 -0
- package/src/_internal/toggle-group.tsx +99 -0
- package/src/_internal/toggle.tsx +42 -0
- package/src/_internal/tooltip.tsx +55 -0
- package/src/_internal/typography.tsx +129 -0
- package/src/hooks/use-mobile.ts +19 -0
- package/src/hooks/use-numeric-input.ts +119 -0
- package/src/index.ts +443 -0
- package/src/lib/numeric-input.ts +88 -0
- package/src/lib/utils.ts +39 -0
- package/src/opinionated/accordion.tsx +92 -0
- package/src/opinionated/ai/attachments.tsx +27 -0
- package/src/opinionated/ai/chain-of-thought.tsx +16 -0
- package/src/opinionated/ai/code-block.tsx +22 -0
- package/src/opinionated/ai/confirmation.tsx +16 -0
- package/src/opinionated/ai/conversation.tsx +13 -0
- package/src/opinionated/ai/index.ts +15 -0
- package/src/opinionated/ai/inline-citation.tsx +30 -0
- package/src/opinionated/ai/message.tsx +26 -0
- package/src/opinionated/ai/plan.tsx +18 -0
- package/src/opinionated/ai/prompt-input.tsx +29 -0
- package/src/opinionated/ai/reasoning.tsx +9 -0
- package/src/opinionated/ai/shimmer.tsx +4 -0
- package/src/opinionated/ai/sources.tsx +10 -0
- package/src/opinionated/ai/suggestion.tsx +6 -0
- package/src/opinionated/ai/task.tsx +12 -0
- package/src/opinionated/ai/tool.tsx +14 -0
- package/src/opinionated/alert-dialog.tsx +143 -0
- package/src/opinionated/alert.tsx +99 -0
- package/src/opinionated/aspect-ratio.tsx +12 -0
- package/src/opinionated/avatar.tsx +59 -0
- package/src/opinionated/badge.tsx +33 -0
- package/src/opinionated/breadcrumb.tsx +99 -0
- package/src/opinionated/bubble.tsx +9 -0
- package/src/opinionated/button.tsx +59 -0
- package/src/opinionated/calendar.tsx +20 -0
- package/src/opinionated/card.tsx +83 -0
- package/src/opinionated/carousel.tsx +99 -0
- package/src/opinionated/checkbox.tsx +11 -0
- package/src/opinionated/code-block.tsx +12 -0
- package/src/opinionated/collapsible.tsx +123 -0
- package/src/opinionated/combobox.tsx +123 -0
- package/src/opinionated/container.tsx +12 -0
- package/src/opinionated/dialog.tsx +124 -0
- package/src/opinionated/direction.tsx +6 -0
- package/src/opinionated/divider.tsx +13 -0
- package/src/opinionated/dropdown-menu.tsx +131 -0
- package/src/opinionated/dropzone.tsx +39 -0
- package/src/opinionated/empty.tsx +191 -0
- package/src/opinionated/field.tsx +26 -0
- package/src/opinionated/form-calendar-popover.tsx +138 -0
- package/src/opinionated/form-checkbox.tsx +107 -0
- package/src/opinionated/form-combobox.tsx +181 -0
- package/src/opinionated/form-date-of-birth.tsx +193 -0
- package/src/opinionated/form-dropzone.tsx +126 -0
- package/src/opinionated/form-input-group.tsx +184 -0
- package/src/opinionated/form-input.tsx +118 -0
- package/src/opinionated/form-multi-combobox.tsx +213 -0
- package/src/opinionated/form-multi-dropzone.tsx +141 -0
- package/src/opinionated/form-radiogroup.tsx +116 -0
- package/src/opinionated/form-select.tsx +176 -0
- package/src/opinionated/form-slider.tsx +100 -0
- package/src/opinionated/form-switch.tsx +117 -0
- package/src/opinionated/form-textarea.tsx +79 -0
- package/src/opinionated/grid-overlay.tsx +11 -0
- package/src/opinionated/grid.tsx +14 -0
- package/src/opinionated/hover-card.tsx +59 -0
- package/src/opinionated/icon.tsx +14 -0
- package/src/opinionated/input-group.tsx +20 -0
- package/src/opinionated/input.tsx +11 -0
- package/src/opinionated/item.tsx +182 -0
- package/src/opinionated/kbd.tsx +16 -0
- package/src/opinionated/label.tsx +11 -0
- package/src/opinionated/layout-bento.tsx +29 -0
- package/src/opinionated/layout.tsx +26 -0
- package/src/opinionated/list.tsx +94 -0
- package/src/opinionated/marker.tsx +7 -0
- package/src/opinionated/message.tsx +8 -0
- package/src/opinionated/native-select.tsx +51 -0
- package/src/opinionated/pagination.tsx +204 -0
- package/src/opinionated/popover.tsx +68 -0
- package/src/opinionated/progress.tsx +48 -0
- package/src/opinionated/radio-group.tsx +13 -0
- package/src/opinionated/resizable.tsx +2 -0
- package/src/opinionated/scroll-area.tsx +82 -0
- package/src/opinionated/select.tsx +101 -0
- package/src/opinionated/separator.tsx +11 -0
- package/src/opinionated/sheet.tsx +120 -0
- package/src/opinionated/sidebar.tsx +68 -0
- package/src/opinionated/skeleton.tsx +246 -0
- package/src/opinionated/slider.tsx +11 -0
- package/src/opinionated/sonner.tsx +15 -0
- package/src/opinionated/spacer.tsx +11 -0
- package/src/opinionated/stack.tsx +18 -0
- package/src/opinionated/switch.tsx +11 -0
- package/src/opinionated/table.tsx +11 -0
- package/src/opinionated/tabs.tsx +68 -0
- package/src/opinionated/textarea.tsx +11 -0
- package/src/opinionated/theme-injector.tsx +31 -0
- package/src/opinionated/toggle-group.tsx +63 -0
- package/src/opinionated/toggle.tsx +75 -0
- package/src/opinionated/token-config-panel/color-editor.tsx +85 -0
- package/src/opinionated/token-config-panel/helpers.ts +31 -0
- package/src/opinionated/token-config-panel/index.tsx +398 -0
- package/src/opinionated/token-config-panel/json-import-export.tsx +89 -0
- package/src/opinionated/token-config-panel/preset-manager.ts +31 -0
- package/src/opinionated/token-config-panel/presets-data.ts +23 -0
- package/src/opinionated/token-config-panel/spacing-editor.tsx +325 -0
- package/src/opinionated/token-config-panel/types.ts +39 -0
- package/src/opinionated/token-config-panel/typography-editor.tsx +145 -0
- package/src/opinionated/tooltip.tsx +62 -0
- package/src/opinionated/typography.tsx +7 -0
- package/src/scripts/lint-no-arbitrary.ts +155 -0
- package/src/styles/composable.css +68 -0
- package/src/styles/presets/brutalist.css +298 -0
- package/src/styles/presets/default.css +298 -0
- package/src/styles/presets/signal-pop.css +369 -0
- package/src/styles/presets-data/brutalist.ts +325 -0
- package/src/styles/presets-data/default.ts +315 -0
- package/src/styles/presets-data/index.ts +45 -0
- package/src/styles/presets-data/signal-pop.ts +393 -0
- package/src/styles/tokens/base.css +71 -0
- package/src/styles/tokens/components.css +150 -0
- package/src/styles/tokens/palette.css +795 -0
- package/src/styles/tokens/registry.ts +324 -0
- package/src/styles/tokens/semantic.css +266 -0
- package/src/styles/tokens/tailwind-theme.css +247 -0
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { cva, type VariantProps } from 'class-variance-authority'
|
|
2
|
+
import { useMemo } from 'react'
|
|
3
|
+
import { Label } from './label'
|
|
4
|
+
import { Separator } from './separator'
|
|
5
|
+
import { cn } from '../lib/utils'
|
|
6
|
+
|
|
7
|
+
function FieldSet({ className, ...props }: React.ComponentProps<'fieldset'>) {
|
|
8
|
+
return (
|
|
9
|
+
<fieldset
|
|
10
|
+
data-slot="field-set"
|
|
11
|
+
className={cn(
|
|
12
|
+
'gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3 flex flex-col',
|
|
13
|
+
className,
|
|
14
|
+
)}
|
|
15
|
+
{...props}
|
|
16
|
+
/>
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function FieldLegend({
|
|
21
|
+
className,
|
|
22
|
+
variant = 'legend',
|
|
23
|
+
...props
|
|
24
|
+
}: React.ComponentProps<'legend'> & { variant?: 'legend' | 'label' }) {
|
|
25
|
+
return (
|
|
26
|
+
<legend
|
|
27
|
+
data-slot="field-legend"
|
|
28
|
+
data-variant={variant}
|
|
29
|
+
className={cn(
|
|
30
|
+
'mb-2 font-medium data-[variant=label]:text-xs/relaxed data-[variant=legend]:text-sm',
|
|
31
|
+
className,
|
|
32
|
+
)}
|
|
33
|
+
{...props}
|
|
34
|
+
/>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function FieldGroup({ className, ...props }: React.ComponentProps<'div'>) {
|
|
39
|
+
return (
|
|
40
|
+
<div
|
|
41
|
+
data-slot="field-group"
|
|
42
|
+
className={cn(
|
|
43
|
+
'gap-4 data-[slot=checkbox-group]:gap-3 [&>[data-slot=field-group]]:gap-4 group/field-group @container/field-group flex w-full flex-col',
|
|
44
|
+
className,
|
|
45
|
+
)}
|
|
46
|
+
{...props}
|
|
47
|
+
/>
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const fieldVariants = cva('data-[invalid=true]:text-danger gap-2 group/field flex w-full', {
|
|
52
|
+
variants: {
|
|
53
|
+
orientation: {
|
|
54
|
+
vertical: 'flex-col [&>*]:w-full [&>.sr-only]:w-auto',
|
|
55
|
+
horizontal:
|
|
56
|
+
'flex-row items-center [&>[data-slot=field-label]]:flex-auto has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px',
|
|
57
|
+
responsive:
|
|
58
|
+
'flex-col [&>*]:w-full [&>.sr-only]:w-auto @md/field-group:flex-row @md/field-group:items-center @md/field-group:[&>*]:w-auto @md/field-group:[&>[data-slot=field-label]]:flex-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px',
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
defaultVariants: {
|
|
62
|
+
orientation: 'vertical',
|
|
63
|
+
},
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
function Field({
|
|
67
|
+
className,
|
|
68
|
+
orientation = 'vertical',
|
|
69
|
+
...props
|
|
70
|
+
}: React.ComponentProps<'div'> & VariantProps<typeof fieldVariants>) {
|
|
71
|
+
return (
|
|
72
|
+
<div
|
|
73
|
+
role="group"
|
|
74
|
+
data-slot="field"
|
|
75
|
+
data-orientation={orientation}
|
|
76
|
+
className={cn(fieldVariants({ orientation }), className)}
|
|
77
|
+
{...props}
|
|
78
|
+
/>
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function FieldContent({ className, ...props }: React.ComponentProps<'div'>) {
|
|
83
|
+
return (
|
|
84
|
+
<div
|
|
85
|
+
data-slot="field-content"
|
|
86
|
+
className={cn('gap-0.5 group/field-content flex flex-1 flex-col leading-snug', className)}
|
|
87
|
+
{...props}
|
|
88
|
+
/>
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function FieldLabel({ className, ...props }: React.ComponentProps<typeof Label>) {
|
|
93
|
+
return (
|
|
94
|
+
<Label
|
|
95
|
+
data-slot="field-label"
|
|
96
|
+
className={cn(
|
|
97
|
+
'has-data-checked:bg-primary/5 dark:has-data-checked:bg-primary/10 gap-2 group-data-[disabled=true]/field:opacity-disabled has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border [&>*]:data-[slot=field]:p-2 group/field-label peer/field-label flex w-fit leading-snug',
|
|
98
|
+
'has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col',
|
|
99
|
+
className,
|
|
100
|
+
)}
|
|
101
|
+
{...props}
|
|
102
|
+
/>
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function FieldTitle({ className, ...props }: React.ComponentProps<'div'>) {
|
|
107
|
+
return (
|
|
108
|
+
<div
|
|
109
|
+
data-slot="field-label"
|
|
110
|
+
className={cn(
|
|
111
|
+
'gap-2 text-xs/relaxed font-medium group-data-[disabled=true]/field:opacity-disabled flex w-fit items-center leading-snug',
|
|
112
|
+
className,
|
|
113
|
+
)}
|
|
114
|
+
{...props}
|
|
115
|
+
/>
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function FieldDescription({ className, ...props }: React.ComponentProps<'p'>) {
|
|
120
|
+
return (
|
|
121
|
+
<p
|
|
122
|
+
data-slot="field-description"
|
|
123
|
+
className={cn(
|
|
124
|
+
'text-muted-foreground text-left text-xs/relaxed [[data-variant=legend]+&]:-mt-1.5 leading-normal font-normal group-has-[[data-orientation=horizontal]]/field:text-balance',
|
|
125
|
+
'last:mt-0 nth-last-2:-mt-1',
|
|
126
|
+
'[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4',
|
|
127
|
+
className,
|
|
128
|
+
)}
|
|
129
|
+
{...props}
|
|
130
|
+
/>
|
|
131
|
+
)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function FieldSeparator({
|
|
135
|
+
children,
|
|
136
|
+
className,
|
|
137
|
+
...props
|
|
138
|
+
}: React.ComponentProps<'div'> & {
|
|
139
|
+
children?: React.ReactNode
|
|
140
|
+
}) {
|
|
141
|
+
return (
|
|
142
|
+
<div
|
|
143
|
+
data-slot="field-separator"
|
|
144
|
+
data-content={!!children}
|
|
145
|
+
className={cn(
|
|
146
|
+
'-my-2 h-5 text-xs/relaxed group-data-[variant=outline]/field-group:-mb-2 relative',
|
|
147
|
+
className,
|
|
148
|
+
)}
|
|
149
|
+
{...props}
|
|
150
|
+
>
|
|
151
|
+
<Separator className="absolute inset-0 top-1/2" />
|
|
152
|
+
{children && (
|
|
153
|
+
<span
|
|
154
|
+
className="text-muted-foreground px-2 bg-page relative mx-auto block w-fit"
|
|
155
|
+
data-slot="field-separator-content"
|
|
156
|
+
>
|
|
157
|
+
{children}
|
|
158
|
+
</span>
|
|
159
|
+
)}
|
|
160
|
+
</div>
|
|
161
|
+
)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function FieldError({
|
|
165
|
+
className,
|
|
166
|
+
children,
|
|
167
|
+
errors,
|
|
168
|
+
...props
|
|
169
|
+
}: React.ComponentProps<'div'> & {
|
|
170
|
+
errors?: Array<{ message?: string } | undefined>
|
|
171
|
+
}) {
|
|
172
|
+
const content = useMemo(() => {
|
|
173
|
+
if (children) {
|
|
174
|
+
return children
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (!errors?.length) {
|
|
178
|
+
return null
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const uniqueErrors = [...new Map(errors.map((error) => [error?.message, error])).values()]
|
|
182
|
+
|
|
183
|
+
if (uniqueErrors?.length === 1) {
|
|
184
|
+
return uniqueErrors[0]?.message
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return (
|
|
188
|
+
<ul className="ml-4 flex list-disc flex-col gap-1">
|
|
189
|
+
{uniqueErrors.map((error, index) => error?.message && <li key={index}>{error.message}</li>)}
|
|
190
|
+
</ul>
|
|
191
|
+
)
|
|
192
|
+
}, [children, errors])
|
|
193
|
+
|
|
194
|
+
if (!content) {
|
|
195
|
+
return null
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return (
|
|
199
|
+
<div
|
|
200
|
+
role="alert"
|
|
201
|
+
data-slot="field-error"
|
|
202
|
+
className={cn('text-danger text-xs/relaxed font-normal break-all', className)}
|
|
203
|
+
{...props}
|
|
204
|
+
>
|
|
205
|
+
{content}
|
|
206
|
+
</div>
|
|
207
|
+
)
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export {
|
|
211
|
+
Field,
|
|
212
|
+
FieldLabel,
|
|
213
|
+
FieldDescription,
|
|
214
|
+
FieldError,
|
|
215
|
+
FieldGroup,
|
|
216
|
+
FieldLegend,
|
|
217
|
+
FieldSeparator,
|
|
218
|
+
FieldSet,
|
|
219
|
+
FieldContent,
|
|
220
|
+
FieldTitle,
|
|
221
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
|
|
3
|
+
import { cn } from '../lib/utils'
|
|
4
|
+
|
|
5
|
+
interface GridOverlayProps extends React.ComponentProps<'div'> {
|
|
6
|
+
/** Grid line color. Defaults to a subtle black/white depending on context. */
|
|
7
|
+
color?: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* GridOverlay — renders a full-viewport grid background aligned to the
|
|
12
|
+
* spacing system. Grid cells are `calc(var(--spacing) * 12)` wide/tall
|
|
13
|
+
* and the pattern is horizontally centered so that containers whose
|
|
14
|
+
* widths are multiples of 96 px snap exactly to the lines.
|
|
15
|
+
*
|
|
16
|
+
* The overlay is fixed, non-interactive (`pointer-events: none`), and
|
|
17
|
+
* sits at `z-[9999]` so it floats above all content.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* <GridOverlay />
|
|
22
|
+
* <GridOverlay color="rgba(0, 100, 255, 0.1)" />
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
function GridOverlay({ color, className, style, ...props }: GridOverlayProps) {
|
|
26
|
+
const lineColor = color ?? 'var(--grid-overlay-color, rgba(0, 0, 0, 0.06))'
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div
|
|
30
|
+
data-slot="grid-overlay"
|
|
31
|
+
aria-hidden="true"
|
|
32
|
+
className={cn('pointer-events-none fixed inset-0 z-[9999]', className)}
|
|
33
|
+
style={{
|
|
34
|
+
backgroundImage: `
|
|
35
|
+
linear-gradient(to right, ${lineColor} 1px, transparent 1px),
|
|
36
|
+
linear-gradient(to bottom, ${lineColor} 1px, transparent 1px)
|
|
37
|
+
`,
|
|
38
|
+
backgroundSize: 'calc(var(--spacing) * 12) calc(var(--spacing) * 12)',
|
|
39
|
+
backgroundPosition: 'center center',
|
|
40
|
+
...style,
|
|
41
|
+
}}
|
|
42
|
+
{...props}
|
|
43
|
+
/>
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { GridOverlay }
|
|
48
|
+
export type { GridOverlayProps }
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { cva, type VariantProps } from 'class-variance-authority'
|
|
2
|
+
import * as React from 'react'
|
|
3
|
+
|
|
4
|
+
import { cn } from '../lib/utils'
|
|
5
|
+
|
|
6
|
+
const gridVariants = cva('grid min-w-0', {
|
|
7
|
+
variants: {
|
|
8
|
+
columns: {
|
|
9
|
+
1: 'grid-cols-1',
|
|
10
|
+
2: 'grid-cols-2',
|
|
11
|
+
3: 'grid-cols-3',
|
|
12
|
+
4: 'grid-cols-4',
|
|
13
|
+
6: 'grid-cols-6',
|
|
14
|
+
12: 'grid-cols-12',
|
|
15
|
+
},
|
|
16
|
+
gap: {
|
|
17
|
+
0: 'gap-0',
|
|
18
|
+
1: 'gap-1',
|
|
19
|
+
2: 'gap-2',
|
|
20
|
+
3: 'gap-3',
|
|
21
|
+
4: 'gap-4',
|
|
22
|
+
5: 'gap-5',
|
|
23
|
+
6: 'gap-6',
|
|
24
|
+
8: 'gap-8',
|
|
25
|
+
10: 'gap-10',
|
|
26
|
+
12: 'gap-12',
|
|
27
|
+
},
|
|
28
|
+
align: {
|
|
29
|
+
start: 'items-start',
|
|
30
|
+
center: 'items-center',
|
|
31
|
+
end: 'items-end',
|
|
32
|
+
stretch: 'items-stretch',
|
|
33
|
+
baseline: 'items-baseline',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
defaultVariants: {
|
|
37
|
+
columns: 12,
|
|
38
|
+
gap: 6,
|
|
39
|
+
align: 'stretch',
|
|
40
|
+
},
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
type GridProps = React.ComponentProps<'div'> & VariantProps<typeof gridVariants>
|
|
44
|
+
|
|
45
|
+
function Grid({ className, columns, gap, align, ...props }: GridProps) {
|
|
46
|
+
return (
|
|
47
|
+
<div
|
|
48
|
+
data-slot="grid"
|
|
49
|
+
className={cn(gridVariants({ columns, gap, align }), className)}
|
|
50
|
+
{...props}
|
|
51
|
+
/>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* ---- GridItem ---- */
|
|
56
|
+
|
|
57
|
+
const gridItemVariants = cva('min-w-0', {
|
|
58
|
+
variants: {
|
|
59
|
+
colSpan: {
|
|
60
|
+
1: 'col-span-1',
|
|
61
|
+
2: 'col-span-2',
|
|
62
|
+
3: 'col-span-3',
|
|
63
|
+
4: 'col-span-4',
|
|
64
|
+
5: 'col-span-5',
|
|
65
|
+
6: 'col-span-6',
|
|
66
|
+
7: 'col-span-7',
|
|
67
|
+
8: 'col-span-8',
|
|
68
|
+
9: 'col-span-9',
|
|
69
|
+
10: 'col-span-10',
|
|
70
|
+
11: 'col-span-11',
|
|
71
|
+
12: 'col-span-12',
|
|
72
|
+
full: 'col-span-full',
|
|
73
|
+
},
|
|
74
|
+
colStart: {
|
|
75
|
+
1: 'col-start-1',
|
|
76
|
+
2: 'col-start-2',
|
|
77
|
+
3: 'col-start-3',
|
|
78
|
+
4: 'col-start-4',
|
|
79
|
+
5: 'col-start-5',
|
|
80
|
+
6: 'col-start-6',
|
|
81
|
+
7: 'col-start-7',
|
|
82
|
+
8: 'col-start-8',
|
|
83
|
+
9: 'col-start-9',
|
|
84
|
+
10: 'col-start-10',
|
|
85
|
+
11: 'col-start-11',
|
|
86
|
+
12: 'col-start-12',
|
|
87
|
+
auto: 'col-start-auto',
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
defaultVariants: {
|
|
91
|
+
colSpan: 12,
|
|
92
|
+
colStart: 'auto',
|
|
93
|
+
},
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
type GridItemProps = React.ComponentProps<'div'> & VariantProps<typeof gridItemVariants>
|
|
97
|
+
|
|
98
|
+
function GridItem({ className, colSpan, colStart, ...props }: GridItemProps) {
|
|
99
|
+
return (
|
|
100
|
+
<div
|
|
101
|
+
data-slot="grid-item"
|
|
102
|
+
className={cn(gridItemVariants({ colSpan, colStart }), className)}
|
|
103
|
+
{...props}
|
|
104
|
+
/>
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export { Grid, GridItem, gridVariants, gridItemVariants }
|
|
109
|
+
export type { GridProps, GridItemProps }
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { PreviewCard as HoverCardPrimitive } from '@base-ui/react/preview-card'
|
|
2
|
+
|
|
3
|
+
import { cn } from '../lib/utils'
|
|
4
|
+
|
|
5
|
+
function HoverCard({ ...props }: HoverCardPrimitive.Root.Props) {
|
|
6
|
+
return <HoverCardPrimitive.Root data-slot="hover-card" {...props} />
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function HoverCardTrigger({ ...props }: HoverCardPrimitive.Trigger.Props) {
|
|
10
|
+
return <HoverCardPrimitive.Trigger data-slot="hover-card-trigger" {...props} />
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function HoverCardContent({
|
|
14
|
+
className,
|
|
15
|
+
align = 'center',
|
|
16
|
+
alignOffset = 0,
|
|
17
|
+
side = 'bottom',
|
|
18
|
+
sideOffset = 4,
|
|
19
|
+
children,
|
|
20
|
+
...props
|
|
21
|
+
}: HoverCardPrimitive.Popup.Props &
|
|
22
|
+
Pick<HoverCardPrimitive.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset'>) {
|
|
23
|
+
return (
|
|
24
|
+
<HoverCardPrimitive.Portal>
|
|
25
|
+
<HoverCardPrimitive.Positioner
|
|
26
|
+
align={align}
|
|
27
|
+
alignOffset={alignOffset}
|
|
28
|
+
side={side}
|
|
29
|
+
sideOffset={sideOffset}
|
|
30
|
+
className="isolate z-popover"
|
|
31
|
+
>
|
|
32
|
+
<HoverCardPrimitive.Popup
|
|
33
|
+
data-slot="hover-card-content"
|
|
34
|
+
className={cn(
|
|
35
|
+
'bg-popover text-popover-foreground data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-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 ring-foreground/10 rounded-lg p-4 text-xs shadow-md ring-[length:var(--border-width)] duration-fast z-popover w-80 origin-(--transform-origin) outline-hidden',
|
|
36
|
+
className,
|
|
37
|
+
)}
|
|
38
|
+
{...props}
|
|
39
|
+
>
|
|
40
|
+
{children}
|
|
41
|
+
</HoverCardPrimitive.Popup>
|
|
42
|
+
</HoverCardPrimitive.Positioner>
|
|
43
|
+
</HoverCardPrimitive.Portal>
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { HoverCard, HoverCardTrigger, HoverCardContent }
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { cva, type VariantProps } from 'class-variance-authority'
|
|
2
|
+
import type * as React from 'react'
|
|
3
|
+
import { cn } from '../lib/utils'
|
|
4
|
+
|
|
5
|
+
const iconVariants = cva(
|
|
6
|
+
'inline-flex items-center justify-center shrink-0 pointer-events-none [&>svg]:size-full',
|
|
7
|
+
{
|
|
8
|
+
variants: {
|
|
9
|
+
size: {
|
|
10
|
+
xs: 'size-2.5',
|
|
11
|
+
sm: 'size-3',
|
|
12
|
+
md: 'size-3.5',
|
|
13
|
+
lg: 'size-4',
|
|
14
|
+
xl: 'size-5',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
defaultVariants: {
|
|
18
|
+
size: 'md',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
function Icon({
|
|
24
|
+
className,
|
|
25
|
+
size = 'md',
|
|
26
|
+
spin = false,
|
|
27
|
+
children,
|
|
28
|
+
...props
|
|
29
|
+
}: React.ComponentProps<'span'> &
|
|
30
|
+
VariantProps<typeof iconVariants> & {
|
|
31
|
+
spin?: boolean
|
|
32
|
+
}) {
|
|
33
|
+
return (
|
|
34
|
+
<span
|
|
35
|
+
data-slot="icon"
|
|
36
|
+
aria-hidden="true"
|
|
37
|
+
className={cn(iconVariants({ size }), spin && 'animate-spin', className)}
|
|
38
|
+
{...props}
|
|
39
|
+
>
|
|
40
|
+
{children}
|
|
41
|
+
</span>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { Icon, iconVariants }
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { cva, type VariantProps } from 'class-variance-authority'
|
|
2
|
+
import type * as React from 'react'
|
|
3
|
+
import { Button } from './button'
|
|
4
|
+
import { Input } from './input'
|
|
5
|
+
import { Textarea } from './textarea'
|
|
6
|
+
import { cn } from '../lib/utils'
|
|
7
|
+
|
|
8
|
+
function InputGroup({ className, ...props }: React.ComponentProps<'div'>) {
|
|
9
|
+
return (
|
|
10
|
+
<div
|
|
11
|
+
data-slot="input-group"
|
|
12
|
+
role="group"
|
|
13
|
+
className={cn(
|
|
14
|
+
'border-field bg-field/20 dark:bg-field/30 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-focus/30 has-[[data-slot=input-group-control]:focus-visible]:ring-[length:calc(var(--border-width)*2)] has-[[data-slot][aria-invalid=true]]:ring-stroke-critical/20 has-[[data-slot][aria-invalid=true]]:border-stroke-critical dark:has-[[data-slot][aria-invalid=true]]:ring-stroke-critical/40 has-[[data-slot][aria-invalid=true]]:ring-[length:calc(var(--border-width)*2)] h-7 rounded-md border has-data-[align=block-end]:rounded-md has-data-[align=block-start]:rounded-md has-[textarea]:rounded-md has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5 [[data-slot=combobox-content]_&]:focus-within:border-inherit [[data-slot=combobox-content]_&]:focus-within:ring-0 group/input-group relative flex w-full min-w-0 items-center outline-none has-[>textarea]:h-auto',
|
|
15
|
+
className,
|
|
16
|
+
)}
|
|
17
|
+
{...props}
|
|
18
|
+
/>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const inputGroupAddonVariants = cva(
|
|
23
|
+
"text-muted-foreground **:data-[slot=kbd]:bg-muted-foreground/10 h-auto gap-1 py-2 text-xs/relaxed font-medium group-data-[disabled=true]/input-group:opacity-disabled **:data-[slot=kbd]:rounded-[calc(var(--radius-sm)-2px)] **:data-[slot=kbd]:px-1 **:data-[slot=kbd]:text-2xs [&>svg:not([class*='size-'])]:size-3.5 flex cursor-text items-center justify-center select-none",
|
|
24
|
+
{
|
|
25
|
+
variants: {
|
|
26
|
+
align: {
|
|
27
|
+
'inline-start': 'pl-2.5 has-[>button]:ml-[-0.275rem] has-[>kbd]:ml-[-0.275rem] order-first',
|
|
28
|
+
'inline-end': 'pr-2.5 has-[>button]:mr-[-0.275rem] has-[>kbd]:mr-[-0.275rem] order-last',
|
|
29
|
+
'block-start':
|
|
30
|
+
'px-2 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2 order-first w-full justify-start',
|
|
31
|
+
'block-end':
|
|
32
|
+
'px-2 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2 order-last w-full justify-start',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
defaultVariants: {
|
|
36
|
+
align: 'inline-start',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
function InputGroupAddon({
|
|
42
|
+
className,
|
|
43
|
+
align = 'inline-start',
|
|
44
|
+
...props
|
|
45
|
+
}: React.ComponentProps<'div'> & VariantProps<typeof inputGroupAddonVariants>) {
|
|
46
|
+
return (
|
|
47
|
+
<div
|
|
48
|
+
role="group"
|
|
49
|
+
data-slot="input-group-addon"
|
|
50
|
+
data-align={align}
|
|
51
|
+
className={cn(inputGroupAddonVariants({ align }), className)}
|
|
52
|
+
onClick={(e) => {
|
|
53
|
+
if ((e.target as HTMLElement).closest('button')) {
|
|
54
|
+
return
|
|
55
|
+
}
|
|
56
|
+
e.currentTarget.parentElement?.querySelector('input')?.focus()
|
|
57
|
+
}}
|
|
58
|
+
{...props}
|
|
59
|
+
/>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const inputGroupButtonVariants = cva(
|
|
64
|
+
'gap-2 rounded-md text-xs/relaxed shadow-none flex items-center',
|
|
65
|
+
{
|
|
66
|
+
variants: {
|
|
67
|
+
size: {
|
|
68
|
+
xs: "h-5 gap-1 rounded-[calc(var(--radius-sm)-2px)] px-1 [&>svg:not([class*='size-'])]:size-3",
|
|
69
|
+
sm: '',
|
|
70
|
+
'icon-xs': 'size-6 p-0 has-[>svg]:p-0',
|
|
71
|
+
'icon-sm': 'size-8 p-0 has-[>svg]:p-0',
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
defaultVariants: {
|
|
75
|
+
size: 'xs',
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
function InputGroupButton({
|
|
81
|
+
className,
|
|
82
|
+
type = 'button',
|
|
83
|
+
variant = 'ghost',
|
|
84
|
+
size = 'xs',
|
|
85
|
+
...props
|
|
86
|
+
}: Omit<React.ComponentProps<typeof Button>, 'size' | 'type'> &
|
|
87
|
+
VariantProps<typeof inputGroupButtonVariants> & {
|
|
88
|
+
type?: 'button' | 'submit' | 'reset'
|
|
89
|
+
}) {
|
|
90
|
+
return (
|
|
91
|
+
<Button
|
|
92
|
+
type={type}
|
|
93
|
+
data-size={size}
|
|
94
|
+
variant={variant}
|
|
95
|
+
className={cn(inputGroupButtonVariants({ size }), className)}
|
|
96
|
+
{...props}
|
|
97
|
+
/>
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function InputGroupText({ className, ...props }: React.ComponentProps<'span'>) {
|
|
102
|
+
return (
|
|
103
|
+
<span
|
|
104
|
+
className={cn(
|
|
105
|
+
"text-muted-foreground gap-2 text-xs/relaxed [&_svg:not([class*='size-'])]:size-4 flex items-center [&_svg]:pointer-events-none",
|
|
106
|
+
className,
|
|
107
|
+
)}
|
|
108
|
+
{...props}
|
|
109
|
+
/>
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function InputGroupInput({ className, ...props }: React.ComponentProps<'input'>) {
|
|
114
|
+
return (
|
|
115
|
+
<Input
|
|
116
|
+
data-slot="input-group-control"
|
|
117
|
+
className={cn(
|
|
118
|
+
'rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 aria-invalid:ring-0 dark:bg-transparent flex-1',
|
|
119
|
+
className,
|
|
120
|
+
)}
|
|
121
|
+
{...props}
|
|
122
|
+
/>
|
|
123
|
+
)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function InputGroupTextarea({ className, ...props }: React.ComponentProps<'textarea'>) {
|
|
127
|
+
return (
|
|
128
|
+
<Textarea
|
|
129
|
+
data-slot="input-group-control"
|
|
130
|
+
className={cn(
|
|
131
|
+
'rounded-none border-0 bg-transparent py-2 shadow-none ring-0 focus-visible:ring-0 aria-invalid:ring-0 dark:bg-transparent flex-1 resize-none',
|
|
132
|
+
className,
|
|
133
|
+
)}
|
|
134
|
+
{...props}
|
|
135
|
+
/>
|
|
136
|
+
)
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export {
|
|
140
|
+
InputGroup,
|
|
141
|
+
InputGroupAddon,
|
|
142
|
+
InputGroupButton,
|
|
143
|
+
InputGroupText,
|
|
144
|
+
InputGroupInput,
|
|
145
|
+
InputGroupTextarea,
|
|
146
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Input as InputPrimitive } from '@base-ui/react/input'
|
|
2
|
+
import type * as React from 'react'
|
|
3
|
+
|
|
4
|
+
import { cn, FOCUS_RING } from '../lib/utils'
|
|
5
|
+
|
|
6
|
+
function Input({ className, type, ...props }: React.ComponentProps<'input'>) {
|
|
7
|
+
return (
|
|
8
|
+
<InputPrimitive
|
|
9
|
+
type={type}
|
|
10
|
+
data-slot="input"
|
|
11
|
+
className={cn(
|
|
12
|
+
FOCUS_RING,
|
|
13
|
+
'bg-field/20 dark:bg-field/30 border-field hover:border-foreground/50 h-7 rounded-md border px-2 py-0.5 text-sm file:h-6 file:text-xs/relaxed file:font-medium md:text-xs/relaxed file:text-foreground placeholder:text-muted-foreground w-full min-w-0 outline-none file:inline-flex file:border-0 file:bg-transparent disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-disabled',
|
|
14
|
+
className,
|
|
15
|
+
)}
|
|
16
|
+
{...props}
|
|
17
|
+
onWheel={(e) => {
|
|
18
|
+
e.currentTarget.blur()
|
|
19
|
+
}}
|
|
20
|
+
/>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { Input }
|