next-anvil 0.3.3 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +158 -14
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,24 +1,36 @@
1
- # Anvil CLI
1
+ # Next-anvil
2
2
 
3
- CLI tool for the Anvil framework - a Next.js framework for creating admin dashboards.
3
+ A Next.js framework for building admin dashboards. Next-anvil provides schema definitions, form field components, and a CLI tool to scaffold resources.
4
4
 
5
5
  ## Installation
6
6
 
7
+ ### CLI Tool
8
+
9
+ Install globally:
10
+
7
11
  ```bash
8
- npm install -g anvil
12
+ npm install -g next-anvil
9
13
  ```
10
14
 
11
15
  Or use it locally in your project:
12
16
 
13
17
  ```bash
14
- npm install --save-dev anvil
18
+ npm install --save-dev next-anvil
19
+ ```
20
+
21
+ ### Library
22
+
23
+ Install as a dependency in your Next.js project:
24
+
25
+ ```bash
26
+ npm install next-anvil
15
27
  ```
16
28
 
17
- ## Usage
29
+ ## CLI Usage
18
30
 
19
31
  ### Create a Resource
20
32
 
21
- Generate a new resource with form and table components:
33
+ Generate resource scaffolding files:
22
34
 
23
35
  ```bash
24
36
  anvil forge:resource <name>
@@ -29,12 +41,12 @@ Example:
29
41
  anvil forge:resource product
30
42
  ```
31
43
 
32
- This will create:
33
- - `src/lib/resources/products/index.ts`
34
- - `src/lib/resources/products/form.ts`
35
- - `src/lib/resources/products/table.ts`
44
+ This creates:
45
+ - `src/lib/resources/products/index.ts` - Resource definition
46
+ - `src/lib/resources/products/form.ts` - Form schema
47
+ - `src/lib/resources/products/table.ts` - Table schema
36
48
 
37
- Run Prisma migrations:
49
+ ### Run Database Migrations
38
50
 
39
51
  ```bash
40
52
  anvil db:migrate
@@ -42,13 +54,145 @@ anvil db:migrate
42
54
 
43
55
  This executes `npx prisma migrate dev && npx prisma generate`.
44
56
 
57
+ ## Library Usage
58
+
59
+ ### Import Styles
60
+
61
+ First, import the compiled Tailwind CSS:
62
+
63
+ ```javascript
64
+ import "next-anvil/styles.css";
65
+ ```
66
+
67
+ ### Defining Field Schemas
68
+
69
+ Next-anvil provides field definition functions for building form schemas:
70
+
71
+ ```typescript
72
+ import { text, email, number, select, date, textarea } from "next-anvil/fields";
73
+ import { defineFormSchema } from "next-anvil/form";
74
+
75
+ const formSchema = defineFormSchema({
76
+ fields: {
77
+ name: text({
78
+ label: "Name",
79
+ required: true,
80
+ placeholder: "Enter name",
81
+ }),
82
+ email: email({
83
+ label: "Email",
84
+ required: true,
85
+ unique: true,
86
+ }),
87
+ age: number({
88
+ label: "Age",
89
+ min: 0,
90
+ max: 120,
91
+ }),
92
+ status: select({
93
+ label: "Status",
94
+ options: [
95
+ { value: "active", label: "Active" },
96
+ { value: "inactive", label: "Inactive" },
97
+ ],
98
+ }),
99
+ birthDate: date({
100
+ label: "Birth Date",
101
+ }),
102
+ bio: textarea({
103
+ label: "Biography",
104
+ rows: 4,
105
+ }),
106
+ },
107
+ });
108
+ ```
109
+
110
+ ### Defining Table Schemas
111
+
112
+ ```typescript
113
+ import { defineTableSchema } from "next-anvil/table";
114
+
115
+ const tableSchema = defineTableSchema({
116
+ columns: [
117
+ { name: "id", label: "ID", visible: "never" },
118
+ { name: "name", label: "Name" },
119
+ { name: "email", label: "Email" },
120
+ { name: "createdAt", label: "Created At" },
121
+ ],
122
+ });
123
+ ```
124
+
125
+ ### Defining Resources
126
+
127
+ ```typescript
128
+ import { defineResource } from "next-anvil/resource";
129
+ import form from "./form";
130
+ import table from "./table";
131
+
132
+ const productResource = defineResource({
133
+ model: "Product",
134
+ label: "Products",
135
+ form,
136
+ table,
137
+ });
138
+ ```
139
+
140
+ ### Using Field Components
141
+
142
+ Next-anvil provides React components for rendering form fields:
143
+
144
+ ```tsx
145
+ import { TextField, EmailField, NumberField } from "next-anvil/components";
146
+
147
+ function MyForm() {
148
+ const [formData, setFormData] = useState({});
149
+
150
+ return (
151
+ <form>
152
+ <TextField
153
+ fieldName="name"
154
+ fieldSchema={formSchema.fields.name}
155
+ value={formData.name}
156
+ onChange={(value) => setFormData({ ...formData, name: value })}
157
+ />
158
+ <EmailField
159
+ fieldName="email"
160
+ fieldSchema={formSchema.fields.email}
161
+ value={formData.email}
162
+ onChange={(value) => setFormData({ ...formData, email: value })}
163
+ />
164
+ </form>
165
+ );
166
+ }
167
+ ```
168
+
169
+ Available field components:
170
+ - `TextField`
171
+ - `EmailField`
172
+ - `NumberField`
173
+ - `SelectField`
174
+ - `DateField`
175
+ - `TextareaField`
176
+ - `FieldWrapper` (base wrapper component)
177
+
178
+ ### Package Exports
179
+
180
+ Next-anvil provides the following exports:
181
+
182
+ - `next-anvil/fields` - Field schema definition functions (text, email, number, select, date, textarea, hidden)
183
+ - `next-anvil/form` - Form schema utilities (`defineFormSchema`)
184
+ - `next-anvil/table` - Table schema utilities (`defineTableSchema`)
185
+ - `next-anvil/resource` - Resource definition utilities (`defineResource`)
186
+ - `next-anvil/components` - React field components
187
+ - `next-anvil/styles.css` - Compiled Tailwind CSS
188
+
45
189
  ## Requirements
46
190
 
47
191
  - Node.js 18.0.0 or higher
48
- - A Next.js project
49
- - Prisma configured (`db:migrate` commands)
192
+ - React 18.0.0 or higher
193
+ - Next.js 14.0.0 or higher
194
+ - Prisma (for database operations)
50
195
 
51
196
  ## License
52
197
 
53
198
  ISC
54
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-anvil",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "CLI tool for the Anvil framework - a Next.js framework for creating admin dashboards",
5
5
  "license": "ISC",
6
6
  "author": "Juan Sanchez <juan.sanchez@stallionstudios.net>",