@hanzo/ui 4.5.4 → 4.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/README-MCP.md +3 -3
  2. package/README.md +229 -0
  3. package/assets/ai-icons.tsx +207 -0
  4. package/assets/crypto.tsx +33 -0
  5. package/assets/file-type-icon.tsx +66 -0
  6. package/assets/file.tsx +45 -0
  7. package/assets/general.tsx +2318 -0
  8. package/assets/hanzo-logo.svg +9 -0
  9. package/assets/hanzo-logo.tsx +15 -0
  10. package/assets/index.ts +8 -0
  11. package/assets/index.tsx +4 -0
  12. package/assets/llm-provider.tsx +1094 -0
  13. package/bin/create-registry.js +1 -1
  14. package/bin/test-mcp.sh +1 -1
  15. package/bin/update-registry.js +2 -2
  16. package/blocks/components/content.tsx +1 -1
  17. package/blocks/components/grid-block/index.tsx +1 -1
  18. package/blocks/components/screenful-block/content.tsx +1 -1
  19. package/blocks/components/screenful-block/poster-background.tsx +1 -1
  20. package/components/index.ts +56 -0
  21. package/dist/button.d.ts +1 -0
  22. package/dist/button.js +1 -0
  23. package/dist/hooks/index.d.ts +7 -0
  24. package/dist/hooks/index.js +7 -0
  25. package/dist/hooks/use-click-away.d.ts +2 -0
  26. package/dist/hooks/use-click-away.js +23 -0
  27. package/dist/hooks/use-combined-refs.d.ts +3 -0
  28. package/dist/hooks/use-combined-refs.js +18 -0
  29. package/dist/hooks/use-copy-clipboard.d.ts +9 -0
  30. package/dist/hooks/use-copy-clipboard.js +21 -0
  31. package/dist/hooks/use-debounce.d.ts +1 -0
  32. package/dist/hooks/use-debounce.js +13 -0
  33. package/dist/hooks/use-fill-ids.d.ts +8 -0
  34. package/dist/hooks/use-fill-ids.js +20 -0
  35. package/dist/hooks/use-map.d.ts +1 -0
  36. package/dist/hooks/use-map.js +20 -0
  37. package/dist/hooks/use-measure.d.ts +8 -0
  38. package/dist/hooks/use-measure.js +25 -0
  39. package/dist/hooks/use-reverse-video-playback.d.ts +1 -0
  40. package/dist/hooks/use-reverse-video-playback.js +41 -0
  41. package/dist/hooks/use-scroll-restoration.d.ts +8 -0
  42. package/dist/hooks/use-scroll-restoration.js +36 -0
  43. package/dist/mcp/enhanced-server.js +2 -2
  44. package/dist/registry/api.d.ts +1 -1
  45. package/dist/registry/api.js +3 -3
  46. package/dist/registry/index.d.ts +48 -48
  47. package/dist/registry/index.js +3 -3
  48. package/dist/utils.d.ts +1 -0
  49. package/dist/utils.js +1 -0
  50. package/helpers/file.ts +33 -0
  51. package/helpers/memoization.ts +40 -0
  52. package/package.json +27 -6
  53. package/primitives/accordion.tsx +53 -45
  54. package/primitives/alert-dialog.tsx +185 -0
  55. package/primitives/alert.tsx +74 -0
  56. package/primitives/apply-typography.tsx +1 -1
  57. package/primitives/avatar.tsx +37 -29
  58. package/primitives/background-beams.tsx +142 -0
  59. package/primitives/badge.tsx +27 -19
  60. package/primitives/breadcrumb.tsx +77 -62
  61. package/primitives/button.tsx +69 -72
  62. package/primitives/card.tsx +73 -59
  63. package/primitives/chat/chat-input-area.tsx +87 -0
  64. package/primitives/chat/chat-input.tsx +71 -0
  65. package/primitives/chat/files-preview.tsx +330 -0
  66. package/primitives/chat/index.ts +6 -0
  67. package/primitives/chat/json-form.tsx +8 -0
  68. package/primitives/chat/message-list.tsx +307 -0
  69. package/primitives/chat/message.tsx +569 -0
  70. package/primitives/chat/sqlite-preview.tsx +215 -0
  71. package/primitives/checkbox.tsx +18 -19
  72. package/primitives/collapsible.tsx +9 -0
  73. package/primitives/command.tsx +75 -83
  74. package/primitives/context-menu.tsx +115 -109
  75. package/primitives/copy-to-clipboard-icon.tsx +60 -0
  76. package/primitives/dialog-video-controller.tsx +1 -1
  77. package/primitives/dialog.tsx +111 -145
  78. package/primitives/dot-pattern.tsx +57 -0
  79. package/primitives/dots-loader.tsx +13 -0
  80. package/primitives/drawer.tsx +59 -87
  81. package/primitives/dropdown-menu.tsx +199 -0
  82. package/primitives/error-message.tsx +19 -0
  83. package/primitives/file-uploader.tsx +200 -0
  84. package/primitives/form.tsx +92 -87
  85. package/primitives/hover-card.tsx +28 -0
  86. package/primitives/icons/github.tsx +1 -1
  87. package/primitives/icons/youtube-logo.tsx +1 -1
  88. package/primitives/index-common.ts +121 -42
  89. package/primitives/index-next.ts +3 -1
  90. package/primitives/input.tsx +115 -20
  91. package/primitives/label.tsx +15 -23
  92. package/primitives/loading-spinner.tsx +1 -1
  93. package/primitives/markdown-preview.tsx +609 -0
  94. package/primitives/mermaid.tsx +196 -0
  95. package/primitives/next/link-element.tsx +1 -1
  96. package/primitives/next/mdx-link.tsx +1 -1
  97. package/primitives/pagination.tsx +117 -0
  98. package/primitives/popover.tsx +20 -25
  99. package/primitives/pretty-json-print.tsx +28 -0
  100. package/primitives/progress.tsx +14 -15
  101. package/primitives/prompt-textarea.tsx +72 -0
  102. package/primitives/qr-code.tsx +112 -0
  103. package/primitives/radio-group.tsx +25 -39
  104. package/primitives/resizable.tsx +47 -0
  105. package/primitives/scroll-area.tsx +35 -25
  106. package/primitives/search-input.tsx +66 -0
  107. package/primitives/select.tsx +62 -109
  108. package/primitives/separator.tsx +22 -26
  109. package/primitives/sheet.tsx +78 -117
  110. package/primitives/skeleton.tsx +13 -16
  111. package/primitives/slider.tsx +50 -60
  112. package/primitives/stepper.tsx +272 -0
  113. package/primitives/switch.tsx +14 -23
  114. package/primitives/table.tsx +65 -77
  115. package/primitives/tabs.tsx +29 -39
  116. package/primitives/text-link.tsx +25 -0
  117. package/primitives/textarea.tsx +61 -0
  118. package/primitives/textfield.tsx +75 -0
  119. package/primitives/toast.tsx +30 -0
  120. package/primitives/toggle-group.tsx +33 -33
  121. package/primitives/toggle.tsx +22 -51
  122. package/primitives/tooltip.tsx +37 -38
  123. package/registry.json +1 -1
  124. package/src/button.ts +1 -0
  125. package/src/hooks/index.ts +7 -0
  126. package/src/hooks/use-click-away.ts +31 -0
  127. package/src/hooks/use-combined-refs.ts +22 -0
  128. package/src/hooks/use-copy-clipboard.ts +30 -0
  129. package/src/hooks/use-debounce.ts +17 -0
  130. package/src/hooks/use-fill-ids.ts +25 -0
  131. package/src/hooks/use-map.ts +26 -0
  132. package/src/hooks/use-measure.ts +42 -0
  133. package/src/hooks/use-reverse-video-playback.ts +43 -0
  134. package/src/hooks/use-scroll-restoration.ts +50 -0
  135. package/src/mcp/README.md +1 -1
  136. package/src/mcp/enhanced-server.ts +2 -2
  137. package/src/registry/api.ts +3 -3
  138. package/src/registry/index.ts +3 -3
  139. package/src/utils.ts +1 -0
  140. package/style/theme-provider.tsx +1 -1
  141. package/test-imports.mjs +19 -0
  142. package/types/animation-def.ts +1 -1
  143. package/types/button-def.ts +1 -1
  144. package/types/index.ts +1 -1
  145. package/util/blob.ts +28 -0
  146. package/util/copy-to-clipboard.ts +17 -0
  147. package/util/create-shadow-root.ts +22 -0
  148. package/util/date.ts +83 -0
  149. package/util/debounce.ts +11 -0
  150. package/util/file.ts +15 -0
  151. package/util/format-and-abbreviate-as-currency.ts +1 -1
  152. package/util/format-text.ts +33 -0
  153. package/util/index.ts +9 -78
  154. package/util/timing.ts +3 -0
  155. package/util/toasts.tsx +17 -0
  156. package/utils.ts +9 -0
