@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,45 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// Define the file schema to match shadcn/ui's format
|
|
3
|
+
export const fileSchema = z.object({
|
|
4
|
+
path: z.string(),
|
|
5
|
+
content: z.string().optional(),
|
|
6
|
+
type: z.string(),
|
|
7
|
+
target: z.string().optional(),
|
|
8
|
+
});
|
|
9
|
+
// Registry item schema aligned with shadcn/ui format
|
|
10
|
+
export const registryItemSchema = z.object({
|
|
11
|
+
name: z.string(),
|
|
12
|
+
type: z.string(),
|
|
13
|
+
description: z.string().optional(),
|
|
14
|
+
author: z.string().optional(),
|
|
15
|
+
dependencies: z.array(z.string()).optional(),
|
|
16
|
+
devDependencies: z.array(z.string()).optional(),
|
|
17
|
+
registryDependencies: z.array(z.string()).optional(),
|
|
18
|
+
files: z.array(fileSchema).optional(),
|
|
19
|
+
meta: z.record(z.any()).optional(),
|
|
20
|
+
title: z.string().optional(),
|
|
21
|
+
cssVars: z.record(z.any()).optional(),
|
|
22
|
+
tailwind: z.record(z.any()).optional(),
|
|
23
|
+
category: z.string().optional(),
|
|
24
|
+
subcategory: z.string().optional(),
|
|
25
|
+
});
|
|
26
|
+
// Registry schema aligned with shadcn/ui format
|
|
27
|
+
export const registrySchema = z.object({
|
|
28
|
+
$schema: z.string().optional(),
|
|
29
|
+
name: z.string(),
|
|
30
|
+
homepage: z.string().optional(),
|
|
31
|
+
style: z.string().optional(),
|
|
32
|
+
items: z.array(registryItemSchema),
|
|
33
|
+
});
|
|
34
|
+
// Schema for a registry with full content
|
|
35
|
+
export const registryWithContentSchema = registrySchema.extend({
|
|
36
|
+
items: z.array(registryItemSchema.extend({
|
|
37
|
+
files: z.array(fileSchema.extend({
|
|
38
|
+
content: z.string(),
|
|
39
|
+
})),
|
|
40
|
+
})),
|
|
41
|
+
});
|
|
42
|
+
// Support CommonJS
|
|
43
|
+
if (typeof module !== 'undefined') {
|
|
44
|
+
module.exports = { fileSchema, registryItemSchema, registrySchema, registryWithContentSchema };
|
|
45
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { ThemeProvider as NextThemesProvider } from "next-themes";
|
|
4
|
+
import {} from "next-themes/dist/types";
|
|
5
|
+
const ThemeProvider = ({ children, ...props }) => (<NextThemesProvider attribute="class" {...props} value={{
|
|
6
|
+
light: 'hanzo-ui-light-theme',
|
|
7
|
+
dark: 'hanzo-ui-dark-theme'
|
|
8
|
+
}}>
|
|
9
|
+
{children}
|
|
10
|
+
</NextThemesProvider>);
|
|
11
|
+
export default ThemeProvider;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
xxs: (string | {
|
|
3
|
+
lineHeight: string;
|
|
4
|
+
})[];
|
|
5
|
+
xs: (string | {
|
|
6
|
+
lineHeight: string;
|
|
7
|
+
})[];
|
|
8
|
+
sm: (string | {
|
|
9
|
+
lineHeight: string;
|
|
10
|
+
})[];
|
|
11
|
+
base: (string | {
|
|
12
|
+
lineHeight: number;
|
|
13
|
+
})[];
|
|
14
|
+
lg: (string | {
|
|
15
|
+
lineHeight: string;
|
|
16
|
+
})[];
|
|
17
|
+
xl: (string | {
|
|
18
|
+
lineHeight: string;
|
|
19
|
+
})[];
|
|
20
|
+
'2xl': (string | {
|
|
21
|
+
lineHeight: string;
|
|
22
|
+
})[];
|
|
23
|
+
'3xl': (string | {
|
|
24
|
+
lineHeight: string;
|
|
25
|
+
})[];
|
|
26
|
+
'4xl': (string | {
|
|
27
|
+
lineHeight: string;
|
|
28
|
+
})[];
|
|
29
|
+
'5xl': (string | {
|
|
30
|
+
lineHeight: string;
|
|
31
|
+
})[];
|
|
32
|
+
'6xl': (string | {
|
|
33
|
+
lineHeight: string;
|
|
34
|
+
})[];
|
|
35
|
+
};
|
|
36
|
+
export default _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
xxs: ['0.65rem', { lineHeight: '0.8rem' }], // very fine print
|
|
3
|
+
xs: ['0.8rem', { lineHeight: '1rem' }], // fine print
|
|
4
|
+
sm: ['0.9rem', { lineHeight: '1.2rem' }], // 'standard' some news article cards (set manually when using typography-sm)
|
|
5
|
+
base: ['1rem', { lineHeight: 1.4 }],
|
|
6
|
+
lg: ['1.125rem', { lineHeight: '1.75rem' }],
|
|
7
|
+
xl: ['1.25rem', { lineHeight: '1.75rem' }],
|
|
8
|
+
'2xl': ['1.5rem', { lineHeight: '2rem' }],
|
|
9
|
+
'3xl': ['1.875rem', { lineHeight: '2.25rem' }],
|
|
10
|
+
'4xl': ['2.25rem', { lineHeight: '2.5rem' }],
|
|
11
|
+
'5xl': ['3rem', { lineHeight: '1' }],
|
|
12
|
+
'6xl': ['3.75rem', { lineHeight: '1' }],
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type ButtonProps } from '../primitives/button';
|
|
2
|
+
type SubmitServerAction = (data: any, enclosure?: any) => Promise<any>;
|
|
3
|
+
interface ButtonModalProps {
|
|
4
|
+
open: boolean;
|
|
5
|
+
onOpenChange: (b: boolean) => void;
|
|
6
|
+
buttonText: string;
|
|
7
|
+
buttonProps: ButtonProps;
|
|
8
|
+
title: string;
|
|
9
|
+
byline?: string;
|
|
10
|
+
action: SubmitServerAction;
|
|
11
|
+
actionEnclosure?: any;
|
|
12
|
+
}
|
|
13
|
+
interface ButtonModalDef {
|
|
14
|
+
Comp: React.ComponentType<ButtonModalProps>;
|
|
15
|
+
title: string;
|
|
16
|
+
props?: any;
|
|
17
|
+
byline?: string;
|
|
18
|
+
action?: SubmitServerAction;
|
|
19
|
+
actionEnclosure?: any;
|
|
20
|
+
}
|
|
21
|
+
interface ButtonDef {
|
|
22
|
+
text: string;
|
|
23
|
+
props: ButtonProps;
|
|
24
|
+
action: {
|
|
25
|
+
type: 'modal';
|
|
26
|
+
def: ButtonModalDef;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export { type ButtonDef, type SubmitServerAction, type ButtonModalProps, type ButtonModalDef, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Breakpoint } from './breakpoints';
|
|
2
|
+
type GridColumnSpec = number | {
|
|
3
|
+
columns: number;
|
|
4
|
+
gap: number;
|
|
5
|
+
};
|
|
6
|
+
interface GridDef {
|
|
7
|
+
/** Must define in ACCENDING order. */
|
|
8
|
+
at: {
|
|
9
|
+
[key in (Breakpoint)]?: GridColumnSpec;
|
|
10
|
+
};
|
|
11
|
+
mobile?: GridColumnSpec;
|
|
12
|
+
}
|
|
13
|
+
declare const COMMON_GRID_1_COL: {
|
|
14
|
+
at: {
|
|
15
|
+
xs: {
|
|
16
|
+
columns: number;
|
|
17
|
+
gap: number;
|
|
18
|
+
};
|
|
19
|
+
md: {
|
|
20
|
+
columns: number;
|
|
21
|
+
gap: number;
|
|
22
|
+
};
|
|
23
|
+
lg: {
|
|
24
|
+
columns: number;
|
|
25
|
+
gap: number;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
mobile: {
|
|
29
|
+
columns: number;
|
|
30
|
+
gap: number;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
declare const COMMON_GRID_2_COL: GridDef;
|
|
34
|
+
declare const COMMON_GRID_3_COL: GridDef;
|
|
35
|
+
declare const COMMON_GRID_4_COL: GridDef;
|
|
36
|
+
export { type GridDef as default, type GridColumnSpec, COMMON_GRID_1_COL, COMMON_GRID_2_COL, COMMON_GRID_3_COL, COMMON_GRID_4_COL };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const COMMON_GRID_1_COL = {
|
|
2
|
+
at: {
|
|
3
|
+
xs: { columns: 1, gap: 2 },
|
|
4
|
+
md: { columns: 1, gap: 3 },
|
|
5
|
+
lg: { columns: 1, gap: 6 }
|
|
6
|
+
},
|
|
7
|
+
mobile: { columns: 1, gap: 2 }
|
|
8
|
+
};
|
|
9
|
+
const COMMON_GRID_2_COL = {
|
|
10
|
+
at: {
|
|
11
|
+
xs: { columns: 1, gap: 2 },
|
|
12
|
+
md: { columns: 2, gap: 3 },
|
|
13
|
+
lg: { columns: 2, gap: 6 }
|
|
14
|
+
},
|
|
15
|
+
mobile: { columns: 1, gap: 2 }
|
|
16
|
+
};
|
|
17
|
+
const COMMON_GRID_3_COL = {
|
|
18
|
+
at: {
|
|
19
|
+
xs: { columns: 1, gap: 2 },
|
|
20
|
+
md: { columns: 3, gap: 3 },
|
|
21
|
+
lg: { columns: 3, gap: 6 }
|
|
22
|
+
},
|
|
23
|
+
mobile: { columns: 1, gap: 2 }
|
|
24
|
+
};
|
|
25
|
+
const COMMON_GRID_4_COL = {
|
|
26
|
+
at: {
|
|
27
|
+
xs: { columns: 1, gap: 2 },
|
|
28
|
+
md: { columns: 2, gap: 3 },
|
|
29
|
+
lg: { columns: 4, gap: 6 }
|
|
30
|
+
},
|
|
31
|
+
mobile: { columns: 1, gap: 2 }
|
|
32
|
+
};
|
|
33
|
+
export { COMMON_GRID_1_COL, COMMON_GRID_2_COL, COMMON_GRID_3_COL, COMMON_GRID_4_COL };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type Dimensions from './dimensions';
|
|
2
|
+
/**
|
|
3
|
+
* Defines a in image to render.
|
|
4
|
+
* ImageDef is part of {@link LinkDef}
|
|
5
|
+
*/
|
|
6
|
+
interface ImageDef {
|
|
7
|
+
/** image url */
|
|
8
|
+
src: string;
|
|
9
|
+
/** defaults to short filename */
|
|
10
|
+
alt?: string;
|
|
11
|
+
/** See next js docs */
|
|
12
|
+
sizes?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Tailwind class for svg files (usually a text-<color>).
|
|
15
|
+
* All affect 'fill' props in the svg file
|
|
16
|
+
* must be set to 'currentColor'.
|
|
17
|
+
*/
|
|
18
|
+
svgFillClass?: string;
|
|
19
|
+
/** rendered dim, unless style prop overrides
|
|
20
|
+
* in which case the file resolution should
|
|
21
|
+
* be supplied so that both Next and the browser
|
|
22
|
+
* can determine the aspect ratio
|
|
23
|
+
*/
|
|
24
|
+
dim: Dimensions;
|
|
25
|
+
rounded?: string;
|
|
26
|
+
}
|
|
27
|
+
export { type ImageDef as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type { default as AnimationDef } from './animation-def';
|
|
2
|
+
export { type Breakpoint, Breakpoints } from './breakpoints';
|
|
3
|
+
export type { default as BulletItem } from './bullet-item';
|
|
4
|
+
export type { ButtonDef, SubmitServerAction, ButtonModalProps, ButtonModalDef, } from './button-def';
|
|
5
|
+
export type { default as Dimensions } from './dimensions';
|
|
6
|
+
export type { default as GridDef, GridColumnSpec } from './grid-def';
|
|
7
|
+
export { COMMON_GRID_1_COL, COMMON_GRID_2_COL, COMMON_GRID_3_COL, COMMON_GRID_4_COL } from './grid-def';
|
|
8
|
+
export type { default as ImageDef } from './image-def';
|
|
9
|
+
export type { default as LinkDef } from './link-def';
|
|
10
|
+
export type { default as TShirtDimensions } from './tshirt-dimensions';
|
|
11
|
+
export type { default as TShirtSize } from './t-shirt-size';
|
|
12
|
+
export type { default as VideoDef } from './video-def';
|
|
13
|
+
export type { MediaStackDef, MediaTransform } from './media-stack-def';
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { VariantProps } from 'class-variance-authority';
|
|
2
|
+
import type { buttonVariants } from '../primitives/button';
|
|
3
|
+
/**
|
|
4
|
+
* A Conf object for the LinkElement primitive.
|
|
5
|
+
*/
|
|
6
|
+
interface LinkDef extends VariantProps<typeof buttonVariants> {
|
|
7
|
+
/**
|
|
8
|
+
* If the LinkElement is rendered directly and has children,
|
|
9
|
+
* the title, icon, iconAfter fields in the supplied LinkDef
|
|
10
|
+
* will be ignored.
|
|
11
|
+
*/
|
|
12
|
+
title?: string;
|
|
13
|
+
/**
|
|
14
|
+
* If the LinkElement is rendered directly and has children,
|
|
15
|
+
* the title, icon, iconAfter fields in the supplied LinkDef
|
|
16
|
+
* will be ignored.
|
|
17
|
+
*/
|
|
18
|
+
icon?: React.ReactNode;
|
|
19
|
+
/**
|
|
20
|
+
* If the LinkElement is rendered directly and has children,
|
|
21
|
+
* the title, icon, iconAfter fields in the supplied LinkDef
|
|
22
|
+
* will be ignored.
|
|
23
|
+
*/
|
|
24
|
+
iconAfter?: boolean;
|
|
25
|
+
href: string;
|
|
26
|
+
/**
|
|
27
|
+
* External links will open in a new tab (via target='_blank') by default,
|
|
28
|
+
* while internal ones will open in the same tab.
|
|
29
|
+
* @field newTab overrides these defaults in both cases.
|
|
30
|
+
* ('external' means the url starts with 'http')
|
|
31
|
+
*/
|
|
32
|
+
newTab?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* rendered as a disabled link, shows default cursor, and eats pointer events.
|
|
35
|
+
*/
|
|
36
|
+
disabled?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
*contents for description link.
|
|
39
|
+
*/
|
|
40
|
+
contents?: string;
|
|
41
|
+
childMenu?: LinkDef[];
|
|
42
|
+
groupName?: string;
|
|
43
|
+
}
|
|
44
|
+
export { type LinkDef as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type AnimationDef from './animation-def';
|
|
2
|
+
import type ImageDef from './image-def';
|
|
3
|
+
import type VideoDef from './video-def';
|
|
4
|
+
/**
|
|
5
|
+
* This will be implemented via css transforms,
|
|
6
|
+
* so will be a subset of those capabilities.
|
|
7
|
+
* Individual transforms will be added as they
|
|
8
|
+
* are needed.
|
|
9
|
+
*/
|
|
10
|
+
interface MediaTransform {
|
|
11
|
+
/** (X and Y) or [X, Y] */
|
|
12
|
+
scale?: number | number[];
|
|
13
|
+
}
|
|
14
|
+
interface MediaStackDef {
|
|
15
|
+
img?: ImageDef;
|
|
16
|
+
video?: VideoDef;
|
|
17
|
+
animation?: AnimationDef;
|
|
18
|
+
mediaTransform?: MediaTransform;
|
|
19
|
+
/** prefered order of precedence.
|
|
20
|
+
* If an type is missing, it will not be used.
|
|
21
|
+
* default (inMediaStack component): ['a', 'v', 'i']
|
|
22
|
+
* */
|
|
23
|
+
order?: ('a' | 'v' | 'i')[];
|
|
24
|
+
}
|
|
25
|
+
export type { MediaStackDef, MediaTransform };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type ConcreteDimensions = {
|
|
2
|
+
w: number;
|
|
3
|
+
h: number;
|
|
4
|
+
};
|
|
5
|
+
type TShirtDimensions = {
|
|
6
|
+
xs?: ConcreteDimensions;
|
|
7
|
+
sm?: ConcreteDimensions;
|
|
8
|
+
md: ConcreteDimensions;
|
|
9
|
+
lg?: ConcreteDimensions;
|
|
10
|
+
xl?: ConcreteDimensions;
|
|
11
|
+
};
|
|
12
|
+
export { type TShirtDimensions as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type QuantityAbbrSymbol } from './number-abbreviate';
|
|
2
|
+
interface FormatThreshold {
|
|
3
|
+
from: number;
|
|
4
|
+
use: QuantityAbbrSymbol;
|
|
5
|
+
}
|
|
6
|
+
declare const formatAndAbbreviateAsCurrency: (n: number | null, thresholds?: FormatThreshold[], roundingAdds?: number, maxDecimal?: number) => {
|
|
7
|
+
full: string;
|
|
8
|
+
result: string;
|
|
9
|
+
change: "rounded" | "none" | "abbr" | "empty";
|
|
10
|
+
};
|
|
11
|
+
export { formatAndAbbreviateAsCurrency as default, type FormatThreshold, type QuantityAbbrSymbol };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import Abbr, { ABBR_SYMBOLS_ARRAY } from './number-abbreviate';
|
|
2
|
+
const usdFormatter = Intl.NumberFormat('en-US', {
|
|
3
|
+
style: 'currency',
|
|
4
|
+
currency: 'USD',
|
|
5
|
+
minimumFractionDigits: 2,
|
|
6
|
+
});
|
|
7
|
+
const formatAsUSCurrency = (n) => {
|
|
8
|
+
let result = usdFormatter.format(n);
|
|
9
|
+
return result.endsWith('.00') ? result.slice(0, -3) : result;
|
|
10
|
+
};
|
|
11
|
+
const formatAndAbbreviateAsCurrency = (n, thresholds = [{
|
|
12
|
+
from: 1000000000,
|
|
13
|
+
use: 'M'
|
|
14
|
+
}],
|
|
15
|
+
/**
|
|
16
|
+
* Chars that will be added by ui if the number is rounded.
|
|
17
|
+
* For example, if the desired output for 10.15 is "~10.1",
|
|
18
|
+
* the tilda counts as 1 char.
|
|
19
|
+
*/
|
|
20
|
+
roundingAdds = 1, maxDecimal = 2) => {
|
|
21
|
+
if (n === null) {
|
|
22
|
+
return {
|
|
23
|
+
full: '',
|
|
24
|
+
result: '',
|
|
25
|
+
change: 'empty'
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const formatted = formatAsUSCurrency(n);
|
|
29
|
+
if (n < thresholds[0].from) {
|
|
30
|
+
return {
|
|
31
|
+
full: formatted,
|
|
32
|
+
result: formatted,
|
|
33
|
+
change: 'none'
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
// Get operative FormatThreshold pair...
|
|
37
|
+
let threshold;
|
|
38
|
+
for (let i = 0; i < thresholds.length && n >= thresholds[i].from; threshold = thresholds[i], i++) { }
|
|
39
|
+
// Build up units array to all units
|
|
40
|
+
// up to threshold.use
|
|
41
|
+
const units = [];
|
|
42
|
+
for (let i = 0; i < ABBR_SYMBOLS_ARRAY.length; i++) {
|
|
43
|
+
const current = ABBR_SYMBOLS_ARRAY[i];
|
|
44
|
+
units.push(current);
|
|
45
|
+
if (current === threshold.use) {
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const abbreviator = new Abbr(units);
|
|
50
|
+
// Use threshold.from as a guide to how many chars are available:
|
|
51
|
+
// first digit + comma = 2
|
|
52
|
+
// Possible trailing cents: '.xx'.length = 3
|
|
53
|
+
// 3 - 2 = 1
|
|
54
|
+
const charsAvail = formatAsUSCurrency(threshold.from).length + 1;
|
|
55
|
+
const abbr = abbreviator.abbreviate(n, charsAvail); // arbitrary, but good approx
|
|
56
|
+
const numStr = abbr.slice(0, -1);
|
|
57
|
+
const abbreviation = abbr.slice(-1);
|
|
58
|
+
const numerical = parseFloat(numStr);
|
|
59
|
+
const integral = Math.floor(numerical);
|
|
60
|
+
const integralString = formatAsUSCurrency(integral);
|
|
61
|
+
const commas = integralString.split(',').length - 1;
|
|
62
|
+
// minus abbr, dec point, dollar sign, and roundingAdds / tilda,
|
|
63
|
+
// (1 + 1 + 1 + roundingAdds)
|
|
64
|
+
// ("precision" does NOT include the decimal point itself,
|
|
65
|
+
// so we have to explicitly factor it in.)
|
|
66
|
+
const roundedString = numerical.toPrecision(charsAvail - commas - (3 + roundingAdds));
|
|
67
|
+
// remove trailing zeros, if any
|
|
68
|
+
const roundedNumerical = parseFloat(roundedString);
|
|
69
|
+
const roundedIntegral = Math.trunc(roundedNumerical);
|
|
70
|
+
const roundedIntegralString = formatAsUSCurrency(roundedIntegral);
|
|
71
|
+
let decimalPortion = roundedNumerical - roundedIntegral;
|
|
72
|
+
let result;
|
|
73
|
+
if (decimalPortion !== 0) {
|
|
74
|
+
// remove trailing zeros if any
|
|
75
|
+
decimalPortion = parseFloat(decimalPortion.toFixed(maxDecimal));
|
|
76
|
+
const decimalPortionString = decimalPortion.toString();
|
|
77
|
+
const afterDecimalString = decimalPortionString.slice(decimalPortionString.indexOf('.') + 1);
|
|
78
|
+
result = roundedIntegralString + '.' + afterDecimalString + abbreviation;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
result = roundedIntegralString + abbreviation;
|
|
82
|
+
}
|
|
83
|
+
// Did we lose any precision?
|
|
84
|
+
const rounded = (roundedIntegral + decimalPortion !== n);
|
|
85
|
+
return {
|
|
86
|
+
full: formatted,
|
|
87
|
+
result,
|
|
88
|
+
change: rounded ? 'rounded' : 'abbr'
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
export { formatAndAbbreviateAsCurrency as default };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import Abbr from './number-abbreviate';
|
|
2
|
+
const abbr = new Abbr(['K', 'M', 'B', 'T']);
|
|
3
|
+
const formatToMaxChar = (n, maxChars,
|
|
4
|
+
/**
|
|
5
|
+
* Chars that will be added by ui if the number is rounded.
|
|
6
|
+
* For example, if the desired output for 10.15 is "~10.1",
|
|
7
|
+
* the tilda counts as 1 char.
|
|
8
|
+
*/
|
|
9
|
+
roundingAdds = 1) => {
|
|
10
|
+
if (n === null) {
|
|
11
|
+
return {
|
|
12
|
+
result: '',
|
|
13
|
+
change: 'empty'
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
const s = n.toString();
|
|
17
|
+
if (s.length > maxChars) {
|
|
18
|
+
// Highest number that can be rounded down to an
|
|
19
|
+
// acceptable string.
|
|
20
|
+
// Decimal point, plus one decimal place = 2 chars
|
|
21
|
+
const cuttoff = Math.pow(10, maxChars - 2 - roundingAdds) - 0.05;
|
|
22
|
+
if (n < cuttoff) {
|
|
23
|
+
const intPortion = Math.floor(n);
|
|
24
|
+
const len = intPortion.toString().length;
|
|
25
|
+
// 1 is for dec point itself
|
|
26
|
+
const availDecimals = maxChars - len - 1 - roundingAdds;
|
|
27
|
+
// removes trailing zeros, if any
|
|
28
|
+
const roundedNumerical = parseFloat(n.toFixed(availDecimals));
|
|
29
|
+
return {
|
|
30
|
+
result: roundedNumerical.toString(),
|
|
31
|
+
change: 'rounded'
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
const str = abbr.abbreviate(n, maxChars);
|
|
36
|
+
const numStr = str.slice(0, -1);
|
|
37
|
+
const abbreviation = str.slice(-1);
|
|
38
|
+
const numerical = parseFloat(numStr);
|
|
39
|
+
// minus abbr, dec point, and roundingAdds / tilda,
|
|
40
|
+
// (1 + 1 + roundingAdds)
|
|
41
|
+
// ("precision" does NOT include the decimal point itself,
|
|
42
|
+
// so we have to explicitly factor it in.)
|
|
43
|
+
const roundedString = numerical.toPrecision(maxChars - (2 + roundingAdds));
|
|
44
|
+
// remove trailing zeros, if any
|
|
45
|
+
const roundedNumerical = parseFloat(roundedString);
|
|
46
|
+
return {
|
|
47
|
+
result: roundedNumerical.toString() + abbreviation,
|
|
48
|
+
change: roundedNumerical === numerical ? 'abbr' : 'rounded'
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
result: s,
|
|
54
|
+
change: 'none'
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
export default formatToMaxChar;
|