@anvilkit/puck-studio 0.0.1
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 +267 -0
- package/dist/index.cjs +4093 -0
- package/dist/index.d.cts +151 -0
- package/dist/index.d.ts +151 -0
- package/dist/index.js +4066 -0
- package/package.json +65 -0
package/README.md
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
# @anvilkit/puck-studio
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@anvilkit/puck-studio)
|
|
4
|
+
[](./LICENSE)
|
|
5
|
+
[](https://react.dev)
|
|
6
|
+
[](https://puckeditor.com)
|
|
7
|
+
|
|
8
|
+
Drop-in Shadcn UI overrides for all 15 Puck Editor surfaces — enterprise-ready, TypeScript-first.
|
|
9
|
+
|
|
10
|
+
> 中文文档请见 [docs/README.zh.md](./docs/README.zh.md)
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Introduction
|
|
15
|
+
|
|
16
|
+
Puck Editor ships with a minimal default UI that works for prototypes but falls short in enterprise products — no design system consistency, no accessible components, no Tailwind integration.
|
|
17
|
+
|
|
18
|
+
`@anvilkit/puck-studio` solves this with a single drop-in `overrides` object built on Shadcn UI, @base-ui/react primitives, and Tailwind v4. All 15 override surfaces are covered. Components are **bundled** into the package — you do not run a Shadcn CLI to copy them.
|
|
19
|
+
|
|
20
|
+
**Key value props:**
|
|
21
|
+
|
|
22
|
+
- All 15 Puck override surfaces implemented
|
|
23
|
+
- TypeScript-first with full type inference
|
|
24
|
+
- Ships ESM + CJS + `.d.ts`
|
|
25
|
+
- No Next.js at runtime — `next` is demo-only
|
|
26
|
+
- @base-ui/react and lucide-react are bundled, not peer deps
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Architecture
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
┌─────────────────────────────────────────────────────────────────────┐
|
|
34
|
+
│ <Studio /> │
|
|
35
|
+
│ props: config, data, onPublish, images?, copywritings?, aiHost? │
|
|
36
|
+
│ │
|
|
37
|
+
│ ┌──────────────────────────────────────────────────────────────┐ │
|
|
38
|
+
│ │ <Puck overrides={mergedOverrides} plugins={[aiPlugin]}> │ │
|
|
39
|
+
│ │ │ │
|
|
40
|
+
│ │ ┌────────────────────────────────────────────────────────┐ │ │
|
|
41
|
+
│ │ │ <EditorLayout /> │ │ │
|
|
42
|
+
│ │ │ │ │ │
|
|
43
|
+
│ │ │ ┌──────────────────────────────────────────────────┐ │ │ │
|
|
44
|
+
│ │ │ │ <Header /> │ │ │ │
|
|
45
|
+
│ │ │ │ back · title · undo/redo · collab · publish │ │ │ │
|
|
46
|
+
│ │ │ └──────────────────────────────────────────────────┘ │ │ │
|
|
47
|
+
│ │ │ │ │ │
|
|
48
|
+
│ │ │ ┌──────┐ ┌────────────────┐ ┌────────┐ ┌───────┐ │ │ │
|
|
49
|
+
│ │ │ │Aside │ │ Dynamic Panel │ │ Canvas │ │Fields │ │ │ │
|
|
50
|
+
│ │ │ │ │ │ │ │ │ │ │ │ │ │
|
|
51
|
+
│ │ │ │insert│ │ insert → │ │ Puck. │ │ Puck. │ │ │ │
|
|
52
|
+
│ │ │ │layer │ │ Puck.Comps │ │Preview │ │Fields │ │ │ │
|
|
53
|
+
│ │ │ │image │ │ layer → │ │ │ │ │ │ │ │
|
|
54
|
+
│ │ │ │text │ │ Puck.Outline │ │ │ │ │ │ │ │
|
|
55
|
+
│ │ │ │copil.│ │ image → │ │ │ │ │ │ │ │
|
|
56
|
+
│ │ │ │ │ │ ImageLibrary │ │ │ │ │ │ │ │
|
|
57
|
+
│ │ │ │ │ │ text → │ │ │ │ │ │ │ │
|
|
58
|
+
│ │ │ │ │ │ CopyLibrary │ │ │ │ │ │ │ │
|
|
59
|
+
│ │ │ │ │ │ copilot→ │ │ │ │ │ │ │ │
|
|
60
|
+
│ │ │ │ │ │ aiPanel │ │ │ │ │ │ │ │
|
|
61
|
+
│ │ │ └──────┘ └────────────────┘ └────────┘ └───────┘ │ │ │
|
|
62
|
+
│ │ └────────────────────────────────────────────────────────┘ │ │
|
|
63
|
+
│ └──────────────────────────────────────────────────────────────┘ │
|
|
64
|
+
└─────────────────────────────────────────────────────────────────────┘
|
|
65
|
+
|
|
66
|
+
Puck Override Surfaces (15 total)
|
|
67
|
+
──────────────────────────────────
|
|
68
|
+
Layout: header · headerActions · drawer · components · outline
|
|
69
|
+
Canvas: iframe · preview · componentOverlay · actionBar · drawerItem · componentItem
|
|
70
|
+
Fields: fields · fieldLabel · fieldTypes (11 renderers) · puck
|
|
71
|
+
|
|
72
|
+
Custom drag-drop events (window):
|
|
73
|
+
anvilkit:librarydragstart → fired on pointer-down in either library
|
|
74
|
+
anvilkit:imagedrop → fired on pointer-up with { src, clientX, clientY }
|
|
75
|
+
anvilkit:textdrop → fired on pointer-up with { text, clientX, clientY }
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Installation
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
pnpm add @anvilkit/puck-studio
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
> `next` is a devDependency used only for the local demo app. It is not included in the published bundle.
|
|
87
|
+
|
|
88
|
+
The package ships both ESM and CJS builds. No additional bundler configuration is required.
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Peer Dependencies
|
|
93
|
+
|
|
94
|
+
| Package | Version |
|
|
95
|
+
|---|---|
|
|
96
|
+
| `react` | `>=19` |
|
|
97
|
+
| `react-dom` | `>=19` |
|
|
98
|
+
| `@puckeditor/core` | `^0.21.1` |
|
|
99
|
+
| `@base-ui/react` | `^1.2.0` |
|
|
100
|
+
| `tailwindcss` | `^4` |
|
|
101
|
+
|
|
102
|
+
> `lucide-react`, `@dnd-kit/*`, `motion`, and `zustand` are **bundled** — do not install them separately.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Quick Start
|
|
107
|
+
|
|
108
|
+
### Import the CSS
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
import "@anvilkit/puck-studio/styles.css";
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Pattern 1 — Raw overrides object
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
import { puckOverrides } from "@anvilkit/puck-studio";
|
|
118
|
+
import { Puck } from "@puckeditor/core";
|
|
119
|
+
|
|
120
|
+
export default function Editor({ config, data, onPublish }) {
|
|
121
|
+
return (
|
|
122
|
+
<Puck
|
|
123
|
+
config={config}
|
|
124
|
+
data={data}
|
|
125
|
+
onPublish={onPublish}
|
|
126
|
+
overrides={puckOverrides}
|
|
127
|
+
/>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Pattern 2 — Studio convenience wrapper
|
|
133
|
+
|
|
134
|
+
```tsx
|
|
135
|
+
import { Studio } from "@anvilkit/puck-studio";
|
|
136
|
+
|
|
137
|
+
export default function Editor({ config, data, onPublish }) {
|
|
138
|
+
return (
|
|
139
|
+
<Studio
|
|
140
|
+
config={config}
|
|
141
|
+
data={data}
|
|
142
|
+
onPublish={onPublish}
|
|
143
|
+
/>
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
`Studio` renders `<Puck overrides={puckOverrides} />` with the correct CSS applied and the full editor shell (header, sidebar, canvas, fields panel).
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Library Customization
|
|
153
|
+
|
|
154
|
+
`Studio` accepts optional props to populate the Image Library and Copy Library panels with your own content.
|
|
155
|
+
|
|
156
|
+
### Image Library
|
|
157
|
+
|
|
158
|
+
```tsx
|
|
159
|
+
import type { ImagesProps, ImageItem } from "@anvilkit/puck-studio";
|
|
160
|
+
|
|
161
|
+
// Option A — replace the default picsum seed list
|
|
162
|
+
<Studio
|
|
163
|
+
config={config}
|
|
164
|
+
data={data}
|
|
165
|
+
onPublish={save}
|
|
166
|
+
images={{ seeds: ["brand", "product", "team", "office"] }}
|
|
167
|
+
/>
|
|
168
|
+
|
|
169
|
+
// Option B — provide a fully custom image list
|
|
170
|
+
const myImages: ImageItem[] = [
|
|
171
|
+
{ id: "hero-1", src: "https://cdn.example.com/hero.jpg", alt: "Hero" },
|
|
172
|
+
{ id: "logo-1", src: "https://cdn.example.com/logo.png", alt: "Logo" },
|
|
173
|
+
];
|
|
174
|
+
|
|
175
|
+
<Studio
|
|
176
|
+
config={config}
|
|
177
|
+
data={data}
|
|
178
|
+
onPublish={save}
|
|
179
|
+
images={{ items: myImages }}
|
|
180
|
+
/>
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
When `items` is provided the search input is hidden (external data is static). When only `seeds` is provided, search still generates picsum results from the query string.
|
|
184
|
+
|
|
185
|
+
### Copy Library
|
|
186
|
+
|
|
187
|
+
```tsx
|
|
188
|
+
import type { CopywritingProps, CopywritingItem } from "@anvilkit/puck-studio";
|
|
189
|
+
|
|
190
|
+
const brandCopy: CopywritingItem[] = [
|
|
191
|
+
{ category: "Headlines", label: "Brand promise", text: "Built for builders." },
|
|
192
|
+
{ category: "CTAs", label: "Primary", text: "Start for free" },
|
|
193
|
+
];
|
|
194
|
+
|
|
195
|
+
<Studio
|
|
196
|
+
config={config}
|
|
197
|
+
data={data}
|
|
198
|
+
onPublish={save}
|
|
199
|
+
copywritings={{ items: brandCopy }}
|
|
200
|
+
/>
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Omit the prop entirely to use the built-in 14-snippet default library.
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## Override Surfaces
|
|
208
|
+
|
|
209
|
+
### Layout
|
|
210
|
+
|
|
211
|
+
| Key | Component | Description |
|
|
212
|
+
|---|---|---|
|
|
213
|
+
| `header` | `EditorHeader` | Top toolbar shell |
|
|
214
|
+
| `headerActions` | `EditorHeader` | Action buttons injected into header; **must render `children`** |
|
|
215
|
+
| `drawer` | `EditorDrawer` | Left panel component list container |
|
|
216
|
+
| `components` | `EditorDrawer` | Component group list inside drawer |
|
|
217
|
+
| `outline` | `EditorOutline` | Layer tree / page outline panel |
|
|
218
|
+
|
|
219
|
+
### Canvas
|
|
220
|
+
|
|
221
|
+
| Key | Component | Description |
|
|
222
|
+
|---|---|---|
|
|
223
|
+
| `iframe` | `CanvasIframe` | Canvas iframe wrapper; injects Tailwind + Shadcn CSS vars |
|
|
224
|
+
| `preview` | `CanvasPreview` | Drag preview ghost |
|
|
225
|
+
| `componentOverlay` | `ComponentOverlay` | Selection/hover highlight overlay; must be `pointer-events-none` |
|
|
226
|
+
| `actionBar` | `ActionBar` | Per-component floating action bar (remove, duplicate, move) |
|
|
227
|
+
| `drawerItem` | `DrawerItem` | Draggable component chip in drawer; **must forward all drag refs and event props to outermost DOM element** |
|
|
228
|
+
| `componentItem` | `DrawerItem` | Alias surface for component items |
|
|
229
|
+
|
|
230
|
+
### Inspector
|
|
231
|
+
|
|
232
|
+
| Key | Component | Description |
|
|
233
|
+
|---|---|---|
|
|
234
|
+
| `fields` | `FieldWrapper` | Props panel field list wrapper |
|
|
235
|
+
| `fieldLabel` | `FieldWrapper` | Individual field label + tooltip |
|
|
236
|
+
| `fieldTypes` | `FieldTypesRegistry` | Map of all 11 field type renderers |
|
|
237
|
+
| `puck` | `EditorHeader` | Puck logo / menu slot in header |
|
|
238
|
+
|
|
239
|
+
> **`headerActions` callout:** This surface receives Puck's built-in publish button as `children`. You must render `{children}` inside your implementation or the publish button disappears (regression introduced in Puck 0.15+).
|
|
240
|
+
|
|
241
|
+
> **`drawerItem` callout:** Puck passes drag refs and pointer event handlers as props. Wrapping the root element in an extra `<div>` silently breaks drag-and-drop. Spread all drag props directly onto the outermost DOM element.
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## Contributing & Build
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
pnpm install # install all dependencies
|
|
249
|
+
pnpm dev # start Next.js demo app
|
|
250
|
+
pnpm build # run tsup → dist/
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
Build output in `dist/`:
|
|
254
|
+
|
|
255
|
+
| File | Format |
|
|
256
|
+
|---|---|
|
|
257
|
+
| `index.js` | CJS |
|
|
258
|
+
| `index.mjs` | ESM |
|
|
259
|
+
| `index.d.ts` | TypeScript declarations |
|
|
260
|
+
|
|
261
|
+
`next` is a devDependency for the demo app only. It does not appear in `src/` and is not included in the bundle.
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## License
|
|
266
|
+
|
|
267
|
+
MIT
|