@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.
Files changed (209) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +387 -0
  3. package/dist/presets/brutalist.css +298 -0
  4. package/dist/presets/default.css +298 -0
  5. package/dist/presets/signal-pop.css +369 -0
  6. package/dist/styles.css +2 -0
  7. package/package.json +216 -0
  8. package/rules/composables.md +244 -0
  9. package/src/_internal/accordion.tsx +93 -0
  10. package/src/_internal/ai-elements/attachments.tsx +385 -0
  11. package/src/_internal/ai-elements/chain-of-thought.tsx +197 -0
  12. package/src/_internal/ai-elements/code-block.tsx +516 -0
  13. package/src/_internal/ai-elements/confirmation.tsx +150 -0
  14. package/src/_internal/ai-elements/conversation.tsx +148 -0
  15. package/src/_internal/ai-elements/inline-citation.tsx +248 -0
  16. package/src/_internal/ai-elements/message.tsx +292 -0
  17. package/src/_internal/ai-elements/plan.tsx +126 -0
  18. package/src/_internal/ai-elements/prompt-input.tsx +1285 -0
  19. package/src/_internal/ai-elements/reasoning.tsx +208 -0
  20. package/src/_internal/ai-elements/shimmer.tsx +72 -0
  21. package/src/_internal/ai-elements/sources.tsx +53 -0
  22. package/src/_internal/ai-elements/suggestion.tsx +48 -0
  23. package/src/_internal/ai-elements/task.tsx +64 -0
  24. package/src/_internal/ai-elements/tool.tsx +156 -0
  25. package/src/_internal/alert-dialog.tsx +159 -0
  26. package/src/_internal/alert.tsx +88 -0
  27. package/src/_internal/aspect-ratio.tsx +23 -0
  28. package/src/_internal/avatar.tsx +58 -0
  29. package/src/_internal/badge.tsx +60 -0
  30. package/src/_internal/breadcrumb.tsx +104 -0
  31. package/src/_internal/bubble.tsx +125 -0
  32. package/src/_internal/button-group.tsx +78 -0
  33. package/src/_internal/button.tsx +62 -0
  34. package/src/_internal/calendar.tsx +179 -0
  35. package/src/_internal/card.tsx +83 -0
  36. package/src/_internal/carousel.tsx +215 -0
  37. package/src/_internal/checkbox.tsx +26 -0
  38. package/src/_internal/code-block.tsx +53 -0
  39. package/src/_internal/collapsible.tsx +15 -0
  40. package/src/_internal/combobox.tsx +264 -0
  41. package/src/_internal/command.tsx +155 -0
  42. package/src/_internal/container.tsx +35 -0
  43. package/src/_internal/dialog.tsx +132 -0
  44. package/src/_internal/direction.tsx +12 -0
  45. package/src/_internal/divider.tsx +162 -0
  46. package/src/_internal/dropdown-menu.tsx +247 -0
  47. package/src/_internal/dropzone.tsx +481 -0
  48. package/src/_internal/empty.tsx +94 -0
  49. package/src/_internal/field.tsx +221 -0
  50. package/src/_internal/grid-overlay.tsx +48 -0
  51. package/src/_internal/grid.tsx +109 -0
  52. package/src/_internal/hover-card.tsx +47 -0
  53. package/src/_internal/icon.tsx +45 -0
  54. package/src/_internal/input-group.tsx +146 -0
  55. package/src/_internal/input.tsx +24 -0
  56. package/src/_internal/item.tsx +187 -0
  57. package/src/_internal/kbd.tsx +28 -0
  58. package/src/_internal/label.tsx +18 -0
  59. package/src/_internal/layout-bento.tsx +386 -0
  60. package/src/_internal/layout.tsx +174 -0
  61. package/src/_internal/marker.tsx +66 -0
  62. package/src/_internal/message.tsx +85 -0
  63. package/src/_internal/native-select.tsx +50 -0
  64. package/src/_internal/pagination.tsx +108 -0
  65. package/src/_internal/popover.tsx +83 -0
  66. package/src/_internal/progress.tsx +59 -0
  67. package/src/_internal/radio-group.tsx +36 -0
  68. package/src/_internal/resizable.tsx +44 -0
  69. package/src/_internal/scroll-area.tsx +48 -0
  70. package/src/_internal/select.tsx +187 -0
  71. package/src/_internal/separator.tsx +19 -0
  72. package/src/_internal/sheet.tsx +122 -0
  73. package/src/_internal/sidebar.tsx +687 -0
  74. package/src/_internal/skeleton.tsx +13 -0
  75. package/src/_internal/slider.tsx +60 -0
  76. package/src/_internal/sonner.tsx +51 -0
  77. package/src/_internal/spacer.tsx +42 -0
  78. package/src/_internal/spinner.tsx +16 -0
  79. package/src/_internal/stack.tsx +78 -0
  80. package/src/_internal/switch.tsx +31 -0
  81. package/src/_internal/table.tsx +84 -0
  82. package/src/_internal/tabs.tsx +74 -0
  83. package/src/_internal/textarea.tsx +19 -0
  84. package/src/_internal/toggle-group.tsx +99 -0
  85. package/src/_internal/toggle.tsx +42 -0
  86. package/src/_internal/tooltip.tsx +55 -0
  87. package/src/_internal/typography.tsx +129 -0
  88. package/src/hooks/use-mobile.ts +19 -0
  89. package/src/hooks/use-numeric-input.ts +119 -0
  90. package/src/index.ts +443 -0
  91. package/src/lib/numeric-input.ts +88 -0
  92. package/src/lib/utils.ts +39 -0
  93. package/src/opinionated/accordion.tsx +92 -0
  94. package/src/opinionated/ai/attachments.tsx +27 -0
  95. package/src/opinionated/ai/chain-of-thought.tsx +16 -0
  96. package/src/opinionated/ai/code-block.tsx +22 -0
  97. package/src/opinionated/ai/confirmation.tsx +16 -0
  98. package/src/opinionated/ai/conversation.tsx +13 -0
  99. package/src/opinionated/ai/index.ts +15 -0
  100. package/src/opinionated/ai/inline-citation.tsx +30 -0
  101. package/src/opinionated/ai/message.tsx +26 -0
  102. package/src/opinionated/ai/plan.tsx +18 -0
  103. package/src/opinionated/ai/prompt-input.tsx +29 -0
  104. package/src/opinionated/ai/reasoning.tsx +9 -0
  105. package/src/opinionated/ai/shimmer.tsx +4 -0
  106. package/src/opinionated/ai/sources.tsx +10 -0
  107. package/src/opinionated/ai/suggestion.tsx +6 -0
  108. package/src/opinionated/ai/task.tsx +12 -0
  109. package/src/opinionated/ai/tool.tsx +14 -0
  110. package/src/opinionated/alert-dialog.tsx +143 -0
  111. package/src/opinionated/alert.tsx +99 -0
  112. package/src/opinionated/aspect-ratio.tsx +12 -0
  113. package/src/opinionated/avatar.tsx +59 -0
  114. package/src/opinionated/badge.tsx +33 -0
  115. package/src/opinionated/breadcrumb.tsx +99 -0
  116. package/src/opinionated/bubble.tsx +9 -0
  117. package/src/opinionated/button.tsx +59 -0
  118. package/src/opinionated/calendar.tsx +20 -0
  119. package/src/opinionated/card.tsx +83 -0
  120. package/src/opinionated/carousel.tsx +99 -0
  121. package/src/opinionated/checkbox.tsx +11 -0
  122. package/src/opinionated/code-block.tsx +12 -0
  123. package/src/opinionated/collapsible.tsx +123 -0
  124. package/src/opinionated/combobox.tsx +123 -0
  125. package/src/opinionated/container.tsx +12 -0
  126. package/src/opinionated/dialog.tsx +124 -0
  127. package/src/opinionated/direction.tsx +6 -0
  128. package/src/opinionated/divider.tsx +13 -0
  129. package/src/opinionated/dropdown-menu.tsx +131 -0
  130. package/src/opinionated/dropzone.tsx +39 -0
  131. package/src/opinionated/empty.tsx +191 -0
  132. package/src/opinionated/field.tsx +26 -0
  133. package/src/opinionated/form-calendar-popover.tsx +138 -0
  134. package/src/opinionated/form-checkbox.tsx +107 -0
  135. package/src/opinionated/form-combobox.tsx +181 -0
  136. package/src/opinionated/form-date-of-birth.tsx +193 -0
  137. package/src/opinionated/form-dropzone.tsx +126 -0
  138. package/src/opinionated/form-input-group.tsx +184 -0
  139. package/src/opinionated/form-input.tsx +118 -0
  140. package/src/opinionated/form-multi-combobox.tsx +213 -0
  141. package/src/opinionated/form-multi-dropzone.tsx +141 -0
  142. package/src/opinionated/form-radiogroup.tsx +116 -0
  143. package/src/opinionated/form-select.tsx +176 -0
  144. package/src/opinionated/form-slider.tsx +100 -0
  145. package/src/opinionated/form-switch.tsx +117 -0
  146. package/src/opinionated/form-textarea.tsx +79 -0
  147. package/src/opinionated/grid-overlay.tsx +11 -0
  148. package/src/opinionated/grid.tsx +14 -0
  149. package/src/opinionated/hover-card.tsx +59 -0
  150. package/src/opinionated/icon.tsx +14 -0
  151. package/src/opinionated/input-group.tsx +20 -0
  152. package/src/opinionated/input.tsx +11 -0
  153. package/src/opinionated/item.tsx +182 -0
  154. package/src/opinionated/kbd.tsx +16 -0
  155. package/src/opinionated/label.tsx +11 -0
  156. package/src/opinionated/layout-bento.tsx +29 -0
  157. package/src/opinionated/layout.tsx +26 -0
  158. package/src/opinionated/list.tsx +94 -0
  159. package/src/opinionated/marker.tsx +7 -0
  160. package/src/opinionated/message.tsx +8 -0
  161. package/src/opinionated/native-select.tsx +51 -0
  162. package/src/opinionated/pagination.tsx +204 -0
  163. package/src/opinionated/popover.tsx +68 -0
  164. package/src/opinionated/progress.tsx +48 -0
  165. package/src/opinionated/radio-group.tsx +13 -0
  166. package/src/opinionated/resizable.tsx +2 -0
  167. package/src/opinionated/scroll-area.tsx +82 -0
  168. package/src/opinionated/select.tsx +101 -0
  169. package/src/opinionated/separator.tsx +11 -0
  170. package/src/opinionated/sheet.tsx +120 -0
  171. package/src/opinionated/sidebar.tsx +68 -0
  172. package/src/opinionated/skeleton.tsx +246 -0
  173. package/src/opinionated/slider.tsx +11 -0
  174. package/src/opinionated/sonner.tsx +15 -0
  175. package/src/opinionated/spacer.tsx +11 -0
  176. package/src/opinionated/stack.tsx +18 -0
  177. package/src/opinionated/switch.tsx +11 -0
  178. package/src/opinionated/table.tsx +11 -0
  179. package/src/opinionated/tabs.tsx +68 -0
  180. package/src/opinionated/textarea.tsx +11 -0
  181. package/src/opinionated/theme-injector.tsx +31 -0
  182. package/src/opinionated/toggle-group.tsx +63 -0
  183. package/src/opinionated/toggle.tsx +75 -0
  184. package/src/opinionated/token-config-panel/color-editor.tsx +85 -0
  185. package/src/opinionated/token-config-panel/helpers.ts +31 -0
  186. package/src/opinionated/token-config-panel/index.tsx +398 -0
  187. package/src/opinionated/token-config-panel/json-import-export.tsx +89 -0
  188. package/src/opinionated/token-config-panel/preset-manager.ts +31 -0
  189. package/src/opinionated/token-config-panel/presets-data.ts +23 -0
  190. package/src/opinionated/token-config-panel/spacing-editor.tsx +325 -0
  191. package/src/opinionated/token-config-panel/types.ts +39 -0
  192. package/src/opinionated/token-config-panel/typography-editor.tsx +145 -0
  193. package/src/opinionated/tooltip.tsx +62 -0
  194. package/src/opinionated/typography.tsx +7 -0
  195. package/src/scripts/lint-no-arbitrary.ts +155 -0
  196. package/src/styles/composable.css +68 -0
  197. package/src/styles/presets/brutalist.css +298 -0
  198. package/src/styles/presets/default.css +298 -0
  199. package/src/styles/presets/signal-pop.css +369 -0
  200. package/src/styles/presets-data/brutalist.ts +325 -0
  201. package/src/styles/presets-data/default.ts +315 -0
  202. package/src/styles/presets-data/index.ts +45 -0
  203. package/src/styles/presets-data/signal-pop.ts +393 -0
  204. package/src/styles/tokens/base.css +71 -0
  205. package/src/styles/tokens/components.css +150 -0
  206. package/src/styles/tokens/palette.css +795 -0
  207. package/src/styles/tokens/registry.ts +324 -0
  208. package/src/styles/tokens/semantic.css +266 -0
  209. package/src/styles/tokens/tailwind-theme.css +247 -0
