@hanzo/ui 4.6.0 → 4.8.2

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 (184) hide show
  1. package/assets/general.tsx +1 -1
  2. package/assets/hanzo-logo.tsx +3 -1
  3. package/assets/index.ts +119 -5
  4. package/blocks/auth/index.ts +6 -0
  5. package/blocks/auth/login-2fa.tsx +165 -0
  6. package/blocks/auth/login-basic.tsx +94 -0
  7. package/blocks/auth/login-social.tsx +148 -0
  8. package/blocks/auth/magic-link.tsx +129 -0
  9. package/blocks/auth/password-reset.tsx +97 -0
  10. package/blocks/auth/signup.tsx +157 -0
  11. package/blocks/data-display/activity-feed.tsx +242 -0
  12. package/blocks/data-display/data-table.tsx +235 -0
  13. package/blocks/data-display/stats-grid.tsx +194 -0
  14. package/blocks/ecommerce/checkout.tsx +242 -0
  15. package/blocks/ecommerce/index.ts +7 -0
  16. package/blocks/ecommerce/product-detail.tsx +257 -0
  17. package/blocks/ecommerce/product-grid.tsx +148 -0
  18. package/blocks/ecommerce/shopping-cart.tsx +181 -0
  19. package/blocks/marketing/cta-section.tsx +207 -0
  20. package/blocks/marketing/faq.tsx +159 -0
  21. package/blocks/marketing/features-grid.tsx +156 -0
  22. package/blocks/marketing/hero-section.tsx +192 -0
  23. package/blocks/marketing/index.ts +6 -0
  24. package/blocks/marketing/pricing-table.tsx +121 -0
  25. package/blocks/marketing/testimonials.tsx +196 -0
  26. package/components/index.ts +4 -51
  27. package/dist/index.js +9351 -0
  28. package/dist/index.mjs +9340 -0
  29. package/dist/lib/utils.js +47 -0
  30. package/dist/lib/utils.mjs +28 -0
  31. package/dist/src/utils.js +47 -0
  32. package/dist/src/utils.mjs +28 -0
  33. package/dist/tailwind/index.js +2050 -0
  34. package/dist/tailwind/index.mjs +2019 -0
  35. package/dist/types/index.js +79 -0
  36. package/dist/types/index.mjs +56 -0
  37. package/dist/util/format-text.js +51 -0
  38. package/dist/util/format-text.mjs +32 -0
  39. package/dist/util/index.js +384 -0
  40. package/dist/util/index.mjs +363 -0
  41. package/frameworks/core/index.ts +6 -0
  42. package/frameworks/core/utils/index.ts +64 -0
  43. package/frameworks/react/components/button.tsx +26 -0
  44. package/frameworks/react/components/index.ts +5 -0
  45. package/frameworks/react/hooks/index.ts +5 -0
  46. package/frameworks/react/index.ts +9 -0
  47. package/frameworks/react/package.json +8 -0
  48. package/frameworks/react/utils/index.ts +2 -0
  49. package/frameworks/react-native/index.ts +9 -0
  50. package/frameworks/react-native/package.json +8 -0
  51. package/frameworks/registry.json +371 -0
  52. package/frameworks/setup.sh +69 -0
  53. package/frameworks/svelte/index.ts +9 -0
  54. package/frameworks/svelte/package.json +8 -0
  55. package/frameworks/tracker.json +1854 -0
  56. package/frameworks/vue/index.ts +9 -0
  57. package/frameworks/vue/package.json +8 -0
  58. package/package.json +192 -28
  59. package/primitives/accordion.tsx +1 -1
  60. package/primitives/alert-dialog.tsx +1 -1
  61. package/primitives/alert.tsx +1 -1
  62. package/primitives/avatar.tsx +1 -1
  63. package/primitives/badge.tsx +2 -1
  64. package/primitives/breadcrumb.tsx +1 -1
  65. package/primitives/button.tsx +37 -47
  66. package/primitives/card.tsx +1 -1
  67. package/primitives/carousel.tsx +3 -2
  68. package/primitives/chat/chat-input-area.tsx +5 -4
  69. package/primitives/chat/chat-input.tsx +2 -2
  70. package/primitives/chat/files-preview.tsx +5 -4
  71. package/primitives/chat/message-list.tsx +2 -1
  72. package/primitives/chat/sqlite-preview.tsx +8 -8
  73. package/primitives/checkbox.tsx +2 -1
  74. package/primitives/command.tsx +3 -1
  75. package/primitives/context-menu.tsx +1 -1
  76. package/primitives/dialog.tsx +6 -1
  77. package/primitives/drawer.tsx +4 -1
  78. package/primitives/dropdown-menu.tsx +1 -1
  79. package/primitives/file-uploader.tsx +4 -2
  80. package/primitives/form.tsx +1 -1
  81. package/primitives/hover-card.tsx +1 -1
  82. package/primitives/icons/github.tsx +2 -2
  83. package/primitives/icons/youtube-logo.tsx +1 -1
  84. package/primitives/index-common.ts +7 -6
  85. package/primitives/input-otp.tsx +1 -1
  86. package/primitives/input.tsx +2 -1
  87. package/primitives/label.tsx +2 -1
  88. package/primitives/markdown-preview.tsx +3 -0
  89. package/primitives/mermaid.tsx +13 -18
  90. package/primitives/next/image.tsx +2 -1
  91. package/primitives/next/inline-icon.tsx +14 -14
  92. package/primitives/next/media-stack.tsx +2 -19
  93. package/primitives/pagination.tsx +1 -1
  94. package/primitives/popover.tsx +4 -2
  95. package/primitives/progress.tsx +2 -1
  96. package/primitives/prompt-textarea.tsx +1 -1
  97. package/primitives/radio-group.tsx +1 -1
  98. package/primitives/scroll-area.tsx +1 -1
  99. package/primitives/search-input.tsx +1 -1
  100. package/primitives/select.tsx +1 -1
  101. package/primitives/separator.tsx +2 -1
  102. package/primitives/sheet.tsx +1 -1
  103. package/primitives/skeleton.tsx +1 -0
  104. package/primitives/slider.tsx +2 -1
  105. package/primitives/stepper.tsx +1 -1
  106. package/primitives/switch.tsx +2 -1
  107. package/primitives/table.tsx +1 -1
  108. package/primitives/tabs.tsx +1 -1
  109. package/primitives/textarea.tsx +2 -1
  110. package/primitives/textfield.tsx +1 -0
  111. package/primitives/toggle-group.tsx +1 -1
  112. package/primitives/toggle.tsx +1 -1
  113. package/primitives/tooltip.tsx +1 -1
  114. package/src/hooks/use-copy-clipboard.ts +1 -1
  115. package/src/index-lean.ts +87 -0
  116. package/src/index.ts +54 -0
  117. package/src/registry/api.ts +1 -1
  118. package/src/utils.ts +19 -1
  119. package/tailwind/tailwind.config.hanzo-preset.js +7 -7
  120. package/tailwind/typo-plugin/index.js +1 -1
  121. package/types/animation-def.ts +1 -1
  122. package/types/index.ts +2 -1
  123. package/util/blob.ts +9 -4
  124. package/util/date.ts +2 -1
  125. package/util/format-text.ts +2 -1
  126. package/util/index.ts +103 -0
  127. package/util/spread-to-transform.ts +9 -8
  128. package/MCP-INSTRUCTIONS.md +0 -73
  129. package/README-MCP.md +0 -175
  130. package/dist/button.d.ts +0 -1
  131. package/dist/button.js +0 -1
  132. package/dist/hooks/index.d.ts +0 -7
  133. package/dist/hooks/index.js +0 -7
  134. package/dist/hooks/use-click-away.d.ts +0 -2
  135. package/dist/hooks/use-click-away.js +0 -23
  136. package/dist/hooks/use-combined-refs.d.ts +0 -3
  137. package/dist/hooks/use-combined-refs.js +0 -18
  138. package/dist/hooks/use-copy-clipboard.d.ts +0 -9
  139. package/dist/hooks/use-copy-clipboard.js +0 -21
  140. package/dist/hooks/use-debounce.d.ts +0 -1
  141. package/dist/hooks/use-debounce.js +0 -13
  142. package/dist/hooks/use-fill-ids.d.ts +0 -8
  143. package/dist/hooks/use-fill-ids.js +0 -20
  144. package/dist/hooks/use-map.d.ts +0 -1
  145. package/dist/hooks/use-map.js +0 -20
  146. package/dist/hooks/use-measure.d.ts +0 -8
  147. package/dist/hooks/use-measure.js +0 -25
  148. package/dist/hooks/use-reverse-video-playback.d.ts +0 -1
  149. package/dist/hooks/use-reverse-video-playback.js +0 -41
  150. package/dist/hooks/use-scroll-restoration.d.ts +0 -8
  151. package/dist/hooks/use-scroll-restoration.js +0 -36
  152. package/dist/mcp/enhanced-server.d.ts +0 -29
  153. package/dist/mcp/enhanced-server.js +0 -1128
  154. package/dist/mcp/index.d.ts +0 -28
  155. package/dist/mcp/index.js +0 -436
  156. package/dist/registry/api.d.ts +0 -37
  157. package/dist/registry/api.js +0 -129
  158. package/dist/registry/index.d.ts +0 -353
  159. package/dist/registry/index.js +0 -45
  160. package/dist/utils.d.ts +0 -1
  161. package/dist/utils.js +0 -1
  162. package/environment.d.ts +0 -6
  163. package/public/r/accordion.json +0 -11
  164. package/public/r/alert.json +0 -11
  165. package/public/r/avatar.json +0 -11
  166. package/public/r/badge.json +0 -11
  167. package/public/r/button.json +0 -11
  168. package/public/r/card.json +0 -11
  169. package/public/r/checkbox.json +0 -11
  170. package/public/r/default.json +0 -6
  171. package/public/r/dialog.json +0 -11
  172. package/public/r/input.json +0 -11
  173. package/public/r/label.json +0 -11
  174. package/public/r/new-york.json +0 -6
  175. package/public/r/popover.json +0 -11
  176. package/public/r/select.json +0 -11
  177. package/public/r/table.json +0 -11
  178. package/public/r/tabs.json +0 -11
  179. package/public/r/toast.json +0 -11
  180. package/registry.json +0 -184
  181. package/test/test-registry.js +0 -73
  182. package/test-imports.mjs +0 -19
  183. package/tsconfig.json +0 -22
  184. package/utils.ts +0 -9
