@rise-x/apps-sdk 0.6.0 → 0.8.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 (93) hide show
  1. package/README.md +192 -10
  2. package/build/connectors/agents.js +1 -1
  3. package/build/connectors/assets.d.ts +9 -3
  4. package/build/connectors/assets.js +32 -1
  5. package/build/connectors/index.d.ts +3 -2
  6. package/build/connectors/index.js +4 -1
  7. package/build/connectors/search.d.ts +34 -0
  8. package/build/connectors/search.js +63 -0
  9. package/build/connectors/types.d.ts +51 -0
  10. package/build/connectors/types.js +71 -0
  11. package/build/connectors/work.d.ts +7 -1
  12. package/build/connectors/work.js +13 -0
  13. package/build/index.d.ts +1 -1
  14. package/build/mockShell.d.ts +11 -0
  15. package/build/mockShell.js +159 -2
  16. package/build/query/assets.d.ts +19 -6
  17. package/build/query/assets.js +35 -3
  18. package/build/query/context.d.ts +14 -0
  19. package/build/query/context.js +16 -0
  20. package/build/query/index.d.ts +4 -3
  21. package/build/query/index.js +14 -2
  22. package/build/query/keys.d.ts +4 -0
  23. package/build/query/keys.js +7 -0
  24. package/build/query/layer.d.ts +25 -3
  25. package/build/query/work.d.ts +14 -1
  26. package/build/query/work.js +32 -1
  27. package/build/shellBridge.d.ts +1 -1
  28. package/build/ui/components/accordion.d.ts +7 -0
  29. package/build/ui/components/aspect-ratio.d.ts +4 -0
  30. package/build/ui/components/button-group.d.ts +7 -0
  31. package/build/ui/components/carousel.d.ts +18 -0
  32. package/build/ui/components/chart.d.ts +45 -94
  33. package/build/ui/components/collapsible.d.ts +6 -0
  34. package/build/ui/components/combobox.d.ts +19 -0
  35. package/build/ui/components/command.d.ts +18 -0
  36. package/build/ui/components/context-menu.d.ts +29 -0
  37. package/build/ui/components/data-table.d.ts +13 -2
  38. package/build/ui/components/date-picker.d.ts +16 -0
  39. package/build/ui/components/direction.d.ts +6 -0
  40. package/build/ui/components/field.d.ts +25 -0
  41. package/build/ui/components/hover-card.d.ts +6 -0
  42. package/build/ui/components/input-group.d.ts +13 -0
  43. package/build/ui/components/input-otp.d.ts +34 -0
  44. package/build/ui/components/input.d.ts +1 -3
  45. package/build/ui/components/item.d.ts +23 -0
  46. package/build/ui/components/kbd.d.ts +4 -0
  47. package/build/ui/components/menubar.d.ts +26 -0
  48. package/build/ui/components/message-scroller.d.ts +15 -0
  49. package/build/ui/components/navigation-menu.d.ts +13 -0
  50. package/build/ui/components/page-header.d.ts +7 -1
  51. package/build/ui/components/table.d.ts +7 -1
  52. package/build/ui/index.d.ts +19 -0
  53. package/build/ui/reference/components/accordion.tsx +85 -0
  54. package/build/ui/reference/components/alert-dialog.tsx +7 -2
  55. package/build/ui/reference/components/aspect-ratio.tsx +28 -0
  56. package/build/ui/reference/components/button-group.tsx +77 -0
  57. package/build/ui/reference/components/button.tsx +8 -1
  58. package/build/ui/reference/components/carousel.tsx +248 -0
  59. package/build/ui/reference/components/chart.tsx +441 -1131
  60. package/build/ui/reference/components/collapsible.tsx +43 -0
  61. package/build/ui/reference/components/combobox.tsx +141 -0
  62. package/build/ui/reference/components/command.tsx +181 -0
  63. package/build/ui/reference/components/context-menu.tsx +243 -0
  64. package/build/ui/reference/components/data-table.tsx +199 -29
  65. package/build/ui/reference/components/date-picker.tsx +218 -0
  66. package/build/ui/reference/components/dialog.tsx +2 -2
  67. package/build/ui/reference/components/direction.tsx +22 -0
  68. package/build/ui/reference/components/dropdown-menu.tsx +2 -2
  69. package/build/ui/reference/components/field.tsx +252 -0
  70. package/build/ui/reference/components/hover-card.tsx +64 -0
  71. package/build/ui/reference/components/input-group.tsx +157 -0
  72. package/build/ui/reference/components/input-otp.tsx +106 -0
  73. package/build/ui/reference/components/input.tsx +4 -32
  74. package/build/ui/reference/components/item.tsx +188 -0
  75. package/build/ui/reference/components/kbd.tsx +43 -0
  76. package/build/ui/reference/components/label.tsx +1 -1
  77. package/build/ui/reference/components/menubar.tsx +275 -0
  78. package/build/ui/reference/components/message-scroller.tsx +141 -0
  79. package/build/ui/reference/components/nav.tsx +9 -0
  80. package/build/ui/reference/components/navigation-menu.tsx +191 -0
  81. package/build/ui/reference/components/page-header.tsx +32 -0
  82. package/build/ui/reference/components/popover.tsx +2 -2
  83. package/build/ui/reference/components/select.tsx +11 -8
  84. package/build/ui/reference/components/sheet.tsx +14 -3
  85. package/build/ui/reference/components/table.tsx +15 -2
  86. package/build/ui/reference/components/timeline.tsx +7 -0
  87. package/build/ui/reference/components/toggle.tsx +1 -1
  88. package/build/ui/reference/index.ts +19 -0
  89. package/build/ui/standalone.js +167 -28
  90. package/build/ui/styles.css +1 -1
  91. package/package.json +15 -9
  92. package/template/README.md +6 -0
  93. package/template/src/App.tsx +10 -1