@@ -0,0 +1,99 @@
1
+ import { AlertTriangleIcon, CircleCheckIcon, InfoIcon, TriangleAlertIcon } from 'lucide-react'
2
+ import type * as React from 'react'
3
+
4
+ import {
5
+ AlertAction,
6
+ AlertDescription,
7
+ Alert as AlertPrimitive,
8
+ AlertTitle,
9
+ } from '../_internal/alert'
10
+
11
+ export type AlertType = 'notice' | 'negative' | 'positive' | 'default' | 'warning'
12
+
13
+ /**
14
+ * Props for the opinionated Alert component.
15
+ *
16
+ * Maps a semantic `type` prop to the appropriate icon and visual variant,
17
+ * so you don't need to handle that mapping yourself.
18
+ *
19
+ * @example
20
+ * ```tsx
21
+ * <Alert type="positive" title="Payment successful" message="Your invoice has been sent." />
22
+ * <Alert type="negative" title="Something went wrong" message={error.message} />
23
+ * <Alert type="notice" message="Your session expires in 5 minutes." />
24
+ * <Alert type="warning" title="Storage almost full">
25
+ * <Button size="sm">Upgrade plan</Button>
26
+ * </Alert>
27
+ * ```
28
+ */
29
+ export interface AlertProps extends Omit<
30
+ React.ComponentProps<typeof AlertPrimitive>,
31
+ 'variant' | 'title'
32
+ > {
33
+ /**
34
+ * Semantic type that controls the icon and colour variant.
35
+ * - `default` — no icon, neutral styling
36
+ * - `notice` — info icon (ℹ), neutral styling
37
+ * - `positive` — check icon, green styling
38
+ * - `warning` — triangle icon, amber styling
39
+ * - `negative` — alert triangle icon, red/destructive styling
40
+ * @default 'default'
41
+ */
42
+ type?: AlertType
43
+ /** Alert heading rendered in bold. */
44
+ title?: React.ReactNode
45
+ /** Alert body text. Alternatively pass `children`. */
46
+ message?: React.ReactNode
47
+ children?: React.ReactNode
48
+ /** Content rendered at the trailing edge of the alert (e.g. a dismiss button). */
49
+ action?: React.ReactNode
50
+ className?: string
51
+ }
52
+
53
+ function Alert({
54
+ type = 'default',
55
+ title,
56
+ message,
57
+ children,
58
+ action,
59
+ className,
60
+ ...alertProps
61
+ }: AlertProps) {
62
+ // Map alert types to variants
63
+ const variant = type === 'negative' ? 'destructive' : type === 'warning' ? 'warning' : 'default'
64
+
65
+ // Get icon based on type
66
+ const getIcon = () => {
67
+ switch (type) {
68
+ case 'negative':
69
+ return <AlertTriangleIcon className="size-3.5" />
70
+ case 'positive':
71
+ return <CircleCheckIcon className="size-3.5" />
72
+ case 'notice':
73
+ return <InfoIcon className="size-3.5" />
74
+ case 'warning':
75
+ return <TriangleAlertIcon className="size-3.5" />
76
+ default:
77
+ return null
78
+ }
79
+ }
80
+
81
+ const icon = getIcon()
82
+ const content = message || children
83
+
84
+ return (
85
+ <AlertPrimitive variant={variant} className={className} {...alertProps}>
86
+ {icon}
87
+ <div className="flex-1">
88
+ {title && <AlertTitle>{title}</AlertTitle>}
89
+ {content && <AlertDescription>{content}</AlertDescription>}
90
+ </div>
91
+ {action && <AlertAction>{action}</AlertAction>}
92
+ </AlertPrimitive>
93
+ )
94
+ }
95
+
96
+ // Re-export all alert sub-components for convenience
97
+ export { AlertAction, AlertDescription, AlertTitle }
98
+
99
+ export { Alert }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Opinionated AspectRatio component.
3
+ * Re-exports the primitive as the API is already clean.
4
+ *
5
+ * @example
6
+ * ```tsx
7
+ * <AspectRatio ratio={16 / 9}>
8
+ * <img src="image.jpg" alt="Landscape" className="object-cover" />
9
+ * </AspectRatio>
10
+ * ```
11
+ */
12
+ export { AspectRatio } from '../_internal/aspect-ratio'
@@ -0,0 +1,59 @@
1
+ import type { VariantProps } from 'class-variance-authority'
2
+ import type * as React from 'react'
3
+
4
+ import {
5
+ AvatarFallback,
6
+ Avatar as AvatarPrimitive,
7
+ AvatarImage,
8
+ avatarVariants,
9
+ } from '../_internal/avatar'
10
+
11
+ /**
12
+ * Get initials from a name string.
13
+ * Takes first letter of first and last words, or first two letters if single word.
14
+ */
15
+ function getInitials(name: string): string {
16
+ const words = name.trim().split(/\s+/)
17
+ if (words.length === 1) {
18
+ return words[0].slice(0, 2).toUpperCase()
19
+ }
20
+ return (words[0][0] + words[words.length - 1][0]).toUpperCase()
21
+ }
22
+
23
+ export interface AvatarProps extends VariantProps<typeof avatarVariants> {
24
+ /** Image source URL */
25
+ src?: string
26
+ /** Alt text for the image */
27
+ alt?: string
28
+ /** Name for generating fallback initials */
29
+ name?: string
30
+ /** Custom fallback content (overrides name-based initials) */
31
+ fallback?: React.ReactNode
32
+ /** Additional class names */
33
+ className?: string
34
+ }
35
+
36
+ /**
37
+ * Opinionated Avatar component with automatic initials fallback.
38
+ *
39
+ * @example
40
+ * ```tsx
41
+ * <Avatar src="/avatar.jpg" name="John Doe" />
42
+ * <Avatar name="Jane Smith" size="lg" />
43
+ * <Avatar src="/user.png" fallback="?" />
44
+ * ```
45
+ */
46
+ function Avatar({ src, alt, name, fallback, size, className }: AvatarProps) {
47
+ const displayFallback = fallback ?? (name ? getInitials(name) : '?')
48
+
49
+ return (
50
+ <AvatarPrimitive size={size} className={className}>
51
+ {src && <AvatarImage src={src} alt={alt ?? name ?? 'Avatar'} />}
52
+ <AvatarFallback>{displayFallback}</AvatarFallback>
53
+ </AvatarPrimitive>
54
+ )
55
+ }
56
+
57
+ // Re-export sub-components for advanced usage
58
+ export { AvatarFallback, AvatarImage, avatarVariants }
59
+ export { Avatar }
@@ -0,0 +1,33 @@
1
+ import type { useRender } from '@base-ui/react/use-render'
2
+ import type { VariantProps } from 'class-variance-authority'
3
+ import type * as React from 'react'
4
+
5
+ import { Badge as BadgePrimitive, type badgeVariants } from '../_internal/badge'
6
+
7
+ /**
8
+ * Props for the opinionated Badge component.
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * <Badge>New</Badge>
13
+ * <Badge variant="secondary">Draft</Badge>
14
+ * <Badge variant="destructive">Error</Badge>
15
+ * <Badge variant="outline">v1.2.3</Badge>
16
+ * ```
17
+ */
18
+ export interface BadgeProps extends Omit<useRender.ComponentProps<'span'>, 'size'> {
19
+ /** Visual style variant. @default 'default' */
20
+ variant?: VariantProps<typeof badgeVariants>['variant']
21
+ className?: string
22
+ children: React.ReactNode
23
+ }
24
+
25
+ function Badge({ variant = 'default', className, children, render, ...badgeProps }: BadgeProps) {
26
+ return (
27
+ <BadgePrimitive variant={variant} className={className} render={render} {...badgeProps}>
28
+ {children}
29
+ </BadgePrimitive>
30
+ )
31
+ }
32
+
33
+ export { Badge }
@@ -0,0 +1,99 @@
1
+ import * as React from 'react'
2
+
3
+ import {
4
+ Breadcrumb as BreadcrumbPrimitive,
5
+ BreadcrumbEllipsis,
6
+ BreadcrumbItem,
7
+ BreadcrumbLink,
8
+ BreadcrumbList,
9
+ BreadcrumbPage,
10
+ BreadcrumbSeparator,
11
+ } from '../_internal/breadcrumb'
12
+
13
+ export interface BreadcrumbItemData {
14
+ /** Display label for the breadcrumb item */
15
+ label: React.ReactNode
16
+ /** URL to navigate to (omit for current page) */
17
+ href?: string
18
+ /** Click handler (alternative to href) */
19
+ onClick?: () => void
20
+ }
21
+
22
+ export interface BreadcrumbProps {
23
+ /** Array of breadcrumb items. Last item is treated as current page. */
24
+ items: BreadcrumbItemData[]
25
+ /** Custom separator element */
26
+ separator?: React.ReactNode
27
+ /** Additional class names */
28
+ className?: string
29
+ /** Children for advanced usage (overrides items) */
30
+ children?: React.ReactNode
31
+ }
32
+
33
+ /**
34
+ * Opinionated Breadcrumb component with items array API.
35
+ * The last item is automatically rendered as the current page (no link).
36
+ *
37
+ * @example
38
+ * ```tsx
39
+ * <Breadcrumb
40
+ * items={[
41
+ * { label: 'Home', href: '/' },
42
+ * { label: 'Products', href: '/products' },
43
+ * { label: 'Electronics', href: '/products/electronics' },
44
+ * { label: 'Phones' }, // Current page, no link
45
+ * ]}
46
+ * />
47
+ * ```
48
+ */
49
+ function Breadcrumb({ items, separator, className, children }: BreadcrumbProps) {
50
+ // If children provided, use primitive API
51
+ if (children) {
52
+ return <BreadcrumbPrimitive className={className}>{children}</BreadcrumbPrimitive>
53
+ }
54
+
55
+ return (
56
+ <BreadcrumbPrimitive className={className}>
57
+ <BreadcrumbList>
58
+ {items.map((item, index) => {
59
+ const isLast = index === items.length - 1
60
+ const isFirst = index === 0
61
+
62
+ return (
63
+ <React.Fragment key={index}>
64
+ {!isFirst && <BreadcrumbSeparator>{separator}</BreadcrumbSeparator>}
65
+ <BreadcrumbItem>
66
+ {isLast ? (
67
+ <BreadcrumbPage>{item.label}</BreadcrumbPage>
68
+ ) : item.href ? (
69
+ <BreadcrumbLink href={item.href}>{item.label}</BreadcrumbLink>
70
+ ) : item.onClick ? (
71
+ <BreadcrumbLink
72
+ render={
73
+ <button type="button" onClick={item.onClick}>
74
+ {item.label}
75
+ </button>
76
+ }
77
+ />
78
+ ) : (
79
+ <BreadcrumbPage>{item.label}</BreadcrumbPage>
80
+ )}
81
+ </BreadcrumbItem>
82
+ </React.Fragment>
83
+ )
84
+ })}
85
+ </BreadcrumbList>
86
+ </BreadcrumbPrimitive>
87
+ )
88
+ }
89
+
90
+ // Re-export sub-components for advanced usage
91
+ export {
92
+ BreadcrumbEllipsis,
93
+ BreadcrumbItem,
94
+ BreadcrumbLink,
95
+ BreadcrumbList,
96
+ BreadcrumbPage,
97
+ BreadcrumbSeparator,
98
+ }
99
+ export { Breadcrumb }
@@ -0,0 +1,9 @@
1
+ export {
2
+ Bubble,
3
+ BubbleContent,
4
+ BubbleGroup,
5
+ BubbleReactions,
6
+ type BubbleProps,
7
+ bubbleReactionsVariants,
8
+ bubbleVariants,
9
+ } from '../_internal/bubble'
@@ -0,0 +1,59 @@
1
+ import type { VariantProps } from 'class-variance-authority'
2
+ import { Loader2Icon } from 'lucide-react'
3
+ import type * as React from 'react'
4
+
5
+ import { Button as ButtonPrimitive, type buttonVariants } from '../_internal/button'
6
+
7
+ /**
8
+ * Props for the opinionated Button component.
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * <Button>Save</Button>
13
+ * <Button variant="outline" size="sm">Cancel</Button>
14
+ * <Button loading>Submitting...</Button>
15
+ * <Button variant="destructive" type="submit">Delete</Button>
16
+ * ```
17
+ */
18
+ export interface ButtonProps extends Omit<React.ComponentProps<'button'>, 'size'> {
19
+ /** Visual style variant. @default 'default' */
20
+ variant?: VariantProps<typeof buttonVariants>['variant']
21
+ /** Size variant. @default 'default' */
22
+ size?: VariantProps<typeof buttonVariants>['size']
23
+ className?: string
24
+ /** Disables the button and prevents interaction. @default false */
25
+ disabled?: boolean
26
+ /** Shows a spinner and disables the button. Replaces children while active. @default false */
27
+ loading?: boolean
28
+ /** HTML button type attribute. @default 'button' */
29
+ type?: 'button' | 'submit' | 'reset'
30
+ children: React.ReactNode
31
+ }
32
+
33
+ function Button({
34
+ variant = 'default',
35
+ size = 'default',
36
+ className,
37
+ disabled = false,
38
+ loading = false,
39
+ type = 'button',
40
+ children,
41
+ ...buttonProps
42
+ }: ButtonProps) {
43
+ const isDisabled = disabled || loading
44
+
45
+ return (
46
+ <ButtonPrimitive
47
+ variant={variant}
48
+ size={size}
49
+ className={className}
50
+ disabled={isDisabled}
51
+ type={type}
52
+ {...buttonProps}
53
+ >
54
+ {loading ? <Loader2Icon className="animate-spin" /> : children}
55
+ </ButtonPrimitive>
56
+ )
57
+ }
58
+
59
+ export { Button }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Opinionated Calendar component.
3
+ * Re-exports the primitive as the API is already clean.
4
+ *
5
+ * @example
6
+ * ```tsx
7
+ * <Calendar
8
+ * mode="single"
9
+ * selected={date}
10
+ * onSelect={setDate}
11
+ * />
12
+ *
13
+ * <Calendar
14
+ * mode="range"
15
+ * selected={dateRange}
16
+ * onSelect={setDateRange}
17
+ * />
18
+ * ```
19
+ */
20
+ export { Calendar, CalendarDayButton } from '../_internal/calendar'
@@ -0,0 +1,83 @@
1
+ import type * as React from 'react'
2
+ import {
3
+ CardAction,
4
+ CardContent,
5
+ CardDescription,
6
+ CardFooter,
7
+ CardHeader,
8
+ Card as CardPrimitive,
9
+ CardTitle,
10
+ } from '../_internal/card'
11
+
12
+ /**
13
+ * Props for the opinionated Card component.
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * <Card title="Revenue" description="This month">
18
+ * <p>$12,400</p>
19
+ * </Card>
20
+ *
21
+ * <Card
22
+ * title="Settings"
23
+ * action={<Button size="sm">Edit</Button>}
24
+ * footer={<Button variant="outline">Cancel</Button>}
25
+ * >
26
+ * <FormInput label="Name" />
27
+ * </Card>
28
+ * ```
29
+ */
30
+ export interface CardProps extends Omit<
31
+ React.ComponentProps<typeof CardPrimitive>,
32
+ 'size' | 'children' | 'title'
33
+ > {
34
+ /** Card heading displayed in the header. */
35
+ title?: React.ReactNode
36
+ /** Subtitle text displayed below the title. */
37
+ description?: React.ReactNode
38
+ /** Content placed in the top-right of the header (e.g. a button or badge). */
39
+ action?: React.ReactNode
40
+ /** Main card body content. */
41
+ children?: React.ReactNode
42
+ /** Content rendered in the card footer. */
43
+ footer?: React.ReactNode
44
+ /** Size variant affecting padding. @default 'default' */
45
+ size?: 'default' | 'sm'
46
+ }
47
+
48
+ export const Card = ({
49
+ title,
50
+ description,
51
+ action,
52
+ children,
53
+ footer,
54
+ size = 'default',
55
+ className,
56
+ ...cardProps
57
+ }: CardProps) => {
58
+ const hasHeader = title || description || action
59
+
60
+ return (
61
+ <CardPrimitive size={size} className={className} {...cardProps}>
62
+ {hasHeader && (
63
+ <CardHeader>
64
+ {title && <CardTitle>{title}</CardTitle>}
65
+ {description && <CardDescription>{description}</CardDescription>}
66
+ {action && <CardAction>{action}</CardAction>}
67
+ </CardHeader>
68
+ )}
69
+ {children && <CardContent>{children}</CardContent>}
70
+ {footer && <CardFooter>{footer}</CardFooter>}
71
+ </CardPrimitive>
72
+ )
73
+ }
74
+
75
+ // Re-export sub-components for advanced usage
76
+ export {
77
+ CardAction,
78
+ CardContent,
79
+ CardDescription,
80
+ CardFooter,
81
+ CardHeader,
82
+ CardTitle,
83
+ } from '../_internal/card'
@@ -0,0 +1,99 @@
1
+ import type * as React from 'react'
2
+
3
+ import {
4
+ type CarouselApi,
5
+ Carousel as CarouselPrimitive,
6
+ CarouselContent,
7
+ CarouselItem,
8
+ CarouselNext,
9
+ CarouselPrevious,
10
+ } from '../_internal/carousel'
11
+
12
+ type CarouselOptions = Parameters<typeof CarouselPrimitive>[0]['opts']
13
+
14
+ export interface CarouselProps {
15
+ /** Array of items to render as slides */
16
+ items?: React.ReactNode[]
17
+ /** Embla carousel options */
18
+ opts?: CarouselOptions
19
+ /** Orientation of the carousel */
20
+ orientation?: 'horizontal' | 'vertical'
21
+ /** Whether to show navigation arrows */
22
+ showNavigation?: boolean
23
+ /** Callback to receive the carousel API */
24
+ setApi?: (api: CarouselApi) => void
25
+ /** Additional class names */
26
+ className?: string
27
+ /** Children for advanced usage (overrides items) */
28
+ children?: React.ReactNode
29
+ }
30
+
31
+ /**
32
+ * Opinionated Carousel component with items array API.
33
+ *
34
+ * @example
35
+ * ```tsx
36
+ * <Carousel
37
+ * items={[
38
+ * <img src="/slide1.jpg" alt="Slide 1" />,
39
+ * <img src="/slide2.jpg" alt="Slide 2" />,
40
+ * <img src="/slide3.jpg" alt="Slide 3" />,
41
+ * ]}
42
+ * showNavigation
43
+ * />
44
+ *
45
+ * // Or with advanced usage
46
+ * <Carousel>
47
+ * <CarouselContent>
48
+ * <CarouselItem className="basis-1/3">Slide 1</CarouselItem>
49
+ * <CarouselItem className="basis-1/3">Slide 2</CarouselItem>
50
+ * </CarouselContent>
51
+ * <CarouselPrevious />
52
+ * <CarouselNext />
53
+ * </Carousel>
54
+ * ```
55
+ */
56
+ function Carousel({
57
+ items,
58
+ opts,
59
+ orientation = 'horizontal',
60
+ showNavigation = false,
61
+ setApi,
62
+ className,
63
+ children,
64
+ }: CarouselProps) {
65
+ // If children provided, use primitive API
66
+ if (children) {
67
+ return (
68
+ <CarouselPrimitive
69
+ opts={opts}
70
+ orientation={orientation}
71
+ setApi={setApi}
72
+ className={className}
73
+ >
74
+ {children}
75
+ </CarouselPrimitive>
76
+ )
77
+ }
78
+
79
+ // Use items array API
80
+ return (
81
+ <CarouselPrimitive opts={opts} orientation={orientation} setApi={setApi} className={className}>
82
+ <CarouselContent>
83
+ {items?.map((item, index) => (
84
+ <CarouselItem key={index}>{item}</CarouselItem>
85
+ ))}
86
+ </CarouselContent>
87
+ {showNavigation && (
88
+ <>
89
+ <CarouselPrevious />
90
+ <CarouselNext />
91
+ </>
92
+ )}
93
+ </CarouselPrimitive>
94
+ )
95
+ }
96
+
97
+ // Re-export sub-components for advanced usage
98
+ export { type CarouselApi, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious }
99
+ export { Carousel }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Opinionated Checkbox component.
3
+ * Re-exports the primitive as the API is already clean.
4
+ *
5
+ * @example
6
+ * ```tsx
7
+ * <Checkbox checked={checked} onCheckedChange={setChecked} />
8
+ * <Checkbox defaultChecked />
9
+ * ```
10
+ */
11
+ export { Checkbox } from '../_internal/checkbox'
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Opinionated CodeBlock component.
3
+ * Re-exports the primitive as the API is already clean.
4
+ *
5
+ * @example
6
+ * ```tsx
7
+ * <CodeBlock language="typescript" showLineNumbers>
8
+ * {`const greeting = "Hello, World!";`}
9
+ * </CodeBlock>
10
+ * ```
11
+ */
12
+ export { CodeBlock, type CodeBlockProps } from '../_internal/code-block'