package/src/index.ts ADDED
@@ -0,0 +1,54 @@
1
+ /**
2
+ * @hanzo/ui - Complete UI Library
3
+ *
4
+ * This file exports all components, utilities, hooks, and blocks from the @hanzo/ui library.
5
+ * Components are organized by category and support tree-shaking.
6
+ */
7
+
8
+ // Core utilities - must be imported first
9
+ export { cn } from './utils'
10
+ export * from './utils'
11
+
12
+ // Registry exports for tooling
13
+ export * from './registry'
14
+
15
+ // MCP (Model Context Protocol) support
16
+ export * from './mcp'
17
+
18
+ // Hooks
19
+ export * from './hooks'
20
+
21
+ // Re-export all primitives
22
+ export * from '../primitives/index-next'
23
+ export * from '../primitives/index-common'
24
+
25
+ // Re-export assets
26
+ export * from '../assets'
27
+
28
+ // Re-export blocks
29
+ export * from '../blocks'
30
+
31
+ // Re-export components (if different from primitives)
32
+ export * from '../components'
33
+
34
+ // Re-export types
35
+ export * from '../types'
36
+
37
+ // Re-export utilities
38
+ export * from '../util'
39
+ export * from '../util/index-client'
40
+
41
+ // Re-export tailwind configuration helpers
42
+ export * from '../tailwind'
43
+
44
+ // Theme provider for brand support
45
+ export { ThemeProvider } from '../style/theme-provider'
46
+
47
+ // Framework-specific exports
48
+ export * as React from '../frameworks/react'
49
+ export * as Vue from '../frameworks/vue'
50
+ export * as Svelte from '../frameworks/svelte'
51
+ export * as ReactNative from '../frameworks/react-native'
52
+
53
+ // Export version
54
+ export const VERSION = '4.8.0'
@@ -1,4 +1,4 @@
1
- import { registryItemSchema, RegistryItem, Registry } from "./schemas"
1
+ import { registryItemSchema, RegistryItem, Registry } from "./index"
2
2
  import { z } from "zod"
