@rise-x/apps-sdk 0.9.0 → 0.11.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 (92) hide show
  1. package/README.md +116 -31
  2. package/build/rsbuild/index.d.ts +6 -1
  3. package/build/rsbuild/index.js +23 -2
  4. package/build/ui/classes.json +209 -0
  5. package/build/ui/components/ai.d.ts +33 -1
  6. package/build/ui/components/app-frame.d.ts +16 -10
  7. package/build/ui/components/chat-input.d.ts +28 -0
  8. package/build/ui/components/message-scroller.d.ts +34 -10
  9. package/build/ui/components/sheet.d.ts +10 -0
  10. package/build/ui/components/thinking-rings.d.ts +4 -0
  11. package/build/ui/demo.html +26794 -0
  12. package/build/ui/index.d.ts +2 -0
  13. package/build/ui/standalone.js +59 -58
  14. package/build/ui/styles.css +1 -1
  15. package/package.json +4 -3
  16. package/template/AGENTS.md +3 -3
  17. package/template/README.md +5 -5
  18. package/template/package.json +8 -9
  19. package/template/rsbuild.config.mts +17 -0
  20. package/template/src/App.tsx +4 -1
  21. package/template/tsconfig.json +3 -1
  22. package/build/ui/reference/README.md +0 -11
  23. package/build/ui/reference/components/accordion.tsx +0 -85
  24. package/build/ui/reference/components/ai.tsx +0 -293
  25. package/build/ui/reference/components/alert-dialog.tsx +0 -207
  26. package/build/ui/reference/components/alert.tsx +0 -112
  27. package/build/ui/reference/components/app-frame.tsx +0 -71
  28. package/build/ui/reference/components/aspect-ratio.tsx +0 -28
  29. package/build/ui/reference/components/avatar.tsx +0 -158
  30. package/build/ui/reference/components/badge.tsx +0 -160
  31. package/build/ui/reference/components/button-group.tsx +0 -77
  32. package/build/ui/reference/components/button.tsx +0 -109
  33. package/build/ui/reference/components/calendar.tsx +0 -119
  34. package/build/ui/reference/components/card.tsx +0 -144
  35. package/build/ui/reference/components/carousel.tsx +0 -248
  36. package/build/ui/reference/components/chart.tsx +0 -704
  37. package/build/ui/reference/components/checkbox.tsx +0 -44
  38. package/build/ui/reference/components/collapsible.tsx +0 -43
  39. package/build/ui/reference/components/combobox.tsx +0 -146
  40. package/build/ui/reference/components/command.tsx +0 -181
  41. package/build/ui/reference/components/context-menu.tsx +0 -243
  42. package/build/ui/reference/components/data-table.tsx +0 -650
  43. package/build/ui/reference/components/date-picker.tsx +0 -218
  44. package/build/ui/reference/components/dialog.tsx +0 -172
  45. package/build/ui/reference/components/direction.tsx +0 -22
  46. package/build/ui/reference/components/dropdown-menu.tsx +0 -245
  47. package/build/ui/reference/components/empty-state.tsx +0 -63
  48. package/build/ui/reference/components/field.tsx +0 -252
  49. package/build/ui/reference/components/file-upload.tsx +0 -116
  50. package/build/ui/reference/components/hover-card.tsx +0 -64
  51. package/build/ui/reference/components/input-group.tsx +0 -157
  52. package/build/ui/reference/components/input-otp.tsx +0 -106
  53. package/build/ui/reference/components/input.tsx +0 -86
  54. package/build/ui/reference/components/item.tsx +0 -188
  55. package/build/ui/reference/components/kbd.tsx +0 -43
  56. package/build/ui/reference/components/label.tsx +0 -19
  57. package/build/ui/reference/components/list.tsx +0 -191
  58. package/build/ui/reference/components/map.css +0 -251
  59. package/build/ui/reference/components/map.tsx +0 -294
  60. package/build/ui/reference/components/menubar.tsx +0 -275
  61. package/build/ui/reference/components/message-scroller.tsx +0 -141
  62. package/build/ui/reference/components/message.tsx +0 -177
  63. package/build/ui/reference/components/nav.tsx +0 -127
  64. package/build/ui/reference/components/navigation-menu.tsx +0 -191
  65. package/build/ui/reference/components/page-header.tsx +0 -245
  66. package/build/ui/reference/components/popover.tsx +0 -76
  67. package/build/ui/reference/components/progress.tsx +0 -31
  68. package/build/ui/reference/components/radio.tsx +0 -65
  69. package/build/ui/reference/components/resizable.tsx +0 -40
  70. package/build/ui/reference/components/scroll-area.tsx +0 -55
  71. package/build/ui/reference/components/segmented.tsx +0 -45
  72. package/build/ui/reference/components/select.tsx +0 -188
  73. package/build/ui/reference/components/separator.tsx +0 -26
  74. package/build/ui/reference/components/sheet.tsx +0 -184
  75. package/build/ui/reference/components/skeleton.tsx +0 -15
  76. package/build/ui/reference/components/slider.tsx +0 -161
  77. package/build/ui/reference/components/snackbar.tsx +0 -27
  78. package/build/ui/reference/components/sonner.tsx +0 -43
  79. package/build/ui/reference/components/spinner.tsx +0 -27
  80. package/build/ui/reference/components/statistic.tsx +0 -122
  81. package/build/ui/reference/components/stepper.tsx +0 -138
  82. package/build/ui/reference/components/switch.tsx +0 -47
  83. package/build/ui/reference/components/table.tsx +0 -246
  84. package/build/ui/reference/components/textarea.tsx +0 -28
  85. package/build/ui/reference/components/timeline.tsx +0 -101
  86. package/build/ui/reference/components/toggle-group.tsx +0 -86
  87. package/build/ui/reference/components/toggle.tsx +0 -46
  88. package/build/ui/reference/components/tooltip.tsx +0 -53
  89. package/build/ui/reference/index.ts +0 -69
  90. package/build/ui/reference/lib/utils.ts +0 -34
  91. package/template/webpack.config.js +0 -112
  92. package/template/webpack.local.config.js +0 -68
