nextworks 0.1.0-alpha.3 → 0.1.0-alpha.5

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/README.md CHANGED
@@ -9,10 +9,10 @@ Nextworks is a CLI that installs **modular Next.js building blocks** into your a
9
9
 
10
10
  > **Status:** early‑access alpha. Expect rough edges and breaking changes between alpha releases.
11
11
  >
12
- > In this alpha, the most reliable setup is to install **Blocks** first using the default command:
12
+ > In this alpha, the most reliable setup is to install **Blocks** first using:
13
13
  >
14
14
  > ```bash
15
- > npx nextworks add blocks
15
+ > npx nextworks add blocks --sections --templates
16
16
  > ```
17
17
  >
18
18
  > and then add **Auth Core**, **Forms**, and **Data** on top. Partial setups (e.g. Auth/Data without Blocks) may require manual tweaks and are not yet fully supported.
@@ -30,7 +30,7 @@ npx nextworks --help
30
30
  Example commands:
31
31
 
32
32
  ```bash
33
- npx nextworks add blocks
33
+ npx nextworks add blocks --sections --templates
34
34
  npx nextworks add auth-core
35
35
  npx nextworks add forms
36
36
  npx nextworks add data
@@ -52,10 +52,10 @@ From your app root:
52
52
  ### 1) Install Blocks (UI kit)
53
53
 
54
54
  ```bash
55
- npx nextworks add blocks
55
+ npx nextworks add blocks --sections --templates
56
56
  ```
57
57
 
58
- This copies by default:
58
+ This copies:
59
59
 
60
60
  - `components/ui/*` (core UI primitives)
61
61
  - `components/sections/*` (reusable sections)
@@ -148,14 +148,18 @@ Then visit:
148
148
 
149
149
  ## Advanced Blocks installs
150
150
 
151
- By default, `npx nextworks add blocks` installs **core UI primitives, sections, and templates** so the example routes under `/templates/*` work out of the box.
151
+ For a full UI kit including core primitives, sections, and templates, use:
152
+
153
+ ```bash
154
+ npx nextworks add blocks --sections --templates
155
+ ```
152
156
 
153
157
  If you want finer control:
154
158
 
155
159
  - `npx nextworks add blocks --ui-only` – install core UI primitives only (no sections/templates).
156
160
  - `npx nextworks add blocks --sections` – install core + sections only.
157
161
  - `npx nextworks add blocks --templates` – install core + templates only.
158
- - `npx nextworks add blocks --sections --templates` – same as the default (core + sections + templates).
162
+ - `npx nextworks add blocks --sections --templates` – install core + sections + templates.
159
163
 
160
164
  ---
161
165
 
@@ -168,7 +172,7 @@ You can add a short “Nextworks setup” section to your app README:
168
172
 
169
173
  1. Install and run the CLI from your Next.js app root:
170
174
 
171
- npx nextworks add blocks
175
+ npx nextworks add blocks --sections --templates
172
176
  npx nextworks add auth-core
173
177
 
174
178
  2. Copy environment variables:
@@ -8,10 +8,10 @@ npx nextworks add auth-core
8
8
 
9
9
  > **Alpha note**
10
10
  >
11
- > In this early alpha, the Auth Core kit is tested and supported on top of the default **Blocks** install. For the smoothest experience, run:
11
+ > In this early alpha, the Auth Core kit is tested and supported on top of a **Blocks** install that includes sections and templates. For the smoothest experience, run:
12
12
  >
13
13
  > ```bash
14
- > npx nextworks add blocks
14
+ > npx nextworks add blocks --sections --templates
15
15
  > npx nextworks add auth-core
16
16
  > ```
17
17
  >
@@ -2,10 +2,10 @@
2
2
 
3
3
  Follow these steps to get email/password auth (and optional GitHub OAuth) running in under 5 minutes.
4
4
 
5
- If you are using the `nextworks` CLI in your own app, the recommended alpha setup is to install Blocks first, then Auth Core:
5
+ If you are using the `nextworks` CLI in your own app, the recommended alpha setup is to install Blocks with sections and templates first, then Auth Core:
6
6
 
7
7
  ```bash
8
- npx nextworks add blocks
8
+ npx nextworks add blocks --sections --templates
9
9
  npx nextworks add auth-core
10
10
  ```
11
11
 
@@ -5,24 +5,27 @@ import { cva, type VariantProps } from "class-variance-authority";
5
5
  import { cn } from "@/lib/utils";
6
6
 
7
7
  const buttonVariants = cva(
8
- "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
8
+ "focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
9
9
  {
10
10
  variants: {
11
11
  variant: {
12
- default: "bg-primary text-primary-foreground hover:bg-primary/90",
12
+ default:
13
+ "bg-primary text-primary-foreground hover:bg-primary/90 shadow-xs",
13
14
  destructive:
14
- "bg-destructive text-destructive-foreground hover:bg-destructive/90",
15
+ "bg-destructive text-destructive-foreground hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60 shadow-xs",
15
16
  outline:
16
- "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
17
- secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
18
- ghost: "hover:bg-accent hover:text-accent-foreground",
17
+ "bg-background hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50 border shadow-xs",
18
+ secondary:
19
+ "bg-secondary text-secondary-foreground hover:bg-secondary/80 shadow-xs",
20
+ ghost:
21
+ "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
19
22
  link: "text-primary underline-offset-4 hover:underline",
20
23
  },
21
24
  size: {
22
- default: "h-10 px-4 py-2",
23
- sm: "h-9 rounded-md px-3",
24
- lg: "h-11 rounded-md px-8",
25
- icon: "h-10 w-10",
25
+ default: "h-9 px-4 py-2 has-[>svg]:px-3",
26
+ sm: "h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",
27
+ lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
28
+ icon: "size-9",
26
29
  },
27
30
  },
28
31
  defaultVariants: {
@@ -32,24 +35,88 @@ const buttonVariants = cva(
32
35
  },
33
36
  );
34
37
 
35
- export interface ButtonProps
36
- extends React.ButtonHTMLAttributes<HTMLButtonElement>,
37
- VariantProps<typeof buttonVariants> {
38
- asChild?: boolean;
39
- }
38
+ type ButtonProps = React.ComponentProps<"button"> &
39
+ VariantProps<typeof buttonVariants> & {
40
+ asChild?: boolean;
41
+ /** When true, bypasses tokenized buttonVariants so callers fully control classes */
42
+ unstyled?: boolean;
43
+ /** Opt-in: force inline CSS var styles for color/bg/border/ring */
44
+ forceInlineVars?: boolean;
45
+ };
40
46
 
