@dinachi/cli 0.8.1 → 0.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.
- package/dist/index.js +79 -4
- package/package.json +5 -2
- package/templates/accordion/accordion.tsx +5 -8
- package/templates/json-render/catalog.ts +483 -0
- package/templates/json-render/components.tsx +958 -0
- package/templates/json-render/index.ts +36 -0
- package/templates/json-render/registry.ts +21 -0
- package/templates/link/index.ts +2 -0
- package/templates/link/link.tsx +94 -0
- package/templates/text/index.ts +2 -0
- package/templates/text/text.tsx +70 -0
- package/templates/tsconfig.json +2 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// Raw definitions — for composition into existing json-render projects
|
|
3
|
+
// =============================================================================
|
|
4
|
+
|
|
5
|
+
// Component + action Zod schemas (pure Zod, no framework dependency)
|
|
6
|
+
export {
|
|
7
|
+
dinachiComponentDefinitions,
|
|
8
|
+
dinachiActionDefinitions,
|
|
9
|
+
type DinachiComponentName,
|
|
10
|
+
type DinachiActionName,
|
|
11
|
+
} from "./catalog";
|
|
12
|
+
|
|
13
|
+
// Component implementations + action handlers (for custom registries)
|
|
14
|
+
export {
|
|
15
|
+
dinachiComponents,
|
|
16
|
+
dinachiActionHandlers,
|
|
17
|
+
toastManager,
|
|
18
|
+
} from "./components";
|
|
19
|
+
|
|
20
|
+
// =============================================================================
|
|
21
|
+
// Pre-built catalog + registry — convenience for new projects
|
|
22
|
+
// =============================================================================
|
|
23
|
+
|
|
24
|
+
export {
|
|
25
|
+
catalog,
|
|
26
|
+
registry,
|
|
27
|
+
handlers,
|
|
28
|
+
executeAction,
|
|
29
|
+
type DinachiCatalog,
|
|
30
|
+
} from "./registry";
|
|
31
|
+
|
|
32
|
+
// =============================================================================
|
|
33
|
+
// Type re-exports
|
|
34
|
+
// =============================================================================
|
|
35
|
+
|
|
36
|
+
export type { Spec } from "@json-render/react";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { defineCatalog } from "@json-render/core";
|
|
2
|
+
import { schema } from "@json-render/react/schema";
|
|
3
|
+
import { defineRegistry } from "@json-render/react";
|
|
4
|
+
import { dinachiComponentDefinitions, dinachiActionDefinitions } from "./catalog";
|
|
5
|
+
import { dinachiComponents, dinachiActionHandlers } from "./components";
|
|
6
|
+
|
|
7
|
+
// Pre-built catalog — convenience for projects using only Dinachi components.
|
|
8
|
+
// For composition into an existing catalog, import raw definitions from "./catalog" instead.
|
|
9
|
+
export const catalog = defineCatalog(schema, {
|
|
10
|
+
components: dinachiComponentDefinitions,
|
|
11
|
+
actions: dinachiActionDefinitions,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export type DinachiCatalog = typeof catalog;
|
|
15
|
+
|
|
16
|
+
// Pre-built registry — convenience for projects using only Dinachi components.
|
|
17
|
+
// For composition into an existing registry, import raw maps from "./components" instead.
|
|
18
|
+
export const { registry, handlers, executeAction } = defineRegistry(catalog, {
|
|
19
|
+
components: dinachiComponents,
|
|
20
|
+
actions: dinachiActionHandlers,
|
|
21
|
+
});
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
5
|
+
import { useRender } from "@base-ui/react/use-render"
|
|
6
|
+
import { cn } from "@/lib/utils"
|
|
7
|
+
|
|
8
|
+
const linkVariants = cva(
|
|
9
|
+
"transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
10
|
+
{
|
|
11
|
+
variants: {
|
|
12
|
+
variant: {
|
|
13
|
+
default:
|
|
14
|
+
"text-primary underline underline-offset-4 hover:text-primary/80",
|
|
15
|
+
muted:
|
|
16
|
+
"text-muted-foreground underline underline-offset-4 hover:text-foreground",
|
|
17
|
+
plain: "text-foreground hover:text-primary",
|
|
18
|
+
unstyled: "",
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
defaultVariants: {
|
|
22
|
+
variant: "default",
|
|
23
|
+
},
|
|
24
|
+
}
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
export interface LinkProps
|
|
28
|
+
extends React.AnchorHTMLAttributes<HTMLAnchorElement>,
|
|
29
|
+
VariantProps<typeof linkVariants> {
|
|
30
|
+
/** Render as a different element (e.g., Next.js Link, React Router Link).
|
|
31
|
+
* Accepts a ReactElement or a render function `(props, state) => ReactElement`. */
|
|
32
|
+
render?: useRender.RenderProp
|
|
33
|
+
/** Show external link indicator and add target="_blank" */
|
|
34
|
+
external?: boolean
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const Link = React.forwardRef<HTMLAnchorElement, LinkProps>(
|
|
38
|
+
(
|
|
39
|
+
{ className, variant, render, external, children, rel, target, ...props },
|
|
40
|
+
ref
|
|
41
|
+
) => {
|
|
42
|
+
const externalProps = external
|
|
43
|
+
? {
|
|
44
|
+
target: target ?? ("_blank" as const),
|
|
45
|
+
rel: rel ?? "noopener noreferrer",
|
|
46
|
+
}
|
|
47
|
+
: { target, rel }
|
|
48
|
+
|
|
49
|
+
const content = (
|
|
50
|
+
<>
|
|
51
|
+
{children}
|
|
52
|
+
{external && (
|
|
53
|
+
<>
|
|
54
|
+
<svg
|
|
55
|
+
className="inline-block h-3 w-3 shrink-0"
|
|
56
|
+
fill="none"
|
|
57
|
+
stroke="currentColor"
|
|
58
|
+
strokeWidth={2}
|
|
59
|
+
strokeLinecap="round"
|
|
60
|
+
strokeLinejoin="round"
|
|
61
|
+
viewBox="0 0 24 24"
|
|
62
|
+
aria-hidden="true"
|
|
63
|
+
>
|
|
64
|
+
<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" />
|
|
65
|
+
<polyline points="15 3 21 3 21 9" />
|
|
66
|
+
<line x1="10" y1="14" x2="21" y2="3" />
|
|
67
|
+
</svg>
|
|
68
|
+
<span className="sr-only">(opens in a new tab)</span>
|
|
69
|
+
</>
|
|
70
|
+
)}
|
|
71
|
+
</>
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
return useRender({
|
|
75
|
+
defaultTagName: 'a',
|
|
76
|
+
render,
|
|
77
|
+
ref,
|
|
78
|
+
props: {
|
|
79
|
+
className: cn(
|
|
80
|
+
linkVariants({ variant }),
|
|
81
|
+
external && "inline-flex items-center gap-1",
|
|
82
|
+
className
|
|
83
|
+
),
|
|
84
|
+
...externalProps,
|
|
85
|
+
...props,
|
|
86
|
+
children: content,
|
|
87
|
+
},
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
Link.displayName = "Link"
|
|
93
|
+
|
|
94
|
+
export { Link, linkVariants }
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
5
|
+
import { cn } from "@/lib/utils"
|
|
6
|
+
|
|
7
|
+
const textVariants = cva("", {
|
|
8
|
+
variants: {
|
|
9
|
+
variant: {
|
|
10
|
+
h1: "scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl",
|
|
11
|
+
h2: "scroll-m-20 text-3xl font-semibold tracking-tight",
|
|
12
|
+
h3: "scroll-m-20 text-2xl font-semibold tracking-tight",
|
|
13
|
+
h4: "scroll-m-20 text-xl font-semibold tracking-tight",
|
|
14
|
+
p: "leading-7",
|
|
15
|
+
large: "text-lg font-semibold",
|
|
16
|
+
small: "text-sm font-medium leading-none",
|
|
17
|
+
lead: "text-xl text-muted-foreground",
|
|
18
|
+
muted: "text-sm text-muted-foreground",
|
|
19
|
+
blockquote: "border-l-2 pl-6 italic",
|
|
20
|
+
code: "relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold",
|
|
21
|
+
span: "",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
defaultVariants: {
|
|
25
|
+
variant: "p",
|
|
26
|
+
},
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
type Variant = NonNullable<VariantProps<typeof textVariants>["variant"]>
|
|
30
|
+
|
|
31
|
+
const variantElementMap: Record<Variant, React.ElementType> = {
|
|
32
|
+
h1: "h1",
|
|
33
|
+
h2: "h2",
|
|
34
|
+
h3: "h3",
|
|
35
|
+
h4: "h4",
|
|
36
|
+
p: "p",
|
|
37
|
+
large: "p",
|
|
38
|
+
small: "p",
|
|
39
|
+
lead: "p",
|
|
40
|
+
muted: "p",
|
|
41
|
+
blockquote: "blockquote",
|
|
42
|
+
code: "code",
|
|
43
|
+
span: "span",
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface TextProps
|
|
47
|
+
extends React.HTMLAttributes<HTMLElement>,
|
|
48
|
+
VariantProps<typeof textVariants> {
|
|
49
|
+
as?: React.ElementType
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const Text = React.forwardRef<HTMLElement, TextProps>(
|
|
53
|
+
({ className, variant = "p", as, children, ...props }, ref) => {
|
|
54
|
+
const Component = as ?? variantElementMap[variant!]
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<Component
|
|
58
|
+
ref={ref}
|
|
59
|
+
className={cn(textVariants({ variant }), className)}
|
|
60
|
+
{...props}
|
|
61
|
+
>
|
|
62
|
+
{children}
|
|
63
|
+
</Component>
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
Text.displayName = "Text"
|
|
69
|
+
|
|
70
|
+
export { Text, textVariants }
|