@@ -1,63 +0,0 @@
1
- import * as React from 'react';
2
-
3
- import { cn } from '@rise-x/ui/lib/utils';
4
-
5
- /*
6
- * Centred, quiet, and short. An empty state is read once and then never again,
7
- * so it earns a glyph, a line, a sub-line and at most one action — not a
8
- * bordered panel with an illustration.
9
- */
10
- function EmptyState({ className, ...props }: React.ComponentProps<'div'>) {
11
- return (
12
- <div
13
- data-slot="empty-state"
14
- className={cn('flex flex-col items-center gap-[3px] px-4 py-8 text-center', className)}
15
- {...props}
16
- />
17
- );
18
- }
19
-
20
- function EmptyStateGlyph({ className, ...props }: React.ComponentProps<'span'>) {
21
- return (
22
- <span
23
- data-slot="empty-state-glyph"
24
- className={cn(
25
- 'mb-[5px] grid size-8 place-items-center rounded-lg bg-muted text-subtle [&_svg]:size-[15px]',
26
- className,
27
- )}
28
- {...props}
29
- />
30
- );
31
- }
32
-
33
- function EmptyStateTitle({ className, ...props }: React.ComponentProps<'div'>) {
34
- return (
35
- <div
36
- data-slot="empty-state-title"
37
- className={cn('text-ui font-medium', className)}
38
- {...props}
39
- />
40
- );
41
- }
42
-
43
- function EmptyStateDescription({ className, ...props }: React.ComponentProps<'div'>) {
44
- return (
45
- <div
46
- data-slot="empty-state-description"
47
- className={cn('max-w-[42ch] text-xs text-muted-foreground', className)}
48
- {...props}
49
- />
50
- );
51
- }
52
-
53
- function EmptyStateActions({ className, ...props }: React.ComponentProps<'div'>) {
54
- return (
55
- <div
56
- data-slot="empty-state-actions"
57
- className={cn('mt-3 flex items-center gap-2', className)}
58
- {...props}
59
- />
60
- );
61
- }
62
-
63
- export { EmptyState, EmptyStateGlyph, EmptyStateTitle, EmptyStateDescription, EmptyStateActions };
@@ -1,252 +0,0 @@
1
- 'use client';
2
-
3
- import * as React from 'react';
4
- import { cva, type VariantProps } from 'class-variance-authority';
5
-
6
- import { cn } from '@rise-x/ui/lib/utils';
7
- import { Label } from '@rise-x/ui/components/label';
8
- import { Separator } from '@rise-x/ui/components/separator';
9
-
10
- /*
11
- * Form scaffolding: label + control + helper + error as ONE addressable unit,
12
- * so spacing between them is owned here and never re-invented per form.
13
- *
14
- * The error slot REPLACES the description rather than stacking under it — a
15
- * field explains itself or reports a problem, never both at once, and the row
16
- * keeps its height when validation fires.
17
- *
18
- * A FieldLabel wrapping a whole Field becomes a selectable choice card. The
19
- * checked affirmation is BRAND (border + tint), same rule as Input focus:
20
- * committing data gets brand, operating chrome gets grey.
21
- */
22
- function FieldSet({ className, ...props }: React.ComponentProps<'fieldset'>) {
23
- return (
24
- <fieldset
25
- data-slot="field-set"
26
- className={cn(
27
- 'flex flex-col gap-6',
28
- 'has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3',
29
- className,
30
- )}
31
- {...props}
32
- />
33
- );
34
- }
35
-
36
- function FieldLegend({
37
- className,
38
- variant = 'legend',
39
- ...props
40
- }: React.ComponentProps<'legend'> & { variant?: 'legend' | 'label' }) {
41
- return (
42
- <legend
43
- data-slot="field-legend"
44
- data-variant={variant}
45
- className={cn(
46
- 'mb-3 font-medium',
47
- /* legend heads a group of fields, label matches a single Label.
48
- * 17px is the scale's step above the 13px body — text-base would add a
49
- * sixth size to a documented five-size scale. */
50
- 'data-[variant=legend]:text-[17px]',
51
- 'data-[variant=label]:text-ui',
52
- className,
53
- )}
54
- {...props}
55
- />
56
- );
57
- }
58
-
59
- function FieldGroup({ className, ...props }: React.ComponentProps<'div'>) {
60
- return (
61
- <div
62
- data-slot="field-group"
63
- className={cn(
64
- 'group/field-group @container/field-group flex w-full flex-col gap-7 data-[slot=checkbox-group]:gap-3 [&>[data-slot=field-group]]:gap-4',
65
- className,
66
- )}
67
- {...props}
68
- />
69
- );
70
- }
71
-
72
- const fieldVariants = cva('group/field flex w-full gap-3 data-[invalid=true]:text-error-text', {
73
- variants: {
74
- orientation: {
75
- vertical: ['flex-col [&>*]:w-full [&>.sr-only]:w-auto'],
76
- horizontal: [
77
- 'flex-row items-center',
78
- '[&>[data-slot=field-label]]:flex-auto',
79
- 'has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px',
80
- ],
81
- responsive: [
82
- 'flex-col @md/field-group:flex-row @md/field-group:items-center [&>*]:w-full @md/field-group:[&>*]:w-auto [&>.sr-only]:w-auto',
83
- '@md/field-group:[&>[data-slot=field-label]]:flex-auto',
84
- '@md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px',
85
- ],
86
- },
87
- },
88
- defaultVariants: {
89
- orientation: 'vertical',
90
- },
91
- });
92
-
93
- function Field({
94
- className,
95
- orientation = 'vertical',
96
- ...props
97
- }: React.ComponentProps<'div'> & VariantProps<typeof fieldVariants>) {
98
- return (
99
- <div
100
- role="group"
101
- data-slot="field"
102
- data-orientation={orientation}
103
- className={cn(fieldVariants({ orientation }), className)}
104
- {...props}
105
- />
106
- );
107
- }
108
-
109
- function FieldContent({ className, ...props }: React.ComponentProps<'div'>) {
110
- return (
111
- <div
112
- data-slot="field-content"
113
- className={cn('group/field-content flex flex-1 flex-col gap-1.5 leading-snug', className)}
114
- {...props}
115
- />
116
- );
117
- }
118
-
119
- function FieldLabel({ className, ...props }: React.ComponentProps<typeof Label>) {
120
- return (
121
- <Label
122
- data-slot="field-label"
123
- className={cn(
124
- 'group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50',
125
- // wrapping a whole Field turns the label into a choice card
126
- 'has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border [&>*]:data-[slot=field]:p-4',
127
- 'has-data-[state=checked]:border-brand has-data-[state=checked]:bg-brand-tint',
128
- className,
129
- )}
130
- {...props}
131
- />
132
- );
133
- }
134
-
135
- function FieldTitle({ className, ...props }: React.ComponentProps<'div'>) {
136
- return (
137
- <div
138
- data-slot="field-label"
139
- className={cn(
140
- 'flex w-fit items-center gap-2 text-ui leading-snug font-medium group-data-[disabled=true]/field:opacity-50',
141
- className,
142
- )}
143
- {...props}
144
- />
145
- );
146
- }
147
-
148
- function FieldDescription({ className, ...props }: React.ComponentProps<'p'>) {
149
- return (
150
- <p
151
- data-slot="field-description"
152
- className={cn(
153
- // helper text is meta, one step below the label — same step as CardDescription
154
- 'text-xs leading-normal font-normal text-muted-foreground group-has-[[data-orientation=horizontal]]/field:text-balance',
155
- 'last:mt-0 nth-last-2:-mt-1 [[data-variant=legend]+&]:-mt-1.5',
156
- '[&>a]:underline [&>a]:underline-offset-3 [&>a:hover]:text-foreground',
157
- className,
158
- )}
159
- {...props}
160
- />
161
- );
162
- }
163
-
164
- function FieldSeparator({
165
- children,
166
- className,
167
- ...props
168
- }: React.ComponentProps<'div'> & {
169
- children?: React.ReactNode;
170
- }) {
171
- return (
172
- <div
173
- data-slot="field-separator"
174
- data-content={!!children}
175
- className={cn(
176
- 'relative -my-2 h-5 text-xs group-data-[variant=outline]/field-group:-mb-2',
177
- className,
178
- )}
179
- {...props}
180
- >
181
- <Separator className="absolute inset-0 top-1/2" />
182
- {children && (
183
- <span
184
- // forms sit on the card surface, so the chip masks with bg-card
185
- className="relative mx-auto block w-fit bg-card px-2 text-muted-foreground"
186
- data-slot="field-separator-content"
187
- >
188
- {children}
189
- </span>
190
- )}
191
- </div>
192
- );
193
- }
194
-
195
- function FieldError({
196
- className,
197
- children,
198
- errors,
199
- ...props
200
- }: React.ComponentProps<'div'> & {
201
- errors?: Array<{ message?: string } | undefined>;
202
- }) {
203
- const content = React.useMemo(() => {
204
- if (children) {
205
- return children;
206
- }
207
-
208
- if (!errors?.length) {
209
- return null;
210
- }
211
-
212
- const uniqueErrors = [...new Map(errors.map((error) => [error?.message, error])).values()];
213
-
214
- if (uniqueErrors?.length === 1) {
215
- return uniqueErrors[0]?.message;
216
- }
217
-
218
- return (
219
- <ul className="ml-4 flex list-disc flex-col gap-1">
220
- {uniqueErrors.map((error, index) => error?.message && <li key={index}>{error.message}</li>)}
221
- </ul>
222
- );
223
- }, [children, errors]);
224
-
225
- if (!content) {
226
- return null;
227
- }
228
-
229
- return (
230
- <div
231
- role="alert"
232
- data-slot="field-error"
233
- className={cn('text-xs font-normal text-error-text', className)}
234
- {...props}
235
- >
236
- {content}
237
- </div>
238
- );
239
- }
240
-
241
- export {
242
- Field,
243
- FieldLabel,
244
- FieldDescription,
245
- FieldError,
246
- FieldGroup,
247
- FieldLegend,
248
- FieldSeparator,
249
- FieldSet,
250
- FieldContent,
251
- FieldTitle,
252
- };
@@ -1,116 +0,0 @@
1
- import * as React from 'react';
2
-
3
- import { cn } from '@rise-x/ui/lib/utils';
4
-
5
- /*
6
- * Upload. The drop zone is DASHED when idle and turns solid brand when a file
7
- * is over it — the same empty-slot/filled grammar the filter triggers use, so
8
- * "a place something goes" looks the same everywhere in the system.
9
- */
10
- function FileDrop({
11
- className,
12
- active,
13
- ...props
14
- }: React.ComponentProps<'div'> & { active?: boolean }) {
15
- return (
16
- <div
17
- data-slot="file-drop"
18
- data-active={active ? '' : undefined}
19
- className={cn(
20
- 'rounded-xl border border-dashed border-border-strong bg-muted p-6 text-center transition-colors',
21
- active && 'border-solid border-brand bg-brand-tint',
22
- className,
23
- )}
24
- {...props}
25
- />
26
- );
27
- }
28
-
29
- function FileDropGlyph({ className, ...props }: React.ComponentProps<'span'>) {
30
- return (
31
- <span
32
- data-slot="file-drop-glyph"
33
- className={cn(
34
- 'mx-auto mb-2 grid size-8 place-items-center rounded-lg bg-card text-subtle [&>svg]:size-4',
35
- className,
36
- )}
37
- {...props}
38
- />
39
- );
40
- }
41
-
42
- /* A file CARD, not a thumbnail. Name plus type · size plus an action — a preview
43
- * image of a PDF tells you nothing that the filename doesn't. */
44
- function FileCard({
45
- className,
46
- glyph,
47
- name,
48
- meta,
49
- action,
50
- ...props
51
- }: React.ComponentProps<'div'> & {
52
- glyph?: React.ReactNode;
53
- name: React.ReactNode;
54
- meta?: React.ReactNode;
55
- action?: React.ReactNode;
56
- }) {
57
- return (
58
- <div
59
- data-slot="file-card"
60
- className={cn(
61
- 'flex items-center gap-2.5 rounded-lg border border-border bg-card px-2.5 py-2',
62
- className,
63
- )}
64
- {...props}
65
- >
66
- {glyph ? (
67
- <span className="grid size-7 shrink-0 place-items-center rounded-md bg-fill-1 text-muted-foreground [&>svg]:size-3.5">
68
- {glyph}
69
- </span>
70
- ) : null}
71
- <span className="min-w-0 flex-1">
72
- <span className="block truncate text-xs">{name}</span>
73
- {meta ? <span className="block text-micro text-subtle">{meta}</span> : null}
74
- </span>
75
- {action}
76
- </div>
77
- );
78
- }
79
-
80
- function AttachmentList({ className, ...props }: React.ComponentProps<'div'>) {
81
- return (
82
- <div
83
- data-slot="attachment-list"
84
- className={cn('flex flex-col gap-1.5', className)}
85
- {...props}
86
- />
87
- );
88
- }
89
-
90
- /* Image/media tile. Fixed square so a gallery of mixed aspect ratios still
91
- * lines up; the image is cropped rather than letterboxed. */
92
- function MediaThumb({
93
- className,
94
- size = 56,
95
- ...props
96
- }: React.ComponentProps<'div'> & { size?: number }) {
97
- return (
98
- <div
99
- data-slot="media-thumb"
100
- style={{ width: size, height: size }}
101
- className={cn(
102
- 'grid shrink-0 place-items-center overflow-hidden rounded-lg border border-border bg-muted text-subtle [&>img]:size-full [&>img]:object-cover [&>svg]:size-4',
103
- className,
104
- )}
105
- {...props}
106
- />
107
- );
108
- }
109
-
110
- function MediaGallery({ className, ...props }: React.ComponentProps<'div'>) {
111
- return (
112
- <div data-slot="media-gallery" className={cn('flex flex-wrap gap-2', className)} {...props} />
113
- );
114
- }
115
-
116
- export { FileDrop, FileDropGlyph, FileCard, AttachmentList, MediaThumb, MediaGallery };
@@ -1,64 +0,0 @@
1
- 'use client';
2
-
3
- import * as React from 'react';
4
- import { HoverCard as HoverCardPrimitive } from 'radix-ui';
5
-
6
- import { cn } from '@rise-x/ui/lib/utils';
7
-
8
- /*
9
- * A preview on hover — who a person is, what a reference points at — without
10
- * leaving the page. Same surface as Popover (14px, shadow-pop, 16px padding),
11
- * because it is the same object; only the way it opens differs.
12
- *
13
- * IT OPENS ON A DELAY AND IT IS NEVER THE ONLY PATH. 300ms in, 150ms out: opening
14
- * instantly turns every stray cursor sweep into a flash of cards, and closing
15
- * instantly makes the card impossible to move onto. Hover does not exist on touch
16
- * and is invisible to keyboard-only use, so whatever is in here must also be
17
- * reachable by clicking the thing it describes.
18
- *
19
- * NOTHING INTERACTIVE INSIDE. A hover card that holds a button asks the user to
20
- * keep the pointer inside a shape they cannot see the edges of. Use Popover for
21
- * anything with a control in it.
22
- */
23
- function HoverCard({
24
- openDelay = 300,
25
- closeDelay = 150,
26
- ...props
27
- }: React.ComponentProps<typeof HoverCardPrimitive.Root>) {
28
- return (
29
- <HoverCardPrimitive.Root
30
- data-slot="hover-card"
31
- openDelay={openDelay}
32
- closeDelay={closeDelay}
33
- {...props}
34
- />
35
- );
36
- }
37
-
38
- function HoverCardTrigger({ ...props }: React.ComponentProps<typeof HoverCardPrimitive.Trigger>) {
39
- return <HoverCardPrimitive.Trigger data-slot="hover-card-trigger" {...props} />;
40
- }
41
-
42
- function HoverCardContent({
43
- className,
44
- align = 'center',
45
- sideOffset = 4,
46
- ...props
47
- }: React.ComponentProps<typeof HoverCardPrimitive.Content>) {
48
- return (
49
- <HoverCardPrimitive.Portal>
50
- <HoverCardPrimitive.Content
51
- data-slot="hover-card-content"
52
- align={align}
53
- sideOffset={sideOffset}
54
- className={cn(
55
- 'z-50 flex w-64 origin-(--radix-hover-card-content-transform-origin) flex-col gap-2.5 rounded-xl bg-popover p-4 text-xs text-popover-foreground shadow-pop outline-hidden duration-100 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 dark:ring-foreground/10 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
56
- className,
57
- )}
58
- {...props}
59
- />
60
- </HoverCardPrimitive.Portal>
61
- );
62
- }
63
-
64
- export { HoverCard, HoverCardTrigger, HoverCardContent };
@@ -1,157 +0,0 @@
1
- 'use client';
2
-
3
- import * as React from 'react';
4
- import { cva, type VariantProps } from 'class-variance-authority';
5
-
6
- import { cn } from '@rise-x/ui/lib/utils';
7
- import { Button } from '@rise-x/ui/components/button';
8
- import { Input } from '@rise-x/ui/components/input';
9
- import { Textarea } from '@rise-x/ui/components/textarea';
10
-
11
- /*
12
- * ONE bordered container that the control and its addons share — the group
13
- * carries the field chrome (surface, border, focus ring) and the Input inside
14
- * is stripped bare, so an addon never doubles a border the way two adjacent
15
- * boxes would. Supersedes the old InputGroup/InputAffix border-merging pair.
16
- *
17
- * Focus and error live on the GROUP, driven by :has() from the control inside:
18
- * the whole object is the field, so the whole object affirms. Brand ring for
19
- * data entry, error tokens for invalid — same contract as Input itself.
20
- */
21
- function InputGroup({ className, ...props }: React.ComponentProps<'div'>) {
22
- return (
23
- <div
24
- data-slot="input-group"
25
- role="group"
26
- className={cn(
27
- 'group/input-group relative flex w-full items-center rounded-lg border border-input bg-card transition-[border-color,box-shadow] duration-100 outline-none',
28
- 'h-control min-w-0 has-[>textarea]:h-auto',
29
-
30
- // Variants based on alignment.
31
- 'has-[>[data-align=inline-start]]:[&>input]:pl-2',
32
- 'has-[>[data-align=inline-end]]:[&>input]:pr-2',
33
- 'has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-2.5',
34
- 'has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-2.5',
35
-
36
- // Focus state — the brand ring Input uses, lifted onto the group.
37
- 'has-[[data-slot=input-group-control]:focus-visible]:border-brand has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-brand/12',
38
-
39
- /* Error state. The ring needs its own width — a colour alone renders
40
- * nothing — and it is scoped to focus like Input's, with both has()
41
- * conditions stacked so it outranks the brand focus ring above rather
42
- * than racing it on source order. */
43
- 'has-[[data-slot][aria-invalid=true]]:border-error',
44
- 'has-[[data-slot][aria-invalid=true]]:has-[[data-slot=input-group-control]:focus-visible]:border-error',
45
- 'has-[[data-slot][aria-invalid=true]]:has-[[data-slot=input-group-control]:focus-visible]:ring-3',
46
- 'has-[[data-slot][aria-invalid=true]]:has-[[data-slot=input-group-control]:focus-visible]:ring-error/18',
47
-
48
- className,
49
- )}
50
- {...props}
51
- />
52
- );
53
- }
54
-
55
- const inputGroupAddonVariants = cva(
56
- // addon text matches the control text (13px), muted because it is not the value
57
- 'flex h-auto cursor-text items-center justify-center gap-2 py-1 text-ui font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>svg:not([class*="size-"])]:size-3.5',
58
- {
59
- variants: {
60
- align: {
61
- // buttons and kbds tuck into the addon padding so they sit flush
62
- 'inline-start': 'order-first pl-2.5 has-[>button]:ml-[-6px] has-[>kbd]:ml-[-5px]',
63
- 'inline-end': 'order-last pr-2.5 has-[>button]:mr-[-6px] has-[>kbd]:mr-[-5px]',
64
- 'block-start':
65
- 'order-first w-full justify-start px-2.5 pt-2.5 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2.5',
66
- 'block-end':
67
- 'order-last w-full justify-start px-2.5 pb-2.5 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2.5',
68
- },
69
- },
70
- defaultVariants: {
71
- align: 'inline-start',
72
- },
73
- },
74
- );
75
-
76
- function InputGroupAddon({
77
- className,
78
- align = 'inline-start',
79
- onClick,
80
- ...props
81
- }: React.ComponentProps<'div'> & VariantProps<typeof inputGroupAddonVariants>) {
82
- return (
83
- <div
84
- role="group"
85
- data-slot="input-group-addon"
86
- data-align={align}
87
- className={cn(inputGroupAddonVariants({ align }), className)}
88
- /* Click-to-focus runs ALONGSIDE a caller's onClick, never instead of it —
89
- * the same rule message-scroller.tsx states for onScroll. And it targets
90
- * the group's control by slot, not by tag: a textarea group is one field
91
- * too, and querying for `input` left its addons dead. */
92
- onClick={(e) => {
93
- onClick?.(e);
94
- if ((e.target as HTMLElement).closest('button')) return;
95
- e.currentTarget.parentElement
96
- ?.querySelector<HTMLElement>('[data-slot=input-group-control]')
97
- ?.focus();
98
- }}
99
- {...props}
100
- />
101
- );
102
- }
103
-
104
- /* Thin passthrough — the kit Button already has the xs / icon-xs steps an
105
- * in-field action needs, so there is no separate size scale to maintain. */
106
- function InputGroupButton({
107
- type = 'button',
108
- variant = 'ghost',
109
- size = 'xs',
110
- ...props
111
- }: React.ComponentProps<typeof Button>) {
112
- return <Button type={type} variant={variant} size={size} {...props} />;
113
- }
114
-
115
- function InputGroupText({ className, ...props }: React.ComponentProps<'span'>) {
116
- return (
117
- <span
118
- className={cn(
119
- 'flex items-center gap-2 text-ui text-muted-foreground [&_svg]:pointer-events-none [&_svg:not([class*="size-"])]:size-3.5',
120
- className,
121
- )}
122
- {...props}
123
- />
124
- );
125
- }
126
-
127
- function InputGroupInput({ className, ...props }: React.ComponentProps<'input'>) {
128
- return (
129
- <Input
130
- data-slot="input-group-control"
131
- className={cn('flex-1 rounded-none border-0 bg-transparent focus-visible:ring-0', className)}
132
- {...props}
133
- />
134
- );
135
- }
136
-
137
- function InputGroupTextarea({ className, ...props }: React.ComponentProps<'textarea'>) {
138
- return (
139
- <Textarea
140
- data-slot="input-group-control"
141
- className={cn(
142
- 'flex-1 resize-none rounded-none border-0 bg-transparent py-2.5 focus-visible:ring-0',
143
- className,
144
- )}
145
- {...props}
146
- />
147
- );
148
- }
149
-
150
- export {
151
- InputGroup,
152
- InputGroupAddon,
153
- InputGroupButton,
154
- InputGroupText,
155
- InputGroupInput,
156
- InputGroupTextarea,
157
- };