41
47
  const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
42
- ({ className, variant, size, asChild = false, ...props }, ref) => {
48
+ (
49
+ {
50
+ className,
51
+ variant,
52
+ size,
53
+ asChild = false,
54
+ unstyled = false,
55
+ forceInlineVars = false,
56
+ ...props
57
+ },
58
+ ref,
59
+ ) => {
43
60
  const Comp = asChild ? Slot : "button";
61
+
62
+ // Use caller-provided style; only inject inline var-driven colors when explicitly requested
63
+ const incomingStyle =
64
+ (props.style as React.CSSProperties | undefined) ?? undefined;
65
+ const finalStyle =
66
+ forceInlineVars && !unstyled
67
+ ? {
68
+ ...incomingStyle,
69
+ color: "var(--btn-fg)",
70
+ backgroundColor: "var(--btn-bg)",
71
+ borderColor: "var(--btn-border)",
72
+ "--tw-ring-color": "var(--btn-ring)",
73
+ }
74
+ : incomingStyle;
75
+
76
+ // Only enable CSS variable hooks when explicitly requested via inline vars
77
+ // or when the caller sets any [--btn-*] classes in className.
78
+ const wantsVarHooks =
79
+ !unstyled &&
80
+ (forceInlineVars ||
81
+ (typeof className === "string" && className.includes("[--btn-")));
82
+
44
83
  return (
45
84
  <Comp
46
- className={cn(buttonVariants({ variant, size, className }))}
47
85
  ref={ref}
86
+ data-slot="button"
87
+ className={
88
+ unstyled
89
+ ? cn(
90
+ "inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap disabled:pointer-events-none disabled:opacity-50",
91
+ className,
92
+ )
93
+ : cn(
94
+ buttonVariants({ variant, size }),
95
+ wantsVarHooks && [
96
+ // Color var hooks (apply only when CSS vars are provided)
97
+ "text-[var(--btn-fg)]",
98
+ "bg-[var(--btn-bg)]",
99
+ "hover:bg-[var(--btn-hover-bg)]",
100
+ "hover:text-[var(--btn-hover-fg)]",
101
+ // explicit dark variants to compete with dark: utilities from variants like outline
102
+ "dark:bg-[var(--btn-bg)]",
103
+ "dark:hover:bg-[var(--btn-hover-bg)]",
104
+ "dark:hover:text-[var(--btn-hover-fg)]",
105
+ // Focus ring and border hooks
106
+ "focus-visible:ring-[var(--btn-ring)]",
107
+ "border-[var(--btn-border)]",
108
+ "dark:border-[var(--btn-border)]",
109
+ ],
110
+ className,
111
+ )
112
+ }
113
+ style={finalStyle}
48
114
  {...props}
49
115
  />
50
116
  );
51
117
  },
52
118
  );
