@oaiz/app-kit 0.0.0-stage → 0.1.4130

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 (107) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +149 -2
  3. package/THIRD_PARTY_NOTICES.md +76 -0
  4. package/package.json +139 -4
  5. package/registry.json +1847 -0
  6. package/src/components/activity-timeline.tsx +227 -0
  7. package/src/components/app-shell.tsx +622 -0
  8. package/src/components/bar-list.tsx +47 -0
  9. package/src/components/board.tsx +700 -0
  10. package/src/components/calendar-view.tsx +1388 -0
  11. package/src/components/card-grid.tsx +462 -0
  12. package/src/components/charts.tsx +701 -0
  13. package/src/components/chat-markdown.tsx +230 -0
  14. package/src/components/chat-panel.tsx +760 -0
  15. package/src/components/code-editor.tsx +276 -0
  16. package/src/components/collection-controls.tsx +226 -0
  17. package/src/components/command-palette.tsx +403 -0
  18. package/src/components/confirm-action.tsx +123 -0
  19. package/src/components/data-table.tsx +821 -0
  20. package/src/components/date-input.tsx +429 -0
  21. package/src/components/empty-state.tsx +31 -0
  22. package/src/components/error-state.tsx +37 -0
  23. package/src/components/file-upload.tsx +595 -0
  24. package/src/components/filter-bar.tsx +415 -0
  25. package/src/components/grouped-picker.tsx +250 -0
  26. package/src/components/line-items.tsx +601 -0
  27. package/src/components/list-view.tsx +491 -0
  28. package/src/components/metrics.tsx +53 -0
  29. package/src/components/page-header.tsx +33 -0
  30. package/src/components/property-picker.tsx +546 -0
  31. package/src/components/record-detail.tsx +416 -0
  32. package/src/components/record-form.tsx +295 -0
  33. package/src/components/record-name.tsx +85 -0
  34. package/src/components/save-bar.tsx +142 -0
  35. package/src/components/sign-in.tsx +179 -0
  36. package/src/components/split-view.tsx +128 -0
  37. package/src/components/status-dot.tsx +56 -0
  38. package/src/components/stepper.tsx +153 -0
  39. package/src/components/text-diff-model.ts +111 -0
  40. package/src/components/text-diff.tsx +98 -0
  41. package/src/components/time-zone-picker.tsx +69 -0
  42. package/src/components/ui/accordion.tsx +138 -0
  43. package/src/components/ui/alert-dialog.tsx +67 -0
  44. package/src/components/ui/alert.tsx +65 -0
  45. package/src/components/ui/avatar-group.tsx +119 -0
  46. package/src/components/ui/avatar.tsx +55 -0
  47. package/src/components/ui/badge.tsx +59 -0
  48. package/src/components/ui/bottom-navigation.tsx +102 -0
  49. package/src/components/ui/breadcrumb.tsx +117 -0
  50. package/src/components/ui/button.tsx +71 -0
  51. package/src/components/ui/card.tsx +95 -0
  52. package/src/components/ui/checkbox.tsx +31 -0
  53. package/src/components/ui/collapsible.tsx +27 -0
  54. package/src/components/ui/context-menu.tsx +270 -0
  55. package/src/components/ui/count-up.tsx +136 -0
  56. package/src/components/ui/detail-disclosure-section.tsx +109 -0
  57. package/src/components/ui/dialog.tsx +157 -0
  58. package/src/components/ui/dropdown-menu.tsx +273 -0
  59. package/src/components/ui/form-field.tsx +155 -0
  60. package/src/components/ui/heading.tsx +126 -0
  61. package/src/components/ui/hover-card.tsx +45 -0
  62. package/src/components/ui/input.tsx +50 -0
  63. package/src/components/ui/label.tsx +30 -0
  64. package/src/components/ui/orb-spinner.tsx +238 -0
  65. package/src/components/ui/popover.tsx +59 -0
  66. package/src/components/ui/progress-ring.tsx +125 -0
  67. package/src/components/ui/progress.tsx +38 -0
  68. package/src/components/ui/radio-group.tsx +124 -0
  69. package/src/components/ui/resizable.tsx +48 -0
  70. package/src/components/ui/scroll-fade.tsx +98 -0
  71. package/src/components/ui/segmented-control.tsx +70 -0
  72. package/src/components/ui/select.tsx +230 -0
  73. package/src/components/ui/separator.tsx +29 -0
  74. package/src/components/ui/sheet.tsx +170 -0
  75. package/src/components/ui/shimmer-text.tsx +87 -0
  76. package/src/components/ui/shortcut.tsx +39 -0
  77. package/src/components/ui/skeleton.tsx +15 -0
  78. package/src/components/ui/slider.tsx +48 -0
  79. package/src/components/ui/switch.tsx +44 -0
  80. package/src/components/ui/table.tsx +119 -0
  81. package/src/components/ui/tabs.tsx +80 -0
  82. package/src/components/ui/text.tsx +93 -0
  83. package/src/components/ui/textarea.tsx +51 -0
  84. package/src/components/ui/toast.tsx +141 -0
  85. package/src/components/ui/toaster.tsx +40 -0
  86. package/src/components/ui/tooltip.tsx +38 -0
  87. package/src/components/ui/top-banner.tsx +108 -0
  88. package/src/components/ui/tree-view.tsx +215 -0
  89. package/src/components/ui/use-toast.tsx +184 -0
  90. package/src/components/ui/voice-orb.tsx +252 -0
  91. package/src/hooks/oaiz-chat.tsx +530 -0
  92. package/src/hooks/oaiz-data.tsx +617 -0
  93. package/src/hooks/oaiz-session.tsx +63 -0
  94. package/src/hooks/use-arrivals.ts +19 -0
  95. package/src/hooks/use-breakpoint.ts +100 -0
  96. package/src/hooks/use-media-query.ts +36 -0
  97. package/src/hooks/use-theme.ts +67 -0
  98. package/src/hooks/use-url-state.ts +77 -0
  99. package/src/lib/breakpoints.ts +81 -0
  100. package/src/lib/csp-nonce.ts +15 -0
  101. package/src/lib/format.ts +291 -0
  102. package/src/lib/speech-level.ts +118 -0
  103. package/src/lib/utils.ts +109 -0
  104. package/src/styles/oaiz/app.css +21 -0
  105. package/src/styles/oaiz/scrollbars.css +20 -0
  106. package/src/styles/oaiz/tokens.css +952 -0
  107. package/src/styles/oaiz/voice-orb.css +39 -0
