@usetheo/ui 0.7.0-next.0 → 0.8.0-next.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.
package/package.json CHANGED
@@ -1,10 +1,12 @@
1
1
  {
2
2
  "name": "@usetheo/ui",
3
- "version": "0.7.0-next.0",
3
+ "version": "0.8.0-next.0",
4
4
  "description": "Theo UI — framework-agnostic React component library with the Violet Forge design system. Focused on AI-agent interfaces, cloud dashboards, and developer-tooling surfaces.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
- "sideEffects": ["**/*.css"],
7
+ "sideEffects": [
8
+ "**/*.css"
9
+ ],
8
10
  "exports": {
9
11
  ".": {
10
12
  "types": "./dist/index.d.ts",
@@ -129,10 +131,18 @@
129
131
  "types": "./dist/index.d.ts",
130
132
  "import": "./dist/index.js"
131
133
  },
134
+ "./code-block": {
135
+ "types": "./dist/index.d.ts",
136
+ "import": "./dist/index.js"
137
+ },
132
138
  "./command-palette": {
133
139
  "types": "./dist/index.d.ts",
134
140
  "import": "./dist/index.js"
135
141
  },
142
+ "./confirm-dialog": {
143
+ "types": "./dist/index.d.ts",
144
+ "import": "./dist/index.js"
145
+ },
136
146
  "./context-card": {
137
147
  "types": "./dist/index.d.ts",
138
148
  "import": "./dist/index.js"
@@ -141,6 +151,10 @@
141
151
  "types": "./dist/index.d.ts",
142
152
  "import": "./dist/index.js"
143
153
  },
154
+ "./copy-button": {
155
+ "types": "./dist/index.d.ts",
156
+ "import": "./dist/index.js"
157
+ },
144
158
  "./cost-meter": {
145
159
  "types": "./dist/index.d.ts",
146
160
  "import": "./dist/index.js"
@@ -157,6 +171,10 @@
157
171
  "types": "./dist/index.d.ts",
158
172
  "import": "./dist/index.js"
159
173
  },
174
+ "./danger-zone": {
175
+ "types": "./dist/index.d.ts",
176
+ "import": "./dist/index.js"
177
+ },
160
178
  "./deployment-row": {
161
179
  "types": "./dist/index.d.ts",
162
180
  "import": "./dist/index.js"
@@ -361,6 +379,14 @@
361
379
  "types": "./dist/index.d.ts",
362
380
  "import": "./dist/index.js"
363
381
  },
382
+ "./stat-tile": {
383
+ "types": "./dist/index.d.ts",
384
+ "import": "./dist/index.js"
385
+ },
386
+ "./status-dot": {
387
+ "types": "./dist/index.d.ts",
388
+ "import": "./dist/index.js"
389
+ },
364
390
  "./steps-rail": {
365
391
  "types": "./dist/index.d.ts",
366
392
  "import": "./dist/index.js"
@@ -377,6 +403,10 @@
377
403
  "types": "./dist/index.d.ts",
378
404
  "import": "./dist/index.js"
379
405
  },
406
+ "./table": {
407
+ "types": "./dist/index.d.ts",
408
+ "import": "./dist/index.js"
409
+ },
380
410
  "./tabs": {
381
411
  "types": "./dist/index.d.ts",
382
412
  "import": "./dist/index.js"
@@ -397,6 +427,10 @@
397
427
  "types": "./dist/index.d.ts",
398
428
  "import": "./dist/index.js"
399
429
  },
430
+ "./timestamp": {
431
+ "types": "./dist/index.d.ts",
432
+ "import": "./dist/index.js"
433
+ },
400
434
  "./toast": {
401
435
  "types": "./dist/index.d.ts",
402
436
  "import": "./dist/index.js"
@@ -470,44 +504,14 @@
470
504
  "import": "./dist/preset-v3-legacy.js"
471
505
  }
472
506
  },
473
- "files": ["dist", "registry/r", "registry/index.json", "LICENSE", "NOTICE", "CHANGELOG.md"],
474
- "scripts": {
475
- "build": "tsup",
476
- "dev": "ladle serve",
477
- "ladle:build": "ladle build",
478
- "ladle:preview": "ladle preview",
479
- "playground": "vite --config playground/vite.config.ts",
480
- "playground:build": "vite build --config playground/vite.config.ts",
481
- "playground:preview": "vite preview --config playground/vite.config.ts",
482
- "typecheck": "tsc --noEmit",
483
- "lint": "biome check src",
484
- "lint:ci": "biome ci src scripts .ladle playground",
485
- "lint:fix": "biome check --write src",
486
- "format": "biome format --write src scripts .ladle package.json tsconfig.json tailwind.config.ts vitest.config.ts tsup.config.ts biome.json",
487
- "format:check": "biome format src scripts .ladle package.json tsconfig.json tailwind.config.ts vitest.config.ts tsup.config.ts biome.json",
488
- "test": "vitest run",
489
- "test:watch": "vitest",
490
- "test:ui": "vitest --ui",
491
- "registry:build": "tsx scripts/build-registry.ts",
492
- "registry:validate": "tsx scripts/validate-registry.ts",
493
- "sync:readme": "tsx scripts/sync-readme.ts",
494
- "sync:exports": "tsx scripts/sync-exports.ts",
495
- "test:registry": "tsx scripts/test-registry-install.ts",
496
- "test:coverage": "vitest run --coverage",
497
- "quality:structure": "tsx scripts/validate-quality-gates.ts",
498
- "quality:bundle": "tsx scripts/validate-bundle-size.ts",
499
- "quality:bundle:update": "tsx scripts/validate-bundle-size.ts --update",
500
- "quality:a11y": "vitest run src/test/ladle-axe.test.tsx",
501
- "dogfood:whiteboard": "tsx scripts/dogfood-whiteboard.ts",
502
- "dogfood:slide": "tsx scripts/dogfood-slide.ts",
503
- "dogfood:slide-deck": "tsx scripts/dogfood-slide-deck.ts",
504
- "dogfood:slide-rich": "tsx scripts/dogfood-slide-rich.ts",
505
- "dogfood:v4-zero-config": "tsx scripts/dogfood-v4-zero-config.ts",
506
- "dogfood:v4-real-build": "bash scripts/dogfood-v4-real-build.sh",
507
- "dogfood:precompiled-utilities": "tsx scripts/dogfood-precompiled-utilities.ts",
508
- "quality:gates": "pnpm format:check && pnpm lint:ci && pnpm typecheck && pnpm test && pnpm build && pnpm registry:build && pnpm registry:validate && pnpm quality:structure && pnpm quality:bundle && pnpm quality:a11y && pnpm ladle:build && pnpm dogfood:whiteboard && pnpm dogfood:slide && pnpm dogfood:slide-deck && pnpm dogfood:slide-rich && pnpm dogfood:v4-zero-config && pnpm dogfood:precompiled-utilities",
509
- "quality:gates:fast": "pnpm format:check && pnpm lint:ci && pnpm typecheck && pnpm registry:build && pnpm registry:validate && pnpm quality:structure"
510
- },
507
+ "files": [
508
+ "dist",
509
+ "registry/r",
510
+ "registry/index.json",
511
+ "LICENSE",
512
+ "NOTICE",
513
+ "CHANGELOG.md"
514
+ ],
511
515
  "peerDependencies": {
512
516
  "@tailwindcss/vite": "^4.0.0",
513
517
  "hast-util-from-html": "^2.0.0",
@@ -660,12 +664,6 @@
660
664
  "engines": {
661
665
  "node": ">=20"
662
666
  },
663
- "pnpm": {
664
- "onlyBuiltDependencies": ["@biomejs/biome", "@swc/core", "esbuild"],
665
- "overrides": {
666
- "postcss": ">=8.5.10"
667
- }
668
- },
669
667
  "keywords": [
670
668
  "react",
671
669
  "components",
@@ -681,5 +679,41 @@
681
679
  "publishConfig": {
682
680
  "access": "public"
683
681
  },
684
- "packageManager": "pnpm@10.32.1+sha512.a706938f0e89ac1456b6563eab4edf1d1faf3368d1191fc5c59790e96dc918e4456ab2e67d613de1043d2e8c81f87303e6b40d4ffeca9df15ef1ad567348f2be"
685
- }
682
+ "scripts": {
683
+ "build": "tsup",
684
+ "dev": "ladle serve",
685
+ "ladle:build": "ladle build",
686
+ "ladle:preview": "ladle preview",
687
+ "playground": "vite --config playground/vite.config.ts",
688
+ "playground:build": "vite build --config playground/vite.config.ts",
689
+ "playground:preview": "vite preview --config playground/vite.config.ts",
690
+ "typecheck": "tsc --noEmit",
691
+ "lint": "biome check src",
692
+ "lint:ci": "biome ci src scripts .ladle playground",
693
+ "lint:fix": "biome check --write src",
694
+ "format": "biome format --write src scripts .ladle package.json tsconfig.json tailwind.config.ts vitest.config.ts tsup.config.ts biome.json",
695
+ "format:check": "biome format src scripts .ladle package.json tsconfig.json tailwind.config.ts vitest.config.ts tsup.config.ts biome.json",
696
+ "test": "vitest run",
697
+ "test:watch": "vitest",
698
+ "test:ui": "vitest --ui",
699
+ "registry:build": "tsx scripts/build-registry.ts",
700
+ "registry:validate": "tsx scripts/validate-registry.ts",
701
+ "sync:readme": "tsx scripts/sync-readme.ts",
702
+ "sync:exports": "tsx scripts/sync-exports.ts",
703
+ "test:registry": "tsx scripts/test-registry-install.ts",
704
+ "test:coverage": "vitest run --coverage",
705
+ "quality:structure": "tsx scripts/validate-quality-gates.ts",
706
+ "quality:bundle": "tsx scripts/validate-bundle-size.ts",
707
+ "quality:bundle:update": "tsx scripts/validate-bundle-size.ts --update",
708
+ "quality:a11y": "vitest run src/test/ladle-axe.test.tsx",
709
+ "dogfood:whiteboard": "tsx scripts/dogfood-whiteboard.ts",
710
+ "dogfood:slide": "tsx scripts/dogfood-slide.ts",
711
+ "dogfood:slide-deck": "tsx scripts/dogfood-slide-deck.ts",
712
+ "dogfood:slide-rich": "tsx scripts/dogfood-slide-rich.ts",
713
+ "dogfood:v4-zero-config": "tsx scripts/dogfood-v4-zero-config.ts",
714
+ "dogfood:v4-real-build": "bash scripts/dogfood-v4-real-build.sh",
715
+ "dogfood:precompiled-utilities": "tsx scripts/dogfood-precompiled-utilities.ts",
716
+ "quality:gates": "pnpm format:check && pnpm lint:ci && pnpm typecheck && pnpm test && pnpm build && pnpm registry:build && pnpm registry:validate && pnpm quality:structure && pnpm quality:bundle && pnpm quality:a11y && pnpm ladle:build && pnpm dogfood:whiteboard && pnpm dogfood:slide && pnpm dogfood:slide-deck && pnpm dogfood:slide-rich && pnpm dogfood:v4-zero-config && pnpm dogfood:precompiled-utilities",
717
+ "quality:gates:fast": "pnpm format:check && pnpm lint:ci && pnpm typecheck && pnpm registry:build && pnpm registry:validate && pnpm quality:structure"
718
+ }
719
+ }
@@ -16,7 +16,7 @@
16
16
  "name": "account-menu",
17
17
  "type": "registry:ui",
18
18
  "title": "AccountMenu",
19
- "description": "Sidebar header for PaaS surfaces. Avatar + name + (optional) PlanBadge + (optional) secondary line, with dual mode: with onClick renders as a <button> with trailing chevron (account picker affordance); without, renders as a static <div>. PaaS-shape sibling of ProjectSwitcher."
19
+ "description": "Sidebar header for PaaS surfaces. Avatar + name + (optional) PlanBadge + (optional) secondary line, with dual mode: with onClick renders as a `button` with trailing chevron (account picker affordance); without, renders as a static `div`. PaaS-shape sibling of ProjectSwitcher."
20
20
  },