3
3
 
4
4
  const registryCache = new Map<string, Promise<any>>()
package/src/utils.ts CHANGED
@@ -1 +1,19 @@
1
- export * from '../../../app/lib/utils'
1
+ import { clsx, type ClassValue } from "clsx"
2
+ import { twMerge } from "tailwind-merge"
3
+
4
+ export function cn(...inputs: ClassValue[]) {
5
+ return twMerge(clsx(inputs))
6
+ }
7
+
8
+ export function formatDate(input: string | number): string {
9
+ const date = new Date(input)
10
+ return date.toLocaleDateString("en-US", {
11
+ month: "long",
12
+ day: "numeric",
13
+ year: "numeric",
14
+ })
15
+ }
16
+
17
+ export function absoluteUrl(path: string) {
18
+ return `${process.env.NEXT_PUBLIC_APP_URL || ''}${path}`
19
+ }
@@ -2,13 +2,13 @@ import animatePlugin from 'tailwindcss-animate'
2
2
  import containerQueriesPlugin from '@tailwindcss/container-queries'
3
3
  import tailwindInteractionMediaPlugin from 'tailwindcss-interaction-media'
4
4
 
5
- import colors from './colors.tailwind'
6
- import safelist from './safelist.tailwind'
7
- import screens from './screens.tailwind'
8
- import spacing from './spacing.tailwind'
9
- import fontSize from './fontSize.tailwind'
10
- import fontFamily from './fontFamily.tailwind'
11
- import zIndex from './z-index.tailwind'
5
+ import colors from './colors.tailwind.js'
6
+ import safelist from './safelist.tailwind.js'
7
+ import screens from './screens.tailwind.js'
8
+ import spacing from './spacing.tailwind.js'
9
+ import fontSize from './fontSize.tailwind.ts'
10
+ import fontFamily from './fontFamily.tailwind.ts'
11
+ import zIndex from './z-index.tailwind.js'
12
12
  import typographyPlugin from './typo-plugin'