@@ -1,30 +1,125 @@
1
- 'use client'
1
+ import { EyeIcon, EyeOffIcon } from 'lucide-react';
2
+ import * as React from 'react';
3
+ import { useEffect, useImperativeHandle, useRef } from 'react';
2
4
 
3
- import React from "react"
4
-
5
- import { cn } from "../util"
5
+ import { RefCallBack } from 'react-hook-form';
6
+ import { cn } from '../src/utils';
7
+ import { Badge } from './badge';
8
+ import { Button } from './button';
6
9
 
7
10
  export interface InputProps
8
- extends React.InputHTMLAttributes<HTMLInputElement> {}
11
+ extends React.InputHTMLAttributes<HTMLInputElement> {
12
+ startAdornment?: React.ReactNode;
13
+ endAdornment?: React.ReactNode;
14
+ hidePasswordToggle?: boolean;
15
+ ref?: React.RefObject<HTMLInputElement | null> | RefCallBack;
16
+ }
17
+
18
+ const Input = ({
19
+ className,
20
+ type,
21
+ startAdornment,
22
+ endAdornment,
23
+ hidePasswordToggle,
24
+ ref,
25
+ ...props
26
+ }: InputProps) => {
27
+ const inputRef = useRef<HTMLInputElement>(null);
28
+ const startAdornmentRef = useRef<HTMLDivElement>(null);
29
+ const endAdornmentRef = useRef<HTMLDivElement>(null);
30
+ const [showPassword, setShowPassword] = React.useState(false);
31
+
32
+ const togglePasswordVisibility = () => {
33
+ setShowPassword(!showPassword);
34
+ };
35
+
36
+ const style: React.CSSProperties = {};
37
+ if (startAdornment) {
38
+ style.paddingLeft = `${
39
+ (startAdornmentRef?.current?.offsetWidth ?? 0) + 20
40
+ }px`;
41
+ }
42
+ if (endAdornment) {
43
+ style.paddingRight = `${
44
+ (endAdornmentRef?.current?.offsetWidth ?? 0) + 20
45
+ }px`;
46
+ }
9
47
 
10
- const Input = React.forwardRef<HTMLInputElement, InputProps>(
11
- ({ className, type, ...props }, ref) => {
12
- return (
48
+ useImperativeHandle(ref, () => inputRef.current!, []);
49
+
50
+ useEffect(() => {
51
+ if (props.autoFocus) {
52
+ setTimeout(() => {
53
+ // trick to wait the modal to be opened to focus
54
+ inputRef?.current?.focus();
55
+ }, 0);
56
+ }
57
+ }, [props.autoFocus]);
58
+
59
+ const inputType = type === 'password' && showPassword ? 'text' : type;
60
+
61
+ return (
62
+ <>
13
63
  <input
14
- type={type}
15
64
  className={cn(
16
- 'flex h-10 w-full rounded-md border border-muted-3 bg-inherit px-3 py-2 text-sm ring-offset-background ' +
17
- 'file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-2 ' +
18
- 'focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 ' +
19
- 'first-letter:disabled:cursor-not-allowed disabled:opacity-50',
20
- className
65
+ 'h-input border-border-input bg-bg-secondary focus:border-border-input-focus disabled:bg-bg-input-disabled peer placeholder-shown:border-border-input text-text-default w-full rounded-lg border px-4 py-3 pt-8 text-sm font-medium placeholder-transparent outline outline-0 transition-all placeholder-shown:border focus:border focus:outline-0 disabled:border-0 disabled:text-gray-400',
66
+ startAdornment && 'pl-[var(--custom-padding-left-input)]',
67
+ endAdornment && 'pr-[var(--custom-padding-right-input)]',
68
+ type === 'password' && 'pr-[60px]',
69
+ className,
21
70
  )}
22
- ref={ref}
71
+ placeholder=" "
72
+ ref={inputRef}
73
+ spellCheck={false}
74
+ style={style}
75
+ type={inputType}
23
76
  {...props}
24
77
  />
25
- )
26
- }
27
- )
28
- Input.displayName = "Input"
78
+ {startAdornment ? (
79
+ <Badge
80
+ className="peer/adornment adornment absolute top-[30px] left-4"
81
+ ref={startAdornmentRef}
82
+ variant="inputAdornment"
83
+ >
84
+ {startAdornment}
85
+ </Badge>
86
+ ) : null}
87
+ {endAdornment && typeof endAdornment === 'string' ? (
88
+ <Badge
89
+ className="peer/adornment adornment absolute top-[30px] right-4"
90
+ ref={endAdornmentRef}
91
+ variant="inputAdornment"
92
+ >
93
+ {endAdornment}
94
+ </Badge>
95
+ ) : null}
96
+ {endAdornment &&
97
+ typeof endAdornment !== 'string' &&
98
+ React.isValidElement(endAdornment)
99
+ ? React.cloneElement(endAdornment, {
100
+ ref: endAdornmentRef,
101
+ } as React.ComponentProps<typeof Badge>)
102
+ : null}
103
+ {type === 'password' && !hidePasswordToggle && (
104
+ <Button
105
+ aria-label={showPassword ? 'Hide password' : 'Show password'}
106
+ className="absolute top-3 right-3"
107
+ onClick={togglePasswordVisibility}
108
+ size={'icon'}
109
+ type="button"
110
+ variant="tertiary"
111
+ >
112
+ {showPassword ? (
113
+ <EyeOffIcon aria-hidden="true" className="h-4 w-4" />
114
+ ) : (
115
+ <EyeIcon aria-hidden="true" className="h-4 w-4" />
116
+ )}
117
+ </Button>
118
+ )}
119
+ </>
120
+ );
121
+ };
122
+
123
+ Input.displayName = 'Input';
29
124
 