21
21
  {
22
22
  "name": "agent-composer",
@@ -192,12 +192,24 @@
192
192
  "title": "cn (Tailwind class merger)",
193
193
  "description": "Merge Tailwind classes with conflict resolution."
194
194
  },
195
+ {
196
+ "name": "code-block",
197
+ "type": "registry:ui",
198
+ "title": "CodeBlock",
199
+ "description": "Terminal / code-snippet surface. Renders code inside a <pre> with optional 'terminal' prefix per line ('$ '), optional caption (file name), and optional inline CopyButton in top-right. Copy uses the raw code (without the visual prefix). language prop is forward-compat for future syntax highlighting."
200
+ },
195
201
  {
196
202
  "name": "command-palette",
197
203
  "type": "registry:ui",
198
204
  "title": "CommandPalette",
199
205
  "description": "Cmd+K-style global launcher with arrow-key navigation, fuzzy ranking, and Enter/Escape behavior — built on cmdk + Theo Dialog."
200
206
  },
207
+ {
208
+ "name": "confirm-dialog",
209
+ "type": "registry:ui",
210
+ "title": "ConfirmDialog",
211
+ "description": "Controlled confirmation modal built on Dialog. Auto-focuses Cancel on open (deliberate — NOT the destructive button). Optional intent=destructive switches the confirm button to destructive variant. Optional confirmationPhrase enables typed-confirmation guard (case-sensitive, empty string = no phrase). Async onConfirm shows Loader2 spinner; resolve closes the dialog; reject keeps it open so consumers can surface their own error. Enter in the phrase input triggers confirm when matched."
212
+ },
201
213
  {
202
214
  "name": "context-card",
203
215
  "type": "registry:ui",
@@ -210,6 +222,12 @@
210
222
  "title": "ContextWindowBar",
211
223
  "description": "Shows how much of the model's context window has been"
212
224
  },
225
+ {
226
+ "name": "copy-button",
227
+ "type": "registry:ui",
228
+ "title": "CopyButton",
229
+ "description": "Click-to-copy button primitive. Wraps navigator.clipboard.writeText with icon swap (Copy → Check on success, Copy → X on failure), aria-live announcement for screen readers, optional label, ghost/outline variants, and SSR-safe rendering. Auto-cleans the revert timer on unmount and debounces double-clicks."
230
+ },
213
231
  {
214
232
  "name": "cost-meter",
215
233
  "type": "registry:ui",
@@ -234,6 +252,12 @@
234
252
  "title": "CronJobsList",
235
253
  "description": "Grid of CronJobCards with a sticky \"new job\" action."
236
254
  },
255
+ {
256
+ "name": "danger-zone",
257
+ "type": "registry:ui",
258
+ "title": "DangerZone",
259
+ "description": "Destructive-actions section primitive with sub-component DangerZone.Action. Red-bordered container with title bar (default 'Danger Zone') and action rows. Each row carries title + description + consumer-provided action slot (typically a destructive Button). Rows separated by hairline dividers; last row drops the bottom border via last:border-b-0."
260
+ },
237
261
  {
238
262
  "name": "deployment-row",
239
263
  "type": "registry:block",
@@ -606,6 +630,18 @@
606
630
  "title": "SocialAuthRow",
607
631
  "description": "Row of OAuth provider buttons."
608
632
  },