119
+
53
120
  Button.displayName = "Button";
54
121
 
55
122
  export { Button, buttonVariants };
@@ -2,8 +2,7 @@ import * as React from "react";
2
2
 
3
3
  import { cn } from "@/lib/utils";
4
4
 
5
- export interface InputProps
6
- extends React.InputHTMLAttributes<HTMLInputElement> {}
5
+ export type InputProps = React.InputHTMLAttributes<HTMLInputElement>;
7
6
 
8
7
  const Input = React.forwardRef<HTMLInputElement, InputProps>(
9
8
  ({ className, type, ...props }, ref) => {
@@ -11,7 +10,10 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
11
10
  <input
12
11
  type={type}
13
12
  className={cn(
14
- "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
13
+ // Base structural + token fallbacks
14
+ "border-input bg-background ring-offset-background placeholder:text-muted-foreground focus-visible:ring-ring aria-invalid:border-destructive aria-invalid:focus-visible:ring-destructive/30 dark:aria-invalid:focus-visible:ring-destructive/40 flex h-10 w-full rounded-md border px-3 py-2 text-sm file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",
15
+ // CSS variable hooks (preset-first). When vars are unset, these are ignored and tokens above apply.
16
+ "focus-visible:ring-offset-background border-[var(--input-border)] bg-[var(--input-bg)] text-[var(--input-fg)] placeholder:text-[var(--input-placeholder)] focus-visible:ring-[var(--input-focus-ring,var(--ring))] focus-visible:ring-offset-2",
15
17
  className,
16
18
  )}
17
19
  ref={ref}
@@ -1,18 +1,24 @@
1
- "use client";
2
-
3
1
  import * as React from "react";
4
2
  import * as LabelPrimitive from "@radix-ui/react-label";
3
+ import { cva, type VariantProps } from "class-variance-authority";
5
4
 
6
5
  import { cn } from "@/lib/utils";
7
6
 
7
+ const labelVariants = cva(
8
+ "text-sm leading-none font-medium peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
9
+ );
10
+
8
11
  const Label = React.forwardRef<
9
12
  React.ElementRef<typeof LabelPrimitive.Root>,
10
- React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
13
+ React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
14
+ VariantProps<typeof labelVariants>
11
15
  >(({ className, ...props }, ref) => (
12
16
  <LabelPrimitive.Root
13
17
  ref={ref}
14
18
  className={cn(
15
- "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
19
+ labelVariants(),
20
+ // Optional color override via var; falls back to inherited color when unset
21
+ "text-[var(--label-fg)]",
16
22
  className,
17
23
  )}
18
24
  {...props}
@@ -8,17 +8,17 @@ This document explains the Blocks kit: prebuilt UI sections, templates and core
8
8
  > If you are using the `nextworks` CLI in your own app, you can install this Blocks kit by running:
9
9
  >
10
10
  > ```bash
11
- > npx nextworks add blocks
11
+ > npx nextworks add blocks --sections --templates
12
12
  > ```
13
13
  >
14
- > By default this installs **core UI primitives, sections, and page templates**, so the example templates work out of the box. The CLI will copy files into your project under `components/`, `app/templates/`, `lib/`, and `public/` as described below.
14
+ > This installs **core UI primitives, sections, and page templates**, so the example templates work out of the box. The CLI will copy files into your project under `components/`, `app/templates/`, `lib/`, and `public/` as described below.
15
15
  >
16
16
  > Advanced:
17
17
  >
18
18
  > - `npx nextworks add blocks --ui-only` → install core UI primitives only (no sections/templates).
19
19
  > - `npx nextworks add blocks --sections` → install core + sections only.
20
20
  > - `npx nextworks add blocks --templates` → install core + templates only.
21
- > - `npx nextworks add blocks --sections --templates` → same as the default (core + sections + templates).
21
+ > - `npx nextworks add blocks --sections --templates` → install core + sections + templates.
22
22
 
23
23
  What’s included
24
24
 
@@ -12,9 +12,9 @@ What the kit includes
12
12
  Install behavior
13
13
 
14
14
  > **Alpha note**
15
- > Other kits (Auth Core, Forms, Data) are currently tested and supported on top of a default Blocks install. For the smoothest experience, run `npx nextworks add blocks` before adding additional kits.
15
+ > Other kits (Auth Core, Forms, Data) are currently tested and supported on top of a Blocks install that includes sections and templates. For the smoothest experience, run `npx nextworks add blocks --sections --templates` before adding additional kits.
16
16
 
17
- - By default, running `npx nextworks add blocks` installs **core UI primitives, sections, and templates** so the example templates work out of the box.
17
+ - For a full UI kit, run `npx nextworks add blocks --sections --templates` to install **core UI primitives, sections, and templates** so the example templates work out of the box.
18
18
  - You can pass flags to control what gets installed:
19
19
  - `npx nextworks add blocks --ui-only` → core UI primitives only (no sections/templates).
20
20
  - `npx nextworks add blocks --sections` → core + sections only.
@@ -7,10 +7,10 @@ Prerequisites
7
7
  - A running PostgreSQL database and `DATABASE_URL` set in `.env`.
8
8
  - Auth kit installed and configured (NextAuth + Prisma). The Data kit relies on NextAuth session for access control.
9
9
  - In the monorepo, this is already wired up.
10
- - In your own app via the CLI, the recommended alpha setup is to install Blocks + Auth Core + Forms first, then Data:
10
+ - In your own app via the CLI, the recommended alpha setup is to install Blocks (with sections + templates) + Auth Core + Forms first, then Data:
11
11
 
12
12
  ```bash
13
- npx nextworks add blocks
13
+ npx nextworks add blocks --sections --templates
14
14
  npx nextworks add auth-core
15
15
  npx nextworks add forms
16
16
  npx nextworks add data
@@ -10,10 +10,10 @@ and is packaged with its own kit dependencies metadata.
10
10
 
11
11
  > **Alpha note**
12
12
  >
13
- > In this early alpha, the Data kit is tested and supported on top of the default **Blocks** and **Auth Core** (and Forms) installs. For the smoothest experience, run:
13
+ > In this early alpha, the Data kit is tested and supported on top of **Blocks** (with sections + templates), **Auth Core**, and **Forms**. For the smoothest experience, run:
14
14
  >
15
15
  > ```bash
16
- > npx nextworks add blocks
16
+ > npx nextworks add blocks --sections --templates
17
17
  > npx nextworks add auth-core
18
18
  > npx nextworks add forms
19
19
  > npx nextworks add data
@@ -2,10 +2,10 @@
2
2
 
3
3
  This short doc points to the minimal example that demonstrates how to use the Forms primitives with Select, Checkbox and Switch components. It also documents the ApiResult pattern for mapping server field errors into react-hook-form and points to the per-field async validation helper used in the signup form.
4
4
 
5
- > To add these examples and primitives to your own app via the CLI, the recommended alpha setup is to install Blocks first, then Forms:
5
+ > To add these examples and primitives to your own app via the CLI, the recommended alpha setup is to install Blocks with sections and templates first, then Forms:
6
6
  >
7
7
  > ```bash
8
- > npx nextworks add blocks
8
+ > npx nextworks add blocks --sections --templates
9
9
  > npx nextworks add forms
10
10
  > ```
11
11
  >
@@ -30,6 +30,7 @@ How to try it locally
30
30
  http://localhost:3000/examples/forms/basic
31
31
 
32
32
  Note: Some examples that hit the server (such as the wizard/server-action flows) assume you have a Prisma schema and database configured in your app, often via Auth Core/Data. If you haven’t set that up yet, expect those examples to need additional setup.
33
+ The Forms kit does **not** include a Prisma schema; you must define your own `prisma/schema.prisma` and run Prisma migrations if you want the server-action and wizard examples to use a real database.
33
34
 
34
35
  Tip: If you change the Prisma schema, run:
35
36
  npx prisma generate
@@ -21,15 +21,16 @@ What the kit includes
21
21
  Notes
22
22
 
23
23
  - The forms primitives are UI-only and do not require Prisma or NextAuth.
24
+ - The Forms kit does **not** ship a Prisma schema; if you use the server-action or wizard examples against a real database, you must add a `prisma/schema.prisma` in your app and run `npx prisma generate` and `npx prisma migrate dev`.
24
25
  - The wizard example assumes a basic app/api/wizard/route.ts endpoint; adjust it as needed for your project.
25
26
  - Keep this kit folder in sync with cli_manifests/forms_manifest.json.
26
27
 
27
28
  > **Alpha note**
28
29
  >
29
- > In this early alpha, Forms is tested on top of the default **Blocks** install. For the smoothest experience, install Blocks first:
30
+ > In this early alpha, Forms is tested on top of a **Blocks** install that includes sections and templates. For the smoothest experience, install Blocks first:
30
31
  >
31
32
  > ```bash
32
- > npx nextworks add blocks
33
+ > npx nextworks add blocks --sections --templates
33
34
  > npx nextworks add forms
34
35
  > ```
35
36
  >
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nextworks",
3
- "version": "0.1.0-alpha.3",
3
+ "version": "0.1.0-alpha.5",
4
4
  "description": "Nextworks CLI - Feature kits installer for Next.js apps",
5
5
  "main": "dist/index.js",
6
6
  "bin": {