13
13
 
14
14
  export default {
@@ -1,4 +1,4 @@
1
- import plugin from 'tailwindcss/plugin'
1
+ import plugin from 'tailwindcss/plugin.js'
2
2
  import merge from 'lodash.merge'
3
3
  import castArray from 'lodash.castarray'
4
4
  import getStyles from './get-plugin-styles'
@@ -1,3 +1,3 @@
1
1
  type AnimationDef = string
2
2
 
3
- export { AnimationDef as default }
3
+ export type { AnimationDef as default }
package/types/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
 
2
2
  export type { default as AnimationDef } from './animation-def'
3
- export { Breakpoint, Breakpoints } from './breakpoints'
3
+ export type { Breakpoint } from './breakpoints'
4
+ export { Breakpoints } from './breakpoints'
4
5
  export type { default as BulletItem } from './bullet-item'
5
6
 
6
7
  export type {
package/util/blob.ts CHANGED
@@ -1,5 +1,3 @@
1
- import { Buffer } from 'buffer';
2
-
3
1
  export const blobToBase64 = (blob: Blob): Promise<string> => {
4
2
  const reader = new FileReader();
5
3
  reader.readAsDataURL(blob);
@@ -23,6 +21,13 @@ export const dataUrlToFile = (
23
21
  return undefined;
24
22
  }
25
23
  const mime = mimeArr[1];
26
- const buff = Buffer.from(arr[1], 'base64');
27
- return new File([buff], filename, { type: mime });
24
+
25
+ // Convert base64 to binary string, then to Uint8Array (browser-compatible)
26
+ const binaryString = atob(arr[1]);
27
+ const bytes = new Uint8Array(binaryString.length);
28
+ for (let i = 0; i < binaryString.length; i++) {
29
+ bytes[i] = binaryString.charCodeAt(i);
30
+ }
31
+
32
+ return new File([bytes], filename, { type: mime });
28
33
  };
package/util/date.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { FormattedMessage } from '@hanzo_network/hanzo-node-state/v2/queries/getChatConversation/types';
1
+ // import { FormattedMessage } from '@hanzo_network/hanzo-node-state/v2/queries/getChatConversation/types';
2
+ type FormattedMessage = any;
2
3
 
3
4
  export type ChatConversationMessage = {
4
5
  hash: string;
@@ -1,4 +1,5 @@
1
- import { HanzoToolHeader } from '@hanzo_network/hanzo-message-ts/api/tools/types';
1
+ // import { HanzoToolHeader } from '@hanzo_network/hanzo-message-ts/api/tools/types';
2
+ type HanzoToolHeader = any;
2
3
 
3
4
  export const formatText = (text: string) => {
4
5
  const camelToSpaces = text.replace(/([a-z])([A-Z])/g, '$1 $2');
package/util/index.ts CHANGED
@@ -1,3 +1,4 @@
1
+ // Export all utilities
1
2
  export * from './date';
2
3
  export * from './file';
3
4
  export * from './create-shadow-root';
@@ -7,3 +8,105 @@ export * from './copy-to-clipboard';
7
8
  export * from './format-text';
8
9
  export * from './toasts';
9
10
  export * from './debounce';
11
+ export { default as spreadToTransform } from './spread-to-transform';
12
+ export * from './specifier';
13
+ export * from './number-abbreviate';
14
+ export * from './format-to-max-char';
15
+ export * from './format-and-abbreviate-as-currency';
16
+ export * from './two-way-map';
17
+
18
+ // Import and re-export cn utility and other common functions
19
+ import { type ClassValue, clsx } from 'clsx';
20
+ import { twMerge } from 'tailwind-merge';
21
+
22
+ export function cn(...inputs: ClassValue[]) {
23
+ return twMerge(clsx(inputs));
24
+ }
25
+
26
+ export function formatDate(input: string | number): string {
27
+ const date = new Date(input);
28
+ return date.toLocaleDateString('en-US', {
29
+ month: 'long',
30
+ day: 'numeric',
31
+ year: 'numeric',
32
+ });
33
+ }
34
+
35
+ export function absoluteUrl(path: string): string {
36
+ if (typeof window !== 'undefined') return path;
37
+ if (process.env.VERCEL_URL) return `https://${process.env.VERCEL_URL}${path}`;
38
+ return `http://localhost:${process.env.PORT ?? 3000}${path}`;
39
+ }
40
+
41
+ // Export VariantProps type from class-variance-authority
42
+ export type { VariantProps } from 'class-variance-authority';
43
+
44
+ // For backward compatibility with components importing from util
45
+ export function constrain(value: number, min: number, max: number): number;
46
+ export function constrain(dim: { w: number; h: number }, constrainTo: { w: number; h: number }): { w: number; h: number };
47
+ export function constrain(
48
+ value: number | { w: number; h: number },
49
+ minOrConstrainTo: number | { w: number; h: number },
50
+ max?: number
51
+ ): number | { w: number; h: number } {
52
+ if (typeof value === 'number' && typeof minOrConstrainTo === 'number' && typeof max === 'number') {
53
+ return Math.min(Math.max(value, minOrConstrainTo), max);
54
+ }
55
+
56
+ if (typeof value === 'object' && typeof minOrConstrainTo === 'object') {
57
+ const dim = value;
58
+ const constrainTo = minOrConstrainTo;
59
+ const aspectRatio = dim.w / dim.h;
60
+ const constrainAspectRatio = constrainTo.w / constrainTo.h;
61
+
62
+ if (aspectRatio > constrainAspectRatio) {
63
+ // constrain by width
64
+ return {
65
+ w: constrainTo.w,
66
+ h: constrainTo.w / aspectRatio
67
+ };
68
+ } else {
69
+ // constrain by height
70
+ return {
71
+ w: constrainTo.h * aspectRatio,
72
+ h: constrainTo.h
73
+ };
74
+ }
75
+ }
76
+
77
+ throw new Error('Invalid parameters for constrain function');
78
+ }
79
+
80
+ // Export round, pxToRem, pxToEm for tailwind plugin
81
+ export function round(value: number): number {
82
+ return Math.round(value * 100) / 100;
83
+ }
84
+
85
+ export function pxToRem(px: number, base = 16): string {
86
+ return `${px / base}rem`;
87
+ }
88
+
89
+ export function pxToEm(px: number, base = 16): string {
90
+ return `${px / base}em`;
91
+ }
92
+
93
+ // Missing utility functions
94
+ export function containsToken(text: string, token: string): boolean {
95
+ return text.toLowerCase().includes(token.toLowerCase());
96
+ }
97
+
98
+ export function ldMerge(...objects: any[]): any {
99
+ // Simple merge function for lodash compatibility
100
+ const result = {};
101
+ for (const obj of objects) {
102
+ if (obj && typeof obj === 'object') {
103
+ Object.assign(result, obj);
104
+ }
105
+ }
106
+ return result;
107
+ }
108
+
109
+ export function asNum(value: any, defaultValue = 0): number {
110
+ const num = Number(value);
111
+ return isNaN(num) ? defaultValue : num;
112
+ }
@@ -1,19 +1,18 @@
1
1
  import type { MediaTransform } from '../types'
2
2
 
3
- export default (t: MediaTransform) => {
4
-
5
- let transformStrings: string[] = []
3
+ export function spreadToTransform(t: MediaTransform) {
4
+ let transformStrings: string[] = []
6
5
  const scaleVal = 'scale' in t ? t.scale : undefined
7
6
  if (scaleVal) {
8
7
  if (typeof scaleVal === 'number') {
9
- transformStrings.push(`scale(${scaleVal})`)
8
+ transformStrings.push(`scale(${scaleVal})`)
10
9
  }
11
10
  else if (
12
- Array.isArray(scaleVal) &&
13
- scaleVal.length == 2 &&
11
+ Array.isArray(scaleVal) &&
12
+ scaleVal.length == 2 &&
14
13
  typeof scaleVal[0] === 'number'
15
14
  ) {
16
- transformStrings.push(`scale(${scaleVal[0]}, ${scaleVal[1]})`)
15
+ transformStrings.push(`scale(${scaleVal[0]}, ${scaleVal[1]})`)
17
16
  }
18
17
  else {
19
18
  throw new Error("parsing MediaTransform: Unrecognized value for 'scale'!")
@@ -21,4 +20,6 @@ export default (t: MediaTransform) => {
21
20
  }
22
21
 
23
22
  return transformStrings.length > 0 ? { transform: transformStrings.join(' ') } : {}
24
- }
23
+ }
24
+
25
+ export default spreadToTransform
@@ -1,73 +0,0 @@
1
- # Using @hanzo/ui with AI Assistants
2
-
3
- This guide explains how to use @hanzo/ui with AI assistants through the Model Context Protocol (MCP).
4
-
5
- ## Getting Started
6
-
7
- 1. Install the package:
8
-
9
- ```bash
10
- npm install @hanzo/ui
11
- ```
12
-
13
- 2. Start the MCP server:
14
-
15
- ```bash
16
- npx @hanzo/ui registry:mcp
17
- ```
18
-
19
- 3. Configure your AI assistant to use the server.
20
-
21
- ## Available Commands
22
-
23
- - **Initialize a new project**:
24
- ```bash
25
- npx @hanzo/ui init --style=default
26
- ```
27
-
28
- - **List available components**:
29
- ```bash
30
- npx @hanzo/ui list
31
- ```
32
-
33
- - **Add a component**:
34
- ```bash
35
- npx @hanzo/ui add button
36
- ```
37
-
38
- ## Using with LLMs
39
-
40
- AI Assistants like Claude or ChatGPT can help you explore and use the components. Just describe what you need, and the AI can guide you through:
41
-
42
- - Finding the right component
43
- - Installing and configuring it
44
- - Using it in your project
45
-
46
- Example prompt: "I need a dropdown menu component for my React project. Can you help me find and set it up using @hanzo/ui?"
47
-
48
- ## Registry Configuration
49
-
50
- You can create a custom registry for your components, making them available through the same interface. To create a registry:
51
-
52
- 1. Set up the registry structure
53
- 2. Run the update-registry script
54
- 3. Host the registry files
55
- 4. Point to your custom registry:
56
-
57
- ```bash
58
- npx @hanzo/ui registry:mcp --registry=https://your-registry-url.com/registry.json
59
- ```
60
-
61
- ## HTTP Mode
62
-
63
- For web-based applications, you can run the MCP server in HTTP mode:
64
-
65
- ```bash
66
- npx @hanzo/ui registry:mcp --http --port=3333
67
- ```
68
-
69
- This exposes an HTTP endpoint at http://localhost:3333 that you can use to communicate with the MCP server.
70
-
71
- ## Learn More
72
-
73
- For detailed documentation, see [README-MCP.md](./README-MCP.md) or visit the [Hanzo UI website](https://ui.hanzo.ai).
package/README-MCP.md DELETED
@@ -1,175 +0,0 @@
1
- # Hanzo UI with MCP Support
2
-
3
- This implementation provides Model Context Protocol (MCP) support for the Hanzo UI library, enabling AI assistants to interact with the component registry based on hanzo/ui.
4
-
5
- ## Quick Start
6
-
7
- ```bash
8
- # Run with npx (recommended)
9
- npx @hanzo/ui registry:mcp
10
-
11
- # Or set a custom registry URL
12
- npx @hanzo/ui registry:mcp --registry=https://ui.hanzo.ai/registry/registry.json
13
-
14
- # Run in HTTP mode instead of stdio
15
- npx @hanzo/ui registry:mcp --http --port=3333
16
- ```
17
-
18
- ## Setup and Usage
19
-
20
- ### Configure Your LLM Tool
21
-
22
- To configure your AI assistant or LLM to use the Hanzo UI MCP server, add the following configuration:
23
-
24
- ```json
25
- {
26
- "name": "hanzo-ui",
27
- "command": "npx @hanzo/ui registry:mcp"
28
- }
29
- ```
30
-
31
- ### Available Tools
32
-
33
- The MCP server provides the following tools for AI assistants:
34
-
35
- 1. `init` - Initialize a new project using @hanzo/ui components and styles
36
- 2. `list_components` - List all available components in the registry
37
- 3. `get_component` - Get detailed information about a specific component
38
- 4. `add_component` - Get instructions for adding a component to a project
39
- 5. `list_styles` - List all available styles in the registry
40
- 6. `search_registry` - Search the registry for components matching criteria
41
-
42
- ### Registry Configuration
43
-
44
- The registry URL can be configured by setting the `REGISTRY_URL` environment variable:
45
-
46
- ```bash
47
- export REGISTRY_URL="https://ui.hanzo.ai/registry/registry.json"
48
- npx @hanzo/ui registry:mcp
49
- ```
50
-
51
- Or by using the `--registry` command-line option:
52
-
53
- ```bash
54
- npx @hanzo/ui registry:mcp --registry=https://ui.hanzo.ai/registry/registry.json
55
- ```
56
-
57
- ## HTTP Mode
58
-
59
- You can run the MCP server in HTTP mode, which exposes the server over HTTP rather than stdio:
60
-
61
- ```bash
62
- npx @hanzo/ui registry:mcp --http --port=3333
63
- ```
64
-
65
- This allows you to access the MCP server directly from web applications or other HTTP clients.
66
-
67
- ## Developer Instructions
68
-
69
- ### Building from Source
70
-
71
- ```bash
72
- # Clone the repository
73
- git clone https://github.com/hanzoai/ui.git
74
- cd ui/pkg/ui
75
-
76
- # Install dependencies
77
- npm install
78
-
79
- # Build the package
80
- npm run build
81
-
82
- # Run the MCP server
83
- node ./bin/cli.js registry:mcp
84
- ```
85
-
86
- ### Project Structure
87
-
88
- - `/pkg/ui/mcp/`: MCP server implementation
89
- - `/pkg/ui/registry/`: Registry schema and API
90
- - `/pkg/ui/bin/`: CLI tools for running the MCP server
91
-
92
- ### Creating a Registry
93
-
94
- The registry is compatible with hanzo/ui's registry format. To create a custom registry:
95
-
96
- 1. Create a `registry.json` file using the schema from `/pkg/ui/registry/schema.ts`
97
- 2. Build the registry using a build script
98
- 3. Host the registry files on a web server or CDN
99
- 4. Point the MCP server to your custom registry using the `--registry` option
100
-
101
- ## How It Works
102
-
103
- The MCP server enables AI assistants to:
104
-
105
- 1. Discover and browse available components in your registry
106
- 2. Fetch detailed information about specific components
107
- 3. Provide instructions on adding components to projects
108
- 4. Initialize new projects with your component library
109
-
110
- This makes it easy for users to interact with your UI library through conversational interfaces.
111
-
112
- ## Example Interactions
113
-
114
- ### Initialize a Project
115
-
116
- ```
117
- Assistant: To create a new project with Hanzo UI components, you can run:
118
-
119
- npx create-next-app@latest my-app
120
- cd my-app
121
- npx @hanzo/ui@latest init
122
- ```
123
-
124
- ### Add a Component
125
-
126
- ```
127
- Assistant: To add the Button component to your project:
128
-
129
- npx @hanzo/ui@latest add button
130
-
131
- This will install the component and its dependencies.
132
- ```
133
-
134
- ### Search for Components
135
-
136
- ```
137
- Assistant: I found several form-related components:
138
- - form
139
- - input
140
- - checkbox
141
- - select
142
- - textarea
143
-
144
- Which one would you like to add to your project?
145
- ```
146
-
147
- ## Technical Details
148
-
149
- ### Registry Schema
150
-
151
- The registry schema is compatible with hanzo/ui and includes:
152
-
153
- - Component metadata (name, description, type)
154
- - Dependencies (npm packages)
155
- - Registry dependencies (other components)
156
- - Component files with source code
157
- - Category and subcategory information
158
-
159
- ### MCP Integration
160
-
161
- The MCP server implements the Model Context Protocol, enabling AI assistants to:
162
-
163
- - Query the registry for components
164
- - Get detailed information about components
165
- - Provide installation instructions
166
- - Generate example usage code
167
-
168
- ### Command-Line Interface
169
-
170
- The CLI provides options for:
171
-
172
- - Setting the registry URL
173
- - Running in HTTP mode
174
- - Specifying the port for HTTP mode
175
- - Verbose logging
package/dist/button.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from '../../../app/registry/new-york/ui/button';
package/dist/button.js DELETED
@@ -1 +0,0 @@
1
- export * from '../../../app/registry/new-york/ui/button';
@@ -1,7 +0,0 @@
1
- export * from './use-debounce';
2
- export * from './use-map';
3
- export * from './use-measure';
4
- export * from './use-click-away';
5
- export * from './use-copy-clipboard';
6
- export * from './use-reverse-video-playback';
7
- export * from './use-scroll-restoration';
@@ -1,7 +0,0 @@
1
- export * from './use-debounce';
2
- export * from './use-map';
3
- export * from './use-measure';
4
- export * from './use-click-away';
5
- export * from './use-copy-clipboard';
6
- export * from './use-reverse-video-playback';
7
- export * from './use-scroll-restoration';
@@ -1,2 +0,0 @@
1
- import React from 'react';
2
- export declare function useClickAway<T extends Element>(cb: (e: Event) => void): React.RefObject<T | null>;
@@ -1,23 +0,0 @@
1
- import React from 'react';
2
- export function useClickAway(cb) {
3
- const ref = React.useRef(null);
4
- const refCb = React.useRef(cb);
5
- React.useLayoutEffect(() => {
6
- refCb.current = cb;
7
- });
8
- React.useEffect(() => {
9
- const handler = (e) => {
10
- const element = ref.current;
11
- if (element && !element.contains(e.target)) {
12
- refCb.current(e);
13
- }
14
- };
15
- document.addEventListener('mousedown', handler);
16
- document.addEventListener('touchstart', handler);
17
- return () => {
18
- document.removeEventListener('mousedown', handler);
19
- document.removeEventListener('touchstart', handler);
20
- };
21
- }, []);
22
- return ref;
23
- }
@@ -1,3 +0,0 @@
1
- import type React from 'react';
2
- declare function useCombinedRefs<T>(...refs: React.ForwardedRef<T>[]): React.RefObject<T | null>;
3
- export { useCombinedRefs };
@@ -1,18 +0,0 @@
1
- import { useEffect, useRef } from 'react';
2
- function useCombinedRefs(...refs) {
3
- const targetRef = useRef(null);
4
- useEffect(() => {
5
- refs.forEach((ref) => {
6
- if (!ref)
7
- return;
8
- if (typeof ref === 'function') {
9
- ref(targetRef.current);
10
- }
11
- else {
12
- ref.current = targetRef.current;
13
- }
14
- });
15
- }, [refs]);
16
- return targetRef;
17
- }
18
- export { useCombinedRefs };
@@ -1,9 +0,0 @@
1
- type UseCopyClipboardProps = {
2
- string?: string;
3
- onCopyClipboard?: () => void;
4
- };
5
- export declare const useCopyClipboard: ({ string, onCopyClipboard, }: UseCopyClipboardProps) => {
6
- isCopied: boolean;
7
- onCopy: () => Promise<void>;
8
- };
9
- export {};
@@ -1,21 +0,0 @@
1
- import { useState } from 'react';
2
- import { copyToClipboard } from '../helpers';
3
- export const useCopyClipboard = ({ string, onCopyClipboard, }) => {
4
- const [isCopied, setIsCopied] = useState(false);
5
- let timeout;
6
- const onCopy = async () => {
7
- if (!string)
8
- return;
9
- const string_ = string.trim();
10
- if (onCopyClipboard && typeof onCopyClipboard === 'function') {
11
- onCopyClipboard();
12
- }
13
- else {
14
- await copyToClipboard(string_);
15
- }
16
- setIsCopied(true);
17
- clearTimeout(timeout);
18
- timeout = setTimeout(() => setIsCopied(false), 1000);
19
- };
20
- return { isCopied, onCopy };
21
- };
@@ -1 +0,0 @@
1
- export declare function useDebounce(value: string, delay?: number): string;