633
+ {
634
+ "name": "stat-tile",
635
+ "type": "registry:ui",
636
+ "title": "StatTile",
637
+ "description": "Big-number stat tile primitive for dashboard summaries. Renders value + label + optional icon + optional delta (trend up/down/flat with TrendingUp/TrendingDown/Minus icons and success/destructive/muted color). Dual mode: with onClick renders as button with hover state + trailing ArrowUpRight chevron; without, renders as static div. Value uses font-display tabular-nums whitespace-nowrap."
638
+ },
639
+ {
640
+ "name": "status-dot",
641
+ "type": "registry:ui",
642
+ "title": "StatusDot",
643
+ "description": "Semantic status indicator (small colored circle + optional label). Five status kinds: live (success), building (warning, auto-pulses), failed (destructive), idle (muted), warning (warning, static). Three sizes (xs 6px / sm 8px default / md 10px). When neither label nor aria-label is provided, auto-applies aria-label=status and emits a dev warning."
644
+ },
609
645
  {
610
646
  "name": "steps-rail",
611
647
  "type": "registry:ui",
@@ -630,6 +666,12 @@
630
666
  "title": "SystemPromptEditor",
631
667
  "description": "Surface the agent's system prompt with a clear"
632
668
  },
669
+ {
670
+ "name": "table",
671
+ "type": "registry:ui",
672
+ "title": "Table",
673
+ "description": "Semantic data-table primitive with sub-components (Table.Header, Table.Body, Table.Row, Table.Cell, Table.HeaderCell). Supports density (default | compact via Context), per-cell align (left | center | right), numeric cells (font-mono tabular-nums), and sortable header cells (onSort + sortDirection with ChevronUp/ChevronDown affordance + aria-sort)."
674
+ },
633
675
  {
634
676
  "name": "tabs",
635
677
  "type": "registry:ui",
@@ -690,6 +732,12 @@
690
732
  "title": "TheoUIProvider",
691
733
  "description": "Primary entry-point provider — composes ThemeProvider + Toaster with sensible defaults. Use as the single root wrapper in consumer apps."
692
734
  },