@@ -0,0 +1,252 @@
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
+ };
@@ -0,0 +1,64 @@
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 };
@@ -0,0 +1,157 @@
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
+ };
@@ -0,0 +1,106 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import { OTPInput, OTPInputContext } from 'input-otp';
5
+ import { MinusIcon } from 'lucide-react';
6
+
7
+ import { cn } from '@rise-x/ui/lib/utils';
8
+
9
+ /*
10
+ * One-time-code entry. A row of slots that behaves like a single field: paste
11
+ * fills every slot, backspace walks back, and the caret is drawn rather than
12
+ * native because there is no real caret to show in an empty box.
13
+ *
14
+ * IT IS ONE FIELD, SO IT TAKES ONE FOCUS TREATMENT. The active slot gets the
15
+ * brand ring — data going in, same as Input — and only the active one, because a
16
+ * row of six rings is a row of six fields.
17
+ *
18
+ * SLOTS SHARE THEIR BORDERS. Same arithmetic as InputGroup and ButtonGroup: the
19
+ * inner edge is drawn once and only the outer corners keep the radius, so a group
20
+ * of six reads as one control rather than six boxes in a row.
21
+ *
22
+ * GROUP IN THREES, NOT SIXES. A six-digit code split 3–3 is read as two chunks
23
+ * and typed more accurately than an undifferentiated run; `InputOTPSeparator` is
24
+ * what marks the split, and it is the container's, not a slot's.
25
+ */
26
+ const InputOTP = React.forwardRef<
27
+ React.ComponentRef<typeof OTPInput>,
28
+ React.ComponentProps<typeof OTPInput>
29
+ >(function InputOTP({ className, containerClassName, ...props }, ref) {
30
+ return (
31
+ <OTPInput
32
+ ref={ref}
33
+ data-slot="input-otp"
34
+ containerClassName={cn('flex items-center gap-2 has-disabled:opacity-45', containerClassName)}
35
+ className={cn('disabled:cursor-not-allowed', className)}
36
+ {...props}
37
+ />
38
+ );
39
+ });
40
+
41
+ function InputOTPGroup({ className, ...props }: React.ComponentProps<'div'>) {
42
+ return (
43
+ <div
44
+ data-slot="input-otp-group"
45
+ className={cn(
46
+ 'flex items-center',
47
+ // shared edges, outer corners only
48
+ '[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0',
49
+ '[&>*:not(:last-child)]:rounded-r-none',
50
+ className,
51
+ )}
52
+ {...props}
53
+ />
54
+ );
55
+ }
56
+
57
+ const InputOTPSlot = React.forwardRef<
58
+ HTMLDivElement,
59
+ React.ComponentProps<'div'> & { index: number }
60
+ >(function InputOTPSlot({ index, className, ...props }, ref) {
61
+ const context = React.useContext(OTPInputContext);
62
+ const slot = context?.slots[index];
63
+
64
+ return (
65
+ <div
66
+ ref={ref}
67
+ data-slot="input-otp-slot"
68
+ data-active={slot?.isActive ? '' : undefined}
69
+ className={cn(
70
+ 'relative grid h-control-lg w-9 place-items-center border border-input bg-card text-ui tabular-nums transition-[border-color,box-shadow] duration-100 first:rounded-l-lg last:rounded-r-lg',
71
+ // the active slot is the focused field, and it has to sit above its
72
+ // neighbours or the ring is clipped by the shared edge
73
+ 'data-active:z-10 data-active:border-brand data-active:ring-3 data-active:ring-brand/12',
74
+ 'aria-invalid:border-error',
75
+ className,
76
+ )}
77
+ {...props}
78
+ >
79
+ {slot?.char}
80
+ {/* a drawn caret: an empty slot has no native one to show */}
81
+ {slot?.hasFakeCaret ? (
82
+ <div className="pointer-events-none absolute inset-0 grid place-items-center">
83
+ {/* no duration utility: --animate-caret-blink already carries 1.25s,
84
+ and a duration-* would fight it rather than tune it */}
85
+ <div className="h-4 w-px animate-caret-blink bg-foreground" />
86
+ </div>
87
+ ) : null}
88
+ </div>
89
+ );
90
+ });
91
+
92
+ function InputOTPSeparator({ className, ...props }: React.ComponentProps<'div'>) {
93
+ return (
94
+ <div
95
+ data-slot="input-otp-separator"
96
+ role="separator"
97
+ aria-hidden
98
+ className={cn('grid place-items-center text-subtle [&>svg]:size-3', className)}
99
+ {...props}
100
+ >
101
+ <MinusIcon />
102
+ </div>
103
+ );
104
+ }
105
+
106
+ export { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator };
@@ -79,36 +79,8 @@ function InputAction({ className, ...props }: React.ComponentProps<'button'>) {
79
79
  );
