@hanzo/ui 4.5.0 → 4.5.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.
- package/MCP-INSTRUCTIONS.md +73 -0
- package/README-MCP.md +175 -0
- package/bin/cli.js +100 -0
- package/bin/create-registry.js +108 -0
- package/bin/mcp.js +403 -0
- package/bin/npx-registry-mcp.js +15 -0
- package/bin/registry-mcp-wrapper.sh +19 -0
- package/bin/registry-mcp.js +100 -0
- package/bin/start-mcp-server.sh +22 -0
- package/bin/test-mcp.sh +52 -0
- package/bin/update-registry.js +196 -0
- package/blocks/components/screenful-block/index.tsx +2 -0
- package/dist/blocks/components/accordian-block.d.ts +4 -0
- package/dist/blocks/components/accordian-block.jsx +25 -0
- package/dist/blocks/components/block-component-props.d.ts +7 -0
- package/dist/blocks/components/block-component-props.js +1 -0
- package/dist/blocks/components/bullet-cards-block.d.ts +4 -0
- package/dist/blocks/components/bullet-cards-block.jsx +25 -0
- package/dist/blocks/components/card-block/index.d.ts +6 -0
- package/dist/blocks/components/card-block/index.jsx +87 -0
- package/dist/blocks/components/card-block/link-out-button.d.ts +6 -0
- package/dist/blocks/components/card-block/link-out-button.jsx +4 -0
- package/dist/blocks/components/card-block/util.d.ts +4 -0
- package/dist/blocks/components/card-block/util.js +6 -0
- package/dist/blocks/components/carte-blanche-block/index.d.ts +4 -0
- package/dist/blocks/components/carte-blanche-block/index.jsx +82 -0
- package/dist/blocks/components/carte-blanche-block/variant-content-left.d.ts +10 -0
- package/dist/blocks/components/carte-blanche-block/variant-content-left.jsx +23 -0
- package/dist/blocks/components/content.d.ts +10 -0
- package/dist/blocks/components/content.jsx +47 -0
- package/dist/blocks/components/cta-block.d.ts +12 -0
- package/dist/blocks/components/cta-block.jsx +69 -0
- package/dist/blocks/components/enh-heading-block.d.ts +7 -0
- package/dist/blocks/components/enh-heading-block.jsx +142 -0
- package/dist/blocks/components/grid-block/grid-block-mutator.d.ts +5 -0
- package/dist/blocks/components/grid-block/grid-block-mutator.js +1 -0
- package/dist/blocks/components/grid-block/index.d.ts +9 -0
- package/dist/blocks/components/grid-block/index.jsx +56 -0
- package/dist/blocks/components/grid-block/mutator-registry.d.ts +3 -0
- package/dist/blocks/components/grid-block/mutator-registry.js +5 -0
- package/dist/blocks/components/grid-block/table-borders.mutator.d.ts +3 -0
- package/dist/blocks/components/grid-block/table-borders.mutator.js +36 -0
- package/dist/blocks/components/group-block.d.ts +7 -0
- package/dist/blocks/components/group-block.jsx +61 -0
- package/dist/blocks/components/heading-block.d.ts +4 -0
- package/dist/blocks/components/heading-block.jsx +99 -0
- package/dist/blocks/components/image-block.d.ts +7 -0
- package/dist/blocks/components/image-block.jsx +69 -0
- package/dist/blocks/components/index.d.ts +14 -0
- package/dist/blocks/components/index.js +13 -0
- package/dist/blocks/components/screenful-block/content.d.ts +8 -0
- package/dist/blocks/components/screenful-block/content.jsx +71 -0
- package/dist/blocks/components/screenful-block/index.d.ts +12 -0
- package/dist/blocks/components/screenful-block/index.jsx +57 -0
- package/dist/blocks/components/screenful-block/poster-background.d.ts +7 -0
- package/dist/blocks/components/screenful-block/poster-background.jsx +14 -0
- package/dist/blocks/components/screenful-block/video-background.d.ts +8 -0
- package/dist/blocks/components/screenful-block/video-background.jsx +20 -0
- package/dist/blocks/components/space-block.d.ts +4 -0
- package/dist/blocks/components/space-block.jsx +42 -0
- package/dist/blocks/components/video-block.d.ts +9 -0
- package/dist/blocks/components/video-block.jsx +83 -0
- package/dist/blocks/def/accordian-block.d.ts +10 -0
- package/dist/blocks/def/accordian-block.js +2 -0
- package/dist/blocks/def/block.d.ts +4 -0
- package/dist/blocks/def/block.js +1 -0
- package/dist/blocks/def/bullet-cards-block.d.ts +17 -0
- package/dist/blocks/def/bullet-cards-block.js +1 -0
- package/dist/blocks/def/card-block.d.ts +17 -0
- package/dist/blocks/def/card-block.js +2 -0
- package/dist/blocks/def/carte-blanche-block.d.ts +12 -0
- package/dist/blocks/def/carte-blanche-block.js +1 -0
- package/dist/blocks/def/cta-block.d.ts +8 -0
- package/dist/blocks/def/cta-block.js +1 -0
- package/dist/blocks/def/element-block.d.ts +7 -0
- package/dist/blocks/def/element-block.js +2 -0
- package/dist/blocks/def/enh-heading-block.d.ts +22 -0
- package/dist/blocks/def/enh-heading-block.js +1 -0
- package/dist/blocks/def/grid-block.d.ts +12 -0
- package/dist/blocks/def/grid-block.js +1 -0
- package/dist/blocks/def/group-block.d.ts +7 -0
- package/dist/blocks/def/group-block.js +1 -0
- package/dist/blocks/def/heading-block.d.ts +11 -0
- package/dist/blocks/def/heading-block.js +1 -0
- package/dist/blocks/def/image-block.d.ts +26 -0
- package/dist/blocks/def/image-block.js +1 -0
- package/dist/blocks/def/index.d.ts +17 -0
- package/dist/blocks/def/index.js +2 -0
- package/dist/blocks/def/screenful-block.d.ts +41 -0
- package/dist/blocks/def/screenful-block.js +1 -0
- package/dist/blocks/def/space-block.d.ts +47 -0
- package/dist/blocks/def/space-block.js +8 -0
- package/dist/blocks/def/video-block.d.ts +5 -0
- package/dist/blocks/def/video-block.js +1 -0
- package/dist/blocks/index.d.ts +2 -0
- package/dist/blocks/index.js +2 -0
- package/dist/mcp/enhanced-server.d.ts +29 -0
- package/dist/mcp/enhanced-server.js +1128 -0
- package/dist/mcp/index.d.ts +28 -0
- package/dist/mcp/index.js +436 -0
- package/dist/primitives/accordion.d.ts +10 -0
- package/dist/primitives/accordion.jsx +21 -0
- package/dist/primitives/action-button.d.ts +9 -0
- package/dist/primitives/action-button.jsx +16 -0
- package/dist/primitives/apply-typography.d.ts +7 -0
- package/dist/primitives/apply-typography.jsx +38 -0
- package/dist/primitives/aspect-ratio.d.ts +3 -0
- package/dist/primitives/aspect-ratio.jsx +4 -0
- package/dist/primitives/avatar.d.ts +6 -0
- package/dist/primitives/avatar.jsx +11 -0
- package/dist/primitives/badge.d.ts +9 -0
- package/dist/primitives/badge.jsx +18 -0
- package/dist/primitives/breadcrumb.d.ts +19 -0
- package/dist/primitives/breadcrumb.jsx +27 -0
- package/dist/primitives/breakpoint-indicator.d.ts +3 -0
- package/dist/primitives/breakpoint-indicator.jsx +14 -0
- package/dist/primitives/button.d.ts +12 -0
- package/dist/primitives/button.jsx +55 -0
- package/dist/primitives/calendar.d.ts +8 -0
- package/dist/primitives/calendar.jsx +40 -0
- package/dist/primitives/card.d.ts +8 -0
- package/dist/primitives/card.jsx +18 -0
- package/dist/primitives/carousel.d.ts +18 -0
- package/dist/primitives/carousel.jsx +106 -0
- package/dist/primitives/checkbox.d.ts +4 -0
- package/dist/primitives/checkbox.jsx +15 -0
- package/dist/primitives/combobox.d.ts +41 -0
- package/dist/primitives/combobox.jsx +77 -0
- package/dist/primitives/command.d.ts +17 -0
- package/dist/primitives/command.jsx +38 -0
- package/dist/primitives/context-menu.d.ts +27 -0
- package/dist/primitives/context-menu.jsx +57 -0
- package/dist/primitives/dialog-video-controller.d.ts +3 -0
- package/dist/primitives/dialog-video-controller.jsx +24 -0
- package/dist/primitives/dialog.d.ts +28 -0
- package/dist/primitives/dialog.jsx +37 -0
- package/dist/primitives/drawer.d.ts +29 -0
- package/dist/primitives/drawer.jsx +34 -0
- package/dist/primitives/form.d.ts +12 -0
- package/dist/primitives/form.jsx +69 -0
- package/dist/primitives/icons/github.d.ts +4 -0
- package/dist/primitives/icons/github.jsx +6 -0
- package/dist/primitives/icons/index.d.ts +4 -0
- package/dist/primitives/icons/index.js +4 -0
- package/dist/primitives/icons/youtube-logo.d.ts +4 -0
- package/dist/primitives/icons/youtube-logo.jsx +39 -0
- package/dist/primitives/index-common.d.ts +47 -0
- package/dist/primitives/index-common.js +46 -0
- package/dist/primitives/index-next.d.ts +2 -0
- package/dist/primitives/index-next.js +2 -0
- package/dist/primitives/input-otp.d.ts +7 -0
- package/dist/primitives/input-otp.jsx +24 -0
- package/dist/primitives/input.d.ts +5 -0
- package/dist/primitives/input.jsx +11 -0
- package/dist/primitives/label.d.ts +5 -0
- package/dist/primitives/label.jsx +11 -0
- package/dist/primitives/list-adaptor.d.ts +9 -0
- package/dist/primitives/list-adaptor.js +1 -0
- package/dist/primitives/list-box.d.ts +10 -0
- package/dist/primitives/list-box.jsx +14 -0
- package/dist/primitives/loading-spinner.d.ts +5 -0
- package/dist/primitives/loading-spinner.jsx +8 -0
- package/dist/primitives/navigation-menu.d.ts +12 -0
- package/dist/primitives/navigation-menu.jsx +38 -0
- package/dist/primitives/next/image.d.ts +11 -0
- package/dist/primitives/next/image.jsx +42 -0
- package/dist/primitives/next/index.d.ts +7 -0
- package/dist/primitives/next/index.js +7 -0
- package/dist/primitives/next/inline-icon.d.ts +13 -0
- package/dist/primitives/next/inline-icon.jsx +15 -0
- package/dist/primitives/next/link-element.d.ts +23 -0
- package/dist/primitives/next/link-element.jsx +56 -0
- package/dist/primitives/next/mdx-link.d.ts +3 -0
- package/dist/primitives/next/mdx-link.jsx +12 -0
- package/dist/primitives/next/media-stack.d.ts +8 -0
- package/dist/primitives/next/media-stack.jsx +28 -0
- package/dist/primitives/next/nav-items.d.ts +10 -0
- package/dist/primitives/next/nav-items.jsx +24 -0
- package/dist/primitives/next/youtube-embed.d.ts +11 -0
- package/dist/primitives/next/youtube-embed.jsx +23 -0
- package/dist/primitives/popover.d.ts +9 -0
- package/dist/primitives/popover.jsx +18 -0
- package/dist/primitives/progress.d.ts +4 -0
- package/dist/primitives/progress.jsx +9 -0
- package/dist/primitives/radio-group.d.ts +7 -0
- package/dist/primitives/radio-group.jsx +18 -0
- package/dist/primitives/scroll-area.d.ts +5 -0
- package/dist/primitives/scroll-area.jsx +19 -0
- package/dist/primitives/select.d.ts +13 -0
- package/dist/primitives/select.jsx +62 -0
- package/dist/primitives/separator.d.ts +4 -0
- package/dist/primitives/separator.jsx +7 -0
- package/dist/primitives/sheet.d.ts +30 -0
- package/dist/primitives/sheet.jsx +56 -0
- package/dist/primitives/skeleton.d.ts +4 -0
- package/dist/primitives/skeleton.jsx +3 -0
- package/dist/primitives/slider.d.ts +9 -0
- package/dist/primitives/slider.jsx +30 -0
- package/dist/primitives/sonner.d.ts +5 -0
- package/dist/primitives/sonner.jsx +16 -0
- package/dist/primitives/step-indicator.d.ts +9 -0
- package/dist/primitives/step-indicator.jsx +23 -0
- package/dist/primitives/switch.d.ts +6 -0
- package/dist/primitives/switch.jsx +14 -0
- package/dist/primitives/table.d.ts +10 -0
- package/dist/primitives/table.jsx +21 -0
- package/dist/primitives/tabs.d.ts +7 -0
- package/dist/primitives/tabs.jsx +18 -0
- package/dist/primitives/text-area.d.ts +5 -0
- package/dist/primitives/text-area.jsx +9 -0
- package/dist/primitives/toggle-group.d.ts +14 -0
- package/dist/primitives/toggle-group.jsx +28 -0
- package/dist/primitives/toggle.d.ts +14 -0
- package/dist/primitives/toggle.jsx +52 -0
- package/dist/primitives/tooltip.d.ts +11 -0
- package/dist/primitives/tooltip.jsx +18 -0
- package/dist/primitives/video-player.d.ts +6 -0
- package/dist/primitives/video-player.jsx +8 -0
- package/dist/registry/api.d.ts +37 -0
- package/dist/registry/api.js +130 -0
- package/dist/registry/index.d.ts +9 -0
- package/dist/registry/index.js +45 -0
- package/dist/style/theme-provider.d.ts +4 -0
- package/dist/style/theme-provider.jsx +11 -0
- package/dist/tailwind/fontFamily.tailwind.d.ts +8 -0
- package/dist/tailwind/fontFamily.tailwind.js +7 -0
- package/dist/tailwind/fontSize.tailwind.d.ts +36 -0
- package/dist/tailwind/fontSize.tailwind.js +13 -0
- package/dist/tailwind/index.d.ts +3 -0
- package/dist/tailwind/index.js +2 -0
- package/dist/tailwind/screens.tailwind.d.ts +9 -0
- package/dist/tailwind/screens.tailwind.js +8 -0
- package/dist/tailwind/tw-font-desc.d.ts +6 -0
- package/dist/tailwind/tw-font-desc.js +6 -0
- package/dist/types/animation-def.d.ts +2 -0
- package/dist/types/animation-def.js +1 -0
- package/dist/types/breakpoints.d.ts +4 -0
- package/dist/types/breakpoints.js +4 -0
- package/dist/types/bullet-item.d.ts +6 -0
- package/dist/types/bullet-item.js +2 -0
- package/dist/types/button-def.d.ts +29 -0
- package/dist/types/button-def.js +2 -0
- package/dist/types/dimensions.d.ts +5 -0
- package/dist/types/dimensions.js +1 -0
- package/dist/types/grid-def.d.ts +36 -0
- package/dist/types/grid-def.js +33 -0
- package/dist/types/image-def.d.ts +27 -0
- package/dist/types/image-def.js +1 -0
- package/dist/types/index.d.ts +13 -0
- package/dist/types/index.js +2 -0
- package/dist/types/link-def.d.ts +44 -0
- package/dist/types/link-def.js +1 -0
- package/dist/types/media-stack-def.d.ts +25 -0
- package/dist/types/media-stack-def.js +1 -0
- package/dist/types/t-shirt-size.d.ts +2 -0
- package/dist/types/t-shirt-size.js +1 -0
- package/dist/types/tshirt-dimensions.d.ts +12 -0
- package/dist/types/tshirt-dimensions.js +1 -0
- package/dist/types/video-def.d.ts +9 -0
- package/dist/types/video-def.js +1 -0
- package/dist/util/format-and-abbreviate-as-currency.d.ts +11 -0
- package/dist/util/format-and-abbreviate-as-currency.js +91 -0
- package/dist/util/format-to-max-char.d.ts +5 -0
- package/dist/util/format-to-max-char.js +57 -0
- package/dist/util/index-client.d.ts +2 -0
- package/dist/util/index-client.js +3 -0
- package/dist/util/index.d.ts +17 -0
- package/dist/util/index.js +41 -0
- package/dist/util/number-abbreviate.d.ts +9 -0
- package/dist/util/number-abbreviate.js +30 -0
- package/dist/util/specifier.d.ts +7 -0
- package/dist/util/specifier.js +31 -0
- package/dist/util/spread-to-transform.d.ts +7 -0
- package/dist/util/spread-to-transform.js +18 -0
- package/dist/util/step-animation.d.ts +5 -0
- package/dist/util/step-animation.js +60 -0
- package/dist/util/two-way-map.d.ts +8 -0
- package/dist/util/two-way-map.js +16 -0
- package/mcp/README.md +141 -0
- package/mcp/enhanced-server.ts +1208 -0
- package/mcp/index.ts +518 -0
- package/mcp/package.json +10 -0
- package/package.json +34 -14
- package/primitives/accordion.tsx +5 -5
- package/primitives/button.tsx +6 -3
- package/primitives/dialog.tsx +12 -7
- package/primitives/tabs.tsx +1 -1
- package/primitives/tooltip.tsx +1 -1
- package/public/r/accordion.json +11 -0
- package/public/r/alert.json +11 -0
- package/public/r/avatar.json +11 -0
- package/public/r/badge.json +11 -0
- package/public/r/button.json +11 -0
- package/public/r/card.json +11 -0
- package/public/r/checkbox.json +11 -0
- package/public/r/default.json +6 -0
- package/public/r/dialog.json +11 -0
- package/public/r/input.json +11 -0
- package/public/r/label.json +11 -0
- package/public/r/new-york.json +6 -0
- package/public/r/popover.json +11 -0
- package/public/r/select.json +11 -0
- package/public/r/table.json +11 -0
- package/public/r/tabs.json +11 -0
- package/public/r/toast.json +11 -0
- package/registry/api.ts +164 -0
- package/registry/index.ts +60 -0
- package/registry/package.json +10 -0
- package/registry.json +184 -0
- package/test/test-registry.js +73 -0
- package/tsconfig.json +8 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ClassValue } from 'clsx';
|
|
2
|
+
export { cva, type VariantProps } from 'class-variance-authority';
|
|
3
|
+
import type { Dimensions } from '../types';
|
|
4
|
+
export declare const cn: (...inputs: ClassValue[]) => string;
|
|
5
|
+
export declare const markdown: (s: string, options?: any) => JSX.Element;
|
|
6
|
+
export declare const round: (num: number) => string;
|
|
7
|
+
export declare const pxToRem: (px: number, base: number) => string;
|
|
8
|
+
export declare const pxToEm: (px: number, base: number) => string;
|
|
9
|
+
export declare const hexToRgb: (hex: string) => string;
|
|
10
|
+
export declare const asNum: (n: number | `${number}`) => number;
|
|
11
|
+
export declare const constrain: (d: Dimensions, c: Dimensions) => Dimensions;
|
|
12
|
+
export declare const containsToken: (s: string | undefined, toFind: string) => boolean;
|
|
13
|
+
export declare const ldMerge: (result: any, ...sources: any[]) => any;
|
|
14
|
+
export declare const capitalize: (str: string) => string;
|
|
15
|
+
export { default as spreadToTransform } from './spread-to-transform';
|
|
16
|
+
export { default as formatToMaxChar } from './format-to-max-char';
|
|
17
|
+
export { default as formatAndAbbreviateAsCurrency, type FormatThreshold, type QuantityAbbrSymbol } from './format-and-abbreviate-as-currency';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { compiler as mdCompiler } from 'markdown-to-jsx';
|
|
2
|
+
import { clsx } from 'clsx';
|
|
3
|
+
import { twMerge } from 'tailwind-merge';
|
|
4
|
+
export { cva } from 'class-variance-authority';
|
|
5
|
+
import { default as _merge } from 'lodash.merge';
|
|
6
|
+
export const cn = (...inputs) => (twMerge(clsx(inputs)));
|
|
7
|
+
export const markdown = (s, options) => (mdCompiler(s, {
|
|
8
|
+
wrapper: null,
|
|
9
|
+
...options
|
|
10
|
+
}));
|
|
11
|
+
export const round = (num) => (num
|
|
12
|
+
.toFixed(7)
|
|
13
|
+
.replace(/(\.[0-9]+?)0+$/, '$1')
|
|
14
|
+
.replace(/\.0$/, ''));
|
|
15
|
+
export const pxToRem = (px, base) => (`${round(px / base)}rem`);
|
|
16
|
+
export const pxToEm = (px, base) => (`${round(px / base)}em`);
|
|
17
|
+
export const hexToRgb = (hex) => {
|
|
18
|
+
hex = hex.replace('#', '');
|
|
19
|
+
hex = hex.length === 3 ? hex.replace(/./g, '$&$&') : hex;
|
|
20
|
+
const r = parseInt(hex.substring(0, 2), 16);
|
|
21
|
+
const g = parseInt(hex.substring(2, 4), 16);
|
|
22
|
+
const b = parseInt(hex.substring(4, 6), 16);
|
|
23
|
+
return `${r} ${g} ${b}`;
|
|
24
|
+
};
|
|
25
|
+
export const asNum = (n) => ((typeof n === 'number') ? n : parseInt(n, 10));
|
|
26
|
+
// https://stackoverflow.com/questions/3971841/how-to-resize-images-proportionally-keeping-the-aspect-ratio
|
|
27
|
+
export const constrain = (d, c) => {
|
|
28
|
+
const ratio = Math.min(c.w / d.w, c.h / d.h);
|
|
29
|
+
return {
|
|
30
|
+
w: Math.round(d.w * ratio),
|
|
31
|
+
h: Math.round(d.h * ratio)
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export const containsToken = (s, toFind) => (s ? s.split(' ').includes(toFind) : false);
|
|
35
|
+
export const ldMerge = (result, ...sources) => (_merge(result, ...sources));
|
|
36
|
+
export const capitalize = (str) => (str.charAt(0).toUpperCase() + str.slice(1));
|
|
37
|
+
export { default as spreadToTransform } from './spread-to-transform';
|
|
38
|
+
export { default as formatToMaxChar } from './format-to-max-char';
|
|
39
|
+
export { default as formatAndAbbreviateAsCurrency } from './format-and-abbreviate-as-currency';
|
|
40
|
+
// Must be imported from 'use client', so can't include this...
|
|
41
|
+
// export * from './step-animation'
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type QuantityAbbrSymbol = 'K' | 'M' | 'B' | 'T';
|
|
2
|
+
declare const ABBR_SYMBOLS_ARRAY: ("K" | "M" | "B" | "T")[];
|
|
3
|
+
declare class NumberAbbreviator {
|
|
4
|
+
private _units;
|
|
5
|
+
constructor(units?: QuantityAbbrSymbol[]);
|
|
6
|
+
private _abbreviate;
|
|
7
|
+
abbreviate: (n: number, decPlaces: number, log?: boolean) => string;
|
|
8
|
+
}
|
|
9
|
+
export { type QuantityAbbrSymbol, ABBR_SYMBOLS_ARRAY, NumberAbbreviator as default };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// cf: https://github.com/domharrington/js-number-abbreviate/blob/master/index.js
|
|
2
|
+
const ABBR_SYMBOLS_ARRAY = ['K', 'M', 'B', 'T'];
|
|
3
|
+
class NumberAbbreviator {
|
|
4
|
+
constructor(units) {
|
|
5
|
+
this._abbreviate = (n, decPlaces, log = false) => {
|
|
6
|
+
const _decPlaces = Math.pow(10, decPlaces);
|
|
7
|
+
let _n = n;
|
|
8
|
+
let _unit;
|
|
9
|
+
for (let i = this._units.length - 1; i >= 0; i--) {
|
|
10
|
+
const size = Math.pow(10, (i + 1) * 3);
|
|
11
|
+
if (size <= _n) {
|
|
12
|
+
_n = Math.round(_n * _decPlaces / size) / _decPlaces;
|
|
13
|
+
if ((_n === 1000) && (i < this._units.length - 1)) {
|
|
14
|
+
_n = 1;
|
|
15
|
+
i++;
|
|
16
|
+
}
|
|
17
|
+
_unit = this._units[i];
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return _n.toString() + (_unit ?? '');
|
|
22
|
+
};
|
|
23
|
+
this.abbreviate = (n, decPlaces, log = false) => {
|
|
24
|
+
const abbreviatedNumber = this._abbreviate(Math.abs(n), decPlaces, log);
|
|
25
|
+
return n < 0 ? '-' + abbreviatedNumber : abbreviatedNumber;
|
|
26
|
+
};
|
|
27
|
+
this._units = units ?? ABBR_SYMBOLS_ARRAY;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export { ABBR_SYMBOLS_ARRAY, NumberAbbreviator as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Dimensions, TShirtSize } from '../types';
|
|
2
|
+
import type { TypographySize } from '../primitives/apply-typography';
|
|
3
|
+
export declare const getPrimaryStartingWith: (s: string, toFind: string) => string | undefined;
|
|
4
|
+
export declare const getTShirtSize: (s: string) => TShirtSize | undefined;
|
|
5
|
+
export declare const getTypographySize: (s: string) => TypographySize | undefined;
|
|
6
|
+
export declare const getDim: (s: string) => Dimensions | undefined;
|
|
7
|
+
export declare function getSpecifierData<T>(main: string, getPrimary: (s: string) => string | undefined, getData: (s: string) => T | undefined, def?: T): T | undefined;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export const getPrimaryStartingWith = (s, toFind) => {
|
|
2
|
+
const tokenArray = s.split(' ');
|
|
3
|
+
return tokenArray.find((tok) => (tok.startsWith(`${toFind}-`)));
|
|
4
|
+
};
|
|
5
|
+
export const getTShirtSize = (s) => {
|
|
6
|
+
const subTokenArray = s.split('-');
|
|
7
|
+
return subTokenArray[subTokenArray.length - 1];
|
|
8
|
+
};
|
|
9
|
+
export const getTypographySize = (s) => {
|
|
10
|
+
const subTokenArray = s.split('-');
|
|
11
|
+
return subTokenArray[subTokenArray.length - 1];
|
|
12
|
+
};
|
|
13
|
+
export const getDim = (s) => {
|
|
14
|
+
const subTokenArray = s.split('-');
|
|
15
|
+
const dimStr = subTokenArray[subTokenArray.length - 1];
|
|
16
|
+
if (dimStr) {
|
|
17
|
+
const dimTokenArray = s.split('x');
|
|
18
|
+
return dimTokenArray ? {
|
|
19
|
+
w: Number(dimTokenArray[0]),
|
|
20
|
+
h: Number(dimTokenArray[1])
|
|
21
|
+
} : undefined;
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
};
|
|
25
|
+
export function getSpecifierData(main, getPrimary, getData, def) {
|
|
26
|
+
const primary = getPrimary(main);
|
|
27
|
+
if (primary) {
|
|
28
|
+
return getData(primary) ?? def;
|
|
29
|
+
}
|
|
30
|
+
return def ?? undefined;
|
|
31
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export default (t) => {
|
|
2
|
+
let transformStrings = [];
|
|
3
|
+
const scaleVal = 'scale' in t ? t.scale : undefined;
|
|
4
|
+
if (scaleVal) {
|
|
5
|
+
if (typeof scaleVal === 'number') {
|
|
6
|
+
transformStrings.push(`scale(${scaleVal})`);
|
|
7
|
+
}
|
|
8
|
+
else if (Array.isArray(scaleVal) &&
|
|
9
|
+
scaleVal.length == 2 &&
|
|
10
|
+
typeof scaleVal[0] === 'number') {
|
|
11
|
+
transformStrings.push(`scale(${scaleVal[0]}, ${scaleVal[1]})`);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
throw new Error("parsing MediaTransform: Unrecognized value for 'scale'!");
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return transformStrings.length > 0 ? { transform: transformStrings.join(' ') } : {};
|
|
18
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { makeObservable, reaction, computed, observable, action } from 'mobx';
|
|
3
|
+
class MyStepAnimation {
|
|
4
|
+
/** initialStep: false -> true: step 0
|
|
5
|
+
true -> false: step 1
|
|
6
|
+
after intervals[0] : step 2
|
|
7
|
+
after intervals[1] : step 3
|
|
8
|
+
|
|
9
|
+
initialStep must contain at least one mobx observable and return boolean
|
|
10
|
+
see: https://mobx.js.org/reactions.html#reaction
|
|
11
|
+
*/
|
|
12
|
+
constructor(initialStep, intervals) {
|
|
13
|
+
this._step = -1;
|
|
14
|
+
this._reactionDisposer = undefined;
|
|
15
|
+
// This is separated out because reactions have to be created
|
|
16
|
+
// once we have a valid doc / window etc. (mobx internals)
|
|
17
|
+
// Can't just do it in constructor and assign to ref
|
|
18
|
+
this.initialize = () => {
|
|
19
|
+
const fireNext = () => {
|
|
20
|
+
this._setStep(this._step + 1);
|
|
21
|
+
if (this._step <= this._intervals.length) {
|
|
22
|
+
// No need to call clearTimeout(): https://stackoverflow.com/a/7391588/11645689
|
|
23
|
+
setTimeout(() => { fireNext(); }, this._intervals[this._step - 1]);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
this._reactionDisposer = reaction(this._initialStep, (triggered) => {
|
|
27
|
+
if (triggered && this._step === -1) {
|
|
28
|
+
this._setStep(0);
|
|
29
|
+
}
|
|
30
|
+
// extra safe
|
|
31
|
+
else if (this._step === 0) {
|
|
32
|
+
fireNext();
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
this._setStep = (v) => { this._step = v; };
|
|
37
|
+
this.dispose = () => {
|
|
38
|
+
if (this._reactionDisposer) {
|
|
39
|
+
this._reactionDisposer();
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
// https://mobx.js.org/computeds-with-args.html#2-close-over-the-arguments
|
|
43
|
+
this.notPast = (step) => (computed(() => (this._step > -1 && this._step <= step)).get());
|
|
44
|
+
this._initialStep = initialStep;
|
|
45
|
+
this._intervals = intervals;
|
|
46
|
+
makeObservable(this, {
|
|
47
|
+
_step: observable,
|
|
48
|
+
_setStep: action
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const useStepAnimation = (initialStep, intervals) => {
|
|
53
|
+
const animRef = useRef(new MyStepAnimation(initialStep, intervals));
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
animRef.current.initialize();
|
|
56
|
+
return animRef.current.dispose;
|
|
57
|
+
}, []);
|
|
58
|
+
return animRef.current;
|
|
59
|
+
};
|
|
60
|
+
export { useStepAnimation };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
class TwoWayReadonlyMap {
|
|
2
|
+
constructor(map) {
|
|
3
|
+
this.map = map;
|
|
4
|
+
this.reverseMap = new Map();
|
|
5
|
+
map.forEach((value, key) => {
|
|
6
|
+
this.reverseMap.set(value, key);
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
get(key) {
|
|
10
|
+
return this.map.get(key);
|
|
11
|
+
}
|
|
12
|
+
revGet(key) {
|
|
13
|
+
return this.reverseMap.get(key);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export default TwoWayReadonlyMap;
|
package/mcp/README.md
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# Hanzo UI MCP Server
|
|
2
|
+
|
|
3
|
+
The Hanzo UI MCP (Model Context Protocol) server provides AI assistants with comprehensive access to the Hanzo UI component library, enabling them to browse, search, and help developers use Hanzo UI components effectively.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
### For AI Clients
|
|
8
|
+
|
|
9
|
+
Configure your AI client to use the Hanzo UI MCP server:
|
|
10
|
+
|
|
11
|
+
**Claude Desktop** (`.mcp.json`):
|
|
12
|
+
```json
|
|
13
|
+
{
|
|
14
|
+
"mcpServers": {
|
|
15
|
+
"hanzo-ui": {
|
|
16
|
+
"command": "npx",
|
|
17
|
+
"args": ["@hanzo/ui@latest", "mcp"]
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Cursor** (`.cursor/mcp.json`):
|
|
24
|
+
```json
|
|
25
|
+
{
|
|
26
|
+
"mcpServers": {
|
|
27
|
+
"hanzo-ui": {
|
|
28
|
+
"command": "npx",
|
|
29
|
+
"args": ["@hanzo/ui@latest", "mcp"]
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**VS Code** (`.vscode/mcp.json`):
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"mcpServers": {
|
|
39
|
+
"hanzo-ui": {
|
|
40
|
+
"command": "npx",
|
|
41
|
+
"args": ["@hanzo/ui@latest", "mcp"]
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Manual Usage
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Run the MCP server (stdio mode for AI clients)
|
|
51
|
+
npx @hanzo/ui mcp
|
|
52
|
+
|
|
53
|
+
# Run in HTTP mode for testing
|
|
54
|
+
npx @hanzo/ui mcp --http --port 3333
|
|
55
|
+
|
|
56
|
+
# Use custom registry
|
|
57
|
+
npx @hanzo/ui mcp --registry https://my-registry.com/registry.json
|
|
58
|
+
|
|
59
|
+
# Legacy command (still works)
|
|
60
|
+
npx @hanzo/ui registry:mcp
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Available Tools
|
|
64
|
+
|
|
65
|
+
The enhanced MCP server provides comprehensive tools:
|
|
66
|
+
|
|
67
|
+
1. **Component Management**
|
|
68
|
+
- `init` - Initialize a new project with Hanzo UI
|
|
69
|
+
- `list_components` - List all available components
|
|
70
|
+
- `get_component` - Get detailed component information
|
|
71
|
+
- `get_component_source` - Get full component source code
|
|
72
|
+
- `get_component_demo` - Get demo implementation
|
|
73
|
+
- `add_component` - Get installation instructions
|
|
74
|
+
|
|
75
|
+
2. **Blocks & Patterns**
|
|
76
|
+
- `list_blocks` - List UI blocks and patterns
|
|
77
|
+
- `get_block` - Get block details
|
|
78
|
+
|
|
79
|
+
3. **Search & Discovery**
|
|
80
|
+
- `search_registry` - Search components by name/description
|
|
81
|
+
- `list_styles` - View available styles
|
|
82
|
+
- `get_installation_guide` - Complete setup guide
|
|
83
|
+
|
|
84
|
+
## Available Resources
|
|
85
|
+
|
|
86
|
+
The MCP server exposes these resources:
|
|
87
|
+
- `hanzo://components/list` - Complete component catalog
|
|
88
|
+
- `hanzo://blocks/list` - UI blocks and patterns
|
|
89
|
+
- `hanzo://installation/guide` - Installation guide
|
|
90
|
+
- `hanzo://theming/guide` - Theming documentation
|
|
91
|
+
|
|
92
|
+
## Available Prompts
|
|
93
|
+
|
|
94
|
+
AI-assisted development prompts:
|
|
95
|
+
- `component_usage` - Generate usage examples
|
|
96
|
+
- `build_page` - Build complete pages
|
|
97
|
+
- `component_composition` - Create custom components
|
|
98
|
+
- `accessibility_review` - Review accessibility
|
|
99
|
+
- `theme_customization` - Generate custom themes
|
|
100
|
+
|
|
101
|
+
## Example Interactions
|
|
102
|
+
|
|
103
|
+
Ask your AI assistant:
|
|
104
|
+
|
|
105
|
+
- "Show me all available Hanzo UI components"
|
|
106
|
+
- "How do I use the Dialog component?"
|
|
107
|
+
- "Build a login form using Hanzo UI"
|
|
108
|
+
- "Create a dashboard layout with Hanzo components"
|
|
109
|
+
- "Generate a dark theme with purple accents"
|
|
110
|
+
- "Create a custom date picker using Hanzo primitives"
|
|
111
|
+
|
|
112
|
+
## Development
|
|
113
|
+
|
|
114
|
+
To build the MCP server:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
cd pkg/ui
|
|
118
|
+
pnpm build
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
This will compile the TypeScript files and make the MCP server available.
|
|
122
|
+
|
|
123
|
+
## Registry Format
|
|
124
|
+
|
|
125
|
+
The registry follows the same format as shadcn/ui registries, with items defined as:
|
|
126
|
+
|
|
127
|
+
```json
|
|
128
|
+
{
|
|
129
|
+
"name": "button",
|
|
130
|
+
"type": "registry:component",
|
|
131
|
+
"description": "A button component with different variants.",
|
|
132
|
+
"files": [
|
|
133
|
+
{
|
|
134
|
+
"path": "components/ui/button.tsx",
|
|
135
|
+
"type": "registry:component"
|
|
136
|
+
}
|
|
137
|
+
]
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
To configure your own registry, set the `REGISTRY_URL` environment variable before running the MCP server.
|