735
+ {
736
+ "name": "timestamp",
737
+ "type": "registry:ui",
738
+ "title": "Timestamp",
739
+ "description": "Accessible <time> primitive with relative/absolute/both formats, auto-refresh interval (default 60s, 0 disables), native title tooltip with absolute time, and aria-label that always carries the full date. Built on Intl.RelativeTimeFormat (zero deps). value accepts ISO string, Date, or Unix ms (NOT seconds). Invalid date renders empty element; invalid locale falls back to default with dev warning."
740
+ },
693
741
  {
694
742
  "name": "toast",
695
743
  "type": "registry:ui",
@@ -3,7 +3,7 @@
3
3
  "name": "account-menu",
4
4
  "type": "registry:ui",
5
5
  "title": "AccountMenu",
6
- "description": "Sidebar header for PaaS surfaces. Avatar + name + (optional) PlanBadge + (optional) secondary line, with dual mode: with onClick renders as a <button> with trailing chevron (account picker affordance); without, renders as a static <div>. PaaS-shape sibling of ProjectSwitcher.",
6
+ "description": "Sidebar header for PaaS surfaces. Avatar + name + (optional) PlanBadge + (optional) secondary line, with dual mode: with onClick renders as a `button` with trailing chevron (account picker affordance); without, renders as a static `div`. PaaS-shape sibling of ProjectSwitcher.",
7
7
  "dependencies": [
8
8
  "lucide-react"
9
9
  ],
@@ -0,0 +1,21 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "code-block",
4
+ "type": "registry:ui",
5
+ "title": "CodeBlock",
6
+ "description": "Terminal / code-snippet surface. Renders code inside a <pre> with optional 'terminal' prefix per line ('$ '), optional caption (file name), and optional inline CopyButton in top-right. Copy uses the raw code (without the visual prefix). language prop is forward-compat for future syntax highlighting.",
7
+ "dependencies": [],
8
+ "registryDependencies": [
9
+ "https://usetheodev.github.io/theo-ui/r/cn.json",
10
+ "https://usetheodev.github.io/theo-ui/r/copy-button.json",
11
+ "https://usetheodev.github.io/theo-ui/r/tailwind-preset.json"
12
+ ],
13
+ "files": [
14
+ {
15
+ "path": "components/composites/code-block/code-block.tsx",
16
+ "type": "registry:ui",
17
+ "target": "components/ui/code-block.tsx",
18
+ "content": "import { forwardRef } from \"react\";\nimport type { HTMLAttributes, ReactNode } from \"react\";\nimport { cn } from \"@/lib/cn\";\nimport { CopyButton } from \"@/components/ui/copy-button\";\n\n/**\n * CodeBlock — terminal command / code snippet surface.\n *\n * Pre-rendered code block with optional terminal \"$ \" prefix per line,\n * optional caption (file name), and optional CopyButton positioned top-right.\n * The CopyButton receives the RAW `code` (without the visual \"$ \" prefix),\n * so consumers paste only the executable command.\n *\n * @example\n * <CodeBlock code=\"theo deploy\" terminal copyable />\n * <CodeBlock code={dotenv} caption=\".env.local\" copyable />\n *\n * `language` is reserved for future syntax highlighting (v1: ignored).\n */\nexport interface CodeBlockProps extends Omit<HTMLAttributes<HTMLDivElement>, \"children\"> {\n /** Code content. Can be multiline. */\n code: string;\n /** Language hint (forward-compat; v1 ignored). */\n language?: string;\n /** When true, prefix each line with \"$ \" for shell commands. */\n terminal?: boolean;\n /** Show inline CopyButton in top-right. */\n copyable?: boolean;\n /** Optional caption above block (e.g. \".env.local\"). */\n caption?: ReactNode;\n}\n\nconst CodeBlock = forwardRef<HTMLDivElement, CodeBlockProps>(\n ({ className, code, language: _language, terminal, copyable, caption, ...props }, ref) => {\n const lines = code.split(/\\r?\\n/);\n\n return (\n <div\n ref={ref}\n className={cn(\n \"relative rounded-lg border border-border/40 bg-muted/40 font-mono text-body-sm\",\n className,\n )}\n {...props}\n >\n {caption !== undefined ? (\n <div className=\"border-border/40 border-b px-3 py-1.5 font-sans text-label text-muted-foreground\">\n {caption}\n </div>\n ) : null}\n {copyable ? (\n <CopyButton value={code} aria-label=\"Copy code\" className=\"absolute top-2 right-2\" />\n ) : null}\n <pre className=\"overflow-x-auto p-3 text-foreground\">\n {terminal ? (\n <code>\n {lines.map((line, i) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: code lines are positional; reorder requires consumer recompute.\n <span key={i} className=\"block whitespace-pre\">\n <span className=\"select-none text-muted-foreground\">$ </span>\n {line}\n </span>\n ))}\n </code>\n ) : (\n <code>{code}</code>\n )}\n </pre>\n </div>\n );\n },\n);\nCodeBlock.displayName = \"CodeBlock\";\n\nexport { CodeBlock };\n"
19
+ }
20
+ ]
21
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "confirm-dialog",
4
+ "type": "registry:ui",
5
+ "title": "ConfirmDialog",
6
+ "description": "Controlled confirmation modal built on Dialog. Auto-focuses Cancel on open (deliberate — NOT the destructive button). Optional intent=destructive switches the confirm button to destructive variant. Optional confirmationPhrase enables typed-confirmation guard (case-sensitive, empty string = no phrase). Async onConfirm shows Loader2 spinner; resolve closes the dialog; reject keeps it open so consumers can surface their own error. Enter in the phrase input triggers confirm when matched.",
7
+ "dependencies": [
8
+ "lucide-react"
9
+ ],
10
+ "registryDependencies": [
11
+ "https://usetheodev.github.io/theo-ui/r/cn.json",
12
+ "https://usetheodev.github.io/theo-ui/r/dialog.json",
13
+ "https://usetheodev.github.io/theo-ui/r/button.json",
14
+ "https://usetheodev.github.io/theo-ui/r/input.json",
15
+ "https://usetheodev.github.io/theo-ui/r/tailwind-preset.json"
16
+ ],
17
+ "files": [
18
+ {
19
+ "path": "components/composites/confirm-dialog/confirm-dialog.tsx",
20
+ "type": "registry:ui",
21
+ "target": "components/ui/confirm-dialog.tsx",
22
+ "content": "import { Loader2 } from \"lucide-react\";\nimport { forwardRef, useEffect, useRef, useState } from \"react\";\nimport type { KeyboardEvent, ReactNode } from \"react\";\nimport { Button } from \"@/components/ui/button\";\nimport { Dialog } from \"@/components/ui/dialog\";\nimport { Input } from \"@/components/ui/input\";\n\n/**\n * ConfirmDialog — controlled confirmation modal built on `Dialog`.\n *\n * Focuses Cancel on open (deliberate — NOT the destructive button).\n * `intent=\"destructive\"` styles the confirm button with the destructive\n * variant. `confirmationPhrase` enables typed-confirmation guard:\n * the confirm button is disabled until the input value matches the\n * phrase exactly (case-sensitive). An empty string phrase is treated\n * as \"no phrase required\" (`!!confirmationPhrase`). Pressing Enter in\n * the input triggers confirm when `canConfirm` is true.\n *\n * `onConfirm` can be async. While the returned promise is pending,\n * both buttons are disabled and a `Loader2` spinner appears. On\n * resolve, the dialog closes via `onOpenChange(false)`. On reject,\n * the dialog stays open so the consumer can show their own error.\n *\n * @example\n * <ConfirmDialog\n * open={open} onOpenChange={setOpen}\n * title=\"Delete project\"\n * description=\"This cannot be undone.\"\n * intent=\"destructive\"\n * confirmationPhrase=\"my-project\"\n * onConfirm={async () => api.deleteProject(id)}\n * />\n */\nexport interface ConfirmDialogProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n title: ReactNode;\n description: ReactNode;\n confirmLabel?: ReactNode;\n cancelLabel?: ReactNode;\n intent?: \"default\" | \"destructive\";\n confirmationPhrase?: string;\n onConfirm: () => void | Promise<void>;\n loading?: boolean;\n}\n\nconst ConfirmDialog = forwardRef<HTMLDivElement, ConfirmDialogProps>(\n (\n {\n open,\n onOpenChange,\n title,\n description,\n confirmLabel = \"Confirm\",\n cancelLabel = \"Cancel\",\n intent = \"default\",\n confirmationPhrase,\n onConfirm,\n loading: externalLoading,\n },\n ref,\n ) => {\n const [phraseInput, setPhraseInput] = useState(\"\");\n const [internalLoading, setInternalLoading] = useState(false);\n const cancelRef = useRef<HTMLButtonElement | null>(null);\n\n const phraseRequired = !!confirmationPhrase;\n const phraseMatched = phraseRequired ? phraseInput === confirmationPhrase : true;\n const showLoading = externalLoading === true || internalLoading;\n const canConfirm = phraseMatched && !showLoading;\n\n // Reset phrase input whenever the dialog closes.\n useEffect(() => {\n if (!open) setPhraseInput(\"\");\n }, [open]);\n\n // Auto-focus Cancel on open (NOT confirm — destructive safety).\n useEffect(() => {\n if (open) {\n const id = window.setTimeout(() => cancelRef.current?.focus(), 0);\n return () => window.clearTimeout(id);\n }\n }, [open]);\n\n async function handleConfirm() {\n if (!canConfirm) return;\n setInternalLoading(true);\n try {\n await onConfirm();\n onOpenChange(false);\n } catch {\n // Stay open; consumer surfaces error.\n } finally {\n setInternalLoading(false);\n }\n }\n\n function handleInputKeyDown(e: KeyboardEvent<HTMLInputElement>) {\n if (e.key === \"Enter\" && canConfirm) {\n e.preventDefault();\n void handleConfirm();\n }\n }\n\n return (\n <Dialog open={open} onOpenChange={onOpenChange}>\n <Dialog.Content ref={ref}>\n <Dialog.Header>\n <Dialog.Title>{title}</Dialog.Title>\n <Dialog.Description>{description}</Dialog.Description>\n </Dialog.Header>\n {phraseRequired ? (\n <Dialog.Body>\n <p className=\"mb-2 text-body-sm text-muted-foreground\">\n Type{\" \"}\n <code className=\"rounded bg-muted px-1 py-0.5 font-mono text-foreground\">\n {confirmationPhrase}\n </code>{\" \"}\n to confirm\n </p>\n <Input\n value={phraseInput}\n onChange={(e) => setPhraseInput(e.target.value)}\n onKeyDown={handleInputKeyDown}\n autoComplete=\"off\"\n aria-label=\"Confirmation phrase\"\n />\n </Dialog.Body>\n ) : null}\n <Dialog.Footer>\n <Button\n ref={cancelRef}\n variant=\"secondary\"\n onClick={() => onOpenChange(false)}\n disabled={showLoading}\n >\n {cancelLabel}\n </Button>\n <Button\n variant={intent === \"destructive\" ? \"destructive\" : \"primary\"}\n onClick={() => void handleConfirm()}\n disabled={!canConfirm}\n data-confirm\n >\n {showLoading ? <Loader2 aria-hidden=\"true\" className=\"size-4 animate-spin\" /> : null}\n {confirmLabel}\n </Button>\n </Dialog.Footer>\n </Dialog.Content>\n </Dialog>\n );\n },\n);\nConfirmDialog.displayName = \"ConfirmDialog\";\n\nexport { ConfirmDialog };\n"
23
+ }
24
+ ]
25
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "copy-button",
4
+ "type": "registry:ui",
5
+ "title": "CopyButton",
6
+ "description": "Click-to-copy button primitive. Wraps navigator.clipboard.writeText with icon swap (Copy → Check on success, Copy → X on failure), aria-live announcement for screen readers, optional label, ghost/outline variants, and SSR-safe rendering. Auto-cleans the revert timer on unmount and debounces double-clicks.",
7
+ "dependencies": [
8
+ "lucide-react"
9
+ ],
10
+ "registryDependencies": [
11
+ "https://usetheodev.github.io/theo-ui/r/cn.json",
12
+ "https://usetheodev.github.io/theo-ui/r/tailwind-preset.json"
13
+ ],
14
+ "files": [
15
+ {
16
+ "path": "components/primitives/copy-button/copy-button.tsx",
17
+ "type": "registry:ui",
18
+ "target": "components/ui/copy-button.tsx",
19
+ "content": "import { Check, Copy, X } from \"lucide-react\";\nimport { forwardRef, useCallback, useEffect, useRef, useState } from \"react\";\nimport type { ButtonHTMLAttributes, ReactNode } from \"react\";\nimport { cn } from \"@/lib/cn\";\n\n/**\n * CopyButton — click-to-copy primitive for PaaS surfaces.\n *\n * Wraps the Clipboard API behind a button that:\n * - Calls `navigator.clipboard.writeText(value)` on click\n * - Swaps the icon (Copy → Check on success, Copy → X on failure)\n * - Optionally swaps the visible `label` to \"Copied!\" / \"Failed\"\n * - Announces the state change via an `aria-live=\"polite\"` sr-only region\n * - Reverts to idle after `feedbackDuration` ms (default 1500)\n *\n * SSR-safe (guards `navigator?.clipboard?.writeText`). Debounces double-clicks\n * by ignoring clicks while not in the `idle` state. Cleans up the revert timer\n * on unmount so no `setState` happens on unmounted components.\n *\n * @example\n * <CopyButton value={envVar.value} /> // icon-only ghost\n * <CopyButton value={token} label=\"Copy token\" variant=\"outline\" />\n */\ntype CopyState = \"idle\" | \"copied\" | \"failed\";\n\nexport interface CopyButtonProps\n extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, \"type\" | \"onClick\" | \"children\"> {\n /** String to copy when clicked. */\n value: string;\n /** Optional button label. Default: just the icon. */\n label?: ReactNode;\n /** Visual style. */\n variant?: \"ghost\" | \"outline\";\n /** Size. */\n size?: \"sm\" | \"md\";\n /** Callback after successful copy (e.g. analytics). */\n onCopied?: (value: string) => void;\n /** Duration of the feedback state in ms. Default 1500. */\n feedbackDuration?: number;\n}\n\nconst VARIANT: Record<NonNullable<CopyButtonProps[\"variant\"]>, string> = {\n ghost: \"hover:bg-muted\",\n outline: \"border border-border/60 rounded-md\",\n};\n\nconst SIZE: Record<NonNullable<CopyButtonProps[\"size\"]>, string> = {\n sm: \"px-2 py-1 text-label\",\n md: \"px-2.5 py-1.5 text-body-sm\",\n};\n\nconst CopyButton = forwardRef<HTMLButtonElement, CopyButtonProps>(\n (\n {\n className,\n value,\n label,\n variant = \"ghost\",\n size = \"sm\",\n onCopied,\n feedbackDuration = 1500,\n ...props\n },\n ref,\n ) => {\n const [state, setState] = useState<CopyState>(\"idle\");\n const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n useEffect(() => {\n return () => {\n if (timerRef.current !== null) {\n clearTimeout(timerRef.current);\n }\n };\n }, []);\n\n const scheduleRevert = useCallback(() => {\n if (timerRef.current !== null) {\n clearTimeout(timerRef.current);\n }\n timerRef.current = setTimeout(() => {\n setState(\"idle\");\n timerRef.current = null;\n }, feedbackDuration);\n }, [feedbackDuration]);\n\n const handleClick = useCallback(() => {\n if (state !== \"idle\") return;\n\n if (typeof navigator === \"undefined\" || !navigator.clipboard?.writeText) {\n setState(\"failed\");\n scheduleRevert();\n return;\n }\n\n navigator.clipboard.writeText(value).then(\n () => {\n setState(\"copied\");\n onCopied?.(value);\n scheduleRevert();\n },\n () => {\n setState(\"failed\");\n scheduleRevert();\n },\n );\n }, [state, value, onCopied, scheduleRevert]);\n\n const Icon = state === \"copied\" ? Check : state === \"failed\" ? X : Copy;\n const liveMessage =\n state === \"copied\" ? \"Copied to clipboard\" : state === \"failed\" ? \"Copy failed\" : \"\";\n\n const labelText =\n label !== undefined\n ? state === \"copied\"\n ? \"Copied!\"\n : state === \"failed\"\n ? \"Failed\"\n : label\n : null;\n\n return (\n <button\n ref={ref}\n type=\"button\"\n onClick={handleClick}\n data-state={state}\n className={cn(\n \"inline-flex items-center gap-1.5\",\n \"font-sans transition-colors\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-card\",\n VARIANT[variant],\n SIZE[size],\n className,\n )}\n {...props}\n >\n <Icon\n aria-hidden=\"true\"\n className={cn(\n \"size-3.5 shrink-0 transition-opacity duration-200\",\n state === \"copied\" && \"text-success\",\n state === \"failed\" && \"text-destructive\",\n )}\n />\n {labelText !== null ? <span>{labelText}</span> : null}\n <span className=\"sr-only\" aria-live=\"polite\">\n {liveMessage}\n </span>\n </button>\n );\n },\n);\nCopyButton.displayName = \"CopyButton\";\n\nexport { CopyButton };\n"
20
+ }
21
+ ]
22
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "danger-zone",
4
+ "type": "registry:ui",
5
+ "title": "DangerZone",
6
+ "description": "Destructive-actions section primitive with sub-component DangerZone.Action. Red-bordered container with title bar (default 'Danger Zone') and action rows. Each row carries title + description + consumer-provided action slot (typically a destructive Button). Rows separated by hairline dividers; last row drops the bottom border via last:border-b-0.",
7
+ "dependencies": [],
8
+ "registryDependencies": [
9
+ "https://usetheodev.github.io/theo-ui/r/cn.json",
10
+ "https://usetheodev.github.io/theo-ui/r/tailwind-preset.json"
11
+ ],
12
+ "files": [
13
+ {
14
+ "path": "components/primitives/danger-zone/danger-zone.tsx",
15
+ "type": "registry:ui",
16
+ "target": "components/ui/danger-zone.tsx",
17
+ "content": "import { forwardRef } from \"react\";\nimport type { HTMLAttributes, ReactNode } from \"react\";\nimport { cn } from \"@/lib/cn\";\n\n/**\n * DangerZone — destructive-actions section primitive.\n *\n * Red-bordered container with a title bar and `DangerZone.Action` rows.\n * Each Action is laid out as title + description on the left, with a\n * consumer-provided action slot (typically a destructive Button) on\n * the right. Rows are separated by hairline dividers; the last row\n * has no bottom border via `last:border-b-0`.\n *\n * The consumer supplies the destructive button — this primitive never\n * imports `<Button>`, keeping it free of internal `@usetheo/ui` deps\n * (true primitive).\n *\n * @example\n * <DangerZone>\n * <DangerZone.Action\n * title=\"Delete project\"\n * description=\"Permanently delete this project.\"\n * action={<Button variant=\"destructive\">Delete</Button>}\n * />\n * </DangerZone>\n */\nexport interface DangerZoneProps extends Omit<HTMLAttributes<HTMLElement>, \"title\"> {\n /** Section title. Default \"Danger Zone\". */\n title?: ReactNode;\n}\n\nconst Root = forwardRef<HTMLElement, DangerZoneProps>(\n ({ className, title = \"Danger Zone\", children, ...props }, ref) => (\n <section\n ref={ref}\n aria-label={typeof title === \"string\" ? title : \"Danger Zone\"}\n className={cn(\"rounded-xl border border-destructive/30 bg-destructive/[0.02]\", className)}\n {...props}\n >\n <div className=\"border-destructive/20 border-b px-5 py-3 font-sans text-destructive text-label-caps uppercase tracking-wider\">\n {title}\n </div>\n {children}\n </section>\n ),\n);\nRoot.displayName = \"DangerZone\";\n\nexport interface DangerZoneActionProps extends Omit<HTMLAttributes<HTMLDivElement>, \"title\"> {\n title: ReactNode;\n description: ReactNode;\n /** Consumer-provided destructive button (or any ReactNode). */\n action: ReactNode;\n}\n\nconst Action = forwardRef<HTMLDivElement, DangerZoneActionProps>(\n ({ className, title, description, action, ...props }, ref) => (\n <div\n ref={ref}\n className={cn(\n \"flex items-center justify-between gap-4 border-destructive/10 border-b px-5 py-4 last:border-b-0\",\n className,\n )}\n {...props}\n >\n <div className=\"flex flex-col\">\n <span className=\"font-medium font-sans text-body-sm text-foreground\">{title}</span>\n <span className=\"mt-0.5 font-sans text-label text-muted-foreground\">{description}</span>\n </div>\n <div className=\"shrink-0\">{action}</div>\n </div>\n ),\n);\nAction.displayName = \"DangerZone.Action\";\n\ntype DangerZoneRoot = typeof Root & { Action: typeof Action };\nconst DangerZone: DangerZoneRoot = Object.assign(Root, { Action });\n\nexport { DangerZone };\n"
18
+ }
19
+ ]
20
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "stat-tile",
4
+ "type": "registry:ui",
5
+ "title": "StatTile",
6
+ "description": "Big-number stat tile primitive for dashboard summaries. Renders value + label + optional icon + optional delta (trend up/down/flat with TrendingUp/TrendingDown/Minus icons and success/destructive/muted color). Dual mode: with onClick renders as button with hover state + trailing ArrowUpRight chevron; without, renders as static div. Value uses font-display tabular-nums whitespace-nowrap.",
7
+ "dependencies": [
8
+ "lucide-react"
9
+ ],
10
+ "registryDependencies": [
11
+ "https://usetheodev.github.io/theo-ui/r/cn.json",
12
+ "https://usetheodev.github.io/theo-ui/r/tailwind-preset.json"
13
+ ],
14
+ "files": [
15
+ {
16
+ "path": "components/primitives/stat-tile/stat-tile.tsx",
17
+ "type": "registry:ui",
18
+ "target": "components/ui/stat-tile.tsx",
19
+ "content": "import { ArrowUpRight, Minus, TrendingDown, TrendingUp } from \"lucide-react\";\nimport { forwardRef } from \"react\";\nimport type { ButtonHTMLAttributes, ElementType, ReactNode } from \"react\";\nimport { cn } from \"@/lib/cn\";\n\n/**\n * StatTile — big number + label + optional delta + optional icon.\n *\n * Dual mode based on `onClick`:\n * - With onClick → renders as `<button>` with hover state + trailing\n * ArrowUpRight chevron (navigation affordance).\n * - Without onClick → renders as static `<div>`.\n *\n * Delta trend drives icon + color: up=success/TrendingUp, down=destructive/\n * TrendingDown, flat=muted/Minus. Big value uses font-display + tabular-nums.\n *\n * @example\n * <StatTile value=\"42\" label=\"Projects\" />\n * <StatTile value=\"$1,234\" label=\"MRR\" icon={DollarSign}\n * delta={{ value: \"+12%\", trend: \"up\" }} onClick={openBilling} />\n */\nexport interface StatTileProps\n extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, \"type\" | \"value\"> {\n value: ReactNode;\n label: ReactNode;\n icon?: ElementType;\n delta?: { value: ReactNode; trend: \"up\" | \"down\" | \"flat\" };\n}\n\nconst TREND: Record<\"up\" | \"down\" | \"flat\", { icon: ElementType; color: string }> = {\n up: { icon: TrendingUp, color: \"text-success\" },\n down: { icon: TrendingDown, color: \"text-destructive\" },\n flat: { icon: Minus, color: \"text-muted-foreground\" },\n};\n\nconst StatTile = forwardRef<HTMLElement, StatTileProps>(\n ({ className, value, label, icon: Icon, delta, onClick, children: _children, ...props }, ref) => {\n const isInteractive = onClick !== undefined;\n const TrendIcon = delta !== undefined ? TREND[delta.trend].icon : null;\n const trendColor = delta !== undefined ? TREND[delta.trend].color : \"\";\n\n const inner = (\n <>\n {(Icon !== undefined || isInteractive) && (\n <div className=\"mb-3 flex items-center justify-between\">\n {Icon !== undefined ? (\n <div className=\"flex size-8 items-center justify-center rounded-lg border border-border/40 bg-muted/40\">\n <Icon aria-hidden=\"true\" className=\"size-4 text-muted-foreground\" />\n </div>\n ) : (\n <div />\n )}\n {isInteractive ? (\n <ArrowUpRight\n aria-hidden=\"true\"\n className=\"size-3.5 text-muted-foreground transition-colors group-hover:text-foreground\"\n />\n ) : null}\n </div>\n )}\n <div className=\"whitespace-nowrap font-bold font-display text-display-md text-foreground tabular-nums leading-none tracking-tight\">\n {value}\n </div>\n <div className=\"mt-1 font-sans text-body-sm text-muted-foreground\">{label}</div>\n {delta !== undefined && TrendIcon !== null ? (\n <div\n className={cn(\"mt-2 inline-flex items-center gap-1 font-mono text-label\", trendColor)}\n >\n <TrendIcon aria-hidden=\"true\" className=\"size-3\" />\n <span>{delta.value}</span>\n </div>\n ) : null}\n </>\n );\n\n if (isInteractive) {\n return (\n <button\n ref={ref as React.Ref<HTMLButtonElement>}\n type=\"button\"\n onClick={onClick}\n className={cn(\n \"group block w-full rounded-xl border border-border/40 bg-card p-5 text-left\",\n \"cursor-pointer transition-colors hover:border-primary/30\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n className,\n )}\n {...props}\n >\n {inner}\n </button>\n );\n }\n\n return (\n <div\n ref={ref as React.Ref<HTMLDivElement>}\n className={cn(\"rounded-xl border border-border/40 bg-card p-5\", className)}\n >\n {inner}\n </div>\n );\n },\n);\nStatTile.displayName = \"StatTile\";\n\nexport { StatTile };\n"
20
+ }
21
+ ]
22
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "status-dot",
4
+ "type": "registry:ui",
5
+ "title": "StatusDot",
6
+ "description": "Semantic status indicator (small colored circle + optional label). Five status kinds: live (success), building (warning, auto-pulses), failed (destructive), idle (muted), warning (warning, static). Three sizes (xs 6px / sm 8px default / md 10px). When neither label nor aria-label is provided, auto-applies aria-label=status and emits a dev warning.",
7
+ "dependencies": [],
8
+ "registryDependencies": [
9
+ "https://usetheodev.github.io/theo-ui/r/cn.json",
10
+ "https://usetheodev.github.io/theo-ui/r/tailwind-preset.json"
11
+ ],
12
+ "files": [
13
+ {
14
+ "path": "components/primitives/status-dot/status-dot.tsx",
15
+ "type": "registry:ui",
16
+ "target": "components/ui/status-dot.tsx",
17
+ "content": "import { forwardRef, useEffect } from \"react\";\nimport type { HTMLAttributes, ReactNode } from \"react\";\nimport { cn } from \"@/lib/cn\";\n\n/**\n * StatusDot — semantic status indicator (colored circle + optional label).\n *\n * Five status kinds:\n * - `live` — deployed / verified / healthy (success)\n * - `building` — in-progress / queued (warning, auto-pulses)\n * - `failed` — error / down / rejected (destructive)\n * - `idle` — pending / offline (muted)\n * - `warning` — degraded but functional (warning, static)\n *\n * Three sizes (xs 6px, sm 8px default, md 10px). `pulse` defaults to\n * `true` for `building` and `false` otherwise; passing `pulse` explicitly\n * overrides the auto behavior. When no visible `label` AND no `aria-label`\n * are provided, the component auto-applies `aria-label={status}` and\n * emits a dev-mode warning (a status communicated only by color is\n * invisible to screen readers).\n *\n * @example\n * <StatusDot status=\"live\" label=\"Production\" />\n * <StatusDot status=\"building\" /> // auto-pulses + auto-aria-label\n */\nexport type StatusKind = \"live\" | \"building\" | \"failed\" | \"idle\" | \"warning\";\n\nexport interface StatusDotProps extends Omit<HTMLAttributes<HTMLSpanElement>, \"children\"> {\n status: StatusKind;\n label?: ReactNode;\n size?: \"xs\" | \"sm\" | \"md\";\n pulse?: boolean;\n}\n\nconst DOT_COLOR: Record<StatusKind, string> = {\n live: \"bg-success\",\n building: \"bg-warning\",\n failed: \"bg-destructive\",\n idle: \"bg-muted-foreground/40\",\n warning: \"bg-warning\",\n};\n\nconst LABEL_COLOR: Record<StatusKind, string> = {\n live: \"text-success\",\n building: \"text-warning\",\n failed: \"text-destructive\",\n idle: \"text-muted-foreground\",\n warning: \"text-warning\",\n};\n\nconst SIZE: Record<NonNullable<StatusDotProps[\"size\"]>, string> = {\n xs: \"size-1.5\",\n sm: \"size-2\",\n md: \"size-2.5\",\n};\n\nconst StatusDot = forwardRef<HTMLSpanElement, StatusDotProps>(\n ({ className, status, label, size = \"sm\", pulse, \"aria-label\": ariaLabel, ...props }, ref) => {\n const shouldPulse = pulse ?? status === \"building\";\n\n const hasVisibleLabel = label !== undefined && label !== null;\n const effectiveAriaLabel = ariaLabel ?? (hasVisibleLabel ? undefined : status);\n\n // EC-6: dev warning when neither label nor aria-label is provided.\n useEffect(() => {\n if (process.env.NODE_ENV !== \"production\" && !hasVisibleLabel && ariaLabel === undefined) {\n // biome-ignore lint/suspicious/noConsole: dev-only diagnostic for a11y misconfiguration.\n console.warn(\n `<StatusDot status=\"${status}\" />: no \\`label\\` or \\`aria-label\\` provided. Color-only status is invisible to screen readers. Falling back to aria-label=\"${status}\".`,\n );\n }\n }, [hasVisibleLabel, ariaLabel, status]);\n\n const dot = (\n <span\n aria-hidden={hasVisibleLabel ? \"true\" : undefined}\n className={cn(\n \"inline-block shrink-0 rounded-full\",\n SIZE[size],\n DOT_COLOR[status],\n shouldPulse && \"animate-pulse\",\n )}\n />\n );\n\n if (!hasVisibleLabel) {\n return (\n <span\n ref={ref}\n // biome-ignore lint/a11y/useSemanticElements: StatusDot is a generic inline indicator; there is no HTML element with implicit role=\"status\" that is an inline span. The native <output> is block-level and form-bound, which doesn't fit this use case.\n role=\"status\"\n aria-label={effectiveAriaLabel}\n className={cn(\"inline-flex items-center\", className)}\n {...props}\n >\n {dot}\n </span>\n );\n }\n\n return (\n <span\n ref={ref}\n aria-label={effectiveAriaLabel}\n className={cn(\n \"inline-flex items-center gap-1.5 font-mono text-label\",\n LABEL_COLOR[status],\n className,\n )}\n {...props}\n >\n {dot}\n <span>{label}</span>\n </span>\n );\n },\n);\nStatusDot.displayName = \"StatusDot\";\n\nexport { StatusDot };\n"
18
+ }
19
+ ]
20
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "table",
4
+ "type": "registry:ui",
5
+ "title": "Table",
6
+ "description": "Semantic data-table primitive with sub-components (Table.Header, Table.Body, Table.Row, Table.Cell, Table.HeaderCell). Supports density (default | compact via Context), per-cell align (left | center | right), numeric cells (font-mono tabular-nums), and sortable header cells (onSort + sortDirection with ChevronUp/ChevronDown affordance + aria-sort).",
7
+ "dependencies": [
8
+ "lucide-react"
9
+ ],
10
+ "registryDependencies": [
11
+ "https://usetheodev.github.io/theo-ui/r/cn.json",
12
+ "https://usetheodev.github.io/theo-ui/r/tailwind-preset.json"
13
+ ],
14
+ "files": [
15
+ {
16
+ "path": "components/primitives/table/table.tsx",
17
+ "type": "registry:ui",
18
+ "target": "components/ui/table.tsx",
19
+ "content": "import { ChevronDown, ChevronUp } from \"lucide-react\";\nimport { createContext, forwardRef, useContext } from \"react\";\nimport type { HTMLAttributes, TdHTMLAttributes, ThHTMLAttributes } from \"react\";\nimport { cn } from \"@/lib/cn\";\n\n/**\n * Table — semantic data table primitive with sub-components.\n *\n * Composition:\n * <Table density=\"default\">\n * <Table.Header>\n * <Table.Row>\n * <Table.HeaderCell>Date</Table.HeaderCell>\n * <Table.HeaderCell align=\"right\">Amount</Table.HeaderCell>\n * </Table.Row>\n * </Table.Header>\n * <Table.Body>\n * <Table.Row>\n * <Table.Cell>2026-05-23</Table.Cell>\n * <Table.Cell align=\"right\" numeric>$ 42.00</Table.Cell>\n * </Table.Row>\n * </Table.Body>\n * </Table>\n *\n * density propagates via Context so Cells pick up vertical padding without\n * prop drilling. Sub-components are attached as static properties on the\n * root (`Table.Header`, etc.) — single import surface.\n *\n * Sortable header: pass `onSort` + `sortDirection`. The HeaderCell renders\n * the sort affordance (ChevronUp/ChevronDown) and triggers the consumer\n * callback. `sortDirection` without `onSort` is a no-op (header stays\n * static); `sortDirection=\"none\"` with `onSort` shows a dimmed affordance.\n */\n\ntype TableDensity = \"default\" | \"compact\";\ntype AlignKind = \"left\" | \"center\" | \"right\";\ntype SortDirection = \"asc\" | \"desc\" | \"none\";\n\nconst TableDensityContext = createContext<TableDensity>(\"default\");\n\nconst alignClass: Record<AlignKind, string> = {\n left: \"text-left\",\n center: \"text-center\",\n right: \"text-right\",\n};\n\nexport interface TableProps extends HTMLAttributes<HTMLTableElement> {\n density?: TableDensity;\n}\n\nconst Root = forwardRef<HTMLTableElement, TableProps>(\n ({ className, density = \"default\", children, ...props }, ref) => (\n <TableDensityContext.Provider value={density}>\n <table\n ref={ref}\n className={cn(\"w-full border-collapse font-sans text-body-sm\", className)}\n {...props}\n >\n {children}\n </table>\n </TableDensityContext.Provider>\n ),\n);\nRoot.displayName = \"Table\";\n\nconst Header = forwardRef<HTMLTableSectionElement, HTMLAttributes<HTMLTableSectionElement>>(\n ({ className, ...props }, ref) => (\n <thead\n ref={ref}\n className={cn(\n \"border-border/40 border-b text-label-caps text-muted-foreground uppercase tracking-wider\",\n className,\n )}\n {...props}\n />\n ),\n);\nHeader.displayName = \"Table.Header\";\n\nconst Body = forwardRef<HTMLTableSectionElement, HTMLAttributes<HTMLTableSectionElement>>(\n ({ className, ...props }, ref) => (\n <tbody ref={ref} className={cn(\"text-foreground\", className)} {...props} />\n ),\n);\nBody.displayName = \"Table.Body\";\n\nconst Row = forwardRef<HTMLTableRowElement, HTMLAttributes<HTMLTableRowElement>>(\n ({ className, ...props }, ref) => (\n <tr\n ref={ref}\n className={cn(\n \"border-border/20 border-b transition-colors last:border-0 hover:bg-muted/40\",\n className,\n )}\n {...props}\n />\n ),\n);\nRow.displayName = \"Table.Row\";\n\nexport interface TableCellProps extends TdHTMLAttributes<HTMLTableCellElement> {\n align?: AlignKind;\n numeric?: boolean;\n}\n\nconst Cell = forwardRef<HTMLTableCellElement, TableCellProps>(\n ({ className, align = \"left\", numeric, children, ...props }, ref) => {\n const density = useContext(TableDensityContext);\n return (\n <td\n ref={ref}\n className={cn(\n \"px-3\",\n density === \"compact\" ? \"py-1.5\" : \"py-3\",\n alignClass[align],\n numeric && \"font-mono tabular-nums\",\n className,\n )}\n {...props}\n >\n {children}\n </td>\n );\n },\n);\nCell.displayName = \"Table.Cell\";\n\nexport interface TableHeaderCellProps extends ThHTMLAttributes<HTMLTableCellElement> {\n align?: AlignKind;\n /** When provided, header becomes a sort trigger. */\n onSort?: () => void;\n /** Current sort state for this column. */\n sortDirection?: SortDirection;\n}\n\nconst HeaderCell = forwardRef<HTMLTableCellElement, TableHeaderCellProps>(\n ({ className, align = \"left\", onSort, sortDirection = \"none\", children, ...props }, ref) => {\n const sortAffordance =\n onSort !== undefined ? (\n <span className=\"ml-1 inline-flex flex-col\">\n <ChevronUp\n aria-hidden=\"true\"\n className={cn(\"-mb-1 size-3\", sortDirection === \"asc\" ? \"opacity-100\" : \"opacity-30\")}\n />\n <ChevronDown\n aria-hidden=\"true\"\n className={cn(\"size-3\", sortDirection === \"desc\" ? \"opacity-100\" : \"opacity-30\")}\n />\n </span>\n ) : null;\n\n const ariaSort: ThHTMLAttributes<HTMLTableCellElement>[\"aria-sort\"] =\n onSort === undefined\n ? undefined\n : sortDirection === \"asc\"\n ? \"ascending\"\n : sortDirection === \"desc\"\n ? \"descending\"\n : \"none\";\n\n return (\n <th\n ref={ref}\n scope=\"col\"\n aria-sort={ariaSort}\n className={cn(\n \"px-3 py-2.5 font-medium\",\n alignClass[align],\n align === \"right\" && \"[&_button]:justify-end\",\n className,\n )}\n {...props}\n >\n {onSort !== undefined ? (\n <button\n type=\"button\"\n onClick={onSort}\n className={cn(\n \"inline-flex items-center gap-1\",\n \"text-label-caps uppercase tracking-wider\",\n \"transition-colors hover:text-foreground\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n )}\n >\n {children}\n {sortAffordance}\n </button>\n ) : (\n children\n )}\n </th>\n );\n },\n);\nHeaderCell.displayName = \"Table.HeaderCell\";\n\ntype TableRoot = typeof Root & {\n Header: typeof Header;\n Body: typeof Body;\n Row: typeof Row;\n Cell: typeof Cell;\n HeaderCell: typeof HeaderCell;\n};\n\nconst Table: TableRoot = Object.assign(Root, { Header, Body, Row, Cell, HeaderCell });\n\nexport { Table };\n"
20
+ }
21
+ ]
22
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "timestamp",
4
+ "type": "registry:ui",
5
+ "title": "Timestamp",
6
+ "description": "Accessible <time> primitive with relative/absolute/both formats, auto-refresh interval (default 60s, 0 disables), native title tooltip with absolute time, and aria-label that always carries the full date. Built on Intl.RelativeTimeFormat (zero deps). value accepts ISO string, Date, or Unix ms (NOT seconds). Invalid date renders empty element; invalid locale falls back to default with dev warning.",
7
+ "dependencies": [],
8
+ "registryDependencies": [
9
+ "https://usetheodev.github.io/theo-ui/r/cn.json",
10
+ "https://usetheodev.github.io/theo-ui/r/tailwind-preset.json"
11
+ ],
12
+ "files": [
13
+ {
14
+ "path": "components/primitives/timestamp/timestamp.tsx",
15
+ "type": "registry:ui",
16
+ "target": "components/ui/timestamp.tsx",
17
+ "content": "import { forwardRef, useEffect, useState } from \"react\";\nimport type { TimeHTMLAttributes } from \"react\";\nimport { cn } from \"@/lib/cn\";\n\n/**\n * Timestamp — accessible relative/absolute time primitive.\n *\n * Renders a semantic `<time datetime>` element. Format modes:\n * - `relative` (default) — \"just now\", \"5 minutes ago\", \"2 hours ago\",\n * \"Dec 5\" (>7d), \"Dec 5, 2024\" (different year)\n * - `absolute` — full localized date+time\n * - `both` — \"Dec 5, 2026 (2 hours ago)\"\n *\n * Uses zero-dep `Intl.RelativeTimeFormat`. The tooltip on hover is the\n * HTML `title` attribute (not the `<Tooltip>` component) — keeps this\n * file a true primitive without sibling-primitive imports.\n *\n * Auto-refreshes via `setInterval` (default 60_000ms); pass\n * `refreshInterval={0}` to disable. `aria-label` always carries the\n * absolute time so screen readers read \"May 23, 2026 14:32 — posted\n * 2 hours ago\".\n *\n * @param value Source date — ISO string, Date object, or **Unix ms**\n * (NOT seconds). Passing seconds renders ~1970.\n */\nexport interface TimestampProps extends Omit<TimeHTMLAttributes<HTMLTimeElement>, \"children\"> {\n value: string | Date | number;\n format?: \"relative\" | \"absolute\" | \"both\";\n /** Auto-refresh interval when format=relative. Default 60000. 0 disables. */\n refreshInterval?: number;\n /** Locale for absolute formatting + Intl.RelativeTimeFormat. Default browser locale. */\n locale?: string;\n /** When true, omit the `title` tooltip. */\n noTooltip?: boolean;\n}\n\nfunction toDate(value: string | Date | number): Date | null {\n const d = value instanceof Date ? value : new Date(value);\n return Number.isNaN(d.getTime()) ? null : d;\n}\n\nconst SEVEN_DAYS_MS = 7 * 24 * 60 * 60 * 1000;\nconst UNITS: Array<{ unit: Intl.RelativeTimeFormatUnit; ms: number }> = [\n { unit: \"year\", ms: 365 * 24 * 60 * 60 * 1000 },\n { unit: \"month\", ms: 30 * 24 * 60 * 60 * 1000 },\n { unit: \"day\", ms: 24 * 60 * 60 * 1000 },\n { unit: \"hour\", ms: 60 * 60 * 1000 },\n { unit: \"minute\", ms: 60 * 1000 },\n];\n\nfunction safeRelativeFormatter(locale: string | undefined): Intl.RelativeTimeFormat | null {\n try {\n return new Intl.RelativeTimeFormat(locale, { numeric: \"auto\" });\n } catch {\n // EC-8: invalid locale tag — fall back to default locale.\n if (process.env.NODE_ENV !== \"production\") {\n // biome-ignore lint/suspicious/noConsole: dev-only diagnostic.\n console.warn(`<Timestamp locale=\"${locale}\">: invalid locale tag, falling back to default.`);\n }\n try {\n return new Intl.RelativeTimeFormat(undefined, { numeric: \"auto\" });\n } catch {\n return null;\n }\n }\n}\n\nfunction safeAbsoluteFormat(date: Date, locale: string | undefined, withYear: boolean): string {\n try {\n return date.toLocaleDateString(locale, {\n month: \"short\",\n day: \"numeric\",\n ...(withYear ? { year: \"numeric\" } : {}),\n });\n } catch {\n return date.toLocaleDateString(undefined, {\n month: \"short\",\n day: \"numeric\",\n ...(withYear ? { year: \"numeric\" } : {}),\n });\n }\n}\n\nfunction formatRelative(date: Date, now: Date, locale: string | undefined): string {\n const diffMs = date.getTime() - now.getTime();\n const absMs = Math.abs(diffMs);\n\n if (absMs < 60_000) return \"just now\";\n\n if (diffMs < 0 && absMs > SEVEN_DAYS_MS) {\n const sameYear = date.getFullYear() === now.getFullYear();\n return safeAbsoluteFormat(date, locale, !sameYear);\n }\n\n const rtf = safeRelativeFormatter(locale);\n if (rtf === null) {\n return safeAbsoluteFormat(date, locale, date.getFullYear() !== now.getFullYear());\n }\n\n for (const { unit, ms } of UNITS) {\n if (absMs >= ms) {\n return rtf.format(Math.round(diffMs / ms), unit);\n }\n }\n return \"just now\";\n}\n\nfunction formatAbsolute(date: Date, locale: string | undefined): string {\n try {\n return date.toLocaleString(locale, {\n year: \"numeric\",\n month: \"short\",\n day: \"numeric\",\n hour: \"2-digit\",\n minute: \"2-digit\",\n });\n } catch {\n return date.toLocaleString(undefined, {\n year: \"numeric\",\n month: \"short\",\n day: \"numeric\",\n hour: \"2-digit\",\n minute: \"2-digit\",\n });\n }\n}\n\nconst Timestamp = forwardRef<HTMLTimeElement, TimestampProps>(\n (\n {\n className,\n value,\n format = \"relative\",\n refreshInterval = 60_000,\n locale,\n noTooltip,\n ...props\n },\n ref,\n ) => {\n const date = toDate(value);\n const [now, setNow] = useState<Date>(() => new Date());\n\n useEffect(() => {\n if (format !== \"relative\" || refreshInterval === 0 || date === null) return;\n const id = setInterval(() => setNow(new Date()), refreshInterval);\n return () => clearInterval(id);\n }, [format, refreshInterval, date]);\n\n if (date === null) {\n return <time ref={ref} className={cn(className)} suppressHydrationWarning {...props} />;\n }\n\n const iso = date.toISOString();\n const absolute = formatAbsolute(date, locale);\n const relative = formatRelative(date, now, locale);\n const visibleText =\n format === \"absolute\" ? absolute : format === \"both\" ? `${absolute} (${relative})` : relative;\n\n return (\n <time\n ref={ref}\n dateTime={iso}\n title={noTooltip ? undefined : absolute}\n aria-label={absolute}\n suppressHydrationWarning\n className={cn(className)}\n {...props}\n >\n {visibleText}\n </time>\n );\n },\n);\nTimestamp.displayName = \"Timestamp\";\n\nexport { Timestamp };\n"
18
+ }
19
+ ]
20
+ }