80
80
  }
81
81
 
82
- /* Prefix / suffix affix (currency, units). Borders are shared, not doubled:
83
- * the affix drops the edge it meets so the group reads as one control. */
84
- function InputGroup({ className, ...props }: React.ComponentProps<'div'>) {
85
- return (
86
- <div
87
- data-slot="input-group"
88
- className={cn(
89
- 'flex [&>input]:rounded-none',
90
- '[&>[data-slot=input-affix]:first-child]:rounded-l-lg [&>[data-slot=input-affix]:first-child]:border-r-0',
91
- '[&>[data-slot=input-affix]:last-child]:rounded-r-lg [&>[data-slot=input-affix]:last-child]:border-l-0',
92
- '[&>[data-slot=input-affix]:first-child+input]:rounded-r-lg',
93
- '[&>input:has(+[data-slot=input-affix])]:rounded-l-lg',
94
- className,
95
- )}
96
- {...props}
97
- />
98
- );
99
- }
100
-
101
- function InputAffix({ className, ...props }: React.ComponentProps<'span'>) {
102
- return (
103
- <span
104
- data-slot="input-affix"
105
- className={cn(
106
- 'inline-flex h-control shrink-0 items-center border border-input bg-muted px-2.5 text-xs text-muted-foreground',
107
- className,
108
- )}
109
- {...props}
110
- />
111
- );
112
- }
82
+ /* The old InputGroup/InputAffix border-merging pair lived here; superseded by
83
+ * components/input-group.tsx, where the GROUP owns the field chrome and addons
84
+ * sit inside one border instead of merging two. */
113
85
 
114
- export { Input, InputNumeric, InputField, InputAction, InputGroup, InputAffix };
86
+ export { Input, InputNumeric, InputField, InputAction };