@oaiz/app-kit 0.0.0-stage → 0.1.4128

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 +143 -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,153 @@
1
+ import { Check } from 'lucide-react';
2
+
3
+ import { cn } from '../lib/utils';
4
+ import { Button } from './ui/button';
5
+ import { Progress } from './ui/progress';
6
+ import { Text } from './ui/text';
7
+
8
+ /** A step's indicator and label; a done step's button and a plain step take the same room. */
9
+ const ITEM = 'flex h-auto min-h-11 min-w-0 flex-1 items-center justify-start gap-inline whitespace-normal px-1 py-0.5 text-left mobile:min-h-8 mobile:flex-initial';
10
+
11
+ export type StepperStep = { key: string; label: string };
12
+
13
+ export type StepperProps = {
14
+ steps: readonly StepperStep[];
15
+ /** The key of the step on screen. Steps before it are done, steps after it are upcoming. */
16
+ current: string;
17
+ /** Makes each done step a button that returns to it. */
18
+ onStepSelect?: (key: string) => void;
19
+ /** The name of the list for a screen reader. */
20
+ label?: string;
21
+ className?: string;
22
+ /** True only after the final step has been submitted successfully. */
23
+ complete?: boolean;
24
+ messages?: {
25
+ position?: (step: number, total: number) => string;
26
+ done?: string;
27
+ completed?: string;
28
+ };
29
+ };
30
+
31
+ /**
32
+ * The steps of a form in several parts: done, current and upcoming, as an ordered list with
33
+ * `aria-current="step"`. A phone stacks the steps below a progress summary.
34
+ */
35
+ export function Stepper({
36
+ steps,
37
+ current,
38
+ onStepSelect,
39
+ label = 'Steps',
40
+ className,
41
+ complete = false,
42
+ messages,
43
+ }: StepperProps) {
44
+ const at = Math.max(
45
+ 0,
46
+ steps.findIndex((step) => step.key === current),
47
+ );
48
+ const currentStep = steps[at];
49
+ const position =
50
+ messages?.position?.(at + 1, steps.length) ??
51
+ `Step ${at + 1} of ${steps.length}`;
52
+ if (steps.length === 0) return null;
53
+
54
+ return (
55
+ <nav aria-label={label} className={cn('min-w-0 space-y-inline', className)}>
56
+ <div className="flex flex-col gap-inline mobile:hidden">
57
+ <Text size="sm" variant="muted">
58
+ {complete ? (messages?.completed ?? 'Completed') : position}
59
+ {currentStep && (
60
+ <>
61
+ {' · '}
62
+ <Text as="span" size="sm" weight="medium">
63
+ {currentStep.label}
64
+ </Text>
65
+ </>
66
+ )}
67
+ </Text>
68
+ <Progress
69
+ value={complete ? 100 : (at / steps.length) * 100}
70
+ aria-label={label}
71
+ getValueLabel={() =>
72
+ complete ? (messages?.completed ?? 'Completed') : position
73
+ }
74
+ className="h-1"
75
+ />
76
+ </div>
77
+ <ol className="flex flex-col gap-inline mobile:flex-row mobile:flex-wrap mobile:items-center">
78
+ {steps.map((step, index) => {
79
+ const state =
80
+ complete || index < at
81
+ ? 'done'
82
+ : index === at
83
+ ? 'current'
84
+ : 'upcoming';
85
+ const content = (
86
+ <>
87
+ <span
88
+ aria-hidden="true"
89
+ className={cn(
90
+ 'flex size-6 shrink-0 items-center justify-center rounded-full border text-xs font-medium tabular-nums transition-colors duration-normal ease-move [&_svg]:size-3.5',
91
+ state === 'done' &&
92
+ 'border-primary bg-primary text-primary-foreground',
93
+ state === 'current' &&
94
+ 'border-primary text-foreground ring-2 ring-primary/20',
95
+ state === 'upcoming' && 'text-muted-foreground',
96
+ )}
97
+ >
98
+ {state === 'done' ? <Check strokeWidth={3} /> : index + 1}
99
+ </span>
100
+ <Text
101
+ as="span"
102
+ size="sm"
103
+ weight={state === 'current' ? 'medium' : 'normal'}
104
+ variant={state === 'upcoming' ? 'muted' : 'default'}
105
+ className="min-w-0 [overflow-wrap:anywhere]"
106
+ >
107
+ {step.label}
108
+ </Text>
109
+ {state === 'done' && (
110
+ <span className="sr-only">, {messages?.done ?? 'done'}</span>
111
+ )}
112
+ </>
113
+ );
114
+ return (
115
+ <li
116
+ key={step.key}
117
+ aria-current={state === 'current' ? 'step' : undefined}
118
+ className={cn(
119
+ 'flex min-w-0 items-center gap-inline',
120
+ index < steps.length - 1 && 'mobile:flex-1',
121
+ )}
122
+ >
123
+ {state === 'done' && onStepSelect ? (
124
+ <Button
125
+ type="button"
126
+ variant="plain"
127
+ onClick={() => onStepSelect(step.key)}
128
+ className={cn(
129
+ ITEM,
130
+ 'rounded-md transition-colors duration-fast ease-move hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
131
+ )}
132
+ >
133
+ {content}
134
+ </Button>
135
+ ) : (
136
+ <span className={ITEM}>{content}</span>
137
+ )}
138
+ {index < steps.length - 1 && (
139
+ <span
140
+ aria-hidden="true"
141
+ className={cn(
142
+ 'hidden h-px min-w-4 flex-1 transition-colors duration-normal ease-move mobile:block',
143
+ index < at ? 'bg-primary' : 'bg-border',
144
+ )}
145
+ />
146
+ )}
147
+ </li>
148
+ );
149
+ })}
150
+ </ol>
151
+ </nav>
152
+ );
153
+ }
@@ -0,0 +1,111 @@
1
+ export type TextDiffLine = {
2
+ type: 'equal' | 'insert' | 'delete';
3
+ text: string;
4
+ };
5
+
6
+ export type TextDiffResult =
7
+ | { status: 'too-large' }
8
+ | { status: 'ready'; lines: TextDiffLine[]; added: number; removed: number };
9
+
10
+ export const TEXT_DIFF_LIMITS = {
11
+ characters: 100_000,
12
+ lines: 2_000,
13
+ comparisons: 1_000_000,
14
+ } as const;
15
+
16
+ /** A bounded line comparison; callers render the explicit limit state. */
17
+ export function compareText(before: string, after: string): TextDiffResult {
18
+ if (
19
+ before.length > TEXT_DIFF_LIMITS.characters ||
20
+ after.length > TEXT_DIFF_LIMITS.characters
21
+ )
22
+ return { status: 'too-large' };
23
+
24
+ const left = before === '' ? [] : before.split('\n');
25
+ const right = after === '' ? [] : after.split('\n');
26
+ if (
27
+ left.length > TEXT_DIFF_LIMITS.lines ||
28
+ right.length > TEXT_DIFF_LIMITS.lines
29
+ ) {
30
+ return { status: 'too-large' };
31
+ }
32
+ let start = 0;
33
+ while (
34
+ start < left.length &&
35
+ start < right.length &&
36
+ left[start] === right[start]
37
+ )
38
+ start++;
39
+ let leftEnd = left.length;
40
+ let rightEnd = right.length;
41
+ while (
42
+ leftEnd > start &&
43
+ rightEnd > start &&
44
+ left[leftEnd - 1] === right[rightEnd - 1]
45
+ ) {
46
+ leftEnd--;
47
+ rightEnd--;
48
+ }
49
+ const n = leftEnd - start;
50
+ const m = rightEnd - start;
51
+ if ((n + 1) * (m + 1) > TEXT_DIFF_LIMITS.comparisons)
52
+ return { status: 'too-large' };
53
+
54
+ const lcs = Array.from({ length: n + 1 }, () => new Uint16Array(m + 1));
55
+ for (let i = n - 1; i >= 0; i--) {
56
+ for (let j = m - 1; j >= 0; j--) {
57
+ lcs[i]![j] =
58
+ left[start + i] === right[start + j]
59
+ ? lcs[i + 1]![j + 1]! + 1
60
+ : Math.max(lcs[i + 1]![j]!, lcs[i]![j + 1]!);
61
+ }
62
+ }
63
+ const lines: TextDiffLine[] = left
64
+ .slice(0, start)
65
+ .map((text) => ({ type: 'equal', text }));
66
+ let i = 0;
67
+ let j = 0;
68
+ let added = 0;
69
+ let removed = 0;
70
+ while (i < n || j < m) {
71
+ if (i < n && j < m && left[start + i] === right[start + j]) {
72
+ lines.push({ type: 'equal', text: left[start + i++]! });
73
+ j++;
74
+ } else if (i < n && (j === m || lcs[i + 1]![j]! >= lcs[i]![j + 1]!)) {
75
+ lines.push({ type: 'delete', text: left[start + i++]! });
76
+ removed++;
77
+ } else {
78
+ lines.push({ type: 'insert', text: right[start + j++]! });
79
+ added++;
80
+ }
81
+ }
82
+ lines.push(
83
+ ...left.slice(leftEnd).map((text) => ({ type: 'equal' as const, text })),
84
+ );
85
+ return { status: 'ready', lines, added, removed };
86
+ }
87
+
88
+ /** Keep three surrounding lines and explicitly mark every omitted range. */
89
+ export function compactTextDiff(
90
+ lines: TextDiffLine[],
91
+ ): (TextDiffLine | { type: 'gap'; count: number })[] {
92
+ const changes = lines.flatMap((line, index) =>
93
+ line.type === 'equal' ? [] : [index],
94
+ );
95
+ if (changes.length === 0) return lines;
96
+ const visible = new Set<number>();
97
+ for (const index of changes) {
98
+ for (let offset = -3; offset <= 3; offset++) visible.add(index + offset);
99
+ }
100
+ const result: (TextDiffLine | { type: 'gap'; count: number })[] = [];
101
+ let omitted = 0;
102
+ for (let index = 0; index < lines.length; index++) {
103
+ if (visible.has(index)) {
104
+ if (omitted) result.push({ type: 'gap', count: omitted });
105
+ omitted = 0;
106
+ result.push(lines[index]!);
107
+ } else omitted++;
108
+ }
109
+ if (omitted) result.push({ type: 'gap', count: omitted });
110
+ return result;
111
+ }
@@ -0,0 +1,98 @@
1
+ import { useMemo } from 'react';
2
+ import { cn } from '../lib/utils';
3
+ import { Alert, AlertDescription } from './ui/alert';
4
+ import { Text } from './ui/text';
5
+ import { compareText, compactTextDiff } from './text-diff-model';
6
+
7
+ export type TextDiffProps = {
8
+ before: string;
9
+ after: string;
10
+ label: string;
11
+ /** Show three lines around each change and name omitted ranges. */
12
+ compact?: boolean;
13
+ className?: string;
14
+ labels?: {
15
+ summary?: (added: number, removed: number) => string;
16
+ unchanged?: string;
17
+ tooLarge?: string;
18
+ omitted?: (count: number) => string;
19
+ added?: string;
20
+ removed?: string;
21
+ };
22
+ };
23
+
24
+ /** Text-only change presentation; neither input is interpreted as markup. */
25
+ export function TextDiff({
26
+ before,
27
+ after,
28
+ label,
29
+ compact = true,
30
+ className,
31
+ labels,
32
+ }: TextDiffProps) {
33
+ const result = useMemo(() => compareText(before, after), [before, after]);
34
+ if (result.status === 'too-large')
35
+ return (
36
+ <Alert variant="warning">
37
+ <AlertDescription>
38
+ {labels?.tooLarge ??
39
+ 'This comparison is too large. Compare a smaller section.'}
40
+ </AlertDescription>
41
+ </Alert>
42
+ );
43
+ const lines = compact ? compactTextDiff(result.lines) : result.lines;
44
+ return (
45
+ <div className={cn('min-w-0 space-y-inline', className)}>
46
+ <Text size="sm" variant="muted">
47
+ {result.added || result.removed
48
+ ? (labels?.summary?.(result.added, result.removed) ??
49
+ `${result.added} added, ${result.removed} removed`)
50
+ : (labels?.unchanged ?? 'No changes')}
51
+ </Text>
52
+ <div
53
+ role="region"
54
+ aria-label={label}
55
+ tabIndex={0}
56
+ className="max-h-96 overflow-auto rounded-md border focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
57
+ >
58
+ <div className="min-w-full w-max whitespace-pre py-inline font-mono text-sm">
59
+ {lines.map((line, index) =>
60
+ line.type === 'gap' ? (
61
+ <div key={index} className="px-inset text-muted-foreground">
62
+ {labels?.omitted?.(line.count) ??
63
+ `… ${line.count} unchanged lines …`}
64
+ </div>
65
+ ) : (
66
+ <div
67
+ key={index}
68
+ className={cn(
69
+ 'flex px-inset',
70
+ line.type === 'insert' &&
71
+ 'bg-success-bg-subtle text-success-text',
72
+ line.type === 'delete' &&
73
+ 'bg-destructive-bg-subtle text-destructive-text',
74
+ )}
75
+ >
76
+ <span aria-hidden="true" className="w-6 shrink-0 select-none">
77
+ {line.type === 'insert'
78
+ ? '+'
79
+ : line.type === 'delete'
80
+ ? '−'
81
+ : ' '}
82
+ </span>
83
+ {line.type !== 'equal' && (
84
+ <span className="sr-only">
85
+ {line.type === 'insert'
86
+ ? (labels?.added ?? 'Added: ')
87
+ : (labels?.removed ?? 'Removed: ')}
88
+ </span>
89
+ )}
90
+ <code>{line.text || ' '}</code>
91
+ </div>
92
+ ),
93
+ )}
94
+ </div>
95
+ </div>
96
+ </div>
97
+ );
98
+ }
@@ -0,0 +1,69 @@
1
+ import { useMemo } from 'react';
2
+ import { PropertyPicker, type PropertyPickerLabels } from './property-picker';
3
+
4
+ export type TimeZonePickerProps = {
5
+ label: string;
6
+ value: string | null;
7
+ onChange: (timeZone: string) => void;
8
+ disabled?: boolean;
9
+ locale?: string;
10
+ /** The instant whose offsets are displayed; defaults to the time the picker mounts. */
11
+ at?: Date;
12
+ /** Restricts the offered IANA zones, for example to an organization's locations. */
13
+ zones?: readonly string[];
14
+ labels?: Partial<PropertyPickerLabels>;
15
+ className?: string;
16
+ };
17
+
18
+ /** Search IANA identifiers and their offset at an explicit instant. The caller owns the chosen zone. */
19
+ export function TimeZonePicker({
20
+ label,
21
+ value,
22
+ onChange,
23
+ disabled,
24
+ locale,
25
+ at,
26
+ zones,
27
+ labels,
28
+ className,
29
+ }: TimeZonePickerProps) {
30
+ const mountedAt = useMemo(() => new Date(), []);
31
+ const instant = at ?? mountedAt;
32
+ const options = useMemo(() => {
33
+ const supported =
34
+ zones ??
35
+ (
36
+ Intl as typeof Intl & {
37
+ supportedValuesOf: (key: 'timeZone') => string[];
38
+ }
39
+ ).supportedValuesOf('timeZone');
40
+ const identifiers = [
41
+ ...new Set(['UTC', ...supported, ...(value ? [value] : [])]),
42
+ ];
43
+ return identifiers.map((zone) => {
44
+ const offset = new Intl.DateTimeFormat(locale, {
45
+ timeZone: zone,
46
+ timeZoneName: 'shortOffset',
47
+ })
48
+ .formatToParts(instant)
49
+ .find((part) => part.type === 'timeZoneName')?.value;
50
+ return {
51
+ value: zone,
52
+ label: offset ? `${zone} (${offset})` : zone,
53
+ keywords: [zone.replaceAll('_', ' ')],
54
+ };
55
+ });
56
+ }, [zones, value, locale, instant]);
57
+ return (
58
+ <PropertyPicker
59
+ label={label}
60
+ value={value}
61
+ onChange={onChange}
62
+ options={options}
63
+ disabled={disabled}
64
+ labels={labels}
65
+ variant="row"
66
+ className={className}
67
+ />
68
+ );
69
+ }
@@ -0,0 +1,138 @@
1
+ import * as React from 'react';
2
+ import * as AccordionPrimitive from '@radix-ui/react-accordion';
3
+ import { ChevronRight } from 'lucide-react';
4
+
5
+ import { cn } from '../../lib/utils';
6
+ import { Heading } from './heading';
7
+ import { Text } from './text';
8
+
9
+ const Accordion = AccordionPrimitive.Root;
10
+
11
+ const AccordionItem = React.forwardRef<
12
+ React.ElementRef<typeof AccordionPrimitive.Item>,
13
+ React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>
14
+ >(({ className, ...props }, ref) => (
15
+ <AccordionPrimitive.Item
16
+ ref={ref}
17
+ className={cn('border-b border-border', className)}
18
+ {...props}
19
+ />
20
+ ));
21
+ AccordionItem.displayName = AccordionPrimitive.Item.displayName;
22
+
23
+ const AccordionHeader = React.forwardRef<
24
+ React.ElementRef<typeof AccordionPrimitive.Header>,
25
+ React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Header>
26
+ >(({ className, ...props }, ref) => (
27
+ <AccordionPrimitive.Header
28
+ ref={ref}
29
+ className={cn('flex min-w-0', className)}
30
+ {...props}
31
+ />
32
+ ));
33
+ AccordionHeader.displayName = AccordionPrimitive.Header.displayName;
34
+
35
+ export interface AccordionTriggerProps extends React.ComponentPropsWithoutRef<
36
+ typeof AccordionPrimitive.Trigger
37
+ > {
38
+ chevronPosition?: 'start' | 'end';
39
+ }
40
+
41
+ const AccordionTrigger = React.forwardRef<
42
+ React.ElementRef<typeof AccordionPrimitive.Trigger>,
43
+ AccordionTriggerProps
44
+ >(({ className, children, chevronPosition = 'start', ...props }, ref) => {
45
+ const chevron = (
46
+ <ChevronRight
47
+ aria-hidden="true"
48
+ className={cn(
49
+ 'h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-fast ease-move group-data-[state=open]:rotate-90',
50
+ chevronPosition === 'end' && 'ml-auto',
51
+ )}
52
+ />
53
+ );
54
+ return (
55
+ <AccordionPrimitive.Trigger
56
+ ref={ref}
57
+ className={cn(
58
+ 'group flex min-w-0 flex-1 items-center gap-1.5 rounded-md p-inset text-left outline-none ring-offset-background transition-colors duration-fast ease-move',
59
+ 'hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
60
+ 'disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent',
61
+ className,
62
+ )}
63
+ {...props}
64
+ >
65
+ {chevronPosition === 'start' && chevron}
66
+ {children}
67
+ {chevronPosition === 'end' && chevron}
68
+ </AccordionPrimitive.Trigger>
69
+ );
70
+ });
71
+ AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName;
72
+
73
+ export interface AccordionContentProps extends React.ComponentPropsWithoutRef<
74
+ typeof AccordionPrimitive.Content
75
+ > {
76
+ /** Classes applied to the measured content wrapper rather than the animated node. */
77
+ innerClassName?: string;
78
+ }
79
+
80
+ const AccordionContent = React.forwardRef<
81
+ React.ElementRef<typeof AccordionPrimitive.Content>,
82
+ AccordionContentProps
83
+ >(({ className, innerClassName, children, ...props }, ref) => (
84
+ <AccordionPrimitive.Content
85
+ ref={ref}
86
+ className={cn(
87
+ 'overflow-hidden data-[state=closed]:animate-[oaiz-accordion-collapse_var(--transition-duration-normal)_var(--ease-move)] data-[state=open]:animate-[oaiz-accordion-expand_var(--transition-duration-normal)_var(--ease-move)]',
88
+ className,
89
+ )}
90
+ {...props}
91
+ >
92
+ <div className={innerClassName}>{children}</div>
93
+ </AccordionPrimitive.Content>
94
+ ));
95
+ AccordionContent.displayName = AccordionPrimitive.Content.displayName;
96
+
97
+ function AccordionTitle({
98
+ className,
99
+ ...props
100
+ }: React.ComponentProps<typeof Heading>) {
101
+ return (
102
+ <Heading
103
+ as="span"
104
+ size="sm"
105
+ weight="semibold"
106
+ variant="default"
107
+ className={cn('block font-inter leading-tight tracking-tight', className)}
108
+ {...props}
109
+ />
110
+ );
111
+ }
112
+
113
+ function AccordionDescription({
114
+ className,
115
+ ...props
116
+ }: React.ComponentProps<typeof Text>) {
117
+ return (
118
+ <Text
119
+ as="span"
120
+ size="xs"
121
+ weight="medium"
122
+ leading="normal"
123
+ variant="muted"
124
+ className={cn('block font-inter', className)}
125
+ {...props}
126
+ />
127
+ );
128
+ }
129
+
130
+ export {
131
+ Accordion,
132
+ AccordionItem,
133
+ AccordionHeader,
134
+ AccordionTrigger,
135
+ AccordionContent,
136
+ AccordionTitle,
137
+ AccordionDescription,
138
+ };
@@ -0,0 +1,67 @@
1
+ import {
2
+ forwardRef,
3
+ useImperativeHandle,
4
+ useRef,
5
+ type ComponentPropsWithoutRef,
6
+ type ElementRef,
7
+ } from 'react';
8
+ import {
9
+ Dialog,
10
+ DialogClose,
11
+ DialogContent,
12
+ DialogDescription,
13
+ DialogFooter,
14
+ DialogHeader,
15
+ DialogTitle,
16
+ DialogTrigger,
17
+ } from './dialog';
18
+
19
+ export const AlertDialog = Dialog;
20
+ export const AlertDialogTrigger = DialogTrigger;
21
+ export const AlertDialogTitle = DialogTitle;
22
+ export const AlertDialogDescription = DialogDescription;
23
+ export const AlertDialogHeader = DialogHeader;
24
+ export const AlertDialogFooter = DialogFooter;
25
+
26
+ /** An explicit decision cannot be accepted or dismissed by clicking its backdrop. */
27
+ export const AlertDialogContent = forwardRef<
28
+ ElementRef<typeof DialogContent>,
29
+ ComponentPropsWithoutRef<typeof DialogContent>
30
+ >(({ onOpenAutoFocus, onInteractOutside, ...props }, ref) => {
31
+ const content = useRef<ElementRef<typeof DialogContent>>(null);
32
+ useImperativeHandle(ref, () => content.current!);
33
+ return (
34
+ <DialogContent
35
+ {...props}
36
+ ref={content}
37
+ role="alertdialog"
38
+ showCloseButton={false}
39
+ onOpenAutoFocus={(event) => {
40
+ onOpenAutoFocus?.(event);
41
+ if (!event.defaultPrevented) {
42
+ const cancel = content.current?.querySelector<HTMLElement>(
43
+ '[data-alert-dialog-cancel]',
44
+ );
45
+ if (cancel) {
46
+ event.preventDefault();
47
+ cancel.focus();
48
+ }
49
+ }
50
+ }}
51
+ onInteractOutside={(event) => {
52
+ onInteractOutside?.(event);
53
+ event.preventDefault();
54
+ }}
55
+ />
56
+ );
57
+ });
58
+ AlertDialogContent.displayName = 'AlertDialogContent';
59
+
60
+ export const AlertDialogCancel = forwardRef<
61
+ ElementRef<typeof DialogClose>,
62
+ ComponentPropsWithoutRef<typeof DialogClose>
63
+ >((props, ref) => (
64
+ <DialogClose {...props} ref={ref} data-alert-dialog-cancel="" />
65
+ ));
66
+ AlertDialogCancel.displayName = 'AlertDialogCancel';
67
+ export const AlertDialogAction = DialogClose;
@@ -0,0 +1,65 @@
1
+ import * as React from 'react';
2
+ import { cva, type VariantProps } from 'class-variance-authority';
3
+ import { cn } from '../../lib/utils';
4
+
5
+ import { Heading } from './heading';
6
+ import { Text } from './text';
7
+ const alertVariants = cva(
8
+ 'relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-0.1875rem] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground',
9
+ {
10
+ variants: {
11
+ variant: {
12
+ default: 'bg-background text-foreground',
13
+ destructive:
14
+ 'border-destructive-text/50 text-destructive-text dark:border-destructive-text [&>svg]:text-destructive-text',
15
+ warning:
16
+ 'border-warning-text/50 bg-warning-bg-subtle text-warning-text [&>svg]:text-warning-text',
17
+ },
18
+ },
19
+ defaultVariants: {
20
+ variant: 'default',
21
+ },
22
+ },
23
+ );
24
+
25
+ const Alert = React.forwardRef<
26
+ HTMLDivElement,
27
+ React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof alertVariants>
28
+ >(({ className, variant, ...props }, ref) => (
29
+ <div
30
+ ref={ref}
31
+ role="alert"
32
+ className={cn(alertVariants({ variant }), className)}
33
+ {...props}
34
+ />
35
+ ));
36
+ Alert.displayName = 'Alert';
37
+
38
+ const AlertTitle = React.forwardRef<
39
+ HTMLHeadingElement,
40
+ React.HTMLAttributes<HTMLHeadingElement> & { level?: 1 | 2 | 3 | 4 | 5 | 6 }
41
+ >(({ className, level = 2, ...props }, ref) => (
42
+ <Heading
43
+ level={level}
44
+ ref={ref}
45
+ className={cn('mb-1', className)}
46
+ {...props}
47
+ />
48
+ ));
49
+ AlertTitle.displayName = 'AlertTitle';
50
+
51
+ const AlertDescription = React.forwardRef<
52
+ HTMLDivElement,
53
+ React.HTMLAttributes<HTMLDivElement>
54
+ >(({ className, ...props }, ref) => (
55
+ <Text
56
+ as="div"
57
+ size="sm"
58
+ ref={ref}
59
+ className={cn('[&_p]:leading-relaxed', className)}
60
+ {...props}
61
+ />
62
+ ));
63
+ AlertDescription.displayName = 'AlertDescription';
64
+
65
+ export { Alert, AlertTitle, AlertDescription };