@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,94 @@
1
+ /**
2
+ * List (opinionated)
3
+ * ─────────────────────────────────────────────────────────────────────────────
4
+ * Variant list renderer: arrow | bullet.
5
+ * Builds on the composables item primitive for consistent sizing and tokens.
6
+ *
7
+ * Usage:
8
+ * // Data-driven:
9
+ * <List variant="arrow" items={[{ content: "Feature one" }, { content: "Feature two" }]} />
10
+ *
11
+ * // Compositional:
12
+ * <List variant="arrow">
13
+ * <ListArrowItem content="Hand-rolled item" />
14
+ * </List>
15
+ */
16
+
17
+ import type * as React from 'react'
18
+ import { cva, type VariantProps } from 'class-variance-authority'
19
+ import { cn } from '../lib/utils'
20
+
21
+ /* ─── Item data type ─── */
22
+
23
+ export interface ListItemData {
24
+ content: React.ReactNode
25
+ }
26
+
27
+ /* ─── Variants ─── */
28
+
29
+ export type ListVariant = 'arrow' | 'bullet'
30
+
31
+ /* ─── Item renderers ─── */
32
+
33
+ function ArrowItem({ content }: ListItemData) {
34
+ return (
35
+ <li className="flex items-start gap-3">
36
+ <span className="text-primary text-sm select-none" aria-hidden="true">
37
+ →
38
+ </span>
39
+ <span className="text-muted-foreground text-sm">{content}</span>
40
+ </li>
41
+ )
42
+ }
43
+
44
+ function BulletItem({ content }: ListItemData) {
45
+ return <li className="text-muted-foreground text-sm">{content}</li>
46
+ }
47
+
48
+ const VARIANT_ITEM: Record<ListVariant, React.FC<ListItemData>> = {
49
+ arrow: ArrowItem,
50
+ bullet: BulletItem,
51
+ }
52
+
53
+ const listVariants = cva('', {
54
+ variants: {
55
+ variant: {
56
+ arrow: 'space-y-4',
57
+ bullet: 'list-disc list-inside space-y-1',
58
+ },
59
+ },
60
+ defaultVariants: {
61
+ variant: 'bullet',
62
+ },
63
+ })
64
+
65
+ /* ─── Props ─── */
66
+
67
+ export interface ListProps extends VariantProps<typeof listVariants> {
68
+ items?: ListItemData[]
69
+ className?: string
70
+ children?: React.ReactNode
71
+ }
72
+
73
+ /* ─── Component ─── */
74
+
75
+ function List({ items, variant, className, children }: ListProps) {
76
+ // Coerce null → 'bullet' so variant={null} doesn't crash VARIANT_ITEM lookup
77
+ const safeVariant: ListVariant = (variant ?? 'bullet') as ListVariant
78
+ if (items) {
79
+ const ItemComponent = VARIANT_ITEM[safeVariant]
80
+ return (
81
+ <ul className={cn(listVariants({ variant: safeVariant }), className)}>
82
+ {items.map((item, i) => (
83
+ <ItemComponent key={i} content={item.content} />
84
+ ))}
85
+ </ul>
86
+ )
87
+ }
88
+
89
+ return <ul className={cn(listVariants({ variant: safeVariant }), className)}>{children}</ul>
90
+ }
91
+
92
+ /* ─── Named item exports for compositional use ─── */
93
+
94
+ export { List, ArrowItem as ListArrowItem, BulletItem as ListBulletItem }
@@ -0,0 +1,7 @@
1
+ export {
2
+ Marker,
3
+ MarkerContent,
4
+ MarkerIcon,
5
+ type MarkerProps,
6
+ markerVariants,
7
+ } from '../_internal/marker'
@@ -0,0 +1,8 @@
1
+ export {
2
+ Message,
3
+ MessageAvatar,
4
+ MessageContent,
5
+ MessageFooter,
6
+ MessageGroup,
7
+ MessageHeader,
8
+ } from '../_internal/message'
@@ -0,0 +1,51 @@
1
+ import type * as React from 'react'
2
+
3
+ import {
4
+ NativeSelect as NativeSelectPrimitive,
5
+ NativeSelectOptGroup,
6
+ NativeSelectOption,
7
+ type NativeSelectProps as NativeSelectPrimitiveProps,
8
+ } from '../_internal/native-select'
9
+
10
+ export interface NativeSelectOptionData {
11
+ label: string
12
+ value: string
13
+ disabled?: boolean
14
+ }
15
+
16
+ export interface NativeSelectProps extends Omit<NativeSelectPrimitiveProps, 'children'> {
17
+ options: NativeSelectOptionData[]
18
+ placeholder?: string
19
+ onValueChange?: (value: string, event: React.ChangeEvent<HTMLSelectElement>) => void
20
+ }
21
+
22
+ function NativeSelect({
23
+ options,
24
+ placeholder,
25
+ onChange,
26
+ onValueChange,
27
+ ...selectProps
28
+ }: NativeSelectProps) {
29
+ return (
30
+ <NativeSelectPrimitive
31
+ onChange={(event) => {
32
+ onChange?.(event)
33
+ onValueChange?.(event.currentTarget.value, event)
34
+ }}
35
+ {...selectProps}
36
+ >
37
+ {placeholder && (
38
+ <NativeSelectOption value="" disabled>
39
+ {placeholder}
40
+ </NativeSelectOption>
41
+ )}
42
+ {options.map((option) => (
43
+ <NativeSelectOption key={option.value} value={option.value} disabled={option.disabled}>
44
+ {option.label}
45
+ </NativeSelectOption>
46
+ ))}
47
+ </NativeSelectPrimitive>
48
+ )
49
+ }
50
+
51
+ export { NativeSelect, NativeSelectOptGroup, NativeSelectOption }
@@ -0,0 +1,204 @@
1
+ import type * as React from 'react'
2
+
3
+ import {
4
+ PaginationContent,
5
+ PaginationEllipsis,
6
+ PaginationItem,
7
+ PaginationLink,
8
+ PaginationNext,
9
+ PaginationPrevious,
10
+ Pagination as PaginationPrimitive,
11
+ } from '../_internal/pagination'
12
+
13
+ /**
14
+ * Props for the opinionated Pagination component.
15
+ *
16
+ * Renders a smart pagination bar that automatically shows ellipsis for large
17
+ * page counts and keeps a consistent number of visible page buttons.
18
+ *
19
+ * @example
20
+ * ```tsx
21
+ * <Pagination
22
+ * currentPage={page}
23
+ * totalPages={totalPages}
24
+ * onPageChange={setPage}
25
+ * />
26
+ *
27
+ * // Hide previous/next arrows
28
+ * <Pagination currentPage={3} totalPages={10} onPageChange={setPage} showPreviousNext={false} />
29
+ * ```
30
+ */
31
+ export interface PaginationProps extends Omit<
32
+ React.ComponentProps<typeof PaginationPrimitive>,
33
+ 'children'
34
+ > {
35
+ className?: string
36
+ /** Currently active page number (1-indexed). */
37
+ currentPage?: number
38
+ /** Total number of pages. */
39
+ totalPages?: number
40
+ /** Called when the user clicks a page number or previous/next. */
41
+ onPageChange?: (page: number) => void
42
+ /** Whether to render Previous / Next navigation buttons. @default true */
43
+ showPreviousNext?: boolean
44
+ /** Override whether the previous button is enabled (default: `currentPage > 1`). */
45
+ canGoPrevious?: boolean
46
+ /** Override whether the next button is enabled (default: `currentPage < totalPages`). */
47
+ canGoNext?: boolean
48
+ /** Use children for a fully custom pagination layout. */
49
+ children?: React.ReactNode
50
+ }
51
+
52
+ function Pagination({
53
+ className,
54
+ currentPage,
55
+ totalPages,
56
+ onPageChange,
57
+ showPreviousNext = true,
58
+ canGoPrevious,
59
+ canGoNext,
60
+ children,
61
+ ...paginationProps
62
+ }: PaginationProps) {
63
+ // If opinionated props are provided, use opinionated API
64
+ if (currentPage !== undefined && totalPages !== undefined) {
65
+ const getPageNumbers = () => {
66
+ const maxVisible = 7
67
+
68
+ if (totalPages <= maxVisible) {
69
+ return Array.from({ length: totalPages }, (_, i) => i + 1)
70
+ }
71
+
72
+ // Always show: [1] [...] [current-1] [current] [current+1] [...] [last]
73
+ // This keeps the number of items consistent
74
+ if (currentPage <= 3) {
75
+ // Near the start: [1] [2] [3] [4] [5] [...] [last]
76
+ return [1, 2, 3, 4, 5, '...', totalPages]
77
+ }
78
+
79
+ if (currentPage >= totalPages - 2) {
80
+ // Near the end: [1] [...] [last-4] [last-3] [last-2] [last-1] [last]
81
+ return [
82
+ 1,
83
+ '...',
84
+ totalPages - 4,
85
+ totalPages - 3,
86
+ totalPages - 2,
87
+ totalPages - 1,
88
+ totalPages,
89
+ ]
90
+ }
91
+
92
+ // Middle: [1] [...] [current-1] [current] [current+1] [...] [last]
93
+ return [1, '...', currentPage - 1, currentPage, currentPage + 1, '...', totalPages]
94
+ }
95
+
96
+ const handlePageClick = (page: number) => {
97
+ if (onPageChange) {
98
+ onPageChange(page)
99
+ }
100
+ }
101
+
102
+ const handlePrevious = () => {
103
+ if (canGoPrevious !== false && currentPage > 1) {
104
+ handlePageClick(currentPage - 1)
105
+ }
106
+ }
107
+
108
+ const handleNext = () => {
109
+ if (canGoNext !== false && currentPage < totalPages) {
110
+ handlePageClick(currentPage + 1)
111
+ }
112
+ }
113
+
114
+ const computedCanGoPrevious = canGoPrevious ?? currentPage > 1
115
+ const computedCanGoNext = canGoNext ?? currentPage < totalPages
116
+
117
+ return (
118
+ <PaginationPrimitive className={className} {...paginationProps}>
119
+ <PaginationContent>
120
+ {showPreviousNext && (
121
+ <PaginationItem>
122
+ <PaginationPrevious
123
+ onClick={(e) => {
124
+ e.preventDefault()
125
+ handlePrevious()
126
+ }}
127
+ aria-disabled={!computedCanGoPrevious}
128
+ style={{
129
+ pointerEvents: !computedCanGoPrevious ? 'none' : 'auto',
130
+ opacity: !computedCanGoPrevious ? 0.5 : 1,
131
+ }}
132
+ />
133
+ </PaginationItem>
134
+ )}
135
+
136
+ {getPageNumbers().map((page, index) =>
137
+ page === '...' ? (
138
+ // biome-ignore lint/suspicious/noArrayIndexKey: Ellipsis position is stable
139
+ <PaginationItem key={`ellipsis-${index}`}>
140
+ <PaginationEllipsis />
141
+ </PaginationItem>
142
+ ) : (
143
+ <PaginationItem key={`page-${page}`}>
144
+ <PaginationLink
145
+ onClick={(e) => {
146
+ e.preventDefault()
147
+ handlePageClick(Number(page))
148
+ }}
149
+ isActive={page === currentPage}
150
+ >
151
+ {page}
152
+ </PaginationLink>
153
+ </PaginationItem>
154
+ ),
155
+ )}
156
+
157
+ {showPreviousNext && (
158
+ <PaginationItem>
159
+ <PaginationNext
160
+ onClick={(e) => {
161
+ e.preventDefault()
162
+ handleNext()
163
+ }}
164
+ aria-disabled={!computedCanGoNext}
165
+ style={{
166
+ pointerEvents: !computedCanGoNext ? 'none' : 'auto',
167
+ opacity: !computedCanGoNext ? 0.5 : 1,
168
+ }}
169
+ />
170
+ </PaginationItem>
171
+ )}
172
+ </PaginationContent>
173
+ </PaginationPrimitive>
174
+ )
175
+ }
176
+
177
+ // Fallback to children-based API for advanced use cases
178
+ if (children) {
179
+ return (
180
+ <PaginationPrimitive className={className} {...paginationProps}>
181
+ {children}
182
+ </PaginationPrimitive>
183
+ )
184
+ }
185
+
186
+ // If neither opinionated props nor children provided, return empty pagination
187
+ return (
188
+ <PaginationPrimitive className={className} {...paginationProps}>
189
+ {null}
190
+ </PaginationPrimitive>
191
+ )
192
+ }
193
+
194
+ // Re-export all pagination sub-components for convenience
195
+ export {
196
+ PaginationContent,
197
+ PaginationEllipsis,
198
+ PaginationItem,
199
+ PaginationLink,
200
+ PaginationNext,
201
+ PaginationPrevious,
202
+ }
203
+
204
+ export { Pagination }
@@ -0,0 +1,68 @@
1
+ import type { Popover as PopoverPrimitiveBase } from '@base-ui/react/popover'
2
+ import type * as React from 'react'
3
+
4
+ import {
5
+ PopoverContent,
6
+ PopoverDescription,
7
+ PopoverHeader,
8
+ Popover as PopoverPrimitive,
9
+ PopoverTitle,
10
+ PopoverTrigger,
11
+ } from '../_internal/popover'
12
+
13
+ export interface PopoverProps extends Omit<PopoverPrimitiveBase.Root.Props, 'children'> {
14
+ /** Element that triggers the popover */
15
+ trigger: React.ReactNode
16
+ /** Content to display in the popover */
17
+ children: React.ReactNode
18
+ /** Additional class names for the content */
19
+ className?: string
20
+ /** Alignment of the content relative to trigger */
21
+ align?: 'start' | 'center' | 'end'
22
+ /** Side to position the content */
23
+ side?: 'top' | 'right' | 'bottom' | 'left'
24
+ }
25
+
26
+ /**
27
+ * Opinionated Popover component for floating content panels.
28
+ *
29
+ * @example
30
+ * ```tsx
31
+ * <Popover trigger={<Button variant="outline">Open Popover</Button>}>
32
+ * <PopoverHeader>
33
+ * <PopoverTitle>Dimensions</PopoverTitle>
34
+ * <PopoverDescription>Set the dimensions for the layer.</PopoverDescription>
35
+ * </PopoverHeader>
36
+ * <div className="grid gap-2">
37
+ * <Input placeholder="Width" />
38
+ * <Input placeholder="Height" />
39
+ * </div>
40
+ * </Popover>
41
+ *
42
+ * // Simple usage
43
+ * <Popover trigger={<Button>Info</Button>} side="right">
44
+ * <p>Additional information goes here.</p>
45
+ * </Popover>
46
+ * ```
47
+ */
48
+ function Popover({
49
+ trigger,
50
+ children,
51
+ className,
52
+ align = 'center',
53
+ side = 'bottom',
54
+ ...popoverProps
55
+ }: PopoverProps) {
56
+ return (
57
+ <PopoverPrimitive {...popoverProps}>
58
+ <PopoverTrigger render={<>{trigger}</>} />
59
+ <PopoverContent className={className} align={align} side={side}>
60
+ {children}
61
+ </PopoverContent>
62
+ </PopoverPrimitive>
63
+ )
64
+ }
65
+
66
+ // Re-export sub-components for advanced usage
67
+ export { PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger }
68
+ export { Popover }
@@ -0,0 +1,48 @@
1
+ import {
2
+ ProgressIndicator,
3
+ ProgressLabel,
4
+ Progress as ProgressPrimitive,
5
+ ProgressTrack,
6
+ ProgressValue,
7
+ } from '../_internal/progress'
8
+
9
+ export interface ProgressProps {
10
+ /** Progress value (0-100) */
11
+ value: number
12
+ /** Optional label text */
13
+ label?: string
14
+ /** Whether to display the numeric value */
15
+ showValue?: boolean
16
+ /** Additional class names */
17
+ className?: string
18
+ }
19
+
20
+ /**
21
+ * Opinionated Progress component with simplified props.
22
+ *
23
+ * @example
24
+ * ```tsx
25
+ * <Progress value={75} />
26
+ * <Progress value={50} label="Uploading" showValue />
27
+ * <Progress value={100} label="Complete" />
28
+ * ```
29
+ */
30
+ function Progress({ value, label, showValue = false, className }: ProgressProps) {
31
+ return (
32
+ <ProgressPrimitive value={value} className={className}>
33
+ {(label || showValue) && (
34
+ <div className="flex items-center justify-between">
35
+ {label && <ProgressLabel>{label}</ProgressLabel>}
36
+ {showValue && <ProgressValue />}
37
+ </div>
38
+ )}
39
+ <ProgressTrack>
40
+ <ProgressIndicator />
41
+ </ProgressTrack>
42
+ </ProgressPrimitive>
43
+ )
44
+ }
45
+
46
+ // Re-export sub-components for advanced usage
47
+ export { ProgressIndicator, ProgressLabel, ProgressTrack, ProgressValue }
48
+ export { Progress }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Opinionated RadioGroup component.
3
+ * Re-exports the primitive as the API is already clean.
4
+ *
5
+ * @example
6
+ * ```tsx
7
+ * <RadioGroup value={value} onValueChange={setValue}>
8
+ * <RadioGroupItem value="option1" />
9
+ * <RadioGroupItem value="option2" />
10
+ * </RadioGroup>
11
+ * ```
12
+ */
13
+ export { RadioGroup, RadioGroupItem } from '../_internal/radio-group'
@@ -0,0 +1,2 @@
1
+ // Re-export resizable components from ui
2
+ export { ResizableHandle, ResizablePanel, ResizablePanelGroup } from '../_internal/resizable'
@@ -0,0 +1,82 @@
1
+ import { ScrollArea as ScrollAreaPrimitive } from '@base-ui/react/scroll-area'
2
+ import { ScrollBar } from '../_internal/scroll-area'
3
+ import { cn, FOCUS_RING } from '../lib/utils'
4
+
5
+ export interface ScrollAreaProps extends ScrollAreaPrimitive.Root.Props {
6
+ /**
7
+ * Maximum height of the scroll area
8
+ * Common values: 'sm' (200px), 'md' (400px), 'lg' (600px), 'xl' (800px)
9
+ * Or provide a custom value like '50vh', '300px', etc.
10
+ */
11
+ maxHeight?: 'sm' | 'md' | 'lg' | 'xl' | string
12
+ /**
13
+ * Fixed height of the scroll area
14
+ * Overrides maxHeight if provided
15
+ */
16
+ height?: string
17
+ /**
18
+ * Show horizontal scrollbar
19
+ * @default false
20
+ */
21
+ showHorizontal?: boolean
22
+ /**
23
+ * Show vertical scrollbar
24
+ * @default true
25
+ */
26
+ showVertical?: boolean
27
+ }
28
+
29
+ const maxHeightMap = {
30
+ sm: 'max-h-[12.5rem]',
31
+ md: 'max-h-[25rem]',
32
+ lg: 'max-h-[37.5rem]',
33
+ xl: 'max-h-[50rem]',
34
+ } as const
35
+
36
+ function ScrollArea({
37
+ maxHeight,
38
+ height,
39
+ showHorizontal = false,
40
+ showVertical = true,
41
+ className,
42
+ children,
43
+ style,
44
+ ...props
45
+ }: ScrollAreaProps) {
46
+ // Determine height classes and styles
47
+ const heightClass = height
48
+ ? ''
49
+ : maxHeight && maxHeight in maxHeightMap
50
+ ? maxHeightMap[maxHeight as keyof typeof maxHeightMap]
51
+ : ''
52
+
53
+ const heightStyle = height
54
+ ? { height, ...style }
55
+ : maxHeight && !(maxHeight in maxHeightMap)
56
+ ? { maxHeight, ...style }
57
+ : style
58
+
59
+ return (
60
+ <ScrollAreaPrimitive.Root
61
+ data-slot="scroll-area"
62
+ className={cn('relative', heightClass, className)}
63
+ style={heightStyle}
64
+ {...props}
65
+ >
66
+ <ScrollAreaPrimitive.Viewport
67
+ data-slot="scroll-area-viewport"
68
+ className={`${FOCUS_RING} size-full rounded-[inherit] transition-[box-shadow] outline-none focus-visible:outline-1`}
69
+ >
70
+ {children}
71
+ </ScrollAreaPrimitive.Viewport>
72
+ {showVertical && <ScrollBar orientation="vertical" />}
73
+ {showHorizontal && <ScrollBar orientation="horizontal" />}
74
+ <ScrollAreaPrimitive.Corner />
75
+ </ScrollAreaPrimitive.Root>
76
+ )
77
+ }
78
+
79
+ // Re-export sub-components for advanced usage
80
+ export { ScrollBar } from '../_internal/scroll-area'
81
+
82
+ export { ScrollArea }
@@ -0,0 +1,101 @@
1
+ import {
2
+ SelectContent,
3
+ SelectGroup,
4
+ SelectItem,
5
+ SelectLabel,
6
+ Select as SelectPrimitive,
7
+ SelectScrollDownButton,
8
+ SelectScrollUpButton,
9
+ SelectSeparator,
10
+ SelectTrigger,
11
+ SelectValue,
12
+ } from '../_internal/select'
13
+
14
+ export interface SelectOption {
15
+ label: string
16
+ value: string
17
+ disabled?: boolean
18
+ }
19
+
20
+ export interface SelectProps {
21
+ /** Currently selected value */
22
+ value?: string
23
+ /** Callback when value changes */
24
+ onValueChange?: (value: string) => void
25
+ /** List of selectable options */
26
+ options: SelectOption[]
27
+ /** Placeholder text when no value is selected */
28
+ placeholder?: string
29
+ /** Whether the select is disabled */
30
+ disabled?: boolean
31
+ /** Additional class names for the trigger */
32
+ className?: string
33
+ /** Size variant */
34
+ size?: 'sm' | 'default'
35
+ }
36
+
37
+ /**
38
+ * Opinionated Select component with simplified options array API.
39
+ * Use for standalone dropdown selects (not form-bound).
40
+ * For form usage, see form-select.
41
+ *
42
+ * @example
43
+ * ```tsx
44
+ * const [value, setValue] = useState('')
45
+ *
46
+ * <Select
47
+ * value={value}
48
+ * onValueChange={setValue}
49
+ * options={[
50
+ * { label: 'Small', value: 'sm' },
51
+ * { label: 'Medium', value: 'md' },
52
+ * { label: 'Large', value: 'lg' },
53
+ * ]}
54
+ * placeholder="Select size"
55
+ * />
56
+ * ```
57
+ */
58
+ function Select({
59
+ value,
60
+ onValueChange,
61
+ options,
62
+ placeholder = 'Select...',
63
+ disabled = false,
64
+ className,
65
+ size = 'default',
66
+ }: SelectProps) {
67
+ return (
68
+ <SelectPrimitive
69
+ value={value}
70
+ onValueChange={(v) => {
71
+ if (v !== null) onValueChange?.(v)
72
+ }}
73
+ disabled={disabled}
74
+ >
75
+ <SelectTrigger className={className} size={size}>
76
+ <SelectValue placeholder={placeholder} />
77
+ </SelectTrigger>
78
+ <SelectContent>
79
+ {options.map((option) => (
80
+ <SelectItem key={option.value} value={option.value} disabled={option.disabled}>
81
+ {option.label}
82
+ </SelectItem>
83
+ ))}
84
+ </SelectContent>
85
+ </SelectPrimitive>
86
+ )
87
+ }
88
+
89
+ // Re-export sub-components for advanced usage
90
+ export {
91
+ SelectContent,
92
+ SelectGroup,
93
+ SelectItem,
94
+ SelectLabel,
95
+ SelectScrollDownButton,
96
+ SelectScrollUpButton,
97
+ SelectSeparator,
98
+ SelectTrigger,
99
+ SelectValue,
100
+ }
101
+ export { Select }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Opinionated Separator component.
3
+ * Re-exports the primitive as the API is already clean.
4
+ *
5
+ * @example
6
+ * ```tsx
7
+ * <Separator />
8
+ * <Separator orientation="vertical" className="h-4" />
9
+ * ```
10
+ */
11
+ export { Separator } from '../_internal/separator'