@@ -0,0 +1,238 @@
1
+ import { useId } from 'react';
2
+ import { cn } from '../../lib/utils';
3
+
4
+ export interface OrbSpinnerProps {
5
+ /** Rendered size in pixels of the square spinner. Defaults to 16. */
6
+ sizePx?: number;
7
+ /** Whether the orb rotates. Defaults to true. */
8
+ spinning?: boolean;
9
+ className?: string;
10
+ 'aria-label'?: string;
11
+ 'aria-hidden'?: boolean | 'true' | 'false';
12
+ 'data-testid'?: string;
13
+ }
14
+
15
+ const PETAL_PATH =
16
+ 'M0 4.75A4.75 4.75 0 0 1 9.5 4.75V6.015Q9.5 8.015 7.5 8.015H2Q0 8.015 0 6.015Z';
17
+ const PETALS = [
18
+ {
19
+ gradient: 'blue-lime',
20
+ transform: 'matrix(0.499998 0.866027 -0.866024 0.500002 15.2965 0)',
21
+ },
22
+ {
23
+ gradient: 'green-gold',
24
+ transform:
25
+ 'matrix(0.866025 -0.500001 0.499999 0.866026 0.000244141 8.83203)',
26
+ },
27
+ {
28
+ gradient: 'blue-cream',
29
+ transform: 'matrix(-0.866025 0.500001 -0.499999 -0.866026 24.053 15.168)',
30
+ },
31
+ {
32
+ gradient: 'warm',
33
+ transform: 'matrix(-0.499997 -0.866027 0.866024 -0.500003 8.75741 24)',
34
+ },
35
+ ];
36
+
37
+ /** A rotating four-petal gradient flower with rounded edges and a yellow centre. */
38
+ export function OrbSpinner({
39
+ sizePx = 16,
40
+ spinning = true,
41
+ className,
42
+ 'aria-label': ariaLabel = 'Loading',
43
+ 'aria-hidden': ariaHidden,
44
+ 'data-testid': dataTestId,
45
+ }: OrbSpinnerProps) {
46
+ const reactId = useId().replace(/:/g, '');
47
+ const filterId = `orb-spinner-blur-${reactId}`;
48
+ const trailFilterId = `orb-spinner-trail-${reactId}`;
49
+ const centerFilterId = `orb-spinner-center-blur-${reactId}`;
50
+ const gradientId = (name: string) => `orb-spinner-${name}-${reactId}`;
51
+ const maskId = (edge: string) => `orb-spinner-${edge}-mask-${reactId}`;
52
+ const isHidden = ariaHidden === true || ariaHidden === 'true';
53
+
54
+ return (
55
+ <span
56
+ role={isHidden ? undefined : 'status'}
57
+ aria-label={isHidden ? undefined : ariaLabel}
58
+ aria-hidden={ariaHidden}
59
+ data-testid={dataTestId}
60
+ className={cn('inline-block shrink-0', className)}
61
+ style={{ width: sizePx, height: sizePx }}
62
+ >
63
+ <svg
64
+ width={sizePx}
65
+ height={sizePx}
66
+ viewBox="0 0 29 29"
67
+ fill="none"
68
+ className={cn(
69
+ 'block overflow-visible',
70
+ spinning && 'motion-safe:animate-spin',
71
+ )}
72
+ style={{
73
+ animationDuration: '2s',
74
+ animationTimingFunction: 'var(--ease-move)',
75
+ }}
76
+ aria-hidden="true"
77
+ >
78
+ <defs>
79
+ <filter
80
+ id={filterId}
81
+ x="-35%"
82
+ y="-35%"
83
+ width="170%"
84
+ height="170%"
85
+ colorInterpolationFilters="sRGB"
86
+ >
87
+ <feGaussianBlur stdDeviation="0.75" />
88
+ <feComposite in2="SourceGraphic" operator="atop" />
89
+ </filter>
90
+ <filter
91
+ id={trailFilterId}
92
+ x="-50%"
93
+ y="-50%"
94
+ width="200%"
95
+ height="200%"
96
+ colorInterpolationFilters="sRGB"
97
+ >
98
+ <feGaussianBlur stdDeviation="1.1 0.85" />
99
+ <feOffset dx="-0.4" />
100
+ </filter>
101
+ {/* Local negative x trails each petal's clockwise movement. */}
102
+ <linearGradient
103
+ id={gradientId('trailing-alpha')}
104
+ x1="0"
105
+ x2="9.5"
106
+ gradientUnits="userSpaceOnUse"
107
+ >
108
+ <stop offset="0.45" stopOpacity="1" />
109
+ <stop offset="0.85" stopOpacity="0" />
110
+ </linearGradient>
111
+ <linearGradient
112
+ id={gradientId('leading-alpha')}
113
+ x1="0"
114
+ x2="9.5"
115
+ gradientUnits="userSpaceOnUse"
116
+ >
117
+ <stop offset="0.2" stopOpacity="0" />
118
+ <stop offset="0.7" stopOpacity="1" />
119
+ </linearGradient>
120
+ {['trailing', 'leading'].map((edge) => (
121
+ <mask
122
+ key={edge}
123
+ id={maskId(edge)}
124
+ maskUnits="userSpaceOnUse"
125
+ x="-5"
126
+ y="-5"
127
+ width="20"
128
+ height="18"
129
+ style={{ maskType: 'alpha' }}
130
+ >
131
+ <rect
132
+ x="-5"
133
+ y="-5"
134
+ width="20"
135
+ height="18"
136
+ fill={`url(#${gradientId(`${edge}-alpha`)})`}
137
+ />
138
+ </mask>
139
+ ))}
140
+ <filter
141
+ id={centerFilterId}
142
+ x="-35%"
143
+ y="-35%"
144
+ width="170%"
145
+ height="170%"
146
+ colorInterpolationFilters="sRGB"
147
+ >
148
+ <feGaussianBlur stdDeviation="0.35" />
149
+ <feComposite in2="SourceGraphic" operator="atop" />
150
+ </filter>
151
+ <linearGradient
152
+ id={gradientId('blue-lime')}
153
+ x1="9.5"
154
+ y1="4"
155
+ x2="0"
156
+ y2="4"
157
+ gradientUnits="userSpaceOnUse"
158
+ >
159
+ <stop stopColor="var(--role-orb-blue)" />
160
+ <stop offset="1" stopColor="var(--role-orb-lime)" />
161
+ </linearGradient>
162
+ <linearGradient
163
+ id={gradientId('green-gold')}
164
+ x1="4.824"
165
+ y1="0"
166
+ x2="4.824"
167
+ y2="8.015"
168
+ gradientUnits="userSpaceOnUse"
169
+ >
170
+ <stop stopColor="var(--role-orb-green)" />
171
+ <stop offset="0.293269" stopColor="var(--role-orb-lime-bright)" />
172
+ <stop offset="0.605769" stopColor="var(--role-orb-gold)" />
173
+ </linearGradient>
174
+ <linearGradient
175
+ id={gradientId('blue-cream')}
176
+ x1="4.824"
177
+ y1="8.015"
178
+ x2="4.824"
179
+ y2="0"
180
+ gradientUnits="userSpaceOnUse"
181
+ >
182
+ <stop stopColor="var(--role-orb-blue-muted)" />
183
+ <stop offset="1" stopColor="var(--role-orb-cream)" />
184
+ </linearGradient>
185
+ <radialGradient
186
+ id={gradientId('warm')}
187
+ cx="4.75"
188
+ cy="4"
189
+ r="5"
190
+ gradientUnits="userSpaceOnUse"
191
+ >
192
+ <stop stopColor="var(--role-orb-red)" />
193
+ <stop offset="0.25" stopColor="var(--role-orb-orange)" />
194
+ <stop offset="1" stopColor="var(--role-orb-amber)" />
195
+ </radialGradient>
196
+ <radialGradient
197
+ id={gradientId('center')}
198
+ cx="12.026"
199
+ cy="12"
200
+ r="4"
201
+ gradientUnits="userSpaceOnUse"
202
+ >
203
+ <stop stopColor="var(--role-orb-center-light)" />
204
+ <stop offset="1" stopColor="var(--role-orb-center)" />
205
+ </radialGradient>
206
+ </defs>
207
+
208
+ <g transform="translate(2.474 2.5)">
209
+ {PETALS.map(({ gradient, transform }) => (
210
+ <g key={gradient} transform={transform}>
211
+ {spinning && (
212
+ <path
213
+ d={PETAL_PATH}
214
+ fill={`url(#${gradientId(gradient)})`}
215
+ filter={`url(#${trailFilterId})`}
216
+ mask={`url(#${maskId('trailing')})`}
217
+ />
218
+ )}
219
+ <path
220
+ d={PETAL_PATH}
221
+ fill={`url(#${gradientId(gradient)})`}
222
+ filter={`url(#${filterId})`}
223
+ mask={spinning ? `url(#${maskId('leading')})` : undefined}
224
+ />
225
+ </g>
226
+ ))}
227
+ <circle
228
+ cx="12.026"
229
+ cy="12"
230
+ r="4"
231
+ fill={`url(#${gradientId('center')})`}
232
+ filter={`url(#${centerFilterId})`}
233
+ />
234
+ </g>
235
+ </svg>
236
+ </span>
237
+ );
238
+ }
@@ -0,0 +1,59 @@
1
+ import * as React from 'react';
2
+ import * as PopoverPrimitive from '@radix-ui/react-popover';
3
+
4
+ import { cn, usePointerCloseFocus } from '../../lib/utils';
5
+
6
+ const Popover = PopoverPrimitive.Root;
7
+
8
+ const PopoverTrigger = PopoverPrimitive.Trigger;
9
+
10
+ const PopoverAnchor = PopoverPrimitive.Anchor;
11
+
12
+ const PopoverContent = React.forwardRef<
13
+ React.ElementRef<typeof PopoverPrimitive.Content>,
14
+ React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>
15
+ >(
16
+ (
17
+ {
18
+ className,
19
+ align = 'center',
20
+ sideOffset = 4,
21
+ onPointerDownCapture,
22
+ onClickCapture,
23
+ onKeyDownCapture,
24
+ onEscapeKeyDown,
25
+ onPointerDownOutside,
26
+ onCloseAutoFocus,
27
+ ...props
28
+ },
29
+ ref,
30
+ ) => {
31
+ const pointerCloseFocus = usePointerCloseFocus({
32
+ onPointerDownCapture,
33
+ onClickCapture,
34
+ onKeyDownCapture,
35
+ onEscapeKeyDown,
36
+ onPointerDownOutside,
37
+ onCloseAutoFocus,
38
+ });
39
+
40
+ return (
41
+ <PopoverPrimitive.Portal>
42
+ <PopoverPrimitive.Content
43
+ ref={ref}
44
+ align={align}
45
+ sideOffset={sideOffset}
46
+ className={cn(
47
+ 'z-50 w-72 rounded-md border bg-popover p-inset text-popover-foreground shadow-md outline-none duration-fast ease-enter data-[state=closed]:ease-exit data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-popover-content-transform-origin]',
48
+ className,
49
+ )}
50
+ {...pointerCloseFocus}
51
+ {...props}
52
+ />
53
+ </PopoverPrimitive.Portal>
54
+ );
55
+ },
56
+ );
57
+ PopoverContent.displayName = PopoverPrimitive.Content.displayName;
58
+
59
+ export { Popover, PopoverTrigger, PopoverAnchor, PopoverContent };
@@ -0,0 +1,125 @@
1
+ import * as React from 'react';
2
+ import { cva, type VariantProps } from 'class-variance-authority';
3
+
4
+ import { cn } from '../../lib/utils';
5
+ import { Text } from './text';
6
+
7
+ const progressRingVariants = cva(
8
+ 'relative inline-flex shrink-0 items-center justify-center',
9
+ {
10
+ variants: {
11
+ size: {
12
+ sm: 'size-10',
13
+ md: 'size-16',
14
+ lg: 'size-24',
15
+ },
16
+ tone: {
17
+ default: 'text-primary',
18
+ success: 'text-success',
19
+ warning: 'text-warning',
20
+ destructive: 'text-destructive',
21
+ },
22
+ },
23
+ defaultVariants: { size: 'md', tone: 'default' },
24
+ },
25
+ );
26
+
27
+ const VALUE_SIZE = { sm: '2xs', md: 'sm', lg: 'lg' } as const;
28
+ const STROKE = { sm: 4, md: 6, lg: 8 } as const;
29
+
30
+ export interface ProgressRingProps
31
+ extends
32
+ Omit<React.HTMLAttributes<HTMLDivElement>, 'children'>,
33
+ VariantProps<typeof progressRingVariants> {
34
+ value: number;
35
+ max?: number;
36
+ /** What the ring measures, such as "Quarterly target"; it names the progress bar. */
37
+ label: string;
38
+ /** Writes the value in the middle; the percentage when omitted. */
39
+ formatValue?: (value: number, max: number) => string;
40
+ /** Leaves the middle empty, for a ring beside its own figure. */
41
+ hideValue?: boolean;
42
+ }
43
+
44
+ /**
45
+ * Progress towards a goal as a ring with the value in the middle: a target, a quota or how much
46
+ * of a checklist is done. A change of value sweeps the ring; reduced motion shows it at once.
47
+ */
48
+ const ProgressRing = React.forwardRef<HTMLDivElement, ProgressRingProps>(
49
+ (
50
+ {
51
+ value,
52
+ max = 100,
53
+ label,
54
+ formatValue,
55
+ hideValue = false,
56
+ size,
57
+ tone,
58
+ className,
59
+ ...props
60
+ },
61
+ ref,
62
+ ) => {
63
+ const scale = size ?? 'md';
64
+ const share = max > 0 ? Math.min(1, Math.max(0, value / max)) : 0;
65
+ const stroke = STROKE[scale];
66
+ const radius = 50 - stroke / 2;
67
+ const circumference = 2 * Math.PI * radius;
68
+ const shown = formatValue
69
+ ? formatValue(value, max)
70
+ : `${Math.round(share * 100)}%`;
71
+ return (
72
+ <div
73
+ ref={ref}
74
+ role="progressbar"
75
+ aria-label={label}
76
+ aria-valuemin={0}
77
+ aria-valuemax={max}
78
+ aria-valuenow={value}
79
+ aria-valuetext={shown}
80
+ className={cn(progressRingVariants({ size, tone }), className)}
81
+ {...props}
82
+ >
83
+ <svg
84
+ viewBox="0 0 100 100"
85
+ className="absolute inset-0 -rotate-90"
86
+ aria-hidden="true"
87
+ >
88
+ <circle
89
+ cx="50"
90
+ cy="50"
91
+ r={radius}
92
+ fill="none"
93
+ strokeWidth={stroke}
94
+ className="stroke-muted"
95
+ />
96
+ <circle
97
+ cx="50"
98
+ cy="50"
99
+ r={radius}
100
+ fill="none"
101
+ stroke="currentColor"
102
+ strokeWidth={stroke}
103
+ strokeLinecap="round"
104
+ strokeDasharray={circumference}
105
+ strokeDashoffset={circumference * (1 - share)}
106
+ className="transition-[stroke-dashoffset] duration-slow ease-move"
107
+ />
108
+ </svg>
109
+ {!hideValue && (
110
+ <Text
111
+ as="span"
112
+ size={VALUE_SIZE[scale]}
113
+ weight="semibold"
114
+ className="relative tabular-nums"
115
+ >
116
+ {shown}
117
+ </Text>
118
+ )}
119
+ </div>
120
+ );
121
+ },
122
+ );
123
+ ProgressRing.displayName = 'ProgressRing';
124
+
125
+ export { ProgressRing, progressRingVariants };
@@ -0,0 +1,38 @@
1
+ import * as React from 'react';
2
+ import * as ProgressPrimitive from '@radix-ui/react-progress';
3
+
4
+ import { cn } from '../../lib/utils';
5
+
6
+ interface ProgressProps extends React.ComponentPropsWithoutRef<
7
+ typeof ProgressPrimitive.Root
8
+ > {
9
+ /** Colours the filled part, for a meter whose fill carries meaning. */
10
+ indicatorClassName?: string;
11
+ }
12
+
13
+ const Progress = React.forwardRef<
14
+ React.ElementRef<typeof ProgressPrimitive.Root>,
15
+ ProgressProps
16
+ >(({ className, indicatorClassName, value, max = 100, ...props }, ref) => (
17
+ <ProgressPrimitive.Root
18
+ ref={ref}
19
+ value={value}
20
+ max={max}
21
+ className={cn(
22
+ 'relative h-4 w-full overflow-hidden rounded-full bg-secondary',
23
+ className,
24
+ )}
25
+ {...props}
26
+ >
27
+ <ProgressPrimitive.Indicator
28
+ className={cn(
29
+ 'h-full w-full flex-1 bg-primary transition-transform duration-slow ease-move',
30
+ indicatorClassName,
31
+ )}
32
+ style={{ transform: `translateX(-${100 - ((value ?? 0) / max) * 100}%)` }}
33
+ />
34
+ </ProgressPrimitive.Root>
35
+ ));
36
+ Progress.displayName = ProgressPrimitive.Root.displayName;
37
+
38
+ export { Progress };
@@ -0,0 +1,124 @@
1
+ import { useId, type ReactNode } from 'react';
2
+ import { cn } from '../../lib/utils';
3
+ import { FieldGroup } from './form-field';
4
+ import { Text } from './text';
5
+
6
+ export interface RadioOption {
7
+ value: string;
8
+ label: ReactNode;
9
+ description?: ReactNode;
10
+ disabled?: boolean;
11
+ }
12
+ export interface RadioGroupProps {
13
+ label: ReactNode;
14
+ name?: string;
15
+ value: string;
16
+ onValueChange: (value: string) => void;
17
+ options: readonly RadioOption[];
18
+ description?: ReactNode;
19
+ error?: ReactNode;
20
+ required?: boolean;
21
+ requiredLabel?: string;
22
+ disabled?: boolean;
23
+ className?: string;
24
+ optionClassName?: string;
25
+ }
26
+
27
+ export function RadioGroup({
28
+ label,
29
+ name,
30
+ value,
31
+ onValueChange,
32
+ options,
33
+ description,
34
+ error,
35
+ required = false,
36
+ requiredLabel = 'required',
37
+ disabled,
38
+ className,
39
+ optionClassName,
40
+ }: RadioGroupProps) {
41
+ const id = useId();
42
+ return (
43
+ <FieldGroup
44
+ legend={
45
+ <>
46
+ {label}
47
+ {required && (
48
+ <span className="ml-1 text-xs font-normal text-muted-foreground">
49
+ ({requiredLabel})
50
+ </span>
51
+ )}
52
+ </>
53
+ }
54
+ description={description}
55
+ disabled={disabled}
56
+ className={className}
57
+ >
58
+ <div className="grid gap-inline">
59
+ {options.map((option, index) => (
60
+ <label
61
+ key={option.value}
62
+ className={cn(
63
+ 'flex min-h-9 cursor-pointer items-start gap-inline rounded-md p-inline has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-ring has-[:disabled]:cursor-not-allowed has-[:disabled]:opacity-50',
64
+ optionClassName,
65
+ )}
66
+ >
67
+ <input
68
+ type="radio"
69
+ name={name ?? id}
70
+ value={option.value}
71
+ checked={value === option.value}
72
+ disabled={disabled === true || option.disabled === true}
73
+ required={required}
74
+ aria-labelledby={`${id}-${index}-label`}
75
+ aria-invalid={error ? true : undefined}
76
+ aria-describedby={
77
+ [
78
+ option.description ? `${id}-${index}-description` : undefined,
79
+ error ? `${id}-error` : undefined,
80
+ ]
81
+ .filter(Boolean)
82
+ .join(' ') || undefined
83
+ }
84
+ onChange={() => onValueChange(option.value)}
85
+ className="mt-0.5 size-4 shrink-0 accent-primary"
86
+ />
87
+ <span className="flex min-w-0 flex-col gap-1">
88
+ <span id={`${id}-${index}-label`} className="text-sm font-medium">
89
+ {option.label}
90
+ </span>
91
+ {option.description && (
92
+ <Text
93
+ as="span"
94
+ id={`${id}-${index}-description`}
95
+ size="sm"
96
+ variant="muted"
97
+ >
98
+ {option.description}
99
+ </Text>
100
+ )}
101
+ </span>
102
+ </label>
103
+ ))}
104
+ </div>
105
+ {error && (
106
+ <Text id={`${id}-error`} size="sm" variant="destructive">
107
+ {error}
108
+ </Text>
109
+ )}
110
+ </FieldGroup>
111
+ );
112
+ }
113
+
114
+ export function ChoiceCards(props: RadioGroupProps) {
115
+ return (
116
+ <RadioGroup
117
+ {...props}
118
+ optionClassName={cn(
119
+ 'border border-input bg-background p-inset has-[:checked]:border-primary has-[:checked]:bg-accent',
120
+ props.optionClassName,
121
+ )}
122
+ />
123
+ );
124
+ }
@@ -0,0 +1,48 @@
1
+ import {
2
+ Group,
3
+ Panel,
4
+ Separator,
5
+ type PanelImperativeHandle,
6
+ } from 'react-resizable-panels';
7
+
8
+ import { cn } from '../../lib/utils';
9
+
10
+ const ResizablePanelGroup = ({
11
+ className,
12
+ ...props
13
+ }: React.ComponentProps<typeof Group>) => (
14
+ <Group className={cn('relative flex h-full w-full', className)} {...props} />
15
+ );
16
+
17
+ const ResizablePanel = Panel;
18
+
19
+ const ResizableHandle = ({
20
+ withHandle,
21
+ className,
22
+ ...props
23
+ }: React.ComponentProps<typeof Separator> & {
24
+ withHandle?: boolean;
25
+ }) => (
26
+ <Separator
27
+ className={cn(
28
+ 'group relative flex w-px items-center justify-center bg-transparent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:-translate-y-1/2 aria-[orientation=horizontal]:after:translate-x-0 [&[aria-orientation=horizontal]>div]:rotate-90',
29
+ className,
30
+ )}
31
+ {...props}
32
+ >
33
+ {withHandle && (
34
+ <div className="pointer-events-none absolute left-1/2 z-10 flex h-10 w-4 -translate-x-[45%] flex-col items-center justify-center gap-0.5 rounded-full border border-border/40 bg-muted/60 [clip-path:inset(0_0_0_50%)] transition-colors group-hover:bg-muted group-hover:border-border/60">
35
+ <span className="h-1 w-1 translate-x-0.5 rounded-full bg-muted-foreground/70" />
36
+ <span className="h-1 w-1 translate-x-0.5 rounded-full bg-muted-foreground/70" />
37
+ <span className="h-1 w-1 translate-x-0.5 rounded-full bg-muted-foreground/70" />
38
+ </div>
39
+ )}
40
+ </Separator>
41
+ );
42
+
43
+ export {
44
+ ResizablePanelGroup,
45
+ ResizablePanel,
46
+ ResizableHandle,
47
+ type PanelImperativeHandle,
48
+ };