30
- export default Input
125
+ export { Input };
@@ -1,28 +1,20 @@
1
- // @ts-nocheck
2
- "use client"
1
+ import * as LabelPrimitive from '@radix-ui/react-label';
2
+ import { cva, type VariantProps } from 'class-variance-authority';
3
+ import * as React from 'react';
3
4
 
4
- import React from "react"
5
- // @ts-ignore
6
- import * as LabelPrimitive from "@radix-ui/react-label"
7
- import { cva, type VariantProps } from "class-variance-authority"
8
-
9
- import { cn } from "../util"
5
+ import { cn } from '../src/utils';
10
6
 
11
7
  const labelVariants = cva(
12
- "font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
13
- )
8
+ 'text-sm leading-none font-medium peer-disabled:cursor-not-allowed peer-disabled:opacity-70',
9
+ );
14
10
 
15
- const Label = React.forwardRef<
16
- React.ElementRef<typeof LabelPrimitive.Root>,
17
- React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
18
- VariantProps<typeof labelVariants>
19
- >(({ className, ...props }, ref) => (
20
- <LabelPrimitive.Root
21
- ref={ref}
22
- className={cn(labelVariants(), className)}
23
- {...props}
24
- />
25
- ))
26
- Label.displayName = LabelPrimitive.Root.displayName
11
+ const Label = ({
12
+ className,
13
+ ...props
14
+ }: React.ComponentProps<typeof LabelPrimitive.Root> &
15
+ VariantProps<typeof labelVariants>) => (
16
+ <LabelPrimitive.Root className={cn(labelVariants(), className)} {...props} />
17
+ );
18
+ Label.displayName = LabelPrimitive.Root.displayName;
27
19
 
28
- export default Label
20
+ export { Label };
@@ -1,6 +1,6 @@
1
1
  import { cn } from '../util'
2
2
 
3
- // cf: https://github.com/shadcn-ui/ui/discussions/1694#discussioncomment-7851248
3
+ // cf: https://github.com/hanzo-ui/ui/discussions/1694#discussioncomment-7851248
4
4
  const LoadingSpinner: React.FC<
5
5
  {
6
6
  size?: number